1 /*
2 * HvLpConfig.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
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.
9 *
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.
14 *
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
20 //===========================================================================
21 //
22 // This file contains the interface to the LPAR configuration data
23 // to determine which resources should be allocated to each partition.
24 //
25 //===========================================================================
26
27 #ifndef _HVCALLCFG_H
28 #include "HvCallCfg.h"
29 #endif
30
31 #ifndef _HVTYPES_H
32 #include <asm/iSeries/HvTypes.h>
33 #endif
34
35 #ifndef _ITLPNACA_H
36 #include <asm/iSeries/ItLpNaca.h>
37 #endif
38
39 #ifndef _LPARDATA_H
40 #include <asm/iSeries/LparData.h>
41 #endif
42
43 #ifndef _HVLPCONFIG_H
44 #define _HVLPCONFIG_H
45
46 //-------------------------------------------------------------------
47 // Constants
48 //-------------------------------------------------------------------
49
50 extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
51
52 //===================================================================
HvLpConfig_getLpIndex(void)53 static inline HvLpIndex HvLpConfig_getLpIndex(void)
54 {
55 return itLpNaca.xLpIndex;
56 }
57 //===================================================================
HvLpConfig_getPrimaryLpIndex(void)58 static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
59 {
60 return itLpNaca.xPrimaryLpIndex;
61 }
62 //=================================================================
HvLpConfig_getLps(void)63 static inline HvLpIndex HvLpConfig_getLps(void)
64 {
65 return HvCallCfg_getLps();
66 }
67 //=================================================================
HvLpConfig_getActiveLpMap(void)68 static inline HvLpIndexMap HvLpConfig_getActiveLpMap(void)
69 {
70 return HvCallCfg_getActiveLpMap();
71 }
72 //=================================================================
HvLpConfig_getSystemMsMegs(void)73 static inline u64 HvLpConfig_getSystemMsMegs(void)
74 {
75 return HvCallCfg_getSystemMsChunks() / HVCHUNKSPERMEG;
76 }
77 //=================================================================
HvLpConfig_getSystemMsChunks(void)78 static inline u64 HvLpConfig_getSystemMsChunks(void)
79 {
80 return HvCallCfg_getSystemMsChunks();
81 }
82 //=================================================================
HvLpConfig_getSystemMsPages(void)83 static inline u64 HvLpConfig_getSystemMsPages(void)
84 {
85 return HvCallCfg_getSystemMsChunks() * HVPAGESPERCHUNK;
86 }
87 //================================================================
HvLpConfig_getMsMegs(void)88 static inline u64 HvLpConfig_getMsMegs(void)
89 {
90 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur) / HVCHUNKSPERMEG;
91 }
92 //================================================================
HvLpConfig_getMsChunks(void)93 static inline u64 HvLpConfig_getMsChunks(void)
94 {
95 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur);
96 }
97 //================================================================
HvLpConfig_getMsPages(void)98 static inline u64 HvLpConfig_getMsPages(void)
99 {
100 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur) * HVPAGESPERCHUNK;
101 }
102 //================================================================
HvLpConfig_getMinMsMegs(void)103 static inline u64 HvLpConfig_getMinMsMegs(void)
104 {
105 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min) / HVCHUNKSPERMEG;
106 }
107 //================================================================
HvLpConfig_getMinMsChunks(void)108 static inline u64 HvLpConfig_getMinMsChunks(void)
109 {
110 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min);
111 }
112 //================================================================
HvLpConfig_getMinMsPages(void)113 static inline u64 HvLpConfig_getMinMsPages(void)
114 {
115 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min) * HVPAGESPERCHUNK;
116 }
117 //================================================================
HvLpConfig_getMinRuntimeMsMegs(void)118 static inline u64 HvLpConfig_getMinRuntimeMsMegs(void)
119 {
120 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex()) / HVCHUNKSPERMEG;
121 }
122 //===============================================================
HvLpConfig_getMinRuntimeMsChunks(void)123 static inline u64 HvLpConfig_getMinRuntimeMsChunks(void)
124 {
125 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex());
126 }
127 //===============================================================
HvLpConfig_getMinRuntimeMsPages(void)128 static inline u64 HvLpConfig_getMinRuntimeMsPages(void)
129 {
130 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex()) * HVPAGESPERCHUNK;
131 }
132 //===============================================================
HvLpConfig_getMaxMsMegs(void)133 static inline u64 HvLpConfig_getMaxMsMegs(void)
134 {
135 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max) / HVCHUNKSPERMEG;
136 }
137 //===============================================================
HvLpConfig_getMaxMsChunks(void)138 static inline u64 HvLpConfig_getMaxMsChunks(void)
139 {
140 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max);
141 }
142 //===============================================================
HvLpConfig_getMaxMsPages(void)143 static inline u64 HvLpConfig_getMaxMsPages(void)
144 {
145 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max) * HVPAGESPERCHUNK;
146 }
147 //===============================================================
HvLpConfig_getInitMsMegs(void)148 static inline u64 HvLpConfig_getInitMsMegs(void)
149 {
150 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init) / HVCHUNKSPERMEG;
151 }
152 //===============================================================
HvLpConfig_getInitMsChunks(void)153 static inline u64 HvLpConfig_getInitMsChunks(void)
154 {
155 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init);
156 }
157 //===============================================================
HvLpConfig_getInitMsPages(void)158 static inline u64 HvLpConfig_getInitMsPages(void)
159 { return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init) * HVPAGESPERCHUNK;
160 }
161 //===============================================================
HvLpConfig_getSystemPhysicalProcessors(void)162 static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
163 {
164 return HvCallCfg_getSystemPhysicalProcessors();
165 }
166 //===============================================================
HvLpConfig_getSystemLogicalProcessors(void)167 static inline u64 HvLpConfig_getSystemLogicalProcessors(void)
168 {
169 return HvCallCfg_getSystemPhysicalProcessors() * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
170 }
171 //===============================================================
HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)172 static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
173 {
174 return HvCallCfg_getNumProcsInSharedPool(sPI);
175 }
176 //===============================================================
HvLpConfig_getPhysicalProcessors(void)177 static inline u64 HvLpConfig_getPhysicalProcessors(void)
178 {
179 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Cur);
180 }
181 //===============================================================
HvLpConfig_getLogicalProcessors(void)182 static inline u64 HvLpConfig_getLogicalProcessors(void)
183 {
184 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Cur) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
185 }
186 //===============================================================
HvLpConfig_getSharedPoolIndex(void)187 static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
188 {
189 return HvCallCfg_getSharedPoolIndex(HvLpConfig_getLpIndex());
190 }
191 //===============================================================
HvLpConfig_getSharedProcUnits(void)192 static inline u64 HvLpConfig_getSharedProcUnits(void)
193 {
194 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Cur);
195 }
196 //===============================================================
HvLpConfig_getMinSharedProcUnits(void)197 static inline u64 HvLpConfig_getMinSharedProcUnits(void)
198 {
199 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Min);
200 }
201 //===============================================================
HvLpConfig_getMaxSharedProcUnits(void)202 static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
203 {
204 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Max);
205 }
206 //===============================================================
HvLpConfig_getMinPhysicalProcessors(void)207 static inline u64 HvLpConfig_getMinPhysicalProcessors(void)
208 {
209 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Min);
210 }
211 //===============================================================
HvLpConfig_getMinLogicalProcessors(void)212 static inline u64 HvLpConfig_getMinLogicalProcessors(void)
213 {
214 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Min) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
215 }
216 //===============================================================
HvLpConfig_getMaxPhysicalProcessors(void)217 static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
218 {
219 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Max);
220 }
221 //===============================================================
HvLpConfig_getMaxLogicalProcessors(void)222 static inline u64 HvLpConfig_getMaxLogicalProcessors(void)
223 {
224 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Max) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
225 }
226 //===============================================================
HvLpConfig_getInitPhysicalProcessors(void)227 static inline u64 HvLpConfig_getInitPhysicalProcessors(void)
228 {
229 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Init);
230 }
231 //===============================================================
HvLpConfig_getInitLogicalProcessors(void)232 static inline u64 HvLpConfig_getInitLogicalProcessors(void)
233 {
234 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Init) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
235 }
236 //================================================================
HvLpConfig_getVirtualLanIndexMap(void)237 static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
238 {
239 return HvCallCfg_getVirtualLanIndexMap(HvLpConfig_getLpIndex_outline());
240 }
241 //===============================================================
HvLpConfig_getVirtualLanIndexMapForLp(HvLpIndex lp)242 static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(HvLpIndex lp)
243 {
244 return HvCallCfg_getVirtualLanIndexMap(lp);
245 }
246 //================================================================
HvLpConfig_getBusOwner(HvBusNumber busNumber)247 static inline HvLpIndex HvLpConfig_getBusOwner(HvBusNumber busNumber)
248 {
249 return HvCallCfg_getBusOwner(busNumber);
250 }
251 //===============================================================
HvLpConfig_isBusDedicated(HvBusNumber busNumber)252 static inline int HvLpConfig_isBusDedicated(HvBusNumber busNumber)
253 {
254 return HvCallCfg_isBusDedicated(busNumber);
255 }
256 //================================================================
HvLpConfig_getBusAllocation(HvBusNumber busNumber)257 static inline HvLpIndexMap HvLpConfig_getBusAllocation(HvBusNumber busNumber)
258 {
259 return HvCallCfg_getBusAllocation(busNumber);
260 }
261 //================================================================
262 // returns the absolute real address of the load area
HvLpConfig_getLoadAddress(void)263 static inline u64 HvLpConfig_getLoadAddress(void)
264 {
265 return itLpNaca.xLoadAreaAddr & 0x7fffffffffffffff;
266 }
267 //================================================================
HvLpConfig_getLoadPages(void)268 static inline u64 HvLpConfig_getLoadPages(void)
269 {
270 return itLpNaca.xLoadAreaChunks * HVPAGESPERCHUNK;
271 }
272 //================================================================
HvLpConfig_isBusOwnedByThisLp(HvBusNumber busNumber)273 static inline int HvLpConfig_isBusOwnedByThisLp(HvBusNumber busNumber)
274 {
275 HvLpIndex busOwner = HvLpConfig_getBusOwner(busNumber);
276 return (busOwner == HvLpConfig_getLpIndex());
277 }
278 //================================================================
HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,HvLpIndex lp2)279 static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1, HvLpIndex lp2)
280 {
281 HvLpVirtualLanIndexMap virtualLanIndexMap1 = HvCallCfg_getVirtualLanIndexMap( lp1 );
282 HvLpVirtualLanIndexMap virtualLanIndexMap2 = HvCallCfg_getVirtualLanIndexMap( lp2 );
283 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
284 }
285 //================================================================
HvLpConfig_getHostingLpIndex(HvLpIndex lp)286 static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
287 {
288 return HvCallCfg_getHostingLpIndex(lp);
289 }
290 //================================================================
291
292 #endif // _HVLPCONFIG_H
293