From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BCB83A0C51; Tue, 13 Jul 2021 15:17:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 967EF412B5; Tue, 13 Jul 2021 15:16:57 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by mails.dpdk.org (Postfix) with ESMTP id 3EB67412AD for ; Tue, 13 Jul 2021 15:16:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TueyeZxCkFMxIRgliF69E3zTg8qZg0HgK+bFLJhv3Pfo8TJXOrh7/DR5VsTc5zBtZIzZHBjnOV1hFLsvGv92aYx9LBgXZ8QUVQ3Rn2ouh0ubwnvcatWfA/R3cybL9CCxzG307sHt+9nogEzgw6eW3fZRis7jAMAFMCxWVe/QuSMmanHfC+/U0c6vlwd2e2UVo62hAushnaADYVQ33i73x0ySq1Wf5Lb/VKVzTG2J4YEqbLxyAHxFWRP4J8ocHqGDte6vqV3R+jTlJQeGUe/TMBNnDPDvebHSnUg9egVfgwVeksRGMtamC+ev/QwRWYK5nkphcSy21rq455tmRWuT+A== 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=KiVL+SyoPV+BFUMr2GREU7B1SbRM24Hw4mG/s+vP4d4=; b=IO/LDYAOBNDi+3GR/cFN3kG1zixLc4JQD8SFe8E4P+myWkOxWq+jcmMHMTmdgdeJ4dQxWvJs+rwq2RRhe26BCa/DhyQiNcgtRwdRaI7woZKdomFWwBGZKKJOiEGZyCKgzeArAKI4hUmmse+VXcv8Sf6c9Po/+Lqt41Z6dhKC3p7BE29+ODubbnAuHIJcYCL9OrjIQGfEQFiGMToyj13WQMtlMkOhPc3N/tAmhBjECnITN5MWBB9nHvbeW8n3BHa4fqeAxJO6renESGlJFnBdrqObkF3kQR++aV67BHTjpKMZNriVCqlAf3k+H+xizt0QFTXyDqe2yQeDwZzWTjYZmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=ashroe.eu smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KiVL+SyoPV+BFUMr2GREU7B1SbRM24Hw4mG/s+vP4d4=; b=Tm85PwbkC67pT4DhaOm6v5OEeCatC+FIBWjbiEFqsPDlpwH56jYyI2xpJSp5E9lBp21mBeW96z/fWuJHR6HthyXwT1GVfoAUXQhTHAFsBk+MJrhjuIhJEFCNfOLLP5wEKFl+ACsbmyOJEUus7y0ex4es8rtyMEbgxNfd1ipnpjkSZK+KgVnxKC1ui2NlLasOigBc2IZAepQvTV34FK93zZULLI8L3ruBuw7pKbMMiLNsVX2/gv6VWr84XVyRPEMtu+CrpwGeqbJThgZN4M24lDWJ+OT8mPoQ1+l1yQCv31b0gamjWGHuk5xy4J0gf0Wp63YjDkhxy8yflrCay7SF2w== Received: from MW4PR03CA0045.namprd03.prod.outlook.com (2603:10b6:303:8e::20) by DM5PR12MB2583.namprd12.prod.outlook.com (2603:10b6:4:b3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Tue, 13 Jul 2021 13:16:53 +0000 Received: from CO1NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::4f) by MW4PR03CA0045.outlook.office365.com (2603:10b6:303:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Tue, 13 Jul 2021 13:16:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; ashroe.eu; dkim=none (message not signed) header.d=none;ashroe.eu; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT023.mail.protection.outlook.com (10.13.175.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4308.20 via Frontend Transport; Tue, 13 Jul 2021 13:16:52 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 13 Jul 2021 13:16:38 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Matan Azrad , Shahaf Shuler , Ray Kinsella Date: Tue, 13 Jul 2021 21:14:37 +0800 Message-ID: <20210713131437.30170-15-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616040935.311733-2-xuemingl@nvidia.com> References: <20210616040935.311733-2-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07edf383-9fb2-4045-bf07-08d946007b64 X-MS-TrafficTypeDiagnostic: DM5PR12MB2583: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4HWAt3Q7GM3osRM8mSGVv6UhDD49gYULInYaJQT7plLTZFnyHlHfUc3Hx85Jwi1Hobip+051HJE+PV3gt97t3KJFgF4EPBY8vFpjZo9XFDbpXiobuSawUxYVRaoHaTTq1C4n+prUndHk6wtUftQjt5WQ51B4EbZQrpj/VrcDh/sOZ+/1iED5v6xv0xtGJ8zkP6qahOGPRthPIRLybaaxFlP4J6QyZAFK8MeEG71+OB7TGo7yIWgUPBUcZA7uMCGp19sEA480otAUgbzj4fkNWPY0qD8r5U+YSrUBp0NyTsynOVD1iTBMyAExg9KSs+rNFVbCTP5s2Dbfx++Cx4ku+nf34add5omn0RxIObFz/+UpHlpauP+ciIX7uZ7ohwefbImnmRmkIEGNqhZPyStVyjz04VnMIv0MuM9/Ny+45aExI02GlHC7ZESF07qe4AAB6p2WoJcMIrw6JE7yPcbooAVJts4H5UjfV9UQcqVEF74qIBPZtsDqPUjdwsYulaYymIvn/ayeMLunf/AB231YzK4SQgHUbH42LkOMImO7bUJdjiPK2G80petERwq+teaRjZ2LnijJvPjopoBu/VJDgdAfMfbGL+buDDf7ELskjvEYYB8SFlGrqd7COxG0oOncCuNX6SQ9HyN1Fyu7K2lW3lFlbDCN1Y998AZyANIh9WXwIN3687g1p1erMKrj8y5nXl1bFL3c4HGJxSSpGBIt6L+wCpFBSnwnXfeMyQRAAzo= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(396003)(376002)(36840700001)(46966006)(86362001)(47076005)(82740400003)(478600001)(36860700001)(7636003)(36756003)(426003)(36906005)(34020700004)(2616005)(16526019)(26005)(186003)(83380400001)(7696005)(55016002)(356005)(2906002)(8936002)(8676002)(54906003)(30864003)(6636002)(5660300002)(336012)(70206006)(37006003)(1076003)(4326008)(6286002)(6862004)(316002)(70586007)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2021 13:16:52.1577 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07edf383-9fb2-4045-bf07-08d946007b64 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2583 Subject: [dpdk-dev] [PATCH v2 14/14] common/mlx5: clean up legacy PCI bus driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Clean up legacy PCI bus driver since all mlx5 PMDs moved to new common PCI bus driver. Signed-off-by: Xueming Li --- drivers/common/mlx5/linux/mlx5_common_os.h | 1 - drivers/common/mlx5/mlx5_common.c | 1 - drivers/common/mlx5/mlx5_common.h | 1 + drivers/common/mlx5/mlx5_common_pci.c | 433 +-------------------- drivers/common/mlx5/mlx5_common_pci.h | 77 ---- drivers/common/mlx5/mlx5_common_private.h | 1 + drivers/common/mlx5/version.map | 3 - 7 files changed, 4 insertions(+), 513 deletions(-) delete mode 100644 drivers/common/mlx5/mlx5_common_pci.h diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index 86d0cb09b0..2b03bf811e 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -289,7 +289,6 @@ mlx5_os_free(void *addr) free(addr); } -__rte_internal struct ibv_device * mlx5_os_get_ibv_device(const struct rte_pci_addr *addr); diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index c258cd127a..558474c706 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -14,7 +14,6 @@ #include "mlx5_common.h" #include "mlx5_common_os.h" #include "mlx5_common_log.h" -#include "mlx5_common_pci.h" #include "mlx5_common_private.h" uint8_t haswell_broadwell_cpu; diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 26d1b58853..f28ca938cf 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 6fe28defbf..8b38091d87 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -8,431 +8,17 @@ #include #include #include +#include +#include #include "mlx5_common_log.h" -#include "mlx5_common_pci.h" #include "mlx5_common_private.h" static struct rte_pci_driver mlx5_common_pci_driver; -/********** Legacy PCI bus driver, to be removed ********/ - -struct mlx5_pci_device { - struct rte_pci_device *pci_dev; - TAILQ_ENTRY(mlx5_pci_device) next; - uint32_t classes_loaded; -}; - -/* Head of list of drivers. */ -static TAILQ_HEAD(mlx5_pci_bus_drv_head, mlx5_pci_driver) drv_list = - TAILQ_HEAD_INITIALIZER(drv_list); - -/* Head of mlx5 pci devices. */ -static TAILQ_HEAD(mlx5_pci_devices_head, mlx5_pci_device) devices_list = - TAILQ_HEAD_INITIALIZER(devices_list); - -static const struct { - const char *name; - unsigned int driver_class; -} mlx5_classes[] = { - { .name = "vdpa", .driver_class = MLX5_CLASS_VDPA }, - { .name = "net", .driver_class = MLX5_CLASS_NET }, - { .name = "regex", .driver_class = MLX5_CLASS_REGEX }, - { .name = "compress", .driver_class = MLX5_CLASS_COMPRESS }, -}; - -static const unsigned int mlx5_class_combinations[] = { - MLX5_CLASS_NET, - MLX5_CLASS_VDPA, - MLX5_CLASS_REGEX, - MLX5_CLASS_COMPRESS, - MLX5_CLASS_NET | MLX5_CLASS_REGEX, - MLX5_CLASS_VDPA | MLX5_CLASS_REGEX, - MLX5_CLASS_NET | MLX5_CLASS_COMPRESS, - MLX5_CLASS_VDPA | MLX5_CLASS_COMPRESS, - MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS, - MLX5_CLASS_NET | MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS, - MLX5_CLASS_VDPA | MLX5_CLASS_REGEX | MLX5_CLASS_COMPRESS, - /* New class combination should be added here. */ -}; - -static int -class_name_to_value(const char *class_name) -{ - unsigned int i; - - for (i = 0; i < RTE_DIM(mlx5_classes); i++) { - if (strcmp(class_name, mlx5_classes[i].name) == 0) - return mlx5_classes[i].driver_class; - } - return -EINVAL; -} - -static struct mlx5_pci_driver * -driver_get(uint32_t class) -{ - struct mlx5_pci_driver *driver; - - TAILQ_FOREACH(driver, &drv_list, next) { - if (driver->driver_class == class) - return driver; - } - return NULL; -} - -static int -bus_cmdline_options_handler(__rte_unused const char *key, - const char *class_names, void *opaque) -{ - int *ret = opaque; - char *nstr_org; - int class_val; - char *found; - char *nstr; - char *refstr = NULL; - - *ret = 0; - nstr = strdup(class_names); - if (!nstr) { - *ret = -ENOMEM; - return *ret; - } - nstr_org = nstr; - found = strtok_r(nstr, ":", &refstr); - if (!found) - goto err; - do { - /* Extract each individual class name. Multiple - * class key,value is supplied as class=net:vdpa:foo:bar. - */ - class_val = class_name_to_value(found); - /* Check if its a valid class. */ - if (class_val < 0) { - *ret = -EINVAL; - goto err; - } - *ret |= class_val; - found = strtok_r(NULL, ":", &refstr); - } while (found); -err: - free(nstr_org); - if (*ret < 0) - DRV_LOG(ERR, "Invalid mlx5 class options %s." - " Maybe typo in device class argument setting?", - class_names); - return *ret; -} - -static int -parse_class_options(const struct rte_devargs *devargs) -{ - const char *key = RTE_DEVARGS_KEY_CLASS; - struct rte_kvargs *kvlist; - int ret = 0; - - if (devargs == NULL) - return 0; - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) - return 0; - if (rte_kvargs_count(kvlist, key)) - rte_kvargs_process(kvlist, key, bus_cmdline_options_handler, - &ret); - rte_kvargs_free(kvlist); - return ret; -} - -static bool -mlx5_bus_match(const struct mlx5_pci_driver *drv, - const struct rte_pci_device *pci_dev) -{ - const struct rte_pci_id *id_table; - - for (id_table = drv->pci_driver.id_table; id_table->vendor_id != 0; - id_table++) { - /* Check if device's ids match the class driver's ids. */ - if (id_table->vendor_id != pci_dev->id.vendor_id && - id_table->vendor_id != RTE_PCI_ANY_ID) - continue; - if (id_table->device_id != pci_dev->id.device_id && - id_table->device_id != RTE_PCI_ANY_ID) - continue; - if (id_table->subsystem_vendor_id != - pci_dev->id.subsystem_vendor_id && - id_table->subsystem_vendor_id != RTE_PCI_ANY_ID) - continue; - if (id_table->subsystem_device_id != - pci_dev->id.subsystem_device_id && - id_table->subsystem_device_id != RTE_PCI_ANY_ID) - continue; - if (id_table->class_id != pci_dev->id.class_id && - id_table->class_id != RTE_CLASS_ANY_ID) - continue; - return true; - } - return false; -} - -static int -is_valid_class_combination(uint32_t user_classes) -{ - unsigned int i; - - /* Verify if user specified valid supported combination. */ - for (i = 0; i < RTE_DIM(mlx5_class_combinations); i++) { - if (mlx5_class_combinations[i] == user_classes) - return 0; - } - /* Not found any valid class combination. */ - return -EINVAL; -} - -static struct mlx5_pci_device * -pci_to_mlx5_device(const struct rte_pci_device *pci_dev) -{ - struct mlx5_pci_device *dev; - - TAILQ_FOREACH(dev, &devices_list, next) { - if (dev->pci_dev == pci_dev) - return dev; - } - return NULL; -} - -static bool -device_class_enabled(const struct mlx5_pci_device *device, uint32_t class) -{ - return (device->classes_loaded & class) ? true : false; -} - -static void -dev_release(struct mlx5_pci_device *dev) -{ - TAILQ_REMOVE(&devices_list, dev, next); - rte_free(dev); -} - -static int -drivers_remove(struct mlx5_pci_device *dev, uint32_t enabled_classes) -{ - struct mlx5_pci_driver *driver; - int local_ret = -ENODEV; - unsigned int i = 0; - int ret = 0; - - enabled_classes &= dev->classes_loaded; - while (enabled_classes) { - driver = driver_get(RTE_BIT64(i)); - if (driver) { - local_ret = driver->pci_driver.remove(dev->pci_dev); - if (!local_ret) - dev->classes_loaded &= ~RTE_BIT64(i); - else if (ret == 0) - ret = local_ret; - } - enabled_classes &= ~RTE_BIT64(i); - i++; - } - if (local_ret) - ret = local_ret; - return ret; -} - -static int -drivers_probe(struct mlx5_pci_device *dev, struct rte_pci_driver *pci_drv, - struct rte_pci_device *pci_dev, uint32_t user_classes) -{ - struct mlx5_pci_driver *driver; - uint32_t enabled_classes = 0; - bool already_loaded; - int ret; - - TAILQ_FOREACH(driver, &drv_list, next) { - if ((driver->driver_class & user_classes) == 0) - continue; - if (!mlx5_bus_match(driver, pci_dev)) - continue; - already_loaded = dev->classes_loaded & driver->driver_class; - if (already_loaded && - !(driver->pci_driver.drv_flags & RTE_PCI_DRV_PROBE_AGAIN)) { - DRV_LOG(ERR, "Device %s is already probed", - pci_dev->device.name); - ret = -EEXIST; - goto probe_err; - } - ret = driver->pci_driver.probe(pci_drv, pci_dev); - if (ret < 0) { - DRV_LOG(ERR, "Failed to load driver %s", - driver->pci_driver.driver.name); - goto probe_err; - } - enabled_classes |= driver->driver_class; - } - dev->classes_loaded |= enabled_classes; - return 0; -probe_err: - /* Only unload drivers which are enabled which were enabled - * in this probe instance. - */ - drivers_remove(dev, enabled_classes); - return ret; -} - -/** - * DPDK callback to register to probe multiple drivers for a PCI device. - * - * @param[in] pci_drv - * PCI driver structure. - * @param[in] dev - * PCI device information. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *pci_dev) -{ - struct mlx5_pci_device *dev; - uint32_t user_classes = 0; - bool new_device = false; - int ret; - - ret = parse_class_options(pci_dev->device.devargs); - if (ret < 0) - return ret; - user_classes = ret; - if (user_classes) { - /* Validate combination here. */ - ret = is_valid_class_combination(user_classes); - if (ret) { - DRV_LOG(ERR, "Unsupported mlx5 classes supplied."); - return ret; - } - } else { - /* Default to net class. */ - user_classes = MLX5_CLASS_NET; - } - dev = pci_to_mlx5_device(pci_dev); - if (!dev) { - dev = rte_zmalloc("mlx5_pci_device", sizeof(*dev), 0); - if (!dev) - return -ENOMEM; - dev->pci_dev = pci_dev; - TAILQ_INSERT_HEAD(&devices_list, dev, next); - new_device = true; - } - ret = drivers_probe(dev, pci_drv, pci_dev, user_classes); - if (ret) - goto class_err; - return 0; -class_err: - if (new_device) - dev_release(dev); - return ret; -} - -/** - * DPDK callback to remove one or more drivers for a PCI device. - * - * This function removes all drivers probed for a given PCI device. - * - * @param[in] pci_dev - * Pointer to the PCI device. - * - * @return - * 0 on success, the function cannot fail. - */ -static int -mlx5_pci_remove(struct rte_pci_device *pci_dev) -{ - struct mlx5_pci_device *dev; - int ret; - - dev = pci_to_mlx5_device(pci_dev); - if (!dev) - return -ENODEV; - /* Matching device found, cleanup and unload drivers. */ - ret = drivers_remove(dev, dev->classes_loaded); - if (!ret) - dev_release(dev); - return ret; -} - -static int -mlx5_pci_dma_map(struct rte_pci_device *pci_dev, void *addr, - uint64_t iova, size_t len) -{ - struct mlx5_pci_driver *driver = NULL; - struct mlx5_pci_driver *temp; - struct mlx5_pci_device *dev; - int ret = -EINVAL; - - dev = pci_to_mlx5_device(pci_dev); - if (!dev) - return -ENODEV; - TAILQ_FOREACH(driver, &drv_list, next) { - if (device_class_enabled(dev, driver->driver_class) && - driver->pci_driver.dma_map) { - ret = driver->pci_driver.dma_map(pci_dev, addr, - iova, len); - if (ret) - goto map_err; - } - } - return ret; -map_err: - TAILQ_FOREACH(temp, &drv_list, next) { - if (temp == driver) - break; - if (device_class_enabled(dev, temp->driver_class) && - temp->pci_driver.dma_map && temp->pci_driver.dma_unmap) - temp->pci_driver.dma_unmap(pci_dev, addr, iova, len); - } - return ret; -} - -static int -mlx5_pci_dma_unmap(struct rte_pci_device *pci_dev, void *addr, - uint64_t iova, size_t len) -{ - struct mlx5_pci_driver *driver; - struct mlx5_pci_device *dev; - int local_ret = -EINVAL; - int ret; - - dev = pci_to_mlx5_device(pci_dev); - if (!dev) - return -ENODEV; - ret = 0; - /* There is no unmap error recovery in current implementation. */ - TAILQ_FOREACH_REVERSE(driver, &drv_list, mlx5_pci_bus_drv_head, next) { - if (device_class_enabled(dev, driver->driver_class) && - driver->pci_driver.dma_unmap) { - local_ret = driver->pci_driver.dma_unmap(pci_dev, addr, - iova, len); - if (local_ret && (ret == 0)) - ret = local_ret; - } - } - if (local_ret) - ret = local_ret; - return ret; -} - /* PCI ID table is build dynamically based on registered mlx5 drivers. */ static struct rte_pci_id *mlx5_pci_id_table; -static struct rte_pci_driver mlx5_pci_driver = { - .driver = { - .name = MLX5_PCI_DRIVER_NAME, - }, - .probe = mlx5_pci_probe, - .remove = mlx5_pci_remove, - .dma_map = mlx5_pci_dma_map, - .dma_unmap = mlx5_pci_dma_unmap, -}; - static int pci_id_table_size_get(const struct rte_pci_id *id_table) { @@ -509,7 +95,6 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table) } /* Terminate table with empty entry. */ updated_table[i].vendor_id = 0; - mlx5_pci_driver.id_table = updated_table; mlx5_common_pci_driver.id_table = updated_table; mlx5_pci_id_table = updated_table; if (old_table) @@ -517,20 +102,6 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table) return 0; } -void -mlx5_pci_driver_register(struct mlx5_pci_driver *driver) -{ - int ret; - - ret = pci_ids_table_update(driver->pci_driver.id_table); - if (ret) - return; - mlx5_pci_driver.drv_flags |= driver->pci_driver.drv_flags; - TAILQ_INSERT_TAIL(&drv_list, driver, next); -} - -/********** New common PCI bus driver ********/ - bool mlx5_dev_is_pci(const struct rte_device *dev) { diff --git a/drivers/common/mlx5/mlx5_common_pci.h b/drivers/common/mlx5/mlx5_common_pci.h deleted file mode 100644 index de89bb98bc..0000000000 --- a/drivers/common/mlx5/mlx5_common_pci.h +++ /dev/null @@ -1,77 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2020 Mellanox Technologies, Ltd - */ - -#ifndef _MLX5_COMMON_PCI_H_ -#define _MLX5_COMMON_PCI_H_ - -/** - * @file - * - * RTE Mellanox PCI Driver Interface - * Mellanox ConnectX PCI device supports multiple class: net,vdpa,regex and - * compress devices. This layer 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 driver. - * - * ----------- ------------ ------------- ---------------- - * | mlx5 | | mlx5 | | mlx5 | | mlx5 | - * | net pmd | | vdpa pmd | | regex pmd | | compress pmd | - * ----------- ------------ ------------- ---------------- - * \ \ / / - * \ \ / / - * \ \_--------------_/ / - * \_______________| mlx5 |_______________/ - * | pci common | - * -------------- - * | - * ----------- - * | mlx5 | - * | pci dev | - * ----------- - * - * - mlx5 pci 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 - -void mlx5_common_pci_init(void); - -/** - * A structure describing a mlx5 pci driver. - */ -struct mlx5_pci_driver { - struct rte_pci_driver pci_driver; /**< Inherit core pci driver. */ - uint32_t driver_class; /**< Class of this driver, enum mlx5_class */ - TAILQ_ENTRY(mlx5_pci_driver) next; -}; - -/** - * Register a mlx5_pci device driver. - * - * @param driver - * A pointer to a mlx5_pci_driver structure describing the driver - * to be registered. - */ -__rte_internal -void -mlx5_pci_driver_register(struct mlx5_pci_driver *driver); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _MLX5_COMMON_PCI_H_ */ diff --git a/drivers/common/mlx5/mlx5_common_private.h b/drivers/common/mlx5/mlx5_common_private.h index 1096fa85e7..c929840408 100644 --- a/drivers/common/mlx5/mlx5_common_private.h +++ b/drivers/common/mlx5/mlx5_common_private.h @@ -31,6 +31,7 @@ int mlx5_common_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, /* Common PCI bus driver: */ +void mlx5_common_pci_init(void); void mlx5_common_driver_on_register_pci(struct mlx5_class_driver *driver); bool mlx5_dev_pci_match(const struct mlx5_class_driver *drv, const struct rte_device *dev); diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index a47c86e354..da91d167b5 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -138,13 +138,10 @@ INTERNAL { mlx5_nl_vlan_vmwa_create; # WINDOWS_NO_EXPORT mlx5_nl_vlan_vmwa_delete; # WINDOWS_NO_EXPORT - mlx5_pci_driver_register; - mlx5_os_alloc_pd; mlx5_os_dealloc_pd; mlx5_os_dereg_mr; mlx5_os_get_ibv_dev; # WINDOWS_NO_EXPORT - mlx5_os_get_ibv_device; # WINDOWS_NO_EXPORT mlx5_os_reg_mr; mlx5_os_umem_dereg; mlx5_os_umem_reg; -- 2.25.1