common/mlx5: register class drivers through common layer
[dpdk.git] / drivers / vdpa / mlx5 / mlx5_vdpa.c
index 7f34193..ffe2f00 100644 (file)
 #include <rte_malloc.h>
 #include <rte_log.h>
 #include <rte_errno.h>
-#include <rte_bus_pci.h>
 #include <rte_pci.h>
 #include <rte_string_fns.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_common.h>
+#include <mlx5_common_pci.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
 #include <mlx5_nl.h>
@@ -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
@@ -48,7 +49,6 @@
 TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list =
                                              TAILQ_HEAD_INITIALIZER(priv_list);
 static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER;
-int mlx5_vdpa_logtype;
 
 static struct mlx5_vdpa_priv *
 mlx5_vdpa_find_priv_resource_by_vdev(struct rte_vdpa_device *vdev)
@@ -145,29 +145,6 @@ mlx5_vdpa_set_vring_state(int vid, int vring, int state)
        return mlx5_vdpa_virtq_enable(priv, vring, state);
 }
 
-static int
-mlx5_vdpa_direct_db_prepare(struct mlx5_vdpa_priv *priv)
-{
-       int ret;
-
-       if (priv->direct_notifier) {
-               ret = rte_vhost_host_notifier_ctrl(priv->vid, false);
-               if (ret != 0) {
-                       DRV_LOG(INFO, "Direct HW notifier FD cannot be "
-                               "destroyed for device %d: %d.", priv->vid, ret);
-                       return -1;
-               }
-               priv->direct_notifier = 0;
-       }
-       ret = rte_vhost_host_notifier_ctrl(priv->vid, true);
-       if (ret != 0)
-               DRV_LOG(INFO, "Direct HW notifier FD cannot be configured for"
-                       " device %d: %d.", priv->vid, ret);
-       else
-               priv->direct_notifier = 1;
-       return 0;
-}
-
 static int
 mlx5_vdpa_features_set(int vid)
 {
@@ -337,7 +314,6 @@ mlx5_vdpa_dev_config(int vid)
                DRV_LOG(WARNING, "MTU cannot be set on device %s.",
                                vdev->device->name);
        if (mlx5_vdpa_pd_create(priv) || mlx5_vdpa_mem_register(priv) ||
-           mlx5_vdpa_direct_db_prepare(priv) ||
            mlx5_vdpa_virtqs_prepare(priv) || mlx5_vdpa_steer_setup(priv) ||
            mlx5_vdpa_cqe_event_setup(priv)) {
                mlx5_vdpa_dev_close(vid);
@@ -681,7 +657,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.
  *
@@ -853,27 +829,29 @@ 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)
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_vdpa_init)
 {
-       /* Initialize common log type. */
-       mlx5_vdpa_logtype = rte_log_register("pmd.vdpa.mlx5");
-       if (mlx5_vdpa_logtype >= 0)
-               rte_log_set_level(mlx5_vdpa_logtype, RTE_LOG_NOTICE);
+       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__);