Netdev List
 help / color / mirror / Atom feed
From: Alban Bedel <alban.bedel@aerq.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	UNGLinuxDriver@microchip.com,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alban Bedel <alban.bedel@aerq.com>
Subject: [PATCH] net: mscc: ocelot: Fix multicast to the CPU port
Date: Mon, 18 Jan 2021 17:03:17 +0100	[thread overview]
Message-ID: <20210118160317.554018-1-alban.bedel@aerq.com> (raw)

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 add a new `flags` parameter to ocelot_mact_learn()
and set MAC_CPU_COPY when the CPU port is in the port set. We still
leave the CPU port in the bitfield as it doesn't seems to hurt.

Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
Fixes: 9403c158 (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb entries)
---
 drivers/net/ethernet/mscc/ocelot.c | 17 ++++++++++++-----
 drivers/net/ethernet/mscc/ocelot.h |  3 ++-
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 0b9992bd6626..c33162dbf075 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -58,12 +58,13 @@ static void ocelot_mact_select(struct ocelot *ocelot,
 
 int ocelot_mact_learn(struct ocelot *ocelot, int port,
 		      const unsigned char mac[ETH_ALEN],
-		      unsigned int vid, enum macaccess_entry_type type)
+		      unsigned int vid, enum macaccess_entry_type type,
+		      u32 flags)
 {
 	ocelot_mact_select(ocelot, mac, vid);
 
 	/* Issue a write command */
-	ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID |
+	ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID | flags |
 			     ANA_TABLES_MACACCESS_DEST_IDX(port) |
 			     ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
 			     ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN),
@@ -574,7 +575,7 @@ int ocelot_fdb_add(struct ocelot *ocelot, int port,
 	if (port == ocelot->npi)
 		pgid = PGID_CPU;
 
-	return ocelot_mact_learn(ocelot, pgid, addr, vid, ENTRYTYPE_LOCKED);
+	return ocelot_mact_learn(ocelot, pgid, addr, vid, ENTRYTYPE_LOCKED, 0);
 }
 EXPORT_SYMBOL(ocelot_fdb_add);
 
@@ -1064,6 +1065,7 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
 	struct ocelot_multicast *mc;
 	struct ocelot_pgid *pgid;
 	u16 vid = mdb->vid;
+	u32 flags = 0;
 
 	if (port == ocelot->npi)
 		port = ocelot->num_phys_ports;
@@ -1107,9 +1109,11 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
 	    mc->entry_type != ENTRYTYPE_MACv6)
 		ocelot_write_rix(ocelot, pgid->ports, ANA_PGID_PGID,
 				 pgid->index);
+	if (mc->ports & BIT(ocelot->num_phys_ports))
+		flags |= ANA_TABLES_MACACCESS_MAC_CPU_COPY;
 
 	return ocelot_mact_learn(ocelot, pgid->index, addr, vid,
-				 mc->entry_type);
+				 mc->entry_type, flags);
 }
 EXPORT_SYMBOL(ocelot_port_mdb_add);
 
@@ -1120,6 +1124,7 @@ int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
 	struct ocelot_multicast *mc;
 	struct ocelot_pgid *pgid;
 	u16 vid = mdb->vid;
+	u32 flags = 0;
 
 	if (port == ocelot->npi)
 		port = ocelot->num_phys_ports;
@@ -1151,9 +1156,11 @@ int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
 	    mc->entry_type != ENTRYTYPE_MACv6)
 		ocelot_write_rix(ocelot, pgid->ports, ANA_PGID_PGID,
 				 pgid->index);
+	if (mc->ports & BIT(ocelot->num_phys_ports))
+		flags |= ANA_TABLES_MACACCESS_MAC_CPU_COPY;
 
 	return ocelot_mact_learn(ocelot, pgid->index, addr, vid,
-				 mc->entry_type);
+				 mc->entry_type, flags);
 }
 EXPORT_SYMBOL(ocelot_port_mdb_del);
 
diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h
index 291d39d49c4e..63045f1ef0cd 100644
--- a/drivers/net/ethernet/mscc/ocelot.h
+++ b/drivers/net/ethernet/mscc/ocelot.h
@@ -106,7 +106,8 @@ int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
 			    bool is_static, void *data);
 int ocelot_mact_learn(struct ocelot *ocelot, int port,
 		      const unsigned char mac[ETH_ALEN],
-		      unsigned int vid, enum macaccess_entry_type type);
+		      unsigned int vid, enum macaccess_entry_type type,
+		      u32 flags);
 int ocelot_mact_forget(struct ocelot *ocelot,
 		       const unsigned char mac[ETH_ALEN], unsigned int vid);
 int ocelot_port_lag_join(struct ocelot *ocelot, int port,
-- 
2.25.1


             reply	other threads:[~2021-01-18 16:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 16:03 Alban Bedel [this message]
2021-01-18 18:55 ` [PATCH] net: mscc: ocelot: Fix multicast to the CPU port Vladimir Oltean
2021-01-19 10:12   ` Bedel, Alban
2021-01-19 10:51     ` Vladimir Oltean

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=20210118160317.554018-1-alban.bedel@aerq.com \
    --to=alban.bedel@aerq.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.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