Skip to contentSkip to conversation

hyper-v: allow access to vmbus from userspace driver

PATCH In review Stephen Hemminger 3 participants 4 messages Feb 3, 2015 – Feb 4, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hyper-v: allow access to vmbus from userspace driver

Brocade is submitting a hyper-v driver for DPDK <[email protected]> but this driver needs a hook in the hyper-v bus layer to allow the additional hv_uio driver to access the shared vmbus pages. The hv_uio driver lives in DPDK (like igb_uio) and provides userspace access to raw network packets.

---
 drivers/hv/connection.c |   20 +++++++++++++++++---
 include/linux/hyperv.h  |    3 +++
 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/hv/connection.c +17 -1
@@ -64,6 +64,21 @@ static __u32 vmbus_get_next_version(__u3
 	}
 }
 
+static const uuid_le HV_NET_GUID = {
+	.b = {
+		0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46,
+		0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e
+	}
+};
+
+void vmbus_get_pages(unsigned long *int_page, unsigned long monitor_pages[2])
+{
+	*int_page = (unsigned long)vmbus_connection.int_page;
+	monitor_pages[0] = (unsigned long)vmbus_connection.monitor_pages[0];
+	monitor_pages[1] = (unsigned long)vmbus_connection.monitor_pages[1];
+}
+EXPORT_SYMBOL_GPL(vmbus_get_pages);
+
 static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo,
 					__u32 version)
 {
@@ -347,7 +362,8 @@ static void process_chn_event(u32 relid)
 			else
 				bytes_to_read = 0;
 		} while (read_state && (bytes_to_read != 0));
-	} else {
+	} else if (!memcmp(&channel->device_obj->dev_type, &HV_NET_GUID,
+			   sizeof(uuid_le))) {
 		pr_err("no channel callback for relid - %u\n", relid);
 	}
 
