From patchwork Thu Aug 5 20:02:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 96684 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 463B5A0C41; Thu, 5 Aug 2021 22:03:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31A0E4128F; Thu, 5 Aug 2021 22:03:07 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B17514128C for ; Thu, 5 Aug 2021 22:03:05 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 175K16UO012523; Thu, 5 Aug 2021 13:03:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=M7aZO5E7KNAkX0zj0SL0NrVrByclnX5WUwJnNdE0ar0=; b=dzCZDsv96sE+JXHp3DP0qAEBDA6hLgDCohTiT5jlj7BW5VFZHtcd4dnnMVP6+RN66Geu qX/3SBxwNYUm3wumW7idckjPQF3fcn9CnxjHS3aIfsAgkfuhi3TWIKkNa3iWHOKCBqqs Rkudv9epzBMHz0UNXLfMXSCEcLuf3igMma0ttAgoYLxUS3D30wVNqQSISmT2sB56jqF2 BEAt7M6vqRsc/zu/fcgSv1dyA1JyFfroXVGPjZBxvxyk9/YblILny2/tcrMbjf8OBm5J LZMNnWK2dBUU4Padj961PIvUw/kZ5N6yuxBxf1Z+EL0Kmkg9b83fmVt4EteSsoukzaNa HA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3a8ata2cky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 05 Aug 2021 13:03:00 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 5 Aug 2021 13:02:58 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 5 Aug 2021 13:02:58 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 48DF63F705D; Thu, 5 Aug 2021 13:02:53 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , Akhil Goyal Date: Fri, 6 Aug 2021 01:32:34 +0530 Message-ID: <20210805200236.1180289-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210805200236.1180289-1-gakhil@marvell.com> References: <20210805200236.1180289-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: YVt3Pyp-N2WNrJAbXAWL-pKUrm5GPqKF X-Proofpoint-GUID: YVt3Pyp-N2WNrJAbXAWL-pKUrm5GPqKF X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-08-05_10:2021-08-05, 2021-08-05 signatures=0 Subject: [dpdk-dev] [PATCH 2/4] cryptodev: change valid dev API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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: Fan Zhang --- .../net/softnic/rte_eth_softnic_cryptodev.c | 2 +- examples/fips_validation/main.c | 2 +- examples/ip_pipeline/cryptodev.c | 3 +- lib/cryptodev/rte_cryptodev.c | 50 +++++++++---------- lib/cryptodev/rte_cryptodev.h | 11 ++++ lib/cryptodev/rte_cryptodev_pmd.h | 11 ---- lib/cryptodev/version.map | 2 +- lib/eventdev/rte_event_crypto_adapter.c | 4 +- lib/eventdev/rte_eventdev.c | 2 +- lib/pipeline/rte_table_action.c | 2 +- 10 files changed, 44 insertions(+), 45 deletions(-) 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 425f459143..33aac44446 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -1358,6 +1358,17 @@ rte_cryptodev_sym_get_private_session_size(uint8_t dev_id); 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 707a2e32d3..9c1f860211 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -37,6 +37,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; @@ -45,7 +46,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;