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 2018 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 235 #define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \ 236 type3, arg3, type4, arg4) \ 237 DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \ 238 type3, arg3, type4, arg4); 239 240 #define DTRACE_NFSV3_5(name, type1, arg1, type2, arg2, \ 241 type3, arg3, type4, arg4, type5, arg5) \ 242 DTRACE_PROBE5(__nfsv3_##name, type1, arg1, type2, arg2, \ 243 type3, arg3, type4, arg4, type5, arg5); 244 245 #define DTRACE_NFSV4_1(name, type1, arg1) \ 246 DTRACE_PROBE1(__nfsv4_##name, type1, arg1); 247 248 #define DTRACE_NFSV4_2(name, type1, arg1, type2, arg2) \ 249 DTRACE_PROBE2(__nfsv4_##name, type1, arg1, type2, arg2); 250 251 #define DTRACE_NFSV4_3(name, type1, arg1, type2, arg2, type3, arg3) \ 252 DTRACE_PROBE3(__nfsv4_##name, type1, arg1, type2, arg2, type3, arg3); 253 254 /* 255 * The SMB probes are done a little differently from the other probes 256 * in this file for the benefit of the libfksmbsrv USDT provider. 257 * See: lib/smbsrv/libfksmbsrv/common/sys/sdt.h 258 */ 259 #define DTRACE_SMB_START(name, type1, arg1) \ 260 DTRACE_PROBE1(__smb_##name##__start, type1, arg1); 261 #define DTRACE_SMB_DONE(name, type1, arg1) \ 262 DTRACE_PROBE1(__smb_##name##__done, type1, arg1); 263 264 #define DTRACE_SMB2_START(name, type1, arg1) \ 265 DTRACE_PROBE1(__smb2_##name##__start, type1, arg1); 266 #define DTRACE_SMB2_DONE(name, type1, arg1) \ 267 DTRACE_PROBE1(__smb2_##name##__done, type1, arg1); 268 269 #define DTRACE_IP(name) \ 270 DTRACE_PROBE(__ip_##name); 271 272 #define DTRACE_IP1(name, type1, arg1) \ 273 DTRACE_PROBE1(__ip_##name, type1, arg1); 274 275 #define DTRACE_IP2(name, type1, arg1, type2, arg2) \ 276 DTRACE_PROBE2(__ip_##name, type1, arg1, type2, arg2); 277 278 #define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \ 279 DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3); 280 281 #define DTRACE_IP4(name, type1, arg1, type2, arg2, \ 282 type3, arg3, type4, arg4) \ 283 DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \ 284 type3, arg3, type4, arg4); 285 286 #define DTRACE_IP5(name, type1, arg1, type2, arg2, \ 287 type3, arg3, type4, arg4, type5, arg5) \ 288 DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \ 289 type3, arg3, type4, arg4, type5, arg5); 290 291 #define DTRACE_IP6(name, type1, arg1, type2, arg2, \ 292 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 293 DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \ 294 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 295 296 #define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \ 297 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 298 DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \ 299 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 300 type7, arg7); 301 302 #define DTRACE_TCP(name) \ 303 DTRACE_PROBE(__tcp_##name); 304 305 #define DTRACE_TCP1(name, type1, arg1) \ 306 DTRACE_PROBE1(__tcp_##name, type1, arg1); 307 308 #define DTRACE_TCP2(name, type1, arg1, type2, arg2) \ 309 DTRACE_PROBE2(__tcp_##name, type1, arg1, type2, arg2); 310 311 #define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \ 312 DTRACE_PROBE3(__tcp_##name, type1, arg1, type2, arg2, type3, arg3); 313 314 #define DTRACE_TCP4(name, type1, arg1, type2, arg2, \ 315 type3, arg3, type4, arg4) \ 316 DTRACE_PROBE4(__tcp_##name, type1, arg1, type2, arg2, \ 317 type3, arg3, type4, arg4); 318 319 #define DTRACE_TCP5(name, type1, arg1, type2, arg2, \ 320 type3, arg3, type4, arg4, type5, arg5) \ 321 DTRACE_PROBE5(__tcp_##name, type1, arg1, type2, arg2, \ 322 type3, arg3, type4, arg4, type5, arg5); 323 324 #define DTRACE_TCP6(name, type1, arg1, type2, arg2, \ 325 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \ 326 DTRACE_PROBE6(__tcp_##name, type1, arg1, type2, arg2, \ 327 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 328 329 #define DTRACE_UDP(name) \ 330 DTRACE_PROBE(__udp_##name); 331 332 #define DTRACE_UDP1(name, type1, arg1) \ 333 DTRACE_PROBE1(__udp_##name, type1, arg1); 334 335 #define DTRACE_UDP2(name, type1, arg1, type2, arg2) \ 336 DTRACE_PROBE2(__udp_##name, type1, arg1, type2, arg2); 337 338 #define DTRACE_UDP3(name, type1, arg1, type2, arg2, type3, arg3) \ 339 DTRACE_PROBE3(__udp_##name, type1, arg1, type2, arg2, type3, arg3); 340 341 #define DTRACE_UDP4(name, type1, arg1, type2, arg2, \ 342 type3, arg3, type4, arg4) \ 343 DTRACE_PROBE4(__udp_##name, type1, arg1, type2, arg2, \ 344 type3, arg3, type4, arg4); 345 346 #define DTRACE_UDP5(name, type1, arg1, type2, arg2, \ 347 type3, arg3, type4, arg4, type5, arg5) \ 348 DTRACE_PROBE5(__udp_##name, type1, arg1, type2, arg2, \ 349 type3, arg3, type4, arg4, type5, arg5); 350 351 352 #define DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2) \ 353 DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2); 354 355 #define DTRACE_XPV(name) \ 356 DTRACE_PROBE(__xpv_##name); 357 358 #define DTRACE_XPV1(name, type1, arg1) \ 359 DTRACE_PROBE1(__xpv_##name, type1, arg1); 360 361 #define DTRACE_XPV2(name, type1, arg1, type2, arg2) \ 362 DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2); 363 364 #define DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3) \ 365 DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3); 366 367 #define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \ 368 type4, arg4) \ 369 DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \ 370 type3, arg3, type4, arg4); 371 372 #define DTRACE_FC_1(name, type1, arg1) \ 373 DTRACE_PROBE1(__fc_##name, type1, arg1); 374 375 #define DTRACE_FC_2(name, type1, arg1, type2, arg2) \ 376 DTRACE_PROBE2(__fc_##name, type1, arg1, type2, arg2); 377 378 #define DTRACE_FC_3(name, type1, arg1, type2, arg2, type3, arg3) \ 379 DTRACE_PROBE3(__fc_##name, type1, arg1, type2, arg2, type3, arg3); 380 381 #define DTRACE_FC_4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ 382 DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ 383 type4, arg4); 384 385 #define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \ 386 type4, arg4, type5, arg5) \ 387 DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \ 388 type4, arg4, type5, arg5); 389 390 #define DTRACE_SRP_1(name, type1, arg1) \ 391 DTRACE_PROBE1(__srp_##name, type1, arg1); 392 393 #define DTRACE_SRP_2(name, type1, arg1, type2, arg2) \ 394 DTRACE_PROBE2(__srp_##name, type1, arg1, type2, arg2); 395 396 #define DTRACE_SRP_3(name, type1, arg1, type2, arg2, type3, arg3) \ 397 DTRACE_PROBE3(__srp_##name, type1, arg1, type2, arg2, type3, arg3); 398 399 #define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \ 400 type4, arg4) \ 401 DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \ 402 type3, arg3, type4, arg4); 403 404 #define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \ 405 type4, arg4, type5, arg5) \ 406 DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \ 407 type3, arg3, type4, arg4, type5, arg5); 408 409 #define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \ 410 type4, arg4, type5, arg5, type6, arg6) \ 411 DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \ 412 type3, arg3, type4, arg4, type5, arg5, type6, arg6); 413 414 #define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \ 415 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \ 416 DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \ 417 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7); 418 419 #define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \ 420 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \ 421 DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \ 422 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \ 423 type7, arg7, type8, arg8); 424 425 /* 426 * The set-error SDT probe is extra static, in that we declare its fake 427 * function literally, rather than with the DTRACE_PROBE1() macro. This is 428 * necessary so that SET_ERROR() can evaluate to a value, which wouldn't 429 * be possible if it required multiple statements (to declare the function 430 * and then call it). 431 * 432 * SET_ERROR() uses the comma operator so that it can be used without much 433 * additional code. For example, "return (EINVAL);" becomes 434 * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated 435 * twice, so it should not have side effects (e.g. something like: 436 * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). 437 */ 438 extern void __dtrace_probe_set__error(uintptr_t); 439 #define SET_ERROR(err) (__dtrace_probe_set__error(err), err) 440 441 #endif /* _KERNEL */ 442 443 extern const char *sdt_prefix; 444 445 typedef struct sdt_probedesc { 446 char *sdpd_name; /* name of this probe */ 447 unsigned long sdpd_offset; /* offset of call in text */ 448 struct sdt_probedesc *sdpd_next; /* next static probe */ 449 } sdt_probedesc_t; 450 451 #ifdef __cplusplus 452 } 453 #endif 454 455 #endif /* _SYS_SDT_H */ 456