common/mlx5: share basic probing with internal drivers

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>
This commit is contained in:
Michael Baum 2021-10-19 23:55:46 +03:00 committed by Thomas Monjalon
parent 620be7f27b
commit 7af08c8f1a
11 changed files with 94 additions and 92 deletions

View File

@ -241,7 +241,7 @@ drivers_remove(struct mlx5_common_device *dev, uint32_t enabled_classes)
while (enabled_classes) { while (enabled_classes) {
driver = driver_get(RTE_BIT64(i)); driver = driver_get(RTE_BIT64(i));
if (driver != NULL) { if (driver != NULL) {
local_ret = driver->remove(dev->dev); local_ret = driver->remove(dev);
if (local_ret == 0) if (local_ret == 0)
dev->classes_loaded &= ~RTE_BIT64(i); dev->classes_loaded &= ~RTE_BIT64(i);
else if (ret == 0) else if (ret == 0)
@ -275,7 +275,7 @@ drivers_probe(struct mlx5_common_device *dev, uint32_t user_classes)
ret = -EEXIST; ret = -EEXIST;
goto probe_err; goto probe_err;
} }
ret = driver->probe(dev->dev); ret = driver->probe(dev);
if (ret < 0) { if (ret < 0) {
DRV_LOG(ERR, "Failed to load driver %s", DRV_LOG(ERR, "Failed to load driver %s",
driver->name); driver->name);

View File

@ -324,15 +324,21 @@ void mlx5_common_init(void);
* from devargs, locating target RDMA device and probing with it. * 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. * 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. * 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 * Driver-specific DMA mapping. After a successful call the device

View File

@ -16,12 +16,6 @@ extern "C" {
/* Common bus driver: */ /* 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_probe(struct rte_device *eal_dev);
int mlx5_common_dev_remove(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, int mlx5_common_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova,

View File

@ -36,7 +36,7 @@ struct mlx5_compress_xform {
struct mlx5_compress_priv { struct mlx5_compress_priv {
TAILQ_ENTRY(mlx5_compress_priv) next; TAILQ_ENTRY(mlx5_compress_priv) next;
struct ibv_context *ctx; /* Device context. */ struct ibv_context *ctx; /* Device context. */
struct rte_compressdev *cdev; struct rte_compressdev *compressdev;
void *uar; void *uar;
uint32_t pdn; /* Protection Domain number. */ uint32_t pdn; /* Protection Domain number. */
uint8_t min_block_size; 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 static int
mlx5_compress_dev_probe(struct rte_device *dev) mlx5_compress_dev_probe(struct mlx5_common_device *cdev)
{ {
struct ibv_device *ibv; struct ibv_device *ibv;
struct rte_compressdev *cdev; struct rte_compressdev *compressdev;
struct ibv_context *ctx; struct ibv_context *ctx;
struct mlx5_compress_priv *priv; struct mlx5_compress_priv *priv;
struct mlx5_hca_attr att = { 0 }; struct mlx5_hca_attr att = { 0 };
struct rte_compressdev_pmd_init_params init_params = { struct rte_compressdev_pmd_init_params init_params = {
.name = "", .name = "",
.socket_id = dev->numa_node, .socket_id = cdev->dev->numa_node,
}; };
if (rte_eal_process_type() != RTE_PROC_PRIMARY) { if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
@ -807,7 +807,7 @@ mlx5_compress_dev_probe(struct rte_device *dev)
rte_errno = ENOTSUP; rte_errno = ENOTSUP;
return -rte_errno; return -rte_errno;
} }
ibv = mlx5_os_get_ibv_dev(dev); ibv = mlx5_os_get_ibv_dev(cdev->dev);
if (ibv == NULL) if (ibv == NULL)
return -rte_errno; return -rte_errno;
ctx = mlx5_glue->dv_open_device(ibv); ctx = mlx5_glue->dv_open_device(ibv);
@ -826,20 +826,20 @@ mlx5_compress_dev_probe(struct rte_device *dev)
rte_errno = ENOTSUP; rte_errno = ENOTSUP;
return -ENOTSUP; return -ENOTSUP;
} }
cdev = rte_compressdev_pmd_create(ibv->name, dev, compressdev = rte_compressdev_pmd_create(ibv->name, cdev->dev,
sizeof(*priv), &init_params); sizeof(*priv), &init_params);
if (cdev == NULL) { if (compressdev == NULL) {
DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name); DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name);
claim_zero(mlx5_glue->close_device(ctx)); claim_zero(mlx5_glue->close_device(ctx));
return -ENODEV; return -ENODEV;
} }
DRV_LOG(INFO, DRV_LOG(INFO,
"Compress device %s was created successfully.", ibv->name); "Compress device %s was created successfully.", ibv->name);
cdev->dev_ops = &mlx5_compress_ops; compressdev->dev_ops = &mlx5_compress_ops;
cdev->dequeue_burst = mlx5_compress_dequeue_burst; compressdev->dequeue_burst = mlx5_compress_dequeue_burst;
cdev->enqueue_burst = mlx5_compress_enqueue_burst; compressdev->enqueue_burst = mlx5_compress_enqueue_burst;
cdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
priv = cdev->data->dev_private; priv = compressdev->data->dev_private;
priv->mmo_decomp_sq = att.mmo_decompress_sq_en; priv->mmo_decomp_sq = att.mmo_decompress_sq_en;
priv->mmo_decomp_qp = att.mmo_decompress_qp_en; priv->mmo_decomp_qp = att.mmo_decompress_qp_en;
priv->mmo_comp_sq = att.mmo_compress_sq_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_sq = att.mmo_dma_sq_en;
priv->mmo_dma_qp = att.mmo_dma_qp_en; priv->mmo_dma_qp = att.mmo_dma_qp_en;
priv->ctx = ctx; priv->ctx = ctx;
priv->cdev = cdev; priv->compressdev = compressdev;
priv->min_block_size = att.compress_min_block_size; priv->min_block_size = att.compress_min_block_size;
priv->qp_ts_format = att.qp_ts_format; priv->qp_ts_format = att.qp_ts_format;
if (mlx5_compress_hw_global_prepare(priv) != 0) { 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)); claim_zero(mlx5_glue->close_device(priv->ctx));
return -1; return -1;
} }
@ -859,7 +859,7 @@ mlx5_compress_dev_probe(struct rte_device *dev)
MLX5_MR_BTREE_CACHE_N * 2, rte_socket_id()) != 0) { MLX5_MR_BTREE_CACHE_N * 2, rte_socket_id()) != 0) {
DRV_LOG(ERR, "Failed to allocate shared cache MR memory."); DRV_LOG(ERR, "Failed to allocate shared cache MR memory.");
mlx5_compress_hw_global_release(priv); 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)); claim_zero(mlx5_glue->close_device(priv->ctx));
rte_errno = ENOMEM; rte_errno = ENOMEM;
return -rte_errno; return -rte_errno;
@ -878,13 +878,13 @@ mlx5_compress_dev_probe(struct rte_device *dev)
} }
static int 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; struct mlx5_compress_priv *priv = NULL;
pthread_mutex_lock(&priv_list_lock); pthread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next) TAILQ_FOREACH(priv, &mlx5_compress_priv_list, next)
if (priv->cdev->device == dev) if (priv->compressdev->device == cdev->dev)
break; break;
if (priv) if (priv)
TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next); TAILQ_REMOVE(&mlx5_compress_priv_list, priv, next);
@ -895,7 +895,7 @@ mlx5_compress_dev_remove(struct rte_device *dev)
NULL); NULL);
mlx5_mr_release_cache(&priv->mr_scache); mlx5_mr_release_cache(&priv->mr_scache);
mlx5_compress_hw_global_release(priv); 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)); claim_zero(mlx5_glue->close_device(priv->ctx));
} }
return 0; return 0;

