From: Jan Blunck Date: Tue, 11 Apr 2017 15:44:13 +0000 (+0200) Subject: vdev: use generic vdev struct for probe and remove X-Git-Tag: spdx-start~3657 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5d2aa461cbcae1b5ede5cee0b0b3a1228c4afc59;p=dpdk.git vdev: use generic vdev struct for probe and remove This is a preparation to embed the generic rte_device into the rte_eth_dev also for virtual devices. Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c index ceec765110..1705896f0b 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c @@ -429,10 +429,11 @@ aesni_gcm_pmd_enqueue_burst(void *queue_pair, return nb_enqueued; } -static int aesni_gcm_remove(const char *name); +static int aesni_gcm_remove(struct rte_vdev_device *vdev); static int -aesni_gcm_create(struct rte_crypto_vdev_init_params *init_params) +aesni_gcm_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct aesni_gcm_private *internals; @@ -483,12 +484,12 @@ aesni_gcm_create(struct rte_crypto_vdev_init_params *init_params) init_error: GCM_LOG_ERR("driver %s: create failed", init_params->name); - aesni_gcm_remove(init_params->name); + aesni_gcm_remove(vdev); return -EFAULT; } static int -aesni_gcm_probe(const char *name, const char *input_args) +aesni_gcm_probe(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -496,7 +497,11 @@ aesni_gcm_probe(const char *name, const char *input_args) rte_socket_id(), {0} }; + const char *name; + const char *input_args; + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, @@ -509,12 +514,15 @@ aesni_gcm_probe(const char *name, const char *input_args) RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return aesni_gcm_create(&init_params); + return aesni_gcm_create(vdev, &init_params); } static int -aesni_gcm_remove(const char *name) +aesni_gcm_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c index be15d2282d..37b22ec69f 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c @@ -669,10 +669,11 @@ aesni_mb_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, return processed_jobs; } -static int cryptodev_aesni_mb_remove(const char *name); +static int cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev); static int -cryptodev_aesni_mb_create(struct rte_crypto_vdev_init_params *init_params) +cryptodev_aesni_mb_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct aesni_mb_private *internals; @@ -750,13 +751,12 @@ init_error: MB_LOG_ERR("driver %s: cryptodev_aesni_create failed", init_params->name); - cryptodev_aesni_mb_remove(init_params->name); + cryptodev_aesni_mb_remove(vdev); return -EFAULT; } static int -cryptodev_aesni_mb_probe(const char *name, - const char *input_args) +cryptodev_aesni_mb_probe(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -764,7 +764,11 @@ cryptodev_aesni_mb_probe(const char *name, rte_socket_id(), "" }; + const char *name; + const char *input_args; + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, @@ -777,12 +781,15 @@ cryptodev_aesni_mb_probe(const char *name, RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return cryptodev_aesni_mb_create(&init_params); + return cryptodev_aesni_mb_create(vdev, &init_params); } static int -cryptodev_aesni_mb_remove(const char *name) +cryptodev_aesni_mb_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c index 6376e9edd1..bf56bc62a4 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd.c +++ b/drivers/crypto/armv8/rte_armv8_pmd.c @@ -44,7 +44,7 @@ #include "rte_armv8_pmd_private.h" -static int cryptodev_armv8_crypto_uninit(const char *name); +static int cryptodev_armv8_crypto_uninit(struct rte_vdev_device *vdev); /** * Pointers to the supported combined mode crypto functions are stored @@ -773,7 +773,8 @@ armv8_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, /** Create ARMv8 crypto device */ static int -cryptodev_armv8_crypto_create(struct rte_crypto_vdev_init_params *init_params) +cryptodev_armv8_crypto_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct armv8_crypto_private *internals; @@ -845,14 +846,13 @@ init_error: "driver %s: cryptodev_armv8_crypto_create failed", init_params->name); - cryptodev_armv8_crypto_uninit(init_params->name); + cryptodev_armv8_crypto_uninit(vdev); return -EFAULT; } /** Initialise ARMv8 crypto device */ static int -cryptodev_armv8_crypto_init(const char *name, - const char *input_args) +cryptodev_armv8_crypto_init(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -860,7 +860,11 @@ cryptodev_armv8_crypto_init(const char *name, rte_socket_id(), {0} }; + const char *name; + const char *input_args; + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, @@ -874,13 +878,16 @@ cryptodev_armv8_crypto_init(const char *name, RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return cryptodev_armv8_crypto_create(&init_params); + return cryptodev_armv8_crypto_create(vdev, &init_params); } /** Uninitialise ARMv8 crypto device */ static int -cryptodev_armv8_crypto_uninit(const char *name) +cryptodev_armv8_crypto_uninit(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c index 55bdb29b8f..42fdd33a7c 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c @@ -548,10 +548,11 @@ kasumi_pmd_dequeue_burst(void *queue_pair, return nb_dequeued; } -static int cryptodev_kasumi_remove(const char *name); +static int cryptodev_kasumi_remove(struct rte_vdev_device *vdev); static int -cryptodev_kasumi_create(struct rte_crypto_vdev_init_params *init_params) +cryptodev_kasumi_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct kasumi_private *internals; @@ -606,13 +607,12 @@ init_error: KASUMI_LOG_ERR("driver %s: cryptodev_kasumi_create failed", init_params->name); - cryptodev_kasumi_remove(init_params->name); + cryptodev_kasumi_remove(vdev); return -EFAULT; } static int -cryptodev_kasumi_probe(const char *name, - const char *input_args) +cryptodev_kasumi_probe(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -620,6 +620,11 @@ cryptodev_kasumi_probe(const char *name, rte_socket_id(), {0} }; + const char *name; + const char *input_args; + + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); @@ -633,12 +638,15 @@ cryptodev_kasumi_probe(const char *name, RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return cryptodev_kasumi_create(&init_params); + return cryptodev_kasumi_create(vdev, &init_params); } static int -cryptodev_kasumi_remove(const char *name) +cryptodev_kasumi_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c index f68ec8d2b8..a44c61a446 100644 --- a/drivers/crypto/null/null_crypto_pmd.c +++ b/drivers/crypto/null/null_crypto_pmd.c @@ -218,8 +218,7 @@ init_error: /** Initialise null crypto device */ static int -cryptodev_null_probe(const char *name, - const char *input_args) +cryptodev_null_probe(struct rte_vdev_device *dev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -228,10 +227,11 @@ cryptodev_null_probe(const char *name, {0} }; - rte_cryptodev_parse_vdev_init_params(&init_params, input_args); + rte_cryptodev_parse_vdev_init_params(&init_params, + rte_vdev_device_args(dev)); - RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, - init_params.socket_id); + RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", + rte_vdev_device_name(dev), init_params.socket_id); if (init_params.name[0] != '\0') RTE_LOG(INFO, PMD, " User defined name = %s\n", init_params.name); @@ -256,9 +256,15 @@ cryptodev_null_remove(const char *name) return 0; } +static int +cryptodev_null_remove_dev(struct rte_vdev_device *dev) +{ + return cryptodev_null_remove(rte_vdev_device_name(dev)); +} + static struct rte_vdev_driver cryptodev_null_pmd_drv = { .probe = cryptodev_null_probe, - .remove = cryptodev_null_remove + .remove = cryptodev_null_remove_dev, }; RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd_drv); diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 5046eac1d1..f3c8f839d9 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -44,7 +44,7 @@ #define DES_BLOCK_SIZE 8 -static int cryptodev_openssl_remove(const char *name); +static int cryptodev_openssl_remove(struct rte_vdev_device *vdev); /*----------------------------------------------------------------------------*/ @@ -1264,7 +1264,8 @@ openssl_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, /** Create OPENSSL crypto device */ static int -cryptodev_openssl_create(struct rte_crypto_vdev_init_params *init_params) +cryptodev_openssl_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct openssl_private *internals; @@ -1312,14 +1313,13 @@ init_error: OPENSSL_LOG_ERR("driver %s: cryptodev_openssl_create failed", init_params->name); - cryptodev_openssl_remove(init_params->name); + cryptodev_openssl_remove(vdev); return -EFAULT; } /** Initialise OPENSSL crypto device */ static int -cryptodev_openssl_probe(const char *name, - const char *input_args) +cryptodev_openssl_probe(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -1327,6 +1327,11 @@ cryptodev_openssl_probe(const char *name, rte_socket_id(), {0} }; + const char *name; + const char *input_args; + + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); @@ -1340,13 +1345,16 @@ cryptodev_openssl_probe(const char *name, RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return cryptodev_openssl_create(&init_params); + return cryptodev_openssl_create(vdev, &init_params); } /** Uninitialise OPENSSL crypto device */ static int -cryptodev_openssl_remove(const char *name) +cryptodev_openssl_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/crypto/scheduler/scheduler_pmd.c b/drivers/crypto/scheduler/scheduler_pmd.c index b189fbdeca..7d9e376019 100644 --- a/drivers/crypto/scheduler/scheduler_pmd.c +++ b/drivers/crypto/scheduler/scheduler_pmd.c @@ -193,14 +193,16 @@ cryptodev_scheduler_create(const char *name, } static int -cryptodev_scheduler_remove(const char *name) +cryptodev_scheduler_remove(struct rte_vdev_device *vdev) { + const char *name; struct rte_cryptodev *dev; struct scheduler_ctx *sched_ctx; - if (name == NULL) + if (vdev == NULL) return -EINVAL; + name = rte_vdev_device_name(vdev); dev = rte_cryptodev_pmd_get_named_dev(name); if (dev == NULL) return -EINVAL; @@ -413,7 +415,7 @@ free_kvlist: } static int -cryptodev_scheduler_probe(const char *name, const char *input_args) +cryptodev_scheduler_probe(struct rte_vdev_device *vdev) { struct scheduler_init_params init_params = { .def_p = { @@ -428,9 +430,11 @@ cryptodev_scheduler_probe(const char *name, const char *input_args) .enable_ordering = 0 }; - scheduler_parse_init_params(&init_params, input_args); + scheduler_parse_init_params(&init_params, + rte_vdev_device_args(vdev)); - RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, + RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", + rte_vdev_device_name(vdev), init_params.def_p.socket_id); RTE_LOG(INFO, PMD, " Max number of queue pairs = %d\n", init_params.def_p.max_nb_queue_pairs); @@ -440,7 +444,8 @@ cryptodev_scheduler_probe(const char *name, const char *input_args) RTE_LOG(INFO, PMD, " User defined name = %s\n", init_params.def_p.name); - return cryptodev_scheduler_create(name, &init_params); + return cryptodev_scheduler_create(rte_vdev_device_name(vdev), + &init_params); } static struct rte_vdev_driver cryptodev_scheduler_pmd_drv = { diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index 1042b311bf..a31eaa81b0 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -539,10 +539,11 @@ snow3g_pmd_dequeue_burst(void *queue_pair, return nb_dequeued; } -static int cryptodev_snow3g_remove(const char *name); +static int cryptodev_snow3g_remove(struct rte_vdev_device *vdev); static int -cryptodev_snow3g_create(struct rte_crypto_vdev_init_params *init_params) +cryptodev_snow3g_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct snow3g_private *internals; @@ -595,13 +596,12 @@ init_error: SNOW3G_LOG_ERR("driver %s: cryptodev_snow3g_create failed", init_params->name); - cryptodev_snow3g_remove(init_params->name); + cryptodev_snow3g_remove(vdev); return -EFAULT; } static int -cryptodev_snow3g_probe(const char *name, - const char *input_args) +cryptodev_snow3g_probe(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -609,6 +609,11 @@ cryptodev_snow3g_probe(const char *name, rte_socket_id(), {0} }; + const char *name; + const char *input_args; + + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); @@ -622,12 +627,15 @@ cryptodev_snow3g_probe(const char *name, RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return cryptodev_snow3g_create(&init_params); + return cryptodev_snow3g_create(vdev, &init_params); } static int -cryptodev_snow3g_remove(const char *name) +cryptodev_snow3g_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c index 06ff503bde..5eec9334bd 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd.c +++ b/drivers/crypto/zuc/rte_zuc_pmd.c @@ -439,10 +439,11 @@ zuc_pmd_dequeue_burst(void *queue_pair, return nb_dequeued; } -static int cryptodev_zuc_remove(const char *name); +static int cryptodev_zuc_remove(struct rte_vdev_device *vdev); static int -cryptodev_zuc_create(struct rte_crypto_vdev_init_params *init_params) +cryptodev_zuc_create(struct rte_vdev_device *vdev, + struct rte_crypto_vdev_init_params *init_params) { struct rte_cryptodev *dev; struct zuc_private *internals; @@ -495,13 +496,12 @@ init_error: ZUC_LOG_ERR("driver %s: cryptodev_zuc_create failed", init_params->name); - cryptodev_zuc_remove(init_params->name); + cryptodev_zuc_remove(vdev); return -EFAULT; } static int -cryptodev_zuc_probe(const char *name, - const char *input_args) +cryptodev_zuc_probe(struct rte_vdev_device *vdev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -509,6 +509,11 @@ cryptodev_zuc_probe(const char *name, rte_socket_id(), {0} }; + const char *name; + const char *input_args; + + name = rte_vdev_device_name(vdev); + input_args = rte_vdev_device_args(vdev); rte_cryptodev_parse_vdev_init_params(&init_params, input_args); @@ -522,12 +527,15 @@ cryptodev_zuc_probe(const char *name, RTE_LOG(INFO, PMD, " Max number of sessions = %d\n", init_params.max_nb_sessions); - return cryptodev_zuc_create(&init_params); + return cryptodev_zuc_create(vdev, &init_params); } static int -cryptodev_zuc_remove(const char *name) +cryptodev_zuc_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c index 6479c802c6..c80a44379f 100644 --- a/drivers/event/octeontx/ssovf_evdev.c +++ b/drivers/event/octeontx/ssovf_evdev.c @@ -488,17 +488,17 @@ static const struct rte_eventdev_ops ssovf_ops = { }; static int -ssovf_vdev_probe(const char *name, const char *params) +ssovf_vdev_probe(struct rte_vdev_device *vdev) { struct octeontx_ssovf_info oinfo; struct ssovf_mbox_dev_info info; struct ssovf_evdev *edev; struct rte_eventdev *eventdev; static int ssovf_init_once; + const char *name; int ret; - RTE_SET_USED(params); - + name = rte_vdev_device_name(vdev); /* More than one instance is not supported */ if (ssovf_init_once) { ssovf_log_err("Request to create >1 %s instance", name); @@ -563,8 +563,11 @@ error: } static int -ssovf_vdev_remove(const char *name) +ssovf_vdev_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); ssovf_log_info("Closing %s", name); return rte_event_pmd_vdev_uninit(name); } diff --git a/drivers/event/skeleton/skeleton_eventdev.c b/drivers/event/skeleton/skeleton_eventdev.c index d2da7d8f1c..800bd76e0b 100644 --- a/drivers/event/skeleton/skeleton_eventdev.c +++ b/drivers/event/skeleton/skeleton_eventdev.c @@ -468,16 +468,22 @@ fail: } static int -skeleton_eventdev_probe(const char *name, __rte_unused const char *input_args) +skeleton_eventdev_probe(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); RTE_LOG(INFO, PMD, "Initializing %s on NUMA node %d\n", name, rte_socket_id()); return skeleton_eventdev_create(name, rte_socket_id()); } static int -skeleton_eventdev_remove(const char *name) +skeleton_eventdev_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); PMD_DRV_LOG(INFO, "Closing %s on NUMA node %d", name, rte_socket_id()); return rte_event_pmd_vdev_uninit(name); diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c index 0caf8ba114..a31aaa6625 100644 --- a/drivers/event/sw/sw_evdev.c +++ b/drivers/event/sw/sw_evdev.c @@ -696,7 +696,7 @@ set_credit_quanta(const char *key __rte_unused, const char *value, void *opaque) } static int -sw_probe(const char *name, const char *params) +sw_probe(struct rte_vdev_device *vdev) { static const struct rte_eventdev_ops evdev_sw_ops = { .dev_configure = sw_dev_configure, @@ -727,12 +727,16 @@ sw_probe(const char *name, const char *params) CREDIT_QUANTA_ARG, NULL }; + const char *name; + const char *params; struct rte_eventdev *dev; struct sw_evdev *sw; int socket_id = rte_socket_id(); int sched_quanta = SW_DEFAULT_SCHED_QUANTA; int credit_quanta = SW_DEFAULT_CREDIT_QUANTA; + name = rte_vdev_device_name(vdev); + params = rte_vdev_device_args(vdev); if (params != NULL && params[0] != '\0') { struct rte_kvargs *kvlist = rte_kvargs_parse(params, args); @@ -806,8 +810,11 @@ sw_probe(const char *name, const char *params) } static int -sw_remove(const char *name) +sw_remove(struct rte_vdev_device *vdev) { + const char *name; + + name = rte_vdev_device_name(vdev); if (name == NULL) return -EINVAL; diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 2f875539ce..77536e82bb 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -923,8 +923,9 @@ rte_eth_from_packet(const char *name, } static int -rte_pmd_af_packet_probe(const char *name, const char *params) +rte_pmd_af_packet_probe(struct rte_vdev_device *dev) { + const char *name = rte_vdev_device_name(dev); unsigned numa_node; int ret = 0; struct rte_kvargs *kvlist; @@ -934,7 +935,7 @@ rte_pmd_af_packet_probe(const char *name, const char *params) numa_node = rte_socket_id(); - kvlist = rte_kvargs_parse(params, valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) { ret = -1; goto exit; @@ -961,7 +962,7 @@ exit: } static int -rte_pmd_af_packet_remove(const char *name) +rte_pmd_af_packet_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals; @@ -970,11 +971,11 @@ rte_pmd_af_packet_remove(const char *name) RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket %u\n", rte_socket_id()); - if (name == NULL) + if (dev == NULL) return -1; /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) return -1; diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 77d3beef07..340d79312f 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2240,16 +2240,19 @@ const struct eth_dev_ops default_dev_ops = { }; static int -bond_probe(const char *name, const char *params) +bond_probe(struct rte_vdev_device *dev) { + const char *name; struct bond_dev_private *internals; struct rte_kvargs *kvlist; uint8_t bonding_mode, socket_id; int arg_count, port_id; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, EAL, "Initializing pmd_bond for %s\n", name); - kvlist = rte_kvargs_parse(params, pmd_bond_init_valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), + pmd_bond_init_valid_arguments); if (kvlist == NULL) return -1; @@ -2307,13 +2310,15 @@ parse_error: } static int -bond_remove(const char *name) +bond_remove(struct rte_vdev_device *dev) { + const char *name; int ret; - if (name == NULL) + if (!dev) return -EINVAL; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, EAL, "Uninitializing pmd_bond for %s\n", name); /* free link bonding eth device */ diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 59205e7dd7..e3ce572d5b 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -393,7 +393,7 @@ eth_kni_create(const char *name, struct eth_kni_args *args, eth_dev->data = data; eth_dev->dev_ops = ð_kni_ops; - eth_dev->driver = NULL; + eth_dev->device->driver = NULL; data->dev_flags = RTE_ETH_DEV_DETACHABLE; data->kdrv = RTE_KDRV_NONE; @@ -442,12 +442,16 @@ eth_kni_kvargs_process(struct eth_kni_args *args, const char *params) } static int -eth_kni_probe(const char *name, const char *params) +eth_kni_probe(struct rte_vdev_device *vdev) { struct rte_eth_dev *eth_dev; struct eth_kni_args args; + const char *name; + const char *params; int ret; + name = rte_vdev_device_name(vdev); + params = rte_vdev_device_args(vdev); RTE_LOG(INFO, PMD, "Initializing eth_kni for %s\n", name); ret = eth_kni_kvargs_process(&args, params); @@ -475,11 +479,13 @@ kni_uninit: } static int -eth_kni_remove(const char *name) +eth_kni_remove(struct rte_vdev_device *vdev) { struct rte_eth_dev *eth_dev; struct pmd_internals *internals; + const char *name; + name = rte_vdev_device_name(vdev); RTE_LOG(INFO, PMD, "Un-Initializing eth_kni for %s\n", name); /* find the ethdev entry */ diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 7e14da0e00..a7b57bcc8f 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -606,17 +606,20 @@ get_packet_copy_arg(const char *key __rte_unused, } static int -rte_pmd_null_probe(const char *name, const char *params) +rte_pmd_null_probe(struct rte_vdev_device *dev) { + const char *name, *params; unsigned numa_node; unsigned packet_size = default_packet_size; unsigned packet_copy = default_packet_copy; struct rte_kvargs *kvlist = NULL; int ret; - if (name == NULL) + if (!dev) return -EINVAL; + name = rte_vdev_device_name(dev); + params = rte_vdev_device_args(dev); RTE_LOG(INFO, PMD, "Initializing pmd_null for %s\n", name); numa_node = rte_socket_id(); @@ -658,18 +661,18 @@ free_kvlist: } static int -rte_pmd_null_remove(const char *name) +rte_pmd_null_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; - if (name == NULL) + if (!dev) return -EINVAL; RTE_LOG(INFO, PMD, "Closing null ethdev on numa socket %u\n", rte_socket_id()); /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) return -1; diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 075e3bed55..05cbd47b3c 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -936,8 +936,9 @@ eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues, } static int -pmd_pcap_probe(const char *name, const char *params) +pmd_pcap_probe(struct rte_vdev_device *dev) { + const char *name; unsigned int is_rx_pcap = 0, is_tx_pcap = 0; struct rte_kvargs *kvlist; struct pmd_devargs pcaps = {0}; @@ -945,13 +946,14 @@ pmd_pcap_probe(const char *name, const char *params) int single_iface = 0; int ret; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name); gettimeofday(&start_time, NULL); start_cycles = rte_get_timer_cycles(); hz = rte_get_timer_hz(); - kvlist = rte_kvargs_parse(params, valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) return -1; @@ -1035,18 +1037,18 @@ free_kvlist: } static int -pmd_pcap_remove(const char *name) +pmd_pcap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %u\n", rte_socket_id()); - if (name == NULL) + if (!dev) return -1; /* reserve an ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) return -1; diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 77ef3a19ac..4bae89570d 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -502,12 +502,16 @@ out: } static int -rte_pmd_ring_probe(const char *name, const char *params) +rte_pmd_ring_probe(struct rte_vdev_device *dev) { + const char *name, *params; struct rte_kvargs *kvlist = NULL; int ret = 0; struct node_action_list *info = NULL; + name = rte_vdev_device_name(dev); + params = rte_vdev_device_args(dev); + RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name); if (params == NULL || params[0] == '\0') { @@ -577,8 +581,9 @@ out_free: } static int -rte_pmd_ring_remove(const char *name) +rte_pmd_ring_remove(struct rte_vdev_device *dev) { + const char *name = rte_vdev_device_name(dev); struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals = NULL; struct ring_queue *r = NULL; diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 347a80741e..698e14baae 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -1288,14 +1288,18 @@ set_remote_iface(const char *key __rte_unused, /* Open a TAP interface device. */ static int -rte_pmd_tap_probe(const char *name, const char *params) +rte_pmd_tap_probe(struct rte_vdev_device *dev) { + const char *name, *params; int ret; struct rte_kvargs *kvlist = NULL; int speed; char tap_name[RTE_ETH_NAME_MAX_LEN]; char remote_iface[RTE_ETH_NAME_MAX_LEN]; + name = rte_vdev_device_name(dev); + params = rte_vdev_device_args(dev); + speed = ETH_SPEED_NUM_10G; snprintf(tap_name, sizeof(tap_name), "%s%d", DEFAULT_TAP_NAME, tap_unit++); @@ -1355,7 +1359,7 @@ leave: /* detach a TAP device. */ static int -rte_pmd_tap_remove(const char *name) +rte_pmd_tap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals; @@ -1365,7 +1369,7 @@ rte_pmd_tap_remove(const char *name) rte_socket_id()); /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (!eth_dev) return 0; diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 41ce5fc588..cdd8c315e3 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -1132,8 +1132,9 @@ open_int(const char *key __rte_unused, const char *value, void *extra_args) } static int -rte_pmd_vhost_probe(const char *name, const char *params) +rte_pmd_vhost_probe(struct rte_vdev_device *dev) { + const char *name; struct rte_kvargs *kvlist = NULL; int ret = 0; char *iface_name; @@ -1142,9 +1143,10 @@ rte_pmd_vhost_probe(const char *name, const char *params) int client_mode = 0; int dequeue_zero_copy = 0; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name); - kvlist = rte_kvargs_parse(params, valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) return -1; @@ -1195,11 +1197,13 @@ out_free: } static int -rte_pmd_vhost_remove(const char *name) +rte_pmd_vhost_remove(struct rte_vdev_device *dev) { + const char *name; struct rte_eth_dev *eth_dev = NULL; unsigned int i; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, PMD, "Un-Initializing pmd_vhost for %s\n", name); /* find an ethdev entry */ diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 4c3f664419..7979c1f00c 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -402,7 +402,7 @@ virtio_user_eth_dev_free(struct rte_eth_dev *eth_dev) * Returns 0 on success. */ static int -virtio_user_pmd_probe(const char *name, const char *params) +virtio_user_pmd_probe(struct rte_vdev_device *dev) { struct rte_kvargs *kvlist = NULL; struct rte_eth_dev *eth_dev; @@ -415,13 +415,7 @@ virtio_user_pmd_probe(const char *name, const char *params) char *mac_addr = NULL; int ret = -1; - if (!params || params[0] == '\0') { - PMD_INIT_LOG(ERR, "arg %s is mandatory for virtio_user", - VIRTIO_USER_ARG_QUEUE_SIZE); - goto end; - } - - kvlist = rte_kvargs_parse(params, valid_args); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_args); if (!kvlist) { PMD_INIT_LOG(ERR, "error when parsing param"); goto end; @@ -507,7 +501,7 @@ virtio_user_pmd_probe(const char *name, const char *params) } if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - eth_dev = virtio_user_eth_dev_alloc(name); + eth_dev = virtio_user_eth_dev_alloc(rte_vdev_device_name(dev)); if (!eth_dev) { PMD_INIT_LOG(ERR, "virtio_user fails to alloc device"); goto end; @@ -521,7 +515,7 @@ virtio_user_pmd_probe(const char *name, const char *params) goto end; } } else { - eth_dev = rte_eth_dev_attach_secondary(name); + eth_dev = rte_eth_dev_attach_secondary(rte_vdev_device_name(dev)); if (!eth_dev) goto end; } @@ -548,15 +542,17 @@ end: /** Called by rte_eth_dev_detach() */ static int -virtio_user_pmd_remove(const char *name) +virtio_user_pmd_remove(struct rte_vdev_device *vdev) { + const char *name; struct rte_eth_dev *eth_dev; struct virtio_hw *hw; struct virtio_user_dev *dev; - if (!name) + if (!vdev) return -EINVAL; + name = rte_vdev_device_name(vdev); PMD_DRV_LOG(INFO, "Un-Initializing %s", name); eth_dev = rte_eth_dev_allocated(name); if (!eth_dev) diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c index 19bc09a3d0..6ec8c08ff1 100644 --- a/drivers/net/xenvirt/rte_eth_xenvirt.c +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c @@ -726,7 +726,7 @@ eth_dev_xenvirt_free(const char *name, const unsigned numa_node) /*TODO: Support multiple process model */ static int -rte_pmd_xenvirt_probe(const char *name, const char *params) +rte_pmd_xenvirt_probe(struct rte_vdev_device *dev) { if (virtio_idx == 0) { if (xenstore_init() != 0) { @@ -738,14 +738,15 @@ rte_pmd_xenvirt_probe(const char *name, const char *params) return -1; } } - eth_dev_xenvirt_create(name, params, rte_socket_id(), DEV_CREATE); + eth_dev_xenvirt_create(rte_vdev_device_name(dev), + rte_vdev_device_args(dev), rte_socket_id(), DEV_CREATE); return 0; } static int -rte_pmd_xenvirt_remove(const char *name) +rte_pmd_xenvirt_remove(struct rte_vdev_device *dev) { - eth_dev_xenvirt_free(name, rte_socket_id()); + eth_dev_xenvirt_free(rte_vdev_device_name(dev), rte_socket_id()); if (virtio_idx == 0) { if (xenstore_uninit() != 0) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 70da608abb..22fe2ca62a 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -76,7 +76,6 @@ static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { const char *name = rte_vdev_device_name(dev); - const char *args = rte_vdev_device_args(dev); struct rte_vdev_driver *driver; int ret; @@ -90,7 +89,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) if (!strncmp(driver->driver.name, name, strlen(driver->driver.name))) { dev->device.driver = &driver->driver; - ret = driver->probe(name, args); + ret = driver->probe(dev); if (ret) dev->device.driver = NULL; return ret; @@ -103,7 +102,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) !strncmp(driver->driver.alias, name, strlen(driver->driver.alias))) { dev->device.driver = &driver->driver; - ret = driver->probe(name, args); + ret = driver->probe(dev); if (ret) dev->device.driver = NULL; return ret; @@ -215,7 +214,7 @@ vdev_remove_driver(struct rte_vdev_device *dev) driver = container_of(dev->device.driver, const struct rte_vdev_driver, driver); - return driver->remove(name); + return driver->remove(dev); } int diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 81f6beb8ab..8db2c00c82 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -68,12 +68,12 @@ TAILQ_HEAD(vdev_driver_list, rte_vdev_driver); /** * Probe function called for each virtual device driver once. */ -typedef int (rte_vdev_probe_t)(const char *name, const char *args); +typedef int (rte_vdev_probe_t)(struct rte_vdev_device *dev); /** * Remove function called for each virtual device driver once. */ -typedef int (rte_vdev_remove_t)(const char *name); +typedef int (rte_vdev_remove_t)(struct rte_vdev_device *dev); /** * A virtual device driver abstraction.