From patchwork Thu Feb 22 12:23:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavan Nikhilesh Bhagavatula X-Patchwork-Id: 137029 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C300E43B74; Thu, 22 Feb 2024 13:24:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B1B940A6D; Thu, 22 Feb 2024 13:24:00 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E0F5040281 for ; Thu, 22 Feb 2024 13:23:56 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41M9BMF4021869; Thu, 22 Feb 2024 04:23:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=r+toDGkDyj1S4vHkUTqPMTg1Fb+WQIdGq/OzFAqFv4Q=; b=DTh wumRjTkNDipfgofMi0IFdCY1WGuG+i67m7IBfMTDza+R2H2qEJ3KA8/JLqPW1Nhf mGFEkC+3A3p1bY66APSY4eIUuu5waRUtnl4T6dsGGDVsYQG5MVenTL9xlNDCGHHa hgPYhDDRFzGDyz2opvE5bS1/fpXt7TOYfUyYtWLb6M9HfhaS7Y5u5fm4jEjcFyHj uU+59p5KNdowAoK8esw1/7WVjwC1/w/WLVUSztgn0oOuHx1ZLzH9SONRgl7FQNoe 1vmb8xttz86KZiBvP738+5I7VccfPThGSb5Vebl583dMUudhnq/8rhVEWL8510qz vU218lJNbASMBgcogEg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3we3dw8j6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 04:23:54 -0800 (PST) Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 22 Feb 2024 04:23:51 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 22 Feb 2024 04:23:51 -0800 Received: from MININT-80QBFE8.corp.innovium.com (unknown [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id 14BF43F71CF; Thu, 22 Feb 2024 04:23:45 -0800 (PST) From: To: , , , CC: , Pavan Nikhilesh Subject: [24.11 PATCH v3 1/5] graph: add support for node specific errors Date: Thu, 22 Feb 2024 17:53:38 +0530 Message-ID: <20240222122342.16375-1-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240222053639.15057-1-pbhagavatula@marvell.com> References: <20240222053639.15057-1-pbhagavatula@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 9ygP3FSP_LMwBeZamu4nX_Pnq9CRCiGo X-Proofpoint-ORIG-GUID: 9ygP3FSP_LMwBeZamu4nX_Pnq9CRCiGo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-22_09,2024-02-22_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Pavan Nikhilesh Add ability for Nodes to advertise error counters during registration. Signed-off-by: Pavan Nikhilesh --- v2 Changes: - Fix compilation. v3 Changes: - Resend as 1/5 didn't make it through. 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(-) -- 2.25.1 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. + Node creation and registration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Node implementer creates the node by implementing ops and attributes of @@ -141,13 +154,13 @@ Link the Nodes to create the graph topology Topology after linking the nodes Once nodes are available to the program, Application or node public API -functions can links them together to create a complex packet processing graph. +functions can link them together to create a complex packet processing graph. There are multiple different types of strategies to link the nodes. Method (a): ^^^^^^^^^^^ -Provide the ``next_nodes[]`` at the node registration time. See ``struct rte_node_register::nb_edges``. +Provide the ``next_nodes[]`` at the node registration time. See ``struct rte_node_register::nb_edges``. This is a use case to address the static node scheme where one knows upfront the ``next_nodes[]`` of the node. @@ -385,8 +398,9 @@ Understanding the memory layout helps to debug the graph library and improve the performance if needed. Graph object consists of a header, circular buffer to store the pending -stream when walking over the graph, and variable-length memory to store -the ``rte_node`` objects. +stream when walking over the graph, variable-length memory to store +the ``rte_node`` objects, and variable-length memory to store the errors +reported by each ``rte_node``. The graph_nodes_mem_create() creates and populate this memory. The functions such as ``rte_graph_walk()`` and ``rte_node_enqueue_*`` use this memory diff --git a/doc/guides/prog_guide/img/anatomy_of_a_node.svg b/doc/guides/prog_guide/img/anatomy_of_a_node.svg index d3bc742e77..29818e267b 100644 --- a/doc/guides/prog_guide/img/anatomy_of_a_node.svg +++ b/doc/guides/prog_guide/img/anatomy_of_a_node.svg @@ -3,13 +3,6 @@ + inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> @@ -27,12 +27,51 @@ image/svg+xml - + + id="defs423"> + + + + + + + + + + inkscape:current-layer="g417" + inkscape:showpageshadow="2" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:lockguides="true" /> + style="fill:#ffffff;fill-rule:evenodd;fill-opacity:1" /> @@ -90,87 +133,92 @@ inkscape:connector-curvature="0" style="fill-rule:evenodd;stroke:#c27ba0;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:4, 3, 1, 3" /> + style="fill-rule:nonzero;stroke:#1155cc;stroke-width:0.99953708;stroke-linecap:butt;stroke-dasharray:none" /> + @@ -275,32 +323,37 @@ inkscape:connector-curvature="0" style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + @@ -975,10 +1028,11 @@ inkscape:connector-curvature="0" style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + style="fill-rule:evenodd;stroke:#595959;stroke-width:1.2253;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:9.80238, 3.67589" + sodipodi:nodetypes="cssscc" /> + style="fill-rule:evenodd;stroke:#595959;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:8, 3" + sodipodi:nodetypes="cssscc" /> + style="fill-rule:evenodd;stroke:#595959;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:8, 3" + sodipodi:nodetypes="cssc" /> @@ -1020,10 +1076,11 @@ inkscape:connector-curvature="0" style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + style="fill-rule:evenodd;stroke:#595959;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:8, 3" + sodipodi:nodetypes="cssssscc" /> + + + + + + + nb_errors + Error 1 + Error 2 + Error 3 + Error n + + + + + + diff --git a/doc/guides/prog_guide/img/graph_mem_layout.svg b/doc/guides/prog_guide/img/graph_mem_layout.svg index 1d41729c9c..042c7fcb0d 100644 --- a/doc/guides/prog_guide/img/graph_mem_layout.svg +++ b/doc/guides/prog_guide/img/graph_mem_layout.svg @@ -3,700 +3,1141 @@ - - - - image/svg+xml - - - - - - + id="svg1" + inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)" + sodipodi:docname="graph_mem_layout.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> - - - + inkscape:current-layer="layer1"> + + + + + + + + + + + + + + + + + + + + + + + - - - + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + + + + + id="path286" + style="fill:none" /> + + + id="path338" + style="fill:none" /> + + + + + + + + Node 1 Errors + Node 1 + Error 1 + Error 1 + Error 1 + Error 2 + Error 2 + Error 2 + Error N + Error 3 + Error 3 + Error 4 + Node 4 + Node 8 + Node N + Node 4 Errors + Node 8 Errors + Node N Errors + + rte_node error memory layout + + + + + + + + + + + + diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index fb88d4bc84..eb4d461c6e 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -62,6 +62,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. */ char next_nodes[][RTE_NODE_NAMESIZE]; /**< Names of next nodes. */ }; diff --git a/lib/graph/node.c b/lib/graph/node.c index 99a9622779..be96005a9e 100644 --- a/lib/graph/node.c +++ b/lib/graph/node.c @@ -85,9 +85,24 @@ __rte_node_register(const struct rte_node_register *reg) goto fail; } + if (reg->errs) { + sz = sizeof(*reg->errs) + (reg->errs->nb_errors * RTE_NODE_ERROR_DESC_SIZE); + node->errs = calloc(1, sz); + if (node->errs == NULL) { + rte_errno = ENOMEM; + goto free; + } + + node->errs->nb_errors = reg->errs->nb_errors; + for (i = 0; i < reg->errs->nb_errors; i++) + if (rte_strscpy(node->errs->err_desc[i], reg->errs->err_desc[i], + RTE_NODE_ERROR_DESC_SIZE) < 0) + goto free_err; + } + /* Initialize the node */ if (rte_strscpy(node->name, reg->name, RTE_NODE_NAMESIZE) < 0) - goto free; + goto free_err; node->flags = reg->flags; node->process = reg->process; node->init = reg->init; @@ -97,7 +112,7 @@ __rte_node_register(const struct rte_node_register *reg) for (i = 0; i < reg->nb_edges; i++) { if (rte_strscpy(node->next_nodes[i], reg->next_nodes[i], RTE_NODE_NAMESIZE) < 0) - goto free; + goto free_err; } node->lcore_id = RTE_MAX_LCORE; @@ -108,6 +123,8 @@ __rte_node_register(const struct rte_node_register *reg) graph_spinlock_unlock(); return node->id; +free_err: + free(node->errs); free: free(node); fail: @@ -134,6 +151,20 @@ node_clone(struct node *node, const char *name) goto fail; } + if (node->errs) { + reg->errs = calloc(1, sizeof(*node->errs) + + (node->errs->nb_errors * RTE_NODE_ERROR_DESC_SIZE)); + if (reg->errs == NULL) { + rte_errno = ENOMEM; + goto fail; + } + + for (i = 0; i < node->errs->nb_errors; i++) + if (rte_strscpy(reg->errs->err_desc[i], node->errs->err_desc[i], + RTE_NODE_ERROR_DESC_SIZE) < 0) + goto free_err; + } + /* Clone the source node */ reg->flags = node->flags; reg->process = node->process; @@ -150,6 +181,8 @@ node_clone(struct node *node, const char *name) goto free; rc = __rte_node_register(reg); +free_err: + free(reg->errs); free: free(reg); fail: diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index 2d37d5e0d6..70b68673c1 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_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. */ +}; + /** * 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. */ rte_node_t id; /**< Node Identifier. */ rte_node_t parent_id; /**< Identifier of parent node. */ rte_edge_t nb_edges; /**< Number of edges from this node. */