Re: [RFC virtio-next 0/4] Introduce CAIF Virtio and reversed Vrings

2012-11-05 Thread Rusty Russell
Sjur Brændeland  writes:
> Hi Rusty,
>
>> So, this adds another host-side virtqueue implementation.
>>
>> Can we combine them together conveniently?  You pulled out more stuff
>> into vring.h which is a start, but it's a bit overloaded.
>> Perhaps we should separate the common fields into struct vring, and use
>> it to build:
>>
>> struct vring_guest {
>> struct vring vr;
>> u16 last_used_idx;
>> };
>>
>> struct vring_host {
>> struct vring vr;
>> u16 last_avail_idx;
>> };
>> I haven't looked closely at vhost to see what it wants, but I would
>> think we could share more code.
>
> I have played around with the code in vhost.c to explore your idea.
> The main issue I run into is that vhost.c is accessing user data while my new
> code does not. So I end up with some quirky code testing if the ring lives in
> user memory or not.  Another issue is sparse warnings when
> accessing user memory.

Sparse is a servant, not a master.  If that's the only thing stopping
us, we can ignore it (or hack around it).

> With your suggested changes I end up sharing about 100 lines of code.
> So in sum, I feel this add more complexity than what we gain by sharing.
>
> Below is an initial draft of the re-usable code. I added "is_uaccess" to 
> struct
> virtio_ring in order to know if the ring lives in user memory.
>
> Let me know what you think.

Agreed, that's horrible...

Fortunately, recent GCCs will inline function pointers, so inlining this
and handing an accessor function gets optimized away.

I would really like this, because I'd love to have a config option to do
strict checking on the format of these things (similar to my recently
posted CONFIG_VIRTIO_DEVICE_TORTURE patch).

See below.

> int virtqueue_add_used(struct vring_host *vr, unsigned int head, int len,
>   struct vring_used_elem  **used)
> {
>   /* The virtqueue contains a ring of used buffers.  Get a pointer to the
>* next entry in that used ring. */
>   *used = &vr->vring.used->ring[vr->last_used_idx % vr->vring.num];
>   if (vr->is_uaccess) {
>   if(unlikely(__put_user(head, &(*used)->id))) {
>   pr_debug("Failed to write used id");
>   return -EFAULT;
>   }
>   if (unlikely(__put_user(len, &(*used)->len))) {
>   pr_debug("Failed to write used len");
>   return -EFAULT;
>   }
>   smp_wmb();
>   if (__put_user(vr->last_used_idx + 1,
>  &vr->vring.used->idx)) {
>   pr_debug("Failed to increment used idx");
>   return -EFAULT;
>   }
>   } else {
>   (*used)->id = head;
>   (*used)->len = len;
>   smp_wmb();
>   vr->vring.used->idx = vr->last_used_idx + 1;
>   }
>   vr->last_used_idx++;
>   return 0;
> }

/* Untested! */
static inline bool in_kernel_put(u32 *dst, u32 v)
{
*dst = v;
return true;
}

static inline bool userspace_put(u32 *dst, u32 v)
{
return __put_user(dst, v) == 0;
}

static inline struct vring_used_elem *vrh_add_used(struct vring_host *vr,
   unsigned int head, u32 len,
   bool (*put)(u32 *dst, u32 v))
{
struct vring_used_elem *used;

/* The virtqueue contains a ring of used buffers.  Get a pointer to the
 * next entry in that used ring. */
used = &vr->vring.used->ring[vr->last_used_idx % vr->vring.num];

if (!put(&used->id, head) || !put(&used->len = len))
return NULL;
smp_wmb();
if (!put(&vr->vring.used->idx, vr->last_used_idx + 1))
return NULL;
vr->last_used_idx++;
return used;
}

Cheers,
Rusty.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCHv8 0/3]virtio_console: Add rproc_serial driver

2012-11-05 Thread Rusty Russell
Amit Shah  writes:
> On (Mon) 05 Nov 2012 [11:31:24], Amit Shah wrote:
>> On (Mon) 05 Nov 2012 [09:11:45], Rusty Russell wrote:
>> > Sjur Brændeland  writes:
>> > 
>> > > From: Sjur Brændeland 
>> > >
>> > > This patch-set introduces a new virtio type "rproc_serial" for 
>> > > communicating
>> > > with remote processors over shared memory. The driver depends on the
>> > > the remoteproc framework. As preparation for introducing "rproc_serial"
>> > > I've done a refactoring of the transmit buffer handling.
>> > >
>> > > Changes since v7:
>> > > - Rebased to virtio-next branch.
>> > > - Removed extra added lines.
>> > > - Removed superfluous checks before calling reclaim_dma_bufs().
>> > > - Rusty raised some question regarding garbage collection of the
>> > >   out-vq, so I moved this into a separate patch.
>> > 
>> > OK, I'm not sure that WARN_ON won't fire, but that's not all that
>> > harmful.
>> 
>> Sjur said he'll send out a respin for this; can you wait for his v8?
>
> Er, v9.
>
>   Amit

Yep, they're in my pending-rebases tree now.

Though no need to repost the whole series; just the changes please.

Cheers,
Rusty.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread George Zhang
Sasha,
There is a 'brief' implementation notes aboutVSOCK protocol family
in af_vsock.c. More about user space layer socket programming is from
VMCI Socket Programming Guide. (remove crosst...@vmware.com for email bouncing).
thanks,
George

- Original Message -
From: "Sasha Levin" 
To: "George Zhang" 
Cc: net...@vger.kernel.org, linux-ker...@vger.kernel.org, 
virtualization@lists.linux-foundation.org, pv-driv...@vmware.com, 
vm-crosst...@vmware.com, da...@davemloft.net, gre...@linuxfoundation.org
Sent: Monday, November 5, 2012 10:23:02 AM
Subject: Re: [PATCH 0/6] VSOCK for Linux upstreaming

Hi George,

On Mon, Nov 5, 2012 at 1:00 PM, George Zhang  wrote:
> For additional information about the use of VMCI and in particular
> VMCI Sockets, please refer to the VMCI Socket Programming Guide
> available at https://www.vmware.com/support/developer/vmci-sdk/.

