Skip to content

Commit 1ae1df3

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5e: Refactor RSS related objects and code
In order to use RSS for hairpin, we refactor the code that deals with setup of the TTC steering tables. This is done using an interim ttc params object that has the flow table attributes, TIR numbers, etc. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 106be53 commit 1ae1df3

File tree

3 files changed

+103
-53
lines changed

3 files changed

+103
-53
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/mlx5/port.h>
4545
#include <linux/mlx5/vport.h>
4646
#include <linux/mlx5/transobj.h>
47+
#include <linux/mlx5/fs.h>
4748
#include <linux/rhashtable.h>
4849
#include <net/switchdev.h>
4950
#include <net/xdp.h>
@@ -1024,11 +1025,26 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
10241025
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
10251026
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
10261027

1027-
int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
1028-
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
1028+
struct ttc_params {
1029+
struct mlx5_flow_table_attr ft_attr;
1030+
u32 any_tt_tirn;
1031+
u32 indir_tirn[MLX5E_NUM_INDIR_TIRS];
1032+
struct mlx5e_ttc_table *inner_ttc;
1033+
};
1034+
1035+
void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params);
1036+
void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params);
1037+
void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params);
1038+
1039+
int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
1040+
struct mlx5e_ttc_table *ttc);
1041+
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv,
1042+
struct mlx5e_ttc_table *ttc);
10291043

1030-
int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv);
1031-
void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv);
1044+
int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
1045+
struct mlx5e_ttc_table *ttc);
1046+
void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
1047+
struct mlx5e_ttc_table *ttc);
10321048

10331049
int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
10341050
u32 underlay_qpn, u32 *tisn);

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

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -806,38 +806,38 @@ mlx5e_generate_ttc_rule(struct mlx5e_priv *priv,
806806
return err ? ERR_PTR(err) : rule;
807807
}
808808

809-
static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv)
809+
static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv,
810+
struct ttc_params *params,
811+
struct mlx5e_ttc_table *ttc)
810812
{
811813
struct mlx5_flow_destination dest = {};
812-
struct mlx5e_ttc_table *ttc;
813814
struct mlx5_flow_handle **rules;
814815
struct mlx5_flow_table *ft;
815816
int tt;
816817
int err;
817818

818-
ttc = &priv->fs.ttc;
819819
ft = ttc->ft.t;
820820
rules = ttc->rules;
821821

822822
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
823823
for (tt = 0; tt < MLX5E_NUM_TT; tt++) {
824824
if (tt == MLX5E_TT_ANY)
825-
dest.tir_num = priv->direct_tir[0].tirn;
825+
dest.tir_num = params->any_tt_tirn;
826826
else
827-
dest.tir_num = priv->indir_tir[tt].tirn;
827+
dest.tir_num = params->indir_tirn[tt];
828828
rules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest,
829829
ttc_rules[tt].etype,
830830
ttc_rules[tt].proto);
831831
if (IS_ERR(rules[tt]))
832832
goto del_rules;
833833
}
834834

835-
if (!mlx5e_tunnel_inner_ft_supported(priv->mdev))
835+
if (!params->inner_ttc || !mlx5e_tunnel_inner_ft_supported(priv->mdev))
836836
return 0;
837837