include/linux/hyperv.h +3 -0
@@ -868,6 +868,9 @@ extern int vmbus_recvpacket_raw(struct v
 
 extern void vmbus_ontimer(unsigned long data);
 
+extern void vmbus_get_pages(unsigned long *int_page,
+			    unsigned long monitor_pages[2]);
+
 /* Base driver object */
 struct hv_driver {
 	const char *name;
#1 lore raw
Quoted 25 lines

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, February 3, 2015 11:04 AM
To: KY Srinivasan; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: [PATCH] hyper-v: allow access to vmbus from userspace driver

Brocade is submitting a hyper-v driver for DPDK <[email protected]> but this driver needs a hook in the hyper-v bus layer to allow the additional hv_uio driver to access the shared vmbus pages. The hv_uio driver lives in DPDK (like igb_uio) and provides userspace access to raw network packets.

---
 drivers/hv/connection.c |   20 +++++++++++++++++---
 include/linux/hyperv.h  |    3 +++
 2 files changed, 20 insertions(+), 3 deletions(-)

drivers/hv/connection.c static __u32 vmbus_get_next_version(__u3 · line 73

Quoted 10 lines
drivers/hv/connection.c +7 -0
@@ -64,6 +64,21 @@ static __u32 vmbus_get_next_version(__u3
 	}
 }
 
+static const uuid_le HV_NET_GUID = {
+	.b = {
+		0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46,
+		0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e
+	}
+};
+

We already have this guid defined in linux/hyperv.h; look at HV_NIC_GUID.

Quoted 15 lines
drivers/hv/connection.c +8 -0
+void vmbus_get_pages(unsigned long *int_page, unsigned long
+monitor_pages[2]) {
+	*int_page = (unsigned long)vmbus_connection.int_page;
+	monitor_pages[0] = (unsigned
 long)vmbus_connection.monitor_pages[0];
+	monitor_pages[1] = (unsigned
 long)vmbus_connection.monitor_pages[1];
+}
+EXPORT_SYMBOL_GPL(vmbus_get_pages);
+
 static int vmbus_negotiate_version(struct vmbus_channel_msginfo

*msginfo,

drivers/hv/connection.c +0 -0
 					__u32 version)
 {

drivers/hv/connection.c static void process_chn_event(u32 relid) · line 369

Quoted 9 lines
drivers/hv/connection.c +2 -1
@@ -347,7 +362,8 @@ static void process_chn_event(u32 relid)
 			else
 				bytes_to_read = 0;
 		} while (read_state && (bytes_to_read != 0));
-	} else {
+	} else if (!memcmp(&channel->device_obj->dev_type,
 &HV_NET_GUID,
+			   sizeof(uuid_le))) {
 		pr_err("no channel callback for relid - %u\n", relid);
 	}

I am not sure this message is all that useful. We may just get rid of the message. If we get rid of this message, we can significantly simplify.

include/linux/hyperv.h extern int vmbus_recvpacket_raw(struct v · line 876

Quoted 13 lines
include/linux/hyperv.h +3 -0
@@ -868,6 +868,9 @@ extern int vmbus_recvpacket_raw(struct v
 
 extern void vmbus_ontimer(unsigned long data);
 
+extern void vmbus_get_pages(unsigned long *int_page,
+			    unsigned long monitor_pages[2]);
+
 /* Base driver object */
 struct hv_driver {
 	const char *name;

Thanks,

K. Y

#2 lore raw
Quoted 49 lines

-----Original Message-----
From: devel [mailto:[email protected]] On Behalf Of KY Srinivasan
Sent: Tuesday, February 3, 2015 11:24 AM
To: Stephen Hemminger; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] hyper-v: allow access to vmbus from userspace driver

Quoted 24 lines

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, February 3, 2015 11:04 AM
To: KY Srinivasan; Haiyang Zhang
Cc: [email protected]; [email protected]
Subject: [PATCH] hyper-v: allow access to vmbus from userspace driver

Brocade is submitting a hyper-v driver for DPDK <[email protected]> but this driver needs a hook in the hyper-v bus layer to allow the additional hv_uio driver to access the shared vmbus pages. The hv_uio driver lives in DPDK (like
igb_uio) and provides userspace access to raw network packets.

---
 drivers/hv/connection.c |   20 +++++++++++++++++---
 include/linux/hyperv.h  |    3 +++
 2 files changed, 20 insertions(+), 3 deletions(-)

drivers/hv/connection.c static __u32 vmbus_get_next_version(__u3 · line 73

Quoted 10 lines
drivers/hv/connection.c +7 -0
@@ -64,6 +64,21 @@ static __u32 vmbus_get_next_version(__u3
 	}
 }
 
+static const uuid_le HV_NET_GUID = {
+	.b = {
+		0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46,
+		0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e
+	}
+};
+

We already have this guid defined in linux/hyperv.h; look at HV_NIC_GUID.

Quoted 9 lines

drivers/hv/connection.c static __u32 vmbus_get_next_version(__u3 · line 82

Quoted 9 lines
drivers/hv/connection.c +7 -0
+void vmbus_get_pages(unsigned long *int_page, unsigned long
+monitor_pages[2]) {
+	*int_page = (unsigned long)vmbus_connection.int_page;
+	monitor_pages[0] = (unsigned
 long)vmbus_connection.monitor_pages[0];
+	monitor_pages[1] = (unsigned
 long)vmbus_connection.monitor_pages[1];
+}
+EXPORT_SYMBOL_GPL(vmbus_get_pages);

vmbus_get_pages() is too generic. Perhaps vmbus_get_monitor_pages() may be a better name for this function.

Regards,

K. Y

#3 lore raw
In reply to Stephen Hemminger

Hi Stephen,

2015-02-03 11:03, stephen hemminger:

Quoted 8 lines

Brocade is submitting a hyper-v driver for DPDK <[email protected]> but this driver needs a hook in the hyper-v bus layer to allow the additional hv_uio driver to access the shared vmbus pages. The hv_uio driver lives in DPDK (like igb_uio) and provides userspace access to raw network packets.

The hyper-v driver for DPDK has not been sent yet to
http://dpdk.org/dev/patchwork
but it would be interesting to better explain this uio mapping.

Thanks

Signature · 1 line
Thomas
Quoted 46 lines
drivers/hv/connection.c +17 -1
@@ -64,6 +64,21 @@ static __u32 vmbus_get_next_version(__u3
 	}
 }
 
+static const uuid_le HV_NET_GUID = {
+	.b = {
+		0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46,
+		0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e
+	}
+};
+
+void vmbus_get_pages(unsigned long *int_page, unsigned long monitor_pages[2])
+{
+	*int_page = (unsigned long)vmbus_connection.int_page;
+	monitor_pages[0] = (unsigned long)vmbus_connection.monitor_pages[0];
+	monitor_pages[1] = (unsigned long)vmbus_connection.monitor_pages[1];
+}
+EXPORT_SYMBOL_GPL(vmbus_get_pages);
+
 static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo,
 					__u32 version)
 {
@@ -347,7 +362,8 @@ static void process_chn_event(u32 relid)
 			else
 				bytes_to_read = 0;
 		} while (read_state && (bytes_to_read != 0));
-	} else {
+	} else if (!memcmp(&channel->device_obj->dev_type, &HV_NET_GUID,
+			   sizeof(uuid_le))) {
 		pr_err("no channel callback for relid - %u\n", relid);
 	}
 
include/linux/hyperv.h +3 -0
@@ -868,6 +868,9 @@ extern int vmbus_recvpacket_raw(struct v
 
 extern void vmbus_ontimer(unsigned long data);
 
+extern void vmbus_get_pages(unsigned long *int_page,
+			    unsigned long monitor_pages[2]);
+
 /* Base driver object */
 struct hv_driver {
 	const char *name;