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 DE628A0C45; Mon, 14 Jun 2021 19:27:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 667694067E; Mon, 14 Jun 2021 19:27:32 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id DF1364067A for ; Mon, 14 Jun 2021 19:27:30 +0200 (CEST) Received: from [192.168.1.71] (unknown [188.170.85.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 150EE7F463; Mon, 14 Jun 2021 20:27:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 150EE7F463 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1623691650; bh=PTCjjZF5QPeU2JfTxKNKZaMFWh5LxKqn7g7BkT0V4PA=; h=Subject:To:References:From:Date:In-Reply-To; b=GDYDtXfnn74qR7a5nrP5dGG6BnBWFi3cs9Nj8yHPem1p60+VuSkiGeKr+6hYFZxZk xODi6VbW9xQirE41cRRsZ3al6V0CR+1DHnSbcke8vUNVMK8kClW0OlbD0x7U+7PZ28 Ye8s3/jjL92CHLJ6NEvoFqD6qY3gs+Ouu3BN2I0k= To: Jiawen Wu , dev@dpdk.org References: <20210602094108.1575640-1-jiawenwu@trustnetic.com> <20210602094108.1575640-4-jiawenwu@trustnetic.com> From: Andrew Rybchenko Message-ID: Date: Mon, 14 Jun 2021 20:27:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210602094108.1575640-4-jiawenwu@trustnetic.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v5 03/24] net/ngbe: support probe and remove 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 Sender: "dev" On 6/2/21 12:40 PM, Jiawen Wu wrote: > Add basic PCIe ethdev probe and remove. > > Signed-off-by: Jiawen Wu > --- > doc/guides/nics/features/ngbe.ini | 1 + > drivers/net/ngbe/ngbe_ethdev.c | 44 ++++++++++++++++++++++++++++--- > drivers/net/ngbe/ngbe_ethdev.h | 10 +++++++ > 3 files changed, 52 insertions(+), 3 deletions(-) > > diff --git a/doc/guides/nics/features/ngbe.ini b/doc/guides/nics/features/ngbe.ini > index a7a524defc..977286ac04 100644 > --- a/doc/guides/nics/features/ngbe.ini > +++ b/doc/guides/nics/features/ngbe.ini > @@ -4,6 +4,7 @@ > ; Refer to default.ini for the full list of available PMD features. > ; > [Features] > +Multiprocess aware = Y > Linux = Y > ARMv8 = Y > x86-32 = Y > diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c > index 0f1fa86fe6..83af1a6bc7 100644 > --- a/drivers/net/ngbe/ngbe_ethdev.c > +++ b/drivers/net/ngbe/ngbe_ethdev.c > @@ -3,9 +3,11 @@ > * Copyright(c) 2010-2017 Intel Corporation > */ > > +#include > #include > > #include > +#include "ngbe_ethdev.h" > > /* > * The set of PCI devices this driver supports > @@ -26,20 +28,56 @@ static const struct rte_pci_id pci_id_ngbe_map[] = { > { .vendor_id = 0, /* sentinel */ }, > }; > > +static int > +eth_ngbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) > +{ > + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); > + > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) > + return 0; > + > + rte_eth_copy_pci_info(eth_dev, pci_dev); > + > + return 0; I think it is misleading to return success when you do nothing. > +} > + > +static int > +eth_ngbe_dev_uninit(struct rte_eth_dev *eth_dev) > +{ > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) > + return 0; > + > + RTE_SET_USED(eth_dev); > + > + return 0; > +} > + > static int > eth_ngbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, > struct rte_pci_device *pci_dev) > { > - RTE_SET_USED(pci_dev); > + int retval; > + > + retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, > + sizeof(struct ngbe_adapter), > + eth_dev_pci_specific_init, pci_dev, > + eth_ngbe_dev_init, NULL); > + > + if (retval) DPDK coding style requires explicit comparison with 0. > + return retval; > > return 0; > } > > static int eth_ngbe_pci_remove(struct rte_pci_device *pci_dev) > { > - RTE_SET_USED(pci_dev); > + struct rte_eth_dev *ethdev; > > - return 0; > + ethdev = rte_eth_dev_allocated(pci_dev->device.name); > + if (!ethdev) DPDK coding style requires explicit comparison with NULL. > + return 0; > + > + return rte_eth_dev_destroy(ethdev, eth_ngbe_dev_uninit); > } > > static struct rte_pci_driver rte_ngbe_pmd = { > diff --git a/drivers/net/ngbe/ngbe_ethdev.h b/drivers/net/ngbe/ngbe_ethdev.h > index e424ff11a2..b79570dc51 100644 > --- a/drivers/net/ngbe/ngbe_ethdev.h > +++ b/drivers/net/ngbe/ngbe_ethdev.h > @@ -3,3 +3,13 @@ > * Copyright(c) 2010-2017 Intel Corporation > */ > > +#ifndef _NGBE_ETHDEV_H_ > +#define _NGBE_ETHDEV_H_ > + > +/* > + * Structure to store private data for each driver instance (for each port). > + */ > +struct ngbe_adapter { As far as I know not all compilers like empty structures. > +}; > + > +#endif /* _NGBE_ETHDEV_H_ */ >