lkml.org 
[lkml]   [2019]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] net/ncsi: Ensure 32-bit boundary for data cksum
From
From: "Terry S. Duncan" <terry.s.duncan@linux.intel.com>
Date: Tue, 13 Aug 2019 18:18:40 -0700

> The NCSI spec indicates that if the data does not end on a 32 bit
> boundary, one to three padding bytes equal to 0x00 shall be present to
> align the checksum field to a 32-bit boundary.
>
> Signed-off-by: Terry S. Duncan <terry.s.duncan@linux.intel.com>
> ---
> net/ncsi/internal.h | 1 +
> net/ncsi/ncsi-cmd.c | 2 +-
> net/ncsi/ncsi-rsp.c | 12 ++++++++----
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
> index 0b3f0673e1a2..468a19fdfd88 100644
> --- a/net/ncsi/internal.h
> +++ b/net/ncsi/internal.h
> @@ -185,6 +185,7 @@ struct ncsi_package;
> #define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
> #define NCSI_MAX_PACKAGE 8
> #define NCSI_MAX_CHANNEL 32
> +#define NCSI_ROUND32(x) (((x) + 3) & ~3) /* Round to 32 bit boundary */

I think we have enough of a proliferation of alignment macros, let's not add more.

Either define this to "ALIGN(x, 4)" or expand that into each of the locations:

> pchecksum = (__be32 *)((void *)h + sizeof(struct ncsi_pkt_hdr) +
> - nca->payload);
> + NCSI_ROUND32(nca->payload));

ALIGN(nca->payload, 4)

> - pchecksum = (__be32 *)((void *)(h + 1) + payload - 4);
> + pchecksum = (__be32 *)((void *)(h + 1) + NCSI_ROUND32(payload) - 4);

ALIGN(payload, 4)


etc.

\
 
 \ /
  Last update: 2019-08-15 21:33    [W:0.040 / U:0.260 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site