1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18option optimize_for = LITE_RUNTIME; 19 20import "perfetto/common/commit_data_request.proto"; 21import "perfetto/config/data_source_config.proto"; 22import "perfetto/config/data_source_descriptor.proto"; 23 24package perfetto.protos; 25 26// IPC interface definition for the producer port of the tracing service. 27service ProducerPort { 28 // Called once only after establishing the connection with the Service. 29 // The service replies sending the shared memory file descriptor in reply. 30 rpc InitializeConnection(InitializeConnectionRequest) 31 returns (InitializeConnectionResponse) {} 32 33 // Advertises a data source. 34 rpc RegisterDataSource(RegisterDataSourceRequest) 35 returns (RegisterDataSourceResponse) {} 36 37 // Unregisters a previously registered data source. 38 rpc UnregisterDataSource(UnregisterDataSourceRequest) 39 returns (UnregisterDataSourceResponse) {} 40 41 // Sent by the client to request the service to: 42 // 1) Move some chunks from the shmem buffer into the logging buffer. 43 // 2) Patch the content of some chunks previously moved. 44 // 3) Acknowledge a Flush() request. 45 rpc CommitData(protos.CommitDataRequest) returns (CommitDataResponse) {} 46 47 // This is a backchannel to get asynchronous commands / notifications back 48 // from the Service. 49 rpc GetAsyncCommand(GetAsyncCommandRequest) 50 returns (stream GetAsyncCommandResponse) {} 51 52 // ---------------------------------------------------- 53 // All methods below have been introduced in Android Q. 54 // ---------------------------------------------------- 55 56 // Associates a trace writer with its target buffer. 57 rpc RegisterTraceWriter(RegisterTraceWriterRequest) 58 returns (RegisterTraceWriterResponse) {} 59 60 // Removes a trace writer association previously added by 61 // RegisterTraceWriter. 62 rpc UnregisterTraceWriter(UnregisterTraceWriterRequest) 63 returns (UnregisterTraceWriterResponse) {} 64 65 // Sent by the client in response to a StartDataSource message, when a data 66 // source is successfully started. This is expected only for data sources that 67 // set the DataSourceDescriptor.will_notify_on_start flag when registering. 68 rpc NotifyDataSourceStarted(NotifyDataSourceStartedRequest) 69 returns (NotifyDataSourceStartedResponse) {} 70 71 // Sent by the client in response to a StopDataSource message, when a data 72 // source is succesfully stopped. This is expected only for data sources that 73 // set the DataSourceDescriptor.will_notify_on_stop flag when registering. 74 rpc NotifyDataSourceStopped(NotifyDataSourceStoppedRequest) 75 returns (NotifyDataSourceStoppedResponse) {} 76 77 // Sent by the client to request the service to: 78 // 1) Find all sessions which define these triggers 79 // 2) Perform an action as defined in those sessions configs. 80 rpc ActivateTriggers(ActivateTriggersRequest) 81 returns (ActivateTriggersResponse) {} 82} 83 84// Arguments for rpc InitializeConnection(). 85message InitializeConnectionRequest { 86 // Defines the granularity of the tracing pages. Must be an integer multiple 87 // of 4096. See tradeoff considerations in shared_memory_abi.h. 88 optional uint32 shared_buffer_page_size_bytes = 1; 89 90 // Optional. Provides a hint to the tracing service about the suggested size 91 // of the shared memory buffer. The service is not required to respect this 92 // and might return a smaller buffer. 93 optional uint32 shared_memory_size_hint_bytes = 2; 94 95 // Required to match the producer config set by the service to the correct 96 // producer. 97 optional string producer_name = 3; 98 99 enum ProducerSMBScrapingMode { 100 // Use the service's default setting for SMB scraping. 101 SMB_SCRAPING_UNSPECIFIED = 0; 102 103 // Enable scraping of uncommitted chunks from the producer's shared memory 104 // buffer. 105 SMB_SCRAPING_ENABLED = 1; 106 107 // Disable scraping of uncommitted chunks from the producer's shared memory 108 // buffer. 109 SMB_SCRAPING_DISABLED = 2; 110 } 111 112 // If provided, overrides the service's SMB scraping setting for the producer. 113 optional ProducerSMBScrapingMode smb_scraping_mode = 4; 114} 115 116message InitializeConnectionResponse { 117 // This message provides the shared memory buffer FD (not a proto field). 118} 119 120// Arguments for rpc RegisterDataSource(). 121 122message RegisterDataSourceRequest { 123 optional protos.DataSourceDescriptor data_source_descriptor = 1; 124} 125 126message RegisterDataSourceResponse { 127 // Only set in case of errors, when |data_source_id| == 0. 128 optional string error = 1; 129}; 130 131// Arguments for rpc UnregisterDataSource(). 132 133message UnregisterDataSourceRequest { 134 // The name of the data source to unregister, as previously passed in 135 // |RegisterDataSourceRequest.name|. 136 optional string data_source_name = 1; 137} 138 139message UnregisterDataSourceResponse {} 140 141// Arguments for rpc RegisterTraceWriter(). 142 143message RegisterTraceWriterRequest { 144 // The ID of a producer's trace writer. 145 optional uint32 trace_writer_id = 1; 146 147 // The ID of the target buffer that the trace writer commits its chunks to. 148 optional uint32 target_buffer = 2; 149} 150 151message RegisterTraceWriterResponse {} 152 153// Arguments for rpc UnregisterTraceWriter(). 154 155message UnregisterTraceWriterRequest { 156 // The ID of a producer's trace writer. 157 optional uint32 trace_writer_id = 1; 158} 159 160message UnregisterTraceWriterResponse {} 161 162// Arguments for rpc CommitData(). 163// See commit_data_request.proto for CommitDataRequest. That has its own file 164// because it is used also as input to generate the C++ classes in tracing/core 165// via tools/gen_tracing_cpp_headers_from_protos.py. 166 167message CommitDataResponse {} 168 169// Arguments for rpc NotifyDataSourceStarted(). 170 171message NotifyDataSourceStartedRequest { 172 // ID of the data source that has successfully started. 173 optional uint64 data_source_id = 1; 174} 175 176message NotifyDataSourceStartedResponse {} 177 178// Arguments for rpc NotifyDataSourceStopped(). 179 180message NotifyDataSourceStoppedRequest { 181 // ID of the data source that has successfully stopped. 182 optional uint64 data_source_id = 1; 183} 184 185message NotifyDataSourceStoppedResponse {} 186 187// Arguments for rpc ActivateTriggersRequest(). 188 189message ActivateTriggersRequest { 190 repeated string trigger_names = 1; 191} 192 193message ActivateTriggersResponse {} 194 195// Arguments for rpc GetAsyncCommand(). 196 197message GetAsyncCommandRequest {} 198 199message GetAsyncCommandResponse { 200 // Called after SetupTracing and before StartDataSource. 201 // This message was introduced in Android Q. 202 message SetupDataSource { 203 optional uint64 new_instance_id = 1; 204 optional protos.DataSourceConfig config = 2; 205 } 206 207 message StartDataSource { 208 optional uint64 new_instance_id = 1; 209 210 // For backwards compat reasons (with Android P), the config passed here 211 // is identical to the one passed to SetupDataSource.config. 212 optional protos.DataSourceConfig config = 2; 213 } 214 215 message StopDataSource { optional uint64 instance_id = 1; } 216 217 // This message also transports the file descriptor for the shared memory 218 // buffer. 219 message SetupTracing { optional uint32 shared_buffer_page_size_kb = 1; } 220 221 message Flush { 222 // The instance id (i.e. StartDataSource.new_instance_id) of the data 223 // sources to flush. 224 repeated uint64 data_source_ids = 1; 225 226 // A monotonic counter generated by the service. The producer is simply 227 // expected to copy this value back into the CommitDataRequest, so the 228 // service can tell when the data for this flush has been committed. 229 optional uint64 request_id = 2; 230 } 231 232 // Instructs the given data sources to stop referring to any trace contents 233 // emitted so far. Sent only to active data sources that set 234 // |handles_incremental_state_clear| in their DataSourceDescriptor. 235 // 236 // Added to perfetto tree in May 2019. 237 message ClearIncrementalState { 238 // The instance id (i.e. StartDataSource.new_instance_id) of the data 239 // sources that should clear their incremental state. 240 repeated uint64 data_source_ids = 1; 241 } 242 243 // Next id: 8. 244 oneof cmd { 245 SetupTracing setup_tracing = 3; 246 SetupDataSource setup_data_source = 6; 247 StartDataSource start_data_source = 1; 248 StopDataSource stop_data_source = 2; 249 // id == 4 was teardown_tracing, never implemented. 250 Flush flush = 5; 251 ClearIncrementalState clear_incremental_state = 7; 252 } 253} 254