blob: 47311cc952d95af821867e59b080d921cd76934c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * HvLpConfig.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07004 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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 Rothwell45dc76a2005-06-21 17:15:33 -07009 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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 Rothwell45dc76a2005-06-21 17:15:33 -070014 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * 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#ifndef _HVLPCONFIG_H
20#define _HVLPCONFIG_H
21
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070022/*
23 * This file contains the interface to the LPAR configuration data
24 * to determine which resources should be allocated to each partition.
25 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27#include <asm/iSeries/HvCallCfg.h>
28#include <asm/iSeries/HvTypes.h>
29#include <asm/iSeries/ItLpNaca.h>
30#include <asm/iSeries/LparData.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034static inline HvLpIndex HvLpConfig_getLpIndex(void)
35{
36 return itLpNaca.xLpIndex;
37}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070038
Linus Torvalds1da177e2005-04-16 15:20:36 -070039static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
40{
41 return itLpNaca.xPrimaryLpIndex;
42}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070043
Linus Torvalds1da177e2005-04-16 15:20:36 -070044static inline HvLpIndex HvLpConfig_getLps(void)
45{
46 return HvCallCfg_getLps();
47}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070048
49static inline HvLpIndexMap HvLpConfig_getActiveLpMap(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 return HvCallCfg_getActiveLpMap();
52}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070053
54static inline u64 HvLpConfig_getSystemMsMegs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
56 return HvCallCfg_getSystemMsChunks() / HVCHUNKSPERMEG;
57}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070058
59static inline u64 HvLpConfig_getSystemMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
61 return HvCallCfg_getSystemMsChunks();
62}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070063
64static inline u64 HvLpConfig_getSystemMsPages(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
66 return HvCallCfg_getSystemMsChunks() * HVPAGESPERCHUNK;
67}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070068
69static inline u64 HvLpConfig_getMsMegs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070071 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Cur)
72 / HVCHUNKSPERMEG;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070074
75static inline u64 HvLpConfig_getMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070077 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070079
80static inline u64 HvLpConfig_getMsPages(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070082 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Cur)
83 * HVPAGESPERCHUNK;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070085
86static inline u64 HvLpConfig_getMinMsMegs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070088 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Min)
89 / HVCHUNKSPERMEG;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070091
92static inline u64 HvLpConfig_getMinMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070094 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Min);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070096
97static inline u64 HvLpConfig_getMinMsPages(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070099 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Min)
100 * HVPAGESPERCHUNK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700102
103static inline u64 HvLpConfig_getMinRuntimeMsMegs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700105 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex())
106 / HVCHUNKSPERMEG;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700108
109static inline u64 HvLpConfig_getMinRuntimeMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
111 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex());
112}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700113
114static inline u64 HvLpConfig_getMinRuntimeMsPages(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700116 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex())
117 * HVPAGESPERCHUNK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700119
120static inline u64 HvLpConfig_getMaxMsMegs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700122 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Max)
123 / HVCHUNKSPERMEG;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700125
126static inline u64 HvLpConfig_getMaxMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700128 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700130
131static inline u64 HvLpConfig_getMaxMsPages(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700133 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Max)
134 * HVPAGESPERCHUNK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700136
137static inline u64 HvLpConfig_getInitMsMegs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700139 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Init)
140 / HVCHUNKSPERMEG;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700142
143static inline u64 HvLpConfig_getInitMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700145 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Init);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700147
148static inline u64 HvLpConfig_getInitMsPages(void)
149{
150 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(), HvCallCfg_Init)
151 * HVPAGESPERCHUNK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700153
154static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
156 return HvCallCfg_getSystemPhysicalProcessors();
157}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700158
159static inline u64 HvLpConfig_getSystemLogicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700161 return HvCallCfg_getSystemPhysicalProcessors()
162 * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700164
165static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166{
167 return HvCallCfg_getNumProcsInSharedPool(sPI);
168}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700169
170static inline u64 HvLpConfig_getPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700172 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
173 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700175
176static inline u64 HvLpConfig_getLogicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700178 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
179 HvCallCfg_Cur)
180 * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700182
183static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184{
185 return HvCallCfg_getSharedPoolIndex(HvLpConfig_getLpIndex());
186}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700187
188static inline u64 HvLpConfig_getSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700190 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),
191 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700193
194static inline u64 HvLpConfig_getMinSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700196 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),
197 HvCallCfg_Min);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700199
200static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700202 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),
203 HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700205
206static inline u64 HvLpConfig_getMinPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700208 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
209 HvCallCfg_Min);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700211
212static inline u64 HvLpConfig_getMinLogicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700214 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
215 HvCallCfg_Min)
216 * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700218
219static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700221 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
222 HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700224
225static inline u64 HvLpConfig_getMaxLogicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700227 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
228 HvCallCfg_Max)
229 * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700231
232static inline u64 HvLpConfig_getInitPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700234 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
235 HvCallCfg_Init);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700237
238static inline u64 HvLpConfig_getInitLogicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700240 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),
241 HvCallCfg_Init)
242 * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700244
245static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246{
247 return HvCallCfg_getVirtualLanIndexMap(HvLpConfig_getLpIndex_outline());
248}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700249
250static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(
251 HvLpIndex lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252{
253 return HvCallCfg_getVirtualLanIndexMap(lp);
254}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700255
256static inline HvLpIndex HvLpConfig_getBusOwner(HvBusNumber busNumber)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257{
258 return HvCallCfg_getBusOwner(busNumber);
259}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700260
261static inline int HvLpConfig_isBusDedicated(HvBusNumber busNumber)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
263 return HvCallCfg_isBusDedicated(busNumber);
264}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700265
266static inline HvLpIndexMap HvLpConfig_getBusAllocation(HvBusNumber busNumber)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267{
268 return HvCallCfg_getBusAllocation(busNumber);
269}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700270
271/* returns the absolute real address of the load area */
272static inline u64 HvLpConfig_getLoadAddress(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273{
274 return itLpNaca.xLoadAreaAddr & 0x7fffffffffffffff;
275}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700276
277static inline u64 HvLpConfig_getLoadPages(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278{
279 return itLpNaca.xLoadAreaChunks * HVPAGESPERCHUNK;
280}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700281
282static inline int HvLpConfig_isBusOwnedByThisLp(HvBusNumber busNumber)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283{
284 HvLpIndex busOwner = HvLpConfig_getBusOwner(busNumber);
285 return (busOwner == HvLpConfig_getLpIndex());
286}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700287
288static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,
289 HvLpIndex lp2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700291 HvLpVirtualLanIndexMap virtualLanIndexMap1 =
292 HvCallCfg_getVirtualLanIndexMap(lp1);
293 HvLpVirtualLanIndexMap virtualLanIndexMap2 =
294 HvCallCfg_getVirtualLanIndexMap(lp2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
296}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700297
298static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299{
300 return HvCallCfg_getHostingLpIndex(lp);
301}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303#endif /* _HVLPCONFIG_H */