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