sn_hwperf.h 6.7 KB

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