> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zh...@intel.com>
> Sent: Friday, January 5, 2024 10:11 PM
> To: Yang, Qiming <qiming.y...@intel.com>; Wu, Wenjun1
> <wenjun1...@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zh...@intel.com>
> Subject: [PATCH v2 2/3] net/ice: refactor tm config data structure
> 
> Simplified struct ice_tm_conf by removing per level node list.
> 
> Signed-off-by: Qi Zhang <qi.z.zh...@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.h |   5 +-
>  drivers/net/ice/ice_tm.c     | 210 +++++++++++++++--------------------
>  2 files changed, 88 insertions(+), 127 deletions(-)
> 
> 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 = NULL;
> -     TAILQ_INIT(&pf->tm_conf.qgroup_list);
> -     TAILQ_INIT(&pf->tm_conf.queue_list);
> -     pf->tm_conf.nb_qgroup_node = 0;
> -     pf->tm_conf.nb_queue_node = 0;
>       pf->tm_conf.committed = false;
>       pf->tm_conf.clear_on_fail = false;
>  }
> 
> -void
> -ice_tm_conf_uninit(struct rte_eth_dev *dev)
> +static void free_node(struct ice_tm_node *root)
>  {
> -     struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data-
> >dev_private);
> -     struct ice_tm_node *tm_node;
> +     uint32_t i;
> 
> -     /* clear node configuration */
> -     while ((tm_node = 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 = 0;
> -     while ((tm_node = 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 = 0;
> -     if (pf->tm_conf.root) {
> -             rte_free(pf->tm_conf.root);
> -             pf->tm_conf.root = NULL;
> -     }
> +     if (root == NULL)
> +             return;
> +
> +     for (i = 0; i < root->reference_count; i++)
> +             free_node(root->children[i]);
> +
> +     rte_free(root);


The memory of point array for children should also be freed.

rte_free(root->children)

As the patch has been acked, I will squash the fix when merging the patch.


Reply via email to