From patchwork Wed Jan 20 14:27:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 367039 Delivered-To: patch@linaro.org Received: by 2002:a17:906:24d5:0:0:0:0 with SMTP id f21csp227125ejb; Wed, 20 Jan 2021 06:38:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqZSJLVk6QIyiAKDdBNnmhntGFMbEACb+rfp3Et9zPQL8w9GRBQtKbj3k+VYIsPMSjHnET X-Received: by 2002:a05:6402:513:: with SMTP id m19mr7639825edv.229.1611153506308; Wed, 20 Jan 2021 06:38:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611153506; cv=none; d=google.com; s=arc-20160816; b=YO/cnrqZA8Na7F78DDx4lIBIeiyCh+IzMfw6sXKfncu3xf8kJ/2kt2KtK6Et2+8ZT4 Z4WCfpsSW7lmLzCJH9TqFD2fMTDeqnYehAW0f3npJ3WtDLTYkOConQ6NcNBxWGtBPRGx gGhfBXxwVvZHeBnbM7Ah+RJ3V3KEJ4fqY7eIfyRsRag79Po6Y0WBz9kBJCTFjTAYVjWQ IBezL/FyhycmBY9+EGEO9hPlyM2+B1ZWjB+JmamS/le9BSkpFLsUUhobs0ptcuJfo/HQ aXEc816uoMk/AT/kRtvAdE78PIoJXuIPjfaaR/pOUxRo4up3PNiBXZvdjtDRB/QWNeez Rfkg== 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=eUwe9k/j7YrpEwSzTb/UqqqAdZZi680+YrBwNjlH6iM=; b=hYQPf42wg0MmuhkY0hLvL8tVfe05aLZE94qferVOgokdheBRZxPQX7KaDLvNN6dL0L yBe+cuFz/rbfb5N7qRMPjREL1FXIL+N7Z5s5SJDB+9+hBhEVKVPBMhRWJ+GmrkxxPBaE G7nUcwuq7BlVUHMsrYVkv6ZUGT+vR5LsxtZfFgOz2SwKlRI8Nf24ZtRCwLwhv3chZ93b CqyFXO5JF1+EyB1lhxgMSLNbgzIvxHY/DEgdu6mVZgTIvqvc3FXU7Y8udIeoKX3z9Jk+ K5H3FPgtSdCpvk+3xHoGZwsp/Di8+8Upb8fTljhHIsHyCt4he5hb0e0ACsM/I7ARz008 V94A== 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 l15si715045ejn.754.2021.01.20.06.38.26; Wed, 20 Jan 2021 06:38:26 -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 192F5140D5B; Wed, 20 Jan 2021 15:38:21 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 702B3140D21 for ; Wed, 20 Jan 2021 15:38:19 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 02E311A14B4; Wed, 20 Jan 2021 15:38:19 +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 B38871A14A8; Wed, 20 Jan 2021 15:38:17 +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 12BEB4031F; Wed, 20 Jan 2021 15:38:15 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org, ferruh.yigit@intel.com Date: Wed, 20 Jan 2021 19:57:17 +0530 Message-Id: <20210120142723.14090-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210120142723.14090-1-hemant.agrawal@nxp.com> References: <20210120142723.14090-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 2/7] 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 6f38da3cce..5c1a12b841 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));