This source file includes following definitions.
- nfp_abm_has_prio
- nfp_abm_has_drop
- nfp_abm_has_mark
1
2
3
4 #ifndef __NFP_ABM_H__
5 #define __NFP_ABM_H__ 1
6
7 #include <linux/bits.h>
8 #include <linux/list.h>
9 #include <linux/radix-tree.h>
10 #include <net/devlink.h>
11 #include <net/pkt_cls.h>
12 #include <net/pkt_sched.h>
13
14
15
16
17 #define NFP_ABM_STATS_REFRESH_IVAL (2500 * 1000)
18
19 #define NFP_ABM_LVL_INFINITY S32_MAX
20
21 struct nfp_app;
22 struct nfp_net;
23
24 #define NFP_ABM_PORTID_TYPE GENMASK(23, 16)
25 #define NFP_ABM_PORTID_ID GENMASK(7, 0)
26
27
28 enum nfp_abm_q_action {
29
30 NFP_ABM_ACT_MARK_DROP = 0,
31
32 NFP_ABM_ACT_MARK_QUEUE = 1,
33 NFP_ABM_ACT_DROP = 2,
34 NFP_ABM_ACT_QUEUE = 3,
35 NFP_ABM_ACT_NOQUEUE = 4,
36 };
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 struct nfp_abm {
64 struct nfp_app *app;
65 unsigned int pf_id;
66
67 unsigned int red_support;
68 unsigned int num_prios;
69 unsigned int num_bands;
70 unsigned int action_mask;
71
72 u32 *thresholds;
73 unsigned long *threshold_undef;
74 u8 *actions;
75 size_t num_thresholds;
76
77 unsigned int prio_map_len;
78 u8 dscp_mask;
79
80 enum devlink_eswitch_mode eswitch_mode;
81
82 const struct nfp_rtsym *q_lvls;
83 const struct nfp_rtsym *qm_stats;
84 const struct nfp_rtsym *q_stats;
85 };
86
87
88
89
90
91
92
93
94
95
96 struct nfp_alink_stats {
97 u64 tx_pkts;
98 u64 tx_bytes;
99 u64 backlog_pkts;
100 u64 backlog_bytes;
101 u64 overlimits;
102 u64 drops;
103 };
104
105
106
107
108
109
110 struct nfp_alink_xstats {
111 u64 ecn_marked;
112 u64 pdrop;
113 };
114
115 enum nfp_qdisc_type {
116 NFP_QDISC_NONE = 0,
117 NFP_QDISC_MQ,
118 NFP_QDISC_RED,
119 NFP_QDISC_GRED,
120 };
121
122 #define NFP_QDISC_UNTRACKED ((struct nfp_qdisc *)1UL)
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 struct nfp_qdisc {
153 struct net_device *netdev;
154 enum nfp_qdisc_type type;
155 u32 handle;
156 u32 parent_handle;
157 unsigned int use_cnt;
158 unsigned int num_children;
159 struct nfp_qdisc **children;
160
161 bool params_ok;
162 bool offload_mark;
163 bool offloaded;
164
165 union {
166
167 struct {
168 struct nfp_alink_stats stats;
169 struct nfp_alink_stats prev_stats;
170 } mq;
171
172 struct {
173 unsigned int num_bands;
174
175 struct {
176 bool ecn;
177 u32 threshold;
178 struct nfp_alink_stats stats;
179 struct nfp_alink_stats prev_stats;
180 struct nfp_alink_xstats xstats;
181 struct nfp_alink_xstats prev_xstats;
182 } band[MAX_DPs];
183 } red;
184 };
185 };
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 struct nfp_abm_link {
207 struct nfp_abm *abm;
208 struct nfp_net *vnic;
209 unsigned int id;
210 unsigned int queue_base;
211 unsigned int total_queues;
212
213 u64 last_stats_update;
214
215 u32 *prio_map;
216 bool has_prio;
217
218 u8 def_band;
219 struct list_head dscp_map;
220
221 struct nfp_qdisc *root_qdisc;
222 struct radix_tree_root qdiscs;
223 };
224
225 static inline bool nfp_abm_has_prio(struct nfp_abm *abm)
226 {
227 return abm->num_bands > 1;
228 }
229
230 static inline bool nfp_abm_has_drop(struct nfp_abm *abm)
231 {
232 return abm->action_mask & BIT(NFP_ABM_ACT_DROP);
233 }
234
235 static inline bool nfp_abm_has_mark(struct nfp_abm *abm)
236 {
237 return abm->action_mask & BIT(NFP_ABM_ACT_MARK_DROP);
238 }
239
240 void nfp_abm_qdisc_offload_update(struct nfp_abm_link *alink);
241 int nfp_abm_setup_root(struct net_device *netdev, struct nfp_abm_link *alink,
242 struct tc_root_qopt_offload *opt);
243 int nfp_abm_setup_tc_red(struct net_device *netdev, struct nfp_abm_link *alink,
244 struct tc_red_qopt_offload *opt);
245 int nfp_abm_setup_tc_mq(struct net_device *netdev, struct nfp_abm_link *alink,
246 struct tc_mq_qopt_offload *opt);
247 int nfp_abm_setup_tc_gred(struct net_device *netdev, struct nfp_abm_link *alink,
248 struct tc_gred_qopt_offload *opt);
249 int nfp_abm_setup_cls_block(struct net_device *netdev, struct nfp_repr *repr,
250 struct flow_block_offload *opt);
251
252 int nfp_abm_ctrl_read_params(struct nfp_abm_link *alink);
253 int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm);
254 int __nfp_abm_ctrl_set_q_lvl(struct nfp_abm *abm, unsigned int id, u32 val);
255 int nfp_abm_ctrl_set_q_lvl(struct nfp_abm_link *alink, unsigned int band,
256 unsigned int queue, u32 val);
257 int __nfp_abm_ctrl_set_q_act(struct nfp_abm *abm, unsigned int id,
258 enum nfp_abm_q_action act);
259 int nfp_abm_ctrl_set_q_act(struct nfp_abm_link *alink, unsigned int band,
260 unsigned int queue, enum nfp_abm_q_action act);
261 int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink,
262 unsigned int band, unsigned int queue,
263 struct nfp_alink_stats *stats);
264 int nfp_abm_ctrl_read_q_xstats(struct nfp_abm_link *alink,
265 unsigned int band, unsigned int queue,
266 struct nfp_alink_xstats *xstats);
267 u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i);
268 u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i);
269 int nfp_abm_ctrl_qm_enable(struct nfp_abm *abm);
270 int nfp_abm_ctrl_qm_disable(struct nfp_abm *abm);
271 void nfp_abm_prio_map_update(struct nfp_abm *abm);
272 int nfp_abm_ctrl_prio_map_update(struct nfp_abm_link *alink, u32 *packed);
273 #endif