From patchwork Sun Apr 3 19:25:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 8734871 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB287C0553 for ; Sun, 3 Apr 2016 19:26:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CFE6B201F5 for ; Sun, 3 Apr 2016 19:26:27 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 08D0B201CE for ; Sun, 3 Apr 2016 19:26:27 +0000 (UTC) Received: from localhost ([::1]:54923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amnfF-0004x9-Bf for patchwork-qemu-devel@patchwork.kernel.org; Sun, 03 Apr 2016 15:26:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amnf6-0004wt-0A for qemu-devel@nongnu.org; Sun, 03 Apr 2016 15:26:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1amnf4-0005WC-Lp for qemu-devel@nongnu.org; Sun, 03 Apr 2016 15:26:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32870) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amnf4-0005W4-EF for qemu-devel@nongnu.org; Sun, 03 Apr 2016 15:26:14 -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 1070164381 for ; Sun, 3 Apr 2016 19:26:14 +0000 (UTC) Received: from wei-thinkpad.nay.redhat.com (vpn1-7-151.pek2.redhat.com [10.72.7.151]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u33JQ7na013812; Sun, 3 Apr 2016 15:26:11 -0400 From: wexu@redhat.com To: qemu-devel@nongnu.org Date: Mon, 4 Apr 2016 03:25:54 +0800 Message-Id: <1459711556-10273-2-git-send-email-wexu@redhat.com> In-Reply-To: <1459711556-10273-1-git-send-email-wexu@redhat.com> References: <1459711556-10273-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.39]); Sun, 03 Apr 2016 19:26:14 +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 Cc: victork@redhat.com, mst@redhat.com, jasowang@redhat.com, yvugenfi@redhat.com, Wei Xu , marcel@redhat.com, dfleytma@redhat.com Subject: [Qemu-devel] [ RFC Patch v4 1/3] virtio-net rsc: add a new host offload(rsc) feature bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Xu A new feature bit 'VIRTIO_NET_F_GUEST_RSC' is introduced to support WHQL Receive-Segment-Offload test, this feature will coalesce tcp packets in IPv4/6 for userspace virtio-net driver. This feature can be enabled either by 'ACK' the feature when loading the driver in the guest, or by sending the 'VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET' command to the host via control queue. Signed-off-by: Wei Xu --- hw/net/virtio-net.c | 29 +++++++++++++++++++++++++++-- include/standard-headers/linux/virtio_net.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5798f87..bd91a4b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -537,6 +537,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO4); virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO6); virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ECN); + virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_RSC); } if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { @@ -582,7 +583,8 @@ static uint64_t virtio_net_guest_offloads_by_features(uint32_t features) (1ULL << VIRTIO_NET_F_GUEST_TSO4) | (1ULL << VIRTIO_NET_F_GUEST_TSO6) | (1ULL << VIRTIO_NET_F_GUEST_ECN) | - (1ULL << VIRTIO_NET_F_GUEST_UFO); + (1ULL << VIRTIO_NET_F_GUEST_UFO) | + (1ULL << VIRTIO_NET_F_GUEST_RSC); return guest_offloads_mask & features; } @@ -1089,7 +1091,8 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) return 0; } -static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t size) +static ssize_t virtio_net_do_receive(NetClientState *nc, + const uint8_t *buf, size_t size) { VirtIONet *n = qemu_get_nic_opaque(nc); VirtIONetQueue *q = virtio_net_get_subqueue(nc); @@ -1685,6 +1688,26 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, return 0; } + +static ssize_t virtio_net_rsc_receive(NetClientState *nc, + const uint8_t *buf, size_t size) +{ + return virtio_net_do_receive(nc, buf, size); +} + +static ssize_t virtio_net_receive(NetClientState *nc, + const uint8_t *buf, size_t size) +{ + VirtIONet *n; + + n = qemu_get_nic_opaque(nc); + if (n->curr_guest_offloads & VIRTIO_NET_F_GUEST_RSC) { + return virtio_net_rsc_receive(nc, buf, size); + } else { + return virtio_net_do_receive(nc, buf, size); + } +} + static NetClientInfo net_virtio_info = { .type = NET_CLIENT_OPTIONS_KIND_NIC, .size = sizeof(NICState), @@ -1909,6 +1932,8 @@ static Property virtio_net_properties[] = { TX_TIMER_INTERVAL), DEFINE_PROP_INT32("x-txburst", VirtIONet, net_conf.txburst, TX_BURST), DEFINE_PROP_STRING("tx", VirtIONet, net_conf.tx), + DEFINE_PROP_BIT("guest_rsc", VirtIONet, host_features, + VIRTIO_NET_F_GUEST_RSC, true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h index a78f33e..5b95762 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -55,6 +55,7 @@ #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_GUEST_RSC 24 /* Guest can coalesce tcp packets */ #ifndef VIRTIO_NET_NO_LEGACY #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */