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