186e2487cSAkhil Goyal /* SPDX-License-Identifier: BSD-3-Clause 286e2487cSAkhil Goyal * Copyright(C) 2022 Marvell. 386e2487cSAkhil Goyal */ 486e2487cSAkhil Goyal 586e2487cSAkhil Goyal 686e2487cSAkhil Goyal #include <stdio.h> 786e2487cSAkhil Goyal #include <inttypes.h> 886e2487cSAkhil Goyal 986e2487cSAkhil Goyal #include <rte_ethdev.h> 1086e2487cSAkhil Goyal #include <rte_malloc.h> 1186e2487cSAkhil Goyal #include <rte_security.h> 1286e2487cSAkhil Goyal 1386e2487cSAkhil Goyal #include "test.h" 1486e2487cSAkhil Goyal #include "test_security_inline_proto_vectors.h" 1586e2487cSAkhil Goyal 1686e2487cSAkhil Goyal #ifdef RTE_EXEC_ENV_WINDOWS 1786e2487cSAkhil Goyal static int 1886e2487cSAkhil Goyal test_inline_ipsec(void) 1986e2487cSAkhil Goyal { 2086e2487cSAkhil Goyal printf("Inline ipsec not supported on Windows, skipping test\n"); 2186e2487cSAkhil Goyal return TEST_SKIPPED; 2286e2487cSAkhil Goyal } 2386e2487cSAkhil Goyal 2410864656SVolodymyr Fialko static int 2510864656SVolodymyr Fialko test_event_inline_ipsec(void) 2610864656SVolodymyr Fialko { 2710864656SVolodymyr Fialko printf("Event inline ipsec not supported on Windows, skipping test\n"); 2810864656SVolodymyr Fialko return TEST_SKIPPED; 2910864656SVolodymyr Fialko } 3010864656SVolodymyr Fialko 3186e2487cSAkhil Goyal #else 3286e2487cSAkhil Goyal 3310864656SVolodymyr Fialko #include <rte_eventdev.h> 3410864656SVolodymyr Fialko #include <rte_event_eth_rx_adapter.h> 3510864656SVolodymyr Fialko #include <rte_event_eth_tx_adapter.h> 3610864656SVolodymyr Fialko 3786e2487cSAkhil Goyal #define NB_ETHPORTS_USED 1 3886e2487cSAkhil Goyal #define MEMPOOL_CACHE_SIZE 32 3986e2487cSAkhil Goyal #define MAX_PKT_BURST 32 404ed89049SDavid Marchand #define RX_DESC_DEFAULT 1024 414ed89049SDavid Marchand #define TX_DESC_DEFAULT 1024 4286e2487cSAkhil Goyal #define RTE_PORT_ALL (~(uint16_t)0x0) 4386e2487cSAkhil Goyal 4486e2487cSAkhil Goyal #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */ 4586e2487cSAkhil Goyal #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */ 4686e2487cSAkhil Goyal #define RX_WTHRESH 0 /**< Default values of RX write-back threshold reg. */ 4786e2487cSAkhil Goyal 4886e2487cSAkhil Goyal #define TX_PTHRESH 32 /**< Default values of TX prefetch threshold reg. */ 4986e2487cSAkhil Goyal #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */ 5086e2487cSAkhil Goyal #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */ 5186e2487cSAkhil Goyal 5286e2487cSAkhil Goyal #define MAX_TRAFFIC_BURST 2048 5386e2487cSAkhil Goyal #define NB_MBUF 10240 5486e2487cSAkhil Goyal 55a3105777SAkhil Goyal #define ENCAP_DECAP_BURST_SZ 33 56a3105777SAkhil Goyal #define APP_REASS_TIMEOUT 10 57a3105777SAkhil Goyal 5886e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_128_gcm; 5986e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_192_gcm; 6086e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_256_gcm; 6186e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_128_gcm_frag; 6286e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_128_cbc_null; 6386e2487cSAkhil Goyal extern struct ipsec_test_data pkt_null_aes_xcbc; 6486e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_128_cbc_hmac_sha384; 6586e2487cSAkhil Goyal extern struct ipsec_test_data pkt_aes_128_cbc_hmac_sha512; 66d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_3des_cbc_hmac_sha256; 67d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_3des_cbc_hmac_sha384; 68d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_3des_cbc_hmac_sha512; 69d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_3des_cbc_hmac_sha256_v6; 70d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_des_cbc_hmac_sha256; 71d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_des_cbc_hmac_sha384; 72d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_des_cbc_hmac_sha512; 73d7001863SVidya Sagar Velumuri extern struct ipsec_test_data pkt_des_cbc_hmac_sha256_v6; 74*5a23f6eaSVidya Sagar Velumuri extern struct ipsec_test_data pkt_aes_128_cbc_md5; 7586e2487cSAkhil Goyal 7686e2487cSAkhil Goyal static struct rte_mempool *mbufpool; 7786e2487cSAkhil Goyal static struct rte_mempool *sess_pool; 7886e2487cSAkhil Goyal /* ethernet addresses of ports */ 7986e2487cSAkhil Goyal static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; 8086e2487cSAkhil Goyal 8186e2487cSAkhil Goyal static struct rte_eth_conf port_conf = { 8286e2487cSAkhil Goyal .rxmode = { 8386e2487cSAkhil Goyal .mq_mode = RTE_ETH_MQ_RX_NONE, 8486e2487cSAkhil Goyal .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM | 8586e2487cSAkhil Goyal RTE_ETH_RX_OFFLOAD_SECURITY, 8686e2487cSAkhil Goyal }, 8786e2487cSAkhil Goyal .txmode = { 8886e2487cSAkhil Goyal .mq_mode = RTE_ETH_MQ_TX_NONE, 8986e2487cSAkhil Goyal .offloads = RTE_ETH_TX_OFFLOAD_SECURITY | 9086e2487cSAkhil Goyal RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE, 9186e2487cSAkhil Goyal }, 9286e2487cSAkhil Goyal .lpbk_mode = 1, /* enable loopback */ 9386e2487cSAkhil Goyal }; 9486e2487cSAkhil Goyal 9586e2487cSAkhil Goyal static struct rte_eth_rxconf rx_conf = { 9686e2487cSAkhil Goyal .rx_thresh = { 9786e2487cSAkhil Goyal .pthresh = RX_PTHRESH, 9886e2487cSAkhil Goyal .hthresh = RX_HTHRESH, 9986e2487cSAkhil Goyal .wthresh = RX_WTHRESH, 10086e2487cSAkhil Goyal }, 10186e2487cSAkhil Goyal .rx_free_thresh = 32, 10286e2487cSAkhil Goyal }; 10386e2487cSAkhil Goyal 10486e2487cSAkhil Goyal static struct rte_eth_txconf tx_conf = { 10586e2487cSAkhil Goyal .tx_thresh = { 10686e2487cSAkhil Goyal .pthresh = TX_PTHRESH, 10786e2487cSAkhil Goyal .hthresh = TX_HTHRESH, 10886e2487cSAkhil Goyal .wthresh = TX_WTHRESH, 10986e2487cSAkhil Goyal }, 11086e2487cSAkhil Goyal .tx_free_thresh = 32, /* Use PMD default values */ 11186e2487cSAkhil Goyal .tx_rs_thresh = 32, /* Use PMD default values */ 11286e2487cSAkhil Goyal }; 11386e2487cSAkhil Goyal 11410864656SVolodymyr Fialko static uint16_t port_id; 11510864656SVolodymyr Fialko static uint8_t eventdev_id; 11610864656SVolodymyr Fialko static uint8_t rx_adapter_id; 11710864656SVolodymyr Fialko static uint8_t tx_adapter_id; 11810864656SVolodymyr Fialko 11910864656SVolodymyr Fialko static bool event_mode_enabled; 12086e2487cSAkhil Goyal 12186e2487cSAkhil Goyal static uint64_t link_mbps; 12286e2487cSAkhil Goyal 123a3105777SAkhil Goyal static int ip_reassembly_dynfield_offset = -1; 124a3105777SAkhil Goyal 12586e2487cSAkhil Goyal static struct rte_flow *default_flow[RTE_MAX_ETHPORTS]; 12686e2487cSAkhil Goyal 12786e2487cSAkhil Goyal /* Create Inline IPsec session */ 12886e2487cSAkhil Goyal static int 12986e2487cSAkhil Goyal create_inline_ipsec_session(struct ipsec_test_data *sa, uint16_t portid, 1302973dbf9SAkhil Goyal void **sess, struct rte_security_ctx **ctx, 13186e2487cSAkhil Goyal uint32_t *ol_flags, const struct ipsec_test_flags *flags, 13286e2487cSAkhil Goyal struct rte_security_session_conf *sess_conf) 13386e2487cSAkhil Goyal { 13486e2487cSAkhil Goyal uint16_t src_v6[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000, 13586e2487cSAkhil Goyal 0x0000, 0x001a}; 13686e2487cSAkhil Goyal uint16_t dst_v6[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174, 13786e2487cSAkhil Goyal 0xe82c, 0x4887}; 13886e2487cSAkhil Goyal uint32_t src_v4 = rte_cpu_to_be_32(RTE_IPV4(192, 168, 1, 2)); 13986e2487cSAkhil Goyal uint32_t dst_v4 = rte_cpu_to_be_32(RTE_IPV4(192, 168, 1, 1)); 14086e2487cSAkhil Goyal struct rte_security_capability_idx sec_cap_idx; 14186e2487cSAkhil Goyal const struct rte_security_capability *sec_cap; 14286e2487cSAkhil Goyal enum rte_security_ipsec_sa_direction dir; 14386e2487cSAkhil Goyal struct rte_security_ctx *sec_ctx; 14486e2487cSAkhil Goyal uint32_t verify; 14586e2487cSAkhil Goyal 14686e2487cSAkhil Goyal sess_conf->action_type = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL; 14786e2487cSAkhil Goyal sess_conf->protocol = RTE_SECURITY_PROTOCOL_IPSEC; 14886e2487cSAkhil Goyal sess_conf->ipsec = sa->ipsec_xform; 14986e2487cSAkhil Goyal 15086e2487cSAkhil Goyal dir = sa->ipsec_xform.direction; 15186e2487cSAkhil Goyal verify = flags->tunnel_hdr_verify; 15286e2487cSAkhil Goyal 15386e2487cSAkhil Goyal if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) { 15486e2487cSAkhil Goyal if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR) 15586e2487cSAkhil Goyal src_v4 += 1; 15686e2487cSAkhil Goyal else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR) 15786e2487cSAkhil Goyal dst_v4 += 1; 15886e2487cSAkhil Goyal } 15986e2487cSAkhil Goyal 16086e2487cSAkhil Goyal if (sa->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) { 16186e2487cSAkhil Goyal if (sa->ipsec_xform.tunnel.type == 16286e2487cSAkhil Goyal RTE_SECURITY_IPSEC_TUNNEL_IPV4) { 16386e2487cSAkhil Goyal memcpy(&sess_conf->ipsec.tunnel.ipv4.src_ip, &src_v4, 16486e2487cSAkhil Goyal sizeof(src_v4)); 16586e2487cSAkhil Goyal memcpy(&sess_conf->ipsec.tunnel.ipv4.dst_ip, &dst_v4, 16686e2487cSAkhil Goyal sizeof(dst_v4)); 16786e2487cSAkhil Goyal 16886e2487cSAkhil Goyal if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1) 16986e2487cSAkhil Goyal sess_conf->ipsec.tunnel.ipv4.df = 0; 17086e2487cSAkhil Goyal 17186e2487cSAkhil Goyal if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0) 17286e2487cSAkhil Goyal sess_conf->ipsec.tunnel.ipv4.df = 1; 17386e2487cSAkhil Goyal 17486e2487cSAkhil Goyal if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1) 17586e2487cSAkhil Goyal sess_conf->ipsec.tunnel.ipv4.dscp = 0; 17686e2487cSAkhil Goyal 17786e2487cSAkhil Goyal if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) 17886e2487cSAkhil Goyal sess_conf->ipsec.tunnel.ipv4.dscp = 17986e2487cSAkhil Goyal TEST_IPSEC_DSCP_VAL; 18086e2487cSAkhil Goyal } else { 18186e2487cSAkhil Goyal if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1) 18286e2487cSAkhil Goyal sess_conf->ipsec.tunnel.ipv6.dscp = 0; 18386e2487cSAkhil Goyal 18486e2487cSAkhil Goyal if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) 18586e2487cSAkhil Goyal sess_conf->ipsec.tunnel.ipv6.dscp = 18686e2487cSAkhil Goyal TEST_IPSEC_DSCP_VAL; 18786e2487cSAkhil Goyal 18891d1d052SVamsi Attunuru if (flags->flabel == TEST_IPSEC_SET_FLABEL_0_INNER_1) 18991d1d052SVamsi Attunuru sess_conf->ipsec.tunnel.ipv6.flabel = 0; 19091d1d052SVamsi Attunuru 19191d1d052SVamsi Attunuru if (flags->flabel == TEST_IPSEC_SET_FLABEL_1_INNER_0) 19291d1d052SVamsi Attunuru sess_conf->ipsec.tunnel.ipv6.flabel = 19391d1d052SVamsi Attunuru TEST_IPSEC_FLABEL_VAL; 19491d1d052SVamsi Attunuru 19586e2487cSAkhil Goyal memcpy(&sess_conf->ipsec.tunnel.ipv6.src_addr, &src_v6, 19686e2487cSAkhil Goyal sizeof(src_v6)); 19786e2487cSAkhil Goyal memcpy(&sess_conf->ipsec.tunnel.ipv6.dst_addr, &dst_v6, 19886e2487cSAkhil Goyal sizeof(dst_v6)); 19986e2487cSAkhil Goyal } 20086e2487cSAkhil Goyal } 20186e2487cSAkhil Goyal 20286e2487cSAkhil Goyal /* Save SA as userdata for the security session. When 20386e2487cSAkhil Goyal * the packet is received, this userdata will be 20486e2487cSAkhil Goyal * retrieved using the metadata from the packet. 20586e2487cSAkhil Goyal * 20686e2487cSAkhil Goyal * The PMD is expected to set similar metadata for other 20786e2487cSAkhil Goyal * operations, like rte_eth_event, which are tied to 20886e2487cSAkhil Goyal * security session. In such cases, the userdata could 20986e2487cSAkhil Goyal * be obtained to uniquely identify the security 21086e2487cSAkhil Goyal * parameters denoted. 21186e2487cSAkhil Goyal */ 21286e2487cSAkhil Goyal 21386e2487cSAkhil Goyal sess_conf->userdata = (void *) sa; 21486e2487cSAkhil Goyal 21586e2487cSAkhil Goyal sec_ctx = (struct rte_security_ctx *)rte_eth_dev_get_sec_ctx(portid); 21686e2487cSAkhil Goyal if (sec_ctx == NULL) { 21786e2487cSAkhil Goyal printf("Ethernet device doesn't support security features.\n"); 21886e2487cSAkhil Goyal return TEST_SKIPPED; 21986e2487cSAkhil Goyal } 22086e2487cSAkhil Goyal 22186e2487cSAkhil Goyal sec_cap_idx.action = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL; 22286e2487cSAkhil Goyal sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC; 22386e2487cSAkhil Goyal sec_cap_idx.ipsec.proto = sess_conf->ipsec.proto; 22486e2487cSAkhil Goyal sec_cap_idx.ipsec.mode = sess_conf->ipsec.mode; 22586e2487cSAkhil Goyal sec_cap_idx.ipsec.direction = sess_conf->ipsec.direction; 22686e2487cSAkhil Goyal sec_cap = rte_security_capability_get(sec_ctx, &sec_cap_idx); 22786e2487cSAkhil Goyal if (sec_cap == NULL) { 22886e2487cSAkhil Goyal printf("No capabilities registered\n"); 22986e2487cSAkhil Goyal return TEST_SKIPPED; 23086e2487cSAkhil Goyal } 23186e2487cSAkhil Goyal 23286e2487cSAkhil Goyal if (sa->aead || sa->aes_gmac) 23386e2487cSAkhil Goyal memcpy(&sess_conf->ipsec.salt, sa->salt.data, 23486e2487cSAkhil Goyal RTE_MIN(sizeof(sess_conf->ipsec.salt), sa->salt.len)); 23586e2487cSAkhil Goyal 23686e2487cSAkhil Goyal /* Copy cipher session parameters */ 23786e2487cSAkhil Goyal if (sa->aead) { 23886e2487cSAkhil Goyal rte_memcpy(sess_conf->crypto_xform, &sa->xform.aead, 23986e2487cSAkhil Goyal sizeof(struct rte_crypto_sym_xform)); 24086e2487cSAkhil Goyal sess_conf->crypto_xform->aead.key.data = sa->key.data; 24186e2487cSAkhil Goyal /* Verify crypto capabilities */ 24286e2487cSAkhil Goyal if (test_ipsec_crypto_caps_aead_verify(sec_cap, 24386e2487cSAkhil Goyal sess_conf->crypto_xform) != 0) { 24486e2487cSAkhil Goyal RTE_LOG(INFO, USER1, 24586e2487cSAkhil Goyal "Crypto capabilities not supported\n"); 24686e2487cSAkhil Goyal return TEST_SKIPPED; 24786e2487cSAkhil Goyal } 24886e2487cSAkhil Goyal } else { 24986e2487cSAkhil Goyal if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { 25086e2487cSAkhil Goyal rte_memcpy(&sess_conf->crypto_xform->cipher, 25186e2487cSAkhil Goyal &sa->xform.chain.cipher.cipher, 25286e2487cSAkhil Goyal sizeof(struct rte_crypto_cipher_xform)); 25386e2487cSAkhil Goyal 25486e2487cSAkhil Goyal rte_memcpy(&sess_conf->crypto_xform->next->auth, 25586e2487cSAkhil Goyal &sa->xform.chain.auth.auth, 25686e2487cSAkhil Goyal sizeof(struct rte_crypto_auth_xform)); 25786e2487cSAkhil Goyal sess_conf->crypto_xform->cipher.key.data = 25886e2487cSAkhil Goyal sa->key.data; 25986e2487cSAkhil Goyal sess_conf->crypto_xform->next->auth.key.data = 26086e2487cSAkhil Goyal sa->auth_key.data; 26186e2487cSAkhil Goyal /* Verify crypto capabilities */ 26286e2487cSAkhil Goyal if (test_ipsec_crypto_caps_cipher_verify(sec_cap, 26386e2487cSAkhil Goyal sess_conf->crypto_xform) != 0) { 26486e2487cSAkhil Goyal RTE_LOG(INFO, USER1, 26586e2487cSAkhil Goyal "Cipher crypto capabilities not supported\n"); 26686e2487cSAkhil Goyal return TEST_SKIPPED; 26786e2487cSAkhil Goyal } 26886e2487cSAkhil Goyal 26986e2487cSAkhil Goyal if (test_ipsec_crypto_caps_auth_verify(sec_cap, 27086e2487cSAkhil Goyal sess_conf->crypto_xform->next) != 0) { 27186e2487cSAkhil Goyal RTE_LOG(INFO, USER1, 27286e2487cSAkhil Goyal "Auth crypto capabilities not supported\n"); 27386e2487cSAkhil Goyal return TEST_SKIPPED; 27486e2487cSAkhil Goyal } 27586e2487cSAkhil Goyal } else { 27686e2487cSAkhil Goyal rte_memcpy(&sess_conf->crypto_xform->next->cipher, 27786e2487cSAkhil Goyal &sa->xform.chain.cipher.cipher, 27886e2487cSAkhil Goyal sizeof(struct rte_crypto_cipher_xform)); 27986e2487cSAkhil Goyal rte_memcpy(&sess_conf->crypto_xform->auth, 28086e2487cSAkhil Goyal &sa->xform.chain.auth.auth, 28186e2487cSAkhil Goyal sizeof(struct rte_crypto_auth_xform)); 28286e2487cSAkhil Goyal sess_conf->crypto_xform->auth.key.data = 28386e2487cSAkhil Goyal sa->auth_key.data; 28486e2487cSAkhil Goyal sess_conf->crypto_xform->next->cipher.key.data = 28586e2487cSAkhil Goyal sa->key.data; 28686e2487cSAkhil Goyal 28786e2487cSAkhil Goyal /* Verify crypto capabilities */ 28886e2487cSAkhil Goyal if (test_ipsec_crypto_caps_cipher_verify(sec_cap, 28986e2487cSAkhil Goyal sess_conf->crypto_xform->next) != 0) { 29086e2487cSAkhil Goyal RTE_LOG(INFO, USER1, 29186e2487cSAkhil Goyal "Cipher crypto capabilities not supported\n"); 29286e2487cSAkhil Goyal return TEST_SKIPPED; 29386e2487cSAkhil Goyal } 29486e2487cSAkhil Goyal 29586e2487cSAkhil Goyal if (test_ipsec_crypto_caps_auth_verify(sec_cap, 29686e2487cSAkhil Goyal sess_conf->crypto_xform) != 0) { 29786e2487cSAkhil Goyal RTE_LOG(INFO, USER1, 29886e2487cSAkhil Goyal "Auth crypto capabilities not supported\n"); 29986e2487cSAkhil Goyal return TEST_SKIPPED; 30086e2487cSAkhil Goyal } 30186e2487cSAkhil Goyal } 30286e2487cSAkhil Goyal } 30386e2487cSAkhil Goyal 30486e2487cSAkhil Goyal if (test_ipsec_sec_caps_verify(&sess_conf->ipsec, sec_cap, false) != 0) 30586e2487cSAkhil Goyal return TEST_SKIPPED; 30686e2487cSAkhil Goyal 30786e2487cSAkhil Goyal if ((sa->ipsec_xform.direction == 30886e2487cSAkhil Goyal RTE_SECURITY_IPSEC_SA_DIR_EGRESS) && 30986e2487cSAkhil Goyal (sa->ipsec_xform.options.iv_gen_disable == 1)) { 31086e2487cSAkhil Goyal /* Set env variable when IV generation is disabled */ 31186e2487cSAkhil Goyal char arr[128]; 31286e2487cSAkhil Goyal int len = 0, j = 0; 31386e2487cSAkhil Goyal int iv_len = (sa->aead || sa->aes_gmac) ? 8 : 16; 31486e2487cSAkhil Goyal 31586e2487cSAkhil Goyal for (; j < iv_len; j++) 31686e2487cSAkhil Goyal len += snprintf(arr+len, sizeof(arr) - len, 31786e2487cSAkhil Goyal "0x%x, ", sa->iv.data[j]); 31886e2487cSAkhil Goyal setenv("ETH_SEC_IV_OVR", arr, 1); 31986e2487cSAkhil Goyal } 32086e2487cSAkhil Goyal 3213f3fc330SAkhil Goyal *sess = rte_security_session_create(sec_ctx, sess_conf, sess_pool); 32286e2487cSAkhil Goyal if (*sess == NULL) { 32386e2487cSAkhil Goyal printf("SEC Session init failed.\n"); 32486e2487cSAkhil Goyal return TEST_FAILED; 32586e2487cSAkhil Goyal } 32686e2487cSAkhil Goyal 32786e2487cSAkhil Goyal *ol_flags = sec_cap->ol_flags; 32886e2487cSAkhil Goyal *ctx = sec_ctx; 32986e2487cSAkhil Goyal 33086e2487cSAkhil Goyal return 0; 33186e2487cSAkhil Goyal } 33286e2487cSAkhil Goyal 33386e2487cSAkhil Goyal /* Check the link status of all ports in up to 3s, and print them finally */ 33486e2487cSAkhil Goyal static void 33586e2487cSAkhil Goyal check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) 33686e2487cSAkhil Goyal { 33786e2487cSAkhil Goyal #define CHECK_INTERVAL 100 /* 100ms */ 33886e2487cSAkhil Goyal #define MAX_CHECK_TIME 30 /* 3s (30 * 100ms) in total */ 33986e2487cSAkhil Goyal uint16_t portid; 34086e2487cSAkhil Goyal uint8_t count, all_ports_up, print_flag = 0; 34186e2487cSAkhil Goyal struct rte_eth_link link; 34286e2487cSAkhil Goyal int ret; 34386e2487cSAkhil Goyal char link_status[RTE_ETH_LINK_MAX_STR_LEN]; 34486e2487cSAkhil Goyal 34586e2487cSAkhil Goyal printf("Checking link statuses...\n"); 34686e2487cSAkhil Goyal fflush(stdout); 34786e2487cSAkhil Goyal for (count = 0; count <= MAX_CHECK_TIME; count++) { 34886e2487cSAkhil Goyal all_ports_up = 1; 34986e2487cSAkhil Goyal for (portid = 0; portid < port_num; portid++) { 35086e2487cSAkhil Goyal if ((port_mask & (1 << portid)) == 0) 35186e2487cSAkhil Goyal continue; 35286e2487cSAkhil Goyal memset(&link, 0, sizeof(link)); 35386e2487cSAkhil Goyal ret = rte_eth_link_get_nowait(portid, &link); 35486e2487cSAkhil Goyal if (ret < 0) { 35586e2487cSAkhil Goyal all_ports_up = 0; 35686e2487cSAkhil Goyal if (print_flag == 1) 35786e2487cSAkhil Goyal printf("Port %u link get failed: %s\n", 35886e2487cSAkhil Goyal portid, rte_strerror(-ret)); 35986e2487cSAkhil Goyal continue; 36086e2487cSAkhil Goyal } 36186e2487cSAkhil Goyal 36286e2487cSAkhil Goyal /* print link status if flag set */ 36386e2487cSAkhil Goyal if (print_flag == 1) { 36486e2487cSAkhil Goyal if (link.link_status && link_mbps == 0) 36586e2487cSAkhil Goyal link_mbps = link.link_speed; 36686e2487cSAkhil Goyal 36786e2487cSAkhil Goyal rte_eth_link_to_str(link_status, 36886e2487cSAkhil Goyal sizeof(link_status), &link); 36986e2487cSAkhil Goyal printf("Port %d %s\n", portid, link_status); 37086e2487cSAkhil Goyal continue; 37186e2487cSAkhil Goyal } 37286e2487cSAkhil Goyal /* clear all_ports_up flag if any link down */ 37386e2487cSAkhil Goyal if (link.link_status == RTE_ETH_LINK_DOWN) { 37486e2487cSAkhil Goyal all_ports_up = 0; 37586e2487cSAkhil Goyal break; 37686e2487cSAkhil Goyal } 37786e2487cSAkhil Goyal } 37886e2487cSAkhil Goyal /* after finally printing all link status, get out */ 37986e2487cSAkhil Goyal if (print_flag == 1) 38086e2487cSAkhil Goyal break; 38186e2487cSAkhil Goyal 38286e2487cSAkhil Goyal if (all_ports_up == 0) { 38386e2487cSAkhil Goyal fflush(stdout); 38486e2487cSAkhil Goyal rte_delay_ms(CHECK_INTERVAL); 38586e2487cSAkhil Goyal } 38686e2487cSAkhil Goyal 38786e2487cSAkhil Goyal /* set the print_flag if all ports up or timeout */ 38886e2487cSAkhil Goyal if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) 38986e2487cSAkhil Goyal print_flag = 1; 39086e2487cSAkhil Goyal } 39186e2487cSAkhil Goyal } 39286e2487cSAkhil Goyal 39386e2487cSAkhil Goyal static void 39486e2487cSAkhil Goyal print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr) 39586e2487cSAkhil Goyal { 39686e2487cSAkhil Goyal char buf[RTE_ETHER_ADDR_FMT_SIZE]; 39786e2487cSAkhil Goyal rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr); 39886e2487cSAkhil Goyal printf("%s%s", name, buf); 39986e2487cSAkhil Goyal } 40086e2487cSAkhil Goyal 40186e2487cSAkhil Goyal static void 40286e2487cSAkhil Goyal copy_buf_to_pkt_segs(const uint8_t *buf, unsigned int len, 40386e2487cSAkhil Goyal struct rte_mbuf *pkt, unsigned int offset) 40486e2487cSAkhil Goyal { 40586e2487cSAkhil Goyal unsigned int copied = 0; 40686e2487cSAkhil Goyal unsigned int copy_len; 40786e2487cSAkhil Goyal struct rte_mbuf *seg; 40886e2487cSAkhil Goyal void *seg_buf; 40986e2487cSAkhil Goyal 41086e2487cSAkhil Goyal seg = pkt; 41186e2487cSAkhil Goyal while (offset >= seg->data_len) { 41286e2487cSAkhil Goyal offset -= seg->data_len; 41386e2487cSAkhil Goyal seg = seg->next; 41486e2487cSAkhil Goyal } 41586e2487cSAkhil Goyal copy_len = seg->data_len - offset; 41686e2487cSAkhil Goyal seg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset); 41786e2487cSAkhil Goyal while (len > copy_len) { 41886e2487cSAkhil Goyal rte_memcpy(seg_buf, buf + copied, (size_t) copy_len); 41986e2487cSAkhil Goyal len -= copy_len; 42086e2487cSAkhil Goyal copied += copy_len; 42186e2487cSAkhil Goyal seg = seg->next; 42286e2487cSAkhil Goyal seg_buf = rte_pktmbuf_mtod(seg, void *); 42386e2487cSAkhil Goyal } 42486e2487cSAkhil Goyal rte_memcpy(seg_buf, buf + copied, (size_t) len); 42586e2487cSAkhil Goyal } 42686e2487cSAkhil Goyal 427c215f6cdSNithin Dabilpuram static bool 428c215f6cdSNithin Dabilpuram is_outer_ipv4(struct ipsec_test_data *td) 429c215f6cdSNithin Dabilpuram { 430c215f6cdSNithin Dabilpuram bool outer_ipv4; 431c215f6cdSNithin Dabilpuram 432c215f6cdSNithin Dabilpuram if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS || 433c215f6cdSNithin Dabilpuram td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT) 434c215f6cdSNithin Dabilpuram outer_ipv4 = (((td->input_text.data[0] & 0xF0) >> 4) == IPVERSION); 435c215f6cdSNithin Dabilpuram else 436c215f6cdSNithin Dabilpuram outer_ipv4 = (td->ipsec_xform.tunnel.type == RTE_SECURITY_IPSEC_TUNNEL_IPV4); 437c215f6cdSNithin Dabilpuram return outer_ipv4; 438c215f6cdSNithin Dabilpuram } 439c215f6cdSNithin Dabilpuram 44086e2487cSAkhil Goyal static inline struct rte_mbuf * 441c215f6cdSNithin Dabilpuram init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len, bool outer_ipv4) 44286e2487cSAkhil Goyal { 44386e2487cSAkhil Goyal struct rte_mbuf *pkt; 44486e2487cSAkhil Goyal 44586e2487cSAkhil Goyal pkt = rte_pktmbuf_alloc(mp); 44686e2487cSAkhil Goyal if (pkt == NULL) 44786e2487cSAkhil Goyal return NULL; 448c215f6cdSNithin Dabilpuram 449c215f6cdSNithin Dabilpuram if (outer_ipv4) { 45086e2487cSAkhil Goyal rte_memcpy(rte_pktmbuf_append(pkt, RTE_ETHER_HDR_LEN), 45186e2487cSAkhil Goyal &dummy_ipv4_eth_hdr, RTE_ETHER_HDR_LEN); 45286e2487cSAkhil Goyal pkt->l3_len = sizeof(struct rte_ipv4_hdr); 45386e2487cSAkhil Goyal } else { 45486e2487cSAkhil Goyal rte_memcpy(rte_pktmbuf_append(pkt, RTE_ETHER_HDR_LEN), 45586e2487cSAkhil Goyal &dummy_ipv6_eth_hdr, RTE_ETHER_HDR_LEN); 45686e2487cSAkhil Goyal pkt->l3_len = sizeof(struct rte_ipv6_hdr); 45786e2487cSAkhil Goyal } 45886e2487cSAkhil Goyal pkt->l2_len = RTE_ETHER_HDR_LEN; 45986e2487cSAkhil Goyal 46086e2487cSAkhil Goyal if (pkt->buf_len > (len + RTE_ETHER_HDR_LEN)) 46186e2487cSAkhil Goyal rte_memcpy(rte_pktmbuf_append(pkt, len), data, len); 46286e2487cSAkhil Goyal else 46386e2487cSAkhil Goyal copy_buf_to_pkt_segs(data, len, pkt, RTE_ETHER_HDR_LEN); 46486e2487cSAkhil Goyal return pkt; 46586e2487cSAkhil Goyal } 46686e2487cSAkhil Goyal 46786e2487cSAkhil Goyal static int 46886e2487cSAkhil Goyal init_mempools(unsigned int nb_mbuf) 46986e2487cSAkhil Goyal { 47086e2487cSAkhil Goyal struct rte_security_ctx *sec_ctx; 47186e2487cSAkhil Goyal uint16_t nb_sess = 512; 47286e2487cSAkhil Goyal uint32_t sess_sz; 47386e2487cSAkhil Goyal char s[64]; 47486e2487cSAkhil Goyal 47586e2487cSAkhil Goyal if (mbufpool == NULL) { 47686e2487cSAkhil Goyal snprintf(s, sizeof(s), "mbuf_pool"); 47786e2487cSAkhil Goyal mbufpool = rte_pktmbuf_pool_create(s, nb_mbuf, 47886e2487cSAkhil Goyal MEMPOOL_CACHE_SIZE, 0, 47986e2487cSAkhil Goyal RTE_MBUF_DEFAULT_BUF_SIZE, SOCKET_ID_ANY); 48086e2487cSAkhil Goyal if (mbufpool == NULL) { 48186e2487cSAkhil Goyal printf("Cannot init mbuf pool\n"); 48286e2487cSAkhil Goyal return TEST_FAILED; 48386e2487cSAkhil Goyal } 48486e2487cSAkhil Goyal printf("Allocated mbuf pool\n"); 48586e2487cSAkhil Goyal } 48686e2487cSAkhil Goyal 48786e2487cSAkhil Goyal sec_ctx = rte_eth_dev_get_sec_ctx(port_id); 48886e2487cSAkhil Goyal if (sec_ctx == NULL) { 48986e2487cSAkhil Goyal printf("Device does not support Security ctx\n"); 49086e2487cSAkhil Goyal return TEST_SKIPPED; 49186e2487cSAkhil Goyal } 49286e2487cSAkhil Goyal sess_sz = rte_security_session_get_size(sec_ctx); 49386e2487cSAkhil Goyal if (sess_pool == NULL) { 49486e2487cSAkhil Goyal snprintf(s, sizeof(s), "sess_pool"); 49586e2487cSAkhil Goyal sess_pool = rte_mempool_create(s, nb_sess, sess_sz, 49686e2487cSAkhil Goyal MEMPOOL_CACHE_SIZE, 0, 49786e2487cSAkhil Goyal NULL, NULL, NULL, NULL, 49886e2487cSAkhil Goyal SOCKET_ID_ANY, 0); 49986e2487cSAkhil Goyal if (sess_pool == NULL) { 50086e2487cSAkhil Goyal printf("Cannot init sess pool\n"); 50186e2487cSAkhil Goyal return TEST_FAILED; 50286e2487cSAkhil Goyal } 50386e2487cSAkhil Goyal printf("Allocated sess pool\n"); 50486e2487cSAkhil Goyal } 50586e2487cSAkhil Goyal 50686e2487cSAkhil Goyal return 0; 50786e2487cSAkhil Goyal } 50886e2487cSAkhil Goyal 50986e2487cSAkhil Goyal static int 51086e2487cSAkhil Goyal create_default_flow(uint16_t portid) 51186e2487cSAkhil Goyal { 51286e2487cSAkhil Goyal struct rte_flow_action action[2]; 51386e2487cSAkhil Goyal struct rte_flow_item pattern[2]; 51486e2487cSAkhil Goyal struct rte_flow_attr attr = {0}; 51586e2487cSAkhil Goyal struct rte_flow_error err; 51686e2487cSAkhil Goyal struct rte_flow *flow; 51786e2487cSAkhil Goyal int ret; 51886e2487cSAkhil Goyal 51986e2487cSAkhil Goyal /* Add the default rte_flow to enable SECURITY for all ESP packets */ 52086e2487cSAkhil Goyal 52186e2487cSAkhil Goyal pattern[0].type = RTE_FLOW_ITEM_TYPE_ESP; 52286e2487cSAkhil Goyal pattern[0].spec = NULL; 52386e2487cSAkhil Goyal pattern[0].mask = NULL; 52486e2487cSAkhil Goyal pattern[0].last = NULL; 52586e2487cSAkhil Goyal pattern[1].type = RTE_FLOW_ITEM_TYPE_END; 52686e2487cSAkhil Goyal 52786e2487cSAkhil Goyal action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY; 52886e2487cSAkhil Goyal action[0].conf = NULL; 52986e2487cSAkhil Goyal action[1].type = RTE_FLOW_ACTION_TYPE_END; 53086e2487cSAkhil Goyal action[1].conf = NULL; 53186e2487cSAkhil Goyal 53286e2487cSAkhil Goyal attr.ingress = 1; 53386e2487cSAkhil Goyal 53486e2487cSAkhil Goyal ret = rte_flow_validate(portid, &attr, pattern, action, &err); 53586e2487cSAkhil Goyal if (ret) { 53686e2487cSAkhil Goyal printf("\nValidate flow failed, ret = %d\n", ret); 53786e2487cSAkhil Goyal return -1; 53886e2487cSAkhil Goyal } 53986e2487cSAkhil Goyal flow = rte_flow_create(portid, &attr, pattern, action, &err); 54086e2487cSAkhil Goyal if (flow == NULL) { 54186e2487cSAkhil Goyal printf("\nDefault flow rule create failed\n"); 54286e2487cSAkhil Goyal return -1; 54386e2487cSAkhil Goyal } 54486e2487cSAkhil Goyal 54586e2487cSAkhil Goyal default_flow[portid] = flow; 54686e2487cSAkhil Goyal 54786e2487cSAkhil Goyal return 0; 54886e2487cSAkhil Goyal } 54986e2487cSAkhil Goyal 55086e2487cSAkhil Goyal static void 55186e2487cSAkhil Goyal destroy_default_flow(uint16_t portid) 55286e2487cSAkhil Goyal { 55386e2487cSAkhil Goyal struct rte_flow_error err; 55486e2487cSAkhil Goyal int ret; 55586e2487cSAkhil Goyal 55686e2487cSAkhil Goyal if (!default_flow[portid]) 55786e2487cSAkhil Goyal return; 55886e2487cSAkhil Goyal ret = rte_flow_destroy(portid, default_flow[portid], &err); 55986e2487cSAkhil Goyal if (ret) { 56086e2487cSAkhil Goyal printf("\nDefault flow rule destroy failed\n"); 56186e2487cSAkhil Goyal return; 56286e2487cSAkhil Goyal } 56386e2487cSAkhil Goyal default_flow[portid] = NULL; 56486e2487cSAkhil Goyal } 56586e2487cSAkhil Goyal 56686e2487cSAkhil Goyal struct rte_mbuf **tx_pkts_burst; 56786e2487cSAkhil Goyal struct rte_mbuf **rx_pkts_burst; 56886e2487cSAkhil Goyal 56986e2487cSAkhil Goyal static int 570a3105777SAkhil Goyal compare_pkt_data(struct rte_mbuf *m, uint8_t *ref, unsigned int tot_len) 571a3105777SAkhil Goyal { 572a3105777SAkhil Goyal unsigned int len; 573a3105777SAkhil Goyal unsigned int nb_segs = m->nb_segs; 574a3105777SAkhil Goyal unsigned int matched = 0; 575a3105777SAkhil Goyal struct rte_mbuf *save = m; 576a3105777SAkhil Goyal 577a3105777SAkhil Goyal while (m) { 578a3105777SAkhil Goyal len = tot_len; 579a3105777SAkhil Goyal if (len > m->data_len) 580a3105777SAkhil Goyal len = m->data_len; 581a3105777SAkhil Goyal if (len != 0) { 582a3105777SAkhil Goyal if (memcmp(rte_pktmbuf_mtod(m, char *), 583a3105777SAkhil Goyal ref + matched, len)) { 584a3105777SAkhil Goyal printf("\n====Reassembly case failed: Data Mismatch"); 585a3105777SAkhil Goyal rte_hexdump(stdout, "Reassembled", 586a3105777SAkhil Goyal rte_pktmbuf_mtod(m, char *), 587a3105777SAkhil Goyal len); 588a3105777SAkhil Goyal rte_hexdump(stdout, "reference", 589a3105777SAkhil Goyal ref + matched, 590a3105777SAkhil Goyal len); 591a3105777SAkhil Goyal return TEST_FAILED; 592a3105777SAkhil Goyal } 593a3105777SAkhil Goyal } 594a3105777SAkhil Goyal tot_len -= len; 595a3105777SAkhil Goyal matched += len; 596a3105777SAkhil Goyal m = m->next; 597a3105777SAkhil Goyal } 598a3105777SAkhil Goyal 599a3105777SAkhil Goyal if (tot_len) { 600a3105777SAkhil Goyal printf("\n====Reassembly case failed: Data Missing %u", 601a3105777SAkhil Goyal tot_len); 602a3105777SAkhil Goyal printf("\n====nb_segs %u, tot_len %u", nb_segs, tot_len); 603a3105777SAkhil Goyal rte_pktmbuf_dump(stderr, save, -1); 604a3105777SAkhil Goyal return TEST_FAILED; 605a3105777SAkhil Goyal } 606a3105777SAkhil Goyal return TEST_SUCCESS; 607a3105777SAkhil Goyal } 608a3105777SAkhil Goyal 609a3105777SAkhil Goyal static inline bool 610a3105777SAkhil Goyal is_ip_reassembly_incomplete(struct rte_mbuf *mbuf) 611a3105777SAkhil Goyal { 612a3105777SAkhil Goyal static uint64_t ip_reassembly_dynflag; 613a3105777SAkhil Goyal int ip_reassembly_dynflag_offset; 614a3105777SAkhil Goyal 615a3105777SAkhil Goyal if (ip_reassembly_dynflag == 0) { 616a3105777SAkhil Goyal ip_reassembly_dynflag_offset = rte_mbuf_dynflag_lookup( 617a3105777SAkhil Goyal RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME, NULL); 618a3105777SAkhil Goyal if (ip_reassembly_dynflag_offset < 0) 619a3105777SAkhil Goyal return false; 620a3105777SAkhil Goyal ip_reassembly_dynflag = RTE_BIT64(ip_reassembly_dynflag_offset); 621a3105777SAkhil Goyal } 622a3105777SAkhil Goyal 623a3105777SAkhil Goyal return (mbuf->ol_flags & ip_reassembly_dynflag) != 0; 624a3105777SAkhil Goyal } 625a3105777SAkhil Goyal 626a3105777SAkhil Goyal static void 627a3105777SAkhil Goyal free_mbuf(struct rte_mbuf *mbuf) 628a3105777SAkhil Goyal { 629a3105777SAkhil Goyal rte_eth_ip_reassembly_dynfield_t dynfield; 630a3105777SAkhil Goyal 631a3105777SAkhil Goyal if (!mbuf) 632a3105777SAkhil Goyal return; 633a3105777SAkhil Goyal 634a3105777SAkhil Goyal if (!is_ip_reassembly_incomplete(mbuf)) { 635a3105777SAkhil Goyal rte_pktmbuf_free(mbuf); 636a3105777SAkhil Goyal } else { 637a3105777SAkhil Goyal if (ip_reassembly_dynfield_offset < 0) 638a3105777SAkhil Goyal return; 639a3105777SAkhil Goyal 640a3105777SAkhil Goyal while (mbuf) { 641a3105777SAkhil Goyal dynfield = *RTE_MBUF_DYNFIELD(mbuf, 642a3105777SAkhil Goyal ip_reassembly_dynfield_offset, 643a3105777SAkhil Goyal rte_eth_ip_reassembly_dynfield_t *); 644a3105777SAkhil Goyal rte_pktmbuf_free(mbuf); 645a3105777SAkhil Goyal mbuf = dynfield.next_frag; 646a3105777SAkhil Goyal } 647a3105777SAkhil Goyal } 648a3105777SAkhil Goyal } 649a3105777SAkhil Goyal 650a3105777SAkhil Goyal 651a3105777SAkhil Goyal static int 652a3105777SAkhil Goyal get_and_verify_incomplete_frags(struct rte_mbuf *mbuf, 653a3105777SAkhil Goyal struct reassembly_vector *vector) 654a3105777SAkhil Goyal { 655a3105777SAkhil Goyal rte_eth_ip_reassembly_dynfield_t *dynfield[MAX_PKT_BURST]; 656a3105777SAkhil Goyal int j = 0, ret; 657a3105777SAkhil Goyal /** 658a3105777SAkhil Goyal * IP reassembly offload is incomplete, and fragments are listed in 659a3105777SAkhil Goyal * dynfield which can be reassembled in SW. 660a3105777SAkhil Goyal */ 661a3105777SAkhil Goyal printf("\nHW IP Reassembly is not complete; attempt SW IP Reassembly," 662a3105777SAkhil Goyal "\nMatching with original frags."); 663a3105777SAkhil Goyal 664a3105777SAkhil Goyal if (ip_reassembly_dynfield_offset < 0) 665a3105777SAkhil Goyal return -1; 666a3105777SAkhil Goyal 667a3105777SAkhil Goyal printf("\ncomparing frag: %d", j); 668a3105777SAkhil Goyal /* Skip Ethernet header comparison */ 669a3105777SAkhil Goyal rte_pktmbuf_adj(mbuf, RTE_ETHER_HDR_LEN); 670a3105777SAkhil Goyal ret = compare_pkt_data(mbuf, vector->frags[j]->data, 671a3105777SAkhil Goyal vector->frags[j]->len); 672a3105777SAkhil Goyal if (ret) 673a3105777SAkhil Goyal return ret; 674a3105777SAkhil Goyal j++; 675a3105777SAkhil Goyal dynfield[j] = RTE_MBUF_DYNFIELD(mbuf, ip_reassembly_dynfield_offset, 676a3105777SAkhil Goyal rte_eth_ip_reassembly_dynfield_t *); 677a3105777SAkhil Goyal printf("\ncomparing frag: %d", j); 678a3105777SAkhil Goyal /* Skip Ethernet header comparison */ 679a3105777SAkhil Goyal rte_pktmbuf_adj(dynfield[j]->next_frag, RTE_ETHER_HDR_LEN); 680a3105777SAkhil Goyal ret = compare_pkt_data(dynfield[j]->next_frag, vector->frags[j]->data, 681a3105777SAkhil Goyal vector->frags[j]->len); 682a3105777SAkhil Goyal if (ret) 683a3105777SAkhil Goyal return ret; 684a3105777SAkhil Goyal 685a3105777SAkhil Goyal while ((dynfield[j]->nb_frags > 1) && 686a3105777SAkhil Goyal is_ip_reassembly_incomplete(dynfield[j]->next_frag)) { 687a3105777SAkhil Goyal j++; 688a3105777SAkhil Goyal dynfield[j] = RTE_MBUF_DYNFIELD(dynfield[j-1]->next_frag, 689a3105777SAkhil Goyal ip_reassembly_dynfield_offset, 690a3105777SAkhil Goyal rte_eth_ip_reassembly_dynfield_t *); 691a3105777SAkhil Goyal printf("\ncomparing frag: %d", j); 692a3105777SAkhil Goyal /* Skip Ethernet header comparison */ 693a3105777SAkhil Goyal rte_pktmbuf_adj(dynfield[j]->next_frag, RTE_ETHER_HDR_LEN); 694a3105777SAkhil Goyal ret = compare_pkt_data(dynfield[j]->next_frag, 695a3105777SAkhil Goyal vector->frags[j]->data, vector->frags[j]->len); 696a3105777SAkhil Goyal if (ret) 697a3105777SAkhil Goyal return ret; 698a3105777SAkhil Goyal } 699a3105777SAkhil Goyal return ret; 700a3105777SAkhil Goyal } 701a3105777SAkhil Goyal 702a3105777SAkhil Goyal static int 703a3105777SAkhil Goyal test_ipsec_with_reassembly(struct reassembly_vector *vector, 704a3105777SAkhil Goyal const struct ipsec_test_flags *flags) 705a3105777SAkhil Goyal { 7062973dbf9SAkhil Goyal void *out_ses[ENCAP_DECAP_BURST_SZ] = {0}; 7072973dbf9SAkhil Goyal void *in_ses[ENCAP_DECAP_BURST_SZ] = {0}; 708a3105777SAkhil Goyal struct rte_eth_ip_reassembly_params reass_capa = {0}; 709a3105777SAkhil Goyal struct rte_security_session_conf sess_conf_out = {0}; 710a3105777SAkhil Goyal struct rte_security_session_conf sess_conf_in = {0}; 711a3105777SAkhil Goyal unsigned int nb_tx, burst_sz, nb_sent = 0; 712a3105777SAkhil Goyal struct rte_crypto_sym_xform cipher_out = {0}; 713a3105777SAkhil Goyal struct rte_crypto_sym_xform auth_out = {0}; 714a3105777SAkhil Goyal struct rte_crypto_sym_xform aead_out = {0}; 715a3105777SAkhil Goyal struct rte_crypto_sym_xform cipher_in = {0}; 716a3105777SAkhil Goyal struct rte_crypto_sym_xform auth_in = {0}; 717a3105777SAkhil Goyal struct rte_crypto_sym_xform aead_in = {0}; 718a3105777SAkhil Goyal struct ipsec_test_data sa_data; 719a3105777SAkhil Goyal struct rte_security_ctx *ctx; 720a3105777SAkhil Goyal unsigned int i, nb_rx = 0, j; 721a3105777SAkhil Goyal uint32_t ol_flags; 722c215f6cdSNithin Dabilpuram bool outer_ipv4; 723a3105777SAkhil Goyal int ret = 0; 724a3105777SAkhil Goyal 725a3105777SAkhil Goyal burst_sz = vector->burst ? ENCAP_DECAP_BURST_SZ : 1; 726a3105777SAkhil Goyal nb_tx = vector->nb_frags * burst_sz; 727a3105777SAkhil Goyal 728a3105777SAkhil Goyal rte_eth_dev_stop(port_id); 729a3105777SAkhil Goyal if (ret != 0) { 730a3105777SAkhil Goyal printf("rte_eth_dev_stop: err=%s, port=%u\n", 731a3105777SAkhil Goyal rte_strerror(-ret), port_id); 732a3105777SAkhil Goyal return ret; 733a3105777SAkhil Goyal } 734a3105777SAkhil Goyal rte_eth_ip_reassembly_capability_get(port_id, &reass_capa); 735a3105777SAkhil Goyal if (reass_capa.max_frags < vector->nb_frags) 736a3105777SAkhil Goyal return TEST_SKIPPED; 737a3105777SAkhil Goyal if (reass_capa.timeout_ms > APP_REASS_TIMEOUT) { 738a3105777SAkhil Goyal reass_capa.timeout_ms = APP_REASS_TIMEOUT; 739a3105777SAkhil Goyal rte_eth_ip_reassembly_conf_set(port_id, &reass_capa); 740a3105777SAkhil Goyal } 741a3105777SAkhil Goyal 742a3105777SAkhil Goyal ret = rte_eth_dev_start(port_id); 743a3105777SAkhil Goyal if (ret < 0) { 744a3105777SAkhil Goyal printf("rte_eth_dev_start: err=%d, port=%d\n", 745a3105777SAkhil Goyal ret, port_id); 746a3105777SAkhil Goyal return ret; 747a3105777SAkhil Goyal } 748a3105777SAkhil Goyal 749a3105777SAkhil Goyal memset(tx_pkts_burst, 0, sizeof(tx_pkts_burst[0]) * nb_tx); 750a3105777SAkhil Goyal memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_tx); 751a3105777SAkhil Goyal 752c215f6cdSNithin Dabilpuram memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data)); 753c215f6cdSNithin Dabilpuram sa_data.ipsec_xform.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS; 754c215f6cdSNithin Dabilpuram outer_ipv4 = is_outer_ipv4(&sa_data); 755c215f6cdSNithin Dabilpuram 756a3105777SAkhil Goyal for (i = 0; i < nb_tx; i += vector->nb_frags) { 757a3105777SAkhil Goyal for (j = 0; j < vector->nb_frags; j++) { 758a3105777SAkhil Goyal tx_pkts_burst[i+j] = init_packet(mbufpool, 759a3105777SAkhil Goyal vector->frags[j]->data, 760c215f6cdSNithin Dabilpuram vector->frags[j]->len, outer_ipv4); 761a3105777SAkhil Goyal if (tx_pkts_burst[i+j] == NULL) { 762a3105777SAkhil Goyal ret = -1; 763a3105777SAkhil Goyal printf("\n packed init failed\n"); 764a3105777SAkhil Goyal goto out; 765a3105777SAkhil Goyal } 766a3105777SAkhil Goyal } 767a3105777SAkhil Goyal } 768a3105777SAkhil Goyal 769a3105777SAkhil Goyal for (i = 0; i < burst_sz; i++) { 770a3105777SAkhil Goyal memcpy(&sa_data, vector->sa_data, 771a3105777SAkhil Goyal sizeof(struct ipsec_test_data)); 772a3105777SAkhil Goyal /* Update SPI for every new SA */ 773a3105777SAkhil Goyal sa_data.ipsec_xform.spi += i; 774a3105777SAkhil Goyal sa_data.ipsec_xform.direction = 775a3105777SAkhil Goyal RTE_SECURITY_IPSEC_SA_DIR_EGRESS; 776a3105777SAkhil Goyal if (sa_data.aead) { 777a3105777SAkhil Goyal sess_conf_out.crypto_xform = &aead_out; 778a3105777SAkhil Goyal } else { 779a3105777SAkhil Goyal sess_conf_out.crypto_xform = &cipher_out; 780a3105777SAkhil Goyal sess_conf_out.crypto_xform->next = &auth_out; 781a3105777SAkhil Goyal } 782a3105777SAkhil Goyal 783a3105777SAkhil Goyal /* Create Inline IPsec outbound session. */ 784a3105777SAkhil Goyal ret = create_inline_ipsec_session(&sa_data, port_id, 785a3105777SAkhil Goyal &out_ses[i], &ctx, &ol_flags, flags, 786a3105777SAkhil Goyal &sess_conf_out); 787a3105777SAkhil Goyal if (ret) { 788a3105777SAkhil Goyal printf("\nInline outbound session create failed\n"); 789a3105777SAkhil Goyal goto out; 790a3105777SAkhil Goyal } 791a3105777SAkhil Goyal } 792a3105777SAkhil Goyal 793a3105777SAkhil Goyal j = 0; 794a3105777SAkhil Goyal for (i = 0; i < nb_tx; i++) { 795a3105777SAkhil Goyal if (ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA) 796a3105777SAkhil Goyal rte_security_set_pkt_metadata(ctx, 797a3105777SAkhil Goyal out_ses[j], tx_pkts_burst[i], NULL); 798a3105777SAkhil Goyal tx_pkts_burst[i]->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD; 799a3105777SAkhil Goyal 800a3105777SAkhil Goyal /* Move to next SA after nb_frags */ 801a3105777SAkhil Goyal if ((i + 1) % vector->nb_frags == 0) 802a3105777SAkhil Goyal j++; 803a3105777SAkhil Goyal } 804a3105777SAkhil Goyal 805a3105777SAkhil Goyal for (i = 0; i < burst_sz; i++) { 806a3105777SAkhil Goyal memcpy(&sa_data, vector->sa_data, 807a3105777SAkhil Goyal sizeof(struct ipsec_test_data)); 808a3105777SAkhil Goyal /* Update SPI for every new SA */ 809a3105777SAkhil Goyal sa_data.ipsec_xform.spi += i; 810a3105777SAkhil Goyal sa_data.ipsec_xform.direction = 811a3105777SAkhil Goyal RTE_SECURITY_IPSEC_SA_DIR_INGRESS; 812a3105777SAkhil Goyal 813a3105777SAkhil Goyal if (sa_data.aead) { 814a3105777SAkhil Goyal sess_conf_in.crypto_xform = &aead_in; 815a3105777SAkhil Goyal } else { 816a3105777SAkhil Goyal sess_conf_in.crypto_xform = &auth_in; 817a3105777SAkhil Goyal sess_conf_in.crypto_xform->next = &cipher_in; 818a3105777SAkhil Goyal } 819a3105777SAkhil Goyal /* Create Inline IPsec inbound session. */ 820a3105777SAkhil Goyal ret = create_inline_ipsec_session(&sa_data, port_id, &in_ses[i], 821a3105777SAkhil Goyal &ctx, &ol_flags, flags, &sess_conf_in); 822a3105777SAkhil Goyal if (ret) { 823a3105777SAkhil Goyal printf("\nInline inbound session create failed\n"); 824a3105777SAkhil Goyal goto out; 825a3105777SAkhil Goyal } 826a3105777SAkhil Goyal } 827a3105777SAkhil Goyal 828a3105777SAkhil Goyal /* Retrieve reassembly dynfield offset if available */ 829a3105777SAkhil Goyal if (ip_reassembly_dynfield_offset < 0 && vector->nb_frags > 1) 830a3105777SAkhil Goyal ip_reassembly_dynfield_offset = rte_mbuf_dynfield_lookup( 831a3105777SAkhil Goyal RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME, NULL); 832a3105777SAkhil Goyal 833a3105777SAkhil Goyal 834a3105777SAkhil Goyal ret = create_default_flow(port_id); 835a3105777SAkhil Goyal if (ret) 836a3105777SAkhil Goyal goto out; 837a3105777SAkhil Goyal 838a3105777SAkhil Goyal nb_sent = rte_eth_tx_burst(port_id, 0, tx_pkts_burst, nb_tx); 839a3105777SAkhil Goyal if (nb_sent != nb_tx) { 840a3105777SAkhil Goyal ret = -1; 841a3105777SAkhil Goyal printf("\nFailed to tx %u pkts", nb_tx); 842a3105777SAkhil Goyal goto out; 843a3105777SAkhil Goyal } 844a3105777SAkhil Goyal 845a3105777SAkhil Goyal rte_delay_ms(1); 846a3105777SAkhil Goyal 847a3105777SAkhil Goyal /* Retry few times before giving up */ 848a3105777SAkhil Goyal nb_rx = 0; 849a3105777SAkhil Goyal j = 0; 850a3105777SAkhil Goyal do { 851a3105777SAkhil Goyal nb_rx += rte_eth_rx_burst(port_id, 0, &rx_pkts_burst[nb_rx], 852a3105777SAkhil Goyal nb_tx - nb_rx); 853a3105777SAkhil Goyal j++; 854a3105777SAkhil Goyal if (nb_rx >= nb_tx) 855a3105777SAkhil Goyal break; 856a3105777SAkhil Goyal rte_delay_ms(1); 857a3105777SAkhil Goyal } while (j < 5 || !nb_rx); 858a3105777SAkhil Goyal 859a3105777SAkhil Goyal /* Check for minimum number of Rx packets expected */ 860a3105777SAkhil Goyal if ((vector->nb_frags == 1 && nb_rx != nb_tx) || 861a3105777SAkhil Goyal (vector->nb_frags > 1 && nb_rx < burst_sz)) { 862a3105777SAkhil Goyal printf("\nreceived less Rx pkts(%u) pkts\n", nb_rx); 863a3105777SAkhil Goyal ret = TEST_FAILED; 864a3105777SAkhil Goyal goto out; 865a3105777SAkhil Goyal } 866a3105777SAkhil Goyal 867a3105777SAkhil Goyal for (i = 0; i < nb_rx; i++) { 868a3105777SAkhil Goyal if (vector->nb_frags > 1 && 869a3105777SAkhil Goyal is_ip_reassembly_incomplete(rx_pkts_burst[i])) { 870a3105777SAkhil Goyal ret = get_and_verify_incomplete_frags(rx_pkts_burst[i], 871a3105777SAkhil Goyal vector); 872a3105777SAkhil Goyal if (ret != TEST_SUCCESS) 873a3105777SAkhil Goyal break; 874a3105777SAkhil Goyal continue; 875a3105777SAkhil Goyal } 876a3105777SAkhil Goyal 877a3105777SAkhil Goyal if (rx_pkts_burst[i]->ol_flags & 878a3105777SAkhil Goyal RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED || 879a3105777SAkhil Goyal !(rx_pkts_burst[i]->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) { 880a3105777SAkhil Goyal printf("\nsecurity offload failed\n"); 881a3105777SAkhil Goyal ret = TEST_FAILED; 882a3105777SAkhil Goyal break; 883a3105777SAkhil Goyal } 884a3105777SAkhil Goyal 885a3105777SAkhil Goyal if (vector->full_pkt->len + RTE_ETHER_HDR_LEN != 886a3105777SAkhil Goyal rx_pkts_burst[i]->pkt_len) { 887a3105777SAkhil Goyal printf("\nreassembled/decrypted packet length mismatch\n"); 888a3105777SAkhil Goyal ret = TEST_FAILED; 889a3105777SAkhil Goyal break; 890a3105777SAkhil Goyal } 891a3105777SAkhil Goyal rte_pktmbuf_adj(rx_pkts_burst[i], RTE_ETHER_HDR_LEN); 892a3105777SAkhil Goyal ret = compare_pkt_data(rx_pkts_burst[i], 893a3105777SAkhil Goyal vector->full_pkt->data, 894a3105777SAkhil Goyal vector->full_pkt->len); 895a3105777SAkhil Goyal if (ret != TEST_SUCCESS) 896a3105777SAkhil Goyal break; 897a3105777SAkhil Goyal } 898a3105777SAkhil Goyal 899a3105777SAkhil Goyal out: 900a3105777SAkhil Goyal destroy_default_flow(port_id); 901a3105777SAkhil Goyal 902a3105777SAkhil Goyal /* Clear session data. */ 903a3105777SAkhil Goyal for (i = 0; i < burst_sz; i++) { 904a3105777SAkhil Goyal if (out_ses[i]) 905a3105777SAkhil Goyal rte_security_session_destroy(ctx, out_ses[i]); 906a3105777SAkhil Goyal if (in_ses[i]) 907a3105777SAkhil Goyal rte_security_session_destroy(ctx, in_ses[i]); 908a3105777SAkhil Goyal } 909a3105777SAkhil Goyal 910a3105777SAkhil Goyal for (i = nb_sent; i < nb_tx; i++) 911a3105777SAkhil Goyal free_mbuf(tx_pkts_burst[i]); 912a3105777SAkhil Goyal for (i = 0; i < nb_rx; i++) 913a3105777SAkhil Goyal free_mbuf(rx_pkts_burst[i]); 914a3105777SAkhil Goyal return ret; 915a3105777SAkhil Goyal } 916a3105777SAkhil Goyal 917a3105777SAkhil Goyal static int 91810864656SVolodymyr Fialko event_tx_burst(struct rte_mbuf **tx_pkts, uint16_t nb_pkts) 91910864656SVolodymyr Fialko { 92010864656SVolodymyr Fialko struct rte_event ev; 92110864656SVolodymyr Fialko int i, nb_sent = 0; 92210864656SVolodymyr Fialko 92310864656SVolodymyr Fialko /* Convert packets to events */ 92410864656SVolodymyr Fialko memset(&ev, 0, sizeof(ev)); 92510864656SVolodymyr Fialko ev.sched_type = RTE_SCHED_TYPE_PARALLEL; 92610864656SVolodymyr Fialko for (i = 0; i < nb_pkts; i++) { 92710864656SVolodymyr Fialko ev.mbuf = tx_pkts[i]; 92810864656SVolodymyr Fialko nb_sent += rte_event_eth_tx_adapter_enqueue( 92910864656SVolodymyr Fialko eventdev_id, port_id, &ev, 1, 0); 93010864656SVolodymyr Fialko } 93110864656SVolodymyr Fialko 93210864656SVolodymyr Fialko return nb_sent; 93310864656SVolodymyr Fialko } 93410864656SVolodymyr Fialko 93510864656SVolodymyr Fialko static int 93610864656SVolodymyr Fialko event_rx_burst(struct rte_mbuf **rx_pkts, uint16_t nb_pkts_to_rx) 93710864656SVolodymyr Fialko { 93810864656SVolodymyr Fialko int nb_ev, nb_rx = 0, j = 0; 93910864656SVolodymyr Fialko const int ms_per_pkt = 3; 94010864656SVolodymyr Fialko struct rte_event ev; 94110864656SVolodymyr Fialko 94210864656SVolodymyr Fialko do { 94310864656SVolodymyr Fialko nb_ev = rte_event_dequeue_burst(eventdev_id, port_id, 94410864656SVolodymyr Fialko &ev, 1, 0); 94510864656SVolodymyr Fialko 94610864656SVolodymyr Fialko if (nb_ev == 0) { 94710864656SVolodymyr Fialko rte_delay_ms(1); 94810864656SVolodymyr Fialko continue; 94910864656SVolodymyr Fialko } 95010864656SVolodymyr Fialko 95110864656SVolodymyr Fialko /* Get packet from event */ 95210864656SVolodymyr Fialko if (ev.event_type != RTE_EVENT_TYPE_ETHDEV) { 95310864656SVolodymyr Fialko printf("Unsupported event type: %i\n", 95410864656SVolodymyr Fialko ev.event_type); 95510864656SVolodymyr Fialko continue; 95610864656SVolodymyr Fialko } 95710864656SVolodymyr Fialko rx_pkts[nb_rx++] = ev.mbuf; 95810864656SVolodymyr Fialko } while (j++ < (nb_pkts_to_rx * ms_per_pkt) && nb_rx < nb_pkts_to_rx); 95910864656SVolodymyr Fialko 96010864656SVolodymyr Fialko return nb_rx; 96110864656SVolodymyr Fialko } 96210864656SVolodymyr Fialko 96310864656SVolodymyr Fialko static int 96434e8a9d9SVamsi Attunuru test_ipsec_inline_sa_exp_event_callback(uint16_t port_id, 96534e8a9d9SVamsi Attunuru enum rte_eth_event_type type, void *param, void *ret_param) 96634e8a9d9SVamsi Attunuru { 96734e8a9d9SVamsi Attunuru struct sa_expiry_vector *vector = (struct sa_expiry_vector *)param; 96834e8a9d9SVamsi Attunuru struct rte_eth_event_ipsec_desc *event_desc = NULL; 96934e8a9d9SVamsi Attunuru 97034e8a9d9SVamsi Attunuru RTE_SET_USED(port_id); 97134e8a9d9SVamsi Attunuru 97234e8a9d9SVamsi Attunuru if (type != RTE_ETH_EVENT_IPSEC) 97334e8a9d9SVamsi Attunuru return -1; 97434e8a9d9SVamsi Attunuru 97534e8a9d9SVamsi Attunuru event_desc = ret_param; 97634e8a9d9SVamsi Attunuru if (event_desc == NULL) { 97734e8a9d9SVamsi Attunuru printf("Event descriptor not set\n"); 97834e8a9d9SVamsi Attunuru return -1; 97934e8a9d9SVamsi Attunuru } 98034e8a9d9SVamsi Attunuru vector->notify_event = true; 98134e8a9d9SVamsi Attunuru if (event_desc->metadata != (uint64_t)vector->sa_data) { 98234e8a9d9SVamsi Attunuru printf("Mismatch in event specific metadata\n"); 98334e8a9d9SVamsi Attunuru return -1; 98434e8a9d9SVamsi Attunuru } 985ff8ef86cSVamsi Attunuru switch (event_desc->subtype) { 986ff8ef86cSVamsi Attunuru case RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY: 98734e8a9d9SVamsi Attunuru vector->event = RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY; 988ff8ef86cSVamsi Attunuru break; 989ff8ef86cSVamsi Attunuru case RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY: 99034e8a9d9SVamsi Attunuru vector->event = RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY; 991ff8ef86cSVamsi Attunuru break; 992ff8ef86cSVamsi Attunuru case RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY: 993ff8ef86cSVamsi Attunuru vector->event = RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY; 994ff8ef86cSVamsi Attunuru break; 995ff8ef86cSVamsi Attunuru case RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY: 996ff8ef86cSVamsi Attunuru vector->event = RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY; 997ff8ef86cSVamsi Attunuru break; 998ff8ef86cSVamsi Attunuru default: 99934e8a9d9SVamsi Attunuru printf("Invalid IPsec event reported\n"); 100034e8a9d9SVamsi Attunuru return -1; 100134e8a9d9SVamsi Attunuru } 100234e8a9d9SVamsi Attunuru 1003ff8ef86cSVamsi Attunuru return 0; 100434e8a9d9SVamsi Attunuru } 100534e8a9d9SVamsi Attunuru 100634e8a9d9SVamsi Attunuru static enum rte_eth_event_ipsec_subtype 100734e8a9d9SVamsi Attunuru test_ipsec_inline_setup_expiry_vector(struct sa_expiry_vector *vector, 100834e8a9d9SVamsi Attunuru const struct ipsec_test_flags *flags, 100934e8a9d9SVamsi Attunuru struct ipsec_test_data *tdata) 101034e8a9d9SVamsi Attunuru { 101134e8a9d9SVamsi Attunuru enum rte_eth_event_ipsec_subtype event = RTE_ETH_EVENT_IPSEC_UNKNOWN; 101234e8a9d9SVamsi Attunuru 101334e8a9d9SVamsi Attunuru vector->event = RTE_ETH_EVENT_IPSEC_UNKNOWN; 101434e8a9d9SVamsi Attunuru vector->notify_event = false; 101534e8a9d9SVamsi Attunuru vector->sa_data = (void *)tdata; 101634e8a9d9SVamsi Attunuru if (flags->sa_expiry_pkts_soft) 101734e8a9d9SVamsi Attunuru event = RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY; 1018ff8ef86cSVamsi Attunuru else if (flags->sa_expiry_bytes_soft) 101934e8a9d9SVamsi Attunuru event = RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY; 1020ff8ef86cSVamsi Attunuru else if (flags->sa_expiry_pkts_hard) 1021ff8ef86cSVamsi Attunuru event = RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY; 1022ff8ef86cSVamsi Attunuru else 1023ff8ef86cSVamsi Attunuru event = RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY; 102434e8a9d9SVamsi Attunuru rte_eth_dev_callback_register(port_id, RTE_ETH_EVENT_IPSEC, 102534e8a9d9SVamsi Attunuru test_ipsec_inline_sa_exp_event_callback, vector); 102634e8a9d9SVamsi Attunuru 102734e8a9d9SVamsi Attunuru return event; 102834e8a9d9SVamsi Attunuru } 102934e8a9d9SVamsi Attunuru 103034e8a9d9SVamsi Attunuru static int 103186e2487cSAkhil Goyal test_ipsec_inline_proto_process(struct ipsec_test_data *td, 103286e2487cSAkhil Goyal struct ipsec_test_data *res_d, 103386e2487cSAkhil Goyal int nb_pkts, 103486e2487cSAkhil Goyal bool silent, 103586e2487cSAkhil Goyal const struct ipsec_test_flags *flags) 103686e2487cSAkhil Goyal { 103734e8a9d9SVamsi Attunuru enum rte_eth_event_ipsec_subtype event = RTE_ETH_EVENT_IPSEC_UNKNOWN; 103886e2487cSAkhil Goyal struct rte_security_session_conf sess_conf = {0}; 103986e2487cSAkhil Goyal struct rte_crypto_sym_xform cipher = {0}; 104086e2487cSAkhil Goyal struct rte_crypto_sym_xform auth = {0}; 104186e2487cSAkhil Goyal struct rte_crypto_sym_xform aead = {0}; 104234e8a9d9SVamsi Attunuru struct sa_expiry_vector vector = {0}; 104386e2487cSAkhil Goyal struct rte_security_ctx *ctx; 104486e2487cSAkhil Goyal int nb_rx = 0, nb_sent; 104586e2487cSAkhil Goyal uint32_t ol_flags; 104686e2487cSAkhil Goyal int i, j = 0, ret; 1047c215f6cdSNithin Dabilpuram bool outer_ipv4; 10482973dbf9SAkhil Goyal void *ses; 104986e2487cSAkhil Goyal 105086e2487cSAkhil Goyal memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_pkts); 105186e2487cSAkhil Goyal 1052ff8ef86cSVamsi Attunuru if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft || 1053ff8ef86cSVamsi Attunuru flags->sa_expiry_pkts_hard || flags->sa_expiry_bytes_hard) { 105434e8a9d9SVamsi Attunuru if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) 105534e8a9d9SVamsi Attunuru return TEST_SUCCESS; 105634e8a9d9SVamsi Attunuru event = test_ipsec_inline_setup_expiry_vector(&vector, flags, td); 105734e8a9d9SVamsi Attunuru } 105834e8a9d9SVamsi Attunuru 105986e2487cSAkhil Goyal if (td->aead) { 106086e2487cSAkhil Goyal sess_conf.crypto_xform = &aead; 106186e2487cSAkhil Goyal } else { 106286e2487cSAkhil Goyal if (td->ipsec_xform.direction == 106386e2487cSAkhil Goyal RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { 106486e2487cSAkhil Goyal sess_conf.crypto_xform = &cipher; 106586e2487cSAkhil Goyal sess_conf.crypto_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER; 106686e2487cSAkhil Goyal sess_conf.crypto_xform->next = &auth; 106786e2487cSAkhil Goyal sess_conf.crypto_xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH; 106886e2487cSAkhil Goyal } else { 106986e2487cSAkhil Goyal sess_conf.crypto_xform = &auth; 107086e2487cSAkhil Goyal sess_conf.crypto_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH; 107186e2487cSAkhil Goyal sess_conf.crypto_xform->next = &cipher; 107286e2487cSAkhil Goyal sess_conf.crypto_xform->next->type = RTE_CRYPTO_SYM_XFORM_CIPHER; 107386e2487cSAkhil Goyal } 107486e2487cSAkhil Goyal } 107586e2487cSAkhil Goyal 107686e2487cSAkhil Goyal /* Create Inline IPsec session. */ 107786e2487cSAkhil Goyal ret = create_inline_ipsec_session(td, port_id, &ses, &ctx, 107886e2487cSAkhil Goyal &ol_flags, flags, &sess_conf); 107986e2487cSAkhil Goyal if (ret) 108086e2487cSAkhil Goyal return ret; 108186e2487cSAkhil Goyal 108286e2487cSAkhil Goyal if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) { 108386e2487cSAkhil Goyal ret = create_default_flow(port_id); 108486e2487cSAkhil Goyal if (ret) 108586e2487cSAkhil Goyal goto out; 108686e2487cSAkhil Goyal } 1087c215f6cdSNithin Dabilpuram outer_ipv4 = is_outer_ipv4(td); 1088c215f6cdSNithin Dabilpuram 108986e2487cSAkhil Goyal for (i = 0; i < nb_pkts; i++) { 109086e2487cSAkhil Goyal tx_pkts_burst[i] = init_packet(mbufpool, td->input_text.data, 1091c215f6cdSNithin Dabilpuram td->input_text.len, outer_ipv4); 109286e2487cSAkhil Goyal if (tx_pkts_burst[i] == NULL) { 109386e2487cSAkhil Goyal while (i--) 109486e2487cSAkhil Goyal rte_pktmbuf_free(tx_pkts_burst[i]); 109586e2487cSAkhil Goyal ret = TEST_FAILED; 109686e2487cSAkhil Goyal goto out; 109786e2487cSAkhil Goyal } 109886e2487cSAkhil Goyal 109986e2487cSAkhil Goyal if (test_ipsec_pkt_update(rte_pktmbuf_mtod_offset(tx_pkts_burst[i], 110086e2487cSAkhil Goyal uint8_t *, RTE_ETHER_HDR_LEN), flags)) { 110186e2487cSAkhil Goyal while (i--) 110286e2487cSAkhil Goyal rte_pktmbuf_free(tx_pkts_burst[i]); 110386e2487cSAkhil Goyal ret = TEST_FAILED; 110486e2487cSAkhil Goyal goto out; 110586e2487cSAkhil Goyal } 110686e2487cSAkhil Goyal 110786e2487cSAkhil Goyal if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { 110886e2487cSAkhil Goyal if (ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA) 110986e2487cSAkhil Goyal rte_security_set_pkt_metadata(ctx, ses, 111086e2487cSAkhil Goyal tx_pkts_burst[i], NULL); 111186e2487cSAkhil Goyal tx_pkts_burst[i]->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD; 111286e2487cSAkhil Goyal } 111386e2487cSAkhil Goyal } 111486e2487cSAkhil Goyal /* Send packet to ethdev for inline IPsec processing. */ 111510864656SVolodymyr Fialko if (event_mode_enabled) 111610864656SVolodymyr Fialko nb_sent = event_tx_burst(tx_pkts_burst, nb_pkts); 111710864656SVolodymyr Fialko else 111886e2487cSAkhil Goyal nb_sent = rte_eth_tx_burst(port_id, 0, tx_pkts_burst, nb_pkts); 111910864656SVolodymyr Fialko 112086e2487cSAkhil Goyal if (nb_sent != nb_pkts) { 112110864656SVolodymyr Fialko printf("\nUnable to TX %d packets, sent: %i", nb_pkts, nb_sent); 112286e2487cSAkhil Goyal for ( ; nb_sent < nb_pkts; nb_sent++) 112386e2487cSAkhil Goyal rte_pktmbuf_free(tx_pkts_burst[nb_sent]); 112486e2487cSAkhil Goyal ret = TEST_FAILED; 112586e2487cSAkhil Goyal goto out; 112686e2487cSAkhil Goyal } 112786e2487cSAkhil Goyal 112886e2487cSAkhil Goyal rte_pause(); 112986e2487cSAkhil Goyal 113086e2487cSAkhil Goyal /* Receive back packet on loopback interface. */ 113110864656SVolodymyr Fialko if (event_mode_enabled) 113210864656SVolodymyr Fialko nb_rx = event_rx_burst(rx_pkts_burst, nb_sent); 113310864656SVolodymyr Fialko else 113486e2487cSAkhil Goyal do { 113586e2487cSAkhil Goyal rte_delay_ms(1); 113610864656SVolodymyr Fialko nb_rx += rte_eth_rx_burst(port_id, 0, 113710864656SVolodymyr Fialko &rx_pkts_burst[nb_rx], 113886e2487cSAkhil Goyal nb_sent - nb_rx); 113986e2487cSAkhil Goyal if (nb_rx >= nb_sent) 114086e2487cSAkhil Goyal break; 114186e2487cSAkhil Goyal } while (j++ < 5 || nb_rx == 0); 114286e2487cSAkhil Goyal 1143ff8ef86cSVamsi Attunuru if (!flags->sa_expiry_pkts_hard && 1144ff8ef86cSVamsi Attunuru !flags->sa_expiry_bytes_hard && 1145ff8ef86cSVamsi Attunuru (nb_rx != nb_sent)) { 114610864656SVolodymyr Fialko printf("\nUnable to RX all %d packets, received(%i)", 114710864656SVolodymyr Fialko nb_sent, nb_rx); 114810864656SVolodymyr Fialko while (--nb_rx >= 0) 114986e2487cSAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[nb_rx]); 115086e2487cSAkhil Goyal ret = TEST_FAILED; 115186e2487cSAkhil Goyal goto out; 115286e2487cSAkhil Goyal } 115386e2487cSAkhil Goyal 115486e2487cSAkhil Goyal for (i = 0; i < nb_rx; i++) { 115586e2487cSAkhil Goyal rte_pktmbuf_adj(rx_pkts_burst[i], RTE_ETHER_HDR_LEN); 115686e2487cSAkhil Goyal 115786e2487cSAkhil Goyal ret = test_ipsec_post_process(rx_pkts_burst[i], td, 115886e2487cSAkhil Goyal res_d, silent, flags); 115986e2487cSAkhil Goyal if (ret != TEST_SUCCESS) { 116086e2487cSAkhil Goyal for ( ; i < nb_rx; i++) 116186e2487cSAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[i]); 116286e2487cSAkhil Goyal goto out; 116386e2487cSAkhil Goyal } 116486e2487cSAkhil Goyal 116586e2487cSAkhil Goyal ret = test_ipsec_stats_verify(ctx, ses, flags, 116686e2487cSAkhil Goyal td->ipsec_xform.direction); 116786e2487cSAkhil Goyal if (ret != TEST_SUCCESS) { 116886e2487cSAkhil Goyal for ( ; i < nb_rx; i++) 116986e2487cSAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[i]); 117086e2487cSAkhil Goyal goto out; 117186e2487cSAkhil Goyal } 117286e2487cSAkhil Goyal 117386e2487cSAkhil Goyal rte_pktmbuf_free(rx_pkts_burst[i]); 117486e2487cSAkhil Goyal rx_pkts_burst[i] = NULL; 117586e2487cSAkhil Goyal } 117686e2487cSAkhil Goyal 117786e2487cSAkhil Goyal out: 117886e2487cSAkhil Goyal if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) 117986e2487cSAkhil Goyal destroy_default_flow(port_id); 1180ff8ef86cSVamsi Attunuru if (flags->sa_expiry_pkts_soft || flags->sa_expiry_bytes_soft || 1181ff8ef86cSVamsi Attunuru flags->sa_expiry_pkts_hard || flags->sa_expiry_bytes_hard) { 118234e8a9d9SVamsi Attunuru if (vector.notify_event && (vector.event == event)) 118334e8a9d9SVamsi Attunuru ret = TEST_SUCCESS; 118434e8a9d9SVamsi Attunuru else 118534e8a9d9SVamsi Attunuru ret = TEST_FAILED; 118634e8a9d9SVamsi Attunuru 118734e8a9d9SVamsi Attunuru rte_eth_dev_callback_unregister(port_id, RTE_ETH_EVENT_IPSEC, 118834e8a9d9SVamsi Attunuru test_ipsec_inline_sa_exp_event_callback, &vector); 118934e8a9d9SVamsi Attunuru } 119086e2487cSAkhil Goyal 119186e2487cSAkhil Goyal /* Destroy session so that other cases can create the session again */ 119286e2487cSAkhil Goyal rte_security_session_destroy(ctx, ses); 119386e2487cSAkhil Goyal ses = NULL; 119486e2487cSAkhil Goyal 119586e2487cSAkhil Goyal return ret; 119686e2487cSAkhil Goyal } 119786e2487cSAkhil Goyal 119886e2487cSAkhil Goyal static int 119978dc764eSAkhil Goyal test_ipsec_inline_proto_all(const struct ipsec_test_flags *flags) 120078dc764eSAkhil Goyal { 120178dc764eSAkhil Goyal struct ipsec_test_data td_outb; 120278dc764eSAkhil Goyal struct ipsec_test_data td_inb; 120378dc764eSAkhil Goyal unsigned int i, nb_pkts = 1, pass_cnt = 0, fail_cnt = 0; 120478dc764eSAkhil Goyal int ret; 120578dc764eSAkhil Goyal 120678dc764eSAkhil Goyal if (flags->iv_gen || flags->sa_expiry_pkts_soft || 120734e8a9d9SVamsi Attunuru flags->sa_expiry_bytes_soft || 1208ff8ef86cSVamsi Attunuru flags->sa_expiry_bytes_hard || 120978dc764eSAkhil Goyal flags->sa_expiry_pkts_hard) 121078dc764eSAkhil Goyal nb_pkts = IPSEC_TEST_PACKETS_MAX; 121178dc764eSAkhil Goyal 121278dc764eSAkhil Goyal for (i = 0; i < RTE_DIM(alg_list); i++) { 121378dc764eSAkhil Goyal test_ipsec_td_prepare(alg_list[i].param1, 121478dc764eSAkhil Goyal alg_list[i].param2, 121578dc764eSAkhil Goyal flags, &td_outb, 1); 121678dc764eSAkhil Goyal 121778dc764eSAkhil Goyal if (!td_outb.aead) { 121878dc764eSAkhil Goyal enum rte_crypto_cipher_algorithm cipher_alg; 121978dc764eSAkhil Goyal enum rte_crypto_auth_algorithm auth_alg; 122078dc764eSAkhil Goyal 122178dc764eSAkhil Goyal cipher_alg = td_outb.xform.chain.cipher.cipher.algo; 122278dc764eSAkhil Goyal auth_alg = td_outb.xform.chain.auth.auth.algo; 122378dc764eSAkhil Goyal 122478dc764eSAkhil Goyal if (td_outb.aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL) 122578dc764eSAkhil Goyal continue; 122678dc764eSAkhil Goyal 122778dc764eSAkhil Goyal /* ICV is not applicable for NULL auth */ 122878dc764eSAkhil Goyal if (flags->icv_corrupt && 122978dc764eSAkhil Goyal auth_alg == RTE_CRYPTO_AUTH_NULL) 123078dc764eSAkhil Goyal continue; 123178dc764eSAkhil Goyal 123278dc764eSAkhil Goyal /* IV is not applicable for NULL cipher */ 123378dc764eSAkhil Goyal if (flags->iv_gen && 123478dc764eSAkhil Goyal cipher_alg == RTE_CRYPTO_CIPHER_NULL) 123578dc764eSAkhil Goyal continue; 123678dc764eSAkhil Goyal } 123778dc764eSAkhil Goyal 123878dc764eSAkhil Goyal if (flags->udp_encap) 123978dc764eSAkhil Goyal td_outb.ipsec_xform.options.udp_encap = 1; 124078dc764eSAkhil Goyal 124134e8a9d9SVamsi Attunuru if (flags->sa_expiry_bytes_soft) 124234e8a9d9SVamsi Attunuru td_outb.ipsec_xform.life.bytes_soft_limit = 124334e8a9d9SVamsi Attunuru (((td_outb.output_text.len + RTE_ETHER_HDR_LEN) 124434e8a9d9SVamsi Attunuru * nb_pkts) >> 3) - 1; 1245ff8ef86cSVamsi Attunuru if (flags->sa_expiry_pkts_hard) 1246ff8ef86cSVamsi Attunuru td_outb.ipsec_xform.life.packets_hard_limit = 1247ff8ef86cSVamsi Attunuru IPSEC_TEST_PACKETS_MAX - 1; 1248ff8ef86cSVamsi Attunuru if (flags->sa_expiry_bytes_hard) 1249ff8ef86cSVamsi Attunuru td_outb.ipsec_xform.life.bytes_hard_limit = 1250ff8ef86cSVamsi Attunuru (((td_outb.output_text.len + RTE_ETHER_HDR_LEN) 1251ff8ef86cSVamsi Attunuru * nb_pkts) >> 3) - 1; 125234e8a9d9SVamsi Attunuru 125378dc764eSAkhil Goyal ret = test_ipsec_inline_proto_process(&td_outb, &td_inb, nb_pkts, 125478dc764eSAkhil Goyal false, flags); 125578dc764eSAkhil Goyal if (ret == TEST_SKIPPED) 125678dc764eSAkhil Goyal continue; 125778dc764eSAkhil Goyal 125878dc764eSAkhil Goyal if (ret == TEST_FAILED) { 125978dc764eSAkhil Goyal printf("\n TEST FAILED"); 126078dc764eSAkhil Goyal test_ipsec_display_alg(alg_list[i].param1, 126178dc764eSAkhil Goyal alg_list[i].param2); 126278dc764eSAkhil Goyal fail_cnt++; 126378dc764eSAkhil Goyal continue; 126478dc764eSAkhil Goyal } 126578dc764eSAkhil Goyal 126678dc764eSAkhil Goyal test_ipsec_td_update(&td_inb, &td_outb, 1, flags); 126778dc764eSAkhil Goyal 126878dc764eSAkhil Goyal ret = test_ipsec_inline_proto_process(&td_inb, NULL, nb_pkts, 126978dc764eSAkhil Goyal false, flags); 127078dc764eSAkhil Goyal if (ret == TEST_SKIPPED) 127178dc764eSAkhil Goyal continue; 127278dc764eSAkhil Goyal 127378dc764eSAkhil Goyal if (ret == TEST_FAILED) { 127478dc764eSAkhil Goyal printf("\n TEST FAILED"); 127578dc764eSAkhil Goyal test_ipsec_display_alg(alg_list[i].param1, 127678dc764eSAkhil Goyal alg_list[i].param2); 127778dc764eSAkhil Goyal fail_cnt++; 127878dc764eSAkhil Goyal continue; 127978dc764eSAkhil Goyal } 128078dc764eSAkhil Goyal 128178dc764eSAkhil Goyal if (flags->display_alg) 128278dc764eSAkhil Goyal test_ipsec_display_alg(alg_list[i].param1, 128378dc764eSAkhil Goyal alg_list[i].param2); 128478dc764eSAkhil Goyal 128578dc764eSAkhil Goyal pass_cnt++; 128678dc764eSAkhil Goyal } 128778dc764eSAkhil Goyal 128878dc764eSAkhil Goyal printf("Tests passed: %d, failed: %d", pass_cnt, fail_cnt); 128978dc764eSAkhil Goyal if (fail_cnt > 0) 129078dc764eSAkhil Goyal return TEST_FAILED; 129178dc764eSAkhil Goyal if (pass_cnt > 0) 129278dc764eSAkhil Goyal return TEST_SUCCESS; 129378dc764eSAkhil Goyal else 129478dc764eSAkhil Goyal return TEST_SKIPPED; 129578dc764eSAkhil Goyal } 129678dc764eSAkhil Goyal 1297fd33d9eeSAkhil Goyal static int 1298fd33d9eeSAkhil Goyal test_ipsec_inline_proto_process_with_esn(struct ipsec_test_data td[], 1299fd33d9eeSAkhil Goyal struct ipsec_test_data res_d[], 1300fd33d9eeSAkhil Goyal int nb_pkts, 1301fd33d9eeSAkhil Goyal bool silent, 1302fd33d9eeSAkhil Goyal const struct ipsec_test_flags *flags) 1303fd33d9eeSAkhil Goyal { 1304fd33d9eeSAkhil Goyal struct rte_security_session_conf sess_conf = {0}; 1305fd33d9eeSAkhil Goyal struct ipsec_test_data *res_d_tmp = NULL; 1306fd33d9eeSAkhil Goyal struct rte_crypto_sym_xform cipher = {0}; 1307fd33d9eeSAkhil Goyal struct rte_crypto_sym_xform auth = {0}; 1308fd33d9eeSAkhil Goyal struct rte_crypto_sym_xform aead = {0}; 1309fd33d9eeSAkhil Goyal struct rte_mbuf *rx_pkt = NULL; 1310fd33d9eeSAkhil Goyal struct rte_mbuf *tx_pkt = NULL; 1311fd33d9eeSAkhil Goyal int nb_rx, nb_sent; 13122973dbf9SAkhil Goyal void *ses; 1313fd33d9eeSAkhil Goyal struct rte_security_ctx *ctx; 1314fd33d9eeSAkhil Goyal uint32_t ol_flags; 1315c215f6cdSNithin Dabilpuram bool outer_ipv4; 1316fd33d9eeSAkhil Goyal int i, ret; 1317fd33d9eeSAkhil Goyal 1318fd33d9eeSAkhil Goyal if (td[0].aead) { 1319fd33d9eeSAkhil Goyal sess_conf.crypto_xform = &aead; 1320fd33d9eeSAkhil Goyal } else { 1321fd33d9eeSAkhil Goyal if (td[0].ipsec_xform.direction == 1322fd33d9eeSAkhil Goyal RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { 1323fd33d9eeSAkhil Goyal sess_conf.crypto_xform = &cipher; 1324fd33d9eeSAkhil Goyal sess_conf.crypto_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER; 1325fd33d9eeSAkhil Goyal sess_conf.crypto_xform->next = &auth; 1326fd33d9eeSAkhil Goyal sess_conf.crypto_xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH; 1327fd33d9eeSAkhil Goyal } else { 1328fd33d9eeSAkhil Goyal sess_conf.crypto_xform = &auth; 1329fd33d9eeSAkhil Goyal sess_conf.crypto_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH; 1330fd33d9eeSAkhil Goyal sess_conf.crypto_xform->next = &cipher; 1331fd33d9eeSAkhil Goyal sess_conf.crypto_xform->next->type = RTE_CRYPTO_SYM_XFORM_CIPHER; 1332fd33d9eeSAkhil Goyal } 1333fd33d9eeSAkhil Goyal } 1334fd33d9eeSAkhil Goyal 1335fd33d9eeSAkhil Goyal /* Create Inline IPsec session. */ 1336fd33d9eeSAkhil Goyal ret = create_inline_ipsec_session(&td[0], port_id, &ses, &ctx, 1337fd33d9eeSAkhil Goyal &ol_flags, flags, &sess_conf); 1338fd33d9eeSAkhil Goyal if (ret) 1339fd33d9eeSAkhil Goyal return ret; 1340fd33d9eeSAkhil Goyal 1341fd33d9eeSAkhil Goyal if (td[0].ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) { 1342fd33d9eeSAkhil Goyal ret = create_default_flow(port_id); 1343fd33d9eeSAkhil Goyal if (ret) 1344fd33d9eeSAkhil Goyal goto out; 1345fd33d9eeSAkhil Goyal } 1346c215f6cdSNithin Dabilpuram outer_ipv4 = is_outer_ipv4(td); 1347fd33d9eeSAkhil Goyal 1348fd33d9eeSAkhil Goyal for (i = 0; i < nb_pkts; i++) { 1349fd33d9eeSAkhil Goyal tx_pkt = init_packet(mbufpool, td[i].input_text.data, 1350c215f6cdSNithin Dabilpuram td[i].input_text.len, outer_ipv4); 1351fd33d9eeSAkhil Goyal if (tx_pkt == NULL) { 1352fd33d9eeSAkhil Goyal ret = TEST_FAILED; 1353fd33d9eeSAkhil Goyal goto out; 1354fd33d9eeSAkhil Goyal } 1355fd33d9eeSAkhil Goyal 1356fd33d9eeSAkhil Goyal if (test_ipsec_pkt_update(rte_pktmbuf_mtod_offset(tx_pkt, 1357fd33d9eeSAkhil Goyal uint8_t *, RTE_ETHER_HDR_LEN), flags)) { 1358fd33d9eeSAkhil Goyal ret = TEST_FAILED; 1359fd33d9eeSAkhil Goyal goto out; 1360fd33d9eeSAkhil Goyal } 1361fd33d9eeSAkhil Goyal 1362fd33d9eeSAkhil Goyal if (td[i].ipsec_xform.direction == 1363fd33d9eeSAkhil Goyal RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { 1364fd33d9eeSAkhil Goyal if (flags->antireplay) { 1365fd33d9eeSAkhil Goyal sess_conf.ipsec.esn.value = 1366fd33d9eeSAkhil Goyal td[i].ipsec_xform.esn.value; 1367fd33d9eeSAkhil Goyal ret = rte_security_session_update(ctx, ses, 1368fd33d9eeSAkhil Goyal &sess_conf); 1369fd33d9eeSAkhil Goyal if (ret) { 1370fd33d9eeSAkhil Goyal printf("Could not update ESN in session\n"); 1371fd33d9eeSAkhil Goyal rte_pktmbuf_free(tx_pkt); 1372fd33d9eeSAkhil Goyal ret = TEST_SKIPPED; 1373fd33d9eeSAkhil Goyal goto out; 1374fd33d9eeSAkhil Goyal } 1375fd33d9eeSAkhil Goyal } 1376fd33d9eeSAkhil Goyal if (ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA) 1377fd33d9eeSAkhil Goyal rte_security_set_pkt_metadata(ctx, ses, 1378fd33d9eeSAkhil Goyal tx_pkt, NULL); 1379fd33d9eeSAkhil Goyal tx_pkt->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD; 1380fd33d9eeSAkhil Goyal } 1381fd33d9eeSAkhil Goyal /* Send packet to ethdev for inline IPsec processing. */ 1382fd33d9eeSAkhil Goyal nb_sent = rte_eth_tx_burst(port_id, 0, &tx_pkt, 1); 1383fd33d9eeSAkhil Goyal if (nb_sent != 1) { 1384fd33d9eeSAkhil Goyal printf("\nUnable to TX packets"); 1385fd33d9eeSAkhil Goyal rte_pktmbuf_free(tx_pkt); 1386fd33d9eeSAkhil Goyal ret = TEST_FAILED; 1387fd33d9eeSAkhil Goyal goto out; 1388fd33d9eeSAkhil Goyal } 1389fd33d9eeSAkhil Goyal 1390fd33d9eeSAkhil Goyal rte_pause(); 1391fd33d9eeSAkhil Goyal 1392fd33d9eeSAkhil Goyal /* Receive back packet on loopback interface. */ 1393fd33d9eeSAkhil Goyal do { 1394fd33d9eeSAkhil Goyal rte_delay_ms(1); 1395fd33d9eeSAkhil Goyal nb_rx = rte_eth_rx_burst(port_id, 0, &rx_pkt, 1); 1396fd33d9eeSAkhil Goyal } while (nb_rx == 0); 1397fd33d9eeSAkhil Goyal 1398fd33d9eeSAkhil Goyal rte_pktmbuf_adj(rx_pkt, RTE_ETHER_HDR_LEN); 1399fd33d9eeSAkhil Goyal 1400fd33d9eeSAkhil Goyal if (res_d != NULL) 1401fd33d9eeSAkhil Goyal res_d_tmp = &res_d[i]; 1402fd33d9eeSAkhil Goyal 1403fd33d9eeSAkhil Goyal ret = test_ipsec_post_process(rx_pkt, &td[i], 1404fd33d9eeSAkhil Goyal res_d_tmp, silent, flags); 1405fd33d9eeSAkhil Goyal if (ret != TEST_SUCCESS) { 1406fd33d9eeSAkhil Goyal rte_pktmbuf_free(rx_pkt); 1407fd33d9eeSAkhil Goyal goto out; 1408fd33d9eeSAkhil Goyal } 1409fd33d9eeSAkhil Goyal 1410fd33d9eeSAkhil Goyal ret = test_ipsec_stats_verify(ctx, ses, flags, 1411fd33d9eeSAkhil Goyal td->ipsec_xform.direction); 1412fd33d9eeSAkhil Goyal if (ret != TEST_SUCCESS) { 1413fd33d9eeSAkhil Goyal rte_pktmbuf_free(rx_pkt); 1414fd33d9eeSAkhil Goyal goto out; 1415fd33d9eeSAkhil Goyal } 1416fd33d9eeSAkhil Goyal 1417fd33d9eeSAkhil Goyal rte_pktmbuf_free(rx_pkt); 1418fd33d9eeSAkhil Goyal rx_pkt = NULL; 1419fd33d9eeSAkhil Goyal tx_pkt = NULL; 1420fd33d9eeSAkhil Goyal } 1421fd33d9eeSAkhil Goyal 1422fd33d9eeSAkhil Goyal out: 1423fd33d9eeSAkhil Goyal if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) 1424fd33d9eeSAkhil Goyal destroy_default_flow(port_id); 1425fd33d9eeSAkhil Goyal 1426fd33d9eeSAkhil Goyal /* Destroy session so that other cases can create the session again */ 1427fd33d9eeSAkhil Goyal rte_security_session_destroy(ctx, ses); 1428fd33d9eeSAkhil Goyal ses = NULL; 1429fd33d9eeSAkhil Goyal 1430fd33d9eeSAkhil Goyal return ret; 1431fd33d9eeSAkhil Goyal } 143278dc764eSAkhil Goyal 143378dc764eSAkhil Goyal static int 143486e2487cSAkhil Goyal ut_setup_inline_ipsec(void) 143586e2487cSAkhil Goyal { 143686e2487cSAkhil Goyal int ret; 143786e2487cSAkhil Goyal 143886e2487cSAkhil Goyal /* Start device */ 143986e2487cSAkhil Goyal ret = rte_eth_dev_start(port_id); 144086e2487cSAkhil Goyal if (ret < 0) { 144186e2487cSAkhil Goyal printf("rte_eth_dev_start: err=%d, port=%d\n", 144286e2487cSAkhil Goyal ret, port_id); 144386e2487cSAkhil Goyal return ret; 144486e2487cSAkhil Goyal } 144586e2487cSAkhil Goyal /* always enable promiscuous */ 144686e2487cSAkhil Goyal ret = rte_eth_promiscuous_enable(port_id); 144786e2487cSAkhil Goyal if (ret != 0) { 144886e2487cSAkhil Goyal printf("rte_eth_promiscuous_enable: err=%s, port=%d\n", 144986e2487cSAkhil Goyal rte_strerror(-ret), port_id); 145086e2487cSAkhil Goyal return ret; 145186e2487cSAkhil Goyal } 145286e2487cSAkhil Goyal 145386e2487cSAkhil Goyal check_all_ports_link_status(1, RTE_PORT_ALL); 145486e2487cSAkhil Goyal 145586e2487cSAkhil Goyal return 0; 145686e2487cSAkhil Goyal } 145786e2487cSAkhil Goyal 145886e2487cSAkhil Goyal static void 145986e2487cSAkhil Goyal ut_teardown_inline_ipsec(void) 146086e2487cSAkhil Goyal { 1461a3105777SAkhil Goyal struct rte_eth_ip_reassembly_params reass_conf = {0}; 146286e2487cSAkhil Goyal uint16_t portid; 146386e2487cSAkhil Goyal int ret; 146486e2487cSAkhil Goyal 146586e2487cSAkhil Goyal /* port tear down */ 146686e2487cSAkhil Goyal RTE_ETH_FOREACH_DEV(portid) { 146786e2487cSAkhil Goyal ret = rte_eth_dev_stop(portid); 146886e2487cSAkhil Goyal if (ret != 0) 146986e2487cSAkhil Goyal printf("rte_eth_dev_stop: err=%s, port=%u\n", 147086e2487cSAkhil Goyal rte_strerror(-ret), portid); 1471a3105777SAkhil Goyal 1472a3105777SAkhil Goyal /* Clear reassembly configuration */ 1473a3105777SAkhil Goyal rte_eth_ip_reassembly_conf_set(portid, &reass_conf); 147486e2487cSAkhil Goyal } 147586e2487cSAkhil Goyal } 147686e2487cSAkhil Goyal 147786e2487cSAkhil Goyal static int 147886e2487cSAkhil Goyal inline_ipsec_testsuite_setup(void) 147986e2487cSAkhil Goyal { 148086e2487cSAkhil Goyal uint16_t nb_rxd; 148186e2487cSAkhil Goyal uint16_t nb_txd; 148286e2487cSAkhil Goyal uint16_t nb_ports; 148386e2487cSAkhil Goyal int ret; 148486e2487cSAkhil Goyal uint16_t nb_rx_queue = 1, nb_tx_queue = 1; 148586e2487cSAkhil Goyal 148686e2487cSAkhil Goyal printf("Start inline IPsec test.\n"); 148786e2487cSAkhil Goyal 148886e2487cSAkhil Goyal nb_ports = rte_eth_dev_count_avail(); 148986e2487cSAkhil Goyal if (nb_ports < NB_ETHPORTS_USED) { 149086e2487cSAkhil Goyal printf("At least %u port(s) used for test\n", 149186e2487cSAkhil Goyal NB_ETHPORTS_USED); 149286e2487cSAkhil Goyal return TEST_SKIPPED; 149386e2487cSAkhil Goyal } 149486e2487cSAkhil Goyal 149586e2487cSAkhil Goyal ret = init_mempools(NB_MBUF); 149686e2487cSAkhil Goyal if (ret) 149786e2487cSAkhil Goyal return ret; 149886e2487cSAkhil Goyal 149986e2487cSAkhil Goyal if (tx_pkts_burst == NULL) { 150086e2487cSAkhil Goyal tx_pkts_burst = (struct rte_mbuf **)rte_calloc("tx_buff", 150186e2487cSAkhil Goyal MAX_TRAFFIC_BURST, 150286e2487cSAkhil Goyal sizeof(void *), 150386e2487cSAkhil Goyal RTE_CACHE_LINE_SIZE); 150486e2487cSAkhil Goyal if (!tx_pkts_burst) 150586e2487cSAkhil Goyal return TEST_FAILED; 150686e2487cSAkhil Goyal 150786e2487cSAkhil Goyal rx_pkts_burst = (struct rte_mbuf **)rte_calloc("rx_buff", 150886e2487cSAkhil Goyal MAX_TRAFFIC_BURST, 150986e2487cSAkhil Goyal sizeof(void *), 151086e2487cSAkhil Goyal RTE_CACHE_LINE_SIZE); 151186e2487cSAkhil Goyal if (!rx_pkts_burst) 151286e2487cSAkhil Goyal return TEST_FAILED; 151386e2487cSAkhil Goyal } 151486e2487cSAkhil Goyal 151586e2487cSAkhil Goyal printf("Generate %d packets\n", MAX_TRAFFIC_BURST); 151686e2487cSAkhil Goyal 15174ed89049SDavid Marchand nb_rxd = RX_DESC_DEFAULT; 15184ed89049SDavid Marchand nb_txd = TX_DESC_DEFAULT; 151986e2487cSAkhil Goyal 152086e2487cSAkhil Goyal /* configuring port 0 for the test is enough */ 152186e2487cSAkhil Goyal port_id = 0; 152286e2487cSAkhil Goyal /* port configure */ 152386e2487cSAkhil Goyal ret = rte_eth_dev_configure(port_id, nb_rx_queue, 152486e2487cSAkhil Goyal nb_tx_queue, &port_conf); 152586e2487cSAkhil Goyal if (ret < 0) { 152686e2487cSAkhil Goyal printf("Cannot configure device: err=%d, port=%d\n", 152786e2487cSAkhil Goyal ret, port_id); 152886e2487cSAkhil Goyal return ret; 152986e2487cSAkhil Goyal } 153086e2487cSAkhil Goyal ret = rte_eth_macaddr_get(port_id, &ports_eth_addr[port_id]); 153186e2487cSAkhil Goyal if (ret < 0) { 153286e2487cSAkhil Goyal printf("Cannot get mac address: err=%d, port=%d\n", 153386e2487cSAkhil Goyal ret, port_id); 153486e2487cSAkhil Goyal return ret; 153586e2487cSAkhil Goyal } 153686e2487cSAkhil Goyal printf("Port %u ", port_id); 153786e2487cSAkhil Goyal print_ethaddr("Address:", &ports_eth_addr[port_id]); 153886e2487cSAkhil Goyal printf("\n"); 153986e2487cSAkhil Goyal 154086e2487cSAkhil Goyal /* tx queue setup */ 154186e2487cSAkhil Goyal ret = rte_eth_tx_queue_setup(port_id, 0, nb_txd, 154286e2487cSAkhil Goyal SOCKET_ID_ANY, &tx_conf); 154386e2487cSAkhil Goyal if (ret < 0) { 154486e2487cSAkhil Goyal printf("rte_eth_tx_queue_setup: err=%d, port=%d\n", 154586e2487cSAkhil Goyal ret, port_id); 154686e2487cSAkhil Goyal return ret; 154786e2487cSAkhil Goyal } 154886e2487cSAkhil Goyal /* rx queue steup */ 154986e2487cSAkhil Goyal ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd, SOCKET_ID_ANY, 155086e2487cSAkhil Goyal &rx_conf, mbufpool); 155186e2487cSAkhil Goyal if (ret < 0) { 155286e2487cSAkhil Goyal printf("rte_eth_rx_queue_setup: err=%d, port=%d\n", 155386e2487cSAkhil Goyal ret, port_id); 155486e2487cSAkhil Goyal return ret; 155586e2487cSAkhil Goyal } 155686e2487cSAkhil Goyal test_ipsec_alg_list_populate(); 155786e2487cSAkhil Goyal 155886e2487cSAkhil Goyal return 0; 155986e2487cSAkhil Goyal } 156086e2487cSAkhil Goyal 156186e2487cSAkhil Goyal static void 156286e2487cSAkhil Goyal inline_ipsec_testsuite_teardown(void) 156386e2487cSAkhil Goyal { 156486e2487cSAkhil Goyal uint16_t portid; 156586e2487cSAkhil Goyal int ret; 156686e2487cSAkhil Goyal 156786e2487cSAkhil Goyal /* port tear down */ 156886e2487cSAkhil Goyal RTE_ETH_FOREACH_DEV(portid) { 156986e2487cSAkhil Goyal ret = rte_eth_dev_reset(portid); 157086e2487cSAkhil Goyal if (ret != 0) 157186e2487cSAkhil Goyal printf("rte_eth_dev_reset: err=%s, port=%u\n", 157286e2487cSAkhil Goyal rte_strerror(-ret), port_id); 157386e2487cSAkhil Goyal } 157410864656SVolodymyr Fialko rte_free(tx_pkts_burst); 157510864656SVolodymyr Fialko rte_free(rx_pkts_burst); 157610864656SVolodymyr Fialko } 157710864656SVolodymyr Fialko 157810864656SVolodymyr Fialko static int 157910864656SVolodymyr Fialko event_inline_ipsec_testsuite_setup(void) 158010864656SVolodymyr Fialko { 158110864656SVolodymyr Fialko struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0}; 158210864656SVolodymyr Fialko struct rte_event_dev_info evdev_default_conf = {0}; 158310864656SVolodymyr Fialko struct rte_event_dev_config eventdev_conf = {0}; 158410864656SVolodymyr Fialko struct rte_event_queue_conf eventq_conf = {0}; 158510864656SVolodymyr Fialko struct rte_event_port_conf ev_port_conf = {0}; 158610864656SVolodymyr Fialko const uint16_t nb_txd = 1024, nb_rxd = 1024; 158710864656SVolodymyr Fialko uint16_t nb_rx_queue = 1, nb_tx_queue = 1; 158810864656SVolodymyr Fialko uint8_t ev_queue_id = 0, tx_queue_id = 0; 158910864656SVolodymyr Fialko int nb_eventqueue = 1, nb_eventport = 1; 159010864656SVolodymyr Fialko const int all_queues = -1; 159110864656SVolodymyr Fialko uint32_t caps = 0; 159210864656SVolodymyr Fialko uint16_t nb_ports; 159310864656SVolodymyr Fialko int ret; 159410864656SVolodymyr Fialko 159510864656SVolodymyr Fialko printf("Start event inline IPsec test.\n"); 159610864656SVolodymyr Fialko 159710864656SVolodymyr Fialko nb_ports = rte_eth_dev_count_avail(); 159810864656SVolodymyr Fialko if (nb_ports == 0) { 159910864656SVolodymyr Fialko printf("Test require: 1 port, available: 0\n"); 160010864656SVolodymyr Fialko return TEST_SKIPPED; 160110864656SVolodymyr Fialko } 160210864656SVolodymyr Fialko 160310864656SVolodymyr Fialko init_mempools(NB_MBUF); 160410864656SVolodymyr Fialko 160510864656SVolodymyr Fialko if (tx_pkts_burst == NULL) { 160610864656SVolodymyr Fialko tx_pkts_burst = (struct rte_mbuf **)rte_calloc("tx_buff", 160710864656SVolodymyr Fialko MAX_TRAFFIC_BURST, 160810864656SVolodymyr Fialko sizeof(void *), 160910864656SVolodymyr Fialko RTE_CACHE_LINE_SIZE); 161010864656SVolodymyr Fialko if (!tx_pkts_burst) 161110864656SVolodymyr Fialko return -1; 161210864656SVolodymyr Fialko 161310864656SVolodymyr Fialko rx_pkts_burst = (struct rte_mbuf **)rte_calloc("rx_buff", 161410864656SVolodymyr Fialko MAX_TRAFFIC_BURST, 161510864656SVolodymyr Fialko sizeof(void *), 161610864656SVolodymyr Fialko RTE_CACHE_LINE_SIZE); 161710864656SVolodymyr Fialko if (!rx_pkts_burst) 161810864656SVolodymyr Fialko return -1; 161910864656SVolodymyr Fialko 162010864656SVolodymyr Fialko } 162110864656SVolodymyr Fialko 162210864656SVolodymyr Fialko printf("Generate %d packets\n", MAX_TRAFFIC_BURST); 162310864656SVolodymyr Fialko 162410864656SVolodymyr Fialko /* configuring port 0 for the test is enough */ 162510864656SVolodymyr Fialko port_id = 0; 162610864656SVolodymyr Fialko /* port configure */ 162710864656SVolodymyr Fialko ret = rte_eth_dev_configure(port_id, nb_rx_queue, 162810864656SVolodymyr Fialko nb_tx_queue, &port_conf); 162910864656SVolodymyr Fialko if (ret < 0) { 163010864656SVolodymyr Fialko printf("Cannot configure device: err=%d, port=%d\n", 163110864656SVolodymyr Fialko ret, port_id); 163210864656SVolodymyr Fialko return ret; 163310864656SVolodymyr Fialko } 163410864656SVolodymyr Fialko 163510864656SVolodymyr Fialko /* Tx queue setup */ 163610864656SVolodymyr Fialko ret = rte_eth_tx_queue_setup(port_id, 0, nb_txd, 163710864656SVolodymyr Fialko SOCKET_ID_ANY, &tx_conf); 163810864656SVolodymyr Fialko if (ret < 0) { 163910864656SVolodymyr Fialko printf("rte_eth_tx_queue_setup: err=%d, port=%d\n", 164010864656SVolodymyr Fialko ret, port_id); 164110864656SVolodymyr Fialko return ret; 164210864656SVolodymyr Fialko } 164310864656SVolodymyr Fialko 164410864656SVolodymyr Fialko /* rx queue steup */ 164510864656SVolodymyr Fialko ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd, SOCKET_ID_ANY, 164610864656SVolodymyr Fialko &rx_conf, mbufpool); 164710864656SVolodymyr Fialko if (ret < 0) { 164810864656SVolodymyr Fialko printf("rte_eth_rx_queue_setup: err=%d, port=%d\n", 164910864656SVolodymyr Fialko ret, port_id); 165010864656SVolodymyr Fialko return ret; 165110864656SVolodymyr Fialko } 165210864656SVolodymyr Fialko 165310864656SVolodymyr Fialko /* Setup eventdev */ 165410864656SVolodymyr Fialko eventdev_id = 0; 165510864656SVolodymyr Fialko rx_adapter_id = 0; 165610864656SVolodymyr Fialko tx_adapter_id = 0; 165710864656SVolodymyr Fialko 165810864656SVolodymyr Fialko /* Get default conf of eventdev */ 165910864656SVolodymyr Fialko ret = rte_event_dev_info_get(eventdev_id, &evdev_default_conf); 166010864656SVolodymyr Fialko if (ret < 0) { 166110864656SVolodymyr Fialko printf("Error in getting event device info[devID:%d]\n", 166210864656SVolodymyr Fialko eventdev_id); 166310864656SVolodymyr Fialko return ret; 166410864656SVolodymyr Fialko } 166510864656SVolodymyr Fialko 166610864656SVolodymyr Fialko /* Get Tx adapter capabilities */ 166710864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_caps_get(eventdev_id, tx_adapter_id, &caps); 166810864656SVolodymyr Fialko if (ret < 0) { 166910864656SVolodymyr Fialko printf("Failed to get event device %d eth tx adapter" 167010864656SVolodymyr Fialko " capabilities for port %d\n", 167110864656SVolodymyr Fialko eventdev_id, port_id); 167210864656SVolodymyr Fialko return ret; 167310864656SVolodymyr Fialko } 167410864656SVolodymyr Fialko if (!(caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT)) 167510864656SVolodymyr Fialko tx_queue_id = nb_eventqueue++; 167610864656SVolodymyr Fialko 167710864656SVolodymyr Fialko eventdev_conf.nb_events_limit = 167810864656SVolodymyr Fialko evdev_default_conf.max_num_events; 167910864656SVolodymyr Fialko eventdev_conf.nb_event_queue_flows = 168010864656SVolodymyr Fialko evdev_default_conf.max_event_queue_flows; 168110864656SVolodymyr Fialko eventdev_conf.nb_event_port_dequeue_depth = 168210864656SVolodymyr Fialko evdev_default_conf.max_event_port_dequeue_depth; 168310864656SVolodymyr Fialko eventdev_conf.nb_event_port_enqueue_depth = 168410864656SVolodymyr Fialko evdev_default_conf.max_event_port_enqueue_depth; 168510864656SVolodymyr Fialko 168610864656SVolodymyr Fialko eventdev_conf.nb_event_queues = nb_eventqueue; 168710864656SVolodymyr Fialko eventdev_conf.nb_event_ports = nb_eventport; 168810864656SVolodymyr Fialko 168910864656SVolodymyr Fialko /* Configure event device */ 169010864656SVolodymyr Fialko 169110864656SVolodymyr Fialko ret = rte_event_dev_configure(eventdev_id, &eventdev_conf); 169210864656SVolodymyr Fialko if (ret < 0) { 169310864656SVolodymyr Fialko printf("Error in configuring event device\n"); 169410864656SVolodymyr Fialko return ret; 169510864656SVolodymyr Fialko } 169610864656SVolodymyr Fialko 169710864656SVolodymyr Fialko /* Configure event queue */ 169810864656SVolodymyr Fialko eventq_conf.schedule_type = RTE_SCHED_TYPE_PARALLEL; 169910864656SVolodymyr Fialko eventq_conf.nb_atomic_flows = 1024; 170010864656SVolodymyr Fialko eventq_conf.nb_atomic_order_sequences = 1024; 170110864656SVolodymyr Fialko 170210864656SVolodymyr Fialko /* Setup the queue */ 170310864656SVolodymyr Fialko ret = rte_event_queue_setup(eventdev_id, ev_queue_id, &eventq_conf); 170410864656SVolodymyr Fialko if (ret < 0) { 170510864656SVolodymyr Fialko printf("Failed to setup event queue %d\n", ret); 170610864656SVolodymyr Fialko return ret; 170710864656SVolodymyr Fialko } 170810864656SVolodymyr Fialko 170910864656SVolodymyr Fialko /* Configure event port */ 171010864656SVolodymyr Fialko ret = rte_event_port_setup(eventdev_id, port_id, NULL); 171110864656SVolodymyr Fialko if (ret < 0) { 171210864656SVolodymyr Fialko printf("Failed to setup event port %d\n", ret); 171310864656SVolodymyr Fialko return ret; 171410864656SVolodymyr Fialko } 171510864656SVolodymyr Fialko 171610864656SVolodymyr Fialko /* Make event queue - event port link */ 171710864656SVolodymyr Fialko ret = rte_event_port_link(eventdev_id, port_id, NULL, NULL, 1); 171810864656SVolodymyr Fialko if (ret < 0) { 171910864656SVolodymyr Fialko printf("Failed to link event port %d\n", ret); 172010864656SVolodymyr Fialko return ret; 172110864656SVolodymyr Fialko } 172210864656SVolodymyr Fialko 172310864656SVolodymyr Fialko /* Setup port conf */ 172410864656SVolodymyr Fialko ev_port_conf.new_event_threshold = 1200; 172510864656SVolodymyr Fialko ev_port_conf.dequeue_depth = 172610864656SVolodymyr Fialko evdev_default_conf.max_event_port_dequeue_depth; 172710864656SVolodymyr Fialko ev_port_conf.enqueue_depth = 172810864656SVolodymyr Fialko evdev_default_conf.max_event_port_enqueue_depth; 172910864656SVolodymyr Fialko 173010864656SVolodymyr Fialko /* Create Rx adapter */ 173110864656SVolodymyr Fialko ret = rte_event_eth_rx_adapter_create(rx_adapter_id, eventdev_id, 173210864656SVolodymyr Fialko &ev_port_conf); 173310864656SVolodymyr Fialko if (ret < 0) { 173410864656SVolodymyr Fialko printf("Failed to create rx adapter %d\n", ret); 173510864656SVolodymyr Fialko return ret; 173610864656SVolodymyr Fialko } 173710864656SVolodymyr Fialko 173810864656SVolodymyr Fialko /* Setup queue conf */ 173910864656SVolodymyr Fialko queue_conf.ev.queue_id = ev_queue_id; 174010864656SVolodymyr Fialko queue_conf.ev.sched_type = RTE_SCHED_TYPE_PARALLEL; 174110864656SVolodymyr Fialko queue_conf.ev.event_type = RTE_EVENT_TYPE_ETHDEV; 174210864656SVolodymyr Fialko 174310864656SVolodymyr Fialko /* Add queue to the adapter */ 174410864656SVolodymyr Fialko ret = rte_event_eth_rx_adapter_queue_add(rx_adapter_id, port_id, 174510864656SVolodymyr Fialko all_queues, &queue_conf); 174610864656SVolodymyr Fialko if (ret < 0) { 174710864656SVolodymyr Fialko printf("Failed to add eth queue to rx adapter %d\n", ret); 174810864656SVolodymyr Fialko return ret; 174910864656SVolodymyr Fialko } 175010864656SVolodymyr Fialko 175110864656SVolodymyr Fialko /* Start rx adapter */ 175210864656SVolodymyr Fialko ret = rte_event_eth_rx_adapter_start(rx_adapter_id); 175310864656SVolodymyr Fialko if (ret < 0) { 175410864656SVolodymyr Fialko printf("Failed to start rx adapter %d\n", ret); 175510864656SVolodymyr Fialko return ret; 175610864656SVolodymyr Fialko } 175710864656SVolodymyr Fialko 175810864656SVolodymyr Fialko /* Create tx adapter */ 175910864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_create(tx_adapter_id, eventdev_id, 176010864656SVolodymyr Fialko &ev_port_conf); 176110864656SVolodymyr Fialko if (ret < 0) { 176210864656SVolodymyr Fialko printf("Failed to create tx adapter %d\n", ret); 176310864656SVolodymyr Fialko return ret; 176410864656SVolodymyr Fialko } 176510864656SVolodymyr Fialko 176610864656SVolodymyr Fialko /* Add queue to the adapter */ 176710864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_queue_add(tx_adapter_id, port_id, 176810864656SVolodymyr Fialko all_queues); 176910864656SVolodymyr Fialko if (ret < 0) { 177010864656SVolodymyr Fialko printf("Failed to add eth queue to tx adapter %d\n", ret); 177110864656SVolodymyr Fialko return ret; 177210864656SVolodymyr Fialko } 177310864656SVolodymyr Fialko /* Setup Tx queue & port */ 177410864656SVolodymyr Fialko if (tx_queue_id) { 177510864656SVolodymyr Fialko /* Setup the queue */ 177610864656SVolodymyr Fialko ret = rte_event_queue_setup(eventdev_id, tx_queue_id, 177710864656SVolodymyr Fialko &eventq_conf); 177810864656SVolodymyr Fialko if (ret < 0) { 177910864656SVolodymyr Fialko printf("Failed to setup tx event queue %d\n", ret); 178010864656SVolodymyr Fialko return ret; 178110864656SVolodymyr Fialko } 178210864656SVolodymyr Fialko /* Link Tx event queue to Tx port */ 178310864656SVolodymyr Fialko ret = rte_event_port_link(eventdev_id, port_id, 178410864656SVolodymyr Fialko &tx_queue_id, NULL, 1); 178510864656SVolodymyr Fialko if (ret != 1) { 178610864656SVolodymyr Fialko printf("Failed to link event queue to port\n"); 178710864656SVolodymyr Fialko return ret; 178810864656SVolodymyr Fialko } 178910864656SVolodymyr Fialko } 179010864656SVolodymyr Fialko 179110864656SVolodymyr Fialko /* Start tx adapter */ 179210864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_start(tx_adapter_id); 179310864656SVolodymyr Fialko if (ret < 0) { 179410864656SVolodymyr Fialko printf("Failed to start tx adapter %d\n", ret); 179510864656SVolodymyr Fialko return ret; 179610864656SVolodymyr Fialko } 179710864656SVolodymyr Fialko 179810864656SVolodymyr Fialko /* Start eventdev */ 179910864656SVolodymyr Fialko ret = rte_event_dev_start(eventdev_id); 180010864656SVolodymyr Fialko if (ret < 0) { 180110864656SVolodymyr Fialko printf("Failed to start event device %d\n", ret); 180210864656SVolodymyr Fialko return ret; 180310864656SVolodymyr Fialko } 180410864656SVolodymyr Fialko 180510864656SVolodymyr Fialko event_mode_enabled = true; 180610864656SVolodymyr Fialko test_ipsec_alg_list_populate(); 180710864656SVolodymyr Fialko 180810864656SVolodymyr Fialko return 0; 180910864656SVolodymyr Fialko } 181010864656SVolodymyr Fialko 181110864656SVolodymyr Fialko static void 181210864656SVolodymyr Fialko event_inline_ipsec_testsuite_teardown(void) 181310864656SVolodymyr Fialko { 181410864656SVolodymyr Fialko uint16_t portid; 181510864656SVolodymyr Fialko int ret; 181610864656SVolodymyr Fialko 181710864656SVolodymyr Fialko event_mode_enabled = false; 181810864656SVolodymyr Fialko 181910864656SVolodymyr Fialko /* Stop and release rx adapter */ 182010864656SVolodymyr Fialko ret = rte_event_eth_rx_adapter_stop(rx_adapter_id); 182110864656SVolodymyr Fialko if (ret < 0) 182210864656SVolodymyr Fialko printf("Failed to stop rx adapter %d\n", ret); 182310864656SVolodymyr Fialko ret = rte_event_eth_rx_adapter_queue_del(rx_adapter_id, port_id, -1); 182410864656SVolodymyr Fialko if (ret < 0) 182510864656SVolodymyr Fialko printf("Failed to remove rx adapter queues %d\n", ret); 182610864656SVolodymyr Fialko ret = rte_event_eth_rx_adapter_free(rx_adapter_id); 182710864656SVolodymyr Fialko if (ret < 0) 182810864656SVolodymyr Fialko printf("Failed to free rx adapter %d\n", ret); 182910864656SVolodymyr Fialko 183010864656SVolodymyr Fialko /* Stop and release tx adapter */ 183110864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_stop(tx_adapter_id); 183210864656SVolodymyr Fialko if (ret < 0) 183310864656SVolodymyr Fialko printf("Failed to stop tx adapter %d\n", ret); 183410864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_queue_del(tx_adapter_id, port_id, -1); 183510864656SVolodymyr Fialko if (ret < 0) 183610864656SVolodymyr Fialko printf("Failed to remove tx adapter queues %d\n", ret); 183710864656SVolodymyr Fialko ret = rte_event_eth_tx_adapter_free(tx_adapter_id); 183810864656SVolodymyr Fialko if (ret < 0) 183910864656SVolodymyr Fialko printf("Failed to free tx adapter %d\n", ret); 184010864656SVolodymyr Fialko 184110864656SVolodymyr Fialko /* Stop and release event devices */ 184210864656SVolodymyr Fialko rte_event_dev_stop(eventdev_id); 184310864656SVolodymyr Fialko ret = rte_event_dev_close(eventdev_id); 184410864656SVolodymyr Fialko if (ret < 0) 184510864656SVolodymyr Fialko printf("Failed to close event dev %d, %d\n", eventdev_id, ret); 184610864656SVolodymyr Fialko 184710864656SVolodymyr Fialko /* port tear down */ 184810864656SVolodymyr Fialko RTE_ETH_FOREACH_DEV(portid) { 184910864656SVolodymyr Fialko ret = rte_eth_dev_reset(portid); 185010864656SVolodymyr Fialko if (ret != 0) 185110864656SVolodymyr Fialko printf("rte_eth_dev_reset: err=%s, port=%u\n", 185210864656SVolodymyr Fialko rte_strerror(-ret), port_id); 185310864656SVolodymyr Fialko } 185410864656SVolodymyr Fialko 185510864656SVolodymyr Fialko rte_free(tx_pkts_burst); 185610864656SVolodymyr Fialko rte_free(rx_pkts_burst); 185786e2487cSAkhil Goyal } 185886e2487cSAkhil Goyal 185986e2487cSAkhil Goyal static int 1860a3105777SAkhil Goyal test_inline_ip_reassembly(const void *testdata) 1861a3105777SAkhil Goyal { 1862a3105777SAkhil Goyal struct reassembly_vector reassembly_td = {0}; 1863a3105777SAkhil Goyal const struct reassembly_vector *td = testdata; 1864a3105777SAkhil Goyal struct ip_reassembly_test_packet full_pkt; 1865a3105777SAkhil Goyal struct ip_reassembly_test_packet frags[MAX_FRAGS]; 1866a3105777SAkhil Goyal struct ipsec_test_flags flags = {0}; 1867a3105777SAkhil Goyal int i = 0; 1868a3105777SAkhil Goyal 1869a3105777SAkhil Goyal reassembly_td.sa_data = td->sa_data; 1870a3105777SAkhil Goyal reassembly_td.nb_frags = td->nb_frags; 1871a3105777SAkhil Goyal reassembly_td.burst = td->burst; 1872a3105777SAkhil Goyal 1873a3105777SAkhil Goyal memcpy(&full_pkt, td->full_pkt, 1874a3105777SAkhil Goyal sizeof(struct ip_reassembly_test_packet)); 1875a3105777SAkhil Goyal reassembly_td.full_pkt = &full_pkt; 1876a3105777SAkhil Goyal 1877a3105777SAkhil Goyal test_vector_payload_populate(reassembly_td.full_pkt, true); 1878a3105777SAkhil Goyal for (; i < reassembly_td.nb_frags; i++) { 1879a3105777SAkhil Goyal memcpy(&frags[i], td->frags[i], 1880a3105777SAkhil Goyal sizeof(struct ip_reassembly_test_packet)); 1881a3105777SAkhil Goyal reassembly_td.frags[i] = &frags[i]; 1882a3105777SAkhil Goyal test_vector_payload_populate(reassembly_td.frags[i], 1883a3105777SAkhil Goyal (i == 0) ? true : false); 1884a3105777SAkhil Goyal } 1885a3105777SAkhil Goyal 1886a3105777SAkhil Goyal return test_ipsec_with_reassembly(&reassembly_td, &flags); 1887a3105777SAkhil Goyal } 1888a3105777SAkhil Goyal 1889a3105777SAkhil Goyal static int 189086e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec(const void *test_data) 189186e2487cSAkhil Goyal { 189286e2487cSAkhil Goyal struct ipsec_test_data td_outb; 189386e2487cSAkhil Goyal struct ipsec_test_flags flags; 189486e2487cSAkhil Goyal 189586e2487cSAkhil Goyal memset(&flags, 0, sizeof(flags)); 189686e2487cSAkhil Goyal 189786e2487cSAkhil Goyal memcpy(&td_outb, test_data, sizeof(td_outb)); 189886e2487cSAkhil Goyal 189986e2487cSAkhil Goyal if (td_outb.aead || 190086e2487cSAkhil Goyal td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL) { 190186e2487cSAkhil Goyal /* Disable IV gen to be able to test with known vectors */ 190286e2487cSAkhil Goyal td_outb.ipsec_xform.options.iv_gen_disable = 1; 190386e2487cSAkhil Goyal } 190486e2487cSAkhil Goyal 190586e2487cSAkhil Goyal return test_ipsec_inline_proto_process(&td_outb, NULL, 1, 190686e2487cSAkhil Goyal false, &flags); 190786e2487cSAkhil Goyal } 190886e2487cSAkhil Goyal 19091c015ddeSAkhil Goyal static int 19101c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb(const void *test_data) 19111c015ddeSAkhil Goyal { 19121c015ddeSAkhil Goyal const struct ipsec_test_data *td = test_data; 19131c015ddeSAkhil Goyal struct ipsec_test_flags flags; 19141c015ddeSAkhil Goyal struct ipsec_test_data td_inb; 19151c015ddeSAkhil Goyal 19161c015ddeSAkhil Goyal memset(&flags, 0, sizeof(flags)); 19171c015ddeSAkhil Goyal 19181c015ddeSAkhil Goyal if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) 19191c015ddeSAkhil Goyal test_ipsec_td_in_from_out(td, &td_inb); 19201c015ddeSAkhil Goyal else 19211c015ddeSAkhil Goyal memcpy(&td_inb, td, sizeof(td_inb)); 19221c015ddeSAkhil Goyal 19231c015ddeSAkhil Goyal return test_ipsec_inline_proto_process(&td_inb, NULL, 1, false, &flags); 19241c015ddeSAkhil Goyal } 19251c015ddeSAkhil Goyal 192678dc764eSAkhil Goyal static int 192778dc764eSAkhil Goyal test_ipsec_inline_proto_display_list(const void *data __rte_unused) 192878dc764eSAkhil Goyal { 192978dc764eSAkhil Goyal struct ipsec_test_flags flags; 193078dc764eSAkhil Goyal 193178dc764eSAkhil Goyal memset(&flags, 0, sizeof(flags)); 193278dc764eSAkhil Goyal 193378dc764eSAkhil Goyal flags.display_alg = true; 193478dc764eSAkhil Goyal 193578dc764eSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 193678dc764eSAkhil Goyal } 19371c015ddeSAkhil Goyal 1938eb3e17ecSAkhil Goyal static int 1939eb3e17ecSAkhil Goyal test_ipsec_inline_proto_udp_encap(const void *data __rte_unused) 1940eb3e17ecSAkhil Goyal { 1941eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 1942eb3e17ecSAkhil Goyal 1943eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 1944eb3e17ecSAkhil Goyal 1945eb3e17ecSAkhil Goyal flags.udp_encap = true; 1946eb3e17ecSAkhil Goyal 1947eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 1948eb3e17ecSAkhil Goyal } 1949eb3e17ecSAkhil Goyal 1950eb3e17ecSAkhil Goyal static int 1951eb3e17ecSAkhil Goyal test_ipsec_inline_proto_udp_ports_verify(const void *data __rte_unused) 1952eb3e17ecSAkhil Goyal { 1953eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 1954eb3e17ecSAkhil Goyal 1955eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 1956eb3e17ecSAkhil Goyal 1957eb3e17ecSAkhil Goyal flags.udp_encap = true; 1958eb3e17ecSAkhil Goyal flags.udp_ports_verify = true; 1959eb3e17ecSAkhil Goyal 1960eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 1961eb3e17ecSAkhil Goyal } 1962eb3e17ecSAkhil Goyal 1963eb3e17ecSAkhil Goyal static int 1964eb3e17ecSAkhil Goyal test_ipsec_inline_proto_err_icv_corrupt(const void *data __rte_unused) 1965eb3e17ecSAkhil Goyal { 1966eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 1967eb3e17ecSAkhil Goyal 1968eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 1969eb3e17ecSAkhil Goyal 1970eb3e17ecSAkhil Goyal flags.icv_corrupt = true; 1971eb3e17ecSAkhil Goyal 1972eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 1973eb3e17ecSAkhil Goyal } 1974eb3e17ecSAkhil Goyal 1975eb3e17ecSAkhil Goyal static int 1976eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_dst_addr_verify(const void *data __rte_unused) 1977eb3e17ecSAkhil Goyal { 1978eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 1979eb3e17ecSAkhil Goyal 1980eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 1981eb3e17ecSAkhil Goyal 1982eb3e17ecSAkhil Goyal flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR; 1983eb3e17ecSAkhil Goyal 1984eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 1985eb3e17ecSAkhil Goyal } 1986eb3e17ecSAkhil Goyal 1987eb3e17ecSAkhil Goyal static int 1988eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused) 1989eb3e17ecSAkhil Goyal { 1990eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 1991eb3e17ecSAkhil Goyal 1992eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 1993eb3e17ecSAkhil Goyal 1994eb3e17ecSAkhil Goyal flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR; 1995eb3e17ecSAkhil Goyal 1996eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 1997eb3e17ecSAkhil Goyal } 1998eb3e17ecSAkhil Goyal 1999eb3e17ecSAkhil Goyal static int 2000eb3e17ecSAkhil Goyal test_ipsec_inline_proto_inner_ip_csum(const void *data __rte_unused) 2001eb3e17ecSAkhil Goyal { 2002eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2003eb3e17ecSAkhil Goyal 2004eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2005eb3e17ecSAkhil Goyal 2006eb3e17ecSAkhil Goyal flags.ip_csum = true; 2007eb3e17ecSAkhil Goyal 2008eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2009eb3e17ecSAkhil Goyal } 2010eb3e17ecSAkhil Goyal 2011eb3e17ecSAkhil Goyal static int 2012eb3e17ecSAkhil Goyal test_ipsec_inline_proto_inner_l4_csum(const void *data __rte_unused) 2013eb3e17ecSAkhil Goyal { 2014eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2015eb3e17ecSAkhil Goyal 2016eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2017eb3e17ecSAkhil Goyal 2018eb3e17ecSAkhil Goyal flags.l4_csum = true; 2019eb3e17ecSAkhil Goyal 2020eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2021eb3e17ecSAkhil Goyal } 2022eb3e17ecSAkhil Goyal 2023eb3e17ecSAkhil Goyal static int 2024eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v4_in_v4(const void *data __rte_unused) 2025eb3e17ecSAkhil Goyal { 2026eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2027eb3e17ecSAkhil Goyal 2028eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2029eb3e17ecSAkhil Goyal 2030eb3e17ecSAkhil Goyal flags.ipv6 = false; 2031eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = false; 2032eb3e17ecSAkhil Goyal 2033eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2034eb3e17ecSAkhil Goyal } 2035eb3e17ecSAkhil Goyal 2036eb3e17ecSAkhil Goyal static int 2037eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v6_in_v6(const void *data __rte_unused) 2038eb3e17ecSAkhil Goyal { 2039eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2040eb3e17ecSAkhil Goyal 2041eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2042eb3e17ecSAkhil Goyal 2043eb3e17ecSAkhil Goyal flags.ipv6 = true; 2044eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = true; 2045eb3e17ecSAkhil Goyal 2046eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2047eb3e17ecSAkhil Goyal } 2048eb3e17ecSAkhil Goyal 2049eb3e17ecSAkhil Goyal static int 2050eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v4_in_v6(const void *data __rte_unused) 2051eb3e17ecSAkhil Goyal { 2052eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2053eb3e17ecSAkhil Goyal 2054eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2055eb3e17ecSAkhil Goyal 2056eb3e17ecSAkhil Goyal flags.ipv6 = false; 2057eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = true; 2058eb3e17ecSAkhil Goyal 2059eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2060eb3e17ecSAkhil Goyal } 2061eb3e17ecSAkhil Goyal 2062eb3e17ecSAkhil Goyal static int 2063eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v6_in_v4(const void *data __rte_unused) 2064eb3e17ecSAkhil Goyal { 2065eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2066eb3e17ecSAkhil Goyal 2067eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2068eb3e17ecSAkhil Goyal 2069eb3e17ecSAkhil Goyal flags.ipv6 = true; 2070eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = false; 2071eb3e17ecSAkhil Goyal 2072eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2073eb3e17ecSAkhil Goyal } 2074eb3e17ecSAkhil Goyal 2075eb3e17ecSAkhil Goyal static int 2076eb3e17ecSAkhil Goyal test_ipsec_inline_proto_transport_v4(const void *data __rte_unused) 2077eb3e17ecSAkhil Goyal { 2078eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2079eb3e17ecSAkhil Goyal 2080eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2081eb3e17ecSAkhil Goyal 2082eb3e17ecSAkhil Goyal flags.ipv6 = false; 2083eb3e17ecSAkhil Goyal flags.transport = true; 2084eb3e17ecSAkhil Goyal 2085eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2086eb3e17ecSAkhil Goyal } 2087eb3e17ecSAkhil Goyal 2088eb3e17ecSAkhil Goyal static int 2089eb3e17ecSAkhil Goyal test_ipsec_inline_proto_transport_l4_csum(const void *data __rte_unused) 2090eb3e17ecSAkhil Goyal { 2091eb3e17ecSAkhil Goyal struct ipsec_test_flags flags = { 2092eb3e17ecSAkhil Goyal .l4_csum = true, 2093eb3e17ecSAkhil Goyal .transport = true, 2094eb3e17ecSAkhil Goyal }; 2095eb3e17ecSAkhil Goyal 2096eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2097eb3e17ecSAkhil Goyal } 2098eb3e17ecSAkhil Goyal 2099eb3e17ecSAkhil Goyal static int 2100eb3e17ecSAkhil Goyal test_ipsec_inline_proto_stats(const void *data __rte_unused) 2101eb3e17ecSAkhil Goyal { 2102eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2103eb3e17ecSAkhil Goyal 2104eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2105eb3e17ecSAkhil Goyal 2106eb3e17ecSAkhil Goyal flags.stats_success = true; 2107eb3e17ecSAkhil Goyal 2108eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2109eb3e17ecSAkhil Goyal } 2110eb3e17ecSAkhil Goyal 2111eb3e17ecSAkhil Goyal static int 2112eb3e17ecSAkhil Goyal test_ipsec_inline_proto_pkt_fragment(const void *data __rte_unused) 2113eb3e17ecSAkhil Goyal { 2114eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2115eb3e17ecSAkhil Goyal 2116eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2117eb3e17ecSAkhil Goyal 2118eb3e17ecSAkhil Goyal flags.fragment = true; 2119eb3e17ecSAkhil Goyal 2120eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2121eb3e17ecSAkhil Goyal 2122eb3e17ecSAkhil Goyal } 2123eb3e17ecSAkhil Goyal 2124eb3e17ecSAkhil Goyal static int 2125eb3e17ecSAkhil Goyal test_ipsec_inline_proto_copy_df_inner_0(const void *data __rte_unused) 2126eb3e17ecSAkhil Goyal { 2127eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2128eb3e17ecSAkhil Goyal 2129eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2130eb3e17ecSAkhil Goyal 2131eb3e17ecSAkhil Goyal flags.df = TEST_IPSEC_COPY_DF_INNER_0; 2132eb3e17ecSAkhil Goyal 2133eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2134eb3e17ecSAkhil Goyal } 2135eb3e17ecSAkhil Goyal 2136eb3e17ecSAkhil Goyal static int 2137eb3e17ecSAkhil Goyal test_ipsec_inline_proto_copy_df_inner_1(const void *data __rte_unused) 2138eb3e17ecSAkhil Goyal { 2139eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2140eb3e17ecSAkhil Goyal 2141eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2142eb3e17ecSAkhil Goyal 2143eb3e17ecSAkhil Goyal flags.df = TEST_IPSEC_COPY_DF_INNER_1; 2144eb3e17ecSAkhil Goyal 2145eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2146eb3e17ecSAkhil Goyal } 2147eb3e17ecSAkhil Goyal 2148eb3e17ecSAkhil Goyal static int 2149eb3e17ecSAkhil Goyal test_ipsec_inline_proto_set_df_0_inner_1(const void *data __rte_unused) 2150eb3e17ecSAkhil Goyal { 2151eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2152eb3e17ecSAkhil Goyal 2153eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2154eb3e17ecSAkhil Goyal 2155eb3e17ecSAkhil Goyal flags.df = TEST_IPSEC_SET_DF_0_INNER_1; 2156eb3e17ecSAkhil Goyal 2157eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2158eb3e17ecSAkhil Goyal } 2159eb3e17ecSAkhil Goyal 2160eb3e17ecSAkhil Goyal static int 2161eb3e17ecSAkhil Goyal test_ipsec_inline_proto_set_df_1_inner_0(const void *data __rte_unused) 2162eb3e17ecSAkhil Goyal { 2163eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2164eb3e17ecSAkhil Goyal 2165eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2166eb3e17ecSAkhil Goyal 2167eb3e17ecSAkhil Goyal flags.df = TEST_IPSEC_SET_DF_1_INNER_0; 2168eb3e17ecSAkhil Goyal 2169eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2170eb3e17ecSAkhil Goyal } 2171eb3e17ecSAkhil Goyal 2172eb3e17ecSAkhil Goyal static int 2173eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused) 2174eb3e17ecSAkhil Goyal { 2175eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2176eb3e17ecSAkhil Goyal 2177eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2178eb3e17ecSAkhil Goyal 2179eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0; 2180eb3e17ecSAkhil Goyal 2181eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2182eb3e17ecSAkhil Goyal } 2183eb3e17ecSAkhil Goyal 2184eb3e17ecSAkhil Goyal static int 2185eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused) 2186eb3e17ecSAkhil Goyal { 2187eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2188eb3e17ecSAkhil Goyal 2189eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2190eb3e17ecSAkhil Goyal 2191eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1; 2192eb3e17ecSAkhil Goyal 2193eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2194eb3e17ecSAkhil Goyal } 2195eb3e17ecSAkhil Goyal 2196eb3e17ecSAkhil Goyal static int 2197eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused) 2198eb3e17ecSAkhil Goyal { 2199eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2200eb3e17ecSAkhil Goyal 2201eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2202eb3e17ecSAkhil Goyal 2203eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1; 2204eb3e17ecSAkhil Goyal 2205eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2206eb3e17ecSAkhil Goyal } 2207eb3e17ecSAkhil Goyal 2208eb3e17ecSAkhil Goyal static int 2209eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused) 2210eb3e17ecSAkhil Goyal { 2211eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2212eb3e17ecSAkhil Goyal 2213eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2214eb3e17ecSAkhil Goyal 2215eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0; 2216eb3e17ecSAkhil Goyal 2217eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2218eb3e17ecSAkhil Goyal } 2219eb3e17ecSAkhil Goyal 2220eb3e17ecSAkhil Goyal static int 2221eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused) 2222eb3e17ecSAkhil Goyal { 2223eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2224eb3e17ecSAkhil Goyal 2225eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2226eb3e17ecSAkhil Goyal 2227eb3e17ecSAkhil Goyal flags.ipv6 = true; 2228eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = true; 2229eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0; 2230eb3e17ecSAkhil Goyal 2231eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2232eb3e17ecSAkhil Goyal } 2233eb3e17ecSAkhil Goyal 2234eb3e17ecSAkhil Goyal static int 2235eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused) 2236eb3e17ecSAkhil Goyal { 2237eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2238eb3e17ecSAkhil Goyal 2239eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2240eb3e17ecSAkhil Goyal 2241eb3e17ecSAkhil Goyal flags.ipv6 = true; 2242eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = true; 2243eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1; 2244eb3e17ecSAkhil Goyal 2245eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2246eb3e17ecSAkhil Goyal } 2247eb3e17ecSAkhil Goyal 2248eb3e17ecSAkhil Goyal static int 2249eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused) 2250eb3e17ecSAkhil Goyal { 2251eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2252eb3e17ecSAkhil Goyal 2253eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2254eb3e17ecSAkhil Goyal 2255eb3e17ecSAkhil Goyal flags.ipv6 = true; 2256eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = true; 2257eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1; 2258eb3e17ecSAkhil Goyal 2259eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2260eb3e17ecSAkhil Goyal } 2261eb3e17ecSAkhil Goyal 2262eb3e17ecSAkhil Goyal static int 2263eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused) 2264eb3e17ecSAkhil Goyal { 2265eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2266eb3e17ecSAkhil Goyal 2267eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2268eb3e17ecSAkhil Goyal 2269eb3e17ecSAkhil Goyal flags.ipv6 = true; 2270eb3e17ecSAkhil Goyal flags.tunnel_ipv6 = true; 2271eb3e17ecSAkhil Goyal flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0; 2272eb3e17ecSAkhil Goyal 2273eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2274eb3e17ecSAkhil Goyal } 2275eb3e17ecSAkhil Goyal 2276eb3e17ecSAkhil Goyal static int 227791d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_copy_flabel_inner_0(const void *data __rte_unused) 227891d1d052SVamsi Attunuru { 227991d1d052SVamsi Attunuru struct ipsec_test_flags flags; 228091d1d052SVamsi Attunuru 228191d1d052SVamsi Attunuru memset(&flags, 0, sizeof(flags)); 228291d1d052SVamsi Attunuru 228391d1d052SVamsi Attunuru flags.ipv6 = true; 228491d1d052SVamsi Attunuru flags.tunnel_ipv6 = true; 228591d1d052SVamsi Attunuru flags.flabel = TEST_IPSEC_COPY_FLABEL_INNER_0; 228691d1d052SVamsi Attunuru 228791d1d052SVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 228891d1d052SVamsi Attunuru } 228991d1d052SVamsi Attunuru 229091d1d052SVamsi Attunuru static int 229191d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_copy_flabel_inner_1(const void *data __rte_unused) 229291d1d052SVamsi Attunuru { 229391d1d052SVamsi Attunuru struct ipsec_test_flags flags; 229491d1d052SVamsi Attunuru 229591d1d052SVamsi Attunuru memset(&flags, 0, sizeof(flags)); 229691d1d052SVamsi Attunuru 229791d1d052SVamsi Attunuru flags.ipv6 = true; 229891d1d052SVamsi Attunuru flags.tunnel_ipv6 = true; 229991d1d052SVamsi Attunuru flags.flabel = TEST_IPSEC_COPY_FLABEL_INNER_1; 230091d1d052SVamsi Attunuru 230191d1d052SVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 230291d1d052SVamsi Attunuru } 230391d1d052SVamsi Attunuru 230491d1d052SVamsi Attunuru static int 230591d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_set_flabel_0_inner_1(const void *data __rte_unused) 230691d1d052SVamsi Attunuru { 230791d1d052SVamsi Attunuru struct ipsec_test_flags flags; 230891d1d052SVamsi Attunuru 230991d1d052SVamsi Attunuru memset(&flags, 0, sizeof(flags)); 231091d1d052SVamsi Attunuru 231191d1d052SVamsi Attunuru flags.ipv6 = true; 231291d1d052SVamsi Attunuru flags.tunnel_ipv6 = true; 231391d1d052SVamsi Attunuru flags.flabel = TEST_IPSEC_SET_FLABEL_0_INNER_1; 231491d1d052SVamsi Attunuru 231591d1d052SVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 231691d1d052SVamsi Attunuru } 231791d1d052SVamsi Attunuru 231891d1d052SVamsi Attunuru static int 231991d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_set_flabel_1_inner_0(const void *data __rte_unused) 232091d1d052SVamsi Attunuru { 232191d1d052SVamsi Attunuru struct ipsec_test_flags flags; 232291d1d052SVamsi Attunuru 232391d1d052SVamsi Attunuru memset(&flags, 0, sizeof(flags)); 232491d1d052SVamsi Attunuru 232591d1d052SVamsi Attunuru flags.ipv6 = true; 232691d1d052SVamsi Attunuru flags.tunnel_ipv6 = true; 232791d1d052SVamsi Attunuru flags.flabel = TEST_IPSEC_SET_FLABEL_1_INNER_0; 232891d1d052SVamsi Attunuru 232991d1d052SVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 233091d1d052SVamsi Attunuru } 233191d1d052SVamsi Attunuru 233291d1d052SVamsi Attunuru static int 2333eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_ttl_decrement(const void *data __rte_unused) 2334eb3e17ecSAkhil Goyal { 2335eb3e17ecSAkhil Goyal struct ipsec_test_flags flags = { 2336eb3e17ecSAkhil Goyal .dec_ttl_or_hop_limit = true 2337eb3e17ecSAkhil Goyal }; 2338eb3e17ecSAkhil Goyal 2339eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2340eb3e17ecSAkhil Goyal } 2341eb3e17ecSAkhil Goyal 2342eb3e17ecSAkhil Goyal static int 2343eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_hop_limit_decrement(const void *data __rte_unused) 2344eb3e17ecSAkhil Goyal { 2345eb3e17ecSAkhil Goyal struct ipsec_test_flags flags = { 2346eb3e17ecSAkhil Goyal .ipv6 = true, 2347eb3e17ecSAkhil Goyal .dec_ttl_or_hop_limit = true 2348eb3e17ecSAkhil Goyal }; 2349eb3e17ecSAkhil Goyal 2350eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2351eb3e17ecSAkhil Goyal } 2352eb3e17ecSAkhil Goyal 2353eb3e17ecSAkhil Goyal static int 2354eb3e17ecSAkhil Goyal test_ipsec_inline_proto_iv_gen(const void *data __rte_unused) 2355eb3e17ecSAkhil Goyal { 2356eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2357eb3e17ecSAkhil Goyal 2358eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2359eb3e17ecSAkhil Goyal 2360eb3e17ecSAkhil Goyal flags.iv_gen = true; 2361eb3e17ecSAkhil Goyal 2362eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_all(&flags); 2363eb3e17ecSAkhil Goyal } 2364eb3e17ecSAkhil Goyal 2365eb3e17ecSAkhil Goyal static int 236634e8a9d9SVamsi Attunuru test_ipsec_inline_proto_sa_pkt_soft_expiry(const void *data __rte_unused) 236734e8a9d9SVamsi Attunuru { 236834e8a9d9SVamsi Attunuru struct ipsec_test_flags flags = { 236934e8a9d9SVamsi Attunuru .sa_expiry_pkts_soft = true 237034e8a9d9SVamsi Attunuru }; 237134e8a9d9SVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 237234e8a9d9SVamsi Attunuru } 237334e8a9d9SVamsi Attunuru static int 237434e8a9d9SVamsi Attunuru test_ipsec_inline_proto_sa_byte_soft_expiry(const void *data __rte_unused) 237534e8a9d9SVamsi Attunuru { 237634e8a9d9SVamsi Attunuru struct ipsec_test_flags flags = { 237734e8a9d9SVamsi Attunuru .sa_expiry_bytes_soft = true 237834e8a9d9SVamsi Attunuru }; 237934e8a9d9SVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 238034e8a9d9SVamsi Attunuru } 238134e8a9d9SVamsi Attunuru 238234e8a9d9SVamsi Attunuru static int 2383ff8ef86cSVamsi Attunuru test_ipsec_inline_proto_sa_pkt_hard_expiry(const void *data __rte_unused) 2384ff8ef86cSVamsi Attunuru { 2385ff8ef86cSVamsi Attunuru struct ipsec_test_flags flags = { 2386ff8ef86cSVamsi Attunuru .sa_expiry_pkts_hard = true 2387ff8ef86cSVamsi Attunuru }; 2388ff8ef86cSVamsi Attunuru 2389ff8ef86cSVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 2390ff8ef86cSVamsi Attunuru } 2391ff8ef86cSVamsi Attunuru 2392ff8ef86cSVamsi Attunuru static int 2393ff8ef86cSVamsi Attunuru test_ipsec_inline_proto_sa_byte_hard_expiry(const void *data __rte_unused) 2394ff8ef86cSVamsi Attunuru { 2395ff8ef86cSVamsi Attunuru struct ipsec_test_flags flags = { 2396ff8ef86cSVamsi Attunuru .sa_expiry_bytes_hard = true 2397ff8ef86cSVamsi Attunuru }; 2398ff8ef86cSVamsi Attunuru 2399ff8ef86cSVamsi Attunuru return test_ipsec_inline_proto_all(&flags); 2400ff8ef86cSVamsi Attunuru } 2401ff8ef86cSVamsi Attunuru 2402ff8ef86cSVamsi Attunuru static int 2403eb3e17ecSAkhil Goyal test_ipsec_inline_proto_known_vec_fragmented(const void *test_data) 2404eb3e17ecSAkhil Goyal { 2405eb3e17ecSAkhil Goyal struct ipsec_test_data td_outb; 2406eb3e17ecSAkhil Goyal struct ipsec_test_flags flags; 2407eb3e17ecSAkhil Goyal 2408eb3e17ecSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2409eb3e17ecSAkhil Goyal flags.fragment = true; 2410eb3e17ecSAkhil Goyal 2411eb3e17ecSAkhil Goyal memcpy(&td_outb, test_data, sizeof(td_outb)); 2412eb3e17ecSAkhil Goyal 2413eb3e17ecSAkhil Goyal /* Disable IV gen to be able to test with known vectors */ 2414eb3e17ecSAkhil Goyal td_outb.ipsec_xform.options.iv_gen_disable = 1; 2415eb3e17ecSAkhil Goyal 2416eb3e17ecSAkhil Goyal return test_ipsec_inline_proto_process(&td_outb, NULL, 1, false, 2417eb3e17ecSAkhil Goyal &flags); 2418eb3e17ecSAkhil Goyal } 2419fd33d9eeSAkhil Goyal 2420fd33d9eeSAkhil Goyal static int 2421fd33d9eeSAkhil Goyal test_ipsec_inline_pkt_replay(const void *test_data, const uint64_t esn[], 2422fd33d9eeSAkhil Goyal bool replayed_pkt[], uint32_t nb_pkts, bool esn_en, 2423fd33d9eeSAkhil Goyal uint64_t winsz) 2424fd33d9eeSAkhil Goyal { 2425fd33d9eeSAkhil Goyal struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX]; 2426fd33d9eeSAkhil Goyal struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX]; 2427fd33d9eeSAkhil Goyal struct ipsec_test_flags flags; 2428fd33d9eeSAkhil Goyal uint32_t i, ret = 0; 2429fd33d9eeSAkhil Goyal 2430fd33d9eeSAkhil Goyal memset(&flags, 0, sizeof(flags)); 2431fd33d9eeSAkhil Goyal flags.antireplay = true; 2432fd33d9eeSAkhil Goyal 2433fd33d9eeSAkhil Goyal for (i = 0; i < nb_pkts; i++) { 243410864656SVolodymyr Fialko memcpy(&td_outb[i], test_data, sizeof(td_outb[0])); 2435fd33d9eeSAkhil Goyal td_outb[i].ipsec_xform.options.iv_gen_disable = 1; 2436fd33d9eeSAkhil Goyal td_outb[i].ipsec_xform.replay_win_sz = winsz; 2437fd33d9eeSAkhil Goyal td_outb[i].ipsec_xform.options.esn = esn_en; 2438fd33d9eeSAkhil Goyal } 2439fd33d9eeSAkhil Goyal 2440fd33d9eeSAkhil Goyal for (i = 0; i < nb_pkts; i++) 2441fd33d9eeSAkhil Goyal td_outb[i].ipsec_xform.esn.value = esn[i]; 2442fd33d9eeSAkhil Goyal 2443fd33d9eeSAkhil Goyal ret = test_ipsec_inline_proto_process_with_esn(td_outb, td_inb, 2444fd33d9eeSAkhil Goyal nb_pkts, true, &flags); 2445fd33d9eeSAkhil Goyal if (ret != TEST_SUCCESS) 2446fd33d9eeSAkhil Goyal return ret; 2447fd33d9eeSAkhil Goyal 2448fd33d9eeSAkhil Goyal test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags); 2449fd33d9eeSAkhil Goyal 2450fd33d9eeSAkhil Goyal for (i = 0; i < nb_pkts; i++) { 2451fd33d9eeSAkhil Goyal td_inb[i].ipsec_xform.options.esn = esn_en; 2452fd33d9eeSAkhil Goyal /* Set antireplay flag for packets to be dropped */ 2453fd33d9eeSAkhil Goyal td_inb[i].ar_packet = replayed_pkt[i]; 2454fd33d9eeSAkhil Goyal } 2455fd33d9eeSAkhil Goyal 2456fd33d9eeSAkhil Goyal ret = test_ipsec_inline_proto_process_with_esn(td_inb, NULL, nb_pkts, 2457fd33d9eeSAkhil Goyal true, &flags); 2458fd33d9eeSAkhil Goyal 2459fd33d9eeSAkhil Goyal return ret; 2460fd33d9eeSAkhil Goyal } 2461fd33d9eeSAkhil Goyal 2462fd33d9eeSAkhil Goyal static int 2463fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay(const void *test_data, uint64_t winsz) 2464fd33d9eeSAkhil Goyal { 2465fd33d9eeSAkhil Goyal 2466fd33d9eeSAkhil Goyal uint32_t nb_pkts = 5; 2467fd33d9eeSAkhil Goyal bool replayed_pkt[5]; 2468fd33d9eeSAkhil Goyal uint64_t esn[5]; 2469fd33d9eeSAkhil Goyal 2470fd33d9eeSAkhil Goyal /* 1. Advance the TOP of the window to WS * 2 */ 2471fd33d9eeSAkhil Goyal esn[0] = winsz * 2; 2472fd33d9eeSAkhil Goyal /* 2. Test sequence number within the new window(WS + 1) */ 2473fd33d9eeSAkhil Goyal esn[1] = winsz + 1; 2474fd33d9eeSAkhil Goyal /* 3. Test sequence number less than the window BOTTOM */ 2475fd33d9eeSAkhil Goyal esn[2] = winsz; 2476fd33d9eeSAkhil Goyal /* 4. Test sequence number in the middle of the window */ 2477fd33d9eeSAkhil Goyal esn[3] = winsz + (winsz / 2); 2478fd33d9eeSAkhil Goyal /* 5. Test replay of the packet in the middle of the window */ 2479fd33d9eeSAkhil Goyal esn[4] = winsz + (winsz / 2); 2480fd33d9eeSAkhil Goyal 2481fd33d9eeSAkhil Goyal replayed_pkt[0] = false; 2482fd33d9eeSAkhil Goyal replayed_pkt[1] = false; 2483fd33d9eeSAkhil Goyal replayed_pkt[2] = true; 2484fd33d9eeSAkhil Goyal replayed_pkt[3] = false; 2485fd33d9eeSAkhil Goyal replayed_pkt[4] = true; 2486fd33d9eeSAkhil Goyal 2487fd33d9eeSAkhil Goyal return test_ipsec_inline_pkt_replay(test_data, esn, replayed_pkt, 2488fd33d9eeSAkhil Goyal nb_pkts, false, winsz); 2489fd33d9eeSAkhil Goyal } 2490fd33d9eeSAkhil Goyal 2491fd33d9eeSAkhil Goyal static int 2492fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay1024(const void *test_data) 2493fd33d9eeSAkhil Goyal { 2494fd33d9eeSAkhil Goyal return test_ipsec_inline_proto_pkt_antireplay(test_data, 1024); 2495fd33d9eeSAkhil Goyal } 2496fd33d9eeSAkhil Goyal 2497fd33d9eeSAkhil Goyal static int 2498fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay2048(const void *test_data) 2499fd33d9eeSAkhil Goyal { 2500fd33d9eeSAkhil Goyal return test_ipsec_inline_proto_pkt_antireplay(test_data, 2048); 2501fd33d9eeSAkhil Goyal } 2502fd33d9eeSAkhil Goyal 2503fd33d9eeSAkhil Goyal static int 2504fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay4096(const void *test_data) 2505fd33d9eeSAkhil Goyal { 2506fd33d9eeSAkhil Goyal return test_ipsec_inline_proto_pkt_antireplay(test_data, 4096); 2507fd33d9eeSAkhil Goyal } 2508fd33d9eeSAkhil Goyal 2509fd33d9eeSAkhil Goyal static int 2510fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz) 2511fd33d9eeSAkhil Goyal { 2512fd33d9eeSAkhil Goyal 2513fd33d9eeSAkhil Goyal uint32_t nb_pkts = 7; 2514fd33d9eeSAkhil Goyal bool replayed_pkt[7]; 2515fd33d9eeSAkhil Goyal uint64_t esn[7]; 2516fd33d9eeSAkhil Goyal 2517fd33d9eeSAkhil Goyal /* Set the initial sequence number */ 2518fd33d9eeSAkhil Goyal esn[0] = (uint64_t)(0xFFFFFFFF - winsz); 2519fd33d9eeSAkhil Goyal /* 1. Advance the TOP of the window to (1<<32 + WS/2) */ 2520fd33d9eeSAkhil Goyal esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2)); 2521fd33d9eeSAkhil Goyal /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */ 2522fd33d9eeSAkhil Goyal esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1); 2523fd33d9eeSAkhil Goyal /* 3. Test with sequence number within window (1<<32 - 1) */ 2524fd33d9eeSAkhil Goyal esn[3] = (uint64_t)((1ULL << 32) - 1); 2525fd33d9eeSAkhil Goyal /* 4. Test with sequence number within window (1<<32 - 1) */ 2526fd33d9eeSAkhil Goyal esn[4] = (uint64_t)(1ULL << 32); 2527fd33d9eeSAkhil Goyal /* 5. Test with duplicate sequence number within 2528fd33d9eeSAkhil Goyal * new window (1<<32 - 1) 2529fd33d9eeSAkhil Goyal */ 2530fd33d9eeSAkhil Goyal esn[5] = (uint64_t)((1ULL << 32) - 1); 2531fd33d9eeSAkhil Goyal /* 6. Test with duplicate sequence number within new window (1<<32) */ 2532fd33d9eeSAkhil Goyal esn[6] = (uint64_t)(1ULL << 32); 2533fd33d9eeSAkhil Goyal 2534fd33d9eeSAkhil Goyal replayed_pkt[0] = false; 2535fd33d9eeSAkhil Goyal replayed_pkt[1] = false; 2536fd33d9eeSAkhil Goyal replayed_pkt[2] = false; 2537fd33d9eeSAkhil Goyal replayed_pkt[3] = false; 2538fd33d9eeSAkhil Goyal replayed_pkt[4] = false; 2539fd33d9eeSAkhil Goyal replayed_pkt[5] = true; 2540fd33d9eeSAkhil Goyal replayed_pkt[6] = true; 2541fd33d9eeSAkhil Goyal 2542fd33d9eeSAkhil Goyal return test_ipsec_inline_pkt_replay(test_data, esn, replayed_pkt, nb_pkts, 2543fd33d9eeSAkhil Goyal true, winsz); 2544fd33d9eeSAkhil Goyal } 2545fd33d9eeSAkhil Goyal 2546fd33d9eeSAkhil Goyal static int 2547fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay1024(const void *test_data) 2548fd33d9eeSAkhil Goyal { 2549fd33d9eeSAkhil Goyal return test_ipsec_inline_proto_pkt_esn_antireplay(test_data, 1024); 2550fd33d9eeSAkhil Goyal } 2551fd33d9eeSAkhil Goyal 2552fd33d9eeSAkhil Goyal static int 2553fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay2048(const void *test_data) 2554fd33d9eeSAkhil Goyal { 2555fd33d9eeSAkhil Goyal return test_ipsec_inline_proto_pkt_esn_antireplay(test_data, 2048); 2556fd33d9eeSAkhil Goyal } 2557fd33d9eeSAkhil Goyal 2558fd33d9eeSAkhil Goyal static int 2559fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay4096(const void *test_data) 2560fd33d9eeSAkhil Goyal { 2561fd33d9eeSAkhil Goyal return test_ipsec_inline_proto_pkt_esn_antireplay(test_data, 4096); 2562fd33d9eeSAkhil Goyal } 2563fd33d9eeSAkhil Goyal 2564fd33d9eeSAkhil Goyal 2565fd33d9eeSAkhil Goyal 256686e2487cSAkhil Goyal static struct unit_test_suite inline_ipsec_testsuite = { 256786e2487cSAkhil Goyal .suite_name = "Inline IPsec Ethernet Device Unit Test Suite", 256886e2487cSAkhil Goyal .unit_test_cases = { 256986e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 257086e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)", 257186e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 257286e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, &pkt_aes_128_gcm), 257386e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 257486e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)", 257586e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 257686e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, &pkt_aes_192_gcm), 257786e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 257886e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)", 257986e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 258086e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, &pkt_aes_256_gcm), 258186e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2582*5a23f6eaSVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])", 2583*5a23f6eaSVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2584*5a23f6eaSVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2585*5a23f6eaSVidya Sagar Velumuri &pkt_aes_128_cbc_md5), 2586*5a23f6eaSVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 258786e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])", 258886e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 258986e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, 259086e2487cSAkhil Goyal &pkt_aes_128_cbc_hmac_sha256), 259186e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 259286e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])", 259386e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 259486e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, 259586e2487cSAkhil Goyal &pkt_aes_128_cbc_hmac_sha384), 259686e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 259786e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])", 259886e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 259986e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, 260086e2487cSAkhil Goyal &pkt_aes_128_cbc_hmac_sha512), 260186e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2602d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])", 2603d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2604d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2605d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha256), 2606d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2607d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])", 2608d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2609d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2610d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha384), 2611d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2612d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])", 2613d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2614d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2615d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha512), 2616d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 261786e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)", 261886e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 261986e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, &pkt_aes_256_gcm_v6), 262086e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 262186e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])", 262286e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 262386e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, 262486e2487cSAkhil Goyal &pkt_aes_128_cbc_hmac_sha256_v6), 262586e2487cSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2626d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])", 2627d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2628d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2629d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha256_v6), 2630d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 263186e2487cSAkhil Goyal "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])", 263286e2487cSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 263386e2487cSAkhil Goyal test_ipsec_inline_proto_known_vec, 263486e2487cSAkhil Goyal &pkt_null_aes_xcbc), 2635d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2636d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])", 2637d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2638d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2639d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha256), 2640d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2641d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])", 2642d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2643d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2644d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha384), 2645d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2646d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])", 2647d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2648d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2649d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha512), 2650d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2651d7001863SVidya Sagar Velumuri "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])", 2652d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2653d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec, 2654d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha256_v6), 2655eb3e17ecSAkhil Goyal 2656eb3e17ecSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2657eb3e17ecSAkhil Goyal "Outbound fragmented packet", 2658eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2659eb3e17ecSAkhil Goyal test_ipsec_inline_proto_known_vec_fragmented, 2660eb3e17ecSAkhil Goyal &pkt_aes_128_gcm_frag), 2661eb3e17ecSAkhil Goyal 26621c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 26631c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)", 26641c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26651c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, &pkt_aes_128_gcm), 26661c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 26671c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)", 26681c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26691c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, &pkt_aes_192_gcm), 26701c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 26711c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)", 26721c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26731c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, &pkt_aes_256_gcm), 26741c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 26751c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)", 26761c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26771c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, &pkt_aes_128_cbc_null), 26781c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2679*5a23f6eaSVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])", 2680*5a23f6eaSVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2681*5a23f6eaSVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2682*5a23f6eaSVidya Sagar Velumuri &pkt_aes_128_cbc_md5), 2683*5a23f6eaSVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 26841c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])", 26851c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26861c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, 26871c015ddeSAkhil Goyal &pkt_aes_128_cbc_hmac_sha256), 26881c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 26891c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])", 26901c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26911c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, 26921c015ddeSAkhil Goyal &pkt_aes_128_cbc_hmac_sha384), 26931c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 26941c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])", 26951c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 26961c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, 26971c015ddeSAkhil Goyal &pkt_aes_128_cbc_hmac_sha512), 26981c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2699d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])", 2700d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2701d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2702d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha256), 2703d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2704d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])", 2705d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2706d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2707d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha384), 2708d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2709d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])", 2710d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2711d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2712d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha512), 2713d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 27141c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)", 27151c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 27161c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, &pkt_aes_256_gcm_v6), 27171c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 27181c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])", 27191c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 27201c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, 27211c015ddeSAkhil Goyal &pkt_aes_128_cbc_hmac_sha256_v6), 27221c015ddeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2723d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])", 2724d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2725d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2726d7001863SVidya Sagar Velumuri &pkt_3des_cbc_hmac_sha256_v6), 2727d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 27281c015ddeSAkhil Goyal "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])", 27291c015ddeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 27301c015ddeSAkhil Goyal test_ipsec_inline_proto_known_vec_inb, 27311c015ddeSAkhil Goyal &pkt_null_aes_xcbc), 2732d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2733d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])", 2734d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2735d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2736d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha256), 2737d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2738d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])", 2739d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2740d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2741d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha384), 2742d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2743d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])", 2744d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2745d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2746d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha512), 2747d7001863SVidya Sagar Velumuri TEST_CASE_NAMED_WITH_DATA( 2748d7001863SVidya Sagar Velumuri "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])", 2749d7001863SVidya Sagar Velumuri ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2750d7001863SVidya Sagar Velumuri test_ipsec_inline_proto_known_vec_inb, 2751d7001863SVidya Sagar Velumuri &pkt_des_cbc_hmac_sha256_v6), 2752d7001863SVidya Sagar Velumuri 27531c015ddeSAkhil Goyal 275478dc764eSAkhil Goyal TEST_CASE_NAMED_ST( 275578dc764eSAkhil Goyal "Combined test alg list", 275678dc764eSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 275778dc764eSAkhil Goyal test_ipsec_inline_proto_display_list), 275878dc764eSAkhil Goyal 2759eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2760eb3e17ecSAkhil Goyal "UDP encapsulation", 2761eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2762eb3e17ecSAkhil Goyal test_ipsec_inline_proto_udp_encap), 2763eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2764eb3e17ecSAkhil Goyal "UDP encapsulation ports verification test", 2765eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2766eb3e17ecSAkhil Goyal test_ipsec_inline_proto_udp_ports_verify), 2767eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2768eb3e17ecSAkhil Goyal "Negative test: ICV corruption", 2769eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2770eb3e17ecSAkhil Goyal test_ipsec_inline_proto_err_icv_corrupt), 2771eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2772eb3e17ecSAkhil Goyal "Tunnel dst addr verification", 2773eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2774eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_dst_addr_verify), 2775eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2776eb3e17ecSAkhil Goyal "Tunnel src and dst addr verification", 2777eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2778eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_src_dst_addr_verify), 2779eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2780eb3e17ecSAkhil Goyal "Inner IP checksum", 2781eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2782eb3e17ecSAkhil Goyal test_ipsec_inline_proto_inner_ip_csum), 2783eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2784eb3e17ecSAkhil Goyal "Inner L4 checksum", 2785eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2786eb3e17ecSAkhil Goyal test_ipsec_inline_proto_inner_l4_csum), 2787eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2788eb3e17ecSAkhil Goyal "Tunnel IPv4 in IPv4", 2789eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2790eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v4_in_v4), 2791eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2792eb3e17ecSAkhil Goyal "Tunnel IPv6 in IPv6", 2793eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2794eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v6_in_v6), 2795eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2796eb3e17ecSAkhil Goyal "Tunnel IPv4 in IPv6", 2797eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2798eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v4_in_v6), 2799eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2800eb3e17ecSAkhil Goyal "Tunnel IPv6 in IPv4", 2801eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2802eb3e17ecSAkhil Goyal test_ipsec_inline_proto_tunnel_v6_in_v4), 2803eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2804eb3e17ecSAkhil Goyal "Transport IPv4", 2805eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2806eb3e17ecSAkhil Goyal test_ipsec_inline_proto_transport_v4), 2807eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2808eb3e17ecSAkhil Goyal "Transport l4 checksum", 2809eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2810eb3e17ecSAkhil Goyal test_ipsec_inline_proto_transport_l4_csum), 2811eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2812eb3e17ecSAkhil Goyal "Statistics: success", 2813eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2814eb3e17ecSAkhil Goyal test_ipsec_inline_proto_stats), 2815eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2816eb3e17ecSAkhil Goyal "Fragmented packet", 2817eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2818eb3e17ecSAkhil Goyal test_ipsec_inline_proto_pkt_fragment), 2819eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2820eb3e17ecSAkhil Goyal "Tunnel header copy DF (inner 0)", 2821eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2822eb3e17ecSAkhil Goyal test_ipsec_inline_proto_copy_df_inner_0), 2823eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2824eb3e17ecSAkhil Goyal "Tunnel header copy DF (inner 1)", 2825eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2826eb3e17ecSAkhil Goyal test_ipsec_inline_proto_copy_df_inner_1), 2827eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2828eb3e17ecSAkhil Goyal "Tunnel header set DF 0 (inner 1)", 2829eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2830eb3e17ecSAkhil Goyal test_ipsec_inline_proto_set_df_0_inner_1), 2831eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2832eb3e17ecSAkhil Goyal "Tunnel header set DF 1 (inner 0)", 2833eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2834eb3e17ecSAkhil Goyal test_ipsec_inline_proto_set_df_1_inner_0), 2835eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2836eb3e17ecSAkhil Goyal "Tunnel header IPv4 copy DSCP (inner 0)", 2837eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2838eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_copy_dscp_inner_0), 2839eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2840eb3e17ecSAkhil Goyal "Tunnel header IPv4 copy DSCP (inner 1)", 2841eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2842eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_copy_dscp_inner_1), 2843eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2844eb3e17ecSAkhil Goyal "Tunnel header IPv4 set DSCP 0 (inner 1)", 2845eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2846eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_set_dscp_0_inner_1), 2847eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2848eb3e17ecSAkhil Goyal "Tunnel header IPv4 set DSCP 1 (inner 0)", 2849eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2850eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_set_dscp_1_inner_0), 2851eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2852eb3e17ecSAkhil Goyal "Tunnel header IPv6 copy DSCP (inner 0)", 2853eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2854eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_copy_dscp_inner_0), 2855eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2856eb3e17ecSAkhil Goyal "Tunnel header IPv6 copy DSCP (inner 1)", 2857eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2858eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_copy_dscp_inner_1), 2859eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2860eb3e17ecSAkhil Goyal "Tunnel header IPv6 set DSCP 0 (inner 1)", 2861eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2862eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_set_dscp_0_inner_1), 2863eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2864eb3e17ecSAkhil Goyal "Tunnel header IPv6 set DSCP 1 (inner 0)", 2865eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2866eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0), 2867eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 286891d1d052SVamsi Attunuru "Tunnel header IPv6 copy FLABEL (inner 0)", 286991d1d052SVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 287091d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_copy_flabel_inner_0), 287191d1d052SVamsi Attunuru TEST_CASE_NAMED_ST( 287291d1d052SVamsi Attunuru "Tunnel header IPv6 copy FLABEL (inner 1)", 287391d1d052SVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 287491d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_copy_flabel_inner_1), 287591d1d052SVamsi Attunuru TEST_CASE_NAMED_ST( 287691d1d052SVamsi Attunuru "Tunnel header IPv6 set FLABEL 0 (inner 1)", 287791d1d052SVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 287891d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_set_flabel_0_inner_1), 287991d1d052SVamsi Attunuru TEST_CASE_NAMED_ST( 288091d1d052SVamsi Attunuru "Tunnel header IPv6 set FLABEL 1 (inner 0)", 288191d1d052SVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 288291d1d052SVamsi Attunuru test_ipsec_inline_proto_ipv6_set_flabel_1_inner_0), 288391d1d052SVamsi Attunuru TEST_CASE_NAMED_ST( 2884eb3e17ecSAkhil Goyal "Tunnel header IPv4 decrement inner TTL", 2885eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2886eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv4_ttl_decrement), 2887eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2888eb3e17ecSAkhil Goyal "Tunnel header IPv6 decrement inner hop limit", 2889eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2890eb3e17ecSAkhil Goyal test_ipsec_inline_proto_ipv6_hop_limit_decrement), 2891eb3e17ecSAkhil Goyal TEST_CASE_NAMED_ST( 2892eb3e17ecSAkhil Goyal "IV generation", 2893eb3e17ecSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2894eb3e17ecSAkhil Goyal test_ipsec_inline_proto_iv_gen), 289534e8a9d9SVamsi Attunuru TEST_CASE_NAMED_ST( 289634e8a9d9SVamsi Attunuru "SA soft expiry with packet limit", 289734e8a9d9SVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 289834e8a9d9SVamsi Attunuru test_ipsec_inline_proto_sa_pkt_soft_expiry), 289934e8a9d9SVamsi Attunuru TEST_CASE_NAMED_ST( 290034e8a9d9SVamsi Attunuru "SA soft expiry with byte limit", 290134e8a9d9SVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 290234e8a9d9SVamsi Attunuru test_ipsec_inline_proto_sa_byte_soft_expiry), 2903ff8ef86cSVamsi Attunuru TEST_CASE_NAMED_ST( 2904ff8ef86cSVamsi Attunuru "SA hard expiry with packet limit", 2905ff8ef86cSVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2906ff8ef86cSVamsi Attunuru test_ipsec_inline_proto_sa_pkt_hard_expiry), 2907ff8ef86cSVamsi Attunuru TEST_CASE_NAMED_ST( 2908ff8ef86cSVamsi Attunuru "SA hard expiry with byte limit", 2909ff8ef86cSVamsi Attunuru ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2910ff8ef86cSVamsi Attunuru test_ipsec_inline_proto_sa_byte_hard_expiry), 2911eb3e17ecSAkhil Goyal 2912a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2913fd33d9eeSAkhil Goyal "Antireplay with window size 1024", 2914fd33d9eeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2915fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay1024, 2916fd33d9eeSAkhil Goyal &pkt_aes_128_gcm), 2917fd33d9eeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2918fd33d9eeSAkhil Goyal "Antireplay with window size 2048", 2919fd33d9eeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2920fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay2048, 2921fd33d9eeSAkhil Goyal &pkt_aes_128_gcm), 2922fd33d9eeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2923fd33d9eeSAkhil Goyal "Antireplay with window size 4096", 2924fd33d9eeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2925fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_antireplay4096, 2926fd33d9eeSAkhil Goyal &pkt_aes_128_gcm), 2927fd33d9eeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2928fd33d9eeSAkhil Goyal "ESN and Antireplay with window size 1024", 2929fd33d9eeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2930fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay1024, 2931fd33d9eeSAkhil Goyal &pkt_aes_128_gcm), 2932fd33d9eeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2933fd33d9eeSAkhil Goyal "ESN and Antireplay with window size 2048", 2934fd33d9eeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2935fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay2048, 2936fd33d9eeSAkhil Goyal &pkt_aes_128_gcm), 2937fd33d9eeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2938fd33d9eeSAkhil Goyal "ESN and Antireplay with window size 4096", 2939fd33d9eeSAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2940fd33d9eeSAkhil Goyal test_ipsec_inline_proto_pkt_esn_antireplay4096, 2941fd33d9eeSAkhil Goyal &pkt_aes_128_gcm), 2942fd33d9eeSAkhil Goyal 2943fd33d9eeSAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2944a3105777SAkhil Goyal "IPv4 Reassembly with 2 fragments", 2945a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2946a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_2frag_vector), 2947a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2948a3105777SAkhil Goyal "IPv6 Reassembly with 2 fragments", 2949a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2950a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv6_2frag_vector), 2951a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2952a3105777SAkhil Goyal "IPv4 Reassembly with 4 fragments", 2953a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2954a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_4frag_vector), 2955a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2956a3105777SAkhil Goyal "IPv6 Reassembly with 4 fragments", 2957a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2958a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv6_4frag_vector), 2959a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2960a3105777SAkhil Goyal "IPv4 Reassembly with 5 fragments", 2961a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2962a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_5frag_vector), 2963a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2964a3105777SAkhil Goyal "IPv6 Reassembly with 5 fragments", 2965a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2966a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv6_5frag_vector), 2967a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2968a3105777SAkhil Goyal "IPv4 Reassembly with incomplete fragments", 2969a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2970a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_incomplete_vector), 2971a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2972a3105777SAkhil Goyal "IPv4 Reassembly with overlapping fragments", 2973a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2974a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_overlap_vector), 2975a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2976a3105777SAkhil Goyal "IPv4 Reassembly with out of order fragments", 2977a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2978a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_out_of_order_vector), 2979a3105777SAkhil Goyal TEST_CASE_NAMED_WITH_DATA( 2980a3105777SAkhil Goyal "IPv4 Reassembly with burst of 4 fragments", 2981a3105777SAkhil Goyal ut_setup_inline_ipsec, ut_teardown_inline_ipsec, 2982a3105777SAkhil Goyal test_inline_ip_reassembly, &ipv4_4frag_burst_vector), 298386e2487cSAkhil Goyal 298486e2487cSAkhil Goyal TEST_CASES_END() /**< NULL terminate unit test array */ 298586e2487cSAkhil Goyal }, 298686e2487cSAkhil Goyal }; 298786e2487cSAkhil Goyal 298886e2487cSAkhil Goyal 298986e2487cSAkhil Goyal static int 299086e2487cSAkhil Goyal test_inline_ipsec(void) 299186e2487cSAkhil Goyal { 299210864656SVolodymyr Fialko inline_ipsec_testsuite.setup = inline_ipsec_testsuite_setup; 299310864656SVolodymyr Fialko inline_ipsec_testsuite.teardown = inline_ipsec_testsuite_teardown; 299410864656SVolodymyr Fialko return unit_test_suite_runner(&inline_ipsec_testsuite); 299510864656SVolodymyr Fialko } 299610864656SVolodymyr Fialko 299710864656SVolodymyr Fialko static int 299810864656SVolodymyr Fialko test_event_inline_ipsec(void) 299910864656SVolodymyr Fialko { 300010864656SVolodymyr Fialko inline_ipsec_testsuite.setup = event_inline_ipsec_testsuite_setup; 300110864656SVolodymyr Fialko inline_ipsec_testsuite.teardown = event_inline_ipsec_testsuite_teardown; 300286e2487cSAkhil Goyal return unit_test_suite_runner(&inline_ipsec_testsuite); 300386e2487cSAkhil Goyal } 300486e2487cSAkhil Goyal 300586e2487cSAkhil Goyal #endif /* !RTE_EXEC_ENV_WINDOWS */ 300686e2487cSAkhil Goyal 300786e2487cSAkhil Goyal REGISTER_TEST_COMMAND(inline_ipsec_autotest, test_inline_ipsec); 300810864656SVolodymyr Fialko REGISTER_TEST_COMMAND(event_inline_ipsec_autotest, test_event_inline_ipsec); 3009