hv_lp_config.h 3.8 KB

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