Skip to contentSkip to conversation

RFC: ethdev: add reassembly offload

PATCH In review Akhil Goyal 12 participants 184 messages Aug 23, 2021 – Sep 27, 2022 Arm/Amlogic Meson SoC support Page 2 of 2

lore
Share & tools
lore
#109 lore raw

PATCH v7 4/7 test/security: add inline IPsec reassembly cases

In reply to Akhil Goyal

Added unit test cases for IP reassembly of inline IPsec inbound scenarios.
In these cases, known test vectors of fragments are first processed for inline outbound processing and then received back on loopback interface for inbound processing along with IP reassembly of the corresponding decrypted packets. The resultant plain text reassembled packet is compared with original unfragmented packet.

In this patch, cases are added for 2/4/5 fragments for both IPv4 and IPv6 packets. A few negative test cases are also added like incomplete fragments, out of place fragments, duplicate fragments.

---
 app/test/test_security_inline_proto.c         | 423 ++++++++++-
 app/test/test_security_inline_proto_vectors.h | 684 ++++++++++++++++++
 2 files changed, 1106 insertions(+), 1 deletion(-)
app/test/test_security_inline_proto.c +422 -1
index a44a4f9b04..e3e25af619 100644
@@ -41,6 +41,9 @@ test_inline_ipsec(void)
 #define MAX_TRAFFIC_BURST		2048
 #define NB_MBUF				10240
 
+#define ENCAP_DECAP_BURST_SZ		33
+#define APP_REASS_TIMEOUT		10
+
 extern struct ipsec_test_data pkt_aes_128_gcm;
 extern struct ipsec_test_data pkt_aes_192_gcm;
 extern struct ipsec_test_data pkt_aes_256_gcm;
@@ -94,6 +97,8 @@ uint16_t port_id;
 
 static uint64_t link_mbps;
 
+static int ip_reassembly_dynfield_offset = -1;
+
 static struct rte_flow *default_flow[RTE_MAX_ETHPORTS];
 
 /* Create Inline IPsec session */
@@ -530,6 +535,349 @@ destroy_default_flow(uint16_t portid)
 struct rte_mbuf **tx_pkts_burst;
 struct rte_mbuf **rx_pkts_burst;
 
+static int
+compare_pkt_data(struct rte_mbuf *m, uint8_t *ref, unsigned int tot_len)
+{
+	unsigned int len;
+	unsigned int nb_segs = m->nb_segs;
+	unsigned int matched = 0;
+	struct rte_mbuf *save = m;
+
+	while (m) {
+		len = tot_len;
+		if (len > m->data_len)
+			len = m->data_len;
+		if (len != 0) {
+			if (memcmp(rte_pktmbuf_mtod(m, char *),
+					ref + matched, len)) {
+				printf("\n====Reassembly case failed: Data Mismatch");
+				rte_hexdump(stdout, "Reassembled",
+					rte_pktmbuf_mtod(m, char *),
+					len);
+				rte_hexdump(stdout, "reference",
+					ref + matched,
+					len);
+				return TEST_FAILED;
+			}
+		}
+		tot_len -= len;
+		matched += len;
+		m = m->next;
+	}
+
+	if (tot_len) {
+		printf("\n====Reassembly case failed: Data Missing %u",
+		       tot_len);
+		printf("\n====nb_segs %u, tot_len %u", nb_segs, tot_len);
+		rte_pktmbuf_dump(stderr, save, -1);
+		return TEST_FAILED;
+	}
+	return TEST_SUCCESS;
+}
+
+static inline bool
+is_ip_reassembly_incomplete(struct rte_mbuf *mbuf)
+{
+	static uint64_t ip_reassembly_dynflag;
+	int ip_reassembly_dynflag_offset;
+
+	if (ip_reassembly_dynflag == 0) {
+		ip_reassembly_dynflag_offset = rte_mbuf_dynflag_lookup(
+			RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME, NULL);
+		if (ip_reassembly_dynflag_offset < 0)
+			return false;
+		ip_reassembly_dynflag = RTE_BIT64(ip_reassembly_dynflag_offset);
+	}
+
+	return (mbuf->ol_flags & ip_reassembly_dynflag) != 0;
+}
+
+static void
+free_mbuf(struct rte_mbuf *mbuf)
+{
+	rte_eth_ip_reassembly_dynfield_t dynfield;
+
+	if (!mbuf)
+		return;
+
+	if (!is_ip_reassembly_incomplete(mbuf)) {
+		rte_pktmbuf_free(mbuf);
+	} else {
+		if (ip_reassembly_dynfield_offset < 0)
+			return;
+
+		while (mbuf) {
+			dynfield = *RTE_MBUF_DYNFIELD(mbuf,
+					ip_reassembly_dynfield_offset,
+					rte_eth_ip_reassembly_dynfield_t *);
+			rte_pktmbuf_free(mbuf);
+			mbuf = dynfield.next_frag;
+		}
+	}
+}
+
+
+static int
+get_and_verify_incomplete_frags(struct rte_mbuf *mbuf,
+				struct reassembly_vector *vector)
+{
+	rte_eth_ip_reassembly_dynfield_t *dynfield[MAX_PKT_BURST];
+	int j = 0, ret;
+	/**
+	 * IP reassembly offload is incomplete, and fragments are listed in
+	 * dynfield which can be reassembled in SW.
+	 */
+	printf("\nHW IP Reassembly is not complete; attempt SW IP Reassembly,"
+		"\nMatching with original frags.");
+
+	if (ip_reassembly_dynfield_offset < 0)
+		return -1;
+
+	printf("\ncomparing frag: %d", j);
+	/* Skip Ethernet header comparison */
+	rte_pktmbuf_adj(mbuf, RTE_ETHER_HDR_LEN);
+	ret = compare_pkt_data(mbuf, vector->frags[j]->data,
+				vector->frags[j]->len);
+	if (ret)
+		return ret;
+	j++;
+	dynfield[j] = RTE_MBUF_DYNFIELD(mbuf, ip_reassembly_dynfield_offset,
+					rte_eth_ip_reassembly_dynfield_t *);
+	printf("\ncomparing frag: %d", j);
+	/* Skip Ethernet header comparison */
+	rte_pktmbuf_adj(dynfield[j]->next_frag, RTE_ETHER_HDR_LEN);
+	ret = compare_pkt_data(dynfield[j]->next_frag, vector->frags[j]->data,
+			vector->frags[j]->len);
+	if (ret)
+		return ret;
+
+	while ((dynfield[j]->nb_frags > 1) &&
+			is_ip_reassembly_incomplete(dynfield[j]->next_frag)) {
+		j++;
+		dynfield[j] = RTE_MBUF_DYNFIELD(dynfield[j-1]->next_frag,
+					ip_reassembly_dynfield_offset,
+					rte_eth_ip_reassembly_dynfield_t *);
+		printf("\ncomparing frag: %d", j);
+		/* Skip Ethernet header comparison */
+		rte_pktmbuf_adj(dynfield[j]->next_frag, RTE_ETHER_HDR_LEN);
+		ret = compare_pkt_data(dynfield[j]->next_frag,
+				vector->frags[j]->data, vector->frags[j]->len);
+		if (ret)
+			return ret;
+	}
+	return ret;
+}
+
+static int
+test_ipsec_with_reassembly(struct reassembly_vector *vector,
+		const struct ipsec_test_flags *flags)
+{
+	struct rte_security_session *out_ses[ENCAP_DECAP_BURST_SZ] = {0};
+	struct rte_security_session *in_ses[ENCAP_DECAP_BURST_SZ] = {0};
+	struct rte_eth_ip_reassembly_params reass_capa = {0};
+	struct rte_security_session_conf sess_conf_out = {0};
+	struct rte_security_session_conf sess_conf_in = {0};
+	unsigned int nb_tx, burst_sz, nb_sent = 0;
+	struct rte_crypto_sym_xform cipher_out = {0};
+	struct rte_crypto_sym_xform auth_out = {0};
+	struct rte_crypto_sym_xform aead_out = {0};
+	struct rte_crypto_sym_xform cipher_in = {0};
+	struct rte_crypto_sym_xform auth_in = {0};
+	struct rte_crypto_sym_xform aead_in = {0};
+	struct ipsec_test_data sa_data;
+	struct rte_security_ctx *ctx;
+	unsigned int i, nb_rx = 0, j;
+	uint32_t ol_flags;
+	int ret = 0;
+
+	burst_sz = vector->burst ? ENCAP_DECAP_BURST_SZ : 1;
+	nb_tx = vector->nb_frags * burst_sz;
+
+	rte_eth_dev_stop(port_id);
+	if (ret != 0) {
+		printf("rte_eth_dev_stop: err=%s, port=%u\n",
+			       rte_strerror(-ret), port_id);
+		return ret;
+	}
+	rte_eth_ip_reassembly_capability_get(port_id, &reass_capa);
+	if (reass_capa.max_frags < vector->nb_frags)
+		return TEST_SKIPPED;
+	if (reass_capa.timeout_ms > APP_REASS_TIMEOUT) {
+		reass_capa.timeout_ms = APP_REASS_TIMEOUT;
+		rte_eth_ip_reassembly_conf_set(port_id, &reass_capa);
+	}
+
+	ret = rte_eth_dev_start(port_id);
+	if (ret < 0) {
+		printf("rte_eth_dev_start: err=%d, port=%d\n",
+			ret, port_id);
+		return ret;
+	}
+
+	memset(tx_pkts_burst, 0, sizeof(tx_pkts_burst[0]) * nb_tx);
+	memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_tx);
+
+	for (i = 0; i < nb_tx; i += vector->nb_frags) {
+		for (j = 0; j < vector->nb_frags; j++) {
+			tx_pkts_burst[i+j] = init_packet(mbufpool,
+						vector->frags[j]->data,
+						vector->frags[j]->len);
+			if (tx_pkts_burst[i+j] == NULL) {
+				ret = -1;
+				printf("\n packed init failed\n");
+				goto out;
+			}
+		}
+	}
+
+	for (i = 0; i < burst_sz; i++) {
+		memcpy(&sa_data, vector->sa_data,
+				sizeof(struct ipsec_test_data));
+		/* Update SPI for every new SA */
+		sa_data.ipsec_xform.spi += i;
+		sa_data.ipsec_xform.direction =
+					RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
+		if (sa_data.aead) {
+			sess_conf_out.crypto_xform = &aead_out;
+		} else {
+			sess_conf_out.crypto_xform = &cipher_out;
+			sess_conf_out.crypto_xform->next = &auth_out;
+		}
+
+		/* Create Inline IPsec outbound session. */
+		ret = create_inline_ipsec_session(&sa_data, port_id,
+				&out_ses[i], &ctx, &ol_flags, flags,
+				&sess_conf_out);
+		if (ret) {
+			printf("\nInline outbound session create failed\n");
+			goto out;
+		}
+	}
+
+	j = 0;
+	for (i = 0; i < nb_tx; i++) {
+		if (ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
+			rte_security_set_pkt_metadata(ctx,
+				out_ses[j], tx_pkts_burst[i], NULL);
+		tx_pkts_burst[i]->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD;
+
+		/* Move to next SA after nb_frags */
+		if ((i + 1) % vector->nb_frags == 0)
+			j++;
+	}
+
+	for (i = 0; i < burst_sz; i++) {
+		memcpy(&sa_data, vector->sa_data,
+				sizeof(struct ipsec_test_data));
+		/* Update SPI for every new SA */
+		sa_data.ipsec_xform.spi += i;
+		sa_data.ipsec_xform.direction =
+					RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
+
+		if (sa_data.aead) {
+			sess_conf_in.crypto_xform = &aead_in;
+		} else {
+			sess_conf_in.crypto_xform = &auth_in;
+			sess_conf_in.crypto_xform->next = &cipher_in;
+		}
+		/* Create Inline IPsec inbound session. */
+		ret = create_inline_ipsec_session(&sa_data, port_id, &in_ses[i],
+				&ctx, &ol_flags, flags, &sess_conf_in);
+		if (ret) {
+			printf("\nInline inbound session create failed\n");
+			goto out;
+		}
+	}
+
+	/* Retrieve reassembly dynfield offset if available */
+	if (ip_reassembly_dynfield_offset < 0 && vector->nb_frags > 1)
+		ip_reassembly_dynfield_offset = rte_mbuf_dynfield_lookup(
+				RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME, NULL);
+
+
+	ret = create_default_flow(port_id);
+	if (ret)
+		goto out;
+
+	nb_sent = rte_eth_tx_burst(port_id, 0, tx_pkts_burst, nb_tx);
+	if (nb_sent != nb_tx) {
+		ret = -1;
+		printf("\nFailed to tx %u pkts", nb_tx);
+		goto out;
+	}
+
+	rte_delay_ms(1);
+
+	/* Retry few times before giving up */
+	nb_rx = 0;
+	j = 0;
+	do {
+		nb_rx += rte_eth_rx_burst(port_id, 0, &rx_pkts_burst[nb_rx],
+					  nb_tx - nb_rx);
+		j++;
+		if (nb_rx >= nb_tx)
+			break;
+		rte_delay_ms(1);
+	} while (j < 5 || !nb_rx);
+
+	/* Check for minimum number of Rx packets expected */
+	if ((vector->nb_frags == 1 && nb_rx != nb_tx) ||
+	    (vector->nb_frags > 1 && nb_rx < burst_sz)) {
+		printf("\nreceived less Rx pkts(%u) pkts\n", nb_rx);
+		ret = TEST_FAILED;
+		goto out;
+	}
+
+	for (i = 0; i < nb_rx; i++) {
+		if (vector->nb_frags > 1 &&
+		    is_ip_reassembly_incomplete(rx_pkts_burst[i])) {
+			ret = get_and_verify_incomplete_frags(rx_pkts_burst[i],
+							      vector);
+			if (ret != TEST_SUCCESS)
+				break;
+			continue;
+		}
+
+		if (rx_pkts_burst[i]->ol_flags &
+		    RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED ||
+		    !(rx_pkts_burst[i]->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
+			printf("\nsecurity offload failed\n");
+			ret = TEST_FAILED;
+			break;
+		}
+
+		if (vector->full_pkt->len + RTE_ETHER_HDR_LEN !=
+				rx_pkts_burst[i]->pkt_len) {
+			printf("\nreassembled/decrypted packet length mismatch\n");
+			ret = TEST_FAILED;
+			break;
+		}
+		rte_pktmbuf_adj(rx_pkts_burst[i], RTE_ETHER_HDR_LEN);
+		ret = compare_pkt_data(rx_pkts_burst[i],
+				       vector->full_pkt->data,
+				       vector->full_pkt->len);
+		if (ret != TEST_SUCCESS)
+			break;
+	}
+
+out:
+	destroy_default_flow(port_id);
+
+	/* Clear session data. */
+	for (i = 0; i < burst_sz; i++) {
+		if (out_ses[i])
+			rte_security_session_destroy(ctx, out_ses[i]);
+		if (in_ses[i])
+			rte_security_session_destroy(ctx, in_ses[i]);
+	}
+
+	for (i = nb_sent; i < nb_tx; i++)
+		free_mbuf(tx_pkts_burst[i]);
+	for (i = 0; i < nb_rx; i++)
+		free_mbuf(rx_pkts_burst[i]);
+	return ret;
+}
+
 static int
 test_ipsec_inline_proto_process(struct ipsec_test_data *td,
 		struct ipsec_test_data *res_d,
@@ -779,6 +1127,7 @@ ut_setup_inline_ipsec(void)
 static void
 ut_teardown_inline_ipsec(void)
 {
+	struct rte_eth_ip_reassembly_params reass_conf = {0};
 	uint16_t portid;
 	int ret;
 
@@ -788,6 +1137,9 @@ ut_teardown_inline_ipsec(void)
 		if (ret != 0)
 			printf("rte_eth_dev_stop: err=%s, port=%u\n",
 			       rte_strerror(-ret), portid);
+
+		/* Clear reassembly configuration */
+		rte_eth_ip_reassembly_conf_set(portid, &reass_conf);
 	}
 }
 
@@ -890,6 +1242,36 @@ inline_ipsec_testsuite_teardown(void)
 	}
 }
 
+static int
+test_inline_ip_reassembly(const void *testdata)
+{
+	struct reassembly_vector reassembly_td = {0};
+	const struct reassembly_vector *td = testdata;
+	struct ip_reassembly_test_packet full_pkt;
+	struct ip_reassembly_test_packet frags[MAX_FRAGS];
+	struct ipsec_test_flags flags = {0};
+	int i = 0;
+
+	reassembly_td.sa_data = td->sa_data;
+	reassembly_td.nb_frags = td->nb_frags;
+	reassembly_td.burst = td->burst;
+
+	memcpy(&full_pkt, td->full_pkt,
+			sizeof(struct ip_reassembly_test_packet));
+	reassembly_td.full_pkt = &full_pkt;
+
+	test_vector_payload_populate(reassembly_td.full_pkt, true);
+	for (; i < reassembly_td.nb_frags; i++) {
+		memcpy(&frags[i], td->frags[i],
+			sizeof(struct ip_reassembly_test_packet));
+		reassembly_td.frags[i] = &frags[i];
+		test_vector_payload_populate(reassembly_td.frags[i],
+				(i == 0) ? true : false);
+	}
+
+	return test_ipsec_with_reassembly(&reassembly_td, &flags);
+}
+
 static int
 test_ipsec_inline_proto_known_vec(const void *test_data)
 {
@@ -1036,7 +1418,46 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
 			test_ipsec_inline_proto_display_list),
 
-
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with 2 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_2frag_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv6 Reassembly with 2 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv6_2frag_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with 4 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_4frag_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv6 Reassembly with 4 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv6_4frag_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with 5 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_5frag_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv6 Reassembly with 5 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv6_5frag_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with incomplete fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_incomplete_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with overlapping fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_overlap_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with out of order fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_out_of_order_vector),
+		TEST_CASE_NAMED_WITH_DATA(
+			"IPv4 Reassembly with burst of 4 fragments",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_inline_ip_reassembly, &ipv4_4frag_burst_vector),
 
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	},
app/test/test_security_inline_proto_vectors.h +684 -0

688 lines not on this page · raw message

Signature · 1 line
2.25.1
#110 lore raw

PATCH v7 5/7 test/security: add more inline IPsec functional cases

In reply to Akhil Goyal

Added more inline IPsec functional verification cases. These cases do not have known vectors but are verified using encap + decap test for all the algo combinations.

---
 app/test/test_security_inline_proto.c | 517 ++++++++++++++++++++++++++
 1 file changed, 517 insertions(+)
app/test/test_security_inline_proto.c +517 -0
index e3e25af619..ecd7d69097 100644
@@ -1321,6 +1321,394 @@ test_ipsec_inline_proto_display_list(const void *data __rte_unused)
 	return test_ipsec_inline_proto_all(&flags);
 }
 