View File

@ -951,7 +951,7 @@ mlx5_crypto_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr,
} }
static int static int
mlx5_crypto_dev_probe(struct rte_device *dev) mlx5_crypto_dev_probe(struct mlx5_common_device *cdev)
{ {
struct ibv_device *ibv; struct ibv_device *ibv;
struct rte_cryptodev *crypto_dev; 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 = { struct rte_cryptodev_pmd_init_params init_params = {
.name = "", .name = "",
.private_data_size = sizeof(struct mlx5_crypto_priv), .private_data_size = sizeof(struct mlx5_crypto_priv),
.socket_id = dev->numa_node, .socket_id = cdev->dev->numa_node,
.max_nb_queue_pairs = .max_nb_queue_pairs =
RTE_CRYPTODEV_PMD_DEFAULT_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; rte_errno = ENOTSUP;
return -rte_errno; return -rte_errno;
} }
ibv = mlx5_os_get_ibv_dev(dev); ibv = mlx5_os_get_ibv_dev(cdev->dev);
if (ibv == NULL) if (ibv == NULL)
return -rte_errno; return -rte_errno;
ctx = mlx5_glue->dv_open_device(ibv); ctx = mlx5_glue->dv_open_device(ibv);
@ -992,7 +992,7 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
rte_errno = ENOTSUP; rte_errno = ENOTSUP;
return -ENOTSUP; return -ENOTSUP;
} }
ret = mlx5_crypto_parse_devargs(dev->devargs, &devarg_prms); ret = mlx5_crypto_parse_devargs(cdev->dev->devargs, &devarg_prms);
if (ret) { if (ret) {
DRV_LOG(ERR, "Failed to parse devargs."); DRV_LOG(ERR, "Failed to parse devargs.");
claim_zero(mlx5_glue->close_device(ctx)); 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)); claim_zero(mlx5_glue->close_device(ctx));
return -rte_errno; return -rte_errno;
} }
crypto_dev = rte_cryptodev_pmd_create(ibv->name, dev, crypto_dev = rte_cryptodev_pmd_create(ibv->name, cdev->dev,
&init_params); &init_params);
if (crypto_dev == NULL) { if (crypto_dev == NULL) {
DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name); DRV_LOG(ERR, "Failed to create device \"%s\".", ibv->name);
claim_zero(mlx5_glue->close_device(ctx)); claim_zero(mlx5_glue->close_device(ctx));
@ -1065,13 +1065,13 @@ mlx5_crypto_dev_probe(struct rte_device *dev)
} }
static int 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; struct mlx5_crypto_priv *priv = NULL;
pthread_mutex_lock(&priv_list_lock); pthread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &mlx5_crypto_priv_list, next) TAILQ_FOREACH(priv, &mlx5_crypto_priv_list, next)
if (priv->crypto_dev->device == dev) if (priv->crypto_dev->device == cdev->dev)
break; break;
if (priv) if (priv)
TAILQ_REMOVE(&mlx5_crypto_priv_list, priv, next); TAILQ_REMOVE(&mlx5_crypto_priv_list, priv, next);

