The chip data specifies both the jumbo port mask and frame size register offsets, but b53_switch_init() only copies the former into the device. Since the device is zero-initialized, b53_set_jumbo() writes the frame size to offset zero instead of the chip-specific size register at 0x05 or 0x08. Copy jumbo_size_reg from the chip data along with jumbo_pm_reg so frame size updates reach the intended register. Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 0880310c9ce3..559d4b360c82 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -3109,6 +3109,7 @@ static int b53_switch_init(struct b53_device *dev) dev->vta_regs[1] = chip->vta_regs[1]; dev->vta_regs[2] = chip->vta_regs[2]; dev->jumbo_pm_reg = chip->jumbo_pm_reg; + dev->jumbo_size_reg = chip->jumbo_size_reg; dev->imp_port = chip->imp_port; dev->num_vlans = chip->vlans; dev->num_arl_bins = chip->arl_bins; -- 2.53.0 b53_srab_request_grant() polls for a grant up to 20 times, but checks for an iteration count of five to detect a timeout. This rejects a grant received on the sixth poll and reports success when all 20 polls finish without a grant. The latter allows a register access to proceed without ownership of the switch resources. Check for exhaustion of all 20 iterations instead. Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Florian Fainelli --- drivers/net/dsa/b53/b53_srab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c index 83a03fca142a..f4689078ccd5 100644 --- a/drivers/net/dsa/b53/b53_srab.c +++ b/drivers/net/dsa/b53/b53_srab.c @@ -105,7 +105,7 @@ static int b53_srab_request_grant(struct b53_device *dev) break; usleep_range(10, 100); } - if (WARN_ON(i == 5)) + if (WARN_ON(i == 20)) return -EIO; return 0; -- 2.53.0 When an ARL lookup does not find the requested MAC and VID, b53_arl_read() returns the first free bin index but leaves the entry populated with the last bin examined. The multicast add path then ORs the requested port into that unrelated entry's forwarding bitmap, potentially forwarding packets to ports which are not members of the multicast group. Clear the entry before creating a new one. Also return without writing anything when deleting an entry which is not present, instead of making a new entry from stale bin contents. Fixes: 5d65b64a3d97 ("net: dsa: b53: Add support for MDB") Signed-off-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 559d4b360c82..0871a10d8cbc 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1992,6 +1992,10 @@ static int b53_arl_op(struct b53_device *dev, int op, int port, addr, vid); return is_valid ? ret : 0; case -ENOENT: + if (!is_valid) + return 0; + + memset(&ent, 0, sizeof(ent)); /* We could not find a matching MAC, so reset to a new entry */ dev_dbg(dev->dev, "{%pM,%.4d} not found, using idx: %d\n", addr, vid, idx); -- 2.53.0 The mirror capture control register selects one destination for all ingress and egress mirror sources. Adding a rule for a different capture port currently overwrites that field and silently redirects all existing mirror rules. Read the capture control before changing any source masks and reject a different destination while mirroring is enabled. Return an extack which describes the hardware limitation, and propagate a failed capture-control read rather than making the decision from uninitialized data. Clear the capture-port field when the final source is removed so a later rule can select a new destination. Fixes: ed3af5fd08eb ("net: dsa: b53: Add support for port mirroring") Signed-off-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 0871a10d8cbc..b8a7b380bac8 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2543,7 +2543,19 @@ int b53_mirror_add(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack) { struct b53_device *dev = ds->priv; - u16 reg, loc; + u16 reg, loc, cap_ctl; + int ret; + + ret = b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &cap_ctl); + if (ret) + return ret; + + if ((cap_ctl & MIRROR_EN) && + (cap_ctl & CAP_PORT_MASK) != mirror->to_local_port) { + NL_SET_ERR_MSG_MOD(extack, + "Only one mirroring destination is supported"); + return -EOPNOTSUPP; + } if (ingress) loc = B53_IG_MIR_CTL; @@ -2554,11 +2566,10 @@ int b53_mirror_add(struct dsa_switch *ds, int port, reg |= BIT(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 |= MIRROR_EN; - b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg); + cap_ctl &= ~CAP_PORT_MASK; + cap_ctl |= mirror->to_local_port; + cap_ctl |= MIRROR_EN; + b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, cap_ctl); return 0; } @@ -2595,10 +2606,8 @@ void b53_mirror_del(struct dsa_switch *ds, int port, b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, ®); /* Both no longer have ports, let's disable mirroring */ - if (loc_disable && other_loc_disable) { - reg &= ~MIRROR_EN; - reg &= ~mirror->to_local_port; - } + if (loc_disable && other_loc_disable) + reg &= ~(MIRROR_EN | CAP_PORT_MASK); b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg); } EXPORT_SYMBOL(b53_mirror_del); -- 2.53.0 The IMP and per-port GMII override registers swap the override-enable and 2 Gbps speed bits. Using the IMP speed bit on a GMII port clears its override enable and leaves any previous 2 Gbps selection intact. Select the speed bit alongside the register and enable bit so lower speeds clear the correct bit and 2 Gbps sets it. Fixes: b6a8a5477fe9 ("net: dsa: b53: fix resetting speed and pause on forced link") Signed-off-by: Florian Fainelli --- drivers/net/dsa/b53/b53_common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index b8a7b380bac8..7bbbfcd611e1 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1370,17 +1370,19 @@ static void b53_force_port_config(struct b53_device *dev, int port, int speed, int duplex, bool tx_pause, bool rx_pause) { - u8 reg, val, off; + u8 reg, val, off, speed2000; /* Override the port settings */ if (port == dev->imp_port) { off = B53_PORT_OVERRIDE_CTRL; val = PORT_OVERRIDE_EN; + speed2000 = PORT_OVERRIDE_SPEED_2000M; } else if (is5325(dev)) { return; } else { off = B53_GMII_PORT_OVERRIDE_CTRL(port); val = GMII_PO_EN; + speed2000 = GMII_PO_SPEED_2000M; } b53_read8(dev, B53_CTRL_PAGE, off, ®); @@ -1392,11 +1394,11 @@ static void b53_force_port_config(struct b53_device *dev, int port, reg &= ~(0x3 << GMII_PO_SPEED_S); if (is5301x(dev) || is58xx(dev)) - reg &= ~PORT_OVERRIDE_SPEED_2000M; + reg &= ~speed2000; switch (speed) { case 2000: - reg |= PORT_OVERRIDE_SPEED_2000M; + reg |= speed2000; fallthrough; case SPEED_1000: reg |= PORT_OVERRIDE_SPEED_1000M; -- 2.53.0