blob: a006fd1e4a2ce18f85fb9e30fef336f518b3d337 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2001 Mike Corrigan IBM Corporation
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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.
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07008 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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.
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070013 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 * 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 */
Kelly Dalyecb3ca272005-11-02 15:53:01 +110018#ifndef _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H
19#define _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070021/*
22 * This file contains the interface to the LPAR configuration data
23 * to determine which resources should be allocated to each partition.
24 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Kelly Daly50592f52005-11-02 11:37:22 +110026#include <asm/iseries/hv_call_sc.h>
Kelly Daly1ec65d72005-11-02 13:46:07 +110027#include <asm/iseries/hv_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Stephen Rothwell2310c972005-06-21 17:15:38 -070029enum {
30 HvCallCfg_Cur = 0,
31 HvCallCfg_Init = 1,
32 HvCallCfg_Max = 2,
33 HvCallCfg_Min = 3
34};
35
36#define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6
37#define HvCallCfgGetPhysicalProcessors HvCallCfg + 7
38#define HvCallCfgGetMsChunks HvCallCfg + 9
39#define HvCallCfgGetSharedPoolIndex HvCallCfg + 20
40#define HvCallCfgGetSharedProcUnits HvCallCfg + 21
41#define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22
42#define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30
43#define HvCallCfgGetHostingLpIndex HvCallCfg + 32
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
Michael Ellermana2ced112006-07-13 17:52:12 +100046extern HvLpIndex HvLpConfig_getLpIndex(void);
47extern HvLpIndex HvLpConfig_getPrimaryLpIndex(void);
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070048
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070049static inline u64 HvLpConfig_getMsChunks(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
Stephen Rothwell2310c972005-06-21 17:15:38 -070051 return HvCall2(HvCallCfgGetMsChunks, HvLpConfig_getLpIndex(),
52 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070054
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070055static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
Stephen Rothwell2310c972005-06-21 17:15:38 -070057 return HvCall0(HvCallCfgGetSystemPhysicalProcessors);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070059
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070060static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
Stephen Rothwell2310c972005-06-21 17:15:38 -070062 return (u16)HvCall1(HvCallCfgGetNumProcsInSharedPool, sPI);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070064
65static inline u64 HvLpConfig_getPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
Stephen Rothwell2310c972005-06-21 17:15:38 -070067 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070068 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070070
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070071static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
Stephen Rothwell2310c972005-06-21 17:15:38 -070073 return HvCall1(HvCallCfgGetSharedPoolIndex, HvLpConfig_getLpIndex());
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070075
76static inline u64 HvLpConfig_getSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077{
Stephen Rothwell2310c972005-06-21 17:15:38 -070078 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070079 HvCallCfg_Cur);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070081
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070082static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
Stephen Rothwell2310c972005-06-21 17:15:38 -070084 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070085 HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070087
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070088static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
Stephen Rothwell2310c972005-06-21 17:15:38 -070090 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070091 HvCallCfg_Max);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070093
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070094static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(
95 HvLpIndex lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Stephen Rothwell2310c972005-06-21 17:15:38 -070097 /*
98 * This is a new function in V5R1 so calls to this on older
99 * hypervisors will return -1
100 */
101 u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp);
102 if (retVal == -1)
103 retVal = 0;
104 return retVal;
105}
106
107static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
108{
109 return HvLpConfig_getVirtualLanIndexMapForLp(
110 HvLpConfig_getLpIndex_outline());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700112
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700113static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,
114 HvLpIndex lp2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115{
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700116 HvLpVirtualLanIndexMap virtualLanIndexMap1 =
Stephen Rothwell2310c972005-06-21 17:15:38 -0700117 HvLpConfig_getVirtualLanIndexMapForLp(lp1);
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700118 HvLpVirtualLanIndexMap virtualLanIndexMap2 =
Stephen Rothwell2310c972005-06-21 17:15:38 -0700119 HvLpConfig_getVirtualLanIndexMapForLp(lp2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
121}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700122
123static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
Stephen Rothwell2310c972005-06-21 17:15:38 -0700125 return HvCall1(HvCallCfgGetHostingLpIndex, lp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Kelly Dalyecb3ca272005-11-02 15:53:01 +1100128#endif /* _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H */