Skip to content

Commit 724b2aa

Browse files
hadarhenziondavem330
authored andcommitted
net/mlx5e: TIRs management refactoring
The current refresh tirs self loopback mechanism, refreshes all the tirs belonging to the same mlx5e instance to prevent self loopback by packets sent over any ring of that instance. This mechanism relies on all the tirs/tises of an instance to be created with the same transport domain number (tdn). Change the driver to refresh all the tirs created under the same tdn regardless of which mlx5e netdev instance they belong to. This behaviour is needed for introducing new mlx5e instances which serve to represent SRIOV VFs. The representors and the PF share vport used for E-Switch management, and we want to avoid NIC level HW loopback between them, e.g when sending broadcast packets. To achieve that, both the representors and the PF NIC will share the tdn. This patch doesn't add any new functionality. Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b50d292 commit 724b2aa

File tree

6 files changed

+77
-57
lines changed

6 files changed

+77
-57
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,10 @@ struct mlx5e_flow_steering {
552552
struct mlx5e_arfs_tables arfs;
553553
};
554554

555-
struct mlx5e_direct_tir {
555+
struct mlx5e_tir {
556556
u32 tirn;
557557
u32 rqtn;
558+
struct list_head list;
558559
};
559560

560561
enum {
@@ -576,8 +577,8 @@ struct mlx5e_priv {
576577
struct mlx5e_channel **channel;
577578
u32 tisn[MLX5E_MAX_NUM_TC];
578579
u32 indir_rqtn;
579-
u32 indir_tirn[MLX5E_NUM_INDIR_TIRS];
580-
struct mlx5e_direct_tir direct_tir[MLX5E_MAX_NUM_CHANNELS];
580+
struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS];
581+
struct mlx5e_tir direct_tir[MLX5E_MAX_NUM_CHANNELS];
581582
u32 tx_rates[MLX5E_MAX_NUM_SQS];
582583

583584
struct mlx5e_flow_steering fs;
@@ -784,7 +785,12 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
784785
#endif
785786

786787
u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
788+
int mlx5e_create_tir(struct mlx5_core_dev *mdev,
789+
struct mlx5e_tir *tir, u32 *in, int inlen);
790+
void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
791+
struct mlx5e_tir *tir);
787792
int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev);
788793
void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev);
794+
int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev);
789795

790796
#endif /* __MLX5_EN_H__ */

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ static enum mlx5e_traffic_types arfs_get_tt(enum arfs_type type)
9393
static int arfs_disable(struct mlx5e_priv *priv)
9494
{
9595
struct mlx5_flow_destination dest;
96-
u32 *tirn = priv->indir_tirn;
96+
struct mlx5e_tir *tir = priv->indir_tir;
9797
int err = 0;
9898
int tt;
9999
int i;
100100

101101
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
102102
for (i = 0; i < ARFS_NUM_TYPES; i++) {
103-
dest.tir_num = tirn[i];
103+
dest.tir_num = tir[i].tirn;
104104
tt = arfs_get_tt(i);
105105
/* Modify ttc rules destination to bypass the aRFS tables*/
106106
err = mlx5_modify_rule_destination(priv->fs.ttc.rules[tt],
@@ -176,7 +176,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
176176
struct arfs_table *arfs_t = &priv->fs.arfs.arfs_tables[type];
177177
struct mlx5_flow_destination dest;
178178
u8 match_criteria_enable = 0;
179-
u32 *tirn = priv->indir_tirn;
179+
struct mlx5e_tir *tir = priv->indir_tir;
180180
u32 *match_criteria;
181181
u32 *match_value;
182182
int err = 0;
@@ -192,16 +192,16 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
192192
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
193193
switch (type) {
194194
case ARFS_IPV4_TCP:
195-
dest.tir_num = tirn[MLX5E_TT_IPV4_TCP];
195+
dest.tir_num = tir[MLX5E_TT_IPV4_TCP].tirn;
196196
break;
197197
case ARFS_IPV4_UDP:
198-
dest.tir_num = tirn[MLX5E_TT_IPV4_UDP];
198+
dest.tir_num = tir[MLX5E_TT_IPV4_UDP].tirn;
199199
break;
200200
case ARFS_IPV6_TCP:
201-
dest.tir_num = tirn[MLX5E_TT_IPV6_TCP];
201+
dest.tir_num = tir[MLX5E_TT_IPV6_TCP].tirn;
202202
break;
203203
case ARFS_IPV6_UDP:
204-
dest.tir_num = tirn[MLX5E_TT_IPV6_UDP];
204+
dest.tir_num = tir[MLX5E_TT_IPV6_UDP].tirn;
205205
break;
206206
default:
207207
err = -EINVAL;

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@
3636
* Global resources are common to all the netdevices crated on the same nic.
3737
*/
3838

39+
int mlx5e_create_tir(struct mlx5_core_dev *mdev,
40+
struct mlx5e_tir *tir, u32 *in, int inlen)
41+
{
42+
int err;
43+
44+
err = mlx5_core_create_tir(mdev, in, inlen, &tir->tirn);
45+
if (err)
46+
return err;
47+
48+
list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list);
49+
50+
return 0;
51+
}
52+
53+
void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
54+
struct mlx5e_tir *tir)
55+
{
56+
mlx5_core_destroy_tir(mdev, tir->tirn);
57+
list_del(&tir->list);
58+
}
59+
3960
static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
4061
struct mlx5_core_mkey *mkey)
4162
{
@@ -89,6 +110,8 @@ int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev)
89110
goto err_dealloc_transport_domain;
90111
}
91112

