From patchwork Fri Oct 21 21:54:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1693277 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=MmjciafA; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=nbF4wwtS; 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 4MvJHC69LJz23kq for ; Sat, 22 Oct 2022 08:57:43 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=yfeA/+7Ajk9Llgr9az+vwKByjMfHNjgH+6N0K582O58=; b=MmjciafAxICUo4 ZRDuM4m0QH4NYF6YTbxkgux0vwqjHViJ8QraFEsL5IZhlojXazAli/aq66chLCoV0wtA8IrbqRxcQ clRGNLxoBCxQyKsDcxgYGvbvE4/JG3Y9gMxqJrQXj6PKRaMYYsvmHXft+afL/P3QLT4XBQWUnnWMt iVtKxDnFWuzqQHYtonxr/bI2m71MzQbqfSI0gC+CKeYzGtbNPRKVyliMuBpaoNxMnfMoBcGHB+UVQ SfuKdExyJuj974SE3J9JmESHgevPaCVG0VDMLV4EoU5zgNE0Z5V1A392K8bTn2bH5JAvspY3BoHyQ oIht+mIu9aKIsLYt4WXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olzzD-00A4U5-4N; Fri, 21 Oct 2022 21:55:27 +0000 Received: from srv4.3e8.eu ([2001:67c:12a0:200::2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olzym-00A4NL-AJ for openwrt-devel@lists.openwrt.org; Fri, 21 Oct 2022 21:55:02 +0000 Received: from localhost.localdomain (p200300c6cf0a9ba0e4a0b66677a12f02.dip0.t-ipconnect.de [IPv6:2003:c6:cf0a:9ba0:e4a0:b666:77a1:2f02]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id A3BBA6011D; Fri, 21 Oct 2022 23:54:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1666389279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3moVzXqgoyaKTdr5EaiPo+Rtsg4ZUCuuPIVwI2p4Eoc=; b=nbF4wwtS71Q4MMBtJj1GK0t0pp0uEdiU5HNEjr4DKpINZ0f5V/eaVMcWlMGo9Ydn1o8d/U 1UFeKisA3Ie4CNeknMJMuof7PcztPIBav1ZSifz2j6dH8/VNRwSokmreRzQCEBRrbD5WxX 3qoWmSMhZu/laLrJyndyopdZT5yXulC9/TqkXVRy3LIcZUTT+wh0IpP6GTRmdf0Nn0uzi2 5GWHbLATK0igQI07J9EHBOkujUbb7YNAl8ceJMPkKZ+f2tildRU1dp7qcv95RssYIhCIWe Nr1Z864WSpnxqql4p9WTe0cADpMYG3vnDbdGObpyKLWFUuYSse+lsB0FOgc4zw== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 1/2] realtek: set up L2 table entries properly Date: Fri, 21 Oct 2022 23:54:26 +0200 Message-Id: <20221021215427.3719844-2-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221021215427.3719844-1-jan@3e8.eu> References: <20221021215427.3719844-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221021_145500_683487_178E3C12 X-CRM114-Status: GOOD ( 12.32 ) 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: Initialize the data structure using memset to avoid the possibility of writing garbage values to the hardware. Always set a valid entry type, which should fix writing unicast entries on RTL930x. For unicast entries, set the is_static flag to prevent the switch from aging them out. 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 Initialize the data structure using memset to avoid the possibility of writing garbage values to the hardware. Always set a valid entry type, which should fix writing unicast entries on RTL930x. For unicast entries, set the is_static flag to prevent the switch from aging them out. Also set the rvid field for unicast entries. This is not strictly necessary, as the switch fills it in automatically from a non-zero vid. However, this makes the code consistent with multicast entry setup. While at it, reorder the statements and fix some style issues (double space, comma instead of semicolon at end of statement). Also remove the unneeded priv parameter and debug print for the multicast entry setup function. Fixes: cde31976e37 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 3ff1a96ed680..45b489afa124 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1559,23 +1559,32 @@ static void dump_l2_entry(struct rtl838x_l2_entry *e) static void rtl83xx_setup_l2_uc_entry(struct rtl838x_l2_entry *e, int port, int vid, u64 mac) { - e->is_ip_mc = e->is_ipv6_mc = false; + memset(e, 0, sizeof(struct rtl838x_l2_entry)); + + e->type = L2_UNICAST; e->valid = true; + e->age = 3; - e->port = port, - e->vid = vid; + e->is_static = true; + + e->port = port; + + e->rvid = e->vid = vid; + e->is_ip_mc = e->is_ipv6_mc = false; u64_to_ether_addr(mac, e->mac); } -static void rtl83xx_setup_l2_mc_entry(struct rtl838x_switch_priv *priv, - struct rtl838x_l2_entry *e, int vid, u64 mac, int mc_group) +static void rtl83xx_setup_l2_mc_entry(struct rtl838x_l2_entry *e, int vid, u64 mac, int mc_group) { - e->is_ip_mc = e->is_ipv6_mc = false; + memset(e, 0, sizeof(struct rtl838x_l2_entry)); + + e->type = L2_MULTICAST; e->valid = true; + e->mc_portmask_index = mc_group; - e->type = L2_MULTICAST; + e->rvid = e->vid = vid; - pr_debug("%s: vid: %d, rvid: %d\n", __func__, e->vid, e->rvid); + e->is_ip_mc = e->is_ipv6_mc = false; u64_to_ether_addr(mac, e->mac); } @@ -1815,7 +1824,7 @@ static void rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, err = -ENOTSUPP; goto out; } - rtl83xx_setup_l2_mc_entry(priv, &e, vid, mac, mc_group); + rtl83xx_setup_l2_mc_entry(&e, vid, mac, mc_group); priv->r->write_l2_entry_using_hash(idx >> 2, idx & 0x3, &e); } goto out; @@ -1836,7 +1845,7 @@ static void rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, err = -ENOTSUPP; goto out; } - rtl83xx_setup_l2_mc_entry(priv, &e, vid, mac, mc_group); + rtl83xx_setup_l2_mc_entry(&e, vid, mac, mc_group); priv->r->write_cam(idx, &e); } goto out; From patchwork Fri Oct 21 21:54:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1693278 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=qnqPSfiD; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=QXH/0sYH; 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 4MvJHC0FrCz23kG for ; Sat, 22 Oct 2022 08:57:42 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=b9h81PSRev80WTecXp/nLfJDBUWLvtbvqn82csbExLQ=; b=qnqPSfiD11DoOB ciHPXgychJf1DGGHKMx/sqKuT4pC9TxsDd6/M2gWul9k3Ucgf0j0zDfG1/6YftT+gEc9Oxdi8Y8bV 8K3fknrFzFBxv5bBn9pMoDcRjbmTzX0y2wer9o23z12CX+vOAsOXaJXrjEDBSa4IKV0YPklQKAhX0 3EswYYWHsERz1Qj8xwhIT5bf5cZhpMO5wJDuK6M6leQlnogtU0h29zROZtZ3WNx13YwAlhg+zJwbR w3HTFQsFPZGIxIEUQqpfB3ISWDaExDQB/+eeCez9ehDoaiw7SDbWxcB6AwYZ4XTt+tqK+fyNjKQAx F5u1dlIooay1pr5a2J7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olzz1-00A4Ro-F7; Fri, 21 Oct 2022 21:55:15 +0000 Received: from srv4.3e8.eu ([2001:67c:12a0:200::2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olzyk-00A4NK-V4 for openwrt-devel@lists.openwrt.org; Fri, 21 Oct 2022 21:55:01 +0000 Received: from localhost.localdomain (p200300c6cf0a9ba0e4a0b66677a12f02.dip0.t-ipconnect.de [IPv6:2003:c6:cf0a:9ba0:e4a0:b666:77a1:2f02]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 8F9AD60129; Fri, 21 Oct 2022 23:54:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1666389280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FhJ+gp/ZAP0BlM1lx7zDVMHa385BNEp2SXZT2HmImYE=; b=QXH/0sYH52nQrbzLGvDKFp+sw1dbs3lAEDipWjY0K9bMXfM0YCztJcGgaGNgFZm51GToDd JEY96y3zohnkoit4wijtCsn7SHq+EWgGk6Qz/UHYUH+XJn70Yql9qs0mKrnnRr7reIgRSy S1+sMDlM46IBNv1h0Hi+5Ap4l7CcVhZWp2jDgepRAy8biANHRsSJ+Fi8LMA4SLGjh1lJ3Y 8Lfdal71xDpCjEbzoHaAR2isKytohy44cPiM8dqmR+aUgYauFwzsxmm1E67izDKJIHM95t 11hWaE4kgBDQpYQoeIuEcsj1Mh0TDKuzLU0x9oXTb/hmhdo4sgW0d05VTebVFQ== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 2/2] realtek: use assisted learning on CPU port Date: Fri, 21 Oct 2022 23:54:27 +0200 Message-Id: <20221021215427.3719844-3-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221021215427.3719844-1-jan@3e8.eu> References: <20221021215427.3719844-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221021_145459_741664_976A021D X-CRM114-Status: GOOD ( 15.19 ) 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: L2 learning on the CPU port is currently not consistently configured and relies on the default configuration of the device. On RTL83xx, it is disabled for packets transmitted with a TX header, as hard [...] 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 L2 learning on the CPU port is currently not consistently configured and relies on the default configuration of the device. On RTL83xx, it is disabled for packets transmitted with a TX header, as hardware learning corrupts the forwarding table otherwise. As a result, unneeded flooding of traffic for the CPU port can already happen on some devices now. It is also likely that similar issues exist on RTL93xx, which doesn't have a field to disable learning in the TX header. To address this, disable hardware learning for the CPU port globally on all devices. Instead, enable assisted learning to let DSA write FDB entries to the switch. For now, this does not sync local/bridge entries to the switch. However, support for that was added in Linux 5.14, so the next switch to a newer kernel version is going to fix this. Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 45b489afa124..f45002f33bfb 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -162,6 +162,16 @@ static void rtl83xx_setup_bpdu_traps(struct rtl838x_switch_priv *priv) priv->r->set_receive_management_action(i, BPDU, COPY2CPU); } +static void rtl83xx_port_set_salrn(struct rtl838x_switch_priv *priv, + int port, bool enable) +{ + int offset = (port & 0xf) << 1; + int val = enable ? 0 : 2; + + sw_w32_mask(0x3 << offset, val << offset, + priv->r->l2_port_new_salrn(port)); +} + static int rtl83xx_setup(struct dsa_switch *ds) { int i; @@ -205,6 +215,9 @@ static int rtl83xx_setup(struct dsa_switch *ds) priv->r->l2_learning_setup(); + rtl83xx_port_set_salrn(priv, priv->cpu_port, false); + ds->assisted_learning_on_cpu_port = true; + /* * Make sure all frames sent to the switch's MAC are trapped to the CPU-port * 0: FWD, 1: DROP, 2: TRAP2CPU @@ -263,6 +276,9 @@ static int rtl93xx_setup(struct dsa_switch *ds) priv->r->l2_learning_setup(); + rtl83xx_port_set_salrn(priv, priv->cpu_port, false); + ds->assisted_learning_on_cpu_port = true; + rtl83xx_enable_phy_polling(priv); priv->r->pie_init(priv);