From patchwork Fri Oct 14 21:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1690170 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=mjPZAbVS; 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=fA4dd6O9; 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 4MpzgS2jbzz23jk for ; Sat, 15 Oct 2022 08:15:16 +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=zHHZLzY4izV52yMSOmZiS8H4sRONDCZtzbw/+HH/5Cc=; b=mjPZAbVS8Yznpj FMbrJyK6665o9mkhdAbx0ZtSuPzmEthgAuhQRoUuq3jQC7yrIlxIFd0bTZrgYSPOYlEUTEOOmRjBG MW4oDAD3QbZRiUddwNRX8/SKRwy4/ZEjQ/kceNFL2aQsFQ6//dg6RlBSc3sjl4A+lii/0/LtE3HeG lcWAiVkQ6g3ZzxcIgm8PsHpyN7Nvm8CeufvmfO7oX2FeF/LKaRNoY/ncJ8iaGfcNl9tHxf5W2ACfX GpaqdUkWWeSPrJ/THCjQzzyEm14DJ0HxK0GX1lYr4oHETSOhfs/T17kWME1Q9LMue+3q8d5X8eD0k qMhUgcd3EX7fQlGGlC6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRvl-00FvZF-R8; Fri, 14 Oct 2022 21:09:21 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRuv-00FvS8-Uq for openwrt-devel@lists.openwrt.org; Fri, 14 Oct 2022 21:08:32 +0000 Received: from localhost.localdomain (p200300c6cf1a0ba001060ed8c12b2b70.dip0.t-ipconnect.de [IPv6:2003:c6:cf1a:ba0:106:ed8:c12b:2b70]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id E10E66011D; Fri, 14 Oct 2022 23:08:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1665781692; 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=EbSb5U/GD7Gpmdqf7uC+AiuNvnm/R0CoWeRBCb0CpxY=; b=fA4dd6O97RempaewZ0cYqDBwMleqVs+9+peneaQqZbmvCQBQaAs30gC5xFSL0PD4C+/ZCC QTlv/PAhJSM6dhEUq60vMAcOLLIIJGIL4PWfR7KaaacSyYGs+efDQxgMjdv3i37Uk2kZBN ZsH2kYDgKE2s1+jwlHcg9MJc1z46HgWoXg116uaOAb/PLtG2X/CXbvU53KOz6qutdWQUEY xgIZf9SLMXpOFwQDSD4EzLznOB334D2vYgm9m5DbyJlx5Uc8Ka+lM5XtF/xxr3REfX062V HQXvUqy5fF6w/LnVeGVW0acxRc9FJt+ke4PC+b+4n3Mdq9EUVKb4C+rknXvj5w== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 1/5] realtek: avoid busy waiting for RTL839x PHY read/write Date: Fri, 14 Oct 2022 23:06:14 +0200 Message-Id: <20221014210618.3012368-2-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014210618.3012368-1-jan@3e8.eu> References: <20221014210618.3012368-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_140830_723135_F74769D0 X-CRM114-Status: GOOD ( 12.63 ) 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: Switch to a polling implementation similar to the one for RTL838x, to allow other kernel tasks to run while waiting. Signed-off-by: Jan Hoffmann --- .../drivers/net/dsa/rtl83xx/rtl839x.c | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) 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 Switch to a polling implementation similar to the one for RTL838x, to allow other kernel tasks to run while waiting. Signed-off-by: Jan Hoffmann --- .../drivers/net/dsa/rtl83xx/rtl839x.c | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c index 199ba347da38..29912257e829 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c @@ -630,9 +630,23 @@ int rtl8390_sds_power(int mac, int val) return 0; } +static int rtl839x_smi_wait_op(int timeout) +{ + int ret = 0; + u32 val; + + ret = readx_poll_timeout(sw_r32, RTL839X_PHYREG_ACCESS_CTRL, + val, !(val & 0x1), 20, timeout); + if (ret) + pr_err("%s: timeout\n", __func__); + + return ret; +} + int rtl839x_read_phy(u32 port, u32 page, u32 reg, u32 *val) { u32 v; + int err = 0; if (port > 63 || page > 4095 || reg > 31) return -ENOTSUPP; @@ -652,13 +666,15 @@ int rtl839x_read_phy(u32 port, u32 page, u32 reg, u32 *val) v |= 1; sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL); - do { - } while (sw_r32(RTL839X_PHYREG_ACCESS_CTRL) & 0x1); + err = rtl839x_smi_wait_op(100000); + if (err) + goto errout; *val = sw_r32(RTL839X_PHYREG_DATA_CTRL) & 0xffff; +errout: mutex_unlock(&smi_lock); - return 0; + return err; } int rtl839x_write_phy(u32 port, u32 page, u32 reg, u32 val) @@ -689,12 +705,14 @@ int rtl839x_write_phy(u32 port, u32 page, u32 reg, u32 val) v |= BIT(3) | 1; /* Write operation and execute */ sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL); - do { - } while (sw_r32(RTL839X_PHYREG_ACCESS_CTRL) & 0x1); + err = rtl839x_smi_wait_op(100000); + if (err) + goto errout; if (sw_r32(RTL839X_PHYREG_ACCESS_CTRL) & 0x2) err = -EIO; +errout: mutex_unlock(&smi_lock); return err; } @@ -722,15 +740,16 @@ int rtl839x_read_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 *val) v = BIT(2) | BIT(0); // MMD-access | EXEC sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL); - do { - v = sw_r32(RTL839X_PHYREG_ACCESS_CTRL); - } while (v & BIT(0)); + err = rtl839x_smi_wait_op(100000); + if (err) + goto errout; + // There is no error-checking via BIT 1 of v, as it does not seem to be set correctly *val = (sw_r32(RTL839X_PHYREG_DATA_CTRL) & 0xffff); pr_debug("%s: port %d, regnum: %x, val: %x (err %d)\n", __func__, port, regnum, *val, err); +errout: mutex_unlock(&smi_lock); - return err; } @@ -760,11 +779,13 @@ int rtl839x_write_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 val) v = BIT(3) | BIT(2) | BIT(0); // WRITE | MMD-access | EXEC sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL); - do { - v = sw_r32(RTL839X_PHYREG_ACCESS_CTRL); - } while (v & BIT(0)); + err = rtl839x_smi_wait_op(100000); + if (err) + goto errout; pr_debug("%s: port %d, regnum: %x, val: %x (err %d)\n", __func__, port, regnum, val, err); + +errout: mutex_unlock(&smi_lock); return err; } From patchwork Fri Oct 14 21:06:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1690167 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=CADmb+47; 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=UyiNUmtJ; 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 4MpzgL2pzKz23jk for ; Sat, 15 Oct 2022 08:15:10 +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=eGA2Ij4G754SPQnjmJDs3R3pbhrjMoyTK4CWB3rBsnU=; b=CADmb+47fl18Nv xjD+L8jnxOuc58y+TdSdOatHd3Rb5O6lFO2YP024nU3wJzJ/6kXUZAaCnCyMNx9ajV1Jt0nxkRyel U56yjaimADEV5H+zerqntY6IyDthJmquM5pT+BvdPkdrtujvo+jedRAGCGWFyTqXvBiBEWavWtmkr x52tSPtGuGQmhMI232XSeKm0zMywWFOjwYYM8NQZz1a4j/cF1SVS/MFiq9iCMAi1bZmEuS3MfTmNy YO5CVjBfcjNFcWDLNpuRsoZUZ8QRk2UaGP9CqXcqUcLgHO1siLR2qXBOfxYbWJv9pRXzh+pW3x5ID uq5ULhPaV78UuMkDiUHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRvB-00FvVJ-1F; Fri, 14 Oct 2022 21:08:45 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRut-00FvSA-O2 for openwrt-devel@lists.openwrt.org; Fri, 14 Oct 2022 21:08:30 +0000 Received: from localhost.localdomain (p200300c6cf1a0ba001060ed8c12b2b70.dip0.t-ipconnect.de [IPv6:2003:c6:cf1a:ba0:106:ed8:c12b:2b70]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 065B160129; Fri, 14 Oct 2022 23:08:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1665781693; 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=i8TAMSjCJWEIiV1CyIQ18EC6JDliXCqlbwjmK898HBQ=; b=UyiNUmtJti+sEuRP0QBjnkpzwBDirR/wpPiZhOkegyqFiU01U63ZsmEIUZoekMVd3/KJvm f98XWMrnelXvJEe/Q5CMyHrXSg/QK1OVWdnkgiohgLTS2oG1EpdL56GSFck+Dq1/TVVVui biA44D+2O7k/l3y7cqD5VyENS33TmvPD8U4oS5qT4WsoefW2SoXh8YsPHhNN68Kmnpph1r BDMgvMimp0Bt8H9IBUrnETvyuJ5eu5fTWS7ZNFm5WjWHXiuB/zivSQ+V0Ao3F4dfpVZwAR wmh6AcfPnYwy5MqytvTXtE2TSps5s6J+NxeUJ8p/Izdy1sAD0vqPlf0R04Bc3Q== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 2/5] realtek: simplify log messages in rtl83xx_mdio_probe Date: Fri, 14 Oct 2022 23:06:15 +0200 Message-Id: <20221014210618.3012368-3-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014210618.3012368-1-jan@3e8.eu> References: <20221014210618.3012368-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_140828_414554_63CFBE32 X-CRM114-Status: UNSURE ( 8.81 ) X-CRM114-Notice: Please train this message. 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: This function currently prints three messages for every switch port at KERN_INFO level. This takes a considerable amount of time during bootup and can even trigger an external watchdog. Replace these log messages by a single one at KERN_DEBUG level. 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 This function currently prints three messages for every switch port at KERN_INFO level. This takes a considerable amount of time during bootup and can even trigger an external watchdog. Replace these log messages by a single one at KERN_DEBUG level. Signed-off-by: Jan Hoffmann --- .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c index 2a60f61c9582..13e63a5f0c5d 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c @@ -323,7 +323,6 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) if (of_property_read_u32(dn, "reg", &pn)) continue; - pr_info("%s found port %d\n", __func__, pn); phy_node = of_parse_phandle(dn, "phy-handle", 0); if (!phy_node) { if (pn != priv->cpu_port) @@ -331,14 +330,13 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv) continue; } - pr_info("%s port %d has phandle\n", __func__, pn); if (of_property_read_u32(phy_node, "sds", &priv->ports[pn].sds_num)) priv->ports[pn].sds_num = -1; else { pr_info("%s sds port %d is %d\n", __func__, pn, priv->ports[pn].sds_num); } - pr_info("%s port %d has SDS\n", __func__, priv->ports[pn].sds_num); + pr_debug("%s port %d has SDS %d\n", __func__, pn, priv->ports[pn].sds_num); if (of_get_phy_mode(dn, &interface)) interface = PHY_INTERFACE_MODE_NA; From patchwork Fri Oct 14 21:06:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1690166 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=t074n84g; 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=CDukk+s3; 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 4MpzgL4l1xz23kJ for ; Sat, 15 Oct 2022 08:15:10 +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=IqbJUzZRcnaL7IcDov49eFlcHKJEJEn4kGAIeGf3CGw=; b=t074n84ghIkVWc 39Y09TyL4lljVtPKsYjnINqAwN+rdTeyPnqBKNLez9Vqnwm7qJ7gtCg+fOGqO5of4N2JL460spFST v/RkHMp3gcvYrPVbjiq6oTOxKd8JYUw6bNP52A4AfR+BIfvP4Ee7kuCsuboAs/dGcW17Fe5XicDbF OwFH5wzb2Vi6Jg7FgJWhrL79OF1nN51FvUED2fQ8IX8Oc3N89NySZX8kTC8qZx7dLcNCBiqcw4TYr 8olhZNgIqBzw8igeyH4G/FcTDFqzml6k4ozsaeNCJhPmrwtUg+QOCyJdneHI0ndEjaIOOM69I0Rs7 h35pEXRY6IevqV/hwxvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRvM-00FvVj-IR; Fri, 14 Oct 2022 21:08:56 +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 1ojRuu-00FvSB-Lc for openwrt-devel@lists.openwrt.org; Fri, 14 Oct 2022 21:08:31 +0000 Received: from localhost.localdomain (p200300c6cf1a0ba001060ed8c12b2b70.dip0.t-ipconnect.de [IPv6:2003:c6:cf1a:ba0:106:ed8:c12b:2b70]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id B845160185; Fri, 14 Oct 2022 23:08:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1665781693; 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=8On0eSuYzPTslfuc2YSeZSP05xtKirv4KMP8HBFtPBs=; b=CDukk+s3lBEhOZFGPp6kbFX9JRyjpse/AuNwVHODvVTL7blZ8xU9e2hob0g5Gq9cnbISPI 3C3mF1XCen30sIvWW3zLg7Z98R500igJW2M/8Nz+zEaFFV5e5fO0bV4xYCkHUG5ALkpoRw simZC9B+dh7w+LJ+ywof9fV8TmwRyNYME53ThsnUygGHL1BSmvp1mJks8GJIzbBK4Gym/A a46PDBqYI4G9FxDJ6ra9LWbCXLmXf7YZ3T0vMYbS5T22yry9ffZFkcvyAo0xOJsPYlyP7Z N3cLdswVdZbB3XCJprZutnY4Kp3JuOQAD3pZW6UQuQI7gsfJG13QiiRXhiLW5g== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 3/5] realtek: add debugfs node for L2 table Date: Fri, 14 Oct 2022 23:06:16 +0200 Message-Id: <20221014210618.3012368-4-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014210618.3012368-1-jan@3e8.eu> References: <20221014210618.3012368-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_140829_033392_ED415F6E X-CRM114-Status: GOOD ( 13.30 ) 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: This allows to view all unicast and multicast entries that are currently in the L2 hash table and the CAM. Signed-off-by: Jan Hoffmann --- .../drivers/net/dsa/rtl83xx/debugfs.c | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) 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 This allows to view all unicast and multicast entries that are currently in the L2 hash table and the CAM. Signed-off-by: Jan Hoffmann --- .../drivers/net/dsa/rtl83xx/debugfs.c | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/debugfs.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/debugfs.c index 21f00096e5bd..6dd064c95bda 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/debugfs.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/debugfs.c @@ -270,6 +270,109 @@ static const struct file_operations drop_counter_fops = { .read = drop_counter_read, }; +static void l2_table_print_entry(struct seq_file *m, struct rtl838x_switch_priv *priv, + struct rtl838x_l2_entry *e) +{ + u64 portmask; + int i; + + if (e->type == L2_UNICAST) { + seq_puts(m, "L2_UNICAST\n"); + + seq_printf(m, " mac %02x:%02x:%02x:%02x:%02x:%02x vid %u rvid %u\n", + e->mac[0], e->mac[1], e->mac[2], e->mac[3], e->mac[4], e->mac[5], + e->vid, e->rvid); + + seq_printf(m, " port %d age %d", e->port, e->age); + if (e->is_static) + seq_puts(m, " static"); + if (e->block_da) + seq_puts(m, " block_da"); + if (e->block_sa) + seq_puts(m, " block_sa"); + if (e->suspended) + seq_puts(m, " suspended"); + if (e->next_hop) + seq_printf(m, " next_hop route_id %u", e->nh_route_id); + seq_puts(m, "\n"); + + } else { + if (e->type == L2_MULTICAST) { + seq_puts(m, "L2_MULTICAST\n"); + + seq_printf(m, " mac %02x:%02x:%02x:%02x:%02x:%02x vid %u rvid %u\n", + e->mac[0], e->mac[1], e->mac[2], e->mac[3], e->mac[4], e->mac[5], + e->vid, e->rvid); + } + + if (e->type == IP4_MULTICAST || e->type == IP6_MULTICAST) { + seq_puts(m, (e->type == IP4_MULTICAST) ? + "IP4_MULTICAST\n" : "IP6_MULTICAST\n"); + + seq_printf(m, " gip %08x sip %08x vid %u rvid %u\n", + e->mc_gip, e->mc_sip, e->vid, e->rvid); + } + + portmask = priv->r->read_mcast_pmask(e->mc_portmask_index); + seq_printf(m, " index %u ports", e->mc_portmask_index); + for (i = 0; i < 64; i++) { + if (portmask & BIT_ULL(i)) + seq_printf(m, " %d", i); + } + seq_puts(m, "\n"); + } + + seq_puts(m, "\n"); +} + +static int l2_table_show(struct seq_file *m, void *v) +{ + struct rtl838x_switch_priv *priv = m->private; + struct rtl838x_l2_entry e; + int i, bucket, index; + + mutex_lock(&priv->reg_mutex); + + for (i = 0; i < priv->fib_entries; i++) { + bucket = i >> 2; + index = i & 0x3; + priv->r->read_l2_entry_using_hash(bucket, index, &e); + + if (!e.valid) + continue; + + seq_printf(m, "Hash table bucket %d index %d ", bucket, index); + l2_table_print_entry(m, priv, &e); + } + + for (i = 0; i < 64; i++) { + priv->r->read_cam(i, &e); + + if (!e.valid) + continue; + + seq_printf(m, "CAM index %d ", i); + l2_table_print_entry(m, priv, &e); + } + + mutex_unlock(&priv->reg_mutex); + + return 0; +} + +static int l2_table_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, l2_table_show, inode->i_private); +} + +static const struct file_operations l2_table_fops = { + .owner = THIS_MODULE, + .open = l2_table_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static ssize_t age_out_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { @@ -608,6 +711,8 @@ void rtl838x_dbgfs_init(struct rtl838x_switch_priv *priv) debugfs_create_file("drop_counters", 0400, rtl838x_dir, priv, &drop_counter_fops); + debugfs_create_file("l2_table", 0400, rtl838x_dir, priv, &l2_table_fops); + return; err: rtl838x_dbgfs_cleanup(priv); @@ -625,4 +730,6 @@ void rtl930x_dbgfs_init(struct rtl838x_switch_priv *priv) priv->dbgfs_dir = dbg_dir; debugfs_create_file("drop_counters", 0400, dbg_dir, priv, &drop_counter_fops); + + debugfs_create_file("l2_table", 0400, dbg_dir, priv, &l2_table_fops); } From patchwork Fri Oct 14 21:06:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1690169 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=lR0obAqV; 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=f0vdFvN5; 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 4MpzgL3q6bz23kH for ; Sat, 15 Oct 2022 08:15:10 +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=yzMxzMUfkbMPWax1tKkK5ve8In+e34IWYvDty2Q2RG0=; b=lR0obAqV/jaSqe kzaaMdnDeP3gbi5UomnSskKOe+cidIihVY9vS1nP3xzWWmdEnQUNNRwop4MY1unZU5cNoBkkoT0JB YB21oHIBoqWWEZOrJHVHgHoIc1yjVJ0OSg22oVU/IvbhvO0FCNsJV4vkfm8Wk8iJHHvRbwQbOwCy+ IPRK5CB/g+TtqC+KVKjo8gPuIUcBKpVlKYcrDqmBf1s3fUtQ4R+wC1NKF1KBUfRKNmGdWNfqxidgu OpoKBRDmC9QGAJ4/n09j2BkbXaUi4YBCwArgLPx3IWigp5jiZihZpdRsD8oku/umm/ABH++BQrMkj pwFXklo17dAualOimepw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRvY-00FvWR-Hz; Fri, 14 Oct 2022 21:09:08 +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 1ojRut-00FvSC-Em for openwrt-devel@lists.openwrt.org; Fri, 14 Oct 2022 21:08:31 +0000 Received: from localhost.localdomain (p200300c6cf1a0ba001060ed8c12b2b70.dip0.t-ipconnect.de [IPv6:2003:c6:cf1a:ba0:106:ed8:c12b:2b70]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 6E00260186; Fri, 14 Oct 2022 23:08:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1665781694; 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=9eAjO5+ins4JVOZ7NNCjjKETbkW9mcy0JtLLuFht28k=; b=f0vdFvN5Sx8R9dnMGzXk/1O7hNtAFMTJqdRDnkzw9sW8mRhFR72VnXMQkfXPyZ4W+yNOSy yILbWaPx4keg6eihkZP+wWf+vbV84Rn37ToeJumG5repKrTWFau0cSWTXb3NVqjRG5H5Hb 6C9CMJ3Cqz7qRs4KVbf1+3OXXX5gOI74ONnCL5wcny/01D7hDvCadJn1zRm1awxPwmWeQ5 vikgr9MvQ3d2x3dfMSEcS0TjoAVRNR/qFNL7Gh/WPFNlEOHR/g+Q26aggeB5wqgQSWJxAf UGYws2qIWp5P7NYvR4uahm9tkxplqT3jEpozPrEF7pziDAyPQyf6OkTBt+KH/w== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 4/5] realtek: reduce excessive logging for FDB operations Date: Fri, 14 Oct 2022 23:06:17 +0200 Message-Id: <20221014210618.3012368-5-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014210618.3012368-1-jan@3e8.eu> References: <20221014210618.3012368-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_140828_411087_2D919A27 X-CRM114-Status: GOOD ( 12.47 ) 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: Currently several messages at KERN_INFO level are printed for every FDB del/dump operation. This can cause a significant slowdown for example while using "bridge fdb", and may even trigger a watchdog. 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 Currently several messages at KERN_INFO level are printed for every FDB del/dump operation. This can cause a significant slowdown for example while using "bridge fdb", and may even trigger a watchdog. Remove most of these log messages, as the new L2 table debugfs node should be a good replacement. Change the remaining messages to KERN_DEBUG level. Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 55 +------------------ .../drivers/net/dsa/rtl83xx/rtl930x.c | 16 ------ 2 files changed, 3 insertions(+), 68 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..10e6103f0d63 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 @@ -1535,28 +1535,6 @@ static int rtl83xx_vlan_del(struct dsa_switch *ds, int port, return 0; } -static void dump_l2_entry(struct rtl838x_l2_entry *e) -{ - pr_info("MAC: %02x:%02x:%02x:%02x:%02x:%02x vid: %d, rvid: %d, port: %d, valid: %d\n", - e->mac[0], e->mac[1], e->mac[2], e->mac[3], e->mac[4], e->mac[5], - e->vid, e->rvid, e->port, e->valid); - - if (e->type != L2_MULTICAST) { - pr_info("Type: %d, is_static: %d, is_ip_mc: %d, is_ipv6_mc: %d, block_da: %d\n", - e->type, e->is_static, e->is_ip_mc, e->is_ipv6_mc, e->block_da); - pr_info(" block_sa: %d, susp: %d, nh: %d, age: %d, is_trunk: %d, trunk: %d\n", - e->block_sa, e->suspended, e->next_hop, e->age, e->is_trunk, e->trunk); - } - if (e->type == L2_MULTICAST) - pr_info(" L2_MULTICAST mc_portmask_index: %d\n", e->mc_portmask_index); - if (e->is_ip_mc || e->is_ipv6_mc) - pr_info(" mc_portmask_index: %d, mc_gip: %d, mc_sip: %d\n", - e->mc_portmask_index, e->mc_gip, e->mc_sip); - pr_info(" stack_dev: %d\n", e->stack_dev); - if (e->next_hop) - pr_info(" nh_route_id: %d\n", e->nh_route_id); -} - 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; @@ -1685,15 +1663,14 @@ static int rtl83xx_port_fdb_del(struct dsa_switch *ds, int port, int err = 0, idx; u64 seed = priv->r->l2_hash_seed(mac, vid); - pr_info("In %s, mac %llx, vid: %d\n", __func__, mac, vid); + pr_debug("In %s, mac %llx, vid: %d\n", __func__, mac, vid); mutex_lock(&priv->reg_mutex); idx = rtl83xx_find_l2_hash_entry(priv, seed, true, &e); if (idx >= 0) { - pr_info("Found entry index %d, key %d and bucket %d\n", idx, idx >> 2, idx & 3); + pr_debug("Found entry index %d, key %d and bucket %d\n", idx, idx >> 2, idx & 3); e.valid = false; - dump_l2_entry(&e); priv->r->write_l2_entry_using_hash(idx >> 2, idx & 0x3, &e); goto out; } @@ -1718,8 +1695,6 @@ static int rtl83xx_port_fdb_dump(struct dsa_switch *ds, int port, struct rtl838x_l2_entry e; struct rtl838x_switch_priv *priv = ds->priv; int i; - u32 fid, pkey; - u64 mac; mutex_lock(&priv->reg_mutex); @@ -1729,30 +1704,8 @@ static int rtl83xx_port_fdb_dump(struct dsa_switch *ds, int port, if (!e.valid) continue; - if (e.port == port || e.port == RTL930X_PORT_IGNORE) { - u64 seed; - u32 key; - - fid = ((i >> 2) & 0x3ff) | (e.rvid & ~0x3ff); - mac = ether_addr_to_u64(&e.mac[0]); - pkey = priv->r->l2_hash_key(priv, priv->r->l2_hash_seed(mac, fid)); - fid = (pkey & 0x3ff) | (fid & ~0x3ff); - pr_info("-> index %d, key %x, bucket %d, dmac %016llx, fid: %x rvid: %x\n", - i, i >> 2, i & 0x3, mac, fid, e.rvid); - dump_l2_entry(&e); - seed = priv->r->l2_hash_seed(mac, e.rvid); - key = priv->r->l2_hash_key(priv, seed); - pr_info("seed: %016llx, key based on rvid: %08x\n", seed, key); + if (e.port == port || e.port == RTL930X_PORT_IGNORE) cb(e.mac, e.vid, e.is_static, data); - } - if (e.type == L2_MULTICAST) { - u64 portmask = priv->r->read_mcast_pmask(e.mc_portmask_index); - - if (portmask & BIT_ULL(port)) { - dump_l2_entry(&e); - pr_info(" PM: %016llx\n", portmask); - } - } } for (i = 0; i < 64; i++) { @@ -1876,7 +1829,6 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, portmask = rtl83xx_mc_group_del_port(priv, e.mc_portmask_index, port); if (!portmask) { e.valid = false; - // dump_l2_entry(&e); priv->r->write_l2_entry_using_hash(idx >> 2, idx & 0x3, &e); } goto out; @@ -1889,7 +1841,6 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, portmask = rtl83xx_mc_group_del_port(priv, e.mc_portmask_index, port); if (!portmask) { e.valid = false; - // dump_l2_entry(&e); priv->r->write_cam(idx, &e); } goto out; diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl930x.c index cd93e4bc8ec1..e89d75d4b9b5 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl930x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl930x.c @@ -579,22 +579,6 @@ static void rtl930x_write_cam(int idx, struct rtl838x_l2_entry *e) rtl_table_release(q); } -static void dump_l2_entry(struct rtl838x_l2_entry *e) -{ - pr_info("MAC: %02x:%02x:%02x:%02x:%02x:%02x vid: %d, rvid: %d, port: %d, valid: %d\n", - e->mac[0], e->mac[1], e->mac[2], e->mac[3], e->mac[4], e->mac[5], - e->vid, e->rvid, e->port, e->valid); - pr_info("Type: %d, is_static: %d, is_ip_mc: %d, is_ipv6_mc: %d, block_da: %d\n", - e->type, e->is_static, e->is_ip_mc, e->is_ipv6_mc, e->block_da); - pr_info(" block_sa: %d, suspended: %d, next_hop: %d, age: %d, is_trunk: %d, trunk: %d\n", - e->block_sa, e->suspended, e->next_hop, e->age, e->is_trunk, e->trunk); - if (e->is_ip_mc || e->is_ipv6_mc) - pr_info(" mc_portmask_index: %d, mc_gip: %d, mc_sip: %d\n", - e->mc_portmask_index, e->mc_gip, e->mc_sip); - pr_info(" stac_dev: %d, nh_route_id: %d, port: %d, dev_id\n", - e->stack_dev, e->nh_route_id, e->port); -} - static u64 rtl930x_read_mcast_pmask(int idx) { u32 portmask; From patchwork Fri Oct 14 21:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1690165 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=vwU9W2BE; 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=mO9F2Uba; 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 4MpzgL3hMRz23kF for ; Sat, 15 Oct 2022 08:15:10 +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=KC4ObCcjlrmHaEpJRZe/Y93KnA1oPcgETd8LpmEb0xY=; b=vwU9W2BEnaNhRG mWXifOVxkfJuSeN5DfUWUt4tMSkFi4XeWC/37I8QlXe1R63KicJxoZ66TdP+70nTQB6WE/sVgr6Z9 UlPUConGo6ni2Wxtkxb8GC4JEiX6ClFipk0myMA3HKYFFniX6ta5/t/p7WhaZ2qWsxAZ9j32dxqiW 0EQFFdccaS3EbaoPY/JTbwyJ22bq9Wb2FpDaRHyvxV74zb+QwOys439KmPOXNGtGCR7orS9FKBU9c yxnJA+x2dxA/Ini9dASEQeEhk5fX0S85jBtqQkH5x3WLuCNVfVUq6LfasTCbruQWpVd+hoOMV/MDZ jQs7hgd8vryzR7Hdczzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRvz-00Fvd8-Sd; Fri, 14 Oct 2022 21:09:36 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojRux-00FvUH-Ss for openwrt-devel@lists.openwrt.org; Fri, 14 Oct 2022 21:08:33 +0000 Received: from localhost.localdomain (p200300c6cf1a0ba001060ed8c12b2b70.dip0.t-ipconnect.de [IPv6:2003:c6:cf1a:ba0:106:ed8:c12b:2b70]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 2BA2460187; Fri, 14 Oct 2022 23:08:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1665781695; 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=VOk0T+ajn4a7+gpd7w2yLYKMVEO8s2I/mkaL5AOQ5Hk=; b=mO9F2Ubavz0//4w1Zb9ie1fhGROu5GkF4f+9S31vp/20NIWZj4joDHVj5Axfi1reNyfJ2x gCCvJ/4HlbQcMWKcq/5XmW81E92ygHf9aDMYyZvswSzVsXYYAE54x56CK8V8qu2i2dkaA4 VzpqiCOnHCCXqUtAdaFGb58eRrjPB+XnucvLwnMvuQorjFELtwAy0UDiHC75AroXDXMS2V vrBSTGkcXhD4mXfTyTuH6230EPDYu03QaTEryN3ROJNg2ohHcTdYOOmnjaQJXnq6oQyMgn fHTGVxD2uwOZ08UDfdStYDrXQjR4/WLFWRUA+R4kp4KLsScBje/c284sTpqJMg== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Sander Vanheule , Jan Hoffmann Subject: [PATCH 5/5] realtek: restructure rtl_table_read/write Date: Fri, 14 Oct 2022 23:06:18 +0200 Message-Id: <20221014210618.3012368-6-jan@3e8.eu> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014210618.3012368-1-jan@3e8.eu> References: <20221014210618.3012368-1-jan@3e8.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_140832_241589_6D91FD01 X-CRM114-Status: GOOD ( 19.39 ) 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: These two functions are identical apart from writing different values to the read/write bit. Create a new function rtl_table_exec to reduce code duplication. Also replace the unbounded busy-waiting loop. As the hardware usually responds very quickly, always call cond_resched, so that callers do not need to worry about blocking for too long. This is especia [...] 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 These two functions are identical apart from writing different values to the read/write bit. Create a new function rtl_table_exec to reduce code duplication. Also replace the unbounded busy-waiting loop. As the hardware usually responds very quickly, always call cond_resched, so that callers do not need to worry about blocking for too long. This is especially important for the L2 table, as a full loop (as in rtl83xx_port_fdb_dump) takes about 20ms on RTL839x (and that function actually ends up being called in a loop for every port). So far, polling timeout errors are only handled by logging an error, but a return value is added to allow proper handling in the future. Signed-off-by: Jan Hoffmann --- I'm not really sure if putting cond_resched in this place is really the best solution. An alternative would be to place it directly in the loops (i.e. rtl83xx_port_fdb_dump and l2_table_show) instead. About error handling: Actually implementing that for all calls is going to require large changes. And doing it in a proper way which is better than just printing an error (i.e. actually trying to leave a consistent state) is non-trivial. I started to work on that only for fdb/mdb access, but that is only a part of where these tables are used: https://github.com/janh/openwrt/commit/e45403299208d49675a0403ad94349ebdff2a374 https://github.com/janh/openwrt/commit/fa68b23cab542683832696f039cf160b96da83db https://github.com/janh/openwrt/commit/92abfc2e4925e5bc1a0e25e464ca1d08833c9b30 .../drivers/net/dsa/rtl83xx/common.c | 47 ++++++++++++++----- .../drivers/net/dsa/rtl83xx/rtl83xx.h | 4 +- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c index 13e63a5f0c5d..5e7c65247fc0 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/common.c @@ -121,28 +121,51 @@ void rtl_table_release(struct table_reg *r) // pr_info("Unlock done\n"); } +static int rtl_table_exec(struct table_reg *r, bool is_write, int idx) +{ + int ret = 0; + u32 cmd, val; + + /* Read/write bit has inverted meaning on RTL838x */ + if (r->rmode) + cmd = is_write ? 0 : BIT(r->c_bit); + else + cmd = is_write ? BIT(r->c_bit) : 0; + + cmd |= BIT(r->c_bit + 1); /* Execute bit */ + cmd |= r->tbl << r->t_bit; /* Table type */ + cmd |= idx & (BIT(r->t_bit) - 1); /* Index */ + + sw_w32(cmd, r->addr); + + /* The hardware typically responds immediately, so make sure that + * other tasks always get a chance to run even if this function is + * called in a loop. + */ + cond_resched(); + + ret = readx_poll_timeout(sw_r32, r->addr, val, + !(val & BIT(r->c_bit + 1)), 20, 10000); + if (ret) + pr_err("%s: timeout\n", __func__); + + return ret; +} + /* * Reads table index idx into the data registers of the table */ -void rtl_table_read(struct table_reg *r, int idx) +int rtl_table_read(struct table_reg *r, int idx) { - u32 cmd = r->rmode ? BIT(r->c_bit) : 0; - - cmd |= BIT(r->c_bit + 1) | (r->tbl << r->t_bit) | (idx & (BIT(r->t_bit) - 1)); - sw_w32(cmd, r->addr); - do { } while (sw_r32(r->addr) & BIT(r->c_bit + 1)); + return rtl_table_exec(r, false, idx); } /* * Writes the content of the table data registers into the table at index idx */ -void rtl_table_write(struct table_reg *r, int idx) +int rtl_table_write(struct table_reg *r, int idx) { - u32 cmd = r->rmode ? 0 : BIT(r->c_bit); - - cmd |= BIT(r->c_bit + 1) | (r->tbl << r->t_bit) | (idx & (BIT(r->t_bit) - 1)); - sw_w32(cmd, r->addr); - do { } while (sw_r32(r->addr) & BIT(r->c_bit + 1)); + return rtl_table_exec(r, true, idx); } /* diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl83xx.h b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl83xx.h index 107016469c69..485d0e8a7e9c 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl83xx.h +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl83xx.h @@ -67,8 +67,8 @@ typedef enum { void rtl_table_init(void); struct table_reg *rtl_table_get(rtl838x_tbl_reg_t r, int t); void rtl_table_release(struct table_reg *r); -void rtl_table_read(struct table_reg *r, int idx); -void rtl_table_write(struct table_reg *r, int idx); +int rtl_table_read(struct table_reg *r, int idx); +int rtl_table_write(struct table_reg *r, int idx); inline u16 rtl_table_data(struct table_reg *r, int i); inline u32 rtl_table_data_r(struct table_reg *r, int i); inline void rtl_table_data_w(struct table_reg *r, u32 v, int i);