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 4DE7D42219; Fri, 1 Sep 2023 04:31:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48DBB402A0; Fri, 1 Sep 2023 04:31:25 +0200 (CEST) Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by mails.dpdk.org (Postfix) with ESMTP id DB1754014F for ; Fri, 1 Sep 2023 04:31:22 +0200 (CEST) X-QQ-mid: bizesmtp81t1693535464tsbcfvvf Received: from steven.localdomain ( [183.81.182.182]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 01 Sep 2023 10:31:03 +0800 (CST) X-QQ-SSF: 01400000000000D0F000000A0000000 X-QQ-FEAT: 3M0okmaRx3gPnSs+m6Xxuvf4Ly+vRY37p4TDFklPWkkB6JQQcpD2pYxVCHyN9 i3S/ycwMQgNoZ/nQC9Gi0yHdWSSFVZww5LtjgMrNfmy+a5rnZFh2SmBtuAGiFAN2nl6AVca Zldcn4+kLakDkLDNYQunSp2WppaiJHG5KABg0Il1M9NefIu6mgf4n84KtydZ1MjZPwnFdSm VqbSyE6ocdkEMTgMj4HhrTsma0eFc9Sr8G+rpm0RUBCPOHdLKqp3qW7N9xegEwCZ0nfoyaC gWFsYQjqk8KqMBOuahXOmEpEc5kZaPxdLHz60g6ytPMvpM7ivdf1TrL5a9eeGWts2/ZEv9m XMb/aEcvu0bLy3pGx4EWNqX0HkmVBtL5JfB1p4TenSf5hAXoz3YI/A4KfBN5bdYFVab8Mo6 nCXjFPZJ1+RtMAxA1wRsqw== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 8259806842091117836 From: Wenbo Cao To: Wenbo Cao , Anatoly Burakov Cc: dev@dpdk.org, ferruh.yigit@amd.com, thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru, yaojun@mucse.com Subject: [PATCH v6 2/8] net/rnp: add ethdev probe and remove Date: Fri, 1 Sep 2023 02:30:44 +0000 Message-Id: <20230901023050.40893-3-caowenbo@mucse.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230901023050.40893-1-caowenbo@mucse.com> References: <20230901023050.40893-1-caowenbo@mucse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:mucse.com:qybglogicsvrgz:qybglogicsvrgz5a-0 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 Add basic PCIe ethdev probe and remove. Signed-off-by: Wenbo Cao --- drivers/net/rnp/rnp.h | 13 ++++++ drivers/net/rnp/rnp_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 drivers/net/rnp/rnp.h diff --git a/drivers/net/rnp/rnp.h b/drivers/net/rnp/rnp.h new file mode 100644 index 0000000000..76d281cc0a --- /dev/null +++ b/drivers/net/rnp/rnp.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Mucse IC Design Ltd. + */ +#ifndef __RNP_H__ +#define __RNP_H__ + +#define PCI_VENDOR_ID_MUCSE (0x8848) +#define RNP_DEV_ID_N10G (0x1000) + +struct rnp_eth_port { +} __rte_cache_aligned; + +#endif /* __RNP_H__ */ diff --git a/drivers/net/rnp/rnp_ethdev.c b/drivers/net/rnp/rnp_ethdev.c index 9ce3c0b497..390f2e7743 100644 --- a/drivers/net/rnp/rnp_ethdev.c +++ b/drivers/net/rnp/rnp_ethdev.c @@ -1,3 +1,86 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(C) 2023 Mucse IC Design Ltd. */ + +#include +#include +#include + +#include "rnp.h" + +static int +rnp_eth_dev_init(struct rte_eth_dev *eth_dev) +{ + RTE_SET_USED(eth_dev); + + return -ENODEV; +} + +static int +rnp_eth_dev_uninit(struct rte_eth_dev *eth_dev) +{ + RTE_SET_USED(eth_dev); + + return -ENODEV; +} + +static int +rnp_pci_remove(struct rte_pci_device *pci_dev) +{ + struct rte_eth_dev *eth_dev; + int rc; + + eth_dev = rte_eth_dev_allocated(pci_dev->device.name); + + if (eth_dev) { + /* Cleanup eth dev */ + rc = rte_eth_dev_pci_generic_remove(pci_dev, + rnp_eth_dev_uninit); + if (rc) + return rc; + } + /* Nothing to be done for secondary processes */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + return 0; +} + +static int +rnp_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) +{ + int rc; + + RTE_SET_USED(pci_drv); + + rc = rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct rnp_eth_port), + rnp_eth_dev_init); + + /* On error on secondary, recheck if port exists in primary or + * in mid of detach state. + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY && rc) + if (!rte_eth_dev_allocated(pci_dev->device.name)) + return 0; + return rc; +} + +static const struct rte_pci_id pci_id_rnp_map[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_MUCSE, RNP_DEV_ID_N10G) + }, + { + .vendor_id = 0, + }, +}; + +static struct rte_pci_driver rte_rnp_pmd = { + .id_table = pci_id_rnp_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, + .probe = rnp_pci_probe, + .remove = rnp_pci_remove, +}; + +RTE_PMD_REGISTER_PCI(net_rnp, rte_rnp_pmd); +RTE_PMD_REGISTER_PCI_TABLE(net_rnp, pci_id_rnp_map); +RTE_PMD_REGISTER_KMOD_DEP(net_rnp, "igb_uio | uio_pci_generic | vfio-pci"); -- 2.27.0