Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2059147pxb; Thu, 11 Feb 2021 03:21:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1MC6y/kCyYRl/iHhtz5eI3A1rj+wvM7rjxGAFQLVJ79rhoExF7zHsAcyQSe8SBdC89WwK X-Received: by 2002:a17:906:2a06:: with SMTP id j6mr7757491eje.164.1613042493333; Thu, 11 Feb 2021 03:21:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613042493; cv=none; d=google.com; s=arc-20160816; b=HGWJFcfM9kDsljJbaP2w1zfZ1v8H/2II7AcsWTJLYt6zVjx7OPCcXSg6X5ifB8v/Db d2S262xBnWwRwrlfEyq2bkv3G0AEKEsZ22JxtNBS8smD7/mL5YqfJDZ2mgM3FRYyJr7+ jrt9r17y/xP9FZ1uxV3+SYt/DloJuqnl+JX7xnFrxRmUERYqBhiZm3zLPzMAkkEDtDj4 Aa4TXchhLTYnfq1/WyxgaiTLjqfSKVc6tgvd0Wl2PpokEvvtzxauJztXw7UMCUX8DZvR Ti8gMs+0KNVJFKWKSVRJjPIhX1RQilD1YyPR1Z89jlxdTlWAQULqMMTv2alCe9AKVn4k MIgQ== 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=DXjQatTR+FYo0xK3DvzCV6/Fj5dqhPmz90uDt3zfAlI=; b=ToAI7bKATfZcXWTsa188WhRPFgTa39WluY7OiXP0Ws3jkuDkORDh/reP22qvFEWXaY 1zc1rV3nK9aWs+rhxcKWO3R+o8IBpEEgtWXTAY9UH7TQPvlvoXIYYpPtZziZ3jYyFuAC La+XiJ6TJsHVcKeZotFfQAIk+oO2Ew/zOFcpP36lf/ZE5E6Y3L0Cp/fZ5axqYOungkYZ CJERzQYmuYsUV0hYtBJP6reuhEfjVbnK4c52xf8aAYMcczX3poClY1CRMtn2Y/B5P8HB 7K52nBGkhdeA6qUb5bMcHfhSX9mZtagGxjCXPmfIkMF15PM7mSoeTwL1IJCH7RRbiyrQ FcEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=T0z38p58; 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 e16si3579970edy.358.2021.02.11.03.21.09; Thu, 11 Feb 2021 03:21:33 -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=T0z38p58; 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 S231383AbhBKLR7 (ORCPT + 99 others); Thu, 11 Feb 2021 06:17:59 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:57188 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbhBKKzK (ORCPT ); Thu, 11 Feb 2021 05:55:10 -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 11BAp92r017018; Thu, 11 Feb 2021 02:54:10 -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=DXjQatTR+FYo0xK3DvzCV6/Fj5dqhPmz90uDt3zfAlI=; b=T0z38p58ZfNWJKIsk/ro78YP5sq7SnOQsdpKLvye0EdyKvSq7DeREFEWCFpxFYTs+ceg ROp3ZteGIdDQSYdtEPnP2ozuxmReWaZJfZ2U6a8OJc8Qa5fWBrT7UfzGDQU2S9WKcruY InDVGrBgt2GsWYZj1n6M/VRGOJFyEa91Am5SH6MIpAkAgj/JSGpyYPjJsXuht4qt1hz4 aW3YDLWHaxIjzRIySui4FPocLq05CGKTMj7SYhJpZ6Qwg7beODi7r6xHDi9J7ynDW0jE aitj7HuzD9f7wgnpUb4mlq4eHPIBa6Lyb/0S0ziMBOG9iePxsSetezoC2WgPINrMaReC sg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 36hugqefhk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 11 Feb 2021 02:54:10 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 11 Feb 2021 02:54:08 -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; Thu, 11 Feb 2021 02:54:08 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id A925F3F7041; Thu, 11 Feb 2021 02:54:04 -0800 (PST) From: To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH v13 net-next 15/15] net: mvpp2: add TX FC firmware check Date: Thu, 11 Feb 2021 12:49:02 +0200 Message-ID: <1613040542-16500-16-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1613040542-16500-1-git-send-email-stefanc@marvell.com> References: <1613040542-16500-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-11_05:2021-02-10,2021-02-11 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 Acked-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 1 + drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 39 ++++++++++++++++---- 2 files changed, 33 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 883d742..4ff195a 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -924,6 +924,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, @@ -7256,7 +7284,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) @@ -7480,13 +7508,10 @@ 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, "Minimum of CM3 firmware 18.09 and chip revision B0 required for flow control\n"); } mvpp2_dbgfs_init(priv, pdev->name); -- 1.9.1