Skip to content

Commit

Permalink
net/mlx5e: Trigger NAPI after activating an SQ
Browse files Browse the repository at this point in the history
If an SQ is deactivated and reactivated again, some packets could be
sent after MLX5E_SQ_STATE_ENABLED is cleared, but before
netif_tx_stop_queue, meaning that NAPI might miss some completions. In
order to handle them, make sure to trigger NAPI after SQ activation in
all cases where it can be relevant. Regular SQs, XDP SQs and XSK SQs are
good. Missing cases added: after recovery, after activating HTB SQs and
after activating PTP SQs.

Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Maxim Mikityanskiy authored and Saeed Mahameed committed Feb 4, 2023
1 parent a738518 commit 79efecb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ struct mlx5e_txqsq {
struct mlx5_clock *clock;
struct net_device *netdev;
struct mlx5_core_dev *mdev;
struct mlx5e_channel *channel;
struct mlx5e_priv *priv;

/* control path */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,8 @@ void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c)
if (test_bit(MLX5E_PTP_STATE_RX, c->state)) {
mlx5e_ptp_rx_set_fs(c->priv);
mlx5e_activate_rq(&c->rq);
mlx5e_trigger_napi_sched(&c->napi);
}
mlx5e_trigger_napi_sched(&c->napi);
}

void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c)
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ static int mlx5e_tx_reporter_err_cqe_recover(void *ctx)
sq->stats->recover++;
clear_bit(MLX5E_SQ_STATE_RECOVERING, &sq->state);
mlx5e_activate_txqsq(sq);
if (sq->channel)
mlx5e_trigger_napi_icosq(sq->channel);
else
mlx5e_trigger_napi_sched(sq->cq.napi);

return 0;
out:
Expand Down
15 changes: 9 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
sq->mkey_be = c->mkey_be;
sq->netdev = c->netdev;
sq->mdev = c->mdev;
sq->channel = c;
sq->priv = c->priv;
sq->ch_ix = c->ix;
sq->txq_ix = txq_ix;
Expand Down Expand Up @@ -2482,8 +2483,6 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)
mlx5e_activate_xsk(c);
else
mlx5e_activate_rq(&c->rq);

mlx5e_trigger_napi_icosq(c);
}

static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
Expand Down Expand Up @@ -2575,13 +2574,19 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
return err;
}

static void mlx5e_activate_channels(struct mlx5e_channels *chs)
static void mlx5e_activate_channels(struct mlx5e_priv *priv, struct mlx5e_channels *chs)
{
int i;

for (i = 0; i < chs->num; i++)
mlx5e_activate_channel(chs->c[i]);

if (priv->htb)
mlx5e_qos_activate_queues(priv);

for (i = 0; i < chs->num; i++)
mlx5e_trigger_napi_icosq(chs->c[i]);

if (chs->ptp)
mlx5e_ptp_activate_channel(chs->ptp);
}
Expand Down Expand Up @@ -2888,9 +2893,7 @@ static void mlx5e_build_txq_maps(struct mlx5e_priv *priv)
void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
{
mlx5e_build_txq_maps(priv);
mlx5e_activate_channels(&priv->channels);
if (priv->htb)
mlx5e_qos_activate_queues(priv);
mlx5e_activate_channels(priv, &priv->channels);
mlx5e_xdp_tx_enable(priv);

/* dev_watchdog() wants all TX queues to be started when the carrier is
Expand Down

0 comments on commit 79efecb

Please sign in to comment.