linux-rdma.vger.kernel.org archive mirror
 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 v2 7/9] RDMA/rxe: Move crc32 init code to rxe_icrc.c
Date: Tue,  6 Jul 2021 23:00:39 -0500	[thread overview]
Message-ID: <20210707040040.15434-8-rpearsonhpe@gmail.com> (raw)
In-Reply-To: <20210707040040.15434-1-rpearsonhpe@gmail.com>

This patch collects the code from rxe_register_device() that sets
up the crc32 calculation into a subroutine rxe_icrc_init() in
rxe_icrc.c.

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe.h       |  1 -
 drivers/infiniband/sw/rxe/rxe_icrc.c  | 18 ++++++++++++++++++
 drivers/infiniband/sw/rxe/rxe_loc.h   |  1 +
 drivers/infiniband/sw/rxe/rxe_verbs.c | 11 +++--------
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe.h b/drivers/infiniband/sw/rxe/rxe.h
index 65a73c1c8b35..1bb3fb618bf5 100644
--- a/drivers/infiniband/sw/rxe/rxe.h
+++ b/drivers/infiniband/sw/rxe/rxe.h
@@ -14,7 +14,6 @@
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
-#include <linux/crc32.h>
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_user_verbs.h>
diff --git a/drivers/infiniband/sw/rxe/rxe_icrc.c b/drivers/infiniband/sw/rxe/rxe_icrc.c
index 777199517e9a..62bcdfc8e96a 100644
--- a/drivers/infiniband/sw/rxe/rxe_icrc.c
+++ b/drivers/infiniband/sw/rxe/rxe_icrc.c
@@ -4,9 +4,27 @@
  * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
  */
 
+#include <linux/crc32.h>
+
 #include "rxe.h"
 #include "rxe_loc.h"
 
+int rxe_icrc_init(struct rxe_dev *rxe)
+{
+	struct crypto_shash *tfm;
+
+	tfm = crypto_alloc_shash("crc32", 0, 0);
+	if (IS_ERR(tfm)) {
+		pr_warn("failed to init crc32 algorithm err:%ld\n",
+			       PTR_ERR(tfm));
+		return PTR_ERR(tfm);
+	}
+
+	rxe->tfm = tfm;
+
+	return 0;
+}
+
 static u32 rxe_crc32(struct rxe_dev *rxe, u32 crc, void *next, size_t len)
 {
 	u32 icrc;
diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h
index 73a2c48a3160..f0c954575bde 100644
--- a/drivers/infiniband/sw/rxe/rxe_loc.h
+++ b/drivers/infiniband/sw/rxe/rxe_loc.h
@@ -193,6 +193,7 @@ int rxe_requester(void *arg);
 int rxe_responder(void *arg);
 
 /* rxe_icrc.c */
+int rxe_icrc_init(struct rxe_dev *rxe);
 int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt);
 void rxe_icrc_generate(struct sk_buff *skb, struct rxe_pkt_info *pkt);
 
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index c223959ac174..f7b1a1f64c13 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -1154,7 +1154,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
 {
 	int err;
 	struct ib_device *dev = &rxe->ib_dev;
-	struct crypto_shash *tfm;
 
 	strscpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
 
@@ -1173,13 +1172,9 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
 	if (err)
 		return err;
 
-	tfm = crypto_alloc_shash("crc32", 0, 0);
-	if (IS_ERR(tfm)) {
-		pr_err("failed to allocate crc algorithm err:%ld\n",
-		       PTR_ERR(tfm));
-		return PTR_ERR(tfm);
-	}
-	rxe->tfm = tfm;
+	err = rxe_icrc_init(rxe);
+	if (err)
+		return err;
 
 	err = ib_register_device(dev, ibdev_name, NULL);
 	if (err)
-- 
2.30.2


  parent reply	other threads:[~2021-07-07  4:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07  4:00 [PATCH for-next v2 0/9] ICRC cleanup Bob Pearson
2021-07-07  4:00 ` [PATCH v2 1/9] RDMA/rxe: Move ICRC checking to a subroutine Bob Pearson
2021-07-13  7:27   ` Zhu Yanjun
2021-07-16 15:55   ` Jason Gunthorpe
2021-07-07  4:00 ` [PATCH v2 2/9] RDMA/rxe: Move rxe_xmit_packet " Bob Pearson
2021-07-14  3:24   ` Zhu Yanjun
2021-07-07  4:00 ` [PATCH v2 3/9] RDMA/rxe: Fixup rxe_send and rxe_loopback Bob Pearson
2021-07-07  4:00 ` [PATCH v2 4/9] RDMA/rxe: Move ICRC generation to a subroutine Bob Pearson
2021-07-16 15:57   ` Jason Gunthorpe
2021-07-16 16:08     ` Bob Pearson
2021-07-16 16:29       ` Jason Gunthorpe
2021-07-16 16:38         ` Pearson, Robert B
2021-07-07  4:00 ` [PATCH v2 5/9] RDMA/rxe: Move rxe_crc32 " Bob Pearson
2021-07-07  4:00 ` [PATCH v2 6/9] RDMA/rxe: Fixup rxe_icrc_hdr Bob Pearson
2021-07-07  4:00 ` Bob Pearson [this message]
2021-07-07  4:00 ` [PATCH v2 8/9] RDMA/rxe: Add kernel-doc comments to rxe_icrc.c Bob Pearson
2021-07-07  4:00 ` [PATCH v2 9/9] RDMA/rxe: Fix types in rxe_icrc.c Bob Pearson
2021-07-16 16:06   ` Jason Gunthorpe
2021-07-08  7:36 ` [PATCH for-next v2 0/9] ICRC cleanup Zhu Yanjun
2021-07-16 17:38 ` Jason Gunthorpe
2021-07-19  8:42   ` Zhu Yanjun
2021-07-19 15:53     ` Olga Kornievskaia
2021-07-19 17:10       ` Jason Gunthorpe
2021-07-19 21:26         ` 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=20210707040040.15434-8-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;
as well as URLs for NNTP newsgroup(s).