linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] RDMA/rxe: Use the standard method to produce udp source port
@ 2021-12-24 17:27 yanjun.zhu
  2022-01-03 11:20 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: yanjun.zhu @ 2021-12-24 17:27 UTC (permalink / raw)
  To: jgg, linux-rdma, yanjun.zhu, leon

From: Zhu Yanjun <yanjun.zhu@linux.dev>

Use the standard method to produce udp source port based on the
commit 2b880b2e5e03 ("RDMA/mlx5: Define RoCEv2 udp source port
when set path").

Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
 drivers/infiniband/sw/rxe/rxe_verbs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 0aa0d7e52773..9a0748ad6417 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -451,6 +451,14 @@ static int rxe_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init,
 	return err;
 }
 
+static u16 rxe_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);
+}
+
 static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 			 int mask, struct ib_udata *udata)
 {
@@ -469,6 +477,16 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	if (err)
 		goto err1;
 
+	if (mask & IB_QP_AV) {
+		if (attr->ah_attr.ah_flags & IB_AH_GRH) {
+			u32 fl = attr->ah_attr.grh.flow_label;
+			u32 lqp = qp->ibqp.qp_num;
+			u32 rqp = qp->attr.dest_qp_num;
+
+			qp->src_port = rxe_get_udp_sport(fl, lqp, rqp);
+		}
+	}
+
 	return 0;
 
 err1:
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] RDMA/rxe: Use the standard method to produce udp source port
  2021-12-24 17:27 [PATCH 1/1] RDMA/rxe: Use the standard method to produce udp source port yanjun.zhu
@ 2022-01-03 11:20 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2022-01-03 11:20 UTC (permalink / raw)
  To: yanjun.zhu; +Cc: jgg, linux-rdma

On Fri, Dec 24, 2021 at 12:27:35PM -0500, yanjun.zhu@linux.dev wrote:
> From: Zhu Yanjun <yanjun.zhu@linux.dev>
> 
> Use the standard method to produce udp source port based on the
> commit 2b880b2e5e03 ("RDMA/mlx5: Define RoCEv2 udp source port
> when set path").
> 
> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
> ---
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
> index 0aa0d7e52773..9a0748ad6417 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.c
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
> @@ -451,6 +451,14 @@ static int rxe_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init,
>  	return err;
>  }
>  
> +static u16 rxe_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);
> +}
> +

Now, we have three drivers with the same function.

>  static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>  			 int mask, struct ib_udata *udata)
>  {
> @@ -469,6 +477,16 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
>  	if (err)
>  		goto err1;
>  
> +	if (mask & IB_QP_AV) {
> +		if (attr->ah_attr.ah_flags & IB_AH_GRH) {
> +			u32 fl = attr->ah_attr.grh.flow_label;
> +			u32 lqp = qp->ibqp.qp_num;
> +			u32 rqp = qp->attr.dest_qp_num;
> +
> +			qp->src_port = rxe_get_udp_sport(fl, lqp, rqp);
> +		}
> +	}
> +
>  	return 0;
>  
>  err1:
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-03 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24 17:27 [PATCH 1/1] RDMA/rxe: Use the standard method to produce udp source port yanjun.zhu
2022-01-03 11:20 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).