Commit 5a995900 authored by Baowen Zheng's avatar Baowen Zheng Committed by David S. Miller

flow_offload: add index to flow_action_entry structure

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.
Signed-off-by: default avatarBaowen Zheng <baowen.zheng@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 144d4c9e
...@@ -1745,7 +1745,7 @@ static void vsc9959_psfp_sfi_table_del(struct ocelot *ocelot, u32 index) ...@@ -1745,7 +1745,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, static void vsc9959_psfp_parse_gate(const struct flow_action_entry *entry,
struct felix_stream_gate *sgi) struct felix_stream_gate *sgi)
{ {
sgi->index = entry->gate.index; sgi->index = entry->hw_index;
sgi->ipv_valid = (entry->gate.prio < 0) ? 0 : 1; sgi->ipv_valid = (entry->gate.prio < 0) ? 0 : 1;
sgi->init_ipv = (sgi->ipv_valid) ? entry->gate.prio : 0; sgi->init_ipv = (sgi->ipv_valid) ? entry->gate.prio : 0;
sgi->basetime = entry->gate.basetime; sgi->basetime = entry->gate.basetime;
...@@ -1947,7 +1947,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port, ...@@ -1947,7 +1947,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
kfree(sgi); kfree(sgi);
break; break;
case FLOW_ACTION_POLICE: case FLOW_ACTION_POLICE:
index = a->police.index + VSC9959_PSFP_POLICER_BASE; index = a->hw_index + VSC9959_PSFP_POLICER_BASE;
if (index > VSC9959_PSFP_POLICER_MAX) { if (index > VSC9959_PSFP_POLICER_MAX) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
......
...@@ -379,7 +379,7 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port, ...@@ -379,7 +379,7 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
vl_rule = true; vl_rule = true;
rc = sja1105_vl_gate(priv, port, extack, cookie, rc = sja1105_vl_gate(priv, port, extack, cookie,
&key, act->gate.index, &key, act->hw_index,
act->gate.prio, act->gate.prio,
act->gate.basetime, act->gate.basetime,
act->gate.cycletime, act->gate.cycletime,
......
...@@ -1182,7 +1182,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, ...@@ -1182,7 +1182,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
} }
/* parsing gate action */ /* parsing gate action */
if (entryg->gate.index >= priv->psfp_cap.max_psfp_gate) { if (entryg->hw_index >= priv->psfp_cap.max_psfp_gate) {
NL_SET_ERR_MSG_MOD(extack, "No Stream Gate resource!"); NL_SET_ERR_MSG_MOD(extack, "No Stream Gate resource!");
err = -ENOSPC; err = -ENOSPC;
goto free_filter; goto free_filter;
...@@ -1202,7 +1202,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, ...@@ -1202,7 +1202,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
} }
refcount_set(&sgi->refcount, 1); refcount_set(&sgi->refcount, 1);
sgi->index = entryg->gate.index; sgi->index = entryg->hw_index;
sgi->init_ipv = entryg->gate.prio; sgi->init_ipv = entryg->gate.prio;
sgi->basetime = entryg->gate.basetime; sgi->basetime = entryg->gate.basetime;
sgi->cycletime = entryg->gate.cycletime; sgi->cycletime = entryg->gate.cycletime;
...@@ -1244,7 +1244,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv, ...@@ -1244,7 +1244,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
refcount_set(&fmi->refcount, 1); refcount_set(&fmi->refcount, 1);
fmi->cir = entryp->police.rate_bytes_ps; fmi->cir = entryp->police.rate_bytes_ps;
fmi->cbs = entryp->police.burst; fmi->cbs = entryp->police.burst;
fmi->index = entryp->police.index; fmi->index = entryp->hw_index;
filter->flags |= ENETC_PSFP_FLAGS_FMI; filter->flags |= ENETC_PSFP_FLAGS_FMI;
filter->fmi_index = fmi->index; filter->fmi_index = fmi->index;
sfi->meter_id = fmi->index; sfi->meter_id = fmi->index;
......
...@@ -203,7 +203,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, ...@@ -203,7 +203,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
*/ */
burst = roundup_pow_of_two(act->police.burst); burst = roundup_pow_of_two(act->police.burst);
err = mlxsw_sp_acl_rulei_act_police(mlxsw_sp, rulei, err = mlxsw_sp_acl_rulei_act_police(mlxsw_sp, rulei,
act->police.index, act->hw_index,
act->police.rate_bytes_ps, act->police.rate_bytes_ps,
burst, extack); burst, extack);
if (err) if (err)
......
...@@ -303,7 +303,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port, ...@@ -303,7 +303,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
} }
filter->action.police_ena = true; filter->action.police_ena = true;
pol_ix = a->police.index + ocelot->vcap_pol.base; pol_ix = a->hw_index + ocelot->vcap_pol.base;
pol_max = ocelot->vcap_pol.max; pol_max = ocelot->vcap_pol.max;
if (ocelot->vcap_pol.max2 && pol_ix > pol_max) { if (ocelot->vcap_pol.max2 && pol_ix > pol_max) {
......
...@@ -197,6 +197,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie); ...@@ -197,6 +197,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie);
struct flow_action_entry { struct flow_action_entry {
enum flow_action_id id; enum flow_action_id id;
u32 hw_index;
enum flow_action_hw_stats hw_stats; enum flow_action_hw_stats hw_stats;
action_destr destructor; action_destr destructor;
void *destructor_priv; void *destructor_priv;
...@@ -232,7 +233,6 @@ struct flow_action_entry { ...@@ -232,7 +233,6 @@ struct flow_action_entry {
bool truncate; bool truncate;
} sample; } sample;
struct { /* FLOW_ACTION_POLICE */ struct { /* FLOW_ACTION_POLICE */
u32 index;
u32 burst; u32 burst;
u64 rate_bytes_ps; u64 rate_bytes_ps;
u64 burst_pkt; u64 burst_pkt;
...@@ -267,7 +267,6 @@ struct flow_action_entry { ...@@ -267,7 +267,6 @@ struct flow_action_entry {
u8 ttl; u8 ttl;
} mpls_mangle; } mpls_mangle;
struct { struct {
u32 index;
s32 prio; s32 prio;
u64 basetime; u64 basetime;
u64 cycletime; u64 cycletime;
......
...@@ -60,11 +60,6 @@ static inline bool is_tcf_gate(const struct tc_action *a) ...@@ -60,11 +60,6 @@ static inline bool is_tcf_gate(const struct tc_action *a)
return false; 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) static inline s32 tcf_gate_prio(const struct tc_action *a)
{ {
s32 tcfg_prio; s32 tcfg_prio;
......
...@@ -3568,6 +3568,7 @@ int tc_setup_flow_action(struct flow_action *flow_action, ...@@ -3568,6 +3568,7 @@ int tc_setup_flow_action(struct flow_action *flow_action,
goto err_out_locked; goto err_out_locked;
entry->hw_stats = tc_act_hw_stats(act->hw_stats); entry->hw_stats = tc_act_hw_stats(act->hw_stats);
entry->hw_index = act->tcfa_index;
if (is_tcf_gact_ok(act)) { if (is_tcf_gact_ok(act)) {
entry->id = FLOW_ACTION_ACCEPT; entry->id = FLOW_ACTION_ACCEPT;
...@@ -3659,7 +3660,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, ...@@ -3659,7 +3660,6 @@ int tc_setup_flow_action(struct flow_action *flow_action,
entry->police.rate_pkt_ps = entry->police.rate_pkt_ps =
tcf_police_rate_pkt_ps(act); tcf_police_rate_pkt_ps(act);
entry->police.mtu = tcf_police_tcfp_mtu(act); entry->police.mtu = tcf_police_tcfp_mtu(act);
entry->police.index = act->tcfa_index;
} else if (is_tcf_ct(act)) { } else if (is_tcf_ct(act)) {
entry->id = FLOW_ACTION_CT; entry->id = FLOW_ACTION_CT;
entry->ct.action = tcf_ct_action(act); entry->ct.action = tcf_ct_action(act);
...@@ -3698,7 +3698,6 @@ int tc_setup_flow_action(struct flow_action *flow_action, ...@@ -3698,7 +3698,6 @@ int tc_setup_flow_action(struct flow_action *flow_action,
entry->priority = tcf_skbedit_priority(act); entry->priority = tcf_skbedit_priority(act);
} else if (is_tcf_gate(act)) { } else if (is_tcf_gate(act)) {
entry->id = FLOW_ACTION_GATE; entry->id = FLOW_ACTION_GATE;
entry->gate.index = tcf_gate_index(act);
entry->gate.prio = tcf_gate_prio(act); entry->gate.prio = tcf_gate_prio(act);
entry->gate.basetime = tcf_gate_basetime(act); entry->gate.basetime = tcf_gate_basetime(act);
entry->gate.cycletime = tcf_gate_cycletime(act); entry->gate.cycletime = tcf_gate_cycletime(act);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment