RDMA/rxe: Move crc32 init code to rxe_icrc.c

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>
This commit is contained in:
Bob Pearson 2021-07-06 23:00:39 -05:00 committed by Jason Gunthorpe
parent 6388751057
commit add2b3b80e
4 changed files with 22 additions and 9 deletions

View 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>

View 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;

View 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);

View 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)