Skip to content

Commit 16f8036

Browse files
ummakynesdavem330
authored andcommitted
net: flow_offload: skip hw stats check for FLOW_ACTION_HW_STATS_DONT_CARE
This patch adds FLOW_ACTION_HW_STATS_DONT_CARE which tells the driver that the frontend does not need counters, this hw stats type request never fails. The FLOW_ACTION_HW_STATS_DISABLED type explicitly requests the driver to disable the stats, however, if the driver cannot disable counters, it bails out. TCA_ACT_HW_STATS_* maintains the 1:1 mapping with FLOW_ACTION_HW_STATS_* except by disabled which is mapped to FLOW_ACTION_HW_STATS_DISABLED (this is 0 in tc). Add tc_act_hw_stats() to perform the mapping between TCA_ACT_HW_STATS_* and FLOW_ACTION_HW_STATS_*. Fixes: 319a1d1 ("flow_offload: check for basic action hw stats type") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b095695 commit 16f8036

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
3636
err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack);
3737
if (err)
3838
return err;
39-
} else if (act->hw_stats != FLOW_ACTION_HW_STATS_DISABLED) {
39+
} else if (act->hw_stats != FLOW_ACTION_HW_STATS_DISABLED &&
40+
act->hw_stats != FLOW_ACTION_HW_STATS_DONT_CARE) {
4041
NL_SET_ERR_MSG_MOD(extack, "Unsupported action HW stats type");
4142
return -EOPNOTSUPP;
4243
}

include/net/flow_offload.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,18 @@ enum flow_action_mangle_base {
166166
enum flow_action_hw_stats_bit {
167167
FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
168168
FLOW_ACTION_HW_STATS_DELAYED_BIT,
169+
FLOW_ACTION_HW_STATS_DISABLED_BIT,
169170
};
170171

171172
enum flow_action_hw_stats {
172-
FLOW_ACTION_HW_STATS_DISABLED = 0,
173+
FLOW_ACTION_HW_STATS_DONT_CARE = 0,
173174
FLOW_ACTION_HW_STATS_IMMEDIATE =
174175
BIT(FLOW_ACTION_HW_STATS_IMMEDIATE_BIT),
175176
FLOW_ACTION_HW_STATS_DELAYED = BIT(FLOW_ACTION_HW_STATS_DELAYED_BIT),
176177
FLOW_ACTION_HW_STATS_ANY = FLOW_ACTION_HW_STATS_IMMEDIATE |
177178
FLOW_ACTION_HW_STATS_DELAYED,
179+
FLOW_ACTION_HW_STATS_DISABLED =
180+
BIT(FLOW_ACTION_HW_STATS_DISABLED_BIT),
178181
};
179182

180183
typedef void (*action_destr)(void *priv);
@@ -325,7 +328,11 @@ __flow_action_hw_stats_check(const struct flow_action *action,
325328
return true;
326329
if (!flow_action_mixed_hw_stats_check(action, extack))
327330
return false;
331+
328332
action_entry = flow_action_first_entry_get(action);
333+
if (action_entry->hw_stats == FLOW_ACTION_HW_STATS_DONT_CARE)
334+
return true;
335+
329336
if (!check_allow_bit &&
330337
action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {
331338
NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");

net/sched/cls_api.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,6 +3523,16 @@ static void tcf_sample_get_group(struct flow_action_entry *entry,
35233523
#endif
35243524
}
35253525

3526+
static enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats)
3527+
{
3528+
if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY))
3529+
return FLOW_ACTION_HW_STATS_DONT_CARE;
3530+
else if (!hw_stats)
3531+
return FLOW_ACTION_HW_STATS_DISABLED;
3532+
3533+
return hw_stats;
3534+
}
3535+
35263536
int tc_setup_flow_action(struct flow_action *flow_action,
35273537
const struct tcf_exts *exts)
35283538
{
@@ -3546,7 +3556,7 @@ int tc_setup_flow_action(struct flow_action *flow_action,
35463556
if (err)
35473557
goto err_out_locked;
35483558

3549-
entry->hw_stats = act->hw_stats;
3559+
entry->hw_stats = tc_act_hw_stats(act->hw_stats);
35503560

35513561
if (is_tcf_gact_ok(act)) {
35523562
entry->id = FLOW_ACTION_ACCEPT;
@@ -3614,7 +3624,7 @@ int tc_setup_flow_action(struct flow_action *flow_action,
36143624
entry->mangle.mask = tcf_pedit_mask(act, k);
36153625
entry->mangle.val = tcf_pedit_val(act, k);
36163626
entry->mangle.offset = tcf_pedit_offset(act, k);
3617-
entry->hw_stats = act->hw_stats;
3627+
entry->hw_stats = tc_act_hw_stats(act->hw_stats);
36183628
entry = &flow_action->entries[++j];
36193629
}
36203630
} else if (is_tcf_csum(act)) {

0 commit comments

Comments
 (0)