From patchwork Thu Jul 27 07:23:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9866377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF9496038C for ; Thu, 27 Jul 2017 07:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B04DA285E4 for ; Thu, 27 Jul 2017 07:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A377B28615; Thu, 27 Jul 2017 07:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36D8228696 for ; Thu, 27 Jul 2017 07:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=xBdfdt+VDWqT/QL7y6vAZ/6O9qtEqbkviBtU3Rx7s7I=; b=ZBf HSpKNCBc/P9DuYBlzTxBjKFk6Rvw9sReQO1zFIMiuSdPDU1etY97JeTbZKWZV7yA+42V7L9iUf4Nq nG5AhtIV5kcCtRp3u1OpFcaRG3Joc9KnAhY0agM/dsA+O+PCli9u7RICYWygfY8YRAy1E4J1XJqYV jkAiqe96mfWJbgsmZ2trjzjkKsKRys9/cSC9niOLnV7OXNZotv5Bb8C8jtCtzkHYFF0UBkp547RBm Wyg0cXzdfeC6nK2y1mStNb6OnHpWi7XrqpvizBH2HVHzYC99ilXMkx2JPbuL8+S1gFr5IyI5PWz8Z jvdoyLnOIxwhZzR6GaRyVSNxdKYD6WQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dad99-0000zq-5I; Thu, 27 Jul 2017 07:23:47 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dad94-0000jY-Vb for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2017 07:23:44 +0000 Received: by mail-pf0-x243.google.com with SMTP id y25so10061321pfk.4 for ; Thu, 27 Jul 2017 00:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=nAGfV/IOelihK7dDW91o+/lYOLpjtO8skiwGsjrAl5k=; b=Uc+m/qIoM/RiwdnLPZciWHwghAUGXVfJOJkT7kLcnc0USI344b8QBMVq+aDPAEJqlH VbtWOWnucb2ZQcKvGsBd9G+q1YKBq9f6BWjZFrdCkMR+vCDRnsV5UsT/6NdkY79HvZXi TH1PFm9CA16YyMECZFdtwicIe5gA+sPxrOeCFEdQkaUs8kc7idv7OQWEVfCYh5dGfGO8 kUPhVyGCgXW2qMHf5YDAjmkLH2gvpX7Yte6BiXuc6HmgxbYB3E4XlhL08LG/tru0sYJ9 l628wHiOo0VpaD++17Vx3Bs0QZ0hy0YpYJ0UJ2FrzAoj2z91dDqrK67wGbdr0CUwXtCj Qnrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nAGfV/IOelihK7dDW91o+/lYOLpjtO8skiwGsjrAl5k=; b=emsHT+1oqCDCzUgcrOiH0LQP7itobmw3l5YkrVsd4/WEr0BMLY2hMZyp42lO9p2rQu ZA4+2GxhciZoobDP1Ho8D+tPbIPo1jVRdr0Q3NF4XDVgdEt6N2yxk14+GcJ2Hkl4URRc 9OePjx3f+7i1gJ09p0c9qNHdC137pMMY1Fo4/GDJ6iOEtv7fxjsHT+TubDm0i+2VroU7 NDVUJZ3wZQy73c8MCT6FWdXaFEJ2Hg4TbMy4aRS7kjWpkqSntud1x6c15C3E1ayI69gt aVNJMmD4KMAD0FygTS8LKOu8rz14+6/qdldXeRivQvFXwJ1QvmUeV06M/RXdTfb2TstA e+rQ== X-Gm-Message-State: AIVw113QyTlExMf3q8l9DFWAchoVn5giNriYyIc1/AU7RVZoSDNcdLmq MB5vuHgnZTEB2Q== X-Received: by 10.98.104.133 with SMTP id d127mr3234470pfc.193.1501140201576; Thu, 27 Jul 2017 00:23:21 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id 8sm8153807pfx.164.2017.07.27.00.23.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jul 2017 00:23:20 -0700 (PDT) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH] net: thunderx: Fix BGX transmit stall due to underflow Date: Thu, 27 Jul 2017 12:53:04 +0530 Message-Id: <1501140184-25625-1-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170727_002343_069904_F9EB6763 X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sunil Goutham , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sunil Goutham For SGMII/RGMII/QSGMII interfaces when physical link goes down while traffic is high is resulting in underflow condition being set on that specific BGX's LMAC. Which assets a backpresure and VNIC stops transmitting packets. This is due to BGX being disabled in link status change callback while packet is in transit. This patch fixes this issue by not disabling BGX but instead just disables packet Rx and Tx. Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 27 ++++++++++++++++++----- drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 7911256..5e5c4d7 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -292,11 +292,30 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac) u64 cmr_cfg; u64 port_cfg = 0; u64 misc_ctl = 0; + bool tx_en, rx_en; cmr_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_CMRX_CFG); - cmr_cfg &= ~CMR_EN; + tx_en = cmr_cfg & CMR_PKT_TX_EN; + rx_en = cmr_cfg & CMR_PKT_RX_EN; + cmr_cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN); bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); + /* Wait for BGX RX to be idle */ + if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, + GMI_PORT_CFG_RX_IDLE, false)) { + dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI RX not idle\n", + bgx->bgx_id, lmac->lmacid); + return; + } + + /* Wait for BGX TX to be idle */ + if (bgx_poll_reg(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, + GMI_PORT_CFG_TX_IDLE, false)) { + dev_err(&bgx->pdev->dev, "BGX%d LMAC%d GMI TX not idle\n", + bgx->bgx_id, lmac->lmacid); + return; + } + port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG); misc_ctl = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL); @@ -347,10 +366,8 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac) bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_PCS_MISCX_CTL, misc_ctl); bgx_reg_write(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG, port_cfg); - port_cfg = bgx_reg_read(bgx, lmac->lmacid, BGX_GMP_GMI_PRTX_CFG); - - /* Re-enable lmac */ - cmr_cfg |= CMR_EN; + /* Restore CMR config settings */ + cmr_cfg |= (rx_en ? CMR_PKT_RX_EN : 0) | (tx_en ? CMR_PKT_TX_EN : 0); bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg); if (bgx->is_rgx && (cmr_cfg & (CMR_PKT_RX_EN | CMR_PKT_TX_EN))) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h index 6b7fe6fd..23acdc5 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h @@ -170,6 +170,8 @@ #define GMI_PORT_CFG_DUPLEX BIT_ULL(2) #define GMI_PORT_CFG_SLOT_TIME BIT_ULL(3) #define GMI_PORT_CFG_SPEED_MSB BIT_ULL(8) +#define GMI_PORT_CFG_RX_IDLE BIT_ULL(12) +#define GMI_PORT_CFG_TX_IDLE BIT_ULL(13) #define BGX_GMP_GMI_RXX_JABBER 0x38038 #define BGX_GMP_GMI_TXX_THRESH 0x38210 #define BGX_GMP_GMI_TXX_APPEND 0x38218