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 722E5A0C46; Mon, 19 Jul 2021 04:56:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DAD7D411C8; Mon, 19 Jul 2021 04:56:04 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) by mails.dpdk.org (Postfix) with ESMTP id 1F06E411B0 for ; Mon, 19 Jul 2021 04:56:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbjPPug0SeDmbPOExCs2VwYBXTyJ8GPUzlGS/63BsQhmRIXT98zLX9IKNdi1M5Q3ePwWMjRfKggcKXX6CThVzDMzBEK2ioEvAx1QAft9K/8YxmZ4fmeFA/GGKJBvxca3QJKBXqv5cM+5SyMJsa3KMdX3Dc27B7wnc4k80kFQk9GWoeeTkUtqWJh2QO+odgLKdBluO4NB/dg/5r8JDK/RIkIlmIMmYBagurIcGHuzfR2fXGfy0Qb/+HEUf3F/V/CxUB7wrN8zCM9KwwbxbcN6VuRHSRlG68JGcgt0wutgrZW1twtxR4nhziwUR/e9LcLdZhXHx4DALo7ZYXLP9nVt8A== 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=oL+9XoZUdDjlw5s4D9fqRgisoPLeOY2ZpuMeZVckHg9lvMKlTjzXb2jA1OByDQhbbWHi9j1QpdxIJaA4rlwsyUbrETON7ndZZ8kozRNoKrohk24qOtVxYuOABj/S7jExweCQiJ4sYVRodtaxLSiY3AvCEwMoUiV75cP5qBKbKR77EdnCHP3Uvyz1qPlwmLmucMprG31u/tSDahHp5+t9XWwavWqQjvMyGdsQkxbM0+JVFs1Tao6HOnreZKvK3L2wtcjKuUt5WHmMh/2A5iQHfYiPSPiy2fpAYgDvUzDc4AvPHXj62RXrWa1rzY3wO4cGX+OXZD06QYmwa4C3712qVQ== 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=quarantine 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=SjUAuZwSIWSydilLOWrZvdM5XIiziYeH2jkVG/Gkeo23JZliIGOqsCSjOgTf7eP0k3Xc8AIBMSdR8QKydLBZO8ebbtORKWj25TetHgzih9OMT2EHT+PPUy3p6QqrgWBF4x5OuQdzfoJTB5j+vnxR6vja/JPy4UewU1aQ3tQdXIO9dPdD3bHLuCtZ4rsvXeHvZgsXoIqPvL0obrZKoCiLTUdPYE0TLv8a0rljjHI51u6YUcg3Y5xuxiS4mCptL6LVo/nkPdVMXlbt4qw2Bt4pgLCsgNr3WV4lPNGVLytezIQPXvEbKnDkk4M0sN9T1tBlRiCSshHjE/S8Oqgn6vD9bg== Received: from MW4PR03CA0091.namprd03.prod.outlook.com (2603:10b6:303:b7::6) by CY4PR12MB1606.namprd12.prod.outlook.com (2603:10b6:910:10::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Mon, 19 Jul 2021 02:55:59 +0000 Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b7:cafe::a2) by MW4PR03CA0091.outlook.office365.com (2603:10b6:303:b7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23 via Frontend Transport; Mon, 19 Jul 2021 02:55:59 +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 CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 02:55:59 +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; Mon, 19 Jul 2021 02:55:56 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Matan Azrad , Fiona Trahe , Ashish Gupta Date: Mon, 19 Jul 2021 10:54:09 +0800 Message-ID: <20210719025410.15483-15-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210713131437.30170-2-xuemingl@nvidia.com> References: <20210713131437.30170-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5d92bf2-4445-419b-e690-08d94a60bca4 X-MS-TrafficTypeDiagnostic: CY4PR12MB1606: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6xeq/HjZx+QfSNlrX1FMcu2h632w3cAZtWW3j7m12aHAFNb8Picx5K4XrH8loaGPaKtB3WteuX4BLxCWCBUQ35wkn4DHV7PCdFuvJDbPAu1P4q4oFeWW0r4pAaGce9//LbYl1dLxKgo5VpmgMP7CMRnpHITn/+gPuGNQGiQ6rYDd0qZyjIp32TJ3/z2fHiA7ariIKB9ZQZvTiEXjjH4LIwhbDxypHJN9FQ31ucOTcbHpZjlvOY5PI8prz0SqIFZy0cIs2/MjUhUlTAH9zNR87CYR+losLynXxtmGZCD/AoexHRsaDxiG4/ozNnhRFlwOuM2C6tRnNiYEwSUVZyulT0VGOZ2iPdmj6vnSAeZvyBCr6xzGxYgYy+f24mkkVfD1GqyrXFqXA9ytbqyqE5b0fzHqGd/B0tkBMsLRUHK9fBx4wY11nYxBBynNYl0LGWLgk102lOFQXuwwBT4keHN4h2VJk4kV1HOWqbIVb/p00nQfK+vWkPodra4RVpfOKqjAyn4vhS0X1TWmJ9hXRS5OjY8G0dvoqqM6zHNDyQ9STJ1GPwM0mym0sRUA5JauDh7cD8GTxoXfoz8lSsP5cOkqo0Lf69ptLBHntz29P4cb7aWSZRJDEhs40B6frcqMV/8ecfarNUfg9dClA+Gfv38mpHy7Ysyakls5zFMb/yb8fMQOb1MjNDL2xK1Y5kH1pAaiIVFVt0jj6w48PDjUcImheg== 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)(136003)(39860400002)(346002)(396003)(376002)(46966006)(36840700001)(82740400003)(2906002)(6636002)(336012)(7696005)(37006003)(55016002)(186003)(2616005)(6862004)(5660300002)(8936002)(26005)(6286002)(7636003)(6666004)(83380400001)(47076005)(4326008)(36756003)(356005)(316002)(16526019)(36906005)(426003)(36860700001)(8676002)(70206006)(82310400003)(478600001)(86362001)(54906003)(70586007)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 02:55:59.0785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5d92bf2-4445-419b-e690-08d94a60bca4 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: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1606 Subject: [dpdk-dev] [PATCH v3 14/15] 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