drivers: use vdev registration
authorJan Viktorin <viktorin@rehivetech.com>
Tue, 20 Sep 2016 12:41:29 +0000 (18:11 +0530)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 3 Oct 2016 14:33:48 +0000 (16:33 +0200)
All PMD_VDEV drivers can now use rte_vdev_driver instead of the
rte_driver (which is embedded in the rte_vdev_driver).

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: David Marchand <david.marchand@6wind.com>
17 files changed:
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
drivers/crypto/kasumi/rte_kasumi_pmd.c
drivers/crypto/null/null_crypto_pmd.c
drivers/crypto/snow3g/rte_snow3g_pmd.c
drivers/net/af_packet/rte_eth_af_packet.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/mpipe/mpipe_tilegx.c
drivers/net/null/rte_eth_null.c
drivers/net/pcap/rte_eth_pcap.c
drivers/net/ring/rte_eth_ring.c
drivers/net/vhost/rte_eth_vhost.c
drivers/net/virtio/virtio_user_ethdev.c
drivers/net/xenvirt/rte_eth_xenvirt.c
lib/librte_eal/common/eal_common_vdev.c
lib/librte_eal/common/include/rte_dev.h
lib/librte_eal/common/include/rte_vdev.h

index dc0b033..c93ebfe 100644 (file)
@@ -37,7 +37,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
@@ -514,13 +514,15 @@ aesni_gcm_uninit(const char *name)
        return 0;
 }
 
-static struct rte_driver aesni_gcm_pmd_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver aesni_gcm_pmd_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = aesni_gcm_init,
        .uninit = aesni_gcm_uninit
 };
 
-PMD_REGISTER_DRIVER(aesni_gcm_pmd_drv, CRYPTODEV_NAME_AESNI_GCM_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_GCM_PMD, aesni_gcm_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
        "max_nb_queue_pairs=<int> "
        "max_nb_sessions=<int> "
index b2d0c8c..30c0706 100644 (file)
@@ -34,7 +34,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
@@ -714,13 +714,15 @@ cryptodev_aesni_mb_uninit(const char *name)
        return 0;
 }
 
-static struct rte_driver cryptodev_aesni_mb_pmd_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = cryptodev_aesni_mb_init,
        .uninit = cryptodev_aesni_mb_uninit
 };
 
-PMD_REGISTER_DRIVER(cryptodev_aesni_mb_pmd_drv, CRYPTODEV_NAME_AESNI_MB_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
        "max_nb_queue_pairs=<int> "
        "max_nb_sessions=<int> "
index 4e21743..ba2829d 100644 (file)
@@ -35,7 +35,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
@@ -650,13 +650,15 @@ cryptodev_kasumi_uninit(const char *name)
        return 0;
 }
 
-static struct rte_driver cryptodev_kasumi_pmd_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = cryptodev_kasumi_init,
        .uninit = cryptodev_kasumi_uninit
 };
 
-PMD_REGISTER_DRIVER(cryptodev_kasumi_pmd_drv, CRYPTODEV_NAME_KASUMI_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
        "max_nb_queue_pairs=<int> "
        "max_nb_sessions=<int> "
index 909b04f..4c12faa 100644 (file)
@@ -33,7 +33,7 @@
 #include <rte_common.h>
 #include <rte_config.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 
 #include "null_crypto_pmd_private.h"
@@ -268,13 +268,15 @@ cryptodev_null_uninit(const char *name)
        return 0;
 }
 
-static struct rte_driver cryptodev_null_pmd_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_null_pmd_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = cryptodev_null_init,
        .uninit = cryptodev_null_uninit
 };
 
-PMD_REGISTER_DRIVER(cryptodev_null_pmd_drv, CRYPTODEV_NAME_NULL_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
        "max_nb_queue_pairs=<int> "
        "max_nb_sessions=<int> "
index 87cd070..10c6b83 100644 (file)
@@ -35,7 +35,7 @@
 #include <rte_hexdump.h>
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
@@ -638,13 +638,15 @@ cryptodev_snow3g_uninit(const char *name)
        return 0;
 }
 
-static struct rte_driver cryptodev_snow3g_pmd_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = cryptodev_snow3g_init,
        .uninit = cryptodev_snow3g_uninit
 };
 
-PMD_REGISTER_DRIVER(cryptodev_snow3g_pmd_drv, CRYPTODEV_NAME_SNOW3G_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
        "max_nb_queue_pairs=<int> "
        "max_nb_sessions=<int> "
index 93ae2d7..050f8fc 100644 (file)
@@ -40,7 +40,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
@@ -889,13 +889,15 @@ rte_pmd_af_packet_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_af_packet_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_af_packet_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_af_packet_devinit,
        .uninit = rte_pmd_af_packet_devuninit,
 };
 
