hv_lp_event.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (C) 2001 Mike Corrigan IBM Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. /* This file contains the class for HV events in the system. */
  19. #ifndef _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
  20. #define _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
  21. #include <asm/types.h>
  22. #include <asm/ptrace.h>
  23. #include <asm/iseries/hv_types.h>
  24. #include <asm/iseries/hv_call_event.h>
  25. /*
  26. * HvLpEvent is the structure for Lp Event messages passed between
  27. * partitions through PLIC.
  28. */
  29. struct HvLpEvent {
  30. u8 flags; /* Event flags x00-x00 */
  31. u8 xType; /* Type of message x01-x01 */
  32. u16 xSubtype; /* Subtype for event x02-x03 */
  33. u8 xSourceLp; /* Source LP x04-x04 */
  34. u8 xTargetLp; /* Target LP x05-x05 */
  35. u8 xSizeMinus1; /* Size of Derived class - 1 x06-x06 */
  36. u8 xRc; /* RC for Ack flows x07-x07 */
  37. u16 xSourceInstanceId; /* Source sides instance id x08-x09 */
  38. u16 xTargetInstanceId; /* Target sides instance id x0A-x0B */
  39. union {
  40. u32 xSubtypeData; /* Data usable by the subtype x0C-x0F */
  41. u16 xSubtypeDataShort[2]; /* Data as 2 shorts */
  42. u8 xSubtypeDataChar[4]; /* Data as 4 chars */
  43. } x;
  44. u64 xCorrelationToken; /* Unique value for source/type x10-x17 */
  45. };
  46. typedef void (*LpEventHandler)(struct HvLpEvent *);
  47. /* Register a handler for an event type - returns 0 on success */
  48. extern int HvLpEvent_registerHandler(HvLpEvent_Type eventType,
  49. LpEventHandler hdlr);
  50. /*
  51. * Unregister a handler for an event type
  52. *
  53. * This call will sleep until the handler being removed is guaranteed to
  54. * be no longer executing on any CPU. Do not call with locks held.
  55. *
  56. * returns 0 on success
  57. * Unregister will fail if there are any paths open for the type
  58. */
  59. extern int HvLpEvent_unregisterHandler(HvLpEvent_Type eventType);
  60. /*
  61. * Open an Lp Event Path for an event type
  62. * returns 0 on success
  63. * openPath will fail if there is no handler registered for the event type.
  64. * The lpIndex specified is the partition index for the target partition
  65. * (for VirtualIo, VirtualLan and SessionMgr) other types specify zero)
  66. */
  67. extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
  68. /*
  69. * Close an Lp Event Path for a type and partition
  70. * returns 0 on success
  71. */
  72. extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
  73. #define HvLpEvent_Type_Hypervisor 0
  74. #define HvLpEvent_Type_MachineFac 1
  75. #define HvLpEvent_Type_SessionMgr 2
  76. #define HvLpEvent_Type_SpdIo 3
  77. #define HvLpEvent_Type_VirtualBus 4
  78. #define HvLpEvent_Type_PciIo 5
  79. #define HvLpEvent_Type_RioIo 6
  80. #define HvLpEvent_Type_VirtualLan 7
  81. #define HvLpEvent_Type_VirtualIo 8
  82. #define HvLpEvent_Type_NumTypes 9
  83. #define HvLpEvent_Rc_Good 0
  84. #define HvLpEvent_Rc_BufferNotAvailable 1
  85. #define HvLpEvent_Rc_Cancelled 2
  86. #define HvLpEvent_Rc_GenericError 3
  87. #define HvLpEvent_Rc_InvalidAddress 4
  88. #define HvLpEvent_Rc_InvalidPartition 5
  89. #define HvLpEvent_Rc_InvalidSize 6
  90. #define HvLpEvent_Rc_InvalidSubtype 7
  91. #define HvLpEvent_Rc_InvalidSubtypeData 8
  92. #define HvLpEvent_Rc_InvalidType 9
  93. #define HvLpEvent_Rc_PartitionDead 10
  94. #define HvLpEvent_Rc_PathClosed 11
  95. #define HvLpEvent_Rc_SubtypeError 12
  96. #define HvLpEvent_Function_Ack 0
  97. #define HvLpEvent_Function_Int 1
  98. #define HvLpEvent_AckInd_NoAck 0
  99. #define HvLpEvent_AckInd_DoAck 1
  100. #define HvLpEvent_AckType_ImmediateAck 0
  101. #define HvLpEvent_AckType_DeferredAck 1
  102. #define HV_LP_EVENT_INT 0x01
  103. #define HV_LP_EVENT_DO_ACK 0x02
  104. #define HV_LP_EVENT_DEFERRED_ACK 0x04
  105. #define HV_LP_EVENT_VALID 0x80
  106. #define HvLpDma_Direction_LocalToRemote 0
  107. #define HvLpDma_Direction_RemoteToLocal 1
  108. #define HvLpDma_AddressType_TceIndex 0
  109. #define HvLpDma_AddressType_RealAddress 1
  110. #define HvLpDma_Rc_Good 0
  111. #define HvLpDma_Rc_Error 1
  112. #define HvLpDma_Rc_PartitionDead 2
  113. #define HvLpDma_Rc_PathClosed 3
  114. #define HvLpDma_Rc_InvalidAddress 4
  115. #define HvLpDma_Rc_InvalidLength 5
  116. static inline int hvlpevent_is_valid(struct HvLpEvent *h)
  117. {
  118. return h->flags & HV_LP_EVENT_VALID;
  119. }
  120. static inline void hvlpevent_invalidate(struct HvLpEvent *h)
  121. {
  122. h->flags &= ~ HV_LP_EVENT_VALID;
  123. }
  124. static inline int hvlpevent_is_int(struct HvLpEvent *h)
  125. {
  126. return h->flags & HV_LP_EVENT_INT;
  127. }
  128. static inline int hvlpevent_is_ack(struct HvLpEvent *h)
  129. {
  130. return !hvlpevent_is_int(h);
  131. }
  132. static inline int hvlpevent_need_ack(struct HvLpEvent *h)
  133. {
  134. return h->flags & HV_LP_EVENT_DO_ACK;
  135. }
  136. #endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */