Skip to content

Commit 8f493ff

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5e: IPoIB, RX steering RSS RQTs and TIRs
Implement IPoIB RX RSS (RQTs and TIRs) HW objects creation, All we do here is simply reuse the mlx5e implementation to create direct and indirect (RSS) steering HW objects. For that we just expose mlx5e_{create,destroy}_{direct,indirect}_{rqt,tir} functions into en.h and call them from ipoib.c in init/cleanup_rx IPoIB netdevice profile callbacks. Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Erez Shitrit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 48935bb commit 8f493ff

File tree

4 files changed

+83
-44
lines changed

4 files changed

+83
-44
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,17 @@ int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr);
999999
void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
10001000
void mlx5e_update_hw_rep_counters(struct mlx5e_priv *priv);
10011001

1002+
int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv);
1003+
1004+
int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv);
1005+
void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv);
1006+
10021007
int mlx5e_create_direct_rqts(struct mlx5e_priv *priv);
1003-
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
1008+
void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv);
10041009
int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
10051010
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
1011+
void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
1012+
10061013
int mlx5e_create_tises(struct mlx5e_priv *priv);
10071014
void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
10081015
int mlx5e_close(struct net_device *netdev);
@@ -1024,5 +1031,8 @@ mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *prof
10241031
int mlx5e_attach_netdev(struct mlx5e_priv *priv);
10251032
void mlx5e_detach_netdev(struct mlx5e_priv *priv);
10261033
void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
1034+
void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
1035+
struct mlx5e_params *params,
1036+
u16 max_channels);
10271037

10281038
#endif /* __MLX5_EN_H__ */

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

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,11 +2115,15 @@ void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt)
21152115
mlx5_core_destroy_rqt(priv->mdev, rqt->rqtn);
21162116
}
21172117

2118-
static int mlx5e_create_indirect_rqts(struct mlx5e_priv *priv)
2118+
int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv)
21192119
{
21202120
struct mlx5e_rqt *rqt = &priv->indir_rqt;
2121+
int err;
21212122

2122-
return mlx5e_create_rqt(priv, MLX5E_INDIR_RQT_SIZE, rqt);
2123+
err = mlx5e_create_rqt(priv, MLX5E_INDIR_RQT_SIZE, rqt);
2124+
if (err)
2125+
mlx5_core_warn(priv->mdev, "create indirect rqts failed, %d\n", err);
2126+
return err;
21232127
}
21242128

21252129
int mlx5e_create_direct_rqts(struct mlx5e_priv *priv)
@@ -2138,12 +2142,21 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv)
21382142
return 0;
21392143

21402144
err_destroy_rqts:
2145+
mlx5_core_warn(priv->mdev, "create direct rqts failed, %d\n", err);
21412146
for (ix--; ix >= 0; ix--)
21422147
mlx5e_destroy_rqt(priv, &priv->direct_tir[ix].rqt);
21432148

21442149
return err;
21452150
}
21462151

2152+
void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv)
2153+
{
2154+
int i;
2155+
2156+
for (i = 0; i < priv->profile->max_nch(priv->mdev); i++)
2157+
mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
2158+
}
2159+
21472160
static int mlx5e_rx_hash_fn(int hfunc)
21482161
{
21492162
return (hfunc == ETH_RSS_HASH_TOP) ?
@@ -2818,7 +2831,7 @@ static void mlx5e_build_direct_tir_ctx(struct mlx5e_priv *priv, u32 rqtn, u32 *t
28182831
MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8);
28192832
}
28202833

2821-
static int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
2834+
int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
28222835
{
28232836
struct mlx5e_tir *tir;
28242837
void *tirc;
@@ -2847,6 +2860,7 @@ static int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
28472860
return 0;
28482861

28492862
err_destroy_tirs:
2863+
mlx5_core_warn(priv->mdev, "create indirect tirs failed, %d\n", err);
28502864
for (tt--; tt >= 0; tt--)
28512865
mlx5e_destroy_tir(priv->mdev, &priv->indir_tir[tt]);
28522866

@@ -2885,6 +2899,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv)
28852899
return 0;
28862900

