diff mbox series

[RFC,3/3] dp8393x: Store CRC using device configured endianess

Message ID 20210703150219.364582-4-f4bug@amsat.org
State New
Headers show
Series dp8393x: Reviewing CRC code | expand

Commit Message

Philippe Mathieu-Daudé July 3, 2021, 3:02 p.m. UTC
Little-Endian CRC is dubious, and the datasheet does not specify
it being little-endian. Proceed similarly with the other memory
accesses, use the device endianess.

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

Patch

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index dee8236400c..3a07f5c8ac9 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -817,8 +817,12 @@  static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
         checksum = crc32(0, buf, pkt_size);
 
         /* Put frame checksum into RBA */
-        address_space_stl_le(&s->as, address, checksum, MEMTXATTRS_UNSPECIFIED,
-                             NULL);
+        if (s->big_endian) {
+            address_space_stl_be(&s->as, address, checksum,
+                                 MEMTXATTRS_UNSPECIFIED, NULL);
+        } else {
+            address_space_stl_le(&s->as, address, checksum,
+                                 MEMTXATTRS_UNSPECIFIED, NULL);
         address += sizeof(checksum);
     }