21 #ifndef BM_BM_SIM_RUNTIME_INTERFACE_H_
22 #define BM_BM_SIM_RUNTIME_INTERFACE_H_
28 #include "action_profile.h"
29 #include "match_tables.h"
30 #include "device_id.h"
34 class RuntimeInterface {
36 using mbr_hdl_t = MatchTableIndirect::mbr_hdl_t;
37 using grp_hdl_t = MatchTableIndirectWS::grp_hdl_t;
39 using MeterErrorCode = Meter::MeterErrorCode;
40 using RegisterErrorCode = Register::RegisterErrorCode;
50 virtual ~RuntimeInterface() { }
54 virtual MatchErrorCode
55 mt_get_num_entries(cxt_id_t cxt_id,
56 const std::string &table_name,
57 size_t *num_entries)
const = 0;
59 virtual MatchErrorCode
60 mt_clear_entries(cxt_id_t cxt_id,
61 const std::string &table_name,
62 bool reset_default_entry) = 0;
66 virtual MatchErrorCode
67 mt_add_entry(cxt_id_t cxt_id,
68 const std::string &table_name,
69 const std::vector<MatchKeyParam> &match_key,
70 const std::string &action_name,
71 ActionData action_data,
72 entry_handle_t *handle,
73 int priority = -1 ) = 0;
75 virtual MatchErrorCode
76 mt_set_default_action(cxt_id_t cxt_id,
77 const std::string &table_name,
78 const std::string &action_name,
79 ActionData action_data) = 0;
81 virtual MatchErrorCode
82 mt_reset_default_entry(cxt_id_t cxt_id,
83 const std::string &table_name) = 0;
85 virtual MatchErrorCode
86 mt_delete_entry(cxt_id_t cxt_id,
87 const std::string &table_name,
88 entry_handle_t handle) = 0;
90 virtual MatchErrorCode
91 mt_modify_entry(cxt_id_t cxt_id,
92 const std::string &table_name,
93 entry_handle_t handle,
94 const std::string &action_name,
95 ActionData action_data) = 0;
97 virtual MatchErrorCode
98 mt_set_entry_ttl(cxt_id_t cxt_id,
99 const std::string &table_name,
100 entry_handle_t handle,
101 unsigned int ttl_ms) = 0;
105 virtual MatchErrorCode
106 mt_act_prof_add_member(cxt_id_t cxt_id,
107 const std::string &act_prof_name,
108 const std::string &action_name,
109 ActionData action_data,
112 virtual MatchErrorCode
113 mt_act_prof_delete_member(cxt_id_t cxt_id,
114 const std::string &act_prof_name,
117 virtual MatchErrorCode
118 mt_act_prof_modify_member(cxt_id_t cxt_id,
119 const std::string &act_prof_name,
121 const std::string &action_name,
122 ActionData action_data) = 0;
124 virtual MatchErrorCode
125 mt_act_prof_create_group(cxt_id_t cxt_id,
126 const std::string &act_prof_name,
129 virtual MatchErrorCode
130 mt_act_prof_delete_group(cxt_id_t cxt_id,
131 const std::string &act_prof_name,
134 virtual MatchErrorCode
135 mt_act_prof_add_member_to_group(cxt_id_t cxt_id,
136 const std::string &act_prof_name,
137 mbr_hdl_t mbr, grp_hdl_t grp) = 0;
139 virtual MatchErrorCode
140 mt_act_prof_remove_member_from_group(cxt_id_t cxt_id,
141 const std::string &act_prof_name,
142 mbr_hdl_t mbr, grp_hdl_t grp) = 0;
144 virtual std::vector<ActionProfile::Member>
145 mt_act_prof_get_members(cxt_id_t cxt_id,
146 const std::string &act_prof_name)
const = 0;
148 virtual MatchErrorCode
149 mt_act_prof_get_member(cxt_id_t cxt_id,
const std::string &act_prof_name,
151 ActionProfile::Member *member)
const = 0;
153 virtual std::vector<ActionProfile::Group>
154 mt_act_prof_get_groups(cxt_id_t cxt_id,
155 const std::string &act_prof_name)
const = 0;
157 virtual MatchErrorCode
158 mt_act_prof_get_group(cxt_id_t cxt_id,
const std::string &act_prof_name,
160 ActionProfile::Group *group)
const = 0;
164 virtual MatchErrorCode
165 mt_indirect_add_entry(cxt_id_t cxt_id,
166 const std::string &table_name,
167 const std::vector<MatchKeyParam> &match_key,
169 entry_handle_t *handle,
170 int priority = 1) = 0;
172 virtual MatchErrorCode
173 mt_indirect_modify_entry(cxt_id_t cxt_id,
174 const std::string &table_name,
175 entry_handle_t handle,
178 virtual MatchErrorCode
179 mt_indirect_delete_entry(cxt_id_t cxt_id,
180 const std::string &table_name,
181 entry_handle_t handle) = 0;
183 virtual MatchErrorCode
184 mt_indirect_set_entry_ttl(cxt_id_t cxt_id,
185 const std::string &table_name,
186 entry_handle_t handle,
187 unsigned int ttl_ms) = 0;
189 virtual MatchErrorCode
190 mt_indirect_set_default_member(cxt_id_t cxt_id,
191 const std::string &table_name,
194 virtual MatchErrorCode
195 mt_indirect_reset_default_entry(cxt_id_t cxt_id,
196 const std::string &table_name) = 0;
198 virtual MatchErrorCode
199 mt_indirect_ws_add_entry(cxt_id_t cxt_id,
200 const std::string &table_name,
201 const std::vector<MatchKeyParam> &match_key,
203 entry_handle_t *handle,
204 int priority = 1) = 0;
206 virtual MatchErrorCode
207 mt_indirect_ws_modify_entry(cxt_id_t cxt_id,
208 const std::string &table_name,
209 entry_handle_t handle,
212 virtual MatchErrorCode
213 mt_indirect_ws_set_default_group(cxt_id_t cxt_id,
214 const std::string &table_name,
218 virtual MatchErrorCode
219 mt_read_counters(cxt_id_t cxt_id,
220 const std::string &table_name,
221 entry_handle_t handle,
222 MatchTableAbstract::counter_value_t *bytes,
223 MatchTableAbstract::counter_value_t *packets) = 0;
225 virtual MatchErrorCode
226 mt_reset_counters(cxt_id_t cxt_id,
227 const std::string &table_name) = 0;
229 virtual MatchErrorCode
230 mt_write_counters(cxt_id_t cxt_id,
231 const std::string &table_name,
232 entry_handle_t handle,
233 MatchTableAbstract::counter_value_t bytes,
234 MatchTableAbstract::counter_value_t packets) = 0;
236 virtual MatchErrorCode
237 mt_set_meter_rates(cxt_id_t cxt_id,
238 const std::string &table_name,
239 entry_handle_t handle,
240 const std::vector<Meter::rate_config_t> &configs) = 0;
242 virtual MatchErrorCode
243 mt_get_meter_rates(cxt_id_t cxt_id,
244 const std::string &table_name,
245 entry_handle_t handle,
246 std::vector<Meter::rate_config_t> *configs) = 0;
248 virtual MatchErrorCode
249 mt_reset_meter_rates(cxt_id_t cxt_id,
250 const std::string &table_name,
251 entry_handle_t handle) = 0;
253 virtual MatchTableType
254 mt_get_type(cxt_id_t cxt_id,
const std::string &table_name)
const = 0;
256 virtual std::vector<MatchTable::Entry>
257 mt_get_entries(cxt_id_t cxt_id,
const std::string &table_name)
const = 0;
259 virtual std::vector<MatchTableIndirect::Entry>
260 mt_indirect_get_entries(cxt_id_t cxt_id,
261 const std::string &table_name)
const = 0;
263 virtual std::vector<MatchTableIndirectWS::Entry>
264 mt_indirect_ws_get_entries(cxt_id_t cxt_id,
265 const std::string &table_name)
const = 0;
267 virtual MatchErrorCode
268 mt_get_entry(cxt_id_t cxt_id,
const std::string &table_name,
269 entry_handle_t handle, MatchTable::Entry *entry)
const = 0;
271 virtual MatchErrorCode
272 mt_indirect_get_entry(cxt_id_t cxt_id,
const std::string &table_name,
273 entry_handle_t handle,
274 MatchTableIndirect::Entry *entry)
const = 0;
276 virtual MatchErrorCode
277 mt_indirect_ws_get_entry(cxt_id_t cxt_id,
const std::string &table_name,
278 entry_handle_t handle,
279 MatchTableIndirectWS::Entry *entry)
const = 0;
281 virtual MatchErrorCode
282 mt_get_default_entry(cxt_id_t cxt_id,
const std::string &table_name,
283 MatchTable::Entry *entry)
const = 0;
285 virtual MatchErrorCode
286 mt_indirect_get_default_entry(cxt_id_t cxt_id,
const std::string &table_name,
287 MatchTableIndirect::Entry *entry)
const = 0;
289 virtual MatchErrorCode
290 mt_indirect_ws_get_default_entry(
291 cxt_id_t cxt_id,
const std::string &table_name,
292 MatchTableIndirectWS::Entry *entry)
const = 0;
294 virtual MatchErrorCode
295 mt_get_entry_from_key(cxt_id_t cxt_id,
const std::string &table_name,
296 const std::vector<MatchKeyParam> &match_key,
297 MatchTable::Entry *entry,
int priority = 1)
const = 0;
299 virtual MatchErrorCode
300 mt_indirect_get_entry_from_key(cxt_id_t cxt_id,
const std::string &table_name,
301 const std::vector<MatchKeyParam> &match_key,
302 MatchTableIndirect::Entry *entry,
303 int priority = 1)
const = 0;
305 virtual MatchErrorCode
306 mt_indirect_ws_get_entry_from_key(cxt_id_t cxt_id,
307 const std::string &table_name,
308 const std::vector<MatchKeyParam> &match_key,
309 MatchTableIndirectWS::Entry *entry,
310 int priority = 1)
const = 0;
312 virtual Counter::CounterErrorCode
313 read_counters(cxt_id_t cxt_id,
314 const std::string &counter_name,
316 MatchTableAbstract::counter_value_t *bytes,
317 MatchTableAbstract::counter_value_t *packets) = 0;
319 virtual Counter::CounterErrorCode
320 reset_counters(cxt_id_t cxt_id,
321 const std::string &counter_name) = 0;
323 virtual Counter::CounterErrorCode
324 write_counters(cxt_id_t cxt_id,
325 const std::string &counter_name,
327 MatchTableAbstract::counter_value_t bytes,
328 MatchTableAbstract::counter_value_t packets) = 0;
331 virtual MeterErrorCode
332 meter_array_set_rates(cxt_id_t cxt_id,
333 const std::string &meter_name,
334 const std::vector<Meter::rate_config_t> &configs) = 0;
336 virtual MeterErrorCode
337 meter_set_rates(cxt_id_t cxt_id,
338 const std::string &meter_name,
size_t idx,
339 const std::vector<Meter::rate_config_t> &configs) = 0;
341 virtual MeterErrorCode
342 meter_get_rates(cxt_id_t cxt_id,
343 const std::string &meter_name,
size_t idx,
344 std::vector<Meter::rate_config_t> *configs) = 0;
346 virtual MeterErrorCode
347 meter_reset_rates(cxt_id_t cxt_id,
348 const std::string &meter_name,
size_t idx) = 0;
350 virtual RegisterErrorCode
351 register_read(cxt_id_t cxt_id,
352 const std::string ®ister_name,
353 const size_t idx, Data *value) = 0;
355 virtual std::vector<Data>
356 register_read_all(cxt_id_t cxt_id,
const std::string ®ister_name) = 0;
358 virtual RegisterErrorCode
359 register_write(cxt_id_t cxt_id,
360 const std::string ®ister_name,
361 const size_t idx, Data value) = 0;
363 virtual RegisterErrorCode
364 register_write_range(cxt_id_t cxt_id,
365 const std::string ®ister_name,
366 const size_t start,
const size_t end,
369 virtual RegisterErrorCode
370 register_reset(cxt_id_t cxt_id,
const std::string ®ister_name) = 0;
372 virtual ParseVSet::ErrorCode
373 parse_vset_add(cxt_id_t cxt_id,
const std::string &parse_vset_name,
374 const ByteContainer &value) = 0;
376 virtual ParseVSet::ErrorCode
377 parse_vset_remove(cxt_id_t cxt_id,
const std::string &parse_vset_name,
378 const ByteContainer &value) = 0;
380 virtual ParseVSet::ErrorCode
381 parse_vset_get(cxt_id_t cxt_id,
const std::string &parse_vset_name,
382 std::vector<ByteContainer> *values) = 0;
384 virtual ParseVSet::ErrorCode
385 parse_vset_clear(cxt_id_t cxt_id,
const std::string &parse_vset_name) = 0;
388 load_new_config(
const std::string &new_config) = 0;
394 get_config()
const = 0;
397 get_config_md5()
const = 0;
399 virtual CustomCrcErrorCode
400 set_crc16_custom_parameters(
401 cxt_id_t cxt_id,
const std::string &calc_name,
402 const CustomCrcMgr<uint16_t>::crc_config_t &crc16_config) = 0;
404 virtual CustomCrcErrorCode
405 set_crc32_custom_parameters(
406 cxt_id_t cxt_id,
const std::string &calc_name,
407 const CustomCrcMgr<uint32_t>::crc_config_t &crc32_config) = 0;
409 virtual ToeplitzErrorCode
411 cxt_id_t cxt_id,
const std::string &calc_name,
412 const ToeplitzMgr::key_t &key) = 0;
418 serialize(std::ostream *out) = 0;
423 #endif // BM_BM_SIM_RUNTIME_INTERFACE_H_