Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197443
b: refs/heads/master
c: 9153f7b
h: refs/heads/master
i:
  197441: c9d81f7
  197439: ce75c91
v: v3
  • Loading branch information
Hank Janssen authored and Greg Kroah-Hartman committed May 17, 2010
1 parent 82c1d99 commit 79f67b1
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94002c07ff0e207a883519ccc35c0b5390b29331
refs/heads/master: 9153f7b997aef3fcfd0bf1eededfd76595c7dc0b
23 changes: 21 additions & 2 deletions trunk/drivers/staging/hv/channel_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct vmbus_channel_message_table_entry {
void (*messageHandler)(struct vmbus_channel_message_header *msg);
};

#define MAX_MSG_TYPES 2
#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 6
#define MAX_MSG_TYPES 3
#define MAX_NUM_DEVICE_CLASSES_SUPPORTED 7

static const struct hv_guid
gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
Expand Down Expand Up @@ -89,6 +89,14 @@ static const struct hv_guid
0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
}
},
/* {57164f39-9115-4e78-ab55-382f3bd5422d} */
/* Heartbeat */
{
.data = {
0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
}
},
};


Expand Down Expand Up @@ -211,6 +219,17 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
.callback = chn_cb_negotiate,
.log_msg = "Timesync channel functionality initialized"
},
/* {57164f39-9115-4e78-ab55-382f3bd5422d} */
/* Heartbeat */
{
.msg_type = HV_HEARTBEAT_MSG,
.data = {
0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
},
.callback = chn_cb_negotiate,
.log_msg = "Heartbeat channel functionality initialized"
},
};
EXPORT_SYMBOL(hv_cb_utils);

Expand Down
64 changes: 64 additions & 0 deletions trunk/drivers/staging/hv/hv_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,62 @@ static void timesync_onchannelcallback(void *context)
DPRINT_EXIT(VMBUS);
}

/*
* Heartbeat functionality.
* Every two seconds, Hyper-V send us a heartbeat request message.
* we respond to this message, and Hyper-V knows we are alive.
*/
static void heartbeat_onchannelcallback(void *context)
{
struct vmbus_channel *channel = context;
u8 *buf;
u32 buflen, recvlen;
u64 requestid;
struct icmsg_hdr *icmsghdrp;
struct heartbeat_msg_data *heartbeat_msg;

DPRINT_ENTER(VMBUS);

buflen = PAGE_SIZE;
buf = kmalloc(buflen, GFP_ATOMIC);

VmbusChannelRecvPacket(channel, buf, buflen, &recvlen, &requestid);

if (recvlen > 0) {
DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
recvlen, requestid);

icmsghdrp = (struct icmsg_hdr *)&buf[
sizeof(struct vmbuspipe_hdr)];

icmsghdrp = (struct icmsg_hdr *)&buf[
sizeof(struct vmbuspipe_hdr)];

if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
prep_negotiate_resp(icmsghdrp, NULL, buf);
} else {
heartbeat_msg = (struct heartbeat_msg_data *)&buf[
sizeof(struct vmbuspipe_hdr) +
sizeof(struct icmsg_hdr)];

DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
heartbeat_msg->seq_num);

heartbeat_msg->seq_num += 1;
}

icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
| ICMSGHDRFLAG_RESPONSE;

VmbusChannelSendPacket(channel, buf,
recvlen, requestid,
VmbusPacketTypeDataInBand, 0);
}

kfree(buf);

DPRINT_EXIT(VMBUS);
}

static int __init init_hyperv_utils(void)
{
Expand All @@ -207,6 +263,10 @@ static int __init init_hyperv_utils(void)
&timesync_onchannelcallback;
hv_cb_utils[HV_TIMESYNC_MSG].callback = &timesync_onchannelcallback;

hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback =
&heartbeat_onchannelcallback;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;

return 0;
}

Expand All @@ -221,6 +281,10 @@ static void exit_hyperv_utils(void)
hv_cb_utils[HV_TIMESYNC_MSG].channel->OnChannelCallback =
&chn_cb_negotiate;
hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;

hv_cb_utils[HV_HEARTBEAT_MSG].channel->OnChannelCallback =
&chn_cb_negotiate;
hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
}

module_init(init_hyperv_utils);
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/staging/hv/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ struct shutdown_msg_data {
u8 display_message[2048];
} __attribute__((packed));

struct heartbeat_msg_data {
u64 seq_num;
u32 reserved[8];
} __attribute__((packed));

/* Time Sync IC defs */
#define ICTIMESYNCFLAG_PROBE 0
Expand All @@ -97,6 +101,7 @@ struct ictimesync_data{
/* Index for each IC struct in array hv_cb_utils[] */
#define HV_SHUTDOWN_MSG 0
#define HV_TIMESYNC_MSG 1
#define HV_HEARTBEAT_MSG 2

struct hyperv_service_callback {
u8 msg_type;
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/staging/hv/version_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
* Minor Number Changes when new functionality is added
* to the Linux IC's that is not a bug fix.
*
* 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync
*/
#define HV_DRV_VERSION "3.0"
#define HV_DRV_VERSION "3.1"


#endif

0 comments on commit 79f67b1

Please sign in to comment.