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 CD98BA0C4D; Thu, 7 Oct 2021 00:04:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 626674119D; Thu, 7 Oct 2021 00:04:22 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2064.outbound.protection.outlook.com [40.107.244.64]) by mails.dpdk.org (Postfix) with ESMTP id 0C8FD41198 for ; Thu, 7 Oct 2021 00:04:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X5asJXybbXzm9hzOU0Wi04YgOLus6VBoLCMIX0365fMp3YWBjEW66iGMJuZFN5EaG+7Hzd5WBNmt394mvRMvZD5QgV+/ShM/rYgRvSvHkvsZvfBrScma5Fu0LZHxJ8TpKhtO3xF9KQZLY7zYWsjEoRMC8K1p4WxG3zIYT8ne10vV9KY/BF+K1JZJhWYSj1N4HskR9AZIa3kTurg63UvW1YDKEbASntrJoj4OuPQorJggUJzUKMsAOjKlG8E93ml8sdjMC0bVG7onl/V2J4zKk1yYipfRvYuGmgDrcYDnUwBlVUNDy47iUOy3e3gO+gUqKTutEYAPcTgRateFP6CLKg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J8WsUGCa3ePrswkVTzy5/Yao0sF2200HlwHlcaH0InA=; b=Y7JcKeRk+W2/C96vktlO/4d46U3f65pWewYTJWcgEkxTJfUrKFiMpwq+V/hgvMnviszrHwviLnvyHU8Ft9l2ZvF08DfDqlhKRX7244n0gvCJHqskBkdcu0P1HGTigT+XC14Y0k81mQnv39GHIpYjjWZ0K4g8QiWNiuyNlfyJ7sp3+GnG1dK9BkYOomMX2RpV3yJFFgkR1SzeOEBqA4fuFWa2oUGO2p+uU59fGw+/ppBXFnCAKDgaZwvKVMq502b9DwElfKvrv/LO7mKXidMeM2emVh5D4SH+NFDAR3FYw5cvCex+f1Bne6LqElxAC+XBNpDH1ttkZ/vhDtsnc5wN2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=J8WsUGCa3ePrswkVTzy5/Yao0sF2200HlwHlcaH0InA=; b=cncB9z8IGY8hVxTrU4rqrzZ/Ep870QjSZAVg03lLkZArbe5VBPxMp3Fa8buueKj5JhS2sIHh85MspqBso07yMZwrtUJIIBxSa8NtMkpTnbsyKPTJ6Vnsl6L/0NYSLkUzNo6AgwI6B1iC3N65dBdy7pe4nrtoxofmOzppIxqR68R1pkbNQ9EMAUwk3jKOa065o3EYYz77zXXX0oC2olFVj9y6Q4r3J80rHLvlOukvMWLdZikdNIROxwMdYBFV9y4KoXS/RAfV86rb0LsUQ0GFarQYmXL9202ZDl8JZMKAxviEFiducCEM39uU6mvRasyRhtbjQbqrfnobzQ0VlcO9cw== Received: from MW4PR03CA0036.namprd03.prod.outlook.com (2603:10b6:303:8e::11) by BN8PR12MB3011.namprd12.prod.outlook.com (2603:10b6:408:4a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Wed, 6 Oct 2021 22:04:17 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::36) by MW4PR03CA0036.outlook.office365.com (2603:10b6:303:8e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Wed, 6 Oct 2021 22:04:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 22:04:16 +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.18; Wed, 6 Oct 2021 22:04:15 +0000 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum Date: Thu, 7 Oct 2021 01:03:34 +0300 Message-ID: <20211006220350.2357487-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211006220350.2357487-1-michaelba@nvidia.com> References: <20210930172822.1949969-1-michaelba@nvidia.com> <20211006220350.2357487-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] 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: ba6d5c0a-a9d9-4edd-9b9b-08d989153d98 X-MS-TrafficTypeDiagnostic: BN8PR12MB3011: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:229; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Y69N/ml7eBPbTdi7YO5jhbGgL4VT1slX1F00gtoPIQswhLPiUK6AaunRUBFXURb/CqI33IuMfp1hO3IBw7o2Q/en1Vd56ljV0vZtI3d6Y2+lY0FpQCN1L1EwOpfsTBRMJdVLCQ2rNymDAPLNXkrZqEBXWsHstEL/ylWYWCEkUzx78/8+PqA+4xmlY38kVyz7YsnNzWsmno2rknbQNi2wBKTVkHHoPwMKbEq2nwhr0PPDuRRYpwhScpNttvXXcGJReR2EfWRHYXRNVYUFLWsFLVj1FIxGayDXc0k5zFK/ddfl/YThmZ7z76vmS3nQ52r1XmBB7wDsxDp+jL+rfx/miKyWyEpu1t8iEOrUpFKZYX2Otfgy7sQX8WemEiBuXsqkTuOR6yHxeWndeAdATto5HuLfDzMNwQ3uj1rc7XQvnsDGc5+0zsgxH9Bm7kYQ/YQN2MSkm7ahrayacoTsbWHSbKtv9UgC6Z0xgC3+Gavi3bGjrWQ1Os0g9dxBVTRM47f/ry80ggVUOBgZuxjbRM0cAUuj9fp90Bj+30mIsKJuNkjoE5kGZXbDzT5OwOeS6TSDOXw1UUzmAx5B/JMrhMw8I4pospeXKnIeJQQeeJYMHxitCVM5yG2WPMQUQb/adr5c4qZh14FcNVFYfMlMAAMOBtotGok0w6pXDhURYGtJilaSar2kD+0WyxoKd8BmmKXlHIJW0AoZ/miX3ILpvHvgA== 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)(36840700001)(46966006)(7636003)(107886003)(5660300002)(336012)(36860700001)(1076003)(426003)(55016002)(6666004)(356005)(86362001)(36756003)(6286002)(508600001)(30864003)(2616005)(6916009)(83380400001)(2906002)(16526019)(70586007)(7696005)(4326008)(47076005)(82310400003)(70206006)(54906003)(8936002)(2876002)(8676002)(26005)(186003)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 22:04:16.9006 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba6d5c0a-a9d9-4edd-9b9b-08d989153d98 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: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3011 Subject: [dpdk-dev] [PATCH v2 02/18] common/mlx5: share basic probing with the internal drivers 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" From: Michael Baum Create common probing structure that includes, for now, basic probing information detected by the common driver and share it with all the internal drivers. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.c | 4 +- drivers/common/mlx5/mlx5_common.h | 10 ++++- drivers/common/mlx5/mlx5_common_private.h | 6 --- drivers/compress/mlx5/mlx5_compress.c | 38 ++++++++--------- drivers/crypto/mlx5/mlx5_crypto.c | 16 +++---- drivers/net/mlx5/linux/mlx5_os.c | 52 ++++++++++++----------- drivers/net/mlx5/mlx5.c | 9 ++-- drivers/net/mlx5/mlx5.h | 7 +-- drivers/net/mlx5/windows/mlx5_os.c | 14 +++--- drivers/regex/mlx5/mlx5_regex.c | 12 +++--- drivers/vdpa/mlx5/mlx5_vdpa.c | 18 ++++---- 11 files changed, 94 insertions(+), 92 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 6885bbb1d2..91de7b3e2c 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -241,7 +241,7 @@ drivers_remove(struct mlx5_common_device *dev, uint32_t enabled_classes) while (enabled_classes) { driver = driver_get(RTE_BIT64(i)); if (driver != NULL) { - local_ret = driver->remove(dev->dev); + local_ret = driver->remove(dev); if (local_ret == 0) dev->classes_loaded &= ~RTE_BIT64(i); else if (ret == 0) @@ -275,7 +275,7 @@ drivers_probe(struct mlx5_common_device *dev, uint32_t user_classes) ret = -EEXIST; goto probe_err; } - ret = driver->probe(dev->dev); + ret = driver->probe(dev); if (ret < 0) { DRV_LOG(ERR, "Failed to load driver %s", driver->name); diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index a772371200..b7e2ad1a82 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -324,15 +324,21 @@ void mlx5_common_init(void); * from devargs, locating target RDMA device and probing with it. */ +struct mlx5_common_device { + struct rte_device *dev; + TAILQ_ENTRY(mlx5_common_device) next; + uint32_t classes_loaded; +}; + /** * Initialization function for the driver called during device probing. */ -typedef int (mlx5_class_driver_probe_t)(struct rte_device *dev); +typedef int (mlx5_class_driver_probe_t)(struct mlx5_common_device *dev); /** * Uninitialization function for the driver called during hot-unplugging. */ -typedef int (mlx5_class_driver_remove_t)(struct rte_device *dev); +typedef int (mlx5_class_driver_remove_t)(struct mlx5_common_device *dev); /** * Driver-specific DMA mapping. After a successful call the device diff --git a/drivers/common/mlx5/mlx5_common_private.h b/drivers/common/mlx5/mlx5_common_private.h index a038330375..04c0af3763 100644 --- a/drivers/common/mlx5/mlx5_common_private.h +++ b/drivers/common/mlx5/mlx5_common_private.h @@ -16,12 +16,6 @@ extern "C" { /* Common bus driver: */ -struct mlx5_common_device { - struct rte_device *dev; - TAILQ_ENTRY(mlx5_common_device) next; - uint32_t classes_loaded; -}; - int mlx5_common_dev_probe(struct rte_device *eal_dev); int mlx5_common_dev_remove(struct rte_device *eal_dev); int mlx5_common_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index 5c5aa87a18..75a07e5380 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -36,7 +36,7 @@ struct mlx5_compress_xform { struct mlx5_compress_priv { TAILQ_ENTRY(mlx5_compress_priv) next; struct ibv_context *ctx; /* Device context. */ - struct rte_compressdev *cdev; + struct rte_compressdev *compressdev; void *uar; uint32_t pdn; /* Protection Domain number. */ uint8_t min_block_size; @@ -790,16 +790,16 @@ mlx5_compress_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr, } static int -mlx5_compress_dev_probe(struct rte_device *dev) +mlx5_compress_dev_probe(struct mlx5_common_device *cdev) { struct ibv_device *ibv; - struct rte_compressdev *cdev; + struct rte_compressdev *compressdev; struct ibv_context *ctx; struct mlx5_compress_priv *priv; struct mlx5_hca_attr att = { 0 }; struct rte_compressdev_pmd_init_params init_params = { .name = "", - .socket_id = dev->numa_node, + .socket_id = cdev->dev->numa_node, }; if (rte_eal_process_type() != RTE_PROC_PRIMARY) { @@ -807,7 +807,7 @@ mlx5_compress_dev_probe(struct rte_device *dev) rte_errno = ENOTSUP; return -rte_errno; } - ibv = mlx5_os_get_ibv_dev(dev); + ibv = mlx5_os_get_ibv_dev(cdev->dev); if (ibv == NULL) return -rte_errno; ctx = mlx5_glue->dv_open_device(ibv); @@ -826,20 +826,20 @@ mlx5_compress_dev_probe(struct rte_device *dev) rte_errno = ENOTSUP; return -ENOTSUP; } - cdev = rte_compressdev_pmd_create(ibv->name, dev, - sizeof(*priv), &init_params); - if (cdev == NULL) { + compressdev = rte_compressdev_pmd_create(ibv->name, cdev->dev, + sizeof(*priv), &init_params); + if (compressdev == NULL) { DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name); claim_zero(mlx5_glue->close_device(ctx)); return -ENODEV; } DRV_LOG(INFO, "Compress device %s was created successfully.", ibv->name); - cdev->dev_ops = &mlx5_compress_ops; - cdev->dequeue_burst = mlx5_compress_dequeue_burst; - cdev->enqueue_burst = mlx5_compress_enqueue_burst; - cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; - priv = cdev->data->dev_private; + compressdev->dev_ops = &mlx5_compress_ops; + compressdev->dequeue_burst = mlx5_compress_dequeue_burst; + compressdev->enqueue_burst = mlx5_compress_enqueue_burst; + compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; + priv = compressdev->data->dev_private; priv->mmo_decomp_sq = att.mmo_decompress_sq_en; priv->mmo_decomp_qp = att.mmo_decompress_qp_en; priv->mmo_comp_sq = att.mmo_compress_sq_en; @@ -847,11 +847,11 @@ mlx5_compress_dev_probe(struct rte_device *dev) priv->mmo_dma_sq = att.mmo_dma_sq_en; priv->mmo_dma_qp = att.mmo_dma_qp_en; priv->ctx = ctx; - priv->cdev = cdev; + priv->compressdev = compressdev; priv->min_block_size = att.compress_min_block_size; priv->qp_ts_format = att.qp_ts_format; if (mlx5_compress_hw_global_prepare(priv) != 0) { - rte_compressdev_pmd_destroy(priv->cdev); + rte_compressdev_pmd_destroy(priv->compressdev); claim_zero(mlx5_glue->close_device(priv->ctx)); return -1; } @@ -859,7 +859,7 @@ mlx5_compress_dev_probe(struct rte_device *dev) MLX5_MR_BTREE_CACHE_N * 2, rte_socket_id()) != 0) { DRV_LOG(ERR, "Failed to allocate shared cache MR memory."); mlx5_compress_hw_global_release(priv); - rte_compressdev_pmd_destroy(priv->cdev); + rte_compressdev_pmd_destroy(priv->compressdev); claim_zero(mlx5_glue->close_device(priv->ctx)); rte_errno = ENOMEM; return -rte_errno; @@ -878,13 +878,13 @@ mlx5_compress_dev_probe(struct rte_device *dev) } static int -mlx5_compress_dev_remove(struct rte_device *dev) +mlx5_compress_dev_remove(struct mlx5_common_device *cdev) { struct mlx5_compress_priv *priv = NULL; pthread_mutex_lock(&priv_list_lock); TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next) - if (priv->cdev->device == dev) + if (priv->compressdev->device == cdev->dev) break; if (priv) TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next); @@ -895,7 +895,7 @@ mlx5_compress_dev_remove(struct rte_device *dev) NULL); mlx5_mr_release_cache(&priv->mr_scache); mlx5_compress_hw_global_release(priv); - rte_compressdev_pmd_destroy(priv->cdev); + rte_compressdev_pmd_destroy(priv->compressdev); claim_zero(mlx5_glue->close_device(priv->ctx)); } return 0; diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 6a2f8b6ac6..d9762a964d 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -951,7 +951,7 @@ mlx5_crypto_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr, } static int -mlx5_crypto_dev_probe(struct rte_device *dev) +mlx5_crypto_dev_probe(struct mlx5_common_device *cdev) { struct ibv_device *ibv; struct rte_cryptodev *crypto_dev; @@ -963,7 +963,7 @@ mlx5_crypto_dev_probe(struct rte_device *dev) struct rte_cryptodev_pmd_init_params init_params = { .name = "", .private_data_size = sizeof(struct mlx5_crypto_priv), - .socket_id = dev->numa_node, + .socket_id = cdev->dev->numa_node, .max_nb_queue_pairs = RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS, }; @@ -975,7 +975,7 @@ mlx5_crypto_dev_probe(struct rte_device *dev) rte_errno = ENOTSUP; return -rte_errno; } - ibv = mlx5_os_get_ibv_dev(dev); + ibv = mlx5_os_get_ibv_dev(cdev->dev); if (ibv == NULL) return -rte_errno; ctx = mlx5_glue->dv_open_device(ibv); @@ -992,7 +992,7 @@ mlx5_crypto_dev_probe(struct rte_device *dev) rte_errno = ENOTSUP; return -ENOTSUP; } - ret = mlx5_crypto_parse_devargs(dev->devargs, &devarg_prms); + ret = mlx5_crypto_parse_devargs(cdev->dev->devargs, &devarg_prms); if (ret) { DRV_LOG(ERR, "Failed to parse devargs."); claim_zero(mlx5_glue->close_device(ctx)); @@ -1005,8 +1005,8 @@ mlx5_crypto_dev_probe(struct rte_device *dev) claim_zero(mlx5_glue->close_device(ctx)); return -rte_errno; } - crypto_dev = rte_cryptodev_pmd_create(ibv->name, dev, - &init_params); + crypto_dev = rte_cryptodev_pmd_create(ibv->name, cdev->dev, + &init_params); if (crypto_dev == NULL) { DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name); claim_zero(mlx5_glue->close_device(ctx)); @@ -1065,13 +1065,13 @@ mlx5_crypto_dev_probe(struct rte_device *dev) } static int -mlx5_crypto_dev_remove(struct rte_device *dev) +mlx5_crypto_dev_remove(struct mlx5_common_device *cdev) { struct mlx5_crypto_priv *priv = NULL; pthread_mutex_lock(&priv_list_lock); TAILQ_FOREACH(priv, &mlx5_crypto_priv_list, next) - if (priv->crypto_dev->device == dev) + if (priv->crypto_dev->device == cdev->dev) break; if (priv) TAILQ_REMOVE(&mlx5_crypto_priv_list, priv, next); diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index e036ed1435..0aad08aba4 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2148,8 +2148,8 @@ mlx5_os_config_default(struct mlx5_dev_config *config) * This function spawns Ethernet devices out of a given PCI device and * bonding owner PF index. * - * @param[in] pci_dev - * PCI device information. + * @param[in] cdev + * Pointer to common mlx5 device structure. * @param[in] req_eth_da * Requested ethdev device argument. * @param[in] owner_id @@ -2159,7 +2159,7 @@ mlx5_os_config_default(struct mlx5_dev_config *config) * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, +mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev, struct rte_eth_devargs *req_eth_da, uint16_t owner_id) { @@ -2188,6 +2188,7 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, * >= 0 - bonding device (value is slave PF index) */ int bd = -1; + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); struct mlx5_dev_spawn_data *list = NULL; struct mlx5_dev_config dev_config; unsigned int dev_config_vf; @@ -2320,6 +2321,7 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, list[ns].phys_dev = ibv_match[0]; list[ns].eth_dev = NULL; list[ns].pci_dev = pci_dev; + list[ns].cdev = cdev; list[ns].pf_bond = bd; list[ns].ifindex = mlx5_nl_ifindex (nl_rdma, @@ -2418,6 +2420,7 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, list[ns].phys_dev = ibv_match[i]; list[ns].eth_dev = NULL; list[ns].pci_dev = pci_dev; + list[ns].cdev = cdev; list[ns].pf_bond = -1; list[ns].ifindex = 0; if (nl_rdma >= 0) @@ -2562,11 +2565,8 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, /* Default configuration. */ mlx5_os_config_default(&dev_config); dev_config.vf = dev_config_vf; - list[i].numa_node = pci_dev->device.numa_node; - list[i].eth_dev = mlx5_dev_spawn(&pci_dev->device, - &list[i], - &dev_config, - ð_da); + list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i], + &dev_config, ð_da); if (!list[i].eth_dev) { if (rte_errno != EBUSY && rte_errno != EEXIST) break; @@ -2678,27 +2678,28 @@ mlx5_os_parse_eth_devargs(struct rte_device *dev, * * This function spawns Ethernet devices out of a given PCI device. * - * @param[in] pci_dev - * PCI device information. + * @param[in] cdev + * Pointer to common mlx5 device structure. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -mlx5_os_pci_probe(struct rte_pci_device *pci_dev) +mlx5_os_pci_probe(struct mlx5_common_device *cdev) { + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); struct rte_eth_devargs eth_da = { .nb_ports = 0 }; int ret = 0; uint16_t p; - ret = mlx5_os_parse_eth_devargs(&pci_dev->device, ð_da); + ret = mlx5_os_parse_eth_devargs(cdev->dev, ð_da); if (ret != 0) return ret; if (eth_da.nb_ports > 0) { /* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */ for (p = 0; p < eth_da.nb_ports; p++) { - ret = mlx5_os_pci_probe_pf(pci_dev, ð_da, + ret = mlx5_os_pci_probe_pf(cdev, ð_da, eth_da.ports[p]); if (ret) break; @@ -2709,21 +2710,22 @@ mlx5_os_pci_probe(struct rte_pci_device *pci_dev) pci_dev->addr.domain, pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function, eth_da.ports[p]); - mlx5_net_remove(&pci_dev->device); + mlx5_net_remove(cdev); } } else { - ret = mlx5_os_pci_probe_pf(pci_dev, ð_da, 0); + ret = mlx5_os_pci_probe_pf(cdev, ð_da, 0); } return ret; } /* Probe a single SF device on auxiliary bus, no representor support. */ static int -mlx5_os_auxiliary_probe(struct rte_device *dev) +mlx5_os_auxiliary_probe(struct mlx5_common_device *cdev) { struct rte_eth_devargs eth_da = { .nb_ports = 0 }; struct mlx5_dev_config config; struct mlx5_dev_spawn_data spawn = { .pf_bond = -1 }; + struct rte_device *dev = cdev->dev; struct rte_auxiliary_device *adev = RTE_DEV_TO_AUXILIARY(dev); struct rte_eth_dev *eth_dev; int ret = 0; @@ -2747,7 +2749,7 @@ mlx5_os_auxiliary_probe(struct rte_device *dev) return ret; } spawn.ifindex = ret; - spawn.numa_node = dev->numa_node; + spawn.cdev = cdev; /* Spawn device. */ eth_dev = mlx5_dev_spawn(dev, &spawn, &config, ð_da); if (eth_dev == NULL) @@ -2768,14 +2770,14 @@ mlx5_os_auxiliary_probe(struct rte_device *dev) * * This function probe PCI bus device(s) or a single SF on auxiliary bus. * - * @param[in] dev - * Pointer to the generic device. + * @param[in] cdev + * Pointer to the common mlx5 device. * * @return - * 0 on success, the function cannot fail. + * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_os_net_probe(struct rte_device *dev) +mlx5_os_net_probe(struct mlx5_common_device *cdev) { int ret; @@ -2783,14 +2785,14 @@ mlx5_os_net_probe(struct rte_device *dev) mlx5_pmd_socket_init(); ret = mlx5_init_once(); if (ret) { - DRV_LOG(ERR, "unable to init PMD global data: %s", + DRV_LOG(ERR, "Unable to init PMD global data: %s", strerror(rte_errno)); return -rte_errno; } - if (mlx5_dev_is_pci(dev)) - return mlx5_os_pci_probe(RTE_DEV_TO_PCI(dev)); + if (mlx5_dev_is_pci(cdev->dev)) + return mlx5_os_pci_probe(cdev); else - return mlx5_os_auxiliary_probe(dev); + return mlx5_os_auxiliary_probe(cdev); } static int diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 1e1b8b736b..e39e77aa9d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1279,7 +1279,8 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, rte_errno = ENOMEM; goto exit; } - sh->numa_node = spawn->numa_node; + sh->numa_node = spawn->cdev->dev->numa_node; + sh->cdev = spawn->cdev; if (spawn->bond_info) sh->bond = *spawn->bond_info; err = mlx5_os_open_device(spawn, config, sh); @@ -2537,19 +2538,19 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev) * * This function removes all Ethernet devices belong to a given device. * - * @param[in] dev + * @param[in] cdev * Pointer to the generic device. * * @return * 0 on success, the function cannot fail. */ int -mlx5_net_remove(struct rte_device *dev) +mlx5_net_remove(struct mlx5_common_device *cdev) { uint16_t port_id; int ret = 0; - RTE_ETH_FOREACH_DEV_OF(port_id, dev) { + RTE_ETH_FOREACH_DEV_OF(port_id, cdev->dev) { /* * mlx5_dev_close() is not registered to secondary process, * call the close function explicitly for secondary process. diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index fe533fcc81..f441352a63 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -134,11 +134,11 @@ struct mlx5_dev_spawn_data { uint32_t max_port; /**< Device maximal port index. */ uint32_t phys_port; /**< Device physical port index. */ int pf_bond; /**< bonding device PF index. < 0 - no bonding */ - int numa_node; /**< Device numa node. */ struct mlx5_switch_info info; /**< Switch information. */ void *phys_dev; /**< Associated physical device. */ struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */ struct rte_pci_device *pci_dev; /**< Backend PCI device. */ + struct mlx5_common_device *cdev; /**< Backend common device. */ struct mlx5_bond_info *bond_info; }; @@ -1148,6 +1148,7 @@ struct mlx5_dev_ctx_shared { uint32_t reclaim_mode:1; /* Reclaim memory. */ uint32_t max_port; /* Maximal IB device port index. */ struct mlx5_bond_info bond; /* Bonding information. */ + struct mlx5_common_device *cdev; /* Backend mlx5 device. */ void *ctx; /* Verbs/DV/DevX context. */ void *pd; /* Protection Domain. */ uint32_t pdn; /* Protection Domain number. */ @@ -1492,7 +1493,7 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev); int mlx5_dev_close(struct rte_eth_dev *dev); -int mlx5_net_remove(struct rte_device *dev); +int mlx5_net_remove(struct mlx5_common_device *cdev); bool mlx5_is_hpf(struct rte_eth_dev *dev); bool mlx5_is_sf_repr(struct rte_eth_dev *dev); void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh); @@ -1782,7 +1783,7 @@ int mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, const struct mlx5_dev_config *config, struct mlx5_dev_ctx_shared *sh); int mlx5_os_get_pdn(void *pd, uint32_t *pdn); -int mlx5_os_net_probe(struct rte_device *dev); +int mlx5_os_net_probe(struct mlx5_common_device *cdev); void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh); void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh); void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb, diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 459414d5c2..8ffbb9ff54 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -337,7 +337,7 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) } /** - * Spawn an Ethernet device from Verbs information. + * Spawn an Ethernet device from DevX information. * * @param dpdk_dev * Backing DPDK device. @@ -982,15 +982,15 @@ mlx5_match_devx_devices_to_addr(struct devx_device_bdf *devx_bdf, * This function spawns Ethernet devices out of a given device. * * @param[in] dev - * Pointer to the generic device. + * Pointer to the common device. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ int -mlx5_os_net_probe(struct rte_device *dev) +mlx5_os_net_probe(struct mlx5_common_device *cdev) { - struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev); + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev); struct devx_device_bdf *devx_bdf_devs, *orig_devx_bdf_devs; /* * Number of found IB Devices matching with requested PCI BDF. @@ -1092,6 +1092,7 @@ mlx5_os_net_probe(struct rte_device *dev) list[ns].phys_dev = devx_bdf_match[ns]; list[ns].eth_dev = NULL; list[ns].pci_dev = pci_dev; + list[ns].cdev = cdev; list[ns].pf_bond = bd; list[ns].ifindex = -1; /* Spawn will assign */ list[ns].info = @@ -1136,10 +1137,7 @@ mlx5_os_net_probe(struct rte_device *dev) dev_config.dv_flow_en = 1; dev_config.decap_en = 0; dev_config.log_hp_size = MLX5_ARG_UNSET; - list[ns].numa_node = pci_dev->device.numa_node; - list[ns].eth_dev = mlx5_dev_spawn(&pci_dev->device, - &list[ns], - &dev_config); + list[ns].eth_dev = mlx5_dev_spawn(cdev->dev, &list[ns], &dev_config); if (!list[ns].eth_dev) goto exit; restore = list[ns].eth_dev->data->dev_flags; diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index 5aa988be6d..399c24a20c 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -121,7 +121,7 @@ mlx5_regex_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr, } static int -mlx5_regex_dev_probe(struct rte_device *rte_dev) +mlx5_regex_dev_probe(struct mlx5_common_device *cdev) { struct ibv_device *ibv; struct mlx5_regex_priv *priv = NULL; @@ -131,7 +131,7 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev) int ret; uint32_t val; - ibv = mlx5_os_get_ibv_dev(rte_dev); + ibv = mlx5_os_get_ibv_dev(cdev->dev); if (ibv == NULL) return -rte_errno; DRV_LOG(INFO, "Probe device \"%s\".", ibv->name); @@ -180,7 +180,7 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev) priv->is_bf2 = 1; /* Default RXP programming mode to Shared. */ priv->prog_mode = MLX5_RXP_SHARED_PROG_MODE; - mlx5_regex_get_name(name, rte_dev); + mlx5_regex_get_name(name, cdev->dev); priv->regexdev = rte_regexdev_register(name); if (priv->regexdev == NULL) { DRV_LOG(ERR, "Failed to register RegEx device."); @@ -214,7 +214,7 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev) priv->regexdev->enqueue = mlx5_regexdev_enqueue_gga; #endif priv->regexdev->dequeue = mlx5_regexdev_dequeue; - priv->regexdev->device = rte_dev; + priv->regexdev->device = cdev->dev; priv->regexdev->data->dev_private = priv; priv->regexdev->state = RTE_REGEXDEV_READY; priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr; @@ -256,13 +256,13 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev) } static int -mlx5_regex_dev_remove(struct rte_device *rte_dev) +mlx5_regex_dev_remove(struct mlx5_common_device *cdev) { char name[RTE_REGEXDEV_NAME_MAX_LEN]; struct rte_regexdev *dev; struct mlx5_regex_priv *priv = NULL; - mlx5_regex_get_name(name, rte_dev); + mlx5_regex_get_name(name, cdev->dev); dev = rte_regexdev_get_device_by_name(name); if (!dev) return 0; diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 6d17d7a6f3..d7ef303cfe 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -630,7 +630,7 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) } static int -mlx5_vdpa_dev_probe(struct rte_device *dev) +mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev) { struct ibv_device *ibv; struct mlx5_vdpa_priv *priv = NULL; @@ -639,14 +639,14 @@ mlx5_vdpa_dev_probe(struct rte_device *dev) int retry; int ret; - if (mlx5_vdpa_roce_disable(dev) != 0) { + if (mlx5_vdpa_roce_disable(cdev->dev) != 0) { DRV_LOG(WARNING, "Failed to disable ROCE for \"%s\".", - dev->name); + cdev->dev->name); return -rte_errno; } /* Wait for the IB device to appear again after reload. */ for (retry = MLX5_VDPA_MAX_RETRIES; retry > 0; --retry) { - ibv = mlx5_os_get_ibv_dev(dev); + ibv = mlx5_os_get_ibv_dev(cdev->dev); if (ibv != NULL) break; usleep(MLX5_VDPA_USEC); @@ -654,7 +654,7 @@ mlx5_vdpa_dev_probe(struct rte_device *dev) if (ibv == NULL) { DRV_LOG(ERR, "Cannot get IB device after disabling RoCE for " "\"%s\", retries exceed %d.", - dev->name, MLX5_VDPA_MAX_RETRIES); + cdev->dev->name, MLX5_VDPA_MAX_RETRIES); rte_errno = EAGAIN; return -rte_errno; } @@ -698,13 +698,13 @@ mlx5_vdpa_dev_probe(struct rte_device *dev) DRV_LOG(ERR, "Failed to allocate VAR %u.", errno); goto error; } - priv->vdev = rte_vdpa_register_device(dev, &mlx5_vdpa_ops); + priv->vdev = rte_vdpa_register_device(cdev->dev, &mlx5_vdpa_ops); if (priv->vdev == NULL) { DRV_LOG(ERR, "Failed to register vDPA device."); rte_errno = rte_errno ? rte_errno : EINVAL; goto error; } - mlx5_vdpa_config_get(dev->devargs, priv); + mlx5_vdpa_config_get(cdev->dev->devargs, priv); SLIST_INIT(&priv->mr_list); pthread_mutex_init(&priv->vq_config_lock, NULL); pthread_mutex_lock(&priv_list_lock); @@ -724,14 +724,14 @@ mlx5_vdpa_dev_probe(struct rte_device *dev) } static int -mlx5_vdpa_dev_remove(struct rte_device *dev) +mlx5_vdpa_dev_remove(struct mlx5_common_device *cdev) { struct mlx5_vdpa_priv *priv = NULL; int found = 0; pthread_mutex_lock(&priv_list_lock); TAILQ_FOREACH(priv, &priv_list, next) { - if (priv->vdev->device == dev) { + if (priv->vdev->device == cdev->dev) { found = 1; break; } -- 2.25.1