linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues
@ 2017-10-31 14:47 Egil Hjelmeland
  2017-10-31 14:48 ` [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast Egil Hjelmeland
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Egil Hjelmeland @ 2017-10-31 14:47 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel; +Cc: Egil Hjelmeland

This patch set finishes the STP support, and fixes flooding issues.

Patch 1 fixes a flooding issue in the previous patch set.
Patch 2 finishes STP support by adding a ALR entry.
Patch 3 prevent duplicate flooding in HW and SW bridge.


Egil Hjelmeland (3):
  net: dsa: lan9303: Transmit using ALR when unicast
  net: dsa: lan9303: Add STP ALR entry on port 0
  net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark

 drivers/net/dsa/lan9303-core.c | 2 ++
 include/linux/dsa/lan9303.h    | 2 ++
 net/dsa/tag_lan9303.c          | 7 ++++---
 3 files changed, 8 insertions(+), 3 deletions(-)

-- 
2.11.0

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

* [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast
  2017-10-31 14:47 [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues Egil Hjelmeland
@ 2017-10-31 14:48 ` Egil Hjelmeland
  2017-11-01 12:04   ` Andrew Lunn
  2017-10-31 14:48 ` [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0 Egil Hjelmeland
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Egil Hjelmeland @ 2017-10-31 14:48 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel; +Cc: Egil Hjelmeland

lan9303_xmit_use_arl() introduced in previous patch set is wrong.
The chip flood broadcast and unknown multicast frames. The effect is that
broadcasts and multicasts are duplicated on egress. It is not possible to
configure the chip to direct unknown multicasts to CPU port only.

This means that only unicast frames can be transmitted using ALR lookup.

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
 net/dsa/tag_lan9303.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c
index 64092325aac3..537ca991fafe 100644
--- a/net/dsa/tag_lan9303.c
+++ b/net/dsa/tag_lan9303.c
@@ -46,7 +46,7 @@
 
 /* Decide whether to transmit using ALR lookup, or transmit directly to
  * port using tag. ALR learning is performed only when using ALR lookup.
- * If the two external ports are bridged and the packet is not STP BPDU,
+ * If the two external ports are bridged and the frame is unicast,
  * then use ALR lookup to allow ALR learning on CPU port.
  * Otherwise transmit directly to port with STP state override.
  * See also: lan9303_separate_ports() and lan9303.pdf 6.4.10.1
@@ -55,7 +55,7 @@ static int lan9303_xmit_use_arl(struct dsa_port *dp, u8 *dest_addr)
 {
 	struct lan9303 *chip = dp->ds->priv;
 
-	return chip->is_bridged && !ether_addr_equal(dest_addr, eth_stp_addr);
+	return chip->is_bridged && !is_multicast_ether_addr(dest_addr);
 }
 
 static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev)
-- 
2.11.0

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

* [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0
  2017-10-31 14:47 [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues Egil Hjelmeland
  2017-10-31 14:48 ` [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast Egil Hjelmeland
@ 2017-10-31 14:48 ` Egil Hjelmeland
  2017-11-01 12:04   ` Andrew Lunn
  2017-10-31 14:48 ` [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark Egil Hjelmeland
  2017-11-01 12:30 ` [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues David Miller
  3 siblings, 1 reply; 9+ messages in thread
From: Egil Hjelmeland @ 2017-10-31 14:48 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel; +Cc: Egil Hjelmeland

STP BPDUs arriving on user ports must sent to CPU port only,
for processing by the SW bridge.

Add an ALR entry with STP state override to fix that.

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
 drivers/net/dsa/lan9303-core.c | 2 ++
 include/linux/dsa/lan9303.h    | 2 ++
 net/dsa/tag_lan9303.c          | 1 -
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 4c412bd52319..c4afc8f1a66d 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -773,6 +773,7 @@ static int lan9303_separate_ports(struct lan9303 *chip)
 {
 	int ret;
 
+	lan9303_alr_del_port(chip, eth_stp_addr, 0);
 	ret = lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR,
 				LAN9303_SWE_PORT_MIRROR_SNIFFER_PORT0 |
 				LAN9303_SWE_PORT_MIRROR_MIRRORED_PORT1 |
@@ -797,6 +798,7 @@ static void lan9303_bridge_ports(struct lan9303 *chip)
 
 	lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_STATE,
 				 chip->swe_port_state);
+	lan9303_alr_add_port(chip, eth_stp_addr, 0, true);
 }
 
 static int lan9303_handle_reset(struct lan9303 *chip)
diff --git a/include/linux/dsa/lan9303.h b/include/linux/dsa/lan9303.h
index 05d8d136baab..b2110e69630f 100644
--- a/include/linux/dsa/lan9303.h
+++ b/include/linux/dsa/lan9303.h
@@ -34,3 +34,5 @@ struct lan9303 {
 	 **/
 	struct lan9303_alr_cache_entry alr_cache[LAN9303_NUM_ALR_RECORDS];
 };
