patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, stable@dpdk.org, Rohit Raj <rohit.raj@nxp.com>
Subject: [dpdk-stable] [PATCH v3 03/23] net/dpaa2: fix link get API implementation
Date: Wed, 24 Feb 2021 18:12:51 +0530	[thread overview]
Message-ID: <20210224124311.29799-4-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20210224124311.29799-1-hemant.agrawal@nxp.com>

From: Rohit Raj <rohit.raj@nxp.com>

According to DPDK Documentation, rte_eth_link_get API can wait up to 9
seconds for auto-negotiation to finish and then returns link status.

In current implementation of rte_eth_link_get API in DPAA2 drivers, it
was not waiting for auto negotiation to finish and was returning link
status DOWN
It can cause issues with DPDK applications which relies on
rte_eth_link_get API for link status and does not support link status
interrupt.
Similar kind of issue was seen in TRex Application.

This patch fixes this bug by adding wait for up to 9 seconds for auto
negotiation to finish.

Fixes: c56c86ff87c1 ("net/dpaa2: update link status")
Cc: stable@dpdk.org

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 38774e255b..a81c73438e 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -31,6 +31,8 @@
 
 #define DRIVER_LOOPBACK_MODE "drv_loopback"
 #define DRIVER_NO_PREFETCH_MODE "drv_no_prefetch"
+#define CHECK_INTERVAL         100  /* 100ms */
+#define MAX_REPEAT_TIME        90   /* 9s (90 * 100ms) in total */
 
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
@@ -1805,23 +1807,32 @@ dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
 /* return 0 means link status changed, -1 means not changed */
 static int
 dpaa2_dev_link_update(struct rte_eth_dev *dev,
-			int wait_to_complete __rte_unused)
+		      int wait_to_complete)
 {
 	int ret;
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
 	struct rte_eth_link link;
 	struct dpni_link_state state = {0};
+	uint8_t count;
 
 	if (dpni == NULL) {
 		DPAA2_PMD_ERR("dpni is NULL");
 		return 0;
 	}
 
-	ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
-	if (ret < 0) {
-		DPAA2_PMD_DEBUG("error: dpni_get_link_state %d", ret);
-		return -1;
+	for (count = 0; count <= MAX_REPEAT_TIME; count++) {
+		ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token,
+					  &state);
+		if (ret < 0) {
+			DPAA2_PMD_DEBUG("error: dpni_get_link_state %d", ret);
+			return -1;
+		}
+		if (state.up == ETH_LINK_DOWN &&
+		    wait_to_complete)
+			rte_delay_ms(CHECK_INTERVAL);
+		else
+			break;
 	}
 
 	memset(&link, 0, sizeof(struct rte_eth_link));
-- 
2.17.1


  parent reply	other threads:[~2021-02-24 12:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210211141620.12482-1-hemant.agrawal@nxp.com>
     [not found] ` <20210224124311.29799-1-hemant.agrawal@nxp.com>
2021-02-24 12:42   ` [dpdk-stable] [PATCH v3 01/23] bus/fslmc: fix to use ci value for qbman 5.0 Hemant Agrawal
2021-02-24 12:42   ` [dpdk-stable] [PATCH v3 02/23] bus/dpaa: fix statistics reading Hemant Agrawal
2021-02-24 12:42   ` Hemant Agrawal [this message]
2021-02-24 12:42   ` [dpdk-stable] [PATCH v3 04/23] net/dpaa: fix link get API implementation Hemant Agrawal

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=20210224124311.29799-4-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=rohit.raj@nxp.com \
    --cc=stable@dpdk.org \
    /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).