qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Jason Wang" <jasowang@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Finn Thain" <fthain@linux-m68k.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [RFC PATCH 1/3] dp8393x: Store CRC using address_space_stl_le()
Date: Sat,  3 Jul 2021 17:02:17 +0200	[thread overview]
Message-ID: <20210703150219.364582-2-f4bug@amsat.org> (raw)
In-Reply-To: <20210703150219.364582-1-f4bug@amsat.org>

The address_space API can handle endianess conversion.
Replace cpu_to_le32() + address_space_write() by a
single address_space_stl_le() call.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/net/dp8393x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index db9cfd786f5..99e179a5e86 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -802,7 +802,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
     s->regs[SONIC_TRBA0] = s->regs[SONIC_CRBA0];
 
     /* Calculate the ethernet checksum */
-    checksum = cpu_to_le32(crc32(0, buf, pkt_size));
+    checksum = crc32(0, buf, pkt_size);
 
     /* Put packet into RBA */
     trace_dp8393x_receive_packet(dp8393x_crba(s));
@@ -812,8 +812,8 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
     address += pkt_size;
 
     /* Put frame checksum into RBA */
-    address_space_write(&s->as, address, MEMTXATTRS_UNSPECIFIED,
-                        &checksum, sizeof(checksum));
+    address_space_stl_le(&s->as, address, checksum, MEMTXATTRS_UNSPECIFIED,
+                         NULL);
     address += sizeof(checksum);
 
     /* Pad short packets to keep pointers aligned */
-- 
2.31.1



  reply	other threads:[~2021-07-03 15:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03 15:02 [RFC PATCH 0/3] dp8393x: Reviewing CRC code Philippe Mathieu-Daudé
2021-07-03 15:02 ` Philippe Mathieu-Daudé [this message]
2021-07-03 15:02 ` [RFC PATCH 2/3] dp8393x: Do not amend CRC if it is inhibited (CRCI bit set) Philippe Mathieu-Daudé
2021-07-03 16:32   ` BALATON Zoltan
2021-07-03 16:40     ` Philippe Mathieu-Daudé
2021-07-04  0:49   ` Finn Thain
2021-07-03 15:02 ` [RFC PATCH 3/3] dp8393x: Store CRC using device configured endianess Philippe Mathieu-Daudé
2021-07-04  1:28 ` [RFC PATCH 0/3] dp8393x: Reviewing CRC code Finn Thain

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=20210703150219.364582-2-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=fthain@linux-m68k.org \
    --cc=jasowang@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).