From: DENG Qingfang <dqfext@gmail.com> Date: 2021-02-24 06:13:14
Use port isolation registers to configure bridge offloading.
Remove the VLAN init, as we have proper CPU tag and bridge offloading
support now.
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
This is not tested, as I don't have a RTL8366RB board. And I think there
is potential race condition in port_bridge_{join,leave}.
drivers/net/dsa/rtl8366rb.c | 73 ++++++++++++++++++++++++++++++++++---
1 file changed, 67 insertions(+), 6 deletions(-)
@@ -835,6 +841,15 @@ static int rtl8366rb_setup(struct dsa_switch *ds)if(ret)returnret;+/* Isolate user ports */+for(i=0;i<RTL8366RB_PORT_NUM_CPU;i++){+ret=regmap_write(smi->map,RTL8366RB_PORT_ISO(i),+RTL8366RB_PORT_ISO_EN|+BIT(RTL8366RB_PORT_NUM_CPU+1));+if(ret)+returnret;+}+/* Set up the "green ethernet" feature */ret=rtl8366rb_jam_table(rtl8366rb_green_jam,ARRAY_SIZE(rtl8366rb_green_jam),smi,false);
On Wed, Feb 24, 2021 at 7:12 AM DENG Qingfang [off-list ref] wrote:
Use port isolation registers to configure bridge offloading.
Remove the VLAN init, as we have proper CPU tag and bridge offloading
support now.
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
This is not tested, as I don't have a RTL8366RB board. And I think there
is potential race condition in port_bridge_{join,leave}.
Compilation failed for me like this:
../drivers/net/dsa/rtl8366rb.c:1573:23: error: initialization of 'void
(*)(struct dsa_switch *, int, struct net_device *)' from incompatible
pointer type 'int (*)(struct dsa_switch *, int, struct net_device *)'
[-Werror=incompatible-pointer-types]
1573 | .port_bridge_leave = rtl8366rb_port_bridge_leave,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/dsa/rtl8366rb.c:1573:23: note: (near initialization for
'rtl8366rb_switch_ops.port_bridge_leave')
I fixed it like this:
On Tue, Mar 2, 2021 at 4:58 AM DENG Qingfang [off-list ref] wrote:
On Mon, Mar 1, 2021 at 9:48 PM Linus Walleij [off-list ref] wrote:
quoted
With my minor changes:
Tested-by: Linus Walleij <redacted>
How about using a mutex lock in port_bridge_{join,leave} ?
In my opinion all functions that access multiple registers should be
synchronized.
That's one way, in some cases the framework (DSA) serialize
the accesses so I don't know if that already happens on a
higher level? Since it is accessed over a slow bus we should go
for mutex in that case indeed.
Yours,
Linus Walleij
On Tue, Mar 2, 2021 at 5:11 PM Vladimir Oltean [off-list ref] wrote:
On Tue, Mar 02, 2021 at 05:05:00PM +0100, Linus Walleij wrote:
quoted
On Tue, Mar 2, 2021 at 4:58 AM DENG Qingfang [off-list ref] wrote:
quoted
On Mon, Mar 1, 2021 at 9:48 PM Linus Walleij [off-list ref] wrote:
quoted
With my minor changes:
Tested-by: Linus Walleij <redacted>
How about using a mutex lock in port_bridge_{join,leave} ?
In my opinion all functions that access multiple registers should be
synchronized.
That's one way, in some cases the framework (DSA) serialize
the accesses so I don't know if that already happens on a
higher level? Since it is accessed over a slow bus we should go
for mutex in that case indeed.
DSA does not serialize this. The .port_bridge_join and
.port_bridge_leave calls are initiated from the NETDEV_CHANGEUPPER net
device event, which is called under rtnl_mutex (see call_netdevice_notifiers).
This is pretty fundamental and I don't think it will ever change.
However, if you still want to add an extra layer of locking (with code
paths that for some reason are not under the rtnl_mutex), then go ahead,
I suppose. It will be challenging to make sure they do something that
isn't snake oil, though.
Nah, just didn't know if was already in place.
I suggest Qingfang go with a driver-local mutex (it may already be needed in
more places).
Yours,
Linus Walleij
From: Vladimir Oltean <olteanv@gmail.com> Date: 2021-03-02 21:21:23
On Tue, Mar 02, 2021 at 05:05:00PM +0100, Linus Walleij wrote:
On Tue, Mar 2, 2021 at 4:58 AM DENG Qingfang [off-list ref] wrote:
quoted
On Mon, Mar 1, 2021 at 9:48 PM Linus Walleij [off-list ref] wrote:
quoted
With my minor changes:
Tested-by: Linus Walleij <redacted>
How about using a mutex lock in port_bridge_{join,leave} ?
In my opinion all functions that access multiple registers should be
synchronized.
That's one way, in some cases the framework (DSA) serialize
the accesses so I don't know if that already happens on a
higher level? Since it is accessed over a slow bus we should go
for mutex in that case indeed.
DSA does not serialize this. The .port_bridge_join and
.port_bridge_leave calls are initiated from the NETDEV_CHANGEUPPER net
device event, which is called under rtnl_mutex (see call_netdevice_notifiers).
This is pretty fundamental and I don't think it will ever change.
However, if you still want to add an extra layer of locking (with code
paths that for some reason are not under the rtnl_mutex), then go ahead,
I suppose. It will be challenging to make sure they do something that
isn't snake oil, though.
Use port isolation registers to configure bridge offloading.
Remove the VLAN init, as we have proper CPU tag and bridge offloading
support now.
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
This is not tested, as I don't have a RTL8366RB board. And I think there
is potential race condition in port_bridge_{join,leave}.
drivers/net/dsa/rtl8366rb.c | 73 ++++++++++++++++++++++++++++++++++---
1 file changed, 67 insertions(+), 6 deletions(-)
@@ -835,6 +841,15 @@ static int rtl8366rb_setup(struct dsa_switch *ds)if(ret)returnret;+/* Isolate user ports */+for(i=0;i<RTL8366RB_PORT_NUM_CPU;i++){+ret=regmap_write(smi->map,RTL8366RB_PORT_ISO(i),+RTL8366RB_PORT_ISO_EN|+BIT(RTL8366RB_PORT_NUM_CPU+1));+if(ret)+returnret;+}+/* Set up the "green ethernet" feature */ret=rtl8366rb_jam_table(rtl8366rb_green_jam,ARRAY_SIZE(rtl8366rb_green_jam),smi,false);
@@ -977,8 +988,6 @@ static int rtl8366rb_setup(struct dsa_switch *ds)return-ENODEV;}-ds->configure_vlan_while_not_filtering=false;
If you have a configuration with ports that are part of a bridge with
VLAN filtering enabled, what happens to the standalone ports, are they a
member of a default VLAN entry still?
--
Florian