Is there documentation about the protocol itself? I couldn't find it
on the link above.


Thanks,
Sasha
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread George Zhang
David,
We will fix this bounces and remove the email: crosst...@vmware.com.
Thanks,
george zhang

- Original Message -
From: "David Miller" 
To: georgezh...@vmware.com
Cc: net...@vger.kernel.org, linux-ker...@vger.kernel.org, 
virtualization@lists.linux-foundation.org, pv-driv...@vmware.com, 
vm-crosst...@vmware.com, gre...@linuxfoundation.org
Sent: Monday, November 5, 2012 10:10:37 AM
Subject: Re: [PATCH 0/6] VSOCK for Linux upstreaming

From: David Miller 
Date: Mon, 05 Nov 2012 13:09:17 -0500 (EST)

> The big and only question is whether anyone can actually use any of
> this stuff without your proprietary bits?

And BTW vm-crosst...@vmware.com bounces, take it out of the CC: list
on all future emails.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread Sasha Levin
Hi George,

On Mon, Nov 5, 2012 at 1:00 PM, George Zhang  wrote:
> For additional information about the use of VMCI and in particular
> VMCI Sockets, please refer to the VMCI Socket Programming Guide
> available at https://www.vmware.com/support/developer/vmci-sdk/.

Is there documentation about the protocol itself? I couldn't find it
on the link above.


