From patchwork Mon Mar 18 18:43:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sfeldma@cumulusnetworks.com X-Patchwork-Id: 228770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F14432C00A5 for ; Tue, 19 Mar 2013 05:44:13 +1100 (EST) Received: from localhost ([::1]:40251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHf2a-0005sv-7Z for incoming@patchwork.ozlabs.org; Mon, 18 Mar 2013 14:44:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHf2F-0005pi-R9 for qemu-devel@nongnu.org; Mon, 18 Mar 2013 14:43:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHf2C-0004vv-QZ for qemu-devel@nongnu.org; Mon, 18 Mar 2013 14:43:51 -0400 Received: from ext3.cumulusnetworks.com ([198.211.106.187]:49037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHf2C-0004vn-Lj for qemu-devel@nongnu.org; Mon, 18 Mar 2013 14:43:48 -0400 Received: from localhost (localhost [127.0.0.1]) by ext3.cumulusnetworks.com (Postfix) with ESMTP id 19FD9203E8; Mon, 18 Mar 2013 11:43:48 -0700 (PDT) X-Virus-Scanned: amavisd-new at cumulusnetworks.com Received: from ext3.cumulusnetworks.com ([127.0.0.1]) by localhost (ext3.cumulusnetworks.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id npU5XE-2dPZR; Mon, 18 Mar 2013 11:43:47 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by ext3.cumulusnetworks.com (Postfix) with ESMTP id 93A17203E7; Mon, 18 Mar 2013 11:43:47 -0700 (PDT) X-Virus-Scanned: amavisd-new at cumulusnetworks.com Received: from ext3.cumulusnetworks.com ([127.0.0.1]) by localhost (ext3.cumulusnetworks.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uwXMEOvzoX2v; Mon, 18 Mar 2013 11:43:46 -0700 (PDT) Received: from localhost (office.cumulusnetworks.com [50.131.52.74]) by ext3.cumulusnetworks.com (Postfix) with ESMTPSA id 85A7E203DF; Mon, 18 Mar 2013 11:43:46 -0700 (PDT) From: sfeldma@cumulusnetworks.com To: qemu-devel@nongnu.org Date: Mon, 18 Mar 2013 11:43:44 -0700 Message-Id: <1363632224-27609-1-git-send-email-sfeldma@cumulusnetworks.com> X-Mailer: git-send-email 1.7.2.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 198.211.106.187 Cc: aliguori@us.ibm.com, shm@cumulusnetworks.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v2] net: increase buffer size to accommodate Jumbo frame pkts 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Scott Feldman Socket buffer sizes were hard-coded to 4K for VDE and socket netdevs. Bump this up to 68K (ala tap netdev) to handle maximum GSO packet size (64k) plus plenty of room for the ethernet and virtio_net headers. Originally, ran into this limitation when using -netdev UDP sockets to connect VM-to-VM, where VM interface is configure with MTU=9000. (Using virtio_net NIC model). Test is simple: ping -M do -s 8500 . This test will attempt to ping with unfragmented packet of given size. Without patch, size is limited to < 4K (minus protocol hdrs). With patch, ping test works with pkt size up to 9000 (again, minus protocol hdrs). v2: per Stefan, increase buf size to (4096+65536) as done in tap and apply to vde and socket netdevs. v1: increase buf size to 12K just for -netdev UDP sockets Signed-off-by: Scott Feldman --- include/net/net.h | 5 +++++ net/net.c | 2 +- net/socket.c | 4 ++-- net/tap.c | 7 +------ net/vde.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index cb049a1..43d85a1 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -11,6 +11,11 @@ #define MAX_QUEUE_NUM 1024 +/* Maximum GSO packet size (64k) plus plenty of room for + * the ethernet and virtio_net headers + */ +#define NET_BUFSIZE (4096 + 65536) + struct MACAddr { uint8_t a[6]; }; diff --git a/net/net.c b/net/net.c index f3d67f8..7869161 100644 --- a/net/net.c +++ b/net/net.c @@ -497,7 +497,7 @@ ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, int iovcnt) { - uint8_t buffer[4096]; + uint8_t buffer[NET_BUFSIZE]; size_t offset; offset = iov_to_buf(iov, iovcnt, 0, buffer, sizeof(buffer)); diff --git a/net/socket.c b/net/socket.c index 396dc8c..d004184 100644 --- a/net/socket.c +++ b/net/socket.c @@ -40,7 +40,7 @@ typedef struct NetSocketState { unsigned int index; unsigned int packet_len; unsigned int send_index; /* number of bytes sent (only SOCK_STREAM) */ - uint8_t buf[4096]; + uint8_t buf[NET_BUFSIZE]; struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */ IOHandler *send_fn; /* differs between SOCK_STREAM/SOCK_DGRAM */ bool read_poll; /* waiting to receive data? */ @@ -146,7 +146,7 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; - uint8_t buf1[4096]; + uint8_t buf1[NET_BUFSIZE]; const uint8_t *buf; size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); diff --git a/net/tap.c b/net/tap.c index daab350..75f1146 100644 --- a/net/tap.c +++ b/net/tap.c @@ -44,17 +44,12 @@ #include "hw/vhost_net.h" -/* Maximum GSO packet size (64k) plus plenty of room for - * the ethernet and virtio_net headers - */ -#define TAP_BUFSIZE (4096 + 65536) - typedef struct TAPState { NetClientState nc; int fd; char down_script[1024]; char down_script_arg[128]; - uint8_t buf[TAP_BUFSIZE]; + uint8_t buf[NET_BUFSIZE]; bool read_poll; bool write_poll; bool using_vnet_hdr; diff --git a/net/vde.c b/net/vde.c index 4dea32d..2a619fb 100644 --- a/net/vde.c +++ b/net/vde.c @@ -39,7 +39,7 @@ typedef struct VDEState { static void vde_to_qemu(void *opaque) { VDEState *s = opaque; - uint8_t buf[4096]; + uint8_t buf[NET_BUFSIZE]; int size; size = vde_recv(s->vde, (char *)buf, sizeof(buf), 0);