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 3218CA0548; Thu, 27 May 2021 15:39:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB09F41129; Thu, 27 May 2021 15:39:05 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2043.outbound.protection.outlook.com [40.107.236.43]) by mails.dpdk.org (Postfix) with ESMTP id 9AC7D410F9 for ; Thu, 27 May 2021 15:39:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HnAHwZuCfgcjhCEI9r5r5eLjE8gsCTtzjYdxLDTqLGWDeQaCokSXr+ojFpZu1UVEVkh0LS9TCE5KKhNwMxLoy7Az4WS88N3WR05UhEoEiFjXBRxjNBKSZX3Ir2I8yzFz9sveAYOQyrh4AUBACgx9xwPhpe85shOnl9s6mU8gc9OzQzl9QdBbW2BuUVw1IbKtlREBQEuRpsdMnmNNOH6PVnFrRQ3CMej1BgNn6PUQNegdrFZVPzp5xBk6RSprAaRJPLuGTvVU8I9sNG+YV8ozq+SzsxZHUdutivqU69jXum/Y+RgdeNd21+RnD6CAvh10ayVCA/ZYrEoaMO0zl3pxHQ== 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=Ma6lusVONP5FdWPz30sm7ibDLqkbm2L/sYoDc4GyxF8=; b=n0EHfkljbw0KZIiRqUbs4ORwndpmvO/hmyC11LuJXudvxS3Ge0iSG89D0KLCjoe9nZVi9hP1M5+WRAXCldo9wS1VOWo0CrCAEBSmLixsOgqDD9WezcB/VWAwM1aqjm3pTi4jdw6H416dvOAiuWCQ9N4xlmu4s1blxyMhRpq6RAvXXrwOWLK6OjsSLrgKYj7+wPog69ebpDL5aVj1q/Lu/w1ZUu2cCUQGfWZ3/LSsAf59bI+6Yv3JtF6fCffe3VCdiLKENg55xidNwfNgnCWdy6R9T80Vp6SA3hXiGshW8egnHpzuUpwfGv4DP2aJmhftOswXJP2xL+zg9XvAo8b6zQ== 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=Ma6lusVONP5FdWPz30sm7ibDLqkbm2L/sYoDc4GyxF8=; b=hnTO3KSJAIWC8QNksPD3lD4RrvtHMbGIE/dK4p0iD46yySOyijlb0hB4uclasDrCxKZM86NwCdxTN7pyr4fYIVtBzwLw3jDy8M08Ztl9qC5P8QbepjC9Xv4SUdxspFyLigXvl/LhZVw1etFZaf+cYHrqxyw31MF+mwMp+ik2grHGiWf+rPssprA7DLSsIA/ProlryVUzqszU468KyvB3sxrfZjcLYBsagnc9zGTFmkEutYcQ8MIFt7b7iyco/CI+dtCb2hIFTOhFSdg+frG/fBXaYoqZkt0D89O3S5RdaCAqOcI+4fXt8NJEwpPQ2eMdzHgzJXzktpt+/2Jb5JQf5g== Received: from CO2PR04CA0165.namprd04.prod.outlook.com (2603:10b6:104:4::19) by MWHPR1201MB0128.namprd12.prod.outlook.com (2603:10b6:301:56::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Thu, 27 May 2021 13:39:01 +0000 Received: from CO1NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:104:4:cafe::e3) by CO2PR04CA0165.outlook.office365.com (2603:10b6:104:4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Thu, 27 May 2021 13:39:01 +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 CO1NAM11FT035.mail.protection.outlook.com (10.13.175.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Thu, 27 May 2021 13:39:01 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 May 2021 13:38:59 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Matan Azrad , Fiona Trahe , Ashish Gupta Date: Thu, 27 May 2021 16:37:51 +0300 Message-ID: <20210527133759.17401-7-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210527133759.17401-1-xuemingl@nvidia.com> References: <20210527133759.17401-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c64243e3-7c33-4279-0621-08d92114c982 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0128: 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: YgNGqxj8q+WbGxa6eIhPCDJMzv7IO/pY3pzPl+6cE5zIHyTlKZZmqGxfvY2mRnlgTsRLNG9cAGO4XKYXda65HunLBN6agQYw8cLvkqPqJkgWt6HF1TXVyCong+LBzhQx23X8x1Y1MF8MrVWHF8rv4Os7o4XlEzidVrTKVjfdisRaM28vl2kg6StvBJv82QmoThJPhrMOjUssNmt34ITcRY3Ik6lSKqESJYr3pUmCr4ZT1lYK/5dnWQjWA4kotxKK/PAkoJmydKqbBnKc+E6nA4qJmKsh6nI1rdlLLw1uYHQUaO/qANjm4lGr+b1eza/DYnJml3hMGBLJkgi4jbPlXihEzt+EaLnn5umri0csYEC+lt8h4IwpJE2lLQKRrEbRkeKMlhJi/1nMp1kb9/73Vgx0ngePUfLIChukS8HXKoZxm3GKNJbApWNLz6q8drqWUOGm8DMkp4P+Xr0STYI6ue+np46pxJSZAM3xjGoU6wJlETIbuH5cwda9YEHOsliEP6inyoAmsQN72NIo2mT6bgnnmtRCb9ALJ5zS9T42wKNV4TsfzLUZpbMX7xXE3/Glz/DGJSCa2dTz/eA2Dur9C7EF/idMqab50TdswXI+fB2kqKdU1NZHgdnwkOVnu5uUAYNPlMLAoAPCLSKYuqJ4GQ== 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)(376002)(136003)(39860400002)(396003)(346002)(36840700001)(46966006)(36860700001)(7696005)(54906003)(36906005)(82310400003)(86362001)(7636003)(83380400001)(37006003)(316002)(6862004)(6286002)(55016002)(8936002)(478600001)(4326008)(8676002)(6666004)(6636002)(82740400003)(47076005)(2906002)(2616005)(186003)(336012)(16526019)(26005)(426003)(36756003)(70586007)(70206006)(1076003)(356005)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2021 13:39:01.2380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c64243e3-7c33-4279-0621-08d92114c982 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: CO1NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0128 Subject: [dpdk-dev] [RFC 06/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..10d64a72d6 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_get_ibv_device(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