diff mbox series

[02/19] RDMA/siw: Introduce siw_srx_update_skb

Message ID 20231009071801.10210-3-guoqing.jiang@linux.dev (mailing list archive)
State Superseded
Headers show
Series Cleanup for siw | expand

Commit Message

Guoqing Jiang Oct. 9, 2023, 7:17 a.m. UTC
There are some places share the same logic, factor a common
helper for it.

Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/sw/siw/siw_qp_rx.c | 31 +++++++++++----------------
 1 file changed, 12 insertions(+), 19 deletions(-)

Comments

Bernard Metzler Oct. 25, 2023, 12:33 p.m. UTC | #1
> -----Original Message-----
> From: Guoqing Jiang <guoqing.jiang@linux.dev>
> Sent: Monday, October 9, 2023 9:18 AM
> To: Bernard Metzler <BMT@zurich.ibm.com>; jgg@ziepe.ca; leon@kernel.org
> Cc: linux-rdma@vger.kernel.org
> Subject: [EXTERNAL] [PATCH 02/19] RDMA/siw: Introduce siw_srx_update_skb
> 
> There are some places share the same logic, factor a common
> helper for it.
> 
> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
> ---
>  drivers/infiniband/sw/siw/siw_qp_rx.c | 31 +++++++++++----------------
>  1 file changed, 12 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
> b/drivers/infiniband/sw/siw/siw_qp_rx.c
> index 33e0fdb362ff..aa7b680452fb 100644
> --- a/drivers/infiniband/sw/siw/siw_qp_rx.c
> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
> @@ -881,6 +881,13 @@ int siw_proc_rresp(struct siw_qp *qp)
>  	return rv;
>  }
> 
> +static void siw_srx_update_skb(struct siw_rx_stream *srx, u16 length)
> +{
> +	srx->skb_offset += length;
> +	srx->skb_new -= length;
> +	srx->skb_copied += length;
> +}
> +

better call it siw_update_skb_rcvd()?
We are not updating the skb here, but our state
referencing an skb.

