git: b6354f040818 - main - OFED: Calculate UDP source port based on flow label or lqpn/rqpn
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Jun 2026 19:51:23 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=b6354f04081823cc0ccf2af573a59a826d7763c8
commit b6354f04081823cc0ccf2af573a59a826d7763c8
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-06-24 19:30:56 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-06-24 19:30:56 +0000
OFED: Calculate UDP source port based on flow label or lqpn/rqpn
Calculate and set UDP source port based on the flow label. If flow label
is not defined in GRH then calculate it based on lqpn/rqpn.
Tested by: Wafa Hamzah <wafah@nvidia.com> (mlx5_ib)
Tested by: John Baldwin <jhb@FreeBSD.org> (iw_cxgbe)
Obtained from: Linux commit 18451db82ef7f943c60a7fce685f16172bda5106
Sponsored by: Chelsio Communications
---
sys/ofed/include/rdma/ib_verbs.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/sys/ofed/include/rdma/ib_verbs.h b/sys/ofed/include/rdma/ib_verbs.h
index 38e6858e767f..8ac13023020b 100644
--- a/sys/ofed/include/rdma/ib_verbs.h
+++ b/sys/ofed/include/rdma/ib_verbs.h
@@ -4223,4 +4223,21 @@ static inline u32 rdma_calc_flow_label(u32 lqpn, u32 rqpn)
return (u32)(v & IB_GRH_FLOWLABEL_MASK);
}
+
+/**
+ * rdma_get_udp_sport - Calculate and set UDP source port based on the flow
+ * label. If flow label is not defined in GRH then
+ * calculate it based on lqpn/rqpn.
+ *
+ * @fl: flow label from GRH
+ * @lqpn: local qp number
+ * @rqpn: remote qp number
+ */
+static inline u16 rdma_get_udp_sport(u32 fl, u32 lqpn, u32 rqpn)
+{
+ if (!fl)
+ fl = rdma_calc_flow_label(lqpn, rqpn);
+
+ return rdma_flow_label_to_udp_sport(fl);
+}
#endif /* IB_VERBS_H */