aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2012-02-02 19:56:50 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-09 11:32:44 -0500
commit2640335438ca4d7b139e114dae5f0d80e740e106 (patch)
tree0e254e2147dedefe04e385d0c97a9fbc15df2a23 /drivers/hv
parenteab6af71f0b83a7f62b9c48be5b2c0a82a86fad3 (diff)
drivers: hv: kvp: Cleanup the kernel/user protocol
Now, cleanup the user/kernel KVP protocol by using the same structure definition that is used for host/guest KVP protocol. This simplifies the code. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/hv_kvp.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 4a6971e13539..0ef4c1f6ca54 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -71,15 +71,20 @@ kvp_register(void)
71{ 71{
72 72
73 struct cn_msg *msg; 73 struct cn_msg *msg;
74 struct hv_kvp_msg *kvp_msg;
75 char *version;
74 76
75 msg = kzalloc(sizeof(*msg) + strlen(HV_DRV_VERSION) + 1 , GFP_ATOMIC); 77 msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg), GFP_ATOMIC);
76 78
77 if (msg) { 79 if (msg) {
80 kvp_msg = (struct hv_kvp_msg *)msg->data;
81 version = kvp_msg->body.kvp_version;
78 msg->id.idx = CN_KVP_IDX; 82 msg->id.idx = CN_KVP_IDX;
79 msg->id.val = CN_KVP_VAL; 83 msg->id.val = CN_KVP_VAL;
80 msg->seq = KVP_REGISTER; 84
81 strcpy(msg->data, HV_DRV_VERSION); 85 kvp_msg->kvp_hdr.operation = KVP_OP_REGISTER;
82 msg->len = strlen(HV_DRV_VERSION) + 1; 86 strcpy(version, HV_DRV_VERSION);
87 msg->len = sizeof(struct hv_kvp_msg);
83 cn_netlink_send(msg, 0, GFP_ATOMIC); 88 cn_netlink_send(msg, 0, GFP_ATOMIC);
84 kfree(msg); 89 kfree(msg);
85 } 90 }
@@ -101,23 +106,24 @@ kvp_work_func(struct work_struct *dummy)
101static void 106static void
102kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp) 107kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
103{ 108{
104 struct hv_ku_msg *message; 109 struct hv_kvp_msg *message;
110 struct hv_kvp_msg_enumerate *data;
105 111
106 message = (struct hv_ku_msg *)msg->data; 112 message = (struct hv_kvp_msg *)msg->data;
107 if (msg->seq == KVP_REGISTER) { 113 if (message->kvp_hdr.operation == KVP_OP_REGISTER) {
108 pr_info("KVP: user-mode registering done.\n"); 114 pr_info("KVP: user-mode registering done.\n");
109 kvp_register(); 115 kvp_register();
110 } 116 }
111 117
112 if (msg->seq == KVP_USER_SET) { 118 if (message->kvp_hdr.operation == KVP_OP_ENUMERATE) {
119 data = &message->body.kvp_enum_data;
113 /* 120 /*
114 * Complete the transaction by forwarding the key value 121 * Complete the transaction by forwarding the key value
115 * to the host. But first, cancel the timeout. 122 * to the host. But first, cancel the timeout.
116 */ 123 */
117 if (cancel_delayed_work_sync(&kvp_work)) 124 if (cancel_delayed_work_sync(&kvp_work))
118 kvp_respond_to_host(message->kvp_key, 125 kvp_respond_to_host(data->data.key, data->data.value,
119 message->kvp_value, 126 !strlen(data->data.key));
120 !strlen(message->kvp_key));
121 } 127 }
122} 128}
123 129
@@ -125,6 +131,7 @@ static void
125kvp_send_key(struct work_struct *dummy) 131kvp_send_key(struct work_struct *dummy)
126{ 132{
127 struct cn_msg *msg; 133 struct cn_msg *msg;
134 struct hv_kvp_msg *message;
128 int index = kvp_transaction.index; 135 int index = kvp_transaction.index;
129 136
130 msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC); 137 msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC);
@@ -132,9 +139,11 @@ kvp_send_key(struct work_struct *dummy)
132 if (msg) { 139 if (msg) {
133 msg->id.idx = CN_KVP_IDX; 140 msg->id.idx = CN_KVP_IDX;
134 msg->id.val = CN_KVP_VAL; 141 msg->id.val = CN_KVP_VAL;
135 msg->seq = KVP_KERNEL_GET; 142
136 ((struct hv_ku_msg *)msg->data)->kvp_index = index; 143 message = (struct hv_kvp_msg *)msg->data;
137 msg->len = sizeof(struct hv_ku_msg); 144 message->kvp_hdr.operation = KVP_OP_ENUMERATE;
145 message->body.kvp_enum_data.index = index;
146 msg->len = sizeof(struct hv_kvp_msg);
138 cn_netlink_send(msg, 0, GFP_ATOMIC); 147 cn_netlink_send(msg, 0, GFP_ATOMIC);
139 kfree(msg); 148 kfree(msg);
140 } 149 }
@@ -191,7 +200,7 @@ kvp_respond_to_host(char *key, char *value, int error)
191 kvp_msg = (struct hv_kvp_msg *) 200 kvp_msg = (struct hv_kvp_msg *)
192 &recv_buffer[sizeof(struct vmbuspipe_hdr) + 201 &recv_buffer[sizeof(struct vmbuspipe_hdr) +
193 sizeof(struct icmsg_hdr)]; 202 sizeof(struct icmsg_hdr)];
194 kvp_data = &kvp_msg->kvp_data; 203 kvp_data = &kvp_msg->body.kvp_enum_data;
195 key_name = key; 204 key_name = key;
196 205
197 /* 206 /*
@@ -266,7 +275,7 @@ void hv_kvp_onchannelcallback(void *context)
266 sizeof(struct vmbuspipe_hdr) + 275 sizeof(struct vmbuspipe_hdr) +
267 sizeof(struct icmsg_hdr)]; 276 sizeof(struct icmsg_hdr)];
268 277
269 kvp_data = &kvp_msg->kvp_data; 278 kvp_data = &kvp_msg->body.kvp_enum_data;
270 279
271 /* 280 /*
272 * We only support the "get" operation on 281 * We only support the "get" operation on