-PMD_REGISTER_DRIVER(pmd_af_packet_drv, net_af_packet);
+DRIVER_REGISTER_VDEV(net_af_packet, pmd_af_packet_drv);
 DRIVER_REGISTER_PARAM_STRING(net_af_packet,
        "iface=<string> "
        "qpairs=<int> "
index 09ce7bf..e19fc5e 100644 (file)
@@ -42,7 +42,7 @@
 #include <rte_ip_frag.h>
 #include <rte_devargs.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_alarm.h>
 #include <rte_cycles.h>
 
@@ -2508,13 +2508,15 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
        return 0;
 }
 
-static struct rte_driver bond_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver bond_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = bond_init,
        .uninit = bond_uninit,
 };
 
-PMD_REGISTER_DRIVER(bond_drv, net_bonding);
+DRIVER_REGISTER_VDEV(net_bonding, bond_drv);
 
 DRIVER_REGISTER_PARAM_STRING(net_bonding,
        "slave=<ifc> "
index 66b43ec..135b78f 100644 (file)
@@ -33,7 +33,7 @@
 #include <unistd.h>
 
 #include <rte_eal.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_eal_memconfig.h>
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
@@ -1623,18 +1623,22 @@ rte_pmd_mpipe_devinit(const char *ifname,
        return 0;
 }
 
-static struct rte_driver pmd_mpipe_xgbe_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_mpipe_devinit,
 };
 
-static struct rte_driver pmd_mpipe_gbe_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_mpipe_gbe_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_mpipe_devinit,
 };
 
-PMD_REGISTER_DRIVER(pmd_mpipe_xgbe_drv, net_mpipe_xgbe);
-PMD_REGISTER_DRIVER(pmd_mpipe_gbe_drv, net_mpipe_gbe);
+DRIVER_REGISTER_VDEV(net_mpipe_xgbe, pmd_mpipe_xgbe_drv);
+DRIVER_REGISTER_VDEV(net_mpipe_gbe, pmd_mpipe_gbe_drv);
 
 static void __attribute__((constructor, used))
 mpipe_init_contexts(void)
index 42ec107..c83b62b 100644 (file)
@@ -35,7 +35,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
 
@@ -686,13 +686,15 @@ rte_pmd_null_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_null_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_null_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_null_devinit,
        .uninit = rte_pmd_null_devuninit,
 };
 
-PMD_REGISTER_DRIVER(pmd_null_drv, net_null);
+DRIVER_REGISTER_VDEV(net_null, pmd_null_drv);
 DRIVER_REGISTER_PARAM_STRING(net_null,
        "size=<int> "
        "copy=<int>");
index 418fc52..8c7f6eb 100644 (file)
@@ -40,7 +40,7 @@
 #include <rte_string_fns.h>
 #include <rte_cycles.h>
 #include <rte_kvargs.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 
 #include <net/if.h>
 
@@ -1083,13 +1083,15 @@ rte_pmd_pcap_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_pcap_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_pcap_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_pcap_devinit,
        .uninit = rte_pmd_pcap_devuninit,
 };
 
-PMD_REGISTER_DRIVER(pmd_pcap_drv, net_pcap);
+DRIVER_REGISTER_VDEV(net_pcap, pmd_pcap_drv);
 DRIVER_REGISTER_PARAM_STRING(net_pcap,
        "rx_pcap=<string> "
        "tx_pcap=<string> "
index b90684c..9cdeb51 100644 (file)
@@ -38,7 +38,7 @@
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
 #include <rte_string_fns.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_kvargs.h>
 #include <rte_errno.h>
 
@@ -623,12 +623,14 @@ rte_pmd_ring_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_ring_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_ring_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_ring_devinit,
        .uninit = rte_pmd_ring_devuninit,
 };
 
-PMD_REGISTER_DRIVER(pmd_ring_drv, net_ring);
+DRIVER_REGISTER_VDEV(net_ring, pmd_ring_drv);
 DRIVER_REGISTER_PARAM_STRING(net_ring,
        "nodeaction=[attach|detach]");
index d0bffbd..01a1f18 100644 (file)
@@ -41,7 +41,7 @@
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <rte_kvargs.h>
 #include <rte_virtio_net.h>
 #include <rte_spinlock.h>
@@ -924,13 +924,15 @@ rte_pmd_vhost_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_vhost_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_vhost_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_vhost_devinit,
        .uninit = rte_pmd_vhost_devuninit,
 };
 
