4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "spdk/util.h"
36 #include "spdk/trace.h"
37 #include "spdk_internal/log.h"
39 struct rpc_tpoint_group
{
44 free_rpc_tpoint_group(struct rpc_tpoint_group
*p
)
49 static const struct spdk_json_object_decoder rpc_tpoint_group_decoders
[] = {
50 {"name", offsetof(struct rpc_tpoint_group
, name
), spdk_json_decode_string
},
54 rpc_trace_enable_tpoint_group(struct spdk_jsonrpc_request
*request
,
55 const struct spdk_json_val
*params
)
57 struct rpc_tpoint_group req
= {};
58 struct spdk_json_write_ctx
*w
;
60 if (spdk_json_decode_object(params
, rpc_tpoint_group_decoders
,
61 SPDK_COUNTOF(rpc_tpoint_group_decoders
), &req
)) {
62 SPDK_DEBUGLOG(SPDK_LOG_TRACE
, "spdk_json_decode_object failed\n");
66 if (req
.name
== NULL
) {
67 SPDK_DEBUGLOG(SPDK_LOG_TRACE
, "flag was NULL\n");
71 if (spdk_trace_enable_tpoint_group(req
.name
)) {
75 free_rpc_tpoint_group(&req
);
77 w
= spdk_jsonrpc_begin_result(request
);
78 spdk_json_write_bool(w
, true);
79 spdk_jsonrpc_end_result(request
, w
);
83 spdk_jsonrpc_send_error_response(request
, SPDK_JSONRPC_ERROR_INVALID_PARAMS
, "Invalid parameters");
84 free_rpc_tpoint_group(&req
);
86 SPDK_RPC_REGISTER("trace_enable_tpoint_group", rpc_trace_enable_tpoint_group
,
87 SPDK_RPC_STARTUP
| SPDK_RPC_RUNTIME
)
88 SPDK_RPC_REGISTER_ALIAS_DEPRECATED(trace_enable_tpoint_group
, enable_tpoint_group
)
91 rpc_trace_disable_tpoint_group(struct spdk_jsonrpc_request
*request
,
92 const struct spdk_json_val
*params
)
94 struct rpc_tpoint_group req
= {};
95 struct spdk_json_write_ctx
*w
;
97 if (spdk_json_decode_object(params
, rpc_tpoint_group_decoders
,
98 SPDK_COUNTOF(rpc_tpoint_group_decoders
), &req
)) {
99 SPDK_DEBUGLOG(SPDK_LOG_TRACE
, "spdk_json_decode_object failed\n");
103 if (req
.name
== NULL
) {
104 SPDK_DEBUGLOG(SPDK_LOG_TRACE
, "flag was NULL\n");
108 if (spdk_trace_disable_tpoint_group(req
.name
)) {
112 free_rpc_tpoint_group(&req
);
114 w
= spdk_jsonrpc_begin_result(request
);
115 spdk_json_write_bool(w
, true);
116 spdk_jsonrpc_end_result(request
, w
);
120 spdk_jsonrpc_send_error_response(request
, SPDK_JSONRPC_ERROR_INVALID_PARAMS
, "Invalid parameters");
121 free_rpc_tpoint_group(&req
);
123 SPDK_RPC_REGISTER("trace_disable_tpoint_group", rpc_trace_disable_tpoint_group
,
124 SPDK_RPC_STARTUP
| SPDK_RPC_RUNTIME
)
125 SPDK_RPC_REGISTER_ALIAS_DEPRECATED(trace_disable_tpoint_group
, disable_tpoint_group
)
128 rpc_trace_get_tpoint_group_mask(struct spdk_jsonrpc_request
*request
,
129 const struct spdk_json_val
*params
)
131 uint64_t tpoint_group_mask
;
134 struct spdk_json_write_ctx
*w
;
135 struct spdk_trace_register_fn
*register_fn
;
137 if (params
!= NULL
) {
138 spdk_jsonrpc_send_error_response(request
, SPDK_JSONRPC_ERROR_INVALID_PARAMS
,
139 "trace_get_tpoint_group_mask requires no parameters");
143 w
= spdk_jsonrpc_begin_result(request
);
144 tpoint_group_mask
= spdk_trace_get_tpoint_group_mask();
146 spdk_json_write_object_begin(w
);
148 snprintf(mask_str
, sizeof(mask_str
), "0x%lx", tpoint_group_mask
);
149 spdk_json_write_named_string(w
, "tpoint_group_mask", mask_str
);
151 register_fn
= spdk_trace_get_first_register_fn();
152 while (register_fn
) {
153 enabled
= spdk_trace_get_tpoint_mask(register_fn
->tgroup_id
) != 0;
155 spdk_json_write_named_object_begin(w
, register_fn
->name
);
156 spdk_json_write_named_bool(w
, "enabled", enabled
);
158 snprintf(mask_str
, sizeof(mask_str
), "0x%lx", (1UL << register_fn
->tgroup_id
));
159 spdk_json_write_named_string(w
, "mask", mask_str
);
160 spdk_json_write_object_end(w
);
162 register_fn
= spdk_trace_get_next_register_fn(register_fn
);
165 spdk_json_write_object_end(w
);
166 spdk_jsonrpc_end_result(request
, w
);
168 SPDK_RPC_REGISTER("trace_get_tpoint_group_mask", rpc_trace_get_tpoint_group_mask
,
169 SPDK_RPC_STARTUP
| SPDK_RPC_RUNTIME
)
170 SPDK_RPC_REGISTER_ALIAS_DEPRECATED(trace_get_tpoint_group_mask
, get_tpoint_group_mask
)