From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 8FFAC5A44 for ; Wed, 11 Jan 2017 16:22:21 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 11 Jan 2017 07:21:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,346,1477983600"; d="scan'208";a="1111113512" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by fmsmga002.fm.intel.com with ESMTP; 11 Jan 2017 07:21:47 -0800 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.112]) by IRSMSX107.ger.corp.intel.com ([169.254.10.3]) with mapi id 14.03.0248.002; Wed, 11 Jan 2017 15:21:46 +0000 From: "Trahe, Fiona" To: "Mrozowicz, SlawomirX" , "dev@dpdk.org" CC: "Mrozowicz, SlawomirX" , "Doherty, Declan" , "Kerlin, Marcin" , "Trahe, Fiona" Thread-Topic: [dpdk-dev] [PATCH v3 1/2] cryptodev: add functions to retrieve device info Thread-Index: AQHSbBSBJo3j+dzP0UGuIjqxW6sc1aEzYNFA Date: Wed, 11 Jan 2017 15:21:45 +0000 Message-ID: <348A99DA5F5B7549AA880327E580B4358916A74F@IRSMSX101.ger.corp.intel.com> References: <1483635001-15473-1-git-send-email-slawomirx.mrozowicz@intel.com> <1484150829-20734-1-git-send-email-slawomirx.mrozowicz@intel.com> <1484150829-20734-2-git-send-email-slawomirx.mrozowicz@intel.com> In-Reply-To: <1484150829-20734-2-git-send-email-slawomirx.mrozowicz@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjdlYWI1M2MtOWNhZC00M2ZlLWEzZDUtN2M3NTI0MDRkYmY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Imxnamp5UStkNzFIdkxLYkdZU2diQW1CTmhHYjZpWjdBdmpiNjV3bTByMWc9In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 1/2] cryptodev: add functions to retrieve device info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2017 15:22:22 -0000 Hi Slawomir > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Slawomir Mrozowicz > Sent: Wednesday, January 11, 2017 4:07 PM > To: dev@dpdk.org > Cc: Mrozowicz, SlawomirX ; Doherty, > Declan ; Kerlin, Marcin > > Subject: [dpdk-dev] [PATCH v3 1/2] cryptodev: add functions to retrieve d= evice > info >=20 > This patch adds helper functions for new performance application which > provide identifiers and number of crypto device and > provide and check capabilities available for defined device and algorithm= . > The performance application can be used to measure throughput and latency > of cryptography operation performed by crypto device. >=20 > Signed-off-by: Declan Doherty > Signed-off-by: Slawomir Mrozowicz > Signed-off-by: Marcin Kerlin > --- > To be applied on top of: > [dpdk-dev,v4] crypto/aesni_gcm: migration from MB library to ISA-L >=20 > v2 changes: > - code style fix > - add information in version.map about changes >=20 > v3 changes: > - title of the cryptodev patch > - supply information in version.map about changes > --- > lib/librte_cryptodev/rte_crypto_sym.h | 16 +++ > lib/librte_cryptodev/rte_cryptodev.c | 181 > +++++++++++++++++++++++++ > lib/librte_cryptodev/rte_cryptodev.h | 120 +++++++++------- > lib/librte_cryptodev/rte_cryptodev_version.map | 14 ++ > 4 files changed, 285 insertions(+), 46 deletions(-) >=20 > diff --git a/lib/librte_cryptodev/rte_crypto_sym.h > b/lib/librte_cryptodev/rte_crypto_sym.h > index 0e20b30..c782588 100644 > --- a/lib/librte_cryptodev/rte_crypto_sym.h > +++ b/lib/librte_cryptodev/rte_crypto_sym.h > @@ -112,6 +112,10 @@ enum rte_crypto_cipher_algorithm { >=20 > }; >=20 > +/** Cipher algorithm name strings */ > +extern const char * > +rte_crypto_cipher_algorithm_strings[]; > + > /** Symmetric Cipher Direction */ > enum rte_crypto_cipher_operation { > RTE_CRYPTO_CIPHER_OP_ENCRYPT, > @@ -120,6 +124,10 @@ enum rte_crypto_cipher_operation { > /**< Decrypt cipher operation */ > }; >=20 > +/** Cipher operation name strings */ > +extern const char * > +rte_crypto_cipher_operation_strings[]; > + > /** > * Symmetric Cipher Setup Data. > * > @@ -245,12 +253,20 @@ enum rte_crypto_auth_algorithm { > RTE_CRYPTO_AUTH_LIST_END > }; >=20 > +/** Authentication algorithm name strings */ > +extern const char * > +rte_crypto_auth_algorithm_strings[]; > + > /** Symmetric Authentication / Hash Operations */ > enum rte_crypto_auth_operation { > RTE_CRYPTO_AUTH_OP_VERIFY, /**< Verify authentication > digest */ > RTE_CRYPTO_AUTH_OP_GENERATE /**< Generate authentication > digest */ > }; >=20 > +/** Authentication operation name strings */ > +extern const char * > +rte_crypto_auth_operation_strings[]; > + > /** > * Authentication / Hash transform data. > * > diff --git a/lib/librte_cryptodev/rte_cryptodev.c > b/lib/librte_cryptodev/rte_cryptodev.c > index bbab4b3..c126b1b 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -111,6 +111,86 @@ static const char *cryptodev_vdev_valid_params[] =3D > { > RTE_CRYPTODEV_VDEV_SOCKET_ID > }; >=20 > +/** > + * The crypto cipher algorithm strings identifiers. > + * It could be used in application command line. > + */ > +const char * > +rte_crypto_cipher_algorithm_strings[] =3D { > + [RTE_CRYPTO_CIPHER_3DES_CBC] =3D "3des-cbc", > + [RTE_CRYPTO_CIPHER_3DES_ECB] =3D "3des-ecb", > + [RTE_CRYPTO_CIPHER_3DES_CTR] =3D "3des-ctr", > + > + [RTE_CRYPTO_CIPHER_AES_CBC] =3D "aes-cbc", > + [RTE_CRYPTO_CIPHER_AES_CCM] =3D "aes-ccm", > + [RTE_CRYPTO_CIPHER_AES_CTR] =3D "aes-ctr", > + [RTE_CRYPTO_CIPHER_AES_ECB] =3D "aes-ecb", > + [RTE_CRYPTO_CIPHER_AES_GCM] =3D "aes-gcm", > + [RTE_CRYPTO_CIPHER_AES_F8] =3D "aes-f8", > + [RTE_CRYPTO_CIPHER_AES_XTS] =3D "aes-xts", > + > + [RTE_CRYPTO_CIPHER_ARC4] =3D "arc4", > + > + [RTE_CRYPTO_CIPHER_NULL] =3D "null", > + > + [RTE_CRYPTO_CIPHER_KASUMI_F8] =3D "kasumi-f8", > + [RTE_CRYPTO_CIPHER_SNOW3G_UEA2] =3D "snow3g-uea2", > + [RTE_CRYPTO_CIPHER_ZUC_EEA3] =3D "zuc-eea3" > +}; > + > +/** > + * The crypto cipher operation strings identifiers. > + * It could be used in application command line. > + */ > +const char * > +rte_crypto_cipher_operation_strings[] =3D { > + [RTE_CRYPTO_CIPHER_OP_ENCRYPT] =3D "encrypt", > + [RTE_CRYPTO_CIPHER_OP_DECRYPT] =3D "decrypt" > +}; > + > +/** > + * The crypto auth algorithm strings identifiers. > + * It could be used in application command line. > + */ > +const char * > +rte_crypto_auth_algorithm_strings[] =3D { > + [RTE_CRYPTO_AUTH_AES_CBC_MAC] =3D "aes-cbc-mac", > + [RTE_CRYPTO_AUTH_AES_CCM] =3D "aes-ccm", > + [RTE_CRYPTO_AUTH_AES_CMAC] =3D "aes-cmac", > + [RTE_CRYPTO_AUTH_AES_GCM] =3D "aes-gcm", > + [RTE_CRYPTO_AUTH_AES_GMAC] =3D "aes-gmac", > + [RTE_CRYPTO_AUTH_AES_XCBC_MAC] =3D "aes-xcbc-mac", > + > + [RTE_CRYPTO_AUTH_MD5] =3D "md5", > + [RTE_CRYPTO_AUTH_MD5_HMAC] =3D "md5-hmac", > + > + [RTE_CRYPTO_AUTH_SHA1] =3D "sha1", > + [RTE_CRYPTO_AUTH_SHA1_HMAC] =3D "sha1-hmac", > + > + [RTE_CRYPTO_AUTH_SHA224] =3D "sha2-224", > + [RTE_CRYPTO_AUTH_SHA224_HMAC] =3D "sha2-224-hmac", > + [RTE_CRYPTO_AUTH_SHA256] =3D "sha2-256", > + [RTE_CRYPTO_AUTH_SHA256_HMAC] =3D "sha2-256-hmac", > + [RTE_CRYPTO_AUTH_SHA384] =3D "sha2-384", > + [RTE_CRYPTO_AUTH_SHA384_HMAC] =3D "sha2-384-hmac", > + [RTE_CRYPTO_AUTH_SHA512] =3D "sha2-512", > + [RTE_CRYPTO_AUTH_SHA512_HMAC] =3D "sha2-512-hmac", > + > + [RTE_CRYPTO_AUTH_KASUMI_F9] =3D "kasumi-f9", > + [RTE_CRYPTO_AUTH_SNOW3G_UIA2] =3D "snow3g-uia2", > + [RTE_CRYPTO_AUTH_ZUC_EIA3] =3D "zuc-eia3" > +}; > + > +/** > + * The crypto auth operation strings identifiers. > + * It could be used in application command line. > + */ > +const char * > +rte_crypto_auth_operation_strings[] =3D { > + [RTE_CRYPTO_AUTH_OP_VERIFY] =3D "verify", > + [RTE_CRYPTO_AUTH_OP_GENERATE] =3D "generate" > +}; > + > static uint8_t > number_of_sockets(void) > { > @@ -191,6 +271,73 @@ rte_cryptodev_parse_vdev_init_params(struct > rte_crypto_vdev_init_params *params, > return ret; > } >=20 > +const struct rte_cryptodev_symmetric_capability * > +rte_cryptodev_capability_get(uint8_t dev_id, > + const struct rte_cryptodev_capability_idx *idx) It would be better to call this rte_cryptodev_sym_capability_get() to allow= for other capability types in future. OR pass in rte_crypto_op_type as a p= arameter or in the idx struct. > +{ > + const struct rte_cryptodev_capabilities *capability; > + struct rte_cryptodev_info dev_info; > + int i =3D 0; > + > + rte_cryptodev_info_get(dev_id, &dev_info); > + > + while ((capability =3D &dev_info.capabilities[i++])->op !=3D > + RTE_CRYPTO_OP_TYPE_UNDEFINED) { > + if (capability->op !=3D RTE_CRYPTO_OP_TYPE_SYMMETRIC) > + continue; > + > + if (capability->sym.xform_type !=3D idx->type) > + continue; > + > + if (idx->type =3D=3D RTE_CRYPTO_SYM_XFORM_AUTH && > + capability->sym.auth.algo =3D=3D idx->algo.auth) > + return &capability->sym; > + > + if (idx->type =3D=3D RTE_CRYPTO_SYM_XFORM_CIPHER && > + capability->sym.cipher.algo =3D=3D idx->algo.cipher) > + return &capability->sym; > + } > + > + return NULL; > + > +} > + > +#define param_range_check(x, y) \ > + (((x < y.min) || (x > y.max)) || \ > + (y.increment !=3D 0 && (x % y.increment) !=3D 0)) > + > +int > +rte_cryptodev_capability_check_cipher( > + const struct rte_cryptodev_symmetric_capability *capability, > + uint16_t key_size, uint16_t iv_size) > +{ > + if (param_range_check(key_size, capability->cipher.key_size)) > + return -1; > + > + if (param_range_check(iv_size, capability->cipher.iv_size)) > + return -1; > + > + return 0; > +} > + > +int > +rte_cryptodev_capability_check_auth( > + const struct rte_cryptodev_symmetric_capability *capability, > + uint16_t key_size, uint16_t digest_size, uint16_t aad_size) > +{ > + if (param_range_check(key_size, capability->auth.key_size)) > + return -1; > + > + if (param_range_check(digest_size, capability->auth.digest_size)) > + return -1; > + > + if (param_range_check(aad_size, capability->auth.aad_size)) > + return -1; > + > + return 0; > +} > + > + > const char * > rte_cryptodev_get_feature_name(uint64_t flag) > { > @@ -263,6 +410,40 @@ rte_cryptodev_count_devtype(enum > rte_cryptodev_type type) > } >=20 > int > +rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices, > + uint8_t nb_devices) > +{ > + uint8_t i, cmp, count =3D 0; > + struct rte_cryptodev **devs =3D &rte_cryptodev_globals->devs; > + struct rte_pci_device *pci; > + > + for (i =3D 0; i < rte_cryptodev_globals->max_devs && count < > nb_devices; > + i++) { > + > + if ((*devs + i) > + && (*devs + i)->attached =3D=3D > + RTE_CRYPTODEV_ATTACHED) > { > + > + pci =3D (*devs + i)->pci_dev; > + > + if (pci) > + cmp =3D strncmp(pci->driver->driver.name, > + dev_name, > + strlen(dev_name)); > + else > + cmp =3D strncmp((*devs + i)->data->name, > + dev_name, > + strlen(dev_name)); > + > + if (cmp =3D=3D 0) > + devices[count++] =3D (*devs + i)->data->dev_id; > + } > + } > + > + return count; > +} > + > +int > rte_cryptodev_socket_id(uint8_t dev_id) > { > struct rte_cryptodev *dev; > diff --git a/lib/librte_cryptodev/rte_cryptodev.h > b/lib/librte_cryptodev/rte_cryptodev.h > index fa311a9..97d1a86 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.h > +++ b/lib/librte_cryptodev/rte_cryptodev.h > @@ -76,7 +76,7 @@ enum rte_cryptodev_type { > RTE_CRYPTODEV_SNOW3G_PMD, /**< SNOW 3G PMD */ > RTE_CRYPTODEV_KASUMI_PMD, /**< KASUMI PMD */ > RTE_CRYPTODEV_ZUC_PMD, /**< ZUC PMD */ > - RTE_CRYPTODEV_OPENSSL_PMD, /**< OpenSSL PMD */ > + RTE_CRYPTODEV_OPENSSL_PMD, /**< OpenSSL PMD */ > }; >=20 > extern const char **rte_cyptodev_names; > @@ -110,6 +110,20 @@ extern const char **rte_cyptodev_names; > #endif >=20 > /** > + * Crypto parameters range description > + */ > +struct rte_crypto_param_range { > + uint16_t min; /**< minimum size */ > + uint16_t max; /**< maximum size */ > + uint16_t increment; > + /**< if a range of sizes are supported, > + * this parameter is used to indicate > + * increments in byte size that are supported > + * between the minimum and maximum > + */ > +}; > + > +/** > * Symmetric Crypto Capability > */ > struct rte_cryptodev_symmetric_capability { > @@ -122,35 +136,11 @@ struct rte_cryptodev_symmetric_capability { > /**< authentication algorithm */ > uint16_t block_size; > /**< algorithm block size */ > - struct { > - uint16_t min; /**< minimum key size */ > - uint16_t max; /**< maximum key size */ > - uint16_t increment; > - /**< if a range of sizes are supported, > - * this parameter is used to indicate > - * increments in byte size that are supported > - * between the minimum and maximum */ > - } key_size; > + struct rte_crypto_param_range key_size; > /**< auth key size range */ > - struct { > - uint16_t min; /**< minimum digest size */ > - uint16_t max; /**< maximum digest size */ > - uint16_t increment; > - /**< if a range of sizes are supported, > - * this parameter is used to indicate > - * increments in byte size that are supported > - * between the minimum and maximum */ > - } digest_size; > + struct rte_crypto_param_range digest_size; > /**< digest size range */ > - struct { > - uint16_t min; /**< minimum aad size */ > - uint16_t max; /**< maximum aad size */ > - uint16_t increment; > - /**< if a range of sizes are supported, > - * this parameter is used to indicate > - * increments in byte size that are supported > - * between the minimum and maximum */ > - } aad_size; > + struct rte_crypto_param_range aad_size; > /**< Additional authentication data size range */ > } auth; > /**< Symmetric Authentication transform capabilities */ > @@ -159,25 +149,9 @@ struct rte_cryptodev_symmetric_capability { > /**< cipher algorithm */ > uint16_t block_size; > /**< algorithm block size */ > - struct { > - uint16_t min; /**< minimum key size */ > - uint16_t max; /**< maximum key size */ > - uint16_t increment; > - /**< if a range of sizes are supported, > - * this parameter is used to indicate > - * increments in byte size that are supported > - * between the minimum and maximum */ > - } key_size; > + struct rte_crypto_param_range key_size; > /**< cipher key size range */ > - struct { > - uint16_t min; /**< minimum iv size */ > - uint16_t max; /**< maximum iv size */ > - uint16_t increment; > - /**< if a range of sizes are supported, > - * this parameter is used to indicate > - * increments in byte size that are supported > - * between the minimum and maximum */ > - } iv_size; > + struct rte_crypto_param_range iv_size; > /**< Initialisation vector data size range */ > } cipher; > /**< Symmetric Cipher transform capabilities */ > @@ -196,6 +170,38 @@ struct rte_cryptodev_capabilities { > }; > }; >=20 > +/** Structure used to describe crypto algorithms */ > +struct rte_cryptodev_capability_idx { This should also have _sym_ in the name. OR add the op into this structure. > + enum rte_crypto_sym_xform_type type; > + union { > + enum rte_crypto_cipher_algorithm cipher; > + enum rte_crypto_auth_algorithm auth; > + } algo; > +}; > + > +/** Provide capabilities available for defined device and algorithm */ > +const struct rte_cryptodev_symmetric_capability * > +rte_cryptodev_capability_get(uint8_t dev_id, > + const struct rte_cryptodev_capability_idx *idx); > + > +/** > + * Check if key size and initial vector are supported > + * in crypto cipher capability > + */ > +int > +rte_cryptodev_capability_check_cipher( > + const struct rte_cryptodev_symmetric_capability *capability, > + uint16_t key_size, uint16_t iv_size); > + > +/** > + * Check if key size and initial vector are supported > + * in crypto auth capability > + */ > +int > +rte_cryptodev_capability_check_auth( > + const struct rte_cryptodev_symmetric_capability *capability, > + uint16_t key_size, uint16_t digest_size, uint16_t aad_size); > + > /** Macro used at end of crypto PMD list */ > #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \ > { RTE_CRYPTO_OP_TYPE_UNDEFINED } > @@ -369,8 +375,30 @@ rte_cryptodev_get_dev_id(const char *name); > extern uint8_t > rte_cryptodev_count(void); >=20 > +/** > + * Get number of crypto device defined type. > + * > + * @param type type of device. > + * > + * @return > + * Returns number of crypto device. > + */ > extern uint8_t > rte_cryptodev_count_devtype(enum rte_cryptodev_type type); > + > +/** > + * Get number and identifiers of attached crypto device. > + * > + * @param dev_name device name. > + * @param devices output devices identifiers. > + * @param nb_devices maximal number of devices. > + * > + * @return > + * Returns number of attached crypto device. > + */ > +int > +rte_cryptodev_devices_get(const char *dev_name, uint8_t *devices, > + uint8_t nb_devices); > /* > * Return the NUMA socket to which a device is connected > * > diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map > b/lib/librte_cryptodev/rte_cryptodev_version.map > index 9dde0e7..bdd5e5d 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_version.map > +++ b/lib/librte_cryptodev/rte_cryptodev_version.map > @@ -46,3 +46,17 @@ DPDK_16.11 { > rte_cryptodev_pci_remove; >=20 > } DPDK_16.07; > + > +DPDK_17.02 { > + global: > + > + rte_cryptodev_capability_check_auth; > + rte_cryptodev_capability_check_cipher; > + rte_cryptodev_capability_get; > + rte_cryptodev_devices_get; > + rte_crypto_auth_algorithm_strings; > + rte_crypto_auth_operation_strings; > + rte_crypto_cipher_algorithm_strings; > + rte_crypto_cipher_operation_strings; > + > +} DPDK_16.11; > -- > 2.5.0