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 6CCD1A0C51; Wed, 21 Jul 2021 16:40:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A12744113E; Wed, 21 Jul 2021 16:39:38 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2049.outbound.protection.outlook.com [40.107.102.49]) by mails.dpdk.org (Postfix) with ESMTP id 9E24941164 for ; Wed, 21 Jul 2021 16:39:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nmf60psGRqyzZ/DKPYNbsYXSG3MLLU9mGwNdLW04ZfrWQmUYW9YGUv4E1FCCAqffmDztYyYJNPFH6dfP1Rv193YG8WRtB7wVC4XTL6b3s2XH2GmQk7dFiim1KNSV8gpA4ZB1liUSpbJwYHPPctnrKpXyHMeORguBxiY6CFQlLzABMzt4MfOODWfADeD+bcoNI/JAsmqVxKPZAs6WD+G1ZFuJQO1Fw8CQJHBJr4hGOZl+T2oYsde1iei+MAMzpDFrTQNoSqJ9h4m7Q9dQlzyv2y8S0L47rWkSVvNTOHa3xeUfocE8vXesFvut00KfhqwoFRcxoXd3TMMXXoU9kNgtlw== 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=BOeHXbRB8KYMmw13fPNgKl/aJDNifRRIrsXweF6geO4=; b=it/slazCk2/yi9Skt1JNO4SRAt6Hw+xiI/4hGvq6PDgZm7QlCSpu0+/NV5NDStJJsHypGhceGGaSIH+p41Y9Zl4drdvZi5PGBQi1WmADdUSZI6l5GkeQwGFMrUeQBTw4WeUPe5ckYHq/peNNRRYKh3fl4EbdJbFZPt7MPXYh0ZAYDrj1GJAjRSjVMtI8aBIFzODkDaLIbRMh92E7PTV41O2TabyVUONOG4d1ElC9uoYxWzaUYi2IGB/buir7UHuBUOkxvvKPlk7KJtE3Mln+UDQMAxXDEGUgh8jFclRZIo8sc3pjUfhClsQRyIqh8RVigEhguZGTPOrT4Z7p8pO2MA== 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=BOeHXbRB8KYMmw13fPNgKl/aJDNifRRIrsXweF6geO4=; b=JpRB9AhRTS7rjWSpSzS3l5/qeLGn+czrUb25yLSri9mafzaRCTLvR/91Mprp2FbzoaYuUjQlil+hzuFFdXVm19Hm2SGk3cMHuEEQDQg8DHzvmHp2XKnyz+smj2gXyjhMZyRRN2iQpG833oB9ShuMBo6QpXnzAkAoXeKN1yKLyWS2mTOm8Zf+ejSxQl7FqEbnsSXqVg3UshB2Mb1gZQdDfCfyrV+FURzUtljrSKN5vKo9YDR8eZIiMN8fCw08MuMPvXlTYSHknYBjKgRgpX67Vmogg1rBfXqSZjFR+KVaKXXtz5f5GUgGSOvSTO7+iZehz/zqDif9MvLn8LtEqhn1hA== Received: from BN9PR03CA0228.namprd03.prod.outlook.com (2603:10b6:408:f8::23) by BN6PR12MB1828.namprd12.prod.outlook.com (2603:10b6:404:108::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Wed, 21 Jul 2021 14:39:35 +0000 Received: from BN8NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f8:cafe::20) by BN9PR03CA0228.outlook.office365.com (2603:10b6:408:f8::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Wed, 21 Jul 2021 14:39:35 +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 BN8NAM11FT060.mail.protection.outlook.com (10.13.177.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 14:39:35 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jul 2021 14:39:33 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Matan Azrad , Fiona Trahe , Ashish Gupta Date: Wed, 21 Jul 2021 22:37:41 +0800 Message-ID: <20210721143743.24626-15-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210721143743.24626-1-xuemingl@nvidia.com> References: <20210616040935.311733-1-xuemingl@nvidia.com> <20210721143743.24626-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] 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: acb0e445-7d06-45d3-8d99-08d94c555c7c X-MS-TrafficTypeDiagnostic: BN6PR12MB1828: 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: +GxJYBDLB6ZWfzPl2qPg2TTvNIID4uNxXQgiYg8w+68iffQL9ZSftaLaSj9eBLehQlAqcgxagpVqXrOu7LurypFBzH7KJkkrQMvut7nknqGMexV577d7scO1moqePlG2wWdzIJ5pYDEsOPtgLyllA8Df0a2rxEEU5W2fxUZAlV8MoXKRzuZaBFCRw5OSAZ+bmFDkeJdZ2dN14ThzRGMVpNuIN0UnBjvNFl0BDkLJ3zya16vU1k7/B+rETqQNKbIzmKrs4UG4Y60wVejSFybtcN9DZJpPDJpREjgrbKxJ15FvTPYXpxTv4FCvl/3N5LGaCI6/lq1vUWq1anwjaJY70j6F/DfZteYoLLb3Ld7z0KODpgjIU3TY30XhfhKu5NF+sAimqZ1lE/X6KZ8/d13sC9mwfBaNh61W1yCqFnOGrFhb7v/EqUCz/HMtTgeG50wae0+jnLR/EhvPzb+Gv3ndnZ9Uh5p2qIXLmK0m/aM/9zIULsC2RX0Doe593Aui8TZitrLhTca1Ly5QA8G2tVMVnCS2slwstUSzA/LWKW18sC6JXG+uAn7mk3GbYcQQkeExQ3viw68jpLvnF149VnawGNoiAlfypDZUsPWVV3fwSFRvlykpe/yNT7T2vR/LAbk7m47osSHASC4Ntsb1DoTqce0atNm8/HI4vgIOta6SoQOPfgImIufWnMn0Z6yC7yXjjV+jyA8dPZURimS/oCdWFQ== 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)(46966006)(36840700001)(8676002)(6636002)(316002)(54906003)(36906005)(37006003)(6666004)(8936002)(86362001)(82310400003)(426003)(4326008)(6286002)(6862004)(2616005)(2906002)(356005)(336012)(47076005)(36756003)(1076003)(83380400001)(7636003)(26005)(5660300002)(70206006)(70586007)(186003)(508600001)(16526019)(7696005)(36860700001)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 14:39:35.5584 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acb0e445-7d06-45d3-8d99-08d94c555c7c 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: BN8NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1828 Subject: [dpdk-dev] [PATCH v4 14/16] 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 Acked-by: Viacheslav Ovsiienko --- 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 f5f51c0ebe..9775c81789 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. */ @@ -780,23 +778,8 @@ mlx5_compress_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr, } } -/** - * 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; @@ -805,24 +788,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); @@ -838,7 +814,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); @@ -853,7 +829,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; @@ -884,25 +859,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); @@ -929,24 +893,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