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