From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A111A42C40; Tue, 6 Jun 2023 18:12:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3616C4067B; Tue, 6 Jun 2023 18:12:45 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2068.outbound.protection.outlook.com [40.107.223.68]) by mails.dpdk.org (Postfix) with ESMTP id 040C940223 for ; Tue, 6 Jun 2023 18:12:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eh+z53Zpey6shq+7UnhiNaQD36y62ZqPEqG/ch1SWLULIMlRbg4Wl2s1P8jAD0jHplrc1WN+9zW1sJAdobzmVjII63JA08hmmVT+mbVN1FMAl/bE5O3H2WgLj2R8NPQPRHplO72O19zri/c/2IRm64VTyHb/MbCtJ1ojI+Jb5Eerf0LsjoNlqNeKhij3vUZswcPVnP3ligv95ptIWhQ2vmHmvuRJF15BAwiV5UXUUhTvdrBOpW/6W3/S8fMEpZj+HHb7iCdfCLQV3bBfXkCSoSab9ZgYgAquvfbXzQ+ENN7XU7PpG0Z2yN8iMuZo9I7fspaejOWh/cuGLRz2vFFCTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J+vuxMfSqJVokY4aVrXR4+Tof43WZiGrRODdq4Fn9NI=; b=BsK46xEJo9x3WULARbzEVHvK1CWVhKFgnnvMdqhIxPoTqQSUG5y4GfdxUc75juOY5NJdkUwZ6k7zeLlOWGoT5xChc0Vu3U9w9r/HxfCJRs/vgL9tiEsTSxNVCxAt3/wscVOb7CF2cSnRGryJRzRTIAlZE0aU/2GB4WfH6hG1QHrVXjD92VuC7wlcdVHePWM6wN3QDIIst4P1odKr37X/SIGDWvxQi8Zj38slG8IHG7O/98ItcWfaSptVfOxGZF115+/kb8Thme0x4fIgxBJLAiaaW1BzBdFy8Z37K+TWiWlqlz7DvtJcjx8+jjyiaWOTm6oKu4sUlWPYK3gEyUbRHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J+vuxMfSqJVokY4aVrXR4+Tof43WZiGrRODdq4Fn9NI=; b=WhZ88ZxRcuMExaPWzv9rxo5+KYf/bZUcURNAvtR+zVysYhJ7rL5+C8ZrepfqBXisqFYezqPU7R/Z6trWZLzb4+EK672k+9w4/DNYPX/uo4CZl9VxlTXi1hAbRkmDiByd00LZRyzxoTNF8+D79vjSYs/nE8W+9KHJgvrv2fa09lg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by DM4PR12MB6110.namprd12.prod.outlook.com (2603:10b6:8:ad::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 16:12:40 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::cf07:30f7:a92a:c53b]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::cf07:30f7:a92a:c53b%4]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 16:12:40 +0000 Message-ID: Date: Tue, 6 Jun 2023 17:12:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH V4 1/5] drivers/bus: restore driver assignment at front of probing Content-Language: en-US To: "lihuisong (C)" , dev@dpdk.org, andrew.rybchenko@oktetlabs.ru Cc: thomas@monjalon.net, liudongdong3@huawei.com, huangdaode@huawei.com, fengchengwen@huawei.com References: <20220825024425.10534-1-lihuisong@huawei.com> <20221206092649.8287-1-lihuisong@huawei.com> <20221206092649.8287-2-lihuisong@huawei.com> <79192ffa-eb80-e56c-5c64-4a22374c7a1a@amd.com> <461a4536-fbbd-3848-af8d-2aa1ebaf8ccb@huawei.com> <5d06f478-6142-651b-d54b-0a3c75e9e7a0@amd.com> <80f82803-0ea0-adf6-4dd6-ccafc6643fbd@huawei.com> From: Ferruh Yigit In-Reply-To: <80f82803-0ea0-adf6-4dd6-ccafc6643fbd@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P265CA0125.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c6::11) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|DM4PR12MB6110:EE_ X-MS-Office365-Filtering-Correlation-Id: 7915c997-af53-478e-4484-08db66a8d9d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dw84DnXRpAakSG4vBxlqQsk1aMs3bJrOn8kaShghf1hwAKMJ9PvPvoqda4EKtTFOUwRWj7dyo/e84vTAdTEitdJGeXSzWNcHkO37Ci3JF5kSGFJBqrAB8OnLIBRo0HKBi3st8Vih7oSkeH8L4TjF0PyU/YZgl2D/kbC8PKTfOvXOwaKfKfi3cmbk3lyHMN5NZgL/Se+F4iSYfi1t+pzY3HbIOZShnx1Jo2ybyC3CkjSA336Y7aHufH2n2UTfISOwGwyyAv2EJXBc+HI9ssSwp970vm89OdQwJ5P9dDv+1uW8rLPlI8SPa97Kdg8CJTHgiwMnuxFPVCki9hsiRf1Xt4pA3tFWGk6vplyA2N+n/E+xXuzSDgWco8RAJxf3Gocz0lpS1g/aK6pxSp353Az1jvvHcAiERvx8NPt/1RS7Wn/YWtTJev0NAv1/5hKGwiRyi1k0aDpb8ZDlu+h1rINlqiu4GWN35JhyQylyuzKeLmwBXD7mrroZu5W9/WJhMOlvh63uxehuFXlL18fQDr8STbO9+UHKqsWWs7FdM/O4VJnEIZiBY/F2OvrQNvyXTMOMr75wEqHo79zS4z4g+ArRP5MiFZK3LWdEuZGvlG10ugtMNhsZnKw2bx0OZ7UbdtL/wF7s0N1elAXezpPqpLl1XA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199021)(6506007)(53546011)(26005)(6512007)(36756003)(83380400001)(31696002)(86362001)(38100700002)(186003)(2616005)(8676002)(4326008)(41300700001)(44832011)(66946007)(478600001)(66476007)(2906002)(316002)(8936002)(31686004)(5660300002)(6486002)(66899021)(66556008)(6666004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Q1NaUERCblVyVk1rS3FqNkVlRkJpVFd1TUpaVFluZmVNVkpIeHdpU3NsMXdo?= =?utf-8?B?cnZxSXBEOXhGb01HeWIxTWtmSTV6WnoyZWYvakVhMVg1OVlud2l3STB0blJP?= =?utf-8?B?Z1MvTUYyNGNudGdFU3poN3M0M1N4ZURJcUY5anRYZUJQM2JpYzNnelIwbGha?= =?utf-8?B?aEI0N2t0NTNocWJrOU1nTmY5VUk3SDU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mh1WWlxWkhmcCtuRzgybUUxbnU2?= =?utf-8?B?U1o0Rk1sVVhYcVFhbkJ3K01hZWg4ei9NNUZlNERYQ2QwNXVxOFlkaWp6a0t5?= =?utf-8?B?QWE4ZXdnNUpUc2RHR2s3eDRuYVRKVjEyTFY5bkRxZFdvWkJDMlpuSW9uNjdu?= =?utf-8?Q?YlcMsTfppKo62PsmCkKvGsnrF?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7915c997-af53-478e-4484-08db66a8d9d5 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 16:12:40.0199 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AJe2V1LcAUIeJLJI5n/quKJLgRTbA34EgWRQuyBCrZMr22ox8SWMxiTC+fxmNP+d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6110 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2/28/2023 2:21 AM, lihuisong (C) wrote: > > 在 2023/2/16 0:09, Ferruh Yigit 写道: >> On 1/12/2023 2:44 AM, lihuisong (C) wrote: >>> 在 2023/1/11 20:51, Ferruh Yigit 写道: >>>> On 12/6/2022 9:26 AM, Huisong Li wrote: >>>>> The driver assignment was moved back at the end of the device probing >>>>> because there is no something to use rte_driver during the phase of >>>>> probing. See commit 391797f04208 ("drivers/bus: move driver assignment >>>>> to end of probing") >>>>> >>>>> However, it is necessary for probing callback to reference rte_driver >>>>> before probing. For example, probing callback may call some APIs which >>>>> access the rte_pci_driver::driver by the device::driver pointer to get >>>>> driver information. In this case, a segment fault will occur in probing >>>>> callback if there is not this assignment. >>>>> >>>> Probing callback gets driver as parameter, so callback function can >>>> access it via 'drv->driver', is there a specific usecase that >>>> 'dev->device->driver' needs to be accessed explicitly? >>>> >>>> I assume this is related to coming patches that setting up device in >>>> testpmd event callback, but can you please clarify exact need. >>> For example, rte_eth_dev_info_get is called in this event callback to get >>> driver name. >>> > Hi Ferruh, > > Sorry for the delay. I missed this email. > Thanks for your review. >> Why 'rte_eth_dev_info_get()' is called in the event called at first place? > There is no limitation on rte_eth_dev_info_get() in event callback. > The upper layer is entirely possible to use. > After all, it is more convenient for app to use this pointer to get > driver information in a probing callback. > I think there is a logical limit in calling 'rte_eth_dev_info_get()' in NEW event callback, we may document this if it is missing. The NEW event callback is to let application do proper tasks before port addition finalized in the ethdev layer, but you are trying to call 'rte_eth_dev_info_get()' in the callback when it is not ready yet. >> This set updates multiple things to extend 'RTE_ETH_EVENT_NEW' event >> callback function support, like: >> >> - Assign device driver *before* probing completed, so that even callback >> can run 'rte_eth_dev_info_get()' >> >> - Add a new ethdev state so that port can be recognized as valid port in >> the even callback. > Yes >> - Stop forwarding implicitly in even callback in case event callback run >> while forwarding is on. > But this is a modification for tesptmd to make it work well. >> All looks to me hack/complexity to make a specific case work, which is >> make secondary *testmp* application work with attached/detached device. > It is not just a testpmd application case, but, I think, still exists in > actual case. > Because eal lib supports hotplugging device on primary and secondary > process and the communication each other when attach or detach device. > The reason why no one has ever put forward this question, I think it may > be attributed to the fact that the scene is not or rarely tested. >> And finally patch 4/5 adds port setup to testpmd event callback for this. >> >> >> I understand the intention, but I disagree with bus and ethdev level >> changes for this. > I'm just raising this issue, and we can discuss how to deal with it > together.😁 >> >> Event callback may not be only way to share port attach/detach >> information between primary and secondary, there is a MP socket and >> 'rte_mp_handle' thread to handle communication between primary and >> secondary process, this should be able to use carrying device >> information, as far as I remember this is why it is introduced at first >> place. >> >> Did you consider using MP socket for your use case? > Actually, the probing event callback called in patch 4/5 is the result > of the MP socket communication (please see hogplug_mp.c). >> >> Following is a sample usage: >> >> Primary: >> started as: >> sudo ./build/app/dpdk-testpmd --no-pci --proc-type=auto -l 0-1 >> --log-level=*:debug -- -i --num-procs=2 --proc-id=0 >> >> `` >> testpmd> show port summary all >> Number of available ports: 0 >> Port MAC Address Name Driver Status Link >> >> testpmd> port attach net_null0 >> Attaching a new port... >> dpaa: rte_dpaa_bus_parse(): Parse device name (net_null0 ) >> fslmc: rte_fslmc_parse(): Parsing dev=(net_null0 ) >> fslmc: rte_fslmc_parse(): Unknown or unsupported device (net_null0 ) >> vdev_probe_all_drivers(): Search driver to probe device net_null0 >> rte_pmd_null_probe(): Initializing pmd_null for net_null0 >> rte_pmd_null_probe(): Configure pmd_null: packet size is 64, packet copy >> is disabled >> eth_dev_null_create(): Creating null ethdev on numa socket 0 >> EAL: request: eal_dev_mp_request >> EAL: msg: bus_vdev_mp >> vdev_action(): send vdev, net_null0 >> EAL: sendmsg: bus_vdev_mp >> EAL: reply: bus_vdev_mp >> EAL: msg: eal_dev_mp_request >> Port 0 is attached. Now total ports is 1 >> Done >> >> testpmd> show port summary all >> Number of available ports: 1 >> Port MAC Address Name Driver Status Link >> 0 DE:E5:79:00:A9:68 net_null0 net_null down 10 Gbps >> >> testpmd> port detach 0 >> Port was not closed >> Removing a device... >> EAL: request: eal_dev_mp_request >> EAL: msg: eal_dev_mp_request >> eth_dev_close(): Closing null ethdev on NUMA socket 0 >> Port 0 is closed >> Device is detached >> Now total ports is 0 > Please note the log *"Now total ports is 0"*, > which indicates the port number is updated if we detached device in this > process. > Yes, as expected. >> Done >> >> testpmd> show port summary all >> Number of available ports: 0 >> Port MAC Address Name Driver Status Link >> testpmd> >> >> `` >> >> Secondary: >> started as: >> sudo ./build/app/dpdk-testpmd --no-pci --proc-type=auto -l 2-3 >> --log-level=*:debug -- -i --num-procs=2 --proc-id=1 >> >> `` >> testpmd> show port summary all >> Number of available ports: 0 >> Port MAC Address Name Driver Status Link >> >> testpmd> EAL: msg: eal_dev_mp_request >> dpaa: rte_dpaa_bus_parse(): Parse device name (net_null0 ) >> fslmc: rte_fslmc_parse(): Parsing dev=(net_null0 ) >> fslmc: rte_fslmc_parse(): Unknown or unsupported device (net_null0 ) >> EAL: request: bus_vdev_mp >> EAL: msg: bus_vdev_mp >> vdev_action(): receive vdev, net_null0 >> EAL: msg: bus_vdev_mp >> vdev_scan(): Received 1 vdevs >> vdev_probe_all_drivers(): Search driver to probe device net_null0 >> rte_pmd_null_probe(): Initializing pmd_null for net_null0 >> EAL: reply: eal_dev_mp_request >> >> testpmd> show port summary all >> Number of available ports: 1 >> Port MAC Address Name Driver Status Link >> 0 DE:E5:79:00:A9:68 net_null0 net_null down 10 Gbps >> >> testpmd> EAL: msg: eal_dev_mp_request >> dpaa: rte_dpaa_bus_parse(): Parse device name (net_null0 ) >> fslmc: rte_fslmc_parse(): Parsing dev=(net_null0 ) >> fslmc: rte_fslmc_parse(): Unknown or unsupported device (net_null0 ) >> eth_dev_close(): Closing null ethdev on NUMA socket 4294967295 >> Port 0 is closed >> EAL: reply: eal_dev_mp_request > But the port number in this process does not be updated after finishing > the destroy event. > That's the problem. > Please see following command output, it says "Number of available ports: 0", so that shows port number is updated after destroy event, isn't it? >> testpmd> show port summary all >> Number of available ports: 0 >> Port MAC Address Name Driver Status Link >> testpmd> >> `` >> >> >> .