28872901
err_destroy_ch_tirs:
2902+
mlx5_core_warn(priv->mdev, "create direct tirs failed, %d\n", err);
28882903
for (ix--; ix >= 0; ix--)
28892904
mlx5e_destroy_tir(priv->mdev, &priv->direct_tir[ix]);
28902905

@@ -2893,7 +2908,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv)
28932908
return err;
28942909
}
28952910

2896-
static void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv)
2911+
void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv)
28972912
{
28982913
int i;
28992914

@@ -3794,9 +3809,9 @@ u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
37943809
return MLX5_CAP_ETH(mdev, lro_timer_supported_periods[i]);
37953810
}
37963811

3797-
static void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
3798-
struct mlx5e_params *params,
3799-
u16 max_channels)
3812+
void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
3813+
struct mlx5e_params *params,
3814+
u16 max_channels)
38003815
{
38013816
u8 cq_period_mode = 0;
38023817
u32 link_speed = 0;
@@ -4031,31 +4046,22 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
40314046
{
40324047
struct mlx5_core_dev *mdev = priv->mdev;
40334048
int err;
4034-
int i;
40354049

4036-
err = mlx5e_create_indirect_rqts(priv);
4037-
if (err) {
4038-
mlx5_core_warn(mdev, "create indirect rqts failed, %d\n", err);
4050+
err = mlx5e_create_indirect_rqt(priv);
4051+
if (err)
40394052
return err;
4040-
}
40414053

40424054
err = mlx5e_create_direct_rqts(priv);
4043-
if (err) {
4044-
mlx5_core_warn(mdev, "create direct rqts failed, %d\n", err);
4055+
if (err)
40454056
goto err_destroy_indirect_rqts;
4046-
}
40474057

40484058
err = mlx5e_create_indirect_tirs(priv);
4049-
if (err) {
4050-
mlx5_core_warn(mdev, "create indirect tirs failed, %d\n", err);
4059+
if (err)
40514060
goto err_destroy_direct_rqts;
4052-
}
40534061

40544062
err = mlx5e_create_direct_tirs(priv);
4055-
if (err) {
4056-
mlx5_core_warn(mdev, "create direct tirs failed, %d\n", err);
4063+
if (err)
40574064
goto err_destroy_indirect_tirs;
4058-
}
40594065

40604066
err = mlx5e_create_flow_steering(priv);
40614067
if (err) {
@@ -4076,23 +4082,19 @@ static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
40764082
err_destroy_indirect_tirs:
40774083
mlx5e_destroy_indirect_tirs(priv);
40784084
err_destroy_direct_rqts:
4079-
for (i = 0; i < priv->profile->max_nch(mdev); i++)
4080-
mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
4085+
mlx5e_destroy_direct_rqts(priv);
40814086
err_destroy_indirect_rqts:
40824087
mlx5e_destroy_rqt(priv, &priv->indir_rqt);
40834088
return err;
40844089
}
40854090

40864091
static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
40874092
{
4088-
int i;
4089-
40904093
mlx5e_tc_cleanup(priv);
40914094
mlx5e_destroy_flow_steering(priv);
40924095
mlx5e_destroy_direct_tirs(priv);
40934096
mlx5e_destroy_indirect_tirs(priv);
4094-
for (i = 0; i < priv->profile->max_nch(priv->mdev); i++)
4095-
mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
4097+
mlx5e_destroy_direct_rqts(priv);
40964098
mlx5e_destroy_rqt(priv, &priv->indir_rqt);
40974099
}
40984100

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -465,24 +465,18 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
465465
{
466466
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
467467
struct mlx5_eswitch_rep *rep = priv->ppriv;
468-
struct mlx5_core_dev *mdev = priv->mdev;
469468
struct mlx5_flow_handle *flow_rule;
470469
int err;
471-
int i;
472470

473471
mlx5e_init_l2_addr(priv);
474472

475473
err = mlx5e_create_direct_rqts(priv);
476-
if (err) {
477-
mlx5_core_warn(mdev, "create direct rqts failed, %d\n", err);
474+
if (err)
478475
return err;
479-
}
480476

481477
err = mlx5e_create_direct_tirs(priv);
482-
if (err) {
483-
mlx5_core_warn(mdev, "create direct tirs failed, %d\n", err);
478+
if (err)
484479
goto err_destroy_direct_rqts;
485-
}
486480

487481
flow_rule = mlx5_eswitch_create_vport_rx_rule(esw,
488482
rep->vport,
@@ -504,21 +498,18 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
504498
err_destroy_direct_tirs:
505499
mlx5e_destroy_direct_tirs(priv);
506500
err_destroy_direct_rqts:
507-
for (i = 0; i < priv->channels.params.num_channels; i++)
508-
mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
501+
mlx5e_destroy_direct_rqts(priv);
509502
return err;
510503
}
511504

512505
static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
513506
{
514507
struct mlx5_eswitch_rep *rep = priv->ppriv;
515-
int i;
516508

517509
mlx5e_tc_cleanup(priv);
518510
mlx5_del_flow_rules(rep->vport_rx_rule);
519511
mlx5e_destroy_direct_tirs(priv);
520-
for (i = 0; i < priv->channels.params.num_channels; i++)
521-
mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
512+
mlx5e_destroy_direct_rqts(priv);
522513
}
523514

524515
static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)

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

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ static void mlx5i_init(struct mlx5_core_dev *mdev,
4444
{
4545
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
4646

47-
priv->ppriv = ppriv;
48-
/* TODO: init netdev and mlx5e_params here */
47+
priv->mdev = mdev;
48+
priv->netdev = netdev;
49+
priv->profile = profile;
50+
priv->ppriv = ppriv;
51+
52+
mlx5e_build_nic_params(mdev, &priv->channels.params, profile->max_nch(mdev));
53+
54+
mutex_init(&priv->state_lock);
55+
/* TODO : init netdev features here */
4956
}
5057

5158
/* Called directly before IPoIB netdevice is destroyed to cleanup SW structs */
@@ -67,12 +74,41 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)
6774

6875
static int mlx5i_init_rx(struct mlx5e_priv *priv)
6976
{
70-
/* TODO: create IPoIB RX HW steering contexts */
77+
int err;
78+
79+
err = mlx5e_create_indirect_rqt(priv);
80+
if (err)
81+
return err;
82+
83+
err = mlx5e_create_direct_rqts(priv);
84+
if (err)
85+
goto err_destroy_indirect_rqts;
86+
87+
err = mlx5e_create_indirect_tirs(priv);
88+
if (err)
89+
goto err_destroy_direct_rqts;
90+
91+
err = mlx5e_create_direct_tirs(priv);
92+
if (err)
93+
goto err_destroy_indirect_tirs;
94+
7195
return 0;
96+
97+
err_destroy_indirect_tirs:
98+
mlx5e_destroy_indirect_tirs(priv);
99+
err_destroy_direct_rqts:
100+
mlx5e_destroy_direct_rqts(priv);
101+
err_destroy_indirect_rqts:
102+
mlx5e_destroy_rqt(priv, &priv->indir_rqt);
103+
return err;
72104
}
73105

74106
static void mlx5i_cleanup_rx(struct mlx5e_priv *priv)
75107
{
108+
mlx5e_destroy_direct_tirs(priv);
109+
mlx5e_destroy_indirect_tirs(priv);
110+
mlx5e_destroy_direct_rqts(priv);
111+
mlx5e_destroy_rqt(priv, &priv->indir_rqt);
76112
}
77113

78114
static const struct mlx5e_profile mlx5i_nic_profile = {

0 commit comments

Comments
 (0)