netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	andrew@lunn.ch, vivien.didelot@gmail.com, davem@davemloft.net,
	idosch@mellanox.com, jiri@mellanox.com,
	ilias.apalodimas@linaro.org, ivan.khoronzhuk@linaro.org,
	roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com
Subject: [PATCH net-next v2 11/12] net: dsa: b53: Add support for toggling IGMP snooping
Date: Tue, 29 Jan 2019 16:55:47 -0800	[thread overview]
Message-ID: <20190130005548.2212-12-f.fainelli@gmail.com> (raw)
In-Reply-To: <20190130005548.2212-1-f.fainelli@gmail.com>

Add the required configuration knobs to honor the turning off of IGMP
snooping (typically through the bridge interface) which means that when
IGMP snooping is off, we must be flooding mutlicast since we do not get
any notifications about IGMP join/leave through the network stack
running on the bridge.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 68 ++++++++++++++++++++++++++++++++
 drivers/net/dsa/b53/b53_priv.h   |  2 +
 2 files changed, 70 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 6c894ad4768a..c0c064a544b9 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1640,6 +1640,73 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
 }
 EXPORT_SYMBOL(b53_fdb_dump);
 
+int b53_multicast_toggle(struct dsa_switch *ds, int port,
+			 bool mc_disabled)
+{
+	unsigned int cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
+	struct b53_device *dev = ds->priv;
+	struct net_device *bridge_dev;
+	struct dsa_port *dp;
+	unsigned int i;
+	u8 port_ctrl;
+	u16 mc_ctrl;
+
+	if (is5325(dev) || is5365(dev))
+		return -EOPNOTSUPP;
+
+	/* Handle the case were multiple bridges span the same switch device
+	 * and one of them has a different setting than what is being requested
+	 * which would be breaking filtering semantics for any of the other
+	 * bridge devices. We must also take care of non-bridged ports which
+	 * expect multicast filtering to remain turned on.
+	 */
+	for (i = 0; i < ds->num_ports; i++) {
+		if (dsa_is_unused_port(ds, i) || dsa_is_cpu_port(ds, i))
+			continue;
+
+		if (i == port)
+			continue;
+
+		dp = dsa_to_port(ds, i);
+		bridge_dev = dp->bridge_dev;
+		if ((bridge_dev &&
+		     bridge_dev != dsa_to_port(ds, port)->bridge_dev &&
+		     br_multicast_enabled(bridge_dev) != !mc_disabled) ||
+		     (!bridge_dev && mc_disabled)) {
+			netdev_err(dp->slave,
+				   "MC filtering is global to the switch!\n");
+			return -EINVAL;
+		}
+	}
+
+	/* Allow CPU port to receive multicast traffic */
+	b53_read8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(cpu_port), &port_ctrl);
+	if (mc_disabled)
+		port_ctrl |= PORT_CTRL_RX_MCST_EN;
+	else
+		port_ctrl &= ~PORT_CTRL_RX_MCST_EN;
+	b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(cpu_port), port_ctrl);
+
+	/* Allow port to flood multicast */
+	b53_read16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, &mc_ctrl);
+	if (mc_disabled)
+		mc_ctrl |= BIT(port);
+	else
+		mc_ctrl &= ~BIT(port);
+	b53_write16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, mc_ctrl);
+
+	/* And flood IP multicast as well */
+	b53_read16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, &mc_ctrl);
+	if (mc_disabled)
+		mc_ctrl |= BIT(port);
+	else
+		mc_ctrl &= ~BIT(port);
+	b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc_ctrl);
+
+	return 0;
+}
+EXPORT_SYMBOL(b53_multicast_toggle);
+
 int b53_mdb_prepare(struct dsa_switch *ds, int port,
 		    const struct switchdev_obj_port_mdb *mdb)
 {
@@ -2025,6 +2092,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
 	.port_mirror_add	= b53_mirror_add,
 	.port_mirror_del	= b53_mirror_del,
 	.port_mdb_prepare	= b53_mdb_prepare,
+	.port_multicast_toggle	= b53_multicast_toggle,
 	.port_mdb_add		= b53_mdb_add,
 	.port_mdb_del		= b53_mdb_del,
 };
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index 620638ff9338..cd259fb8b00e 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -350,6 +350,8 @@ int b53_fdb_del(struct dsa_switch *ds, int port,
 		const unsigned char *addr, u16 vid);
 int b53_fdb_dump(struct dsa_switch *ds, int port,
 		 dsa_fdb_dump_cb_t *cb, void *data);
+int b53_multicast_toggle(struct dsa_switch *ds, int port,
+			 bool mc_disabled);
 int b53_mdb_prepare(struct dsa_switch *ds, int port,
 		    const struct switchdev_obj_port_mdb *mdb);
 void b53_mdb_add(struct dsa_switch *ds, int port,
-- 
2.17.1


  parent reply	other threads:[~2019-01-30  0:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  0:55 [PATCH net-next v2 00/12] net: dsa: management mode for bcm_sf2 Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 01/12] net: bridge: multicast: Propagate br_mc_disabled_update() return Florian Fainelli
2019-01-30  7:36   ` Ido Schimmel
2019-01-31  1:00     ` Florian Fainelli
2019-01-31  7:50       ` Ido Schimmel
2019-02-01  1:19         ` Florian Fainelli
2019-02-02 15:47           ` Ido Schimmel
2019-02-11 19:05             ` Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 02/12] net: dsa: b53: Fix default VLAN ID Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 03/12] net: dsa: b53: Properly account for VLAN filtering Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 04/12] net: systemport: Fix reception of BPDUs Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 05/12] net: dsa: b53: Define registers for IGMP snooping Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 06/12] net: dsa: b53: Add support for MDB Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 07/12] net: dsa: Add ability to program multicast filter for CPU port Florian Fainelli
2019-01-30 22:28   ` Vivien Didelot
2019-01-30 22:55     ` Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 08/12] net: dsa: Add ndo_vlan_rx_{add,kill}_vid implementation Florian Fainelli
2019-01-30 22:38   ` Vivien Didelot
2019-01-30  0:55 ` [PATCH net-next v2 09/12] net: dsa: Make VLAN filtering use DSA notifiers Florian Fainelli
2019-01-30  0:55 ` [PATCH net-next v2 10/12] net: dsa: Wire up multicast IGMP snooping attribute notification Florian Fainelli
2019-01-30 16:06   ` Andrew Lunn
2019-01-30 22:32     ` Florian Fainelli
2019-01-30 22:46   ` Andrew Lunn
2019-01-30 23:02     ` Florian Fainelli
2019-01-30  0:55 ` Florian Fainelli [this message]
2019-01-30  0:55 ` [PATCH net-next v2 12/12] net: dsa: bcm_sf2: Enable management mode Florian Fainelli
2019-01-30  7:38 ` [PATCH net-next v2 00/12] net: dsa: management mode for bcm_sf2 Ido Schimmel
2019-01-30 22:23 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190130005548.2212-12-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=ivan.khoronzhuk@linaro.org \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).