linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn
@ 2022-01-06 18:03 yanjun.zhu
  2022-01-06 18:03 ` [PATCH v3 1/4] RDMA/core: Calculate UDP source port based on " yanjun.zhu
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: yanjun.zhu @ 2022-01-06 18:03 UTC (permalink / raw)
  To: jgg, mustafa.ismail, shiraz.saleem, zyjzyj2000, linux-rdma,
	yanjun.zhu, leonro

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

Follow the advice from Leon Romanovsky, rdma_get_udp_sport is moved to
ib_verbs.h. several drivers generate udp source port with this function.

---
v2->v3:Because in-subnet communications, GRH is optional. Without thei
       randomization for src_port done in rxe_qp_init_req, udp source
       port will be 0xC000 in that case.
v1->v2:Remove the local variables in commits "RDMA/irdma: Make the source
       udp port vary" and "RDMA/rxe: Use the standard method to produce
       udp source port". A new commit is added to remove the redundant
       randomization for UDP source port in RXE.
---



Zhu Yanjun (4):
  RDMA/core: Calculate UDP source port based on flow label or lqpn/rqpn
  RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport
  RDMA/irdma: Make the source udp port vary
  RDMA/rxe: Use the standard method to produce udp source port

 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 12 ++----------
 drivers/infiniband/hw/irdma/verbs.c        |  4 ++++
 drivers/infiniband/sw/rxe/rxe_verbs.c      |  6 ++++++
 include/rdma/ib_verbs.h                    | 17 +++++++++++++++++
 4 files changed, 29 insertions(+), 10 deletions(-)

-- 
2.27.0


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

* [PATCH v3 1/4] RDMA/core: Calculate UDP source port based on flow label or lqpn/rqpn
  2022-01-06 18:03 [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn yanjun.zhu
@ 2022-01-06 18:03 ` yanjun.zhu
  2022-01-06 18:03 ` [PATCH v3 2/4] RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport yanjun.zhu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: yanjun.zhu @ 2022-01-06 18:03 UTC (permalink / raw)
  To: jgg, mustafa.ismail, shiraz.saleem, zyjzyj2000, linux-rdma,
	yanjun.zhu, leonro

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

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.

Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
---
 include/rdma/ib_verbs.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6e9ad656ecb7..69d883f7fb41 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -4749,6 +4749,23 @@ 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);
+}
+
 const struct ib_port_immutable*
 ib_port_immutable_read(struct ib_device *dev, unsigned int port);
 #endif /* IB_VERBS_H */
-- 
2.27.0


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

* [PATCH v3 2/4] RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport
  2022-01-06 18:03 [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn yanjun.zhu
  2022-01-06 18:03 ` [PATCH v3 1/4] RDMA/core: Calculate UDP source port based on " yanjun.zhu
