xref: /openbmc/linux/arch/x86/include/asm/uv/uv_hub.h (revision 729d69e6)
1bb898558SAl Viro /*
2bb898558SAl Viro  * This file is subject to the terms and conditions of the GNU General Public
3bb898558SAl Viro  * License.  See the file "COPYING" in the main directory of this archive
4bb898558SAl Viro  * for more details.
5bb898558SAl Viro  *
6bb898558SAl Viro  * SGI UV architectural definitions
7bb898558SAl Viro  *
8bb898558SAl Viro  * Copyright (C) 2007-2008 Silicon Graphics, Inc. All rights reserved.
9bb898558SAl Viro  */
10bb898558SAl Viro 
1105e4d316SH. Peter Anvin #ifndef _ASM_X86_UV_UV_HUB_H
1205e4d316SH. Peter Anvin #define _ASM_X86_UV_UV_HUB_H
13bb898558SAl Viro 
14bc5d9940SJack Steiner #ifdef CONFIG_X86_64
15bb898558SAl Viro #include <linux/numa.h>
16bb898558SAl Viro #include <linux/percpu.h>
17c08b6accSMike Travis #include <linux/timer.h>
188dc579e8SJack Steiner #include <linux/io.h>
19bb898558SAl Viro #include <asm/types.h>
20bb898558SAl Viro #include <asm/percpu.h>
2166666e50SJack Steiner #include <asm/uv/uv_mmrs.h>
2202dd0a06SRobin Holt #include <asm/irq_vectors.h>
2302dd0a06SRobin Holt #include <asm/io_apic.h>
24bb898558SAl Viro 
25bb898558SAl Viro 
26bb898558SAl Viro /*
27bb898558SAl Viro  * Addressing Terminology
28bb898558SAl Viro  *
29bb898558SAl Viro  *	M       - The low M bits of a physical address represent the offset
30bb898558SAl Viro  *		  into the blade local memory. RAM memory on a blade is physically
31bb898558SAl Viro  *		  contiguous (although various IO spaces may punch holes in
32bb898558SAl Viro  *		  it)..
33bb898558SAl Viro  *
34bb898558SAl Viro  * 	N	- Number of bits in the node portion of a socket physical
35bb898558SAl Viro  * 		  address.
36bb898558SAl Viro  *
37bb898558SAl Viro  * 	NASID   - network ID of a router, Mbrick or Cbrick. Nasid values of
38bb898558SAl Viro  * 	 	  routers always have low bit of 1, C/MBricks have low bit
39bb898558SAl Viro  * 		  equal to 0. Most addressing macros that target UV hub chips
40bb898558SAl Viro  * 		  right shift the NASID by 1 to exclude the always-zero bit.
41bb898558SAl Viro  * 		  NASIDs contain up to 15 bits.
42bb898558SAl Viro  *
43bb898558SAl Viro  *	GNODE   - NASID right shifted by 1 bit. Most mmrs contain gnodes instead
44bb898558SAl Viro  *		  of nasids.
45bb898558SAl Viro  *
46bb898558SAl Viro  * 	PNODE   - the low N bits of the GNODE. The PNODE is the most useful variant
47bb898558SAl Viro  * 		  of the nasid for socket usage.
48bb898558SAl Viro  *
49bb898558SAl Viro  *
50bb898558SAl Viro  *  NumaLink Global Physical Address Format:
51bb898558SAl Viro  *  +--------------------------------+---------------------+
52bb898558SAl Viro  *  |00..000|      GNODE             |      NodeOffset     |
53bb898558SAl Viro  *  +--------------------------------+---------------------+
54bb898558SAl Viro  *          |<-------53 - M bits --->|<--------M bits ----->
55bb898558SAl Viro  *
56bb898558SAl Viro  *	M - number of node offset bits (35 .. 40)
57bb898558SAl Viro  *
58bb898558SAl Viro  *
59bb898558SAl Viro  *  Memory/UV-HUB Processor Socket Address Format:
60bb898558SAl Viro  *  +----------------+---------------+---------------------+
61bb898558SAl Viro  *  |00..000000000000|   PNODE       |      NodeOffset     |
62bb898558SAl Viro  *  +----------------+---------------+---------------------+
63bb898558SAl Viro  *                   <--- N bits --->|<--------M bits ----->
64bb898558SAl Viro  *
65bb898558SAl Viro  *	M - number of node offset bits (35 .. 40)
66bb898558SAl Viro  *	N - number of PNODE bits (0 .. 10)
67bb898558SAl Viro  *
68bb898558SAl Viro  *		Note: M + N cannot currently exceed 44 (x86_64) or 46 (IA64).
69bb898558SAl Viro  *		The actual values are configuration dependent and are set at
70bb898558SAl Viro  *		boot time. M & N values are set by the hardware/BIOS at boot.
71bb898558SAl Viro  *
72bb898558SAl Viro  *
73bb898558SAl Viro  * APICID format
74bb898558SAl Viro  * 	NOTE!!!!!! This is the current format of the APICID. However, code
75bb898558SAl Viro  * 	should assume that this will change in the future. Use functions
76bb898558SAl Viro  * 	in this file for all APICID bit manipulations and conversion.
77bb898558SAl Viro  *
78bb898558SAl Viro  * 		1111110000000000
79bb898558SAl Viro  * 		5432109876543210
80bb898558SAl Viro  *		pppppppppplc0cch
81bb898558SAl Viro  *		sssssssssss
82bb898558SAl Viro  *
83bb898558SAl Viro  *			p  = pnode bits
84bb898558SAl Viro  *			l =  socket number on board
85bb898558SAl Viro  *			c  = core
86bb898558SAl Viro  *			h  = hyperthread
87bb898558SAl Viro  *			s  = bits that are in the SOCKET_ID CSR
88bb898558SAl Viro  *
89bb898558SAl Viro  *	Note: Processor only supports 12 bits in the APICID register. The ACPI
90bb898558SAl Viro  *	      tables hold all 16 bits. Software needs to be aware of this.
91bb898558SAl Viro  *
92bb898558SAl Viro  * 	      Unless otherwise specified, all references to APICID refer to
93bb898558SAl Viro  * 	      the FULL value contained in ACPI tables, not the subset in the
94bb898558SAl Viro  * 	      processor APICID register.
95bb898558SAl Viro  */
96bb898558SAl Viro 
97bb898558SAl Viro 
98bb898558SAl Viro /*
99bb898558SAl Viro  * Maximum number of bricks in all partitions and in all coherency domains.
100bb898558SAl Viro  * This is the total number of bricks accessible in the numalink fabric. It
101bb898558SAl Viro  * includes all C & M bricks. Routers are NOT included.
102bb898558SAl Viro  *
103bb898558SAl Viro  * This value is also the value of the maximum number of non-router NASIDs
104bb898558SAl Viro  * in the numalink fabric.
105bb898558SAl Viro  *
106bb898558SAl Viro  * NOTE: a brick may contain 1 or 2 OS nodes. Don't get these confused.
107bb898558SAl Viro  */
108bb898558SAl Viro #define UV_MAX_NUMALINK_BLADES	16384
109bb898558SAl Viro 
110bb898558SAl Viro /*
111bb898558SAl Viro  * Maximum number of C/Mbricks within a software SSI (hardware may support
112bb898558SAl Viro  * more).
113bb898558SAl Viro  */
114bb898558SAl Viro #define UV_MAX_SSI_BLADES	256
115bb898558SAl Viro 
116bb898558SAl Viro /*
117bb898558SAl Viro  * The largest possible NASID of a C or M brick (+ 2)
118bb898558SAl Viro  */
1191d21e6e3SRobin Holt #define UV_MAX_NASID_VALUE	(UV_MAX_NUMALINK_BLADES * 2)
120bb898558SAl Viro 
1217f1baa06SMike Travis struct uv_scir_s {
1227f1baa06SMike Travis 	struct timer_list timer;
1237f1baa06SMike Travis 	unsigned long	offset;
1247f1baa06SMike Travis 	unsigned long	last;
1257f1baa06SMike Travis 	unsigned long	idle_on;
1267f1baa06SMike Travis 	unsigned long	idle_off;
1277f1baa06SMike Travis 	unsigned char	state;
1287f1baa06SMike Travis 	unsigned char	enabled;
1297f1baa06SMike Travis };
1307f1baa06SMike Travis 
131bb898558SAl Viro /*
132bb898558SAl Viro  * The following defines attributes of the HUB chip. These attributes are
133bb898558SAl Viro  * frequently referenced and are kept in the per-cpu data areas of each cpu.
134bb898558SAl Viro  * They are kept together in a struct to minimize cache misses.
135bb898558SAl Viro  */
136bb898558SAl Viro struct uv_hub_info_s {
137bb898558SAl Viro 	unsigned long		global_mmr_base;
138bb898558SAl Viro 	unsigned long		gpa_mask;
139c4ed3f04SJack Steiner 	unsigned int		gnode_extra;
140bb898558SAl Viro 	unsigned long		gnode_upper;
141bb898558SAl Viro 	unsigned long		lowmem_remap_top;
142bb898558SAl Viro 	unsigned long		lowmem_remap_base;
143bb898558SAl Viro 	unsigned short		pnode;
144bb898558SAl Viro 	unsigned short		pnode_mask;
145bb898558SAl Viro 	unsigned short		coherency_domain_number;
146bb898558SAl Viro 	unsigned short		numa_blade_id;
147bb898558SAl Viro 	unsigned char		blade_processor_id;
148bb898558SAl Viro 	unsigned char		m_val;
149bb898558SAl Viro 	unsigned char		n_val;
1507f1baa06SMike Travis 	struct uv_scir_s	scir;
151bb898558SAl Viro };
1527f1baa06SMike Travis 
153bb898558SAl Viro DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
154bb898558SAl Viro #define uv_hub_info 		(&__get_cpu_var(__uv_hub_info))
155bb898558SAl Viro #define uv_cpu_hub_info(cpu)	(&per_cpu(__uv_hub_info, cpu))
156bb898558SAl Viro 
157bb898558SAl Viro /*
158bb898558SAl Viro  * Local & Global MMR space macros.
159bb898558SAl Viro  * 	Note: macros are intended to be used ONLY by inline functions
160bb898558SAl Viro  * 	in this file - not by other kernel code.
161bb898558SAl Viro  * 		n -  NASID (full 15-bit global nasid)
162bb898558SAl Viro  * 		g -  GNODE (full 15-bit global nasid, right shifted 1)
163bb898558SAl Viro  * 		p -  PNODE (local part of nsids, right shifted 1)
164bb898558SAl Viro  */
165bb898558SAl Viro #define UV_NASID_TO_PNODE(n)		(((n) >> 1) & uv_hub_info->pnode_mask)
166c4ed3f04SJack Steiner #define UV_PNODE_TO_GNODE(p)		((p) |uv_hub_info->gnode_extra)
167c4ed3f04SJack Steiner #define UV_PNODE_TO_NASID(p)		(UV_PNODE_TO_GNODE(p) << 1)
168bb898558SAl Viro 
169bb898558SAl Viro #define UV_LOCAL_MMR_BASE		0xf4000000UL
170bb898558SAl Viro #define UV_GLOBAL_MMR32_BASE		0xf8000000UL
171bb898558SAl Viro #define UV_GLOBAL_MMR64_BASE		(uv_hub_info->global_mmr_base)
172bb898558SAl Viro #define UV_LOCAL_MMR_SIZE		(64UL * 1024 * 1024)
173bb898558SAl Viro #define UV_GLOBAL_MMR32_SIZE		(64UL * 1024 * 1024)
174bb898558SAl Viro 
175bb898558SAl Viro #define UV_GLOBAL_MMR32_PNODE_SHIFT	15
176bb898558SAl Viro #define UV_GLOBAL_MMR64_PNODE_SHIFT	26
177bb898558SAl Viro 
178bb898558SAl Viro #define UV_GLOBAL_MMR32_PNODE_BITS(p)	((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT))
179bb898558SAl Viro 
180bb898558SAl Viro #define UV_GLOBAL_MMR64_PNODE_BITS(p)					\
18167e83f30SJack Steiner 	(((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT)
182bb898558SAl Viro 
183bb898558SAl Viro #define UV_APIC_PNODE_SHIFT	6
184bb898558SAl Viro 
1857f1baa06SMike Travis /* Local Bus from cpu's perspective */
1867f1baa06SMike Travis #define LOCAL_BUS_BASE		0x1c00000
1877f1baa06SMike Travis #define LOCAL_BUS_SIZE		(4 * 1024 * 1024)
1887f1baa06SMike Travis 
1897f1baa06SMike Travis /*
1907f1baa06SMike Travis  * System Controller Interface Reg
1917f1baa06SMike Travis  *
1927f1baa06SMike Travis  * Note there are NO leds on a UV system.  This register is only
1937f1baa06SMike Travis  * used by the system controller to monitor system-wide operation.
1947f1baa06SMike Travis  * There are 64 regs per node.  With Nahelem cpus (2 cores per node,
1957f1baa06SMike Travis  * 8 cpus per core, 2 threads per cpu) there are 32 cpu threads on
1967f1baa06SMike Travis  * a node.
1977f1baa06SMike Travis  *
1987f1baa06SMike Travis  * The window is located at top of ACPI MMR space
1997f1baa06SMike Travis  */
2007f1baa06SMike Travis #define SCIR_WINDOW_COUNT	64
2017f1baa06SMike Travis #define SCIR_LOCAL_MMR_BASE	(LOCAL_BUS_BASE + \
2027f1baa06SMike Travis 				 LOCAL_BUS_SIZE - \
2037f1baa06SMike Travis 				 SCIR_WINDOW_COUNT)
2047f1baa06SMike Travis 
2057f1baa06SMike Travis #define SCIR_CPU_HEARTBEAT	0x01	/* timer interrupt */
2067f1baa06SMike Travis #define SCIR_CPU_ACTIVITY	0x02	/* not idle */
2077f1baa06SMike Travis #define SCIR_CPU_HB_INTERVAL	(HZ)	/* once per second */
2087f1baa06SMike Travis 
2098661984fSDimitri Sivanich /* Loop through all installed blades */
2108661984fSDimitri Sivanich #define for_each_possible_blade(bid)		\
2118661984fSDimitri Sivanich 	for ((bid) = 0; (bid) < uv_num_possible_blades(); (bid)++)
2128661984fSDimitri Sivanich 
213bb898558SAl Viro /*
214bb898558SAl Viro  * Macros for converting between kernel virtual addresses, socket local physical
215bb898558SAl Viro  * addresses, and UV global physical addresses.
216bb898558SAl Viro  * 	Note: use the standard __pa() & __va() macros for converting
217bb898558SAl Viro  * 	      between socket virtual and socket physical addresses.
218bb898558SAl Viro  */
219bb898558SAl Viro 
220bb898558SAl Viro /* socket phys RAM --> UV global physical address */
221bb898558SAl Viro static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
222bb898558SAl Viro {
223bb898558SAl Viro 	if (paddr < uv_hub_info->lowmem_remap_top)
224189f67c4SJack Steiner 		paddr |= uv_hub_info->lowmem_remap_base;
225bb898558SAl Viro 	return paddr | uv_hub_info->gnode_upper;
226bb898558SAl Viro }
227bb898558SAl Viro 
228bb898558SAl Viro 
229bb898558SAl Viro /* socket virtual --> UV global physical address */
230bb898558SAl Viro static inline unsigned long uv_gpa(void *v)
231bb898558SAl Viro {
232189f67c4SJack Steiner 	return uv_soc_phys_ram_to_gpa(__pa(v));
233bb898558SAl Viro }
234bb898558SAl Viro 
235729d69e6SRobin Holt /* UV global physical address --> socket phys RAM */
236729d69e6SRobin Holt static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
237729d69e6SRobin Holt {
238729d69e6SRobin Holt 	unsigned long paddr = gpa & uv_hub_info->gpa_mask;
239729d69e6SRobin Holt 	unsigned long remap_base = uv_hub_info->lowmem_remap_base;
240729d69e6SRobin Holt 	unsigned long remap_top =  uv_hub_info->lowmem_remap_top;
241729d69e6SRobin Holt 
242729d69e6SRobin Holt 	if (paddr >= remap_base && paddr < remap_base + remap_top)
243729d69e6SRobin Holt 		paddr -= remap_base;
244729d69e6SRobin Holt 	return paddr;
245729d69e6SRobin Holt }
246729d69e6SRobin Holt 
247729d69e6SRobin Holt 
2481d21e6e3SRobin Holt /* gnode -> pnode */
2491d21e6e3SRobin Holt static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)
2501d21e6e3SRobin Holt {
2511d21e6e3SRobin Holt 	return gpa >> uv_hub_info->m_val;
2521d21e6e3SRobin Holt }
2531d21e6e3SRobin Holt 
2541d21e6e3SRobin Holt /* gpa -> pnode */
2551d21e6e3SRobin Holt static inline int uv_gpa_to_pnode(unsigned long gpa)
2561d21e6e3SRobin Holt {
2571d21e6e3SRobin Holt 	unsigned long n_mask = (1UL << uv_hub_info->n_val) - 1;
2581d21e6e3SRobin Holt 
2591d21e6e3SRobin Holt 	return uv_gpa_to_gnode(gpa) & n_mask;
2601d21e6e3SRobin Holt }
2611d21e6e3SRobin Holt 
262bb898558SAl Viro /* pnode, offset --> socket virtual */
263bb898558SAl Viro static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
264bb898558SAl Viro {
265bb898558SAl Viro 	return __va(((unsigned long)pnode << uv_hub_info->m_val) | offset);
266bb898558SAl Viro }
267bb898558SAl Viro 
268bb898558SAl Viro 
269bb898558SAl Viro /*
270bb898558SAl Viro  * Extract a PNODE from an APICID (full apicid, not processor subset)
271bb898558SAl Viro  */
272bb898558SAl Viro static inline int uv_apicid_to_pnode(int apicid)
273bb898558SAl Viro {
274bb898558SAl Viro 	return (apicid >> UV_APIC_PNODE_SHIFT);
275bb898558SAl Viro }
276bb898558SAl Viro 
277bb898558SAl Viro /*
278bb898558SAl Viro  * Access global MMRs using the low memory MMR32 space. This region supports
279bb898558SAl Viro  * faster MMR access but not all MMRs are accessible in this space.
280bb898558SAl Viro  */
281bb898558SAl Viro static inline unsigned long *uv_global_mmr32_address(int pnode,
282bb898558SAl Viro 				unsigned long offset)
283bb898558SAl Viro {
284bb898558SAl Viro 	return __va(UV_GLOBAL_MMR32_BASE |
285bb898558SAl Viro 		       UV_GLOBAL_MMR32_PNODE_BITS(pnode) | offset);
286bb898558SAl Viro }
287bb898558SAl Viro 
288bb898558SAl Viro static inline void uv_write_global_mmr32(int pnode, unsigned long offset,
289bb898558SAl Viro 				 unsigned long val)
290bb898558SAl Viro {
2918dc579e8SJack Steiner 	writeq(val, uv_global_mmr32_address(pnode, offset));
292bb898558SAl Viro }
293bb898558SAl Viro 
294bb898558SAl Viro static inline unsigned long uv_read_global_mmr32(int pnode,
295bb898558SAl Viro 						 unsigned long offset)
296bb898558SAl Viro {
2978dc579e8SJack Steiner 	return readq(uv_global_mmr32_address(pnode, offset));
298bb898558SAl Viro }
299bb898558SAl Viro 
300bb898558SAl Viro /*
301bb898558SAl Viro  * Access Global MMR space using the MMR space located at the top of physical
302bb898558SAl Viro  * memory.
303bb898558SAl Viro  */
304bb898558SAl Viro static inline unsigned long *uv_global_mmr64_address(int pnode,
305bb898558SAl Viro 				unsigned long offset)
306bb898558SAl Viro {
307bb898558SAl Viro 	return __va(UV_GLOBAL_MMR64_BASE |
308bb898558SAl Viro 		    UV_GLOBAL_MMR64_PNODE_BITS(pnode) | offset);
309bb898558SAl Viro }
310bb898558SAl Viro 
311bb898558SAl Viro static inline void uv_write_global_mmr64(int pnode, unsigned long offset,
312bb898558SAl Viro 				unsigned long val)
313bb898558SAl Viro {
3148dc579e8SJack Steiner 	writeq(val, uv_global_mmr64_address(pnode, offset));
315bb898558SAl Viro }
316bb898558SAl Viro 
317bb898558SAl Viro static inline unsigned long uv_read_global_mmr64(int pnode,
318bb898558SAl Viro 						 unsigned long offset)
319bb898558SAl Viro {
3208dc579e8SJack Steiner 	return readq(uv_global_mmr64_address(pnode, offset));
321bb898558SAl Viro }
322bb898558SAl Viro 
323bb898558SAl Viro /*
324bb898558SAl Viro  * Access hub local MMRs. Faster than using global space but only local MMRs
325bb898558SAl Viro  * are accessible.
326bb898558SAl Viro  */
327bb898558SAl Viro static inline unsigned long *uv_local_mmr_address(unsigned long offset)
328bb898558SAl Viro {
329bb898558SAl Viro 	return __va(UV_LOCAL_MMR_BASE | offset);
330bb898558SAl Viro }
331bb898558SAl Viro 
332bb898558SAl Viro static inline unsigned long uv_read_local_mmr(unsigned long offset)
333bb898558SAl Viro {
3348dc579e8SJack Steiner 	return readq(uv_local_mmr_address(offset));
335bb898558SAl Viro }
336bb898558SAl Viro 
337bb898558SAl Viro static inline void uv_write_local_mmr(unsigned long offset, unsigned long val)
338bb898558SAl Viro {
3398dc579e8SJack Steiner 	writeq(val, uv_local_mmr_address(offset));
340bb898558SAl Viro }
341bb898558SAl Viro 
3427f1baa06SMike Travis static inline unsigned char uv_read_local_mmr8(unsigned long offset)
3437f1baa06SMike Travis {
3448dc579e8SJack Steiner 	return readb(uv_local_mmr_address(offset));
3457f1baa06SMike Travis }
3467f1baa06SMike Travis 
3477f1baa06SMike Travis static inline void uv_write_local_mmr8(unsigned long offset, unsigned char val)
3487f1baa06SMike Travis {
3498dc579e8SJack Steiner 	writeb(val, uv_local_mmr_address(offset));
3507f1baa06SMike Travis }
3517f1baa06SMike Travis 
352bb898558SAl Viro /*
353bb898558SAl Viro  * Structures and definitions for converting between cpu, node, pnode, and blade
354bb898558SAl Viro  * numbers.
355bb898558SAl Viro  */
356bb898558SAl Viro struct uv_blade_info {
357bb898558SAl Viro 	unsigned short	nr_possible_cpus;
358bb898558SAl Viro 	unsigned short	nr_online_cpus;
359bb898558SAl Viro 	unsigned short	pnode;
3606c7184b7SJack Steiner 	short		memory_nid;
361bb898558SAl Viro };
362bb898558SAl Viro extern struct uv_blade_info *uv_blade_info;
363bb898558SAl Viro extern short *uv_node_to_blade;
364bb898558SAl Viro extern short *uv_cpu_to_blade;
365bb898558SAl Viro extern short uv_possible_blades;
366bb898558SAl Viro 
367bb898558SAl Viro /* Blade-local cpu number of current cpu. Numbered 0 .. <# cpus on the blade> */
368bb898558SAl Viro static inline int uv_blade_processor_id(void)
369bb898558SAl Viro {
370bb898558SAl Viro 	return uv_hub_info->blade_processor_id;
371bb898558SAl Viro }
372bb898558SAl Viro 
373bb898558SAl Viro /* Blade number of current cpu. Numnbered 0 .. <#blades -1> */
374bb898558SAl Viro static inline int uv_numa_blade_id(void)
375bb898558SAl Viro {
376bb898558SAl Viro 	return uv_hub_info->numa_blade_id;
377bb898558SAl Viro }
378bb898558SAl Viro 
379bb898558SAl Viro /* Convert a cpu number to the the UV blade number */
380bb898558SAl Viro static inline int uv_cpu_to_blade_id(int cpu)
381bb898558SAl Viro {
382bb898558SAl Viro 	return uv_cpu_to_blade[cpu];
383bb898558SAl Viro }
384bb898558SAl Viro 
385bb898558SAl Viro /* Convert linux node number to the UV blade number */
386bb898558SAl Viro static inline int uv_node_to_blade_id(int nid)
387bb898558SAl Viro {
388bb898558SAl Viro 	return uv_node_to_blade[nid];
389bb898558SAl Viro }
390bb898558SAl Viro 
391bb898558SAl Viro /* Convert a blade id to the PNODE of the blade */
392bb898558SAl Viro static inline int uv_blade_to_pnode(int bid)
393bb898558SAl Viro {
394bb898558SAl Viro 	return uv_blade_info[bid].pnode;
395bb898558SAl Viro }
396bb898558SAl Viro 
3976c7184b7SJack Steiner /* Nid of memory node on blade. -1 if no blade-local memory */
3986c7184b7SJack Steiner static inline int uv_blade_to_memory_nid(int bid)
3996c7184b7SJack Steiner {
4006c7184b7SJack Steiner 	return uv_blade_info[bid].memory_nid;
4016c7184b7SJack Steiner }
4026c7184b7SJack Steiner 
403bb898558SAl Viro /* Determine the number of possible cpus on a blade */
404bb898558SAl Viro static inline int uv_blade_nr_possible_cpus(int bid)
405bb898558SAl Viro {
406bb898558SAl Viro 	return uv_blade_info[bid].nr_possible_cpus;
407bb898558SAl Viro }
408bb898558SAl Viro 
409bb898558SAl Viro /* Determine the number of online cpus on a blade */
410bb898558SAl Viro static inline int uv_blade_nr_online_cpus(int bid)
411bb898558SAl Viro {
412bb898558SAl Viro 	return uv_blade_info[bid].nr_online_cpus;
413bb898558SAl Viro }
414bb898558SAl Viro 
415bb898558SAl Viro /* Convert a cpu id to the PNODE of the blade containing the cpu */
416bb898558SAl Viro static inline int uv_cpu_to_pnode(int cpu)
417bb898558SAl Viro {
418bb898558SAl Viro 	return uv_blade_info[uv_cpu_to_blade_id(cpu)].pnode;
419bb898558SAl Viro }
420bb898558SAl Viro 
421bb898558SAl Viro /* Convert a linux node number to the PNODE of the blade */
422bb898558SAl Viro static inline int uv_node_to_pnode(int nid)
423bb898558SAl Viro {
424bb898558SAl Viro 	return uv_blade_info[uv_node_to_blade_id(nid)].pnode;
425bb898558SAl Viro }
426bb898558SAl Viro 
427bb898558SAl Viro /* Maximum possible number of blades */
428bb898558SAl Viro static inline int uv_num_possible_blades(void)
429bb898558SAl Viro {
430bb898558SAl Viro 	return uv_possible_blades;
431bb898558SAl Viro }
432bb898558SAl Viro 
4337f1baa06SMike Travis /* Update SCIR state */
4347f1baa06SMike Travis static inline void uv_set_scir_bits(unsigned char value)
4357f1baa06SMike Travis {
4367f1baa06SMike Travis 	if (uv_hub_info->scir.state != value) {
4377f1baa06SMike Travis 		uv_hub_info->scir.state = value;
4387f1baa06SMike Travis 		uv_write_local_mmr8(uv_hub_info->scir.offset, value);
4397f1baa06SMike Travis 	}
4407f1baa06SMike Travis }
44166666e50SJack Steiner 
4427f1baa06SMike Travis static inline void uv_set_cpu_scir_bits(int cpu, unsigned char value)
4437f1baa06SMike Travis {
4447f1baa06SMike Travis 	if (uv_cpu_hub_info(cpu)->scir.state != value) {
4457f1baa06SMike Travis 		uv_cpu_hub_info(cpu)->scir.state = value;
4467f1baa06SMike Travis 		uv_write_local_mmr8(uv_cpu_hub_info(cpu)->scir.offset, value);
4477f1baa06SMike Travis 	}
4487f1baa06SMike Travis }
449bb898558SAl Viro 
45066666e50SJack Steiner static inline void uv_hub_send_ipi(int pnode, int apicid, int vector)
45166666e50SJack Steiner {
45266666e50SJack Steiner 	unsigned long val;
45302dd0a06SRobin Holt 	unsigned long dmode = dest_Fixed;
45402dd0a06SRobin Holt 
45502dd0a06SRobin Holt 	if (vector == NMI_VECTOR)
45602dd0a06SRobin Holt 		dmode = dest_NMI;
45766666e50SJack Steiner 
45866666e50SJack Steiner 	val = (1UL << UVH_IPI_INT_SEND_SHFT) |
459d2374aecSJack Steiner 			((apicid) << UVH_IPI_INT_APIC_ID_SHFT) |
46002dd0a06SRobin Holt 			(dmode << UVH_IPI_INT_DELIVERY_MODE_SHFT) |
46166666e50SJack Steiner 			(vector << UVH_IPI_INT_VECTOR_SHFT);
46266666e50SJack Steiner 	uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
46366666e50SJack Steiner }
46466666e50SJack Steiner 
465bc5d9940SJack Steiner #endif /* CONFIG_X86_64 */
4667f1baa06SMike Travis #endif /* _ASM_X86_UV_UV_HUB_H */
467