X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fvdpa%2Fmlx5%2Fmlx5_vdpa.c;h=a8f3e4b1de3734108e6dd8553c66714e72b80169;hb=4fb86eb5e8971c609d98112a8dae9e5703bf4b61;hp=9bb462e95c4f76c7c10db14c4c99bbc55ed99853;hpb=a7551b6c6010f8ec70126687121509b33eb15804;p=dpdk.git diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 9bb462e95c..a8f3e4b1de 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -11,12 +11,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -39,7 +39,8 @@ (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \ (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \ (1ULL << VHOST_USER_PROTOCOL_F_MQ) | \ - (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU)) + (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU) | \ + (1ULL << VHOST_USER_PROTOCOL_F_STATUS)) #define MLX5_VDPA_MAX_RETRIES 20 #define MLX5_VDPA_USEC 1000 @@ -132,6 +133,7 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state) struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid); struct mlx5_vdpa_priv *priv = mlx5_vdpa_find_priv_resource_by_vdev(vdev); + int ret; if (priv == NULL) { DRV_LOG(ERR, "Invalid vDPA device: %s.", vdev->device->name); @@ -141,7 +143,10 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state) DRV_LOG(ERR, "Too big vring id: %d.", vring); return -E2BIG; } - return mlx5_vdpa_virtq_enable(priv, vring, state); + pthread_mutex_lock(&priv->vq_config_lock); + ret = mlx5_vdpa_virtq_enable(priv, vring, state); + pthread_mutex_unlock(&priv->vq_config_lock); + return ret; } static int @@ -656,7 +661,7 @@ mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv) } /** - * DPDK callback to register a PCI device. + * DPDK callback to register a mlx5 PCI device. * * This function spawns vdpa device out of a given PCI device. * @@ -679,11 +684,6 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct mlx5_hca_attr attr; int ret; - if (mlx5_class_get(pci_dev->device.devargs) != MLX5_CLASS_VDPA) { - DRV_LOG(DEBUG, "Skip probing - should be probed by other mlx5" - " driver."); - return 1; - } ibv = mlx5_vdpa_get_ib_device_match(&pci_dev->addr); if (!ibv) { DRV_LOG(ERR, "No matching IB device for PCI slot " @@ -746,6 +746,7 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, } mlx5_vdpa_config_get(pci_dev->device.devargs, priv); SLIST_INIT(&priv->mr_list); + pthread_mutex_init(&priv->vq_config_lock, NULL); pthread_mutex_lock(&priv_list_lock); TAILQ_INSERT_TAIL(&priv_list, priv, next); pthread_mutex_unlock(&priv_list_lock); @@ -797,6 +798,7 @@ mlx5_vdpa_pci_remove(struct rte_pci_device *pci_dev) priv->var = NULL; } mlx5_glue->close_device(priv->ctx); + pthread_mutex_destroy(&priv->vq_config_lock); rte_free(priv); } return 0; @@ -828,14 +830,17 @@ static const struct rte_pci_id mlx5_vdpa_pci_id_map[] = { } }; -static struct rte_pci_driver mlx5_vdpa_driver = { - .driver = { - .name = "mlx5_vdpa", +static struct mlx5_pci_driver mlx5_vdpa_driver = { + .driver_class = MLX5_CLASS_VDPA, + .pci_driver = { + .driver = { + .name = "mlx5_vdpa", + }, + .id_table = mlx5_vdpa_pci_id_map, + .probe = mlx5_vdpa_pci_probe, + .remove = mlx5_vdpa_pci_remove, + .drv_flags = 0, }, - .id_table = mlx5_vdpa_pci_id_map, - .probe = mlx5_vdpa_pci_probe, - .remove = mlx5_vdpa_pci_remove, - .drv_flags = 0, }; RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) @@ -845,8 +850,9 @@ RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) */ RTE_INIT(rte_mlx5_vdpa_init) { + mlx5_common_init(); if (mlx5_glue) - rte_pci_register(&mlx5_vdpa_driver); + mlx5_pci_driver_register(&mlx5_vdpa_driver); } RTE_PMD_EXPORT_NAME(net_mlx5_vdpa, __COUNTER__);