sn_hwperf.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
  7. *
  8. * Data types used by the SN_SAL_HWPERF_OP SAL call for monitoring
  9. * SGI Altix node and router hardware
  10. *
  11. * Mark Goodwin <markgw@sgi.com> Mon Aug 30 12:23:46 EST 2004
  12. */
  13. #ifndef SN_HWPERF_H
  14. #define SN_HWPERF_H
  15. /*
  16. * object structure. SN_HWPERF_ENUM_OBJECTS and SN_HWPERF_GET_CPU_INFO
  17. * return an array of these. Do not change this without also
  18. * changing the corresponding SAL code.
  19. */
  20. #define SN_HWPERF_MAXSTRING 128
  21. struct sn_hwperf_object_info {
  22. u32 id;
  23. union {
  24. struct {
  25. u64 this_part:1;
  26. u64 is_shared:1;
  27. } fields;
  28. struct {
  29. u64 flags;
  30. u64 reserved;
  31. } b;
  32. } f;
  33. char name[SN_HWPERF_MAXSTRING];
  34. char location[SN_HWPERF_MAXSTRING];
  35. u32 ports;
  36. };
  37. #define sn_hwp_this_part f.fields.this_part
  38. #define sn_hwp_is_shared f.fields.is_shared
  39. #define sn_hwp_flags f.b.flags
  40. /* macros for object classification */
  41. #define SN_HWPERF_IS_NODE(x) ((x) && strstr((x)->name, "SHub"))
  42. #define SN_HWPERF_IS_NODE_SHUB2(x) ((x) && strstr((x)->name, "SHub 2."))
  43. #define SN_HWPERF_IS_IONODE(x) ((x) && strstr((x)->name, "TIO"))
  44. #define SN_HWPERF_IS_NL3ROUTER(x) ((x) && strstr((x)->name, "NL3Router"))
  45. #define SN_HWPERF_IS_NL4ROUTER(x) ((x) && strstr((x)->name, "NL4Router"))
  46. #define SN_HWPERF_IS_OLDROUTER(x) ((x) && strstr((x)->name, "Router"))
  47. #define SN_HWPERF_IS_ROUTER(x) (SN_HWPERF_IS_NL3ROUTER(x) || \
  48. SN_HWPERF_IS_NL4ROUTER(x) || \
  49. SN_HWPERF_IS_OLDROUTER(x))
  50. #define SN_HWPERF_FOREIGN(x) ((x) && !(x)->sn_hwp_this_part && !(x)->sn_hwp_is_shared)
  51. #define SN_HWPERF_SAME_OBJTYPE(x,y) ((SN_HWPERF_IS_NODE(x) && SN_HWPERF_IS_NODE(y)) ||\
  52. (SN_HWPERF_IS_IONODE(x) && SN_HWPERF_IS_IONODE(y)) ||\
  53. (SN_HWPERF_IS_ROUTER(x) && SN_HWPERF_IS_ROUTER(y)))
  54. /* numa port structure, SN_HWPERF_ENUM_PORTS returns an array of these */
  55. struct sn_hwperf_port_info {
  56. u32 port;
  57. u32 conn_id;
  58. u32 conn_port;
  59. };
  60. /* for HWPERF_{GET,SET}_MMRS */
  61. struct sn_hwperf_data {
  62. u64 addr;
  63. u64 data;
  64. };
  65. /* user ioctl() argument, see below */
  66. struct sn_hwperf_ioctl_args {
  67. u64 arg; /* argument, usually an object id */
  68. u64 sz; /* size of transfer */
  69. void *ptr; /* pointer to source/target */
  70. u32 v0; /* second return value */
  71. };
  72. /*
  73. * For SN_HWPERF_{GET,SET}_MMRS and SN_HWPERF_OBJECT_DISTANCE,
  74. * sn_hwperf_ioctl_args.arg can be used to specify a CPU on which
  75. * to call SAL, and whether to use an interprocessor interrupt
  76. * or task migration in order to do so. If the CPU specified is
  77. * SN_HWPERF_ARG_ANY_CPU, then the current CPU will be used.
  78. */
  79. #define SN_HWPERF_ARG_ANY_CPU 0x7fffffffUL
  80. #define SN_HWPERF_ARG_CPU_MASK 0x7fffffff00000000ULL
  81. #define SN_HWPERF_ARG_USE_IPI_MASK 0x8000000000000000ULL
  82. #define SN_HWPERF_ARG_OBJID_MASK 0x00000000ffffffffULL
  83. /*
  84. * ioctl requests on the "sn_hwperf" misc device that call SAL.
  85. */
  86. #define SN_HWPERF_OP_MEM_COPYIN 0x1000
  87. #define SN_HWPERF_OP_MEM_COPYOUT 0x2000
  88. #define SN_HWPERF_OP_MASK 0x0fff
  89. /*
  90. * Determine mem requirement.
  91. * arg don't care
  92. * sz 8
  93. * p pointer to u64 integer
  94. */
  95. #define SN_HWPERF_GET_HEAPSIZE 1
  96. /*
  97. * Install mem for SAL drvr
  98. * arg don't care
  99. * sz sizeof buffer pointed to by p
  100. * p pointer to buffer for scratch area
  101. */
  102. #define SN_HWPERF_INSTALL_HEAP 2
  103. /*
  104. * Determine number of objects
  105. * arg don't care
  106. * sz 8
  107. * p pointer to u64 integer
  108. */
  109. #define SN_HWPERF_OBJECT_COUNT (10|SN_HWPERF_OP_MEM_COPYOUT)
  110. /*
  111. * Determine object "distance", relative to a cpu. This operation can
  112. * execute on a designated logical cpu number, using either an IPI or
  113. * via task migration. If the cpu number is SN_HWPERF_ANY_CPU, then
  114. * the current CPU is used. See the SN_HWPERF_ARG_* macros above.
  115. *
  116. * arg bitmap of IPI flag, cpu number and object id
  117. * sz 8
  118. * p pointer to u64 integer
  119. */
  120. #define SN_HWPERF_OBJECT_DISTANCE (11|SN_HWPERF_OP_MEM_COPYOUT)
  121. /*
  122. * Enumerate objects. Special case if sz == 8, returns the required
  123. * buffer size.
  124. * arg don't care
  125. * sz sizeof buffer pointed to by p
  126. * p pointer to array of struct sn_hwperf_object_info
  127. */
  128. #define SN_HWPERF_ENUM_OBJECTS (12|SN_HWPERF_OP_MEM_COPYOUT)
  129. /*
  130. * Enumerate NumaLink ports for an object. Special case if sz == 8,
  131. * returns the required buffer size.
  132. * arg object id
  133. * sz sizeof buffer pointed to by p
  134. * p pointer to array of struct sn_hwperf_port_info
  135. */
  136. #define SN_HWPERF_ENUM_PORTS (13|SN_HWPERF_OP_MEM_COPYOUT)
  137. /*
  138. * SET/GET memory mapped registers. These operations can execute
  139. * on a designated logical cpu number, using either an IPI or via
  140. * task migration. If the cpu number is SN_HWPERF_ANY_CPU, then
  141. * the current CPU is used. See the SN_HWPERF_ARG_* macros above.
  142. *
  143. * arg bitmap of ipi flag, cpu number and object id
  144. * sz sizeof buffer pointed to by p
  145. * p pointer to array of struct sn_hwperf_data
  146. */
  147. #define SN_HWPERF_SET_MMRS (14|SN_HWPERF_OP_MEM_COPYIN)
  148. #define SN_HWPERF_GET_MMRS (15|SN_HWPERF_OP_MEM_COPYOUT| \
  149. SN_HWPERF_OP_MEM_COPYIN)
  150. /*
  151. * Lock a shared object
  152. * arg object id
  153. * sz don't care
  154. * p don't care
  155. */
  156. #define SN_HWPERF_ACQUIRE 16
  157. /*
  158. * Unlock a shared object
  159. * arg object id
  160. * sz don't care
  161. * p don't care
  162. */
  163. #define SN_HWPERF_RELEASE 17
  164. /*
  165. * Break a lock on a shared object
  166. * arg object id
  167. * sz don't care
  168. * p don't care
  169. */
  170. #define SN_HWPERF_FORCE_RELEASE 18
  171. /*
  172. * ioctl requests on "sn_hwperf" that do not call SAL
  173. */
  174. /*
  175. * get cpu info as an array of hwperf_object_info_t.
  176. * id is logical CPU number, name is description, location
  177. * is geoid (e.g. 001c04#1c). Special case if sz == 8,
  178. * returns the required buffer size.
  179. *
  180. * arg don't care
  181. * sz sizeof buffer pointed to by p
  182. * p pointer to array of struct sn_hwperf_object_info
  183. */
  184. #define SN_HWPERF_GET_CPU_INFO (100|SN_HWPERF_OP_MEM_COPYOUT)
  185. /*
  186. * Given an object id, return it's node number (aka cnode).
  187. * arg object id
  188. * sz 8
  189. * p pointer to u64 integer
  190. */
  191. #define SN_HWPERF_GET_OBJ_NODE (101|SN_HWPERF_OP_MEM_COPYOUT)
  192. /*
  193. * Given a node number (cnode), return it's nasid.
  194. * arg ordinal node number (aka cnodeid)
  195. * sz 8
  196. * p pointer to u64 integer
  197. */
  198. #define SN_HWPERF_GET_NODE_NASID (102|SN_HWPERF_OP_MEM_COPYOUT)
  199. /*
  200. * Given a node id, determine the id of the nearest node with CPUs
  201. * and the id of the nearest node that has memory. The argument
  202. * node would normally be a "headless" node, e.g. an "IO node".
  203. * Return 0 on success.
  204. */
  205. extern int sn_hwperf_get_nearest_node(cnodeid_t node,
  206. cnodeid_t *near_mem, cnodeid_t *near_cpu);
  207. /* return codes */
  208. #define SN_HWPERF_OP_OK 0
  209. #define SN_HWPERF_OP_NOMEM 1
  210. #define SN_HWPERF_OP_NO_PERM 2
  211. #define SN_HWPERF_OP_IO_ERROR 3
  212. #define SN_HWPERF_OP_BUSY 4
  213. #define SN_HWPERF_OP_RECONFIGURE 253
  214. #define SN_HWPERF_OP_INVAL 254
  215. int sn_topology_open(struct inode *inode, struct file *file);
  216. int sn_topology_release(struct inode *inode, struct file *file);
  217. #endif /* SN_HWPERF_H */