+static int
+test_ipsec_inline_proto_udp_encap(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.udp_encap = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_udp_ports_verify(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.udp_encap = true;
+	flags.udp_ports_verify = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.icv_corrupt = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_inner_ip_csum(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ip_csum = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_inner_l4_csum(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.l4_csum = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_tunnel_v4_in_v4(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = false;
+	flags.tunnel_ipv6 = false;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_tunnel_v6_in_v6(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = true;
+	flags.tunnel_ipv6 = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_tunnel_v4_in_v6(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = false;
+	flags.tunnel_ipv6 = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_tunnel_v6_in_v4(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = true;
+	flags.tunnel_ipv6 = false;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_transport_v4(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = false;
+	flags.transport = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_transport_l4_csum(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags = {
+		.l4_csum = true,
+		.transport = true,
+	};
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_stats(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.stats_success = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_pkt_fragment(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.fragment = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+
+}
+
+static int
+test_ipsec_inline_proto_copy_df_inner_0(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_copy_df_inner_1(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_set_df_0_inner_1(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_set_df_1_inner_0(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = true;
+	flags.tunnel_ipv6 = true;
+	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = true;
+	flags.tunnel_ipv6 = true;
+	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = true;
+	flags.tunnel_ipv6 = true;
+	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.ipv6 = true;
+	flags.tunnel_ipv6 = true;
+	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+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
+	};
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+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
+	};
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_iv_gen(const void *data __rte_unused)
+{
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+
+	flags.iv_gen = true;
+
+	return test_ipsec_inline_proto_all(&flags);
+}
+
+static int
+test_ipsec_inline_proto_known_vec_fragmented(const void *test_data)
+{
+	struct ipsec_test_data td_outb;
+	struct ipsec_test_flags flags;
+
+	memset(&flags, 0, sizeof(flags));
+	flags.fragment = true;
+
+	memcpy(&td_outb, test_data, sizeof(td_outb));
+
+	/* Disable IV gen to be able to test with known vectors */
+	td_outb.ipsec_xform.options.iv_gen_disable = 1;
+
+	return test_ipsec_inline_proto_process(&td_outb, NULL, 1, false,
+						&flags);
+}
 static struct unit_test_suite inline_ipsec_testsuite  = {
 	.suite_name = "Inline IPsec Ethernet Device Unit Test Suite",
 	.setup = inline_ipsec_testsuite_setup,
@@ -1367,6 +1755,13 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
 			test_ipsec_inline_proto_known_vec,
 			&pkt_null_aes_xcbc),
+
+		TEST_CASE_NAMED_WITH_DATA(
+			"Outbound fragmented packet",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_known_vec_fragmented,
+			&pkt_aes_128_gcm_frag),
+
 		TEST_CASE_NAMED_WITH_DATA(
 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
 			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
@@ -1418,6 +1813,128 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
 			test_ipsec_inline_proto_display_list),
 
+		TEST_CASE_NAMED_ST(
+			"UDP encapsulation",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_udp_encap),
+		TEST_CASE_NAMED_ST(
+			"UDP encapsulation ports verification test",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_udp_ports_verify),
+		TEST_CASE_NAMED_ST(
+			"Negative test: ICV corruption",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_err_icv_corrupt),
+		TEST_CASE_NAMED_ST(
+			"Tunnel dst addr verification",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_tunnel_dst_addr_verify),
+		TEST_CASE_NAMED_ST(
+			"Tunnel src and dst addr verification",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_tunnel_src_dst_addr_verify),
+		TEST_CASE_NAMED_ST(
+			"Inner IP checksum",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_inner_ip_csum),
+		TEST_CASE_NAMED_ST(
+			"Inner L4 checksum",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_inner_l4_csum),
+		TEST_CASE_NAMED_ST(
+			"Tunnel IPv4 in IPv4",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_tunnel_v4_in_v4),
+		TEST_CASE_NAMED_ST(
+			"Tunnel IPv6 in IPv6",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_tunnel_v6_in_v6),
+		TEST_CASE_NAMED_ST(
+			"Tunnel IPv4 in IPv6",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_tunnel_v4_in_v6),
+		TEST_CASE_NAMED_ST(
+			"Tunnel IPv6 in IPv4",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_tunnel_v6_in_v4),
+		TEST_CASE_NAMED_ST(
+			"Transport IPv4",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_transport_v4),
+		TEST_CASE_NAMED_ST(
+			"Transport l4 checksum",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_transport_l4_csum),
+		TEST_CASE_NAMED_ST(
+			"Statistics: success",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_stats),
+		TEST_CASE_NAMED_ST(
+			"Fragmented packet",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_fragment),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header copy DF (inner 0)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_copy_df_inner_0),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header copy DF (inner 1)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_copy_df_inner_1),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header set DF 0 (inner 1)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_set_df_0_inner_1),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header set DF 1 (inner 0)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_set_df_1_inner_0),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv4 copy DSCP (inner 0)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv4_copy_dscp_inner_0),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv4 copy DSCP (inner 1)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv4_copy_dscp_inner_1),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv4 set DSCP 0 (inner 1)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv4_set_dscp_0_inner_1),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv4 set DSCP 1 (inner 0)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv4_set_dscp_1_inner_0),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv6 copy DSCP (inner 0)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv6_copy_dscp_inner_0),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv6 copy DSCP (inner 1)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv6_copy_dscp_inner_1),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv6 set DSCP 0 (inner 1)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv6_set_dscp_0_inner_1),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv6 set DSCP 1 (inner 0)",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv6_set_dscp_1_inner_0),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv4 decrement inner TTL",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv4_ttl_decrement),
+		TEST_CASE_NAMED_ST(
+			"Tunnel header IPv6 decrement inner hop limit",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_ipv6_hop_limit_decrement),
+		TEST_CASE_NAMED_ST(
+			"IV generation",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_iv_gen),
+
+
 		TEST_CASE_NAMED_WITH_DATA(
 			"IPv4 Reassembly with 2 fragments",
 			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
Signature · 1 line
2.25.1
#111 lore raw

PATCH v7 6/7 test/security: add ESN and anti-replay cases for inline

In reply to Akhil Goyal

Added cases to test anti replay for inline IPsec processing with and without extended sequence number support.

---
 app/test/test_security_inline_proto.c | 311 ++++++++++++++++++++++++++
 1 file changed, 311 insertions(+)
app/test/test_security_inline_proto.c +311 -0
index ecd7d69097..518fb09113 100644
@@ -1098,6 +1098,139 @@ test_ipsec_inline_proto_all(const struct ipsec_test_flags *flags)
 		return TEST_SKIPPED;
 }
 
+static int
+test_ipsec_inline_proto_process_with_esn(struct ipsec_test_data td[],
+		struct ipsec_test_data res_d[],
+		int nb_pkts,
+		bool silent,
+		const struct ipsec_test_flags *flags)
+{
+	struct rte_security_session_conf sess_conf = {0};
+	struct ipsec_test_data *res_d_tmp = NULL;
+	struct rte_crypto_sym_xform cipher = {0};
+	struct rte_crypto_sym_xform auth = {0};
+	struct rte_crypto_sym_xform aead = {0};
+	struct rte_mbuf *rx_pkt = NULL;
+	struct rte_mbuf *tx_pkt = NULL;
+	int nb_rx, nb_sent;
+	struct rte_security_session *ses;
+	struct rte_security_ctx *ctx;
+	uint32_t ol_flags;
+	int i, ret;
+
+	if (td[0].aead) {
+		sess_conf.crypto_xform = &aead;
+	} else {
+		if (td[0].ipsec_xform.direction ==
+				RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
+			sess_conf.crypto_xform = &cipher;
+			sess_conf.crypto_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+			sess_conf.crypto_xform->next = &auth;
+			sess_conf.crypto_xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
+		} else {
+			sess_conf.crypto_xform = &auth;
+			sess_conf.crypto_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
+			sess_conf.crypto_xform->next = &cipher;
+			sess_conf.crypto_xform->next->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+		}
+	}
+
+	/* Create Inline IPsec session. */
+	ret = create_inline_ipsec_session(&td[0], port_id, &ses, &ctx,
+					  &ol_flags, flags, &sess_conf);
+	if (ret)
+		return ret;
+
+	if (td[0].ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
+		ret = create_default_flow(port_id);
+		if (ret)
+			goto out;
+	}
+
+	for (i = 0; i < nb_pkts; i++) {
+		tx_pkt = init_packet(mbufpool, td[i].input_text.data,
+					td[i].input_text.len);
+		if (tx_pkt == NULL) {
+			ret = TEST_FAILED;
+			goto out;
+		}
+
+		if (test_ipsec_pkt_update(rte_pktmbuf_mtod_offset(tx_pkt,
+					uint8_t *, RTE_ETHER_HDR_LEN), flags)) {
+			ret = TEST_FAILED;
+			goto out;
+		}
+
+		if (td[i].ipsec_xform.direction ==
+				RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
+			if (flags->antireplay) {
+				sess_conf.ipsec.esn.value =
+						td[i].ipsec_xform.esn.value;
+				ret = rte_security_session_update(ctx, ses,
+						&sess_conf);
+				if (ret) {
+					printf("Could not update ESN in session\n");
+					rte_pktmbuf_free(tx_pkt);
+					ret = TEST_SKIPPED;
+					goto out;
+				}
+			}
+			if (ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
+				rte_security_set_pkt_metadata(ctx, ses,
+						tx_pkt, NULL);
+			tx_pkt->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD;
+		}
+		/* Send packet to ethdev for inline IPsec processing. */
+		nb_sent = rte_eth_tx_burst(port_id, 0, &tx_pkt, 1);
+		if (nb_sent != 1) {
+			printf("\nUnable to TX packets");
+			rte_pktmbuf_free(tx_pkt);
+			ret = TEST_FAILED;
+			goto out;
+		}
+
+		rte_pause();
+
+		/* Receive back packet on loopback interface. */
+		do {
+			rte_delay_ms(1);
+			nb_rx = rte_eth_rx_burst(port_id, 0, &rx_pkt, 1);
+		} while (nb_rx == 0);
+
+		rte_pktmbuf_adj(rx_pkt, RTE_ETHER_HDR_LEN);
+
+		if (res_d != NULL)
+			res_d_tmp = &res_d[i];
+
+		ret = test_ipsec_post_process(rx_pkt, &td[i],
+					      res_d_tmp, silent, flags);
+		if (ret != TEST_SUCCESS) {
+			rte_pktmbuf_free(rx_pkt);
+			goto out;
+		}
+
+		ret = test_ipsec_stats_verify(ctx, ses, flags,
+					td->ipsec_xform.direction);
+		if (ret != TEST_SUCCESS) {
+			rte_pktmbuf_free(rx_pkt);
+			goto out;
+		}
+
+		rte_pktmbuf_free(rx_pkt);
+		rx_pkt = NULL;
+		tx_pkt = NULL;
+	}
+
+out:
+	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+		destroy_default_flow(port_id);
+
+	/* Destroy session so that other cases can create the session again */
+	rte_security_session_destroy(ctx, ses);
+	ses = NULL;
+
+	return ret;
+}
 
 static int
 ut_setup_inline_ipsec(void)
@@ -1709,6 +1842,153 @@ test_ipsec_inline_proto_known_vec_fragmented(const void *test_data)
 	return test_ipsec_inline_proto_process(&td_outb, NULL, 1, false,
 						&flags);
 }
+
+static int
+test_ipsec_inline_pkt_replay(const void *test_data, const uint64_t esn[],
+		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
+		      uint64_t winsz)
+{
+	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+	struct ipsec_test_flags flags;
+	uint32_t i, ret = 0;
+
+	memset(&flags, 0, sizeof(flags));
+	flags.antireplay = true;
+
+	for (i = 0; i < nb_pkts; i++) {
+		memcpy(&td_outb[i], test_data, sizeof(td_outb));
+		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
+		td_outb[i].ipsec_xform.replay_win_sz = winsz;
+		td_outb[i].ipsec_xform.options.esn = esn_en;
+	}
+
+	for (i = 0; i < nb_pkts; i++)
+		td_outb[i].ipsec_xform.esn.value = esn[i];
+
+	ret = test_ipsec_inline_proto_process_with_esn(td_outb, td_inb,
+				nb_pkts, true, &flags);
+	if (ret != TEST_SUCCESS)
+		return ret;
+
+	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
+
+	for (i = 0; i < nb_pkts; i++) {
+		td_inb[i].ipsec_xform.options.esn = esn_en;
+		/* Set antireplay flag for packets to be dropped */
+		td_inb[i].ar_packet = replayed_pkt[i];
+	}
+
+	ret = test_ipsec_inline_proto_process_with_esn(td_inb, NULL, nb_pkts,
+				true, &flags);
+
+	return ret;
+}
+
+static int
+test_ipsec_inline_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
+{
+
+	uint32_t nb_pkts = 5;
+	bool replayed_pkt[5];
+	uint64_t esn[5];
+
+	/* 1. Advance the TOP of the window to WS * 2 */
+	esn[0] = winsz * 2;
+	/* 2. Test sequence number within the new window(WS + 1) */
+	esn[1] = winsz + 1;
+	/* 3. Test sequence number less than the window BOTTOM */
+	esn[2] = winsz;
+	/* 4. Test sequence number in the middle of the window */
+	esn[3] = winsz + (winsz / 2);
+	/* 5. Test replay of the packet in the middle of the window */
+	esn[4] = winsz + (winsz / 2);
+
+	replayed_pkt[0] = false;
+	replayed_pkt[1] = false;
+	replayed_pkt[2] = true;
+	replayed_pkt[3] = false;
+	replayed_pkt[4] = true;
+
+	return test_ipsec_inline_pkt_replay(test_data, esn, replayed_pkt,
+			nb_pkts, false, winsz);
+}
+
+static int
+test_ipsec_inline_proto_pkt_antireplay1024(const void *test_data)
+{
+	return test_ipsec_inline_proto_pkt_antireplay(test_data, 1024);
+}
+
+static int
+test_ipsec_inline_proto_pkt_antireplay2048(const void *test_data)
+{
+	return test_ipsec_inline_proto_pkt_antireplay(test_data, 2048);
+}
+
+static int
+test_ipsec_inline_proto_pkt_antireplay4096(const void *test_data)
+{
+	return test_ipsec_inline_proto_pkt_antireplay(test_data, 4096);
+}
+
+static int
+test_ipsec_inline_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
+{
+
+	uint32_t nb_pkts = 7;
+	bool replayed_pkt[7];
+	uint64_t esn[7];
+
+	/* Set the initial sequence number */
+	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
+	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
+	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
+	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
+	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
+	/* 3. Test with sequence number within window (1<<32 - 1) */
+	esn[3] = (uint64_t)((1ULL << 32) - 1);
+	/* 4. Test with sequence number within window (1<<32 - 1) */
+	esn[4] = (uint64_t)(1ULL << 32);
+	/* 5. Test with duplicate sequence number within
+	 * new window (1<<32 - 1)
+	 */
+	esn[5] = (uint64_t)((1ULL << 32) - 1);
+	/* 6. Test with duplicate sequence number within new window (1<<32) */
+	esn[6] = (uint64_t)(1ULL << 32);
+
+	replayed_pkt[0] = false;
+	replayed_pkt[1] = false;
+	replayed_pkt[2] = false;
+	replayed_pkt[3] = false;
+	replayed_pkt[4] = false;
+	replayed_pkt[5] = true;
+	replayed_pkt[6] = true;
+
+	return test_ipsec_inline_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
+				     true, winsz);
+}
+
+static int
+test_ipsec_inline_proto_pkt_esn_antireplay1024(const void *test_data)
+{
+	return test_ipsec_inline_proto_pkt_esn_antireplay(test_data, 1024);
+}
+
+static int
+test_ipsec_inline_proto_pkt_esn_antireplay2048(const void *test_data)
+{
+	return test_ipsec_inline_proto_pkt_esn_antireplay(test_data, 2048);
+}
+
+static int
+test_ipsec_inline_proto_pkt_esn_antireplay4096(const void *test_data)
+{
+	return test_ipsec_inline_proto_pkt_esn_antireplay(test_data, 4096);
+}
+
+
+
 static struct unit_test_suite inline_ipsec_testsuite  = {
 	.suite_name = "Inline IPsec Ethernet Device Unit Test Suite",
 	.setup = inline_ipsec_testsuite_setup,
@@ -1935,6 +2215,37 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 			test_ipsec_inline_proto_iv_gen),
 
 
+		TEST_CASE_NAMED_WITH_DATA(
+			"Antireplay with window size 1024",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_antireplay1024,
+			&pkt_aes_128_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Antireplay with window size 2048",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_antireplay2048,
+			&pkt_aes_128_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"Antireplay with window size 4096",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_antireplay4096,
+			&pkt_aes_128_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"ESN and Antireplay with window size 1024",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_esn_antireplay1024,
+			&pkt_aes_128_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"ESN and Antireplay with window size 2048",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_esn_antireplay2048,
+			&pkt_aes_128_gcm),
+		TEST_CASE_NAMED_WITH_DATA(
+			"ESN and Antireplay with window size 4096",
+			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
+			test_ipsec_inline_proto_pkt_esn_antireplay4096,
+			&pkt_aes_128_gcm),
+
 		TEST_CASE_NAMED_WITH_DATA(
 			"IPv4 Reassembly with 2 fragments",
 			ut_setup_inline_ipsec, ut_teardown_inline_ipsec,
Signature · 1 line
2.25.1
#112 lore raw

PATCH v7 7/7 test/security: add inline IPsec IPv6 flow label cases

In reply to Akhil Goyal

From: Vamsi Attunuru <[email protected]>

Patch adds unit tests for IPv6 flow label set & copy operations.

---
 app/test/test_cryptodev_security_ipsec.c | 35 ++++++++++-
 app/test/test_cryptodev_security_ipsec.h | 10 +++
 app/test/test_security_inline_proto.c    | 79 ++++++++++++++++++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
app/test/test_cryptodev_security_ipsec.c +34 -1
index 14c6ba681f..408bd0bc82 100644
@@ -495,6 +495,10 @@ test_ipsec_td_prepare(const struct crypto_param *param1,
 		    flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1)
 			td->ipsec_xform.options.copy_dscp = 1;
 
+		if (flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_0 ||
+		    flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1)
+			td->ipsec_xform.options.copy_flabel = 1;
+
 		if (flags->dec_ttl_or_hop_limit)
 			td->ipsec_xform.options.dec_ttl = 1;
 	}
@@ -933,6 +937,7 @@ test_ipsec_iph6_hdr_validate(const struct rte_ipv6_hdr *iph6,
 			     const struct ipsec_test_flags *flags)
 {
 	uint32_t vtc_flow;
+	uint32_t flabel;
 	uint8_t dscp;
 
 	if (!is_valid_ipv6_pkt(iph6)) {
@@ -959,6 +964,23 @@ test_ipsec_iph6_hdr_validate(const struct rte_ipv6_hdr *iph6,
 		}
 	}
 
+	flabel = vtc_flow & RTE_IPV6_HDR_FL_MASK;
+
+	if (flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1 ||
+	    flags->flabel == TEST_IPSEC_SET_FLABEL_1_INNER_0) {
+		if (flabel != TEST_IPSEC_FLABEL_VAL) {
+			printf("FLABEL value is not matching [exp: %x, actual: %x]\n",
+			       TEST_IPSEC_FLABEL_VAL, flabel);
+			return -1;
+		}
+	} else {
+		if (flabel != 0) {
+			printf("FLABEL value is set [exp: 0, actual: %x]\n",
+			       flabel);
+			return -1;
+		}
+	}
+
 	return 0;
 }
 
@@ -1159,7 +1181,11 @@ test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags)
 	if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 ||
 	    flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1 ||
 	    flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_0 ||
-	    flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) {
+	    flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0 ||
+	    flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1 ||
+	    flags->flabel == TEST_IPSEC_SET_FLABEL_0_INNER_1 ||
+	    flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_0 ||
+	    flags->flabel == TEST_IPSEC_SET_FLABEL_1_INNER_0) {
 
 		if (is_ipv4(iph4)) {
 			uint8_t tos;
@@ -1187,6 +1213,13 @@ test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags)
 			else
 				vtc_flow &= ~RTE_IPV6_HDR_DSCP_MASK;
 
+			if (flags->flabel == TEST_IPSEC_COPY_FLABEL_INNER_1 ||
+			    flags->flabel == TEST_IPSEC_SET_FLABEL_0_INNER_1)
+				vtc_flow |= (RTE_IPV6_HDR_FL_MASK &
+					     (TEST_IPSEC_FLABEL_VAL << RTE_IPV6_HDR_FL_SHIFT));
+			else
+				vtc_flow &= ~RTE_IPV6_HDR_FL_MASK;
+
 			iph6->vtc_flow = rte_cpu_to_be_32(vtc_flow);
 		}
 	}
app/test/test_cryptodev_security_ipsec.h +10 -0
index 0d9b5b6e2e..744dd64a9e 100644
@@ -73,6 +73,15 @@ enum dscp_flags {
 	TEST_IPSEC_SET_DSCP_1_INNER_0,
 };
 
