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 975D8A0519; Fri, 3 Jul 2020 15:47:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D8351DBC4; Fri, 3 Jul 2020 15:47:07 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2079.outbound.protection.outlook.com [40.107.20.79]) by dpdk.org (Postfix) with ESMTP id 529831DBB4 for ; Fri, 3 Jul 2020 15:47:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TZb/7Gj93y2MYiXx+/DRaTsXUNnU4VaqpZZ+v8gT4iP/lOuZqeq3CVcmnRSvIRXwpVqDnjZwDSYKiH9uorrKnaKPgpo3XJHnn5fLW+PeSnd1ZLNpF+spYnPPpPJHRWmuQePkbQ999A6nCxKtIRqyZ4jHWHd4ZxrQcHCM9cnK7T3POAK1k99PyhXV2zJG9xPoZOkpzo9XsmnuhmANHRSnUzXDV4CKdVgZXu9DTibHYbiDNpEc2IQpGVWIXqKogYyX8hmiVMmQLL5DG6g1rvX1hTxQdfWrpZemnTWMg4qbgGN7oQ/21RUJdMNvG0EDN4QuZIFOB5IfvgI+IJfvrYe7UQ== 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=//f7FXc9rdtDuc3RSsQNgrDTs9ZCenHwYZ4Tr//PydA=; b=SXM4H8rulQyXZiTpUJLBoGIEQ/f7nalOwKwRaZcThlfRs7wpewaYurlu4DZy4VqpICjLIHg/H1MQk3c3OeR4r64u5z8MCRms6dAw25pIyphdcVJ2tcSUnH8nElV4RoflEF+lB1haQdhfamCminnzBsnmN0mH1C14zVCsHH+vPWNy7Mt0q3UYU715BofbtR1fz+T706xZYj9q5bXdh7Do12xDUAWqkdGR7UVDlqSNf9pLA1y8/UF9ub8Fbx0FuZeBw00cfLaa91aoTZFMW7H56yoFwQPhdAYLq/Emhl2LJVbczHOMZdffsgS3mvwRqcC/SmPfBy6obdGkvMwbZYtTEg== 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=//f7FXc9rdtDuc3RSsQNgrDTs9ZCenHwYZ4Tr//PydA=; b=Uu0x0WCNdpjTgbqeB2j5WBykpwnopU32SzFIb2uKapVjC0lrFysDkKr99N1MqlQ2mulvX/aBrfNbeaHhb5puGgqQ4Wzdr700eCTuaF3WC/rcwesB8cHx2nnIMhu/VOnzU+RTWmWuP/QcwjIQK0ot81GtlpA9IpGSffrAukzw3As= 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 AM4PR05MB3345.eurprd05.prod.outlook.com (2603:10a6:205:a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21; Fri, 3 Jul 2020 13:47:01 +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 13:47:00 +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 16:46:31 +0300 Message-Id: <20200703134641.386297-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-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SN4PR0401CA0009.namprd04.prod.outlook.com (2603:10b6:803:21::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 SN4PR0401CA0009.namprd04.prod.outlook.com (2603:10b6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21 via Frontend Transport; Fri, 3 Jul 2020 13:46:59 +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: 5921d12e-d0f8-4415-02a3-08d81f578f6e X-MS-TrafficTypeDiagnostic: AM4PR05MB3345: 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:4941; X-Forefront-PRVS: 045315E1EE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YSfPf2BmeLekoNdcdTfj2VA+6jLDbK81RxUxSFbvDesatsEO5jJYFcTkvuc6629Eek1HdDt7SOUNXYYbgFIBCyktytdfRuCnGvwuknXUS2LF6YmtZhHcfzjAzu0wtMHeQCk7X1JV/Itg7BooNdTvi8FeN1dahbV3ZXtJuyElJ2bN12FbjjJuwOoUqtSl3wx3SDkiFkg7cUa2xRLm+nJKPFJPe9OWqnA64jQXdWRgFvVhxryOVF+Rwlf7h/4mOlgaQ96mqVHCBqdKPFFbxIEQ2TwXajVUrR9+U5g74xnOHxOF3P3WIplcxu7Z9TaIiWr0y91yDvuKQ81XOIE/i+LUhQ== 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)(396003)(376002)(136003)(39860400002)(4326008)(66476007)(8936002)(8676002)(6486002)(6506007)(478600001)(66946007)(52116002)(83380400001)(956004)(6666004)(186003)(26005)(1076003)(16526019)(107886003)(66556008)(5660300002)(2616005)(2906002)(86362001)(36756003)(316002)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: RIQqmUS8bIKaLxHQTYLnFkqLWhn7ufNvG5im8t460h/bBZh/IOXTvAK76ook+dGcgdyuAV+m2mvZNA1ltFf3rdwX77ahi3XP4676xM/g3feuk0VJPodtT/ADkdncubZgedStjVc2lSQeMeRyR4VIiBx13oc2d5PRn8LfrjDkRKIAVp6NaHSF597o4X/ePPmboZdd6pVpejT+k44QEpujSCeKsVIBSl0EQj8rTWz3zKKXb+l9hmr1m0LnlgnMay6aGVhfcp+h9gc+jBXFDegYIaYeipl9hlYMkcZvk+kaP/xsXIXqnID4xrGHcREGSYIs8p4Lt8jpPc4YVuIK9DNxv1LDtkdTHLLSLOojEF8wPpDJ6gfj2R5q3foBScoZ8EUCVvSwgCL+n/A5TPKJY6zD6mo2UdopI4IrobH3F8AQncqzvyzMKhzF5JHKPdBSFw/JG5MRTdhmKA3dNlv15LrCwvdcyH8Cymqw7O+nxsLCcUyG84FJXP0SLaI30tZlq0p8 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5921d12e-d0f8-4415-02a3-08d81f578f6e X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4866.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2020 13:47:00.8908 (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: AURRK5jr04hd+MzhalDWwfK3QkbyMc7wVVACeh0h42JnuQRqLupDJebQejVgS3I84b2cUw8R7FOURr7o4pMS5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3345 Subject: [dpdk-dev] [PATCH v4 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 bus 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, a new mlx5 PCI bus is created. This bus allows binding multiple class drivers (such as net, vdpa, regex(future)) to bind to the mlx5 PCI bus driver. Change description ------------------ Patch-1 Introduces RTE_BIT() macro Patch-2 Introduces new RTE constructor priority for common initialization Patch-3 Fixes compilation error Patch-4 Define mlx5 class as bit fields Patch-5 Uses new RTE common priority Patch-6 Adds mlx5 PCI bus Patch-7 Implements a mlx5 PCI bus driver Patch-8 Migrates mlx5 net and vdpa driver to use mlx5 PCI bus API instead of rte PCI bus API Patch-9 Removed class check code as its already part of the bus now Patch-10 Add maintainers for the new bus Design overview --------------- ----------- ------------ ------------- | mlx5 | | mlx5 | | mlx5 | | net pmd | | vdpa pmd | | regex 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. - In future as code evolves, more device setup/cleanup and resource creation code moves to mlx5 PCI bus driver. Alternatives considered ----------------------- 1. Instead of creating mlx5 pci bus, a common driver is implemented which exposes class registration API. However, bus 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 bus driver. It also eliminates peer blind zone problem as bottom pci bus 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:vdpa ./testpmd -w ,class=vdpa In future, ./testpmd -w ,class=net:regex Changelog: 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 (10): eal: introduce macros for getting value for bit eal: introduce RTE common initialization level common/mlx5: fix empty input style in glue wrappers common/mlx5: change mlx5 class enum values as bits common/mlx5: use common rte priority bus/mlx5_pci: add mlx5 PCI bus bus/mlx5_pci: register a PCI driver bus/mlx5_pci: enable net and vDPA to use mlx5 PCI bus driver common/mlx5: remove class checks from individual driver maintainers: add maintainers for mlx5 pci bus MAINTAINERS | 5 + drivers/bus/Makefile | 3 + drivers/bus/meson.build | 2 +- drivers/bus/mlx5_pci/Makefile | 40 ++ drivers/bus/mlx5_pci/meson.build | 19 + drivers/bus/mlx5_pci/mlx5_pci_bus.c | 522 ++++++++++++++++++ drivers/bus/mlx5_pci/rte_bus_mlx5_pci.h | 84 +++ .../bus/mlx5_pci/rte_bus_mlx5_pci_version.map | 5 + drivers/common/mlx5/linux/mlx5_glue.h | 4 +- drivers/common/mlx5/mlx5_common.c | 39 +- drivers/common/mlx5/mlx5_common.h | 7 +- .../common/mlx5/rte_common_mlx5_version.map | 2 - drivers/net/mlx5/Makefile | 3 +- drivers/net/mlx5/linux/mlx5_os.c | 6 - drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 26 +- drivers/net/mlx5/mlx5.h | 1 - drivers/vdpa/mlx5/Makefile | 3 +- drivers/vdpa/mlx5/meson.build | 2 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 30 +- lib/librte_eal/include/rte_bitops.h | 2 + lib/librte_eal/include/rte_common.h | 1 + mk/rte.app.mk | 1 + 23 files changed, 724 insertions(+), 85 deletions(-) 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 -- 2.26.2