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";
18
19package perfetto.protos;
20
21message CommitDataRequest {
22  // When |chunks_to_move| is present, the producer is requesting the service to
23  // move the given chunks form the share memory buffer into the central
24  // trace buffer(s).
25  message ChunksToMove {
26    // The 0-based index of the page in the Shared Memory Buffer.
27    optional uint32 page = 1;
28
29    // The 0-based chunk index [0..13] within the page.
30    optional uint32 chunk = 2;
31
32    // The target buffer it should be moved onto. The service will check that
33    // the producer is allowed to write into that buffer before the move.
34    optional uint32 target_buffer = 3;
35  }
36  repeated ChunksToMove chunks_to_move = 1;
37
38  // Used to patch chunks that have already been sent to the service. The chunk
39  // might not be in the shared memory buffer anymore as it could have been
40  // moved by the service in response to a prior CommitDataRequest.
41  // It is perfectly valid to patch a chunk that is being notified in the same
42  // message (a chunk can show up both in the |changed_pages| and |patches|
43  // field within the same CommitDataRequest message).
44  // In other words, |chunks_to_patch| is always processed after
45  // |chunks_to_move|.
46  message ChunkToPatch {
47    message Patch {
48      // Offset in bytes from the start of the chunk payload. e.g., offset == 0
49      // corresponds to the first byte of the first packet (or fragment) in the
50      // chunk.
51      optional uint32 offset = 1;
52
53      // Bytes to patch at the given offset.
54      optional bytes data = 2;
55    }
56
57    optional uint32 target_buffer = 1;
58
59    // {WriterID, ChunkID} uniquely identify a chunk for the current producer.
60    optional uint32 writer_id = 2;
61    optional uint32 chunk_id = 3;
62
63    // List of patches to apply to the given chunk.
64    repeated Patch patches = 4;
65
66    // When true more patches will follow in future requests and the chunk
67    // should be still considered as patch-pending. When false the chunk becomes
68    // eligible for reading.
69    optional bool has_more_patches = 5;
70  }
71  repeated ChunkToPatch chunks_to_patch = 2;
72
73  // Optional. If this commit is made in response to a Flush(id) request coming
74  // from the service, copy back the id of the request so the service can tell
75  // when the flush happened.
76  optional uint64 flush_request_id = 3;
77}
78