Skip to content

Commit

Permalink
net: tc_skbedit: Make the skbedit priority offloadable
Browse files Browse the repository at this point in the history
The skbedit action "priority" is used for adjusting SKB priority. Allow
drivers to offload the action by introducing two new skbedit getters and a
new flow action, and initializing appropriately in tc_setup_flow_action().

Signed-off-by: Petr Machata <[email protected]>
Reviewed-by: Jiri Pirko <[email protected]>
Signed-off-by: Ido Schimmel <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
pmachata authored and davem330 committed Mar 20, 2020
1 parent fe93f0b commit 2ce1241
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/net/flow_offload.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ enum flow_action_id {
FLOW_ACTION_CSUM,
FLOW_ACTION_MARK,
FLOW_ACTION_PTYPE,
FLOW_ACTION_PRIORITY,
FLOW_ACTION_WAKE,
FLOW_ACTION_QUEUE,
FLOW_ACTION_SAMPLE,
Expand Down Expand Up @@ -211,6 +212,7 @@ struct flow_action_entry {
u32 csum_flags; /* FLOW_ACTION_CSUM */
u32 mark; /* FLOW_ACTION_MARK */
u16 ptype; /* FLOW_ACTION_PTYPE */
u32 priority; /* FLOW_ACTION_PRIORITY */
struct { /* FLOW_ACTION_QUEUE */
u32 ctx;
u32 index;
Expand Down
17 changes: 17 additions & 0 deletions include/net/tc_act/tc_skbedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,21 @@ static inline u32 tcf_skbedit_ptype(const struct tc_action *a)
return ptype;
}

/* Return true iff action is priority */
static inline bool is_tcf_skbedit_priority(const struct tc_action *a)
{
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_PRIORITY);
}

static inline u32 tcf_skbedit_priority(const struct tc_action *a)
{
u32 priority;

rcu_read_lock();
priority = rcu_dereference(to_skbedit(a)->params)->priority;
rcu_read_unlock();

return priority;
}

#endif /* __NET_TC_SKBEDIT_H */
3 changes: 3 additions & 0 deletions net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,9 @@ int tc_setup_flow_action(struct flow_action *flow_action,
} else if (is_tcf_skbedit_ptype(act)) {
entry->id = FLOW_ACTION_PTYPE;
entry->ptype = tcf_skbedit_ptype(act);
} else if (is_tcf_skbedit_priority(act)) {
entry->id = FLOW_ACTION_PRIORITY;
entry->priority = tcf_skbedit_priority(act);
} else {
err = -EOPNOTSUPP;
goto err_out_locked;
Expand Down

0 comments on commit 2ce1241

Please sign in to comment.