Skip to contentSkip to conversation

IB/core: Add more speed parsing in ib_get_width_and_speed()

PATCH Applied Selvin Xavier 3 participants 8 messages Aug 2, 2023 – Aug 13, 2023 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 IB/core: Add more speed parsing in ib_get_width_and_speed()

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +10 -1
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
 		} else if (netdev_speed <= SPEED_40000) {
 			*width = IB_WIDTH_4X;
 			*speed = IB_SPEED_FDR10;
-		} else {
+		} else if (netdev_speed <= SPEED_50000) {
+			*width = IB_WIDTH_2X;
+			*speed = IB_SPEED_EDR;
+		} else if (netdev_speed <= SPEED_100000) {
 			*width = IB_WIDTH_4X;
 			*speed = IB_SPEED_EDR;
+		} else if (netdev_speed <= SPEED_200000) {
+			*width = IB_WIDTH_4X;
+			*speed = IB_SPEED_HDR;
+		} else {
+			*width = IB_WIDTH_4X;
+			*speed = IB_SPEED_NDR;
 		}
 
 		return;
Signature · 1 line
2.5.5
#1 lore raw
Quoted 26 lines · Selvin Xavier

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +0 -0
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
 		} else if (netdev_speed <= SPEED_40000) {
 			*width = IB_WIDTH_4X;
 			*speed = IB_SPEED_FDR10;

drivers/infiniband/core/verbs.c static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, · line 1910

Quoted 10 lines
drivers/infiniband/core/verbs.c +7 -1
-		} else {
+		} else if (netdev_speed <= SPEED_50000) {
+			*width = IB_WIDTH_2X;
+			*speed = IB_SPEED_EDR;
+		} else if (netdev_speed <= SPEED_100000) {
 			*width = IB_WIDTH_4X;
 			*speed = IB_SPEED_EDR;
+		} else if (netdev_speed <= SPEED_200000) {
+			*width = IB_WIDTH_4X;
+			*speed = IB_SPEED_HDR;

SPEED_50000, SPEED_100000 and SPEED_200000 depends on ClassPortInfo:CapabilityMask2.is* values.

For example, SPEED_50000 can b IB_WIDTH_2X/IB_SPEED_EDR and IB_WIDTH_1X/IB_SPEED_HDR.

Thanks

Quoted 9 lines
drivers/infiniband/core/verbs.c +3 -0
+		} else {
+			*width = IB_WIDTH_4X;
+			*speed = IB_SPEED_NDR;
 		}
 
 		return;
Signature · 1 line
2.5.5
#2 lore raw
Quoted 43 lines · Leon Romanovsky
Quoted 26 lines · Selvin Xavier

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +0 -0
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
              } else if (netdev_speed <= SPEED_40000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_FDR10;

drivers/infiniband/core/verbs.c static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, · line 1910

Quoted 10 lines
drivers/infiniband/core/verbs.c +7 -1
-             } else {
+             } else if (netdev_speed <= SPEED_50000) {
+                     *width = IB_WIDTH_2X;
+                     *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_100000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_200000) {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_HDR;

SPEED_50000, SPEED_100000 and SPEED_200000 depends on ClassPortInfo:CapabilityMask2.is* values.

Quoted 1 line

For example, SPEED_50000 can b IB_WIDTH_2X/IB_SPEED_EDR and IB_WIDTH_1X/IB_SPEED_HDR.

Agree with that.
This reporting can be achieved by the existing code, but the L2 driver needs to report non zero values for lanes in ethtool_ops->get_link_ksettings.
Caller of this modified function gets the speed and number of lanes from ethtool_ops->get_link_ksettings.

In this patch we are trying to handle the case where ethtool ops doesn't provide the lanes. We can default to some value so that we dont report wrong total link speed (width * speed) for any speed more than 40G.

Quoted 14 lines

Thanks

Quoted 9 lines
drivers/infiniband/core/verbs.c +3 -1
+             } else {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_NDR;
              }
 
              return;
