summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-07-29 19:41:19 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-07-29 19:41:19 +0000
commitc6a6a5e3bb7120e1eb33eca6364a290229c1e72e (patch)
tree6b51554505d02fba0d23891ef5692bb762541a4a
parent48c643630c5e994e4885dceb45a5da1c403a678a (diff)
e1000: use common checksumming code
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4972 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/e1000.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 1a1405162..d81d9bea2 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -279,26 +279,18 @@ flash_eerd_read(E1000State *s, int x)
E1000_EEPROM_RW_REG_DONE | r;
}
-static unsigned int
-do_cksum(uint8_t *dp, uint8_t *de)
-{
- unsigned int bsum[2] = {0, 0}, i, sum;
-
- for (i = 1; dp < de; bsum[i^=1] += *dp++)
- ;
- sum = (bsum[0] << 8) + bsum[1];
- sum = (sum >> 16) + (sum & 0xffff);
- return ~(sum + (sum >> 16));
-}
-
static void
putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse)
{
+ uint32_t sum;
+
if (cse && cse < n)
n = cse + 1;
- if (sloc < n-1)
+ if (sloc < n-1) {
+ sum = net_checksum_add(n-css, data+css);
cpu_to_be16wu((uint16_t *)(data + sloc),
- do_cksum(data + css, data + n));
+ net_checksum_finish(sum));
+ }
}
static void