summaryrefslogtreecommitdiff
path: root/include/rdma
diff options
context:
space:
mode:
authorOr Har-Toov <ohartoov@nvidia.com>2025-12-18 17:58:32 +0200
committerLeon Romanovsky <leon@kernel.org>2026-01-05 02:42:53 -0500
commit2941abac6d0bffd6bf8f438135505b39168a0a08 (patch)
treed64e679beca447cf6f4b648cf0109042ab45fb74 /include/rdma
parent263d1d9975b5ac2b813c3107fe21c957b57f0a59 (diff)
downloadlinux-2941abac6d0bffd6bf8f438135505b39168a0a08.tar.gz
linux-2941abac6d0bffd6bf8f438135505b39168a0a08.tar.bz2
linux-2941abac6d0bffd6bf8f438135505b39168a0a08.zip
IB/core: Add helper to convert port attributes to data rate
Introduce ib_port_attr_to_rate() to compute the data rate in 100 Mbps units (deci-Gb/sec) from a port's active_speed and active_width attributes. This generic helper removes duplicated speed-to-rate calculations, which are used by sysfs and the upcoming new verb. Signed-off-by: Or Har-Toov <ohartoov@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Signed-off-by: Edward Srouji <edwards@nvidia.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_verbs.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 95f1e557cbb8..b984f9581a73 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -878,6 +878,20 @@ __attribute_const__ int ib_rate_to_mult(enum ib_rate rate);
*/
__attribute_const__ int ib_rate_to_mbps(enum ib_rate rate);
+struct ib_port_speed_info {
+ const char *str;
+ int rate; /* in deci-Gb/sec (100 MBps units) */
+};
+
+/**
+ * ib_port_attr_to_speed_info - Convert port attributes to speed information
+ * @attr: Port attributes containing active_speed and active_width
+ * @speed_info: Speed information to return
+ *
+ * Returns 0 on success, -EINVAL on error.
+ */
+int ib_port_attr_to_speed_info(struct ib_port_attr *attr,
+ struct ib_port_speed_info *speed_info);
/**
* enum ib_mr_type - memory region type