--

2.5.5

#3 lore raw
Quoted 52 lines · Selvin Xavier
Quoted 43 lines · Leon Romanovsky
Quoted 26 lines · Selvin Xavier

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +0 -0
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
              } else if (netdev_speed <= SPEED_40000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_FDR10;

drivers/infiniband/core/verbs.c static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, · line 1910

Quoted 10 lines
drivers/infiniband/core/verbs.c +7 -1
-             } else {
+             } else if (netdev_speed <= SPEED_50000) {
+                     *width = IB_WIDTH_2X;
+                     *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_100000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_200000) {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_HDR;

SPEED_50000, SPEED_100000 and SPEED_200000 depends on ClassPortInfo:CapabilityMask2.is* values.

Quoted 1 line

For example, SPEED_50000 can b IB_WIDTH_2X/IB_SPEED_EDR and IB_WIDTH_1X/IB_SPEED_HDR.

Agree with that.
This reporting can be achieved by the existing code, but the L2 driver needs to report non zero values for lanes in ethtool_ops->get_link_ksettings.
Caller of this modified function gets the speed and number of lanes from ethtool_ops->get_link_ksettings.

Quoted 2 lines

In this patch we are trying to handle the case where ethtool ops doesn't provide the lanes.

Almost all drivers don't support lanes reporting.

Quoted 17 lines

We can default to some value so that we
dont report wrong total link speed (width * speed) for any speed more than 40G.

Quoted 14 lines

Thanks

Quoted 9 lines
drivers/infiniband/core/verbs.c +3 -1
+             } else {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_NDR;
              }
 
              return;
--

2.5.5

#4 lore raw
Quoted 54 lines · Leon Romanovsky
Quoted 52 lines · Selvin Xavier
Quoted 43 lines · Leon Romanovsky
Quoted 26 lines · Selvin Xavier

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +0 -0
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
              } else if (netdev_speed <= SPEED_40000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_FDR10;

drivers/infiniband/core/verbs.c static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, · line 1910

Quoted 10 lines
drivers/infiniband/core/verbs.c +7 -1
-             } else {
+             } else if (netdev_speed <= SPEED_50000) {
+                     *width = IB_WIDTH_2X;
+                     *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_100000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_200000) {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_HDR;

SPEED_50000, SPEED_100000 and SPEED_200000 depends on ClassPortInfo:CapabilityMask2.is* values.

Quoted 1 line

For example, SPEED_50000 can b IB_WIDTH_2X/IB_SPEED_EDR and IB_WIDTH_1X/IB_SPEED_HDR.

Agree with that.
This reporting can be achieved by the existing code, but the L2 driver needs to report non zero values for lanes in ethtool_ops->get_link_ksettings.
Caller of this modified function gets the speed and number of lanes from ethtool_ops->get_link_ksettings.

Quoted 4 lines
Quoted 2 lines

In this patch we are trying to handle the case where ethtool ops doesn't provide the lanes.

Almost all drivers don't support lanes reporting.

Agreed. But this patch will at least correct the overall speed reporting. So it's an improvement from the current behavior. If you still feel that this is not needed, you can drop the patch. We will have to modify the L2 drivers to report the lanes in that case.

Quoted 20 lines
Quoted 18 lines

We can default to some value so that we
dont report wrong total link speed (width * speed) for any speed more than 40G.

Quoted 14 lines

Thanks

Quoted 9 lines
drivers/infiniband/core/verbs.c +3 -1
+             } else {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_NDR;
              }
 
              return;
--

2.5.5

