1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020-2020 Hisilicon Limited.
10 #include <rte_tm_driver.h>
12 enum hns3_tm_node_type {
13 HNS3_TM_NODE_TYPE_PORT,
15 HNS3_TM_NODE_TYPE_QUEUE,
16 HNS3_TM_NODE_TYPE_MAX,
19 enum hns3_tm_node_level {
20 HNS3_TM_NODE_LEVEL_PORT,
21 HNS3_TM_NODE_LEVEL_TC,
22 HNS3_TM_NODE_LEVEL_QUEUE,
23 HNS3_TM_NODE_LEVEL_MAX,
26 struct hns3_tm_shaper_profile {
27 TAILQ_ENTRY(hns3_tm_shaper_profile) node;
28 uint32_t shaper_profile_id;
29 uint32_t reference_count;
30 struct rte_tm_shaper_params profile;
33 TAILQ_HEAD(hns3_shaper_profile_list, hns3_tm_shaper_profile);
36 TAILQ_ENTRY(hns3_tm_node) node;
38 uint32_t reference_count;
39 struct hns3_tm_node *parent;
40 struct hns3_tm_shaper_profile *shaper_profile;
41 struct rte_tm_node_params params;
44 TAILQ_HEAD(hns3_tm_node_list, hns3_tm_node);
47 uint32_t nb_leaf_nodes_max; /* max numbers of leaf nodes */
48 uint32_t nb_nodes_max; /* max numbers of nodes */
49 uint32_t nb_shaper_profile_max; /* max numbers of shaper profile */
51 struct hns3_shaper_profile_list shaper_profile_list;
52 uint32_t nb_shaper_profile; /* number of shaper profile */
54 struct hns3_tm_node *root;
55 struct hns3_tm_node_list tc_list;
56 struct hns3_tm_node_list queue_list;
57 uint32_t nb_tc_node; /* number of added TC nodes */
58 uint32_t nb_queue_node; /* number of added queue nodes */
61 * This flag is used to check if APP can change the TM node
63 * When it's true, means the configuration is applied to HW,
64 * APP should not add/delete the TM node configuration.
65 * When starting the port, APP should call the hierarchy_commit API to
66 * set this flag to true. When stopping the port, this flag should be
73 * This API used to calc node TC no. User must make sure the node id is in the
76 * User could call rte_eth_dev_info_get API to get port's max_tx_queues, The TM
77 * id's assignment should following the below rules:
78 * [0, max_tx_queues-1]: correspond queues's node id
79 * max_tx_queues + 0 : correspond TC0's node id
80 * max_tx_queues + 1 : correspond TC1's node id
82 * max_tx_queues + 7 : correspond TC7's node id
83 * max_tx_queues + 8 : correspond port's node id
87 hns3_tm_calc_node_tc_no(struct hns3_tm_conf *conf, uint32_t node_id)
89 if (node_id >= conf->nb_leaf_nodes_max &&
90 node_id < conf->nb_nodes_max - 1)
91 return node_id - conf->nb_leaf_nodes_max;
96 void hns3_tm_conf_init(struct rte_eth_dev *dev);
97 void hns3_tm_conf_uninit(struct rte_eth_dev *dev);
98 int hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg);
99 void hns3_tm_dev_start_proc(struct hns3_hw *hw);
100 void hns3_tm_dev_stop_proc(struct hns3_hw *hw);
101 int hns3_tm_conf_update(struct hns3_hw *hw);
103 #endif /* _HNS3_TM_H */