hv_lp_config.h 3.9 KB

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