X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=app%2Ftest%2Ftest_ipsec.c;h=4342b730b7fed37ec9048bd27751df204cb4ebbe;hb=5ef2546767525c8a4a3c2bc60357b23c3dffcf6b;hp=80a2d255fb5fd5d1401c22de2c0e00566911a6a6;hpb=a9de470cc7c0649221e156fc5f30a2dbdfe7c166;p=dpdk.git diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c index 80a2d255fb..4342b730b7 100644 --- a/app/test/test_ipsec.c +++ b/app/test/test_ipsec.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -42,6 +42,7 @@ #define OUTBOUND_SPI 17 #define BURST_SIZE 32 #define REORDER_PKTS 1 +#define DEQUEUE_COUNT 1000 struct user_params { enum rte_crypto_sym_xform_type auth; @@ -79,7 +80,6 @@ struct ipsec_unitest_params { struct rte_mbuf *obuf[BURST_SIZE], *ibuf[BURST_SIZE], *testbuf[BURST_SIZE]; - uint8_t *digest; uint16_t pkt_index; }; @@ -111,8 +111,6 @@ static struct ipsec_testsuite_params testsuite_params = { NULL }; static struct ipsec_unitest_params unittest_params; static struct user_params uparams; -static uint8_t global_key[128] = { 0 }; - struct supported_cipher_algo { const char *keyword; enum rte_crypto_cipher_algorithm algo; @@ -215,30 +213,26 @@ fill_crypto_xform(struct ipsec_unitest_params *ut_params, const struct supported_auth_algo *auth_algo, const struct supported_cipher_algo *cipher_algo) { - ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; - ut_params->auth_xform.auth.algo = auth_algo->algo; - ut_params->auth_xform.auth.key.data = global_key; - ut_params->auth_xform.auth.key.length = auth_algo->key_len; - ut_params->auth_xform.auth.digest_length = auth_algo->digest_len; - ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; - ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; ut_params->cipher_xform.cipher.algo = cipher_algo->algo; - ut_params->cipher_xform.cipher.key.data = global_key; - ut_params->cipher_xform.cipher.key.length = cipher_algo->key_len; - ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT; - ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; - ut_params->cipher_xform.cipher.iv.length = cipher_algo->iv_len; + ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; + ut_params->auth_xform.auth.algo = auth_algo->algo; if (ut_params->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) { - ut_params->crypto_xforms = &ut_params->auth_xform; - ut_params->auth_xform.next = &ut_params->cipher_xform; + ut_params->cipher_xform.cipher.op = + RTE_CRYPTO_CIPHER_OP_DECRYPT; + ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; ut_params->cipher_xform.next = NULL; + ut_params->auth_xform.next = &ut_params->cipher_xform; + ut_params->crypto_xforms = &ut_params->auth_xform; } else { - ut_params->crypto_xforms = &ut_params->cipher_xform; - ut_params->cipher_xform.next = &ut_params->auth_xform; + ut_params->cipher_xform.cipher.op = + RTE_CRYPTO_CIPHER_OP_ENCRYPT; + ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; ut_params->auth_xform.next = NULL; + ut_params->cipher_xform.next = &ut_params->auth_xform; + ut_params->crypto_xforms = &ut_params->cipher_xform; } } @@ -287,9 +281,12 @@ testsuite_setup(void) int rc; memset(ts_params, 0, sizeof(*ts_params)); + memset(ut_params, 0, sizeof(*ut_params)); + memset(&uparams, 0, sizeof(struct user_params)); uparams.auth = RTE_CRYPTO_SYM_XFORM_AUTH; uparams.cipher = RTE_CRYPTO_SYM_XFORM_CIPHER; + uparams.aead = RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED; strcpy(uparams.auth_algo, "null"); strcpy(uparams.cipher_algo, "null"); @@ -572,12 +569,12 @@ setup_test_string_tunneled(struct rte_mempool *mpool, const char *string, size_t len, uint32_t spi, uint32_t seq) { struct rte_mbuf *m = rte_pktmbuf_alloc(mpool); - uint32_t hdrlen = sizeof(struct ipv4_hdr) + sizeof(struct esp_hdr); + uint32_t hdrlen = sizeof(struct ipv4_hdr) + sizeof(struct rte_esp_hdr); uint32_t taillen = sizeof(struct esp_tail); uint32_t t_len = len + hdrlen + taillen; uint32_t padlen; - struct esp_hdr esph = { + struct rte_esp_hdr esph = { .spi = rte_cpu_to_be_32(spi), .seq = rte_cpu_to_be_32(seq) }; @@ -752,6 +749,29 @@ create_sa(enum rte_security_session_action_type action_type, return rc; } +static int +crypto_dequeue_burst(uint16_t num_pkts) +{ + struct ipsec_testsuite_params *ts_params = &testsuite_params; + struct ipsec_unitest_params *ut_params = &unittest_params; + uint32_t pkt_cnt, k; + int i; + + for (i = 0, pkt_cnt = 0; + i < DEQUEUE_COUNT && pkt_cnt != num_pkts; i++) { + k = rte_cryptodev_dequeue_burst(ts_params->valid_dev, 0, + &ut_params->cop[pkt_cnt], num_pkts - pkt_cnt); + pkt_cnt += k; + rte_delay_us(1); + } + + if (pkt_cnt != num_pkts) { + RTE_LOG(ERR, USER1, "rte_cryptodev_dequeue_burst fail\n"); + return TEST_FAILED; + } + return TEST_SUCCESS; +} + static int crypto_ipsec(uint16_t num_pkts) { @@ -767,6 +787,7 @@ crypto_ipsec(uint16_t num_pkts) RTE_LOG(ERR, USER1, "rte_ipsec_pkt_crypto_prepare fail\n"); return TEST_FAILED; } + k = rte_cryptodev_enqueue_burst(ts_params->valid_dev, 0, ut_params->cop, num_pkts); if (k != num_pkts) { @@ -774,12 +795,8 @@ crypto_ipsec(uint16_t num_pkts) return TEST_FAILED; } - k = rte_cryptodev_dequeue_burst(ts_params->valid_dev, 0, - ut_params->cop, num_pkts); - if (k != num_pkts) { - RTE_LOG(ERR, USER1, "rte_cryptodev_dequeue_burst fail\n"); + if (crypto_dequeue_burst(num_pkts) == TEST_FAILED) return TEST_FAILED; - } ng = rte_ipsec_pkt_crypto_group( (const struct rte_crypto_op **)(uintptr_t)ut_params->cop, @@ -868,7 +885,6 @@ crypto_ipsec_2sa(void) struct ipsec_testsuite_params *ts_params = &testsuite_params; struct ipsec_unitest_params *ut_params = &unittest_params; struct rte_ipsec_group grp[BURST_SIZE]; - uint32_t k, ng, i, r; for (i = 0; i < BURST_SIZE; i++) { @@ -890,12 +906,8 @@ crypto_ipsec_2sa(void) } } - k = rte_cryptodev_dequeue_burst(ts_params->valid_dev, 0, - ut_params->cop, BURST_SIZE); - if (k != BURST_SIZE) { - RTE_LOG(ERR, USER1, "rte_cryptodev_dequeue_burst fail\n"); + if (crypto_dequeue_burst(BURST_SIZE) == TEST_FAILED) return TEST_FAILED; - } ng = rte_ipsec_pkt_crypto_group( (const struct rte_crypto_op **)(uintptr_t)ut_params->cop, @@ -1029,12 +1041,8 @@ crypto_ipsec_2sa_4grp(void) } } - k = rte_cryptodev_dequeue_burst(ts_params->valid_dev, 0, - ut_params->cop, BURST_SIZE); - if (k != BURST_SIZE) { - RTE_LOG(ERR, USER1, "rte_cryptodev_dequeue_burst fail\n"); + if (crypto_dequeue_burst(BURST_SIZE) == TEST_FAILED) return TEST_FAILED; - } ng = rte_ipsec_pkt_crypto_group( (const struct rte_crypto_op **)(uintptr_t)ut_params->cop,