Skip to content

Commit 13aca17

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
net/mlx5e: CT: Use per action stats
CT action can miss in a middle of an action list, use per action stats to correctly report stats for missed packets. Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent a830ec4 commit 13aca17

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct mlx5e_tc_act {
5656
const struct flow_action_entry *act,
5757
struct mlx5_flow_attr *attr);
5858

59+
bool (*is_missable)(const struct flow_action_entry *act);
60+
5961
int (*offload_action)(struct mlx5e_priv *priv,
6062
struct flow_offload_action *fl_act,
6163
struct flow_action_entry *act);

drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,17 @@ tc_act_is_multi_table_act_ct(struct mlx5e_priv *priv,
9595
return true;
9696
}
9797

98+
static bool
99+
tc_act_is_missable_ct(const struct flow_action_entry *act)
100+
{
101+
return !(act->ct.action & TCA_CT_ACT_CLEAR);
102+
}
103+
98104
struct mlx5e_tc_act mlx5e_tc_act_ct = {
99105
.can_offload = tc_act_can_offload_ct,
100106
.parse_action = tc_act_parse_ct,
101-
.is_multi_table_act = tc_act_is_multi_table_act_ct,
102107
.post_parse = tc_act_post_parse_ct,
108+
.is_multi_table_act = tc_act_is_multi_table_act_ct,
109+
.is_missable = tc_act_is_missable_ct,
103110
};
104111

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,7 +4052,9 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
40524052
enum mlx5_flow_namespace_type ns_type;
40534053
struct mlx5e_priv *priv = flow->priv;
40544054
struct flow_action_entry *act, **_act;
4055+
struct mlx5_flow_attr *prev_attr;
40554056
struct mlx5e_tc_act *tc_act;
4057+
bool is_missable;
40564058
int err, i;
40574059

40584060
flow_action_reorder.num_entries = flow_action->num_entries;
@@ -4069,6 +4071,9 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
40694071
flow_action_for_each(i, _act, &flow_action_reorder) {
40704072
jump_state.jump_target = false;
40714073
act = *_act;
4074+
is_missable = false;
4075+
prev_attr = attr;
4076+
40724077
tc_act = mlx5e_tc_act_get(act->id, ns_type);
40734078
if (!tc_act) {
40744079
NL_SET_ERR_MSG_MOD(extack, "Not implemented offload action");
@@ -4092,14 +4097,14 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
40924097
goto out_free;
40934098

40944099
parse_state->actions |= attr->action;
4095-
if (!tc_act->stats_action)
4096-
attr->tc_act_cookies[attr->tc_act_cookies_count++] = act->cookie;
40974100

40984101
/* Split attr for multi table act if not the last act. */
40994102
if (jump_state.jump_target ||
41004103
(tc_act->is_multi_table_act &&
41014104
tc_act->is_multi_table_act(priv, act, attr) &&
41024105
i < flow_action_reorder.num_entries - 1)) {
4106+
is_missable = tc_act->is_missable ? tc_act->is_missable(act) : false;
4107+
41034108
err = mlx5e_tc_act_post_parse(parse_state, flow_action, attr, ns_type);
41044109
if (err)
41054110
goto out_free;
@@ -4112,6 +4117,16 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
41124117

41134118
list_add(&attr->list, &flow->attrs);
41144119
}
4120+
4121+
if (is_missable) {
4122+
/* Add counter to prev, and assign act to new (next) attr */
4123+
prev_attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT;
4124+
flow_flag_set(flow, USE_ACT_STATS);
4125+
4126+
attr->tc_act_cookies[attr->tc_act_cookies_count++] = act->cookie;
4127+
} else if (!tc_act->stats_action) {
4128+
prev_attr->tc_act_cookies[prev_attr->tc_act_cookies_count++] = act->cookie;
4129+
}
41154130
}
41164131

41174132
kfree(flow_action_reorder.entries);

0 commit comments

Comments
 (0)