Skip to content

Commit 18451db

Browse files
zhuyjjgunthorpe
authored andcommitted
RDMA/core: 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. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Zhu Yanjun <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 4d2a3c1 commit 18451db

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

include/rdma/ib_verbs.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,6 +4749,23 @@ static inline u32 rdma_calc_flow_label(u32 lqpn, u32 rqpn)
47494749
return (u32)(v & IB_GRH_FLOWLABEL_MASK);
47504750
}
47514751

4752+
/**
4753+
* rdma_get_udp_sport - Calculate and set UDP source port based on the flow
4754+
* label. If flow label is not defined in GRH then
4755+
* calculate it based on lqpn/rqpn.
4756+
*
4757+
* @fl: flow label from GRH
4758+
* @lqpn: local qp number
4759+
* @rqpn: remote qp number
4760+
*/
4761+
static inline u16 rdma_get_udp_sport(u32 fl, u32 lqpn, u32 rqpn)
4762+
{
4763+
if (!fl)
4764+
fl = rdma_calc_flow_label(lqpn, rqpn);
4765+
4766+
return rdma_flow_label_to_udp_sport(fl);
4767+
}
4768+
47524769
const struct ib_port_immutable*
47534770
ib_port_immutable_read(struct ib_device *dev, unsigned int port);
47544771
#endif /* IB_VERBS_H */

0 commit comments

Comments
 (0)