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