Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3188694pxb; Sun, 7 Feb 2021 00:31:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMXOf9JD7CC6z0Gy0SH4Le3IGzZ0KxVzkpAcQdHym+xZEcX7VwMVLzyU4dVBuWAjI0Xgw8 X-Received: by 2002:a17:906:8555:: with SMTP id h21mr11565939ejy.403.1612686709640; Sun, 07 Feb 2021 00:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612686709; cv=none; d=google.com; s=arc-20160816; b=b0CIWEM7Q/lFGGbfvnVk9zt7tABmLve4dSxWCYXVtosxSTGys0XTjdl9VV5wn3pomG ljhnC8fjScFO4aj8rFb/DgKVJ6DBpFCe2FwaHWNifUOmnttiUlnC8zExtpABqATikqYO jMFl6UIs4/F7b+7NWOup6PgTj2BixSpvRGA+sJmLh1VyVqHGdYue3hSA/bIZqGdeWOSU lZW8QhmkPbu5kdON0nr19NoJlyhL4aGT7USUolaM6ytkfCSxb+Evu18fPpvDHUNPyfe1 iRSqN0uI6LcE7PaxvXfxdjys9obFrchObOyGJ+9+DBJsADgIRdevyibRGcn+UulYXj63 RJvQ== 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=OPe9kw3KgrmCl20IXxeiNKwyyAIVDOtu+mzfNNZEIRs=; b=EZ6NobZcF8IgwOjmXwtHtz6IsvjeGTwY9TikfHj2qmyRibl8k6C7uy9CIeSgf5i3l1 yzf9fg3CbckibgKzpTgfwaRXMKIgTSOVJb7LkY7ZMWU2nnfT6cbQd8lz24NlNvH77pbY 37UpgQjl9YMHyCLLrS4oIbvpTtJdVlWs0RlkHuSkrVxJPAfZQ+J65XqgzfmDHwKkIY2R wiL3E6NTK8/nLemGkPIbenqI1dEPrnOKYsi6hOP8xdvdoPn7+rTodrqnQOMYa+pifzBd uR1WldbttxUskrtofFKxPJbbwNDgVPYKax3VsOim/C4HfGXveEGTQEFzsYi/5nke6V1F zqDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=K6cfxUAl; 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 z92si9700300ede.291.2021.02.07.00.31.26; Sun, 07 Feb 2021 00:31:49 -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=K6cfxUAl; 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 S230221AbhBGIao (ORCPT + 99 others); Sun, 7 Feb 2021 03:30:44 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:8460 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbhBGIXg (ORCPT ); Sun, 7 Feb 2021 03:23:36 -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 1178LJnR025674; Sun, 7 Feb 2021 00:22:45 -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=OPe9kw3KgrmCl20IXxeiNKwyyAIVDOtu+mzfNNZEIRs=; b=K6cfxUAlAzRWPGg1Feo8VqgJM4G//j6Fza/dgIJ1W6ryijXtzCiT9CeB7unCLkL9BFIH JbXqYbB6qU/A4/dj4WESNKYjPRuDeoYQD/POvFMHqRwF0VAPOlmJYUcqrtohTaVYiBQa P0PX9T60QMx9GHwncJgMM7ed8pVwO4ocNjw+nRnKrw/QbrVVMS+aUoEZ+GAxVfJB8Fjl VxuYvCQlp8GWvxCcPwCi6Tl9i/UnAnM7DXdgg0lesNji/cDoEYYUoj8kgJDDUaPbgi7m hlQyvsxavjMuFo0UHVXU7t48ujZN4lcQfX7yXpOc/hLSIzmLYjS3ZCYKtTVXZZkJBBAy XQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 36hugq1m3k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 07 Feb 2021 00:22:45 -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 00:22:44 -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 00:22:44 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id 3A28D3F703F; Sun, 7 Feb 2021 00:22:40 -0800 (PST) From: To: CC: , , , , , , , , , , , , , , , , Subject: [RESEND PATCH v8 net-next 15/15] net: mvpp2: add TX FC firmware check Date: Sun, 7 Feb 2021 10:19:24 +0200 Message-ID: <1612685964-21890-16-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1612685964-21890-1-git-send-email-stefanc@marvell.com> References: <1612685964-21890-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_03: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 9947385..25013a4 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h @@ -829,6 +829,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 5526214..dfc2e71 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -932,6 +932,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, @@ -7281,7 +7309,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) @@ -7509,13 +7537,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