Thanks,
Sasha
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [Pv-drivers] [PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread Andy King
Hi David,

> The big and only question is whether anyone can actually use any of
> this stuff without your proprietary bits?

Do you mean the VMCI calls?  The VMCI driver is in the process of being
upstreamed into the drivers/misc tree.  Greg (cc'd on these patches) is
actively reviewing that code and we are addressing feedback.

Also, there was some interest from RedHat into using vSockets as a unified
interface, routed over a hypervisor-specific transport (virtio or
otherwise, although for now VMCI is the only one implemented).

Thanks!
- Andy
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread David Miller
From: David Miller 
Date: Mon, 05 Nov 2012 13:09:17 -0500 (EST)

> The big and only question is whether anyone can actually use any of
> this stuff without your proprietary bits?

And BTW vm-crosst...@vmware.com bounces, take it out of the CC: list
on all future emails.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread David Miller

The big and only question is whether anyone can actually use any of
this stuff without your proprietary bits?
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 6/6] VSOCK: header and config files.

2012-11-05 Thread George Zhang
VSOCK header files, Makefiles and Kconfig systems for Linux VSocket module.


Signed-off-by: George Zhang 
---
 include/linux/socket.h  |4 
 net/Kconfig |1 
 net/Makefile|1 
 net/vmw_vsock/Kconfig   |   14 +
 net/vmw_vsock/Makefile  |4 
 net/vmw_vsock/notify_qstate.c   |  627 +++
 net/vmw_vsock/vmci_sockets.h|  517 +
 net/vmw_vsock/vmci_sockets_packet.h |  106 ++
 net/vmw_vsock/vsock_common.h|  130 +++
 net/vmw_vsock/vsock_packet.h|  131 +++
 net/vmw_vsock/vsock_version.h   |   29 ++
 11 files changed, 1563 insertions(+), 1 deletions(-)
 create mode 100644 net/vmw_vsock/Kconfig
 create mode 100644 net/vmw_vsock/Makefile
 create mode 100644 net/vmw_vsock/notify_qstate.c
 create mode 100644 net/vmw_vsock/vmci_sockets.h
 create mode 100644 net/vmw_vsock/vmci_sockets_packet.h
 create mode 100644 net/vmw_vsock/vsock_common.h
 create mode 100644 net/vmw_vsock/vsock_packet.h
 create mode 100644 net/vmw_vsock/vsock_version.h

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 25d6322..57bc85e 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -195,7 +195,8 @@ struct ucred {
 #define AF_CAIF37  /* CAIF sockets */
 #define AF_ALG 38  /* Algorithm sockets*/
 #define AF_NFC 39  /* NFC sockets  */
-#define AF_MAX 40  /* For now.. */
+#define AF_VSOCK   40  /* VMCI sockets */
+#define AF_MAX 41  /* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC  AF_UNSPEC
@@ -238,6 +239,7 @@ struct ucred {
 #define PF_CAIFAF_CAIF
 #define PF_ALG AF_ALG
 #define PF_NFC AF_NFC
+#define PF_VSOCK   AF_VSOCK
 #define PF_MAX AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
diff --git a/net/Kconfig b/net/Kconfig
index 245831b..75b8d5e 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -216,6 +216,7 @@ source "net/dcb/Kconfig"
 source "net/dns_resolver/Kconfig"
 source "net/batman-adv/Kconfig"
 source "net/openvswitch/Kconfig"
+source "net/vmw_vsock/Kconfig"
 
 config RPS
boolean
diff --git a/net/Makefile b/net/Makefile
index 4f4ee08..cae59f4 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -70,3 +70,4 @@ obj-$(CONFIG_CEPH_LIB)+= ceph/
 obj-$(CONFIG_BATMAN_ADV)   += batman-adv/
 obj-$(CONFIG_NFC)  += nfc/
 obj-$(CONFIG_OPENVSWITCH)  += openvswitch/
+obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock/
diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig
new file mode 100644
index 000..95e2568
--- /dev/null
+++ b/net/vmw_vsock/Kconfig
@@ -0,0 +1,14 @@
+#
+# Vsock protocol
+#
+
+config VMWARE_VSOCK
+   tristate "Virtual Socket protocol"
+   depends on VMWARE_VMCI
+   help
+ Virtual Socket Protocol is a socket protocol similar to TCP/IP
+ allowing comunication between Virtual Machines and VMware
+ hypervisor.
+
+ To compile this driver as a module, choose M here: the module
+ will be called vsock. If unsure, say N.
diff --git a/net/vmw_vsock/Makefile b/net/vmw_vsock/Makefile
new file mode 100644
index 000..4e940fe
--- /dev/null
+++ b/net/vmw_vsock/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_VMWARE_VSOCK) += vmw_vsock.o
+
+vmw_vsock-y += af_vsock.o notify.o notify_qstate.o stats.o util.o \
+   vsock_addr.o
diff --git a/net/vmw_vsock/notify_qstate.c b/net/vmw_vsock/notify_qstate.c
new file mode 100644
index 000..9cc4b58
--- /dev/null
+++ b/net/vmw_vsock/notify_qstate.c
@@ -0,0 +1,627 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2009-2012 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * notifyQState.c --
+ *
+ * Linux control notifications based on Queuepair state for the VMCI Stream
+ * Sockets protocol.
+ */
+
+#include 
+
+#include 
+
+#include   /* for NULL */
+#include 
+
+#include "notify.h"
+#include "af_vsock.h"
+
+#define PKT_FIELD(vsk, field_name) \
+   (vsk)->notify.pkt_q_state.field_name
+
+/*
+ *
+ * vsock_vmci_notify_waiting_write --
+ *
+ * Determines if the conditions have been met to notify a waiting writer.
+ *
+ * Results: true if a notification should be sent, false otherwise.
+ *
+ * Side effects: None.
+ */
+
+static bool vsock_vmci_notify_waiting_write(vsock_vmci_sock *vsk)
+{

[PATCH 5/6] VSOCK: utility functions.

2012-11-05 Thread George Zhang
VSOCK utility functions for Linux VSocket module.


Signed-off-by: George Zhang 
---
 net/vmw_vsock/util.c |  626 ++
 net/vmw_vsock/util.h |  312 +
 2 files changed, 938 insertions(+), 0 deletions(-)
 create mode 100644 net/vmw_vsock/util.c
 create mode 100644 net/vmw_vsock/util.h

diff --git a/net/vmw_vsock/util.c b/net/vmw_vsock/util.c
new file mode 100644
index 000..1c42b23
--- /dev/null
+++ b/net/vmw_vsock/util.c
@@ -0,0 +1,626 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2007-2012 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * util.c --
+ *
+ * Utility functions for Linux VSocket module.
+ */
+
+#include 
+#include 
+#include 
+#include   /* for NULL */
+#include 
+
+#include "af_vsock.h"
+#include "util.h"
+
+struct list_head vsock_bind_table[VSOCK_HASH_SIZE + 1];
+struct list_head vsock_connected_table[VSOCK_HASH_SIZE];
+
+DEFINE_SPINLOCK(vsock_table_lock);
+
+/*
+ *
+ * vsock_vmci_log_pkt --
+ *
+ * Logs the provided packet.
+ *
+ * Results: None.
+ *
+ * Side effects: None.
+ */
+
+void vsock_vmci_log_pkt(char const *function, u32 line, vsock_packet *pkt)
+{
+   char buf[256];
+   char *cur = buf;
+   int left = sizeof buf;
+   int written = 0;
+   char *type_strings[] = {
+   [VSOCK_PACKET_TYPE_INVALID] = "INVALID",
+   [VSOCK_PACKET_TYPE_REQUEST] = "REQUEST",
+   [VSOCK_PACKET_TYPE_NEGOTIATE] = "NEGOTIATE",
+   [VSOCK_PACKET_TYPE_OFFER] = "OFFER",
+   [VSOCK_PACKET_TYPE_ATTACH] = "ATTACH",
+   [VSOCK_PACKET_TYPE_WROTE] = "WROTE",
+   [VSOCK_PACKET_TYPE_READ] = "READ",
+   [VSOCK_PACKET_TYPE_RST] = "RST",
+   [VSOCK_PACKET_TYPE_SHUTDOWN] = "SHUTDOWN",
+   [VSOCK_PACKET_TYPE_WAITING_WRITE] = "WAITING_WRITE",
+   [VSOCK_PACKET_TYPE_WAITING_READ] = "WAITING_READ",
+   [VSOCK_PACKET_TYPE_REQUEST2] = "REQUEST2",
+   [VSOCK_PACKET_TYPE_NEGOTIATE2] = "NEGOTIATE2",
+   };
+
+   written = snprintf(cur, left, "PKT: %u:%u -> %u:%u",
+  VMCI_HANDLE_TO_CONTEXT_ID(pkt->dg.src),
+  pkt->src_port,
+  VMCI_HANDLE_TO_CONTEXT_ID(pkt->dg.dst),
+  pkt->dst_port);
+   if (written >= left)
+   goto error;
+
+   left -= written;
+   cur += written;
+
+   switch (pkt->type) {
+   case VSOCK_PACKET_TYPE_REQUEST:
+   case VSOCK_PACKET_TYPE_NEGOTIATE:
+   written = snprintf(cur, left, ", %s, size = %" FMT64 "u",
+  type_strings[pkt->type], pkt->u.size);
+   break;
+
+   case VSOCK_PACKET_TYPE_OFFER:
+   case VSOCK_PACKET_TYPE_ATTACH:
+   written = snprintf(cur, left, ", %s, handle = %u:%u",
+  type_strings[pkt->type],
+  VMCI_HANDLE_TO_CONTEXT_ID(pkt->u.handle),
+  VMCI_HANDLE_TO_RESOURCE_ID(pkt->u.handle));
+   break;
+
+   case VSOCK_PACKET_TYPE_WROTE:
+   case VSOCK_PACKET_TYPE_READ:
+   case VSOCK_PACKET_TYPE_RST:
+   written = snprintf(cur, left, ", %s", type_strings[pkt->type]);
+   break;
+   case VSOCK_PACKET_TYPE_SHUTDOWN: {
+   bool recv;
+   bool send;
+
+   recv = pkt->u.mode & RCV_SHUTDOWN;
+   send = pkt->u.mode & SEND_SHUTDOWN;
+   written = snprintf(cur, left, ", %s, mode = %c%c",
+  type_strings[pkt->type],
+  recv ? 'R' : ' ', send ? 'S' : ' ');
+   }
+   break;
+
+   case VSOCK_PACKET_TYPE_WAITING_WRITE:
+   case VSOCK_PACKET_TYPE_WAITING_READ:
+   written = snprintf(cur, left, ", %s, generation = %" FMT64 "u, "
+  "offset = %" FMT64 "u",
+  type_strings[pkt->type],
+  pkt->u.wait.generation, pkt->u.wait.offset);
+
+   break;
+
+   case VSOCK_PACKET_TYPE_REQUEST2:
+   case VSOCK_PACKET_TYPE_NEGOTIATE2:
+   written = snprintf(cur, left, ", %s, size = %" FMT64 "u, "
+  "proto = %u",
+  type_strings[pkt->type], pkt->u.size,
+  pkt->proto);
+   bre

[PATCH 4/6] VSOCK: statistics implementation.

2012-11-05 Thread George Zhang
VSOCK stats for VMCI Stream Sockets protocol.


Signed-off-by: George Zhang 
---
 net/vmw_vsock/stats.c |   37 
 net/vmw_vsock/stats.h |  219 +
 2 files changed, 256 insertions(+), 0 deletions(-)
 create mode 100644 net/vmw_vsock/stats.c
 create mode 100644 net/vmw_vsock/stats.h

diff --git a/net/vmw_vsock/stats.c b/net/vmw_vsock/stats.c
new file mode 100644
index 000..2d172d5
--- /dev/null
+++ b/net/vmw_vsock/stats.c
@@ -0,0 +1,37 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2009-2012 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * stats.c --
+ *
+ * Linux stats for the VMCI Stream Sockets protocol.
+ */
+
+#include 
+
+#include 
+#include   /* for NULL */
+#include 
+
+#include "af_vsock.h"
+#include "stats.h"
+
+#ifdef VSOCK_GATHER_STATISTICS
+u64 vsock_stats_ctl_pkt_count[VSOCK_PACKET_TYPE_MAX];
+u64 vsock_stats_consume_queue_hist[VSOCK_NUM_QUEUE_LEVEL_BUCKETS];
+u64 vsock_stats_produce_queue_hist[VSOCK_NUM_QUEUE_LEVEL_BUCKETS];
+atomic64_t vsock_stats_consume_total;
+atomic64_t vsock_stats_produce_total;
+#endif
diff --git a/net/vmw_vsock/stats.h b/net/vmw_vsock/stats.h
new file mode 100644
index 000..2f9d44c
--- /dev/null
+++ b/net/vmw_vsock/stats.h
@@ -0,0 +1,219 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2009-2012 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * stats.h --
+ *
+ * Stats functions for Linux vsock module.
+ */
+
+#ifndef __STATS_H__
+#define __STATS_H__
+
+#include 
+
+#include "vsock_common.h"
+#include "vsock_packet.h"
+
+/*
+ * Define VSOCK_GATHER_STATISTICS to turn on statistics gathering. Currently
+ * this consists of 3 types of stats: 1. The number of control datagram
+ * messages sent. 2. The level of queuepair fullness (in 10% buckets) whenever
+ * data is about to be enqueued or dequeued from the queuepair. 3. The total
+ * number of bytes enqueued/dequeued.
+ */
+
+#ifdef VSOCK_GATHER_STATISTICS
+
+#define VSOCK_NUM_QUEUE_LEVEL_BUCKETS 10
+extern u64 vsock_stats_ctl_pkt_count[VSOCK_PACKET_TYPE_MAX];
+extern u64 vsock_stats_consume_queue_hist[VSOCK_NUM_QUEUE_LEVEL_BUCKETS];
+extern u64 vsock_stats_produce_queue_hist[VSOCK_NUM_QUEUE_LEVEL_BUCKETS];
+extern atomic64_t vsock_stats_consume_total;
+extern atomic64_t vsock_stats_produce_total;
+
+#define VSOCK_STATS_STREAM_CONSUME_HIST(vsk)   \
+   vsock_vmci_stats_update_queue_bucket_count((vsk)->qpair,\
+   (vsk)->consume_size,\
+   vmci_qpair_consume_buf_ready((vsk)->qpair), \
+   vsock_stats_consume_queue_hist)
+#define VSOCK_STATS_STREAM_PRODUCE_HIST(vsk)   \
+   vsock_vmci_stats_update_queue_bucket_count((vsk)->qpair,\
+   (vsk)->produce_size,\
+   vmci_qpair_produce_buf_ready((vsk)->qpair), \
+   vsock_stats_produce_queue_hist)
+#define VSOCK_STATS_CTLPKT_LOG(pkt_type)   \
+   do {\
+   ++vsock_stats_ctl_pkt_count[pkt_type];  \
+   } while (0)
+#define VSOCK_STATS_STREAM_CONSUME(bytes)  \
+   atomic64_add(&vsock_stats_consume_total, bytes)
+#define VSOCK_STATS_STREAM_PRODUCE(bytes)  \
+   atomic64_add(&vsock_stats_produce_total, bytes)
+#define VSOCK_STATS_CTLPKT_DUMP_ALL() vsock_vmci_stats_ctl_pkt_dump_all()
+#define VSOCK_STATS_HIST_DUMP_ALL()   vsock_vmci_stats_hist_dump_all()
+#define VSOCK_STATS_TOTALS_DUMP_ALL() vsock_vmci_stats_totals_dump_all()
+#define VSOCK_STATS_RESET()   vsock_vmci_stats_reset()
+
+/*
+ *
+ * vsock_vmci_stats_update_queue_bucket_count --
+ *
+ * Given a queue, determine how much data is enqueued and add that to the
+ * specified queue level statistic bucket.
+ *
+ * Results: None.
+ *
+ * Side effects: None.
+ */
+
+static inline void
+vsock_vmci_stats_update_queue_bucket_count(v

[PATCH 3/6] VSOCK: notification implementation.

2012-11-05 Thread George Zhang
VSOCK control notifications for VMCI Stream Sockets protocol.


Signed-off-by: George Zhang 
---
 net/vmw_vsock/notify.c |  984 
 net/vmw_vsock/notify.h |  130 ++
 2 files changed, 1114 insertions(+), 0 deletions(-)
 create mode 100644 net/vmw_vsock/notify.c
 create mode 100644 net/vmw_vsock/notify.h

diff --git a/net/vmw_vsock/notify.c b/net/vmw_vsock/notify.c
new file mode 100644
index 000..5c69c7c
--- /dev/null
+++ b/net/vmw_vsock/notify.c
@@ -0,0 +1,984 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2009-2012 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * notify.c --
+ *
+ * Linux control notifications for the VMCI Stream Sockets protocol.
+ */
+
+#include 
+
+#include 
+#include   /* for NULL */
+#include 
+
+#include "notify.h"
+#include "af_vsock.h"
+
+#define PKT_FIELD(vsk, field_name) \
+   (vsk)->notify.pkt.field_name
+
+#define VSOCK_MAX_DGRAM_RESENDS   10
+
+/*
+ *
+ * vsock_vmci_notify_waiting_write --
+ *
+ * Determines if the conditions have been met to notify a waiting writer.
+ *
+ * Results: true if a notification should be sent, false otherwise.
+ *
+ * Side effects: None.
+ */
+
+static bool vsock_vmci_notify_waiting_write(vsock_vmci_sock *vsk)
+{
+#if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
+   bool retval;
+   u64 notify_limit;
+
+   if (!PKT_FIELD(vsk, peer_waiting_write))
+   return false;
+
+#ifdef VSOCK_OPTIMIZATION_FLOW_CONTROL
+   /*
+* When the sender blocks, we take that as a sign that the sender is
+* faster than the receiver. To reduce the transmit rate of the sender,
+* we delay the sending of the read notification by decreasing the
+* write_notify_window. The notification is delayed until the number of
+* bytes used in the queue drops below the write_notify_window.
+*/
+
+   if (!PKT_FIELD(vsk, peer_waiting_write_detected)) {
+   PKT_FIELD(vsk, peer_waiting_write_detected) = true;
+   if (PKT_FIELD(vsk, write_notify_window) < PAGE_SIZE) {
+   PKT_FIELD(vsk, write_notify_window) =
+   PKT_FIELD(vsk, write_notify_min_window);
+   } else {
+   PKT_FIELD(vsk, write_notify_window) -= PAGE_SIZE;
+   if (PKT_FIELD(vsk, write_notify_window) <
+   PKT_FIELD(vsk, write_notify_min_window))
+   PKT_FIELD(vsk, write_notify_window) =
+   PKT_FIELD(vsk, write_notify_min_window);
+
+   }
+   }
+   notify_limit = vsk->consume_size - PKT_FIELD(vsk, write_notify_window);
+#else
+   notify_limit = 0;
+#endif
+
+   /*
+* For now we ignore the wait information and just see if the free
+* space exceeds the notify limit.  Note that improving this function
+* to be more intelligent will not require a protocol change and will
+* retain compatibility between endpoints with mixed versions of this
+* function.
+*
+* The notify_limit is used to delay notifications in the case where
+* flow control is enabled. Below the test is expressed in terms of
+* free space in the queue: if free_space > ConsumeSize -
+* write_notify_window then notify An alternate way of expressing this
+* is to rewrite the expression to use the data ready in the receive
+* queue: if write_notify_window > bufferReady then notify as
+* free_space == ConsumeSize - bufferReady.
+*/
+   retval = vmci_qpair_consume_free_space(vsk->qpair) > notify_limit;
+#ifdef VSOCK_OPTIMIZATION_FLOW_CONTROL
+   if (retval) {
+   /*
+* Once we notify the peer, we reset the detected flag so the
+* next wait will again cause a decrease in the window size.
+*/
+
+   PKT_FIELD(vsk, peer_waiting_write_detected) = false;
+   }
+#endif
+   return retval;
+#else
+   return true;
+#endif
+}
+
+/*
+ *
+ * vsock_vmci_notify_waiting_read --
+ *
+ * Determines if the conditions have been met to notify a waiting reader.
+ *
+ * Results: true if a notification should be sent, false otherwise.
+ *
+ * Side effects: None.
+ */
+
+static bool vsock_vmci_notify_waiting_read(vsock_vmci_sock *vsk)
+{
+#if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
+   if (!PKT_FIELD(vsk, peer_waiting_read))
+   ret

[PATCH 2/6] VSOCK: vsock address implementaion.

2012-11-05 Thread George Zhang
VSOCK linux address code implementation.


Signed-off-by: George Zhang 
---
 net/vmw_vsock/vsock_addr.c |  264 
 net/vmw_vsock/vsock_addr.h |   40 +++
 2 files changed, 304 insertions(+), 0 deletions(-)
 create mode 100644 net/vmw_vsock/vsock_addr.c
 create mode 100644 net/vmw_vsock/vsock_addr.h

diff --git a/net/vmw_vsock/vsock_addr.c b/net/vmw_vsock/vsock_addr.c
new file mode 100644
index 000..c93a174
--- /dev/null
+++ b/net/vmw_vsock/vsock_addr.c
@@ -0,0 +1,264 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2007-2012 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+/*
+ * vsockAddr.c --
+ *
+ * VSockets address implementation.
+ */
+
+/*
+ * These includes come before vsockCommon.h to ensure that VMware's ASSERT
+ * macro is used instead of Linux's irda.h definition.
+ */
+#include 
+#include 
+#include   /* for NULL */
+#include 
+
+#include "vsock_common.h"
+
+/*
+ *
+ * vsock_addr_init --
+ *
+ * Initialize the given address with the given context id and port. This will
+ * clear the address, set the correct family, and add the given values.
+ *
+ * Results: None.
+ *
+ * Side effects: None.
+ */
+
+void vsock_addr_init(struct sockaddr_vm *addr, u32 cid, u32 port)
+{
+   memset(addr, 0, sizeof *addr);
+
+   addr->svm_family = AF_VSOCK;
+   addr->svm_cid = cid;
+   addr->svm_port = port;
+
+   BUG_ON(vsock_addr_validate(addr) != 0);
+}
+
+/*
+ *
+ * vsock_addr_validate --
+ *
+ * Try to validate the given address.  The address must not be null and must
+ * have the correct address family.  Any reserved fields must be zero.
+ *
+ * Results: 0 on success, EFAULT if the address is null, EAFNOSUPPORT if the
+ * address is of the wrong family, and EINVAL if the reserved fields are not
+ * zero.
+ *
+ * Side effects: None.
+ */
+
+int vsock_addr_validate(const struct sockaddr_vm *addr)
+{
+   if (!addr)
+   return -EFAULT;
+
+   if (addr->svm_family != AF_VSOCK)
+   return -EAFNOSUPPORT;
+
+   if (addr->svm_zero[0] != 0)
+   return -EINVAL;
+
+   return 0;
+}
+
+/*
+ *
+ * vsock_addr_bound --
+ *
+ * Determines whether the provided address is bound.
+ *
+ * Results: TRUE if the address structure is bound, FALSE otherwise.
+ *
+ * Side effects: None.
+ */
+
+bool vsock_addr_bound(const struct sockaddr_vm *addr)
+{
+   BUG_ON(!addr);
+
+   return addr->svm_port != VMADDR_PORT_ANY;
+}
+
+/*
+ *
+ * vsock_addr_unbind --
+ *
+ * Unbind the given addresss.
+ *
+ * Results: None.
+ *
+ * Side effects: None.
+ */
+
+void vsock_addr_unbind(struct sockaddr_vm *addr)
+{
+   vsock_addr_init(addr, VMADDR_CID_ANY, VMADDR_PORT_ANY);
+}
+
+/*
+ *
+ * vsock_addr_equals_addr --
+ *
+ * Determine if the given addresses are equal.
+ *
+ * Results: TRUE if the addresses are equal, FALSE otherwise.
+ *
+ * Side effects: None.
+ */
+
+bool vsock_addr_equals_addr(const struct sockaddr_vm *addr,
+   const struct sockaddr_vm *other)
+{
+   BUG_ON(vsock_addr_validate(addr) != 0);
+   BUG_ON(vsock_addr_validate(other) != 0);
+
+   return addr->svm_cid == other->svm_cid &&
+   addr->svm_port == other->svm_port;
+}
+
+/*
+ *
+ * vsock_addr_equals_addr_any --
+ *
+ * Determine if the given addresses are equal. Will accept either an exact
+ * match or one where the rids match and that either the cids match or are set
+ * to VMADDR_CID_ANY.
+ *
+ * Results: TRUE if the addresses are equal, FALSE otherwise.
+ *
+ * Side effects: None.
+ */
+
+bool vsock_addr_equals_addr_any(const struct sockaddr_vm *addr,
+   const struct sockaddr_vm *other)
+{
+   BUG_ON(vsock_addr_validate(addr) != 0);
+   BUG_ON(vsock_addr_validate(other) != 0);
+
+   return (addr->svm_cid == VMADDR_CID_ANY ||
+   other->svm_cid == VMADDR_CID_ANY ||
+   addr->svm_cid == other->svm_cid) &&
+  addr->svm_port == other->svm_port;
+}
+
+/*
+ *
+ * vsock_addr_equals_handle_port --
+ *
+ * Determines if the given address matches the given handle and port.
+ *
+ * Results: TRUE if the address matches the handle and port, FALSE otherwise.
+ *
+ * Side effects: None.
+ */
+
+bool vsock_addr_equals_handle_port(const struct sockaddr_vm *addr,
+  struct vmci_handle handle, u32 port)
+{
+   BUG_ON(vsock_addr_validate(addr) != 0);
+
+   return addr->svm_cid == VMCI_HANDLE_TO_CONTEXT_ID(handle) &&
+   addr->svm_por

[PATCH 0/6] VSOCK for Linux upstreaming

2012-11-05 Thread George Zhang
* * *
This series of VSOCK linux upstreaming patches include latest udpate from
VMware.

Summary of changes:
- Add include/linux/socket.h for AF_VSOCK.
- Cleanup some comments.
- Cleanup makefiles.



* * *

In an effort to improve the out-of-the-box experience with Linux
kernels for VMware users, VMware is working on readying the Virtual
Machine Communication Interface (vmw_vmci) and VMCI Sockets (VSOCK)
(vmw_vsock) kernel modules for inclusion in the Linux kernel. The
purpose of this post is to acquire feedback on the vmw_vsock kernel
module. The vmw_vmci kernel module has been presented in an early post.


* * *

VMCI Sockets allows virtual machines to communicate with host kernel
modules and the VMware hypervisors. VMCI Sockets kernel module has
dependency on VMCI kernel module. User level applications both in
a virtual machine and on the host can use vmw_vmci through VMCI
Sockets API which facilitates fast and efficient communication
between guest virtual machines and their host. A socket
address family designed to be compatible with UDP and TCP at the
interface level. Today, VMCI and VMCI Sockets are used by the VMware
shared folders (HGFS) and various VMware Tools components inside the
guest for zero-config, network-less access to VMware host services. In
addition to this, VMware's users are using VMCI Sockets for various
applications, where network access of the virtual machine is
restricted or non-existent. Examples of this are VMs communicating
with device proxies for proprietary hardware running as host
applications and automated testing of applications running within
virtual machines.

The VMware VMCI Sockets are similar to other socket types, like
Berkeley UNIX socket interface. The VMCI sockets module supports
both connection-oriented stream sockets like TCP, and connectionless
datagram sockets like UDP. The VSOCK protocol family is defined as
"AF_VSOCK" and the socket operations split for SOCK_DGRAM and
SOCK_STREAM.

For additional information about the use of VMCI and in particular
VMCI Sockets, please refer to the VMCI Socket Programming Guide
available at https://www.vmware.com/support/developer/vmci-sdk/.



---

George Zhang (6):
  VSOCK: vsock protocol implementation.
  VSOCK: vsock address implementaion.
  VSOCK: notification implementation.
  VSOCK: statistics implementation.
  VSOCK: utility functions.
  VSOCK: header and config files.


 include/linux/socket.h  |4 
 net/Kconfig |1 
 net/Makefile|1 
 net/vmw_vsock/Kconfig   |   14 
 net/vmw_vsock/Makefile  |4 
 net/vmw_vsock/af_vsock.c| 4165 +++
 net/vmw_vsock/af_vsock.h|  179 ++
 net/vmw_vsock/notify.c  |  984 
 net/vmw_vsock/notify.h  |  130 +
 net/vmw_vsock/notify_qstate.c   |  627 +
 net/vmw_vsock/stats.c   |   37 
 net/vmw_vsock/stats.h   |  219 ++
 net/vmw_vsock/util.c|  626 +
 net/vmw_vsock/util.h|  312 +++
 net/vmw_vsock/vmci_sockets.h|  517 
 net/vmw_vsock/vmci_sockets_packet.h |  106 +
 net/vmw_vsock/vsock_addr.c  |  264 ++
 net/vmw_vsock/vsock_addr.h  |   40 
 net/vmw_vsock/vsock_common.h|  130 +
 net/vmw_vsock/vsock_packet.h|  131 +
 net/vmw_vsock/vsock_version.h   |   29 
 21 files changed, 8519 insertions(+), 1 deletions(-)
 create mode 100644 net/vmw_vsock/Kconfig
 create mode 100644 net/vmw_vsock/Makefile
 create mode 100644 net/vmw_vsock/af_vsock.c
 create mode 100644 net/vmw_vsock/af_vsock.h
 create mode 100644 net/vmw_vsock/notify.c
 create mode 100644 net/vmw_vsock/notify.h
 create mode 100644 net/vmw_vsock/notify_qstate.c
 create mode 100644 net/vmw_vsock/stats.c
 create mode 100644 net/vmw_vsock/stats.h
 create mode 100644 net/vmw_vsock/util.c
 create mode 100644 net/vmw_vsock/util.h
 create mode 100644 net/vmw_vsock/vmci_sockets.h
 create mode 100644 net/vmw_vsock/vmci_sockets_packet.h
 create mode 100644 net/vmw_vsock/vsock_addr.c
 create mode 100644 net/vmw_vsock/vsock_addr.h
 create mode 100644 net/vmw_vsock/vsock_common.h
 create mode 100644 net/vmw_vsock/vsock_packet.h
 create mode 100644 net/vmw_vsock/vsock_version.h

-- 
Signature
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] virtio-mmio: Fix irq parsing in command line parameter

2012-11-05 Thread Lee Jones
On Mon, 05 Nov 2012, Pawel Moll wrote:

> On Mon, 2012-11-05 at 13:44 +, Lee Jones wrote:
> > On Mon, 05 Nov 2012, Pawel Moll wrote:
> > 
> > > On 64-bit machines resource_size_t is a 64-bit value, while
> > > sscanf() format for this argument was defined as "%u". Fixed
> > > by using an intermediate local value of a known length.
> > > 
> > > Also added cleaned up the resource creation and adde extra
> > > comments to make the parameters parsing easier to follow.
> > > 
> > > Reported-by: Lee Jones 
> > > Signed-off-by: Pawel Moll 
> > > ---
> > >  drivers/virtio/virtio_mmio.c |   26 ++
> > >  1 file changed, 18 insertions(+), 8 deletions(-)
> > 
> > Resorted to poaching now have we Pawel? ;)
> 
> Sure thing - the poached eggs are my firm favourite :-P ;-)
> 
> But seriously speaking - it's an old patch (all the comments and
> resources creation, the IRQ stuff is a new thing :-), but never had
> enough motivation to push it out...

I believe you, many would not. ;)

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH] virtio-mmio: Fix irq parsing in command line parameter

2012-11-05 Thread Pawel Moll
On Mon, 2012-11-05 at 13:44 +, Lee Jones wrote:
> On Mon, 05 Nov 2012, Pawel Moll wrote:
> 
> > On 64-bit machines resource_size_t is a 64-bit value, while
> > sscanf() format for this argument was defined as "%u". Fixed
> > by using an intermediate local value of a known length.
> > 
> > Also added cleaned up the resource creation and adde extra
> > comments to make the parameters parsing easier to follow.
> > 
> > Reported-by: Lee Jones 
> > Signed-off-by: Pawel Moll 
> > ---
> >  drivers/virtio/virtio_mmio.c |   26 ++
> >  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> Resorted to poaching now have we Pawel? ;)

Sure thing - the poached eggs are my firm favourite :-P ;-)

