git: 5963423232e8 - main - libibverbs: Extend support of NDR rates

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 15 Mar 2025 04:45:04 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=5963423232e869b8dbe8e9a65134e92735dfb521

commit 5963423232e869b8dbe8e9a65134e92735dfb521
Author:     Slava Shwartsman <slavash@nvidia.com>
AuthorDate: 2025-03-12 08:49:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-03-15 04:44:07 +0000

    libibverbs: Extend support of NDR rates
    
    NDR(106.25 Gbps) support exposed new data rates:
    800 Gbps - NDR 8x.
    1200 Gbps - NDR 12x.
    
    Utility methods were updated to support the new rates mentioned above:
    1) Rate to mult - Convert the IB rate enum to a multiple of 2.5 Gbps.
    2) Rate to mbps - Convert IB rate enum to the mbps value.
    
    In addition, speed_str() of ibv_devinfo was updated to consider the new
    NDR rate.
    
    Reference:      IB Spec Release 1.5
    PR:             285305
    MFC after:      1 week
    Sponsored by:   NVidia networking
    
    Change-Id: I77541e406f700585fbfeddc162d5a0e7b79a1c11
    Signed-off-by: Slava Shwartsman <slavash@nvidia.com>
---
 contrib/ofed/libibverbs/examples/devinfo.c | 1 +
 contrib/ofed/libibverbs/verbs.c            | 8 ++++++++
 contrib/ofed/libibverbs/verbs.h            | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/contrib/ofed/libibverbs/examples/devinfo.c b/contrib/ofed/libibverbs/examples/devinfo.c
index 7693cb30739d..866d82718f7d 100644
--- a/contrib/ofed/libibverbs/examples/devinfo.c
+++ b/contrib/ofed/libibverbs/examples/devinfo.c
@@ -145,6 +145,7 @@ static const char *speed_str(uint8_t speed)
 	case 16: return "14.0 Gbps";
 	case 32: return "25.0 Gbps";
 	case 64: return "50.0 Gbps";
+	case 128: return "100.0 Gbps";
 	default: return "invalid speed";
 	}
 }
diff --git a/contrib/ofed/libibverbs/verbs.c b/contrib/ofed/libibverbs/verbs.c
index 5c23406e69e7..c24a29926c22 100644
--- a/contrib/ofed/libibverbs/verbs.c
+++ b/contrib/ofed/libibverbs/verbs.c
@@ -115,6 +115,8 @@ int __attribute__((const)) ibv_rate_to_mult(enum ibv_rate rate)
 	case IBV_RATE_50_GBPS:  return 20;
 	case IBV_RATE_400_GBPS: return 160;
 	case IBV_RATE_600_GBPS: return 240;
+	case IBV_RATE_800_GBPS: return 320;
+	case IBV_RATE_1200_GBPS: return 480;
 	default:           return -1;
 	}
 }
@@ -135,6 +137,8 @@ enum ibv_rate __attribute__((const)) mult_to_ibv_rate(int mult)
 	case 20: return IBV_RATE_50_GBPS;
 	case 160: return IBV_RATE_400_GBPS;
 	case 240: return IBV_RATE_600_GBPS;
+	case 320: return IBV_RATE_800_GBPS;
+	case 480: return IBV_RATE_1200_GBPS;
 	default: return IBV_RATE_MAX;
 	}
 }
@@ -163,6 +167,8 @@ int  __attribute__((const)) ibv_rate_to_mbps(enum ibv_rate rate)
 	case IBV_RATE_50_GBPS:  return 53125;
 	case IBV_RATE_400_GBPS: return 425000;
 	case IBV_RATE_600_GBPS: return 637500;
+	case IBV_RATE_800_GBPS: return 850000;
+	case IBV_RATE_1200_GBPS: return 1275000;
 	default:               return -1;
 	}
 }
@@ -191,6 +197,8 @@ enum ibv_rate __attribute__((const)) mbps_to_ibv_rate(int mbps)
 	case 53125:  return IBV_RATE_50_GBPS;
 	case 425000: return IBV_RATE_400_GBPS;
 	case 637500: return IBV_RATE_600_GBPS;
+	case 850000: return IBV_RATE_800_GBPS;
+	case 1275000: return IBV_RATE_1200_GBPS;
 	default:     return IBV_RATE_MAX;
 	}
 }
diff --git a/contrib/ofed/libibverbs/verbs.h b/contrib/ofed/libibverbs/verbs.h
index bea817e36fc9..63a9ddbb1538 100644
--- a/contrib/ofed/libibverbs/verbs.h
+++ b/contrib/ofed/libibverbs/verbs.h
@@ -595,6 +595,8 @@ enum ibv_rate {
 	IBV_RATE_50_GBPS  = 20,
 	IBV_RATE_400_GBPS = 21,
 	IBV_RATE_600_GBPS = 22,
+	IBV_RATE_800_GBPS = 23,
+	IBV_RATE_1200_GBPS = 24,
 };
 
 /**