-PMD_REGISTER_DRIVER(pmd_vhost_drv, net_vhost);
+DRIVER_REGISTER_VDEV(net_vhost, pmd_vhost_drv);
 DRIVER_REGISTER_PARAM_STRING(net_vhost,
        "iface=<ifc> "
        "queues=<int>");
index c682d8f..50de484 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <rte_malloc.h>
 #include <rte_kvargs.h>
+#include <rte_vdev.h>
 
 #include "virtio_ethdev.h"
 #include "virtio_logs.h"
@@ -461,13 +462,15 @@ virtio_user_pmd_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver virtio_user_driver = {
-       .type   = PMD_VDEV,
+static struct rte_vdev_driver virtio_user_driver = {
+       .driver = {
+               .type   = PMD_VDEV,
+       },
        .init   = virtio_user_pmd_devinit,
        .uninit = virtio_user_pmd_devuninit,
 };
 
-PMD_REGISTER_DRIVER(virtio_user_driver, net_virtio_user);
+DRIVER_REGISTER_VDEV(net_virtio_user, virtio_user_driver);
 DRIVER_REGISTER_PARAM_STRING(net_virtio_user,
        "path=<path> "
        "mac=<mac addr> "
index 2ffa54c..605aba9 100644 (file)
@@ -56,7 +56,7 @@
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
-#include <rte_dev.h>
+#include <rte_vdev.h>
 #include <cmdline_parse.h>
 #include <cmdline_parse_etheraddr.h>
 
@@ -759,12 +759,14 @@ rte_pmd_xenvirt_devuninit(const char *name)
        return 0;
 }
 
-static struct rte_driver pmd_xenvirt_drv = {
-       .type = PMD_VDEV,
+static struct rte_vdev_driver pmd_xenvirt_drv = {
+       .driver = {
+               .type = PMD_VDEV,
+       },
        .init = rte_pmd_xenvirt_devinit,
        .uninit = rte_pmd_xenvirt_devuninit,
 };
 
-PMD_REGISTER_DRIVER(pmd_xenvirt_drv, net_xenvirt);
+DRIVER_REGISTER_VDEV(net_xenvirt, pmd_xenvirt_drv);
 DRIVER_REGISTER_PARAM_STRING(net_xenvirt,
        "mac=<mac addr>");
index 67cb397..1a4dec6 100644 (file)
@@ -74,7 +74,7 @@ rte_eal_vdev_init(const char *name, const char *args)
                 */
                if (!strncmp(driver->driver.name, name,
                            strlen(driver->driver.name)))
-                       return driver->driver.init(name, args);
+                       return driver->init(name, args);
        }
 
        RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
@@ -98,7 +98,7 @@ rte_eal_vdev_uninit(const char *name)
                 */
                if (!strncmp(driver->driver.name, name,
                             strlen(driver->driver.name)))
-                       return driver->driver.uninit(name);
+                       return driver->uninit(name);
        }
 
        RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
index 6cc9b01..8796f97 100644 (file)
@@ -104,16 +104,6 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
 
-/**
- * Initialization function called for each device driver once.
- */
-typedef int (rte_dev_init_t)(const char *name, const char *args);
-
-/**
- * Uninitilization function called for each device driver once.
- */
-typedef int (rte_dev_uninit_t)(const char *name);
-
 /**
  * Driver type enumeration
  */
@@ -129,8 +119,6 @@ struct rte_driver {
        TAILQ_ENTRY(rte_driver) next;  /**< Next in list. */
        enum pmd_type type;                /**< PMD Driver type */
        const char *name;                   /**< Driver name. */
-       rte_dev_init_t *init;              /**< Device init. function. */
-       rte_dev_uninit_t *uninit;          /**< Device uninit. function. */
 };
 
 /**
index 9c5cc54..1e6b338 100644 (file)
@@ -43,12 +43,24 @@ extern "C" {
 /** Double linked list of virtual device drivers. */
 TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
 
+/**
+ * Initialization function called for each virtual device driver once.
+ */
+typedef int (rte_vdev_init_t)(const char *name, const char *args);
+
+/**
+ * Uninitilization function called for each virtual device driver once.
+ */
+typedef int (rte_vdev_uninit_t)(const char *name);
+
 /**
  * A virtual device driver abstraction.
  */
 struct rte_vdev_driver {
        TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
        struct rte_driver driver;          /**< Inherited general driver. */
+       rte_vdev_init_t *init;         /**< Virtual device init. function. */
+       rte_vdev_uninit_t *uninit;     /**< Virtual device uninit. function. */
 };
 
 /**