sn_hwperf.h 6.3 KB

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