public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bob Pearson <rpearsonhpe@gmail.com>
To: jgg@nvidia.com, zyjzyj2000@gmail.com, linux-rdma@vger.kernel.org
Cc: Bob Pearson <rpearsonhpe@gmail.com>
Subject: [PATCH 4/5] RDMA/rxe: Move rxe_crc32 to a subroutine
Date: Tue, 29 Jun 2021 15:14:09 -0500	[thread overview]
Message-ID: <20210629201412.28306-5-rpearsonhpe@gmail.com> (raw)
In-Reply-To: <20210629201412.28306-1-rpearsonhpe@gmail.com>

Move rxe_crc32 from rxe.h to rxe_icrc.c as a static local function.
Add some comments to rxe_icrc.c

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe.h      | 21 ------------
 drivers/infiniband/sw/rxe/rxe_icrc.c | 50 +++++++++++++++++++++++++---
 drivers/infiniband/sw/rxe/rxe_loc.h  |  1 -
 3 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe.h b/drivers/infiniband/sw/rxe/rxe.h
index 623fd17df02d..65a73c1c8b35 100644
--- a/drivers/infiniband/sw/rxe/rxe.h
+++ b/drivers/infiniband/sw/rxe/rxe.h
@@ -42,27 +42,6 @@
 
 extern bool rxe_initialized;
 
-static inline u32 rxe_crc32(struct rxe_dev *rxe,
-			    u32 crc, void *next, size_t len)
-{
-	u32 retval;
-	int err;
-
-	SHASH_DESC_ON_STACK(shash, rxe->tfm);
-
-	shash->tfm = rxe->tfm;
-	*(u32 *)shash_desc_ctx(shash) = crc;
-	err = crypto_shash_update(shash, next, len);
-	if (unlikely(err)) {
-		pr_warn_ratelimited("failed crc calculation, err: %d\n", err);
-		return crc32_le(crc, next, len);
-	}
-
-	retval = *(u32 *)shash_desc_ctx(shash);
-	barrier_data(shash_desc_ctx(shash));
-	return retval;
-}
-
 void rxe_set_mtu(struct rxe_dev *rxe, unsigned int dev_mtu);
 
 int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name);
diff --git a/drivers/infiniband/sw/rxe/rxe_icrc.c b/drivers/infiniband/sw/rxe/rxe_icrc.c
index 5424b8bea908..e116c63d7b84 100644
--- a/drivers/infiniband/sw/rxe/rxe_icrc.c
+++ b/drivers/infiniband/sw/rxe/rxe_icrc.c
@@ -7,8 +7,44 @@
 #include "rxe.h"
 #include "rxe_loc.h"
 
-/* Compute a partial ICRC for all the IB transport headers. */
-u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
+/**
+ * rxe_crc32 - Compute incremental crc32 for a contiguous segment
+ * @rxe: rdma_rxe device object
+ * @crc: starting crc32 value from previous segments
+ * @addr: starting address of segment
+ * @len: length of the segment in bytes
+ *
+ * Returns the crc32 checksum of the segment starting from crc.
+ */
+static u32 rxe_crc32(struct rxe_dev *rxe, u32 crc, void *addr, size_t len)
+{
+	u32 icrc;
+	int err;
+
+	SHASH_DESC_ON_STACK(shash, rxe->tfm);
+
+	shash->tfm = rxe->tfm;
+	*(u32 *)shash_desc_ctx(shash) = crc;
+	err = crypto_shash_update(shash, addr, len);
+	if (unlikely(err)) {
+		pr_warn_ratelimited("failed crc calculation, err: %d\n", err);
+		return crc32_le(crc, addr, len);
+	}
+
+	icrc = *(u32 *)shash_desc_ctx(shash);
+	barrier_data(shash_desc_ctx(shash));
+
+	return icrc;
+}
+
+/**
+ * rxe_icrc_hdr - Compute a partial ICRC for the IB transport headers.
+ * @pkt: Information about the current packet
+ * @skb: The packet buffer
+ *
+ * Returns the partial ICRC
+ */
+static u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
 {
 	unsigned int bth_offset = 0;
 	struct iphdr *ip4h = NULL;
@@ -71,9 +107,9 @@ u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
 /**
  * rxe_icrc_check - Compute ICRC for a packet and compare to the ICRC
  *		    delivered in the packet.
- * @skb: The packet buffer with packet info in skb->cb[] (receive path)
+ * @skb: packet buffer with packet info in skb->cb[] (receive path)
  *
- * Returns 0 on success or an error on failure
+ * Returns 0 if the ICRCs match or an error on failure
  */
 int rxe_icrc_check(struct sk_buff *skb)
 {
@@ -106,7 +142,11 @@ int rxe_icrc_check(struct sk_buff *skb)
 	return 0;
 }
 
-/* rxe_icrc_generate- compute ICRC for a packet. */
+/**
+ * rxe_icrc_generate - Compute ICRC for a packet.
+ * @pkt: packet information
+ * @skb: packet buffer
+ */
 void rxe_icrc_generate(struct rxe_pkt_info *pkt, struct sk_buff *skb)
 {
 	__be32 *icrcp;
diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h
index 2c724b9970d6..b08689b664ec 100644
--- a/drivers/infiniband/sw/rxe/rxe_loc.h
+++ b/drivers/infiniband/sw/rxe/rxe_loc.h
@@ -193,7 +193,6 @@ int rxe_requester(void *arg);
 int rxe_responder(void *arg);
 
 /* rxe_icrc.c */
-u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb);
 int rxe_icrc_check(struct sk_buff *skb);
 void rxe_icrc_generate(struct rxe_pkt_info *pkt, struct sk_buff *skb);
 
-- 
2.30.2


  parent reply	other threads:[~2021-06-29 20:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29 20:14 [PATCH 0/7] RDMA/rxe: Cleanup ICRC Bob Pearson
2021-06-29 20:14 ` [PATCH 1/5] RDMA/rxe: Move ICRC checking to a subroutine Bob Pearson
2021-06-29 20:14 ` [PATCH 2/5] RDMA/rxe: Move rxe_xmit_packet " Bob Pearson
2021-06-29 20:14 ` [PATCH 3/5] RDMA/rxe: Move ICRC generation " Bob Pearson
2021-06-29 20:14 ` Bob Pearson [this message]
2021-06-29 20:14 ` [PATCH 5/5] RDMA/rxe: Move crc32 init code to rxe_icrc.c Bob Pearson
2021-06-30  4:09   ` Zhu Yanjun
2021-06-30  4:13     ` Pearson, Robert B
2021-07-01  3:38   ` kernel test robot
2021-06-29 20:14 ` [PATCH 6/7] RDMA/rxe: Add parameters to control checking/generating ICRC Bob Pearson
2021-06-29 20:14 ` [PATCH 7/7] RDMA/rxe: Extend ICRC to support nonlinear skbs Bob Pearson
2021-06-29 20:16   ` Bob Pearson
2021-06-29 20:17   ` Bob Pearson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210629201412.28306-5-rpearsonhpe@gmail.com \
    --to=rpearsonhpe@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=zyjzyj2000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox