From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C1A4A0562; Fri, 3 Apr 2020 12:54:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C8CF31C12F; Fri, 3 Apr 2020 12:54:29 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id AD4C31C12A for ; Fri, 3 Apr 2020 12:54:28 +0200 (CEST) IronPort-SDR: 20W5Nr2o+Zq6kCt/e6u6yO11RoyfA4iOLu9nh5rNrap9VL1KB/NFsuVAa7Kegbrf/XfV9Tqw0L culgtYf2e72w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 03:54:27 -0700 IronPort-SDR: 1YEjtsvaEKFdzZLeXDwf/i+pX2GH8qaGS1fOUwLCRtBKf1NeGHCLcYf7AjMxz3APq+5lM4+FsK KaOHv81PoV9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,339,1580803200"; d="scan'208";a="449991226" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by fmsmga005.fm.intel.com with ESMTP; 03 Apr 2020 03:54:26 -0700 Received: from orsmsx122.amr.corp.intel.com (10.22.225.227) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 3 Apr 2020 03:54:26 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX122.amr.corp.intel.com (10.22.225.227) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 3 Apr 2020 03:54:26 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 3 Apr 2020 03:54:26 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PRhXEly6El9JoQ0yp5YCVFm8IlVkgDHs0KlVoGHOe59AKOlkDuCXDQ83PKofUstAfPo6uTTiLbg3G1QCaSzY9jChzZb7A6nA98pAeSTeHFEaABdMGPWLrF5mPGKu/NR2DGBNR898uKx8yDyPhXvfjH3A9gG5CGOB+OdkTZsxOb/+4d0GUJ386SXUv8DGEB5vXqn5xjyxMhWYVQYwgUVuiansPp9PGoPtykQW6EX+XdOunrVJIVDgqC9zLhDrYrwwTCpy+TZKqBt/2YlTLI8Tl6CBJBU0dLC/w1yb5yH02M6gKQ+iqB0DTH6sIFQhTJgmgw3Q+KUdI2+RaQtgWesVlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q0ir+9ZemUnKH80OzLoCdIS3cvdCB7vYVHpWbG0bVkA=; b=OhldV3NDhwM5A602IIqIb19euWWqYaF9f7YTFkXJWzG9HXxI1oVi/jE4TYx2cyD+14ZI03a1HMJQ0tEz3y0ChwnZ6lpDKOFkUVwxhnfsV5LYEX6yDpZX0vpzt/fV8WxiX2KI8cl7t81kL2XsAxtWV0nXQSinoyMCNaXlMpk47tfUD/dXA+zs1b3eWTcmx54yCW+B2VlxFRICFNnRvpWJnreCwBXmD1/io66bV/GaD+X+w1LWfBir2/aDfwESPDXGcAU6bmOPQth0AGz5MflS6/CKOFCD1ABflhcKvJ8p6dlO0lJGO396E4GLa9W4wMP8z5xrFhB7H5hALr2VUzxzjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q0ir+9ZemUnKH80OzLoCdIS3cvdCB7vYVHpWbG0bVkA=; b=E4w94FdROcb5/Sj3JapxKMZg97XbQnzEmJa/fKRepJ/XAKPCeXMHYTzTCaUhHRW7r8YZzXwnRv82+eyDbkNmNbU4jxdmMTRiY6J+kyE2stSisvCnDKmB6peJc2ucOAeDcloQ5pNZ/421xE6rjwbznCcNmB42oSGfpWdT9mu4Sso= Received: from BN6PR11MB1473.namprd11.prod.outlook.com (2603:10b6:405:a::16) by BN6PR11MB1923.namprd11.prod.outlook.com (2603:10b6:404:107::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15; Fri, 3 Apr 2020 10:54:23 +0000 Received: from BN6PR11MB1473.namprd11.prod.outlook.com ([fe80::d013:5d99:e57e:570e]) by BN6PR11MB1473.namprd11.prod.outlook.com ([fe80::d013:5d99:e57e:570e%7]) with mapi id 15.20.2856.019; Fri, 3 Apr 2020 10:54:23 +0000 From: "Wang, Xiao W" To: "jerinj@marvell.com" , Kiran Kumar K CC: "dev@dpdk.org" , "thomas@monjalon.net" , "david.marchand@redhat.com" , "mdr@ashroe.eu" , "mattias.ronnblom@ericsson.com" , "pbhagavatula@marvell.com" , "ndabilpuram@marvell.com" Thread-Topic: [dpdk-dev] [PATCH v3 03/29] graph: implement node operations Thread-Index: AQHWB5LvNXMyK73OQE2/VoFvT9oibKhnOwOw Date: Fri, 3 Apr 2020 10:54:23 +0000 Message-ID: References: <20200326165644.866053-1-jerinj@marvell.com> <20200331192945.2466880-1-jerinj@marvell.com> <20200331192945.2466880-4-jerinj@marvell.com> In-Reply-To: <20200331192945.2466880-4-jerinj@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=xiao.w.wang@intel.com; x-originating-ip: [192.55.52.223] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4e8cc7a4-a8b7-4776-eae3-08d7d7bd5ef5 x-ms-traffictypediagnostic: BN6PR11MB1923: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2201; x-forefront-prvs: 0362BF9FDB x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR11MB1473.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(136003)(39860400002)(366004)(346002)(396003)(376002)(478600001)(26005)(4326008)(186003)(86362001)(55016002)(2906002)(9686003)(66476007)(81156014)(66556008)(33656002)(6506007)(54906003)(8676002)(7696005)(64756008)(8936002)(66946007)(316002)(71200400001)(5660300002)(110136005)(66446008)(52536014)(76116006)(53546011)(81166006); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6Ezen7iOIVDhlTEVdHcq83R6PPrhwhMtsQmmtQGFeXv922u0KUwG0Zns6AFXuHCv7lB9nE1mF0gXd/EV00z9CTzTskwkIiXF/f02G4erj17ombVRLCbUCFlDnCE81UtfBQQrVUUewEFbU1mfRCZMghX19FWrhdAfj+Fw647NBkRRvWKiCC7nRIxdRsXJFwJ0TCZjH8hhXmx1/fK7ldKBbN6ykdeN5bKnyhGrkD0ogRG335j0aWcwvgMlni8pIwOiAT3g7fLAPvquOJzBGFavJvkdAEp1vjOiLy7djMu73KjZJOHklk2YlM3il7wRbyjamx7MLMhnuzBMrT3bD3YIMYghPGLw3JbYK6qeMLX3JNvKWp2tX1srs/8Sc4MJNhXCTqHxqQjmq/cBQZHBbmsBmMbVV1ej7X2a3Q5RO6b7Cd93VyNIuCqxK6FkCkoGoz/g x-ms-exchange-antispam-messagedata: lYLsBTEZRpvydJj322Q3OYEFt/VpOC2Z3JGgyOqclKOh4eGZdRPpzyrRafOfLfj8Wx7EcPOf/RMLgMVs/aKbcTxhGkzw58mUE5AUw7we5uQn+CJGpdw/D4fwP5sP6IqwOBP7awEqj6eRYoQSqFd3YA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 4e8cc7a4-a8b7-4776-eae3-08d7d7bd5ef5 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Apr 2020 10:54:23.7290 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6zUiVuomVlFNQOLWsSO/NSsbMi7ZGfMKPPb3ns7/U10QVM4741oQLQyluBYZUkfAme+eIsT58Wa/bWqR4nXFPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1923 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 03/29] graph: implement node operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Jerin, Comment inline. Best Regards, Xiao > -----Original Message----- > From: dev On Behalf Of jerinj@marvell.com > Sent: Wednesday, April 1, 2020 3:29 AM > To: Jerin Jacob ; Kiran Kumar K > > Cc: dev@dpdk.org; thomas@monjalon.net; david.marchand@redhat.com; > mdr@ashroe.eu; mattias.ronnblom@ericsson.com; > pbhagavatula@marvell.com; ndabilpuram@marvell.com > Subject: [dpdk-dev] [PATCH v3 03/29] graph: implement node operations >=20 > From: Jerin Jacob >=20 > Adding node-specific API implementation like cloning node, updating > edges for the node, shrinking edges of a node, retrieving edges of a > node. >=20 > Signed-off-by: Jerin Jacob > Signed-off-by: Kiran Kumar K > Signed-off-by: Pavan Nikhilesh > Signed-off-by: Nithin Dabilpuram > --- > lib/librte_graph/graph_private.h | 10 + > lib/librte_graph/node.c | 269 +++++++++++++++++++++++++ > lib/librte_graph/rte_graph_version.map | 10 + > 3 files changed, 289 insertions(+) >=20 > diff --git a/lib/librte_graph/graph_private.h > b/lib/librte_graph/graph_private.h > index 8b9ff5292..7ed6d01b6 100644 > --- a/lib/librte_graph/graph_private.h > +++ b/lib/librte_graph/graph_private.h > @@ -13,6 +13,16 @@ >=20 > #include "rte_graph.h" >=20 > + > +#define ID_CHECK(id, id_max) = \ > + do { = \ > + if ((id) >=3D (id_max)) { \ > + rte_errno =3D EINVAL; \ > + goto fail; \ > + } \ > + } while (0) > + > + [...] > +char * > +rte_node_id_to_name(rte_node_t id) > +{ > + struct node *node; > + > + NODE_ID_CHECK(id); > + STAILQ_FOREACH(node, &node_list, next) > + if (node->id =3D=3D id) > + return node->name; > + > +fail: > + return NULL; > +} > + > +rte_edge_t > +rte_node_edge_count(rte_node_t id) > +{ > + struct node *node; > + > + NODE_ID_CHECK(id); > + STAILQ_FOREACH(node, &node_list, next) > + if (node->id =3D=3D id) > + return node->nb_edges; > +fail: > + return RTE_EDGE_ID_INVALID; > +} > + > +static rte_edge_t > +edge_update(struct node *node, struct node *prev, rte_edge_t from, > + const char **next_nodes, rte_edge_t nb_edges) > +{ > + rte_edge_t i, max_edges, count =3D 0; > + struct node *new_node; > + bool need_realloc; > + size_t sz; > + > + if (from =3D=3D RTE_EDGE_ID_INVALID) > + from =3D node->nb_edges; > + > + /* Don't create hole in next_nodes[] list */ > + if (from > node->nb_edges) { > + rte_errno =3D ENOMEM; > + goto fail; > + } > + > + /* Remove me from list */ > + STAILQ_REMOVE(&node_list, node, node, next); > + > + /* Allocate the storage space for new node if required */ > + max_edges =3D from + nb_edges; > + need_realloc =3D max_edges > node->nb_edges; > + if (need_realloc) { > + sz =3D sizeof(struct node) + (max_edges * > RTE_NODE_NAMESIZE); > + new_node =3D realloc(node, sz); > + if (new_node =3D=3D NULL) { > + rte_errno =3D ENOMEM; > + goto restore; > + } else { > + node =3D new_node; > + } > + } > + > + /* Update the new nodes name */ > + for (i =3D from; i < max_edges; i++, count++) { > + if (rte_strscpy(node->next_nodes[i], next_nodes[count], > + RTE_NODE_NAMESIZE) < 0) { > + rte_errno =3D E2BIG; > + goto restore; > + } > + } > +restore: > + /* Update the linked list to point new node address in prev node */ > + if (prev) > + STAILQ_INSERT_AFTER(&node_list, prev, node, next); > + else > + STAILQ_INSERT_HEAD(&node_list, node, next); > + > + if (need_realloc) > + node->nb_edges +=3D count; If the "from" starts from somewhere in the middle of the edges, and also tr= iggers a realloc, then the new edge number should be: node->nb_edges =3D max_edges; > + > +fail: > + return count;