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