View 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 * This function spawns Ethernet devices out of a given PCI device and
* bonding owner PF index. * bonding owner PF index.
* *
* @param[in] pci_dev * @param[in] cdev
* PCI device information. * Pointer to common mlx5 device structure.
* @param[in] req_eth_da * @param[in] req_eth_da
* Requested ethdev device argument. * Requested ethdev device argument.
* @param[in] owner_id * @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. * 0 on success, a negative errno value otherwise and rte_errno is set.
*/ */
static int 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, struct rte_eth_devargs *req_eth_da,
uint16_t owner_id) 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) * >= 0 - bonding device (value is slave PF index)
*/ */
int bd = -1; 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_spawn_data *list = NULL;
struct mlx5_dev_config dev_config; struct mlx5_dev_config dev_config;
unsigned int dev_config_vf; 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].phys_dev = ibv_match[0];
list[ns].eth_dev = NULL; list[ns].eth_dev = NULL;
list[ns].pci_dev = pci_dev; list[ns].pci_dev = pci_dev;
list[ns].cdev = cdev;
list[ns].pf_bond = bd; list[ns].pf_bond = bd;
list[ns].ifindex = mlx5_nl_ifindex list[ns].ifindex = mlx5_nl_ifindex
(nl_rdma, (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].phys_dev = ibv_match[i];
list[ns].eth_dev = NULL; list[ns].eth_dev = NULL;
list[ns].pci_dev = pci_dev; list[ns].pci_dev = pci_dev;
list[ns].cdev = cdev;
list[ns].pf_bond = -1; list[ns].pf_bond = -1;
list[ns].ifindex = 0; list[ns].ifindex = 0;
if (nl_rdma >= 0) if (nl_rdma >= 0)
@ -2582,11 +2585,8 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev,
/* Default configuration. */ /* Default configuration. */
mlx5_os_config_default(&dev_config); mlx5_os_config_default(&dev_config);
dev_config.vf = dev_config_vf; dev_config.vf = dev_config_vf;
list[i].numa_node = pci_dev->device.numa_node; list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i],
list[i].eth_dev = mlx5_dev_spawn(&pci_dev->device, &dev_config, &eth_da);
&list[i],
&dev_config,
&eth_da);
if (!list[i].eth_dev) { if (!list[i].eth_dev) {
if (rte_errno != EBUSY && rte_errno != EEXIST) if (rte_errno != EBUSY && rte_errno != EEXIST)
break; 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. * This function spawns Ethernet devices out of a given PCI device.
* *
* @param[in] pci_dev * @param[in] cdev
* PCI device information. * Pointer to common mlx5 device structure.
* *
* @return * @return
* 0 on success, a negative errno value otherwise and rte_errno is set. * 0 on success, a negative errno value otherwise and rte_errno is set.
*/ */
static int 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 }; struct rte_eth_devargs eth_da = { .nb_ports = 0 };
int ret = 0; int ret = 0;
uint16_t p; 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) if (ret != 0)
return ret; return ret;
if (eth_da.nb_ports > 0) { if (eth_da.nb_ports > 0) {
/* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */ /* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */
for (p = 0; p < eth_da.nb_ports; p++) { 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]); eth_da.ports[p]);
if (ret) if (ret)
break; 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.domain, pci_dev->addr.bus,
pci_dev->addr.devid, pci_dev->addr.function, pci_dev->addr.devid, pci_dev->addr.function,
eth_da.ports[p]); eth_da.ports[p]);
mlx5_net_remove(&pci_dev->device); mlx5_net_remove(cdev);
} }
} else { } else {
ret = mlx5_os_pci_probe_pf(pci_dev, &eth_da, 0); ret = mlx5_os_pci_probe_pf(cdev, &eth_da, 0);
} }
return ret; return ret;
} }
/* Probe a single SF device on auxiliary bus, no representor support. */ /* Probe a single SF device on auxiliary bus, no representor support. */
static int 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 rte_eth_devargs eth_da = { .nb_ports = 0 };
struct mlx5_dev_config config; struct mlx5_dev_config config;
struct mlx5_dev_spawn_data spawn = { .pf_bond = -1 }; 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_auxiliary_device *adev = RTE_DEV_TO_AUXILIARY(dev);
struct rte_eth_dev *eth_dev; struct rte_eth_dev *eth_dev;
int ret = 0; int ret = 0;
@ -2767,7 +2769,7 @@ mlx5_os_auxiliary_probe(struct rte_device *dev)
return ret; return ret;
} }
spawn.ifindex = ret; spawn.ifindex = ret;
spawn.numa_node = dev->numa_node; spawn.cdev = cdev;
/* Spawn device. */ /* Spawn device. */
eth_dev = mlx5_dev_spawn(dev, &spawn, &config, &eth_da); eth_dev = mlx5_dev_spawn(dev, &spawn, &config, &eth_da);
if (eth_dev == NULL) 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. * This function probe PCI bus device(s) or a single SF on auxiliary bus.
* *
* @param[in] dev * @param[in] cdev
* Pointer to the generic device. * Pointer to the common mlx5 device.
* *
* @return * @return
* 0 on success, the function cannot fail. * 0 on success, a negative errno value otherwise and rte_errno is set.
*/ */
int int
mlx5_os_net_probe(struct rte_device *dev) mlx5_os_net_probe(struct mlx5_common_device *cdev)
{ {
int ret; int ret;
@ -2803,14 +2805,14 @@ mlx5_os_net_probe(struct rte_device *dev)
mlx5_pmd_socket_init(); mlx5_pmd_socket_init();
ret = mlx5_init_once(); ret = mlx5_init_once();
if (ret) { 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)); strerror(rte_errno));
return -rte_errno; return -rte_errno;
} }
if (mlx5_dev_is_pci(dev)) if (mlx5_dev_is_pci(cdev->dev))
return mlx5_os_pci_probe(RTE_DEV_TO_PCI(dev)); return mlx5_os_pci_probe(cdev);
else else
return mlx5_os_auxiliary_probe(dev); return mlx5_os_auxiliary_probe(cdev);
} }
static int static int

