]> git.droids-corp.org - dpdk.git/commitdiff
cryptodev: add algorithm string parsers
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Mon, 27 Feb 2017 14:38:44 +0000 (14:38 +0000)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 5 Apr 2017 22:17:44 +0000 (00:17 +0200)
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
lib/librte_cryptodev/rte_cryptodev.h
lib/librte_cryptodev/rte_cryptodev_version.map

index fedb9d09972bec5b3e430b0f2b6f4b75c60e7276..f15f65ba2a8020016d315bf5f509ef61d34ecf9a 100644 (file)
@@ -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.
index 82f3bc30c5de057c0009a60491c6d53b184d1149..d61a43eb747b335b568868b4d61ddb8c913d52c3 100644 (file)
@@ -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 }
index 238bf130004270e8d181b048f813a0c81087c8d0..831a15cabc9711d3cd6985cbed87f2e5cdb5e58f 100644 (file)
@@ -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;