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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/sdt_impl.h>
26
27 static dtrace_pattr_t vtrace_attr = {
28 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
29 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
30 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
31 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
32 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
33 };
34
35 static dtrace_pattr_t info_attr = {
36 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
37 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
38 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
39 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
40 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
41 };
42
80 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
81 };
82
83 static dtrace_pattr_t xpv_attr = {
84 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_PLATFORM },
85 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
86 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
87 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
88 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
89 };
90
91 static dtrace_pattr_t iscsi_attr = {
92 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
93 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
94 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
95 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
96 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
97 };
98
99 sdt_provider_t sdt_providers[] = {
100 { "vtrace", "__vtrace_", &vtrace_attr, 0 },
101 { "sysinfo", "__cpu_sysinfo_", &info_attr, 0 },
102 { "vminfo", "__cpu_vminfo_", &info_attr, 0 },
103 { "fpuinfo", "__fpuinfo_", &fpu_attr, 0 },
104 { "sched", "__sched_", &stab_attr, 0 },
105 { "proc", "__proc_", &stab_attr, 0 },
106 { "io", "__io_", &stab_attr, 0 },
107 { "ip", "__ip_", &stab_attr, 0 },
108 { "tcp", "__tcp_", &stab_attr, 0 },
109 { "udp", "__udp_", &stab_attr, 0 },
110 { "mib", "__mib_", &stab_attr, 0 },
111 { "fsinfo", "__fsinfo_", &fsinfo_attr, 0 },
112 { "iscsi", "__iscsi_", &iscsi_attr, 0 },
113 { "nfsv3", "__nfsv3_", &stab_attr, 0 },
114 { "nfsv4", "__nfsv4_", &stab_attr, 0 },
115 { "xpv", "__xpv_", &xpv_attr, 0 },
116 { "fc", "__fc_", &fc_attr, 0 },
117 { "srp", "__srp_", &fc_attr, 0 },
118 { "sysevent", "__sysevent_", &stab_attr, 0 },
119 { "sdt", NULL, &sdt_attr, 0 },
120 { NULL }
121 };
122
123 sdt_argdesc_t sdt_args[] = {
124 { "sched", "wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
125 { "sched", "wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
126 { "sched", "dequeue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
127 { "sched", "dequeue", 1, 0, "kthread_t *", "psinfo_t *" },
128 { "sched", "dequeue", 2, 1, "disp_t *", "cpuinfo_t *" },
129 { "sched", "enqueue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
130 { "sched", "enqueue", 1, 0, "kthread_t *", "psinfo_t *" },
131 { "sched", "enqueue", 2, 1, "disp_t *", "cpuinfo_t *" },
132 { "sched", "enqueue", 3, 2, "int" },
133 { "sched", "off-cpu", 0, 0, "kthread_t *", "lwpsinfo_t *" },
134 { "sched", "off-cpu", 1, 0, "kthread_t *", "psinfo_t *" },
135 { "sched", "tick", 0, 0, "kthread_t *", "lwpsinfo_t *" },
136 { "sched", "tick", 1, 0, "kthread_t *", "psinfo_t *" },
137 { "sched", "change-pri", 0, 0, "kthread_t *", "lwpsinfo_t *" },
138 { "sched", "change-pri", 1, 0, "kthread_t *", "psinfo_t *" },
139 { "sched", "change-pri", 2, 1, "pri_t" },
1138 "scsicmd_t *" },
1139 { "fc", "xfer-done", 3, 3, "fct_i_remote_port_t *",
1140 "fc_port_info_t *" },
1141 { "fc", "xfer-done", 4, 4, "stmf_data_buf_t *",
1142 "fc_xferinfo_t *" },
1143 { "fc", "rscn-receive", 0, 0, "fct_i_local_port_t *",
1144 "conninfo_t *" },
1145 { "fc", "rscn-receive", 1, 1, "int", "int"},
1146 { "fc", "abts-receive", 0, 0, "fct_cmd_t *",
1147 "conninfo_t *" },
1148 { "fc", "abts-receive", 1, 1, "fct_i_local_port_t *",
1149 "fc_port_info_t *" },
1150 { "fc", "abts-receive", 2, 2, "fct_i_remote_port_t *",
1151 "fc_port_info_t *" },
1152
1153
1154 { NULL }
1155 };
1156
1157 /*ARGSUSED*/
1158 void
1159 sdt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
1160 {
1161 sdt_probe_t *sdp = parg;
1162 int i;
1163
1164 desc->dtargd_native[0] = '\0';
1165 desc->dtargd_xlate[0] = '\0';
1166
1167 for (i = 0; sdt_args[i].sda_provider != NULL; i++) {
1168 sdt_argdesc_t *a = &sdt_args[i];
1169
1170 if (strcmp(sdp->sdp_provider->sdtp_name, a->sda_provider) != 0)
1171 continue;
1172
1173 if (a->sda_name != NULL &&
1174 strcmp(sdp->sdp_name, a->sda_name) != 0)
1175 continue;
1176
1177 if (desc->dtargd_ndx != a->sda_ndx)
|
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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
24 */
25
26 #include <sys/sdt_impl.h>
27
28 static dtrace_pattr_t vtrace_attr = {
29 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
30 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
31 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
32 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
33 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
34 };
35
36 static dtrace_pattr_t info_attr = {
37 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
38 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
39 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
40 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
41 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
42 };
43
81 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
82 };
83
84 static dtrace_pattr_t xpv_attr = {
85 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_PLATFORM },
86 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
87 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
88 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
89 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
90 };
91
92 static dtrace_pattr_t iscsi_attr = {
93 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
94 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
95 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
96 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
97 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
98 };
99
100 sdt_provider_t sdt_providers[] = {
101 { "vtrace", "__vtrace_", &vtrace_attr },
102 { "sysinfo", "__cpu_sysinfo_", &info_attr, DTRACE_PRIV_USER },
103 { "vminfo", "__cpu_vminfo_", &info_attr, DTRACE_PRIV_USER },
104 { "fpuinfo", "__fpuinfo_", &fpu_attr },
105 { "sched", "__sched_", &stab_attr, DTRACE_PRIV_USER },
106 { "proc", "__proc_", &stab_attr, DTRACE_PRIV_USER },
107 { "io", "__io_", &stab_attr },
108 { "ip", "__ip_", &stab_attr },
109 { "tcp", "__tcp_", &stab_attr },
110 { "udp", "__udp_", &stab_attr },
111 { "mib", "__mib_", &stab_attr },
112 { "fsinfo", "__fsinfo_", &fsinfo_attr },
113 { "iscsi", "__iscsi_", &iscsi_attr },
114 { "nfsv3", "__nfsv3_", &stab_attr },
115 { "nfsv4", "__nfsv4_", &stab_attr },
116 { "xpv", "__xpv_", &xpv_attr },
117 { "fc", "__fc_", &fc_attr },
118 { "srp", "__srp_", &fc_attr },
119 { "sysevent", "__sysevent_", &stab_attr },
120 { "sdt", NULL, &sdt_attr },
121 { NULL }
122 };
123
124 sdt_argdesc_t sdt_args[] = {
125 { "sched", "wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
126 { "sched", "wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
127 { "sched", "dequeue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
128 { "sched", "dequeue", 1, 0, "kthread_t *", "psinfo_t *" },
129 { "sched", "dequeue", 2, 1, "disp_t *", "cpuinfo_t *" },
130 { "sched", "enqueue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
131 { "sched", "enqueue", 1, 0, "kthread_t *", "psinfo_t *" },
132 { "sched", "enqueue", 2, 1, "disp_t *", "cpuinfo_t *" },
133 { "sched", "enqueue", 3, 2, "int" },
134 { "sched", "off-cpu", 0, 0, "kthread_t *", "lwpsinfo_t *" },
135 { "sched", "off-cpu", 1, 0, "kthread_t *", "psinfo_t *" },
136 { "sched", "tick", 0, 0, "kthread_t *", "lwpsinfo_t *" },
137 { "sched", "tick", 1, 0, "kthread_t *", "psinfo_t *" },
138 { "sched", "change-pri", 0, 0, "kthread_t *", "lwpsinfo_t *" },
139 { "sched", "change-pri", 1, 0, "kthread_t *", "psinfo_t *" },
140 { "sched", "change-pri", 2, 1, "pri_t" },
1139 "scsicmd_t *" },
1140 { "fc", "xfer-done", 3, 3, "fct_i_remote_port_t *",
1141 "fc_port_info_t *" },
1142 { "fc", "xfer-done", 4, 4, "stmf_data_buf_t *",
1143 "fc_xferinfo_t *" },
1144 { "fc", "rscn-receive", 0, 0, "fct_i_local_port_t *",
1145 "conninfo_t *" },
1146 { "fc", "rscn-receive", 1, 1, "int", "int"},
1147 { "fc", "abts-receive", 0, 0, "fct_cmd_t *",
1148 "conninfo_t *" },
1149 { "fc", "abts-receive", 1, 1, "fct_i_local_port_t *",
1150 "fc_port_info_t *" },
1151 { "fc", "abts-receive", 2, 2, "fct_i_remote_port_t *",
1152 "fc_port_info_t *" },
1153
1154
1155 { NULL }
1156 };
1157
1158 /*ARGSUSED*/
1159 int
1160 sdt_mode(void *arg, dtrace_id_t id, void *parg)
1161 {
1162 /*
1163 * We tell DTrace that we're in kernel mode, that the firing needs to
1164 * be dropped for anything that doesn't have necessary privileges, and
1165 * that it needs to be restricted for anything that has restricted
1166 * (i.e., not all-zone) privileges.
1167 */
1168 return (DTRACE_MODE_KERNEL | DTRACE_MODE_NOPRIV_DROP |
1169 DTRACE_MODE_LIMITEDPRIV_RESTRICT);
1170 }
1171
1172 /*ARGSUSED*/
1173 void
1174 sdt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
1175 {
1176 sdt_probe_t *sdp = parg;
1177 int i;
1178
1179 desc->dtargd_native[0] = '\0';
1180 desc->dtargd_xlate[0] = '\0';
1181
1182 for (i = 0; sdt_args[i].sda_provider != NULL; i++) {
1183 sdt_argdesc_t *a = &sdt_args[i];
1184
1185 if (strcmp(sdp->sdp_provider->sdtp_name, a->sda_provider) != 0)
1186 continue;
1187
1188 if (a->sda_name != NULL &&
1189 strcmp(sdp->sdp_name, a->sda_name) != 0)
1190 continue;
1191
1192 if (desc->dtargd_ndx != a->sda_ndx)
|