[24.11,v3,2/5] graph: add node fastpath error counters

Message ID 20240222122342.16375-2-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 warning coding style issues

Commit Message

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

Add node fastpath error counters advertised during
node registration.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 lib/graph/graph_populate.c          | 22 +++++++++++++++++++---
 lib/graph/graph_private.h           |  2 ++
 lib/graph/rte_graph_worker_common.h |  1 +
 3 files changed, 22 insertions(+), 3 deletions(-)
  

Comments

Yan, Zhirun Feb. 23, 2024, 7:15 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>
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@marvell.com>
> Subject: [24.11 PATCH v3 2/5] graph: add node fastpath error counters
> 
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Add node fastpath error counters advertised during node registration.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  lib/graph/graph_populate.c          | 22 +++++++++++++++++++---
>  lib/graph/graph_private.h           |  2 ++
>  lib/graph/rte_graph_worker_common.h |  1 +
>  3 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/graph/graph_populate.c b/lib/graph/graph_populate.c index
> ed596a7711..924f5a3034 100644
> --- a/lib/graph/graph_populate.c
> +++ b/lib/graph/graph_populate.c
> @@ -39,6 +39,15 @@ graph_fp_mem_calc_size(struct graph *graph)
>  		/* Pointer to next nodes(edges) */
>  		sz += sizeof(struct rte_node *) * graph_node->node->nb_edges;
>  	}
> +	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> +	graph->errors_start = sz;
> +	/* For 0..N node objects with error counters */
> +	STAILQ_FOREACH (graph_node, &graph->node_list, next) {
> +		if (graph_node->node->errs == NULL)
> +			continue;
> +		sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> +		sz += sizeof(uint64_t) * graph_node->node->errs->nb_errors;
> +	}
> 
>  	graph->mem_sz = sz;
>  	return sz;
> @@ -64,6 +73,7 @@ graph_header_popluate(struct graph *_graph)  static void
> graph_nodes_populate(struct graph *_graph)  {
> +	rte_graph_off_t err_off = _graph->errors_start;
>  	rte_graph_off_t off = _graph->nodes_start;
>  	struct rte_graph *graph = _graph->graph;
>  	struct graph_node *graph_node;
> @@ -99,6 +109,12 @@ graph_nodes_populate(struct graph *_graph)
>  						     ->adjacency_list[count]
>  						     ->node->name[0];
> 
> +		if (graph_node->node->errs != NULL) {
> +			node->err_off = err_off - off;
> +			err_off += sizeof(uint64_t) * graph_node->node->errs-
> >nb_errors;
> +			err_off = RTE_ALIGN(err_off, RTE_CACHE_LINE_SIZE);
> +		}
> +
>  		off += sizeof(struct rte_node *) * nb_edges;
>  		off = RTE_ALIGN(off, RTE_CACHE_LINE_SIZE);
>  		node->next = off;
> @@ -158,7 +174,7 @@ graph_node_nexts_populate(struct graph *_graph)  }
> 
>  static int
> -graph_src_nodes_populate(struct graph *_graph)
> +graph_src_nodes_offset_populate(struct graph *_graph)
>  {
>  	struct rte_graph *graph = _graph->graph;
>  	struct graph_node *graph_node;
> @@ -193,7 +209,7 @@ graph_fp_mem_populate(struct graph *graph)
>  		graph_pcap_init(graph);
>  	graph_nodes_populate(graph);
>  	rc = graph_node_nexts_populate(graph);
> -	rc |= graph_src_nodes_populate(graph);
> +	rc |= graph_src_nodes_offset_populate(graph);
> 
>  	return rc;
>  }
> @@ -228,7 +244,7 @@ graph_nodes_mem_destroy(struct rte_graph *graph)
>  	if (graph == NULL)
>  		return;
> 
> -	rte_graph_foreach_node(count, off, graph, node)
> +	rte_graph_foreach_node (count, off, graph, node)
No need to add space here.
  

Patch

