78f4269643f529ea17f835ca5855e313ad9b88c8
[dpdk.git] / drivers / net / txgbe / txgbe_tm.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #include <rte_malloc.h>
6
7 #include "txgbe_ethdev.h"
8
9 void
10 txgbe_tm_conf_init(struct rte_eth_dev *dev)
11 {
12         struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
13
14         /* initialize shaper profile list */
15         TAILQ_INIT(&tm_conf->shaper_profile_list);
16
17         /* initialize node configuration */
18         tm_conf->root = NULL;
19         TAILQ_INIT(&tm_conf->queue_list);
20         TAILQ_INIT(&tm_conf->tc_list);
21         tm_conf->nb_tc_node = 0;
22         tm_conf->nb_queue_node = 0;
23         tm_conf->committed = false;
24 }
25
26 void
27 txgbe_tm_conf_uninit(struct rte_eth_dev *dev)
28 {
29         struct txgbe_tm_conf *tm_conf = TXGBE_DEV_TM_CONF(dev);
30         struct txgbe_tm_shaper_profile *shaper_profile;
31         struct txgbe_tm_node *tm_node;
32
33         /* clear node configuration */
34         while ((tm_node = TAILQ_FIRST(&tm_conf->queue_list))) {
35                 TAILQ_REMOVE(&tm_conf->queue_list, tm_node, node);
36                 rte_free(tm_node);
37         }
38         tm_conf->nb_queue_node = 0;
39         while ((tm_node = TAILQ_FIRST(&tm_conf->tc_list))) {
40                 TAILQ_REMOVE(&tm_conf->tc_list, tm_node, node);
41                 rte_free(tm_node);
42         }
43         tm_conf->nb_tc_node = 0;
44         if (tm_conf->root) {
45                 rte_free(tm_conf->root);
46                 tm_conf->root = NULL;
47         }
48
49         /* Remove all shaper profiles */
50         while ((shaper_profile =
51                TAILQ_FIRST(&tm_conf->shaper_profile_list))) {
52                 TAILQ_REMOVE(&tm_conf->shaper_profile_list,
53                              shaper_profile, node);
54                 rte_free(shaper_profile);
55         }
56 }
57