+#define TEST_IPSEC_FLABEL_VAL 0x1234
+
+enum flabel_flags {
+	TEST_IPSEC_COPY_FLABEL_INNER_0 = 1,
+	TEST_IPSEC_COPY_FLABEL_INNER_1,
+	TEST_IPSEC_SET_FLABEL_0_INNER_1,
+	TEST_IPSEC_SET_FLABEL_1_INNER_0,
+};
+
 struct ipsec_test_flags {
 	bool display_alg;
 	bool sa_expiry_pkts_soft;
@@ -92,6 +101,7 @@ struct ipsec_test_flags {
 	bool antireplay;
 	enum df_flags df;
 	enum dscp_flags dscp;
+	enum flabel_flags flabel;
 	bool dec_ttl_or_hop_limit;
 	bool ah;
 };
app/test/test_security_inline_proto.c +79 -0

97 lines not on this page · raw message

Signature · 1 line
2.25.1
#113 lore raw

RE: [PATCH v7 0/7] app/test: add inline IPsec and reassembly cases

In reply to Akhil Goyal
Quoted 58 lines

IP reassembly offload was added in last release.
The test app for unit testing IP reassembly of inline inbound IPsec flows is added in this patchset.
For testing IP reassembly, base inline IPsec is also added. The app is enhanced in v4 to handle more functional unit test cases for inline IPsec similar to Lookaside IPsec.
The functions from Lookaside more are reused to verify functional cases.

Changes in v7:
- fixed compilation

Changes in v6:
- Addressed comments from Anoob.

changes in v5:
- removed soft/hard expiry patches which are deferred for next release
- skipped tests if no port is added.
- added release notes.
Changes in v4:
- rebased over next-crypto
- updated app to take benefit from Lookaside protocol test functions.
- Added more functional cases
- Added soft and hard expiry event subtypes in ethdev for testing SA soft and hard pkt/byte expiry events.
- reassembly cases are squashed in a single patch

Changes in v3:
- incorporated latest ethdev changes for reassembly.
- skipped build on windows as it needs rte_ipsec lib which is not compiled on windows.
changes in v2:
- added IPsec burst mode case
- updated as per the latest ethdev changes.

Akhil Goyal (6):
app/test: add unit cases for inline IPsec offload test/security: add inline inbound IPsec cases test/security: add combined mode inline IPsec cases test/security: add inline IPsec reassembly cases test/security: add more inline IPsec functional cases test/security: add ESN and anti-replay cases for inline

Vamsi Attunuru (1):
test/security: add inline IPsec IPv6 flow label cases

 MAINTAINERS                                   |    2 +-
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev_security_ipsec.c      |   35 +-
 app/test/test_cryptodev_security_ipsec.h      |   10 +
 app/test/test_security_inline_proto.c         | 2382 +++++++++++++++++
 app/test/test_security_inline_proto_vectors.h |  704 +++++
 doc/guides/rel_notes/release_22_07.rst        |    5 +
 7 files changed, 3137 insertions(+), 2 deletions(-)  create mode 100644
app/test/test_security_inline_proto.c
 create mode 100644 app/test/test_security_inline_proto_vectors.h
Quoted 2 lines

--
2.25.1

Series Acked-by: Anoob Joseph <[email protected]>

author Applied
#114 lore raw

RE: [PATCH v7 0/7] app/test: add inline IPsec and reassembly cases

Quoted 22 lines
Quoted 22 lines

Akhil Goyal (6):
app/test: add unit cases for inline IPsec offload test/security: add inline inbound IPsec cases test/security: add combined mode inline IPsec cases test/security: add inline IPsec reassembly cases test/security: add more inline IPsec functional cases test/security: add ESN and anti-replay cases for inline

Vamsi Attunuru (1):
test/security: add inline IPsec IPv6 flow label cases

 MAINTAINERS                                   |    2 +-
 app/test/meson.build                          |    1 +
 app/test/test_cryptodev_security_ipsec.c      |   35 +-
 app/test/test_cryptodev_security_ipsec.h      |   10 +
 app/test/test_security_inline_proto.c         | 2382 +++++++++++++++++
 app/test/test_security_inline_proto_vectors.h |  704 +++++
 doc/guides/rel_notes/release_22_07.rst        |    5 +
 7 files changed, 3137 insertions(+), 2 deletions(-)  create mode 100644
app/test/test_security_inline_proto.c
 create mode 100644 app/test/test_security_inline_proto_vectors.h
Quoted 4 lines
Quoted 2 lines

--
2.25.1

Series Acked-by: Anoob Joseph <[email protected]>

Applied to dpdk-next-crypto

#115 lore raw

PATCH 6/8 app/test: add IP reassembly case with no frags

In reply to Akhil Goyal

test_inline_ipsec testsuite is extended to test IP reassembly of inbound fragmented packets. The fragmented packet is sent on an interface which encrypts the packet and then it is loopbacked on the same interface which decrypts the packet and then attempts IP reassembly of the decrypted packets.
In this patch, a case is added for packets without fragmentation to verify the complete path. Other cases are added in subsequent patches.

---
 app/test/test_inline_ipsec.c | 154 +++++++++++++++++++++++++++++++++++
 1 file changed, 154 insertions(+)
app/test/test_inline_ipsec.c +154 -0
index 54b56ba9e8..f704725c0f 100644
@@ -460,6 +460,145 @@ create_default_flow(uint16_t port_id)
 
 struct rte_mbuf **tx_pkts_burst;
 
+static int
+compare_pkt_data(struct rte_mbuf *m, uint8_t *ref, unsigned int tot_len)
+{
+	unsigned int len;
+	unsigned int nb_segs = m->nb_segs;
+	unsigned int matched = 0;
+
+	while (m && nb_segs != 0) {
+		len = tot_len;
+		if (len > m->data_len)
+			len = m->data_len;
+		if (len != 0) {
+			if (memcmp(rte_pktmbuf_mtod(m, char *),
+					ref + matched, len)) {
+				printf("\n====Reassembly case failed: Data Mismatch");
+				rte_hexdump(stdout, "Reassembled",
+					rte_pktmbuf_mtod(m, char *),
+					len);
+				rte_hexdump(stdout, "reference",
+					ref + matched,
+					len);
+				return TEST_FAILED;
+			}
+		}
+		tot_len -= len;
+		matched += len;
+		m = m->next;
+		nb_segs--;
+	}
+	return TEST_SUCCESS;
+}
+
+static int
+test_reassembly(struct reassembly_vector *vector,
+		enum rte_security_ipsec_tunnel_type tun_type)
+{
+	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+	unsigned i, portid, nb_rx = 0, nb_tx = 0;
+	struct rte_ipsec_session out_ips = {0};
+	struct rte_ipsec_session in_ips = {0};
+	struct rte_eth_dev_info dev_info = {0};
+	int ret = 0;
+
+	/* Initialize mbuf with test vectors. */
+	nb_tx = reass_test_vectors_init(vector);
+
+	portid = lcore_cfg.port;
+	rte_eth_dev_info_get(portid, &dev_info);
+	if (dev_info.reass_capa.max_frags < nb_tx)
+		return TEST_SKIPPED;
+
+	/**
+	 * Set some finite value in timeout incase PMD support much
+	 * more than requied in this app.
+	 */
+	if (dev_info.reass_capa.reass_timeout > APP_REASS_TIMEOUT) {
+		dev_info.reass_capa.reass_timeout = APP_REASS_TIMEOUT;
+		rte_eth_ip_reassembly_conf_set(portid, &dev_info.reass_capa);
+	}
+
+	init_traffic(mbufpool[lcore_cfg.socketid],
+			tx_pkts_burst, vector->frags, nb_tx);
+
+	/* Create Inline IPsec outbound session. */
+	ret = create_inline_ipsec_session(vector->sa_data, portid, &out_ips,
+			RTE_SECURITY_IPSEC_SA_DIR_EGRESS, tun_type);
+	if (ret)
+		return ret;
+	for (i = 0; i < nb_tx; i++) {
+		if (out_ips.security.ol_flags &
+				RTE_SECURITY_TX_OLOAD_NEED_MDATA)
+			rte_security_set_pkt_metadata(out_ips.security.ctx,
+				out_ips.security.ses, tx_pkts_burst[i], NULL);
+		tx_pkts_burst[i]->ol_flags |= RTE_MBUF_F_TX_SEC_OFFLOAD;
+		tx_pkts_burst[i]->l2_len = RTE_ETHER_HDR_LEN;
+	}
+	/* Create Inline IPsec inbound session. */
+	create_inline_ipsec_session(vector->sa_data, portid, &in_ips,
+			RTE_SECURITY_IPSEC_SA_DIR_INGRESS, tun_type);
+	create_default_flow(portid);
+
+	nb_tx = rte_eth_tx_burst(portid, 0, tx_pkts_burst, nb_tx);
+
+	rte_pause();
+
+	do {
+		nb_rx = rte_eth_rx_burst(portid, 0, pkts_burst, MAX_PKT_BURST);
+		for (i = 0; i < nb_rx; i++) {
+			if ((pkts_burst[i]->ol_flags &
+			    RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE) &&
+			    rte_eth_ip_reass_dynfield_is_registered()) {
+				rte_eth_ip_reass_dynfield_t *dynfield[MAX_PKT_BURST];
+				int j = 0;
+
+				dynfield[j] = rte_eth_ip_reass_dynfield(pkts_burst[i]);
+				while ((dynfield[j]->next_frag->ol_flags &
+				    RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE) &&
+				    dynfield[j]->nb_frags > 0) {
+
+					rte_pktmbuf_dump(stdout,
+						dynfield[j]->next_frag,
+						dynfield[j]->next_frag->data_len);
+					j++;
+					dynfield[j] = rte_eth_ip_reass_dynfield(
+						dynfield[j-1]->next_frag);
+				}
+				/**
+				 * IP reassembly offload is incomplete, and
+				 * fragments are listed in dynfield which
+				 * can be reassembled in SW.
+				 */
+				printf("\nHW IP Reassembly failed,"
+					"\nAttempt SW IP Reassembly,"
+					"\nmbuf is chained with fragments.\n");
+			}
+		}
+	} while (nb_rx == 0);
+
+	/* Clear session data. */
+	rte_security_session_destroy(out_ips.security.ctx,
+				     out_ips.security.ses);
+	rte_security_session_destroy(in_ips.security.ctx,
+				     in_ips.security.ses);
+
+	/* Compare results with known vectors. */
+	if (nb_rx == 1) {
+		if (vector->full_pkt->len == pkts_burst[0]->pkt_len)
+			return compare_pkt_data(pkts_burst[0],
+					vector->full_pkt->data,
+					vector->full_pkt->len);
+		else {
+			rte_pktmbuf_dump(stdout, pkts_burst[0],
+					pkts_burst[0]->pkt_len);
+		}
+	}
+
+	return TEST_FAILED;
+}
+
 static int
 test_ipsec(struct reassembly_vector *vector,
 	   enum rte_security_ipsec_sa_direction dir,
@@ -703,6 +842,18 @@ test_ipsec_ipv4_decap_nofrag(void) {
 			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
 }
 
+static int
+test_reassembly_ipv4_nofrag(void) {
+	struct reassembly_vector ipv4_nofrag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_plain,
+				.frags[0] = &pkt_ipv4_plain,
+	};
+	return test_reassembly(&ipv4_nofrag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+
 static struct unit_test_suite inline_ipsec_testsuite  = {
 	.suite_name = "Inline IPsec Ethernet Device Unit Test Suite",
 	.setup = testsuite_setup,
@@ -714,6 +865,9 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 		TEST_CASE_ST(ut_setup_inline_ipsec,
 				ut_teardown_inline_ipsec,
 				test_ipsec_ipv4_decap_nofrag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv4_nofrag),
 
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
Signature · 1 line
2.25.1
#116 lore raw

PATCH 7/8 app/test: add IP reassembly cases with multiple fragments

In reply to Akhil Goyal

More cases are added in test_inline_ipsec test suite to verify packets having multiple IP(v4/v6) fragments. These fragments are encrypted and then decrypted as per inline IPsec processing and then an attempt is made to reassemble the fragments. The reassembled packet content is matched with the known test vectors.

---
 app/test/test_inline_ipsec.c                  | 101 +++
 .../test_inline_ipsec_reassembly_vectors.h    | 592 ++++++++++++++++++
 2 files changed, 693 insertions(+)
app/test/test_inline_ipsec.c +101 -0
index f704725c0f..3f3731760d 100644
@@ -853,6 +853,89 @@ test_reassembly_ipv4_nofrag(void) {
 			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
 }
 
+static int
+test_reassembly_ipv4_2frag(void) {
+	struct reassembly_vector ipv4_2frag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p1,
+				.frags[0] = &pkt_ipv4_udp_p1_f1,
+				.frags[1] = &pkt_ipv4_udp_p1_f2,
+
+	};
+	return test_reassembly(&ipv4_2frag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_ipv6_2frag(void) {
+	struct reassembly_vector ipv6_2frag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv6_udp_p1,
+				.frags[0] = &pkt_ipv6_udp_p1_f1,
+				.frags[1] = &pkt_ipv6_udp_p1_f2,
+	};
+	return test_reassembly(&ipv6_2frag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV6);
+}
+
+static int
+test_reassembly_ipv4_4frag(void) {
+	struct reassembly_vector ipv4_4frag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p2,
+				.frags[0] = &pkt_ipv4_udp_p2_f1,
+				.frags[1] = &pkt_ipv4_udp_p2_f2,
+				.frags[2] = &pkt_ipv4_udp_p2_f3,
+				.frags[3] = &pkt_ipv4_udp_p2_f4,
+	};
+	return test_reassembly(&ipv4_4frag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_ipv6_4frag(void) {
+	struct reassembly_vector ipv6_4frag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv6_udp_p2,
+				.frags[0] = &pkt_ipv6_udp_p2_f1,
+				.frags[1] = &pkt_ipv6_udp_p2_f2,
+				.frags[2] = &pkt_ipv6_udp_p2_f3,
+				.frags[3] = &pkt_ipv6_udp_p2_f4,
+	};
+	return test_reassembly(&ipv6_4frag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV6);
+}
+
+static int
+test_reassembly_ipv4_5frag(void) {
+	struct reassembly_vector ipv4_5frag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p3,
+				.frags[0] = &pkt_ipv4_udp_p3_f1,
+				.frags[1] = &pkt_ipv4_udp_p3_f2,
+				.frags[2] = &pkt_ipv4_udp_p3_f3,
+				.frags[3] = &pkt_ipv4_udp_p3_f4,
+				.frags[4] = &pkt_ipv4_udp_p3_f5,
+	};
+	return test_reassembly(&ipv4_5frag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_ipv6_5frag(void) {
+	struct reassembly_vector ipv6_5frag_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv6_udp_p3,
+				.frags[0] = &pkt_ipv6_udp_p3_f1,
+				.frags[1] = &pkt_ipv6_udp_p3_f2,
+				.frags[2] = &pkt_ipv6_udp_p3_f3,
+				.frags[3] = &pkt_ipv6_udp_p3_f4,
+				.frags[4] = &pkt_ipv6_udp_p3_f5,
+	};
+	return test_reassembly(&ipv6_5frag_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV6);
+}
+
 
 static struct unit_test_suite inline_ipsec_testsuite  = {
 	.suite_name = "Inline IPsec Ethernet Device Unit Test Suite",
@@ -868,6 +951,24 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 		TEST_CASE_ST(ut_setup_inline_ipsec,
 				ut_teardown_inline_ipsec,
 				test_reassembly_ipv4_nofrag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv4_2frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv6_2frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv4_4frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv6_4frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv4_5frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_ipv6_5frag),
 
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
app/test/test_inline_ipsec_reassembly_vectors.h +592 -0

604 lines not on this page · raw message

Signature · 1 line
2.25.1
#117 lore raw

PATCH 8/8 app/test: add IP reassembly negative cases

In reply to Akhil Goyal

test_inline_ipsec testsuite is added with cases where the IP reassembly is incomplete and software will need to reassemble them later. The failure cases added are:
- all fragments are not received.
- same fragment is received more than once.
- out of order fragments.

---
 app/test/test_inline_ipsec.c | 53 ++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
app/test/test_inline_ipsec.c +53 -0
index 3f3731760d..0d74e23359 100644
@@ -936,6 +936,50 @@ test_reassembly_ipv6_5frag(void) {
 			RTE_SECURITY_IPSEC_TUNNEL_IPV6);
 }
 
+static int
+test_reassembly_incomplete(void) {
+	/* Negative test case, not sending all fragments. */
+	struct reassembly_vector ipv4_incomplete_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p2,
+				.frags[0] = &pkt_ipv4_udp_p2_f1,
+				.frags[1] = &pkt_ipv4_udp_p2_f2,
+				.frags[2] = NULL,
+				.frags[3] = NULL,
+	};
+	return test_reassembly(&ipv4_incomplete_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_overlap(void) {
+	/* Negative test case, sending 1 fragment twice. */
+	struct reassembly_vector ipv4_overlap_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p2,
+				.frags[0] = &pkt_ipv4_udp_p2_f1,
+				.frags[1] = &pkt_ipv4_udp_p2_f2,
+				.frags[2] = &pkt_ipv4_udp_p2_f2, /* overlap */
+				.frags[3] = &pkt_ipv4_udp_p2_f3,
+	};
+	return test_reassembly(&ipv4_overlap_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
+
+static int
+test_reassembly_out_of_order(void) {
+	/* Negative test case, sending 1 fragment twice. */
+	struct reassembly_vector ipv4_ooo_case = {
+				.sa_data = &conf_aes_128_gcm,
+				.full_pkt = &pkt_ipv4_udp_p2,
+				.frags[0] = &pkt_ipv4_udp_p2_f4,
+				.frags[1] = &pkt_ipv4_udp_p2_f3,
+				.frags[2] = &pkt_ipv4_udp_p2_f1,
+				.frags[3] = &pkt_ipv4_udp_p2_f2,
+	};
+	return test_reassembly(&ipv4_ooo_case,
+			RTE_SECURITY_IPSEC_TUNNEL_IPV4);
+}
 
 static struct unit_test_suite inline_ipsec_testsuite  = {
 	.suite_name = "Inline IPsec Ethernet Device Unit Test Suite",
@@ -969,6 +1013,15 @@ static struct unit_test_suite inline_ipsec_testsuite  = {
 		TEST_CASE_ST(ut_setup_inline_ipsec,
 				ut_teardown_inline_ipsec,
 				test_reassembly_ipv6_5frag),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_incomplete),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_overlap),
+		TEST_CASE_ST(ut_setup_inline_ipsec,
+				ut_teardown_inline_ipsec,
+				test_reassembly_out_of_order),
 
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
Signature · 1 line
2.25.1
#118 lore raw

Re: [PATCH 0/8] ethdev: introduce IP reassembly offload

In reply to Akhil Goyal
Quoted 24 lines · Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the RX offload and an application to test it. Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation is added as a separate patchset.

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/

Akhil Goyal (8):
ethdev: introduce IP reassembly offload
ethdev: add dev op for IP reassembly configuration
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly app/test: add unit cases for inline IPsec offload app/test: add IP reassembly case with no frags app/test: add IP reassembly cases with multiple fragments app/test: add IP reassembly negative cases

Quoted 3 lines
 app/test/meson.build                          |    1 +
 app/test/test_inline_ipsec.c                  | 1036 +++++++++++++++++
 .../test_inline_ipsec_reassembly_vectors.h    |  790 +++++++++++++

I see no update in MAINTAINERS for those new files. So I think they end up in the "main" repo scope.

You can either update MAINTAINERS (changing the app/test/test_ipsec* pattern as app/test/test_*ipsec*) or rename files as app/test/test_ipsec_inline.c, for example.

Signature · 1 line
David Marchand
#119 lore raw

RE: [EXT] Re: [PATCH 0/8] ethdev: introduce IP reassembly offload

Quoted 14 lines
Quoted 10 lines

Akhil Goyal (8):
ethdev: introduce IP reassembly offload
ethdev: add dev op for IP reassembly configuration
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly app/test: add unit cases for inline IPsec offload app/test: add IP reassembly case with no frags app/test: add IP reassembly cases with multiple fragments app/test: add IP reassembly negative cases

Quoted 3 lines
 app/test/meson.build                          |    1 +
 app/test/test_inline_ipsec.c                  | 1036 +++++++++++++++++
 .../test_inline_ipsec_reassembly_vectors.h    |  790 +++++++++++++
Quoted 7 lines

I see no update in MAINTAINERS for those new files. So I think they end up in the "main" repo scope.

You can either update MAINTAINERS (changing the app/test/test_ipsec* pattern as app/test/test_*ipsec*) or rename files as app/test/test_ipsec_inline.c, for example.

Thanks for the update David,
There are a few other issues in the patchset, I will post a new version in next few days With MAINTAINERS updated.

#120 lore raw

v2 cover ethdev: introduce IP reassembly offload

In reply to Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Akhil Goyal (4):
ethdev: introduce IP reassembly offload
ethdev: add dev op to set/get IP reassembly configuration
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

 devtools/libabigail.abignore |  19 ++++++
 doc/guides/nics/features.rst |  11 ++++
 lib/ethdev/ethdev_driver.h   |  45 ++++++++++++++
 lib/ethdev/rte_ethdev.c      | 110 +++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h      | 104 ++++++++++++++++++++++++++++++++-
 lib/ethdev/version.map       |   5 ++
 lib/security/rte_security.h  |  12 +++-
 7 files changed, 304 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#121 lore raw

PATCH v2 1/4 ethdev: introduce IP reassembly offload

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is introduced in ethdev for devices which can attempt reassembly of packets in hardware. rte_eth_dev_info is updated with the reassembly capabilities which a device can support.

The resulting reassembled packet would be a typical segmented mbuf in case of success.

And if reassembly of fragments is failed or is incomplete (if fragments do not come before the reass_timeout), the mbuf ol_flags can be updated. This is updated in a subsequent patch.

---
 devtools/libabigail.abignore |  5 +++++
 doc/guides/nics/features.rst | 11 +++++++++++
 lib/ethdev/rte_ethdev.c      |  1 +
 lib/ethdev/rte_ethdev.h      | 32 +++++++++++++++++++++++++++++++-
 4 files changed, 48 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +5 -0
index 4b676f317d..90f449c43a 100644
@@ -11,3 +11,8 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_64s of rte_eth_dev_info
+[suppress_type]
+	name = rte_eth_dev_info
+	has_data_member_inserted_between = {offset_of(reserved_64s), end}
doc/guides/nics/features.rst +11 -0
index 27be2d2576..b45bce4a78 100644
@@ -602,6 +602,17 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[uses]     rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY``.
+* **[provides] rte_eth_dev_info**: ``reass_capa``.
+
+
 .. _nic_features_shared_rx_queue:
 
 Shared Rx queue
lib/ethdev/rte_ethdev.c +1 -0
index a1d475a292..d9a03f12f9 100644
@@ -126,6 +126,7 @@ static const struct {
 	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
 	RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
 	RTE_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(IP_REASSEMBLY),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
lib/ethdev/rte_ethdev.h +31 -1
index fa299c8ad7..11427b2e4d 100644
@@ -1586,6 +1586,7 @@ struct rte_eth_conf {
 #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
 #define DEV_RX_OFFLOAD_RSS_HASH             RTE_ETH_RX_OFFLOAD_RSS_HASH
 #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
+#define RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY    RTE_BIT64(21)
 
 #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
@@ -1781,6 +1782,33 @@ enum rte_eth_representor_type {
 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
 };
 
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ *
+ * A structure used to set IP reassembly configuration.
+ *
+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure:
+ *
+ */
+struct rte_eth_ip_reass_params {
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
 /**
  * A structure used to retrieve the contextual information of
  * an Ethernet device, such as the controlling driver of the
@@ -1841,8 +1869,10 @@ struct rte_eth_dev_info {
 	 * embedded managed interconnect/switch.
 	 */
 	struct rte_eth_switch_info switch_info;
+	/** IP reassembly offload capabilities that a device can support. */
+	struct rte_eth_ip_reass_params reass_capa;
 
-	uint64_t reserved_64s[2]; /**< Reserved for future fields */
+	uint64_t reserved_64s[1]; /**< Reserved for future fields */
 	void *reserved_ptrs[2];   /**< Reserved for future fields */
 };
 
Signature · 1 line
2.25.1
#122 lore raw

Re: [PATCH v2 1/4] ethdev: introduce IP reassembly offload

Quoted 13 lines · On Thu, 20 Jan 2022 21:56:24 +0530 Akhil Goyal <[email protected]> wrote:
lib/ethdev/rte_ethdev.h +13 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ *
+ * A structure used to set IP reassembly configuration.
+ *
+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure:
+ *
+ */
+struct rte_eth_ip_reass_params {
+	/** Maximum time in ms which PMD can wait for other fragments. */

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1811

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+	uint32_t reass_timeout;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+

Actually, this is not experimental. You are embedding this in dev_info and dev_info is not experimental; therefore the reassembly parameters can never change without breaking ABI of dev_info.

#123 lore raw

RE: [EXT] Re: [PATCH v2 1/4] ethdev: introduce IP reassembly offload

Quoted 22 lines
Quoted 19 lines · On Thu, 20 Jan 2022 21:56:24 +0530 Akhil Goyal <[email protected]> wrote:
lib/ethdev/rte_ethdev.h +19 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ *
+ * A structure used to set IP reassembly configuration.
+ *
+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure:
+ *
+ */
+struct rte_eth_ip_reass_params {
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
Quoted 8 lines

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1811

Quoted 4 lines
lib/ethdev/rte_ethdev.h +4 -0
+	 */
+	uint16_t flags;
+};
+

Actually, this is not experimental. You are embedding this in dev_info and dev_info is not experimental; therefore the reassembly parameters can never change without breaking ABI of dev_info.

Agreed, will remove the experimental tag from this struct.

#124 lore raw

PATCH v2 2/4 ethdev: add dev op to set/get IP reassembly configuration

In reply to Akhil Goyal

A new ethernet device op is added to give application control over the IP reassembly configuration. This operation is an optional call from the application, default values are set by PMD and exposed via rte_eth_dev_info.
Application should always first retrieve the capabilities from rte_eth_dev_info and then set the fields accordingly. User can get the currently set values using the get API.

---
 lib/ethdev/ethdev_driver.h | 37 +++++++++++++++++
 lib/ethdev/rte_ethdev.c    | 81 ++++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 51 ++++++++++++++++++++++++
 lib/ethdev/version.map     |  4 ++
 4 files changed, 173 insertions(+)
lib/ethdev/ethdev_driver.h +37 -0
index d95605a355..a310001648 100644
@@ -990,6 +990,38 @@ typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
 				       uint64_t *features);
 
+/**
+ * @internal
+ * Get IP reassembly offload configuration parameters set in PMD.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[out] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
+				       struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @internal
+ * Set configuration parameters for enabling IP reassembly offload in hardware.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[in] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
+				       struct rte_eth_ip_reass_params *conf);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1186,6 +1218,11 @@ struct eth_dev_ops {
 	 * kinds of metadata to the PMD
 	 */
 	eth_rx_metadata_negotiate_t rx_metadata_negotiate;
+
+	/** Get IP reassembly configuration */
+	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
+	/** Set IP reassembly configuration */
+	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
 };
 
 /**
lib/ethdev/rte_ethdev.c +81 -0

87 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +51 -0

57 lines not on this page · raw message

lib/ethdev/version.map +4 -0
index c2fb0669a4..ad829dd47e 100644
@@ -256,6 +256,10 @@ EXPERIMENTAL {
 	rte_flow_flex_item_create;
 	rte_flow_flex_item_release;
 	rte_flow_pick_transfer_proxy;
+
+	#added in 22.03
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
#125 lore raw

Re: [PATCH v2 2/4] ethdev: add dev op to set/get IP reassembly configuration

Quoted 1 line · Akhil Goyal

A new ethernet device op is added to give application control over

ethernet -> Ethernet

Quoted 3 lines

the IP reassembly configuration. This operation is an optional call from the application, default values are set by PMD and exposed via rte_eth_dev_info.

Are defaults or maximum support values exposed via rte_eth_dev_info? I guess it should be maximum. Defaults can be obtained using get without set.

Quoted 5 lines

Application should always first retrieve the capabilities from rte_eth_dev_info and then set the fields accordingly. User can get the currently set values using the get API.

[snip]

Quoted 5 lines
lib/ethdev/ethdev_driver.h +5 -0
+/**
+ * @internal
+ * Set configuration parameters for enabling IP reassembly offload in hardware.
+ *
+ * @param dev

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, · line 1023

Quoted 10 lines
lib/ethdev/ethdev_driver.h +10 -0
+ *   Port (ethdev) handle
+ *
+ * @param[in] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
+				       struct rte_eth_ip_reass_params *conf);

const

[snip]

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6523

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+int
+rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+			       struct rte_eth_ip_reass_params *conf)

Please, preserve order everywhere. If get comes first, it must be first everywhere.

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6533

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (conf == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Cannot get reassembly info to NULL");
+		return -EINVAL;
+	}

Why is order of check different in set and get?

Quoted 31 lines
lib/ethdev/rte_ethdev.c +23 -0
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
+	if ((dev->data->dev_conf.rxmode.offloads &
+			RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"The port (ID=%"PRIu16") is not configured for IP reassembly\n",
+			port_id);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_conf_get,
+				-ENOTSUP);
+	memset(conf, 0, sizeof(struct rte_eth_ip_reass_params));
+	return eth_err(port_id,
+		       (*dev->dev_ops->ip_reassembly_conf_get)(dev, conf));
+}
+
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +0 -0
index 11427b2e4d..53af158bcb 100644

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5226

Quoted 9 lines
lib/ethdev/rte_ethdev.h +6 -0
@@ -5218,6 +5218,57 @@ int rte_eth_representor_info_get(uint16_t port_id,
  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get IP reassembly configuration parameters currently set in PMD,
+ * if device rx offload flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is

rx -> Rx

Quoted 12 lines
lib/ethdev/rte_ethdev.h +12 -0
+ * enabled and the PMD supports IP reassembly offload.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-EINVAL) if offload is not enabled in rte_eth_conf.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5248

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+				   struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Set IP reassembly configuration parameters if device rx offload

rx -> Rx

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id,

Quoted 5 lines
lib/ethdev/rte_ethdev.h +5 -0
+ * flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is enabled and the PMD
+ * supports IP reassembly offload. User should first check the
+ * reass_capa in rte_eth_dev_info before setting the configuration.
+ * The values of configuration parameters must not exceed the device
+ * capabilities.

It sounds like set API should retrieve dev_info and check set values vs maximums.

Quoted 2 lines

The use of this API is optional and if called, it
+ * should be called before rte_eth_dev_start().

It should be highlighted that the device must be already configured.

Quoted 35 lines

+ *
+ * @param port_id
+ * The port identifier of the device.
+ * @param conf
+ * A pointer to rte_eth_ip_reass_params structure.
+ * @return

+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-EINVAL) if offload is not enabled in rte_eth_conf.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.

+ */

lib/ethdev/rte_ethdev.h +5 -0
+__rte_experimental
+int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
+				   struct rte_eth_ip_reass_params *conf);
+
+
  #include <rte_ethdev_core.h>
 
  /**
lib/ethdev/version.map +4 -0
index c2fb0669a4..ad829dd47e 100644
@@ -256,6 +256,10 @@ EXPERIMENTAL {
  	rte_flow_flex_item_create;
  	rte_flow_flex_item_release;
  	rte_flow_pick_transfer_proxy;
+
+	#added in 22.03
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
  };
 
  INTERNAL {
#126 lore raw

RE: [EXT] Re: [PATCH v2 2/4] ethdev: add dev op to set/get IP reassembly configuration

Hi Andrew,

Quoted 4 lines · Akhil Goyal
Quoted 1 line

A new ethernet device op is added to give application control over

ethernet -> Ethernet

Ok

Quoted 9 lines
Quoted 4 lines

the IP reassembly configuration. This operation is an optional call from the application, default values are set by PMD and exposed via rte_eth_dev_info.

Are defaults or maximum support values exposed via rte_eth_dev_info? I guess it should be maximum. Defaults can be obtained using get without set.

Rte_eth_dev_info gives the maximum values/capabilities that a device can support And also the default values set if user does not call set() API.

And get() op will give the currently set values.

Quoted 28 lines
Quoted 5 lines

Application should always first retrieve the capabilities from rte_eth_dev_info and then set the fields accordingly. User can get the currently set values using the get API.

[snip]

Quoted 3 lines

+/**
+ * @internal
+ * Set configuration parameters for enabling IP reassembly offload in

hardware.

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, · line 1023

Quoted 12 lines

+ *
+ * @param dev
+ * Port (ethdev) handle
+ *
+ * @param[in] conf
+ * Configuration parameters for IP reassembly.
+ *
+ * @return
+ * Negative errno value on error, zero otherwise
+ */

lib/ethdev/ethdev_driver.h +2 -0
+typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
+				       struct rte_eth_ip_reass_params *conf);

const

Quoted 8 lines

[snip]

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6523

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+int
+rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+			       struct rte_eth_ip_reass_params *conf)

Please, preserve order everywhere. If get comes first, it must be first everywhere.

ok

Quoted 13 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6533

Quoted 11 lines
lib/ethdev/rte_ethdev.c +10 -0
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (conf == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Cannot get reassembly info to NULL");
+		return -EINVAL;
+	}

Why is order of check different in set and get?

Ok will correct it.

Quoted 62 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 13 lines
lib/ethdev/rte_ethdev.c +12 -0
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
+	if ((dev->data->dev_conf.rxmode.offloads &
+			RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"The port (ID=%"PRIu16") is not configured for IP

reassembly\n",

Quoted 20 lines
lib/ethdev/rte_ethdev.c +5 -0
+			port_id);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-

ip_reassembly_conf_get,

lib/ethdev/rte_ethdev.c +6 -0
+				-ENOTSUP);
+	memset(conf, 0, sizeof(struct rte_eth_ip_reass_params));
+	return eth_err(port_id,
+		       (*dev->dev_ops->ip_reassembly_conf_get)(dev, conf));
+}
+
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +0 -0
index 11427b2e4d..53af158bcb 100644

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5226

Quoted 9 lines
lib/ethdev/rte_ethdev.h +6 -0
@@ -5218,6 +5218,57 @@ int rte_eth_representor_info_get(uint16_t port_id,
  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get IP reassembly configuration parameters currently set in PMD,
+ * if device rx offload flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is

rx -> Rx

Quoted 16 lines
lib/ethdev/rte_ethdev.h +16 -0
+ * enabled and the PMD supports IP reassembly offload.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-EINVAL) if offload is not enabled in rte_eth_conf.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+				   struct rte_eth_ip_reass_params *conf);
Quoted 9 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5248

Quoted 6 lines
lib/ethdev/rte_ethdev.h +6 -0
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Set IP reassembly configuration parameters if device rx offload

rx -> Rx

Ok

Quoted 8 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id,

Quoted 5 lines
lib/ethdev/rte_ethdev.h +5 -0
+ * flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is enabled and the PMD
+ * supports IP reassembly offload. User should first check the
+ * reass_capa in rte_eth_dev_info before setting the configuration.
+ * The values of configuration parameters must not exceed the device
+ * capabilities.

It sounds like set API should retrieve dev_info and check set values vs maximums.

Yes.

Quoted 5 lines
Quoted 3 lines

The use of this API is optional and if called, it
+ * should be called before rte_eth_dev_start().

It should be highlighted that the device must be already configured.

Where should this be highlighted?

#127 lore raw

PATCH v2 3/4 ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

---
 lib/ethdev/ethdev_driver.h |  8 ++++++++
 lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 21 +++++++++++++++++++++
 lib/ethdev/version.map     |  1 +
 4 files changed, 58 insertions(+)
lib/ethdev/ethdev_driver.h +8 -0
index a310001648..7499a4fbf5 100644
@@ -1689,6 +1689,14 @@ int
 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
 				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
 /*
  * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +28 -0
index 4bd31034a6..f6a155dceb 100644
@@ -6554,6 +6554,34 @@ rte_eth_ip_reassembly_conf_get(uint16_t port_id,
 		       (*dev->dev_ops->ip_reassembly_conf_get)(dev, conf));
 }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_ETH_IP_REASS_DYNFIELD_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name = RTE_ETH_IP_REASS_INCOMPLETE_DYNFLAG_NAME,
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +21 -0
index 53af158bcb..a6b43bcf2c 100644
@@ -5268,6 +5268,27 @@ __rte_experimental
 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 				   struct rte_eth_ip_reass_params *conf);
 
+#define RTE_ETH_IP_REASS_DYNFIELD_NAME "rte_eth_ip_reass_dynfield"
+#define RTE_ETH_IP_REASS_INCOMPLETE_DYNFLAG_NAME "rte_eth_ip_reass_incomplete_dynflag"
+
+/**
+ * In case of IP reassembly offload failure, ol_flags in mbuf will be set
+ * with RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE and packets will be returned
+ * without alteration. The application can retrieve the attached fragments
+ * using mbuf dynamic field.
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reass_dynfield_t;
+
 
 #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index ad829dd47e..8b7578471a 100644
@@ -283,6 +283,7 @@ INTERNAL {
 	rte_eth_hairpin_queue_peer_bind;
 	rte_eth_hairpin_queue_peer_unbind;
 	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reass_dynfield_register;
 	rte_eth_representor_id_get;
 	rte_eth_switch_domain_alloc;
 	rte_eth_switch_domain_free;
Signature · 1 line
2.25.1
#128 lore raw

PATCH v2 4/4 security: add IPsec option for IP reassembly

In reply to Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

---
 devtools/libabigail.abignore | 14 ++++++++++++++
 lib/security/rte_security.h  | 12 +++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +14 -0
index 90f449c43a..c6e304282f 100644
@@ -16,3 +16,17 @@
 [suppress_type]
 	name = rte_eth_dev_info
 	has_data_member_inserted_between = {offset_of(reserved_64s), end}
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
lib/security/rte_security.h +11 -1
index 1228b6c8b1..168b837a82 100644
@@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options {
 	 */
 	uint32_t l4_csum_enable : 1;
 
+	/** Enable reassembly on incoming packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if rx_offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in
+	 *      inline Ethernet device.
+	 * * 0: Disable reassembly of packets (default).
+	 */
+	uint32_t reass_en : 1;
+
 	/** Reserved bit fields for future extension
 	 *
 	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +281,7 @@ struct rte_security_ipsec_sa_options {
 	 *
 	 * Note: Reduce number of bits in reserved_opts for every new option.
 	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
 };
 
 /** IPSec security association direction */
Signature · 1 line
2.25.1
#129 lore raw

v3 cover ethdev: introduce IP reassembly offload

In reply to Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/

changes in v3:
- incorporated comments from Andrew and Stephen Hemminger

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Akhil Goyal (4):
ethdev: introduce IP reassembly offload
ethdev: add dev op to set/get IP reassembly configuration
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

 devtools/libabigail.abignore |  19 ++++++
 doc/guides/nics/features.rst |  12 ++++
 lib/ethdev/ethdev_driver.h   |  45 +++++++++++++++
 lib/ethdev/rte_ethdev.c      | 109 +++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h      | 100 +++++++++++++++++++++++++++++++-
 lib/ethdev/version.map       |   5 ++
 lib/security/rte_security.h  |  12 +++-
 7 files changed, 300 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#130 lore raw

PATCH v3 1/4 ethdev: introduce IP reassembly offload

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is introduced in ethdev for devices which can attempt reassembly of packets in hardware. rte_eth_dev_info is updated with the reassembly capabilities which a device can support.

The resulting reassembled packet would be a typical segmented mbuf in case of success.

And if reassembly of fragments is failed or is incomplete (if fragments do not come before the reass_timeout), the mbuf ol_flags can be updated. This is updated in a subsequent patch.

---
 devtools/libabigail.abignore |  5 +++++
 doc/guides/nics/features.rst | 11 +++++++++++
 lib/ethdev/rte_ethdev.c      |  1 +
 lib/ethdev/rte_ethdev.h      | 28 +++++++++++++++++++++++++++-
 4 files changed, 44 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +5 -0
index 4b676f317d..90f449c43a 100644
@@ -11,3 +11,8 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_64s of rte_eth_dev_info
+[suppress_type]
+	name = rte_eth_dev_info
+	has_data_member_inserted_between = {offset_of(reserved_64s), end}
doc/guides/nics/features.rst +11 -0
index 27be2d2576..b45bce4a78 100644
@@ -602,6 +602,17 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[uses]     rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY``.
+* **[provides] rte_eth_dev_info**: ``reass_capa``.
+
+
 .. _nic_features_shared_rx_queue:
 
 Shared Rx queue
lib/ethdev/rte_ethdev.c +1 -0
index a1d475a292..d9a03f12f9 100644
@@ -126,6 +126,7 @@ static const struct {
 	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
 	RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
 	RTE_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(IP_REASSEMBLY),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
lib/ethdev/rte_ethdev.h +27 -1
index fa299c8ad7..cfaf7a5afc 100644
@@ -1586,6 +1586,7 @@ struct rte_eth_conf {
 #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
 #define DEV_RX_OFFLOAD_RSS_HASH             RTE_ETH_RX_OFFLOAD_RSS_HASH
 #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
+#define RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY    RTE_BIT64(21)
 
 #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
@@ -1781,6 +1782,29 @@ enum rte_eth_representor_type {
 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
 };
 
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * A structure used to get/set IP reassembly configuration.
+ *
+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure.
+ */
+struct rte_eth_ip_reass_params {
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout_ms;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
 /**
  * A structure used to retrieve the contextual information of
  * an Ethernet device, such as the controlling driver of the
@@ -1841,8 +1865,10 @@ struct rte_eth_dev_info {
 	 * embedded managed interconnect/switch.
 	 */
 	struct rte_eth_switch_info switch_info;
+	/** IP reassembly offload capabilities that a device can support. */
+	struct rte_eth_ip_reass_params reass_capa;
 
-	uint64_t reserved_64s[2]; /**< Reserved for future fields */
+	uint64_t reserved_64s[1]; /**< Reserved for future fields */
 	void *reserved_ptrs[2];   /**< Reserved for future fields */
 };
 
Signature · 1 line
2.25.1
#131 lore raw

Re: [PATCH v3 1/4] ethdev: introduce IP reassembly offload

Quoted 91 lines · Akhil Goyal

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is introduced in ethdev for devices which can attempt reassembly of packets in hardware. rte_eth_dev_info is updated with the reassembly capabilities which a device can support.

The resulting reassembled packet would be a typical segmented mbuf in case of success.

And if reassembly of fragments is failed or is incomplete (if fragments do not come before the reass_timeout), the mbuf ol_flags can be updated. This is updated in a subsequent patch.

---
  devtools/libabigail.abignore |  5 +++++
  doc/guides/nics/features.rst | 11 +++++++++++
  lib/ethdev/rte_ethdev.c      |  1 +
  lib/ethdev/rte_ethdev.h      | 28 +++++++++++++++++++++++++++-
  4 files changed, 44 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +5 -0
index 4b676f317d..90f449c43a 100644
@@ -11,3 +11,8 @@
  ; Ignore generated PMD information strings
  [suppress_variable]
          name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_64s of rte_eth_dev_info
+[suppress_type]
+	name = rte_eth_dev_info
+	has_data_member_inserted_between = {offset_of(reserved_64s), end}
doc/guides/nics/features.rst +11 -0
index 27be2d2576..b45bce4a78 100644
@@ -602,6 +602,17 @@ Supports inner packet L4 checksum.
    ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[uses]     rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY``.
+* **[provides] rte_eth_dev_info**: ``reass_capa``.
+
+
  .. _nic_features_shared_rx_queue:
 
  Shared Rx queue
lib/ethdev/rte_ethdev.c +1 -0
index a1d475a292..d9a03f12f9 100644
@@ -126,6 +126,7 @@ static const struct {
  	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
  	RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
  	RTE_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(IP_REASSEMBLY),
  };
 
  #undef RTE_RX_OFFLOAD_BIT2STR
lib/ethdev/rte_ethdev.h +3 -0
index fa299c8ad7..cfaf7a5afc 100644
@@ -1586,6 +1586,7 @@ struct rte_eth_conf {
  #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
  #define DEV_RX_OFFLOAD_RSS_HASH             RTE_ETH_RX_OFFLOAD_RSS_HASH
  #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
+#define RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY    RTE_BIT64(21)
 
  #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
  				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
@@ -1781,6 +1782,29 @@ enum rte_eth_representor_type {
  	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
  };
 
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1796

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * A structure used to get/set IP reassembly configuration.
+ *
+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure.
+ */
+struct rte_eth_ip_reass_params {

As a generic comment, what do you think to use full 'reassembly' instead of 'reass' short version, to clarify/simplify the meaning?

Quoted 15 lines
lib/ethdev/rte_ethdev.h +11 -0
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout_ms;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
  /**
   * A structure used to retrieve the contextual information of
   * an Ethernet device, such as the controlling driver of the

lib/ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1870

Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -0
@@ -1841,8 +1865,10 @@ struct rte_eth_dev_info {
  	 * embedded managed interconnect/switch.
  	 */
  	struct rte_eth_switch_info switch_info;
+	/** IP reassembly offload capabilities that a device can support. */
+	struct rte_eth_ip_reass_params reass_capa;
 

"struct rte_eth_dev_info" & 'rte_eth_dev_info_get()' are very common, all applications that use net devices and even some internal APIs rely on this struct and API.
It makes me uneasy to extend this struct with rarely used features, worrying on loading to much (capability/status/config) on single API/struct can cause an unmaintainable code by time.

Also most of the time (if not always) offload flag is just an on/off flag to the PMD, application set/unset offload flag and PMD knows what to do. But for this case some capability variables, and a configuration API is required/involved.

For considering above two cases, what do you think implement this as control plane APIs instead of offload flag?
There are already 'conf_set()' and 'conf_get()' APIs introduced in coming patches, introducing an additional 'capability_get()' API removes the need of change in "struct rte_eth_dev_info" and 'RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY' can be removed.
Thomas, Andrew, what do you think?

Quoted 5 lines
lib/ethdev/rte_ethdev.h +1 -1
-	uint64_t reserved_64s[2]; /**< Reserved for future fields */
+	uint64_t reserved_64s[1]; /**< Reserved for future fields */
  	void *reserved_ptrs[2];   /**< Reserved for future fields */
  };
 
#132 lore raw

RE: [EXT] Re: [PATCH v3 1/4] ethdev: introduce IP reassembly offload

Quoted 7 lines
Quoted 7 lines
lib/ethdev/rte_ethdev.h +7 -0
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * A structure used to get/set IP reassembly configuration.
+ *
Quoted 8 lines
Quoted 5 lines

+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure.
+ */
+struct rte_eth_ip_reass_params {

As a generic comment, what do you think to use full 'reassembly' instead of 'reass' short version, to clarify/simplify the meaning?

Full reassembly was used in most places. But here the struct name would be too big. IMO, reass is good enough here. Though, no strong opinion. Will change if you insist.

Quoted 35 lines
Quoted 16 lines
lib/ethdev/rte_ethdev.h +11 -0
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout_ms;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
  /**
   * A structure used to retrieve the contextual information of
   * an Ethernet device, such as the controlling driver of the

lib/ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1870

Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -0
@@ -1841,8 +1865,10 @@ struct rte_eth_dev_info {
  	 * embedded managed interconnect/switch.
  	 */
  	struct rte_eth_switch_info switch_info;
+	/** IP reassembly offload capabilities that a device can support. */
+	struct rte_eth_ip_reass_params reass_capa;
 

"struct rte_eth_dev_info" & 'rte_eth_dev_info_get()' are very common, all applications that use net devices and even some internal APIs rely on this struct and API.
It makes me uneasy to extend this struct with rarely used features, worrying on loading to much (capability/status/config) on single API/struct can cause an unmaintainable code by time.

Also most of the time (if not always) offload flag is just an on/off flag to the PMD, application set/unset offload flag and PMD knows what to do. But for this case some capability variables, and a configuration API is required/involved.

Quoted 8 lines

For considering above two cases, what do you think implement this as control plane APIs instead of offload flag?
There are already 'conf_set()' and 'conf_get()' APIs introduced in coming patches, introducing an additional 'capability_get()' API removes the need of change in "struct rte_eth_dev_info" and 'RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY'
can be removed.
Thomas, Andrew, what do you think?

We are ok to add a new dev_op for capability_get() if we agree on that. Thomas, Andrew, let me know if you think otherwise.

Quoted 7 lines
Quoted 7 lines
lib/ethdev/rte_ethdev.h +1 -1
-	uint64_t reserved_64s[2]; /**< Reserved for future fields */
+	uint64_t reserved_64s[1]; /**< Reserved for future fields */
  	void *reserved_ptrs[2];   /**< Reserved for future fields */
  };
 
#133 lore raw

Re: [EXT] Re: [PATCH v3 1/4] ethdev: introduce IP reassembly offload

Quoted 16 lines · Akhil Goyal
Quoted 7 lines
Quoted 7 lines
lib/ethdev/rte_ethdev.h +7 -0
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * A structure used to get/set IP reassembly configuration.
+ *
Quoted 8 lines
Quoted 5 lines

+ * If RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY flag is set in offloads field,
+ * the PMD will attempt IP reassembly for the received packets as per
+ * properties defined in this structure.
+ */
+struct rte_eth_ip_reass_params {

As a generic comment, what do you think to use full 'reassembly' instead of 'reass' short version, to clarify/simplify the meaning?

Quoted 3 lines

Full reassembly was used in most places. But here the struct name would be too big. IMO, reass is good enough here. Though, no strong opinion. Will change if you insist.

Only it doesn't remind me 'reassembly' when I see 'reass', so I think not clear, we can wait for more comments from others.

Quoted 55 lines
Quoted 35 lines
Quoted 16 lines
lib/ethdev/rte_ethdev.h +11 -0
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout_ms;
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
   /**
    * A structure used to retrieve the contextual information of
    * an Ethernet device, such as the controlling driver of the

lib/ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1870

Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -0
@@ -1841,8 +1865,10 @@ struct rte_eth_dev_info {
   	 * embedded managed interconnect/switch.
   	 */
   	struct rte_eth_switch_info switch_info;
+	/** IP reassembly offload capabilities that a device can support. */
+	struct rte_eth_ip_reass_params reass_capa;
 

"struct rte_eth_dev_info" & 'rte_eth_dev_info_get()' are very common, all applications that use net devices and even some internal APIs rely on this struct and API.
It makes me uneasy to extend this struct with rarely used features, worrying on loading to much (capability/status/config) on single API/struct can cause an unmaintainable code by time.

Also most of the time (if not always) offload flag is just an on/off flag to the PMD, application set/unset offload flag and PMD knows what to do. But for this case some capability variables, and a configuration API is required/involved.

Quoted 8 lines

For considering above two cases, what do you think implement this as control plane APIs instead of offload flag?
There are already 'conf_set()' and 'conf_get()' APIs introduced in coming patches, introducing an additional 'capability_get()' API removes the need of change in "struct rte_eth_dev_info" and 'RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY'
can be removed.
Thomas, Andrew, what do you think?

We are ok to add a new dev_op for capability_get() if we agree on that. Thomas, Andrew, let me know if you think otherwise.

Quoted 7 lines
Quoted 7 lines
lib/ethdev/rte_ethdev.h +1 -1
-	uint64_t reserved_64s[2]; /**< Reserved for future fields */
+	uint64_t reserved_64s[1]; /**< Reserved for future fields */
   	void *reserved_ptrs[2];   /**< Reserved for future fields */
   };
 
#134 lore raw

PATCH v3 2/4 ethdev: add dev op to set/get IP reassembly configuration

In reply to Akhil Goyal

A new Ethernet device op is added to give application control over the IP reassembly configuration. This operation is an optional call from the application, default/max values are set by PMD and exposed via rte_eth_dev_info.
Application should always first retrieve the capabilities from rte_eth_dev_info and then set the fields accordingly. The set API should be called before the starting the device.

User can get the currently set values using the get API.

---
 doc/guides/nics/features.rst |  1 +
 lib/ethdev/ethdev_driver.h   | 37 +++++++++++++++++
 lib/ethdev/rte_ethdev.c      | 80 ++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h      | 51 +++++++++++++++++++++++
 lib/ethdev/version.map       |  4 ++
 5 files changed, 173 insertions(+)
doc/guides/nics/features.rst +1 -0
index b45bce4a78..2a3cf09066 100644
@@ -611,6 +611,7 @@ Supports IP reassembly in hardware.
 
 * **[uses]     rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY``.
 * **[provides] rte_eth_dev_info**: ``reass_capa``.
+* **[provides] eth_dev_ops**: ``ip_reassembly_conf_get:ip_reassembly_conf_set``.
 
 
 .. _nic_features_shared_rx_queue:
lib/ethdev/ethdev_driver.h +37 -0
index d95605a355..a310001648 100644
@@ -990,6 +990,38 @@ typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
 				       uint64_t *features);
 
+/**
+ * @internal
+ * Get IP reassembly offload configuration parameters set in PMD.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[out] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
+				       struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @internal
+ * Set configuration parameters for enabling IP reassembly offload in hardware.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[in] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
+				       struct rte_eth_ip_reass_params *conf);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1186,6 +1218,11 @@ struct eth_dev_ops {
 	 * kinds of metadata to the PMD
 	 */
 	eth_rx_metadata_negotiate_t rx_metadata_negotiate;
+
+	/** Get IP reassembly configuration */
+	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
+	/** Set IP reassembly configuration */
+	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
 };
 
 /**
lib/ethdev/rte_ethdev.c +80 -0

86 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +51 -0

57 lines not on this page · raw message

lib/ethdev/version.map +4 -0
index c2fb0669a4..ad829dd47e 100644
@@ -256,6 +256,10 @@ EXPERIMENTAL {
 	rte_flow_flex_item_create;
 	rte_flow_flex_item_release;
 	rte_flow_pick_transfer_proxy;
+
+	#added in 22.03
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
#135 lore raw

PATCH v3 3/4 ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

---
 lib/ethdev/ethdev_driver.h |  8 ++++++++
 lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 21 +++++++++++++++++++++
 lib/ethdev/version.map     |  1 +
 4 files changed, 58 insertions(+)
lib/ethdev/ethdev_driver.h +8 -0
index a310001648..7499a4fbf5 100644
@@ -1689,6 +1689,14 @@ int
 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
 				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
 /*
  * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +28 -0
index 6e9a8cf33b..3c68a951c0 100644
@@ -6553,6 +6553,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
 }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_ETH_IP_REASS_DYNFIELD_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name = RTE_ETH_IP_REASS_INCOMPLETE_DYNFLAG_NAME,
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +21 -0
index e3532591f4..e3e6368a1d 100644
@@ -5264,6 +5264,27 @@ __rte_experimental
 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 				   struct rte_eth_ip_reass_params *conf);
 
+#define RTE_ETH_IP_REASS_DYNFIELD_NAME "rte_eth_ip_reass_dynfield"
+#define RTE_ETH_IP_REASS_INCOMPLETE_DYNFLAG_NAME "rte_eth_ip_reass_incomplete_dynflag"
+
+/**
+ * In case of IP reassembly offload failure, ol_flags in mbuf will be set
+ * with RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE and packets will be returned
+ * without alteration. The application can retrieve the attached fragments
+ * using mbuf dynamic field.
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent_ms;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reass_dynfield_t;
+
 
 #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index ad829dd47e..8b7578471a 100644
@@ -283,6 +283,7 @@ INTERNAL {
 	rte_eth_hairpin_queue_peer_bind;
 	rte_eth_hairpin_queue_peer_unbind;
 	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reass_dynfield_register;
 	rte_eth_representor_id_get;
 	rte_eth_switch_domain_alloc;
 	rte_eth_switch_domain_free;
Signature · 1 line
2.25.1
#136 lore raw

Re: [PATCH v3 3/4] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 11 lines · Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

<...>

lib/ethdev/rte_ethdev.h __rte_experimental · line 5268

Quoted 9 lines

index e3532591f4..e3e6368a1d 100644

lib/ethdev/rte_ethdev.h +2 -0
@@ -5264,6 +5264,27 @@ __rte_experimental
  int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
  				   struct rte_eth_ip_reass_params *conf);
 
+#define RTE_ETH_IP_REASS_DYNFIELD_NAME "rte_eth_ip_reass_dynfield"
+#define RTE_ETH_IP_REASS_INCOMPLETE_DYNFLAG_NAME "rte_eth_ip_reass_incomplete_dynflag"

For other dynfield/dynflag these defines resides in mbuf library, not sure if these also should go there. cc'ed Olivier for comment.

#137 lore raw

RE: [EXT] Re: [PATCH v3 3/4] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 22 lines · Akhil Goyal
Quoted 11 lines

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

<...>

Quoted 7 lines

index e3532591f4..e3e6368a1d 100644

lib/ethdev/rte_ethdev.h +0 -0
@@ -5264,6 +5264,27 @@ __rte_experimental
  int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
  				   struct rte_eth_ip_reass_params *conf);
 
Quoted 6 lines

lib/ethdev/rte_ethdev.h __rte_experimental · line 5268

Quoted 2 lines
lib/ethdev/rte_ethdev.h +2 -0
+#define RTE_ETH_IP_REASS_DYNFIELD_NAME "rte_eth_ip_reass_dynfield"
+#define RTE_ETH_IP_REASS_INCOMPLETE_DYNFLAG_NAME

"rte_eth_ip_reass_incomplete_dynflag"

For other dynfield/dynflag these defines resides in mbuf library, not sure if these also should go there. cc'ed Olivier for comment.

Ok I will move these in rte_mbuf_dyn.h

#138 lore raw

PATCH v3 4/4 security: add IPsec option for IP reassembly

In reply to Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

---
 devtools/libabigail.abignore | 14 ++++++++++++++
 lib/security/rte_security.h  | 12 +++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +14 -0
index 90f449c43a..c6e304282f 100644
@@ -16,3 +16,17 @@
 [suppress_type]
 	name = rte_eth_dev_info
 	has_data_member_inserted_between = {offset_of(reserved_64s), end}
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
lib/security/rte_security.h +11 -1
index 1228b6c8b1..168b837a82 100644
@@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options {
 	 */
 	uint32_t l4_csum_enable : 1;
 
+	/** Enable reassembly on incoming packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if rx_offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in
+	 *      inline Ethernet device.
+	 * * 0: Disable reassembly of packets (default).
+	 */
+	uint32_t reass_en : 1;
+
 	/** Reserved bit fields for future extension
 	 *
 	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +281,7 @@ struct rte_security_ipsec_sa_options {
 	 *
 	 * Note: Reduce number of bits in reserved_opts for every new option.
 	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
 };
 
 /** IPSec security association direction */
Signature · 1 line
2.25.1
#139 lore raw

Re: [PATCH v3 4/4] security: add IPsec option for IP reassembly

Quoted 7 lines · Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

---
  devtools/libabigail.abignore | 14 ++++++++++++++
  lib/security/rte_security.h  | 12 +++++++++++-

+Radu for review

Quoted 54 lines
  2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +14 -0
index 90f449c43a..c6e304282f 100644
@@ -16,3 +16,17 @@
  [suppress_type]
  	name = rte_eth_dev_info
  	has_data_member_inserted_between = {offset_of(reserved_64s), end}
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
lib/security/rte_security.h +11 -1
index 1228b6c8b1..168b837a82 100644
@@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options {
  	 */
  	uint32_t l4_csum_enable : 1;
 
+	/** Enable reassembly on incoming packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if rx_offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in
+	 *      inline Ethernet device.
+	 * * 0: Disable reassembly of packets (default).
+	 */
+	uint32_t reass_en : 1;
+
  	/** Reserved bit fields for future extension
  	 *
  	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +281,7 @@ struct rte_security_ipsec_sa_options {
  	 *
  	 * Note: Reduce number of bits in reserved_opts for every new option.
  	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
  };
 
  /** IPSec security association direction */
#140 lore raw

RE: [EXT] Re: [PATCH v3 4/4] security: add IPsec option for IP reassembly

Quoted 33 lines · Akhil Goyal
Quoted 7 lines

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

---
  devtools/libabigail.abignore | 14 ++++++++++++++
  lib/security/rte_security.h  | 12 +++++++++++-

+Radu for review

devtools/libabigail.abignore line 20

Quoted 12 lines
  2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +2 -0
index 90f449c43a..c6e304282f 100644
@@ -16,3 +16,17 @@
  [suppress_type]
  	name = rte_eth_dev_info
  	has_data_member_inserted_between = {offset_of(reserved_64s), end}
+
+; Ignore fields inserted in place of reserved_opts of

rte_security_ipsec_sa_options

devtools/libabigail.abignore

Quoted 8 lines
devtools/libabigail.abignore +8 -0
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts),
Quoted 6 lines

(offset_of(reserved_opts) + 18)}

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Could not find any better way to suppress the ABI warning. Any better idea?

Quoted 30 lines
Quoted 30 lines
lib/security/rte_security.h +11 -1
index 1228b6c8b1..168b837a82 100644
@@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options {
  	 */
  	uint32_t l4_csum_enable : 1;
 
+	/** Enable reassembly on incoming packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if rx_offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in
+	 *      inline Ethernet device.
+	 * * 0: Disable reassembly of packets (default).
+	 */
+	uint32_t reass_en : 1;
+
  	/** Reserved bit fields for future extension
  	 *
  	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +281,7 @@ struct rte_security_ipsec_sa_options {
  	 *
  	 * Note: Reduce number of bits in reserved_opts for every new option.
  	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
  };
 
  /** IPSec security association direction */
#141 lore raw

Re: [EXT] Re: [PATCH v3 4/4] security: add IPsec option for IP reassembly

Quoted 34 lines · Akhil Goyal
Quoted 34 lines · Akhil Goyal
Quoted 7 lines

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

---
   devtools/libabigail.abignore | 14 ++++++++++++++
   lib/security/rte_security.h  | 12 +++++++++++-

+Radu for review

devtools/libabigail.abignore line 20

Quoted 12 lines
   2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +2 -0
index 90f449c43a..c6e304282f 100644
@@ -16,3 +16,17 @@
   [suppress_type]
   	name = rte_eth_dev_info
   	has_data_member_inserted_between = {offset_of(reserved_64s), end}
+
+; Ignore fields inserted in place of reserved_opts of

rte_security_ipsec_sa_options

devtools/libabigail.abignore

Quoted 8 lines
devtools/libabigail.abignore +8 -0
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Quoted 9 lines
Quoted 5 lines

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Could not find any better way to suppress the ABI warning. Any better idea?

+David for it, who knows abigail better.

Quoted 31 lines
Quoted 30 lines
Quoted 30 lines
lib/security/rte_security.h +11 -1
index 1228b6c8b1..168b837a82 100644
@@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options {
   	 */
   	uint32_t l4_csum_enable : 1;
 
+	/** Enable reassembly on incoming packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if rx_offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in
+	 *      inline Ethernet device.
+	 * * 0: Disable reassembly of packets (default).
+	 */
+	uint32_t reass_en : 1;
+
   	/** Reserved bit fields for future extension
   	 *
   	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +281,7 @@ struct rte_security_ipsec_sa_options {
   	 *
   	 * Note: Reduce number of bits in reserved_opts for every new option.
   	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
   };
 
   /** IPSec security association direction */
#142 lore raw

Re: [PATCH v3 0/4] ethdev: introduce IP reassembly offload

In reply to Akhil Goyal
Quoted 9 lines · Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.>

Can you please share the links of those sets?

Quoted 34 lines

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/

changes in v3:
- incorporated comments from Andrew and Stephen Hemminger

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Akhil Goyal (4):
ethdev: introduce IP reassembly offload
ethdev: add dev op to set/get IP reassembly configuration
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

  devtools/libabigail.abignore |  19 ++++++
  doc/guides/nics/features.rst |  12 ++++
  lib/ethdev/ethdev_driver.h   |  45 +++++++++++++++
  lib/ethdev/rte_ethdev.c      | 109 +++++++++++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h      | 100 +++++++++++++++++++++++++++++++-
  lib/ethdev/version.map       |   5 ++
  lib/security/rte_security.h  |  12 +++-
  7 files changed, 300 insertions(+), 2 deletions(-)
#143 lore raw

RE: [EXT] Re: [PATCH v3 0/4] ethdev: introduce IP reassembly offload

Quoted 13 lines · Akhil Goyal
Quoted 9 lines

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.>

Can you please share the links of those sets?

APP: http://patches.dpdk.org/project/dpdk/list/?series=21284
PMD: http://patches.dpdk.org/project/dpdk/list/?series=21285

#144 lore raw

v4 cover ethdev: introduce IP reassembly offload

In reply to Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.[2][3]

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/
[2]: APP: http://patches.dpdk.org/project/dpdk/list/?series=21284
[3]: PMD: http://patches.dpdk.org/project/dpdk/list/?series=21285
Newer versions of app and PMD will be sent once library changes are
acked.

Changes in v4:
- removed rte_eth_dev_info update for capability (Ferruh)
- removed Rx offload flag (Ferruh)
- added capability_get() (Ferruh)
- moved dynfield and dynflag namedefines in rte_mbuf_dyn.h (Ferruh)

changes in v3:
- incorporated comments from Andrew and Stephen Hemminger

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Akhil Goyal (3):
ethdev: introduce IP reassembly offload
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

 devtools/libabigail.abignore |  14 ++++
 doc/guides/nics/features.rst |  13 ++++
 lib/ethdev/ethdev_driver.h   |  63 ++++++++++++++++++
 lib/ethdev/rte_ethdev.c      | 121 +++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h      | 108 +++++++++++++++++++++++++++++++
 lib/ethdev/version.map       |   6 ++
 lib/mbuf/rte_mbuf_dyn.h      |   9 +++
 lib/security/rte_security.h  |  12 +++-
 8 files changed, 345 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#145 lore raw

PATCH v4 1/3 ethdev: introduce IP reassembly offload

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

Change-Id Ic20bb3af1ed599e8f2f3665d2d6c47b2e420e509
---
 doc/guides/nics/features.rst | 13 +++++
 lib/ethdev/ethdev_driver.h   | 55 +++++++++++++++++++++
 lib/ethdev/rte_ethdev.c      | 93 ++++++++++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h      | 91 +++++++++++++++++++++++++++++++++++
 lib/ethdev/version.map       |  5 ++
 5 files changed, 257 insertions(+)
doc/guides/nics/features.rst +13 -0
index 27be2d2576..e6e0bbe9d8 100644
@@ -602,6 +602,19 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[provides] eth_dev_ops**: ``ip_reassemly_capability_get``,
+  ``ip_reassembly_conf_get``, ``ip_reassembly_conf_set``.
+* **[related]    API**: ``rte_eth_ip_reassembly_capability_get()``,
+  ``rte_eth_ip_reassembly_conf_get()``, ``rte_eth_ip_reassembly_conf_set()``.
+
+
 .. _nic_features_shared_rx_queue:
 
 Shared Rx queue
lib/ethdev/ethdev_driver.h +55 -0

67 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +93 -0

99 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +91 -0

103 lines not on this page · raw message

lib/ethdev/version.map +5 -0
index c2fb0669a4..e22c102818 100644
@@ -256,6 +256,11 @@ EXPERIMENTAL {
 	rte_flow_flex_item_create;
 	rte_flow_flex_item_release;
 	rte_flow_pick_transfer_proxy;
+
+	# added in 22.03
+	rte_eth_ip_reassembly_capability_get;
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
#146 lore raw

RE: [PATCH v4 1/3] ethdev: introduce IP reassembly offload

Quoted 20 lines

Subject: [PATCH v4 1/3] ethdev: introduce IP reassembly offload

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

Quoted 7 lines

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be
updated by the PMD. This is updated in a subsequent patch.

Change-Id Ic20bb3af1ed599e8f2f3665d2d6c47b2e420e509

Please ignore the change-Id, will remove it in next version, or can be removed while applying if no further comments.

#147 lore raw

Re: [PATCH v4 1/3] ethdev: introduce IP reassembly offload

In reply to Akhil Goyal
Quoted 43 lines · Akhil Goyal

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

Change-Id Ic20bb3af1ed599e8f2f3665d2d6c47b2e420e509
---
  doc/guides/nics/features.rst | 13 +++++
  lib/ethdev/ethdev_driver.h   | 55 +++++++++++++++++++++
  lib/ethdev/rte_ethdev.c      | 93 ++++++++++++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h      | 91 +++++++++++++++++++++++++++++++++++
  lib/ethdev/version.map       |  5 ++
  5 files changed, 257 insertions(+)
doc/guides/nics/features.rst +3 -0
index 27be2d2576..e6e0bbe9d8 100644
@@ -602,6 +602,19 @@ Supports inner packet L4 checksum.
    ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly

doc/guides/nics/features.rst Supports inner packet L4 checksum. · line 617

Quoted 10 lines
doc/guides/nics/features.rst +10 -0
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[provides] eth_dev_ops**: ``ip_reassemly_capability_get``,
+  ``ip_reassembly_conf_get``, ``ip_reassembly_conf_set``.
+* **[related]    API**: ``rte_eth_ip_reassembly_capability_get()``,
+  ``rte_eth_ip_reassembly_conf_get()``, ``rte_eth_ip_reassembly_conf_set()``.
+
+

Need to update 'default.ini' to have this new feature.

Quoted 81 lines
doc/guides/nics/features.rst +0 -0
  .. _nic_features_shared_rx_queue:
 
  Shared Rx queue
lib/ethdev/ethdev_driver.h +55 -0
index d95605a355..8fe77f283f 100644
@@ -990,6 +990,54 @@ typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
  typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
  				       uint64_t *features);
 
+/**
+ * @internal
+ * Get IP reassembly offload capability of a PMD.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[out] conf
+ *   IP reassembly capability supported by the PMD
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev *dev,
+				struct rte_eth_ip_reass_params *capa);
+
+/**
+ * @internal
+ * Get IP reassembly offload configuration parameters set in PMD.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[out] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
+				struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @internal
+ * Set configuration parameters for enabling IP reassembly offload in hardware.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[in] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
+				const struct rte_eth_ip_reass_params *conf);
+
  /**
   * @internal A structure containing the functions exported by an Ethernet driver.
   */
@@ -1186,6 +1234,13 @@ struct eth_dev_ops {
  	 * kinds of metadata to the PMD
  	 */
  	eth_rx_metadata_negotiate_t rx_metadata_negotiate;
+
+	/** Get IP reassembly capability */
+	eth_ip_reassembly_capability_get_t ip_reassembly_capability_get;
+	/** Get IP reassembly configuration */
+	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
+	/** Set IP reassembly configuration */
+	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
  };
 
  /**
lib/ethdev/rte_ethdev.c +0 -0
index 29e21ad580..88ca4ce867 100644

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6479

Quoted 6 lines
lib/ethdev/rte_ethdev.c +3 -0
@@ -6474,6 +6474,99 @@ rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)
  		       (*dev->dev_ops->rx_metadata_negotiate)(dev, features));
  }
 
+int
+rte_eth_ip_reassembly_capability_get(uint16_t port_id,
+				     struct rte_eth_ip_reass_params *reass_capa)

syntax, dpdk coding converntion doesn't align the next line, mostly it has two tabs in next line.

Same comment valid for many instances below.

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6488

Quoted 9 lines
lib/ethdev/rte_ethdev.c +9 -0
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not configured.\n",

- while printing port_id, can use %u, 'PRIu16' has no benefit as far as I can see, and I see both are used in existing code, I prefer %u but no strong option there

- The log doesn't mention from ip reassembly capability at all, assume you see this log, will it give enough context to understand problem is related to ip reassembly?

- Andrew has a comment before that each log message should be unique, to be able to detect location easily, exact same log message is used a few other locations.

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6493

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+			port_id);
+		return -EINVAL;
+	}
+
+	if (reass_capa == NULL) {

I still think all 'reass' usage should be 'reassembly', but again that is me.

Quoted 26 lines
lib/ethdev/rte_ethdev.c +26 -0
+		RTE_ETHDEV_LOG(ERR, "Cannot get reassembly capability to NULL");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_capability_get,
+				-ENOTSUP);
+	memset(reass_capa, 0, sizeof(struct rte_eth_ip_reass_params));
+
+	return eth_err(port_id, (*dev->dev_ops->ip_reassembly_capability_get)
+					(dev, reass_capa));
+}
+
+int
+rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+			       struct rte_eth_ip_reass_params *conf)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6529

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+	}
+
+	if (conf == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Cannot get reassembly info to NULL");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_conf_get,
+				-ENOTSUP);
+	memset(conf, 0, sizeof(struct rte_eth_ip_reass_params));

If user didn't call 'rte_eth_ip_reassembly_conf_set()' prior to this call, what user will get here? All zeros, or can PMD fill with some defaults? Or should this API set some kind of error in that case to highlight there is no configuration?

Quoted 51 lines
lib/ethdev/rte_ethdev.c +40 -0
+	return eth_err(port_id,
+		       (*dev->dev_ops->ip_reassembly_conf_get)(dev, conf));
+}
+
+int
+rte_eth_ip_reassembly_conf_set(uint16_t port_id,
+			       const struct rte_eth_ip_reass_params *conf)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not configured.\n",
+			port_id);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started != 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" started,\n"
+			"cannot configure IP reassembly params.\n",
+			port_id);
+		return -EINVAL;
+	}
+
+	if (conf == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+				"Invalid IP reassembly configuration (NULL)\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->ip_reassembly_conf_set,
+				-ENOTSUP);
+	return eth_err(port_id,
+		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
+}
+
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +0 -0
index 147cc1ced3..ecc5cd50b9 100644
@@ -1794,6 +1794,29 @@ enum rte_eth_representor_type {
  	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
  };
 

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1806

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * A structure used to get/set IP reassembly configuration/capability.
+ *
+ * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be
+ * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than
+ * capability can be set in the PMD.

Can you please clarify "params values lower than capability"? Is it refering to 'max_frags'?

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1810

Quoted 4 lines
lib/ethdev/rte_ethdev.h +4 -0
+ */
+struct rte_eth_ip_reass_params {
+	/** Maximum time in ms which PMD can wait for other fragments. */
+	uint32_t reass_timeout_ms;

Other variables in the struct is missing 'reass_' prefix, like it is 'max_frags' instead of 'reass_max_frags', should we do the same for this variable?

Quoted 32 lines
lib/ethdev/rte_ethdev.h +25 -0
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
  /**
   * A structure used to retrieve the contextual information of
   * an Ethernet device, such as the controlling driver of the
@@ -5202,6 +5225,74 @@ int rte_eth_representor_info_get(uint16_t port_id,
  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get IP reassembly capabilities supported by the PMD,
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5253

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+__rte_experimental
+int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
+					 struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get IP reassembly configuration parameters currently set in PMD,
+ * if device Rx offload flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is

This flag is no more. Needs to updated the sentences.

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5255

Quoted 2 lines
lib/ethdev/rte_ethdev.h +2 -0
+ * enabled and the PMD supports IP reassembly offload.
+ *

Device needs to be configured to call this API, should it be documented here?

Quoted 15 lines
lib/ethdev/rte_ethdev.h +15 -0
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-EINVAL) if offload is not enabled in rte_eth_conf.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+				   struct rte_eth_ip_reass_params *conf);
+

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5280

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Set IP reassembly configuration parameters if the PMD supports IP reassembly
+ * offload. User should first call rte_eth_ip_reassembly_capability_get() to
+ * check the maximum values supported by the PMD before setting the
+ * configuration. The use of this API is mandatory to enable this feature and
+ * should be called before rte_eth_dev_start().
+ *

Not sure if above cause confusion, what above mean is this API should be called when device is stopped. When you call it should be called before 'te_eth_dev_start()' can it be taken as it should be called from first ever start() API?
If you think above is clear enough we can continue as it is.

Quoted 34 lines
lib/ethdev/rte_ethdev.h +15 -0
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
+				   const struct rte_eth_ip_reass_params *conf);
+
+
  #include <rte_ethdev_core.h>
 
  /**
lib/ethdev/version.map +5 -0
index c2fb0669a4..e22c102818 100644
@@ -256,6 +256,11 @@ EXPERIMENTAL {
  	rte_flow_flex_item_create;
  	rte_flow_flex_item_release;
  	rte_flow_pick_transfer_proxy;
+
+	# added in 22.03
+	rte_eth_ip_reassembly_capability_get;
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
  };
 
  INTERNAL {
#148 lore raw

RE: [EXT] Re: [PATCH v4 1/3] ethdev: introduce IP reassembly offload

Hi Ferruh,

Thanks for review,
Will send the next version soon.
Please see the comments inline.

Quoted 61 lines · Akhil Goyal
Quoted 6 lines

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which

can

Quoted 5 lines

attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before

rte_eth_dev_start()).

Quoted 4 lines

- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using

rte_eth_ip_reassembly_conf_set(),

Quoted 5 lines

the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags

can be

Quoted 8 lines

updated by the PMD. This is updated in a subsequent patch.

Change-Id Ic20bb3af1ed599e8f2f3665d2d6c47b2e420e509
---
  doc/guides/nics/features.rst | 13 +++++
  lib/ethdev/ethdev_driver.h   | 55 +++++++++++++++++++++
  lib/ethdev/rte_ethdev.c      | 93

++++++++++++++++++++++++++++++++++++

Quoted 1 line
  lib/ethdev/rte_ethdev.h      | 91

+++++++++++++++++++++++++++++++++++

doc/guides/nics/features.rst Supports inner packet L4 checksum. · line 602

Quoted 9 lines
  lib/ethdev/version.map       |  5 ++
  5 files changed, 257 insertions(+)
doc/guides/nics/features.rst +0 -0
index 27be2d2576..e6e0bbe9d8 100644
@@ -602,6 +602,19 @@ Supports inner packet L4 checksum.
 

``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_ UDP_CKSUM``.

doc/guides/nics/features.rst Supports inner packet L4 checksum.

Quoted 13 lines
doc/guides/nics/features.rst +11 -0
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[provides] eth_dev_ops**: ``ip_reassemly_capability_get``,
+  ``ip_reassembly_conf_get``, ``ip_reassembly_conf_set``.
+* **[related]    API**: ``rte_eth_ip_reassembly_capability_get()``,
+  ``rte_eth_ip_reassembly_conf_get()``,

``rte_eth_ip_reassembly_conf_set()``.

Quoted 4 lines

doc/guides/nics/features.rst Supports inner packet L4 checksum. · line 615

Quoted 2 lines
doc/guides/nics/features.rst +2 -0
+
+

Need to update 'default.ini' to have this new feature.

Yes, It got missed.

Quoted 97 lines

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct

Quoted 9 lines
doc/guides/nics/features.rst +0 -0
  .. _nic_features_shared_rx_queue:
 
  Shared Rx queue
lib/ethdev/ethdev_driver.h +0 -0
index d95605a355..8fe77f283f 100644
@@ -990,6 +990,54 @@ typedef int (*eth_representor_info_get_t)(struct

rte_eth_dev *dev,

Quoted 7 lines
lib/ethdev/ethdev_driver.h +4 -0
  typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
  				       uint64_t *features);
 
+/**
+ * @internal
+ * Get IP reassembly offload capability of a PMD.
+ *

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,

Quoted 10 lines
lib/ethdev/ethdev_driver.h +10 -0
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[out] conf
+ *   IP reassembly capability supported by the PMD
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev

*dev,

Quoted 11 lines
lib/ethdev/ethdev_driver.h +11 -0
+				struct rte_eth_ip_reass_params *capa);
+
+/**
+ * @internal
+ * Get IP reassembly offload configuration parameters set in PMD.
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[out] conf
+ *   Configuration parameters for IP reassembly.

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,

Quoted 10 lines
lib/ethdev/ethdev_driver.h +10 -0
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
+				struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @internal
+ * Set configuration parameters for enabling IP reassembly offload in

hardware.

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,

Quoted 12 lines
lib/ethdev/ethdev_driver.h +12 -0
+ *
+ * @param dev
+ *   Port (ethdev) handle
+ *
+ * @param[in] conf
+ *   Configuration parameters for IP reassembly.
+ *
+ * @return
+ *   Negative errno value on error, zero otherwise
+ */
+typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
+				const struct rte_eth_ip_reass_params

*conf);

lib/ethdev/ethdev_driver.h typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,

Quoted 3 lines
lib/ethdev/ethdev_driver.h +1 -0
+
  /**
   * @internal A structure containing the functions exported by an Ethernet

driver.

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t

Quoted 20 lines
lib/ethdev/ethdev_driver.h +7 -0
   */
@@ -1186,6 +1234,13 @@ struct eth_dev_ops {
  	 * kinds of metadata to the PMD
  	 */
  	eth_rx_metadata_negotiate_t rx_metadata_negotiate;
+
+	/** Get IP reassembly capability */
+	eth_ip_reassembly_capability_get_t ip_reassembly_capability_get;
+	/** Get IP reassembly configuration */
+	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
+	/** Set IP reassembly configuration */
+	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
  };
 
  /**
lib/ethdev/rte_ethdev.c +0 -0
index 29e21ad580..88ca4ce867 100644
@@ -6474,6 +6474,99 @@ rte_eth_rx_metadata_negotiate(uint16_t

port_id, uint64_t *features)

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t · line 6474

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -0
  		       (*dev->dev_ops->rx_metadata_negotiate)(dev,

features));

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 5 lines
lib/ethdev/rte_ethdev.c +3 -0
  }
 
+int
+rte_eth_ip_reassembly_capability_get(uint16_t port_id,
+				     struct rte_eth_ip_reass_params

*reass_capa)

Quoted 5 lines

syntax, dpdk coding converntion doesn't align the next line, mostly it has two tabs in next line.

Same comment valid for many instances below.

Ok

Quoted 21 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 9 lines
lib/ethdev/rte_ethdev.c +9 -0
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not

configured.\n",

- while printing port_id, can use %u, 'PRIu16' has no benefit as far as I can see,
and I see both are used in existing code, I prefer %u but no strong option there

- The log doesn't mention from ip reassembly capability at all, assume you see this
log, will it give enough context to understand problem is related to ip reassembly?

Quoted 4 lines

- Andrew has a comment before that each log message should be unique, to be able
to detect location easily, exact same log message is used a few other locations.

Ok will update the logs.

Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6493

Quoted 6 lines
lib/ethdev/rte_ethdev.c +5 -0
+			port_id);
+		return -EINVAL;
+	}
+
+	if (reass_capa == NULL) {

I still think all 'reass' usage should be 'reassembly', but again that is me.

Ok will change it.

Quoted 36 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t · line 6494

Quoted 2 lines
lib/ethdev/rte_ethdev.c +1 -0
+		RTE_ETHDEV_LOG(ERR, "Cannot get reassembly capability to

NULL");

Quoted 15 lines
lib/ethdev/rte_ethdev.c +13 -0
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
 ip_reassembly_capability_get,
+				-ENOTSUP);
+	memset(reass_capa, 0, sizeof(struct rte_eth_ip_reass_params));
+
+	return eth_err(port_id, (*dev->dev_ops-
 ip_reassembly_capability_get)
+					(dev, reass_capa));
+}
+
+int
+rte_eth_ip_reassembly_conf_get(uint16_t port_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+			       struct rte_eth_ip_reass_params *conf)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not

configured.\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 6 lines
lib/ethdev/rte_ethdev.c +6 -0
+			port_id);
+		return -EINVAL;
+	}
+
+	if (conf == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Cannot get reassembly info to

NULL");

Quoted 12 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features) · line 6529

Quoted 7 lines
lib/ethdev/rte_ethdev.c +6 -0
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
 ip_reassembly_conf_get,
+				-ENOTSUP);
+	memset(conf, 0, sizeof(struct rte_eth_ip_reass_params));

If user didn't call 'rte_eth_ip_reassembly_conf_set()' prior to this call, what user will get here? All zeros, or can PMD fill with some defaults? Or should this API set some kind of error in that case to highlight there is no configuration?

Ok I will update the doxygen comments for this. I believe it should give error.

Quoted 65 lines
Quoted 7 lines
lib/ethdev/rte_ethdev.c +6 -0
+	return eth_err(port_id,
+		       (*dev->dev_ops->ip_reassembly_conf_get)(dev, conf));
+}
+
+int
+rte_eth_ip_reassembly_conf_set(uint16_t port_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+			       const struct rte_eth_ip_reass_params *conf)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	if (dev->data->dev_configured == 0) {
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" is not

configured.\n",

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+			port_id);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started != 0) {

lib/ethdev/rte_ethdev.c rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+		RTE_ETHDEV_LOG(ERR,
+			"Device with port_id=%"PRIu16" started,\n"
+			"cannot configure IP reassembly params.\n",
+			port_id);
+		return -EINVAL;
+	}
+
+	if (conf == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+				"Invalid IP reassembly configuration

(NULL)\n");

Quoted 18 lines
lib/ethdev/rte_ethdev.c +4 -0
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-

ip_reassembly_conf_set,

lib/ethdev/rte_ethdev.c +5 -0
+				-ENOTSUP);
+	return eth_err(port_id,
+		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
+}
+
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +0 -0
index 147cc1ced3..ecc5cd50b9 100644

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1794

Quoted 1 line
lib/ethdev/rte_ethdev.h +0 -0
@@ -1794,6 +1794,29 @@ enum rte_eth_representor_type {
  	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function.

*/

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type {

Quoted 10 lines
lib/ethdev/rte_ethdev.h +8 -0
  };
 
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
+/**
+ * A structure used to get/set IP reassembly configuration/capability.
+ *
+ * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can

be

Quoted 6 lines

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1805

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+ * enabled using rte_eth_ip_reassembly_conf_set() and params values

lower than

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1806

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+ * capability can be set in the PMD.

Can you please clarify "params values lower than capability"? Is it refering to 'max_frags'?

It can be for all three params.
Timeout should be less than the capability of the driver.
It may be the case, app want to enable only IPv4 and not IPv6 but PMD can support both. So conf_set() params should be lesser compared to capability.

Quoted 10 lines

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type {

Quoted 4 lines
lib/ethdev/rte_ethdev.h +3 -0
+ */
+struct rte_eth_ip_reass_params {
+	/** Maximum time in ms which PMD can wait for other fragments.

*/

lib/ethdev/rte_ethdev.h enum rte_eth_representor_type { · line 1810

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+	uint32_t reass_timeout_ms;

Other variables in the struct is missing 'reass_' prefix, like it is 'max_frags' instead of 'reass_max_frags', should we do the same for this variable?

Ok I will drop reass from reass_timeout_ms. As it is part of rte_eth_ip_reass_params. Or I should say rte_eth_ip_reassembly_params - as per your comment.

Quoted 38 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t

Quoted 13 lines
lib/ethdev/rte_ethdev.h +9 -0
+	/** Maximum number of fragments that can be reassembled. */
+	uint16_t max_frags;
+	/**
+	 * Flags to enable reassembly of packet types -
+	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
+	 */
+	uint16_t flags;
+};
+
  /**
   * A structure used to retrieve the contextual information of
   * an Ethernet device, such as the controlling driver of the
@@ -5202,6 +5225,74 @@ int rte_eth_representor_info_get(uint16_t

port_id,

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t · line 5226

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t

*features);

Quoted 10 lines
lib/ethdev/rte_ethdev.h +9 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get IP reassembly capabilities supported by the PMD,
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id,

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
+					 struct rte_eth_ip_reass_params

*conf);

Quoted 9 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5253

Quoted 7 lines
lib/ethdev/rte_ethdev.h +7 -0
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get IP reassembly configuration parameters currently set in PMD,
+ * if device Rx offload flag (RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY) is

This flag is no more. Needs to updated the sentences.

Ahh my bad. Will correct it.

Quoted 6 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t · line 5254

Quoted 3 lines
lib/ethdev/rte_ethdev.h +2 -0
+ * enabled and the PMD supports IP reassembly offload.
+ *

Device needs to be configured to call this API, should it be documented here?

Ok will add one.

Quoted 30 lines
Quoted 11 lines
lib/ethdev/rte_ethdev.h +10 -0
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-EINVAL) if offload is not enabled in rte_eth_conf.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id,

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
+				   struct rte_eth_ip_reass_params *conf);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Set IP reassembly configuration parameters if the PMD supports IP

reassembly

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t · line 5275

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+ * offload. User should first call rte_eth_ip_reassembly_capability_get()

to

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t · line 5277

Quoted 2 lines
lib/ethdev/rte_ethdev.h +2 -0
+ * check the maximum values supported by the PMD before setting the
+ * configuration. The use of this API is mandatory to enable this feature

and

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5280

Quoted 2 lines
lib/ethdev/rte_ethdev.h +2 -0
+ * should be called before rte_eth_dev_start().
+ *
Quoted 6 lines

Not sure if above cause confusion, what above mean is this API should be called
when device is stopped. When you call it should be called before 'te_eth_dev_start()'
can it be taken as it should be called from first ever start() API? If you think above is clear enough we can continue as it is.

I believe dev_start() should be called after conf_set(). So we can continue as is. No requirement for first ever start call.

Quoted 36 lines
Quoted 4 lines
lib/ethdev/rte_ethdev.h +3 -0
+ * @param port_id
+ *   The port identifier of the device.
+ * @param conf

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id,

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+ *   A pointer to rte_eth_ip_reass_params structure.
+ * @return
+ *   - (-ENOTSUP) if offload configuration is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
+				   const struct rte_eth_ip_reass_params

*conf);

Quoted 21 lines
lib/ethdev/rte_ethdev.h +2 -0
+
+
  #include <rte_ethdev_core.h>
 
  /**
lib/ethdev/version.map +5 -0
index c2fb0669a4..e22c102818 100644
@@ -256,6 +256,11 @@ EXPERIMENTAL {
  	rte_flow_flex_item_create;
  	rte_flow_flex_item_release;
  	rte_flow_pick_transfer_proxy;
+
+	# added in 22.03
+	rte_eth_ip_reassembly_capability_get;
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
  };
 
  INTERNAL {
#149 lore raw

PATCH v4 2/3 ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
 lib/ethdev/ethdev_driver.h |  8 ++++++++
 lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
 lib/ethdev/version.map     |  1 +
 lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
 5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +8 -0
index 8fe77f283f..6cfb266f7d 100644
@@ -1707,6 +1707,14 @@ int
 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
 				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
 /*
  * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +28 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
 }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name = RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +17 -0
index ecc5cd50b9..ce35023c40 100644
@@ -5292,6 +5292,23 @@ __rte_experimental
 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 				   const struct rte_eth_ip_reass_params *conf);
 
+/**
+ * In case of IP reassembly offload failure, ol_flags in mbuf will be
+ * updated with dynamic flag and packets will be returned without alteration.
+ * The application can retrieve the attached fragments using mbuf dynamic field.
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reass_dynfield_t;
+
 
 #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index e22c102818..d6de8d402e 100644
@@ -284,6 +284,7 @@ INTERNAL {
 	rte_eth_hairpin_queue_peer_bind;
 	rte_eth_hairpin_queue_peer_unbind;
 	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reass_dynfield_register;
 	rte_eth_representor_id_get;
 	rte_eth_switch_domain_alloc;
 	rte_eth_switch_domain_free;
lib/mbuf/rte_mbuf_dyn.h +9 -0
index 29abe8da53..299638513b 100644
@@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);
  */
 int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t *tx_flag);
 
+/**
+ * For the PMDs which support IP reassembly of packets, PMD will updated the
+ * packet with RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME to denote that
+ * IP reassembly is incomplete and application can retrieve the packets back
+ * using RTE_MBUF_DYNFIELD_IP_REASS_NAME.
+ */
+#define RTE_MBUF_DYNFIELD_IP_REASS_NAME "rte_eth_ip_reass_dynfield"
+#define RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME "rte_eth_ip_reass_incomplete_dynflag"
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.25.1
#150 lore raw

Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 65 lines · Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
  lib/ethdev/ethdev_driver.h |  8 ++++++++
  lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
  lib/ethdev/version.map     |  1 +
  lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
  5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +8 -0
index 8fe77f283f..6cfb266f7d 100644
@@ -1707,6 +1707,14 @@ int
  rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
  				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
  /*
   * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +18 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
  		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
  }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name = RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 6597

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+

How mandatory is this field for the feature?

If 'rte_eth_ip_reass_dynfield_register()' fails, what PMD should do? Should this API called before 'rte_eth_ip_reassembly_capability_get()' and if registering dnyfield fails should PMD return feature as not supported?

Can you please describe this dependency, preferable in the 'rte_eth_ip_reassembly_capability_get()' doxygen comment?

Quoted 50 lines
lib/ethdev/rte_ethdev.c +0 -0
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +17 -0
index ecc5cd50b9..ce35023c40 100644
@@ -5292,6 +5292,23 @@ __rte_experimental
  int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
  				   const struct rte_eth_ip_reass_params *conf);
 
+/**
+ * In case of IP reassembly offload failure, ol_flags in mbuf will be
+ * updated with dynamic flag and packets will be returned without alteration.
+ * The application can retrieve the attached fragments using mbuf dynamic field.
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reass_dynfield_t;
+
 
  #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index e22c102818..d6de8d402e 100644
@@ -284,6 +284,7 @@ INTERNAL {
  	rte_eth_hairpin_queue_peer_bind;
  	rte_eth_hairpin_queue_peer_unbind;
  	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reass_dynfield_register;
  	rte_eth_representor_id_get;
  	rte_eth_switch_domain_alloc;
  	rte_eth_switch_domain_free;
lib/mbuf/rte_mbuf_dyn.h +0 -0
index 29abe8da53..299638513b 100644
@@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);
   */
  int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t *tx_flag);

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag); · line 331

Quoted 10 lines
lib/mbuf/rte_mbuf_dyn.h +9 -0
 
+/**
+ * For the PMDs which support IP reassembly of packets, PMD will updated the
+ * packet with RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME to denote that
+ * IP reassembly is incomplete and application can retrieve the packets back
+ * using RTE_MBUF_DYNFIELD_IP_REASS_NAME.
+ */
+#define RTE_MBUF_DYNFIELD_IP_REASS_NAME "rte_eth_ip_reass_dynfield"
+#define RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME "rte_eth_ip_reass_incomplete_dynflag"
+

Needs Olivier's comment/ack.

#151 lore raw

RE: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 82 lines · Akhil Goyal
Quoted 25 lines

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
  lib/ethdev/ethdev_driver.h |  8 ++++++++
  lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
  lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
  lib/ethdev/version.map     |  1 +
  lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
  5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +0 -0
index 8fe77f283f..6cfb266f7d 100644

lib/ethdev/ethdev_driver.h int · line 1707

Quoted 1 line
lib/ethdev/ethdev_driver.h +0 -0
@@ -1707,6 +1707,14 @@ int
  rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t

cur_queue,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t

Quoted 18 lines
lib/ethdev/ethdev_driver.h +8 -0
  				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
  /*
   * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +0 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t

port_id,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 13 lines
lib/ethdev/rte_ethdev.c +10 -0
  		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
  }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name =

RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 6597

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+

How mandatory is this field for the feature?

Quoted 3 lines

If 'rte_eth_ip_reass_dynfield_register()' fails, what PMD should do? Should this API called before 'rte_eth_ip_reassembly_capability_get()' and if registering dnyfield fails should PMD return feature as not supported?

Dynfield is added for the error/ incomplete reassembly case.
If the dynfield is not registered, the feature can work well for success scenarios. Dynfield registration is responsibility of PMD and it is upto the driver to decide when to set the dynfield. The registration can be done in conf_set() API.

Quoted 3 lines

Can you please describe this dependency, preferable in the 'rte_eth_ip_reassembly_capability_get()' doxygen comment?

Capability get is not a place where the feature is enabled. Dynfield should be registered only in case the feature is enabled. I will add following line in conf_set() doxygen comment.

The PMD should call 'rte_eth_ip_reass_dynfield_register()' when the feature is enabled and return error if dynfield is not registered. Dynfield is needed to give packets back to the application in case the reassembly is not complete.

Quoted 67 lines

lib/ethdev/rte_ethdev.h __rte_experimental · line 5293

Quoted 11 lines
lib/ethdev/rte_ethdev.c +0 -0
  RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
  RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +0 -0
index ecc5cd50b9..ce35023c40 100644
@@ -5292,6 +5292,23 @@ __rte_experimental
  int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
  				   const struct rte_eth_ip_reass_params

*conf);

lib/ethdev/rte_ethdev.h __rte_experimental

Quoted 4 lines
lib/ethdev/rte_ethdev.h +3 -0
+/**
+ * In case of IP reassembly offload failure, ol_flags in mbuf will be
+ * updated with dynamic flag and packets will be returned without

alteration.

lib/ethdev/rte_ethdev.h __rte_experimental · line 5297

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+ * The application can retrieve the attached fragments using mbuf

dynamic field.

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int

Quoted 33 lines
lib/ethdev/rte_ethdev.h +13 -0
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reass_dynfield_t;
+
 
  #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index e22c102818..d6de8d402e 100644
@@ -284,6 +284,7 @@ INTERNAL {
  	rte_eth_hairpin_queue_peer_bind;
  	rte_eth_hairpin_queue_peer_unbind;
  	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reass_dynfield_register;
  	rte_eth_representor_id_get;
  	rte_eth_switch_domain_alloc;
  	rte_eth_switch_domain_free;
lib/mbuf/rte_mbuf_dyn.h +0 -0
index 29abe8da53..299638513b 100644
@@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int

*field_offset, uint64_t *rx_flag);

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 321

Quoted 2 lines
lib/mbuf/rte_mbuf_dyn.h +0 -0
   */
  int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t

*tx_flag);

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 323

Quoted 3 lines
lib/mbuf/rte_mbuf_dyn.h +2 -0
+/**
+ * For the PMDs which support IP reassembly of packets, PMD will

updated the

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 324

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+ * packet with RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME to

denote that

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 325

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+ * IP reassembly is incomplete and application can retrieve the packets

back

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);

Quoted 3 lines
lib/mbuf/rte_mbuf_dyn.h +3 -0
+ * using RTE_MBUF_DYNFIELD_IP_REASS_NAME.
+ */
+#define RTE_MBUF_DYNFIELD_IP_REASS_NAME
Quoted 6 lines

"rte_eth_ip_reass_dynfield"

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 329

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+#define RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME

"rte_eth_ip_reass_incomplete_dynflag"

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 330

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+

Needs Olivier's comment/ack.

@Olivier: could you please comment on this?

#152 lore raw

Re: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 95 lines · Akhil Goyal
Quoted 82 lines · Akhil Goyal
Quoted 25 lines

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
   lib/ethdev/ethdev_driver.h |  8 ++++++++
   lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
   lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
   lib/ethdev/version.map     |  1 +
   lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
   5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +0 -0
index 8fe77f283f..6cfb266f7d 100644

lib/ethdev/ethdev_driver.h int · line 1707

Quoted 1 line
lib/ethdev/ethdev_driver.h +0 -0
@@ -1707,6 +1707,14 @@ int
   rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t

cur_queue,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t

Quoted 18 lines
lib/ethdev/ethdev_driver.h +8 -0
   				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
   /*
    * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +0 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t

port_id,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 13 lines
lib/ethdev/rte_ethdev.c +10 -0
   		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
   }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name =

RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 6597

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+

How mandatory is this field for the feature?

Quoted 3 lines

If 'rte_eth_ip_reass_dynfield_register()' fails, what PMD should do? Should this API called before 'rte_eth_ip_reassembly_capability_get()' and if registering dnyfield fails should PMD return feature as not supported?

Dynfield is added for the error/ incomplete reassembly case.
If the dynfield is not registered, the feature can work well for success scenarios. Dynfield registration is responsibility of PMD and it is upto the driver to decide when to set the dynfield. The registration can be done in conf_set() API.

Quoted 3 lines

Can you please describe this dependency, preferable in the 'rte_eth_ip_reassembly_capability_get()' doxygen comment?

Quoted 9 lines

Capability get is not a place where the feature is enabled. Dynfield should be registered only in case the feature is enabled. I will add following line in conf_set() doxygen comment.

The PMD should call 'rte_eth_ip_reass_dynfield_register()' when the feature is enabled and return error if dynfield is not registered. Dynfield is needed to give packets back to the application in case the reassembly is not complete.

Can you also clarify what PMD should do related to the ip reassembly feature when registering dynfield fails? Should it keep the feature enabled or disabled?

This will also clarify for the application, if application detects that 'RTE_MBUF_DYNFIELD_IP_REASS_NAME' is not registered how it should behave? Ignore it? Fail? Disable ip reassembly?

Quoted 74 lines
Quoted 67 lines

lib/ethdev/rte_ethdev.h __rte_experimental · line 5293

Quoted 11 lines
lib/ethdev/rte_ethdev.c +0 -0
   RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
   RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +0 -0
index ecc5cd50b9..ce35023c40 100644
@@ -5292,6 +5292,23 @@ __rte_experimental
   int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
   				   const struct rte_eth_ip_reass_params

*conf);

lib/ethdev/rte_ethdev.h __rte_experimental

Quoted 4 lines
lib/ethdev/rte_ethdev.h +3 -0
+/**
+ * In case of IP reassembly offload failure, ol_flags in mbuf will be
+ * updated with dynamic flag and packets will be returned without

alteration.

lib/ethdev/rte_ethdev.h __rte_experimental · line 5297

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+ * The application can retrieve the attached fragments using mbuf

dynamic field.

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int

Quoted 33 lines
lib/ethdev/rte_ethdev.h +13 -0
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reass_dynfield_t;
+
 
   #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index e22c102818..d6de8d402e 100644
@@ -284,6 +284,7 @@ INTERNAL {
   	rte_eth_hairpin_queue_peer_bind;
   	rte_eth_hairpin_queue_peer_unbind;
   	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reass_dynfield_register;
   	rte_eth_representor_id_get;
   	rte_eth_switch_domain_alloc;
   	rte_eth_switch_domain_free;
lib/mbuf/rte_mbuf_dyn.h +0 -0
index 29abe8da53..299638513b 100644
@@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int

*field_offset, uint64_t *rx_flag);

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 321

Quoted 2 lines
lib/mbuf/rte_mbuf_dyn.h +0 -0
    */
   int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t

*tx_flag);

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 323