@ 2022-01-06 18:03 ` yanjun.zhu
  2022-01-07 10:03   ` Wenpeng Liang
  2022-01-06 18:03 ` [PATCH v3 3/4] RDMA/irdma: Make the source udp port vary yanjun.zhu
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: yanjun.zhu @ 2022-01-06 18:03 UTC (permalink / raw)
  To: jgg, mustafa.ismail, shiraz.saleem, zyjzyj2000, linux-rdma,
	yanjun.zhu, leonro

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

Several drivers have the same function xxx_get_udp_sport. So this
function is moved to ib_verbs.h.

Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index eb0defa80d0d..cb795663b813 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4488,14 +4488,6 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp,
 	return 0;
 }
 
-static inline u16 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 get_dip_ctx_idx(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
 			   u32 *dip_idx)
 {
@@ -4712,8 +4704,8 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,
 	}
 
 	hr_reg_write(context, QPC_UDPSPN,
-		     is_udp ? get_udp_sport(grh->flow_label, ibqp->qp_num,
-					    attr->dest_qp_num) : 0);
+		     is_udp ? rdma_get_udp_sport(grh->flow_label, ibqp->qp_num,
+						 attr->dest_qp_num) : 0);
 
 	hr_reg_clear(qpc_mask, QPC_UDPSPN);
 
-- 
2.27.0


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

* [PATCH v3 3/4] RDMA/irdma: Make the source udp port vary
  2022-01-06 18:03 [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn yanjun.zhu
  2022-01-06 18:03 ` [PATCH v3 1/4] RDMA/core: Calculate UDP source port based on " yanjun.zhu
  2022-01-06 18:03 ` [PATCH v3 2/4] RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport yanjun.zhu
@ 2022-01-06 18:03 ` yanjun.zhu
  2022-01-06 18:03 ` [PATCH v3 4/4] RDMA/rxe: Use the standard method to produce udp source port yanjun.zhu
  2022-01-07 23:39 ` [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn Jason Gunthorpe
  4 siblings, 0 replies; 7+ messages in thread
From: yanjun.zhu @ 2022-01-06 18:03 UTC (permalink / raw)
  To: jgg, mustafa.ismail, shiraz.saleem, zyjzyj2000, linux-rdma,
	yanjun.zhu, leonro

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

Get the source udp port number for a QP based on the grh.flow_label or
lqpn/rqrpn. This provides a better spread of traffic across NIC RX queues.

Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
 drivers/infiniband/hw/irdma/verbs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 8cd5f9261692..8234a101e752 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -1170,6 +1170,10 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 			udp_info->ttl = attr->ah_attr.grh.hop_limit;
 			udp_info->flow_label = attr->ah_attr.grh.flow_label;
 			udp_info->tos = attr->ah_attr.grh.traffic_class;
+			udp_info->src_port = rdma_get_udp_sport(
+						udp_info->flow_label,
+						ibqp->qp_num,
+						roce_info->dest_qp);
 			irdma_qp_rem_qos(&iwqp->sc_qp);
 			dev->ws_remove(iwqp->sc_qp.vsi, ctx_info->user_pri);
 			ctx_info->user_pri = rt_tos2priority(udp_info->tos);
-- 
2.27.0


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

* [PATCH v3 4/4] RDMA/rxe: Use the standard method to produce udp source port
  2022-01-06 18:03 [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn yanjun.zhu
                   ` (2 preceding siblings ...)
  2022-01-06 18:03 ` [PATCH v3 3/4] RDMA/irdma: Make the source udp port vary yanjun.zhu
@ 2022-01-06 18:03 ` yanjun.zhu
  2022-01-07 23:39 ` [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn Jason Gunthorpe
  4 siblings, 0 replies; 7+ messages in thread
From: yanjun.zhu @ 2022-01-06 18:03 UTC (permalink / raw)
  To: jgg, mustafa.ismail, shiraz.saleem, zyjzyj2000, linux-rdma,
	yanjun.zhu, leonro

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

Use the standard method to produce udp source port.

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

diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 0aa0d7e52773..42fa81b455de 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -469,6 +469,12 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	if (err)
 		goto err1;
 
+	if ((mask & IB_QP_AV) && (attr->ah_attr.ah_flags & IB_AH_GRH))
+		qp->src_port = rdma_get_udp_sport(attr->ah_attr.grh.flow_label,
+						  qp->ibqp.qp_num,
+						  qp->attr.dest_qp_num);
+
+
 	return 0;
 
 err1:
-- 
2.27.0


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

* Re: [PATCH v3 2/4] RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport
  2022-01-06 18:03 ` [PATCH v3 2/4] RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport yanjun.zhu
@ 2022-01-07 10:03   ` Wenpeng Liang
  0 siblings, 0 replies; 7+ messages in thread
From: Wenpeng Liang @ 2022-01-07 10:03 UTC (permalink / raw)
  To: yanjun.zhu, jgg, mustafa.ismail, shiraz.saleem, zyjzyj2000,
	linux-rdma, leonro

On 2022/1/7 2:03, yanjun.zhu@linux.dev wrote:
> From: Zhu Yanjun <yanjun.zhu@linux.dev>
> 
> Several drivers have the same function xxx_get_udp_sport. So this
> function is moved to ib_verbs.h.
> 
> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)

Thanks

Acked-by: Wenpeng Liang <liangwenpeng@huawei.com>

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

* Re: [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn
  2022-01-06 18:03 [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn yanjun.zhu
                   ` (3 preceding siblings ...)
  2022-01-06 18:03 ` [PATCH v3 4/4] RDMA/rxe: Use the standard method to produce udp source port yanjun.zhu
@ 2022-01-07 23:39 ` Jason Gunthorpe
  4 siblings, 0 replies; 7+ messages in thread
From: Jason Gunthorpe @ 2022-01-07 23:39 UTC (permalink / raw)
  To: yanjun.zhu; +Cc: mustafa.ismail, shiraz.saleem, zyjzyj2000, linux-rdma, leonro

On Thu, Jan 06, 2022 at 01:03:55PM -0500, yanjun.zhu@linux.dev wrote:
> From: Zhu Yanjun <yanjun.zhu@linux.dev>
> 
> Follow the advice from Leon Romanovsky, rdma_get_udp_sport is moved to
> ib_verbs.h. several drivers generate udp source port with this function.
> 
> ---
> v2->v3:Because in-subnet communications, GRH is optional. Without thei
>        randomization for src_port done in rxe_qp_init_req, udp source
>        port will be 0xC000 in that case.
> v1->v2:Remove the local variables in commits "RDMA/irdma: Make the source
>        udp port vary" and "RDMA/rxe: Use the standard method to produce
>        udp source port". A new commit is added to remove the redundant
>        randomization for UDP source port in RXE.
> ---
> 
> 
> 
> Zhu Yanjun (4):
>   RDMA/core: Calculate UDP source port based on flow label or lqpn/rqpn
>   RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport
>   RDMA/irdma: Make the source udp port vary
>   RDMA/rxe: Use the standard method to produce udp source port

Applied to for-next, thanks

Jason

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

end of thread, other threads:[~2022-01-07 23:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-06 18:03 [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn yanjun.zhu
2022-01-06 18:03 ` [PATCH v3 1/4] RDMA/core: Calculate UDP source port based on " yanjun.zhu
2022-01-06 18:03 ` [PATCH v3 2/4] RDMA/hns: Replace get_udp_sport with rdma_get_udp_sport yanjun.zhu
2022-01-07 10:03   ` Wenpeng Liang
2022-01-06 18:03 ` [PATCH v3 3/4] RDMA/irdma: Make the source udp port vary yanjun.zhu
2022-01-06 18:03 ` [PATCH v3 4/4] RDMA/rxe: Use the standard method to produce udp source port yanjun.zhu
2022-01-07 23:39 ` [PATCH v3 0/4] Generate UDP src port with flow label or lqpn/rqpn Jason Gunthorpe

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).