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
6 * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
8 * Data types used by the SN_SAL_HWPERF_OP SAL call for monitoring
9 * SGI Altix node and router hardware
11 * Mark Goodwin <markgw@sgi.com> Mon Aug 30 12:23:46 EST 2004
18 * object structure. SN_HWPERF_ENUM_OBJECTS and SN_HWPERF_GET_CPU_INFO
19 * return an array of these. Do not change this without also
20 * changing the corresponding SAL code.
22 #define SN_HWPERF_MAXSTRING 128
23 struct sn_hwperf_object_info {
35 char name[SN_HWPERF_MAXSTRING];
36 char location[SN_HWPERF_MAXSTRING];
40 #define sn_hwp_this_part f.fields.this_part
41 #define sn_hwp_is_shared f.fields.is_shared
42 #define sn_hwp_flags f.b.flags
44 /* macros for object classification */
45 #define SN_HWPERF_IS_NODE(x) ((x) && strstr((x)->name, "SHub"))
46 #define SN_HWPERF_IS_NODE_SHUB2(x) ((x) && strstr((x)->name, "SHub 2."))
47 #define SN_HWPERF_IS_IONODE(x) ((x) && strstr((x)->name, "TIO"))
48 #define SN_HWPERF_IS_NL3ROUTER(x) ((x) && strstr((x)->name, "NL3Router"))
49 #define SN_HWPERF_IS_NL4ROUTER(x) ((x) && strstr((x)->name, "NL4Router"))
50 #define SN_HWPERF_IS_OLDROUTER(x) ((x) && strstr((x)->name, "Router"))
51 #define SN_HWPERF_IS_ROUTER(x) (SN_HWPERF_IS_NL3ROUTER(x) || \
52 SN_HWPERF_IS_NL4ROUTER(x) || \
53 SN_HWPERF_IS_OLDROUTER(x))
54 #define SN_HWPERF_FOREIGN(x) ((x) && !(x)->sn_hwp_this_part && !(x)->sn_hwp_is_shared)
55 #define SN_HWPERF_SAME_OBJTYPE(x,y) ((SN_HWPERF_IS_NODE(x) && SN_HWPERF_IS_NODE(y)) ||\
56 (SN_HWPERF_IS_IONODE(x) && SN_HWPERF_IS_IONODE(y)) ||\
57 (SN_HWPERF_IS_ROUTER(x) && SN_HWPERF_IS_ROUTER(y)))
59 /* numa port structure, SN_HWPERF_ENUM_PORTS returns an array of these */
60 struct sn_hwperf_port_info {
66 /* for HWPERF_{GET,SET}_MMRS */
67 struct sn_hwperf_data {
72 /* user ioctl() argument, see below */
73 struct sn_hwperf_ioctl_args {
74 u64 arg; /* argument, usually an object id */
75 u64 sz; /* size of transfer */
76 void *ptr; /* pointer to source/target */
77 u32 v0; /* second return value */
81 * For SN_HWPERF_{GET,SET}_MMRS and SN_HWPERF_OBJECT_DISTANCE,
82 * sn_hwperf_ioctl_args.arg can be used to specify a CPU on which
83 * to call SAL, and whether to use an interprocessor interrupt
84 * or task migration in order to do so. If the CPU specified is
85 * SN_HWPERF_ARG_ANY_CPU, then the current CPU will be used.
87 #define SN_HWPERF_ARG_ANY_CPU 0x7fffffffUL
88 #define SN_HWPERF_ARG_CPU_MASK 0x7fffffff00000000ULL
89 #define SN_HWPERF_ARG_USE_IPI_MASK 0x8000000000000000ULL
90 #define SN_HWPERF_ARG_OBJID_MASK 0x00000000ffffffffULL
93 * ioctl requests on the "sn_hwperf" misc device that call SAL.
95 #define SN_HWPERF_OP_MEM_COPYIN 0x1000
96 #define SN_HWPERF_OP_MEM_COPYOUT 0x2000
97 #define SN_HWPERF_OP_MASK 0x0fff
100 * Determine mem requirement.
103 * p pointer to u64 integer
105 #define SN_HWPERF_GET_HEAPSIZE 1
108 * Install mem for SAL drvr
110 * sz sizeof buffer pointed to by p
111 * p pointer to buffer for scratch area
113 #define SN_HWPERF_INSTALL_HEAP 2
116 * Determine number of objects
119 * p pointer to u64 integer
121 #define SN_HWPERF_OBJECT_COUNT (10|SN_HWPERF_OP_MEM_COPYOUT)
124 * Determine object "distance", relative to a cpu. This operation can
125 * execute on a designated logical cpu number, using either an IPI or
126 * via task migration. If the cpu number is SN_HWPERF_ANY_CPU, then
127 * the current CPU is used. See the SN_HWPERF_ARG_* macros above.
129 * arg bitmap of IPI flag, cpu number and object id
131 * p pointer to u64 integer
133 #define SN_HWPERF_OBJECT_DISTANCE (11|SN_HWPERF_OP_MEM_COPYOUT)
136 * Enumerate objects. Special case if sz == 8, returns the required
139 * sz sizeof buffer pointed to by p
140 * p pointer to array of struct sn_hwperf_object_info
142 #define SN_HWPERF_ENUM_OBJECTS (12|SN_HWPERF_OP_MEM_COPYOUT)
145 * Enumerate NumaLink ports for an object. Special case if sz == 8,
146 * returns the required buffer size.
148 * sz sizeof buffer pointed to by p
149 * p pointer to array of struct sn_hwperf_port_info
151 #define SN_HWPERF_ENUM_PORTS (13|SN_HWPERF_OP_MEM_COPYOUT)
154 * SET/GET memory mapped registers. These operations can execute
155 * on a designated logical cpu number, using either an IPI or via
156 * task migration. If the cpu number is SN_HWPERF_ANY_CPU, then
157 * the current CPU is used. See the SN_HWPERF_ARG_* macros above.
159 * arg bitmap of ipi flag, cpu number and object id
160 * sz sizeof buffer pointed to by p
161 * p pointer to array of struct sn_hwperf_data
163 #define SN_HWPERF_SET_MMRS (14|SN_HWPERF_OP_MEM_COPYIN)
164 #define SN_HWPERF_GET_MMRS (15|SN_HWPERF_OP_MEM_COPYOUT| \
165 SN_HWPERF_OP_MEM_COPYIN)
167 * Lock a shared object
172 #define SN_HWPERF_ACQUIRE 16
175 * Unlock a shared object
180 #define SN_HWPERF_RELEASE 17
183 * Break a lock on a shared object
188 #define SN_HWPERF_FORCE_RELEASE 18
191 * ioctl requests on "sn_hwperf" that do not call SAL
195 * get cpu info as an array of hwperf_object_info_t.
196 * id is logical CPU number, name is description, location
197 * is geoid (e.g. 001c04#1c). Special case if sz == 8,
198 * returns the required buffer size.
201 * sz sizeof buffer pointed to by p
202 * p pointer to array of struct sn_hwperf_object_info
204 #define SN_HWPERF_GET_CPU_INFO (100|SN_HWPERF_OP_MEM_COPYOUT)
207 * Given an object id, return it's node number (aka cnode).
210 * p pointer to u64 integer
212 #define SN_HWPERF_GET_OBJ_NODE (101|SN_HWPERF_OP_MEM_COPYOUT)
215 * Given a node number (cnode), return it's nasid.
216 * arg ordinal node number (aka cnodeid)
218 * p pointer to u64 integer
220 #define SN_HWPERF_GET_NODE_NASID (102|SN_HWPERF_OP_MEM_COPYOUT)
223 * Given a node id, determine the id of the nearest node with CPUs
224 * and the id of the nearest node that has memory. The argument
225 * node would normally be a "headless" node, e.g. an "IO node".
226 * Return 0 on success.
228 extern int sn_hwperf_get_nearest_node(cnodeid_t node,
229 cnodeid_t *near_mem, cnodeid_t *near_cpu);
232 #define SN_HWPERF_OP_OK 0
233 #define SN_HWPERF_OP_NOMEM 1
234 #define SN_HWPERF_OP_NO_PERM 2
235 #define SN_HWPERF_OP_IO_ERROR 3
236 #define SN_HWPERF_OP_BUSY 4
237 #define SN_HWPERF_OP_RECONFIGURE 253
238 #define SN_HWPERF_OP_INVAL 254
240 int sn_topology_open(struct inode *inode, struct file *file);
241 int sn_topology_release(struct inode *inode, struct file *file);
242 #endif /* SN_HWPERF_H */