All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] vmbus: add support for dynamic device id's
@ 2016-10-17 19:29 Stephen Hemminger
  2016-10-17 19:31 ` [PATCH v2 2/3] uio-hv-generic: new userspace i/o driver for VMBus Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Stephen Hemminger @ 2016-10-17 19:29 UTC (permalink / raw)
  To: Greg KH, KY Srinivasan, Haiyang Zhang; +Cc: devel, linux-kernel

From: Stephen Hemminger <sthemmin@microsoft.com>

This patch adds sysfs interface to dynamically bind new UUID values
to existing VMBus device. This is useful for generic UIO driver to
act similar to uio_pci_generic.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
v2 - allow device driver to have empty id table, and fix bugs

 drivers/hv/vmbus_drv.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++---
 include/linux/hyperv.h |   6 ++
 2 files changed, 172 insertions(+), 8 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index a259e18..d8d34bf 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -45,6 +45,11 @@
 #include <linux/random.h>
 #include "hyperv_vmbus.h"
 
+struct vmbus_dynid {
+	struct list_head node;
+	struct hv_vmbus_device_id id;
+};
+
 static struct acpi_device  *hv_acpi_dev;
 
 static struct completion probe_event;
@@ -500,7 +505,7 @@ static ssize_t device_show(struct device *dev,
 static DEVICE_ATTR_RO(device);
 
 /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
-static struct attribute *vmbus_attrs[] = {
+static struct attribute *vmbus_dev_attrs[] = {
 	&dev_attr_id.attr,
 	&dev_attr_state.attr,
 	&dev_attr_monitor_id.attr,
@@ -528,7 +533,7 @@ static struct attribute *vmbus_attrs[] = {
 	&dev_attr_device.attr,
 	NULL,
 };
-ATTRIBUTE_GROUPS(vmbus);
+ATTRIBUTE_GROUPS(vmbus_dev);
 
 /*
  * vmbus_uevent - add uevent for our device
@@ -565,10 +570,29 @@ static inline bool is_null_guid(const uuid_le *guid)
  * Return a matching hv_vmbus_device_id pointer.
  * If there is no match, return NULL.
  */
-static const struct hv_vmbus_device_id *hv_vmbus_get_id(
-					const struct hv_vmbus_device_id *id,
+static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
 					const uuid_le *guid)
 {
+	const struct hv_vmbus_device_id *id = NULL;
+	struct vmbus_dynid *dynid;
+
+	/* Look at the dynamic ids first, before the static ones */
+	spin_lock(&drv->dynids.lock);
+	list_for_each_entry(dynid, &drv->dynids.list, node) {
+		if (!uuid_le_cmp(dynid->id.guid, *guid)) {
+			id = &dynid->id;
+			break;
+		}
+	}
+	spin_unlock(&drv->dynids.lock);
+
+	if (id)
+		return id;
+
+	id = drv->id_table;
+	if (id == NULL)
+		return NULL; /* empty device table */
+
 	for (; !is_null_guid(&id->guid); id++)
 		if (!uuid_le_cmp(id->guid, *guid))
 			return id;
@@ -576,6 +600,134 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(
 	return NULL;
 }
 
+/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */
+static int vmbus_add_dynid(struct hv_driver *drv, uuid_le *guid)
+{
+	struct vmbus_dynid *dynid;
+
+	dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
+	if (!dynid)
+		return -ENOMEM;
+
+	dynid->id.guid = *guid;
+
+	spin_lock(&drv->dynids.lock);
+	list_add_tail(&dynid->node, &drv->dynids.list);
+	spin_unlock(&drv->dynids.lock);
+
+	return driver_attach(&drv->driver);
+}
+
+static void vmbus_free_dynids(struct hv_driver *drv)
+{
+	struct vmbus_dynid *dynid, *n;
+
+	spin_lock(&drv->dynids.lock);
+	list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
+		list_del(&dynid->node);
+		kfree(dynid);
+	}
+	spin_unlock(&drv->dynids.lock);
+}
+
+/* Parse string of form: 1b4e28ba-2fa1-11d2-883f-b9a761bde3f */
+static int get_uuid_le(const char *str, uuid_le *uu)
+{
+	unsigned int b[16];
+	int i;
+
+	if (strlen(str) < 37)
+		return -1;
+
+	for (i = 0; i < 36; i++) {
+		switch (i) {
+		case 8: case 13: case 18: case 23:
+			if (str[i] != '-')
+				return -1;
+			break;
+		default:
+			if (!isxdigit(str[i]))
+				return -1;
+		}
+	}
+
+	/* unparse little endian output byte order */
+	if (sscanf(str,
+		   "%2x%2x%2x%2x-%2x%2x-%2x%2x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+		   &b[3], &b[2], &b[1], &b[0],
+		   &b[5], &b[4], &b[7], &b[6], &b[8], &b[9],
+		   &b[10], &b[11], &b[12], &b[13], &b[14], &b[15]) != 16)
+		return -1;
+
+	for (i = 0; i < 16; i++)
+		uu->b[i] = b[i];
+	return 0;
+}
+
+/*
+ * store_new_id - sysfs frontend to vmbus_add_dynid()
+ *
+ * Allow GUIDs to be added to an existing driver via sysfs.
+ */
+static ssize_t store_new_id(struct device_driver *driver, const char *buf,
+			    size_t count)
+{
+	struct hv_driver *drv = drv_to_hv_drv(driver);
+	uuid_le guid = NULL_UUID_LE;
+	ssize_t retval;
+
+	if (get_uuid_le(buf, &guid) != 0)
+		return -EINVAL;
+
+	if (hv_vmbus_get_id(drv, &guid))
+		return -EEXIST;
+
+	retval = vmbus_add_dynid(drv, &guid);
+	if (retval)
+		return retval;
+	return count;
+}
+static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
+
+/*
+ * store_remove_id - remove a PCI device ID from this driver
+ *
+ * Removes a dynamic pci device ID to this driver.
+ */
+static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
+			       size_t count)
+{
+	struct hv_driver *drv = drv_to_hv_drv(driver);
+	struct vmbus_dynid *dynid, *n;
+	uuid_le guid = NULL_UUID_LE;
+	size_t retval = -ENODEV;
+
+	if (get_uuid_le(buf, &guid))
+		return -EINVAL;
+
+	spin_lock(&drv->dynids.lock);
+	list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
+		struct hv_vmbus_device_id *id = &dynid->id;
+
+		if (!uuid_le_cmp(id->guid, guid)) {
+			list_del(&dynid->node);
+			kfree(dynid);
+			retval = count;
+			break;
+		}
+	}
+	spin_unlock(&drv->dynids.lock);
+
+	return retval;
+}
+static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
+
+static struct attribute *vmbus_drv_attrs[] = {
+	&driver_attr_new_id.attr,
+	&driver_attr_remove_id.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(vmbus_drv);
 
 
 /*
@@ -590,7 +742,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver)
 	if (is_hvsock_channel(hv_dev->channel))
 		return drv->hvsock;
 
-	if (hv_vmbus_get_id(drv->id_table, &hv_dev->dev_type))
+	if (hv_vmbus_get_id(drv, &hv_dev->dev_type))
 		return 1;
 
 	return 0;
@@ -607,7 +759,7 @@ static int vmbus_probe(struct device *child_device)
 	struct hv_device *dev = device_to_hv_device(child_device);
 	const struct hv_vmbus_device_id *dev_id;
 
-	dev_id = hv_vmbus_get_id(drv->id_table, &dev->dev_type);
+	dev_id = hv_vmbus_get_id(drv, &dev->dev_type);
 	if (drv->probe) {
 		ret = drv->probe(dev, dev_id);
 		if (ret != 0)
@@ -684,7 +836,8 @@ static struct bus_type  hv_bus = {
 	.remove =		vmbus_remove,
 	.probe =		vmbus_probe,
 	.uevent =		vmbus_uevent,
-	.dev_groups =		vmbus_groups,
+	.dev_groups =		vmbus_dev_groups,
+	.drv_groups =		vmbus_drv_groups,
 };
 
 struct onmessage_work_context {
@@ -905,6 +1058,9 @@ int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, c
 	hv_driver->driver.mod_name = mod_name;
 	hv_driver->driver.bus = &hv_bus;
 
+	spin_lock_init(&hv_driver->dynids.lock);
+	INIT_LIST_HEAD(&hv_driver->dynids.list);
+
 	ret = driver_register(&hv_driver->driver);
 
 	return ret;
@@ -923,8 +1079,10 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver)
 {
 	pr_info("unregistering driver %s\n", hv_driver->name);
 
-	if (!vmbus_exists())
+	if (!vmbus_exists()) {
 		driver_unregister(&hv_driver->driver);
+		vmbus_free_dynids(hv_driver);
+	}
 }
 EXPORT_SYMBOL_GPL(vmbus_driver_unregister);
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 6824556..737ac0d 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1119,6 +1119,12 @@ struct hv_driver {
 
 	struct device_driver driver;
 
+	/* dynamic device GUID's */
+	struct  {
+		spinlock_t lock;
+		struct list_head list;
+	} dynids;
+
 	int (*probe)(struct hv_device *, const struct hv_vmbus_device_id *);
 	int (*remove)(struct hv_device *);
 	void (*shutdown)(struct hv_device *);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] uio-hv-generic: new userspace i/o driver for VMBus
  2016-10-17 19:29 [PATCH v2 1/3] vmbus: add support for dynamic device id's Stephen Hemminger
@ 2016-10-17 19:31 ` Stephen Hemminger
  2016-10-17 19:33 ` [PATCH v2 3/3] doc: add documentation for uio-hv-generic Stephen Hemminger
  2016-11-10 15:59 ` [PATCH v2 1/3] vmbus: add support for dynamic device id's Greg KH
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2016-10-17 19:31 UTC (permalink / raw)
  To: Greg KH, KY Srinivasan, Haiyang Zhang; +Cc: devel, linux-kernel

