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 B5942A0546; Thu, 16 Jul 2020 09:31:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2E8AA1BF7F; Thu, 16 Jul 2020 09:30:21 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130043.outbound.protection.outlook.com [40.107.13.43]) by dpdk.org (Postfix) with ESMTP id 1766B1BEA3 for ; Thu, 16 Jul 2020 09:30:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eWdE0epvCVksHey6gtNErO3VFqbS6Zp63rV2mL0qJl72s/YIloF7rShTJIspWSGGHoy05fWB/c0uzx4vK//GgeEx/G2ZVUkghfFh0tL6n3Z6l0w8dfSrFQmrdGkt0OKIHizbX+dKBG8LUDR+E26fCp+gQCkb8uqXb00g52qjvZ1DuN5emFouxMtVumPmt+6gxDzNPi5E2Pbvaipt3UW2V8BYTgh3T1Tm+v87QiLpinzpNpdRkQPA+Zs2QPCC5mvG3O6h9WYRrqbIBRpttTFiYtWwKpvwJAH/FS0h79bnGV23cD0NyyY1T+zLOiVhw4BIUc1ZrNrdKhYq3JMXQ28YMw== 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-SenderADCheck; bh=sYVYTMuSCBxDKYWh+u578Q24q3mmGUHppUPOeONINc0=; b=Ul9c8/UMkDF5R/RDFBBj7oSGxRITkfQa3Pvh3pzHs27cKlyBLwdU/eTRZEENu/GqXLNhG2NAlMj7divyfx0CaaixYxga5hkytILFjMTxq0Qd2Bya+/QnDrxHFWH4G5dbO1zQ82yyBb03fHcPU7q+ZKWJU3MdzCdVNcSiZpq8fgUcafjoGPShTU2qMua635ulvoZqrFoFPBCumhGGD/eQq7Mc5/yDQ3PIxEprjMPHV7ojVnhy0AG2HGTirCiwsFYSAQfn3XRMO14sr4qL7WRIWqCTzUSx1Qvjjw/CFnmF40Xm88A7ACnK2EIi9JoBv4dccySyn14iWnaRak/yU5A87A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sYVYTMuSCBxDKYWh+u578Q24q3mmGUHppUPOeONINc0=; b=Y9FF9pMiOgr675/uugQtmAeBR7E2YPY+7IrJJgLQGl7/wm3bjP4ae5Ar2lbG49YF2RypIrVyAXOUSCa1fPaB1CuZEoKkipAyYaTCJchC/4lp/eU8sOFAYhPtHglnxlmmm2DpQhzRw9uTl4c5ZU4ESYF6WXjJ/OaWbnuVoeJoC+c= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) by AM0PR05MB5329.eurprd05.prod.outlook.com (2603:10a6:208:ed::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Thu, 16 Jul 2020 07:30:15 +0000 Received: from AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::d44d:a804:c730:d2b7]) by AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::d44d:a804:c730:d2b7%2]) with mapi id 15.20.3174.026; Thu, 16 Jul 2020 07:30:15 +0000 From: Parav Pandit To: dev@dpdk.org, grive@u256.net, ferruh.yigit@intel.com, thomas@monjalon.net Cc: rasland@mellanox.com, orika@mellanox.com, matan@mellanox.com, joyce.kong@arm.com, Parav Pandit Date: Thu, 16 Jul 2020 10:29:37 +0300 Message-Id: <20200716072938.812733-9-parav@mellanox.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200716072938.812733-1-parav@mellanox.com> References: <20200610171728.89-2-parav@mellanox.com> <20200716072938.812733-1-parav@mellanox.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SN6PR16CA0057.namprd16.prod.outlook.com (2603:10b6:805:ca::34) To AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sw-mtx-036.mtx.labs.mlnx (208.176.44.194) by SN6PR16CA0057.namprd16.prod.outlook.com (2603:10b6:805:ca::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Thu, 16 Jul 2020 07:30:14 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [208.176.44.194] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8340d091-bc21-4631-5150-08d8295a1560 X-MS-TrafficTypeDiagnostic: AM0PR05MB5329: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:655; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwjcQzP7nbgOjzLTQW5UQ2VLdbZwE/ylZFyFyUhCKHw8lDIr/+HgXhAz7FcS7BJFiOwkuMegsmhoj2klXQMgKBuh1l8b/OLU65ZlINB2Y6EM/+FSRQLMbM4quDBPOYOy7za0kUGUWV46grvt8O65T7tTzNk4WDn9iZBFcp41UjL5Yku+olYElth6kkXVZzYHibejU0Quqhty9hhtq59CKCOFdESYuVx0IuMIINtMETvG5RpNiYTUFEDTN6E2ZnGXrgIDq5mt4gEl4sluJRw4h3vLNtbXDsqIcT0ME4YTDK6dNUy7C69gp+93W4XPuiLAVCNfFPj+qs7SkLMfzEcvYQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4866.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(6506007)(6666004)(16526019)(186003)(66946007)(107886003)(66556008)(26005)(8936002)(86362001)(6512007)(6486002)(52116002)(83380400001)(66476007)(5660300002)(2616005)(956004)(36756003)(8676002)(478600001)(316002)(1076003)(2906002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8FOVnUWj96QZEBD7otLLggtP5iIkFkLwPQkS6FE70CasjJdsaURD/VaHUR6WOzH/uIWIWQe9UsoJRs69Vt5X445c12nz75XFobczlsiY+CkMbzKqp7rF0k2SBXVLypMZEU356SEcI8XflAk3IzHZAmWgymZbWxEWi9q5I/HMi78SXYP7RcA3AsFQBL2PeANhbxuWAVNFutP8x9lKSA39B18lfxzvtV8VYypgZMq+nBIhEazfDxhKeeHt3Q81zgJrdM7MX/qoEDWflUQpYLfp0PUDViIy8thVHOAuDsD1/0GXdNQCXQavqRUi4h+bg2rqayQ9kJHhH5jXbXd8pmG4TmHLAZUzosf9Qie4V03OdJZPG/yHE89QzOdD/gxp1WVYIXMgnWwv3CTExfuiAnQaKSE/xfZhs6ioiWIDjh2rL4mv80MA1jD/JwahQas7ejAkkOcRtLMjtYwG8BJQ/nWMAzuozJ+vKcqH9RWWz1A6deFbgUqbw85vAsVGNS23HYod X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8340d091-bc21-4631-5150-08d8295a1560 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4866.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2020 07:30:15.7763 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0vwM5PzeVC0RpKxulBqaGdxyhVCgzo5iMiN5DmqFDdu4jch8GulRYXDp/u5MBO1+1sIFQqXdg3H39ZHgzuPAqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5329 Subject: [dpdk-dev] [PATCH v6 8/9] bus/mlx5_pci: enable net and vDPA to use mlx5 PCI bus driver 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" Enable class driver to match with the mlx5 pci devices. Migrate mlx5 net PMD and vdpa PMD to start using mlx5 common class driver. Signed-off-by: Parav Pandit Acked-by: Matan Azrad --- Changelog: v2->v3: - Avoid static table v1->v2: - Migreate API from rte_driver to rte_pci_driver --- drivers/net/mlx5/Makefile | 3 ++- drivers/net/mlx5/linux/mlx5_os.c | 1 - drivers/net/mlx5/linux/mlx5_os.h | 1 + drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 24 ++++++++++++++---------- drivers/net/mlx5/mlx5.h | 1 - drivers/vdpa/mlx5/Makefile | 3 ++- drivers/vdpa/mlx5/meson.build | 2 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 23 +++++++++++++---------- mk/rte.app.mk | 1 + 10 files changed, 35 insertions(+), 26 deletions(-) diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index a458402dc..1cea7cd07 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -45,16 +45,17 @@ CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5/linux CFLAGS += -I$(RTE_SDK)/drivers/net/mlx5 CFLAGS += -I$(RTE_SDK)/drivers/net/mlx5/linux CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5 +CFLAGS += -I$(RTE_SDK)/drivers/bus/mlx5_pci CFLAGS += -D_BSD_SOURCE CFLAGS += -D_DEFAULT_SOURCE CFLAGS += -D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-strict-prototypes LDLIBS += -lrte_common_mlx5 +LDLIBS += -lrte_bus_mlx5_pci LDLIBS += -lm LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -LDLIBS += -lrte_bus_pci # A few warnings cannot be avoided in external headers. CFLAGS += -Wno-error=cast-qual diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 2dc57b20e..b6042b7ef 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1321,7 +1321,6 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, strerror(rte_errno)); return -rte_errno; } - MLX5_ASSERT(pci_drv == &mlx5_driver); errno = 0; ibv_list = mlx5_glue->get_device_list(&ret); if (!ibv_list) { diff --git a/drivers/net/mlx5/linux/mlx5_os.h b/drivers/net/mlx5/linux/mlx5_os.h index 31add3988..695722520 100644 --- a/drivers/net/mlx5/linux/mlx5_os.h +++ b/drivers/net/mlx5/linux/mlx5_os.h @@ -15,4 +15,5 @@ enum { #define PCI_DRV_FLAGS (RTE_PCI_DRV_INTR_LSC | \ RTE_PCI_DRV_INTR_RMV | \ RTE_PCI_DRV_PROBE_AGAIN) + #endif /* RTE_PMD_MLX5_OS_H_ */ diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index e95ce0267..26699a79b 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -8,7 +8,7 @@ if not (is_linux or is_windows) subdir_done() endif -deps += ['hash', 'common_mlx5'] +deps += ['hash', 'common_mlx5', 'bus_mlx5_pci'] sources = files( 'mlx5.c', 'mlx5_ethdev.c', diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index a6a65957e..8f853844b 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -1894,16 +1895,19 @@ static const struct rte_pci_id mlx5_pci_id_map[] = { } }; -struct rte_pci_driver mlx5_driver = { - .driver = { - .name = MLX5_DRIVER_NAME +static struct rte_mlx5_pci_driver mlx5_driver = { + .dev_class = MLX5_CLASS_NET, + .pci_driver = { + .driver = { + .name = MLX5_DRIVER_NAME, + }, + .id_table = mlx5_pci_id_map, + .probe = mlx5_os_pci_probe, + .remove = mlx5_pci_remove, + .dma_map = mlx5_dma_map, + .dma_unmap = mlx5_dma_unmap, + .drv_flags = PCI_DRV_FLAGS, }, - .id_table = mlx5_pci_id_map, - .probe = mlx5_os_pci_probe, - .remove = mlx5_pci_remove, - .dma_map = mlx5_dma_map, - .dma_unmap = mlx5_dma_unmap, - .drv_flags = PCI_DRV_FLAGS, }; /* Initialize driver log type. */ @@ -1919,7 +1923,7 @@ RTE_INIT_PRIO(rte_mlx5_pmd_init, CLASS) mlx5_set_cksum_table(); mlx5_set_swp_types_table(); if (mlx5_glue) - rte_pci_register(&mlx5_driver); + rte_mlx5_pci_driver_register(&mlx5_driver); } RTE_PMD_EXPORT_NAME(net_mlx5, __COUNTER__); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 46e66eb1c..df7b5eb87 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -129,7 +129,6 @@ struct mlx5_local_data { }; extern struct mlx5_shared_data *mlx5_shared_data; -extern struct rte_pci_driver mlx5_driver; /* Dev ops structs */ extern const struct eth_dev_ops mlx5_os_dev_ops; diff --git a/drivers/vdpa/mlx5/Makefile b/drivers/vdpa/mlx5/Makefile index 8a1c2eab5..9bb5dfdbf 100644 --- a/drivers/vdpa/mlx5/Makefile +++ b/drivers/vdpa/mlx5/Makefile @@ -24,13 +24,14 @@ CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5/linux CFLAGS += -I$(RTE_SDK)/drivers/net/mlx5_vdpa CFLAGS += -I$(RTE_SDK)/lib/librte_sched CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5 +CFLAGS += -I$(RTE_SDK)/drivers/bus/mlx5_pci CFLAGS += -D_BSD_SOURCE CFLAGS += -D_DEFAULT_SOURCE CFLAGS += -D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-strict-prototypes LDLIBS += -lrte_common_mlx5 -LDLIBS += -lrte_eal -lrte_vhost -lrte_kvargs -lrte_pci -lrte_bus_pci -lrte_sched +LDLIBS += -lrte_eal -lrte_vhost -lrte_kvargs -lrte_pci -lrte_bus_mlx5_pci -lrte_sched LDLIBS += -pthread # A few warnings cannot be avoided in external headers. diff --git a/drivers/vdpa/mlx5/meson.build b/drivers/vdpa/mlx5/meson.build index 2963aad71..f4175c34e 100644 --- a/drivers/vdpa/mlx5/meson.build +++ b/drivers/vdpa/mlx5/meson.build @@ -8,7 +8,7 @@ if not is_linux endif fmt_name = 'mlx5_vdpa' -deps += ['hash', 'common_mlx5', 'vhost', 'pci', 'bus_pci', 'eal', 'sched'] +deps += ['hash', 'common_mlx5', 'vhost', 'pci', 'bus_mlx5_pci', 'eal', 'sched'] sources = files( 'mlx5_vdpa.c', 'mlx5_vdpa_mem.c', diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 205a9e4ad..5d247e0a1 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -657,7 +657,7 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) } /** - * DPDK callback to register a PCI device. + * DPDK callback to register a mlx5 PCI bus device. * * This function spawns vdpa device out of a given PCI device. * @@ -829,14 +829,17 @@ static const struct rte_pci_id mlx5_vdpa_pci_id_map[] = { } }; -static struct rte_pci_driver mlx5_vdpa_driver = { - .driver = { - .name = "mlx5_vdpa", +static struct rte_mlx5_pci_driver mlx5_vdpa_driver = { + .dev_class = MLX5_CLASS_VDPA, + .pci_driver = { + .driver = { + .name = "mlx5_vdpa", + }, + .id_table = mlx5_vdpa_pci_id_map, + .probe = mlx5_vdpa_pci_probe, + .remove = mlx5_vdpa_pci_remove, + .drv_flags = 0, }, - .id_table = mlx5_vdpa_pci_id_map, - .probe = mlx5_vdpa_pci_probe, - .remove = mlx5_vdpa_pci_remove, - .drv_flags = 0, }; RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) @@ -847,7 +850,7 @@ RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) RTE_INIT_PRIO(rte_mlx5_vdpa_init, CLASS) { if (mlx5_glue) - rte_pci_register(&mlx5_vdpa_driver); + rte_mlx5_pci_driver_register(&mlx5_vdpa_driver); } RTE_PMD_EXPORT_NAME(net_mlx5_vdpa, __COUNTER__); diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 0ce8cf541..d7c1d90e4 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -203,6 +203,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_MEMIF) += -lrte_pmd_memif _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 ifeq ($(findstring y,$(CONFIG_RTE_LIBRTE_MLX5_PMD)$(CONFIG_RTE_LIBRTE_MLX5_VDPA_PMD)),y) _LDLIBS-y += -lrte_common_mlx5 +_LDLIBS-y += -lrte_bus_mlx5_pci endif _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_VDPA_PMD) += -lrte_pmd_mlx5_vdpa -- 2.26.2