Quoted 3 lines
lib/mbuf/rte_mbuf_dyn.h +2 -0
+/**
+ * For the PMDs which support IP reassembly of packets, PMD will

updated the

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 324

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+ * packet with RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME to

denote that

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 325

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+ * IP reassembly is incomplete and application can retrieve the packets

back

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);

Quoted 3 lines
lib/mbuf/rte_mbuf_dyn.h +3 -0
+ * using RTE_MBUF_DYNFIELD_IP_REASS_NAME.
+ */
+#define RTE_MBUF_DYNFIELD_IP_REASS_NAME
Quoted 6 lines

"rte_eth_ip_reass_dynfield"

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 329

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+#define RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME

"rte_eth_ip_reass_incomplete_dynflag"

lib/mbuf/rte_mbuf_dyn.h int rte_mbuf_dyn_rx_timestamp_register(int · line 330

Quoted 1 line
lib/mbuf/rte_mbuf_dyn.h +1 -0
+

Needs Olivier's comment/ack.

@Olivier: could you please comment on this?

#153 lore raw

RE: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 107 lines · Akhil Goyal
Quoted 82 lines
Quoted 82 lines · Akhil Goyal
Quoted 25 lines

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
   lib/ethdev/ethdev_driver.h |  8 ++++++++
   lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
   lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
   lib/ethdev/version.map     |  1 +
   lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
   5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +0 -0
index 8fe77f283f..6cfb266f7d 100644

lib/ethdev/ethdev_driver.h int · line 1707

Quoted 1 line
lib/ethdev/ethdev_driver.h +0 -0
@@ -1707,6 +1707,14 @@ int
   rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t

cur_queue,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t

Quoted 18 lines
lib/ethdev/ethdev_driver.h +8 -0
   				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
   /*
    * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +0 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t

port_id,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 13 lines
lib/ethdev/rte_ethdev.c +10 -0
   		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
   }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name =

RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 6597

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+

How mandatory is this field for the feature?

Quoted 6 lines
Quoted 3 lines

If 'rte_eth_ip_reass_dynfield_register()' fails, what PMD should do? Should this API called before 'rte_eth_ip_reassembly_capability_get()' and if registering dnyfield fails should PMD return feature as not supported?

Dynfield is added for the error/ incomplete reassembly case. If the dynfield is not registered, the feature can work well for success

scenarios.

Quoted 7 lines

Dynfield registration is responsibility of PMD and it is upto the driver to decide when to set the dynfield. The registration can be done in conf_set() API.

Quoted 3 lines

Can you please describe this dependency, preferable in the 'rte_eth_ip_reassembly_capability_get()' doxygen comment?

Quoted 9 lines

Capability get is not a place where the feature is enabled. Dynfield should be registered only in case the feature is enabled. I will add following line in conf_set() doxygen comment.

The PMD should call 'rte_eth_ip_reass_dynfield_register()' when the feature is enabled and return error if dynfield is not registered. Dynfield is needed to give packets back to the application in case the reassembly is not complete.

Quoted 7 lines

Can you also clarify what PMD should do related to the ip reassembly feature when registering dynfield fails? Should it keep the feature enabled or disabled?

This will also clarify for the application, if application detects that 'RTE_MBUF_DYNFIELD_IP_REASS_NAME' is not registered how it should behave?
Ignore it? Fail? Disable ip reassembly?

The PMD can return error in the conf_set API, if dynfield is not successfully registered. Or in case of inline IPsec, the PMD can return the error while creating inline security session.

Hence the application will get to know if the dynfield is successfully configured Or not.
If the dynfield is not configured, PMD will return configuration error (either in conf_set or in security_session_create) and feature
will not be enabled.

#154 lore raw

Re: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 110 lines · Akhil Goyal
Quoted 110 lines · Akhil Goyal
Quoted 82 lines
Quoted 82 lines · Akhil Goyal
Quoted 25 lines

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
    lib/ethdev/ethdev_driver.h |  8 ++++++++
    lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
    lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
    lib/ethdev/version.map     |  1 +
    lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
    5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +0 -0
index 8fe77f283f..6cfb266f7d 100644

lib/ethdev/ethdev_driver.h int · line 1707

Quoted 1 line
lib/ethdev/ethdev_driver.h +0 -0
@@ -1707,6 +1707,14 @@ int
    rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t

cur_queue,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t

Quoted 18 lines
lib/ethdev/ethdev_driver.h +8 -0
    				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
    /*
     * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +0 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t

port_id,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 13 lines
lib/ethdev/rte_ethdev.c +10 -0
    		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
    }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name =

RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 6597

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+

How mandatory is this field for the feature?

Quoted 6 lines
Quoted 3 lines

If 'rte_eth_ip_reass_dynfield_register()' fails, what PMD should do? Should this API called before 'rte_eth_ip_reassembly_capability_get()' and if registering dnyfield fails should PMD return feature as not supported?

Dynfield is added for the error/ incomplete reassembly case. If the dynfield is not registered, the feature can work well for success

scenarios.

Quoted 7 lines

Dynfield registration is responsibility of PMD and it is upto the driver to decide when to set the dynfield. The registration can be done in conf_set() API.

Quoted 3 lines

Can you please describe this dependency, preferable in the 'rte_eth_ip_reassembly_capability_get()' doxygen comment?

Quoted 9 lines

Capability get is not a place where the feature is enabled. Dynfield should be registered only in case the feature is enabled. I will add following line in conf_set() doxygen comment.

The PMD should call 'rte_eth_ip_reass_dynfield_register()' when the feature is enabled and return error if dynfield is not registered. Dynfield is needed to give packets back to the application in case the reassembly is not complete.

Can you also clarify what PMD should do related to the ip reassembly feature when registering dynfield fails? Should it keep the feature enabled or disabled?

Quoted 9 lines
Quoted 4 lines

This will also clarify for the application, if application detects that 'RTE_MBUF_DYNFIELD_IP_REASS_NAME' is not registered how it should behave?
Ignore it? Fail? Disable ip reassembly?

The PMD can return error in the conf_set API, if dynfield is not successfully registered. Or in case of inline IPsec, the PMD can return the error while creating inline security session.

I think better to handle in the conf_set, since there can be other users than IPSec.

Quoted 2 lines

Hence the application will get to know if the dynfield is successfully configured Or not.

Application already can know if dynfield is registered or not via 'rte_mbuf_dynfield_lookup()'.

Quoted 4 lines

If the dynfield is not configured, PMD will return configuration error (either in conf_set or in security_session_create) and feature will not be enabled.

ack.
What do you think to document this in the API documentation (doxygen comment)?

#155 lore raw

RE: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 141 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, February 7, 2022 10:11 PM
To: Akhil Goyal <[email protected]>; [email protected]; [email protected]
Cc: Anoob Joseph <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 11 lines · Akhil Goyal
Quoted 11 lines · Akhil Goyal
Quoted 10 lines
Quoted 10 lines · Akhil Goyal
Quoted 9 lines

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more

time.

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 16 lines
Change-Id I118847cd6269da7e6313ac4e0d970d790dfef1ff
---
    lib/ethdev/ethdev_driver.h |  8 ++++++++
    lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
    lib/ethdev/rte_ethdev.h    | 17 +++++++++++++++++
    lib/ethdev/version.map     |  1 +
    lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
    5 files changed, 63 insertions(+)
lib/ethdev/ethdev_driver.h +0 -0
index 8fe77f283f..6cfb266f7d 100644

lib/ethdev/ethdev_driver.h int · line 1707

Quoted 1 line
lib/ethdev/ethdev_driver.h +0 -0
@@ -1707,6 +1707,14 @@ int
    rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t

cur_queue,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

lib/ethdev/ethdev_driver.h int

Quoted 5 lines
lib/ethdev/ethdev_driver.h +3 -0
    				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete

case.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t

Quoted 13 lines
lib/ethdev/ethdev_driver.h +5 -0
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);
+
 
    /*
     * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +0 -0
index 88ca4ce867..48367dbec1 100644
@@ -6567,6 +6567,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t

port_id,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t · line 6567

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -0
    		       (*dev->dev_ops->ip_reassembly_conf_set)(dev,

conf));

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 4 lines
lib/ethdev/rte_ethdev.c +2 -0
    }
 
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int

*flag_offset)

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASS_NAME,
+		.size = sizeof(rte_eth_ip_reass_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reass_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reass_dynflag = {
+		.name =

RTE_MBUF_DYNFLAG_IP_REASS_INCOMPLETE_NAME,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 6597

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+
+	offset = rte_mbuf_dynflag_register(&ip_reass_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+

How mandatory is this field for the feature?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

If 'rte_eth_ip_reass_dynfield_register()' fails, what PMD should do? Should this API called before 'rte_eth_ip_reassembly_capability_get()'

and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

if registering dnyfield fails should PMD return feature as not

supported?

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

Dynfield is added for the error/ incomplete reassembly case. If the dynfield is not registered, the feature can work well for success

scenarios.

Quoted 1 line

Dynfield registration is responsibility of PMD and it is upto the driver to

decide

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

when to set the dynfield. The registration can be done in conf_set() API.

Quoted 3 lines

Can you please describe this dependency, preferable in the 'rte_eth_ip_reassembly_capability_get()' doxygen comment?

Capability get is not a place where the feature is enabled. Dynfield should be registered only in case the feature is enabled. I will add following line in conf_set() doxygen comment.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

The PMD should call 'rte_eth_ip_reass_dynfield_register()' when the feature is enabled and return error if dynfield is not registered. Dynfield is needed to give packets back to the application in case the reassembly is not complete.

Can you also clarify what PMD should do related to the ip reassembly

feature

Quoted 1 line
Quoted 1 line

when registering dynfield fails? Should it keep the feature enabled or

disabled?

Quoted 6 lines
Quoted 5 lines

This will also clarify for the application, if application detects that 'RTE_MBUF_DYNFIELD_IP_REASS_NAME' is not registered how it should behave?
Ignore it? Fail? Disable ip reassembly?

Quoted 7 lines
Quoted 4 lines

The PMD can return error in the conf_set API, if dynfield is not successfully registered. Or in case of inline IPsec, the PMD can return the error while creating inline security session.

I think better to handle in the conf_set, since there can be other users than IPSec.

I think it can be left to the PMD, as there can be cases when reassembly is supported Only with IPsec flows and not with normal IP packets.
So reassembly may get enabled for IPsec flows only when security session is created. In that case session creation will fail.

Quoted 8 lines
Quoted 2 lines

Hence the application will get to know if the dynfield is successfully

configured

Quoted 1 line

Or not.

Application already can know if dynfield is registered or not via 'rte_mbuf_dynfield_lookup()'.

Quoted 8 lines
Quoted 4 lines

If the dynfield is not configured, PMD will return configuration error (either in conf_set or in security_session_create) and feature will not be enabled.

ack.
What do you think to document this in the API documentation (doxygen comment)?

Ok I will try to clarify this in doxygen comments.

#156 lore raw

Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Akhil Goyal

lib/ethdev/ethdev_driver.h int · line 1716

Quoted 7 lines · On Sat, 5 Feb 2022 03:43:33 +0530 Akhil Goyal <[email protected]> wrote:
lib/ethdev/ethdev_driver.h +7 -0
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);

Maybe use RTE_INIT() constructor for this?

#157 lore raw

Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 12 lines · Stephen Hemminger

lib/ethdev/ethdev_driver.h int · line 1716

Quoted 7 lines · On Sat, 5 Feb 2022 03:43:33 +0530 Akhil Goyal <[email protected]> wrote:
lib/ethdev/ethdev_driver.h +7 -0
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);

Maybe use RTE_INIT() constructor for this?

Dynfiled should be registered only when users asks for the feature.

#158 lore raw

Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 14 lines · On Mon, 7 Feb 2022 17:28:26 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 12 lines · Stephen Hemminger

lib/ethdev/ethdev_driver.h int · line 1716

Quoted 7 lines · On Sat, 5 Feb 2022 03:43:33 +0530 Akhil Goyal <[email protected]> wrote:
lib/ethdev/ethdev_driver.h +7 -0
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);  

Maybe use RTE_INIT() constructor for this?

Quoted 1 line

Dynfiled should be registered only when users asks for the feature.

right but making the user ask can lead to errors, can it be done implicitly on first use.

#159 lore raw

RE: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 18 lines
Quoted 7 lines · On Mon, 7 Feb 2022 17:28:26 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 6 lines · Stephen Hemminger
Quoted 3 lines · On Sat, 5 Feb 2022 03:43:33 +0530 Akhil Goyal <[email protected]> wrote:

+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete

case.

Quoted 7 lines
Quoted 6 lines

lib/ethdev/ethdev_driver.h int · line 1716

Quoted 4 lines

+ */

lib/ethdev/ethdev_driver.h +3 -0
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);

