Skip to content

Commit 7ca560b

Browse files
Eran Ben ElishaSaeed Mahameed
authored andcommitted
net/mlx5e: Poll event queue upon TX timeout before performing full channels recovery
Up until this patch, on every TX timeout we would try to do channels recovery. However, in case of a lost interrupt for an EQ, the channel associated to it cannot be recovered if reopened as it would never get another interrupt on sent/received traffic, and eventually ends up with another TX timeout (Restarting the EQ is not part of channel recovery). This patch adds a mechanism for explicitly polling EQ in case of a TX timeout in order to recover from a lost interrupt. If this is not the case (no pending EQEs), perform a channels full recovery as usual. Once a lost EQE is recovered, it triggers the NAPI to run and handle all pending completions. This will free some budget in the bql (via calling netdev_tx_completed_queue) or by clearing pending TXWQEs and waking up the queue. One of the above actions will move the queue to be ready for transmit again. Signed-off-by: Eran Ben Elisha <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 3a32b26 commit 7ca560b

File tree

3 files changed

+55
-15
lines changed

3 files changed

+55
-15
lines changed

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

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,40 +3757,61 @@ static netdev_features_t mlx5e_features_check(struct sk_buff *skb,
37573757
return features;
37583758
}
37593759

3760+
static bool mlx5e_tx_timeout_eq_recover(struct net_device *dev,
3761+
struct mlx5e_txqsq *sq)
3762+
{
3763+
struct mlx5e_priv *priv = netdev_priv(dev);
3764+
struct mlx5_core_dev *mdev = priv->mdev;
3765+
int irqn_not_used, eqn;
3766+
struct mlx5_eq *eq;
3767+
u32 eqe_count;
3768+
3769+
if (mlx5_vector2eqn(mdev, sq->cq.mcq.vector, &eqn, &irqn_not_used))
3770+
return false;
3771+
3772+
eq = mlx5_eqn2eq(mdev, eqn);
3773+
if (IS_ERR(eq))
3774+
return false;
3775+
3776+
netdev_err(dev, "EQ 0x%x: Cons = 0x%x, irqn = 0x%x\n",
3777+
eqn, eq->cons_index, eq->irqn);
3778+
3779+
eqe_count = mlx5_eq_poll_irq_disabled(eq);
3780+
if (!eqe_count)
3781+
return false;
3782+
3783+
netdev_err(dev, "Recover %d eqes on EQ 0x%x\n", eqe_count, eq->eqn);
3784+
return true;
3785+
}
3786+
37603787
static void mlx5e_tx_timeout(struct net_device *dev)
37613788
{
37623789
struct mlx5e_priv *priv = netdev_priv(dev);
3763-
bool sched_work = false;
3790+
bool reopen_channels = false;
37643791
int i;
37653792

37663793
netdev_err(dev, "TX timeout detected\n");
37673794

37683795
for (i = 0; i < priv->channels.num * priv->channels.params.num_tc; i++) {
37693796
struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, i);
37703797
struct mlx5e_txqsq *sq = priv->txq2sq[i];
3771-
struct mlx5_core_dev *mdev = priv->mdev;
3772-
int irqn_not_used, eqn;
3773-
struct mlx5_eq *eq;
37743798

37753799
if (!netif_xmit_stopped(dev_queue))
37763800
continue;
3777-
sched_work = true;
3778-
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
37793801
netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x, usecs since last trans: %u\n",
37803802
i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc,
37813803
jiffies_to_usecs(jiffies - dev_queue->trans_start));
37823804

3783-
if (mlx5_vector2eqn(mdev, sq->cq.mcq.vector, &eqn,
3784-
&irqn_not_used))
3785-
continue;
3786-
3787-
eq = mlx5_eqn2eq(mdev, eqn);
3788-
if (!IS_ERR(eq))
3789-
netdev_err(dev, "EQ 0x%x: Cons = 0x%x, irqn = 0x%x\n",
3790-
eqn, eq->cons_index, eq->irqn);
3805+
/* If we recover a lost interrupt, most likely TX timeout will
3806+
* be resolved, skip reopening channels
3807+
*/
3808+
if (!mlx5e_tx_timeout_eq_recover(dev, sq)) {
3809+
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
3810+
reopen_channels = true;
3811+
}
37913812
}
37923813

3793-
if (sched_work && test_bit(MLX5E_STATE_OPENED, &priv->state))
3814+
if (reopen_channels && test_bit(MLX5E_STATE_OPENED, &priv->state))
37943815
schedule_work(&priv->tx_timeout_work);
37953816
}
37963817

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,24 @@ static irqreturn_t mlx5_eq_int(int irq, void *eq_ptr)
530530
return IRQ_HANDLED;
531531
}
532532

533+
/* Some architectures don't latch interrupts when they are disabled, so using
534+
* mlx5_eq_poll_irq_disabled could end up losing interrupts while trying to
535+
* avoid losing them. It is not recommended to use it, unless this is the last
536+
* resort.
537+
*/
538+
u32 mlx5_eq_poll_irq_disabled(struct mlx5_eq *eq)
539+
{
540+
u32 count_eqe;
541+
542+
disable_irq(eq->irqn);
543+
count_eqe = eq->cons_index;
544+
mlx5_eq_int(eq->irqn, eq);
545+
count_eqe = eq->cons_index - count_eqe;
546+
enable_irq(eq->irqn);
547+
548+
return count_eqe;
549+
}
550+
533551
static void init_eq_buf(struct mlx5_eq *eq)
534552
{
535553
struct mlx5_eqe *eqe;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ int mlx5_destroy_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,
116116
int mlx5_wait_for_vf_pages(struct mlx5_core_dev *dev);
117117
u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev);
118118
struct mlx5_eq *mlx5_eqn2eq(struct mlx5_core_dev *dev, int eqn);
119+
u32 mlx5_eq_poll_irq_disabled(struct mlx5_eq *eq);
119120
void mlx5_cq_tasklet_cb(unsigned long data);
120121

121122
int mlx5_query_pcam_reg(struct mlx5_core_dev *dev, u32 *pcam, u8 feature_group,

0 commit comments

Comments
 (0)