From fe363dd42505612b966f81caa41712fa4edba6ee Mon Sep 17 00:00:00 2001 From: Jan Viktorin Date: Tue, 20 Sep 2016 18:11:29 +0530 Subject: [PATCH] drivers: use vdev registration 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 Signed-off-by: Shreyansh Jain Acked-by: David Marchand --- drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 10 ++++++---- drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 10 ++++++---- drivers/crypto/kasumi/rte_kasumi_pmd.c | 10 ++++++---- drivers/crypto/null/null_crypto_pmd.c | 10 ++++++---- drivers/crypto/snow3g/rte_snow3g_pmd.c | 10 ++++++---- drivers/net/af_packet/rte_eth_af_packet.c | 10 ++++++---- drivers/net/bonding/rte_eth_bond_pmd.c | 10 ++++++---- drivers/net/mpipe/mpipe_tilegx.c | 18 +++++++++++------- drivers/net/null/rte_eth_null.c | 10 ++++++---- drivers/net/pcap/rte_eth_pcap.c | 10 ++++++---- drivers/net/ring/rte_eth_ring.c | 10 ++++++---- drivers/net/vhost/rte_eth_vhost.c | 10 ++++++---- drivers/net/virtio/virtio_user_ethdev.c | 9 ++++++--- drivers/net/xenvirt/rte_eth_xenvirt.c | 10 ++++++---- lib/librte_eal/common/eal_common_vdev.c | 4 ++-- lib/librte_eal/common/include/rte_dev.h | 12 ------------ lib/librte_eal/common/include/rte_vdev.h | 12 ++++++++++++ 17 files changed, 103 insertions(+), 72 deletions(-) diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c index dc0b0337f9..c93ebfe454 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -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= " "max_nb_sessions= " diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c index b2d0c8ca41..30c07062c7 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -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= " "max_nb_sessions= " diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c index 4e21743425..ba2829d38d 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include @@ -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= " "max_nb_sessions= " diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c index 909b04f989..4c12faa9b6 100644 --- a/drivers/crypto/null/null_crypto_pmd.c +++ b/drivers/crypto/null/null_crypto_pmd.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #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= " "max_nb_sessions= " diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index 87cd070a46..10c6b8376c 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include @@ -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= " "max_nb_sessions= " diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 93ae2d755c..050f8fc56e 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -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= " "qpairs= " diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 09ce7bf749..e19fc5ee9d 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -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= " diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c index 66b43ec456..135b78f6ba 100644 --- a/drivers/net/mpipe/mpipe_tilegx.c +++ b/drivers/net/mpipe/mpipe_tilegx.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include #include @@ -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) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 42ec107b7e..c83b62bf0c 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include @@ -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= " "copy="); diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 418fc528bd..8c7f6eb33d 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include @@ -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= " "tx_pcap= " diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index b90684ce7a..9cdeb51a4e 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -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]"); diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index d0bffbd2fd..01a1f18a45 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -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= " "queues="); diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index c682d8f03c..50de48481a 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -37,6 +37,7 @@ #include #include +#include #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= " "mac= " diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c index 2ffa54c9c8..605aba91f4 100644 --- a/drivers/net/xenvirt/rte_eth_xenvirt.c +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include @@ -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="); diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 67cb397535..1a4dec6922 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -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); diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 6cc9b017ca..8796f97b9f 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -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. */ }; /** diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 9c5cc54735..1e6b33820a 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -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. */ }; /** -- 2.20.1