Skip to content

Commit b8922a7

Browse files
author
Saeed Mahameed
committed
net/mlx5e: API to manipulate TTC rules destinations
Store the default destinations of the on-load generated TTC (Traffic Type Classifier) rules in the ttc rules table. Introduce TTC API functions to manipulate/restore and get the TTC rule destination and use these API functions in arfs implementation. This will allow a better decoupling between TTC implementation and its users. Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]>
1 parent c293ac9 commit b8922a7

File tree

3 files changed

+86
-48
lines changed

3 files changed

+86
-48
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/fs.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ enum mlx5e_tunnel_types {
105105

106106
bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev);
107107

108+
struct mlx5e_ttc_rule {
109+
struct mlx5_flow_handle *rule;
110+
struct mlx5_flow_destination default_dest;
111+
};
112+
108113
/* L3/L4 traffic type classifier */
109114
struct mlx5e_ttc_table {
110-
struct mlx5e_flow_table ft;
111-
struct mlx5_flow_handle *rules[MLX5E_NUM_TT];
112-
struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
115+
struct mlx5e_flow_table ft;
116+
struct mlx5e_ttc_rule rules[MLX5E_NUM_TT];
117+
struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
113118
};
114119

115120
/* NIC prio FTS */
@@ -248,6 +253,11 @@ void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
248253
struct mlx5e_ttc_table *ttc);
249254

250255
void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
256+
int mlx5e_ttc_fwd_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type,
257+
struct mlx5_flow_destination *new_dest);
258+
struct mlx5_flow_destination
259+
mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type);
260+
int mlx5e_ttc_fwd_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type);
251261

252262
void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
253263
void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,15 @@ static enum mlx5e_traffic_types arfs_get_tt(enum arfs_type type)
9090

9191
static int arfs_disable(struct mlx5e_priv *priv)
9292
{
93-
struct mlx5_flow_destination dest = {};
94-
struct mlx5e_tir *tir = priv->indir_tir;
95-
int err = 0;
96-
int tt;
97-
int i;
93+
int err, i;
9894

99-
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
10095
for (i = 0; i < ARFS_NUM_TYPES; i++) {
101-
dest.tir_num = tir[i].tirn;
102-
tt = arfs_get_tt(i);
103-
/* Modify ttc rules destination to bypass the aRFS tables*/
104-
err = mlx5_modify_rule_destination(priv->fs.ttc.rules[tt],
105-
&dest, NULL);
96+
/* Modify ttc rules destination back to their default */
97+
err = mlx5e_ttc_fwd_default_dest(priv, arfs_get_tt(i));
10698
if (err) {
10799
netdev_err(priv->netdev,
108-
"%s: modify ttc destination failed\n",
109-
__func__);
100+
"%s: modify ttc[%d] default destination failed, err(%d)\n",
101+
__func__, arfs_get_tt(i), err);
110102
return err;
111103
}
112104
}
@@ -125,21 +117,17 @@ int mlx5e_arfs_disable(struct mlx5e_priv *priv)
125117
int mlx5e_arfs_enable(struct mlx5e_priv *priv)
126118
{
127119
struct mlx5_flow_destination dest = {};
128-
int err = 0;
129-
int tt;
130-
int i;
120+
int err, i;
131121

132122
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
133123
for (i = 0; i < ARFS_NUM_TYPES; i++) {
134124
dest.ft = priv->fs.arfs.arfs_tables[i].ft.t;
135-
tt = arfs_get_tt(i);
136125
/* Modify ttc rules destination to point on the aRFS FTs */
137-
err = mlx5_modify_rule_destination(priv->fs.ttc.rules[tt],
138-
&dest, NULL);
126+
err = mlx5e_ttc_fwd_dest(priv, arfs_get_tt(i), &dest);
139127
if (err) {
140128
netdev_err(priv->netdev,
141-
"%s: modify ttc destination failed err=%d\n",
142-
__func__, err);
129+
"%s: modify ttc[%d] dest to arfs, failed err(%d)\n",
130+
__func__, arfs_get_tt(i), err);
143131
arfs_disable(priv);
144132
return err;
145133
}
@@ -186,8 +174,10 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
186174
return -EINVAL;
187175
}
188176

177+
/* FIXME: Must use mlx5e_ttc_get_default_dest(),
178+
* but can't since TTC default is not setup yet !
179+
*/
189180
dest.tir_num = tir[tt].tirn;
190-
191181
arfs_t->default_rule = mlx5_add_flow_rules(arfs_t->ft.t, NULL,
192182
&flow_act,
193183
&dest, 1);

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

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ static void mlx5e_cleanup_ttc_rules(struct mlx5e_ttc_table *ttc)
672672
int i;
673673

