diff options
Diffstat (limited to 'drivers/hv/hv_util.c')
-rw-r--r-- | drivers/hv/hv_util.c | 71 |
1 files changed, 54 insertions, 17 deletions
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index cb82233541b1..273e3ddb3a20 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c | |||
@@ -28,17 +28,32 @@ | |||
28 | #include <linux/reboot.h> | 28 | #include <linux/reboot.h> |
29 | #include <linux/hyperv.h> | 29 | #include <linux/hyperv.h> |
30 | 30 | ||
31 | #define SHUTDOWN_MAJOR 3 | ||
32 | #define SHUTDOWN_MINOR 0 | ||
33 | #define SHUTDOWN_MAJOR_MINOR (SHUTDOWN_MAJOR << 16 | SHUTDOWN_MINOR) | ||
34 | 31 | ||
35 | #define TIMESYNCH_MAJOR 3 | 32 | #define SD_MAJOR 3 |
36 | #define TIMESYNCH_MINOR 0 | 33 | #define SD_MINOR 0 |
37 | #define TIMESYNCH_MAJOR_MINOR (TIMESYNCH_MAJOR << 16 | TIMESYNCH_MINOR) | 34 | #define SD_VERSION (SD_MAJOR << 16 | SD_MINOR) |
38 | 35 | ||
39 | #define HEARTBEAT_MAJOR 3 | 36 | #define SD_WS2008_MAJOR 1 |
40 | #define HEARTBEAT_MINOR 0 | 37 | #define SD_WS2008_VERSION (SD_WS2008_MAJOR << 16 | SD_MINOR) |
41 | #define HEARTBEAT_MAJOR_MINOR (HEARTBEAT_MAJOR << 16 | HEARTBEAT_MINOR) | 38 | |
39 | #define TS_MAJOR 3 | ||
40 | #define TS_MINOR 0 | ||
41 | #define TS_VERSION (TS_MAJOR << 16 | TS_MINOR) | ||
42 | |||
43 | #define TS_WS2008_MAJOR 1 | ||
44 | #define TS_WS2008_VERSION (TS_WS2008_MAJOR << 16 | TS_MINOR) | ||
45 | |||
46 | #define HB_MAJOR 3 | ||
47 | #define HB_MINOR 0 | ||
48 | #define HB_VERSION (HB_MAJOR << 16 | HB_MINOR) | ||
49 | |||
50 | #define HB_WS2008_MAJOR 1 | ||
51 | #define HB_WS2008_VERSION (HB_WS2008_MAJOR << 16 | HB_MINOR) | ||
52 | |||
53 | static int sd_srv_version; | ||
54 | static int ts_srv_version; | ||
55 | static int hb_srv_version; | ||
56 | static int util_fw_version; | ||
42 | 57 | ||
43 | static void shutdown_onchannelcallback(void *context); | 58 | static void shutdown_onchannelcallback(void *context); |
44 | static struct hv_util_service util_shutdown = { | 59 | static struct hv_util_service util_shutdown = { |
@@ -99,8 +114,8 @@ static void shutdown_onchannelcallback(void *context) | |||
99 | 114 | ||
100 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { | 115 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { |
101 | vmbus_prep_negotiate_resp(icmsghdrp, negop, | 116 | vmbus_prep_negotiate_resp(icmsghdrp, negop, |
102 | shut_txf_buf, UTIL_FW_MAJOR_MINOR, | 117 | shut_txf_buf, util_fw_version, |
103 | SHUTDOWN_MAJOR_MINOR); | 118 | sd_srv_version); |
104 | } else { | 119 | } else { |
105 | shutdown_msg = | 120 | shutdown_msg = |
106 | (struct shutdown_msg_data *)&shut_txf_buf[ | 121 | (struct shutdown_msg_data *)&shut_txf_buf[ |
@@ -216,6 +231,7 @@ static void timesync_onchannelcallback(void *context) | |||
216 | struct icmsg_hdr *icmsghdrp; | 231 | struct icmsg_hdr *icmsghdrp; |
217 | struct ictimesync_data *timedatap; | 232 | struct ictimesync_data *timedatap; |
218 | u8 *time_txf_buf = util_timesynch.recv_buffer; | 233 | u8 *time_txf_buf = util_timesynch.recv_buffer; |
234 | struct icmsg_negotiate *negop = NULL; | ||
219 | 235 | ||
220 | vmbus_recvpacket(channel, time_txf_buf, | 236 | vmbus_recvpacket(channel, time_txf_buf, |
221 | PAGE_SIZE, &recvlen, &requestid); | 237 | PAGE_SIZE, &recvlen, &requestid); |
@@ -225,9 +241,10 @@ static void timesync_onchannelcallback(void *context) | |||
225 | sizeof(struct vmbuspipe_hdr)]; | 241 | sizeof(struct vmbuspipe_hdr)]; |
226 | 242 | ||
227 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { | 243 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { |
228 | vmbus_prep_negotiate_resp(icmsghdrp, NULL, time_txf_buf, | 244 | vmbus_prep_negotiate_resp(icmsghdrp, negop, |
229 | UTIL_FW_MAJOR_MINOR, | 245 | time_txf_buf, |
230 | TIMESYNCH_MAJOR_MINOR); | 246 | util_fw_version, |
247 | ts_srv_version); | ||
231 | } else { | 248 | } else { |
232 | timedatap = (struct ictimesync_data *)&time_txf_buf[ | 249 | timedatap = (struct ictimesync_data *)&time_txf_buf[ |
233 | sizeof(struct vmbuspipe_hdr) + | 250 | sizeof(struct vmbuspipe_hdr) + |
@@ -257,6 +274,7 @@ static void heartbeat_onchannelcallback(void *context) | |||
257 | struct icmsg_hdr *icmsghdrp; | 274 | struct icmsg_hdr *icmsghdrp; |
258 | struct heartbeat_msg_data *heartbeat_msg; | 275 | struct heartbeat_msg_data *heartbeat_msg; |
259 | u8 *hbeat_txf_buf = util_heartbeat.recv_buffer; | 276 | u8 *hbeat_txf_buf = util_heartbeat.recv_buffer; |
277 | struct icmsg_negotiate *negop = NULL; | ||
260 | 278 | ||
261 | vmbus_recvpacket(channel, hbeat_txf_buf, | 279 | vmbus_recvpacket(channel, hbeat_txf_buf, |
262 | PAGE_SIZE, &recvlen, &requestid); | 280 | PAGE_SIZE, &recvlen, &requestid); |
@@ -266,9 +284,9 @@ static void heartbeat_onchannelcallback(void *context) | |||
266 | sizeof(struct vmbuspipe_hdr)]; | 284 | sizeof(struct vmbuspipe_hdr)]; |
267 | 285 | ||
268 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { | 286 | if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) { |
269 | vmbus_prep_negotiate_resp(icmsghdrp, NULL, | 287 | vmbus_prep_negotiate_resp(icmsghdrp, negop, |
270 | hbeat_txf_buf, UTIL_FW_MAJOR_MINOR, | 288 | hbeat_txf_buf, util_fw_version, |
271 | HEARTBEAT_MAJOR_MINOR); | 289 | hb_srv_version); |
272 | } else { | 290 | } else { |
273 | heartbeat_msg = | 291 | heartbeat_msg = |
274 | (struct heartbeat_msg_data *)&hbeat_txf_buf[ | 292 | (struct heartbeat_msg_data *)&hbeat_txf_buf[ |
@@ -321,6 +339,25 @@ static int util_probe(struct hv_device *dev, | |||
321 | goto error; | 339 | goto error; |
322 | 340 | ||
323 | hv_set_drvdata(dev, srv); | 341 | hv_set_drvdata(dev, srv); |
342 | /* | ||
343 | * Based on the host; initialize the framework and | ||
344 | * service version numbers we will negotiate. | ||
345 | */ | ||
346 | switch (vmbus_proto_version) { | ||
347 | case (VERSION_WS2008): | ||
348 | util_fw_version = UTIL_WS2K8_FW_VERSION; | ||
349 | sd_srv_version = SD_WS2008_VERSION; | ||
350 | ts_srv_version = TS_WS2008_VERSION; | ||
351 | hb_srv_version = HB_WS2008_VERSION; | ||
352 | break; | ||
353 | |||
354 | default: | ||
355 | util_fw_version = UTIL_FW_VERSION; | ||
356 | sd_srv_version = SD_VERSION; | ||
357 | ts_srv_version = TS_VERSION; | ||
358 | hb_srv_version = HB_VERSION; | ||
359 | } | ||
360 | |||
324 | return 0; | 361 | return 0; |
325 | 362 | ||
326 | error: | 363 | error: |