Maybe use RTE_INIT() constructor for this?

Quoted 4 lines
Quoted 1 line

Dynfiled should be registered only when users asks for the feature.

right but making the user ask can lead to errors, can it be done implicitly on first use.

Registering dynfield is responsibility of PMD when the application asks for the feature. So how can it lead to errors.

#160 lore raw

Re: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 18 lines · On Mon, 7 Feb 2022 18:28:03 +0000 Akhil Goyal <[email protected]> wrote:
Quoted 18 lines
Quoted 7 lines · On Mon, 7 Feb 2022 17:28:26 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 6 lines · Stephen Hemminger
Quoted 3 lines · On Sat, 5 Feb 2022 03:43:33 +0530 Akhil Goyal <[email protected]> wrote:

+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete

case.

Quoted 7 lines
Quoted 6 lines

lib/ethdev/ethdev_driver.h int · line 1716

Quoted 4 lines

+ */

lib/ethdev/ethdev_driver.h +3 -0
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);  

Maybe use RTE_INIT() constructor for this?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Dynfiled should be registered only when users asks for the feature.

right but making the user ask can lead to errors, can it be done implicitly on first use.

Registering dynfield is responsibility of PMD when the application asks for the feature. So how can it lead to errors.

Sorry, forgot this is a PMD internal thing.

