* Copyright(c) 2018 Intel Corporation
*/
+#include "test.h"
+
#include <time.h>
#include <rte_common.h>
#include <rte_cycles.h>
#include <rte_bus_vdev.h>
#include <rte_ip.h>
-
#include <rte_crypto.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
#include <rte_lcore.h>
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+static int
+test_ipsec(void)
+{
+ printf("ipsec not supported on Windows, skipping test\n");
+ return TEST_SKIPPED;
+}
+
+#else
+
#include <rte_ipsec.h>
#include <rte_random.h>
#include <rte_esp.h>
#include <rte_security_driver.h>
-#include "test.h"
#include "test_cryptodev.h"
#define VDEV_ARGS_SIZE 100
}
static int
-ut_setup(void)
+ut_setup_ipsec(void)
{
struct ipsec_testsuite_params *ts_params = &testsuite_params;
struct ipsec_unitest_params *ut_params = &unittest_params;
}
static void
-ut_teardown(void)
+ut_teardown_ipsec(void)
{
struct ipsec_testsuite_params *ts_params = &testsuite_params;
struct ipsec_unitest_params *ut_params = &unittest_params;
static struct rte_security_session_conf conf;
ut->ss[j].security.ses = rte_security_session_create(&dummy_sec_ctx,
- &conf, qp->mp_session_private);
+ &conf, qp->mp_session,
+ qp->mp_session_private);
if (ut->ss[j].security.ses == NULL)
return -ENOMEM;
if (s == NULL)
return -ENOMEM;
- /* initiliaze SA crypto session for device */
+ /* initialize SA crypto session for device */
rc = rte_cryptodev_sym_session_init(dev_id, s,
ut->crypto_xforms, qp->mp_session_private);
if (rc == 0) {
ut->ss[j].type = action_type;
rc = create_session(ut, &ts->qp_conf, ts->valid_dev, j);
if (rc != 0)
- return TEST_FAILED;
+ return rc;
rc = rte_ipsec_sa_init(ut->ss[j].sa, &ut->sa_prm, sz);
rc = (rc > 0 && (uint32_t)rc <= sz) ? 0 : -EINVAL;
}
}
+static void
+destroy_dummy_sec_session(struct ipsec_unitest_params *ut,
+ uint32_t j)
+{
+ rte_security_session_destroy(&dummy_sec_ctx,
+ ut->ss[j].security.ses);
+ ut->ss[j].security.ctx = NULL;
+}
+
+static void
+destroy_crypto_session(struct ipsec_unitest_params *ut,
+ uint8_t crypto_dev, uint32_t j)
+{
+ rte_cryptodev_sym_session_clear(crypto_dev, ut->ss[j].crypto.ses);
+ rte_cryptodev_sym_session_free(ut->ss[j].crypto.ses);
+ memset(&ut->ss[j], 0, sizeof(ut->ss[j]));
+}
+
+static void
+destroy_session(struct ipsec_unitest_params *ut,
+ uint8_t crypto_dev, uint32_t j)
+{
+ if (ut->ss[j].type == RTE_SECURITY_ACTION_TYPE_NONE)
+ return destroy_crypto_session(ut, crypto_dev, j);
+ else
+ return destroy_dummy_sec_session(ut, j);
+}
+
static void
destroy_sa(uint32_t j)
{
rte_ipsec_sa_fini(ut->ss[j].sa);
rte_free(ut->ss[j].sa);
- rte_cryptodev_sym_session_clear(ts->valid_dev, ut->ss[j].crypto.ses);
- rte_cryptodev_sym_session_free(ut->ss[j].crypto.ses);
- memset(&ut->ss[j], 0, sizeof(ut->ss[j]));
+
+ destroy_session(ut, ts->valid_dev, j);
}
static int
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate input mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate inbound mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate inbound mbuf data */
"ibuf pkt_len is not equal to obuf pkt_len");
/* check mbuf ol_flags */
- TEST_ASSERT(ut_params->ibuf[j]->ol_flags & PKT_TX_SEC_OFFLOAD,
- "ibuf PKT_TX_SEC_OFFLOAD is not set");
+ TEST_ASSERT(ut_params->ibuf[j]->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD,
+ "ibuf RTE_MBUF_F_TX_SEC_OFFLOAD is not set");
}
return 0;
}
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate inbound mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* Generate inbound mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa 0 failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* create second rte_ipsec_sa */
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa 1 failed, cfg %d\n", i);
destroy_sa(0);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
test_cfg[i].replay_win_sz, test_cfg[i].flags, 0);
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa 0 failed, cfg %d\n", i);
- return TEST_FAILED;
+ return rc;
}
/* create second rte_ipsec_sa */
if (rc != 0) {
RTE_LOG(ERR, USER1, "create_sa 1 failed, cfg %d\n", i);
destroy_sa(0);
- return TEST_FAILED;
+ return rc;
}
/* Generate test mbuf data */
.setup = testsuite_setup,
.teardown = testsuite_teardown,
.unit_test_cases = {
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_crypto_inb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_crypto_outb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_inline_crypto_inb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_inline_crypto_outb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_inline_proto_inb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_inline_proto_outb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_lksd_proto_inb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_lksd_proto_outb_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_replay_inb_inside_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_replay_inb_outside_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_replay_inb_repeat_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_replay_inb_inside_burst_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_crypto_inb_burst_2sa_null_null_wrapper),
- TEST_CASE_ST(ut_setup, ut_teardown,
+ TEST_CASE_ST(ut_setup_ipsec, ut_teardown_ipsec,
test_ipsec_crypto_inb_burst_2sa_4grp_null_null_wrapper),
TEST_CASES_END() /**< NULL terminate unit test array */
}
return unit_test_suite_runner(&ipsec_testsuite);
}
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
REGISTER_TEST_COMMAND(ipsec_autotest, test_ipsec);