public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/core: Add more speed parsing in ib_get_eth_speed()
@ 2023-07-26  8:34 Selvin Xavier
  2023-07-26 13:07 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Selvin Xavier @ 2023-07-26  8:34 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, andrew.gospodarek, Kalesh AP, Selvin Xavier

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

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

The function ib_get_eth_speed() does not take consideration
of 50G, 56G, 100G and 200G speeds. Added these speeds parsing.
We are not considering the lane width now. This can be enhanced
later.

Also, refactored the code to use switch case instead of if-else.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
 drivers/infiniband/core/verbs.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index b99b3cc..ebd389a 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1908,22 +1908,44 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
 			netdev_speed);
 	}
 
-	if (netdev_speed <= SPEED_1000) {
+	switch (netdev_speed) {
+	case SPEED_1000:
 		*width = IB_WIDTH_1X;
 		*speed = IB_SPEED_SDR;
-	} else if (netdev_speed <= SPEED_10000) {
+		break;
+	case SPEED_10000:
 		*width = IB_WIDTH_1X;
 		*speed = IB_SPEED_FDR10;
-	} else if (netdev_speed <= SPEED_20000) {
+		break;
+	case SPEED_20000:
 		*width = IB_WIDTH_4X;
 		*speed = IB_SPEED_DDR;
-	} else if (netdev_speed <= SPEED_25000) {
+		break;
+	case SPEED_25000:
 		*width = IB_WIDTH_1X;
 		*speed = IB_SPEED_EDR;
-	} else if (netdev_speed <= SPEED_40000) {
+		break;
+	case SPEED_40000:
 		*width = IB_WIDTH_4X;
 		*speed = IB_SPEED_FDR10;
-	} else {
+		break;
+	case SPEED_50000:
+		*width = IB_WIDTH_2X;
+		*speed = IB_SPEED_EDR;
+		break;
+	case SPEED_56000:
+		*width = IB_WIDTH_4X;
+		*speed = IB_SPEED_FDR;
+		break;
+	case SPEED_100000:
+		*width = IB_WIDTH_4X;
+		*speed = IB_SPEED_EDR;
+		break;
+	case SPEED_200000:
+		*width = IB_WIDTH_4X;
+		*speed = IB_SPEED_HDR;
+		break;
+	default:
 		*width = IB_WIDTH_4X;
 		*speed = IB_SPEED_EDR;
 	}
-- 
2.5.5


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

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

end of thread, other threads:[~2023-07-26 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26  8:34 [PATCH] IB/core: Add more speed parsing in ib_get_eth_speed() Selvin Xavier
2023-07-26 13:07 ` Leon Romanovsky
2023-07-26 14:40   ` Selvin Xavier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox