DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: declan.doherty@intel.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/4] cryptodev: add algorithm string parsers
Date: Mon, 27 Feb 2017 14:38:44 +0000	[thread overview]
Message-ID: <1488206326-70385-3-git-send-email-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <1488206326-70385-1-git-send-email-pablo.de.lara.guarch@intel.com>

Adds functions to get the cipher/authentication
algorithm enums, given a string. This is useful for applications
which gets the algorithm required from the user, to have a common
string-enum mapping.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/librte_cryptodev/rte_cryptodev.c           | 34 ++++++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 30 +++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  8 ++++++
 3 files changed, 72 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index fedb9d0..f15f65b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -187,6 +187,40 @@ rte_crypto_auth_algorithm_strings[] = {
 	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3"
 };
 
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+		const char *algo_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_cipher_algorithm_strings); i++) {
+		if (strcmp(algo_string, rte_crypto_cipher_algorithm_strings[i]) == 0) {
+			*algo_enum = (enum rte_crypto_cipher_algorithm) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+		const char *algo_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_auth_algorithm_strings); i++) {
+		if (strcmp(algo_string, rte_crypto_auth_algorithm_strings[i]) == 0) {
+			*algo_enum = (enum rte_crypto_auth_algorithm) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
 /**
  * The crypto auth operation strings identifiers.
  * It could be used in application command line.
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 82f3bc3..d61a43e 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -234,6 +234,36 @@ rte_cryptodev_sym_capability_check_auth(
 		const struct rte_cryptodev_symmetric_capability *capability,
 		uint16_t key_size, uint16_t digest_size, uint16_t aad_size);
 
+/**
+ * Provide the cipher algorithm enum, given an algorithm string
+ *
+ * @param	algo_enum	A pointer to the cipher algorithm
+ *				enum to be filled
+ * @param	algo_string	Authentication algo string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 is the string is valid
+ */
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+		const char *algo_string);
+
+/**
+ * Provide the authentication algorithm enum, given an algorithm string
+ *
+ * @param	algo_enum	A pointer to the authentication algorithm
+ *				enum to be filled
+ * @param	algo_string	Authentication algo string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 is the string is valid
+ */
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+		const char *algo_string);
+
 /** Macro used at end of crypto PMD list */
 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
 	{ RTE_CRYPTO_OP_TYPE_UNDEFINED }
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 238bf13..831a15c 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -64,3 +64,11 @@ DPDK_17.02 {
 	rte_crypto_cipher_operation_strings;
 
 } DPDK_16.11;
+
+DPDK_17.05 {
+	global:
+
+	rte_cryptodev_get_auth_algo_enum;
+	rte_cryptodev_get_cipher_algo_enum;
+
+} DPDK_17.02;
-- 
2.7.4

  parent reply	other threads:[~2017-02-27 14:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 12:33 [dpdk-dev] [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 1/4] cryptodev: add missing algorithm strings Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 2/4] cryptodev: add algorithm string parsers Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 4/4] examples/l2fwd-crypto: " Pablo de Lara
2017-02-24 15:41 ` [dpdk-dev] [PATCH 0/4] New crypto algorithm string parser API Trahe, Fiona
2017-02-25 11:18   ` Hemant Agrawal
2017-02-27 14:38 ` [dpdk-dev] [PATCH v2 " Pablo de Lara
2017-02-27 14:38   ` [dpdk-dev] [PATCH v2 1/4] cryptodev: add missing algorithm strings Pablo de Lara
2017-02-27 14:38   ` Pablo de Lara [this message]
2017-02-27 14:38   ` [dpdk-dev] [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
2017-02-27 14:38   ` [dpdk-dev] [PATCH v2 4/4] examples/l2fwd-crypto: " Pablo de Lara
2017-02-28 14:18   ` [dpdk-dev] [PATCH v2 0/4] New crypto algorithm string parser API De Lara Guarch, Pablo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1488206326-70385-3-git-send-email-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).