From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C3460457E5; Fri, 16 Aug 2024 17:10:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D639042E59; Fri, 16 Aug 2024 17:10:01 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 87566427C7 for ; Fri, 16 Aug 2024 17:09:58 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47GEr7lY007089; Fri, 16 Aug 2024 08:09:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=y XEMf0jT3DA5zXWuOT1fvBGeDc0kkqQ0Uwf3auzLzqY=; b=UWLvHuY9MUDZ2X8wS eyO3KVCHzUta9IEgDIwsgImM6gkJg0e3dr+Eq6FKEIHRrzEkgL1KQ2ViOOgszr8/ T0/PI/ixnYaoYQcf9Yns0iRJFWrWHo2235I5vNwfprpKZHbuesZJPCDm3M9WYR2K j6JGrI1ZpZLrCC4pPb3wY4nCkXn0OsYmjL50S57fb4FWBUooLUZt19ZTIDkBhjXM VDGEyG545Gql+AYygulGY9k9ryDC4BtKIjyk1DcaeWf6YmtZ2VIrOgydn44i4X6z Mmtdecu/8yRnVW1kFSiprXijvYNBdaGKpmaCneNMes27qQOILCkP86Jvy+bo5jKC gVVkA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4128wrr3ab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Aug 2024 08:09:47 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 16 Aug 2024 08:09:45 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 16 Aug 2024 08:09:45 -0700 Received: from MININT-80QBFE8.corp.innovium.com (MININT-80QBFE8.marvell.com [10.28.164.106]) by maili.marvell.com (Postfix) with ESMTP id B0CA43F7085; Fri, 16 Aug 2024 08:09:39 -0700 (PDT) From: To: , , , , Zhirun Yan CC: , Pavan Nikhilesh Subject: [PATCH v4 1/5] graph: add support for node specific errors Date: Fri, 16 Aug 2024 20:39:22 +0530 Message-ID: <20240816150926.5789-1-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240222122342.16375-1-pbhagavatula@marvell.com> References: <20240222122342.16375-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Proofpoint-ORIG-GUID: IyJmGxqmGVtfvmewRJlQg5CjOjEZokn8 X-Proofpoint-GUID: IyJmGxqmGVtfvmewRJlQg5CjOjEZokn8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-16_09,2024-08-16_01,2024-05-17_01 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. 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/gr= aph_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 sou= rce 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 gr= aph. +functions can link them together to create a complex packet processing gra= ph. 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 r= te_node_register::nb_edges``. This is a use case to address the static node scheme where one knows upfro= nt the ``next_nodes[]`` of the node. @@ -385,8 +398,9 @@ Understanding the memory layout helps to debug the grap= h 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 functio= ns 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/p= rog_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=3D"1.3.2 (091e20e, 2023-11-25, custom)" + xmlns:inkscape=3D"http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi=3D"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns=3D"http://www.w3.org/2000/svg" + xmlns:svg=3D"http://www.w3.org/2000/svg" + xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc=3D"http://creativecommons.org/ns#" + xmlns:dc=3D"http://purl.org/dc/elements/1.1/"> @@ -27,12 +27,51 @@ image/svg+xml - + + id=3D"defs423"> + + + + + + + + + + inkscape:current-layer=3D"g417" + inkscape:showpageshadow=3D"2" + inkscape:pagecheckerboard=3D"0" + inkscape:deskcolor=3D"#d1d1d1" + inkscape:lockguides=3D"true" /> + style=3D"fill:#ffffff;fill-rule:evenodd;fill-opacity:1" /> @@ -90,87 +133,92 @@ inkscape:connector-curvature=3D"0" style=3D"fill-rule:evenodd;stroke:#c27ba0;stroke-width:1;stroke-lin= ecap:butt;stroke-linejoin:round;stroke-dasharray:4, 3, 1, 3" /> + style=3D"fill-rule:nonzero;stroke:#1155cc;stroke-width:0.99953708;s= troke-linecap:butt;stroke-dasharray:none" /> + @@ -275,32 +323,37 @@ inkscape:connector-curvature=3D"0" style=3D"fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + @@ -975,10 +1028,11 @@ inkscape:connector-curvature=3D"0" style=3D"fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + style=3D"fill-rule:evenodd;stroke:#595959;stroke-width:1.2253;strok= e-linecap:butt;stroke-linejoin:round;stroke-dasharray:9.80238, 3.67589" + sodipodi:nodetypes=3D"cssscc" /> + style=3D"fill-rule:evenodd;stroke:#595959;stroke-width:1;stroke-lin= ecap:butt;stroke-linejoin:round;stroke-dasharray:8, 3" + sodipodi:nodetypes=3D"cssscc" /> + style=3D"fill-rule:evenodd;stroke:#595959;stroke-width:1;stroke-lin= ecap:butt;stroke-linejoin:round;stroke-dasharray:8, 3" + sodipodi:nodetypes=3D"cssc" /> @@ -1020,10 +1076,11 @@ inkscape:connector-curvature=3D"0" style=3D"fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + style=3D"fill-rule:evenodd;stroke:#595959;stroke-width:1;stroke-lin= ecap:butt;stroke-linejoin:round;stroke-dasharray:8, 3" + sodipodi:nodetypes=3D"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/pr= og_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=3D"svg1" + inkscape:version=3D"1.3.2 (091e20e, 2023-11-25, custom)" + sodipodi:docname=3D"graph_mem_layout.svg" + xmlns:inkscape=3D"http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi=3D"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink=3D"http://www.w3.org/1999/xlink" + xmlns=3D"http://www.w3.org/2000/svg" + xmlns:svg=3D"http://www.w3.org/2000/svg"> - - - + inkscape:current-layer=3D"layer1"> + + + + + + + + + + + + + + + + + + + + + + + - - - + inkscape:label=3D"Layer 1" + inkscape:groupmode=3D"layer" + id=3D"layer1"> + + + + + id=3D"path286" + style=3D"fill:none" /> + + + id=3D"path338" + style=3D"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 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. */ 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 =3D sizeof(*reg->errs) + (reg->errs->nb_errors * RTE_NODE_ERROR_DESC_= SIZE); + node->errs =3D calloc(1, sz); + if (node->errs =3D=3D NULL) { + rte_errno =3D ENOMEM; + goto free; + } + + node->errs->nb_errors =3D reg->errs->nb_errors; + for (i =3D 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 =3D reg->flags; node->process =3D reg->process; node->init =3D reg->init; @@ -97,7 +112,7 @@ __rte_node_register(const struct rte_node_register *reg) for (i =3D 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 =3D 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 =3D calloc(1, sizeof(*node->errs) + + (node->errs->nb_errors * RTE_NODE_ERROR_DESC_SIZE)); + if (reg->errs =3D=3D NULL) { + rte_errno =3D ENOMEM; + goto fail; + } + + for (i =3D 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 =3D node->flags; reg->process =3D node->process; @@ -150,6 +181,8 @@ node_clone(struct node *node, const char *name) goto free; rc =3D __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 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_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_clus= ter_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. */ -- 2.25.1