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 F2625A0519; Fri, 3 Jul 2020 11:14:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 44BC21DAD9; Fri, 3 Jul 2020 11:13:32 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00046.outbound.protection.outlook.com [40.107.0.46]) by dpdk.org (Postfix) with ESMTP id CC9E71DACF for ; Fri, 3 Jul 2020 11:13:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDeMskm1T8B2TktscF4QXwt3/sVgxImvHJLJaE+ACjsN8BgQcBegFMeMOCJSBz9XwS5+gvUkfwRkOIDB46yKCfLXtnFo231HnlXv3O+KAJeL1jD+wexuhNTCpSeiwwnCkETqeh8cfn5hULEx4R23yIDeYqWsbM/xUW5t7lKzzqNbCwIXnkvibq8hM/L45ej5RxXTgtLA/6X+BfoPNGabTnyclkqrL/L0YLJadNsvQxkKATl2cBa4d3+Rof9kH8i17MpZH9vLauOsLL6ZOyvn/UeKfVBMyfLFIV9rAeUWLBc2OyBUkXmtduKPGoVoeI/xiXoY411Zw7+vAk3HsfYlMA== 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=8T91Ktikro+Q84Mkiss5UWGnRxBzXRgOehojdMfcIhM=; b=cut+S6gMSrQMQKfrWPJQFGIXJFZbuvZTOpRF+0VFDtNM6bt9KEqn1JRd/ZeFmSVoBoz7orqp0NosUHiGZ38DT+Oi9hh3kCfjIa8O9ahRAwNua8mlu9nKpww9kDMWbdoHjTlSsC+poH9bQdw0/jObfw8m4kn0l6Hzu8AtpgPdZxyPrp8IH8/lqqMlmBZo4MQLmJ6bHXq/GI7JhmCDBwbLRMmTjingAkVMA6BN1Mb7aD6oe22Mr/FVkSI0pXHC6c18B9lulG8CBeiJVOygEVLAfpMVbKVyJ6WRIlNHYYIjIm23494XTcLtf7sP2UE0A56pD3TrXUXUeNYhiZLq4W0edA== 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=8T91Ktikro+Q84Mkiss5UWGnRxBzXRgOehojdMfcIhM=; b=E0lfvH4bQVOMNdBUZ3stN62wFlMWXeolTl7uAlcqHn3Pucpo5ro4P65ARxcxy1R27wFtd9hsVjdy8exMdU5Z3crfV4NC6d2ZR6Z1F3NkxHKSBiCFfxeItxYMn88uinn1fPsBZZ2Jt5VIM8Rf6Yio/lFyyfYyOxiS3Y69ihXn5/o= 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 AM0PR05MB4353.eurprd05.prod.outlook.com (2603:10a6:208:67::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.24; Fri, 3 Jul 2020 09:13:29 +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.3153.024; Fri, 3 Jul 2020 09:13:29 +0000 From: Parav Pandit To: dev@dpdk.org, grive@u256.net, ferruh.yigit@intel.com Cc: thomas@monjalon.net, orika@mellanox.com, matan@mellanox.com, Parav Pandit Date: Fri, 3 Jul 2020 12:12:55 +0300 Message-Id: <20200703091259.2108996-7-parav@mellanox.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200703091259.2108996-1-parav@mellanox.com> References: <20200610171728.89-2-parav@mellanox.com> <20200703091259.2108996-1-parav@mellanox.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SN4PR0501CA0006.namprd05.prod.outlook.com (2603:10b6:803:40::19) 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 SN4PR0501CA0006.namprd05.prod.outlook.com (2603:10b6:803:40::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.8 via Frontend Transport; Fri, 3 Jul 2020 09:13:27 +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: 3f0a30b4-e06a-4dfc-d5a3-08d81f315952 X-MS-TrafficTypeDiagnostic: AM0PR05MB4353: 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:7219; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yg6gFoTawY3mRcMVa8cToKvlUQqDKt5sQ6cKhwQfgO5369AmLICrmMp4i6FRWC5zV3DY+9Gy5LgdZnvZmG1Gi4Y85rAYPyjo06GoG+ZCC2Obl/MB6nn3ytTmc8mU6fXWbL/WCd7ZwVVJuhyj1yIRlR62QvMihiG7hKjkrdvK79x7upT+Fd+vU3LumKEVCXjzPfTDof5/Iw1GkWsSe1Z5F9mQlRgZ4ClqP8OBRRKuT5BcOo884q9lr1Nzn52vSOB2WTDlse4ra2+DWIR/qKosBZTWK6gYWy0EFN75usquFrAaluiLA2gct6pY+jGZ3pp65LSBqkukTyTjMsrJFYOR+w== 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)(366004)(346002)(376002)(396003)(39860400002)(136003)(66476007)(86362001)(1076003)(66946007)(4326008)(66556008)(6506007)(6666004)(2906002)(6486002)(107886003)(478600001)(6512007)(16526019)(36756003)(316002)(8676002)(186003)(956004)(52116002)(2616005)(8936002)(83380400001)(5660300002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: frXoJwp2ldD5oTMYcn8+fv1jd/nhQvXvctiY5XhBbqJBtpIh6fTAiIqaDaedWsetRU7fQUlOcoUb1ib24J0rEXgUmgy/oH+DpmcoGR9lOo49vFT4F8HsW5O+4pEh0FY30x3B0TaRvCwiCJ5cJeO8Uq+8ddm4XZOyth0z8FgU+pVih22YhJCZiA39XkaZya6RcAZD6Yt9OFeSs9LL03BmU30HJ/djaHeBqGTsgC3ojjMfnUcp9W3RFb0ocq6PP+tZffOJJLvNtiYeKyJYOoE5ezdduaHdAnqVR9ZZCBaw67g8mtpwTtkku3zGNHoufumROETRiJ9aX8nD+/x1Lq0yein0PRZ+UM3FJ0t7onxsGsgds8NQXoFz1CPMqoczyeuE6HHoejOSOt2IMW8+2+nyCNZdNdtCJ3O0fjtO0j5KFm94UWb2YmKZ5Nbsti51LWtYtZKqQoaIacIWwidtPvRGA/1k6TKcSwqXVg6Zf3cXJkiOzUGCow/UNxEjX2dzFR3P X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f0a30b4-e06a-4dfc-d5a3-08d81f315952 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4866.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 09:13:29.7477 (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: qRCrOEz2ZbwesCH3INsYgoBUpeJLu1JldjQeOBKIKdMwi98Zk/Dg3K148nxad8TE5UOOE83vwLOg5IFL87Tufg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4353 Subject: [dpdk-dev] [PATCH v3 06/10] 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 Acked-by: Matan Azrad --- Changelog: v2->v3: - Addressed comments from Thomas and Asaf - Moved pci_driver structure instance as first in driver - Removed white spaces at the end of line in diagram - Address comments from Matan - Removed CONFIG_RTE_LIBRTE_MLX5_PCI_BUS from config files - Changed alignedment to mlx5 specific aligment instead of standard DPDK - Using uint32_t instead of mlx5_class enum 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 --- drivers/bus/meson.build | 2 +- drivers/bus/mlx5_pci/Makefile | 38 +++++++++ drivers/bus/mlx5_pci/meson.build | 19 +++++ 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 ++ 6 files changed, 161 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/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..de4ccd83f --- /dev/null +++ b/drivers/bus/mlx5_pci/Makefile @@ -0,0 +1,38 @@ +# 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 -Wall -Wextra +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -Wno-strict-prototypes +CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5 +CFLAGS += -I$(BUILDDIR)/drivers/common/mlx5 +CFLAGS += -I$(RTE_SDK)/drivers/common/mlx5/linux +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 + +# +# 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..64a17cbad --- /dev/null +++ b/drivers/bus/mlx5_pci/meson.build @@ -0,0 +1,19 @@ +# 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') + +cflags_options = [ + '-std=c11', + '-Wno-strict-prototypes', + '-D_BSD_SOURCE', + '-D_DEFAULT_SOURCE', + '-D_XOPEN_SOURCE=600' +] +foreach option:cflags_options + if cc.has_argument(option) + cflags += option + endif +endforeach 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..9f8d22e2b --- /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 { + struct rte_pci_driver pci_driver; /**< Inherit core pci driver. */ + uint32_t dev_class; /**< Class of this driver, enum mlx5_class */ + 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.26.2