From: Stephen Hemminger <sthemmin@microsoft.com>

This is a new driver to enable userspace networking on VMBus.
It is based largely on the similar driver that already exists
for PCI, and earlier work done by Brocade to support DPDK.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
v2 - put in UIO not staging
     rename to uio-hv-generic (since it is like uio-pci-generic)
     add example to comment

 drivers/hv/connection.c      |   1 +
 drivers/uio/Kconfig          |   9 ++
 drivers/uio/Makefile         |   1 +
 drivers/uio/uio_hv_generic.c | 216 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 227 insertions(+)
 create mode 100644 drivers/uio/uio_hv_generic.c

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 78e6368..6ce8b87 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -39,6 +39,7 @@ struct vmbus_connection vmbus_connection = {
 	.conn_state		= DISCONNECTED,
 	.next_gpadl_handle	= ATOMIC_INIT(0xE1E10),
 };
+EXPORT_SYMBOL_GPL(vmbus_connection);
 
 /*
  * Negotiated protocol version with the host.
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 52c98ce..7e8dc78 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -155,4 +155,13 @@ config UIO_MF624
 
 	  If you compile this as a module, it will be called uio_mf624.
 
+config UIO_HV_GENERIC
+	tristate "Generic driver for Hyper-V VMBus"
+	depends on HYPERV
+	help
+	  Generic driver that you can bind, dynamically, to any
+	  Hyper-V VMBus device. It is useful to provide direct access
+	  to network and storage devices from userspace.
+
+	  If you compile this as a module, it will be called uio_hv_generic.
 endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 8560dad..e9663bb 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_UIO_NETX)	+= uio_netx.o
 obj-$(CONFIG_UIO_PRUSS)         += uio_pruss.o
 obj-$(CONFIG_UIO_MF624)         += uio_mf624.o
 obj-$(CONFIG_UIO_FSL_ELBC_GPCM)	+= uio_fsl_elbc_gpcm.o
+obj-$(CONFIG_UIO_HV_GENERIC)	+= uio_hv_generic.o
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
new file mode 100644
index 0000000..66ea574
--- /dev/null
+++ b/drivers/uio/uio_hv_generic.c
@@ -0,0 +1,216 @@
+/*
+ * uio_hv_generic - generic UIO driver for VMBus
+ *
+ * Copyright (c) 2013-2016 Brocade Communications Systems, Inc.
+ * Copyright (c) 2016, Microsoft Corporation.
+ *
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ *
+ * Since the driver does not declare any device ids, you must allocate
+ * id and bind the device to the driver yourself.  For example:
+ *
+ * # echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" \
+ *    > /sys/bus/vmbus/drivers/uio_hv_generic
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *    > /sys/bus/vmbus/drivers/hv_netvsc/unbind
+ * # echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 \
+ *    > /sys/bus/vmbus/drivers/uio_hv_generic/bind
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/uio_driver.h>
+#include <linux/netdevice.h>
+#include <linux/if_ether.h>
+#include <linux/skbuff.h>
+#include <linux/hyperv.h>
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+
+#include "../hv/hyperv_vmbus.h"
+
+#define DRIVER_VERSION	"0.02.0"
+#define DRIVER_AUTHOR	"Stephen Hemminger <sthemmin@microsoft.com>"
+#define DRIVER_DESC	"Generic UIO driver for VMBus devices"
+
+/*
+ * List of resources to be mapped to user space
+ * can be extended up to MAX_UIO_MAPS(5) items
+ */
+enum hv_uio_map {
+	TXRX_RING_MAP = 0,
+	INT_PAGE_MAP,
+	MON_PAGE_MAP,
+};
+
+#define HV_RING_SIZE	512
+
+struct hv_uio_private_data {
+	struct uio_info info;
+	struct hv_device *device;
+};
+
+static int
+hv_uio_mmap(struct uio_info *info, struct vm_area_struct *vma)
+{
+	int mi;
+
+	if (vma->vm_pgoff >= MAX_UIO_MAPS)
+		return -EINVAL;
+
+	if (info->mem[vma->vm_pgoff].size == 0)
+		return -EINVAL;
+
+	mi = (int)vma->vm_pgoff;
+
+	return remap_pfn_range(vma, vma->vm_start,
+			       virt_to_phys((void *)info->mem[mi].addr) >> PAGE_SHIFT,
+			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
+}
+
+/*
+ * This is the irqcontrol callback to be registered to uio_info.
+ * It can be used to disable/enable interrupt from user space processes.
+ *
+ * @param info
+ *  pointer to uio_info.
+ * @param irq_state
+ *  state value. 1 to enable interrupt, 0 to disable interrupt.
+ */
+static int
+hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
+{
+	struct hv_uio_private_data *pdata = info->priv;
+	struct hv_device *dev = pdata->device;
+
+	dev->channel->inbound.ring_buffer->interrupt_mask = !irq_state;
+	virt_mb();
+
+	return 0;
+}
+
+/*
+ * Callback from vmbus_event when something is in inbound ring.
+ */
+static void hv_uio_channel_cb(void *context)
+{
+	struct hv_uio_private_data *pdata = context;
+	struct hv_device *dev = pdata->device;
+
+	dev->channel->inbound.ring_buffer->interrupt_mask = 1;
+	virt_mb();
+
+	uio_event_notify(&pdata->info);
+}
+
+static int
+hv_uio_probe(struct hv_device *dev,
+	     const struct hv_vmbus_device_id *dev_id)
+{
+	struct hv_uio_private_data *pdata;
+	int ret;
+
+	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
+
+	ret = vmbus_open(dev->channel, HV_RING_SIZE * PAGE_SIZE,
+			 HV_RING_SIZE * PAGE_SIZE, NULL, 0,
+			 hv_uio_channel_cb, pdata);
+	if (ret)
+		goto fail;
+
+	dev->channel->inbound.ring_buffer->interrupt_mask = 1;
+	dev->channel->batched_reading = false;
+
+	/* Fill general uio info */
+	pdata->info.name = "uio_hv_generic";
+	pdata->info.version = DRIVER_VERSION;
+	pdata->info.irqcontrol = hv_uio_irqcontrol;
+	pdata->info.mmap = hv_uio_mmap;
+	pdata->info.irq = UIO_IRQ_CUSTOM;
+
+	/* mem resources */
+	pdata->info.mem[TXRX_RING_MAP].name = "txrx_rings";
+	pdata->info.mem[TXRX_RING_MAP].addr
+		= (phys_addr_t)dev->channel->ringbuffer_pages;
+	pdata->info.mem[TXRX_RING_MAP].size
+		= dev->channel->ringbuffer_pagecount * PAGE_SIZE;
+	pdata->info.mem[TXRX_RING_MAP].memtype = UIO_MEM_LOGICAL;
+
+	pdata->info.mem[INT_PAGE_MAP].name = "int_page";
+	pdata->info.mem[INT_PAGE_MAP].addr = (phys_addr_t)vmbus_connection.int_page;
+	pdata->info.mem[INT_PAGE_MAP].size = PAGE_SIZE;
+	pdata->info.mem[INT_PAGE_MAP].memtype = UIO_MEM_LOGICAL;
+
+	pdata->info.mem[MON_PAGE_MAP].name = "monitor_pages";
+	pdata->info.mem[MON_PAGE_MAP].addr = (phys_addr_t)vmbus_connection.monitor_pages[1];
+	pdata->info.mem[MON_PAGE_MAP].size = PAGE_SIZE;
+	pdata->info.mem[MON_PAGE_MAP].memtype = UIO_MEM_LOGICAL;
+
+	pdata->info.priv = pdata;
+	pdata->device = dev;
+
+	ret = uio_register_device(&dev->device, &pdata->info);
+	if (ret) {
+		dev_err(&dev->device, "hv_uio register failed\n");
+		goto fail_close;
+	}
+
+	hv_set_drvdata(dev, pdata);
+
+	return 0;
+
+fail_close:
+	vmbus_close(dev->channel);
+fail:
+	kfree(pdata);
+
+	return ret;
+}
+
+static int
+hv_uio_remove(struct hv_device *dev)
+{
+	struct hv_uio_private_data *pdata = hv_get_drvdata(dev);
+
+	if (!pdata)
+		return 0;
+
+	uio_unregister_device(&pdata->info);
+	hv_set_drvdata(dev, NULL);
+	vmbus_close(dev->channel);
+	kfree(pdata);
+	return 0;
+}
+
+static struct hv_driver hv_uio_drv = {
+	.name = "uio_hv_generic",
+	.id_table = NULL, /* only dynamic id's */
+	.probe = hv_uio_probe,
+	.remove = hv_uio_remove,
+};
+
+static int __init
+hyperv_module_init(void)
+{
+	return vmbus_driver_register(&hv_uio_drv);
+}
+
+static void __exit
+hyperv_module_exit(void)
+{
+	vmbus_driver_unregister(&hv_uio_drv);
+}
+
+module_init(hyperv_module_init);
+module_exit(hyperv_module_exit);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] doc: add documentation for uio-hv-generic
  2016-10-17 19:29 [PATCH v2 1/3] vmbus: add support for dynamic device id's Stephen Hemminger
  2016-10-17 19:31 ` [PATCH v2 2/3] uio-hv-generic: new userspace i/o driver for VMBus Stephen Hemminger
@ 2016-10-17 19:33 ` Stephen Hemminger
  2016-10-18 10:54   ` Jani Nikula
  2016-10-21 21:10   ` Jonathan Corbet
  2016-11-10 15:59 ` [PATCH v2 1/3] vmbus: add support for dynamic device id's Greg KH
  2 siblings, 2 replies; 9+ messages in thread
From: Stephen Hemminger @ 2016-10-17 19:33 UTC (permalink / raw)
  To: Greg KH, KY Srinivasan, Haiyang Zhang, corbet
  Cc: devel, linux-kernel, linux-doc

From: Stephen Hemminger <sthemmin@microsoft.com>

Update UIO documentation to include basic information about
uio_hv_generic.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 Documentation/DocBook/uio-howto.tmpl | 62 ++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index cd0e452..5210f8a 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -46,6 +46,13 @@ GPL version 2.
 
 <revhistory>
 	<revision>
+	<revnumber>0.10</revnumber>
+	<date>2016-10-17</date>
+	<authorinitials>sch</authorinitials>
+	<revremark>Added generic hyperv driver
+		</revremark>
+	</revision>
+	<revision>
 	<revnumber>0.9</revnumber>
 	<date>2009-07-16</date>
 	<authorinitials>mst</authorinitials>
@@ -1033,6 +1040,61 @@ int main()
 
 </chapter>
 
+<chapter id="uio_hv_generic" xreflabel="Using Generic driver for Hyper-V VMBUS">
+<?dbhtml filename="uio_hv_generic.html"?>
+<title>Generic Hyper-V UIO driver</title>
+	<para>
+	The generic driver is a kernel module named uio_hv_generic.
+	It supports devices on the Hyper-V VMBus similar to uio_pci_generic
+	on PCI bus.
+	</para>
+
+<sect1 id="uio_hv_generic_binding">
+<title>Making the driver recognize the device</title>
+	<para>
+Since the driver does not declare any device GUID's, it will not get loaded
+automatically and will not automatically bind to any devices, you must load it
+and allocate id to the driver yourself. For example, to use the network device
+GUID:
+	<programlisting>
+ modprobe uio_hv_generic
+ echo &quot;f8615163-df3e-46c5-913f-f2d2f965ed0e&quot; &gt; /sys/bus/vmbus/drivers/uio_hv_generic/new_id
+	</programlisting>
+	</para>
+	<para>
+If there already is a hardware specific kernel driver for the device, the
+generic driver still won't bind to it, in this case if you want to use the
+generic driver (why would you?) you'll have to manually unbind the hardware
+specific driver and bind the generic driver, like this:
+	<programlisting>
+	  echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/hv_netvsc/unbind
+	  echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/uio_hv_generic/bind
+	</programlisting>
+	</para>
+	<para>
+You can verify that the device has been bound to the driver
+by looking for it in sysfs, for example like the following:
+	<programlisting>
+    ls -l /sys/bus/vmbus/devices/vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
+	</programlisting>
+Which if successful should print
+	<programlisting>
+  .../vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -&gt; ../../../bus/vmbus/drivers/uio_hv_generic
+	</programlisting>
+	</para>
+</sect1>
+
+<sect1 id="uio_hv_generic_internals">
+<title>Things to know about uio_hv_generic</title>
+	<para>
+On each interrupt, uio_hv_generic sets the Interrupt Disable bit.
+This prevents the device from generating further interrupts
+until the bit is cleared. The userspace driver should clear this
+bit before blocking and waiting for more interrupts.
+	</para>
+</sect1>
+</chapter>
+
 <appendix id="app1">
 <title>Further information</title>
 <itemizedlist>
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] doc: add documentation for uio-hv-generic
  2016-10-17 19:33 ` [PATCH v2 3/3] doc: add documentation for uio-hv-generic Stephen Hemminger
