Skip to contentSkip to conversation

RDMA/rxe: Add common rxe_prepare_res()

PATCH Superseded Xiao Yang 4 participants 6 messages Jul 5, 2022 – Jul 14, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/2 RDMA/rxe: Add common rxe_prepare_res()

Replace rxe_prepare_atomic_res() and rxe_prepare_read_res() with rxe_prepare_res().

---
 drivers/infiniband/sw/rxe/rxe_resp.c | 71 +++++++++++++---------------
 1 file changed, 32 insertions(+), 39 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +32 -39
index ccdfc1a6b659..5536582b8fe4 100644
@@ -553,27 +553,48 @@ static enum resp_states write_data_in(struct rxe_qp *qp,
 	return rc;
 }
 
-/* Guarantee atomicity of atomic operations at the machine level. */
-static DEFINE_SPINLOCK(atomic_ops_lock);
-
-static struct resp_res *rxe_prepare_atomic_res(struct rxe_qp *qp,
-					       struct rxe_pkt_info *pkt)
+static struct resp_res *rxe_prepare_res(struct rxe_qp *qp,
+					struct rxe_pkt_info *pkt,
+					int type)
 {
 	struct resp_res *res;
+	u32 pkts;
 
 	res = &qp->resp.resources[qp->resp.res_head];
 	rxe_advance_resp_resource(qp);
 	free_rd_atomic_resource(qp, res);
 
-	res->type = RXE_ATOMIC_MASK;
-	res->first_psn = pkt->psn;
-	res->last_psn = pkt->psn;
-	res->cur_psn = pkt->psn;
+	res->type = type;
 	res->replay = 0;
 
+	switch (type) {
+	case RXE_READ_MASK:
+		res->read.va = qp->resp.va + qp->resp.offset;
+		res->read.va_org = qp->resp.va + qp->resp.offset;
+		res->read.resid = qp->resp.resid;
+		res->read.length = qp->resp.resid;
+		res->read.rkey = qp->resp.rkey;
+
+		pkts = max_t(u32, (reth_len(pkt) + qp->mtu - 1)/qp->mtu, 1);
+		res->first_psn = pkt->psn;
+		res->cur_psn = pkt->psn;
+		res->last_psn = (pkt->psn + pkts - 1) & BTH_PSN_MASK;
+
+		res->state = rdatm_res_state_new;
+		break;
+	case RXE_ATOMIC_MASK:
+		res->first_psn = pkt->psn;
+		res->last_psn = pkt->psn;
+		res->cur_psn = pkt->psn;
+		break;
+	}
+
 	return res;
 }
 