View File

@ -1309,7 +1309,8 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
rte_errno = ENOMEM; rte_errno = ENOMEM;
goto exit; goto exit;
} }
sh->numa_node = spawn->numa_node; sh->numa_node = spawn->cdev->dev->numa_node;
sh->cdev = spawn->cdev;
if (spawn->bond_info) if (spawn->bond_info)
sh->bond = *spawn->bond_info; sh->bond = *spawn->bond_info;
err = mlx5_os_open_device(spawn, config, sh); 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. * This function removes all Ethernet devices belong to a given device.
* *
* @param[in] dev * @param[in] cdev
* Pointer to the generic device. * Pointer to the generic device.
* *
* @return * @return
* 0 on success, the function cannot fail. * 0 on success, the function cannot fail.
*/ */
int int
mlx5_net_remove(struct rte_device *dev) mlx5_net_remove(struct mlx5_common_device *cdev)
{ {
uint16_t port_id; uint16_t port_id;
int ret = 0; 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, * mlx5_dev_close() is not registered to secondary process,
* call the close function explicitly for secondary process. * call the close function explicitly for secondary process.

View File

@ -134,11 +134,11 @@ struct mlx5_dev_spawn_data {
uint32_t max_port; /**< Device maximal port index. */ uint32_t max_port; /**< Device maximal port index. */
uint32_t phys_port; /**< Device physical port index. */ uint32_t phys_port; /**< Device physical port index. */
int pf_bond; /**< bonding device PF index. < 0 - no bonding */ int pf_bond; /**< bonding device PF index. < 0 - no bonding */
int numa_node; /**< Device numa node. */
struct mlx5_switch_info info; /**< Switch information. */ struct mlx5_switch_info info; /**< Switch information. */
void *phys_dev; /**< Associated physical device. */ void *phys_dev; /**< Associated physical device. */
struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */ struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */
struct rte_pci_device *pci_dev; /**< Backend PCI device. */ struct rte_pci_device *pci_dev; /**< Backend PCI device. */
struct mlx5_common_device *cdev; /**< Backend common device. */
struct mlx5_bond_info *bond_info; struct mlx5_bond_info *bond_info;
}; };
@ -1141,6 +1141,7 @@ struct mlx5_dev_ctx_shared {
uint32_t reclaim_mode:1; /* Reclaim memory. */ uint32_t reclaim_mode:1; /* Reclaim memory. */
uint32_t max_port; /* Maximal IB device port index. */ uint32_t max_port; /* Maximal IB device port index. */
struct mlx5_bond_info bond; /* Bonding information. */ struct mlx5_bond_info bond; /* Bonding information. */
struct mlx5_common_device *cdev; /* Backend mlx5 device. */
void *ctx; /* Verbs/DV/DevX context. */ void *ctx; /* Verbs/DV/DevX context. */
void *pd; /* Protection Domain. */ void *pd; /* Protection Domain. */
uint32_t pdn; /* Protection Domain number. */ 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); struct rte_eth_udp_tunnel *udp_tunnel);
uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev); 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_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_hpf(struct rte_eth_dev *dev);
bool mlx5_is_sf_repr(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); 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, const struct mlx5_dev_config *config,
struct mlx5_dev_ctx_shared *sh); struct mlx5_dev_ctx_shared *sh);
int mlx5_os_get_pdn(void *pd, uint32_t *pdn); 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_install(struct mlx5_dev_ctx_shared *sh);
void mlx5_os_dev_shared_handler_uninstall(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, void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,

View 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 * @param dpdk_dev
* Backing DPDK device. * 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. * This function spawns Ethernet devices out of a given device.
* *
* @param[in] dev * @param[in] dev
* Pointer to the generic device. * Pointer to the common device.
* *
* @return * @return
* 0 on success, a negative errno value otherwise and rte_errno is set. * 0 on success, a negative errno value otherwise and rte_errno is set.
*/ */
int 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; struct devx_device_bdf *devx_bdf_devs, *orig_devx_bdf_devs;
/* /*
* Number of found IB Devices matching with requested PCI BDF. * 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].phys_dev = devx_bdf_match[ns];
list[ns].eth_dev = NULL; list[ns].eth_dev = NULL;
list[ns].pci_dev = pci_dev; list[ns].pci_dev = pci_dev;
list[ns].cdev = cdev;
list[ns].pf_bond = bd; list[ns].pf_bond = bd;
list[ns].ifindex = -1; /* Spawn will assign */ list[ns].ifindex = -1; /* Spawn will assign */
list[ns].info = list[ns].info =
@ -1173,10 +1174,7 @@ mlx5_os_net_probe(struct rte_device *dev)
dev_config.dv_flow_en = 1; dev_config.dv_flow_en = 1;
dev_config.decap_en = 0; dev_config.decap_en = 0;
dev_config.log_hp_size = MLX5_ARG_UNSET; dev_config.log_hp_size = MLX5_ARG_UNSET;
list[ns].numa_node = pci_dev->device.numa_node; list[ns].eth_dev = mlx5_dev_spawn(cdev->dev, &list[ns], &dev_config);
list[ns].eth_dev = mlx5_dev_spawn(&pci_dev->device,
&list[ns],
&dev_config);
if (!list[ns].eth_dev) if (!list[ns].eth_dev)
goto exit; goto exit;
restore = list[ns].eth_dev->data->dev_flags; restore = list[ns].eth_dev->data->dev_flags;

View File

@ -121,7 +121,7 @@ mlx5_regex_mr_mem_event_cb(enum rte_mem_event event_type, const void *addr,
} }
static int 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 ibv_device *ibv;
struct mlx5_regex_priv *priv = NULL; struct mlx5_regex_priv *priv = NULL;
@ -131,7 +131,7 @@ mlx5_regex_dev_probe(struct rte_device *rte_dev)
int ret; int ret;
uint32_t val; uint32_t val;
ibv = mlx5_os_get_ibv_dev(rte_dev); ibv = mlx5_os_get_ibv_dev(cdev->dev);
if (ibv == NULL) if (ibv == NULL)
return -rte_errno; return -rte_errno;
DRV_LOG(INFO, "Probe device \"%s\".", ibv->name); 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; priv->is_bf2 = 1;
/* Default RXP programming mode to Shared. */ /* Default RXP programming mode to Shared. */
priv->prog_mode = MLX5_RXP_SHARED_PROG_MODE; 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); priv->regexdev = rte_regexdev_register(name);
if (priv->regexdev == NULL) { if (priv->regexdev == NULL) {
DRV_LOG(ERR, "Failed to register RegEx device."); 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; priv->regexdev->enqueue = mlx5_regexdev_enqueue_gga;
#endif #endif
priv->regexdev->dequeue = mlx5_regexdev_dequeue; priv->regexdev->dequeue = mlx5_regexdev_dequeue;
priv->regexdev->device = rte_dev; priv->regexdev->device = cdev->dev;
priv->regexdev->data->dev_private = priv; priv->regexdev->data->dev_private = priv;
priv->regexdev->state = RTE_REGEXDEV_READY; priv->regexdev->state = RTE_REGEXDEV_READY;
priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr; 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 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]; char name[RTE_REGEXDEV_NAME_MAX_LEN];
struct rte_regexdev *dev; struct rte_regexdev *dev;
struct mlx5_regex_priv *priv = NULL; 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); dev = rte_regexdev_get_device_by_name(name);
if (!dev) if (!dev)
return 0; return 0;