>  int siw_proc_terminate(struct siw_qp *qp)
>  {
>  	struct siw_rx_stream *srx = &qp->rx_stream;
> @@ -925,9 +932,7 @@ int siw_proc_terminate(struct siw_qp *qp)
>  		goto out;
> 
>  	infop += to_copy;
> -	srx->skb_offset += to_copy;
> -	srx->skb_new -= to_copy;
> -	srx->skb_copied += to_copy;
> +	siw_srx_update_skb(srx, to_copy);
>  	srx->fpdu_part_rcvd += to_copy;
>  	srx->fpdu_part_rem -= to_copy;
> 
> @@ -949,9 +954,7 @@ int siw_proc_terminate(struct siw_qp *qp)
>  			   term->flag_m ? "valid" : "invalid");
>  	}
>  out:
> -	srx->skb_new -= to_copy;
> -	srx->skb_offset += to_copy;
> -	srx->skb_copied += to_copy;
> +	siw_srx_update_skb(srx, to_copy);
>  	srx->fpdu_part_rcvd += to_copy;
>  	srx->fpdu_part_rem -= to_copy;
> 
> @@ -970,9 +973,7 @@ static int siw_get_trailer(struct siw_qp *qp, struct
> siw_rx_stream *srx)
> 
>  	skb_copy_bits(skb, srx->skb_offset, tbuf, avail);
> 
> -	srx->skb_new -= avail;
> -	srx->skb_offset += avail;
> -	srx->skb_copied += avail;
> +	siw_srx_update_skb(srx, avail);
>  	srx->fpdu_part_rem -= avail;
> 
>  	if (srx->fpdu_part_rem)
> @@ -1023,12 +1024,8 @@ static int siw_get_hdr(struct siw_rx_stream *srx)
>  		skb_copy_bits(skb, srx->skb_offset,
>  			      (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
> 
> +		siw_srx_update_skb(srx, bytes);
>  		srx->fpdu_part_rcvd += bytes;
> -
> -		srx->skb_new -= bytes;
> -		srx->skb_offset += bytes;
> -		srx->skb_copied += bytes;
> -
>  		if (srx->fpdu_part_rcvd < MIN_DDP_HDR)
>  			return -EAGAIN;
> 
> @@ -1091,12 +1088,8 @@ static int siw_get_hdr(struct siw_rx_stream *srx)
>  		skb_copy_bits(skb, srx->skb_offset,
>  			      (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
> 
> +		siw_srx_update_skb(srx, bytes);
>  		srx->fpdu_part_rcvd += bytes;
> -
> -		srx->skb_new -= bytes;
> -		srx->skb_offset += bytes;
> -		srx->skb_copied += bytes;
> -
>  		if (srx->fpdu_part_rcvd < hdrlen)
>  			return -EAGAIN;
>  	}
> --
> 2.35.3
Guoqing Jiang Oct. 26, 2023, 6:37 a.m. UTC | #2
On 10/25/23 20:33, Bernard Metzler wrote:
>> -----Original Message-----
>> From: Guoqing Jiang<guoqing.jiang@linux.dev>
>> Sent: Monday, October 9, 2023 9:18 AM
>> To: Bernard Metzler<BMT@zurich.ibm.com>;jgg@ziepe.ca;leon@kernel.org
>> Cc:linux-rdma@vger.kernel.org
>> Subject: [EXTERNAL] [PATCH 02/19] RDMA/siw: Introduce siw_srx_update_skb
>>
>> There are some places share the same logic, factor a common
>> helper for it.
>>
>> Signed-off-by: Guoqing Jiang<guoqing.jiang@linux.dev>
>> ---
>>   drivers/infiniband/sw/siw/siw_qp_rx.c | 31 +++++++++++----------------
>>   1 file changed, 12 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
>> b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> index 33e0fdb362ff..aa7b680452fb 100644
>> --- a/drivers/infiniband/sw/siw/siw_qp_rx.c
>> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> @@ -881,6 +881,13 @@ int siw_proc_rresp(struct siw_qp *qp)
>>   	return rv;
>>   }
>>
>> +static void siw_srx_update_skb(struct siw_rx_stream *srx, u16 length)
>> +{
>> +	srx->skb_offset += length;
>> +	srx->skb_new -= length;
>> +	srx->skb_copied += length;
>> +}
>> +
> better call it siw_update_skb_rcvd()?
> We are not updating the skb here, but our state
> referencing an skb.

Sure, thanks for the naming!

Thanks,
Guoqing
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
index 33e0fdb362ff..aa7b680452fb 100644
--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
@@ -881,6 +881,13 @@  int siw_proc_rresp(struct siw_qp *qp)
 	return rv;
 }
 
+static void siw_srx_update_skb(struct siw_rx_stream *srx, u16 length)
+{
+	srx->skb_offset += length;
+	srx->skb_new -= length;
+	srx->skb_copied += length;
+}
+
 int siw_proc_terminate(struct siw_qp *qp)
 {
 	struct siw_rx_stream *srx = &qp->rx_stream;
@@ -925,9 +932,7 @@  int siw_proc_terminate(struct siw_qp *qp)
 		goto out;
 
 	infop += to_copy;
-	srx->skb_offset += to_copy;
-	srx->skb_new -= to_copy;
-	srx->skb_copied += to_copy;
+	siw_srx_update_skb(srx, to_copy);
 	srx->fpdu_part_rcvd += to_copy;
 	srx->fpdu_part_rem -= to_copy;
 
@@ -949,9 +954,7 @@  int siw_proc_terminate(struct siw_qp *qp)
 			   term->flag_m ? "valid" : "invalid");
 	}
 out:
-	srx->skb_new -= to_copy;
-	srx->skb_offset += to_copy;
-	srx->skb_copied += to_copy;
+	siw_srx_update_skb(srx, to_copy);
 	srx->fpdu_part_rcvd += to_copy;
 	srx->fpdu_part_rem -= to_copy;
 
@@ -970,9 +973,7 @@  static int siw_get_trailer(struct siw_qp *qp, struct siw_rx_stream *srx)
 
 	skb_copy_bits(skb, srx->skb_offset, tbuf, avail);
 
-	srx->skb_new -= avail;
-	srx->skb_offset += avail;
-	srx->skb_copied += avail;
+	siw_srx_update_skb(srx, avail);
 	srx->fpdu_part_rem -= avail;
 
 	if (srx->fpdu_part_rem)
@@ -1023,12 +1024,8 @@  static int siw_get_hdr(struct siw_rx_stream *srx)
 		skb_copy_bits(skb, srx->skb_offset,
 			      (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
 
+		siw_srx_update_skb(srx, bytes);
 		srx->fpdu_part_rcvd += bytes;
-
-		srx->skb_new -= bytes;
-		srx->skb_offset += bytes;
-		srx->skb_copied += bytes;
-
 		if (srx->fpdu_part_rcvd < MIN_DDP_HDR)
 			return -EAGAIN;
 
@@ -1091,12 +1088,8 @@  static int siw_get_hdr(struct siw_rx_stream *srx)
 		skb_copy_bits(skb, srx->skb_offset,
 			      (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
 
+		siw_srx_update_skb(srx, bytes);
 		srx->fpdu_part_rcvd += bytes;
-
-		srx->skb_new -= bytes;
-		srx->skb_offset += bytes;
-		srx->skb_copied += bytes;
-
 		if (srx->fpdu_part_rcvd < hdrlen)
 			return -EAGAIN;
 	}