blob: df75a581266ae1657b7385e8ee5decaea1578223 [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/********************************************************************\
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053021 * Function : bal_acc_term_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053022 * 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
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053030 if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053031 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 {
Rajeswara Raob2e441c2017-09-20 16:40:21 +053039 ASFVOLT_LOG(ASFVOLT_DEBUG, "Processing BAL API \'%s\' IND callback (status is %s)\n",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053040 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;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053052
53 BalAccessTerminalInd acessTermInd;
54 memset(&acessTermInd, 0, sizeof(BalAccessTerminalInd));
55 bal_access_terminal_ind__init(&acessTermInd);
56 balIndCfg.access_term_ind = &acessTermInd;
57
58 BalObj hdr;
59 memset(&hdr, 0, sizeof(BalObj));
60 bal_obj__init(&hdr);
61 balIndCfg.access_term_ind->hdr = &hdr;
62
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053063 BalAccessTerminalKey accessTermkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053064 memset(&accessTermkey, 0, sizeof(BalAccessTerminalKey));
65 bal_access_terminal_key__init(&accessTermkey);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053066 balIndCfg.access_term_ind->key = &accessTermkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053067
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053068 balIndCfg.access_term_ind->key->has_access_term_id = BAL_GRPC_PRES;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053069 balIndCfg.access_term_ind->key->access_term_id = acc_term_ind->key.access_term_id;
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053070
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053071 BalAccessTerminalIndData accessTermIndData;
72 memset(&accessTermIndData, 0, sizeof(BalAccessTerminalIndData));
73 bal_access_terminal_ind_data__init(&accessTermIndData);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053074 balIndCfg.access_term_ind->data = &accessTermIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053075
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053076 balIndCfg.access_term_ind->data->has_admin_state = BAL_GRPC_PRES;
77 balIndCfg.access_term_ind->data->admin_state = acc_term_ind->data.admin_state;
78 balIndCfg.access_term_ind->data->has_oper_status = BAL_GRPC_PRES;
79 balIndCfg.access_term_ind->data->oper_status = acc_term_ind->data.oper_status;
80 balIndCfg.access_term_ind->data->has_iwf_mode = BAL_GRPC_PRES;
81 balIndCfg.access_term_ind->data->iwf_mode = acc_term_ind->data.iwf_mode;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053082
83 BalTopology balTop;
84 memset(&balTop, 0, sizeof(BalTopology));
85 bal_topology__init(&balTop);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053086 balIndCfg.access_term_ind->data->topology = &balTop;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053087
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053088 balIndCfg.access_term_ind->data->topology->has_num_of_nni_ports = BAL_GRPC_PRES;
89 balIndCfg.access_term_ind->data->topology->num_of_nni_ports =
90 acc_term_ind->data.topology.num_of_nni_ports;
91 balIndCfg.access_term_ind->data->topology->has_num_of_pon_ports = BAL_GRPC_PRES;
92 balIndCfg.access_term_ind->data->topology->num_of_pon_ports =
93 acc_term_ind->data.topology.num_of_pon_ports;
94 balIndCfg.access_term_ind->data->topology->has_num_of_mac_devs = BAL_GRPC_PRES;
95 balIndCfg.access_term_ind->data->topology->num_of_mac_devs =
96 acc_term_ind->data.topology.num_of_mac_devs;
97 balIndCfg.access_term_ind->data->topology->has_num_of_pons_per_mac_dev = BAL_GRPC_PRES;
98 balIndCfg.access_term_ind->data->topology->num_of_pons_per_mac_dev =
99 acc_term_ind->data.topology.num_of_pons_per_mac_dev;
100 balIndCfg.access_term_ind->data->topology->has_pon_family = BAL_GRPC_PRES;
101 balIndCfg.access_term_ind->data->topology->pon_family =
102 acc_term_ind->data.topology.pon_family;
103 balIndCfg.access_term_ind->data->topology->has_pon_sub_family = BAL_GRPC_PRES;
104 balIndCfg.access_term_ind->data->topology->pon_sub_family =
105 acc_term_ind->data.topology.pon_sub_family;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530106
107 BalSwVersion balsv;
108 memset(&balsv, 0, sizeof(BalSwVersion));
109 bal_sw_version__init(&balsv);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530110 balIndCfg.access_term_ind->data->sw_version = &balsv;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530111
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530112 balIndCfg.access_term_ind->data->sw_version->has_version_type = BAL_GRPC_PRES;
113 balIndCfg.access_term_ind->data->sw_version->version_type =
114 acc_term_ind->data.sw_version.version_type;
115 balIndCfg.access_term_ind->data->sw_version->has_major_rev = BAL_GRPC_PRES;
116 balIndCfg.access_term_ind->data->sw_version->major_rev =
117 acc_term_ind->data.sw_version.major_rev;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530118 balIndCfg.access_term_ind->data->sw_version->has_minor_rev = BAL_GRPC_PRES;
119 balIndCfg.access_term_ind->data->sw_version->minor_rev =
120 acc_term_ind->data.sw_version.minor_rev;
121 balIndCfg.access_term_ind->data->sw_version->has_patch_rev = BAL_GRPC_PRES;
122 balIndCfg.access_term_ind->data->sw_version->patch_rev =
123 acc_term_ind->data.sw_version.patch_rev;
124 balIndCfg.access_term_ind->data->sw_version->has_om_version = BAL_GRPC_PRES;
125 balIndCfg.access_term_ind->data->sw_version->om_version =
126 acc_term_ind->data.sw_version.om_version;
127 balIndCfg.access_term_ind->data->sw_version->has_dev_point = BAL_GRPC_PRES;
128 balIndCfg.access_term_ind->data->sw_version->dev_point =
129 acc_term_ind->data.sw_version.dev_point;
130
131 bal_register_indication_cbs();
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530132
133 BalErr *output;
134 result = bal_ind__bal_acc_term_ind(client, NULL, &balIndCfg, &output, NULL, 0);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530135 is_reboot = BAL_REBOOT_STATUS__BAL_OLT_UP_AFTER_ACTIVATION;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530136 }
137
138 return result;
139}
140
141/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530142 * Function : bal_acc_term_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530143 * 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
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530151 if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530152 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
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530170 bcmbal_access_terminal_oper_status_change *acc_term_osc =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530171 (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
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530178 BalObj hdr;
179 memset(&hdr, 0, sizeof(BalObj));
180 bal_obj__init(&hdr);
181 balIndCfg.access_term_ind_op_state->hdr = &hdr;
182
183 BalAccessTerminalKey accessTermkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530184 memset(&accessTermkey, 0, sizeof(BalAccessTerminalKey));
185 bal_access_terminal_key__init(&accessTermkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530186 balIndCfg.access_term_ind_op_state->key = &accessTermkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530187
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530188 balIndCfg.access_term_ind_op_state->key->has_access_term_id = BAL_GRPC_PRES;
189 balIndCfg.access_term_ind_op_state->key->access_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530190 acc_term_osc->key.access_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530191
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530192 BalAccessTerminalOperStatusChangeData accessTermOscData;
193 memset(&accessTermOscData, 0, sizeof(BalAccessTerminalOperStatusChangeData));
194 bal_access_terminal_oper_status_change_data__init(&accessTermOscData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530195 balIndCfg.access_term_ind_op_state->data = &accessTermOscData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530196
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530197 balIndCfg.access_term_ind_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
198 balIndCfg.access_term_ind_op_state->data->new_oper_status =
199 acc_term_osc->data.new_oper_status;
200 balIndCfg.access_term_ind_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
201 balIndCfg.access_term_ind_op_state->data->old_oper_status =
202 acc_term_osc->data.old_oper_status;
203 balIndCfg.access_term_ind_op_state->data->has_admin_state = BAL_GRPC_PRES;
204 balIndCfg.access_term_ind_op_state->data->admin_state =
205 acc_term_osc->data.admin_state;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530206
207 BalErr *output;
208 result = bal_ind__bal_acc_term_oper_sts_cng_ind(client, NULL, &balIndCfg, &output, NULL, 0);
209 }
210
211 return result;
212}
213
214/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530215 * Function : bal_flow_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530216 * Description : This function will handle the indications for *
217 * Flow Operational State Change *
218 * *
219 ********************************************************************/
220bcmos_errno bal_flow_osc_indication_cb(bcmbal_obj *obj)
221{
222 bcmos_errno result = BCM_ERR_OK;
223
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530224 if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530225 bcmbal_flow_auto_id_oper_status_change != obj->subgroup)
226 {
227 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
228 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
229 result = BCM_ERR_INTERNAL;
230 }
231 else
232 {
233 BalIndications balIndCfg;
234 memset(&balIndCfg, 0, sizeof(BalIndications));
235 bal_indications__init(&balIndCfg);
236 balIndCfg.u_case = BAL_INDICATIONS__U_FLOW_OP_STATE;
237 balIndCfg.has_objtype = BAL_GRPC_PRES;
238 balIndCfg.objtype = obj->obj_type;
239 balIndCfg.has_sub_group = BAL_GRPC_PRES;
240 balIndCfg.sub_group = obj->subgroup;
241 balIndCfg.device_id = voltha_device_id;
242
243 bcmbal_flow_oper_status_change *flow_osc = (bcmbal_flow_oper_status_change *)obj;
244
245 BalFlowOperStatusChange flowOscInd;
246 memset(&flowOscInd, 0, sizeof(BalFlowOperStatusChange));
247 bal_flow_oper_status_change__init(&flowOscInd);
248 balIndCfg.flow_op_state = &flowOscInd;
249
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530250 BalObj hdr;
251 memset(&hdr, 0, sizeof(BalObj));
252 bal_obj__init(&hdr);
253 balIndCfg.flow_op_state->hdr = &hdr;
254
255 BalFlowKey flowkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530256 memset(&flowkey, 0, sizeof(BalFlowKey));
257 bal_flow_key__init(&flowkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530258 balIndCfg.flow_op_state->key = &flowkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530259
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530260 balIndCfg.flow_op_state->key->has_flow_id = BAL_GRPC_PRES;
261 balIndCfg.flow_op_state->key->flow_id = flow_osc->key.flow_id;
262 balIndCfg.flow_op_state->key->has_flow_type = BAL_GRPC_PRES;
263 balIndCfg.flow_op_state->key->flow_type = flow_osc->key.flow_type;
264
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530265 BalFlowOperStatusChangeData flowOscIndData;
266 memset(&flowOscIndData, 0, sizeof(BalFlowOperStatusChangeData));
267 bal_flow_oper_status_change_data__init(&flowOscIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530268 balIndCfg.flow_op_state->data = &flowOscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530269
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530270 balIndCfg.flow_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
271 balIndCfg.flow_op_state->data->new_oper_status = flow_osc->data.new_oper_status;
272 balIndCfg.flow_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
273 balIndCfg.flow_op_state->data->old_oper_status = flow_osc->data.old_oper_status;
274 balIndCfg.flow_op_state->data->has_admin_state = BAL_GRPC_PRES;
275 balIndCfg.flow_op_state->data->admin_state = flow_osc->data.admin_state;
276 balIndCfg.flow_op_state->data->has_svc_port_id = BAL_GRPC_PRES;
277 balIndCfg.flow_op_state->data->svc_port_id = flow_osc->data.svc_port_id;
278 balIndCfg.flow_op_state->data->has_dba_tm_sched_id = BAL_GRPC_PRES;
279 balIndCfg.flow_op_state->data->dba_tm_sched_id = flow_osc->data.dba_tm_sched_id;
280 balIndCfg.flow_op_state->data->has_cookie = BAL_GRPC_PRES;
281 balIndCfg.flow_op_state->data->cookie = flow_osc->data.cookie;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530282
283 BalErr *output;
284 result = bal_ind__bal_flow_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
285 }
286
287 return result;
288}
289
290/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530291 * Function : bal_flow_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530292 * Description : This function will handle the indications for *
293 * Flow Indication *
294 * *
295 ********************************************************************/
296bcmos_errno bal_flow_indication_cb(bcmbal_obj *obj)
297{
298 bcmos_errno result = BCM_ERR_OK;
299
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530300 if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530301 bcmbal_flow_auto_id_ind != obj->subgroup)
302 {
303 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
304 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
305 result = BCM_ERR_INTERNAL;
306 }
307 else
308 {
309 BalIndications balIndCfg;
310 memset(&balIndCfg, 0, sizeof(BalIndications));
311 bal_indications__init(&balIndCfg);
312 balIndCfg.u_case = BAL_INDICATIONS__U_FLOW_IND;
313 balIndCfg.has_objtype = BAL_GRPC_PRES;
314 balIndCfg.objtype = obj->obj_type;
315 balIndCfg.has_sub_group = BAL_GRPC_PRES;
316 balIndCfg.sub_group = obj->subgroup;
317 balIndCfg.device_id = voltha_device_id;
318
319 bcmbal_flow_ind *flow_ind = (bcmbal_flow_ind *)obj;
320
321 BalFlowInd flowInd;
322 memset(&flowInd, 0, sizeof(BalFlowInd));
323 bal_flow_ind__init(&flowInd);
324 balIndCfg.flow_ind = &flowInd;
325
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530326 BalObj hdr;
327 memset(&hdr, 0, sizeof(BalObj));
328 bal_obj__init(&hdr);
329 balIndCfg.flow_ind->hdr = &hdr;
330
331 BalFlowKey flowkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530332 memset(&flowkey, 0, sizeof(BalFlowKey));
333 bal_flow_key__init(&flowkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530334 balIndCfg.flow_ind->key = &flowkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530335
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530336 balIndCfg.flow_ind->key->has_flow_id = BAL_GRPC_PRES;
337 balIndCfg.flow_ind->key->flow_id = flow_ind->key.flow_id;
338 balIndCfg.flow_ind->key->has_flow_type = BAL_GRPC_PRES;
339 balIndCfg.flow_ind->key->flow_type = flow_ind->key.flow_type;
340
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530341 BalFlowIndData flowIndData;
342 memset(&flowIndData, 0, sizeof(BalFlowIndData));
343 bal_flow_ind_data__init(&flowIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530344 balIndCfg.flow_ind->data = &flowIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530345
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530346 balIndCfg.flow_ind->data->has_admin_state = BAL_GRPC_PRES;
347 balIndCfg.flow_ind->data->admin_state = flow_ind->data.admin_state;
348 balIndCfg.flow_ind->data->has_oper_status= BAL_GRPC_PRES;
349 balIndCfg.flow_ind->data->oper_status= flow_ind->data.oper_status;
350 balIndCfg.flow_ind->data->has_access_int_id = BAL_GRPC_PRES;
351 balIndCfg.flow_ind->data->access_int_id = flow_ind->data.access_int_id;
352 balIndCfg.flow_ind->data->has_network_int_id = BAL_GRPC_PRES;
353 balIndCfg.flow_ind->data->network_int_id = flow_ind->data.network_int_id;
354 balIndCfg.flow_ind->data->has_sub_term_id = BAL_GRPC_PRES;
355 balIndCfg.flow_ind->data->sub_term_id = flow_ind->data.sub_term_id;
356 balIndCfg.flow_ind->data->has_sub_term_uni_idx = BAL_GRPC_PRES;
357 balIndCfg.flow_ind->data->sub_term_uni_idx = flow_ind->data.sub_term_uni_idx;
358 balIndCfg.flow_ind->data->has_svc_port_id = BAL_GRPC_PRES;
359 balIndCfg.flow_ind->data->svc_port_id = flow_ind->data.svc_port_id;
360 balIndCfg.flow_ind->data->has_resolve_mac = BAL_GRPC_PRES;
361 balIndCfg.flow_ind->data->resolve_mac = flow_ind->data.resolve_mac;
362 balIndCfg.flow_ind->data->has_cookie = BAL_GRPC_PRES;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530363 balIndCfg.flow_ind->data->cookie = flow_ind->data.cookie;
364
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530365 BalClassifier balClassifier;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530366 memset(&balClassifier, 0, sizeof(BalClassifier));
367 bal_classifier__init(&balClassifier);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530368 balIndCfg.flow_ind->data->classifier = &balClassifier;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530369
370 balIndCfg.flow_ind->data->classifier->has_presence_mask = BAL_GRPC_PRES;
371 balIndCfg.flow_ind->data->classifier->presence_mask = flow_ind->data.classifier.presence_mask;
372 balIndCfg.flow_ind->data->classifier->has_o_tpid = BAL_GRPC_PRES;
373 balIndCfg.flow_ind->data->classifier->o_tpid = flow_ind->data.classifier.o_tpid;
374 balIndCfg.flow_ind->data->classifier->has_o_vid = BAL_GRPC_PRES;
375 balIndCfg.flow_ind->data->classifier->o_vid = flow_ind->data.classifier.o_vid;
376 balIndCfg.flow_ind->data->classifier->has_i_tpid = BAL_GRPC_PRES;
377 balIndCfg.flow_ind->data->classifier->i_tpid = flow_ind->data.classifier.i_tpid;
378 balIndCfg.flow_ind->data->classifier->has_i_vid = BAL_GRPC_PRES;
379 balIndCfg.flow_ind->data->classifier->i_vid = flow_ind->data.classifier.i_vid;
380 balIndCfg.flow_ind->data->classifier->has_o_pbits = BAL_GRPC_PRES;
381 balIndCfg.flow_ind->data->classifier->o_pbits = flow_ind->data.classifier.o_pbits;
382 balIndCfg.flow_ind->data->classifier->has_i_pbits = BAL_GRPC_PRES;
383 balIndCfg.flow_ind->data->classifier->i_pbits = flow_ind->data.classifier.i_pbits;
384 balIndCfg.flow_ind->data->classifier->has_ether_type = BAL_GRPC_PRES;
385 balIndCfg.flow_ind->data->classifier->ether_type = flow_ind->data.classifier.ether_type;
386 balIndCfg.flow_ind->data->classifier->has_dst_mac = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530387 balIndCfg.flow_ind->data->classifier->dst_mac.len =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530388 (BCMOS_ETH_ALEN)*sizeof(flow_ind->data.classifier.dst_mac.u8);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530389 balIndCfg.flow_ind->data->classifier->dst_mac.data =
390 (uint8_t *)malloc((balIndCfg.flow_ind->data->classifier->dst_mac.len)*sizeof(uint8_t));
391 memcpy(balIndCfg.flow_ind->data->classifier->dst_mac.data,
392 flow_ind->data.classifier.dst_mac.u8,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530393 balIndCfg.flow_ind->data->classifier->dst_mac.len);
394 balIndCfg.flow_ind->data->classifier->has_src_mac = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530395 balIndCfg.flow_ind->data->classifier->src_mac.len =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530396 (BCMOS_ETH_ALEN)*sizeof(flow_ind->data.classifier.src_mac.u8);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530397 balIndCfg.flow_ind->data->classifier->src_mac.data =
398 (uint8_t *)malloc((balIndCfg.flow_ind->data->classifier->src_mac.len)*sizeof(uint8_t));
399 memcpy(balIndCfg.flow_ind->data->classifier->src_mac.data,
400 flow_ind->data.classifier.src_mac.u8,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530401 balIndCfg.flow_ind->data->classifier->src_mac.len);
402 balIndCfg.flow_ind->data->classifier->has_ip_proto = BAL_GRPC_PRES;
403 balIndCfg.flow_ind->data->classifier->ip_proto = flow_ind->data.classifier.ip_proto;
404 balIndCfg.flow_ind->data->classifier->has_dst_ip = BAL_GRPC_PRES;
405 balIndCfg.flow_ind->data->classifier->dst_ip = flow_ind->data.classifier.dst_ip.u32;
406 balIndCfg.flow_ind->data->classifier->has_src_ip = BAL_GRPC_PRES;
407 balIndCfg.flow_ind->data->classifier->src_ip = flow_ind->data.classifier.src_ip.u32;
408 balIndCfg.flow_ind->data->classifier->has_src_port = BAL_GRPC_PRES;
409 balIndCfg.flow_ind->data->classifier->src_port = flow_ind->data.classifier.src_port;
410 balIndCfg.flow_ind->data->classifier->has_dst_port = BAL_GRPC_PRES;
411 balIndCfg.flow_ind->data->classifier->dst_port = flow_ind->data.classifier.dst_port;
412 balIndCfg.flow_ind->data->classifier->has_pkt_tag_type = BAL_GRPC_PRES;
413 balIndCfg.flow_ind->data->classifier->pkt_tag_type = flow_ind->data.classifier.pkt_tag_type;
414
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530415 BalAction balAction;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530416 memset(&balAction, 0, sizeof(BalAction));
417 bal_action__init(&balAction);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530418 balIndCfg.flow_ind->data->action = &balAction;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530419
420 balIndCfg.flow_ind->data->action->has_presence_mask = BAL_GRPC_PRES;
421 balIndCfg.flow_ind->data->action->presence_mask = flow_ind->data.action.presence_mask;
422 balIndCfg.flow_ind->data->action->has_cmds_bitmask = BAL_GRPC_PRES;
423 balIndCfg.flow_ind->data->action->cmds_bitmask = flow_ind->data.action.cmds_bitmask;
424 balIndCfg.flow_ind->data->action->has_o_vid = BAL_GRPC_PRES;
425 balIndCfg.flow_ind->data->action->o_vid = flow_ind->data.action.o_vid;
426 balIndCfg.flow_ind->data->action->has_o_pbits = BAL_GRPC_PRES;
427 balIndCfg.flow_ind->data->action->o_pbits = flow_ind->data.action.o_pbits;
428 balIndCfg.flow_ind->data->action->has_o_tpid = BAL_GRPC_PRES;
429 balIndCfg.flow_ind->data->action->o_tpid = flow_ind->data.action.o_tpid;
430 balIndCfg.flow_ind->data->action->has_i_vid = BAL_GRPC_PRES;
431 balIndCfg.flow_ind->data->action->i_vid = flow_ind->data.action.i_vid;
432 balIndCfg.flow_ind->data->action->has_i_pbits = BAL_GRPC_PRES;
433 balIndCfg.flow_ind->data->action->i_pbits = flow_ind->data.action.i_pbits;
434 balIndCfg.flow_ind->data->action->has_i_tpid = BAL_GRPC_PRES;
435 balIndCfg.flow_ind->data->action->i_tpid = flow_ind->data.action.i_tpid;
436 BalErr *output;
437 result = bal_ind__bal_flow_ind(client, NULL, &balIndCfg, &output, NULL, 0);
438 }
439
440 return result;
441}
442
443/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530444 * Function : bal_group_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530445 * Description : This function will handle the indications for *
446 * Group Indication *
447 * *
448 ********************************************************************/
449bcmos_errno bal_group_indication_cb(bcmbal_obj *obj)
450{
451 bcmos_errno result = BCM_ERR_OK;
452
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530453 if(BCMBAL_OBJ_ID_GROUP != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530454 bcmbal_group_auto_id_ind != obj->subgroup)
455 {
456 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
457 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
458 result = BCM_ERR_INTERNAL;
459 }
460 else
461 {
462 BalIndications balIndCfg;
463 memset(&balIndCfg, 0, sizeof(BalIndications));
464 bal_indications__init(&balIndCfg);
465 balIndCfg.u_case = BAL_INDICATIONS__U_GROUP_IND;
466 balIndCfg.has_objtype = BAL_GRPC_PRES;
467 balIndCfg.objtype = obj->obj_type;
468 balIndCfg.has_sub_group = BAL_GRPC_PRES;
469 balIndCfg.sub_group = obj->subgroup;
470 balIndCfg.device_id = voltha_device_id;
471
472 bcmbal_group_ind *group_ind = (bcmbal_group_ind *)obj;
473
474 BalGroupInd groupInd;
475 memset(&groupInd, 0, sizeof(BalGroupInd));
476 bal_group_ind__init(&groupInd);
477 balIndCfg.group_ind = &groupInd;
478
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530479 BalObj hdr;
480 memset(&hdr, 0, sizeof(BalObj));
481 bal_obj__init(&hdr);
482 balIndCfg.group_ind->hdr = &hdr;
483
484 BalGroupKey groupkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530485 memset(&groupkey, 0, sizeof(BalGroupKey));
486 bal_group_key__init(&groupkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530487 balIndCfg.group_ind->key = &groupkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530488
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530489 balIndCfg.group_ind->key->has_group_id = BAL_GRPC_PRES;
490 balIndCfg.group_ind->key->group_id = group_ind->key.group_id;
491
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530492 BalGroupIndData groupIndData;
493 memset(&groupIndData, 0, sizeof(BalGroupIndData));
494 bal_group_ind_data__init(&groupIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530495 balIndCfg.group_ind->data = &groupIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530496
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530497 balIndCfg.group_ind->data->has_members_cmd = BAL_GRPC_PRES;
498 balIndCfg.group_ind->data->members_cmd = group_ind->data.members_cmd;
499 balIndCfg.group_ind->data->has_cookie = BAL_GRPC_PRES;
500 balIndCfg.group_ind->data->cookie = group_ind->data.cookie;
501 balIndCfg.group_ind->data->has_owner = BAL_GRPC_PRES;
502 balIndCfg.group_ind->data->owner = group_ind->data.owner;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530503
504 BalGroupMemberInfoList balMembers;
505 memset(&balMembers, 0, sizeof(BalGroupMemberInfoList));
506 bal_group_member_info_list__init(&balMembers);
507 balIndCfg.group_ind->data->members = &balMembers;
508
509 balIndCfg.group_ind->data->members->n_val = group_ind->data.members.len;
510
511 BalGroupMemberInfo *balMemberInfo;
512 balMemberInfo = (BalGroupMemberInfo *)malloc(sizeof(BalGroupMemberInfo));
513 memset(&balMemberInfo, 0, sizeof(BalGroupMemberInfo));
514 bal_group_member_info__init(balMemberInfo);
515 balIndCfg.group_ind->data->members->val = &balMemberInfo;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530516
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530517 balMemberInfo->has_intf_id = BAL_GRPC_PRES;
518 balMemberInfo->intf_id = group_ind->data.members.val->intf_id;
519 balMemberInfo->has_svc_port_id = BAL_GRPC_PRES;
520 balMemberInfo->svc_port_id = group_ind->data.members.val->svc_port_id;
521
522 BalAction balAction;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530523 memset(&balAction, 0, sizeof(BalAction));
524 bal_action__init(&balAction);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530525 balMemberInfo->action = &balAction;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530526
527 balMemberInfo->action->has_presence_mask = BAL_GRPC_PRES;
528 balMemberInfo->action->presence_mask = group_ind->data.members.val->action.presence_mask;
529 balMemberInfo->action->has_cmds_bitmask = BAL_GRPC_PRES;
530 balMemberInfo->action->cmds_bitmask = group_ind->data.members.val->action.cmds_bitmask;
531 balMemberInfo->action->has_o_vid = BAL_GRPC_PRES;
532 balMemberInfo->action->o_vid = group_ind->data.members.val->action.o_vid;
533 balMemberInfo->action->has_o_pbits = BAL_GRPC_PRES;
534 balMemberInfo->action->o_pbits = group_ind->data.members.val->action.o_pbits;
535 balMemberInfo->action->has_o_tpid = BAL_GRPC_PRES;
536 balMemberInfo->action->o_tpid = group_ind->data.members.val->action.o_tpid;
537 balMemberInfo->action->has_i_vid = BAL_GRPC_PRES;
538 balMemberInfo->action->i_vid = group_ind->data.members.val->action.i_vid;
539 balMemberInfo->action->has_i_pbits = BAL_GRPC_PRES;
540 balMemberInfo->action->i_pbits = group_ind->data.members.val->action.i_pbits;
541 balMemberInfo->action->has_i_tpid = BAL_GRPC_PRES;
542 balMemberInfo->action->i_tpid = group_ind->data.members.val->action.i_tpid;
543
544 BalTmQueueRef balQueue;
545 memset(&balQueue, 0, sizeof(BalTmQueueRef));
546 bal_tm_queue_ref__init(&balQueue);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530547 balMemberInfo->queue = &balQueue;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530548
549 balMemberInfo->queue->has_sched_id = BAL_GRPC_PRES;
550 balMemberInfo->queue->sched_id = group_ind->data.members.val->queue.sched_id;
551 balMemberInfo->queue->has_queue_id = BAL_GRPC_PRES;
552 balMemberInfo->queue->queue_id = group_ind->data.members.val->queue.queue_id;
553
554 BalIdList balFlows;
555 memset(&balFlows, 0, sizeof(BalIdList));
556 bal_id_list__init(&balFlows);
557 balIndCfg.group_ind->data->flows = &balFlows;
558
559 balIndCfg.group_ind->data->flows->n_val = group_ind->data.flows.len;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530560 balIndCfg.group_ind->data->flows->val =
561 (uint32_t *)malloc((balIndCfg.group_ind->data->flows->n_val)*sizeof(uint32_t));
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530562 memcpy(balIndCfg.group_ind->data->flows->val, group_ind->data.flows.val,
563 balIndCfg.group_ind->data->flows->n_val);
564
565 BalErr *output;
566 result = bal_ind__bal_group_ind(client, NULL, &balIndCfg, &output, NULL, 0);
567 }
568
569 return result;
570}
571
572/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530573 * Function : bal_interface_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530574 * Description : This function will handle the indications for *
575 * Interface Operational State Change *
576 * *
577 ********************************************************************/
578bcmos_errno bal_interface_osc_indication_cb(bcmbal_obj *obj)
579{
580 bcmos_errno result = BCM_ERR_OK;
581
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530582 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530583 bcmbal_interface_auto_id_oper_status_change != obj->subgroup)
584 {
585 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
586 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
587 result = BCM_ERR_INTERNAL;
588 }
589 else
590 {
591 BalIndications balIndCfg;
592 memset(&balIndCfg, 0, sizeof(BalIndications));
593 bal_indications__init(&balIndCfg);
594 balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_OP_STATE;
595 balIndCfg.has_objtype = BAL_GRPC_PRES;
596 balIndCfg.objtype = obj->obj_type;
597 balIndCfg.has_sub_group = BAL_GRPC_PRES;
598 balIndCfg.sub_group = obj->subgroup;
599 balIndCfg.device_id = voltha_device_id;
600
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530601 bcmbal_interface_oper_status_change *int_osc_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530602 (bcmbal_interface_oper_status_change *)obj;
603
604 BalInterfaceOperStatusChange ifOsc;
605 memset(&ifOsc, 0, sizeof(BalInterfaceOperStatusChange));
606 bal_interface_oper_status_change__init(&ifOsc);
607 balIndCfg.interface_op_state = &ifOsc;
608
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530609 BalObj hdr;
610 memset(&hdr, 0, sizeof(BalObj));
611 bal_obj__init(&hdr);
612 balIndCfg.interface_op_state->hdr = &hdr;
613
614 BalInterfaceKey ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530615 memset(&ifkey, 0, sizeof(BalInterfaceKey));
616 bal_interface_key__init(&ifkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530617 balIndCfg.interface_op_state->key = &ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530618
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530619 balIndCfg.interface_op_state->key->has_intf_id = BAL_GRPC_PRES;
620 balIndCfg.interface_op_state->key->intf_id = int_osc_ind->key.intf_id;
621 balIndCfg.interface_op_state->key->has_intf_type = BAL_GRPC_PRES;
622 balIndCfg.interface_op_state->key->intf_type = int_osc_ind->key.intf_type;
623
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530624 BalInterfaceOperStatusChangeData ifOscIndData;
625 memset(&ifOscIndData, 0, sizeof(BalInterfaceOperStatusChangeData));
626 bal_interface_oper_status_change_data__init(&ifOscIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530627 balIndCfg.interface_op_state->data = &ifOscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530628
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530629 balIndCfg.interface_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
630 balIndCfg.interface_op_state->data->new_oper_status = int_osc_ind->data.new_oper_status;
631 balIndCfg.interface_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
632 balIndCfg.interface_op_state->data->old_oper_status = int_osc_ind->data.old_oper_status;
633 balIndCfg.interface_op_state->data->has_admin_state = BAL_GRPC_PRES;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530634 balIndCfg.interface_op_state->data->admin_state = int_osc_ind->data.admin_state;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530635
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530636 BalErr *output;
637 result = bal_ind__bal_iface_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
638 }
639
640 return result;
641}
642
643/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530644 * Function : bal_interface_los_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530645 * Description : This function will handle the indications for *
646 * Interface los Indication *
647 * *
648 ********************************************************************/
649bcmos_errno bal_interface_los_indication_cb(bcmbal_obj *obj)
650{
651 bcmos_errno result = BCM_ERR_OK;
652
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530653 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530654 bcmbal_interface_auto_id_los != obj->subgroup)
655 {
656 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
657 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
658 result = BCM_ERR_INTERNAL;
659 }
660 else
661 {
662 BalIndications balIndCfg;
663 memset(&balIndCfg, 0, sizeof(BalIndications));
664 bal_indications__init(&balIndCfg);
665 balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_LOS;
666 balIndCfg.has_objtype = BAL_GRPC_PRES;
667 balIndCfg.objtype = obj->obj_type;
668 balIndCfg.has_sub_group = BAL_GRPC_PRES;
669 balIndCfg.sub_group = obj->subgroup;
670 balIndCfg.device_id = voltha_device_id;
671
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530672 bcmbal_interface_los *int_los_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530673 (bcmbal_interface_los *)obj;
674
675 BalInterfaceLos ifLos;
676 memset(&ifLos, 0, sizeof(BalInterfaceLos));
677 bal_interface_los__init(&ifLos);
678 balIndCfg.interface_los = &ifLos;
679
680 BalObj hdr;
681 memset(&hdr, 0, sizeof(BalObj));
682 bal_obj__init(&hdr);
683 balIndCfg.interface_los->hdr = &hdr;
684
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530685 BalInterfaceKey ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530686 memset(&ifkey, 0, sizeof(BalInterfaceKey));
687 bal_interface_key__init(&ifkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530688 balIndCfg.interface_los->key = &ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530689
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530690 balIndCfg.interface_los->key->has_intf_id = BAL_GRPC_PRES;
691 balIndCfg.interface_los->key->intf_id = int_los_ind->key.intf_id;
692 balIndCfg.interface_los->key->has_intf_type = BAL_GRPC_PRES;
693 balIndCfg.interface_los->key->intf_type = int_los_ind->key.intf_type;
694
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530695 BalInterfaceLosData ifLosIndData;
696 memset(&ifLosIndData, 0, sizeof(BalInterfaceLosData));
697 bal_interface_los_data__init(&ifLosIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530698 balIndCfg.interface_los->data = &ifLosIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530699
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530700 balIndCfg.interface_los->data->has_status = BAL_GRPC_PRES;
701 balIndCfg.interface_los->data->status = int_los_ind->data.status;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530702
703 BalErr *output;
704 result = bal_ind__bal_iface_los(client, NULL, &balIndCfg, &output, NULL, 0);
705 }
706
707 return result;
708}
709
710/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530711 * Function : bal_interface_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530712 * Description : This function will handle the indications for *
713 * Interface Indication *
714 * *
715 ********************************************************************/
716bcmos_errno bal_interface_indication_cb(bcmbal_obj *obj)
717{
718 bcmos_errno result = BCM_ERR_OK;
719
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530720 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530721 bcmbal_interface_auto_id_ind != obj->subgroup)
722 {
723 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
724 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
725 result = BCM_ERR_INTERNAL;
726 }
727 else
728 {
729 BalIndications balIndCfg;
730 memset(&balIndCfg, 0, sizeof(BalIndications));
731 bal_indications__init(&balIndCfg);
732 balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_IND;
733 balIndCfg.has_objtype = BAL_GRPC_PRES;
734 balIndCfg.objtype = obj->obj_type;
735 balIndCfg.has_sub_group = BAL_GRPC_PRES;
736 balIndCfg.sub_group = obj->subgroup;
737 balIndCfg.device_id = voltha_device_id;
738
739 bcmbal_interface_ind *interface_ind = (bcmbal_interface_ind *)obj;
740
741 BalInterfaceInd ifInd;
742 memset(&ifInd, 0, sizeof(BalInterfaceInd));
743 bal_interface_ind__init(&ifInd);
744 balIndCfg.interface_ind = &ifInd;
745
746 BalObj hdr;
747 memset(&hdr, 0, sizeof(BalObj));
748 bal_obj__init(&hdr);
749 balIndCfg.interface_ind->hdr = &hdr;
750
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530751 BalInterfaceKey ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530752 memset(&ifkey, 0, sizeof(BalInterfaceKey));
753 bal_interface_key__init(&ifkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530754 balIndCfg.interface_ind->key = &ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530755
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530756 balIndCfg.interface_ind->key->has_intf_id = BAL_GRPC_PRES;
757 balIndCfg.interface_ind->key->intf_id = interface_ind->key.intf_id;
758 balIndCfg.interface_ind->key->has_intf_type = BAL_GRPC_PRES;
759 balIndCfg.interface_ind->key->intf_type = interface_ind->key.intf_type;
760
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530761 BalInterfaceIndData ifIndData;
762 memset(&ifIndData, 0, sizeof(BalInterfaceIndData));
763 bal_interface_ind_data__init(&ifIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530764 balIndCfg.interface_ind->data = &ifIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530765
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530766 balIndCfg.interface_ind->data->has_admin_state = BAL_GRPC_PRES;
767 balIndCfg.interface_ind->data->admin_state = interface_ind->data.admin_state;
768 balIndCfg.interface_ind->data->has_oper_status = BAL_GRPC_PRES;
769 balIndCfg.interface_ind->data->oper_status = interface_ind->data.oper_status;
770 balIndCfg.interface_ind->data->has_min_data_agg_port_id = BAL_GRPC_PRES;
771 balIndCfg.interface_ind->data->min_data_agg_port_id = interface_ind->data.min_data_agg_port_id;
772 balIndCfg.interface_ind->data->has_min_data_svc_port_id = BAL_GRPC_PRES;
773 balIndCfg.interface_ind->data->min_data_svc_port_id = interface_ind->data.min_data_svc_port_id;
774 balIndCfg.interface_ind->data->has_transceiver_type = BAL_GRPC_PRES;
775 balIndCfg.interface_ind->data->transceiver_type = interface_ind->data.transceiver_type;
776 balIndCfg.interface_ind->data->has_ds_miss_mode = BAL_GRPC_PRES;
777 balIndCfg.interface_ind->data->ds_miss_mode = interface_ind->data.ds_miss_mode;
778 balIndCfg.interface_ind->data->has_mtu = BAL_GRPC_PRES;
779 balIndCfg.interface_ind->data->mtu = interface_ind->data.mtu;
780 balIndCfg.interface_ind->data->has_flow_control = BAL_GRPC_PRES;
781 balIndCfg.interface_ind->data->flow_control = interface_ind->data.flow_control;
782 balIndCfg.interface_ind->data->has_ds_tm = BAL_GRPC_PRES;
783 balIndCfg.interface_ind->data->ds_tm = interface_ind->data.ds_tm;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530784 balIndCfg.interface_ind->data->has_us_tm = BAL_GRPC_PRES;
785 balIndCfg.interface_ind->data->us_tm = interface_ind->data.us_tm;
786
787 BalIdList balFlows;
788 memset(&balFlows, 0, sizeof(BalIdList));
789 bal_id_list__init(&balFlows);
790 balIndCfg.interface_ind->data->sub_term_id_list = &balFlows;
791
792 balIndCfg.interface_ind->data->sub_term_id_list->n_val = interface_ind->data.sub_term_id_list.len;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530793 balIndCfg.interface_ind->data->sub_term_id_list->val =
794 (uint32_t *)malloc((balIndCfg.interface_ind->data->sub_term_id_list->n_val)*sizeof(uint32_t));
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530795 memcpy(balIndCfg.interface_ind->data->sub_term_id_list->val, interface_ind->data.sub_term_id_list.val,
796 balIndCfg.interface_ind->data->sub_term_id_list->n_val);
797
798 BalErr *output;
799 result = bal_ind__bal_iface_ind(client, NULL, &balIndCfg, &output, NULL, 0);
800 }
801
802 return result;
803}
804
805/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530806 * Function : bal_sub_term_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530807 * Description : This function will handle the indications for *
808 * Subscriber term Operational State Change *
809 * *
810 ********************************************************************/
811bcmos_errno bal_sub_term_osc_indication_cb(bcmbal_obj *obj)
812{
813 bcmos_errno result = BCM_ERR_OK;
814
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530815 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530816 bcmbal_subscriber_terminal_auto_id_oper_status_change != obj->subgroup)
817 {
818 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
819 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
820 result = BCM_ERR_INTERNAL;
821 }
822 else
823 {
824 BalIndications balIndCfg;
825 memset(&balIndCfg, 0, sizeof(BalIndications));
826 bal_indications__init(&balIndCfg);
827 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_OP_STATE;
828 balIndCfg.has_objtype = BAL_GRPC_PRES;
829 balIndCfg.objtype = obj->obj_type;
830 balIndCfg.has_sub_group = BAL_GRPC_PRES;
831 balIndCfg.sub_group = obj->subgroup;
832 balIndCfg.device_id = voltha_device_id;
833
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530834 bcmbal_subscriber_terminal_oper_status_change *sub_osc_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530835 (bcmbal_subscriber_terminal_oper_status_change *)obj;
836
837 BalSubscriberTerminalOperStatusChange subOscInd;
838 memset(&subOscInd, 0, sizeof(BalSubscriberTerminalOperStatusChange));
839 bal_subscriber_terminal_oper_status_change__init(&subOscInd);
840 balIndCfg.terminal_op_state = &subOscInd;
841
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530842 BalObj hdr;
843 memset(&hdr, 0, sizeof(BalObj));
844 bal_obj__init(&hdr);
845 balIndCfg.terminal_op_state->hdr = &hdr;
846
847 BalSubscriberTerminalKey subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530848 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
849 bal_subscriber_terminal_key__init(&subkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530850 balIndCfg.terminal_op_state->key = &subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530851
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530852 balIndCfg.terminal_op_state->key->has_intf_id = BAL_GRPC_PRES;
853 balIndCfg.terminal_op_state->key->intf_id = sub_osc_ind->key.intf_id;
854 balIndCfg.terminal_op_state->key->has_sub_term_id = BAL_GRPC_PRES;
855 balIndCfg.terminal_op_state->key->sub_term_id = sub_osc_ind->key.sub_term_id;
856
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530857 BalSubscriberTerminalOperStatusChangeData subOscIndData;
858 memset(&subOscIndData, 0, sizeof(BalSubscriberTerminalOperStatusChangeData));
859 bal_subscriber_terminal_oper_status_change_data__init(&subOscIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530860 balIndCfg.terminal_op_state->data = &subOscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530861
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530862 balIndCfg.terminal_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
863 balIndCfg.terminal_op_state->data->new_oper_status =
864 sub_osc_ind->data.new_oper_status;
865 balIndCfg.terminal_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
866 balIndCfg.terminal_op_state->data->old_oper_status =
867 sub_osc_ind->data.old_oper_status;
868 balIndCfg.terminal_op_state->data->has_admin_state = BAL_GRPC_PRES;
869 balIndCfg.terminal_op_state->data->admin_state =
870 sub_osc_ind->data.admin_state;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530871
872 BalErr *output;
873 result = bal_ind__bal_subs_term_oper_sts_cng(client, NULL, &balIndCfg, &output, NULL, 0);
874 }
875
876 return result;
877}
878
879/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530880 * Function : bal_sub_term_disc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530881 * Description : This function will handle the indications for *
882 * Subscriber term disc indication *
883 * *
884 ********************************************************************/
885bcmos_errno bal_sub_term_disc_indication_cb(bcmbal_obj *obj)
886{
887 bcmos_errno result = BCM_ERR_OK;
888
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530889 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530890 bcmbal_subscriber_terminal_auto_id_sub_term_disc != obj->subgroup)
891 {
892 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
893 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
894 result = BCM_ERR_INTERNAL;
895 }
896 else
897 {
898 ASFVOLT_LOG(ASFVOLT_DEBUG, "Processing BAL API \'%s\' IND callback (status is %s)\n",
899 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
900 BalIndications balIndCfg;
901 memset(&balIndCfg, 0, sizeof(BalIndications));
902 bal_indications__init(&balIndCfg);
903 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DISC;
904 balIndCfg.has_objtype = BAL_GRPC_PRES;
905 balIndCfg.objtype = obj->obj_type;
906 balIndCfg.has_sub_group = BAL_GRPC_PRES;
907 balIndCfg.sub_group = obj->subgroup;
908 balIndCfg.device_id = voltha_device_id;
909
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530910 bcmbal_subscriber_terminal_sub_term_disc *sub_disc_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530911 (bcmbal_subscriber_terminal_sub_term_disc *)obj;
912
913 BalSubscriberTerminalSubTermDisc subDiscInd;
914 memset(&subDiscInd, 0, sizeof(BalSubscriberTerminalSubTermDisc));
915 bal_subscriber_terminal_sub_term_disc__init(&subDiscInd);
916 balIndCfg.terminal_disc = &subDiscInd;
917
918 BalObj hdr;
919 memset(&hdr, 0, sizeof(BalObj));
920 bal_obj__init(&hdr);
921 balIndCfg.terminal_disc->hdr = &hdr;
922
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530923 BalSubscriberTerminalKey subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530924 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
925 bal_subscriber_terminal_key__init(&subkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530926 balIndCfg.terminal_disc->key = &subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530927
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530928 balIndCfg.terminal_disc->key->has_intf_id = BAL_GRPC_PRES;
929 balIndCfg.terminal_disc->key->intf_id = sub_disc_ind->key.intf_id;
930 balIndCfg.terminal_disc->key->has_sub_term_id = BAL_GRPC_PRES;
931 balIndCfg.terminal_disc->key->sub_term_id = sub_disc_ind->key.sub_term_id;
932
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530933 BalSubscriberTerminalSubTermDiscData subDiscIndData;
934 memset(&subDiscIndData, 0, sizeof(BalSubscriberTerminalSubTermDiscData));
935 bal_subscriber_terminal_sub_term_disc_data__init(&subDiscIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530936 balIndCfg.terminal_disc->data = &subDiscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530937
938 BalSerialNumber serial_number;
939 memset(&serial_number, 0, sizeof(BalSerialNumber));
940 bal_serial_number__init(&serial_number);
941
942 balIndCfg.terminal_disc->data->serial_number = &serial_number;
943
944 ASFVOLT_LOG(ASFVOLT_DEBUG, "Discovered ONU serial number "
945 "%2X%2X%2X%2X%1X%1X%1X%1X%1X%1X%1X%1X ",
946 sub_disc_ind->data.serial_number.vendor_id[0],
947 sub_disc_ind->data.serial_number.vendor_id[1],
948 sub_disc_ind->data.serial_number.vendor_id[2],
949 sub_disc_ind->data.serial_number.vendor_id[3],
950 sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
951 sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
952 sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
953 sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
954 sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
955 sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
956 sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
957 sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
958
959 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor id is %s\n", sub_disc_ind->data.serial_number.vendor_id);
960 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor specific is %s\n", sub_disc_ind->data.serial_number.vendor_specific);
961
962 char vendor_id[MAX_CHAR_LENGTH];
963 memset(&vendor_id, 0, MAX_CHAR_LENGTH);
964 sprintf(vendor_id,"%c%c%c%c",
965 sub_disc_ind->data.serial_number.vendor_id[0],
966 sub_disc_ind->data.serial_number.vendor_id[1],
967 sub_disc_ind->data.serial_number.vendor_id[2],
968 sub_disc_ind->data.serial_number.vendor_id[3]);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530969 balIndCfg.terminal_disc->data->serial_number->vendor_id = vendor_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530970 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor id is %s\n", balIndCfg.terminal_disc->data->serial_number->vendor_id);
971 char vendor_specific[MAX_CHAR_LENGTH];
972 memset(&vendor_specific, 0, MAX_CHAR_LENGTH);
973 sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
974 sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
975 sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
976 sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
977 sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
978 sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
979 sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
980 sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
981 sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
982 balIndCfg.terminal_disc->data->serial_number->vendor_specific = vendor_specific;
983 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor specific is %s\n", balIndCfg.terminal_disc->data->serial_number->vendor_specific);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530984
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530985 BalErr *output;
986 result = bal_ind__bal_subs_term_discovery_ind(client, NULL, &balIndCfg, &output, NULL, 0);
987 }
988
989 return result;
990}
991
992/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530993 * Function : bal_sub_term_alarm_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530994 * Description : This function will handle the indications for *
995 * Subscriber term alarm indication *
996 * *
997 ********************************************************************/
998bcmos_errno bal_sub_term_alarm_indication_cb(bcmbal_obj *obj)
999{
1000 bcmos_errno result = BCM_ERR_OK;
1001
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301002 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301003 bcmbal_subscriber_terminal_auto_id_sub_term_alarm != obj->subgroup)
1004 {
1005 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1006 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1007 result = BCM_ERR_INTERNAL;
1008 }
1009 else
1010 {
1011 BalIndications balIndCfg;
1012 memset(&balIndCfg, 0, sizeof(BalIndications));
1013 bal_indications__init(&balIndCfg);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301014 balIndCfg.has_objtype = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301015 balIndCfg.objtype = BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301016 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1017 balIndCfg.sub_group = obj->subgroup;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301018
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301019 balIndCfg.device_id = voltha_device_id;
1020
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301021 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_ALARM;
1022 bcmbal_subscriber_terminal_sub_term_alarm *sub_term_alarm =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301023 (bcmbal_subscriber_terminal_sub_term_alarm *)obj;
1024
1025 BalSubscriberTerminalSubTermAlarm subTermAlarm;
1026 memset(&subTermAlarm, 0, sizeof(BalSubscriberTerminalSubTermAlarm));
1027 bal_subscriber_terminal_sub_term_alarm__init(&subTermAlarm);
1028 balIndCfg.terminal_alarm = &subTermAlarm;
1029
1030 BalObj hdr;
1031 memset(&hdr, 0, sizeof(BalObj));
1032 bal_obj__init(&hdr);
1033 balIndCfg.terminal_alarm->hdr = &hdr;
1034
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301035 BalSubscriberTerminalKey subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301036 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
1037 bal_subscriber_terminal_key__init(&subkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301038 balIndCfg.terminal_alarm->key = &subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301039
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301040 balIndCfg.terminal_alarm->key->has_sub_term_id = BAL_GRPC_PRES;
1041 balIndCfg.terminal_alarm->key->sub_term_id = sub_term_alarm->key.sub_term_id;
1042 balIndCfg.terminal_alarm->key->has_intf_id = BAL_GRPC_PRES;
1043 balIndCfg.terminal_alarm->key->intf_id = sub_term_alarm->key.intf_id;
1044
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301045 BalsubscriberTerminalSubTermAlarmData subTermAlarmData;
1046 memset(&subTermAlarmData, 0, sizeof(BalsubscriberTerminalSubTermAlarmData));
1047 balsubscriber_terminal_sub_term_alarm_data__init(&subTermAlarmData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301048 balIndCfg.terminal_alarm->data = &subTermAlarmData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301049
1050 BalSubscriberTerminalAlarms balSubAlarms;
1051 memset(&balSubAlarms, 0, sizeof(BalSubscriberTerminalAlarms));
1052 bal_subscriber_terminal_alarms__init(&balSubAlarms);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301053 balIndCfg.terminal_alarm->data->alarm = &balSubAlarms;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301054
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301055 balIndCfg.terminal_alarm->data->alarm->has_los = BAL_GRPC_PRES;
1056 balIndCfg.terminal_alarm->data->alarm->los = sub_term_alarm->data.alarm.los;
1057 balIndCfg.terminal_alarm->data->alarm->has_lob = BAL_GRPC_PRES;
1058 balIndCfg.terminal_alarm->data->alarm->lob = sub_term_alarm->data.alarm.lob;
1059 balIndCfg.terminal_alarm->data->alarm->has_lopc_miss = BAL_GRPC_PRES;
1060 balIndCfg.terminal_alarm->data->alarm->lopc_miss = sub_term_alarm->data.alarm.lopc_miss;
1061 balIndCfg.terminal_alarm->data->alarm->has_lopc_mic_error = BAL_GRPC_PRES;
1062 balIndCfg.terminal_alarm->data->alarm->lopc_mic_error = sub_term_alarm->data.alarm.lopc_mic_error;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301063
1064 BalErr *output;
1065 result = bal_ind__bal_subs_term_alarm_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1066 }
1067
1068 return result;
1069}
1070
1071/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301072 * Function : bal_sub_term_dgi_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301073 * Description : This function will handle the indications for *
1074 * Subscriber term dgi indication *
1075 * *
1076 ********************************************************************/
1077bcmos_errno bal_sub_term_dgi_indication_cb(bcmbal_obj *obj)
1078{
1079 bcmos_errno result = BCM_ERR_OK;
1080
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301081 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301082 bcmbal_subscriber_terminal_auto_id_dgi != obj->subgroup)
1083 {
1084 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1085 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1086 result = BCM_ERR_INTERNAL;
1087 }
1088 else
1089 {
1090 BalIndications balIndCfg;
1091 memset(&balIndCfg, 0, sizeof(BalIndications));
1092 bal_indications__init(&balIndCfg);
1093 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DGI;
1094 balIndCfg.has_objtype = BAL_GRPC_PRES;
1095 balIndCfg.objtype = obj->obj_type;
1096 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1097 balIndCfg.sub_group = obj->subgroup;
1098 balIndCfg.device_id = voltha_device_id;
1099
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301100 bcmbal_subscriber_terminal_dgi *sub_dgi_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301101 (bcmbal_subscriber_terminal_dgi *)obj;
1102
1103 BalSubscriberTerminalDgi subDgiInd;
1104 memset(&subDgiInd, 0, sizeof(BalSubscriberTerminalDgi));
1105 bal_subscriber_terminal_dgi__init(&subDgiInd);
1106 balIndCfg.terminal_dgi= &subDgiInd;
1107
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301108 BalObj hdr;
1109 memset(&hdr, 0, sizeof(BalObj));
1110 bal_obj__init(&hdr);
1111 balIndCfg.terminal_dgi->hdr = &hdr;
1112
1113 BalSubscriberTerminalKey subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301114 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
1115 bal_subscriber_terminal_key__init(&subkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301116 balIndCfg.terminal_disc->key = &subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301117
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301118 balIndCfg.terminal_dgi->key->has_intf_id = BAL_GRPC_PRES;
1119 balIndCfg.terminal_dgi->key->intf_id = sub_dgi_ind->key.intf_id;
1120 balIndCfg.terminal_dgi->key->has_sub_term_id = BAL_GRPC_PRES;
1121 balIndCfg.terminal_dgi->key->sub_term_id = sub_dgi_ind->key.sub_term_id;
1122
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301123 BalSubscriberTerminalDgiData subDgiIndData;
1124 memset(&subDgiIndData, 0, sizeof(BalSubscriberTerminalDgiData));
1125 bal_subscriber_terminal_dgi_data__init(&subDgiIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301126 balIndCfg.terminal_dgi->data = &subDgiIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301127
1128 balIndCfg.terminal_dgi->data->has_dgi_status = BAL_GRPC_PRES;
1129 balIndCfg.terminal_dgi->data->dgi_status = sub_dgi_ind->data.dgi_status;
1130
1131 BalErr *output;
1132 result = bal_ind__bal_subs_term_dgi_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1133 }
1134
1135 return result;
1136}
1137
1138/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301139 * Function : bal_sub_term_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301140 * Description : This function will handle the indications for *
1141 * Subscriber term indication *
1142 * *
1143 ********************************************************************/
1144bcmos_errno bal_sub_term_indication_cb(bcmbal_obj *obj)
1145{
1146 bcmos_errno result = BCM_ERR_OK;
1147
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301148 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301149 bcmbal_subscriber_terminal_auto_id_ind != obj->subgroup)
1150 {
1151 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1152 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1153 result = BCM_ERR_INTERNAL;
1154 }
1155 else
1156 {
1157 BalIndications balIndCfg;
1158 memset(&balIndCfg, 0, sizeof(BalIndications));
1159 bal_indications__init(&balIndCfg);
1160 balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_IND;
1161 balIndCfg.has_objtype = BAL_GRPC_PRES;
1162 balIndCfg.objtype = obj->obj_type;
1163 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1164 balIndCfg.sub_group = obj->subgroup;
1165 balIndCfg.device_id = voltha_device_id;
1166
1167 bcmbal_subscriber_terminal_ind *sub_ind = (bcmbal_subscriber_terminal_ind *)obj;
1168
1169 BalSubscriberTerminalInd subInd;
1170 memset(&subInd, 0, sizeof(BalSubscriberTerminalInd));
1171 bal_subscriber_terminal_ind__init(&subInd);
1172 balIndCfg.terminal_ind = &subInd;
1173
1174 BalObj hdr;
1175 memset(&hdr, 0, sizeof(BalObj));
1176 bal_obj__init(&hdr);
1177 balIndCfg.terminal_ind->hdr = &hdr;
1178
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301179 BalSubscriberTerminalKey subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301180 memset(&subkey, 0, sizeof(BalSubscriberTerminalKey));
1181 bal_subscriber_terminal_key__init(&subkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301182 balIndCfg.terminal_ind->key = &subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301183
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301184 balIndCfg.terminal_ind->key->has_intf_id = BAL_GRPC_PRES;
1185 balIndCfg.terminal_ind->key->intf_id = sub_ind->key.intf_id;
1186 balIndCfg.terminal_ind->key->has_sub_term_id = BAL_GRPC_PRES;
1187 balIndCfg.terminal_ind->key->sub_term_id = sub_ind->key.sub_term_id;
1188
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301189 BalSubscriberTerminalIndData subIndData;
1190 memset(&subIndData, 0, sizeof(BalSubscriberTerminalIndData));
1191 bal_subscriber_terminal_ind_data__init(&subIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301192 balIndCfg.terminal_ind->data = &subIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301193
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301194 balIndCfg.terminal_ind->data->has_admin_state = BAL_GRPC_PRES;
1195 balIndCfg.terminal_ind->data->admin_state = sub_ind->data.admin_state;
1196 balIndCfg.terminal_ind->data->has_oper_status = BAL_GRPC_PRES;
1197 balIndCfg.terminal_ind->data->oper_status = sub_ind->data.oper_status;
1198 balIndCfg.terminal_ind->data->has_svc_port_id = BAL_GRPC_PRES;
1199 balIndCfg.terminal_ind->data->svc_port_id = sub_ind->data.svc_port_id;
1200 balIndCfg.terminal_ind->data->has_ds_tm = BAL_GRPC_PRES;
1201 balIndCfg.terminal_ind->data->ds_tm = sub_ind->data.ds_tm;
1202 balIndCfg.terminal_ind->data->has_us_tm = BAL_GRPC_PRES;
1203 balIndCfg.terminal_ind->data->us_tm = sub_ind->data.us_tm;
1204 balIndCfg.terminal_ind->data->has_sub_term_rate = BAL_GRPC_PRES;
1205 balIndCfg.terminal_ind->data->sub_term_rate = sub_ind->data.sub_term_rate;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301206 char password[MAX_CHAR_LENGTH*2];
1207 memset(&password, 0, MAX_CHAR_LENGTH*2);
1208 strcpy(password,(const char *)sub_ind->data.password.arr);
1209 balIndCfg.terminal_ind->data->password = password;
1210 char registration_id[MAX_CHAR_LENGTH*8];
1211 memset(&registration_id, 0, MAX_CHAR_LENGTH*8);
1212 strcpy(registration_id,(const char *)sub_ind->data.registration_id.arr);
1213 balIndCfg.terminal_ind->data->registration_id = registration_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301214
1215#if 0
1216 balIndCfg.terminal_ind->data->has_mac_address = BAL_GRPC_PRES;
1217 balIndCfg.terminal_ind->data->mac_address.len =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301218 (BCMOS_ETH_ALEN)*sizeof(sub_ind->data.mac_address.u8);
1219 uint8_t mac_address[balIndCfg.terminal_ind->data->mac_address.len];
1220 memset(&mac_address, 0 ,balIndCfg.terminal_ind->data->mac_address.len);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301221 strcpy((char *)mac_address,(const char *)sub_ind->data.mac_address.u8);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301222 balIndCfg.terminal_ind->data->mac_address.data = mac_address;
1223#endif
1224
1225 BalSerialNumber serialNum;
1226 memset(&serialNum, 0, sizeof(BalSerialNumber));
1227 bal_serial_number__init(&serialNum);
1228 balIndCfg.terminal_ind->data->serial_number = &serialNum;
1229
1230 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:Before decoding:Vendor id is %s\n", sub_ind->data.serial_number.vendor_id);
1231 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:Before decoding:Vendor specific is %s\n", sub_ind->data.serial_number.vendor_specific);
1232
1233 char vendor_id[MAX_CHAR_LENGTH];
1234 memset(&vendor_id, 0, MAX_CHAR_LENGTH);
1235 sprintf(vendor_id,"%c%c%c%c",
1236 sub_ind->data.serial_number.vendor_id[0],
1237 sub_ind->data.serial_number.vendor_id[1],
1238 sub_ind->data.serial_number.vendor_id[2],
1239 sub_ind->data.serial_number.vendor_id[3]);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301240 balIndCfg.terminal_ind->data->serial_number->vendor_id = vendor_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301241 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:After decoding:Vendor id is %s\n", balIndCfg.terminal_ind->data->serial_number->vendor_id);
1242 char vendor_specific[MAX_CHAR_LENGTH];
1243 memset(&vendor_specific, 0, MAX_CHAR_LENGTH);
1244 sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
1245 sub_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
1246 sub_ind->data.serial_number.vendor_specific[0] & 0x0f,
1247 sub_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
1248 sub_ind->data.serial_number.vendor_specific[1] & 0x0f,
1249 sub_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
1250 sub_ind->data.serial_number.vendor_specific[2] & 0x0f,
1251 sub_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
1252 sub_ind->data.serial_number.vendor_specific[3] & 0x0f);
1253 balIndCfg.terminal_ind->data->serial_number->vendor_specific = vendor_specific;
1254 ASFVOLT_LOG(ASFVOLT_ERROR, "ONU Activation:After decoding:Vendor specific is %s\n", balIndCfg.terminal_ind->data->serial_number->vendor_specific);
1255
1256 BalIdList balAggportList;
1257 memset(&balAggportList, 0, sizeof(BalIdList));
1258 bal_id_list__init(&balAggportList);
1259 balIndCfg.terminal_ind->data->agg_port_id_list = &balAggportList;
1260
1261#if 0
1262 balIndCfg.terminal_ind->data->agg_port_id_list->n_val = sub_ind->data.agg_port_id_list.len;
1263 uint32_t agg_port_id_list[balIndCfg.terminal_ind->data->agg_port_id_list->n_val];
1264 memset(&agg_port_id_list, 0, balIndCfg.terminal_ind->data->agg_port_id_list->n_val);
1265 strcpy((char *)agg_port_id_list,(const char *)sub_ind->data.agg_port_id_list.val);
1266 balIndCfg.terminal_ind->data->agg_port_id_list->val = agg_port_id_list;
1267#endif
1268
1269 BalErr *output;
1270 result = bal_ind__bal_subs_term_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1271 }
1272
1273 return result;
1274}
1275
1276/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301277 * Function : fill_bal_tm_red *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301278 * Description : This function will fill grpc-BalTmred struture *
1279 * from bal-bcmbal_tm_red structure *
1280 * *
1281 ********************************************************************/
1282void fill_bal_tm_red(BalTmred *grpc_red, bcmbal_tm_red *bal_red)
1283{
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301284 grpc_red->has_min_threshold = BAL_GRPC_PRES;
1285 grpc_red->min_threshold = bal_red->min_threshold;
1286 grpc_red->has_max_threshold = BAL_GRPC_PRES;
1287 grpc_red->max_threshold = bal_red->max_threshold;
1288 grpc_red->has_max_probability = BAL_GRPC_PRES;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301289 grpc_red->max_probability = bal_red->max_probability;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301290 return;
1291}
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301292
1293/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301294 * Function : bal_tm_queue_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301295 * Description : This function will handle the indications for *
1296 * TM Queue indication *
1297 * *
1298 ********************************************************************/
1299bcmos_errno bal_tm_queue_indication_cb(bcmbal_obj *obj)
1300{
1301 bcmos_errno result = BCM_ERR_OK;
1302
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301303 if(BCMBAL_OBJ_ID_TM_QUEUE != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301304 bcmbal_tm_queue_auto_id_ind != obj->subgroup)
1305 {
1306 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1307 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1308 result = BCM_ERR_INTERNAL;
1309 }
1310 else
1311 {
1312 BalIndications balIndCfg;
1313 memset(&balIndCfg, 0, sizeof(BalIndications));
1314 bal_indications__init(&balIndCfg);
1315 balIndCfg.u_case = BAL_INDICATIONS__U_TM_QUEUE__IND;
1316 balIndCfg.has_objtype = BAL_GRPC_PRES;
1317 balIndCfg.objtype = obj->obj_type;
1318 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1319 balIndCfg.sub_group = obj->subgroup;
1320 balIndCfg.device_id = voltha_device_id;
1321
1322 bcmbal_tm_queue_ind *tm_que_ind = (bcmbal_tm_queue_ind *)obj;
1323
1324 BalTmQueueInd tmQueInd;
1325 memset(&tmQueInd, 0, sizeof(BalTmQueueInd));
1326 bal_tm_queue_ind__init(&tmQueInd);
1327 balIndCfg.tm_queue_ind = &tmQueInd;
1328
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301329 BalTmQueueKey tmQkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301330 memset(&tmQkey, 0, sizeof(BalTmQueueKey));
1331 bal_tm_queue_key__init(&tmQkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301332 balIndCfg.tm_queue_ind->key = &tmQkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301333
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301334 balIndCfg.tm_queue_ind->key->has_sched_id = BAL_GRPC_PRES;
1335 balIndCfg.tm_queue_ind->key->sched_id = tm_que_ind->key.sched_id;
1336 balIndCfg.tm_queue_ind->key->has_sched_dir = BAL_GRPC_PRES;
1337 balIndCfg.tm_queue_ind->key->sched_dir = tm_que_ind->key.sched_dir;
1338 balIndCfg.tm_queue_ind->key->has_id = BAL_GRPC_PRES;
1339 balIndCfg.tm_queue_ind->key->id = tm_que_ind->key.id;
1340
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301341 BalTmQueueIndData tmQIndData;
1342 memset(&tmQIndData, 0, sizeof(BalTmQueueIndData));
1343 bal_tm_queue_ind_data__init(&tmQIndData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301344 balIndCfg.tm_queue_ind->data = &tmQIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301345
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301346 balIndCfg.tm_queue_ind->data->has_priority = BAL_GRPC_PRES;
1347 balIndCfg.tm_queue_ind->data->priority = tm_que_ind->data.priority;
1348 balIndCfg.tm_queue_ind->data->has_weight = BAL_GRPC_PRES;
1349 balIndCfg.tm_queue_ind->data->weight = tm_que_ind->data.weight;
1350 balIndCfg.tm_queue_ind->data->has_create_mode = BAL_GRPC_PRES;
1351 balIndCfg.tm_queue_ind->data->create_mode = tm_que_ind->data.create_mode;
1352 balIndCfg.tm_queue_ind->data->has_ref_count = BAL_GRPC_PRES;
1353 balIndCfg.tm_queue_ind->data->ref_count = tm_que_ind->data.ref_count;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301354
1355 BalTmShaping balShape;
1356 memset(&balShape, 0, sizeof(BalTmShaping));
1357 bal_tm_shaping__init(&balShape);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301358 balIndCfg.tm_queue_ind->data->rate = &balShape;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301359
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301360 balIndCfg.tm_queue_ind->data->rate->has_presence_mask = BAL_GRPC_PRES;
1361 balIndCfg.tm_queue_ind->data->rate->presence_mask = tm_que_ind->data.rate.presence_mask;
1362 balIndCfg.tm_queue_ind->data->rate->has_cir = BAL_GRPC_PRES;
1363 balIndCfg.tm_queue_ind->data->rate->cir = tm_que_ind->data.rate.cir;
1364 balIndCfg.tm_queue_ind->data->rate->has_pir = BAL_GRPC_PRES;
1365 balIndCfg.tm_queue_ind->data->rate->pir = tm_que_ind->data.rate.pir;
1366 balIndCfg.tm_queue_ind->data->rate->has_burst = BAL_GRPC_PRES;
1367 balIndCfg.tm_queue_ind->data->rate->burst = tm_que_ind->data.rate.burst;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301368
1369 BalTmBac balBac;
1370 memset(&balBac, 0, sizeof(BalTmBac));
1371 bal_tm_bac__init(&balBac);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301372 balIndCfg.tm_queue_ind->data->bac = &balBac;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301373
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301374 balIndCfg.tm_queue_ind->data->bac->has_type = BAL_GRPC_PRES;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301375 balIndCfg.tm_queue_ind->data->bac->type = tm_que_ind->data.bac.type;
1376 switch(tm_que_ind->data.bac.type)
1377 {
1378 case BCMBAL_TM_BAC_TYPE_TAILDROP:
1379 {
1380 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_TAILDROP;
1381 BalTMBacTaildrop balTaildrop;
1382 memset(&balTaildrop, 0, sizeof(BalTMBacTaildrop));
1383 bal_tmbac_taildrop__init(&balTaildrop);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301384 balIndCfg.tm_queue_ind->data->bac->taildrop = &balTaildrop;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301385
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301386 balIndCfg.tm_queue_ind->data->bac->taildrop->has_max_size = BAL_GRPC_PRES;
1387 balIndCfg.tm_queue_ind->data->bac->taildrop->max_size =
1388 tm_que_ind->data.bac.u.taildrop.max_size;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301389 }
1390 break;
1391 case BCMBAL_TM_BAC_TYPE_WTAILDROP:
1392 {
1393 /* No bal/grpc structure was defined */
1394 }
1395 break;
1396 case BCMBAL_TM_BAC_TYPE_RED:
1397 {
1398 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_RED;
1399 BalTMBacRed balBacRed;
1400 memset(&balBacRed, 0, sizeof(BalTMBacRed));
1401 bal_tmbac_red__init(&balBacRed);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301402 balIndCfg.tm_queue_ind->data->bac->red = &balBacRed;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301403
1404 BalTmred balRed;
1405 memset(&balRed, 0, sizeof(BalTmred));
1406 bal_tmred__init(&balRed);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301407 balIndCfg.tm_queue_ind->data->bac->red->red = &balRed;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301408 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->red->red, &tm_que_ind->data.bac.u.red.red);
1409 }
1410 break;
1411 case BCMBAL_TM_BAC_TYPE_WRED:
1412 {
1413 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U_WRED;
1414 BalTMBacWred balBacWred;
1415 memset(&balBacWred, 0, sizeof(BalTMBacWred));
1416 bal_tmbac_wred__init(&balBacWred);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301417 balIndCfg.tm_queue_ind->data->bac->wred = &balBacWred;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301418
1419 BalTmred balGreen;
1420 memset(&balGreen, 0, sizeof(BalTmred));
1421 bal_tmred__init(&balGreen);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301422 balIndCfg.tm_queue_ind->data->bac->wred->green = &balGreen;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301423 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->green, &tm_que_ind->data.bac.u.wred.green);
1424
1425 BalTmred balYellow;
1426 memset(&balYellow, 0, sizeof(BalTmred));
1427 bal_tmred__init(&balYellow);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301428 balIndCfg.tm_queue_ind->data->bac->wred->yellow = &balYellow;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301429 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->yellow, &tm_que_ind->data.bac.u.wred.yellow);
1430
1431 BalTmred balRed;
1432 memset(&balRed, 0, sizeof(BalTmred));
1433 bal_tmred__init(&balRed);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301434 balIndCfg.tm_queue_ind->data->bac->wred->red = &balRed;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301435 fill_bal_tm_red(balIndCfg.tm_queue_ind->data->bac->wred->red, &tm_que_ind->data.bac.u.wred.red);
1436 }
1437 break;
1438 default:
1439 {
1440 balIndCfg.tm_queue_ind->data->bac->u_case = BAL_TM_BAC__U__NOT_SET;
1441 }
1442 break;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301443
1444 }
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301445
1446 BalErr *output;
1447 result = bal_ind__bal_tm_queue_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
1448 }
1449
1450 return result;
1451}
1452
1453/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301454 * Function : bal_tm_sched_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301455 * Description : This function will handle the indications for *
1456 * TM Sched indication *
1457 * *
1458 ********************************************************************/
1459bcmos_errno bal_tm_sched_indication_cb(bcmbal_obj *obj)
1460{
1461 bcmos_errno result = BCM_ERR_OK;
1462
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301463 if(BCMBAL_OBJ_ID_TM_SCHED != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301464 bcmbal_tm_sched_auto_id_ind != obj->subgroup)
1465 {
1466 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1467 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1468 result = BCM_ERR_INTERNAL;
1469 }
1470 else
1471 {
1472 BalIndications balIndCfg;
1473 memset(&balIndCfg, 0, sizeof(BalIndications));
1474 bal_indications__init(&balIndCfg);
1475 balIndCfg.u_case = BAL_INDICATIONS__U_TM_SCHED__IND;
1476 balIndCfg.has_objtype = BAL_GRPC_PRES;
1477 balIndCfg.objtype = obj->obj_type;
1478 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1479 balIndCfg.sub_group = obj->subgroup;
1480 balIndCfg.device_id = voltha_device_id;
1481
1482 bcmbal_tm_sched_ind *tm_sched_ind = (bcmbal_tm_sched_ind *)obj;
1483
1484 BalTmSchedInd tmSchedInd;
1485 memset(&tmSchedInd, 0, sizeof(BalTmSchedInd));
1486 bal_tm_sched_ind__init(&tmSchedInd);
1487 balIndCfg.tm_sched_ind = &tmSchedInd;
1488
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301489 BalTmSchedKey tmSchedkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301490 memset(&tmSchedkey, 0, sizeof(BalTmSchedKey));
1491 bal_tm_sched_key__init(&tmSchedkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301492 balIndCfg.tm_sched_ind->key = &tmSchedkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301493
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301494 balIndCfg.tm_sched_ind->key->has_dir = BAL_GRPC_PRES;
1495 balIndCfg.tm_sched_ind->key->dir = tm_sched_ind->key.dir;
1496 balIndCfg.tm_sched_ind->key->has_id = BAL_GRPC_PRES;
1497 balIndCfg.tm_sched_ind->key->id = tm_sched_ind->key.id;
1498
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301499 BalTmSchedIndData tmSIndData;
1500 memset(&tmSIndData, 0, sizeof(BalTmSchedIndData));
1501 bal_tm_sched_ind_data__init(&tmSIndData);
1502 balIndCfg.tm_sched_ind->data = &tmSIndData;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301503 /* TODO: data should be populate */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301504
1505 BalErr *output;
1506 result = bal_ind__bal_tm_sched_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
1507 }
1508
1509 return result;
1510}
1511
1512/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301513 * Function : bal_packet_data_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301514 * Description : This function will handle the indications for *
1515 * Packet Data indication *
1516 * *
1517 ********************************************************************/
1518bcmos_errno bal_packet_data_indication_cb(bcmbal_obj *obj)
1519{
1520 bcmos_errno result = BCM_ERR_OK;
1521
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301522 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301523 bcmbal_packet_auto_id_bearer_channel_rx != obj->subgroup)
1524 {
1525 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1526 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1527 result = BCM_ERR_INTERNAL;
1528 }
1529 else
1530 {
1531 /*bcmos_mutex_lock(&bal_ind_lock);-- Need to define bcm independent mutex*/
1532
1533 BalIndications balIndCfg;
Rajeswara Raoa3efbca2017-09-08 18:01:16 +05301534 memset(&balIndCfg, 0, sizeof(BalIndications));
1535 bal_indications__init(&balIndCfg);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301536 balIndCfg.u_case = BAL_INDICATIONS__U_PKT_DATA;
1537 balIndCfg.has_objtype = BAL_GRPC_PRES;
1538 balIndCfg.objtype = obj->obj_type;
1539 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1540 balIndCfg.sub_group = obj->subgroup;
1541 balIndCfg.device_id = voltha_device_id;
1542
1543 BalPacketBearerChannelRx rxChannel;
1544 memset(&rxChannel, 0, sizeof(BalPacketBearerChannelRx));
1545 bal_packet_bearer_channel_rx__init(&rxChannel);
1546 balIndCfg.pktdata = &rxChannel;
1547
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301548 BalObj hdr;
1549 memset(&hdr, 0, sizeof(BalObj));
1550 bal_obj__init(&hdr);
1551 balIndCfg.pktdata->hdr = &hdr;
1552
1553 BalPacketKey packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301554 memset(&packetkey, 0, sizeof(BalPacketKey));
1555 bal_packet_key__init(&packetkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301556 balIndCfg.pktdata->key = &packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301557
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301558 bcmbal_packet_bearer_channel_rx *rx_channel =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301559 (bcmbal_packet_bearer_channel_rx *)obj;
1560
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301561 balIndCfg.pktdata->key->has_reserved = BAL_GRPC_PRES;
1562 balIndCfg.pktdata->key->reserved = rx_channel->key.reserved;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301563
1564 BalDest PktSndDest;
1565 memset(&PktSndDest, 0, sizeof(BalDest));
1566 bal_dest__init(&PktSndDest);
1567 balIndCfg.pktdata->key->packet_send_dest = &PktSndDest;
1568
1569 balIndCfg.pktdata->key->packet_send_dest->has_type = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301570 balIndCfg.pktdata->key->packet_send_dest->type =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301571 rx_channel->key.packet_send_dest.type;
1572 switch( rx_channel->key.packet_send_dest.type)
1573 {
1574 case BCMBAL_DEST_TYPE_NNI:
1575 {
1576 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_NNI;
1577 BalDestNni balNni;
1578 memset(&balNni, 0, sizeof(BalDestNni));
1579 bal_dest_nni__init(&balNni);
1580 balIndCfg.pktdata->key->packet_send_dest->nni = &balNni;
1581 balIndCfg.pktdata->key->packet_send_dest->nni->has_intf_id = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301582 balIndCfg.pktdata->key->packet_send_dest->nni->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301583 rx_channel->key.packet_send_dest.u.nni.intf_id;
1584 }
1585 break;
1586 case BCMBAL_DEST_TYPE_SUB_TERM:
1587 {
1588 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SUB_TERM;
1589 BalDestSubTerm balSubTerm;
1590 memset(&balSubTerm, 0, sizeof(BalDestSubTerm));
1591 bal_dest_sub_term__init(&balSubTerm);
1592 balIndCfg.pktdata->key->packet_send_dest->sub_term = &balSubTerm;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301593 balIndCfg.pktdata->key->packet_send_dest->sub_term->has_sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301594 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301595 balIndCfg.pktdata->key->packet_send_dest->sub_term->sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301596 rx_channel->key.packet_send_dest.u.sub_term.sub_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301597 balIndCfg.pktdata->key->packet_send_dest->sub_term->has_sub_term_uni =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301598 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301599 balIndCfg.pktdata->key->packet_send_dest->sub_term->sub_term_uni =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301600 rx_channel->key.packet_send_dest.u.sub_term.sub_term_uni;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301601 balIndCfg.pktdata->key->packet_send_dest->sub_term->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301602 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301603 balIndCfg.pktdata->key->packet_send_dest->sub_term->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301604 rx_channel->key.packet_send_dest.u.sub_term.intf_id;
1605 }
1606 break;
1607 case BCMBAL_DEST_TYPE_SVC_PORT:
1608 {
1609 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SVC_PORT;
1610 BalDestSvcPort balSvcPort;
1611 memset(&balSvcPort, 0, sizeof(BalDestSvcPort));
1612 bal_dest_svc_port__init(&balSvcPort);
1613 balIndCfg.pktdata->key->packet_send_dest->svc_port = &balSvcPort;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301614 balIndCfg.pktdata->key->packet_send_dest->svc_port->has_svc_port_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301615 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301616 balIndCfg.pktdata->key->packet_send_dest->svc_port->svc_port_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301617 rx_channel->key.packet_send_dest.u.svc_port.svc_port_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301618 balIndCfg.pktdata->key->packet_send_dest->svc_port->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301619 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301620 balIndCfg.pktdata->key->packet_send_dest->svc_port->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301621 rx_channel->key.packet_send_dest.u.svc_port.intf_id;
1622 }
1623 break;
1624 default:
1625 {
1626 balIndCfg.pktdata->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
1627 }
1628 break;
1629 }
1630
1631 BalPacketBearerChannelRxData pkdData;
1632 memset(&pkdData, 0, sizeof(BalPacketBearerChannelRxData));
1633 bal_packet_bearer_channel_rx_data__init(&pkdData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301634 balIndCfg.pktdata->data = &pkdData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301635
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301636 balIndCfg.pktdata->data->has_flow_id = BAL_GRPC_PRES;
1637 balIndCfg.pktdata->data->flow_id = rx_channel->data.flow_id;
1638 balIndCfg.pktdata->data->has_flow_type = BAL_GRPC_PRES;
1639 balIndCfg.pktdata->data->flow_type = rx_channel->data.flow_type;
1640 balIndCfg.pktdata->data->has_intf_id = BAL_GRPC_PRES;
1641 balIndCfg.pktdata->data->intf_id = rx_channel->data.intf_id;
1642 balIndCfg.pktdata->data->has_intf_type = BAL_GRPC_PRES;
1643 balIndCfg.pktdata->data->intf_type = rx_channel->data.intf_type;
1644 balIndCfg.pktdata->data->has_svc_port = BAL_GRPC_PRES;
1645 balIndCfg.pktdata->data->svc_port = rx_channel->data.svc_port;
1646 balIndCfg.pktdata->data->has_flow_cookie = BAL_GRPC_PRES;
1647 balIndCfg.pktdata->data->flow_cookie = rx_channel->data.flow_cookie;
1648 balIndCfg.pktdata->data->has_pkt = BAL_GRPC_PRES;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301649 balIndCfg.pktdata->data->pkt.len = rx_channel->data.pkt.len;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301650 balIndCfg.pktdata->data->pkt.data = (uint8_t *)malloc((balIndCfg.pktdata->data->pkt.len)*sizeof(uint8_t));
1651 memcpy(balIndCfg.pktdata->data->pkt.data, rx_channel->data.pkt.val, balIndCfg.pktdata->data->pkt.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301652
1653 /*bcmos_mutex_unlock(&bal_ind_lock);-- Need to define bcm independent mutex*/
1654
1655 BalErr *output;
1656 result = bal_ind__bal_pkt_bearer_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1657 }
1658
1659 return result;
1660}
1661
1662/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301663 * Function : bal_omci_data_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301664 * Description : This function will handle the indications for *
1665 * OMCI Data Response *
1666 * *
1667 ********************************************************************/
1668bcmos_errno bal_omci_data_indication_cb(bcmbal_obj *obj)
1669{
1670 bcmos_errno result = BCM_ERR_OK;
1671
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301672 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301673 bcmbal_packet_auto_id_itu_omci_channel_rx != obj->subgroup)
1674 {
1675 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1676 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1677 result = BCM_ERR_INTERNAL;
1678 }
1679 else
1680 {
1681 ASFVOLT_LOG(ASFVOLT_DEBUG, "Received OMCI response via BAL APIs\n");
1682 BalIndications balIndCfg;
1683 memset(&balIndCfg, 0, sizeof(BalIndications));
1684 bal_indications__init(&balIndCfg);
1685 balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OMCI_RESP;
1686 balIndCfg.has_objtype = BAL_GRPC_PRES;
1687 balIndCfg.objtype = obj->obj_type;
1688 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1689 balIndCfg.sub_group = obj->subgroup;
1690 balIndCfg.device_id = voltha_device_id;
1691
1692 BalPacketItuOmciChannelRx omciChannel;
1693 memset(&omciChannel, 0, sizeof(BalPacketItuOmciChannelRx));
1694 bal_packet_itu_omci_channel_rx__init(&omciChannel);
1695 balIndCfg.balomciresp = &omciChannel;
1696
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301697 BalObj hdr;
1698 memset(&hdr, 0, sizeof(BalObj));
1699 bal_obj__init(&hdr);
1700 balIndCfg.balomciresp->hdr = &hdr;
1701
1702 BalPacketKey packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301703 memset(&packetkey, 0, sizeof(BalPacketKey));
1704 bal_packet_key__init(&packetkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301705 balIndCfg.balomciresp->key = &packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301706
1707 BalPacketItuOmciChannelRxData omciData;
1708 memset(&omciData, 0, sizeof(BalPacketItuOmciChannelRxData));
1709 bal_packet_itu_omci_channel_rx_data__init(&omciData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301710 balIndCfg.balomciresp->data = &omciData;
1711
1712 bcmbal_packet_itu_omci_channel_rx *omci_channel =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301713 (bcmbal_packet_itu_omci_channel_rx *)obj;
1714
1715 balIndCfg.balomciresp->data->has_pkt = BAL_GRPC_PRES;
1716 balIndCfg.balomciresp->data->pkt.len = omci_channel->data.pkt.len;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301717 balIndCfg.balomciresp->data->pkt.data = (uint8_t *)malloc((omci_channel->data.pkt.len)*sizeof(uint8_t));
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301718 memcpy(balIndCfg.balomciresp->data->pkt.data, omci_channel->data.pkt.val,
1719 balIndCfg.balomciresp->data->pkt.len);
1720
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301721 balIndCfg.balomciresp->key->has_reserved = BAL_GRPC_PRES;
1722 balIndCfg.balomciresp->key->reserved = omci_channel->key.reserved;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301723
1724 BalDest PktSndDest;
1725 memset(&PktSndDest, 0, sizeof(BalDest));
1726 bal_dest__init(&PktSndDest);
1727 balIndCfg.balomciresp->key->packet_send_dest = &PktSndDest;
1728
1729 balIndCfg.balomciresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301730 balIndCfg.balomciresp->key->packet_send_dest->type =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301731 omci_channel->key.packet_send_dest.type;
1732 switch( omci_channel->key.packet_send_dest.type)
1733 {
1734 case BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL:
1735 {
1736 balIndCfg.balomciresp->key->packet_send_dest->u_case = BAL_DEST__U_ITU_OMCI_CHANNEL;
1737 BalItuOmciChannel balOmci;
1738 memset(&balOmci, 0, sizeof(BalItuOmciChannel));
1739 bal_itu_omci_channel__init(&balOmci);
1740 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel = &balOmci;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301741 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->has_sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301742 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301743 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301744 omci_channel->key.packet_send_dest.u.itu_omci_channel.sub_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301745 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301746 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301747 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301748 omci_channel->key.packet_send_dest.u.itu_omci_channel.intf_id;
1749 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d\n",
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301750 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301751 }
1752 break;
1753 default:
1754 {
1755 balIndCfg.balomciresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
1756 }
1757 break;
1758 }
1759
1760 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response with %zd bytes is \n",balIndCfg.balomciresp->data->pkt.len);
1761 uint16_t idx;
1762 for(idx=0; idx<balIndCfg.balomciresp->data->pkt.len; idx++)
1763 {
1764 printf("%02x", balIndCfg.balomciresp->data->pkt.data[idx]);
1765 }
1766 printf("\n");
1767 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d\n",
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301768 balIndCfg.balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301769 BalErr *output;
1770 result = bal_ind__bal_pkt_omci_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1771 }
1772
1773 return result;
1774}
1775
1776/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301777 * Function : bal_oam_data_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301778 * Description : This function will handle the indications for *
1779 * OAM Data Response *
1780 * *
1781 ********************************************************************/
1782bcmos_errno bal_oam_data_indication_cb(bcmbal_obj *obj)
1783{
1784 bcmos_errno result = BCM_ERR_OK;
1785
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301786 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301787 bcmbal_packet_auto_id_ieee_oam_channel_rx != obj->subgroup)
1788 {
1789 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)\n",
1790 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1791 result = BCM_ERR_INTERNAL;
1792 }
1793 else
1794 {
1795 BalIndications balIndCfg;
1796 memset(&balIndCfg, 0, sizeof(BalIndications));
1797 bal_indications__init(&balIndCfg);
1798 balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OAM_RESP;
1799 balIndCfg.has_objtype = BAL_GRPC_PRES;
1800 balIndCfg.objtype = obj->obj_type;
1801 balIndCfg.has_sub_group = BAL_GRPC_PRES;
1802 balIndCfg.sub_group = obj->subgroup;
1803 balIndCfg.device_id = voltha_device_id;
1804
1805 BalPacketIeeeOamChannelRx oamChannel;
1806 memset(&oamChannel, 0, sizeof(BalPacketIeeeOamChannelRx));
1807 bal_packet_ieee_oam_channel_rx__init(&oamChannel);
1808 balIndCfg.baloamresp = &oamChannel;
1809
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301810 BalObj hdr;
1811 memset(&hdr, 0, sizeof(BalObj));
1812 bal_obj__init(&hdr);
1813 balIndCfg.baloamresp->hdr = &hdr;
1814
1815 BalPacketKey packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301816 memset(&packetkey, 0, sizeof(BalPacketKey));
1817 bal_packet_key__init(&packetkey);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301818 balIndCfg.baloamresp->key = &packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301819
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301820 bcmbal_packet_ieee_oam_channel_rx *oam_channel =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301821 (bcmbal_packet_ieee_oam_channel_rx *)obj;
1822
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301823 balIndCfg.baloamresp->key->has_reserved = BAL_GRPC_PRES;
1824 balIndCfg.baloamresp->key->reserved = oam_channel->key.reserved;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301825
1826 BalDest PktSndDest;
1827 memset(&PktSndDest, 0, sizeof(BalDest));
1828 bal_dest__init(&PktSndDest);
1829 balIndCfg.baloamresp->key->packet_send_dest = &PktSndDest;
1830
1831 balIndCfg.baloamresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301832 balIndCfg.baloamresp->key->packet_send_dest->type =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301833 oam_channel->key.packet_send_dest.type;
1834 switch( oam_channel->key.packet_send_dest.type)
1835 {
1836 case BCMBAL_DEST_TYPE_IEEE_OAM_CHANNEL:
1837 {
1838 balIndCfg.baloamresp->key->packet_send_dest->u_case = BAL_DEST__U_IEEE_OAM_CHANNEL;
1839 BalIeeeOamChannel balOam;
1840 memset(&balOam, 0, sizeof(BalIeeeOamChannel));
1841 bal_ieee_oam_channel__init(&balOam);
1842 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel = &balOam;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301843 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301844 BAL_GRPC_PRES;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301845 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301846 oam_channel->key.packet_send_dest.u.ieee_oam_channel.intf_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301847 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->has_mac_address = BAL_GRPC_PRES;
1848 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301849 (BCMOS_ETH_ALEN)*sizeof(oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301850 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.data =
1851 (uint8_t *)malloc((balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len)*sizeof(uint8_t));
1852 memcpy(balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.data,
1853 oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301854 balIndCfg.baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len);
1855
1856 }
1857 break;
1858 default:
1859 {
1860 balIndCfg.baloamresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
1861 }
1862 break;
1863 }
1864
1865 BalPacketIeeeOamChannelRxData oamData;
1866 memset(&oamData, 0, sizeof(BalPacketIeeeOamChannelRxData));
1867 bal_packet_ieee_oam_channel_rx_data__init(&oamData);
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301868 balIndCfg.baloamresp->data = &oamData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301869
1870 balIndCfg.baloamresp->data->pkt.len = oam_channel->data.pkt.len;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301871 balIndCfg.baloamresp->data->pkt.data = (uint8_t *)malloc((balIndCfg.baloamresp->data->pkt.len)*sizeof(uint8_t));
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301872 memcpy(balIndCfg.baloamresp->data->pkt.data, oam_channel->data.pkt.val,
1873 balIndCfg.baloamresp->data->pkt.len);
1874
1875 BalErr *output;
1876 result = bal_ind__bal_pkt_ieee_oam_channel_rx_ind(client, NULL, &balIndCfg, &output, NULL, 0);
1877
1878 }
1879
1880 return result;
1881}