Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef __NET_PKT_CLS_H |
3 | #define __NET_PKT_CLS_H | |
4 | ||
5 | #include <linux/pkt_cls.h> | |
7aa0045d | 6 | #include <linux/workqueue.h> |
1da177e4 LT |
7 | #include <net/sch_generic.h> |
8 | #include <net/act_api.h> | |
a5148626 | 9 | #include <net/net_namespace.h> |
1da177e4 | 10 | |
cd11b164 | 11 | /* TC action not accessible from user space */ |
720f22fe | 12 | #define TC_ACT_CONSUMED (TC_ACT_VALUE_MAX + 1) |
cd11b164 | 13 | |
1da177e4 LT |
14 | /* Basic packet classifier frontend definitions. */ |
15 | ||
fd2c3ef7 | 16 | struct tcf_walker { |
1da177e4 LT |
17 | int stop; |
18 | int skip; | |
19 | int count; | |
6676d5e4 | 20 | bool nonempty; |
01683a14 | 21 | unsigned long cookie; |
8113c095 | 22 | int (*fn)(struct tcf_proto *, void *node, struct tcf_walker *); |
1da177e4 LT |
23 | }; |
24 | ||
5c15257f | 25 | int register_tcf_proto_ops(struct tcf_proto_ops *ops); |
bc5c8260 | 26 | void unregister_tcf_proto_ops(struct tcf_proto_ops *ops); |
1da177e4 | 27 | |
8c4083b3 | 28 | struct tcf_block_ext_info { |
32f8c409 | 29 | enum flow_block_binder_type binder_type; |
c7eb7d72 JP |
30 | tcf_chain_head_change_t *chain_head_change; |
31 | void *chain_head_change_priv; | |
48617387 | 32 | u32 block_index; |
8c4083b3 JP |
33 | }; |
34 | ||
3625750f PM |
35 | struct tcf_qevent { |
36 | struct tcf_block *block; | |
37 | struct tcf_block_ext_info info; | |
38 | struct tcf_proto __rcu *filter_chain; | |
39 | }; | |
40 | ||
acb67442 | 41 | struct tcf_block_cb; |
aaa908ff | 42 | bool tcf_queue_work(struct rcu_work *rwork, work_func_t func); |
acb67442 | 43 | |
8ae70032 | 44 | #ifdef CONFIG_NET_CLS |
1f3ed383 JP |
45 | struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, |
46 | u32 chain_index); | |
1f3ed383 | 47 | void tcf_chain_put_by_act(struct tcf_chain *chain); |
bbf73830 VB |
48 | struct tcf_chain *tcf_get_next_chain(struct tcf_block *block, |
49 | struct tcf_chain *chain); | |
fe2923af | 50 | struct tcf_proto *tcf_get_next_proto(struct tcf_chain *chain, |
0fca55ed | 51 | struct tcf_proto *tp); |
f36fe1c4 | 52 | void tcf_block_netif_keep_dst(struct tcf_block *block); |
6529eaba | 53 | int tcf_block_get(struct tcf_block **p_block, |
8d1a77f9 AA |
54 | struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, |
55 | struct netlink_ext_ack *extack); | |
c7eb7d72 | 56 | int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q, |
8d1a77f9 AA |
57 | struct tcf_block_ext_info *ei, |
58 | struct netlink_ext_ack *extack); | |
6529eaba | 59 | void tcf_block_put(struct tcf_block *block); |
c7eb7d72 | 60 | void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, |
8c4083b3 | 61 | struct tcf_block_ext_info *ei); |
44186460 | 62 | |
48617387 JP |
63 | static inline bool tcf_block_shared(struct tcf_block *block) |
64 | { | |
65 | return block->index; | |
66 | } | |
67 | ||
c1a970d0 VB |
68 | static inline bool tcf_block_non_null_shared(struct tcf_block *block) |
69 | { | |
70 | return block && block->index; | |
71 | } | |
72 | ||
44186460 JP |
73 | static inline struct Qdisc *tcf_block_q(struct tcf_block *block) |
74 | { | |
48617387 | 75 | WARN_ON(tcf_block_shared(block)); |
44186460 JP |
76 | return block->q; |
77 | } | |
78 | ||
3aa26055 DC |
79 | int tcf_classify(struct sk_buff *skb, |
80 | const struct tcf_block *block, | |
81 | const struct tcf_proto *tp, struct tcf_result *res, | |
82 | bool compat_mode); | |
87d83093 | 83 | |
fe0df81d ZS |
84 | static inline bool tc_cls_stats_dump(struct tcf_proto *tp, |
85 | struct tcf_walker *arg, | |
86 | void *filter) | |
87 | { | |
88 | if (arg->count >= arg->skip && arg->fn(tp, filter, arg) < 0) { | |
89 | arg->stop = 1; | |
90 | return false; | |
91 | } | |
92 | ||
93 | arg->count++; | |
94 | return true; | |
95 | } | |
96 | ||
8ae70032 | 97 | #else |
88c44a52 PJV |
98 | static inline bool tcf_block_shared(struct tcf_block *block) |
99 | { | |
100 | return false; | |
101 | } | |
102 | ||
c1a970d0 VB |
103 | static inline bool tcf_block_non_null_shared(struct tcf_block *block) |
104 | { | |
105 | return false; | |
106 | } | |
107 | ||
6529eaba JP |
108 | static inline |
109 | int tcf_block_get(struct tcf_block **p_block, | |
3c149091 SM |
110 | struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, |
111 | struct netlink_ext_ack *extack) | |
6529eaba JP |
112 | { |
113 | return 0; | |
114 | } | |
115 | ||
8c4083b3 | 116 | static inline |
c7eb7d72 | 117 | int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q, |
33c30a8b QM |
118 | struct tcf_block_ext_info *ei, |
119 | struct netlink_ext_ack *extack) | |
8c4083b3 JP |
120 | { |
121 | return 0; | |
122 | } | |
123 | ||
6529eaba | 124 | static inline void tcf_block_put(struct tcf_block *block) |
8ae70032 JP |
125 | { |
126 | } | |
87d83093 | 127 | |
8c4083b3 | 128 | static inline |
c7eb7d72 | 129 | void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, |
8c4083b3 JP |
130 | struct tcf_block_ext_info *ei) |
131 | { | |
132 | } | |
133 | ||
44186460 JP |
134 | static inline struct Qdisc *tcf_block_q(struct tcf_block *block) |
135 | { | |
136 | return NULL; | |
137 | } | |
138 | ||
acb67442 | 139 | static inline |
a7323311 | 140 | int tc_setup_cb_block_register(struct tcf_block *block, flow_setup_cb_t *cb, |
acb67442 JP |
141 | void *cb_priv) |
142 | { | |
143 | return 0; | |
144 | } | |
145 | ||
146 | static inline | |
a7323311 | 147 | void tc_setup_cb_block_unregister(struct tcf_block *block, flow_setup_cb_t *cb, |
acb67442 JP |
148 | void *cb_priv) |
149 | { | |
150 | } | |
151 | ||
3aa26055 DC |
152 | static inline int tcf_classify(struct sk_buff *skb, |
153 | const struct tcf_block *block, | |
154 | const struct tcf_proto *tp, | |
87d83093 JP |
155 | struct tcf_result *res, bool compat_mode) |
156 | { | |
157 | return TC_ACT_UNSPEC; | |
158 | } | |
9410c940 | 159 | |
8ae70032 | 160 | #endif |
cf1facda | 161 | |
1da177e4 LT |
162 | static inline unsigned long |
163 | __cls_set_class(unsigned long *clp, unsigned long cl) | |
164 | { | |
a0efb80c | 165 | return xchg(clp, cl); |
1da177e4 LT |
166 | } |
167 | ||
2e24cd75 CW |
168 | static inline void |
169 | __tcf_bind_filter(struct Qdisc *q, struct tcf_result *r, unsigned long base) | |
1da177e4 | 170 | { |
2e24cd75 | 171 | unsigned long cl; |
34e3759c | 172 | |
2e24cd75 CW |
173 | cl = q->ops->cl_ops->bind_tcf(q, base, r->classid); |
174 | cl = __cls_set_class(&r->class, cl); | |
175 | if (cl) | |
176 | q->ops->cl_ops->unbind_tcf(q, cl); | |
1da177e4 LT |
177 | } |
178 | ||
179 | static inline void | |
180 | tcf_bind_filter(struct tcf_proto *tp, struct tcf_result *r, unsigned long base) | |
181 | { | |
34e3759c | 182 | struct Qdisc *q = tp->chain->block->q; |
1da177e4 | 183 | |
34e3759c JP |
184 | /* Check q as it is not set for shared blocks. In that case, |
185 | * setting class is not supported. | |
186 | */ | |
187 | if (!q) | |
188 | return; | |
2e24cd75 CW |
189 | sch_tree_lock(q); |
190 | __tcf_bind_filter(q, r, base); | |
191 | sch_tree_unlock(q); | |
192 | } | |
193 | ||
194 | static inline void | |
195 | __tcf_unbind_filter(struct Qdisc *q, struct tcf_result *r) | |
196 | { | |
197 | unsigned long cl; | |
198 | ||
199 | if ((cl = __cls_set_class(&r->class, 0)) != 0) | |
34e3759c | 200 | q->ops->cl_ops->unbind_tcf(q, cl); |
1da177e4 LT |
201 | } |
202 | ||
203 | static inline void | |
204 | tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r) | |
205 | { | |
34e3759c | 206 | struct Qdisc *q = tp->chain->block->q; |
1da177e4 | 207 | |
34e3759c JP |
208 | if (!q) |
209 | return; | |
2e24cd75 | 210 | __tcf_unbind_filter(q, r); |
1da177e4 LT |
211 | } |
212 | ||
fd2c3ef7 | 213 | struct tcf_exts { |
1da177e4 | 214 | #ifdef CONFIG_NET_CLS_ACT |
33be6271 | 215 | __u32 type; /* for backward compat(TCA_OLD_COMPAT) */ |
22dc13c8 WC |
216 | int nr_actions; |
217 | struct tc_action **actions; | |
dbdcda63 ED |
218 | struct net *net; |
219 | netns_tracker ns_tracker; | |
1da177e4 | 220 | #endif |
5da57f42 WC |
221 | /* Map to export classifier specific extension TLV types to the |
222 | * generic extensions API. Unsupported extensions must be set to 0. | |
223 | */ | |
1da177e4 LT |
224 | int action; |
225 | int police; | |
226 | }; | |
227 | ||
14215108 CW |
228 | static inline int tcf_exts_init(struct tcf_exts *exts, struct net *net, |
229 | int action, int police) | |
33be6271 WC |
230 | { |
231 | #ifdef CONFIG_NET_CLS_ACT | |
5da57f42 | 232 | exts->type = 0; |
22dc13c8 | 233 | exts->nr_actions = 0; |
cb963a19 ED |
234 | /* Note: we do not own yet a reference on net. |
235 | * This reference might be taken later from tcf_exts_get_net(). | |
236 | */ | |
14215108 | 237 | exts->net = net; |
22dc13c8 WC |
238 | exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *), |
239 | GFP_KERNEL); | |
b9a24bb7 WC |
240 | if (!exts->actions) |
241 | return -ENOMEM; | |
33be6271 | 242 | #endif |
5da57f42 WC |
243 | exts->action = action; |
244 | exts->police = police; | |
b9a24bb7 | 245 | return 0; |
33be6271 WC |
246 | } |
247 | ||
e4b95c41 CW |
248 | /* Return false if the netns is being destroyed in cleanup_net(). Callers |
249 | * need to do cleanup synchronously in this case, otherwise may race with | |
250 | * tc_action_net_exit(). Return true for other cases. | |
251 | */ | |
252 | static inline bool tcf_exts_get_net(struct tcf_exts *exts) | |
253 | { | |
254 | #ifdef CONFIG_NET_CLS_ACT | |
255 | exts->net = maybe_get_net(exts->net); | |
dbdcda63 ED |
256 | if (exts->net) |
257 | netns_tracker_alloc(exts->net, &exts->ns_tracker, GFP_KERNEL); | |
e4b95c41 CW |
258 | return exts->net != NULL; |
259 | #else | |
260 | return true; | |
261 | #endif | |
262 | } | |
263 | ||
264 | static inline void tcf_exts_put_net(struct tcf_exts *exts) | |
265 | { | |
266 | #ifdef CONFIG_NET_CLS_ACT | |
267 | if (exts->net) | |
dbdcda63 | 268 | put_net_track(exts->net, &exts->ns_tracker); |
e4b95c41 CW |
269 | #endif |
270 | } | |
271 | ||
22dc13c8 | 272 | #ifdef CONFIG_NET_CLS_ACT |
244cd96a CW |
273 | #define tcf_exts_for_each_action(i, a, exts) \ |
274 | for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = (exts)->actions[i]); i++) | |
275 | #else | |
276 | #define tcf_exts_for_each_action(i, a, exts) \ | |
191672ca | 277 | for (; 0; (void)(i), (void)(a), (void)(exts)) |
22dc13c8 | 278 | #endif |
22dc13c8 | 279 | |
8cbfe939 BZ |
280 | #define tcf_act_for_each_action(i, a, actions) \ |
281 | for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) | |
282 | ||
d897a638 | 283 | static inline void |
bcd64368 BZ |
284 | tcf_exts_hw_stats_update(const struct tcf_exts *exts, |
285 | u64 bytes, u64 packets, u64 drops, u64 lastuse, | |
286 | u8 used_hw_stats, bool used_hw_stats_valid) | |
d897a638 JK |
287 | { |
288 | #ifdef CONFIG_NET_CLS_ACT | |
289 | int i; | |
290 | ||
d897a638 JK |
291 | for (i = 0; i < exts->nr_actions; i++) { |
292 | struct tc_action *a = exts->actions[i]; | |
293 | ||
c7a66f8d BZ |
294 | /* if stats from hw, just skip */ |
295 | if (tcf_action_update_hw_stats(a)) { | |
296 | preempt_disable(); | |
297 | tcf_action_stats_update(a, bytes, packets, drops, | |
298 | lastuse, true); | |
299 | preempt_enable(); | |
d897a638 | 300 | |
c7a66f8d BZ |
301 | a->used_hw_stats = used_hw_stats; |
302 | a->used_hw_stats_valid = used_hw_stats_valid; | |
303 | } | |
304 | } | |
d897a638 JK |
305 | #endif |
306 | } | |
307 | ||
3bcc0cec JP |
308 | /** |
309 | * tcf_exts_has_actions - check if at least one action is present | |
310 | * @exts: tc filter extensions handle | |
311 | * | |
312 | * Returns true if at least one action is present. | |
313 | */ | |
314 | static inline bool tcf_exts_has_actions(struct tcf_exts *exts) | |
315 | { | |
2734437e | 316 | #ifdef CONFIG_NET_CLS_ACT |
3bcc0cec JP |
317 | return exts->nr_actions; |
318 | #else | |
319 | return false; | |
320 | #endif | |
321 | } | |
2734437e | 322 | |
af69afc5 JP |
323 | /** |
324 | * tcf_exts_exec - execute tc filter extensions | |
325 | * @skb: socket buffer | |
326 | * @exts: tc filter extensions handle | |
327 | * @res: desired result | |
328 | * | |
af089e70 | 329 | * Executes all configured extensions. Returns TC_ACT_OK on a normal execution, |
af69afc5 JP |
330 | * a negative number if the filter must be considered unmatched or |
331 | * a positive action code (TC_ACT_*) which must be returned to the | |
332 | * underlying layer. | |
333 | */ | |
334 | static inline int | |
335 | tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, | |
336 | struct tcf_result *res) | |
337 | { | |
338 | #ifdef CONFIG_NET_CLS_ACT | |
ec1a9cca | 339 | return tcf_action_exec(skb, exts->actions, exts->nr_actions, res); |
af69afc5 | 340 | #endif |
af089e70 | 341 | return TC_ACT_OK; |
af69afc5 JP |
342 | } |
343 | ||
5c15257f JP |
344 | int tcf_exts_validate(struct net *net, struct tcf_proto *tp, |
345 | struct nlattr **tb, struct nlattr *rate_tlv, | |
695176bf | 346 | struct tcf_exts *exts, u32 flags, |
50a56190 | 347 | struct netlink_ext_ack *extack); |
c86e0209 BZ |
348 | int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **tb, |
349 | struct nlattr *rate_tlv, struct tcf_exts *exts, | |
350 | u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); | |
18d0264f | 351 | void tcf_exts_destroy(struct tcf_exts *exts); |
9b0d4446 | 352 | void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src); |
5da57f42 | 353 | int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts); |
ca44b738 | 354 | int tcf_exts_terse_dump(struct sk_buff *skb, struct tcf_exts *exts); |
5da57f42 | 355 | int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts); |
1da177e4 LT |
356 | |
357 | /** | |
358 | * struct tcf_pkt_info - packet information | |
0161d151 BX |
359 | * |
360 | * @ptr: start of the pkt data | |
361 | * @nexthdr: offset of the next header | |
1da177e4 | 362 | */ |
fd2c3ef7 | 363 | struct tcf_pkt_info { |
1da177e4 LT |
364 | unsigned char * ptr; |
365 | int nexthdr; | |
366 | }; | |
367 | ||
368 | #ifdef CONFIG_NET_EMATCH | |
369 | ||
370 | struct tcf_ematch_ops; | |
371 | ||
372 | /** | |
373 | * struct tcf_ematch - extended match (ematch) | |
374 | * | |
375 | * @matchid: identifier to allow userspace to reidentify a match | |
376 | * @flags: flags specifying attributes and the relation to other matches | |
377 | * @ops: the operations lookup table of the corresponding ematch module | |
378 | * @datalen: length of the ematch specific configuration data | |
379 | * @data: ematch specific data | |
0161d151 | 380 | * @net: the network namespace |
1da177e4 | 381 | */ |
fd2c3ef7 | 382 | struct tcf_ematch { |
1da177e4 LT |
383 | struct tcf_ematch_ops * ops; |
384 | unsigned long data; | |
385 | unsigned int datalen; | |
386 | u16 matchid; | |
387 | u16 flags; | |
82a470f1 | 388 | struct net *net; |
1da177e4 LT |
389 | }; |
390 | ||
391 | static inline int tcf_em_is_container(struct tcf_ematch *em) | |
392 | { | |
393 | return !em->ops; | |
394 | } | |
395 | ||
396 | static inline int tcf_em_is_simple(struct tcf_ematch *em) | |
397 | { | |
398 | return em->flags & TCF_EM_SIMPLE; | |
399 | } | |
400 | ||
401 | static inline int tcf_em_is_inverted(struct tcf_ematch *em) | |
402 | { | |
403 | return em->flags & TCF_EM_INVERT; | |
404 | } | |
405 | ||
406 | static inline int tcf_em_last_match(struct tcf_ematch *em) | |
407 | { | |
408 | return (em->flags & TCF_EM_REL_MASK) == TCF_EM_REL_END; | |
409 | } | |
410 | ||
411 | static inline int tcf_em_early_end(struct tcf_ematch *em, int result) | |
412 | { | |
413 | if (tcf_em_last_match(em)) | |
414 | return 1; | |
415 | ||
416 | if (result == 0 && em->flags & TCF_EM_REL_AND) | |
417 | return 1; | |
418 | ||
419 | if (result != 0 && em->flags & TCF_EM_REL_OR) | |
420 | return 1; | |
421 | ||
422 | return 0; | |
423 | } | |
424 | ||
425 | /** | |
426 | * struct tcf_ematch_tree - ematch tree handle | |
427 | * | |
428 | * @hdr: ematch tree header supplied by userspace | |
429 | * @matches: array of ematches | |
430 | */ | |
fd2c3ef7 | 431 | struct tcf_ematch_tree { |
1da177e4 LT |
432 | struct tcf_ematch_tree_hdr hdr; |
433 | struct tcf_ematch * matches; | |
434 | ||
435 | }; | |
436 | ||
437 | /** | |
438 | * struct tcf_ematch_ops - ematch module operations | |
439 | * | |
440 | * @kind: identifier (kind) of this ematch module | |
441 | * @datalen: length of expected configuration data (optional) | |
442 | * @change: called during validation (optional) | |
443 | * @match: called during ematch tree evaluation, must return 1/0 | |
444 | * @destroy: called during destroyage (optional) | |
445 | * @dump: called during dumping process (optional) | |
446 | * @owner: owner, must be set to THIS_MODULE | |
447 | * @link: link to previous/next ematch module (internal use) | |
448 | */ | |
fd2c3ef7 | 449 | struct tcf_ematch_ops { |
1da177e4 LT |
450 | int kind; |
451 | int datalen; | |
82a470f1 | 452 | int (*change)(struct net *net, void *, |
1da177e4 LT |
453 | int, struct tcf_ematch *); |
454 | int (*match)(struct sk_buff *, struct tcf_ematch *, | |
455 | struct tcf_pkt_info *); | |
82a470f1 | 456 | void (*destroy)(struct tcf_ematch *); |
1da177e4 LT |
457 | int (*dump)(struct sk_buff *, struct tcf_ematch *); |
458 | struct module *owner; | |
459 | struct list_head link; | |
460 | }; | |
461 | ||
5c15257f JP |
462 | int tcf_em_register(struct tcf_ematch_ops *); |
463 | void tcf_em_unregister(struct tcf_ematch_ops *); | |
464 | int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *, | |
465 | struct tcf_ematch_tree *); | |
82a470f1 | 466 | void tcf_em_tree_destroy(struct tcf_ematch_tree *); |
5c15257f JP |
467 | int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); |
468 | int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *, | |
469 | struct tcf_pkt_info *); | |
1da177e4 | 470 | |
1da177e4 LT |
471 | /** |
472 | * tcf_em_tree_match - evaulate an ematch tree | |
473 | * | |
474 | * @skb: socket buffer of the packet in question | |
475 | * @tree: ematch tree to be used for evaluation | |
476 | * @info: packet information examined by classifier | |
477 | * | |
478 | * This function matches @skb against the ematch tree in @tree by going | |
479 | * through all ematches respecting their logic relations returning | |
480 | * as soon as the result is obvious. | |
481 | * | |
482 | * Returns 1 if the ematch tree as-one matches, no ematches are configured | |
483 | * or ematch is not enabled in the kernel, otherwise 0 is returned. | |
484 | */ | |
485 | static inline int tcf_em_tree_match(struct sk_buff *skb, | |
486 | struct tcf_ematch_tree *tree, | |
487 | struct tcf_pkt_info *info) | |
488 | { | |
489 | if (tree->hdr.nmatches) | |
490 | return __tcf_em_tree_match(skb, tree, info); | |
491 | else | |
492 | return 1; | |
493 | } | |
494 | ||
db3d99c0 PM |
495 | #define MODULE_ALIAS_TCF_EMATCH(kind) MODULE_ALIAS("ematch-kind-" __stringify(kind)) |
496 | ||
1da177e4 LT |
497 | #else /* CONFIG_NET_EMATCH */ |
498 | ||
fd2c3ef7 | 499 | struct tcf_ematch_tree { |
1da177e4 LT |
500 | }; |
501 | ||
502 | #define tcf_em_tree_validate(tp, tb, t) ((void)(t), 0) | |
82a470f1 | 503 | #define tcf_em_tree_destroy(t) do { (void)(t); } while(0) |
1da177e4 | 504 | #define tcf_em_tree_dump(skb, t, tlv) (0) |
1da177e4 LT |
505 | #define tcf_em_tree_match(skb, t, info) ((void)(info), 1) |
506 | ||
507 | #endif /* CONFIG_NET_EMATCH */ | |
508 | ||
509 | static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer) | |
510 | { | |
511 | switch (layer) { | |
512 | case TCF_LAYER_LINK: | |
d3303a65 | 513 | return skb_mac_header(skb); |
1da177e4 | 514 | case TCF_LAYER_NETWORK: |
d56f90a7 | 515 | return skb_network_header(skb); |
1da177e4 | 516 | case TCF_LAYER_TRANSPORT: |
9c70220b | 517 | return skb_transport_header(skb); |
1da177e4 LT |
518 | } |
519 | ||
520 | return NULL; | |
521 | } | |
522 | ||
eddc9ec5 ACM |
523 | static inline int tcf_valid_offset(const struct sk_buff *skb, |
524 | const unsigned char *ptr, const int len) | |
1da177e4 | 525 | { |
da521b2c DM |
526 | return likely((ptr + len) <= skb_tail_pointer(skb) && |
527 | ptr >= skb->head && | |
528 | (ptr <= (ptr + len))); | |
1da177e4 LT |
529 | } |
530 | ||
1da177e4 | 531 | static inline int |
1057c55f AA |
532 | tcf_change_indev(struct net *net, struct nlattr *indev_tlv, |
533 | struct netlink_ext_ack *extack) | |
1da177e4 | 534 | { |
2519a602 WC |
535 | char indev[IFNAMSIZ]; |
536 | struct net_device *dev; | |
537 | ||
872f6903 | 538 | if (nla_strscpy(indev, indev_tlv, IFNAMSIZ) < 0) { |
e4a58ef3 GN |
539 | NL_SET_ERR_MSG_ATTR(extack, indev_tlv, |
540 | "Interface name too long"); | |
1da177e4 | 541 | return -EINVAL; |
1057c55f | 542 | } |
2519a602 | 543 | dev = __dev_get_by_name(net, indev); |
e4a58ef3 GN |
544 | if (!dev) { |
545 | NL_SET_ERR_MSG_ATTR(extack, indev_tlv, | |
546 | "Network device not found"); | |
2519a602 | 547 | return -ENODEV; |
e4a58ef3 | 548 | } |
2519a602 | 549 | return dev->ifindex; |
1da177e4 LT |
550 | } |
551 | ||
2519a602 WC |
552 | static inline bool |
553 | tcf_match_indev(struct sk_buff *skb, int ifindex) | |
1da177e4 | 554 | { |
2519a602 WC |
555 | if (!ifindex) |
556 | return true; | |
557 | if (!skb->skb_iif) | |
558 | return false; | |
559 | return ifindex == skb->skb_iif; | |
1da177e4 | 560 | } |
1da177e4 | 561 | |
9c1c0e12 | 562 | int tc_setup_offload_action(struct flow_action *flow_action, |
c2ccf84e IS |
563 | const struct tcf_exts *exts, |
564 | struct netlink_ext_ack *extack); | |
9c1c0e12 | 565 | void tc_cleanup_offload_action(struct flow_action *flow_action); |
8cbfe939 | 566 | int tc_setup_action(struct flow_action *flow_action, |
c2ccf84e IS |
567 | struct tc_action *actions[], |
568 | struct netlink_ext_ack *extack); | |
5a6ff4b1 | 569 | |
aeb3fecd | 570 | int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, |
40119211 VB |
571 | void *type_data, bool err_stop, bool rtnl_held); |
572 | int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, | |
573 | enum tc_setup_type type, void *type_data, bool err_stop, | |
574 | u32 *flags, unsigned int *in_hw_count, bool rtnl_held); | |
575 | int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, | |
576 | enum tc_setup_type type, void *type_data, bool err_stop, | |
577 | u32 *old_flags, unsigned int *old_in_hw_count, | |
578 | u32 *new_flags, unsigned int *new_in_hw_count, | |
579 | bool rtnl_held); | |
580 | int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, | |
581 | enum tc_setup_type type, void *type_data, bool err_stop, | |
582 | u32 *flags, unsigned int *in_hw_count, bool rtnl_held); | |
583 | int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, | |
584 | bool add, flow_setup_cb_t *cb, | |
585 | enum tc_setup_type type, void *type_data, | |
586 | void *cb_priv, u32 *flags, unsigned int *in_hw_count); | |
e3ab786b | 587 | unsigned int tcf_exts_num_actions(struct tcf_exts *exts); |
717503b9 | 588 | |
3625750f PM |
589 | #ifdef CONFIG_NET_CLS_ACT |
590 | int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch, | |
591 | enum flow_block_binder_type binder_type, | |
592 | struct nlattr *block_index_attr, | |
593 | struct netlink_ext_ack *extack); | |
594 | void tcf_qevent_destroy(struct tcf_qevent *qe, struct Qdisc *sch); | |
595 | int tcf_qevent_validate_change(struct tcf_qevent *qe, struct nlattr *block_index_attr, | |
596 | struct netlink_ext_ack *extack); | |
597 | struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struct sk_buff *skb, | |
55f656cd | 598 | struct sk_buff **to_free, int *ret); |
3625750f PM |
599 | int tcf_qevent_dump(struct sk_buff *skb, int attr_name, struct tcf_qevent *qe); |
600 | #else | |
601 | static inline int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch, | |
602 | enum flow_block_binder_type binder_type, | |
603 | struct nlattr *block_index_attr, | |
604 | struct netlink_ext_ack *extack) | |
605 | { | |
606 | return 0; | |
607 | } | |
608 | ||
609 | static inline void tcf_qevent_destroy(struct tcf_qevent *qe, struct Qdisc *sch) | |
610 | { | |
611 | } | |
612 | ||
613 | static inline int tcf_qevent_validate_change(struct tcf_qevent *qe, struct nlattr *block_index_attr, | |
614 | struct netlink_ext_ack *extack) | |
615 | { | |
616 | return 0; | |
617 | } | |
618 | ||
619 | static inline struct sk_buff * | |
620 | tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struct sk_buff *skb, | |
55f656cd | 621 | struct sk_buff **to_free, int *ret) |
3625750f PM |
622 | { |
623 | return skb; | |
624 | } | |
625 | ||
626 | static inline int tcf_qevent_dump(struct sk_buff *skb, int attr_name, struct tcf_qevent *qe) | |
627 | { | |
628 | return 0; | |
629 | } | |
630 | #endif | |
631 | ||
a1b7c5fd JF |
632 | struct tc_cls_u32_knode { |
633 | struct tcf_exts *exts; | |
068ceb35 | 634 | struct tcf_result *res; |
e014860e | 635 | struct tc_u32_sel *sel; |
a1b7c5fd JF |
636 | u32 handle; |
637 | u32 val; | |
638 | u32 mask; | |
639 | u32 link_handle; | |
e014860e | 640 | u8 fshift; |
a1b7c5fd JF |
641 | }; |
642 | ||
643 | struct tc_cls_u32_hnode { | |
644 | u32 handle; | |
645 | u32 prio; | |
646 | unsigned int divisor; | |
647 | }; | |
648 | ||
649 | enum tc_clsu32_command { | |
650 | TC_CLSU32_NEW_KNODE, | |
651 | TC_CLSU32_REPLACE_KNODE, | |
652 | TC_CLSU32_DELETE_KNODE, | |
653 | TC_CLSU32_NEW_HNODE, | |
654 | TC_CLSU32_REPLACE_HNODE, | |
655 | TC_CLSU32_DELETE_HNODE, | |
656 | }; | |
657 | ||
658 | struct tc_cls_u32_offload { | |
f9e30088 | 659 | struct flow_cls_common_offload common; |
a1b7c5fd JF |
660 | /* knode values */ |
661 | enum tc_clsu32_command command; | |
662 | union { | |
663 | struct tc_cls_u32_knode knode; | |
664 | struct tc_cls_u32_hnode hnode; | |
665 | }; | |
666 | }; | |
667 | ||
7b06e8ae | 668 | static inline bool tc_can_offload(const struct net_device *dev) |
6843e7a2 | 669 | { |
70b5aee4 | 670 | return dev->features & NETIF_F_HW_TC; |
6843e7a2 JF |
671 | } |
672 | ||
f9eda14f QM |
673 | static inline bool tc_can_offload_extack(const struct net_device *dev, |
674 | struct netlink_ext_ack *extack) | |
675 | { | |
676 | bool can = tc_can_offload(dev); | |
677 | ||
678 | if (!can) | |
679 | NL_SET_ERR_MSG(extack, "TC offload is disabled on net device"); | |
680 | ||
681 | return can; | |
682 | } | |
683 | ||
878db9f0 JK |
684 | static inline bool |
685 | tc_cls_can_offload_and_chain0(const struct net_device *dev, | |
f9e30088 | 686 | struct flow_cls_common_offload *common) |
878db9f0 JK |
687 | { |
688 | if (!tc_can_offload_extack(dev, common->extack)) | |
689 | return false; | |
690 | if (common->chain_index) { | |
691 | NL_SET_ERR_MSG(common->extack, | |
692 | "Driver supports only offload of chain 0"); | |
693 | return false; | |
694 | } | |
695 | return true; | |
696 | } | |
697 | ||
55330f05 HHZ |
698 | static inline bool tc_skip_hw(u32 flags) |
699 | { | |
700 | return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false; | |
701 | } | |
702 | ||
d34e3e18 SS |
703 | static inline bool tc_skip_sw(u32 flags) |
704 | { | |
705 | return (flags & TCA_CLS_FLAGS_SKIP_SW) ? true : false; | |
706 | } | |
707 | ||
708 | /* SKIP_HW and SKIP_SW are mutually exclusive flags. */ | |
709 | static inline bool tc_flags_valid(u32 flags) | |
710 | { | |
81c7288b MRL |
711 | if (flags & ~(TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW | |
712 | TCA_CLS_FLAGS_VERBOSE)) | |
d34e3e18 SS |
713 | return false; |
714 | ||
81c7288b | 715 | flags &= TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW; |
d34e3e18 SS |
716 | if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW))) |
717 | return false; | |
718 | ||
719 | return true; | |
720 | } | |
721 | ||
e696028a OG |
722 | static inline bool tc_in_hw(u32 flags) |
723 | { | |
724 | return (flags & TCA_CLS_FLAGS_IN_HW) ? true : false; | |
725 | } | |
726 | ||
34832e1c | 727 | static inline void |
f9e30088 | 728 | tc_cls_common_offload_init(struct flow_cls_common_offload *cls_common, |
34832e1c JK |
729 | const struct tcf_proto *tp, u32 flags, |
730 | struct netlink_ext_ack *extack) | |
731 | { | |
732 | cls_common->chain_index = tp->chain->index; | |
733 | cls_common->protocol = tp->protocol; | |
ef01adae | 734 | cls_common->prio = tp->prio >> 16; |
81c7288b | 735 | if (tc_skip_sw(flags) || flags & TCA_CLS_FLAGS_VERBOSE) |
34832e1c JK |
736 | cls_common->extack = extack; |
737 | } | |
738 | ||
9453d45e VB |
739 | #if IS_ENABLED(CONFIG_NET_TC_SKB_EXT) |
740 | static inline struct tc_skb_ext *tc_skb_ext_alloc(struct sk_buff *skb) | |
741 | { | |
742 | struct tc_skb_ext *tc_skb_ext = skb_ext_add(skb, TC_SKB_EXT); | |
743 | ||
744 | if (tc_skb_ext) | |
745 | memset(tc_skb_ext, 0, sizeof(*tc_skb_ext)); | |
746 | return tc_skb_ext; | |
747 | } | |
748 | #endif | |
749 | ||
b87f7936 YG |
750 | enum tc_matchall_command { |
751 | TC_CLSMATCHALL_REPLACE, | |
752 | TC_CLSMATCHALL_DESTROY, | |
b7fe4ab8 | 753 | TC_CLSMATCHALL_STATS, |
b87f7936 YG |
754 | }; |
755 | ||
756 | struct tc_cls_matchall_offload { | |
f9e30088 | 757 | struct flow_cls_common_offload common; |
b87f7936 | 758 | enum tc_matchall_command command; |
f00cbf19 | 759 | struct flow_rule *rule; |
b7fe4ab8 | 760 | struct flow_stats stats; |
b87f7936 YG |
761 | unsigned long cookie; |
762 | }; | |
763 | ||
332ae8e2 | 764 | enum tc_clsbpf_command { |
102740bd | 765 | TC_CLSBPF_OFFLOAD, |
68d64063 | 766 | TC_CLSBPF_STATS, |
332ae8e2 JK |
767 | }; |
768 | ||
769 | struct tc_cls_bpf_offload { | |
f9e30088 | 770 | struct flow_cls_common_offload common; |
332ae8e2 JK |
771 | enum tc_clsbpf_command command; |
772 | struct tcf_exts *exts; | |
773 | struct bpf_prog *prog; | |
102740bd | 774 | struct bpf_prog *oldprog; |
332ae8e2 JK |
775 | const char *name; |
776 | bool exts_integrated; | |
777 | }; | |
778 | ||
4e8b86c0 AN |
779 | struct tc_mqprio_qopt_offload { |
780 | /* struct tc_mqprio_qopt must always be the first element */ | |
781 | struct tc_mqprio_qopt qopt; | |
782 | u16 mode; | |
783 | u16 shaper; | |
784 | u32 flags; | |
785 | u64 min_rate[TC_QOPT_MAX_QUEUE]; | |
786 | u64 max_rate[TC_QOPT_MAX_QUEUE]; | |
787 | }; | |
1045ba77 JHS |
788 | |
789 | /* This structure holds cookie structure that is passed from user | |
790 | * to the kernel for actions and classifiers | |
791 | */ | |
792 | struct tc_cookie { | |
793 | u8 *data; | |
794 | u32 len; | |
eec94fdb | 795 | struct rcu_head rcu; |
1045ba77 | 796 | }; |
602f3baf | 797 | |
f34b4aac | 798 | struct tc_qopt_offload_stats { |
50dc9a85 | 799 | struct gnet_stats_basic_sync *bstats; |
f34b4aac NF |
800 | struct gnet_stats_queue *qstats; |
801 | }; | |
802 | ||
f971b132 JK |
803 | enum tc_mq_command { |
804 | TC_MQ_CREATE, | |
805 | TC_MQ_DESTROY, | |
47c669a4 | 806 | TC_MQ_STATS, |
d577a3d2 JK |
807 | TC_MQ_GRAFT, |
808 | }; | |
809 | ||
810 | struct tc_mq_opt_offload_graft_params { | |
811 | unsigned long queue; | |
812 | u32 child_handle; | |
f971b132 JK |
813 | }; |
814 | ||
815 | struct tc_mq_qopt_offload { | |
816 | enum tc_mq_command command; | |
817 | u32 handle; | |
d577a3d2 JK |
818 | union { |
819 | struct tc_qopt_offload_stats stats; | |
820 | struct tc_mq_opt_offload_graft_params graft_params; | |
821 | }; | |
f971b132 JK |
822 | }; |
823 | ||
d03b195b MM |
824 | enum tc_htb_command { |
825 | /* Root */ | |
826 | TC_HTB_CREATE, /* Initialize HTB offload. */ | |
827 | TC_HTB_DESTROY, /* Destroy HTB offload. */ | |
828 | ||
829 | /* Classes */ | |
830 | /* Allocate qid and create leaf. */ | |
831 | TC_HTB_LEAF_ALLOC_QUEUE, | |
832 | /* Convert leaf to inner, preserve and return qid, create new leaf. */ | |
833 | TC_HTB_LEAF_TO_INNER, | |
834 | /* Delete leaf, while siblings remain. */ | |
835 | TC_HTB_LEAF_DEL, | |
836 | /* Delete leaf, convert parent to leaf, preserving qid. */ | |
837 | TC_HTB_LEAF_DEL_LAST, | |
838 | /* TC_HTB_LEAF_DEL_LAST, but delete driver data on hardware errors. */ | |
839 | TC_HTB_LEAF_DEL_LAST_FORCE, | |
840 | /* Modify parameters of a node. */ | |
841 | TC_HTB_NODE_MODIFY, | |
842 | ||
843 | /* Class qdisc */ | |
844 | TC_HTB_LEAF_QUERY_QUEUE, /* Query qid by classid. */ | |
845 | }; | |
846 | ||
847 | struct tc_htb_qopt_offload { | |
848 | struct netlink_ext_ack *extack; | |
849 | enum tc_htb_command command; | |
d03b195b | 850 | u32 parent_classid; |
ca49bfd9 | 851 | u16 classid; |
d03b195b | 852 | u16 qid; |
d03b195b MM |
853 | u64 rate; |
854 | u64 ceil; | |
855 | }; | |
856 | ||
857 | #define TC_HTB_CLASSID_ROOT U32_MAX | |
858 | ||
602f3baf NF |
859 | enum tc_red_command { |
860 | TC_RED_REPLACE, | |
861 | TC_RED_DESTROY, | |
862 | TC_RED_STATS, | |
863 | TC_RED_XSTATS, | |
bf2a752b | 864 | TC_RED_GRAFT, |
602f3baf NF |
865 | }; |
866 | ||
867 | struct tc_red_qopt_offload_params { | |
868 | u32 min; | |
869 | u32 max; | |
870 | u32 probability; | |
c0b7490b | 871 | u32 limit; |
602f3baf | 872 | bool is_ecn; |
190852a5 | 873 | bool is_harddrop; |
0a7fad23 | 874 | bool is_nodrop; |
416ef9b1 | 875 | struct gnet_stats_queue *qstats; |
602f3baf | 876 | }; |
602f3baf NF |
877 | |
878 | struct tc_red_qopt_offload { | |
879 | enum tc_red_command command; | |
880 | u32 handle; | |
881 | u32 parent; | |
882 | union { | |
883 | struct tc_red_qopt_offload_params set; | |
f34b4aac | 884 | struct tc_qopt_offload_stats stats; |
602f3baf | 885 | struct red_stats *xstats; |
bf2a752b | 886 | u32 child_handle; |
602f3baf NF |
887 | }; |
888 | }; | |
889 | ||
890d8d23 JK |
890 | enum tc_gred_command { |
891 | TC_GRED_REPLACE, | |
892 | TC_GRED_DESTROY, | |
e49efd52 | 893 | TC_GRED_STATS, |
890d8d23 JK |
894 | }; |
895 | ||
896 | struct tc_gred_vq_qopt_offload_params { | |
897 | bool present; | |
898 | u32 limit; | |
899 | u32 prio; | |
900 | u32 min; | |
901 | u32 max; | |
902 | bool is_ecn; | |
903 | bool is_harddrop; | |
904 | u32 probability; | |
905 | /* Only need backlog, see struct tc_prio_qopt_offload_params */ | |
906 | u32 *backlog; | |
907 | }; | |
908 | ||
909 | struct tc_gred_qopt_offload_params { | |
910 | bool grio_on; | |
911 | bool wred_on; | |
912 | unsigned int dp_cnt; | |
913 | unsigned int dp_def; | |
914 | struct gnet_stats_queue *qstats; | |
915 | struct tc_gred_vq_qopt_offload_params tab[MAX_DPs]; | |
916 | }; | |
917 | ||
e49efd52 | 918 | struct tc_gred_qopt_offload_stats { |
50dc9a85 | 919 | struct gnet_stats_basic_sync bstats[MAX_DPs]; |
e49efd52 JK |
920 | struct gnet_stats_queue qstats[MAX_DPs]; |
921 | struct red_stats *xstats[MAX_DPs]; | |
922 | }; | |
923 | ||
890d8d23 JK |
924 | struct tc_gred_qopt_offload { |
925 | enum tc_gred_command command; | |
926 | u32 handle; | |
927 | u32 parent; | |
928 | union { | |
929 | struct tc_gred_qopt_offload_params set; | |
e49efd52 | 930 | struct tc_gred_qopt_offload_stats stats; |
890d8d23 JK |
931 | }; |
932 | }; | |
933 | ||
7fdb61b4 NF |
934 | enum tc_prio_command { |
935 | TC_PRIO_REPLACE, | |
936 | TC_PRIO_DESTROY, | |
937 | TC_PRIO_STATS, | |
b9c7a7ac | 938 | TC_PRIO_GRAFT, |
7fdb61b4 NF |
939 | }; |
940 | ||
941 | struct tc_prio_qopt_offload_params { | |
942 | int bands; | |
943 | u8 priomap[TC_PRIO_MAX + 1]; | |
9586a992 PM |
944 | /* At the point of un-offloading the Qdisc, the reported backlog and |
945 | * qlen need to be reduced by the portion that is in HW. | |
7fdb61b4 NF |
946 | */ |
947 | struct gnet_stats_queue *qstats; | |
948 | }; | |
949 | ||
b9c7a7ac NF |
950 | struct tc_prio_qopt_offload_graft_params { |
951 | u8 band; | |
952 | u32 child_handle; | |
953 | }; | |
954 | ||
7fdb61b4 NF |
955 | struct tc_prio_qopt_offload { |
956 | enum tc_prio_command command; | |
957 | u32 handle; | |
958 | u32 parent; | |
959 | union { | |
960 | struct tc_prio_qopt_offload_params replace_params; | |
961 | struct tc_qopt_offload_stats stats; | |
b9c7a7ac | 962 | struct tc_prio_qopt_offload_graft_params graft_params; |
7fdb61b4 NF |
963 | }; |
964 | }; | |
b9c7a7ac | 965 | |
98b0e5f6 JK |
966 | enum tc_root_command { |
967 | TC_ROOT_GRAFT, | |
968 | }; | |
969 | ||
970 | struct tc_root_qopt_offload { | |
971 | enum tc_root_command command; | |
972 | u32 handle; | |
973 | bool ingress; | |
974 | }; | |
975 | ||
d35eb52b PM |
976 | enum tc_ets_command { |
977 | TC_ETS_REPLACE, | |
978 | TC_ETS_DESTROY, | |
979 | TC_ETS_STATS, | |
980 | TC_ETS_GRAFT, | |
981 | }; | |
982 | ||
983 | struct tc_ets_qopt_offload_replace_params { | |
984 | unsigned int bands; | |
985 | u8 priomap[TC_PRIO_MAX + 1]; | |
986 | unsigned int quanta[TCQ_ETS_MAX_BANDS]; /* 0 for strict bands. */ | |
987 | unsigned int weights[TCQ_ETS_MAX_BANDS]; | |
988 | struct gnet_stats_queue *qstats; | |
989 | }; | |
990 | ||
991 | struct tc_ets_qopt_offload_graft_params { | |
992 | u8 band; | |
993 | u32 child_handle; | |
994 | }; | |
995 | ||
996 | struct tc_ets_qopt_offload { | |
997 | enum tc_ets_command command; | |
998 | u32 handle; | |
999 | u32 parent; | |
1000 | union { | |
1001 | struct tc_ets_qopt_offload_replace_params replace_params; | |
1002 | struct tc_qopt_offload_stats stats; | |
1003 | struct tc_ets_qopt_offload_graft_params graft_params; | |
1004 | }; | |
1005 | }; | |
1006 | ||
ef6aadcc PM |
1007 | enum tc_tbf_command { |
1008 | TC_TBF_REPLACE, | |
1009 | TC_TBF_DESTROY, | |
1010 | TC_TBF_STATS, | |
6b3efbfa | 1011 | TC_TBF_GRAFT, |
ef6aadcc PM |
1012 | }; |
1013 | ||
1014 | struct tc_tbf_qopt_offload_replace_params { | |
1015 | struct psched_ratecfg rate; | |
1016 | u32 max_size; | |
1017 | struct gnet_stats_queue *qstats; | |
1018 | }; | |
1019 | ||
1020 | struct tc_tbf_qopt_offload { | |
1021 | enum tc_tbf_command command; | |
1022 | u32 handle; | |
1023 | u32 parent; | |
1024 | union { | |
1025 | struct tc_tbf_qopt_offload_replace_params replace_params; | |
1026 | struct tc_qopt_offload_stats stats; | |
6b3efbfa | 1027 | u32 child_handle; |
ef6aadcc PM |
1028 | }; |
1029 | }; | |
1030 | ||
aaca9408 PM |
1031 | enum tc_fifo_command { |
1032 | TC_FIFO_REPLACE, | |
1033 | TC_FIFO_DESTROY, | |
1034 | TC_FIFO_STATS, | |
1035 | }; | |
1036 | ||
1037 | struct tc_fifo_qopt_offload { | |
1038 | enum tc_fifo_command command; | |
1039 | u32 handle; | |
1040 | u32 parent; | |
1041 | union { | |
1042 | struct tc_qopt_offload_stats stats; | |
1043 | }; | |
1044 | }; | |
1045 | ||
35d39fec PB |
1046 | #ifdef CONFIG_NET_CLS_ACT |
1047 | DECLARE_STATIC_KEY_FALSE(tc_skb_ext_tc); | |
1048 | void tc_skb_ext_tc_enable(void); | |
1049 | void tc_skb_ext_tc_disable(void); | |
1050 | #define tc_skb_ext_tc_enabled() static_branch_unlikely(&tc_skb_ext_tc) | |
1051 | #else /* CONFIG_NET_CLS_ACT */ | |
1052 | static inline void tc_skb_ext_tc_enable(void) { } | |
1053 | static inline void tc_skb_ext_tc_disable(void) { } | |
1054 | #define tc_skb_ext_tc_enabled() false | |
1055 | #endif | |
1056 | ||
1da177e4 | 1057 | #endif |