blob: 1c34d6efaa3710a71168c11d03757b62292769ae [file] [log] [blame]
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301/*
2** Copyright 2017-present Open Networking Foundation
3**
4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at
7**
8** http://www.apache.org/licenses/LICENSE-2.0
9**
10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and
14** limitations under the License.
15*/
16
17#include "bal_indications_hdlr.h"
18
19/*static bcmos_mutex bal_ind_lock; - Need to define bcm independent mutex*/
20/********************************************************************\
21 * Function : bal_acc_term_indication_cb *
22 * Description : This function will handle the indications for *
23 * Access Terminal Indication *
24 * *
25 ********************************************************************/
26bcmos_errno bal_acc_term_indication_cb(bcmbal_obj *obj)
27{
28 bcmos_errno result = BCM_ERR_OK;
29
30 if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
31 bcmbal_access_terminal_auto_id_ind != obj->subgroup)
32 {
33 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
34 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
35 result = BCM_ERR_INTERNAL;
36 }
37 else
38 {
39 ASFVOLT_LOG(ASFVOLT_DEBUG, "suhas:Processing BAL API \'%s\' IND callback (status is %s)\n",
40 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
41 BalIndications balIndCfg;
42 memset(&balIndCfg, 0, sizeof(BalIndications));
43 bal_indications__init(&balIndCfg);
44 balIndCfg.u_case = BAL_INDICATIONS__U_ACCESS_TERM_IND;
45 balIndCfg.has_objtype = BAL_GRPC_PRES;
46 balIndCfg.objtype = obj->obj_type;
47 balIndCfg.has_sub_group = BAL_GRPC_PRES;
48 balIndCfg.sub_group = obj->subgroup;
49 balIndCfg.device_id = voltha_device_id;
50
51 bcmbal_access_terminal_ind *acc_term_ind = (bcmbal_access_terminal_ind *)obj;
52
53
54 BalAccessTerminalInd acessTermInd;
55 memset(&acessTermInd, 0, sizeof(BalAccessTerminalInd));
56 bal_access_terminal_ind__init(&acessTermInd);
57 balIndCfg.access_term_ind = &acessTermInd;
58
59 BalObj hdr;
60 memset(&hdr, 0, sizeof(BalObj));
61 bal_obj__init(&hdr);
62 balIndCfg.access_term_ind->hdr = &hdr;
63
64 BalAccessTerminalKey accessTermkey;
65 memset(&accessTermkey, 0, sizeof(BalAccessTerminalKey));
66 bal_access_terminal_key__init(&accessTermkey);
67 balIndCfg.access_term_ind->key = &accessTermkey;
68
69 balIndCfg.access_term_ind->key->has_access_term_id = BAL_GRPC_PRES;
70 balIndCfg.access_term_ind->key->access_term_id = acc_term_ind->key.access_term_id;
71
72 BalAccessTerminalIndData accessTermIndData;
73 memset(&accessTermIndData, 0, sizeof(BalAccessTerminalIndData));
74 bal_access_terminal_ind_data__init(&accessTermIndData);
75 balIndCfg.access_term_ind->data = &accessTermIndData;
76
77 balIndCfg.access_term_ind->data->has_admin_state = BAL_GRPC_PRES;
78 balIndCfg.access_term_ind->data->admin_state = acc_term_ind->data.admin_state;
79 balIndCfg.access_term_ind->data->has_oper_status = BAL_GRPC_PRES;
80 balIndCfg.access_term_ind->data->oper_status = acc_term_ind->data.oper_status;
81 balIndCfg.access_term_ind->data->has_iwf_mode = BAL_GRPC_PRES;
82 balIndCfg.access_term_ind->data->iwf_mode = acc_term_ind->data.iwf_mode;
83
84 BalTopology balTop;
85 memset(&balTop, 0, sizeof(BalTopology));
86 bal_topology__init(&balTop);
87 balIndCfg.access_term_ind->data->topology = &balTop;
88
89 balIndCfg.access_term_ind->data->topology->has_num_of_nni_ports = BAL_GRPC_PRES;
90 balIndCfg.access_term_ind->data->topology->num_of_nni_ports =
91 acc_term_ind->data.topology.num_of_nni_ports;
92 balIndCfg.access_term_ind->data->topology->has_num_of_pon_ports = BAL_GRPC_PRES;
93 balIndCfg.access_term_ind->data->topology->num_of_pon_ports =
94 acc_term_ind->data.topology.num_of_pon_ports;
95 balIndCfg.access_term_ind->data->topology->has_num_of_mac_devs = BAL_GRPC_PRES;
96 balIndCfg.access_term_ind->data->topology->num_of_mac_devs =
97 acc_term_ind->data.topology.num_of_mac_devs;
98 balIndCfg.access_term_ind->data->topology->has_num_of_pons_per_mac_dev = BAL_GRPC_PRES;
99 balIndCfg.access_term_ind->data->topology->num_of_pons_per_mac_dev =
100 acc_term_ind->data.topology.num_of_pons_per_mac_dev;
101 balIndCfg.access_term_ind->data->topology->has_pon_family = BAL_GRPC_PRES;
102 balIndCfg.access_term_ind->data->topology->pon_family =
103 acc_term_ind->data.topology.pon_family;
104 balIndCfg.access_term_ind->data->topology->has_pon_sub_family = BAL_GRPC_PRES;
105 balIndCfg.access_term_ind->data->topology->pon_sub_family =
106 acc_term_ind->data.topology.pon_sub_family;
107
108 BalSwVersion balsv;
109 memset(&balsv, 0, sizeof(BalSwVersion));
110 bal_sw_version__init(&balsv);
111 balIndCfg.access_term_ind->data->sw_version = &balsv;
112
113 balIndCfg.access_term_ind->data->sw_version->has_version_type = BAL_GRPC_PRES;
114 balIndCfg.access_term_ind->data->sw_version->version_type =
115 acc_term_ind->data.sw_version.version_type;
116 balIndCfg.access_term_ind->data->sw_version->has_major_rev = BAL_GRPC_PRES;
117 balIndCfg.access_term_ind->data->sw_version->major_rev =
118 acc_term_ind->data.sw_version.major_rev;
119 balIndCfg.access_term_ind->data->sw_version->has_minor_rev = BAL_GRPC_PRES;
120 balIndCfg.access_term_ind->data->sw_version->minor_rev =
121 acc_term_ind->data.sw_version.minor_rev;
122 balIndCfg.access_term_ind->data->sw_version->has_patch_rev = BAL_GRPC_PRES;
123 balIndCfg.access_term_ind->data->sw_version->patch_rev =
124 acc_term_ind->data.sw_version.patch_rev;
125 balIndCfg.access_term_ind->data->sw_version->has_om_version = BAL_GRPC_PRES;
126 balIndCfg.access_term_ind->data->sw_version->om_version =
127 acc_term_ind->data.sw_version.om_version;
128 balIndCfg.access_term_ind->data->sw_version->has_dev_point = BAL_GRPC_PRES;
129 balIndCfg.access_term_ind->data->sw_version->dev_point =
130 acc_term_ind->data.sw_version.dev_point;
131
132 bal_register_indication_cbs();
133
134 BalErr *output;
135 result = bal_ind__bal_acc_term_ind(client, NULL, &balIndCfg, &output, NULL, 0);
136 }
137
138 return result;
139}
140
141/********************************************************************\
142 * Function : bal_acc_term_osc_indication_cb *
143 * Description : This function will handle the indications for *
144 * Access Terminal Operational State Change *
145 * *
146 ********************************************************************/
147bcmos_errno bal_acc_term_osc_indication_cb(bcmbal_obj *obj)
148{
149 bcmos_errno result = BCM_ERR_OK;
150
151 if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
152 bcmbal_access_terminal_auto_id_oper_status_change != obj->subgroup)
153 {
154 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
155 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
156 result = BCM_ERR_INTERNAL;
157 }
158 else
159 {
160 BalIndications balIndCfg;
161 memset(&balIndCfg, 0, sizeof(BalIndications));
162 bal_indications__init(&balIndCfg);
163 balIndCfg.has_objtype = BAL_GRPC_PRES;
164 balIndCfg.objtype = obj->obj_type;
165 balIndCfg.has_sub_group = BAL_GRPC_PRES;
166 balIndCfg.sub_group = obj->subgroup;
167 balIndCfg.u_case = BAL_INDICATIONS__U_ACCESS_TERM_IND_OP_STATE;
168 balIndCfg.device_id = voltha_device_id;
169
170 bcmbal_access_terminal_oper_status_change *acc_term_osc =
171 (bcmbal_access_terminal_oper_status_change *)obj;
172
173 BalAccessTerminalOperStatusChange acessTermOSC;
174 memset(&acessTermOSC, 0, sizeof(BalAccessTerminalOperStatusChange));
175 bal_access_terminal_oper_status_change__init(&acessTermOSC);
176 balIndCfg.access_term_ind_op_state = &acessTermOSC;
177
178 BalAccessTerminalKey accessTermkey;
179 memset(&accessTermkey, 0, sizeof(BalAccessTerminalKey));
180 bal_access_terminal_key__init(&accessTermkey);
181 balIndCfg.access_term_ind_op_state->key = &accessTermkey;
182
183 balIndCfg.access_term_ind_op_state->key->has_access_term_id = BAL_GRPC_PRES;
184 balIndCfg.access_term_ind_op_state->key->access_term_id =
185 acc_term_osc->key.access_term_id;
186
187 BalAccessTerminalOperStatusChangeData accessTermOscData;
188 memset(&accessTermOscData, 0, sizeof(BalAccessTerminalOperStatusChangeData));
189 bal_access_terminal_oper_status_change_data__init(&accessTermOscData);
190 balIndCfg.access_term_ind_op_state->data = &accessTermOscData;
191
192 balIndCfg.access_term_ind_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
193 balIndCfg.access_term_ind_op_state->data->new_oper_status =
194 acc_term_osc->data.new_oper_status;
195 balIndCfg.access_term_ind_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
196 balIndCfg.access_term_ind_op_state->data->old_oper_status =
197 acc_term_osc->data.old_oper_status;
198 balIndCfg.access_term_ind_op_state->data->has_admin_state = BAL_GRPC_PRES;
199 balIndCfg.access_term_ind_op_state->data->admin_state =
200 acc_term_osc->data.admin_state;
201
202 BalErr *output;
203 result = bal_ind__bal_acc_term_oper_sts_cng_ind(client, NULL, &balIndCfg, &output, NULL, 0);
204 }
205
206 return result;
207}
208
209/********************************************************************\
210 * Function : bal_flow_osc_indication_cb *
211 * Description : This function will handle the indications for *
212 * Flow Operational State Change *
213 * *
214 ********************************************************************/
215bcmos_errno bal_flow_osc_indication_cb(bcmbal_obj *obj)
216{
217 bcmos_errno result = BCM_ERR_OK;
218
219 if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
220 bcmbal_flow_auto_id_oper_status_change != obj->subgroup)
221 {
222 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
223 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
224 result = BCM_ERR_INTERNAL;
225 }
226 else
227 {
228 BalIndications balIndCfg;
229 memset(&balIndCfg, 0, sizeof(BalIndications));
230 bal_indications__init(&balIndCfg);
231 balIndCfg.u_case = BAL_INDICATIONS__U_FLOW_OP_STATE;
232 balIndCfg.has_objtype = BAL_GRPC_PRES;
233 balIndCfg.objtype = obj->obj_type;
234 balIndCfg.has_sub_group = BAL_GRPC_PRES;
235 balIndCfg.sub_group = obj->subgroup;
236 balIndCfg.device_id = voltha_device_id;
237
238 bcmbal_flow_oper_status_change *flow_osc = (bcmbal_flow_oper_status_change *)obj;
239
240 BalFlowOperStatusChange flowOscInd;
241 memset(&flowOscInd, 0, sizeof(BalFlowOperStatusChange));
242 bal_flow_oper_status_change__init(&flowOscInd);
243 balIndCfg.flow_op_state = &flowOscInd;
244
245 BalFlowKey flowkey;
246 memset(&flowkey, 0, sizeof(BalFlowKey));
247 bal_flow_key__init(&flowkey);
248 balIndCfg.flow_op_state->key = &flowkey;
249
250 balIndCfg.flow_op_state->key->has_flow_id = BAL_GRPC_PRES;
251 balIndCfg.flow_op_state->key->flow_id = flow_osc->key.flow_id;
252 balIndCfg.flow_op_state->key->has_flow_type = BAL_GRPC_PRES;
253 balIndCfg.flow_op_state->key->flow_type = flow_osc->key.flow_type;
254
255 BalFlowOperStatusChangeData flowOscIndData;
256 memset(&flowOscIndData, 0, sizeof(BalFlowOperStatusChangeData));
257 bal_flow_oper_status_change_data__init(&flowOscIndData);
258 balIndCfg.flow_op_state->data = &flowOscIndData;
259
260 balIndCfg.flow_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
261 balIndCfg.flow_op_state->data->new_oper_status = flow_osc->data.new_oper_status;
262 balIndCfg.flow_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
263 balIndCfg.flow_op_state->data->old_oper_status = flow_osc->data.old_oper_status;
264 balIndCfg.flow_op_state->data->has_admin_state = BAL_GRPC_PRES;
265 balIndCfg.flow_op_state->data->admin_state = flow_osc->data.admin_state;
266 balIndCfg.flow_op_state->data->has_svc_port_id = BAL_GRPC_PRES;
267 balIndCfg.flow_op_state->data->svc_port_id = flow_osc->data.svc_port_id;
268 balIndCfg.flow_op_state->data->has_dba_tm_sched_id = BAL_GRPC_PRES;
269 balIndCfg.flow_op_state->data->dba_tm_sched_id = flow_osc->data.dba_tm_sched_id;
270 balIndCfg.flow_op_state->data->has_cookie = BAL_GRPC_PRES;
271 balIndCfg.flow_op_state->data->cookie = flow_osc->data.cookie;
272
273 BalErr *output;
274 result = bal_ind__bal_flow_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
275 }
276
277 return result;
278}
279
280/********************************************************************\
281 * Function : bal_flow_indication_cb *
282 * Description : This function will handle the indications for *
283 * Flow Indication *
284 * *
285 ********************************************************************/
286bcmos_errno bal_flow_indication_cb(bcmbal_obj *obj)
287{
288 bcmos_errno result = BCM_ERR_OK;
289
290 if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
291 bcmbal_flow_auto_id_ind != obj->subgroup)
292 {
293 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
294 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
295 result = BCM_ERR_INTERNAL;
296 }
297 else
298 {
299 BalIndications balIndCfg;
300 memset(&balIndCfg, 0, sizeof(BalIndications));
301 bal_indications__init(&balIndCfg);
302 balIndCfg.u_case = BAL_INDICATIONS__U_FLOW_IND;
303 balIndCfg.has_objtype = BAL_GRPC_PRES;
304 balIndCfg.objtype = obj->obj_type;
305 balIndCfg.has_sub_group = BAL_GRPC_PRES;
306 balIndCfg.sub_group = obj->subgroup;
307 balIndCfg.device_id = voltha_device_id;
308
309 bcmbal_flow_ind *flow_ind = (bcmbal_flow_ind *)obj;
310
311 BalFlowInd flowInd;
312 memset(&flowInd, 0, sizeof(BalFlowInd));
313 bal_flow_ind__init(&flowInd);
314 balIndCfg.flow_ind = &flowInd;
315
316 BalFlowKey flowkey;
317 memset(&flowkey, 0, sizeof(BalFlowKey));
318 bal_flow_key__init(&flowkey);
319 balIndCfg.flow_ind->key = &flowkey;
320
321 balIndCfg.flow_ind->key->has_flow_id = BAL_GRPC_PRES;
322 balIndCfg.flow_ind->key->flow_id = flow_ind->key.flow_id;
323 balIndCfg.flow_ind->key->has_flow_type = BAL_GRPC_PRES;
324 balIndCfg.flow_ind->key->flow_type = flow_ind->key.flow_type;
325
326 BalFlowIndData flowIndData;
327 memset(&flowIndData, 0, sizeof(BalFlowIndData));
328 bal_flow_ind_data__init(&flowIndData);
329 balIndCfg.flow_ind->data = &flowIndData;
330
331 balIndCfg.flow_ind->data->has_admin_state = BAL_GRPC_PRES;
332 balIndCfg.flow_ind->data->admin_state = flow_ind->data.admin_state;
333 balIndCfg.flow_ind->data->has_oper_status= BAL_GRPC_PRES;
334 balIndCfg.flow_ind->data->oper_status= flow_ind->data.oper_status;
335 balIndCfg.flow_ind->data->has_access_int_id = BAL_GRPC_PRES;
336 balIndCfg.flow_ind->data->access_int_id = flow_ind->data.access_int_id;
337 balIndCfg.flow_ind->data->has_network_int_id = BAL_GRPC_PRES;
338 balIndCfg.flow_ind->data->network_int_id = flow_ind->data.network_int_id;
339 balIndCfg.flow_ind->data->has_sub_term_id = BAL_GRPC_PRES;
340 balIndCfg.flow_ind->data->sub_term_id = flow_ind->data.sub_term_id;
341 balIndCfg.flow_ind->data->has_sub_term_uni_idx = BAL_GRPC_PRES;
342 balIndCfg.flow_ind->data->sub_term_uni_idx = flow_ind->data.sub_term_uni_idx;
343 balIndCfg.flow_ind->data->has_svc_port_id = BAL_GRPC_PRES;
344 balIndCfg.flow_ind->data->svc_port_id = flow_ind->data.svc_port_id;
345 balIndCfg.flow_ind->data->has_resolve_mac = BAL_GRPC_PRES;
346 balIndCfg.flow_ind->data->resolve_mac = flow_ind->data.resolve_mac;
347 balIndCfg.flow_ind->data->has_cookie = BAL_GRPC_PRES;
348 balIndCfg.flow_ind->data->cookie = flow_ind->data.cookie;
349
350 BalClassifier balClassifier;
351 memset(&balClassifier, 0, sizeof(BalClassifier));
352 bal_classifier__init(&balClassifier);
353 balIndCfg.flow_ind->data->classifier = &balClassifier;
354
355 balIndCfg.flow_ind->data->classifier->has_presence_mask = BAL_GRPC_PRES;
356 balIndCfg.flow_ind->data->classifier->presence_mask = flow_ind->data.classifier.presence_mask;
357 balIndCfg.flow_ind->data->classifier->has_o_tpid = BAL_GRPC_PRES;
358 balIndCfg.flow_ind->data->classifier->o_tpid = flow_ind->data.classifier.o_tpid;
359 balIndCfg.flow_ind->data->classifier->has_o_vid = BAL_GRPC_PRES;
360 balIndCfg.flow_ind->data->classifier->o_vid = flow_ind->data.classifier.o_vid;
361 balIndCfg.flow_ind->data->classifier->has_i_tpid = BAL_GRPC_PRES;
362 balIndCfg.flow_ind->data->classifier->i_tpid = flow_ind->data.classifier.i_tpid;
363 balIndCfg.flow_ind->data->classifier->has_i_vid = BAL_GRPC_PRES;
364 balIndCfg.flow_ind->data->classifier->i_vid = flow_ind->data.classifier.i_vid;
365 balIndCfg.flow_ind->data->classifier->has_o_pbits = BAL_GRPC_PRES;
366 balIndCfg.flow_ind->data->classifier->o_pbits = flow_ind->data.classifier.o_pbits;
367 balIndCfg.flow_ind->data->classifier->has_i_pbits = BAL_GRPC_PRES;
368 balIndCfg.flow_ind->data->classifier->i_pbits = flow_ind->data.classifier.i_pbits;
369 balIndCfg.flow_ind->data->classifier->has_ether_type = BAL_GRPC_PRES;
370 balIndCfg.flow_ind->data->classifier->ether_type = flow_ind->data.classifier.ether_type;
371 balIndCfg.flow_ind->data->classifier->has_dst_mac = BAL_GRPC_PRES;
372 balIndCfg.flow_ind->data->classifier->dst_mac.len =
373 (BCMOS_ETH_ALEN)*sizeof(flow_ind->data.classifier.dst_mac.u8);
374 memcpy(balIndCfg.flow_ind->data->classifier->dst_mac.data,
375 flow_ind->data.classifier.dst_mac.u8,
376 balIndCfg.flow_ind->data->classifier->dst_mac.len);
377 balIndCfg.flow_ind->data->classifier->has_src_mac = BAL_GRPC_PRES;
378 balIndCfg.flow_ind->data->classifier->src_mac.len =
379 (BCMOS_ETH_ALEN)*sizeof(flow_ind->data.classifier.src_mac.u8);
380 memcpy(balIndCfg.flow_ind->data->classifier->src_mac.data,
381 flow_ind->data.classifier.src_mac.u8,
382 balIndCfg.flow_ind->data->classifier->src_mac.len);
383 balIndCfg.flow_ind->data->classifier->has_ip_proto = BAL_GRPC_PRES;
384 balIndCfg.flow_ind->data->classifier->ip_proto = flow_ind->data.classifier.ip_proto;
385 balIndCfg.flow_ind->data->classifier->has_dst_ip = BAL_GRPC_PRES;
386 balIndCfg.flow_ind->data->classifier->dst_ip = flow_ind->data.classifier.dst_ip.u32;
387 balIndCfg.flow_ind->data->classifier->has_src_ip = BAL_GRPC_PRES;
388 balIndCfg.flow_ind->data->classifier->src_ip = flow_ind->data.classifier.src_ip.u32;
389 balIndCfg.flow_ind->data->classifier->has_src_port = BAL_GRPC_PRES;
390 balIndCfg.flow_ind->data->classifier->src_port = flow_ind->data.classifier.src_port;
391 balIndCfg.flow_ind->data->classifier->has_dst_port = BAL_GRPC_PRES;
392 balIndCfg.flow_ind->data->classifier->dst_port = flow_ind->data.classifier.dst_port;
393 balIndCfg.flow_ind->data->classifier->has_pkt_tag_type = BAL_GRPC_PRES;
394 balIndCfg.flow_ind->data->classifier->pkt_tag_type = flow_ind->data.classifier.pkt_tag_type;
395
396 BalAction balAction;
397 memset(&balAction, 0, sizeof(BalAction));
398 bal_action__init(&balAction);
399 balIndCfg.flow_ind->data->action = &balAction;
400
401 balIndCfg.flow_ind->data->action->has_presence_mask = BAL_GRPC_PRES;
402 balIndCfg.flow_ind->data->action->presence_mask = flow_ind->data.action.presence_mask;
403 balIndCfg.flow_ind->data->action->has_cmds_bitmask = BAL_GRPC_PRES;
404 balIndCfg.flow_ind->data->action->cmds_bitmask = flow_ind->data.action.cmds_bitmask;
405 balIndCfg.flow_ind->data->action->has_o_vid = BAL_GRPC_PRES;
406 balIndCfg.flow_ind->data->action->o_vid = flow_ind->data.action.o_vid;
407 balIndCfg.flow_ind->data->action->has_o_pbits = BAL_GRPC_PRES;
408 balIndCfg.flow_ind->data->action->o_pbits = flow_ind->data.action.o_pbits;
409 balIndCfg.flow_ind->data->action->has_o_tpid = BAL_GRPC_PRES;
410 balIndCfg.flow_ind->data->action->o_tpid = flow_ind->data.action.o_tpid;
411 balIndCfg.flow_ind->data->action->has_i_vid = BAL_GRPC_PRES;
412 balIndCfg.flow_ind->data->action->i_vid = flow_ind->data.action.i_vid;
413 balIndCfg.flow_ind->data->action->has_i_pbits = BAL_GRPC_PRES;
414 balIndCfg.flow_ind->data->action->i_pbits = flow_ind->data.action.i_pbits;
415 balIndCfg.flow_ind->data->action->has_i_tpid = BAL_GRPC_PRES;
416 balIndCfg.flow_ind->data->action->i_tpid = flow_ind->data.action.i_tpid;
417 BalErr *output;
418 result = bal_ind__bal_flow_ind(client, NULL, &balIndCfg, &output, NULL, 0);
419 }
420
421 return result;
422}
423
424/********************************************************************\
425 * Function : bal_group_indication_cb *
426 * Description : This function will handle the indications for *
427 * Group Indication *
428 * *
429 ********************************************************************/
430bcmos_errno bal_group_indication_cb(bcmbal_obj *obj)
431{
432 bcmos_errno result = BCM_ERR_OK;
433
434 if(BCMBAL_OBJ_ID_GROUP != obj->obj_type ||
435 bcmbal_group_auto_id_ind != obj->subgroup)
436 {
437 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
438 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
439 result = BCM_ERR_INTERNAL;
440 }
441 else
442 {
443 BalIndications balIndCfg;
444 memset(&balIndCfg, 0, sizeof(BalIndications));
445 bal_indications__init(&balIndCfg);
446 balIndCfg.u_case = BAL_INDICATIONS__U_GROUP_IND;
447 balIndCfg.has_objtype = BAL_GRPC_PRES;
448 balIndCfg.objtype = obj->obj_type;
449 balIndCfg.has_sub_group = BAL_GRPC_PRES;
450 balIndCfg.sub_group = obj->subgroup;
451 balIndCfg.device_id = voltha_device_id;
452
453 bcmbal_group_ind *group_ind = (bcmbal_group_ind *)obj;
454
455 BalGroupInd groupInd;
456 memset(&groupInd, 0, sizeof(BalGroupInd));
457 bal_group_ind__init(&groupInd);
458 balIndCfg.group_ind = &groupInd;
459
460 BalGroupKey groupkey;
461 memset(&groupkey, 0, sizeof(BalGroupKey));
462 bal_group_key__init(&groupkey);
463 balIndCfg.group_ind->key = &groupkey;
464
465 balIndCfg.group_ind->key->has_group_id = BAL_GRPC_PRES;
466 balIndCfg.group_ind->key->group_id = group_ind->key.group_id;
467
468 BalGroupIndData groupIndData;
469 memset(&groupIndData, 0, sizeof(BalGroupIndData));
470 bal_group_ind_data__init(&groupIndData);
471 balIndCfg.group_ind->data = &groupIndData;
472
473 balIndCfg.group_ind->data->has_members_cmd = BAL_GRPC_PRES;
474 balIndCfg.group_ind->data->members_cmd = group_ind->data.members_cmd;
475 balIndCfg.group_ind->data->has_cookie = BAL_GRPC_PRES;
476 balIndCfg.group_ind->data->cookie = group_ind->data.cookie;
477 balIndCfg.group_ind->data->has_owner = BAL_GRPC_PRES;
478 balIndCfg.group_ind->data->owner = group_ind->data.owner;
479
480 BalGroupMemberInfoList balMembers;
481 memset(&balMembers, 0, sizeof(BalGroupMemberInfoList));
482 bal_group_member_info_list__init(&balMembers);
483 balIndCfg.group_ind->data->members = &balMembers;
484
485 balIndCfg.group_ind->data->members->n_val = group_ind->data.members.len;
486
487 BalGroupMemberInfo *balMemberInfo;
488 balMemberInfo = (BalGroupMemberInfo *)malloc(sizeof(BalGroupMemberInfo));
489 memset(&balMemberInfo, 0, sizeof(BalGroupMemberInfo));
490 bal_group_member_info__init(balMemberInfo);
491 balIndCfg.group_ind->data->members->val = &balMemberInfo;
492
493 balMemberInfo->has_intf_id = BAL_GRPC_PRES;
494 balMemberInfo->intf_id = group_ind->data.members.val->intf_id;
495 balMemberInfo->has_svc_port_id = BAL_GRPC_PRES;
496 balMemberInfo->svc_port_id = group_ind->data.members.val->svc_port_id;
497
498 BalAction balAction;
499 memset(&balAction, 0, sizeof(BalAction));
500 bal_action__init(&balAction);
501 balMemberInfo->action = &balAction;
502
503 balMemberInfo->action->has_presence_mask = BAL_GRPC_PRES;
504 balMemberInfo->action->presence_mask = group_ind->data.members.val->action.presence_mask;
505 balMemberInfo->action->has_cmds_bitmask = BAL_GRPC_PRES;
506 balMemberInfo->action->cmds_bitmask = group_ind->data.members.val->action.cmds_bitmask;
507 balMemberInfo->action->has_o_vid = BAL_GRPC_PRES;
508 balMemberInfo->action->o_vid = group_ind->data.members.val->action.o_vid;
509 balMemberInfo->action->has_o_pbits = BAL_GRPC_PRES;
510 balMemberInfo->action->o_pbits = group_ind->data.members.val->action.o_pbits;
511 balMemberInfo->action->has_o_tpid = BAL_GRPC_PRES;
512 balMemberInfo->action->o_tpid = group_ind->data.members.val->action.o_tpid;
513 balMemberInfo->action->has_i_vid = BAL_GRPC_PRES;
514 balMemberInfo->action->i_vid = group_ind->data.members.val->action.i_vid;
515 balMemberInfo->action->has_i_pbits = BAL_GRPC_PRES;
516 balMemberInfo->action->i_pbits = group_ind->data.members.val->action.i_pbits;
517 balMemberInfo->action->has_i_tpid = BAL_GRPC_PRES;
518 balMemberInfo->action->i_tpid = group_ind->data.members.val->action.i_tpid;
519
520 BalTmQueueRef balQueue;
521 memset(&balQueue, 0, sizeof(BalTmQueueRef));
522 bal_tm_queue_ref__init(&balQueue);
523 balMemberInfo->queue = &balQueue;
524
525 balMemberInfo->queue->has_sched_id = BAL_GRPC_PRES;
526 balMemberInfo->queue->sched_id = group_ind->data.members.val->queue.sched_id;
527 balMemberInfo->queue->has_queue_id = BAL_GRPC_PRES;
528 balMemberInfo->queue->queue_id = group_ind->data.members.val->queue.queue_id;
529
530 BalIdList balFlows;
531 memset(&balFlows, 0, sizeof(BalIdList));
532 bal_id_list__init(&balFlows);
533 balIndCfg.group_ind->data->flows = &balFlows;
534
535 balIndCfg.group_ind->data->flows->n_val = group_ind->data.flows.len;
536 memcpy(balIndCfg.group_ind->data->flows->val, group_ind->data.flows.val,
537 balIndCfg.group_ind->data->flows->n_val);
538
539 BalErr *output;
540 result = bal_ind__bal_group_ind(client, NULL, &balIndCfg, &output, NULL, 0);
541 }
542
543 return result;
544}
545
546/********************************************************************\
547 * Function : bal_interface_osc_indication_cb *
548 * Description : This function will handle the indications for *
549 * Interface Operational State Change *
550 * *
551 ********************************************************************/
552bcmos_errno bal_interface_osc_indication_cb(bcmbal_obj *obj)
553{
554 bcmos_errno result = BCM_ERR_OK;
555
556 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
557 bcmbal_interface_auto_id_oper_status_change != obj->subgroup)
558 {
559 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
560 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
561 result = BCM_ERR_INTERNAL;
562 }
563 else
564 {
565 BalIndications balIndCfg;
566 memset(&balIndCfg, 0, sizeof(BalIndications));
567 bal_indications__init(&balIndCfg);
568 balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_OP_STATE;
569 balIndCfg.has_objtype = BAL_GRPC_PRES;
570 balIndCfg.objtype = obj->obj_type;
571 balIndCfg.has_sub_group = BAL_GRPC_PRES;
572 balIndCfg.sub_group = obj->subgroup;
573 balIndCfg.device_id = voltha_device_id;
574
575 bcmbal_interface_oper_status_change *int_osc_ind =
576 (bcmbal_interface_oper_status_change *)obj;
577
578 BalInterfaceOperStatusChange ifOsc;
579 memset(&ifOsc, 0, sizeof(BalInterfaceOperStatusChange));
580 bal_interface_oper_status_change__init(&ifOsc);
581 balIndCfg.interface_op_state = &ifOsc;
582
583 BalInterfaceKey ifkey;
584 memset(&ifkey, 0, sizeof(BalInterfaceKey));
585 bal_interface_key__init(&ifkey);
586 balIndCfg.interface_op_state->key = &ifkey;
587
588 balIndCfg.interface_op_state->key->has_intf_id = BAL_GRPC_PRES;
589 balIndCfg.interface_op_state->key->intf_id = int_osc_ind->key.intf_id;
590 balIndCfg.interface_op_state->key->has_intf_type = BAL_GRPC_PRES;
591 balIndCfg.interface_op_state->key->intf_type = int_osc_ind->key.intf_type;
592
593 BalInterfaceOperStatusChangeData ifOscIndData;
594 memset(&ifOscIndData, 0, sizeof(BalInterfaceOperStatusChangeData));
595 bal_interface_oper_status_change_data__init(&ifOscIndData);
596 balIndCfg.interface_op_state->data = &ifOscIndData;
597
598 balIndCfg.interface_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
599 balIndCfg.interface_op_state->data->new_oper_status = int_osc_ind->data.new_oper_status;
600 balIndCfg.interface_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
601 balIndCfg.interface_op_state->data->old_oper_status = int_osc_ind->data.old_oper_status;
602 balIndCfg.interface_op_state->data->has_admin_state = BAL_GRPC_PRES;
603 balIndCfg.interface_op_state->data->admin_state = int_osc_ind->data.admin_state;
604
605 BalErr *output;
606 result = bal_ind__bal_iface_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
607 }
608
609 return result;
610}
611
612/********************************************************************\
613 * Function : bal_interface_los_indication_cb *
614 * Description : This function will handle the indications for *
615 * Interface los Indication *
616 * *
617 ********************************************************************/
618bcmos_errno bal_interface_los_indication_cb(bcmbal_obj *obj)
619{
620 bcmos_errno result = BCM_ERR_OK;
621
622 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
623 bcmbal_interface_auto_id_los != obj->subgroup)
624 {
625 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
626 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
627 result = BCM_ERR_INTERNAL;
628 }
629 else
630 {
631 BalIndications balIndCfg;
632 memset(&balIndCfg, 0, sizeof(BalIndications));
633 bal_indications__init(&balIndCfg);
634 balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_LOS;
635 balIndCfg.has_objtype = BAL_GRPC_PRES;
636 balIndCfg.objtype = obj->obj_type;
637 balIndCfg.has_sub_group = BAL_GRPC_PRES;
638 balIndCfg.sub_group = obj->subgroup;
639 balIndCfg.device_id = voltha_device_id;
640
641 bcmbal_interface_los *int_los_ind =
642 (bcmbal_interface_los *)obj;
643
644 BalInterfaceLos ifLos;
645 memset(&ifLos, 0, sizeof(BalInterfaceLos));
646 bal_interface_los__init(&ifLos);
647 balIndCfg.interface_los = &ifLos;
648
649 BalObj hdr;
650 memset(&hdr, 0, sizeof(BalObj));
651 bal_obj__init(&hdr);
652 balIndCfg.interface_los->hdr = &hdr;
653
654 BalInterfaceKey ifkey;
655 memset(&ifkey, 0, sizeof(BalInterfaceKey));
656 bal_interface_key__init(&ifkey);
657 balIndCfg.interface_los->key = &ifkey;
658
659 balIndCfg.interface_los->key->has_intf_id = BAL_GRPC_PRES;
660 balIndCfg.interface_los->key->intf_id = int_los_ind->key.intf_id;
661 balIndCfg.interface_los->key->has_intf_type = BAL_GRPC_PRES;
662 balIndCfg.interface_los->key->intf_type = int_los_ind->key.intf_type;
663
664 BalInterfaceLosData ifLosIndData;
665 memset(&ifLosIndData, 0, sizeof(BalInterfaceLosData));
666 bal_interface_los_data__init(&ifLosIndData);
667 balIndCfg.interface_los->data = &ifLosIndData;
668
669 balIndCfg.interface_los->data->has_status = BAL_GRPC_PRES;
670 balIndCfg.interface_los->data->status = int_los_ind->data.status;
671
672 BalErr *output;
673 result = bal_ind__bal_iface_los(client, NULL, &balIndCfg, &output, NULL, 0);
674 }
675
676 return result;
677}
678
679/********************************************************************\
680 * Function : bal_interface_indication_cb *
681 * Description : This function will handle the indications for *
682 * Interface Indication *
683 * *
684 ********************************************************************/
685bcmos_errno bal_interface_indication_cb(bcmbal_obj *obj)
686{
687 bcmos_errno result = BCM_ERR_OK;
688
689 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
690 bcmbal_interface_auto_id_ind != obj->subgroup)
691 {
692 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
693 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
694 result = BCM_ERR_INTERNAL;
695 }
696 else
697 {
698 BalIndications balIndCfg;
699 memset(&balIndCfg, 0, sizeof(BalIndications));
700 bal_indications__init(&balIndCfg);
701 balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_IND;
702 balIndCfg.has_objtype = BAL_GRPC_PRES;
703 balIndCfg.objtype = obj->obj_type;
704 balIndCfg.has_sub_group = BAL_GRPC_PRES;
705 balIndCfg.sub_group = obj->subgroup;
706 balIndCfg.device_id = voltha_device_id;
707
708 bcmbal_interface_ind *interface_ind = (bcmbal_interface_ind *)obj;
709
710 BalInterfaceInd ifInd;
711 memset(&ifInd, 0, sizeof(BalInterfaceInd));
712 bal_interface_ind__init(&ifInd);
713 balIndCfg.interface_ind = &ifInd;
714
715 BalObj hdr;
716 memset(&hdr, 0, sizeof(BalObj));
717 bal_obj__init(&hdr);
718 balIndCfg.interface_ind->hdr = &hdr;
719
720 BalInterfaceKey ifkey;
721 memset(&ifkey, 0, sizeof(BalInterfaceKey));
722 bal_interface_key__init(&ifkey);
723 balIndCfg.interface_ind->key = &ifkey;
724
725 balIndCfg.interface_ind->key->has_intf_id = BAL_GRPC_PRES;
726 balIndCfg.interface_ind->key->intf_id = interface_ind->key.intf_id;
727 balIndCfg.interface_ind->key->has_intf_type = BAL_GRPC_PRES;
728 balIndCfg.interface_ind->key->intf_type = interface_ind->key.intf_type;
729
730 BalInterfaceIndData ifIndData;
731 memset(&ifIndData, 0, sizeof(BalInterfaceIndData));
732 bal_interface_ind_data__init(&ifIndData);
733 balIndCfg.interface_ind->data = &ifIndData;
734
735 balIndCfg.interface_ind->data->has_admin_state = BAL_GRPC_PRES;
736 balIndCfg.interface_ind->data->admin_state = interface_ind->data.admin_state;
737 balIndCfg.interface_ind->data->has_oper_status = BAL_GRPC_PRES;
738 balIndCfg.interface_ind->data->oper_status = interface_ind->data.oper_status;
739 balIndCfg.interface_ind->data->has_min_data_agg_port_id = BAL_GRPC_PRES;
740 balIndCfg.interface_ind->data->min_data_agg_port_id = interface_ind->data.min_data_agg_port_id;
741 balIndCfg.interface_ind->data->has_min_data_svc_port_id = BAL_GRPC_PRES;
742 balIndCfg.interface_ind->data->min_data_svc_port_id = interface_ind->data.min_data_svc_port_id;
743 balIndCfg.interface_ind->data->has_transceiver_type = BAL_GRPC_PRES;
744 balIndCfg.interface_ind->data->transceiver_type = interface_ind->data.transceiver_type;
745 balIndCfg.interface_ind->data->has_ds_miss_mode = BAL_GRPC_PRES;
746 balIndCfg.interface_ind->data->ds_miss_mode = interface_ind->data.ds_miss_mode;
747 balIndCfg.interface_ind->data->has_mtu = BAL_GRPC_PRES;
748 balIndCfg.interface_ind->data->mtu = interface_ind->data.mtu;
749 balIndCfg.interface_ind->data->has_flow_control = BAL_GRPC_PRES;
750 balIndCfg.interface_ind->data->flow_control = interface_ind->data.flow_control;
751 balIndCfg.interface_ind->data->has_ds_tm = BAL_GRPC_PRES;
752 balIndCfg.interface_ind->data->ds_tm = interface_ind->data.ds_tm;
753 balIndCfg.interface_ind->data->has_us_tm = BAL_GRPC_PRES;
754 balIndCfg.interface_ind->data->us_tm = interface_ind->data.us_tm;
755
756 BalIdList balFlows;
757 memset(&balFlows, 0, sizeof(BalIdList));
758 bal_id_list__init(&balFlows);
759 balIndCfg.interface_ind->data->sub_term_id_list = &balFlows;
760
761 balIndCfg.interface_ind->data->sub_term_id_list->n_val = interface_ind->data.sub_term_id_list.len;
762 memcpy(balIndCfg.interface_ind->data->sub_term_id_list->val, interface_ind->data.sub_term_id_list.val,
763 balIndCfg.interface_ind->data->sub_term_id_list->n_val);
764
765 BalErr *output;
766 result = bal_ind__bal_iface_ind(client, NULL, &balIndCfg, &output, NULL, 0);
767 }
768
769 return result;
770}
771
772/********************************************************************\
773 * Function : bal_sub_term_osc_indication_cb *
774 * Description : This function will handle the indications for *
775 * Subscriber term Operational State Change *
776 * *
777 ********************************************************************/
778bcmos_errno bal_sub_term_osc_indication_cb(bcmbal_obj *obj)
779{
780 bcmos_errno result = BCM_ERR_OK;
781
782 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
783 bcmbal_subscriber_terminal_auto_id_oper_status_change != obj->subgroup)
784 {
785 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
786 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
787 result = BCM_ERR_INTERNAL;
788 }
789 else
790 {
791 BalIndications balIndCfg;
792 memset(&balIndCfg, 0, sizeof(BalIndications));
793 bal_indications__init(&balIndCfg);
794 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_OP_STATE;
795 balIndCfg.has_objtype = BAL_GRPC_PRES;
796 balIndCfg.objtype = obj->obj_type;
797 balIndCfg.has_sub_group = BAL_GRPC_PRES;
798 balIndCfg.sub_group = obj->subgroup;
799 balIndCfg.device_id = voltha_device_id;
800
801 bcmbal_subscriber_terminal_oper_status_change *sub_osc_ind =
802 (bcmbal_subscriber_terminal_oper_status_change *)obj;
803
804 BalSubscriberTerminalOperStatusChange subOscInd;
805 memset(&subOscInd, 0, sizeof(BalSubscriberTerminalOperStatusChange));
806 bal_subscriber_terminal_oper_status_change__init(&subOscInd);
807 balIndCfg.terminal_op_state = &subOscInd;
808
809 BalSubscriberTerminalKey subkey;
810 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
811 bal_subscriber_terminal_key__init(&subkey);
812 balIndCfg.terminal_op_state->key = &subkey;
813
814 balIndCfg.terminal_op_state->key->has_intf_id = BAL_GRPC_PRES;
815 balIndCfg.terminal_op_state->key->intf_id = sub_osc_ind->key.intf_id;
816 balIndCfg.terminal_op_state->key->has_sub_term_id = BAL_GRPC_PRES;
817 balIndCfg.terminal_op_state->key->sub_term_id = sub_osc_ind->key.sub_term_id;
818
819 BalSubscriberTerminalOperStatusChangeData subOscIndData;
820 memset(&subOscIndData, 0, sizeof(BalSubscriberTerminalOperStatusChangeData));
821 bal_subscriber_terminal_oper_status_change_data__init(&subOscIndData);
822 balIndCfg.terminal_op_state->data = &subOscIndData;
823
824 balIndCfg.terminal_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
825 balIndCfg.terminal_op_state->data->new_oper_status =
826 sub_osc_ind->data.new_oper_status;
827 balIndCfg.terminal_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
828 balIndCfg.terminal_op_state->data->old_oper_status =
829 sub_osc_ind->data.old_oper_status;
830 balIndCfg.terminal_op_state->data->has_admin_state = BAL_GRPC_PRES;
831 balIndCfg.terminal_op_state->data->admin_state =
832 sub_osc_ind->data.admin_state;
833
834 BalErr *output;
835 result = bal_ind__bal_subs_term_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
836 }
837
838 return result;
839}
840
841/********************************************************************\
842 * Function : bal_sub_term_disc_indication_cb *
843 * Description : This function will handle the indications for *
844 * Subscriber term disc indication *
845 * *
846 ********************************************************************/
847bcmos_errno bal_sub_term_disc_indication_cb(bcmbal_obj *obj)
848{
849 bcmos_errno result = BCM_ERR_OK;
850
851 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
852 bcmbal_subscriber_terminal_auto_id_sub_term_disc != obj->subgroup)
853 {
854 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
855 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
856 result = BCM_ERR_INTERNAL;
857 }
858 else
859 {
860 ASFVOLT_LOG(ASFVOLT_DEBUG, "Processing BAL API \'%s\' IND callback (status is %s)\n",
861 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
862 BalIndications balIndCfg;
863 memset(&balIndCfg, 0, sizeof(BalIndications));
864 bal_indications__init(&balIndCfg);
865 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DISC;
866 balIndCfg.has_objtype = BAL_GRPC_PRES;
867 balIndCfg.objtype = obj->obj_type;
868 balIndCfg.has_sub_group = BAL_GRPC_PRES;
869 balIndCfg.sub_group = obj->subgroup;
870 balIndCfg.device_id = voltha_device_id;
871
872 bcmbal_subscriber_terminal_sub_term_disc *sub_disc_ind =
873 (bcmbal_subscriber_terminal_sub_term_disc *)obj;
874
875 BalSubscriberTerminalSubTermDisc subDiscInd;
876 memset(&subDiscInd, 0, sizeof(BalSubscriberTerminalSubTermDisc));
877 bal_subscriber_terminal_sub_term_disc__init(&subDiscInd);
878 balIndCfg.terminal_disc = &subDiscInd;
879
880 BalObj hdr;
881 memset(&hdr, 0, sizeof(BalObj));
882 bal_obj__init(&hdr);
883 balIndCfg.terminal_disc->hdr = &hdr;
884
885 BalSubscriberTerminalKey subkey;
886 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
887 bal_subscriber_terminal_key__init(&subkey);
888 balIndCfg.terminal_disc->key = &subkey;
889
890 balIndCfg.terminal_disc->key->has_intf_id = BAL_GRPC_PRES;
891 balIndCfg.terminal_disc->key->intf_id = sub_disc_ind->key.intf_id;
892 balIndCfg.terminal_disc->key->has_sub_term_id = BAL_GRPC_PRES;
893 balIndCfg.terminal_disc->key->sub_term_id = sub_disc_ind->key.sub_term_id;
894
895 BalSubscriberTerminalSubTermDiscData subDiscIndData;
896 memset(&subDiscIndData, 0, sizeof(BalSubscriberTerminalSubTermDiscData));
897 bal_subscriber_terminal_sub_term_disc_data__init(&subDiscIndData);
898 balIndCfg.terminal_disc->data = &subDiscIndData;
899
900 BalSerialNumber serial_number;
901 memset(&serial_number, 0, sizeof(BalSerialNumber));
902 bal_serial_number__init(&serial_number);
903
904 balIndCfg.terminal_disc->data->serial_number = &serial_number;
905
906 ASFVOLT_LOG(ASFVOLT_DEBUG, "Discovered ONU serial number "
907 "%2X%2X%2X%2X%1X%1X%1X%1X%1X%1X%1X%1X ",
908 sub_disc_ind->data.serial_number.vendor_id[0],
909 sub_disc_ind->data.serial_number.vendor_id[1],
910 sub_disc_ind->data.serial_number.vendor_id[2],
911 sub_disc_ind->data.serial_number.vendor_id[3],
912 sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
913 sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
914 sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
915 sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
916 sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
917 sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
918 sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
919 sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
920
921 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor id is %s\n", sub_disc_ind->data.serial_number.vendor_id);
922 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor specific is %s\n", sub_disc_ind->data.serial_number.vendor_specific);
923
924 char vendor_id[MAX_CHAR_LENGTH];
925 memset(&vendor_id, 0, MAX_CHAR_LENGTH);
926 sprintf(vendor_id,"%c%c%c%c",
927 sub_disc_ind->data.serial_number.vendor_id[0],
928 sub_disc_ind->data.serial_number.vendor_id[1],
929 sub_disc_ind->data.serial_number.vendor_id[2],
930 sub_disc_ind->data.serial_number.vendor_id[3]);
931 balIndCfg.terminal_disc->data->serial_number->vendor_id = vendor_id;
932 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor id is %s\n", balIndCfg.terminal_disc->data->serial_number->vendor_id);
933 char vendor_specific[MAX_CHAR_LENGTH];
934 memset(&vendor_specific, 0, MAX_CHAR_LENGTH);
935 sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
936 sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
937 sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
938 sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
939 sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
940 sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
941 sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
942 sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
943 sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
944 balIndCfg.terminal_disc->data->serial_number->vendor_specific = vendor_specific;
945 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor specific is %s\n", balIndCfg.terminal_disc->data->serial_number->vendor_specific);
946
947 BalErr *output;
948 result = bal_ind__bal_subs_term_discovery_ind(client, NULL, &balIndCfg, &output, NULL, 0);
949 }
950
951 return result;
952}
953
954/********************************************************************\
955 * Function : bal_sub_term_alarm_indication_cb *
956 * Description : This function will handle the indications for *
957 * Subscriber term alarm indication *
958 * *
959 ********************************************************************/
960bcmos_errno bal_sub_term_alarm_indication_cb(bcmbal_obj *obj)
961{
962 bcmos_errno result = BCM_ERR_OK;
963
964 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
965 bcmbal_subscriber_terminal_auto_id_sub_term_alarm != obj->subgroup)
966 {
967 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
968 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
969 result = BCM_ERR_INTERNAL;
970 }
971 else
972 {
973 BalIndications balIndCfg;
974 memset(&balIndCfg, 0, sizeof(BalIndications));
975 bal_indications__init(&balIndCfg);
976 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_ALARM;
977 balIndCfg.has_objtype = BAL_GRPC_PRES;
978 balIndCfg.objtype = obj->obj_type;
979 balIndCfg.has_sub_group = BAL_GRPC_PRES;
980 balIndCfg.sub_group = obj->subgroup;
981 balIndCfg.device_id = voltha_device_id;
982
983 bcmbal_subscriber_terminal_sub_term_alarm *sub_term_alarm =
984 (bcmbal_subscriber_terminal_sub_term_alarm *)obj;
985
986 BalSubscriberTerminalSubTermAlarm subTermAlarm;
987 memset(&subTermAlarm, 0, sizeof(BalSubscriberTerminalSubTermAlarm));
988 bal_subscriber_terminal_sub_term_alarm__init(&subTermAlarm);
989 balIndCfg.terminal_alarm = &subTermAlarm;
990
991 BalObj hdr;
992 memset(&hdr, 0, sizeof(BalObj));
993 bal_obj__init(&hdr);
994 balIndCfg.terminal_alarm->hdr = &hdr;
995
996 BalSubscriberTerminalKey subkey;
997 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
998 bal_subscriber_terminal_key__init(&subkey);
999 balIndCfg.terminal_alarm->key = &subkey;
1000
1001 balIndCfg.terminal_alarm->key->has_intf_id = BAL_GRPC_PRES;
1002 balIndCfg.terminal_alarm->key->intf_id = sub_term_alarm->key.intf_id;
1003 balIndCfg.terminal_alarm->key->has_sub_term_id = BAL_GRPC_PRES;
1004 balIndCfg.terminal_alarm->key->sub_term_id = sub_term_alarm->key.sub_term_id;
1005
1006 BalsubscriberTerminalSubTermAlarmData subTermAlarmData;
1007 memset(&subTermAlarmData, 0, sizeof(BalsubscriberTerminalSubTermAlarmData));
1008 balsubscriber_terminal_sub_term_alarm_data__init(&subTermAlarmData);
1009 balIndCfg.terminal_alarm->data = &subTermAlarmData;
1010
1011 BalSubscriberTerminalAlarms balSubAlarms;
1012 memset(&balSubAlarms, 0, sizeof(BalSubscriberTerminalAlarms));
1013 bal_subscriber_terminal_alarms__init(&balSubAlarms);
1014 balIndCfg.terminal_alarm->data->alarm = &balSubAlarms;
1015
1016 balIndCfg.terminal_alarm->data->alarm->has_los = BAL_GRPC_PRES;
1017 balIndCfg.terminal_alarm->data->alarm->los = sub_term_alarm->data.alarm.los;
1018 balIndCfg.terminal_alarm->data->alarm->has_lob = BAL_GRPC_PRES;
1019 balIndCfg.terminal_alarm->data->alarm->lob = sub_term_alarm->data.alarm.lob;
1020 balIndCfg.terminal_alarm->data->alarm->has_lopc_miss = BAL_GRPC_PRES;
1021 balIndCfg.terminal_alarm->data->alarm->lopc_miss = sub_term_alarm->data.alarm.lopc_miss;
1022 balIndCfg.terminal_alarm->data->alarm->has_lopc_mic_error = BAL_GRPC_PRES;
1023 balIndCfg.terminal_alarm->data->alarm->lopc_mic_error = sub_term_alarm->data.alarm.lopc_mic_error;
1024
1025 BalErr *output;
1026 result = bal_ind__bal_subs_term_alarm_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1027 }
1028
1029 return result;
1030}
1031
1032/********************************************************************\
1033 * Function : bal_sub_term_dgi_indication_cb *
1034 * Description : This function will handle the indications for *
1035 * Subscriber term dgi indication *
1036 * *
1037 ********************************************************************/
1038bcmos_errno bal_sub_term_dgi_indication_cb(bcmbal_obj *obj)
1039{
1040 bcmos_errno result = BCM_ERR_OK;
1041
1042 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1043 bcmbal_subscriber_terminal_auto_id_dgi != obj->subgroup)
1044 {
1045 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1046 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1047 result = BCM_ERR_INTERNAL;
1048 }
1049 else
1050 {
1051 BalIndications balIndCfg;
1052 memset(&balIndCfg, 0, sizeof(BalIndications));
1053 bal_indications__init(&balIndCfg);
1054 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DGI;
1055 balIndCfg.has_objtype = BAL_GRPC_PRES;
1056 balIndCfg.objtype = obj->obj_type;
1057 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1058 balIndCfg.sub_group = obj->subgroup;
1059 balIndCfg.device_id = voltha_device_id;
1060
1061 bcmbal_subscriber_terminal_dgi *sub_dgi_ind =
1062 (bcmbal_subscriber_terminal_dgi *)obj;
1063
1064 BalSubscriberTerminalDgi subDgiInd;
1065 memset(&subDgiInd, 0, sizeof(BalSubscriberTerminalDgi));
1066 bal_subscriber_terminal_dgi__init(&subDgiInd);
1067 balIndCfg.terminal_dgi= &subDgiInd;
1068
1069 BalSubscriberTerminalKey subkey;
1070 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
1071 bal_subscriber_terminal_key__init(&subkey);
1072 balIndCfg.terminal_disc->key = &subkey;
1073
1074 balIndCfg.terminal_dgi->key->has_intf_id = BAL_GRPC_PRES;
1075 balIndCfg.terminal_dgi->key->intf_id = sub_dgi_ind->key.intf_id;
1076 balIndCfg.terminal_dgi->key->has_sub_term_id = BAL_GRPC_PRES;
1077 balIndCfg.terminal_dgi->key->sub_term_id = sub_dgi_ind->key.sub_term_id;
1078
1079 BalSubscriberTerminalDgiData subDgiIndData;
1080 memset(&subDgiIndData, 0, sizeof(BalSubscriberTerminalDgiData));
1081 bal_subscriber_terminal_dgi_data__init(&subDgiIndData);
1082 balIndCfg.terminal_dgi->data = &subDgiIndData;
1083
1084 balIndCfg.terminal_dgi->data->has_dgi_status = BAL_GRPC_PRES;
1085 balIndCfg.terminal_dgi->data->dgi_status = sub_dgi_ind->data.dgi_status;
1086
1087 BalErr *output;
1088 result = bal_ind__bal_subs_term_dgi_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1089 }
1090
1091 return result;
1092}
1093
1094/********************************************************************\
1095 * Function : bal_sub_term_indication_cb *
1096 * Description : This function will handle the indications for *
1097 * Subscriber term indication *
1098 * *
1099 ********************************************************************/
1100bcmos_errno bal_sub_term_indication_cb(bcmbal_obj *obj)
1101{
1102 bcmos_errno result = BCM_ERR_OK;
1103
1104 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1105 bcmbal_subscriber_terminal_auto_id_ind != obj->subgroup)
1106 {
1107 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1108 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1109 result = BCM_ERR_INTERNAL;
1110 }
1111 else
1112 {
1113 BalIndications balIndCfg;
1114 memset(&balIndCfg, 0, sizeof(BalIndications));
1115 bal_indications__init(&balIndCfg);
1116 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_IND;
1117 balIndCfg.has_objtype = BAL_GRPC_PRES;
1118 balIndCfg.objtype = obj->obj_type;
1119 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1120 balIndCfg.sub_group = obj->subgroup;
1121 balIndCfg.device_id = voltha_device_id;
1122
1123 bcmbal_subscriber_terminal_ind *sub_ind = (bcmbal_subscriber_terminal_ind *)obj;
1124
1125 BalSubscriberTerminalInd subInd;
1126 memset(&subInd, 0, sizeof(BalSubscriberTerminalInd));
1127 bal_subscriber_terminal_ind__init(&subInd);
1128 balIndCfg.terminal_ind = &subInd;
1129
1130 BalObj hdr;
1131 memset(&hdr, 0, sizeof(BalObj));
1132 bal_obj__init(&hdr);
1133 balIndCfg.terminal_ind->hdr = &hdr;
1134
1135 BalSubscriberTerminalKey subkey;
1136 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
1137 bal_subscriber_terminal_key__init(&subkey);
1138 balIndCfg.terminal_ind->key = &subkey;
1139
1140 balIndCfg.terminal_ind->key->has_intf_id = BAL_GRPC_PRES;
1141 balIndCfg.terminal_ind->key->intf_id = sub_ind->key.intf_id;
1142 balIndCfg.terminal_ind->key->has_sub_term_id = BAL_GRPC_PRES;
1143 balIndCfg.terminal_ind->key->sub_term_id = sub_ind->key.sub_term_id;
1144
1145 BalSubscriberTerminalIndData subIndData;
1146 memset(&subIndData, 0, sizeof(BalSubscriberTerminalIndData));
1147 bal_subscriber_terminal_ind_data__init(&subIndData);
1148 balIndCfg.terminal_ind->data = &subIndData;
1149
1150 balIndCfg.terminal_ind->data->has_admin_state = BAL_GRPC_PRES;
1151 balIndCfg.terminal_ind->data->admin_state = sub_ind->data.admin_state;
1152 balIndCfg.terminal_ind->data->has_oper_status = BAL_GRPC_PRES;
1153 balIndCfg.terminal_ind->data->oper_status = sub_ind->data.oper_status;
1154 balIndCfg.terminal_ind->data->has_svc_port_id = BAL_GRPC_PRES;
1155 balIndCfg.terminal_ind->data->svc_port_id = sub_ind->data.svc_port_id;
1156 balIndCfg.terminal_ind->data->has_ds_tm = BAL_GRPC_PRES;
1157 balIndCfg.terminal_ind->data->ds_tm = sub_ind->data.ds_tm;
1158 balIndCfg.terminal_ind->data->has_us_tm = BAL_GRPC_PRES;
1159 balIndCfg.terminal_ind->data->us_tm = sub_ind->data.us_tm;
1160 balIndCfg.terminal_ind->data->has_sub_term_rate = BAL_GRPC_PRES;
1161 balIndCfg.terminal_ind->data->sub_term_rate = sub_ind->data.sub_term_rate;
1162 char password[MAX_CHAR_LENGTH*2];
1163 memset(&password, 0, MAX_CHAR_LENGTH*2);
1164 strcpy(password,(const char *)sub_ind->data.password.arr);
1165 balIndCfg.terminal_ind->data->password = password;
1166 char registration_id[MAX_CHAR_LENGTH*8];
1167 memset(&registration_id, 0, MAX_CHAR_LENGTH*8);
1168 strcpy(registration_id,(const char *)sub_ind->data.registration_id.arr);
1169 balIndCfg.terminal_ind->data->registration_id = registration_id;
1170
1171#if 0
1172 balIndCfg.terminal_ind->data->has_mac_address = BAL_GRPC_PRES;
1173 balIndCfg.terminal_ind->data->mac_address.len =
1174 (BCMOS_ETH_ALEN)*sizeof(sub_ind->data.mac_address.u8);
1175 uint8_t mac_address[balIndCfg.terminal_ind->data->mac_address.len];
1176 memset(&mac_address, 0 ,balIndCfg.terminal_ind->data->mac_address.len);
1177 strcpy((char *)mac_address,(const char *)sub_ind->data.mac_address.u8);
1178 balIndCfg.terminal_ind->data->mac_address.data = mac_address;
1179#endif
1180
1181 BalSerialNumber serialNum;
1182 memset(&serialNum, 0, sizeof(BalSerialNumber));
1183 bal_serial_number__init(&serialNum);
1184 balIndCfg.terminal_ind->data->serial_number = &serialNum;
1185
1186 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:Before decoding:Vendor id is %s\n", sub_ind->data.serial_number.vendor_id);
1187 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:Before decoding:Vendor specific is %s\n", sub_ind->data.serial_number.vendor_specific);
1188
1189 char vendor_id[MAX_CHAR_LENGTH];
1190 memset(&vendor_id, 0, MAX_CHAR_LENGTH);
1191 sprintf(vendor_id,"%c%c%c%c",
1192 sub_ind->data.serial_number.vendor_id[0],
1193 sub_ind->data.serial_number.vendor_id[1],
1194 sub_ind->data.serial_number.vendor_id[2],
1195 sub_ind->data.serial_number.vendor_id[3]);
1196 balIndCfg.terminal_ind->data->serial_number->vendor_id = vendor_id;
1197 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:After decoding:Vendor id is %s\n", balIndCfg.terminal_ind->data->serial_number->vendor_id);
1198 char vendor_specific[MAX_CHAR_LENGTH];
1199 memset(&vendor_specific, 0, MAX_CHAR_LENGTH);
1200 sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
1201 sub_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
1202 sub_ind->data.serial_number.vendor_specific[0] & 0x0f,
1203 sub_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
1204 sub_ind->data.serial_number.vendor_specific[1] & 0x0f,
1205 sub_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
1206 sub_ind->data.serial_number.vendor_specific[2] & 0x0f,
1207 sub_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
1208 sub_ind->data.serial_number.vendor_specific[3] & 0x0f);
1209 balIndCfg.terminal_ind->data->serial_number->vendor_specific = vendor_specific;
1210 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:After decoding:Vendor specific is %s\n", balIndCfg.terminal_ind->data->serial_number->vendor_specific);
1211
1212 BalIdList balAggportList;
1213 memset(&balAggportList, 0, sizeof(BalIdList));
1214 bal_id_list__init(&balAggportList);
1215 balIndCfg.terminal_ind->data->agg_port_id_list = &balAggportList;
1216
1217#if 0
1218 balIndCfg.terminal_ind->data->agg_port_id_list->n_val = sub_ind->data.agg_port_id_list.len;
1219 uint32_t agg_port_id_list[balIndCfg.terminal_ind->data->agg_port_id_list->n_val];
1220 memset(&agg_port_id_list, 0, balIndCfg.terminal_ind->data->agg_port_id_list->n_val);
1221 strcpy((char *)agg_port_id_list,(const char *)sub_ind->data.agg_port_id_list.val);
1222 balIndCfg.terminal_ind->data->agg_port_id_list->val = agg_port_id_list;
1223#endif
1224
1225 BalErr *output;
1226 result = bal_ind__bal_subs_term_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1227 }
1228
1229 return result;
1230}
1231
1232/********************************************************************\
1233 * Function : fill_bal_tm_red *
1234 * Description : This function will fill grpc-BalTmred struture *
1235 * from bal-bcmbal_tm_red structure *
1236 * *
1237 ********************************************************************/
1238void fill_bal_tm_red(BalTmred *grpc_red, bcmbal_tm_red *bal_red)
1239{
1240 grpc_red->has_min_threshold = BAL_GRPC_PRES;
1241 grpc_red->min_threshold = bal_red->min_threshold;
1242 grpc_red->has_max_threshold = BAL_GRPC_PRES;
1243 grpc_red->max_threshold = bal_red->max_threshold;
1244 grpc_red->has_max_probability = BAL_GRPC_PRES;
1245 grpc_red->max_probability = bal_red->max_probability;
1246 return;
1247}
1248
1249/********************************************************************\
1250 * Function : bal_tm_queue_indication_cb *
1251 * Description : This function will handle the indications for *
1252 * TM Queue indication *
1253 * *
1254 ********************************************************************/
1255bcmos_errno bal_tm_queue_indication_cb(bcmbal_obj *obj)
1256{
1257 bcmos_errno result = BCM_ERR_OK;
1258
1259 if(BCMBAL_OBJ_ID_TM_QUEUE != obj->obj_type ||
1260 bcmbal_tm_queue_auto_id_ind != obj->subgroup)
1261 {
1262 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1263 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1264 result = BCM_ERR_INTERNAL;
1265 }
1266 else
1267 {
1268 BalIndications balIndCfg;
1269 memset(&balIndCfg, 0, sizeof(BalIndications));
1270 bal_indications__init(&balIndCfg);
1271 balIndCfg.u_case = BAL_INDICATIONS__U_TM_QUEUE__IND;
1272 balIndCfg.has_objtype = BAL_GRPC_PRES;
1273 balIndCfg.objtype = obj->obj_type;
1274 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1275 balIndCfg.sub_group = obj->subgroup;
1276 balIndCfg.device_id = voltha_device_id;
1277
1278 bcmbal_tm_queue_ind *tm_que_ind = (bcmbal_tm_queue_ind *)obj;
1279
1280 BalTmQueueInd tmQueInd;
1281 memset(&tmQueInd, 0, sizeof(BalTmQueueInd));
1282 bal_tm_queue_ind__init(&tmQueInd);
1283 balIndCfg.tm_queue_ind = &tmQueInd;
1284
1285 BalTmQueueKey tmQkey;
1286 memset(&tmQkey, 0, sizeof(BalTmQueueKey));
1287 bal_tm_queue_key__init(&tmQkey);
1288 balIndCfg.tm_queue_ind->key = &tmQkey;
1289
1290 balIndCfg.tm_queue_ind->key->has_sched_id = BAL_GRPC_PRES;
1291 balIndCfg.tm_queue_ind->key->sched_id = tm_que_ind->key.sched_id;
1292 balIndCfg.tm_queue_ind->key->has_sched_dir = BAL_GRPC_PRES;
1293 balIndCfg.tm_queue_ind->key->sched_dir = tm_que_ind->key.sched_dir;
1294 balIndCfg.tm_queue_ind->key->has_id = BAL_GRPC_PRES;
1295 balIndCfg.tm_queue_ind->key->id = tm_que_ind->key.id;
1296
1297 BalTmQueueIndData tmQIndData;
1298 memset(&tmQIndData, 0, sizeof(BalTmQueueIndData));
1299 bal_tm_queue_ind_data__init(&tmQIndData);
1300 balIndCfg.tm_queue_ind->data = &tmQIndData;
1301
1302 balIndCfg.tm_queue_ind->data->has_priority = BAL_GRPC_PRES;
1303 balIndCfg.tm_queue_ind->data->priority = tm_que_ind->data.priority;
1304 balIndCfg.tm_queue_ind->data->has_weight = BAL_GRPC_PRES;
1305 balIndCfg.tm_queue_ind->data->weight = tm_que_ind->data.weight;
1306 balIndCfg.tm_queue_ind->data->has_create_mode = BAL_GRPC_PRES;
1307 balIndCfg.tm_queue_ind->data->create_mode = tm_que_ind->data.create_mode;
1308 balIndCfg.tm_queue_ind->data->has_ref_count = BAL_GRPC_PRES;
1309 balIndCfg.tm_queue_ind->data->ref_count = tm_que_ind->data.ref_count;
1310
1311 BalTmShaping balShape;
1312 memset(&balShape, 0, sizeof(BalTmShaping));
1313 bal_tm_shaping__init(&balShape);
1314 balIndCfg.tm_queue_ind->data->rate = &balShape;
1315
1316 balIndCfg.tm_queue_ind->data->rate->has_presence_mask = BAL_GRPC_PRES;
1317 balIndCfg.tm_queue_ind->data->rate->presence_mask = tm_que_ind->data.rate.presence_mask;
1318 balIndCfg.tm_queue_ind->data->rate->has_cir = BAL_GRPC_PRES;
1319 balIndCfg.tm_queue_ind->data->rate->cir = tm_que_ind->data.rate.cir;
1320 balIndCfg.tm_queue_ind->data->rate->has_pir = BAL_GRPC_PRES;
1321 balIndCfg.tm_queue_ind->data->rate->pir = tm_que_ind->data.rate.pir;
1322 balIndCfg.tm_queue_ind->data->rate->has_burst = BAL_GRPC_PRES;
1323 balIndCfg.tm_queue_ind->data->rate->burst = tm_que_ind->data.rate.burst;
1324
1325 BalTmBac balBac;
1326 memset(&balBac, 0, sizeof(BalTmBac));
1327 bal_tm_bac__init(&balBac);
1328 balIndCfg.tm_queue_ind->data->bac = &balBac;
1329
1330 balIndCfg.tm_queue_ind->data->bac->has_type = BAL_GRPC_PRES;
1331 balIndCfg.tm_queue_ind->data->bac->type = tm_que_ind->data.bac.type;
1332 switch(tm_que_ind->data.bac.type)
1333 {
1334 case BCMBAL_TM_BAC_TYPE_TAILDROP:
1335 {
1336 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_TAILDROP;
1337 BalTMBacTaildrop balTaildrop;
1338 memset(&balTaildrop, 0, sizeof(BalTMBacTaildrop));
1339 bal_tmbac_taildrop__init(&balTaildrop);
1340 balIndCfg.tm_queue_ind->data->bac->taildrop = &balTaildrop;
1341
1342 balIndCfg.tm_queue_ind->data->bac->taildrop->has_max_size = BAL_GRPC_PRES;
1343 balIndCfg.tm_queue_ind->data->bac->taildrop->max_size =
1344 tm_que_ind->data.bac.u.taildrop.max_size;
1345 }
1346 break;
1347 case BCMBAL_TM_BAC_TYPE_WTAILDROP:
1348 {
1349 /* No bal/grpc structure was defined */
1350 }
1351 break;
1352 case BCMBAL_TM_BAC_TYPE_RED:
1353 {
1354 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_RED;
1355 BalTMBacRed balBacRed;
1356 memset(&balBacRed, 0, sizeof(BalTMBacRed));
1357 bal_tmbac_red__init(&balBacRed);
1358 balIndCfg.tm_queue_ind->data->bac->red = &balBacRed;
1359
1360 BalTmred balRed;
1361 memset(&balRed, 0, sizeof(BalTmred));
1362 bal_tmred__init(&balRed);
1363 balIndCfg.tm_queue_ind->data->bac->red->red = &balRed;
1364 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->red->red, &tm_que_ind->data.bac.u.red.red);
1365 }
1366 break;
1367 case BCMBAL_TM_BAC_TYPE_WRED:
1368 {
1369 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_WRED;
1370 BalTMBacWred balBacWred;
1371 memset(&balBacWred, 0, sizeof(BalTMBacWred));
1372 bal_tmbac_wred__init(&balBacWred);
1373 balIndCfg.tm_queue_ind->data->bac->wred = &balBacWred;
1374
1375 BalTmred balGreen;
1376 memset(&balGreen, 0, sizeof(BalTmred));
1377 bal_tmred__init(&balGreen);
1378 balIndCfg.tm_queue_ind->data->bac->wred->green = &balGreen;
1379 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->green, &tm_que_ind->data.bac.u.wred.green);
1380
1381 BalTmred balYellow;
1382 memset(&balYellow, 0, sizeof(BalTmred));
1383 bal_tmred__init(&balYellow);
1384 balIndCfg.tm_queue_ind->data->bac->wred->yellow = &balYellow;
1385 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->yellow, &tm_que_ind->data.bac.u.wred.yellow);
1386
1387 BalTmred balRed;
1388 memset(&balRed, 0, sizeof(BalTmred));
1389 bal_tmred__init(&balRed);
1390 balIndCfg.tm_queue_ind->data->bac->wred->red = &balRed;
1391 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->red, &tm_que_ind->data.bac.u.wred.red);
1392 }
1393 break;
1394 default:
1395 {
1396 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U__NOT_SET;
1397 }
1398 break;
1399
1400 }
1401
1402 BalErr *output;
1403 result = bal_ind__bal_tm_queue_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
1404 }
1405
1406 return result;
1407}
1408
1409/********************************************************************\
1410 * Function : bal_tm_sched_indication_cb *
1411 * Description : This function will handle the indications for *
1412 * TM Sched indication *
1413 * *
1414 ********************************************************************/
1415bcmos_errno bal_tm_sched_indication_cb(bcmbal_obj *obj)
1416{
1417 bcmos_errno result = BCM_ERR_OK;
1418
1419 if(BCMBAL_OBJ_ID_TM_SCHED != obj->obj_type ||
1420 bcmbal_tm_sched_auto_id_ind != obj->subgroup)
1421 {
1422 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1423 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1424 result = BCM_ERR_INTERNAL;
1425 }
1426 else
1427 {
1428 BalIndications balIndCfg;
1429 memset(&balIndCfg, 0, sizeof(BalIndications));
1430 bal_indications__init(&balIndCfg);
1431 balIndCfg.u_case = BAL_INDICATIONS__U_TM_SCHED__IND;
1432 balIndCfg.has_objtype = BAL_GRPC_PRES;
1433 balIndCfg.objtype = obj->obj_type;
1434 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1435 balIndCfg.sub_group = obj->subgroup;
1436 balIndCfg.device_id = voltha_device_id;
1437
1438 bcmbal_tm_sched_ind *tm_sched_ind = (bcmbal_tm_sched_ind *)obj;
1439
1440 BalTmSchedInd tmSchedInd;
1441 memset(&tmSchedInd, 0, sizeof(BalTmSchedInd));
1442 bal_tm_sched_ind__init(&tmSchedInd);
1443 balIndCfg.tm_sched_ind = &tmSchedInd;
1444
1445 BalTmSchedKey tmSchedkey;
1446 memset(&tmSchedkey, 0, sizeof(BalTmSchedKey));
1447 bal_tm_sched_key__init(&tmSchedkey);
1448 balIndCfg.tm_sched_ind->key = &tmSchedkey;
1449
1450 balIndCfg.tm_sched_ind->key->has_dir = BAL_GRPC_PRES;
1451 balIndCfg.tm_sched_ind->key->dir = tm_sched_ind->key.dir;
1452 balIndCfg.tm_sched_ind->key->has_id = BAL_GRPC_PRES;
1453 balIndCfg.tm_sched_ind->key->id = tm_sched_ind->key.id;
1454
1455 BalTmSchedIndData tmSIndData;
1456 memset(&tmSIndData, 0, sizeof(BalTmSchedIndData));
1457 bal_tm_sched_ind_data__init(&tmSIndData);
1458 balIndCfg.tm_sched_ind->data = &tmSIndData;
1459 /* TODO: data should be populate */
1460
1461 BalErr *output;
1462 result = bal_ind__bal_tm_sched_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
1463 }
1464
1465 return result;
1466}
1467
1468/********************************************************************\
1469 * Function : bal_packet_data_indication_cb *
1470 * Description : This function will handle the indications for *
1471 * Packet Data indication *
1472 * *
1473 ********************************************************************/
1474bcmos_errno bal_packet_data_indication_cb(bcmbal_obj *obj)
1475{
1476 bcmos_errno result = BCM_ERR_OK;
1477
1478 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
1479 bcmbal_packet_auto_id_bearer_channel_rx != obj->subgroup)
1480 {
1481 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1482 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1483 result = BCM_ERR_INTERNAL;
1484 }
1485 else
1486 {
1487 /*bcmos_mutex_lock(&bal_ind_lock);-- Need to define bcm independent mutex*/
1488
1489 BalIndications balIndCfg;
1490 balIndCfg.u_case = BAL_INDICATIONS__U_PKT_DATA;
1491 balIndCfg.has_objtype = BAL_GRPC_PRES;
1492 balIndCfg.objtype = obj->obj_type;
1493 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1494 balIndCfg.sub_group = obj->subgroup;
1495 balIndCfg.device_id = voltha_device_id;
1496
1497 BalPacketBearerChannelRx rxChannel;
1498 memset(&rxChannel, 0, sizeof(BalPacketBearerChannelRx));
1499 bal_packet_bearer_channel_rx__init(&rxChannel);
1500 balIndCfg.pktdata = &rxChannel;
1501
1502 BalPacketKey packetkey;
1503 memset(&packetkey, 0, sizeof(BalPacketKey));
1504 bal_packet_key__init(&packetkey);
1505 balIndCfg.pktdata->key = &packetkey;
1506
1507 bcmbal_packet_bearer_channel_rx *rx_channel =
1508 (bcmbal_packet_bearer_channel_rx *)obj;
1509
1510 balIndCfg.pktdata->key->has_reserved = BAL_GRPC_PRES;
1511 balIndCfg.pktdata->key->reserved = rx_channel->key.reserved;
1512
1513 BalDest PktSndDest;
1514 memset(&PktSndDest, 0, sizeof(BalDest));
1515 bal_dest__init(&PktSndDest);
1516 balIndCfg.pktdata->key->packet_send_dest = &PktSndDest;
1517
1518 balIndCfg.pktdata->key->packet_send_dest->has_type = BAL_GRPC_PRES;
1519 balIndCfg.pktdata->key->packet_send_dest->type =
1520 rx_channel->key.packet_send_dest.type;
1521 switch( rx_channel->key.packet_send_dest.type)
1522 {
1523 case BCMBAL_DEST_TYPE_NNI:
1524 {
1525 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_NNI;
1526 BalDestNni balNni;
1527 memset(&balNni, 0, sizeof(BalDestNni));
1528 bal_dest_nni__init(&balNni);
1529 balIndCfg.pktdata->key->packet_send_dest->nni = &balNni;
1530 balIndCfg.pktdata->key->packet_send_dest->nni->has_intf_id = BAL_GRPC_PRES;
1531 balIndCfg.pktdata->key->packet_send_dest->nni->intf_id =
1532 rx_channel->key.packet_send_dest.u.nni.intf_id;
1533 }
1534 break;
1535 case BCMBAL_DEST_TYPE_SUB_TERM:
1536 {
1537 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SUB_TERM;
1538 BalDestSubTerm balSubTerm;
1539 memset(&balSubTerm, 0, sizeof(BalDestSubTerm));
1540 bal_dest_sub_term__init(&balSubTerm);
1541 balIndCfg.pktdata->key->packet_send_dest->sub_term = &balSubTerm;
1542 balIndCfg.pktdata->key->packet_send_dest->sub_term->has_sub_term_id =
1543 BAL_GRPC_PRES;
1544 balIndCfg.pktdata->key->packet_send_dest->sub_term->sub_term_id =
1545 rx_channel->key.packet_send_dest.u.sub_term.sub_term_id;
1546 balIndCfg.pktdata->key->packet_send_dest->sub_term->has_sub_term_uni =
1547 BAL_GRPC_PRES;
1548 balIndCfg.pktdata->key->packet_send_dest->sub_term->sub_term_uni =
1549 rx_channel->key.packet_send_dest.u.sub_term.sub_term_uni;
1550 balIndCfg.pktdata->key->packet_send_dest->sub_term->has_intf_id =
1551 BAL_GRPC_PRES;
1552 balIndCfg.pktdata->key->packet_send_dest->sub_term->intf_id =
1553 rx_channel->key.packet_send_dest.u.sub_term.intf_id;
1554 }
1555 break;
1556 case BCMBAL_DEST_TYPE_SVC_PORT:
1557 {
1558 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SVC_PORT;
1559 BalDestSvcPort balSvcPort;
1560 memset(&balSvcPort, 0, sizeof(BalDestSvcPort));
1561 bal_dest_svc_port__init(&balSvcPort);
1562 balIndCfg.pktdata->key->packet_send_dest->svc_port = &balSvcPort;
1563 balIndCfg.pktdata->key->packet_send_dest->svc_port->has_svc_port_id =
1564 BAL_GRPC_PRES;
1565 balIndCfg.pktdata->key->packet_send_dest->svc_port->svc_port_id =
1566 rx_channel->key.packet_send_dest.u.svc_port.svc_port_id;
1567 balIndCfg.pktdata->key->packet_send_dest->svc_port->has_intf_id =
1568 BAL_GRPC_PRES;
1569 balIndCfg.pktdata->key->packet_send_dest->svc_port->has_intf_id =
1570 rx_channel->key.packet_send_dest.u.svc_port.intf_id;
1571 }
1572 break;
1573 default:
1574 {
1575 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
1576 }
1577 break;
1578 }
1579
1580 BalPacketBearerChannelRxData pkdData;
1581 memset(&pkdData, 0, sizeof(BalPacketBearerChannelRxData));
1582 bal_packet_bearer_channel_rx_data__init(&pkdData);
1583 balIndCfg.pktdata->data = &pkdData;
1584
1585 balIndCfg.pktdata->data->has_flow_id = BAL_GRPC_PRES;
1586 balIndCfg.pktdata->data->flow_id = rx_channel->data.flow_id;
1587 balIndCfg.pktdata->data->has_flow_type = BAL_GRPC_PRES;
1588 balIndCfg.pktdata->data->flow_type = rx_channel->data.flow_type;
1589 balIndCfg.pktdata->data->has_intf_id = BAL_GRPC_PRES;
1590 balIndCfg.pktdata->data->intf_id = rx_channel->data.intf_id;
1591 balIndCfg.pktdata->data->has_intf_type = BAL_GRPC_PRES;
1592 balIndCfg.pktdata->data->intf_type = rx_channel->data.intf_type;
1593 balIndCfg.pktdata->data->has_svc_port = BAL_GRPC_PRES;
1594 balIndCfg.pktdata->data->svc_port = rx_channel->data.svc_port;
1595 balIndCfg.pktdata->data->has_flow_cookie = BAL_GRPC_PRES;
1596 balIndCfg.pktdata->data->flow_cookie = rx_channel->data.flow_cookie;
1597 balIndCfg.pktdata->data->has_pkt = BAL_GRPC_PRES;
1598 balIndCfg.pktdata->data->pkt.len = rx_channel->data.pkt.len;
1599 memcpy(balIndCfg.pktdata->data->pkt.data, rx_channel->data.pkt.val, balIndCfg.pktdata->data->pkt.len);
1600
1601 /*bcmos_mutex_unlock(&bal_ind_lock);-- Need to define bcm independent mutex*/
1602
1603 BalErr *output;
1604 result = bal_ind__bal_pkt_bearer_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1605 }
1606
1607 return result;
1608}
1609
1610/********************************************************************\
1611 * Function : bal_omci_data_indication_cb *
1612 * Description : This function will handle the indications for *
1613 * OMCI Data Response *
1614 * *
1615 ********************************************************************/
1616bcmos_errno bal_omci_data_indication_cb(bcmbal_obj *obj)
1617{
1618 bcmos_errno result = BCM_ERR_OK;
1619
1620 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
1621 bcmbal_packet_auto_id_itu_omci_channel_rx != obj->subgroup)
1622 {
1623 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1624 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1625 result = BCM_ERR_INTERNAL;
1626 }
1627 else
1628 {
1629 ASFVOLT_LOG(ASFVOLT_DEBUG, "Received OMCI response via BAL APIs\n");
1630 BalIndications balIndCfg;
1631 memset(&balIndCfg, 0, sizeof(BalIndications));
1632 bal_indications__init(&balIndCfg);
1633 balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OMCI_RESP;
1634 balIndCfg.has_objtype = BAL_GRPC_PRES;
1635 balIndCfg.objtype = obj->obj_type;
1636 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1637 balIndCfg.sub_group = obj->subgroup;
1638 balIndCfg.device_id = voltha_device_id;
1639
1640 BalPacketItuOmciChannelRx omciChannel;
1641 memset(&omciChannel, 0, sizeof(BalPacketItuOmciChannelRx));
1642 bal_packet_itu_omci_channel_rx__init(&omciChannel);
1643 balIndCfg.balomciresp = &omciChannel;
1644
1645 BalPacketKey packetkey;
1646 memset(&packetkey, 0, sizeof(BalPacketKey));
1647 bal_packet_key__init(&packetkey);
1648 balIndCfg.balomciresp->key = &packetkey;
1649
1650 BalPacketItuOmciChannelRxData omciData;
1651 memset(&omciData, 0, sizeof(BalPacketItuOmciChannelRxData));
1652 bal_packet_itu_omci_channel_rx_data__init(&omciData);
1653 balIndCfg.balomciresp->data = &omciData;
1654
1655 bcmbal_packet_itu_omci_channel_rx *omci_channel =
1656 (bcmbal_packet_itu_omci_channel_rx *)obj;
1657
1658 balIndCfg.balomciresp->data->has_pkt = BAL_GRPC_PRES;
1659 balIndCfg.balomciresp->data->pkt.len = omci_channel->data.pkt.len;
1660 balIndCfg.balomciresp->data->pkt.data = (uint8_t *)malloc((omci_channel->data.pkt.len)*sizeof(uint8_t));
1661 memcpy(balIndCfg.balomciresp->data->pkt.data, omci_channel->data.pkt.val,
1662 balIndCfg.balomciresp->data->pkt.len);
1663
1664 balIndCfg.balomciresp->key->has_reserved = BAL_GRPC_PRES;
1665 balIndCfg.balomciresp->key->reserved = omci_channel->key.reserved;
1666
1667 BalDest PktSndDest;
1668 memset(&PktSndDest, 0, sizeof(BalDest));
1669 bal_dest__init(&PktSndDest);
1670 balIndCfg.balomciresp->key->packet_send_dest = &PktSndDest;
1671
1672 balIndCfg.balomciresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
1673 balIndCfg.balomciresp->key->packet_send_dest->type =
1674 omci_channel->key.packet_send_dest.type;
1675 switch( omci_channel->key.packet_send_dest.type)
1676 {
1677 case BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL:
1678 {
1679 balIndCfg.balomciresp->key->packet_send_dest->u_case = BAL_DEST__U_ITU_OMCI_CHANNEL;
1680 BalItuOmciChannel balOmci;
1681 memset(&balOmci, 0, sizeof(BalItuOmciChannel));
1682 bal_itu_omci_channel__init(&balOmci);
1683 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel = &balOmci;
1684 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->has_sub_term_id =
1685 BAL_GRPC_PRES;
1686 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id =
1687 omci_channel->key.packet_send_dest.u.itu_omci_channel.sub_term_id;
1688 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->has_intf_id =
1689 BAL_GRPC_PRES;
1690 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->intf_id =
1691 omci_channel->key.packet_send_dest.u.itu_omci_channel.intf_id;
1692 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d\n",
1693 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
1694 }
1695 break;
1696 default:
1697 {
1698 balIndCfg.balomciresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
1699 }
1700 break;
1701 }
1702
1703 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response with %zd bytes is \n",balIndCfg.balomciresp->data->pkt.len);
1704 uint16_t idx;
1705 for(idx=0; idx<balIndCfg.balomciresp->data->pkt.len; idx++)
1706 {
1707 printf("%02x", balIndCfg.balomciresp->data->pkt.data[idx]);
1708 }
1709 printf("\n");
1710 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d\n",
1711 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
1712 BalErr *output;
1713 result = bal_ind__bal_pkt_omci_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1714 }
1715
1716 return result;
1717}
1718
1719/********************************************************************\
1720 * Function : bal_oam_data_indication_cb *
1721 * Description : This function will handle the indications for *
1722 * OAM Data Response *
1723 * *
1724 ********************************************************************/
1725bcmos_errno bal_oam_data_indication_cb(bcmbal_obj *obj)
1726{
1727 bcmos_errno result = BCM_ERR_OK;
1728
1729 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
1730 bcmbal_packet_auto_id_ieee_oam_channel_rx != obj->subgroup)
1731 {
1732 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1733 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1734 result = BCM_ERR_INTERNAL;
1735 }
1736 else
1737 {
1738 BalIndications balIndCfg;
1739 memset(&balIndCfg, 0, sizeof(BalIndications));
1740 bal_indications__init(&balIndCfg);
1741 balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OAM_RESP;
1742 balIndCfg.has_objtype = BAL_GRPC_PRES;
1743 balIndCfg.objtype = obj->obj_type;
1744 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1745 balIndCfg.sub_group = obj->subgroup;
1746 balIndCfg.device_id = voltha_device_id;
1747
1748 BalPacketIeeeOamChannelRx oamChannel;
1749 memset(&oamChannel, 0, sizeof(BalPacketIeeeOamChannelRx));
1750 bal_packet_ieee_oam_channel_rx__init(&oamChannel);
1751 balIndCfg.baloamresp = &oamChannel;
1752
1753 BalPacketKey packetkey;
1754 memset(&packetkey, 0, sizeof(BalPacketKey));
1755 bal_packet_key__init(&packetkey);
1756 balIndCfg.baloamresp->key = &packetkey;
1757
1758 bcmbal_packet_ieee_oam_channel_rx *oam_channel =
1759 (bcmbal_packet_ieee_oam_channel_rx *)obj;
1760
1761 balIndCfg.baloamresp->key->has_reserved = BAL_GRPC_PRES;
1762 balIndCfg.baloamresp->key->reserved = oam_channel->key.reserved;
1763
1764 BalDest PktSndDest;
1765 memset(&PktSndDest, 0, sizeof(BalDest));
1766 bal_dest__init(&PktSndDest);
1767 balIndCfg.baloamresp->key->packet_send_dest = &PktSndDest;
1768
1769 balIndCfg.baloamresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
1770 balIndCfg.baloamresp->key->packet_send_dest->type =
1771 oam_channel->key.packet_send_dest.type;
1772 switch( oam_channel->key.packet_send_dest.type)
1773 {
1774 case BCMBAL_DEST_TYPE_IEEE_OAM_CHANNEL:
1775 {
1776 balIndCfg.baloamresp->key->packet_send_dest->u_case = BAL_DEST__U_IEEE_OAM_CHANNEL;
1777 BalIeeeOamChannel balOam;
1778 memset(&balOam, 0, sizeof(BalIeeeOamChannel));
1779 bal_ieee_oam_channel__init(&balOam);
1780 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel = &balOam;
1781 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->has_intf_id =
1782 BAL_GRPC_PRES;
1783 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->intf_id =
1784 oam_channel->key.packet_send_dest.u.ieee_oam_channel.intf_id;
1785 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->has_mac_address = BAL_GRPC_PRES;
1786 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len =
1787 (BCMOS_ETH_ALEN)*sizeof(oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8);
1788 memcpy(balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.data,
1789 oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8,
1790 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len);
1791
1792 }
1793 break;
1794 default:
1795 {
1796 balIndCfg.baloamresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
1797 }
1798 break;
1799 }
1800
1801 BalPacketIeeeOamChannelRxData oamData;
1802 memset(&oamData, 0, sizeof(BalPacketIeeeOamChannelRxData));
1803 bal_packet_ieee_oam_channel_rx_data__init(&oamData);
1804 balIndCfg.baloamresp->data = &oamData;
1805
1806 balIndCfg.baloamresp->data->pkt.len = oam_channel->data.pkt.len;
1807 memcpy(balIndCfg.baloamresp->data->pkt.data, oam_channel->data.pkt.val,
1808 balIndCfg.baloamresp->data->pkt.len);
1809
1810 BalErr *output;
1811 result = bal_ind__bal_pkt_ieee_oam_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1812
1813 }
1814
1815 return result;
1816}