From patchwork Wed Feb 24 12:42:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 386840 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp341772jap; Wed, 24 Feb 2021 04:43:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVC3Fl1DeWt/+PCvIZNl8XwyGOtWaq2TQUvDdSqjfthJJmXsqtEcFgbamoDeEuL9QdhMNB X-Received: by 2002:a50:fe89:: with SMTP id d9mr33394766edt.57.1614170622932; Wed, 24 Feb 2021 04:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614170622; cv=none; d=google.com; s=arc-20160816; b=vMxh/yrOww1byHVD1zl7iAnOayGaPqTKD609sEEKgj2kIdjC+Bm2oV58JQSvcNdnZ4 P0y90XthqCLml1YWsaMcDDb7Rkr5QMjf5EGfZAOTicKvOkZSIe2o/nShod4vhJeyZ3Az mmEO06mRoEAqxuuZv3eIB8lM/5aWz+CareCsIGCrEIcsOkGf/nZndG1nxtQJfZbskwvw rZ6TBxI4boVwxrZX8Nd5A+hLzX0xiqAYRwTCbXoKENkGJbAOIwNubOAVM8bp8+HF6Q3V sm+rDXI7KFzndS0eJqIbZpUEdglVI0b3EdY4MOx3+67wwBlKfPfhTp03yLLvzRIygn/f EHnw== 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:cc:to:from; bh=XZgMyK5Ssqw5jsgaqKBOWlWX7J1YTQlgiUXClkesqks=; b=Xyrg9YmWeEgNohiRgkry2ROhIPO6UvCtvPZ08CAxws8B3tSY481lcQr+XqFLUKZmhi 6XuFFRLISzLYZAYuHKMgr6UlWLV6DmlMnFShLQoOONKOyjEAEFV7rJdWLCFN9wzNO3Bz I8SMaHu4B2KnYI0NurCbvVnIv/YcIgBNx2i2VTANwRFiQ8/rPcphmqyUJSfNHTj0Hfge tvZwj6zX1tD+7AjgDtKuqeOgtJTJgaOF3A5OOSQYz124KM3sIBBYvlnxNsVMAvn8AA+f HLlzyTPidsjILtYj8ajnVj+iStbXNvbEfCnAceh8oZrBcATO95PPq0uY8exsSJSAhRQV BHiQ== 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 c13si1264561eje.65.2021.02.24.04.43.42; Wed, 24 Feb 2021 04:43:42 -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 857B6160845; Wed, 24 Feb 2021 13:43:24 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id C72E2160835; Wed, 24 Feb 2021 13:43:21 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 922121A039F; Wed, 24 Feb 2021 13:43:21 +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 F41541A009C; Wed, 24 Feb 2021 13:43:18 +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 59D7F40281; Wed, 24 Feb 2021 13:43:15 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, stable@dpdk.org, Rohit Raj Date: Wed, 24 Feb 2021 18:12:51 +0530 Message-Id: <20210224124311.29799-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210224124311.29799-1-hemant.agrawal@nxp.com> References: <20210211141620.12482-1-hemant.agrawal@nxp.com> <20210224124311.29799-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 03/23] 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 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 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));