blob: a596039d02ab8a50018764897a48b262ddaab77d [file] [log] [blame]
K. Y. Srinivasan5c473402011-05-12 19:34:14 -07001/*
2 *
3 * Copyright (c) 2011, Microsoft Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 * K. Y. Srinivasan <kys@microsoft.com>
22 *
23 */
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -070024
25#ifndef _HYPERV_H
26#define _HYPERV_H
27
28struct hv_guid {
29 unsigned char data[16];
30};
31
K. Y. Srinivasana363bf72011-05-12 19:34:16 -070032#define MAX_PAGE_BUFFER_COUNT 16
33#define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
34
35#pragma pack(push, 1)
36
37/* Single-page buffer */
38struct hv_page_buffer {
39 u32 len;
40 u32 offset;
41 u64 pfn;
42};
43
44/* Multiple-page buffer */
45struct hv_multipage_buffer {
46 /* Length and Offset determines the # of pfns in the array */
47 u32 len;
48 u32 offset;
49 u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT];
50};
51
52/* 0x18 includes the proprietary packet header */
53#define MAX_PAGE_BUFFER_PACKET (0x18 + \
54 (sizeof(struct hv_page_buffer) * \
55 MAX_PAGE_BUFFER_COUNT))
56#define MAX_MULTIPAGE_BUFFER_PACKET (0x18 + \
57 sizeof(struct hv_multipage_buffer))
58
59
60#pragma pack(pop)
61
K. Y. Srinivasan7effffb2011-05-12 19:34:17 -070062struct hv_ring_buffer {
63 /* Offset in bytes from the start of ring data below */
64 u32 write_index;
65
66 /* Offset in bytes from the start of ring data below */
67 u32 read_index;
68
69 u32 interrupt_mask;
70
71 /* Pad it to PAGE_SIZE so that data starts on page boundary */
72 u8 reserved[4084];
73
74 /* NOTE:
75 * The interrupt_mask field is used only for channels but since our
76 * vmbus connection also uses this data structure and its data starts
77 * here, we commented out this field.
78 */
79
80 /*
81 * Ring data starts here + RingDataStartOffset
82 * !!! DO NOT place any fields below this !!!
83 */
84 u8 buffer[0];
85} __packed;
86
87struct hv_ring_buffer_info {
88 struct hv_ring_buffer *ring_buffer;
89 u32 ring_size; /* Include the shared header */
90 spinlock_t ring_lock;
91
92 u32 ring_datasize; /* < ring_size */
93 u32 ring_data_startoffset;
94};
95
96struct hv_ring_buffer_debug_info {
97 u32 current_interrupt_mask;
98 u32 current_read_index;
99 u32 current_write_index;
100 u32 bytes_avail_toread;
101 u32 bytes_avail_towrite;
102};
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -0700103
K. Y. Srinivasanf7c6dfd2011-05-12 19:34:18 -0700104/*
105 * We use the same version numbering for all Hyper-V modules.
106 *
107 * Definition of versioning is as follows;
108 *
109 * Major Number Changes for these scenarios;
110 * 1. When a new version of Windows Hyper-V
111 * is released.
112 * 2. A Major change has occurred in the
113 * Linux IC's.
114 * (For example the merge for the first time
115 * into the kernel) Every time the Major Number
116 * changes, the Revision number is reset to 0.
117 * Minor Number Changes when new functionality is added
118 * to the Linux IC's that is not a bug fix.
119 *
120 * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync
121 */
122#define HV_DRV_VERSION "3.1"
123
124
K. Y. Srinivasan517d8dc2011-05-12 19:34:19 -0700125/*
126 * A revision number of vmbus that is used for ensuring both ends on a
127 * partition are using compatible versions.
128 */
129#define VMBUS_REVISION_NUMBER 13
130
131/* Make maximum size of pipe payload of 16K */
132#define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384)
133
134/* Define PipeMode values. */
135#define VMBUS_PIPE_TYPE_BYTE 0x00000000
136#define VMBUS_PIPE_TYPE_MESSAGE 0x00000004
137
138/* The size of the user defined data buffer for non-pipe offers. */
139#define MAX_USER_DEFINED_BYTES 120
140
141/* The size of the user defined data buffer for pipe offers. */
142#define MAX_PIPE_USER_DEFINED_BYTES 116
143
144/*
145 * At the center of the Channel Management library is the Channel Offer. This
146 * struct contains the fundamental information about an offer.
147 */
148struct vmbus_channel_offer {
149 struct hv_guid if_type;
150 struct hv_guid if_instance;
151 u64 int_latency; /* in 100ns units */
152 u32 if_revision;
153 u32 server_ctx_size; /* in bytes */
154 u16 chn_flags;
155 u16 mmio_megabytes; /* in bytes * 1024 * 1024 */
156
157 union {
158 /* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */
159 struct {
160 unsigned char user_def[MAX_USER_DEFINED_BYTES];
161 } std;
162
163 /*
164 * Pipes:
165 * The following sructure is an integrated pipe protocol, which
166 * is implemented on top of standard user-defined data. Pipe
167 * clients have MAX_PIPE_USER_DEFINED_BYTES left for their own
168 * use.
169 */
170 struct {
171 u32 pipe_mode;
172 unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES];
173 } pipe;
174 } u;
175 u32 padding;
176} __packed;
177
178/* Server Flags */
179#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 1
180#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 2
181#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 4
182#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10
183#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100
184#define VMBUS_CHANNEL_PARENT_OFFER 0x200
185#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400
186
K. Y. Srinivasan50ed40e2011-05-12 19:34:20 -0700187struct vmpacket_descriptor {
188 u16 type;
189 u16 offset8;
190 u16 len8;
191 u16 flags;
192 u64 trans_id;
193} __packed;
194
195struct vmpacket_header {
196 u32 prev_pkt_start_offset;
197 struct vmpacket_descriptor descriptor;
198} __packed;
199
200struct vmtransfer_page_range {
201 u32 byte_count;
202 u32 byte_offset;
203} __packed;
204
205struct vmtransfer_page_packet_header {
206 struct vmpacket_descriptor d;
207 u16 xfer_pageset_id;
208 bool sender_owns_set;
209 u8 reserved;
210 u32 range_cnt;
211 struct vmtransfer_page_range ranges[1];
212} __packed;
213
214struct vmgpadl_packet_header {
215 struct vmpacket_descriptor d;
216 u32 gpadl;
217 u32 reserved;
218} __packed;
219
220struct vmadd_remove_transfer_page_set {
221 struct vmpacket_descriptor d;
222 u32 gpadl;
223 u16 xfer_pageset_id;
224 u16 reserved;
225} __packed;
226
227/*
228 * This structure defines a range in guest physical space that can be made to
229 * look virtually contiguous.
230 */
231struct gpa_range {
232 u32 byte_count;
233 u32 byte_offset;
234 u64 pfn_array[0];
235};
236
237/*
238 * This is the format for an Establish Gpadl packet, which contains a handle by
239 * which this GPADL will be known and a set of GPA ranges associated with it.
240 * This can be converted to a MDL by the guest OS. If there are multiple GPA
241 * ranges, then the resulting MDL will be "chained," representing multiple VA
242 * ranges.
243 */
244struct vmestablish_gpadl {
245 struct vmpacket_descriptor d;
246 u32 gpadl;
247 u32 range_cnt;
248 struct gpa_range range[1];
249} __packed;
250
251/*
252 * This is the format for a Teardown Gpadl packet, which indicates that the
253 * GPADL handle in the Establish Gpadl packet will never be referenced again.
254 */
255struct vmteardown_gpadl {
256 struct vmpacket_descriptor d;
257 u32 gpadl;
258 u32 reserved; /* for alignment to a 8-byte boundary */
259} __packed;
260
261/*
262 * This is the format for a GPA-Direct packet, which contains a set of GPA
263 * ranges, in addition to commands and/or data.
264 */
265struct vmdata_gpa_direct {
266 struct vmpacket_descriptor d;
267 u32 reserved;
268 u32 range_cnt;
269 struct gpa_range range[1];
270} __packed;
271
272/* This is the format for a Additional Data Packet. */
273struct vmadditional_data {
274 struct vmpacket_descriptor d;
275 u64 total_bytes;
276 u32 offset;
277 u32 byte_cnt;
278 unsigned char data[1];
279} __packed;
280
281union vmpacket_largest_possible_header {
282 struct vmpacket_descriptor simple_hdr;
283 struct vmtransfer_page_packet_header xfer_page_hdr;
284 struct vmgpadl_packet_header gpadl_hdr;
285 struct vmadd_remove_transfer_page_set add_rm_xfer_page_hdr;
286 struct vmestablish_gpadl establish_gpadl_hdr;
287 struct vmteardown_gpadl teardown_gpadl_hdr;
288 struct vmdata_gpa_direct data_gpa_direct_hdr;
289};
290
291#define VMPACKET_DATA_START_ADDRESS(__packet) \
292 (void *)(((unsigned char *)__packet) + \
293 ((struct vmpacket_descriptor)__packet)->offset8 * 8)
294
295#define VMPACKET_DATA_LENGTH(__packet) \
296 ((((struct vmpacket_descriptor)__packet)->len8 - \
297 ((struct vmpacket_descriptor)__packet)->offset8) * 8)
298
299#define VMPACKET_TRANSFER_MODE(__packet) \
300 (((struct IMPACT)__packet)->type)
301
302enum vmbus_packet_type {
303 VM_PKT_INVALID = 0x0,
304 VM_PKT_SYNCH = 0x1,
305 VM_PKT_ADD_XFER_PAGESET = 0x2,
306 VM_PKT_RM_XFER_PAGESET = 0x3,
307 VM_PKT_ESTABLISH_GPADL = 0x4,
308 VM_PKT_TEARDOWN_GPADL = 0x5,
309 VM_PKT_DATA_INBAND = 0x6,
310 VM_PKT_DATA_USING_XFER_PAGES = 0x7,
311 VM_PKT_DATA_USING_GPADL = 0x8,
312 VM_PKT_DATA_USING_GPA_DIRECT = 0x9,
313 VM_PKT_CANCEL_REQUEST = 0xa,
314 VM_PKT_COMP = 0xb,
315 VM_PKT_DATA_USING_ADDITIONAL_PKT = 0xc,
316 VM_PKT_ADDITIONAL_DATA = 0xd
317};
318
319#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1
K. Y. Srinivasan517d8dc2011-05-12 19:34:19 -0700320
K. Y. Srinivasanb56dda02011-05-12 19:34:21 -0700321
322#include <linux/list.h>
323#include <linux/timer.h>
324#include <linux/workqueue.h>
325#include <linux/completion.h>
326#include "hyperv.h"
327
328/* Version 1 messages */
329enum vmbus_channel_message_type {
330 CHANNELMSG_INVALID = 0,
331 CHANNELMSG_OFFERCHANNEL = 1,
332 CHANNELMSG_RESCIND_CHANNELOFFER = 2,
333 CHANNELMSG_REQUESTOFFERS = 3,
334 CHANNELMSG_ALLOFFERS_DELIVERED = 4,
335 CHANNELMSG_OPENCHANNEL = 5,
336 CHANNELMSG_OPENCHANNEL_RESULT = 6,
337 CHANNELMSG_CLOSECHANNEL = 7,
338 CHANNELMSG_GPADL_HEADER = 8,
339 CHANNELMSG_GPADL_BODY = 9,
340 CHANNELMSG_GPADL_CREATED = 10,
341 CHANNELMSG_GPADL_TEARDOWN = 11,
342 CHANNELMSG_GPADL_TORNDOWN = 12,
343 CHANNELMSG_RELID_RELEASED = 13,
344 CHANNELMSG_INITIATE_CONTACT = 14,
345 CHANNELMSG_VERSION_RESPONSE = 15,
346 CHANNELMSG_UNLOAD = 16,
347#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
348 CHANNELMSG_VIEWRANGE_ADD = 17,
349 CHANNELMSG_VIEWRANGE_REMOVE = 18,
350#endif
351 CHANNELMSG_COUNT
352};
353
354struct vmbus_channel_message_header {
355 enum vmbus_channel_message_type msgtype;
356 u32 padding;
357} __packed;
358
359/* Query VMBus Version parameters */
360struct vmbus_channel_query_vmbus_version {
361 struct vmbus_channel_message_header header;
362 u32 version;
363} __packed;
364
365/* VMBus Version Supported parameters */
366struct vmbus_channel_version_supported {
367 struct vmbus_channel_message_header header;
368 bool version_supported;
369} __packed;
370
371/* Offer Channel parameters */
372struct vmbus_channel_offer_channel {
373 struct vmbus_channel_message_header header;
374 struct vmbus_channel_offer offer;
375 u32 child_relid;
376 u8 monitorid;
377 bool monitor_allocated;
378} __packed;
379
380/* Rescind Offer parameters */
381struct vmbus_channel_rescind_offer {
382 struct vmbus_channel_message_header header;
383 u32 child_relid;
384} __packed;
385
386/*
387 * Request Offer -- no parameters, SynIC message contains the partition ID
388 * Set Snoop -- no parameters, SynIC message contains the partition ID
389 * Clear Snoop -- no parameters, SynIC message contains the partition ID
390 * All Offers Delivered -- no parameters, SynIC message contains the partition
391 * ID
392 * Flush Client -- no parameters, SynIC message contains the partition ID
393 */
394
395/* Open Channel parameters */
396struct vmbus_channel_open_channel {
397 struct vmbus_channel_message_header header;
398
399 /* Identifies the specific VMBus channel that is being opened. */
400 u32 child_relid;
401
402 /* ID making a particular open request at a channel offer unique. */
403 u32 openid;
404
405 /* GPADL for the channel's ring buffer. */
406 u32 ringbuffer_gpadlhandle;
407
408 /* GPADL for the channel's server context save area. */
409 u32 server_contextarea_gpadlhandle;
410
411 /*
412 * The upstream ring buffer begins at offset zero in the memory
413 * described by RingBufferGpadlHandle. The downstream ring buffer
414 * follows it at this offset (in pages).
415 */
416 u32 downstream_ringbuffer_pageoffset;
417
418 /* User-specific data to be passed along to the server endpoint. */
419 unsigned char userdata[MAX_USER_DEFINED_BYTES];
420} __packed;
421
422/* Open Channel Result parameters */
423struct vmbus_channel_open_result {
424 struct vmbus_channel_message_header header;
425 u32 child_relid;
426 u32 openid;
427 u32 status;
428} __packed;
429
430/* Close channel parameters; */
431struct vmbus_channel_close_channel {
432 struct vmbus_channel_message_header header;
433 u32 child_relid;
434} __packed;
435
436/* Channel Message GPADL */
437#define GPADL_TYPE_RING_BUFFER 1
438#define GPADL_TYPE_SERVER_SAVE_AREA 2
439#define GPADL_TYPE_TRANSACTION 8
440
441/*
442 * The number of PFNs in a GPADL message is defined by the number of
443 * pages that would be spanned by ByteCount and ByteOffset. If the
444 * implied number of PFNs won't fit in this packet, there will be a
445 * follow-up packet that contains more.
446 */
447struct vmbus_channel_gpadl_header {
448 struct vmbus_channel_message_header header;
449 u32 child_relid;
450 u32 gpadl;
451 u16 range_buflen;
452 u16 rangecount;
453 struct gpa_range range[0];
454} __packed;
455
456/* This is the followup packet that contains more PFNs. */
457struct vmbus_channel_gpadl_body {
458 struct vmbus_channel_message_header header;
459 u32 msgnumber;
460 u32 gpadl;
461 u64 pfn[0];
462} __packed;
463
464struct vmbus_channel_gpadl_created {
465 struct vmbus_channel_message_header header;
466 u32 child_relid;
467 u32 gpadl;
468 u32 creation_status;
469} __packed;
470
471struct vmbus_channel_gpadl_teardown {
472 struct vmbus_channel_message_header header;
473 u32 child_relid;
474 u32 gpadl;
475} __packed;
476
477struct vmbus_channel_gpadl_torndown {
478 struct vmbus_channel_message_header header;
479 u32 gpadl;
480} __packed;
481
482#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
483struct vmbus_channel_view_range_add {
484 struct vmbus_channel_message_header header;
485 PHYSICAL_ADDRESS viewrange_base;
486 u64 viewrange_length;
487 u32 child_relid;
488} __packed;
489
490struct vmbus_channel_view_range_remove {
491 struct vmbus_channel_message_header header;
492 PHYSICAL_ADDRESS viewrange_base;
493 u32 child_relid;
494} __packed;
495#endif
496
497struct vmbus_channel_relid_released {
498 struct vmbus_channel_message_header header;
499 u32 child_relid;
500} __packed;
501
502struct vmbus_channel_initiate_contact {
503 struct vmbus_channel_message_header header;
504 u32 vmbus_version_requested;
505 u32 padding2;
506 u64 interrupt_page;
507 u64 monitor_page1;
508 u64 monitor_page2;
509} __packed;
510
511struct vmbus_channel_version_response {
512 struct vmbus_channel_message_header header;
513 bool version_supported;
514} __packed;
515
516enum vmbus_channel_state {
517 CHANNEL_OFFER_STATE,
518 CHANNEL_OPENING_STATE,
519 CHANNEL_OPEN_STATE,
520};
521
522struct vmbus_channel {
523 struct list_head listentry;
524
525 struct hv_device *device_obj;
526
527 struct timer_list poll_timer; /* SA-111 workaround */
528 struct work_struct work;
529
530 enum vmbus_channel_state state;
531
532 struct vmbus_channel_offer_channel offermsg;
533 /*
534 * These are based on the OfferMsg.MonitorId.
535 * Save it here for easy access.
536 */
537 u8 monitor_grp;
538 u8 monitor_bit;
539
540 u32 ringbuffer_gpadlhandle;
541
542 /* Allocated memory for ring buffer */
543 void *ringbuffer_pages;
544 u32 ringbuffer_pagecount;
545 struct hv_ring_buffer_info outbound; /* send to parent */
546 struct hv_ring_buffer_info inbound; /* receive from parent */
547 spinlock_t inbound_lock;
548 struct workqueue_struct *controlwq;
549
550 /* Channel callback are invoked in this workqueue context */
551 /* HANDLE dataWorkQueue; */
552
553 void (*onchannel_callback)(void *context);
554 void *channel_callback_context;
555};
556
557struct vmbus_channel_debug_info {
558 u32 relid;
559 enum vmbus_channel_state state;
560 struct hv_guid interfacetype;
561 struct hv_guid interface_instance;
562 u32 monitorid;
563 u32 servermonitor_pending;
564 u32 servermonitor_latency;
565 u32 servermonitor_connectionid;
566 u32 clientmonitor_pending;
567 u32 clientmonitor_latency;
568 u32 clientmonitor_connectionid;
569
570 struct hv_ring_buffer_debug_info inbound;
571 struct hv_ring_buffer_debug_info outbound;
572};
573
574/*
575 * Represents each channel msg on the vmbus connection This is a
576 * variable-size data structure depending on the msg type itself
577 */
578struct vmbus_channel_msginfo {
579 /* Bookkeeping stuff */
580 struct list_head msglistentry;
581
582 /* So far, this is only used to handle gpadl body message */
583 struct list_head submsglist;
584
585 /* Synchronize the request/response if needed */
586 struct completion waitevent;
587 union {
588 struct vmbus_channel_version_supported version_supported;
589 struct vmbus_channel_open_result open_result;
590 struct vmbus_channel_gpadl_torndown gpadl_torndown;
591 struct vmbus_channel_gpadl_created gpadl_created;
592 struct vmbus_channel_version_response version_response;
593 } response;
594
595 u32 msgsize;
596 /*
597 * The channel message that goes out on the "wire".
598 * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
599 */
600 unsigned char msg[0];
601};
602
603
604void free_channel(struct vmbus_channel *channel);
605
606void vmbus_onmessage(void *context);
607
608int vmbus_request_offers(void);
609
K. Y. Srinivasanc35470b2011-05-12 19:34:22 -0700610/* The format must be the same as struct vmdata_gpa_direct */
611struct vmbus_channel_packet_page_buffer {
612 u16 type;
613 u16 dataoffset8;
614 u16 length8;
615 u16 flags;
616 u64 transactionid;
617 u32 reserved;
618 u32 rangecount;
619 struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT];
620} __packed;
621
622/* The format must be the same as struct vmdata_gpa_direct */
623struct vmbus_channel_packet_multipage_buffer {
624 u16 type;
625 u16 dataoffset8;
626 u16 length8;
627 u16 flags;
628 u64 transactionid;
629 u32 reserved;
630 u32 rangecount; /* Always 1 in this case */
631 struct hv_multipage_buffer range;
632} __packed;
633
634
635extern int vmbus_open(struct vmbus_channel *channel,
636 u32 send_ringbuffersize,
637 u32 recv_ringbuffersize,
638 void *userdata,
639 u32 userdatalen,
640 void(*onchannel_callback)(void *context),
641 void *context);
642
643extern void vmbus_close(struct vmbus_channel *channel);
644
645extern int vmbus_sendpacket(struct vmbus_channel *channel,
646 const void *buffer,
647 u32 bufferLen,
648 u64 requestid,
649 enum vmbus_packet_type type,
650 u32 flags);
651
652extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
653 struct hv_page_buffer pagebuffers[],
654 u32 pagecount,
655 void *buffer,
656 u32 bufferlen,
657 u64 requestid);
658
659extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
660 struct hv_multipage_buffer *mpb,
661 void *buffer,
662 u32 bufferlen,
663 u64 requestid);
664
665extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
666 void *kbuffer,
667 u32 size,
668 u32 *gpadl_handle);
669
670extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
671 u32 gpadl_handle);
672
673extern int vmbus_recvpacket(struct vmbus_channel *channel,
674 void *buffer,
675 u32 bufferlen,
676 u32 *buffer_actual_len,
677 u64 *requestid);
678
679extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
680 void *buffer,
681 u32 bufferlen,
682 u32 *buffer_actual_len,
683 u64 *requestid);
684
685extern void vmbus_onchannel_event(struct vmbus_channel *channel);
686
687extern void vmbus_get_debug_info(struct vmbus_channel *channel,
688 struct vmbus_channel_debug_info *debug);
689
690extern void vmbus_ontimer(unsigned long data);
691
K. Y. Srinivasanf63c9142011-05-12 19:34:23 -0700692
693#define LOWORD(dw) ((unsigned short)(dw))
694#define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF))
695
696
697#define VMBUS 0x0001
698#define STORVSC 0x0002
699#define NETVSC 0x0004
700#define INPUTVSC 0x0008
701#define BLKVSC 0x0010
702#define VMBUS_DRV 0x0100
703#define STORVSC_DRV 0x0200
704#define NETVSC_DRV 0x0400
705#define INPUTVSC_DRV 0x0800
706#define BLKVSC_DRV 0x1000
707
708#define ALL_MODULES (VMBUS |\
709 STORVSC |\
710 NETVSC |\
711 INPUTVSC |\
712 BLKVSC |\
713 VMBUS_DRV |\
714 STORVSC_DRV |\
715 NETVSC_DRV |\
716 INPUTVSC_DRV|\
717 BLKVSC_DRV)
718
719/* Logging Level */
720#define ERROR_LVL 3
721#define WARNING_LVL 4
722#define INFO_LVL 6
723#define DEBUG_LVL 7
724#define DEBUG_LVL_ENTEREXIT 8
725#define DEBUG_RING_LVL 9
726
727extern unsigned int vmbus_loglevel;
728
729#define DPRINT(mod, lvl, fmt, args...) do {\
730 if ((mod & (HIWORD(vmbus_loglevel))) && \
731 (lvl <= LOWORD(vmbus_loglevel))) \
732 printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
733 } while (0)
734
735#define DPRINT_DBG(mod, fmt, args...) do {\
736 if ((mod & (HIWORD(vmbus_loglevel))) && \
737 (DEBUG_LVL <= LOWORD(vmbus_loglevel))) \
738 printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
739 } while (0)
740
741#define DPRINT_INFO(mod, fmt, args...) do {\
742 if ((mod & (HIWORD(vmbus_loglevel))) && \
743 (INFO_LVL <= LOWORD(vmbus_loglevel))) \
744 printk(KERN_INFO #mod": " fmt "\n", ## args);\
745 } while (0)
746
747#define DPRINT_WARN(mod, fmt, args...) do {\
748 if ((mod & (HIWORD(vmbus_loglevel))) && \
749 (WARNING_LVL <= LOWORD(vmbus_loglevel))) \
750 printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\
751 } while (0)
752
753#define DPRINT_ERR(mod, fmt, args...) do {\
754 if ((mod & (HIWORD(vmbus_loglevel))) && \
755 (ERROR_LVL <= LOWORD(vmbus_loglevel))) \
756 printk(KERN_ERR #mod": %s() ERROR!! " fmt "\n", \
757 __func__, ## args);\
758 } while (0)
759
K. Y. Srinivasan3f335ea2011-05-12 19:34:15 -0700760#endif /* _HYPERV_H */