But seriously speaking - it's an old patch (all the comments and
resources creation, the IRQ stuff is a new thing :-), but never had
enough motivation to push it out...

Cheers!

Paweł



___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH] virtio-mmio: Fix irq parsing in command line parameter

2012-11-05 Thread Lee Jones
On Mon, 05 Nov 2012, Pawel Moll wrote:

> On 64-bit machines resource_size_t is a 64-bit value, while
> sscanf() format for this argument was defined as "%u". Fixed
> by using an intermediate local value of a known length.
> 
> Also added cleaned up the resource creation and adde extra
> comments to make the parameters parsing easier to follow.
> 
> Reported-by: Lee Jones 
> Signed-off-by: Pawel Moll 
> ---
>  drivers/virtio/virtio_mmio.c |   26 ++
>  1 file changed, 18 insertions(+), 8 deletions(-)

Resorted to poaching now have we Pawel? ;)

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH] virtio-mmio: Fix irq parsing in command line parameter

2012-11-05 Thread Pawel Moll
On 64-bit machines resource_size_t is a 64-bit value, while
sscanf() format for this argument was defined as "%u". Fixed
by using an intermediate local value of a known length.

Also added cleaned up the resource creation and adde extra
comments to make the parameters parsing easier to follow.

Reported-by: Lee Jones 
Signed-off-by: Pawel Moll 
---
 drivers/virtio/virtio_mmio.c |   26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 6b1b7e1..0d08843 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -521,25 +521,35 @@ static int vm_cmdline_set(const char *device,
int err;
struct resource resources[2] = {};
char *str;
-   long long int base;
+   long long int base, size;
+   unsigned int irq;
int processed, consumed = 0;
struct platform_device *pdev;
 
-   resources[0].flags = IORESOURCE_MEM;
-   resources[1].flags = IORESOURCE_IRQ;
-
-   resources[0].end = memparse(device, &str) - 1;
+   /* Get "size" part of the command line parameter */
+   size = memparse(device, &str) - 1;
 
+   /* Get "@:[:]" chunks */
processed = sscanf(str, "@%lli:%u%n:%d%n",
-   &base, &resources[1].start, &consumed,
+   &base, &irq, &consumed,
&vm_cmdline_id, &consumed);
 
+   /*
+* sscanf() processes 3 chunks if "" is given, 2 if not;
+* also there must be no extra characters after the last
+* chunk, so str[consumed] should be '\0'
+*/
if (processed < 2 || processed > 3 || str[consumed])
return -EINVAL;
 
+   /* Memory resource */
+   resources[0].flags = IORESOURCE_MEM;
resources[0].start = base;
-   resources[0].end += base;
-   resources[1].end = resources[1].start;
+   resources[0].end = base + size;
+
+   /* Interrupt resource */
+   resources[1].flags = IORESOURCE_IRQ;
+   resources[1].start = resources[1].end = irq;
 
if (!vm_cmdline_parent_registered) {
err = device_register(&vm_cmdline_parent);
-- 
1.7.10.4


___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 6/9] virtio_mmio: Cast &resources[1].start to ‘unsigned int *’ to rid compiler warning

2012-11-05 Thread Pawel Moll
On Mon, 2012-11-05 at 08:21 +, Lee Jones wrote:
> > >   processed = sscanf(str, "@%lli:%u%n:%d%n",
> > > - &base, &resources[1].start, &consumed,
> > > + &base, (unsigned int *)&resources[1].start, &consumed,
> > >   &vm_cmdline_id, &consumed);
> > 
> > This suppresses a valid warning, leaving our code no less wrong than
> > before.  But now it's silently wrong!
> > 
> > Do you want to try again?
> 
> For sure I'll try again.
> 
> How does `s/%u/%p/` suit?

sscanf doesn't do "%p"... The only reasonable way of fixing this is a
intermediate local variable - will post a patch in a second.

Thanks for spotting this!

Paweł


___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCHv8 0/3]virtio_console: Add rproc_serial driver

