DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ankur Dwivedi <adwivedi@marvell.com>
To: <dev@dpdk.org>
Cc: <jerinj@marvell.com>, <vladimir.medvedkin@intel.com>,
	<ndabilpuram@marvell.com>, <pbhagavatula@marvell.com>,
	<skori@marvell.com>, <rkudurumalla@marvell.com>,
	<nsaxena@marvell.com>, Ankur Dwivedi <adwivedi@marvell.com>
Subject: [PATCH v2 11/13] node: add process callback for IP6 FIB
Date: Fri, 9 May 2025 12:14:46 +0530	[thread overview]
Message-ID: <20250509064448.724019-12-adwivedi@marvell.com> (raw)
In-Reply-To: <20250509064448.724019-1-adwivedi@marvell.com>

Adds the process callback function for ip6_lookup_fib node.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
 lib/node/ip6_lookup_fib.c | 148 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 148 insertions(+)

diff --git a/lib/node/ip6_lookup_fib.c b/lib/node/ip6_lookup_fib.c
index b510452ad8..3df61890e9 100644
--- a/lib/node/ip6_lookup_fib.c
+++ b/lib/node/ip6_lookup_fib.c
@@ -40,6 +40,153 @@ static struct ip6_lookup_fib_node_main ip6_lookup_fib_nm;
 #define IP6_LOOKUP_FIB_NODE_PRIV1_OFF(ctx) \
 	(((struct ip6_lookup_fib_node_ctx *)ctx)->mbuf_priv1_off)
 
+static uint16_t
+ip6_lookup_fib_node_process(struct rte_graph *graph, struct rte_node *node, void **objs,
+			    uint16_t nb_objs)
+{
+	struct rte_mbuf *mbuf0, *mbuf1, *mbuf2, *mbuf3, **pkts;
+	const int dyn = IP6_LOOKUP_FIB_NODE_PRIV1_OFF(node->ctx);
+	struct rte_fib6 *fib = IP6_LOOKUP_FIB_NODE(node->ctx);
+	struct rte_ipv6_addr ip[RTE_GRAPH_BURST_SIZE] = { 0 };
+	uint64_t next_hop[RTE_GRAPH_BURST_SIZE];
+	struct rte_ipv6_hdr *ipv6_hdr;
+	uint16_t lookup_err = 0;
+	void **to_next, **from;
+	uint16_t last_spec = 0;
+	rte_edge_t next_index;
+	uint16_t n_left_from;
+	uint16_t held = 0;
+	uint16_t next;
+	int i;
+
+	/* Speculative next */
+	next_index = RTE_NODE_IP6_LOOKUP_NEXT_REWRITE;
+
+	pkts = (struct rte_mbuf **)objs;
+	from = objs;
+	n_left_from = nb_objs;
+
+	/* Get stream for the speculated next node */
+	to_next = rte_node_next_stream_get(graph, node, next_index, nb_objs);
+
+	for (i = 0; i < 4 && i < n_left_from; i++)
+		rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[i], void *,
+					sizeof(struct rte_ether_hdr)));
+
+	i = 0;
+	while (n_left_from >= 4) {
+		if (likely(n_left_from > 7)) {
+
+			/* Prefetch next-next mbufs */
+			if (likely(n_left_from > 11)) {
+				rte_prefetch0(pkts[8]);
+				rte_prefetch0(pkts[9]);
+				rte_prefetch0(pkts[10]);
+				rte_prefetch0(pkts[11]);
+			}
+
+			/* Prefetch next mbuf data */
+			rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[4], void *,
+					sizeof(struct rte_ether_hdr)));
+			rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[5], void *,
+					sizeof(struct rte_ether_hdr)));
+			rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[6], void *,
+					sizeof(struct rte_ether_hdr)));
+			rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[7], void *,
+					sizeof(struct rte_ether_hdr)));
+		}
+
+		mbuf0 = pkts[0];
+		mbuf1 = pkts[1];
+		mbuf2 = pkts[2];
+		mbuf3 = pkts[3];
+		pkts += 4;
+		n_left_from -= 4;
+		/* Extract DIP of mbuf0 */
+		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf0, struct rte_ipv6_hdr *,
+				sizeof(struct rte_ether_hdr));
+		/* Extract hop_limits as ipv6 hdr is in cache */
+		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
+
+		ip[i++] = ipv6_hdr->dst_addr;
+
+		/* Extract DIP of mbuf1 */
+		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf1, struct rte_ipv6_hdr *,
+				sizeof(struct rte_ether_hdr));
+		/* Extract hop_limits as ipv6 hdr is in cache */
+		node_mbuf_priv1(mbuf1, dyn)->ttl = ipv6_hdr->hop_limits;
+
+		ip[i++] = ipv6_hdr->dst_addr;
+
+		/* Extract DIP of mbuf2 */
+		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf2, struct rte_ipv6_hdr *,
+				sizeof(struct rte_ether_hdr));
+		/* Extract hop_limits as ipv6 hdr is in cache */
+		node_mbuf_priv1(mbuf2, dyn)->ttl = ipv6_hdr->hop_limits;
+
+		ip[i++] = ipv6_hdr->dst_addr;
+
+		/* Extract DIP of mbuf3 */
+		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf3, struct rte_ipv6_hdr *,
+				sizeof(struct rte_ether_hdr));
+		/* Extract hop_limits as ipv6 hdr is in cache */
+		node_mbuf_priv1(mbuf3, dyn)->ttl = ipv6_hdr->hop_limits;
+
+		ip[i++] = ipv6_hdr->dst_addr;
+	}
+	while (n_left_from > 0) {
+		mbuf0 = pkts[0];
+		pkts += 1;
+		n_left_from -= 1;
+
+		/* Extract DIP of mbuf0 */
+		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf0, struct rte_ipv6_hdr *,
+				sizeof(struct rte_ether_hdr));
+		/* Extract hop_limits as ipv6 hdr is in cache */
+		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
+
+		ip[i++] = ipv6_hdr->dst_addr;
+	}
+
+	rte_fib6_lookup_bulk(fib, ip, next_hop, nb_objs);
+
+	for (i = 0; i < nb_objs; i++) {
+		mbuf0 = (struct rte_mbuf *)objs[i];
+		node_mbuf_priv1(mbuf0, dyn)->nh = (uint16_t)next_hop[i];
+		next = (uint16_t)(next_hop[i] >> 16);
+
+		if (unlikely(next_index ^ next)) {
+			/* Copy things successfully speculated till now */
+			rte_memcpy(to_next, from, last_spec * sizeof(from[0]));
+			from += last_spec;
+			to_next += last_spec;
+			held += last_spec;
+			last_spec = 0;
+
+			rte_node_enqueue_x1(graph, node, next, from[0]);
+			from += 1;
+		} else {
+			last_spec += 1;
+		}
+
+		if (unlikely(next_hop[i] == FIB6_DEFAULT_NH))
+			lookup_err += 1;
+	}
+
+	/* !!! Home run !!! */
+	if (likely(last_spec == nb_objs)) {
+		rte_node_next_stream_move(graph, node, next_index);
+		return nb_objs;
+	}
+
+	NODE_INCREMENT_XSTAT_ID(node, 0, lookup_err != 0, lookup_err);
+	held += last_spec;
+	rte_memcpy(to_next, from, last_spec * sizeof(from[0]));
+	rte_node_next_stream_put(graph, node, next_index, held);
+
+	return nb_objs;
+}
+
 RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_node_ip6_fib_create, 25.07)
 int
 rte_node_ip6_fib_create(int socket, struct rte_fib6_conf *conf)
