diff mbox series

realtek: Trap all frames with switch as destination to CPU-port

Message ID d1d7f0b0-f3bf-58d4-4de3-bcbe0d582824@birger-koblitz.de
State Changes Requested
Delegated to: Sander Vanheule
Headers show
Series realtek: Trap all frames with switch as destination to CPU-port | expand

Commit Message

Birger Koblitz April 24, 2022, 6:37 p.m. UTC
This fixes a bug where frames sent to the switch itself were
flooded to all ports unless the MAC address of the CPU-port
was learned otherwise.

Tested-by: Wenli Looi <wlooi@ucalgary.ca>
Tested-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
---
This was previously sent as a patch with a wrong subject
"[PATCH] realtek: do not reset SerDes on link change"

 .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c  | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Sander Vanheule April 25, 2022, 6:40 p.m. UTC | #1
Hi Birger,

On Sun, 2022-04-24 at 20:37 +0200, Birger Koblitz wrote:
> This fixes a bug where frames sent to the switch itself were
> flooded to all ports unless the MAC address of the CPU-port
> was learned otherwise.
> 
> Tested-by: Wenli Looi <wlooi@ucalgary.ca>
> Tested-by: Bjørn Mork <bjorn@mork.no>
> Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
> ---
> This was previously sent as a patch with a wrong subject
> "[PATCH] realtek: do not reset SerDes on link change"
> 
>  .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c  | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> index 4780632983..858b692640 100644
> --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> @@ -205,6 +205,12 @@ static int rtl83xx_setup(struct dsa_switch *ds)
> 
>         priv->r->l2_learning_setup();
> 
> +       // Make sure all frames sent to the switch's MAC are trapped to the CPU-port
> +       if (priv->family_id == RTL8380_FAMILY_ID)
> +           sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: DROP, 2:
> TRAP2CPU
> +       else
> +           sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);
> +
>         /* Enable MAC Polling PHY again */
>         rtl83xx_enable_phy_polling(priv);
>         pr_debug("Please wait until PHY is settled\n");

checkpatch.pl has some complaints:

WARNING: suspect code indent for conditional statements (8, 12)
#142: FILE: target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c:209:
+	if (priv->family_id == RTL8380_FAMILY_ID)
+	    sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: DROP, 2: TRAP2CPU

WARNING: suspect code indent for conditional statements (8, 12)
#144: FILE: target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c:211:
+	else
+	    sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);

WARNING: Missing Signed-off-by: line by nominal patch author 'Birger Koblitz <mail@birger-koblitz.de>'

total: 0 errors, 3 warnings, 12 lines checked


Please indent with tabs, but you can ignore the third warning.


Best,
Sander
Sander Vanheule May 8, 2022, 11:13 a.m. UTC | #2
Hi,

On Mon, 2022-04-25 at 20:40 +0200, Sander Vanheule wrote:
> Hi Birger,
> 
> On Sun, 2022-04-24 at 20:37 +0200, Birger Koblitz wrote:
> > This fixes a bug where frames sent to the switch itself were
> > flooded to all ports unless the MAC address of the CPU-port
> > was learned otherwise.
> > 
> > Tested-by: Wenli Looi <wlooi@ucalgary.ca>
> > Tested-by: Bjørn Mork <bjorn@mork.no>
> > Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
> > ---
> > This was previously sent as a patch with a wrong subject
> > "[PATCH] realtek: do not reset SerDes on link change"
> > 
> >  .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c  | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> > b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> > index 4780632983..858b692640 100644
> > --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> > +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> > @@ -205,6 +205,12 @@ static int rtl83xx_setup(struct dsa_switch *ds)
> > 
> >         priv->r->l2_learning_setup();
> > 
> > +       // Make sure all frames sent to the switch's MAC are trapped to the CPU-port
> > +       if (priv->family_id == RTL8380_FAMILY_ID)
> > +           sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: DROP, 2:
> > TRAP2CPU
> > +       else
> > +           sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);
> > +
> >         /* Enable MAC Polling PHY again */
> >         rtl83xx_enable_phy_polling(priv);
> >         pr_debug("Please wait until PHY is settled\n");
> 
> checkpatch.pl has some complaints:
> 
> WARNING: suspect code indent for conditional statements (8, 12)
> #142: FILE: target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c:209:
> +       if (priv->family_id == RTL8380_FAMILY_ID)
> +           sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: DROP, 2:
> TRAP2CPU
> 
> WARNING: suspect code indent for conditional statements (8, 12)
> #144: FILE: target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c:211:
> +       else
> +           sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);
> 
> WARNING: Missing Signed-off-by: line by nominal patch author 'Birger Koblitz
> <mail@birger-koblitz.de>'
> 
> total: 0 errors, 3 warnings, 12 lines checked
> 
> 
> Please indent with tabs, but you can ignore the third warning.


I've fixed the issues myself, and merged the changes. Please run checkpatch.pl next time,
and fix any errors or warnings, including the author-mismatch (with a From: line at the
start of the patch).

Best,
Sander
diff mbox series

Patch

diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
index 4780632983..858b692640 100644
--- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
@@ -205,6 +205,12 @@  static int rtl83xx_setup(struct dsa_switch *ds)

 	priv->r->l2_learning_setup();

+	// Make sure all frames sent to the switch's MAC are trapped to the CPU-port
+	if (priv->family_id == RTL8380_FAMILY_ID)
+	    sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: DROP, 2: TRAP2CPU
+	else
+	    sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);
+
 	/* Enable MAC Polling PHY again */
 	rtl83xx_enable_phy_polling(priv);
 	pr_debug("Please wait until PHY is settled\n");