#161 lore raw

RE: [EXT] Re: [PATCH v4 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Stephen Hemminger
Quoted 12 lines

lib/ethdev/ethdev_driver.h int · line 1716

Quoted 7 lines · On Sat, 5 Feb 2022 03:43:33 +0530 Akhil Goyal <[email protected]> wrote:
lib/ethdev/ethdev_driver.h +7 -0
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reass_dynfield_register(int *field_offset, int *flag);

Maybe use RTE_INIT() constructor for this?

The same application can be used for non-reassembly case as well. RTE_INIT would mean, dynfield would be registered always even if it is enabled or not.
The current implementation would register it only when the Reassembly option is enabled.

#162 lore raw

PATCH v4 3/3 security: add IPsec option for IP reassembly

In reply to Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

Change-Id I6f66f0b5a659550976a32629130594070cb16cb1
---
 devtools/libabigail.abignore | 14 ++++++++++++++
 lib/security/rte_security.h  | 12 +++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +14 -0
index 4b676f317d..3bd39042e8 100644
@@ -11,3 +11,17 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
lib/security/rte_security.h +11 -1
index 1228b6c8b1..168b837a82 100644
@@ -264,6 +264,16 @@ struct rte_security_ipsec_sa_options {
 	 */
 	uint32_t l4_csum_enable : 1;
 
+	/** Enable reassembly on incoming packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if rx_offload RTE_ETH_RX_OFFLOAD_IP_REASSEMBLY is set in
+	 *      inline Ethernet device.
+	 * * 0: Disable reassembly of packets (default).
+	 */
+	uint32_t reass_en : 1;
+
 	/** Reserved bit fields for future extension
 	 *
 	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +281,7 @@ struct rte_security_ipsec_sa_options {
 	 *
 	 * Note: Reduce number of bits in reserved_opts for every new option.
 	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
 };
 
 /** IPSec security association direction */
Signature · 1 line
2.25.1
#163 lore raw

Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Hello Akhil,

Quoted 3 lines · Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

First, about extending this structure.

Copying the header:

        /** Reserved bit fields for future extension
         *
         * User should ensure reserved_opts is cleared as it may change in
         * subsequent releases to support new options.
         *
         * Note: Reduce number of bits in reserved_opts for every new option.
         */
        uint32_t reserved_opts : 18;

I did not follow the introduction of the reserved_opts field, but writing this comment in the API only is weak.
Why can't the rte_security API enforce reserved_opts == 0 (like in rte_security_session_create)?

Quoted 3 lines
Change-Id I6f66f0b5a659550976a32629130594070cb16cb1

^^^
Internal tag, please remove.

Quoted 17 lines
---
 devtools/libabigail.abignore | 14 ++++++++++++++
 lib/security/rte_security.h  | 12 +++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +4 -0
index 4b676f317d..3bd39042e8 100644
@@ -11,3 +11,17 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_ipsec_sa_prm

devtools/libabigail.abignore line 27

Quoted 10 lines
devtools/libabigail.abignore +10 -0
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts), (offset_of(reserved_opts) + 18)}

