From: Akhil Goyal Date: Tue, 10 Aug 2021 19:50:18 +0000 (+0530) Subject: cryptodev: rename function to check device validity X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e74abd48433dc05e3d40cc922577d6c55b5b844c;p=dpdk.git cryptodev: rename function to check device validity The API rte_cryptodev_pmd_is_valid_dev, can be used by the application as well as PMD to check whether the device is valid or not. Hence, _pmd is removed from the API. The applications and drivers which use this API are also updated. Signed-off-by: Akhil Goyal Acked-by: Hemant Agrawal --- diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 411fa9530a..e7ad50ba09 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -102,6 +102,10 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to + rte_cryptodev_is_valid_dev as it can be used by the application as + well as PMD to check whether the device is valid or not. + ABI Changes ----------- diff --git a/drivers/net/softnic/rte_eth_softnic_cryptodev.c b/drivers/net/softnic/rte_eth_softnic_cryptodev.c index a1a4ca5650..8e278801c5 100644 --- a/drivers/net/softnic/rte_eth_softnic_cryptodev.c +++ b/drivers/net/softnic/rte_eth_softnic_cryptodev.c @@ -82,7 +82,7 @@ softnic_cryptodev_create(struct pmd_internals *p, dev_id = (uint32_t)status; } else { - if (rte_cryptodev_pmd_is_valid_dev(params->dev_id) == 0) + if (rte_cryptodev_is_valid_dev(params->dev_id) == 0) return NULL; dev_id = params->dev_id; diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index c175fe6ac2..e892078f0e 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -196,7 +196,7 @@ parse_cryptodev_id_arg(char *arg) } - if (!rte_cryptodev_pmd_is_valid_dev(cryptodev_id)) { + if (!rte_cryptodev_is_valid_dev(cryptodev_id)) { RTE_LOG(ERR, USER1, "Error %i: invalid cryptodev id %s\n", cryptodev_id, arg); return -1; diff --git a/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c index b0d9f3d217..9997d97456 100644 --- a/examples/ip_pipeline/cryptodev.c +++ b/examples/ip_pipeline/cryptodev.c @@ -6,7 +6,6 @@ #include #include -#include #include #include "cryptodev.h" @@ -74,7 +73,7 @@ cryptodev_create(const char *name, struct cryptodev_params *params) dev_id = (uint32_t)status; } else { - if (rte_cryptodev_pmd_is_valid_dev(params->dev_id) == 0) + if (rte_cryptodev_is_valid_dev(params->dev_id) == 0) return NULL; dev_id = params->dev_id; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 447aa9d519..37502b9b3c 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -663,7 +663,7 @@ rte_cryptodev_is_valid_device_data(uint8_t dev_id) } unsigned int -rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id) +rte_cryptodev_is_valid_dev(uint8_t dev_id) { struct rte_cryptodev *dev = NULL; @@ -761,7 +761,7 @@ rte_cryptodev_socket_id(uint8_t dev_id) { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + if (!rte_cryptodev_is_valid_dev(dev_id)) return -1; dev = rte_cryptodev_pmd_get_dev(dev_id); @@ -1032,7 +1032,7 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config) struct rte_cryptodev *dev; int diag; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1080,7 +1080,7 @@ rte_cryptodev_start(uint8_t dev_id) CDEV_LOG_DEBUG("Start dev_id=%" PRIu8, dev_id); - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1110,7 +1110,7 @@ rte_cryptodev_stop(uint8_t dev_id) { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return; } @@ -1136,7 +1136,7 @@ rte_cryptodev_close(uint8_t dev_id) struct rte_cryptodev *dev; int retval; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -1; } @@ -1176,7 +1176,7 @@ rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id) { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1207,7 +1207,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1283,7 +1283,7 @@ rte_cryptodev_add_enq_callback(uint8_t dev_id, return NULL; } - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); rte_errno = ENODEV; return NULL; @@ -1349,7 +1349,7 @@ rte_cryptodev_remove_enq_callback(uint8_t dev_id, return -EINVAL; } - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); return -ENODEV; } @@ -1418,7 +1418,7 @@ rte_cryptodev_add_deq_callback(uint8_t dev_id, return NULL; } - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); rte_errno = ENODEV; return NULL; @@ -1484,7 +1484,7 @@ rte_cryptodev_remove_deq_callback(uint8_t dev_id, return -EINVAL; } - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); return -ENODEV; } @@ -1542,7 +1542,7 @@ rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats) { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); return -ENODEV; } @@ -1565,7 +1565,7 @@ rte_cryptodev_stats_reset(uint8_t dev_id) { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return; } @@ -1581,7 +1581,7 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info) { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); return; } @@ -1608,7 +1608,7 @@ rte_cryptodev_callback_register(uint8_t dev_id, if (!cb_fn) return -EINVAL; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1652,7 +1652,7 @@ rte_cryptodev_callback_unregister(uint8_t dev_id, if (!cb_fn) return -EINVAL; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1720,7 +1720,7 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, uint8_t index; int ret; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1765,7 +1765,7 @@ rte_cryptodev_asym_session_init(uint8_t dev_id, uint8_t index; int ret; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1939,7 +1939,7 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, struct rte_cryptodev *dev; uint8_t driver_id; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -1969,7 +1969,7 @@ rte_cryptodev_asym_session_clear(uint8_t dev_id, { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); return -EINVAL; } @@ -2079,7 +2079,7 @@ rte_cryptodev_sym_get_private_session_size(uint8_t dev_id) struct rte_cryptodev *dev; unsigned int priv_sess_size; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + if (!rte_cryptodev_is_valid_dev(dev_id)) return 0; dev = rte_cryptodev_pmd_get_dev(dev_id); @@ -2099,7 +2099,7 @@ rte_cryptodev_asym_get_private_session_size(uint8_t dev_id) unsigned int header_size = sizeof(void *) * nb_drivers; unsigned int priv_sess_size; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + if (!rte_cryptodev_is_valid_dev(dev_id)) return 0; dev = rte_cryptodev_pmd_get_dev(dev_id); @@ -2156,7 +2156,7 @@ rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, { struct rte_cryptodev *dev; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { + if (!rte_cryptodev_is_valid_dev(dev_id)) { sym_crypto_fill_status(vec, EINVAL); return 0; } @@ -2179,7 +2179,7 @@ rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id) int32_t size = sizeof(struct rte_crypto_raw_dp_ctx); int32_t priv_size; - if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + if (!rte_cryptodev_is_valid_dev(dev_id)) return -EINVAL; dev = rte_cryptodev_pmd_get_dev(dev_id); diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 11f4e6fdbf..bb01f0f195 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -1368,6 +1368,17 @@ __rte_experimental unsigned int rte_cryptodev_asym_get_private_session_size(uint8_t dev_id); +/** + * Validate if the crypto device index is valid attached crypto device. + * + * @param dev_id Crypto device index. + * + * @return + * - If the device index is valid (1) or not (0). + */ +unsigned int +rte_cryptodev_is_valid_dev(uint8_t dev_id); + /** * Provide driver identifier. * diff --git a/lib/cryptodev/rte_cryptodev_pmd.h b/lib/cryptodev/rte_cryptodev_pmd.h index 1274436870..dd2a4940a2 100644 --- a/lib/cryptodev/rte_cryptodev_pmd.h +++ b/lib/cryptodev/rte_cryptodev_pmd.h @@ -94,17 +94,6 @@ rte_cryptodev_pmd_get_dev(uint8_t dev_id); struct rte_cryptodev * rte_cryptodev_pmd_get_named_dev(const char *name); -/** - * Validate if the crypto device index is valid attached crypto device. - * - * @param dev_id Crypto device index. - * - * @return - * - If the device index is valid (1) or not (0). - */ -unsigned int -rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id); - /** * The pool of rte_cryptodev structures. */ diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index 979d823a7c..1a7f759c57 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -25,6 +25,7 @@ DPDK_22 { rte_cryptodev_get_feature_name; rte_cryptodev_get_sec_ctx; rte_cryptodev_info_get; + rte_cryptodev_is_valid_dev; rte_cryptodev_name_get; rte_cryptodev_pmd_allocate; rte_cryptodev_pmd_callback_process; @@ -33,7 +34,6 @@ DPDK_22 { rte_cryptodev_pmd_destroy; rte_cryptodev_pmd_get_dev; rte_cryptodev_pmd_get_named_dev; - rte_cryptodev_pmd_is_valid_dev; rte_cryptodev_pmd_parse_input_args; rte_cryptodev_pmd_release_device; rte_cryptodev_queue_pair_count; diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c index e1d38d383d..2d38389858 100644 --- a/lib/eventdev/rte_event_crypto_adapter.c +++ b/lib/eventdev/rte_event_crypto_adapter.c @@ -781,7 +781,7 @@ rte_event_crypto_adapter_queue_pair_add(uint8_t id, EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL); - if (!rte_cryptodev_pmd_is_valid_dev(cdev_id)) { + if (!rte_cryptodev_is_valid_dev(cdev_id)) { RTE_EDEV_LOG_ERR("Invalid dev_id=%" PRIu8, cdev_id); return -EINVAL; } @@ -898,7 +898,7 @@ rte_event_crypto_adapter_queue_pair_del(uint8_t id, uint8_t cdev_id, EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL); - if (!rte_cryptodev_pmd_is_valid_dev(cdev_id)) { + if (!rte_cryptodev_is_valid_dev(cdev_id)) { RTE_EDEV_LOG_ERR("Invalid dev_id=%" PRIu8, cdev_id); return -EINVAL; } diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c index 594dd5e759..cb0ed7b620 100644 --- a/lib/eventdev/rte_eventdev.c +++ b/lib/eventdev/rte_eventdev.c @@ -165,7 +165,7 @@ rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id, struct rte_cryptodev *cdev; RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); - if (!rte_cryptodev_pmd_is_valid_dev(cdev_id)) + if (!rte_cryptodev_is_valid_dev(cdev_id)) return -EINVAL; dev = &rte_eventdevs[dev_id]; diff --git a/lib/pipeline/rte_table_action.c b/lib/pipeline/rte_table_action.c index 98f3438774..54721ed96a 100644 --- a/lib/pipeline/rte_table_action.c +++ b/lib/pipeline/rte_table_action.c @@ -1732,7 +1732,7 @@ struct sym_crypto_data { static int sym_crypto_cfg_check(struct rte_table_action_sym_crypto_config *cfg) { - if (!rte_cryptodev_pmd_is_valid_dev(cfg->cryptodev_id)) + if (!rte_cryptodev_is_valid_dev(cfg->cryptodev_id)) return -EINVAL; if (cfg->mp_create == NULL || cfg->mp_init == NULL) return -EINVAL;