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 45966A0350; Sun, 21 Jun 2020 21:12:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D51C1C138; Sun, 21 Jun 2020 21:12:30 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2082.outbound.protection.outlook.com [40.107.22.82]) by dpdk.org (Postfix) with ESMTP id 662FC1C194 for ; Sun, 21 Jun 2020 21:12:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NjMILwdLvSnNSIeoADXji5rcHFL4CIF6qDKH67m6+v9O85d8ovDaKLpkFfS+8OzRy0J46kR7SHzafawm2j+CTJIpqKP0PQZQU2WLOmnPvehtpwmjhSVPYv6iJkqMJ0peykZ5wuXFZ7UeO4oXLIGEVEHYCyVd63y2B1DkMfdXkkMIlSYJJoH7AifSvYXF53SXCj3BaJrDoKWb9tLKGHinWVhUIAYVX8pyGeRSg/4tL8BWv8htaTYNg17d2OMWs9cI5Z0XDPdND8dA/8jbd07/MxIvkRCnCaVZN5MtqSFOwBhYk9NxV9S7bQJZOQ43kdr6aelGHsKJfYTbud3PkAPmfw== 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=WMsPSCH0zy61Bx85uR2lTrWC5G2m13RL5S7zyyozP3s=; b=dvRhm138tX9bw6vZmHfA5yhXNWE640CjMSc+cHQDOEQ8syDYrYtE7F6Nam+aJRfqEuRXEn5aAKtZsfA1NA+e48l4Aom/t4A2WpxT42oQUHBwS1oPQ3/iBVjcJZdkIJnLnOGRqrSf9YUnq8h2Ger92DMzYKTm46ap3QVI2u+UrLYtI/1G+iz2y4wXa1fhO+isr8lLFxartjZOEV2U8deGR1xKK4VkFqt1+GALZRhbX+AJ1oBpPOWxAuzTPjyz+ZL1Rnj8fVbqtFAeAMUUkaEc4KlBipp97OliXXKT0evovUHe7WhimTGv3kStTl2YRI6CPKB7Zysl1d0Gcntp1sUaOg== 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=WMsPSCH0zy61Bx85uR2lTrWC5G2m13RL5S7zyyozP3s=; b=EQT/FjrJshnwnjZo4jVrB/UG4PdFcXD16To2/hMRfrxqlM5dz72pKrcvISe1b7ndj4Q7au6tI7hBPW81I/Z6rGIFxvwuGNUFMiak+REVVfMuhkVskkOAa0sdzXE+YfuKSafIF2FoBXU/DEyzUxFsFa7XcoHQCtHG27B1l4LqsoE= Authentication-Results: u256.net; dkim=none (message not signed) header.d=none;u256.net; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) by AM0PR05MB6307.eurprd05.prod.outlook.com (2603:10a6:208:145::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Sun, 21 Jun 2020 19:12:23 +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.3109.026; Sun, 21 Jun 2020 19:12:23 +0000 From: Parav Pandit To: grive@u256.net, ferruh.yigit@intel.com, thomas@monjalon.net, dev@dpdk.org Cc: orika@mellanox.com, matan@mellanox.com, Parav Pandit Date: Sun, 21 Jun 2020 19:11:57 +0000 Message-Id: <20200621191200.28120-4-parav@mellanox.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200621191200.28120-1-parav@mellanox.com> References: <20200610171728.89-2-parav@mellanox.com> <20200621191200.28120-1-parav@mellanox.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM6PR02CA0105.namprd02.prod.outlook.com (2603:10b6:5:1f4::46) 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 DM6PR02CA0105.namprd02.prod.outlook.com (2603:10b6:5:1f4::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Sun, 21 Jun 2020 19:12:21 +0000 X-Mailer: git-send-email 2.25.4 X-Originating-IP: [208.176.44.194] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 25ccd952-9466-4029-9e4a-08d816170707 X-MS-TrafficTypeDiagnostic: AM0PR05MB6307: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 04410E544A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ++R9hc+4I8mE4thUkBeSjFUWZX7lOVeB1AZM1pL5+GVRSxA1qbPOz5PSdGJYiLnImgBm6eUAsMHiouDb1gYxbSMMCvB+cqIpQaK7Iy3tT18oPDBI2XtJ6yck8mhCFvtRiwUY/CUM848MMIz1Kz6tuWnO87o0IfOUMYi0qfQP3VM8vW8Z5dnj+hmOjbhGFHDk6ZztAXCgfUpzY5Py3Wf28Dlhjvrj5iuRNVWtnyXl1QoBJCoPtF2vfw0kA4a2roSOc4x/K13h/p2+hxKkMDkmkjGggYilF+Lz8AvS8f43WcnMWuHkpkMWWWpIwl2VKUQTORxxvJvPHbnp/aHwhv1uwA== 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)(39860400002)(396003)(346002)(136003)(36756003)(66556008)(66476007)(6506007)(4326008)(5660300002)(6486002)(66946007)(26005)(186003)(107886003)(16526019)(316002)(86362001)(6512007)(1076003)(478600001)(2616005)(6666004)(8676002)(83380400001)(956004)(52116002)(2906002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sJBpL9wZ7GEbNneL9sCG3ybtXpU1cy+udK3a6vYaX8gXueBDPNsAe+5Jb1pzcvD+w83Y+wiL7rhG21xNsCgb0HofLjItfa53ReKxir2SdU72LB086tbIWeVXBBuXzfu6qGdVtX8+NgfyPbnBV0uhY2RI2FdCCjJqHEq3+muCd7FvU9Edxgh1UuK/e2eVrOGq/7hIPtkOxSvPlhLz1mIaIv3w5mc/BQxHihOaKZHXFpzAKLKluHp01e917PurisztnY4TAcs0/AfoHjt7cFDjiriGotDko9nCsgG7HT1psCza+4a/goN0C+vGdF0MHoW5kmz3TOfU9i9Faaa6IPJWlvtZx6fsSTRdt2zSw16hjHlxJdg6kHS3LNebB09d6IxjA9jLccgGMaAYGeICgMOS1iffIls+K47Eh8X6uyje/PRK2UQVvK6SAps1Sne7Ekr07E3bV2yCCLlSNPzteGJ0sOlueAFeizhJtBYfB6qUQzXDvjzrW0o+i9Nbr+y12U5U X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25ccd952-9466-4029-9e4a-08d816170707 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2020 19:12:23.4182 (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: UfCbFRHRK4faOvowQaDBnO6uDvuPw/5iK7TldoMvM+Gdleqv3kBiqPBg4oJ1J25yoL9nQqkCxJjhYY9G7CaHqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6307 Subject: [dpdk-dev] [PATCH v2 3/6] bus/mlx5_pci: add mlx5 PCI bus 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" Add mlx5 PCI bus which enables multiple mlx5 drivers to bind to single pci device. Signed-off-by: Parav Pandit --- Changelog: v1->v2: - Address comments from Thomas and Gaetan - Inheriting ret_pci_driver instead of rte_driver - Added design and description of the mlx5_pci bus --- config/common_base | 6 ++ config/defconfig_arm64-bluefield-linuxapp-gcc | 6 ++ drivers/bus/meson.build | 2 +- drivers/bus/mlx5_pci/Makefile | 47 +++++++++++ drivers/bus/mlx5_pci/meson.build | 6 ++ drivers/bus/mlx5_pci/mlx5_pci_bus.c | 14 ++++ drivers/bus/mlx5_pci/rte_bus_mlx5_pci.h | 84 +++++++++++++++++++ .../bus/mlx5_pci/rte_bus_mlx5_pci_version.map | 5 ++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/mlx5_pci/Makefile create mode 100644 drivers/bus/mlx5_pci/meson.build create mode 100644 drivers/bus/mlx5_pci/mlx5_pci_bus.c create mode 100644 drivers/bus/mlx5_pci/rte_bus_mlx5_pci.h create mode 100644 drivers/bus/mlx5_pci/rte_bus_mlx5_pci_version.map diff --git a/config/common_base b/config/common_base index c7d5c7321..f75b333f9 100644 --- a/config/common_base +++ b/config/common_base @@ -366,6 +366,12 @@ CONFIG_RTE_LIBRTE_IGC_DEBUG_TX=n CONFIG_RTE_LIBRTE_MLX4_PMD=n CONFIG_RTE_LIBRTE_MLX4_DEBUG=n +# +# Compile Mellanox PCI BUS for ConnectX-4, ConnectX-5, +# ConnectX-6 & BlueField (MLX5) PMD +# +CONFIG_RTE_LIBRTE_MLX5_PCI_BUS=n + # # Compile burst-oriented Mellanox ConnectX-4, ConnectX-5, # ConnectX-6 & BlueField (MLX5) PMD diff --git a/config/defconfig_arm64-bluefield-linuxapp-gcc b/config/defconfig_arm64-bluefield-linuxapp-gcc index b49653881..15ade7ebc 100644 --- a/config/defconfig_arm64-bluefield-linuxapp-gcc +++ b/config/defconfig_arm64-bluefield-linuxapp-gcc @@ -14,5 +14,11 @@ CONFIG_RTE_CACHE_LINE_SIZE=64 CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n CONFIG_RTE_LIBRTE_VHOST_NUMA=n +# +# Compile Mellanox PCI BUS for ConnectX-4, ConnectX-5, +# ConnectX-6 & BlueField (MLX5) PMD +# +CONFIG_RTE_LIBRTE_MLX5_PCI_BUS=n + # PMD for ConnectX-5 CONFIG_RTE_LIBRTE_MLX5_PMD=y diff --git a/drivers/bus/meson.build b/drivers/bus/meson.build index 80de2d91d..b1381838d 100644 --- a/drivers/bus/meson.build +++ b/drivers/bus/meson.build @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev', 'vmbus'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'mlx5_pci', 'vdev', 'vmbus'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@' diff --git a/drivers/bus/mlx5_pci/Makefile b/drivers/bus/mlx5_pci/Makefile new file mode 100644 index 000000000..7db977ba8 --- /dev/null +++ b/drivers/bus/mlx5_pci/Makefile @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2020 Mellanox Technologies, Ltd + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_mlx5_pci.a + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5 +CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5 +CFLAGS += -I$(RTE_SDK)/drivers/bus/pci +LDLIBS += -lrte_eal +LDLIBS += -lrte_common_mlx5 +LDLIBS += -lrte_pci -lrte_bus_pci + +# versioning export map +EXPORT_MAP := rte_bus_mlx5_pci_version.map + +SRCS-y += mlx5_pci_bus.c + +# DEBUG which is usually provided on the command-line may enable +# CONFIG_RTE_LIBRTE_MLX5_DEBUG. +ifeq ($(DEBUG),1) +CONFIG_RTE_LIBRTE_MLX5_DEBUG := y +endif + +# User-defined CFLAGS. +ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DEBUG),y) +CFLAGS += -pedantic +ifneq ($(CONFIG_RTE_TOOLCHAIN_ICC),y) +CFLAGS += -DPEDANTIC +endif +AUTO_CONFIG_CFLAGS += -Wno-pedantic +else +CFLAGS += -UPEDANTIC +endif + +# +# Export include files +# +SYMLINK-y-include += rte_bus_mlx5_pci.h + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/bus/mlx5_pci/meson.build b/drivers/bus/mlx5_pci/meson.build new file mode 100644 index 000000000..cc4a84e23 --- /dev/null +++ b/drivers/bus/mlx5_pci/meson.build @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2020 Mellanox Technologies Ltd + +deps += ['pci', 'bus_pci', 'common_mlx5'] +install_headers('rte_bus_mlx5_pci.h') +sources = files('mlx5_pci_bus.c') diff --git a/drivers/bus/mlx5_pci/mlx5_pci_bus.c b/drivers/bus/mlx5_pci/mlx5_pci_bus.c new file mode 100644 index 000000000..66db3c7b0 --- /dev/null +++ b/drivers/bus/mlx5_pci/mlx5_pci_bus.c @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#include "rte_bus_mlx5_pci.h" + +static TAILQ_HEAD(mlx5_pci_bus_drv_head, rte_mlx5_pci_driver) drv_list = + TAILQ_HEAD_INITIALIZER(drv_list); + +void +rte_mlx5_pci_driver_register(struct rte_mlx5_pci_driver *driver) +{ + TAILQ_INSERT_TAIL(&drv_list, driver, next); +} diff --git a/drivers/bus/mlx5_pci/rte_bus_mlx5_pci.h b/drivers/bus/mlx5_pci/rte_bus_mlx5_pci.h new file mode 100644 index 000000000..571f7dfd6 --- /dev/null +++ b/drivers/bus/mlx5_pci/rte_bus_mlx5_pci.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#ifndef _RTE_BUS_MLX5_PCI_H_ +#define _RTE_BUS_MLX5_PCI_H_ + +/** + * @file + * + * RTE Mellanox PCI Bus Interface + * Mellanox ConnectX PCI device supports multiple class (net/vdpa/regex) + * devices. This bus enables creating such multiple class of devices on a + * single PCI device by allowing to bind multiple class specific device + * driver to attach to mlx5_pci bus driver. + * + * ----------- ------------ ----------------- + * | mlx5 | | mlx5 | | mlx5 | + * | net pmd | | vdpa pmd | | new class pmd | + * ----------- ------------ ----------------- + * \ | / + * \ | / + * \ ------------- / + * \______| mlx5 |_____ / + * | pci bus | + * ------------- + * | + * ----------- + * | mlx5 | + * | pci dev | + * ----------- + * + * - mlx5 pci bus driver binds to mlx5 PCI devices defined by PCI + * ID table of all related mlx5 PCI devices. + * - mlx5 class driver such as net, vdpa, regex PMD defines its + * specific PCI ID table and mlx5 bus driver probes matching + * class drivers. + * - mlx5 pci bus driver is cental place that validates supported + * class combinations. + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include + +#include + +/** + * A structure describing a mlx5 pci driver. + */ +struct rte_mlx5_pci_driver { + enum mlx5_class dev_class; /**< Class of this driver */ + struct rte_pci_driver pci_driver; /**< Inherit core pci driver. */ + TAILQ_ENTRY(rte_mlx5_pci_driver) next; +}; + +/** + * Register a mlx5_pci device driver. + * + * @param driver + * A pointer to a rte_mlx5_pci_driver structure describing the driver + * to be registered. + */ +__rte_internal +void +rte_mlx5_pci_driver_register(struct rte_mlx5_pci_driver *driver); + +#define RTE_PMD_REGISTER_MLX5_PCI(nm, drv) \ +static const char *mlx5_pci_drvinit_fn_ ## nm; \ +RTE_INIT(mlx5_pci_drvinit_fn_ ##drv) \ +{ \ + (drv).driver.name = RTE_STR(nm); \ + rte_mlx5_pci_driver_register(&drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTE_BUS_MLX5_PCI_H_ */ diff --git a/drivers/bus/mlx5_pci/rte_bus_mlx5_pci_version.map b/drivers/bus/mlx5_pci/rte_bus_mlx5_pci_version.map new file mode 100644 index 000000000..4cfd3db10 --- /dev/null +++ b/drivers/bus/mlx5_pci/rte_bus_mlx5_pci_version.map @@ -0,0 +1,5 @@ +INTERNAL { + global: + + rte_mlx5_pci_driver_register; +}; -- 2.25.4