hyperv_vmbus.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. /*
  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. */
  24. #ifndef _HYPERV_VMBUS_H
  25. #define _HYPERV_VMBUS_H
  26. #include <linux/list.h>
  27. #include <asm/sync_bitops.h>
  28. #include <linux/atomic.h>
  29. #include <linux/hyperv.h>
  30. /*
  31. * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
  32. * is set by CPUID(HVCPUID_VERSION_FEATURES).
  33. */
  34. enum hv_cpuid_function {
  35. HVCPUID_VERSION_FEATURES = 0x00000001,
  36. HVCPUID_VENDOR_MAXFUNCTION = 0x40000000,
  37. HVCPUID_INTERFACE = 0x40000001,
  38. /*
  39. * The remaining functions depend on the value of
  40. * HVCPUID_INTERFACE
  41. */
  42. HVCPUID_VERSION = 0x40000002,
  43. HVCPUID_FEATURES = 0x40000003,
  44. HVCPUID_ENLIGHTENMENT_INFO = 0x40000004,
  45. HVCPUID_IMPLEMENTATION_LIMITS = 0x40000005,
  46. };
  47. /* Define version of the synthetic interrupt controller. */
  48. #define HV_SYNIC_VERSION (1)
  49. /* Define the expected SynIC version. */
  50. #define HV_SYNIC_VERSION_1 (0x1)
  51. /* Define synthetic interrupt controller message constants. */
  52. #define HV_MESSAGE_SIZE (256)
  53. #define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
  54. #define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
  55. #define HV_ANY_VP (0xFFFFFFFF)
  56. /* Define synthetic interrupt controller flag constants. */
  57. #define HV_EVENT_FLAGS_COUNT (256 * 8)
  58. #define HV_EVENT_FLAGS_BYTE_COUNT (256)
  59. #define HV_EVENT_FLAGS_DWORD_COUNT (256 / sizeof(u32))
  60. /* Define hypervisor message types. */
  61. enum hv_message_type {
  62. HVMSG_NONE = 0x00000000,
  63. /* Memory access messages. */
  64. HVMSG_UNMAPPED_GPA = 0x80000000,
  65. HVMSG_GPA_INTERCEPT = 0x80000001,
  66. /* Timer notification messages. */
  67. HVMSG_TIMER_EXPIRED = 0x80000010,
  68. /* Error messages. */
  69. HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
  70. HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021,
  71. HVMSG_UNSUPPORTED_FEATURE = 0x80000022,
  72. /* Trace buffer complete messages. */
  73. HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040,
  74. /* Platform-specific processor intercept messages. */
  75. HVMSG_X64_IOPORT_INTERCEPT = 0x80010000,
  76. HVMSG_X64_MSR_INTERCEPT = 0x80010001,
  77. HVMSG_X64_CPUID_INTERCEPT = 0x80010002,
  78. HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003,
  79. HVMSG_X64_APIC_EOI = 0x80010004,
  80. HVMSG_X64_LEGACY_FP_ERROR = 0x80010005
  81. };
  82. /* Define the number of synthetic interrupt sources. */
  83. #define HV_SYNIC_SINT_COUNT (16)
  84. #define HV_SYNIC_STIMER_COUNT (4)
  85. /* Define invalid partition identifier. */
  86. #define HV_PARTITION_ID_INVALID ((u64)0x0)
  87. /* Define port identifier type. */
  88. union hv_port_id {
  89. u32 asu32;
  90. struct {
  91. u32 id:24;
  92. u32 reserved:8;
  93. } u ;
  94. };
  95. /* Define port type. */
  96. enum hv_port_type {
  97. HVPORT_MSG = 1,
  98. HVPORT_EVENT = 2,
  99. HVPORT_MONITOR = 3
  100. };
  101. /* Define port information structure. */
  102. struct hv_port_info {
  103. enum hv_port_type port_type;
  104. u32 padding;
  105. union {
  106. struct {
  107. u32 target_sint;
  108. u32 target_vp;
  109. u64 rsvdz;
  110. } message_port_info;
  111. struct {
  112. u32 target_sint;
  113. u32 target_vp;
  114. u16 base_flag_bumber;
  115. u16 flag_count;
  116. u32 rsvdz;
  117. } event_port_info;
  118. struct {
  119. u64 monitor_address;
  120. u64 rsvdz;
  121. } monitor_port_info;
  122. };
  123. };
  124. struct hv_connection_info {
  125. enum hv_port_type port_type;
  126. u32 padding;
  127. union {
  128. struct {
  129. u64 rsvdz;
  130. } message_connection_info;
  131. struct {
  132. u64 rsvdz;
  133. } event_connection_info;
  134. struct {
  135. u64 monitor_address;
  136. } monitor_connection_info;
  137. };
  138. };
  139. /* Define synthetic interrupt controller message flags. */
  140. union hv_message_flags {
  141. u8 asu8;
  142. struct {
  143. u8 msg_pending:1;
  144. u8 reserved:7;
  145. };
  146. };
  147. /* Define synthetic interrupt controller message header. */
  148. struct hv_message_header {
  149. enum hv_message_type message_type;
  150. u8 payload_size;
  151. union hv_message_flags message_flags;
  152. u8 reserved[2];
  153. union {
  154. u64 sender;
  155. union hv_port_id port;
  156. };
  157. };
  158. /*
  159. * Timer configuration register.
  160. */
  161. union hv_timer_config {
  162. u64 as_uint64;
  163. struct {
  164. u64 enable:1;
  165. u64 periodic:1;
  166. u64 lazy:1;
  167. u64 auto_enable:1;
  168. u64 reserved_z0:12;
  169. u64 sintx:4;
  170. u64 reserved_z1:44;
  171. };
  172. };
  173. /* Define timer message payload structure. */
  174. struct hv_timer_message_payload {
  175. u32 timer_index;
  176. u32 reserved;
  177. u64 expiration_time; /* When the timer expired */
  178. u64 delivery_time; /* When the message was delivered */
  179. };
  180. /* Define synthetic interrupt controller message format. */
  181. struct hv_message {
  182. struct hv_message_header header;
  183. union {
  184. u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
  185. } u ;
  186. };
  187. /* Define the number of message buffers associated with each port. */
  188. #define HV_PORT_MESSAGE_BUFFER_COUNT (16)
  189. /* Define the synthetic interrupt message page layout. */
  190. struct hv_message_page {
  191. struct hv_message sint_message[HV_SYNIC_SINT_COUNT];
  192. };
  193. /* Define the synthetic interrupt controller event flags format. */
  194. union hv_synic_event_flags {
  195. u8 flags8[HV_EVENT_FLAGS_BYTE_COUNT];
  196. u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT];
  197. };
  198. /* Define the synthetic interrupt flags page layout. */
  199. struct hv_synic_event_flags_page {
  200. union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
  201. };
  202. /* Define SynIC control register. */
  203. union hv_synic_scontrol {
  204. u64 as_uint64;
  205. struct {
  206. u64 enable:1;
  207. u64 reserved:63;
  208. };
  209. };
  210. /* Define synthetic interrupt source. */
  211. union hv_synic_sint {
  212. u64 as_uint64;
  213. struct {
  214. u64 vector:8;
  215. u64 reserved1:8;
  216. u64 masked:1;
  217. u64 auto_eoi:1;
  218. u64 reserved2:46;
  219. };
  220. };
  221. /* Define the format of the SIMP register */
  222. union hv_synic_simp {
  223. u64 as_uint64;
  224. struct {
  225. u64 simp_enabled:1;
  226. u64 preserved:11;
  227. u64 base_simp_gpa:52;
  228. };
  229. };
  230. /* Define the format of the SIEFP register */
  231. union hv_synic_siefp {
  232. u64 as_uint64;
  233. struct {
  234. u64 siefp_enabled:1;
  235. u64 preserved:11;
  236. u64 base_siefp_gpa:52;
  237. };
  238. };
  239. /* Definitions for the monitored notification facility */
  240. union hv_monitor_trigger_group {
  241. u64 as_uint64;
  242. struct {
  243. u32 pending;
  244. u32 armed;
  245. };
  246. };
  247. struct hv_monitor_parameter {
  248. union hv_connection_id connectionid;
  249. u16 flagnumber;
  250. u16 rsvdz;
  251. };
  252. union hv_monitor_trigger_state {
  253. u32 asu32;
  254. struct {
  255. u32 group_enable:4;
  256. u32 rsvdz:28;
  257. };
  258. };
  259. /* struct hv_monitor_page Layout */
  260. /* ------------------------------------------------------ */
  261. /* | 0 | TriggerState (4 bytes) | Rsvd1 (4 bytes) | */
  262. /* | 8 | TriggerGroup[0] | */
  263. /* | 10 | TriggerGroup[1] | */
  264. /* | 18 | TriggerGroup[2] | */
  265. /* | 20 | TriggerGroup[3] | */
  266. /* | 28 | Rsvd2[0] | */
  267. /* | 30 | Rsvd2[1] | */
  268. /* | 38 | Rsvd2[2] | */
  269. /* | 40 | NextCheckTime[0][0] | NextCheckTime[0][1] | */
  270. /* | ... | */
  271. /* | 240 | Latency[0][0..3] | */
  272. /* | 340 | Rsvz3[0] | */
  273. /* | 440 | Parameter[0][0] | */
  274. /* | 448 | Parameter[0][1] | */
  275. /* | ... | */
  276. /* | 840 | Rsvd4[0] | */
  277. /* ------------------------------------------------------ */
  278. struct hv_monitor_page {
  279. union hv_monitor_trigger_state trigger_state;
  280. u32 rsvdz1;
  281. union hv_monitor_trigger_group trigger_group[4];
  282. u64 rsvdz2[3];
  283. s32 next_checktime[4][32];
  284. u16 latency[4][32];
  285. u64 rsvdz3[32];
  286. struct hv_monitor_parameter parameter[4][32];
  287. u8 rsvdz4[1984];
  288. };
  289. /* Declare the various hypercall operations. */
  290. enum hv_call_code {
  291. HVCALL_POST_MESSAGE = 0x005c,
  292. HVCALL_SIGNAL_EVENT = 0x005d,
  293. };
  294. /* Definition of the hv_post_message hypercall input structure. */
  295. struct hv_input_post_message {
  296. union hv_connection_id connectionid;
  297. u32 reserved;
  298. enum hv_message_type message_type;
  299. u32 payload_size;
  300. u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
  301. };
  302. /*
  303. * Versioning definitions used for guests reporting themselves to the
  304. * hypervisor, and visa versa.
  305. */
  306. /* Version info reported by guest OS's */
  307. enum hv_guest_os_vendor {
  308. HVGUESTOS_VENDOR_MICROSOFT = 0x0001
  309. };
  310. enum hv_guest_os_microsoft_ids {
  311. HVGUESTOS_MICROSOFT_UNDEFINED = 0x00,
  312. HVGUESTOS_MICROSOFT_MSDOS = 0x01,
  313. HVGUESTOS_MICROSOFT_WINDOWS3X = 0x02,
  314. HVGUESTOS_MICROSOFT_WINDOWS9X = 0x03,
  315. HVGUESTOS_MICROSOFT_WINDOWSNT = 0x04,
  316. HVGUESTOS_MICROSOFT_WINDOWSCE = 0x05
  317. };
  318. /*
  319. * Declare the MSR used to identify the guest OS.
  320. */
  321. #define HV_X64_MSR_GUEST_OS_ID 0x40000000
  322. union hv_x64_msr_guest_os_id_contents {
  323. u64 as_uint64;
  324. struct {
  325. u64 build_number:16;
  326. u64 service_version:8; /* Service Pack, etc. */
  327. u64 minor_version:8;
  328. u64 major_version:8;
  329. u64 os_id:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
  330. u64 vendor_id:16; /* enum hv_guest_os_vendor */
  331. };
  332. };
  333. /*
  334. * Declare the MSR used to setup pages used to communicate with the hypervisor.
  335. */
  336. #define HV_X64_MSR_HYPERCALL 0x40000001
  337. union hv_x64_msr_hypercall_contents {
  338. u64 as_uint64;
  339. struct {
  340. u64 enable:1;
  341. u64 reserved:11;
  342. u64 guest_physical_address:52;
  343. };
  344. };
  345. enum {
  346. VMBUS_MESSAGE_CONNECTION_ID = 1,
  347. VMBUS_MESSAGE_PORT_ID = 1,
  348. VMBUS_EVENT_CONNECTION_ID = 2,
  349. VMBUS_EVENT_PORT_ID = 2,
  350. VMBUS_MONITOR_CONNECTION_ID = 3,
  351. VMBUS_MONITOR_PORT_ID = 3,
  352. VMBUS_MESSAGE_SINT = 2,
  353. };
  354. /* #defines */
  355. #define HV_PRESENT_BIT 0x80000000
  356. /*
  357. * The guest OS needs to register the guest ID with the hypervisor.
  358. * The guest ID is a 64 bit entity and the structure of this ID is
  359. * specified in the Hyper-V specification:
  360. *
  361. * http://msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx
  362. *
  363. * While the current guideline does not specify how Linux guest ID(s)
  364. * need to be generated, our plan is to publish the guidelines for
  365. * Linux and other guest operating systems that currently are hosted
  366. * on Hyper-V. The implementation here conforms to this yet
  367. * unpublished guidelines.
  368. *
  369. *
  370. * Bit(s)
  371. * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
  372. * 62:56 - Os Type; Linux is 0x100
  373. * 55:48 - Distro specific identification
  374. * 47:16 - Linux kernel version number
  375. * 15:0 - Distro specific identification
  376. *
  377. *
  378. */
  379. #define HV_LINUX_VENDOR_ID 0x8100
  380. /*
  381. * Generate the guest ID based on the guideline described above.
  382. */
  383. static inline __u64 generate_guest_id(__u8 d_info1, __u32 kernel_version,
  384. __u16 d_info2)
  385. {
  386. __u64 guest_id = 0;
  387. guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
  388. guest_id |= (((__u64)(d_info1)) << 48);
  389. guest_id |= (((__u64)(kernel_version)) << 16);
  390. guest_id |= ((__u64)(d_info2));
  391. return guest_id;
  392. }
  393. #define HV_CPU_POWER_MANAGEMENT (1 << 0)
  394. #define HV_RECOMMENDATIONS_MAX 4
  395. #define HV_X64_MAX 5
  396. #define HV_CAPS_MAX 8
  397. #define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)
  398. /* Service definitions */
  399. #define HV_SERVICE_PARENT_PORT (0)
  400. #define HV_SERVICE_PARENT_CONNECTION (0)
  401. #define HV_SERVICE_CONNECT_RESPONSE_SUCCESS (0)
  402. #define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER (1)
  403. #define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE (2)
  404. #define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED (3)
  405. #define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID (1)
  406. #define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID (2)
  407. #define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID (3)
  408. #define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID (4)
  409. #define HV_SERVICE_MAX_MESSAGE_ID (4)
  410. #define HV_SERVICE_PROTOCOL_VERSION (0x0010)
  411. #define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
  412. /* #define VMBUS_REVISION_NUMBER 6 */
  413. /* Our local vmbus's port and connection id. Anything >0 is fine */
  414. /* #define VMBUS_PORT_ID 11 */
  415. /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
  416. static const uuid_le VMBUS_SERVICE_ID = {
  417. .b = {
  418. 0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
  419. 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
  420. },
  421. };
  422. struct hv_context {
  423. /* We only support running on top of Hyper-V
  424. * So at this point this really can only contain the Hyper-V ID
  425. */
  426. u64 guestid;
  427. void *hypercall_page;
  428. bool synic_initialized;
  429. void *synic_message_page[NR_CPUS];
  430. void *synic_event_page[NR_CPUS];
  431. /*
  432. * Hypervisor's notion of virtual processor ID is different from
  433. * Linux' notion of CPU ID. This information can only be retrieved
  434. * in the context of the calling CPU. Setup a map for easy access
  435. * to this information:
  436. *
  437. * vp_index[a] is the Hyper-V's processor ID corresponding to
  438. * Linux cpuid 'a'.
  439. */
  440. u32 vp_index[NR_CPUS];
  441. /*
  442. * Starting with win8, we can take channel interrupts on any CPU;
  443. * we will manage the tasklet that handles events on a per CPU
  444. * basis.
  445. */
  446. struct tasklet_struct *event_dpc[NR_CPUS];
  447. /*
  448. * To optimize the mapping of relid to channel, maintain
  449. * per-cpu list of the channels based on their CPU affinity.
  450. */
  451. struct list_head percpu_list[NR_CPUS];
  452. /*
  453. * buffer to post messages to the host.
  454. */
  455. void *post_msg_page[NR_CPUS];
  456. /*
  457. * Support PV clockevent device.
  458. */
  459. struct clock_event_device *clk_evt[NR_CPUS];
  460. };
  461. extern struct hv_context hv_context;
  462. struct hv_ring_buffer_debug_info {
  463. u32 current_interrupt_mask;
  464. u32 current_read_index;
  465. u32 current_write_index;
  466. u32 bytes_avail_toread;
  467. u32 bytes_avail_towrite;
  468. };
  469. /* Hv Interface */
  470. extern int hv_init(void);
  471. extern void hv_cleanup(void);
  472. extern int hv_post_message(union hv_connection_id connection_id,
  473. enum hv_message_type message_type,
  474. void *payload, size_t payload_size);
  475. extern u16 hv_signal_event(void *con_id);
  476. extern int hv_synic_alloc(void);
  477. extern void hv_synic_free(void);
  478. extern void hv_synic_init(void *irqarg);
  479. extern void hv_synic_cleanup(void *arg);
  480. /*
  481. * Host version information.
  482. */
  483. extern unsigned int host_info_eax;
  484. extern unsigned int host_info_ebx;
  485. extern unsigned int host_info_ecx;
  486. extern unsigned int host_info_edx;
  487. /* Interface */
  488. int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
  489. u32 buflen);
  490. void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
  491. int hv_ringbuffer_write(struct hv_ring_buffer_info *ring_info,
  492. struct kvec *kv_list,
  493. u32 kv_count, bool *signal);
  494. int hv_ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
  495. u32 buflen);
  496. int hv_ringbuffer_read(struct hv_ring_buffer_info *ring_info,
  497. void *buffer,
  498. u32 buflen,
  499. u32 offset, bool *signal);
  500. void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
  501. struct hv_ring_buffer_debug_info *debug_info);
  502. void hv_begin_read(struct hv_ring_buffer_info *rbi);
  503. u32 hv_end_read(struct hv_ring_buffer_info *rbi);
  504. /*
  505. * Maximum channels is determined by the size of the interrupt page
  506. * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
  507. * and the other is receive endpoint interrupt
  508. */
  509. #define MAX_NUM_CHANNELS ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
  510. /* The value here must be in multiple of 32 */
  511. /* TODO: Need to make this configurable */
  512. #define MAX_NUM_CHANNELS_SUPPORTED 256
  513. enum vmbus_connect_state {
  514. DISCONNECTED,
  515. CONNECTING,
  516. CONNECTED,
  517. DISCONNECTING
  518. };
  519. #define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
  520. struct vmbus_connection {
  521. enum vmbus_connect_state conn_state;
  522. atomic_t next_gpadl_handle;
  523. /*
  524. * Represents channel interrupts. Each bit position represents a
  525. * channel. When a channel sends an interrupt via VMBUS, it finds its
  526. * bit in the sendInterruptPage, set it and calls Hv to generate a port
  527. * event. The other end receives the port event and parse the
  528. * recvInterruptPage to see which bit is set
  529. */
  530. void *int_page;
  531. void *send_int_page;
  532. void *recv_int_page;
  533. /*
  534. * 2 pages - 1st page for parent->child notification and 2nd
  535. * is child->parent notification
  536. */
  537. struct hv_monitor_page *monitor_pages[2];
  538. struct list_head chn_msg_list;
  539. spinlock_t channelmsg_lock;
  540. /* List of channels */
  541. struct list_head chn_list;
  542. spinlock_t channel_lock;
  543. struct workqueue_struct *work_queue;
  544. };
  545. struct vmbus_msginfo {
  546. /* Bookkeeping stuff */
  547. struct list_head msglist_entry;
  548. /* The message itself */
  549. unsigned char msg[0];
  550. };
  551. extern struct vmbus_connection vmbus_connection;
  552. /* General vmbus interface */
  553. struct hv_device *vmbus_device_create(const uuid_le *type,
  554. const uuid_le *instance,
  555. struct vmbus_channel *channel);
  556. int vmbus_device_register(struct hv_device *child_device_obj);
  557. void vmbus_device_unregister(struct hv_device *device_obj);
  558. /* static void */
  559. /* VmbusChildDeviceDestroy( */
  560. /* struct hv_device *); */
  561. struct vmbus_channel *relid2channel(u32 relid);
  562. void vmbus_free_channels(void);
  563. /* Connection interface */
  564. int vmbus_connect(void);
  565. int vmbus_post_msg(void *buffer, size_t buflen);
  566. int vmbus_set_event(struct vmbus_channel *channel);
  567. void vmbus_on_event(unsigned long data);
  568. int hv_fcopy_init(struct hv_util_service *);
  569. void hv_fcopy_deinit(void);
  570. void hv_fcopy_onchannelcallback(void *);
  571. #endif /* _HYPERV_VMBUS_H */