From patchwork Sat May 28 16:37:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 9139479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7FF9860221 for ; Sat, 28 May 2016 16:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FC4B2796F for ; Sat, 28 May 2016 16:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64A0B28138; Sat, 28 May 2016 16:41:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 12A232796F for ; Sat, 28 May 2016 16:41:41 +0000 (UTC) Received: from localhost ([::1]:53679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6hIy-00023i-Va for patchwork-qemu-devel@patchwork.kernel.org; Sat, 28 May 2016 12:41:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6hFH-0007BM-BH for qemu-devel@nongnu.org; Sat, 28 May 2016 12:37:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6hFE-0006SP-41 for qemu-devel@nongnu.org; Sat, 28 May 2016 12:37:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6hFD-0006SJ-V1 for qemu-devel@nongnu.org; Sat, 28 May 2016 12:37:48 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D70CC057EC7 for ; Sat, 28 May 2016 16:37:47 +0000 (UTC) Received: from kvm.redhat.com (vpn1-4-119.pek2.redhat.com [10.72.4.119]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4SGbYi8022035; Sat, 28 May 2016 12:37:45 -0400 From: wexu@redhat.com To: qemu-devel@nongnu.org Date: Sun, 29 May 2016 00:37:34 +0800 Message-Id: <1464453454-5703-4-git-send-email-wexu@redhat.com> In-Reply-To: <1464453454-5703-1-git-send-email-wexu@redhat.com> References: <1464453454-5703-1-git-send-email-wexu@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 28 May 2016 16:37:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [ RFC Patch v6 3/3] virtio-net rsc: add 2 new rsc information fields to 'virtio_net_hdr' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, yvugenfi@redhat.com, Wei Xu , marcel@redhat.com, dfleytma@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Xu Field 'coalesced' is to indicate how many packets are coalesced and field 'dup_ack' is how many duplicate acks are merged, guest driver can use these information to notify what's the exact scene of original traffic over the networks. Signed-off-by: Wei Xu --- hw/net/virtio-net.c | 8 ++++++++ include/standard-headers/linux/virtio_net.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index cc8cbe4..20f552a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1768,6 +1768,10 @@ static size_t virtio_net_rsc_drain_seg(NetRscChain *chain, NetRscSeg *seg) if ((chain->proto == ETH_P_IP) && seg->is_coalesced) { virtio_net_rsc_ipv4_checksum(h, seg->unit.ip); } + h->coalesced = seg->packets; + h->dup_ack = seg->dup_ack; + h->gso_type = chain->gso_type; + h->gso_size = chain->max_payload; ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size); QTAILQ_REMOVE(&chain->buffers, seg, next); g_free(seg->buf); @@ -2302,9 +2306,13 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t size) { VirtIONet *n; + struct virtio_net_hdr *h; n = qemu_get_nic_opaque(nc); if (n->host_features & (1ULL << VIRTIO_NET_F_GUEST_RSC)) { + h = (struct virtio_net_hdr *)buf; + h->coalesced = 0; + h->dup_ack = 0; return virtio_net_rsc_receive(nc, buf, size); } else { return virtio_net_do_receive(nc, buf, size); diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h index 5b95762..c837417 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -114,6 +114,8 @@ struct virtio_net_hdr { __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ __virtio16 csum_start; /* Position to start checksumming from */ __virtio16 csum_offset; /* Offset after that to place checksum */ + __virtio16 coalesced; /* packets coalesced by host */ + __virtio16 dup_ack; /* duplicate ack count */ }; /* This is the version of the header to use when the MRG_RXBUF