RDMA/rxe: Move crc32 init code to rxe_icrc.c
authorBob Pearson <rpearsonhpe@gmail.com>
Wed, 7 Jul 2021 04:00:39 +0000 (23:00 -0500)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 16 Jul 2021 15:43:34 +0000 (12:43 -0300)
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.

Link: https://lore.kernel.org/r/20210707040040.15434-8-rpearsonhpe@gmail.com
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/rxe/rxe.h
drivers/infiniband/sw/rxe/rxe_icrc.c
drivers/infiniband/sw/rxe/rxe_loc.h
drivers/infiniband/sw/rxe/rxe_verbs.c

index 65a73c1..1bb3fb6 100644 (file)
@@ -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>
index 7771995..62bcdfc 100644 (file)
@@ -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;
index 73a2c48..f0c9545 100644 (file)
@@ -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);
 
index c223959..f7b1a1f 100644 (file)
@@ -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)