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 397F5A0526; Fri, 24 Jul 2020 16:24:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A3D31C033; Fri, 24 Jul 2020 16:24:31 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20064.outbound.protection.outlook.com [40.107.2.64]) by dpdk.org (Postfix) with ESMTP id C1AEF1C027 for ; Fri, 24 Jul 2020 16:24:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mgZLim1Z0vGa4bb217qFZeEt8BEwMkh55UX9pBpyY9yR3s3nmwde5Trp+qOUIDzR2Xrm+Hnd6iw4o2FRLPEXz2c8i0FAgEO25GoGjFXdtyg6VKQ9lscaw7EV6K4FqwHttsekbE9pwz3/cimU4NHOTJcaPqNw4S3sVmwQlXuN9uk5JEfURUfkHv4MGybI3X4MWGU+GFeXNfqWbdyk+QbvVVld3NEYLa6GpjgMQxIvEqWQvZxlRBHoekRhVSPuU7wJlWDFow9ZTGS6ldSB/QGNrypdXhJnvMOc9qQgzc1NV1tfjnMXTDR5feIZg6npqHbnXZUDPuq2idgwmzvv2DUX3Q== 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=XCoPBTTP5blXCOtUfsBz8adADh4Qe05vpbvHqrMSrGg=; b=FBuVyjJpgyD9ee8mcaAes1ti58pZOo7vIE/MKwxhVSz7Md1PrnXpnTqvwdIEnPMKNCwwXzksprEDqxAPLg9fAmvNMTXF2IgJ7nj+PMJ0SUe1MyUqUIrbChzZeAJaqKIHbSlEznF0LAbFHjuAqGwshXdRFhbNDEKKjyd2nARcZ7+MtRYIrB46ugEUl57AMf5LNbcxuMOkNn9u8/IaV/+QSM6M6KNrPiQNEhaZzY3mIxUkOeFu89mTOjh5P35R493DE1P2wFTNrZZsVi6O+UQk1+noLoAXlZJKbUxvyEIR7y3Bs1b4VmDf998xiEeTAii3T6zbpnzqzLWQwa1Mv4GsLw== 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=XCoPBTTP5blXCOtUfsBz8adADh4Qe05vpbvHqrMSrGg=; b=VySZKvuQwfofwRSHx0mZ0ceYnKSWC67qVxhJvgg1RGtKK9kgRE3ptYJOfpYtWjlK8BqfigmhoC2Ri/XOqv40+NQlBSCCvVP84k9n7pJ00tQnMA87rb9DOjof9Y+2TD6mwKU1EfaRKVLjJ33H1i0T1lnBbo7I89qYqMX1YLZQW4k= 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 AM4PR05MB3203.eurprd05.prod.outlook.com (2603:10a6:205:6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.20; Fri, 24 Jul 2020 14:24:23 +0000 Received: from AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::eccf:72b3:bacb:f09d]) by AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::eccf:72b3:bacb:f09d%5]) with mapi id 15.20.3216.024; Fri, 24 Jul 2020 14:24:23 +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: Fri, 24 Jul 2020 17:23:53 +0300 Message-Id: <20200724142403.6132-1-parav@mellanox.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200610171728.89-2-parav@mellanox.com> References: <20200610171728.89-2-parav@mellanox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DM6PR02CA0136.namprd02.prod.outlook.com (2603:10b6:5:1b4::38) 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 DM6PR02CA0136.namprd02.prod.outlook.com (2603:10b6:5:1b4::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21 via Frontend Transport; Fri, 24 Jul 2020 14:24:21 +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: 1ad11829-6d28-4258-b01a-08d82fdd432c X-MS-TrafficTypeDiagnostic: AM4PR05MB3203: 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:469; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K7D6tA+cRoktJtzj4YeuvtjYYyMJRygy0kLsFM+jZihP/bMxAyLP0XrjT9aj+lZgHFpGdiRv2PAGVwEglr8o7BqIYNEAtVWlLPr7zzW9Pv8Ql84OdzW58Dhy07UDoTaJth2+4krXEY95V6s4I/QJD7WZNoEZak/OzZiouPXqDUclVSkZ9UKJYVDlfYZxYvub4zsxSEhFi31cHiRUUBIJS+Ih1FYBvyNauTWhNTEQJUzhwylubzWr8QTZudpk8LrbwVVjYcTGvTxbN0mEMDnRe18L7r/w6R5D8cvmlMxC6d+j7F++xOvFj+mCaAcy4sEqgsz/Aa2xpELuZEtxM5tGBA== 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)(39860400002)(366004)(396003)(136003)(346002)(376002)(6666004)(52116002)(8936002)(478600001)(8676002)(66574015)(36756003)(83380400001)(6486002)(1076003)(107886003)(2906002)(6512007)(316002)(66556008)(66946007)(66476007)(5660300002)(86362001)(2616005)(956004)(6506007)(4326008)(186003)(26005)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: onyQCt4odAX1W2UnduqYOxF/OPq3Lzymjn7RGRUNFfmsKAg2rHIGo+L4UWQmc4lJzxeScUm7LHxERil31vSsMwEdCWDVDbg2l2uMB4lsyzVZYSinF9xgs+jakc8OONyjQbw/5VVaxL7WDTSBdWcqWNt7OpqL6Lrm0eUF7v3pmlq33s8FIbdTM5Jee6W1c7Eom0iFs/6j7+rsjJtlnIry4ko5UAYZf1fdUBHILevc5e9uRC/IIWLPgHPERITKp6la89/9r3E/Loko7IOqDoVKFa1AunqDlOwfyfPXrdht/ElgzBa0MANZFSTrkg5CeX0wlZy01iMj0YG8iQ7foRyyICZgVkXVByDbwnDgoWF2v5sYRFgHToozeEvSSVuGUKonJLhKI0brpEtpwt/qDT31qK5yRfaN1Czm5o2wng0v8z6w2LOoNERXm26IPZu619L/R8d1RP8N/nFYMQnpHiTqWYAT5kcQHVZT64T4KtIkjwMNm6xkB02CQYxBePxblghH X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ad11829-6d28-4258-b01a-08d82fdd432c X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4866.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2020 14:24:23.5804 (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: PAHk+5uXupK+HZ+x9SmKZUgBRQc0VFcvo6fDm8yocf0Q8pKK9Uc5YXkrcNYUXWRZQMEBE5fVskLeTUxg5FwnqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3203 Subject: [dpdk-dev] [PATCH v9 00/10] Improve mlx5 PMD driver framework for multiple classes 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" This series introduces mlx5 common driver layer to support multiple class of devices for a single PCI device. Motivation and example ---------------------- mlx5 PCI device supports multiple class of devices such as net, vdpa and regex devices. Currently only one pmd (either net or vdpa) can bind to this device. This design limits use of PCI device only for single device class. To support multiple classes simultaneously for a mlx5 PCI device, mlx5 common module is extended as generic PCI PMD. This PMD enables multiple class PMDS (net, regex, vdpa) to be loaded on a single PCI Device. Change description ------------------ Patch-1 Introduces RTE_BIT() macro Patch-2 Fixed indentation for directory listing Patch-3 Relax dependency order Patch-4 Fixes compilation error Patch-5 Fixes segmentation fault in regex probe error unwind path Patch-6 Avoid using class constructor priority Patch-7 Change class values as bits Patch-8 Introduce mlx5 layer to support multiple class drivers Patch-9 Migrates mlx5 net and vdpa driver to use mlx5 PCI driver API instead of rte PCI bus API Patch-10 Removed class check code from class drivers Design overview --------------- ----------- ------------ ------------- | mlx5 | | mlx5 | | mlx5 | | net pmd | | vdpa pmd | | regex pmd | ----------- ------------ ------------- \ | / \ | / \ --------------- / \______| mlx5 common |____/ | pmd | --------------- | ----------- | mlx5 | | pci dev | ----------- - mlx5 common 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 define their specific PCI ID tables. mlx5 common driver probes each individual class driver(s) for maching and enabled classes. - mlx5 pci layer is cental place that validates supported class combinations. - In future as code evolves, more device setup/cleanup and resource creation code moves to mlx5 PCI common driver. Alternatives considered ----------------------- 1. Instead of creating mlx5 pci common PMD, a common driver is implemented which exposes class registration API. However, common PMD model fits better with existing DPDK design similar to ifpga driver. Class registration API need to create a new callbacks and ID signature; instead it is better to utilize current well defined methods. 2. Enhance pci core to allow multiple driver binding to single rte PCI device. This approach is not taken, because peer drivers using one PCI device won't be aware of other's presence. This requires cross-driver syncronization of who initializes common resources (such as irq, eq and more). This also requires refcounting common objects etc among peer drivers. Instead of layered approach delivers and allows putting common resource sharing, setup code in common driver. It also eliminates peer blind zone problem as bottom pci layer provides necessary setup without any reference counting. 3. In future mlx5 prefers to use RDMA MR cache of the mbuf used between net and regex pmd so that same mbuf use across multiple device can be possible. Examples: -------- A user who wish to use a specific class(es) provides list of classes at command line such as, ./testpmd -w ,class=net:regex ./testpmd -w ,class=vdpa Changelog: v8->v9: - Updated commit message - Fixed LD_FLAGS - Fixed white space to tab - Fixed Makefile to have dependency on common/mlx5 for parallel builds v7->v8: - Instead of dedicated mlx5 bus driver, merged the PMD to common_mlx5 - Avoided new RTE PRIORITY - Removed mlx5 common to use RTE_PRIORITY_CLASS v6->v7: - Updated release notes v5->v6: - Fixed compilation failure in parallel build for shared lib v4->v5: - Squash the maintainers update path with other patch which adds the bus - Addressed comments from Morten Brørup - Renamed newly added macro to RTE_BIT64 - Added doxygen comment section for the macro v3->v4: - Fixed dma_map error unwinding flow to follow same order for unmap v2->v3: - Added RTE priority for common driver initialization - Addressed comments from Thomas and Asaf - Fixed compilation error in glue wrapper - Moved pci_driver structure instance as first in driver - Removed white spaces at the end of line in diagram - Address commnts from Matan - Removed CONFIG_RTE_LIBRTE_MLX5_PCI_BUS from config files - Renamed mlx5_valid_class_combo to mlx5_class_combinations - Added cross check for class drivers to support only 3 flags for now - Added full stop at the end of comment block - Using full names in function names - Added new line before function name in multiple functions - Added example string to parse for multiple classes - Dropped mlx5 prefix from static function - Removed empty lines - Fixed issue to remove multiple classes for a driver - Using define for drv_flags at multiple places - Deriving drv_flags based on the class drivers - Fixed alignment for id_table - Perform dma map on best effort basis for all supported drivers - Dynamically build pci id table - Using PCI to mlx5 device helper routines v1->v2: - Addressed most comments from Thomas and Gaetan. - Symbols starting with prefix rte_bus_pci_mlx5 may be confusing as it may appear as it belong to rte_bus_pci module. Hence it is kept as rte_bus_mlx5_pci which matches with other modules as mlx5_vdpa, mlx5_net. - Dropped 2nd patch and replace with new 6th patch. - Avoided new file, added macro to rte_bitops.h - Inheriting ret_pci_driver instead of rte_driver - Added design and description of the mlx5_pci bus - Enhanced driver to honor RTE_PCI_DRV_PROBE_AGAIN drv_flag - Use anonymous structure for class search and code changes around it - Define static for class comination array - Use RTE_DIM to find array size - Added OOM check for strdup() - Renamed copy variable to nstr_orig - Returning negagive error code - Returning directly if match entry found - Use compat condition check - Avoided cutting error message string - Use uint32_t datatype instead of enum mlx5_class - Changed logic to parse device arguments only once during probe() - Added check to fail driver probe if multiple classes register with DMA ops - Renamed function to parse_class_options - Migreate API from rte_driver to rte_pci_driver Parav Pandit (8): eal: introduce macro for bit definition common/mlx5: fix void parameters in glue wrappers regex/mlx5: fix segmentation fault during error unwinding common/mlx5: avoid using class constructor priority common/mlx5: change class values as bits common/mlx5: introduce layer to support multiple class drivers common/mlx5: register class drivers through common layer common/mlx5: remove class check from class drivers Thomas Monjalon (2): drivers: fix indent of directory list drivers: relax dependency order drivers/Makefile | 10 +- drivers/common/Makefile | 4 - drivers/common/meson.build | 2 +- drivers/common/mlx5/Makefile | 2 + drivers/common/mlx5/linux/mlx5_glue.h | 4 +- drivers/common/mlx5/meson.build | 9 +- drivers/common/mlx5/mlx5_common.c | 52 +- drivers/common/mlx5/mlx5_common.h | 12 +- drivers/common/mlx5/mlx5_common_pci.c | 539 ++++++++++++++++++ drivers/common/mlx5/mlx5_common_pci.h | 77 +++ .../common/mlx5/rte_common_mlx5_version.map | 4 +- drivers/meson.build | 51 +- drivers/net/mlx5/Makefile | 1 - drivers/net/mlx5/linux/mlx5_os.c | 6 - drivers/net/mlx5/mlx5.c | 25 +- drivers/net/mlx5/mlx5.h | 1 - drivers/regex/mlx5/meson.build | 2 +- drivers/regex/mlx5/mlx5_regex.c | 29 +- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/meson.build | 2 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 29 +- lib/librte_eal/include/rte_bitops.h | 8 + 22 files changed, 748 insertions(+), 123 deletions(-) create mode 100644 drivers/common/mlx5/mlx5_common_pci.c create mode 100644 drivers/common/mlx5/mlx5_common_pci.h -- 2.26.2