netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: mscc: ocelot: Fix multicast to the CPU port
@ 2021-01-19 14:06 Alban Bedel
  2021-01-19 16:46 ` Vladimir Oltean
  0 siblings, 1 reply; 3+ messages in thread
From: Alban Bedel @ 2021-01-19 14:06 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: Claudiu Manoil, Alexandre Belloni, UNGLinuxDriver,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel,
	Alban Bedel

Multicast entries in the MAC table use the high bits of the MAC
address to encode the ports that should get the packets. But this port
mask does not work for the CPU port, to receive these packets on the
CPU port the MAC_CPU_COPY flag must be set.

Because of this IPv6 was effectively not working because neighbor
solicitations were never received. This was not apparent before commit
9403c158 (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb
entries) as the IPv6 entries were broken so all incoming IPv6
multicast was then treated as unknown and flooded on all ports.

To fix this problem rework the ocelot_mact_learn() to set the
MAC_CPU_COPY flag when a multicast entry that target the CPU port is
added. For this we have to read back the ports endcoded in the pseudo
MAC address by the caller. It is not a very nice design but that avoid
changing the callers and should make backporting easier.

Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
Fixes: 9403c158b872 ("net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb entries")

---
Changelog:

v2: - Fix inside ocelot_mact_learn() as suggested by Vladimir Oltean
      to avoid changing the callers and making backport easier.
    - Fixed the Fixes tag to have a 12 digits hash
---
 drivers/net/ethernet/mscc/ocelot.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 0b9992bd6626..ff87a0bc089c 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -60,14 +60,27 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port,
 		      const unsigned char mac[ETH_ALEN],
 		      unsigned int vid, enum macaccess_entry_type type)
 {
+	u32 cmd = ANA_TABLES_MACACCESS_VALID |
+		ANA_TABLES_MACACCESS_DEST_IDX(port) |
+		ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
+		ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN);
+	unsigned int mc_ports;
+
+	/* Set MAC_CPU_COPY if the CPU port is used by a multicast entry */
+	if (type == ENTRYTYPE_MACv4)
+		mc_ports = (mac[1] << 8) | mac[2];
+	else if (type == ENTRYTYPE_MACv6)
+		mc_ports = (mac[0] << 8) | mac[1];
+	else
+		mc_ports = 0;
+
+	if (mc_ports & BIT(ocelot->num_phys_ports))
+		cmd |= ANA_TABLES_MACACCESS_MAC_CPU_COPY;
+
 	ocelot_mact_select(ocelot, mac, vid);
 
 	/* Issue a write command */
-	ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID |
-			     ANA_TABLES_MACACCESS_DEST_IDX(port) |
-			     ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
-			     ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN),
-			     ANA_TABLES_MACACCESS);
+	ocelot_write(ocelot, cmd, ANA_TABLES_MACACCESS);
 
 	return ocelot_mact_wait_for_completion(ocelot);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: mscc: ocelot: Fix multicast to the CPU port
  2021-01-19 14:06 [PATCH net v2] net: mscc: ocelot: Fix multicast to the CPU port Alban Bedel
@ 2021-01-19 16:46 ` Vladimir Oltean
  2021-01-20 17:00   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Oltean @ 2021-01-19 16:46 UTC (permalink / raw)
  To: Bedel, Alban
  Cc: Claudiu Manoil, Alexandre Belloni, UNGLinuxDriver,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel

On Tue, Jan 19, 2021 at 03:06:38PM +0100, Alban Bedel wrote:
> Multicast entries in the MAC table use the high bits of the MAC
> address to encode the ports that should get the packets. But this port
> mask does not work for the CPU port, to receive these packets on the
> CPU port the MAC_CPU_COPY flag must be set.
> 
> Because of this IPv6 was effectively not working because neighbor
> solicitations were never received. This was not apparent before commit
> 9403c158 (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb
> entries) as the IPv6 entries were broken so all incoming IPv6
> multicast was then treated as unknown and flooded on all ports.
> 
> To fix this problem rework the ocelot_mact_learn() to set the
> MAC_CPU_COPY flag when a multicast entry that target the CPU port is
> added. For this we have to read back the ports endcoded in the pseudo
> MAC address by the caller. It is not a very nice design but that avoid
> changing the callers and should make backporting easier.
> 
> Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
> Fixes: 9403c158b872 ("net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb entries")
> 
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: mscc: ocelot: Fix multicast to the CPU port
  2021-01-19 16:46 ` Vladimir Oltean
@ 2021-01-20 17:00   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-01-20 17:00 UTC (permalink / raw)
  To: Vladimir Oltean, Bedel, Alban
  Cc: Claudiu Manoil, Alexandre Belloni, UNGLinuxDriver,
	David S. Miller, netdev, linux-kernel

On Tue, 19 Jan 2021 16:46:01 +0000 Vladimir Oltean wrote:
> On Tue, Jan 19, 2021 at 03:06:38PM +0100, Alban Bedel wrote:
> > Multicast entries in the MAC table use the high bits of the MAC
> > address to encode the ports that should get the packets. But this port
> > mask does not work for the CPU port, to receive these packets on the
> > CPU port the MAC_CPU_COPY flag must be set.
> > 
> > Because of this IPv6 was effectively not working because neighbor
> > solicitations were never received. This was not apparent before commit
> > 9403c158 (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb
> > entries) as the IPv6 entries were broken so all incoming IPv6
> > multicast was then treated as unknown and flooded on all ports.
> > 
> > To fix this problem rework the ocelot_mact_learn() to set the
> > MAC_CPU_COPY flag when a multicast entry that target the CPU port is
> > added. For this we have to read back the ports endcoded in the pseudo
> > MAC address by the caller. It is not a very nice design but that avoid
> > changing the callers and should make backporting easier.
> > 
> > Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
> > Fixes: 9403c158b872 ("net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb entries")
> > 
> > ---  
> 
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-20 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 14:06 [PATCH net v2] net: mscc: ocelot: Fix multicast to the CPU port Alban Bedel
2021-01-19 16:46 ` Vladimir Oltean
2021-01-20 17:00   ` Jakub Kicinski

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).