From patchwork Thu Feb 11 14:16:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 380997 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2121547jah; Thu, 11 Feb 2021 06:28:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWA91JUogICCsAlbT3ipCbX6LERw3XApUsBp5fAzKGtPK3V4ZnBpSjkKy/8tvvhpHueoIG X-Received: by 2002:a17:906:3c1:: with SMTP id c1mr8433071eja.428.1613053705288; Thu, 11 Feb 2021 06:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613053705; cv=none; d=google.com; s=arc-20160816; b=OwqOh8/1bFJrjk8RTlf7nNBOaYj8syr2/lLOpvbFG4v9r7CXCK7OJOId/jqxDcvDVF eGLOws25b5rIPddet42BGxg6Qvt+zfksmbS32hKzynIrzWkQHBfO0Bhf48u5mil6vqSo 2AkGy88+eGF602NiO8+XCO1NVClV6vYxF1tkA0E6UE/9N+MtnHujq+CuL+Ieyc5r8zsY a4lpQBLJoc5ZAz1vUJluRMB+7gh45AZTT0CyKNnqWqvPJCCVksIgERS08ipzCCJGQ0Y2 MhWt+wr/4LBGgA6FK4wNJ/G45No6RuJKNyB35jPlLtS0bKQIc2pgtjDXAr6M3Qwuvg6C FJoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from; bh=dW4uS4Ic5abRpi+2aiB83ervdiXwBapPwfxqYKxYRR8=; b=hRibhPfnrweWrjuXgoY2yUSrToouxU3Ox3wzz/aalwuRofhvv2effKM8geq9NdEO7+ F6uAhGBUrNt5QVGe9sQafppg+WJMtPZ5aHOugg83O0exPN2Nb2J27Tcy0NHLL6OxtUvE x2RyDtYJi6EmiCZK2vrM/YyoO9pksQtXhsxsIqVsdHVaLrhdcFi4UdI1WzrzanwpTxHo 51fVsncVZDccugbIwkv/2ZEy2ScRgjUjXXyswCkXjCBx7c8EpZHNDQAWwr4QEIAyYhAb /zADmDs3OWnKJOQobC9KiuAzh4a/mpx7er4/zhM3b0QYrj4tLo+3ecIjRMvvqEcqzRN/ k6Xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id n5si3874579eja.433.2021.02.11.06.28.25; Thu, 11 Feb 2021 06:28:25 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52DB11CC55D; Thu, 11 Feb 2021 15:28:04 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 46E3E1CC38A for ; Thu, 11 Feb 2021 15:28:00 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id C77BD1A05EF; Thu, 11 Feb 2021 15:27:59 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 8740C1A05D6; Thu, 11 Feb 2021 15:27:58 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 86986402D0; Thu, 11 Feb 2021 15:27:56 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org, ferruh.yigit@intel.com Date: Thu, 11 Feb 2021 19:46:03 +0530 Message-Id: <20210211141620.12482-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210211141620.12482-1-hemant.agrawal@nxp.com> References: <20210120142723.14090-1-hemant.agrawal@nxp.com> <20210211141620.12482-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 03/20] net/dpaa2: fix link get API implementation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Rohit Raj According to DPDK Documentation, rte_eth_link_get API can wait upto 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 wasn't 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 doesn't 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 Acked-by: Hemant Agrawal --- drivers/net/dpaa2/dpaa2_ethdev.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) -- 2.17.1 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));