Now, about the suppression rule, I don't understand the intention of those 3 rules.

I would simply suppress modifications (after reserved_opts) to the rte_security_ipsec_sa_options struct.
Like:

; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
[suppress_type]
name = rte_security_ipsec_sa_options has_data_member_inserted_between = {offset_of(reserved_opts), end}

Signature · 1 line
David Marchand
#164 lore raw

RE: [EXT] Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Quoted 21 lines

Hello Akhil,

Quoted 3 lines · Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

First, about extending this structure.

Copying the header:

        /** Reserved bit fields for future extension
         *
         * User should ensure reserved_opts is cleared as it may change in
         * subsequent releases to support new options.
         *
         * Note: Reduce number of bits in reserved_opts for every new option.
         */
        uint32_t reserved_opts : 18;
Quoted 5 lines

I did not follow the introduction of the reserved_opts field, but writing this comment in the API only is weak.
Why can't the rte_security API enforce reserved_opts == 0 (like in rte_security_session_create)?

This was discussed here.
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
rte_security_ipsec_sa_options is being used at multiple places as listed below in abiignore. Checking a particular field in each of the API does not make sense to me.

Quoted 8 lines
Quoted 5 lines
Change-Id I6f66f0b5a659550976a32629130594070cb16cb1

^^^
Internal tag, please remove.

Yes, missed that will remove.

Quoted 39 lines
Quoted 11 lines
---
 devtools/libabigail.abignore | 14 ++++++++++++++
 lib/security/rte_security.h  | 12 +++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +0 -0
index 4b676f317d..3bd39042e8 100644

devtools/libabigail.abignore line 15

Quoted 5 lines
devtools/libabigail.abignore +2 -0
@@ -11,3 +11,17 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of

rte_security_ipsec_sa_options

devtools/libabigail.abignore

Quoted 8 lines
devtools/libabigail.abignore +8 -0
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Now, about the suppression rule, I don't understand the intention of those 3 rules.

I would simply suppress modifications (after reserved_opts) to the rte_security_ipsec_sa_options struct.
Like:

Quoted 6 lines

; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
[suppress_type]
name = rte_security_ipsec_sa_options has_data_member_inserted_between = {offset_of(reserved_opts), end}

I tried this in the first place but abi check was complaining in other structures which included rte_security_ipsec_sa_options. So I had to add suppression for those as well. Can you try at your end?

#165 lore raw

Re: [EXT] Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Quoted 27 lines · Akhil Goyal
Quoted 22 lines

Hello Akhil,

Quoted 3 lines · Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound packets.

First, about extending this structure.

Copying the header:

        /** Reserved bit fields for future extension
         *
         * User should ensure reserved_opts is cleared as it may change in
         * subsequent releases to support new options.
         *
         * Note: Reduce number of bits in reserved_opts for every new option.
         */
        uint32_t reserved_opts : 18;
Quoted 5 lines

I did not follow the introduction of the reserved_opts field, but writing this comment in the API only is weak.
Why can't the rte_security API enforce reserved_opts == 0 (like in rte_security_session_create)?

Quoted 4 lines

This was discussed here.
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
rte_security_ipsec_sa_options is being used at multiple places as listed below in abiignore. Checking a particular field in each of the API does not make sense to me.

It's strange to me that a user may pass this structure as input in multiple functions.
But if it's how the security lib works, ok.

Quoted 55 lines
Quoted 9 lines
Quoted 6 lines
Change-Id I6f66f0b5a659550976a32629130594070cb16cb1

^^^
Internal tag, please remove.

Yes, missed that will remove.

Quoted 39 lines
Quoted 11 lines
---
 devtools/libabigail.abignore | 14 ++++++++++++++
 lib/security/rte_security.h  | 12 +++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +0 -0
index 4b676f317d..3bd39042e8 100644

devtools/libabigail.abignore line 15

Quoted 5 lines
devtools/libabigail.abignore +2 -0
@@ -11,3 +11,17 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of

rte_security_ipsec_sa_options

devtools/libabigail.abignore

Quoted 8 lines
devtools/libabigail.abignore +8 -0
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Now, about the suppression rule, I don't understand the intention of those 3 rules.

I would simply suppress modifications (after reserved_opts) to the rte_security_ipsec_sa_options struct.
Like:

Quoted 6 lines

; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
[suppress_type]
name = rte_security_ipsec_sa_options has_data_member_inserted_between = {offset_of(reserved_opts), end}

Quoted 3 lines

I tried this in the first place but abi check was complaining in other structures which included rte_security_ipsec_sa_options. So I had to add suppression for those as well. Can you try at your end?

I tried before suggesting, and it works with a single rule on this structure.

I'm using libabigail current master, which version are you using so I can try with the same?

Signature · 1 line
David Marchand
#166 lore raw

RE: [EXT] Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Quoted 41 lines
Quoted 11 lines
Quoted 11 lines

devtools/libabigail.abignore line 15

Quoted 10 lines
devtools/libabigail.abignore +2 -0
index 4b676f317d..3bd39042e8 100644
@@ -11,3 +11,17 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of

rte_security_ipsec_sa_options

Quoted 4 lines
Quoted 4 lines

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts),

end}

Quoted 18 lines
Quoted 18 lines

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Now, about the suppression rule, I don't understand the intention of those 3 rules.

I would simply suppress modifications (after reserved_opts) to the rte_security_ipsec_sa_options struct.
Like:

Quoted 7 lines
Quoted 6 lines

; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
[suppress_type]
name = rte_security_ipsec_sa_options has_data_member_inserted_between = {offset_of(reserved_opts), end}

I tried this in the first place but abi check was complaining in other structures

Quoted 9 lines

which included

Quoted 2 lines

rte_security_ipsec_sa_options. So I had to add suppression for those as well. Can you try at your end?

I tried before suggesting, and it works with a single rule on this structure.

I'm using libabigail current master, which version are you using so I can try with the same?

I am currently using 1.6 version. I will try with latest version.

$ abidiff --version
abidiff: 1.6.0

and I get following issue after removing the last two suppress rules. Functions changes summary: 0 Removed, 1 Changed (8 filtered out), 0 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

[C]'function const rte_security_capability* rte_security_capabilities_get(rte_security_ctx*)' at rte_security.c:158:1 has some indirect sub-type changes:
return type changed:
in pointed to type 'const rte_security_capability':
in unqualified underlying type 'struct rte_security_capability' at rte_security.h:808:1:
type size hasn't changed
1 data member change:

parameter 1 of type 'rte_security_ctx*' has sub-type changes:
in pointed to type 'struct rte_security_ctx' at rte_security.h:72:1:
type size hasn't changed
1 data member change:
type of 'const rte_security_ops* rte_security_ctx::ops' changed:
in pointed to type 'const rte_security_ops':
in unqualified underlying type 'struct rte_security_ops' at rte_security_driver.h:140:1:
type size hasn't changed
1 data member changes (2 filtered):
type of 'security_session_create_t rte_security_ops::session_create' changed:
underlying type 'int (void*, rte_security_session_conf*, rte_security_session*, rte_mempool*)*' changed:
in pointed to type 'function type int (void*, rte_security_session_conf*, rte_security_session*, rte_mempool*)':
parameter 2 of type 'rte_security_session_conf*' has sub-type changes:
in pointed to type 'struct rte_security_session_conf' at rte_security.h:502:1:
type size hasn't changed
1 data member change:

#167 lore raw

RE: [EXT] Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Hi David,

Quoted 46 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

devtools/libabigail.abignore line 15

Quoted 10 lines
devtools/libabigail.abignore +2 -0
index 4b676f317d..3bd39042e8 100644
@@ -11,3 +11,17 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of

rte_security_ipsec_sa_options

Quoted 28 lines
Quoted 4 lines
Quoted 4 lines

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+[suppress_type]
+       name = rte_ipsec_sa_prm
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts),

end}

Quoted 23 lines
Quoted 23 lines

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_capability
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

devtools/libabigail.abignore

Quoted 4 lines
devtools/libabigail.abignore +4 -0
+
+[suppress_type]
+       name = rte_security_session_conf
+       has_data_member_inserted_between = {offset_of(reserved_opts),

(offset_of(reserved_opts) + 18)}

Now, about the suppression rule, I don't understand the intention of those 3 rules.

I would simply suppress modifications (after reserved_opts) to the rte_security_ipsec_sa_options struct.
Like:

; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
[suppress_type]
name = rte_security_ipsec_sa_options has_data_member_inserted_between = {offset_of(reserved_opts),

end}

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

I tried this in the first place but abi check was complaining in other structures

which included

Quoted 2 lines

rte_security_ipsec_sa_options. So I had to add suppression for those as well. Can you try at your end?

Quoted 9 lines
Quoted 5 lines

I tried before suggesting, and it works with a single rule on this structure.

I'm using libabigail current master, which version are you using so I can try with the same?

I am currently using 1.6 version. I will try with latest version.

$ abidiff --version
abidiff: 1.6.0

It seems the latest version 2.0 is not compatible with Ubuntu 20.04. It is not getting compiled.
Can you check with 1.6.0 version?

#168 lore raw

Re: [EXT] Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Quoted 10 lines · Akhil Goyal
Quoted 10 lines
Quoted 10 lines
Quoted 1 line

I tried this in the first place but abi check was complaining in other structures

which included

Quoted 2 lines

rte_security_ipsec_sa_options. So I had to add suppression for those as well. Can you try at your end?

I tried before suggesting, and it works with a single rule on this structure.

I'm using libabigail current master, which version are you using so I can try with the same?

Quoted 6 lines
Quoted 4 lines

I am currently using 1.6 version. I will try with latest version.

$ abidiff --version
abidiff: 1.6.0

It seems the latest version 2.0 is not compatible with Ubuntu 20.04. It is not getting compiled.

I am using the HEAD of libabigail master branch, so maybe something got fixed between 2.0 and the current master.

Quoted 1 line

Can you check with 1.6.0 version?

I tried 1.6 in GHA (Ubuntu 18.04), and I can reproduce the warnings you reported.

But in the end, we use 1.8 in GHA:
https://git.dpdk.org/dpdk/tree/.github/workflows/build.yml#n23

The simplest rule (on rte_security_ipsec_sa_options only) passes fine with this version of libabigail:
https://github.com/david-marchand/dpdk/runs/5109221298?check_suite_focus=true

Signature · 1 line
David Marchand
#169 lore raw

RE: [EXT] Re: [PATCH v4 3/3] security: add IPsec option for IP reassembly

Hi David,

Quoted 29 lines · Akhil Goyal
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

I tried this in the first place but abi check was complaining in other

structures

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

which included

Quoted 1 line

rte_security_ipsec_sa_options. So I had to add suppression for those as

well.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Can you try at your end?

I tried before suggesting, and it works with a single rule on this structure.

I'm using libabigail current master, which version are you using so I can try with the same?

Quoted 6 lines
Quoted 4 lines

I am currently using 1.6 version. I will try with latest version.

$ abidiff --version
abidiff: 1.6.0

It seems the latest version 2.0 is not compatible with Ubuntu 20.04. It is not getting compiled.

I am using the HEAD of libabigail master branch, so maybe something got fixed between 2.0 and the current master.

Quoted 1 line

Can you check with 1.6.0 version?

I tried 1.6 in GHA (Ubuntu 18.04), and I can reproduce the warnings you reported.

Quoted 6 lines

But in the end, we use 1.8 in GHA:
https://git.dpdk.org/dpdk/tree/.github/workflows/build.yml#n23

The simplest rule (on rte_security_ipsec_sa_options only) passes fine with this version of libabigail:
https://github.com/david-marchand/dpdk/runs/5109221298?check_suite_focus=true

Thanks for trying it out. I will remove the last two rules and send next version.

#170 lore raw

v5 cover ethdev: introduce IP reassembly offload

In reply to Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.[2][3]

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/
[2]: APP: http://patches.dpdk.org/project/dpdk/list/?series=21284
[3]: PMD: http://patches.dpdk.org/project/dpdk/list/?series=21285
Newer versions of app and PMD will be sent once library changes are
acked.

Changes in v5:
- updated Doxygen comments.(Ferruh)
- Added release notes.
- updated libabigail suppress rules.(David)

Changes in v4:
- removed rte_eth_dev_info update for capability (Ferruh)
- removed Rx offload flag (Ferruh)
- added capability_get() (Ferruh)
- moved dynfield and dynflag namedefines in rte_mbuf_dyn.h (Ferruh)

changes in v3:
- incorporated comments from Andrew and Stephen Hemminger

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Akhil Goyal (3):
ethdev: introduce IP reassembly offload
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

 devtools/libabigail.abignore           |   5 +
 doc/guides/nics/features.rst           |  13 +++
 doc/guides/nics/features/default.ini   |   1 +
 doc/guides/rel_notes/release_22_03.rst |   6 ++
 lib/ethdev/ethdev_driver.h             |  63 +++++++++++++
 lib/ethdev/rte_ethdev.c                | 124 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 126 +++++++++++++++++++++++++
 lib/ethdev/version.map                 |   6 ++
 lib/mbuf/rte_mbuf_dyn.h                |   9 ++
 lib/security/rte_security.h            |  15 ++-
 10 files changed, 367 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#171 lore raw

