/drivers/staging/hv/vmbus_private.h

https://github.com/MacArrow/A81E-rowboat-kernel · C Header · 133 lines · 48 code · 36 blank · 49 comment · 0 complexity · 6a8f81850a941f15fcb97791edf2e1ea MD5 · raw file

  1. /*
  2. *
  3. * Copyright (c) 2009, 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. *
  22. */
  23. #ifndef _VMBUS_PRIVATE_H_
  24. #define _VMBUS_PRIVATE_H_
  25. #include "hv.h"
  26. #include "vmbus_api.h"
  27. #include "channel.h"
  28. #include "channel_mgmt.h"
  29. #include "ring_buffer.h"
  30. #include <linux/list.h>
  31. /*
  32. * Maximum channels is determined by the size of the interrupt page
  33. * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
  34. * and the other is receive endpoint interrupt
  35. */
  36. #define MAX_NUM_CHANNELS ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
  37. /* The value here must be in multiple of 32 */
  38. /* TODO: Need to make this configurable */
  39. #define MAX_NUM_CHANNELS_SUPPORTED 256
  40. enum VMBUS_CONNECT_STATE {
  41. Disconnected,
  42. Connecting,
  43. Connected,
  44. Disconnecting
  45. };
  46. #define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT
  47. struct VMBUS_CONNECTION {
  48. enum VMBUS_CONNECT_STATE ConnectState;
  49. atomic_t NextGpadlHandle;
  50. /*
  51. * Represents channel interrupts. Each bit position represents a
  52. * channel. When a channel sends an interrupt via VMBUS, it finds its
  53. * bit in the sendInterruptPage, set it and calls Hv to generate a port
  54. * event. The other end receives the port event and parse the
  55. * recvInterruptPage to see which bit is set
  56. */
  57. void *InterruptPage;
  58. void *SendInterruptPage;
  59. void *RecvInterruptPage;
  60. /*
  61. * 2 pages - 1st page for parent->child notification and 2nd
  62. * is child->parent notification
  63. */
  64. void *MonitorPages;
  65. struct list_head ChannelMsgList;
  66. spinlock_t channelmsg_lock;
  67. /* List of channels */
  68. struct list_head ChannelList;
  69. spinlock_t channel_lock;
  70. struct workqueue_struct *WorkQueue;
  71. };
  72. struct VMBUS_MSGINFO {
  73. /* Bookkeeping stuff */
  74. struct list_head MsgListEntry;
  75. /* Synchronize the request/response if needed */
  76. struct osd_waitevent *WaitEvent;
  77. /* The message itself */
  78. unsigned char Msg[0];
  79. };
  80. extern struct VMBUS_CONNECTION gVmbusConnection;
  81. /* General vmbus interface */
  82. struct hv_device *VmbusChildDeviceCreate(struct hv_guid *deviceType,
  83. struct hv_guid *deviceInstance,
  84. struct vmbus_channel *channel);
  85. int VmbusChildDeviceAdd(struct hv_device *Device);
  86. void VmbusChildDeviceRemove(struct hv_device *Device);
  87. /* static void */
  88. /* VmbusChildDeviceDestroy( */
  89. /* struct hv_device *); */
  90. struct vmbus_channel *GetChannelFromRelId(u32 relId);
  91. /* Connection interface */
  92. int VmbusConnect(void);
  93. int VmbusDisconnect(void);
  94. int VmbusPostMessage(void *buffer, size_t bufSize);
  95. int VmbusSetEvent(u32 childRelId);
  96. void VmbusOnEvents(void);
  97. #endif /* _VMBUS_PRIVATE_H_ */