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 09A004386B; Tue, 9 Jan 2024 03:50:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8731440298; Tue, 9 Jan 2024 03:50:51 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 635074021F for ; Tue, 9 Jan 2024 03:50:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704768648; x=1736304648; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=r26afmU6SXDUoxNNua7ONCAG1Ry3xetbh87/xcE9KHE=; b=mI02IkV8ufwD7l8Ei+5LwKuspaHm5HJF01DwsiIzZyW/7SSS7XNfwwXV 1lQxcGsJxXJhm3cZQCuWy+KKqgpFNpnIVVbw9U79ilA69+SxO+fIgQ0Bw tkYzVsSVhawLqtMJ+WTWRo7j5T6OTcyAKig8+luI911+/cWVs7w7aAElg 4tBjAPvZy/ETa6fZMZyzz8hzA9p20EnGBE++8GFNaX9VEqEzCz6KgePIQ OXLv+3fNwsoXoxt9oNJ5m6+j+BqQUFQL5v7Bay8HeHdn/b+6vQYdSQ+m0 4+NOEdXfQHHFaSSQVh0x4H0Pd436IBJtDNEf27HO9vUmr0IcyQ7J06tIX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="462345397" X-IronPort-AV: E=Sophos;i="6.04,181,1695711600"; d="scan'208";a="462345397" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 18:50:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="757821942" X-IronPort-AV: E=Sophos;i="6.04,181,1695711600"; d="scan'208";a="757821942" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 08 Jan 2024 18:50:47 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 8 Jan 2024 18:50:47 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 8 Jan 2024 18:50:46 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 8 Jan 2024 18:50:46 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 8 Jan 2024 18:50:46 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApmzRZU/Aqj+BeFJftj2R+lExd0WWOyuGAXdMU48QJ0INb1Bcab+fnU4DjUJi8Vm4o87dO7nI87nGjBRyiR1RvSN06C0jMpPUG8U9tHsoZ7D1lfkl7dhh9ePsxIWYhl9+Ny1weABkGqeIAVNBFyIK0I3r2MGyfDPbg/ESudAV9WX6Vmh30zGf+7AS/39rklPLLsjnoHiZTX39W46ZAQtgDbLZfv8T81TcGONdUVAP49LMvQc7Otw8Ar5+h+5aAcuzF6+NtKvLHcn6KPGCQXV+Kn2cHQF4F38Gh7pfhRYkNe688jQah1dO/6CUyBg/6oUa1HcZOwmL/67ms/4FRIiAg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h9yJjDu7o9i3iSJKJiI9tWpfia//zDtibVv1Obsf5+k=; b=kBO7cxF8Yu/2p94rKj6vasc20j59Ci8Lr4LiIejNGubBjG/dCISdJi6S3ANOBlx2wNMnrDjtpwvgPuCUv8hFOLiuwr0MObwvA8u8AvZdBeSQcveAkwM75kGAKOp5JLqrL8spLwBJ8GM8bpMmwufrbk5xZcP5MrmCOxea64tMrJw/+zrWejTSr4/o3OA2ypyjxtLvq3G+RS9OYkx66nXcsBXhKWqZWxQizNXcxBW3wq5mFE3Ci51E6xyhdt7QgkxpbSDwI6Zno+ayeT+YRQz/OAIWYDwq5+qs1KDpE3GEqWQdW/sFagHn+PauyZ054gPPa4K3a0xU8TNbjNeFoKm9UA== 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 Received: from DS7PR11MB7951.namprd11.prod.outlook.com (2603:10b6:8:eb::13) by IA1PR11MB7319.namprd11.prod.outlook.com (2603:10b6:208:425::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Tue, 9 Jan 2024 02:50:44 +0000 Received: from DS7PR11MB7951.namprd11.prod.outlook.com ([fe80::140b:c837:6099:c810]) by DS7PR11MB7951.namprd11.prod.outlook.com ([fe80::140b:c837:6099:c810%4]) with mapi id 15.20.7159.020; Tue, 9 Jan 2024 02:50:44 +0000 From: "Wu, Wenjun1" To: "Zhang, Qi Z" , "Yang, Qiming" CC: "dev@dpdk.org" Subject: RE: [PATCH v2 2/3] net/ice: refactor tm config data structure Thread-Topic: [PATCH v2 2/3] net/ice: refactor tm config data structure Thread-Index: AQHaP5osDXzr07TwOkOJYw5VFChgIbDQzW2A Date: Tue, 9 Jan 2024 02:50:44 +0000 Message-ID: References: <20240105135906.383394-1-qi.z.zhang@intel.com> <20240105141120.384681-1-qi.z.zhang@intel.com> <20240105141120.384681-3-qi.z.zhang@intel.com> In-Reply-To: <20240105141120.384681-3-qi.z.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR11MB7951:EE_|IA1PR11MB7319:EE_ x-ms-office365-filtering-correlation-id: 97a1f80f-3942-4e88-6054-08dc10bdc6b3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sfTt/ny8AP9x/Fx3xqbm0rVR84le2O+IB0b4+3QO2In8OILtw1hu1bxRkui2R4FpdRKKocZNd3Ws+YcdHqRqwIQBzW9dpyG31mJO9acu/RLMOcsNI13lMzyvf2TSQhGdkYqMlyOl0wjcHQCHm1mmmmoLzg5AO8uzfgHeWmPpcEe5C3xUMaiabrzffVzWUNSvmSk1GrHT2fOW3+qKlZUeVUbcMZ40YlaDyrivGK4PdOcOaQx7BiJ9+nvPFhHHmSTwMry8/pnWNEaGyrLNexvYwQGZn7FbCgurKA+WS3ZbaLc25Zq0VtOv4boz6UDKRBHbEXqE4Lz86xOa/xNr9EUAZkXBb5WLBuw9/TXVew0iwYGyLK6M57poxLE6RsCDtJrjPnTGtvMc9e7aDdjK6xY/QFQSTLlrjc0twPHpxELyHWNRL1tPjgVerb83Uy1mvnd6Wuj6rr84LW/1ej+YLYpWvuSgCOGzMs3omHvP2npnNGRwQUzmbNdJFG7QRj0iF2IWAxa+cUfjpQVlmiB7re3DGaX6MCqaPygZMHQiWKmzXP0jqFFGW1ZnnxzLOdoFDf3JkurCwFPeFZR0Up8jjFcLxweHIQj/oSPHRHF0SdzLxedKS68iVfJRcI8TaYSlNYwV x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR11MB7951.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(136003)(346002)(396003)(39860400002)(376002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(6506007)(53546011)(9686003)(478600001)(71200400001)(26005)(7696005)(83380400001)(5660300002)(316002)(41300700001)(2906002)(30864003)(64756008)(66476007)(76116006)(4326008)(66946007)(66556008)(66446008)(110136005)(8936002)(52536014)(8676002)(38070700009)(6636002)(38100700002)(122000001)(33656002)(86362001)(82960400001)(55016003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Qkmhq5oIyzjE3WaOLDcPQl8wDzSL2aaiVlVfXlN9mYMklJknB9A7m8ztPNz+?= =?us-ascii?Q?WZTI4MiSTeJHls12pWICMnv2gtcFLkBRwZfVnYdELBDF5qAKKSA/aPDflY6v?= =?us-ascii?Q?Jpi9738a+QZMSDXoips0Shov22fPnXfzx3m2COxBgj2NtiurNzxj7/Y/XaVi?= =?us-ascii?Q?Jv3XHQDSBXCDxxY1WmycCuFJpKfUYppYgA0It6hevvvNmypb9BYT43UD7IAg?= =?us-ascii?Q?jRtFxg6QzNVG4hZ+0EB1FItqKGdVjYz6xYHZ7nlv3su6/M5YFZnrP3zaQ18E?= =?us-ascii?Q?FxLYLj3jljGtcDwEBtyUh5uUUNIXr1+hEWreldJXLpiVmWpmQcOOX9vOCPC7?= =?us-ascii?Q?XaNddXra+znw2MgDq8V+S36c/9c0nhdHKar4iZ39/3s8lGCebSTaWnNk5XBY?= =?us-ascii?Q?IrVGiktqhBJ6s26CmDp6ABjLIuNvsFzlAVEg1WueWvNzOZ/4EcoSdpubqL+Q?= =?us-ascii?Q?s6s/ecXZ9uzMulnFacc8FfsCxk6hR9WgUaKlAxMsX1sEjV+JEZaY4Jw2wAdg?= =?us-ascii?Q?7D96qHN8cxMDfSTjxc9rn0STuq+VeWtshc6vtwlUftBxDmTYAT95CrCFXorI?= =?us-ascii?Q?CD0mJIrd9pUDTlmhNKvvIDtuKLqmZ11L1lasZCL7JvmXHomZoznfi8onVi/c?= =?us-ascii?Q?GlPVei6yL0rBqLZbns/R/bcjaA651FtS73vEKfU8ug+k+vL2rIHZtktSsmb0?= =?us-ascii?Q?JPzGv2vjZaGRVy/RYjHN3T6XUD8dPOx3eEOTC3nUUF7esJMeVTdP9qMxtBav?= =?us-ascii?Q?+36w01Ifu8mHrTwYoB+WHop6AT/1A+jDgdhAvRhNE2YAenL3SCNJFzG1KTQV?= =?us-ascii?Q?5mqHbGu85MeqtaEqtqFjbijgyZByQgNiV+fQc429x3GBISpcICZXuAmPucMZ?= =?us-ascii?Q?MLd6b5awouZW/uVx4jpbssJRAdaeUfnVQ+GFshbgX0ft9HdZgZtccF4kaByR?= =?us-ascii?Q?xbeIiGjEeUCOd8ukdYU5dnwFrt0YAKBcRPzM8WvDZLLQ0x5+B4K1f0SebFqq?= =?us-ascii?Q?qyB4hSHM8WA2VQv/+JmXGDVqnD0Ai9H3IlEsFzrT/xfrxGBJHZifWtGltszT?= =?us-ascii?Q?9LhlK7meB917Rc/8wIbcyW2bOhvg6VrhI+c9Yo2DY8eVX8+TLOrHqqj2J7xN?= =?us-ascii?Q?XJ9u/LBSPnNtnCPRBx1S05i7s5NYr10NmZVhEOQYeXwtdG7ZYb7/pyVJVT12?= =?us-ascii?Q?I0VFmruI0ctgP0VLqQKU1AeHCsrDqKAqx2KC7zzlRtDp0fO6OMlZKaDnp7Iv?= =?us-ascii?Q?BdNcOwfPTJSeSJWuN+gidxI2juW8atHyBO3PrNJOUNwWkalTcyInqzDwqVEt?= =?us-ascii?Q?VLWQ8iJeMR7vkgdMT43zKjZo6RB1dsIdTXkUiJ08VQxVOqCvcu+Jma3mdRfv?= =?us-ascii?Q?uTsT54syQ7m1/tpFFfdYJDjUFngkoErdOq+Qlwquolnq9Mtx0CnqHcH3xHdh?= =?us-ascii?Q?HGaAJMLUp899Ff3DRs8Dz3tt44Q3Xfxw37i3zzYey8DuUSek8oHAZviRSdE9?= =?us-ascii?Q?C5lEQ3YHbyIDLeZTcdVIcYoduM8i5gw5BOOYbhlW3dGeTDqkQSjoN4hlybNO?= =?us-ascii?Q?f7LMpFvXg3EvPrGa8jd6rY5E8NmV0yzvadAqL7gP?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB7951.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97a1f80f-3942-4e88-6054-08dc10bdc6b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jan 2024 02:50:44.7874 (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: jEH0wgsV6lnn1oPw1ys3ttgMUMfgvnztQNIvD5bF732w/IaM9GZ4ygPHoQdo7Ltea8Wv5rohiVOj7KkD9qDk+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB7319 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Zhang, Qi Z > Sent: Friday, January 5, 2024 10:11 PM > To: Yang, Qiming ; Wu, Wenjun1 > > Cc: dev@dpdk.org; Zhang, Qi Z > Subject: [PATCH v2 2/3] net/ice: refactor tm config data structure >=20 > Simplified struct ice_tm_conf by removing per level node list. >=20 > Signed-off-by: Qi Zhang > --- > drivers/net/ice/ice_ethdev.h | 5 +- > drivers/net/ice/ice_tm.c | 210 +++++++++++++++-------------------- > 2 files changed, 88 insertions(+), 127 deletions(-) >=20 > diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h = index > ae22c29ffc..008a7a23b9 100644 > --- a/drivers/net/ice/ice_ethdev.h > +++ b/drivers/net/ice/ice_ethdev.h > @@ -472,6 +472,7 @@ struct ice_tm_node { > uint32_t id; > uint32_t priority; > uint32_t weight; > + uint32_t level; > uint32_t reference_count; > struct ice_tm_node *parent; > struct ice_tm_node **children; > @@ -492,10 +493,6 @@ enum ice_tm_node_type { struct ice_tm_conf { > struct ice_shaper_profile_list shaper_profile_list; > struct ice_tm_node *root; /* root node - port */ > - struct ice_tm_node_list qgroup_list; /* node list for all the queue > groups */ > - struct ice_tm_node_list queue_list; /* node list for all the queues */ > - uint32_t nb_qgroup_node; > - uint32_t nb_queue_node; > bool committed; > bool clear_on_fail; > }; > diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c index > 7ae68c683b..7c662f8a85 100644 > --- a/drivers/net/ice/ice_tm.c > +++ b/drivers/net/ice/ice_tm.c > @@ -43,66 +43,30 @@ ice_tm_conf_init(struct rte_eth_dev *dev) > /* initialize node configuration */ > TAILQ_INIT(&pf->tm_conf.shaper_profile_list); > pf->tm_conf.root =3D NULL; > - TAILQ_INIT(&pf->tm_conf.qgroup_list); > - TAILQ_INIT(&pf->tm_conf.queue_list); > - pf->tm_conf.nb_qgroup_node =3D 0; > - pf->tm_conf.nb_queue_node =3D 0; > pf->tm_conf.committed =3D false; > pf->tm_conf.clear_on_fail =3D false; > } >=20 > -void > -ice_tm_conf_uninit(struct rte_eth_dev *dev) > +static void free_node(struct ice_tm_node *root) > { > - struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > - struct ice_tm_node *tm_node; > + uint32_t i; >=20 > - /* clear node configuration */ > - while ((tm_node =3D TAILQ_FIRST(&pf->tm_conf.queue_list))) { > - TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node); > - rte_free(tm_node); > - } > - pf->tm_conf.nb_queue_node =3D 0; > - while ((tm_node =3D TAILQ_FIRST(&pf->tm_conf.qgroup_list))) { > - TAILQ_REMOVE(&pf->tm_conf.qgroup_list, tm_node, node); > - rte_free(tm_node); > - } > - pf->tm_conf.nb_qgroup_node =3D 0; > - if (pf->tm_conf.root) { > - rte_free(pf->tm_conf.root); > - pf->tm_conf.root =3D NULL; > - } > + if (root =3D=3D NULL) > + return; > + > + for (i =3D 0; i < root->reference_count; i++) > + free_node(root->children[i]); > + > + rte_free(root); > } >=20 > -static inline struct ice_tm_node * > -ice_tm_node_search(struct rte_eth_dev *dev, > - uint32_t node_id, enum ice_tm_node_type *node_type) > +void > +ice_tm_conf_uninit(struct rte_eth_dev *dev) > { > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > - struct ice_tm_node_list *qgroup_list =3D &pf->tm_conf.qgroup_list; > - struct ice_tm_node_list *queue_list =3D &pf->tm_conf.queue_list; > - struct ice_tm_node *tm_node; > - > - if (pf->tm_conf.root && pf->tm_conf.root->id =3D=3D node_id) { > - *node_type =3D ICE_TM_NODE_TYPE_PORT; > - return pf->tm_conf.root; > - } >=20 > - TAILQ_FOREACH(tm_node, qgroup_list, node) { > - if (tm_node->id =3D=3D node_id) { > - *node_type =3D ICE_TM_NODE_TYPE_QGROUP; > - return tm_node; > - } > - } > - > - TAILQ_FOREACH(tm_node, queue_list, node) { > - if (tm_node->id =3D=3D node_id) { > - *node_type =3D ICE_TM_NODE_TYPE_QUEUE; > - return tm_node; > - } > - } > - > - return NULL; > + free_node(pf->tm_conf.root); > + pf->tm_conf.root =3D NULL; > } >=20 > static int > @@ -195,11 +159,29 @@ ice_node_param_check(struct ice_pf *pf, uint32_t > node_id, > return 0; > } >=20 > +static struct ice_tm_node * > +find_node(struct ice_tm_node *root, uint32_t id) { > + uint32_t i; > + > + if (root =3D=3D NULL || root->id =3D=3D id) > + return root; > + > + for (i =3D 0; i < root->reference_count; i++) { > + struct ice_tm_node *node =3D find_node(root->children[i], id); > + > + if (node) > + return node; > + } > + > + return NULL; > +} > + > static int > ice_node_type_get(struct rte_eth_dev *dev, uint32_t node_id, > int *is_leaf, struct rte_tm_error *error) { > - enum ice_tm_node_type node_type =3D ICE_TM_NODE_TYPE_MAX; > + struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > struct ice_tm_node *tm_node; >=20 > if (!is_leaf || !error) > @@ -212,14 +194,14 @@ ice_node_type_get(struct rte_eth_dev *dev, > uint32_t node_id, > } >=20 > /* check if the node id exists */ > - tm_node =3D ice_tm_node_search(dev, node_id, &node_type); > + tm_node =3D find_node(pf->tm_conf.root, node_id); > if (!tm_node) { > error->type =3D RTE_TM_ERROR_TYPE_NODE_ID; > error->message =3D "no such node"; > return -EINVAL; > } >=20 > - if (node_type =3D=3D ICE_TM_NODE_TYPE_QUEUE) > + if (tm_node->level =3D=3D ICE_TM_NODE_TYPE_QUEUE) > *is_leaf =3D true; > else > *is_leaf =3D false; > @@ -351,8 +333,6 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t > node_id, > struct rte_tm_error *error) > { > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > - enum ice_tm_node_type node_type =3D ICE_TM_NODE_TYPE_MAX; > - enum ice_tm_node_type parent_node_type =3D > ICE_TM_NODE_TYPE_MAX; > struct ice_tm_shaper_profile *shaper_profile =3D NULL; > struct ice_tm_node *tm_node; > struct ice_tm_node *parent_node; > @@ -367,7 +347,7 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t > node_id, > return ret; >=20 > /* check if the node is already existed */ > - if (ice_tm_node_search(dev, node_id, &node_type)) { > + if (find_node(pf->tm_conf.root, node_id)) { > error->type =3D RTE_TM_ERROR_TYPE_NODE_ID; > error->message =3D "node id already used"; > return -EINVAL; > @@ -408,6 +388,7 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t > node_id, > if (!tm_node) > return -ENOMEM; > tm_node->id =3D node_id; > + tm_node->level =3D ICE_TM_NODE_TYPE_PORT; > tm_node->parent =3D NULL; > tm_node->reference_count =3D 0; > tm_node->shaper_profile =3D shaper_profile; @@ -420,29 > +401,28 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id, > } >=20 > /* check the parent node */ > - parent_node =3D ice_tm_node_search(dev, parent_node_id, > - &parent_node_type); > + parent_node =3D find_node(pf->tm_conf.root, parent_node_id); > if (!parent_node) { > error->type =3D > RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID; > error->message =3D "parent not exist"; > return -EINVAL; > } > - if (parent_node_type !=3D ICE_TM_NODE_TYPE_PORT && > - parent_node_type !=3D ICE_TM_NODE_TYPE_QGROUP) { > + if (parent_node->level !=3D ICE_TM_NODE_TYPE_PORT && > + parent_node->level !=3D ICE_TM_NODE_TYPE_QGROUP) { > error->type =3D > RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID; > error->message =3D "parent is not valid"; > return -EINVAL; > } > /* check level */ > if (level_id !=3D RTE_TM_NODE_LEVEL_ID_ANY && > - level_id !=3D (uint32_t)parent_node_type + 1) { > + level_id !=3D parent_node->level + 1) { > error->type =3D RTE_TM_ERROR_TYPE_NODE_PARAMS; > error->message =3D "Wrong level"; > return -EINVAL; > } >=20 > /* check the node number */ > - if (parent_node_type =3D=3D ICE_TM_NODE_TYPE_PORT) { > + if (parent_node->level =3D=3D ICE_TM_NODE_TYPE_PORT) { > /* check the queue group number */ > if (parent_node->reference_count >=3D pf->dev_data- > >nb_tx_queues) { > error->type =3D RTE_TM_ERROR_TYPE_NODE_ID; @@ - > 473,6 +453,7 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t > node_id, > tm_node->weight =3D weight; > tm_node->reference_count =3D 0; > tm_node->parent =3D parent_node; > + tm_node->level =3D parent_node->level + 1; > tm_node->shaper_profile =3D shaper_profile; > tm_node->children =3D (struct ice_tm_node **) > rte_calloc(NULL, 256, (sizeof(struct ice_tm_node *)), > 0); @@ -490,15 +471,6 @@ ice_tm_node_add(struct rte_eth_dev *dev, > uint32_t node_id, >=20 > rte_memcpy(&tm_node->params, params, > sizeof(struct rte_tm_node_params)); > - if (parent_node_type =3D=3D ICE_TM_NODE_TYPE_PORT) { > - TAILQ_INSERT_TAIL(&pf->tm_conf.qgroup_list, > - tm_node, node); > - pf->tm_conf.nb_qgroup_node++; > - } else { > - TAILQ_INSERT_TAIL(&pf->tm_conf.queue_list, > - tm_node, node); > - pf->tm_conf.nb_queue_node++; > - } > tm_node->parent->reference_count++; >=20 > return 0; > @@ -509,7 +481,6 @@ ice_tm_node_delete(struct rte_eth_dev *dev, > uint32_t node_id, > struct rte_tm_error *error) > { > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > - enum ice_tm_node_type node_type =3D ICE_TM_NODE_TYPE_MAX; > struct ice_tm_node *tm_node; >=20 > if (!error) > @@ -522,7 +493,7 @@ ice_tm_node_delete(struct rte_eth_dev *dev, > uint32_t node_id, > } >=20 > /* check if the node id exists */ > - tm_node =3D ice_tm_node_search(dev, node_id, &node_type); > + tm_node =3D find_node(pf->tm_conf.root, node_id); > if (!tm_node) { > error->type =3D RTE_TM_ERROR_TYPE_NODE_ID; > error->message =3D "no such node"; > @@ -538,7 +509,7 @@ ice_tm_node_delete(struct rte_eth_dev *dev, > uint32_t node_id, > } >=20 > /* root node */ > - if (node_type =3D=3D ICE_TM_NODE_TYPE_PORT) { > + if (tm_node->level =3D=3D ICE_TM_NODE_TYPE_PORT) { > rte_free(tm_node); > pf->tm_conf.root =3D NULL; > return 0; > @@ -546,13 +517,6 @@ ice_tm_node_delete(struct rte_eth_dev *dev, > uint32_t node_id, >=20 > /* queue group or queue node */ > tm_node->parent->reference_count--; > - if (node_type =3D=3D ICE_TM_NODE_TYPE_QGROUP) { > - TAILQ_REMOVE(&pf->tm_conf.qgroup_list, tm_node, node); > - pf->tm_conf.nb_qgroup_node--; > - } else { > - TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node); > - pf->tm_conf.nb_queue_node--; > - } > rte_free(tm_node); >=20 > return 0; > @@ -708,9 +672,9 @@ static int ice_reset_noleaf_nodes(struct rte_eth_dev > *dev) { > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > - struct ice_tm_node_list *qgroup_list =3D &pf->tm_conf.qgroup_list; > struct ice_sched_node *vsi_node =3D ice_get_vsi_node(hw); > - struct ice_tm_node *tm_node; > + struct ice_tm_node *root =3D pf->tm_conf.root; > + uint32_t i; > int ret; >=20 > /* reset vsi_node */ > @@ -720,8 +684,12 @@ static int ice_reset_noleaf_nodes(struct rte_eth_dev > *dev) > return ret; > } >=20 > - /* reset queue group nodes */ > - TAILQ_FOREACH(tm_node, qgroup_list, node) { > + if (root =3D=3D NULL) > + return 0; > + > + for (i =3D 0; i < root->reference_count; i++) { > + struct ice_tm_node *tm_node =3D root->children[i]; > + > if (tm_node->sched_node =3D=3D NULL) > continue; >=20 > @@ -774,9 +742,7 @@ int ice_do_hierarchy_commit(struct rte_eth_dev > *dev, { > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > - struct ice_tm_node_list *qgroup_list =3D &pf->tm_conf.qgroup_list; > - struct ice_tm_node_list *queue_list =3D &pf->tm_conf.queue_list; > - struct ice_tm_node *tm_node; > + struct ice_tm_node *root; > struct ice_sched_node *vsi_node =3D NULL; > struct ice_sched_node *queue_node; > struct ice_tx_queue *txq; > @@ -807,14 +773,14 @@ int ice_do_hierarchy_commit(struct rte_eth_dev > *dev, >=20 > /* config vsi node */ > vsi_node =3D ice_get_vsi_node(hw); > - tm_node =3D pf->tm_conf.root; > + root =3D pf->tm_conf.root; >=20 > - ret_val =3D ice_set_node_rate(hw, tm_node, vsi_node); > + ret_val =3D ice_set_node_rate(hw, root, vsi_node); > if (ret_val) { > error->type =3D RTE_TM_ERROR_TYPE_UNSPECIFIED; > PMD_DRV_LOG(ERR, > "configure vsi node %u bandwidth failed", > - tm_node->id); > + root->id); > goto add_leaf; > } >=20 > @@ -825,13 +791,27 @@ int ice_do_hierarchy_commit(struct rte_eth_dev > *dev, > idx_vsi_child =3D 0; > idx_qg =3D 0; >=20 > - TAILQ_FOREACH(tm_node, qgroup_list, node) { > + if (root =3D=3D NULL) > + goto commit; > + > + for (i =3D 0; i < root->reference_count; i++) { > + struct ice_tm_node *tm_node =3D root->children[i]; > struct ice_tm_node *tm_child_node; > struct ice_sched_node *qgroup_sched_node =3D > vsi_node->children[idx_vsi_child]->children[idx_qg]; > + uint32_t j; >=20 > - for (i =3D 0; i < tm_node->reference_count; i++) { > - tm_child_node =3D tm_node->children[i]; > + ret_val =3D ice_cfg_hw_node(hw, tm_node, > qgroup_sched_node); > + if (ret_val) { > + error->type =3D RTE_TM_ERROR_TYPE_UNSPECIFIED; > + PMD_DRV_LOG(ERR, > + "configure queue group node %u failed", > + tm_node->id); > + goto reset_leaf; > + } > + > + for (j =3D 0; j < tm_node->reference_count; j++) { > + tm_child_node =3D tm_node->children[j]; > qid =3D tm_child_node->id; > ret_val =3D ice_tx_queue_start(dev, qid); > if (ret_val) { > @@ -847,25 +827,25 @@ int ice_do_hierarchy_commit(struct rte_eth_dev > *dev, > PMD_DRV_LOG(ERR, "get queue %u node > failed", qid); > goto reset_leaf; > } > - if (queue_node->info.parent_teid =3D=3D > qgroup_sched_node->info.node_teid) > - continue; > - ret_val =3D ice_move_recfg_lan_txq(dev, queue_node, > qgroup_sched_node, qid); > + if (queue_node->info.parent_teid !=3D > qgroup_sched_node->info.node_teid) { > + ret_val =3D ice_move_recfg_lan_txq(dev, > queue_node, > + > qgroup_sched_node, qid); > + if (ret_val) { > + error->type =3D > RTE_TM_ERROR_TYPE_UNSPECIFIED; > + PMD_DRV_LOG(ERR, "move > queue %u failed", qid); > + goto reset_leaf; > + } > + } > + ret_val =3D ice_cfg_hw_node(hw, tm_child_node, > queue_node); > if (ret_val) { > error->type =3D > RTE_TM_ERROR_TYPE_UNSPECIFIED; > - PMD_DRV_LOG(ERR, "move queue %u failed", > qid); > + PMD_DRV_LOG(ERR, > + "configure queue group node %u > failed", > + tm_node->id); > goto reset_leaf; > } > } >=20 > - ret_val =3D ice_cfg_hw_node(hw, tm_node, > qgroup_sched_node); > - if (ret_val) { > - error->type =3D RTE_TM_ERROR_TYPE_UNSPECIFIED; > - PMD_DRV_LOG(ERR, > - "configure queue group node %u failed", > - tm_node->id); > - goto reset_leaf; > - } > - > idx_qg++; > if (idx_qg >=3D nb_qg) { > idx_qg =3D 0; > @@ -878,23 +858,7 @@ int ice_do_hierarchy_commit(struct rte_eth_dev > *dev, > } > } >=20 > - /* config queue nodes */ > - TAILQ_FOREACH(tm_node, queue_list, node) { > - qid =3D tm_node->id; > - txq =3D dev->data->tx_queues[qid]; > - q_teid =3D txq->q_teid; > - queue_node =3D ice_sched_get_node(hw->port_info, q_teid); > - > - ret_val =3D ice_cfg_hw_node(hw, tm_node, queue_node); > - if (ret_val) { > - error->type =3D RTE_TM_ERROR_TYPE_UNSPECIFIED; > - PMD_DRV_LOG(ERR, > - "configure queue group node %u failed", > - tm_node->id); > - goto reset_leaf; > - } > - } > - > +commit: > pf->tm_conf.committed =3D true; > pf->tm_conf.clear_on_fail =3D clear_on_fail; >=20 > -- > 2.31.1 Acked-by: Wenjun Wu