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