blob: 6a13ccef691738b003a5c4a1a16d266fcc96a3a4 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/******************************************************************************
2 *
3 * <:copyright-BRCM:2016:DUAL/GPL:standard
4 *
5 * Copyright (c) 2016 Broadcom
6 * All Rights Reserved
7 *
8 * Unless you and Broadcom execute a separate written software license
9 * agreement governing use of this software, this software is licensed
10 * to you under the terms of the GNU General Public License version 2
11 * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
12 * with the following added to such license:
13 *
14 * As a special exception, the copyright holders of this software give
15 * you permission to link this software with independent modules, and
16 * to copy and distribute the resulting executable under terms of your
17 * choice, provided that you also meet, for each linked independent
18 * module, the terms and conditions of the license of that module.
19 * An independent module is a module which is not derived from this
20 * software. The special exception does not apply to any modifications
21 * of the software.
22 *
23 * Not withstanding the above, under no circumstances may you combine
24 * this software in any way with any other Broadcom software provided
25 * under a license other than the GPL, without Broadcom's express prior
26 * written consent.
27 *
28 * :>
29 *
30 *****************************************************************************/
31
32/**
33 * @file bal_objs.h
34 * @brief The file provides an enumeration of all BAL objects
35 *
36 */
37#ifndef BALOBJS_H
38#define BALOBJS_H
39
40#include <bcmolt_host_api.h>
41#include "bal_common.h"
42#include "bal_model_ids.h"
43#include "bal_model_types.h"
44
45/** \ingroup api
46 * @{
47 */
48
49static char *bal_obj_str[] =
50{
51 [bcmbal_obj_id_access_terminal] = "access_terminal object",
52 [bcmbal_obj_id_interface] = "interface object",
53 [bcmbal_obj_id_subscriber_terminal] = "subscriber_terminal object",
54 [bcmbal_obj_id_flow] = "flow object",
55 [bcmbal_obj_id_packet] = "packet object",
56 [bcmbal_obj_id_group] = "group object",
57 [bcmbal_obj_id_tm_sched] = "scheduler object",
58 [bcmbal_obj_id_tm_queue] = "queue object",
59};
60
61/* Ensure that the name array size matches the associated enum */
62BAL_STATIC_ASSERT (BCMBAL_OBJ_ID__NUM_OF == (sizeof (bal_obj_str) / sizeof (char *)), bcmbal_obj_id);
63
64static inline char *bcmbal_objtype_str(bcmbal_obj_id obj)
65{
66 return (BCMBAL_OBJ_ID__NUM_OF >= obj) ? bal_obj_str[obj] : "unknown";
67}
68
69#define BCMBAL_FLOW_PRIORITY_MAX 65535
70#define BCMBAL_FLOW_PRIORITY_MIN 0
71#define BAL_FLOW_DEFAULT_PRIORITY 10
72
73/*
74 * ------------------------------------------------------------------
75 *
76 * Internal BCMBAL macros used to manipulate the BAL object elements
77 *
78 * ------------------------------------------------------------------
79 */
80
81/* Initialize request. Internal macro
82 * \ingroup api
83 * \param[in] _h Message header
84 * \param[in] _obj Object name (i.e. flow)
85 * \param[in] _grp message type
86 * \param[in] _subgrp message subgroup
87 */
88#define _BCMBAL_REQ_INIT(_h, _obj, _grp, _subgrp) \
89 (_h)->obj_init_val = BCMBAL_OBJ_INIT_VAL; \
90 (_h)->version = BCMBAL_OBJ_VERSION; \
91 (_h)->status = BCM_ERR_OK; \
92 (_h)->presence_mask = 0; \
93 (_h)->obj_type = bcmbal_obj_id_ ## _obj; \
94 (_h)->group = _grp; \
95 (_h)->subgroup = _subgrp;
96
97/** Initialize set structure
98 * \ingroup api
99 * \param[in] _s Set structure
100 * \param[in] _obj Object name (i.e. flow)
101 * \param[in] _key Object key
102 */
103#define BCMBAL_CFG_INIT(_s, _obj, _key) \
104 do { \
105 bcmbal_ ## _obj ## _cfg *_x_ = _s; \
106 memset(_x_, 0, sizeof(*_x_)); \
107 _BCMBAL_REQ_INIT(&((_x_)->hdr.hdr), _obj, BCMBAL_MGT_GROUP_CFG, 0); \
108 (_x_)->key = _key; \
109 } while (0)
110
111/** Initialize statistics structure
112 * \ingroup api
113 * \param[in] _s Statistics structure
114 * \param[in] _obj Object name (i.e. flow)
115 * \param[in] _key Object key
116 */
117#define BCMBAL_STAT_INIT(_s, _obj, _key) \
118 do { \
119 bcmbal_ ## _obj ## _stat *_x_ = _s; \
120 memset(_x_, 0, sizeof(*_x_)); \
121 _BCMBAL_REQ_INIT(&((_x_)->hdr.hdr), _obj, BCMBAL_MGT_GROUP_STAT, 0); \
122 (_x_)->key = _key; \
123 } while (0)
124
125/** Set the memory buffer to use for variable-sized lists within a cfg get
126 * \ingroup api
127 * \param[in] _s Configuration structure
128 * \param[in] _obj Object type
129 * \param[in] _buf Pointer to a location in memory in which to store the lists
130 * \param[in] _len Length of the buffer pointed to by _buf
131 */
132#define BCMBAL_CFG_LIST_BUF_SET(_s, _obj, _buf, _len) \
133 do { \
134 bcmbal_ ## _obj ## _cfg *_x_ = _s; \
135 _x_->hdr.hdr.list_buf = _buf; \
136 _x_->hdr.hdr.list_buf_size = _len; \
137 } while (0)
138
139/* Set the object progress state
140 * \ingroup api
141 * \param[in] _s Object structure
142 * \param[in] _p New object in-progress state: BCMOS_TRUE, or BCMOS_FALSE
143 */
144#define BCMBAL_OBJ_IN_PROGRESS_SET(_s, _p) ((_s)->hdr.hdr.is_inprogress = _p )
145
146/* Return the object progress state
147 * \ingroup api
148 * \param[in] _s Object structure
149 */
150#define BCMBAL_OBJ_IN_PROGRESS_GET(_s) ((_s)->hdr.hdr.is_inprogress)
151
152/* Internal macro: Get a bitmask given a property ID enum */
153#define BCMBAL_PROP_MASK_GET(_obj, _grp, _p) \
154 (bcmbal_ ## _obj ## _grp ## _id_ ## _p == bcmbal_ ## _obj ## _grp ## _id_all_properties ? \
155 ((1ULL << (uint64_t)bcmbal_ ## _obj ## _grp ## _id_ ## _p) - 1) : \
156 (1ULL << (uint64_t)bcmbal_ ## _obj ## _grp ## _id_ ## _p))
157
158
159/* Macro: Indicate that configuration property is present - USE WITH CAUTION */
160#define BCMBAL_PROP_SET_PRESENT(_m, _obj, _grp, _p) \
161 do { \
162 (_m)->hdr.hdr.presence_mask |= BCMBAL_PROP_MASK_GET(_obj, _grp, _p); \
163 } while (0)
164
165/* Internal macro: Indicate that configuration property is not present */
166#define BCMBAL_PROP_CLEAR_PRESENT(_m, _obj, _grp, _p) \
167 do { \
168 (_m)->hdr.hdr.presence_mask &= ~(BCMBAL_PROP_MASK_GET(_obj, _grp, _p));\
169 } while (0)
170
171/* Internal macro: check if property is present */
172#define _BCMBAL_PROP_IS_PRESENT(_m, _obj, _grp, _p) \
173 (((_m)->hdr.hdr.presence_mask & BCMBAL_PROP_MASK_GET(_obj, _grp, _p)) ? \
174 BCMOS_TRUE : BCMOS_FALSE)
175
176/** Set configuration property in message structure
177 * \ingroup api
178 * \param[in] _m Configuration structure
179 * \param[in] _obj Object type
180 * \param[in] _p Property name
181 * \param[in] _v Property value
182 */
183#define BCMBAL_CFG_PROP_SET(_m, _obj, _p, _v) \
184 do { \
185 BCMBAL_PROP_SET_PRESENT(_m, _obj, _cfg, _p);\
186 (_m)->data._p = (_v);\
187 } while (0)
188
189/** Indicate that configuration property should be read
190 * \ingroup api
191 * \param[in] _m Configuration structure
192 * \param[in] _obj Object type
193 * \param[in] _p Property name
194 */
195#define BCMBAL_CFG_PROP_GET(_m, _obj, _p) BCMBAL_PROP_SET_PRESENT(_m, _obj, _cfg, _p)
196
197/** clear object property in message structure
198 * \ingroup api
199 * \param[in] _m Object structure pointer
200 * \param[in] _obj Object name (i.e. flow)
201 * \param[in] _p Attribute name (i.e. admin_state)
202 */
203#define BCMBAL_CFG_PROP_CLEAR(_m, _obj, _p) \
204 do { \
205 BCMBAL_PROP_CLEAR_PRESENT(_m, _obj, _cfg, _p); \
206 memset(&((_m)->data._p), 0, sizeof((_m)->data._p)); \
207 } while (0)
208
209/** Check if configuration property is set in message structure
210 * \ingroup api
211 * \param[in] _m Configuration structure
212 * \param[in] _obj Object type
213 * \param[in] _p Property name
214 */
215#define BCMBAL_CFG_PROP_IS_SET(_m, _obj, _p) _BCMBAL_PROP_IS_PRESENT(_m, _obj, _cfg, _p)
216
217/** Indicate that statistic property should be read
218 * \ingroup api
219 * \param[in] _m Configuration structure
220 * \param[in] _obj Object type
221 * \param[in] _p Property name
222 */
223#define BCMBAL_STAT_PROP_GET(_m, _obj, _p) BCMBAL_PROP_SET_PRESENT(_m, _obj, _stat, _p)
224
225/** Check if statistic property is set in message structure
226 * \ingroup api
227 * \param[in] _m Statistic structure
228 * \param[in] _obj Object type
229 * \param[in] _p Property name
230 */
231#define BCMBAL_STAT_PROP_IS_SET(_m, _obj, _p) _BCMBAL_PROP_IS_PRESENT(_m, _obj, _stat, _p)
232
233
234/***********************************************************************************
235 **
236 ** Macros for setting attribute values where an attribute supports a presence_mask
237 **
238 ***********************************************************************************
239 **/
240
241/* Internal macro: Get a bitmask given a attribute element property ID enum */
242#define BCMBAL_ATTRIBUTE_PROP_MASK_GET(_attr, _p) bcmbal_ ## _attr ## _id_ ## _p
243
244/* Internal macro: Indicate that configuration property is present */
245#define _BCMBAL_ATTRIBUTE_PROP_SET_PRESENT(p_attr, _attr,_p) \
246 do { \
247 (p_attr)->presence_mask |= BCMBAL_ATTRIBUTE_PROP_MASK_GET(_attr, _p); \
248 } while (0)
249
250/* Internal macro: Indicate that configuration property is not present */
251#define _BCMBAL_ATTRIBUTE_PROP_CLEAR_PRESENT(p_attr, _attr,_p) \
252 do { \
253 (p_attr)->presence_mask &= ~(BCMBAL_ATTRIBUTE_PROP_MASK_GET(_attr, _p)); \
254 } while (0)
255
256/** Set attribute element property in message structure
257 * \param[in] _p_attr Attribute structure pointer
258 * \param[in] _attr Attribute name
259 * \param[in] _p Element name (i.e. o_tpid)
260 * \param[in] _v Element value
261 */
262#define BCMBAL_ATTRIBUTE_PROP_SET(_p_attr, _attr, _p, _v) \
263 do { \
264 _BCMBAL_ATTRIBUTE_PROP_SET_PRESENT(_p_attr, _attr, _p); \
265 (_p_attr)->_p = (_v); \
266 } while (0)
267
268/** Clear attribute element property in message structure
269 * \param[in] _p_attr Attribute structure pointer
270 * \param[in] _attr Attribute name
271 * \param[in] _p Element name (i.e. o_tpid)
272 */
273#define BCMBAL_ATTRIBUTE_PROP_CLEAR(_p_attr, _attr, _p) \
274 do { \
275 _BCMBAL_ATTRIBUTE_PROP_CLEAR_PRESENT(_p_attr, _attr, _p); \
276 memset(&((_p_attr)->_p), 0, sizeof((_p_attr)->_p)); \
277 } while (0)
278
279
280/* Internal macro: check if an attribute element is present */
281#define _BCMBAL_ATTRIBUTE_PROP_IS_PRESENT(_p_attr, _attr, _p) \
282 (((_p_attr)->presence_mask & BCMBAL_ATTRIBUTE_PROP_MASK_GET(_attr, _p)) ? \
283 BCMOS_TRUE : BCMOS_FALSE)
284
285/** Check if attribute element property is set in message structure
286 * \param[in] _p_attr Attribute structure pointer
287 * \param[in] _attr Attribute name
288 * \param[in] _p Element name (i.e. o_tpid)
289 */
290#define BCMBAL_ATTRIBUTE_PROP_IS_SET(_p_attr, _attr, _p) _BCMBAL_ATTRIBUTE_PROP_IS_PRESENT(_p_attr, _attr, _p)
291
292
293/*
294 * ------------------------------------------------------------------
295 *
296 * Internal BCMBAL macros used to manipulate cmds_bitmask of action parameters
297 *
298 * ------------------------------------------------------------------
299 */
300
301/** Check if action cmd id is set in action structure
302 * \param[in] _m Object structure pointer
303 * \param[in] _b cmd Id bitmask
304 */
305#define BCMBAL_ACTION_CMD_ID_IS_SET(_m, _b) \
306 (((_m)->cmds_bitmask & (_b)) ? \
307 BCMOS_TRUE : BCMOS_FALSE)
308
309/** Set action cmd id in action structure
310 * \param[in] _m Object structure pointer
311 * \param[in] _b cmd Id bitmask
312 */
313#define BCMBAL_ACTION_CMD_ID_SET(_m, _b) \
314 do { \
315 (_m)->cmds_bitmask |= (_b);\
316 } while (0)
317
318
319/** Clear action cmd id in action structure
320 * \param[in] _m Object structure pointer
321 * \param[in] _b cmd Id bitmask
322 */
323#define BCMBAL_ACTION_CMD_ID_CLEAR(_m, _b) \
324 do { \
325 (_m)->cmds_bitmask &= ~(_b);\
326 } while (0)
327
328
329
330static inline void bcmbal_flow_object_overlay_w_src_priority(bcmbal_flow_cfg *dstobj, bcmbal_flow_cfg *srcobj)
331{
332 BUG_ON(NULL == dstobj);
333 BUG_ON(NULL == srcobj);
334
335 bcmbal_presence_mask dest_presence_mask;
336
337 /* First, copy the common object and keys in their entirety, except for preserving the presence_mask */
338 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
339 dstobj->hdr = srcobj->hdr;
340 dstobj->key = srcobj->key;
341 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
342
343 /* Now copy only the fields that have been specified in the source object */
344 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, admin_state))
345 {
346 BCMBAL_CFG_PROP_SET(dstobj, flow, admin_state, srcobj->data.admin_state);
347 }
348
349 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, access_int_id))
350 {
351 BCMBAL_CFG_PROP_SET(dstobj, flow, access_int_id, srcobj->data.access_int_id);
352 }
353
354 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, network_int_id))
355 {
356 BCMBAL_CFG_PROP_SET(dstobj, flow, network_int_id, srcobj->data.network_int_id);
357 }
358
359 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, sub_term_id))
360 {
361 BCMBAL_CFG_PROP_SET(dstobj, flow, sub_term_id, srcobj->data.sub_term_id);
362 }
363
364 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, svc_port_id))
365 {
366 BCMBAL_CFG_PROP_SET(dstobj, flow, svc_port_id, srcobj->data.svc_port_id);
367 }
368
369 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, agg_port_id))
370 {
371 BCMBAL_CFG_PROP_SET(dstobj, flow, agg_port_id, srcobj->data.agg_port_id);
372 }
373
374 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, resolve_mac))
375 {
376 BCMBAL_CFG_PROP_SET(dstobj, flow, resolve_mac, srcobj->data.resolve_mac);
377 }
378
379 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, queue))
380 {
381 BCMBAL_CFG_PROP_SET(dstobj, flow, queue, srcobj->data.queue);
382 }
383
384 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, action))
385 {
386 BCMBAL_CFG_PROP_SET(dstobj, flow, action, srcobj->data.action);
387 }
388
389 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, classifier))
390 {
391 BCMBAL_CFG_PROP_SET(dstobj, flow, classifier, srcobj->data.classifier);
392 }
393
394 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, sla))
395 {
396 BCMBAL_CFG_PROP_SET(dstobj, flow, sla, srcobj->data.sla);
397 }
398
399 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, group_id))
400 {
401 BCMBAL_CFG_PROP_SET(dstobj, flow, group_id, srcobj->data.group_id);
402 }
403
404 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, cookie))
405 {
406 BCMBAL_CFG_PROP_SET(dstobj, flow, cookie, srcobj->data.cookie);
407 }
408}
409
410static inline void bcmbal_flow_object_overlay_w_dst_priority(bcmbal_flow_cfg *dstobj, bcmbal_flow_cfg *srcobj)
411{
412 BUG_ON(NULL == dstobj);
413 BUG_ON(NULL == srcobj);
414
415 bcmbal_presence_mask dest_presence_mask;
416
417 /* First, copy the common object and keys in their entirety,
418 * except for preserving the presence_mask */
419 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
420 dstobj->hdr = srcobj->hdr;
421 dstobj->key = srcobj->key;
422 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
423
424 /* Now copy only the fields that have been specified in the source and are not already set in the dst object */
425 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, admin_state))
426 {
427 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, admin_state))
428 BCMBAL_CFG_PROP_SET(dstobj, flow, admin_state, srcobj->data.admin_state);
429 }
430
431 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, access_int_id))
432 {
433 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, access_int_id))
434 BCMBAL_CFG_PROP_SET(dstobj, flow, access_int_id, srcobj->data.access_int_id);
435 }
436
437 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, network_int_id))
438 {
439 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, network_int_id))
440 BCMBAL_CFG_PROP_SET(dstobj, flow, network_int_id, srcobj->data.network_int_id);
441 }
442
443 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, sub_term_id))
444 {
445 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, sub_term_id))
446 BCMBAL_CFG_PROP_SET(dstobj, flow, sub_term_id, srcobj->data.sub_term_id);
447 }
448
449 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, svc_port_id))
450 {
451 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, svc_port_id))
452 BCMBAL_CFG_PROP_SET(dstobj, flow, svc_port_id, srcobj->data.svc_port_id);
453 }
454
455 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, agg_port_id))
456 {
457 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, agg_port_id))
458 BCMBAL_CFG_PROP_SET(dstobj, flow, agg_port_id, srcobj->data.agg_port_id);
459 }
460
461 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, resolve_mac))
462 {
463 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, resolve_mac))
464 BCMBAL_CFG_PROP_SET(dstobj, flow, resolve_mac, srcobj->data.resolve_mac);
465 }
466
467 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, queue))
468 {
469 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, queue))
470 BCMBAL_CFG_PROP_SET(dstobj, flow, queue, srcobj->data.queue);
471 }
472
473 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, action))
474 {
475 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, action))
476 BCMBAL_CFG_PROP_SET(dstobj, flow, action, srcobj->data.action);
477 }
478
479 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, classifier))
480 {
481 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, classifier))
482 BCMBAL_CFG_PROP_SET(dstobj, flow, classifier, srcobj->data.classifier);
483 }
484
485 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, sla))
486 {
487 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, sla))
488 BCMBAL_CFG_PROP_SET(dstobj, flow, sla, srcobj->data.sla);
489 }
490
491 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, group_id))
492 {
493 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, group_id))
494 BCMBAL_CFG_PROP_SET(dstobj, flow, group_id, srcobj->data.group_id);
495 }
496
497 if(BCMBAL_CFG_PROP_IS_SET(srcobj, flow, cookie))
498 {
499 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, flow, cookie))
500 BCMBAL_CFG_PROP_SET(dstobj, flow, cookie, srcobj->data.cookie);
501 }
502}
503
504static inline void bcmbal_sub_term_object_overlay_w_src_priority(bcmbal_subscriber_terminal_cfg *dstobj,
505 bcmbal_subscriber_terminal_cfg *srcobj)
506{
507 BUG_ON(NULL == dstobj);
508 BUG_ON(NULL == srcobj);
509
510 bcmbal_presence_mask dest_presence_mask;
511
512 /* First, copy the common object and keys in their entirety, except for preserving the presence_mask */
513 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
514 dstobj->hdr = srcobj->hdr;
515 dstobj->key = srcobj->key;
516 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
517
518 /* Now copy only the fields that have been specified in the source object */
519 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, admin_state))
520 {
521 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, admin_state, srcobj->data.admin_state);
522 }
523
524 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, serial_number))
525 {
526 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, serial_number, srcobj->data.serial_number);
527 }
528
529 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, password))
530 {
531 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, password, srcobj->data.password);
532 }
533
534 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, registration_id))
535 {
536 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, registration_id, srcobj->data.registration_id);
537 }
538
539 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, svc_port_id))
540 {
541 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, svc_port_id, srcobj->data.svc_port_id);
542 }
543
544 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, ds_tm))
545 {
546 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, ds_tm, srcobj->data.ds_tm);
547 }
548
549 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, us_tm))
550 {
551 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, us_tm, srcobj->data.us_tm);
552 }
553
554 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, mac_address))
555 {
556 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, mac_address, srcobj->data.mac_address);
557 }
558}
559
560static inline void bcmbal_sub_term_object_overlay_w_dst_priority(bcmbal_subscriber_terminal_cfg *dstobj,
561 bcmbal_subscriber_terminal_cfg *srcobj)
562{
563 BUG_ON(NULL == dstobj);
564 BUG_ON(NULL == srcobj);
565
566 bcmbal_presence_mask dest_presence_mask;
567
568 /* First, copy the common object and keys in their entirety, except for preserving the presence_mask */
569 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
570 dstobj->hdr = srcobj->hdr;
571 dstobj->key = srcobj->key;
572 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
573
574 /* Now copy only the fields that have been specified in the source object */
575 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, admin_state))
576 {
577 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, admin_state))
578 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, admin_state, srcobj->data.admin_state);
579 }
580
581 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, serial_number))
582 {
583 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, serial_number))
584 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, serial_number, srcobj->data.serial_number);
585 }
586
587 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, password))
588 {
589 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, password))
590 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, password, srcobj->data.password);
591 }
592
593 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, registration_id))
594 {
595 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, registration_id))
596 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, registration_id, srcobj->data.registration_id);
597 }
598
599 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, svc_port_id))
600 {
601 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, svc_port_id))
602 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, svc_port_id, srcobj->data.svc_port_id);
603 }
604
605 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, ds_tm))
606 {
607 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, ds_tm))
608 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, ds_tm, srcobj->data.ds_tm);
609 }
610
611 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, us_tm))
612 {
613 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, us_tm))
614 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, us_tm, srcobj->data.us_tm);
615 }
616
617 if(BCMBAL_CFG_PROP_IS_SET(srcobj, subscriber_terminal, mac_address))
618 {
619 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, subscriber_terminal, mac_address))
620 BCMBAL_CFG_PROP_SET(dstobj, subscriber_terminal, mac_address, srcobj->data.mac_address);
621 }
622}
623
624static inline void bcmbal_tm_sched_object_overlay_w_src_priority(bcmbal_tm_sched_cfg *dstobj, bcmbal_tm_sched_cfg *srcobj)
625{
626 BUG_ON(NULL == dstobj);
627 BUG_ON(NULL == srcobj);
628
629 bcmbal_presence_mask dest_presence_mask;
630
631 /* First, copy the common object and keys in their entirety, except for preserving the presence_mask */
632 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
633 dstobj->hdr = srcobj->hdr;
634 dstobj->key = srcobj->key;
635 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
636
637 /* Now copy only the fields that have been specified in the source object */
638 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, owner))
639 {
640 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, owner, srcobj->data.owner);
641 }
642
643 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, sched_type))
644 {
645 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, sched_type, srcobj->data.sched_type);
646 }
647
648 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, sched_parent))
649 {
650 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, sched_parent, srcobj->data.sched_parent);
651 }
652
653 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, sched_child_type))
654 {
655 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, sched_child_type, srcobj->data.sched_child_type);
656 }
657
658 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, rate))
659 {
660 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, rate, srcobj->data.rate);
661 }
662
663 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, tcont_sla))
664 {
665 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, tcont_sla, srcobj->data.tcont_sla);
666 }
667
668 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, creation_mode))
669 {
670 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, creation_mode, srcobj->data.creation_mode);
671 }
672
673 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, num_priorities))
674 {
675 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, num_priorities, srcobj->data.num_priorities);
676 }
677
678}
679
680
681
682static inline void bcmbal_tm_sched_object_overlay_w_dst_priority(bcmbal_tm_sched_cfg *dstobj, bcmbal_tm_sched_cfg *srcobj)
683{
684 BUG_ON(NULL == dstobj);
685 BUG_ON(NULL == srcobj);
686
687 bcmbal_presence_mask dest_presence_mask;
688
689 /* First, copy the common object and keys in their entirety,
690 * except for preserving the presence_mask */
691 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
692 dstobj->hdr = srcobj->hdr;
693 dstobj->key = srcobj->key;
694 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
695
696 /* Now copy only the fields that have been specified in the source and are not already set in the dst object */
697 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, owner))
698 {
699 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, owner))
700 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, owner, srcobj->data.owner);
701 }
702 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, sched_type))
703 {
704 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, sched_type))
705 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, sched_type, srcobj->data.sched_type);
706 }
707 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, sched_parent))
708 {
709 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, sched_parent))
710 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, sched_parent, srcobj->data.sched_parent);
711 }
712 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, sched_child_type))
713 {
714 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, sched_child_type))
715 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, sched_child_type, srcobj->data.sched_child_type);
716 }
717
718 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, rate))
719 {
720 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, rate))
721 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, rate, srcobj->data.rate);
722 }
723 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, tcont_sla))
724 {
725 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, tcont_sla))
726 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, tcont_sla, srcobj->data.tcont_sla);
727 }
728 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_sched, creation_mode))
729 {
730 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, tm_sched, creation_mode))
731 BCMBAL_CFG_PROP_SET(dstobj, tm_sched, creation_mode, srcobj->data.creation_mode);
732 }
733
734}
735
736
737static inline void bcmbal_tm_queue_object_overlay(bcmbal_tm_queue_cfg *dstobj, bcmbal_tm_queue_cfg *srcobj)
738{
739 BUG_ON(NULL == dstobj);
740 BUG_ON(NULL == srcobj);
741
742 bcmbal_presence_mask dest_presence_mask;
743
744 /* First, copy the common object and keys in their entirety, except for preserving the presence_mask */
745 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
746 dstobj->hdr = srcobj->hdr;
747 dstobj->key = srcobj->key;
748 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
749
750 /* Now copy only the fields that have been specified in the source object */
751
752 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_queue, priority))
753 {
754 BCMBAL_CFG_PROP_SET(dstobj, tm_queue, priority, srcobj->data.priority);
755 }
756
757 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_queue, weight))
758 {
759 BCMBAL_CFG_PROP_SET(dstobj, tm_queue, weight, srcobj->data.weight);
760 }
761
762 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_queue, rate))
763 {
764 BCMBAL_CFG_PROP_SET(dstobj, tm_queue, rate, srcobj->data.rate);
765 }
766
767 if(BCMBAL_CFG_PROP_IS_SET(srcobj, tm_queue, bac))
768 {
769 BCMBAL_CFG_PROP_SET(dstobj, tm_queue, bac, srcobj->data.bac);
770 }
771}
772
773static inline bcmos_errno bal_obj_key_str_get(bcmbal_obj *obj, char *p_obj_key_str)
774{
775 BUG_ON(NULL == p_obj_key_str);
776
777 bcmos_errno ret = BCM_ERR_OK;
778
779 switch (obj->obj_type)
780 {
781
782 case (BCMBAL_OBJ_ID_ACCESS_TERMINAL):
783 {
784 sprintf(p_obj_key_str, "unit:%d",
785 ((bcmbal_access_terminal_cfg *)obj)->key.access_term_id);
786 break;
787 }
788
789 case (BCMBAL_OBJ_ID_INTERFACE):
790 {
791 sprintf(p_obj_key_str, "intf_id:%d, type:%s",
792 ((bcmbal_interface_cfg *)obj)->key.intf_id,
793 ((bcmbal_interface_cfg *)obj)->key.intf_type == BCMBAL_INTF_TYPE_NNI ? "NNI" :
794 ((bcmbal_interface_cfg *)obj)->key.intf_type == BCMBAL_INTF_TYPE_PON ? "PON" :
795 "???"
796 );
797 break;
798 }
799
800 case (BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL):
801 {
802 sprintf(p_obj_key_str, "sub_term_id:%d, intf_id:%d",
803 ((bcmbal_subscriber_terminal_cfg *)obj)->key.sub_term_id,
804 ((bcmbal_subscriber_terminal_cfg *)obj)->key.intf_id);
805 break;
806 }
807
808 case (BCMBAL_OBJ_ID_FLOW):
809 {
810 sprintf(p_obj_key_str, "flow_id:%d, type:%s",
811 ((bcmbal_flow_cfg *)obj)->key.flow_id,
812 ((bcmbal_flow_cfg *)obj)->key.flow_type == BCMBAL_FLOW_TYPE_UPSTREAM ? "upstream" :
813 ((bcmbal_flow_cfg *)obj)->key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM ? "downstream" :
814 ((bcmbal_flow_cfg *)obj)->key.flow_type == BCMBAL_FLOW_TYPE_BROADCAST ? "broadcast" :
815 ((bcmbal_flow_cfg *)obj)->key.flow_type == BCMBAL_FLOW_TYPE_MULTICAST ? "multicast" :
816 "???"
817 );
818 break;
819 }
820
821 case (BCMBAL_OBJ_ID_GROUP):
822 {
823 sprintf(p_obj_key_str, "group_id:%d",
824 ((bcmbal_group_cfg *)obj)->key.group_id);
825 break;
826 }
827
828 case (BCMBAL_OBJ_ID_TM_SCHED):
829 {
830 sprintf(p_obj_key_str, "dir:%s, id:%d",
831 ((bcmbal_tm_sched_cfg *)obj)->key.dir == BCMBAL_TM_SCHED_DIR_US ? "upstream" :
832 ((bcmbal_tm_sched_cfg *)obj)->key.dir == BCMBAL_TM_SCHED_DIR_DS ? "downstream" :
833 "???",
834 ((bcmbal_tm_sched_cfg *)obj)->key.id
835 );
836 break;
837 }
838
839 case (BCMBAL_OBJ_ID_TM_QUEUE):
840 {
841 sprintf(p_obj_key_str, "sched_id:%d, sched_dir:%s, id:%d",
842 ((bcmbal_tm_queue_cfg *)obj)->key.sched_id,
843 ((bcmbal_tm_queue_cfg *)obj)->key.sched_dir == BCMBAL_TM_SCHED_DIR_US ? "upstream" :
844 ((bcmbal_tm_queue_cfg *)obj)->key.sched_dir == BCMBAL_TM_SCHED_DIR_DS ? "downstream" :
845 "???",
846 ((bcmbal_tm_queue_cfg *)obj)->key.id
847 );
848 break;
849 }
850
851 case (BCMBAL_OBJ_ID_PACKET):
852 {
853 sprintf(p_obj_key_str, " ");
854 break;
855 }
856
857 default:
858 sprintf(p_obj_key_str, " ");
859 ret = BCM_ERR_PARM;
860 break;
861 }
862
863 return ret;
864}
865
866static inline void bcmbal_interface_object_overlay_w_dst_priority(bcmbal_interface_cfg *dstobj, bcmbal_interface_cfg *srcobj)
867{
868 BUG_ON(NULL == dstobj);
869 BUG_ON(NULL == srcobj);
870
871 bcmbal_presence_mask dest_presence_mask;
872
873 /* First, copy the common object and keys in their entirety,
874 * except for preserving the presence_mask */
875 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
876 dstobj->hdr = srcobj->hdr;
877 dstobj->key = srcobj->key;
878 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
879
880 /* Now copy only the fields that have been specified in the source and are not already set in the dst object */
881 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, admin_state))
882 {
883 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, admin_state))
884 BCMBAL_CFG_PROP_SET(dstobj, interface, admin_state, srcobj->data.admin_state);
885 }
886 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, min_data_agg_port_id))
887 {
888 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, min_data_agg_port_id))
889 BCMBAL_CFG_PROP_SET(dstobj, interface, min_data_agg_port_id, srcobj->data.min_data_agg_port_id);
890 }
891 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, min_data_svc_port_id))
892 {
893 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, min_data_svc_port_id))
894 BCMBAL_CFG_PROP_SET(dstobj, interface, min_data_svc_port_id, srcobj->data.min_data_svc_port_id);
895 }
896 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, transceiver_type))
897 {
898 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, transceiver_type))
899 BCMBAL_CFG_PROP_SET(dstobj, interface, transceiver_type, srcobj->data.transceiver_type);
900 }
901 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, ds_miss_mode))
902 {
903 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, ds_miss_mode))
904 BCMBAL_CFG_PROP_SET(dstobj, interface, ds_miss_mode, srcobj->data.ds_miss_mode);
905 }
906 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, mtu))
907 {
908 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, mtu))
909 BCMBAL_CFG_PROP_SET(dstobj, interface, mtu, srcobj->data.mtu);
910 }
911 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, flow_control))
912 {
913 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, flow_control))
914 BCMBAL_CFG_PROP_SET(dstobj, interface, flow_control, srcobj->data.flow_control);
915 }
916 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, ds_tm))
917 {
918 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, ds_tm))
919 BCMBAL_CFG_PROP_SET(dstobj, interface, ds_tm, srcobj->data.ds_tm);
920 }
921 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, us_tm))
922 {
923 if(!BCMBAL_CFG_PROP_IS_SET(dstobj, interface, us_tm))
924 BCMBAL_CFG_PROP_SET(dstobj, interface, us_tm, srcobj->data.us_tm);
925 }
926}
927
928
929static inline void bcmbal_interface_object_overlay_w_src_priority(bcmbal_interface_cfg *dstobj,
930 bcmbal_interface_cfg *srcobj)
931{
932 BUG_ON(NULL == dstobj);
933 BUG_ON(NULL == srcobj);
934
935 bcmbal_presence_mask dest_presence_mask;
936
937 /* First, copy the common object and keys in their entirety, except for preserving the presence_mask */
938 dest_presence_mask = dstobj->hdr.hdr.presence_mask;
939 dstobj->hdr = srcobj->hdr;
940 dstobj->key = srcobj->key;
941 dstobj->hdr.hdr.presence_mask = dest_presence_mask;
942
943 /* Now copy only the fields that have been specified in the source object */
944 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, admin_state))
945 {
946 BCMBAL_CFG_PROP_SET(dstobj, interface, admin_state, srcobj->data.admin_state);
947 }
948 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, min_data_agg_port_id))
949 {
950 BCMBAL_CFG_PROP_SET(dstobj, interface, min_data_agg_port_id, srcobj->data.min_data_agg_port_id);
951 }
952 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, min_data_svc_port_id))
953 {
954 BCMBAL_CFG_PROP_SET(dstobj, interface, min_data_svc_port_id, srcobj->data.min_data_svc_port_id);
955 }
956 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, transceiver_type))
957 {
958 BCMBAL_CFG_PROP_SET(dstobj, interface, transceiver_type, srcobj->data.transceiver_type);
959 }
960 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, ds_miss_mode))
961 {
962 BCMBAL_CFG_PROP_SET(dstobj, interface, ds_miss_mode, srcobj->data.ds_miss_mode);
963 }
964 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, mtu))
965 {
966 BCMBAL_CFG_PROP_SET(dstobj, interface, mtu, srcobj->data.mtu);
967 }
968 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, flow_control))
969 {
970 BCMBAL_CFG_PROP_SET(dstobj, interface, flow_control, srcobj->data.flow_control);
971 }
972 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, ds_tm))
973 {
974 BCMBAL_CFG_PROP_SET(dstobj, interface, ds_tm, srcobj->data.ds_tm);
975 }
976 if(BCMBAL_CFG_PROP_IS_SET(srcobj, interface, us_tm))
977 {
978 BCMBAL_CFG_PROP_SET(dstobj, interface, us_tm, srcobj->data.us_tm);
979 }
980
981}
982/*@}*/
983
984
985#endif /* BALOBJS_H */