diff mbox series

[34/35] net/ionic: retry init commands up to five times

Message ID 20221007174336.54354-35-andrew.boyer@amd.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series net/ionic: updates for 22.11 release | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Boyer, Andrew Oct. 7, 2022, 5:43 p.m. UTC
In some configurations, the FW may return EAGAIN if it is not able
to respond to commands immediately. Retry the init commands in this
case to prevent errors from reaching the client.

Fix up some return-code stuff while here, for clarity.

Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
---
 drivers/net/ionic/ionic_dev.h  |  1 +
 drivers/net/ionic/ionic_lif.c  | 14 ++++++++++++++
 drivers/net/ionic/ionic_main.c |  4 ++--
 3 files changed, 17 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index d696de45e0..4d07d9206e 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -24,6 +24,7 @@ 
 
 #define IONIC_DEVCMD_TIMEOUT		5	/* devcmd_timeout */
 #define IONIC_DEVCMD_CHECK_PERIOD_US	10	/* devcmd status chk period */
+#define IONIC_DEVCMD_RETRY_WAIT_US	20000
 
 #define IONIC_ALIGN			4096
 
diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c
index 0affdd9dc4..bc6de83d56 100644
--- a/drivers/net/ionic/ionic_lif.c
+++ b/drivers/net/ionic/ionic_lif.c
@@ -1423,10 +1423,17 @@  ionic_lif_adminq_init(struct ionic_lif *lif)
 	struct ionic_admin_qcq *aqcq = lif->adminqcq;
 	struct ionic_queue *q = &aqcq->qcq.q;
 	struct ionic_q_init_comp comp;
+	uint32_t retries = 5;
 	int err;
 
+retry_adminq_init:
 	ionic_dev_cmd_adminq_init(idev, &aqcq->qcq);
 	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+	if (err == -EAGAIN && retries > 0) {
+		retries--;
+		rte_delay_us_block(IONIC_DEVCMD_RETRY_WAIT_US);
+		goto retry_adminq_init;
+	}
 	if (err)
 		return err;
 
@@ -1713,12 +1720,19 @@  ionic_lif_init(struct ionic_lif *lif)
 {
 	struct ionic_dev *idev = &lif->adapter->idev;
 	struct ionic_lif_init_comp comp;
+	uint32_t retries = 5;
 	int err;
 
 	memset(&lif->stats_base, 0, sizeof(lif->stats_base));
 
+retry_lif_init:
 	ionic_dev_cmd_lif_init(idev, lif->info_pa);
 	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+	if (err == -EAGAIN && retries > 0) {
+		retries--;
+		rte_delay_us_block(IONIC_DEVCMD_RETRY_WAIT_US);
+		goto retry_lif_init;
+	}
 	if (err)
 		return err;
 
diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c
index 996af0a51f..3d8157dac3 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -313,10 +313,10 @@  ionic_dev_cmd_check_error(struct ionic_dev *idev)
 	uint8_t status;
 
 	status = ionic_dev_cmd_status(idev);
-	if (status == 0)
+	if (status == IONIC_RC_SUCCESS)
 		return 0;
 
-	return -EIO;
+	return (status == IONIC_RC_EAGAIN) ? -EAGAIN : -EIO;
 }
 
 int