@ 2016-10-18 10:54   ` Jani Nikula
  2016-10-18 11:01     ` Markus Heiser
  2016-10-21 21:10   ` Jonathan Corbet
  1 sibling, 1 reply; 9+ messages in thread
From: Jani Nikula @ 2016-10-18 10:54 UTC (permalink / raw)
  To: Stephen Hemminger, Greg KH, KY Srinivasan, Haiyang Zhang, corbet
  Cc: devel, linux-kernel, linux-doc

On Mon, 17 Oct 2016, Stephen Hemminger <stephen@networkplumber.org> wrote:
> From: Stephen Hemminger <sthemmin@microsoft.com>
>
> Update UIO documentation to include basic information about
> uio_hv_generic.

How about converting to Sphinx/reStructuredText first...? It's not a big
file...

BR,
Jani.



>
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
> ---
>  Documentation/DocBook/uio-howto.tmpl | 62 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
>
> diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
> index cd0e452..5210f8a 100644
> --- a/Documentation/DocBook/uio-howto.tmpl
> +++ b/Documentation/DocBook/uio-howto.tmpl
> @@ -46,6 +46,13 @@ GPL version 2.
>  
>  <revhistory>
>  	<revision>
> +	<revnumber>0.10</revnumber>
> +	<date>2016-10-17</date>
> +	<authorinitials>sch</authorinitials>
> +	<revremark>Added generic hyperv driver
> +		</revremark>
> +	</revision>
> +	<revision>
>  	<revnumber>0.9</revnumber>
>  	<date>2009-07-16</date>
>  	<authorinitials>mst</authorinitials>
> @@ -1033,6 +1040,61 @@ int main()
>  
>  </chapter>
>  
> +<chapter id="uio_hv_generic" xreflabel="Using Generic driver for Hyper-V VMBUS">
> +<?dbhtml filename="uio_hv_generic.html"?>
> +<title>Generic Hyper-V UIO driver</title>
> +	<para>
> +	The generic driver is a kernel module named uio_hv_generic.
> +	It supports devices on the Hyper-V VMBus similar to uio_pci_generic
> +	on PCI bus.
> +	</para>
> +
> +<sect1 id="uio_hv_generic_binding">
> +<title>Making the driver recognize the device</title>
> +	<para>
> +Since the driver does not declare any device GUID's, it will not get loaded
> +automatically and will not automatically bind to any devices, you must load it
> +and allocate id to the driver yourself. For example, to use the network device
> +GUID:
> +	<programlisting>
> + modprobe uio_hv_generic
> + echo &quot;f8615163-df3e-46c5-913f-f2d2f965ed0e&quot; &gt; /sys/bus/vmbus/drivers/uio_hv_generic/new_id
> +	</programlisting>
> +	</para>
> +	<para>
> +If there already is a hardware specific kernel driver for the device, the
> +generic driver still won't bind to it, in this case if you want to use the
> +generic driver (why would you?) you'll have to manually unbind the hardware
> +specific driver and bind the generic driver, like this:
> +	<programlisting>
> +	  echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/hv_netvsc/unbind
> +	  echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/uio_hv_generic/bind
> +	</programlisting>
> +	</para>
> +	<para>
> +You can verify that the device has been bound to the driver
> +by looking for it in sysfs, for example like the following:
> +	<programlisting>
> +    ls -l /sys/bus/vmbus/devices/vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
> +	</programlisting>
> +Which if successful should print
> +	<programlisting>
> +  .../vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -&gt; ../../../bus/vmbus/drivers/uio_hv_generic
> +	</programlisting>
> +	</para>
> +</sect1>
> +
> +<sect1 id="uio_hv_generic_internals">
> +<title>Things to know about uio_hv_generic</title>
> +	<para>
> +On each interrupt, uio_hv_generic sets the Interrupt Disable bit.
> +This prevents the device from generating further interrupts
> +until the bit is cleared. The userspace driver should clear this
> +bit before blocking and waiting for more interrupts.
> +	</para>
> +</sect1>
> +</chapter>
> +
>  <appendix id="app1">
>  <title>Further information</title>
>  <itemizedlist>

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] doc: add documentation for uio-hv-generic
  2016-10-18 10:54   ` Jani Nikula