113+
INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list);
114+
92115
return 0;
93116

94117
err_dealloc_transport_domain:
@@ -110,3 +133,28 @@ void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev)
110133
mlx5_core_dealloc_pd(mdev, res->pdn);
111134
mlx5_unmap_free_uar(mdev, &res->cq_uar);
112135
}
136+
137+
int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev)
138+
{
139+
struct mlx5e_tir *tir;
140+
void *in;
141+
int inlen;
142+
int err;
143+
144+
inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
145+
in = mlx5_vzalloc(inlen);
146+
if (!in)
147+
return -ENOMEM;
148+
149+
MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1);
150+
151+
list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) {
152+
err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen);
153+
if (err)
154+
return err;
155+
}
156+
157+
kvfree(in);
158+
159+
return 0;
160+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ static void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in, int inlen)
876876
mlx5e_build_tir_ctx_hash(tirc, priv);
877877

878878
for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++)
879-
mlx5_core_modify_tir(mdev, priv->indir_tirn[i], in, inlen);
879+
mlx5_core_modify_tir(mdev, priv->indir_tir[i].tirn, in, inlen);
880880
}
881881

882882
static int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv)
655655
if (tt == MLX5E_TT_ANY)
656656
dest.tir_num = priv->direct_tir[0].tirn;
657657
else
658-
dest.tir_num = priv->indir_tirn[tt];
658+
dest.tir_num = priv->indir_tir[tt].tirn;
659659
rules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest,
660660
ttc_rules[tt].etype,
661661
ttc_rules[tt].proto);

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

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv)
16611661
mlx5e_build_tir_ctx_lro(tirc, priv);
16621662

16631663
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
1664-
err = mlx5_core_modify_tir(mdev, priv->indir_tirn[tt], in,
1664+
err = mlx5_core_modify_tir(mdev, priv->indir_tir[tt].tirn, in,
16651665
inlen);
16661666
if (err)
16671667
goto free_in;
@@ -1680,40 +1680,6 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv)
16801680
return err;
16811681
}
16821682

1683-
static int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5e_priv *priv)
1684-
{
1685-
void *in;
1686-
int inlen;
1687-
int err;
1688-
int i;
1689-
1690-
inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
1691-
in = mlx5_vzalloc(inlen);
1692-
if (!in)
1693-
return -ENOMEM;
1694-
1695-
MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1);
1696-
1697-
for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++) {
1698-
err = mlx5_core_modify_tir(priv->mdev, priv->indir_tirn[i], in,
1699-
inlen);
1700-
if (err)
1701-
return err;
1702-
}
1703-
1704-
for (i = 0; i < priv->params.num_channels; i++) {
1705-
err = mlx5_core_modify_tir(priv->mdev,
1706-
priv->direct_tir[i].tirn, in,
1707-
inlen);
1708-
if (err)
1709-
return err;
1710-
}
1711-
1712-
kvfree(in);
1713-
1714-
return 0;
1715-
}
1716-
17171683
static int mlx5e_set_mtu(struct mlx5e_priv *priv, u16 mtu)
17181684
{
17191685
struct mlx5_core_dev *mdev = priv->mdev;
@@ -1804,7 +1770,7 @@ int mlx5e_open_locked(struct net_device *netdev)
18041770
goto err_clear_state_opened_flag;
18051771
}
18061772

