@@ -82,29 +82,54 @@ pub enum EreportRequest {
82
82
// `version_byte_values` test below!
83
83
}
84
84
85
+ /// An ereport request ID (sequence number)
86
+ ///
87
+ /// This is an arbitrary 8-bit value sent in the request packet. The SP is
88
+ /// expected to include this value in the header for the response packet.
89
+ #[ derive(
90
+ Clone ,
91
+ Copy ,
92
+ Debug ,
93
+ PartialEq ,
94
+ Eq ,
95
+ Ord ,
96
+ PartialOrd ,
97
+ Serialize ,
98
+ Deserialize ,
99
+ SerializedSize ,
100
+ ) ]
101
+ #[ repr( transparent) ]
102
+ pub struct RequestIdV0 ( pub u8 ) ;
103
+
104
+ impl RequestIdV0 {
105
+ pub fn increment ( & mut self ) {
106
+ self . 0 = self . 0 . wrapping_add ( 1 ) ;
107
+ }
108
+ }
109
+
85
110
/// A request for ereports aggregated by the SP's snitch task, version 0.
86
111
///
87
112
/// ```text
88
113
/// 0 1 2 3
89
114
/// +--------+--------+--------+--------+
90
- /// | version|-------C| limit | |
91
- /// +--------+--------+--------+ |
115
+ /// | version|-------C| limit | req ID |
116
+ /// +--------+--------+--------+--------+
92
117
/// | |
93
118
/// + +
94
119
/// | |
95
120
/// + restart ID (128 bits) +
96
121
/// | |
97
- /// + +-------- +
98
- /// | | |
99
- /// +--------+--------+--------+ +
122
+ /// + +
123
+ /// | |
124
+ /// +--------+--------+--------+-------- +
100
125
/// | first ENA desired in response |
101
- /// + (64 bits) +-------- +
102
- /// | | |
103
- /// +--------+--------+--------+ +
126
+ /// + (64 bits) +
127
+ /// | |
128
+ /// +--------+--------+--------+-------- +
104
129
/// | last ENA written to database | only present when C bit set
105
- /// + (64 bits) +-------- +
106
- /// | |
107
- /// +--------+--------+--------+
130
+ /// + (64 bits) +
131
+ /// | |
132
+ /// +--------+--------+--------+--------+
108
133
/// ```
109
134
///
110
135
/// See [RFD 545 §4.4.3.1] for details.
@@ -118,6 +143,10 @@ pub struct RequestV0 {
118
143
/// Maximum number of ereports to include in the response packet.
119
144
pub limit : u8 ,
120
145
146
+ /// Message ID of this request. The SP must include this value in the
147
+ /// response header for the response to this request.
148
+ pub request_id : RequestIdV0 ,
149
+
121
150
/// The restart ID of the SP's snitch task which the control plane believes
122
151
/// is current.
123
152
///
@@ -167,6 +196,7 @@ bitflags::bitflags! {
167
196
impl RequestV0 {
168
197
pub const fn new (
169
198
restart_id : RestartId ,
199
+ request_id : RequestIdV0 ,
170
200
start_ena : Ena ,
171
201
limit : u8 ,
172
202
committed_ena : Option < Ena > ,
@@ -175,7 +205,7 @@ impl RequestV0 {
175
205
Some ( ena) => ( ena, RequestFlagsV0 :: COMMIT ) ,
176
206
None => ( Ena ( 0 ) , RequestFlagsV0 :: empty ( ) ) ,
177
207
} ;
178
- Self { flags, limit, restart_id, start_ena, committed_ena }
208
+ Self { flags, limit, request_id , restart_id, start_ena, committed_ena }
179
209
}
180
210
181
211
/// Returns the "committed ENA" field if this packet contains one.
@@ -214,31 +244,31 @@ pub enum EreportResponseHeader {
214
244
/// ```text
215
245
/// 0 1 2 3
216
246
/// +--------+--------+--------+--------+
217
- /// | version| |
218
- /// +--------+ +
247
+ /// | version| req ID | |
248
+ /// +--------+--------+ +
219
249
/// | |
220
250
/// + +
221
251
/// | restart ID (128 bits) |
222
252
/// + +
223
253
/// | |
224
- /// + +--------+
225
- /// | | 0xBF | beginning of CBOR metadata map
254
+ /// + +-------- +--------+
255
+ /// | | 0xBF | beginning of CBOR metadata map
226
256
/// +--------+--------+--------+--------+
227
257
/// ... metadata k/v pairs ... | 0xFF | metadata-only packets may end here
228
258
/// +--------+--------+--------+--------+
229
259
/// | start ENA (64 bits) |
230
260
/// +--------+--------+--------+--------+
231
- /// | 0x9F | ... ereports ...
261
+ /// | 0x9F | ... ereports ...| 0xFF |
232
262
/// +--------+ +--------+
233
- /// ... ereports ... | 0xFF |
234
- /// +--------+
235
263
/// ```
236
264
/// See [RFD 545 §4.4.4] for details.
237
265
/// [RFD 545 §4.4.4]: https://rfd.shared.oxide.computer/rfd/0545#_readresponse
238
266
#[ derive(
239
267
Debug , Clone , Copy , PartialEq , Eq , Serialize , Deserialize , SerializedSize ,
240
268
) ]
241
269
pub struct ResponseHeaderV0 {
270
+ /// The request ID of the request that this message is a response to.
271
+ pub request_id : RequestIdV0 ,
242
272
/// The reporter restart ID of the SP's snitch task when this response was
243
273
/// produced.
244
274
pub restart_id : RestartId ,
@@ -276,6 +306,7 @@ mod tests {
276
306
& mut buf,
277
307
& EreportRequest :: V0 ( RequestV0 :: new (
278
308
RestartId ( 1 ) ,
309
+ RequestIdV0 ( 1 ) ,
279
310
Ena ( 2 ) ,
280
311
3 ,
281
312
Some ( Ena ( 4 ) ) ,
@@ -288,6 +319,7 @@ mod tests {
288
319
& mut buf,
289
320
& EreportResponseHeader :: V0 ( ResponseHeaderV0 {
290
321
restart_id : RestartId ( 1 ) ,
322
+ request_id : RequestIdV0 ( 1 ) ,
291
323
} ) ,
292
324
) ;
293
325
assert_eq ! ( bytes[ 0 ] , 0 , "ResponseHeader v0 version byte should be 0" ) ;
0 commit comments