cryptodev: add feature flags to disable

Adding a new field, ff_disable, to allow applications to control the
features enabled on the crypto device. This would allow for efficient
usage of HW/SW offloads.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
This commit is contained in:
Anoob Joseph 2019-06-25 11:09:24 +05:30 committed by Akhil Goyal
parent 5f2ea5533a
commit c9030ae382
15 changed files with 36 additions and 20 deletions

View File

@ -200,7 +200,8 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
} }
struct rte_cryptodev_config conf = { struct rte_cryptodev_config conf = {
.nb_queue_pairs = opts->nb_qps, .nb_queue_pairs = opts->nb_qps,
.socket_id = socket_id .socket_id = socket_id,
.ff_disable = RTE_CRYPTODEV_FF_SECURITY,
}; };
struct rte_cryptodev_qp_conf qp_conf = { struct rte_cryptodev_qp_conf qp_conf = {

View File

@ -430,6 +430,7 @@ testsuite_setup(void)
ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs; ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
ts_params->conf.socket_id = SOCKET_ID_ANY; ts_params->conf.socket_id = SOCKET_ID_ANY;
ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
unsigned int session_size = unsigned int session_size =
rte_cryptodev_sym_get_private_session_size(dev_id); rte_cryptodev_sym_get_private_session_size(dev_id);
@ -524,6 +525,7 @@ ut_setup(void)
/* Reconfigure device to default parameters */ /* Reconfigure device to default parameters */
ts_params->conf.socket_id = SOCKET_ID_ANY; ts_params->conf.socket_id = SOCKET_ID_ANY;
ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
ts_params->qp_conf.mp_session = ts_params->session_mpool; ts_params->qp_conf.mp_session = ts_params->session_mpool;
ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool; ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;

View File

@ -548,6 +548,7 @@ configure_cryptodev(void)
rte_cryptodev_info_get(TEST_CDEV_ID, &info); rte_cryptodev_info_get(TEST_CDEV_ID, &info);
conf.nb_queue_pairs = info.max_nb_queue_pairs; conf.nb_queue_pairs = info.max_nb_queue_pairs;
conf.socket_id = SOCKET_ID_ANY; conf.socket_id = SOCKET_ID_ANY;
conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(TEST_CDEV_ID, &conf), TEST_ASSERT_SUCCESS(rte_cryptodev_configure(TEST_CDEV_ID, &conf),
"Failed to configure cryptodev %u with %u qps\n", "Failed to configure cryptodev %u with %u qps\n",

View File

@ -342,6 +342,7 @@ testsuite_setup(void)
ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs; ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
ts_params->conf.socket_id = SOCKET_ID_ANY; ts_params->conf.socket_id = SOCKET_ID_ANY;
ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
sess_sz = rte_cryptodev_sym_get_private_session_size(dev_id); sess_sz = rte_cryptodev_sym_get_private_session_size(dev_id);
sess_sz = RTE_MAX(sess_sz, sizeof(struct rte_security_session)); sess_sz = RTE_MAX(sess_sz, sizeof(struct rte_security_session));

View File

@ -59,20 +59,6 @@ Deprecation Notices
Target release for removal of the legacy API will be defined once most Target release for removal of the legacy API will be defined once most
PMDs have switched to rte_flow. PMDs have switched to rte_flow.
* cryptodev: New member in ``rte_cryptodev_config`` to allow applications to
disable features supported by the crypto device. Only the following features
would be allowed to be disabled this way,
- ``RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO``
- ``RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO``
- ``RTE_CRYPTODEV_FF_SECURITY``
Disabling unused features would facilitate efficient usage of HW/SW offload.
- Member ``uint64_t ff_disable`` in ``rte_cryptodev_config``
The field would be added in v19.08.
* cryptodev: the ``uint8_t *data`` member of ``key`` structure in the xforms * cryptodev: the ``uint8_t *data`` member of ``key`` structure in the xforms
structure (``rte_crypto_cipher_xform``, ``rte_crypto_auth_xform``, and structure (``rte_crypto_cipher_xform``, ``rte_crypto_auth_xform``, and
``rte_crypto_aead_xform``) will be changed to ``const uint8_t *data``. ``rte_crypto_aead_xform``) will be changed to ``const uint8_t *data``.

View File

@ -236,6 +236,16 @@ ABI Changes
Add a Rx adapter stats field to keep track of the total Add a Rx adapter stats field to keep track of the total
number of dropped packets. number of dropped packets.
* cryptodev: New member in ``rte_cryptodev_config`` to allow applications to
disable features supported by the crypto device. Only the following features
would be allowed to be disabled this way,
- ``RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO``
- ``RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO``
- ``RTE_CRYPTODEV_FF_SECURITY``
Disabling unused features would facilitate efficient usage of HW/SW offload.
Shared Library Versions Shared Library Versions
----------------------- -----------------------
@ -267,7 +277,7 @@ The libraries prepended with a plus sign were incremented in this version.
librte_cfgfile.so.2 librte_cfgfile.so.2
librte_cmdline.so.2 librte_cmdline.so.2
librte_compressdev.so.1 librte_compressdev.so.1
librte_cryptodev.so.7 + librte_cryptodev.so.8
librte_distributor.so.1 librte_distributor.so.1
+ librte_eal.so.11 + librte_eal.so.11
librte_efd.so.1 librte_efd.so.1

View File

@ -1557,12 +1557,16 @@ fips_dev_auto_test_uninit(uint8_t dev_id,
static int static int
fips_dev_auto_test_init(uint8_t dev_id, struct fips_dev_auto_test_env *env) fips_dev_auto_test_init(uint8_t dev_id, struct fips_dev_auto_test_env *env)
{ {
struct rte_cryptodev_config conf = {rte_cryptodev_socket_id(dev_id), 1};
struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL}; struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL};
uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size(dev_id); uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size(dev_id);
struct rte_cryptodev_config conf;
char name[128]; char name[128];
int ret; int ret;
conf.socket_id = rte_cryptodev_socket_id(dev_id);
conf.nb_queue_pairs = 1;
conf.ff_disable = 0;
ret = rte_cryptodev_configure(dev_id, &conf); ret = rte_cryptodev_configure(dev_id, &conf);
if (ret < 0) if (ret < 0)
return ret; return ret;

View File

@ -48,7 +48,7 @@ struct cryptodev_fips_validate_env {
static int static int
cryptodev_fips_validate_app_int(void) cryptodev_fips_validate_app_int(void)
{ {
struct rte_cryptodev_config conf = {rte_socket_id(), 1}; struct rte_cryptodev_config conf = {rte_socket_id(), 1, 0};
struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL}; struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL};
uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size( uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size(
env.dev_id); env.dev_id);

View File

@ -95,6 +95,7 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
dev_conf.socket_id = socket_id; dev_conf.socket_id = socket_id;
dev_conf.nb_queue_pairs = params->n_queues; dev_conf.nb_queue_pairs = params->n_queues;
dev_conf.ff_disable = 0;
status = rte_cryptodev_configure(dev_id, &dev_conf); status = rte_cryptodev_configure(dev_id, &dev_conf);
if (status < 0) if (status < 0)

View File

@ -1720,6 +1720,7 @@ cryptodevs_init(void)
dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id); dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
dev_conf.nb_queue_pairs = qp; dev_conf.nb_queue_pairs = qp;
dev_conf.ff_disable = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
uint32_t dev_max_sess = cdev_info.sym.max_nb_sessions; uint32_t dev_max_sess = cdev_info.sym.max_nb_sessions;
if (dev_max_sess != 0 && dev_max_sess < CDEV_MP_NB_OBJS) if (dev_max_sess != 0 && dev_max_sess < CDEV_MP_NB_OBJS)

View File

@ -2256,6 +2256,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
struct rte_cryptodev_config conf = { struct rte_cryptodev_config conf = {
.nb_queue_pairs = 1, .nb_queue_pairs = 1,
.socket_id = socket_id, .socket_id = socket_id,
.ff_disable = RTE_CRYPTODEV_FF_SECURITY,
}; };
rte_cryptodev_info_get(cdev_id, &dev_info); rte_cryptodev_info_get(cdev_id, &dev_info);

View File

@ -516,6 +516,7 @@ main(int argc, char *argv[])
config.nb_queue_pairs = dev_info.max_nb_queue_pairs; config.nb_queue_pairs = dev_info.max_nb_queue_pairs;
config.socket_id = rte_lcore_to_socket_id(lo->lcore_id); config.socket_id = rte_lcore_to_socket_id(lo->lcore_id);
config.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
ret = rte_cryptodev_configure(info->cid, &config); ret = rte_cryptodev_configure(info->cid, &config);
if (ret < 0) { if (ret < 0) {

View File

@ -7,7 +7,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
LIB = librte_cryptodev.a LIB = librte_cryptodev.a
# library version # library version
LIBABIVER := 7 LIBABIVER := 8
# build flags # build flags
CFLAGS += -O3 CFLAGS += -O3

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2019 Intel Corporation # Copyright(c) 2017-2019 Intel Corporation
version = 7 version = 8
allow_experimental_apis = true allow_experimental_apis = true
sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c') sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c')
headers = files('rte_cryptodev.h', headers = files('rte_cryptodev.h',

View File

@ -616,6 +616,13 @@ struct rte_cryptodev_config {
int socket_id; /**< Socket to allocate resources on */ int socket_id; /**< Socket to allocate resources on */
uint16_t nb_queue_pairs; uint16_t nb_queue_pairs;
/**< Number of queue pairs to configure on device */ /**< Number of queue pairs to configure on device */
uint64_t ff_disable;
/**< Feature flags to be disabled. Only the following features are
* allowed to be disabled,
* - RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO
* - RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO
* - RTE_CRYTPODEV_FF_SECURITY
*/
}; };
/** /**