1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright (c) 2013 by Delphix. All rights reserved. 24 * Copyright 2017 Nexenta Systems, Inc. All rights reserved. 25 */ 26 27 #ifndef _SYS_SDT_H 28 #define _SYS_SDT_H 29 30 #include <sys/stdint.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #ifndef _KERNEL 37 38 #define DTRACE_PROBE(provider, name) { \ 39 extern void __dtrace_##provider##___##name(void); \ 40 __dtrace_##provider##___##name(); \ 41 } 42 43 #define DTRACE_PROBE1(provider, name, arg1) { \ 44 extern void __dtrace_##provider##___##name(unsigned long); \ 45 __dtrace_##provider##___##name((unsigned long)arg1); \ 46 } 47 48 #define DTRACE_PROBE2(provider, name, arg1, arg2) { \ 49 extern void __dtrace_##provider##___##name(unsigned long, \ 50 unsigned long); \ 51 __dtrace_##provider##___##name((unsigned long)arg1, \ 52 (unsigned long)arg2); \ 53 } 54 55 #define DTRACE_PROBE3(provider, name, arg1, arg2, arg3) { \ 56 extern void __dtrace_##provider##___##name(unsigned long, \ 57 unsigned long, unsigned long); \ 58 __dtrace_##provider##___##name((unsigned long)arg1, \ 59 (unsigned long)arg2, (unsigned long)arg3); \ 60 } 61 62 #define DTRACE_PROBE4(provider, name, arg1, arg2, arg3, arg4) { \ 63 extern void __dtrace_##provider##___##name(unsigned long, \ 64 unsigned long, unsigned long, unsigned long); \ 65 __dtrace_##provider##___##name((unsigned long)arg1, \ 66 (unsigned long)arg2, (unsigned long)arg3, \ 67 (unsigned long)arg4); \ 68 } 69 70 #define DTRACE_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) { \ 71 extern void __dtrace_##provider##___##name(unsigned long, \ 72 unsigned long, unsigned long, unsigned long, unsigned long);\ 73 __dtrace_##provider##___##name((unsigned long)arg1, \ 74 (unsigned long)arg2, (unsigned long)arg3, \ 75 (unsigned long)arg4, (unsigned long)arg5); \ 76 } 77 78 #else /* _KERNEL */ 79 80 #define DTRACE_PROBE(name) { \ 81 extern void __dtrace_probe_##name(void); \ 82 __dtrace_probe_##name(); \ 83 } 84 85 #define DTRACE_PROBE1(name, type1, arg1) { \ 86 extern void __dtrace_probe_##name(uintptr_t); \ 87 __dtrace_probe_##name((uintptr_t)(arg1)); \ 88 } 89 90 #define DTRACE_PROBE2(name, type1, arg1, type2, arg2) { \ 91 extern void __dtrace_probe_##name(uintptr_t, uintptr_t); \ 92 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2)); \ 93 } 94 95 #define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) { \ 96 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, uintptr_t); \ 97 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 98 (uintptr_t)(arg3)); \ 99 } 100 101 #define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \ 102 type3, arg3, type4, arg4) { \ 103 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 104 uintptr_t, uintptr_t); \ 105 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 106 (uintptr_t)(arg3), (uintptr_t)(arg4)); \ 107 } 108 109 #define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \ 110 type3, arg3, type4, arg4, type5, arg5) { \ 111 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 112 uintptr_t, uintptr_t, uintptr_t); \ 113 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 114 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5)); \ 115 } 116 117 #define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \ 118 type3, arg3, type4, arg4, type5, arg5, type6, arg6) { \ 119 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 120 uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ 121 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 122 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ 123 (uintptr_t)(arg6)); \ 124 } 125 126 #define DTRACE_PROBE7(name, type1, arg1, type2, arg2, type3, arg3, \ 127 type4, arg4, type5, arg5, type6, arg6, type7, arg7) { \ 128 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 129 uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); \ 130 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 131 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ 132 (uintptr_t)(arg6), (uintptr_t)(arg7)); \ 133 } 134 135 #define DTRACE_PROBE8(name, type1, arg1, type2, arg2, type3, arg3, \ 136 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) { \ 137 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \ 138 uintptr_t, uintptr_t, uintptr_t, uintptr_t, \ 139 uintptr_t, uintptr_t); \ 140 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \ 141 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \ 142 (uintptr_t)(arg6), (uintptr_t)(arg7), (uintptr_t)(arg8)); \ 143 } 144 145 #define DTRACE_SCHED(name) \ 146 DTRACE_PROBE(__sched_##name); 147 148 #define DTRACE_SCHED1(name, type1, arg1) \ 149 DTRACE_PROBE1(__sched_##name, type1, arg1); 150 151 #define DTRACE_SCHED2(name, type1, arg1, type2, arg2) \ 152 DTRACE_PROBE2(__sched_##name, type1, arg1, type2, arg2); 153 154 #define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \ 155 DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3); 156 157 #define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \ 158 type3, arg3, type4, arg4) \ 159 DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \ 160 type3, arg3, type4, arg4); 161 162 #define DTRACE_PROC(name) \ 163 DTRACE_PROBE(__proc_##name); 164 165 #define DTRACE_PROC1(name, type1, arg1) \ 166 DTRACE_PROBE1(__proc_##name, type1, arg1); 167 168 #define DTRACE_PROC2(name, type1, arg1, type2, arg2) \ 169 DTRACE_PROBE2(__proc_##name, type1, arg1, type2, arg2); 170 171 #define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \ 172 DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3); 173 174 #define DTRACE_PROC4(name, type1, arg1, type2, arg2, \ 175 type3, arg3, type4, arg4) \ 176 DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \ 177 type3, arg3, type4, arg4); 178 179 #define DTRACE_IO(name) \ 180 DTRACE_PROBE(__io_##name); 181 182 #define DTRACE_IO1(name, type1, arg1) \ 183 DTRACE_PROBE1(__io_##name, type1, arg1); 184 185 #define DTRACE_IO2(name, type1, arg1, type2, arg2) \ 186 DTRACE_PROBE2(__io_##name, type1, arg1, type2, arg2); 187 188 #define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \ 189 DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3); 190 191 #define DTRACE_IO4(name, type1, arg1, type2, arg2, \ 192 type3, arg3, type4, arg4) \ 193 DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \ 194 type3, arg3, type4, arg4); 195 196 #define DTRACE_ISCSI_2(name, type1, arg1, type2, arg2) \ 197 DTRACE_PROBE2(__iscsi_##name, type1, arg1, type2, arg2); 198 199 #define DTRACE_ISCSI_3(name, type1, arg1, type2, arg2, type3, arg3) \ 200 DTRACE_PROBE3(__iscsi_##name, type1, arg1, type2, arg2, type3, arg3); 201 202 #define DTRACE_ISCSI_4(name, type1, arg1, type2, arg2, \ 203 type3, arg3, type4, arg4) \ 204 DTRACE_PROBE4(__iscsi_##name, type1, arg1, type2, arg2, \ 205 type3, arg3, type4, arg4); 206 207 #define DTRACE_ISCSI_5(name, type1, arg1, type2, arg2, \ 208 type3, arg3, type4, arg4, type5, arg5) \ 209 DTRACE_PROBE5(__iscsi_##name, type1, arg1, type2, arg2, \ 210 type3, arg3, type4, arg4, type5, arg5); 211 212 #define DTRACE_ISCSI_6(name, type1, arg1, type2, arg2, \ 213 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 214 DTRACE_PROBE6(__iscsi_##name, type1, arg1, type2, arg2, \ 215 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 216 217 #define DTRACE_ISCSI_7(name, type1, arg1, type2, arg2, \ 218 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 219 DTRACE_PROBE7(__iscsi_##name, type1, arg1, type2, arg2, \ 220 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 221 type7, arg7); 222 223 #define DTRACE_ISCSI_8(name, type1, arg1, type2, arg2, \ 224 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 225 type7, arg7, type8, arg8) \ 226 DTRACE_PROBE8(__iscsi_##name, type1, arg1, type2, arg2, \ 227 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 228 type7, arg7, type8, arg8); 229 230 #define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \ 231 type3, arg3) \ 232 DTRACE_PROBE3(__nfsv3_##name, type1, arg1, type2, arg2, \ 233 type3, arg3); 234 #define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \ 235 type3, arg3, type4, arg4) \ 236 DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \ 237 type3, arg3, type4, arg4); 238 239 #define DTRACE_NFSV4_1(name, type1, arg1) \ 240 DTRACE_PROBE1(__nfsv4_##name, type1, arg1); 241 242 #define DTRACE_NFSV4_2(name, type1, arg1, type2, arg2) \ 243 DTRACE_PROBE2(__nfsv4_##name, type1, arg1, type2, arg2); 244 245 #define DTRACE_NFSV4_3(name, type1, arg1, type2, arg2, type3, arg3) \ 246 DTRACE_PROBE3(__nfsv4_##name, type1, arg1, type2, arg2, type3, arg3); 247 248 /* 249 * The SMB probes are done a little differently from the other probes 250 * in this file for the benefit of the libfksmbsrv USDT provider. 251 * See: lib/smbsrv/libfksmbsrv/common/sys/sdt.h 252 */ 253 #define DTRACE_SMB_START(name, type1, arg1) \ 254 DTRACE_PROBE1(__smb_##name##__start, type1, arg1); 255 #define DTRACE_SMB_DONE(name, type1, arg1) \ 256 DTRACE_PROBE1(__smb_##name##__done, type1, arg1); 257 258 #define DTRACE_SMB2_START(name, type1, arg1) \ 259 DTRACE_PROBE1(__smb2_##name##__start, type1, arg1); 260 #define DTRACE_SMB2_DONE(name, type1, arg1) \ 261 DTRACE_PROBE1(__smb2_##name##__done, type1, arg1); 262 263 #define DTRACE_IP(name) \ 264 DTRACE_PROBE(__ip_##name); 265 266 #define DTRACE_IP1(name, type1, arg1) \ 267 DTRACE_PROBE1(__ip_##name, type1, arg1); 268 269 #define DTRACE_IP2(name, type1, arg1, type2, arg2) \ 270 DTRACE_PROBE2(__ip_##name, type1, arg1, type2, arg2); 271 272 #define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \ 273 DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3); 274 275 #define DTRACE_IP4(name, type1, arg1, type2, arg2, \ 276 type3, arg3, type4, arg4) \ 277 DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \ 278 type3, arg3, type4, arg4); 279 280 #define DTRACE_IP5(name, type1, arg1, type2, arg2, \ 281 type3, arg3, type4, arg4, type5, arg5) \ 282 DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \ 283 type3, arg3, type4, arg4, type5, arg5); 284 285 #define DTRACE_IP6(name, type1, arg1, type2, arg2, \ 286 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 287 DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \ 288 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 289 290 #define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \ 291 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 292 DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \ 293 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 294 type7, arg7); 295 296 #define DTRACE_TCP(name) \ 297 DTRACE_PROBE(__tcp_##name); 298 299 #define DTRACE_TCP1(name, type1, arg1) \ 300 DTRACE_PROBE1(__tcp_##name, type1, arg1); 301 302 #define DTRACE_TCP2(name, type1, arg1, type2, arg2) \ 303 DTRACE_PROBE2(__tcp_##name, type1, arg1, type2, arg2); 304 305 #define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \ 306 DTRACE_PROBE3(__tcp_##name, type1, arg1, type2, arg2, type3, arg3); 307 308 #define DTRACE_TCP4(name, type1, arg1, type2, arg2, \ 309 type3, arg3, type4, arg4) \ 310 DTRACE_PROBE4(__tcp_##name, type1, arg1, type2, arg2, \ 311 type3, arg3, type4, arg4); 312 313 #define DTRACE_TCP5(name, type1, arg1, type2, arg2, \ 314 type3, arg3, type4, arg4, type5, arg5) \ 315 DTRACE_PROBE5(__tcp_##name, type1, arg1, type2, arg2, \ 316 type3, arg3, type4, arg4, type5, arg5); 317 318 #define DTRACE_TCP6(name, type1, arg1, type2, arg2, \ 319 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 320 DTRACE_PROBE6(__tcp_##name, type1, arg1, type2, arg2, \ 321 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 322 323 #define DTRACE_UDP(name) \ 324 DTRACE_PROBE(__udp_##name); 325 326 #define DTRACE_UDP1(name, type1, arg1) \ 327 DTRACE_PROBE1(__udp_##name, type1, arg1); 328 329 #define DTRACE_UDP2(name, type1, arg1, type2, arg2) \ 330 DTRACE_PROBE2(__udp_##name, type1, arg1, type2, arg2); 331 332 #define DTRACE_UDP3(name, type1, arg1, type2, arg2, type3, arg3) \ 333 DTRACE_PROBE3(__udp_##name, type1, arg1, type2, arg2, type3, arg3); 334 335 #define DTRACE_UDP4(name, type1, arg1, type2, arg2, \ 336 type3, arg3, type4, arg4) \ 337 DTRACE_PROBE4(__udp_##name, type1, arg1, type2, arg2, \ 338 type3, arg3, type4, arg4); 339 340 #define DTRACE_UDP5(name, type1, arg1, type2, arg2, \ 341 type3, arg3, type4, arg4, type5, arg5) \ 342 DTRACE_PROBE5(__udp_##name, type1, arg1, type2, arg2, \ 343 type3, arg3, type4, arg4, type5, arg5); 344 345 346 #define DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2) \ 347 DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2); 348 349 #define DTRACE_XPV(name) \ 350 DTRACE_PROBE(__xpv_##name); 351 352 #define DTRACE_XPV1(name, type1, arg1) \ 353 DTRACE_PROBE1(__xpv_##name, type1, arg1); 354 355 #define DTRACE_XPV2(name, type1, arg1, type2, arg2) \ 356 DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2); 357 358 #define DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3) \ 359 DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3); 360 361 #define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \ 362 type4, arg4) \ 363 DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \ 364 type3, arg3, type4, arg4); 365 366 #define DTRACE_FC_1(name, type1, arg1) \ 367 DTRACE_PROBE1(__fc_##name, type1, arg1); 368 369 #define DTRACE_FC_2(name, type1, arg1, type2, arg2) \ 370 DTRACE_PROBE2(__fc_##name, type1, arg1, type2, arg2); 371 372 #define DTRACE_FC_3(name, type1, arg1, type2, arg2, type3, arg3) \ 373 DTRACE_PROBE3(__fc_##name, type1, arg1, type2, arg2, type3, arg3); 374 375 #define DTRACE_FC_4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ 376 DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ 377 type4, arg4); 378 379 #define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \ 380 type4, arg4, type5, arg5) \ 381 DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ 382 type4, arg4, type5, arg5); 383 384 #define DTRACE_SRP_1(name, type1, arg1) \ 385 DTRACE_PROBE1(__srp_##name, type1, arg1); 386 387 #define DTRACE_SRP_2(name, type1, arg1, type2, arg2) \ 388 DTRACE_PROBE2(__srp_##name, type1, arg1, type2, arg2); 389 390 #define DTRACE_SRP_3(name, type1, arg1, type2, arg2, type3, arg3) \ 391 DTRACE_PROBE3(__srp_##name, type1, arg1, type2, arg2, type3, arg3); 392 393 #define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \ 394 type4, arg4) \ 395 DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \ 396 type3, arg3, type4, arg4); 397 398 #define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \ 399 type4, arg4, type5, arg5) \ 400 DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \ 401 type3, arg3, type4, arg4, type5, arg5); 402 403 #define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \ 404 type4, arg4, type5, arg5, type6, arg6) \ 405 DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \ 406 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 407 408 #define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \ 409 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 410 DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \ 411 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7); 412 413 #define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \ 414 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \ 415 DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \ 416 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 417 type7, arg7, type8, arg8); 418 419 /* 420 * The set-error SDT probe is extra static, in that we declare its fake 421 * function literally, rather than with the DTRACE_PROBE1() macro. This is 422 * necessary so that SET_ERROR() can evaluate to a value, which wouldn't 423 * be possible if it required multiple statements (to declare the function 424 * and then call it). 425 * 426 * SET_ERROR() uses the comma operator so that it can be used without much 427 * additional code. For example, "return (EINVAL);" becomes 428 * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated 429 * twice, so it should not have side effects (e.g. something like: 430 * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). 431 */ 432 extern void __dtrace_probe_set__error(uintptr_t); 433 #define SET_ERROR(err) (__dtrace_probe_set__error(err), err) 434 435 #endif /* _KERNEL */ 436 437 extern const char *sdt_prefix; 438 439 typedef struct sdt_probedesc { 440 char *sdpd_name; /* name of this probe */ 441 unsigned long sdpd_offset; /* offset of call in text */ 442 struct sdt_probedesc *sdpd_next; /* next static probe */ 443 } sdt_probedesc_t; 444 445 #ifdef __cplusplus 446 } 447 #endif 448 449 #endif /* _SYS_SDT_H */ 450