aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2026-06-24 19:30:56 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2026-06-24 19:30:56 +0000
commitb6354f04081823cc0ccf2af573a59a826d7763c8 (patch)
tree70b6089f5ab53725719ba36ed3b123d63e88ef35
parent45c0d87c57298599397204179c2c4fa0f580a5d9 (diff)
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
-rw-r--r--sys/ofed/include/rdma/ib_verbs.h17
1 files changed, 17 insertions, 0 deletions
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 */