Skip to content

Commit 694826e

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Fix wrong max num channels indication
No XSK support in the enhanced IPoIB driver and representors. Add a profile property to specify this, and enhance the logic that calculates the max number of channels to take it into account. Fixes: db05815 ("net/mlx5e: Add XSK zero-copy support") Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 7a32f29 commit 694826e

File tree

9 files changed

+35
-41
lines changed

9 files changed

+35
-41
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ do { \
159159
enum mlx5e_rq_group {
160160
MLX5E_RQ_GROUP_REGULAR,
161161
MLX5E_RQ_GROUP_XSK,
162-
MLX5E_NUM_RQ_GROUPS /* Keep last. */
162+
#define MLX5E_NUM_RQ_GROUPS(g) (1 + MLX5E_RQ_GROUP_##g)
163163
};
164164

165165
static inline u16 mlx5_min_rx_wqes(int wq_type, u32 wq_size)
@@ -182,14 +182,6 @@ static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
182182
min_t(int, mlx5_comp_vectors_count(mdev), MLX5E_MAX_NUM_CHANNELS);
183183
}
184184

185-
/* Use this function to get max num channels after netdev was created */
186-
static inline int mlx5e_get_netdev_max_channels(struct net_device *netdev)
187-
{
188-
return min_t(unsigned int,
189-
netdev->num_rx_queues / MLX5E_NUM_RQ_GROUPS,
190-
netdev->num_tx_queues);
191-
}
192-
193185
struct mlx5e_tx_wqe {
194186
struct mlx5_wqe_ctrl_seg ctrl;
195187
struct mlx5_wqe_eth_seg eth;
@@ -830,6 +822,7 @@ struct mlx5e_priv {
830822
struct net_device *netdev;
831823
struct mlx5e_stats stats;
832824
struct mlx5e_channel_stats channel_stats[MLX5E_MAX_NUM_CHANNELS];
825+
u16 max_nch;
833826
u8 max_opened_tc;
834827
struct hwtstamp_config tstamp;
835828
u16 q_counter;
@@ -871,6 +864,7 @@ struct mlx5e_profile {
871864
mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe;
872865
} rx_handlers;
873866
int max_tc;
867+
u8 rq_groups;
874868
};
875869

876870
void mlx5e_build_ptys2ethtool_map(void);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ static inline void mlx5e_qid_get_ch_and_group(struct mlx5e_params *params,
6666
*group = qid / nch;
6767
}
6868

69-
static inline bool mlx5e_qid_validate(struct mlx5e_params *params, u64 qid)
69+
static inline bool mlx5e_qid_validate(const struct mlx5e_profile *profile,
70+
struct mlx5e_params *params, u64 qid)
7071
{
71-
return qid < params->num_channels * MLX5E_NUM_RQ_GROUPS;
72+
return qid < params->num_channels * profile->rq_groups;
7273
}
7374

7475
/* Parameter calculations */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
391391
{
392392
mutex_lock(&priv->state_lock);
393393

394-
ch->max_combined = mlx5e_get_netdev_max_channels(priv->netdev);
394+
ch->max_combined = priv->max_nch;
395395
ch->combined_count = priv->channels.params.num_channels;
396396
if (priv->xsk.refcnt) {
397397
/* The upper half are XSK queues. */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ static int validate_flow(struct mlx5e_priv *priv,
611611
return -ENOSPC;
612612

613613
if (fs->ring_cookie != RX_CLS_FLOW_DISC)
614-
if (!mlx5e_qid_validate(&priv->channels.params, fs->ring_cookie))
614+
if (!mlx5e_qid_validate(priv->profile, &priv->channels.params,
615+
fs->ring_cookie))
615616
return -EINVAL;
616617

617618
switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) {

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,10 +1677,10 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c,
16771677
struct mlx5e_channel_param *cparam)
16781678
{
16791679
struct mlx5e_priv *priv = c->priv;
1680-
int err, tc, max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
1680+
int err, tc;
16811681

16821682
for (tc = 0; tc < params->num_tc; tc++) {
1683-
int txq_ix = c->ix + tc * max_nch;
1683+
int txq_ix = c->ix + tc * priv->max_nch;
16841684

16851685
err = mlx5e_open_txqsq(c, c->priv->tisn[tc], txq_ix,
16861686
params, &cparam->sq, &c->sq[tc], tc);
@@ -2438,11 +2438,10 @@ int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv)
24382438

24392439
int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
24402440
{
2441-
const int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
24422441
int err;
24432442
int ix;
24442443

2445-
for (ix = 0; ix < max_nch; ix++) {
2444+
for (ix = 0; ix < priv->max_nch; ix++) {
24462445
err = mlx5e_create_rqt(priv, 1 /*size */, &tirs[ix].rqt);
24472446
if (unlikely(err))
24482447
goto err_destroy_rqts;
@@ -2460,10 +2459,9 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
24602459

24612460
void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
24622461
{
2463-
const int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
24642462
int i;
24652463

2466-
for (i = 0; i < max_nch; i++)
2464+
for (i = 0; i < priv->max_nch; i++)
24672465
mlx5e_destroy_rqt(priv, &tirs[i].rqt);
24682466
}
24692467

@@ -2557,7 +2555,7 @@ static void mlx5e_redirect_rqts(struct mlx5e_priv *priv,
25572555
mlx5e_redirect_rqt(priv, rqtn, MLX5E_INDIR_RQT_SIZE, rrp);
25582556
}
25592557

2560-
for (ix = 0; ix < mlx5e_get_netdev_max_channels(priv->netdev); ix++) {
2558+
for (ix = 0; ix < priv->max_nch; ix++) {
25612559
struct mlx5e_redirect_rqt_param direct_rrp = {
25622560
.is_rss = false,
25632561
{
@@ -2758,7 +2756,7 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv)
27582756
goto free_in;
27592757
}
27602758

2761-
for (ix = 0; ix < mlx5e_get_netdev_max_channels(priv->netdev); ix++) {
2759+
for (ix = 0; ix < priv->max_nch; ix++) {
27622760
err = mlx5_core_modify_tir(mdev, priv->direct_tir[ix].tirn,
27632761
in, inlen);
27642762
if (err)
@@ -2858,12 +2856,11 @@ static void mlx5e_netdev_set_tcs(struct net_device *netdev)
28582856

28592857
static void mlx5e_build_tc2txq_maps(struct mlx5e_priv *priv)
28602858
{
2861-
int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
28622859
int i, tc;
28632860

2864-
for (i = 0; i < max_nch; i++)
2861+
for (i = 0; i < priv->max_nch; i++)
28652862
for (tc = 0; tc < priv->profile->max_tc; tc++)
2866-
priv->channel_tc2txq[i][tc] = i + tc * max_nch;
2863+
priv->channel_tc2txq[i][tc] = i + tc * priv->max_nch;
28672864
}
28682865

28692866
static void mlx5e_build_tx2sq_maps(struct mlx5e_priv *priv)
@@ -2884,7 +2881,7 @@ static void mlx5e_build_tx2sq_maps(struct mlx5e_priv *priv)
28842881
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
28852882
{
28862883
int num_txqs = priv->channels.num * priv->channels.params.num_tc;
2887-
int num_rxqs = priv->channels.num * MLX5E_NUM_RQ_GROUPS;
2884+
int num_rxqs = priv->channels.num * priv->profile->rq_groups;
28882885
struct net_device *netdev = priv->netdev;
28892886

28902887
mlx5e_netdev_set_tcs(netdev);
@@ -3306,7 +3303,6 @@ int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc)
33063303

33073304
int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
33083305
{
3309-
const int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
33103306
struct mlx5e_tir *tir;
33113307
void *tirc;
33123308
int inlen;
@@ -3319,7 +3315,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
33193315
if (!in)
33203316
return -ENOMEM;
33213317

3322-
for (ix = 0; ix < max_nch; ix++) {
3318+
for (ix = 0; ix < priv->max_nch; ix++) {
33233319
memset(in, 0, inlen);
33243320
tir = &tirs[ix];
33253321
tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
@@ -3358,10 +3354,9 @@ void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv, bool inner_ttc)
33583354

33593355
void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv, struct mlx5e_tir *tirs)
33603356
{
3361-
const int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
33623357
int i;
33633358

3364-
for (i = 0; i < max_nch; i++)
3359+
for (i = 0; i < priv->max_nch; i++)
33653360
mlx5e_destroy_tir(priv->mdev, &tirs[i]);
33663361
}
33673362

@@ -3487,7 +3482,7 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s)
34873482
{
34883483
int i;
34893484

3490-
for (i = 0; i < mlx5e_get_netdev_max_channels(priv->netdev); i++) {
3485+
for (i = 0; i < priv->max_nch; i++) {
34913486
struct mlx5e_channel_stats *channel_stats = &priv->channel_stats[i];
34923487
struct mlx5e_rq_stats *xskrq_stats = &channel_stats->xskrq;
34933488
struct mlx5e_rq_stats *rq_stats = &channel_stats->rq;
@@ -4960,8 +4955,7 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
49604955
return err;
49614956

49624957
mlx5e_build_nic_params(mdev, &priv->xsk, rss, &priv->channels.params,
4963-
mlx5e_get_netdev_max_channels(netdev),
4964-
netdev->mtu);
4958+
priv->max_nch, netdev->mtu);
49654959

49664960
mlx5e_timestamp_init(priv);
49674961

@@ -5164,6 +5158,7 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
51645158
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe,
51655159
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
51665160
.max_tc = MLX5E_MAX_NUM_TC,
5161+
.rq_groups = MLX5E_NUM_RQ_GROUPS(XSK),
51675162
};
51685163

51695164
/* mlx5e generic netdev management API (move to en_common.c) */
@@ -5181,6 +5176,7 @@ int mlx5e_netdev_init(struct net_device *netdev,
51815176
priv->profile = profile;
51825177
priv->ppriv = ppriv;
51835178
priv->msglevel = MLX5E_MSG_LEVEL;
5179+
priv->max_nch = netdev->num_rx_queues / max_t(u8, profile->rq_groups, 1);
51845180
priv->max_opened_tc = 1;
51855181

51865182
mutex_init(&priv->state_lock);
@@ -5218,7 +5214,7 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
52185214

52195215
netdev = alloc_etherdev_mqs(sizeof(struct mlx5e_priv),
52205216
nch * profile->max_tc,
5221-
nch * MLX5E_NUM_RQ_GROUPS);
5217+
nch * profile->rq_groups);
52225218
if (!netdev) {
52235219
mlx5_core_err(mdev, "alloc_etherdev_mqs() failed\n");
52245220
return NULL;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,7 @@ static const struct mlx5e_profile mlx5e_rep_profile = {
17021702
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
17031703
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
17041704
.max_tc = 1,
1705+
.rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
17051706
};
17061707

17071708
static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
@@ -1719,6 +1720,7 @@ static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
17191720
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
17201721
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
17211722
.max_tc = MLX5E_MAX_NUM_TC,
1723+
.rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
17221724
};
17231725

17241726
static bool

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv)
172172

173173
memset(s, 0, sizeof(*s));
174174

175-
for (i = 0; i < mlx5e_get_netdev_max_channels(priv->netdev); i++) {
175+
for (i = 0; i < priv->max_nch; i++) {
176176
struct mlx5e_channel_stats *channel_stats =
177177
&priv->channel_stats[i];
178178
struct mlx5e_xdpsq_stats *xdpsq_red_stats = &channel_stats->xdpsq;
@@ -1395,7 +1395,7 @@ static const struct counter_desc ch_stats_desc[] = {
13951395

13961396
static int mlx5e_grp_channels_get_num_stats(struct mlx5e_priv *priv)
13971397
{
1398-
int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
1398+
int max_nch = priv->max_nch;
13991399

14001400
return (NUM_RQ_STATS * max_nch) +
14011401
(NUM_CH_STATS * max_nch) +
@@ -1409,8 +1409,8 @@ static int mlx5e_grp_channels_get_num_stats(struct mlx5e_priv *priv)
14091409
static int mlx5e_grp_channels_fill_strings(struct mlx5e_priv *priv, u8 *data,
14101410
int idx)
14111411
{
1412-
int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
14131412
bool is_xsk = priv->xsk.ever_used;
1413+
int max_nch = priv->max_nch;
14141414
int i, j, tc;
14151415

14161416
for (i = 0; i < max_nch; i++)
@@ -1452,8 +1452,8 @@ static int mlx5e_grp_channels_fill_strings(struct mlx5e_priv *priv, u8 *data,
14521452
static int mlx5e_grp_channels_fill_stats(struct mlx5e_priv *priv, u64 *data,
14531453
int idx)
14541454
{
1455-
int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
14561455
bool is_xsk = priv->xsk.ever_used;
1456+
int max_nch = priv->max_nch;
14571457
int i, j, tc;
14581458

14591459
for (i = 0; i < max_nch; i++)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ int mlx5i_init(struct mlx5_core_dev *mdev,
8888
netdev->mtu = netdev->max_mtu;
8989

9090
mlx5e_build_nic_params(mdev, NULL, &priv->rss_params, &priv->channels.params,
91-
mlx5e_get_netdev_max_channels(netdev),
92-
netdev->mtu);
91+
priv->max_nch, netdev->mtu);
9392
mlx5i_build_nic_params(mdev, &priv->channels.params);
9493

9594
mlx5e_timestamp_init(priv);
@@ -118,11 +117,10 @@ void mlx5i_cleanup(struct mlx5e_priv *priv)
118117

119118
static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
120119
{
121-
int max_nch = mlx5e_get_netdev_max_channels(priv->netdev);
122120
struct mlx5e_sw_stats s = { 0 };
123121
int i, j;
124122

125-
for (i = 0; i < max_nch; i++) {
123+
for (i = 0; i < priv->max_nch; i++) {
126124
struct mlx5e_channel_stats *channel_stats;
127125
struct mlx5e_rq_stats *rq_stats;
128126

@@ -436,6 +434,7 @@ static const struct mlx5e_profile mlx5i_nic_profile = {
436434
.rx_handlers.handle_rx_cqe = mlx5i_handle_rx_cqe,
437435
.rx_handlers.handle_rx_cqe_mpwqe = NULL, /* Not supported */
438436
.max_tc = MLX5I_MAX_NUM_TC,
437+
.rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
439438
};
440439

441440
/* mlx5i netdev NDos */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static const struct mlx5e_profile mlx5i_pkey_nic_profile = {
355355
.rx_handlers.handle_rx_cqe = mlx5i_handle_rx_cqe,
356356
.rx_handlers.handle_rx_cqe_mpwqe = NULL, /* Not supported */
357357
.max_tc = MLX5I_MAX_NUM_TC,
358+
.rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR),
358359
};
359360

360361
const struct mlx5e_profile *mlx5i_pkey_get_profile(void)

0 commit comments

Comments
 (0)