From patchwork Tue Mar 27 15:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Lomovtsev X-Patchwork-Id: 10310431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C04360212 for ; Tue, 27 Mar 2018 15:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8823A2862D for ; Tue, 27 Mar 2018 15:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B0BA29B84; Tue, 27 Mar 2018 15:09:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 40D0A2862D for ; Tue, 27 Mar 2018 15:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4UyyhSl+rZEb9qJaQDJTE+Km6dyn94Djbt4EPmutD0A=; b=GniO4XwfmunNUC gLuIAvn8dILzxz8Z32Ti2rGbwbNN1sTmBEIIKYQut+acCNbCEc8LIMLz4xCeRDkXQ+qjl70BDPTxw f4N0qSuZllwKpXWWIsaCx58f/BpMkhtKPr91VLRyr8o2sVNri8ph8T7//niZ7D/+HEtn8lZHff6zB l87DYs08AwZV7U4HqDTC4RadBOAe9Vki1XgxrwwJ+q+xONN4IID7Hbc3cV6rNjgZhTQIFN3j1M+FN CNSueSVYyHAScIHcfbPWeFd6pZKn2Hv1Y6ztGEwm394BI1/GXqhJA6jv+feYkDvuBHAtI1yCnwcWN e+mrKKRwTS8keu9aH3Jw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0qDu-0002nP-Vo; Tue, 27 Mar 2018 15:09:18 +0000 Received: from mail-dm3nam03on0069.outbound.protection.outlook.com ([104.47.41.69] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0qCj-0001h2-5p for linux-arm-kernel@lists.infradead.org; Tue, 27 Mar 2018 15:08:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+zFVks1HxG559lN85/EIxM4gLO2FPDdQUo+c4qwbpjk=; b=Yv1FBLQB+Hhk1+J3r5kbNlC5Efnr1+mGwsyf3/eWbEiJ50Mg+ukiVs3MEyKiOayv4JTxS3YyOoNT2Li5Ih8nmZzvWpxQrj4jvtL09KfZnFYT0MUL6H/IoRvAA5q5/HbzzbMziGVbYyxQdgTR1S5rF8+VbMA2c1e311cnL/97zlY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Vadim.Lomovtsev@cavium.com; Received: from localhost.localdomain.com (50.233.148.156) by CY4PR07MB2998.namprd07.prod.outlook.com (2603:10b6:903:d0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.609.10; Tue, 27 Mar 2018 15:07:49 +0000 From: Vadim Lomovtsev To: sgoutham@cavium.com, sunil.kovvuri@gmail.com, robert.richter@kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] net: thunderx: add multicast filter management support Date: Tue, 27 Mar 2018 08:07:32 -0700 Message-Id: <20180327150736.10718-4-Vadim.Lomovtsev@caviumnetworks.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180327150736.10718-1-Vadim.Lomovtsev@caviumnetworks.com> References: <20180327150736.10718-1-Vadim.Lomovtsev@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: DM5PR20CA0003.namprd20.prod.outlook.com (2603:10b6:3:93::13) To CY4PR07MB2998.namprd07.prod.outlook.com (2603:10b6:903:d0::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6bd505e-f5f9-40e3-1684-08d593f481e1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603328)(7153060)(7193020); SRVR:CY4PR07MB2998; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB2998; 3:T4P3sgq1wmmfn1OTbGLLa2e86BtBkuqxusa2KltN6ozd7JPjzT3XjkpJGTNAAVCCQIMDRJ4hDWE+stk90+ukIeMOrHIOfRtVSulgytEHZ5KnPIZKpOAfj9xPtYVK3eeGRc8lVPpdfH+m8bW7X8hpQUiPMca68/BOUWYoIDqUMtXP3+5znZJJ29opklpTYFY4otbsYpvTDmx3DJIA1u8++Pyq9/y8W+LSp7Hwe0YO0LFgW80X0YwsnuFqCfpizqoe; 25:xLO5PUygGPQS+XM1cZHuqyI9aRSlPQ+DoX82s75Dugk6Aeo694JU7jj3jGLA+1hoS9g1tnEir0e5uUX4qcD1ZX7L6RY1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ON3AVM9pmq8Nn6dAGOrx4Ln/vm1/boi1fuPrvovaQFGtxjDtAbpLXASGl9X3Ipl2Flhd+QvYBN21FaKEeHuNk3zx9iZluKRJuRqVrZn43s=; 4:Dk8c9Ju3lsCR4AYmr3jBtFg9wRA+KgFWM5j37iHPYeyaWEROTWhTK2EYr2bfksvgP3MdPioRrLd2icKX7Tqblz9e7jGf/MC83cNRrHSaYIPY+thrz7IzpXzOm5BPGD33NIddjvS3lHM1m5eZHZXk6uxRkptDX/zs0xVSfl58jgfutMssoy/BMgzBgn7L1nh6GxoEEeTW76LVDQiAOLJzLmlxkZSNN7a/FtOFl4rM7/BedaMc2MjkfoEkxQSZ4e/bliwITU1k4BeyGCWEyt7LXg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3002001)(10201501046)(3231221)(944501327)(52105095)(6041310)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:CY4PR07MB2998; BCL:0; PCL:0; RULEID:; SRVR:CY4PR07MB2998; X-Forefront-PRVS: 0624A2429E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(366004)(39860400002)(396003)(39380400002)(376002)(189003)(199004)(446003)(2616005)(6116002)(478600001)(1076002)(107886003)(3846002)(6666003)(956004)(97736004)(39060400002)(50466002)(7736002)(53936002)(16526019)(66066001)(47776003)(26005)(48376002)(486005)(486005)(6486002)(6512007)(316002)(305945005)(11346002)(16586007)(105586002)(42882007)(6506007)(575784001)(386003)(68736007)(59450400001)(69596002)(106356001)(72206003)(25786009)(2906002)(52116002)(53416004)(76176011)(5890100001)(81166006)(51416003)(8676002)(36756003)(476003)(50226002)(4326008)(5660300001)(81156014)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB2998; H:localhost.localdomain.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB2998; 23:hrGF2iLjdKIOGPdxErt1CRKPapSgtq7ZI3qiJu53j?= =?us-ascii?Q?qilxCK8IH1bEtmosSk59hGEVwF9TRtT9d3mxyD5cduDAj2R/7nKn4uz2eei7?= =?us-ascii?Q?QnBvP6RxEB9j0n2JoTLV914HD2EFqvsBCcnfhOudQVjYGpTmJFOty1AmnUQZ?= =?us-ascii?Q?uBg6Yn8hFA//+YcnC9aAjismdy+j/rudblGnVsOukRVj7hbiLvDN9PL9+IrC?= =?us-ascii?Q?u13h3SgZclN5JyiGyBQOXXgnHfnF20YdFPyatb4ZSjl0/CClFyopt1s7Uonv?= =?us-ascii?Q?o+Aks8MgtbuI+xPP9JKekkXc0C2CFiPNJikzPvhu0kpJ5vqwA2KVbU4TQYR4?= =?us-ascii?Q?3zQ3wJaB2ED21lQhrAimiR5zIjOaWwS1Ft+PxHQL1HMVRuFg/prd/eIlygpf?= =?us-ascii?Q?JTrT3iJECXOr8gBUexw6mOhMVyuuW031N1lKssvvGt9tSZyAQdOS7hX5Jnaf?= =?us-ascii?Q?R8tc18p3WpYhIPGGWnB7SShJLXDJj/C+r9AgoTRdce9y5F3FG8jERFwVbIP9?= =?us-ascii?Q?0mWesRPCWOq3UckZ+/po0eUrkSGRK6Y0KaI1K5Ia6O8HGebu6C78reFb7yI5?= =?us-ascii?Q?OvpaRmrIPunBCyRFw4Msqiz80WUXZqrjyT0pm1vXT0JQgFGksJhwf4R8wexR?= =?us-ascii?Q?JDO3n870F+C7BeYktuiGj61u2Ofv+x4rf63GnkIytd0V8JMf8/t+gTZ7bLjY?= =?us-ascii?Q?DNFC0UQy/O1lCVqwaOh4Oa/gZnz4/fl3t5TWrdvN0bLZRoS4hOD74fXnH2Uk?= =?us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GD0QtFez5vPkHLoS+h7yvejnm8OgsQc8attZQI/dFgHmqQ0ZiSyCWwPsHTXYxLFsPMAOx3eXiqKx/ogNrvJLCDeEaJzAO2GTMYhN9la03rf8FptLpBo6464Tbe45tNsJzauvogLucaL0uHFfK+7b1CDGTt2AIkV8x842SxuBo+7JnDLlKeP+owl1exnvyTMxNcQFFLFf/4tX0RuSh+4kKc2XiYrJFgEZd+a2Bfo+pJ3gGZKT0ZK0llV5Oj+BgPmlY8oKvl77r2GxslOJQ9uSAmznKgsclJCb5thLrkso6aBuFDSS3k/jFxPAa3PtddY1Pfgi28gjikLnDbcAQuNU/vUWp6R5xwyuNxAIyRBKKjfbGOFjye4b3do8dly4am3c70o5t9rqwp/MNSeD6ebDPjy+SNAgiG8KmysUrcPbTaoAA==; 5:WUOFlCzxRkNreB7uNCOPr413z7k4vLzBmU3uXU/0HHMUVzZ5DXmmqfiUCBmC6R5zk7vfXpaUHy2yvVyB8Y2ukBfHlDAVpFw3Lny81pWZ//h59/w4T3oMHA4GpOx43CxRqd9OxvYJeAy4ZFaCXON3LUJlGigo3j2gJ+cNzKnYzLU=; 24:8APdrD1mPXTi/N0xUODLEg5Omzn4y9SHyIDWxy1mCpOLY8PpKbiOd+XZ5stFhdbQLTDFQi4uwd92K9P+UFLy4EjkLPHAUHenaH4zsPXswds= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB2998; 7:AHmgXVo4wNITWZttk3TDM04DAezpu0JK3D7lA4tAeMT+FgfMBFfZ4mQThdCu/2Sf/S0uoCgtKj10b+5DyP2USCVzvU0lTmujYr+GoVZZFOakiri+XYX9zw9PbWLZFLTuAbV9Cv+nuccsZswVqmkLVrf4EpXMkiZNsAWj2uUpVp8b86ATZkc31N2+Hv3V36i/qSpigkwJLnl8DLXz+aw5P6+7E/ykDdD/nnny6TvgI0QRQ3/88GE+s/fbXkHb1Yxy X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2018 15:07:49.6858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6bd505e-f5f9-40e3-1684-08d593f481e1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB2998 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180327_080805_254924_FBDA9093 X-CRM114-Status: GOOD ( 14.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dnelson@redhat.com, Vadim Lomovtsev Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vadim Lomovtsev The ThunderX NIC could be partitioned to up to 128 VFs and thus represented to system. Each VF is mapped to pair BGX:LMAC, and each of VF is configured by kernel individually. Eventually the bunch of VFs could be mapped onto same pair BGX:LMAC and thus could cause several multicast filtering configuration requests to LMAC with the same MAC addresses. This commit is to add ThunderX NIC BGX filtering manipulation routines. Signed-off-by: Vadim Lomovtsev --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 141 ++++++++++++++++++++++ drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 8 ++ 2 files changed, 149 insertions(+) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index cf0cc19c03c5..52fef3dab0a3 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -256,6 +256,147 @@ static void bgx_flush_dmac_cam_filter(struct bgx *bgx, int lmacid) bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + ((lmacid * lmac->dmacs_count) + idx) * sizeof(u64), 0); } +static void bgx_lmac_remove_filters(struct lmac *lmac, u8 vf_id) +{ + int i = 0; + + if (!lmac) + return; + + /* We've got reset filters request from some of attached VF, while the + * others might want to keep their configuration. So in this case lets + * iterate over all of configured filters and decrease number of + * referencies. if some addresses get zero refs remove them from list + */ + for (i = lmac->dmacs_cfg - 1; i >= 0; i--) { + lmac->dmacs[i].vf_map &= ~BIT_ULL(vf_id); + if (!lmac->dmacs[i].vf_map) { + lmac->dmacs_cfg--; + lmac->dmacs[i].dmac = 0; + lmac->dmacs[i].vf_map = 0; + } + } +} + +static int bgx_lmac_save_filter(struct lmac *lmac, u64 dmac, u8 vf_id) +{ + u8 i = 0; + + if (!lmac) + return; + + /* At the same time we could have several VFs 'attached' to some + * particular LMAC, and each VF is represented as network interface + * for kernel. So from user perspective it should be possible to + * manipulate with its' (VF) receive modes. However from PF + * driver perspective we need to keep track of filter configurations + * for different VFs to prevent filter values dupes + */ + for (i = 0; i < lmac->dmacs_cfg; i++) { + if (lmac->dmacs[i].dmac == dmac) { + lmac->dmacs[i].vf_map |= BIT_ULL(vf_id); + return -1; + } + } + + if (!(lmac->dmacs_cfg < lmac->dmacs_count)) + return -1; + + /* keep it for further tracking */ + lmac->dmacs[lmac->dmacs_cfg].dmac = dmac; + lmac->dmacs[lmac->dmacs_cfg].vf_map = BIT_ULL(vf_id); + lmac->dmacs_cfg++; + return 0; +} + +static int bgx_set_dmac_cam_filter_mac(struct bgx *bgx, int lmacid, u64 cam_dmac, u8 idx) +{ + struct lmac *lmac = NULL; + u64 cfg = 0; + + /* skip zero addresses as meaningless */ + if (!cam_dmac || !bgx) + return -1; + + lmac = &bgx->lmac[lmacid]; + + /* configure DCAM filtering for designated LMAC */ + cfg = RX_DMACX_CAM_LMACID(lmacid & LMAC_ID_MASK) | + RX_DMACX_CAM_EN | cam_dmac; + bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + ((lmacid * lmac->dmacs_count) + idx) * sizeof(u64), cfg); + return 0; +} + +void bgx_set_dmac_cam_filter(int node, int bgx_idx, int lmacid, u64 cam_dmac, u8 vf_id) +{ + struct bgx *bgx = get_bgx(node, bgx_idx); + struct lmac *lmac = NULL; + + if (!bgx) + return; + + lmac = &bgx->lmac[lmacid]; + + if (!cam_dmac) + cam_dmac = ether_addr_to_u64(lmac->mac); + + /* since we might have several VFs attached to particular LMAC + * and kernel could call mcast config for each of them with the + * same MAC, check if requested MAC is already in filtering list and + * updare/prepare list of MACs to be applied later to HW filters + */ + bgx_lmac_save_filter(lmac, cam_dmac, vf_id); +} +EXPORT_SYMBOL(bgx_set_dmac_cam_filter); + +void bgx_set_xcast_mode(int node, int bgx_idx, int lmacid, u8 mode) +{ + struct bgx *bgx = get_bgx(node, bgx_idx); + struct lmac *lmac = NULL; + u64 cfg = 0; + u8 i = 0; + + if (!bgx) + return; + + lmac = &bgx->lmac[lmacid]; + + cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL); + if (mode & BGX_XCAST_BCAST_ACCEPT) + cfg |= BCAST_ACCEPT; + else + cfg &= ~BCAST_ACCEPT; + + /* disable all MCASTs and DMAC filtering */ + cfg &= ~(CAM_ACCEPT | BGX_MCAST_MODE(MCAST_MODE_MASK)); + + /* check requested bits and set filtergin mode appropriately */ + if (mode & (BGX_XCAST_MCAST_ACCEPT)) { + cfg |= (BGX_MCAST_MODE(MCAST_MODE_ACCEPT)); + } else if (mode & BGX_XCAST_MCAST_FILTER) { + cfg |= (BGX_MCAST_MODE(MCAST_MODE_CAM_FILTER) | CAM_ACCEPT); + for (i = 0; i < lmac->dmacs_cfg; i++) + bgx_set_dmac_cam_filter_mac(bgx, lmacid, + lmac->dmacs[i].dmac, i); + } + bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, cfg); +} +EXPORT_SYMBOL(bgx_set_xcast_mode); + +void bgx_reset_xcast_mode(int node, int bgx_idx, int lmacid, u8 vf_id) +{ + struct bgx *bgx = get_bgx(node, bgx_idx); + + if (!bgx) + return; + + bgx_lmac_remove_filters(&bgx->lmac[lmacid], vf_id); + bgx_flush_dmac_cam_filter(bgx, lmacid); + bgx_set_xcast_mode(node, bgx_idx, lmacid, + (BGX_XCAST_BCAST_ACCEPT | BGX_XCAST_MCAST_ACCEPT)); +} +EXPORT_SYMBOL(bgx_reset_xcast_mode); + void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable) { struct bgx *bgx = get_bgx(node, bgx_idx); diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h index 52439da62c97..f5de44bc3bdb 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h @@ -30,6 +30,7 @@ #define DEFAULT_PAUSE_TIME 0xFFFF #define BGX_ID_MASK 0x3 +#define LMAC_ID_MASK 0x3 #define MAX_DMAC_PER_LMAC_TNS_BYPASS_MODE 2 @@ -205,6 +206,13 @@ #define LMAC_INTR_LINK_UP BIT(0) #define LMAC_INTR_LINK_DOWN BIT(1) +#define BGX_XCAST_BCAST_ACCEPT BIT(0) +#define BGX_XCAST_MCAST_ACCEPT BIT(1) +#define BGX_XCAST_MCAST_FILTER BIT(2) + +void bgx_set_dmac_cam_filter(int node, int bgx_idx, int lmacid, u64 mac, u8 vf); +void bgx_reset_xcast_mode(int node, int bgx_idx, int lmacid, u8 vf); +void bgx_set_xcast_mode(int node, int bgx_idx, int lmacid, u8 mode); void octeon_mdiobus_force_mod_depencency(void); void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable); void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac);