Thread (24 messages) 24 messages, 5 authors, 2021-07-19

Re: [PATCH v2 9/9] RDMA/rxe: Fix types in rxe_icrc.c

From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2021-07-16 16:06:46

On Tue, Jul 06, 2021 at 11:00:41PM -0500, Bob Pearson wrote:
Currently the ICRC is generated as a u32 type and then forced to a __be32
and stored into the ICRC field in the packet. The actual type of the ICRC
is __be32. This patch replaces u32 by __be32 and eliminates the casts.
The computation is exactly the same as the original but the types are
more consistent.

Signed-off-by: Bob Pearson <redacted>
---
 drivers/infiniband/sw/rxe/rxe_icrc.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
Oh, well Ok, it mostly gets fixed up here
 	shash->tfm = rxe->tfm;
-	*(u32 *)shash_desc_ctx(shash) = crc;
+	*(__be32 *)shash_desc_ctx(shash) = crc;
 	err = crypto_shash_update(shash, next, len);
 	if (unlikely(err)) {
 		pr_warn_ratelimited("failed crc calculation, err: %d\n", err);
-		return crc32_le(crc, next, len);
+		return (__force __be32)crc32_le((__force u32)crc, next, len);
 	}
But all this makes my head ache, I'm skeptical it is OK, but isn't any
worse
quoted hunk ↗ jump to hunk
@@ -91,7 +91,7 @@ static u32 rxe_icrc_hdr(struct sk_buff *skb, struct rxe_pkt_info *pkt)
 	/* This seed is the result of computing a CRC with a seed of
 	 * 0xfffffff and 8 bytes of 0xff representing a masked LRH.
 	 */
-	crc = 0xdebb20e3;
+	crc = (__force __be32)0xdebb20e3;
Eg should this be cpu_to_be32(0xe320bbde) ?

Hard to know without a BE system to check it out on

Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help