Skip to contentSkip to conversation

node: add pkt classifier node

PATCH Applied Nithin Dabilpuram 2 participants 2 messages Jun 7, 2020 – Jul 21, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 node: add pkt classifier node

This node classifies pkts based on packet type and sends them to appropriate next node. This is node helps in distribution of packets from ethdev_rx node to different next node with a constant overhead for all packet types.

Currently all except non fragmented IPV4 packets are marked to be sent to "pkt_drop" node.
Performance difference on ARM64 Octeontx2 is -4.9% due to addition of new node in the path.

---
 lib/librte_node/Makefile          |   1 +
 lib/librte_node/ethdev_rx.c       |  20 +++-
 lib/librte_node/ethdev_rx_priv.h  |   2 +
 lib/librte_node/ip4_lookup_neon.h |   1 -
 lib/librte_node/meson.build       |   2 +-
 lib/librte_node/node_private.h    |   2 +
 lib/librte_node/pkt_cls.c         | 225 ++++++++++++++++++++++++++++++++++++++
 lib/librte_node/pkt_cls_priv.h    |  27 +++++
 8 files changed, 273 insertions(+), 7 deletions(-)
 create mode 100644 lib/librte_node/pkt_cls.c
 create mode 100644 lib/librte_node/pkt_cls_priv.h
lib/librte_node/Makefile +1 -0
index 9dee8b4..3ec0210 100644
@@ -23,6 +23,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ethdev_tx.c
 SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ethdev_ctrl.c
 SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ip4_lookup.c
 SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ip4_rewrite.c
+SRCS-$(CONFIG_RTE_LIBRTE_NODE) += pkt_cls.c
 SRCS-$(CONFIG_RTE_LIBRTE_NODE) += pkt_drop.c
 
 # install header files
