[PATCH net v5 4/6] net: dsa: mt7530: fix handling of LLDP frames

arinc9.unal@gmail.com posted 6 patches 1 year, 3 months ago
There is a newer version of this series
[PATCH net v5 4/6] net: dsa: mt7530: fix handling of LLDP frames
Posted by arinc9.unal@gmail.com 1 year, 3 months ago
From: Arınç ÜNAL <arinc.unal@arinc9.com>

LLDP frames are link-local frames, therefore they must be trapped to the
CPU port. Currently, the MT753X switches treat LLDP frames as regular
multicast frames, therefore flooding them to user ports. To fix this, set
LLDP frames to be trapped to the CPU port(s).

Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
---
 drivers/net/dsa/mt7530.c | 8 ++++++++
 drivers/net/dsa/mt7530.h | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 7b72cf3a0e30..c85876fd9107 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2266,6 +2266,10 @@ mt7530_setup(struct dsa_switch *ds)
 	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
 		   MT753X_BPDU_CPU_ONLY);
 
+	/* Trap LLDP frames with :0E MAC DA to the CPU port */
+	mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
+		   MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
+
 	/* Enable and reset MIB counters */
 	mt7530_mib_reset(ds);
 
@@ -2369,6 +2373,10 @@ mt7531_setup_common(struct dsa_switch *ds)
 	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
 		   MT753X_BPDU_CPU_ONLY);
 
+	/* Trap LLDP frames with :0E MAC DA to the CPU port(s) */
+	mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
+		   MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
+
 	/* Enable and reset MIB counters */
 	mt7530_mib_reset(ds);
 
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index e590cf43f3ae..08045b035e6a 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -67,6 +67,11 @@ enum mt753x_id {
 #define MT753X_BPC			0x24
 #define  MT753X_BPDU_PORT_FW_MASK	GENMASK(2, 0)
 
+/* Register for :03 and :0E MAC DA frame control */
+#define MT753X_RGAC2			0x2c
+#define  MT753X_R0E_PORT_FW_MASK	GENMASK(18, 16)
+#define  MT753X_R0E_PORT_FW(x)		FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x)
+
 enum mt753x_bpdu_port_fw {
 	MT753X_BPDU_FOLLOW_MFC,
 	MT753X_BPDU_CPU_EXCLUDE = 4,
-- 
2.39.2

Re: [PATCH net v5 4/6] net: dsa: mt7530: fix handling of LLDP frames
Posted by Frank Wunderlich 1 year, 3 months ago
Am 16. Juni 2023 04:53:25 MESZ schrieb arinc9.unal@gmail.com:
>From: Arınç ÜNAL <arinc.unal@arinc9.com>
>
>LLDP frames are link-local frames, therefore they must be trapped to the
>CPU port. Currently, the MT753X switches treat LLDP frames as regular
>multicast frames, therefore flooding them to user ports. To fix this, set
>LLDP frames to be trapped to the CPU port(s).
>
>Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
>Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
>---
> drivers/net/dsa/mt7530.c | 8 ++++++++
> drivers/net/dsa/mt7530.h | 5 +++++
> 2 files changed, 13 insertions(+)
>
>diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
>index 7b72cf3a0e30..c85876fd9107 100644
>--- a/drivers/net/dsa/mt7530.c
>+++ b/drivers/net/dsa/mt7530.c
>@@ -2266,6 +2266,10 @@ mt7530_setup(struct dsa_switch *ds)
> 	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
> 		   MT753X_BPDU_CPU_ONLY);
> 
>+	/* Trap LLDP frames with :0E MAC DA to the CPU port */
>+	mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
>+		   MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
>+
> 	/* Enable and reset MIB counters */
> 	mt7530_mib_reset(ds);
> 
>@@ -2369,6 +2373,10 @@ mt7531_setup_common(struct dsa_switch *ds)
> 	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
> 		   MT753X_BPDU_CPU_ONLY);
> 
>+	/* Trap LLDP frames with :0E MAC DA to the CPU port(s) */
>+	mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
>+		   MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
>+
> 	/* Enable and reset MIB counters */
> 	mt7530_mib_reset(ds);
> 


I though these 2 hunks should go into some common function as these are redundant or am i wrong?

Btw.thx for your work on this driver :)

regards Frank
Re: [PATCH net v5 4/6] net: dsa: mt7530: fix handling of LLDP frames
Posted by Arınç ÜNAL 1 year, 3 months ago
On 16 June 2023 08:44:32 GMT+03:00, Frank Wunderlich <frank-w@public-files.de> wrote:
>Am 16. Juni 2023 04:53:25 MESZ schrieb arinc9.unal@gmail.com:
>>From: Arınç ÜNAL <arinc.unal@arinc9.com>
>>
>>LLDP frames are link-local frames, therefore they must be trapped to the
>>CPU port. Currently, the MT753X switches treat LLDP frames as regular
>>multicast frames, therefore flooding them to user ports. To fix this, set
>>LLDP frames to be trapped to the CPU port(s).
>>
>>Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
>>Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
>>---
>> drivers/net/dsa/mt7530.c | 8 ++++++++
>> drivers/net/dsa/mt7530.h | 5 +++++
>> 2 files changed, 13 insertions(+)
>>
>>diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
>>index 7b72cf3a0e30..c85876fd9107 100644
>>--- a/drivers/net/dsa/mt7530.c
>>+++ b/drivers/net/dsa/mt7530.c
>>@@ -2266,6 +2266,10 @@ mt7530_setup(struct dsa_switch *ds)
>> 	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
>> 		   MT753X_BPDU_CPU_ONLY);
>> 
>>+	/* Trap LLDP frames with :0E MAC DA to the CPU port */
>>+	mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
>>+		   MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
>>+
>> 	/* Enable and reset MIB counters */
>> 	mt7530_mib_reset(ds);
>> 
>>@@ -2369,6 +2373,10 @@ mt7531_setup_common(struct dsa_switch *ds)
>> 	mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
>> 		   MT753X_BPDU_CPU_ONLY);
>> 
>>+	/* Trap LLDP frames with :0E MAC DA to the CPU port(s) */
>>+	mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK,
>>+		   MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
>>+
>> 	/* Enable and reset MIB counters */
>> 	mt7530_mib_reset(ds);
>> 
>
>
>I though these 2 hunks should go into some common function

Like I said, I will do that on my net-next patch series.

Arınç
Re: [PATCH net v5 4/6] net: dsa: mt7530: fix handling of LLDP frames
Posted by Vladimir Oltean 1 year, 3 months ago
On Fri, Jun 16, 2023 at 09:21:40AM +0300, Arınç ÜNAL wrote:
> On 16 June 2023 08:44:32 GMT+03:00, Frank Wunderlich <frank-w@public-files.de> wrote:
> >Am 16. Juni 2023 04:53:25 MESZ schrieb arinc9.unal@gmail.com:
> >I though these 2 hunks should go into some common function
> 
> Like I said, I will do that on my net-next patch series.
> 
> Arınç

Please create a common function now.