2012-11-05 Thread Amit Shah
On (Mon) 05 Nov 2012 [11:31:24], Amit Shah wrote:
> On (Mon) 05 Nov 2012 [09:11:45], Rusty Russell wrote:
> > Sjur Brændeland  writes:
> > 
> > > From: Sjur Brændeland 
> > >
> > > This patch-set introduces a new virtio type "rproc_serial" for 
> > > communicating
> > > with remote processors over shared memory. The driver depends on the
> > > the remoteproc framework. As preparation for introducing "rproc_serial"
> > > I've done a refactoring of the transmit buffer handling.
> > >
> > > Changes since v7:
> > > - Rebased to virtio-next branch.
> > > - Removed extra added lines.
> > > - Removed superfluous checks before calling reclaim_dma_bufs().
> > > - Rusty raised some question regarding garbage collection of the
> > >   out-vq, so I moved this into a separate patch.
> > 
> > OK, I'm not sure that WARN_ON won't fire, but that's not all that
> > harmful.
> 
> Sjur said he'll send out a respin for this; can you wait for his v8?

Er, v9.

Amit
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCHv8 0/3]virtio_console: Add rproc_serial driver

2012-11-05 Thread Amit Shah
On (Mon) 05 Nov 2012 [09:11:45], Rusty Russell wrote:
> Sjur Brændeland  writes:
> 
> > From: Sjur Brændeland 
> >
> > This patch-set introduces a new virtio type "rproc_serial" for communicating
> > with remote processors over shared memory. The driver depends on the
> > the remoteproc framework. As preparation for introducing "rproc_serial"
> > I've done a refactoring of the transmit buffer handling.
> >
> > Changes since v7:
> > - Rebased to virtio-next branch.
> > - Removed extra added lines.
> > - Removed superfluous checks before calling reclaim_dma_bufs().
> > - Rusty raised some question regarding garbage collection of the
> >   out-vq, so I moved this into a separate patch.
> 
> OK, I'm not sure that WARN_ON won't fire, but that's not all that
> harmful.

