From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796205451; b=h2a+tqlXBDkIo1kr5WjClyCii5+T9lC6LV8pSYNMV4eOKaV8UG0QrycDIQcNoSsPitZz YQtrNiyNLNUT/m1AnYnMzGQbIHGpkao3LvESFr+B1C88CthcgjfKWDSY29BdO/NuYm2Tx aB88kCnBhi1ci0WJo4D2pmDBECwDtLQ4+0+14XA674LgNuodWSGQVvNC7EYkMM91dVkDn 4LOBCD+6zE0PhRAvCDjPQ6ixhftPePEAfZbqMlKYYfX6SHjXtKrhrBqLsot5eccOQLG9f sptSgc0kW0yhGc+S2XEjRmdGzymjyuGfJz8UVCR7E7VEAuGwa4N9VUyjFeMQKtWIDOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796205451; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=9wxo0E9HnNlIitzOVxCpc4CJ7VjDKJ4gF8LBvwEJRgc=; b=wbV0LH38oEBFxSDhuf61RndhqWFQUNOCZtG+Z8oUCw9v9lVPAy2eh3vA9gxXwZ1y2qSz kHRKMFDr3ZhNwZYX0VAn7AHjX0aidGPuIkLld6QuhycQGJ/WyUg0cum1jn8i/n7XAFazY 7Mqs71FCsOvu4ATdyBbSktoemgBYVi7UJmxLu0aUL1odFnlXT6hNxPWE62fVgQFahUcAw fJw6v/YddCE2Y6J9C4LyAXg9db4Da9RsvjoWwbsTKYjS9SrAJyutp3CEy0a70p5YasquX p1AdjAqeOqwce09szyC3IX+DH1i69xZkJY18xI4Keq19ShNJF6Mxw4YuVCqUAI0jb3A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VrVS4ggr; arc=none smtp.remote-ip=209.85.218.43 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93A84606A322 for ; Wed, 2 Dec 2026 09:57:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 93A84606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VrVS4ggr Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-c4322d310e7so1198218466b.0 for ; Wed, 02 Dec 2026 01:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796205449; x=1796810249; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=9wxo0E9HnNlIitzOVxCpc4CJ7VjDKJ4gF8LBvwEJRgc=; b=VrVS4ggrEo8iwA6HtAfJ6soWgwCQH/LVdHpfEDsBMLr/t7Qlxsl5vsjLo2QwWaknXl lzlvZ018Kk0LNnz6C3iDD9VaMbaAKMpeCo2n8Qt4XsQnh8qoHapMMLhq0JVp+A8j9YeU JctmSZxsz29mqRqRrYRLrg5yx3LFHUR4anKLjRd3NlRnIv6cR5T352JEZPSWcUJAb2uK BeE3gWZfBOnna1puuuNK2PfdpR9DBZYpDa3iKotH8oUXUrXK8i7J1nSBg4XZ94ps4g+5 VZPcXQCVCpYXdT5rzX/aVtUJL0qrNZrRuHzzrtETfT4cog6+WP22z2GMLH89W1A7gyS0 m2WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796205449; x=1796810249; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9wxo0E9HnNlIitzOVxCpc4CJ7VjDKJ4gF8LBvwEJRgc=; b=Ntg49Wyy5cD+PLzT+SytxPN0yrsXDjqBoeKbQwPBBSbduhniCpu0UQv2uRQrft+T9G 7QUVxERG8RJxa6BgZLTHdkyG8vu8FbkJ9DgeyYFoshmhIQWbqWpfRkd5kGkZZVpe1fUv RMFw0fu3XmMFu391euyC6jz0oZmJyoIjg0HsLXTTvsVL0swkbCgNN0ScSnRdYvIPst5+ ZxSzAZ3KCH/dvnSHjG8jp4aytf1T3ZsxTNlUheY8w2aDWqK7DRQLnyC1a0EWiMCogYx5 mIwo4Im25/FFcLw+QKhLAxK9c6UnV0ayh+tuNoED9T1Xr3WjFpJEnfCjmPISYI7PEvmv wmaQ== X-Gm-Message-State: APuU4Z8O/cWBbzlZPIS8r6YiDC3nI8GFScQjAd1prOe2149YjbUlctF2 k1tHu70J+6yOsVglRwhCVW6jE910DNyrasQZRJInF6dHp4xCUR/dXlIv78a+c8SB X-Gm-Gg: AZFdTZdEbnbCdaw6R3fu3Zl78vF2G7KIpRiAfI3Rm0E/YuV7/RkySF78LnnIeYmglZd Mjs7VuizHITZw87toiFfZGYTxN2HygsEG7GUmch9JtEwjb/GUPssvcd/avX+zhEZD2FMkWpqUC9 CjAEQh3MuW1pyCPVM6mTkV/Paxt7cqLbtBbet6llsuo3tl7WuE97Q7hA0JS8nxjEyZ54Z1wC9Jp DFhcdiTULOFyTw76UZAVKqUXLHa4dCysDmNpW0Z/9SjGPDs5emPV/HwSPL8g/+iqNeH5AnNH9ec TeHH55M5w2C7IQ1hYzliaXEfThbLxzJ5Y4m66zy+DEwkw3nXtB21TE6xw1JVdc/slYgXNmj9StU yTzQQFUlojHKDtApBZD0XFdYb+QXh1APh6T0FGVdT+BT4+9kv8EgcLn5o97m5cvBhOLbtL//6ue +33tuDg2jMNJ8dpmgmdITAV0ajMbaZoMhjFcRW2Ijd+1/y/Rj0dTNq7LgTNQEIHdzSFLG9wjY39 DF/Ja3jM/JO/DwUmoN8lGOgaO+bJgdpMfe69Dhk/ue/mPecB7y3Y4WeMkvTL1n0oLvuXo5yuQQh G/0WgFAGy/Tv6vx8Djlr34HTnaSim40UVagu5s+p X-Received: by 2002:a17:907:84e:b0:c51:f8f6:42d1 with SMTP id a640c23a62f3a-c51f8f64346mr972676966b.17.1796205448834; Wed, 02 Dec 2026 01:57:28 -0800 (PST) Received: from kordpc.lan ([2a13:e746:396c:c600::8f9]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afed51asm1305046966b.76.2026.12.02.01.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 01:57:28 -0800 (PST) From: Kordian Chmielewski To: netdev@vger.kernel.org Cc: Florian Fainelli , Florian Fainelli , Jonas Gorski , Andrew Lunn , Vladimir Oltean , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net] net: dsa: bcm_sf2: raise BCM4908 egress queue flow control thresholds Date: Wed, 2 Dec 2026 10:57:25 +0100 Message-ID: <20261202095725.157121-1-kudzo51@gmail.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit bcm_sf2_port_setup() writes a pause threshold of 32 pages to CORE_TXQ_THD_PAUSE_QN_PORT(port). On the BCM4908 switch these registers of flow control page 0x0B hold per egress queue thresholds that all ports share, so the write for each user port lands on the queue with the same number. On a TP-Link Archer AX6000 v1, whose user ports are 0-3 and 7, the switch reads back 32 pages for queues 0-3 and 7, and queue 0 carries the traffic to the CPU. The frames that the CPU sends are accounted in another set of thresholds, page 0x0D, which the driver does not touch (pause thresholds of 199-255 pages there). The switch runs in TX based flow control mode (PAUSE_DROP_CTRL, page 0x0A register 0x1C, reads 0x0fd9), and the WAN port, whose link came up with flow control off, loses frames at ingress once their egress queue is over its pause threshold. Measured on that router with iperf3, with the thresholds changed at run time: - a 2.5G host on the WAN port sending to the router, 4 TCP streams for 15 s: queue 0 peaked at 40 pages and the router received 1386 Mbit/s. With the thresholds below, queue 0 peaked at 802 pages and the router received 1877 and 1876 Mbit/s in two runs, with about as many TCP retransmissions as before (15016 and 14177, against 16921). With only queue 0 changed, pause levels of 199 and 400 pages gave 1824 to 1871 Mbit/s and levels from 700 to 1000 pages all gave 1875 to 1877 Mbit/s, while a hysteresis far below the pause level multiplied the retransmissions (35474 at 1000/500 pages, 10164 at 1000/968). - a Wi-Fi client sending through the router to a host on a 1G LAN port, 4 TCP streams for 15 s: with page 0x0D at its defaults, the busiest queues of that port peaked within 5 pages of their page 0x0D pause thresholds and the host received 377 and 540 Mbit/s in two runs. With page 0x0D at 800 pages, those queues went up to 804 pages and the host received 668 to 725 Mbit/s in four runs. The router ran OpenWrt with Linux 6.12 and changes that are not in mainline: for the WAN port, the 2.5G PHY behind it and the SerDes between them, for the Wi-Fi chip, and for bcm4908_enet, among them earlier versions of most of its fixes now in net. On BCM4908, skip the 32-page write and program both pages: every egress queue pauses at 800 pages and all queues together at 1300, below the total drop thresholds of 1423-1527 pages, and each resumes 32 pages lower. The drop thresholds keep their defaults. Fixes: 73b7a6047971 ("net: dsa: bcm_sf2: support BCM4908's integrated switch") Signed-off-by: Kordian Chmielewski --- Tested again on an Archer AX6000 v1 with OpenWrt, Linux 6.18.55 and this version of the patch, with a device tree that has no WAN port and no Wi-Fi yet, so the runs above could not be repeated: after boot the switch reads back 800/768 pages for every queue and 1300/1268 for the totals on both pages, with the drop thresholds at their defaults, and TCP between the router and a host on a 1G LAN port ran at 941 Mbit/s in both directions. drivers/net/dsa/bcm_sf2.c | 44 ++++++++++++++++++++++++++++++++-- drivers/net/dsa/bcm_sf2_regs.h | 11 +++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index cbaa5de9b107..f8b7d2b9ee7e 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -330,8 +330,11 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port, if (port == priv->moca_port) bcm_sf2_port_intr_enable(priv, port); - /* Set per-queue pause threshold to 32 */ - core_writel(priv, 32, CORE_TXQ_THD_PAUSE_QN_PORT(port)); + /* Set per-queue pause threshold to 32, except on BCM4908: see + * bcm_sf2_4908_txq_thresholds() + */ + if (priv->type != BCM4908_DEVICE_ID) + core_writel(priv, 32, CORE_TXQ_THD_PAUSE_QN_PORT(port)); /* Set ACB threshold to 24 */ for (i = 0; i < SF2_NUM_EGRESS_QUEUES; i++) { @@ -947,6 +950,41 @@ static void bcm_sf2_enable_acb(struct dsa_switch *ds) acb_writel(priv, reg, ACB_CONTROL); } +/* On BCM4908 the flow control thresholds are per egress queue and shared by + * all ports, in sets chosen by where a frame enters the switch: page 0x0B for + * the frames received on the user ports and page 0x0D for the frames sent by + * the CPU on port 8 (IMP0). A queue over its pause threshold drops what a port + * without flow control sends to it, and the 32 pages that + * bcm_sf2_port_setup() writes on other switches would land on the page 0x0B + * queues numbered like the user ports, queue 0 among them, which carries the + * traffic to the CPU. Pause each queue at 800 pages and all of them together + * at 1300, and resume 32 pages below each level. The drop thresholds keep + * their defaults. + */ +#define BCM4908_TXQ_PAUSE_THD 800 +#define BCM4908_TXQ_HYST_THD (BCM4908_TXQ_PAUSE_THD - 32) +#define BCM4908_TOTAL_PAUSE_THD 1300 +#define BCM4908_TOTAL_HYST_THD (BCM4908_TOTAL_PAUSE_THD - 32) + +static void bcm_sf2_4908_txq_thresholds(struct bcm_sf2_priv *priv) +{ + static const u32 pages[] = { CORE_FC_LAN_TXQ, CORE_FC_IMP0_TXQ }; + unsigned int i, q; + + for (i = 0; i < ARRAY_SIZE(pages); i++) { + for (q = 0; q < SF2_NUM_EGRESS_QUEUES; q++) { + core_writel(priv, BCM4908_TXQ_PAUSE_THD, + pages[i] + FC_TXQ_THD_PAUSE(q)); + core_writel(priv, BCM4908_TXQ_HYST_THD, + pages[i] + FC_TXQ_THD_HYST(q)); + core_writel(priv, BCM4908_TOTAL_PAUSE_THD, + pages[i] + FC_TOTAL_THD_PAUSE(q)); + core_writel(priv, BCM4908_TOTAL_HYST_THD, + pages[i] + FC_TOTAL_THD_HYST(q)); + } + } +} + static int bcm_sf2_sw_suspend(struct dsa_switch *ds) { struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); @@ -1078,6 +1116,8 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds) b53_configure_vlan(ds); bcm_sf2_enable_acb(ds); + if (priv->type == BCM4908_DEVICE_ID) + bcm_sf2_4908_txq_thresholds(priv); ret = b53_enable_mcast_snooping(priv->dev); if (ret) diff --git a/drivers/net/dsa/bcm_sf2_regs.h b/drivers/net/dsa/bcm_sf2_regs.h index da0dedbd6555..27977d0a25cb 100644 --- a/drivers/net/dsa/bcm_sf2_regs.h +++ b/drivers/net/dsa/bcm_sf2_regs.h @@ -322,6 +322,17 @@ enum bcm_sf2_reg_offs { #define CORE_TXQ_THD_PAUSE_QN_PORT(x) (CORE_TXQ_THD_PAUSE_QN_PORT_0 + \ (x) * 0x8) +/* Flow control pages with per egress queue thresholds, shared by all ports, + * in 256-byte buffer pages: 0x0B for frames received on the user ports, 0x0D + * for frames sent by the CPU (IMP0) + */ +#define CORE_FC_LAN_TXQ 0x2c00 +#define CORE_FC_IMP0_TXQ 0x3400 +#define FC_TXQ_THD_HYST(q) (0x040 + (q) * 0x8) +#define FC_TXQ_THD_PAUSE(q) (0x080 + (q) * 0x8) +#define FC_TOTAL_THD_HYST(q) (0x100 + (q) * 0x8) +#define FC_TOTAL_THD_PAUSE(q) (0x140 + (q) * 0x8) + #define CORE_DEFAULT_1Q_TAG_P(x) (0xd040 + ((x) * 8)) #define CFI_SHIFT 12 #define PRI_SHIFT 13 base-commit: 0d39bf81267861742b80d5f1c52e8a63e9ca0ca1 -- 2.56.1