[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC Patch 06/10] IPv4 checksum.
From: |
wexu |
Subject: |
[Qemu-devel] [RFC Patch 06/10] IPv4 checksum. |
Date: |
Tue, 26 Jan 2016 06:24:46 +0800 |
Signed-off-by: Wei Xu <address@hidden>
---
hw/net/virtio-net.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 8da2815..1ca3dd5 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1630,6 +1630,18 @@ static int virtio_net_load_device(VirtIODevice *vdev,
QEMUFile *f,
return 0;
}
+static void virtio_net_rsc_ipv4_checksum(NetRscSeg *seg)
+{
+ uint32_t sum;
+ struct ip_header *ip;
+
+ ip = (struct ip_header *)(seg->buf + IP_OFFSET);
+
+ ip->ip_sum = 0;
+ sum = net_checksum_add_cont(sizeof(struct ip_header), (uint8_t *)ip, 0);
+ ip->ip_sum = cpu_to_be16(net_checksum_finish(sum));
+}
+
static void virtio_net_rsc_purge(void *opq)
{
int ret = 0;
@@ -1643,6 +1655,10 @@ static void virtio_net_rsc_purge(void *opq)
continue;
}
+ if ((chain->proto == ETH_P_IP) && seg->is_coalesced) {
+ virtio_net_rsc_ipv4_checksum(seg);
+ }
+
ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size);
QTAILQ_REMOVE(&chain->buffers, seg, next);
g_free(seg->buf);
@@ -1853,6 +1869,9 @@ static size_t virtio_net_rsc_callback(NetRscChain *chain,
NetClientState *nc,
QTAILQ_FOREACH_SAFE(seg, &chain->buffers, next, nseg) {
ret = coalesce(chain, seg, buf, size);
if (RSC_FINAL == ret) {
+ if ((chain->proto == ETH_P_IP) && seg->is_coalesced) {
+ virtio_net_rsc_ipv4_checksum(seg);
+ }
ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size);
QTAILQ_REMOVE(&chain->buffers, seg, next);
g_free(seg->buf);
--
2.4.0
- [Qemu-devel] [RFC 0/10] Support Receive-Segment-Offload(RSC) for WHQL test of Window guest, wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 02/10] Initilize & Cleanup., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 10/10] Statistics., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 01/10] 'Segment', 'Chain' and 'Status' enumeration data structure., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 03/10] Chain lookup and packets caching., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 05/10] The draining timer, create a timer to purge the packets from the cached pool., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 07/10] TCP control packet handling., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 06/10] IPv4 checksum.,
wexu <=
- [Qemu-devel] [RFC Patch 04/10] Tcp general data coalescing, the parameters is a little bit horrible, it's complicated to read, should can be optimized later., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 08/10] Sanity check & More bypass cases check., wexu, 2016/01/25
- [Qemu-devel] [RFC Patch 09/10] IPv6 support., wexu, 2016/01/25
- Re: [Qemu-devel] [RFC 0/10] Support Receive-Segment-Offload(RSC) for WHQL test of Window guest, Fam Zheng, 2016/01/26