From patchwork Tue Sep 7 19:00:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 98221 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 466ABA0C47; Tue, 7 Sep 2021 21:00:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D57141142; Tue, 7 Sep 2021 21:00:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 11E5C41100 for ; Tue, 7 Sep 2021 21:00:47 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 187HaaAc018356; Tue, 7 Sep 2021 12:00:42 -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=3nCqWEDA4dCrkEUbI0l2t+bQJseuvCKZgJEo9T7IbgY=; b=kIloz1aENNsxFHgpShGV3oDs/TqDjqmoExnmWgBvc8GjhctkqBq/7MjEraw5Ew0irnD4 xDSjtoVjTRrwM+Wnzhu7uTeWsZC1d66tgUoyfLMP51g3bK5T2wHBI5I0+gK4ITr0y8Z6 5k4GLaUUf0qYFTVMdT2Wq4eBeAlO3q8dMxszsM3clP43pU1E9PMIhmq7a5atArLt8que Jjo8TxzpCfsM6O/KHQgawJxeaY1XSL07cfzx4J5zXhuwU/YuQYBQBkzO5bCraKdxbVwy 1GQXou2xGYev+/t2x25jGy/bt55N8gic+TocB7wtDGSz1k5SL/aSgR2GB5bHbpN8y+BO zA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3axcmj8a7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 07 Sep 2021 12:00:41 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 7 Sep 2021 12:00:39 -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; Tue, 7 Sep 2021 12:00:39 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 94BAD3F7094; Tue, 7 Sep 2021 12:00:34 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , Akhil Goyal Date: Wed, 8 Sep 2021 00:30:18 +0530 Message-ID: <20210907190020.2968234-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907190020.2968234-1-gakhil@marvell.com> References: <20210810195020.1423013-1-gakhil@marvell.com> <20210907190020.2968234-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: vTrGs-Tq7dpP_tg6HRiVGuls3qtfblIS X-Proofpoint-ORIG-GUID: vTrGs-Tq7dpP_tg6HRiVGuls3qtfblIS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-07_07,2021-09-07_02,2020-04-07_01 Subject: [dpdk-dev] [PATCH v3 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 --- doc/guides/rel_notes/release_21_11.rst | 4 ++ .../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 +- 11 files changed, 48 insertions(+), 45 deletions(-) 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;