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 17 syntax = "proto2"; 18 option optimize_for = LITE_RUNTIME; 19 20 import "perfetto/config/data_source_config.proto"; 21 import "perfetto/config/data_source_descriptor.proto"; 22 import "perfetto/common/commit_data_request.proto"; 23 24 package perfetto.protos; 25 26 // IPC interface definition for the producer port of the tracing service. 27 service 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 rpc CommitData(protos.CommitDataRequest) returns (CommitDataResponse) {} 45 46 // This is a backchannel to get asynchronous commands / notifications back 47 // from the Service. 48 rpc GetAsyncCommand(GetAsyncCommandRequest) 49 returns (stream GetAsyncCommandResponse) {} 50 } 51 52 // Arguments for rpc InitializeConnection(). 53 message InitializeConnectionRequest { 54 // Defines the granularity of the tracing pages. Must be an integer multiple 55 // of 4096. See tradeoff considerations in shared_memory_abi.h. 56 optional uint32 shared_buffer_page_size_bytes = 1; 57 58 // Optional. Provides a hint to the tracing service about the suggested size 59 // of the shared memory buffer. The service is not required to respect this 60 // and might return a smaller buffer. 61 optional uint32 shared_memory_size_hint_bytes = 2; 62 63 // Required to match the producer config set by the service to the correct 64 // producer. 65 optional string producer_name = 3; 66 } 67 68 message InitializeConnectionResponse { 69 // This message provides the shared memory buffer FD (not a proto field). 70 } 71 72 // Arguments for rpc RegisterDataSource(). 73 74 message RegisterDataSourceRequest { 75 optional protos.DataSourceDescriptor data_source_descriptor = 1; 76 } 77 78 message RegisterDataSourceResponse { 79 // Only set in case of errors, when |data_source_id| == 0. 80 optional string error = 1; 81 }; 82 83 // Arguments for rpc UnregisterDataSource(). 84 85 message UnregisterDataSourceRequest { 86 // The name of the data source to unregister, as previously passed in 87 // |RegisterDataSourceRequest.name|. 88 optional string data_source_name = 1; 89 } 90 91 message UnregisterDataSourceResponse {} 92 93 // Arguments for rpc CommitData(). 94 // See commit_data_request.proto for CommitDataRequest. That has its own file 95 // because it is used also as input to generate the C++ classes in tracing/core 96 // via tools/gen_tracing_cpp_headers_from_protos.py. 97 98 message CommitDataResponse {} 99 100 // Arguments for rpc GetAsyncCommand(). 101 102 message GetAsyncCommandRequest {} 103 104 message GetAsyncCommandResponse { 105 message StartDataSource { 106 optional uint64 new_instance_id = 1; 107 optional protos.DataSourceConfig config = 2; 108 } 109 110 message StopDataSource { optional uint64 instance_id = 1; } 111 112 // This message also transports the file descriptor for the shared memory 113 // buffer. 114 message SetupTracing { optional uint32 shared_buffer_page_size_kb = 1; } 115 116 message Flush { 117 // The instance id (i.e. StartDataSource.new_instance_id) of the data 118 // sources to flush. 119 repeated uint64 data_source_ids = 1; 120 121 // A monotonic counter generated by the service. The producer is simply 122 // expected to copy this value back into the CommitDataRequest, so the 123 // service can tell when the data for this flush has been committed. 124 optional uint64 request_id = 2; 125 } 126 127 oneof cmd { 128 StartDataSource start_data_source = 1; 129 StopDataSource stop_data_source = 2; 130 SetupTracing setup_tracing = 3; 131 // id == 4 was teardown_tracing, never implemented. 132 Flush flush = 5; 133 } 134 } 135