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 13984A0C51; Tue, 13 Jul 2021 15:17:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4820412AA; Tue, 13 Jul 2021 15:16:54 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2063.outbound.protection.outlook.com [40.107.101.63]) by mails.dpdk.org (Postfix) with ESMTP id 01DEF41289 for ; Tue, 13 Jul 2021 15:16:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+w8OdXAHQLCduTEy6TfnRJO85ia1VTk+70c7x2BXb81WJUablRZsjzyYvCN+PXgO2mNm2nHbhV72Rnw3hhV8tW4ze+ScUopmCN0t/p9CAkn9NJKVHSenv355DRmnkh7JJkLsQPd/x1RIVu7a0Uux7UjISFYKnu1VTR5RYGPfDkMR9TDJWz60t2mIXnqSrqu83dexA8GY6/bHSA5zh24AMbgcYY9zdjzuvoQYLRWn29xJfowYn/YIEhkcoA+JrN+KOyHrG/ZTHr3dvIN+tRcZW2+MbwVYmZpJTDm7jxNEWAZ2Q41qYpfph8yEyldT4iLAgsD2JWwurkE/t5xVOXTzw== 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=yIrFe2ZOlwhlHsJ1fY7U+iesWwWW5wQ8ZdM9JXNUKcg=; b=P2eEqyt/oVVgtPaas1vkzxwpR7M5hOETxws6ReEDklXuoJtgWbFOMdvThldXMmP2KKFTU1a85Xzr08TX88vR/FSOJ341eoXtyqjHvb+RTkQZv/gW+o0RB/55Wl2S/FI0OYMsbmCRz5Bpa/7v8VriyPwywKCOHawMLABIvlZ74rNh7QEgmfvYNQdzlhSosS00vI8V95TAISuvtvSwnL+QJigRC7UdTd0lmrD8XQtUziepKb3Fd8Xc71GAOgKVmNQm8zIQ738YkAx+zRX9xALZdJT5nYORbMbjI7RjtTSf5/QXPFNKu0GdNPni5JK3YC4SdA6DK/nmNsNFyRc6AWRTJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=marvell.com 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=yIrFe2ZOlwhlHsJ1fY7U+iesWwWW5wQ8ZdM9JXNUKcg=; b=qtx2zMZFC3cYZNrPIo32+OPQvD8Jxt3MpcMMQxWEM4WVXySRlJFn1ultN0qfIT6g8/UhbqskXJYqnrz5Hv8uP3yA10mko4z2ejBz2yUZ16wvgK70e6JXoAvJZ9IhoK+vZM/1kKvBNHxkB6AxgVKEMysbiuGtD2Iv7sZfmsNIb7HzLc3mmKuYqry+kvmWmH5ixy1jYAmOKZHbEAB7eSRaM9p3W/YRrHEXSst0Pl2tKC2OagVN9gBsmOlrRSx772MAM/vCxKpWXtmuq61Pgm6L7wxReflDrJvZ8tkrcfCFHVeksLzeupZexrgRuD5c/TBjvrMgcujHjO/QJ/WYVKBzmQ== Received: from MW4PR03CA0052.namprd03.prod.outlook.com (2603:10b6:303:8e::27) by BY5PR12MB4196.namprd12.prod.outlook.com (2603:10b6:a03:205::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Tue, 13 Jul 2021 13:16:51 +0000 Received: from CO1NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::1) by MW4PR03CA0052.outlook.office365.com (2603:10b6:303:8e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 13 Jul 2021 13:16:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; marvell.com; dkim=none (message not signed) header.d=none;marvell.com; 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:50 +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:35 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Matan Azrad , Fiona Trahe , Ashish Gupta Date: Tue, 13 Jul 2021 21:14:36 +0800 Message-ID: <20210713131437.30170-14-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: 56dcf1c0-8d04-4a95-8a85-08d9460079f3 X-MS-TrafficTypeDiagnostic: BY5PR12MB4196: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BLmlOosbdC6hUlkpcZQfb6Fsgja/yB8NXU8eoTzIo/PDo+tyf34G/fE0yQBW9LLuTWZ3Ndzvc6GeBvhYDEDmoWlLCwVP4Ne4xAp9kgCa+HTQ1zbClSQ1H1YpAa5RXptrrw9/kxo9Nu3VeQFCt4uyBKsOiXcGe/AiVeKmifH9r0I9UlcvG/3zqdZQ8YM2CssgC6PROWaVIqm021r6tr+mNIay5BUlxENt4Xzg8a3noJSOzFyo80mEzuDtAYHGhDj38xEwmPdx8pNn4RP+8PAdjFWYrxbGARGFS+57/szirM5bM+zaNUMAKta0RIuIfRkuSr3TcydFvsnY6gdns1NUVO7BjTN1Fu+C9orvOGKvyi9WTTk7NNa6bw/5AzgpXU1nfRK9Qik7shSLkstV2nBiY6HxBLU/FslAiUOPrJKi472gOOqbzzXu3TaW5BtPFJACU4yFiA8Gw36RZhmOAW7QQhTB0KNWf+2NxkCu1uSwj+9etFS26geHHt1KRRrxo5d5IvQgPFxNDcHoFb4iSqtFZBTvjWwKzVMSV4tasdGG2KLbE9ZEznbE2FslGuMt0BBTPiVykjzI6512WoaHt8jblIyygy5BUlzP7JiZdK71yT3iOoY24TObiJR8woaQRrq+vqdqv/U6tiBCwv1LhFa3Ft836IUkREevZH1PxAKlwEkDP2EL/zbhtTrhmCX6EPZyNeWq6meout1BNCuxhWjBf9n8AMuERnjET+VqzovCUjw= 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)(396003)(346002)(39860400002)(376002)(136003)(46966006)(36840700001)(8936002)(6862004)(8676002)(6286002)(2616005)(316002)(336012)(47076005)(4326008)(36906005)(426003)(83380400001)(356005)(6636002)(82310400003)(37006003)(1076003)(34020700004)(5660300002)(36860700001)(7636003)(36756003)(26005)(54906003)(86362001)(478600001)(70206006)(16526019)(70586007)(186003)(55016002)(7696005)(82740400003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2021 13:16:50.8334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56dcf1c0-8d04-4a95-8a85-08d9460079f3 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: BY5PR12MB4196 Subject: [dpdk-dev] [PATCH v2 13/14] compress/mlx5: migrate to common 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" To support auxiliary bus, upgrades driver to use mlx5 common driver structure. Signed-off-by: Xueming Li --- drivers/compress/mlx5/mlx5_compress.c | 71 ++++++--------------------- 1 file changed, 15 insertions(+), 56 deletions(-) diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index 80c564f10b..77f426e399 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -37,7 +36,6 @@ struct mlx5_compress_xform { struct mlx5_compress_priv { TAILQ_ENTRY(mlx5_compress_priv) next; struct ibv_context *ctx; /* Device context. */ - struct rte_pci_device *pci_dev; struct rte_compressdev *cdev; void *uar; uint32_t pdn; /* Protection Domain number. */ @@ -711,23 +709,8 @@ mlx5_compress_hw_global_prepare(struct mlx5_compress_priv *priv) return 0; } -/** - * DPDK callback to register a PCI device. - * - * This function spawns compress device out of a given PCI device. - * - * @param[in] pci_drv - * PCI driver structure (mlx5_compress_driver). - * @param[in] pci_dev - * PCI device information. - * - * @return - * 0 on success, 1 to skip this driver, a negative errno value otherwise - * and rte_errno is set. - */ static int -mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, - struct rte_pci_device *pci_dev) +mlx5_compress_dev_probe(struct rte_device *dev) { struct ibv_device *ibv; struct rte_compressdev *cdev; @@ -736,24 +719,17 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, struct mlx5_hca_attr att = { 0 }; struct rte_compressdev_pmd_init_params init_params = { .name = "", - .socket_id = pci_dev->device.numa_node, + .socket_id = dev->numa_node, }; - RTE_SET_USED(pci_drv); if (rte_eal_process_type() != RTE_PROC_PRIMARY) { DRV_LOG(ERR, "Non-primary process type is not supported."); rte_errno = ENOTSUP; return -rte_errno; } - ibv = mlx5_os_get_ibv_device(&pci_dev->addr); - if (ibv == NULL) { - DRV_LOG(ERR, "No matching IB device for PCI slot " - PCI_PRI_FMT ".", pci_dev->addr.domain, - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function); + ibv = mlx5_os_get_ibv_dev(dev); + if (ibv == NULL) return -rte_errno; - } - DRV_LOG(INFO, "PCI information matches for device \"%s\".", ibv->name); ctx = mlx5_glue->dv_open_device(ibv); if (ctx == NULL) { DRV_LOG(ERR, "Failed to open IB device \"%s\".", ibv->name); @@ -769,7 +745,7 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, rte_errno = ENOTSUP; return -ENOTSUP; } - cdev = rte_compressdev_pmd_create(ibv->name, &pci_dev->device, + cdev = rte_compressdev_pmd_create(ibv->name, dev, sizeof(*priv), &init_params); if (cdev == NULL) { DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name); @@ -784,7 +760,6 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; priv = cdev->data->dev_private; priv->ctx = ctx; - priv->pci_dev = pci_dev; priv->cdev = cdev; priv->min_block_size = att.compress_min_block_size; priv->sq_ts_format = att.sq_ts_format; @@ -810,25 +785,14 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, return 0; } -/** - * DPDK callback to remove a PCI device. - * - * This function removes all compress devices belong to a given PCI device. - * - * @param[in] pci_dev - * Pointer to the PCI device. - * - * @return - * 0 on success, the function cannot fail. - */ static int -mlx5_compress_pci_remove(struct rte_pci_device *pdev) +mlx5_compress_dev_remove(struct rte_device *dev) { struct mlx5_compress_priv *priv = NULL; pthread_mutex_lock(&priv_list_lock); TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next) - if (rte_pci_addr_cmp(&priv->pci_dev->addr, &pdev->addr) != 0) + if (priv->cdev->device == dev) break; if (priv) TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next); @@ -852,24 +816,19 @@ static const struct rte_pci_id mlx5_compress_pci_id_map[] = { } }; -static struct mlx5_pci_driver mlx5_compress_driver = { - .driver_class = MLX5_CLASS_COMPRESS, - .pci_driver = { - .driver = { - .name = RTE_STR(MLX5_COMPRESS_DRIVER_NAME), - }, - .id_table = mlx5_compress_pci_id_map, - .probe = mlx5_compress_pci_probe, - .remove = mlx5_compress_pci_remove, - .drv_flags = 0, - }, +static struct mlx5_class_driver mlx5_compress_driver = { + .drv_class = MLX5_CLASS_COMPRESS, + .name = RTE_STR(MLX5_COMPRESS_DRIVER_NAME), + .id_table = mlx5_compress_pci_id_map, + .probe = mlx5_compress_dev_probe, + .remove = mlx5_compress_dev_remove, }; RTE_INIT(rte_mlx5_compress_init) { mlx5_common_init(); if (mlx5_glue != NULL) - mlx5_pci_driver_register(&mlx5_compress_driver); + mlx5_class_driver_register(&mlx5_compress_driver); } RTE_LOG_REGISTER_DEFAULT(mlx5_compress_logtype, NOTICE) -- 2.25.1