@ 2016-10-18 11:01     ` Markus Heiser
  2016-10-18 13:59       ` Stephen Hemminger
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Heiser @ 2016-10-18 11:01 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Jani Nikula, Greg KH, KY Srinivasan, Haiyang Zhang, corbet,
	devel, linux-kernel, linux-doc@vger.kernel.org Mailing List


Am 18.10.2016 um 12:54 schrieb Jani Nikula <jani.nikula@linux.intel.com>:

> On Mon, 17 Oct 2016, Stephen Hemminger <stephen@networkplumber.org> wrote:
>> From: Stephen Hemminger <sthemmin@microsoft.com>
>> 
>> Update UIO documentation to include basic information about
>> uio_hv_generic.
> 
> How about converting to Sphinx/reStructuredText first...? It's not a big
> file...
> 

The files from :

 https://github.com/return42/sphkerneldoc/tree/master/doc/Documentation/books_migrated/uio-howto

might be a good starting point for migration / if you use them, 
please drop the comments at the end of each file.

--M--

> BR,
> Jani.
> 
> 
> 
>> 
>> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
>> ---
>> Documentation/DocBook/uio-howto.tmpl | 62 ++++++++++++++++++++++++++++++++++++
>> 1 file changed, 62 insertions(+)
>> 
>> diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
>> index cd0e452..5210f8a 100644
>> --- a/Documentation/DocBook/uio-howto.tmpl
>> +++ b/Documentation/DocBook/uio-howto.tmpl
>> @@ -46,6 +46,13 @@ GPL version 2.
>> 
>> <revhistory>
>> 	<revision>
>> +	<revnumber>0.10</revnumber>
>> +	<date>2016-10-17</date>
>> +	<authorinitials>sch</authorinitials>
>> +	<revremark>Added generic hyperv driver
>> +		</revremark>
>> +	</revision>
>> +	<revision>
>> 	<revnumber>0.9</revnumber>
>> 	<date>2009-07-16</date>
>> 	<authorinitials>mst</authorinitials>
>> @@ -1033,6 +1040,61 @@ int main()
>> 
>> </chapter>
>> 
>> +<chapter id="uio_hv_generic" xreflabel="Using Generic driver for Hyper-V VMBUS">
>> +<?dbhtml filename="uio_hv_generic.html"?>
>> +<title>Generic Hyper-V UIO driver</title>
>> +	<para>
>> +	The generic driver is a kernel module named uio_hv_generic.
>> +	It supports devices on the Hyper-V VMBus similar to uio_pci_generic
>> +	on PCI bus.
>> +	</para>
>> +
>> +<sect1 id="uio_hv_generic_binding">
>> +<title>Making the driver recognize the device</title>
>> +	<para>
>> +Since the driver does not declare any device GUID's, it will not get loaded
>> +automatically and will not automatically bind to any devices, you must load it
>> +and allocate id to the driver yourself. For example, to use the network device
>> +GUID:
>> +	<programlisting>
>> + modprobe uio_hv_generic
>> + echo &quot;f8615163-df3e-46c5-913f-f2d2f965ed0e&quot; &gt; /sys/bus/vmbus/drivers/uio_hv_generic/new_id
>> +	</programlisting>
>> +	</para>
>> +	<para>
>> +If there already is a hardware specific kernel driver for the device, the
>> +generic driver still won't bind to it, in this case if you want to use the
>> +generic driver (why would you?) you'll have to manually unbind the hardware
>> +specific driver and bind the generic driver, like this:
>> +	<programlisting>
>> +	  echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/hv_netvsc/unbind
>> +	  echo -n vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3 &gt; /sys/bus/vmbus/drivers/uio_hv_generic/bind
>> +	</programlisting>
>> +	</para>
>> +	<para>
>> +You can verify that the device has been bound to the driver
>> +by looking for it in sysfs, for example like the following:
>> +	<programlisting>
>> +    ls -l /sys/bus/vmbus/devices/vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
>> +	</programlisting>
>> +Which if successful should print
>> +	<programlisting>
>> +  .../vmbus-ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -&gt; ../../../bus/vmbus/drivers/uio_hv_generic
>> +	</programlisting>
>> +	</para>
>> +</sect1>
>> +
>> +<sect1 id="uio_hv_generic_internals">
>> +<title>Things to know about uio_hv_generic</title>
>> +	<para>
>> +On each interrupt, uio_hv_generic sets the Interrupt Disable bit.
>> +This prevents the device from generating further interrupts
>> +until the bit is cleared. The userspace driver should clear this
>> +bit before blocking and waiting for more interrupts.
>> +	</para>
>> +</sect1>
>> +</chapter>
>> +
>> <appendix id="app1">
>> <title>Further information</title>
>> <itemizedlist>
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> --
> To unsubscribe from this list: send the line "unsubscribe linux-doc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] doc: add documentation for uio-hv-generic
  2016-10-18 11:01     ` Markus Heiser
@ 2016-10-18 13:59       ` Stephen Hemminger
  2016-10-18 14:04         ` Markus Heiser
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2016-10-18 13:59 UTC (permalink / raw)
  To: Markus Heiser
  Cc: Jani Nikula, Greg KH, KY Srinivasan, Haiyang Zhang, corbet,
	devel, linux-kernel, linux-doc@vger.kernel.org Mailing List

On Tue, 18 Oct 2016 13:01:20 +0200
Markus Heiser <markus.heiser@darmarit.de> wrote:

> Am 18.10.2016 um 12:54 schrieb Jani Nikula <jani.nikula@linux.intel.com>:
> 
> > On Mon, 17 Oct 2016, Stephen Hemminger <stephen@networkplumber.org> wrote:  
> >> From: Stephen Hemminger <sthemmin@microsoft.com>
> >> 
> >> Update UIO documentation to include basic information about
> >> uio_hv_generic.  
> > 
> > How about converting to Sphinx/reStructuredText first...? It's not a big
> > file...
> >   
> 
> The files from :
> 
>  https://github.com/return42/sphkerneldoc/tree/master/doc/Documentation/books_migrated/uio-howto
> 
> might be a good starting point for migration / if you use them, 
> please drop the comments at the end of each file.
> 
> --M--

Sure, you are welcome to do this. I just wanted to add to existing documentation in existing
format.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] doc: add documentation for uio-hv-generic
  2016-10-18 13:59       ` Stephen Hemminger
