From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNpqC-0005Xx-5a for qemu-devel@nongnu.org; Tue, 29 Jul 2008 10:06:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNpqA-0005XT-Lr for qemu-devel@nongnu.org; Tue, 29 Jul 2008 10:06:15 -0400 Received: from [199.232.76.173] (port=39604 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNpqA-0005XQ-Ef for qemu-devel@nongnu.org; Tue, 29 Jul 2008 10:06:14 -0400 Received: from mx1.redhat.com ([66.187.233.31]:35157) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KNpq9-0005DG-Kf for qemu-devel@nongnu.org; Tue, 29 Jul 2008 10:06:14 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6TE6DVH018862 for ; Tue, 29 Jul 2008 10:06:13 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6TE6BD1029724 for ; Tue, 29 Jul 2008 10:06:12 -0400 Received: from zweiblum.travel.kraxel.org (vpn-4-92.str.redhat.com [10.32.4.92]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id m6TE6BdF026403 for ; Tue, 29 Jul 2008 10:06:11 -0400 Message-ID: <488F23D2.4050906@redhat.com> Date: Tue, 29 Jul 2008 16:06:10 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090204040301050907030304" Subject: [Qemu-devel] [PATCH] make e1000 use the checksuming code Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------090204040301050907030304 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, This patch makes the e1000 nic driver use the checksumming code added with the previous patch. That one better should be reviewed by someone knowing the e1000 better than I do. I think I got it right though ... cheers, Gerd -- http://kraxel.fedorapeople.org/xenner/ --------------090204040301050907030304 Content-Type: text/x-patch; name="0005-e1000-use-common-checksumming-code.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0005-e1000-use-common-checksumming-code.patch" >>From 6b61fa35c52092c6372e9d095e2131370cc151cd Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 29 Jul 2008 13:39:32 +0200 Subject: [PATCH 05/22] e1000: use common checksumming code. Signed-off-by: Gerd Hoffmann --- hw/e1000.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 1a14051..d81d9be 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 -- 1.5.4.1 --------------090204040301050907030304--