blob: 726813950ba6ca508261db10c2cf19d22ef24b55 [file] [log] [blame]
Matteo Scandoloc9306e42016-08-04 16:24:30 -07001namespace java org.p4.bmv2.thrift
2/* Copyright 2013-present Barefoot Networks, Inc.
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/*
18 * Antonin Bas (antonin@barefootnetworks.com)
19 *
20 */
21
22namespace cpp bm_runtime.standard
23namespace py bm_runtime.standard
24
25typedef i64 BmEntryHandle
26typedef list<binary> BmActionData
27
28typedef i32 BmMemberHandle
29typedef i32 BmGroupHandle
30
31typedef i32 BmLearningListId
32typedef i64 BmLearningBufferId
33typedef i32 BmLearningSampleId
34
35enum BmMatchParamType {
36 EXACT = 0,
37 LPM = 1,
38 TERNARY = 2,
39 VALID = 3
40}
41
42struct BmMatchParamExact {
43 1:binary key
44}
45
46struct BmMatchParamLPM {
47 1:binary key,
48 2:i32 prefix_length
49}
50
51struct BmMatchParamTernary {
52 1:binary key,
53 2:binary mask
54}
55
56struct BmMatchParamValid {
57 1:bool key
58}
59
60# Thrift union sucks in C++, the following is much better
61struct BmMatchParam {
62 1:BmMatchParamType type,
63 2:optional BmMatchParamExact exact,
64 3:optional BmMatchParamLPM lpm,
65 4:optional BmMatchParamTernary ternary,
66 5:optional BmMatchParamValid valid
67}
68
69typedef list<BmMatchParam> BmMatchParams
70
71struct BmAddEntryOptions {
72 1:optional i32 priority
73}
74
75struct BmCounterValue {
76 1:i64 bytes;
77 2:i64 packets;
78}
79
80struct BmMeterRateConfig {
81 1:double units_per_micros;
82 2:i32 burst_size;
83}
84
85enum TableOperationErrorCode {
86 TABLE_FULL = 1,
87 INVALID_HANDLE = 2,
88 EXPIRED_HANDLE = 3,
89 COUNTERS_DISABLED = 4,
90 METERS_DISABLED = 5,
91 AGEING_DISABLED = 6,
92 INVALID_TABLE_NAME = 7,
93 INVALID_ACTION_NAME = 8,
94 WRONG_TABLE_TYPE = 9,
95 INVALID_MBR_HANDLE = 10,
96 MBR_STILL_USED = 11,
97 MBR_ALREADY_IN_GRP = 12,
98 MBR_NOT_IN_GRP = 13,
99 INVALID_GRP_HANDLE = 14,
100 GRP_STILL_USED = 15,
101 EMPTY_GRP = 16,
102 DUPLICATE_ENTRY = 17,
103 BAD_MATCH_KEY = 18,
104 INVALID_METER_OPERATION = 19,
105 ERROR = 20,
106}
107
108exception InvalidTableOperation {
109 1:TableOperationErrorCode code
110}
111
112enum CounterOperationErrorCode {
113 INVALID_COUNTER_NAME = 1,
114 INVALID_INDEX = 2,
115 ERROR = 3,
116}
117
118exception InvalidCounterOperation {
119 1:CounterOperationErrorCode code
120}
121
122enum SwapOperationErrorCode {
123 CONFIG_SWAP_DISABLED = 1,
124 ONGOING_SWAP = 2,
125 NO_ONGOING_SWAP = 3
126}
127
128exception InvalidSwapOperation {
129 1:SwapOperationErrorCode code
130}
131
132enum MeterOperationErrorCode {
133 INVALID_INDEX = 1,
134 BAD_RATES_LIST = 2,
135 INVALID_INFO_RATE_VALUE = 3,
136 INVALID_BURST_SIZE_VALUE = 4,
137 ERROR = 5
138}
139
140exception InvalidMeterOperation {
141 1:MeterOperationErrorCode code
142}
143
144typedef i64 BmRegisterValue
145
146enum RegisterOperationErrorCode {
147 INVALID_INDEX = 1,
148 ERROR = 2
149}
150
151exception InvalidRegisterOperation {
152 1:RegisterOperationErrorCode code
153}
154
155enum LearnOperationErrorCode {
156 INVALID_LIST_ID = 1,
157 ERROR = 2
158}
159
160exception InvalidLearnOperation {
161 1:LearnOperationErrorCode code
162}
163
164// TODO
165enum DevMgrErrorCode {
166 ERROR = 1
167}
168
169exception InvalidDevMgrOperation {
170 1:DevMgrErrorCode code
171}
172
173struct DevMgrPortInfo {
174 1:i32 port_num;
175 2:string iface_name;
176 3:bool is_up;
177 4:map<string, string> extra;
178}
179
180service Standard {
181
182 // table operations
183
184 BmEntryHandle bm_mt_add_entry(
185 1:i32 cxt_id,
186 2:string table_name,
187 3:BmMatchParams match_key,
188 4:string action_name,
189 5:BmActionData action_data,
190 6:BmAddEntryOptions options
191 ) throws (1:InvalidTableOperation ouch),
192
193 void bm_mt_set_default_action(
194 1:i32 cxt_id,
195 2:string table_name,
196 3:string action_name,
197 4:BmActionData action_data
198 ) throws (1:InvalidTableOperation ouch),
199
200 void bm_mt_delete_entry(
201 1:i32 cxt_id,
202 2:string table_name,
203 3:BmEntryHandle entry_handle
204 ) throws (1:InvalidTableOperation ouch),
205
206 void bm_mt_modify_entry(
207 1:i32 cxt_id,
208 2:string table_name,
209 3:BmEntryHandle entry_handle,
210 4:string action_name,
211 5:BmActionData action_data
212 ) throws (1:InvalidTableOperation ouch),
213
214 void bm_mt_set_entry_ttl(
215 1:i32 cxt_id,
216 2:string table_name
217 3:BmEntryHandle entry_handle,
218 4:i32 timeout_ms
219 ) throws (1:InvalidTableOperation ouch),
220
221 // indirect tables
222
223 BmMemberHandle bm_mt_indirect_add_member(
224 1:i32 cxt_id,
225 2:string table_name,
226 3:string action_name,
227 4:BmActionData action_data
228 ) throws (1:InvalidTableOperation ouch),
229
230 void bm_mt_indirect_delete_member(
231 1:i32 cxt_id,
232 2:string table_name,
233 3:BmMemberHandle mbr_handle
234 ) throws (1:InvalidTableOperation ouch),
235
236 void bm_mt_indirect_modify_member(
237 1:i32 cxt_id,
238 2:string table_name,
239 3:BmMemberHandle mbr_handle,
240 4:string action_name,
241 5:BmActionData action_data
242 ) throws (1:InvalidTableOperation ouch),
243
244 BmEntryHandle bm_mt_indirect_add_entry(
245 1:i32 cxt_id,
246 2:string table_name,
247 3:BmMatchParams match_key,
248 4:BmMemberHandle mbr_handle,
249 5:BmAddEntryOptions options
250 ) throws (1:InvalidTableOperation ouch),
251
252 void bm_mt_indirect_modify_entry(
253 1:i32 cxt_id,
254 2:string table_name,
255 3:BmEntryHandle entry_handle,
256 4:BmMemberHandle mbr_handle
257 ) throws (1:InvalidTableOperation ouch),
258
259 void bm_mt_indirect_delete_entry(
260 1:i32 cxt_id,
261 2:string table_name,
262 3:BmEntryHandle entry_handle
263 ) throws (1:InvalidTableOperation ouch),
264
265 void bm_mt_indirect_set_entry_ttl(
266 1:i32 cxt_id,
267 2:string table_name
268 3:BmEntryHandle entry_handle,
269 4:i32 timeout_ms
270 ) throws (1:InvalidTableOperation ouch),
271
272 void bm_mt_indirect_set_default_member(
273 1:i32 cxt_id,
274 2:string table_name,
275 3:BmMemberHandle mbr_handle
276 ) throws (1:InvalidTableOperation ouch),
277
278 // indirect tables with selector
279
280 BmGroupHandle bm_mt_indirect_ws_create_group(
281 1:i32 cxt_id,
282 2:string table_name
283 ) throws (1:InvalidTableOperation ouch),
284
285 void bm_mt_indirect_ws_delete_group(
286 1:i32 cxt_id,
287 2:string table_name,
288 3:BmGroupHandle grp_handle
289 ) throws (1:InvalidTableOperation ouch),
290
291 void bm_mt_indirect_ws_add_member_to_group(
292 1:i32 cxt_id,
293 2:string table_name,
294 3:BmMemberHandle mbr_handle,
295 4:BmGroupHandle grp_handle
296 ) throws (1:InvalidTableOperation ouch),
297
298 void bm_mt_indirect_ws_remove_member_from_group(
299 1:i32 cxt_id,
300 2:string table_name,
301 3:BmMemberHandle mbr_handle,
302 4:BmGroupHandle grp_handle
303 ) throws (1:InvalidTableOperation ouch),
304
305 BmEntryHandle bm_mt_indirect_ws_add_entry(
306 1:i32 cxt_id,
307 2:string table_name,
308 3:BmMatchParams match_key,
309 4:BmGroupHandle grp_handle
310 5:BmAddEntryOptions options
311 ) throws (1:InvalidTableOperation ouch),
312
313 void bm_mt_indirect_ws_modify_entry(
314 1:i32 cxt_id,
315 2:string table_name,
316 3:BmEntryHandle entry_handle,
317 4:BmGroupHandle grp_handle
318 ) throws (1:InvalidTableOperation ouch),
319
320 void bm_mt_indirect_ws_set_default_group(
321 1:i32 cxt_id,
322 2:string table_name,
323 3:BmGroupHandle grp_handle
324 ) throws (1:InvalidTableOperation ouch),
325
326 BmCounterValue bm_mt_read_counter(
327 1:i32 cxt_id,
328 2:string table_name,
329 3:BmEntryHandle entry_handle
330 ) throws (1:InvalidTableOperation ouch),
331
332 void bm_mt_reset_counters(
333 1:i32 cxt_id,
334 2:string table_name
335 ) throws (1:InvalidTableOperation ouch),
336
337 void bm_mt_write_counter(
338 1:i32 cxt_id,
339 2:string table_name,
340 3:BmEntryHandle entry_handle,
341 4:BmCounterValue value
342 ) throws (1:InvalidTableOperation ouch),
343
344 void bm_mt_set_meter_rates(
345 1:i32 cxt_id,
346 2:string table_name,
347 3:BmEntryHandle entry_handle,
348 4:list<BmMeterRateConfig> rates
349 ) throws (1:InvalidTableOperation ouch),
350
351 // indirect counters
352
353 BmCounterValue bm_counter_read(
354 1:i32 cxt_id,
355 2:string counter_name,
356 3:i32 index
357 ) throws (1:InvalidCounterOperation ouch),
358
359 void bm_counter_reset_all(
360 1:i32 cxt_id,
361 2:string counter_name
362 ) throws (1:InvalidCounterOperation ouch),
363
364 void bm_counter_write(
365 1:i32 cxt_id,
366 2:string counter_name,
367 3:i32 index,
368 4:BmCounterValue value
369 ) throws (1:InvalidCounterOperation ouch),
370
371 // learning acks
372
373 void bm_learning_ack(
374 1:i32 cxt_id,
375 2:BmLearningListId list_id,
376 3:BmLearningBufferId buffer_id,
377 4:list<BmLearningSampleId> sample_ids
378 ) throws (1:InvalidLearnOperation ouch),
379
380 void bm_learning_ack_buffer(
381 1:i32 cxt_id,
382 2:BmLearningListId list_id,
383 3:BmLearningBufferId buffer_id
384 ) throws (1:InvalidLearnOperation ouch),
385
386 void bm_learning_set_timeout(
387 1:i32 cxt_id,
388 2:BmLearningListId list_id,
389 3:i32 timeout_ms
390 ) throws (1:InvalidLearnOperation ouch),
391
392 void bm_learning_set_buffer_size(
393 1:i32 cxt_id,
394 2:BmLearningListId list_id,
395 3:i32 nb_samples
396 ) throws (1:InvalidLearnOperation ouch),
397
398 // swap configs
399
400 void bm_load_new_config(
401 1:string config_str
402 ) throws (1:InvalidSwapOperation ouch),
403
404 void bm_swap_configs() throws (1:InvalidSwapOperation ouch),
405
406 // meters
407
408 void bm_meter_array_set_rates(
409 1:i32 cxt_id,
410 2:string meter_array_name,
411 3:list<BmMeterRateConfig> rates
412 ) throws (1:InvalidMeterOperation ouch)
413
414 void bm_meter_set_rates(
415 1:i32 cxt_id,
416 2:string meter_array_name,
417 3:i32 index,
418 4:list<BmMeterRateConfig> rates
419 ) throws (1:InvalidMeterOperation ouch)
420
421
422 // registers
423
424 BmRegisterValue bm_register_read(
425 1:i32 cxt_id,
426 2:string register_array_name,
427 3:i32 idx
428 ) throws (1:InvalidRegisterOperation ouch)
429
430 void bm_register_write(
431 1:i32 cxt_id,
432 2:string register_array_name,
433 3:i32 index,
434 4:BmRegisterValue value
435 ) throws (1:InvalidRegisterOperation ouch)
436
437 void bm_register_write_range(
438 1:i32 cxt_id,
439 2:string register_array_name,
440 3:i32 start_index,
441 4:i32 end_index,
442 5:BmRegisterValue value
443 ) throws (1:InvalidRegisterOperation ouch)
444
445 void bm_register_reset(
446 1:i32 cxt_id,
447 2:string register_array_name
448 ) throws (1:InvalidRegisterOperation ouch)
449
450
451 // device manager
452
453 void bm_dev_mgr_add_port(
454 1:string iface_name,
455 2:i32 port_num,
456 3:string pcap_path // optional
457 ) throws (1:InvalidDevMgrOperation ouch)
458
459 void bm_dev_mgr_remove_port(
460 1:i32 port_num
461 ) throws (1:InvalidDevMgrOperation ouch)
462
463 list<DevMgrPortInfo> bm_dev_mgr_show_ports(
464 ) throws (1:InvalidDevMgrOperation ouch)
465
466 // debug functions
467
468 string bm_dump_table(
469 1:i32 cxt_id,
470 2:string table_name
471 )
472
473 void bm_reset_state()
474
475 string bm_get_config()
476 string bm_get_config_md5()
477
478 string bm_serialize_state()
479}