Hi Pavan,

, Aug 16, 2024 at 17:09:
From: Pavan Nikhilesh <pbhagavat...@marvell.com>

Add ability for Nodes to advertise error counters
during registration.

Signed-off-by: Pavan Nikhilesh <pbhagavat...@marvell.com>
---
v2 Changes:
- Fix compilation.
v3 Changes:
- Resend as 1/5 didn't make it through.
v4 Changes:
- Address review comments.
- Rebase on main branch.

 doc/guides/prog_guide/graph_lib.rst           |  22 +-
 .../prog_guide/img/anatomy_of_a_node.svg      | 329 +++++--
 .../prog_guide/img/graph_mem_layout.svg       | 921 +++++++++++++-----
 lib/graph/graph_private.h                     |   1 +
 lib/graph/node.c                              |  37 +-
 lib/graph/rte_graph.h                         |   7 +
 6 files changed, 1016 insertions(+), 301 deletions(-)

diff --git a/doc/guides/prog_guide/graph_lib.rst 
b/doc/guides/prog_guide/graph_lib.rst
index ad09bdfe26..018900caea 100644
--- a/doc/guides/prog_guide/graph_lib.rst
+++ b/doc/guides/prog_guide/graph_lib.rst
@@ -21,6 +21,7 @@ Features of the Graph library are:
 - Nodes as plugins.
 - Support for out of tree nodes.
 - Inbuilt nodes for packet processing.
+- Node specific error counts.
 - Multi-process support.
 - Low overhead graph walk and node enqueue.
 - Low overhead statistics collection infrastructure.
@@ -124,6 +125,18 @@ Source nodes are static nodes created using 
``RTE_NODE_REGISTER`` by passing
 While performing the graph walk, the ``process()`` function of all the source
 nodes will be called first. So that these nodes can be used as input nodes for 
a graph.

+nb_errors:
+^^^^^^^^^^
+
+The number of errors that this node can report. The ``err_desc[]`` stores the 
error
+descriptions which will later be propagated to stats.
+
+err_desc[]:
+^^^^^^^^^^^
+
+The dynamic array to store the error descriptions that will be reported by this
+node.

This feature could be useful to store detailed statistics per node, not only for errors. It would be better to rename "errors" to "stats" or "xstats".

See below for a concrete suggestion.

diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
index d557d55f2d..e663b04d8b 100644
--- a/lib/graph/graph_private.h
+++ b/lib/graph/graph_private.h
@@ -61,6 +61,7 @@ struct node {
        rte_node_t id;                /**< Allocated identifier for the node. */
        rte_node_t parent_id;         /**< Parent node identifier. */
        rte_edge_t nb_edges;          /**< Number of edges from this node. */
+       struct rte_node_errors *errs; /**< Node specific errors. */

How about:

   struct rte_node_xstats *xstats; /**< Node specific extra statistics. */

And maybe const? I didn't check if you make a full copy, or if you only copy the pointer.

diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h
index ecfec2068a..b28143d737 100644
--- a/lib/graph/rte_graph.h
+++ b/lib/graph/rte_graph.h
@@ -29,6 +29,7 @@ extern "C" {

 #define RTE_GRAPH_NAMESIZE 64 /**< Max length of graph name. */
 #define RTE_NODE_NAMESIZE 64  /**< Max length of node name. */
+#define RTE_NODE_ERROR_DESC_SIZE 64  /**< Max length of node name. */

#define RTE_NODE_XSTATS_DESC_SIZE 64 /**< Max length of node xstats names. */

 #define RTE_GRAPH_PCAP_FILE_SZ 64 /**< Max length of pcap file name. */
 #define RTE_GRAPH_OFF_INVALID UINT32_MAX /**< Invalid graph offset. */
 #define RTE_NODE_ID_INVALID UINT32_MAX   /**< Invalid node id. */
@@ -460,6 +461,11 @@ void rte_graph_cluster_stats_get(struct 
rte_graph_cluster_stats *stat,
  */
 void rte_graph_cluster_stats_reset(struct rte_graph_cluster_stats *stat);

+struct rte_node_errors {
+       uint16_t nb_errors;                              /**< Number of errors. 
*/
+       char err_desc[][RTE_NODE_ERROR_DESC_SIZE];       /**< Names of errors. 
*/
+};


struct rte_node_xstats {
   uint16_t xstats_num; /**< Number of xstats. */
   char xstats_desc[RTE_NODE_XSTATS_DESC_SIZE];  /**< Names of xstats. */
};

+
 /**
  * Structure defines the node registration parameters.
  *
@@ -472,6 +478,7 @@ struct rte_node_register {
        rte_node_process_t process; /**< Node process function. */
        rte_node_init_t init;       /**< Node init function. */
        rte_node_fini_t fini;       /**< Node fini function. */
+       struct rte_node_errors *errs; /**< Node specific errors. */

   struct rte_node_xstats *xstats; /**< Node specific extra statistics. */

Cheers!

Reply via email to