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 "hypervisor call" interface which is used to
19 * drive the hypervisor from the OS.
20 */
21 #ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
22 #define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
23
24 #include <linux/types.h>
25 #include <linux/dma-mapping.h>
26
27 #include <asm/iseries/hv_call_sc.h>
28 #include <asm/iseries/hv_types.h>
29 #include <asm/abs_addr.h>
30
31 struct HvLpEvent;
32
33 typedef u8 HvLpEvent_Type;
34 typedef u8 HvLpEvent_AckInd;
35 typedef u8 HvLpEvent_AckType;
36
37 typedef u8 HvLpDma_Direction;
38 typedef u8 HvLpDma_AddressType;
39
40 typedef u64 HvLpEvent_Rc;
41 typedef u64 HvLpDma_Rc;
42
43 #define HvCallEventAckLpEvent HvCallEvent + 0
44 #define HvCallEventCancelLpEvent HvCallEvent + 1
45 #define HvCallEventCloseLpEventPath HvCallEvent + 2
46 #define HvCallEventDmaBufList HvCallEvent + 3
47 #define HvCallEventDmaSingle HvCallEvent + 4
48 #define HvCallEventDmaToSp HvCallEvent + 5
49 #define HvCallEventGetOverflowLpEvents HvCallEvent + 6
50 #define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
51 #define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
52 #define HvCallEventOpenLpEventPath HvCallEvent + 9
53 #define HvCallEventSetLpEventStack HvCallEvent + 10
54 #define HvCallEventSignalLpEvent HvCallEvent + 11
55 #define HvCallEventSignalLpEventParms HvCallEvent + 12
56 #define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
57 #define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
58 #define HvCallEventRouter15 HvCallEvent + 15
59
HvCallEvent_getOverflowLpEvents(u8 queueIndex)60 static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
61 {
62 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
63 }
64
HvCallEvent_setInterLpQueueIndex(u8 queueIndex)65 static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
66 {
67 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
68 }
69
HvCallEvent_setLpEventStack(u8 queueIndex,char * eventStackAddr,u32 eventStackSize)70 static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
71 char *eventStackAddr, u32 eventStackSize)
72 {
73 HvCall3(HvCallEventSetLpEventStack, queueIndex,
74 virt_to_abs(eventStackAddr), eventStackSize);
75 }
76
HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,u16 lpLogicalProcIndex)77 static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
78 u16 lpLogicalProcIndex)
79 {
80 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
81 lpLogicalProcIndex);
82 }
83
HvCallEvent_signalLpEvent(struct HvLpEvent * event)84 static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
85 {
86 return HvCall1(HvCallEventSignalLpEvent, virt_to_abs(event));
87 }
88
HvCallEvent_signalLpEventFast(HvLpIndex targetLp,HvLpEvent_Type type,u16 subtype,HvLpEvent_AckInd ackInd,HvLpEvent_AckType ackType,HvLpInstanceId sourceInstanceId,HvLpInstanceId targetInstanceId,u64 correlationToken,u64 eventData1,u64 eventData2,u64 eventData3,u64 eventData4,u64 eventData5)89 static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
90 HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
91 HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
92 HvLpInstanceId targetInstanceId, u64 correlationToken,
93 u64 eventData1, u64 eventData2, u64 eventData3,
94 u64 eventData4, u64 eventData5)
95 {
96 /* Pack the misc bits into a single Dword to pass to PLIC */
97 union {
98 struct {
99 u8 ack_and_target;
100 u8 type;
101 u16 subtype;
102 HvLpInstanceId src_inst;
103 HvLpInstanceId target_inst;
104 } parms;
105 u64 dword;
106 } packed;
107
108 packed.parms.ack_and_target = (ackType << 7) | (ackInd << 6) | targetLp;
109 packed.parms.type = type;
110 packed.parms.subtype = subtype;
111 packed.parms.src_inst = sourceInstanceId;
112 packed.parms.target_inst = targetInstanceId;
113
114 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
115 correlationToken, eventData1, eventData2,
116 eventData3, eventData4, eventData5);
117 }
118
119 extern void *iseries_hv_alloc(size_t size, dma_addr_t *dma_handle, gfp_t flag);
120 extern void iseries_hv_free(size_t size, void *vaddr, dma_addr_t dma_handle);
121 extern dma_addr_t iseries_hv_map(void *vaddr, size_t size,
122 enum dma_data_direction direction);
123 extern void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
124 enum dma_data_direction direction);
125
HvCallEvent_ackLpEvent(struct HvLpEvent * event)126 static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
127 {
128 return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
129 }
130
HvCallEvent_cancelLpEvent(struct HvLpEvent * event)131 static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
132 {
133 return HvCall1(HvCallEventCancelLpEvent, virt_to_abs(event));
134 }
135
HvCallEvent_getSourceLpInstanceId(HvLpIndex targetLp,HvLpEvent_Type type)136 static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
137 HvLpIndex targetLp, HvLpEvent_Type type)
138 {
139 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
140 }
141
HvCallEvent_getTargetLpInstanceId(HvLpIndex targetLp,HvLpEvent_Type type)142 static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
143 HvLpIndex targetLp, HvLpEvent_Type type)
144 {
145 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
146 }
147
HvCallEvent_openLpEventPath(HvLpIndex targetLp,HvLpEvent_Type type)148 static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
149 HvLpEvent_Type type)
150 {
151 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
152 }
153
HvCallEvent_closeLpEventPath(HvLpIndex targetLp,HvLpEvent_Type type)154 static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
155 HvLpEvent_Type type)
156 {
157 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
158 }
159
HvCallEvent_dmaBufList(HvLpEvent_Type type,HvLpIndex remoteLp,HvLpDma_Direction direction,HvLpInstanceId localInstanceId,HvLpInstanceId remoteInstanceId,HvLpDma_AddressType localAddressType,HvLpDma_AddressType remoteAddressType,u64 localBufList,u64 remoteBufList,u32 transferLength)160 static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
161 HvLpIndex remoteLp, HvLpDma_Direction direction,
162 HvLpInstanceId localInstanceId,
163 HvLpInstanceId remoteInstanceId,
164 HvLpDma_AddressType localAddressType,
165 HvLpDma_AddressType remoteAddressType,
166 /* Do these need to be converted to absolute addresses? */
167 u64 localBufList, u64 remoteBufList, u32 transferLength)
168 {
169 /* Pack the misc bits into a single Dword to pass to PLIC */
170 union {
171 struct {
172 u8 flags;
173 HvLpIndex remote;
174 u8 type;
175 u8 reserved;
176 HvLpInstanceId local_inst;
177 HvLpInstanceId remote_inst;
178 } parms;
179 u64 dword;
180 } packed;
181
182 packed.parms.flags = (direction << 7) |
183 (localAddressType << 6) | (remoteAddressType << 5);
184 packed.parms.remote = remoteLp;
185 packed.parms.type = type;
186 packed.parms.reserved = 0;
187 packed.parms.local_inst = localInstanceId;
188 packed.parms.remote_inst = remoteInstanceId;
189
190 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
191 remoteBufList, transferLength);
192 }
193
HvCallEvent_dmaToSp(void * local,u32 remote,u32 length,HvLpDma_Direction dir)194 static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
195 u32 length, HvLpDma_Direction dir)
196 {
197 return HvCall4(HvCallEventDmaToSp, virt_to_abs(local), remote,
198 length, dir);
199 }
200
201 #endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */
202