+
+#define eth_stp_addr eth_reserved_addr_base
diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c
index 537ca991fafe..18f45cd9f625 100644
--- a/net/dsa/tag_lan9303.c
+++ b/net/dsa/tag_lan9303.c
@@ -42,7 +42,6 @@
 #define LAN9303_TAG_LEN 4
 # define LAN9303_TAG_TX_USE_ALR BIT(3)
 # define LAN9303_TAG_TX_STP_OVERRIDE BIT(4)
-#define eth_stp_addr eth_reserved_addr_base
 
 /* Decide whether to transmit using ALR lookup, or transmit directly to
  * port using tag. ALR learning is performed only when using ALR lookup.
-- 
2.11.0

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

* [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark
  2017-10-31 14:47 [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues Egil Hjelmeland
  2017-10-31 14:48 ` [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast Egil Hjelmeland
  2017-10-31 14:48 ` [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0 Egil Hjelmeland
@ 2017-10-31 14:48 ` Egil Hjelmeland
  2017-11-01 12:03   ` Andrew Lunn
  2017-11-01 12:30 ` [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues David Miller
  3 siblings, 1 reply; 9+ messages in thread
From: Egil Hjelmeland @ 2017-10-31 14:48 UTC (permalink / raw)
  To: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel; +Cc: Egil Hjelmeland

The chip flood broadcast and unknown multicast frames.
On receive set skb->offload_fwd_mark to prevent the SW from flooding to the
same ports.

One exception: Because the ALR is set up to forward STP BPDUs only to CPU,
the SW bridge should flood STP BPDUs if local STP is not enabled.
This is archived by not setting skb->offload_fwd_mark on STP BPDUs.

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
---
 net/dsa/tag_lan9303.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c
index 18f45cd9f625..e526c8967b98 100644
--- a/net/dsa/tag_lan9303.c
+++ b/net/dsa/tag_lan9303.c
@@ -126,6 +126,8 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
 	skb_pull_rcsum(skb, 2 + 2);
 	memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN),
 		2 * ETH_ALEN);
+	skb->offload_fwd_mark = !ether_addr_equal(skb->data - ETH_HLEN,
+						  eth_stp_addr);
 
 	return skb;
 }
-- 
2.11.0

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

* Re: [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark
  2017-10-31 14:48 ` [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark Egil Hjelmeland
@ 2017-11-01 12:03   ` Andrew Lunn
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2017-11-01 12:03 UTC (permalink / raw)
  To: Egil Hjelmeland; +Cc: vivien.didelot, f.fainelli, netdev, linux-kernel

> One exception: Because the ALR is set up to forward STP BPDUs only to CPU,
> the SW bridge should flood STP BPDUs if local STP is not enabled.
> This is archived by not setting skb->offload_fwd_mark on STP BPDUs.

Hi Egil

This bit is interesting. I had not thought about that.

I think we need a few more drivers to set offload_fwd_mark, and then
maybe try to consolidate it into the core. But it is too early now.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0
  2017-10-31 14:48 ` [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0 Egil Hjelmeland
@ 2017-11-01 12:04   ` Andrew Lunn
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2017-11-01 12:04 UTC (permalink / raw)
  To: Egil Hjelmeland; +Cc: vivien.didelot, f.fainelli, netdev, linux-kernel

On Tue, Oct 31, 2017 at 03:48:01PM +0100, Egil Hjelmeland wrote:
> STP BPDUs arriving on user ports must sent to CPU port only,
> for processing by the SW bridge.
> 
> Add an ALR entry with STP state override to fix that.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast
  2017-10-31 14:48 ` [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast Egil Hjelmeland
@ 2017-11-01 12:04   ` Andrew Lunn
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2017-11-01 12:04 UTC (permalink / raw)
  To: Egil Hjelmeland; +Cc: vivien.didelot, f.fainelli, netdev, linux-kernel

On Tue, Oct 31, 2017 at 03:48:00PM +0100, Egil Hjelmeland wrote:
> lan9303_xmit_use_arl() introduced in previous patch set is wrong.
> The chip flood broadcast and unknown multicast frames. The effect is that
> broadcasts and multicasts are duplicated on egress. It is not possible to
> configure the chip to direct unknown multicasts to CPU port only.
> 
> This means that only unicast frames can be transmitted using ALR lookup.
> 
> Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues
  2017-10-31 14:47 [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues Egil Hjelmeland
                   ` (2 preceding siblings ...)
  2017-10-31 14:48 ` [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark Egil Hjelmeland
@ 2017-11-01 12:30 ` David Miller
  2017-11-02  9:06   ` Egil Hjelmeland
  3 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2017-11-01 12:30 UTC (permalink / raw)
  To: privat; +Cc: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel

From: Egil Hjelmeland <privat@egil-hjelmeland.no>
Date: Tue, 31 Oct 2017 15:47:59 +0100

> This patch set finishes the STP support, and fixes flooding issues.
> 
> Patch 1 fixes a flooding issue in the previous patch set.
> Patch 2 finishes STP support by adding a ALR entry.
> Patch 3 prevent duplicate flooding in HW and SW bridge.

Series applied, thank you.

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

* Re: [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues
  2017-11-01 12:30 ` [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues David Miller
@ 2017-11-02  9:06   ` Egil Hjelmeland
  0 siblings, 0 replies; 9+ messages in thread
From: Egil Hjelmeland @ 2017-11-02  9:06 UTC (permalink / raw)
  To: David Miller; +Cc: andrew, vivien.didelot, f.fainelli, netdev, linux-kernel

On 01. nov. 2017 13:30, David Miller wrote:
> From: Egil Hjelmeland <privat@egil-hjelmeland.no>
> Date: Tue, 31 Oct 2017 15:47:59 +0100
> 
>> This patch set finishes the STP support, and fixes flooding issues.
>>
> 
> Series applied, thank you.
> 

Thanks! Based on happy testing on my desktop, I conclude that the 
net-next lan9303 driver has now reached a level where my employer 
Zenitel can use it out of the box. We have covered everything we need 
from our proprietary driver.

Our old proprietary driver can not separate the interfaces. Being able 
to do so may be interesting in some custom usages of our product. And we 
are very much looking forward to Andrew progressing his series for IGMP 
snooping for local traffic!

Egil

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

end of thread, other threads:[~2017-11-02  9:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 14:47 [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues Egil Hjelmeland
2017-10-31 14:48 ` [PATCH net-next 1/3] net: dsa: lan9303: Transmit using ALR when unicast Egil Hjelmeland
2017-11-01 12:04   ` Andrew Lunn
2017-10-31 14:48 ` [PATCH net-next 2/3] net: dsa: lan9303: Add STP ALR entry on port 0 Egil Hjelmeland
2017-11-01 12:04   ` Andrew Lunn
2017-10-31 14:48 ` [PATCH net-next 3/3] net: dsa: lan9303: lan9303_rcv set skb->offload_fwd_mark Egil Hjelmeland
2017-11-01 12:03   ` Andrew Lunn
2017-11-01 12:30 ` [PATCH net-next 0/3] net: dsa: lan9303: Fix STP and flooding issues David Miller
2017-11-02  9:06   ` Egil Hjelmeland

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