From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0FE6CA0487 for ; Wed, 3 Jul 2019 10:44:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 43F061D9E; Wed, 3 Jul 2019 10:44:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id D7DE3235 for ; Wed, 3 Jul 2019 10:44:42 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x638e9Lu027006; Wed, 3 Jul 2019 01:44:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=UnhVS9hylVSp0JsnPuJDrs+0YvRUrJNzxjNvciHOeQE=; b=FmfG8ngQas7MfWA9KdgjuKScEFNT50pnTUc8OjzBHVKIsR6GTd2dtrBTn7NzoDVx67MF ZWqdI3MAkA8zKLaYJ79eCavcoVc+gLSmpetJSBGhoEm6iJOOLWoOPea0EErpZNHDpXTv 2tqt0krbuiMs0nkmuT9CFb3YNBqvaJKq88U8ci04lDz6A2SPXcPRcMH3Ypqsv8NRfMiA RJA8Z9FykRHWCYwBBULuMjOCh6lP2WBFFH6tgBwTzS8v8TzbPsjFR+mLQEfXqIjWneT6 jxm5VVsdRNqLGGVMosVXgdrYl68nyO8XSNDYnMixhasA+j7FwdUd/TeMVTEWin3rU7ee tg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2tgrv181yx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 03 Jul 2019 01:44:41 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 3 Jul 2019 01:43:15 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 3 Jul 2019 01:43:15 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 2E7B43F703F; Wed, 3 Jul 2019 01:43:13 -0700 (PDT) From: To: , Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K , "Anatoly Burakov" Date: Wed, 3 Jul 2019 14:11:48 +0530 Message-ID: <20190703084244.33553-3-jerinj@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190703084244.33553-1-jerinj@marvell.com> References: <20190630180609.36705-1-jerinj@marvell.com> <20190703084244.33553-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-03_03:, , signatures=0 Subject: [dpdk-dev] [PATCH v3 02/58] net/octeontx2: add ethdev probe and remove X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Jerin Jacob add basic PCIe ethdev probe and remove. Signed-off-by: Jerin Jacob Signed-off-by: Nithin Dabilpuram --- drivers/net/octeontx2/Makefile | 11 +++- drivers/net/octeontx2/meson.build | 14 ++++- drivers/net/octeontx2/otx2_ethdev.c | 93 +++++++++++++++++++++++++++++ drivers/net/octeontx2/otx2_ethdev.h | 27 +++++++++ 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 drivers/net/octeontx2/otx2_ethdev.h diff --git a/drivers/net/octeontx2/Makefile b/drivers/net/octeontx2/Makefile index 9c467352f..8999c38d1 100644 --- a/drivers/net/octeontx2/Makefile +++ b/drivers/net/octeontx2/Makefile @@ -15,6 +15,14 @@ CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx2 CFLAGS += -I$(RTE_SDK)/drivers/net/octeontx2 CFLAGS += -O3 +ifneq ($(CONFIG_RTE_ARCH_64),y) +CFLAGS += -Wno-int-to-pointer-cast +CFLAGS += -Wno-pointer-to-int-cast +ifeq ($(CONFIG_RTE_TOOLCHAIN_ICC),y) +CFLAGS += -diag-disable 2259 -flax-vector-conversions +endif +endif + EXPORT_MAP := rte_pmd_octeontx2_version.map LIBABIVER := 1 @@ -25,6 +33,7 @@ LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX2_PMD) += \ otx2_ethdev.c -LDLIBS += -lrte_common_octeontx2 -lrte_mempool_octeontx2 +LDLIBS += -lrte_common_octeontx2 -lrte_mempool_octeontx2 -lrte_eal +LDLIBS += -lrte_ethdev -lrte_bus_pci include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/octeontx2/meson.build b/drivers/net/octeontx2/meson.build index 0d0ca32da..db375f33b 100644 --- a/drivers/net/octeontx2/meson.build +++ b/drivers/net/octeontx2/meson.build @@ -6,4 +6,16 @@ sources = files( 'otx2_ethdev.c', ) -deps += ['common_octeontx2', 'mempool_octeontx2'] +deps += ['bus_pci', 'common_octeontx2', 'mempool_octeontx2'] + +extra_flags = [] +# This integrated controller runs only on a arm64 machine, remove 32bit warnings +if not dpdk_conf.get('RTE_ARCH_64') + extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast'] +endif + +foreach flag: extra_flags + if cc.has_argument(flag) + cflags += flag + endif +endforeach diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index d26535dee..05fa8988e 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -1,3 +1,96 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(C) 2019 Marvell International Ltd. */ + +#include +#include +#include + +#include "otx2_ethdev.h" + +static int +otx2_eth_dev_init(struct rte_eth_dev *eth_dev) +{ + RTE_SET_USED(eth_dev); + + return -ENODEV; +} + +static int +otx2_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close) +{ + RTE_SET_USED(eth_dev); + RTE_SET_USED(mbox_close); + + return -ENODEV; +} + +static int +nix_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 = otx2_eth_dev_uninit(eth_dev, true); + if (rc) + return rc; + + rte_eth_dev_pci_release(eth_dev); + } + + /* Nothing to be done for secondary processes */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + return 0; +} + +static int +nix_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 otx2_eth_dev), + otx2_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_nix_map[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_PF) + }, + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_RVU_VF) + }, + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, + PCI_DEVID_OCTEONTX2_RVU_AF_VF) + }, + { + .vendor_id = 0, + }, +}; + +static struct rte_pci_driver pci_nix = { + .id_table = pci_nix_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA | + RTE_PCI_DRV_INTR_LSC, + .probe = nix_probe, + .remove = nix_remove, +}; + +RTE_PMD_REGISTER_PCI(net_octeontx2, pci_nix); +RTE_PMD_REGISTER_PCI_TABLE(net_octeontx2, pci_nix_map); +RTE_PMD_REGISTER_KMOD_DEP(net_octeontx2, "vfio-pci"); diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h new file mode 100644 index 000000000..fd01a3254 --- /dev/null +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell International Ltd. + */ + +#ifndef __OTX2_ETHDEV_H__ +#define __OTX2_ETHDEV_H__ + +#include + +#include + +#include "otx2_common.h" +#include "otx2_dev.h" +#include "otx2_irq.h" +#include "otx2_mempool.h" + +struct otx2_eth_dev { + OTX2_DEV; /* Base class */ +} __rte_cache_aligned; + +static inline struct otx2_eth_dev * +otx2_eth_pmd_priv(struct rte_eth_dev *eth_dev) +{ + return eth_dev->data->dev_private; +} + +#endif /* __OTX2_ETHDEV_H__ */ -- 2.21.0