aboutsummaryrefslogtreecommitdiff
path: root/hw/e1000.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-09-02 17:47:43 +0300
committerMichael S. Tsirkin <mst@redhat.com>2010-09-06 14:47:56 +0300
commita05e8a6e90c82cec67d16fed24da0fd04ec00f32 (patch)
tree32b6d957e929b44b3590d4b06f19e2e5fb7cf5d0 /hw/e1000.c
parentba5e7f82169f32ab8163c707d97c799ca09f8924 (diff)
downloadqemu-a05e8a6e90c82cec67d16fed24da0fd04ec00f32.zip
qemu-a05e8a6e90c82cec67d16fed24da0fd04ec00f32.tar.gz
qemu-a05e8a6e90c82cec67d16fed24da0fd04ec00f32.tar.bz2
qemu: e1000 fix TOR math
Patch b0b900070c7cb29bbefb732ec00397abe5de6d73 made TOR valuer incorrect: the spec says it should always include the CRC field. No one seems to use this field, but better to stick to spec. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/e1000.c')
-rw-r--r--hw/e1000.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 80b78bc..7d7d140 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -345,7 +345,7 @@ is_vlan_txd(uint32_t txd_lower)
/* FCS aka Ethernet CRC-32. We don't get it from backends and can't
* fill it in, just pad descriptor length by 4 bytes unless guest
- * told us to trip it off the packet. */
+ * told us to strip it off the packet. */
static inline int
fcs_len(E1000State *s)
{
@@ -690,9 +690,14 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
s->mac_reg[GPRC]++;
s->mac_reg[TPR]++;
- n = s->mac_reg[TORL];
- if ((s->mac_reg[TORL] += size) < n)
+ /* TOR - Total Octets Received:
+ * This register includes bytes received in a packet from the <Destination
+ * Address> field through the <CRC> field, inclusively.
+ */
+ n = s->mac_reg[TORL] + size + /* Always include FCS length. */ 4;
+ if (n < s->mac_reg[TORL])
s->mac_reg[TORH]++;
+ s->mac_reg[TORL] = n;
n = E1000_ICS_RXT0;
if ((rdt = s->mac_reg[RDT]) < s->mac_reg[RDH])