common/mlx5: share basic probing with internal drivers
authorMichael Baum <michaelba@nvidia.com>
Tue, 19 Oct 2021 20:55:46 +0000 (23:55 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 21 Oct 2021 13:38:46 +0000 (15:38 +0200)
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 <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/common/mlx5/mlx5_common.c
drivers/common/mlx5/mlx5_common.h
drivers/common/mlx5/mlx5_common_private.h
drivers/compress/mlx5/mlx5_compress.c
drivers/crypto/mlx5/mlx5_crypto.c
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/windows/mlx5_os.c
drivers/regex/mlx5/mlx5_regex.c
drivers/vdpa/mlx5/mlx5_vdpa.c

index 6885bbb..91de7b3 100644 (file)
@@ -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);
index a772371..b7e2ad1 100644 (file)
@@ -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
index a038330..04c0af3 100644 (file)
@@ -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,
index 5c5aa87..75a07e5 100644 (file)
@@ -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;
index 6a2f8b6..d9762a9 100644 (file)
@@ -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);
index 26a8d75..d7623bd 100644 (file)
@@ -2168,8 +2168,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
@@ -2179,7 +2179,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)
 {
@@ -2208,6 +2208,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;
@@ -2340,6 +2341,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,
@@ -2438,6 +2440,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)
@@ -2582,11 +2585,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,
-                                                &eth_da);
+               list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i],
+                                                &dev_config, &eth_da);
                if (!list[i].eth_dev) {
                        if (rte_errno != EBUSY && rte_errno != EEXIST)
                                break;
@@ -2698,27 +2698,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, &eth_da);
+       ret = mlx5_os_parse_eth_devargs(cdev->dev, &eth_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, &eth_da,
+                       ret = mlx5_os_pci_probe_pf(cdev, &eth_da,
                                                   eth_da.ports[p]);
                        if (ret)
                                break;
@@ -2729,21 +2730,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, &eth_da, 0);
+               ret = mlx5_os_pci_probe_pf(cdev, &eth_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;
@@ -2767,7 +2769,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, &eth_da);
        if (eth_dev == NULL)
@@ -2788,14 +2790,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;
 
@@ -2803,14 +2805,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
index c712fc3..99f0847 100644 (file)
@@ -1309,7 +1309,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);
@@ -2556,19 +2557,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.
index 68acc01..fcf22f8 100644 (file)
@@ -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;
 };
 
@@ -1141,6 +1141,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. */
@@ -1483,7 +1484,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);
@@ -1773,7 +1774,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,
index 75a1f9a..fd3e33d 100644 (file)
@@ -342,7 +342,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.
@@ -1019,15 +1019,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.
@@ -1129,6 +1129,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 =
@@ -1173,10 +1174,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;
index 5aa988b..399c24a 100644 (file)
@@ -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 @@ dev_error:
 }
 
 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;
index 6d17d7a..d7ef303 100644 (file)
@@ -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 @@ error:
 }
 
 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;
                }