blob: f18bac9977dbd78d95010c08f3ffdaed6be7c40c [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2<:copyright-BRCM:2016:DUAL/GPL:standard
3
4 Broadcom Proprietary and Confidential.(c) 2016 Broadcom
5 All Rights Reserved
6
7Unless you and Broadcom execute a separate written software license
8agreement governing use of this software, this software is licensed
9to you under the terms of the GNU General Public License version 2
10(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
11with the following added to such license:
12
13 As a special exception, the copyright holders of this software give
14 you permission to link this software with independent modules, and
15 to copy and distribute the resulting executable under terms of your
16 choice, provided that you also meet, for each linked independent
17 module, the terms and conditions of the license of that module.
18 An independent module is a module which is not derived from this
19 software. The special exception does not apply to any modifications
20 of the software.
21
22Not withstanding the above, under no circumstances may you combine
23this software in any way with any other Broadcom software provided
24under a license other than the GPL, without Broadcom's express prior
25written consent.
26
27:>
28 */
29
30#ifndef BCMOLT_API_H_
31#define BCMOLT_API_H_
32
33#include <bcmos_system.h>
34#include <bcmolt_msg.h>
35
36/** \defgroup api BCM6862x Host API
37 *
38 * Data Types, functions and macros that should be used for BCM6862x device management.
39 * @{
40 */
41
42/** \defgroup api_macros Message Access Macros
43 * @{
44 */
45
46/*
47 * Message Initialization Macros
48 */
49
50/* Initialize request. Internal macro
51 * \param[in] _h Message header
52 * \param[in] _obj Object type
53 * \param[in] _grp message type
54 * \param[in] _subgrp message subgroup
55 */
56#define _BCMOLT_REQ_INIT(_h, _obj, _grp, _subgrp) \
57 (_h)->hdr.dir = BCMOLT_MSG_DIR_REQUEST;\
58 (_h)->hdr.err = BCM_ERR_OK;\
59 (_h)->hdr.presence_mask = 0;\
60 (_h)->hdr.obj_type = bcmolt_obj_id_ ## _obj;\
61 (_h)->hdr.group = _grp;\
62 (_h)->hdr.subgroup = (uint16_t)_subgrp;\
63 (_h)->hdr.corr_tag = 0
64
65/** Initialize configuration structure
66 * \param[in] _s Configuration structure
67 * \param[in] _obj Object type
68 * \param[in] _key Object key
69 */
70#define BCMOLT_CFG_INIT(_s, _obj, _key) \
71 do {\
72 bcmolt_ ## _obj ## _cfg *_x_ = _s;\
73 memset(_x_, 0, sizeof(*_x_));\
74 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_CFG, 0);\
75 (_x_)->key = _key;\
76 } while (0)
77
78/** Initialize statistics structure
79 * \param[in] _s Statistics structure
80 * \param[in] _obj Object type
81 * \param[in] _key Object key
82 */
83#define BCMOLT_STAT_INIT(_s, _obj, _key) \
84 do {\
85 bcmolt_ ## _obj ## _stat *_x_ = _s;\
86 memset(_x_, 0, sizeof(*_x_));\
87 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_STAT, 0);\
88 (_x_)->key = _key;\
89 } while (0)
90
91/** Initialize statistic configuration structure
92 * \param[in] _s Statistics configuration structure
93 * \param[in] _obj Object type
94 * \param[in] _stat Statistic counter name
95 * \param[in] _key Object key
96 */
97#define BCMOLT_STAT_CFG_INIT(_s, _obj, _stat, _key) \
98 do {\
99 bcmolt_ ## _obj ## _stat_cfg *_x_ = _s;\
100 memset(_x_, 0, sizeof(*_x_));\
101 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_STAT_CFG, bcmolt_ ## _obj ## _stat_id_ ## _stat);\
102 (_x_)->key = _key;\
103 } while (0)
104
105/** Initialize indication configuration structure
106 * \param[in] _s Indication configuration structure
107 * \param[in] _obj Object type
108 * \param[in] _key Object key
109 */
110#define BCMOLT_AUTO_CFG_INIT(_s, _obj, _key) \
111 do {\
112 bcmolt_ ## _obj ## _auto_cfg *_x_ = _s;\
113 memset(_x_, 0, sizeof(*_x_));\
114 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_AUTO_CFG, 0);\
115 (_x_)->key = _key;\
116 } while (0)
117
118/** Initialize operation structure
119 * \param[in] _s Operation structure
120 * \param[in] _obj Object type
121 * \param[in] _op Operation type
122 * \param[in] _key Object key
123 */
124#define BCMOLT_OPER_INIT(_s, _obj, _op, _key) \
125 do {\
126 bcmolt_ ## _obj ## _ ## _op *_x_ = _s;\
127 memset(_x_, 0, sizeof(*_x_));\
128 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_OPER, bcmolt_ ## _obj ## _oper_id_ ## _op);\
129 (_x_)->key = _key;\
130 } while (0)
131
132/** Initialize proxy message structure
133 * \param[in] _s Operation structure
134 * \param[in] _obj Object type
135 * \param[in] _m Proxy message type
136 * \param[in] _key Object key
137 */
138#define BCMOLT_PROXY_INIT(_s, _obj, _m, _key) \
139 do {\
140 bcmolt_ ## _obj ## _ ## _m *_x_ = _s;\
141 memset(_x_, 0, sizeof(*_x_));\
142 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_PROXY, bcmolt_ ## _obj ## _proxy_id_ ## _m);\
143 (_x_)->key = _key;\
144 } while (0)
145
146/** Initialize autonomous indication structure
147 * \param[in] _s Autonomous indication structure
148 * \param[in] _obj Object type
149 * \param[in] _au Autonomous indication type
150 */
151#define BCMOLT_AUTO_INIT(_s, _obj, _au) \
152 do {\
153 bcmolt_ ## _obj ## _ ## _au *_x_ = _s;\
154 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_AUTO, bcmolt_ ## _obj ## _auto_id_ ## _au);\
155 _x_->hdr.hdr.subch = 0;\
156 _x_->hdr.hdr.presence_mask = (1ULL << (uint64_t)bcmolt_ ## _obj ## _ ## _au ## _id_all_properties) - 1;\
157 } while (0)
158
159/** Initialize proxy_rx structure
160 * \param[in] _s Proxy rx message structure
161 * \param[in] _obj Object type
162 * \param[in] _pr Proxy message type
163 */
164#define BCMOLT_PROXY_RX_INIT(_s, _obj, _pr) \
165 do {\
166 bcmolt_ ## _obj ## _ ## _pr *_x_ = _s;\
167 _BCMOLT_REQ_INIT(&((_x_)->hdr), _obj, BCMOLT_MGT_GROUP_PROXY_RX, bcmolt_ ## _obj ## _proxy_rx_id_ ## _pr);\
168 _x_->hdr.hdr.subch = 0;\
169 _x_->hdr.hdr.presence_mask = (1ULL << (uint64_t)bcmolt_ ## _obj ## _ ## _pr ## _id_all_properties) - 1;\
170 } while (0)
171
172/** Set the memory buffer to use for variable-sized lists within a cfg get
173* \param[in] _s Configuration structure
174* \param[in] _obj Object type
175* \param[in] _buf Pointer to a location in memory in which to store the lists
176* \param[in] _len Length of the buffer pointed to by _buf
177*/
178#define BCMOLT_CFG_LIST_BUF_SET(_s, _obj, _buf, _len) \
179 do {\
180 bcmolt_ ## _obj ## _cfg *_x_ = _s;\
181 _x_->hdr.hdr.list_buf = _buf;\
182 _x_->hdr.hdr.list_buf_size = _len;\
183 } while (0)
184
185/* Internal macro: Get a bitmask given a property ID enum */
186#define BCMOLT_PROP_MASK_GET(_obj, _grp, _p) \
187 (bcmolt_ ## _obj ## _grp ## _id_ ## _p == bcmolt_ ## _obj ## _grp ## _id_all_properties ? \
188 ((1ULL << (uint64_t)bcmolt_ ## _obj ## _grp ## _id_ ## _p) - 1) : \
189 (1ULL << (uint64_t)bcmolt_ ## _obj ## _grp ## _id_ ## _p))
190
191/* Internal macro: Indicate that configuration property is present */
192#define _BCMOLT_PROP_SET_PRESENT(_m, _obj, _grp, _p) \
193 do { \
194 (_m)->hdr.hdr.presence_mask |= BCMOLT_PROP_MASK_GET(_obj, _grp, _p);\
195 } while (0)
196
197/* Internal macro: check if property is present */
198#define _BCMOLT_PROP_IS_PRESENT(_m, _obj, _grp, _p) \
199 (((_m)->hdr.hdr.presence_mask & BCMOLT_PROP_MASK_GET(_obj, _grp, _p)) ? \
200 BCMOS_TRUE : BCMOS_FALSE)
201
202/** Set configuration property in message structure
203 * \param[in] _m Configuration structure
204 * \param[in] _obj Object type
205 * \param[in] _p Property name
206 * \param[in] _v Property value
207 */
208#define BCMOLT_CFG_PROP_SET(_m, _obj, _p, _v) \
209 do { \
210 _BCMOLT_PROP_SET_PRESENT(_m, _obj, _cfg, _p);\
211 (_m)->data._p = (_v);\
212 } while (0)
213
214/** Indicate that configuration property should be read
215 * \param[in] _m Configuration structure
216 * \param[in] _obj Object type
217 * \param[in] _p Property name
218 */
219#define BCMOLT_CFG_PROP_GET(_m, _obj, _p) _BCMOLT_PROP_SET_PRESENT(_m, _obj, _cfg, _p)
220
221/** Check if configuration property is set in message structure
222 * \param[in] _m Configuration structure
223 * \param[in] _obj Object type
224 * \param[in] _p Property name
225 */
226#define BCMOLT_CFG_PROP_IS_SET(_m, _obj, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _cfg, _p)
227
228/** Indicate that statistic property should be read
229 * \param[in] _m Configuration structure
230 * \param[in] _obj Object type
231 * \param[in] _p Property name
232 */
233#define BCMOLT_STAT_PROP_GET(_m, _obj, _p) _BCMOLT_PROP_SET_PRESENT(_m, _obj, _stat, _p)
234
235/** Check if statistic property is set in message structure
236 * \param[in] _m Statistic structure
237 * \param[in] _obj Object type
238 * \param[in] _p Property name
239 */
240#define BCMOLT_STAT_PROP_IS_SET(_m, _obj, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _stat, _p)
241
242/** Set operation property in message structure
243 * \param[in] _m Operation structure
244 * \param[in] _obj Object type
245 * \param[in] _op Operation
246 * \param[in] _p Property name
247 * \param[in] _v Property value
248 */
249#define BCMOLT_OPER_PROP_SET(_m, _obj, _op, _p, _v) \
250 do { \
251 _BCMOLT_PROP_SET_PRESENT(_m, _obj, _ ## _op, _p);\
252 (_m)->data._p = (_v);\
253 } while (0)
254
255/** Check if operation property is set in message structure
256* \param[in] _m Operation structure
257* \param[in] _obj Object type
258* \param[in] _op Operation
259* \param[in] _p Property name
260*/
261#define BCMOLT_OPER_PROP_IS_SET(_m, _obj, _op, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _op, _p)
262
263/** Indicate that autonomous message configuration property should be read
264 * \param[in] _m Configuration structure
265 * \param[in] _obj Object type
266 * \param[in] _p Property name
267 */
268#define BCMOLT_AUTO_CFG_PROP_GET(_m, _obj, _p) _BCMOLT_PROP_SET_PRESENT(_m, _obj, _auto_cfg, _p)
269
270/** Set autonomous message configuration property in message structure
271 * \param[in] _m Operation structure
272 * \param[in] _obj Object type
273 * \param[in] _p Property name
274 * \param[in] _v Property value
275 */
276#define BCMOLT_AUTO_CFG_PROP_SET(_m, _obj, _p, _v) \
277 do { \
278 _BCMOLT_PROP_SET_PRESENT(_m, _obj, _auto_cfg, _p);\
279 (_m)->data._p = (_v);\
280 } while (0)
281
282/** Check if autonomous message configuration property is set in message structure
283* \param[in] _m Configuration structure
284* \param[in] _obj Object type
285* \param[in] _p Property name
286*/
287#define BCMOLT_AUTO_CFG_PROP_IS_SET(_m, _obj, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _auto_cfg, _p)
288
289/** Set statistic configuration property in message structure
290* \param[in] _m Configuration structure
291* \param[in] _obj Object type
292* \param[in] _p Property name
293* \param[in] _v Property value
294*/
295#define BCMOLT_STAT_CFG_PROP_SET(_m, _obj, _p, _v) \
296 do { \
297 _BCMOLT_PROP_SET_PRESENT(_m, _obj, _stat_cfg, _p);\
298 (_m)->data._p = (_v);\
299 } while (0)
300
301/** Check if statistic configuration property is set in message structure
302* \param[in] _m Configuration structure
303* \param[in] _obj Object type
304* \param[in] _p Property name
305*/
306#define BCMOLT_STAT_CFG_PROP_IS_SET(_m, _obj, _p) _BCMOLT_PROP_IS_PRESENT(_m, _obj, _stat_cfg, _p)
307
308/** Set proxy message property in message structure
309 * \param[in] _m Configuration structure
310 * \param[in] _obj Object type
311 * \param[in] _grp Proxy message type
312 * \param[in] _p Property name
313 * \param[in] _v Property value
314 */
315#define BCMOLT_PROXY_PROP_SET(_m, _obj, _grp, _p, _v) \
316 do { \
317 _BCMOLT_PROP_SET_PRESENT(_m, _obj, _ ## _grp, _p);\
318 (_m)->data._p = (_v);\
319 } while (0)
320
321/** \defgroup multi_api_func Multi-object property access macros
322 * @{
323 */
324
325/*
326 * Macros for multi-object configuration and statistics retrieval
327 */
328
329/* Internal macro: Indicate that configuration property is present */
330#define _BCMOLT_MSGSET_PROP_SET_PRESENT(_set, _obj, _grp, _p) \
331 do { \
332 (_set)->presence_mask |= BCMOLT_PROP_MASK_GET(_obj, _grp, _p);\
333 } while (0)
334
335/* Internal macro: check if property is present */
336#define _BCMOLT_MSGSET_PROP_IS_PRESENT(_set, _obj, _grp, _p) \
337 (((_set)->presence_mask & BCMOLT_PROP_MASK_GET(_obj, _grp, _p)) ? \
338 BCMOS_TRUE : BCMOS_FALSE)
339
340/** Indicate that configuration property should be read
341 * \param[in] _set Message set
342 * \param[in] _obj Object type
343 * \param[in] _p Property name
344 */
345#define BCMOLT_MSGSET_CFG_PROP_GET(_set, _obj, _p) _BCMOLT_MSGSET_PROP_SET_PRESENT(_set, _obj, _cfg, _p)
346
347/** Check if configuration property is set in message set
348 * \param[in] _set Message set
349 * \param[in] _obj Object type
350 * \param[in] _p Property name
351 */
352#define BCMOLT_MSGSET_CFG_PROP_IS_SET(_set, _obj, _p) _BCMOLT_MSGSET_PROP_IS_PRESENT(_set, _obj, _cfg, _p)
353
354/** Indicate that statistic should be read
355 * \param[in] _set Message set
356 * \param[in] _obj Object type
357 * \param[in] _p Property name
358 */
359#define BCMOLT_MSGSET_STAT_PROP_GET(_set, _obj, _p) _BCMOLT_MSGSET_PROP_SET_PRESENT(_set, _obj, _stat, _p)
360
361/** Check if statistic property is set in message set
362 * \param[in] _set Message set
363 * \param[in] _obj Object type
364 * \param[in] _p Property name
365 */
366#define BCMOLT_MSGSET_STAT_PROP_IS_SET(_set, _obj, _p) _BCMOLT_MSGSET_PROP_IS_PRESENT(_m, _obj, _stat, _p)
367
368/** @} */
369
370/** @} */
371
372/** \defgroup api_func API Functions
373 * @{
374 */
375
376/*
377 * API
378 */
379
380typedef void (*system_mode_change_cb)(bcmolt_devid dev);
381
382extern system_mode_change_cb sm_change_cb;
383
384/** Set Configuration
385 *
386 * \param[in] dev Device id
387 * \param[in] cfg Configuration
388 * \returns error code
389 */
390bcmos_errno bcmolt_cfg_set(bcmolt_devid dev, bcmolt_cfg *cfg);
391
392/** Get Configuration
393 *
394 * \param[in] dev Device id
395 * \param[in] cfg Configuration
396 * \returns error code
397 * The error code can indicate local or remote failure
398 */
399bcmos_errno bcmolt_cfg_get(bcmolt_devid dev, bcmolt_cfg *cfg);
400
401/** Clear Configuration
402 *
403 * \param[in] dev Device id
404 * \param[in] cfg Configuration
405 * \returns error code
406 * The error code can indicate local or remote failure
407 */
408bcmos_errno bcmolt_cfg_clear(bcmolt_devid dev, bcmolt_cfg *cfg);
409
410/** Get Statistics
411 *
412 * \param[in] dev Device id
413 * \param[in] stat Configuration
414 * \param[in] flags Flags
415 * \returns error code
416 * The error code can indicate local or remote failure
417 */
418bcmos_errno bcmolt_stat_get(bcmolt_devid dev, bcmolt_stat *stat, bcmolt_stat_flags flags);
419
420/** Get Statistics Configuration
421 *
422 * \param[in] dev Device id
423 * \param[in] cfg Configuration
424 * \returns error code
425 * The error code can indicate local or remote failure
426 */
427bcmos_errno bcmolt_stat_cfg_get(bcmolt_devid dev, bcmolt_stat_cfg *cfg);
428
429/** Set Statistics Configuration
430 *
431 * \param[in] dev Device id
432 * \param[in] cfg Configuration
433 * \returns error code
434 * The error code can indicate local or remote failure
435 */
436bcmos_errno bcmolt_stat_cfg_set(bcmolt_devid dev, bcmolt_stat_cfg *cfg);
437
438/** Get Indication Configuration
439 *
440 * \param[in] dev Device id
441 * \param[in] cfg Configuration
442 * \returns error code
443 * The error code can indicate local or remote failure
444 */
445bcmos_errno bcmolt_auto_cfg_get(bcmolt_devid dev, bcmolt_auto_cfg *cfg);
446
447/** Set Indication Configuration
448 *
449 * \param[in] dev Device id
450 * \param[in] cfg Configuration
451 * \returns error code
452 * The error code can indicate local or remote failure
453 */
454bcmos_errno bcmolt_auto_cfg_set(bcmolt_devid dev, bcmolt_auto_cfg *cfg);
455
456/** Submit Operation
457 *
458 * \param[in] dev Device id
459 * \param[in] oper Operation
460 * \returns error code
461 */
462bcmos_errno bcmolt_oper_submit(bcmolt_devid dev, bcmolt_oper *oper);
463
464/** Send Message to ONU
465 *
466 * \param[in] dev Device id
467 * \param[in] msg Message to be sent
468 * \returns error code
469 */
470bcmos_errno bcmolt_proxy_send(bcmolt_devid dev, bcmolt_proxy *msg);
471
472/** Receive callback registration parameters */
473typedef struct bcmolt_rx_cfg
474{
475 bcmolt_obj_id obj_type; /**< Object type. Can be \ref BCMOLT_OBJECT_ANY */
476 f_bcmolt_msg_handler rx_cb; /**< Receive callback. NULL=unregister */
477 bcmolt_auto_flags flags; /**< Dispatch flags. Receive callback function can be called
478 in the context of rx task or application task,
479 depending on the flags */
480 bcmos_module_id module; /**< Target module id.
481 Relevant only if flags == BCMOLT_AUTO_FLAGS_DISPATCH */
482 uint32_t pon_ni_mask; /**< Bitmask of pon_ni interfaces the registration applies to.
483 0=all interfaces. Each interface is identified by (1 << pon_ni) bit */
484} bcmolt_rx_cfg;
485
486/* (Un)Register Autonomous Indication Message Handler
487 *
488 * \param[in] dev Device id
489 * \param[in] rx_cfg Receive handler configuration
490 * \returns error code
491 */
492bcmos_errno bcmolt_auto_rx_cb_set(bcmolt_devid device, bcmolt_rx_cfg *rx_cfg);
493
494/* (Un)Register Proxy Message Handler
495 *
496 * \param[in] dev Device id
497 * \param[in] rx_cfg Receive handler configuration
498 * \returns error code
499 */
500bcmos_errno bcmolt_proxy_rx_cb_set(bcmolt_devid device, bcmolt_rx_cfg *rx_cfg);
501
502/** \defgroup multi_api_func Multi-object API Functions
503 * @{
504 */
505
506/* Get configuration of multiple objects
507 * \param[in] olt Device id
508 * \param[in] filter Object filter. Header of generated bcmolt_xx_cfg structure
509 * \param[in] filter_flags Optional filtering flags
510 * \param[in,out] msg_set Message set
511 */
512bcmos_errno bcmolt_cfg_get_multi(bcmolt_devid olt, bcmolt_cfg *filter,
513 bcmolt_filter_flags filter_flags, bcmolt_msg_set *msg_set);
514
515/** @} */
516
517/** @} */
518
519/** @} */
520
521#endif /* BCMOLT_API_H_ */