@@ -159,6 +306,7 @@ static struct rte_node_xstats ip6_lookup_fib_xstats = {
 };
 
 static struct rte_node_register ip6_lookup_fib_node = {
+	.process = ip6_lookup_fib_node_process,
 	.name = "ip6_lookup_fib",
 
 	.init = ip6_lookup_fib_node_init,
-- 
2.25.1


  parent reply	other threads:[~2025-05-09  6:46 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 12:10 [PATCH v1 00/12] add lookup fib nodes in graph library Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 01/12] fib: move macro to header file Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 02/12] node: add IP4 lookup FIB node Ankur Dwivedi
2025-04-16  7:32   ` Nitin Saxena
2025-04-16 10:26     ` [EXTERNAL] " Ankur Dwivedi
2025-04-16  9:34   ` Medvedkin, Vladimir
2025-04-16 10:07     ` [EXTERNAL] " Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 03/12] node: add IP4 FIB route add Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 04/12] node: add process callback for IP4 FIB Ankur Dwivedi
2025-04-16  7:54   ` Nitin Saxena
2025-04-16 12:54   ` Medvedkin, Vladimir
2025-04-18  7:38     ` [EXTERNAL] " Ankur Dwivedi
2025-04-19 18:14       ` Vladimir Medvedkin
2025-04-23  9:46         ` Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 05/12] node: add next node in packet classification Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 06/12] app/graph: add IP4 lookup mode command Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 07/12] fib: move macro to header file Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 08/12] node: add IP6 lookup FIB node Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 09/12] node: add IP6 FIB route add Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 10/12] node: add process callback for IP6 FIB Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 11/12] node: add next node in packet classification Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 12/12] app/graph: add IP6 lookup mode command Ankur Dwivedi
2025-05-09  6:44 ` [PATCH v2 00/13] add lookup fib nodes in graph library Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 01/13] fib: move macro to header file Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 02/13] node: add IP4 lookup FIB node Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 03/13] node: add IP4 FIB route add Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 04/13] node: add process callback for IP4 FIB Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 05/13] node: move next nodes to public header file Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 06/13] node: add next node in packet classification Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 07/13] app/graph: add IP4 lookup mode command Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 08/13] fib: move macro to header file Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 09/13] node: add IP6 lookup FIB node Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 10/13] node: add IP6 FIB route add Ankur Dwivedi
2025-05-09  6:44   ` Ankur Dwivedi [this message]
2025-05-09  6:44   ` [PATCH v2 12/13] node: add next node in packet classification Ankur Dwivedi
2025-05-09  6:44   ` [PATCH v2 13/13] app/graph: add IP6 lookup mode command Ankur Dwivedi

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20250509064448.724019-12-adwivedi@marvell.com \
    --to=adwivedi@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=nsaxena@marvell.com \
    --cc=pbhagavatula@marvell.com \
    --cc=rkudurumalla@marvell.com \
    --cc=skori@marvell.com \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

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

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