blob: cc90bbfac88a807187dd89f4049c547283f22b1e [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001#include <bcmos_system.h>
2#include <bal_api.h>
3#include <bcmcli.h>
4#include "bal_api_cli_helpers.h"
5#include "bal_api_cli_handlers.h"
6
7bcmcli_session *bcmbal_apicli_log_session = NULL;
8
9typedef struct
10{
11 uint8_t *start;
12 uint32_t used;
13} bcmbal_apicli_byte_pool;
14
15static bcmos_errno bcmbal_apicli_byte_pool_create(bcmbal_apicli_byte_pool *buf)
16{
17 buf->used = 0;
18 buf->start = bcmos_calloc(BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
19 return (buf->start == NULL) ? BCM_ERR_NOMEM : BCM_ERR_OK;
20}
21
22static void bcmbal_apicli_byte_pool_destroy(bcmbal_apicli_byte_pool *buf)
23{
24 bcmos_free(buf->start);
25}
26
27static void *bcmbal_apicli_byte_pool_calloc(bcmbal_apicli_byte_pool *buf, uint32_t num_bytes)
28{
29 void *ret;
30 if (buf->used + num_bytes > BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE)
31 {
32 return NULL;
33 }
34
35 ret = buf->start + buf->used;
36 buf->used += num_bytes;
37 memset(ret, 0, num_bytes);
38 return ret;
39}
40
41/*
42 * Start/end banners - these are specially formatted so listening apps can easily tell where API handling starts/ends.
43 */
44static void bcmbal_apicli_print_start(bcmcli_session *session, const char *api_name)
45{
46 bcmcli_print(session, "[-- API Start: %s --]\n", api_name);
47}
48
49static void bcmbal_apicli_print_data_start(bcmcli_session *session)
50{
51 bcmcli_print(session, "[-- API Message Data --]\n");
52}
53
54static void bcmbal_apicli_print_complete(bcmcli_session *session, bcmos_errno err, const char *err_text)
55{
56 if (err != BCM_ERR_OK && err_text != NULL && err_text[0] != '\0')
57 {
58 bcmcli_print(session, "ERROR: %s", err_text);
59 }
60
61 bcmcli_print(session, "[-- API Complete: %d (%s) --]\n", err, bcmos_strerror(err));
62}
63
64static int bcmbal_apicli_session_write_cb(bcmcli_session *cli_session, const char *buf, uint32_t size)
65{
66 bcmcli_log(buf, "%.*s", size, buf);
67 return (int)size;
68}
69
70/* Logs a property value to the CLI log in such a way that it is a valid RHS in an initializer. For a primitve, this
71 * will just print the value (e.g. "42"). For a struct, it will emit all members in between curly braces. */
72static void bcmbal_apicli_log_prop_val(bcmolt_obj_id obj, bcmolt_mgt_group group, uint16_t subgroup, uint16_t prop, void *value)
73{
74 bcmos_errno err;
75 const bcmbal_apicli_prop_descr *prop_descr;
76
77 if (bcmbal_apicli_log_session == NULL)
78 {
79 static bcmcli_session_parm session_params = { .write = bcmbal_apicli_session_write_cb };
80
81 err = bcmcli_session_open(&session_params, &bcmbal_apicli_log_session);
82 if (err != BCM_ERR_OK)
83 {
84 bcmos_trace(BCMOS_TRACE_LEVEL_ERROR, "Error opening session: %s", bcmos_strerror(err));
85 return;
86 }
87 }
88
89 err = bcmbal_apicli_object_property(obj, group, subgroup, prop, &prop_descr);
90 if (err != BCM_ERR_OK)
91 {
92 bcmos_trace(BCMOS_TRACE_LEVEL_ERROR, "Error getting info for property: %s", bcmos_strerror(err));
93 return;
94 }
95
96 err = bcmbal_apicli_dump_prop_initializer(bcmbal_apicli_log_session, prop_descr, value);
97 if (err != BCM_ERR_OK)
98 {
99 bcmos_trace(BCMOS_TRACE_LEVEL_ERROR, "Error printing property: %s", bcmos_strerror(err));
100 }
101}
102
103static inline bcmos_ipv4_address bcmbal_apicli_unumber_to_ipv4(uint32_t num)
104{
105 bcmos_ipv4_address ip = { .u32 = num };
106 return ip;
107}
108
109/******************************************************************************/
110static bcmos_errno bcmbal_cli_access_terminal_cfg_get(bcmcli_session *session)
111{
112 bcmcli_cmd_parm *cli_parm;
113 bcmos_errno err;
114 bcmbal_access_terminal_cfg cfg; /**< declare main API struct */
115 bcmbal_access_terminal_key key = { }; /**< declare key */
116 bcmcli_log("bcmbal_access_terminal_cfg cfg;\n");
117 bcmcli_log("bcmbal_access_terminal_key key = { };\n");
118 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
119
120 /* init the API struct */
121 BCMBAL_CFG_INIT(&cfg, access_terminal, key);
122 bcmcli_log("BCMBAL_CFG_INIT(&cfg, access_terminal, key);\n");
123
124 /* decode API parameters from CLI */
125 cli_parm = bcmcli_find_named_parm(session, "admin_state");
126 if (cli_parm != NULL)
127 {
128 if (cli_parm->value.number)
129 {
130 BCMBAL_CFG_PROP_GET(&cfg, access_terminal, admin_state);
131 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, access_terminal, admin_state);\n");
132 }
133 }
134
135 cli_parm = bcmcli_find_named_parm(session, "oper_status");
136 if (cli_parm != NULL)
137 {
138 if (cli_parm->value.number)
139 {
140 BCMBAL_CFG_PROP_GET(&cfg, access_terminal, oper_status);
141 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, access_terminal, oper_status);\n");
142 }
143 }
144
145 cli_parm = bcmcli_find_named_parm(session, "iwf_mode");
146 if (cli_parm != NULL)
147 {
148 if (cli_parm->value.number)
149 {
150 BCMBAL_CFG_PROP_GET(&cfg, access_terminal, iwf_mode);
151 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, access_terminal, iwf_mode);\n");
152 }
153 }
154
155 /* if no properties were requested, include everything */
156 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, access_terminal, admin_state) && !BCMBAL_CFG_PROP_IS_SET(&cfg, access_terminal, oper_status) && !BCMBAL_CFG_PROP_IS_SET(&cfg, access_terminal, iwf_mode))
157 {
158 BCMBAL_CFG_PROP_GET(&cfg, access_terminal, all_properties);
159 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, access_terminal, all_properties);\n");
160 }
161
162 /* call API */
163 err = bcmbal_cfg_get(&cfg.hdr);
164 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
165 if (err == BCM_ERR_OK)
166 {
167 /* print API contents to the CLI */
168 bcmbal_apicli_print_data_start(session);
169 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
170 }
171
172 bcmbal_apicli_print_complete(session, err, NULL);
173 return err;
174}
175
176/******************************************************************************/
177static bcmos_errno bcmbal_cli_access_terminal_cfg_set(bcmcli_session *session)
178{
179 bcmcli_cmd_parm *cli_parm;
180 bcmos_errno err;
181 bcmbal_access_terminal_cfg cfg; /**< declare main API struct */
182 bcmbal_access_terminal_key key = { }; /**< declare key */
183 bcmcli_log("bcmbal_access_terminal_cfg cfg;\n");
184 bcmcli_log("bcmbal_access_terminal_key key = { };\n");
185 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
186
187 /* init the API struct */
188 BCMBAL_CFG_INIT(&cfg, access_terminal, key);
189 bcmcli_log("BCMBAL_CFG_INIT(&cfg, access_terminal, key);\n");
190
191 /* decode API parameters from CLI */
192 cli_parm = bcmcli_find_named_parm(session, "admin_state");
193 if (cli_parm != NULL)
194 {
195 bcmbal_state val;
196 val = (bcmbal_state) cli_parm->value.enum_val;
197 BCMBAL_CFG_PROP_SET(&cfg, access_terminal, admin_state, val);
198 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, access_terminal, admin_state, ");
199 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_ACCESS_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_ACCESS_TERMINAL_CFG_ID_ADMIN_STATE, &val);
200 bcmcli_log(");\n");
201 }
202
203 /* call API */
204 err = bcmbal_cfg_set(&cfg.hdr);
205 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
206 bcmbal_apicli_print_complete(session, err, NULL);
207 return err;
208}
209
210/******************************************************************************/
211static bcmos_errno bcmbal_cli_access_terminal_cfg_clear(bcmcli_session *session)
212{
213 bcmos_errno err;
214 bcmbal_access_terminal_cfg cfg; /**< declare main API struct */
215 bcmbal_access_terminal_key key = { }; /**< declare key */
216 bcmcli_log("bcmbal_access_terminal_cfg cfg;\n");
217 bcmcli_log("bcmbal_access_terminal_key key = { };\n");
218 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
219
220 /* init the API struct */
221 BCMBAL_CFG_INIT(&cfg, access_terminal, key);
222 bcmcli_log("BCMBAL_CFG_INIT(&cfg, access_terminal, key);\n");
223
224 /* call API */
225 err = bcmbal_cfg_clear(&cfg.hdr);
226 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
227 bcmbal_apicli_print_complete(session, err, NULL);
228 return err;
229}
230
231/******************************************************************************/
232static bcmos_errno bcmbal_cli_flow_cfg_get(bcmcli_session *session)
233{
234 bcmcli_cmd_parm *cli_parm;
235 bcmos_errno err;
236 bcmbal_flow_cfg cfg; /**< declare main API struct */
237 bcmbal_flow_key key = { }; /**< declare key */
238 bcmcli_log("bcmbal_flow_cfg cfg;\n");
239 bcmcli_log("bcmbal_flow_key key = { };\n");
240 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
241
242 /* build key from CLI parameters */
243 cli_parm = bcmcli_find_named_parm(session, "flow_id");
244 if (cli_parm != NULL)
245 {
246 key.flow_id = (bcmbal_flow_id) cli_parm->value.unumber;
247 }
248 else
249 {
250 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_id is not set\n");
251 return BCM_ERR_PARM;
252 }
253
254 bcmcli_log("key.flow_id = ");
255 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_ID, &key.flow_id);
256 bcmcli_log(";\n");
257 cli_parm = bcmcli_find_named_parm(session, "flow_type");
258 if (cli_parm != NULL)
259 {
260 key.flow_type = (bcmbal_flow_type) cli_parm->value.enum_val;
261 }
262 else
263 {
264 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_type is not set\n");
265 return BCM_ERR_PARM;
266 }
267
268 bcmcli_log("key.flow_type = ");
269 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_TYPE, &key.flow_type);
270 bcmcli_log(";\n");
271
272 /* init the API struct */
273 BCMBAL_CFG_INIT(&cfg, flow, key);
274 bcmcli_log("BCMBAL_CFG_INIT(&cfg, flow, key);\n");
275
276 /* decode API parameters from CLI */
277 cli_parm = bcmcli_find_named_parm(session, "admin_state");
278 if (cli_parm != NULL)
279 {
280 if (cli_parm->value.number)
281 {
282 BCMBAL_CFG_PROP_GET(&cfg, flow, admin_state);
283 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, admin_state);\n");
284 }
285 }
286
287 cli_parm = bcmcli_find_named_parm(session, "oper_status");
288 if (cli_parm != NULL)
289 {
290 if (cli_parm->value.number)
291 {
292 BCMBAL_CFG_PROP_GET(&cfg, flow, oper_status);
293 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, oper_status);\n");
294 }
295 }
296
297 cli_parm = bcmcli_find_named_parm(session, "access_int_id");
298 if (cli_parm != NULL)
299 {
300 if (cli_parm->value.number)
301 {
302 BCMBAL_CFG_PROP_GET(&cfg, flow, access_int_id);
303 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, access_int_id);\n");
304 }
305 }
306
307 cli_parm = bcmcli_find_named_parm(session, "network_int_id");
308 if (cli_parm != NULL)
309 {
310 if (cli_parm->value.number)
311 {
312 BCMBAL_CFG_PROP_GET(&cfg, flow, network_int_id);
313 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, network_int_id);\n");
314 }
315 }
316
317 cli_parm = bcmcli_find_named_parm(session, "sub_term_id");
318 if (cli_parm != NULL)
319 {
320 if (cli_parm->value.number)
321 {
322 BCMBAL_CFG_PROP_GET(&cfg, flow, sub_term_id);
323 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, sub_term_id);\n");
324 }
325 }
326
327 cli_parm = bcmcli_find_named_parm(session, "sub_term_uni_idx");
328 if (cli_parm != NULL)
329 {
330 if (cli_parm->value.number)
331 {
332 BCMBAL_CFG_PROP_GET(&cfg, flow, sub_term_uni_idx);
333 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, sub_term_uni_idx);\n");
334 }
335 }
336
337 cli_parm = bcmcli_find_named_parm(session, "svc_port_id");
338 if (cli_parm != NULL)
339 {
340 if (cli_parm->value.number)
341 {
342 BCMBAL_CFG_PROP_GET(&cfg, flow, svc_port_id);
343 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, svc_port_id);\n");
344 }
345 }
346
347 cli_parm = bcmcli_find_named_parm(session, "agg_port_id");
348 if (cli_parm != NULL)
349 {
350 if (cli_parm->value.number)
351 {
352 BCMBAL_CFG_PROP_GET(&cfg, flow, agg_port_id);
353 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, agg_port_id);\n");
354 }
355 }
356
357 cli_parm = bcmcli_find_named_parm(session, "resolve_mac");
358 if (cli_parm != NULL)
359 {
360 if (cli_parm->value.number)
361 {
362 BCMBAL_CFG_PROP_GET(&cfg, flow, resolve_mac);
363 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, resolve_mac);\n");
364 }
365 }
366
367 cli_parm = bcmcli_find_named_parm(session, "classifier");
368 if (cli_parm != NULL)
369 {
370 if (cli_parm->value.number)
371 {
372 BCMBAL_CFG_PROP_GET(&cfg, flow, classifier);
373 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, classifier);\n");
374 }
375 }
376
377 cli_parm = bcmcli_find_named_parm(session, "action");
378 if (cli_parm != NULL)
379 {
380 if (cli_parm->value.number)
381 {
382 BCMBAL_CFG_PROP_GET(&cfg, flow, action);
383 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, action);\n");
384 }
385 }
386
387 cli_parm = bcmcli_find_named_parm(session, "sla");
388 if (cli_parm != NULL)
389 {
390 if (cli_parm->value.number)
391 {
392 BCMBAL_CFG_PROP_GET(&cfg, flow, sla);
393 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, sla);\n");
394 }
395 }
396
397 cli_parm = bcmcli_find_named_parm(session, "cookie");
398 if (cli_parm != NULL)
399 {
400 if (cli_parm->value.number)
401 {
402 BCMBAL_CFG_PROP_GET(&cfg, flow, cookie);
403 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, cookie);\n");
404 }
405 }
406
407 cli_parm = bcmcli_find_named_parm(session, "priority");
408 if (cli_parm != NULL)
409 {
410 if (cli_parm->value.number)
411 {
412 BCMBAL_CFG_PROP_GET(&cfg, flow, priority);
413 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, priority);\n");
414 }
415 }
416
417 cli_parm = bcmcli_find_named_parm(session, "group_id");
418 if (cli_parm != NULL)
419 {
420 if (cli_parm->value.number)
421 {
422 BCMBAL_CFG_PROP_GET(&cfg, flow, group_id);
423 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, group_id);\n");
424 }
425 }
426
427 cli_parm = bcmcli_find_named_parm(session, "queue");
428 if (cli_parm != NULL)
429 {
430 if (cli_parm->value.number)
431 {
432 BCMBAL_CFG_PROP_GET(&cfg, flow, queue);
433 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, queue);\n");
434 }
435 }
436
437 /* if no properties were requested, include everything */
438 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, flow, admin_state) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, oper_status) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, access_int_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, network_int_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, sub_term_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, sub_term_uni_idx) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, svc_port_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, agg_port_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, resolve_mac) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, classifier) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, action) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, sla) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, cookie) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, priority) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, group_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, flow, queue))
439 {
440 BCMBAL_CFG_PROP_GET(&cfg, flow, all_properties);
441 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, flow, all_properties);\n");
442 }
443
444 /* call API */
445 err = bcmbal_cfg_get(&cfg.hdr);
446 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
447 if (err == BCM_ERR_OK)
448 {
449 /* print API contents to the CLI */
450 bcmbal_apicli_print_data_start(session);
451 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
452 }
453
454 bcmbal_apicli_print_complete(session, err, NULL);
455 return err;
456}
457
458/******************************************************************************/
459static bcmos_errno bcmbal_cli_flow_cfg_set(bcmcli_session *session)
460{
461 bcmcli_cmd_parm *cli_parm;
462 bcmos_errno err;
463 bcmbal_flow_cfg cfg; /**< declare main API struct */
464 bcmbal_flow_key key = { }; /**< declare key */
465 bcmcli_log("bcmbal_flow_cfg cfg;\n");
466 bcmcli_log("bcmbal_flow_key key = { };\n");
467 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
468
469 /* build key from CLI parameters */
470 cli_parm = bcmcli_find_named_parm(session, "flow_id");
471 if (cli_parm != NULL)
472 {
473 key.flow_id = (bcmbal_flow_id) cli_parm->value.unumber;
474 }
475 else
476 {
477 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_id is not set\n");
478 return BCM_ERR_PARM;
479 }
480
481 bcmcli_log("key.flow_id = ");
482 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_ID, &key.flow_id);
483 bcmcli_log(";\n");
484 cli_parm = bcmcli_find_named_parm(session, "flow_type");
485 if (cli_parm != NULL)
486 {
487 key.flow_type = (bcmbal_flow_type) cli_parm->value.enum_val;
488 }
489 else
490 {
491 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_type is not set\n");
492 return BCM_ERR_PARM;
493 }
494
495 bcmcli_log("key.flow_type = ");
496 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_TYPE, &key.flow_type);
497 bcmcli_log(";\n");
498
499 /* init the API struct */
500 BCMBAL_CFG_INIT(&cfg, flow, key);
501 bcmcli_log("BCMBAL_CFG_INIT(&cfg, flow, key);\n");
502
503 /* decode API parameters from CLI */
504 cli_parm = bcmcli_find_named_parm(session, "admin_state");
505 if (cli_parm != NULL)
506 {
507 bcmbal_state val;
508 val = (bcmbal_state) cli_parm->value.enum_val;
509 BCMBAL_CFG_PROP_SET(&cfg, flow, admin_state, val);
510 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, admin_state, ");
511 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_ADMIN_STATE, &val);
512 bcmcli_log(");\n");
513 }
514
515 cli_parm = bcmcli_find_named_parm(session, "access_int_id");
516 if (cli_parm != NULL)
517 {
518 bcmbal_intf_id val;
519 val = (bcmbal_intf_id) cli_parm->value.unumber;
520 BCMBAL_CFG_PROP_SET(&cfg, flow, access_int_id, val);
521 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, access_int_id, ");
522 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_ACCESS_INT_ID, &val);
523 bcmcli_log(");\n");
524 }
525
526 cli_parm = bcmcli_find_named_parm(session, "network_int_id");
527 if (cli_parm != NULL)
528 {
529 bcmbal_intf_id val;
530 val = (bcmbal_intf_id) cli_parm->value.unumber;
531 BCMBAL_CFG_PROP_SET(&cfg, flow, network_int_id, val);
532 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, network_int_id, ");
533 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_NETWORK_INT_ID, &val);
534 bcmcli_log(");\n");
535 }
536
537 cli_parm = bcmcli_find_named_parm(session, "sub_term_id");
538 if (cli_parm != NULL)
539 {
540 bcmbal_sub_id val;
541 val = (bcmbal_sub_id) cli_parm->value.unumber;
542 BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_id, val);
543 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_id, ");
544 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_SUB_TERM_ID, &val);
545 bcmcli_log(");\n");
546 }
547
548 cli_parm = bcmcli_find_named_parm(session, "sub_term_uni_idx");
549 if (cli_parm != NULL)
550 {
551 uint8_t val;
552 val = cli_parm->value.unumber;
553 BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_uni_idx, val);
554 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_uni_idx, ");
555 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_SUB_TERM_UNI_IDX, &val);
556 bcmcli_log(");\n");
557 }
558
559 cli_parm = bcmcli_find_named_parm(session, "svc_port_id");
560 if (cli_parm != NULL)
561 {
562 bcmbal_service_port_id val;
563 val = (bcmbal_service_port_id) cli_parm->value.unumber;
564 BCMBAL_CFG_PROP_SET(&cfg, flow, svc_port_id, val);
565 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, svc_port_id, ");
566 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_SVC_PORT_ID, &val);
567 bcmcli_log(");\n");
568 }
569
570 cli_parm = bcmcli_find_named_parm(session, "agg_port_id");
571 if (cli_parm != NULL)
572 {
573 bcmbal_aggregation_port_id val;
574 val = (bcmbal_aggregation_port_id) cli_parm->value.unumber;
575 BCMBAL_CFG_PROP_SET(&cfg, flow, agg_port_id, val);
576 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, agg_port_id, ");
577 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_AGG_PORT_ID, &val);
578 bcmcli_log(");\n");
579 }
580
581 cli_parm = bcmcli_find_named_parm(session, "resolve_mac");
582 if (cli_parm != NULL)
583 {
584 bcmos_bool val;
585 val = cli_parm->value.number;
586 BCMBAL_CFG_PROP_SET(&cfg, flow, resolve_mac, val);
587 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, resolve_mac, ");
588 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_RESOLVE_MAC, &val);
589 bcmcli_log(");\n");
590 }
591
592 cli_parm = bcmcli_find_parm_by_prefix(session, "classifier.");
593 if (cli_parm != NULL)
594 {
595 bcmbal_classifier val = { };
596 cli_parm = bcmcli_find_named_parm(session, "classifier.o_tpid");
597 if (cli_parm != NULL)
598 {
599 val.o_tpid = cli_parm->value.unumber;
600 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_O_TPID;
601 }
602
603 cli_parm = bcmcli_find_named_parm(session, "classifier.o_vid");
604 if (cli_parm != NULL)
605 {
606 val.o_vid = cli_parm->value.unumber;
607 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_O_VID;
608 }
609
610 cli_parm = bcmcli_find_named_parm(session, "classifier.i_tpid");
611 if (cli_parm != NULL)
612 {
613 val.i_tpid = cli_parm->value.unumber;
614 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_I_TPID;
615 }
616
617 cli_parm = bcmcli_find_named_parm(session, "classifier.i_vid");
618 if (cli_parm != NULL)
619 {
620 val.i_vid = cli_parm->value.unumber;
621 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_I_VID;
622 }
623
624 cli_parm = bcmcli_find_named_parm(session, "classifier.o_pbits");
625 if (cli_parm != NULL)
626 {
627 val.o_pbits = cli_parm->value.unumber;
628 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_O_PBITS;
629 }
630
631 cli_parm = bcmcli_find_named_parm(session, "classifier.i_pbits");
632 if (cli_parm != NULL)
633 {
634 val.i_pbits = cli_parm->value.unumber;
635 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_I_PBITS;
636 }
637
638 cli_parm = bcmcli_find_named_parm(session, "classifier.ether_type");
639 if (cli_parm != NULL)
640 {
641 val.ether_type = cli_parm->value.unumber;
642 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_ETHER_TYPE;
643 }
644
645 cli_parm = bcmcli_find_named_parm(session, "classifier.dst_mac");
646 if (cli_parm != NULL)
647 {
648 val.dst_mac = cli_parm->value.mac;
649 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_DST_MAC;
650 }
651
652 cli_parm = bcmcli_find_named_parm(session, "classifier.src_mac");
653 if (cli_parm != NULL)
654 {
655 val.src_mac = cli_parm->value.mac;
656 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_SRC_MAC;
657 }
658
659 cli_parm = bcmcli_find_named_parm(session, "classifier.ip_proto");
660 if (cli_parm != NULL)
661 {
662 val.ip_proto = cli_parm->value.unumber;
663 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_IP_PROTO;
664 }
665
666 cli_parm = bcmcli_find_named_parm(session, "classifier.dst_ip");
667 if (cli_parm != NULL)
668 {
669 val.dst_ip = bcmbal_apicli_unumber_to_ipv4(cli_parm->value.unumber);
670 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_DST_IP;
671 }
672
673 cli_parm = bcmcli_find_named_parm(session, "classifier.src_ip");
674 if (cli_parm != NULL)
675 {
676 val.src_ip = bcmbal_apicli_unumber_to_ipv4(cli_parm->value.unumber);
677 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_SRC_IP;
678 }
679
680 cli_parm = bcmcli_find_named_parm(session, "classifier.src_port");
681 if (cli_parm != NULL)
682 {
683 val.src_port = cli_parm->value.unumber;
684 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_SRC_PORT;
685 }
686
687 cli_parm = bcmcli_find_named_parm(session, "classifier.dst_port");
688 if (cli_parm != NULL)
689 {
690 val.dst_port = cli_parm->value.unumber;
691 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_DST_PORT;
692 }
693
694 cli_parm = bcmcli_find_named_parm(session, "classifier.pkt_tag_type");
695 if (cli_parm != NULL)
696 {
697 val.pkt_tag_type = (bcmbal_pkt_tag_type) cli_parm->value.enum_val;
698 val.presence_mask = val.presence_mask | BCMBAL_CLASSIFIER_ID_PKT_TAG_TYPE;
699 }
700
701 BCMBAL_CFG_PROP_SET(&cfg, flow, classifier, val);
702 bcmcli_log("{\n");
703 bcmcli_log("bcmbal_classifier val = ");
704 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_CLASSIFIER, &val);
705 bcmcli_log(";\n");
706 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, classifier, val);\n");
707 bcmcli_log("}\n");
708 }
709
710 cli_parm = bcmcli_find_parm_by_prefix(session, "action.");
711 if (cli_parm != NULL)
712 {
713 bcmbal_action val = { };
714 cli_parm = bcmcli_find_named_parm(session, "action.cmds_bitmask");
715 if (cli_parm != NULL)
716 {
717 val.cmds_bitmask = (bcmbal_action_cmd_id) cli_parm->value.enum_val;
718 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_CMDS_BITMASK;
719 }
720
721 cli_parm = bcmcli_find_named_parm(session, "action.o_vid");
722 if (cli_parm != NULL)
723 {
724 val.o_vid = cli_parm->value.unumber;
725 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_O_VID;
726 }
727
728 cli_parm = bcmcli_find_named_parm(session, "action.o_pbits");
729 if (cli_parm != NULL)
730 {
731 val.o_pbits = cli_parm->value.unumber;
732 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_O_PBITS;
733 }
734
735 cli_parm = bcmcli_find_named_parm(session, "action.o_tpid");
736 if (cli_parm != NULL)
737 {
738 val.o_tpid = cli_parm->value.unumber;
739 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_O_TPID;
740 }
741
742 cli_parm = bcmcli_find_named_parm(session, "action.i_vid");
743 if (cli_parm != NULL)
744 {
745 val.i_vid = cli_parm->value.unumber;
746 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_I_VID;
747 }
748
749 cli_parm = bcmcli_find_named_parm(session, "action.i_pbits");
750 if (cli_parm != NULL)
751 {
752 val.i_pbits = cli_parm->value.unumber;
753 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_I_PBITS;
754 }
755
756 cli_parm = bcmcli_find_named_parm(session, "action.i_tpid");
757 if (cli_parm != NULL)
758 {
759 val.i_tpid = cli_parm->value.unumber;
760 val.presence_mask = val.presence_mask | BCMBAL_ACTION_ID_I_TPID;
761 }
762
763 BCMBAL_CFG_PROP_SET(&cfg, flow, action, val);
764 bcmcli_log("{\n");
765 bcmcli_log("bcmbal_action val = ");
766 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_ACTION, &val);
767 bcmcli_log(";\n");
768 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, action, val);\n");
769 bcmcli_log("}\n");
770 }
771
772 cli_parm = bcmcli_find_parm_by_prefix(session, "sla.");
773 if (cli_parm != NULL)
774 {
775 bcmbal_sla val = { };
776 cli_parm = bcmcli_find_named_parm(session, "sla.min_rate");
777 if (cli_parm != NULL)
778 {
779 val.min_rate = cli_parm->value.unumber;
780 val.presence_mask = val.presence_mask | BCMBAL_SLA_ID_MIN_RATE;
781 }
782
783 cli_parm = bcmcli_find_named_parm(session, "sla.max_rate");
784 if (cli_parm != NULL)
785 {
786 val.max_rate = cli_parm->value.unumber;
787 val.presence_mask = val.presence_mask | BCMBAL_SLA_ID_MAX_RATE;
788 }
789
790 BCMBAL_CFG_PROP_SET(&cfg, flow, sla, val);
791 bcmcli_log("{\n");
792 bcmcli_log("bcmbal_sla val = ");
793 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_SLA, &val);
794 bcmcli_log(";\n");
795 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, sla, val);\n");
796 bcmcli_log("}\n");
797 }
798
799 cli_parm = bcmcli_find_named_parm(session, "cookie");
800 if (cli_parm != NULL)
801 {
802 bcmbal_cookie val;
803 val = (bcmbal_cookie) cli_parm->value.unumber64;
804 BCMBAL_CFG_PROP_SET(&cfg, flow, cookie, val);
805 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, cookie, ");
806 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_COOKIE, &val);
807 bcmcli_log(");\n");
808 }
809
810 cli_parm = bcmcli_find_named_parm(session, "priority");
811 if (cli_parm != NULL)
812 {
813 uint16_t val;
814 val = cli_parm->value.unumber;
815 BCMBAL_CFG_PROP_SET(&cfg, flow, priority, val);
816 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, priority, ");
817 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_PRIORITY, &val);
818 bcmcli_log(");\n");
819 }
820
821 cli_parm = bcmcli_find_named_parm(session, "group_id");
822 if (cli_parm != NULL)
823 {
824 bcmbal_group_id val;
825 val = (bcmbal_group_id) cli_parm->value.unumber;
826 BCMBAL_CFG_PROP_SET(&cfg, flow, group_id, val);
827 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, group_id, ");
828 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_GROUP_ID, &val);
829 bcmcli_log(");\n");
830 }
831
832 cli_parm = bcmcli_find_parm_by_prefix(session, "queue.");
833 if (cli_parm != NULL)
834 {
835 bcmbal_tm_queue_ref val = { };
836 cli_parm = bcmcli_find_named_parm(session, "queue.sched_id");
837 if (cli_parm != NULL)
838 {
839 val.sched_id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
840 }
841 else
842 {
843 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "queue.sched_id is not set\n");
844 return BCM_ERR_PARM;
845 }
846
847 cli_parm = bcmcli_find_named_parm(session, "queue.queue_id");
848 if (cli_parm != NULL)
849 {
850 val.queue_id = (bcmbal_tm_queue_id) cli_parm->value.unumber;
851 }
852 else
853 {
854 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "queue.queue_id is not set\n");
855 return BCM_ERR_PARM;
856 }
857
858 BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val);
859 bcmcli_log("{\n");
860 bcmcli_log("bcmbal_tm_queue_ref val = ");
861 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_FLOW_CFG_ID_QUEUE, &val);
862 bcmcli_log(";\n");
863 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val);\n");
864 bcmcli_log("}\n");
865 }
866
867 /* call API */
868 err = bcmbal_cfg_set(&cfg.hdr);
869 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
870 bcmbal_apicli_print_complete(session, err, NULL);
871 return err;
872}
873
874/******************************************************************************/
875static bcmos_errno bcmbal_cli_flow_cfg_clear(bcmcli_session *session)
876{
877 bcmcli_cmd_parm *cli_parm;
878 bcmos_errno err;
879 bcmbal_flow_cfg cfg; /**< declare main API struct */
880 bcmbal_flow_key key = { }; /**< declare key */
881 bcmcli_log("bcmbal_flow_cfg cfg;\n");
882 bcmcli_log("bcmbal_flow_key key = { };\n");
883 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
884
885 /* build key from CLI parameters */
886 cli_parm = bcmcli_find_named_parm(session, "flow_id");
887 if (cli_parm != NULL)
888 {
889 key.flow_id = (bcmbal_flow_id) cli_parm->value.unumber;
890 }
891 else
892 {
893 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_id is not set\n");
894 return BCM_ERR_PARM;
895 }
896
897 bcmcli_log("key.flow_id = ");
898 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_ID, &key.flow_id);
899 bcmcli_log(";\n");
900 cli_parm = bcmcli_find_named_parm(session, "flow_type");
901 if (cli_parm != NULL)
902 {
903 key.flow_type = (bcmbal_flow_type) cli_parm->value.enum_val;
904 }
905 else
906 {
907 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_type is not set\n");
908 return BCM_ERR_PARM;
909 }
910
911 bcmcli_log("key.flow_type = ");
912 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_TYPE, &key.flow_type);
913 bcmcli_log(";\n");
914
915 /* init the API struct */
916 BCMBAL_CFG_INIT(&cfg, flow, key);
917 bcmcli_log("BCMBAL_CFG_INIT(&cfg, flow, key);\n");
918
919 /* call API */
920 err = bcmbal_cfg_clear(&cfg.hdr);
921 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
922 bcmbal_apicli_print_complete(session, err, NULL);
923 return err;
924}
925
926/******************************************************************************/
927static bcmos_errno bcmbal_cli_flow_stat_get(bcmcli_session *session)
928{
929 bcmcli_cmd_parm *cli_parm;
930 bcmos_errno err;
931 bcmbal_flow_stat stat; /**< declare main API struct */
932 bcmbal_flow_key key = { }; /**< declare key */
933 bcmcli_log("bcmbal_flow_stat stat;\n");
934 bcmcli_log("bcmbal_flow_key key = { };\n");
935 bcmbal_apicli_print_start(session, "bcmbal_stat_get");
936
937 /* build key from CLI parameters */
938 cli_parm = bcmcli_find_named_parm(session, "flow_id");
939 if (cli_parm != NULL)
940 {
941 key.flow_id = (bcmbal_flow_id) cli_parm->value.unumber;
942 }
943 else
944 {
945 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_id is not set\n");
946 return BCM_ERR_PARM;
947 }
948
949 bcmcli_log("key.flow_id = ");
950 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_ID, &key.flow_id);
951 bcmcli_log(";\n");
952 cli_parm = bcmcli_find_named_parm(session, "flow_type");
953 if (cli_parm != NULL)
954 {
955 key.flow_type = (bcmbal_flow_type) cli_parm->value.enum_val;
956 }
957 else
958 {
959 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "flow_type is not set\n");
960 return BCM_ERR_PARM;
961 }
962
963 bcmcli_log("key.flow_type = ");
964 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_FLOW, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_FLOW_KEY_ID_FLOW_TYPE, &key.flow_type);
965 bcmcli_log(";\n");
966
967 /* init the API struct */
968 BCMBAL_STAT_INIT(&stat, flow, key);
969 bcmcli_log("BCMBAL_STAT_INIT(&stat, flow, key);\n");
970
971 /* decode API parameters from CLI */
972 cli_parm = bcmcli_find_named_parm(session, "rx_packets");
973 if (cli_parm != NULL)
974 {
975 if (cli_parm->value.number)
976 {
977 BCMBAL_STAT_PROP_GET(&stat, flow, rx_packets);
978 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, flow, rx_packets);\n");
979 }
980 }
981
982 cli_parm = bcmcli_find_named_parm(session, "rx_bytes");
983 if (cli_parm != NULL)
984 {
985 if (cli_parm->value.number)
986 {
987 BCMBAL_STAT_PROP_GET(&stat, flow, rx_bytes);
988 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, flow, rx_bytes);\n");
989 }
990 }
991
992 cli_parm = bcmcli_find_named_parm(session, "tx_packets");
993 if (cli_parm != NULL)
994 {
995 if (cli_parm->value.number)
996 {
997 BCMBAL_STAT_PROP_GET(&stat, flow, tx_packets);
998 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, flow, tx_packets);\n");
999 }
1000 }
1001
1002 cli_parm = bcmcli_find_named_parm(session, "tx_bytes");
1003 if (cli_parm != NULL)
1004 {
1005 if (cli_parm->value.number)
1006 {
1007 BCMBAL_STAT_PROP_GET(&stat, flow, tx_bytes);
1008 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, flow, tx_bytes);\n");
1009 }
1010 }
1011
1012 /* if no properties were requested, include everything */
1013 if (!BCMBAL_STAT_PROP_IS_SET(&stat, flow, rx_packets) && !BCMBAL_STAT_PROP_IS_SET(&stat, flow, rx_bytes) && !BCMBAL_STAT_PROP_IS_SET(&stat, flow, tx_packets) && !BCMBAL_STAT_PROP_IS_SET(&stat, flow, tx_bytes))
1014 {
1015 BCMBAL_STAT_PROP_GET(&stat, flow, all_properties);
1016 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, flow, all_properties);\n");
1017 }
1018
1019 /* call API */
1020 err = bcmbal_stat_get(&stat.hdr);
1021 bcmcli_log("bcmbal_stat_get(&stat.hdr);\n");
1022 if (err == BCM_ERR_OK)
1023 {
1024 /* print API contents to the CLI */
1025 bcmbal_apicli_print_data_start(session);
1026 err = bcmbal_apicli_msg_dump(session, &stat.hdr.hdr);
1027 }
1028
1029 bcmbal_apicli_print_complete(session, err, NULL);
1030 return err;
1031}
1032
1033/******************************************************************************/
1034static bcmos_errno bcmbal_cli_group_cfg_get(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
1035{
1036 bcmcli_cmd_parm *cli_parm;
1037 bcmos_errno err;
1038 bcmbal_group_cfg cfg; /**< declare main API struct */
1039 bcmbal_group_key key = { }; /**< declare key */
1040 uint8_t *list_mem; /**< declare memory buffer for variable-sized lists */
1041 bcmcli_log("bcmbal_group_cfg cfg;\n");
1042 bcmcli_log("bcmbal_group_key key = { };\n");
1043 bcmcli_log("uint8_t* list_mem;\n");
1044 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
1045
1046 /* build key from CLI parameters */
1047 cli_parm = bcmcli_find_named_parm(session, "group_id");
1048 if (cli_parm != NULL)
1049 {
1050 key.group_id = (bcmbal_group_id) cli_parm->value.unumber;
1051 }
1052 else
1053 {
1054 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "group_id is not set\n");
1055 return BCM_ERR_PARM;
1056 }
1057
1058 bcmcli_log("key.group_id = ");
1059 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_GROUP, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_GROUP_KEY_ID_GROUP_ID, &key.group_id);
1060 bcmcli_log(";\n");
1061
1062 /* init the API struct */
1063 BCMBAL_CFG_INIT(&cfg, group, key);
1064 bcmcli_log("BCMBAL_CFG_INIT(&cfg, group, key);\n");
1065
1066 /* decode API parameters from CLI */
1067 cli_parm = bcmcli_find_named_parm(session, "members_cmd");
1068 if (cli_parm != NULL)
1069 {
1070 if (cli_parm->value.number)
1071 {
1072 BCMBAL_CFG_PROP_GET(&cfg, group, members_cmd);
1073 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, group, members_cmd);\n");
1074 }
1075 }
1076
1077 cli_parm = bcmcli_find_named_parm(session, "members");
1078 if (cli_parm != NULL)
1079 {
1080 if (cli_parm->value.number)
1081 {
1082 BCMBAL_CFG_PROP_GET(&cfg, group, members);
1083 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, group, members);\n");
1084 }
1085 }
1086
1087 cli_parm = bcmcli_find_named_parm(session, "cookie");
1088 if (cli_parm != NULL)
1089 {
1090 if (cli_parm->value.number)
1091 {
1092 BCMBAL_CFG_PROP_GET(&cfg, group, cookie);
1093 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, group, cookie);\n");
1094 }
1095 }
1096
1097 cli_parm = bcmcli_find_named_parm(session, "flows");
1098 if (cli_parm != NULL)
1099 {
1100 if (cli_parm->value.number)
1101 {
1102 BCMBAL_CFG_PROP_GET(&cfg, group, flows);
1103 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, group, flows);\n");
1104 }
1105 }
1106
1107 cli_parm = bcmcli_find_named_parm(session, "owner");
1108 if (cli_parm != NULL)
1109 {
1110 if (cli_parm->value.number)
1111 {
1112 BCMBAL_CFG_PROP_GET(&cfg, group, owner);
1113 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, group, owner);\n");
1114 }
1115 }
1116
1117 /* if no properties were requested, include everything */
1118 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, group, members_cmd) && !BCMBAL_CFG_PROP_IS_SET(&cfg, group, members) && !BCMBAL_CFG_PROP_IS_SET(&cfg, group, cookie) && !BCMBAL_CFG_PROP_IS_SET(&cfg, group, flows) && !BCMBAL_CFG_PROP_IS_SET(&cfg, group, owner))
1119 {
1120 BCMBAL_CFG_PROP_GET(&cfg, group, all_properties);
1121 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, group, all_properties);\n");
1122 }
1123
1124 /* set memory to use for variable-sized lists */
1125 list_mem = bcmbal_apicli_byte_pool_calloc(byte_pool, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
1126 if (list_mem == NULL)
1127 {
1128 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
1129 return BCM_ERR_NOMEM;
1130 }
1131
1132 bcmcli_log("list_mem = bcmos_calloc(BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
1133 BCMBAL_CFG_LIST_BUF_SET(&cfg, group, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
1134 bcmcli_log("BCMBAL_CFG_LIST_BUF_SET(&cfg, group, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
1135
1136 /* call API */
1137 err = bcmbal_cfg_get(&cfg.hdr);
1138 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
1139 if (err == BCM_ERR_OK)
1140 {
1141 /* print API contents to the CLI */
1142 bcmbal_apicli_print_data_start(session);
1143 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
1144 }
1145
1146 bcmbal_apicli_print_complete(session, err, NULL);
1147 return err;
1148}
1149
1150/******************************************************************************/
1151static bcmos_errno bcmbal_cli_group_cfg_set(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
1152{
1153 bcmcli_cmd_parm *cli_parm;
1154 bcmos_errno err;
1155 bcmbal_group_cfg cfg; /**< declare main API struct */
1156 bcmbal_group_key key = { }; /**< declare key */
1157 bcmcli_log("bcmbal_group_cfg cfg;\n");
1158 bcmcli_log("bcmbal_group_key key = { };\n");
1159 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
1160
1161 /* build key from CLI parameters */
1162 cli_parm = bcmcli_find_named_parm(session, "group_id");
1163 if (cli_parm != NULL)
1164 {
1165 key.group_id = (bcmbal_group_id) cli_parm->value.unumber;
1166 }
1167 else
1168 {
1169 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "group_id is not set\n");
1170 return BCM_ERR_PARM;
1171 }
1172
1173 bcmcli_log("key.group_id = ");
1174 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_GROUP, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_GROUP_KEY_ID_GROUP_ID, &key.group_id);
1175 bcmcli_log(";\n");
1176
1177 /* init the API struct */
1178 BCMBAL_CFG_INIT(&cfg, group, key);
1179 bcmcli_log("BCMBAL_CFG_INIT(&cfg, group, key);\n");
1180
1181 /* decode API parameters from CLI */
1182 cli_parm = bcmcli_find_named_parm(session, "members_cmd");
1183 if (cli_parm != NULL)
1184 {
1185 bcmbal_group_member_cmd val;
1186 val = (bcmbal_group_member_cmd) cli_parm->value.enum_val;
1187 BCMBAL_CFG_PROP_SET(&cfg, group, members_cmd, val);
1188 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, group, members_cmd, ");
1189 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_GROUP, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_GROUP_CFG_ID_MEMBERS_CMD, &val);
1190 bcmcli_log(");\n");
1191 }
1192
1193 cli_parm = bcmcli_find_parm_by_prefix(session, "members.");
1194 if (cli_parm != NULL)
1195 {
1196 bcmbal_group_member_info_list_u16 val = { };
1197 int32_t i0;
1198 val.val = bcmbal_apicli_byte_pool_calloc(byte_pool, cli_parm->array_size * sizeof(*val.val));
1199 if (val.val == NULL)
1200 {
1201 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
1202 return BCM_ERR_NOMEM;
1203 }
1204
1205 val.len = cli_parm->array_size;
1206 cli_parm = bcmcli_find_named_parm(session, "members.intf_id");
1207 if (cli_parm != NULL)
1208 {
1209 if (cli_parm->array_size != val.len)
1210 {
1211 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.intf_id is a different size than other arrays in the struct\n");
1212 return BCM_ERR_PARM;
1213 }
1214
1215 for (i0 = 0; i0 < val.len; i0++)
1216 {
1217 val.val[i0].intf_id = (bcmbal_intf_id) cli_parm->values[i0].unumber;
1218 }
1219 }
1220
1221 cli_parm = bcmcli_find_named_parm(session, "members.svc_port_id");
1222 if (cli_parm != NULL)
1223 {
1224 if (cli_parm->array_size != val.len)
1225 {
1226 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.svc_port_id is a different size than other arrays in the struct\n");
1227 return BCM_ERR_PARM;
1228 }
1229
1230 for (i0 = 0; i0 < val.len; i0++)
1231 {
1232 val.val[i0].svc_port_id = (bcmbal_service_port_id) cli_parm->values[i0].unumber;
1233 }
1234 }
1235
1236 cli_parm = bcmcli_find_named_parm(session, "members.action.cmds_bitmask");
1237 if (cli_parm != NULL)
1238 {
1239 if (cli_parm->array_size != val.len)
1240 {
1241 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.cmds_bitmask is a different size than other arrays in the struct\n");
1242 return BCM_ERR_PARM;
1243 }
1244
1245 for (i0 = 0; i0 < val.len; i0++)
1246 {
1247 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1248 {
1249 val.val[i0].action.cmds_bitmask = (bcmbal_action_cmd_id) cli_parm->values[i0].enum_val;
1250 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_CMDS_BITMASK;
1251 }
1252 }
1253 }
1254
1255 cli_parm = bcmcli_find_named_parm(session, "members.action.o_vid");
1256 if (cli_parm != NULL)
1257 {
1258 if (cli_parm->array_size != val.len)
1259 {
1260 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.o_vid is a different size than other arrays in the struct\n");
1261 return BCM_ERR_PARM;
1262 }
1263
1264 for (i0 = 0; i0 < val.len; i0++)
1265 {
1266 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1267 {
1268 val.val[i0].action.o_vid = cli_parm->values[i0].unumber;
1269 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_O_VID;
1270 }
1271 }
1272 }
1273
1274 cli_parm = bcmcli_find_named_parm(session, "members.action.o_pbits");
1275 if (cli_parm != NULL)
1276 {
1277 if (cli_parm->array_size != val.len)
1278 {
1279 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.o_pbits is a different size than other arrays in the struct\n");
1280 return BCM_ERR_PARM;
1281 }
1282
1283 for (i0 = 0; i0 < val.len; i0++)
1284 {
1285 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1286 {
1287 val.val[i0].action.o_pbits = cli_parm->values[i0].unumber;
1288 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_O_PBITS;
1289 }
1290 }
1291 }
1292
1293 cli_parm = bcmcli_find_named_parm(session, "members.action.o_tpid");
1294 if (cli_parm != NULL)
1295 {
1296 if (cli_parm->array_size != val.len)
1297 {
1298 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.o_tpid is a different size than other arrays in the struct\n");
1299 return BCM_ERR_PARM;
1300 }
1301
1302 for (i0 = 0; i0 < val.len; i0++)
1303 {
1304 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1305 {
1306 val.val[i0].action.o_tpid = cli_parm->values[i0].unumber;
1307 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_O_TPID;
1308 }
1309 }
1310 }
1311
1312 cli_parm = bcmcli_find_named_parm(session, "members.action.i_vid");
1313 if (cli_parm != NULL)
1314 {
1315 if (cli_parm->array_size != val.len)
1316 {
1317 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.i_vid is a different size than other arrays in the struct\n");
1318 return BCM_ERR_PARM;
1319 }
1320
1321 for (i0 = 0; i0 < val.len; i0++)
1322 {
1323 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1324 {
1325 val.val[i0].action.i_vid = cli_parm->values[i0].unumber;
1326 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_I_VID;
1327 }
1328 }
1329 }
1330
1331 cli_parm = bcmcli_find_named_parm(session, "members.action.i_pbits");
1332 if (cli_parm != NULL)
1333 {
1334 if (cli_parm->array_size != val.len)
1335 {
1336 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.i_pbits is a different size than other arrays in the struct\n");
1337 return BCM_ERR_PARM;
1338 }
1339
1340 for (i0 = 0; i0 < val.len; i0++)
1341 {
1342 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1343 {
1344 val.val[i0].action.i_pbits = cli_parm->values[i0].unumber;
1345 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_I_PBITS;
1346 }
1347 }
1348 }
1349
1350 cli_parm = bcmcli_find_named_parm(session, "members.action.i_tpid");
1351 if (cli_parm != NULL)
1352 {
1353 if (cli_parm->array_size != val.len)
1354 {
1355 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.action.i_tpid is a different size than other arrays in the struct\n");
1356 return BCM_ERR_PARM;
1357 }
1358
1359 for (i0 = 0; i0 < val.len; i0++)
1360 {
1361 if (bcmcli_parm_value_is_set(session, cli_parm, i0))
1362 {
1363 val.val[i0].action.i_tpid = cli_parm->values[i0].unumber;
1364 val.val[i0].action.presence_mask = val.val[i0].action.presence_mask | BCMBAL_ACTION_ID_I_TPID;
1365 }
1366 }
1367 }
1368
1369 cli_parm = bcmcli_find_named_parm(session, "members.queue.sched_id");
1370 if (cli_parm != NULL)
1371 {
1372 if (cli_parm->array_size != val.len)
1373 {
1374 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.queue.sched_id is a different size than other arrays in the struct\n");
1375 return BCM_ERR_PARM;
1376 }
1377
1378 for (i0 = 0; i0 < val.len; i0++)
1379 {
1380 val.val[i0].queue.sched_id = (bcmbal_tm_sched_id) cli_parm->values[i0].unumber;
1381 }
1382 }
1383
1384 cli_parm = bcmcli_find_named_parm(session, "members.queue.queue_id");
1385 if (cli_parm != NULL)
1386 {
1387 if (cli_parm->array_size != val.len)
1388 {
1389 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "members.queue.queue_id is a different size than other arrays in the struct\n");
1390 return BCM_ERR_PARM;
1391 }
1392
1393 for (i0 = 0; i0 < val.len; i0++)
1394 {
1395 val.val[i0].queue.queue_id = (bcmbal_tm_queue_id) cli_parm->values[i0].unumber;
1396 }
1397 }
1398
1399 BCMBAL_CFG_PROP_SET(&cfg, group, members, val);
1400 bcmcli_log("{\n");
1401 bcmcli_log("bcmbal_group_member_info_list_u16 val = ");
1402 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_GROUP, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_GROUP_CFG_ID_MEMBERS, &val);
1403 bcmcli_log(";\n");
1404 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, group, members, val);\n");
1405 bcmcli_log("}\n");
1406 }
1407
1408 cli_parm = bcmcli_find_named_parm(session, "cookie");
1409 if (cli_parm != NULL)
1410 {
1411 bcmbal_cookie val;
1412 val = (bcmbal_cookie) cli_parm->value.unumber64;
1413 BCMBAL_CFG_PROP_SET(&cfg, group, cookie, val);
1414 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, group, cookie, ");
1415 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_GROUP, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_GROUP_CFG_ID_COOKIE, &val);
1416 bcmcli_log(");\n");
1417 }
1418
1419 /* call API */
1420 err = bcmbal_cfg_set(&cfg.hdr);
1421 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
1422 bcmbal_apicli_print_complete(session, err, NULL);
1423 return err;
1424}
1425
1426/******************************************************************************/
1427static bcmos_errno bcmbal_cli_group_cfg_clear(bcmcli_session *session)
1428{
1429 bcmcli_cmd_parm *cli_parm;
1430 bcmos_errno err;
1431 bcmbal_group_cfg cfg; /**< declare main API struct */
1432 bcmbal_group_key key = { }; /**< declare key */
1433 bcmcli_log("bcmbal_group_cfg cfg;\n");
1434 bcmcli_log("bcmbal_group_key key = { };\n");
1435 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
1436
1437 /* build key from CLI parameters */
1438 cli_parm = bcmcli_find_named_parm(session, "group_id");
1439 if (cli_parm != NULL)
1440 {
1441 key.group_id = (bcmbal_group_id) cli_parm->value.unumber;
1442 }
1443 else
1444 {
1445 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "group_id is not set\n");
1446 return BCM_ERR_PARM;
1447 }
1448
1449 bcmcli_log("key.group_id = ");
1450 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_GROUP, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_GROUP_KEY_ID_GROUP_ID, &key.group_id);
1451 bcmcli_log(";\n");
1452
1453 /* init the API struct */
1454 BCMBAL_CFG_INIT(&cfg, group, key);
1455 bcmcli_log("BCMBAL_CFG_INIT(&cfg, group, key);\n");
1456
1457 /* call API */
1458 err = bcmbal_cfg_clear(&cfg.hdr);
1459 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
1460 bcmbal_apicli_print_complete(session, err, NULL);
1461 return err;
1462}
1463
1464/******************************************************************************/
1465static bcmos_errno bcmbal_cli_interface_cfg_get(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
1466{
1467 bcmcli_cmd_parm *cli_parm;
1468 bcmos_errno err;
1469 bcmbal_interface_cfg cfg; /**< declare main API struct */
1470 bcmbal_interface_key key = { }; /**< declare key */
1471 uint8_t *list_mem; /**< declare memory buffer for variable-sized lists */
1472 bcmcli_log("bcmbal_interface_cfg cfg;\n");
1473 bcmcli_log("bcmbal_interface_key key = { };\n");
1474 bcmcli_log("uint8_t* list_mem;\n");
1475 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
1476
1477 /* build key from CLI parameters */
1478 cli_parm = bcmcli_find_named_parm(session, "intf_id");
1479 if (cli_parm != NULL)
1480 {
1481 key.intf_id = cli_parm->value.unumber;
1482 }
1483 else
1484 {
1485 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
1486 return BCM_ERR_PARM;
1487 }
1488
1489 bcmcli_log("key.intf_id = ");
1490 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_ID, &key.intf_id);
1491 bcmcli_log(";\n");
1492 cli_parm = bcmcli_find_named_parm(session, "intf_type");
1493 if (cli_parm != NULL)
1494 {
1495 key.intf_type = (bcmbal_intf_type) cli_parm->value.enum_val;
1496 }
1497 else
1498 {
1499 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_type is not set\n");
1500 return BCM_ERR_PARM;
1501 }
1502
1503 bcmcli_log("key.intf_type = ");
1504 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_TYPE, &key.intf_type);
1505 bcmcli_log(";\n");
1506
1507 /* init the API struct */
1508 BCMBAL_CFG_INIT(&cfg, interface, key);
1509 bcmcli_log("BCMBAL_CFG_INIT(&cfg, interface, key);\n");
1510
1511 /* decode API parameters from CLI */
1512 cli_parm = bcmcli_find_named_parm(session, "admin_state");
1513 if (cli_parm != NULL)
1514 {
1515 if (cli_parm->value.number)
1516 {
1517 BCMBAL_CFG_PROP_GET(&cfg, interface, admin_state);
1518 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, admin_state);\n");
1519 }
1520 }
1521
1522 cli_parm = bcmcli_find_named_parm(session, "oper_status");
1523 if (cli_parm != NULL)
1524 {
1525 if (cli_parm->value.number)
1526 {
1527 BCMBAL_CFG_PROP_GET(&cfg, interface, oper_status);
1528 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, oper_status);\n");
1529 }
1530 }
1531
1532 cli_parm = bcmcli_find_named_parm(session, "min_data_agg_port_id");
1533 if (cli_parm != NULL)
1534 {
1535 if (cli_parm->value.number)
1536 {
1537 BCMBAL_CFG_PROP_GET(&cfg, interface, min_data_agg_port_id);
1538 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, min_data_agg_port_id);\n");
1539 }
1540 }
1541
1542 cli_parm = bcmcli_find_named_parm(session, "min_data_svc_port_id");
1543 if (cli_parm != NULL)
1544 {
1545 if (cli_parm->value.number)
1546 {
1547 BCMBAL_CFG_PROP_GET(&cfg, interface, min_data_svc_port_id);
1548 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, min_data_svc_port_id);\n");
1549 }
1550 }
1551
1552 cli_parm = bcmcli_find_named_parm(session, "transceiver_type");
1553 if (cli_parm != NULL)
1554 {
1555 if (cli_parm->value.number)
1556 {
1557 BCMBAL_CFG_PROP_GET(&cfg, interface, transceiver_type);
1558 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, transceiver_type);\n");
1559 }
1560 }
1561
1562 cli_parm = bcmcli_find_named_parm(session, "ds_miss_mode");
1563 if (cli_parm != NULL)
1564 {
1565 if (cli_parm->value.number)
1566 {
1567 BCMBAL_CFG_PROP_GET(&cfg, interface, ds_miss_mode);
1568 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, ds_miss_mode);\n");
1569 }
1570 }
1571
1572 cli_parm = bcmcli_find_named_parm(session, "mtu");
1573 if (cli_parm != NULL)
1574 {
1575 if (cli_parm->value.number)
1576 {
1577 BCMBAL_CFG_PROP_GET(&cfg, interface, mtu);
1578 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, mtu);\n");
1579 }
1580 }
1581
1582 cli_parm = bcmcli_find_named_parm(session, "flow_control");
1583 if (cli_parm != NULL)
1584 {
1585 if (cli_parm->value.number)
1586 {
1587 BCMBAL_CFG_PROP_GET(&cfg, interface, flow_control);
1588 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, flow_control);\n");
1589 }
1590 }
1591
1592 cli_parm = bcmcli_find_named_parm(session, "ds_tm");
1593 if (cli_parm != NULL)
1594 {
1595 if (cli_parm->value.number)
1596 {
1597 BCMBAL_CFG_PROP_GET(&cfg, interface, ds_tm);
1598 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, ds_tm);\n");
1599 }
1600 }
1601
1602 cli_parm = bcmcli_find_named_parm(session, "us_tm");
1603 if (cli_parm != NULL)
1604 {
1605 if (cli_parm->value.number)
1606 {
1607 BCMBAL_CFG_PROP_GET(&cfg, interface, us_tm);
1608 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, us_tm);\n");
1609 }
1610 }
1611
1612 cli_parm = bcmcli_find_named_parm(session, "sub_term_id_list");
1613 if (cli_parm != NULL)
1614 {
1615 if (cli_parm->value.number)
1616 {
1617 BCMBAL_CFG_PROP_GET(&cfg, interface, sub_term_id_list);
1618 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, sub_term_id_list);\n");
1619 }
1620 }
1621
1622 /* if no properties were requested, include everything */
1623 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, interface, admin_state) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, oper_status) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, min_data_agg_port_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, min_data_svc_port_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, transceiver_type) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, ds_miss_mode) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, mtu) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, flow_control) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, ds_tm) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, us_tm) && !BCMBAL_CFG_PROP_IS_SET(&cfg, interface, sub_term_id_list))
1624 {
1625 BCMBAL_CFG_PROP_GET(&cfg, interface, all_properties);
1626 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, interface, all_properties);\n");
1627 }
1628
1629 /* set memory to use for variable-sized lists */
1630 list_mem = bcmbal_apicli_byte_pool_calloc(byte_pool, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
1631 if (list_mem == NULL)
1632 {
1633 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
1634 return BCM_ERR_NOMEM;
1635 }
1636
1637 bcmcli_log("list_mem = bcmos_calloc(BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
1638 BCMBAL_CFG_LIST_BUF_SET(&cfg, interface, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
1639 bcmcli_log("BCMBAL_CFG_LIST_BUF_SET(&cfg, interface, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
1640
1641 /* call API */
1642 err = bcmbal_cfg_get(&cfg.hdr);
1643 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
1644 if (err == BCM_ERR_OK)
1645 {
1646 /* print API contents to the CLI */
1647 bcmbal_apicli_print_data_start(session);
1648 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
1649 }
1650
1651 bcmbal_apicli_print_complete(session, err, NULL);
1652 return err;
1653}
1654
1655/******************************************************************************/
1656static bcmos_errno bcmbal_cli_interface_cfg_set(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
1657{
1658 bcmcli_cmd_parm *cli_parm;
1659 bcmos_errno err;
1660 bcmbal_interface_cfg cfg; /**< declare main API struct */
1661 bcmbal_interface_key key = { }; /**< declare key */
1662 bcmcli_log("bcmbal_interface_cfg cfg;\n");
1663 bcmcli_log("bcmbal_interface_key key = { };\n");
1664 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
1665
1666 /* build key from CLI parameters */
1667 cli_parm = bcmcli_find_named_parm(session, "intf_id");
1668 if (cli_parm != NULL)
1669 {
1670 key.intf_id = cli_parm->value.unumber;
1671 }
1672 else
1673 {
1674 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
1675 return BCM_ERR_PARM;
1676 }
1677
1678 bcmcli_log("key.intf_id = ");
1679 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_ID, &key.intf_id);
1680 bcmcli_log(";\n");
1681 cli_parm = bcmcli_find_named_parm(session, "intf_type");
1682 if (cli_parm != NULL)
1683 {
1684 key.intf_type = (bcmbal_intf_type) cli_parm->value.enum_val;
1685 }
1686 else
1687 {
1688 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_type is not set\n");
1689 return BCM_ERR_PARM;
1690 }
1691
1692 bcmcli_log("key.intf_type = ");
1693 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_TYPE, &key.intf_type);
1694 bcmcli_log(";\n");
1695
1696 /* init the API struct */
1697 BCMBAL_CFG_INIT(&cfg, interface, key);
1698 bcmcli_log("BCMBAL_CFG_INIT(&cfg, interface, key);\n");
1699
1700 /* decode API parameters from CLI */
1701 cli_parm = bcmcli_find_named_parm(session, "admin_state");
1702 if (cli_parm != NULL)
1703 {
1704 bcmbal_state val;
1705 val = (bcmbal_state) cli_parm->value.enum_val;
1706 BCMBAL_CFG_PROP_SET(&cfg, interface, admin_state, val);
1707 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, admin_state, ");
1708 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_ADMIN_STATE, &val);
1709 bcmcli_log(");\n");
1710 }
1711
1712 cli_parm = bcmcli_find_named_parm(session, "min_data_agg_port_id");
1713 if (cli_parm != NULL)
1714 {
1715 bcmbal_aggregation_port_id val;
1716 val = (bcmbal_aggregation_port_id) cli_parm->value.unumber;
1717 BCMBAL_CFG_PROP_SET(&cfg, interface, min_data_agg_port_id, val);
1718 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, min_data_agg_port_id, ");
1719 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_MIN_DATA_AGG_PORT_ID, &val);
1720 bcmcli_log(");\n");
1721 }
1722
1723 cli_parm = bcmcli_find_named_parm(session, "min_data_svc_port_id");
1724 if (cli_parm != NULL)
1725 {
1726 bcmbal_service_port_id val;
1727 val = (bcmbal_service_port_id) cli_parm->value.unumber;
1728 BCMBAL_CFG_PROP_SET(&cfg, interface, min_data_svc_port_id, val);
1729 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, min_data_svc_port_id, ");
1730 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_MIN_DATA_SVC_PORT_ID, &val);
1731 bcmcli_log(");\n");
1732 }
1733
1734 cli_parm = bcmcli_find_named_parm(session, "transceiver_type");
1735 if (cli_parm != NULL)
1736 {
1737 bcmbal_trx_type val;
1738 val = (bcmbal_trx_type) cli_parm->value.enum_val;
1739 BCMBAL_CFG_PROP_SET(&cfg, interface, transceiver_type, val);
1740 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, transceiver_type, ");
1741 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_TRANSCEIVER_TYPE, &val);
1742 bcmcli_log(");\n");
1743 }
1744
1745 cli_parm = bcmcli_find_named_parm(session, "ds_miss_mode");
1746 if (cli_parm != NULL)
1747 {
1748 bcmbal_ds_miss_mode val;
1749 val = (bcmbal_ds_miss_mode) cli_parm->value.enum_val;
1750 BCMBAL_CFG_PROP_SET(&cfg, interface, ds_miss_mode, val);
1751 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, ds_miss_mode, ");
1752 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_DS_MISS_MODE, &val);
1753 bcmcli_log(");\n");
1754 }
1755
1756 cli_parm = bcmcli_find_named_parm(session, "mtu");
1757 if (cli_parm != NULL)
1758 {
1759 uint16_t val;
1760 val = cli_parm->value.unumber;
1761 BCMBAL_CFG_PROP_SET(&cfg, interface, mtu, val);
1762 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, mtu, ");
1763 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_MTU, &val);
1764 bcmcli_log(");\n");
1765 }
1766
1767 cli_parm = bcmcli_find_named_parm(session, "flow_control");
1768 if (cli_parm != NULL)
1769 {
1770 bcmbal_control val;
1771 val = (bcmbal_control) cli_parm->value.enum_val;
1772 BCMBAL_CFG_PROP_SET(&cfg, interface, flow_control, val);
1773 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, flow_control, ");
1774 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_FLOW_CONTROL, &val);
1775 bcmcli_log(");\n");
1776 }
1777
1778 cli_parm = bcmcli_find_named_parm(session, "ds_tm");
1779 if (cli_parm != NULL)
1780 {
1781 bcmbal_tm_sched_id val;
1782 val = (bcmbal_tm_sched_id) cli_parm->value.unumber;
1783 BCMBAL_CFG_PROP_SET(&cfg, interface, ds_tm, val);
1784 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, ds_tm, ");
1785 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_DS_TM, &val);
1786 bcmcli_log(");\n");
1787 }
1788
1789 cli_parm = bcmcli_find_named_parm(session, "us_tm");
1790 if (cli_parm != NULL)
1791 {
1792 bcmbal_tm_sched_id val;
1793 val = (bcmbal_tm_sched_id) cli_parm->value.unumber;
1794 BCMBAL_CFG_PROP_SET(&cfg, interface, us_tm, val);
1795 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, interface, us_tm, ");
1796 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_INTERFACE_CFG_ID_US_TM, &val);
1797 bcmcli_log(");\n");
1798 }
1799
1800 /* call API */
1801 err = bcmbal_cfg_set(&cfg.hdr);
1802 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
1803 bcmbal_apicli_print_complete(session, err, NULL);
1804 return err;
1805}
1806
1807/******************************************************************************/
1808static bcmos_errno bcmbal_cli_interface_cfg_clear(bcmcli_session *session)
1809{
1810 bcmcli_cmd_parm *cli_parm;
1811 bcmos_errno err;
1812 bcmbal_interface_cfg cfg; /**< declare main API struct */
1813 bcmbal_interface_key key = { }; /**< declare key */
1814 bcmcli_log("bcmbal_interface_cfg cfg;\n");
1815 bcmcli_log("bcmbal_interface_key key = { };\n");
1816 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
1817
1818 /* build key from CLI parameters */
1819 cli_parm = bcmcli_find_named_parm(session, "intf_id");
1820 if (cli_parm != NULL)
1821 {
1822 key.intf_id = cli_parm->value.unumber;
1823 }
1824 else
1825 {
1826 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
1827 return BCM_ERR_PARM;
1828 }
1829
1830 bcmcli_log("key.intf_id = ");
1831 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_ID, &key.intf_id);
1832 bcmcli_log(";\n");
1833 cli_parm = bcmcli_find_named_parm(session, "intf_type");
1834 if (cli_parm != NULL)
1835 {
1836 key.intf_type = (bcmbal_intf_type) cli_parm->value.enum_val;
1837 }
1838 else
1839 {
1840 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_type is not set\n");
1841 return BCM_ERR_PARM;
1842 }
1843
1844 bcmcli_log("key.intf_type = ");
1845 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_TYPE, &key.intf_type);
1846 bcmcli_log(";\n");
1847
1848 /* init the API struct */
1849 BCMBAL_CFG_INIT(&cfg, interface, key);
1850 bcmcli_log("BCMBAL_CFG_INIT(&cfg, interface, key);\n");
1851
1852 /* call API */
1853 err = bcmbal_cfg_clear(&cfg.hdr);
1854 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
1855 bcmbal_apicli_print_complete(session, err, NULL);
1856 return err;
1857}
1858
1859/******************************************************************************/
1860static bcmos_errno bcmbal_cli_interface_stat_get(bcmcli_session *session)
1861{
1862 bcmcli_cmd_parm *cli_parm;
1863 bcmos_errno err;
1864 bcmbal_interface_stat stat; /**< declare main API struct */
1865 bcmbal_interface_key key = { }; /**< declare key */
1866 bcmcli_log("bcmbal_interface_stat stat;\n");
1867 bcmcli_log("bcmbal_interface_key key = { };\n");
1868 bcmbal_apicli_print_start(session, "bcmbal_stat_get");
1869
1870 /* build key from CLI parameters */
1871 cli_parm = bcmcli_find_named_parm(session, "intf_id");
1872 if (cli_parm != NULL)
1873 {
1874 key.intf_id = cli_parm->value.unumber;
1875 }
1876 else
1877 {
1878 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
1879 return BCM_ERR_PARM;
1880 }
1881
1882 bcmcli_log("key.intf_id = ");
1883 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_ID, &key.intf_id);
1884 bcmcli_log(";\n");
1885 cli_parm = bcmcli_find_named_parm(session, "intf_type");
1886 if (cli_parm != NULL)
1887 {
1888 key.intf_type = (bcmbal_intf_type) cli_parm->value.enum_val;
1889 }
1890 else
1891 {
1892 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_type is not set\n");
1893 return BCM_ERR_PARM;
1894 }
1895
1896 bcmcli_log("key.intf_type = ");
1897 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_INTERFACE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_INTERFACE_KEY_ID_INTF_TYPE, &key.intf_type);
1898 bcmcli_log(";\n");
1899
1900 /* init the API struct */
1901 BCMBAL_STAT_INIT(&stat, interface, key);
1902 bcmcli_log("BCMBAL_STAT_INIT(&stat, interface, key);\n");
1903
1904 /* decode API parameters from CLI */
1905 cli_parm = bcmcli_find_named_parm(session, "rx_packets");
1906 if (cli_parm != NULL)
1907 {
1908 if (cli_parm->value.number)
1909 {
1910 BCMBAL_STAT_PROP_GET(&stat, interface, rx_packets);
1911 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, interface, rx_packets);\n");
1912 }
1913 }
1914
1915 cli_parm = bcmcli_find_named_parm(session, "rx_bytes");
1916 if (cli_parm != NULL)
1917 {
1918 if (cli_parm->value.number)
1919 {
1920 BCMBAL_STAT_PROP_GET(&stat, interface, rx_bytes);
1921 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, interface, rx_bytes);\n");
1922 }
1923 }
1924
1925 cli_parm = bcmcli_find_named_parm(session, "tx_packets");
1926 if (cli_parm != NULL)
1927 {
1928 if (cli_parm->value.number)
1929 {
1930 BCMBAL_STAT_PROP_GET(&stat, interface, tx_packets);
1931 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, interface, tx_packets);\n");
1932 }
1933 }
1934
1935 cli_parm = bcmcli_find_named_parm(session, "tx_bytes");
1936 if (cli_parm != NULL)
1937 {
1938 if (cli_parm->value.number)
1939 {
1940 BCMBAL_STAT_PROP_GET(&stat, interface, tx_bytes);
1941 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, interface, tx_bytes);\n");
1942 }
1943 }
1944
1945 /* if no properties were requested, include everything */
1946 if (!BCMBAL_STAT_PROP_IS_SET(&stat, interface, rx_packets) && !BCMBAL_STAT_PROP_IS_SET(&stat, interface, rx_bytes) && !BCMBAL_STAT_PROP_IS_SET(&stat, interface, tx_packets) && !BCMBAL_STAT_PROP_IS_SET(&stat, interface, tx_bytes))
1947 {
1948 BCMBAL_STAT_PROP_GET(&stat, interface, all_properties);
1949 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, interface, all_properties);\n");
1950 }
1951
1952 /* call API */
1953 err = bcmbal_stat_get(&stat.hdr);
1954 bcmcli_log("bcmbal_stat_get(&stat.hdr);\n");
1955 if (err == BCM_ERR_OK)
1956 {
1957 /* print API contents to the CLI */
1958 bcmbal_apicli_print_data_start(session);
1959 err = bcmbal_apicli_msg_dump(session, &stat.hdr.hdr);
1960 }
1961
1962 bcmbal_apicli_print_complete(session, err, NULL);
1963 return err;
1964}
1965
1966/******************************************************************************/
1967static bcmos_errno bcmbal_cli_packet_cfg_get(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
1968{
1969 bcmcli_cmd_parm *cli_parm;
1970 bcmos_errno err;
1971 bcmbal_packet_cfg cfg; /**< declare main API struct */
1972 bcmbal_packet_key key = { }; /**< declare key */
1973 uint8_t *list_mem; /**< declare memory buffer for variable-sized lists */
1974 bcmcli_log("bcmbal_packet_cfg cfg;\n");
1975 bcmcli_log("bcmbal_packet_key key = { };\n");
1976 bcmcli_log("uint8_t* list_mem;\n");
1977 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
1978
1979 /* build key from CLI parameters */
1980 cli_parm = bcmcli_find_named_parm(session, "reserved");
1981 if (cli_parm != NULL)
1982 {
1983 key.reserved = cli_parm->value.unumber;
1984 }
1985 else
1986 {
1987 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "reserved is not set\n");
1988 return BCM_ERR_PARM;
1989 }
1990
1991 bcmcli_log("key.reserved = ");
1992 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_PACKET_KEY_ID_RESERVED, &key.reserved);
1993 bcmcli_log(";\n");
1994 cli_parm = bcmcli_find_parm_by_prefix(session, "packet_send_dest.");
1995 if (cli_parm != NULL)
1996 {
1997 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.type");
1998 if (cli_parm != NULL)
1999 {
2000 key.packet_send_dest.type = (bcmbal_dest_type) cli_parm->value.enum_val;
2001 }
2002 else
2003 {
2004 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.type is not set\n");
2005 return BCM_ERR_PARM;
2006 }
2007
2008 switch (key.packet_send_dest.type)
2009 {
2010 case BCMBAL_DEST_TYPE_NNI:
2011 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.int_id");
2012 if (cli_parm != NULL)
2013 {
2014 key.packet_send_dest.u.nni.int_id = (bcmbal_intf_id) cli_parm->value.unumber;
2015 }
2016 else
2017 {
2018 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.int_id is not set\n");
2019 return BCM_ERR_PARM;
2020 }
2021 break;
2022 case BCMBAL_DEST_TYPE_SUB_TERM:
2023 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.sub_term_id");
2024 if (cli_parm != NULL)
2025 {
2026 key.packet_send_dest.u.sub_term.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2027 }
2028 else
2029 {
2030 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.sub_term_id is not set\n");
2031 return BCM_ERR_PARM;
2032 }
2033
2034 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.sub_term_uni");
2035 if (cli_parm != NULL)
2036 {
2037 key.packet_send_dest.u.sub_term.sub_term_uni = cli_parm->value.unumber;
2038 }
2039 else
2040 {
2041 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.sub_term_uni is not set\n");
2042 return BCM_ERR_PARM;
2043 }
2044
2045 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.int_id");
2046 if (cli_parm != NULL)
2047 {
2048 key.packet_send_dest.u.sub_term.int_id = cli_parm->value.unumber;
2049 }
2050 else
2051 {
2052 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.int_id is not set\n");
2053 return BCM_ERR_PARM;
2054 }
2055 break;
2056 case BCMBAL_DEST_TYPE_HOST:
2057 break;
2058 default:
2059 bcmbal_apicli_print_complete(session, BCM_ERR_RANGE, "\n");
2060 return BCM_ERR_RANGE;
2061 }
2062 }
2063 else
2064 {
2065 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest is not set\n");
2066 return BCM_ERR_PARM;
2067 }
2068
2069 bcmcli_log("key.packet_send_dest = ");
2070 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_PACKET_KEY_ID_PACKET_SEND_DEST, &key.packet_send_dest);
2071 bcmcli_log(";\n");
2072
2073 /* init the API struct */
2074 BCMBAL_CFG_INIT(&cfg, packet, key);
2075 bcmcli_log("BCMBAL_CFG_INIT(&cfg, packet, key);\n");
2076
2077 /* decode API parameters from CLI */
2078 cli_parm = bcmcli_find_named_parm(session, "flow_id");
2079 if (cli_parm != NULL)
2080 {
2081 if (cli_parm->value.number)
2082 {
2083 BCMBAL_CFG_PROP_GET(&cfg, packet, flow_id);
2084 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, flow_id);\n");
2085 }
2086 }
2087
2088 cli_parm = bcmcli_find_named_parm(session, "flow_type");
2089 if (cli_parm != NULL)
2090 {
2091 if (cli_parm->value.number)
2092 {
2093 BCMBAL_CFG_PROP_GET(&cfg, packet, flow_type);
2094 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, flow_type);\n");
2095 }
2096 }
2097
2098 cli_parm = bcmcli_find_named_parm(session, "intf_id");
2099 if (cli_parm != NULL)
2100 {
2101 if (cli_parm->value.number)
2102 {
2103 BCMBAL_CFG_PROP_GET(&cfg, packet, intf_id);
2104 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, intf_id);\n");
2105 }
2106 }
2107
2108 cli_parm = bcmcli_find_named_parm(session, "intf_type");
2109 if (cli_parm != NULL)
2110 {
2111 if (cli_parm->value.number)
2112 {
2113 BCMBAL_CFG_PROP_GET(&cfg, packet, intf_type);
2114 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, intf_type);\n");
2115 }
2116 }
2117
2118 cli_parm = bcmcli_find_named_parm(session, "svc_port");
2119 if (cli_parm != NULL)
2120 {
2121 if (cli_parm->value.number)
2122 {
2123 BCMBAL_CFG_PROP_GET(&cfg, packet, svc_port);
2124 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, svc_port);\n");
2125 }
2126 }
2127
2128 cli_parm = bcmcli_find_named_parm(session, "flow_cookie");
2129 if (cli_parm != NULL)
2130 {
2131 if (cli_parm->value.number)
2132 {
2133 BCMBAL_CFG_PROP_GET(&cfg, packet, flow_cookie);
2134 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, flow_cookie);\n");
2135 }
2136 }
2137
2138 cli_parm = bcmcli_find_named_parm(session, "pkt");
2139 if (cli_parm != NULL)
2140 {
2141 if (cli_parm->value.number)
2142 {
2143 BCMBAL_CFG_PROP_GET(&cfg, packet, pkt);
2144 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, pkt);\n");
2145 }
2146 }
2147
2148 /* if no properties were requested, include everything */
2149 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, packet, flow_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, packet, flow_type) && !BCMBAL_CFG_PROP_IS_SET(&cfg, packet, intf_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, packet, intf_type) && !BCMBAL_CFG_PROP_IS_SET(&cfg, packet, svc_port) && !BCMBAL_CFG_PROP_IS_SET(&cfg, packet, flow_cookie) && !BCMBAL_CFG_PROP_IS_SET(&cfg, packet, pkt))
2150 {
2151 BCMBAL_CFG_PROP_GET(&cfg, packet, all_properties);
2152 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, packet, all_properties);\n");
2153 }
2154
2155 /* set memory to use for variable-sized lists */
2156 list_mem = bcmbal_apicli_byte_pool_calloc(byte_pool, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
2157 if (list_mem == NULL)
2158 {
2159 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
2160 return BCM_ERR_NOMEM;
2161 }
2162
2163 bcmcli_log("list_mem = bcmos_calloc(BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
2164 BCMBAL_CFG_LIST_BUF_SET(&cfg, packet, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
2165 bcmcli_log("BCMBAL_CFG_LIST_BUF_SET(&cfg, packet, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
2166
2167 /* call API */
2168 err = bcmbal_cfg_get(&cfg.hdr);
2169 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
2170 if (err == BCM_ERR_OK)
2171 {
2172 /* print API contents to the CLI */
2173 bcmbal_apicli_print_data_start(session);
2174 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
2175 }
2176
2177 bcmbal_apicli_print_complete(session, err, NULL);
2178 return err;
2179}
2180
2181/******************************************************************************/
2182static bcmos_errno bcmbal_cli_packet_cfg_set(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
2183{
2184 bcmcli_cmd_parm *cli_parm;
2185 bcmos_errno err;
2186 bcmbal_packet_cfg cfg; /**< declare main API struct */
2187 bcmbal_packet_key key = { }; /**< declare key */
2188 bcmcli_log("bcmbal_packet_cfg cfg;\n");
2189 bcmcli_log("bcmbal_packet_key key = { };\n");
2190 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
2191
2192 /* build key from CLI parameters */
2193 cli_parm = bcmcli_find_named_parm(session, "reserved");
2194 if (cli_parm != NULL)
2195 {
2196 key.reserved = cli_parm->value.unumber;
2197 }
2198 else
2199 {
2200 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "reserved is not set\n");
2201 return BCM_ERR_PARM;
2202 }
2203
2204 bcmcli_log("key.reserved = ");
2205 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_PACKET_KEY_ID_RESERVED, &key.reserved);
2206 bcmcli_log(";\n");
2207 cli_parm = bcmcli_find_parm_by_prefix(session, "packet_send_dest.");
2208 if (cli_parm != NULL)
2209 {
2210 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.type");
2211 if (cli_parm != NULL)
2212 {
2213 key.packet_send_dest.type = (bcmbal_dest_type) cli_parm->value.enum_val;
2214 }
2215 else
2216 {
2217 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.type is not set\n");
2218 return BCM_ERR_PARM;
2219 }
2220
2221 switch (key.packet_send_dest.type)
2222 {
2223 case BCMBAL_DEST_TYPE_NNI:
2224 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.int_id");
2225 if (cli_parm != NULL)
2226 {
2227 key.packet_send_dest.u.nni.int_id = (bcmbal_intf_id) cli_parm->value.unumber;
2228 }
2229 else
2230 {
2231 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.int_id is not set\n");
2232 return BCM_ERR_PARM;
2233 }
2234 break;
2235 case BCMBAL_DEST_TYPE_SUB_TERM:
2236 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.sub_term_id");
2237 if (cli_parm != NULL)
2238 {
2239 key.packet_send_dest.u.sub_term.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2240 }
2241 else
2242 {
2243 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.sub_term_id is not set\n");
2244 return BCM_ERR_PARM;
2245 }
2246
2247 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.sub_term_uni");
2248 if (cli_parm != NULL)
2249 {
2250 key.packet_send_dest.u.sub_term.sub_term_uni = cli_parm->value.unumber;
2251 }
2252 else
2253 {
2254 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.sub_term_uni is not set\n");
2255 return BCM_ERR_PARM;
2256 }
2257
2258 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.int_id");
2259 if (cli_parm != NULL)
2260 {
2261 key.packet_send_dest.u.sub_term.int_id = cli_parm->value.unumber;
2262 }
2263 else
2264 {
2265 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.int_id is not set\n");
2266 return BCM_ERR_PARM;
2267 }
2268 break;
2269 case BCMBAL_DEST_TYPE_HOST:
2270 break;
2271 default:
2272 bcmbal_apicli_print_complete(session, BCM_ERR_RANGE, "\n");
2273 return BCM_ERR_RANGE;
2274 }
2275 }
2276 else
2277 {
2278 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest is not set\n");
2279 return BCM_ERR_PARM;
2280 }
2281
2282 bcmcli_log("key.packet_send_dest = ");
2283 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_PACKET_KEY_ID_PACKET_SEND_DEST, &key.packet_send_dest);
2284 bcmcli_log(";\n");
2285
2286 /* init the API struct */
2287 BCMBAL_CFG_INIT(&cfg, packet, key);
2288 bcmcli_log("BCMBAL_CFG_INIT(&cfg, packet, key);\n");
2289
2290 /* decode API parameters from CLI */
2291 cli_parm = bcmcli_find_named_parm(session, "flow_id");
2292 if (cli_parm != NULL)
2293 {
2294 bcmbal_flow_id val;
2295 val = (bcmbal_flow_id) cli_parm->value.unumber;
2296 BCMBAL_CFG_PROP_SET(&cfg, packet, flow_id, val);
2297 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, flow_id, ");
2298 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_FLOW_ID, &val);
2299 bcmcli_log(");\n");
2300 }
2301
2302 cli_parm = bcmcli_find_named_parm(session, "flow_type");
2303 if (cli_parm != NULL)
2304 {
2305 bcmbal_flow_type val;
2306 val = (bcmbal_flow_type) cli_parm->value.enum_val;
2307 BCMBAL_CFG_PROP_SET(&cfg, packet, flow_type, val);
2308 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, flow_type, ");
2309 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_FLOW_TYPE, &val);
2310 bcmcli_log(");\n");
2311 }
2312
2313 cli_parm = bcmcli_find_named_parm(session, "intf_id");
2314 if (cli_parm != NULL)
2315 {
2316 bcmbal_intf_id val;
2317 val = (bcmbal_intf_id) cli_parm->value.unumber;
2318 BCMBAL_CFG_PROP_SET(&cfg, packet, intf_id, val);
2319 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, intf_id, ");
2320 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_INTF_ID, &val);
2321 bcmcli_log(");\n");
2322 }
2323
2324 cli_parm = bcmcli_find_named_parm(session, "intf_type");
2325 if (cli_parm != NULL)
2326 {
2327 bcmbal_intf_type val;
2328 val = (bcmbal_intf_type) cli_parm->value.enum_val;
2329 BCMBAL_CFG_PROP_SET(&cfg, packet, intf_type, val);
2330 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, intf_type, ");
2331 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_INTF_TYPE, &val);
2332 bcmcli_log(");\n");
2333 }
2334
2335 cli_parm = bcmcli_find_named_parm(session, "svc_port");
2336 if (cli_parm != NULL)
2337 {
2338 bcmbal_service_port_id val;
2339 val = (bcmbal_service_port_id) cli_parm->value.unumber;
2340 BCMBAL_CFG_PROP_SET(&cfg, packet, svc_port, val);
2341 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, svc_port, ");
2342 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_SVC_PORT, &val);
2343 bcmcli_log(");\n");
2344 }
2345
2346 cli_parm = bcmcli_find_named_parm(session, "flow_cookie");
2347 if (cli_parm != NULL)
2348 {
2349 bcmbal_cookie val;
2350 val = (bcmbal_cookie) cli_parm->value.unumber64;
2351 BCMBAL_CFG_PROP_SET(&cfg, packet, flow_cookie, val);
2352 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, flow_cookie, ");
2353 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_FLOW_COOKIE, &val);
2354 bcmcli_log(");\n");
2355 }
2356
2357 cli_parm = bcmcli_find_named_parm(session, "pkt");
2358 if (cli_parm != NULL)
2359 {
2360 bcmbal_u8_list_u32 val = { };
2361 val.len = bcmbal_buf_get_used(&cli_parm->value.buffer);
2362 val.val = bcmbal_apicli_byte_pool_calloc(byte_pool, val.len);
2363 if (val.val == NULL)
2364 {
2365 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
2366 return BCM_ERR_NOMEM;
2367 }
2368
2369 bcmbal_buf_set_pos(&cli_parm->value.buffer, 0);
2370 bcmbal_buf_read(&cli_parm->value.buffer, val.val, val.len);
2371 BCMBAL_CFG_PROP_SET(&cfg, packet, pkt, val);
2372 bcmcli_log("{\n");
2373 bcmcli_log("bcmbal_u8_list_u32 val = ");
2374 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_PACKET_CFG_ID_PKT, &val);
2375 bcmcli_log(";\n");
2376 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, packet, pkt, val);\n");
2377 bcmcli_log("}\n");
2378 }
2379
2380 /* call API */
2381 err = bcmbal_cfg_set(&cfg.hdr);
2382 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
2383 bcmbal_apicli_print_complete(session, err, NULL);
2384 return err;
2385}
2386
2387/******************************************************************************/
2388static bcmos_errno bcmbal_cli_packet_cfg_clear(bcmcli_session *session)
2389{
2390 bcmcli_cmd_parm *cli_parm;
2391 bcmos_errno err;
2392 bcmbal_packet_cfg cfg; /**< declare main API struct */
2393 bcmbal_packet_key key = { }; /**< declare key */
2394 bcmcli_log("bcmbal_packet_cfg cfg;\n");
2395 bcmcli_log("bcmbal_packet_key key = { };\n");
2396 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
2397
2398 /* build key from CLI parameters */
2399 cli_parm = bcmcli_find_named_parm(session, "reserved");
2400 if (cli_parm != NULL)
2401 {
2402 key.reserved = cli_parm->value.unumber;
2403 }
2404 else
2405 {
2406 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "reserved is not set\n");
2407 return BCM_ERR_PARM;
2408 }
2409
2410 bcmcli_log("key.reserved = ");
2411 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_PACKET_KEY_ID_RESERVED, &key.reserved);
2412 bcmcli_log(";\n");
2413 cli_parm = bcmcli_find_parm_by_prefix(session, "packet_send_dest.");
2414 if (cli_parm != NULL)
2415 {
2416 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.type");
2417 if (cli_parm != NULL)
2418 {
2419 key.packet_send_dest.type = (bcmbal_dest_type) cli_parm->value.enum_val;
2420 }
2421 else
2422 {
2423 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.type is not set\n");
2424 return BCM_ERR_PARM;
2425 }
2426
2427 switch (key.packet_send_dest.type)
2428 {
2429 case BCMBAL_DEST_TYPE_NNI:
2430 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.int_id");
2431 if (cli_parm != NULL)
2432 {
2433 key.packet_send_dest.u.nni.int_id = (bcmbal_intf_id) cli_parm->value.unumber;
2434 }
2435 else
2436 {
2437 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.int_id is not set\n");
2438 return BCM_ERR_PARM;
2439 }
2440 break;
2441 case BCMBAL_DEST_TYPE_SUB_TERM:
2442 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.sub_term_id");
2443 if (cli_parm != NULL)
2444 {
2445 key.packet_send_dest.u.sub_term.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2446 }
2447 else
2448 {
2449 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.sub_term_id is not set\n");
2450 return BCM_ERR_PARM;
2451 }
2452
2453 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.sub_term_uni");
2454 if (cli_parm != NULL)
2455 {
2456 key.packet_send_dest.u.sub_term.sub_term_uni = cli_parm->value.unumber;
2457 }
2458 else
2459 {
2460 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.sub_term_uni is not set\n");
2461 return BCM_ERR_PARM;
2462 }
2463
2464 cli_parm = bcmcli_find_named_parm(session, "packet_send_dest.int_id");
2465 if (cli_parm != NULL)
2466 {
2467 key.packet_send_dest.u.sub_term.int_id = cli_parm->value.unumber;
2468 }
2469 else
2470 {
2471 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest.int_id is not set\n");
2472 return BCM_ERR_PARM;
2473 }
2474 break;
2475 case BCMBAL_DEST_TYPE_HOST:
2476 break;
2477 default:
2478 bcmbal_apicli_print_complete(session, BCM_ERR_RANGE, "\n");
2479 return BCM_ERR_RANGE;
2480 }
2481 }
2482 else
2483 {
2484 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "packet_send_dest is not set\n");
2485 return BCM_ERR_PARM;
2486 }
2487
2488 bcmcli_log("key.packet_send_dest = ");
2489 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_PACKET, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_PACKET_KEY_ID_PACKET_SEND_DEST, &key.packet_send_dest);
2490 bcmcli_log(";\n");
2491
2492 /* init the API struct */
2493 BCMBAL_CFG_INIT(&cfg, packet, key);
2494 bcmcli_log("BCMBAL_CFG_INIT(&cfg, packet, key);\n");
2495
2496 /* call API */
2497 err = bcmbal_cfg_clear(&cfg.hdr);
2498 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
2499 bcmbal_apicli_print_complete(session, err, NULL);
2500 return err;
2501}
2502
2503/******************************************************************************/
2504static bcmos_errno bcmbal_cli_subscriber_terminal_cfg_get(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
2505{
2506 bcmcli_cmd_parm *cli_parm;
2507 bcmos_errno err;
2508 bcmbal_subscriber_terminal_cfg cfg; /**< declare main API struct */
2509 bcmbal_subscriber_terminal_key key = { }; /**< declare key */
2510 uint8_t *list_mem; /**< declare memory buffer for variable-sized lists */
2511 bcmcli_log("bcmbal_subscriber_terminal_cfg cfg;\n");
2512 bcmcli_log("bcmbal_subscriber_terminal_key key = { };\n");
2513 bcmcli_log("uint8_t* list_mem;\n");
2514 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
2515
2516 /* build key from CLI parameters */
2517 cli_parm = bcmcli_find_named_parm(session, "sub_term_id");
2518 if (cli_parm != NULL)
2519 {
2520 key.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2521 }
2522 else
2523 {
2524 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sub_term_id is not set\n");
2525 return BCM_ERR_PARM;
2526 }
2527
2528 bcmcli_log("key.sub_term_id = ");
2529 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_SUB_TERM_ID, &key.sub_term_id);
2530 bcmcli_log(";\n");
2531 cli_parm = bcmcli_find_named_parm(session, "intf_id");
2532 if (cli_parm != NULL)
2533 {
2534 key.intf_id = (bcmbal_intf_id) cli_parm->value.unumber;
2535 }
2536 else
2537 {
2538 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
2539 return BCM_ERR_PARM;
2540 }
2541
2542 bcmcli_log("key.intf_id = ");
2543 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_INTF_ID, &key.intf_id);
2544 bcmcli_log(";\n");
2545
2546 /* init the API struct */
2547 BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);
2548 bcmcli_log("BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);\n");
2549
2550 /* decode API parameters from CLI */
2551 cli_parm = bcmcli_find_named_parm(session, "admin_state");
2552 if (cli_parm != NULL)
2553 {
2554 if (cli_parm->value.number)
2555 {
2556 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, admin_state);
2557 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, admin_state);\n");
2558 }
2559 }
2560
2561 cli_parm = bcmcli_find_named_parm(session, "oper_status");
2562 if (cli_parm != NULL)
2563 {
2564 if (cli_parm->value.number)
2565 {
2566 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, oper_status);
2567 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, oper_status);\n");
2568 }
2569 }
2570
2571 cli_parm = bcmcli_find_named_parm(session, "serial_number");
2572 if (cli_parm != NULL)
2573 {
2574 if (cli_parm->value.number)
2575 {
2576 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, serial_number);
2577 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, serial_number);\n");
2578 }
2579 }
2580
2581 cli_parm = bcmcli_find_named_parm(session, "password");
2582 if (cli_parm != NULL)
2583 {
2584 if (cli_parm->value.number)
2585 {
2586 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, password);
2587 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, password);\n");
2588 }
2589 }
2590
2591 cli_parm = bcmcli_find_named_parm(session, "registration_id");
2592 if (cli_parm != NULL)
2593 {
2594 if (cli_parm->value.number)
2595 {
2596 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, registration_id);
2597 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, registration_id);\n");
2598 }
2599 }
2600
2601 cli_parm = bcmcli_find_named_parm(session, "svc_port_id");
2602 if (cli_parm != NULL)
2603 {
2604 if (cli_parm->value.number)
2605 {
2606 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, svc_port_id);
2607 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, svc_port_id);\n");
2608 }
2609 }
2610
2611 cli_parm = bcmcli_find_named_parm(session, "mac_address");
2612 if (cli_parm != NULL)
2613 {
2614 if (cli_parm->value.number)
2615 {
2616 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, mac_address);
2617 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, mac_address);\n");
2618 }
2619 }
2620
2621 cli_parm = bcmcli_find_named_parm(session, "ds_tm");
2622 if (cli_parm != NULL)
2623 {
2624 if (cli_parm->value.number)
2625 {
2626 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, ds_tm);
2627 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, ds_tm);\n");
2628 }
2629 }
2630
2631 cli_parm = bcmcli_find_named_parm(session, "us_tm");
2632 if (cli_parm != NULL)
2633 {
2634 if (cli_parm->value.number)
2635 {
2636 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, us_tm);
2637 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, us_tm);\n");
2638 }
2639 }
2640
2641 cli_parm = bcmcli_find_named_parm(session, "svc_port_id_list");
2642 if (cli_parm != NULL)
2643 {
2644 if (cli_parm->value.number)
2645 {
2646 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, svc_port_id_list);
2647 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, svc_port_id_list);\n");
2648 }
2649 }
2650
2651 cli_parm = bcmcli_find_named_parm(session, "agg_port_id_list");
2652 if (cli_parm != NULL)
2653 {
2654 if (cli_parm->value.number)
2655 {
2656 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, agg_port_id_list);
2657 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, agg_port_id_list);\n");
2658 }
2659 }
2660
2661 /* if no properties were requested, include everything */
2662 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, admin_state) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, oper_status) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, serial_number) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, password) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, registration_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, svc_port_id) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, mac_address) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, ds_tm) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, us_tm) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, svc_port_id_list) && !BCMBAL_CFG_PROP_IS_SET(&cfg, subscriber_terminal, agg_port_id_list))
2663 {
2664 BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, all_properties);
2665 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, subscriber_terminal, all_properties);\n");
2666 }
2667
2668 /* set memory to use for variable-sized lists */
2669 list_mem = bcmbal_apicli_byte_pool_calloc(byte_pool, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
2670 if (list_mem == NULL)
2671 {
2672 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
2673 return BCM_ERR_NOMEM;
2674 }
2675
2676 bcmcli_log("list_mem = bcmos_calloc(BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
2677 BCMBAL_CFG_LIST_BUF_SET(&cfg, subscriber_terminal, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
2678 bcmcli_log("BCMBAL_CFG_LIST_BUF_SET(&cfg, subscriber_terminal, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
2679
2680 /* call API */
2681 err = bcmbal_cfg_get(&cfg.hdr);
2682 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
2683 if (err == BCM_ERR_OK)
2684 {
2685 /* print API contents to the CLI */
2686 bcmbal_apicli_print_data_start(session);
2687 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
2688 }
2689
2690 bcmbal_apicli_print_complete(session, err, NULL);
2691 return err;
2692}
2693
2694/******************************************************************************/
2695static bcmos_errno bcmbal_cli_subscriber_terminal_cfg_set(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
2696{
2697 bcmcli_cmd_parm *cli_parm;
2698 bcmos_errno err;
2699 bcmbal_subscriber_terminal_cfg cfg; /**< declare main API struct */
2700 bcmbal_subscriber_terminal_key key = { }; /**< declare key */
2701 bcmcli_log("bcmbal_subscriber_terminal_cfg cfg;\n");
2702 bcmcli_log("bcmbal_subscriber_terminal_key key = { };\n");
2703 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
2704
2705 /* build key from CLI parameters */
2706 cli_parm = bcmcli_find_named_parm(session, "sub_term_id");
2707 if (cli_parm != NULL)
2708 {
2709 key.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2710 }
2711 else
2712 {
2713 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sub_term_id is not set\n");
2714 return BCM_ERR_PARM;
2715 }
2716
2717 bcmcli_log("key.sub_term_id = ");
2718 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_SUB_TERM_ID, &key.sub_term_id);
2719 bcmcli_log(";\n");
2720 cli_parm = bcmcli_find_named_parm(session, "intf_id");
2721 if (cli_parm != NULL)
2722 {
2723 key.intf_id = (bcmbal_intf_id) cli_parm->value.unumber;
2724 }
2725 else
2726 {
2727 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
2728 return BCM_ERR_PARM;
2729 }
2730
2731 bcmcli_log("key.intf_id = ");
2732 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_INTF_ID, &key.intf_id);
2733 bcmcli_log(";\n");
2734
2735 /* init the API struct */
2736 BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);
2737 bcmcli_log("BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);\n");
2738
2739 /* decode API parameters from CLI */
2740 cli_parm = bcmcli_find_named_parm(session, "admin_state");
2741 if (cli_parm != NULL)
2742 {
2743 bcmbal_state val;
2744 val = (bcmbal_state) cli_parm->value.enum_val;
2745 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, admin_state, val);
2746 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, admin_state, ");
2747 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_ADMIN_STATE, &val);
2748 bcmcli_log(");\n");
2749 }
2750
2751 cli_parm = bcmcli_find_parm_by_prefix(session, "serial_number.");
2752 if (cli_parm != NULL)
2753 {
2754 bcmbal_serial_number val = { };
2755 cli_parm = bcmcli_find_named_parm(session, "serial_number.vendor_id");
2756 if (cli_parm != NULL)
2757 {
2758 if (bcmbal_buf_get_used(&cli_parm->value.buffer) != 4)
2759 {
2760 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "buffer serial_number.vendor_id must have 4 bytes\n");
2761 return BCM_ERR_PARM;
2762 }
2763
2764 bcmbal_buf_set_pos(&cli_parm->value.buffer, 0);
2765 bcmbal_buf_read(&cli_parm->value.buffer, val.vendor_id, 4);
2766 }
2767 else
2768 {
2769 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "serial_number.vendor_id is not set\n");
2770 return BCM_ERR_PARM;
2771 }
2772
2773 cli_parm = bcmcli_find_named_parm(session, "serial_number.vendor_specific");
2774 if (cli_parm != NULL)
2775 {
2776 if (bcmbal_buf_get_used(&cli_parm->value.buffer) != 4)
2777 {
2778 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "buffer serial_number.vendor_specific must have 4 bytes\n");
2779 return BCM_ERR_PARM;
2780 }
2781
2782 bcmbal_buf_set_pos(&cli_parm->value.buffer, 0);
2783 bcmbal_buf_read(&cli_parm->value.buffer, val.vendor_specific, 4);
2784 }
2785 else
2786 {
2787 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "serial_number.vendor_specific is not set\n");
2788 return BCM_ERR_PARM;
2789 }
2790
2791 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, serial_number, val);
2792 bcmcli_log("{\n");
2793 bcmcli_log("bcmbal_serial_number val = ");
2794 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_SERIAL_NUMBER, &val);
2795 bcmcli_log(";\n");
2796 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, serial_number, val);\n");
2797 bcmcli_log("}\n");
2798 }
2799
2800 cli_parm = bcmcli_find_parm_by_prefix(session, "password.");
2801 if (cli_parm != NULL)
2802 {
2803 bcmbal_password val = { };
2804 cli_parm = bcmcli_find_named_parm(session, "password.arr");
2805 if (cli_parm != NULL)
2806 {
2807 if (bcmbal_buf_get_used(&cli_parm->value.buffer) != 10)
2808 {
2809 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "buffer password.arr must have 10 bytes\n");
2810 return BCM_ERR_PARM;
2811 }
2812
2813 bcmbal_buf_set_pos(&cli_parm->value.buffer, 0);
2814 bcmbal_buf_read(&cli_parm->value.buffer, val.arr, 10);
2815 }
2816 else
2817 {
2818 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "password.arr is not set\n");
2819 return BCM_ERR_PARM;
2820 }
2821
2822 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, password, val);
2823 bcmcli_log("{\n");
2824 bcmcli_log("bcmbal_password val = ");
2825 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_PASSWORD, &val);
2826 bcmcli_log(";\n");
2827 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, password, val);\n");
2828 bcmcli_log("}\n");
2829 }
2830
2831 cli_parm = bcmcli_find_parm_by_prefix(session, "registration_id.");
2832 if (cli_parm != NULL)
2833 {
2834 bcmbal_registration_id val = { };
2835 cli_parm = bcmcli_find_named_parm(session, "registration_id.arr");
2836 if (cli_parm != NULL)
2837 {
2838 if (bcmbal_buf_get_used(&cli_parm->value.buffer) != 36)
2839 {
2840 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "buffer registration_id.arr must have 36 bytes\n");
2841 return BCM_ERR_PARM;
2842 }
2843
2844 bcmbal_buf_set_pos(&cli_parm->value.buffer, 0);
2845 bcmbal_buf_read(&cli_parm->value.buffer, val.arr, 36);
2846 }
2847 else
2848 {
2849 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "registration_id.arr is not set\n");
2850 return BCM_ERR_PARM;
2851 }
2852
2853 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, registration_id, val);
2854 bcmcli_log("{\n");
2855 bcmcli_log("bcmbal_registration_id val = ");
2856 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_REGISTRATION_ID, &val);
2857 bcmcli_log(";\n");
2858 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, registration_id, val);\n");
2859 bcmcli_log("}\n");
2860 }
2861
2862 cli_parm = bcmcli_find_named_parm(session, "mac_address");
2863 if (cli_parm != NULL)
2864 {
2865 bcmos_mac_address val;
2866 val = cli_parm->value.mac;
2867 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, mac_address, val);
2868 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, mac_address, ");
2869 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_MAC_ADDRESS, &val);
2870 bcmcli_log(");\n");
2871 }
2872
2873 cli_parm = bcmcli_find_named_parm(session, "ds_tm");
2874 if (cli_parm != NULL)
2875 {
2876 bcmbal_tm_sched_id val;
2877 val = (bcmbal_tm_sched_id) cli_parm->value.unumber;
2878 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, ds_tm, val);
2879 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, ds_tm, ");
2880 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_DS_TM, &val);
2881 bcmcli_log(");\n");
2882 }
2883
2884 cli_parm = bcmcli_find_named_parm(session, "us_tm");
2885 if (cli_parm != NULL)
2886 {
2887 bcmbal_tm_sched_id val;
2888 val = (bcmbal_tm_sched_id) cli_parm->value.unumber;
2889 BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, us_tm, val);
2890 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, subscriber_terminal, us_tm, ");
2891 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_SUBSCRIBER_TERMINAL_CFG_ID_US_TM, &val);
2892 bcmcli_log(");\n");
2893 }
2894
2895 /* call API */
2896 err = bcmbal_cfg_set(&cfg.hdr);
2897 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
2898 bcmbal_apicli_print_complete(session, err, NULL);
2899 return err;
2900}
2901
2902/******************************************************************************/
2903static bcmos_errno bcmbal_cli_subscriber_terminal_cfg_clear(bcmcli_session *session)
2904{
2905 bcmcli_cmd_parm *cli_parm;
2906 bcmos_errno err;
2907 bcmbal_subscriber_terminal_cfg cfg; /**< declare main API struct */
2908 bcmbal_subscriber_terminal_key key = { }; /**< declare key */
2909 bcmcli_log("bcmbal_subscriber_terminal_cfg cfg;\n");
2910 bcmcli_log("bcmbal_subscriber_terminal_key key = { };\n");
2911 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
2912
2913 /* build key from CLI parameters */
2914 cli_parm = bcmcli_find_named_parm(session, "sub_term_id");
2915 if (cli_parm != NULL)
2916 {
2917 key.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2918 }
2919 else
2920 {
2921 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sub_term_id is not set\n");
2922 return BCM_ERR_PARM;
2923 }
2924
2925 bcmcli_log("key.sub_term_id = ");
2926 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_SUB_TERM_ID, &key.sub_term_id);
2927 bcmcli_log(";\n");
2928 cli_parm = bcmcli_find_named_parm(session, "intf_id");
2929 if (cli_parm != NULL)
2930 {
2931 key.intf_id = (bcmbal_intf_id) cli_parm->value.unumber;
2932 }
2933 else
2934 {
2935 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
2936 return BCM_ERR_PARM;
2937 }
2938
2939 bcmcli_log("key.intf_id = ");
2940 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_INTF_ID, &key.intf_id);
2941 bcmcli_log(";\n");
2942
2943 /* init the API struct */
2944 BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);
2945 bcmcli_log("BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);\n");
2946
2947 /* call API */
2948 err = bcmbal_cfg_clear(&cfg.hdr);
2949 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
2950 bcmbal_apicli_print_complete(session, err, NULL);
2951 return err;
2952}
2953
2954/******************************************************************************/
2955static bcmos_errno bcmbal_cli_subscriber_terminal_stat_get(bcmcli_session *session)
2956{
2957 bcmcli_cmd_parm *cli_parm;
2958 bcmos_errno err;
2959 bcmbal_subscriber_terminal_stat stat; /**< declare main API struct */
2960 bcmbal_subscriber_terminal_key key = { }; /**< declare key */
2961 bcmcli_log("bcmbal_subscriber_terminal_stat stat;\n");
2962 bcmcli_log("bcmbal_subscriber_terminal_key key = { };\n");
2963 bcmbal_apicli_print_start(session, "bcmbal_stat_get");
2964
2965 /* build key from CLI parameters */
2966 cli_parm = bcmcli_find_named_parm(session, "sub_term_id");
2967 if (cli_parm != NULL)
2968 {
2969 key.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
2970 }
2971 else
2972 {
2973 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sub_term_id is not set\n");
2974 return BCM_ERR_PARM;
2975 }
2976
2977 bcmcli_log("key.sub_term_id = ");
2978 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_SUB_TERM_ID, &key.sub_term_id);
2979 bcmcli_log(";\n");
2980 cli_parm = bcmcli_find_named_parm(session, "intf_id");
2981 if (cli_parm != NULL)
2982 {
2983 key.intf_id = (bcmbal_intf_id) cli_parm->value.unumber;
2984 }
2985 else
2986 {
2987 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "intf_id is not set\n");
2988 return BCM_ERR_PARM;
2989 }
2990
2991 bcmcli_log("key.intf_id = ");
2992 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_SUBSCRIBER_TERMINAL_KEY_ID_INTF_ID, &key.intf_id);
2993 bcmcli_log(";\n");
2994
2995 /* init the API struct */
2996 BCMBAL_STAT_INIT(&stat, subscriber_terminal, key);
2997 bcmcli_log("BCMBAL_STAT_INIT(&stat, subscriber_terminal, key);\n");
2998
2999 /* decode API parameters from CLI */
3000 cli_parm = bcmcli_find_named_parm(session, "rx_packets");
3001 if (cli_parm != NULL)
3002 {
3003 if (cli_parm->value.number)
3004 {
3005 BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, rx_packets);
3006 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, rx_packets);\n");
3007 }
3008 }
3009
3010 cli_parm = bcmcli_find_named_parm(session, "rx_bytes");
3011 if (cli_parm != NULL)
3012 {
3013 if (cli_parm->value.number)
3014 {
3015 BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, rx_bytes);
3016 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, rx_bytes);\n");
3017 }
3018 }
3019
3020 cli_parm = bcmcli_find_named_parm(session, "tx_packets");
3021 if (cli_parm != NULL)
3022 {
3023 if (cli_parm->value.number)
3024 {
3025 BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, tx_packets);
3026 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, tx_packets);\n");
3027 }
3028 }
3029
3030 cli_parm = bcmcli_find_named_parm(session, "tx_bytes");
3031 if (cli_parm != NULL)
3032 {
3033 if (cli_parm->value.number)
3034 {
3035 BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, tx_bytes);
3036 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, tx_bytes);\n");
3037 }
3038 }
3039
3040 /* if no properties were requested, include everything */
3041 if (!BCMBAL_STAT_PROP_IS_SET(&stat, subscriber_terminal, rx_packets) && !BCMBAL_STAT_PROP_IS_SET(&stat, subscriber_terminal, rx_bytes) && !BCMBAL_STAT_PROP_IS_SET(&stat, subscriber_terminal, tx_packets) && !BCMBAL_STAT_PROP_IS_SET(&stat, subscriber_terminal, tx_bytes))
3042 {
3043 BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, all_properties);
3044 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, subscriber_terminal, all_properties);\n");
3045 }
3046
3047 /* call API */
3048 err = bcmbal_stat_get(&stat.hdr);
3049 bcmcli_log("bcmbal_stat_get(&stat.hdr);\n");
3050 if (err == BCM_ERR_OK)
3051 {
3052 /* print API contents to the CLI */
3053 bcmbal_apicli_print_data_start(session);
3054 err = bcmbal_apicli_msg_dump(session, &stat.hdr.hdr);
3055 }
3056
3057 bcmbal_apicli_print_complete(session, err, NULL);
3058 return err;
3059}
3060
3061/******************************************************************************/
3062static bcmos_errno bcmbal_cli_tm_queue_cfg_get(bcmcli_session *session)
3063{
3064 bcmcli_cmd_parm *cli_parm;
3065 bcmos_errno err;
3066 bcmbal_tm_queue_cfg cfg; /**< declare main API struct */
3067 bcmbal_tm_queue_key key = { }; /**< declare key */
3068 bcmcli_log("bcmbal_tm_queue_cfg cfg;\n");
3069 bcmcli_log("bcmbal_tm_queue_key key = { };\n");
3070 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
3071
3072 /* build key from CLI parameters */
3073 cli_parm = bcmcli_find_named_parm(session, "sched_id");
3074 if (cli_parm != NULL)
3075 {
3076 key.sched_id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
3077 }
3078 else
3079 {
3080 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_id is not set\n");
3081 return BCM_ERR_PARM;
3082 }
3083
3084 bcmcli_log("key.sched_id = ");
3085 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_ID, &key.sched_id);
3086 bcmcli_log(";\n");
3087 cli_parm = bcmcli_find_named_parm(session, "sched_dir");
3088 if (cli_parm != NULL)
3089 {
3090 key.sched_dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
3091 }
3092 else
3093 {
3094 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_dir is not set\n");
3095 return BCM_ERR_PARM;
3096 }
3097
3098 bcmcli_log("key.sched_dir = ");
3099 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_DIR, &key.sched_dir);
3100 bcmcli_log(";\n");
3101 cli_parm = bcmcli_find_named_parm(session, "id");
3102 if (cli_parm != NULL)
3103 {
3104 key.id = (bcmbal_tm_queue_id) cli_parm->value.unumber;
3105 }
3106 else
3107 {
3108 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
3109 return BCM_ERR_PARM;
3110 }
3111
3112 bcmcli_log("key.id = ");
3113 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_ID, &key.id);
3114 bcmcli_log(";\n");
3115
3116 /* init the API struct */
3117 BCMBAL_CFG_INIT(&cfg, tm_queue, key);
3118 bcmcli_log("BCMBAL_CFG_INIT(&cfg, tm_queue, key);\n");
3119
3120 /* decode API parameters from CLI */
3121 cli_parm = bcmcli_find_named_parm(session, "priority");
3122 if (cli_parm != NULL)
3123 {
3124 if (cli_parm->value.number)
3125 {
3126 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, priority);
3127 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, priority);\n");
3128 }
3129 }
3130
3131 cli_parm = bcmcli_find_named_parm(session, "weight");
3132 if (cli_parm != NULL)
3133 {
3134 if (cli_parm->value.number)
3135 {
3136 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, weight);
3137 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, weight);\n");
3138 }
3139 }
3140
3141 cli_parm = bcmcli_find_named_parm(session, "rate");
3142 if (cli_parm != NULL)
3143 {
3144 if (cli_parm->value.number)
3145 {
3146 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, rate);
3147 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, rate);\n");
3148 }
3149 }
3150
3151 cli_parm = bcmcli_find_named_parm(session, "bac");
3152 if (cli_parm != NULL)
3153 {
3154 if (cli_parm->value.number)
3155 {
3156 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, bac);
3157 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, bac);\n");
3158 }
3159 }
3160
3161 cli_parm = bcmcli_find_named_parm(session, "creation_mode");
3162 if (cli_parm != NULL)
3163 {
3164 if (cli_parm->value.number)
3165 {
3166 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, creation_mode);
3167 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, creation_mode);\n");
3168 }
3169 }
3170
3171 cli_parm = bcmcli_find_named_parm(session, "ref_count");
3172 if (cli_parm != NULL)
3173 {
3174 if (cli_parm->value.number)
3175 {
3176 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, ref_count);
3177 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, ref_count);\n");
3178 }
3179 }
3180
3181 /* if no properties were requested, include everything */
3182 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, tm_queue, priority) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_queue, weight) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_queue, rate) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_queue, bac) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_queue, creation_mode) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_queue, ref_count))
3183 {
3184 BCMBAL_CFG_PROP_GET(&cfg, tm_queue, all_properties);
3185 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_queue, all_properties);\n");
3186 }
3187
3188 /* call API */
3189 err = bcmbal_cfg_get(&cfg.hdr);
3190 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
3191 if (err == BCM_ERR_OK)
3192 {
3193 /* print API contents to the CLI */
3194 bcmbal_apicli_print_data_start(session);
3195 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
3196 }
3197
3198 bcmbal_apicli_print_complete(session, err, NULL);
3199 return err;
3200}
3201
3202/******************************************************************************/
3203static bcmos_errno bcmbal_cli_tm_queue_cfg_set(bcmcli_session *session)
3204{
3205 bcmcli_cmd_parm *cli_parm;
3206 bcmos_errno err;
3207 bcmbal_tm_queue_cfg cfg; /**< declare main API struct */
3208 bcmbal_tm_queue_key key = { }; /**< declare key */
3209 bcmcli_log("bcmbal_tm_queue_cfg cfg;\n");
3210 bcmcli_log("bcmbal_tm_queue_key key = { };\n");
3211 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
3212
3213 /* build key from CLI parameters */
3214 cli_parm = bcmcli_find_named_parm(session, "sched_id");
3215 if (cli_parm != NULL)
3216 {
3217 key.sched_id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
3218 }
3219 else
3220 {
3221 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_id is not set\n");
3222 return BCM_ERR_PARM;
3223 }
3224
3225 bcmcli_log("key.sched_id = ");
3226 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_ID, &key.sched_id);
3227 bcmcli_log(";\n");
3228 cli_parm = bcmcli_find_named_parm(session, "sched_dir");
3229 if (cli_parm != NULL)
3230 {
3231 key.sched_dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
3232 }
3233 else
3234 {
3235 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_dir is not set\n");
3236 return BCM_ERR_PARM;
3237 }
3238
3239 bcmcli_log("key.sched_dir = ");
3240 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_DIR, &key.sched_dir);
3241 bcmcli_log(";\n");
3242 cli_parm = bcmcli_find_named_parm(session, "id");
3243 if (cli_parm != NULL)
3244 {
3245 key.id = (bcmbal_tm_queue_id) cli_parm->value.unumber;
3246 }
3247 else
3248 {
3249 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
3250 return BCM_ERR_PARM;
3251 }
3252
3253 bcmcli_log("key.id = ");
3254 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_ID, &key.id);
3255 bcmcli_log(";\n");
3256
3257 /* init the API struct */
3258 BCMBAL_CFG_INIT(&cfg, tm_queue, key);
3259 bcmcli_log("BCMBAL_CFG_INIT(&cfg, tm_queue, key);\n");
3260
3261 /* decode API parameters from CLI */
3262 cli_parm = bcmcli_find_named_parm(session, "priority");
3263 if (cli_parm != NULL)
3264 {
3265 bcmbal_tm_priority val;
3266 val = (bcmbal_tm_priority) cli_parm->value.unumber;
3267 BCMBAL_CFG_PROP_SET(&cfg, tm_queue, priority, val);
3268 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_queue, priority, ");
3269 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_QUEUE_CFG_ID_PRIORITY, &val);
3270 bcmcli_log(");\n");
3271 }
3272
3273 cli_parm = bcmcli_find_named_parm(session, "weight");
3274 if (cli_parm != NULL)
3275 {
3276 bcmbal_tm_weight val;
3277 val = (bcmbal_tm_weight) cli_parm->value.unumber;
3278 BCMBAL_CFG_PROP_SET(&cfg, tm_queue, weight, val);
3279 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_queue, weight, ");
3280 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_QUEUE_CFG_ID_WEIGHT, &val);
3281 bcmcli_log(");\n");
3282 }
3283
3284 cli_parm = bcmcli_find_parm_by_prefix(session, "rate.");
3285 if (cli_parm != NULL)
3286 {
3287 bcmbal_tm_shaping val = { };
3288 cli_parm = bcmcli_find_named_parm(session, "rate.sbr");
3289 if (cli_parm != NULL)
3290 {
3291 val.sbr = cli_parm->value.unumber;
3292 val.presence_mask = val.presence_mask | BCMBAL_TM_SHAPING_ID_SBR;
3293 }
3294
3295 cli_parm = bcmcli_find_named_parm(session, "rate.pbr");
3296 if (cli_parm != NULL)
3297 {
3298 val.pbr = cli_parm->value.unumber;
3299 val.presence_mask = val.presence_mask | BCMBAL_TM_SHAPING_ID_PBR;
3300 }
3301
3302 cli_parm = bcmcli_find_named_parm(session, "rate.burst");
3303 if (cli_parm != NULL)
3304 {
3305 val.burst = cli_parm->value.unumber;
3306 val.presence_mask = val.presence_mask | BCMBAL_TM_SHAPING_ID_BURST;
3307 }
3308
3309 BCMBAL_CFG_PROP_SET(&cfg, tm_queue, rate, val);
3310 bcmcli_log("{\n");
3311 bcmcli_log("bcmbal_tm_shaping val = ");
3312 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_QUEUE_CFG_ID_RATE, &val);
3313 bcmcli_log(";\n");
3314 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_queue, rate, val);\n");
3315 bcmcli_log("}\n");
3316 }
3317
3318 cli_parm = bcmcli_find_parm_by_prefix(session, "bac.");
3319 if (cli_parm != NULL)
3320 {
3321 bcmbal_tm_bac val = { };
3322 cli_parm = bcmcli_find_named_parm(session, "bac.type");
3323 if (cli_parm != NULL)
3324 {
3325 val.type = (bcmbal_tm_bac_type) cli_parm->value.enum_val;
3326 }
3327 else
3328 {
3329 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.type is not set\n");
3330 return BCM_ERR_PARM;
3331 }
3332
3333 switch (val.type)
3334 {
3335 case BCMBAL_TM_BAC_TYPE_TAILDROP:
3336 cli_parm = bcmcli_find_named_parm(session, "bac.max_size");
3337 if (cli_parm != NULL)
3338 {
3339 val.u.taildrop.max_size = cli_parm->value.unumber;
3340 }
3341 else
3342 {
3343 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.max_size is not set\n");
3344 return BCM_ERR_PARM;
3345 }
3346 break;
3347 case BCMBAL_TM_BAC_TYPE_RED:
3348 cli_parm = bcmcli_find_parm_by_prefix(session, "bac.red.");
3349 if (cli_parm != NULL)
3350 {
3351 cli_parm = bcmcli_find_named_parm(session, "bac.red.min_threshold");
3352 if (cli_parm != NULL)
3353 {
3354 val.u.red.red.min_threshold = (bcmbal_percent) cli_parm->value.unumber;
3355 }
3356 else
3357 {
3358 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red.min_threshold is not set\n");
3359 return BCM_ERR_PARM;
3360 }
3361
3362 cli_parm = bcmcli_find_named_parm(session, "bac.red.max_threshold");
3363 if (cli_parm != NULL)
3364 {
3365 val.u.red.red.max_threshold = (bcmbal_percent) cli_parm->value.unumber;
3366 }
3367 else
3368 {
3369 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red.max_threshold is not set\n");
3370 return BCM_ERR_PARM;
3371 }
3372
3373 cli_parm = bcmcli_find_named_parm(session, "bac.red.max_probability");
3374 if (cli_parm != NULL)
3375 {
3376 val.u.red.red.max_probability = (bcmbal_percent) cli_parm->value.unumber;
3377 }
3378 else
3379 {
3380 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red.max_probability is not set\n");
3381 return BCM_ERR_PARM;
3382 }
3383 }
3384 else
3385 {
3386 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red is not set\n");
3387 return BCM_ERR_PARM;
3388 }
3389 break;
3390 case BCMBAL_TM_BAC_TYPE_WRED:
3391 cli_parm = bcmcli_find_parm_by_prefix(session, "bac.green.");
3392 if (cli_parm != NULL)
3393 {
3394 cli_parm = bcmcli_find_named_parm(session, "bac.green.min_threshold");
3395 if (cli_parm != NULL)
3396 {
3397 val.u.wred.green.min_threshold = (bcmbal_percent) cli_parm->value.unumber;
3398 }
3399 else
3400 {
3401 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.green.min_threshold is not set\n");
3402 return BCM_ERR_PARM;
3403 }
3404
3405 cli_parm = bcmcli_find_named_parm(session, "bac.green.max_threshold");
3406 if (cli_parm != NULL)
3407 {
3408 val.u.wred.green.max_threshold = (bcmbal_percent) cli_parm->value.unumber;
3409 }
3410 else
3411 {
3412 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.green.max_threshold is not set\n");
3413 return BCM_ERR_PARM;
3414 }
3415
3416 cli_parm = bcmcli_find_named_parm(session, "bac.green.max_probability");
3417 if (cli_parm != NULL)
3418 {
3419 val.u.wred.green.max_probability = (bcmbal_percent) cli_parm->value.unumber;
3420 }
3421 else
3422 {
3423 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.green.max_probability is not set\n");
3424 return BCM_ERR_PARM;
3425 }
3426 }
3427 else
3428 {
3429 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.green is not set\n");
3430 return BCM_ERR_PARM;
3431 }
3432
3433 cli_parm = bcmcli_find_parm_by_prefix(session, "bac.yellow.");
3434 if (cli_parm != NULL)
3435 {
3436 cli_parm = bcmcli_find_named_parm(session, "bac.yellow.min_threshold");
3437 if (cli_parm != NULL)
3438 {
3439 val.u.wred.yellow.min_threshold = (bcmbal_percent) cli_parm->value.unumber;
3440 }
3441 else
3442 {
3443 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.yellow.min_threshold is not set\n");
3444 return BCM_ERR_PARM;
3445 }
3446
3447 cli_parm = bcmcli_find_named_parm(session, "bac.yellow.max_threshold");
3448 if (cli_parm != NULL)
3449 {
3450 val.u.wred.yellow.max_threshold = (bcmbal_percent) cli_parm->value.unumber;
3451 }
3452 else
3453 {
3454 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.yellow.max_threshold is not set\n");
3455 return BCM_ERR_PARM;
3456 }
3457
3458 cli_parm = bcmcli_find_named_parm(session, "bac.yellow.max_probability");
3459 if (cli_parm != NULL)
3460 {
3461 val.u.wred.yellow.max_probability = (bcmbal_percent) cli_parm->value.unumber;
3462 }
3463 else
3464 {
3465 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.yellow.max_probability is not set\n");
3466 return BCM_ERR_PARM;
3467 }
3468 }
3469 else
3470 {
3471 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.yellow is not set\n");
3472 return BCM_ERR_PARM;
3473 }
3474
3475 cli_parm = bcmcli_find_parm_by_prefix(session, "bac.red.");
3476 if (cli_parm != NULL)
3477 {
3478 cli_parm = bcmcli_find_named_parm(session, "bac.red.min_threshold");
3479 if (cli_parm != NULL)
3480 {
3481 val.u.wred.red.min_threshold = (bcmbal_percent) cli_parm->value.unumber;
3482 }
3483 else
3484 {
3485 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red.min_threshold is not set\n");
3486 return BCM_ERR_PARM;
3487 }
3488
3489 cli_parm = bcmcli_find_named_parm(session, "bac.red.max_threshold");
3490 if (cli_parm != NULL)
3491 {
3492 val.u.wred.red.max_threshold = (bcmbal_percent) cli_parm->value.unumber;
3493 }
3494 else
3495 {
3496 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red.max_threshold is not set\n");
3497 return BCM_ERR_PARM;
3498 }
3499
3500 cli_parm = bcmcli_find_named_parm(session, "bac.red.max_probability");
3501 if (cli_parm != NULL)
3502 {
3503 val.u.wred.red.max_probability = (bcmbal_percent) cli_parm->value.unumber;
3504 }
3505 else
3506 {
3507 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red.max_probability is not set\n");
3508 return BCM_ERR_PARM;
3509 }
3510 }
3511 else
3512 {
3513 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "bac.red is not set\n");
3514 return BCM_ERR_PARM;
3515 }
3516 break;
3517 default:
3518 bcmbal_apicli_print_complete(session, BCM_ERR_RANGE, "\n");
3519 return BCM_ERR_RANGE;
3520 }
3521
3522 BCMBAL_CFG_PROP_SET(&cfg, tm_queue, bac, val);
3523 bcmcli_log("{\n");
3524 bcmcli_log("bcmbal_tm_bac val = ");
3525 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_QUEUE_CFG_ID_BAC, &val);
3526 bcmcli_log(";\n");
3527 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_queue, bac, val);\n");
3528 bcmcli_log("}\n");
3529 }
3530
3531 /* call API */
3532 err = bcmbal_cfg_set(&cfg.hdr);
3533 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
3534 bcmbal_apicli_print_complete(session, err, NULL);
3535 return err;
3536}
3537
3538/******************************************************************************/
3539static bcmos_errno bcmbal_cli_tm_queue_cfg_clear(bcmcli_session *session)
3540{
3541 bcmcli_cmd_parm *cli_parm;
3542 bcmos_errno err;
3543 bcmbal_tm_queue_cfg cfg; /**< declare main API struct */
3544 bcmbal_tm_queue_key key = { }; /**< declare key */
3545 bcmcli_log("bcmbal_tm_queue_cfg cfg;\n");
3546 bcmcli_log("bcmbal_tm_queue_key key = { };\n");
3547 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
3548
3549 /* build key from CLI parameters */
3550 cli_parm = bcmcli_find_named_parm(session, "sched_id");
3551 if (cli_parm != NULL)
3552 {
3553 key.sched_id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
3554 }
3555 else
3556 {
3557 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_id is not set\n");
3558 return BCM_ERR_PARM;
3559 }
3560
3561 bcmcli_log("key.sched_id = ");
3562 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_ID, &key.sched_id);
3563 bcmcli_log(";\n");
3564 cli_parm = bcmcli_find_named_parm(session, "sched_dir");
3565 if (cli_parm != NULL)
3566 {
3567 key.sched_dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
3568 }
3569 else
3570 {
3571 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_dir is not set\n");
3572 return BCM_ERR_PARM;
3573 }
3574
3575 bcmcli_log("key.sched_dir = ");
3576 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_DIR, &key.sched_dir);
3577 bcmcli_log(";\n");
3578 cli_parm = bcmcli_find_named_parm(session, "id");
3579 if (cli_parm != NULL)
3580 {
3581 key.id = (bcmbal_tm_queue_id) cli_parm->value.unumber;
3582 }
3583 else
3584 {
3585 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
3586 return BCM_ERR_PARM;
3587 }
3588
3589 bcmcli_log("key.id = ");
3590 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_ID, &key.id);
3591 bcmcli_log(";\n");
3592
3593 /* init the API struct */
3594 BCMBAL_CFG_INIT(&cfg, tm_queue, key);
3595 bcmcli_log("BCMBAL_CFG_INIT(&cfg, tm_queue, key);\n");
3596
3597 /* call API */
3598 err = bcmbal_cfg_clear(&cfg.hdr);
3599 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
3600 bcmbal_apicli_print_complete(session, err, NULL);
3601 return err;
3602}
3603
3604/******************************************************************************/
3605static bcmos_errno bcmbal_cli_tm_queue_stat_get(bcmcli_session *session)
3606{
3607 bcmcli_cmd_parm *cli_parm;
3608 bcmos_errno err;
3609 bcmbal_tm_queue_stat stat; /**< declare main API struct */
3610 bcmbal_tm_queue_key key = { }; /**< declare key */
3611 bcmcli_log("bcmbal_tm_queue_stat stat;\n");
3612 bcmcli_log("bcmbal_tm_queue_key key = { };\n");
3613 bcmbal_apicli_print_start(session, "bcmbal_stat_get");
3614
3615 /* build key from CLI parameters */
3616 cli_parm = bcmcli_find_named_parm(session, "sched_id");
3617 if (cli_parm != NULL)
3618 {
3619 key.sched_id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
3620 }
3621 else
3622 {
3623 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_id is not set\n");
3624 return BCM_ERR_PARM;
3625 }
3626
3627 bcmcli_log("key.sched_id = ");
3628 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_ID, &key.sched_id);
3629 bcmcli_log(";\n");
3630 cli_parm = bcmcli_find_named_parm(session, "sched_dir");
3631 if (cli_parm != NULL)
3632 {
3633 key.sched_dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
3634 }
3635 else
3636 {
3637 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "sched_dir is not set\n");
3638 return BCM_ERR_PARM;
3639 }
3640
3641 bcmcli_log("key.sched_dir = ");
3642 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_SCHED_DIR, &key.sched_dir);
3643 bcmcli_log(";\n");
3644 cli_parm = bcmcli_find_named_parm(session, "id");
3645 if (cli_parm != NULL)
3646 {
3647 key.id = (bcmbal_tm_queue_id) cli_parm->value.unumber;
3648 }
3649 else
3650 {
3651 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
3652 return BCM_ERR_PARM;
3653 }
3654
3655 bcmcli_log("key.id = ");
3656 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_QUEUE, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_QUEUE_KEY_ID_ID, &key.id);
3657 bcmcli_log(";\n");
3658
3659 /* init the API struct */
3660 BCMBAL_STAT_INIT(&stat, tm_queue, key);
3661 bcmcli_log("BCMBAL_STAT_INIT(&stat, tm_queue, key);\n");
3662
3663 /* decode API parameters from CLI */
3664 cli_parm = bcmcli_find_named_parm(session, "packets_ok");
3665 if (cli_parm != NULL)
3666 {
3667 if (cli_parm->value.number)
3668 {
3669 BCMBAL_STAT_PROP_GET(&stat, tm_queue, packets_ok);
3670 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, tm_queue, packets_ok);\n");
3671 }
3672 }
3673
3674 cli_parm = bcmcli_find_named_parm(session, "bytes_ok");
3675 if (cli_parm != NULL)
3676 {
3677 if (cli_parm->value.number)
3678 {
3679 BCMBAL_STAT_PROP_GET(&stat, tm_queue, bytes_ok);
3680 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, tm_queue, bytes_ok);\n");
3681 }
3682 }
3683
3684 cli_parm = bcmcli_find_named_parm(session, "packets_discarded");
3685 if (cli_parm != NULL)
3686 {
3687 if (cli_parm->value.number)
3688 {
3689 BCMBAL_STAT_PROP_GET(&stat, tm_queue, packets_discarded);
3690 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, tm_queue, packets_discarded);\n");
3691 }
3692 }
3693
3694 cli_parm = bcmcli_find_named_parm(session, "bytes_discarded");
3695 if (cli_parm != NULL)
3696 {
3697 if (cli_parm->value.number)
3698 {
3699 BCMBAL_STAT_PROP_GET(&stat, tm_queue, bytes_discarded);
3700 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, tm_queue, bytes_discarded);\n");
3701 }
3702 }
3703
3704 /* if no properties were requested, include everything */
3705 if (!BCMBAL_STAT_PROP_IS_SET(&stat, tm_queue, packets_ok) && !BCMBAL_STAT_PROP_IS_SET(&stat, tm_queue, bytes_ok) && !BCMBAL_STAT_PROP_IS_SET(&stat, tm_queue, packets_discarded) && !BCMBAL_STAT_PROP_IS_SET(&stat, tm_queue, bytes_discarded))
3706 {
3707 BCMBAL_STAT_PROP_GET(&stat, tm_queue, all_properties);
3708 bcmcli_log("BCMBAL_STAT_PROP_GET(&stat, tm_queue, all_properties);\n");
3709 }
3710
3711 /* call API */
3712 err = bcmbal_stat_get(&stat.hdr);
3713 bcmcli_log("bcmbal_stat_get(&stat.hdr);\n");
3714 if (err == BCM_ERR_OK)
3715 {
3716 /* print API contents to the CLI */
3717 bcmbal_apicli_print_data_start(session);
3718 err = bcmbal_apicli_msg_dump(session, &stat.hdr.hdr);
3719 }
3720
3721 bcmbal_apicli_print_complete(session, err, NULL);
3722 return err;
3723}
3724
3725/******************************************************************************/
3726static bcmos_errno bcmbal_cli_tm_sched_cfg_get(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
3727{
3728 bcmcli_cmd_parm *cli_parm;
3729 bcmos_errno err;
3730 bcmbal_tm_sched_cfg cfg; /**< declare main API struct */
3731 bcmbal_tm_sched_key key = { }; /**< declare key */
3732 uint8_t *list_mem; /**< declare memory buffer for variable-sized lists */
3733 bcmcli_log("bcmbal_tm_sched_cfg cfg;\n");
3734 bcmcli_log("bcmbal_tm_sched_key key = { };\n");
3735 bcmcli_log("uint8_t* list_mem;\n");
3736 bcmbal_apicli_print_start(session, "bcmbal_cfg_get");
3737
3738 /* build key from CLI parameters */
3739 cli_parm = bcmcli_find_named_parm(session, "dir");
3740 if (cli_parm != NULL)
3741 {
3742 key.dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
3743 }
3744 else
3745 {
3746 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "dir is not set\n");
3747 return BCM_ERR_PARM;
3748 }
3749
3750 bcmcli_log("key.dir = ");
3751 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_SCHED_KEY_ID_DIR, &key.dir);
3752 bcmcli_log(";\n");
3753 cli_parm = bcmcli_find_named_parm(session, "id");
3754 if (cli_parm != NULL)
3755 {
3756 key.id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
3757 }
3758 else
3759 {
3760 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
3761 return BCM_ERR_PARM;
3762 }
3763
3764 bcmcli_log("key.id = ");
3765 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_SCHED_KEY_ID_ID, &key.id);
3766 bcmcli_log(";\n");
3767
3768 /* init the API struct */
3769 BCMBAL_CFG_INIT(&cfg, tm_sched, key);
3770 bcmcli_log("BCMBAL_CFG_INIT(&cfg, tm_sched, key);\n");
3771
3772 /* decode API parameters from CLI */
3773 cli_parm = bcmcli_find_named_parm(session, "owner");
3774 if (cli_parm != NULL)
3775 {
3776 if (cli_parm->value.number)
3777 {
3778 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, owner);
3779 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, owner);\n");
3780 }
3781 }
3782
3783 cli_parm = bcmcli_find_named_parm(session, "sched_type");
3784 if (cli_parm != NULL)
3785 {
3786 if (cli_parm->value.number)
3787 {
3788 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sched_type);
3789 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sched_type);\n");
3790 }
3791 }
3792
3793 cli_parm = bcmcli_find_named_parm(session, "sched_parent");
3794 if (cli_parm != NULL)
3795 {
3796 if (cli_parm->value.number)
3797 {
3798 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sched_parent);
3799 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sched_parent);\n");
3800 }
3801 }
3802
3803 cli_parm = bcmcli_find_named_parm(session, "sched_child_type");
3804 if (cli_parm != NULL)
3805 {
3806 if (cli_parm->value.number)
3807 {
3808 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sched_child_type);
3809 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sched_child_type);\n");
3810 }
3811 }
3812
3813 cli_parm = bcmcli_find_named_parm(session, "rate");
3814 if (cli_parm != NULL)
3815 {
3816 if (cli_parm->value.number)
3817 {
3818 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, rate);
3819 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, rate);\n");
3820 }
3821 }
3822
3823 cli_parm = bcmcli_find_named_parm(session, "tcont_sla");
3824 if (cli_parm != NULL)
3825 {
3826 if (cli_parm->value.number)
3827 {
3828 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, tcont_sla);
3829 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, tcont_sla);\n");
3830 }
3831 }
3832
3833 cli_parm = bcmcli_find_named_parm(session, "creation_mode");
3834 if (cli_parm != NULL)
3835 {
3836 if (cli_parm->value.number)
3837 {
3838 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, creation_mode);
3839 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, creation_mode);\n");
3840 }
3841 }
3842
3843 cli_parm = bcmcli_find_named_parm(session, "queues");
3844 if (cli_parm != NULL)
3845 {
3846 if (cli_parm->value.number)
3847 {
3848 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, queues);
3849 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, queues);\n");
3850 }
3851 }
3852
3853 cli_parm = bcmcli_find_named_parm(session, "sub_scheds");
3854 if (cli_parm != NULL)
3855 {
3856 if (cli_parm->value.number)
3857 {
3858 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sub_scheds);
3859 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, sub_scheds);\n");
3860 }
3861 }
3862
3863 cli_parm = bcmcli_find_named_parm(session, "num_priorities");
3864 if (cli_parm != NULL)
3865 {
3866 if (cli_parm->value.number)
3867 {
3868 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, num_priorities);
3869 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, num_priorities);\n");
3870 }
3871 }
3872
3873 /* if no properties were requested, include everything */
3874 if (!BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, owner) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, sched_type) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, sched_parent) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, sched_child_type) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, rate) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, tcont_sla) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, creation_mode) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, queues) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, sub_scheds) && !BCMBAL_CFG_PROP_IS_SET(&cfg, tm_sched, num_priorities))
3875 {
3876 BCMBAL_CFG_PROP_GET(&cfg, tm_sched, all_properties);
3877 bcmcli_log("BCMBAL_CFG_PROP_GET(&cfg, tm_sched, all_properties);\n");
3878 }
3879
3880 /* set memory to use for variable-sized lists */
3881 list_mem = bcmbal_apicli_byte_pool_calloc(byte_pool, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
3882 if (list_mem == NULL)
3883 {
3884 bcmbal_apicli_print_complete(session, BCM_ERR_NOMEM, "\n");
3885 return BCM_ERR_NOMEM;
3886 }
3887
3888 bcmcli_log("list_mem = bcmos_calloc(BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
3889 BCMBAL_CFG_LIST_BUF_SET(&cfg, tm_sched, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);
3890 bcmcli_log("BCMBAL_CFG_LIST_BUF_SET(&cfg, tm_sched, list_mem, BCMBAL_APICLI_DYNAMIC_LIST_BUFFER_SIZE);\n");
3891
3892 /* call API */
3893 err = bcmbal_cfg_get(&cfg.hdr);
3894 bcmcli_log("bcmbal_cfg_get(&cfg.hdr);\n");
3895 if (err == BCM_ERR_OK)
3896 {
3897 /* print API contents to the CLI */
3898 bcmbal_apicli_print_data_start(session);
3899 err = bcmbal_apicli_msg_dump(session, &cfg.hdr.hdr);
3900 }
3901
3902 bcmbal_apicli_print_complete(session, err, NULL);
3903 return err;
3904}
3905
3906/******************************************************************************/
3907static bcmos_errno bcmbal_cli_tm_sched_cfg_set(bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
3908{
3909 bcmcli_cmd_parm *cli_parm;
3910 bcmos_errno err;
3911 bcmbal_tm_sched_cfg cfg; /**< declare main API struct */
3912 bcmbal_tm_sched_key key = { }; /**< declare key */
3913 bcmcli_log("bcmbal_tm_sched_cfg cfg;\n");
3914 bcmcli_log("bcmbal_tm_sched_key key = { };\n");
3915 bcmbal_apicli_print_start(session, "bcmbal_cfg_set");
3916
3917 /* build key from CLI parameters */
3918 cli_parm = bcmcli_find_named_parm(session, "dir");
3919 if (cli_parm != NULL)
3920 {
3921 key.dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
3922 }
3923 else
3924 {
3925 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "dir is not set\n");
3926 return BCM_ERR_PARM;
3927 }
3928
3929 bcmcli_log("key.dir = ");
3930 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_SCHED_KEY_ID_DIR, &key.dir);
3931 bcmcli_log(";\n");
3932 cli_parm = bcmcli_find_named_parm(session, "id");
3933 if (cli_parm != NULL)
3934 {
3935 key.id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
3936 }
3937 else
3938 {
3939 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
3940 return BCM_ERR_PARM;
3941 }
3942
3943 bcmcli_log("key.id = ");
3944 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_SCHED_KEY_ID_ID, &key.id);
3945 bcmcli_log(";\n");
3946
3947 /* init the API struct */
3948 BCMBAL_CFG_INIT(&cfg, tm_sched, key);
3949 bcmcli_log("BCMBAL_CFG_INIT(&cfg, tm_sched, key);\n");
3950
3951 /* decode API parameters from CLI */
3952 cli_parm = bcmcli_find_parm_by_prefix(session, "owner.");
3953 if (cli_parm != NULL)
3954 {
3955 bcmbal_tm_sched_owner val = { };
3956 cli_parm = bcmcli_find_named_parm(session, "owner.type");
3957 if (cli_parm != NULL)
3958 {
3959 val.type = (bcmbal_tm_sched_owner_type) cli_parm->value.enum_val;
3960 }
3961 else
3962 {
3963 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.type is not set\n");
3964 return BCM_ERR_PARM;
3965 }
3966
3967 switch (val.type)
3968 {
3969 case BCMBAL_TM_SCHED_OWNER_TYPE_INTERFACE:
3970 cli_parm = bcmcli_find_named_parm(session, "owner.intf_type");
3971 if (cli_parm != NULL)
3972 {
3973 val.u.interface.intf_type = (bcmbal_intf_type) cli_parm->value.enum_val;
3974 }
3975 else
3976 {
3977 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.intf_type is not set\n");
3978 return BCM_ERR_PARM;
3979 }
3980
3981 cli_parm = bcmcli_find_named_parm(session, "owner.intf_id");
3982 if (cli_parm != NULL)
3983 {
3984 val.u.interface.intf_id = (bcmbal_intf_id) cli_parm->value.unumber;
3985 }
3986 else
3987 {
3988 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.intf_id is not set\n");
3989 return BCM_ERR_PARM;
3990 }
3991 break;
3992 case BCMBAL_TM_SCHED_OWNER_TYPE_SUB_TERM:
3993 cli_parm = bcmcli_find_named_parm(session, "owner.intf_id");
3994 if (cli_parm != NULL)
3995 {
3996 val.u.sub_term.intf_id = (bcmbal_intf_id) cli_parm->value.unumber;
3997 }
3998 else
3999 {
4000 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.intf_id is not set\n");
4001 return BCM_ERR_PARM;
4002 }
4003
4004 cli_parm = bcmcli_find_named_parm(session, "owner.sub_term_id");
4005 if (cli_parm != NULL)
4006 {
4007 val.u.sub_term.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
4008 }
4009 else
4010 {
4011 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.sub_term_id is not set\n");
4012 return BCM_ERR_PARM;
4013 }
4014 break;
4015 case BCMBAL_TM_SCHED_OWNER_TYPE_AGG_PORT:
4016 cli_parm = bcmcli_find_named_parm(session, "owner.intf_id");
4017 if (cli_parm != NULL)
4018 {
4019 val.u.agg_port.intf_id = cli_parm->value.unumber;
4020 val.u.agg_port.presence_mask = val.u.agg_port.presence_mask | BCMBAL_TM_SCHED_OWNER_AGG_PORT_ID_INTF_ID;
4021 }
4022
4023 cli_parm = bcmcli_find_named_parm(session, "owner.sub_term_id");
4024 if (cli_parm != NULL)
4025 {
4026 val.u.agg_port.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
4027 val.u.agg_port.presence_mask = val.u.agg_port.presence_mask | BCMBAL_TM_SCHED_OWNER_AGG_PORT_ID_SUB_TERM_ID;
4028 }
4029
4030 cli_parm = bcmcli_find_named_parm(session, "owner.agg_port_id");
4031 if (cli_parm != NULL)
4032 {
4033 val.u.agg_port.agg_port_id = (bcmbal_aggregation_port_id) cli_parm->value.unumber;
4034 val.u.agg_port.presence_mask = val.u.agg_port.presence_mask | BCMBAL_TM_SCHED_OWNER_AGG_PORT_ID_AGG_PORT_ID;
4035 }
4036 break;
4037 case BCMBAL_TM_SCHED_OWNER_TYPE_UNI:
4038 cli_parm = bcmcli_find_named_parm(session, "owner.intf_id");
4039 if (cli_parm != NULL)
4040 {
4041 val.u.uni.intf_id = cli_parm->value.unumber;
4042 }
4043 else
4044 {
4045 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.intf_id is not set\n");
4046 return BCM_ERR_PARM;
4047 }
4048
4049 cli_parm = bcmcli_find_named_parm(session, "owner.sub_term_id");
4050 if (cli_parm != NULL)
4051 {
4052 val.u.uni.sub_term_id = (bcmbal_sub_id) cli_parm->value.unumber;
4053 }
4054 else
4055 {
4056 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.sub_term_id is not set\n");
4057 return BCM_ERR_PARM;
4058 }
4059
4060 cli_parm = bcmcli_find_named_parm(session, "owner.idx");
4061 if (cli_parm != NULL)
4062 {
4063 val.u.uni.idx = cli_parm->value.unumber;
4064 }
4065 else
4066 {
4067 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.idx is not set\n");
4068 return BCM_ERR_PARM;
4069 }
4070 break;
4071 case BCMBAL_TM_SCHED_OWNER_TYPE_VIRTUAL:
4072 cli_parm = bcmcli_find_named_parm(session, "owner.idx");
4073 if (cli_parm != NULL)
4074 {
4075 val.u.virtual.idx = cli_parm->value.unumber;
4076 }
4077 else
4078 {
4079 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "owner.idx is not set\n");
4080 return BCM_ERR_PARM;
4081 }
4082 break;
4083 default:
4084 bcmbal_apicli_print_complete(session, BCM_ERR_RANGE, "\n");
4085 return BCM_ERR_RANGE;
4086 }
4087
4088 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, owner, val);
4089 bcmcli_log("{\n");
4090 bcmcli_log("bcmbal_tm_sched_owner val = ");
4091 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_OWNER, &val);
4092 bcmcli_log(";\n");
4093 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, owner, val);\n");
4094 bcmcli_log("}\n");
4095 }
4096
4097 cli_parm = bcmcli_find_named_parm(session, "sched_type");
4098 if (cli_parm != NULL)
4099 {
4100 bcmbal_tm_sched_type val;
4101 val = (bcmbal_tm_sched_type) cli_parm->value.enum_val;
4102 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_type, val);
4103 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_type, ");
4104 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_SCHED_TYPE, &val);
4105 bcmcli_log(");\n");
4106 }
4107
4108 cli_parm = bcmcli_find_parm_by_prefix(session, "sched_parent.");
4109 if (cli_parm != NULL)
4110 {
4111 bcmbal_tm_sched_parent val = { };
4112 cli_parm = bcmcli_find_named_parm(session, "sched_parent.sched_id");
4113 if (cli_parm != NULL)
4114 {
4115 val.sched_id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
4116 val.presence_mask = val.presence_mask | BCMBAL_TM_SCHED_PARENT_ID_SCHED_ID;
4117 }
4118
4119 cli_parm = bcmcli_find_named_parm(session, "sched_parent.priority");
4120 if (cli_parm != NULL)
4121 {
4122 val.priority = (bcmbal_tm_priority) cli_parm->value.unumber;
4123 val.presence_mask = val.presence_mask | BCMBAL_TM_SCHED_PARENT_ID_PRIORITY;
4124 }
4125
4126 cli_parm = bcmcli_find_named_parm(session, "sched_parent.weight");
4127 if (cli_parm != NULL)
4128 {
4129 val.weight = (bcmbal_tm_weight) cli_parm->value.unumber;
4130 val.presence_mask = val.presence_mask | BCMBAL_TM_SCHED_PARENT_ID_WEIGHT;
4131 }
4132
4133 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_parent, val);
4134 bcmcli_log("{\n");
4135 bcmcli_log("bcmbal_tm_sched_parent val = ");
4136 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_SCHED_PARENT, &val);
4137 bcmcli_log(";\n");
4138 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_parent, val);\n");
4139 bcmcli_log("}\n");
4140 }
4141
4142 cli_parm = bcmcli_find_named_parm(session, "sched_child_type");
4143 if (cli_parm != NULL)
4144 {
4145 bcmbal_tm_sched_child_type val;
4146 val = (bcmbal_tm_sched_child_type) cli_parm->value.enum_val;
4147 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_child_type, val);
4148 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, sched_child_type, ");
4149 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_SCHED_CHILD_TYPE, &val);
4150 bcmcli_log(");\n");
4151 }
4152
4153 cli_parm = bcmcli_find_parm_by_prefix(session, "rate.");
4154 if (cli_parm != NULL)
4155 {
4156 bcmbal_tm_shaping val = { };
4157 cli_parm = bcmcli_find_named_parm(session, "rate.sbr");
4158 if (cli_parm != NULL)
4159 {
4160 val.sbr = cli_parm->value.unumber;
4161 val.presence_mask = val.presence_mask | BCMBAL_TM_SHAPING_ID_SBR;
4162 }
4163
4164 cli_parm = bcmcli_find_named_parm(session, "rate.pbr");
4165 if (cli_parm != NULL)
4166 {
4167 val.pbr = cli_parm->value.unumber;
4168 val.presence_mask = val.presence_mask | BCMBAL_TM_SHAPING_ID_PBR;
4169 }
4170
4171 cli_parm = bcmcli_find_named_parm(session, "rate.burst");
4172 if (cli_parm != NULL)
4173 {
4174 val.burst = cli_parm->value.unumber;
4175 val.presence_mask = val.presence_mask | BCMBAL_TM_SHAPING_ID_BURST;
4176 }
4177
4178 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, rate, val);
4179 bcmcli_log("{\n");
4180 bcmcli_log("bcmbal_tm_shaping val = ");
4181 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_RATE, &val);
4182 bcmcli_log(";\n");
4183 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, rate, val);\n");
4184 bcmcli_log("}\n");
4185 }
4186
4187 cli_parm = bcmcli_find_parm_by_prefix(session, "tcont_sla.");
4188 if (cli_parm != NULL)
4189 {
4190 bcmbal_tm_tcont_sla val = { };
4191 cli_parm = bcmcli_find_named_parm(session, "tcont_sla.extra_bw_elig");
4192 if (cli_parm != NULL)
4193 {
4194 val.extra_bw_elig = (bcmbal_extra_bw_eligibility_type) cli_parm->value.enum_val;
4195 val.presence_mask = val.presence_mask | BCMBAL_TM_TCONT_SLA_ID_EXTRA_BW_ELIG;
4196 }
4197
4198 cli_parm = bcmcli_find_named_parm(session, "tcont_sla.nrt_cbr");
4199 if (cli_parm != NULL)
4200 {
4201 val.nrt_cbr = cli_parm->value.unumber;
4202 val.presence_mask = val.presence_mask | BCMBAL_TM_TCONT_SLA_ID_NRT_CBR;
4203 }
4204
4205 cli_parm = bcmcli_find_named_parm(session, "tcont_sla.rt_cbr");
4206 if (cli_parm != NULL)
4207 {
4208 val.rt_cbr = cli_parm->value.unumber;
4209 val.presence_mask = val.presence_mask | BCMBAL_TM_TCONT_SLA_ID_RT_CBR;
4210 }
4211
4212 cli_parm = bcmcli_find_named_parm(session, "tcont_sla.rt_profile");
4213 if (cli_parm != NULL)
4214 {
4215 val.rt_profile = cli_parm->value.unumber;
4216 val.presence_mask = val.presence_mask | BCMBAL_TM_TCONT_SLA_ID_RT_PROFILE;
4217 }
4218
4219 cli_parm = bcmcli_find_named_parm(session, "tcont_sla.nrt_profile");
4220 if (cli_parm != NULL)
4221 {
4222 val.nrt_profile = cli_parm->value.unumber;
4223 val.presence_mask = val.presence_mask | BCMBAL_TM_TCONT_SLA_ID_NRT_PROFILE;
4224 }
4225
4226 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, tcont_sla, val);
4227 bcmcli_log("{\n");
4228 bcmcli_log("bcmbal_tm_tcont_sla val = ");
4229 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_TCONT_SLA, &val);
4230 bcmcli_log(";\n");
4231 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, tcont_sla, val);\n");
4232 bcmcli_log("}\n");
4233 }
4234
4235 cli_parm = bcmcli_find_named_parm(session, "num_priorities");
4236 if (cli_parm != NULL)
4237 {
4238 uint8_t val;
4239 val = cli_parm->value.unumber;
4240 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, num_priorities, val);
4241 bcmcli_log("BCMBAL_CFG_PROP_SET(&cfg, tm_sched, num_priorities, ");
4242 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_CFG, 0, BCMBAL_TM_SCHED_CFG_ID_NUM_PRIORITIES, &val);
4243 bcmcli_log(");\n");
4244 }
4245
4246 /* call API */
4247 err = bcmbal_cfg_set(&cfg.hdr);
4248 bcmcli_log("bcmbal_cfg_set(&cfg.hdr);\n");
4249 bcmbal_apicli_print_complete(session, err, NULL);
4250 return err;
4251}
4252
4253/******************************************************************************/
4254static bcmos_errno bcmbal_cli_tm_sched_cfg_clear(bcmcli_session *session)
4255{
4256 bcmcli_cmd_parm *cli_parm;
4257 bcmos_errno err;
4258 bcmbal_tm_sched_cfg cfg; /**< declare main API struct */
4259 bcmbal_tm_sched_key key = { }; /**< declare key */
4260 bcmcli_log("bcmbal_tm_sched_cfg cfg;\n");
4261 bcmcli_log("bcmbal_tm_sched_key key = { };\n");
4262 bcmbal_apicli_print_start(session, "bcmbal_cfg_clear");
4263
4264 /* build key from CLI parameters */
4265 cli_parm = bcmcli_find_named_parm(session, "dir");
4266 if (cli_parm != NULL)
4267 {
4268 key.dir = (bcmbal_tm_sched_dir) cli_parm->value.enum_val;
4269 }
4270 else
4271 {
4272 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "dir is not set\n");
4273 return BCM_ERR_PARM;
4274 }
4275
4276 bcmcli_log("key.dir = ");
4277 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_SCHED_KEY_ID_DIR, &key.dir);
4278 bcmcli_log(";\n");
4279 cli_parm = bcmcli_find_named_parm(session, "id");
4280 if (cli_parm != NULL)
4281 {
4282 key.id = (bcmbal_tm_sched_id) cli_parm->value.unumber;
4283 }
4284 else
4285 {
4286 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "id is not set\n");
4287 return BCM_ERR_PARM;
4288 }
4289
4290 bcmcli_log("key.id = ");
4291 bcmbal_apicli_log_prop_val(BCMBAL_OBJ_ID_TM_SCHED, BCMBAL_MGT_GROUP_KEY, 0, BCMBAL_TM_SCHED_KEY_ID_ID, &key.id);
4292 bcmcli_log(";\n");
4293
4294 /* init the API struct */
4295 BCMBAL_CFG_INIT(&cfg, tm_sched, key);
4296 bcmcli_log("BCMBAL_CFG_INIT(&cfg, tm_sched, key);\n");
4297
4298 /* call API */
4299 err = bcmbal_cfg_clear(&cfg.hdr);
4300 bcmcli_log("bcmbal_cfg_clear(&cfg.hdr);\n");
4301 bcmbal_apicli_print_complete(session, err, NULL);
4302 return err;
4303}
4304
4305/******************************************************************************/
4306static bcmos_errno bcmbal_apicli_root(bcmbal_mgt_group group_type, bcmbal_obj_msg_type msg_type, bcmcli_session *session, bcmbal_apicli_byte_pool *byte_pool)
4307{
4308 bcmcli_cmd_parm *cli_parm;
4309 bcmbal_obj_id obj_id;
4310 cli_parm = bcmcli_find_named_parm(session, "object");
4311 if (cli_parm != NULL)
4312 {
4313 obj_id = cli_parm->value.number;
4314 }
4315 else
4316 {
4317 bcmbal_apicli_print_complete(session, BCM_ERR_PARM, "object is not set\n");
4318 return BCM_ERR_PARM;
4319 }
4320
4321 switch (obj_id)
4322 {
4323 case BCMBAL_OBJ_ID_ACCESS_TERMINAL:
4324 switch (group_type)
4325 {
4326 case BCMBAL_MGT_GROUP_CFG:
4327 switch (msg_type)
4328 {
4329 case BCMBAL_OBJ_MSG_TYPE_GET:
4330 return bcmbal_cli_access_terminal_cfg_get(session);
4331 case BCMBAL_OBJ_MSG_TYPE_SET:
4332 return bcmbal_cli_access_terminal_cfg_set(session);
4333 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4334 return bcmbal_cli_access_terminal_cfg_clear(session);
4335 default:
4336 return BCM_ERR_RANGE;
4337 }
4338
4339 default:
4340 return BCM_ERR_RANGE;
4341 }
4342
4343 case BCMBAL_OBJ_ID_FLOW:
4344 switch (group_type)
4345 {
4346 case BCMBAL_MGT_GROUP_CFG:
4347 switch (msg_type)
4348 {
4349 case BCMBAL_OBJ_MSG_TYPE_GET:
4350 return bcmbal_cli_flow_cfg_get(session);
4351 case BCMBAL_OBJ_MSG_TYPE_SET:
4352 return bcmbal_cli_flow_cfg_set(session);
4353 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4354 return bcmbal_cli_flow_cfg_clear(session);
4355 default:
4356 return BCM_ERR_RANGE;
4357 }
4358
4359 case BCMBAL_MGT_GROUP_STAT:
4360 return bcmbal_cli_flow_stat_get(session);
4361 default:
4362 return BCM_ERR_RANGE;
4363 }
4364
4365 case BCMBAL_OBJ_ID_GROUP:
4366 switch (group_type)
4367 {
4368 case BCMBAL_MGT_GROUP_CFG:
4369 switch (msg_type)
4370 {
4371 case BCMBAL_OBJ_MSG_TYPE_GET:
4372 return bcmbal_cli_group_cfg_get(session, byte_pool);
4373 case BCMBAL_OBJ_MSG_TYPE_SET:
4374 return bcmbal_cli_group_cfg_set(session, byte_pool);
4375 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4376 return bcmbal_cli_group_cfg_clear(session);
4377 default:
4378 return BCM_ERR_RANGE;
4379 }
4380
4381 default:
4382 return BCM_ERR_RANGE;
4383 }
4384
4385 case BCMBAL_OBJ_ID_INTERFACE:
4386 switch (group_type)
4387 {
4388 case BCMBAL_MGT_GROUP_CFG:
4389 switch (msg_type)
4390 {
4391 case BCMBAL_OBJ_MSG_TYPE_GET:
4392 return bcmbal_cli_interface_cfg_get(session, byte_pool);
4393 case BCMBAL_OBJ_MSG_TYPE_SET:
4394 return bcmbal_cli_interface_cfg_set(session, byte_pool);
4395 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4396 return bcmbal_cli_interface_cfg_clear(session);
4397 default:
4398 return BCM_ERR_RANGE;
4399 }
4400
4401 case BCMBAL_MGT_GROUP_STAT:
4402 return bcmbal_cli_interface_stat_get(session);
4403 default:
4404 return BCM_ERR_RANGE;
4405 }
4406
4407 case BCMBAL_OBJ_ID_PACKET:
4408 switch (group_type)
4409 {
4410 case BCMBAL_MGT_GROUP_CFG:
4411 switch (msg_type)
4412 {
4413 case BCMBAL_OBJ_MSG_TYPE_GET:
4414 return bcmbal_cli_packet_cfg_get(session, byte_pool);
4415 case BCMBAL_OBJ_MSG_TYPE_SET:
4416 return bcmbal_cli_packet_cfg_set(session, byte_pool);
4417 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4418 return bcmbal_cli_packet_cfg_clear(session);
4419 default:
4420 return BCM_ERR_RANGE;
4421 }
4422
4423 default:
4424 return BCM_ERR_RANGE;
4425 }
4426
4427 case BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL:
4428 switch (group_type)
4429 {
4430 case BCMBAL_MGT_GROUP_CFG:
4431 switch (msg_type)
4432 {
4433 case BCMBAL_OBJ_MSG_TYPE_GET:
4434 return bcmbal_cli_subscriber_terminal_cfg_get(session, byte_pool);
4435 case BCMBAL_OBJ_MSG_TYPE_SET:
4436 return bcmbal_cli_subscriber_terminal_cfg_set(session, byte_pool);
4437 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4438 return bcmbal_cli_subscriber_terminal_cfg_clear(session);
4439 default:
4440 return BCM_ERR_RANGE;
4441 }
4442
4443 case BCMBAL_MGT_GROUP_STAT:
4444 return bcmbal_cli_subscriber_terminal_stat_get(session);
4445 default:
4446 return BCM_ERR_RANGE;
4447 }
4448
4449 case BCMBAL_OBJ_ID_TM_QUEUE:
4450 switch (group_type)
4451 {
4452 case BCMBAL_MGT_GROUP_CFG:
4453 switch (msg_type)
4454 {
4455 case BCMBAL_OBJ_MSG_TYPE_GET:
4456 return bcmbal_cli_tm_queue_cfg_get(session);
4457 case BCMBAL_OBJ_MSG_TYPE_SET:
4458 return bcmbal_cli_tm_queue_cfg_set(session);
4459 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4460 return bcmbal_cli_tm_queue_cfg_clear(session);
4461 default:
4462 return BCM_ERR_RANGE;
4463 }
4464
4465 case BCMBAL_MGT_GROUP_STAT:
4466 return bcmbal_cli_tm_queue_stat_get(session);
4467 default:
4468 return BCM_ERR_RANGE;
4469 }
4470
4471 case BCMBAL_OBJ_ID_TM_SCHED:
4472 switch (group_type)
4473 {
4474 case BCMBAL_MGT_GROUP_CFG:
4475 switch (msg_type)
4476 {
4477 case BCMBAL_OBJ_MSG_TYPE_GET:
4478 return bcmbal_cli_tm_sched_cfg_get(session, byte_pool);
4479 case BCMBAL_OBJ_MSG_TYPE_SET:
4480 return bcmbal_cli_tm_sched_cfg_set(session, byte_pool);
4481 case BCMBAL_OBJ_MSG_TYPE_CLEAR:
4482 return bcmbal_cli_tm_sched_cfg_clear(session);
4483 default:
4484 return BCM_ERR_RANGE;
4485 }
4486
4487 default:
4488 return BCM_ERR_RANGE;
4489 }
4490
4491 default:
4492 return BCM_ERR_RANGE;
4493 }
4494}
4495
4496/* Perform an API call based on CLI input */
4497bcmos_errno bcmbal_apicli_call(bcmbal_mgt_group group_type, bcmbal_obj_msg_type msg_type, bcmcli_session *session)
4498{
4499 bcmos_errno err;
4500 bcmbal_apicli_byte_pool byte_pool;
4501
4502 /* setup memory pool for dynamically-sized list memory allocation */
4503 err = bcmbal_apicli_byte_pool_create(&byte_pool);
4504 if (err != BCM_ERR_OK)
4505 {
4506 return err;
4507 }
4508
4509 /* call the root API handler */
4510 err = bcmbal_apicli_root(group_type, msg_type, session, &byte_pool);
4511
4512 /* free all dynamically allocated memory */
4513 bcmbal_apicli_byte_pool_destroy(&byte_pool);
4514
4515 return err;
4516}