* Re: [Qemu-devel] Re: [PATCH] Implement a virtio GPU transport
From: Anthony Liguori @ 2010-11-12 13:21 UTC (permalink / raw)
To: Ian Molton
Cc: QEMU Developers, Rusty Russell, linux-kernel, virtualization,
virtualization, Alon Levy, Avi Kivity
In-Reply-To: <4CDD2F9A.7000702@collabora.co.uk>
On 11/12/2010 06:14 AM, Ian Molton wrote:
> On 10/11/10 17:47, Anthony Liguori wrote:
>> On 11/10/2010 11:22 AM, Ian Molton wrote:
>>> Ping ?
>>
>> I think the best way forward is to post patches.
>
> I posted links to the git trees. I can post patches, but they are
> *large*. Do you really want me to post them?
Yes, and they have to be split up into something reviewable.
>
>> To summarize what I was trying to express in the thread, I think this is
>> not the right long term architecture but am not opposed to it as a short
>> term solution. I think having a new virtio device is a bad design choice
>> but am not totally opposed to it.
>
> Ok! (I agree (that this should be a short term solution) :) )
>
>> you want to go for the path of integration, you're going to have to fix
>> all of the coding style issues and make the code fit into QEMU. Dropping
>> a bunch of junk into target-i386/ is not making the code fit into QEMU.
>
> I agree. how about hw/gl for the renderer and hw/ for the virtio module?
That would be fine.
>> If you post just what you have now in patch form, I can try to provide
>> more concrete advice ignoring the coding style problems.
>
> I can post patches, although I dont think LKML would appreciate the
> volume! I can post them to the qemu list if you do.
Yes, qemu is where I was suggesting you post them.
Regards,
Anthony Liguori
> -Ian
^ permalink raw reply
* Re: [PATCH 04/20] x86/ticketlock: make large and small ticket versions of spin_lock the same
From: Srivatsa Vaddagiri @ 2010-11-12 12:19 UTC (permalink / raw)
To: Jeremy Fitzhardinge
Cc: Nick Piggin, Xen-devel, Peter Zijlstra, Linux Kernel Mailing List,
Jan Beulich, Linux Virtualization, Jeremy Fitzhardinge,
Avi Kivity, H. Peter Anvin
In-Reply-To: <5b3cbff3a6e96a085651f140a0525be80a4df8ba.1288794124.git.jeremy.fitzhardinge@citrix.com>
On Wed, Nov 03, 2010 at 10:59:45AM -0400, Jeremy Fitzhardinge wrote:
> Make the bulk of __ticket_spin_lock look identical for large and small
> number of cpus.
[snip]
> #if (NR_CPUS < 256)
> static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
> {
> - register union {
> - struct __raw_tickets tickets;
> - unsigned short slock;
> - } inc = { .slock = 1 << TICKET_SHIFT };
> + register struct __raw_tickets inc = { .tail = 1 };
[snip]
> #else
> static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
> {
> - unsigned inc = 1 << TICKET_SHIFT;
> - __ticket_t tmp;
> + register struct __raw_tickets inc = { .tickets.tail = 1 };
s/.tickets//?
Otherwise I get a compile error for NR_CPUS > 256, with just 4 patches applied.
- vatsa
^ permalink raw reply
* Re: [Qemu-devel] Re: [PATCH] Implement a virtio GPU transport
From: Ian Molton @ 2010-11-12 12:14 UTC (permalink / raw)
To: Anthony Liguori
Cc: QEMU Developers, Rusty Russell, linux-kernel, virtualization,
virtualization, Alon Levy, Avi Kivity
In-Reply-To: <4CDADACC.4070405@codemonkey.ws>
On 10/11/10 17:47, Anthony Liguori wrote:
> On 11/10/2010 11:22 AM, Ian Molton wrote:
>> Ping ?
>
> I think the best way forward is to post patches.
I posted links to the git trees. I can post patches, but they are
*large*. Do you really want me to post them?
> To summarize what I was trying to express in the thread, I think this is
> not the right long term architecture but am not opposed to it as a short
> term solution. I think having a new virtio device is a bad design choice
> but am not totally opposed to it.
Ok! (I agree (that this should be a short term solution) :) )
> you want to go for the path of integration, you're going to have to fix
> all of the coding style issues and make the code fit into QEMU. Dropping
> a bunch of junk into target-i386/ is not making the code fit into QEMU.
I agree. how about hw/gl for the renderer and hw/ for the virtio module?
> If you post just what you have now in patch form, I can try to provide
> more concrete advice ignoring the coding style problems.
I can post patches, although I dont think LKML would appreciate the
volume! I can post them to the qemu list if you do.
-Ian
^ permalink raw reply
* Re: [PATCH]: An implementation of HyperV KVP functionality
From: Greg KH @ 2010-11-11 21:19 UTC (permalink / raw)
To: Ky Srinivasan; +Cc: devel, Virtualization, Haiyang Zhang, Greg KH
In-Reply-To: <4CDBE98E02000030000902C9@novprvoes0310.provo.novell.com>
On Thu, Nov 11, 2010 at 01:03:10PM -0700, Ky Srinivasan wrote:
> +/*
> + * Array of keys we support in Linux.
Not really, you can support "any" number of keys as the kernel shouldn't
care, or did I get it wrong?
> + *
> + */
> +#define KVP_MAX_KEY 10
> +#define KVP_LIC_VERSION 1
Um, this is a nice magic number, care to explain it a bit more?
> +static char *kvp_keys[KVP_MAX_KEY] = {"FullyQualifiedDomainName",
> + "IntegrationServicesVersion",
Looks like it matches up with this, right? You might want to make that
a bit more "tied" together.
> + case (KVP_LIC_VERSION):
> + kvp_transaction_active = true;
> + kvp_respond_to_host(kvp_data->index,
> + HV_DRV_VERSION);
Why are you doing this in the kernel? Why not do it from userspace like
all other messages?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH]: An implementation of HyperV KVP functionality
From: Greg KH @ 2010-11-11 21:15 UTC (permalink / raw)
To: Ky Srinivasan; +Cc: devel, Virtualization, Haiyang Zhang, Greg KH
In-Reply-To: <4CDBE98E02000030000902C9@novprvoes0310.provo.novell.com>
On Thu, Nov 11, 2010 at 01:03:10PM -0700, Ky Srinivasan wrote:
> +/*
> + * An implementation of key value pair (KVP) functionality for Linux.
> + *
> + *
> + * Copyright (C) 2010, Novell, Inc.
> + * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
This is all that is needed.
> + *
> + * 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, GOOD TITLE or
> + * NON INFRINGEMENT. See the GNU General Public License for more
> + * details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
You can delete this chunk.
> +/*
> + * KVP protocol: The user mode component first registers with the
> + * the kernel component. Subsequently, the kernel component requests, data
> + * for the specified keys. In response to this message the user mode component
> + * fills in the value corresponding to the specified key. We overload the
> + * sequence field in the cn_msg header to define our KVP message types.
> + *
> + * XXXKYS: Have a shared header file between the user and kernel (TODO)
> + */
> +
> +enum kvp_op {
> + KVP_REGISTER = 0, /* Register the user mode component */
> + KVP_KERNEL_GET,/*Kernel is requesting the value for the specified key*/
> + KVP_KERNEL_SET, /*Kernel is providing the value for the specified key*/
> + KVP_USER_GET, /*User is requesting the value for the specified key*/
> + KVP_USER_SET /*User is providing the value for the specified key*/
> +};
As these values are shared between the kernel and userspace, you should
specifically define them.
Also, your spaces with the /* stuff is incorrect.
And, "KVP"? That's very generic, how about, "HYPERV_KVP_..." instead?
That fits the global namespace much better.
s/kvp_op/hyperv_kvp_op/ as well.
> +#define KVP_KEY_SIZE 512
> +#define KVP_VALUE_SIZE 2048
> +
> +
> +typedef struct kvp_msg {
> + __u32 kvp_key; /* Key */
> + __u8 kvp_value[0]; /* Corresponding value */
> +} kvp_msg_t;
I thought that kvp_value was really KVP_VALUE_SIZE?
And no typedefs, you did run your code through checkpatch.pl, right?
Why ignore the stuff it spits back at you?
> +static char *kvp_keys[KVP_MAX_KEY] = {"FullyQualifiedDomainName",
> + "IntegrationServicesVersion",
> + "NetworkAddressIPv4",
> + "NetworkAddressIPv6",
> + "OSBuildNumber",
> + "OSName",
> + "OSMajorVersion",
> + "OSMinorVersion",
> + "OSVersion",
> + "ProcessorArchitecture",
> + };
Why list these at all, as more might come in the future, and the kernel
really doesn't care about them, right?
> +int
> +kvp_init(void)
All of your global symbols should have "hyperv_" on the front of them.
> --- linux.trees.git.orig/drivers/staging/hv/Makefile 2010-11-10 14:01:55.000000000 -0500
> +++ linux.trees.git/drivers/staging/hv/Makefile 2010-11-11 11:24:54.000000000 -0500
> @@ -2,7 +2,7 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o hv_t
> obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o
> obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o
> obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o
> -obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o
> +obj-$(CONFIG_HYPERV_UTILS) += hv_util.o
Ick, you just renamed the kernel module. Did you really mean to do
this? What tools are now going to break because you did this? (I'm
thinking installers here...)
>
> hv_vmbus-y := vmbus_drv.o osd.o \
> vmbus.o hv.o connection.o channel.o \
> @@ -10,3 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
> hv_storvsc-y := storvsc_drv.o storvsc.o
> hv_blkvsc-y := blkvsc_drv.o blkvsc.o
> hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
> +hv_util-y := hv_utils.o kvp.o
> Index: linux.trees.git/drivers/staging/hv/kvp.h
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ linux.trees.git/drivers/staging/hv/kvp.h 2010-11-10 14:03:47.000000000 -0500
hyperv_kvp.h as this is going to be a global header file, right?
> +typedef enum {
> + ICKvpExchangeOperationGet = 0,
> + ICKvpExchangeOperationSet,
> + ICKvpExchangeOperationDelete,
> + ICKvpExchangeOperationEnumerate,
> + ICKvpExchangeOperationCount /* Number of operations, must be last. */
> +} IC_KVP_EXCHANGE_OPERATION;
> +
> +typedef enum {
> + ICKvpExchangePoolExternal = 0,
> + ICKvpExchangePoolGuest,
> + ICKvpExchangePoolAuto,
> + ICKvpExchangePoolAutoExternal,
> + ICKvpExchangePoolInternal,
> + ICKvpExchangePoolCount /* Number of pools, must be last. */
> +} IC_KVP_EXCHANGE_POOL;
> +
> +typedef struct ic_kvp_hdr {
> + u8 operation;
> + u8 pool;
> +} ic_kvp_hdr_t;
> +
> +typedef struct ic_kvp_exchg_msg_value {
> + u32 value_type;
> + u32 key_size;
> + u32 value_size;
> + u8 key[IC_KVP_EXCHANGE_MAX_KEY_SIZE];
> + u8 value[IC_KVP_EXCHANGE_MAX_VALUE_SIZE];
> +} ic_kvp_exchg_msg_value_t;
> +
> +typedef struct ic_kvp__msg_enumerate {
> + u32 index;
> + ic_kvp_exchg_msg_value_t data;
> +} ic_kvp_msg_enumerate_t;
> +
> +typedef struct ic_kvp_msg {
> + ic_kvp_hdr_t kvp_hdr;
> + ic_kvp_msg_enumerate_t kvp_data;
> +} ic_kvp_msg_t;
Again, no typedefs, and fix up the names of these structures to be
understandable :)
> --- linux.trees.git.orig/include/linux/connector.h 2010-11-09 17:22:15.000000000 -0500
> +++ linux.trees.git/include/linux/connector.h 2010-11-11 13:14:52.000000000 -0500
> @@ -42,8 +42,9 @@
> #define CN_VAL_DM_USERSPACE_LOG 0x1
> #define CN_IDX_DRBD 0x8
> #define CN_VAL_DRBD 0x1
> +#define CN_KVP_IDX 0x9 /* MSFT KVP functionality */
Did you reserve this number with anyone? Who?
> -#define CN_NETLINK_USERS 8
> +#define CN_NETLINK_USERS 10
Are you sure you incremented this properly?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH]: An implementation of HyperV KVP functionality
From: Stephen Hemminger @ 2010-11-11 20:49 UTC (permalink / raw)
To: Ky Srinivasan; +Cc: devel, Virtualization, Haiyang Zhang, Greg KH
In-Reply-To: <4CDBE98E02000030000902C9@novprvoes0310.provo.novell.com>
On Thu, 11 Nov 2010 13:03:10 -0700
"Ky Srinivasan" <ksrinivasan@novell.com> wrote:
> +static char *kvp_keys[KVP_MAX_KEY] = {"FullyQualifiedDomainName",
> + "IntegrationServicesVersion",
> + "NetworkAddressIPv4",
> + "NetworkAddressIPv6",
> + "OSBuildNumber",
> + "OSName",
> + "OSMajorVersion",
> + "OSMinorVersion",
> + "OSVersion",
> + "ProcessorArchitecture",
> + };
Minor nit:
static const char *kvp_keys[KVP_MAX_KEY] = {
"FullQualifiedDomainName",
...
+/*
+ * Global state maintained for transaction that is being processed.
+ * Note that only one transaction can be active at any point in time.
+ *
+ * This state is set when we receive a request from the host; we
+ * cleanup this state when the transaction is completed - when we respond
+ * to the host with the key value.
+ */
+
+static u8 *recv_buffer; /* the receive buffer that we allocated */
+static int recv_len; /* number of bytes received. */
+static struct vmbus_channel *recv_channel; /*chn on which we got the request*/
+static u64 recv_req_id; /* request ID. */
+static int kvp_current_index;
+
I would put all the state variables for the transaction in one
structure,
+static void kvp_timer_func(unsigned long __data)
+{
+ u32 key = *((u32 *)__data);
+ /*
+ * If the timer fires, the user-mode component has not responded;
+ * process the pending transaction.
+ */
+ kvp_respond_to_host(key, "Guest timed out");
+}
delayed_work is sometimes better for things like this, since it
runs in user context and can sleep.
+ case (KVP_MAX_KEY):
+ /*
+ * We don't support this key
+ * and any key beyond this.
+ */
+ icmsghdrp->status = HV_E_FAIL;
+ goto callback_done;
+
case labels do not need parens
^ permalink raw reply
* [PATCH]: An implementation of HyperV KVP functionality
From: Ky Srinivasan @ 2010-11-11 20:03 UTC (permalink / raw)
To: devel, Virtualization; +Cc: Haiyang Zhang, Greg KH
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
I am enclosing a patch that implements the KVP (Key Value Pair) functionality for Linux guests on HyperV. This functionality allows Microsoft Management stack to query information from the guest. This functionality is implemented in two parts: (a) A kernel component that communicates with the host and (b) A user level daemon that implements data gathering. The attached patch (kvp.patch) implements the kernel component. I am also attaching the code for the user-level daemon (kvp_daemon.c) for reference.
Regards,
K. Y
[-- Attachment #2: kvp.patch --]
[-- Type: text/plain, Size: 18054 bytes --]
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: An implementation of key/value pair feature (KVP) for Linux
on HyperV.
Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Index: linux.trees.git/drivers/staging/hv/kvp.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/kvp.c 2010-11-11 13:45:17.000000000 -0500
@@ -0,0 +1,404 @@
+/*
+ * An implementation of key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include <linux/net.h>
+#include <linux/nls.h>
+#include <linux/connector.h>
+
+#include "logging.h"
+#include "osd.h"
+#include "vmbus.h"
+#include "vmbus_packet_format.h"
+#include "vmbus_channel_interface.h"
+#include "version_info.h"
+#include "channel.h"
+#include "vmbus_private.h"
+#include "vmbus_api.h"
+#include "utils.h"
+#include "kvp.h"
+
+
+/*
+ *
+ * The following definitions are shared with the user-mode component; do not
+ * change any of this without making the corresponding changes in
+ * the KVP user-mode component.
+ */
+
+#define CN_KVP_VAL 0x1 /* This supports queries from the kernel */
+#define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */
+
+
+/*
+ * KVP protocol: The user mode component first registers with the
+ * the kernel component. Subsequently, the kernel component requests, data
+ * for the specified keys. In response to this message the user mode component
+ * fills in the value corresponding to the specified key. We overload the
+ * sequence field in the cn_msg header to define our KVP message types.
+ *
+ * XXXKYS: Have a shared header file between the user and kernel (TODO)
+ */
+
+enum kvp_op {
+ KVP_REGISTER = 0, /* Register the user mode component */
+ KVP_KERNEL_GET,/*Kernel is requesting the value for the specified key*/
+ KVP_KERNEL_SET, /*Kernel is providing the value for the specified key*/
+ KVP_USER_GET, /*User is requesting the value for the specified key*/
+ KVP_USER_SET /*User is providing the value for the specified key*/
+};
+
+
+
+#define KVP_KEY_SIZE 512
+#define KVP_VALUE_SIZE 2048
+
+
+typedef struct kvp_msg {
+ __u32 kvp_key; /* Key */
+ __u8 kvp_value[0]; /* Corresponding value */
+} kvp_msg_t;
+
+/*
+ * End of shared definitions.
+ */
+
+/*
+ * Registry value types.
+ */
+
+#define REG_SZ 1
+
+/*
+ * Array of keys we support in Linux.
+ *
+ */
+#define KVP_MAX_KEY 10
+#define KVP_LIC_VERSION 1
+
+
+static char *kvp_keys[KVP_MAX_KEY] = {"FullyQualifiedDomainName",
+ "IntegrationServicesVersion",
+ "NetworkAddressIPv4",
+ "NetworkAddressIPv6",
+ "OSBuildNumber",
+ "OSName",
+ "OSMajorVersion",
+ "OSMinorVersion",
+ "OSVersion",
+ "ProcessorArchitecture",
+ };
+
+/*
+ * Global state maintained for transaction that is being processed.
+ * Note that only one transaction can be active at any point in time.
+ *
+ * This state is set when we receive a request from the host; we
+ * cleanup this state when the transaction is completed - when we respond
+ * to the host with the key value.
+ */
+
+static u8 *recv_buffer; /* the receive buffer that we allocated */
+static int recv_len; /* number of bytes received. */
+static struct vmbus_channel *recv_channel; /*chn on which we got the request*/
+static u64 recv_req_id; /* request ID. */
+static int kvp_current_index;
+
+static int
+kvp_send_key(int index);
+
+static
+void kvp_respond_to_host(int key, char *value);
+
+static struct cb_id kvp_id = { CN_KVP_IDX, CN_KVP_VAL };
+static char kvp_name[] = "kvp_kernel_module";
+
+static bool kvp_transaction_active;
+
+static struct timer_list kvp_timer;
+
+static void kvp_timer_func(unsigned long __data)
+{
+ u32 key = *((u32 *)__data);
+ /*
+ * If the timer fires, the user-mode component has not responded;
+ * process the pending transaction.
+ */
+ kvp_respond_to_host(key, "Guest timed out");
+}
+
+/*
+ * Callback when data is received from user mode.
+ */
+
+static void
+kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
+{
+ struct kvp_msg *message;
+
+ message = (struct kvp_msg *)msg->data;
+ if (msg->seq == KVP_REGISTER)
+ printk(KERN_WARNING "KVP: user-mode registering done.\n");
+
+ if (msg->seq == KVP_USER_SET) {
+ /*
+ * Complete the transaction by forwarding the key value
+ * to the host. But first, cancel the timeout.
+ */
+ if (del_timer_sync(&kvp_timer))
+ kvp_respond_to_host(message->kvp_key,
+ message->kvp_value);
+ }
+}
+
+static int
+kvp_send_key(int index)
+{
+ struct cn_msg *msg;
+
+ msg = kzalloc(sizeof(*msg) + sizeof(kvp_msg_t) , GFP_ATOMIC);
+
+ if (msg) {
+ msg->id.idx = CN_KVP_IDX;
+ msg->id.val = CN_KVP_VAL;
+ msg->seq = KVP_KERNEL_GET;
+ ((kvp_msg_t *)msg->data)->kvp_key = index;
+ msg->len = sizeof(kvp_msg_t);
+ cn_netlink_send(msg, 0, GFP_ATOMIC);
+ kfree(msg);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * Send a response back to the host.
+ * key specifies the key for which the value is being returned.
+ */
+
+static
+void kvp_respond_to_host(int key, char *value)
+{
+ ic_kvp_msg_t *kvp_msg;
+ ic_kvp_msg_enumerate_t *kvp_data;
+ char *key_name;
+ struct icmsg_hdr *icmsghdrp;
+ int keylen, valuelen;
+ u8 *buf;
+ u32 buf_len;
+ struct vmbus_channel *channel;
+ u64 req_id;
+
+ /*
+ * If a transaction is not active; log and return.
+ */
+
+ if (!kvp_transaction_active) {
+ /*
+ * This is a spurious call!
+ */
+ printk(KERN_WARNING "KVP: Transaction not active\n");
+ return;
+ }
+ /*
+ * Copy the global state for completing the transaction. Note that
+ * only one transaction can be active at a time.
+ */
+
+ buf = recv_buffer;
+ buf_len = recv_len;
+ channel = recv_channel;
+ req_id = recv_req_id;
+
+ kvp_transaction_active = false;
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[sizeof(struct vmbuspipe_hdr)];
+ kvp_msg = (ic_kvp_msg_t *)&buf[sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+ kvp_data = &kvp_msg->kvp_data;
+ key_name = kvp_keys[key];
+
+ /*
+ * The windows host expects the key/value pair to be encoded
+ * in utf16.
+ */
+ keylen = utf8s_to_utf16s(key_name, strlen(key_name),
+ (wchar_t *)kvp_data->data.key);
+ kvp_data->data.key_size = 2*(keylen + 1); /* utf16 encoding */
+ valuelen = utf8s_to_utf16s(value, strlen(value),
+ (wchar_t *)kvp_data->data.value);
+ kvp_data->data.value_size = 2*(valuelen + 1); /* utf16 encoding */
+
+ kvp_data->data.value_type = REG_SZ; /* all our values are strings */
+ icmsghdrp->status = HV_S_OK;
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf, buf_len, req_id,
+ VmbusPacketTypeDataInBand, 0);
+
+ /*
+ * Free up the buffer that was allocatted when we received a message
+ * from the host.
+ */
+ kfree(buf);
+}
+
+/*
+ * This callback is invoked when we get a KVP message from the host.
+ * The host ensures that only one KVP transaction can be active at a time.
+ * KVP implementation in Linux needs to forward the key to a user-mde
+ * component to retrive the corresponding value. Consequently, we cannot
+ * respond to the host in the conext of this callback. Since the host
+ * guarantees that at most only one transaction can be active at a time,
+ * we stash away the transaction state in a set of global variables.
+ */
+
+void kvp_onchannelcallback(void *context)
+{
+ struct vmbus_channel *channel = context;
+ u8 *buf;
+ u32 buflen, recvlen;
+ u64 requestid;
+
+ ic_kvp_msg_t *kvp_msg;
+ ic_kvp_msg_enumerate_t *kvp_data;
+
+ struct icmsg_hdr *icmsghdrp;
+ struct icmsg_negotiate *negop = NULL;
+
+
+ buflen = PAGE_SIZE;
+ buf = kmalloc(buflen, GFP_ATOMIC);
+
+ vmbus_recvpacket(channel, buf, buflen, &recvlen, &requestid);
+
+ if (recvlen > 0) {
+ DPRINT_DBG(VMBUS, "KVP packet: len=%d, requestid=%lld",
+ recvlen, requestid);
+
+ icmsghdrp = (struct icmsg_hdr *)&buf[
+ sizeof(struct vmbuspipe_hdr)];
+
+ if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
+ prep_negotiate_resp(icmsghdrp, negop, buf);
+ } else {
+ kvp_msg = (ic_kvp_msg_t *)&buf[
+ sizeof(struct vmbuspipe_hdr) +
+ sizeof(struct icmsg_hdr)];
+
+ kvp_data = &kvp_msg->kvp_data;
+
+ /*
+ * We only support the "get" operation on
+ * "ICKvpExchangePoolAuto" pool.
+ */
+
+ if ((kvp_msg->kvp_hdr.pool != ICKvpExchangePoolAuto) ||
+ (kvp_msg->kvp_hdr.operation !=
+ ICKvpExchangeOperationEnumerate) ||
+ kvp_transaction_active) {
+ if (kvp_transaction_active)
+ printk(KERN_WARNING
+ "KVP: Invalid call\n");
+ icmsghdrp->status = HV_E_FAIL;
+ goto callback_done;
+ }
+
+ /*
+ * Stash away this global state for completing the
+ * transaction; note transactions are serialized.
+ */
+ recv_buffer = buf;
+ recv_len = recvlen;
+ recv_channel = channel;
+ recv_req_id = requestid;
+
+ switch (kvp_data->index) {
+ case (KVP_MAX_KEY):
+ /*
+ * We don't support this key
+ * and any key beyond this.
+ */
+ icmsghdrp->status = HV_E_FAIL;
+ goto callback_done;
+
+ case (KVP_LIC_VERSION):
+ kvp_transaction_active = true;
+ kvp_respond_to_host(kvp_data->index,
+ HV_DRV_VERSION);
+ return;
+ default:
+ /*
+ * Get the information from the
+ * user-mode component.
+ * component. This transaction will be
+ * completed when we get the value from
+ * the user-mode component.
+ * Set a timeout to deal with
+ * user-mode not responding.
+ */
+ kvp_current_index = kvp_data->index;
+ mod_timer(&kvp_timer, jiffies+75);
+ kvp_transaction_active = true;
+ kvp_send_key(kvp_data->index);
+ return;
+ }
+
+ }
+
+callback_done:
+
+ icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
+ | ICMSGHDRFLAG_RESPONSE;
+
+ vmbus_sendpacket(channel, buf,
+ recvlen, requestid,
+ VmbusPacketTypeDataInBand, 0);
+ }
+
+ kfree(buf);
+
+
+}
+
+int
+kvp_init(void)
+{
+ int err;
+
+ err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback);
+ if (err)
+ return err;
+
+ setup_timer(&kvp_timer, kvp_timer_func,
+ (unsigned long)&kvp_current_index);
+ return 0;
+}
+
+void kvp_deinit(void)
+{
+ cn_del_callback(&kvp_id);
+ del_timer_sync(&kvp_timer);
+}
+
Index: linux.trees.git/drivers/staging/hv/Makefile
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/Makefile 2010-11-10 14:01:55.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/Makefile 2010-11-11 11:24:54.000000000 -0500
@@ -2,7 +2,7 @@ obj-$(CONFIG_HYPERV) += hv_vmbus.o hv_t
obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o
obj-$(CONFIG_HYPERV_BLOCK) += hv_blkvsc.o
obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o
-obj-$(CONFIG_HYPERV_UTILS) += hv_utils.o
+obj-$(CONFIG_HYPERV_UTILS) += hv_util.o
hv_vmbus-y := vmbus_drv.o osd.o \
vmbus.o hv.o connection.o channel.o \
@@ -10,3 +10,4 @@ hv_vmbus-y := vmbus_drv.o osd.o \
hv_storvsc-y := storvsc_drv.o storvsc.o
hv_blkvsc-y := blkvsc_drv.o blkvsc.o
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
+hv_util-y := hv_utils.o kvp.o
Index: linux.trees.git/drivers/staging/hv/kvp.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.trees.git/drivers/staging/hv/kvp.h 2010-11-10 14:03:47.000000000 -0500
@@ -0,0 +1,101 @@
+/*
+ * An implementation of key value pair (KVP) functionality for Linux.
+ *
+ *
+ * Copyright (C) 2010, Novell, Inc.
+ * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+#ifndef _KVP_H
+#define _KVP_H_
+
+/*
+ * Maximum value size - used for both key names and value data, and includes
+ * any applicable NULL terminators.
+ *
+ * Note: This limit is somewhat arbitrary, but falls easily within what is
+ * supported for all native guests (back to Win 2000) and what is reasonable
+ * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
+ * limited to 255 character key names.
+ *
+ * MSDN recommends not storing data values larger than 2048 bytes in the
+ * registry.
+ *
+ * Note: This value is used in defining the KVP exchange message - this value
+ * cannot be modified without affecting the message size and compatability.
+ */
+
+/*
+ * bytes, including any null terminators
+ */
+#define IC_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
+
+
+/*
+ * Maximum key size - the registry limit for the length of an entry name
+ * is 256 characters, including the null terminator
+ */
+
+#define IC_KVP_EXCHANGE_MAX_KEY_SIZE (512)
+
+
+typedef enum {
+ ICKvpExchangeOperationGet = 0,
+ ICKvpExchangeOperationSet,
+ ICKvpExchangeOperationDelete,
+ ICKvpExchangeOperationEnumerate,
+ ICKvpExchangeOperationCount /* Number of operations, must be last. */
+} IC_KVP_EXCHANGE_OPERATION;
+
+typedef enum {
+ ICKvpExchangePoolExternal = 0,
+ ICKvpExchangePoolGuest,
+ ICKvpExchangePoolAuto,
+ ICKvpExchangePoolAutoExternal,
+ ICKvpExchangePoolInternal,
+ ICKvpExchangePoolCount /* Number of pools, must be last. */
+} IC_KVP_EXCHANGE_POOL;
+
+typedef struct ic_kvp_hdr {
+ u8 operation;
+ u8 pool;
+} ic_kvp_hdr_t;
+
+typedef struct ic_kvp_exchg_msg_value {
+ u32 value_type;
+ u32 key_size;
+ u32 value_size;
+ u8 key[IC_KVP_EXCHANGE_MAX_KEY_SIZE];
+ u8 value[IC_KVP_EXCHANGE_MAX_VALUE_SIZE];
+} ic_kvp_exchg_msg_value_t;
+
+typedef struct ic_kvp__msg_enumerate {
+ u32 index;
+ ic_kvp_exchg_msg_value_t data;
+} ic_kvp_msg_enumerate_t;
+
+typedef struct ic_kvp_msg {
+ ic_kvp_hdr_t kvp_hdr;
+ ic_kvp_msg_enumerate_t kvp_data;
+} ic_kvp_msg_t;
+
+int kvp_init(void);
+void kvp_deinit(void);
+void kvp_onchannelcallback(void *);
+
+#endif /* _KVP_H */
+
Index: linux.trees.git/drivers/staging/hv/utils.h
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/utils.h 2010-11-10 10:30:23.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/utils.h 2010-11-10 14:03:47.000000000 -0500
@@ -102,6 +102,7 @@ struct ictimesync_data{
#define HV_SHUTDOWN_MSG 0
#define HV_TIMESYNC_MSG 1
#define HV_HEARTBEAT_MSG 2
+#define HV_KVP_MSG 3
struct hyperv_service_callback {
u8 msg_type;
Index: linux.trees.git/drivers/staging/hv/hv_utils.c
===================================================================
--- linux.trees.git.orig/drivers/staging/hv/hv_utils.c 2010-11-10 14:02:40.000000000 -0500
+++ linux.trees.git/drivers/staging/hv/hv_utils.c 2010-11-11 13:42:38.000000000 -0500
@@ -37,6 +37,7 @@
#include "vmbus_private.h"
#include "vmbus_api.h"
#include "utils.h"
+#include "kvp.h"
static void shutdown_onchannelcallback(void *context)
@@ -268,6 +269,9 @@ static int __init init_hyperv_utils(void
{
printk(KERN_INFO "Registering HyperV Utility Driver\n");
+ if (kvp_init())
+ return -ENODEV;
+
if (!dmi_check_system(hv_utils_dmi_table))
return -ENODEV;
@@ -283,6 +287,10 @@ static int __init init_hyperv_utils(void
&heartbeat_onchannelcallback;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
+ hv_cb_utils[HV_KVP_MSG].channel->OnChannelCallback =
+ &kvp_onchannelcallback;
+
+
return 0;
}
@@ -301,6 +309,12 @@ static void exit_hyperv_utils(void)
hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback =
&chn_cb_negotiate;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
+
+ hv_cb_utils[HV_KVP_MSG].channel->OnChannelCallback =
+ &chn_cb_negotiate;
+
+ kvp_deinit();
+
}
module_init(init_hyperv_utils);
Index: linux.trees.git/include/linux/connector.h
===================================================================
--- linux.trees.git.orig/include/linux/connector.h 2010-11-09 17:22:15.000000000 -0500
+++ linux.trees.git/include/linux/connector.h 2010-11-11 13:14:52.000000000 -0500
@@ -42,8 +42,9 @@
#define CN_VAL_DM_USERSPACE_LOG 0x1
#define CN_IDX_DRBD 0x8
#define CN_VAL_DRBD 0x1
+#define CN_KVP_IDX 0x9 /* MSFT KVP functionality */
-#define CN_NETLINK_USERS 8
+#define CN_NETLINK_USERS 10
/*
* Maximum connector's message size.
[-- Attachment #3: kvp_daemon.c --]
[-- Type: application/octet-stream, Size: 10284 bytes --]
/*
* An implementation of key value pair (KVP) functionality for Linux.
*
*
* Copyright (C) 2010, Novell, Inc.
* Author : K. Y. Srinivasan <ksrinivasan@novell.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* 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, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/utsname.h>
#include <asm/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <linux/connector.h>
#include <linux/netlink.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <syslog.h>
/*
* KYS: TODO. Need to register these in the kernel.
*
* The following definitions are shared with the in-kernel component; do not
* change any of this without making the corresponding changes in
* the KVP kernel component.
*/
#define CN_KVP_IDX 0x9 /* MSFT KVP functionality */
#define CN_KVP_VAL 0x1 /* This supports queries from the kernel */
#define CN_KVP_USER_VAL 0x2 /* This supports queries from the user */
/*
* KVP protocol: The user mode component first registers with the
* the kernel component. Subsequently, the kernel component requests, data
* for the specified keys. In response to this message the user mode component
* fills in the value corresponding to the specified key. We overload the
* sequence field in the cn_msg header to define our KVP message types.
*
* We use this infrastructure for also supporting queries from user mode
* application for state that may be maintained in the KVP kernel component.
*
* XXXKYS: Have a shared header file between the user and kernel (TODO)
*/
enum kvp_op {
KVP_REGISTER = 0, /* Register the user mode component*/
KVP_KERNEL_GET, /*Kernel is requesting the value for the specified key*/
KVP_KERNEL_SET, /*Kernel is providing the value for the specified key*/
KVP_USER_GET, /*User is requesting the value for the specified key*/
KVP_USER_SET /*User is providing the value for the specified key*/
};
#define KVP_KEY_SIZE 512
#define KVP_VALUE_SIZE 2048
typedef struct kvp_msg {
__u32 kvp_key;
__u8 kvp_value[KVP_VALUE_SIZE];
} kvp_msg_t;
typedef enum {
FullyQualifiedDomainName = 0,
IntegrationServicesVersion, /*This key is serviced in the kernel*/
NetworkAddressIPv4,
NetworkAddressIPv6,
OSBuildNumber,
OSName,
OSMajorVersion,
OSMinorVersion,
OSVersion,
ProcessorArchitecture
} kvp_key_name_t;
/*
* End of shared definitions.
*/
static char kvp_send_buffer[4096];
static char kvp_recv_buffer[4096];
static struct sockaddr_nl addr;
static char os_name[100];
static char os_major[50];
static char os_minor[50];
static char processor_arch[50];
static char os_build[100];
void kvp_get_os_info(void)
{
FILE *file;
char *eol;
struct utsname buf;
uname(&buf);
strcpy(os_build, buf.release);
strcpy(processor_arch, buf.machine);
if ((file = fopen("/etc/SuSE-release", "r")) != NULL)
goto kvp_osinfo_found;
if ((file = fopen("/etc/SuSE-release", "r")) != NULL)
goto kvp_osinfo_found;
/*
* Add code for other supported platforms.
*/
/*
* We don't have information about the os.
*/
strcpy(os_name, "Linux");
strcpy(os_major, "0");
strcpy(os_minor, "0");
return;
kvp_osinfo_found:
fgets(os_name, 99, file);
eol = index(os_name, '\n');
*eol = '\0';
fgets(os_major, 49, file);
eol = index(os_major, '\n');
*eol = '\0';
fgets(os_minor, 49, file);
eol = index(os_minor, '\n');
*eol = '\0';
fclose(file);
return;
}
static int
kvp_get_ip_address(int family, char *buffer, int length)
{
struct ifaddrs *ifap;
struct ifaddrs *curp;
int ipv4_len = strlen("255.255.255.255") + 1;
int ipv6_len = strlen("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")+1;
int offset = 0;
const char *str;
char tmp[50];
int error = 0;
/*
* On entry into this function, the buffer is capable of holding the
* maximum key value (2048 bytes).
*/
if (getifaddrs(&ifap)) {
strcpy(buffer, "getifaddrs failed\n");
return 1;
}
curp = ifap;
while (curp != NULL) {
if ((curp->ifa_addr != NULL) &&
(curp->ifa_addr->sa_family == family)) {
if (family == AF_INET) {
struct sockaddr_in *addr =
(struct sockaddr_in *) curp->ifa_addr;
if (!(str = inet_ntop(family, &addr->sin_addr,
tmp, 50))) {
strcpy(buffer, "inet_ntop failed\n");
error = 1;
goto getaddr_done;
}
if (offset == 0)
strcpy(buffer, tmp);
else
strcat(buffer, tmp);
strcat(buffer, ";");
offset += strlen(str) +1;
if ((length - offset) < (ipv4_len + 1)) {
goto getaddr_done;
}
} else {
/*
* We only support AF_INET and AF_INET6
* and the list of addresses is seperated by a ";".
*/
struct sockaddr_in6 *addr =
(struct sockaddr_in6 *) curp->ifa_addr;
if (!(str = inet_ntop(family,
&addr->sin6_addr.s6_addr,
tmp, 50))) {
strcpy(buffer, "inet_ntop failed\n");
error = 1;
goto getaddr_done;
}
if (offset == 0)
strcpy(buffer, tmp);
else
strcat(buffer, tmp);
strcat(buffer, ";");
offset += strlen(str) +1;
if ((length - offset) < (ipv6_len +1)) {
goto getaddr_done;
}
}
}
curp = curp->ifa_next;
}
getaddr_done:
freeifaddrs(ifap);
return error;
}
static int
kvp_get_domain_name(char *buffer, int length)
{
struct addrinfo hints, *info ;
gethostname(buffer, length);
int error =0;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
if ((error = getaddrinfo(buffer, "http", &hints, &info)) !=0) {
strcpy(buffer, "getaddrinfo failed\n");
error = 1;
goto get_domain_done;
}
strcpy(buffer, info->ai_canonname);
get_domain_done:
freeaddrinfo(info);
return (error);
}
static int
netlink_send(int fd, struct cn_msg *msg)
{
struct nlmsghdr *nlh;
unsigned int size;
struct msghdr message;
char buffer[64];
struct iovec iov[2];
size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len);
nlh = (struct nlmsghdr *)buffer;
nlh->nlmsg_seq = 0;
nlh->nlmsg_pid = getpid();
nlh->nlmsg_type = NLMSG_DONE;
nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh));
nlh->nlmsg_flags = 0;
iov[0].iov_base = nlh;
iov[0].iov_len = sizeof(*nlh);
iov[1].iov_base = msg;
iov[1].iov_len = size;
memset(&message, 0, sizeof(message));
message.msg_name = &addr;
message.msg_namelen = sizeof(addr);
message.msg_iov = iov;
message.msg_iovlen = 2;
return (sendmsg(fd, &message, 0));
}
main(void)
{
int fd, len, sock_opt;
int error;
struct cn_msg *message;
struct pollfd pfd;
struct nlmsghdr *incoming_msg;
struct cn_msg *incoming_cn_msg;
char *key_value;
kvp_key_name_t key_name;
daemon(1, 0);
openlog("KVP", 0, LOG_USER);
syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
/*
* Retrieve OS release information.
*/
kvp_get_os_info();
fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
if (fd < 0) {
syslog(LOG_ERR, "netlink socket creation failed; error:%d",fd);
exit -1;
}
addr.nl_family = AF_NETLINK;
addr.nl_pad = 0;
addr.nl_pid = 0;
addr.nl_groups = CN_KVP_IDX;
if ((error = bind(fd, (struct sockaddr *)&addr, sizeof(addr))) < 0) {
syslog(LOG_ERR, "bind failed; error:%d",error);
close(fd);
exit -1;
}
sock_opt = addr.nl_groups;
setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt));
/*
* Register ourselves with the kernel.
*/
message = (struct cn_msg *)kvp_send_buffer;
message->id.idx = CN_KVP_IDX;
message->id.val = CN_KVP_VAL;
message->seq = KVP_REGISTER;
message->ack = 0;
message->len = 0;
len = netlink_send(fd, message);
if (len < 0) {
syslog(LOG_ERR, "netlink_send failed; error:%d", len);
close(fd);
exit -1;
}
pfd.fd = fd;
while (1) {
pfd.events = POLLIN;
pfd.revents = 0;
poll(&pfd, 1, -1);
len = recv(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0);
if (len < 0) {
syslog(LOG_ERR, "recv failed; error:%d", len);
close(fd);
return -1;
}
incoming_msg = (struct nlmsghdr *)kvp_recv_buffer;
incoming_cn_msg = (struct cn_msg *)NLMSG_DATA(incoming_msg);
if (incoming_cn_msg->seq != KVP_KERNEL_GET) {
continue;
}
key_name =
((struct kvp_msg *)incoming_cn_msg->data)->kvp_key;
key_value =
((struct kvp_msg *)incoming_cn_msg->data)->kvp_value;
switch (key_name) {
case FullyQualifiedDomainName:
kvp_get_domain_name(key_value, KVP_VALUE_SIZE);
break;
case NetworkAddressIPv4:
kvp_get_ip_address(AF_INET, key_value,
KVP_VALUE_SIZE);
break;
case NetworkAddressIPv6:
kvp_get_ip_address(AF_INET6, key_value,
KVP_VALUE_SIZE);
break;
case OSBuildNumber:
strcpy(key_value, os_build);
break;
case OSName:
strcpy(key_value, os_name);
break;
case OSMajorVersion:
strcpy(key_value, os_major);
break;
case OSMinorVersion:
strcpy(key_value, os_minor);
break;
case OSVersion:
strcpy(key_value, os_build);
break;
case ProcessorArchitecture:
strcpy(key_value, processor_arch);
break;
default:
strcpy(key_value, "Unknown Key");
break;
}
/*
* Send the value back to the kernel. The response is
* already in the receive buffer. Update the cn_msg header to
* reflect the key value that has been added to the message
*/
incoming_cn_msg->id.idx = CN_KVP_IDX;
incoming_cn_msg->id.val = CN_KVP_VAL;
incoming_cn_msg->seq = KVP_USER_SET;
incoming_cn_msg->ack = 0;
incoming_cn_msg->len = KVP_KEY_SIZE + strlen(key_value);
len = netlink_send(fd, incoming_cn_msg);
if (len < 0) {
syslog(LOG_ERR, "net_link send failed; error:%d", len);
exit -1;
}
}
}
[-- Attachment #4: Type: text/plain, Size: 159 bytes --]
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
^ permalink raw reply
* Re: [Qemu-devel] Re: [PATCH] Implement a virtio GPU transport
From: Anthony Liguori @ 2010-11-10 17:47 UTC (permalink / raw)
To: Ian Molton
Cc: QEMU Developers, Rusty Russell, linux-kernel, virtualization,
virtualization, Alon Levy, Avi Kivity
In-Reply-To: <4CDAD4D4.3070009@collabora.co.uk>
On 11/10/2010 11:22 AM, Ian Molton wrote:
> Ping ?
I think the best way forward is to post patches.
To summarize what I was trying to express in the thread, I think this is
not the right long term architecture but am not opposed to it as a short
term solution. I think having a new virtio device is a bad design
choice but am not totally opposed to it.
My advice is that using virtio-serial + an external tool is probably the
least amount of work to get something working and usable with QEMU. If
you want to go for the path of integration, you're going to have to fix
all of the coding style issues and make the code fit into QEMU.
Dropping a bunch of junk into target-i386/ is not making the code fit
into QEMU.
If you post just what you have now in patch form, I can try to provide
more concrete advice ignoring the coding style problems.
Regards,
Anthony Liguori
^ permalink raw reply
* Re: [Qemu-devel] Re: [PATCH] Implement a virtio GPU transport
From: Ian Molton @ 2010-11-10 17:22 UTC (permalink / raw)
To: Anthony Liguori
Cc: QEMU Developers, Rusty Russell, linux-kernel, virtualization,
virtualization, Alon Levy, Avi Kivity
In-Reply-To: <4CD44759.5020500@collabora.co.uk>
Ping ?
On 05/11/10 18:05, Ian Molton wrote:
> On 03/11/10 18:17, Anthony Liguori wrote:
>> On 11/03/2010 01:03 PM, Ian Molton wrote:
>
>> Why is it better than using virtio-serial?
>
> For one thing, it enforces the PID in kernel so the guests processes
> cant screw each other over by forging the PID passed to qemu.
>
>>> My current patch touches a tiny part of the qemu sources. It works
>>> today.
>>
>> But it's not at all mergable in the current form. If you want to do the
>> work of getting it into a mergable state (cleaning up the coding style,
>> moving it to hw/, etc.) than I'm willing to consider it. But I don't
>> think a custom virtio transport is the right thing to do here.
>
> Hm, I thought I'd indented everything in qemus odd way... Is there a
> codingstyle document or a checkpatch-like tool for qemu?
>
> I'm happy to make the code meet qemus coding style.
>
>> However, if you want something that Just Works with the least amount of
>> code possible, just split it into a separate process and we can stick it
>> in a contrib/ directory or something.
>
> I dont see what splitting it into a seperate process buys us given we
> still need the virtio-gl driver in order to enforce the PID. The virtio
> driver is probably quite a bit more efficient at marshalling the data
> too, given that it was designed alongside the userspace code.
>
>>>> I
>>>> think we can consider integrating it into QEMU (or at least simplifying
>>>> the execution of the backend) but integrating into QEMU is going to
>>>> require an awful lot of the existing code to be rewritten.
>
> Why? aside from codingstyle, whats massively wrong with it thats going
> to demand a total rewrite?
>
>>>> Keeping it
>>>> separate has the advantage of allowing something to Just Work as an
>>>> interim solution as we wait for proper support in Spice.
>
> Why does keeping it seperate make life easier? qemu is in a git repo.
> when the time comes, if it reall is a total replacement, git-rm will
> nuke it all.
>
>>> I dont know why you think integrating it into qemu is hard? I've
>>> already done it.
>>
>> Adding a file that happens to compile as part of qemu even though it
>> doesn't actually integrate with qemu in any meaningful way is not
>> integrating. That's just build system manipulation.
>
> Uh? Either it compiles and works as part of qemu (which it does) or it
> doesnt. How is that not integrated? I've added it to the configure
> script too.
>
> -Ian
>
^ permalink raw reply
* Re: [PATCH] virtio: fix format of sysfs driver/vendor files
From: Rusty Russell @ 2010-11-10 12:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Greg KH, virtualization, linux-kernel
In-Reply-To: <20101109222029.65f3e192@nehalam>
On Wed, 10 Nov 2010 04:50:29 pm Stephen Hemminger wrote:
> The sysfs files for virtio produce the wrong format and are missing
> the required newline. The output for virtio bus vendor/device should
> have the same format as the corresponding entries for PCI devices.
>
> Although this technically changes the ABI for sysfs, these files were
> broken to start with!
Agreed, and I don't think anyone currently uses them.
Applied,
Rusty.
^ permalink raw reply
* [PATCH] virtio: fix format of sysfs driver/vendor files
From: Stephen Hemminger @ 2010-11-10 6:20 UTC (permalink / raw)
To: Greg KH, Rusty Russell; +Cc: virtualization, linux-kernel
The sysfs files for virtio produce the wrong format and are missing
the required newline. The output for virtio bus vendor/device should
have the same format as the corresponding entries for PCI devices.
Although this technically changes the ABI for sysfs, these files were
broken to start with!
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/virtio/virtio.c 2010-11-09 21:39:31.713916249 -0800
+++ b/drivers/virtio/virtio.c 2010-11-09 21:40:16.072089461 -0800
@@ -9,19 +9,19 @@ static ssize_t device_show(struct device
struct device_attribute *attr, char *buf)
{
struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
- return sprintf(buf, "%hu", dev->id.device);
+ return sprintf(buf, "0x%04x\n", dev->id.device);
}
static ssize_t vendor_show(struct device *_d,
struct device_attribute *attr, char *buf)
{
struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
- return sprintf(buf, "%hu", dev->id.vendor);
+ return sprintf(buf, "0x%04x\n", dev->id.vendor);
}
static ssize_t status_show(struct device *_d,
struct device_attribute *attr, char *buf)
{
struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
- return sprintf(buf, "0x%08x", dev->config->get_status(dev));
+ return sprintf(buf, "0x%08x\n", dev->config->get_status(dev));
}
static ssize_t modalias_show(struct device *_d,
struct device_attribute *attr, char *buf)
^ permalink raw reply
* [PATCH 10/10] staging: hv: Convert camel cased functions in ring_buffer.c to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-9-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased functions in ring_buffer.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 40 ++++++------
drivers/staging/hv/ring_buffer.c | 123 +++++++++++++++++++------------------
drivers/staging/hv/ring_buffer.h | 16 +++---
3 files changed, 91 insertions(+), 88 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 97db545..45a627d 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -155,8 +155,8 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
monitorpage->parameter[monitor_group]
[monitor_offset].connectionid.u.id;
- RingBufferGetDebugInfo(&channel->inbound, &debuginfo->inbound);
- RingBufferGetDebugInfo(&channel->outbound, &debuginfo->outbound);
+ ringbuffer_get_debuginfo(&channel->inbound, &debuginfo->inbound);
+ ringbuffer_get_debuginfo(&channel->outbound, &debuginfo->outbound);
}
/*
@@ -193,13 +193,13 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
recv_ringbuffer_size) >> PAGE_SHIFT;
- ret = RingBufferInit(&newchannel->outbound, out, send_ringbuffer_size);
+ ret = ringbuffer_init(&newchannel->outbound, out, send_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
}
- ret = RingBufferInit(&newchannel->inbound, in, recv_ringbuffer_size);
+ ret = ringbuffer_init(&newchannel->inbound, in, recv_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
@@ -298,8 +298,8 @@ Cleanup:
return 0;
errorout:
- RingBufferCleanup(&newchannel->outbound);
- RingBufferCleanup(&newchannel->inbound);
+ ringbuffer_cleanup(&newchannel->outbound);
+ ringbuffer_cleanup(&newchannel->inbound);
osd_page_free(out, (send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
kfree(openInfo);
@@ -683,8 +683,8 @@ void vmbus_close(struct vmbus_channel *channel)
/* TODO: Send a msg to release the childRelId */
/* Cleanup the ring buffers for this channel */
- RingBufferCleanup(&channel->outbound);
- RingBufferCleanup(&channel->inbound);
+ ringbuffer_cleanup(&channel->outbound);
+ ringbuffer_cleanup(&channel->inbound);
osd_page_free(channel->ringbuffer_pages, channel->ringbuffer_pagecount);
@@ -752,10 +752,10 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
sg_set_buf(&bufferlist[2], &aligned_data,
packetlen_aligned - packetlen);
- ret = RingBufferWrite(&channel->outbound, bufferlist, 3);
+ ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&channel->outbound))
+ if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
vmbus_setevent(channel);
return ret;
@@ -817,10 +817,10 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
sg_set_buf(&bufferlist[2], &aligned_data,
packetlen_aligned - packetlen);
- ret = RingBufferWrite(&channel->outbound, bufferlist, 3);
+ ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&channel->outbound))
+ if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
vmbus_setevent(channel);
return ret;
@@ -886,10 +886,10 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
sg_set_buf(&bufferlist[2], &aligned_data,
packetlen_aligned - packetlen);
- ret = RingBufferWrite(&channel->outbound, bufferlist, 3);
+ ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&channel->outbound))
+ if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
vmbus_setevent(channel);
return ret;
@@ -923,7 +923,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&channel->inbound, &desc,
+ ret = ringbuffer_peek(&channel->inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -956,7 +956,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
*requestid = desc.TransactionId;
/* Copy over the packet to the user buffer */
- ret = RingBufferRead(&channel->inbound, buffer, userlen,
+ ret = ringbuffer_read(&channel->inbound, buffer, userlen,
(desc.DataOffset8 << 3));
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -983,7 +983,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&channel->inbound, &desc,
+ ret = ringbuffer_peek(&channel->inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -1015,7 +1015,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
*requestid = desc.TransactionId;
/* Copy over the entire packet to the user buffer */
- ret = RingBufferRead(&channel->inbound, buffer, packetlen, 0);
+ ret = ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
@@ -1052,6 +1052,6 @@ void vmbus_ontimer(unsigned long data)
static void dump_vmbus_channel(struct vmbus_channel *channel)
{
DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid);
- Dumpring_info(&channel->outbound, "Outbound ");
- Dumpring_info(&channel->inbound, "Inbound ");
+ dump_ring_info(&channel->outbound, "Outbound ");
+ dump_ring_info(&channel->inbound, "Inbound ");
}
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index 705d95f..4d53392 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -38,7 +38,7 @@
/*++
Name:
- GetRingBufferAvailBytes()
+ get_ringbuffer_availbytes()
Description:
Get number of bytes available to read and to write to
@@ -46,7 +46,8 @@ Description:
--*/
static inline void
-GetRingBufferAvailBytes(struct hv_ring_buffer_info *rbi, u32 *read, u32 *write)
+get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
+ u32 *read, u32 *write)
{
u32 read_loc, write_loc;
@@ -61,14 +62,14 @@ GetRingBufferAvailBytes(struct hv_ring_buffer_info *rbi, u32 *read, u32 *write)
/*++
Name:
- GetNextWriteLocation()
+ get_next_write_location()
Description:
Get the next write location for the specified ring buffer
--*/
static inline u32
-GetNextWriteLocation(struct hv_ring_buffer_info *ring_info)
+get_next_write_location(struct hv_ring_buffer_info *ring_info)
{
u32 next = ring_info->ring_buffer->write_index;
@@ -80,14 +81,14 @@ GetNextWriteLocation(struct hv_ring_buffer_info *ring_info)
/*++
Name:
- SetNextWriteLocation()
+ set_next_write_location()
Description:
Set the next write location for the specified ring buffer
--*/
static inline void
-SetNextWriteLocation(struct hv_ring_buffer_info *ring_info,
+set_next_write_location(struct hv_ring_buffer_info *ring_info,
u32 next_write_location)
{
ring_info->ring_buffer->write_index = next_write_location;
@@ -96,14 +97,14 @@ SetNextWriteLocation(struct hv_ring_buffer_info *ring_info,
/*++
Name:
- GetNextReadLocation()
+ get_next_read_location()
Description:
Get the next read location for the specified ring buffer
--*/
static inline u32
-GetNextReadLocation(struct hv_ring_buffer_info *ring_info)
+get_next_read_location(struct hv_ring_buffer_info *ring_info)
{
u32 next = ring_info->ring_buffer->read_index;
@@ -115,7 +116,7 @@ GetNextReadLocation(struct hv_ring_buffer_info *ring_info)
/*++
Name:
- GetNextReadLocationWithOffset()
+ get_next_readlocation_withoffset()
Description:
Get the next read location + offset for the specified ring buffer.
@@ -123,7 +124,8 @@ Description:
--*/
static inline u32
-GetNextReadLocationWithOffset(struct hv_ring_buffer_info *ring_info, u32 offset)
+get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
+ u32 offset)
{
u32 next = ring_info->ring_buffer->read_index;
@@ -137,14 +139,14 @@ GetNextReadLocationWithOffset(struct hv_ring_buffer_info *ring_info, u32 offset)
/*++
Name:
- SetNextReadLocation()
+ set_next_read_location()
Description:
Set the next read location for the specified ring buffer
--*/
static inline void
-SetNextReadLocation(struct hv_ring_buffer_info *ring_info,
+set_next_read_location(struct hv_ring_buffer_info *ring_info,
u32 next_read_location)
{
ring_info->ring_buffer->read_index = next_read_location;
@@ -154,14 +156,14 @@ SetNextReadLocation(struct hv_ring_buffer_info *ring_info,
/*++
Name:
- GetRingBuffer()
+ get_ring_buffer()
Description:
Get the start of the ring buffer
--*/
static inline void *
-GetRingBuffer(struct hv_ring_buffer_info *ring_info)
+get_ring_buffer(struct hv_ring_buffer_info *ring_info)
{
return (void *)ring_info->ring_buffer->buffer;
}
@@ -170,14 +172,14 @@ GetRingBuffer(struct hv_ring_buffer_info *ring_info)
/*++
Name:
- GetRingBufferSize()
+ get_ring_buffersize()
Description:
Get the size of the ring buffer
--*/
static inline u32
-GetRingBufferSize(struct hv_ring_buffer_info *ring_info)
+get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
{
return ring_info->ring_datasize;
}
@@ -185,14 +187,14 @@ GetRingBufferSize(struct hv_ring_buffer_info *ring_info)
/*++
Name:
- GetRingBufferIndices()
+ get_ring_bufferindices()
Description:
Get the read and write indices as u64 of the specified ring buffer
--*/
static inline u64
-GetRingBufferIndices(struct hv_ring_buffer_info *ring_info)
+get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
{
return (u64)ring_info->ring_buffer->write_index << 32;
}
@@ -201,18 +203,18 @@ GetRingBufferIndices(struct hv_ring_buffer_info *ring_info)
/*++
Name:
- Dumpring_info()
+ dump_ring_info()
Description:
Dump out to console the ring buffer info
--*/
-void Dumpring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
+void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
{
u32 bytes_avail_towrite;
u32 bytes_avail_toread;
- GetRingBufferAvailBytes(ring_info,
+ get_ringbuffer_availbytes(ring_info,
&bytes_avail_toread,
&bytes_avail_towrite);
@@ -233,14 +235,14 @@ void Dumpring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
/* Internal routines */
static u32
-CopyToRingBuffer(
+copyto_ringbuffer(
struct hv_ring_buffer_info *ring_info,
u32 start_write_offset,
void *src,
u32 srclen);
static u32
-CopyFromRingBuffer(
+copyfrom_ringbuffer(
struct hv_ring_buffer_info *ring_info,
void *dest,
u32 destlen,
@@ -251,20 +253,20 @@ CopyFromRingBuffer(
/*++
Name:
- RingBufferGetDebugInfo()
+ ringbuffer_get_debuginfo()
Description:
Get various debug metrics for the specified ring buffer
--*/
-void RingBufferGetDebugInfo(struct hv_ring_buffer_info *ring_info,
+void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
struct hv_ring_buffer_debug_info *debug_info)
{
u32 bytes_avail_towrite;
u32 bytes_avail_toread;
if (ring_info->ring_buffer) {
- GetRingBufferAvailBytes(ring_info,
+ get_ringbuffer_availbytes(ring_info,
&bytes_avail_toread,
&bytes_avail_towrite);
@@ -283,13 +285,13 @@ void RingBufferGetDebugInfo(struct hv_ring_buffer_info *ring_info,
/*++
Name:
- GetRingBufferInterruptMask()
+ get_ringbuffer_interrupt_mask()
Description:
Get the interrupt mask for the specified ring buffer
--*/
-u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *rbi)
+u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
{
return rbi->ring_buffer->interrupt_mask;
}
@@ -297,13 +299,13 @@ u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *rbi)
/*++
Name:
- RingBufferInit()
+ ringbuffer_init()
Description:
Initialize the ring buffer
--*/
-int RingBufferInit(struct hv_ring_buffer_info *ring_info,
+int ringbuffer_init(struct hv_ring_buffer_info *ring_info,
void *buffer, u32 buflen)
{
if (sizeof(struct hv_ring_buffer) != PAGE_SIZE)
@@ -326,26 +328,26 @@ int RingBufferInit(struct hv_ring_buffer_info *ring_info,
/*++
Name:
- RingBufferCleanup()
+ ringbuffer_cleanup()
Description:
Cleanup the ring buffer
--*/
-void RingBufferCleanup(struct hv_ring_buffer_info *ring_info)
+void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
{
}
/*++
Name:
- RingBufferWrite()
+ ringbuffer_write()
Description:
Write to the ring buffer
--*/
-int RingBufferWrite(struct hv_ring_buffer_info *outring_info,
+int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
struct scatterlist *sglist, u32 sgcount)
{
int i = 0;
@@ -367,7 +369,7 @@ int RingBufferWrite(struct hv_ring_buffer_info *outring_info,
spin_lock_irqsave(&outring_info->ring_lock, flags);
- GetRingBufferAvailBytes(outring_info,
+ get_ringbuffer_availbytes(outring_info,
&bytes_avail_toread,
&bytes_avail_towrite);
@@ -390,20 +392,20 @@ int RingBufferWrite(struct hv_ring_buffer_info *outring_info,
}
/* Write to the ring buffer */
- next_write_location = GetNextWriteLocation(outring_info);
+ next_write_location = get_next_write_location(outring_info);
for_each_sg(sglist, sg, sgcount, i)
{
- next_write_location = CopyToRingBuffer(outring_info,
+ next_write_location = copyto_ringbuffer(outring_info,
next_write_location,
sg_virt(sg),
sg->length);
}
/* Set previous packet start */
- prev_indices = GetRingBufferIndices(outring_info);
+ prev_indices = get_ring_bufferindices(outring_info);
- next_write_location = CopyToRingBuffer(outring_info,
+ next_write_location = copyto_ringbuffer(outring_info,
next_write_location,
&prev_indices,
sizeof(u64));
@@ -412,7 +414,7 @@ int RingBufferWrite(struct hv_ring_buffer_info *outring_info,
mb();
/* Now, update the write location */
- SetNextWriteLocation(outring_info, next_write_location);
+ set_next_write_location(outring_info, next_write_location);
/* Dumpring_info(Outring_info, "AFTER "); */
@@ -424,13 +426,13 @@ int RingBufferWrite(struct hv_ring_buffer_info *outring_info,
/*++
Name:
- RingBufferPeek()
+ ringbuffer_peek()
Description:
Read without advancing the read index
--*/
-int RingBufferPeek(struct hv_ring_buffer_info *Inring_info,
+int ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
void *Buffer, u32 buflen)
{
u32 bytes_avail_towrite;
@@ -440,7 +442,7 @@ int RingBufferPeek(struct hv_ring_buffer_info *Inring_info,
spin_lock_irqsave(&Inring_info->ring_lock, flags);
- GetRingBufferAvailBytes(Inring_info,
+ get_ringbuffer_availbytes(Inring_info,
&bytes_avail_toread,
&bytes_avail_towrite);
@@ -458,9 +460,9 @@ int RingBufferPeek(struct hv_ring_buffer_info *Inring_info,
}
/* Convert to byte offset */
- next_read_location = GetNextReadLocation(Inring_info);
+ next_read_location = get_next_read_location(Inring_info);
- next_read_location = CopyFromRingBuffer(Inring_info,
+ next_read_location = copyfrom_ringbuffer(Inring_info,
Buffer,
buflen,
next_read_location);
@@ -474,13 +476,13 @@ int RingBufferPeek(struct hv_ring_buffer_info *Inring_info,
/*++
Name:
- RingBufferRead()
+ ringbuffer_read()
Description:
Read and advance the read index
--*/
-int RingBufferRead(struct hv_ring_buffer_info *inring_info, void *buffer,
+int ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
u32 buflen, u32 offset)
{
u32 bytes_avail_towrite;
@@ -494,7 +496,7 @@ int RingBufferRead(struct hv_ring_buffer_info *inring_info, void *buffer,
spin_lock_irqsave(&inring_info->ring_lock, flags);
- GetRingBufferAvailBytes(inring_info,
+ get_ringbuffer_availbytes(inring_info,
&bytes_avail_toread,
&bytes_avail_towrite);
@@ -515,14 +517,15 @@ int RingBufferRead(struct hv_ring_buffer_info *inring_info, void *buffer,
return -1;
}
- next_read_location = GetNextReadLocationWithOffset(inring_info, offset);
+ next_read_location =
+ get_next_readlocation_withoffset(inring_info, offset);
- next_read_location = CopyFromRingBuffer(inring_info,
+ next_read_location = copyfrom_ringbuffer(inring_info,
buffer,
buflen,
next_read_location);
- next_read_location = CopyFromRingBuffer(inring_info,
+ next_read_location = copyfrom_ringbuffer(inring_info,
&prev_indices,
sizeof(u64),
next_read_location);
@@ -533,7 +536,7 @@ int RingBufferRead(struct hv_ring_buffer_info *inring_info, void *buffer,
mb();
/* Update the read index */
- SetNextReadLocation(inring_info, next_read_location);
+ set_next_read_location(inring_info, next_read_location);
/* Dumpring_info(Inring_info, "AFTER "); */
@@ -546,7 +549,7 @@ int RingBufferRead(struct hv_ring_buffer_info *inring_info, void *buffer,
/*++
Name:
- CopyToRingBuffer()
+ copyto_ringbuffer()
Description:
Helper routine to copy from source to ring buffer.
@@ -554,14 +557,14 @@ Description:
--*/
static u32
-CopyToRingBuffer(
+copyto_ringbuffer(
struct hv_ring_buffer_info *ring_info,
u32 start_write_offset,
void *src,
u32 srclen)
{
- void *ring_buffer = GetRingBuffer(ring_info);
- u32 ring_buffer_size = GetRingBufferSize(ring_info);
+ void *ring_buffer = get_ring_buffer(ring_info);
+ u32 ring_buffer_size = get_ring_buffersize(ring_info);
u32 frag_len;
/* wrap-around detected! */
@@ -584,7 +587,7 @@ CopyToRingBuffer(
/*++
Name:
- CopyFromRingBuffer()
+ copyfrom_ringbuffer()
Description:
Helper routine to copy to source from ring buffer.
@@ -592,14 +595,14 @@ Description:
--*/
static u32
-CopyFromRingBuffer(
+copyfrom_ringbuffer(
struct hv_ring_buffer_info *ring_info,
void *dest,
u32 destlen,
u32 start_read_offset)
{
- void *ring_buffer = GetRingBuffer(ring_info);
- u32 ring_buffer_size = GetRingBufferSize(ring_info);
+ void *ring_buffer = get_ring_buffer(ring_info);
+ u32 ring_buffer_size = get_ring_buffersize(ring_info);
u32 frag_len;
diff --git a/drivers/staging/hv/ring_buffer.h b/drivers/staging/hv/ring_buffer.h
index f30be1f..7bd6ecf 100644
--- a/drivers/staging/hv/ring_buffer.h
+++ b/drivers/staging/hv/ring_buffer.h
@@ -75,28 +75,28 @@ struct hv_ring_buffer_debug_info {
/* Interface */
-int RingBufferInit(struct hv_ring_buffer_info *ring_info, void *buffer,
+int ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
u32 buflen);
-void RingBufferCleanup(struct hv_ring_buffer_info *ring_info);
+void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
-int RingBufferWrite(struct hv_ring_buffer_info *ring_info,
+int ringbuffer_write(struct hv_ring_buffer_info *ring_info,
struct scatterlist *sglist,
u32 sgcount);
-int RingBufferPeek(struct hv_ring_buffer_info *ring_info, void *buffer,
+int ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
u32 buflen);
-int RingBufferRead(struct hv_ring_buffer_info *ring_info,
+int ringbuffer_read(struct hv_ring_buffer_info *ring_info,
void *buffer,
u32 buflen,
u32 offset);
-u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *ring_info);
+u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
-void Dumpring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
+void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
-void RingBufferGetDebugInfo(struct hv_ring_buffer_info *ring_info,
+void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
struct hv_ring_buffer_debug_info *debug_info);
#endif /* _RING_BUFFER_H_ */
--
1.6.3.2
^ permalink raw reply related
* [PATCH 09/10] staging: hv: Convert camel cased local variables in ring_buffer.c to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-8-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased local variables in ring_buffer.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 4 +-
drivers/staging/hv/ring_buffer.c | 337 +++++++++++++++++++-------------------
drivers/staging/hv/ring_buffer.h | 26 ++--
3 files changed, 185 insertions(+), 182 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 0e554e9..97db545 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -1052,6 +1052,6 @@ void vmbus_ontimer(unsigned long data)
static void dump_vmbus_channel(struct vmbus_channel *channel)
{
DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid);
- DumpRingInfo(&channel->outbound, "Outbound ");
- DumpRingInfo(&channel->inbound, "Inbound ");
+ Dumpring_info(&channel->outbound, "Outbound ");
+ Dumpring_info(&channel->inbound, "Inbound ");
}
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index 6095cc5..705d95f 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -68,11 +68,11 @@ Description:
--*/
static inline u32
-GetNextWriteLocation(struct hv_ring_buffer_info *RingInfo)
+GetNextWriteLocation(struct hv_ring_buffer_info *ring_info)
{
- u32 next = RingInfo->ring_buffer->write_index;
+ u32 next = ring_info->ring_buffer->write_index;
- /* ASSERT(next < RingInfo->RingDataSize); */
+ /* ASSERT(next < ring_info->RingDataSize); */
return next;
}
@@ -87,10 +87,10 @@ Description:
--*/
static inline void
-SetNextWriteLocation(struct hv_ring_buffer_info *RingInfo,
- u32 NextWriteLocation)
+SetNextWriteLocation(struct hv_ring_buffer_info *ring_info,
+ u32 next_write_location)
{
- RingInfo->ring_buffer->write_index = NextWriteLocation;
+ ring_info->ring_buffer->write_index = next_write_location;
}
/*++
@@ -103,11 +103,11 @@ Description:
--*/
static inline u32
-GetNextReadLocation(struct hv_ring_buffer_info *RingInfo)
+GetNextReadLocation(struct hv_ring_buffer_info *ring_info)
{
- u32 next = RingInfo->ring_buffer->read_index;
+ u32 next = ring_info->ring_buffer->read_index;
- /* ASSERT(next < RingInfo->RingDataSize); */
+ /* ASSERT(next < ring_info->RingDataSize); */
return next;
}
@@ -123,13 +123,13 @@ Description:
--*/
static inline u32
-GetNextReadLocationWithOffset(struct hv_ring_buffer_info *RingInfo, u32 Offset)
+GetNextReadLocationWithOffset(struct hv_ring_buffer_info *ring_info, u32 offset)
{
- u32 next = RingInfo->ring_buffer->read_index;
+ u32 next = ring_info->ring_buffer->read_index;
- /* ASSERT(next < RingInfo->RingDataSize); */
- next += Offset;
- next %= RingInfo->ring_datasize;
+ /* ASSERT(next < ring_info->RingDataSize); */
+ next += offset;
+ next %= ring_info->ring_datasize;
return next;
}
@@ -144,9 +144,10 @@ Description:
--*/
static inline void
-SetNextReadLocation(struct hv_ring_buffer_info *RingInfo, u32 NextReadLocation)
+SetNextReadLocation(struct hv_ring_buffer_info *ring_info,
+ u32 next_read_location)
{
- RingInfo->ring_buffer->read_index = NextReadLocation;
+ ring_info->ring_buffer->read_index = next_read_location;
}
@@ -160,9 +161,9 @@ Description:
--*/
static inline void *
-GetRingBuffer(struct hv_ring_buffer_info *RingInfo)
+GetRingBuffer(struct hv_ring_buffer_info *ring_info)
{
- return (void *)RingInfo->ring_buffer->buffer;
+ return (void *)ring_info->ring_buffer->buffer;
}
@@ -176,9 +177,9 @@ Description:
--*/
static inline u32
-GetRingBufferSize(struct hv_ring_buffer_info *RingInfo)
+GetRingBufferSize(struct hv_ring_buffer_info *ring_info)
{
- return RingInfo->ring_datasize;
+ return ring_info->ring_datasize;
}
/*++
@@ -191,41 +192,41 @@ Description:
--*/
static inline u64
-GetRingBufferIndices(struct hv_ring_buffer_info *RingInfo)
+GetRingBufferIndices(struct hv_ring_buffer_info *ring_info)
{
- return (u64)RingInfo->ring_buffer->write_index << 32;
+ return (u64)ring_info->ring_buffer->write_index << 32;
}
/*++
Name:
- DumpRingInfo()
+ Dumpring_info()
Description:
Dump out to console the ring buffer info
--*/
-void DumpRingInfo(struct hv_ring_buffer_info *RingInfo, char *Prefix)
+void Dumpring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
{
- u32 bytesAvailToWrite;
- u32 bytesAvailToRead;
+ u32 bytes_avail_towrite;
+ u32 bytes_avail_toread;
- GetRingBufferAvailBytes(RingInfo,
- &bytesAvailToRead,
- &bytesAvailToWrite);
+ GetRingBufferAvailBytes(ring_info,
+ &bytes_avail_toread,
+ &bytes_avail_towrite);
DPRINT(VMBUS,
DEBUG_RING_LVL,
"%s <<ringinfo %p buffer %p avail write %u "
"avail read %u read idx %u write idx %u>>",
- Prefix,
- RingInfo,
- RingInfo->ring_buffer->buffer,
- bytesAvailToWrite,
- bytesAvailToRead,
- RingInfo->ring_buffer->read_index,
- RingInfo->ring_buffer->write_index);
+ prefix,
+ ring_info,
+ ring_info->ring_buffer->buffer,
+ bytes_avail_towrite,
+ bytes_avail_toread,
+ ring_info->ring_buffer->read_index,
+ ring_info->ring_buffer->write_index);
}
@@ -233,17 +234,17 @@ void DumpRingInfo(struct hv_ring_buffer_info *RingInfo, char *Prefix)
static u32
CopyToRingBuffer(
- struct hv_ring_buffer_info *RingInfo,
- u32 StartWriteOffset,
- void *Src,
- u32 SrcLen);
+ struct hv_ring_buffer_info *ring_info,
+ u32 start_write_offset,
+ void *src,
+ u32 srclen);
static u32
CopyFromRingBuffer(
- struct hv_ring_buffer_info *RingInfo,
- void *Dest,
- u32 DestLen,
- u32 StartReadOffset);
+ struct hv_ring_buffer_info *ring_info,
+ void *dest,
+ u32 destlen,
+ u32 start_read_offset);
@@ -256,25 +257,25 @@ Description:
Get various debug metrics for the specified ring buffer
--*/
-void RingBufferGetDebugInfo(struct hv_ring_buffer_info *RingInfo,
+void RingBufferGetDebugInfo(struct hv_ring_buffer_info *ring_info,
struct hv_ring_buffer_debug_info *debug_info)
{
- u32 bytesAvailToWrite;
- u32 bytesAvailToRead;
+ u32 bytes_avail_towrite;
+ u32 bytes_avail_toread;
- if (RingInfo->ring_buffer) {
- GetRingBufferAvailBytes(RingInfo,
- &bytesAvailToRead,
- &bytesAvailToWrite);
+ if (ring_info->ring_buffer) {
+ GetRingBufferAvailBytes(ring_info,
+ &bytes_avail_toread,
+ &bytes_avail_towrite);
- debug_info->bytes_avail_toread = bytesAvailToRead;
- debug_info->bytes_avail_towrite = bytesAvailToWrite;
+ debug_info->bytes_avail_toread = bytes_avail_toread;
+ debug_info->bytes_avail_towrite = bytes_avail_towrite;
debug_info->current_read_index =
- RingInfo->ring_buffer->read_index;
+ ring_info->ring_buffer->read_index;
debug_info->current_write_index =
- RingInfo->ring_buffer->write_index;
+ ring_info->ring_buffer->write_index;
debug_info->current_interrupt_mask =
- RingInfo->ring_buffer->interrupt_mask;
+ ring_info->ring_buffer->interrupt_mask;
}
}
@@ -302,21 +303,22 @@ Description:
Initialize the ring buffer
--*/
-int RingBufferInit(struct hv_ring_buffer_info *RingInfo, void *Buffer, u32 BufferLen)
+int RingBufferInit(struct hv_ring_buffer_info *ring_info,
+ void *buffer, u32 buflen)
{
if (sizeof(struct hv_ring_buffer) != PAGE_SIZE)
return -EINVAL;
- memset(RingInfo, 0, sizeof(struct hv_ring_buffer_info));
+ memset(ring_info, 0, sizeof(struct hv_ring_buffer_info));
- RingInfo->ring_buffer = (struct hv_ring_buffer *)Buffer;
- RingInfo->ring_buffer->read_index =
- RingInfo->ring_buffer->write_index = 0;
+ ring_info->ring_buffer = (struct hv_ring_buffer *)buffer;
+ ring_info->ring_buffer->read_index =
+ ring_info->ring_buffer->write_index = 0;
- RingInfo->ring_size = BufferLen;
- RingInfo->ring_datasize = BufferLen - sizeof(struct hv_ring_buffer);
+ ring_info->ring_size = buflen;
+ ring_info->ring_datasize = buflen - sizeof(struct hv_ring_buffer);
- spin_lock_init(&RingInfo->ring_lock);
+ spin_lock_init(&ring_info->ring_lock);
return 0;
}
@@ -330,7 +332,7 @@ Description:
Cleanup the ring buffer
--*/
-void RingBufferCleanup(struct hv_ring_buffer_info *RingInfo)
+void RingBufferCleanup(struct hv_ring_buffer_info *ring_info)
{
}
@@ -343,78 +345,78 @@ Description:
Write to the ring buffer
--*/
-int RingBufferWrite(struct hv_ring_buffer_info *OutRingInfo,
+int RingBufferWrite(struct hv_ring_buffer_info *outring_info,
struct scatterlist *sglist, u32 sgcount)
{
int i = 0;
- u32 byteAvailToWrite;
- u32 byteAvailToRead;
- u32 totalBytesToWrite = 0;
+ u32 bytes_avail_towrite;
+ u32 bytes_avail_toread;
+ u32 totalbytes_towrite = 0;
struct scatterlist *sg;
- volatile u32 nextWriteLocation;
- u64 prevIndices = 0;
+ volatile u32 next_write_location;
+ u64 prev_indices = 0;
unsigned long flags;
for_each_sg(sglist, sg, sgcount, i)
{
- totalBytesToWrite += sg->length;
+ totalbytes_towrite += sg->length;
}
- totalBytesToWrite += sizeof(u64);
+ totalbytes_towrite += sizeof(u64);
- spin_lock_irqsave(&OutRingInfo->ring_lock, flags);
+ spin_lock_irqsave(&outring_info->ring_lock, flags);
- GetRingBufferAvailBytes(OutRingInfo,
- &byteAvailToRead,
- &byteAvailToWrite);
+ GetRingBufferAvailBytes(outring_info,
+ &bytes_avail_toread,
+ &bytes_avail_towrite);
- DPRINT_DBG(VMBUS, "Writing %u bytes...", totalBytesToWrite);
+ DPRINT_DBG(VMBUS, "Writing %u bytes...", totalbytes_towrite);
- /* DumpRingInfo(OutRingInfo, "BEFORE "); */
+ /* Dumpring_info(Outring_info, "BEFORE "); */
/* If there is only room for the packet, assume it is full. */
/* Otherwise, the next time around, we think the ring buffer */
/* is empty since the read index == write index */
- if (byteAvailToWrite <= totalBytesToWrite) {
+ if (bytes_avail_towrite <= totalbytes_towrite) {
DPRINT_DBG(VMBUS,
"No more space left on outbound ring buffer "
"(needed %u, avail %u)",
- totalBytesToWrite,
- byteAvailToWrite);
+ totalbytes_towrite,
+ bytes_avail_towrite);
- spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags);
+ spin_unlock_irqrestore(&outring_info->ring_lock, flags);
return -1;
}
/* Write to the ring buffer */
- nextWriteLocation = GetNextWriteLocation(OutRingInfo);
+ next_write_location = GetNextWriteLocation(outring_info);
for_each_sg(sglist, sg, sgcount, i)
{
- nextWriteLocation = CopyToRingBuffer(OutRingInfo,
- nextWriteLocation,
+ next_write_location = CopyToRingBuffer(outring_info,
+ next_write_location,
sg_virt(sg),
sg->length);
}
/* Set previous packet start */
- prevIndices = GetRingBufferIndices(OutRingInfo);
+ prev_indices = GetRingBufferIndices(outring_info);
- nextWriteLocation = CopyToRingBuffer(OutRingInfo,
- nextWriteLocation,
- &prevIndices,
+ next_write_location = CopyToRingBuffer(outring_info,
+ next_write_location,
+ &prev_indices,
sizeof(u64));
/* Make sure we flush all writes before updating the writeIndex */
mb();
/* Now, update the write location */
- SetNextWriteLocation(OutRingInfo, nextWriteLocation);
+ SetNextWriteLocation(outring_info, next_write_location);
- /* DumpRingInfo(OutRingInfo, "AFTER "); */
+ /* Dumpring_info(Outring_info, "AFTER "); */
- spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags);
+ spin_unlock_irqrestore(&outring_info->ring_lock, flags);
return 0;
}
@@ -428,41 +430,42 @@ Description:
Read without advancing the read index
--*/
-int RingBufferPeek(struct hv_ring_buffer_info *InRingInfo, void *Buffer, u32 BufferLen)
+int RingBufferPeek(struct hv_ring_buffer_info *Inring_info,
+ void *Buffer, u32 buflen)
{
- u32 bytesAvailToWrite;
- u32 bytesAvailToRead;
- u32 nextReadLocation = 0;
+ u32 bytes_avail_towrite;
+ u32 bytes_avail_toread;
+ u32 next_read_location = 0;
unsigned long flags;
- spin_lock_irqsave(&InRingInfo->ring_lock, flags);
+ spin_lock_irqsave(&Inring_info->ring_lock, flags);
- GetRingBufferAvailBytes(InRingInfo,
- &bytesAvailToRead,
- &bytesAvailToWrite);
+ GetRingBufferAvailBytes(Inring_info,
+ &bytes_avail_toread,
+ &bytes_avail_towrite);
/* Make sure there is something to read */
- if (bytesAvailToRead < BufferLen) {
+ if (bytes_avail_toread < buflen) {
/* DPRINT_DBG(VMBUS,
"got callback but not enough to read "
"<avail to read %d read size %d>!!",
- bytesAvailToRead,
+ bytes_avail_toread,
BufferLen); */
- spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
+ spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
return -1;
}
/* Convert to byte offset */
- nextReadLocation = GetNextReadLocation(InRingInfo);
+ next_read_location = GetNextReadLocation(Inring_info);
- nextReadLocation = CopyFromRingBuffer(InRingInfo,
+ next_read_location = CopyFromRingBuffer(Inring_info,
Buffer,
- BufferLen,
- nextReadLocation);
+ buflen,
+ next_read_location);
- spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
+ spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
return 0;
}
@@ -477,52 +480,52 @@ Description:
Read and advance the read index
--*/
-int RingBufferRead(struct hv_ring_buffer_info *InRingInfo, void *Buffer,
- u32 BufferLen, u32 Offset)
+int RingBufferRead(struct hv_ring_buffer_info *inring_info, void *buffer,
+ u32 buflen, u32 offset)
{
- u32 bytesAvailToWrite;
- u32 bytesAvailToRead;
- u32 nextReadLocation = 0;
- u64 prevIndices = 0;
+ u32 bytes_avail_towrite;
+ u32 bytes_avail_toread;
+ u32 next_read_location = 0;
+ u64 prev_indices = 0;
unsigned long flags;
- if (BufferLen <= 0)
+ if (buflen <= 0)
return -EINVAL;
- spin_lock_irqsave(&InRingInfo->ring_lock, flags);
+ spin_lock_irqsave(&inring_info->ring_lock, flags);
- GetRingBufferAvailBytes(InRingInfo,
- &bytesAvailToRead,
- &bytesAvailToWrite);
+ GetRingBufferAvailBytes(inring_info,
+ &bytes_avail_toread,
+ &bytes_avail_towrite);
- DPRINT_DBG(VMBUS, "Reading %u bytes...", BufferLen);
+ DPRINT_DBG(VMBUS, "Reading %u bytes...", buflen);
- /* DumpRingInfo(InRingInfo, "BEFORE "); */
+ /* Dumpring_info(Inring_info, "BEFORE "); */
/* Make sure there is something to read */
- if (bytesAvailToRead < BufferLen) {
+ if (bytes_avail_toread < buflen) {
DPRINT_DBG(VMBUS,
"got callback but not enough to read "
"<avail to read %d read size %d>!!",
- bytesAvailToRead,
- BufferLen);
+ bytes_avail_toread,
+ buflen);
- spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
+ spin_unlock_irqrestore(&inring_info->ring_lock, flags);
return -1;
}
- nextReadLocation = GetNextReadLocationWithOffset(InRingInfo, Offset);
+ next_read_location = GetNextReadLocationWithOffset(inring_info, offset);
- nextReadLocation = CopyFromRingBuffer(InRingInfo,
- Buffer,
- BufferLen,
- nextReadLocation);
+ next_read_location = CopyFromRingBuffer(inring_info,
+ buffer,
+ buflen,
+ next_read_location);
- nextReadLocation = CopyFromRingBuffer(InRingInfo,
- &prevIndices,
+ next_read_location = CopyFromRingBuffer(inring_info,
+ &prev_indices,
sizeof(u64),
- nextReadLocation);
+ next_read_location);
/* Make sure all reads are done before we update the read index since */
/* the writer may start writing to the read area once the read index */
@@ -530,11 +533,11 @@ int RingBufferRead(struct hv_ring_buffer_info *InRingInfo, void *Buffer,
mb();
/* Update the read index */
- SetNextReadLocation(InRingInfo, nextReadLocation);
+ SetNextReadLocation(inring_info, next_read_location);
- /* DumpRingInfo(InRingInfo, "AFTER "); */
+ /* Dumpring_info(Inring_info, "AFTER "); */
- spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
+ spin_unlock_irqrestore(&inring_info->ring_lock, flags);
return 0;
}
@@ -552,29 +555,29 @@ Description:
--*/
static u32
CopyToRingBuffer(
- struct hv_ring_buffer_info *RingInfo,
- u32 StartWriteOffset,
- void *Src,
- u32 SrcLen)
+ struct hv_ring_buffer_info *ring_info,
+ u32 start_write_offset,
+ void *src,
+ u32 srclen)
{
- void *ringBuffer = GetRingBuffer(RingInfo);
- u32 ringBufferSize = GetRingBufferSize(RingInfo);
- u32 fragLen;
+ void *ring_buffer = GetRingBuffer(ring_info);
+ u32 ring_buffer_size = GetRingBufferSize(ring_info);
+ u32 frag_len;
/* wrap-around detected! */
- if (SrcLen > ringBufferSize - StartWriteOffset) {
+ if (srclen > ring_buffer_size - start_write_offset) {
DPRINT_DBG(VMBUS, "wrap-around detected!");
- fragLen = ringBufferSize - StartWriteOffset;
- memcpy(ringBuffer + StartWriteOffset, Src, fragLen);
- memcpy(ringBuffer, Src + fragLen, SrcLen - fragLen);
+ frag_len = ring_buffer_size - start_write_offset;
+ memcpy(ring_buffer + start_write_offset, src, frag_len);
+ memcpy(ring_buffer, src + frag_len, srclen - frag_len);
} else
- memcpy(ringBuffer + StartWriteOffset, Src, SrcLen);
+ memcpy(ring_buffer + start_write_offset, src, srclen);
- StartWriteOffset += SrcLen;
- StartWriteOffset %= ringBufferSize;
+ start_write_offset += srclen;
+ start_write_offset %= ring_buffer_size;
- return StartWriteOffset;
+ return start_write_offset;
}
@@ -590,33 +593,33 @@ Description:
--*/
static u32
CopyFromRingBuffer(
- struct hv_ring_buffer_info *RingInfo,
- void *Dest,
- u32 DestLen,
- u32 StartReadOffset)
+ struct hv_ring_buffer_info *ring_info,
+ void *dest,
+ u32 destlen,
+ u32 start_read_offset)
{
- void *ringBuffer = GetRingBuffer(RingInfo);
- u32 ringBufferSize = GetRingBufferSize(RingInfo);
+ void *ring_buffer = GetRingBuffer(ring_info);
+ u32 ring_buffer_size = GetRingBufferSize(ring_info);
- u32 fragLen;
+ u32 frag_len;
/* wrap-around detected at the src */
- if (DestLen > ringBufferSize - StartReadOffset) {
+ if (destlen > ring_buffer_size - start_read_offset) {
DPRINT_DBG(VMBUS, "src wrap-around detected!");
- fragLen = ringBufferSize - StartReadOffset;
+ frag_len = ring_buffer_size - start_read_offset;
- memcpy(Dest, ringBuffer + StartReadOffset, fragLen);
- memcpy(Dest + fragLen, ringBuffer, DestLen - fragLen);
+ memcpy(dest, ring_buffer + start_read_offset, frag_len);
+ memcpy(dest + frag_len, ring_buffer, destlen - frag_len);
} else
- memcpy(Dest, ringBuffer + StartReadOffset, DestLen);
+ memcpy(dest, ring_buffer + start_read_offset, destlen);
- StartReadOffset += DestLen;
- StartReadOffset %= ringBufferSize;
+ start_read_offset += destlen;
+ start_read_offset %= ring_buffer_size;
- return StartReadOffset;
+ return start_read_offset;
}
diff --git a/drivers/staging/hv/ring_buffer.h b/drivers/staging/hv/ring_buffer.h
index bb4c5bc..f30be1f 100644
--- a/drivers/staging/hv/ring_buffer.h
+++ b/drivers/staging/hv/ring_buffer.h
@@ -75,28 +75,28 @@ struct hv_ring_buffer_debug_info {
/* Interface */
-int RingBufferInit(struct hv_ring_buffer_info *RingInfo, void *Buffer,
- u32 BufferLen);
+int RingBufferInit(struct hv_ring_buffer_info *ring_info, void *buffer,
+ u32 buflen);
-void RingBufferCleanup(struct hv_ring_buffer_info *RingInfo);
+void RingBufferCleanup(struct hv_ring_buffer_info *ring_info);
-int RingBufferWrite(struct hv_ring_buffer_info *RingInfo,
+int RingBufferWrite(struct hv_ring_buffer_info *ring_info,
struct scatterlist *sglist,
u32 sgcount);
-int RingBufferPeek(struct hv_ring_buffer_info *RingInfo, void *Buffer,
- u32 BufferLen);
+int RingBufferPeek(struct hv_ring_buffer_info *ring_info, void *buffer,
+ u32 buflen);
-int RingBufferRead(struct hv_ring_buffer_info *RingInfo,
- void *Buffer,
- u32 BufferLen,
- u32 Offset);
+int RingBufferRead(struct hv_ring_buffer_info *ring_info,
+ void *buffer,
+ u32 buflen,
+ u32 offset);
-u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *RingInfo);
+u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *ring_info);
-void DumpRingInfo(struct hv_ring_buffer_info *RingInfo, char *Prefix);
+void Dumpring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
-void RingBufferGetDebugInfo(struct hv_ring_buffer_info *RingInfo,
+void RingBufferGetDebugInfo(struct hv_ring_buffer_info *ring_info,
struct hv_ring_buffer_debug_info *debug_info);
#endif /* _RING_BUFFER_H_ */
--
1.6.3.2
^ permalink raw reply related
* [PATCH 08/10] staging: hv: Convert camel cased struct fields in ring_buffer.h to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-7-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased struct fields in ring_buffer.h to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 10 +++---
drivers/staging/hv/ring_buffer.c | 58 ++++++++++++++++++++-----------------
drivers/staging/hv/ring_buffer.h | 30 ++++++++++----------
drivers/staging/hv/vmbus_drv.c | 25 +++++++++-------
4 files changed, 65 insertions(+), 58 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index abc2988..0e554e9 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -213,7 +213,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
newchannel->ringbuffer_gpadlhandle = 0;
ret = vmbus_establish_gpadl(newchannel,
- newchannel->outbound.RingBuffer,
+ newchannel->outbound.ring_buffer,
send_ringbuffer_size +
recv_ringbuffer_size,
&newchannel->ringbuffer_gpadlhandle);
@@ -227,10 +227,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
"size %d recv ring %p size %d, downstreamoffset %d>",
newchannel, newchannel->offermsg.child_relid,
newchannel->ringbuffer_gpadlhandle,
- newchannel->outbound.RingBuffer,
- newchannel->outbound.RingSize,
- newchannel->inbound.RingBuffer,
- newchannel->inbound.RingSize,
+ newchannel->outbound.ring_buffer,
+ newchannel->outbound.ring_size,
+ newchannel->inbound.ring_buffer,
+ newchannel->inbound.ring_size,
send_ringbuffer_size);
/* Create and init the channel open message */
diff --git a/drivers/staging/hv/ring_buffer.c b/drivers/staging/hv/ring_buffer.c
index d78c569..6095cc5 100644
--- a/drivers/staging/hv/ring_buffer.c
+++ b/drivers/staging/hv/ring_buffer.c
@@ -51,11 +51,11 @@ GetRingBufferAvailBytes(struct hv_ring_buffer_info *rbi, u32 *read, u32 *write)
u32 read_loc, write_loc;
/* Capture the read/write indices before they changed */
- read_loc = rbi->RingBuffer->ReadIndex;
- write_loc = rbi->RingBuffer->WriteIndex;
+ read_loc = rbi->ring_buffer->read_index;
+ write_loc = rbi->ring_buffer->write_index;
- *write = BYTES_AVAIL_TO_WRITE(read_loc, write_loc, rbi->RingDataSize);
- *read = rbi->RingDataSize - *write;
+ *write = BYTES_AVAIL_TO_WRITE(read_loc, write_loc, rbi->ring_datasize);
+ *read = rbi->ring_datasize - *write;
}
/*++
@@ -70,7 +70,7 @@ Description:
static inline u32
GetNextWriteLocation(struct hv_ring_buffer_info *RingInfo)
{
- u32 next = RingInfo->RingBuffer->WriteIndex;
+ u32 next = RingInfo->ring_buffer->write_index;
/* ASSERT(next < RingInfo->RingDataSize); */
@@ -90,7 +90,7 @@ static inline void
SetNextWriteLocation(struct hv_ring_buffer_info *RingInfo,
u32 NextWriteLocation)
{
- RingInfo->RingBuffer->WriteIndex = NextWriteLocation;
+ RingInfo->ring_buffer->write_index = NextWriteLocation;
}
/*++
@@ -105,7 +105,7 @@ Description:
static inline u32
GetNextReadLocation(struct hv_ring_buffer_info *RingInfo)
{
- u32 next = RingInfo->RingBuffer->ReadIndex;
+ u32 next = RingInfo->ring_buffer->read_index;
/* ASSERT(next < RingInfo->RingDataSize); */
@@ -125,11 +125,11 @@ Description:
static inline u32
GetNextReadLocationWithOffset(struct hv_ring_buffer_info *RingInfo, u32 Offset)
{
- u32 next = RingInfo->RingBuffer->ReadIndex;
+ u32 next = RingInfo->ring_buffer->read_index;
/* ASSERT(next < RingInfo->RingDataSize); */
next += Offset;
- next %= RingInfo->RingDataSize;
+ next %= RingInfo->ring_datasize;
return next;
}
@@ -146,7 +146,7 @@ Description:
static inline void
SetNextReadLocation(struct hv_ring_buffer_info *RingInfo, u32 NextReadLocation)
{
- RingInfo->RingBuffer->ReadIndex = NextReadLocation;
+ RingInfo->ring_buffer->read_index = NextReadLocation;
}
@@ -162,7 +162,7 @@ Description:
static inline void *
GetRingBuffer(struct hv_ring_buffer_info *RingInfo)
{
- return (void *)RingInfo->RingBuffer->Buffer;
+ return (void *)RingInfo->ring_buffer->buffer;
}
@@ -178,7 +178,7 @@ Description:
static inline u32
GetRingBufferSize(struct hv_ring_buffer_info *RingInfo)
{
- return RingInfo->RingDataSize;
+ return RingInfo->ring_datasize;
}
/*++
@@ -193,7 +193,7 @@ Description:
static inline u64
GetRingBufferIndices(struct hv_ring_buffer_info *RingInfo)
{
- return (u64)RingInfo->RingBuffer->WriteIndex << 32;
+ return (u64)RingInfo->ring_buffer->write_index << 32;
}
@@ -221,11 +221,11 @@ void DumpRingInfo(struct hv_ring_buffer_info *RingInfo, char *Prefix)
"avail read %u read idx %u write idx %u>>",
Prefix,
RingInfo,
- RingInfo->RingBuffer->Buffer,
+ RingInfo->ring_buffer->buffer,
bytesAvailToWrite,
bytesAvailToRead,
- RingInfo->RingBuffer->ReadIndex,
- RingInfo->RingBuffer->WriteIndex);
+ RingInfo->ring_buffer->read_index,
+ RingInfo->ring_buffer->write_index);
}
@@ -262,16 +262,19 @@ void RingBufferGetDebugInfo(struct hv_ring_buffer_info *RingInfo,
u32 bytesAvailToWrite;
u32 bytesAvailToRead;
- if (RingInfo->RingBuffer) {
+ if (RingInfo->ring_buffer) {
GetRingBufferAvailBytes(RingInfo,
&bytesAvailToRead,
&bytesAvailToWrite);
- debug_info->BytesAvailToRead = bytesAvailToRead;
- debug_info->BytesAvailToWrite = bytesAvailToWrite;
- debug_info->CurrentReadIndex = RingInfo->RingBuffer->ReadIndex;
- debug_info->CurrentWriteIndex = RingInfo->RingBuffer->WriteIndex;
- debug_info->CurrentInterruptMask = RingInfo->RingBuffer->InterruptMask;
+ debug_info->bytes_avail_toread = bytesAvailToRead;
+ debug_info->bytes_avail_towrite = bytesAvailToWrite;
+ debug_info->current_read_index =
+ RingInfo->ring_buffer->read_index;
+ debug_info->current_write_index =
+ RingInfo->ring_buffer->write_index;
+ debug_info->current_interrupt_mask =
+ RingInfo->ring_buffer->interrupt_mask;
}
}
@@ -287,7 +290,7 @@ Description:
--*/
u32 GetRingBufferInterruptMask(struct hv_ring_buffer_info *rbi)
{
- return rbi->RingBuffer->InterruptMask;
+ return rbi->ring_buffer->interrupt_mask;
}
/*++
@@ -306,11 +309,12 @@ int RingBufferInit(struct hv_ring_buffer_info *RingInfo, void *Buffer, u32 Buffe
memset(RingInfo, 0, sizeof(struct hv_ring_buffer_info));
- RingInfo->RingBuffer = (struct hv_ring_buffer *)Buffer;
- RingInfo->RingBuffer->ReadIndex = RingInfo->RingBuffer->WriteIndex = 0;
+ RingInfo->ring_buffer = (struct hv_ring_buffer *)Buffer;
+ RingInfo->ring_buffer->read_index =
+ RingInfo->ring_buffer->write_index = 0;
- RingInfo->RingSize = BufferLen;
- RingInfo->RingDataSize = BufferLen - sizeof(struct hv_ring_buffer);
+ RingInfo->ring_size = BufferLen;
+ RingInfo->ring_datasize = BufferLen - sizeof(struct hv_ring_buffer);
spin_lock_init(&RingInfo->ring_lock);
diff --git a/drivers/staging/hv/ring_buffer.h b/drivers/staging/hv/ring_buffer.h
index a7f1717..bb4c5bc 100644
--- a/drivers/staging/hv/ring_buffer.h
+++ b/drivers/staging/hv/ring_buffer.h
@@ -29,18 +29,18 @@
struct hv_ring_buffer {
/* Offset in bytes from the start of ring data below */
- volatile u32 WriteIndex;
+ volatile u32 write_index;
/* Offset in bytes from the start of ring data below */
- volatile u32 ReadIndex;
+ volatile u32 read_index;
- volatile u32 InterruptMask;
+ volatile u32 interrupt_mask;
/* Pad it to PAGE_SIZE so that data starts on page boundary */
- u8 Reserved[4084];
+ u8 reserved[4084];
/* NOTE:
- * The InterruptMask field is used only for channels but since our
+ * The interrupt_mask field is used only for channels but since our
* vmbus connection also uses this data structure and its data starts
* here, we commented out this field.
*/
@@ -50,24 +50,24 @@ struct hv_ring_buffer {
* Ring data starts here + RingDataStartOffset
* !!! DO NOT place any fields below this !!!
*/
- u8 Buffer[0];
+ u8 buffer[0];
} __attribute__((packed));
struct hv_ring_buffer_info {
- struct hv_ring_buffer *RingBuffer;
- u32 RingSize; /* Include the shared header */
+ struct hv_ring_buffer *ring_buffer;
+ u32 ring_size; /* Include the shared header */
spinlock_t ring_lock;
- u32 RingDataSize; /* < ringSize */
- u32 RingDataStartOffset;
+ u32 ring_datasize; /* < ring_size */
+ u32 ring_data_startoffset;
};
struct hv_ring_buffer_debug_info {
- u32 CurrentInterruptMask;
- u32 CurrentReadIndex;
- u32 CurrentWriteIndex;
- u32 BytesAvailToRead;
- u32 BytesAvailToWrite;
+ u32 current_interrupt_mask;
+ u32 current_read_index;
+ u32 current_write_index;
+ u32 bytes_avail_toread;
+ u32 bytes_avail_towrite;
};
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 2bbf4ec..0965875 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -156,18 +156,21 @@ static void get_channel_info(struct hv_device *device,
info->ClientMonitorLatency = debug_info.clientmonitor_latency;
info->ClientMonitorConnectionId = debug_info.clientmonitor_connectionid;
- info->Inbound.InterruptMask = debug_info.inbound.CurrentInterruptMask;
- info->Inbound.ReadIndex = debug_info.inbound.CurrentReadIndex;
- info->Inbound.WriteIndex = debug_info.inbound.CurrentWriteIndex;
- info->Inbound.BytesAvailToRead = debug_info.inbound.BytesAvailToRead;
- info->Inbound.BytesAvailToWrite = debug_info.inbound.BytesAvailToWrite;
-
- info->Outbound.InterruptMask = debug_info.outbound.CurrentInterruptMask;
- info->Outbound.ReadIndex = debug_info.outbound.CurrentReadIndex;
- info->Outbound.WriteIndex = debug_info.outbound.CurrentWriteIndex;
- info->Outbound.BytesAvailToRead = debug_info.outbound.BytesAvailToRead;
+ info->Inbound.InterruptMask = debug_info.inbound.current_interrupt_mask;
+ info->Inbound.ReadIndex = debug_info.inbound.current_read_index;
+ info->Inbound.WriteIndex = debug_info.inbound.current_write_index;
+ info->Inbound.BytesAvailToRead = debug_info.inbound.bytes_avail_toread;
+ info->Inbound.BytesAvailToWrite =
+ debug_info.inbound.bytes_avail_towrite;
+
+ info->Outbound.InterruptMask =
+ debug_info.outbound.current_interrupt_mask;
+ info->Outbound.ReadIndex = debug_info.outbound.current_read_index;
+ info->Outbound.WriteIndex = debug_info.outbound.current_write_index;
+ info->Outbound.BytesAvailToRead =
+ debug_info.outbound.bytes_avail_toread;
info->Outbound.BytesAvailToWrite =
- debug_info.outbound.BytesAvailToWrite;
+ debug_info.outbound.bytes_avail_towrite;
}
/*
--
1.6.3.2
^ permalink raw reply related
* [PATCH 07/10] staging: hv: Convert camel cased functions in osd.c to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-6-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased functions in osd.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 20 +++++++++---------
drivers/staging/hv/channel_mgmt.c | 12 +++++-----
drivers/staging/hv/connection.c | 14 ++++++------
drivers/staging/hv/hv.c | 12 +++++-----
drivers/staging/hv/netvsc.c | 24 +++++++++++-----------
drivers/staging/hv/osd.c | 40 ++++++++++++++++++------------------
drivers/staging/hv/osd.h | 18 ++++++++--------
drivers/staging/hv/rndis_filter.c | 10 ++++----
drivers/staging/hv/storvsc.c | 16 +++++++-------
9 files changed, 83 insertions(+), 83 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 7c15c40..abc2988 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -180,7 +180,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
newchannel->channel_callback_context = context;
/* Allocate the ring buffer */
- out = osd_PageAlloc((send_ringbuffer_size + recv_ringbuffer_size)
+ out = osd_page_alloc((send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
if (!out)
return -ENOMEM;
@@ -242,7 +242,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
goto errorout;
}
- openInfo->waitevent = osd_WaitEventCreate();
+ openInfo->waitevent = osd_waitevent_create();
if (!openInfo->waitevent) {
err = -ENOMEM;
goto errorout;
@@ -280,7 +280,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
}
/* FIXME: Need to time-out here */
- osd_WaitEventWait(openInfo->waitevent);
+ osd_waitevent_wait(openInfo->waitevent);
if (openInfo->response.open_result.status == 0)
DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
@@ -300,7 +300,7 @@ Cleanup:
errorout:
RingBufferCleanup(&newchannel->outbound);
RingBufferCleanup(&newchannel->inbound);
- osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
+ osd_page_free(out, (send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
kfree(openInfo);
return err;
@@ -508,7 +508,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
if (ret)
return ret;
- msginfo->waitevent = osd_WaitEventCreate();
+ msginfo->waitevent = osd_waitevent_create();
if (!msginfo->waitevent) {
ret = -ENOMEM;
goto Cleanup;
@@ -565,7 +565,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
}
}
- osd_WaitEventWait(msginfo->waitevent);
+ osd_waitevent_wait(msginfo->waitevent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
@@ -604,7 +604,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
if (!info)
return -ENOMEM;
- info->waitevent = osd_WaitEventCreate();
+ info->waitevent = osd_waitevent_create();
if (!info->waitevent) {
kfree(info);
return -ENOMEM;
@@ -628,7 +628,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
/* something... */
}
- osd_WaitEventWait(info->waitevent);
+ osd_waitevent_wait(info->waitevent);
/* Received a torndown response */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
@@ -663,7 +663,7 @@ void vmbus_close(struct vmbus_channel *channel)
if (!info)
return;
- /* info->waitEvent = osd_WaitEventCreate(); */
+ /* info->waitEvent = osd_waitevent_create(); */
msg = (struct vmbus_channel_close_channel *)info->msg;
msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
@@ -686,7 +686,7 @@ void vmbus_close(struct vmbus_channel *channel)
RingBufferCleanup(&channel->outbound);
RingBufferCleanup(&channel->inbound);
- osd_PageFree(channel->ringbuffer_pages, channel->ringbuffer_pagecount);
+ osd_page_free(channel->ringbuffer_pages, channel->ringbuffer_pagecount);
kfree(info);
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index be34e38..ae830f2 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -566,7 +566,7 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
memcpy(&msginfo->response.open_result,
result,
sizeof(struct vmbus_channel_open_result));
- osd_WaitEventSet(msginfo->waitevent);
+ osd_waitevent_set(msginfo->waitevent);
break;
}
}
@@ -616,7 +616,7 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
memcpy(&msginfo->response.gpadl_created,
gpadlcreated,
sizeof(struct vmbus_channel_gpadl_created));
- osd_WaitEventSet(msginfo->waitevent);
+ osd_waitevent_set(msginfo->waitevent);
break;
}
}
@@ -662,7 +662,7 @@ static void vmbus_ongpadl_torndown(
memcpy(&msginfo->response.gpadl_torndown,
gpadl_torndown,
sizeof(struct vmbus_channel_gpadl_torndown));
- osd_WaitEventSet(msginfo->waitevent);
+ osd_waitevent_set(msginfo->waitevent);
break;
}
}
@@ -703,7 +703,7 @@ static void vmbus_onversion_response(
memcpy(&msginfo->response.version_response,
version_response,
sizeof(struct vmbus_channel_version_response));
- osd_WaitEventSet(msginfo->waitevent);
+ osd_waitevent_set(msginfo->waitevent);
}
}
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
@@ -782,7 +782,7 @@ int vmbus_request_offers(void)
if (!msginfo)
return -ENOMEM;
- msginfo->waitevent = osd_WaitEventCreate();
+ msginfo->waitevent = osd_waitevent_create();
if (!msginfo->waitevent) {
kfree(msginfo);
return -ENOMEM;
@@ -808,7 +808,7 @@ int vmbus_request_offers(void)
goto Cleanup;
}
- /* osd_WaitEventWait(msgInfo->waitEvent); */
+ /* osd_waitevent_wait(msgInfo->waitEvent); */
/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 97321d1..c2e298f 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -66,7 +66,7 @@ int VmbusConnect(void)
* Setup the vmbus event connection for channel interrupt
* abstraction stuff
*/
- gVmbusConnection.InterruptPage = osd_PageAlloc(1);
+ gVmbusConnection.InterruptPage = osd_page_alloc(1);
if (gVmbusConnection.InterruptPage == NULL) {
ret = -1;
goto Cleanup;
@@ -81,7 +81,7 @@ int VmbusConnect(void)
* Setup the monitor notification facility. The 1st page for
* parent->child and the 2nd page for child->parent
*/
- gVmbusConnection.MonitorPages = osd_PageAlloc(2);
+ gVmbusConnection.MonitorPages = osd_page_alloc(2);
if (gVmbusConnection.MonitorPages == NULL) {
ret = -1;
goto Cleanup;
@@ -95,7 +95,7 @@ int VmbusConnect(void)
goto Cleanup;
}
- msgInfo->waitevent = osd_WaitEventCreate();
+ msgInfo->waitevent = osd_waitevent_create();
if (!msgInfo->waitevent) {
ret = -ENOMEM;
goto Cleanup;
@@ -134,7 +134,7 @@ int VmbusConnect(void)
}
/* Wait for the connection response */
- osd_WaitEventWait(msgInfo->waitevent);
+ osd_waitevent_wait(msgInfo->waitevent);
list_del(&msgInfo->msglistentry);
@@ -162,12 +162,12 @@ Cleanup:
destroy_workqueue(gVmbusConnection.WorkQueue);
if (gVmbusConnection.InterruptPage) {
- osd_PageFree(gVmbusConnection.InterruptPage, 1);
+ osd_page_free(gVmbusConnection.InterruptPage, 1);
gVmbusConnection.InterruptPage = NULL;
}
if (gVmbusConnection.MonitorPages) {
- osd_PageFree(gVmbusConnection.MonitorPages, 2);
+ osd_page_free(gVmbusConnection.MonitorPages, 2);
gVmbusConnection.MonitorPages = NULL;
}
@@ -202,7 +202,7 @@ int VmbusDisconnect(void)
if (ret != 0)
goto Cleanup;
- osd_PageFree(gVmbusConnection.InterruptPage, 1);
+ osd_page_free(gVmbusConnection.InterruptPage, 1);
/* TODO: iterate thru the msg list and free up */
destroy_workqueue(gVmbusConnection.WorkQueue);
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 66f04d8..a34d713 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -228,9 +228,9 @@ int hv_init(void)
/*
* Allocate the hypercall page memory
- * virtaddr = osd_PageAlloc(1);
+ * virtaddr = osd_page_alloc(1);
*/
- virtaddr = osd_VirtualAllocExec(PAGE_SIZE);
+ virtaddr = osd_virtual_alloc_exec(PAGE_SIZE);
if (!virtaddr) {
DPRINT_ERR(VMBUS,
@@ -462,10 +462,10 @@ void hv_synic_init(void *irqarg)
Cleanup:
if (hv_context.synic_event_page[cpu])
- osd_PageFree(hv_context.synic_event_page[cpu], 1);
+ osd_page_free(hv_context.synic_event_page[cpu], 1);
if (hv_context.synic_message_page[cpu])
- osd_PageFree(hv_context.synic_message_page[cpu], 1);
+ osd_page_free(hv_context.synic_message_page[cpu], 1);
return;
}
@@ -502,6 +502,6 @@ void hv_synic_cleanup(void *arg)
wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
- osd_PageFree(hv_context.synic_message_page[cpu], 1);
- osd_PageFree(hv_context.synic_event_page[cpu], 1);
+ osd_page_free(hv_context.synic_message_page[cpu], 1);
+ osd_page_free(hv_context.synic_event_page[cpu], 1);
}
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index 4c2632c..8022781 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -221,7 +221,7 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device)
/* ASSERT((netDevice->ReceiveBufferSize & (PAGE_SIZE - 1)) == 0); */
netDevice->ReceiveBuffer =
- osd_PageAlloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT);
+ osd_page_alloc(netDevice->ReceiveBufferSize >> PAGE_SHIFT);
if (!netDevice->ReceiveBuffer) {
DPRINT_ERR(NETVSC,
"unable to allocate receive buffer of size %d",
@@ -249,7 +249,7 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device)
goto Cleanup;
}
- /* osd_WaitEventWait(ext->ChannelInitEvent); */
+ /* osd_waitevent_wait(ext->ChannelInitEvent); */
/* Notify the NetVsp of the gpadl handle */
DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendReceiveBuffer...");
@@ -274,7 +274,7 @@ static int NetVscInitializeReceiveBufferWithNetVsp(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(netDevice->ChannelInitEvent);
+ osd_waitevent_wait(netDevice->ChannelInitEvent);
/* Check the response */
if (initPacket->Messages.Version1Messages.SendReceiveBufferComplete.Status != NvspStatusSuccess) {
@@ -350,7 +350,7 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device)
/* ASSERT((netDevice->SendBufferSize & (PAGE_SIZE - 1)) == 0); */
netDevice->SendBuffer =
- osd_PageAlloc(netDevice->SendBufferSize >> PAGE_SHIFT);
+ osd_page_alloc(netDevice->SendBufferSize >> PAGE_SHIFT);
if (!netDevice->SendBuffer) {
DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d",
netDevice->SendBufferSize);
@@ -375,7 +375,7 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device)
goto Cleanup;
}
- /* osd_WaitEventWait(ext->ChannelInitEvent); */
+ /* osd_waitevent_wait(ext->ChannelInitEvent); */
/* Notify the NetVsp of the gpadl handle */
DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendSendBuffer...");
@@ -400,7 +400,7 @@ static int NetVscInitializeSendBufferWithNetVsp(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(netDevice->ChannelInitEvent);
+ osd_waitevent_wait(netDevice->ChannelInitEvent);
/* Check the response */
if (initPacket->Messages.Version1Messages.SendSendBufferComplete.Status != NvspStatusSuccess) {
@@ -480,7 +480,7 @@ static int NetVscDestroyReceiveBuffer(struct netvsc_device *NetDevice)
DPRINT_INFO(NETVSC, "Freeing up receive buffer...");
/* Free up the receive buffer */
- osd_PageFree(NetDevice->ReceiveBuffer,
+ osd_page_free(NetDevice->ReceiveBuffer,
NetDevice->ReceiveBufferSize >> PAGE_SHIFT);
NetDevice->ReceiveBuffer = NULL;
}
@@ -553,7 +553,7 @@ static int NetVscDestroySendBuffer(struct netvsc_device *NetDevice)
DPRINT_INFO(NETVSC, "Freeing up send buffer...");
/* Free up the receive buffer */
- osd_PageFree(NetDevice->SendBuffer,
+ osd_page_free(NetDevice->SendBuffer,
NetDevice->SendBufferSize >> PAGE_SHIFT);
NetDevice->SendBuffer = NULL;
}
@@ -597,7 +597,7 @@ static int NetVscConnectToVsp(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(netDevice->ChannelInitEvent);
+ osd_waitevent_wait(netDevice->ChannelInitEvent);
/* Now, check the response */
/* ASSERT(initPacket->Messages.InitMessages.InitComplete.MaximumMdlChainLength <= MAX_MULTIPAGE_BUFFER_COUNT); */
@@ -651,7 +651,7 @@ static int NetVscConnectToVsp(struct hv_device *Device)
* packet) since our Vmbus always set the
* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED flag
*/
- /* osd_WaitEventWait(NetVscChannel->ChannelInitEvent); */
+ /* osd_waitevent_wait(NetVscChannel->ChannelInitEvent); */
/* Post the big receive buffer to NetVSP */
ret = NetVscInitializeReceiveBufferWithNetVsp(Device);
@@ -710,7 +710,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
list_add_tail(&packet->ListEntry,
&netDevice->ReceivePacketList);
}
- netDevice->ChannelInitEvent = osd_WaitEventCreate();
+ netDevice->ChannelInitEvent = osd_waitevent_create();
if (!netDevice->ChannelInitEvent) {
ret = -ENOMEM;
goto Cleanup;
@@ -855,7 +855,7 @@ static void NetVscOnSendCompletion(struct hv_device *Device,
/* Copy the response back */
memcpy(&netDevice->ChannelInitPacket, nvspPacket,
sizeof(struct nvsp_message));
- osd_WaitEventSet(netDevice->ChannelInitEvent);
+ osd_waitevent_set(netDevice->ChannelInitEvent);
} else if (nvspPacket->Header.MessageType ==
NvspMessage1TypeSendRNDISPacketComplete) {
/* Get the send context */
diff --git a/drivers/staging/hv/osd.c b/drivers/staging/hv/osd.c
index b39ec25..b699ee2 100644
--- a/drivers/staging/hv/osd.c
+++ b/drivers/staging/hv/osd.c
@@ -49,7 +49,7 @@ struct osd_callback_struct {
void *data;
};
-void *osd_VirtualAllocExec(unsigned int size)
+void *osd_virtual_alloc_exec(unsigned int size)
{
#ifdef __x86_64__
return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL_EXEC);
@@ -60,7 +60,7 @@ void *osd_VirtualAllocExec(unsigned int size)
}
/**
- * osd_PageAlloc() - Allocate pages
+ * osd_page_alloc() - Allocate pages
* @count: Total number of Kernel pages you want to allocate
*
* Tries to allocate @count number of consecutive free kernel pages.
@@ -68,7 +68,7 @@ void *osd_VirtualAllocExec(unsigned int size)
* If successfull it will return pointer to the @count pages.
* Mainly used by Hyper-V drivers.
*/
-void *osd_PageAlloc(unsigned int count)
+void *osd_page_alloc(unsigned int count)
{
void *p;
@@ -85,26 +85,26 @@ void *osd_PageAlloc(unsigned int count)
/* if (p) memset(p, 0, PAGE_SIZE); */
/* return p; */
}
-EXPORT_SYMBOL_GPL(osd_PageAlloc);
+EXPORT_SYMBOL_GPL(osd_page_alloc);
/**
- * osd_PageFree() - Free pages
+ * osd_page_free() - Free pages
* @page: Pointer to the first page to be freed
* @count: Total number of Kernel pages you free
*
- * Frees the pages allocated by osd_PageAlloc()
+ * Frees the pages allocated by osd_page_alloc()
* Mainly used by Hyper-V drivers.
*/
-void osd_PageFree(void *page, unsigned int count)
+void osd_page_free(void *page, unsigned int count)
{
free_pages((unsigned long)page, get_order(count * PAGE_SIZE));
/*struct page* p = virt_to_page(page);
__free_page(p);*/
}
-EXPORT_SYMBOL_GPL(osd_PageFree);
+EXPORT_SYMBOL_GPL(osd_page_free);
/**
- * osd_WaitEventCreate() - Create the event queue
+ * osd_waitevent_create() - Create the event queue
*
* Allocates memory for a &struct osd_waitevent. And then calls
* init_waitqueue_head to set up the wait queue for the event.
@@ -114,7 +114,7 @@ EXPORT_SYMBOL_GPL(osd_PageFree);
* Returns pointer to &struct osd_waitevent
* Mainly used by Hyper-V drivers.
*/
-struct osd_waitevent *osd_WaitEventCreate(void)
+struct osd_waitevent *osd_waitevent_create(void)
{
struct osd_waitevent *wait = kmalloc(sizeof(struct osd_waitevent),
GFP_KERNEL);
@@ -125,11 +125,11 @@ struct osd_waitevent *osd_WaitEventCreate(void)
init_waitqueue_head(&wait->event);
return wait;
}
-EXPORT_SYMBOL_GPL(osd_WaitEventCreate);
+EXPORT_SYMBOL_GPL(osd_waitevent_create);
/**
- * osd_WaitEventSet() - Wake up the process
+ * osd_waitevent_set() - Wake up the process
* @wait_event: Structure to event to be woken up
*
* @wait_event is of type &struct osd_waitevent
@@ -140,15 +140,15 @@ EXPORT_SYMBOL_GPL(osd_WaitEventCreate);
*
* Only used by Network and Storage Hyper-V drivers.
*/
-void osd_WaitEventSet(struct osd_waitevent *wait_event)
+void osd_waitevent_set(struct osd_waitevent *wait_event)
{
wait_event->condition = 1;
wake_up_interruptible(&wait_event->event);
}
-EXPORT_SYMBOL_GPL(osd_WaitEventSet);
+EXPORT_SYMBOL_GPL(osd_waitevent_set);
/**
- * osd_WaitEventWait() - Wait for event till condition is true
+ * osd_waitevent_wait() - Wait for event till condition is true
* @wait_event: Structure to event to be put to sleep
*
* @wait_event is of type &struct osd_waitevent
@@ -161,7 +161,7 @@ EXPORT_SYMBOL_GPL(osd_WaitEventSet);
*
* Mainly used by Hyper-V drivers.
*/
-int osd_WaitEventWait(struct osd_waitevent *wait_event)
+int osd_waitevent_wait(struct osd_waitevent *wait_event)
{
int ret = 0;
@@ -170,10 +170,10 @@ int osd_WaitEventWait(struct osd_waitevent *wait_event)
wait_event->condition = 0;
return ret;
}
-EXPORT_SYMBOL_GPL(osd_WaitEventWait);
+EXPORT_SYMBOL_GPL(osd_waitevent_wait);
/**
- * osd_WaitEventWaitEx() - Wait for event or timeout for process wakeup
+ * osd_waitevent_waitex() - Wait for event or timeout for process wakeup
* @wait_event: Structure to event to be put to sleep
* @timeout_in_ms: Total number of Milliseconds to wait before waking up
*
@@ -187,7 +187,7 @@ EXPORT_SYMBOL_GPL(osd_WaitEventWait);
*
* Mainly used by Hyper-V drivers.
*/
-int osd_WaitEventWaitEx(struct osd_waitevent *wait_event, u32 timeout_in_ms)
+int osd_waitevent_waitex(struct osd_waitevent *wait_event, u32 timeout_in_ms)
{
int ret = 0;
@@ -197,7 +197,7 @@ int osd_WaitEventWaitEx(struct osd_waitevent *wait_event, u32 timeout_in_ms)
wait_event->condition = 0;
return ret;
}
-EXPORT_SYMBOL_GPL(osd_WaitEventWaitEx);
+EXPORT_SYMBOL_GPL(osd_waitevent_waitex);
static void osd_callback_work(struct work_struct *work)
{
diff --git a/drivers/staging/hv/osd.h b/drivers/staging/hv/osd.h
index ce064e8..cae126f 100644
--- a/drivers/staging/hv/osd.h
+++ b/drivers/staging/hv/osd.h
@@ -50,18 +50,18 @@ struct osd_waitevent {
/* Osd routines */
-extern void *osd_VirtualAllocExec(unsigned int size);
+extern void *osd_virtual_alloc_exec(unsigned int size);
-extern void *osd_PageAlloc(unsigned int count);
-extern void osd_PageFree(void *page, unsigned int count);
+extern void *osd_page_alloc(unsigned int count);
+extern void osd_page_free(void *page, unsigned int count);
-extern struct osd_waitevent *osd_WaitEventCreate(void);
-extern void osd_WaitEventSet(struct osd_waitevent *waitEvent);
-extern int osd_WaitEventWait(struct osd_waitevent *waitEvent);
+extern struct osd_waitevent *osd_waitevent_create(void);
+extern void osd_waitevent_set(struct osd_waitevent *wait_event);
+extern int osd_waitevent_wait(struct osd_waitevent *wait_event);
-/* If >0, waitEvent got signaled. If ==0, timeout. If < 0, error */
-extern int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent,
- u32 TimeoutInMs);
+/* If >0, wait_event got signaled. If ==0, timeout. If < 0, error */
+extern int osd_waitevent_waitex(struct osd_waitevent *wait_event,
+ u32 timeout_in_ms);
int osd_schedule_callback(struct workqueue_struct *wq,
void (*func)(void *),
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index fa2141f..b85c825 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -129,7 +129,7 @@ static struct rndis_request *GetRndisRequest(struct rndis_device *Device,
if (!request)
return NULL;
- request->WaitEvent = osd_WaitEventCreate();
+ request->WaitEvent = osd_waitevent_create();
if (!request->WaitEvent) {
kfree(request);
return NULL;
@@ -313,7 +313,7 @@ static void RndisFilterReceiveResponse(struct rndis_device *Device,
}
}
- osd_WaitEventSet(request->WaitEvent);
+ osd_waitevent_set(request->WaitEvent);
} else {
DPRINT_ERR(NETVSC, "no rndis request found for this response "
"(id 0x%x res type 0x%x)",
@@ -497,7 +497,7 @@ static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid,
if (ret != 0)
goto Cleanup;
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
/* Copy the response back */
queryComplete = &request->ResponseMessage.Message.QueryComplete;
@@ -572,7 +572,7 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device,
if (ret != 0)
goto Cleanup;
- ret = osd_WaitEventWaitEx(request->WaitEvent, 2000/*2sec*/);
+ ret = osd_waitevent_waitex(request->WaitEvent, 2000/*2sec*/);
if (!ret) {
ret = -1;
DPRINT_ERR(NETVSC, "timeout before we got a set response...");
@@ -665,7 +665,7 @@ static int RndisFilterInitDevice(struct rndis_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
initComplete = &request->ResponseMessage.Message.InitializeComplete;
status = initComplete->Status;
diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
index 19e87f6..525c8ee 100644
--- a/drivers/staging/hv/storvsc.c
+++ b/drivers/staging/hv/storvsc.c
@@ -198,7 +198,7 @@ static int StorVscChannelInit(struct hv_device *Device)
* channel
*/
memset(request, 0, sizeof(struct storvsc_request_extension));
- request->WaitEvent = osd_WaitEventCreate();
+ request->WaitEvent = osd_waitevent_create();
if (!request->WaitEvent) {
ret = -ENOMEM;
goto nomem;
@@ -224,7 +224,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
if (vstorPacket->Operation != VStorOperationCompleteIo ||
vstorPacket->Status != 0) {
@@ -255,7 +255,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
/* TODO: Check returned version */
if (vstorPacket->Operation != VStorOperationCompleteIo ||
@@ -287,7 +287,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
/* TODO: Check returned version */
if (vstorPacket->Operation != VStorOperationCompleteIo ||
@@ -323,7 +323,7 @@ static int StorVscChannelInit(struct hv_device *Device)
goto Cleanup;
}
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
if (vstorPacket->Operation != VStorOperationCompleteIo ||
vstorPacket->Status != 0) {
@@ -473,7 +473,7 @@ static void StorVscOnChannelCallback(void *context)
memcpy(&request->VStorPacket, packet,
sizeof(struct vstor_packet));
- osd_WaitEventSet(request->WaitEvent);
+ osd_waitevent_set(request->WaitEvent);
} else {
StorVscOnReceive(device,
(struct vstor_packet *)packet,
@@ -622,7 +622,7 @@ int StorVscOnHostReset(struct hv_device *Device)
request = &storDevice->ResetRequest;
vstorPacket = &request->VStorPacket;
- request->WaitEvent = osd_WaitEventCreate();
+ request->WaitEvent = osd_waitevent_create();
if (!request->WaitEvent) {
ret = -ENOMEM;
goto Cleanup;
@@ -644,7 +644,7 @@ int StorVscOnHostReset(struct hv_device *Device)
}
/* FIXME: Add a timeout */
- osd_WaitEventWait(request->WaitEvent);
+ osd_waitevent_wait(request->WaitEvent);
kfree(request->WaitEvent);
DPRINT_INFO(STORVSC, "host adapter reset completed");
--
1.6.3.2
^ permalink raw reply related
* [PATCH 06/10] staging: hv: Convert camel cased local variables in osd.c to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-5-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased local variables in osd.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/osd.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/hv/osd.c b/drivers/staging/hv/osd.c
index 8c3eb27..b39ec25 100644
--- a/drivers/staging/hv/osd.c
+++ b/drivers/staging/hv/osd.c
@@ -130,9 +130,9 @@ EXPORT_SYMBOL_GPL(osd_WaitEventCreate);
/**
* osd_WaitEventSet() - Wake up the process
- * @waitEvent: Structure to event to be woken up
+ * @wait_event: Structure to event to be woken up
*
- * @waitevent is of type &struct osd_waitevent
+ * @wait_event is of type &struct osd_waitevent
*
* Wake up the sleeping process so it can do some work.
* And set condition indicator in &struct osd_waitevent to indicate
@@ -140,18 +140,18 @@ EXPORT_SYMBOL_GPL(osd_WaitEventCreate);
*
* Only used by Network and Storage Hyper-V drivers.
*/
-void osd_WaitEventSet(struct osd_waitevent *waitEvent)
+void osd_WaitEventSet(struct osd_waitevent *wait_event)
{
- waitEvent->condition = 1;
- wake_up_interruptible(&waitEvent->event);
+ wait_event->condition = 1;
+ wake_up_interruptible(&wait_event->event);
}
EXPORT_SYMBOL_GPL(osd_WaitEventSet);
/**
* osd_WaitEventWait() - Wait for event till condition is true
- * @waitEvent: Structure to event to be put to sleep
+ * @wait_event: Structure to event to be put to sleep
*
- * @waitevent is of type &struct osd_waitevent
+ * @wait_event is of type &struct osd_waitevent
*
* Set up the process to sleep until waitEvent->condition get true.
* And set condition indicator in &struct osd_waitevent to indicate
@@ -161,25 +161,25 @@ EXPORT_SYMBOL_GPL(osd_WaitEventSet);
*
* Mainly used by Hyper-V drivers.
*/
-int osd_WaitEventWait(struct osd_waitevent *waitEvent)
+int osd_WaitEventWait(struct osd_waitevent *wait_event)
{
int ret = 0;
- ret = wait_event_interruptible(waitEvent->event,
- waitEvent->condition);
- waitEvent->condition = 0;
+ ret = wait_event_interruptible(wait_event->event,
+ wait_event->condition);
+ wait_event->condition = 0;
return ret;
}
EXPORT_SYMBOL_GPL(osd_WaitEventWait);
/**
* osd_WaitEventWaitEx() - Wait for event or timeout for process wakeup
- * @waitEvent: Structure to event to be put to sleep
- * @TimeoutInMs: Total number of Milliseconds to wait before waking up
+ * @wait_event: Structure to event to be put to sleep
+ * @timeout_in_ms: Total number of Milliseconds to wait before waking up
*
- * @waitevent is of type &struct osd_waitevent
+ * @wait_event is of type &struct osd_waitevent
* Set up the process to sleep until @waitEvent->condition get true or
- * @TimeoutInMs (Time out in Milliseconds) has been reached.
+ * @timeout_in_ms (Time out in Milliseconds) has been reached.
* And set condition indicator in &struct osd_waitevent to indicate
* the process is in a sleeping state.
*
@@ -187,14 +187,14 @@ EXPORT_SYMBOL_GPL(osd_WaitEventWait);
*
* Mainly used by Hyper-V drivers.
*/
-int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs)
+int osd_WaitEventWaitEx(struct osd_waitevent *wait_event, u32 timeout_in_ms)
{
int ret = 0;
- ret = wait_event_interruptible_timeout(waitEvent->event,
- waitEvent->condition,
- msecs_to_jiffies(TimeoutInMs));
- waitEvent->condition = 0;
+ ret = wait_event_interruptible_timeout(wait_event->event,
+ wait_event->condition,
+ msecs_to_jiffies(timeout_in_ms));
+ wait_event->condition = 0;
return ret;
}
EXPORT_SYMBOL_GPL(osd_WaitEventWaitEx);
--
1.6.3.2
^ permalink raw reply related
* [PATCH 05/10] staging: hv: Convert camel cased functions in hv.c to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-4-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased functions in hv.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/connection.c | 4 +-
drivers/staging/hv/hv.c | 47 ++++++++++++++++++++------------------
drivers/staging/hv/hv.h | 16 ++++++------
drivers/staging/hv/hv_api.h | 4 +-
drivers/staging/hv/vmbus.c | 8 +++---
5 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index ba50dd8..97321d1 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -311,7 +311,7 @@ int VmbusPostMessage(void *buffer, size_t bufferLen)
connId.asu32 = 0;
connId.u.id = VMBUS_MESSAGE_CONNECTION_ID;
- return HvPostMessage(connId, 1, buffer, bufferLen);
+ return hv_post_message(connId, 1, buffer, bufferLen);
}
/*
@@ -324,5 +324,5 @@ int VmbusSetEvent(u32 childRelId)
(unsigned long *)gVmbusConnection.SendInterruptPage +
(childRelId >> 5));
- return HvSignalEvent();
+ return hv_signal_event();
}
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 2fd234d..66f04d8 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -36,9 +36,10 @@ struct hv_context hv_context = {
};
/*
- * HvQueryHypervisorPresence - Query the cpuid for presense of windows hypervisor
+ * query_hypervisor_presence
+ * - Query the cpuid for presense of windows hypervisor
*/
-static int HvQueryHypervisorPresence(void)
+static int query_hypervisor_presence(void)
{
unsigned int eax;
unsigned int ebx;
@@ -57,9 +58,9 @@ static int HvQueryHypervisorPresence(void)
}
/*
- * HvQueryHypervisorInfo - Get version info of the windows hypervisor
+ * query_hypervisor_info - Get version info of the windows hypervisor
*/
-static int HvQueryHypervisorInfo(void)
+static int query_hypervisor_info(void)
{
unsigned int eax;
unsigned int ebx;
@@ -126,9 +127,9 @@ static int HvQueryHypervisorInfo(void)
}
/*
- * HvDoHypercall - Invoke the specified hypercall
+ * do_hypercall- Invoke the specified hypercall
*/
-static u64 HvDoHypercall(u64 control, void *input, void *output)
+static u64 do_hypercall(u64 control, void *input, void *output)
{
#ifdef CONFIG_X86_64
u64 hv_status = 0;
@@ -181,11 +182,11 @@ static u64 HvDoHypercall(u64 control, void *input, void *output)
}
/*
- * HvInit - Main initialization routine.
+ * hv_init - Main initialization routine.
*
* This routine must be called before any other routines in here are called
*/
-int HvInit(void)
+int hv_init(void)
{
int ret = 0;
int max_leaf;
@@ -196,7 +197,7 @@ int HvInit(void)
memset(hv_context.synic_message_page, 0,
sizeof(void *) * MAX_NUM_CPUS);
- if (!HvQueryHypervisorPresence()) {
+ if (!query_hypervisor_presence()) {
DPRINT_ERR(VMBUS, "No Windows hypervisor detected!!");
goto Cleanup;
}
@@ -204,7 +205,7 @@ int HvInit(void)
DPRINT_INFO(VMBUS,
"Windows hypervisor detected! Retrieving more info...");
- max_leaf = HvQueryHypervisorInfo();
+ max_leaf = query_hypervisor_info();
/* HvQueryHypervisorFeatures(maxLeaf); */
/*
@@ -291,11 +292,11 @@ Cleanup:
}
/*
- * HvCleanup - Cleanup routine.
+ * hv_cleanup - Cleanup routine.
*
* This routine is called normally during driver unloading or exiting.
*/
-void HvCleanup(void)
+void hv_cleanup(void)
{
union hv_x64_msr_hypercall_contents hypercall_msr;
@@ -312,11 +313,11 @@ void HvCleanup(void)
}
/*
- * HvPostMessage - Post a message using the hypervisor message IPC.
+ * hv_post_message - Post a message using the hypervisor message IPC.
*
* This involves a hypercall.
*/
-u16 HvPostMessage(union hv_connection_id connection_id,
+u16 hv_post_message(union hv_connection_id connection_id,
enum hv_message_type message_type,
void *payload, size_t payload_size)
{
@@ -344,7 +345,8 @@ u16 HvPostMessage(union hv_connection_id connection_id,
aligned_msg->payload_size = payload_size;
memcpy((void *)aligned_msg->payload, payload, payload_size);
- status = HvDoHypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL) & 0xFFFF;
+ status = do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL)
+ & 0xFFFF;
kfree((void *)addr);
@@ -353,28 +355,29 @@ u16 HvPostMessage(union hv_connection_id connection_id,
/*
- * HvSignalEvent - Signal an event on the specified connection using the hypervisor event IPC.
+ * hv_signal_event -
+ * Signal an event on the specified connection using the hypervisor event IPC.
*
* This involves a hypercall.
*/
-u16 HvSignalEvent(void)
+u16 hv_signal_event(void)
{
u16 status;
- status = HvDoHypercall(HVCALL_SIGNAL_EVENT,
+ status = do_hypercall(HVCALL_SIGNAL_EVENT,
hv_context.signal_event_param,
NULL) & 0xFFFF;
return status;
}
/*
- * HvSynicInit - Initialize the Synthethic Interrupt Controller.
+ * hv_synic_init - Initialize the Synthethic Interrupt Controller.
*
* If it is already initialized by another entity (ie x2v shim), we need to
* retrieve the initialized message and event pages. Otherwise, we create and
* initialize the message and event pages.
*/
-void HvSynicInit(void *irqarg)
+void hv_synic_init(void *irqarg)
{
u64 version;
union hv_synic_simp simp;
@@ -467,9 +470,9 @@ Cleanup:
}
/*
- * HvSynicCleanup - Cleanup routine for HvSynicInit().
+ * hv_synic_cleanup - Cleanup routine for hv_synic_init().
*/
-void HvSynicCleanup(void *arg)
+void hv_synic_cleanup(void *arg)
{
union hv_synic_sint shared_sint;
union hv_synic_simp simp;
diff --git a/drivers/staging/hv/hv.h b/drivers/staging/hv/hv.h
index 6e396fc..829aff8 100644
--- a/drivers/staging/hv/hv.h
+++ b/drivers/staging/hv/hv.h
@@ -123,18 +123,18 @@ extern struct hv_context hv_context;
/* Hv Interface */
-extern int HvInit(void);
+extern int hv_init(void);
-extern void HvCleanup(void);
+extern void hv_cleanup(void);
-extern u16 HvPostMessage(union hv_connection_id connectionId,
- enum hv_message_type messageType,
- void *payload, size_t payloadSize);
+extern u16 hv_post_message(union hv_connection_id connection_id,
+ enum hv_message_type message_type,
+ void *payload, size_t payload_size);
-extern u16 HvSignalEvent(void);
+extern u16 hv_signal_event(void);
-extern void HvSynicInit(void *irqarg);
+extern void hv_synic_init(void *irqarg);
-extern void HvSynicCleanup(void *arg);
+extern void hv_synic_cleanup(void *arg);
#endif /* __HV_H__ */
diff --git a/drivers/staging/hv/hv_api.h b/drivers/staging/hv/hv_api.h
index 9df6472..70e863a 100644
--- a/drivers/staging/hv/hv_api.h
+++ b/drivers/staging/hv/hv_api.h
@@ -836,7 +836,7 @@ enum hv_call_code {
HVCALL_SIGNAL_EVENT = 0x005d,
};
-/* Definition of the HvPostMessage hypercall input structure. */
+/* Definition of the hv_post_message hypercall input structure. */
struct hv_input_post_message {
union hv_connection_id connectionid;
u32 reserved;
@@ -845,7 +845,7 @@ struct hv_input_post_message {
u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
};
-/* Definition of the HvSignalEvent hypercall input structure. */
+/* Definition of the hv_signal_event hypercall input structure. */
struct hv_input_signal_event {
union hv_connection_id connectionid;
u16 flag_number;
diff --git a/drivers/staging/hv/vmbus.c b/drivers/staging/hv/vmbus.c
index b1ec876..e6462c6 100644
--- a/drivers/staging/hv/vmbus.c
+++ b/drivers/staging/hv/vmbus.c
@@ -109,7 +109,7 @@ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo)
/* strcpy(dev->name, "vmbus"); */
/* SynIC setup... */
- on_each_cpu(HvSynicInit, (void *)irqvector, 1);
+ on_each_cpu(hv_synic_init, (void *)irqvector, 1);
/* Connect to VMBus in the root partition */
ret = VmbusConnect();
@@ -127,7 +127,7 @@ static int VmbusOnDeviceRemove(struct hv_device *dev)
vmbus_release_unattached_channels();
VmbusDisconnect();
- on_each_cpu(HvSynicCleanup, NULL, 1);
+ on_each_cpu(hv_synic_cleanup, NULL, 1);
return ret;
}
@@ -138,7 +138,7 @@ static void VmbusOnCleanup(struct hv_driver *drv)
{
/* struct vmbus_driver *driver = (struct vmbus_driver *)drv; */
- HvCleanup();
+ hv_cleanup();
}
/*
@@ -264,7 +264,7 @@ int VmbusInitialize(struct hv_driver *drv)
driver->GetChannelOffers = VmbusGetChannelOffers;
/* Hypervisor initialization...setup hypercall page..etc */
- ret = HvInit();
+ ret = hv_init();
if (ret != 0)
DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x",
ret);
--
1.6.3.2
^ permalink raw reply related
* [PATCH 04/10] staging: hv: Convert camel cased local variables in hv.c to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-3-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased local variables in hv.c to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/hv.c | 172 +++++++++++++++++++++++-----------------------
1 files changed, 86 insertions(+), 86 deletions(-)
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index d0e8c85..2fd234d 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -65,7 +65,7 @@ static int HvQueryHypervisorInfo(void)
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
- unsigned int maxLeaf;
+ unsigned int max_leaf;
unsigned int op;
/*
@@ -93,7 +93,7 @@ static int HvQueryHypervisorInfo(void)
((edx >> 16) & 0xFF),
((edx >> 24) & 0xFF));
- maxLeaf = eax;
+ max_leaf = eax;
eax = 0;
ebx = 0;
ecx = 0;
@@ -107,7 +107,7 @@ static int HvQueryHypervisorInfo(void)
((eax >> 16) & 0xFF),
((eax >> 24) & 0xFF));
- if (maxLeaf >= HVCPUID_VERSION) {
+ if (max_leaf >= HVCPUID_VERSION) {
eax = 0;
ebx = 0;
ecx = 0;
@@ -122,61 +122,61 @@ static int HvQueryHypervisorInfo(void)
edx >> 24,
edx & 0xFFFFFF);
}
- return maxLeaf;
+ return max_leaf;
}
/*
* HvDoHypercall - Invoke the specified hypercall
*/
-static u64 HvDoHypercall(u64 Control, void *Input, void *Output)
+static u64 HvDoHypercall(u64 control, void *input, void *output)
{
#ifdef CONFIG_X86_64
- u64 hvStatus = 0;
- u64 inputAddress = (Input) ? virt_to_phys(Input) : 0;
- u64 outputAddress = (Output) ? virt_to_phys(Output) : 0;
- volatile void *hypercallPage = hv_context.hypercall_page;
+ u64 hv_status = 0;
+ u64 input_address = (input) ? virt_to_phys(input) : 0;
+ u64 output_address = (output) ? virt_to_phys(output) : 0;
+ volatile void *hypercall_page = hv_context.hypercall_page;
DPRINT_DBG(VMBUS, "Hypercall <control %llx input phys %llx virt %p "
"output phys %llx virt %p hypercall %p>",
- Control, inputAddress, Input,
- outputAddress, Output, hypercallPage);
+ control, input_address, input,
+ output_address, output, hypercall_page);
- __asm__ __volatile__("mov %0, %%r8" : : "r" (outputAddress) : "r8");
- __asm__ __volatile__("call *%3" : "=a" (hvStatus) :
- "c" (Control), "d" (inputAddress),
- "m" (hypercallPage));
+ __asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
+ __asm__ __volatile__("call *%3" : "=a" (hv_status) :
+ "c" (control), "d" (input_address),
+ "m" (hypercall_page));
- DPRINT_DBG(VMBUS, "Hypercall <return %llx>", hvStatus);
+ DPRINT_DBG(VMBUS, "Hypercall <return %llx>", hv_status);
- return hvStatus;
+ return hv_status;
#else
- u32 controlHi = Control >> 32;
- u32 controlLo = Control & 0xFFFFFFFF;
- u32 hvStatusHi = 1;
- u32 hvStatusLo = 1;
- u64 inputAddress = (Input) ? virt_to_phys(Input) : 0;
- u32 inputAddressHi = inputAddress >> 32;
- u32 inputAddressLo = inputAddress & 0xFFFFFFFF;
- u64 outputAddress = (Output) ? virt_to_phys(Output) : 0;
- u32 outputAddressHi = outputAddress >> 32;
- u32 outputAddressLo = outputAddress & 0xFFFFFFFF;
- volatile void *hypercallPage = hv_context.hypercall_page;
+ u32 control_hi = control >> 32;
+ u32 control_lo = control & 0xFFFFFFFF;
+ u32 hv_status_hi = 1;
+ u32 hv_status_lo = 1;
+ u64 input_address = (input) ? virt_to_phys(input) : 0;
+ u32 input_address_hi = input_address >> 32;
+ u32 input_address_lo = input_address & 0xFFFFFFFF;
+ u64 output_address = (output) ? virt_to_phys(output) : 0;
+ u32 output_address_hi = output_address >> 32;
+ u32 output_address_lo = output_address & 0xFFFFFFFF;
+ volatile void *hypercall_page = hv_context.hypercall_page;
DPRINT_DBG(VMBUS, "Hypercall <control %llx input %p output %p>",
- Control, Input, Output);
+ control, input, output);
- __asm__ __volatile__ ("call *%8" : "=d"(hvStatusHi),
- "=a"(hvStatusLo) : "d" (controlHi),
- "a" (controlLo), "b" (inputAddressHi),
- "c" (inputAddressLo), "D"(outputAddressHi),
- "S"(outputAddressLo), "m" (hypercallPage));
+ __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
+ "=a"(hv_status_lo) : "d" (control_hi),
+ "a" (control_lo), "b" (input_address_hi),
+ "c" (input_address_lo), "D"(output_address_hi),
+ "S"(output_address_lo), "m" (hypercall_page));
DPRINT_DBG(VMBUS, "Hypercall <return %llx>",
- hvStatusLo | ((u64)hvStatusHi << 32));
+ hv_status_lo | ((u64)hv_status_hi << 32));
- return hvStatusLo | ((u64)hvStatusHi << 32);
+ return hv_status_lo | ((u64)hv_status_hi << 32);
#endif /* !x86_64 */
}
@@ -188,9 +188,9 @@ static u64 HvDoHypercall(u64 Control, void *Input, void *Output)
int HvInit(void)
{
int ret = 0;
- int maxLeaf;
- union hv_x64_msr_hypercall_contents hypercallMsr;
- void *virtAddr = NULL;
+ int max_leaf;
+ union hv_x64_msr_hypercall_contents hypercall_msr;
+ void *virtaddr = NULL;
memset(hv_context.synic_event_page, 0, sizeof(void *) * MAX_NUM_CPUS);
memset(hv_context.synic_message_page, 0,
@@ -204,7 +204,7 @@ int HvInit(void)
DPRINT_INFO(VMBUS,
"Windows hypervisor detected! Retrieving more info...");
- maxLeaf = HvQueryHypervisorInfo();
+ max_leaf = HvQueryHypervisorInfo();
/* HvQueryHypervisorFeatures(maxLeaf); */
/*
@@ -223,39 +223,39 @@ int HvInit(void)
hv_context.guestid = HV_LINUX_GUEST_ID;
/* See if the hypercall page is already set */
- rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
+ rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
/*
* Allocate the hypercall page memory
- * virtAddr = osd_PageAlloc(1);
+ * virtaddr = osd_PageAlloc(1);
*/
- virtAddr = osd_VirtualAllocExec(PAGE_SIZE);
+ virtaddr = osd_VirtualAllocExec(PAGE_SIZE);
- if (!virtAddr) {
+ if (!virtaddr) {
DPRINT_ERR(VMBUS,
"unable to allocate hypercall page!!");
goto Cleanup;
}
- hypercallMsr.enable = 1;
+ hypercall_msr.enable = 1;
- hypercallMsr.guest_physical_address = vmalloc_to_pfn(virtAddr);
- wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
+ hypercall_msr.guest_physical_address = vmalloc_to_pfn(virtaddr);
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
/* Confirm that hypercall page did get setup. */
- hypercallMsr.as_uint64 = 0;
- rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
+ hypercall_msr.as_uint64 = 0;
+ rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
- if (!hypercallMsr.enable) {
+ if (!hypercall_msr.enable) {
DPRINT_ERR(VMBUS, "unable to set hypercall page!!");
goto Cleanup;
}
- hv_context.hypercall_page = virtAddr;
+ hv_context.hypercall_page = virtaddr;
DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx",
hv_context.hypercall_page,
- (u64)hypercallMsr.guest_physical_address << PAGE_SHIFT);
+ (u64)hypercall_msr.guest_physical_address << PAGE_SHIFT);
/* Setup the global signal event param for the signal event hypercall */
hv_context.signal_event_buffer =
@@ -278,13 +278,13 @@ int HvInit(void)
return ret;
Cleanup:
- if (virtAddr) {
- if (hypercallMsr.enable) {
- hypercallMsr.as_uint64 = 0;
- wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
+ if (virtaddr) {
+ if (hypercall_msr.enable) {
+ hypercall_msr.as_uint64 = 0;
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
}
- vfree(virtAddr);
+ vfree(virtaddr);
}
ret = -1;
return ret;
@@ -297,15 +297,15 @@ Cleanup:
*/
void HvCleanup(void)
{
- union hv_x64_msr_hypercall_contents hypercallMsr;
+ union hv_x64_msr_hypercall_contents hypercall_msr;
kfree(hv_context.signal_event_buffer);
hv_context.signal_event_buffer = NULL;
hv_context.signal_event_param = NULL;
if (hv_context.hypercall_page) {
- hypercallMsr.as_uint64 = 0;
- wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
+ hypercall_msr.as_uint64 = 0;
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
vfree(hv_context.hypercall_page);
hv_context.hypercall_page = NULL;
}
@@ -316,35 +316,35 @@ void HvCleanup(void)
*
* This involves a hypercall.
*/
-u16 HvPostMessage(union hv_connection_id connectionId,
- enum hv_message_type messageType,
- void *payload, size_t payloadSize)
+u16 HvPostMessage(union hv_connection_id connection_id,
+ enum hv_message_type message_type,
+ void *payload, size_t payload_size)
{
- struct alignedInput {
+ struct aligned_input {
u64 alignment8;
struct hv_input_post_message msg;
};
- struct hv_input_post_message *alignedMsg;
+ struct hv_input_post_message *aligned_msg;
u16 status;
unsigned long addr;
- if (payloadSize > HV_MESSAGE_PAYLOAD_BYTE_COUNT)
+ if (payload_size > HV_MESSAGE_PAYLOAD_BYTE_COUNT)
return -1;
- addr = (unsigned long)kmalloc(sizeof(struct alignedInput), GFP_ATOMIC);
+ addr = (unsigned long)kmalloc(sizeof(struct aligned_input), GFP_ATOMIC);
if (!addr)
return -1;
- alignedMsg = (struct hv_input_post_message *)
+ aligned_msg = (struct hv_input_post_message *)
(ALIGN_UP(addr, HV_HYPERCALL_PARAM_ALIGN));
- alignedMsg->connectionid = connectionId;
- alignedMsg->message_type = messageType;
- alignedMsg->payload_size = payloadSize;
- memcpy((void *)alignedMsg->payload, payload, payloadSize);
+ aligned_msg->connectionid = connection_id;
+ aligned_msg->message_type = message_type;
+ aligned_msg->payload_size = payload_size;
+ memcpy((void *)aligned_msg->payload, payload, payload_size);
- status = HvDoHypercall(HVCALL_POST_MESSAGE, alignedMsg, NULL) & 0xFFFF;
+ status = HvDoHypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL) & 0xFFFF;
kfree((void *)addr);
@@ -379,10 +379,10 @@ void HvSynicInit(void *irqarg)
u64 version;
union hv_synic_simp simp;
union hv_synic_siefp siefp;
- union hv_synic_sint sharedSint;
+ union hv_synic_sint shared_sint;
union hv_synic_scontrol sctrl;
- u32 irqVector = *((u32 *)(irqarg));
+ u32 irq_vector = *((u32 *)(irqarg));
int cpu = smp_processor_id();
if (!hv_context.hypercall_page)
@@ -436,17 +436,17 @@ void HvSynicInit(void *irqarg)
/* interceptionSint.as_uint64); */
/* Setup the shared SINT. */
- rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
+ rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
- sharedSint.as_uint64 = 0;
- sharedSint.vector = irqVector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */
- sharedSint.masked = false;
- sharedSint.auto_eoi = true;
+ shared_sint.as_uint64 = 0;
+ shared_sint.vector = irq_vector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */
+ shared_sint.masked = false;
+ shared_sint.auto_eoi = true;
DPRINT_DBG(VMBUS, "HV_X64_MSR_SINT1 msr set to: %llx",
- sharedSint.as_uint64);
+ shared_sint.as_uint64);
- wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
+ wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
/* Enable the global synic bit */
rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
@@ -471,7 +471,7 @@ Cleanup:
*/
void HvSynicCleanup(void *arg)
{
- union hv_synic_sint sharedSint;
+ union hv_synic_sint shared_sint;
union hv_synic_simp simp;
union hv_synic_siefp siefp;
int cpu = smp_processor_id();
@@ -479,13 +479,13 @@ void HvSynicCleanup(void *arg)
if (!hv_context.synic_initialized)
return;
- rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
+ rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
- sharedSint.masked = 1;
+ shared_sint.masked = 1;
/* Need to correctly cleanup in the case of SMP!!! */
/* Disable the interrupt */
- wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
+ wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
simp.simp_enabled = 0;
--
1.6.3.2
^ permalink raw reply related
* [PATCH 03/10] staging: hv: Convert camel cased struct fields in hv.h to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-2-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased struct fields in hv.h to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/hv.c | 95 +++++++++++++++++++++++---------------------
drivers/staging/hv/hv.h | 20 +++++-----
drivers/staging/hv/vmbus.c | 6 +-
3 files changed, 63 insertions(+), 58 deletions(-)
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index ab03327..d0e8c85 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -28,11 +28,11 @@
#include "vmbus_private.h"
/* The one and only */
-struct hv_context gHvContext = {
- .SynICInitialized = false,
- .HypercallPage = NULL,
- .SignalEventParam = NULL,
- .SignalEventBuffer = NULL,
+struct hv_context hv_context = {
+ .synic_initialized = false,
+ .hypercall_page = NULL,
+ .signal_event_param = NULL,
+ .signal_event_buffer = NULL,
};
/*
@@ -134,7 +134,7 @@ static u64 HvDoHypercall(u64 Control, void *Input, void *Output)
u64 hvStatus = 0;
u64 inputAddress = (Input) ? virt_to_phys(Input) : 0;
u64 outputAddress = (Output) ? virt_to_phys(Output) : 0;
- volatile void *hypercallPage = gHvContext.HypercallPage;
+ volatile void *hypercallPage = hv_context.hypercall_page;
DPRINT_DBG(VMBUS, "Hypercall <control %llx input phys %llx virt %p "
"output phys %llx virt %p hypercall %p>",
@@ -162,7 +162,7 @@ static u64 HvDoHypercall(u64 Control, void *Input, void *Output)
u64 outputAddress = (Output) ? virt_to_phys(Output) : 0;
u32 outputAddressHi = outputAddress >> 32;
u32 outputAddressLo = outputAddress & 0xFFFFFFFF;
- volatile void *hypercallPage = gHvContext.HypercallPage;
+ volatile void *hypercallPage = hv_context.hypercall_page;
DPRINT_DBG(VMBUS, "Hypercall <control %llx input %p output %p>",
Control, Input, Output);
@@ -192,8 +192,9 @@ int HvInit(void)
union hv_x64_msr_hypercall_contents hypercallMsr;
void *virtAddr = NULL;
- memset(gHvContext.synICEventPage, 0, sizeof(void *) * MAX_NUM_CPUS);
- memset(gHvContext.synICMessagePage, 0, sizeof(void *) * MAX_NUM_CPUS);
+ memset(hv_context.synic_event_page, 0, sizeof(void *) * MAX_NUM_CPUS);
+ memset(hv_context.synic_message_page, 0,
+ sizeof(void *) * MAX_NUM_CPUS);
if (!HvQueryHypervisorPresence()) {
DPRINT_ERR(VMBUS, "No Windows hypervisor detected!!");
@@ -209,17 +210,17 @@ int HvInit(void)
/*
* We only support running on top of Hyper-V
*/
- rdmsrl(HV_X64_MSR_GUEST_OS_ID, gHvContext.GuestId);
+ rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
- if (gHvContext.GuestId != 0) {
+ if (hv_context.guestid != 0) {
DPRINT_ERR(VMBUS, "Unknown guest id (0x%llx)!!",
- gHvContext.GuestId);
+ hv_context.guestid);
goto Cleanup;
}
/* Write our OS info */
wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID);
- gHvContext.GuestId = HV_LINUX_GUEST_ID;
+ hv_context.guestid = HV_LINUX_GUEST_ID;
/* See if the hypercall page is already set */
rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
@@ -250,28 +251,29 @@ int HvInit(void)
goto Cleanup;
}
- gHvContext.HypercallPage = virtAddr;
+ hv_context.hypercall_page = virtAddr;
DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx",
- gHvContext.HypercallPage,
+ hv_context.hypercall_page,
(u64)hypercallMsr.guest_physical_address << PAGE_SHIFT);
/* Setup the global signal event param for the signal event hypercall */
- gHvContext.SignalEventBuffer =
+ hv_context.signal_event_buffer =
kmalloc(sizeof(struct hv_input_signal_event_buffer),
GFP_KERNEL);
- if (!gHvContext.SignalEventBuffer)
+ if (!hv_context.signal_event_buffer)
goto Cleanup;
- gHvContext.SignalEventParam =
+ hv_context.signal_event_param =
(struct hv_input_signal_event *)
- (ALIGN_UP((unsigned long)gHvContext.SignalEventBuffer,
+ (ALIGN_UP((unsigned long)
+ hv_context.signal_event_buffer,
HV_HYPERCALL_PARAM_ALIGN));
- gHvContext.SignalEventParam->connectionid.asu32 = 0;
- gHvContext.SignalEventParam->connectionid.u.id =
+ hv_context.signal_event_param->connectionid.asu32 = 0;
+ hv_context.signal_event_param->connectionid.u.id =
VMBUS_EVENT_CONNECTION_ID;
- gHvContext.SignalEventParam->flag_number = 0;
- gHvContext.SignalEventParam->rsvdz = 0;
+ hv_context.signal_event_param->flag_number = 0;
+ hv_context.signal_event_param->rsvdz = 0;
return ret;
@@ -297,15 +299,15 @@ void HvCleanup(void)
{
union hv_x64_msr_hypercall_contents hypercallMsr;
- kfree(gHvContext.SignalEventBuffer);
- gHvContext.SignalEventBuffer = NULL;
- gHvContext.SignalEventParam = NULL;
+ kfree(hv_context.signal_event_buffer);
+ hv_context.signal_event_buffer = NULL;
+ hv_context.signal_event_param = NULL;
- if (gHvContext.HypercallPage) {
+ if (hv_context.hypercall_page) {
hypercallMsr.as_uint64 = 0;
wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
- vfree(gHvContext.HypercallPage);
- gHvContext.HypercallPage = NULL;
+ vfree(hv_context.hypercall_page);
+ hv_context.hypercall_page = NULL;
}
}
@@ -359,7 +361,8 @@ u16 HvSignalEvent(void)
{
u16 status;
- status = HvDoHypercall(HVCALL_SIGNAL_EVENT, gHvContext.SignalEventParam,
+ status = HvDoHypercall(HVCALL_SIGNAL_EVENT,
+ hv_context.signal_event_param,
NULL) & 0xFFFF;
return status;
}
@@ -382,7 +385,7 @@ void HvSynicInit(void *irqarg)
u32 irqVector = *((u32 *)(irqarg));
int cpu = smp_processor_id();
- if (!gHvContext.HypercallPage)
+ if (!hv_context.hypercall_page)
return;
/* Check the version */
@@ -390,17 +393,19 @@ void HvSynicInit(void *irqarg)
DPRINT_INFO(VMBUS, "SynIC version: %llx", version);
- gHvContext.synICMessagePage[cpu] = (void *)get_zeroed_page(GFP_ATOMIC);
+ hv_context.synic_message_page[cpu] =
+ (void *)get_zeroed_page(GFP_ATOMIC);
- if (gHvContext.synICMessagePage[cpu] == NULL) {
+ if (hv_context.synic_message_page[cpu] == NULL) {
DPRINT_ERR(VMBUS,
"unable to allocate SYNIC message page!!");
goto Cleanup;
}
- gHvContext.synICEventPage[cpu] = (void *)get_zeroed_page(GFP_ATOMIC);
+ hv_context.synic_event_page[cpu] =
+ (void *)get_zeroed_page(GFP_ATOMIC);
- if (gHvContext.synICEventPage[cpu] == NULL) {
+ if (hv_context.synic_event_page[cpu] == NULL) {
DPRINT_ERR(VMBUS,
"unable to allocate SYNIC event page!!");
goto Cleanup;
@@ -409,7 +414,7 @@ void HvSynicInit(void *irqarg)
/* Setup the Synic's message page */
rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
simp.simp_enabled = 1;
- simp.base_simp_gpa = virt_to_phys(gHvContext.synICMessagePage[cpu])
+ simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu])
>> PAGE_SHIFT;
DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.as_uint64);
@@ -419,7 +424,7 @@ void HvSynicInit(void *irqarg)
/* Setup the Synic's event page */
rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
siefp.siefp_enabled = 1;
- siefp.base_siefp_gpa = virt_to_phys(gHvContext.synICEventPage[cpu])
+ siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu])
>> PAGE_SHIFT;
DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.as_uint64);
@@ -449,15 +454,15 @@ void HvSynicInit(void *irqarg)
wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
- gHvContext.SynICInitialized = true;
+ hv_context.synic_initialized = true;
return;
Cleanup:
- if (gHvContext.synICEventPage[cpu])
- osd_PageFree(gHvContext.synICEventPage[cpu], 1);
+ if (hv_context.synic_event_page[cpu])
+ osd_PageFree(hv_context.synic_event_page[cpu], 1);
- if (gHvContext.synICMessagePage[cpu])
- osd_PageFree(gHvContext.synICMessagePage[cpu], 1);
+ if (hv_context.synic_message_page[cpu])
+ osd_PageFree(hv_context.synic_message_page[cpu], 1);
return;
}
@@ -471,7 +476,7 @@ void HvSynicCleanup(void *arg)
union hv_synic_siefp siefp;
int cpu = smp_processor_id();
- if (!gHvContext.SynICInitialized)
+ if (!hv_context.synic_initialized)
return;
rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
@@ -494,6 +499,6 @@ void HvSynicCleanup(void *arg)
wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
- osd_PageFree(gHvContext.synICMessagePage[cpu], 1);
- osd_PageFree(gHvContext.synICEventPage[cpu], 1);
+ osd_PageFree(hv_context.synic_message_page[cpu], 1);
+ osd_PageFree(hv_context.synic_event_page[cpu], 1);
}
diff --git a/drivers/staging/hv/hv.h b/drivers/staging/hv/hv.h
index 41f5ebb..6e396fc 100644
--- a/drivers/staging/hv/hv.h
+++ b/drivers/staging/hv/hv.h
@@ -92,33 +92,33 @@ static const struct hv_guid VMBUS_SERVICE_ID = {
struct hv_input_signal_event_buffer {
- u64 Align8;
- struct hv_input_signal_event Event;
+ u64 align8;
+ struct hv_input_signal_event event;
};
struct hv_context {
/* We only support running on top of Hyper-V
* So at this point this really can only contain the Hyper-V ID
*/
- u64 GuestId;
+ u64 guestid;
- void *HypercallPage;
+ void *hypercall_page;
- bool SynICInitialized;
+ bool synic_initialized;
/*
* This is used as an input param to HvCallSignalEvent hypercall. The
* input param is immutable in our usage and must be dynamic mem (vs
* stack or global). */
- struct hv_input_signal_event_buffer *SignalEventBuffer;
+ struct hv_input_signal_event_buffer *signal_event_buffer;
/* 8-bytes aligned of the buffer above */
- struct hv_input_signal_event *SignalEventParam;
+ struct hv_input_signal_event *signal_event_param;
- void *synICMessagePage[MAX_NUM_CPUS];
- void *synICEventPage[MAX_NUM_CPUS];
+ void *synic_message_page[MAX_NUM_CPUS];
+ void *synic_event_page[MAX_NUM_CPUS];
};
-extern struct hv_context gHvContext;
+extern struct hv_context hv_context;
/* Hv Interface */
diff --git a/drivers/staging/hv/vmbus.c b/drivers/staging/hv/vmbus.c
index 7c54ca9..b1ec876 100644
--- a/drivers/staging/hv/vmbus.c
+++ b/drivers/staging/hv/vmbus.c
@@ -147,7 +147,7 @@ static void VmbusOnCleanup(struct hv_driver *drv)
static void VmbusOnMsgDPC(struct hv_driver *drv)
{
int cpu = smp_processor_id();
- void *page_addr = gHvContext.synICMessagePage[cpu];
+ void *page_addr = hv_context.synic_message_page[cpu];
struct hv_message *msg = (struct hv_message *)page_addr +
VMBUS_MESSAGE_SINT;
struct hv_message *copied;
@@ -208,7 +208,7 @@ static int VmbusOnISR(struct hv_driver *drv)
struct hv_message *msg;
union hv_synic_event_flags *event;
- page_addr = gHvContext.synICMessagePage[cpu];
+ page_addr = hv_context.synic_message_page[cpu];
msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
/* Check if there are actual msgs to be process */
@@ -220,7 +220,7 @@ static int VmbusOnISR(struct hv_driver *drv)
}
/* TODO: Check if there are events to be process */
- page_addr = gHvContext.synICEventPage[cpu];
+ page_addr = hv_context.synic_event_page[cpu];
event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
/* Since we are a child, we only need to check bit 0 */
--
1.6.3.2
^ permalink raw reply related
* [PATCH 02/10] staging: hv: Convert camel cased struct fields in hv_api.h to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
In-Reply-To: <1289253887-2596-1-git-send-email-haiyangz@linuxonhyperv.com>
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased struct fields in hv_api.h to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 32 ++--
drivers/staging/hv/channel_mgmt.c | 6 +-
drivers/staging/hv/connection.c | 4 +-
drivers/staging/hv/hv.c | 120 ++++++++--------
drivers/staging/hv/hv_api.h | 274 ++++++++++++++++++------------------
drivers/staging/hv/vmbus.c | 18 ++--
6 files changed, 227 insertions(+), 227 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 9fa0fe1..7c15c40 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -43,24 +43,24 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
int j = 0;
DPRINT_DBG(VMBUS, "monitorPage - %p, trigger state - %d",
- MonitorPage, MonitorPage->TriggerState);
+ MonitorPage, MonitorPage->trigger_state);
for (i = 0; i < 4; i++)
DPRINT_DBG(VMBUS, "trigger group (%d) - %llx", i,
- MonitorPage->TriggerGroup[i].AsUINT64);
+ MonitorPage->trigger_group[i].as_uint64);
for (i = 0; i < 4; i++) {
for (j = 0; j < 32; j++) {
DPRINT_DBG(VMBUS, "latency (%d)(%d) - %llx", i, j,
- MonitorPage->Latency[i][j]);
+ MonitorPage->latency[i][j]);
}
}
for (i = 0; i < 4; i++) {
for (j = 0; j < 32; j++) {
DPRINT_DBG(VMBUS, "param-conn id (%d)(%d) - %d", i, j,
- MonitorPage->Parameter[i][j].ConnectionId.Asu32);
+ MonitorPage->parameter[i][j].connectionid.asu32);
DPRINT_DBG(VMBUS, "param-flag (%d)(%d) - %d", i, j,
- MonitorPage->Parameter[i][j].FlagNumber);
+ MonitorPage->parameter[i][j].flag_number);
}
}
}
@@ -84,8 +84,8 @@ static void vmbus_setevent(struct vmbus_channel *channel)
monitorpage++; /* Get the child to parent monitor page */
set_bit(channel->monitor_bit,
- (unsigned long *)&monitorpage->TriggerGroup
- [channel->monitor_grp].Pending);
+ (unsigned long *)&monitorpage->trigger_group
+ [channel->monitor_grp].pending);
} else {
VmbusSetEvent(channel->offermsg.child_relid);
@@ -108,7 +108,7 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
monitorPage++; /* Get the child to parent monitor page */
clear_bit(Channel->monitor_bit,
- (unsigned long *)&monitorPage->TriggerGroup
+ (unsigned long *)&monitorPage->trigger_group
[Channel->monitor_grp].Pending);
}
}
@@ -138,22 +138,22 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
debuginfo->monitorid = channel->offermsg.monitorid;
debuginfo->servermonitor_pending =
- monitorpage->TriggerGroup[monitor_group].Pending;
+ monitorpage->trigger_group[monitor_group].pending;
debuginfo->servermonitor_latency =
- monitorpage->Latency[monitor_group][monitor_offset];
+ monitorpage->latency[monitor_group][monitor_offset];
debuginfo->servermonitor_connectionid =
- monitorpage->Parameter[monitor_group]
- [monitor_offset].ConnectionId.u.Id;
+ monitorpage->parameter[monitor_group]
+ [monitor_offset].connectionid.u.id;
monitorpage++;
debuginfo->clientmonitor_pending =
- monitorpage->TriggerGroup[monitor_group].Pending;
+ monitorpage->trigger_group[monitor_group].pending;
debuginfo->clientmonitor_latency =
- monitorpage->Latency[monitor_group][monitor_offset];
+ monitorpage->latency[monitor_group][monitor_offset];
debuginfo->clientmonitor_connectionid =
- monitorpage->Parameter[monitor_group]
- [monitor_offset].ConnectionId.u.Id;
+ monitorpage->parameter[monitor_group]
+ [monitor_offset].connectionid.u.id;
RingBufferGetDebugInfo(&channel->inbound, &debuginfo->inbound);
RingBufferGetDebugInfo(&channel->outbound, &debuginfo->outbound);
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index dbfe0f2..be34e38 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -742,8 +742,8 @@ void vmbus_onmessage(void *context)
struct vmbus_channel_message_header *hdr;
int size;
- hdr = (struct vmbus_channel_message_header *)msg->u.Payload;
- size = msg->Header.PayloadSize;
+ hdr = (struct vmbus_channel_message_header *)msg->u.payload;
+ size = msg->header.payload_size;
DPRINT_DBG(VMBUS, "message type %d size %d", hdr->msgtype, size);
@@ -752,7 +752,7 @@ void vmbus_onmessage(void *context)
"Received invalid channel message type %d size %d",
hdr->msgtype, size);
print_hex_dump_bytes("", DUMP_PREFIX_NONE,
- (unsigned char *)msg->u.Payload, size);
+ (unsigned char *)msg->u.payload, size);
kfree(msg);
return;
}
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index 6f3f525..ba50dd8 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -309,8 +309,8 @@ int VmbusPostMessage(void *buffer, size_t bufferLen)
{
union hv_connection_id connId;
- connId.Asu32 = 0;
- connId.u.Id = VMBUS_MESSAGE_CONNECTION_ID;
+ connId.asu32 = 0;
+ connId.u.id = VMBUS_MESSAGE_CONNECTION_ID;
return HvPostMessage(connId, 1, buffer, bufferLen);
}
diff --git a/drivers/staging/hv/hv.c b/drivers/staging/hv/hv.c
index 86b1ddd..ab03327 100644
--- a/drivers/staging/hv/hv.c
+++ b/drivers/staging/hv/hv.c
@@ -50,7 +50,7 @@ static int HvQueryHypervisorPresence(void)
ebx = 0;
ecx = 0;
edx = 0;
- op = HvCpuIdFunctionVersionAndFeatures;
+ op = HVCPUID_VERSION_FEATURES;
cpuid(op, &eax, &ebx, &ecx, &edx);
return ecx & HV_PRESENT_BIT;
@@ -76,7 +76,7 @@ static int HvQueryHypervisorInfo(void)
ebx = 0;
ecx = 0;
edx = 0;
- op = HvCpuIdFunctionHvVendorAndMaxFunction;
+ op = HVCPUID_VENDOR_MAXFUNCTION;
cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c",
@@ -98,7 +98,7 @@ static int HvQueryHypervisorInfo(void)
ebx = 0;
ecx = 0;
edx = 0;
- op = HvCpuIdFunctionHvInterface;
+ op = HVCPUID_INTERFACE;
cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "Interface ID: %c%c%c%c",
@@ -107,12 +107,12 @@ static int HvQueryHypervisorInfo(void)
((eax >> 16) & 0xFF),
((eax >> 24) & 0xFF));
- if (maxLeaf >= HvCpuIdFunctionMsHvVersion) {
+ if (maxLeaf >= HVCPUID_VERSION) {
eax = 0;
ebx = 0;
ecx = 0;
edx = 0;
- op = HvCpuIdFunctionMsHvVersion;
+ op = HVCPUID_VERSION;
cpuid(op, &eax, &ebx, &ecx, &edx);
DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",\
eax,
@@ -222,7 +222,7 @@ int HvInit(void)
gHvContext.GuestId = HV_LINUX_GUEST_ID;
/* See if the hypercall page is already set */
- rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64);
+ rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
/*
* Allocate the hypercall page memory
@@ -236,16 +236,16 @@ int HvInit(void)
goto Cleanup;
}
- hypercallMsr.Enable = 1;
+ hypercallMsr.enable = 1;
- hypercallMsr.GuestPhysicalAddress = vmalloc_to_pfn(virtAddr);
- wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64);
+ hypercallMsr.guest_physical_address = vmalloc_to_pfn(virtAddr);
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
/* Confirm that hypercall page did get setup. */
- hypercallMsr.AsUINT64 = 0;
- rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64);
+ hypercallMsr.as_uint64 = 0;
+ rdmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
- if (!hypercallMsr.Enable) {
+ if (!hypercallMsr.enable) {
DPRINT_ERR(VMBUS, "unable to set hypercall page!!");
goto Cleanup;
}
@@ -254,7 +254,7 @@ int HvInit(void)
DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx",
gHvContext.HypercallPage,
- (u64)hypercallMsr.GuestPhysicalAddress << PAGE_SHIFT);
+ (u64)hypercallMsr.guest_physical_address << PAGE_SHIFT);
/* Setup the global signal event param for the signal event hypercall */
gHvContext.SignalEventBuffer =
@@ -267,19 +267,19 @@ int HvInit(void)
(struct hv_input_signal_event *)
(ALIGN_UP((unsigned long)gHvContext.SignalEventBuffer,
HV_HYPERCALL_PARAM_ALIGN));
- gHvContext.SignalEventParam->ConnectionId.Asu32 = 0;
- gHvContext.SignalEventParam->ConnectionId.u.Id =
+ gHvContext.SignalEventParam->connectionid.asu32 = 0;
+ gHvContext.SignalEventParam->connectionid.u.id =
VMBUS_EVENT_CONNECTION_ID;
- gHvContext.SignalEventParam->FlagNumber = 0;
- gHvContext.SignalEventParam->RsvdZ = 0;
+ gHvContext.SignalEventParam->flag_number = 0;
+ gHvContext.SignalEventParam->rsvdz = 0;
return ret;
Cleanup:
if (virtAddr) {
- if (hypercallMsr.Enable) {
- hypercallMsr.AsUINT64 = 0;
- wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64);
+ if (hypercallMsr.enable) {
+ hypercallMsr.as_uint64 = 0;
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
}
vfree(virtAddr);
@@ -302,8 +302,8 @@ void HvCleanup(void)
gHvContext.SignalEventParam = NULL;
if (gHvContext.HypercallPage) {
- hypercallMsr.AsUINT64 = 0;
- wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.AsUINT64);
+ hypercallMsr.as_uint64 = 0;
+ wrmsrl(HV_X64_MSR_HYPERCALL, hypercallMsr.as_uint64);
vfree(gHvContext.HypercallPage);
gHvContext.HypercallPage = NULL;
}
@@ -337,12 +337,12 @@ u16 HvPostMessage(union hv_connection_id connectionId,
alignedMsg = (struct hv_input_post_message *)
(ALIGN_UP(addr, HV_HYPERCALL_PARAM_ALIGN));
- alignedMsg->ConnectionId = connectionId;
- alignedMsg->MessageType = messageType;
- alignedMsg->PayloadSize = payloadSize;
- memcpy((void *)alignedMsg->Payload, payload, payloadSize);
+ alignedMsg->connectionid = connectionId;
+ alignedMsg->message_type = messageType;
+ alignedMsg->payload_size = payloadSize;
+ memcpy((void *)alignedMsg->payload, payload, payloadSize);
- status = HvDoHypercall(HvCallPostMessage, alignedMsg, NULL) & 0xFFFF;
+ status = HvDoHypercall(HVCALL_POST_MESSAGE, alignedMsg, NULL) & 0xFFFF;
kfree((void *)addr);
@@ -359,7 +359,7 @@ u16 HvSignalEvent(void)
{
u16 status;
- status = HvDoHypercall(HvCallSignalEvent, gHvContext.SignalEventParam,
+ status = HvDoHypercall(HVCALL_SIGNAL_EVENT, gHvContext.SignalEventParam,
NULL) & 0xFFFF;
return status;
}
@@ -407,47 +407,47 @@ void HvSynicInit(void *irqarg)
}
/* Setup the Synic's message page */
- rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64);
- simp.SimpEnabled = 1;
- simp.BaseSimpGpa = virt_to_phys(gHvContext.synICMessagePage[cpu])
+ rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
+ simp.simp_enabled = 1;
+ simp.base_simp_gpa = virt_to_phys(gHvContext.synICMessagePage[cpu])
>> PAGE_SHIFT;
- DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.AsUINT64);
+ DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.as_uint64);
- wrmsrl(HV_X64_MSR_SIMP, simp.AsUINT64);
+ wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
/* Setup the Synic's event page */
- rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64);
- siefp.SiefpEnabled = 1;
- siefp.BaseSiefpGpa = virt_to_phys(gHvContext.synICEventPage[cpu])
+ rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
+ siefp.siefp_enabled = 1;
+ siefp.base_siefp_gpa = virt_to_phys(gHvContext.synICEventPage[cpu])
>> PAGE_SHIFT;
- DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.AsUINT64);
+ DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.as_uint64);
- wrmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64);
+ wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
/* Setup the interception SINT. */
/* wrmsrl((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX), */
- /* interceptionSint.AsUINT64); */
+ /* interceptionSint.as_uint64); */
/* Setup the shared SINT. */
- rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64);
+ rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
- sharedSint.AsUINT64 = 0;
- sharedSint.Vector = irqVector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */
- sharedSint.Masked = false;
- sharedSint.AutoEoi = true;
+ sharedSint.as_uint64 = 0;
+ sharedSint.vector = irqVector; /* HV_SHARED_SINT_IDT_VECTOR + 0x20; */
+ sharedSint.masked = false;
+ sharedSint.auto_eoi = true;
DPRINT_DBG(VMBUS, "HV_X64_MSR_SINT1 msr set to: %llx",
- sharedSint.AsUINT64);
+ sharedSint.as_uint64);
- wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64);
+ wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
/* Enable the global synic bit */
- rdmsrl(HV_X64_MSR_SCONTROL, sctrl.AsUINT64);
- sctrl.Enable = 1;
+ rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
+ sctrl.enable = 1;
- wrmsrl(HV_X64_MSR_SCONTROL, sctrl.AsUINT64);
+ wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
gHvContext.SynICInitialized = true;
return;
@@ -474,25 +474,25 @@ void HvSynicCleanup(void *arg)
if (!gHvContext.SynICInitialized)
return;
- rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64);
+ rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
- sharedSint.Masked = 1;
+ sharedSint.masked = 1;
/* Need to correctly cleanup in the case of SMP!!! */
/* Disable the interrupt */
- wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.AsUINT64);
+ wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, sharedSint.as_uint64);
- rdmsrl(HV_X64_MSR_SIMP, simp.AsUINT64);
- simp.SimpEnabled = 0;
- simp.BaseSimpGpa = 0;
+ rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
+ simp.simp_enabled = 0;
+ simp.base_simp_gpa = 0;
- wrmsrl(HV_X64_MSR_SIMP, simp.AsUINT64);
+ wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
- rdmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64);
- siefp.SiefpEnabled = 0;
- siefp.BaseSiefpGpa = 0;
+ rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
+ siefp.siefp_enabled = 0;
+ siefp.base_siefp_gpa = 0;
- wrmsrl(HV_X64_MSR_SIEFP, siefp.AsUINT64);
+ wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
osd_PageFree(gHvContext.synICMessagePage[cpu], 1);
osd_PageFree(gHvContext.synICEventPage[cpu], 1);
diff --git a/drivers/staging/hv/hv_api.h b/drivers/staging/hv/hv_api.h
index 9eb818e..9df6472 100644
--- a/drivers/staging/hv/hv_api.h
+++ b/drivers/staging/hv/hv_api.h
@@ -510,21 +510,21 @@
/*
* The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
- * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
+ * is set by CPUID(HVCPUID_VERSION_FEATURES).
*/
enum hv_cpuid_function {
- HvCpuIdFunctionVersionAndFeatures = 0x00000001,
- HvCpuIdFunctionHvVendorAndMaxFunction = 0x40000000,
- HvCpuIdFunctionHvInterface = 0x40000001,
+ HVCPUID_VERSION_FEATURES = 0x00000001,
+ HVCPUID_VENDOR_MAXFUNCTION = 0x40000000,
+ HVCPUID_INTERFACE = 0x40000001,
/*
* The remaining functions depend on the value of
- * HvCpuIdFunctionInterface
+ * HVCPUID_INTERFACE
*/
- HvCpuIdFunctionMsHvVersion = 0x40000002,
- HvCpuIdFunctionMsHvFeatures = 0x40000003,
- HvCpuIdFunctionMsHvEnlightenmentInformation = 0x40000004,
- HvCpuIdFunctionMsHvImplementationLimits = 0x40000005,
+ HVCPUID_VERSION = 0x40000002,
+ HVCPUID_FEATURES = 0x40000003,
+ HVCPUID_ENLIGHTENMENT_INFO = 0x40000004,
+ HVCPUID_IMPLEMENTATION_LIMITS = 0x40000005,
};
/* Define the virtual APIC registers */
@@ -575,30 +575,30 @@ enum hv_cpuid_function {
/* Define hypervisor message types. */
enum hv_message_type {
- HvMessageTypeNone = 0x00000000,
+ HVMSG_NONE = 0x00000000,
/* Memory access messages. */
- HvMessageTypeUnmappedGpa = 0x80000000,
- HvMessageTypeGpaIntercept = 0x80000001,
+ HVMSG_UNMAPPED_GPA = 0x80000000,
+ HVMSG_GPA_INTERCEPT = 0x80000001,
/* Timer notification messages. */
- HvMessageTimerExpired = 0x80000010,
+ HVMSG_TIMER_EXPIRED = 0x80000010,
/* Error messages. */
- HvMessageTypeInvalidVpRegisterValue = 0x80000020,
- HvMessageTypeUnrecoverableException = 0x80000021,
- HvMessageTypeUnsupportedFeature = 0x80000022,
+ HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
+ HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021,
+ HVMSG_UNSUPPORTED_FEATURE = 0x80000022,
/* Trace buffer complete messages. */
- HvMessageTypeEventLogBufferComplete = 0x80000040,
+ HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040,
/* Platform-specific processor intercept messages. */
- HvMessageTypeX64IoPortIntercept = 0x80010000,
- HvMessageTypeX64MsrIntercept = 0x80010001,
- HvMessageTypeX64CpuidIntercept = 0x80010002,
- HvMessageTypeX64ExceptionIntercept = 0x80010003,
- HvMessageTypeX64ApicEoi = 0x80010004,
- HvMessageTypeX64LegacyFpError = 0x80010005
+ HVMSG_X64_IOPORT_INTERCEPT = 0x80010000,
+ HVMSG_X64_MSR_INTERCEPT = 0x80010001,
+ HVMSG_X64_CPUID_INTERCEPT = 0x80010002,
+ HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003,
+ HVMSG_X64_APIC_EOI = 0x80010004,
+ HVMSG_X64_LEGACY_FP_ERROR = 0x80010005
};
/* Define the number of synthetic interrupt sources. */
@@ -610,103 +610,103 @@ enum hv_message_type {
/* Define connection identifier type. */
union hv_connection_id {
- u32 Asu32;
+ u32 asu32;
struct {
- u32 Id:24;
- u32 Reserved:8;
+ u32 id:24;
+ u32 reserved:8;
} u;
};
/* Define port identifier type. */
union hv_port_id {
- u32 Asu32;
+ u32 asu32;
struct {
- u32 Id:24;
- u32 Reserved:8;
+ u32 id:24;
+ u32 reserved:8;
} u ;
};
/* Define port type. */
enum hv_port_type {
- HvPortTypeMessage = 1,
- HvPortTypeEvent = 2,
- HvPortTypeMonitor = 3
+ HVPORT_MSG = 1,
+ HVPORT_EVENT = 2,
+ HVPORT_MONITOR = 3
};
/* Define port information structure. */
struct hv_port_info {
- enum hv_port_type PortType;
- u32 Padding;
+ enum hv_port_type port_type;
+ u32 padding;
union {
struct {
- u32 TargetSint;
- u32 TargetVp;
- u64 RsvdZ;
- } MessagePortInfo;
+ u32 target_sint;
+ u32 target_vp;
+ u64 rsvdz;
+ } message_port_info;
struct {
- u32 TargetSint;
- u32 TargetVp;
- u16 BaseFlagNumber;
- u16 FlagCount;
- u32 RsvdZ;
- } EventPortInfo;
+ u32 target_sint;
+ u32 target_vp;
+ u16 base_flag_bumber;
+ u16 flag_count;
+ u32 rsvdz;
+ } event_port_info;
struct {
- u64 MonitorAddress;
- u64 RsvdZ;
- } MonitorPortInfo;
+ u64 monitor_address;
+ u64 rsvdz;
+ } monitor_port_info;
};
};
struct hv_connection_info {
- enum hv_port_type PortType;
- u32 Padding;
+ enum hv_port_type port_type;
+ u32 padding;
union {
struct {
- u64 RsvdZ;
- } MessageConnectionInfo;
+ u64 rsvdz;
+ } message_connection_info;
struct {
- u64 RsvdZ;
- } EventConnectionInfo;
+ u64 rsvdz;
+ } event_connection_info;
struct {
- u64 MonitorAddress;
- } MonitorConnectionInfo;
+ u64 monitor_address;
+ } monitor_connection_info;
};
};
/* Define synthetic interrupt controller message flags. */
union hv_message_flags {
- u8 Asu8;
+ u8 asu8;
struct {
- u8 MessagePending:1;
- u8 Reserved:7;
+ u8 msg_pending:1;
+ u8 reserved:7;
};
};
/* Define synthetic interrupt controller message header. */
struct hv_message_header {
- enum hv_message_type MessageType;
- u8 PayloadSize;
- union hv_message_flags MessageFlags;
- u8 Reserved[2];
+ enum hv_message_type message_type;
+ u8 payload_size;
+ union hv_message_flags message_flags;
+ u8 reserved[2];
union {
- u64 Sender;
- union hv_port_id Port;
+ u64 sender;
+ union hv_port_id port;
};
};
/* Define timer message payload structure. */
struct hv_timer_message_payload {
- u32 TimerIndex;
- u32 Reserved;
- u64 ExpirationTime; /* When the timer expired */
- u64 DeliveryTime; /* When the message was delivered */
+ u32 timer_index;
+ u32 reserved;
+ u64 expiration_time; /* When the timer expired */
+ u64 delivery_time; /* When the message was delivered */
};
/* Define synthetic interrupt controller message format. */
struct hv_message {
- struct hv_message_header Header;
+ struct hv_message_header header;
union {
- u64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
+ u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
} u ;
};
@@ -715,82 +715,82 @@ struct hv_message {
/* Define the synthetic interrupt message page layout. */
struct hv_message_page {
- struct hv_message SintMessage[HV_SYNIC_SINT_COUNT];
+ struct hv_message sint_message[HV_SYNIC_SINT_COUNT];
};
/* Define the synthetic interrupt controller event flags format. */
union hv_synic_event_flags {
- u8 Flags8[HV_EVENT_FLAGS_BYTE_COUNT];
- u32 Flags32[HV_EVENT_FLAGS_DWORD_COUNT];
+ u8 flags8[HV_EVENT_FLAGS_BYTE_COUNT];
+ u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT];
};
/* Define the synthetic interrupt flags page layout. */
struct hv_synic_event_flags_page {
- union hv_synic_event_flags SintEventFlags[HV_SYNIC_SINT_COUNT];
+ union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
};
/* Define SynIC control register. */
union hv_synic_scontrol {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u64 Enable:1;
- u64 Reserved:63;
+ u64 enable:1;
+ u64 reserved:63;
};
};
/* Define synthetic interrupt source. */
union hv_synic_sint {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u64 Vector:8;
- u64 Reserved1:8;
- u64 Masked:1;
- u64 AutoEoi:1;
- u64 Reserved2:46;
+ u64 vector:8;
+ u64 reserved1:8;
+ u64 masked:1;
+ u64 auto_eoi:1;
+ u64 reserved2:46;
};
};
/* Define the format of the SIMP register */
union hv_synic_simp {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u64 SimpEnabled:1;
- u64 Preserved:11;
- u64 BaseSimpGpa:52;
+ u64 simp_enabled:1;
+ u64 preserved:11;
+ u64 base_simp_gpa:52;
};
};
/* Define the format of the SIEFP register */
union hv_synic_siefp {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u64 SiefpEnabled:1;
- u64 Preserved:11;
- u64 BaseSiefpGpa:52;
+ u64 siefp_enabled:1;
+ u64 preserved:11;
+ u64 base_siefp_gpa:52;
};
};
/* Definitions for the monitored notification facility */
union hv_monitor_trigger_group {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u32 Pending;
- u32 Armed;
+ u32 pending;
+ u32 armed;
};
};
struct hv_monitor_parameter {
- union hv_connection_id ConnectionId;
- u16 FlagNumber;
- u16 RsvdZ;
+ union hv_connection_id connectionid;
+ u16 flagnumber;
+ u16 rsvdz;
};
union hv_monitor_trigger_state {
- u32 Asu32;
+ u32 asu32;
struct {
- u32 GroupEnable:4;
- u32 RsvdZ:28;
+ u32 group_enable:4;
+ u32 rsvdz:28;
};
};
@@ -814,42 +814,42 @@ union hv_monitor_trigger_state {
/* | 840 | Rsvd4[0] | */
/* ------------------------------------------------------ */
struct hv_monitor_page {
- union hv_monitor_trigger_state TriggerState;
- u32 RsvdZ1;
+ union hv_monitor_trigger_state trigger_state;
+ u32 rsvdz1;
- union hv_monitor_trigger_group TriggerGroup[4];
- u64 RsvdZ2[3];
+ union hv_monitor_trigger_group trigger_group[4];
+ u64 rsvdz2[3];
- s32 NextCheckTime[4][32];
+ s32 next_checktime[4][32];
- u16 Latency[4][32];
- u64 RsvdZ3[32];
+ u16 latency[4][32];
+ u64 rsvdz3[32];
- struct hv_monitor_parameter Parameter[4][32];
+ struct hv_monitor_parameter parameter[4][32];
- u8 RsvdZ4[1984];
+ u8 rsvdz4[1984];
};
/* Declare the various hypercall operations. */
enum hv_call_code {
- HvCallPostMessage = 0x005c,
- HvCallSignalEvent = 0x005d,
+ HVCALL_POST_MESSAGE = 0x005c,
+ HVCALL_SIGNAL_EVENT = 0x005d,
};
/* Definition of the HvPostMessage hypercall input structure. */
struct hv_input_post_message {
- union hv_connection_id ConnectionId;
- u32 Reserved;
- enum hv_message_type MessageType;
- u32 PayloadSize;
- u64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
+ union hv_connection_id connectionid;
+ u32 reserved;
+ enum hv_message_type message_type;
+ u32 payload_size;
+ u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
};
/* Definition of the HvSignalEvent hypercall input structure. */
struct hv_input_signal_event {
- union hv_connection_id ConnectionId;
- u16 FlagNumber;
- u16 RsvdZ;
+ union hv_connection_id connectionid;
+ u16 flag_number;
+ u16 rsvdz;
};
/*
@@ -859,16 +859,16 @@ struct hv_input_signal_event {
/* Version info reported by guest OS's */
enum hv_guest_os_vendor {
- HvGuestOsVendorMicrosoft = 0x0001
+ HVGUESTOS_VENDOR_MICROSOFT = 0x0001
};
enum hv_guest_os_microsoft_ids {
- HvGuestOsMicrosoftUndefined = 0x00,
- HvGuestOsMicrosoftMSDOS = 0x01,
- HvGuestOsMicrosoftWindows3x = 0x02,
- HvGuestOsMicrosoftWindows9x = 0x03,
- HvGuestOsMicrosoftWindowsNT = 0x04,
- HvGuestOsMicrosoftWindowsCE = 0x05
+ HVGUESTOS_MICROSOFT_UNDEFINED = 0x00,
+ HVGUESTOS_MICROSOFT_MSDOS = 0x01,
+ HVGUESTOS_MICROSOFT_WINDOWS3X = 0x02,
+ HVGUESTOS_MICROSOFT_WINDOWS9X = 0x03,
+ HVGUESTOS_MICROSOFT_WINDOWSNT = 0x04,
+ HVGUESTOS_MICROSOFT_WINDOWSCE = 0x05
};
/*
@@ -877,14 +877,14 @@ enum hv_guest_os_microsoft_ids {
#define HV_X64_MSR_GUEST_OS_ID 0x40000000
union hv_x64_msr_guest_os_id_contents {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u64 BuildNumber:16;
- u64 ServiceVersion:8; /* Service Pack, etc. */
- u64 MinorVersion:8;
- u64 MajorVersion:8;
- u64 OsId:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
- u64 VendorId:16; /* enum hv_guest_os_vendor */
+ u64 build_number:16;
+ u64 service_version:8; /* Service Pack, etc. */
+ u64 minor_version:8;
+ u64 major_version:8;
+ u64 os_id:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
+ u64 vendor_id:16; /* enum hv_guest_os_vendor */
};
};
@@ -894,11 +894,11 @@ union hv_x64_msr_guest_os_id_contents {
#define HV_X64_MSR_HYPERCALL 0x40000001
union hv_x64_msr_hypercall_contents {
- u64 AsUINT64;
+ u64 as_uint64;
struct {
- u64 Enable:1;
- u64 Reserved:11;
- u64 GuestPhysicalAddress:52;
+ u64 enable:1;
+ u64 reserved:11;
+ u64 guest_physical_address:52;
};
};
diff --git a/drivers/staging/hv/vmbus.c b/drivers/staging/hv/vmbus.c
index d449daf..7c54ca9 100644
--- a/drivers/staging/hv/vmbus.c
+++ b/drivers/staging/hv/vmbus.c
@@ -153,7 +153,7 @@ static void VmbusOnMsgDPC(struct hv_driver *drv)
struct hv_message *copied;
while (1) {
- if (msg->Header.MessageType == HvMessageTypeNone) {
+ if (msg->header.message_type == HVMSG_NONE) {
/* no msg */
break;
} else {
@@ -166,18 +166,18 @@ static void VmbusOnMsgDPC(struct hv_driver *drv)
(void *)copied);
}
- msg->Header.MessageType = HvMessageTypeNone;
+ msg->header.message_type = HVMSG_NONE;
/*
* Make sure the write to MessageType (ie set to
- * HvMessageTypeNone) happens before we read the
+ * HVMSG_NONE) happens before we read the
* MessagePending and EOMing. Otherwise, the EOMing
* will not deliver any more messages since there is
* no empty slot
*/
mb();
- if (msg->Header.MessageFlags.MessagePending) {
+ if (msg->header.message_flags.msg_pending) {
/*
* This will cause message queue rescan to
* possibly deliver another msg from the
@@ -212,10 +212,10 @@ static int VmbusOnISR(struct hv_driver *drv)
msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
/* Check if there are actual msgs to be process */
- if (msg->Header.MessageType != HvMessageTypeNone) {
+ if (msg->header.message_type != HVMSG_NONE) {
DPRINT_DBG(VMBUS, "received msg type %d size %d",
- msg->Header.MessageType,
- msg->Header.PayloadSize);
+ msg->header.message_type,
+ msg->header.payload_size);
ret |= 0x1;
}
@@ -224,8 +224,8 @@ static int VmbusOnISR(struct hv_driver *drv)
event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
/* Since we are a child, we only need to check bit 0 */
- if (test_and_clear_bit(0, (unsigned long *) &event->Flags32[0])) {
- DPRINT_DBG(VMBUS, "received event %d", event->Flags32[0]);
+ if (test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) {
+ DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]);
ret |= 0x2;
}
--
1.6.3.2
^ permalink raw reply related
* [PATCH 01/10] staging: hv: Convert camel cased struct fields in channel_mgmt.h to lower cases
From: Haiyang Zhang @ 2010-11-08 22:04 UTC (permalink / raw)
To: haiyangz, hjanssen, gregkh, linux-kernel, devel, virtualization
From: Haiyang Zhang <haiyangz@microsoft.com>
staging: hv: Convert camel cased struct fields in channel_mgmt.h to lower cases
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
---
drivers/staging/hv/channel.c | 302 ++++++++++++++++++------------------
drivers/staging/hv/channel_mgmt.c | 186 ++++++++++++------------
drivers/staging/hv/channel_mgmt.h | 244 +++++++++++++++---------------
drivers/staging/hv/connection.c | 38 +++---
drivers/staging/hv/hv_utils.c | 12 +-
drivers/staging/hv/vmbus_drv.c | 42 +++---
6 files changed, 412 insertions(+), 412 deletions(-)
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 26ebc77..9fa0fe1 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -74,21 +74,21 @@ static void vmbus_setevent(struct vmbus_channel *channel)
{
struct hv_monitor_page *monitorpage;
- if (channel->OfferMsg.MonitorAllocated) {
+ if (channel->offermsg.monitor_allocated) {
/* Each u32 represents 32 channels */
- set_bit(channel->OfferMsg.ChildRelId & 31,
+ set_bit(channel->offermsg.child_relid & 31,
(unsigned long *) gVmbusConnection.SendInterruptPage +
- (channel->OfferMsg.ChildRelId >> 5));
+ (channel->offermsg.child_relid >> 5));
monitorpage = gVmbusConnection.MonitorPages;
monitorpage++; /* Get the child to parent monitor page */
- set_bit(channel->MonitorBit,
+ set_bit(channel->monitor_bit,
(unsigned long *)&monitorpage->TriggerGroup
- [channel->MonitorGroup].Pending);
+ [channel->monitor_grp].Pending);
} else {
- VmbusSetEvent(channel->OfferMsg.ChildRelId);
+ VmbusSetEvent(channel->offermsg.child_relid);
}
}
@@ -97,19 +97,19 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel)
{
struct hv_monitor_page *monitorPage;
- if (Channel->OfferMsg.MonitorAllocated) {
+ if (Channel->offermsg.monitor_allocated) {
/* Each u32 represents 32 channels */
- clear_bit(Channel->OfferMsg.ChildRelId & 31,
+ clear_bit(Channel->offermsg.child_relid & 31,
(unsigned long *)gVmbusConnection.SendInterruptPage +
- (Channel->OfferMsg.ChildRelId >> 5));
+ (Channel->offermsg.child_relid >> 5));
monitorPage =
(struct hv_monitor_page *)gVmbusConnection.MonitorPages;
monitorPage++; /* Get the child to parent monitor page */
- clear_bit(Channel->MonitorBit,
+ clear_bit(Channel->monitor_bit,
(unsigned long *)&monitorPage->TriggerGroup
- [Channel->MonitorGroup].Pending);
+ [Channel->monitor_grp].Pending);
}
}
@@ -121,42 +121,42 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
struct vmbus_channel_debug_info *debuginfo)
{
struct hv_monitor_page *monitorpage;
- u8 monitor_group = (u8)channel->OfferMsg.MonitorId / 32;
- u8 monitor_offset = (u8)channel->OfferMsg.MonitorId % 32;
+ u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
+ u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
/* u32 monitorBit = 1 << monitorOffset; */
- debuginfo->RelId = channel->OfferMsg.ChildRelId;
- debuginfo->State = channel->State;
- memcpy(&debuginfo->InterfaceType,
- &channel->OfferMsg.Offer.InterfaceType, sizeof(struct hv_guid));
- memcpy(&debuginfo->InterfaceInstance,
- &channel->OfferMsg.Offer.InterfaceInstance,
+ debuginfo->relid = channel->offermsg.child_relid;
+ debuginfo->state = channel->state;
+ memcpy(&debuginfo->interfacetype,
+ &channel->offermsg.offer.InterfaceType, sizeof(struct hv_guid));
+ memcpy(&debuginfo->interface_instance,
+ &channel->offermsg.offer.InterfaceInstance,
sizeof(struct hv_guid));
monitorpage = (struct hv_monitor_page *)gVmbusConnection.MonitorPages;
- debuginfo->MonitorId = channel->OfferMsg.MonitorId;
+ debuginfo->monitorid = channel->offermsg.monitorid;
- debuginfo->ServerMonitorPending =
+ debuginfo->servermonitor_pending =
monitorpage->TriggerGroup[monitor_group].Pending;
- debuginfo->ServerMonitorLatency =
+ debuginfo->servermonitor_latency =
monitorpage->Latency[monitor_group][monitor_offset];
- debuginfo->ServerMonitorConnectionId =
+ debuginfo->servermonitor_connectionid =
monitorpage->Parameter[monitor_group]
[monitor_offset].ConnectionId.u.Id;
monitorpage++;
- debuginfo->ClientMonitorPending =
+ debuginfo->clientmonitor_pending =
monitorpage->TriggerGroup[monitor_group].Pending;
- debuginfo->ClientMonitorLatency =
+ debuginfo->clientmonitor_latency =
monitorpage->Latency[monitor_group][monitor_offset];
- debuginfo->ClientMonitorConnectionId =
+ debuginfo->clientmonitor_connectionid =
monitorpage->Parameter[monitor_group]
[monitor_offset].ConnectionId.u.Id;
- RingBufferGetDebugInfo(&channel->Inbound, &debuginfo->Inbound);
- RingBufferGetDebugInfo(&channel->Outbound, &debuginfo->Outbound);
+ RingBufferGetDebugInfo(&channel->inbound, &debuginfo->inbound);
+ RingBufferGetDebugInfo(&channel->outbound, &debuginfo->outbound);
}
/*
@@ -176,8 +176,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
/* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
/* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
- newchannel->OnChannelCallback = onchannelcallback;
- newchannel->ChannelCallbackContext = context;
+ newchannel->onchannel_callback = onchannelcallback;
+ newchannel->channel_callback_context = context;
/* Allocate the ring buffer */
out = osd_PageAlloc((send_ringbuffer_size + recv_ringbuffer_size)
@@ -189,17 +189,17 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
in = (void *)((unsigned long)out + send_ringbuffer_size);
- newchannel->RingBufferPages = out;
- newchannel->RingBufferPageCount = (send_ringbuffer_size +
+ newchannel->ringbuffer_pages = out;
+ newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
recv_ringbuffer_size) >> PAGE_SHIFT;
- ret = RingBufferInit(&newchannel->Outbound, out, send_ringbuffer_size);
+ ret = RingBufferInit(&newchannel->outbound, out, send_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
}
- ret = RingBufferInit(&newchannel->Inbound, in, recv_ringbuffer_size);
+ ret = RingBufferInit(&newchannel->inbound, in, recv_ringbuffer_size);
if (ret != 0) {
err = ret;
goto errorout;
@@ -210,13 +210,13 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
newchannel);
- newchannel->RingBufferGpadlHandle = 0;
+ newchannel->ringbuffer_gpadlhandle = 0;
ret = vmbus_establish_gpadl(newchannel,
- newchannel->Outbound.RingBuffer,
+ newchannel->outbound.RingBuffer,
send_ringbuffer_size +
recv_ringbuffer_size,
- &newchannel->RingBufferGpadlHandle);
+ &newchannel->ringbuffer_gpadlhandle);
if (ret != 0) {
err = ret;
@@ -225,12 +225,12 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
"size %d recv ring %p size %d, downstreamoffset %d>",
- newchannel, newchannel->OfferMsg.ChildRelId,
- newchannel->RingBufferGpadlHandle,
- newchannel->Outbound.RingBuffer,
- newchannel->Outbound.RingSize,
- newchannel->Inbound.RingBuffer,
- newchannel->Inbound.RingSize,
+ newchannel, newchannel->offermsg.child_relid,
+ newchannel->ringbuffer_gpadlhandle,
+ newchannel->outbound.RingBuffer,
+ newchannel->outbound.RingSize,
+ newchannel->inbound.RingBuffer,
+ newchannel->inbound.RingSize,
send_ringbuffer_size);
/* Create and init the channel open message */
@@ -242,20 +242,20 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
goto errorout;
}
- openInfo->WaitEvent = osd_WaitEventCreate();
- if (!openInfo->WaitEvent) {
+ openInfo->waitevent = osd_WaitEventCreate();
+ if (!openInfo->waitevent) {
err = -ENOMEM;
goto errorout;
}
- openMsg = (struct vmbus_channel_open_channel *)openInfo->Msg;
- openMsg->Header.MessageType = ChannelMessageOpenChannel;
- openMsg->OpenId = newchannel->OfferMsg.ChildRelId; /* FIXME */
- openMsg->ChildRelId = newchannel->OfferMsg.ChildRelId;
- openMsg->RingBufferGpadlHandle = newchannel->RingBufferGpadlHandle;
- openMsg->DownstreamRingBufferPageOffset = send_ringbuffer_size >>
+ openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
+ openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
+ openMsg->openid = newchannel->offermsg.child_relid; /* FIXME */
+ openMsg->child_relid = newchannel->offermsg.child_relid;
+ openMsg->ringbuffer_gpadlhandle = newchannel->ringbuffer_gpadlhandle;
+ openMsg->downstream_ringbuffer_pageoffset = send_ringbuffer_size >>
PAGE_SHIFT;
- openMsg->ServerContextAreaGpadlHandle = 0; /* TODO */
+ openMsg->server_contextarea_gpadlhandle = 0; /* TODO */
if (userdatalen > MAX_USER_DEFINED_BYTES) {
err = -EINVAL;
@@ -263,10 +263,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
}
if (userdatalen)
- memcpy(openMsg->UserData, userdata, userdatalen);
+ memcpy(openMsg->userdata, userdata, userdatalen);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&openInfo->MsgListEntry,
+ list_add_tail(&openInfo->msglistentry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
@@ -280,26 +280,26 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
}
/* FIXME: Need to time-out here */
- osd_WaitEventWait(openInfo->WaitEvent);
+ osd_WaitEventWait(openInfo->waitevent);
- if (openInfo->Response.OpenResult.Status == 0)
+ if (openInfo->response.open_result.status == 0)
DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
else
DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
- newchannel, openInfo->Response.OpenResult.Status);
+ newchannel, openInfo->response.open_result.status);
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&openInfo->MsgListEntry);
+ list_del(&openInfo->msglistentry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(openInfo->WaitEvent);
+ kfree(openInfo->waitevent);
kfree(openInfo);
return 0;
errorout:
- RingBufferCleanup(&newchannel->Outbound);
- RingBufferCleanup(&newchannel->Inbound);
+ RingBufferCleanup(&newchannel->outbound);
+ RingBufferCleanup(&newchannel->inbound);
osd_PageFree(out, (send_ringbuffer_size + recv_ringbuffer_size)
>> PAGE_SHIFT);
kfree(openInfo);
@@ -322,7 +322,7 @@ static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
for (i = 0; i < pfncount; i++)
DPRINT_DBG(VMBUS, "gpadl body - %d) pfn %llu",
- i, gpadl->Pfn[i]);
+ i, gpadl->pfn[i]);
}
/*
@@ -336,18 +336,18 @@ static void dump_gpadl_header(struct vmbus_channel_gpadl_header *gpadl)
DPRINT_DBG(VMBUS,
"gpadl header - relid %d, range count %d, range buflen %d",
- gpadl->ChildRelId, gpadl->RangeCount, gpadl->RangeBufLen);
- for (i = 0; i < gpadl->RangeCount; i++) {
- pagecount = gpadl->Range[i].ByteCount >> PAGE_SHIFT;
+ gpadl->child_relid, gpadl->rangecount, gpadl->range_buflen);
+ for (i = 0; i < gpadl->rangecount; i++) {
+ pagecount = gpadl->range[i].ByteCount >> PAGE_SHIFT;
pagecount = (pagecount > 26) ? 26 : pagecount;
DPRINT_DBG(VMBUS, "gpadl range %d - len %d offset %d "
- "page count %d", i, gpadl->Range[i].ByteCount,
- gpadl->Range[i].ByteOffset, pagecount);
+ "page count %d", i, gpadl->range[i].ByteCount,
+ gpadl->range[i].ByteOffset, pagecount);
for (j = 0; j < pagecount; j++)
DPRINT_DBG(VMBUS, "%d) pfn %llu", j,
- gpadl->Range[i].PfnArray[j]);
+ gpadl->range[i].PfnArray[j]);
}
}
@@ -391,18 +391,18 @@ static int create_gpadl_header(void *kbuffer, u32 size,
if (!msgheader)
goto nomem;
- INIT_LIST_HEAD(&msgheader->SubMsgList);
- msgheader->MessageSize = msgsize;
+ INIT_LIST_HEAD(&msgheader->submsglist);
+ msgheader->msgsize = msgsize;
gpadl_header = (struct vmbus_channel_gpadl_header *)
- msgheader->Msg;
- gpadl_header->RangeCount = 1;
- gpadl_header->RangeBufLen = sizeof(struct gpa_range) +
+ msgheader->msg;
+ gpadl_header->rangecount = 1;
+ gpadl_header->range_buflen = sizeof(struct gpa_range) +
pagecount * sizeof(u64);
- gpadl_header->Range[0].ByteOffset = 0;
- gpadl_header->Range[0].ByteCount = size;
+ gpadl_header->range[0].ByteOffset = 0;
+ gpadl_header->range[0].ByteCount = size;
for (i = 0; i < pfncount; i++)
- gpadl_header->Range[0].PfnArray[i] = pfn+i;
+ gpadl_header->range[0].PfnArray[i] = pfn+i;
*msginfo = msgheader;
*messagecount = 1;
@@ -428,10 +428,10 @@ static int create_gpadl_header(void *kbuffer, u32 size,
/* FIXME: we probably need to more if this fails */
if (!msgbody)
goto nomem;
- msgbody->MessageSize = msgsize;
+ msgbody->msgsize = msgsize;
(*messagecount)++;
gpadl_body =
- (struct vmbus_channel_gpadl_body *)msgbody->Msg;
+ (struct vmbus_channel_gpadl_body *)msgbody->msg;
/*
* FIXME:
@@ -440,11 +440,11 @@ static int create_gpadl_header(void *kbuffer, u32 size,
*/
/* gpadl_body->Gpadl = kbuffer; */
for (i = 0; i < pfncurr; i++)
- gpadl_body->Pfn[i] = pfn + pfnsum + i;
+ gpadl_body->pfn[i] = pfn + pfnsum + i;
/* add to msg header */
- list_add_tail(&msgbody->MsgListEntry,
- &msgheader->SubMsgList);
+ list_add_tail(&msgbody->msglistentry,
+ &msgheader->submsglist);
pfnsum += pfncurr;
pfnleft -= pfncurr;
}
@@ -456,17 +456,17 @@ static int create_gpadl_header(void *kbuffer, u32 size,
msgheader = kzalloc(msgsize, GFP_KERNEL);
if (msgheader == NULL)
goto nomem;
- msgheader->MessageSize = msgsize;
+ msgheader->msgsize = msgsize;
gpadl_header = (struct vmbus_channel_gpadl_header *)
- msgheader->Msg;
- gpadl_header->RangeCount = 1;
- gpadl_header->RangeBufLen = sizeof(struct gpa_range) +
+ msgheader->msg;
+ gpadl_header->rangecount = 1;
+ gpadl_header->range_buflen = sizeof(struct gpa_range) +
pagecount * sizeof(u64);
- gpadl_header->Range[0].ByteOffset = 0;
- gpadl_header->Range[0].ByteCount = size;
+ gpadl_header->range[0].ByteOffset = 0;
+ gpadl_header->range[0].ByteCount = size;
for (i = 0; i < pagecount; i++)
- gpadl_header->Range[0].PfnArray[i] = pfn+i;
+ gpadl_header->range[0].PfnArray[i] = pfn+i;
*msginfo = msgheader;
*messagecount = 1;
@@ -508,21 +508,21 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
if (ret)
return ret;
- msginfo->WaitEvent = osd_WaitEventCreate();
- if (!msginfo->WaitEvent) {
+ msginfo->waitevent = osd_WaitEventCreate();
+ if (!msginfo->waitevent) {
ret = -ENOMEM;
goto Cleanup;
}
- gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->Msg;
- gpadlmsg->Header.MessageType = ChannelMessageGpadlHeader;
- gpadlmsg->ChildRelId = channel->OfferMsg.ChildRelId;
- gpadlmsg->Gpadl = next_gpadl_handle;
+ gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
+ gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
+ gpadlmsg->child_relid = channel->offermsg.child_relid;
+ gpadlmsg->gpadl = next_gpadl_handle;
dump_gpadl_header(gpadlmsg);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msginfo->MsgListEntry,
+ list_add_tail(&msginfo->msglistentry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
@@ -530,9 +530,9 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
kbuffer, size, msgcount);
DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
- msginfo->MessageSize - sizeof(*msginfo));
+ msginfo->msgsize - sizeof(*msginfo));
- ret = VmbusPostMessage(gpadlmsg, msginfo->MessageSize -
+ ret = VmbusPostMessage(gpadlmsg, msginfo->msgsize -
sizeof(*msginfo));
if (ret != 0) {
DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
@@ -540,48 +540,48 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
}
if (msgcount > 1) {
- list_for_each(curr, &msginfo->SubMsgList) {
+ list_for_each(curr, &msginfo->submsglist) {
/* FIXME: should this use list_entry() instead ? */
submsginfo = (struct vmbus_channel_msginfo *)curr;
gpadl_body =
- (struct vmbus_channel_gpadl_body *)submsginfo->Msg;
+ (struct vmbus_channel_gpadl_body *)submsginfo->msg;
- gpadl_body->Header.MessageType =
- ChannelMessageGpadlBody;
- gpadl_body->Gpadl = next_gpadl_handle;
+ gpadl_body->header.msgtype =
+ CHANNELMSG_GPADL_BODY;
+ gpadl_body->gpadl = next_gpadl_handle;
DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
- submsginfo->MessageSize -
+ submsginfo->msgsize -
sizeof(*submsginfo));
- dump_gpadl_body(gpadl_body, submsginfo->MessageSize -
+ dump_gpadl_body(gpadl_body, submsginfo->msgsize -
sizeof(*submsginfo));
ret = VmbusPostMessage(gpadl_body,
- submsginfo->MessageSize -
+ submsginfo->msgsize -
sizeof(*submsginfo));
if (ret != 0)
goto Cleanup;
}
}
- osd_WaitEventWait(msginfo->WaitEvent);
+ osd_WaitEventWait(msginfo->waitevent);
/* At this point, we received the gpadl created msg */
DPRINT_DBG(VMBUS, "Received GPADL created "
"(relid %d, status %d handle %x)",
- channel->OfferMsg.ChildRelId,
- msginfo->Response.GpadlCreated.CreationStatus,
- gpadlmsg->Gpadl);
+ channel->offermsg.child_relid,
+ msginfo->response.gpadl_created.creation_status,
+ gpadlmsg->gpadl);
- *gpadl_handle = gpadlmsg->Gpadl;
+ *gpadl_handle = gpadlmsg->gpadl;
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&msginfo->MsgListEntry);
+ list_del(&msginfo->msglistentry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(msginfo->WaitEvent);
+ kfree(msginfo->waitevent);
kfree(msginfo);
return ret;
}
@@ -604,20 +604,20 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
if (!info)
return -ENOMEM;
- info->WaitEvent = osd_WaitEventCreate();
- if (!info->WaitEvent) {
+ info->waitevent = osd_WaitEventCreate();
+ if (!info->waitevent) {
kfree(info);
return -ENOMEM;
}
- msg = (struct vmbus_channel_gpadl_teardown *)info->Msg;
+ msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
- msg->Header.MessageType = ChannelMessageGpadlTeardown;
- msg->ChildRelId = channel->OfferMsg.ChildRelId;
- msg->Gpadl = gpadl_handle;
+ msg->header.msgtype = CHANNELMSG_GPADL_TEARDOWN;
+ msg->child_relid = channel->offermsg.child_relid;
+ msg->gpadl = gpadl_handle;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&info->MsgListEntry,
+ list_add_tail(&info->msglistentry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
@@ -628,14 +628,14 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
/* something... */
}
- osd_WaitEventWait(info->WaitEvent);
+ osd_WaitEventWait(info->waitevent);
/* Received a torndown response */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_del(&info->MsgListEntry);
+ list_del(&info->msglistentry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
- kfree(info->WaitEvent);
+ kfree(info->waitevent);
kfree(info);
return ret;
}
@@ -652,7 +652,7 @@ void vmbus_close(struct vmbus_channel *channel)
int ret;
/* Stop callback and cancel the timer asap */
- channel->OnChannelCallback = NULL;
+ channel->onchannel_callback = NULL;
del_timer_sync(&channel->poll_timer);
/* Send a closing message */
@@ -665,9 +665,9 @@ void vmbus_close(struct vmbus_channel *channel)
/* info->waitEvent = osd_WaitEventCreate(); */
- msg = (struct vmbus_channel_close_channel *)info->Msg;
- msg->Header.MessageType = ChannelMessageCloseChannel;
- msg->ChildRelId = channel->OfferMsg.ChildRelId;
+ msg = (struct vmbus_channel_close_channel *)info->msg;
+ msg->header.msgtype = CHANNELMSG_CLOSECHANNEL;
+ msg->child_relid = channel->offermsg.child_relid;
ret = VmbusPostMessage(msg, sizeof(struct vmbus_channel_close_channel));
if (ret != 0) {
@@ -676,17 +676,17 @@ void vmbus_close(struct vmbus_channel *channel)
}
/* Tear down the gpadl for the channel's ring buffer */
- if (channel->RingBufferGpadlHandle)
+ if (channel->ringbuffer_gpadlhandle)
vmbus_teardown_gpadl(channel,
- channel->RingBufferGpadlHandle);
+ channel->ringbuffer_gpadlhandle);
/* TODO: Send a msg to release the childRelId */
/* Cleanup the ring buffers for this channel */
- RingBufferCleanup(&channel->Outbound);
- RingBufferCleanup(&channel->Inbound);
+ RingBufferCleanup(&channel->outbound);
+ RingBufferCleanup(&channel->inbound);
- osd_PageFree(channel->RingBufferPages, channel->RingBufferPageCount);
+ osd_PageFree(channel->ringbuffer_pages, channel->ringbuffer_pagecount);
kfree(info);
@@ -696,9 +696,9 @@ void vmbus_close(struct vmbus_channel *channel)
* caller will free the channel
*/
- if (channel->State == CHANNEL_OPEN_STATE) {
+ if (channel->state == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_del(&channel->ListEntry);
+ list_del(&channel->listentry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
free_channel(channel);
@@ -752,10 +752,10 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
sg_set_buf(&bufferlist[2], &aligned_data,
packetlen_aligned - packetlen);
- ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
+ ret = RingBufferWrite(&channel->outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->outbound))
vmbus_setevent(channel);
return ret;
@@ -817,10 +817,10 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
sg_set_buf(&bufferlist[2], &aligned_data,
packetlen_aligned - packetlen);
- ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
+ ret = RingBufferWrite(&channel->outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->outbound))
vmbus_setevent(channel);
return ret;
@@ -886,10 +886,10 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
sg_set_buf(&bufferlist[2], &aligned_data,
packetlen_aligned - packetlen);
- ret = RingBufferWrite(&channel->Outbound, bufferlist, 3);
+ ret = RingBufferWrite(&channel->outbound, bufferlist, 3);
/* TODO: We should determine if this is optional */
- if (ret == 0 && !GetRingBufferInterruptMask(&channel->Outbound))
+ if (ret == 0 && !GetRingBufferInterruptMask(&channel->outbound))
vmbus_setevent(channel);
return ret;
@@ -923,7 +923,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -940,7 +940,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- channel, channel->OfferMsg.ChildRelId, desc.Type,
+ channel, channel->offermsg.child_relid, desc.Type,
desc.Flags, desc.TransactionId, packetlen, userlen);
*buffer_actual_len = userlen;
@@ -956,7 +956,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
*requestid = desc.TransactionId;
/* Copy over the packet to the user buffer */
- ret = RingBufferRead(&channel->Inbound, buffer, userlen,
+ ret = RingBufferRead(&channel->inbound, buffer, userlen,
(desc.DataOffset8 << 3));
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -983,7 +983,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
spin_lock_irqsave(&channel->inbound_lock, flags);
- ret = RingBufferPeek(&channel->Inbound, &desc,
+ ret = RingBufferPeek(&channel->inbound, &desc,
sizeof(struct vmpacket_descriptor));
if (ret != 0) {
spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -999,7 +999,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
"flag %d tid %llx pktlen %d datalen %d> ",
- channel, channel->OfferMsg.ChildRelId, desc.Type,
+ channel, channel->offermsg.child_relid, desc.Type,
desc.Flags, desc.TransactionId, packetlen, userlen);
*buffer_actual_len = packetlen;
@@ -1015,7 +1015,7 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
*requestid = desc.TransactionId;
/* Copy over the entire packet to the user buffer */
- ret = RingBufferRead(&channel->Inbound, buffer, packetlen, 0);
+ ret = RingBufferRead(&channel->inbound, buffer, packetlen, 0);
spin_unlock_irqrestore(&channel->inbound_lock, flags);
return 0;
@@ -1030,7 +1030,7 @@ void vmbus_onchannel_event(struct vmbus_channel *channel)
dump_vmbus_channel(channel);
/* ASSERT(Channel->OnChannelCallback); */
- channel->OnChannelCallback(channel->ChannelCallbackContext);
+ channel->onchannel_callback(channel->channel_callback_context);
mod_timer(&channel->poll_timer, jiffies + usecs_to_jiffies(100));
}
@@ -1042,8 +1042,8 @@ void vmbus_ontimer(unsigned long data)
{
struct vmbus_channel *channel = (struct vmbus_channel *)data;
- if (channel->OnChannelCallback)
- channel->OnChannelCallback(channel->ChannelCallbackContext);
+ if (channel->onchannel_callback)
+ channel->onchannel_callback(channel->channel_callback_context);
}
/*
@@ -1051,7 +1051,7 @@ void vmbus_ontimer(unsigned long data)
*/
static void dump_vmbus_channel(struct vmbus_channel *channel)
{
- DPRINT_DBG(VMBUS, "Channel (%d)", channel->OfferMsg.ChildRelId);
- DumpRingInfo(&channel->Outbound, "Outbound ");
- DumpRingInfo(&channel->Inbound, "Inbound ");
+ DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid);
+ DumpRingInfo(&channel->outbound, "Outbound ");
+ DumpRingInfo(&channel->inbound, "Inbound ");
}
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 45dbe30..dbfe0f2 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -251,8 +251,8 @@ static struct vmbus_channel *alloc_channel(void)
channel->poll_timer.data = (unsigned long)channel;
channel->poll_timer.function = vmbus_ontimer;
- channel->ControlWQ = create_workqueue("hv_vmbus_ctl");
- if (!channel->ControlWQ) {
+ channel->controlwq = create_workqueue("hv_vmbus_ctl");
+ if (!channel->controlwq) {
kfree(channel);
return NULL;
}
@@ -268,7 +268,7 @@ static inline void release_channel(void *context)
struct vmbus_channel *channel = context;
DPRINT_DBG(VMBUS, "releasing channel (%p)", channel);
- destroy_workqueue(channel->ControlWQ);
+ destroy_workqueue(channel->controlwq);
DPRINT_DBG(VMBUS, "channel released (%p)", channel);
kfree(channel);
@@ -325,12 +325,12 @@ static void vmbus_process_offer(void *context)
/* Make sure this is a new offer */
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) {
- if (!memcmp(&channel->OfferMsg.Offer.InterfaceType,
- &newchannel->OfferMsg.Offer.InterfaceType,
+ list_for_each_entry(channel, &gVmbusConnection.ChannelList, listentry) {
+ if (!memcmp(&channel->offermsg.offer.InterfaceType,
+ &newchannel->offermsg.offer.InterfaceType,
sizeof(struct hv_guid)) &&
- !memcmp(&channel->OfferMsg.Offer.InterfaceInstance,
- &newchannel->OfferMsg.Offer.InterfaceInstance,
+ !memcmp(&channel->offermsg.offer.InterfaceInstance,
+ &newchannel->offermsg.offer.InterfaceInstance,
sizeof(struct hv_guid))) {
fnew = false;
break;
@@ -338,14 +338,14 @@ static void vmbus_process_offer(void *context)
}
if (fnew)
- list_add_tail(&newchannel->ListEntry,
+ list_add_tail(&newchannel->listentry,
&gVmbusConnection.ChannelList);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
if (!fnew) {
DPRINT_DBG(VMBUS, "Ignoring duplicate offer for relid (%d)",
- newchannel->OfferMsg.ChildRelId);
+ newchannel->offermsg.child_relid);
free_channel(newchannel);
return;
}
@@ -355,27 +355,27 @@ static void vmbus_process_offer(void *context)
* We need to set the DeviceObject field before calling
* VmbusChildDeviceAdd()
*/
- newchannel->DeviceObject = VmbusChildDeviceCreate(
- &newchannel->OfferMsg.Offer.InterfaceType,
- &newchannel->OfferMsg.Offer.InterfaceInstance,
+ newchannel->device_obj = VmbusChildDeviceCreate(
+ &newchannel->offermsg.offer.InterfaceType,
+ &newchannel->offermsg.offer.InterfaceInstance,
newchannel);
DPRINT_DBG(VMBUS, "child device object allocated - %p",
- newchannel->DeviceObject);
+ newchannel->device_obj);
/*
* Add the new device to the bus. This will kick off device-driver
* binding which eventually invokes the device driver's AddDevice()
* method.
*/
- ret = VmbusChildDeviceAdd(newchannel->DeviceObject);
+ ret = VmbusChildDeviceAdd(newchannel->device_obj);
if (ret != 0) {
DPRINT_ERR(VMBUS,
"unable to add child device object (relid %d)",
- newchannel->OfferMsg.ChildRelId);
+ newchannel->offermsg.child_relid);
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_del(&newchannel->ListEntry);
+ list_del(&newchannel->listentry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
free_channel(newchannel);
@@ -385,11 +385,11 @@ static void vmbus_process_offer(void *context)
* so that when we do close the channel normally, we
* can cleanup properly
*/
- newchannel->State = CHANNEL_OPEN_STATE;
+ newchannel->state = CHANNEL_OPEN_STATE;
/* Open IC channels */
for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
- if (memcmp(&newchannel->OfferMsg.Offer.InterfaceType,
+ if (memcmp(&newchannel->offermsg.offer.InterfaceType,
&hv_cb_utils[cnt].data,
sizeof(struct hv_guid)) == 0 &&
vmbus_open(newchannel, 2 * PAGE_SIZE,
@@ -413,7 +413,7 @@ static void vmbus_process_rescind_offer(void *context)
{
struct vmbus_channel *channel = context;
- VmbusChildDeviceRemove(channel->DeviceObject);
+ VmbusChildDeviceRemove(channel->device_obj);
}
/*
@@ -434,7 +434,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
offer = (struct vmbus_channel_offer_channel *)hdr;
for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
- if (memcmp(&offer->Offer.InterfaceType,
+ if (memcmp(&offer->offer.InterfaceType,
&gSupportedDeviceClasses[i], sizeof(struct hv_guid)) == 0) {
fsupported = 1;
break;
@@ -443,12 +443,12 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
if (!fsupported) {
DPRINT_DBG(VMBUS, "Ignoring channel offer notification for "
- "child relid %d", offer->ChildRelId);
+ "child relid %d", offer->child_relid);
return;
}
- guidtype = &offer->Offer.InterfaceType;
- guidinstance = &offer->Offer.InterfaceInstance;
+ guidtype = &offer->offer.InterfaceType;
+ guidinstance = &offer->offer.InterfaceInstance;
DPRINT_INFO(VMBUS, "Channel offer notification - "
"child relid %d monitor id %d allocated %d, "
@@ -456,8 +456,8 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
"%02x%02x%02x%02x%02x%02x%02x%02x} "
"instance {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
"%02x%02x%02x%02x%02x%02x%02x%02x}",
- offer->ChildRelId, offer->MonitorId,
- offer->MonitorAllocated,
+ offer->child_relid, offer->monitorid,
+ offer->monitor_allocated,
guidtype->data[3], guidtype->data[2],
guidtype->data[1], guidtype->data[0],
guidtype->data[5], guidtype->data[4],
@@ -484,13 +484,13 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
DPRINT_DBG(VMBUS, "channel object allocated - %p", newchannel);
- memcpy(&newchannel->OfferMsg, offer,
+ memcpy(&newchannel->offermsg, offer,
sizeof(struct vmbus_channel_offer_channel));
- newchannel->MonitorGroup = (u8)offer->MonitorId / 32;
- newchannel->MonitorBit = (u8)offer->MonitorId % 32;
+ newchannel->monitor_grp = (u8)offer->monitorid / 32;
+ newchannel->monitor_bit = (u8)offer->monitorid % 32;
/* TODO: Make sure the offer comes from our parent partition */
- osd_schedule_callback(newchannel->ControlWQ, vmbus_process_offer,
+ osd_schedule_callback(newchannel->controlwq, vmbus_process_offer,
newchannel);
}
@@ -505,14 +505,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
struct vmbus_channel *channel;
rescind = (struct vmbus_channel_rescind_offer *)hdr;
- channel = GetChannelFromRelId(rescind->ChildRelId);
+ channel = GetChannelFromRelId(rescind->child_relid);
if (channel == NULL) {
DPRINT_DBG(VMBUS, "channel not found for relId %d",
- rescind->ChildRelId);
+ rescind->child_relid);
return;
}
- osd_schedule_callback(channel->ControlWQ,
+ osd_schedule_callback(channel->controlwq,
vmbus_process_rescind_offer,
channel);
}
@@ -545,7 +545,7 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
unsigned long flags;
result = (struct vmbus_channel_open_result *)hdr;
- DPRINT_DBG(VMBUS, "vmbus open result - %d", result->Status);
+ DPRINT_DBG(VMBUS, "vmbus open result - %d", result->status);
/*
* Find the open msg, copy the result and signal/unblock the wait event
@@ -556,17 +556,17 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
- (struct vmbus_channel_message_header *)msginfo->Msg;
+ (struct vmbus_channel_message_header *)msginfo->msg;
- if (requestheader->MessageType == ChannelMessageOpenChannel) {
+ if (requestheader->msgtype == CHANNELMSG_OPENCHANNEL) {
openmsg =
- (struct vmbus_channel_open_channel *)msginfo->Msg;
- if (openmsg->ChildRelId == result->ChildRelId &&
- openmsg->OpenId == result->OpenId) {
- memcpy(&msginfo->Response.OpenResult,
+ (struct vmbus_channel_open_channel *)msginfo->msg;
+ if (openmsg->child_relid == result->child_relid &&
+ openmsg->openid == result->openid) {
+ memcpy(&msginfo->response.open_result,
result,
sizeof(struct vmbus_channel_open_result));
- osd_WaitEventSet(msginfo->WaitEvent);
+ osd_WaitEventSet(msginfo->waitevent);
break;
}
}
@@ -592,7 +592,7 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d",
- gpadlcreated->CreationStatus);
+ gpadlcreated->creation_status);
/*
* Find the establish msg, copy the result and signal/unblock the wait
@@ -604,19 +604,19 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
- (struct vmbus_channel_message_header *)msginfo->Msg;
+ (struct vmbus_channel_message_header *)msginfo->msg;
- if (requestheader->MessageType == ChannelMessageGpadlHeader) {
+ if (requestheader->msgtype == CHANNELMSG_GPADL_HEADER) {
gpadlheader =
(struct vmbus_channel_gpadl_header *)requestheader;
- if ((gpadlcreated->ChildRelId ==
- gpadlheader->ChildRelId) &&
- (gpadlcreated->Gpadl == gpadlheader->Gpadl)) {
- memcpy(&msginfo->Response.GpadlCreated,
+ if ((gpadlcreated->child_relid ==
+ gpadlheader->child_relid) &&
+ (gpadlcreated->gpadl == gpadlheader->gpadl)) {
+ memcpy(&msginfo->response.gpadl_created,
gpadlcreated,
sizeof(struct vmbus_channel_gpadl_created));
- osd_WaitEventSet(msginfo->WaitEvent);
+ osd_WaitEventSet(msginfo->waitevent);
break;
}
}
@@ -652,17 +652,17 @@ static void vmbus_ongpadl_torndown(
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
- (struct vmbus_channel_message_header *)msginfo->Msg;
+ (struct vmbus_channel_message_header *)msginfo->msg;
- if (requestheader->MessageType == ChannelMessageGpadlTeardown) {
+ if (requestheader->msgtype == CHANNELMSG_GPADL_TEARDOWN) {
gpadl_teardown =
(struct vmbus_channel_gpadl_teardown *)requestheader;
- if (gpadl_torndown->Gpadl == gpadl_teardown->Gpadl) {
- memcpy(&msginfo->Response.GpadlTorndown,
+ if (gpadl_torndown->gpadl == gpadl_teardown->gpadl) {
+ memcpy(&msginfo->response.gpadl_torndown,
gpadl_torndown,
sizeof(struct vmbus_channel_gpadl_torndown));
- osd_WaitEventSet(msginfo->WaitEvent);
+ osd_WaitEventSet(msginfo->waitevent);
break;
}
}
@@ -694,16 +694,16 @@ static void vmbus_onversion_response(
/* FIXME: this should probably use list_entry() instead */
msginfo = (struct vmbus_channel_msginfo *)curr;
requestheader =
- (struct vmbus_channel_message_header *)msginfo->Msg;
+ (struct vmbus_channel_message_header *)msginfo->msg;
- if (requestheader->MessageType ==
- ChannelMessageInitiateContact) {
+ if (requestheader->msgtype ==
+ CHANNELMSG_INITIATE_CONTACT) {
initiate =
(struct vmbus_channel_initiate_contact *)requestheader;
- memcpy(&msginfo->Response.VersionResponse,
+ memcpy(&msginfo->response.version_response,
version_response,
sizeof(struct vmbus_channel_version_response));
- osd_WaitEventSet(msginfo->WaitEvent);
+ osd_WaitEventSet(msginfo->waitevent);
}
}
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
@@ -711,24 +711,24 @@ static void vmbus_onversion_response(
/* Channel message dispatch table */
static struct vmbus_channel_message_table_entry
- gChannelMessageTable[ChannelMessageCount] = {
- {ChannelMessageInvalid, NULL},
- {ChannelMessageOfferChannel, vmbus_onoffer},
- {ChannelMessageRescindChannelOffer, vmbus_onoffer_rescind},
- {ChannelMessageRequestOffers, NULL},
- {ChannelMessageAllOffersDelivered, vmbus_onoffers_delivered},
- {ChannelMessageOpenChannel, NULL},
- {ChannelMessageOpenChannelResult, vmbus_onopen_result},
- {ChannelMessageCloseChannel, NULL},
- {ChannelMessageGpadlHeader, NULL},
- {ChannelMessageGpadlBody, NULL},
- {ChannelMessageGpadlCreated, vmbus_ongpadl_created},
- {ChannelMessageGpadlTeardown, NULL},
- {ChannelMessageGpadlTorndown, vmbus_ongpadl_torndown},
- {ChannelMessageRelIdReleased, NULL},
- {ChannelMessageInitiateContact, NULL},
- {ChannelMessageVersionResponse, vmbus_onversion_response},
- {ChannelMessageUnload, NULL},
+ gChannelMessageTable[CHANNELMSG_COUNT] = {
+ {CHANNELMSG_INVALID, NULL},
+ {CHANNELMSG_OFFERCHANNEL, vmbus_onoffer},
+ {CHANNELMSG_RESCIND_CHANNELOFFER, vmbus_onoffer_rescind},
+ {CHANNELMSG_REQUESTOFFERS, NULL},
+ {CHANNELMSG_ALLOFFERS_DELIVERED, vmbus_onoffers_delivered},
+ {CHANNELMSG_OPENCHANNEL, NULL},
+ {CHANNELMSG_OPENCHANNEL_RESULT, vmbus_onopen_result},
+ {CHANNELMSG_CLOSECHANNEL, NULL},
+ {CHANNELMSG_GPADL_HEADER, NULL},
+ {CHANNELMSG_GPADL_BODY, NULL},
+ {CHANNELMSG_GPADL_CREATED, vmbus_ongpadl_created},
+ {CHANNELMSG_GPADL_TEARDOWN, NULL},
+ {CHANNELMSG_GPADL_TORNDOWN, vmbus_ongpadl_torndown},
+ {CHANNELMSG_RELID_RELEASED, NULL},
+ {CHANNELMSG_INITIATE_CONTACT, NULL},
+ {CHANNELMSG_VERSION_RESPONSE, vmbus_onversion_response},
+ {CHANNELMSG_UNLOAD, NULL},
};
/*
@@ -745,23 +745,23 @@ void vmbus_onmessage(void *context)
hdr = (struct vmbus_channel_message_header *)msg->u.Payload;
size = msg->Header.PayloadSize;
- DPRINT_DBG(VMBUS, "message type %d size %d", hdr->MessageType, size);
+ DPRINT_DBG(VMBUS, "message type %d size %d", hdr->msgtype, size);
- if (hdr->MessageType >= ChannelMessageCount) {
+ if (hdr->msgtype >= CHANNELMSG_COUNT) {
DPRINT_ERR(VMBUS,
"Received invalid channel message type %d size %d",
- hdr->MessageType, size);
+ hdr->msgtype, size);
print_hex_dump_bytes("", DUMP_PREFIX_NONE,
(unsigned char *)msg->u.Payload, size);
kfree(msg);
return;
}
- if (gChannelMessageTable[hdr->MessageType].messageHandler)
- gChannelMessageTable[hdr->MessageType].messageHandler(hdr);
+ if (gChannelMessageTable[hdr->msgtype].messageHandler)
+ gChannelMessageTable[hdr->msgtype].messageHandler(hdr);
else
DPRINT_ERR(VMBUS, "Unhandled channel message type %d",
- hdr->MessageType);
+ hdr->msgtype);
/* Free the msg that was allocated in VmbusOnMsgDPC() */
kfree(msg);
@@ -782,15 +782,15 @@ int vmbus_request_offers(void)
if (!msginfo)
return -ENOMEM;
- msginfo->WaitEvent = osd_WaitEventCreate();
- if (!msginfo->WaitEvent) {
+ msginfo->waitevent = osd_WaitEventCreate();
+ if (!msginfo->waitevent) {
kfree(msginfo);
return -ENOMEM;
}
- msg = (struct vmbus_channel_message_header *)msginfo->Msg;
+ msg = (struct vmbus_channel_message_header *)msginfo->msg;
- msg->MessageType = ChannelMessageRequestOffers;
+ msg->msgtype = CHANNELMSG_REQUESTOFFERS;
/*SpinlockAcquire(gVmbusConnection.channelMsgLock);
INSERT_TAIL_LIST(&gVmbusConnection.channelMsgList,
@@ -817,7 +817,7 @@ int vmbus_request_offers(void)
Cleanup:
if (msginfo) {
- kfree(msginfo->WaitEvent);
+ kfree(msginfo->waitevent);
kfree(msginfo);
}
@@ -837,17 +837,17 @@ void vmbus_release_unattached_channels(void)
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
list_for_each_entry_safe(channel, pos, &gVmbusConnection.ChannelList,
- ListEntry) {
+ listentry) {
if (channel == start)
break;
- if (!channel->DeviceObject->Driver) {
- list_del(&channel->ListEntry);
+ if (!channel->device_obj->Driver) {
+ list_del(&channel->listentry);
DPRINT_INFO(VMBUS,
"Releasing unattached device object %p",
- channel->DeviceObject);
+ channel->device_obj);
- VmbusChildDeviceRemove(channel->DeviceObject);
+ VmbusChildDeviceRemove(channel->device_obj);
free_channel(channel);
} else {
if (!start)
diff --git a/drivers/staging/hv/channel_mgmt.h b/drivers/staging/hv/channel_mgmt.h
index d16cc08..12f30af 100644
--- a/drivers/staging/hv/channel_mgmt.h
+++ b/drivers/staging/hv/channel_mgmt.h
@@ -33,60 +33,60 @@
/* Version 1 messages */
enum vmbus_channel_message_type {
- ChannelMessageInvalid = 0,
- ChannelMessageOfferChannel = 1,
- ChannelMessageRescindChannelOffer = 2,
- ChannelMessageRequestOffers = 3,
- ChannelMessageAllOffersDelivered = 4,
- ChannelMessageOpenChannel = 5,
- ChannelMessageOpenChannelResult = 6,
- ChannelMessageCloseChannel = 7,
- ChannelMessageGpadlHeader = 8,
- ChannelMessageGpadlBody = 9,
- ChannelMessageGpadlCreated = 10,
- ChannelMessageGpadlTeardown = 11,
- ChannelMessageGpadlTorndown = 12,
- ChannelMessageRelIdReleased = 13,
- ChannelMessageInitiateContact = 14,
- ChannelMessageVersionResponse = 15,
- ChannelMessageUnload = 16,
+ CHANNELMSG_INVALID = 0,
+ CHANNELMSG_OFFERCHANNEL = 1,
+ CHANNELMSG_RESCIND_CHANNELOFFER = 2,
+ CHANNELMSG_REQUESTOFFERS = 3,
+ CHANNELMSG_ALLOFFERS_DELIVERED = 4,
+ CHANNELMSG_OPENCHANNEL = 5,
+ CHANNELMSG_OPENCHANNEL_RESULT = 6,
+ CHANNELMSG_CLOSECHANNEL = 7,
+ CHANNELMSG_GPADL_HEADER = 8,
+ CHANNELMSG_GPADL_BODY = 9,
+ CHANNELMSG_GPADL_CREATED = 10,
+ CHANNELMSG_GPADL_TEARDOWN = 11,
+ CHANNELMSG_GPADL_TORNDOWN = 12,
+ CHANNELMSG_RELID_RELEASED = 13,
+ CHANNELMSG_INITIATE_CONTACT = 14,
+ CHANNELMSG_VERSION_RESPONSE = 15,
+ CHANNELMSG_UNLOAD = 16,
#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
- ChannelMessageViewRangeAdd = 17,
- ChannelMessageViewRangeRemove = 18,
+ CHANNELMSG_VIEWRANGE_ADD = 17,
+ CHANNELMSG_VIEWRANGE_REMOVE = 18,
#endif
- ChannelMessageCount
+ CHANNELMSG_COUNT
};
struct vmbus_channel_message_header {
- enum vmbus_channel_message_type MessageType;
- u32 Padding;
+ enum vmbus_channel_message_type msgtype;
+ u32 padding;
} __attribute__((packed));
/* Query VMBus Version parameters */
struct vmbus_channel_query_vmbus_version {
- struct vmbus_channel_message_header Header;
- u32 Version;
+ struct vmbus_channel_message_header header;
+ u32 version;
} __attribute__((packed));
/* VMBus Version Supported parameters */
struct vmbus_channel_version_supported {
- struct vmbus_channel_message_header Header;
- bool VersionSupported;
+ struct vmbus_channel_message_header header;
+ bool version_supported;
} __attribute__((packed));
/* Offer Channel parameters */
struct vmbus_channel_offer_channel {
- struct vmbus_channel_message_header Header;
- struct vmbus_channel_offer Offer;
- u32 ChildRelId;
- u8 MonitorId;
- bool MonitorAllocated;
+ struct vmbus_channel_message_header header;
+ struct vmbus_channel_offer offer;
+ u32 child_relid;
+ u8 monitorid;
+ bool monitor_allocated;
} __attribute__((packed));
/* Rescind Offer parameters */
struct vmbus_channel_rescind_offer {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
} __attribute__((packed));
/*
@@ -100,43 +100,43 @@ struct vmbus_channel_rescind_offer {
/* Open Channel parameters */
struct vmbus_channel_open_channel {
- struct vmbus_channel_message_header Header;
+ struct vmbus_channel_message_header header;
/* Identifies the specific VMBus channel that is being opened. */
- u32 ChildRelId;
+ u32 child_relid;
/* ID making a particular open request at a channel offer unique. */
- u32 OpenId;
+ u32 openid;
/* GPADL for the channel's ring buffer. */
- u32 RingBufferGpadlHandle;
+ u32 ringbuffer_gpadlhandle;
/* GPADL for the channel's server context save area. */
- u32 ServerContextAreaGpadlHandle;
+ u32 server_contextarea_gpadlhandle;
/*
* The upstream ring buffer begins at offset zero in the memory
* described by RingBufferGpadlHandle. The downstream ring buffer
* follows it at this offset (in pages).
*/
- u32 DownstreamRingBufferPageOffset;
+ u32 downstream_ringbuffer_pageoffset;
/* User-specific data to be passed along to the server endpoint. */
- unsigned char UserData[MAX_USER_DEFINED_BYTES];
+ unsigned char userdata[MAX_USER_DEFINED_BYTES];
} __attribute__((packed));
/* Open Channel Result parameters */
struct vmbus_channel_open_result {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
- u32 OpenId;
- u32 Status;
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
+ u32 openid;
+ u32 status;
} __attribute__((packed));
/* Close channel parameters; */
struct vmbus_channel_close_channel {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
} __attribute__((packed));
/* Channel Message GPADL */
@@ -151,72 +151,72 @@ struct vmbus_channel_close_channel {
* follow-up packet that contains more.
*/
struct vmbus_channel_gpadl_header {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
- u32 Gpadl;
- u16 RangeBufLen;
- u16 RangeCount;
- struct gpa_range Range[0];
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
+ u32 gpadl;
+ u16 range_buflen;
+ u16 rangecount;
+ struct gpa_range range[0];
} __attribute__((packed));
/* This is the followup packet that contains more PFNs. */
struct vmbus_channel_gpadl_body {
- struct vmbus_channel_message_header Header;
- u32 MessageNumber;
- u32 Gpadl;
- u64 Pfn[0];
+ struct vmbus_channel_message_header header;
+ u32 msgnumber;
+ u32 gpadl;
+ u64 pfn[0];
} __attribute__((packed));
struct vmbus_channel_gpadl_created {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
- u32 Gpadl;
- u32 CreationStatus;
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
+ u32 gpadl;
+ u32 creation_status;
} __attribute__((packed));
struct vmbus_channel_gpadl_teardown {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
- u32 Gpadl;
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
+ u32 gpadl;
} __attribute__((packed));
struct vmbus_channel_gpadl_torndown {
- struct vmbus_channel_message_header Header;
- u32 Gpadl;
+ struct vmbus_channel_message_header header;
+ u32 gpadl;
} __attribute__((packed));
#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
struct vmbus_channel_view_range_add {
- struct vmbus_channel_message_header Header;
- PHYSICAL_ADDRESS ViewRangeBase;
- u64 ViewRangeLength;
- u32 ChildRelId;
+ struct vmbus_channel_message_header header;
+ PHYSICAL_ADDRESS viewrange_base;
+ u64 viewrange_length;
+ u32 child_relid;
} __attribute__((packed));
struct vmbus_channel_view_range_remove {
- struct vmbus_channel_message_header Header;
- PHYSICAL_ADDRESS ViewRangeBase;
- u32 ChildRelId;
+ struct vmbus_channel_message_header header;
+ PHYSICAL_ADDRESS viewrange_base;
+ u32 child_relid;
} __attribute__((packed));
#endif
struct vmbus_channel_relid_released {
- struct vmbus_channel_message_header Header;
- u32 ChildRelId;
+ struct vmbus_channel_message_header header;
+ u32 child_relid;
} __attribute__((packed));
struct vmbus_channel_initiate_contact {
- struct vmbus_channel_message_header Header;
- u32 VMBusVersionRequested;
- u32 Padding2;
- u64 InterruptPage;
- u64 MonitorPage1;
- u64 MonitorPage2;
+ struct vmbus_channel_message_header header;
+ u32 vmbus_version_requested;
+ u32 padding2;
+ u64 interrupt_page;
+ u64 monitor_page1;
+ u64 monitor_page2;
} __attribute__((packed));
struct vmbus_channel_version_response {
- struct vmbus_channel_message_header Header;
- bool VersionSupported;
+ struct vmbus_channel_message_header header;
+ bool version_supported;
} __attribute__((packed));
enum vmbus_channel_state {
@@ -226,54 +226,54 @@ enum vmbus_channel_state {
};
struct vmbus_channel {
- struct list_head ListEntry;
+ struct list_head listentry;
- struct hv_device *DeviceObject;
+ struct hv_device *device_obj;
struct timer_list poll_timer; /* SA-111 workaround */
- enum vmbus_channel_state State;
+ enum vmbus_channel_state state;
- struct vmbus_channel_offer_channel OfferMsg;
+ struct vmbus_channel_offer_channel offermsg;
/*
* These are based on the OfferMsg.MonitorId.
* Save it here for easy access.
*/
- u8 MonitorGroup;
- u8 MonitorBit;
+ u8 monitor_grp;
+ u8 monitor_bit;
- u32 RingBufferGpadlHandle;
+ u32 ringbuffer_gpadlhandle;
/* Allocated memory for ring buffer */
- void *RingBufferPages;
- u32 RingBufferPageCount;
- struct hv_ring_buffer_info Outbound; /* send to parent */
- struct hv_ring_buffer_info Inbound; /* receive from parent */
+ void *ringbuffer_pages;
+ u32 ringbuffer_pagecount;
+ struct hv_ring_buffer_info outbound; /* send to parent */
+ struct hv_ring_buffer_info inbound; /* receive from parent */
spinlock_t inbound_lock;
- struct workqueue_struct *ControlWQ;
+ struct workqueue_struct *controlwq;
/* Channel callback are invoked in this workqueue context */
/* HANDLE dataWorkQueue; */
- void (*OnChannelCallback)(void *context);
- void *ChannelCallbackContext;
+ void (*onchannel_callback)(void *context);
+ void *channel_callback_context;
};
struct vmbus_channel_debug_info {
- u32 RelId;
- enum vmbus_channel_state State;
- struct hv_guid InterfaceType;
- struct hv_guid InterfaceInstance;
- u32 MonitorId;
- u32 ServerMonitorPending;
- u32 ServerMonitorLatency;
- u32 ServerMonitorConnectionId;
- u32 ClientMonitorPending;
- u32 ClientMonitorLatency;
- u32 ClientMonitorConnectionId;
-
- struct hv_ring_buffer_debug_info Inbound;
- struct hv_ring_buffer_debug_info Outbound;
+ u32 relid;
+ enum vmbus_channel_state state;
+ struct hv_guid interfacetype;
+ struct hv_guid interface_instance;
+ u32 monitorid;
+ u32 servermonitor_pending;
+ u32 servermonitor_latency;
+ u32 servermonitor_connectionid;
+ u32 clientmonitor_pending;
+ u32 clientmonitor_latency;
+ u32 clientmonitor_connectionid;
+
+ struct hv_ring_buffer_debug_info inbound;
+ struct hv_ring_buffer_debug_info outbound;
};
/*
@@ -282,28 +282,28 @@ struct vmbus_channel_debug_info {
*/
struct vmbus_channel_msginfo {
/* Bookkeeping stuff */
- struct list_head MsgListEntry;
+ struct list_head msglistentry;
/* So far, this is only used to handle gpadl body message */
- struct list_head SubMsgList;
+ struct list_head submsglist;
/* Synchronize the request/response if needed */
- struct osd_waitevent *WaitEvent;
+ struct osd_waitevent *waitevent;
union {
- struct vmbus_channel_version_supported VersionSupported;
- struct vmbus_channel_open_result OpenResult;
- struct vmbus_channel_gpadl_torndown GpadlTorndown;
- struct vmbus_channel_gpadl_created GpadlCreated;
- struct vmbus_channel_version_response VersionResponse;
- } Response;
-
- u32 MessageSize;
+ struct vmbus_channel_version_supported version_supported;
+ struct vmbus_channel_open_result open_result;
+ struct vmbus_channel_gpadl_torndown gpadl_torndown;
+ struct vmbus_channel_gpadl_created gpadl_created;
+ struct vmbus_channel_version_response version_response;
+ } response;
+
+ u32 msgsize;
/*
* The channel message that goes out on the "wire".
* It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
*/
- unsigned char Msg[0];
+ unsigned char msg[0];
};
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index f847707..6f3f525 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -95,19 +95,19 @@ int VmbusConnect(void)
goto Cleanup;
}
- msgInfo->WaitEvent = osd_WaitEventCreate();
- if (!msgInfo->WaitEvent) {
+ msgInfo->waitevent = osd_WaitEventCreate();
+ if (!msgInfo->waitevent) {
ret = -ENOMEM;
goto Cleanup;
}
- msg = (struct vmbus_channel_initiate_contact *)msgInfo->Msg;
+ msg = (struct vmbus_channel_initiate_contact *)msgInfo->msg;
- msg->Header.MessageType = ChannelMessageInitiateContact;
- msg->VMBusVersionRequested = VMBUS_REVISION_NUMBER;
- msg->InterruptPage = virt_to_phys(gVmbusConnection.InterruptPage);
- msg->MonitorPage1 = virt_to_phys(gVmbusConnection.MonitorPages);
- msg->MonitorPage2 = virt_to_phys(
+ msg->header.msgtype = CHANNELMSG_INITIATE_CONTACT;
+ msg->vmbus_version_requested = VMBUS_REVISION_NUMBER;
+ msg->interrupt_page = virt_to_phys(gVmbusConnection.InterruptPage);
+ msg->monitor_page1 = virt_to_phys(gVmbusConnection.MonitorPages);
+ msg->monitor_page2 = virt_to_phys(
(void *)((unsigned long)gVmbusConnection.MonitorPages +
PAGE_SIZE));
@@ -116,30 +116,30 @@ int VmbusConnect(void)
* receive the response before returning from this routine
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
- list_add_tail(&msgInfo->MsgListEntry,
+ list_add_tail(&msgInfo->msglistentry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, "
"monitor1 pfn %llx,, monitor2 pfn %llx",
- msg->InterruptPage, msg->MonitorPage1, msg->MonitorPage2);
+ msg->interrupt_page, msg->monitor_page1, msg->monitor_page2);
DPRINT_DBG(VMBUS, "Sending channel initiate msg...");
ret = VmbusPostMessage(msg,
sizeof(struct vmbus_channel_initiate_contact));
if (ret != 0) {
- list_del(&msgInfo->MsgListEntry);
+ list_del(&msgInfo->msglistentry);
goto Cleanup;
}
/* Wait for the connection response */
- osd_WaitEventWait(msgInfo->WaitEvent);
+ osd_WaitEventWait(msgInfo->waitevent);
- list_del(&msgInfo->MsgListEntry);
+ list_del(&msgInfo->msglistentry);
/* Check if successful */
- if (msgInfo->Response.VersionResponse.VersionSupported) {
+ if (msgInfo->response.version_response.version_supported) {
DPRINT_INFO(VMBUS, "Vmbus connected!!");
gVmbusConnection.ConnectState = Connected;
@@ -151,7 +151,7 @@ int VmbusConnect(void)
goto Cleanup;
}
- kfree(msgInfo->WaitEvent);
+ kfree(msgInfo->waitevent);
kfree(msgInfo);
return 0;
@@ -172,7 +172,7 @@ Cleanup:
}
if (msgInfo) {
- kfree(msgInfo->WaitEvent);
+ kfree(msgInfo->waitevent);
kfree(msgInfo);
}
@@ -195,7 +195,7 @@ int VmbusDisconnect(void)
if (!msg)
return -ENOMEM;
- msg->MessageType = ChannelMessageUnload;
+ msg->msgtype = CHANNELMSG_UNLOAD;
ret = VmbusPostMessage(msg,
sizeof(struct vmbus_channel_message_header));
@@ -226,8 +226,8 @@ struct vmbus_channel *GetChannelFromRelId(u32 relId)
unsigned long flags;
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
- list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) {
- if (channel->OfferMsg.ChildRelId == relId) {
+ list_for_each_entry(channel, &gVmbusConnection.ChannelList, listentry) {
+ if (channel->offermsg.child_relid == relId) {
foundChannel = channel;
break;
}
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c
index 702a478..6dc1c35 100644
--- a/drivers/staging/hv/hv_utils.c
+++ b/drivers/staging/hv/hv_utils.c
@@ -271,15 +271,15 @@ static int __init init_hyperv_utils(void)
if (!dmi_check_system(hv_utils_dmi_table))
return -ENODEV;
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->OnChannelCallback =
+ hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
&shutdown_onchannelcallback;
hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
- hv_cb_utils[HV_TIMESYNC_MSG].channel->OnChannelCallback =
+ hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
×ync_onchannelcallback;
hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback =
+ hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
&heartbeat_onchannelcallback;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
@@ -290,15 +290,15 @@ static void exit_hyperv_utils(void)
{
printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
- hv_cb_utils[HV_SHUTDOWN_MSG].channel->OnChannelCallback =
+ hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
&chn_cb_negotiate;
hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
- hv_cb_utils[HV_TIMESYNC_MSG].channel->OnChannelCallback =
+ hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
&chn_cb_negotiate;
hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
- hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback =
+ hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
&chn_cb_negotiate;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
}
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 0d9f3a4..2bbf4ec 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -139,35 +139,35 @@ static void get_channel_info(struct hv_device *device,
vmbus_get_debug_info(device->channel, &debug_info);
- info->ChannelId = debug_info.RelId;
- info->ChannelState = debug_info.State;
- memcpy(&info->ChannelType, &debug_info.InterfaceType,
+ info->ChannelId = debug_info.relid;
+ info->ChannelState = debug_info.state;
+ memcpy(&info->ChannelType, &debug_info.interfacetype,
sizeof(struct hv_guid));
- memcpy(&info->ChannelInstance, &debug_info.InterfaceInstance,
+ memcpy(&info->ChannelInstance, &debug_info.interface_instance,
sizeof(struct hv_guid));
- info->MonitorId = debug_info.MonitorId;
+ info->MonitorId = debug_info.monitorid;
- info->ServerMonitorPending = debug_info.ServerMonitorPending;
- info->ServerMonitorLatency = debug_info.ServerMonitorLatency;
- info->ServerMonitorConnectionId = debug_info.ServerMonitorConnectionId;
+ info->ServerMonitorPending = debug_info.servermonitor_pending;
+ info->ServerMonitorLatency = debug_info.servermonitor_latency;
+ info->ServerMonitorConnectionId = debug_info.servermonitor_connectionid;
- info->ClientMonitorPending = debug_info.ClientMonitorPending;
- info->ClientMonitorLatency = debug_info.ClientMonitorLatency;
- info->ClientMonitorConnectionId = debug_info.ClientMonitorConnectionId;
+ info->ClientMonitorPending = debug_info.clientmonitor_pending;
+ info->ClientMonitorLatency = debug_info.clientmonitor_latency;
+ info->ClientMonitorConnectionId = debug_info.clientmonitor_connectionid;
- info->Inbound.InterruptMask = debug_info.Inbound.CurrentInterruptMask;
- info->Inbound.ReadIndex = debug_info.Inbound.CurrentReadIndex;
- info->Inbound.WriteIndex = debug_info.Inbound.CurrentWriteIndex;
- info->Inbound.BytesAvailToRead = debug_info.Inbound.BytesAvailToRead;
- info->Inbound.BytesAvailToWrite = debug_info.Inbound.BytesAvailToWrite;
+ info->Inbound.InterruptMask = debug_info.inbound.CurrentInterruptMask;
+ info->Inbound.ReadIndex = debug_info.inbound.CurrentReadIndex;
+ info->Inbound.WriteIndex = debug_info.inbound.CurrentWriteIndex;
+ info->Inbound.BytesAvailToRead = debug_info.inbound.BytesAvailToRead;
+ info->Inbound.BytesAvailToWrite = debug_info.inbound.BytesAvailToWrite;
- info->Outbound.InterruptMask = debug_info.Outbound.CurrentInterruptMask;
- info->Outbound.ReadIndex = debug_info.Outbound.CurrentReadIndex;
- info->Outbound.WriteIndex = debug_info.Outbound.CurrentWriteIndex;
- info->Outbound.BytesAvailToRead = debug_info.Outbound.BytesAvailToRead;
+ info->Outbound.InterruptMask = debug_info.outbound.CurrentInterruptMask;
+ info->Outbound.ReadIndex = debug_info.outbound.CurrentReadIndex;
+ info->Outbound.WriteIndex = debug_info.outbound.CurrentWriteIndex;
+ info->Outbound.BytesAvailToRead = debug_info.outbound.BytesAvailToRead;
info->Outbound.BytesAvailToWrite =
- debug_info.Outbound.BytesAvailToWrite;
+ debug_info.outbound.BytesAvailToWrite;
}
/*
--
1.6.3.2
^ permalink raw reply related
* Re: [PATCH 36/49] drivers/video: Use vzalloc
From: Konrad Rzeszutek Wilk @ 2010-11-08 16:43 UTC (permalink / raw)
To: Joe Perches
Cc: Jiri Kosina, Jaya Kumar, Jeremy Fitzhardinge, linux-kernel,
xen-devel, virtualization
In-Reply-To: <a1c4c46381ac1867c4af3edb811e58a721957842.1288925425.git.joe@perches.com>
On Thu, Nov 04, 2010 at 08:08:00PM -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <joe@perches.com>
Looks good on xen-fb.
> ---
> drivers/video/arcfb.c | 5 ++---
> drivers/video/broadsheetfb.c | 4 +---
> drivers/video/hecubafb.c | 5 ++---
> drivers/video/metronomefb.c | 4 +---
> drivers/video/xen-fbfront.c | 3 +--
> 5 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
> index 3ec4923..86573e2 100644
> --- a/drivers/video/arcfb.c
> +++ b/drivers/video/arcfb.c
> @@ -515,11 +515,10 @@ static int __devinit arcfb_probe(struct platform_device *dev)
>
> /* We need a flat backing store for the Arc's
> less-flat actual paged framebuffer */
> - if (!(videomemory = vmalloc(videomemorysize)))
> + videomemory = vmalloc(videomemorysize);
> + if (!videomemory)
> return retval;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
> if (!info)
> goto err;
> diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c
> index ebda687..377dde3 100644
> --- a/drivers/video/broadsheetfb.c
> +++ b/drivers/video/broadsheetfb.c
> @@ -1101,12 +1101,10 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev)
>
> videomemorysize = roundup((dpyw*dpyh), PAGE_SIZE);
>
> - videomemory = vmalloc(videomemorysize);
> + videomemory = vzalloc(videomemorysize);
> if (!videomemory)
> goto err_fb_rel;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info->screen_base = (char *)videomemory;
> info->fbops = &broadsheetfb_ops;
>
> diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
> index c77bcc6..a941e6f 100644
> --- a/drivers/video/hecubafb.c
> +++ b/drivers/video/hecubafb.c
> @@ -231,11 +231,10 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
>
> videomemorysize = (DPY_W*DPY_H)/8;
>
> - if (!(videomemory = vmalloc(videomemorysize)))
> + videomemory = vzalloc(videomemorysize);
> + if (!videomemory)
> return retval;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
> if (!info)
> goto err_fballoc;
> diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
> index 63ed3b7..c0c358c 100644
> --- a/drivers/video/metronomefb.c
> +++ b/drivers/video/metronomefb.c
> @@ -628,12 +628,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
> /* we need to add a spare page because our csum caching scheme walks
> * to the end of the page */
> videomemorysize = PAGE_SIZE + (fw * fh);
> - videomemory = vmalloc(videomemorysize);
> + videomemory = vzalloc(videomemorysize);
> if (!videomemory)
> goto err_fb_rel;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info->screen_base = (char __force __iomem *)videomemory;
> info->fbops = &metronomefb_ops;
>
> diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
> index 428d273..81fcaea 100644
> --- a/drivers/video/xen-fbfront.c
> +++ b/drivers/video/xen-fbfront.c
> @@ -395,10 +395,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
> spin_lock_init(&info->dirty_lock);
> spin_lock_init(&info->resize_lock);
>
> - info->fb = vmalloc(fb_size);
> + info->fb = vzalloc(fb_size);
> if (info->fb == NULL)
> goto error_nomem;
> - memset(info->fb, 0, fb_size);
>
> info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
>
> --
> 1.7.3.1.g432b3.dirty
^ permalink raw reply
* [PATCH 9/9] do not use macv[tap/lan] interfaces as ports
From: Jens Osterkamp @ 2010-11-08 16:12 UTC (permalink / raw)
To: e1000-eedc, virtualization, evb; +Cc: chrisw, Jens Osterkamp
In-Reply-To: <1289232720-27443-1-git-send-email-jens@linux.vnet.ibm.com>
At startup lldpad walks through all network interfaces in the system and
creates internal data structures for them. Some interfaces as e.g. vlan
and wlan are skipped in the walkthrough, some have to be treated special
(e.g. bond devices).
This patch adds macvtap and macvlan interfaces to the list of devices that
are skipped as we do not want to send out EVB/ECP frames on them.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
---
config.c | 2 +
include/lldp_util.h | 1 +
lldp_util.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/config.c b/config.c
index 26afe3b..fdb63f7 100644
--- a/config.c
+++ b/config.c
@@ -365,6 +365,8 @@ void init_ports(void)
p->if_name);
} else if (is_vlan(p->if_name)) {
;
+ } else if (is_macvtap(p->if_name)) {
+ ;
} else if (is_bridge(p->if_name)) {
; /* ignore bridge device */
} else if (check_link_status(p->if_name)) {
diff --git a/include/lldp_util.h b/include/lldp_util.h
index 3353067..ef2c562 100644
--- a/include/lldp_util.h
+++ b/include/lldp_util.h
@@ -40,6 +40,7 @@ int is_bridge(const char *ifname);
int is_vlan(const char *ifname);
int is_vlan_capable(const char *ifname);
int is_wlan(const char *ifname);
+int is_macvtap(const char *ifname);
int is_valid_mac(const u8 *mac);
int is_san_mac(u8 *addr);
int is_ether(const char *ifname);
diff --git a/lldp_util.c b/lldp_util.c
index f39fe6b..40db741 100644
--- a/lldp_util.c
+++ b/lldp_util.c
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_arp.h>
+#include <netlink/msg.h>
#include <arpa/inet.h>
#include <linux/if.h>
#include <linux/if_bonding.h>
@@ -42,6 +43,7 @@
#include <linux/wireless.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
+#include <linux/rtnetlink.h>
#include <dirent.h>
#include "lldp.h"
#include "lldp_util.h"
@@ -57,6 +59,8 @@ int is_valid_lldp_device(const char *device_name)
return 0;
if (is_bridge(device_name))
return 0;
+ if (is_macvtap(device_name))
+ return 0;
return 1;
}
@@ -534,6 +538,92 @@ int is_wlan(const char *ifname)
return rc;
}
+#define NLMSG_SIZE 1024
+
+static struct nla_policy ifla_info_policy[IFLA_INFO_MAX + 1] =
+{
+ [IFLA_INFO_KIND] = { .type = NLA_STRING},
+ [IFLA_INFO_DATA] = { .type = NLA_NESTED },
+};
+
+int is_macvtap(const char *ifname)
+{
+ int ret, s;
+ struct nlmsghdr *nlh;
+ struct ifinfomsg *ifinfo;
+ struct nlattr *tb[IFLA_MAX+1],
+ *tb2[IFLA_INFO_MAX+1];
+
+ s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
+
+ if (s < 0) {
+ goto out;
+ }
+
+ nlh = malloc(NLMSG_SIZE);
+ memset(nlh, 0, NLMSG_SIZE);
+
+ if (!nlh) {
+ goto out;
+ }
+
+ nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+ nlh->nlmsg_type = RTM_GETLINK;
+ nlh->nlmsg_flags = NLM_F_REQUEST;
+
+ ifinfo = NLMSG_DATA(nlh);
+ ifinfo->ifi_family = AF_UNSPEC;
+ ifinfo->ifi_index = get_ifidx(ifname);
+
+ ret = send(s, nlh, nlh->nlmsg_len, 0);
+
+ if (ret < 0) {
+ goto out_free;
+ }
+
+ memset(nlh, 0, NLMSG_SIZE);
+
+ do {
+ ret = recv(s, (void *) nlh, NLMSG_SIZE, MSG_DONTWAIT);
+ } while ((ret < 0) && errno == EINTR);
+
+ if (nlmsg_parse(nlh, sizeof(struct ifinfomsg),
+ (struct nlattr **)&tb, IFLA_MAX, NULL)) {
+ goto out_free;
+ }
+
+ if (tb[IFLA_IFNAME]) {
+ ifname = (char *)RTA_DATA(tb[IFLA_IFNAME]);
+ } else {
+ ifinfo = (struct ifinfomsg *)NLMSG_DATA(nlh);
+ }
+
+ if (tb[IFLA_LINKINFO]) {
+ if (nla_parse_nested(tb2, IFLA_INFO_MAX, tb[IFLA_LINKINFO],
+ ifla_info_policy)) {
+ goto out_free;
+ }
+
+ if (tb2[IFLA_INFO_KIND]) {
+ char *kind = (char*)(RTA_DATA(tb2[IFLA_INFO_KIND]));
+ if (!(strcmp("macvtap", kind) && strcmp("macvlan", kind))) {
+ free(nlh);
+ close(s);
+ return true;
+ }
+ }
+
+ } else {
+ goto out_free;
+ }
+
+out_free:
+ free(nlh);
+out:
+ close(s);
+ return false;
+}
+
int is_router(const char *ifname)
{
int rc = 0;
--
1.7.1
^ permalink raw reply related
* [PATCH 8/9] lldpad support for libvirt netlink message
From: Jens Osterkamp @ 2010-11-08 16:11 UTC (permalink / raw)
To: e1000-eedc, virtualization, evb
Cc: chrisw, Gerhard Stenzel, Stefan Berger, Jens Osterkamp
In-Reply-To: <1289232720-27443-1-git-send-email-jens@linux.vnet.ibm.com>
This code receives a IEEE 802.1Qbg virtual station instance from libvirt in
a SETLINK message. The parsed VSI is then handed over to VDP for processing.
The VDP state machine processes the VSI while libvirt polls the result using
GETLINK.
Requires at least Linux kernel 2.6.35-rc1.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: Gerhard Stenzel <gstenzel@linux.vnet.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
event_iface.c | 600 ++++++++++++++++++++++++++++++++++++++++++++++++-
include/event_iface.h | 1 +
include/lldp_vdp.h | 2 +
lldp_vdp.c | 2 +-
lldpad.c | 10 +
5 files changed, 604 insertions(+), 11 deletions(-)
diff --git a/event_iface.c b/event_iface.c
index 439e4d0..00ac3b1 100644
--- a/event_iface.c
+++ b/event_iface.c
@@ -3,6 +3,13 @@
LLDP Agent Daemon (LLDPAD) Software
Copyright(c) 2007-2010 Intel Corporation.
+ implementation of libvirt netlink interface
+ (c) Copyright IBM Corp. 2010
+
+ Author(s): Jens Osterkamp <jens@linux.vnet.ibm.com>
+ Stefan Berger <stefanb@linux.vnet.ibm.com>
+ Gerhard Stenzel <gstenzel@linux.vnet.ibm.com>
+
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
@@ -31,12 +38,16 @@
#include <sys/socket.h>
#include <linux/rtnetlink.h>
#include <linux/if.h>
+#include <linux/if_link.h>
#include <linux/if_vlan.h>
#include <linux/sockios.h>
#include <syslog.h>
#include <unistd.h>
+#include <linux/netlink.h>
+#include <netlink/msg.h>
#include "lldpad.h"
#include "lldp_mod.h"
+#include "lldp_vdp.h"
#include "common.h"
#include "eloop.h"
#include "drv_cfg.h"
@@ -47,6 +58,7 @@
#include "lldp/l2_packet.h"
#include "config.h"
#include "lldp/states.h"
+#include "messages.h"
static void event_if_decode_rta(int type, struct rtattr *rta);
@@ -55,6 +67,32 @@ static void event_if_decode_rta(int type, struct rtattr *rta);
static char *device_name = NULL;
static int link_status = 0;
+static struct nla_policy ifla_vf_policy[IFLA_VF_MAX + 1] =
+{
+ [IFLA_VF_MAC] = { .minlen = sizeof(struct ifla_vf_mac),
+ .maxlen = sizeof(struct ifla_vf_mac)},
+ [IFLA_VF_VLAN] = { .minlen = sizeof(struct ifla_vf_vlan),
+ .maxlen = sizeof(struct ifla_vf_vlan)},
+};
+
+static struct nla_policy ifla_vf_ports_policy[IFLA_VF_PORT_MAX + 1] =
+{
+ [IFLA_VF_PORT] = { .type = NLA_NESTED },
+};
+
+static struct nla_policy ifla_port_policy[IFLA_PORT_MAX + 1] =
+{
+ [IFLA_PORT_VF] = { .type = NLA_U32 },
+ [IFLA_PORT_PROFILE] = { .type = NLA_STRING },
+ [IFLA_PORT_VSI_TYPE] = { .minlen = sizeof(struct ifla_port_vsi) },
+ [IFLA_PORT_INSTANCE_UUID] = { .minlen = PORT_UUID_MAX,
+ .maxlen = PORT_UUID_MAX, },
+ [IFLA_PORT_HOST_UUID] = { .minlen = PORT_UUID_MAX,
+ .maxlen = PORT_UUID_MAX, },
+ [IFLA_PORT_REQUEST] = { .type = NLA_U8 },
+ [IFLA_PORT_RESPONSE] = { .type = NLA_U16 },
+};
+
static void event_if_decode_rta(int type, struct rtattr *rta)
{
@@ -220,15 +258,517 @@ static void event_if_decode_nlmsg(int route_type, void *data, int len)
}
}
-
static void event_if_process_recvmsg(struct nlmsghdr *nlmsg)
{
-
- /* print out details */
+ LLDPAD_DBG("%s:%s: nlmsg_type: %d", __FILE__, __FUNCTION__, nlmsg->nlmsg_type);
event_if_decode_nlmsg(nlmsg->nlmsg_type, NLMSG_DATA(nlmsg),
NLMSG_PAYLOAD(nlmsg, 0));
}
+static int event_if_parse_getmsg(struct nlmsghdr *nlh, int *ifindex,
+ char *ifname)
+{
+ struct nlattr *tb[IFLA_MAX+1];
+ struct ifinfomsg *ifinfo;
+
+ if (nlmsg_parse(nlh, sizeof(struct ifinfomsg),
+ (struct nlattr **)&tb, IFLA_MAX, NULL)) {
+ LLDPAD_ERR("Error parsing GETLINK request...");
+ return -EINVAL;
+ }
+
+ if (tb[IFLA_IFNAME]) {
+ ifname = (char *)RTA_DATA(tb[IFLA_IFNAME]);
+ LLDPAD_DBG("IFLA_IFNAME=%s", ifname);
+ } else {
+ ifinfo = (struct ifinfomsg *)NLMSG_DATA(nlh);
+ *ifindex = ifinfo->ifi_index;
+ LLDPAD_DBG("interface index: %d", ifinfo->ifi_index);
+ }
+
+ return 0;
+}
+
+static int event_if_parse_setmsg(struct nlmsghdr *nlh)
+{
+ struct nlattr *tb[IFLA_MAX+1],
+ *tb3[IFLA_PORT_MAX+1],
+ *tb_vfinfo[IFLA_VF_MAX+1],
+ *tb_vfinfo_list;
+ struct vsi_profile *profile, *p;
+ struct ifinfomsg *ifinfo;
+ char *ifname;
+ int rem;
+
+ profile = malloc(sizeof(struct vsi_profile));
+ if (!profile)
+ return -ENOMEM;
+ memset(profile, 0, sizeof(struct vsi_profile));
+
+ if (nlmsg_parse(nlh, sizeof(struct ifinfomsg),
+ (struct nlattr **)&tb, IFLA_MAX, NULL)) {
+ LLDPAD_ERR("Error parsing request...\n");
+ return -EINVAL;
+ }
+
+ LLDPAD_DBG("%s(%d): nlmsg_len %i", __FILE__, __LINE__, nlh->nlmsg_len);
+
+ if (tb[IFLA_IFNAME]) {
+ ifname = (char *)RTA_DATA(tb[IFLA_IFNAME]);
+ LLDPAD_DBG("IFLA_IFNAME=%s", ifname);
+ } else {
+ ifinfo = (struct ifinfomsg *)NLMSG_DATA(nlh);
+ LLDPAD_DBG("interface index: %d", ifinfo->ifi_index);
+ }
+
+ if (!tb[IFLA_VFINFO_LIST]) {
+ LLDPAD_ERR("IFLA_VFINFO_LIST missing.");
+ return -EINVAL;
+ } else {
+ LLDPAD_DBG("FOUND IFLA_VFINFO_LIST!");
+ }
+
+ nla_for_each_nested(tb_vfinfo_list, tb[IFLA_VFINFO_LIST], rem) {
+ if (nla_type(tb_vfinfo_list) != IFLA_VF_INFO) {
+ LLDPAD_ERR("nested parsing of IFLA_VFINFO_LIST failed.");
+ return -EINVAL;
+ }
+
+ if (nla_parse_nested(tb_vfinfo, IFLA_VF_MAX, tb_vfinfo_list,
+ ifla_vf_policy)) {
+ LLDPAD_ERR("nested parsing of IFLA_VF_INFO failed.");
+ return -EINVAL;
+ }
+ }
+
+ if (tb_vfinfo[IFLA_VF_MAC]) {
+ struct ifla_vf_mac *mac = RTA_DATA(tb_vfinfo[IFLA_VF_MAC]);
+ u8 *m = mac->mac;
+ LLDPAD_DBG("IFLA_VF_MAC=%2x:%2x:%2x:%2x:%2x:%2x",
+ m[0], m[1], m[2], m[3], m[4], m[5]);
+ memcpy(&profile->mac, m, ETH_ALEN);
+ }
+
+ if (tb_vfinfo[IFLA_VF_VLAN]) {
+ struct ifla_vf_vlan *vlan = RTA_DATA(tb_vfinfo[IFLA_VF_VLAN]);
+ LLDPAD_DBG("IFLA_VF_VLAN=%d", vlan->vlan);
+ profile->vlan = (u16) vlan->vlan;
+ }
+
+ if (tb[IFLA_VF_PORTS]) {
+ struct nlattr *tb_vf_ports;
+
+ LLDPAD_DBG("FOUND IFLA_VF_PORTS");
+
+ nla_for_each_nested(tb_vf_ports, tb[IFLA_VF_PORTS], rem) {
+
+ LLDPAD_DBG("ITERATING");
+
+ if (nla_type(tb_vf_ports) != IFLA_VF_PORT) {
+ LLDPAD_DBG("not a IFLA_VF_PORT. skipping");
+ continue;
+ }
+
+ if (nla_parse_nested(tb3, IFLA_PORT_MAX, tb_vf_ports,
+ ifla_port_policy)) {
+ LLDPAD_ERR("nested parsing on level 2 failed.");
+ return -EINVAL;
+ }
+
+ if (tb3[IFLA_PORT_VF]) {
+ LLDPAD_DBG("IFLA_PORT_VF=%d", *(uint32_t*)(RTA_DATA(tb3[IFLA_PORT_VF])));
+ }
+
+ if (tb3[IFLA_PORT_PROFILE]) {
+ LLDPAD_DBG("IFLA_PORT_PROFILE=%s", (char *)RTA_DATA(tb3[IFLA_PORT_PROFILE]));
+ }
+
+ if (tb3[IFLA_PORT_VSI_TYPE]) {
+ struct ifla_port_vsi *pvsi;
+ int tid = 0;
+
+ pvsi = (struct ifla_port_vsi*)RTA_DATA(tb3[IFLA_PORT_VSI_TYPE]);
+ tid = pvsi->vsi_type_id[2] << 16 |
+ pvsi->vsi_type_id[1] << 8 |
+ pvsi->vsi_type_id[0];
+
+ LLDPAD_DBG("mgr_id : %d", pvsi->vsi_mgr_id);
+ LLDPAD_DBG("type_id : %d", tid);
+ LLDPAD_DBG("type_version : %d", pvsi->vsi_type_version);
+
+ profile->mgrid = pvsi->vsi_mgr_id;
+ profile->id = tid;
+ profile->version = pvsi->vsi_type_version;
+ }
+
+ if (tb3[IFLA_PORT_INSTANCE_UUID]) {
+ int i;
+ unsigned char *uuid;
+ uuid = (unsigned char *)RTA_DATA(tb3[IFLA_PORT_INSTANCE_UUID]);
+
+ char instance[INSTANCE_STRLEN+2];
+ instance2str(uuid, instance, sizeof(instance));
+ LLDPAD_DBG("IFLA_PORT_INSTANCE_UUID=%s", &instance[0]);
+
+ memcpy(&profile->instance,
+ RTA_DATA(tb3[IFLA_PORT_INSTANCE_UUID]), 16);
+ }
+
+ if (tb3[IFLA_PORT_REQUEST]) {
+ LLDPAD_DBG("IFLA_PORT_REQUEST=%d",
+ *(uint8_t*)RTA_DATA(tb3[IFLA_PORT_REQUEST]));
+ profile->mode = *(uint8_t*)RTA_DATA(tb3[IFLA_PORT_REQUEST]);
+ }
+
+ if (tb3[IFLA_PORT_RESPONSE]) {
+ LLDPAD_DBG("IFLA_PORT_RESPONSE=%d",
+ *(uint16_t*)RTA_DATA(tb3[IFLA_PORT_RESPONSE]));
+ profile->response = *(uint16_t*)RTA_DATA(tb3[IFLA_PORT_RESPONSE]);
+ }
+ }
+ }
+
+ if (ifname) {
+ struct port *port = port_find_by_name(ifname);
+
+ if (port) {
+ profile->port = port;
+ } else {
+ LLDPAD_ERR("%s(%i): Could not find port for %s", __func__,
+ __LINE__, ifname);
+ return -EEXIST;
+ }
+ }
+
+ p = vdp_add_profile(profile);
+
+ if (!p) {
+ free(profile);
+ return -EINVAL;
+ }
+
+ vdp_somethingChangedLocal(profile, VDP_PROFILE_REQ);
+ vdp_vsi_sm_station(p);
+
+ return 0;
+}
+
+static void event_if_parseResponseMsg(struct nlmsghdr *nlh)
+{
+ struct nlattr *tb[IFLA_MAX+1],
+ *tb2[IFLA_VF_PORT_MAX + 1],
+ *tb3[IFLA_PORT_MAX+1];
+
+ if (nlmsg_parse(nlh, sizeof(struct ifinfomsg),
+ (struct nlattr **)&tb, IFLA_MAX, NULL)) {
+ LLDPAD_ERR("Error parsing netlink response...");
+ return;
+ }
+
+ if (tb[IFLA_IFNAME]) {
+ LLDPAD_DBG("IFLA_IFNAME=%s", (char *)RTA_DATA(tb[IFLA_IFNAME]));
+ } else {
+ struct ifinfomsg *ifinfo = (struct ifinfomsg *)NLMSG_DATA(nlh);
+ LLDPAD_DBG("interface index: %d", ifinfo->ifi_index);
+ }
+
+ if (tb[IFLA_VF_PORTS]) {
+ if (nla_parse_nested(tb2, IFLA_VF_PORT_MAX, tb[IFLA_VF_PORTS],
+ ifla_vf_ports_policy)) {
+ LLDPAD_ERR("nested parsing on level 1 failed.");
+ return;
+ }
+
+ if (tb2[IFLA_VF_PORT]) {
+ if (nla_parse_nested(tb3, IFLA_PORT_MAX, tb2[IFLA_VF_PORT],
+ ifla_port_policy)) {
+ LLDPAD_ERR("nested parsing on level 2 failed.");
+ return;
+ }
+
+ if (tb3[IFLA_PORT_VF]) {
+ LLDPAD_DBG("IFLA_PORT_VF=%d", *(uint32_t*)(RTA_DATA(tb3[IFLA_PORT_VF])));
+ }
+
+ if (tb3[IFLA_PORT_PROFILE]) {
+ LLDPAD_DBG("IFLA_PORT_PROFILE=%s", (char *)RTA_DATA(tb3[IFLA_PORT_PROFILE]));
+ }
+
+ if (tb3[IFLA_PORT_VSI_TYPE]) {
+ struct ifla_port_vsi *pvsi;
+ int tid = 0;
+ pvsi = (struct ifla_port_vsi*)RTA_DATA(tb3[IFLA_PORT_VSI_TYPE]);
+ tid = pvsi->vsi_type_id[2] << 16 |
+ pvsi->vsi_type_id[1] << 8 |
+ pvsi->vsi_type_id[0];
+ LLDPAD_DBG("mgr_id : %d"
+ "type_id : %d"
+ "type_version : %d",
+ pvsi->vsi_mgr_id,
+ tid,
+ pvsi->vsi_type_version);
+ }
+
+ if (tb3[IFLA_PORT_INSTANCE_UUID]) {
+ int i;
+ unsigned char *uuid;
+ uuid = (unsigned char *)RTA_DATA(tb3[IFLA_PORT_INSTANCE_UUID]);
+
+ char instance[INSTANCE_STRLEN+2];
+ instance2str(uuid, instance, sizeof(instance));
+ LLDPAD_DBG("IFLA_PORT_INSTANCE_UUID=%s", &instance[0]);
+ }
+
+ if (tb3[IFLA_PORT_REQUEST]) {
+ LLDPAD_DBG("IFLA_PORT_REQUEST=%d",
+ *(uint8_t*)RTA_DATA(tb3[IFLA_PORT_REQUEST]));
+ }
+
+ if (tb3[IFLA_PORT_RESPONSE]) {
+ LLDPAD_DBG("IFLA_PORT_RESPONSE=%d",
+ *(uint16_t*)RTA_DATA(tb3[IFLA_PORT_RESPONSE]));
+ }
+ }
+ }
+}
+
+struct nl_msg *event_if_constructResponse(struct nlmsghdr *nlh, int ifindex)
+{
+ struct nl_msg *nl_msg;
+ struct nlattr *vf_ports = NULL, *vf_port;
+ struct ifinfomsg ifinfo;
+ struct vdp_data *vd;
+ uint32_t pid = nlh->nlmsg_pid;
+ uint32_t seq = nlh->nlmsg_seq;
+ char *ifname = malloc(IFNAMSIZ);
+ struct vsi_profile *p;
+
+ nl_msg = nlmsg_alloc();
+
+ if (!nl_msg) {
+ LLDPAD_ERR("%s(%i): Unable to allocate netlink message !", __func__, __LINE__);
+ return NULL;
+ }
+
+ if (!if_indextoname(ifindex, ifname)) {
+ LLDPAD_ERR("%s(%i): No name found for interface with index %i !", __func__, __LINE__,
+ ifindex);
+ }
+
+ vd = vdp_data(ifname);
+ if (!vd) {
+ LLDPAD_ERR("%s(%i): Could not find vdp_data for %s !", __func__, __LINE__,
+ ifname);
+ return NULL;
+ }
+
+ free(ifname);
+
+ if (nlmsg_put(nl_msg, pid, seq, NLMSG_DONE, 0, 0) == NULL)
+ goto err_exit;
+
+ ifinfo.ifi_index = ifindex;
+
+ if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) < 0)
+ goto err_exit;
+
+ vf_ports = nla_nest_start(nl_msg, IFLA_VF_PORTS);
+
+ if (!vf_ports)
+ goto err_exit;
+
+ /* loop over all existing profiles on this interface and
+ * put them into the nested IFLA_VF_PORT structure */
+ LIST_FOREACH(p, &vd->profile_head, profile) {
+ if (p) {
+ vdp_print_profile(p);
+
+ vf_port = nla_nest_start(nl_msg, IFLA_VF_PORT);
+
+ if (!vf_port)
+ goto err_exit;
+
+ if (nla_put(nl_msg, IFLA_PORT_INSTANCE_UUID, 16, p->instance) < 0)
+ goto err_exit;
+
+ if (nla_put_u32(nl_msg, IFLA_PORT_VF, PORT_SELF_VF) < 0)
+ goto err_exit;
+
+ if (p->mode == p->state) {
+ if (nla_put_u16(nl_msg, IFLA_PORT_RESPONSE,
+ PORT_VDP_RESPONSE_SUCCESS) < 0)
+ goto err_exit;
+ } else {
+ if (p->state == VSI_EXIT) {
+ if (p->response > PORT_VDP_RESPONSE_SUCCESS) {
+ if (nla_put_u16(nl_msg, IFLA_PORT_RESPONSE, p->response) < 0)
+ goto err_exit;
+ } else {
+ if (nla_put_u16(nl_msg, IFLA_PORT_RESPONSE,
+ PORT_VDP_RESPONSE_INSUFFICIENT_RESOURCES) < 0)
+ goto err_exit;
+ }
+ }
+ }
+
+ nla_nest_end(nl_msg, vf_port);
+ }
+ }
+
+ if (vf_ports)
+ nla_nest_end(nl_msg, vf_ports);
+
+ return nl_msg;
+
+err_exit:
+ nlmsg_free(nl_msg);
+
+ return NULL;
+}
+
+struct nl_msg *event_if_simpleResponse(uint32_t pid, uint32_t seq, int err)
+{
+ struct nl_msg *nl_msg = nlmsg_alloc();
+ struct nlmsgerr nlmsgerr;
+
+ memset(&nlmsgerr, 0x0, sizeof(nlmsgerr));
+
+ nlmsgerr.error = err;
+ LLDPAD_DBG("RESPONSE error code: %d",err);
+
+ if (nlmsg_put(nl_msg, pid, seq, NLMSG_ERROR, 0, 0) == NULL)
+ goto err_exit;
+
+ if (nlmsg_append(nl_msg, &nlmsgerr, sizeof(nlmsgerr), NLMSG_ALIGNTO) < 0)
+ goto err_exit;
+
+ return nl_msg;
+
+err_exit:
+ nlmsg_free(nl_msg);
+
+ return NULL;
+}
+
+static void event_iface_receive_user_space(int sock, void *eloop_ctx, void *sock_ctx)
+{
+ struct nlmsghdr *nlh, *nlh2;
+ struct nl_msg *nl_msg;
+ struct msghdr msg;
+ struct sockaddr_nl dest_addr;
+ struct iovec iov;
+ int result;
+ int err;
+ int ifindex = 0;
+ char *ifname = NULL;
+
+ nlh = (struct nlmsghdr *)calloc(1,
+ NLMSG_SPACE(MAX_PAYLOAD));
+ if (!nlh) {
+ LLDPAD_ERR("%s(%i): could not allocate nlh !", __func__,
+ __LINE__);
+ return;
+ }
+ memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));
+
+ memset(&dest_addr, 0, sizeof(dest_addr));
+ iov.iov_base = (void *)nlh;
+ iov.iov_len = NLMSG_SPACE(MAX_PAYLOAD);
+ msg.msg_name = (void *)&dest_addr;
+ msg.msg_namelen = sizeof(dest_addr);
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = NULL;
+ msg.msg_controllen = 0;
+ msg.msg_flags = 0;
+
+ LLDPAD_DBG("Waiting for message");
+ result = recvmsg(sock, &msg, MSG_DONTWAIT);
+
+ LLDPAD_DBG("%s(%i): ", __func__, __LINE__);
+ LLDPAD_DBG("recvmsg received %d bytes", result);
+
+ if(result < 0) {
+ LLDPAD_ERR("Error receiving from netlink socket : %s", strerror(errno));
+ }
+
+ LLDPAD_DBG("dest_addr.nl_pid: %d", dest_addr.nl_pid);
+ LLDPAD_DBG("nlh.nl_pid: %d", nlh->nlmsg_pid);
+ LLDPAD_DBG("nlh_type: %d", nlh->nlmsg_type);
+ LLDPAD_DBG("nlh_seq: 0x%x", nlh->nlmsg_seq);
+ LLDPAD_DBG("nlh_len: 0x%x", nlh->nlmsg_len);
+
+ switch (nlh->nlmsg_type) {
+ case RTM_SETLINK:
+ LLDPAD_DBG("RTM_SETLINK");
+
+ err = event_if_parse_setmsg(nlh);
+
+ /* send simple response wether profile was accepted
+ * or not */
+ nl_msg = event_if_simpleResponse(nlh->nlmsg_pid,
+ nlh->nlmsg_seq,
+ err);
+ nlh2 = nlmsg_hdr(nl_msg);
+ break;
+ case RTM_GETLINK:
+ LLDPAD_DBG("RTM_GETLINK");
+
+ err = event_if_parse_getmsg(nlh, &ifindex, ifname);
+
+ if (err) {
+ nl_msg = event_if_simpleResponse(nlh->nlmsg_pid,
+ nlh->nlmsg_seq,
+ err);
+ } else if (ifname) {
+ ifindex = if_nametoindex(ifname);
+ LLDPAD_DBG("%s(%i): ifname %s (%d)", __func__,
+ __LINE__, ifname, ifindex);
+ } else {
+ LLDPAD_DBG("%s(%i): ifindex %i", __func__,
+ __LINE__, ifindex);
+ }
+
+ nl_msg = event_if_constructResponse(nlh, ifindex);
+
+ if (!nl_msg) {
+ LLDPAD_ERR("%s(%i): Unable to construct response !",
+ __func__, __LINE__);
+ goto out_err;
+ }
+
+ nlh2 = nlmsg_hdr(nl_msg);
+
+ LLDPAD_DBG("RESPONSE:");
+
+ event_if_parseResponseMsg(nlh2);
+
+ break;
+ }
+
+ iov.iov_base = (void*)nlh2;
+ iov.iov_len = nlh2->nlmsg_len;
+
+ msg.msg_name = (void *)&dest_addr;
+ msg.msg_namelen = sizeof(dest_addr);
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+
+ result = sendmsg(sock, &msg, 0);
+
+ if (result < 0) {
+ LLDPAD_ERR("Error sending on netlink socket (%s) !", strerror(errno));
+ } else {
+ LLDPAD_DBG("Sent %d bytes !",result);
+ }
+
+out_err:
+ free(nlh);
+ nlmsg_free(nl_msg);
+
+ return;
+}
+
static void event_iface_receive(int sock, void *eloop_ctx, void *sock_ctx)
{
struct nlmsghdr *nlh;
@@ -236,12 +776,14 @@ static void event_iface_receive(int sock, void *eloop_ctx, void *sock_ctx)
char buf[MAX_MSG_SIZE];
socklen_t fromlen = sizeof(dest_addr);
int result;
-
+
result = recvfrom(sock, buf, sizeof(buf), MSG_DONTWAIT,
(struct sockaddr *) &dest_addr, &fromlen);
+ LLDPAD_DBG("%s:%s: result from receive: %d", __FILE__, __FUNCTION__, result);
+
if (result < 0) {
- perror("recvfrom(Event interface)");
+ LLDPAD_ERR("recvfrom(event interface): %s", strerror(errno));
if ((errno == ENOBUFS) || (errno == EAGAIN))
eloop_register_timeout(INI_TIMER, 0, scan_port,
NULL, NULL);
@@ -250,10 +792,15 @@ static void event_iface_receive(int sock, void *eloop_ctx, void *sock_ctx)
TRACE("PRINT BUF info.\n")
- device_name = NULL;
- link_status = IF_OPER_UNKNOWN;
- nlh = (struct nlmsghdr *)buf;
- event_if_process_recvmsg(nlh);
+ /* Separate handler for kernel messages from userspace messages*/
+ LLDPAD_DBG("%s:%s: dest_addr.nl_pid: %d", __FILE__, __FUNCTION__, dest_addr.nl_pid);
+
+ if (dest_addr.nl_pid == 0) {
+ device_name = NULL;
+ link_status = IF_OPER_UNKNOWN;
+ nlh = (struct nlmsghdr *)buf;
+ event_if_process_recvmsg(nlh);
+ }
}
int event_iface_init()
@@ -261,7 +808,7 @@ int event_iface_init()
int fd;
int rcv_size = MAX_MSG_SIZE;
struct sockaddr_nl snl;
-
+ fprintf(stderr, "%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (fd < 0)
@@ -282,6 +829,39 @@ int event_iface_init()
}
eloop_register_read_sock(fd, event_iface_receive, NULL, NULL);
+
+ return 0;
+}
+
+int event_iface_init_user_space()
+{
+ int fd;
+ int rcv_size = MAX_MSG_SIZE;
+ struct sockaddr_nl snl;
+
+ fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+
+ if (fd < 0)
+ return fd;
+
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcv_size, sizeof(int)) < 0) {
+ close(fd);
+ return -EIO;
+ }
+
+ memset((void *)&snl, 0, sizeof(struct sockaddr_nl));
+ snl.nl_family = AF_NETLINK;
+ snl.nl_pid = getpid(); /* self pid */
+ snl.nl_groups = 0;
+
+ if (bind(fd, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)) < 0) {
+ close(fd);
+ LLDPAD_ERR("Error binding to netlink socket (%s) !", strerror(errno));
+ return -EIO;
+ }
+
+ eloop_register_read_sock(fd, event_iface_receive_user_space, NULL, NULL);
+
return 0;
}
diff --git a/include/event_iface.h b/include/event_iface.h
index b2c93f0..d80158d 100644
--- a/include/event_iface.h
+++ b/include/event_iface.h
@@ -29,6 +29,7 @@
#define _EVENT_IFACE_H_
int event_iface_init(void);
+int event_iface_init_user_space(void);
int event_iface_deinit(void);
int oper_add_device(char *device_name);
diff --git a/include/lldp_vdp.h b/include/lldp_vdp.h
index b97d8c0..53f814c 100644
--- a/include/lldp_vdp.h
+++ b/include/lldp_vdp.h
@@ -134,6 +134,8 @@ struct vdp_data *vdp_data(char *ifname);
struct packed_tlv *vdp_gettlv(struct vdp_data *vd, struct vsi_profile *profile);
void vdp_vsi_sm_station(struct vsi_profile *profile);
struct vsi_profile *vdp_add_profile(struct vsi_profile *profile);
+void vdp_somethingChangedLocal(struct vsi_profile *profile, int mode);
+void vdp_print_profile(struct vsi_profile *profile);
#define MAC_ADDR_STRLEN 18
#define INSTANCE_STRLEN 32
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 01bcbf7..3a507e9 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -105,7 +105,7 @@ static void vdp_free_data(struct vdp_user_data *ud)
* prints the contents of a profile first to a string using the PRINT_PROFILE
* macro, and then to the screen. Used for debug purposes.
*/
-static inline void vdp_print_profile(struct vsi_profile *profile)
+void vdp_print_profile(struct vsi_profile *profile)
{
LLDPAD_DBG("profile:\n");
diff --git a/lldpad.c b/lldpad.c
index c0938af..69faa29 100644
--- a/lldpad.c
+++ b/lldpad.c
@@ -374,6 +374,16 @@ int main(int argc, char *argv[])
exit(1);
}
+ /* setup event netlink interface for user space processes.
+ * This needs to be setup first to ensure it gets lldpads
+ * pid as netlink address.
+ */
+ if (event_iface_init_user_space() < 0) {
+ log_message(MSG_ERR_SERVICE_START_FAILURE,
+ "%s", "failed to register user space event interface");
+ exit(1);
+ }
+
init_modules("");
--
1.7.1
^ permalink raw reply related
* [PATCH 7/9] use connect instead of bind
From: Jens Osterkamp @ 2010-11-08 16:11 UTC (permalink / raw)
To: e1000-eedc, virtualization, evb; +Cc: chrisw, Gerhard Stenzel, Jens Osterkamp
In-Reply-To: <1289232720-27443-1-git-send-email-jens@linux.vnet.ibm.com>
modifies the setup of the netlink socket in drv_cfg.c to use pid 0 instead
of the processes pid.
Also replaces bind with connect to allow the reception of netlink messages
from libvirt.
Preparation patch for communication between libvirt and lldpad.
Signed-off-by: Gerhard Stenzel <gstenzel@linux.vnet.ibm.com>
---
drv_cfg.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drv_cfg.c b/drv_cfg.c
index 6c02555..23c11f3 100644
--- a/drv_cfg.c
+++ b/drv_cfg.c
@@ -71,9 +71,9 @@ static int init_socket(void)
memset((void *)&snl, 0, sizeof(struct sockaddr_nl));
snl.nl_family = AF_NETLINK;
- snl.nl_pid = getpid();
+ snl.nl_pid = 0;
- if (bind(sd, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)) < 0) {
+ if (connect(sd, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)) < 0) {
close(sd);
return -EIO;
}
@@ -195,6 +195,7 @@ static struct nlmsghdr *get_msg(unsigned int seq)
nlh = NULL;
break;
}
+ fprintf(stderr, "%s:%s: nlmsg_type: %d\n", __FILE__, __FUNCTION__, nlh->nlmsg_type);
if ((nlh->nlmsg_type == RTM_GETDCB ||
nlh->nlmsg_type == RTM_SETDCB) &&
nlh->nlmsg_seq == seq) {
--
1.7.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox