[OpenWrt-Devel] ar8216: Use IGMP Join and Fast Leave functions
diff mbox

Message ID 1417790192-3760-1-git-send-email-cristian@samknows.com
State Changes Requested
Headers show

Commit Message

Cristian Morales Vega Dec. 5, 2014, 2:36 p.m. UTC
Avoids flooding the network with multicast data.

Signed-off-by: Cristian Morales Vega <cristian@samknows.com>
---
Since I guess not all the switches support this... Good idea? Is some OpenWRT
package expecting to receive the multicast packages?
At the very least you lose the capacity of using iptables to play with the packets.

 target/linux/generic/files/drivers/net/phy/ar8216.c | 13 ++++++++++++-
 target/linux/generic/files/drivers/net/phy/ar8216.h | 11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

Comments

Felix Fietkau Dec. 12, 2014, 4:16 p.m. UTC | #1
On 2014-12-05 15:36, Cristian Morales Vega wrote:
> Avoids flooding the network with multicast data.
> 
> Signed-off-by: Cristian Morales Vega <cristian@samknows.com>
> ---
> Since I guess not all the switches support this... Good idea? Is some OpenWRT
> package expecting to receive the multicast packages?
> At the very least you lose the capacity of using iptables to play with the packets.
I think this needs to be optional (and preferably disabled by default
initially, until it has received more testing).

- Felix
Cristian Morales Vega Dec. 15, 2014, 4:47 p.m. UTC | #2
On 12 December 2014 at 16:16, Felix Fietkau <nbd@openwrt.org> wrote:
>
> On 2014-12-05 15:36, Cristian Morales Vega wrote:
> > Avoids flooding the network with multicast data.
> >
> > Signed-off-by: Cristian Morales Vega <cristian@samknows.com>
> > ---
> > Since I guess not all the switches support this... Good idea? Is some
> OpenWRT
> > package expecting to receive the multicast packages?
> > At the very least you lose the capacity of using iptables to play with
> the packets.
> I think this needs to be optional (and preferably disabled by default
> initially, until it has received more testing).


Sure. I will send another patch.

Patch
diff mbox

diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 558b9f7..6583d8d 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -1690,7 +1690,6 @@  ar8327_init_globals(struct ar8xxx_priv *priv)
 
 	/* forward multicast and broadcast frames to CPU */
 	t = (AR8327_PORTS_ALL << AR8327_FWD_CTRL1_UC_FLOOD_S) |
-	    (AR8327_PORTS_ALL << AR8327_FWD_CTRL1_MC_FLOOD_S) |
 	    (AR8327_PORTS_ALL << AR8327_FWD_CTRL1_BC_FLOOD_S);
 	priv->write(priv, AR8327_REG_FWD_CTRL1, t);
 
@@ -1710,6 +1709,18 @@  ar8327_init_globals(struct ar8xxx_priv *priv)
 	     AR8327_EEE_CTRL_DISABLE_PHY(3) |
 	     AR8327_EEE_CTRL_DISABLE_PHY(4);
 	priv->write(priv, AR8327_REG_EEE_CTRL, t);
+
+	/* Enable IGMP Join/Leave */
+	t = AR8327_IGMP_JOIN_LEAVE0 |
+	    AR8327_IGMP_JOIN_LEAVE1 |
+	    AR8327_IGMP_JOIN_LEAVE2 |
+	    AR8327_IGMP_JOIN_LEAVE3;
+	priv->write(priv, AR8327_REG_FRAM_ACK_CTRL0, t);
+	t = AR8327_IGMP_JOIN_LEAVE4 |
+	    AR8327_IGMP_JOIN_LEAVE5 |
+	    AR8327_IGMP_JOIN_LEAVE6;
+	t |= AR8327_IGMP_V3; /* Look _also_ for IGMPv3 */
+	priv->write(priv, AR8327_REG_FRAM_ACK_CTRL1, t);
 }
 
 static void
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h
index f6df7c8..871134d 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.h
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.h
@@ -364,6 +364,17 @@ 
 #define AR8327_REG_EEE_CTRL			0x100
 #define   AR8327_EEE_CTRL_DISABLE_PHY(_i)	BIT(4 + (_i) * 2)
 
+#define AR8327_REG_FRAM_ACK_CTRL0		0x210
+#define   AR8327_IGMP_JOIN_LEAVE0		BITS(1, 2)
+#define   AR8327_IGMP_JOIN_LEAVE1		BITS(9, 2)
+#define   AR8327_IGMP_JOIN_LEAVE2		BITS(17, 2)
+#define   AR8327_IGMP_JOIN_LEAVE3		BITS(25, 2)
+#define AR8327_REG_FRAM_ACK_CTRL1		0x214
+#define   AR8327_IGMP_JOIN_LEAVE4		BITS(1, 2)
+#define   AR8327_IGMP_JOIN_LEAVE5		BITS(9, 2)
+#define   AR8327_IGMP_JOIN_LEAVE6		BITS(17, 2)
+#define   AR8327_IGMP_V3			BIT(24)
+
 #define AR8327_REG_PORT_VLAN0(_i)		(0x420 + (_i) * 0x8)
 #define   AR8327_PORT_VLAN0_DEF_SVID		BITS(0, 12)
 #define   AR8327_PORT_VLAN0_DEF_SVID_S		0