Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2276513pxb; Mon, 11 Jan 2021 05:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXTgI2jN0EFpV4hKX8pU96T8HfEJa2lJS2BFRFQwedH4wPP71K6VxM9CM0TF+pY3YKKXPw X-Received: by 2002:a05:6402:229b:: with SMTP id cw27mr14149223edb.23.1610373078022; Mon, 11 Jan 2021 05:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610373078; cv=none; d=google.com; s=arc-20160816; b=RYH7hlgiF0lm0F2VnVcwXrZHPq++gAZGcNPnzES0fszchJxBKRr8XPoqmmM38frtbd cgk/jmexXR0sdUR/lByWWZnigN8o7bRw3QJCwt7Al65rFWfmI2Z/IYU5px85woWxVlod XxWM6b5V2FL9jNwe1QLrofuH077MKCDBirbtN3ElIDJMAZ32Z+9Zpm1tukEKntZ9djRO qICGKBn8n4YZ0qAWcjHhV0pAGE6KgsLFxLIiZHG0UlfgYCnaZ4/hGwp/nzUXcBox2TdL rUUBRvUJ3HqVmzXtrVJVu2VGv7z7kIWu012SO093yika4qMGxGNnaALX4ukJGrZwL/UE 7eVQ== 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=s8lFMU7Xx1/SikLt4h/nFj7H6JCM5GNaVtgaba7cGIyGB0lpd2UcWxLiHTlckPzSLA aB7Xnlh0tloOoktvx7oDVWjICeYTNdtMDbmJSc8iWeZels4ENNO7tqKK/qzlVNLdo2nm hc5gBY5L9+21y+uSEMsZFDTMYFe861mQz2E0Jm9pxUYQ8uULjOzvfFh5P+4QDdcKPk4O oDyURCIaJBAovFrKeKpsvtINtWQ8GsZWMveTSVS7KqkrmPqBsCRKROZ7wdGl0SmOqlIX ZZgtsbqktpJjn34chXvyhjoiRaTt296PuAg8MNJV88+89QK13VxlUcTBKd6kTzPkc8j3 1N1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WX8c++cH; 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 k17si6557607ejc.181.2021.01.11.05.50.54; Mon, 11 Jan 2021 05:51:18 -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=WX8c++cH; 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 S2387956AbhAKNsx (ORCPT + 99 others); Mon, 11 Jan 2021 08:48:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:57100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731127AbhAKNKG (ORCPT ); Mon, 11 Jan 2021 08:10:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64C7F22AAD; Mon, 11 Jan 2021 13:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370590; bh=tzvl5sHdBtluz5D1Fyj4DNPYehSKsO9XCZc2JL+oR/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WX8c++cHOQkemi8nYLAm/PJLC2+UPBgw5Ogk6E9gqPxkHq+5wFaXXUTrnr2KMUM20 OTdYxz7Z0iggDi1E5GLsW+AJpwz7NNLDXD52UZk8O0CSFy/gxY12u0LYds6GLu1Gcs 3cVLBQYwr17AzdzbJJ/PePB5v7deZ+OVReWWVdbE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Chulski , Jakub Kicinski Subject: [PATCH 5.4 12/92] net: mvpp2: Add TCAM entry to drop flow control pause frames Date: Mon, 11 Jan 2021 14:01:16 +0100 Message-Id: <20210111130039.744765021@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@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)