From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: zyjzyj2000@gmail.com, linux-rdma@vger.kernel.org
Subject: Re: [PATCH v2 1/9] RDMA/rxe: Move ICRC checking to a subroutine
Date: Fri, 16 Jul 2021 12:55:56 -0300 [thread overview]
Message-ID: <20210716155556.GA759856@nvidia.com> (raw)
In-Reply-To: <20210707040040.15434-2-rpearsonhpe@gmail.com>
On Tue, Jul 06, 2021 at 11:00:33PM -0500, Bob Pearson wrote:
> Move the code in rxe_recv() that checks the ICRC on incoming packets to a
> subroutine rxe_check_icrc() and move that to rxe_icrc.c.
>
> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
> Reviewed-by: Zhu Yanjun <zyjzyj2000@gmail.com>
> drivers/infiniband/sw/rxe/rxe_icrc.c | 38 ++++++++++++++++++++++++++++
> drivers/infiniband/sw/rxe/rxe_loc.h | 2 ++
> drivers/infiniband/sw/rxe/rxe_recv.c | 23 ++---------------
> 3 files changed, 42 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_icrc.c b/drivers/infiniband/sw/rxe/rxe_icrc.c
> index 66b2aad54bb7..d067841214be 100644
> +++ b/drivers/infiniband/sw/rxe/rxe_icrc.c
> @@ -67,3 +67,41 @@ u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
> rxe_opcode[pkt->opcode].length - RXE_BTH_BYTES);
> return crc;
> }
> +
> +/**
> + * rxe_icrc_check() - Compute ICRC for a packet and compare to the ICRC
> + * delivered in the packet.
> + * @skb: packet buffer
> + * @pkt: packet info
> + *
> + * Return: 0 if the values match else an error
> + */
> +int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt)
> +{
> + __be32 *icrcp;
> + u32 pkt_icrc;
> + u32 icrc;
> +
> + icrcp = (__be32 *)(pkt->hdr + pkt->paylen - RXE_ICRC_SIZE);
> + pkt_icrc = be32_to_cpu(*icrcp);
> +
> + icrc = rxe_icrc_hdr(pkt, skb);
> + icrc = rxe_crc32(pkt->rxe, icrc, (u8 *)payload_addr(pkt),
> + payload_size(pkt) + bth_pad(pkt));
> + icrc = (__force u32)cpu_to_be32(~icrc);
This isn't right, the return value of rxe_crc32 is a __b32 so icrc
here should be a __b32 too
> + if (unlikely(icrc != pkt_icrc)) {
And this should be written
if (unlikely(be32_to_cpu(~icrc) != pkt_icrc)) {
Or, alternatively you can skip both of the be32_to_cpu's and just
directly compare the __be32 types
Also, I'm not sure the rxe_crc32 byteswapping is right either, the
crc32 shash implementation is storing a __le32 in the shash_desc_ctx()
but this code reads it out as a __be32 ? On BE that will gain a
byteswap, is it OK?
Jason
next prev parent reply other threads:[~2021-07-16 15:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 4:00 [PATCH for-next v2 0/9] ICRC cleanup Bob Pearson
2021-07-07 4:00 ` [PATCH v2 1/9] RDMA/rxe: Move ICRC checking to a subroutine Bob Pearson
2021-07-13 7:27 ` Zhu Yanjun
2021-07-16 15:55 ` Jason Gunthorpe [this message]
2021-07-07 4:00 ` [PATCH v2 2/9] RDMA/rxe: Move rxe_xmit_packet " Bob Pearson
2021-07-14 3:24 ` Zhu Yanjun
2021-07-07 4:00 ` [PATCH v2 3/9] RDMA/rxe: Fixup rxe_send and rxe_loopback Bob Pearson
2021-07-07 4:00 ` [PATCH v2 4/9] RDMA/rxe: Move ICRC generation to a subroutine Bob Pearson
2021-07-16 15:57 ` Jason Gunthorpe
2021-07-16 16:08 ` Bob Pearson
2021-07-16 16:29 ` Jason Gunthorpe
2021-07-16 16:38 ` Pearson, Robert B
2021-07-07 4:00 ` [PATCH v2 5/9] RDMA/rxe: Move rxe_crc32 " Bob Pearson
2021-07-07 4:00 ` [PATCH v2 6/9] RDMA/rxe: Fixup rxe_icrc_hdr Bob Pearson
2021-07-07 4:00 ` [PATCH v2 7/9] RDMA/rxe: Move crc32 init code to rxe_icrc.c Bob Pearson
2021-07-07 4:00 ` [PATCH v2 8/9] RDMA/rxe: Add kernel-doc comments " Bob Pearson
2021-07-07 4:00 ` [PATCH v2 9/9] RDMA/rxe: Fix types in rxe_icrc.c Bob Pearson
2021-07-16 16:06 ` Jason Gunthorpe
2021-07-08 7:36 ` [PATCH for-next v2 0/9] ICRC cleanup Zhu Yanjun
2021-07-16 17:38 ` Jason Gunthorpe
2021-07-19 8:42 ` Zhu Yanjun
2021-07-19 15:53 ` Olga Kornievskaia
2021-07-19 17:10 ` Jason Gunthorpe
2021-07-19 21:26 ` Bob Pearson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210716155556.GA759856@nvidia.com \
--to=jgg@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=rpearsonhpe@gmail.com \
--cc=zyjzyj2000@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.