blob: bc00f036bca03d6f1abd9cb640964e6332da3b14 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * HvLpConfig.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07004 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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.
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07009 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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.
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070014 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * 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 */
Kelly Dalyecb3ca272005-11-02 15:53:01 +110019#ifndef _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H
20#define _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070022/*
23 * This file contains the interface to the LPAR configuration data
24 * to determine which resources should be allocated to each partition.
25 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Kelly Daly50592f52005-11-02 11:37:22 +110027#include <asm/iseries/hv_call_sc.h>
Kelly Daly1ec65d72005-11-02 13:46:07 +110028#include <asm/iseries/hv_types.h>
Kelly Dalyf218aab2005-11-02 13:51:41 +110029#include <asm/iseries/it_lp_naca.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Stephen Rothwell2310c972005-06-21 17:15:38 -070031enum {
32 HvCallCfg_Cur = 0,
33 HvCallCfg_Init = 1,
34 HvCallCfg_Max = 2,
35 HvCallCfg_Min = 3
36};
37
38#define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6
39#define HvCallCfgGetPhysicalProcessors HvCallCfg + 7
40#define HvCallCfgGetMsChunks HvCallCfg + 9
41#define HvCallCfgGetSharedPoolIndex HvCallCfg + 20
42#define HvCallCfgGetSharedProcUnits HvCallCfg + 21
43#define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22
44#define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30
45#define HvCallCfgGetHostingLpIndex HvCallCfg + 32
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049static inline HvLpIndex HvLpConfig_getLpIndex(void)
50{
51 return itLpNaca.xLpIndex;
52}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
55{
56 return itLpNaca.xPrimaryLpIndex;
57}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070058
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070059static inline u64 HvLpConfig_getMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
Stephen Rothwell2310c972005-06-21 17:15:38 -070061 return HvCall2(HvCallCfgGetMsChunks, HvLpConfig_getLpIndex(),
62 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070064
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070065static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
Stephen Rothwell2310c972005-06-21 17:15:38 -070067 return HvCall0(HvCallCfgGetSystemPhysicalProcessors);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070069
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070070static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Stephen Rothwell2310c972005-06-21 17:15:38 -070072 return (u16)HvCall1(HvCallCfgGetNumProcsInSharedPool, sPI);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070074
75static inline u64 HvLpConfig_getPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Stephen Rothwell2310c972005-06-21 17:15:38 -070077 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070078 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070080
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070081static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Stephen Rothwell2310c972005-06-21 17:15:38 -070083 return HvCall1(HvCallCfgGetSharedPoolIndex, HvLpConfig_getLpIndex());
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070085
86static inline u64 HvLpConfig_getSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Stephen Rothwell2310c972005-06-21 17:15:38 -070088 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070089 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070091
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070092static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
Stephen Rothwell2310c972005-06-21 17:15:38 -070094 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070095 HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070097
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070098static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099{
Stephen Rothwell2310c972005-06-21 17:15:38 -0700100 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700101 HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700103
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700104static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(
105 HvLpIndex lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
Stephen Rothwell2310c972005-06-21 17:15:38 -0700107 /*
108 * This is a new function in V5R1 so calls to this on older
109 * hypervisors will return -1
110 */
111 u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp);
112 if (retVal == -1)
113 retVal = 0;
114 return retVal;
115}
116
117static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
118{
119 return HvLpConfig_getVirtualLanIndexMapForLp(
120 HvLpConfig_getLpIndex_outline());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700122
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700123static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,
124 HvLpIndex lp2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700126 HvLpVirtualLanIndexMap virtualLanIndexMap1 =
Stephen Rothwell2310c972005-06-21 17:15:38 -0700127 HvLpConfig_getVirtualLanIndexMapForLp(lp1);
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700128 HvLpVirtualLanIndexMap virtualLanIndexMap2 =
Stephen Rothwell2310c972005-06-21 17:15:38 -0700129 HvLpConfig_getVirtualLanIndexMapForLp(lp2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
131}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700132
133static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
Stephen Rothwell2310c972005-06-21 17:15:38 -0700135 return HvCall1(HvCallCfgGetHostingLpIndex, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Kelly Dalyecb3ca272005-11-02 15:53:01 +1100138#endif /* _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H */