~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/staging/hv/hv_util.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *   Haiyang Zhang <haiyangz@microsoft.com>
19
19
 *   Hank Janssen  <hjanssen@microsoft.com>
20
20
 */
 
21
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
22
 
21
23
#include <linux/kernel.h>
22
24
#include <linux/init.h>
23
25
#include <linux/module.h>
27
29
#include <linux/dmi.h>
28
30
#include <linux/pci.h>
29
31
 
30
 
#include "logging.h"
31
 
#include "hv_api.h"
32
 
#include "vmbus.h"
33
 
#include "vmbus_packet_format.h"
34
 
#include "vmbus_channel_interface.h"
35
 
#include "version_info.h"
36
 
#include "channel.h"
37
 
#include "vmbus_private.h"
38
 
#include "vmbus_api.h"
39
 
#include "utils.h"
 
32
#include "hyperv.h"
40
33
#include "hv_kvp.h"
41
34
 
42
35
static u8 *shut_txf_buf;
59
52
                         PAGE_SIZE, &recvlen, &requestid);
60
53
 
61
54
        if (recvlen > 0) {
62
 
                DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
63
 
                           recvlen, requestid);
64
 
 
65
55
                icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[
66
56
                        sizeof(struct vmbuspipe_hdr)];
67
57
 
79
69
                                icmsghdrp->status = HV_S_OK;
80
70
                                execute_shutdown = true;
81
71
 
82
 
                                DPRINT_INFO(VMBUS, "Shutdown request received -"
83
 
                                            " graceful shutdown initiated");
 
72
                                pr_info("Shutdown request received -"
 
73
                                            " graceful shutdown initiated\n");
84
74
                                break;
85
75
                        default:
86
76
                                icmsghdrp->status = HV_E_FAIL;
87
77
                                execute_shutdown = false;
88
78
 
89
 
                                DPRINT_INFO(VMBUS, "Shutdown request received -"
90
 
                                            " Invalid request");
 
79
                                pr_info("Shutdown request received -"
 
80
                                            " Invalid request\n");
91
81
                                break;
92
 
                        };
 
82
                        }
93
83
                }
94
84
 
95
85
                icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
159
149
                         PAGE_SIZE, &recvlen, &requestid);
160
150
 
161
151
        if (recvlen > 0) {
162
 
                DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
163
 
                        recvlen, requestid);
164
 
 
165
152
                icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[
166
153
                                sizeof(struct vmbuspipe_hdr)];
167
154
 
200
187
                         PAGE_SIZE, &recvlen, &requestid);
201
188
 
202
189
        if (recvlen > 0) {
203
 
                DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
204
 
                           recvlen, requestid);
205
 
 
206
190
                icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[
207
191
                                sizeof(struct vmbuspipe_hdr)];
208
192
 
214
198
                                        sizeof(struct vmbuspipe_hdr) +
215
199
                                        sizeof(struct icmsg_hdr)];
216
200
 
217
 
                        DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
218
 
                                   heartbeat_msg->seq_num);
219
 
 
220
201
                        heartbeat_msg->seq_num += 1;
221
202
                }
222
203
 
254
235
 
255
236
static int __init init_hyperv_utils(void)
256
237
{
257
 
        printk(KERN_INFO "Registering HyperV Utility Driver\n");
 
238
        pr_info("Registering HyperV Utility Driver\n");
258
239
 
259
240
        if (hv_kvp_init())
260
241
                return -ENODEV;
268
249
        hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
269
250
 
270
251
        if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
271
 
                printk(KERN_INFO
272
 
                       "Unable to allocate memory for receive buffer\n");
 
252
                pr_info("Unable to allocate memory for receive buffer\n");
273
253
                kfree(shut_txf_buf);
274
254
                kfree(time_txf_buf);
275
255
                kfree(hbeat_txf_buf);
276
256
                return -ENOMEM;
277
257
        }
278
258
 
279
 
        hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
280
 
                &shutdown_onchannelcallback;
281
259
        hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
282
260
 
283
 
        hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
284
 
                &timesync_onchannelcallback;
285
261
        hv_cb_utils[HV_TIMESYNC_MSG].callback = &timesync_onchannelcallback;
286
262
 
287
 
        hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
288
 
                &heartbeat_onchannelcallback;
289
263
        hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
290
264
 
291
 
        hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
292
 
                &hv_kvp_onchannelcallback;
293
 
 
294
 
 
 
265
        hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
295
266
 
296
267
        return 0;
297
268
}
298
269
 
299
270
static void exit_hyperv_utils(void)
300
271
{
301
 
        printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
302
 
 
303
 
        hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
304
 
                &chn_cb_negotiate;
305
 
        hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
306
 
 
307
 
        hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
308
 
                &chn_cb_negotiate;
309
 
        hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
310
 
 
311
 
        hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
312
 
                &chn_cb_negotiate;
313
 
        hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
314
 
 
315
 
        hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
316
 
                &chn_cb_negotiate;
 
272
        pr_info("De-Registered HyperV Utility Driver\n");
 
273
 
 
274
        if (hv_cb_utils[HV_SHUTDOWN_MSG].channel != NULL)
 
275
                hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
 
276
                        &chn_cb_negotiate;
 
277
        hv_cb_utils[HV_SHUTDOWN_MSG].callback = NULL;
 
278
 
 
279
        if (hv_cb_utils[HV_TIMESYNC_MSG].channel != NULL)
 
280
                hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
 
281
                        &chn_cb_negotiate;
 
282
        hv_cb_utils[HV_TIMESYNC_MSG].callback = NULL;
 
283
 
 
284
        if (hv_cb_utils[HV_HEARTBEAT_MSG].channel != NULL)
 
285
                hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
 
286
                        &chn_cb_negotiate;
 
287
        hv_cb_utils[HV_HEARTBEAT_MSG].callback = NULL;
 
288
 
 
289
        if (hv_cb_utils[HV_KVP_MSG].channel != NULL)
 
290
                hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
 
291
                        &chn_cb_negotiate;
 
292
        hv_cb_utils[HV_KVP_MSG].callback = NULL;
 
293
 
317
294
        hv_kvp_deinit();
318
295
 
319
296
        kfree(shut_txf_buf);