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=1796386419; b=X3y81QufhacFD8SLiBY1uk52A+YlG7sbKOPApyTQGK2plC6hcV8KCqzCV+tsukHeQyAb S7qEOEKbxUOCROexOb/sTUbjbCRumsd52CMeZov4+G7mEIQnUKNe7tCN4lY7YSvKM+aBW gfTwwOnZrIzFtRaVf7PoChhdjqFOSJRgqYEX6IcER/OVF55KA8S84EzGeoI+8ShJW505F 3Ybqit+HiT+LvCowAwNIRNLVNWClIWaSzyeH8BxkC+5fEaTU8DpEsVPp/CtKQNh3pJvSd Gq2lKsVwR81rw8NTb7FUsLdQWwa5aneq8W5CHCSZfvPW1J/guRTnEyTzWF5CYodjpPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386419; 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=A0eJAIv7auwM2YAgU/SOmDWEZBspDQQQEqZH5XnB6WU=; b=oYN3M2QIHIYNaoxHpS4KSMcntDUfyhxR83MEejSN2PXzKywUUBr20fGIxBjPr9NpVBVq fbVrv28VNS2kMDLU29eQWFoxAj+Cx/Oc3/sVeGvwV+xGEXaBzqGEwkgCETtwZInwZdIB1 PWOrId9CtVZ/edmaw6Lt1wrbzlgbiHJgSi880mowC1D6GuuHCesY0cryz+gJLVdLH8sfL 1KTJuSfHqY/1/iwxuVuDwrM6tCSEegkNR9EXyrJvIek6MHwFbbwIaHKTz/QQLDb4H7X2E /SIP+5h+IGxKDaLLMEk9Vi99gTjEmrcrZeeDcw4vVz+TLdDCkw5hQFfa9JIAMykzpQQ== 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=Uvba7qHw; 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 86576606A322; Fri, 4 Dec 2026 12:13:39 +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=Uvba7qHw Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5C441F00897; Fri, 4 Dec 2026 12:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386419; bh=A0eJAIv7auwM2YAgU/SOmDWEZBspDQQQEqZH5XnB6WU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Uvba7qHwP+2TiLSYrCA++jWojey1/GSNpk2b23Sb2Y7rU1sl72zTaglv1PwvZUg2J YuhzIkwpRD6VjWEqNBk0Xksxy8jO9pTpxNzip5/I8icXup6/f65wEFnP8vTaXLRsO0 PcZhFRCw/o7XK9iHjWRjPicl048KB+lmI1wqkDyo= 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.6 0955/1167] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Date: Fri, 4 Dec 2026 19:06:22 +0900 Message-ID: <20261204100727.064751015@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 23363bcbf9c60..0a9fed7717590 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2254,6 +2254,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) @@ -2267,12 +2292,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); @@ -2294,7 +2319,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); @@ -2313,7 +2338,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 0a2a0f4f4f5d8..eb0ef4a2f67a7 100644 --- a/drivers/net/dsa/b53/b53_regs.h +++ b/drivers/net/dsa/b53/b53_regs.h @@ -221,6 +221,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