All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: phy: ncsi: Correct the endian of the checksum
@ 2024-02-05  8:02 Jacky Chou
  2024-02-05 15:04 ` Dan Carpenter
  2024-03-28 15:08 ` Tom Rini
  0 siblings, 2 replies; 7+ messages in thread
From: Jacky Chou @ 2024-02-05  8:02 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, trini, michal.simek,
	marek.vasut+renesas, u-boot
  Cc: BMC-SW

There is no need to perform the endian twice here.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 drivers/net/phy/ncsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/ncsi.c b/drivers/net/phy/ncsi.c
index eb3fd65bb4..74c5386d2e 100644
--- a/drivers/net/phy/ncsi.c
+++ b/drivers/net/phy/ncsi.c
@@ -551,7 +551,7 @@ static int ncsi_send_command(unsigned int np, unsigned int nc, unsigned int cmd,
 	checksum = ncsi_calculate_checksum((unsigned char *)hdr,
 					   sizeof(*hdr) + len);
 	pchecksum = (__be32 *)((void *)(hdr + 1) + len);
-	put_unaligned_be32(htonl(checksum), pchecksum);
+	put_unaligned_be32(checksum, pchecksum);
 
 	if (wait) {
 		net_set_timeout_handler(1000UL, ncsi_timeout_handler);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: phy: ncsi: Correct the endian of the checksum
  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-28 15:08 ` Tom Rini
  1 sibling, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-02-05 15:04 UTC (permalink / raw)
  To: Jacky Chou
  Cc: joe.hershberger, rfried.dev, trini, michal.simek,
	marek.vasut+renesas, u-boot, BMC-SW

On Mon, Feb 05, 2024 at 04:02:28PM +0800, Jacky Chou wrote:
> There is no need to perform the endian twice here.
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: f641a8ac93e0 ("phy: Add support for the NC-SI protocol")

How did this ever work?  Was this always tested on big endian hardware
or was nothing verifying the checksums?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* 回覆: [PATCH] net: phy: ncsi: Correct the endian of the checksum
  2024-02-05 15:04 ` Dan Carpenter
@ 2024-03-03  2:14   ` Jacky Chou
  2024-03-04  6:25     ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Jacky Chou @ 2024-03-03  2:14 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: joe.hershberger, rfried.dev, trini, michal.simek,
	marek.vasut+renesas, u-boot, BMC-SW

Hi Dan Carpenter,

I have verified it on the little-endian platform, such as ASPEED AST2600.
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.


Thanks,
Jacky

________________________________
寄件者: Dan Carpenter <dan.carpenter@linaro.org>
寄件日期: 2024年2月5日 下午 11:04
收件者: Jacky Chou <jacky_chou@aspeedtech.com>
副本: 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>
主旨: Re: [PATCH] net: phy: ncsi: Correct the endian of the checksum

On Mon, Feb 05, 2024 at 04:02:28PM +0800, Jacky Chou wrote:
> There is no need to perform the endian twice here.
>
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: f641a8ac93e0 ("phy: Add support for the NC-SI protocol")

How did this ever work?  Was this always tested on big endian hardware
or was nothing verifying the checksums?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: 回覆: [PATCH] net: phy: ncsi: Correct the endian of the checksum
  2024-03-03  2:14   ` 回覆: " Jacky Chou
@ 2024-03-04  6:25     ` Dan Carpenter
  2024-03-04  8:59       ` Jacky Chou
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-03-04  6:25 UTC (permalink / raw)
  To: Jacky Chou
  Cc: joe.hershberger, rfried.dev, trini, michal.simek,
	marek.vasut+renesas, u-boot, BMC-SW

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...

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: RE: [PATCH] net: phy: ncsi: Correct the endian of the checksum
  2024-03-04  6:25     ` Dan Carpenter
@ 2024-03-04  8:59       ` Jacky Chou
  2024-03-04 10:26         ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Jacky Chou @ 2024-03-04  8:59 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: joe.hershberger, rfried.dev, trini, michal.simek,
	marek.vasut+renesas, u-boot, BMC-SW

> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RE: [PATCH] net: phy: ncsi: Correct the endian of the checksum
  2024-03-04  8:59       ` Jacky Chou
@ 2024-03-04 10:26         ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2024-03-04 10:26 UTC (permalink / raw)
  To: Jacky Chou
  Cc: joe.hershberger, rfried.dev, trini, michal.simek,
	marek.vasut+renesas, u-boot, BMC-SW

Anyway, looks good!  I already gave my reviewed by.  Thanks for your
work on this.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: phy: ncsi: Correct the endian of the checksum
  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-28 15:08 ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2024-03-28 15:08 UTC (permalink / raw)
  To: Jacky Chou
  Cc: joe.hershberger, rfried.dev, michal.simek, marek.vasut+renesas,
	u-boot, BMC-SW

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

On Mon, Feb 05, 2024 at 04:02:28PM +0800, Jacky Chou wrote:

> There is no need to perform the endian twice here.
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-28 15:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2024-03-04 10:26         ` Dan Carpenter
2024-03-28 15:08 ` Tom Rini

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.