674674
for (i = 0; i < MLX5E_NUM_TT; i++) {
675-
if (!IS_ERR_OR_NULL(ttc->rules[i])) {
676-
mlx5_del_flow_rules(ttc->rules[i]);
677-
ttc->rules[i] = NULL;
675+
if (!IS_ERR_OR_NULL(ttc->rules[i].rule)) {
676+
mlx5_del_flow_rules(ttc->rules[i].rule);
677+
ttc->rules[i].rule = NULL;
678678
}
679679
}
680680

@@ -857,7 +857,8 @@ static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv,
857857
struct mlx5e_ttc_table *ttc)
858858
{
859859
struct mlx5_flow_destination dest = {};
860-
struct mlx5_flow_handle **rules;
860+
struct mlx5_flow_handle **trules;
861+
struct mlx5e_ttc_rule *rules;
861862
struct mlx5_flow_table *ft;
862863
int tt;
863864
int err;
@@ -867,39 +868,47 @@ static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv,
867868

868869
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
869870
for (tt = 0; tt < MLX5E_NUM_TT; tt++) {
871+
struct mlx5e_ttc_rule *rule = &rules[tt];
872+
870873
if (tt == MLX5E_TT_ANY)
871874
dest.tir_num = params->any_tt_tirn;
872875
else
873876
dest.tir_num = params->indir_tirn[tt];
874-
rules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest,
875-
ttc_rules[tt].etype,
876-
ttc_rules[tt].proto);
877-
if (IS_ERR(rules[tt]))
877+
878+
rule->rule = mlx5e_generate_ttc_rule(priv, ft, &dest,
879+
ttc_rules[tt].etype,
880+
ttc_rules[tt].proto);
881+
if (IS_ERR(rule->rule)) {
882+
err = PTR_ERR(rule->rule);
883+
rule->rule = NULL;
878884
goto del_rules;
885+
}
886+
rule->default_dest = dest;
879887
}
880888

881889
if (!params->inner_ttc || !mlx5e_tunnel_inner_ft_supported(priv->mdev))
882890
return 0;
883891

884-
rules = ttc->tunnel_rules;
892+
trules = ttc->tunnel_rules;
885893
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
886894
dest.ft = params->inner_ttc->ft.t;
887895
for (tt = 0; tt < MLX5E_NUM_TUNNEL_TT; tt++) {
888896
if (!mlx5e_tunnel_proto_supported(priv->mdev,
889897
ttc_tunnel_rules[tt].proto))
890898
continue;
891-
rules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest,
892-
ttc_tunnel_rules[tt].etype,
893-
ttc_tunnel_rules[tt].proto);
894-
if (IS_ERR(rules[tt]))
899+
trules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest,
900+
ttc_tunnel_rules[tt].etype,
901+
ttc_tunnel_rules[tt].proto);
902+
if (IS_ERR(trules[tt])) {
903+
err = PTR_ERR(trules[tt]);
904+
trules[tt] = NULL;
895905
goto del_rules;
906+
}
896907
}
897908

898909
return 0;
899910

900911
del_rules:
901-
err = PTR_ERR(rules[tt]);
902-
rules[tt] = NULL;
903912
mlx5e_cleanup_ttc_rules(ttc);
904913
return err;
905914
}
@@ -1015,33 +1024,38 @@ static int mlx5e_generate_inner_ttc_table_rules(struct mlx5e_priv *priv,
10151024
struct mlx5e_ttc_table *ttc)
10161025
{
10171026
struct mlx5_flow_destination dest = {};
1018-
struct mlx5_flow_handle **rules;
1027+
struct mlx5e_ttc_rule *rules;
10191028
struct mlx5_flow_table *ft;
10201029
int err;
10211030
int tt;
10221031

10231032
ft = ttc->ft.t;
10241033
rules = ttc->rules;
1025-
10261034
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
1035+
10271036
for (tt = 0; tt < MLX5E_NUM_TT; tt++) {
1037+
struct mlx5e_ttc_rule *rule = &rules[tt];
1038+
10281039
if (tt == MLX5E_TT_ANY)
10291040
dest.tir_num = params->any_tt_tirn;
10301041
else
10311042
dest.tir_num = params->indir_tirn[tt];
10321043

1033-
rules[tt] = mlx5e_generate_inner_ttc_rule(priv, ft, &dest,
1034-
ttc_rules[tt].etype,
1035-
ttc_rules[tt].proto);
1036-
if (IS_ERR(rules[tt]))
1044+
rule->rule = mlx5e_generate_inner_ttc_rule(priv, ft, &dest,
1045+
ttc_rules[tt].etype,
1046+
ttc_rules[tt].proto);
1047+
if (IS_ERR(rule->rule)) {
1048+
err = PTR_ERR(rule->rule);
1049+
rule->rule = NULL;
10371050
goto del_rules;
1051+
}
1052+
rule->default_dest = dest;
10381053
}
10391054

10401055
return 0;
10411056

10421057
del_rules:
1043-
err = PTR_ERR(rules[tt]);
1044-
rules[tt] = NULL;
1058+
10451059
mlx5e_cleanup_ttc_rules(ttc);
10461060
return err;
10471061
}
@@ -1210,6 +1224,30 @@ int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
12101224
return err;
12111225
}
12121226

1227+
int mlx5e_ttc_fwd_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type,
1228+
struct mlx5_flow_destination *new_dest)
1229+
{
1230+
return mlx5_modify_rule_destination(priv->fs.ttc.rules[type].rule, new_dest, NULL);
1231+
}
1232+
1233+
struct mlx5_flow_destination
1234+
mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type)
1235+
{
1236+
struct mlx5_flow_destination *dest = &priv->fs.ttc.rules[type].default_dest;
1237+
1238+
WARN_ONCE(dest->type != MLX5_FLOW_DESTINATION_TYPE_TIR,
1239+
"TTC[%d] default dest is not setup yet", type);
1240+
1241+
return *dest;
1242+
}
1243+
1244+
int mlx5e_ttc_fwd_default_dest(struct mlx5e_priv *priv, enum mlx5e_traffic_types type)
1245+
{
1246+
struct mlx5_flow_destination dest = mlx5e_ttc_get_default_dest(priv, type);
1247+
1248+
return mlx5e_ttc_fwd_dest(priv, type, &dest);
1249+
}
1250+
12131251
static void mlx5e_del_l2_flow_rule(struct mlx5e_priv *priv,
12141252
struct mlx5e_l2_rule *ai)
12151253
{

0 commit comments

Comments
 (0)