uv_hub.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * SGI UV architectural definitions
  7. *
  8. * Copyright (C) 2008 Silicon Graphics, Inc. All rights reserved.
  9. */
  10. #ifndef __ASM_IA64_UV_HUB_H__
  11. #define __ASM_IA64_UV_HUB_H__
  12. #include <linux/numa.h>
  13. #include <linux/percpu.h>
  14. #include <asm/types.h>
  15. #include <asm/percpu.h>
  16. /*
  17. * Addressing Terminology
  18. *
  19. * M - The low M bits of a physical address represent the offset
  20. * into the blade local memory. RAM memory on a blade is physically
  21. * contiguous (although various IO spaces may punch holes in
  22. * it)..
  23. *
  24. * N - Number of bits in the node portion of a socket physical
  25. * address.
  26. *
  27. * NASID - network ID of a router, Mbrick or Cbrick. Nasid values of
  28. * routers always have low bit of 1, C/MBricks have low bit
  29. * equal to 0. Most addressing macros that target UV hub chips
  30. * right shift the NASID by 1 to exclude the always-zero bit.
  31. * NASIDs contain up to 15 bits.
  32. *
  33. * GNODE - NASID right shifted by 1 bit. Most mmrs contain gnodes instead
  34. * of nasids.
  35. *
  36. * PNODE - the low N bits of the GNODE. The PNODE is the most useful variant
  37. * of the nasid for socket usage.
  38. *
  39. *
  40. * NumaLink Global Physical Address Format:
  41. * +--------------------------------+---------------------+
  42. * |00..000| GNODE | NodeOffset |
  43. * +--------------------------------+---------------------+
  44. * |<-------53 - M bits --->|<--------M bits ----->
  45. *
  46. * M - number of node offset bits (35 .. 40)
  47. *
  48. *
  49. * Memory/UV-HUB Processor Socket Address Format:
  50. * +----------------+---------------+---------------------+
  51. * |00..000000000000| PNODE | NodeOffset |
  52. * +----------------+---------------+---------------------+
  53. * <--- N bits --->|<--------M bits ----->
  54. *
  55. * M - number of node offset bits (35 .. 40)
  56. * N - number of PNODE bits (0 .. 10)
  57. *
  58. * Note: M + N cannot currently exceed 44 (x86_64) or 46 (IA64).
  59. * The actual values are configuration dependent and are set at
  60. * boot time. M & N values are set by the hardware/BIOS at boot.
  61. */
  62. /*
  63. * Maximum number of bricks in all partitions and in all coherency domains.
  64. * This is the total number of bricks accessible in the numalink fabric. It
  65. * includes all C & M bricks. Routers are NOT included.
  66. *
  67. * This value is also the value of the maximum number of non-router NASIDs
  68. * in the numalink fabric.
  69. *
  70. * NOTE: a brick may contain 1 or 2 OS nodes. Don't get these confused.
  71. */
  72. #define UV_MAX_NUMALINK_BLADES 16384
  73. /*
  74. * Maximum number of C/Mbricks within a software SSI (hardware may support
  75. * more).
  76. */
  77. #define UV_MAX_SSI_BLADES 1
  78. /*
  79. * The largest possible NASID of a C or M brick (+ 2)
  80. */
  81. #define UV_MAX_NASID_VALUE (UV_MAX_NUMALINK_NODES * 2)
  82. /*
  83. * The following defines attributes of the HUB chip. These attributes are
  84. * frequently referenced and are kept in the per-cpu data areas of each cpu.
  85. * They are kept together in a struct to minimize cache misses.
  86. */
  87. struct uv_hub_info_s {
  88. unsigned long global_mmr_base;
  89. unsigned long gpa_mask;
  90. unsigned long gnode_upper;
  91. unsigned long lowmem_remap_top;
  92. unsigned long lowmem_remap_base;
  93. unsigned short pnode;
  94. unsigned short pnode_mask;
  95. unsigned short coherency_domain_number;
  96. unsigned short numa_blade_id;
  97. unsigned char blade_processor_id;
  98. unsigned char m_val;
  99. unsigned char n_val;
  100. };
  101. DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
  102. #define uv_hub_info this_cpu_ptr(&__uv_hub_info)
  103. #define uv_cpu_hub_info(cpu) (&per_cpu(__uv_hub_info, cpu))
  104. /*
  105. * Local & Global MMR space macros.
  106. * Note: macros are intended to be used ONLY by inline functions
  107. * in this file - not by other kernel code.
  108. * n - NASID (full 15-bit global nasid)
  109. * g - GNODE (full 15-bit global nasid, right shifted 1)
  110. * p - PNODE (local part of nsids, right shifted 1)
  111. */
  112. #define UV_NASID_TO_PNODE(n) (((n) >> 1) & uv_hub_info->pnode_mask)
  113. #define UV_PNODE_TO_NASID(p) (((p) << 1) | uv_hub_info->gnode_upper)
  114. #define UV_LOCAL_MMR_BASE 0xf4000000UL
  115. #define UV_GLOBAL_MMR32_BASE 0xf8000000UL
  116. #define UV_GLOBAL_MMR64_BASE (uv_hub_info->global_mmr_base)
  117. #define UV_GLOBAL_MMR32_PNODE_SHIFT 15
  118. #define UV_GLOBAL_MMR64_PNODE_SHIFT 26
  119. #define UV_GLOBAL_MMR32_PNODE_BITS(p) ((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT))
  120. #define UV_GLOBAL_MMR64_PNODE_BITS(p) \
  121. ((unsigned long)(p) << UV_GLOBAL_MMR64_PNODE_SHIFT)
  122. /*
  123. * Macros for converting between kernel virtual addresses, socket local physical
  124. * addresses, and UV global physical addresses.
  125. * Note: use the standard __pa() & __va() macros for converting
  126. * between socket virtual and socket physical addresses.
  127. */
  128. /* socket phys RAM --> UV global physical address */
  129. static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
  130. {
  131. if (paddr < uv_hub_info->lowmem_remap_top)
  132. paddr += uv_hub_info->lowmem_remap_base;
  133. return paddr | uv_hub_info->gnode_upper;
  134. }
  135. /* socket virtual --> UV global physical address */
  136. static inline unsigned long uv_gpa(void *v)
  137. {
  138. return __pa(v) | uv_hub_info->gnode_upper;
  139. }
  140. /* socket virtual --> UV global physical address */
  141. static inline void *uv_vgpa(void *v)
  142. {
  143. return (void *)uv_gpa(v);
  144. }
  145. /* UV global physical address --> socket virtual */
  146. static inline void *uv_va(unsigned long gpa)
  147. {
  148. return __va(gpa & uv_hub_info->gpa_mask);
  149. }
  150. /* pnode, offset --> socket virtual */
  151. static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
  152. {
  153. return __va(((unsigned long)pnode << uv_hub_info->m_val) | offset);
  154. }
  155. /*
  156. * Access global MMRs using the low memory MMR32 space. This region supports
  157. * faster MMR access but not all MMRs are accessible in this space.
  158. */
  159. static inline unsigned long *uv_global_mmr32_address(int pnode,
  160. unsigned long offset)
  161. {
  162. return __va(UV_GLOBAL_MMR32_BASE |
  163. UV_GLOBAL_MMR32_PNODE_BITS(pnode) | offset);
  164. }
  165. static inline void uv_write_global_mmr32(int pnode, unsigned long offset,
  166. unsigned long val)
  167. {
  168. *uv_global_mmr32_address(pnode, offset) = val;
  169. }
  170. static inline unsigned long uv_read_global_mmr32(int pnode,
  171. unsigned long offset)
  172. {
  173. return *uv_global_mmr32_address(pnode, offset);
  174. }
  175. /*
  176. * Access Global MMR space using the MMR space located at the top of physical
  177. * memory.
  178. */
  179. static inline unsigned long *uv_global_mmr64_address(int pnode,
  180. unsigned long offset)
  181. {
  182. return __va(UV_GLOBAL_MMR64_BASE |
  183. UV_GLOBAL_MMR64_PNODE_BITS(pnode) | offset);
  184. }
  185. static inline void uv_write_global_mmr64(int pnode, unsigned long offset,
  186. unsigned long val)
  187. {
  188. *uv_global_mmr64_address(pnode, offset) = val;
  189. }
  190. static inline unsigned long uv_read_global_mmr64(int pnode,
  191. unsigned long offset)
  192. {
  193. return *uv_global_mmr64_address(pnode, offset);
  194. }
  195. /*
  196. * Access hub local MMRs. Faster than using global space but only local MMRs
  197. * are accessible.
  198. */
  199. static inline unsigned long *uv_local_mmr_address(unsigned long offset)
  200. {
  201. return __va(UV_LOCAL_MMR_BASE | offset);
  202. }
  203. static inline unsigned long uv_read_local_mmr(unsigned long offset)
  204. {
  205. return *uv_local_mmr_address(offset);
  206. }
  207. static inline void uv_write_local_mmr(unsigned long offset, unsigned long val)
  208. {
  209. *uv_local_mmr_address(offset) = val;
  210. }
  211. /*
  212. * Structures and definitions for converting between cpu, node, pnode, and blade
  213. * numbers.
  214. */
  215. /* Blade-local cpu number of current cpu. Numbered 0 .. <# cpus on the blade> */
  216. static inline int uv_blade_processor_id(void)
  217. {
  218. return smp_processor_id();
  219. }
  220. /* Blade number of current cpu. Numnbered 0 .. <#blades -1> */
  221. static inline int uv_numa_blade_id(void)
  222. {
  223. return 0;
  224. }
  225. /* Convert a cpu number to the the UV blade number */
  226. static inline int uv_cpu_to_blade_id(int cpu)
  227. {
  228. return 0;
  229. }
  230. /* Convert linux node number to the UV blade number */
  231. static inline int uv_node_to_blade_id(int nid)
  232. {
  233. return 0;
  234. }
  235. /* Convert a blade id to the PNODE of the blade */
  236. static inline int uv_blade_to_pnode(int bid)
  237. {
  238. return 0;
  239. }
  240. /* Determine the number of possible cpus on a blade */
  241. static inline int uv_blade_nr_possible_cpus(int bid)
  242. {
  243. return num_possible_cpus();
  244. }
  245. /* Determine the number of online cpus on a blade */
  246. static inline int uv_blade_nr_online_cpus(int bid)
  247. {
  248. return num_online_cpus();
  249. }
  250. /* Convert a cpu id to the PNODE of the blade containing the cpu */
  251. static inline int uv_cpu_to_pnode(int cpu)
  252. {
  253. return 0;
  254. }
  255. /* Convert a linux node number to the PNODE of the blade */
  256. static inline int uv_node_to_pnode(int nid)
  257. {
  258. return 0;
  259. }
  260. /* Maximum possible number of blades */
  261. static inline int uv_num_possible_blades(void)
  262. {
  263. return 1;
  264. }
  265. static inline void uv_hub_send_ipi(int pnode, int apicid, int vector)
  266. {
  267. /* not currently needed on ia64 */
  268. }
  269. #endif /* __ASM_IA64_UV_HUB__ */