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)
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);
* 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
/* 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,
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;
}
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) {
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);
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;
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;
}
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;
}
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);
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;
}
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;
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,
};
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);
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));
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));
}
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);
* 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
* 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)
{
* >= 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;
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,
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)
/* 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;
*
* 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;
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;
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)
*
* 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;
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
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);
*
* 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.
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;
};
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. */
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);
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,
}
/**
- * Spawn an Ethernet device from Verbs information.
+ * Spawn an Ethernet device from DevX information.
*
* @param dpdk_dev
* Backing DPDK device.
* 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.
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 =
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;
}
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;
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);
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.");
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;
}
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;
}
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;
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);
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;
}
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);
}
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;
}