HvLpConfig.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/HvCallSc.h>
  26. #include <asm/iSeries/HvTypes.h>
  27. #include <asm/iSeries/ItLpNaca.h>
  28. enum {
  29. HvCallCfg_Cur = 0,
  30. HvCallCfg_Init = 1,
  31. HvCallCfg_Max = 2,
  32. HvCallCfg_Min = 3
  33. };
  34. #define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6
  35. #define HvCallCfgGetPhysicalProcessors HvCallCfg + 7
  36. #define HvCallCfgGetMsChunks HvCallCfg + 9
  37. #define HvCallCfgGetSharedPoolIndex HvCallCfg + 20
  38. #define HvCallCfgGetSharedProcUnits HvCallCfg + 21
  39. #define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22
  40. #define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30
  41. #define HvCallCfgGetHostingLpIndex HvCallCfg + 32
  42. extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
  43. static inline HvLpIndex HvLpConfig_getLpIndex(void)
  44. {
  45. return itLpNaca.xLpIndex;
  46. }
  47. static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
  48. {
  49. return itLpNaca.xPrimaryLpIndex;
  50. }
  51. static inline u64 HvLpConfig_getMsChunks(void)
  52. {
  53. return HvCall2(HvCallCfgGetMsChunks, HvLpConfig_getLpIndex(),
  54. HvCallCfg_Cur);
  55. }
  56. static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
  57. {
  58. return HvCall0(HvCallCfgGetSystemPhysicalProcessors);
  59. }
  60. static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
  61. {
  62. return (u16)HvCall1(HvCallCfgGetNumProcsInSharedPool, sPI);
  63. }
  64. static inline u64 HvLpConfig_getPhysicalProcessors(void)
  65. {
  66. return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
  67. HvCallCfg_Cur);
  68. }
  69. static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
  70. {
  71. return HvCall1(HvCallCfgGetSharedPoolIndex, HvLpConfig_getLpIndex());
  72. }
  73. static inline u64 HvLpConfig_getSharedProcUnits(void)
  74. {
  75. return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
  76. HvCallCfg_Cur);
  77. }
  78. static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
  79. {
  80. return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
  81. HvCallCfg_Max);
  82. }
  83. static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
  84. {
  85. return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
  86. HvCallCfg_Max);
  87. }
  88. static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(
  89. HvLpIndex lp)
  90. {
  91. /*
  92. * This is a new function in V5R1 so calls to this on older
  93. * hypervisors will return -1
  94. */
  95. u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp);
  96. if (retVal == -1)
  97. retVal = 0;
  98. return retVal;
  99. }
  100. static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
  101. {
  102. return HvLpConfig_getVirtualLanIndexMapForLp(
  103. HvLpConfig_getLpIndex_outline());
  104. }
  105. static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,
  106. HvLpIndex lp2)
  107. {
  108. HvLpVirtualLanIndexMap virtualLanIndexMap1 =
  109. HvLpConfig_getVirtualLanIndexMapForLp(lp1);
  110. HvLpVirtualLanIndexMap virtualLanIndexMap2 =
  111. HvLpConfig_getVirtualLanIndexMapForLp(lp2);
  112. return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
  113. }
  114. static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
  115. {
  116. return HvCall1(HvCallCfgGetHostingLpIndex, lp);
  117. }
  118. #endif /* _HVLPCONFIG_H */