diff mbox series

RDMA/irdma: use crypto_shash_digest() in irdma_ieq_check_mpacrc()

Message ID 20231029045756.153943-1-ebiggers@kernel.org (mailing list archive)
State Accepted
Headers show
Series RDMA/irdma: use crypto_shash_digest() in irdma_ieq_check_mpacrc() | expand

Commit Message

Eric Biggers Oct. 29, 2023, 4:57 a.m. UTC
From: Eric Biggers <ebiggers@google.com>

Simplify irdma_ieq_check_mpacrc() by using crypto_shash_digest() instead
of an init+update+final sequence.  This should also improve performance.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 drivers/infiniband/hw/irdma/utils.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)


base-commit: 2af9b20dbb39f6ebf9b9b6c090271594627d818e

Comments

Leon Romanovsky Nov. 13, 2023, 8:45 a.m. UTC | #1
On Sat, 28 Oct 2023 21:57:56 -0700, Eric Biggers wrote:
> Simplify irdma_ieq_check_mpacrc() by using crypto_shash_digest() instead
> of an init+update+final sequence.  This should also improve performance.
> 
> 

Applied, thanks!

[1/1] RDMA/irdma: use crypto_shash_digest() in irdma_ieq_check_mpacrc()
      https://git.kernel.org/rdma/rdma/c/42c9ce5203de6d

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
index 6cd5cb85dafe..ead573aabc5c 100644
--- a/drivers/infiniband/hw/irdma/utils.c
+++ b/drivers/infiniband/hw/irdma/utils.c
@@ -1386,31 +1386,26 @@  void irdma_free_hash_desc(struct shash_desc *desc)
  * irdma_ieq_check_mpacrc - check if mpa crc is OK
  * @desc: desc for hash
  * @addr: address of buffer for crc
  * @len: length of buffer
  * @val: value to be compared
  */
 int irdma_ieq_check_mpacrc(struct shash_desc *desc, void *addr, u32 len,
 			   u32 val)
 {
 	u32 crc = 0;
-	int ret;
-	int ret_code = 0;
 
-	crypto_shash_init(desc);
-	ret = crypto_shash_update(desc, addr, len);
-	if (!ret)
-		crypto_shash_final(desc, (u8 *)&crc);
+	crypto_shash_digest(desc, addr, len, (u8 *)&crc);
 	if (crc != val)
-		ret_code = -EINVAL;
+		return -EINVAL;
 
-	return ret_code;
+	return 0;
 }
 
 /**
  * irdma_ieq_get_qp - get qp based on quad in puda buffer
  * @dev: hardware control device structure
  * @buf: receive puda buffer on exception q
  */
 struct irdma_sc_qp *irdma_ieq_get_qp(struct irdma_sc_dev *dev,
 				     struct irdma_puda_buf *buf)
 {