patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Michal Krawczyk <mk@semihalf.com>
To: dev@dpdk.org
Cc: shaibran@amazon.com, upstream@semihalf.com,
	Dawid Gorecki <dgr@semihalf.com>,
	stable@dpdk.org, Michal Krawczyk <mk@semihalf.com>
Subject: [PATCH 15/21] net/ena: check if reset was already triggered
Date: Tue, 22 Feb 2022 17:06:28 +0100	[thread overview]
Message-ID: <20220222160634.24489-16-mk@semihalf.com> (raw)
In-Reply-To: <20220222160634.24489-1-mk@semihalf.com>

From: Dawid Gorecki <dgr@semihalf.com>

When triggering the reset, no check was performed to see if the reset
was already triggered. This could result in original reset reaon 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 occurences of manually setting the reset with
ena_trigger_reset call.

Fixes: 2081d5e2e92d ("net/ena: add reset routine")
Cc: stable@dpdk.org

Signed-off-by: Dawid Gorecki <dgr@semihalf.com>
Reviewed-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Shai Brandes <shaibran@amazon.com>
---
 drivers/net/ena/ena_ethdev.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 0766f613b0..d413111b08 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -539,6 +539,15 @@ ENA_PROXY_DESC(ena_com_indirect_table_get, ENA_MP_IND_TBL_GET,
 }),
 	struct ena_com_dev *ena_dev, u32 *ind_tbl);
 
+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 ena_ring *rx_ring,
 				       struct rte_mbuf *mbuf,
 				       struct ena_com_rx_ctx *ena_rx_ctx,
@@ -666,8 +675,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;
 }
 
@@ -1783,8 +1791,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;
 	}
 }
@@ -1794,8 +1801,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);
 	}
 }
 
@@ -2606,14 +2612,13 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				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;
 		}
 
@@ -2978,9 +2983,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;
 	}
 
-- 
2.25.1


  parent reply	other threads:[~2022-02-22 16:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220222160634.24489-1-mk@semihalf.com>
2022-02-22 16:06 ` [PATCH 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-22 16:06 ` Michal Krawczyk [this message]
2022-02-22 16:06 ` [PATCH 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-22 16:06 ` [PATCH 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-22 16:06 ` [PATCH 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
     [not found] ` <20220222181146.28882-1-mk@semihalf.com>
2022-02-22 18:11   ` [PATCH v2 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
     [not found]   ` <20220223121944.24156-1-mk@semihalf.com>
2022-02-23 12:19     ` [PATCH v3 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220222160634.24489-16-mk@semihalf.com \
    --to=mk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=dgr@semihalf.com \
    --cc=shaibran@amazon.com \
    --cc=stable@dpdk.org \
    --cc=upstream@semihalf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).