Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3478376pxb; Sun, 7 Feb 2021 10:50:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeNpb68e+Wxb4zTXtr/5w8LEu/m7v0kKfC4O8cjqJBWox/bKPkHM7vcjb5bhLCbUN/Rml1 X-Received: by 2002:aa7:d2c7:: with SMTP id k7mr6691812edr.374.1612723804211; Sun, 07 Feb 2021 10:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612723804; cv=none; d=google.com; s=arc-20160816; b=dxZVWct3kW6A+fSISJJU+sATWHJ2QrFMLUqLo0FermEhjG6JJ4hZJQRzdqWAp9ly3P KH89iT6mSNY6NdE6KJGanfuRegNzKsWm0Q0xW9y6cAOhPUigFTqLi5+pj6aJbv29rnxT TCCLdf2gJ4vhS6LzaprIwM2ypUCJl4Ua4kqsRX1RL1M8OI49CJi+D2HfNuxguJ06LqAC 4SqJ+GyGsRLwLw46zccvNazUJNogq/AyPW4Sg3xVTrCFnGYQxpUGt5p/rdbtR57ajMAd ZuUzhIufkw66pLzOEZPGh6VU7nFtg2ZicF70QkFtFXrqQ67yPlKn3s87PPRzGuBAmabM Wduw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YyIJ/1eDbCh0foaOPgcKNNopcXPvlFkHzZZvwgJfM/4=; b=LzbXqsrZe7LU5sk+J7dLlXp8QjU2FmDlHLsfnHBdnXULaHvSLXPYzmANK3tTAIpprj ApTQ57qxISA/yjEhk2Y7pSypYNwopygvXuIfRjyuuitJliaIjzNLgqJV+vPVaPoODlf3 Phw6DRhzdmgk7MY0trXftIqpB4MwF4KSQJsfZB027tf/xobJwxSb4tilc+sHvOGjFxiT KO8486H8gwTSVdSdwQLpdUgB5vfrbbBONY0yzHl0uIWYe9HMzAeGgxWDIgulyv1gv+nh Ew9qnh+7tglZvx8WSOocp8JkJwLMoEfhOPFC6C2iQtHMLWmm+4qB1h+MbvyekcLWONC4 MxGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=dM2EmSeX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si10354014edm.396.2021.02.07.10.49.41; Sun, 07 Feb 2021 10:50:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=dM2EmSeX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbhBGSqg (ORCPT + 99 others); Sun, 7 Feb 2021 13:46:36 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:49776 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbhBGSn6 (ORCPT ); Sun, 7 Feb 2021 13:43:58 -0500 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 117IUPmw027844; Sun, 7 Feb 2021 10:43:07 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=YyIJ/1eDbCh0foaOPgcKNNopcXPvlFkHzZZvwgJfM/4=; b=dM2EmSeXOG9Yb/fxeYrJM0TT9ok+ev2aA68lL3teTYl5LopVAedtFwaYx9HwQ1RBbjjy Dhcb8de0rLWCDxMFWGgb6TmYjVwB1VEJSH88vX2+Hz3JfZIKgYUHOudWJt/PC7xD3xdL wXjZetags4pFBMBu+y4xn1L7FdEQqFj4KJZ5NKNSPLmDDKQ8He2NF5h5QTP2gl6yHPfD qR+aiKnXH2wqV60ILZ+ta8Z3TjOl3jNdPVPpMKq+DQvkZtYRXGgoHVSwmdqVwmGJZStK 053fsLoC++bbwKzmElFO8bD1vKFs1C/JiE5bcEVc/bjrUiUNpNhJP4AoF0mUOvBmcnxA CA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 36hugq2ex2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 07 Feb 2021 10:43:07 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 7 Feb 2021 10:43:05 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sun, 7 Feb 2021 10:43:05 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id 5788C3F7040; Sun, 7 Feb 2021 10:43:01 -0800 (PST) From: To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH v9 net-next 15/15] net: mvpp2: add TX FC firmware check Date: Sun, 7 Feb 2021 20:38:57 +0200 Message-ID: <1612723137-18045-16-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1612723137-18045-1-git-send-email-stefanc@marvell.com> References: <1612723137-18045-1-git-send-email-stefanc@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-07_10:2021-02-05,2021-02-07 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Chulski Patch check that TX FC firmware is running in CM3. If not, global TX FC would be disabled. Signed-off-by: Stefan Chulski --- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 1 + drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 42 ++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h index b61a1ba..da87152 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h @@ -828,6 +828,7 @@ #define MSS_THRESHOLD_STOP 768 #define MSS_THRESHOLD_START 1024 +#define MSS_FC_MAX_TIMEOUT 5000 /* RX buffer constants */ #define MVPP2_SKB_SHINFO_SIZE \ diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 4d0a398..fed4521 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -931,6 +931,34 @@ static void mvpp2_bm_pool_update_fc(struct mvpp2_port *port, spin_unlock_irqrestore(&port->priv->mss_spinlock, flags); } +static int mvpp2_enable_global_fc(struct mvpp2 *priv) +{ + int val, timeout = 0; + + /* Enable global flow control. In this stage global + * flow control enabled, but still disabled per port. + */ + val = mvpp2_cm3_read(priv, MSS_FC_COM_REG); + val |= FLOW_CONTROL_ENABLE_BIT; + mvpp2_cm3_write(priv, MSS_FC_COM_REG, val); + + /* Check if Firmware running and disable FC if not*/ + val |= FLOW_CONTROL_UPDATE_COMMAND_BIT; + mvpp2_cm3_write(priv, MSS_FC_COM_REG, val); + + while (timeout < MSS_FC_MAX_TIMEOUT) { + val = mvpp2_cm3_read(priv, MSS_FC_COM_REG); + + if (!(val & FLOW_CONTROL_UPDATE_COMMAND_BIT)) + return 0; + usleep_range(10, 20); + timeout++; + } + + priv->global_tx_fc = false; + return -EOPNOTSUPP; +} + /* Release buffer to BM */ static inline void mvpp2_bm_pool_put(struct mvpp2_port *port, int pool, dma_addr_t buf_dma_addr, @@ -7263,7 +7291,7 @@ static int mvpp2_probe(struct platform_device *pdev) struct resource *res; void __iomem *base; int i, shared; - int err, val; + int err; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -7487,13 +7515,13 @@ static int mvpp2_probe(struct platform_device *pdev) goto err_port_probe; } - /* Enable global flow control. In this stage global - * flow control enabled, but still disabled per port. - */ if (priv->global_tx_fc && priv->hw_version != MVPP21) { - val = mvpp2_cm3_read(priv, MSS_FC_COM_REG); - val |= FLOW_CONTROL_ENABLE_BIT; - mvpp2_cm3_write(priv, MSS_FC_COM_REG, val); + err = mvpp2_enable_global_fc(priv); + if (err) { + dev_warn(&pdev->dev, "CM3 firmware not running, version should be higher than 18.09 "); + dev_warn(&pdev->dev, "and chip revision B0\n"); + dev_warn(&pdev->dev, "Flow control not supported\n"); + } } mvpp2_dbgfs_init(priv, pdev->name); -- 1.9.1