838838
rules = ttc->tunnel_rules;
839839
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
840-
dest.ft = priv->fs.inner_ttc.ft.t;
840+
dest.ft = params->inner_ttc->ft.t;
841841
for (tt = 0; tt < MLX5E_NUM_TUNNEL_TT; tt++) {
842842
rules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest,
843843
ttc_tunnel_rules[tt].etype,
@@ -977,25 +977,25 @@ mlx5e_generate_inner_ttc_rule(struct mlx5e_priv *priv,
977977
return err ? ERR_PTR(err) : rule;
978978
}
979979

980-
static int mlx5e_generate_inner_ttc_table_rules(struct mlx5e_priv *priv)
980+
static int mlx5e_generate_inner_ttc_table_rules(struct mlx5e_priv *priv,
981+
struct ttc_params *params,
982+
struct mlx5e_ttc_table *ttc)
981983
{
982984
struct mlx5_flow_destination dest = {};
983985
struct mlx5_flow_handle **rules;
984-
struct mlx5e_ttc_table *ttc;
985986
struct mlx5_flow_table *ft;
986987
int err;
987988
int tt;
988989

989-
ttc = &priv->fs.inner_ttc;
990990
ft = ttc->ft.t;
991991
rules = ttc->rules;
992992

993993
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
994994
for (tt = 0; tt < MLX5E_NUM_TT; tt++) {
995995
if (tt == MLX5E_TT_ANY)
996-
dest.tir_num = priv->direct_tir[0].tirn;
996+
dest.tir_num = params->any_tt_tirn;
997997
else
998-
dest.tir_num = priv->inner_indir_tir[tt].tirn;
998+
dest.tir_num = params->indir_tirn[tt];
999999

10001000
rules[tt] = mlx5e_generate_inner_ttc_rule(priv, ft, &dest,
10011001
ttc_rules[tt].etype,
@@ -1075,21 +1075,42 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc)
10751075
return err;
10761076
}
10771077

1078-
int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv)
1078+
void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv,
1079+
struct ttc_params *ttc_params)
1080+
{
1081+
ttc_params->any_tt_tirn = priv->direct_tir[0].tirn;
1082+
ttc_params->inner_ttc = &priv->fs.inner_ttc;
1083+
}
1084+
1085+
void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params)
1086+
{
1087+
struct mlx5_flow_table_attr *ft_attr = &ttc_params->ft_attr;
1088+
1089+
ft_attr->max_fte = MLX5E_INNER_TTC_TABLE_SIZE;
1090+
ft_attr->level = MLX5E_INNER_TTC_FT_LEVEL;
1091+
ft_attr->prio = MLX5E_NIC_PRIO;
1092+
}
1093+
1094+
void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params)
1095+
1096+
{
1097+
struct mlx5_flow_table_attr *ft_attr = &ttc_params->ft_attr;
1098+
1099+
ft_attr->max_fte = MLX5E_TTC_TABLE_SIZE;
1100+
ft_attr->level = MLX5E_TTC_FT_LEVEL;
1101+
ft_attr->prio = MLX5E_NIC_PRIO;
1102+
}
1103+
1104+
int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
1105+
struct mlx5e_ttc_table *ttc)
10791106
{
1080-
struct mlx5e_ttc_table *ttc = &priv->fs.inner_ttc;
1081-
struct mlx5_flow_table_attr ft_attr = {};
10821107
struct mlx5e_flow_table *ft = &ttc->ft;
10831108
int err;
10841109

10851110
if (!mlx5e_tunnel_inner_ft_supported(priv->mdev))
10861111
return 0;
10871112

1088-
ft_attr.max_fte = MLX5E_INNER_TTC_TABLE_SIZE;
1089-
ft_attr.level = MLX5E_INNER_TTC_FT_LEVEL;
1090-
ft_attr.prio = MLX5E_NIC_PRIO;
1091-
1092-
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
1113+
ft->t = mlx5_create_flow_table(priv->fs.ns, &params->ft_attr);
10931114
if (IS_ERR(ft->t)) {
10941115
err = PTR_ERR(ft->t);
10951116
ft->t = NULL;
@@ -1100,7 +1121,7 @@ int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv)
11001121
if (err)
11011122
goto err;
11021123

1103-
err = mlx5e_generate_inner_ttc_table_rules(priv);
1124+
err = mlx5e_generate_inner_ttc_table_rules(priv, params, ttc);
11041125
if (err)
11051126
goto err;
11061127

@@ -1111,38 +1132,31 @@ int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv)
11111132
return err;
11121133
}
11131134

1114-
void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv)
1135+
void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
1136+
struct mlx5e_ttc_table *ttc)
11151137
{
1116-
struct mlx5e_ttc_table *ttc = &priv->fs.inner_ttc;
1117-
11181138
if (!mlx5e_tunnel_inner_ft_supported(priv->mdev))
11191139
return;
11201140

11211141
mlx5e_cleanup_ttc_rules(ttc);
11221142
mlx5e_destroy_flow_table(&ttc->ft);
11231143
}
11241144

1125-
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv)
1145+
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv,
1146+
struct mlx5e_ttc_table *ttc)
11261147
{
1127-
struct mlx5e_ttc_table *ttc = &priv->fs.ttc;
1128-
11291148
mlx5e_cleanup_ttc_rules(ttc);
11301149
mlx5e_destroy_flow_table(&ttc->ft);
11311150
}
11321151

1133-
int mlx5e_create_ttc_table(struct mlx5e_priv *priv)
1152+
int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
1153+
struct mlx5e_ttc_table *ttc)
11341154
{
11351155
bool match_ipv_outer = MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ft_field_support.outer_ip_version);
1136-
struct mlx5e_ttc_table *ttc = &priv->fs.ttc;
1137-
struct mlx5_flow_table_attr ft_attr = {};
11381156
struct mlx5e_flow_table *ft = &ttc->ft;
11391157
int err;
11401158

