From patchwork Sun Sep 25 14:47:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 12988008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68ACCC04A95 for ; Sun, 25 Sep 2022 14:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Tg6uW5SLIsIiOc/VjUWs1nF3LrSzELaqZRS6J0xlVfU=; b=cCXM2dnHq6YUyZCXxSs34rZHPj fl7sc7hLI8YejZRl2ym20r0n0W1wVCQXtrUMjUnfuD84Eu3emafri+xNOQ24LEfn6j+oxK8hXcQ0x TjCsz3//S4QheS968PzFAGYO+pVCzJJTXUQQlX5L1YykOEwPILEyfQthTptXxBRJS+i0aCG01v/78 wSYa7n+MuFJngqdhmzJQtKDw3EgepLJW5ZCnxGcTiBGt2H1VEv4+rgchAkr4P/bUkD2I8ZIN3WYiU UbcFh7t2iQP8qaSF8zyitq2Z8w1vWNi9iBp+AF+iQaq/KtyQNaQDUuRigvKZ1SDe30mUzx5REe8+j Uk8VA4gA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocSux-00EFzt-SI; Sun, 25 Sep 2022 14:47:39 +0000 Received: from fudo.makrotopia.org ([2a07:2ec0:3002::71]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocSuu-00EFwW-J2 for linux-mediatek@lists.infradead.org; Sun, 25 Sep 2022 14:47:37 +0000 Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ocSuk-0002Tw-1a; Sun, 25 Sep 2022 16:47:26 +0200 Date: Sun, 25 Sep 2022 15:47:20 +0100 From: Daniel Golle To: linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, Lorenzo Bianconi Cc: Sujuan Chen , Bo Jiao , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Chen Minqiang Subject: [PATCH 1/2] net: ethernet: mtk_eth_soc: fix wrong use of new helper function Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220925_074736_644969_135688AB X-CRM114-Status: GOOD ( 10.17 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In function mtk_foe_entry_set_vlan() the call to field accessor macro FIELD_GET(MTK_FOE_IB1_BIND_VLAN_LAYER, entry->ib1) has been wrongly replaced by mtk_prep_ib1_vlan_layer(eth, entry->ib1) Use correct helper function mtk_get_ib1_vlan_layer instead. Reported-by: Chen Minqiang Fixes: 03a3180e5c09e1 ("net: ethernet: mtk_eth_soc: introduce flow offloading support for mt7986") Signed-off-by: Daniel Golle Acked-by: Lorenzo Bianconi --- drivers/net/ethernet/mediatek/mtk_ppe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 25f8738a062bd0..4ea2b342f252ac 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -337,7 +337,7 @@ int mtk_foe_entry_set_vlan(struct mtk_eth *eth, struct mtk_foe_entry *entry, { struct mtk_foe_mac_info *l2 = mtk_foe_entry_l2(eth, entry); - switch (mtk_prep_ib1_vlan_layer(eth, entry->ib1)) { + switch (mtk_get_ib1_vlan_layer(eth, entry->ib1)) { case 0: entry->ib1 |= mtk_get_ib1_vlan_tag_mask(eth) | mtk_prep_ib1_vlan_layer(eth, 1); From patchwork Sun Sep 25 14:48:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 12988009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B1FBC04A95 for ; Sun, 25 Sep 2022 14:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=IFLT2hzEyF3+TnhAdjTrqq6/uaknXmaqUTs3cCGB+pU=; b=OdWgaU05z9mOhiAjcSdgq0Vk7B OQkZaWOT1XHu1La4J8CZGcQV++rKZttSJoVHdgVLSv5VSIT0jiESRQp1O00DtGzZIsVrnJGZNSDj4 K0z87GUS1k3buR+Vp1e7dSME7WXr2J4ekR7JhOXICf071TWHjOYqOWNRNsJ5VhFPx/MafDP2/ELa1 aCf1LlyvWs9RCuzbp3W03Y13StYp4By3mINFDU43r9t7CPZ8cu/ru4T7KYQCFJQIOj0oQqooQbe+s 0MjTC2917B4s2rif5pcOZukF4GbDXvecDw/7yal8iaIaWzo6eEx6i31/Q+gbY4+DYMmLElYHMDMnt vAwOgbpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocSwA-00EGUi-8S; Sun, 25 Sep 2022 14:48:54 +0000 Received: from fudo.makrotopia.org ([2a07:2ec0:3002::71]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocSw8-00EGTU-0U for linux-mediatek@lists.infradead.org; Sun, 25 Sep 2022 14:48:53 +0000 Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ocSw5-0002Ul-3B; Sun, 25 Sep 2022 16:48:50 +0200 Date: Sun, 25 Sep 2022 15:48:43 +0100 From: Daniel Golle To: linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, Lorenzo Bianconi Cc: Sujuan Chen , Bo Jiao , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Chen Minqiang Subject: [PATCH 2/2] net: ethernet: mtk_eth_soc: fix usage of foe_entry_size Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220925_074852_069771_19A211F8 X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org As sizeof(hwe->data) can now longer be used as the actual size depends on foe_entry_size, in commit 9d8cb4c096ab02 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc") the use of sizeof(hwe->data) is hence replaced. However, replacing it with ppe->eth->soc->foe_entry_size is wrong as foe_entry_size represents the size of the whole descriptor and not just the 'data' field. Fix this by subtracing the size of the only other field in the struct 'ib1', so we actually end up with the correct size to be copied to the data field. Reported-by: Chen Minqiang Fixes: 9d8cb4c096ab02 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc") Signed-off-by: Daniel Golle Acked-by: Lorenzo Bianconi --- drivers/net/ethernet/mediatek/mtk_ppe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 4ea2b342f252ac..887f430734f747 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -547,7 +547,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, } hwe = mtk_foe_get_entry(ppe, hash); - memcpy(&hwe->data, &entry->data, eth->soc->foe_entry_size); + memcpy(&hwe->data, &entry->data, eth->soc->foe_entry_size - sizeof(hwe->ib1)); wmb(); hwe->ib1 = entry->ib1;