[PATCH] IB/core: Add more speed parsing in ib_get_eth_speed()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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@xxxxxxxxxxxx>
Signed-off-by: Selvin Xavier <selvin.xavier@xxxxxxxxxxxx>
---
 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: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux