common/mlx5: register class drivers through common layer
authorParav Pandit <parav@mellanox.com>
Mon, 27 Jul 2020 17:47:14 +0000 (20:47 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 28 Jul 2020 17:01:30 +0000 (19:01 +0200)
Migrate mlx5 net, vdpa and regex PMD to start using mlx5 common class
driver.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
drivers/net/mlx5/Makefile
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/regex/mlx5/meson.build
drivers/regex/mlx5/mlx5_regex.c
drivers/vdpa/mlx5/Makefile
drivers/vdpa/mlx5/meson.build
drivers/vdpa/mlx5/mlx5_vdpa.c

index 253faf9..568c772 100644 (file)
@@ -55,7 +55,6 @@ LDLIBS += -lrte_common_mlx5
 LDLIBS += -lm
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
-LDLIBS += -lrte_bus_pci
 
 # A few warnings cannot be avoided in external headers.
 CFLAGS += -Wno-error=cast-qual
index c4e6c6f..fd2e631 100644 (file)
@@ -1535,7 +1535,6 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                        strerror(rte_errno));
                return -rte_errno;
        }
-       MLX5_ASSERT(pci_drv == &mlx5_driver);
        errno = 0;
        ibv_list = mlx5_glue->get_device_list(&ret);
        if (!ibv_list) {
index 2defe4a..2560ae1 100644 (file)
@@ -30,6 +30,7 @@
 #include <mlx5_common.h>
 #include <mlx5_common_os.h>
 #include <mlx5_common_mp.h>
+#include <mlx5_common_pci.h>
 #include <mlx5_malloc.h>
 
 #include "mlx5_defs.h"
@@ -1965,16 +1966,19 @@ static const struct rte_pci_id mlx5_pci_id_map[] = {
        }
 };
 
-struct rte_pci_driver mlx5_driver = {
-       .driver = {
-               .name = MLX5_DRIVER_NAME
+static struct mlx5_pci_driver mlx5_driver = {
+       .driver_class = MLX5_CLASS_NET,
+       .pci_driver = {
+               .driver = {
+                       .name = MLX5_DRIVER_NAME,
+               },
+               .id_table = mlx5_pci_id_map,
+               .probe = mlx5_os_pci_probe,
+               .remove = mlx5_pci_remove,
+               .dma_map = mlx5_dma_map,
+               .dma_unmap = mlx5_dma_unmap,
+               .drv_flags = PCI_DRV_FLAGS,
        },
-       .id_table = mlx5_pci_id_map,
-       .probe = mlx5_os_pci_probe,
-       .remove = mlx5_pci_remove,
-       .dma_map = mlx5_dma_map,
-       .dma_unmap = mlx5_dma_unmap,
-       .drv_flags = PCI_DRV_FLAGS,
 };
 
 /* Initialize driver log type. */
@@ -1991,7 +1995,7 @@ RTE_INIT(rte_mlx5_pmd_init)
        mlx5_set_cksum_table();
        mlx5_set_swp_types_table();
        if (mlx5_glue)
-               rte_pci_register(&mlx5_driver);
+               mlx5_pci_driver_register(&mlx5_driver);
 }
 
 RTE_PMD_EXPORT_NAME(net_mlx5, __COUNTER__);
index ee8e8bf..a73ac14 100644 (file)
@@ -119,7 +119,6 @@ struct mlx5_local_data {
 };
 
 extern struct mlx5_shared_data *mlx5_shared_data;
-extern struct rte_pci_driver mlx5_driver;
 
 /* Dev ops structs */
 extern const struct eth_dev_ops mlx5_os_dev_ops;
index 7f800f2..d7cb2c5 100644 (file)
@@ -8,7 +8,7 @@ if not is_linux
 endif
 
 fmt_name = 'mlx5_regex'
-deps += ['common_mlx5', 'bus_pci', 'eal', 'regexdev']
+deps += ['common_mlx5', 'eal', 'regexdev']
 sources = files(
        'mlx5_regex.c',
        'mlx5_rxp.c',
index 4e03670..ae9f001 100644 (file)
@@ -5,12 +5,12 @@
 #include <rte_malloc.h>
 #include <rte_log.h>
 #include <rte_errno.h>
-#include <rte_bus_pci.h>
 #include <rte_pci.h>
 #include <rte_regexdev.h>
 #include <rte_regexdev_core.h>
 #include <rte_regexdev_driver.h>
 
+#include <mlx5_common_pci.h>
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
 #include <mlx5_prm.h>
@@ -246,21 +246,24 @@ static const struct rte_pci_id mlx5_regex_pci_id_map[] = {
        }
 };
 
-static struct rte_pci_driver mlx5_regex_driver = {
-       .driver = {
-               .name = "mlx5_regex",
+static struct mlx5_pci_driver mlx5_regex_driver = {
+       .driver_class = MLX5_CLASS_REGEX,
+       .pci_driver = {
+               .driver = {
+                       .name = "mlx5_regex",
+               },
+               .id_table = mlx5_regex_pci_id_map,
+               .probe = mlx5_regex_pci_probe,
+               .remove = mlx5_regex_pci_remove,
+               .drv_flags = 0,
        },
-       .id_table = mlx5_regex_pci_id_map,
-       .probe = mlx5_regex_pci_probe,
-       .remove = mlx5_regex_pci_remove,
-       .drv_flags = 0,
 };
 
 RTE_INIT(rte_mlx5_regex_init)
 {
        mlx5_common_init();
        if (mlx5_glue)
-               rte_pci_register(&mlx5_regex_driver);
+               mlx5_pci_driver_register(&mlx5_regex_driver);
 }
 
 RTE_LOG_REGISTER(mlx5_regex_logtype, pmd.regex.mlx5, NOTICE)
index 8a1c2ea..d46699f 100644 (file)
@@ -30,7 +30,7 @@ CFLAGS += -D_XOPEN_SOURCE=600
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -Wno-strict-prototypes
 LDLIBS += -lrte_common_mlx5
-LDLIBS += -lrte_eal -lrte_vhost -lrte_kvargs -lrte_pci -lrte_bus_pci -lrte_sched
+LDLIBS += -lrte_eal -lrte_vhost -lrte_kvargs -lrte_pci -lrte_sched
 LDLIBS += -pthread
 
 # A few warnings cannot be avoided in external headers.
index 2963aad..254a8ec 100644 (file)
@@ -8,7 +8,7 @@ if not is_linux
 endif
 
 fmt_name = 'mlx5_vdpa'
-deps += ['hash', 'common_mlx5', 'vhost', 'pci', 'bus_pci', 'eal', 'sched']
+deps += ['hash', 'common_mlx5', 'vhost', 'pci', 'eal', 'sched']
 sources = files(
        'mlx5_vdpa.c',
        'mlx5_vdpa_mem.c',
index 85dbcf9..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>
@@ -657,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.
  *
@@ -829,14 +829,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)
@@ -848,7 +851,7 @@ 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__);