diff --git a/lib/graph/graph_populate.c b/lib/graph/graph_populate.c
index ed596a7711..924f5a3034 100644
--- a/lib/graph/graph_populate.c
+++ b/lib/graph/graph_populate.c
@@ -39,6 +39,15 @@  graph_fp_mem_calc_size(struct graph *graph)
 		/* Pointer to next nodes(edges) */
 		sz += sizeof(struct rte_node *) * graph_node->node->nb_edges;
 	}
+	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
+	graph->errors_start = sz;
+	/* For 0..N node objects with error counters */
+	STAILQ_FOREACH (graph_node, &graph->node_list, next) {
+		if (graph_node->node->errs == NULL)
+			continue;
+		sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
+		sz += sizeof(uint64_t) * graph_node->node->errs->nb_errors;
+	}
 
 	graph->mem_sz = sz;
 	return sz;
@@ -64,6 +73,7 @@  graph_header_popluate(struct graph *_graph)
 static void
 graph_nodes_populate(struct graph *_graph)
 {
+	rte_graph_off_t err_off = _graph->errors_start;
 	rte_graph_off_t off = _graph->nodes_start;
 	struct rte_graph *graph = _graph->graph;
 	struct graph_node *graph_node;
@@ -99,6 +109,12 @@  graph_nodes_populate(struct graph *_graph)
 						     ->adjacency_list[count]
 						     ->node->name[0];
 
+		if (graph_node->node->errs != NULL) {
+			node->err_off = err_off - off;
+			err_off += sizeof(uint64_t) * graph_node->node->errs->nb_errors;
+			err_off = RTE_ALIGN(err_off, RTE_CACHE_LINE_SIZE);
+		}
+
 		off += sizeof(struct rte_node *) * nb_edges;
 		off = RTE_ALIGN(off, RTE_CACHE_LINE_SIZE);
 		node->next = off;
@@ -158,7 +174,7 @@  graph_node_nexts_populate(struct graph *_graph)
 }
 
 static int
-graph_src_nodes_populate(struct graph *_graph)
+graph_src_nodes_offset_populate(struct graph *_graph)
 {
 	struct rte_graph *graph = _graph->graph;
 	struct graph_node *graph_node;
@@ -193,7 +209,7 @@  graph_fp_mem_populate(struct graph *graph)
 		graph_pcap_init(graph);
 	graph_nodes_populate(graph);
 	rc = graph_node_nexts_populate(graph);
-	rc |= graph_src_nodes_populate(graph);
+	rc |= graph_src_nodes_offset_populate(graph);
 
 	return rc;
 }
@@ -228,7 +244,7 @@  graph_nodes_mem_destroy(struct rte_graph *graph)
 	if (graph == NULL)
 		return;
 
-	rte_graph_foreach_node(count, off, graph, node)
+	rte_graph_foreach_node (count, off, graph, node)
 		rte_free(node->objs);
 }
 
diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
index eb4d461c6e..a185a5a4ea 100644
--- a/lib/graph/graph_private.h
+++ b/lib/graph/graph_private.h
@@ -104,6 +104,8 @@  struct graph {
 	/**< Memzone to store graph data. */
 	rte_graph_off_t nodes_start;
 	/**< Node memory start offset in graph reel. */
+	rte_graph_off_t errors_start;
+	/**< Node error memory start offset in graph reel. */
 	rte_node_t src_node_count;
 	/**< Number of source nodes in a graph. */
 	struct rte_graph *graph;
diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h
index 4045a7a8dc..b58f37c734 100644
--- a/lib/graph/rte_graph_worker_common.h
+++ b/lib/graph/rte_graph_worker_common.h
@@ -107,6 +107,7 @@  struct rte_node {
 			uint64_t total_sched_fail; /**< Number of scheduled failure. */
 		} dispatch;
 	};
+	rte_graph_off_t err_off; /**< Offset to error counters. */
 	/* Fast path area  */
 #define RTE_NODE_CTX_SZ 16
 	uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */