diff mbox series

[3/5] net/cnxk: support IP reassembly mbuf dynfield

Message ID 20220103160149.1715058-4-gakhil@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers show
Series net/cnxk: support IP reassembly offload | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Akhil Goyal Jan. 3, 2022, 4:01 p.m. UTC
From: Vidya Sagar Velumuri <vvelumuri@marvell.com>

Register the dynamic field for IPsec reassembly.
Attach the fragments using the dynamic field in case of incomplete
reassembly

Signed-off-by: Vidya Sagar Velumuri <vvelumuri@marvell.com>
---
 drivers/net/cnxk/cn10k_ethdev_sec.c |  3 +++
 drivers/net/cnxk/cn10k_rx.h         | 38 +++++++++++++++++++++++------
 2 files changed, 33 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/cnxk/cn10k_ethdev_sec.c b/drivers/net/cnxk/cn10k_ethdev_sec.c
index 235c16840e..f20a111cd9 100644
--- a/drivers/net/cnxk/cn10k_ethdev_sec.c
+++ b/drivers/net/cnxk/cn10k_ethdev_sec.c
@@ -249,6 +249,9 @@  cn10k_eth_sec_session_create(void *device,
 	if (rte_security_dynfield_register() < 0)
 		return -ENOTSUP;
 
+	if (rte_eth_ip_reass_dynfield_register() < 0)
+		return -rte_errno;
+
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		roc_nix_inl_cb_register(cn10k_eth_sec_sso_work_cb, NULL);
 
diff --git a/drivers/net/cnxk/cn10k_rx.h b/drivers/net/cnxk/cn10k_rx.h
index 5c415634a9..0ba60ed22f 100644
--- a/drivers/net/cnxk/cn10k_rx.h
+++ b/drivers/net/cnxk/cn10k_rx.h
@@ -94,7 +94,7 @@  nix_sec_attach_frags(const struct cpt_parse_hdr_s *hdr,
 	uint32_t offset = hdr->w2.fi_offset;
 	union nix_rx_parse_u *frag_rx;
 	struct cpt_frag_info_s *finfo;
-	struct rte_mbuf *head, *mbuf;
+	struct rte_mbuf *head, *mbuf, *mbuf_prev;
 	uint64_t *frag_ptr;
 	uint16_t frag_size;
 	uint16_t rlen;
@@ -115,10 +115,15 @@  nix_sec_attach_frags(const struct cpt_parse_hdr_s *hdr,
 	mbuf = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
 	mbuf->data_len = frag_size;
 	mbuf->pkt_len = frag_size;
+	mbuf->ol_flags |= RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE;
 	head = mbuf;
+	mbuf_prev = mbuf;
 	/* Update dynamic field with userdata */
 	*rte_security_dynfield(mbuf) = (uint64_t)inb_priv->userdata;
 
+	rte_eth_ip_reass_dynfield(head)->nb_frags = hdr->w0.num_frags - 1;
+	rte_eth_ip_reass_dynfield(head)->next_frag = NULL;
+
 	/* Frag-1: */
 	if (hdr->w0.num_frags > 1) {
 		wqe = (uint64_t *)(rte_be_to_cpu_64(hdr->frag1_wqe_ptr));
@@ -128,13 +133,19 @@  nix_sec_attach_frags(const struct cpt_parse_hdr_s *hdr,
 		frag_size = rlen + frag_rx->lcptr - frag_rx->laptr;
 		frag_rx->pkt_lenm1 = frag_size - 1;
 
-		mbuf->next = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
-		mbuf = mbuf->next;
+		mbuf = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
 		mbuf->data_len = frag_size;
 		mbuf->pkt_len = frag_size;
+		mbuf->ol_flags |= RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE;
 
 		/* Update dynamic field with userdata */
 		*rte_security_dynfield(mbuf) = (uint64_t)inb_priv->userdata;
+
+		rte_eth_ip_reass_dynfield(mbuf)->nb_frags =
+			hdr->w0.num_frags - 2;
+		rte_eth_ip_reass_dynfield(mbuf)->next_frag = NULL;
+		rte_eth_ip_reass_dynfield(mbuf_prev)->next_frag = mbuf;
+		mbuf_prev = mbuf;
 	}
 
 	/* Frag-2: */
@@ -147,13 +158,19 @@  nix_sec_attach_frags(const struct cpt_parse_hdr_s *hdr,
 		frag_size = rlen + frag_rx->lcptr - frag_rx->laptr;
 		frag_rx->pkt_lenm1 = frag_size - 1;
 
-		mbuf->next = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
-		mbuf = mbuf->next;
+		mbuf = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
 		mbuf->data_len = frag_size;
 		mbuf->pkt_len = frag_size;
+		mbuf->ol_flags |= RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE;
 
 		/* Update dynamic field with userdata */
 		*rte_security_dynfield(mbuf) = (uint64_t)inb_priv->userdata;
+
+		rte_eth_ip_reass_dynfield(mbuf)->nb_frags =
+			hdr->w0.num_frags - 3;
+		rte_eth_ip_reass_dynfield(mbuf)->next_frag = NULL;
+		rte_eth_ip_reass_dynfield(mbuf_prev)->next_frag = mbuf;
+		mbuf_prev = mbuf;
 	}
 
 	/* Frag-3: */
@@ -165,16 +182,21 @@  nix_sec_attach_frags(const struct cpt_parse_hdr_s *hdr,
 		frag_size = rlen + frag_rx->lcptr - frag_rx->laptr;
 		frag_rx->pkt_lenm1 = frag_size - 1;
 
-		mbuf->next = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
-		mbuf = mbuf->next;
+		mbuf = (struct rte_mbuf *)(wqe - sizeof(struct rte_mbuf));
 		mbuf->data_len = frag_size;
 		mbuf->pkt_len = frag_size;
+		mbuf->ol_flags |= RTE_MBUF_F_RX_IPREASSEMBLY_INCOMPLETE;
 
 		/* Update dynamic field with userdata */
 		*rte_security_dynfield(mbuf) = (uint64_t)inb_priv->userdata;
+
+		rte_eth_ip_reass_dynfield(mbuf)->nb_frags =
+			hdr->w0.num_frags - 4;
+		rte_eth_ip_reass_dynfield(mbuf)->next_frag = NULL;
+		rte_eth_ip_reass_dynfield(mbuf_prev)->next_frag = mbuf;
 	}
+	head->next = NULL;
 
-	mbuf->next = NULL;
 	return head;
 }