/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2015-2020 Intel Corporation
+ * Copyright 2020 NXP
*/
#include <time.h>
#include <rte_cryptodev_pmd.h>
#include <rte_string_fns.h>
-#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+#ifdef RTE_CRYPTO_SCHEDULER
#include <rte_cryptodev_scheduler.h>
#include <rte_cryptodev_scheduler_operations.h>
#endif
#include "test_cryptodev_aead_test_vectors.h"
#include "test_cryptodev_hmac_test_vectors.h"
#include "test_cryptodev_mixed_test_vectors.h"
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
#include "test_cryptodev_security_pdcp_test_vectors.h"
+#include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
#include "test_cryptodev_security_pdcp_test_func.h"
#include "test_cryptodev_security_docsis_test_vectors.h"
+
+#define SDAP_DISABLED 0
+#define SDAP_ENABLED 1
#endif
#define VDEV_ARGS_SIZE 100
#define IN_PLACE 0
#define OUT_OF_PLACE 1
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
static int gbl_driver_id;
static enum rte_security_session_action_type gbl_action_type =
struct rte_crypto_sym_xform cipher_xform;
struct rte_crypto_sym_xform auth_xform;
struct rte_crypto_sym_xform aead_xform;
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
struct rte_security_docsis_xform docsis_xform;
#endif
union {
struct rte_cryptodev_sym_session *sess;
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
struct rte_security_session *sec_session;
#endif
};
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
enum rte_security_session_action_type type;
#endif
struct rte_crypto_op *op;
}
}
-#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+#ifdef RTE_CRYPTO_SCHEDULER
char vdev_args[VDEV_ARGS_SIZE] = {""};
char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
"ordering=enable,name=cryptodev_test_scheduler,corelist="};
/* Identify the Worker Cores
* Use 2 worker cores for the device args
*/
- RTE_LCORE_FOREACH_SLAVE(i) {
+ RTE_LCORE_FOREACH_WORKER(i) {
if (worker_core_count > 1)
break;
snprintf(vdev_args, sizeof(vdev_args),
i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
}
}
-#endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
+#endif /* RTE_CRYPTO_SCHEDULER */
nb_devs = rte_cryptodev_count();
if (nb_devs < 1) {
unsigned int session_size =
rte_cryptodev_sym_get_private_session_size(dev_id);
+#ifdef RTE_LIB_SECURITY
+ unsigned int security_session_size = rte_security_session_get_size(
+ rte_cryptodev_get_sec_ctx(dev_id));
+
+ if (session_size < security_session_size)
+ session_size = security_session_size;
+#endif
/*
- * Create mempool with maximum number of sessions * 2,
- * to include the session headers
+ * Create mempool with maximum number of sessions.
*/
if (info.sym.max_nb_sessions != 0 &&
info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
struct rte_cryptodev_stats stats;
/* free crypto session structure */
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
if (ut_params->sec_session) {
rte_security_session_destroy(rte_cryptodev_get_sec_ctx
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Create KASUMI session */
retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
RTE_CRYPTO_CIPHER_OP_ENCRYPT,
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Create KASUMI session */
retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
RTE_CRYPTO_CIPHER_OP_ENCRYPT,
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Create KASUMI session */
retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
RTE_CRYPTO_CIPHER_OP_DECRYPT,
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Create SNOW 3G session */
retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
RTE_CRYPTO_CIPHER_OP_ENCRYPT,
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Create SNOW 3G session */
retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
RTE_CRYPTO_CIPHER_OP_ENCRYPT,
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Create SNOW 3G session */
retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
RTE_CRYPTO_CIPHER_OP_DECRYPT,
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Check if device supports ZUC EEA3 */
cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
&cap_idx) == NULL)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
&cap_idx) == NULL)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
if (op_mode == OUT_OF_PLACE) {
if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
return -ENOTSUP;
&cap_idx) == NULL)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Verify the capabilities */
struct rte_cryptodev_sym_capability_idx cap_idx;
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
struct rte_cryptodev_sym_capability_idx cap_idx;
/* Check if device supports ZUC EEA3 */
&cap_idx) == NULL)
return -ENOTSUP;
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
uint64_t feat_flags = dev_info.feature_flags;
return -ENOTSUP;
}
+ if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
+ return -ENOTSUP;
+
/* Check if device supports ZUC EIA3 */
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
unsigned int ciphertext_len;
struct rte_cryptodev_info dev_info;
+ struct rte_crypto_op *op;
/* Check if device supports particular algorithms separately */
if (test_mixed_check_if_unsupported(tdata))
return -ENOTSUP;
}
- if (op_mode == OUT_OF_PLACE)
- return -ENOTSUP;
-
/* Create the session */
if (verify)
retval = create_wireless_algo_cipher_auth_session(
if (retval < 0)
return retval;
- ut_params->op = process_crypto_request(ts_params->valid_devs[0],
- ut_params->op);
+ op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
/* Check if the op failed because the device doesn't */
/* support this particular combination of algorithms */
- if (ut_params->op == NULL && ut_params->op->status ==
+ if (op == NULL && ut_params->op->status ==
RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
printf("Device doesn't support this mixed combination. "
"Test Skipped.\n");
return -ENOTSUP;
}
+ ut_params->op = op;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
uint8_t digest_buffer[10000];
struct rte_cryptodev_info dev_info;
+ struct rte_crypto_op *op;
/* Check if device supports particular algorithms */
if (test_mixed_check_if_unsupported(tdata))
if (retval < 0)
return retval;
- ut_params->op = process_crypto_request(ts_params->valid_devs[0],
- ut_params->op);
+ op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
/* Check if the op failed because the device doesn't */
/* support this particular combination of algorithms */
- if (ut_params->op == NULL && ut_params->op->status ==
+ if (op == NULL && ut_params->op->status ==
RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
printf("Device doesn't support this mixed combination. "
"Test Skipped.\n");
return -ENOTSUP;
}
+ ut_params->op = op;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
}
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
static int
security_proto_supported(enum rte_security_session_action_type action,
enum rte_security_session_protocol proto)
/* Create security session */
ut_params->sec_session = rte_security_session_create(ctx,
- &sess_conf, ts_params->session_priv_mpool);
+ &sess_conf, ts_params->session_mpool,
+ ts_params->session_priv_mpool);
if (!ut_params->sec_session) {
printf("TestCase %s()-%d line %d failed %s: ",
/* Create security session */
ut_params->sec_session = rte_security_session_create(ctx,
- &sess_conf, ts_params->session_priv_mpool);
+ &sess_conf, ts_params->session_mpool,
+ ts_params->session_priv_mpool);
if (!ut_params->sec_session) {
printf("TestCase %s()-%d line %d failed %s: ",
128, 32);
}
+static int
+test_PDCP_SDAP_PROTO_encap_all(void)
+{
+ int i = 0, size = 0;
+ int err, all_err = TEST_SUCCESS;
+ const struct pdcp_sdap_test *cur_test;
+
+ size = ARRAY_SIZE(list_pdcp_sdap_tests);
+
+ for (i = 0; i < size; i++) {
+ cur_test = &list_pdcp_sdap_tests[i];
+ err = test_pdcp_proto(
+ i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+ RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
+ cur_test->in_len, cur_test->data_out,
+ cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
+ cur_test->param.cipher_alg, cur_test->cipher_key,
+ cur_test->param.cipher_key_len,
+ cur_test->param.auth_alg,
+ cur_test->auth_key, cur_test->param.auth_key_len,
+ cur_test->bearer, cur_test->param.domain,
+ cur_test->packet_direction, cur_test->sn_size,
+ cur_test->hfn,
+ cur_test->hfn_threshold, SDAP_ENABLED);
+ if (err) {
+ printf("\t%d) %s: Encapsulation failed\n",
+ cur_test->test_idx,
+ cur_test->param.name);
+ err = TEST_FAILED;
+ } else {
+ printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
+ cur_test->param.name);
+ err = TEST_SUCCESS;
+ }
+ all_err += err;
+ }
+
+ printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
+
+ return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
+}
+
+static int
+test_PDCP_SDAP_PROTO_decap_all(void)
+{
+ int i = 0, size = 0;
+ int err, all_err = TEST_SUCCESS;
+ const struct pdcp_sdap_test *cur_test;
+
+ size = ARRAY_SIZE(list_pdcp_sdap_tests);
+
+ for (i = 0; i < size; i++) {
+ cur_test = &list_pdcp_sdap_tests[i];
+ err = test_pdcp_proto(
+ i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
+ RTE_CRYPTO_AUTH_OP_VERIFY,
+ cur_test->data_out,
+ cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
+ cur_test->data_in, cur_test->in_len,
+ cur_test->param.cipher_alg,
+ cur_test->cipher_key, cur_test->param.cipher_key_len,
+ cur_test->param.auth_alg, cur_test->auth_key,
+ cur_test->param.auth_key_len, cur_test->bearer,
+ cur_test->param.domain, cur_test->packet_direction,
+ cur_test->sn_size, cur_test->hfn,
+ cur_test->hfn_threshold, SDAP_ENABLED);
+ if (err) {
+ printf("\t%d) %s: Decapsulation failed\n",
+ cur_test->test_idx,
+ cur_test->param.name);
+ err = TEST_FAILED;
+ } else {
+ printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
+ cur_test->param.name);
+ err = TEST_SUCCESS;
+ }
+ all_err += err;
+ }
+
+ printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
+
+ return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
+}
+
static int
test_PDCP_PROTO_all(void)
{
status += test_PDCP_PROTO_SGL_oop_32B_128B();
status += test_PDCP_PROTO_SGL_oop_32B_40B();
status += test_PDCP_PROTO_SGL_oop_128B_32B();
+ status += test_PDCP_SDAP_PROTO_encap_all();
+ status += test_PDCP_SDAP_PROTO_decap_all();
if (status)
return TEST_FAILED;
/* Create security session */
ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
+ ts_params->session_mpool,
ts_params->session_priv_mpool);
if (!ut_params->sec_session) {
/* Create security session */
ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
+ ts_params->session_mpool,
ts_params->session_priv_mpool);
if (!ut_params->sec_session) {
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
feature_flags = dev_info.feature_flags;
- if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) &&
- (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) &&
+ if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
+ (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
return -ENOTSUP;
return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
}
-#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+#ifdef RTE_CRYPTO_SCHEDULER
/* global AESNI worker IDs for the scheduler test */
uint8_t aesni_ids[2];
}
};
-#endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
+#endif /* RTE_CRYPTO_SCHEDULER */
static struct unit_test_suite cryptodev_testsuite = {
.suite_name = "Crypto Unit Test Suite",
TEST_CASE_ST(ut_setup, ut_teardown,
test_verify_auth_aes_cmac_cipher_null_test_case_1),
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
TEST_CASE_ST(ut_setup_security, ut_teardown,
test_PDCP_PROTO_all),
TEST_CASE_ST(ut_setup_security, ut_teardown,
return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
}
-#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+#ifdef RTE_CRYPTO_SCHEDULER
static int
test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
if (gbl_driver_id == -1) {
- RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
- "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
- "are enabled in config file to run this testsuite.\n");
+ RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
return TEST_SKIPPED;
}