From patchwork Thu Apr 20 21:06:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 86044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp625574vqo; Thu, 20 Apr 2023 14:25:40 -0700 (PDT) X-Google-Smtp-Source: AKy350YSD3jhLIHYB6xtSIUZEy4J0P2i6coj0bgVRj52Owv0lfbOTZyv30YafiDxZnTcWM6ktA84 X-Received: by 2002:a17:90a:17e4:b0:239:ea16:5b13 with SMTP id q91-20020a17090a17e400b00239ea165b13mr2923098pja.14.1682025939685; Thu, 20 Apr 2023 14:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682025939; cv=none; d=google.com; s=arc-20160816; b=vV3BsOvw29/TJKFw1S/DQAT/2rIR/aAJBBbY0GOUcOK7XXVhBBjhUOMmqJlR0qybWD /bGL4wDjz8r2hQwszuLTo/okncXH+nwIRCYKW73xbdToMOuVOA8LqOiysvcE/33b/Jjz bMcx81knZH1vynwA/JqDYzWC0Yq8rtQTscchujPxT3L8MPLtD3ESRA78QvtNv9cPQzJN TwKNsRftHOCxRfPr0I4paLaJvl8jerHoNrEeoYgLA1ceE1t0zbuQkIXJp6lTbZnwcsBT dAGVgXDaBS3n3YjFZvVr7kAPwZqW1CSuAtBUNusdR/fMbaKivRgahi32dO3VGC9T5GSh 3CQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=CEIIxz47kughbPq/IHjwOs7hBKb5DVOHOPKww/Vy0Ww=; b=x3+9UQyt2Ze0pX0ZUBTOz2Pv9xCYudQCGHe6G1QXGtJFfPeuyIllunrdqfbqoHZ3s3 lKbdCHqsHQVzQQeqeRHJb6fpnl2rCh7fJA52Eyqi1P5iUYEl0UND7WhIS3FKuXkYomwW dW46zhgo5duu2gX2ztDMjD8zbBG4Nvufahai5xBgJ8O4Q2Mr4ArgT7Gurx1X0Sxuk59d 8w4DIMeKtCD1nB3QyisZBev4TkN05BwfGMu8unpWu0eQPqpQAo26epq091BPo7/vj468 k/FOEmaJPOxHc+LRkSLiVRHhaFvG5GSq4o9dOrkP6+ex5JnG14pws6SI3wxBsLHLnRig cfUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 88-20020a17090a09e100b00247ad11b6d3si2913172pjo.88.2023.04.20.14.25.22; Thu, 20 Apr 2023 14:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232354AbjDTVG7 (ORCPT + 99 others); Thu, 20 Apr 2023 17:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbjDTVG4 (ORCPT ); Thu, 20 Apr 2023 17:06:56 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B269D4220; Thu, 20 Apr 2023 14:06:55 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ppbUP-0002gY-0C; Thu, 20 Apr 2023 23:06:49 +0200 Date: Thu, 20 Apr 2023 22:06:42 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Subject: [PATCH net-next] net: mtk_eth_soc: mediatek: fix ppe flow accounting for v1 hardware Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763732032025909470?= X-GMAIL-MSGID: =?utf-8?q?1763732032025909470?= From: Felix Fietkau Older chips (like MT7622) use a different bit in ib2 to enable hardware counter support. Add macros for both and select the appropriate bit. Fixes: 3fbe4d8c0e53 ("net: ethernet: mtk_eth_soc: ppe: add support for flow accounting") Signed-off-by: Felix Fietkau Signed-off-by: Daniel Golle --- drivers/net/ethernet/mediatek/mtk_ppe.c | 10 ++++++++-- drivers/net/ethernet/mediatek/mtk_ppe.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index dd9581334b054..9129821f3ab8f 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -601,6 +601,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, struct mtk_eth *eth = ppe->eth; u16 timestamp = mtk_eth_timestamp(eth); struct mtk_foe_entry *hwe; + u32 val; if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { entry->ib1 &= ~MTK_FOE_IB1_BIND_TIMESTAMP_V2; @@ -617,8 +618,13 @@ __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, wmb(); hwe->ib1 = entry->ib1; - if (ppe->accounting) - *mtk_foe_entry_ib2(eth, hwe) |= MTK_FOE_IB2_MIB_CNT; + if (ppe->accounting) { + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) + val = MTK_FOE_IB2_MIB_CNT_V2; + else + val = MTK_FOE_IB2_MIB_CNT; + *mtk_foe_entry_ib2(eth, hwe) |= val; + } dma_wmb(); diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h index e1aab2e8e2629..e51de31a52ec6 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.h +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h @@ -55,9 +55,10 @@ enum { #define MTK_FOE_IB2_PSE_QOS BIT(4) #define MTK_FOE_IB2_DEST_PORT GENMASK(7, 5) #define MTK_FOE_IB2_MULTICAST BIT(8) +#define MTK_FOE_IB2_MIB_CNT BIT(10) #define MTK_FOE_IB2_WDMA_QID2 GENMASK(13, 12) -#define MTK_FOE_IB2_MIB_CNT BIT(15) +#define MTK_FOE_IB2_MIB_CNT_V2 BIT(15) #define MTK_FOE_IB2_WDMA_DEVIDX BIT(16) #define MTK_FOE_IB2_WDMA_WINFO BIT(17)