PATCH v5 1/3 ethdev: introduce IP reassembly offload

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

---
 doc/guides/nics/features.rst           |  13 ++++
 doc/guides/nics/features/default.ini   |   1 +
 doc/guides/rel_notes/release_22_03.rst |   6 ++
 lib/ethdev/ethdev_driver.h             |  55 ++++++++++++++
 lib/ethdev/rte_ethdev.c                |  96 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 100 +++++++++++++++++++++++++
 lib/ethdev/version.map                 |   5 ++
 7 files changed, 276 insertions(+)
doc/guides/nics/features.rst +13 -0
index 27be2d2576..e6112e16f4 100644
@@ -602,6 +602,19 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[provides] eth_dev_ops**: ``ip_reassembly_capability_get``,
+  ``ip_reassembly_conf_get``, ``ip_reassembly_conf_set``.
+* **[related]    API**: ``rte_eth_ip_reassembly_capability_get()``,
+  ``rte_eth_ip_reassembly_conf_get()``, ``rte_eth_ip_reassembly_conf_set()``.
+
+
 .. _nic_features_shared_rx_queue:
 
 Shared Rx queue
doc/guides/nics/features/default.ini +1 -0
index c96a52b58e..22750dfacb 100644
@@ -52,6 +52,7 @@ Timestamp offload    =
 MACsec offload       =
 Inner L3 checksum    =
 Inner L4 checksum    =
+IP reassembly        =
 Packet type parsing  =
 Timesync             =
 Rx descriptor status =
doc/guides/rel_notes/release_22_03.rst +6 -0
index 746f50e84f..03ec8d6faa 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added IP reassembly Ethernet offload API, to get and set config.**
+
+  Added IP reassembly offload APIs which provide functions to query IP
+  reassembly capabilities, to set configuration and to get currently set
+  reassembly configuration.
+
 * **Updated Cisco enic driver.**
 
   * Added rte_flow support for matching GENEVE packets.
lib/ethdev/ethdev_driver.h +55 -0

67 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +96 -0

102 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +100 -0

106 lines not on this page · raw message

lib/ethdev/version.map +5 -0
index c2fb0669a4..e22c102818 100644
@@ -256,6 +256,11 @@ EXPERIMENTAL {
 	rte_flow_flex_item_create;
 	rte_flow_flex_item_release;
 	rte_flow_pick_transfer_proxy;
+
+	# added in 22.03
+	rte_eth_ip_reassembly_capability_get;
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
#172 lore raw

PATCH v5 2/3 ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

---
 lib/ethdev/ethdev_driver.h |  8 ++++++++
 lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 28 +++++++++++++++++++++++++++-
 lib/ethdev/version.map     |  1 +
 lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
 5 files changed, 73 insertions(+), 1 deletion(-)
lib/ethdev/ethdev_driver.h +8 -0
index 4acf75781d..81be991191 100644
@@ -1707,6 +1707,14 @@ int
 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
 				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag);
+
 
 /*
  * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +28 -0
index 6b37cffd07..a707f395c4 100644
@@ -6570,6 +6570,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
 }
 
+int
+rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME,
+		.size = sizeof(rte_eth_ip_reassembly_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reassembly_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reassembly_dynflag = {
+		.name = RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME,
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;
+
+	offset = rte_mbuf_dynflag_register(&ip_reassembly_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +27 -1
index dd416fda37..b2c41ceb9a 100644
@@ -5285,6 +5285,12 @@ int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
  * configuration. The use of this API is mandatory to enable this feature and
  * should be called before rte_eth_dev_start().
  *
+ * In datapath, PMD cannot guarantee that IP reassembly is always successful.
+ * Hence, PMD shall register mbuf dynamic field and dynamic flag using
+ * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
+ * If dynfield is not successfully registered, error will be returned and
+ * IP reassembly offload cannnot be used.
+ *
  * @param port_id
  *   The port identifier of the device.
  * @param conf
@@ -5294,13 +5300,33 @@ int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
  *   - (-ENODEV) if *port_id* invalid.
  *   - (-EIO) if device is removed.
  *   - (-EINVAL) if device is not configured or if device is already started or
- *               if *conf* passed is NULL.
+ *               if *conf* passed is NULL or if mbuf dynfield is not registered
+ *               successfully by the PMD.
  *   - (0) on success.
  */
 __rte_experimental
 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		const struct rte_eth_ip_reassembly_params *conf);
 
+/**
+ * In case of IP reassembly offload failure, packet will be updated with
+ * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
+ * will be returned without alteration.
+ * The application can retrieve the attached fragments using mbuf dynamic field
+ * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reassembly_dynfield_t;
+
 
 #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index e22c102818..b5499cd9b5 100644
@@ -284,6 +284,7 @@ INTERNAL {
 	rte_eth_hairpin_queue_peer_bind;
 	rte_eth_hairpin_queue_peer_unbind;
 	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reassembly_dynfield_register;
 	rte_eth_representor_id_get;
 	rte_eth_switch_domain_alloc;
 	rte_eth_switch_domain_free;
lib/mbuf/rte_mbuf_dyn.h +9 -0
index 29abe8da53..1c948e996e 100644
@@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);
  */
 int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t *tx_flag);
 
+/**
+ * For the PMDs which support IP reassembly of packets, PMD will updated the
+ * packet with RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME to denote that
+ * IP reassembly is incomplete and application can retrieve the packets back
+ * using RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
+ */
+#define RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME "rte_dynfield_ip_reassembly"
+#define RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME "rte_dynflag_ip_reassembly_incomplete"
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.25.1
#173 lore raw

PATCH v5 3/3 security: add IPsec option for IP reassembly

In reply to Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound IP packets.

---
 devtools/libabigail.abignore |  5 +++++
 lib/security/rte_security.h  | 15 ++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +5 -0
index 4b676f317d..5be41b8805 100644
@@ -11,3 +11,8 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
lib/security/rte_security.h +14 -1
index 1228b6c8b1..b080d10c2c 100644
@@ -264,6 +264,19 @@ struct rte_security_ipsec_sa_options {
 	 */
 	uint32_t l4_csum_enable : 1;
 
+	/** Enable IP reassembly on inline inbound packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if user has successfully set IP reassembly config params
+	 *      using rte_eth_ip_reassembly_conf_set() for the inline Ethernet
+	 *      device. PMD need to register mbuf dynamic fields using
+	 *      rte_eth_ip_reassembly_dynfield_register() and security session
+	 *      creation would fail if dynfield is not registered successfully.
+	 * * 0: Disable IP reassembly of packets (default).
+	 */
+	uint32_t ip_reassembly_en : 1;
+
 	/** Reserved bit fields for future extension
 	 *
 	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +284,7 @@ struct rte_security_ipsec_sa_options {
 	 *
 	 * Note: Reduce number of bits in reserved_opts for every new option.
 	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
 };
 
 /** IPSec security association direction */
Signature · 1 line
2.25.1
#174 lore raw

v6 cover ethdev: introduce IP reassembly offload

In reply to Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.[2][3]

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/
[2]: APP: http://patches.dpdk.org/project/dpdk/list/?series=21284
[3]: PMD: http://patches.dpdk.org/project/dpdk/list/?series=21285
Newer versions of app and PMD will be sent once library changes are
acked.

Changes in v6:
- fix warnings.

Changes in v5:
- updated Doxygen comments.(Ferruh)
- Added release notes.
- updated libabigail suppress rules.(David)

Changes in v4:
- removed rte_eth_dev_info update for capability (Ferruh)
- removed Rx offload flag (Ferruh)
- added capability_get() (Ferruh)
- moved dynfield and dynflag namedefines in rte_mbuf_dyn.h (Ferruh)

changes in v3:
- incorporated comments from Andrew and Stephen Hemminger

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Akhil Goyal (3):
ethdev: introduce IP reassembly offload
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

 devtools/libabigail.abignore           |   5 +
 doc/guides/nics/features.rst           |  13 +++
 doc/guides/nics/features/default.ini   |   1 +
 doc/guides/rel_notes/release_22_03.rst |   6 ++
 lib/ethdev/ethdev_driver.h             |  63 +++++++++++++
 lib/ethdev/rte_ethdev.c                | 124 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 126 +++++++++++++++++++++++++
 lib/ethdev/version.map                 |   6 ++
 lib/mbuf/rte_mbuf_dyn.h                |   9 ++
 lib/security/rte_security.h            |  15 ++-
 10 files changed, 367 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#175 lore raw

PATCH v6 1/3 ethdev: introduce IP reassembly offload

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

---
 doc/guides/nics/features.rst           |  13 ++++
 doc/guides/nics/features/default.ini   |   1 +
 doc/guides/rel_notes/release_22_03.rst |   6 ++
 lib/ethdev/ethdev_driver.h             |  55 ++++++++++++++
 lib/ethdev/rte_ethdev.c                |  96 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 100 +++++++++++++++++++++++++
 lib/ethdev/version.map                 |   5 ++
 7 files changed, 276 insertions(+)
doc/guides/nics/features.rst +13 -0
index 27be2d2576..e6112e16f4 100644
@@ -602,6 +602,19 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_ip_reassembly:
+
+IP reassembly
+-------------
+
+Supports IP reassembly in hardware.
+
+* **[provides] eth_dev_ops**: ``ip_reassembly_capability_get``,
+  ``ip_reassembly_conf_get``, ``ip_reassembly_conf_set``.
+* **[related]    API**: ``rte_eth_ip_reassembly_capability_get()``,
+  ``rte_eth_ip_reassembly_conf_get()``, ``rte_eth_ip_reassembly_conf_set()``.
+
+
 .. _nic_features_shared_rx_queue:
 
 Shared Rx queue
doc/guides/nics/features/default.ini +1 -0
index c96a52b58e..22750dfacb 100644
@@ -52,6 +52,7 @@ Timestamp offload    =
 MACsec offload       =
 Inner L3 checksum    =
 Inner L4 checksum    =
+IP reassembly        =
 Packet type parsing  =
 Timesync             =
 Rx descriptor status =
doc/guides/rel_notes/release_22_03.rst +6 -0
index 746f50e84f..03ec8d6faa 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added IP reassembly Ethernet offload API, to get and set config.**
+
+  Added IP reassembly offload APIs which provide functions to query IP
+  reassembly capabilities, to set configuration and to get currently set
+  reassembly configuration.
+
 * **Updated Cisco enic driver.**
 
   * Added rte_flow support for matching GENEVE packets.
lib/ethdev/ethdev_driver.h +55 -0

67 lines not on this page · raw message

lib/ethdev/rte_ethdev.c +96 -0

102 lines not on this page · raw message

lib/ethdev/rte_ethdev.h +100 -0

106 lines not on this page · raw message

lib/ethdev/version.map +5 -0
index c2fb0669a4..e22c102818 100644
@@ -256,6 +256,11 @@ EXPERIMENTAL {
 	rte_flow_flex_item_create;
 	rte_flow_flex_item_release;
 	rte_flow_pick_transfer_proxy;
+
+	# added in 22.03
+	rte_eth_ip_reassembly_capability_get;
+	rte_eth_ip_reassembly_conf_get;
+	rte_eth_ip_reassembly_conf_set;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
Reviewed-by on v6 1/3
#176 lore raw

Re: [PATCH v6 1/3] ethdev: introduce IP reassembly offload

Quoted 19 lines · Akhil Goyal

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

Quoted 6 lines

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

#177 lore raw

Re: [PATCH v6 1/3] ethdev: introduce IP reassembly offload

In reply to Akhil Goyal
Quoted 19 lines · Akhil Goyal

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

Quoted 6 lines

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

Just one nit below, sorry that I'm so late

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5208

Quoted 12 lines
lib/ethdev/rte_ethdev.h +4 -0
index 147cc1ced3..0215f9d854 100644
@@ -5202,6 +5202,106 @@ int rte_eth_representor_info_get(uint16_t port_id,
  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
 
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))

Doxygen style comments shoud be above: /**

#178 lore raw

Re: [PATCH v6 1/3] ethdev: introduce IP reassembly offload

Quoted 29 lines · Andrew Rybchenko
Quoted 19 lines · Akhil Goyal

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

Quoted 6 lines

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

Just one nit below, sorry that I'm so late

Quoted 13 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5208

Quoted 11 lines
lib/ethdev/rte_ethdev.h +0 -0
index 147cc1ced3..0215f9d854 100644
@@ -5202,6 +5202,106 @@ int rte_eth_representor_info_get(uint16_t port_id,

  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);

lib/ethdev/rte_ethdev.h +4 -0
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))

Doxygen style comments shoud be above: /**

ack. Let me fix that in next-net.

#179 lore raw

Re: [PATCH v6 1/3] ethdev: introduce IP reassembly offload

Quoted 44 lines · Ferruh Yigit
Quoted 29 lines · Andrew Rybchenko
Quoted 19 lines · Akhil Goyal

IP Reassembly is a costly operation if it is done in software. The operation becomes even more costlier if IP fragments are encrypted. However, if it is offloaded to HW, it can considerably save application cycles.

Hence, a new offload feature is exposed in eth_dev ops for devices which can attempt IP reassembly of packets in hardware.
- rte_eth_ip_reassembly_capability_get() - to get the maximum values of reassembly configuration which can be set.
- rte_eth_ip_reassembly_conf_set() - to set IP reassembly configuration and to enable the feature in the PMD (to be called before rte_eth_dev_start()).
- rte_eth_ip_reassembly_conf_get() - to get the current configuration set in PMD.

Now when the offload is enabled using rte_eth_ip_reassembly_conf_set(), the resulting reassembled IP packet would be a typical segmented mbuf in case of success.

Quoted 6 lines

And if reassembly of IP fragments is failed or is incomplete (if fragments do not come before the reass_timeout, overlap, etc), the mbuf dynamic flags can be updated by the PMD. This is updated in a subsequent patch.

Just one nit below, sorry that I'm so late

Quoted 13 lines

lib/ethdev/rte_ethdev.h int rte_eth_representor_info_get(uint16_t port_id, · line 5208

Quoted 11 lines
lib/ethdev/rte_ethdev.h +0 -0
index 147cc1ced3..0215f9d854 100644
@@ -5202,6 +5202,106 @@ int rte_eth_representor_info_get(uint16_t port_id,

  __rte_experimental
  int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);

lib/ethdev/rte_ethdev.h +4 -0
+/* Flag to offload IP reassembly for IPv4 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
+/* Flag to offload IP reassembly for IPv6 packets. */
+#define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))

Doxygen style comments shoud be above: /**

Quoted 1 line

ack. Let me fix that in next-net.

done, please verify in next-net

#180 lore raw

PATCH v6 2/3 ethdev: add mbuf dynfield for incomplete IP reassembly

In reply to Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

---
 lib/ethdev/ethdev_driver.h |  8 ++++++++
 lib/ethdev/rte_ethdev.c    | 28 ++++++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h    | 28 +++++++++++++++++++++++++++-
 lib/ethdev/version.map     |  1 +
 lib/mbuf/rte_mbuf_dyn.h    |  9 +++++++++
 5 files changed, 73 insertions(+), 1 deletion(-)
lib/ethdev/ethdev_driver.h +8 -0
index 4acf75781d..81be991191 100644
@@ -1707,6 +1707,14 @@ int
 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
 				  uint32_t direction);
 
+/**
+ * @internal
+ * Register mbuf dynamic field and flag for IP reassembly incomplete case.
+ */
+__rte_internal
+int
+rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag);
+
 
 /*
  * Legacy ethdev API used internally by drivers.
lib/ethdev/rte_ethdev.c +28 -0
index 6b37cffd07..a707f395c4 100644
@@ -6570,6 +6570,34 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
 }
 
+int
+rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag_offset)
+{
+	static const struct rte_mbuf_dynfield field_desc = {
+		.name = RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME,
+		.size = sizeof(rte_eth_ip_reassembly_dynfield_t),
+		.align = __alignof__(rte_eth_ip_reassembly_dynfield_t),
+	};
+	static const struct rte_mbuf_dynflag ip_reassembly_dynflag = {
+		.name = RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME,
+	};
+	int offset;
+
+	offset = rte_mbuf_dynfield_register(&field_desc);
+	if (offset < 0)
+		return -1;
+	if (field_offset != NULL)
+		*field_offset = offset;
+
+	offset = rte_mbuf_dynflag_register(&ip_reassembly_dynflag);
+	if (offset < 0)
+		return -1;
+	if (flag_offset != NULL)
+		*flag_offset = offset;
+
+	return 0;
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
lib/ethdev/rte_ethdev.h +27 -1
index 0215f9d854..eba9c2f402 100644
@@ -5285,6 +5285,12 @@ int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
  * configuration. The use of this API is mandatory to enable this feature and
  * should be called before rte_eth_dev_start().
  *
+ * In datapath, PMD cannot guarantee that IP reassembly is always successful.
+ * Hence, PMD shall register mbuf dynamic field and dynamic flag using
+ * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
+ * If dynfield is not successfully registered, error will be returned and
+ * IP reassembly offload cannot be used.
+ *
  * @param port_id
  *   The port identifier of the device.
  * @param conf
@@ -5294,13 +5300,33 @@ int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
  *   - (-ENODEV) if *port_id* invalid.
  *   - (-EIO) if device is removed.
  *   - (-EINVAL) if device is not configured or if device is already started or
- *               if *conf* passed is NULL.
+ *               if *conf* passed is NULL or if mbuf dynfield is not registered
+ *               successfully by the PMD.
  *   - (0) on success.
  */
 __rte_experimental
 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		const struct rte_eth_ip_reassembly_params *conf);
 
+/**
+ * In case of IP reassembly offload failure, packet will be updated with
+ * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
+ * will be returned without alteration.
+ * The application can retrieve the attached fragments using mbuf dynamic field
+ * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
+ */
+typedef struct {
+	/**
+	 * Next fragment packet. Application should fetch dynamic field of
+	 * each fragment until a NULL is received and nb_frags is 0.
+	 */
+	struct rte_mbuf *next_frag;
+	/** Time spent(in ms) by HW in waiting for further fragments. */
+	uint16_t time_spent;
+	/** Number of more fragments attached in mbuf dynamic fields. */
+	uint16_t nb_frags;
+} rte_eth_ip_reassembly_dynfield_t;
+
 
 #include <rte_ethdev_core.h>
 
lib/ethdev/version.map +1 -0
index e22c102818..b5499cd9b5 100644
@@ -284,6 +284,7 @@ INTERNAL {
 	rte_eth_hairpin_queue_peer_bind;
 	rte_eth_hairpin_queue_peer_unbind;
 	rte_eth_hairpin_queue_peer_update;
+	rte_eth_ip_reassembly_dynfield_register;
 	rte_eth_representor_id_get;
 	rte_eth_switch_domain_alloc;
 	rte_eth_switch_domain_free;
lib/mbuf/rte_mbuf_dyn.h +9 -0
index 29abe8da53..1c948e996e 100644
@@ -320,6 +320,15 @@ int rte_mbuf_dyn_rx_timestamp_register(int *field_offset, uint64_t *rx_flag);
  */
 int rte_mbuf_dyn_tx_timestamp_register(int *field_offset, uint64_t *tx_flag);
 
+/**
+ * For the PMDs which support IP reassembly of packets, PMD will updated the
+ * packet with RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME to denote that
+ * IP reassembly is incomplete and application can retrieve the packets back
+ * using RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
+ */
+#define RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME "rte_dynfield_ip_reassembly"
+#define RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME "rte_dynflag_ip_reassembly_incomplete"
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.25.1
Reviewed-by on v6 2/3
#181 lore raw

Re: [PATCH v6 2/3] ethdev: add mbuf dynfield for incomplete IP reassembly

Quoted 11 lines · Akhil Goyal

Hardware IP reassembly may be incomplete for multiple reasons like reassembly timeout reached, duplicate fragments, etc. To save application cycles to process these packets again, a new mbuf dynflag is added to show that the mbuf received is not reassembled properly.

Now if this dynflag is set, application can retrieve corresponding chain of mbufs using mbuf dynfield set by the PMD. Now, it will be up to application to either drop those fragments or wait for more time.

#182 lore raw

PATCH v6 3/3 security: add IPsec option for IP reassembly

In reply to Akhil Goyal

A new option is added in IPsec to enable and attempt reassembly of inbound IP packets.

---
 devtools/libabigail.abignore |  5 +++++
 lib/security/rte_security.h  | 15 ++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
devtools/libabigail.abignore +5 -0
index 4b676f317d..5be41b8805 100644
@@ -11,3 +11,8 @@
 ; Ignore generated PMD information strings
 [suppress_variable]
         name_regexp = _pmd_info$
+
+; Ignore fields inserted in place of reserved_opts of rte_security_ipsec_sa_options
+[suppress_type]
+       name = rte_security_ipsec_sa_options
+       has_data_member_inserted_between = {offset_of(reserved_opts), end}
lib/security/rte_security.h +14 -1
index 1228b6c8b1..b080d10c2c 100644
@@ -264,6 +264,19 @@ struct rte_security_ipsec_sa_options {
 	 */
 	uint32_t l4_csum_enable : 1;
 
+	/** Enable IP reassembly on inline inbound packets.
+	 *
+	 * * 1: Enable driver to try reassembly of encrypted IP packets for
+	 *      this SA, if supported by the driver. This feature will work
+	 *      only if user has successfully set IP reassembly config params
+	 *      using rte_eth_ip_reassembly_conf_set() for the inline Ethernet
+	 *      device. PMD need to register mbuf dynamic fields using
+	 *      rte_eth_ip_reassembly_dynfield_register() and security session
+	 *      creation would fail if dynfield is not registered successfully.
+	 * * 0: Disable IP reassembly of packets (default).
+	 */
+	uint32_t ip_reassembly_en : 1;
+
 	/** Reserved bit fields for future extension
 	 *
 	 * User should ensure reserved_opts is cleared as it may change in
@@ -271,7 +284,7 @@ struct rte_security_ipsec_sa_options {
 	 *
 	 * Note: Reduce number of bits in reserved_opts for every new option.
 	 */
-	uint32_t reserved_opts : 18;
+	uint32_t reserved_opts : 17;
 };
 
 /** IPSec security association direction */
Signature · 1 line
2.25.1
#183 lore raw

Re: [PATCH v6 0/3] ethdev: introduce IP reassembly offload

In reply to Akhil Goyal
Quoted 47 lines · Akhil Goyal

As discussed in the RFC[1] sent in 21.11, a new offload is introduced in ethdev for IP reassembly.

This patchset add the IP reassembly RX offload.
Currently, the offload is tested along with inline IPsec processing. It can also be updated as a standalone offload without IPsec, if there are some hardware available to test it.
The patchset is tested on cnxk platform. The driver implementation and a test app are added as separate patchsets.[2][3]

[1]: http://patches.dpdk.org/project/dpdk/patch/[email protected]/
[2]: APP: http://patches.dpdk.org/project/dpdk/list/?series=21284
[3]: PMD: http://patches.dpdk.org/project/dpdk/list/?series=21285
Newer versions of app and PMD will be sent once library changes are
acked.

Changes in v6:
- fix warnings.

Changes in v5:
- updated Doxygen comments.(Ferruh)
- Added release notes.
- updated libabigail suppress rules.(David)

Changes in v4:
- removed rte_eth_dev_info update for capability (Ferruh)
- removed Rx offload flag (Ferruh)
- added capability_get() (Ferruh)
- moved dynfield and dynflag namedefines in rte_mbuf_dyn.h (Ferruh)

changes in v3:
- incorporated comments from Andrew and Stephen Hemminger

changes in v2:
- added abi ignore exceptions for modifications in reserved fields. Added a crude way to subside the rte_security and rte_ipsec ABI issue. Please suggest a better way.
- incorporated Konstantin's comment for extra checks in new API introduced.
- converted static mbuf ol_flag to mbuf dynflag (Konstantin)
- added a get API for reassembly configuration (Konstantin)
- Fixed checkpatch issues.
- Dynfield is NOT split into 2 parts as it would cause an extra fetch in case of IP reassembly failure.
- Application patches are split into a separate series.

Quoted 5 lines

Akhil Goyal (3):
ethdev: introduce IP reassembly offload
ethdev: add mbuf dynfield for incomplete IP reassembly
security: add IPsec option for IP reassembly

Series applied to dpdk-next-net/main, thanks.