All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: bridge: assign path_cost for 2.5G and 5G link speed
@ 2022-09-28 17:57 ` Steven Hsieh
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Hsieh @ 2022-09-28 17:57 UTC (permalink / raw)
  To: Steven Hsieh
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski,
	Nikolay Aleksandrov, Paolo Abeni, Roopa Prabhu, bridge,
	linux-kernel, netdev

[-- Attachment #1: Type: text/plain, Size: 1994 bytes --]

As 2.5G, 5G ethernet ports are more common and affordable,
these ports are being used in LAN bridge devices.
STP port_cost() is missing path_cost assignment for these link speeds,
causes highest cost 100 being used.
This result in lower speed port being picked
when there is loop between 5G and 1G ports.

Original path_cost: 10G=2, 1G=4, 100m=19, 10m=100
Adjusted path_cost: 10G=2, 5G=3, 2.5G=4, 1G=5, 100m=19, 10m=100
                    speed greater than 10G = 1

Signed-off-by: Steven Hsieh <steven.hsieh@broadcom.com>

---

 net/bridge/br_if.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index a84a7cfb9d6d..a24a1e782e8f 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -40,12 +40,21 @@ static int port_cost(struct net_device *dev)
 		switch (ecmd.base.speed) {
 		case SPEED_10000:
 			return 2;
-		case SPEED_1000:
+		case SPEED_5000:
+			return 3;
+		case SPEED_2500:
 			return 4;
+		case SPEED_1000:
+			return 5;
 		case SPEED_100:
 			return 19;
 		case SPEED_10:
 			return 100;
+		case SPEED_UNKNOWN:
+			return 100;
+		default:
+			if (ecmd.base.speed > SPEED_10000)
+				return 1;
 		}
 	}
 
-- 
2.34.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* [Bridge] [PATCH net-next] net: bridge: assign path_cost for 2.5G and 5G link speed
@ 2022-09-28 17:57 ` Steven Hsieh
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Hsieh @ 2022-09-28 17:57 UTC (permalink / raw)
  To: Steven Hsieh
  Cc: netdev, Nikolay Aleksandrov, bridge, linux-kernel, Eric Dumazet,
	Roopa Prabhu, Jakub Kicinski, Paolo Abeni, David S. Miller

[-- Attachment #1: Type: text/plain, Size: 1994 bytes --]

As 2.5G, 5G ethernet ports are more common and affordable,
these ports are being used in LAN bridge devices.
STP port_cost() is missing path_cost assignment for these link speeds,
causes highest cost 100 being used.
This result in lower speed port being picked
when there is loop between 5G and 1G ports.

Original path_cost: 10G=2, 1G=4, 100m=19, 10m=100
Adjusted path_cost: 10G=2, 5G=3, 2.5G=4, 1G=5, 100m=19, 10m=100
                    speed greater than 10G = 1

Signed-off-by: Steven Hsieh <steven.hsieh@broadcom.com>

---

 net/bridge/br_if.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index a84a7cfb9d6d..a24a1e782e8f 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -40,12 +40,21 @@ static int port_cost(struct net_device *dev)
 		switch (ecmd.base.speed) {
 		case SPEED_10000:
 			return 2;
-		case SPEED_1000:
+		case SPEED_5000:
+			return 3;
+		case SPEED_2500:
 			return 4;
+		case SPEED_1000:
+			return 5;
 		case SPEED_100:
 			return 19;
 		case SPEED_10:
 			return 100;
+		case SPEED_UNKNOWN:
+			return 100;
+		default:
+			if (ecmd.base.speed > SPEED_10000)
+				return 1;
 		}
 	}
 
-- 
2.34.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* Re: [PATCH net-next] net: bridge: assign path_cost for 2.5G and 5G link speed
  2022-09-28 17:57 ` [Bridge] " Steven Hsieh
@ 2022-09-30 11:40   ` patchwork-bot+netdevbpf
  -1 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-30 11:40 UTC (permalink / raw)
  To: Steven Hsieh
  Cc: davem, edumazet, kuba, razor, pabeni, roopa, bridge,
	linux-kernel, netdev

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 28 Sep 2022 10:57:58 -0700 you wrote:
> As 2.5G, 5G ethernet ports are more common and affordable,
> these ports are being used in LAN bridge devices.
> STP port_cost() is missing path_cost assignment for these link speeds,
> causes highest cost 100 being used.
> This result in lower speed port being picked
> when there is loop between 5G and 1G ports.
> 
> [...]

Here is the summary with links:
  - [net-next] net: bridge: assign path_cost for 2.5G and 5G link speed
    https://git.kernel.org/netdev/net-next/c/bd1393815319

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [Bridge] [PATCH net-next] net: bridge: assign path_cost for 2.5G and 5G link speed
@ 2022-09-30 11:40   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-30 11:40 UTC (permalink / raw)
  To: Steven Hsieh
  Cc: netdev, razor, bridge, linux-kernel, edumazet, roopa, kuba,
	pabeni, davem

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 28 Sep 2022 10:57:58 -0700 you wrote:
> As 2.5G, 5G ethernet ports are more common and affordable,
> these ports are being used in LAN bridge devices.
> STP port_cost() is missing path_cost assignment for these link speeds,
> causes highest cost 100 being used.
> This result in lower speed port being picked
> when there is loop between 5G and 1G ports.
> 
> [...]

Here is the summary with links:
  - [net-next] net: bridge: assign path_cost for 2.5G and 5G link speed
    https://git.kernel.org/netdev/net-next/c/bd1393815319

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-09-30 11:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 17:57 [PATCH net-next] net: bridge: assign path_cost for 2.5G and 5G link speed Steven Hsieh
2022-09-28 17:57 ` [Bridge] " Steven Hsieh
2022-09-30 11:40 ` patchwork-bot+netdevbpf
2022-09-30 11:40   ` [Bridge] " patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.