Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Oleksij Rempel
Thu, 12 Nov 2026 08:37
[PATCH net-next v2 05/10] net: dsa: realtek: rtl8365mb: describe the ports of each chip
Author: Oleksij Rempel
Date: Thu, 12 Nov 2026 08:37
Date: Thu, 12 Nov 2026 08:37
126 lines
15128 bytes
15128 bytes
Record which ports each chip has, report one more than its highest
port to DSA as the port count, and reject a devicetree port the chip
does not have. Lower the family maximum to 8 to match.
Commit ca5ecd4246d4 ("net: dsa: realtek: rtl8365mb: correct the max
number of ports") raised the port count of all chips to 11, but no
supported chip has a port above 7.
Since commit 51a4a22301b0 ("net: dsa: realtek: rtl8365mb: use dsa
helpers for port iteration"), setup also programs unused ports, so
every probe writes per-port registers of ports 8..10. Their learn-limit
writes go to 0x0A28..0x0A2A, above the learn-limit registers of ports
0..7. We have not seen a visible effect from these writes.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- New in v2. The QoS patches after it handle ports 0..7 only.
---
drivers/net/dsa/realtek/rtl8365mb_main.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
index da06f952a053d1497647a2c6f15a861fc21860f9..1e6cdc61f6bd3b3f74e422dbbcfdcb67cc0532a7 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_main.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
@@ -115,7 +115,7 @@
#define RTL8365MB_PHYADDRMAX 7
#define RTL8365MB_NUM_PHYREGS 32
#define RTL8365MB_PHYREGMAX (RTL8365MB_NUM_PHYREGS - 1)
-#define RTL8365MB_MAX_NUM_PORTS 11
+#define RTL8365MB_MAX_NUM_PORTS 8
/* Valid for the whole family except RTL8370B, which has 4160 entries.
* RTL8370B is mentioned in vendor code but it might not even belong
* to the same RTL8367C family.
@@ -707,6 +707,7 @@ struct rtl8365mb_extint {
* @name: human-readable chip name
* @chip_id: chip identifier
* @chip_ver: chip silicon revision
+ * @port_mask: ports the chip has
* @extints: available external interfaces
* @jam_table: chip-specific initialization jam table
* @jam_size: size of the chip's jam table
@@ -719,6 +720,7 @@ struct rtl8365mb_chip_info {
const char *name;
u32 chip_id;
u32 chip_ver;
+ u32 port_mask;
const struct rtl8365mb_extint extints[RTL8365MB_MAX_NUM_EXTINTS];
const struct rtl8365mb_jam_tbl_entry *jam_table;
size_t jam_size;
@@ -726,11 +728,20 @@ struct rtl8365mb_chip_info {
/* Chip info for each supported switch in the family */
#define PHY_INTF(_mode) (RTL8365MB_PHY_INTERFACE_MODE_ ## _mode)
+#define PORT_MASK(_m) \
+ ((_m) + \
+ BUILD_BUG_ON_ZERO((_m) & ~GENMASK(RTL8365MB_MAX_NUM_PORTS - 1, 0)))
+
+/* Copper ports are 0..3 on the RTL8365MB-VC and 0..4 on the others. Extension
+ * interfaces are port 6 on the VC and ports 6 and 7 on the others, as the
+ * extints rows show.
+ */
static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
{
.name = "RTL8365MB-VC",
.chip_id = 0x6367,
.chip_ver = 0x0040,
+ .port_mask = PORT_MASK(GENMASK(3, 0) | BIT(6)),
.extints = {
{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
PHY_INTF(RMII) | PHY_INTF(RGMII) },
@@ -742,6 +753,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8367S",
.chip_id = 0x6367,
.chip_ver = 0x00A0,
+ .port_mask = PORT_MASK(GENMASK(4, 0) | BIT(6) | BIT(7)),
.extints = {
{ 6, 1, PHY_INTF(SGMII) | PHY_INTF(HSGMII) },
{ 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) |
@@ -754,6 +766,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8367SB",
.chip_id = 0x6367,
.chip_ver = 0x0010,
+ .port_mask = PORT_MASK(GENMASK(4, 0) | BIT(6) | BIT(7)),
.extints = {
{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
PHY_INTF(RMII) | PHY_INTF(RGMII) |
@@ -768,6 +781,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8367RB-VB",
.chip_id = 0x6367,
.chip_ver = 0x0020,
+ .port_mask = PORT_MASK(GENMASK(4, 0) | BIT(6) | BIT(7)),
.extints = {
{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
PHY_INTF(RMII) | PHY_INTF(RGMII) },
@@ -3140,6 +3154,16 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
dev_info(priv->dev, "no interrupt support\n");
dsa_switch_for_each_port(dp, ds) {
+ if (dsa_port_is_unused(dp))
+ continue;
+
+ if (!(mb->chip_info->port_mask & BIT(dp->index))) {
+ dev_err(priv->dev, "port %d does not exist on %s\n",
+ dp->index, mb->chip_info->name);
+ ret = -EINVAL;
+ goto out_teardown_irq;
+ }
+
/* Cascading (DSA links) is not supported yet.
* Historically, the driver has always been broken
* without a dedicated CPU port because CPU tagging
@@ -3349,7 +3373,7 @@ static int rtl8365mb_detect(struct realtek_priv *priv)
dev_info(priv->dev, "found an %s switch\n", mb->chip_info->name);
- priv->num_ports = RTL8365MB_MAX_NUM_PORTS;
+ priv->num_ports = fls(mb->chip_info->port_mask);
mb->priv = priv;
mb->cpu.trap_port = RTL8365MB_MAX_NUM_PORTS;
mb->cpu.insert = RTL8365MB_CPU_INSERT_TO_ALL;
--
2.47.3
Re: [PATCH net-next v2 05/10] net: dsa: realtek: rtl8365mb: describe the ports of each chip
Author: Linus Walleij
Date: Thu, 12 Nov 2026 20:38
Date: Thu, 12 Nov 2026 20:38
28 lines
10231 bytes
10231 bytes
On Thu, Nov 12, 2026 at 9:37 AM Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> Record which ports each chip has, report one more than its highest
> port to DSA as the port count, and reject a devicetree port the chip
> does not have. Lower the family maximum to 8 to match.
>
> Commit ca5ecd4246d4 ("net: dsa: realtek: rtl8365mb: correct the max
> number of ports") raised the port count of all chips to 11, but no
> supported chip has a port above 7.
>
> Since commit 51a4a22301b0 ("net: dsa: realtek: rtl8365mb: use dsa
> helpers for port iteration"), setup also programs unused ports, so
> every probe writes per-port registers of ports 8..10. Their learn-limit
> writes go to 0x0A28..0x0A2A, above the learn-limit registers of ports
> 0..7. We have not seen a visible effect from these writes.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> Changes in v2:
> - New in v2. The QoS patches after it handle ports 0..7 only.
With Alvin's comments addressed:
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
Re: [PATCH net-next v2 05/10] net: dsa: realtek: rtl8365mb: describe the ports of each chip
Author: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 23:01
Date: Sun, 15 Nov 2026 23:01
79 lines
10912 bytes
10912 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch lowers RTL8365MB_MAX_NUM_PORTS from 11 to 8.
--
net: dsa: realtek: rtl8365mb: describe the ports of each chip
This commit adds a per-chip port_mask to rtl8365mb_chip_info. It reports
fls(port_mask) to DSA as the port count and rejects devicetree ports that
the chip does not have. It also lowers RTL8365MB_MAX_NUM_PORTS from 11 to
8.
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index da06f952a053d..1e6cdc61f6bd3 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
> @@ -115,7 +115,7 @@
> #define RTL8365MB_PHYADDRMAX 7
> #define RTL8365MB_NUM_PHYREGS 32
> #define RTL8365MB_PHYREGMAX (RTL8365MB_NUM_PHYREGS - 1)
> -#define RTL8365MB_MAX_NUM_PORTS 11
> +#define RTL8365MB_MAX_NUM_PORTS 8
[Severity: Low]
This isn't a bug, but is "family maximum" the right description for this
value?
The commit message says:
Lower the family maximum to 8 to match.
The constant also still sits under this heading:
/* Family-specific data and limits */
The file header comment still describes the family as having more ports
than that, and it lists the RTL8370MB as a member:
* In the same family of chips, some carry up to 8 user ports and up to 2
* extension ports. Where possible this driver tries to make things generic, but
...
* - RTL8370MB
Some of the family-generic register handling was also written for port
indexes above 7. Examples are the 11-bit RTL8365MB_PORT_MASK, the EXT bit
for the trap port in CPU_CTRL, and the L2 flush code in rtl8365mb_l2.c:
/* Now issue the flush command and wait for its completion. There are
* two registers for this purpose, and which one to use depends on the
* port number. The _EXT register is for ports 8 or higher.
*/
if (port < 8) {
With this change, 8 looks like the largest port count among the chips the
driver supports, not a limit for the whole family. The BUILD_BUG_ON in
PORT_MASK() reads the same way. So does the later static_assert in this
series that ties RTL8365MB_MAX_NUM_PORTS to RTL8365MB_QOS_MAX_PORTS.
At the end of the series, the header comment and the placement of the
constant are still unchanged.
Would it be clearer to rename the constant to something that marks it as
a driver-supported maximum? Moving it out of the family-limits group and
updating the comment and commit message would also work.
> /* Valid for the whole family except RTL8370B, which has 4160 entries.
> * RTL8370B is mentioned in vendor code but it might not even belong
> * to the same RTL8367C family.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-rtl8365mb-dcb-ingress-v2-0-f8e6fbdf8c99%40pengutronix.de
Re: [PATCH net-next v2 05/10] net: dsa: realtek: rtl8365mb: describe the ports of each chip
Author: Oleksij Rempel
Date: Mon, 16 Nov 2026 13:36
Date: Mon, 16 Nov 2026 13:36
60 lines
12844 bytes
12844 bytes
On Thu, Nov 12, 2026 at 04:08:47PM +0100, Alvin Šipraga wrote:
> On Thu, Nov 12, 2026 at 09:37:48AM +0100, Oleksij Rempel wrote:
> > Record which ports each chip has, report one more than its highest
> > port to DSA as the port count, and reject a devicetree port the chip
> > does not have. Lower the family maximum to 8 to match.
> >
> > Commit ca5ecd4246d4 ("net: dsa: realtek: rtl8365mb: correct the max
> > number of ports") raised the port count of all chips to 11, but no
> > supported chip has a port above 7.
> >
> > Since commit 51a4a22301b0 ("net: dsa: realtek: rtl8365mb: use dsa
> > helpers for port iteration"), setup also programs unused ports, so
> > every probe writes per-port registers of ports 8..10. Their learn-limit
> > writes go to 0x0A28..0x0A2A, above the learn-limit registers of ports
> > 0..7. We have not seen a visible effect from these writes.
>
> I'm not quite sure what the point of the patch is (sorry, maybe it's
> clear later in the series, but I didn't get that far yet). Was the setup
> of nonexistent ports clobbering some other registers?
Not that I could see. I saw no effect from the writes to ports 8..10.
The reason is the rest of the series. The QoS code in the later
patches handles ports 0..7 only. With 11 ports, DSA accepts a
devicetree port 8..10, and the QoS code would then write a register
that does not hold that port's field. With the per-chip port mask, the
driver no longer accepts a port the chip does not have. I reworded the
commit message to say this.
> Also in the blamed commit there was:
>
> -/* RTL8370MB and RTL8310SR, possibly suportable by this driver, have 10 ports */
> -#define RTL8365MB_MAX_NUM_PORTS 10
> +#define RTL8365MB_MAX_NUM_PORTS 11
>
> So maybe it needs bumping in the future if support is added for those
> chips. That's why I'm wondering if you saw something off?
Good point. v3 drops that.
> > dsa_switch_for_each_port(dp, ds) {
> > + if (dsa_port_is_unused(dp))
> > + continue;
>
> You can use dsa_switch_for_each_available_port() here.
Done in v3.
> > +
> > + if (!(mb->chip_info->port_mask & BIT(dp->index))) {
> > + dev_err(priv->dev, "port %d does not exist on %s\n",
> > + dp->index, mb->chip_info->name);
> > + ret = -EINVAL;
> > + goto out_teardown_irq;
> > + }
> > +
Thanks,
Oleksij
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads