Skip to content

Commit 80cd22c

Browse files
Paul Blakeykuba-moo
Paul Blakey
authored andcommitted
net/sched: cls_api: Support hardware miss to tc action
For drivers to support partial offload of a filter's action list, add support for action miss to specify an action instance to continue from in sw. CT action in particular can't be fully offloaded, as new connections need to be handled in software. This imposes other limitations on the actions that can be offloaded together with the CT action, such as packet modifications. Assign each action on a filter's action list a unique miss_cookie which drivers can then use to fill action_miss part of the tc skb extension. On getting back this miss_cookie, find the action instance with relevant cookie and continue classifying from there. Signed-off-by: Paul Blakey <paulb@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent db4b490 commit 80cd22c

File tree

7 files changed

+236
-27
lines changed

7 files changed

+236
-27
lines changed

include/linux/skbuff.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,16 @@ struct nf_bridge_info {
319319
* and read by ovs to recirc_id.
320320
*/
321321
struct tc_skb_ext {
322-
__u32 chain;
322+
union {
323+
u64 act_miss_cookie;
324+
__u32 chain;
325+
};
323326
__u16 mru;
324327
__u16 zone;
325328
u8 post_ct:1;
326329
u8 post_ct_snat:1;
327330
u8 post_ct_dnat:1;
331+
u8 act_miss:1; /* Set if act_miss_cookie is used */
328332
};
329333
#endif
330334

include/net/flow_offload.h

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ struct flow_action_entry {
229229
enum flow_action_id id;
230230
u32 hw_index;
231231
unsigned long cookie;
232+
u64 miss_cookie;
232233
enum flow_action_hw_stats hw_stats;
233234
action_destr destructor;
234235
void *destructor_priv;

include/net/pkt_cls.h

+20-14
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
5959
void tcf_block_put(struct tcf_block *block);
6060
void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
6161
struct tcf_block_ext_info *ei);
62+
int tcf_exts_init_ex(struct tcf_exts *exts, struct net *net, int action,
63+
int police, struct tcf_proto *tp, u32 handle, bool used_action_miss);
6264

6365
static inline bool tcf_block_shared(struct tcf_block *block)
6466
{
@@ -229,6 +231,7 @@ struct tcf_exts {
229231
struct tc_action **actions;
230232
struct net *net;
231233
netns_tracker ns_tracker;
234+
struct tcf_exts_miss_cookie_node *miss_cookie_node;
232235
#endif
233236
/* Map to export classifier specific extension TLV types to the
234237
* generic extensions API. Unsupported extensions must be set to 0.
@@ -240,21 +243,11 @@ struct tcf_exts {
240243
static inline int tcf_exts_init(struct tcf_exts *exts, struct net *net,
241244
int action, int police)
242245
{
243-
#ifdef CONFIG_NET_CLS_ACT
244-
exts->type = 0;
245-
exts->nr_actions = 0;
246-
/* Note: we do not own yet a reference on net.
247-
* This reference might be taken later from tcf_exts_get_net().
248-
*/
249-
exts->net = net;
250-
exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *),
251-
GFP_KERNEL);
252-
if (!exts->actions)
253-
return -ENOMEM;
246+
#ifdef CONFIG_NET_CLS
247+
return tcf_exts_init_ex(exts, net, action, police, NULL, 0, false);
248+
#else
249+
return -EOPNOTSUPP;
254250
#endif
255-
exts->action = action;
256-
exts->police = police;
257-
return 0;
258251
}
259252

260253
/* Return false if the netns is being destroyed in cleanup_net(). Callers
@@ -360,6 +353,18 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
360353
return TC_ACT_OK;
361354
}
362355

356+
static inline int
357+
tcf_exts_exec_ex(struct sk_buff *skb, struct tcf_exts *exts, int act_index,
358+
struct tcf_result *res)
359+
{
360+
#ifdef CONFIG_NET_CLS_ACT
361+
return tcf_action_exec(skb, exts->actions + act_index,
362+
exts->nr_actions - act_index, res);
363+
#else
364+
return TC_ACT_OK;
365+
#endif
366+
}
367+
363368
int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
364369
struct nlattr **tb, struct nlattr *rate_tlv,
365370
struct tcf_exts *exts, u32 flags,
@@ -584,6 +589,7 @@ int tc_setup_offload_action(struct flow_action *flow_action,
584589
void tc_cleanup_offload_action(struct flow_action *flow_action);
585590
int tc_setup_action(struct flow_action *flow_action,
586591
struct tc_action *actions[],
592+
u32 miss_cookie_base,
587593
struct netlink_ext_ack *extack);
588594

589595
int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,

include/net/sch_generic.h

+2
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ struct tcf_proto_ops {
369369
struct nlattr **tca,
370370
struct netlink_ext_ack *extack);
371371
void (*tmplt_destroy)(void *tmplt_priv);
372+
struct tcf_exts * (*get_exts)(const struct tcf_proto *tp,
373+
u32 handle);
372374

373375
/* rtnetlink specific */
374376
int (*dump)(struct net*, struct tcf_proto*, void *,

net/openvswitch/flow.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info,
10411041
#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
10421042
if (tc_skb_ext_tc_enabled()) {
10431043
tc_ext = skb_ext_find(skb, TC_SKB_EXT);
1044-
key->recirc_id = tc_ext ? tc_ext->chain : 0;
1044+
key->recirc_id = tc_ext && !tc_ext->act_miss ?
1045+
tc_ext->chain : 0;
10451046
OVS_CB(skb)->mru = tc_ext ? tc_ext->mru : 0;
10461047
post_ct = tc_ext ? tc_ext->post_ct : false;
10471048
post_ct_snat = post_ct ? tc_ext->post_ct_snat : false;

net/sched/act_api.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static int tcf_action_offload_add_ex(struct tc_action *action,
268268
if (err)
269269
goto fl_err;
270270

271-
err = tc_setup_action(&fl_action->action, actions, extack);
271+
err = tc_setup_action(&fl_action->action, actions, 0, extack);
272272
if (err) {
273273
NL_SET_ERR_MSG_MOD(extack,
274274
"Failed to setup tc actions for offload");

0 commit comments

Comments
 (0)