blob: 04aa0649f3b09bb093cfee126f9cd51378006e4a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __NET_PKT_CLS_H
3#define __NET_PKT_CLS_H
4
5#include <linux/pkt_cls.h>
Cong Wang7aa00452017-10-26 18:24:28 -07006#include <linux/workqueue.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <net/sch_generic.h>
8#include <net/act_api.h>
Jiri Pirkoa5148622019-06-15 11:03:49 +02009#include <net/net_namespace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Paolo Abenicd11b1642018-07-30 14:30:44 +020011/* TC action not accessible from user space */
John Hurley720f22f2019-06-24 23:13:35 +010012#define TC_ACT_CONSUMED (TC_ACT_VALUE_MAX + 1)
Paolo Abenicd11b1642018-07-30 14:30:44 +020013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014/* Basic packet classifier frontend definitions. */
15
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000016struct tcf_walker {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 int stop;
18 int skip;
19 int count;
Vlad Buslov6676d5e2019-02-25 17:38:31 +020020 bool nonempty;
Vlad Buslov01683a12018-07-09 13:29:11 +030021 unsigned long cookie;
WANG Cong8113c092017-08-04 21:31:43 -070022 int (*fn)(struct tcf_proto *, void *node, struct tcf_walker *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023};
24
Joe Perches5c152572013-07-30 22:47:13 -070025int register_tcf_proto_ops(struct tcf_proto_ops *ops);
26int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Jiri Pirko8c4083b2017-10-19 15:50:29 +020028struct tcf_block_ext_info {
Pablo Neira Ayuso32f8c402019-07-09 22:55:41 +020029 enum flow_block_binder_type binder_type;
Jiri Pirkoc7eb7d72017-11-03 11:46:24 +010030 tcf_chain_head_change_t *chain_head_change;
31 void *chain_head_change_priv;
Jiri Pirko48617382018-01-17 11:46:46 +010032 u32 block_index;
Jiri Pirko8c4083b2017-10-19 15:50:29 +020033};
34
Jiri Pirkoacb67442017-10-19 15:50:31 +020035struct tcf_block_cb;
Cong Wangaaa908f2018-05-23 15:26:53 -070036bool tcf_queue_work(struct rcu_work *rwork, work_func_t func);
Jiri Pirkoacb67442017-10-19 15:50:31 +020037
Jiri Pirko8ae70032017-02-15 11:57:50 +010038#ifdef CONFIG_NET_CLS
Jiri Pirko1f3ed382018-07-27 09:45:05 +020039struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block,
40 u32 chain_index);
Jiri Pirko1f3ed382018-07-27 09:45:05 +020041void tcf_chain_put_by_act(struct tcf_chain *chain);
Vlad Buslovbbf73832019-02-11 10:55:36 +020042struct tcf_chain *tcf_get_next_chain(struct tcf_block *block,
43 struct tcf_chain *chain);
Vlad Buslovfe2923a2019-02-11 10:55:40 +020044struct tcf_proto *tcf_get_next_proto(struct tcf_chain *chain,
Vlad Buslov12db03b2019-02-11 10:55:45 +020045 struct tcf_proto *tp, bool rtnl_held);
Jiri Pirkof36fe1c2018-01-17 11:46:48 +010046void tcf_block_netif_keep_dst(struct tcf_block *block);
Jiri Pirko6529eab2017-05-17 11:07:55 +020047int tcf_block_get(struct tcf_block **p_block,
Alexander Aring8d1a77f2017-12-20 12:35:19 -050048 struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
49 struct netlink_ext_ack *extack);
Jiri Pirkoc7eb7d72017-11-03 11:46:24 +010050int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
Alexander Aring8d1a77f2017-12-20 12:35:19 -050051 struct tcf_block_ext_info *ei,
52 struct netlink_ext_ack *extack);
Jiri Pirko6529eab2017-05-17 11:07:55 +020053void tcf_block_put(struct tcf_block *block);
Jiri Pirkoc7eb7d72017-11-03 11:46:24 +010054void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
Jiri Pirko8c4083b2017-10-19 15:50:29 +020055 struct tcf_block_ext_info *ei);
Jiri Pirko44186462017-10-13 14:00:59 +020056
Jiri Pirko48617382018-01-17 11:46:46 +010057static inline bool tcf_block_shared(struct tcf_block *block)
58{
59 return block->index;
60}
61
Vlad Buslovc1a970d2019-07-10 20:12:29 +030062static inline bool tcf_block_non_null_shared(struct tcf_block *block)
63{
64 return block && block->index;
65}
66
Jiri Pirko44186462017-10-13 14:00:59 +020067static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
68{
Jiri Pirko48617382018-01-17 11:46:46 +010069 WARN_ON(tcf_block_shared(block));
Jiri Pirko44186462017-10-13 14:00:59 +020070 return block->q;
71}
72
Jiri Pirko87d83092017-05-17 11:07:54 +020073int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
74 struct tcf_result *res, bool compat_mode);
Paul Blakey7d17c542020-02-16 12:01:22 +020075int tcf_classify_ingress(struct sk_buff *skb,
76 const struct tcf_block *ingress_block,
77 const struct tcf_proto *tp, struct tcf_result *res,
78 bool compat_mode);
Jiri Pirko87d83092017-05-17 11:07:54 +020079
Jiri Pirko8ae70032017-02-15 11:57:50 +010080#else
Pieter Jansen van Vuuren88c44a52019-05-04 04:46:25 -070081static inline bool tcf_block_shared(struct tcf_block *block)
82{
83 return false;
84}
85
Vlad Buslovc1a970d2019-07-10 20:12:29 +030086static inline bool tcf_block_non_null_shared(struct tcf_block *block)
87{
88 return false;
89}
90
Jiri Pirko6529eab2017-05-17 11:07:55 +020091static inline
92int tcf_block_get(struct tcf_block **p_block,
Sudip Mukherjee3c149092017-12-22 15:52:05 +000093 struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
94 struct netlink_ext_ack *extack)
Jiri Pirko6529eab2017-05-17 11:07:55 +020095{
96 return 0;
97}
98
Jiri Pirko8c4083b2017-10-19 15:50:29 +020099static inline
Jiri Pirkoc7eb7d72017-11-03 11:46:24 +0100100int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
Quentin Monnet33c30a82018-01-03 17:30:45 -0800101 struct tcf_block_ext_info *ei,
102 struct netlink_ext_ack *extack)
Jiri Pirko8c4083b2017-10-19 15:50:29 +0200103{
104 return 0;
105}
106
Jiri Pirko6529eab2017-05-17 11:07:55 +0200107static inline void tcf_block_put(struct tcf_block *block)
Jiri Pirko8ae70032017-02-15 11:57:50 +0100108{
109}
Jiri Pirko87d83092017-05-17 11:07:54 +0200110
Jiri Pirko8c4083b2017-10-19 15:50:29 +0200111static inline
Jiri Pirkoc7eb7d72017-11-03 11:46:24 +0100112void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
Jiri Pirko8c4083b2017-10-19 15:50:29 +0200113 struct tcf_block_ext_info *ei)
114{
115}
116
Jiri Pirko44186462017-10-13 14:00:59 +0200117static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
118{
119 return NULL;
120}
121
Jiri Pirkoacb67442017-10-19 15:50:31 +0200122static inline
Pablo Neira Ayusoa7323312019-07-19 18:20:15 +0200123int tc_setup_cb_block_register(struct tcf_block *block, flow_setup_cb_t *cb,
Jiri Pirkoacb67442017-10-19 15:50:31 +0200124 void *cb_priv)
125{
126 return 0;
127}
128
129static inline
Pablo Neira Ayusoa7323312019-07-19 18:20:15 +0200130void tc_setup_cb_block_unregister(struct tcf_block *block, flow_setup_cb_t *cb,
Jiri Pirkoacb67442017-10-19 15:50:31 +0200131 void *cb_priv)
132{
133}
134
Jiri Pirko87d83092017-05-17 11:07:54 +0200135static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
136 struct tcf_result *res, bool compat_mode)
137{
138 return TC_ACT_UNSPEC;
139}
Paul Blakey9410c942020-02-16 12:01:21 +0200140
141static inline int tcf_classify_ingress(struct sk_buff *skb,
Paul Blakey7d17c542020-02-16 12:01:22 +0200142 const struct tcf_block *ingress_block,
Paul Blakey9410c942020-02-16 12:01:21 +0200143 const struct tcf_proto *tp,
144 struct tcf_result *res, bool compat_mode)
145{
146 return TC_ACT_UNSPEC;
147}
148
Jiri Pirko8ae70032017-02-15 11:57:50 +0100149#endif
Jiri Pirkocf1facd2017-02-09 14:38:56 +0100150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151static inline unsigned long
152__cls_set_class(unsigned long *clp, unsigned long cl)
153{
WANG Conga0efb802014-09-30 16:07:24 -0700154 return xchg(clp, cl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155}
156
Cong Wang2e24cd72020-01-23 16:26:18 -0800157static inline void
158__tcf_bind_filter(struct Qdisc *q, struct tcf_result *r, unsigned long base)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159{
Cong Wang2e24cd72020-01-23 16:26:18 -0800160 unsigned long cl;
Jiri Pirko34e37592017-10-13 14:01:00 +0200161
Cong Wang2e24cd72020-01-23 16:26:18 -0800162 cl = q->ops->cl_ops->bind_tcf(q, base, r->classid);
163 cl = __cls_set_class(&r->class, cl);
164 if (cl)
165 q->ops->cl_ops->unbind_tcf(q, cl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166}
167
168static inline void
169tcf_bind_filter(struct tcf_proto *tp, struct tcf_result *r, unsigned long base)
170{
Jiri Pirko34e37592017-10-13 14:01:00 +0200171 struct Qdisc *q = tp->chain->block->q;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Jiri Pirko34e37592017-10-13 14:01:00 +0200173 /* Check q as it is not set for shared blocks. In that case,
174 * setting class is not supported.
175 */
176 if (!q)
177 return;
Cong Wang2e24cd72020-01-23 16:26:18 -0800178 sch_tree_lock(q);
179 __tcf_bind_filter(q, r, base);
180 sch_tree_unlock(q);
181}
182
183static inline void
184__tcf_unbind_filter(struct Qdisc *q, struct tcf_result *r)
185{
186 unsigned long cl;
187
188 if ((cl = __cls_set_class(&r->class, 0)) != 0)
Jiri Pirko34e37592017-10-13 14:01:00 +0200189 q->ops->cl_ops->unbind_tcf(q, cl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190}
191
192static inline void
193tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r)
194{
Jiri Pirko34e37592017-10-13 14:01:00 +0200195 struct Qdisc *q = tp->chain->block->q;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Jiri Pirko34e37592017-10-13 14:01:00 +0200197 if (!q)
198 return;
Cong Wang2e24cd72020-01-23 16:26:18 -0800199 __tcf_unbind_filter(q, r);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200}
201
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000202struct tcf_exts {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203#ifdef CONFIG_NET_CLS_ACT
WANG Cong33be6272013-12-15 20:15:05 -0800204 __u32 type; /* for backward compat(TCA_OLD_COMPAT) */
WANG Cong22dc13c2016-08-13 22:35:00 -0700205 int nr_actions;
206 struct tc_action **actions;
Cong Wange4b95c42017-11-06 13:47:19 -0800207 struct net *net;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#endif
WANG Cong5da57f42013-12-15 20:15:07 -0800209 /* Map to export classifier specific extension TLV types to the
210 * generic extensions API. Unsupported extensions must be set to 0.
211 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 int action;
213 int police;
214};
215
Cong Wang14215102019-02-20 21:37:42 -0800216static inline int tcf_exts_init(struct tcf_exts *exts, struct net *net,
217 int action, int police)
WANG Cong33be6272013-12-15 20:15:05 -0800218{
219#ifdef CONFIG_NET_CLS_ACT
WANG Cong5da57f42013-12-15 20:15:07 -0800220 exts->type = 0;
WANG Cong22dc13c2016-08-13 22:35:00 -0700221 exts->nr_actions = 0;
Cong Wang14215102019-02-20 21:37:42 -0800222 exts->net = net;
WANG Cong22dc13c2016-08-13 22:35:00 -0700223 exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *),
224 GFP_KERNEL);
WANG Congb9a24bb2016-08-19 12:36:54 -0700225 if (!exts->actions)
226 return -ENOMEM;
WANG Cong33be6272013-12-15 20:15:05 -0800227#endif
WANG Cong5da57f42013-12-15 20:15:07 -0800228 exts->action = action;
229 exts->police = police;
WANG Congb9a24bb2016-08-19 12:36:54 -0700230 return 0;
WANG Cong33be6272013-12-15 20:15:05 -0800231}
232
Cong Wange4b95c42017-11-06 13:47:19 -0800233/* Return false if the netns is being destroyed in cleanup_net(). Callers
234 * need to do cleanup synchronously in this case, otherwise may race with
235 * tc_action_net_exit(). Return true for other cases.
236 */
237static inline bool tcf_exts_get_net(struct tcf_exts *exts)
238{
239#ifdef CONFIG_NET_CLS_ACT
240 exts->net = maybe_get_net(exts->net);
241 return exts->net != NULL;
242#else
243 return true;
244#endif
245}
246
247static inline void tcf_exts_put_net(struct tcf_exts *exts)
248{
249#ifdef CONFIG_NET_CLS_ACT
250 if (exts->net)
251 put_net(exts->net);
252#endif
253}
254
WANG Cong22dc13c2016-08-13 22:35:00 -0700255#ifdef CONFIG_NET_CLS_ACT
Cong Wang244cd962018-08-19 12:22:09 -0700256#define tcf_exts_for_each_action(i, a, exts) \
257 for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = (exts)->actions[i]); i++)
258#else
259#define tcf_exts_for_each_action(i, a, exts) \
Arnd Bergmann191672c2018-08-22 17:25:44 +0200260 for (; 0; (void)(i), (void)(a), (void)(exts))
WANG Cong22dc13c2016-08-13 22:35:00 -0700261#endif
WANG Cong22dc13c2016-08-13 22:35:00 -0700262
Jakub Kicinskid897a632017-05-31 08:06:43 -0700263static inline void
264tcf_exts_stats_update(const struct tcf_exts *exts,
Jiri Pirko93a129e2020-03-28 16:37:43 +0100265 u64 bytes, u64 packets, u64 lastuse,
266 u8 used_hw_stats, bool used_hw_stats_valid)
Jakub Kicinskid897a632017-05-31 08:06:43 -0700267{
268#ifdef CONFIG_NET_CLS_ACT
269 int i;
270
271 preempt_disable();
272
273 for (i = 0; i < exts->nr_actions; i++) {
274 struct tc_action *a = exts->actions[i];
275
Eelco Chaudron28169ab2018-09-21 07:14:02 -0400276 tcf_action_stats_update(a, bytes, packets, lastuse, true);
Jiri Pirko93a129e2020-03-28 16:37:43 +0100277 a->used_hw_stats = used_hw_stats;
278 a->used_hw_stats_valid = used_hw_stats_valid;
Jakub Kicinskid897a632017-05-31 08:06:43 -0700279 }
280
281 preempt_enable();
282#endif
283}
284
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285/**
Jiri Pirko3bcc0ce2017-08-04 14:28:58 +0200286 * tcf_exts_has_actions - check if at least one action is present
287 * @exts: tc filter extensions handle
288 *
289 * Returns true if at least one action is present.
290 */
291static inline bool tcf_exts_has_actions(struct tcf_exts *exts)
292{
WANG Cong2734437e2016-08-13 22:34:59 -0700293#ifdef CONFIG_NET_CLS_ACT
Jiri Pirko3bcc0ce2017-08-04 14:28:58 +0200294 return exts->nr_actions;
295#else
296 return false;
297#endif
298}
WANG Cong2734437e2016-08-13 22:34:59 -0700299
Jiri Pirko3bcc0ce2017-08-04 14:28:58 +0200300/**
Jiri Pirkoaf69afc2017-08-04 14:28:59 +0200301 * tcf_exts_exec - execute tc filter extensions
302 * @skb: socket buffer
303 * @exts: tc filter extensions handle
304 * @res: desired result
305 *
Jiri Pirkoaf089e72017-08-04 14:29:01 +0200306 * Executes all configured extensions. Returns TC_ACT_OK on a normal execution,
Jiri Pirkoaf69afc2017-08-04 14:28:59 +0200307 * a negative number if the filter must be considered unmatched or
308 * a positive action code (TC_ACT_*) which must be returned to the
309 * underlying layer.
310 */
311static inline int
312tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
313 struct tcf_result *res)
314{
315#ifdef CONFIG_NET_CLS_ACT
Jiri Pirkoec1a9cc2017-08-04 14:29:02 +0200316 return tcf_action_exec(skb, exts->actions, exts->nr_actions, res);
Jiri Pirkoaf69afc2017-08-04 14:28:59 +0200317#endif
Jiri Pirkoaf089e72017-08-04 14:29:01 +0200318 return TC_ACT_OK;
Jiri Pirkoaf69afc2017-08-04 14:28:59 +0200319}
320
Joe Perches5c152572013-07-30 22:47:13 -0700321int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
322 struct nlattr **tb, struct nlattr *rate_tlv,
Vlad Buslovec6743a2019-02-11 10:55:43 +0200323 struct tcf_exts *exts, bool ovr, bool rtnl_held,
Alexander Aring50a56192018-01-18 11:20:52 -0500324 struct netlink_ext_ack *extack);
WANG Cong18d02642014-09-25 10:26:37 -0700325void tcf_exts_destroy(struct tcf_exts *exts);
Jiri Pirko9b0d4442017-08-04 14:29:15 +0200326void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
WANG Cong5da57f42013-12-15 20:15:07 -0800327int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
328int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330/**
331 * struct tcf_pkt_info - packet information
332 */
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000333struct tcf_pkt_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 unsigned char * ptr;
335 int nexthdr;
336};
337
338#ifdef CONFIG_NET_EMATCH
339
340struct tcf_ematch_ops;
341
342/**
343 * struct tcf_ematch - extended match (ematch)
344 *
345 * @matchid: identifier to allow userspace to reidentify a match
346 * @flags: flags specifying attributes and the relation to other matches
347 * @ops: the operations lookup table of the corresponding ematch module
348 * @datalen: length of the ematch specific configuration data
349 * @data: ematch specific data
350 */
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000351struct tcf_ematch {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 struct tcf_ematch_ops * ops;
353 unsigned long data;
354 unsigned int datalen;
355 u16 matchid;
356 u16 flags;
John Fastabend82a470f2014-10-05 21:27:53 -0700357 struct net *net;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358};
359
360static inline int tcf_em_is_container(struct tcf_ematch *em)
361{
362 return !em->ops;
363}
364
365static inline int tcf_em_is_simple(struct tcf_ematch *em)
366{
367 return em->flags & TCF_EM_SIMPLE;
368}
369
370static inline int tcf_em_is_inverted(struct tcf_ematch *em)
371{
372 return em->flags & TCF_EM_INVERT;
373}
374
375static inline int tcf_em_last_match(struct tcf_ematch *em)
376{
377 return (em->flags & TCF_EM_REL_MASK) == TCF_EM_REL_END;
378}
379
380static inline int tcf_em_early_end(struct tcf_ematch *em, int result)
381{
382 if (tcf_em_last_match(em))
383 return 1;
384
385 if (result == 0 && em->flags & TCF_EM_REL_AND)
386 return 1;
387
388 if (result != 0 && em->flags & TCF_EM_REL_OR)
389 return 1;
390
391 return 0;
392}
393
394/**
395 * struct tcf_ematch_tree - ematch tree handle
396 *
397 * @hdr: ematch tree header supplied by userspace
398 * @matches: array of ematches
399 */
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000400struct tcf_ematch_tree {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 struct tcf_ematch_tree_hdr hdr;
402 struct tcf_ematch * matches;
403
404};
405
406/**
407 * struct tcf_ematch_ops - ematch module operations
408 *
409 * @kind: identifier (kind) of this ematch module
410 * @datalen: length of expected configuration data (optional)
411 * @change: called during validation (optional)
412 * @match: called during ematch tree evaluation, must return 1/0
413 * @destroy: called during destroyage (optional)
414 * @dump: called during dumping process (optional)
415 * @owner: owner, must be set to THIS_MODULE
416 * @link: link to previous/next ematch module (internal use)
417 */
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000418struct tcf_ematch_ops {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 int kind;
420 int datalen;
John Fastabend82a470f2014-10-05 21:27:53 -0700421 int (*change)(struct net *net, void *,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 int, struct tcf_ematch *);
423 int (*match)(struct sk_buff *, struct tcf_ematch *,
424 struct tcf_pkt_info *);
John Fastabend82a470f2014-10-05 21:27:53 -0700425 void (*destroy)(struct tcf_ematch *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 int (*dump)(struct sk_buff *, struct tcf_ematch *);
427 struct module *owner;
428 struct list_head link;
429};
430
Joe Perches5c152572013-07-30 22:47:13 -0700431int tcf_em_register(struct tcf_ematch_ops *);
432void tcf_em_unregister(struct tcf_ematch_ops *);
433int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *,
434 struct tcf_ematch_tree *);
John Fastabend82a470f2014-10-05 21:27:53 -0700435void tcf_em_tree_destroy(struct tcf_ematch_tree *);
Joe Perches5c152572013-07-30 22:47:13 -0700436int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int);
437int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *,
438 struct tcf_pkt_info *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
440/**
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 * tcf_em_tree_match - evaulate an ematch tree
442 *
443 * @skb: socket buffer of the packet in question
444 * @tree: ematch tree to be used for evaluation
445 * @info: packet information examined by classifier
446 *
447 * This function matches @skb against the ematch tree in @tree by going
448 * through all ematches respecting their logic relations returning
449 * as soon as the result is obvious.
450 *
451 * Returns 1 if the ematch tree as-one matches, no ematches are configured
452 * or ematch is not enabled in the kernel, otherwise 0 is returned.
453 */
454static inline int tcf_em_tree_match(struct sk_buff *skb,
455 struct tcf_ematch_tree *tree,
456 struct tcf_pkt_info *info)
457{
458 if (tree->hdr.nmatches)
459 return __tcf_em_tree_match(skb, tree, info);
460 else
461 return 1;
462}
463
Patrick McHardydb3d99c2007-07-11 19:46:26 -0700464#define MODULE_ALIAS_TCF_EMATCH(kind) MODULE_ALIAS("ematch-kind-" __stringify(kind))
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466#else /* CONFIG_NET_EMATCH */
467
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000468struct tcf_ematch_tree {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469};
470
471#define tcf_em_tree_validate(tp, tb, t) ((void)(t), 0)
John Fastabend82a470f2014-10-05 21:27:53 -0700472#define tcf_em_tree_destroy(t) do { (void)(t); } while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473#define tcf_em_tree_dump(skb, t, tlv) (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474#define tcf_em_tree_match(skb, t, info) ((void)(info), 1)
475
476#endif /* CONFIG_NET_EMATCH */
477
478static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer)
479{
480 switch (layer) {
481 case TCF_LAYER_LINK:
Wolfgang Bumillerd3303a62018-01-18 11:32:36 +0100482 return skb_mac_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 case TCF_LAYER_NETWORK:
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -0700484 return skb_network_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 case TCF_LAYER_TRANSPORT:
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -0700486 return skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 }
488
489 return NULL;
490}
491
Arnaldo Carvalho de Meloeddc9ec2007-04-20 22:47:35 -0700492static inline int tcf_valid_offset(const struct sk_buff *skb,
493 const unsigned char *ptr, const int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494{
David S. Millerda521b22010-12-21 12:43:16 -0800495 return likely((ptr + len) <= skb_tail_pointer(skb) &&
496 ptr >= skb->head &&
497 (ptr <= (ptr + len)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498}
499
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500static inline int
Alexander Aring1057c552018-01-18 11:20:54 -0500501tcf_change_indev(struct net *net, struct nlattr *indev_tlv,
502 struct netlink_ext_ack *extack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503{
WANG Cong2519a602014-01-09 16:14:02 -0800504 char indev[IFNAMSIZ];
Patrick McHardyc01003c2007-03-29 11:46:52 -0700505 struct net_device *dev;
506
Alexander Aring1057c552018-01-18 11:20:54 -0500507 if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) {
Guillaume Naulte4a58ef2020-03-23 21:48:47 +0100508 NL_SET_ERR_MSG_ATTR(extack, indev_tlv,
509 "Interface name too long");
WANG Cong2519a602014-01-09 16:14:02 -0800510 return -EINVAL;
Alexander Aring1057c552018-01-18 11:20:54 -0500511 }
WANG Cong2519a602014-01-09 16:14:02 -0800512 dev = __dev_get_by_name(net, indev);
Guillaume Naulte4a58ef2020-03-23 21:48:47 +0100513 if (!dev) {
514 NL_SET_ERR_MSG_ATTR(extack, indev_tlv,
515 "Network device not found");
WANG Cong2519a602014-01-09 16:14:02 -0800516 return -ENODEV;
Guillaume Naulte4a58ef2020-03-23 21:48:47 +0100517 }
WANG Cong2519a602014-01-09 16:14:02 -0800518 return dev->ifindex;
519}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
WANG Cong2519a602014-01-09 16:14:02 -0800521static inline bool
522tcf_match_indev(struct sk_buff *skb, int ifindex)
523{
524 if (!ifindex)
525 return true;
526 if (!skb->skb_iif)
527 return false;
528 return ifindex == skb->skb_iif;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Pablo Neira Ayuso3a7b6862019-02-02 12:50:46 +0100531int tc_setup_flow_action(struct flow_action *flow_action,
Vlad Buslovb15e7a62020-02-17 12:12:12 +0200532 const struct tcf_exts *exts);
Vlad Buslov5a6ff4b2019-08-26 16:45:04 +0300533void tc_cleanup_flow_action(struct flow_action *flow_action);
534
Cong Wangaeb3fec2018-12-11 11:15:46 -0800535int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
Vlad Buslov40119212019-08-26 16:44:59 +0300536 void *type_data, bool err_stop, bool rtnl_held);
537int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp,
538 enum tc_setup_type type, void *type_data, bool err_stop,
539 u32 *flags, unsigned int *in_hw_count, bool rtnl_held);
540int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp,
541 enum tc_setup_type type, void *type_data, bool err_stop,
542 u32 *old_flags, unsigned int *old_in_hw_count,
543 u32 *new_flags, unsigned int *new_in_hw_count,
544 bool rtnl_held);
545int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp,
546 enum tc_setup_type type, void *type_data, bool err_stop,
547 u32 *flags, unsigned int *in_hw_count, bool rtnl_held);
548int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp,
549 bool add, flow_setup_cb_t *cb,
550 enum tc_setup_type type, void *type_data,
551 void *cb_priv, u32 *flags, unsigned int *in_hw_count);
Pablo Neira Ayusoe3ab7862019-02-02 12:50:45 +0100552unsigned int tcf_exts_num_actions(struct tcf_exts *exts);
Jiri Pirko717503b2017-10-11 09:41:09 +0200553
John Fastabenda1b7c5f2016-02-16 21:17:09 -0800554struct tc_cls_u32_knode {
555 struct tcf_exts *exts;
Jakub Kicinski068ceb32018-11-19 15:21:46 -0800556 struct tcf_result *res;
John Fastabende0148602016-02-17 14:59:30 -0800557 struct tc_u32_sel *sel;
John Fastabenda1b7c5f2016-02-16 21:17:09 -0800558 u32 handle;
559 u32 val;
560 u32 mask;
561 u32 link_handle;
John Fastabende0148602016-02-17 14:59:30 -0800562 u8 fshift;
John Fastabenda1b7c5f2016-02-16 21:17:09 -0800563};
564
565struct tc_cls_u32_hnode {
566 u32 handle;
567 u32 prio;
568 unsigned int divisor;
569};
570
571enum tc_clsu32_command {
572 TC_CLSU32_NEW_KNODE,
573 TC_CLSU32_REPLACE_KNODE,
574 TC_CLSU32_DELETE_KNODE,
575 TC_CLSU32_NEW_HNODE,
576 TC_CLSU32_REPLACE_HNODE,
577 TC_CLSU32_DELETE_HNODE,
578};
579
580struct tc_cls_u32_offload {
Pablo Neira Ayusof9e30082019-07-09 22:55:49 +0200581 struct flow_cls_common_offload common;
John Fastabenda1b7c5f2016-02-16 21:17:09 -0800582 /* knode values */
583 enum tc_clsu32_command command;
584 union {
585 struct tc_cls_u32_knode knode;
586 struct tc_cls_u32_hnode hnode;
587 };
588};
589
Jiri Pirko7b06e8a2017-08-09 14:30:35 +0200590static inline bool tc_can_offload(const struct net_device *dev)
John Fastabend6843e7a2016-02-26 07:53:49 -0800591{
Jiri Pirko70b5aee2017-11-01 11:47:41 +0100592 return dev->features & NETIF_F_HW_TC;
John Fastabend6843e7a2016-02-26 07:53:49 -0800593}
594
Quentin Monnetf9eda142018-01-19 17:44:48 -0800595static inline bool tc_can_offload_extack(const struct net_device *dev,
596 struct netlink_ext_ack *extack)
597{
598 bool can = tc_can_offload(dev);
599
600 if (!can)
601 NL_SET_ERR_MSG(extack, "TC offload is disabled on net device");
602
603 return can;
604}
605
Jakub Kicinski878db9f2018-01-25 14:00:43 -0800606static inline bool
607tc_cls_can_offload_and_chain0(const struct net_device *dev,
Pablo Neira Ayusof9e30082019-07-09 22:55:49 +0200608 struct flow_cls_common_offload *common)
Jakub Kicinski878db9f2018-01-25 14:00:43 -0800609{
610 if (!tc_can_offload_extack(dev, common->extack))
611 return false;
612 if (common->chain_index) {
613 NL_SET_ERR_MSG(common->extack,
614 "Driver supports only offload of chain 0");
615 return false;
616 }
617 return true;
618}
619
Hadar Hen Zion55330f02016-12-01 14:06:33 +0200620static inline bool tc_skip_hw(u32 flags)
621{
622 return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false;
623}
624
Samudrala, Sridhard34e3e12016-05-12 17:08:23 -0700625static inline bool tc_skip_sw(u32 flags)
626{
627 return (flags & TCA_CLS_FLAGS_SKIP_SW) ? true : false;
628}
629
630/* SKIP_HW and SKIP_SW are mutually exclusive flags. */
631static inline bool tc_flags_valid(u32 flags)
632{
Marcelo Ricardo Leitner81c72882018-05-13 17:44:27 -0300633 if (flags & ~(TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW |
634 TCA_CLS_FLAGS_VERBOSE))
Samudrala, Sridhard34e3e12016-05-12 17:08:23 -0700635 return false;
636
Marcelo Ricardo Leitner81c72882018-05-13 17:44:27 -0300637 flags &= TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW;
Samudrala, Sridhard34e3e12016-05-12 17:08:23 -0700638 if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW)))
639 return false;
640
641 return true;
642}
643
Or Gerlitze6960282017-02-16 10:31:12 +0200644static inline bool tc_in_hw(u32 flags)
645{
646 return (flags & TCA_CLS_FLAGS_IN_HW) ? true : false;
647}
648
Jakub Kicinski34832e12018-01-24 12:54:14 -0800649static inline void
Pablo Neira Ayusof9e30082019-07-09 22:55:49 +0200650tc_cls_common_offload_init(struct flow_cls_common_offload *cls_common,
Jakub Kicinski34832e12018-01-24 12:54:14 -0800651 const struct tcf_proto *tp, u32 flags,
652 struct netlink_ext_ack *extack)
653{
654 cls_common->chain_index = tp->chain->index;
655 cls_common->protocol = tp->protocol;
Pablo Neira Ayusoef01ada2019-08-16 03:24:09 +0200656 cls_common->prio = tp->prio >> 16;
Marcelo Ricardo Leitner81c72882018-05-13 17:44:27 -0300657 if (tc_skip_sw(flags) || flags & TCA_CLS_FLAGS_VERBOSE)
Jakub Kicinski34832e12018-01-24 12:54:14 -0800658 cls_common->extack = extack;
659}
660
Yotam Gigib87f7932016-07-21 12:03:12 +0200661enum tc_matchall_command {
662 TC_CLSMATCHALL_REPLACE,
663 TC_CLSMATCHALL_DESTROY,
Pieter Jansen van Vuurenb7fe4ab2019-05-04 04:46:23 -0700664 TC_CLSMATCHALL_STATS,
Yotam Gigib87f7932016-07-21 12:03:12 +0200665};
666
667struct tc_cls_matchall_offload {
Pablo Neira Ayusof9e30082019-07-09 22:55:49 +0200668 struct flow_cls_common_offload common;
Yotam Gigib87f7932016-07-21 12:03:12 +0200669 enum tc_matchall_command command;
Pieter Jansen van Vuurenf00cbf192019-05-04 04:46:17 -0700670 struct flow_rule *rule;
Pieter Jansen van Vuurenb7fe4ab2019-05-04 04:46:23 -0700671 struct flow_stats stats;
Yotam Gigib87f7932016-07-21 12:03:12 +0200672 unsigned long cookie;
673};
674
Jakub Kicinski332ae8e2016-09-21 11:43:53 +0100675enum tc_clsbpf_command {
Jakub Kicinski102740b2017-12-19 13:32:13 -0800676 TC_CLSBPF_OFFLOAD,
Jakub Kicinski68d64062016-09-21 11:44:02 +0100677 TC_CLSBPF_STATS,
Jakub Kicinski332ae8e2016-09-21 11:43:53 +0100678};
679
680struct tc_cls_bpf_offload {
Pablo Neira Ayusof9e30082019-07-09 22:55:49 +0200681 struct flow_cls_common_offload common;
Jakub Kicinski332ae8e2016-09-21 11:43:53 +0100682 enum tc_clsbpf_command command;
683 struct tcf_exts *exts;
684 struct bpf_prog *prog;
Jakub Kicinski102740b2017-12-19 13:32:13 -0800685 struct bpf_prog *oldprog;
Jakub Kicinski332ae8e2016-09-21 11:43:53 +0100686 const char *name;
687 bool exts_integrated;
688};
689
Amritha Nambiar4e8b86c2017-09-07 04:00:06 -0700690struct tc_mqprio_qopt_offload {
691 /* struct tc_mqprio_qopt must always be the first element */
692 struct tc_mqprio_qopt qopt;
693 u16 mode;
694 u16 shaper;
695 u32 flags;
696 u64 min_rate[TC_QOPT_MAX_QUEUE];
697 u64 max_rate[TC_QOPT_MAX_QUEUE];
698};
Jamal Hadi Salim1045ba72017-01-24 07:02:41 -0500699
700/* This structure holds cookie structure that is passed from user
701 * to the kernel for actions and classifiers
702 */
703struct tc_cookie {
704 u8 *data;
705 u32 len;
Vlad Busloveec94fd2018-07-05 17:24:23 +0300706 struct rcu_head rcu;
Jamal Hadi Salim1045ba72017-01-24 07:02:41 -0500707};
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100708
Nogah Frankelf34b4aa2018-01-10 14:59:58 +0100709struct tc_qopt_offload_stats {
710 struct gnet_stats_basic_packed *bstats;
711 struct gnet_stats_queue *qstats;
712};
713
Jakub Kicinskif971b132018-05-25 21:53:35 -0700714enum tc_mq_command {
715 TC_MQ_CREATE,
716 TC_MQ_DESTROY,
Jakub Kicinski47c669a42018-05-25 21:53:37 -0700717 TC_MQ_STATS,
Jakub Kicinskid577a3d2018-11-12 14:58:14 -0800718 TC_MQ_GRAFT,
719};
720
721struct tc_mq_opt_offload_graft_params {
722 unsigned long queue;
723 u32 child_handle;
Jakub Kicinskif971b132018-05-25 21:53:35 -0700724};
725
726struct tc_mq_qopt_offload {
727 enum tc_mq_command command;
728 u32 handle;
Jakub Kicinskid577a3d2018-11-12 14:58:14 -0800729 union {
730 struct tc_qopt_offload_stats stats;
731 struct tc_mq_opt_offload_graft_params graft_params;
732 };
Jakub Kicinskif971b132018-05-25 21:53:35 -0700733};
734
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100735enum tc_red_command {
736 TC_RED_REPLACE,
737 TC_RED_DESTROY,
738 TC_RED_STATS,
739 TC_RED_XSTATS,
Jakub Kicinskibf2a7522018-11-12 14:58:13 -0800740 TC_RED_GRAFT,
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100741};
742
743struct tc_red_qopt_offload_params {
744 u32 min;
745 u32 max;
746 u32 probability;
Jakub Kicinskic0b74902018-11-12 14:58:16 -0800747 u32 limit;
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100748 bool is_ecn;
Jakub Kicinski190852a2018-11-08 19:50:38 -0800749 bool is_harddrop;
Petr Machata0a7fad22020-03-13 01:10:57 +0200750 bool is_nodrop;
Jakub Kicinski416ef9b2018-01-14 20:01:26 -0800751 struct gnet_stats_queue *qstats;
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100752};
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100753
754struct tc_red_qopt_offload {
755 enum tc_red_command command;
756 u32 handle;
757 u32 parent;
758 union {
759 struct tc_red_qopt_offload_params set;
Nogah Frankelf34b4aa2018-01-10 14:59:58 +0100760 struct tc_qopt_offload_stats stats;
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100761 struct red_stats *xstats;
Jakub Kicinskibf2a7522018-11-12 14:58:13 -0800762 u32 child_handle;
Nogah Frankel602f3ba2017-11-06 07:23:41 +0100763 };
764};
765
Jakub Kicinski890d8d22018-11-19 15:21:42 -0800766enum tc_gred_command {
767 TC_GRED_REPLACE,
768 TC_GRED_DESTROY,
Jakub Kicinskie49efd52018-11-19 15:21:43 -0800769 TC_GRED_STATS,
Jakub Kicinski890d8d22018-11-19 15:21:42 -0800770};
771
772struct tc_gred_vq_qopt_offload_params {
773 bool present;
774 u32 limit;
775 u32 prio;
776 u32 min;
777 u32 max;
778 bool is_ecn;
779 bool is_harddrop;
780 u32 probability;
781 /* Only need backlog, see struct tc_prio_qopt_offload_params */
782 u32 *backlog;
783};
784
785struct tc_gred_qopt_offload_params {
786 bool grio_on;
787 bool wred_on;
788 unsigned int dp_cnt;
789 unsigned int dp_def;
790 struct gnet_stats_queue *qstats;
791 struct tc_gred_vq_qopt_offload_params tab[MAX_DPs];
792};
793
Jakub Kicinskie49efd52018-11-19 15:21:43 -0800794struct tc_gred_qopt_offload_stats {
795 struct gnet_stats_basic_packed bstats[MAX_DPs];
796 struct gnet_stats_queue qstats[MAX_DPs];
797 struct red_stats *xstats[MAX_DPs];
798};
799
Jakub Kicinski890d8d22018-11-19 15:21:42 -0800800struct tc_gred_qopt_offload {
801 enum tc_gred_command command;
802 u32 handle;
803 u32 parent;
804 union {
805 struct tc_gred_qopt_offload_params set;
Jakub Kicinskie49efd52018-11-19 15:21:43 -0800806 struct tc_gred_qopt_offload_stats stats;
Jakub Kicinski890d8d22018-11-19 15:21:42 -0800807 };
808};
809
Nogah Frankel7fdb61b2018-01-14 12:33:15 +0100810enum tc_prio_command {
811 TC_PRIO_REPLACE,
812 TC_PRIO_DESTROY,
813 TC_PRIO_STATS,
Nogah Frankelb9c7a7a2018-02-28 10:45:06 +0100814 TC_PRIO_GRAFT,
Nogah Frankel7fdb61b2018-01-14 12:33:15 +0100815};
816
817struct tc_prio_qopt_offload_params {
818 int bands;
819 u8 priomap[TC_PRIO_MAX + 1];
Petr Machata9586a992019-12-18 14:55:08 +0000820 /* At the point of un-offloading the Qdisc, the reported backlog and
821 * qlen need to be reduced by the portion that is in HW.
Nogah Frankel7fdb61b2018-01-14 12:33:15 +0100822 */
823 struct gnet_stats_queue *qstats;
824};
825
Nogah Frankelb9c7a7a2018-02-28 10:45:06 +0100826struct tc_prio_qopt_offload_graft_params {
827 u8 band;
828 u32 child_handle;
829};
830
Nogah Frankel7fdb61b2018-01-14 12:33:15 +0100831struct tc_prio_qopt_offload {
832 enum tc_prio_command command;
833 u32 handle;
834 u32 parent;
835 union {
836 struct tc_prio_qopt_offload_params replace_params;
837 struct tc_qopt_offload_stats stats;
Nogah Frankelb9c7a7a2018-02-28 10:45:06 +0100838 struct tc_prio_qopt_offload_graft_params graft_params;
Nogah Frankel7fdb61b2018-01-14 12:33:15 +0100839 };
840};
Nogah Frankelb9c7a7a2018-02-28 10:45:06 +0100841
Jakub Kicinski98b0e5f2018-11-12 14:58:10 -0800842enum tc_root_command {
843 TC_ROOT_GRAFT,
844};
845
846struct tc_root_qopt_offload {
847 enum tc_root_command command;
848 u32 handle;
849 bool ingress;
850};
851
Petr Machatad35eb522019-12-18 14:55:15 +0000852enum tc_ets_command {
853 TC_ETS_REPLACE,
854 TC_ETS_DESTROY,
855 TC_ETS_STATS,
856 TC_ETS_GRAFT,
857};
858
859struct tc_ets_qopt_offload_replace_params {
860 unsigned int bands;
861 u8 priomap[TC_PRIO_MAX + 1];
862 unsigned int quanta[TCQ_ETS_MAX_BANDS]; /* 0 for strict bands. */
863 unsigned int weights[TCQ_ETS_MAX_BANDS];
864 struct gnet_stats_queue *qstats;
865};
866
867struct tc_ets_qopt_offload_graft_params {
868 u8 band;
869 u32 child_handle;
870};
871
872struct tc_ets_qopt_offload {
873 enum tc_ets_command command;
874 u32 handle;
875 u32 parent;
876 union {
877 struct tc_ets_qopt_offload_replace_params replace_params;
878 struct tc_qopt_offload_stats stats;
879 struct tc_ets_qopt_offload_graft_params graft_params;
880 };
881};
882
Petr Machataef6aadc2020-01-24 15:23:06 +0200883enum tc_tbf_command {
884 TC_TBF_REPLACE,
885 TC_TBF_DESTROY,
886 TC_TBF_STATS,
887};
888
889struct tc_tbf_qopt_offload_replace_params {
890 struct psched_ratecfg rate;
891 u32 max_size;
892 struct gnet_stats_queue *qstats;
893};
894
895struct tc_tbf_qopt_offload {
896 enum tc_tbf_command command;
897 u32 handle;
898 u32 parent;
899 union {
900 struct tc_tbf_qopt_offload_replace_params replace_params;
901 struct tc_qopt_offload_stats stats;
902 };
903};
904
Petr Machataaaca9402020-03-05 09:16:40 +0200905enum tc_fifo_command {
906 TC_FIFO_REPLACE,
907 TC_FIFO_DESTROY,
908 TC_FIFO_STATS,
909};
910
911struct tc_fifo_qopt_offload {
912 enum tc_fifo_command command;
913 u32 handle;
914 u32 parent;
915 union {
916 struct tc_qopt_offload_stats stats;
917 };
918};
919
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920#endif