diff options
author | Hank Janssen <hjanssen@microsoft.com> | 2010-05-15 17:39:58 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-17 19:32:30 -0400 |
commit | 9153f7b997aef3fcfd0bf1eededfd76595c7dc0b (patch) | |
tree | 5122ab51d6b722b34e93f3a11e608fa168151ff6 /drivers/staging | |
parent | 94002c07ff0e207a883519ccc35c0b5390b29331 (diff) |
staging: hv: Added heartbeat functionality to hv_utils
Add heartbeat functionality to hv_utils/Hyper-V
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/hv/channel_mgmt.c | 23 | ||||
-rw-r--r-- | drivers/staging/hv/hv_utils.c | 64 | ||||
-rw-r--r-- | drivers/staging/hv/utils.h | 5 | ||||
-rw-r--r-- | drivers/staging/hv/version_info.h | 3 |
4 files changed, 92 insertions, 3 deletions
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c index 6877e8e7f71e..3f53b4d1e4cf 100644 --- a/drivers/staging/hv/channel_mgmt.c +++ b/drivers/staging/hv/channel_mgmt.c | |||
@@ -33,8 +33,8 @@ struct vmbus_channel_message_table_entry { | |||
33 | void (*messageHandler)(struct vmbus_channel_message_header *msg); | 33 | void (*messageHandler)(struct vmbus_channel_message_header *msg); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | #define MAX_MSG_TYPES 2 | 36 | #define MAX_MSG_TYPES 3 |
37 | #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 6 | 37 | #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 7 |
38 | 38 | ||
39 | static const struct hv_guid | 39 | static const struct hv_guid |
40 | gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = { | 40 | gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = { |
@@ -89,6 +89,14 @@ static const struct hv_guid | |||
89 | 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf | 89 | 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf |
90 | } | 90 | } |
91 | }, | 91 | }, |
92 | /* {57164f39-9115-4e78-ab55-382f3bd5422d} */ | ||
93 | /* Heartbeat */ | ||
94 | { | ||
95 | .data = { | ||
96 | 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, | ||
97 | 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d | ||
98 | } | ||
99 | }, | ||
92 | }; | 100 | }; |
93 | 101 | ||
94 | 102 | ||
@@ -211,6 +219,17 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = { | |||
211 | .callback = chn_cb_negotiate, | 219 | .callback = chn_cb_negotiate, |
212 | .log_msg = "Timesync channel functionality initialized" | 220 | .log_msg = "Timesync channel functionality initialized" |
213 | }, | 221 | }, |
222 | /* {57164f39-9115-4e78-ab55-382f3bd5422d} */ | ||
223 | /* Heartbeat */ | ||
224 | { | ||
225 | .msg_type = HV_HEARTBEAT_MSG, | ||
226 | .data = { | ||
227 | 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, | ||
228 | 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d | ||
229 | }, | ||
230 | .callback = chn_cb_negotiate, | ||
231 | .log_msg = "Heartbeat channel functionality initialized" | ||
232 | }, | ||
214 | }; | 233 | }; |
215 | EXPORT_SYMBOL(hv_cb_utils); | 234 | EXPORT_SYMBOL(hv_cb_utils); |
216 | 235 | ||
diff --git a/drivers/staging/hv/hv_utils.c b/drivers/staging/hv/hv_utils.c index db45d97a3a7c..8a49aafea37a 100644 --- a/drivers/staging/hv/hv_utils.c +++ b/drivers/staging/hv/hv_utils.c | |||
@@ -194,6 +194,62 @@ static void timesync_onchannelcallback(void *context) | |||
194 | DPRINT_EXIT(VMBUS); | 194 | DPRINT_EXIT(VMBUS); |
195 | } | 195 | } |
196 | 196 | ||
197 | /* | ||
198 | * Heartbeat functionality. | ||
199 | * Every two seconds, Hyper-V send us a heartbeat request message. | ||
200 | * we respond to this message, and Hyper-V knows we are alive. | ||
201 | */ | ||
202 | static void heartbeat_onchannelcallback(void *context) | ||
203 | { | ||
204 | struct vmbus_channel *channel = context; | ||
205 | u8 *buf; | ||
206 | u32 buflen, recvlen; | ||
207 | u64 requestid; | ||
208 | struct icmsg_hdr *icmsghdrp; | ||
209 | struct heartbeat_msg_data *heartbeat_msg; | ||
210 | |||
211 | DPRINT_ENTER(VMBUS); | ||
212 | |||
213 | buflen = PAGE_SIZE; | ||
214 | buf = kmalloc(buflen, GFP_ATOMIC); | ||
215 | |||
216 | VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid); | ||
217 | |||
218 | if (recvlen > 0) { | ||
219 | DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld", | ||
220 | recvlen, requestid); | ||
221 | |||
222 | icmsghdrp = (struct icmsg_hdr *)&buf[ | ||
223 | sizeof(struct vmbuspipe_hdr)]; | ||
224 | |||
225 | icmsghdrp = (struct icmsg_hdr *)&buf[ | ||
226 | sizeof(struct vmbuspipe_hdr)]; | ||
227 | |||
228 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { | ||
229 | prep_negotiate_resp(icmsghdrp, NULL, buf); | ||
230 | } else { | ||
231 | heartbeat_msg = (struct heartbeat_msg_data *)&buf[ | ||
232 | sizeof(struct vmbuspipe_hdr) + | ||
233 | sizeof(struct icmsg_hdr)]; | ||
234 | |||
235 | DPRINT_DBG(VMBUS, "heartbeat seq = %lld", | ||
236 | heartbeat_msg->seq_num); | ||
237 | |||
238 | heartbeat_msg->seq_num += 1; | ||
239 | } | ||
240 | |||
241 | icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION | ||
242 | | ICMSGHDRFLAG_RESPONSE; | ||
243 | |||
244 | VmbusChannelSendPacket(channel, buf, | ||
245 | recvlen, requestid, | ||
246 | VmbusPacketTypeDataInBand, 0); | ||
247 | } | ||
248 | |||
249 | kfree(buf); | ||
250 | |||
251 | DPRINT_EXIT(VMBUS); | ||
252 | } | ||
197 | 253 | ||
198 | static int __init init_hyperv_utils(void) | 254 | static int __init init_hyperv_utils(void) |
199 | { | 255 | { |
@@ -207,6 +263,10 @@ static int __init init_hyperv_utils(void) | |||
207 | ×ync_onchannelcallback; | 263 | ×ync_onchannelcallback; |
208 | hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback; | 264 | hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback; |
209 | 265 | ||
266 | hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback = | ||
267 | &heartbeat_onchannelcallback; | ||
268 | hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback; | ||
269 | |||
210 | return 0; | 270 | return 0; |
211 | } | 271 | } |
212 | 272 | ||
@@ -221,6 +281,10 @@ static void exit_hyperv_utils(void) | |||
221 | hv_cb_utils[HV_TIMESYNC_MSG].channel->OnChannelCallback = | 281 | hv_cb_utils[HV_TIMESYNC_MSG].channel->OnChannelCallback = |
222 | &chn_cb_negotiate; | 282 | &chn_cb_negotiate; |
223 | hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate; | 283 | hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate; |
284 | |||
285 | hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback = | ||
286 | &chn_cb_negotiate; | ||
287 | hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate; | ||
224 | } | 288 | } |
225 | 289 | ||
226 | module_init(init_hyperv_utils); | 290 | module_init(init_hyperv_utils); |
diff --git a/drivers/staging/hv/utils.h b/drivers/staging/hv/utils.h index a4b9fd06e270..7c0749999a6f 100644 --- a/drivers/staging/hv/utils.h +++ b/drivers/staging/hv/utils.h | |||
@@ -75,6 +75,10 @@ struct shutdown_msg_data { | |||
75 | u8 display_message[2048]; | 75 | u8 display_message[2048]; |
76 | } __attribute__((packed)); | 76 | } __attribute__((packed)); |
77 | 77 | ||
78 | struct heartbeat_msg_data { | ||
79 | u64 seq_num; | ||
80 | u32 reserved[8]; | ||
81 | } __attribute__((packed)); | ||
78 | 82 | ||
79 | /* Time Sync IC defs */ | 83 | /* Time Sync IC defs */ |
80 | #define ICTIMESYNCFLAG_PROBE 0 | 84 | #define ICTIMESYNCFLAG_PROBE 0 |
@@ -97,6 +101,7 @@ struct ictimesync_data{ | |||
97 | /* Index for each IC struct in array hv_cb_utils[] */ | 101 | /* Index for each IC struct in array hv_cb_utils[] */ |
98 | #define HV_SHUTDOWN_MSG 0 | 102 | #define HV_SHUTDOWN_MSG 0 |
99 | #define HV_TIMESYNC_MSG 1 | 103 | #define HV_TIMESYNC_MSG 1 |
104 | #define HV_HEARTBEAT_MSG 2 | ||
100 | 105 | ||
101 | struct hyperv_service_callback { | 106 | struct hyperv_service_callback { |
102 | u8 msg_type; | 107 | u8 msg_type; |
diff --git a/drivers/staging/hv/version_info.h b/drivers/staging/hv/version_info.h index 82e74b1ab150..35178f2c7967 100644 --- a/drivers/staging/hv/version_info.h +++ b/drivers/staging/hv/version_info.h | |||
@@ -40,8 +40,9 @@ | |||
40 | * Minor Number Changes when new functionality is added | 40 | * Minor Number Changes when new functionality is added |
41 | * to the Linux IC's that is not a bug fix. | 41 | * to the Linux IC's that is not a bug fix. |
42 | * | 42 | * |
43 | * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync | ||
43 | */ | 44 | */ |
44 | #define HV_DRV_VERSION "3.0" | 45 | #define HV_DRV_VERSION "3.1" |
45 | 46 | ||
46 | 47 | ||
47 | #endif | 48 | #endif |