#5 lore raw
Quoted 55 lines · Selvin Xavier
Quoted 54 lines · Leon Romanovsky
Quoted 52 lines · Selvin Xavier
Quoted 43 lines · Leon Romanovsky
Quoted 26 lines · Selvin Xavier

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +0 -0
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
              } else if (netdev_speed <= SPEED_40000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_FDR10;

drivers/infiniband/core/verbs.c static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, · line 1910

Quoted 10 lines
drivers/infiniband/core/verbs.c +7 -1
-             } else {
+             } else if (netdev_speed <= SPEED_50000) {
+                     *width = IB_WIDTH_2X;
+                     *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_100000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_200000) {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_HDR;

SPEED_50000, SPEED_100000 and SPEED_200000 depends on ClassPortInfo:CapabilityMask2.is* values.

Quoted 1 line

For example, SPEED_50000 can b IB_WIDTH_2X/IB_SPEED_EDR and IB_WIDTH_1X/IB_SPEED_HDR.

Agree with that.
This reporting can be achieved by the existing code, but the L2 driver needs to report non zero values for lanes in ethtool_ops->get_link_ksettings.
Caller of this modified function gets the speed and number of lanes from ethtool_ops->get_link_ksettings.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

In this patch we are trying to handle the case where ethtool ops doesn't provide the lanes.

Almost all drivers don't support lanes reporting.

Agreed. But this patch will at least correct the overall speed reporting. So it's an improvement from the current behavior. If you still feel that this is not needed, you can drop the patch.

I'm ok with the implementation, just waiting to hear second opinion from Jason.

Thanks

#6 lore raw
Quoted 59 lines · Leon Romanovsky
Quoted 58 lines · Selvin Xavier
Quoted 57 lines · Leon Romanovsky
Quoted 54 lines · Selvin Xavier
Quoted 43 lines · Leon Romanovsky
Quoted 26 lines · Selvin Xavier

From: Kalesh AP <[email protected]>

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

---
v1 - v2:
- Rebased the patch based on the latest changes in ib_get_width_and_speed
- removed the switch case and use the existing else if check

---
 drivers/infiniband/core/verbs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +0 -0
index 25367bd..41ff559 100644
@@ -1899,9 +1899,18 @@ static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes,
              } else if (netdev_speed <= SPEED_40000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_FDR10;

drivers/infiniband/core/verbs.c static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, · line 1910

Quoted 10 lines
drivers/infiniband/core/verbs.c +7 -1
-             } else {
+             } else if (netdev_speed <= SPEED_50000) {
+                     *width = IB_WIDTH_2X;
+                     *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_100000) {
                      *width = IB_WIDTH_4X;
                      *speed = IB_SPEED_EDR;
+             } else if (netdev_speed <= SPEED_200000) {
+                     *width = IB_WIDTH_4X;
+                     *speed = IB_SPEED_HDR;

SPEED_50000, SPEED_100000 and SPEED_200000 depends on ClassPortInfo:CapabilityMask2.is* values.

Quoted 1 line

For example, SPEED_50000 can b IB_WIDTH_2X/IB_SPEED_EDR and IB_WIDTH_1X/IB_SPEED_HDR.

Agree with that.
This reporting can be achieved by the existing code, but the L2 driver needs to report non zero values for lanes in ethtool_ops->get_link_ksettings.
Caller of this modified function gets the speed and number of lanes from ethtool_ops->get_link_ksettings.

In this patch we are trying to handle the case where ethtool ops doesn't provide the lanes.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Almost all drivers don't support lanes reporting.

Agreed. But this patch will at least correct the overall speed reporting. So it's an improvement from the current behavior. If you still feel that this is not needed, you can drop the patch.

I'm ok with the implementation, just waiting to hear second opinion from Jason.

It seems fine, I think 4x is a reasonable place to default to.

Jason

#7 lore raw
In reply to Selvin Xavier
Quoted 8 lines · Selvin Xavier

When the Ethernet driver does not provide the number of lanes in the __ethtool_get_link_ksettings() response, the function ib_get_width_and_speed() does not take consideration of 50G, 100G and 200G speeds while calculating the IB width and speed. Update the width and speed for the above netdev speeds.

[...]

Applied, thanks!

[1/1] IB/core: Add more speed parsing in ib_get_width_and_speed()

      https://git.kernel.org/rdma/rdma/c/ca60fd116c7ee1

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>