Blame view
include/net/pkt_cls.h
23 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 |
#ifndef __NET_PKT_CLS_H #define __NET_PKT_CLS_H #include <linux/pkt_cls.h> |
7aa0045da net_sched: introd... |
6 |
#include <linux/workqueue.h> |
1da177e4c Linux-2.6.12-rc2 |
7 8 |
#include <net/sch_generic.h> #include <net/act_api.h> |
a51486266 net: sched: remov... |
9 |
#include <net/net_namespace.h> |
1da177e4c Linux-2.6.12-rc2 |
10 |
|
cd11b1640 net/tc: introduce... |
11 |
/* TC action not accessible from user space */ |
720f22fed net: sched: refac... |
12 |
#define TC_ACT_CONSUMED (TC_ACT_VALUE_MAX + 1) |
cd11b1640 net/tc: introduce... |
13 |
|
1da177e4c Linux-2.6.12-rc2 |
14 |
/* Basic packet classifier frontend definitions. */ |
fd2c3ef76 net: cleanup incl... |
15 |
struct tcf_walker { |
1da177e4c Linux-2.6.12-rc2 |
16 17 18 |
int stop; int skip; int count; |
6676d5e41 net: sched: set d... |
19 |
bool nonempty; |
01683a146 net: sched: refac... |
20 |
unsigned long cookie; |
8113c0956 net_sched: use vo... |
21 |
int (*fn)(struct tcf_proto *, void *node, struct tcf_walker *); |
1da177e4c Linux-2.6.12-rc2 |
22 |
}; |
5c15257f9 net: Remove exter... |
23 24 |
int register_tcf_proto_ops(struct tcf_proto_ops *ops); int unregister_tcf_proto_ops(struct tcf_proto_ops *ops); |
1da177e4c Linux-2.6.12-rc2 |
25 |
|
8c4083b30 net: sched: add b... |
26 |
struct tcf_block_ext_info { |
32f8c4093 net: flow_offload... |
27 |
enum flow_block_binder_type binder_type; |
c7eb7d723 net: sched: intro... |
28 29 |
tcf_chain_head_change_t *chain_head_change; void *chain_head_change_priv; |
486173877 net: sched: intro... |
30 |
u32 block_index; |
8c4083b30 net: sched: add b... |
31 |
}; |
3625750f0 net: sched: Intro... |
32 33 34 35 36 |
struct tcf_qevent { struct tcf_block *block; struct tcf_block_ext_info info; struct tcf_proto __rcu *filter_chain; }; |
acb674428 net: sched: intro... |
37 |
struct tcf_block_cb; |
aaa908ffb net_sched: switch... |
38 |
bool tcf_queue_work(struct rcu_work *rwork, work_func_t func); |
acb674428 net: sched: intro... |
39 |
|
8ae700325 sched: have stub ... |
40 |
#ifdef CONFIG_NET_CLS |
1f3ed383f net: sched: don't... |
41 42 |
struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, u32 chain_index); |
1f3ed383f net: sched: don't... |
43 |
void tcf_chain_put_by_act(struct tcf_chain *chain); |
bbf73830c net: sched: trave... |
44 45 |
struct tcf_chain *tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain); |
fe2923afc net: sched: trave... |
46 |
struct tcf_proto *tcf_get_next_proto(struct tcf_chain *chain, |
12db03b65 net: sched: exten... |
47 |
struct tcf_proto *tp, bool rtnl_held); |
f36fe1c49 net: sched: intro... |
48 |
void tcf_block_netif_keep_dst(struct tcf_block *block); |
6529eaba3 net: sched: intro... |
49 |
int tcf_block_get(struct tcf_block **p_block, |
8d1a77f97 net: sch: api: ad... |
50 51 |
struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, struct netlink_ext_ack *extack); |
c7eb7d723 net: sched: intro... |
52 |
int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q, |
8d1a77f97 net: sch: api: ad... |
53 54 |
struct tcf_block_ext_info *ei, struct netlink_ext_ack *extack); |
6529eaba3 net: sched: intro... |
55 |
void tcf_block_put(struct tcf_block *block); |
c7eb7d723 net: sched: intro... |
56 |
void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, |
8c4083b30 net: sched: add b... |
57 |
struct tcf_block_ext_info *ei); |
44186460c net: sched: intro... |
58 |
|
486173877 net: sched: intro... |
59 60 61 62 |
static inline bool tcf_block_shared(struct tcf_block *block) { return block->index; } |
c1a970d06 net: sched: Fix N... |
63 64 65 66 |
static inline bool tcf_block_non_null_shared(struct tcf_block *block) { return block && block->index; } |
44186460c net: sched: intro... |
67 68 |
static inline struct Qdisc *tcf_block_q(struct tcf_block *block) { |
486173877 net: sched: intro... |
69 |
WARN_ON(tcf_block_shared(block)); |
44186460c net: sched: intro... |
70 71 |
return block->q; } |
87d83093b net: sched: move ... |
72 73 |
int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode); |
7d17c544c net: sched: Pass ... |
74 75 76 77 |
int tcf_classify_ingress(struct sk_buff *skb, const struct tcf_block *ingress_block, const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode); |
87d83093b net: sched: move ... |
78 |
|
8ae700325 sched: have stub ... |
79 |
#else |
88c44a520 net/sched: add bl... |
80 81 82 83 |
static inline bool tcf_block_shared(struct tcf_block *block) { return false; } |
c1a970d06 net: sched: Fix N... |
84 85 86 87 |
static inline bool tcf_block_non_null_shared(struct tcf_block *block) { return false; } |
6529eaba3 net: sched: intro... |
88 89 |
static inline int tcf_block_get(struct tcf_block **p_block, |
3c1490913 net: sch: api: fi... |
90 91 |
struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q, struct netlink_ext_ack *extack) |
6529eaba3 net: sched: intro... |
92 93 94 |
{ return 0; } |
8c4083b30 net: sched: add b... |
95 |
static inline |
c7eb7d723 net: sched: intro... |
96 |
int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q, |
33c30a8b6 net: sched: fix t... |
97 98 |
struct tcf_block_ext_info *ei, struct netlink_ext_ack *extack) |
8c4083b30 net: sched: add b... |
99 100 101 |
{ return 0; } |
6529eaba3 net: sched: intro... |
102 |
static inline void tcf_block_put(struct tcf_block *block) |
8ae700325 sched: have stub ... |
103 104 |
{ } |
87d83093b net: sched: move ... |
105 |
|
8c4083b30 net: sched: add b... |
106 |
static inline |
c7eb7d723 net: sched: intro... |
107 |
void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, |
8c4083b30 net: sched: add b... |
108 109 110 |
struct tcf_block_ext_info *ei) { } |
44186460c net: sched: intro... |
111 112 113 114 |
static inline struct Qdisc *tcf_block_q(struct tcf_block *block) { return NULL; } |
acb674428 net: sched: intro... |
115 |
static inline |
a73233115 net: flow_offload... |
116 |
int tc_setup_cb_block_register(struct tcf_block *block, flow_setup_cb_t *cb, |
acb674428 net: sched: intro... |
117 118 119 120 121 122 |
void *cb_priv) { return 0; } static inline |
a73233115 net: flow_offload... |
123 |
void tc_setup_cb_block_unregister(struct tcf_block *block, flow_setup_cb_t *cb, |
acb674428 net: sched: intro... |
124 125 126 |
void *cb_priv) { } |
87d83093b net: sched: move ... |
127 128 129 130 131 |
static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { return TC_ACT_UNSPEC; } |
9410c9409 net: sched: Intro... |
132 133 |
static inline int tcf_classify_ingress(struct sk_buff *skb, |
7d17c544c net: sched: Pass ... |
134 |
const struct tcf_block *ingress_block, |
9410c9409 net: sched: Intro... |
135 136 137 138 139 |
const struct tcf_proto *tp, struct tcf_result *res, bool compat_mode) { return TC_ACT_UNSPEC; } |
8ae700325 sched: have stub ... |
140 |
#endif |
cf1facda2 sched: move tcf_p... |
141 |
|
1da177e4c Linux-2.6.12-rc2 |
142 143 144 |
static inline unsigned long __cls_set_class(unsigned long *clp, unsigned long cl) { |
a0efb80ce net_sched: avoid ... |
145 |
return xchg(clp, cl); |
1da177e4c Linux-2.6.12-rc2 |
146 |
} |
2e24cd755 net_sched: fix op... |
147 148 |
static inline void __tcf_bind_filter(struct Qdisc *q, struct tcf_result *r, unsigned long base) |
1da177e4c Linux-2.6.12-rc2 |
149 |
{ |
2e24cd755 net_sched: fix op... |
150 |
unsigned long cl; |
34e3759cf net: sched: teach... |
151 |
|
2e24cd755 net_sched: fix op... |
152 153 154 155 |
cl = q->ops->cl_ops->bind_tcf(q, base, r->classid); cl = __cls_set_class(&r->class, cl); if (cl) q->ops->cl_ops->unbind_tcf(q, cl); |
1da177e4c Linux-2.6.12-rc2 |
156 157 158 159 160 |
} static inline void tcf_bind_filter(struct tcf_proto *tp, struct tcf_result *r, unsigned long base) { |
34e3759cf net: sched: teach... |
161 |
struct Qdisc *q = tp->chain->block->q; |
1da177e4c Linux-2.6.12-rc2 |
162 |
|
34e3759cf net: sched: teach... |
163 164 165 166 167 |
/* Check q as it is not set for shared blocks. In that case, * setting class is not supported. */ if (!q) return; |
2e24cd755 net_sched: fix op... |
168 169 170 171 172 173 174 175 176 177 178 |
sch_tree_lock(q); __tcf_bind_filter(q, r, base); sch_tree_unlock(q); } static inline void __tcf_unbind_filter(struct Qdisc *q, struct tcf_result *r) { unsigned long cl; if ((cl = __cls_set_class(&r->class, 0)) != 0) |
34e3759cf net: sched: teach... |
179 |
q->ops->cl_ops->unbind_tcf(q, cl); |
1da177e4c Linux-2.6.12-rc2 |
180 181 182 183 184 |
} static inline void tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r) { |
34e3759cf net: sched: teach... |
185 |
struct Qdisc *q = tp->chain->block->q; |
1da177e4c Linux-2.6.12-rc2 |
186 |
|
34e3759cf net: sched: teach... |
187 188 |
if (!q) return; |
2e24cd755 net_sched: fix op... |
189 |
__tcf_unbind_filter(q, r); |
1da177e4c Linux-2.6.12-rc2 |
190 |
} |
fd2c3ef76 net: cleanup incl... |
191 |
struct tcf_exts { |
1da177e4c Linux-2.6.12-rc2 |
192 |
#ifdef CONFIG_NET_CLS_ACT |
33be62715 net_sched: act: u... |
193 |
__u32 type; /* for backward compat(TCA_OLD_COMPAT) */ |
22dc13c83 net_sched: conver... |
194 195 |
int nr_actions; struct tc_action **actions; |
e4b95c41d net_sched: introd... |
196 |
struct net *net; |
1da177e4c Linux-2.6.12-rc2 |
197 |
#endif |
5da57f422 net_sched: cls: r... |
198 199 200 |
/* Map to export classifier specific extension TLV types to the * generic extensions API. Unsupported extensions must be set to 0. */ |
1da177e4c Linux-2.6.12-rc2 |
201 202 203 |
int action; int police; }; |
14215108a net_sched: initia... |
204 205 |
static inline int tcf_exts_init(struct tcf_exts *exts, struct net *net, int action, int police) |
33be62715 net_sched: act: u... |
206 207 |
{ #ifdef CONFIG_NET_CLS_ACT |
5da57f422 net_sched: cls: r... |
208 |
exts->type = 0; |
22dc13c83 net_sched: conver... |
209 |
exts->nr_actions = 0; |
14215108a net_sched: initia... |
210 |
exts->net = net; |
22dc13c83 net_sched: conver... |
211 212 |
exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *), GFP_KERNEL); |
b9a24bb76 net_sched: proper... |
213 214 |
if (!exts->actions) return -ENOMEM; |
33be62715 net_sched: act: u... |
215 |
#endif |
5da57f422 net_sched: cls: r... |
216 217 |
exts->action = action; exts->police = police; |
b9a24bb76 net_sched: proper... |
218 |
return 0; |
33be62715 net_sched: act: u... |
219 |
} |
e4b95c41d net_sched: introd... |
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
/* Return false if the netns is being destroyed in cleanup_net(). Callers * need to do cleanup synchronously in this case, otherwise may race with * tc_action_net_exit(). Return true for other cases. */ static inline bool tcf_exts_get_net(struct tcf_exts *exts) { #ifdef CONFIG_NET_CLS_ACT exts->net = maybe_get_net(exts->net); return exts->net != NULL; #else return true; #endif } static inline void tcf_exts_put_net(struct tcf_exts *exts) { #ifdef CONFIG_NET_CLS_ACT if (exts->net) put_net(exts->net); #endif } |
22dc13c83 net_sched: conver... |
241 |
#ifdef CONFIG_NET_CLS_ACT |
244cd96ad net_sched: remove... |
242 243 244 245 |
#define tcf_exts_for_each_action(i, a, exts) \ for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = (exts)->actions[i]); i++) #else #define tcf_exts_for_each_action(i, a, exts) \ |
191672ca0 net_sched: fix un... |
246 |
for (; 0; (void)(i), (void)(a), (void)(exts)) |
22dc13c83 net_sched: conver... |
247 |
#endif |
22dc13c83 net_sched: conver... |
248 |
|
d897a638e sched: add helper... |
249 250 |
static inline void tcf_exts_stats_update(const struct tcf_exts *exts, |
4b61d3e8d net: qos offload ... |
251 |
u64 bytes, u64 packets, u64 drops, u64 lastuse, |
93a129eb8 net: sched: expos... |
252 |
u8 used_hw_stats, bool used_hw_stats_valid) |
d897a638e sched: add helper... |
253 254 255 256 257 258 259 260 |
{ #ifdef CONFIG_NET_CLS_ACT int i; preempt_disable(); for (i = 0; i < exts->nr_actions; i++) { struct tc_action *a = exts->actions[i]; |
4b61d3e8d net: qos offload ... |
261 262 |
tcf_action_stats_update(a, bytes, packets, drops, lastuse, true); |
93a129eb8 net: sched: expos... |
263 264 |
a->used_hw_stats = used_hw_stats; a->used_hw_stats_valid = used_hw_stats_valid; |
d897a638e sched: add helper... |
265 266 267 268 269 |
} preempt_enable(); #endif } |
1da177e4c Linux-2.6.12-rc2 |
270 |
/** |
3bcc0cec8 net: sched: chang... |
271 272 273 274 275 276 277 |
* tcf_exts_has_actions - check if at least one action is present * @exts: tc filter extensions handle * * Returns true if at least one action is present. */ static inline bool tcf_exts_has_actions(struct tcf_exts *exts) { |
2734437ef net_sched: move t... |
278 |
#ifdef CONFIG_NET_CLS_ACT |
3bcc0cec8 net: sched: chang... |
279 280 281 282 283 |
return exts->nr_actions; #else return false; #endif } |
2734437ef net_sched: move t... |
284 |
|
3bcc0cec8 net: sched: chang... |
285 |
/** |
af69afc55 net: sched: use t... |
286 287 288 289 290 |
* tcf_exts_exec - execute tc filter extensions * @skb: socket buffer * @exts: tc filter extensions handle * @res: desired result * |
af089e701 net: sched: fix r... |
291 |
* Executes all configured extensions. Returns TC_ACT_OK on a normal execution, |
af69afc55 net: sched: use t... |
292 293 294 295 296 297 298 299 300 |
* a negative number if the filter must be considered unmatched or * a positive action code (TC_ACT_*) which must be returned to the * underlying layer. */ static inline int tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, struct tcf_result *res) { #ifdef CONFIG_NET_CLS_ACT |
ec1a9cca0 net: sched: remov... |
301 |
return tcf_action_exec(skb, exts->actions, exts->nr_actions, res); |
af69afc55 net: sched: use t... |
302 |
#endif |
af089e701 net: sched: fix r... |
303 |
return TC_ACT_OK; |
af69afc55 net: sched: use t... |
304 |
} |
5c15257f9 net: Remove exter... |
305 306 |
int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, struct nlattr *rate_tlv, |
ec6743a10 net: sched: track... |
307 |
struct tcf_exts *exts, bool ovr, bool rtnl_held, |
50a561900 net: sched: cls: ... |
308 |
struct netlink_ext_ack *extack); |
18d0264f6 net_sched: remove... |
309 |
void tcf_exts_destroy(struct tcf_exts *exts); |
9b0d4446b net: sched: avoid... |
310 |
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src); |
5da57f422 net_sched: cls: r... |
311 |
int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts); |
ca44b738e net: sched: imple... |
312 |
int tcf_exts_terse_dump(struct sk_buff *skb, struct tcf_exts *exts); |
5da57f422 net_sched: cls: r... |
313 |
int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts); |
1da177e4c Linux-2.6.12-rc2 |
314 315 316 317 |
/** * struct tcf_pkt_info - packet information */ |
fd2c3ef76 net: cleanup incl... |
318 |
struct tcf_pkt_info { |
1da177e4c Linux-2.6.12-rc2 |
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
unsigned char * ptr; int nexthdr; }; #ifdef CONFIG_NET_EMATCH struct tcf_ematch_ops; /** * struct tcf_ematch - extended match (ematch) * * @matchid: identifier to allow userspace to reidentify a match * @flags: flags specifying attributes and the relation to other matches * @ops: the operations lookup table of the corresponding ematch module * @datalen: length of the ematch specific configuration data * @data: ematch specific data */ |
fd2c3ef76 net: cleanup incl... |
336 |
struct tcf_ematch { |
1da177e4c Linux-2.6.12-rc2 |
337 338 339 340 341 |
struct tcf_ematch_ops * ops; unsigned long data; unsigned int datalen; u16 matchid; u16 flags; |
82a470f11 net: sched: remov... |
342 |
struct net *net; |
1da177e4c Linux-2.6.12-rc2 |
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
}; static inline int tcf_em_is_container(struct tcf_ematch *em) { return !em->ops; } static inline int tcf_em_is_simple(struct tcf_ematch *em) { return em->flags & TCF_EM_SIMPLE; } static inline int tcf_em_is_inverted(struct tcf_ematch *em) { return em->flags & TCF_EM_INVERT; } static inline int tcf_em_last_match(struct tcf_ematch *em) { return (em->flags & TCF_EM_REL_MASK) == TCF_EM_REL_END; } static inline int tcf_em_early_end(struct tcf_ematch *em, int result) { if (tcf_em_last_match(em)) return 1; if (result == 0 && em->flags & TCF_EM_REL_AND) return 1; if (result != 0 && em->flags & TCF_EM_REL_OR) return 1; return 0; } /** * struct tcf_ematch_tree - ematch tree handle * * @hdr: ematch tree header supplied by userspace * @matches: array of ematches */ |
fd2c3ef76 net: cleanup incl... |
385 |
struct tcf_ematch_tree { |
1da177e4c Linux-2.6.12-rc2 |
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
struct tcf_ematch_tree_hdr hdr; struct tcf_ematch * matches; }; /** * struct tcf_ematch_ops - ematch module operations * * @kind: identifier (kind) of this ematch module * @datalen: length of expected configuration data (optional) * @change: called during validation (optional) * @match: called during ematch tree evaluation, must return 1/0 * @destroy: called during destroyage (optional) * @dump: called during dumping process (optional) * @owner: owner, must be set to THIS_MODULE * @link: link to previous/next ematch module (internal use) */ |
fd2c3ef76 net: cleanup incl... |
403 |
struct tcf_ematch_ops { |
1da177e4c Linux-2.6.12-rc2 |
404 405 |
int kind; int datalen; |
82a470f11 net: sched: remov... |
406 |
int (*change)(struct net *net, void *, |
1da177e4c Linux-2.6.12-rc2 |
407 408 409 |
int, struct tcf_ematch *); int (*match)(struct sk_buff *, struct tcf_ematch *, struct tcf_pkt_info *); |
82a470f11 net: sched: remov... |
410 |
void (*destroy)(struct tcf_ematch *); |
1da177e4c Linux-2.6.12-rc2 |
411 412 413 414 |
int (*dump)(struct sk_buff *, struct tcf_ematch *); struct module *owner; struct list_head link; }; |
5c15257f9 net: Remove exter... |
415 416 417 418 |
int tcf_em_register(struct tcf_ematch_ops *); void tcf_em_unregister(struct tcf_ematch_ops *); int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *, struct tcf_ematch_tree *); |
82a470f11 net: sched: remov... |
419 |
void tcf_em_tree_destroy(struct tcf_ematch_tree *); |
5c15257f9 net: Remove exter... |
420 421 422 |
int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *, struct tcf_pkt_info *); |
1da177e4c Linux-2.6.12-rc2 |
423 424 |
/** |
1da177e4c Linux-2.6.12-rc2 |
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
* tcf_em_tree_match - evaulate an ematch tree * * @skb: socket buffer of the packet in question * @tree: ematch tree to be used for evaluation * @info: packet information examined by classifier * * This function matches @skb against the ematch tree in @tree by going * through all ematches respecting their logic relations returning * as soon as the result is obvious. * * Returns 1 if the ematch tree as-one matches, no ematches are configured * or ematch is not enabled in the kernel, otherwise 0 is returned. */ static inline int tcf_em_tree_match(struct sk_buff *skb, struct tcf_ematch_tree *tree, struct tcf_pkt_info *info) { if (tree->hdr.nmatches) return __tcf_em_tree_match(skb, tree, info); else return 1; } |
db3d99c09 [NET_SCHED]: emat... |
447 |
#define MODULE_ALIAS_TCF_EMATCH(kind) MODULE_ALIAS("ematch-kind-" __stringify(kind)) |
1da177e4c Linux-2.6.12-rc2 |
448 |
#else /* CONFIG_NET_EMATCH */ |
fd2c3ef76 net: cleanup incl... |
449 |
struct tcf_ematch_tree { |
1da177e4c Linux-2.6.12-rc2 |
450 451 452 |
}; #define tcf_em_tree_validate(tp, tb, t) ((void)(t), 0) |
82a470f11 net: sched: remov... |
453 |
#define tcf_em_tree_destroy(t) do { (void)(t); } while(0) |
1da177e4c Linux-2.6.12-rc2 |
454 |
#define tcf_em_tree_dump(skb, t, tlv) (0) |
1da177e4c Linux-2.6.12-rc2 |
455 456 457 458 459 460 461 462 |
#define tcf_em_tree_match(skb, t, info) ((void)(info), 1) #endif /* CONFIG_NET_EMATCH */ static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer) { switch (layer) { case TCF_LAYER_LINK: |
d3303a65a net: sched: fix T... |
463 |
return skb_mac_header(skb); |
1da177e4c Linux-2.6.12-rc2 |
464 |
case TCF_LAYER_NETWORK: |
d56f90a7c [SK_BUFF]: Introd... |
465 |
return skb_network_header(skb); |
1da177e4c Linux-2.6.12-rc2 |
466 |
case TCF_LAYER_TRANSPORT: |
9c70220b7 [SK_BUFF]: Introd... |
467 |
return skb_transport_header(skb); |
1da177e4c Linux-2.6.12-rc2 |
468 469 470 471 |
} return NULL; } |
eddc9ec53 [SK_BUFF]: Introd... |
472 473 |
static inline int tcf_valid_offset(const struct sk_buff *skb, const unsigned char *ptr, const int len) |
1da177e4c Linux-2.6.12-rc2 |
474 |
{ |
da521b2c4 net: Fix range ch... |
475 476 477 |
return likely((ptr + len) <= skb_tail_pointer(skb) && ptr >= skb->head && (ptr <= (ptr + len))); |
1da177e4c Linux-2.6.12-rc2 |
478 |
} |
1da177e4c Linux-2.6.12-rc2 |
479 |
static inline int |
1057c55f6 net: sched: cls: ... |
480 481 |
tcf_change_indev(struct net *net, struct nlattr *indev_tlv, struct netlink_ext_ack *extack) |
1da177e4c Linux-2.6.12-rc2 |
482 |
{ |
2519a602c net_sched: optimi... |
483 484 |
char indev[IFNAMSIZ]; struct net_device *dev; |
1057c55f6 net: sched: cls: ... |
485 |
if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) { |
e4a58ef3c net: sched: refin... |
486 487 |
NL_SET_ERR_MSG_ATTR(extack, indev_tlv, "Interface name too long"); |
1da177e4c Linux-2.6.12-rc2 |
488 |
return -EINVAL; |
1057c55f6 net: sched: cls: ... |
489 |
} |
2519a602c net_sched: optimi... |
490 |
dev = __dev_get_by_name(net, indev); |
e4a58ef3c net: sched: refin... |
491 492 493 |
if (!dev) { NL_SET_ERR_MSG_ATTR(extack, indev_tlv, "Network device not found"); |
2519a602c net_sched: optimi... |
494 |
return -ENODEV; |
e4a58ef3c net: sched: refin... |
495 |
} |
2519a602c net_sched: optimi... |
496 |
return dev->ifindex; |
1da177e4c Linux-2.6.12-rc2 |
497 |
} |
2519a602c net_sched: optimi... |
498 499 |
static inline bool tcf_match_indev(struct sk_buff *skb, int ifindex) |
1da177e4c Linux-2.6.12-rc2 |
500 |
{ |
2519a602c net_sched: optimi... |
501 502 503 504 505 |
if (!ifindex) return true; if (!skb->skb_iif) return false; return ifindex == skb->skb_iif; |
1da177e4c Linux-2.6.12-rc2 |
506 |
} |
1da177e4c Linux-2.6.12-rc2 |
507 |
|
3a7b68617 cls_api: add tran... |
508 |
int tc_setup_flow_action(struct flow_action *flow_action, |
b15e7a6e8 net: sched: don't... |
509 |
const struct tcf_exts *exts); |
5a6ff4b13 net: sched: take ... |
510 |
void tc_cleanup_flow_action(struct flow_action *flow_action); |
aeb3fecde net_sched: fold t... |
511 |
int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, |
401192113 net: sched: refac... |
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
void *type_data, bool err_stop, bool rtnl_held); int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, enum tc_setup_type type, void *type_data, bool err_stop, u32 *flags, unsigned int *in_hw_count, bool rtnl_held); int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, enum tc_setup_type type, void *type_data, bool err_stop, u32 *old_flags, unsigned int *old_in_hw_count, u32 *new_flags, unsigned int *new_in_hw_count, bool rtnl_held); int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, enum tc_setup_type type, void *type_data, bool err_stop, u32 *flags, unsigned int *in_hw_count, bool rtnl_held); int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, bool add, flow_setup_cb_t *cb, enum tc_setup_type type, void *type_data, void *cb_priv, u32 *flags, unsigned int *in_hw_count); |
e3ab786b4 flow_offload: add... |
528 |
unsigned int tcf_exts_num_actions(struct tcf_exts *exts); |
717503b9c net: sched: conve... |
529 |
|
3625750f0 net: sched: Intro... |
530 531 532 533 534 535 536 537 538 |
#ifdef CONFIG_NET_CLS_ACT int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch, enum flow_block_binder_type binder_type, struct nlattr *block_index_attr, struct netlink_ext_ack *extack); void tcf_qevent_destroy(struct tcf_qevent *qe, struct Qdisc *sch); int tcf_qevent_validate_change(struct tcf_qevent *qe, struct nlattr *block_index_attr, struct netlink_ext_ack *extack); struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struct sk_buff *skb, |
55f656cdb net: sched: Do no... |
539 |
struct sk_buff **to_free, int *ret); |
3625750f0 net: sched: Intro... |
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
int tcf_qevent_dump(struct sk_buff *skb, int attr_name, struct tcf_qevent *qe); #else static inline int tcf_qevent_init(struct tcf_qevent *qe, struct Qdisc *sch, enum flow_block_binder_type binder_type, struct nlattr *block_index_attr, struct netlink_ext_ack *extack) { return 0; } static inline void tcf_qevent_destroy(struct tcf_qevent *qe, struct Qdisc *sch) { } static inline int tcf_qevent_validate_change(struct tcf_qevent *qe, struct nlattr *block_index_attr, struct netlink_ext_ack *extack) { return 0; } static inline struct sk_buff * tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struct sk_buff *skb, |
55f656cdb net: sched: Do no... |
562 |
struct sk_buff **to_free, int *ret) |
3625750f0 net: sched: Intro... |
563 564 565 566 567 568 569 570 571 |
{ return skb; } static inline int tcf_qevent_dump(struct sk_buff *skb, int attr_name, struct tcf_qevent *qe) { return 0; } #endif |
a1b7c5fd7 net: sched: add c... |
572 573 |
struct tc_cls_u32_knode { struct tcf_exts *exts; |
068ceb355 net: sched: cls_u... |
574 |
struct tcf_result *res; |
e014860e3 net: pack tc_cls_... |
575 |
struct tc_u32_sel *sel; |
a1b7c5fd7 net: sched: add c... |
576 577 578 579 |
u32 handle; u32 val; u32 mask; u32 link_handle; |
e014860e3 net: pack tc_cls_... |
580 |
u8 fshift; |
a1b7c5fd7 net: sched: add c... |
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
}; struct tc_cls_u32_hnode { u32 handle; u32 prio; unsigned int divisor; }; enum tc_clsu32_command { TC_CLSU32_NEW_KNODE, TC_CLSU32_REPLACE_KNODE, TC_CLSU32_DELETE_KNODE, TC_CLSU32_NEW_HNODE, TC_CLSU32_REPLACE_HNODE, TC_CLSU32_DELETE_HNODE, }; struct tc_cls_u32_offload { |
f9e30088d net: flow_offload... |
599 |
struct flow_cls_common_offload common; |
a1b7c5fd7 net: sched: add c... |
600 601 602 603 604 605 606 |
/* knode values */ enum tc_clsu32_command command; union { struct tc_cls_u32_knode knode; struct tc_cls_u32_hnode hnode; }; }; |
7b06e8aed net: sched: remov... |
607 |
static inline bool tc_can_offload(const struct net_device *dev) |
6843e7a2a net: sched: conso... |
608 |
{ |
70b5aee46 net: sched: remov... |
609 |
return dev->features & NETIF_F_HW_TC; |
6843e7a2a net: sched: conso... |
610 |
} |
f9eda14f0 net: sched: creat... |
611 612 613 614 615 616 617 618 619 620 |
static inline bool tc_can_offload_extack(const struct net_device *dev, struct netlink_ext_ack *extack) { bool can = tc_can_offload(dev); if (!can) NL_SET_ERR_MSG(extack, "TC offload is disabled on net device"); return can; } |
878db9f0f pkt_cls: add new ... |
621 622 |
static inline bool tc_cls_can_offload_and_chain0(const struct net_device *dev, |
f9e30088d net: flow_offload... |
623 |
struct flow_cls_common_offload *common) |
878db9f0f pkt_cls: add new ... |
624 625 626 627 628 629 630 631 632 633 |
{ if (!tc_can_offload_extack(dev, common->extack)) return false; if (common->chain_index) { NL_SET_ERR_MSG(common->extack, "Driver supports only offload of chain 0"); return false; } return true; } |
55330f059 net/sched: Add se... |
634 635 636 637 |
static inline bool tc_skip_hw(u32 flags) { return (flags & TCA_CLS_FLAGS_SKIP_HW) ? true : false; } |
d34e3e181 net: cls_u32: Add... |
638 639 640 641 642 643 644 645 |
static inline bool tc_skip_sw(u32 flags) { return (flags & TCA_CLS_FLAGS_SKIP_SW) ? true : false; } /* SKIP_HW and SKIP_SW are mutually exclusive flags. */ static inline bool tc_flags_valid(u32 flags) { |
81c7288b1 sched: cls: enabl... |
646 647 |
if (flags & ~(TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW | TCA_CLS_FLAGS_VERBOSE)) |
d34e3e181 net: cls_u32: Add... |
648 |
return false; |
81c7288b1 sched: cls: enabl... |
649 |
flags &= TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW; |
d34e3e181 net: cls_u32: Add... |
650 651 652 653 654 |
if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW))) return false; return true; } |
e696028ac net/sched: Reflec... |
655 656 657 658 |
static inline bool tc_in_hw(u32 flags) { return (flags & TCA_CLS_FLAGS_IN_HW) ? true : false; } |
34832e1c7 net: sched: prepa... |
659 |
static inline void |
f9e30088d net: flow_offload... |
660 |
tc_cls_common_offload_init(struct flow_cls_common_offload *cls_common, |
34832e1c7 net: sched: prepa... |
661 662 663 664 665 |
const struct tcf_proto *tp, u32 flags, struct netlink_ext_ack *extack) { cls_common->chain_index = tp->chain->index; cls_common->protocol = tp->protocol; |
ef01adae0 net: sched: use m... |
666 |
cls_common->prio = tp->prio >> 16; |
81c7288b1 sched: cls: enabl... |
667 |
if (tc_skip_sw(flags) || flags & TCA_CLS_FLAGS_VERBOSE) |
34832e1c7 net: sched: prepa... |
668 669 |
cls_common->extack = extack; } |
b87f7936a net/sched: Add ma... |
670 671 672 |
enum tc_matchall_command { TC_CLSMATCHALL_REPLACE, TC_CLSMATCHALL_DESTROY, |
b7fe4ab8a net/sched: extend... |
673 |
TC_CLSMATCHALL_STATS, |
b87f7936a net/sched: Add ma... |
674 675 676 |
}; struct tc_cls_matchall_offload { |
f9e30088d net: flow_offload... |
677 |
struct flow_cls_common_offload common; |
b87f7936a net/sched: Add ma... |
678 |
enum tc_matchall_command command; |
f00cbf196 net/sched: use th... |
679 |
struct flow_rule *rule; |
b7fe4ab8a net/sched: extend... |
680 |
struct flow_stats stats; |
b87f7936a net/sched: Add ma... |
681 682 |
unsigned long cookie; }; |
332ae8e2f net: cls_bpf: add... |
683 |
enum tc_clsbpf_command { |
102740bd9 cls_bpf: fix offl... |
684 |
TC_CLSBPF_OFFLOAD, |
68d640630 net: cls_bpf: all... |
685 |
TC_CLSBPF_STATS, |
332ae8e2f net: cls_bpf: add... |
686 687 688 |
}; struct tc_cls_bpf_offload { |
f9e30088d net: flow_offload... |
689 |
struct flow_cls_common_offload common; |
332ae8e2f net: cls_bpf: add... |
690 691 692 |
enum tc_clsbpf_command command; struct tcf_exts *exts; struct bpf_prog *prog; |
102740bd9 cls_bpf: fix offl... |
693 |
struct bpf_prog *oldprog; |
332ae8e2f net: cls_bpf: add... |
694 695 696 |
const char *name; bool exts_integrated; }; |
4e8b86c06 mqprio: Introduce... |
697 698 699 700 701 702 703 704 705 |
struct tc_mqprio_qopt_offload { /* struct tc_mqprio_qopt must always be the first element */ struct tc_mqprio_qopt qopt; u16 mode; u16 shaper; u32 flags; u64 min_rate[TC_QOPT_MAX_QUEUE]; u64 max_rate[TC_QOPT_MAX_QUEUE]; }; |
1045ba77a net sched actions... |
706 707 708 709 710 711 712 |
/* This structure holds cookie structure that is passed from user * to the kernel for actions and classifiers */ struct tc_cookie { u8 *data; u32 len; |
eec94fdb0 net: sched: use r... |
713 |
struct rcu_head rcu; |
1045ba77a net sched actions... |
714 |
}; |
602f3baf2 net_sch: red: Add... |
715 |
|
f34b4aac4 net: sch: red: Ch... |
716 717 718 719 |
struct tc_qopt_offload_stats { struct gnet_stats_basic_packed *bstats; struct gnet_stats_queue *qstats; }; |
f971b1323 net: sched: mq: a... |
720 721 722 |
enum tc_mq_command { TC_MQ_CREATE, TC_MQ_DESTROY, |
47c669a40 net: sched: mq: r... |
723 |
TC_MQ_STATS, |
d577a3d27 net: sched: mq: o... |
724 725 726 727 728 729 |
TC_MQ_GRAFT, }; struct tc_mq_opt_offload_graft_params { unsigned long queue; u32 child_handle; |
f971b1323 net: sched: mq: a... |
730 731 732 733 734 |
}; struct tc_mq_qopt_offload { enum tc_mq_command command; u32 handle; |
d577a3d27 net: sched: mq: o... |
735 736 737 738 |
union { struct tc_qopt_offload_stats stats; struct tc_mq_opt_offload_graft_params graft_params; }; |
f971b1323 net: sched: mq: a... |
739 |
}; |
602f3baf2 net_sch: red: Add... |
740 741 742 743 744 |
enum tc_red_command { TC_RED_REPLACE, TC_RED_DESTROY, TC_RED_STATS, TC_RED_XSTATS, |
bf2a752be net: sched: red: ... |
745 |
TC_RED_GRAFT, |
602f3baf2 net_sch: red: Add... |
746 747 748 749 750 751 |
}; struct tc_red_qopt_offload_params { u32 min; u32 max; u32 probability; |
c0b7490b1 net: sched: red: ... |
752 |
u32 limit; |
602f3baf2 net_sch: red: Add... |
753 |
bool is_ecn; |
190852a55 net: sched: red: ... |
754 |
bool is_harddrop; |
0a7fad237 net: sched: RED: ... |
755 |
bool is_nodrop; |
416ef9b15 net: sched: red: ... |
756 |
struct gnet_stats_queue *qstats; |
602f3baf2 net_sch: red: Add... |
757 |
}; |
602f3baf2 net_sch: red: Add... |
758 759 760 761 762 763 764 |
struct tc_red_qopt_offload { enum tc_red_command command; u32 handle; u32 parent; union { struct tc_red_qopt_offload_params set; |
f34b4aac4 net: sch: red: Ch... |
765 |
struct tc_qopt_offload_stats stats; |
602f3baf2 net_sch: red: Add... |
766 |
struct red_stats *xstats; |
bf2a752be net: sched: red: ... |
767 |
u32 child_handle; |
602f3baf2 net_sch: red: Add... |
768 769 |
}; }; |
890d8d23e net: sched: gred:... |
770 771 772 |
enum tc_gred_command { TC_GRED_REPLACE, TC_GRED_DESTROY, |
e49efd528 net: sched: gred:... |
773 |
TC_GRED_STATS, |
890d8d23e net: sched: gred:... |
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
}; struct tc_gred_vq_qopt_offload_params { bool present; u32 limit; u32 prio; u32 min; u32 max; bool is_ecn; bool is_harddrop; u32 probability; /* Only need backlog, see struct tc_prio_qopt_offload_params */ u32 *backlog; }; struct tc_gred_qopt_offload_params { bool grio_on; bool wred_on; unsigned int dp_cnt; unsigned int dp_def; struct gnet_stats_queue *qstats; struct tc_gred_vq_qopt_offload_params tab[MAX_DPs]; }; |
e49efd528 net: sched: gred:... |
797 798 799 800 801 |
struct tc_gred_qopt_offload_stats { struct gnet_stats_basic_packed bstats[MAX_DPs]; struct gnet_stats_queue qstats[MAX_DPs]; struct red_stats *xstats[MAX_DPs]; }; |
890d8d23e net: sched: gred:... |
802 803 804 805 806 807 |
struct tc_gred_qopt_offload { enum tc_gred_command command; u32 handle; u32 parent; union { struct tc_gred_qopt_offload_params set; |
e49efd528 net: sched: gred:... |
808 |
struct tc_gred_qopt_offload_stats stats; |
890d8d23e net: sched: gred:... |
809 810 |
}; }; |
7fdb61b44 net: sch: prio: A... |
811 812 813 814 |
enum tc_prio_command { TC_PRIO_REPLACE, TC_PRIO_DESTROY, TC_PRIO_STATS, |
b9c7a7acc net: sch: prio: A... |
815 |
TC_PRIO_GRAFT, |
7fdb61b44 net: sch: prio: A... |
816 817 818 819 820 |
}; struct tc_prio_qopt_offload_params { int bands; u8 priomap[TC_PRIO_MAX + 1]; |
9586a992f net: pkt_cls: Cla... |
821 822 |
/* At the point of un-offloading the Qdisc, the reported backlog and * qlen need to be reduced by the portion that is in HW. |
7fdb61b44 net: sch: prio: A... |
823 824 825 |
*/ struct gnet_stats_queue *qstats; }; |
b9c7a7acc net: sch: prio: A... |
826 827 828 829 |
struct tc_prio_qopt_offload_graft_params { u8 band; u32 child_handle; }; |
7fdb61b44 net: sch: prio: A... |
830 831 832 833 834 835 836 |
struct tc_prio_qopt_offload { enum tc_prio_command command; u32 handle; u32 parent; union { struct tc_prio_qopt_offload_params replace_params; struct tc_qopt_offload_stats stats; |
b9c7a7acc net: sch: prio: A... |
837 |
struct tc_prio_qopt_offload_graft_params graft_params; |
7fdb61b44 net: sch: prio: A... |
838 839 |
}; }; |
b9c7a7acc net: sch: prio: A... |
840 |
|
98b0e5f68 net: sched: provi... |
841 842 843 844 845 846 847 848 849 |
enum tc_root_command { TC_ROOT_GRAFT, }; struct tc_root_qopt_offload { enum tc_root_command command; u32 handle; bool ingress; }; |
d35eb52bd net: sch_ets: Mak... |
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
enum tc_ets_command { TC_ETS_REPLACE, TC_ETS_DESTROY, TC_ETS_STATS, TC_ETS_GRAFT, }; struct tc_ets_qopt_offload_replace_params { unsigned int bands; u8 priomap[TC_PRIO_MAX + 1]; unsigned int quanta[TCQ_ETS_MAX_BANDS]; /* 0 for strict bands. */ unsigned int weights[TCQ_ETS_MAX_BANDS]; struct gnet_stats_queue *qstats; }; struct tc_ets_qopt_offload_graft_params { u8 band; u32 child_handle; }; struct tc_ets_qopt_offload { enum tc_ets_command command; u32 handle; u32 parent; union { struct tc_ets_qopt_offload_replace_params replace_params; struct tc_qopt_offload_stats stats; struct tc_ets_qopt_offload_graft_params graft_params; }; }; |
ef6aadcc7 net: sched: Make ... |
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 |
enum tc_tbf_command { TC_TBF_REPLACE, TC_TBF_DESTROY, TC_TBF_STATS, }; struct tc_tbf_qopt_offload_replace_params { struct psched_ratecfg rate; u32 max_size; struct gnet_stats_queue *qstats; }; struct tc_tbf_qopt_offload { enum tc_tbf_command command; u32 handle; u32 parent; union { struct tc_tbf_qopt_offload_replace_params replace_params; struct tc_qopt_offload_stats stats; }; }; |
aaca94080 net: sched: Make ... |
901 902 903 904 905 906 907 908 909 910 911 912 913 914 |
enum tc_fifo_command { TC_FIFO_REPLACE, TC_FIFO_DESTROY, TC_FIFO_STATS, }; struct tc_fifo_qopt_offload { enum tc_fifo_command command; u32 handle; u32 parent; union { struct tc_qopt_offload_stats stats; }; }; |
1da177e4c Linux-2.6.12-rc2 |
915 |
#endif |