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 1AD44A0C45; Wed, 16 Jun 2021 06:10:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 931AE4111E; Wed, 16 Jun 2021 06:10:07 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.70]) by mails.dpdk.org (Postfix) with ESMTP id AAE4F410E8 for ; Wed, 16 Jun 2021 06:10:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dNxkAKazC1Sr1PhGZ+j1+nbkEq0n6KTmfOqGd2gG+/yeYh+3UcQ24BYSuN4l8psTCkBD3EpbqzZaLt9sn5gcNsqo6at+Sqo7xHjWTKcwW3nFMfo/1gPEb7m4aoToBB2xcmrcW/Z2fC5AuBVe1y/KAOAhfKuEw2w/Qg3OCMaaiKzBVgjv7Z6inn63bpw/11+6utst4Cgk9mX6vMVU/grWh14Ami035AJB24S1SaDc/ndGqau2wZ/Ld0eh2nIURMHLCw06Qncy+cUsx3Q+sOfLnMBtb7JlKTHaullrvH2odliwXbiekbr05zCk9HwAxw5MaJuJgaxsOBRRKGoBet3MwA== 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=qedLy7jH/Vr67kmod5SptQ5bSXhpz1NRriW343D2dl4=; b=fdUeo5LhxHfdsn3E71wbFQNpU3WEPRXOZlo2cdldXGA7G4HxChsxEw5VVQqWCerRW1eYhHfnCn/VmPP4PbvNATsnIk/fU7RV7RefnHyzyovBXbEaxnwS9+KE3IqWDzdXxKaGdyawSGGouvHKw9cOK6a9SXCwfnjO686FhHyae5hIz4mA3F9TApEOI8eJNJn/dxDyy1JaAprZTM72fo873G5OKOt53GVr9/lcHy4Lqs5IIiP6L6+Wnl3BotI+v6kswauoBH0ltd+nzn/zMpg2X6a9paPpqd4c5zhsddTL54UKt33hoHDg+WIcY9ht99VRNvw9VN31heIMrqgy3O+m6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.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=qedLy7jH/Vr67kmod5SptQ5bSXhpz1NRriW343D2dl4=; b=OUKjwUN/+aMBc2w9vMn99dHaLTV6hNJQVyDLem/cuUQx2ykhsfR1S2LxjljjccTrmQYdAQdv4YJv9EB5BNYPTvICqZ95p3hbkERkPL0HhEXZdlWhFhyEqTzYZA2gUmYDgYmV0NquwU4wlx1mn6QvaNcoYnRhHkbqzD2ZweyP13xzWiKfA0pp6CPPafxdi26B40ytm3GkZa44kF0vNJmOtgEou93o8hJ0cxttFZaUuy0jcgWa40zZJaXLvCJxEaMfWvmGzgMbhqT3tgJDFCb8wFt/t5kvpD9fdUxSrdvj1fNhvq1hkFuC+h7wmz7kvnZ7l2EUGqfX2gXMSA11DkMxKA== Received: from DM6PR03CA0012.namprd03.prod.outlook.com (2603:10b6:5:40::25) by DM5PR12MB1914.namprd12.prod.outlook.com (2603:10b6:3:109::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.22; Wed, 16 Jun 2021 04:10:04 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:40:cafe::15) by DM6PR03CA0012.outlook.office365.com (2603:10b6:5:40::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 04:10:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.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 DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4242.16 via Frontend Transport; Wed, 16 Jun 2021 04:10:02 +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, 16 Jun 2021 04:10:00 +0000 From: Xueming Li To: Viacheslav Ovsiienko CC: , , Matan Azrad , Shahaf Shuler , Anatoly Burakov Date: Wed, 16 Jun 2021 07:09:27 +0300 Message-ID: <20210616040935.311733-7-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210527133759.17401-2-xuemingl@nvidia.com> References: <20210527133759.17401-2-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.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: 21b6f074-717b-4296-8ade-08d9307c9dbf X-MS-TrafficTypeDiagnostic: DM5PR12MB1914: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:30; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3iZaj0dA5MPOesb0IU8i4Wf7MNarHZb1tr+Vbcb+UxWLevGugP4+dMCwf7d32fdh/2GjSjt4UYaurwrq54BNpnLpkOhPvI7Uz54WAcH9rPOHyk1N/HSJxRfqE4LiP1NfD/ybnaoYMMlPNONtsCghEDqxhmhWDuDQGr2cXpS5UGTFODW2OdlakgYdeHU+HaffN+82pVT8kiYHwpFl4Zy69N1mzC5nv1Wy2MdrWt1ZULyEKSXS2P7WTw2bpcZc1kXyKS0HN+4ze4q6psabIFIFyIS7hU250YlgO7WdxMUVo5UZsTtqdc4boJZc5BaWuNZieWi3/L9lR3l0QxfnjGQDe3EiTPaovjyt+fs5SV+Oj4+aPveLCJ6Rb/AvrCRfte+78cQUylEp/E+iiMOzb+/U5vvt/q9JDSwK8kjsStjJTET07cpOvSifo4+WvF7XXTWgoKbwwiLObkEiOXjsfiSbV+Ju0bAZjstGV2HQMGX7MpsIZGsFhNuZHk66Pu8VcOlmeN4Kkjj03A2wEQv1IEwFWh2Eq3uEU6fVJoNTZauOEGqDbruWD78v410qI5FAAAP8iWfqw+ywO5hgXxnKFc7VZ29mqma3Het8DqejzfqGBTMWo/ECMmEIxEwZUsGSld/SMPgrA8wjIk6A5DETaAldnyejcjoWjxwxgGeVrCVEeTw= 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)(136003)(346002)(376002)(39860400002)(46966006)(36840700001)(86362001)(7636003)(70586007)(356005)(55016002)(70206006)(8936002)(36756003)(83380400001)(36860700001)(82740400003)(47076005)(82310400003)(8676002)(2616005)(336012)(426003)(4326008)(6862004)(6286002)(36906005)(30864003)(7696005)(5660300002)(1076003)(54906003)(6666004)(26005)(478600001)(6636002)(186003)(16526019)(37006003)(316002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 04:10:02.8860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21b6f074-717b-4296-8ade-08d9307c9dbf 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: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1914 Subject: [dpdk-dev] [PATCH v1 06/14] net/mlx5: migrate to bus-agnostic 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 SubFunction based on auxiliary bus, common driver supports new bus-agnostic driver. This patch migrates net driver to new common driver. Signed-off-by: Xueming Li --- drivers/net/mlx5/linux/mlx5_os.c | 46 ++++++++++++++++++++++---------- drivers/net/mlx5/linux/mlx5_os.h | 3 --- drivers/net/mlx5/mlx5.c | 40 +++++++++++++-------------- drivers/net/mlx5/mlx5.h | 3 +-- drivers/net/mlx5/mlx5_mr.c | 38 +++++++++++++------------- drivers/net/mlx5/mlx5_rxtx.h | 9 +++---- 6 files changed, 73 insertions(+), 66 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index b695929e0b..a941ecf641 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1969,14 +1969,6 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, struct mlx5_bond_info bond_info; int ret = -1; - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - mlx5_pmd_socket_init(); - ret = mlx5_init_once(); - if (ret) { - DRV_LOG(ERR, "unable to init PMD global data: %s", - strerror(rte_errno)); - return -rte_errno; - } errno = 0; ibv_list = mlx5_glue->get_device_list(&ret); if (!ibv_list) { @@ -2409,21 +2401,18 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev, } /** - * DPDK callback to register a PCI device. + * Callback to register a PCI device. * * This function spawns Ethernet devices out of a given PCI device. * - * @param[in] pci_drv - * PCI driver structure (mlx5_driver). * @param[in] pci_dev * PCI device information. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -int -mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *pci_dev) +static int +mlx5_os_pci_probe(struct rte_pci_device *pci_dev) { struct rte_eth_devargs eth_da = { .type = RTE_ETH_REPRESENTOR_NONE }; int ret = 0; @@ -2462,6 +2451,35 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, return ret; } +/** + * Common bus driver callback to probe a device. + * + * This function probe PCI bus device(s). + * + * @param[in] dev + * Pointer to the generic device. + * + * @return + * 0 on success, the function cannot fail. + */ +int +mlx5_os_net_probe(struct rte_device *dev) +{ + int ret; + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + mlx5_pmd_socket_init(); + ret = mlx5_init_once(); + if (ret) { + 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)); + return 0; +} + static int mlx5_config_doorbell_mapping_env(const struct mlx5_dev_config *config) { diff --git a/drivers/net/mlx5/linux/mlx5_os.h b/drivers/net/mlx5/linux/mlx5_os.h index 4ae7d0ef47..af7cbeb418 100644 --- a/drivers/net/mlx5/linux/mlx5_os.h +++ b/drivers/net/mlx5/linux/mlx5_os.h @@ -19,7 +19,4 @@ enum { #define MLX5_NAMESIZE IF_NAMESIZE -#define PCI_DRV_FLAGS (RTE_PCI_DRV_INTR_LSC | \ - RTE_PCI_DRV_INTR_RMV | \ - RTE_PCI_DRV_PROBE_AGAIN) #endif /* RTE_PMD_MLX5_OS_H_ */ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 6077c701e7..c9474a6e74 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -28,7 +27,6 @@ #include #include #include -#include #include #include "mlx5_defs.h" @@ -2326,23 +2324,23 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev) } /** - * DPDK callback to remove a PCI device. + * Callback to remove a device. * - * This function removes all Ethernet devices belong to a given PCI device. + * This function removes all Ethernet devices belong to a given device. * - * @param[in] pci_dev - * Pointer to the PCI device. + * @param[in] dev + * Pointer to the generic device. * * @return * 0 on success, the function cannot fail. */ static int -mlx5_pci_remove(struct rte_pci_device *pci_dev) +mlx5_net_remove(struct rte_device *dev) { uint16_t port_id; int ret = 0; - RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) { + RTE_ETH_FOREACH_DEV_OF(port_id, dev) { /* * mlx5_dev_close() is not registered to secondary process, * call the close function explicitly for secondary process. @@ -2433,19 +2431,17 @@ static const struct rte_pci_id mlx5_pci_id_map[] = { } }; -static struct mlx5_pci_driver mlx5_driver = { - .driver_class = MLX5_CLASS_ETH, - .pci_driver = { - .driver = { - .name = MLX5_PCI_DRIVER_NAME, - }, - .id_table = mlx5_pci_id_map, - .probe = mlx5_os_pci_probe, - .remove = mlx5_pci_remove, - .dma_map = mlx5_dma_map, - .dma_unmap = mlx5_dma_unmap, - .drv_flags = PCI_DRV_FLAGS, - }, +static struct mlx5_class_driver mlx5_net_driver = { + .drv_class = MLX5_CLASS_ETH, + .name = "mlx5_eth", + .id_table = mlx5_pci_id_map, + .probe = mlx5_os_net_probe, + .remove = mlx5_net_remove, + .dma_map = mlx5_net_dma_map, + .dma_unmap = mlx5_net_dma_unmap, + .probe_again = 1, + .intr_lsc = 1, + .intr_rmv = 1, }; /* Initialize driver log type. */ @@ -2463,7 +2459,7 @@ RTE_INIT(rte_mlx5_pmd_init) mlx5_set_cksum_table(); mlx5_set_swp_types_table(); if (mlx5_glue) - mlx5_pci_driver_register(&mlx5_driver); + mlx5_class_driver_register(&mlx5_net_driver); } RTE_PMD_EXPORT_NAME(net_mlx5, __COUNTER__); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 42de853167..5ea465fa0b 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1680,8 +1680,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_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, - struct rte_pci_device *pci_dev); +int mlx5_os_net_probe(struct rte_device *dev); 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/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index e6324c22c5..fab5470ba2 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -308,10 +307,10 @@ dev_to_eth_dev(struct rte_device *dev) } /** - * DPDK callback to DMA map external memory to a PCI device. + * Callback to DMA map external memory to a device. * - * @param pdev - * Pointer to the PCI device. + * @param rte_dev + * Pointer to the generic device. * @param addr * Starting virtual address of memory to be mapped. * @param iova @@ -323,18 +322,18 @@ dev_to_eth_dev(struct rte_device *dev) * 0 on success, negative value on error. */ int -mlx5_dma_map(struct rte_pci_device *pdev, void *addr, - uint64_t iova __rte_unused, size_t len) +mlx5_net_dma_map(struct rte_device *rte_dev, void *addr, + uint64_t iova __rte_unused, size_t len) { struct rte_eth_dev *dev; struct mlx5_mr *mr; struct mlx5_priv *priv; struct mlx5_dev_ctx_shared *sh; - dev = dev_to_eth_dev(&pdev->device); + dev = dev_to_eth_dev(rte_dev); if (!dev) { DRV_LOG(WARNING, "unable to find matching ethdev " - "to PCI device %p", (void *)pdev); + "to device %s", rte_dev->name); rte_errno = ENODEV; return -1; } @@ -357,10 +356,10 @@ mlx5_dma_map(struct rte_pci_device *pdev, void *addr, } /** - * DPDK callback to DMA unmap external memory to a PCI device. + * Callback to DMA unmap external memory to a device. * - * @param pdev - * Pointer to the PCI device. + * @param rte_dev + * Pointer to the generic device. * @param addr * Starting virtual address of memory to be unmapped. * @param iova @@ -372,8 +371,8 @@ mlx5_dma_map(struct rte_pci_device *pdev, void *addr, * 0 on success, negative value on error. */ int -mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, - uint64_t iova __rte_unused, size_t len __rte_unused) +mlx5_net_dma_unmap(struct rte_device *rte_dev, void *addr, + uint64_t iova __rte_unused, size_t len __rte_unused) { struct rte_eth_dev *dev; struct mlx5_priv *priv; @@ -381,10 +380,10 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, struct mlx5_mr *mr; struct mr_cache_entry entry; - dev = dev_to_eth_dev(&pdev->device); + dev = dev_to_eth_dev(rte_dev); if (!dev) { - DRV_LOG(WARNING, "unable to find matching ethdev " - "to PCI device %p", (void *)pdev); + DRV_LOG(WARNING, "unable to find matching ethdev to device %s", + rte_dev->name); rte_errno = ENODEV; return -1; } @@ -394,16 +393,15 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, mr = mlx5_mr_lookup_list(&sh->share_cache, &entry, (uintptr_t)addr); if (!mr) { rte_rwlock_read_unlock(&sh->share_cache.rwlock); - DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn't registered " - "to PCI device %p", (uintptr_t)addr, - (void *)pdev); + DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn't registered to device %s", + (uintptr_t)addr, rte_dev->name); rte_errno = EINVAL; return -1; } LIST_REMOVE(mr, mr); - mlx5_mr_free(mr, sh->share_cache.dereg_mr_cb); DRV_LOG(DEBUG, "port %u remove MR(%p) from list", dev->data->port_id, (void *)mr); + mlx5_mr_free(mr, sh->share_cache.dereg_mr_cb); mlx5_mr_rebuild_cache(&sh->share_cache); /* * No explicit wmb is needed after updating dev_gen due to diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index e168dd46f9..ad1144e218 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -48,10 +47,10 @@ int mlx5_queue_state_modify(struct rte_eth_dev *dev, /* mlx5_mr.c */ void mlx5_mr_flush_local_cache(struct mlx5_mr_ctrl *mr_ctrl); -int mlx5_dma_map(struct rte_pci_device *pdev, void *addr, uint64_t iova, - size_t len); -int mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, uint64_t iova, - size_t len); +int mlx5_net_dma_map(struct rte_device *rte_dev, void *addr, uint64_t iova, + size_t len); +int mlx5_net_dma_unmap(struct rte_device *rte_dev, void *addr, uint64_t iova, + size_t len); /** * Get Memory Pool (MP) from mbuf. If mbuf is indirect, the pool from which the -- 2.25.1