+/* Guarantee atomicity of atomic operations at the machine level. */
+static DEFINE_SPINLOCK(atomic_ops_lock);
+
 static enum resp_states rxe_atomic_reply(struct rxe_qp *qp,
 					 struct rxe_pkt_info *pkt)
 {
@@ -584,7 +605,7 @@ static enum resp_states rxe_atomic_reply(struct rxe_qp *qp,
 	u64 value;
 
 	if (!res) {
-		res = rxe_prepare_atomic_res(qp, pkt);
+		res = rxe_prepare_res(qp, pkt, RXE_ATOMIC_MASK);
 		qp->resp.res = res;
 	}
 
@@ -680,34 +701,6 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp,
 	return skb;
 }
 
-static struct resp_res *rxe_prepare_read_res(struct rxe_qp *qp,
-					struct rxe_pkt_info *pkt)
-{
-	struct resp_res *res;
-	u32 pkts;
-
-	res = &qp->resp.resources[qp->resp.res_head];
-	rxe_advance_resp_resource(qp);
-	free_rd_atomic_resource(qp, res);
-
-	res->type = RXE_READ_MASK;
-	res->replay = 0;
-	res->read.va = qp->resp.va + qp->resp.offset;
-	res->read.va_org = qp->resp.va + qp->resp.offset;
-	res->read.resid = qp->resp.resid;
-	res->read.length = qp->resp.resid;
-	res->read.rkey = qp->resp.rkey;
-
-	pkts = max_t(u32, (reth_len(pkt) + qp->mtu - 1)/qp->mtu, 1);
-	res->first_psn = pkt->psn;
-	res->cur_psn = pkt->psn;
-	res->last_psn = (pkt->psn + pkts - 1) & BTH_PSN_MASK;
-
-	res->state = rdatm_res_state_new;
-
-	return res;
-}
-
 /**
  * rxe_recheck_mr - revalidate MR from rkey and get a reference
  * @qp: the qp
@@ -778,7 +771,7 @@ static enum resp_states read_reply(struct rxe_qp *qp,
 	struct rxe_mr *mr;
 
 	if (!res) {
-		res = rxe_prepare_read_res(qp, req_pkt);
+		res = rxe_prepare_res(qp, req_pkt, RXE_READ_MASK);
 		qp->resp.res = res;
 	}
 
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/2 RDMA/rxe: Rename rxe_atomic_reply to atomic_reply

It's better to use the unified naming format.

---
 drivers/infiniband/sw/rxe/rxe_resp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +2 -2
index 5536582b8fe4..265e46fe050f 100644
@@ -595,7 +595,7 @@ static struct resp_res *rxe_prepare_res(struct rxe_qp *qp,
 /* Guarantee atomicity of atomic operations at the machine level. */
 static DEFINE_SPINLOCK(atomic_ops_lock);
 
-static enum resp_states rxe_atomic_reply(struct rxe_qp *qp,
+static enum resp_states atomic_reply(struct rxe_qp *qp,
 					 struct rxe_pkt_info *pkt)
 {
 	u64 *vaddr;
@@ -1333,7 +1333,7 @@ int rxe_responder(void *arg)
 			state = read_reply(qp, pkt);
 			break;
 		case RESPST_ATOMIC_REPLY:
-			state = rxe_atomic_reply(qp, pkt);
+			state = atomic_reply(qp, pkt);
 			break;
 		case RESPST_ACKNOWLEDGE:
 			state = acknowledge(qp, pkt);
Signature · 1 line
2.34.1
#2 lore raw

RE: [PATCH 2/2] RDMA/rxe: Rename rxe_atomic_reply to atomic_reply

Generally over time I have been adding a rxe_ prefix to all searchable names static or non static. This avoids collisions with similar names in other drivers with e.g. ctags. I agree a unified naming Scheme is good but would like to see one with a common prefix for subroutine names.

Bob

-----Original Message-----
From: Xiao Yang <[email protected]>
Sent: Tuesday, July 5, 2022 6:46 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Xiao Yang <[email protected]>
Subject: [PATCH 2/2] RDMA/rxe: Rename rxe_atomic_reply to atomic_reply

It's better to use the unified naming format.

---
 drivers/infiniband/sw/rxe/rxe_resp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +2 -2
index 5536582b8fe4..265e46fe050f 100644
@@ -595,7 +595,7 @@ static struct resp_res *rxe_prepare_res(struct rxe_qp *qp,
 /* Guarantee atomicity of atomic operations at the machine level. */  static DEFINE_SPINLOCK(atomic_ops_lock);
 
-static enum resp_states rxe_atomic_reply(struct rxe_qp *qp,
+static enum resp_states atomic_reply(struct rxe_qp *qp,
 					 struct rxe_pkt_info *pkt)
 {
 	u64 *vaddr;
@@ -1333,7 +1333,7 @@ int rxe_responder(void *arg)
 			state = read_reply(qp, pkt);
 			break;
 		case RESPST_ATOMIC_REPLY:
-			state = rxe_atomic_reply(qp, pkt);
+			state = atomic_reply(qp, pkt);
 			break;
 		case RESPST_ACKNOWLEDGE:
 			state = acknowledge(qp, pkt);

--
2.34.1

#3 lore raw

Re: [PATCH 2/2] RDMA/rxe: Rename rxe_atomic_reply to atomic_reply

Quoted 3 lines · Robert B

Generally over time I have been adding a rxe_ prefix to all searchable names static or non static. This avoids collisions with similar names in other drivers with e.g. ctags. I agree a unified naming Scheme is good but would like to see one with a common prefix for subroutine names.

Hi Bob,

I think it's hard to use unique name in all drivers. I saw that all functions called by different qp states don't use the rxe_ prefix in rxe_responders so just remove the rxe_ prefix. We can drop the patch if you don't agree with this change.

Best Regards,
Xiao Yang

Quoted 43 lines

Bob

-----Original Message-----
From: Xiao Yang <[email protected]>
Sent: Tuesday, July 5, 2022 6:46 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Xiao Yang <[email protected]>
Subject: [PATCH 2/2] RDMA/rxe: Rename rxe_atomic_reply to atomic_reply

It's better to use the unified naming format.

---
  drivers/infiniband/sw/rxe/rxe_resp.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +2 -3
index 5536582b8fe4..265e46fe050f 100644
@@ -595,7 +595,7 @@ static struct resp_res *rxe_prepare_res(struct rxe_qp *qp,
  /* Guarantee atomicity of atomic operations at the machine level. */  static DEFINE_SPINLOCK(atomic_ops_lock);
 
-static enum resp_states rxe_atomic_reply(struct rxe_qp *qp,
+static enum resp_states atomic_reply(struct rxe_qp *qp,
  					 struct rxe_pkt_info *pkt)
  {
  	u64 *vaddr;
@@ -1333,7 +1333,7 @@ int rxe_responder(void *arg)
  			state = read_reply(qp, pkt);
  			break;
  		case RESPST_ATOMIC_REPLY:
-			state = rxe_atomic_reply(qp, pkt);
+			state = atomic_reply(qp, pkt);
  			break;
  		case RESPST_ACKNOWLEDGE:
  			state = acknowledge(qp, pkt);
--

2.34.1

#4 lore raw

Re: [PATCH 2/2] RDMA/rxe: Rename rxe_atomic_reply to atomic_reply

Quoted 6 lines · On 7/6/22 07:14, [email protected] wrote:
Quoted 3 lines · Robert B

Generally over time I have been adding a rxe_ prefix to all searchable names static or non static. This avoids collisions with similar names in other drivers with e.g. ctags. I agree a unified naming Scheme is good but would like to see one with a common prefix for subroutine names.

Hi Bob,

Quoted 7 lines

I think it's hard to use unique name in all drivers. I saw that all functions called by different qp states don't use the rxe_ prefix in rxe_responders so just remove the rxe_ prefix. We can drop the patch if you don't agree with this change.

Best Regards,
Xiao Yang

I fought on your side of this argument with Zhu a while back but now I am completely on his side. Linux has a lot of lines and generic subroutine names will very often collide all over the place. The better answer is to add rxe_ not remove it. It's not super critical so I have been doing it as a background task whenever I touch a piece of code. If you get the urge to make things more consistent feel free to do that but by adding a prefix and not deleting it.

Bob

#5 lore raw
In reply to Xiao Yang
Quoted 2 lines · Xiao Yang

Replace rxe_prepare_atomic_res() and rxe_prepare_read_res() with rxe_prepare_res().

Explain why we should do a change like this in the commit message please

Jason