All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jacky Chou <jacky_chou@aspeedtech.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: "joe.hershberger@ni.com" <joe.hershberger@ni.com>,
	"rfried.dev@gmail.com" <rfried.dev@gmail.com>,
	"trini@konsulko.com" <trini@konsulko.com>,
	"michal.simek@amd.com" <michal.simek@amd.com>,
	"marek.vasut+renesas@mailbox.org"
	<marek.vasut+renesas@mailbox.org>,
	"u-boot@lists.denx.de" <u-boot@lists.denx.de>,
	BMC-SW <BMC-SW@aspeedtech.com>
Subject: RE: RE: [PATCH] net: phy: ncsi: Correct the endian of the checksum
Date: Mon, 4 Mar 2024 08:59:47 +0000	[thread overview]
Message-ID: <SEYPR06MB5134211DDFB9F9FDB0125F609D232@SEYPR06MB5134.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <901d6849-2e8d-4876-95b6-afdb9696d862@moroto.mountain>

> On Sun, Mar 03, 2024 at 02:14:43AM +0000, Jacky Chou wrote:
> > Hi Dan Carpenter,
> >
> > I have verified it on the little-endian platform, such as ASPEED AST2600.
> 
> Awesome.  Thanks for this.
> 
> > I think put_unaligned_be32() and htonl() functions have no effect on
> big-endian platforms.
> > And keep put_unaligned_be32() to help access the unaligned memory, such
> as pchecksum variable.
> 
> Yes.  I know that.
> 
> What I'm just puzzled by is how we ever merged this code when it doesn't work
> for little endian systems.  How was it tested originally?  How do the errors
> look like?  Perhaps they're not as bad I assume from looking at the code...

I am not sure how it was originally tested.
The first patch was based on Linux NC-SI driver.
I found the code in the Linux kernel where NC-SI calculates the checksum.
	...
	/* Fill with calculated checksum */
	checksum = ncsi_calculate_checksum((unsigned char *)h,
					   sizeof(*h) + nca->payload);
	pchecksum = (__be32 *)((void *)h + sizeof(struct ncsi_pkt_hdr) +
		    ALIGN(nca->payload, 4));
	*pchecksum = htonl(checksum);
	...
It gets the pointer of checksum field and call htonl() to do endian conversion.
Linux NC-IS driver only performs endian conversion.

Thanks,
Jacky

  reply	other threads:[~2024-03-04  9:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05  8:02 [PATCH] net: phy: ncsi: Correct the endian of the checksum Jacky Chou
2024-02-05 15:04 ` Dan Carpenter
2024-03-03  2:14   ` 回覆: " Jacky Chou
2024-03-04  6:25     ` Dan Carpenter
2024-03-04  8:59       ` Jacky Chou [this message]
2024-03-04 10:26         ` Dan Carpenter
2024-03-28 15:08 ` Tom Rini

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=SEYPR06MB5134211DDFB9F9FDB0125F609D232@SEYPR06MB5134.apcprd06.prod.outlook.com \
    --to=jacky_chou@aspeedtech.com \
    --cc=BMC-SW@aspeedtech.com \
    --cc=dan.carpenter@linaro.org \
    --cc=joe.hershberger@ni.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=michal.simek@amd.com \
    --cc=rfried.dev@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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.