1141-
ft_attr.max_fte = MLX5E_TTC_TABLE_SIZE;
1142-
ft_attr.level = MLX5E_TTC_FT_LEVEL;
1143-
ft_attr.prio = MLX5E_NIC_PRIO;
1144-
1145-
ft->t = mlx5_create_flow_table(priv->fs.ns, &ft_attr);
1159+
ft->t = mlx5_create_flow_table(priv->fs.ns, &params->ft_attr);
11461160
if (IS_ERR(ft->t)) {
11471161
err = PTR_ERR(ft->t);
11481162
ft->t = NULL;
@@ -1153,7 +1167,7 @@ int mlx5e_create_ttc_table(struct mlx5e_priv *priv)
11531167
if (err)
11541168
goto err;
11551169

1156-
err = mlx5e_generate_ttc_table_rules(priv);
1170+
err = mlx5e_generate_ttc_table_rules(priv, params, ttc);
11571171
if (err)
11581172
goto err;
11591173

@@ -1474,7 +1488,8 @@ static void mlx5e_destroy_vlan_table(struct mlx5e_priv *priv)
14741488

14751489
int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
14761490
{
1477-
int err;
1491+
struct ttc_params ttc_params = {};
1492+
int tt, err;
14781493

14791494
priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
14801495
MLX5_FLOW_NAMESPACE_KERNEL);
@@ -1489,14 +1504,23 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
14891504
priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
14901505
}
14911506

1492-
err = mlx5e_create_inner_ttc_table(priv);
1507+
mlx5e_set_ttc_basic_params(priv, &ttc_params);
1508+
mlx5e_set_inner_ttc_ft_params(&ttc_params);
1509+
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
1510+
ttc_params.indir_tirn[tt] = priv->inner_indir_tir[tt].tirn;
1511+
1512+
err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc);
14931513
if (err) {
14941514
netdev_err(priv->netdev, "Failed to create inner ttc table, err=%d\n",
14951515
err);
14961516
goto err_destroy_arfs_tables;
14971517
}
14981518

1499-
err = mlx5e_create_ttc_table(priv);
1519+
mlx5e_set_ttc_ft_params(&ttc_params);
1520+
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
1521+
ttc_params.indir_tirn[tt] = priv->indir_tir[tt].tirn;
1522+
1523+
err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc);
15001524
if (err) {
15011525
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
15021526
err);
@@ -1524,9 +1548,9 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
15241548
err_destroy_l2_table:
15251549
mlx5e_destroy_l2_table(priv);
15261550
err_destroy_ttc_table:
1527-
mlx5e_destroy_ttc_table(priv);
1551+
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
15281552
err_destroy_inner_ttc_table:
1529-
mlx5e_destroy_inner_ttc_table(priv);
1553+
mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc);
15301554
err_destroy_arfs_tables:
15311555
mlx5e_arfs_destroy_tables(priv);
15321556

@@ -1537,8 +1561,8 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)
15371561
{
15381562
mlx5e_destroy_vlan_table(priv);
15391563
mlx5e_destroy_l2_table(priv);
1540-
mlx5e_destroy_ttc_table(priv);
1541-
mlx5e_destroy_inner_ttc_table(priv);
1564+
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
1565+
mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc);
15421566
mlx5e_arfs_destroy_tables(priv);
15431567
mlx5e_ethtool_cleanup_steering(priv);
15441568
}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)
241241

242242
static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
243243
{
244-
int err;
244+
struct ttc_params ttc_params = {};
245+
int tt, err;
245246

246247
priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
247248
MLX5_FLOW_NAMESPACE_KERNEL);
@@ -256,14 +257,23 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
256257
priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
257258
}
258259

259-
err = mlx5e_create_inner_ttc_table(priv);
260+
mlx5e_set_ttc_basic_params(priv, &ttc_params);
261+
mlx5e_set_inner_ttc_ft_params(&ttc_params);
262+
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
263+
ttc_params.indir_tirn[tt] = priv->inner_indir_tir[tt].tirn;
264+
265+
err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc);
260266
if (err) {
261267
netdev_err(priv->netdev, "Failed to create inner ttc table, err=%d\n",
262268
err);
263269
goto err_destroy_arfs_tables;
264270
}
265271

266-
err = mlx5e_create_ttc_table(priv);
272+
mlx5e_set_ttc_ft_params(&ttc_params);
273+
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
274+
ttc_params.indir_tirn[tt] = priv->inner_indir_tir[tt].tirn;
275+
276+
err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc);
267277
if (err) {
268278
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
269279
err);
@@ -273,7 +283,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
273283
return 0;
274284

275285
err_destroy_inner_ttc_table:
276-
mlx5e_destroy_inner_ttc_table(priv);
286+
mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc);
277287
err_destroy_arfs_tables:
278288
mlx5e_arfs_destroy_tables(priv);
279289

@@ -282,8 +292,8 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
282292

283293
static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv)
284294
{
285-
mlx5e_destroy_ttc_table(priv);
286-
mlx5e_destroy_inner_ttc_table(priv);
295+
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc);
296+
mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc);
287297
mlx5e_arfs_destroy_tables(priv);
288298
}
289299

0 commit comments

Comments
 (0)