Skip to content

Commit 2aee430

Browse files
hjelmelanddavem330
authored andcommitted
net: dsa: lan9303: Set up trapping of IGMP to CPU port
IGMP packets should be trapped to the CPU port. The SW bridge knows whether to forward to other ports. With "IGMP snooping for local traffic" merged, IGMP trapping is also required for stable IGMPv2 operation. LAN9303 does not trap IGMP packets by default. Enable IGMP trapping in lan9303_setup. Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 940c9c4 commit 2aee430

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/net/dsa/lan9303-core.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
# define LAN9303_SWE_VLAN_UNTAG_PORT0 BIT(12)
154154
#define LAN9303_SWE_VLAN_CMD_STS 0x1810
155155
#define LAN9303_SWE_GLB_INGRESS_CFG 0x1840
156+
# define LAN9303_SWE_GLB_INGR_IGMP_TRAP BIT(7)
157+
# define LAN9303_SWE_GLB_INGR_IGMP_PORT(p) BIT(10 + p)
156158
#define LAN9303_SWE_PORT_STATE 0x1843
157159
# define LAN9303_SWE_PORT_STATE_FORWARDING_PORT2 (0)
158160
# define LAN9303_SWE_PORT_STATE_LEARNING_PORT2 BIT(5)
@@ -450,6 +452,21 @@ static int lan9303_read_switch_reg(struct lan9303 *chip, u16 regnum, u32 *val)
450452
return ret;
451453
}
452454

455+
static int lan9303_write_switch_reg_mask(struct lan9303 *chip, u16 regnum,
456+
u32 val, u32 mask)
457+
{
458+
int ret;
459+
u32 reg;
460+
461+
ret = lan9303_read_switch_reg(chip, regnum, &reg);
462+
if (ret)
463+
return ret;
464+
465+
reg = (reg & ~mask) | val;
466+
467+
return lan9303_write_switch_reg(chip, regnum, reg);
468+
}
469+
453470
static int lan9303_write_switch_port(struct lan9303 *chip, int port,
454471
u16 regnum, u32 val)
455472
{
@@ -905,6 +922,15 @@ static int lan9303_setup(struct dsa_switch *ds)
905922
if (ret)
906923
dev_err(chip->dev, "failed to re-enable switching %d\n", ret);
907924

925+
/* Trap IGMP to port 0 */
926+
ret = lan9303_write_switch_reg_mask(chip, LAN9303_SWE_GLB_INGRESS_CFG,
927+
LAN9303_SWE_GLB_INGR_IGMP_TRAP |
928+
LAN9303_SWE_GLB_INGR_IGMP_PORT(0),
929+
LAN9303_SWE_GLB_INGR_IGMP_PORT(1) |
930+
LAN9303_SWE_GLB_INGR_IGMP_PORT(2));
931+
if (ret)
932+
dev_err(chip->dev, "failed to setup IGMP trap %d\n", ret);
933+
908934
return 0;
909935
}
910936

0 commit comments

Comments
 (0)