qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [4972] e1000: use common checksumming code
@ 2008-07-29 19:41 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2008-07-29 19:41 UTC (permalink / raw)
  To: qemu-devel

Revision: 4972
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4972
Author:   aliguori
Date:     2008-07-29 19:41:19 +0000 (Tue, 29 Jul 2008)

Log Message:
-----------
e1000: use common checksumming code

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Modified Paths:
--------------
    trunk/hw/e1000.c

Modified: trunk/hw/e1000.c
===================================================================
--- trunk/hw/e1000.c	2008-07-29 19:40:04 UTC (rev 4971)
+++ trunk/hw/e1000.c	2008-07-29 19:41:19 UTC (rev 4972)
@@ -279,26 +279,18 @@
            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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-29 19:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29 19:41 [Qemu-devel] [4972] e1000: use common checksumming code Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).