[24.11,v3,4/5] node: add error stats for ip4 lookup node

Message ID 20240222122342.16375-4-pbhagavatula@marvell.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series [24.11,v3,1/5] graph: add support for node specific errors |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula Feb. 22, 2024, 12:23 p.m. UTC
From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Add error counters for ip4 LPM lookup failures in
ip4_lookup node.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 lib/node/ip4_lookup.c      | 9 +++++++++
 lib/node/ip4_lookup_neon.h | 5 +++++
 lib/node/ip4_lookup_sse.h  | 6 ++++++
 lib/node/node_private.h    | 8 ++++++++
 4 files changed, 28 insertions(+)
  

Comments

Yan, Zhirun Feb. 23, 2024, 7:18 a.m. UTC | #1
> -----Original Message-----
> From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> Sent: Thursday, February 22, 2024 8:24 PM
> To: jerinj@marvell.com; ndabilpuram@marvell.com; kirankumark@marvell.com;
> Yan, Zhirun <zhirun.yan@intel.com>; Pavan Nikhilesh
> <pbhagavatula@marvell.com>; Ruifeng Wang <ruifeng.wang@arm.com>;
> Richardson, Bruce <bruce.richardson@intel.com>; Konstantin Ananyev
> <konstantin.v.ananyev@yandex.ru>
> Cc: dev@dpdk.org
> Subject: [24.11 PATCH v3 4/5] node: add error stats for ip4 lookup node
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Add error counters for ip4 LPM lookup failures in ip4_lookup node.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  lib/node/ip4_lookup.c      | 9 +++++++++
>  lib/node/ip4_lookup_neon.h | 5 +++++
>  lib/node/ip4_lookup_sse.h  | 6 ++++++
>  lib/node/node_private.h    | 8 ++++++++
>  4 files changed, 28 insertions(+)
> 
> diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c index
> 18955971f6..5a7921db75 100644
> --- a/lib/node/ip4_lookup.c
> +++ b/lib/node/ip4_lookup.c
> @@ -86,6 +86,7 @@ ip4_lookup_node_process_scalar(struct rte_graph *graph,
> struct rte_node *node,
>  		rc = rte_lpm_lookup(lpm, rte_be_to_cpu_32(ipv4_hdr-
> >dst_addr),
>  				    &next_hop);
>  		next_hop = (rc == 0) ? next_hop : drop_nh;
> +		NODE_INCREMENT_ERROR_ID(node, 0, (rc != 0), 1);
> 
>  		node_mbuf_priv1(mbuf, dyn)->nh = (uint16_t)next_hop;
>  		next_hop = next_hop >> 16;
> @@ -219,11 +220,19 @@ ip4_lookup_node_init(const struct rte_graph *graph,
> struct rte_node *node)
>  	return 0;
>  }
> 
> +static struct rte_node_errors ip4_lookup_errors = {
> +	.nb_errors = 1,
> +	.err_desc = {
> +		[0] = "ip4_lookup_error",

Here, if one node has a list of err_desc, should we add a table for counting?
like: 
  err_type  count 
  type_a        1
  type_b        2
  type_c        3

or we can report the total number of failed pkts for one node only.
  
Pavan Nikhilesh Bhagavatula Feb. 26, 2024, 7:46 a.m. UTC | #2
> > -----Original Message-----
> > From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> > Sent: Thursday, February 22, 2024 8:24 PM
> > To: jerinj@marvell.com; ndabilpuram@marvell.com;
> kirankumark@marvell.com;
> > Yan, Zhirun <zhirun.yan@intel.com>; Pavan Nikhilesh
> > <pbhagavatula@marvell.com>; Ruifeng Wang <ruifeng.wang@arm.com>;
> > Richardson, Bruce <bruce.richardson@intel.com>; Konstantin Ananyev
> > <konstantin.v.ananyev@yandex.ru>
> > Cc: dev@dpdk.org
> > Subject: [24.11 PATCH v3 4/5] node: add error stats for ip4 lookup node
> >
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Add error counters for ip4 LPM lookup failures in ip4_lookup node.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  lib/node/ip4_lookup.c      | 9 +++++++++
> >  lib/node/ip4_lookup_neon.h | 5 +++++
> >  lib/node/ip4_lookup_sse.h  | 6 ++++++
> >  lib/node/node_private.h    | 8 ++++++++
> >  4 files changed, 28 insertions(+)
> >
> > diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c index
> > 18955971f6..5a7921db75 100644
> > --- a/lib/node/ip4_lookup.c
> > +++ b/lib/node/ip4_lookup.c
> > @@ -86,6 +86,7 @@ ip4_lookup_node_process_scalar(struct rte_graph
> *graph,
> > struct rte_node *node,
> >  		rc = rte_lpm_lookup(lpm, rte_be_to_cpu_32(ipv4_hdr-
> > >dst_addr),
> >  				    &next_hop);
> >  		next_hop = (rc == 0) ? next_hop : drop_nh;
> > +		NODE_INCREMENT_ERROR_ID(node, 0, (rc != 0), 1);
> >
> >  		node_mbuf_priv1(mbuf, dyn)->nh = (uint16_t)next_hop;
> >  		next_hop = next_hop >> 16;
> > @@ -219,11 +220,19 @@ ip4_lookup_node_init(const struct rte_graph
> *graph,
> > struct rte_node *node)
> >  	return 0;
> >  }
> >
> > +static struct rte_node_errors ip4_lookup_errors = {
> > +	.nb_errors = 1,
> > +	.err_desc = {
> > +		[0] = "ip4_lookup_error",
> 
> Here, if one node has a list of err_desc, should we add a table for counting?

A more complex node can have a table of errors, the lookup node has only one type of failure i.e. lpm lookup failure.

The id to increment can be selected by 
NODE_INCREMENT_ERROR_ID(node, 0, (rc != 0), 1); -> increments id 0 error
NODE_INCREMENT_ERROR_ID(node, 1, (rc != 0), 1); -> increments id 1 error


> like:
>   err_type  count
>   type_a        1
>   type_b        2
>   type_c        3
> 
> or we can report the total number of failed pkts for one node only.
  

Patch

diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c
index 18955971f6..5a7921db75 100644
--- a/lib/node/ip4_lookup.c
+++ b/lib/node/ip4_lookup.c
@@ -86,6 +86,7 @@  ip4_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 		rc = rte_lpm_lookup(lpm, rte_be_to_cpu_32(ipv4_hdr->dst_addr),
 				    &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
+		NODE_INCREMENT_ERROR_ID(node, 0, (rc != 0), 1);
 
 		node_mbuf_priv1(mbuf, dyn)->nh = (uint16_t)next_hop;
 		next_hop = next_hop >> 16;
@@ -219,11 +220,19 @@  ip4_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)
 	return 0;
 }
 
+static struct rte_node_errors ip4_lookup_errors = {
+	.nb_errors = 1,
+	.err_desc = {
+		[0] = "ip4_lookup_error",
+	},
+};
+
 static struct rte_node_register ip4_lookup_node = {
 	.process = ip4_lookup_node_process_scalar,
 	.name = "ip4_lookup",
 
 	.init = ip4_lookup_node_init,
+	.errs = &ip4_lookup_errors,
 
 	.nb_edges = RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP + 1,
 	.next_nodes = {
diff --git a/lib/node/ip4_lookup_neon.h b/lib/node/ip4_lookup_neon.h
index d5c8da3719..907c7c955a 100644
--- a/lib/node/ip4_lookup_neon.h
+++ b/lib/node/ip4_lookup_neon.h
@@ -116,6 +116,10 @@  ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
 		priv01.u16[4] = result.u16[2];
 		priv23.u16[0] = result.u16[4];
 		priv23.u16[4] = result.u16[6];
+		NODE_INCREMENT_ERROR_ID(node, 0, result.u16[1] == (drop_nh >> 16), 1);
+		NODE_INCREMENT_ERROR_ID(node, 0, result.u16[3] == (drop_nh >> 16), 1);
+		NODE_INCREMENT_ERROR_ID(node, 0, result.u16[5] == (drop_nh >> 16), 1);
+		NODE_INCREMENT_ERROR_ID(node, 0, result.u16[7] == (drop_nh >> 16), 1);
 
 		node_mbuf_priv1(mbuf0, dyn)->u = priv01.u64[0];
 		node_mbuf_priv1(mbuf1, dyn)->u = priv01.u64[1];
@@ -202,6 +206,7 @@  ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
 				    &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
 
+		NODE_INCREMENT_ERROR_ID(node, 0, (rc != 0), 1);
 		node_mbuf_priv1(mbuf0, dyn)->nh = (uint16_t)next_hop;
 		next_hop = next_hop >> 16;
 		next0 = (uint16_t)next_hop;
diff --git a/lib/node/ip4_lookup_sse.h b/lib/node/ip4_lookup_sse.h
index 74dbf97533..a38131e629 100644
--- a/lib/node/ip4_lookup_sse.h
+++ b/lib/node/ip4_lookup_sse.h
@@ -115,6 +115,11 @@  ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
 		/* Perform LPM lookup to get NH and next node */
 		rte_lpm_lookupx4(lpm, dip, dst.u32, drop_nh);
 
+		NODE_INCREMENT_ERROR_ID(node, 0, dst.u16[1] == (drop_nh >> 16), 1);
+		NODE_INCREMENT_ERROR_ID(node, 0, dst.u16[3] == (drop_nh >> 16), 1);
+		NODE_INCREMENT_ERROR_ID(node, 0, dst.u16[5] == (drop_nh >> 16), 1);
+		NODE_INCREMENT_ERROR_ID(node, 0, dst.u16[7] == (drop_nh >> 16), 1);
+
 		/* Extract next node id and NH */
 		node_mbuf_priv1(mbuf0, dyn)->nh = dst.u32[0] & 0xFFFF;
 		next0 = (dst.u32[0] >> 16);
@@ -206,6 +211,7 @@  ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
 		rc = rte_lpm_lookup(lpm, rte_be_to_cpu_32(ipv4_hdr->dst_addr),
 				    &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
+		NODE_INCREMENT_ERROR_ID(node, 0, rc != 0, 1);
 
 		node_mbuf_priv1(mbuf0, dyn)->nh = next_hop & 0xFFFF;
 		next0 = (next_hop >> 16);
diff --git a/lib/node/node_private.h b/lib/node/node_private.h
index 2b9bad1a11..25870f97fe 100644
--- a/lib/node/node_private.h
+++ b/lib/node/node_private.h
@@ -12,6 +12,8 @@ 
 #include <rte_mbuf.h>
 #include <rte_mbuf_dyn.h>
 
+#include <rte_graph_worker_common.h>
+
 extern int rte_node_logtype;
 #define RTE_LOGTYPE_NODE rte_node_logtype
 
@@ -89,4 +91,10 @@  node_mbuf_priv2(struct rte_mbuf *m)
 	return (struct node_mbuf_priv2 *)rte_mbuf_to_priv(m);
 }
 
+#define NODE_INCREMENT_ERROR_ID(node, id, cond, cnt)                                               \
+	{                                                                                          \
+		if (unlikely(rte_graph_has_stats_feature() && (cond)))                             \
+			((uint64_t *)RTE_PTR_ADD(node, node->err_off))[id] += (cnt);               \
+	}
+
 #endif /* __NODE_PRIVATE_H__ */