Skip to content

Commit 2b880b2

Browse files
Mark Zhangjgunthorpe
authored andcommitted
RDMA/mlx5: Define RoCEv2 udp source port when set path
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: Mark Zhang <[email protected]> Reviewed-by: Maor Gottlieb <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 9611d53 commit 2b880b2

File tree

1 file changed

+24
-6
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+24
-6
lines changed

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,6 +3133,21 @@ static int modify_raw_packet_tx_affinity(struct mlx5_core_dev *dev,
31333133
return err;
31343134
}
31353135

3136+
static void mlx5_set_path_udp_sport(struct mlx5_qp_path *path,
3137+
const struct rdma_ah_attr *ah,
3138+
u32 lqpn, u32 rqpn)
3139+
3140+
{
3141+
u32 fl = ah->grh.flow_label;
3142+
u16 sport;
3143+
3144+
if (!fl)
3145+
fl = rdma_calc_flow_label(lqpn, rqpn);
3146+
3147+
sport = rdma_flow_label_to_udp_sport(fl);
3148+
path->udp_sport = cpu_to_be16(sport);
3149+
}
3150+
31363151
static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
31373152
const struct rdma_ah_attr *ah,
31383153
struct mlx5_qp_path *path, u8 port, int attr_mask,
@@ -3164,12 +3179,15 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
31643179
return -EINVAL;
31653180

31663181
memcpy(path->rmac, ah->roce.dmac, sizeof(ah->roce.dmac));
3167-
if (qp->ibqp.qp_type == IB_QPT_RC ||
3168-
qp->ibqp.qp_type == IB_QPT_UC ||
3169-
qp->ibqp.qp_type == IB_QPT_XRC_INI ||
3170-
qp->ibqp.qp_type == IB_QPT_XRC_TGT)
3171-
path->udp_sport =
3172-
mlx5_get_roce_udp_sport(dev, ah->grh.sgid_attr);
3182+
if ((qp->ibqp.qp_type == IB_QPT_RC ||
3183+
qp->ibqp.qp_type == IB_QPT_UC ||
3184+
qp->ibqp.qp_type == IB_QPT_XRC_INI ||
3185+
qp->ibqp.qp_type == IB_QPT_XRC_TGT) &&
3186+
(grh->sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) &&
3187+
(attr_mask & IB_QP_DEST_QPN))
3188+
mlx5_set_path_udp_sport(path, ah,
3189+
qp->ibqp.qp_num,
3190+
attr->dest_qp_num);
31733191
path->dci_cfi_prio_sl = (sl & 0x7) << 4;
31743192
gid_type = ah->grh.sgid_attr->gid_type;
31753193
if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP)

0 commit comments

Comments
 (0)