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 14 #ifndef SN_HWPERF_H 15 #define SN_HWPERF_H 16 17 /* 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. 21 */ 22 #define SN_HWPERF_MAXSTRING 128 23 struct sn_hwperf_object_info { 24 u32 id; 25 union { 26 struct { 27 u64 this_part:1; 28 u64 is_shared:1; 29 } fields; 30 struct { 31 u64 flags; 32 u64 reserved; 33 } b; 34 } f; 35 char name[SN_HWPERF_MAXSTRING]; 36 char location[SN_HWPERF_MAXSTRING]; 37 u32 ports; 38 }; 39 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 43 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))) 58 59 /* numa port structure, SN_HWPERF_ENUM_PORTS returns an array of these */ 60 struct sn_hwperf_port_info { 61 u32 port; 62 u32 conn_id; 63 u32 conn_port; 64 }; 65 66 /* for HWPERF_{GET,SET}_MMRS */ 67 struct sn_hwperf_data { 68 u64 addr; 69 u64 data; 70 }; 71 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 */ 78 }; 79 80 /* 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. 86 */ 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 91 92 /* 93 * ioctl requests on the "sn_hwperf" misc device that call SAL. 94 */ 95 #define SN_HWPERF_OP_MEM_COPYIN 0x1000 96 #define SN_HWPERF_OP_MEM_COPYOUT 0x2000 97 #define SN_HWPERF_OP_MASK 0x0fff 98 99 /* 100 * Determine mem requirement. 101 * arg don't care 102 * sz 8 103 * p pointer to u64 integer 104 */ 105 #define SN_HWPERF_GET_HEAPSIZE 1 106 107 /* 108 * Install mem for SAL drvr 109 * arg don't care 110 * sz sizeof buffer pointed to by p 111 * p pointer to buffer for scratch area 112 */ 113 #define SN_HWPERF_INSTALL_HEAP 2 114 115 /* 116 * Determine number of objects 117 * arg don't care 118 * sz 8 119 * p pointer to u64 integer 120 */ 121 #define SN_HWPERF_OBJECT_COUNT (10|SN_HWPERF_OP_MEM_COPYOUT) 122 123 /* 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. 128 * 129 * arg bitmap of IPI flag, cpu number and object id 130 * sz 8 131 * p pointer to u64 integer 132 */ 133 #define SN_HWPERF_OBJECT_DISTANCE (11|SN_HWPERF_OP_MEM_COPYOUT) 134 135 /* 136 * Enumerate objects. Special case if sz == 8, returns the required 137 * buffer size. 138 * arg don't care 139 * sz sizeof buffer pointed to by p 140 * p pointer to array of struct sn_hwperf_object_info 141 */ 142 #define SN_HWPERF_ENUM_OBJECTS (12|SN_HWPERF_OP_MEM_COPYOUT) 143 144 /* 145 * Enumerate NumaLink ports for an object. Special case if sz == 8, 146 * returns the required buffer size. 147 * arg object id 148 * sz sizeof buffer pointed to by p 149 * p pointer to array of struct sn_hwperf_port_info 150 */ 151 #define SN_HWPERF_ENUM_PORTS (13|SN_HWPERF_OP_MEM_COPYOUT) 152 153 /* 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. 158 * 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 162 */ 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) 166 /* 167 * Lock a shared object 168 * arg object id 169 * sz don't care 170 * p don't care 171 */ 172 #define SN_HWPERF_ACQUIRE 16 173 174 /* 175 * Unlock a shared object 176 * arg object id 177 * sz don't care 178 * p don't care 179 */ 180 #define SN_HWPERF_RELEASE 17 181 182 /* 183 * Break a lock on a shared object 184 * arg object id 185 * sz don't care 186 * p don't care 187 */ 188 #define SN_HWPERF_FORCE_RELEASE 18 189 190 /* 191 * ioctl requests on "sn_hwperf" that do not call SAL 192 */ 193 194 /* 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. 199 * 200 * arg don't care 201 * sz sizeof buffer pointed to by p 202 * p pointer to array of struct sn_hwperf_object_info 203 */ 204 #define SN_HWPERF_GET_CPU_INFO (100|SN_HWPERF_OP_MEM_COPYOUT) 205 206 /* 207 * Given an object id, return it's node number (aka cnode). 208 * arg object id 209 * sz 8 210 * p pointer to u64 integer 211 */ 212 #define SN_HWPERF_GET_OBJ_NODE (101|SN_HWPERF_OP_MEM_COPYOUT) 213 214 /* 215 * Given a node number (cnode), return it's nasid. 216 * arg ordinal node number (aka cnodeid) 217 * sz 8 218 * p pointer to u64 integer 219 */ 220 #define SN_HWPERF_GET_NODE_NASID (102|SN_HWPERF_OP_MEM_COPYOUT) 221 222 /* 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. 227 */ 228 extern int sn_hwperf_get_nearest_node(cnodeid_t node, 229 cnodeid_t *near_mem, cnodeid_t *near_cpu); 230 231 /* return codes */ 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 239 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 */ 243