Merge branches 'pm-devfreq', 'pm-qos', 'pm-tools' and 'pm-docs'
[linux-2.6-block.git] / include / net / flow_offload.h
CommitLineData
8f256622
PNA
1#ifndef _NET_FLOW_OFFLOAD_H
2#define _NET_FLOW_OFFLOAD_H
3
fa85999f 4#include <linux/kernel.h>
a7323311 5#include <linux/list.h>
319a1d19 6#include <linux/netlink.h>
8f256622
PNA
7#include <net/flow_dissector.h>
8
9struct flow_match {
10 struct flow_dissector *dissector;
11 void *mask;
12 void *key;
13};
14
9558a83a
JP
15struct flow_match_meta {
16 struct flow_dissector_key_meta *key, *mask;
17};
18
8f256622
PNA
19struct flow_match_basic {
20 struct flow_dissector_key_basic *key, *mask;
21};
22
23struct flow_match_control {
24 struct flow_dissector_key_control *key, *mask;
25};
26
27struct flow_match_eth_addrs {
28 struct flow_dissector_key_eth_addrs *key, *mask;
29};
30
31struct flow_match_vlan {
32 struct flow_dissector_key_vlan *key, *mask;
33};
34
35struct flow_match_ipv4_addrs {
36 struct flow_dissector_key_ipv4_addrs *key, *mask;
37};
38
39struct flow_match_ipv6_addrs {
40 struct flow_dissector_key_ipv6_addrs *key, *mask;
41};
42
43struct flow_match_ip {
44 struct flow_dissector_key_ip *key, *mask;
45};
46
47struct flow_match_ports {
48 struct flow_dissector_key_ports *key, *mask;
49};
50
51struct flow_match_icmp {
52 struct flow_dissector_key_icmp *key, *mask;
53};
54
55struct flow_match_tcp {
56 struct flow_dissector_key_tcp *key, *mask;
57};
58
59struct flow_match_mpls {
60 struct flow_dissector_key_mpls *key, *mask;
61};
62
63struct flow_match_enc_keyid {
64 struct flow_dissector_key_keyid *key, *mask;
65};
66
67struct flow_match_enc_opts {
68 struct flow_dissector_key_enc_opts *key, *mask;
69};
70
ee1c45e8
PB
71struct flow_match_ct {
72 struct flow_dissector_key_ct *key, *mask;
73};
74
8f256622
PNA
75struct flow_rule;
76
9558a83a
JP
77void flow_rule_match_meta(const struct flow_rule *rule,
78 struct flow_match_meta *out);
8f256622
PNA
79void flow_rule_match_basic(const struct flow_rule *rule,
80 struct flow_match_basic *out);
81void flow_rule_match_control(const struct flow_rule *rule,
82 struct flow_match_control *out);
83void flow_rule_match_eth_addrs(const struct flow_rule *rule,
84 struct flow_match_eth_addrs *out);
85void flow_rule_match_vlan(const struct flow_rule *rule,
86 struct flow_match_vlan *out);
bae9ed69
EC
87void flow_rule_match_cvlan(const struct flow_rule *rule,
88 struct flow_match_vlan *out);
8f256622
PNA
89void flow_rule_match_ipv4_addrs(const struct flow_rule *rule,
90 struct flow_match_ipv4_addrs *out);
91void flow_rule_match_ipv6_addrs(const struct flow_rule *rule,
92 struct flow_match_ipv6_addrs *out);
93void flow_rule_match_ip(const struct flow_rule *rule,
94 struct flow_match_ip *out);
95void flow_rule_match_ports(const struct flow_rule *rule,
96 struct flow_match_ports *out);
97void flow_rule_match_tcp(const struct flow_rule *rule,
98 struct flow_match_tcp *out);
99void flow_rule_match_icmp(const struct flow_rule *rule,
100 struct flow_match_icmp *out);
101void flow_rule_match_mpls(const struct flow_rule *rule,
102 struct flow_match_mpls *out);
103void flow_rule_match_enc_control(const struct flow_rule *rule,
104 struct flow_match_control *out);
105void flow_rule_match_enc_ipv4_addrs(const struct flow_rule *rule,
106 struct flow_match_ipv4_addrs *out);
107void flow_rule_match_enc_ipv6_addrs(const struct flow_rule *rule,
108 struct flow_match_ipv6_addrs *out);
109void flow_rule_match_enc_ip(const struct flow_rule *rule,
110 struct flow_match_ip *out);
111void flow_rule_match_enc_ports(const struct flow_rule *rule,
112 struct flow_match_ports *out);
113void flow_rule_match_enc_keyid(const struct flow_rule *rule,
114 struct flow_match_enc_keyid *out);
115void flow_rule_match_enc_opts(const struct flow_rule *rule,
116 struct flow_match_enc_opts *out);
ee1c45e8
PB
117void flow_rule_match_ct(const struct flow_rule *rule,
118 struct flow_match_ct *out);
8f256622 119
e3ab786b
PNA
120enum flow_action_id {
121 FLOW_ACTION_ACCEPT = 0,
122 FLOW_ACTION_DROP,
123 FLOW_ACTION_TRAP,
124 FLOW_ACTION_GOTO,
125 FLOW_ACTION_REDIRECT,
126 FLOW_ACTION_MIRRED,
48e584ac
JH
127 FLOW_ACTION_REDIRECT_INGRESS,
128 FLOW_ACTION_MIRRED_INGRESS,
e3ab786b
PNA
129 FLOW_ACTION_VLAN_PUSH,
130 FLOW_ACTION_VLAN_POP,
131 FLOW_ACTION_VLAN_MANGLE,
132 FLOW_ACTION_TUNNEL_ENCAP,
133 FLOW_ACTION_TUNNEL_DECAP,
134 FLOW_ACTION_MANGLE,
135 FLOW_ACTION_ADD,
136 FLOW_ACTION_CSUM,
137 FLOW_ACTION_MARK,
fb1b775a 138 FLOW_ACTION_PTYPE,
2ce12410 139 FLOW_ACTION_PRIORITY,
8bec2833
PNA
140 FLOW_ACTION_WAKE,
141 FLOW_ACTION_QUEUE,
a7a7be60 142 FLOW_ACTION_SAMPLE,
8c8cfc6e 143 FLOW_ACTION_POLICE,
b57dc7c1 144 FLOW_ACTION_CT,
9c26ba9b 145 FLOW_ACTION_CT_METADATA,
6749d590
JH
146 FLOW_ACTION_MPLS_PUSH,
147 FLOW_ACTION_MPLS_POP,
148 FLOW_ACTION_MPLS_MANGLE,
d29bdd69 149 FLOW_ACTION_GATE,
563ae557 150 FLOW_ACTION_PPPOE_PUSH,
b8cd5831
JL
151 FLOW_ACTION_JUMP,
152 FLOW_ACTION_PIPE,
ab95465c
MD
153 FLOW_ACTION_VLAN_PUSH_ETH,
154 FLOW_ACTION_VLAN_POP_ETH,
052f744f 155 FLOW_ACTION_CONTINUE,
7a978759 156 NUM_FLOW_ACTIONS,
e3ab786b
PNA
157};
158
159/* This is mirroring enum pedit_header_type definition for easy mapping between
160 * tc pedit action. Legacy TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK is mapped to
161 * FLOW_ACT_MANGLE_UNSPEC, which is supported by no driver.
162 */
163enum flow_action_mangle_base {
164 FLOW_ACT_MANGLE_UNSPEC = 0,
165 FLOW_ACT_MANGLE_HDR_TYPE_ETH,
166 FLOW_ACT_MANGLE_HDR_TYPE_IP4,
167 FLOW_ACT_MANGLE_HDR_TYPE_IP6,
168 FLOW_ACT_MANGLE_HDR_TYPE_TCP,
169 FLOW_ACT_MANGLE_HDR_TYPE_UDP,
170};
171
0dfb2d82 172enum flow_action_hw_stats_bit {
53eca1f3
JK
173 FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
174 FLOW_ACTION_HW_STATS_DELAYED_BIT,
16f80360 175 FLOW_ACTION_HW_STATS_DISABLED_BIT,
060b6381
EC
176
177 FLOW_ACTION_HW_STATS_NUM_BITS
42d5fe5f
JP
178};
179
0dfb2d82 180enum flow_action_hw_stats {
53eca1f3
JK
181 FLOW_ACTION_HW_STATS_IMMEDIATE =
182 BIT(FLOW_ACTION_HW_STATS_IMMEDIATE_BIT),
183 FLOW_ACTION_HW_STATS_DELAYED = BIT(FLOW_ACTION_HW_STATS_DELAYED_BIT),
184 FLOW_ACTION_HW_STATS_ANY = FLOW_ACTION_HW_STATS_IMMEDIATE |
185 FLOW_ACTION_HW_STATS_DELAYED,
16f80360
PNA
186 FLOW_ACTION_HW_STATS_DISABLED =
187 BIT(FLOW_ACTION_HW_STATS_DISABLED_BIT),
060b6381 188 FLOW_ACTION_HW_STATS_DONT_CARE = BIT(FLOW_ACTION_HW_STATS_NUM_BITS) - 1,
42d5fe5f 189};
2514921e 190
1158958a
VB
191typedef void (*action_destr)(void *priv);
192
2008495d
JP
193struct flow_action_cookie {
194 u32 cookie_len;
195 u8 cookie[];
196};
197
198struct flow_action_cookie *flow_action_cookie_create(void *data,
199 unsigned int len,
200 gfp_t gfp);
201void flow_action_cookie_destroy(struct flow_action_cookie *cookie);
202
e3ab786b
PNA
203struct flow_action_entry {
204 enum flow_action_id id;
5a995900 205 u32 hw_index;
0dfb2d82 206 enum flow_action_hw_stats hw_stats;
1158958a
VB
207 action_destr destructor;
208 void *destructor_priv;
e3ab786b
PNA
209 union {
210 u32 chain_index; /* FLOW_ACTION_GOTO */
211 struct net_device *dev; /* FLOW_ACTION_REDIRECT */
212 struct { /* FLOW_ACTION_VLAN */
213 u16 vid;
214 __be16 proto;
215 u8 prio;
216 } vlan;
ab95465c
MD
217 struct { /* FLOW_ACTION_VLAN_PUSH_ETH */
218 unsigned char dst[ETH_ALEN];
219 unsigned char src[ETH_ALEN];
220 } vlan_push_eth;
1f40be6a
PM
221 struct { /* FLOW_ACTION_MANGLE */
222 /* FLOW_ACTION_ADD */
e3ab786b
PNA
223 enum flow_action_mangle_base htype;
224 u32 offset;
225 u32 mask;
226 u32 val;
227 } mangle;
1158958a 228 struct ip_tunnel_info *tunnel; /* FLOW_ACTION_TUNNEL_ENCAP */
e3ab786b
PNA
229 u32 csum_flags; /* FLOW_ACTION_CSUM */
230 u32 mark; /* FLOW_ACTION_MARK */
fb1b775a 231 u16 ptype; /* FLOW_ACTION_PTYPE */
2ce12410 232 u32 priority; /* FLOW_ACTION_PRIORITY */
8bec2833
PNA
233 struct { /* FLOW_ACTION_QUEUE */
234 u32 ctx;
235 u32 index;
236 u8 vf;
237 } queue;
a7a7be60
PJV
238 struct { /* FLOW_ACTION_SAMPLE */
239 struct psample_group *psample_group;
240 u32 rate;
241 u32 trunc_size;
242 bool truncate;
243 } sample;
8c8cfc6e 244 struct { /* FLOW_ACTION_POLICE */
5f035af7 245 u32 burst;
8c8cfc6e 246 u64 rate_bytes_ps;
b8cd5831
JL
247 u64 peakrate_bytes_ps;
248 u32 avrate;
249 u16 overhead;
25660156
XH
250 u64 burst_pkt;
251 u64 rate_pkt_ps;
19e528dc 252 u32 mtu;
b8cd5831
JL
253 struct {
254 enum flow_action_id act_id;
255 u32 extval;
256 } exceed, notexceed;
8c8cfc6e 257 } police;
b57dc7c1
PB
258 struct { /* FLOW_ACTION_CT */
259 int action;
260 u16 zone;
edd5861e 261 struct nf_flowtable *flow_table;
b57dc7c1 262 } ct;
9c26ba9b 263 struct {
30b0cf90 264 unsigned long cookie;
9c26ba9b
PB
265 u32 mark;
266 u32 labels[4];
941eff5a 267 bool orig_dir;
9c26ba9b 268 } ct_metadata;
6749d590
JH
269 struct { /* FLOW_ACTION_MPLS_PUSH */
270 u32 label;
271 __be16 proto;
272 u8 tc;
273 u8 bos;
274 u8 ttl;
275 } mpls_push;
276 struct { /* FLOW_ACTION_MPLS_POP */
277 __be16 proto;
278 } mpls_pop;
279 struct { /* FLOW_ACTION_MPLS_MANGLE */
280 u32 label;
281 u8 tc;
282 u8 bos;
283 u8 ttl;
284 } mpls_mangle;
d29bdd69 285 struct {
d29bdd69
PL
286 s32 prio;
287 u64 basetime;
288 u64 cycletime;
289 u64 cycletimeext;
290 u32 num_entries;
291 struct action_gate_entry *entries;
292 } gate;
563ae557
PNA
293 struct { /* FLOW_ACTION_PPPOE_PUSH */
294 u16 sid;
295 } pppoe;
e3ab786b 296 };
2008495d 297 struct flow_action_cookie *cookie; /* user defined action cookie */
e3ab786b
PNA
298};
299
300struct flow_action {
301 unsigned int num_entries;
8661b6e7 302 struct flow_action_entry entries[];
e3ab786b
PNA
303};
304
305static inline bool flow_action_has_entries(const struct flow_action *action)
306{
307 return action->num_entries;
308}
309
ab79af32 310/**
c87a4c54 311 * flow_offload_has_one_action() - check if exactly one action is present
ab79af32
PJV
312 * @action: tc filter flow offload action
313 *
314 * Returns true if exactly one action is present.
315 */
316static inline bool flow_offload_has_one_action(const struct flow_action *action)
317{
318 return action->num_entries == 1;
319}
320
d97b4b10
JL
321static inline bool flow_action_is_last_entry(const struct flow_action *action,
322 const struct flow_action_entry *entry)
323{
324 return entry == &action->entries[action->num_entries - 1];
325}
326
62751b68
JP
327#define flow_action_for_each(__i, __act, __actions) \
328 for (__i = 0, __act = &(__actions)->entries[0]; \
329 __i < (__actions)->num_entries; \
330 __act = &(__actions)->entries[++__i])
331
319a1d19 332static inline bool
53eca1f3
JK
333flow_action_mixed_hw_stats_check(const struct flow_action *action,
334 struct netlink_ext_ack *extack)
319a1d19
JP
335{
336 const struct flow_action_entry *action_entry;
3f649ab7 337 u8 last_hw_stats;
319a1d19
JP
338 int i;
339
340 if (flow_offload_has_one_action(action))
341 return true;
342
fa05bdb8
IS
343 flow_action_for_each(i, action_entry, action) {
344 if (i && action_entry->hw_stats != last_hw_stats) {
345 NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");
346 return false;
319a1d19 347 }
fa05bdb8 348 last_hw_stats = action_entry->hw_stats;
319a1d19
JP
349 }
350 return true;
351}
352
353static inline const struct flow_action_entry *
354flow_action_first_entry_get(const struct flow_action *action)
355{
356 WARN_ON(!flow_action_has_entries(action));
357 return &action->entries[0];
358}
359
360static inline bool
53eca1f3
JK
361__flow_action_hw_stats_check(const struct flow_action *action,
362 struct netlink_ext_ack *extack,
363 bool check_allow_bit,
0dfb2d82 364 enum flow_action_hw_stats_bit allow_bit)
319a1d19
JP
365{
366 const struct flow_action_entry *action_entry;
367
368 if (!flow_action_has_entries(action))
369 return true;
53eca1f3 370 if (!flow_action_mixed_hw_stats_check(action, extack))
319a1d19 371 return false;
16f80360 372
319a1d19 373 action_entry = flow_action_first_entry_get(action);
060b6381
EC
374
375 /* Zero is not a legal value for hw_stats, catch anyone passing it */
376 WARN_ON_ONCE(!action_entry->hw_stats);
16f80360 377
a16fa289 378 if (!check_allow_bit &&
060b6381 379 ~action_entry->hw_stats & FLOW_ACTION_HW_STATS_ANY) {
319a1d19
JP
380 NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
381 return false;
a16fa289 382 } else if (check_allow_bit &&
0dfb2d82 383 !(action_entry->hw_stats & BIT(allow_bit))) {
319a1d19
JP
384 NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");
385 return false;
386 }
387 return true;
388}
389
a16fa289 390static inline bool
53eca1f3
JK
391flow_action_hw_stats_check(const struct flow_action *action,
392 struct netlink_ext_ack *extack,
0dfb2d82 393 enum flow_action_hw_stats_bit allow_bit)
a16fa289 394{
53eca1f3 395 return __flow_action_hw_stats_check(action, extack, true, allow_bit);
a16fa289
JP
396}
397
319a1d19 398static inline bool
53eca1f3
JK
399flow_action_basic_hw_stats_check(const struct flow_action *action,
400 struct netlink_ext_ack *extack)
319a1d19 401{
53eca1f3 402 return __flow_action_hw_stats_check(action, extack, false, 0);
319a1d19
JP
403}
404
8f256622
PNA
405struct flow_rule {
406 struct flow_match match;
e3ab786b 407 struct flow_action action;
8f256622
PNA
408};
409
e3ab786b 410struct flow_rule *flow_rule_alloc(unsigned int num_actions);
8f256622
PNA
411
412static inline bool flow_rule_match_key(const struct flow_rule *rule,
413 enum flow_dissector_key_id key)
414{
415 return dissector_uses_key(rule->match.dissector, key);
416}
417
3b1903ef
PNA
418struct flow_stats {
419 u64 pkts;
420 u64 bytes;
4b61d3e8 421 u64 drops;
3b1903ef 422 u64 lastused;
93a129eb
JP
423 enum flow_action_hw_stats used_hw_stats;
424 bool used_hw_stats_valid;
3b1903ef
PNA
425};
426
427static inline void flow_stats_update(struct flow_stats *flow_stats,
4b61d3e8
PL
428 u64 bytes, u64 pkts,
429 u64 drops, u64 lastused,
93a129eb 430 enum flow_action_hw_stats used_hw_stats)
3b1903ef 431{
9f9dc493
JH
432 flow_stats->pkts += pkts;
433 flow_stats->bytes += bytes;
4b61d3e8 434 flow_stats->drops += drops;
9f9dc493 435 flow_stats->lastused = max_t(u64, flow_stats->lastused, lastused);
93a129eb
JP
436
437 /* The driver should pass value with a maximum of one bit set.
438 * Passing FLOW_ACTION_HW_STATS_ANY is invalid.
439 */
440 WARN_ON(used_hw_stats == FLOW_ACTION_HW_STATS_ANY);
441 flow_stats->used_hw_stats |= used_hw_stats;
442 flow_stats->used_hw_stats_valid = true;
3b1903ef
PNA
443}
444
4e95bc26 445enum flow_block_command {
9c0e189e
PNA
446 FLOW_BLOCK_BIND,
447 FLOW_BLOCK_UNBIND,
4e95bc26
PNA
448};
449
450enum flow_block_binder_type {
32f8c409
PNA
451 FLOW_BLOCK_BINDER_TYPE_UNSPEC,
452 FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS,
453 FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS,
aee9caa0
PM
454 FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP,
455 FLOW_BLOCK_BINDER_TYPE_RED_MARK,
4e95bc26
PNA
456};
457
14bfb13f
PNA
458struct flow_block {
459 struct list_head cb_list;
460};
461
4e95bc26
PNA
462struct netlink_ext_ack;
463
464struct flow_block_offload {
465 enum flow_block_command command;
466 enum flow_block_binder_type binder_type;
955bcb6e 467 bool block_shared;
c9f14470 468 bool unlocked_driver_cb;
da3eeb90 469 struct net *net;
14bfb13f 470 struct flow_block *block;
da3eeb90 471 struct list_head cb_list;
4e95bc26
PNA
472 struct list_head *driver_block_list;
473 struct netlink_ext_ack *extack;
c40f4e50 474 struct Qdisc *sch;
74fc4f82 475 struct list_head *cb_list_head;
4e95bc26
PNA
476};
477
a7323311
PNA
478enum tc_setup_type;
479typedef int flow_setup_cb_t(enum tc_setup_type type, void *type_data,
480 void *cb_priv);
481
1fac52da
PNA
482struct flow_block_cb;
483
484struct flow_block_indr {
485 struct list_head list;
486 struct net_device *dev;
c40f4e50 487 struct Qdisc *sch;
1fac52da
PNA
488 enum flow_block_binder_type binder_type;
489 void *data;
a1db2178 490 void *cb_priv;
1fac52da
PNA
491 void (*cleanup)(struct flow_block_cb *block_cb);
492};
493
d63db30c 494struct flow_block_cb {
da3eeb90 495 struct list_head driver_list;
d63db30c 496 struct list_head list;
a7323311 497 flow_setup_cb_t *cb;
d63db30c
PNA
498 void *cb_ident;
499 void *cb_priv;
500 void (*release)(void *cb_priv);
1fac52da 501 struct flow_block_indr indr;
d63db30c
PNA
502 unsigned int refcnt;
503};
504
a7323311 505struct flow_block_cb *flow_block_cb_alloc(flow_setup_cb_t *cb,
d63db30c
PNA
506 void *cb_ident, void *cb_priv,
507 void (*release)(void *cb_priv));
26f2eb27 508struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,
509 void *cb_ident, void *cb_priv,
510 void (*release)(void *cb_priv),
511 struct flow_block_offload *bo,
c40f4e50
PM
512 struct net_device *dev,
513 struct Qdisc *sch, void *data,
a1db2178 514 void *indr_cb_priv,
26f2eb27 515 void (*cleanup)(struct flow_block_cb *block_cb));
d63db30c
PNA
516void flow_block_cb_free(struct flow_block_cb *block_cb);
517
14bfb13f 518struct flow_block_cb *flow_block_cb_lookup(struct flow_block *block,
a7323311 519 flow_setup_cb_t *cb, void *cb_ident);
da3eeb90 520
67bd0d5e
PNA
521void *flow_block_cb_priv(struct flow_block_cb *block_cb);
522void flow_block_cb_incref(struct flow_block_cb *block_cb);
523unsigned int flow_block_cb_decref(struct flow_block_cb *block_cb);
524
da3eeb90
PNA
525static inline void flow_block_cb_add(struct flow_block_cb *block_cb,
526 struct flow_block_offload *offload)
527{
528 list_add_tail(&block_cb->list, &offload->cb_list);
529}
530
531static inline void flow_block_cb_remove(struct flow_block_cb *block_cb,
532 struct flow_block_offload *offload)
533{
534 list_move(&block_cb->list, &offload->cb_list);
535}
536
26f2eb27 537static inline void flow_indr_block_cb_remove(struct flow_block_cb *block_cb,
538 struct flow_block_offload *offload)
539{
540 list_del(&block_cb->indr.list);
541 list_move(&block_cb->list, &offload->cb_list);
542}
543
a7323311 544bool flow_block_cb_is_busy(flow_setup_cb_t *cb, void *cb_ident,
0d4fd02e
PNA
545 struct list_head *driver_block_list);
546
4e95bc26 547int flow_block_cb_setup_simple(struct flow_block_offload *f,
a7323311
PNA
548 struct list_head *driver_list,
549 flow_setup_cb_t *cb,
4e95bc26
PNA
550 void *cb_ident, void *cb_priv, bool ingress_only);
551
f9e30088
PNA
552enum flow_cls_command {
553 FLOW_CLS_REPLACE,
554 FLOW_CLS_DESTROY,
555 FLOW_CLS_STATS,
556 FLOW_CLS_TMPLT_CREATE,
557 FLOW_CLS_TMPLT_DESTROY,
558};
559
560struct flow_cls_common_offload {
561 u32 chain_index;
562 __be16 protocol;
563 u32 prio;
564 struct netlink_ext_ack *extack;
565};
566
567struct flow_cls_offload {
568 struct flow_cls_common_offload common;
569 enum flow_cls_command command;
570 unsigned long cookie;
571 struct flow_rule *rule;
572 struct flow_stats stats;
573 u32 classid;
574};
575
8cbfe939
BZ
576enum offload_act_command {
577 FLOW_ACT_REPLACE,
578 FLOW_ACT_DESTROY,
579 FLOW_ACT_STATS,
580};
581
582struct flow_offload_action {
583 struct netlink_ext_ack *extack; /* NULL in FLOW_ACT_STATS process*/
584 enum offload_act_command command;
585 enum flow_action_id id;
586 u32 index;
587 struct flow_stats stats;
588 struct flow_action action;
589};
590
591struct flow_offload_action *offload_action_alloc(unsigned int num_actions);
592
f9e30088
PNA
593static inline struct flow_rule *
594flow_cls_offload_flow_rule(struct flow_cls_offload *flow_cmd)
595{
596 return flow_cmd->rule;
597}
598
14bfb13f
PNA
599static inline void flow_block_init(struct flow_block *flow_block)
600{
601 INIT_LIST_HEAD(&flow_block->cb_list);
602}
603
c40f4e50 604typedef int flow_indr_block_bind_cb_t(struct net_device *dev, struct Qdisc *sch, void *cb_priv,
66f1939a 605 enum tc_setup_type type, void *type_data,
606 void *data,
607 void (*cleanup)(struct flow_block_cb *block_cb));
4e481908 608
1fac52da
PNA
609int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv);
610void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv,
a1db2178 611 void (*release)(void *cb_priv));
c40f4e50 612int flow_indr_dev_setup_offload(struct net_device *dev, struct Qdisc *sch,
1fac52da
PNA
613 enum tc_setup_type type, void *data,
614 struct flow_block_offload *bo,
615 void (*cleanup)(struct flow_block_cb *block_cb));
3a41c64d 616bool flow_indr_dev_exists(void);
1fac52da 617
8f256622 618#endif /* _NET_FLOW_OFFLOAD_H */