xref: /openbmc/linux/include/net/pkt_cls.h (revision 33c30a8b)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef __NET_PKT_CLS_H
31da177e4SLinus Torvalds #define __NET_PKT_CLS_H
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #include <linux/pkt_cls.h>
67aa0045dSCong Wang #include <linux/workqueue.h>
71da177e4SLinus Torvalds #include <net/sch_generic.h>
81da177e4SLinus Torvalds #include <net/act_api.h>
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds /* Basic packet classifier frontend definitions. */
111da177e4SLinus Torvalds 
12fd2c3ef7SEric Dumazet struct tcf_walker {
131da177e4SLinus Torvalds 	int	stop;
141da177e4SLinus Torvalds 	int	skip;
151da177e4SLinus Torvalds 	int	count;
168113c095SWANG Cong 	int	(*fn)(struct tcf_proto *, void *node, struct tcf_walker *);
171da177e4SLinus Torvalds };
181da177e4SLinus Torvalds 
195c15257fSJoe Perches int register_tcf_proto_ops(struct tcf_proto_ops *ops);
205c15257fSJoe Perches int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
211da177e4SLinus Torvalds 
228c4083b3SJiri Pirko enum tcf_block_binder_type {
238c4083b3SJiri Pirko 	TCF_BLOCK_BINDER_TYPE_UNSPEC,
246e40cf2dSJiri Pirko 	TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS,
256e40cf2dSJiri Pirko 	TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS,
268c4083b3SJiri Pirko };
278c4083b3SJiri Pirko 
288c4083b3SJiri Pirko struct tcf_block_ext_info {
298c4083b3SJiri Pirko 	enum tcf_block_binder_type binder_type;
30c7eb7d72SJiri Pirko 	tcf_chain_head_change_t *chain_head_change;
31c7eb7d72SJiri Pirko 	void *chain_head_change_priv;
328c4083b3SJiri Pirko };
338c4083b3SJiri Pirko 
34acb67442SJiri Pirko struct tcf_block_cb;
357aa0045dSCong Wang bool tcf_queue_work(struct work_struct *work);
36acb67442SJiri Pirko 
378ae70032SJiri Pirko #ifdef CONFIG_NET_CLS
38367a8ce8SWANG Cong struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
39367a8ce8SWANG Cong 				bool create);
405bc17018SJiri Pirko void tcf_chain_put(struct tcf_chain *chain);
416529eabaSJiri Pirko int tcf_block_get(struct tcf_block **p_block,
428d1a77f9SAlexander Aring 		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
438d1a77f9SAlexander Aring 		  struct netlink_ext_ack *extack);
44c7eb7d72SJiri Pirko int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
458d1a77f9SAlexander Aring 		      struct tcf_block_ext_info *ei,
468d1a77f9SAlexander Aring 		      struct netlink_ext_ack *extack);
476529eabaSJiri Pirko void tcf_block_put(struct tcf_block *block);
48c7eb7d72SJiri Pirko void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
498c4083b3SJiri Pirko 		       struct tcf_block_ext_info *ei);
5044186460SJiri Pirko 
5144186460SJiri Pirko static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
5244186460SJiri Pirko {
5344186460SJiri Pirko 	return block->q;
5444186460SJiri Pirko }
5544186460SJiri Pirko 
5644186460SJiri Pirko static inline struct net_device *tcf_block_dev(struct tcf_block *block)
5744186460SJiri Pirko {
5844186460SJiri Pirko 	return tcf_block_q(block)->dev_queue->dev;
5944186460SJiri Pirko }
6044186460SJiri Pirko 
61acb67442SJiri Pirko void *tcf_block_cb_priv(struct tcf_block_cb *block_cb);
62acb67442SJiri Pirko struct tcf_block_cb *tcf_block_cb_lookup(struct tcf_block *block,
63acb67442SJiri Pirko 					 tc_setup_cb_t *cb, void *cb_ident);
64acb67442SJiri Pirko void tcf_block_cb_incref(struct tcf_block_cb *block_cb);
65acb67442SJiri Pirko unsigned int tcf_block_cb_decref(struct tcf_block_cb *block_cb);
66acb67442SJiri Pirko struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
67acb67442SJiri Pirko 					     tc_setup_cb_t *cb, void *cb_ident,
68acb67442SJiri Pirko 					     void *cb_priv);
69acb67442SJiri Pirko int tcf_block_cb_register(struct tcf_block *block,
70acb67442SJiri Pirko 			  tc_setup_cb_t *cb, void *cb_ident,
71acb67442SJiri Pirko 			  void *cb_priv);
72acb67442SJiri Pirko void __tcf_block_cb_unregister(struct tcf_block_cb *block_cb);
73acb67442SJiri Pirko void tcf_block_cb_unregister(struct tcf_block *block,
74acb67442SJiri Pirko 			     tc_setup_cb_t *cb, void *cb_ident);
75acb67442SJiri Pirko 
7687d83093SJiri Pirko int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
7787d83093SJiri Pirko 		 struct tcf_result *res, bool compat_mode);
7887d83093SJiri Pirko 
798ae70032SJiri Pirko #else
806529eabaSJiri Pirko static inline
816529eabaSJiri Pirko int tcf_block_get(struct tcf_block **p_block,
823c149091SSudip Mukherjee 		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
833c149091SSudip Mukherjee 		  struct netlink_ext_ack *extack)
846529eabaSJiri Pirko {
856529eabaSJiri Pirko 	return 0;
866529eabaSJiri Pirko }
876529eabaSJiri Pirko 
888c4083b3SJiri Pirko static inline
89c7eb7d72SJiri Pirko int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
9033c30a8bSQuentin Monnet 		      struct tcf_block_ext_info *ei,
9133c30a8bSQuentin Monnet 		      struct netlink_ext_ack *extack)
928c4083b3SJiri Pirko {
938c4083b3SJiri Pirko 	return 0;
948c4083b3SJiri Pirko }
958c4083b3SJiri Pirko 
966529eabaSJiri Pirko static inline void tcf_block_put(struct tcf_block *block)
978ae70032SJiri Pirko {
988ae70032SJiri Pirko }
9987d83093SJiri Pirko 
1008c4083b3SJiri Pirko static inline
101c7eb7d72SJiri Pirko void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
1028c4083b3SJiri Pirko 		       struct tcf_block_ext_info *ei)
1038c4083b3SJiri Pirko {
1048c4083b3SJiri Pirko }
1058c4083b3SJiri Pirko 
10644186460SJiri Pirko static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
10744186460SJiri Pirko {
10844186460SJiri Pirko 	return NULL;
10944186460SJiri Pirko }
11044186460SJiri Pirko 
11144186460SJiri Pirko static inline struct net_device *tcf_block_dev(struct tcf_block *block)
11244186460SJiri Pirko {
11344186460SJiri Pirko 	return NULL;
11444186460SJiri Pirko }
11544186460SJiri Pirko 
116acb67442SJiri Pirko static inline
117acb67442SJiri Pirko int tc_setup_cb_block_register(struct tcf_block *block, tc_setup_cb_t *cb,
118acb67442SJiri Pirko 			       void *cb_priv)
119acb67442SJiri Pirko {
120acb67442SJiri Pirko 	return 0;
121acb67442SJiri Pirko }
122acb67442SJiri Pirko 
123acb67442SJiri Pirko static inline
124acb67442SJiri Pirko void tc_setup_cb_block_unregister(struct tcf_block *block, tc_setup_cb_t *cb,
125acb67442SJiri Pirko 				  void *cb_priv)
126acb67442SJiri Pirko {
127acb67442SJiri Pirko }
128acb67442SJiri Pirko 
129acb67442SJiri Pirko static inline
130acb67442SJiri Pirko void *tcf_block_cb_priv(struct tcf_block_cb *block_cb)
131acb67442SJiri Pirko {
132acb67442SJiri Pirko 	return NULL;
133acb67442SJiri Pirko }
134acb67442SJiri Pirko 
135acb67442SJiri Pirko static inline
136acb67442SJiri Pirko struct tcf_block_cb *tcf_block_cb_lookup(struct tcf_block *block,
137acb67442SJiri Pirko 					 tc_setup_cb_t *cb, void *cb_ident)
138acb67442SJiri Pirko {
139acb67442SJiri Pirko 	return NULL;
140acb67442SJiri Pirko }
141acb67442SJiri Pirko 
142acb67442SJiri Pirko static inline
143acb67442SJiri Pirko void tcf_block_cb_incref(struct tcf_block_cb *block_cb)
144acb67442SJiri Pirko {
145acb67442SJiri Pirko }
146acb67442SJiri Pirko 
147acb67442SJiri Pirko static inline
148acb67442SJiri Pirko unsigned int tcf_block_cb_decref(struct tcf_block_cb *block_cb)
149acb67442SJiri Pirko {
150acb67442SJiri Pirko 	return 0;
151acb67442SJiri Pirko }
152acb67442SJiri Pirko 
153acb67442SJiri Pirko static inline
154acb67442SJiri Pirko struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
155acb67442SJiri Pirko 					     tc_setup_cb_t *cb, void *cb_ident,
156acb67442SJiri Pirko 					     void *cb_priv)
157acb67442SJiri Pirko {
158acb67442SJiri Pirko 	return NULL;
159acb67442SJiri Pirko }
160acb67442SJiri Pirko 
161acb67442SJiri Pirko static inline
162acb67442SJiri Pirko int tcf_block_cb_register(struct tcf_block *block,
163acb67442SJiri Pirko 			  tc_setup_cb_t *cb, void *cb_ident,
164acb67442SJiri Pirko 			  void *cb_priv)
165acb67442SJiri Pirko {
166acb67442SJiri Pirko 	return 0;
167acb67442SJiri Pirko }
168acb67442SJiri Pirko 
169acb67442SJiri Pirko static inline
170acb67442SJiri Pirko void __tcf_block_cb_unregister(struct tcf_block_cb *block_cb)
171acb67442SJiri Pirko {
172acb67442SJiri Pirko }
173acb67442SJiri Pirko 
174acb67442SJiri Pirko static inline
175acb67442SJiri Pirko void tcf_block_cb_unregister(struct tcf_block *block,
176acb67442SJiri Pirko 			     tc_setup_cb_t *cb, void *cb_ident)
177acb67442SJiri Pirko {
178acb67442SJiri Pirko }
179acb67442SJiri Pirko 
18087d83093SJiri Pirko static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
18187d83093SJiri Pirko 			       struct tcf_result *res, bool compat_mode)
18287d83093SJiri Pirko {
18387d83093SJiri Pirko 	return TC_ACT_UNSPEC;
18487d83093SJiri Pirko }
1858ae70032SJiri Pirko #endif
186cf1facdaSJiri Pirko 
1871da177e4SLinus Torvalds static inline unsigned long
1881da177e4SLinus Torvalds __cls_set_class(unsigned long *clp, unsigned long cl)
1891da177e4SLinus Torvalds {
190a0efb80cSWANG Cong 	return xchg(clp, cl);
1911da177e4SLinus Torvalds }
1921da177e4SLinus Torvalds 
1931da177e4SLinus Torvalds static inline unsigned long
19434e3759cSJiri Pirko cls_set_class(struct Qdisc *q, unsigned long *clp, unsigned long cl)
1951da177e4SLinus Torvalds {
1961da177e4SLinus Torvalds 	unsigned long old_cl;
1971da177e4SLinus Torvalds 
19834e3759cSJiri Pirko 	sch_tree_lock(q);
1991da177e4SLinus Torvalds 	old_cl = __cls_set_class(clp, cl);
20034e3759cSJiri Pirko 	sch_tree_unlock(q);
2011da177e4SLinus Torvalds 	return old_cl;
2021da177e4SLinus Torvalds }
2031da177e4SLinus Torvalds 
2041da177e4SLinus Torvalds static inline void
2051da177e4SLinus Torvalds tcf_bind_filter(struct tcf_proto *tp, struct tcf_result *r, unsigned long base)
2061da177e4SLinus Torvalds {
20734e3759cSJiri Pirko 	struct Qdisc *q = tp->chain->block->q;
2081da177e4SLinus Torvalds 	unsigned long cl;
2091da177e4SLinus Torvalds 
21034e3759cSJiri Pirko 	/* Check q as it is not set for shared blocks. In that case,
21134e3759cSJiri Pirko 	 * setting class is not supported.
21234e3759cSJiri Pirko 	 */
21334e3759cSJiri Pirko 	if (!q)
21434e3759cSJiri Pirko 		return;
21534e3759cSJiri Pirko 	cl = q->ops->cl_ops->bind_tcf(q, base, r->classid);
21634e3759cSJiri Pirko 	cl = cls_set_class(q, &r->class, cl);
2171da177e4SLinus Torvalds 	if (cl)
21834e3759cSJiri Pirko 		q->ops->cl_ops->unbind_tcf(q, cl);
2191da177e4SLinus Torvalds }
2201da177e4SLinus Torvalds 
2211da177e4SLinus Torvalds static inline void
2221da177e4SLinus Torvalds tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r)
2231da177e4SLinus Torvalds {
22434e3759cSJiri Pirko 	struct Qdisc *q = tp->chain->block->q;
2251da177e4SLinus Torvalds 	unsigned long cl;
2261da177e4SLinus Torvalds 
22734e3759cSJiri Pirko 	if (!q)
22834e3759cSJiri Pirko 		return;
2291da177e4SLinus Torvalds 	if ((cl = __cls_set_class(&r->class, 0)) != 0)
23034e3759cSJiri Pirko 		q->ops->cl_ops->unbind_tcf(q, cl);
2311da177e4SLinus Torvalds }
2321da177e4SLinus Torvalds 
233fd2c3ef7SEric Dumazet struct tcf_exts {
2341da177e4SLinus Torvalds #ifdef CONFIG_NET_CLS_ACT
23533be6271SWANG Cong 	__u32	type; /* for backward compat(TCA_OLD_COMPAT) */
23622dc13c8SWANG Cong 	int nr_actions;
23722dc13c8SWANG Cong 	struct tc_action **actions;
238e4b95c41SCong Wang 	struct net *net;
2391da177e4SLinus Torvalds #endif
2401da177e4SLinus Torvalds 	/* Map to export classifier specific extension TLV types to the
2411da177e4SLinus Torvalds 	 * generic extensions API. Unsupported extensions must be set to 0.
2421da177e4SLinus Torvalds 	 */
2431da177e4SLinus Torvalds 	int action;
2441da177e4SLinus Torvalds 	int police;
2451da177e4SLinus Torvalds };
2461da177e4SLinus Torvalds 
247b9a24bb7SWANG Cong static inline int tcf_exts_init(struct tcf_exts *exts, int action, int police)
24833be6271SWANG Cong {
24933be6271SWANG Cong #ifdef CONFIG_NET_CLS_ACT
2505da57f42SWANG Cong 	exts->type = 0;
25122dc13c8SWANG Cong 	exts->nr_actions = 0;
252e4b95c41SCong Wang 	exts->net = NULL;
25322dc13c8SWANG Cong 	exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *),
25422dc13c8SWANG Cong 				GFP_KERNEL);
255b9a24bb7SWANG Cong 	if (!exts->actions)
256b9a24bb7SWANG Cong 		return -ENOMEM;
25733be6271SWANG Cong #endif
2585da57f42SWANG Cong 	exts->action = action;
2595da57f42SWANG Cong 	exts->police = police;
260b9a24bb7SWANG Cong 	return 0;
26133be6271SWANG Cong }
26233be6271SWANG Cong 
263e4b95c41SCong Wang /* Return false if the netns is being destroyed in cleanup_net(). Callers
264e4b95c41SCong Wang  * need to do cleanup synchronously in this case, otherwise may race with
265e4b95c41SCong Wang  * tc_action_net_exit(). Return true for other cases.
266e4b95c41SCong Wang  */
267e4b95c41SCong Wang static inline bool tcf_exts_get_net(struct tcf_exts *exts)
268e4b95c41SCong Wang {
269e4b95c41SCong Wang #ifdef CONFIG_NET_CLS_ACT
270e4b95c41SCong Wang 	exts->net = maybe_get_net(exts->net);
271e4b95c41SCong Wang 	return exts->net != NULL;
272e4b95c41SCong Wang #else
273e4b95c41SCong Wang 	return true;
274e4b95c41SCong Wang #endif
275e4b95c41SCong Wang }
276e4b95c41SCong Wang 
277e4b95c41SCong Wang static inline void tcf_exts_put_net(struct tcf_exts *exts)
278e4b95c41SCong Wang {
279e4b95c41SCong Wang #ifdef CONFIG_NET_CLS_ACT
280e4b95c41SCong Wang 	if (exts->net)
281e4b95c41SCong Wang 		put_net(exts->net);
282e4b95c41SCong Wang #endif
283e4b95c41SCong Wang }
284e4b95c41SCong Wang 
28522dc13c8SWANG Cong static inline void tcf_exts_to_list(const struct tcf_exts *exts,
28622dc13c8SWANG Cong 				    struct list_head *actions)
28722dc13c8SWANG Cong {
28822dc13c8SWANG Cong #ifdef CONFIG_NET_CLS_ACT
28922dc13c8SWANG Cong 	int i;
29022dc13c8SWANG Cong 
29122dc13c8SWANG Cong 	for (i = 0; i < exts->nr_actions; i++) {
29222dc13c8SWANG Cong 		struct tc_action *a = exts->actions[i];
29322dc13c8SWANG Cong 
294fa5effe7SHadar Hen Zion 		list_add_tail(&a->list, actions);
29522dc13c8SWANG Cong 	}
29622dc13c8SWANG Cong #endif
29722dc13c8SWANG Cong }
29822dc13c8SWANG Cong 
299d897a638SJakub Kicinski static inline void
300d897a638SJakub Kicinski tcf_exts_stats_update(const struct tcf_exts *exts,
301d897a638SJakub Kicinski 		      u64 bytes, u64 packets, u64 lastuse)
302d897a638SJakub Kicinski {
303d897a638SJakub Kicinski #ifdef CONFIG_NET_CLS_ACT
304d897a638SJakub Kicinski 	int i;
305d897a638SJakub Kicinski 
306d897a638SJakub Kicinski 	preempt_disable();
307d897a638SJakub Kicinski 
308d897a638SJakub Kicinski 	for (i = 0; i < exts->nr_actions; i++) {
309d897a638SJakub Kicinski 		struct tc_action *a = exts->actions[i];
310d897a638SJakub Kicinski 
311d897a638SJakub Kicinski 		tcf_action_stats_update(a, bytes, packets, lastuse);
312d897a638SJakub Kicinski 	}
313d897a638SJakub Kicinski 
314d897a638SJakub Kicinski 	preempt_enable();
315d897a638SJakub Kicinski #endif
316d897a638SJakub Kicinski }
317d897a638SJakub Kicinski 
3181da177e4SLinus Torvalds /**
3193bcc0cecSJiri Pirko  * tcf_exts_has_actions - check if at least one action is present
3203bcc0cecSJiri Pirko  * @exts: tc filter extensions handle
3213bcc0cecSJiri Pirko  *
3223bcc0cecSJiri Pirko  * Returns true if at least one action is present.
3233bcc0cecSJiri Pirko  */
3243bcc0cecSJiri Pirko static inline bool tcf_exts_has_actions(struct tcf_exts *exts)
3253bcc0cecSJiri Pirko {
3262734437eSWANG Cong #ifdef CONFIG_NET_CLS_ACT
3273bcc0cecSJiri Pirko 	return exts->nr_actions;
3283bcc0cecSJiri Pirko #else
3293bcc0cecSJiri Pirko 	return false;
3303bcc0cecSJiri Pirko #endif
3313bcc0cecSJiri Pirko }
3322734437eSWANG Cong 
3333bcc0cecSJiri Pirko /**
3343bcc0cecSJiri Pirko  * tcf_exts_has_one_action - check if exactly one action is present
3353bcc0cecSJiri Pirko  * @exts: tc filter extensions handle
3363bcc0cecSJiri Pirko  *
3373bcc0cecSJiri Pirko  * Returns true if exactly one action is present.
3383bcc0cecSJiri Pirko  */
3393bcc0cecSJiri Pirko static inline bool tcf_exts_has_one_action(struct tcf_exts *exts)
3403bcc0cecSJiri Pirko {
3413bcc0cecSJiri Pirko #ifdef CONFIG_NET_CLS_ACT
3423bcc0cecSJiri Pirko 	return exts->nr_actions == 1;
3433bcc0cecSJiri Pirko #else
3443bcc0cecSJiri Pirko 	return false;
3453bcc0cecSJiri Pirko #endif
3463bcc0cecSJiri Pirko }
3472734437eSWANG Cong 
348af69afc5SJiri Pirko /**
349af69afc5SJiri Pirko  * tcf_exts_exec - execute tc filter extensions
350af69afc5SJiri Pirko  * @skb: socket buffer
351af69afc5SJiri Pirko  * @exts: tc filter extensions handle
352af69afc5SJiri Pirko  * @res: desired result
353af69afc5SJiri Pirko  *
354af089e70SJiri Pirko  * Executes all configured extensions. Returns TC_ACT_OK on a normal execution,
355af69afc5SJiri Pirko  * a negative number if the filter must be considered unmatched or
356af69afc5SJiri Pirko  * a positive action code (TC_ACT_*) which must be returned to the
357af69afc5SJiri Pirko  * underlying layer.
358af69afc5SJiri Pirko  */
359af69afc5SJiri Pirko static inline int
360af69afc5SJiri Pirko tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
361af69afc5SJiri Pirko 	      struct tcf_result *res)
362af69afc5SJiri Pirko {
363af69afc5SJiri Pirko #ifdef CONFIG_NET_CLS_ACT
364ec1a9ccaSJiri Pirko 	return tcf_action_exec(skb, exts->actions, exts->nr_actions, res);
365af69afc5SJiri Pirko #endif
366af089e70SJiri Pirko 	return TC_ACT_OK;
367af69afc5SJiri Pirko }
368af69afc5SJiri Pirko 
3695c15257fSJoe Perches int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
370c1b52739SBenjamin LaHaise 		      struct nlattr **tb, struct nlattr *rate_tlv,
3712f7ef2f8SCong Wang 		      struct tcf_exts *exts, bool ovr);
37218d0264fSWANG Cong void tcf_exts_destroy(struct tcf_exts *exts);
3739b0d4446SJiri Pirko void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
3745da57f42SWANG Cong int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
3755da57f42SWANG Cong int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
3761da177e4SLinus Torvalds 
3771da177e4SLinus Torvalds /**
3781da177e4SLinus Torvalds  * struct tcf_pkt_info - packet information
3791da177e4SLinus Torvalds  */
380fd2c3ef7SEric Dumazet struct tcf_pkt_info {
3811da177e4SLinus Torvalds 	unsigned char *		ptr;
3821da177e4SLinus Torvalds 	int			nexthdr;
3831da177e4SLinus Torvalds };
3841da177e4SLinus Torvalds 
3851da177e4SLinus Torvalds #ifdef CONFIG_NET_EMATCH
3861da177e4SLinus Torvalds 
3871da177e4SLinus Torvalds struct tcf_ematch_ops;
3881da177e4SLinus Torvalds 
3891da177e4SLinus Torvalds /**
3901da177e4SLinus Torvalds  * struct tcf_ematch - extended match (ematch)
3911da177e4SLinus Torvalds  *
3921da177e4SLinus Torvalds  * @matchid: identifier to allow userspace to reidentify a match
3931da177e4SLinus Torvalds  * @flags: flags specifying attributes and the relation to other matches
3941da177e4SLinus Torvalds  * @ops: the operations lookup table of the corresponding ematch module
3951da177e4SLinus Torvalds  * @datalen: length of the ematch specific configuration data
3961da177e4SLinus Torvalds  * @data: ematch specific data
3971da177e4SLinus Torvalds  */
398fd2c3ef7SEric Dumazet struct tcf_ematch {
3991da177e4SLinus Torvalds 	struct tcf_ematch_ops * ops;
4001da177e4SLinus Torvalds 	unsigned long		data;
4011da177e4SLinus Torvalds 	unsigned int		datalen;
4021da177e4SLinus Torvalds 	u16			matchid;
4031da177e4SLinus Torvalds 	u16			flags;
40482a470f1SJohn Fastabend 	struct net		*net;
4051da177e4SLinus Torvalds };
4061da177e4SLinus Torvalds 
4071da177e4SLinus Torvalds static inline int tcf_em_is_container(struct tcf_ematch *em)
4081da177e4SLinus Torvalds {
4091da177e4SLinus Torvalds 	return !em->ops;
4101da177e4SLinus Torvalds }
4111da177e4SLinus Torvalds 
4121da177e4SLinus Torvalds static inline int tcf_em_is_simple(struct tcf_ematch *em)
4131da177e4SLinus Torvalds {
4141da177e4SLinus Torvalds 	return em->flags & TCF_EM_SIMPLE;
4151da177e4SLinus Torvalds }
4161da177e4SLinus Torvalds 
4171da177e4SLinus Torvalds static inline int tcf_em_is_inverted(struct tcf_ematch *em)
4181da177e4SLinus Torvalds {
4191da177e4SLinus Torvalds 	return em->flags & TCF_EM_INVERT;
4201da177e4SLinus Torvalds }
4211da177e4SLinus Torvalds 
4221da177e4SLinus Torvalds static inline int tcf_em_last_match(struct tcf_ematch *em)
4231da177e4SLinus Torvalds {
4241da177e4SLinus Torvalds 	return (em->flags & TCF_EM_REL_MASK) == TCF_EM_REL_END;
4251da177e4SLinus Torvalds }
4261da177e4SLinus Torvalds 
4271da177e4SLinus Torvalds static inline int tcf_em_early_end(struct tcf_ematch *em, int result)
4281da177e4SLinus Torvalds {
4291da177e4SLinus Torvalds 	if (tcf_em_last_match(em))
4301da177e4SLinus Torvalds 		return 1;
4311da177e4SLinus Torvalds 
4321da177e4SLinus Torvalds 	if (result == 0 && em->flags & TCF_EM_REL_AND)
4331da177e4SLinus Torvalds 		return 1;
4341da177e4SLinus Torvalds 
4351da177e4SLinus Torvalds 	if (result != 0 && em->flags & TCF_EM_REL_OR)
4361da177e4SLinus Torvalds 		return 1;
4371da177e4SLinus Torvalds 
4381da177e4SLinus Torvalds 	return 0;
4391da177e4SLinus Torvalds }
4401da177e4SLinus Torvalds 
4411da177e4SLinus Torvalds /**
4421da177e4SLinus Torvalds  * struct tcf_ematch_tree - ematch tree handle
4431da177e4SLinus Torvalds  *
4441da177e4SLinus Torvalds  * @hdr: ematch tree header supplied by userspace
4451da177e4SLinus Torvalds  * @matches: array of ematches
4461da177e4SLinus Torvalds  */
447fd2c3ef7SEric Dumazet struct tcf_ematch_tree {
4481da177e4SLinus Torvalds 	struct tcf_ematch_tree_hdr hdr;
4491da177e4SLinus Torvalds 	struct tcf_ematch *	matches;
4501da177e4SLinus Torvalds 
4511da177e4SLinus Torvalds };
4521da177e4SLinus Torvalds 
4531da177e4SLinus Torvalds /**
4541da177e4SLinus Torvalds  * struct tcf_ematch_ops - ematch module operations
4551da177e4SLinus Torvalds  *
4561da177e4SLinus Torvalds  * @kind: identifier (kind) of this ematch module
4571da177e4SLinus Torvalds  * @datalen: length of expected configuration data (optional)
4581da177e4SLinus Torvalds  * @change: called during validation (optional)
4591da177e4SLinus Torvalds  * @match: called during ematch tree evaluation, must return 1/0
4601da177e4SLinus Torvalds  * @destroy: called during destroyage (optional)
4611da177e4SLinus Torvalds  * @dump: called during dumping process (optional)
4621da177e4SLinus Torvalds  * @owner: owner, must be set to THIS_MODULE
4631da177e4SLinus Torvalds  * @link: link to previous/next ematch module (internal use)
4641da177e4SLinus Torvalds  */
465fd2c3ef7SEric Dumazet struct tcf_ematch_ops {
4661da177e4SLinus Torvalds 	int			kind;
4671da177e4SLinus Torvalds 	int			datalen;
46882a470f1SJohn Fastabend 	int			(*change)(struct net *net, void *,
4691da177e4SLinus Torvalds 					  int, struct tcf_ematch *);
4701da177e4SLinus Torvalds 	int			(*match)(struct sk_buff *, struct tcf_ematch *,
4711da177e4SLinus Torvalds 					 struct tcf_pkt_info *);
47282a470f1SJohn Fastabend 	void			(*destroy)(struct tcf_ematch *);
4731da177e4SLinus Torvalds 	int			(*dump)(struct sk_buff *, struct tcf_ematch *);
4741da177e4SLinus Torvalds 	struct module		*owner;
4751da177e4SLinus Torvalds 	struct list_head	link;
4761da177e4SLinus Torvalds };
4771da177e4SLinus Torvalds 
4785c15257fSJoe Perches int tcf_em_register(struct tcf_ematch_ops *);
4795c15257fSJoe Perches void tcf_em_unregister(struct tcf_ematch_ops *);
4805c15257fSJoe Perches int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *,
4811da177e4SLinus Torvalds 			 struct tcf_ematch_tree *);
48282a470f1SJohn Fastabend void tcf_em_tree_destroy(struct tcf_ematch_tree *);
4835c15257fSJoe Perches int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int);
4845c15257fSJoe Perches int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *,
4851da177e4SLinus Torvalds 			struct tcf_pkt_info *);
4861da177e4SLinus Torvalds 
4871da177e4SLinus Torvalds /**
4881da177e4SLinus Torvalds  * tcf_em_tree_match - evaulate an ematch tree
4891da177e4SLinus Torvalds  *
4901da177e4SLinus Torvalds  * @skb: socket buffer of the packet in question
4911da177e4SLinus Torvalds  * @tree: ematch tree to be used for evaluation
4921da177e4SLinus Torvalds  * @info: packet information examined by classifier
4931da177e4SLinus Torvalds  *
4941da177e4SLinus Torvalds  * This function matches @skb against the ematch tree in @tree by going
4951da177e4SLinus Torvalds  * through all ematches respecting their logic relations returning
4961da177e4SLinus Torvalds  * as soon as the result is obvious.
4971da177e4SLinus Torvalds  *
4981da177e4SLinus Torvalds  * Returns 1 if the ematch tree as-one matches, no ematches are configured
4991da177e4SLinus Torvalds  * or ematch is not enabled in the kernel, otherwise 0 is returned.
5001da177e4SLinus Torvalds  */
5011da177e4SLinus Torvalds static inline int tcf_em_tree_match(struct sk_buff *skb,
5021da177e4SLinus Torvalds 				    struct tcf_ematch_tree *tree,
5031da177e4SLinus Torvalds 				    struct tcf_pkt_info *info)
5041da177e4SLinus Torvalds {
5051da177e4SLinus Torvalds 	if (tree->hdr.nmatches)
5061da177e4SLinus Torvalds 		return __tcf_em_tree_match(skb, tree, info);
5071da177e4SLinus Torvalds 	else
5081da177e4SLinus Torvalds 		return 1;
5091da177e4SLinus Torvalds }
5101da177e4SLinus Torvalds 
511db3d99c0SPatrick McHardy #define MODULE_ALIAS_TCF_EMATCH(kind)	MODULE_ALIAS("ematch-kind-" __stringify(kind))
512db3d99c0SPatrick McHardy 
5131da177e4SLinus Torvalds #else /* CONFIG_NET_EMATCH */
5141da177e4SLinus Torvalds 
515fd2c3ef7SEric Dumazet struct tcf_ematch_tree {
5161da177e4SLinus Torvalds };
5171da177e4SLinus Torvalds 
5181da177e4SLinus Torvalds #define tcf_em_tree_validate(tp, tb, t) ((void)(t), 0)
51982a470f1SJohn Fastabend #define tcf_em_tree_destroy(t) do { (void)(t); } while(0)
5201da177e4SLinus Torvalds #define tcf_em_tree_dump(skb, t, tlv) (0)
5211da177e4SLinus Torvalds #define tcf_em_tree_match(skb, t, info) ((void)(info), 1)
5221da177e4SLinus Torvalds 
5231da177e4SLinus Torvalds #endif /* CONFIG_NET_EMATCH */
5241da177e4SLinus Torvalds 
5251da177e4SLinus Torvalds static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer)
5261da177e4SLinus Torvalds {
5271da177e4SLinus Torvalds 	switch (layer) {
5281da177e4SLinus Torvalds 		case TCF_LAYER_LINK:
5291da177e4SLinus Torvalds 			return skb->data;
5301da177e4SLinus Torvalds 		case TCF_LAYER_NETWORK:
531d56f90a7SArnaldo Carvalho de Melo 			return skb_network_header(skb);
5321da177e4SLinus Torvalds 		case TCF_LAYER_TRANSPORT:
5339c70220bSArnaldo Carvalho de Melo 			return skb_transport_header(skb);
5341da177e4SLinus Torvalds 	}
5351da177e4SLinus Torvalds 
5361da177e4SLinus Torvalds 	return NULL;
5371da177e4SLinus Torvalds }
5381da177e4SLinus Torvalds 
539eddc9ec5SArnaldo Carvalho de Melo static inline int tcf_valid_offset(const struct sk_buff *skb,
540eddc9ec5SArnaldo Carvalho de Melo 				   const unsigned char *ptr, const int len)
5411da177e4SLinus Torvalds {
542da521b2cSDavid S. Miller 	return likely((ptr + len) <= skb_tail_pointer(skb) &&
543da521b2cSDavid S. Miller 		      ptr >= skb->head &&
544da521b2cSDavid S. Miller 		      (ptr <= (ptr + len)));
5451da177e4SLinus Torvalds }
5461da177e4SLinus Torvalds 
5471da177e4SLinus Torvalds #ifdef CONFIG_NET_CLS_IND
5480eeb8ffcSDenis V. Lunev #include <net/net_namespace.h>
5490eeb8ffcSDenis V. Lunev 
5501da177e4SLinus Torvalds static inline int
5512519a602SWANG Cong tcf_change_indev(struct net *net, struct nlattr *indev_tlv)
5521da177e4SLinus Torvalds {
5532519a602SWANG Cong 	char indev[IFNAMSIZ];
554c01003c2SPatrick McHardy 	struct net_device *dev;
555c01003c2SPatrick McHardy 
5562519a602SWANG Cong 	if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ)
5572519a602SWANG Cong 		return -EINVAL;
5582519a602SWANG Cong 	dev = __dev_get_by_name(net, indev);
5592519a602SWANG Cong 	if (!dev)
5602519a602SWANG Cong 		return -ENODEV;
5612519a602SWANG Cong 	return dev->ifindex;
5621da177e4SLinus Torvalds }
5631da177e4SLinus Torvalds 
5642519a602SWANG Cong static inline bool
5652519a602SWANG Cong tcf_match_indev(struct sk_buff *skb, int ifindex)
5662519a602SWANG Cong {
5672519a602SWANG Cong 	if (!ifindex)
5682519a602SWANG Cong 		return true;
5692519a602SWANG Cong 	if  (!skb->skb_iif)
5702519a602SWANG Cong 		return false;
5712519a602SWANG Cong 	return ifindex == skb->skb_iif;
5721da177e4SLinus Torvalds }
5731da177e4SLinus Torvalds #endif /* CONFIG_NET_CLS_IND */
5741da177e4SLinus Torvalds 
575208c0f4bSJiri Pirko int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts,
576208c0f4bSJiri Pirko 		     enum tc_setup_type type, void *type_data, bool err_stop);
577717503b9SJiri Pirko 
5788c4083b3SJiri Pirko enum tc_block_command {
5798c4083b3SJiri Pirko 	TC_BLOCK_BIND,
5808c4083b3SJiri Pirko 	TC_BLOCK_UNBIND,
5818c4083b3SJiri Pirko };
5828c4083b3SJiri Pirko 
5838c4083b3SJiri Pirko struct tc_block_offload {
5848c4083b3SJiri Pirko 	enum tc_block_command command;
5858c4083b3SJiri Pirko 	enum tcf_block_binder_type binder_type;
5868c4083b3SJiri Pirko 	struct tcf_block *block;
5878c4083b3SJiri Pirko };
5888c4083b3SJiri Pirko 
5895fd9fc4eSJiri Pirko struct tc_cls_common_offload {
5905fd9fc4eSJiri Pirko 	u32 chain_index;
5915fd9fc4eSJiri Pirko 	__be16 protocol;
592d7c1c8d2SJiri Pirko 	u32 prio;
5935fd9fc4eSJiri Pirko };
5945fd9fc4eSJiri Pirko 
5955fd9fc4eSJiri Pirko static inline void
5965fd9fc4eSJiri Pirko tc_cls_common_offload_init(struct tc_cls_common_offload *cls_common,
5975fd9fc4eSJiri Pirko 			   const struct tcf_proto *tp)
5985fd9fc4eSJiri Pirko {
5995fd9fc4eSJiri Pirko 	cls_common->chain_index = tp->chain->index;
6005fd9fc4eSJiri Pirko 	cls_common->protocol = tp->protocol;
601d7c1c8d2SJiri Pirko 	cls_common->prio = tp->prio;
6025fd9fc4eSJiri Pirko }
6035fd9fc4eSJiri Pirko 
604a1b7c5fdSJohn Fastabend struct tc_cls_u32_knode {
605a1b7c5fdSJohn Fastabend 	struct tcf_exts *exts;
606e014860eSJohn Fastabend 	struct tc_u32_sel *sel;
607a1b7c5fdSJohn Fastabend 	u32 handle;
608a1b7c5fdSJohn Fastabend 	u32 val;
609a1b7c5fdSJohn Fastabend 	u32 mask;
610a1b7c5fdSJohn Fastabend 	u32 link_handle;
611e014860eSJohn Fastabend 	u8 fshift;
612a1b7c5fdSJohn Fastabend };
613a1b7c5fdSJohn Fastabend 
614a1b7c5fdSJohn Fastabend struct tc_cls_u32_hnode {
615a1b7c5fdSJohn Fastabend 	u32 handle;
616a1b7c5fdSJohn Fastabend 	u32 prio;
617a1b7c5fdSJohn Fastabend 	unsigned int divisor;
618a1b7c5fdSJohn Fastabend };
619a1b7c5fdSJohn Fastabend 
620a1b7c5fdSJohn Fastabend enum tc_clsu32_command {
621a1b7c5fdSJohn Fastabend 	TC_CLSU32_NEW_KNODE,
622a1b7c5fdSJohn Fastabend 	TC_CLSU32_REPLACE_KNODE,
623a1b7c5fdSJohn Fastabend 	TC_CLSU32_DELETE_KNODE,
624a1b7c5fdSJohn Fastabend 	TC_CLSU32_NEW_HNODE,
625a1b7c5fdSJohn Fastabend 	TC_CLSU32_REPLACE_HNODE,
626a1b7c5fdSJohn Fastabend 	TC_CLSU32_DELETE_HNODE,
627a1b7c5fdSJohn Fastabend };
628a1b7c5fdSJohn Fastabend 
629a1b7c5fdSJohn Fastabend struct tc_cls_u32_offload {
6305fd9fc4eSJiri Pirko 	struct tc_cls_common_offload common;
631a1b7c5fdSJohn Fastabend 	/* knode values */
632a1b7c5fdSJohn Fastabend 	enum tc_clsu32_command command;
633a1b7c5fdSJohn Fastabend 	union {
634a1b7c5fdSJohn Fastabend 		struct tc_cls_u32_knode knode;
635a1b7c5fdSJohn Fastabend 		struct tc_cls_u32_hnode hnode;
636a1b7c5fdSJohn Fastabend 	};
637a1b7c5fdSJohn Fastabend };
638a1b7c5fdSJohn Fastabend 
6397b06e8aeSJiri Pirko static inline bool tc_can_offload(const struct net_device *dev)
6406843e7a2SJohn Fastabend {
64170b5aee4SJiri Pirko 	return dev->features & NETIF_F_HW_TC;
6426843e7a2SJohn Fastabend }
6436843e7a2SJohn Fastabend 
64455330f05SHadar Hen Zion static inline bool tc_skip_hw(u32 flags)
64555330f05SHadar Hen Zion {
64655330f05SHadar Hen Zion 	return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false;
64755330f05SHadar Hen Zion }
64855330f05SHadar Hen Zion 
649d34e3e18SSamudrala, Sridhar static inline bool tc_skip_sw(u32 flags)
650d34e3e18SSamudrala, Sridhar {
651d34e3e18SSamudrala, Sridhar 	return (flags & TCA_CLS_FLAGS_SKIP_SW) ? true : false;
652d34e3e18SSamudrala, Sridhar }
653d34e3e18SSamudrala, Sridhar 
654d34e3e18SSamudrala, Sridhar /* SKIP_HW and SKIP_SW are mutually exclusive flags. */
655d34e3e18SSamudrala, Sridhar static inline bool tc_flags_valid(u32 flags)
656d34e3e18SSamudrala, Sridhar {
657d34e3e18SSamudrala, Sridhar 	if (flags & ~(TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW))
658d34e3e18SSamudrala, Sridhar 		return false;
659d34e3e18SSamudrala, Sridhar 
660d34e3e18SSamudrala, Sridhar 	if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW)))
661d34e3e18SSamudrala, Sridhar 		return false;
662d34e3e18SSamudrala, Sridhar 
663d34e3e18SSamudrala, Sridhar 	return true;
664d34e3e18SSamudrala, Sridhar }
665d34e3e18SSamudrala, Sridhar 
666e696028aSOr Gerlitz static inline bool tc_in_hw(u32 flags)
667e696028aSOr Gerlitz {
668e696028aSOr Gerlitz 	return (flags & TCA_CLS_FLAGS_IN_HW) ? true : false;
669e696028aSOr Gerlitz }
670e696028aSOr Gerlitz 
6715b33f488SAmir Vadai enum tc_fl_command {
6725b33f488SAmir Vadai 	TC_CLSFLOWER_REPLACE,
6735b33f488SAmir Vadai 	TC_CLSFLOWER_DESTROY,
67410cbc684SAmir Vadai 	TC_CLSFLOWER_STATS,
6755b33f488SAmir Vadai };
6765b33f488SAmir Vadai 
6775b33f488SAmir Vadai struct tc_cls_flower_offload {
6785fd9fc4eSJiri Pirko 	struct tc_cls_common_offload common;
6795b33f488SAmir Vadai 	enum tc_fl_command command;
6808208d21bSAmir Vadai 	unsigned long cookie;
6815b33f488SAmir Vadai 	struct flow_dissector *dissector;
6825b33f488SAmir Vadai 	struct fl_flow_key *mask;
6835b33f488SAmir Vadai 	struct fl_flow_key *key;
6845b33f488SAmir Vadai 	struct tcf_exts *exts;
685384c181eSAmritha Nambiar 	u32 classid;
6865b33f488SAmir Vadai };
6875b33f488SAmir Vadai 
688b87f7936SYotam Gigi enum tc_matchall_command {
689b87f7936SYotam Gigi 	TC_CLSMATCHALL_REPLACE,
690b87f7936SYotam Gigi 	TC_CLSMATCHALL_DESTROY,
691b87f7936SYotam Gigi };
692b87f7936SYotam Gigi 
693b87f7936SYotam Gigi struct tc_cls_matchall_offload {
6945fd9fc4eSJiri Pirko 	struct tc_cls_common_offload common;
695b87f7936SYotam Gigi 	enum tc_matchall_command command;
696b87f7936SYotam Gigi 	struct tcf_exts *exts;
697b87f7936SYotam Gigi 	unsigned long cookie;
698b87f7936SYotam Gigi };
699b87f7936SYotam Gigi 
700332ae8e2SJakub Kicinski enum tc_clsbpf_command {
701102740bdSJakub Kicinski 	TC_CLSBPF_OFFLOAD,
70268d64063SJakub Kicinski 	TC_CLSBPF_STATS,
703332ae8e2SJakub Kicinski };
704332ae8e2SJakub Kicinski 
705332ae8e2SJakub Kicinski struct tc_cls_bpf_offload {
7065fd9fc4eSJiri Pirko 	struct tc_cls_common_offload common;
707332ae8e2SJakub Kicinski 	enum tc_clsbpf_command command;
708332ae8e2SJakub Kicinski 	struct tcf_exts *exts;
709332ae8e2SJakub Kicinski 	struct bpf_prog *prog;
710102740bdSJakub Kicinski 	struct bpf_prog *oldprog;
711332ae8e2SJakub Kicinski 	const char *name;
712332ae8e2SJakub Kicinski 	bool exts_integrated;
7130d01d45fSJakub Kicinski 	u32 gen_flags;
714332ae8e2SJakub Kicinski };
715332ae8e2SJakub Kicinski 
7164e8b86c0SAmritha Nambiar struct tc_mqprio_qopt_offload {
7174e8b86c0SAmritha Nambiar 	/* struct tc_mqprio_qopt must always be the first element */
7184e8b86c0SAmritha Nambiar 	struct tc_mqprio_qopt qopt;
7194e8b86c0SAmritha Nambiar 	u16 mode;
7204e8b86c0SAmritha Nambiar 	u16 shaper;
7214e8b86c0SAmritha Nambiar 	u32 flags;
7224e8b86c0SAmritha Nambiar 	u64 min_rate[TC_QOPT_MAX_QUEUE];
7234e8b86c0SAmritha Nambiar 	u64 max_rate[TC_QOPT_MAX_QUEUE];
7244e8b86c0SAmritha Nambiar };
7251045ba77SJamal Hadi Salim 
7261045ba77SJamal Hadi Salim /* This structure holds cookie structure that is passed from user
7271045ba77SJamal Hadi Salim  * to the kernel for actions and classifiers
7281045ba77SJamal Hadi Salim  */
7291045ba77SJamal Hadi Salim struct tc_cookie {
7301045ba77SJamal Hadi Salim 	u8  *data;
7311045ba77SJamal Hadi Salim 	u32 len;
7321045ba77SJamal Hadi Salim };
733602f3bafSNogah Frankel 
734602f3bafSNogah Frankel enum tc_red_command {
735602f3bafSNogah Frankel 	TC_RED_REPLACE,
736602f3bafSNogah Frankel 	TC_RED_DESTROY,
737602f3bafSNogah Frankel 	TC_RED_STATS,
738602f3bafSNogah Frankel 	TC_RED_XSTATS,
739602f3bafSNogah Frankel };
740602f3bafSNogah Frankel 
741602f3bafSNogah Frankel struct tc_red_qopt_offload_params {
742602f3bafSNogah Frankel 	u32 min;
743602f3bafSNogah Frankel 	u32 max;
744602f3bafSNogah Frankel 	u32 probability;
745602f3bafSNogah Frankel 	bool is_ecn;
746602f3bafSNogah Frankel };
747602f3bafSNogah Frankel struct tc_red_qopt_offload_stats {
748602f3bafSNogah Frankel 	struct gnet_stats_basic_packed *bstats;
749602f3bafSNogah Frankel 	struct gnet_stats_queue *qstats;
750602f3bafSNogah Frankel };
751602f3bafSNogah Frankel 
752602f3bafSNogah Frankel struct tc_red_qopt_offload {
753602f3bafSNogah Frankel 	enum tc_red_command command;
754602f3bafSNogah Frankel 	u32 handle;
755602f3bafSNogah Frankel 	u32 parent;
756602f3bafSNogah Frankel 	union {
757602f3bafSNogah Frankel 		struct tc_red_qopt_offload_params set;
758602f3bafSNogah Frankel 		struct tc_red_qopt_offload_stats stats;
759602f3bafSNogah Frankel 		struct red_stats *xstats;
760602f3bafSNogah Frankel 	};
761602f3bafSNogah Frankel };
762602f3bafSNogah Frankel 
7631da177e4SLinus Torvalds #endif
764