Sjur said he'll send out a respin for this; can you wait for his v8?

Amit
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH 6/9] virtio_mmio: Cast &resources[1].start to ‘unsigned int *’ to rid compiler warning

2012-11-05 Thread Lee Jones
On Mon, 05 Nov 2012, Rusty Russell wrote:

> Lee Jones  writes:
> > drivers/virtio/virtio_mmio.c: In function ‘vm_cmdline_set’:
> > drivers/virtio/virtio_mmio.c:535:4: warning: format ‘%u’ expects argument 
> > of type ‘unsigned int *’, but argument 4 has type ‘resource_size_t *’ 
> > [-Wformat]
> >
> > Cc: Rusty Russell 
> > Cc: virtualization@lists.linux-foundation.org
> > Signed-off-by: Lee Jones 
> > ---
> >  drivers/virtio/virtio_mmio.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> > index 6b1b7e1..077e9ca 100644
> > --- a/drivers/virtio/virtio_mmio.c
> > +++ b/drivers/virtio/virtio_mmio.c
> > @@ -531,7 +531,7 @@ static int vm_cmdline_set(const char *device,
> > resources[0].end = memparse(device, &str) - 1;
> >  
> > processed = sscanf(str, "@%lli:%u%n:%d%n",
> > -   &base, &resources[1].start, &consumed,
> > +   &base, (unsigned int *)&resources[1].start, &consumed,
> > &vm_cmdline_id, &consumed);
> 
> This suppresses a valid warning, leaving our code no less wrong than
> before.  But now it's silently wrong!
> 
> Do you want to try again?

For sure I'll try again.

How does `s/%u/%p/` suit?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization