All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin@oracle.com>
To: penberg@kernel.org, asias@redhat.com
Cc: kvm@vger.kernel.org, Sasha Levin <sasha.levin@oracle.com>
Subject: [PATCH 1/8] kvm tools: pass virtio header size to uip_init
Date: Fri,  3 May 2013 16:29:10 -0400	[thread overview]
Message-ID: <1367612957-6719-1-git-send-email-sasha.levin@oracle.com> (raw)

We want to make the size of the virtio net header opaque to
uip.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 tools/kvm/include/kvm/uip.h | 1 +
 tools/kvm/net/uip/core.c    | 8 ++++----
 tools/kvm/net/uip/tcp.c     | 2 +-
 tools/kvm/net/uip/udp.c     | 2 +-
 tools/kvm/virtio/net.c      | 1 +
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h
index ac248d2..338582d 100644
--- a/tools/kvm/include/kvm/uip.h
+++ b/tools/kvm/include/kvm/uip.h
@@ -205,6 +205,7 @@ struct uip_info {
 	u32 dns_ip[UIP_DHCP_MAX_DNS_SERVER_NR];
 	char *domain_name;
 	u32 buf_nr;
+	u32 vnet_hdr_len;
 };
 
 struct uip_buf {
diff --git a/tools/kvm/net/uip/core.c b/tools/kvm/net/uip/core.c
index 4e5bb82..7a74261 100644
--- a/tools/kvm/net/uip/core.c
+++ b/tools/kvm/net/uip/core.c
@@ -172,10 +172,10 @@ int uip_init(struct uip_info *info)
 	}
 
 	list_for_each_entry(buf, buf_head, list) {
-		buf->vnet	= malloc(sizeof(struct virtio_net_hdr));
-		buf->vnet_len	= sizeof(struct virtio_net_hdr);
-		buf->eth	= malloc(1024*64 + sizeof(struct uip_pseudo_hdr));
-		buf->eth_len	= 1024*64 + sizeof(struct uip_pseudo_hdr);
+		buf->vnet_len   = info->vnet_hdr_len;
+		buf->vnet	= malloc(buf->vnet_len);
+		buf->eth_len    = 1024*64 + sizeof(struct uip_pseudo_hdr);
+		buf->eth	= malloc(buf->eth_len);
 
 		memset(buf->vnet, 0, buf->vnet_len);
 		memset(buf->eth, 0, buf->eth_len);
diff --git a/tools/kvm/net/uip/tcp.c b/tools/kvm/net/uip/tcp.c
index 9044f40..3c30ade 100644
--- a/tools/kvm/net/uip/tcp.c
+++ b/tools/kvm/net/uip/tcp.c
@@ -153,7 +153,7 @@ static int uip_tcp_payload_send(struct uip_tcp_socket *sk, u8 flag, u16 payload_
 	/*
 	 * virtio_net_hdr
 	 */
-	buf->vnet_len	= sizeof(struct virtio_net_hdr);
+	buf->vnet_len	= info->vnet_hdr_len;
 	memset(buf->vnet, 0, buf->vnet_len);
 
 	buf->eth_len	= ntohs(ip2->len) + uip_eth_hdrlen(&ip2->eth);
diff --git a/tools/kvm/net/uip/udp.c b/tools/kvm/net/uip/udp.c
index 31c417c..dd288c5 100644
--- a/tools/kvm/net/uip/udp.c
+++ b/tools/kvm/net/uip/udp.c
@@ -142,7 +142,7 @@ int uip_udp_make_pkg(struct uip_info *info, struct uip_udp_socket *sk, struct ui
 	/*
 	 * virtio_net_hdr
 	 */
-	buf->vnet_len	= sizeof(struct virtio_net_hdr);
+	buf->vnet_len	= info->vnet_hdr_len;
 	memset(buf->vnet, 0, buf->vnet_len);
 
 	buf->eth_len	= ntohs(ip2->len) + uip_eth_hdrlen(&ip2->eth);
diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index c0a8f12..2de9222 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -668,6 +668,7 @@ static int virtio_net__init_one(struct virtio_net_params *params)
 		ndev->info.guest_ip		= ntohl(inet_addr(params->guest_ip));
 		ndev->info.guest_netmask	= ntohl(inet_addr("255.255.255.0"));
 		ndev->info.buf_nr		= 20,
+		ndev->info.vnet_hdr_len		= sizeof(struct virtio_net_hdr);
 		uip_init(&ndev->info);
 		ndev->ops = &uip_ops;
 	}
-- 
1.8.2.1


             reply	other threads:[~2013-05-03 20:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03 20:29 Sasha Levin [this message]
2013-05-03 20:29 ` [PATCH 2/8] kvm tools: fix vhost interaction with ctrl vq Sasha Levin
2013-05-03 20:29 ` [PATCH 3/8] kvm tools: add status notification hook for virtio Sasha Levin
2013-05-03 20:29 ` [PATCH 4/8] kvm tools: init network devices only when the virtio driver is ready to go Sasha Levin
2013-05-03 20:29 ` [PATCH 5/8] kvm tools: use correct vnet header size for mergable rx buffers Sasha Levin
2013-05-03 20:29 ` [PATCH 6/8] kvm tools: steal iovec handling routines from the kernel Sasha Levin
2013-05-03 20:29 ` [PATCH 7/8] kvm tools: use iovec functions in uip_rx Sasha Levin
2013-05-03 20:29 ` [PATCH 8/8] kvm tools: virtio-net mergable rx buffers Sasha Levin
2013-05-14 15:30 ` [PATCH 1/8] kvm tools: pass virtio header size to uip_init Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367612957-6719-1-git-send-email-sasha.levin@oracle.com \
    --to=sasha.levin@oracle.com \
    --cc=asias@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.