[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 3/3] dp8393x: Store CRC using device configured endianess
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 3/3] dp8393x: Store CRC using device configured endianess |
Date: |
Sat, 3 Jul 2021 17:02:19 +0200 |
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 --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);
}
--
2.31.1