@ 2016-10-18 14:04         ` Markus Heiser
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Heiser @ 2016-10-18 14:04 UTC (permalink / raw)
  To: Stephen Hemminger, Greg KH
  Cc: Jani Nikula, KY Srinivasan, Haiyang Zhang, corbet, devel,
	linux-kernel@vger.kernel.org Mailing List,
	linux-doc@vger.kernel.org Mailing List


Am 18.10.2016 um 15:59 schrieb Stephen Hemminger <stephen@networkplumber.org>:

> On Tue, 18 Oct 2016 13:01:20 +0200
> Markus Heiser <markus.heiser@darmarit.de> wrote:
> 
>> Am 18.10.2016 um 12:54 schrieb Jani Nikula <jani.nikula@linux.intel.com>:
>> 
>>> On Mon, 17 Oct 2016, Stephen Hemminger <stephen@networkplumber.org> wrote:  
>>>> From: Stephen Hemminger <sthemmin@microsoft.com>
>>>> 
>>>> Update UIO documentation to include basic information about
>>>> uio_hv_generic.  
>>> 
>>> How about converting to Sphinx/reStructuredText first...? It's not a big
>>> file...
>>> 
>> 
>> The files from :
>> 
>> https://github.com/return42/sphkerneldoc/tree/master/doc/Documentation/books_migrated/uio-howto
>> 
>> might be a good starting point for migration / if you use them, 
>> please drop the comments at the end of each file.
>> 
>> --M--
> 
> Sure, you are welcome to do this. I just wanted to add to existing documentation in existing
> format.

OK, I will send a patch / hope Greck and you will give me your acked ;-)

--M--

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] doc: add documentation for uio-hv-generic
  2016-10-17 19:33 ` [PATCH v2 3/3] doc: add documentation for uio-hv-generic Stephen Hemminger
  2016-10-18 10:54   ` Jani Nikula
@ 2016-10-21 21:10   ` Jonathan Corbet
  1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Corbet @ 2016-10-21 21:10 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Greg KH, KY Srinivasan, Haiyang Zhang, devel, linux-kernel, linux-doc

