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;