Skip to content

Commit

Permalink
net/ena: fix reset reason being overwritten
Browse files Browse the repository at this point in the history
[ upstream commit 2bae75e ]

When triggering the reset, no check was performed to see if the reset
was already triggered. This could result in original reset reason being
overwritten. Add ena_trigger_reset helper function, which checks if the
reset was triggered and only sets the reset reason if the reset wasn't
triggered yet. Replace all occurrences of manually setting the reset
with ena_trigger_reset call.

Fixes: 2081d5e ("net/ena: add reset routine")

Signed-off-by: Dawid Gorecki <dgr@semihalf.com>
Reviewed-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Shai Brandes <shaibran@amazon.com>
  • Loading branch information
semihalf-gorecki-dawid authored and bluca committed Feb 28, 2022
1 parent b1d55a4 commit 5bb3ff7
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions drivers/net/ena/ena_ethdev.c
Expand Up @@ -303,6 +303,15 @@ void ena_rss_key_fill(void *key, size_t size)
rte_memcpy(key, default_key, size);
}

static inline void ena_trigger_reset(struct ena_adapter *adapter,
enum ena_regs_reset_reason_types reason)
{
if (likely(!adapter->trigger_reset)) {
adapter->reset_reason = reason;
adapter->trigger_reset = true;
}
}

static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
struct ena_com_rx_ctx *ena_rx_ctx)
{
Expand Down Expand Up @@ -420,8 +429,7 @@ static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id)

/* Trigger device reset */
++tx_ring->tx_stats.bad_req_id;
tx_ring->adapter->reset_reason = ENA_REGS_RESET_INV_TX_REQ_ID;
tx_ring->adapter->trigger_reset = true;
ena_trigger_reset(tx_ring->adapter, ENA_REGS_RESET_INV_TX_REQ_ID);
return -EFAULT;
}

Expand Down Expand Up @@ -1630,8 +1638,7 @@ static void check_for_missing_keep_alive(struct ena_adapter *adapter)
if (unlikely((rte_get_timer_cycles() - adapter->timestamp_wd) >=
adapter->keep_alive_timeout)) {
PMD_DRV_LOG(ERR, "Keep alive timeout\n");
adapter->reset_reason = ENA_REGS_RESET_KEEP_ALIVE_TO;
adapter->trigger_reset = true;
ena_trigger_reset(adapter, ENA_REGS_RESET_KEEP_ALIVE_TO);
++adapter->dev_stats.wd_expired;
}
}
Expand All @@ -1641,8 +1648,7 @@ static void check_for_admin_com_state(struct ena_adapter *adapter)
{
if (unlikely(!ena_com_get_admin_running_state(&adapter->ena_dev))) {
PMD_DRV_LOG(ERR, "ENA admin queue is not in running state!\n");
adapter->reset_reason = ENA_REGS_RESET_ADMIN_TO;
adapter->trigger_reset = true;
ena_trigger_reset(adapter, ENA_REGS_RESET_ADMIN_TO);
}
}

Expand Down Expand Up @@ -2311,14 +2317,13 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
PMD_DRV_LOG(ERR, "ena_com_rx_pkt error %d\n", rc);
if (rc == ENA_COM_NO_SPACE) {
++rx_ring->rx_stats.bad_desc_num;
rx_ring->adapter->reset_reason =
ENA_REGS_RESET_TOO_MANY_RX_DESCS;
ena_trigger_reset(rx_ring->adapter,
ENA_REGS_RESET_TOO_MANY_RX_DESCS);
} else {
++rx_ring->rx_stats.bad_req_id;
rx_ring->adapter->reset_reason =
ENA_REGS_RESET_INV_RX_REQ_ID;
ena_trigger_reset(rx_ring->adapter,
ENA_REGS_RESET_INV_RX_REQ_ID);
}
rx_ring->adapter->trigger_reset = true;
return 0;
}

Expand Down Expand Up @@ -2707,9 +2712,8 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf)
if (unlikely(rc)) {
PMD_DRV_LOG(ERR, "Failed to prepare Tx buffers, rc: %d\n", rc);
++tx_ring->tx_stats.prepare_ctx_err;
tx_ring->adapter->reset_reason =
ENA_REGS_RESET_DRIVER_INVALID_STATE;
tx_ring->adapter->trigger_reset = true;
ena_trigger_reset(tx_ring->adapter,
ENA_REGS_RESET_DRIVER_INVALID_STATE);
return rc;
}

Expand Down

0 comments on commit 5bb3ff7

Please sign in to comment.