HvLpConfig.h 7.7 KB

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