blob: 685435af170d8d543fdf74b73d269325153e6e70 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
8 */
9
10
11#ifndef _ASM_IA64_SN_SN_CPUID_H
12#define _ASM_IA64_SN_SN_CPUID_H
13
14#include <linux/config.h>
15#include <linux/smp.h>
16#include <asm/sn/addrs.h>
17#include <asm/sn/pda.h>
18#include <asm/intrinsics.h>
19
20
21/*
22 * Functions for converting between cpuids, nodeids and NASIDs.
23 *
24 * These are for SGI platforms only.
25 *
26 */
27
28
29
30
31/*
32 * Definitions of terms (these definitions are for IA64 ONLY. Other architectures
33 * use cpuid/cpunum quite defferently):
34 *
35 * CPUID - a number in range of 0..NR_CPUS-1 that uniquely identifies
36 * the cpu. The value cpuid has no significance on IA64 other than
37 * the boot cpu is 0.
38 * smp_processor_id() returns the cpuid of the current cpu.
39 *
40 * CPU_PHYSICAL_ID (also known as HARD_PROCESSOR_ID)
41 * This is the same as 31:24 of the processor LID register
42 * hard_smp_processor_id()- cpu_physical_id of current processor
43 * cpu_physical_id(cpuid) - convert a <cpuid> to a <physical_cpuid>
44 * cpu_logical_id(phy_id) - convert a <physical_cpuid> to a <cpuid>
45 * * not real efficient - don't use in perf critical code
46 *
47 * SLICE - a number in the range of 0 - 3 (typically) that represents the
48 * cpu number on a brick.
49 *
50 * SUBNODE - (almost obsolete) the number of the FSB that a cpu is
51 * connected to. This is also the same as the PI number. Usually 0 or 1.
52 *
53 * NOTE!!!: the value of the bits in the cpu physical id (SAPICid or LID) of a cpu has no
54 * significance. The SAPIC id (LID) is a 16-bit cookie that has meaning only to the PROM.
55 *
56 *
57 * The macros convert between cpu physical ids & slice/nasid/cnodeid.
58 * These terms are described below:
59 *
60 *
61 * Brick
62 * ----- ----- ----- ----- CPU
63 * | 0 | | 1 | | 0 | | 1 | SLICE
64 * ----- ----- ----- -----
65 * | | | |
66 * | | | |
67 * 0 | | 2 0 | | 2 FSB SLOT
68 * ------- -------
69 * | |
70 * | |
71 * | |
72 * ------------ -------------
73 * | | | |
74 * | SHUB | | SHUB | NASID (0..MAX_NASIDS)
75 * | |----- | | CNODEID (0..num_compact_nodes-1)
76 * | | | |
77 * | | | |
78 * ------------ -------------
79 * | |
80 *
81 *
82 */
83
84#ifndef CONFIG_SMP
85#define cpu_physical_id(cpuid) ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
86#endif
87
88
89#define get_node_number(addr) NASID_GET(addr)
90
91/*
92 * NOTE: on non-MP systems, only cpuid 0 exists
93 */
94
95extern short physical_node_map[]; /* indexed by nasid to get cnode */
96
97/*
98 * Macros for retrieving info about current cpu
99 */
100#define get_nasid() (nodepda->phys_cpuid[smp_processor_id()].nasid)
101#define get_subnode() (nodepda->phys_cpuid[smp_processor_id()].subnode)
102#define get_slice() (nodepda->phys_cpuid[smp_processor_id()].slice)
103#define get_cnode() (nodepda->phys_cpuid[smp_processor_id()].cnode)
104#define get_sapicid() ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
105
106/*
107 * Macros for retrieving info about an arbitrary cpu
108 * cpuid - logical cpu id
109 */
110#define cpuid_to_nasid(cpuid) (nodepda->phys_cpuid[cpuid].nasid)
111#define cpuid_to_subnode(cpuid) (nodepda->phys_cpuid[cpuid].subnode)
112#define cpuid_to_slice(cpuid) (nodepda->phys_cpuid[cpuid].slice)
113#define cpuid_to_cnodeid(cpuid) (physical_node_map[cpuid_to_nasid(cpuid)])
114
115
116/*
117 * Dont use the following in performance critical code. They require scans
118 * of potentially large tables.
119 */
120extern int nasid_slice_to_cpuid(int, int);
121#define nasid_slice_to_cpu_physical_id(nasid, slice) \
122 cpu_physical_id(nasid_slice_to_cpuid(nasid, slice))
123
124/*
125 * cnodeid_to_nasid - convert a cnodeid to a NASID
126 * Macro relies on pg_data for a node being on the node itself.
127 * Just extract the NASID from the pointer.
128 *
129 */
130#define cnodeid_to_nasid(cnodeid) pda->cnodeid_to_nasid_table[cnodeid]
131
132/*
133 * nasid_to_cnodeid - convert a NASID to a cnodeid
134 */
135#define nasid_to_cnodeid(nasid) (physical_node_map[nasid])
136
137/*
138 * partition_coherence_id - get the coherence ID of the current partition
139 */
140extern u8 sn_coherency_id;
141#define partition_coherence_id() (sn_coherency_id)
142
143#endif /* _ASM_IA64_SN_SN_CPUID_H */
144