allow user to offload tc action to net device
Subsystems (14)
v5 cover allow user to offload tc action to net device
Baowen Zheng says:
Allow use of flow_indr_dev_register/flow_indr_dev_setup_offload to offload tc actions independent of flows.
The motivation for this work is to prepare for using TC police action instances to provide hardware offload of OVS metering feature - which calls for policers that may be used by multiple flows and whose lifecycle is independent of any flows that use them.
This patch includes basic changes to offload drivers to return EOPNOTSUPP if this feature is used - it is not yet supported by any driver.
Tc cli command to offload and quote an action:
# tc qdisc del dev $DEV ingress && sleep 1 || true # tc actions delete action police index 200 || true
# tc qdisc add dev $DEV ingress # tc qdisc show dev $DEV ingress
# tc actions add action police rate 100mbit burst 10000k index 200 skip_sw # tc -s -d actions list action police total acts 1
action order 0: police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify overhead 0b linklayer ethernet
ref 1 bind 0 installed 142 sec used 0 sec
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
skip_sw in_hw in_hw_count 1
used_hw_stats delayed
# tc filter add dev $DEV protocol ip parent ffff: \
flower skip_sw ip_proto tcp action police index 200
# tc -s -d filter show dev $DEV protocol ip parent ffff:
filter pref 49152 flower chain 0
filter pref 49152 flower chain 0 handle 0x1
eth_type ipv4
ip_proto tcp
skip_sw
in_hw in_hw_count 1
action order 1: police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action
reclassify overhead 0b linklayer ethernet
ref 2 bind 1 installed 300 sec used 0 sec
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
skip_sw in_hw in_hw_count 1
used_hw_stats delayed # tc filter add dev $DEV protocol ipv6 parent ffff: \
flower skip_sw ip_proto tcp action police index 200
# tc -s -d filter show dev $DEV protocol ipv6 parent ffff:
filter pref 49151 flower chain 0
filter pref 49151 flower chain 0 handle 0x1
eth_type ipv6
ip_proto tcp
skip_sw
in_hw in_hw_count 1
action order 1: police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action
reclassify overhead 0b linklayer ethernet
ref 3 bind 2 installed 761 sec used 0 sec
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
skip_sw in_hw in_hw_count 1
used_hw_stats delayed# tc -s -d actions list action police total acts 1
action order 0: police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify overhead 0b linklayer ethernet ref 3 bind 2 installed 917 sec used 0 sec
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
skip_sw in_hw in_hw_count 1
used_hw_stats delayed
Changes compared to v4 patches:
* Made changes of code style according to the public review comments.
* Add a fix for unsupported mpls action type in flow action setup stage.
* Add ops to tc_action_ops for flow action setup to facilitate adding a standalone action module.
* Add notification process when deleting action in reoffload process.
Baowen Zheng (12):
flow_offload: fill flags to action structure
flow_offload: reject to offload tc actions in offload drivers
flow_offload: add index to flow_action_entry structure
flow_offload: return EOPNOTSUPP for the unsupported mpls action type
flow_offload: add ops to tc_action_ops for flow action setup
flow_offload: allow user to offload tc action to net device
flow_offload: add skip_hw and skip_sw to control if offload the action
flow_offload: add process to update action stats from hardware
net: sched: save full flags for tc action
flow_offload: add reoffload process to update hw_count
flow_offload: validate flags of filter and actions
selftests: tc-testing: add action offload selftest for action and
filter
drivers/net/dsa/ocelot/felix_vsc9959.c | 4 +- drivers/net/dsa/sja1105/sja1105_flower.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 2 +- .../net/ethernet/freescale/enetc/enetc_qos.c | 6 +- .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 3 + .../ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 2 +- .../ethernet/netronome/nfp/flower/offload.c | 3 + include/linux/netdevice.h | 1 + include/net/act_api.h | 27 +- include/net/flow_offload.h | 20 +- include/net/pkt_cls.h | 27 +- include/net/tc_act/tc_gate.h | 5 - include/uapi/linux/pkt_cls.h | 9 +- net/core/flow_offload.c | 46 +- net/sched/act_api.c | 450 +++++++++++++++++- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_csum.c | 19 + net/sched/act_ct.c | 21 + net/sched/act_ctinfo.c | 2 +- net/sched/act_gact.c | 38 ++ net/sched/act_gate.c | 51 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 2 +- net/sched/act_mirred.c | 50 ++ net/sched/act_mpls.c | 54 ++- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 36 +- net/sched/act_police.c | 27 +- net/sched/act_sample.c | 32 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 38 +- net/sched/act_skbmod.c | 2 +- net/sched/act_tunnel_key.c | 54 +++ net/sched/act_vlan.c | 48 ++ net/sched/cls_api.c | 263 ++-------- net/sched/cls_flower.c | 9 +- net/sched/cls_matchall.c | 9 +- net/sched/cls_u32.c | 12 +- .../tc-testing/tc-tests/actions/police.json | 24 + .../tc-testing/tc-tests/filters/matchall.json | 24 + 42 files changed, 1144 insertions(+), 290 deletions(-)
Signature · 1 line
2.20.1
PATCH v5 1/12 flow_offload: fill flags to action structure
From: Baowen Zheng <[email protected]>
Fill flags to action structure to allow user control if the action should be offloaded to hardware or not.
--- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_ctinfo.c | 2 +- net/sched/act_gate.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 2 +- net/sched/act_mpls.c | 2 +- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-)
net/sched/act_bpf.c +1 -1
@@ -305,7 +305,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, ret =tcf_idr_check_alloc (tn, &index, act, bind);if (!ret) { ret =tcf_idr_create (tn, index, est, act, - &act_bpf_ops, bind, true,0 ); + &act_bpf_ops, bind, true, flags);if (ret <0 ) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_connmark.c +1 -1
@@ -124,7 +124,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, ret =tcf_idr_check_alloc (tn, &index, a, bind);if (!ret) { ret =tcf_idr_create (tn, index, est, a, - &act_connmark_ops, bind, false,0 ); + &act_connmark_ops, bind, false, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_ctinfo.c +1 -1
@@ -212,7 +212,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, err =tcf_idr_check_alloc (tn, &index, a, bind);if (!err) { ret =tcf_idr_create (tn, index, est, a, - &act_ctinfo_ops, bind, false,0 ); + &act_ctinfo_ops, bind, false, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_gate.c +1 -1
@@ -357,7 +357,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla,if (!err) { ret =tcf_idr_create (tn, index, est, a, - &act_gate_ops, bind, false,0 ); + &act_gate_ops, bind, false, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_ife.c +1 -1
@@ -553,7 +553,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, &act_ife_ops, - bind, true,0 ); + bind, true, flags);if (ret) {tcf_idr_cleanup (tn, index);kfree (p);
net/sched/act_ipt.c +1 -1
@@ -145,7 +145,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, ops, bind, - false,0 ); + false, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_mpls.c +1 -1
@@ -248,7 +248,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, - &act_mpls_ops, bind, true,0 ); + &act_mpls_ops, bind, true, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_nat.c +1 -1
@@ -61,7 +61,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, err =tcf_idr_check_alloc (tn, &index, a, bind);if (!err) { ret =tcf_idr_create (tn, index, est, a, - &act_nat_ops, bind, false,0 ); + &act_nat_ops, bind, false, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_pedit.c +1 -1
@@ -189,7 +189,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, err =tcf_idr_check_alloc (tn, &index, a, bind);if (!err) { ret =tcf_idr_create (tn, index, est, a, - &act_pedit_ops, bind, false,0 ); + &act_pedit_ops, bind, false, flags);if (ret) {tcf_idr_cleanup (tn, index); goto out_free;
net/sched/act_police.c +1 -1
@@ -90,7 +90,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index,NULL , a, - &act_police_ops, bind, true,0 ); + &act_police_ops, bind, true, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_sample.c +1 -1
@@ -70,7 +70,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, - &act_sample_ops, bind, true,0 ); + &act_sample_ops, bind, true, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_simple.c +1 -1
@@ -129,7 +129,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, - &act_simp_ops, bind, false,0 ); + &act_simp_ops, bind, false, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_skbedit.c +1 -1
@@ -176,7 +176,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, - &act_skbedit_ops, bind, true,0 ); + &act_skbedit_ops, bind, true, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
net/sched/act_skbmod.c +1 -1
@@ -168,7 +168,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,if (!exists) { ret =tcf_idr_create (tn, index, est, a, - &act_skbmod_ops, bind, true,0 ); + &act_skbmod_ops, bind, true, flags);if (ret) {tcf_idr_cleanup (tn, index);return ret;
Signature · 1 line
2.20.1
PATCH v5 2/12 flow_offload: reject to offload tc actions in offload drivers
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
A follow-up patch will allow users to offload tc actions independent of classifier in the software datapath.
In preparation for this, teach all drivers that support offload of the flow tables to reject such configuration as currently none of them support it.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 3 +++ drivers/net/ethernet/netronome/nfp/flower/offload.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +1 -1
@@ -1962,7 +1962,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, struct Qdisc *sch, v void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { - if (!bnxt_is_netdev_indr_offload(netdev)) + if (!netdev || !bnxt_is_netdev_indr_offload(netdev)) return -EOPNOTSUPP;switch (type) {
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +3 -0
@@ -517,6 +517,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, struct Qdisc *sch, void * void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { + if (!netdev) + return -EOPNOTSUPP; +switch (type) {case TC_SETUP_BLOCK : return mlx5e_rep_indr_setup_block(netdev, sch, cb_priv, type_data,
drivers/net/ethernet/netronome/nfp/flower/offload.c +3 -0
@@ -1867,6 +1867,9 @@ nfp_flower_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch, void * void *data, void (*cleanup)(struct flow_block_cb *block_cb)) { + if (!netdev) + return -EOPNOTSUPP; +if (!nfp_fl_is_netdev_to_offload (netdev))return -EOPNOTSUPP ;
Signature · 1 line
2.20.1
PATCH v5 3/12 flow_offload: add index to flow_action_entry structure
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Add index to flow_action_entry structure and delete index from police and gate child structure.
We make this change to offload tc action for driver to identify a tc action.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/sja1105/sja1105_flower.c | 2 +- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 6 +++--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 2 +- include/net/flow_offload.h | 3 +-- include/net/tc_act/tc_gate.h | 5 ----- net/sched/cls_api.c | 3 +-- 8 files changed, 10 insertions(+), 17 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +2 -2
@@ -1746,7 +1746,7 @@ static void vsc9959_psfp_sfi_table_del(struct ocelot *ocelot, u32 index)static void vsc9959_psfp_parse_gate (const struct flow_action_entry *entry,struct felix_stream_gate *sgi) { - sgi->index = entry->gate.index; + sgi->index = entry->index; sgi->ipv_valid = (entry->gate.prio <0 ) ?0 :1 ; sgi->init_ipv = (sgi->ipv_valid) ? entry->gate.prio :0 ; sgi->basetime = entry->gate.basetime;
@@ -1948,7 +1948,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,kfree (sgi);break ;case FLOW_ACTION_POLICE : - index = a->police.index +VSC9959_PSFP_POLICER_BASE ; + index = a->index +VSC9959_PSFP_POLICER_BASE ;if (index >VSC9959_PSFP_POLICER_MAX ) { ret = -EINVAL ; goto err;
drivers/net/dsa/sja1105/sja1105_flower.c +1 -1
@@ -379,7 +379,7 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port, vl_rule = true; rc = sja1105_vl_gate(priv, port, extack, cookie, - &key, act->gate.index, + &key, act->index, act->gate.prio, act->gate.basetime, act->gate.cycletime,
drivers/net/ethernet/freescale/enetc/enetc_qos.c +3 -3
@@ -1182,7 +1182,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, }/* parsing gate action */ -if (entryg->gate.index >= priv->psfp_cap.max_psfp_gate) { +if (entryg->index >= priv->psfp_cap.max_psfp_gate) {NL_SET_ERR_MSG_MOD (extack,"No Stream Gate resource!" ); err = -ENOSPC ; goto free_filter;
@@ -1202,7 +1202,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, }refcount_set (&sgi->refcount,1 ); - sgi->index = entryg->gate.index; + sgi->index = entryg->index; sgi->init_ipv = entryg->gate.prio; sgi->basetime = entryg->gate.basetime; sgi->cycletime = entryg->gate.cycletime;
@@ -1244,7 +1244,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,refcount_set (&fmi->refcount,1 ); fmi->cir = entryp->police.rate_bytes_ps; fmi->cbs = entryp->police.burst; - fmi->index = entryp->police.index; + fmi->index = entryp->index; filter->flags |=ENETC_PSFP_FLAGS_FMI ; filter->fmi_index = fmi->index; sfi->meter_id = fmi->index;
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +1 -1
@@ -203,7 +203,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,*/ burst =roundup_pow_of_two (act->police.burst); err =mlxsw_sp_acl_rulei_act_police (mlxsw_sp, rulei, - act->police.index, + act->index, act->police.rate_bytes_ps, burst, extack);if (err)
drivers/net/ethernet/mscc/ocelot_flower.c +1 -1
@@ -303,7 +303,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, } filter->action.police_ena = true; - pol_ix = a->police.index + ocelot->vcap_pol.base; + pol_ix = a->index + ocelot->vcap_pol.base; pol_max = ocelot->vcap_pol.max;if (ocelot->vcap_pol.max2 && pol_ix > pol_max) {
include/net/flow_offload.h +1 -2
@@ -197,6 +197,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie);struct flow_action_entry {enum flow_action_id id; +u32 index;enum flow_action_hw_stats hw_stats;action_destr destructor;void *destructor_priv;
@@ -232,7 +233,6 @@ struct flow_action_entry {bool truncate; } sample;struct {/* FLOW_ACTION_POLICE */ -u32 index;u32 burst;u64 rate_bytes_ps;u64 burst_pkt;
@@ -267,7 +267,6 @@ struct flow_action_entry {u8 ttl; } mpls_mangle;struct { -u32 index;s32 prio;u64 basetime;u64 cycletime;
include/net/tc_act/tc_gate.h +0 -5
@@ -60,11 +60,6 @@ static inline bool is_tcf_gate(const struct tc_action *a)return false; } -static inline u32 tcf_gate_index (const struct tc_action *a) -{ -return a->tcfa_index; -} -static inline s32 tcf_gate_prio (const struct tc_action *a) {s32 tcfg_prio;
net/sched/cls_api.c +1 -2
@@ -3568,6 +3568,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, goto err_out_locked; entry->hw_stats =tc_act_hw_stats (act->hw_stats); + entry->index = act->tcfa_index;if (is_tcf_gact_ok (act)) { entry->id =FLOW_ACTION_ACCEPT ;
@@ -3659,7 +3660,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->police.rate_pkt_ps =tcf_police_rate_pkt_ps (act); entry->police.mtu =tcf_police_tcfp_mtu (act); - entry->police.index = act->tcfa_index; }else if (is_tcf_ct (act)) { entry->id =FLOW_ACTION_CT ; entry->ct.action =tcf_ct_action (act);
@@ -3697,7 +3697,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->priority =tcf_skbedit_priority (act); }else if (is_tcf_gate (act)) { entry->id =FLOW_ACTION_GATE ; - entry->gate.index =tcf_gate_index (act); entry->gate.prio =tcf_gate_prio (act); entry->gate.basetime =tcf_gate_basetime (act); entry->gate.cycletime =tcf_gate_cycletime (act);
Signature · 1 line
2.20.1
PATCH v5 4/12 flow_offload: return EOPNOTSUPP for the unsupported mpls action type
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
We need to return EOPNOTSUPP for the unsupported mpls action type when setup the flow action.
In the original implement, we will return 0 for the unsupported mpls action type, actually we do not setup it and the following actions to the flow action entry.
--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_api.c +1 -0
@@ -3687,6 +3687,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->mpls_mangle.ttl =tcf_mpls_ttl (act);break ;default : + err = -EOPNOTSUPP ; goto err_out_locked; } }else if (is_tcf_skbedit_ptype (act)) {
Signature · 1 line
2.20.1
PATCH v5 5/12 flow_offload: add ops to tc_action_ops for flow action setup
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Add a new ops to tc_action_ops for flow action setup.
Refactor function tc_setup_flow_action to use this new ops.
We make this change to facilitate to add standalone action module.
We will also use this ops to offload action independent of filter in following patch.
--- include/net/act_api.h | 12 ++ net/sched/act_csum.c | 17 +++ net/sched/act_ct.c | 19 ++++ net/sched/act_gact.c | 27 +++++ net/sched/act_gate.c | 47 ++++++++ net/sched/act_mirred.c | 39 +++++++ net/sched/act_mpls.c | 38 +++++++ net/sched/act_pedit.c | 34 ++++++ net/sched/act_police.c | 23 ++++ net/sched/act_sample.c | 28 +++++ net/sched/act_skbedit.c | 27 +++++ net/sched/act_tunnel_key.c | 47 ++++++++ net/sched/act_vlan.c | 34 ++++++ net/sched/cls_api.c | 222 +++---------------------------------- 14 files changed, 406 insertions(+), 208 deletions(-)
include/net/act_api.h +12 -0
@@ -88,6 +88,16 @@ static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm) dtm->expires =jiffies_to_clock_t (stm->expires); } +static inline enum flow_action_hw_stats tc_act_hw_stats (u8 hw_stats) +{ +if (WARN_ON_ONCE (hw_stats >TCA_ACT_HW_STATS_ANY )) +return FLOW_ACTION_HW_STATS_DONT_CARE ; +else if (!hw_stats) +return FLOW_ACTION_HW_STATS_DISABLED ; + +return hw_stats; +} +#ifdef CONFIG_NET_CLS_ACT #define ACT_P_CREATED 1
@@ -121,6 +131,8 @@ struct tc_action_ops {struct psample_group * (*get_psample_group)(const struct tc_action *a,tc_action_priv_destructor *destructor); +int (*flow_act_setup)(struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind); };struct tc_action_net {
net/sched/act_csum.c +17 -0
@@ -695,6 +695,22 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act)return nla_total_size (sizeof (struct tc_csum )); } +static int tcf_csum_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + + entry->id =FLOW_ACTION_CSUM ; + entry->csum_flags =tcf_csum_update_flags (act); + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_csum_ops = { .kind ="csum" , .id =TCA_ID_CSUM ,
@@ -706,6 +722,7 @@ static struct tc_action_ops act_csum_ops = { .walk = tcf_csum_walker, .lookup = tcf_csum_search, .get_fill_size = tcf_csum_get_fill_size, + .flow_act_setup = tcf_csum_flow_act_setup, .size = sizeof(struct tcf_csum), };
net/sched/act_ct.c +19 -0
@@ -1493,6 +1493,24 @@ static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets, c->tcf_tm.lastuse =max_t (u64, c->tcf_tm.lastuse, lastuse); } +static int tcf_ct_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + + entry->id =FLOW_ACTION_CT ; + entry->ct.action =tcf_ct_action (act); + entry->ct.zone =tcf_ct_zone (act); + entry->ct.flow_table =tcf_ct_ft (act); + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_ct_ops = { .kind ="ct" , .id =TCA_ID_CT ,
@@ -1504,6 +1522,7 @@ static struct tc_action_ops act_ct_ops = { .walk = tcf_ct_walker, .lookup = tcf_ct_search, .stats_update = tcf_stats_update, + .flow_act_setup = tcf_ct_flow_act_setup, .size = sizeof(struct tcf_ct), };
net/sched/act_gact.c +27 -0
@@ -252,6 +252,32 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act)return sz; } +static int tcf_gact_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + +if (is_tcf_gact_ok (act)) { + entry->id =FLOW_ACTION_ACCEPT ; + }else if (is_tcf_gact_shot (act)) { + entry->id =FLOW_ACTION_DROP ; + }else if (is_tcf_gact_trap (act)) { + entry->id =FLOW_ACTION_TRAP ; + }else if (is_tcf_gact_goto_chain (act)) { + entry->id =FLOW_ACTION_GOTO ; + entry->chain_index =tcf_gact_goto_chain_index (act); + }else { +return -EOPNOTSUPP ; + } + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_gact_ops = { .kind ="gact" , .id =TCA_ID_GACT ,
@@ -263,6 +289,7 @@ static struct tc_action_ops act_gact_ops = { .walk = tcf_gact_walker, .lookup = tcf_gact_search, .get_fill_size = tcf_gact_get_fill_size, + .flow_act_setup = tcf_gact_flow_act_setup, .size = sizeof(struct tcf_gact), };
net/sched/act_gate.c +47 -0
59 lines not on this page · raw message
net/sched/act_mirred.c +39 -0
@@ -448,6 +448,44 @@ static size_t tcf_mirred_get_fill_size(const struct tc_action *act)return nla_total_size (sizeof (struct tc_mirred )); } +static void tcf_flow_mirred_get_dev (struct flow_action_entry *entry, +const struct tc_action *act) +{ + entry->dev = act->ops->get_dev (act, &entry->destructor); +if (!entry->dev) +return ; + entry->destructor_priv = entry->dev; +} + +static int tcf_mirred_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + +if (is_tcf_mirred_egress_redirect (act)) { + entry->id =FLOW_ACTION_REDIRECT ; +tcf_flow_mirred_get_dev (entry, act); + }else if (is_tcf_mirred_egress_mirror (act)) { + entry->id =FLOW_ACTION_MIRRED ; +tcf_flow_mirred_get_dev (entry, act); + }else if (is_tcf_mirred_ingress_redirect (act)) { + entry->id =FLOW_ACTION_REDIRECT_INGRESS ; +tcf_flow_mirred_get_dev (entry, act); + }else if (is_tcf_mirred_ingress_mirror (act)) { + entry->id =FLOW_ACTION_MIRRED_INGRESS ; +tcf_flow_mirred_get_dev (entry, act); + }else { +return -EOPNOTSUPP ; + } + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_mirred_ops = { .kind ="mirred" , .id =TCA_ID_MIRRED ,
@@ -460,6 +498,7 @@ static struct tc_action_ops act_mirred_ops = { .walk = tcf_mirred_walker, .lookup = tcf_mirred_search, .get_fill_size = tcf_mirred_get_fill_size, + .flow_act_setup = tcf_mirred_flow_act_setup, .size = sizeof(struct tcf_mirred), .get_dev = tcf_mirred_get_dev, };
net/sched/act_mpls.c +38 -0
@@ -384,6 +384,43 @@ static int tcf_mpls_search(struct net *net, struct tc_action **a, u32 index)return tcf_idr_search (tn, a, index); } +static int tcf_mpls_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + +switch (tcf_mpls_action (act)) { +case TCA_MPLS_ACT_PUSH : + entry->id =FLOW_ACTION_MPLS_PUSH ; + entry->mpls_push.proto =tcf_mpls_proto (act); + entry->mpls_push.label =tcf_mpls_label (act); + entry->mpls_push.tc =tcf_mpls_tc (act); + entry->mpls_push.bos =tcf_mpls_bos (act); + entry->mpls_push.ttl =tcf_mpls_ttl (act); +break ; +case TCA_MPLS_ACT_POP : + entry->id =FLOW_ACTION_MPLS_POP ; + entry->mpls_pop.proto =tcf_mpls_proto (act); +break ; +case TCA_MPLS_ACT_MODIFY : + entry->id =FLOW_ACTION_MPLS_MANGLE ; + entry->mpls_mangle.label =tcf_mpls_label (act); + entry->mpls_mangle.tc =tcf_mpls_tc (act); + entry->mpls_mangle.bos =tcf_mpls_bos (act); + entry->mpls_mangle.ttl =tcf_mpls_ttl (act); +break ; +default : +return -EOPNOTSUPP ; + } + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_mpls_ops = { .kind ="mpls" , .id =TCA_ID_MPLS ,
@@ -394,6 +431,7 @@ static struct tc_action_ops act_mpls_ops = { .cleanup = tcf_mpls_cleanup, .walk = tcf_mpls_walker, .lookup = tcf_mpls_search, + .flow_act_setup = tcf_mpls_flow_act_setup, .size = sizeof(struct tcf_mpls), };
net/sched/act_pedit.c +34 -0
@@ -487,6 +487,39 @@ static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index)return tcf_idr_search (tn, a, index); } +static int tcf_pedit_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; +int k; + +for (k =0 ; k <tcf_pedit_nkeys (act); k++) { +switch (tcf_pedit_cmd (act, k)) { +case TCA_PEDIT_KEY_EX_CMD_SET : + entry->id =FLOW_ACTION_MANGLE ; +break ; +case TCA_PEDIT_KEY_EX_CMD_ADD : + entry->id =FLOW_ACTION_ADD ; +break ; +default : +return -EOPNOTSUPP ; + } + entry->mangle.htype =tcf_pedit_htype (act, k); + entry->mangle.mask =tcf_pedit_mask (act, k); + entry->mangle.val =tcf_pedit_val (act, k); + entry->mangle.offset =tcf_pedit_offset (act, k); + entry->hw_stats =tc_act_hw_stats (act->hw_stats); + entry++; + } + *index_inc = k; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_pedit_ops = { .kind ="pedit" , .id =TCA_ID_PEDIT ,
@@ -498,6 +531,7 @@ static struct tc_action_ops act_pedit_ops = { .init = tcf_pedit_init, .walk = tcf_pedit_walker, .lookup = tcf_pedit_search, + .flow_act_setup = tcf_pedit_flow_act_setup, .size = sizeof(struct tcf_pedit), };
net/sched/act_police.c +23 -0
@@ -405,6 +405,28 @@ static int tcf_police_search(struct net *net, struct tc_action **a, u32 index)return tcf_idr_search (tn, a, index); } +static int tcf_police_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + + entry->id =FLOW_ACTION_POLICE ; + entry->police.burst =tcf_police_burst (act); + entry->police.rate_bytes_ps = +tcf_police_rate_bytes_ps (act); + entry->police.burst_pkt =tcf_police_burst_pkt (act); + entry->police.rate_pkt_ps = +tcf_police_rate_pkt_ps (act); + entry->police.mtu =tcf_police_tcfp_mtu (act); + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +MODULE_AUTHOR ("Alexey Kuznetsov" );MODULE_DESCRIPTION ("Policing actions" );MODULE_LICENSE ("GPL" );
@@ -420,6 +442,7 @@ static struct tc_action_ops act_police_ops = { .walk = tcf_police_walker, .lookup = tcf_police_search, .cleanup = tcf_police_cleanup, + .flow_act_setup = tcf_police_flow_act_setup, .size = sizeof(struct tcf_police), };
net/sched/act_sample.c +28 -0
@@ -282,6 +282,33 @@ tcf_sample_get_group(const struct tc_action *a,return group; } +static void tcf_flow_sample_get_group (struct flow_action_entry *entry, +const struct tc_action *act) +{ + entry->sample.psample_group = + act->ops->get_psample_group (act, &entry->destructor); + entry->destructor_priv = entry->sample.psample_group; +} + +static int tcf_sample_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + + entry->id =FLOW_ACTION_SAMPLE ; + entry->sample.trunc_size =tcf_sample_trunc_size (act); + entry->sample.truncate =tcf_sample_truncate (act); + entry->sample.rate =tcf_sample_rate (act); +tcf_flow_sample_get_group (entry, act); + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_sample_ops = { .kind ="sample" , .id =TCA_ID_SAMPLE ,
@@ -294,6 +321,7 @@ static struct tc_action_ops act_sample_ops = { .walk = tcf_sample_walker, .lookup = tcf_sample_search, .get_psample_group = tcf_sample_get_group, + .flow_act_setup = tcf_sample_flow_act_setup, .size = sizeof(struct tcf_sample), };
net/sched/act_skbedit.c +27 -0
@@ -327,6 +327,32 @@ static size_t tcf_skbedit_get_fill_size(const struct tc_action *act) +nla_total_size_64bit (sizeof (u64));/* TCA_SKBEDIT_FLAGS */ } +static int tcf_skbedit_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + +if (is_tcf_skbedit_mark (act)) { + entry->id =FLOW_ACTION_MARK ; + entry->mark =tcf_skbedit_mark (act); + }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 { +return -EOPNOTSUPP ; + } + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_skbedit_ops = { .kind ="skbedit" , .id =TCA_ID_SKBEDIT ,
@@ -339,6 +365,7 @@ static struct tc_action_ops act_skbedit_ops = { .walk = tcf_skbedit_walker, .get_fill_size = tcf_skbedit_get_fill_size, .lookup = tcf_skbedit_search, + .flow_act_setup = tcf_skbedit_flow_act_setup, .size = sizeof(struct tcf_skbedit), };
net/sched/act_tunnel_key.c +47 -0
59 lines not on this page · raw message
net/sched/act_vlan.c +34 -0
@@ -368,6 +368,39 @@ static size_t tcf_vlan_get_fill_size(const struct tc_action *act) +nla_total_size (sizeof (u8));/* TCA_VLAN_PUSH_VLAN_PRIORITY */ } +static int tcf_vlan_flow_act_setup (struct tc_action *act,void *entry_data, +u32 *index_inc,bool bind) +{ +if (bind) { +struct flow_action_entry *entry = entry_data; + +switch (tcf_vlan_action (act)) { +case TCA_VLAN_ACT_PUSH : + entry->id =FLOW_ACTION_VLAN_PUSH ; + entry->vlan.vid =tcf_vlan_push_vid (act); + entry->vlan.proto =tcf_vlan_push_proto (act); + entry->vlan.prio =tcf_vlan_push_prio (act); +break ; +case TCA_VLAN_ACT_POP : + entry->id =FLOW_ACTION_VLAN_POP ; +break ; +case TCA_VLAN_ACT_MODIFY : + entry->id =FLOW_ACTION_VLAN_MANGLE ; + entry->vlan.vid =tcf_vlan_push_vid (act); + entry->vlan.proto =tcf_vlan_push_proto (act); + entry->vlan.prio =tcf_vlan_push_prio (act); +break ; +default : +return -EOPNOTSUPP ; + } + *index_inc =1 ; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +static struct tc_action_ops act_vlan_ops = { .kind ="vlan" , .id =TCA_ID_VLAN ,
@@ -380,6 +413,7 @@ static struct tc_action_ops act_vlan_ops = { .stats_update = tcf_vlan_stats_update, .get_fill_size = tcf_vlan_get_fill_size, .lookup = tcf_vlan_search, + .flow_act_setup = tcf_vlan_flow_act_setup, .size = sizeof(struct tcf_vlan), };
net/sched/cls_api.c +14 -208
246 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v5 6/12 flow_offload: allow user to offload tc action to net device
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Use flow_indr_dev_register/flow_indr_dev_setup_offload to offload tc action.
We need to call tc_cleanup_flow_action to clean up tc action entry since in tc_setup_action, some actions may hold dev refcnt, especially the mirror action.
--- include/linux/netdevice.h | 1 + include/net/flow_offload.h | 17 +++++++ include/net/pkt_cls.h | 6 +++ net/core/flow_offload.c | 42 +++++++++++++---- net/sched/act_api.c | 92 ++++++++++++++++++++++++++++++++++++++ net/sched/act_csum.c | 4 +- net/sched/act_ct.c | 4 +- net/sched/act_gact.c | 13 +++++- net/sched/act_gate.c | 4 +- net/sched/act_mirred.c | 13 +++++- net/sched/act_mpls.c | 16 ++++++- net/sched/act_police.c | 4 +- net/sched/act_sample.c | 4 +- net/sched/act_skbedit.c | 11 ++++- net/sched/act_tunnel_key.c | 9 +++- net/sched/act_vlan.c | 16 ++++++- net/sched/cls_api.c | 21 +++++++-- 17 files changed, 254 insertions(+), 23 deletions(-)
include/linux/netdevice.h +1 -0
@@ -916,6 +916,7 @@ enum tc_setup_type {TC_SETUP_QDISC_TBF ,TC_SETUP_QDISC_FIFO ,TC_SETUP_QDISC_HTB , + TC_SETUP_ACT, };/* These structures hold the attributes of bpf state that are being passed
include/net/flow_offload.h +17 -0
@@ -551,6 +551,23 @@ struct flow_cls_offload {u32 classid; }; +enum flow_act_command { +FLOW_ACT_REPLACE , +FLOW_ACT_DESTROY , +FLOW_ACT_STATS , +}; + +struct flow_offload_action { +struct netlink_ext_ack *extack;/* NULL in FLOW_ACT_STATS process*/ +enum flow_act_command command; +enum flow_action_id id; +u32 index; +struct flow_stats stats; +struct flow_action action; +}; + +struct flow_offload_action *flow_action_alloc (unsigned int num_actions); +static inline struct flow_rule *flow_cls_offload_flow_rule (struct flow_cls_offload *flow_cmd) {
include/net/pkt_cls.h +6 -0
@@ -258,6 +258,9 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts) for (; 0; (void)(i), (void)(a), (void)(exts))#endif +#define tcf_act_for_each_action (i, a, actions) \ + for (i = 0; i < TCA_ACT_MAX_PRIO && ((a) = actions[i]); i++) + static inline void tcf_exts_stats_update(const struct tcf_exts *exts, u64 bytes, u64 packets, u64 drops, u64 lastuse,
@@ -534,6 +537,9 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)int tc_setup_flow_action (struct flow_action *flow_action,const struct tcf_exts *exts); + +int tc_setup_action (struct flow_action *flow_action, +struct tc_action *actions[]);void tc_cleanup_flow_action (struct flow_action *flow_action); int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
net/core/flow_offload.c +34 -8
59 lines not on this page · raw message
net/sched/act_api.c +92 -0
120 lines not on this page · raw message
net/sched/act_csum.c +3 -1
@@ -705,7 +705,9 @@ static int tcf_csum_flow_act_setup(struct tc_action *act, void *entry_data, entry->csum_flags =tcf_csum_update_flags (act); *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + + fl_action->id =FLOW_ACTION_CSUM ; }return 0 ;
net/sched/act_ct.c +3 -1
@@ -1505,7 +1505,9 @@ static int tcf_ct_flow_act_setup(struct tc_action *act, void *entry_data, entry->ct.flow_table =tcf_ct_ft (act); *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + + fl_action->id =FLOW_ACTION_CT ; }return 0 ;
net/sched/act_gact.c +12 -1
@@ -272,7 +272,18 @@ static int tcf_gact_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + +if (is_tcf_gact_ok (act)) + fl_action->id =FLOW_ACTION_ACCEPT ; +else if (is_tcf_gact_shot (act)) + fl_action->id =FLOW_ACTION_DROP ; +else if (is_tcf_gact_trap (act)) + fl_action->id =FLOW_ACTION_TRAP ; +else if (is_tcf_gact_goto_chain (act)) + fl_action->id =FLOW_ACTION_GOTO ; +else +return -EOPNOTSUPP ; }return 0 ;
net/sched/act_gate.c +3 -1
@@ -637,7 +637,9 @@ static int tcf_gate_flow_act_setup(struct tc_action *act, void *entry_data,return err; *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + + fl_action->id =FLOW_ACTION_GATE ; }return 0 ;
net/sched/act_mirred.c +12 -1
@@ -480,7 +480,18 @@ static int tcf_mirred_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + +if (is_tcf_mirred_egress_redirect (act)) + fl_action->id =FLOW_ACTION_REDIRECT ; +else if (is_tcf_mirred_egress_mirror (act)) + fl_action->id =FLOW_ACTION_MIRRED ; +else if (is_tcf_mirred_ingress_redirect (act)) + fl_action->id =FLOW_ACTION_REDIRECT_INGRESS ; +else if (is_tcf_mirred_ingress_mirror (act)) + fl_action->id =FLOW_ACTION_MIRRED_INGRESS ; +else +return -EOPNOTSUPP ; }return 0 ;
net/sched/act_mpls.c +15 -1
@@ -415,7 +415,21 @@ static int tcf_mpls_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + +switch (tcf_mpls_action (act)) { +case TCA_MPLS_ACT_PUSH : + fl_action->id =FLOW_ACTION_MPLS_PUSH ; +break ; +case TCA_MPLS_ACT_POP : + fl_action->id =FLOW_ACTION_MPLS_POP ; +break ; +case TCA_MPLS_ACT_MODIFY : + fl_action->id =FLOW_ACTION_MPLS_MANGLE ; +break ; +default : +return -EOPNOTSUPP ; + } }return 0 ;
net/sched/act_police.c +3 -1
@@ -421,7 +421,9 @@ static int tcf_police_flow_act_setup(struct tc_action *act, void *entry_data, entry->police.mtu =tcf_police_tcfp_mtu (act); *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + + fl_action->id =FLOW_ACTION_POLICE ; }return 0 ;
net/sched/act_sample.c +3 -1
@@ -303,7 +303,9 @@ static int tcf_sample_flow_act_setup(struct tc_action *act, void *entry_data,tcf_flow_sample_get_group (entry, act); *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + + fl_action->id =FLOW_ACTION_SAMPLE ; }return 0 ;
net/sched/act_skbedit.c +10 -1
@@ -347,7 +347,16 @@ static int tcf_skbedit_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + +if (is_tcf_skbedit_mark (act)) + fl_action->id =FLOW_ACTION_MARK ; +else if (is_tcf_skbedit_ptype (act)) + fl_action->id =FLOW_ACTION_PTYPE ; +else if (is_tcf_skbedit_priority (act)) + fl_action->id =FLOW_ACTION_PRIORITY ; +else +return -EOPNOTSUPP ; }return 0 ;
net/sched/act_tunnel_key.c +8 -1
@@ -827,7 +827,14 @@ static int tcf_tunnel_key_flow_act_setup(struct tc_action *act, } *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + +if (is_tcf_tunnel_set (act)) + fl_action->id =FLOW_ACTION_TUNNEL_ENCAP ; +else if (is_tcf_tunnel_release (act)) + fl_action->id =FLOW_ACTION_TUNNEL_DECAP ; +else +return -EOPNOTSUPP ; }return 0 ;
net/sched/act_vlan.c +15 -1
@@ -395,7 +395,21 @@ static int tcf_vlan_flow_act_setup(struct tc_action *act, void *entry_data, } *index_inc =1 ; }else { -return -EOPNOTSUPP ; +struct flow_offload_action *fl_action = entry_data; + +switch (tcf_vlan_action (act)) { +case TCA_VLAN_ACT_PUSH : + fl_action->id =FLOW_ACTION_VLAN_PUSH ; +break ; +case TCA_VLAN_ACT_POP : + fl_action->id =FLOW_ACTION_VLAN_POP ; +break ; +case TCA_VLAN_ACT_MODIFY : + fl_action->id =FLOW_ACTION_VLAN_MANGLE ; +break ; +default : +return -EOPNOTSUPP ; + } }return 0 ;
net/sched/cls_api.c +17 -4
@@ -3488,8 +3488,8 @@ static int tc_setup_flow_act(struct tc_action *act,#endif } -int tc_setup_flow_action (struct flow_action *flow_action, -const struct tcf_exts *exts) +int tc_setup_action (struct flow_action *flow_action, +struct tc_action *actions[]) {int i, j, index, err =0 ;struct tc_action *act;
@@ -3498,11 +3498,11 @@ int tc_setup_flow_action(struct flow_action *flow_action,BUILD_BUG_ON (TCA_ACT_HW_STATS_IMMEDIATE !=FLOW_ACTION_HW_STATS_IMMEDIATE );BUILD_BUG_ON (TCA_ACT_HW_STATS_DELAYED !=FLOW_ACTION_HW_STATS_DELAYED ); -if (!exts) +if (!actions)return 0 ; j =0 ; -tcf_exts_for_each_action (i, act, exts) { +tcf_act_for_each_action (i, act, actions) {struct flow_action_entry *entry; entry = &flow_action->entries[j];
@@ -3531,6 +3531,19 @@ int tc_setup_flow_action(struct flow_action *flow_action,spin_unlock_bh (&act->tcfa_lock); goto err_out; } + +int tc_setup_flow_action (struct flow_action *flow_action, +const struct tcf_exts *exts) +{ +#ifdef CONFIG_NET_CLS_ACT +if (!exts) +return 0 ; + +return tc_setup_action (flow_action, exts->actions); +#else +return 0 ; +#endif +}EXPORT_SYMBOL (tc_setup_flow_action);unsigned int tcf_exts_num_actions (struct tcf_exts *exts)
Signature · 1 line
2.20.1
PATCH v5 7/12 flow_offload: add skip_hw and skip_sw to control if offload the action
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
We add skip_hw and skip_sw for user to control if offload the action to hardware.
We also add in_hw_count for user to indicate if the action is offloaded to any hardware.
--- include/net/act_api.h | 1 + include/uapi/linux/pkt_cls.h | 9 ++-- net/sched/act_api.c | 83 +++++++++++++++++++++++++++++++++--- 3 files changed, 84 insertions(+), 9 deletions(-)
include/net/act_api.h +1 -0
@@ -44,6 +44,7 @@ struct tc_action {u8 hw_stats;u8 used_hw_stats;bool used_hw_stats_valid; +u32 in_hw_count; };#define tcf_index common.tcfa_index#define tcf_refcnt common.tcfa_refcnt
include/uapi/linux/pkt_cls.h +6 -3
@@ -19,13 +19,16 @@ enum {TCA_ACT_FLAGS ,TCA_ACT_HW_STATS ,TCA_ACT_USED_HW_STATS , +TCA_ACT_IN_HW_COUNT , __TCA_ACT_MAX };/* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */ -#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1/* Don't use percpu allocator for -* actions stats. -*/ +#define TCA_ACT_FLAGS_NO_PERCPU_STATS (1 << 0)/* Don't use percpu allocator for +* actions stats. +*/ +#define TCA_ACT_FLAGS_SKIP_HW (1 << 1)/* don't offload action to HW */ +#define TCA_ACT_FLAGS_SKIP_SW (1 << 2)/* don't use action in SW */ /* tca HW stats type * When user does not pass the attribute, he does not care.
net/sched/act_api.c +77 -6
168 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v5 8/12 flow_offload: add process to update action stats from hardware
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
When collecting stats for actions update them using both hardware and software counters.
Stats update process should not run in context of preempt_disable.
--- include/net/act_api.h | 1 + include/net/pkt_cls.h | 18 ++++++++++-------- net/sched/act_api.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-)
include/net/act_api.h +1 -0
@@ -253,6 +253,7 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, u64 drops, bool hw);int tcf_action_copy_stats (struct sk_buff *,struct tc_action *,int ); +int tcf_action_update_hw_stats (struct tc_action *action);int tcf_action_check_ctrlact (int action,struct tcf_proto *tp,struct tcf_chain **handle,struct netlink_ext_ack *newchain);
include/net/pkt_cls.h +10 -8
@@ -269,18 +269,20 @@ tcf_exts_stats_update(const struct tcf_exts *exts,#ifdef CONFIG_NET_CLS_ACT int i; -preempt_disable (); -for (i =0 ; i < exts->nr_actions; i++) {struct tc_action *a = exts->actions[i]; -tcf_action_stats_update (a, bytes, packets, drops, - lastuse, true); - a->used_hw_stats = used_hw_stats; - a->used_hw_stats_valid = used_hw_stats_valid; - } +/* if stats from hw, just skip */ +if (tcf_action_update_hw_stats (a)) { +preempt_disable (); +tcf_action_stats_update (a, bytes, packets, drops, + lastuse, true); +preempt_enable (); -preempt_enable (); + a->used_hw_stats = used_hw_stats; + a->used_hw_stats_valid = used_hw_stats_valid; + } + }#endif }
net/sched/act_api.c +34 -0
@@ -245,6 +245,37 @@ static int tcf_action_offload_add(struct tc_action *action,return err; } +int tcf_action_update_hw_stats (struct tc_action *action) +{ +struct flow_offload_action fl_act = {}; +int err; + +if (!tc_act_in_hw (action)) +return -EOPNOTSUPP ; + + err =flow_action_init (&fl_act, action,FLOW_ACT_STATS ,NULL ); +if (err) +return err; + + err =tcf_action_offload_cmd (&fl_act,NULL ,NULL ); +if (!err) { +preempt_disable (); +tcf_action_stats_update (action, fl_act.stats.bytes, + fl_act.stats.pkts, + fl_act.stats.drops, + fl_act.stats.lastused, + true); +preempt_enable (); + action->used_hw_stats = fl_act.stats.used_hw_stats; + action->used_hw_stats_valid = true; + }else { +return -EOPNOTSUPP ; + } + +return 0 ; +} +EXPORT_SYMBOL (tcf_action_update_hw_stats); +static int tcf_action_offload_del (struct tc_action *action) {struct flow_offload_action fl_act = {};
@@ -1317,6 +1348,9 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p,if (p ==NULL ) goto errout; +/* update hw stats for this action */ +tcf_action_update_hw_stats (p); +/* compat_mode being true specifies a call that is supposed * to add additional backward compatibility statistic TLVs. */
Signature · 1 line
2.20.1
PATCH v5 9/12 net: sched: save full flags for tc action
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Save full action flags and return user flags when return flags to user space.
Save full action flags to distinguish if the action is created independent from classifier.
We made this change mainly for further patch to reoffload tc actions.
--- net/sched/act_api.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/sched/act_api.c +5 -3
@@ -668,7 +668,7 @@ int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, p->tcfa_tm.install = jiffies; p->tcfa_tm.lastuse = jiffies; p->tcfa_tm.firstuse =0 ; - p->tcfa_flags = flags &TCA_ACT_FLAGS_USER_MASK ; + p->tcfa_flags = flags;if (est) { err = gen_new_estimator(&p->tcfa_bstats, p->cpu_bstats, &p->tcfa_rate_est,
@@ -995,6 +995,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)int err = -EINVAL ;unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest; +u32 flags;if (tcf_action_dump_terse (skb, a, false)) goto nla_put_failure;
@@ -1009,9 +1010,10 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) a->used_hw_stats, TCA_ACT_HW_STATS_ANY)) goto nla_put_failure; -if (a->tcfa_flags && + flags = a->tcfa_flags &TCA_ACT_FLAGS_USER_MASK ; +if (flags &&nla_put_bitfield32 (skb,TCA_ACT_FLAGS , - a->tcfa_flags, a->tcfa_flags)) + flags, flags)) goto nla_put_failure;if (nla_put_u32 (skb,TCA_ACT_IN_HW_COUNT , a->in_hw_count))
Signature · 1 line
2.20.1
PATCH v5 10/12 flow_offload: add reoffload process to update hw_count
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Add reoffload process to update hw_count when driver is inserted or removed.
We will delete the action if it is with skip_sw flag and not offloaded to any hardware in reoffload process.
When reoffloading actions, we still offload the actions that are added independent of filters.
--- include/net/act_api.h | 11 ++ net/core/flow_offload.c | 4 + net/sched/act_api.c | 249 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 248 insertions(+), 16 deletions(-)
include/net/act_api.h +11 -0
@@ -7,6 +7,7 @@*/ #include <linux/refcount.h> +#include <net/flow_offload.h> #include <net/sch_generic.h> #include <net/pkt_sched.h> #include <net/net_namespace.h>
@@ -254,6 +255,8 @@ void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets,int tcf_action_copy_stats (struct sk_buff *,struct tc_action *,int );int tcf_action_update_hw_stats (struct tc_action *action); +int tcf_action_reoffload_cb (flow_indr_block_bind_cb_t *cb, +void *cb_priv,bool add);int tcf_action_check_ctrlact (int action,struct tcf_proto *tp,struct tcf_chain **handle,struct netlink_ext_ack *newchain);
@@ -265,6 +268,14 @@ DECLARE_STATIC_KEY_FALSE(tcf_frag_xmit_count);#endif int tcf_dev_queue_xmit (struct sk_buff *skb,int (*xmit)(struct sk_buff *skb)); + +#else /* !CONFIG_NET_CLS_ACT */ + +static inline int tcf_action_reoffload_cb (flow_indr_block_bind_cb_t *cb, +void *cb_priv,bool add) { +return 0 ; +} +#endif /* CONFIG_NET_CLS_ACT */ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
net/core/flow_offload.c +4 -0
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ #include <linux/kernel.h> #include <linux/slab.h> +#include <net/act_api.h> #include <net/flow_offload.h> #include <linux/rtnetlink.h> #include <linux/mutex.h>
@@ -417,6 +418,8 @@ int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)existing_qdiscs_register (cb, cb_priv);mutex_unlock (&flow_indr_block_lock); +tcf_action_reoffload_cb (cb, cb_priv, true); +return 0 ; }EXPORT_SYMBOL (flow_indr_dev_register);
@@ -469,6 +472,7 @@ void flow_indr_dev_unregister(flow_indr_block_bind_cb_t *cb, void *cb_priv,__flow_block_indr_cleanup (release, cb_priv, &cleanup_list);mutex_unlock (&flow_indr_block_lock); +tcf_action_reoffload_cb (cb, cb_priv, false);flow_block_indr_notify (&cleanup_list);kfree (indr_dev); }
net/sched/act_api.c +233 -16
340 lines not on this page · raw message
Signature · 1 line
2.20.1
Dan Carpenter
build botRe: [PATCH v5 net-next 10/12] flow_offload: add reoffload process to update hw_count
CC: kbuild-all(a)lists.01.org In-Reply-To: <[email protected]> References: <[email protected]> TO: Simon Horman…
CC: kbuild-all(a)lists.01.org
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Simon Horman <[email protected]>
TO: netdev(a)vger.kernel.org
CC: Cong Wang <[email protected]>
CC: Ido Schimmel <[email protected]>
CC: Jamal Hadi Salim <[email protected]>
CC: Jiri Pirko <[email protected]>
CC: Oz Shlomo <[email protected]>
CC: Roi Dayan <[email protected]>
CC: Vlad Buslov <[email protected]>
CC: Baowen Zheng <[email protected]>
CC: Louis Peens <[email protected]>
Hi Simon,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Simon-Horman/allow-user-to-offload-tc-action-to-net-device/20211203-202602 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 43332cf97425a3e5508c827c82201ecc5ddd54e0
:::::: branch date: 4 days ago
:::::: commit date: 4 days ago
config: i386-randconfig-m021-20211203 (https://download.01.org/0day-ci/archive/20211207/202112070927.kCpOi5qD-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
New smatch warnings:net/sched/act_api.c:946 tcf_register_action() error: we previously assumed 'ops->id' could be null (see line 926)
Old smatch warnings:net/sched/act_api.c:1362 tcf_action_init_1() error: uninitialized symbol 'a'. net/sched/act_api.c:1365 tcf_action_init_1() error: potentially dereferencing uninitialized 'a'. net/sched/act_api.c:1367 tcf_action_init_1() error: uninitialized symbol 'a'. net/sched/act_api.c:1611 tcf_action_get_1() error: uninitialized symbol 'a'.
vim +946 net/sched/act_api.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 908
ddf97ccdd7cb7e WANG Cong 2016-02-22 909 int tcf_register_action(struct tc_action_ops *act,
ddf97ccdd7cb7e WANG Cong 2016-02-22 910 struct pernet_operations *ops)
^1da177e4c3f41 Linus Torvalds 2005-04-16 911 {
1f747c26c48bb2 WANG Cong 2013-12-15 912 struct tc_action_ops *a;
ddf97ccdd7cb7e WANG Cong 2016-02-22 913 int ret;
^1da177e4c3f41 Linus Torvalds 2005-04-16 914
ddf97ccdd7cb7e WANG Cong 2016-02-22 915 if (!act->act || !act->dump || !act->init || !act->walk || !act->lookup)
76c82d7a3d24a4 Jamal Hadi Salim 2013-12-04 916 return -EINVAL;
76c82d7a3d24a4 Jamal Hadi Salim 2013-12-04 917
ab102b80cef28c WANG Cong 2016-10-11 918 /* We have to register pernet ops before making the action ops visible,
ab102b80cef28c WANG Cong 2016-10-11 919 * otherwise tcf_action_init_1() could get a partially initialized
ab102b80cef28c WANG Cong 2016-10-11 920 * netns.
ab102b80cef28c WANG Cong 2016-10-11 921 */
ab102b80cef28c WANG Cong 2016-10-11 922 ret = register_pernet_subsys(ops);
ab102b80cef28c WANG Cong 2016-10-11 923 if (ret)
ab102b80cef28c WANG Cong 2016-10-11 924 return ret;
ab102b80cef28c WANG Cong 2016-10-11 925
d99abedd4989e7 Baowen Zheng 2021-12-03 @926 if (ops->id) {
d99abedd4989e7 Baowen Zheng 2021-12-03 927 ret = tcf_pernet_add_id_list(*ops->id);
d99abedd4989e7 Baowen Zheng 2021-12-03 928 if (ret)
d99abedd4989e7 Baowen Zheng 2021-12-03 929 goto err_id;
d99abedd4989e7 Baowen Zheng 2021-12-03 930 }
d99abedd4989e7 Baowen Zheng 2021-12-03 931
^1da177e4c3f41 Linus Torvalds 2005-04-16 932 write_lock(&act_mod_lock);
1f747c26c48bb2 WANG Cong 2013-12-15 933 list_for_each_entry(a, &act_base, head) {
eddd2cf195d6fb Eli Cohen 2019-02-10 934 if (act->id == a->id || (strcmp(act->kind, a->kind) == 0)) {
d99abedd4989e7 Baowen Zheng 2021-12-03 935 ret = -EEXIST;
d99abedd4989e7 Baowen Zheng 2021-12-03 936 goto err_out;
^1da177e4c3f41 Linus Torvalds 2005-04-16 937 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 938 }
1f747c26c48bb2 WANG Cong 2013-12-15 939 list_add_tail(&act->head, &act_base);
^1da177e4c3f41 Linus Torvalds 2005-04-16 940 write_unlock(&act_mod_lock);
ddf97ccdd7cb7e WANG Cong 2016-02-22 941
^1da177e4c3f41 Linus Torvalds 2005-04-16 942 return 0;
d99abedd4989e7 Baowen Zheng 2021-12-03 943
d99abedd4989e7 Baowen Zheng 2021-12-03 944 err_out:
d99abedd4989e7 Baowen Zheng 2021-12-03 945 write_unlock(&act_mod_lock);
d99abedd4989e7 Baowen Zheng 2021-12-03 @946 tcf_pernet_del_id_list(*ops->id);
d99abedd4989e7 Baowen Zheng 2021-12-03 947 err_id:
d99abedd4989e7 Baowen Zheng 2021-12-03 948 unregister_pernet_subsys(ops);
d99abedd4989e7 Baowen Zheng 2021-12-03 949 return ret;
^1da177e4c3f41 Linus Torvalds 2005-04-16 950 }
62e3ba1b558e5f Patrick McHardy 2008-01-22 951 EXPORT_SYMBOL(tcf_register_action);
^1da177e4c3f41 Linus Torvalds 2005-04-16 952 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v5 11/12 flow_offload: validate flags of filter and actions
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Add process to validate flags of filter and actions when adding a tc filter.
We need to prevent adding filter with flags conflicts with its actions.
--- include/net/act_api.h | 2 +- include/net/pkt_cls.h | 3 +++ net/sched/act_api.c | 18 +++++++++++++++--- net/sched/cls_api.c | 18 ++++++++++++++---- net/sched/cls_flower.c | 9 ++++++--- net/sched/cls_matchall.c | 9 +++++---- net/sched/cls_u32.c | 12 +++++++----- 7 files changed, 51 insertions(+), 20 deletions(-)
include/net/act_api.h +1 -1
@@ -203,7 +203,7 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,int tcf_action_init (struct net *net,struct tcf_proto *tp,struct nlattr *nla,struct nlattr *est,struct tc_action *actions[],int init_res[],size_t *attr_size, -u32 flags,struct netlink_ext_ack *extack); +u32 flags,u32 fl_flags,struct netlink_ext_ack *extack);struct tc_action_ops *tc_action_load_ops (struct nlattr *nla,bool police,bool rtnl_held,struct netlink_ext_ack *extack);
include/net/pkt_cls.h +3 -0
@@ -326,6 +326,9 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, struct nlattr *rate_tlv, struct tcf_exts *exts, u32 flags, struct netlink_ext_ack *extack); +int tcf_exts_validate_ex (struct net *net,struct tcf_proto *tp,struct nlattr **tb, +struct nlattr *rate_tlv,struct tcf_exts *exts, +u32 flags,u32 fl_flags,struct netlink_ext_ack *extack);void tcf_exts_destroy (struct tcf_exts *exts);void tcf_exts_change (struct tcf_exts *dst,struct tcf_exts *src);int tcf_exts_dump (struct sk_buff *skb,struct tcf_exts *exts);
net/sched/act_api.c +15 -3
@@ -1383,7 +1383,8 @@ static bool tc_act_bind(u32 flags)int tcf_action_init (struct net *net,struct tcf_proto *tp,struct nlattr *nla,struct nlattr *est,struct tc_action *actions[], -int init_res[],size_t *attr_size,u32 flags, +int init_res[],size_t *attr_size, +u32 flags,u32 fl_flags,struct netlink_ext_ack *extack) {struct tc_action_ops *ops[TCA_ACT_MAX_PRIO ] = {};
@@ -1421,7 +1422,18 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, sz +=tcf_action_fill_size (act);/* Start from index 0 */ actions[i -1 ] = act; -if (!tc_act_bind (flags)) { +if (tc_act_bind (flags)) { +bool skip_sw =tc_skip_sw (fl_flags); +bool skip_hw =tc_skip_hw (fl_flags); + +if (tc_act_bind (act->tcfa_flags)) +continue ; +if (skip_sw !=tc_act_skip_sw (act->tcfa_flags) || + skip_hw !=tc_act_skip_hw (act->tcfa_flags)) { + err = -EINVAL ; + goto err; + } + }else { err =tcf_action_offload_add (act, extack);if (tc_act_skip_sw (act->tcfa_flags) && err) goto err;
@@ -1924,7 +1936,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,for (loop =0 ; loop <10 ; loop++) { ret =tcf_action_init (net,NULL , nla,NULL , actions, init_res, - &attr_size, flags, extack); + &attr_size, flags,0 , extack);if (ret != -EAGAIN )break ; }
net/sched/cls_api.c +14 -4
@@ -3025,9 +3025,9 @@ void tcf_exts_destroy(struct tcf_exts *exts) }EXPORT_SYMBOL (tcf_exts_destroy); -int tcf_exts_validate (struct net *net,struct tcf_proto *tp,struct nlattr **tb, -struct nlattr *rate_tlv,struct tcf_exts *exts, -u32 flags,struct netlink_ext_ack *extack) +int tcf_exts_validate_ex (struct net *net,struct tcf_proto *tp,struct nlattr **tb, +struct nlattr *rate_tlv,struct tcf_exts *exts, +u32 flags,u32 fl_flags,struct netlink_ext_ack *extack) {#ifdef CONFIG_NET_CLS_ACT {
@@ -3061,7 +3061,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, flags |=TCA_ACT_FLAGS_BIND ; err =tcf_action_init (net, tp, tb[exts->action], rate_tlv, exts->actions, init_res, - &attr_size, flags, extack); + &attr_size, flags, fl_flags, + extack);if (err <0 )return err; exts->nr_actions = err;
@@ -3077,6 +3078,15 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,return 0 ; } +EXPORT_SYMBOL (tcf_exts_validate_ex); + +int tcf_exts_validate (struct net *net,struct tcf_proto *tp,struct nlattr **tb, +struct nlattr *rate_tlv,struct tcf_exts *exts, +u32 flags,struct netlink_ext_ack *extack) +{ +return tcf_exts_validate_ex (net, tp, tb, rate_tlv, exts, + flags,0 , extack); +}EXPORT_SYMBOL (tcf_exts_validate);void tcf_exts_change (struct tcf_exts *dst,struct tcf_exts *src)
net/sched/cls_flower.c +6 -3
@@ -1917,12 +1917,14 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp, struct cls_fl_filter *f, struct fl_flow_mask *mask, unsigned long base, struct nlattr **tb, struct nlattr *est, - struct fl_flow_tmplt *tmplt, u32 flags, + struct fl_flow_tmplt *tmplt, + u32 flags, u32 fl_flags, struct netlink_ext_ack *extack) { int err; - err =tcf_exts_validate (net, tp, tb, est, &f->exts, flags, extack); + err =tcf_exts_validate_ex (net, tp, tb, est, &f->exts, flags, + fl_flags, extack);if (err <0 )return err;
@@ -2036,7 +2038,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, } err =fl_set_parms (net, tp, fnew, mask, base, tb, tca[TCA_RATE ], - tp->chain->tmplt_priv, flags, extack); + tp->chain->tmplt_priv, flags, fnew->flags, + extack);if (err) goto errout;
net/sched/cls_matchall.c +5 -4
@@ -163,12 +163,13 @@ static const struct nla_policy mall_policy[TCA_MATCHALL_MAX + 1] = {static int mall_set_parms (struct net *net,struct tcf_proto *tp,struct cls_mall_head *head,unsigned long base,struct nlattr **tb, -struct nlattr *est,u32 flags, +struct nlattr *est,u32 flags,u32 fl_flags,struct netlink_ext_ack *extack) {int err; - err =tcf_exts_validate (net, tp, tb, est, &head->exts, flags, extack); + err =tcf_exts_validate_ex (net, tp, tb, est, &head->exts, flags, + fl_flags, extack);if (err <0 )return err;
@@ -226,8 +227,8 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, goto err_alloc_percpu; } - err =mall_set_parms (net, tp, new, base, tb, tca[TCA_RATE ], flags, - extack); + err =mall_set_parms (net, tp, new, base, tb, tca[TCA_RATE ], + flags, new->flags, extack);if (err) goto err_set_parms;
net/sched/cls_u32.c +7 -5
@@ -709,12 +709,13 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = {static int u32_set_parms (struct net *net,struct tcf_proto *tp,unsigned long base,struct tc_u_knode *n,struct nlattr **tb, -struct nlattr *est,u32 flags, +struct nlattr *est,u32 flags,u32 fl_flags,struct netlink_ext_ack *extack) {int err; - err =tcf_exts_validate (net, tp, tb, est, &n->exts, flags, extack); + err =tcf_exts_validate_ex (net, tp, tb, est, &n->exts, flags, + fl_flags, extack);if (err <0 )return err;
@@ -895,7 +896,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,return -ENOMEM ; err =u32_set_parms (net, tp, base, new, tb, - tca[TCA_RATE ], flags, extack); + tca[TCA_RATE ], flags, new->flags, + extack);if (err) {u32_destroy_key (new, false);
@@ -1060,8 +1062,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, }#endif - err =u32_set_parms (net, tp, base, n, tb, tca[TCA_RATE ], flags, - extack); + err =u32_set_parms (net, tp, base, n, tb, tca[TCA_RATE ], + flags, n->flags, extack);if (err ==0 ) {struct tc_u_knode __rcu **ins;struct tc_u_knode *pins;
Signature · 1 line
2.20.1
PATCH v5 12/12 selftests: tc-testing: add action offload selftest for action and filter
In reply to Simon HormanFrom: Baowen Zheng <[email protected]>
Add selftest cases in action police with skip_hw. Add selftest case to validate flags of filter and action. These tests depend on corresponding iproute2 command support.
--- .../tc-testing/tc-tests/actions/police.json | 24 +++++++++++++++++++ .../tc-testing/tc-tests/filters/matchall.json | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+)
tools/testing/selftests/tc-testing/tc-tests/actions/police.json +24 -0
@@ -812,5 +812,29 @@ "teardown": [ "$TC actions flush action police" ] + }, + { + "id": "7d64", + "name": "Add police action with skip_hw option", + "category": [ + "actions", + "police" + ], + "setup": [ + [ + "$TC actions flush action police", + 0, + 1, + 255 + ] + ], + "cmdUnderTest": "$TC actions add action police rate 1kbit burst 10k index 100 skip_hw", + "expExitCode": "0", + "verifyCmd": "$TC actions ls action police | grep skip_hw", + "matchPattern": "skip_hw", + "matchCount": "1", + "teardown": [ + "$TC actions flush action police" + ] } ]
tools/testing/selftests/tc-testing/tc-tests/filters/matchall.json +24 -0
@@ -387,5 +387,29 @@ "$TC qdisc del dev $DUMMY ingress", "$IP link del dev $DUMMY type dummy" ] + }, + { + "id": "3329", + "name": "Validate flags of the matchall filter and police action with skip_sw", + "category": [ + "filter", + "matchall" + ], + "setup": [ + "$IP link add dev $DUMMY type dummy || /bin/true", + "$TC qdisc add dev $DUMMY ingress", + "$TC actions flush action police", + "$TC actions add action police rate 1mbit burst 100k index 199 skip_hw" + ], + "cmdUnderTest": "$TC filter add dev $DUMMY parent ffff: handle 0x1 prio 1 protocol ipv4 matchall skip_sw action police index 199", + "expExitCode": "2", + "verifyCmd": "$TC filter get dev $DUMMY parent ffff: handle 1 prio 1 protocol ipv4 matchall", + "matchPattern": "^filter parent ffff: protocol ip pref 1 matchall.*handle 0x1.*", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY ingress", + "$IP link del dev $DUMMY type dummy", + "$TC actions del action police index 199" + ] } ]
Signature · 1 line
2.20.1