View File

@ -630,7 +630,7 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv)
} }
static int static int
mlx5_vdpa_dev_probe(struct rte_device *dev) mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev)
{ {
struct ibv_device *ibv; struct ibv_device *ibv;
struct mlx5_vdpa_priv *priv = NULL; struct mlx5_vdpa_priv *priv = NULL;
@ -639,14 +639,14 @@ mlx5_vdpa_dev_probe(struct rte_device *dev)
int retry; int retry;
int ret; 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\".", DRV_LOG(WARNING, "Failed to disable ROCE for \"%s\".",
dev->name); cdev->dev->name);
return -rte_errno; return -rte_errno;
} }
/* Wait for the IB device to appear again after reload. */ /* Wait for the IB device to appear again after reload. */
for (retry = MLX5_VDPA_MAX_RETRIES; retry > 0; --retry) { 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) if (ibv != NULL)
break; break;
usleep(MLX5_VDPA_USEC); usleep(MLX5_VDPA_USEC);
@ -654,7 +654,7 @@ mlx5_vdpa_dev_probe(struct rte_device *dev)
if (ibv == NULL) { if (ibv == NULL) {
DRV_LOG(ERR, "Cannot get IB device after disabling RoCE for " DRV_LOG(ERR, "Cannot get IB device after disabling RoCE for "
"\"%s\", retries exceed %d.", "\"%s\", retries exceed %d.",
dev->name, MLX5_VDPA_MAX_RETRIES); cdev->dev->name, MLX5_VDPA_MAX_RETRIES);
rte_errno = EAGAIN; rte_errno = EAGAIN;
return -rte_errno; return -rte_errno;
} }
@ -698,13 +698,13 @@ mlx5_vdpa_dev_probe(struct rte_device *dev)
DRV_LOG(ERR, "Failed to allocate VAR %u.", errno); DRV_LOG(ERR, "Failed to allocate VAR %u.", errno);
goto error; 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) { if (priv->vdev == NULL) {
DRV_LOG(ERR, "Failed to register vDPA device."); DRV_LOG(ERR, "Failed to register vDPA device.");
rte_errno = rte_errno ? rte_errno : EINVAL; rte_errno = rte_errno ? rte_errno : EINVAL;
goto error; goto error;
} }
mlx5_vdpa_config_get(dev->devargs, priv); mlx5_vdpa_config_get(cdev->dev->devargs, priv);
SLIST_INIT(&priv->mr_list); SLIST_INIT(&priv->mr_list);
pthread_mutex_init(&priv->vq_config_lock, NULL); pthread_mutex_init(&priv->vq_config_lock, NULL);
pthread_mutex_lock(&priv_list_lock); pthread_mutex_lock(&priv_list_lock);
@ -724,14 +724,14 @@ mlx5_vdpa_dev_probe(struct rte_device *dev)
} }
static int 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; struct mlx5_vdpa_priv *priv = NULL;
int found = 0; int found = 0;
pthread_mutex_lock(&priv_list_lock); pthread_mutex_lock(&priv_list_lock);
TAILQ_FOREACH(priv, &priv_list, next) { TAILQ_FOREACH(priv, &priv_list, next) {
if (priv->vdev->device == dev) { if (priv->vdev->device == cdev->dev) {
found = 1; found = 1;
break; break;
} }