blob: 60f1e0b4ff61bb39a1763804937dfa916ecfa95b [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_api.h
34 * @brief Function declarations and all inclusions required for the BAL Public API
35 *
36 * @defgroup api BAL Public API
37 */
38#ifndef BCMBAL_API_H
39#define BCMBAL_API_H
40
41#include <bcmos_system.h>
42#include <bcmolt_model_types.h>
43
44#include <bal_objs.h>
45
46
47/*@{*/
48
49/*
50 * This example only controls the default access terminal
51 */
52#define DEFAULT_ATERM_ID (0)
53
54/* Max number of access-terminals supported by BAL */
55#define MAX_ACC_TERM_ID (255)
56
57/*------------------------------------------------
58 * See the bal_objs.h file for the BAL objects
59 *------------------------------------------------
60 */
61
62/*
63 * An enumeration of the BAL mgmt operations
64 */
65typedef enum
66{
67 BCMBAL_MGMT_OPER_ID_SET = 1 << 0,
68 BCMBAL_MGMT_OPER_ID_GET = 1 << 1,
69 BCMBAL_MGMT_OPER_ID_GET_STATS = 1 << 2,
70 BCMBAL_MGMT_OPER_ID_CLEAR = 1 << 3,
71 BCMBAL_MGMT_OPER_ID__NUM_OF = 1 << 4,
72 BCMBAL_MGMT_OPER_ID_ALL = BCMBAL_MGMT_OPER_ID__NUM_OF - 1,
73} bcmbal_mgmt_oper_id;
74
75
76/* access_terminal:key:acc_term_id max value */
77#define BAL_API_MAX_ACC_TERM_ID (255)
78
79/* flow:key:flow_id max value */
80#define BAL_API_MAX_FLOW_ID (65535)
81
82/* interface:mtu limits */
83#define BAL_API_MIN_INTF_MTU_SIZE (64)
84#define BAL_API_MAX_INTF_MTU_SIZE (9216)
85
86/* Max number of interfaces per interface:type in BAL */
87#define BAL_API_MAX_INTF_ID (15)
88
89/* Max sub_term_id per interface for the various modes */
90#define BAL_API_MAX_SUB_TERM_ID_GPON (127)
91#define BAL_API_MAX_SUB_TERM_ID_EPON (256)
92#define BAL_API_MAX_SUB_TERM_ID_XGPON (511)
93
94/* Max and min values for interface attributes */
95#define BAL_API_MIN_LOW_DATA_AGG_PORT_ID (256)
96#define BAL_API_MAX_LOW_DATA_AGG_PORT_ID (14591)
97
98#define BAL_API_MIN_LOW_DATA_SVC_PORT_ID (1024)
99#define BAL_API_MAX_LOW_DATA_SVC_PORT_ID (57598)
100
101
102/* Max and Min values for agg_port_id and svc_port_id */
103#define BAL_API_MIN_DATA_SVC_PORT_ID (256)
104#define BAL_API_MAX_DATA_SVC_PORT_ID (16383)
105
106/* Max and Min values for agg_port_id and svc_port_id */
107#define BAL_API_MIN_DATA_AGG_PORT_ID (256)
108#define BAL_API_MAX_DATA_AGG_PORT_ID (16383)
109
110/* Max value for pbits */
111#define MAX_PBITS_VALUE (7)
112
113/*
114 * BAL CLI max values
115 */
116/** Max number of supported OLTs */
117#define MAX_SUPPORTED_OLTS (BAL_API_MAX_ACC_TERM_ID+1)
118
119/** Max number of supported subscriber terminals (ONUs) */
120#define MAX_SUPPORTED_SUBS (BAL_API_MAX_SUB_TERM_ID_XGPON+1)
121
122/** Max number of supported flows */
123#define MAX_SUPPORTED_FLOWS (BAL_API_MAX_FLOW_ID+1)
124
125/** Max number of supported PON and NNI interfaces */
126#define MAX_SUPPORTED_INTF (BAL_API_MAX_INTF_ID+1)
127
128/** BAL Indication callback handler function prototype */
129typedef void (*f_bcmbal_ind_handler)(bcmbal_obj *obj);
130
131/** BAL Indication callback registration parameters */
132typedef struct bcmbal_cb_cfg
133{
134 bcmbal_obj_id obj_type; /**< Object type */
135 f_bcmbal_ind_handler ind_cb_hdlr; /**< Indication callback function. NULL=unregister */
136 bcmos_module_id module; /**< Target module id.
137 If it is BCMOS_MODULE_ID_NONE (0), the callback will be called
138 in BAL's context. Otherwise, it will be called in application
139 module's context */
140} bcmbal_cb_cfg; /* This structure is used for passing the mgmt queue
141
142 * IP:port information between the core main thread and
143 * core worker thread and bal API.
144 */
145typedef struct mgmt_queue_addr_ports
146{
147 const char *core_mgmt_ip_port;
148 const char *balapi_mgmt_ip_port;
149} mgmt_queue_addr_ports;
150
151extern dev_log_id log_id_public_api;
152
153const char *bcmbal_get_interface_type_str(bcmbal_intf_type int_type);
154
155/*
156 *------------------------------------------------------------------------------------------
157 *
158 * @brief The BAL Public API
159 *
160 *------------------------------------------------------------------------------------------
161 */
162
163/**
164 * @brief Initialize the BAL Public API internal data structures
165 *
166 * @param balapi_mgmt_ip_port The IP:port of the BAL API management queue
167 *
168 * @param core_mgmt_ip_port The IP:port of the core management queue
169 *
170 * @returns bcmos_errno
171 *
172 **/
173bcmos_errno bcmbal_api_init(const char *balapi_mgmt_ip_port, const char *core_mgmt_ip_port);
174
175/**
176 * @brief Un-initialize the BAL Public API internal data structures
177 *
178 * @returns bcmos_errno == BCM_ERR_OK
179 *
180 **/
181bcmos_errno bcmbal_api_finish(void);
182
183/**
184 * @brief BAL Public API Set (or modify) command.
185 *
186 * Set (or modify) the specified object instance (with implicit creation
187 * of dynamic objects) associated with the specified access-terminal device.
188 *
189 * @param objinfo A pointer to a BAL object
190 *
191 * @returns bcmos_errno
192 *
193 **/
194bcmos_errno bcmbal_cfg_set(bcmbal_cfg *objinfo);
195
196/**
197 * @brief BAL Public API Get command.
198 *
199 * Get the specified object instance
200 *
201 * @param objinfo A pointer to a BAL object
202 *
203 * @returns bcmos_errno
204 *
205 */
206bcmos_errno bcmbal_cfg_get(bcmbal_cfg *objinfo);
207
208/**
209 * @brief BAL Public API Packet Send function.
210 *
211 * Send a packet to the specified destination
212 *
213 * @param dest The destination of the user packet
214 *
215 * @param packet_to_send A pointer to the user packet to send to the specified destination
216 *
217 * @param packet_len The length of the user packet (must be <=1600 bytes)
218 *
219 * @returns bcmos_errno
220 *
221 */
222bcmos_errno bcmbal_pkt_send(bcmbal_dest dest,
223 const char *packet_to_send,
224 uint16_t packet_len);
225
226/**
227 * @brief BAL Public API Clear command.
228 *
229 * Set all attributes to default (or remove the object instance for
230 * dynamic objects) for the specified object instance
231 *
232 * @param objinfo A pointer to a BAL object
233 *
234 * @returns bcmos_errno
235 *
236 */
237bcmos_errno bcmbal_cfg_clear(bcmbal_cfg * objinfo);
238
239/**
240 * @brief BAL Public API Get Stats command.
241 *
242 * Get (and clear) the stats associated with specified object instance
243 *
244 * @param objinfo A pointer to a BAL object
245 *
246 * @returns bcmos_errno
247 *
248 */
249bcmos_errno bcmbal_stat_get(bcmbal_stat *objinfo);
250
251/**
252 * @brief BAL Public API indication subscription.
253 *
254 * Subscription function for the specified indications
255 *
256 * @param cb_cfg A pointer to the callback configuration parameters for the
257 * object indications being subscribed to.
258 *
259 * @returns bcmos_errno
260 *
261 */
262bcmos_errno bcmbal_subscribe_ind(bcmbal_cb_cfg *cb_cfg);
263
264/**
265 * @brief BAL Public API indication un-subscription.
266 *
267 * Un-subscription function for the specified (or all) indications
268 *
269 * @param cb_cfg A pointer to the callback configuration parameters for the
270 * object indications being un-subscribed from.
271 *
272 * @returns bcmos_errno
273 *
274 */
275bcmos_errno bcmbal_unsubscribe_ind(bcmbal_cb_cfg *cb_cfg);
276
277/**
278 * @brief Get the number of NNI ports supported by the running system
279 *
280 * @returns Number of NNI ports
281 */
282uint16_t bcmbal_num_nni_ports_get(void);
283
284/*@}*/
285
286#endif /* BCMBAL_API_H */