1807-
err = mlx5e_refresh_tirs_self_loopback_enable(priv);
1773+
err = mlx5e_refresh_tirs_self_loopback_enable(priv->mdev);
18081774
if (err) {
18091775
netdev_err(netdev, "%s: mlx5e_refresh_tirs_self_loopback_enable failed, %d\n",
18101776
__func__, err);
@@ -2148,9 +2114,9 @@ static void mlx5e_build_direct_tir_ctx(struct mlx5e_priv *priv, u32 *tirc,
21482114
static int mlx5e_create_tirs(struct mlx5e_priv *priv)
21492115
{
21502116
int nch = mlx5e_get_max_num_channels(priv->mdev);
2117+
struct mlx5e_tir *tir;
21512118
void *tirc;
21522119
int inlen;
2153-
u32 *tirn;
21542120
int err;
21552121
u32 *in;
21562122
int ix;
@@ -2164,22 +2130,22 @@ static int mlx5e_create_tirs(struct mlx5e_priv *priv)
21642130
/* indirect tirs */
21652131
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
21662132
memset(in, 0, inlen);
2167-
tirn = &priv->indir_tirn[tt];
2133+
tir = &priv->indir_tir[tt];
21682134
tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
21692135
mlx5e_build_indir_tir_ctx(priv, tirc, tt);
2170-
err = mlx5_core_create_tir(priv->mdev, in, inlen, tirn);
2136+
err = mlx5e_create_tir(priv->mdev, tir, in, inlen);
21712137
if (err)
21722138
goto err_destroy_tirs;
21732139
}
21742140

21752141
/* direct tirs */
21762142
for (ix = 0; ix < nch; ix++) {
21772143
memset(in, 0, inlen);
2178-
tirn = &priv->direct_tir[ix].tirn;
2144+
tir = &priv->direct_tir[ix];
21792145
tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
21802146
mlx5e_build_direct_tir_ctx(priv, tirc,
21812147
priv->direct_tir[ix].rqtn);
2182-
err = mlx5_core_create_tir(priv->mdev, in, inlen, tirn);
2148+
err = mlx5e_create_tir(priv->mdev, tir, in, inlen);
21832149
if (err)
21842150
goto err_destroy_ch_tirs;
21852151
}
@@ -2190,11 +2156,11 @@ static int mlx5e_create_tirs(struct mlx5e_priv *priv)
21902156

21912157
err_destroy_ch_tirs:
21922158
for (ix--; ix >= 0; ix--)
2193-
mlx5_core_destroy_tir(priv->mdev, priv->direct_tir[ix].tirn);
2159+
mlx5e_destroy_tir(priv->mdev, &priv->direct_tir[ix]);
21942160

21952161
err_destroy_tirs:
21962162
for (tt--; tt >= 0; tt--)
2197-
mlx5_core_destroy_tir(priv->mdev, priv->indir_tirn[tt]);
2163+
mlx5e_destroy_tir(priv->mdev, &priv->indir_tir[tt]);
21982164

21992165
kvfree(in);
22002166

@@ -2207,10 +2173,10 @@ static void mlx5e_destroy_tirs(struct mlx5e_priv *priv)
22072173
int i;
22082174

22092175
for (i = 0; i < nch; i++)
2210-
mlx5_core_destroy_tir(priv->mdev, priv->direct_tir[i].tirn);
2176+
mlx5e_destroy_tir(priv->mdev, &priv->direct_tir[i]);
22112177

22122178
for (i = 0; i < MLX5E_NUM_INDIR_TIRS; i++)
2213-
mlx5_core_destroy_tir(priv->mdev, priv->indir_tirn[i]);
2179+
mlx5e_destroy_tir(priv->mdev, &priv->indir_tir[i]);
22142180
}
22152181

22162182
int mlx5e_modify_rqs_vsd(struct mlx5e_priv *priv, bool vsd)

0 commit comments

Comments
 (0)