From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796383576; b=z1ZG3umFmadmd1WsSyD/h/Zzx2hMFnLn0HKwvW0lzWtQj+08x0m3j3a9ARye6H3NeEEK nQNyz5pys33c6vyADr4wlAO/b2ErgV9VITkytRpwNR9Yu7p4l8iG14XRetV1G3gzIOTBu y3pySn85+BLxaHHRq1UuR7jSYMUKR6dbcsFsZNG2A+yt0LTEsQ26eGQwkiKlS4ZSQvcNn kvBVYet9cT+Tlpo391sbop9xYAQ/b5PElECE+DLDQJ5AH+YocrTssF92KrM0k5iaUshk3 oRYMicXH472e34YacbhRFRIOd79JypPuvUdSemohPn00LrHOmpAdrHzI8sPcgdxPZGw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383576; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=VqTPN4I2ic8NHWs7TpXk57gSC28uLcmAEiGbwovMFmY=; b=l2pxkZqLrNIMoxEtwOcGB7+ZzP+emYuBqcqWEOhp4PTjqjCINOGFegbhnZWXKebSkscj UMS20Eed0+pyfAUBsTAXFCnqdyotFFK+flILUgRq/M5jneye0TbDB8F4JjQolK/r7isM7 ioDxwWHIr7j8Tk/yHJQFC3HlevbtIYQseyR7f62T0Ft/ZltBX6CgtOE6Im1+rt7mqnBhc VSgOETIa/KMYn+5Q2vtPgMuJycPyRQl+Uc0HiEwd+I5KEKzaXqMXrUNXEu76sS4Cztmpc 5wr7yegOj3kT9Gj5mWQY1N7TI+FrHXKx3U4nxLw/bQEeolYHW+8NDCPErDvGrdo7sPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="QI/ONMuE"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09E2F606A32C; Fri, 4 Dec 2026 11:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=QI/ONMuE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 772401F000CE; Fri, 4 Dec 2026 11:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383575; bh=VqTPN4I2ic8NHWs7TpXk57gSC28uLcmAEiGbwovMFmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QI/ONMuELJaq1w+pwh4M4QKSq+ELG4f7S8KaOoY3mZ42qK6AWOsLtbt34GX+HDmSx auXy9cjolxHpGekiu2IIlW7tid6UkaXRNOx+Ys5HQ2CvF8qthIH6USiOTM2Tpx8Kp+ 1uvLGs8UpYhLC6RMm6m4WhNzOCl5HcXkfCSl/Mio= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Fainelli , Willem de Bruijn , Sasha Levin Subject: [PATCH 6.12 277/555] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Date: Fri, 4 Dec 2026 19:05:20 +0900 Message-ID: <20261204100619.692210801@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Fainelli [ Upstream commit 000d468855945953c491810f97fb0bd4166b0b07 ] BCM5325 and BCM5365 use an 11-bit bitmap for the mirror capture port, whereas newer switches use a four-bit port ID. Programming the port number directly can select no destination or the wrong destination, and can select multiple destinations. For example, port 2 requires BIT(2), but writing 2 selects port 1 instead. Use the bitmap encoding on BCM5325 and BCM5365, including translating logical CPU port 5 to hardware bit 8. Apply the corresponding field mask when checking for a conflicting destination, replacing the destination, and clearing it after the last mirror source is removed. Keep the port ID encoding for newer switches. The ingress and egress mirror source masks use the same layout on these switches, with the CPU port at bit 8 and bits 5-7 reserved, so apply the same translation when setting and clearing a source port bit. Fixes: ed3af5fd08eb ("net: dsa: b53: Add support for port mirroring") Signed-off-by: Florian Fainelli Signed-off-by: Willem de Bruijn Signed-off-by: Sasha Levin --- drivers/net/dsa/b53/b53_common.c | 35 +++++++++++++++++++++++++++----- drivers/net/dsa/b53/b53_regs.h | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index be16e773903a4..c2cb5ca65ccc3 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2395,6 +2395,31 @@ enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, } EXPORT_SYMBOL(b53_get_tag_protocol); +static u16 b53_mirror_capture_port_mask(struct b53_device *dev) +{ + if (is5325(dev) || is5365(dev)) + return CAP_PORT_MASK_25; + + return CAP_PORT_MASK; +} + +static u16 b53_mirror_port_mask(struct b53_device *dev, int port) +{ + /* These switches use a bitmap with the CPU port at bit 8. */ + if ((is5325(dev) || is5365(dev)) && port == B53_CPU_PORT_25) + port = B53_CPU_PORT; + + return BIT(port); +} + +static u16 b53_mirror_capture_port(struct b53_device *dev, int port) +{ + if (is5325(dev) || is5365(dev)) + return b53_mirror_port_mask(dev, port); + + return port; +} + int b53_mirror_add(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress, struct netlink_ext_ack *extack) @@ -2408,12 +2433,12 @@ int b53_mirror_add(struct dsa_switch *ds, int port, loc = B53_EG_MIR_CTL; b53_read16(dev, B53_MGMT_PAGE, loc, ®); - reg |= BIT(port); + reg |= b53_mirror_port_mask(dev, port); b53_write16(dev, B53_MGMT_PAGE, loc, reg); b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, ®); - reg &= ~CAP_PORT_MASK; - reg |= mirror->to_local_port; + reg &= ~b53_mirror_capture_port_mask(dev); + reg |= b53_mirror_capture_port(dev, mirror->to_local_port); reg |= MIRROR_EN; b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg); @@ -2435,7 +2460,7 @@ void b53_mirror_del(struct dsa_switch *ds, int port, /* Update the desired ingress/egress register */ b53_read16(dev, B53_MGMT_PAGE, loc, ®); - reg &= ~BIT(port); + reg &= ~b53_mirror_port_mask(dev, port); if (!(reg & MIRROR_MASK)) loc_disable = true; b53_write16(dev, B53_MGMT_PAGE, loc, reg); @@ -2454,7 +2479,7 @@ void b53_mirror_del(struct dsa_switch *ds, int port, /* Both no longer have ports, let's disable mirroring */ if (loc_disable && other_loc_disable) { reg &= ~MIRROR_EN; - reg &= ~mirror->to_local_port; + reg &= ~b53_mirror_capture_port_mask(dev); } b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg); } diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h index 628fdfae47c84..f71206a0a74ff 100644 --- a/drivers/net/dsa/b53/b53_regs.h +++ b/drivers/net/dsa/b53/b53_regs.h @@ -227,6 +227,7 @@ /* Mirror capture control register (16 bit) */ #define B53_MIR_CAP_CTL 0x10 #define CAP_PORT_MASK 0xf +#define CAP_PORT_MASK_25 0x7ff #define BLK_NOT_MIR BIT(14) #define MIRROR_EN BIT(15) -- 2.53.0