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 AACA8A0524; Wed, 2 Jun 2021 11:40:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC72E410FB; Wed, 2 Jun 2021 11:39:45 +0200 (CEST) Received: from smtpbg511.qq.com (smtpbg511.qq.com [203.205.250.109]) by mails.dpdk.org (Postfix) with ESMTP id BA397410D7 for ; Wed, 2 Jun 2021 11:39:41 +0200 (CEST) X-QQ-mid: bizesmtp32t1622626774tvv4n847 Received: from wxdbg.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Wed, 02 Jun 2021 17:39:34 +0800 (CST) X-QQ-SSF: 01400000000000D0E000B00A0000000 X-QQ-FEAT: sHM4pNkI5yT4zdy8QjEprIcJ+428Usbmz1kZ9iWhhhMZGdKd9pgPkAaOsDskB 5DXy3qcUz6pC9W4yCj+oriJkOpkLmCfOf2Kkt8GWzuz7X76bZXd52heM6bkFyROVSBBeTn2 VnLUh2gIsGt0QVFg6CvLozAywLb4Ih8gK+nrYNRbR7+wGBhjMu5BEyMPbdau6pkX2XVcUn/ cw6aF2NJN3pCAREBKP6yaoEcLSIw1z+3aNpmhi2B5CjNZfBmM/zwaYJYXncQCx8U37jzSGN B/QvJNyjBRkRcxvTchUN+Gqpx8XbUxjno0ugZdm+/sBRWBuAOIvoGqC8DVxlpiy3W5U6UJw RO/fF3lI0Yt5hE5v4HJUOG+vLuDow== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Wed, 2 Jun 2021 17:40:47 +0800 Message-Id: <20210602094108.1575640-4-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210602094108.1575640-1-jiawenwu@trustnetic.com> References: <20210602094108.1575640-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [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" 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; +} + +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) + 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) + 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 { +}; + +#endif /* _NGBE_ETHDEV_H_ */ -- 2.27.0