Skip to contentSkip to conversation

Staging: hv: Implement key/value pair (KVP)

PATCH New Ky Srinivasan 1 participant 1 message Dec 17, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 3/4 Staging: hv: Implement key/value pair (KVP)

This is an implementation of the key value/pair (KVP) functionality for Linux guests hosted on HyperV. This component communicates with the host to support the KVP functionality.

---
 drivers/staging/hv/Makefile       |    2 +-
 drivers/staging/hv/channel_mgmt.c |   23 +++-
 drivers/staging/hv/hv_kvp.c       |  346 +++++++++++++++++++++++++++++++++++++
 drivers/staging/hv/hv_kvp.h       |  184 ++++++++++++++++++++
 drivers/staging/hv/hv_util.c      |   14 ++
 drivers/staging/hv/utils.h        |    1 +
 6 files changed, 567 insertions(+), 3 deletions(-)
 create mode 100644 drivers/staging/hv/hv_kvp.c
 create mode 100644 drivers/staging/hv/hv_kvp.h
drivers/staging/hv/Makefile +1 -1
index 4c14138..606ce7d 100644
@@ -10,4 +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_utils-y := hv_util.o
+hv_utils-y := hv_util.o hv_kvp.o
drivers/staging/hv/channel_mgmt.c +21 -2
index 0f4d609..375f164 100644
@@ -34,8 +34,8 @@ struct vmbus_channel_message_table_entry {
 	void (*messageHandler)(struct vmbus_channel_message_header *msg);
 };
 
-#define MAX_MSG_TYPES                    3
-#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 7
+#define MAX_MSG_TYPES                    4
+#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
 
 static const struct hv_guid
 	gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
@@ -98,6 +98,15 @@ static const struct hv_guid
 			0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
 		}
 	},
+	/* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
+	/* KVP */
+	{
+		.data = {
+			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
+	}
+	},
+
 };
 
 
@@ -231,6 +240,16 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
 		.callback = chn_cb_negotiate,
 		.log_msg = "Heartbeat channel functionality initialized"
 	},
+	/* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
+	/* KVP */
+	{
+		.data = {
+			0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
+			0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
+		},
+		.callback = chn_cb_negotiate,
+		.log_msg = "KVP channel functionality initialized"
+	},
 };
 EXPORT_SYMBOL(hv_cb_utils);
 
drivers/staging/hv/hv_kvp.c new file +346 -0

346 lines not on this page · raw message

drivers/staging/hv/hv_kvp.h new file +184 -0

184 lines not on this page · raw message

drivers/staging/hv/hv_util.c +14 -0
index 0074581..dea0513 100644
@@ -37,6 +37,7 @@
 #include "vmbus_private.h"
 #include "vmbus_api.h"
 #include "utils.h"
+#include "hv_kvp.h"
 
 static u8 *shut_txf_buf;
 static u8 *time_txf_buf;
@@ -255,6 +256,10 @@ static int __init init_hyperv_utils(void)
 {
 	printk(KERN_INFO "Registering HyperV Utility Driver\n");
 
+	if (hv_kvp_init())
+		return -ENODEV;
+
+
 	if (!dmi_check_system(hv_utils_dmi_table))
 		return -ENODEV;
 
@@ -283,6 +288,11 @@ 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->onchannel_callback =
+		&hv_kvp_onchannelcallback;
+
+
+
 	return 0;
 }
 
@@ -302,6 +312,10 @@ static void exit_hyperv_utils(void)
 		&chn_cb_negotiate;
 	hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
 
+	hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
+		&chn_cb_negotiate;
+	hv_kvp_deinit();
+
 	kfree(shut_txf_buf);
 	kfree(time_txf_buf);
 	kfree(hbeat_txf_buf);
drivers/staging/hv/utils.h +1 -0
index 7c07499..6d27d15 100644
@@ -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;
Signature · 1 line
1.7.1