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-2021 Tintri by DDN, Inc. All rights reserved. 25 */ 26 27 #ifndef _SYS_SDT_H 28 #define _SYS_SDT_H 29 30 #include <sys/stdint.h> 31 #include <fksmb_dt.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #ifdef _KERNEL 38 #error "libfksmbsrv/common/sys/sdt.h in kernel?" 39 #endif 40 41 /* 42 * DTrace SDT probes have different signatures in userland than they do in 43 * the kernel. This file is strictly for libfksmbsrv, where we compile the 44 * smbsrv kernel code for user space. In "fksmbd", we can use the probes 45 * defined for the (real, in-kernel) "smb" and "smb2" SDT provider by 46 * mapping them onto the USDT proviver defined in ../fksmb_dt.d 47 * 48 * An example of how to use these probes can be found in: 49 * $SRC/cmd/smbsrv/fksmbd/Watch-fksmb.d 50 */ 51 52 /* 53 * Map "smb" provider probes. 54 */ 55 56 #define DTRACE_SMB_START(name, type1, arg1) \ 57 FKSMB_SMB_START(#name, (unsigned long)arg1) 58 #define DTRACE_SMB_DONE(name, type1, arg1) \ 59 FKSMB_SMB_DONE(#name, (unsigned long)arg1) 60 61 /* 62 * Map "smb2" provider probes. 63 */ 64 65 #define DTRACE_SMB2_START(name, type1, arg1) \ 66 FKSMB_SMB2_START(#name, (unsigned long)arg1) 67 #define DTRACE_SMB2_DONE(name, type1, arg1) \ 68 FKSMB_SMB2_DONE(#name, (unsigned long)arg1) 69 70 /* 71 * These are for the other (specialized) dtrace SDT probes sprinkled 72 * through the smbsrv code. These are less often used. 73 */ 74 75 #define DTRACE_PROBE(name, type1, arg1) \ 76 FKSMB_PROBE0(#name) 77 78 #define DTRACE_PROBE1(name, type1, arg1) \ 79 FKSMB_PROBE1(#name, (unsigned long)arg1) 80 81 #define DTRACE_PROBE2(name, type1, arg1, type2, arg2) \ 82 FKSMB_PROBE2(#name, (unsigned long)arg1, (unsigned long)arg2) 83 84 #define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) \ 85 FKSMB_PROBE3(#name, (unsigned long)arg1, (unsigned long)arg2, \ 86 (unsigned long)arg3) 87 88 /* 89 * We use the comma operator so that this macro can be used without much 90 * additional code. For example, "return (EINVAL);" becomes 91 * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated 92 * twice, so it should not have side effects (e.g. something like: 93 * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice). 94 */ 95 #define SET_ERROR(err) (FKSMB_SET_ERROR(err), err) 96 97 #ifdef __cplusplus 98 } 99 #endif 100 101 #endif /* _SYS_SDT_H */ 102