DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nithin Dabilpuram <ndabilpuram@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>, Fan Zhang <royzhang1980@gmail.com>
Cc: <jerinj@marvell.com>, <dev@dpdk.org>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>
Subject: [PATCH] app/test: add support to run multi-seg inline IPsec test
Date: Thu, 20 Oct 2022 12:16:48 +0530	[thread overview]
Message-ID: <20221020064650.2764464-1-ndabilpuram@marvell.com> (raw)

Add support to run multi-seg inline ipsec test using
new test comman `inline_ipsec_sg_autotest`

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
---
 app/test/test_cryptodev_security_ipsec.c |  97 ++++++++++++++++-
 app/test/test_cryptodev_security_ipsec.h |   6 +-
 app/test/test_security_inline_proto.c    | 133 +++++++++++++++++++++--
 3 files changed, 218 insertions(+), 18 deletions(-)

diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c
index cb77b39dbb..f7569aba1b 100644
--- a/app/test/test_cryptodev_security_ipsec.c
+++ b/app/test/test_cryptodev_security_ipsec.c
@@ -445,6 +445,65 @@ test_ipsec_td_prepare(const struct crypto_param *param1,
 			}
 		}
 
+		/* Adjust the data to requested length */
+		if (flags->plaintext_len && flags->ipv6) {
+			struct rte_ipv6_hdr *ip6 = (struct rte_ipv6_hdr *)td->input_text.data;
+			struct rte_tcp_hdr *tcp;
+			int64_t payload_len;
+			uint8_t *data;
+			int64_t i;
+
+			payload_len = RTE_MIN(flags->plaintext_len, IPSEC_TEXT_MAX_LEN);
+			payload_len -= sizeof(struct rte_ipv6_hdr);
+			payload_len -= sizeof(struct rte_tcp_hdr);
+			if (payload_len <= 16)
+				payload_len = 16;
+
+			/* IPv6 */
+			ip6->proto = IPPROTO_TCP;
+			ip6->payload_len = sizeof(*tcp) + payload_len;
+			ip6->payload_len = rte_cpu_to_be_16(ip6->payload_len);
+
+			/* TCP */
+			tcp = (struct rte_tcp_hdr *)(ip6 + 1);
+			data = (uint8_t *)(tcp + 1);
+			for (i = 0; i < payload_len; i++)
+				data[i] = i;
+			tcp->cksum = 0;
+			tcp->cksum = rte_ipv6_udptcp_cksum(ip6, tcp);
+			td->input_text.len = payload_len + sizeof(struct rte_ipv6_hdr) +
+				sizeof(struct rte_tcp_hdr);
+		} else if (flags->plaintext_len) {
+			struct rte_ipv4_hdr *ip = (struct rte_ipv4_hdr *)td->input_text.data;
+			struct rte_tcp_hdr *tcp;
+			int64_t payload_len;
+			uint8_t *data;
+			int64_t i;
+
+			payload_len = RTE_MIN(flags->plaintext_len, IPSEC_TEXT_MAX_LEN);
+			payload_len -= sizeof(struct rte_ipv4_hdr);
+			payload_len -= sizeof(struct rte_tcp_hdr);
+			if (payload_len <= 8)
+				payload_len = 8;
+
+			/* IPv4 */
+			ip->next_proto_id = IPPROTO_TCP;
+			ip->total_length = sizeof(*ip) + sizeof(*tcp) + payload_len;
+			ip->total_length = rte_cpu_to_be_16(ip->total_length);
+			ip->hdr_checksum = 0;
+			ip->hdr_checksum = rte_ipv4_cksum(ip);
+
+			/* TCP */
+			tcp = (struct rte_tcp_hdr *)(ip + 1);
+			data = (uint8_t *)(tcp + 1);
+			for (i = 0; i < payload_len; i++)
+				data[i] = i;
+			tcp->cksum = 0;
+			tcp->cksum = rte_ipv4_udptcp_cksum(ip, tcp);
+			td->input_text.len = payload_len + sizeof(struct rte_ipv4_hdr) +
+				sizeof(struct rte_tcp_hdr);
+		}
+
 		if (flags->ah) {
 			td->ipsec_xform.proto =
 					RTE_SECURITY_IPSEC_SA_PROTO_AH;
@@ -662,13 +721,23 @@ static int
 test_ipsec_l4_csum_verify(struct rte_mbuf *m)
 {
 	uint16_t actual_cksum = 0, expected_cksum = 0;
+	uint32_t len = rte_pktmbuf_pkt_len(m);
+	uint8_t data_arr[IPSEC_TEXT_MAX_LEN];
 	struct rte_ipv4_hdr *ipv4;
 	struct rte_ipv6_hdr *ipv6;
+	uint8_t *data = data_arr;
 	struct rte_tcp_hdr *tcp;
 	struct rte_udp_hdr *udp;
+	const uint8_t *ptr;
 	void *ip, *l4;
 
-	ip = rte_pktmbuf_mtod(m, void *);
+	ptr = rte_pktmbuf_read(m, 0, len, data_arr);
+	if (!ptr)
+		return -EINVAL;
+	else if (ptr != data_arr)
+		data = rte_pktmbuf_mtod_offset(m, uint8_t *, 0);
+
+	ip = (struct rte_ipv4_hdr *)data;
 
 	if (is_ipv4(ip)) {
 		ipv4 = ip;
@@ -748,9 +817,11 @@ static int
 test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 		     bool silent, const struct ipsec_test_flags *flags)
 {
-	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t skip, len = rte_pktmbuf_pkt_len(m);
-	uint8_t td_output_text[4096];
+	uint8_t td_output_text[IPSEC_TEXT_MAX_LEN];
+	uint8_t data_arr[IPSEC_TEXT_MAX_LEN];
+	uint8_t *output_text = data_arr;
+	const uint8_t *ptr;
 	int ret;
 
 	/* For tests with status as error for test success, skip verification */
@@ -761,6 +832,12 @@ test_ipsec_td_verify(struct rte_mbuf *m, const struct ipsec_test_data *td,
 	     td->ar_packet))
 		return TEST_SUCCESS;
 
+	ptr = rte_pktmbuf_read(m, 0, len, data_arr);
+	if (!ptr)
+		return -EINVAL;
+	else if (ptr != data_arr)
+		output_text = rte_pktmbuf_mtod_offset(m, uint8_t *, 0);
+
 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
 	   flags->udp_encap) {
 		const struct rte_ipv4_hdr *iph4;
@@ -868,10 +945,20 @@ test_ipsec_res_d_prepare(struct rte_mbuf *m, const struct ipsec_test_data *td,
 {
 	uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
 	uint32_t len = rte_pktmbuf_pkt_len(m);
+	struct rte_mbuf *next = m;
+	uint32_t off = 0;
 
 	memcpy(res_d, td, sizeof(*res_d));
-	memcpy(res_d->input_text.data, output_text, len);
-	res_d->input_text.len = len;
+
+	while (next && off < len) {
+		output_text = rte_pktmbuf_mtod(next, uint8_t *);
+		if (off + next->data_len > sizeof(res_d->input_text.data))
+			break;
+		memcpy(&res_d->input_text.data[off], output_text, next->data_len);
+		off += next->data_len;
+		next = next->next;
+	}
+	res_d->input_text.len = off;
 
 	res_d->ipsec_xform.direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
 	if (res_d->aead) {
diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h
index 67b783e637..cc0bf14777 100644
--- a/app/test/test_cryptodev_security_ipsec.h
+++ b/app/test/test_cryptodev_security_ipsec.h
@@ -9,6 +9,7 @@
 #include <rte_security.h>
 
 #define IPSEC_TEST_PACKETS_MAX 32
+#define IPSEC_TEXT_MAX_LEN 16384u
 
 struct ipsec_test_data {
 	struct {
@@ -19,12 +20,12 @@ struct ipsec_test_data {
 	} auth_key;
 
 	struct {
-		uint8_t data[1024];
+		uint8_t data[IPSEC_TEXT_MAX_LEN];
 		unsigned int len;
 	} input_text;
 
 	struct {
-		uint8_t data[1024];
+		uint8_t data[IPSEC_TEXT_MAX_LEN];
 		unsigned int len;
 	} output_text;
 
@@ -106,6 +107,7 @@ struct ipsec_test_flags {
 	enum flabel_flags flabel;
 	bool dec_ttl_or_hop_limit;
 	bool ah;
+	uint32_t plaintext_len;
 };
 
 struct crypto_param {
diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c
index 19297d3628..1ffbe76083 100644
--- a/app/test/test_security_inline_proto.c
+++ b/app/test/test_security_inline_proto.c
@@ -106,6 +106,8 @@ static uint16_t port_id;
 static uint8_t eventdev_id;
 static uint8_t rx_adapter_id;
 static uint8_t tx_adapter_id;
+static uint16_t plaintext_len;
+static bool sg_mode;
 
 static bool event_mode_enabled;
 
@@ -399,20 +401,26 @@ copy_buf_to_pkt_segs(const uint8_t *buf, unsigned int len,
 	void *seg_buf;
 
 	seg = pkt;
-	while (offset >= seg->data_len) {
-		offset -= seg->data_len;
+	while (offset >= rte_pktmbuf_tailroom(seg)) {
+		offset -= rte_pktmbuf_tailroom(seg);
 		seg = seg->next;
 	}
-	copy_len = seg->data_len - offset;
+	copy_len = seg->buf_len - seg->data_off - offset;
 	seg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);
 	while (len > copy_len) {
 		rte_memcpy(seg_buf, buf + copied, (size_t) copy_len);
 		len -= copy_len;
 		copied += copy_len;
+		seg->data_len += copy_len;
+
 		seg = seg->next;
+		copy_len = seg->buf_len - seg->data_off;
 		seg_buf = rte_pktmbuf_mtod(seg, void *);
 	}
 	rte_memcpy(seg_buf, buf + copied, (size_t) len);
+	seg->data_len = len;
+
+	pkt->pkt_len += copied + len;
 }
 
 static bool
@@ -431,7 +439,8 @@ is_outer_ipv4(struct ipsec_test_data *td)
 static inline struct rte_mbuf *
 init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len, bool outer_ipv4)
 {
-	struct rte_mbuf *pkt;
+	struct rte_mbuf *pkt, *tail;
+	uint16_t space;
 
 	pkt = rte_pktmbuf_alloc(mp);
 	if (pkt == NULL)
@@ -448,11 +457,31 @@ init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len, bool
 	}
 	pkt->l2_len = RTE_ETHER_HDR_LEN;
 
-	if (pkt->buf_len > (len + RTE_ETHER_HDR_LEN))
+	space = rte_pktmbuf_tailroom(pkt);
+	tail = pkt;
+	/* Error if SG mode is not enabled */
+	if (!sg_mode && space < len) {
+		rte_pktmbuf_free(pkt);
+		return NULL;
+	}
+	/* Extra room for expansion */
+	while (space < len) {
+		tail->next = rte_pktmbuf_alloc(mp);
+		if (!tail->next)
+			goto error;
+		tail = tail->next;
+		space += rte_pktmbuf_tailroom(tail);
+		pkt->nb_segs++;
+	}
+
+	if (pkt->buf_len > len + RTE_ETHER_HDR_LEN)
 		rte_memcpy(rte_pktmbuf_append(pkt, len), data, len);
 	else
 		copy_buf_to_pkt_segs(data, len, pkt, RTE_ETHER_HDR_LEN);
 	return pkt;
+error:
+	rte_pktmbuf_free(pkt);
+	return NULL;
 }
 
 static int
@@ -466,7 +495,7 @@ init_mempools(unsigned int nb_mbuf)
 	if (mbufpool == NULL) {
 		snprintf(s, sizeof(s), "mbuf_pool");
 		mbufpool = rte_pktmbuf_pool_create(s, nb_mbuf,
-				MEMPOOL_CACHE_SIZE, 0,
+				MEMPOOL_CACHE_SIZE, RTE_CACHE_LINE_SIZE,
 				RTE_MBUF_DEFAULT_BUF_SIZE, SOCKET_ID_ANY);
 		if (mbufpool == NULL) {
 			printf("Cannot init mbuf pool\n");
@@ -1468,6 +1497,8 @@ ut_teardown_inline_ipsec(void)
 static int
 inline_ipsec_testsuite_setup(void)
 {
+	struct rte_eth_conf local_port_conf;
+	struct rte_eth_dev_info dev_info;
 	uint16_t nb_rxd;
 	uint16_t nb_txd;
 	uint16_t nb_ports;
@@ -1510,9 +1541,25 @@ inline_ipsec_testsuite_setup(void)
 
 	/* configuring port 0 for the test is enough */
 	port_id = 0;
+	if (rte_eth_dev_info_get(0, &dev_info)) {
+		printf("Failed to get devinfo");
+		return -1;
+	}
+
+	memcpy(&local_port_conf, &port_conf, sizeof(port_conf));
+	/* Add Multi seg flags */
+	if (sg_mode) {
+		uint16_t max_data_room = RTE_MBUF_DEFAULT_DATAROOM *
+			dev_info.rx_desc_lim.nb_seg_max;
+
+		local_port_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_SCATTER;
+		local_port_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+		local_port_conf.rxmode.mtu = RTE_MIN(dev_info.max_mtu, max_data_room - 256);
+	}
+
 	/* port configure */
 	ret = rte_eth_dev_configure(port_id, nb_rx_queue,
-				    nb_tx_queue, &port_conf);
+				    nb_tx_queue, &local_port_conf);
 	if (ret < 0) {
 		printf("Cannot configure device: err=%d, port=%d\n",
 			 ret, port_id);
@@ -1546,6 +1593,15 @@ inline_ipsec_testsuite_setup(void)
 	}
 	test_ipsec_alg_list_populate();
 
+	/* Change the plaintext size for tests without Known vectors */
+	if (sg_mode) {
+		/* Leave space of 256B as ESP packet would be bigger and we
+		 * expect packets to be received back on same interface.
+		 * Without SG mode, default value is picked.
+		 */
+		plaintext_len = local_port_conf.rxmode.mtu - 256;
+	}
+
 	return 0;
 }
 
@@ -1922,6 +1978,7 @@ test_ipsec_inline_proto_display_list(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.display_alg = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -1934,6 +1991,7 @@ test_ipsec_inline_proto_udp_encap(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.udp_encap = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -1947,6 +2005,7 @@ test_ipsec_inline_proto_udp_ports_verify(const void *data __rte_unused)
 
 	flags.udp_encap = true;
 	flags.udp_ports_verify = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -1959,6 +2018,7 @@ test_ipsec_inline_proto_err_icv_corrupt(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.icv_corrupt = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -1971,6 +2031,7 @@ test_ipsec_inline_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -1983,6 +2044,7 @@ test_ipsec_inline_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused
 	memset(&flags, 0, sizeof(flags));
 
 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -1995,6 +2057,7 @@ test_ipsec_inline_proto_inner_ip_csum(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.ip_csum = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2007,6 +2070,7 @@ test_ipsec_inline_proto_inner_l4_csum(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.l4_csum = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2020,6 +2084,7 @@ test_ipsec_inline_proto_tunnel_v4_in_v4(const void *data __rte_unused)
 
 	flags.ipv6 = false;
 	flags.tunnel_ipv6 = false;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2033,6 +2098,7 @@ test_ipsec_inline_proto_tunnel_v6_in_v6(const void *data __rte_unused)
 
 	flags.ipv6 = true;
 	flags.tunnel_ipv6 = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2046,6 +2112,7 @@ test_ipsec_inline_proto_tunnel_v4_in_v6(const void *data __rte_unused)
 
 	flags.ipv6 = false;
 	flags.tunnel_ipv6 = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2059,6 +2126,7 @@ test_ipsec_inline_proto_tunnel_v6_in_v4(const void *data __rte_unused)
 
 	flags.ipv6 = true;
 	flags.tunnel_ipv6 = false;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2072,6 +2140,7 @@ test_ipsec_inline_proto_transport_v4(const void *data __rte_unused)
 
 	flags.ipv6 = false;
 	flags.transport = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2082,6 +2151,7 @@ test_ipsec_inline_proto_transport_l4_csum(const void *data __rte_unused)
 	struct ipsec_test_flags flags = {
 		.l4_csum = true,
 		.transport = true,
+		.plaintext_len = plaintext_len,
 	};
 
 	return test_ipsec_inline_proto_all(&flags);
@@ -2095,6 +2165,7 @@ test_ipsec_inline_proto_stats(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.stats_success = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2107,6 +2178,7 @@ test_ipsec_inline_proto_pkt_fragment(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.fragment = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 
@@ -2120,6 +2192,7 @@ test_ipsec_inline_proto_copy_df_inner_0(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2132,6 +2205,7 @@ test_ipsec_inline_proto_copy_df_inner_1(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2144,6 +2218,7 @@ test_ipsec_inline_proto_set_df_0_inner_1(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2156,6 +2231,7 @@ test_ipsec_inline_proto_set_df_1_inner_0(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2168,6 +2244,7 @@ test_ipsec_inline_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2180,6 +2257,7 @@ test_ipsec_inline_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2192,6 +2270,7 @@ test_ipsec_inline_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2204,6 +2283,7 @@ test_ipsec_inline_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2218,6 +2298,7 @@ test_ipsec_inline_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
 	flags.ipv6 = true;
 	flags.tunnel_ipv6 = true;
 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2232,6 +2313,7 @@ test_ipsec_inline_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
 	flags.ipv6 = true;
 	flags.tunnel_ipv6 = true;
 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2246,6 +2328,7 @@ test_ipsec_inline_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
 	flags.ipv6 = true;
 	flags.tunnel_ipv6 = true;
 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2260,6 +2343,7 @@ test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
 	flags.ipv6 = true;
 	flags.tunnel_ipv6 = true;
 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2324,7 +2408,8 @@ static int
 test_ipsec_inline_proto_ipv4_ttl_decrement(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags = {
-		.dec_ttl_or_hop_limit = true
+		.dec_ttl_or_hop_limit = true,
+		.plaintext_len = plaintext_len,
 	};
 
 	return test_ipsec_inline_proto_all(&flags);
@@ -2335,7 +2420,8 @@ test_ipsec_inline_proto_ipv6_hop_limit_decrement(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags = {
 		.ipv6 = true,
-		.dec_ttl_or_hop_limit = true
+		.dec_ttl_or_hop_limit = true,
+		.plaintext_len = plaintext_len,
 	};
 
 	return test_ipsec_inline_proto_all(&flags);
@@ -2349,6 +2435,7 @@ test_ipsec_inline_proto_iv_gen(const void *data __rte_unused)
 	memset(&flags, 0, sizeof(flags));
 
 	flags.iv_gen = true;
+	flags.plaintext_len = plaintext_len;
 
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2357,7 +2444,8 @@ static int
 test_ipsec_inline_proto_sa_pkt_soft_expiry(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags = {
-		.sa_expiry_pkts_soft = true
+		.sa_expiry_pkts_soft = true,
+		.plaintext_len = plaintext_len,
 	};
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2365,7 +2453,8 @@ static int
 test_ipsec_inline_proto_sa_byte_soft_expiry(const void *data __rte_unused)
 {
 	struct ipsec_test_flags flags = {
-		.sa_expiry_bytes_soft = true
+		.sa_expiry_bytes_soft = true,
+		.plaintext_len = plaintext_len,
 	};
 	return test_ipsec_inline_proto_all(&flags);
 }
@@ -2398,6 +2487,7 @@ test_ipsec_inline_proto_known_vec_fragmented(const void *test_data)
 
 	memset(&flags, 0, sizeof(flags));
 	flags.fragment = true;
+	flags.plaintext_len = plaintext_len;
 
 	memcpy(&td_outb, test_data, sizeof(td_outb));
 
@@ -2420,6 +2510,7 @@ test_ipsec_inline_pkt_replay(const void *test_data, const uint64_t esn[],
 
 	memset(&flags, 0, sizeof(flags));
 	flags.antireplay = true;
+	flags.plaintext_len = plaintext_len;
 
 	for (i = 0; i < nb_pkts; i++) {
 		memcpy(&td_outb[i], test_data, sizeof(td_outb[0]));
@@ -2894,6 +2985,25 @@ test_inline_ipsec(void)
 	return unit_test_suite_runner(&inline_ipsec_testsuite);
 }
 
+
+static int
+test_inline_ipsec_sg(void)
+{
+	int rc;
+
+	inline_ipsec_testsuite.setup = inline_ipsec_testsuite_setup;
+	inline_ipsec_testsuite.teardown = inline_ipsec_testsuite_teardown;
+
+	sg_mode = true;
+	/* Run the tests */
+	rc = unit_test_suite_runner(&inline_ipsec_testsuite);
+	sg_mode = false;
+
+	port_conf.rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_SCATTER;
+	port_conf.txmode.offloads &= ~RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+	return rc;
+}
+
 static int
 test_event_inline_ipsec(void)
 {
@@ -2905,4 +3015,5 @@ test_event_inline_ipsec(void)
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
 REGISTER_TEST_COMMAND(inline_ipsec_autotest, test_inline_ipsec);
+REGISTER_TEST_COMMAND(inline_ipsec_sg_autotest, test_inline_ipsec_sg);
 REGISTER_TEST_COMMAND(event_inline_ipsec_autotest, test_event_inline_ipsec);
-- 
2.25.1


             reply	other threads:[~2022-10-20  6:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  6:46 Nithin Dabilpuram [this message]
2022-10-20  8:14 ` [PATCH v2] " Nithin Dabilpuram
2022-10-27 10:07   ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221020064650.2764464-1-ndabilpuram@marvell.com \
    --to=ndabilpuram@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=royzhang1980@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).