drm: Add adv7511 encoder driver
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / hv / hv_kvp.c
1 /*
2  * An implementation of key value pair (KVP) functionality for Linux.
3  *
4  *
5  * Copyright (C) 2010, Novell, Inc.
6  * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License version 2 as published
10  * by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
15  * NON INFRINGEMENT.  See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  */
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
25 #include <linux/net.h>
26 #include <linux/nls.h>
27 #include <linux/connector.h>
28 #include <linux/workqueue.h>
29 #include <linux/hyperv.h>
30
31
32 /*
33  * Pre win8 version numbers used in ws2008 and ws 2008 r2 (win7)
34  */
35 #define WS2008_SRV_MAJOR        1
36 #define WS2008_SRV_MINOR        0
37 #define WS2008_SRV_VERSION     (WS2008_SRV_MAJOR << 16 | WS2008_SRV_MINOR)
38
39 #define WIN7_SRV_MAJOR   3
40 #define WIN7_SRV_MINOR   0
41 #define WIN7_SRV_VERSION     (WIN7_SRV_MAJOR << 16 | WIN7_SRV_MINOR)
42
43 #define WIN8_SRV_MAJOR   4
44 #define WIN8_SRV_MINOR   0
45 #define WIN8_SRV_VERSION     (WIN8_SRV_MAJOR << 16 | WIN8_SRV_MINOR)
46
47 /*
48  * Global state maintained for transaction that is being processed.
49  * Note that only one transaction can be active at any point in time.
50  *
51  * This state is set when we receive a request from the host; we
52  * cleanup this state when the transaction is completed - when we respond
53  * to the host with the key value.
54  */
55
56 static struct {
57         bool active; /* transaction status - active or not */
58         int recv_len; /* number of bytes received. */
59         struct hv_kvp_msg  *kvp_msg; /* current message */
60         struct vmbus_channel *recv_channel; /* chn we got the request */
61         u64 recv_req_id; /* request ID. */
62         void *kvp_context; /* for the channel callback */
63 } kvp_transaction;
64
65 /*
66  * Before we can accept KVP messages from the host, we need
67  * to handshake with the user level daemon. This state tracks
68  * if we are in the handshake phase.
69  */
70 static bool in_hand_shake = true;
71
72 /*
73  * This state maintains the version number registered by the daemon.
74  */
75 static int dm_reg_value;
76
77 static void kvp_send_key(struct work_struct *dummy);
78
79
80 static void kvp_respond_to_host(struct hv_kvp_msg *msg, int error);
81 static void kvp_work_func(struct work_struct *dummy);
82 static void kvp_register(int);
83
84 static DECLARE_DELAYED_WORK(kvp_work, kvp_work_func);
85 static DECLARE_WORK(kvp_sendkey_work, kvp_send_key);
86
87 static struct cb_id kvp_id = { CN_KVP_IDX, CN_KVP_VAL };
88 static const char kvp_name[] = "kvp_kernel_module";
89 static u8 *recv_buffer;
90 /*
91  * Register the kernel component with the user-level daemon.
92  * As part of this registration, pass the LIC version number.
93  * This number has no meaning, it satisfies the registration protocol.
94  */
95 #define HV_DRV_VERSION           "3.1"
96
97 static void
98 kvp_register(int reg_value)
99 {
100
101         struct cn_msg *msg;
102         struct hv_kvp_msg *kvp_msg;
103         char *version;
104
105         msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg), GFP_ATOMIC);
106
107         if (msg) {
108                 kvp_msg = (struct hv_kvp_msg *)msg->data;
109                 version = kvp_msg->body.kvp_register.version;
110                 msg->id.idx =  CN_KVP_IDX;
111                 msg->id.val = CN_KVP_VAL;
112
113                 kvp_msg->kvp_hdr.operation = reg_value;
114                 strcpy(version, HV_DRV_VERSION);
115                 msg->len = sizeof(struct hv_kvp_msg);
116                 cn_netlink_send(msg, 0, GFP_ATOMIC);
117                 kfree(msg);
118         }
119 }
120 static void
121 kvp_work_func(struct work_struct *dummy)
122 {
123         /*
124          * If the timer fires, the user-mode component has not responded;
125          * process the pending transaction.
126          */
127         kvp_respond_to_host(NULL, HV_E_FAIL);
128 }
129
130 static void poll_channel(struct vmbus_channel *channel)
131 {
132         unsigned long flags;
133
134         spin_lock_irqsave(&channel->inbound_lock, flags);
135         hv_kvp_onchannelcallback(channel);
136         spin_unlock_irqrestore(&channel->inbound_lock, flags);
137 }
138
139 static int kvp_handle_handshake(struct hv_kvp_msg *msg)
140 {
141         int ret = 1;
142
143         switch (msg->kvp_hdr.operation) {
144         case KVP_OP_REGISTER:
145                 dm_reg_value = KVP_OP_REGISTER;
146                 pr_info("KVP: IP injection functionality not available\n");
147                 pr_info("KVP: Upgrade the KVP daemon\n");
148                 break;
149         case KVP_OP_REGISTER1:
150                 dm_reg_value = KVP_OP_REGISTER1;
151                 break;
152         default:
153                 pr_info("KVP: incompatible daemon\n");
154                 pr_info("KVP: KVP version: %d, Daemon version: %d\n",
155                         KVP_OP_REGISTER1, msg->kvp_hdr.operation);
156                 ret = 0;
157         }
158
159         if (ret) {
160                 /*
161                  * We have a compatible daemon; complete the handshake.
162                  */
163                 pr_info("KVP: user-mode registering done.\n");
164                 kvp_register(dm_reg_value);
165                 kvp_transaction.active = false;
166                 if (kvp_transaction.kvp_context)
167                         poll_channel(kvp_transaction.kvp_context);
168         }
169         return ret;
170 }
171
172
173 /*
174  * Callback when data is received from user mode.
175  */
176
177 static void
178 kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
179 {
180         struct hv_kvp_msg *message;
181         struct hv_kvp_msg_enumerate *data;
182         int     error = 0;
183
184         message = (struct hv_kvp_msg *)msg->data;
185
186         /*
187          * If we are negotiating the version information
188          * with the daemon; handle that first.
189          */
190
191         if (in_hand_shake) {
192                 if (kvp_handle_handshake(message))
193                         in_hand_shake = false;
194                 return;
195         }
196
197         /*
198          * Based on the version of the daemon, we propagate errors from the
199          * daemon differently.
200          */
201
202         data = &message->body.kvp_enum_data;
203
204         switch (dm_reg_value) {
205         case KVP_OP_REGISTER:
206                 /*
207                  * Null string is used to pass back error condition.
208                  */
209                 if (data->data.key[0] == 0)
210                         error = HV_S_CONT;
211                 break;
212
213         case KVP_OP_REGISTER1:
214                 /*
215                  * We use the message header information from
216                  * the user level daemon to transmit errors.
217                  */
218                 error = message->error;
219                 break;
220         }
221
222         /*
223          * Complete the transaction by forwarding the key value
224          * to the host. But first, cancel the timeout.
225          */
226         if (cancel_delayed_work_sync(&kvp_work))
227                 kvp_respond_to_host(message, error);
228 }
229
230
231 static int process_ob_ipinfo(void *in_msg, void *out_msg, int op)
232 {
233         struct hv_kvp_msg *in = in_msg;
234         struct hv_kvp_ip_msg *out = out_msg;
235         int len;
236
237         switch (op) {
238         case KVP_OP_GET_IP_INFO:
239                 /*
240                  * Transform all parameters into utf16 encoding.
241                  */
242                 len = utf8s_to_utf16s((char *)in->body.kvp_ip_val.ip_addr,
243                                 strlen((char *)in->body.kvp_ip_val.ip_addr),
244                                 UTF16_HOST_ENDIAN,
245                                 (wchar_t *)out->kvp_ip_val.ip_addr,
246                                 MAX_IP_ADDR_SIZE);
247                 if (len < 0)
248                         return len;
249
250                 len = utf8s_to_utf16s((char *)in->body.kvp_ip_val.sub_net,
251                                 strlen((char *)in->body.kvp_ip_val.sub_net),
252                                 UTF16_HOST_ENDIAN,
253                                 (wchar_t *)out->kvp_ip_val.sub_net,
254                                 MAX_IP_ADDR_SIZE);
255                 if (len < 0)
256                         return len;
257
258                 len = utf8s_to_utf16s((char *)in->body.kvp_ip_val.gate_way,
259                                 strlen((char *)in->body.kvp_ip_val.gate_way),
260                                 UTF16_HOST_ENDIAN,
261                                 (wchar_t *)out->kvp_ip_val.gate_way,
262                                 MAX_GATEWAY_SIZE);
263                 if (len < 0)
264                         return len;
265
266                 len = utf8s_to_utf16s((char *)in->body.kvp_ip_val.dns_addr,
267                                 strlen((char *)in->body.kvp_ip_val.dns_addr),
268                                 UTF16_HOST_ENDIAN,
269                                 (wchar_t *)out->kvp_ip_val.dns_addr,
270                                 MAX_IP_ADDR_SIZE);
271                 if (len < 0)
272                         return len;
273
274                 len = utf8s_to_utf16s((char *)in->body.kvp_ip_val.adapter_id,
275                                 strlen((char *)in->body.kvp_ip_val.adapter_id),
276                                 UTF16_HOST_ENDIAN,
277                                 (wchar_t *)out->kvp_ip_val.adapter_id,
278                                 MAX_IP_ADDR_SIZE);
279                 if (len < 0)
280                         return len;
281
282                 out->kvp_ip_val.dhcp_enabled =
283                         in->body.kvp_ip_val.dhcp_enabled;
284                 out->kvp_ip_val.addr_family =
285                         in->body.kvp_ip_val.addr_family;
286         }
287
288         return 0;
289 }
290
291 static void process_ib_ipinfo(void *in_msg, void *out_msg, int op)
292 {
293         struct hv_kvp_ip_msg *in = in_msg;
294         struct hv_kvp_msg *out = out_msg;
295
296         switch (op) {
297         case KVP_OP_SET_IP_INFO:
298                 /*
299                  * Transform all parameters into utf8 encoding.
300                  */
301                 utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.ip_addr,
302                                 MAX_IP_ADDR_SIZE,
303                                 UTF16_LITTLE_ENDIAN,
304                                 (__u8 *)out->body.kvp_ip_val.ip_addr,
305                                 MAX_IP_ADDR_SIZE);
306
307                 utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.sub_net,
308                                 MAX_IP_ADDR_SIZE,
309                                 UTF16_LITTLE_ENDIAN,
310                                 (__u8 *)out->body.kvp_ip_val.sub_net,
311                                 MAX_IP_ADDR_SIZE);
312
313                 utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.gate_way,
314                                 MAX_GATEWAY_SIZE,
315                                 UTF16_LITTLE_ENDIAN,
316                                 (__u8 *)out->body.kvp_ip_val.gate_way,
317                                 MAX_GATEWAY_SIZE);
318
319                 utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.dns_addr,
320                                 MAX_IP_ADDR_SIZE,
321                                 UTF16_LITTLE_ENDIAN,
322                                 (__u8 *)out->body.kvp_ip_val.dns_addr,
323                                 MAX_IP_ADDR_SIZE);
324
325                 out->body.kvp_ip_val.dhcp_enabled = in->kvp_ip_val.dhcp_enabled;
326
327         default:
328                 utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.adapter_id,
329                                 MAX_ADAPTER_ID_SIZE,
330                                 UTF16_LITTLE_ENDIAN,
331                                 (__u8 *)out->body.kvp_ip_val.adapter_id,
332                                 MAX_ADAPTER_ID_SIZE);
333
334                 out->body.kvp_ip_val.addr_family = in->kvp_ip_val.addr_family;
335         }
336 }
337
338
339
340
341 static void
342 kvp_send_key(struct work_struct *dummy)
343 {
344         struct cn_msg *msg;
345         struct hv_kvp_msg *message;
346         struct hv_kvp_msg *in_msg;
347         __u8 operation = kvp_transaction.kvp_msg->kvp_hdr.operation;
348         __u8 pool = kvp_transaction.kvp_msg->kvp_hdr.pool;
349         __u32 val32;
350         __u64 val64;
351
352         msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC);
353         if (!msg)
354                 return;
355
356         msg->id.idx =  CN_KVP_IDX;
357         msg->id.val = CN_KVP_VAL;
358
359         message = (struct hv_kvp_msg *)msg->data;
360         message->kvp_hdr.operation = operation;
361         message->kvp_hdr.pool = pool;
362         in_msg = kvp_transaction.kvp_msg;
363
364         /*
365          * The key/value strings sent from the host are encoded in
366          * in utf16; convert it to utf8 strings.
367          * The host assures us that the utf16 strings will not exceed
368          * the max lengths specified. We will however, reserve room
369          * for the string terminating character - in the utf16s_utf8s()
370          * function we limit the size of the buffer where the converted
371          * string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to gaurantee
372          * that the strings can be properly terminated!
373          */
374
375         switch (message->kvp_hdr.operation) {
376         case KVP_OP_SET_IP_INFO:
377                 process_ib_ipinfo(in_msg, message, KVP_OP_SET_IP_INFO);
378                 break;
379         case KVP_OP_GET_IP_INFO:
380                 process_ib_ipinfo(in_msg, message, KVP_OP_GET_IP_INFO);
381                 break;
382         case KVP_OP_SET:
383                 switch (in_msg->body.kvp_set.data.value_type) {
384                 case REG_SZ:
385                         /*
386                          * The value is a string - utf16 encoding.
387                          */
388                         message->body.kvp_set.data.value_size =
389                                 utf16s_to_utf8s(
390                                 (wchar_t *)in_msg->body.kvp_set.data.value,
391                                 in_msg->body.kvp_set.data.value_size,
392                                 UTF16_LITTLE_ENDIAN,
393                                 message->body.kvp_set.data.value,
394                                 HV_KVP_EXCHANGE_MAX_VALUE_SIZE - 1) + 1;
395                                 break;
396
397                 case REG_U32:
398                         /*
399                          * The value is a 32 bit scalar.
400                          * We save this as a utf8 string.
401                          */
402                         val32 = in_msg->body.kvp_set.data.value_u32;
403                         message->body.kvp_set.data.value_size =
404                                 sprintf(message->body.kvp_set.data.value,
405                                         "%d", val32) + 1;
406                         break;
407
408                 case REG_U64:
409                         /*
410                          * The value is a 64 bit scalar.
411                          * We save this as a utf8 string.
412                          */
413                         val64 = in_msg->body.kvp_set.data.value_u64;
414                         message->body.kvp_set.data.value_size =
415                                 sprintf(message->body.kvp_set.data.value,
416                                         "%llu", val64) + 1;
417                         break;
418
419                 }
420         case KVP_OP_GET:
421                 message->body.kvp_set.data.key_size =
422                         utf16s_to_utf8s(
423                         (wchar_t *)in_msg->body.kvp_set.data.key,
424                         in_msg->body.kvp_set.data.key_size,
425                         UTF16_LITTLE_ENDIAN,
426                         message->body.kvp_set.data.key,
427                         HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1;
428                         break;
429
430         case KVP_OP_DELETE:
431                 message->body.kvp_delete.key_size =
432                         utf16s_to_utf8s(
433                         (wchar_t *)in_msg->body.kvp_delete.key,
434                         in_msg->body.kvp_delete.key_size,
435                         UTF16_LITTLE_ENDIAN,
436                         message->body.kvp_delete.key,
437                         HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1;
438                         break;
439
440         case KVP_OP_ENUMERATE:
441                 message->body.kvp_enum_data.index =
442                         in_msg->body.kvp_enum_data.index;
443                         break;
444         }
445
446         msg->len = sizeof(struct hv_kvp_msg);
447         cn_netlink_send(msg, 0, GFP_ATOMIC);
448         kfree(msg);
449
450         return;
451 }
452
453 /*
454  * Send a response back to the host.
455  */
456
457 static void
458 kvp_respond_to_host(struct hv_kvp_msg *msg_to_host, int error)
459 {
460         struct hv_kvp_msg  *kvp_msg;
461         struct hv_kvp_exchg_msg_value  *kvp_data;
462         char    *key_name;
463         char    *value;
464         struct icmsg_hdr *icmsghdrp;
465         int     keylen = 0;
466         int     valuelen = 0;
467         u32     buf_len;
468         struct vmbus_channel *channel;
469         u64     req_id;
470         int ret;
471
472         /*
473          * If a transaction is not active; log and return.
474          */
475
476         if (!kvp_transaction.active) {
477                 /*
478                  * This is a spurious call!
479                  */
480                 pr_warn("KVP: Transaction not active\n");
481                 return;
482         }
483         /*
484          * Copy the global state for completing the transaction. Note that
485          * only one transaction can be active at a time.
486          */
487
488         buf_len = kvp_transaction.recv_len;
489         channel = kvp_transaction.recv_channel;
490         req_id = kvp_transaction.recv_req_id;
491
492         kvp_transaction.active = false;
493
494         icmsghdrp = (struct icmsg_hdr *)
495                         &recv_buffer[sizeof(struct vmbuspipe_hdr)];
496
497         if (channel->onchannel_callback == NULL)
498                 /*
499                  * We have raced with util driver being unloaded;
500                  * silently return.
501                  */
502                 return;
503
504         icmsghdrp->status = error;
505
506         /*
507          * If the error parameter is set, terminate the host's enumeration
508          * on this pool.
509          */
510         if (error) {
511                 /*
512                  * Something failed or we have timedout;
513                  * terminate the current host-side iteration.
514                  */
515                 goto response_done;
516         }
517
518         kvp_msg = (struct hv_kvp_msg *)
519                         &recv_buffer[sizeof(struct vmbuspipe_hdr) +
520                         sizeof(struct icmsg_hdr)];
521
522         switch (kvp_transaction.kvp_msg->kvp_hdr.operation) {
523         case KVP_OP_GET_IP_INFO:
524                 ret = process_ob_ipinfo(msg_to_host,
525                                  (struct hv_kvp_ip_msg *)kvp_msg,
526                                  KVP_OP_GET_IP_INFO);
527                 if (ret < 0)
528                         icmsghdrp->status = HV_E_FAIL;
529
530                 goto response_done;
531         case KVP_OP_SET_IP_INFO:
532                 goto response_done;
533         case KVP_OP_GET:
534                 kvp_data = &kvp_msg->body.kvp_get.data;
535                 goto copy_value;
536
537         case KVP_OP_SET:
538         case KVP_OP_DELETE:
539                 goto response_done;
540
541         default:
542                 break;
543         }
544
545         kvp_data = &kvp_msg->body.kvp_enum_data.data;
546         key_name = msg_to_host->body.kvp_enum_data.data.key;
547
548         /*
549          * The windows host expects the key/value pair to be encoded
550          * in utf16. Ensure that the key/value size reported to the host
551          * will be less than or equal to the MAX size (including the
552          * terminating character).
553          */
554         keylen = utf8s_to_utf16s(key_name, strlen(key_name), UTF16_HOST_ENDIAN,
555                                 (wchar_t *) kvp_data->key,
556                                 (HV_KVP_EXCHANGE_MAX_KEY_SIZE / 2) - 2);
557         kvp_data->key_size = 2*(keylen + 1); /* utf16 encoding */
558
559 copy_value:
560         value = msg_to_host->body.kvp_enum_data.data.value;
561         valuelen = utf8s_to_utf16s(value, strlen(value), UTF16_HOST_ENDIAN,
562                                 (wchar_t *) kvp_data->value,
563                                 (HV_KVP_EXCHANGE_MAX_VALUE_SIZE / 2) - 2);
564         kvp_data->value_size = 2*(valuelen + 1); /* utf16 encoding */
565
566         /*
567          * If the utf8s to utf16s conversion failed; notify host
568          * of the error.
569          */
570         if ((keylen < 0) || (valuelen < 0))
571                 icmsghdrp->status = HV_E_FAIL;
572
573         kvp_data->value_type = REG_SZ; /* all our values are strings */
574
575 response_done:
576         icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE;
577
578         vmbus_sendpacket(channel, recv_buffer, buf_len, req_id,
579                                 VM_PKT_DATA_INBAND, 0);
580         poll_channel(channel);
581
582 }
583
584 /*
585  * This callback is invoked when we get a KVP message from the host.
586  * The host ensures that only one KVP transaction can be active at a time.
587  * KVP implementation in Linux needs to forward the key to a user-mde
588  * component to retrive the corresponding value. Consequently, we cannot
589  * respond to the host in the conext of this callback. Since the host
590  * guarantees that at most only one transaction can be active at a time,
591  * we stash away the transaction state in a set of global variables.
592  */
593
594 void hv_kvp_onchannelcallback(void *context)
595 {
596         struct vmbus_channel *channel = context;
597         u32 recvlen;
598         u64 requestid;
599
600         struct hv_kvp_msg *kvp_msg;
601
602         struct icmsg_hdr *icmsghdrp;
603         struct icmsg_negotiate *negop = NULL;
604         int util_fw_version;
605         int kvp_srv_version;
606
607         if (kvp_transaction.active) {
608                 /*
609                  * We will defer processing this callback once
610                  * the current transaction is complete.
611                  */
612                 kvp_transaction.kvp_context = context;
613                 return;
614         }
615
616         vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen,
617                          &requestid);
618
619         if (recvlen > 0) {
620                 icmsghdrp = (struct icmsg_hdr *)&recv_buffer[
621                         sizeof(struct vmbuspipe_hdr)];
622
623                 if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
624                         /*
625                          * Based on the host, select appropriate
626                          * framework and service versions we will
627                          * negotiate.
628                          */
629                         switch (vmbus_proto_version) {
630                         case (VERSION_WS2008):
631                                 util_fw_version = UTIL_WS2K8_FW_VERSION;
632                                 kvp_srv_version = WS2008_SRV_VERSION;
633                                 break;
634                         case (VERSION_WIN7):
635                                 util_fw_version = UTIL_FW_VERSION;
636                                 kvp_srv_version = WIN7_SRV_VERSION;
637                                 break;
638                         default:
639                                 util_fw_version = UTIL_FW_VERSION;
640                                 kvp_srv_version = WIN8_SRV_VERSION;
641                         }
642                         vmbus_prep_negotiate_resp(icmsghdrp, negop,
643                                  recv_buffer, util_fw_version,
644                                  kvp_srv_version);
645
646                 } else {
647                         kvp_msg = (struct hv_kvp_msg *)&recv_buffer[
648                                 sizeof(struct vmbuspipe_hdr) +
649                                 sizeof(struct icmsg_hdr)];
650
651                         /*
652                          * Stash away this global state for completing the
653                          * transaction; note transactions are serialized.
654                          */
655
656                         kvp_transaction.recv_len = recvlen;
657                         kvp_transaction.recv_channel = channel;
658                         kvp_transaction.recv_req_id = requestid;
659                         kvp_transaction.active = true;
660                         kvp_transaction.kvp_msg = kvp_msg;
661
662                         /*
663                          * Get the information from the
664                          * user-mode component.
665                          * component. This transaction will be
666                          * completed when we get the value from
667                          * the user-mode component.
668                          * Set a timeout to deal with
669                          * user-mode not responding.
670                          */
671                         schedule_work(&kvp_sendkey_work);
672                         schedule_delayed_work(&kvp_work, 5*HZ);
673
674                         return;
675
676                 }
677
678                 icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
679                         | ICMSGHDRFLAG_RESPONSE;
680
681                 vmbus_sendpacket(channel, recv_buffer,
682                                        recvlen, requestid,
683                                        VM_PKT_DATA_INBAND, 0);
684         }
685
686 }
687
688 int
689 hv_kvp_init(struct hv_util_service *srv)
690 {
691         int err;
692
693         err = cn_add_callback(&kvp_id, kvp_name, kvp_cn_callback);
694         if (err)
695                 return err;
696         recv_buffer = srv->recv_buffer;
697
698         /*
699          * When this driver loads, the user level daemon that
700          * processes the host requests may not yet be running.
701          * Defer processing channel callbacks until the daemon
702          * has registered.
703          */
704         kvp_transaction.active = true;
705
706         return 0;
707 }
708
709 void hv_kvp_deinit(void)
710 {
711         cn_del_callback(&kvp_id);
712         cancel_delayed_work_sync(&kvp_work);
713         cancel_work_sync(&kvp_sendkey_work);
714 }