]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/siw: Use crypto_shash_digest() in siw_qp_prepare_tx()
authorEric Biggers <ebiggers@google.com>
Sun, 29 Oct 2023 04:58:39 +0000 (21:58 -0700)
committerLeon Romanovsky <leon@kernel.org>
Mon, 13 Nov 2023 08:35:12 +0000 (10:35 +0200)
Simplify siw_qp_prepare_tx() 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>
Link: https://lore.kernel.org/r/20231029045839.154071-1-ebiggers@kernel.org
Acked-by: Bernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/sw/siw/siw_qp_tx.c

index b2c06100cf01c19e69fc74fe06abca4d1d7f6dd9..64c113dc8a995cedea276d8ebcfedf92df154c6f 100644 (file)
@@ -249,14 +249,10 @@ static int siw_qp_prepare_tx(struct siw_iwarp_tx *c_tx)
                /*
                 * Do complete CRC if enabled and short packet
                 */
-               if (c_tx->mpa_crc_hd) {
-                       crypto_shash_init(c_tx->mpa_crc_hd);
-                       if (crypto_shash_update(c_tx->mpa_crc_hd,
-                                               (u8 *)&c_tx->pkt,
-                                               c_tx->ctrl_len))
-                               return -EINVAL;
-                       crypto_shash_final(c_tx->mpa_crc_hd, (u8 *)crc);
-               }
+               if (c_tx->mpa_crc_hd &&
+                   crypto_shash_digest(c_tx->mpa_crc_hd, (u8 *)&c_tx->pkt,
+                                       c_tx->ctrl_len, (u8 *)crc) != 0)
+                       return -EINVAL;
                c_tx->ctrl_len += MPA_CRC_SIZE;
 
                return PKT_COMPLETE;