On Mon, 17 Oct 2016 12:33:19 -0700
Stephen Hemminger <stephen@networkplumber.org> wrote:

> From: Stephen Hemminger <sthemmin@microsoft.com>
> 
> Update UIO documentation to include basic information about
> uio_hv_generic.

I've applied this to the docs tree, thanks.

jon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] vmbus: add support for dynamic device id's
  2016-10-17 19:29 [PATCH v2 1/3] vmbus: add support for dynamic device id's Stephen Hemminger
  2016-10-17 19:31 ` [PATCH v2 2/3] uio-hv-generic: new userspace i/o driver for VMBus Stephen Hemminger
  2016-10-17 19:33 ` [PATCH v2 3/3] doc: add documentation for uio-hv-generic Stephen Hemminger
@ 2016-11-10 15:59 ` Greg KH
  2 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2016-11-10 15:59 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: KY Srinivasan, Haiyang Zhang, devel, linux-kernel

On Mon, Oct 17, 2016 at 12:29:59PM -0700, Stephen Hemminger wrote:
> From: Stephen Hemminger <sthemmin@microsoft.com>
> 
> This patch adds sysfs interface to dynamically bind new UUID values
> to existing VMBus device. This is useful for generic UIO driver to
> act similar to uio_pci_generic.
> 
> Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
> ---
> v2 - allow device driver to have empty id table, and fix bugs
> 
>  drivers/hv/vmbus_drv.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++---
>  include/linux/hyperv.h |   6 ++
>  2 files changed, 172 insertions(+), 8 deletions(-)

Can I get an ack from the hyperv maintainers before accepting this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-11-10 15:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 19:29 [PATCH v2 1/3] vmbus: add support for dynamic device id's Stephen Hemminger
2016-10-17 19:31 ` [PATCH v2 2/3] uio-hv-generic: new userspace i/o driver for VMBus Stephen Hemminger
2016-10-17 19:33 ` [PATCH v2 3/3] doc: add documentation for uio-hv-generic Stephen Hemminger
2016-10-18 10:54   ` Jani Nikula
2016-10-18 11:01     ` Markus Heiser
2016-10-18 13:59       ` Stephen Hemminger
2016-10-18 14:04         ` Markus Heiser
2016-10-21 21:10   ` Jonathan Corbet
2016-11-10 15:59 ` [PATCH v2 1/3] vmbus: add support for dynamic device id's Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.