Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2280042pxb; Mon, 11 Jan 2021 05:57:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxannsOl247iKW0R9C8SNIc6jxazVXD8MgFfNMoWnA59SsTp27qau1UAYF0FeDkUTaZ6H6s X-Received: by 2002:aa7:dc0d:: with SMTP id b13mr14285818edu.170.1610373460484; Mon, 11 Jan 2021 05:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610373460; cv=none; d=google.com; s=arc-20160816; b=t65NZgmJ37wOML8zqXWpFkYCWihnkvhyygN9EG1yDwxJHsoSg1r1zkv+/4IexjEpV/ hlndK+2tbLXvHNUzb5j00CKOKogCnKNl6DTdYIx0K2mQZiJvVjtHGLNEQUSSB0pQSgeR gAQwXHMWE7XvyZAsvfoKBBP6Bca6LnblI4iBi04+aAMiDqKtB1Ge8xa5qJxXORAhXhWJ HGDEix2TdCyInQl+tGz4MR+58O2pgxAM3gHqtcQrLE5SpB2Ws/kJSiyIDdVLYy5vtWTZ c6V33SCn3H1zy3hsg6XMmIowtwlfN/JCCkwe9q9QxIbZdrpbX9XjvQsPDQoseSyxR54A rcmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gxmXM8nU7fmv7/uNI0YnuGjIUttrbOCUa+dDNBg94+U=; b=qHqZFvTT5aqyOuWtEEF/7KkGDz9pbz4qV5jcoxxLTJXOVRV/EHRBGLA4jXdywRbHdv vK47BtgdkGlHlcacVWCBiaw26QiZfP6aXRso/MH7x82aCPt/6ZRdyaGS7mZZ6vyQGFUh CYqervPIDoqmLKqC01/MI14Lt8SUkaG86mNjNUAMuwjfEGmxIzTjnoHqi0l0ZJG8uoMY Kr34xfhSXW8dqxrl3JqcCN4HDtgEs5Ze6H0zI9J2AFvjjTefUHB8vbzByiZ3/ivRip6V J5Eu1ey19yfYDcP7ZK8oeZA958mE027cqPjfhLQSzilsMEZYqH4VZvuv0j4fM4APq18P Rw0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WMpTirW0; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si6992901edq.304.2021.01.11.05.57.15; Mon, 11 Jan 2021 05:57:40 -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=@linuxfoundation.org header.s=korg header.b=WMpTirW0; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731096AbhAKNzU (ORCPT + 99 others); Mon, 11 Jan 2021 08:55:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:55026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730605AbhAKNHg (ORCPT ); Mon, 11 Jan 2021 08:07:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AAFD221534; Mon, 11 Jan 2021 13:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370415; bh=tzvl5sHdBtluz5D1Fyj4DNPYehSKsO9XCZc2JL+oR/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WMpTirW0c8gz4yusurCRQIm0tdMEo/ICW4rCubdAj1Xcs1UQDA8tb9XkIEvLqYXYA byQ1L1NzGMujpBgj8/pleaxfv4bZiPumaP1s1Z/DhgymAv8Mz0Bg2uHv/xhqK9CZMp W3pI5xgt4fXzsUpQRZCF1BcyH2/Flabck5Yvty3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Chulski , Jakub Kicinski Subject: [PATCH 4.19 12/77] net: mvpp2: Add TCAM entry to drop flow control pause frames Date: Mon, 11 Jan 2021 14:01:21 +0100 Message-Id: <20210111130037.004553186@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130036.414620026@linuxfoundation.org> References: <20210111130036.414620026@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Chulski [ Upstream commit 3f48fab62bb81a7f9d01e9d43c40395fad011dd5 ] Issue: Flow control frame used to pause GoP(MAC) was delivered to the CPU and created a load on the CPU. Since XOFF/XON frames are used only by MAC, these frames should be dropped inside MAC. Fix: According to 802.3-2012 - IEEE Standard for Ethernet pause frame has unique destination MAC address 01-80-C2-00-00-01. Add TCAM parser entry to track and drop pause frames by destination MAC. Fixes: 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Stefan Chulski Link: https://lore.kernel.org/r/1608229817-21951-1-git-send-email-stefanc@marvell.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c | 33 +++++++++++++++++++++++++ drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.h | 2 - 2 files changed, 34 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c @@ -405,6 +405,38 @@ static int mvpp2_prs_tcam_first_free(str return -EINVAL; } +/* Drop flow control pause frames */ +static void mvpp2_prs_drop_fc(struct mvpp2 *priv) +{ + unsigned char da[ETH_ALEN] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x01 }; + struct mvpp2_prs_entry pe; + unsigned int len; + + memset(&pe, 0, sizeof(pe)); + + /* For all ports - drop flow control frames */ + pe.index = MVPP2_PE_FC_DROP; + mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC); + + /* Set match on DA */ + len = ETH_ALEN; + while (len--) + mvpp2_prs_tcam_data_byte_set(&pe, len, da[len], 0xff); + + mvpp2_prs_sram_ri_update(&pe, MVPP2_PRS_RI_DROP_MASK, + MVPP2_PRS_RI_DROP_MASK); + + mvpp2_prs_sram_bits_set(&pe, MVPP2_PRS_SRAM_LU_GEN_BIT, 1); + mvpp2_prs_sram_next_lu_set(&pe, MVPP2_PRS_LU_FLOWS); + + /* Mask all ports */ + mvpp2_prs_tcam_port_map_set(&pe, MVPP2_PRS_PORT_MASK); + + /* Update shadow table and hw entry */ + mvpp2_prs_shadow_set(priv, pe.index, MVPP2_PRS_LU_MAC); + mvpp2_prs_hw_write(priv, &pe); +} + /* Enable/disable dropping all mac da's */ static void mvpp2_prs_mac_drop_all_set(struct mvpp2 *priv, int port, bool add) { @@ -1162,6 +1194,7 @@ static void mvpp2_prs_mac_init(struct mv mvpp2_prs_hw_write(priv, &pe); /* Create dummy entries for drop all and promiscuous modes */ + mvpp2_prs_drop_fc(priv); mvpp2_prs_mac_drop_all_set(priv, 0, false); mvpp2_prs_mac_promisc_set(priv, 0, MVPP2_PRS_L2_UNI_CAST, false); mvpp2_prs_mac_promisc_set(priv, 0, MVPP2_PRS_L2_MULTI_CAST, false); --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.h +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.h @@ -129,7 +129,7 @@ #define MVPP2_PE_VID_EDSA_FLTR_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 7) #define MVPP2_PE_VLAN_DBL (MVPP2_PRS_TCAM_SRAM_SIZE - 6) #define MVPP2_PE_VLAN_NONE (MVPP2_PRS_TCAM_SRAM_SIZE - 5) -/* reserved */ +#define MVPP2_PE_FC_DROP (MVPP2_PRS_TCAM_SRAM_SIZE - 4) #define MVPP2_PE_MAC_MC_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 3) #define MVPP2_PE_MAC_UC_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 2) #define MVPP2_PE_MAC_NON_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 1)