Commit ccf1d14a1e37abe1f0da162c00a8941963b47a4c
1 parent
bf5ee248
Fix rtl8139 checksum calculation, by Tim Deegan.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3109 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
5 additions
and
6 deletions
hw/rtl8139.c
... | ... | @@ -53,9 +53,8 @@ |
53 | 53 | /* debug RTL8139 card C+ mode only */ |
54 | 54 | //#define DEBUG_RTL8139CP 1 |
55 | 55 | |
56 | -/* RTL8139 provides frame CRC with received packet, this feature seems to be | |
57 | - ignored by most drivers, disabled by default */ | |
58 | -//#define RTL8139_CALCULATE_RXCRC 1 | |
56 | +/* Calculate CRCs properly on Rx packets */ | |
57 | +#define RTL8139_CALCULATE_RXCRC 1 | |
59 | 58 | |
60 | 59 | /* Uncomment to enable on-board timer interrupts */ |
61 | 60 | //#define RTL8139_ONBOARD_TIMER 1 |
... | ... | @@ -747,7 +746,7 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size) |
747 | 746 | int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize); |
748 | 747 | |
749 | 748 | /* write packet data */ |
750 | - if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s)) | |
749 | + if (wrapped && !(s->RxBufferSize < 65536 && rtl8139_RxWrap(s))) | |
751 | 750 | { |
752 | 751 | DEBUG_PRINT((">>> RTL8139: rx packet wrapped in buffer at %d\n", size-wrapped)); |
753 | 752 | |
... | ... | @@ -1023,7 +1022,7 @@ static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int d |
1023 | 1022 | |
1024 | 1023 | /* write checksum */ |
1025 | 1024 | #if defined (RTL8139_CALCULATE_RXCRC) |
1026 | - val = cpu_to_le32(crc32(~0, buf, size)); | |
1025 | + val = cpu_to_le32(crc32(0, buf, size)); | |
1027 | 1026 | #else |
1028 | 1027 | val = 0; |
1029 | 1028 | #endif |
... | ... | @@ -1129,7 +1128,7 @@ static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int d |
1129 | 1128 | |
1130 | 1129 | /* write checksum */ |
1131 | 1130 | #if defined (RTL8139_CALCULATE_RXCRC) |
1132 | - val = cpu_to_le32(crc32(~0, buf, size)); | |
1131 | + val = cpu_to_le32(crc32(0, buf, size)); | |
1133 | 1132 | #else |
1134 | 1133 | val = 0; |
1135 | 1134 | #endif | ... | ... |