lib/librte_node/ethdev_rx.c +15 -5
index 5cc7365..4c23961 100644
@@ -16,9 +16,14 @@ static struct ethdev_rx_node_main ethdev_rx_main;
 
 static __rte_always_inline uint16_t
 ethdev_rx_node_process_inline(struct rte_graph *graph, struct rte_node *node,
-			      uint16_t port, uint16_t queue)
+			      ethdev_rx_node_ctx_t *ctx)
 {
-	uint16_t count, next_index = ETHDEV_RX_NEXT_IP4_LOOKUP;
+	uint16_t count, next_index;
+	uint16_t port, queue;
+
+	port = ctx->port_id;
+	queue = ctx->queue_id;
+	next_index = ctx->cls_next;
 
 	/* Get pkts from port */
 	count = rte_eth_rx_burst(port, queue, (struct rte_mbuf **)node->objs,
@@ -43,8 +48,7 @@ ethdev_rx_node_process(struct rte_graph *graph, struct rte_node *node,
 	RTE_SET_USED(objs);
 	RTE_SET_USED(cnt);
 
-	n_pkts = ethdev_rx_node_process_inline(graph, node, ctx->port_id,
-					       ctx->queue_id);
+	n_pkts = ethdev_rx_node_process_inline(graph, node, ctx);
 	return n_pkts;
 }
 
@@ -191,6 +195,8 @@ ethdev_rx_node_init(const struct rte_graph *graph, struct rte_node *node)
 
 	RTE_VERIFY(elem != NULL);
 
+	ctx->cls_next = ETHDEV_RX_NEXT_PKT_CLS;
+
 	/* Check and setup ptype */
 	return ethdev_ptype_setup(ctx->port_id, ctx->queue_id);
 }
@@ -209,7 +215,11 @@ static struct rte_node_register ethdev_rx_node_base = {
 	.init = ethdev_rx_node_init,
 
 	.nb_edges = ETHDEV_RX_NEXT_MAX,
-	.next_nodes = {[ETHDEV_RX_NEXT_IP4_LOOKUP] = "ip4_lookup"},
+	.next_nodes = {
+		/* Default pkt classification node */
+		[ETHDEV_RX_NEXT_PKT_CLS] = "pkt_cls",
+		[ETHDEV_RX_NEXT_IP4_LOOKUP] = "ip4_lookup",
+	},
 };
 
 struct rte_node_register *
lib/librte_node/ethdev_rx_priv.h +2 -0
index 2d7195a..efcd66d 100644
@@ -23,6 +23,7 @@ typedef struct ethdev_rx_node_ctx ethdev_rx_node_ctx_t;
 struct ethdev_rx_node_ctx {
 	uint16_t port_id;  /**< Port identifier of the Rx node. */
 	uint16_t queue_id; /**< Queue identifier of the Rx node. */
+	uint16_t cls_next;
 };
 
 /**
@@ -41,6 +42,7 @@ struct ethdev_rx_node_elem {
 
 enum ethdev_rx_next_nodes {
 	ETHDEV_RX_NEXT_IP4_LOOKUP,
+	ETHDEV_RX_NEXT_PKT_CLS,
 	ETHDEV_RX_NEXT_MAX,
 };
 
lib/librte_node/ip4_lookup_neon.h +0 -1
index dd21cb2..5e5a7d8 100644
@@ -37,7 +37,6 @@ ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node,
 	from = objs;
 	n_left_from = nb_objs;
 
-#define OBJS_PER_CLINE (RTE_CACHE_LINE_SIZE / sizeof(void *))
 	for (i = OBJS_PER_CLINE; i < RTE_GRAPH_BURST_SIZE; i += OBJS_PER_CLINE)
 		rte_prefetch0(&objs[i]);
 
lib/librte_node/meson.build +1 -1
index 17f1316..3d582f6 100644
@@ -2,7 +2,7 @@
 # Copyright(C) 2020 Marvell International Ltd.
 
 sources = files('null.c', 'log.c', 'ethdev_rx.c', 'ethdev_tx.c', 'ip4_lookup.c',
-		'ip4_rewrite.c', 'pkt_drop.c', 'ethdev_ctrl.c')
+		'ip4_rewrite.c', 'pkt_drop.c', 'ethdev_ctrl.c', 'pkt_cls.c')
 headers = files('rte_node_ip4_api.h', 'rte_node_eth_api.h')
 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
 cflags += '-fno-strict-aliasing'
lib/librte_node/node_private.h +2 -0
index 975b9aa..ab7941c 100644
@@ -46,6 +46,8 @@ struct node_mbuf_priv2 {
 
 #define NODE_MBUF_PRIV2_SIZE sizeof(struct node_mbuf_priv2)
 
+#define OBJS_PER_CLINE (RTE_CACHE_LINE_SIZE / sizeof(void *))
+
 /**
  * Get mbuf_priv1 pointer from rte_mbuf.
  *
lib/librte_node/pkt_cls.c new file +225 -0

225 lines not on this page · raw message

lib/librte_node/pkt_cls_priv.h new file +27 -0
new file mode 100644
index 0000000..3f2bb04
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) 2020 Marvell.
+ */
+#ifndef __INCLUDE_PKT_CLS_PRIV_H__
+#define __INCLUDE_PKT_CLS_PRIV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_common.h>
+
+struct pkt_cls_node_ctx {
+	uint16_t l2l3_type;
+};
+
+enum pkt_cls_next_nodes {
+	PKT_CLS_NEXT_PKT_DROP,
+	PKT_CLS_NEXT_IP4_LOOKUP,
+	PKT_CLS_NEXT_MAX,
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __INCLUDE_PKT_CLS_PRIV_H__ */
Signature · 1 line
2.8.4
#1 lore raw

07/06/2020 18:40, Nithin Dabilpuram:

Quoted 6 lines

This node classifies pkts based on packet type and sends them to appropriate next node. This is node helps in distribution of packets from ethdev_rx node to different next node with a constant overhead for all packet types.

Quoted 6 lines

Currently all except non fragmented IPV4 packets are marked to be sent to "pkt_drop" node.
Performance difference on ARM64 Octeontx2 is -4.9% due to addition of new node in the path.

There has been zero comment.
I assume it is good to merge.

Applied, thanks