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 7ED404386C; Tue, 9 Jan 2024 05:51:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA4D640261; Tue, 9 Jan 2024 05:51:35 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 015434021F for ; Tue, 9 Jan 2024 05:51:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704775894; x=1736311894; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IXx8v0b+X+KquWnCsl4Yyd2t3Sc8jTetMQyAQW5QzdY=; b=B5usX37M19zOlt7zvvk8MW2RphGaVDXsGc/IGw1QtYFvIsBNwx9dLAQ7 7XgbXiSTdpJBLlvJ6PD+olwBm4JTwrjI4U9sLg/c5Xw+tMS0+iXokFZU7 xhFX+EbKVheym2jLeeOs8YwcX5hcG1v0hvWvrGhYlnnesD8z+W0OkiZJF RLbm0vnE+ALF74i7T224P6b134gX9lCnnEysCFkMG7OojpEbkygecXm+h HEkd3e6wF7lOoJEf01RmBTKRtcy9OZaxjmSAQfPQQbq0c2VGQ529lpTr+ YQe7AzmySYj9xU3LGKgF1pvRukUAxXhqCYOrWB2N/vPvSbexyMneFvPjX A==; X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="397787205" X-IronPort-AV: E=Sophos;i="6.04,181,1695711600"; d="scan'208";a="397787205" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 20:51:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="785090086" X-IronPort-AV: E=Sophos;i="6.04,181,1695711600"; d="scan'208";a="785090086" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga007.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 08 Jan 2024 20:51:31 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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 20:51:31 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) 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 20:51:30 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 20:51:30 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (192.55.55.71) 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 20:51:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8V+vw/gSV+8BB7P4MetRxtj89vPPHeKOLqVMGUhtB1BElxr7J7O1kLZvAiAM64H7oR9uKua7e6H7gVkkyDVFzrIZtYoIIMJr6Arie946OUPVUq29L81+tzlMWjeeTt2lYDtJOIifoM/ibT9rxdO35usw7kPEC+38jejmc0ShqdExnFQLBSBxqbqQufS8ZZA349lvp7AUo9yf3pn6fZL65UJvxO47xnbZOyrCVJKSgpwWRwVKZmO/T2qNHHM1MlogILtLs3lEJuiEe5pBHrNCGZVW46TVbMuPkK3Y2spyyA2Z2F+IVB5b535X6g/Q7MgTas3WmR0uChNk6H3PxXY+Q== 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=1bekLUerAMKSFN1lwMy6NX+S3weP9x7q3HJN3xv/kwE=; b=U1J6DPKZvjCQQGJHGoDn9nMffLleabCKR/gRMzGo+ACSXLHZg991KmCsyLHN85WE4b3BQ74akckVYRU+k5GkCcDTDXHeTM23mpAykk62X0irzb9g+JQNIfml2lZQD2N7BtbQAQCTpM7urGReeSLx1P8Gy/nJZxyWdPIMBTHi/3PRczqC+0ZpKBAJdVT7d2rDy7DJ5zRDltw03GpWWXTCkAO+x/xbBEzo8Ecs2FIuezpHMPeqK2wwa7MFKyO2FmR/NZBKc/6+niUTxykxixFjBcOz5pVbJG46ulOJ/DgbUUFU5YPXp/rZuTCoWOdy6J1RdIyz60QdAgXbt2WoymJK5Q== 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 IA0PR11MB7955.namprd11.prod.outlook.com (2603:10b6:208:3dd::6) by PH7PR11MB6748.namprd11.prod.outlook.com (2603:10b6:510:1b6::8) 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 04:51:27 +0000 Received: from IA0PR11MB7955.namprd11.prod.outlook.com ([fe80::1ec3:e3e7:c7e7:b89c]) by IA0PR11MB7955.namprd11.prod.outlook.com ([fe80::1ec3:e3e7:c7e7:b89c%7]) with mapi id 15.20.7159.020; Tue, 9 Jan 2024 04:51:27 +0000 From: "Wu, Wenjun1" To: "Zhang, Qi Z" , "Yang, Qiming" CC: "dev@dpdk.org" Subject: RE: [PATCH v4 2/3] net/ice: refactor tm config data structure Thread-Topic: [PATCH v4 2/3] net/ice: refactor tm config data structure Thread-Index: AQHaQilzsYY3fHQkpU6+jvwqLs2zFLDQ6pdw Date: Tue, 9 Jan 2024 04:51:27 +0000 Message-ID: References: <20240105211237.394105-1-qi.z.zhang@intel.com> <20240108202158.567910-1-qi.z.zhang@intel.com> <20240108202158.567910-3-qi.z.zhang@intel.com> In-Reply-To: <20240108202158.567910-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: IA0PR11MB7955:EE_|PH7PR11MB6748:EE_ x-ms-office365-filtering-correlation-id: 12c2b23a-3d42-4eb0-dbb2-08dc10cea3b3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hLuJhqskM/1BDfsIcGR/YRkuhUkCo6S5QkIQ17Wo2UWmyF0kdnzjQfZ1yx1KHDIMNh8Qo+BSUfhBwXlBcYFsZ8Ftv3CHXIO1EWlVOsu908bcU4DKaoOJ/3PtMW+winhv4p/dZh4xqS+nNJioFRN9ack1jZMPdrdKKggbPW6I5koF+n/evQyFyd9GTytkTf7aApyuFt7nLYUt665CFmJ+Ydy6nM11EPFJSqmha42ENdUhlbhNbhmaecR+Vi8zwP4lygpMoQ/LoQyKTSGoF1ez9OT0Jm+v8C1nJqQTb1Om+SHHFJwk7RyckxohuS7Ah2TD7xS8OwmNRss2bDZfKuX0Nm2XqWem4QTRWVG0r41VxeUQ6h5PjNsu7xtbgFmt0iZjLjDzY06r/iMfxBpOj5RuyJZoDtJnEPE51nZY418YOiBqCd0kCLR6mpX5LbVsHW5AGVsiIniTfnryzu+tyeVjrSMjeKiOT3t31uVEBPHv8aTZETdM0r5AhbXJpbBU5BLjnXPdzAOx8iocuJVrQbQQ0qwnEHbIic5jFCl0JPmwx8mjxiw/1iTbag0EW7Jq0wMPKx5K/r3UmA9Ty0ZJYDLHPD0selmUxpsusH6nFBi23nERWb4N6aze3o4gIPevmQGq x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:IA0PR11MB7955.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(396003)(366004)(136003)(376002)(346002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(30864003)(5660300002)(478600001)(71200400001)(33656002)(7696005)(86362001)(53546011)(9686003)(6506007)(8676002)(8936002)(41300700001)(110136005)(316002)(76116006)(66946007)(66556008)(66476007)(64756008)(6636002)(66446008)(122000001)(38100700002)(83380400001)(26005)(82960400001)(38070700009)(4326008)(52536014)(55016003)(2906002)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9yh3A0EOPyIupPjkQbYxH3qMsQfSQgwFUB4BoO3+mlTRzUeinfSt4w98MjtW?= =?us-ascii?Q?f2IqRDlJLfeozMVjuLWHg9DTMs+nsWjTeY9EwhUD5fnAbxcpcO+h6/STR+UC?= =?us-ascii?Q?2oZUkR8x8JXiSYwU2snGoTz13ZJX8NrTQzlh9gnw7jPGw6qEjCXEdL7b82Ea?= =?us-ascii?Q?KwIXxBNk2bQl072YHlq0h0N5ToBdw9Y/VmTacvCOAaaG+dBHu6sFJk0ftWjP?= =?us-ascii?Q?+YMnIagp+RKVgBW2aMfgtwocJUgjiF1n+lkvuVJT0JOIaHySaTMRaoa8bxSu?= =?us-ascii?Q?BfFLnu1AOIXDrF/O7df5GsTIZGOM4YPprZKGeg2bL4x5ZK2oWkbtS+78osQR?= =?us-ascii?Q?bDeINq7nFHnKkOxuVwxYzfsqKNy8hOHbB2TxO+pjiUQip65oNE4dzB1Jyw4d?= =?us-ascii?Q?lQrBOJDqKATfKgqOYDWR2eec6uNFl2yD8U7AP/bSQ6VmrKFa5bM23FvmmG5V?= =?us-ascii?Q?mWYeQe6s+au+WD7qXPq0udyeMvX1xFDeqacYlEAoWBVDm7DB5Z18N0X4IlR2?= =?us-ascii?Q?sHnb6NIPaCVY6maa0r1lU/ATMwWeiGQ6jrUtz+KC+SWqasSjFyIxWx6mlN/K?= =?us-ascii?Q?hA5VcCXwhgm4K68XBs0baS0tLMVvwMemQ4Qgwk5LMMirG/sLoxrHqEv8hTc3?= =?us-ascii?Q?1zmZteCpTDtdbWY7fasLpE2PE6yxa8TMqDIMyrvava4PJmvZIyQjWbkhHbGj?= =?us-ascii?Q?y15qRE2sXTzbCeOB+54fWFAd1Hsr6J2Kwhi7vOuIRdumwwcQKBpU/QF5lRrh?= =?us-ascii?Q?7qFNuSPXLeAxQSLS0/v3sQX6Ff/C4AI3VyeF40ikieTZ9uWCPeQyz/XtUUWd?= =?us-ascii?Q?XN9gjSBfYHzE5ylui8GMwcXrG0BZA7zmBoO+TzzC469Ebffc4Oi4cn3JOLuA?= =?us-ascii?Q?J9Hk36myAvTVOFGGkDCeI4VqkpsjRPxE+iOtZWsF/pslYQenPyoCi1XDBFA2?= =?us-ascii?Q?G3/J0IG69p5WF3QNy740CD4Pwo3/Cbtcgj3uzZVAYkn422I1Qp7esI+isqyC?= =?us-ascii?Q?AotPxQAjG8kxDu2TiKnKWLWyJ6klwDvKUmGrifjijPo4/tChMvmCWHYANpnd?= =?us-ascii?Q?uzNt69U4QkVwFmAM7W0mwDYgCXZM2QI/KIpXs0W5TWiOTBWRiDRqFev0T63k?= =?us-ascii?Q?rmfFPtxF6hSXNEzAfvKbslTjLGW21PGHQrlPG2h4N6eVPj7OCyopviWsKKvP?= =?us-ascii?Q?+6zYqEPnkWHau+cCUf0+7ijYdXuhgxbR8qCCaKJ33KT2a6owFVUr6aIOG/wm?= =?us-ascii?Q?4YHhNmayOeEe5NgAD47WP30qATJFDUPDyoe4fLUN7N0nfUypZ0WqhUfHoCBS?= =?us-ascii?Q?UU7YeaoLDk+aoOAl7YZUp9m0dGGSqaO/TN96szmInZCj3B5mJLGshVu7/ZX7?= =?us-ascii?Q?DYK1yNAITYQRobQCGWO7OFhL1tt7OF+5lFWGv9/x2sbOm8b/CLj4uTD7bIW7?= =?us-ascii?Q?yfREvesHe6yXiWTdD2XsjDI0snEWnwscJDh+LhDEHN9mBxqVIHqoShqoPBGU?= =?us-ascii?Q?PjSLWkEJJddAUBdj0l8JygluyCf3HF4pFYfan9p+v7MW7HZkgp/MXO/UITBg?= =?us-ascii?Q?WON3X+j4nGi0+NyImskApSXYViNiEOT0gDgRa3pU?= 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: IA0PR11MB7955.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12c2b23a-3d42-4eb0-dbb2-08dc10cea3b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jan 2024 04:51:27.5221 (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: i51rZbrwHGZmctYQ087DZluw98WtLK466o58ULG9sjja1gIa/peXvE702G0GD/CYskMCbkEr3XIkE7wSmSMT7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6748 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: Tuesday, January 9, 2024 4:22 AM > To: Yang, Qiming ; Wu, Wenjun1 > > Cc: dev@dpdk.org; Zhang, Qi Z > Subject: [PATCH v4 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 | 248 ++++++++++++++++------------------- > 2 files changed, 113 insertions(+), 140 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 > d67783c77e..fbab0b8808 100644 > --- a/drivers/net/ice/ice_tm.c > +++ b/drivers/net/ice/ice_tm.c > @@ -6,6 +6,9 @@ > #include "ice_ethdev.h" > #include "ice_rxtx.h" >=20 > +#define MAX_CHILDREN_PER_SCHED_NODE 8 > +#define MAX_CHILDREN_PER_TM_NODE 256 > + > static int ice_hierarchy_commit(struct rte_eth_dev *dev, > int clear_on_fail, > __rte_unused struct rte_tm_error *error); > @@ -43,20 +46,28 @@ 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 > +static void free_node(struct ice_tm_node *root) { > + uint32_t i; > + > + if (root =3D=3D NULL) > + return; > + > + for (i =3D 0; i < root->reference_count; i++) > + free_node(root->children[i]); > + > + rte_free(root); > +} > + > 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_shaper_profile *shaper_profile; > - struct ice_tm_node *tm_node; >=20 > /* clear profile */ > while ((shaper_profile =3D TAILQ_FIRST(&pf- > >tm_conf.shaper_profile_list))) { @@ -64,52 +75,8 @@ > ice_tm_conf_uninit(struct rte_eth_dev *dev) > rte_free(shaper_profile); > } >=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; > - } > -} > - > -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) > -{ > - 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; > - } > - > - 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 > @@ -202,11 +169,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) > @@ -219,14 +204,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; > @@ -348,8 +333,6 @@ ice_shaper_profile_del(struct rte_eth_dev *dev, > return 0; > } >=20 > -#define MAX_QUEUE_PER_GROUP 8 > - > static int > ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id, > uint32_t parent_node_id, uint32_t priority, @@ -358,8 +341,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; > @@ -374,7 +355,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; > @@ -409,17 +390,19 @@ ice_tm_node_add(struct rte_eth_dev *dev, > uint32_t node_id, > } >=20 > /* add the root node */ > - tm_node =3D rte_zmalloc("ice_tm_node", > - sizeof(struct ice_tm_node), > + tm_node =3D rte_zmalloc(NULL, > + sizeof(struct ice_tm_node) + > + sizeof(struct ice_tm_node *) * > MAX_CHILDREN_PER_TM_NODE, > 0); > 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; > - tm_node->children =3D (struct ice_tm_node **) > - rte_calloc(NULL, 256, (sizeof(struct ice_tm_node *)), > 0); > + tm_node->children =3D > + (void *)((uint8_t *)tm_node + sizeof(struct > ice_tm_node)); > rte_memcpy(&tm_node->params, params, > sizeof(struct rte_tm_node_params)); > pf->tm_conf.root =3D tm_node; > @@ -427,29 +410,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; @@ - > 458,7 +440,8 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t > node_id, > } > } else { > /* check the queue number */ > - if (parent_node->reference_count >=3D > MAX_QUEUE_PER_GROUP) { > + if (parent_node->reference_count >=3D > + MAX_CHILDREN_PER_SCHED_NODE) { > error->type =3D RTE_TM_ERROR_TYPE_NODE_ID; > error->message =3D "too many queues"; > return -EINVAL; > @@ -470,8 +453,9 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t > node_id, > } > } >=20 > - tm_node =3D rte_zmalloc("ice_tm_node", > - sizeof(struct ice_tm_node), > + tm_node =3D rte_zmalloc(NULL, > + sizeof(struct ice_tm_node) + > + sizeof(struct ice_tm_node *) * > MAX_CHILDREN_PER_TM_NODE, > 0); > if (!tm_node) > return -ENOMEM; > @@ -480,9 +464,10 @@ 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); > + tm_node->children =3D > + (void *)((uint8_t *)tm_node + sizeof(struct ice_tm_node)); > tm_node->parent->children[tm_node->parent->reference_count] =3D > tm_node; >=20 > if (tm_node->priority !=3D 0 && level_id !=3D ICE_TM_NODE_TYPE_QUEUE > && @@ -497,15 +482,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; > @@ -516,8 +492,8 @@ 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; > + uint32_t i, j; >=20 > if (!error) > return -EINVAL; > @@ -529,7 +505,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"; > @@ -545,21 +521,21 @@ 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; > } >=20 > /* queue group or queue node */ > + for (i =3D 0; i < tm_node->parent->reference_count; i++) > + if (tm_node->parent->children[i] =3D=3D tm_node) > + break; > + > + for (j =3D i ; j < tm_node->parent->reference_count - 1; j++) > + tm_node->parent->children[j] =3D tm_node->parent->children[j > + 1]; > + > 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; > @@ -720,9 +696,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 */ > @@ -732,8 +708,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 > @@ -786,9 +766,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; > @@ -819,14 +797,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 > @@ -837,13 +815,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) { > @@ -859,25 +851,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; > @@ -890,23 +882,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