1
2
3
4
5#ifndef _HNS3_TM_H_
6#define _HNS3_TM_H_
7
8#include <stdint.h>
9#include <rte_tailq.h>
10#include <rte_tm_driver.h>
11
12struct hns3_port_limit_rate_cmd {
13 uint32_t speed;
14 uint32_t rsvd[5];
15};
16
17struct hns3_tc_limit_rate_cmd {
18 uint32_t speed;
19 uint8_t tc_id;
20 uint8_t rsvd[3];
21 uint32_t rsvd1[4];
22};
23
24enum hns3_tm_node_type {
25 HNS3_TM_NODE_TYPE_PORT,
26 HNS3_TM_NODE_TYPE_TC,
27 HNS3_TM_NODE_TYPE_QUEUE,
28 HNS3_TM_NODE_TYPE_MAX,
29};
30
31enum hns3_tm_node_level {
32 HNS3_TM_NODE_LEVEL_PORT,
33 HNS3_TM_NODE_LEVEL_TC,
34 HNS3_TM_NODE_LEVEL_QUEUE,
35 HNS3_TM_NODE_LEVEL_MAX,
36};
37
38struct hns3_tm_shaper_profile {
39 TAILQ_ENTRY(hns3_tm_shaper_profile) node;
40 uint32_t shaper_profile_id;
41 uint32_t reference_count;
42 struct rte_tm_shaper_params profile;
43};
44
45TAILQ_HEAD(hns3_shaper_profile_list, hns3_tm_shaper_profile);
46
47struct hns3_tm_node {
48 TAILQ_ENTRY(hns3_tm_node) node;
49 uint32_t id;
50 uint32_t reference_count;
51 struct hns3_tm_node *parent;
52 struct hns3_tm_shaper_profile *shaper_profile;
53 struct rte_tm_node_params params;
54};
55
56TAILQ_HEAD(hns3_tm_node_list, hns3_tm_node);
57
58struct hns3_tm_conf {
59 uint32_t nb_leaf_nodes_max;
60 uint32_t nb_nodes_max;
61 uint32_t nb_shaper_profile_max;
62
63 struct hns3_shaper_profile_list shaper_profile_list;
64 uint32_t nb_shaper_profile;
65
66 struct hns3_tm_node *root;
67 struct hns3_tm_node_list tc_list;
68 struct hns3_tm_node_list queue_list;
69 uint32_t nb_tc_node;
70 uint32_t nb_queue_node;
71
72
73
74
75
76
77
78
79
80
81 bool committed;
82};
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98static inline uint8_t
99hns3_tm_calc_node_tc_no(struct hns3_tm_conf *conf, uint32_t node_id)
100{
101 if (node_id >= conf->nb_leaf_nodes_max &&
102 node_id < conf->nb_nodes_max - 1)
103 return node_id - conf->nb_leaf_nodes_max;
104 else
105 return 0;
106}
107
108void hns3_tm_conf_init(struct rte_eth_dev *dev);
109void hns3_tm_conf_uninit(struct rte_eth_dev *dev);
110int hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg);
111void hns3_tm_dev_start_proc(struct hns3_hw *hw);
112void hns3_tm_dev_stop_proc(struct hns3_hw *hw);
113int hns3_tm_conf_update(struct hns3_hw *hw);
114
115#endif
116