From patchwork Thu Sep 8 17:35:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 1675745 X-Patchwork-Delegate: sander@svanheule.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=1L3b0z+G; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.a=rsa-sha256 header.s=b header.b=Ki8FmI6/; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MNmYZ4WPPz1yhR for ; Fri, 9 Sep 2022 03:38:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3g/5QkSFRDlrJM9Ut6kBEn3/2O+fn/aYPVjLWC6z0i0=; b=1L3b0z+GXgirIq ElgEzcRbn7ysGRuK2Uw4SVc7ky5pGQdDygzLAiUdqgdh4u3RM1DDFVAgMLTBIFjAznhrVtxB1QYZY 3s1uk2zbuP9hIr3VlyVBFjWTjio7bHieF9g+e3gnc03PbuzlvnJNmOujt/n0wCpfTxeRYEuhqvasv hYKkHcm+NRpjaU54cj4C9La6MkYroI80V7F9Y6IwkKKNt6kgGWyHBJp5UuuG1DnIRX6mKD0iv2/kJ 5gMjZzttmmz9FZDDMHB81Chpovq9dasYdXfTdVxtDhkf0zSAAbi9R02Y5NioyrmdISWF6yf0Y231j vowO3CBaX78jztvu1AUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWLRo-006Lmb-3B; Thu, 08 Sep 2022 17:36:16 +0000 Received: from louie.mork.no ([2001:41c8:51:8a:feff:ff:fe00:e5]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWLRZ-006LcU-6a for openwrt-devel@lists.openwrt.org; Thu, 08 Sep 2022 17:36:06 +0000 Received: from canardo.dyn.mork.no ([IPv6:2a01:799:c9e:d400:0:0:0:1]) (authenticated bits=0) by louie.mork.no (8.15.2/8.15.2) with ESMTPSA id 288HZhLf1017964 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Thu, 8 Sep 2022 18:35:44 +0100 Received: from canardo.dyn.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.dyn.mork.no (8.15.2/8.15.2) with ESMTPS id 288HZbwK1324287 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Thu, 8 Sep 2022 19:35:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1662658538; bh=fWby5N7fNzlUEQCQbjdZo398lSkiPtsz5gB94i/jT0A=; h=From:To:Cc:Subject:Date:Message-Id:From; b=Ki8FmI6/QxX3VHMJfp9GuJLF1tTo9y+iu5OlV0ZgJALV37yxN9LwOLF2hXn/0qEcC /ny8M002KPay0ZTIae8yDQiuHUq1uMTPNcO1aZVcu2SQckTpjk99Rvq688TEMLXJug pG6h4YB1aKZO0VYIjjd0CaDlT11ARfDGOuO05hqA= Received: (from bjorn@localhost) by canardo.dyn.mork.no (8.15.2/8.15.2/Submit) id 288HZbMV1324286; Thu, 8 Sep 2022 19:35:37 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= , Jan Hoffmann Subject: [PATCH] realtek: fix RTL838x receive tag decoding Date: Thu, 8 Sep 2022 19:35:34 +0200 Message-Id: <20220908173534.1324239-1-bjorn@mork.no> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on canardo.dyn.mork.no X-Virus-Scanned: clamav-milter 0.103.6 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220908_103601_710714_27E481F7 X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Commit dc9cc0d3e2a1 ("realtek: add QoS and rate control") replaced a 16 bit reserved field in the RTL83xx packet header with the initial cpu_tag word, shifting the real cpu_tag fields by one. Adjustin [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Commit dc9cc0d3e2a1 ("realtek: add QoS and rate control") replaced a 16 bit reserved field in the RTL83xx packet header with the initial cpu_tag word, shifting the real cpu_tag fields by one. Adjusting for this new shift was partially forgotten in the new RX tag decoders. This caused the switch to block IGMP, effectively blocking IPv4 multicast. The bug was partially fixed by commit 9d847244d9fd ("realtek: fix RTL839X receive tag decoding") Fix on RTL838x too, including correct NIC_RX_REASON_SPECIAL_TRAP value. Based-on-fix-by: Jan Hoffmann Fixes: dc9cc0d3e2a1 ("realtek: add QoS and rate control") Signed-off-by: Bjørn Mork --- .../files-5.10/drivers/net/ethernet/rtl838x_eth.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c index 0eee06d803ad..d9ade6552698 100644 --- a/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c +++ b/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c @@ -58,6 +58,7 @@ struct p_hdr { uint16_t size; /* buffer size */ uint16_t offset; uint16_t len; /* pkt len */ + /* cpu_tag[0] is a reserved uint16_t on RTL83xx */ uint16_t cpu_tag[10]; } __packed __aligned(1); @@ -262,13 +263,14 @@ struct dsa_tag { bool rtl838x_decode_tag(struct p_hdr *h, struct dsa_tag *t) { - t->reason = h->cpu_tag[3] & 0xf; - t->queue = (h->cpu_tag[0] & 0xe0) >> 5; + /* cpu_tag[0] is reserved. Fields are off-by-one */ + t->reason = h->cpu_tag[4] & 0xf; + t->queue = (h->cpu_tag[1] & 0xe0) >> 5; t->port = h->cpu_tag[1] & 0x1f; t->crc_error = t->reason == 13; pr_debug("Reason: %d\n", t->reason); - if (t->reason != 4) // NIC_RX_REASON_SPECIAL_TRAP + if (t->reason != 6) // NIC_RX_REASON_SPECIAL_TRAP t->l2_offloaded = 1; else t->l2_offloaded = 0; @@ -278,6 +280,7 @@ bool rtl838x_decode_tag(struct p_hdr *h, struct dsa_tag *t) bool rtl839x_decode_tag(struct p_hdr *h, struct dsa_tag *t) { + /* cpu_tag[0] is reserved. Fields are off-by-one */ t->reason = h->cpu_tag[5] & 0x1f; t->queue = (h->cpu_tag[3] & 0xe000) >> 13; t->port = h->cpu_tag[1] & 0x3f;