blob: a633b0ddaf89617da8bb9bfa3ea21ea07194d787 [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"
VoLTHA753536e2017-11-02 20:15:09 +053018#include "bal_indications_queue.h"
19
20/*global variables*/
21
22/*extern variables*/
23
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053024
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053025/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +053026 * Function : bal_acc_term_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053027 * Description : This function will handle the indications for *
28 * Access Terminal Operational State Change *
29 * *
30 ********************************************************************/
31bcmos_errno bal_acc_term_osc_indication_cb(bcmbal_obj *obj)
32{
33 bcmos_errno result = BCM_ERR_OK;
34
Rajeswara Raob2e441c2017-09-20 16:40:21 +053035 if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053036 bcmbal_access_terminal_auto_id_oper_status_change != obj->subgroup)
37 {
Kim Kempfafa1ab42017-11-13 09:31:47 -080038 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053039 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
40 result = BCM_ERR_INTERNAL;
41 }
42 else
43 {
VoLTHA753536e2017-11-02 20:15:09 +053044 BalIndications *balIndCfg;
45 balIndCfg = malloc(sizeof(BalIndications));
46 memset(balIndCfg, 0, sizeof(BalIndications));
47 bal_indications__init(balIndCfg);
48 balIndCfg->has_objtype = BAL_GRPC_PRES;
49 balIndCfg->objtype = obj->obj_type;
50 balIndCfg->has_sub_group = BAL_GRPC_PRES;
51 balIndCfg->sub_group = obj->subgroup;
52 balIndCfg->u_case = BAL_INDICATIONS__U_ACCESS_TERM_IND_OP_STATE;
53 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053054
Rajeswara Raob2e441c2017-09-20 16:40:21 +053055 bcmbal_access_terminal_oper_status_change *acc_term_osc =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053056 (bcmbal_access_terminal_oper_status_change *)obj;
57
VoLTHA753536e2017-11-02 20:15:09 +053058 BalAccessTerminalOperStatusChange *acessTermOSC;
59 acessTermOSC = malloc(sizeof(BalAccessTerminalOperStatusChange));
60 memset(acessTermOSC, 0, sizeof(BalAccessTerminalOperStatusChange));
61 bal_access_terminal_oper_status_change__init(acessTermOSC);
62 balIndCfg->access_term_ind_op_state = acessTermOSC;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053063
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070064 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +053065
VoLTHA753536e2017-11-02 20:15:09 +053066 BalAccessTerminalKey *accessTermkey;
67 accessTermkey = malloc(sizeof(BalAccessTerminalKey));
68 memset(accessTermkey, 0, sizeof(BalAccessTerminalKey));
69 bal_access_terminal_key__init(accessTermkey);
70 balIndCfg->access_term_ind_op_state->key = accessTermkey;
71 balIndCfg->access_term_ind_op_state->key->has_access_term_id = BAL_GRPC_PRES;
72 balIndCfg->access_term_ind_op_state->key->access_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053073 acc_term_osc->key.access_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +053074
VoLTHA753536e2017-11-02 20:15:09 +053075 BalAccessTerminalOperStatusChangeData *accessTermOscData;
76 accessTermOscData = malloc(sizeof(BalAccessTerminalOperStatusChangeData));
77 memset(accessTermOscData, 0, sizeof(BalAccessTerminalOperStatusChangeData));
78 bal_access_terminal_oper_status_change_data__init(accessTermOscData);
79 balIndCfg->access_term_ind_op_state->data = accessTermOscData;
80 balIndCfg->access_term_ind_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
81 balIndCfg->access_term_ind_op_state->data->new_oper_status =
Rajeswara Raob2e441c2017-09-20 16:40:21 +053082 acc_term_osc->data.new_oper_status;
VoLTHA753536e2017-11-02 20:15:09 +053083 balIndCfg->access_term_ind_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
84 balIndCfg->access_term_ind_op_state->data->old_oper_status =
Rajeswara Raob2e441c2017-09-20 16:40:21 +053085 acc_term_osc->data.old_oper_status;
VoLTHA753536e2017-11-02 20:15:09 +053086 balIndCfg->access_term_ind_op_state->data->has_admin_state = BAL_GRPC_PRES;
87 balIndCfg->access_term_ind_op_state->data->admin_state =
Rajeswara Raob2e441c2017-09-20 16:40:21 +053088 acc_term_osc->data.admin_state;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053089
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070090 bal_register_indication_cbs();
91
92 list_node *bal_indication_node = malloc(sizeof(list_node));
93 bal_indication_node->bal_indication = balIndCfg;
94
95 pthread_mutex_lock(&bal_ind_queue_lock);
96 add_bal_indication_node(bal_indication_node);
97 pthread_mutex_unlock(&bal_ind_queue_lock);
98 is_reboot = BAL_REBOOT_STATUS__BAL_OLT_UP_AFTER_ACTIVATION;
99 }
100
101 return result;
102}
103
104/********************************************************************\
105 * Function : bal_acc_term_processing_error_indication_cb *
106 * Description : This function will handle the error indications *
107 * for Access Terminal *
108 * *
109 ********************************************************************/
110bcmos_errno bal_acc_term_processing_error_indication_cb(bcmbal_obj *obj)
111{
112 bcmos_errno result = BCM_ERR_OK;
113
114 if(BCMBAL_OBJ_ID_ACCESS_TERMINAL != obj->obj_type ||
115 bcmbal_access_terminal_auto_id_processing_error != obj->subgroup)
116 {
117 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
118 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
119 result = BCM_ERR_INTERNAL;
120 }
121 else
122 {
123 BalIndications *balIndCfg;
124 balIndCfg = malloc(sizeof(BalIndications));
125 memset(balIndCfg, 0, sizeof(BalIndications));
126 bal_indications__init(balIndCfg);
127 balIndCfg->has_objtype = BAL_GRPC_PRES;
128 balIndCfg->objtype = obj->obj_type;
129 balIndCfg->has_sub_group = BAL_GRPC_PRES;
130 balIndCfg->sub_group = obj->subgroup;
131 balIndCfg->u_case = BAL_INDICATIONS__U_ACCESS_TERM_PROC_ERR;
132 balIndCfg->device_id = voltha_device_id;
133
134 bcmbal_access_terminal_processing_error *acc_term_err =
135 (bcmbal_access_terminal_processing_error *)obj;
136
137 BalAccessTerminalProcessingError *acessTermError;
138 acessTermError = malloc(sizeof(BalAccessTerminalProcessingError));
139 memset(acessTermError, 0, sizeof(BalAccessTerminalProcessingError));
140 bal_access_terminal_processing_error__init(acessTermError);
141 balIndCfg->access_term_proc_err = acessTermError;
142
143 /*'hdr' field is not parsed by voltha adapter, hence not filled */
144
145 BalAccessTerminalKey *accessTermkey;
146 accessTermkey = malloc(sizeof(BalAccessTerminalKey));
147 memset(accessTermkey, 0, sizeof(BalAccessTerminalKey));
148 bal_access_terminal_key__init(accessTermkey);
149 balIndCfg->access_term_proc_err->key = accessTermkey;
150 balIndCfg->access_term_proc_err->key->has_access_term_id = BAL_GRPC_PRES;
151 balIndCfg->access_term_proc_err->key->access_term_id =
152 acc_term_err->key.access_term_id;
153
VoLTHA753536e2017-11-02 20:15:09 +0530154 list_node *bal_indication_node = malloc(sizeof(list_node));
155 bal_indication_node->bal_indication = balIndCfg;
156
157 pthread_mutex_lock(&bal_ind_queue_lock);
158 add_bal_indication_node(bal_indication_node);
159 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530160 }
161
162 return result;
163}
164
165/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530166 * Function : bal_flow_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530167 * Description : This function will handle the indications for *
168 * Flow Operational State Change *
169 * *
170 ********************************************************************/
171bcmos_errno bal_flow_osc_indication_cb(bcmbal_obj *obj)
172{
173 bcmos_errno result = BCM_ERR_OK;
174
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530175 if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530176 bcmbal_flow_auto_id_oper_status_change != obj->subgroup)
177 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800178 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530179 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
180 result = BCM_ERR_INTERNAL;
181 }
182 else
183 {
VoLTHA753536e2017-11-02 20:15:09 +0530184 BalIndications *balIndCfg;
185 balIndCfg = malloc(sizeof(BalIndications));
186 memset(balIndCfg, 0, sizeof(BalIndications));
187 bal_indications__init(balIndCfg);
188 balIndCfg->u_case = BAL_INDICATIONS__U_FLOW_OP_STATE;
189 balIndCfg->has_objtype = BAL_GRPC_PRES;
190 balIndCfg->objtype = obj->obj_type;
191 balIndCfg->has_sub_group = BAL_GRPC_PRES;
192 balIndCfg->sub_group = obj->subgroup;
193 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530194
195 bcmbal_flow_oper_status_change *flow_osc = (bcmbal_flow_oper_status_change *)obj;
196
VoLTHA753536e2017-11-02 20:15:09 +0530197 BalFlowOperStatusChange *flowOscInd;
198 flowOscInd = malloc(sizeof(BalFlowOperStatusChange));
199 memset(flowOscInd, 0, sizeof(BalFlowOperStatusChange));
200 bal_flow_oper_status_change__init(flowOscInd);
201 balIndCfg->flow_op_state = flowOscInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530202
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700203 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530204
VoLTHA753536e2017-11-02 20:15:09 +0530205 BalFlowKey *flowkey;
206 flowkey = malloc(sizeof(BalFlowKey));
207 memset(flowkey, 0, sizeof(BalFlowKey));
208 bal_flow_key__init(flowkey);
209 balIndCfg->flow_op_state->key = flowkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530210
VoLTHA753536e2017-11-02 20:15:09 +0530211 balIndCfg->flow_op_state->key->has_flow_id = BAL_GRPC_PRES;
212 balIndCfg->flow_op_state->key->flow_id = flow_osc->key.flow_id;
213 balIndCfg->flow_op_state->key->has_flow_type = BAL_GRPC_PRES;
214 balIndCfg->flow_op_state->key->flow_type = flow_osc->key.flow_type;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530215
VoLTHA753536e2017-11-02 20:15:09 +0530216 BalFlowOperStatusChangeData *flowOscIndData;
217 flowOscIndData = malloc(sizeof(BalFlowOperStatusChangeData));
218 memset(flowOscIndData, 0, sizeof(BalFlowOperStatusChangeData));
219 bal_flow_oper_status_change_data__init(flowOscIndData);
220 balIndCfg->flow_op_state->data = flowOscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530221
VoLTHA753536e2017-11-02 20:15:09 +0530222 balIndCfg->flow_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
223 balIndCfg->flow_op_state->data->new_oper_status = flow_osc->data.new_oper_status;
224 balIndCfg->flow_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
225 balIndCfg->flow_op_state->data->old_oper_status = flow_osc->data.old_oper_status;
226 balIndCfg->flow_op_state->data->has_admin_state = BAL_GRPC_PRES;
227 balIndCfg->flow_op_state->data->admin_state = flow_osc->data.admin_state;
228 balIndCfg->flow_op_state->data->has_svc_port_id = BAL_GRPC_PRES;
229 balIndCfg->flow_op_state->data->svc_port_id = flow_osc->data.svc_port_id;
230 balIndCfg->flow_op_state->data->has_dba_tm_sched_id = BAL_GRPC_PRES;
231 balIndCfg->flow_op_state->data->dba_tm_sched_id = flow_osc->data.dba_tm_sched_id;
232 balIndCfg->flow_op_state->data->has_cookie = BAL_GRPC_PRES;
233 balIndCfg->flow_op_state->data->cookie = flow_osc->data.cookie;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530234
VoLTHA753536e2017-11-02 20:15:09 +0530235 list_node *bal_indication_node = malloc(sizeof(list_node));
236 bal_indication_node->bal_indication = balIndCfg;
237
238 pthread_mutex_lock(&bal_ind_queue_lock);
239 add_bal_indication_node(bal_indication_node);
240 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530241 }
242
243 return result;
244}
245
246/********************************************************************\
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700247 * Function : bal_flow_processing_error_indication_cb *
248 * Description : This function will handle flow processing errors *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530249 * *
250 ********************************************************************/
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700251bcmos_errno bal_flow_processing_error_indication_cb(bcmbal_obj *obj)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530252{
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700253 bcmos_errno result = BCM_ERR_OK;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530254
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530255 if(BCMBAL_OBJ_ID_FLOW != obj->obj_type ||
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700256 bcmbal_flow_auto_id_processing_error != obj->subgroup)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530257 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800258 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530259 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
260 result = BCM_ERR_INTERNAL;
261 }
262 else
263 {
VoLTHA753536e2017-11-02 20:15:09 +0530264 BalIndications *balIndCfg;
265 balIndCfg = malloc(sizeof(BalIndications));
266 memset(balIndCfg, 0, sizeof(BalIndications));
267 bal_indications__init(balIndCfg);
VoLTHA753536e2017-11-02 20:15:09 +0530268 balIndCfg->has_objtype = BAL_GRPC_PRES;
269 balIndCfg->objtype = obj->obj_type;
270 balIndCfg->has_sub_group = BAL_GRPC_PRES;
271 balIndCfg->sub_group = obj->subgroup;
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700272 balIndCfg->u_case = BAL_INDICATIONS__U_FLOW_PROC_ERR;
VoLTHA753536e2017-11-02 20:15:09 +0530273 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530274
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700275 bcmbal_flow_processing_error *flow_proc_error =
276 (bcmbal_flow_processing_error *)obj;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530277
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700278 BalFlowProcessingError *flowProcError;
279 flowProcError = malloc(sizeof(BalFlowProcessingError));
280 memset(flowProcError, 0, sizeof(BalFlowProcessingError));
281 bal_flow_processing_error__init(flowProcError);
282 balIndCfg->flow_proc_err = flowProcError;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530283
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700284 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530285
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700286 BalFlowKey *flowKey;
287 flowKey = malloc(sizeof(BalFlowKey));
288 memset(flowKey, 0, sizeof(BalFlowKey));
289 bal_flow_key__init(flowKey);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530290
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700291 balIndCfg->flow_proc_err->key = flowKey;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530292
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700293 balIndCfg->flow_proc_err->key->has_flow_id = BAL_GRPC_PRES;
294 balIndCfg->flow_proc_err->key->flow_id =
295 flow_proc_error->key.flow_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530296
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700297 balIndCfg->flow_proc_err->key->has_flow_type = BAL_GRPC_PRES;
298 balIndCfg->flow_proc_err->key->flow_type =
299 flow_proc_error->key.flow_type;
VoLTHA753536e2017-11-02 20:15:09 +0530300
301 list_node *bal_indication_node = malloc(sizeof(list_node));
302 bal_indication_node->bal_indication = balIndCfg;
303
304 pthread_mutex_lock(&bal_ind_queue_lock);
305 add_bal_indication_node(bal_indication_node);
306 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530307 }
308
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700309
310 return result;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530311}
312
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530313
314/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530315 * Function : bal_interface_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530316 * Description : This function will handle the indications for *
317 * Interface Operational State Change *
318 * *
319 ********************************************************************/
320bcmos_errno bal_interface_osc_indication_cb(bcmbal_obj *obj)
321{
322 bcmos_errno result = BCM_ERR_OK;
323
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530324 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530325 bcmbal_interface_auto_id_oper_status_change != obj->subgroup)
326 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800327 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530328 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
329 result = BCM_ERR_INTERNAL;
330 }
331 else
332 {
VoLTHA753536e2017-11-02 20:15:09 +0530333 BalIndications *balIndCfg;
334 balIndCfg = malloc(sizeof(BalIndications));
335 memset(balIndCfg, 0, sizeof(BalIndications));
336 bal_indications__init(balIndCfg);
337 balIndCfg->u_case = BAL_INDICATIONS__U_INTERFACE_OP_STATE;
338 balIndCfg->has_objtype = BAL_GRPC_PRES;
339 balIndCfg->objtype = obj->obj_type;
340 balIndCfg->has_sub_group = BAL_GRPC_PRES;
341 balIndCfg->sub_group = obj->subgroup;
342 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530343
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530344 bcmbal_interface_oper_status_change *int_osc_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530345 (bcmbal_interface_oper_status_change *)obj;
346
VoLTHA753536e2017-11-02 20:15:09 +0530347 BalInterfaceOperStatusChange *ifOsc;
348 ifOsc = malloc(sizeof(BalInterfaceOperStatusChange));
349 memset(ifOsc, 0, sizeof(BalInterfaceOperStatusChange));
350 bal_interface_oper_status_change__init(ifOsc);
351 balIndCfg->interface_op_state = ifOsc;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530352
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700353 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530354
VoLTHA753536e2017-11-02 20:15:09 +0530355 BalInterfaceKey *ifkey;
356 ifkey = malloc(sizeof(BalInterfaceKey));
357 memset(ifkey, 0, sizeof(BalInterfaceKey));
358 bal_interface_key__init(ifkey);
359 balIndCfg->interface_op_state->key = ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530360
VoLTHA753536e2017-11-02 20:15:09 +0530361 balIndCfg->interface_op_state->key->has_intf_id = BAL_GRPC_PRES;
362 balIndCfg->interface_op_state->key->intf_id = int_osc_ind->key.intf_id;
363 balIndCfg->interface_op_state->key->has_intf_type = BAL_GRPC_PRES;
364 balIndCfg->interface_op_state->key->intf_type = int_osc_ind->key.intf_type;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530365
VoLTHA753536e2017-11-02 20:15:09 +0530366 BalInterfaceOperStatusChangeData *ifOscIndData;
367 ifOscIndData = malloc(sizeof(BalInterfaceOperStatusChangeData));
368 memset(ifOscIndData, 0, sizeof(BalInterfaceOperStatusChangeData));
369 bal_interface_oper_status_change_data__init(ifOscIndData);
370 balIndCfg->interface_op_state->data = ifOscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530371
VoLTHA753536e2017-11-02 20:15:09 +0530372 balIndCfg->interface_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
373 balIndCfg->interface_op_state->data->new_oper_status = int_osc_ind->data.new_oper_status;
374 balIndCfg->interface_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
375 balIndCfg->interface_op_state->data->old_oper_status = int_osc_ind->data.old_oper_status;
376 balIndCfg->interface_op_state->data->has_admin_state = BAL_GRPC_PRES;
377 balIndCfg->interface_op_state->data->admin_state = int_osc_ind->data.admin_state;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530378
VoLTHA753536e2017-11-02 20:15:09 +0530379 list_node *bal_indication_node = malloc(sizeof(list_node));
380 bal_indication_node->bal_indication = balIndCfg;
381
382 pthread_mutex_lock(&bal_ind_queue_lock);
383 add_bal_indication_node(bal_indication_node);
384 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530385 }
386
387 return result;
388}
389
390/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530391 * Function : bal_interface_los_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530392 * Description : This function will handle the indications for *
393 * Interface los Indication *
394 * *
395 ********************************************************************/
396bcmos_errno bal_interface_los_indication_cb(bcmbal_obj *obj)
397{
398 bcmos_errno result = BCM_ERR_OK;
399
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530400 if(BCMBAL_OBJ_ID_INTERFACE != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530401 bcmbal_interface_auto_id_los != obj->subgroup)
402 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800403 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530404 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
405 result = BCM_ERR_INTERNAL;
406 }
407 else
408 {
VoLTHA753536e2017-11-02 20:15:09 +0530409 BalIndications *balIndCfg;
410 balIndCfg = malloc(sizeof(BalIndications));
411 memset(balIndCfg, 0, sizeof(BalIndications));
412 bal_indications__init(balIndCfg);
413 balIndCfg->u_case = BAL_INDICATIONS__U_INTERFACE_LOS;
414 balIndCfg->has_objtype = BAL_GRPC_PRES;
415 balIndCfg->objtype = obj->obj_type;
416 balIndCfg->has_sub_group = BAL_GRPC_PRES;
417 balIndCfg->sub_group = obj->subgroup;
418 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530419
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530420 bcmbal_interface_los *int_los_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530421 (bcmbal_interface_los *)obj;
422
VoLTHA753536e2017-11-02 20:15:09 +0530423 BalInterfaceLos *ifLos;
424 ifLos = malloc(sizeof(BalInterfaceLos));
425 memset(ifLos, 0, sizeof(BalInterfaceLos));
426 bal_interface_los__init(ifLos);
427 balIndCfg->interface_los = ifLos;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530428
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700429 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530430
VoLTHA753536e2017-11-02 20:15:09 +0530431 BalInterfaceKey *ifkey;
432 ifkey = malloc(sizeof(BalInterfaceKey));
433 memset(ifkey, 0, sizeof(BalInterfaceKey));
434 bal_interface_key__init(ifkey);
435 balIndCfg->interface_los->key = ifkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530436
VoLTHA753536e2017-11-02 20:15:09 +0530437 balIndCfg->interface_los->key->has_intf_id = BAL_GRPC_PRES;
438 balIndCfg->interface_los->key->intf_id = int_los_ind->key.intf_id;
439 balIndCfg->interface_los->key->has_intf_type = BAL_GRPC_PRES;
440 balIndCfg->interface_los->key->intf_type = int_los_ind->key.intf_type;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530441
VoLTHA753536e2017-11-02 20:15:09 +0530442 BalInterfaceLosData *ifLosIndData;
443 ifLosIndData = malloc(sizeof(BalInterfaceLosData));
444 memset(ifLosIndData, 0, sizeof(BalInterfaceLosData));
445 bal_interface_los_data__init(ifLosIndData);
446 balIndCfg->interface_los->data = ifLosIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530447
VoLTHA753536e2017-11-02 20:15:09 +0530448 balIndCfg->interface_los->data->has_status = BAL_GRPC_PRES;
449 balIndCfg->interface_los->data->status = int_los_ind->data.status;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530450
VoLTHA753536e2017-11-02 20:15:09 +0530451 list_node *bal_indication_node = malloc(sizeof(list_node));
452 bal_indication_node->bal_indication = balIndCfg;
453
454 pthread_mutex_lock(&bal_ind_queue_lock);
455 add_bal_indication_node(bal_indication_node);
456 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530457 }
458
459 return result;
460}
461
462/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530463 * Function : bal_sub_term_osc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530464 * Description : This function will handle the indications for *
465 * Subscriber term Operational State Change *
466 * *
467 ********************************************************************/
468bcmos_errno bal_sub_term_osc_indication_cb(bcmbal_obj *obj)
469{
470 bcmos_errno result = BCM_ERR_OK;
471
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530472 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530473 bcmbal_subscriber_terminal_auto_id_oper_status_change != obj->subgroup)
474 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800475 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530476 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
477 result = BCM_ERR_INTERNAL;
478 }
479 else
480 {
VoLTHA753536e2017-11-02 20:15:09 +0530481 BalIndications *balIndCfg;
482 balIndCfg = malloc(sizeof(BalIndications));
483 memset(balIndCfg, 0, sizeof(BalIndications));
484 bal_indications__init(balIndCfg);
485 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_OP_STATE;
486 balIndCfg->has_objtype = BAL_GRPC_PRES;
487 balIndCfg->objtype = obj->obj_type;
488 balIndCfg->has_sub_group = BAL_GRPC_PRES;
489 balIndCfg->sub_group = obj->subgroup;
490 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530491
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530492 bcmbal_subscriber_terminal_oper_status_change *sub_osc_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530493 (bcmbal_subscriber_terminal_oper_status_change *)obj;
494
VoLTHA753536e2017-11-02 20:15:09 +0530495 BalSubscriberTerminalOperStatusChange *subOscInd;
496 subOscInd = malloc(sizeof(BalSubscriberTerminalOperStatusChange));
497 memset(subOscInd, 0, sizeof(BalSubscriberTerminalOperStatusChange));
498 bal_subscriber_terminal_oper_status_change__init(subOscInd);
499 balIndCfg->terminal_op_state = subOscInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530500
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700501 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530502
VoLTHA753536e2017-11-02 20:15:09 +0530503 BalSubscriberTerminalKey *subkey;
504 subkey = malloc(sizeof(BalSubscriberTerminalKey));
505 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
506 bal_subscriber_terminal_key__init(subkey);
507 balIndCfg->terminal_op_state->key = subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530508
VoLTHA753536e2017-11-02 20:15:09 +0530509 balIndCfg->terminal_op_state->key->has_intf_id = BAL_GRPC_PRES;
510 balIndCfg->terminal_op_state->key->intf_id = sub_osc_ind->key.intf_id;
511 balIndCfg->terminal_op_state->key->has_sub_term_id = BAL_GRPC_PRES;
512 balIndCfg->terminal_op_state->key->sub_term_id = sub_osc_ind->key.sub_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530513
VoLTHA753536e2017-11-02 20:15:09 +0530514 BalSubscriberTerminalOperStatusChangeData *subOscIndData;
515 subOscIndData = malloc(sizeof(BalSubscriberTerminalOperStatusChangeData));
516 memset(subOscIndData, 0, sizeof(BalSubscriberTerminalOperStatusChangeData));
517 bal_subscriber_terminal_oper_status_change_data__init(subOscIndData);
518 balIndCfg->terminal_op_state->data = subOscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530519
VoLTHA753536e2017-11-02 20:15:09 +0530520 balIndCfg->terminal_op_state->data->has_new_oper_status = BAL_GRPC_PRES;
521 balIndCfg->terminal_op_state->data->new_oper_status =
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530522 sub_osc_ind->data.new_oper_status;
VoLTHA753536e2017-11-02 20:15:09 +0530523 balIndCfg->terminal_op_state->data->has_old_oper_status = BAL_GRPC_PRES;
524 balIndCfg->terminal_op_state->data->old_oper_status =
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530525 sub_osc_ind->data.old_oper_status;
VoLTHA753536e2017-11-02 20:15:09 +0530526 balIndCfg->terminal_op_state->data->has_admin_state = BAL_GRPC_PRES;
527 balIndCfg->terminal_op_state->data->admin_state =
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530528 sub_osc_ind->data.admin_state;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530529
VoLTHA753536e2017-11-02 20:15:09 +0530530 list_node *bal_indication_node = malloc(sizeof(list_node));
531 bal_indication_node->bal_indication = balIndCfg;
532
533 pthread_mutex_lock(&bal_ind_queue_lock);
534 add_bal_indication_node(bal_indication_node);
535 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530536 }
537
538 return result;
539}
540
541/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530542 * Function : bal_sub_term_disc_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530543 * Description : This function will handle the indications for *
544 * Subscriber term disc indication *
545 * *
546 ********************************************************************/
547bcmos_errno bal_sub_term_disc_indication_cb(bcmbal_obj *obj)
548{
549 bcmos_errno result = BCM_ERR_OK;
550
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530551 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530552 bcmbal_subscriber_terminal_auto_id_sub_term_disc != obj->subgroup)
553 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800554 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530555 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
556 result = BCM_ERR_INTERNAL;
557 }
558 else
559 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800560 ASFVOLT_LOG(ASFVOLT_DEBUG, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530561 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
VoLTHA753536e2017-11-02 20:15:09 +0530562 BalIndications *balIndCfg;
563 balIndCfg = malloc(sizeof(BalIndications));
564 memset(balIndCfg, 0, sizeof(BalIndications));
565 bal_indications__init(balIndCfg);
566 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_DISC;
567 balIndCfg->has_objtype = BAL_GRPC_PRES;
568 balIndCfg->objtype = obj->obj_type;
569 balIndCfg->has_sub_group = BAL_GRPC_PRES;
570 balIndCfg->sub_group = obj->subgroup;
571 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530572
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530573 bcmbal_subscriber_terminal_sub_term_disc *sub_disc_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530574 (bcmbal_subscriber_terminal_sub_term_disc *)obj;
575
VoLTHA753536e2017-11-02 20:15:09 +0530576 BalSubscriberTerminalSubTermDisc *subDiscInd;
577 subDiscInd = malloc(sizeof(BalSubscriberTerminalSubTermDisc));
578 memset(subDiscInd, 0, sizeof(BalSubscriberTerminalSubTermDisc));
579 bal_subscriber_terminal_sub_term_disc__init(subDiscInd);
580 balIndCfg->terminal_disc = subDiscInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530581
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700582 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530583
VoLTHA753536e2017-11-02 20:15:09 +0530584 BalSubscriberTerminalKey *subkey;
585 subkey = malloc(sizeof(BalSubscriberTerminalKey));
586 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
587 bal_subscriber_terminal_key__init(subkey);
588 balIndCfg->terminal_disc->key = subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530589
VoLTHA753536e2017-11-02 20:15:09 +0530590 balIndCfg->terminal_disc->key->has_intf_id = BAL_GRPC_PRES;
591 balIndCfg->terminal_disc->key->intf_id = sub_disc_ind->key.intf_id;
592 balIndCfg->terminal_disc->key->has_sub_term_id = BAL_GRPC_PRES;
593 balIndCfg->terminal_disc->key->sub_term_id = sub_disc_ind->key.sub_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530594
VoLTHA753536e2017-11-02 20:15:09 +0530595 BalSubscriberTerminalSubTermDiscData *subDiscIndData;
596 subDiscIndData = malloc(sizeof(BalSubscriberTerminalSubTermDiscData));
597 memset(subDiscIndData, 0, sizeof(BalSubscriberTerminalSubTermDiscData));
598 bal_subscriber_terminal_sub_term_disc_data__init(subDiscIndData);
599 balIndCfg->terminal_disc->data = subDiscIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530600
VoLTHA753536e2017-11-02 20:15:09 +0530601 BalSerialNumber *serial_number;
602 serial_number = malloc(sizeof(BalSerialNumber));
603 memset(serial_number, 0, sizeof(BalSerialNumber));
604 bal_serial_number__init(serial_number);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530605
VoLTHA753536e2017-11-02 20:15:09 +0530606 balIndCfg->terminal_disc->data->serial_number = serial_number;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530607
Kim Kempfafa1ab42017-11-13 09:31:47 -0800608 ASFVOLT_LOG(ASFVOLT_INFO, "Discovered ONU serial number "
609 "%c%c%c%c%02X%02X%02X%02X",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530610 sub_disc_ind->data.serial_number.vendor_id[0],
611 sub_disc_ind->data.serial_number.vendor_id[1],
612 sub_disc_ind->data.serial_number.vendor_id[2],
613 sub_disc_ind->data.serial_number.vendor_id[3],
Kim Kempfafa1ab42017-11-13 09:31:47 -0800614 sub_disc_ind->data.serial_number.vendor_specific[0],
615 sub_disc_ind->data.serial_number.vendor_specific[1],
616 sub_disc_ind->data.serial_number.vendor_specific[2],
617 sub_disc_ind->data.serial_number.vendor_specific[3]);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530618
Kim Kempfafa1ab42017-11-13 09:31:47 -0800619 //ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor id is %s", sub_disc_ind->data.serial_number.vendor_id);
620 //ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:Before decoding:Vendor specific is %s", sub_disc_ind->data.serial_number.vendor_specific);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530621
VoLTHA753536e2017-11-02 20:15:09 +0530622 char *vendor_id = malloc(sizeof(char)*MAX_CHAR_LENGTH);
623 memset(vendor_id, 0, MAX_CHAR_LENGTH);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530624 sprintf(vendor_id,"%c%c%c%c",
625 sub_disc_ind->data.serial_number.vendor_id[0],
626 sub_disc_ind->data.serial_number.vendor_id[1],
627 sub_disc_ind->data.serial_number.vendor_id[2],
628 sub_disc_ind->data.serial_number.vendor_id[3]);
VoLTHA753536e2017-11-02 20:15:09 +0530629 balIndCfg->terminal_disc->data->serial_number->vendor_id = vendor_id;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800630 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor id is %s", balIndCfg->terminal_disc->data->serial_number->vendor_id);
VoLTHA753536e2017-11-02 20:15:09 +0530631 char *vendor_specific = malloc(sizeof(char)*MAX_CHAR_LENGTH);
632 memset(vendor_specific, 0, MAX_CHAR_LENGTH);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530633 sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
634 sub_disc_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f,
635 sub_disc_ind->data.serial_number.vendor_specific[0] & 0x0f,
636 sub_disc_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f,
637 sub_disc_ind->data.serial_number.vendor_specific[1] & 0x0f,
638 sub_disc_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f,
639 sub_disc_ind->data.serial_number.vendor_specific[2] & 0x0f,
640 sub_disc_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
641 sub_disc_ind->data.serial_number.vendor_specific[3] & 0x0f);
VoLTHA753536e2017-11-02 20:15:09 +0530642 balIndCfg->terminal_disc->data->serial_number->vendor_specific = vendor_specific;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800643 ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Discovery:After decoding:Vendor specific is %s", balIndCfg->terminal_disc->data->serial_number->vendor_specific);
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530644
VoLTHA753536e2017-11-02 20:15:09 +0530645 list_node *bal_indication_node = malloc(sizeof(list_node));
646 bal_indication_node->bal_indication = balIndCfg;
647
648 pthread_mutex_lock(&bal_ind_queue_lock);
649 add_bal_indication_node(bal_indication_node);
650 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530651 }
652
653 return result;
654}
655
656/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530657 * Function : bal_sub_term_alarm_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530658 * Description : This function will handle the indications for *
659 * Subscriber term alarm indication *
660 * *
661 ********************************************************************/
662bcmos_errno bal_sub_term_alarm_indication_cb(bcmbal_obj *obj)
663{
664 bcmos_errno result = BCM_ERR_OK;
665
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530666 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530667 bcmbal_subscriber_terminal_auto_id_sub_term_alarm != obj->subgroup)
668 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800669 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API \'%s\' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530670 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
671 result = BCM_ERR_INTERNAL;
672 }
673 else
674 {
VoLTHA753536e2017-11-02 20:15:09 +0530675 BalIndications *balIndCfg;
676 balIndCfg = malloc(sizeof(BalIndications));
677 memset(balIndCfg, 0, sizeof(BalIndications));
678 bal_indications__init(balIndCfg);
679 balIndCfg->has_objtype = BAL_GRPC_PRES;
680 balIndCfg->objtype = BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL;
681 balIndCfg->has_sub_group = BAL_GRPC_PRES;
682 balIndCfg->sub_group = obj->subgroup;
683 balIndCfg->device_id = voltha_device_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530684
VoLTHA753536e2017-11-02 20:15:09 +0530685 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_ALARM;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530686 bcmbal_subscriber_terminal_sub_term_alarm *sub_term_alarm =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530687 (bcmbal_subscriber_terminal_sub_term_alarm *)obj;
688
VoLTHA753536e2017-11-02 20:15:09 +0530689 BalSubscriberTerminalSubTermAlarm *subTermAlarm;
690 subTermAlarm = malloc(sizeof(BalSubscriberTerminalSubTermAlarm));
691 memset(subTermAlarm, 0, sizeof(BalSubscriberTerminalSubTermAlarm));
692 bal_subscriber_terminal_sub_term_alarm__init(subTermAlarm);
693 balIndCfg->terminal_alarm = subTermAlarm;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530694
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700695 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530696
VoLTHA753536e2017-11-02 20:15:09 +0530697 BalSubscriberTerminalKey *subkey;
698 subkey = malloc(sizeof(BalSubscriberTerminalKey));
699 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
700 bal_subscriber_terminal_key__init(subkey);
701 balIndCfg->terminal_alarm->key = subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530702
VoLTHA753536e2017-11-02 20:15:09 +0530703 balIndCfg->terminal_alarm->key->has_sub_term_id = BAL_GRPC_PRES;
704 balIndCfg->terminal_alarm->key->sub_term_id = sub_term_alarm->key.sub_term_id;
705 balIndCfg->terminal_alarm->key->has_intf_id = BAL_GRPC_PRES;
706 balIndCfg->terminal_alarm->key->intf_id = sub_term_alarm->key.intf_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530707
VoLTHA753536e2017-11-02 20:15:09 +0530708 BalsubscriberTerminalSubTermAlarmData *subTermAlarmData;
709 subTermAlarmData = malloc(sizeof(BalsubscriberTerminalSubTermAlarmData));
710 memset(subTermAlarmData, 0, sizeof(BalsubscriberTerminalSubTermAlarmData));
711 balsubscriber_terminal_sub_term_alarm_data__init(subTermAlarmData);
712 balIndCfg->terminal_alarm->data = subTermAlarmData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530713
VoLTHA753536e2017-11-02 20:15:09 +0530714 BalSubscriberTerminalAlarms *balSubAlarms;
715 balSubAlarms = malloc(sizeof(BalSubscriberTerminalAlarms));
716 memset(balSubAlarms, 0, sizeof(BalSubscriberTerminalAlarms));
717 bal_subscriber_terminal_alarms__init(balSubAlarms);
718 balIndCfg->terminal_alarm->data->alarm = balSubAlarms;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530719
VoLTHA753536e2017-11-02 20:15:09 +0530720 balIndCfg->terminal_alarm->data->alarm->has_los = BAL_GRPC_PRES;
721 balIndCfg->terminal_alarm->data->alarm->los = sub_term_alarm->data.alarm.los;
722 balIndCfg->terminal_alarm->data->alarm->has_lob = BAL_GRPC_PRES;
723 balIndCfg->terminal_alarm->data->alarm->lob = sub_term_alarm->data.alarm.lob;
724 balIndCfg->terminal_alarm->data->alarm->has_lopc_miss = BAL_GRPC_PRES;
725 balIndCfg->terminal_alarm->data->alarm->lopc_miss = sub_term_alarm->data.alarm.lopc_miss;
726 balIndCfg->terminal_alarm->data->alarm->has_lopc_mic_error = BAL_GRPC_PRES;
727 balIndCfg->terminal_alarm->data->alarm->lopc_mic_error = sub_term_alarm->data.alarm.lopc_mic_error;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530728
VoLTHA753536e2017-11-02 20:15:09 +0530729 list_node *bal_indication_node = malloc(sizeof(list_node));
730 bal_indication_node->bal_indication = balIndCfg;
731
732 pthread_mutex_lock(&bal_ind_queue_lock);
733 add_bal_indication_node(bal_indication_node);
734 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530735 }
736
737 return result;
738}
739
740/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530741 * Function : bal_sub_term_dgi_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530742 * Description : This function will handle the indications for *
743 * Subscriber term dgi indication *
744 * *
745 ********************************************************************/
746bcmos_errno bal_sub_term_dgi_indication_cb(bcmbal_obj *obj)
747{
748 bcmos_errno result = BCM_ERR_OK;
749
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530750 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530751 bcmbal_subscriber_terminal_auto_id_dgi != obj->subgroup)
752 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800753 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530754 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
755 result = BCM_ERR_INTERNAL;
756 }
757 else
758 {
VoLTHA753536e2017-11-02 20:15:09 +0530759 BalIndications *balIndCfg;
760 balIndCfg = malloc(sizeof(BalIndications));
761 memset(balIndCfg, 0, sizeof(BalIndications));
762 bal_indications__init(balIndCfg);
763 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_DGI;
764 balIndCfg->has_objtype = BAL_GRPC_PRES;
765 balIndCfg->objtype = obj->obj_type;
766 balIndCfg->has_sub_group = BAL_GRPC_PRES;
767 balIndCfg->sub_group = obj->subgroup;
768 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530769
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530770 bcmbal_subscriber_terminal_dgi *sub_dgi_ind =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530771 (bcmbal_subscriber_terminal_dgi *)obj;
772
VoLTHA753536e2017-11-02 20:15:09 +0530773 BalSubscriberTerminalDgi *subDgiInd;
774 subDgiInd = malloc(sizeof(BalSubscriberTerminalDgi));
775 memset(subDgiInd, 0, sizeof(BalSubscriberTerminalDgi));
776 bal_subscriber_terminal_dgi__init(subDgiInd);
777 balIndCfg->terminal_dgi= subDgiInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530778
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700779 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530780
VoLTHA753536e2017-11-02 20:15:09 +0530781 BalSubscriberTerminalKey *subkey;
782 subkey = malloc(sizeof(BalSubscriberTerminalKey));
783 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
784 bal_subscriber_terminal_key__init(subkey);
785 balIndCfg->terminal_dgi->key = subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530786
VoLTHA753536e2017-11-02 20:15:09 +0530787 balIndCfg->terminal_dgi->key->has_intf_id = BAL_GRPC_PRES;
788 balIndCfg->terminal_dgi->key->intf_id = sub_dgi_ind->key.intf_id;
789 balIndCfg->terminal_dgi->key->has_sub_term_id = BAL_GRPC_PRES;
790 balIndCfg->terminal_dgi->key->sub_term_id = sub_dgi_ind->key.sub_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530791
VoLTHA753536e2017-11-02 20:15:09 +0530792 BalSubscriberTerminalDgiData *subDgiIndData;
793 subDgiIndData = malloc(sizeof(BalSubscriberTerminalDgiData));
794 memset(subDgiIndData, 0, sizeof(BalSubscriberTerminalDgiData));
795 bal_subscriber_terminal_dgi_data__init(subDgiIndData);
796 balIndCfg->terminal_dgi->data = subDgiIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530797
VoLTHA753536e2017-11-02 20:15:09 +0530798 balIndCfg->terminal_dgi->data->has_dgi_status = BAL_GRPC_PRES;
799 balIndCfg->terminal_dgi->data->dgi_status = sub_dgi_ind->data.dgi_status;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530800
VoLTHA753536e2017-11-02 20:15:09 +0530801 list_node *bal_indication_node = malloc(sizeof(list_node));
802 bal_indication_node->bal_indication = balIndCfg;
803
804 pthread_mutex_lock(&bal_ind_queue_lock);
805 add_bal_indication_node(bal_indication_node);
806 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530807 }
808
809 return result;
810}
811
812/********************************************************************\
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700813 * Function : bal_sub_term_dowi_indication_cb *
814 * Description : This function will handle dowi indication *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530815 * *
816 ********************************************************************/
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700817bcmos_errno bal_sub_term_dowi_indication_cb(bcmbal_obj *obj)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530818{
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700819bcmos_errno result = BCM_ERR_OK;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530820
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530821 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700822 bcmbal_subscriber_terminal_auto_id_dowi != obj->subgroup)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530823 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800824 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530825 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
826 result = BCM_ERR_INTERNAL;
827 }
828 else
829 {
VoLTHA753536e2017-11-02 20:15:09 +0530830 BalIndications *balIndCfg;
831 balIndCfg = malloc(sizeof(BalIndications));
832 memset(balIndCfg, 0, sizeof(BalIndications));
833 bal_indications__init(balIndCfg);
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700834 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_DOWI;
VoLTHA753536e2017-11-02 20:15:09 +0530835 balIndCfg->has_objtype = BAL_GRPC_PRES;
836 balIndCfg->objtype = obj->obj_type;
837 balIndCfg->has_sub_group = BAL_GRPC_PRES;
838 balIndCfg->sub_group = obj->subgroup;
839 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530840
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700841 bcmbal_subscriber_terminal_dowi *sub_dowi_ind =
842 (bcmbal_subscriber_terminal_dowi *)obj;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530843
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700844 BalSubscriberTerminalDowi *subDowiInd;
845 subDowiInd = malloc(sizeof(BalSubscriberTerminalDowi));
846 memset(subDowiInd, 0, sizeof(BalSubscriberTerminalDowi));
847 bal_subscriber_terminal_dowi__init(subDowiInd);
848 balIndCfg->terminal_dowi= subDowiInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530849
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700850 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530851
VoLTHA753536e2017-11-02 20:15:09 +0530852 BalSubscriberTerminalKey *subkey;
853 subkey = malloc(sizeof(BalSubscriberTerminalKey));
854 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
855 bal_subscriber_terminal_key__init(subkey);
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700856 balIndCfg->terminal_dowi->key = subkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530857
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700858 balIndCfg->terminal_dowi->key->has_intf_id = BAL_GRPC_PRES;
859 balIndCfg->terminal_dowi->key->intf_id = sub_dowi_ind->key.intf_id;
860 balIndCfg->terminal_dowi->key->has_sub_term_id = BAL_GRPC_PRES;
861 balIndCfg->terminal_dowi->key->sub_term_id = sub_dowi_ind->key.sub_term_id;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530862
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700863 BalSubscriberTerminalDowiData *subDowiIndData;
864 subDowiIndData = malloc(sizeof(BalSubscriberTerminalDowiData));
865 memset(subDowiIndData, 0, sizeof(BalSubscriberTerminalDowiData));
866 bal_subscriber_terminal_dowi_data__init(subDowiIndData);
867 balIndCfg->terminal_dowi->data = subDowiIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530868
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700869 balIndCfg->terminal_dowi->data->has_dowi_status = BAL_GRPC_PRES;
870 balIndCfg->terminal_dowi->data->dowi_status = sub_dowi_ind->data.dowi_status;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530871
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700872 balIndCfg->terminal_dowi->data->has_drift_value = BAL_GRPC_PRES;
873 balIndCfg->terminal_dowi->data->drift_value = sub_dowi_ind->data.drift_value;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530874
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700875 balIndCfg->terminal_dowi->data->has_new_eqd = BAL_GRPC_PRES;
876 balIndCfg->terminal_dowi->data->new_eqd = sub_dowi_ind->data.new_eqd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530877
VoLTHA753536e2017-11-02 20:15:09 +0530878 list_node *bal_indication_node = malloc(sizeof(list_node));
879 bal_indication_node->bal_indication = balIndCfg;
880
881 pthread_mutex_lock(&bal_ind_queue_lock);
882 add_bal_indication_node(bal_indication_node);
883 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530884 }
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530885 return result;
886}
887
888/********************************************************************\
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700889 * Function : bal_sub_term_looci_indication_cb *
890 * Description : This function will handle looci indication *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530891 * *
892 ********************************************************************/
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700893bcmos_errno bal_sub_term_looci_indication_cb(bcmbal_obj *obj)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530894{
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700895bcmos_errno result = BCM_ERR_OK;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530896
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700897 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
898 bcmbal_subscriber_terminal_auto_id_looci != obj->subgroup)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530899 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800900 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530901 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
902 result = BCM_ERR_INTERNAL;
903 }
904 else
905 {
VoLTHA753536e2017-11-02 20:15:09 +0530906 BalIndications *balIndCfg;
907 balIndCfg = malloc(sizeof(BalIndications));
908 memset(balIndCfg, 0, sizeof(BalIndications));
909 bal_indications__init(balIndCfg);
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700910 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_LOOCI;
VoLTHA753536e2017-11-02 20:15:09 +0530911 balIndCfg->has_objtype = BAL_GRPC_PRES;
912 balIndCfg->objtype = obj->obj_type;
913 balIndCfg->has_sub_group = BAL_GRPC_PRES;
914 balIndCfg->sub_group = obj->subgroup;
915 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530916
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700917 bcmbal_subscriber_terminal_looci *sub_looci_ind =
918 (bcmbal_subscriber_terminal_looci *)obj;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530919
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700920 BalSubscriberTerminalLooci *subLoociInd;
921 subLoociInd = malloc(sizeof(BalSubscriberTerminalLooci));
922 memset(subLoociInd, 0, sizeof(BalSubscriberTerminalLooci));
923 bal_subscriber_terminal_looci__init(subLoociInd);
924 balIndCfg->terminal_looci= subLoociInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530925
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700926 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530927
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700928 BalSubscriberTerminalKey *subkey;
929 subkey = malloc(sizeof(BalSubscriberTerminalKey));
930 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
931 bal_subscriber_terminal_key__init(subkey);
932 balIndCfg->terminal_looci->key = subkey;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530933
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700934 balIndCfg->terminal_looci->key->has_intf_id = BAL_GRPC_PRES;
935 balIndCfg->terminal_looci->key->intf_id = sub_looci_ind->key.intf_id;
936 balIndCfg->terminal_looci->key->has_sub_term_id = BAL_GRPC_PRES;
937 balIndCfg->terminal_looci->key->sub_term_id = sub_looci_ind->key.sub_term_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530938
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700939 BalSubscriberTerminalLoociData *subLoociIndData;
940 subLoociIndData = malloc(sizeof(BalSubscriberTerminalLoociData));
941 memset(subLoociIndData, 0, sizeof(BalSubscriberTerminalLoociData));
942 bal_subscriber_terminal_looci_data__init(subLoociIndData);
943 balIndCfg->terminal_looci->data = subLoociIndData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530944
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700945 balIndCfg->terminal_looci->data->has_looci_status = BAL_GRPC_PRES;
946 balIndCfg->terminal_looci->data->looci_status = sub_looci_ind->data.looci_status;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530947
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700948 list_node *bal_indication_node = malloc(sizeof(list_node));
949 bal_indication_node->bal_indication = balIndCfg;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530950
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700951 pthread_mutex_lock(&bal_ind_queue_lock);
952 add_bal_indication_node(bal_indication_node);
953 pthread_mutex_unlock(&bal_ind_queue_lock);
954 }
955 return result;
956}
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530957
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700958/********************************************************************\
959 * Function : bal_sub_term_processing_error_indication_cb *
960 * Description : This function will handle sub term processing error*
961 * *
962 ********************************************************************/
963bcmos_errno bal_sub_term_processing_error_indication_cb(bcmbal_obj *obj)
964{
965bcmos_errno result = BCM_ERR_OK;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530966
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700967 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
968 bcmbal_subscriber_terminal_auto_id_processing_error != obj->subgroup)
969 {
970 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
971 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
972 result = BCM_ERR_INTERNAL;
973 }
974 else
975 {
976 BalIndications *balIndCfg;
977 balIndCfg = malloc(sizeof(BalIndications));
978 memset(balIndCfg, 0, sizeof(BalIndications));
979 bal_indications__init(balIndCfg);
980 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_PROC_ERR;
981 balIndCfg->has_objtype = BAL_GRPC_PRES;
982 balIndCfg->objtype = obj->obj_type;
983 balIndCfg->has_sub_group = BAL_GRPC_PRES;
984 balIndCfg->sub_group = obj->subgroup;
985 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530986
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700987 bcmbal_subscriber_terminal_processing_error *sub_proc_err_ind =
988 (bcmbal_subscriber_terminal_processing_error *)obj;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530989
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700990 BalSubscriberTerminalProcessingError *subProcErrInd;
991 subProcErrInd = malloc(sizeof(BalSubscriberTerminalProcessingError));
992 memset(subProcErrInd, 0, sizeof(BalSubscriberTerminalProcessingError));
993 bal_subscriber_terminal_processing_error__init(subProcErrInd);
994 balIndCfg->terminal_proc_err= subProcErrInd;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530995
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700996 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530997
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700998 BalSubscriberTerminalKey *subkey;
999 subkey = malloc(sizeof(BalSubscriberTerminalKey));
1000 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
1001 bal_subscriber_terminal_key__init(subkey);
1002 balIndCfg->terminal_proc_err->key = subkey;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301003
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001004 balIndCfg->terminal_proc_err->key->has_intf_id = BAL_GRPC_PRES;
1005 balIndCfg->terminal_proc_err->key->intf_id = sub_proc_err_ind->key.intf_id;
1006 balIndCfg->terminal_proc_err->key->has_sub_term_id = BAL_GRPC_PRES;
1007 balIndCfg->terminal_proc_err->key->sub_term_id = sub_proc_err_ind->key.sub_term_id;
1008
1009 list_node *bal_indication_node = malloc(sizeof(list_node));
1010 bal_indication_node->bal_indication = balIndCfg;
1011
1012 pthread_mutex_lock(&bal_ind_queue_lock);
1013 add_bal_indication_node(bal_indication_node);
1014 pthread_mutex_unlock(&bal_ind_queue_lock);
1015 }
1016 return result;
1017}
1018
1019/********************************************************************\
1020 * Function : bal_sub_term_sdi_indication_cb *
1021 * Description : This function will handle sdi indication *
1022 * *
1023 ********************************************************************/
1024bcmos_errno bal_sub_term_sdi_indication_cb(bcmbal_obj *obj)
1025{
1026bcmos_errno result = BCM_ERR_OK;
1027
1028 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1029 bcmbal_subscriber_terminal_auto_id_sdi != obj->subgroup)
1030 {
1031 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
1032 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1033 result = BCM_ERR_INTERNAL;
1034 }
1035 else
1036 {
1037 BalIndications *balIndCfg;
1038 balIndCfg = malloc(sizeof(BalIndications));
1039 memset(balIndCfg, 0, sizeof(BalIndications));
1040 bal_indications__init(balIndCfg);
1041 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_SDI;
1042 balIndCfg->has_objtype = BAL_GRPC_PRES;
1043 balIndCfg->objtype = obj->obj_type;
1044 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1045 balIndCfg->sub_group = obj->subgroup;
1046 balIndCfg->device_id = voltha_device_id;
1047
1048 bcmbal_subscriber_terminal_sdi *sub_sdi_ind =
1049 (bcmbal_subscriber_terminal_sdi *)obj;
1050
1051 BalSubscriberTerminalSdi *subSdiInd;
1052 subSdiInd = malloc(sizeof(BalSubscriberTerminalSdi));
1053 memset(subSdiInd, 0, sizeof(BalSubscriberTerminalSdi));
1054 bal_subscriber_terminal_sdi__init(subSdiInd);
1055 balIndCfg->terminal_sdi= subSdiInd;
1056
1057 /*'hdr' field is not parsed by voltha adapter, hence not filled */
1058
1059 BalSubscriberTerminalKey *subkey;
1060 subkey = malloc(sizeof(BalSubscriberTerminalKey));
1061 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
1062 bal_subscriber_terminal_key__init(subkey);
1063 balIndCfg->terminal_sdi->key = subkey;
1064
1065 balIndCfg->terminal_sdi->key->has_intf_id = BAL_GRPC_PRES;
1066 balIndCfg->terminal_sdi->key->intf_id = sub_sdi_ind->key.intf_id;
1067 balIndCfg->terminal_sdi->key->has_sub_term_id = BAL_GRPC_PRES;
1068 balIndCfg->terminal_sdi->key->sub_term_id = sub_sdi_ind->key.sub_term_id;
1069
1070 BalSubscriberTerminalSdiData *subSdiIndData;
1071 subSdiIndData = malloc(sizeof(BalSubscriberTerminalSdiData));
1072 memset(subSdiIndData, 0, sizeof(BalSubscriberTerminalSdiData));
1073 bal_subscriber_terminal_sdi_data__init(subSdiIndData);
1074 balIndCfg->terminal_sdi->data = subSdiIndData;
1075
1076 balIndCfg->terminal_sdi->data->has_sdi_status = BAL_GRPC_PRES;
1077 balIndCfg->terminal_sdi->data->sdi_status = sub_sdi_ind->data.sdi_status;
1078
1079 balIndCfg->terminal_sdi->data->has_ber = BAL_GRPC_PRES;
1080 balIndCfg->terminal_sdi->data->ber = sub_sdi_ind->data.ber;
1081
1082 list_node *bal_indication_node = malloc(sizeof(list_node));
1083 bal_indication_node->bal_indication = balIndCfg;
1084
1085 pthread_mutex_lock(&bal_ind_queue_lock);
1086 add_bal_indication_node(bal_indication_node);
1087 pthread_mutex_unlock(&bal_ind_queue_lock);
1088 }
1089 return result;
1090}
1091
1092/********************************************************************\
1093 * Function : bal_sub_term_sfi_indication_cb *
1094 * Description : This function will handle sfi indication *
1095 * *
1096 ********************************************************************/
1097bcmos_errno bal_sub_term_sfi_indication_cb(bcmbal_obj *obj)
1098{
1099bcmos_errno result = BCM_ERR_OK;
1100
1101 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1102 bcmbal_subscriber_terminal_auto_id_sfi != obj->subgroup)
1103 {
1104 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
1105 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1106 result = BCM_ERR_INTERNAL;
1107 }
1108 else
1109 {
1110 BalIndications *balIndCfg;
1111 balIndCfg = malloc(sizeof(BalIndications));
1112 memset(balIndCfg, 0, sizeof(BalIndications));
1113 bal_indications__init(balIndCfg);
1114 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_SFI;
1115 balIndCfg->has_objtype = BAL_GRPC_PRES;
1116 balIndCfg->objtype = obj->obj_type;
1117 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1118 balIndCfg->sub_group = obj->subgroup;
1119 balIndCfg->device_id = voltha_device_id;
1120
1121 bcmbal_subscriber_terminal_sfi *sub_sfi_ind =
1122 (bcmbal_subscriber_terminal_sfi *)obj;
1123
1124 BalSubscriberTerminalSfi *subSfiInd;
1125 subSfiInd = malloc(sizeof(BalSubscriberTerminalSfi));
1126 memset(subSfiInd, 0, sizeof(BalSubscriberTerminalSfi));
1127 bal_subscriber_terminal_sfi__init(subSfiInd);
1128 balIndCfg->terminal_sfi= subSfiInd;
1129
1130 /*'hdr' field is not parsed by voltha adapter, hence not filled */
1131
1132 BalSubscriberTerminalKey *subkey;
1133 subkey = malloc(sizeof(BalSubscriberTerminalKey));
1134 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
1135 bal_subscriber_terminal_key__init(subkey);
1136 balIndCfg->terminal_sfi->key = subkey;
1137
1138 balIndCfg->terminal_sfi->key->has_intf_id = BAL_GRPC_PRES;
1139 balIndCfg->terminal_sfi->key->intf_id = sub_sfi_ind->key.intf_id;
1140 balIndCfg->terminal_sfi->key->has_sub_term_id = BAL_GRPC_PRES;
1141 balIndCfg->terminal_sfi->key->sub_term_id = sub_sfi_ind->key.sub_term_id;
1142
1143 BalSubscriberTerminalSfiData *subSfiIndData;
1144 subSfiIndData = malloc(sizeof(BalSubscriberTerminalSfiData));
1145 memset(subSfiIndData, 0, sizeof(BalSubscriberTerminalSfiData));
1146 bal_subscriber_terminal_sfi_data__init(subSfiIndData);
1147 balIndCfg->terminal_sfi->data = subSfiIndData;
1148
1149 balIndCfg->terminal_sfi->data->has_sfi_status = BAL_GRPC_PRES;
1150 balIndCfg->terminal_sfi->data->sfi_status = sub_sfi_ind->data.sfi_status;
1151
1152 balIndCfg->terminal_sfi->data->has_ber = BAL_GRPC_PRES;
1153 balIndCfg->terminal_sfi->data->ber = sub_sfi_ind->data.ber;
1154
1155 list_node *bal_indication_node = malloc(sizeof(list_node));
1156 bal_indication_node->bal_indication = balIndCfg;
1157
1158 pthread_mutex_lock(&bal_ind_queue_lock);
1159 add_bal_indication_node(bal_indication_node);
1160 pthread_mutex_unlock(&bal_ind_queue_lock);
1161 }
1162 return result;
1163}
1164
1165/********************************************************************\
1166 * Function : bal_sub_term_act_fail_indication_cb *
1167 * Description : This function will handle sub term activation fail *
1168 * indication *
1169 * *
1170 ********************************************************************/
1171bcmos_errno bal_sub_term_act_fail_indication_cb(bcmbal_obj *obj)
1172{
1173bcmos_errno result = BCM_ERR_OK;
1174
1175 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1176 bcmbal_subscriber_terminal_auto_id_sub_term_act_fail != obj->subgroup)
1177 {
1178 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
1179 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1180 result = BCM_ERR_INTERNAL;
1181 }
1182 else
1183 {
1184 BalIndications *balIndCfg;
1185 balIndCfg = malloc(sizeof(BalIndications));
1186 memset(balIndCfg, 0, sizeof(BalIndications));
1187 bal_indications__init(balIndCfg);
1188 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_SUB_TERM_ACT_FAIL;
1189 balIndCfg->has_objtype = BAL_GRPC_PRES;
1190 balIndCfg->objtype = obj->obj_type;
1191 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1192 balIndCfg->sub_group = obj->subgroup;
1193 balIndCfg->device_id = voltha_device_id;
1194
1195 bcmbal_subscriber_terminal_sub_term_act_fail *sub_term_act_fail_ind =
1196 (bcmbal_subscriber_terminal_sub_term_act_fail *)obj;
1197
1198 BalSubscriberTerminalSubTermActFail *subTermActFailInd;
1199 subTermActFailInd = malloc(sizeof(BalSubscriberTerminalSubTermActFail));
1200 memset(subTermActFailInd, 0, sizeof(BalSubscriberTerminalSubTermActFail));
1201 bal_subscriber_terminal_sub_term_act_fail__init(subTermActFailInd);
1202 balIndCfg->terminal_sub_term_act_fail= subTermActFailInd;
1203
1204 /*'hdr' field is not parsed by voltha adapter, hence not filled */
1205
1206 BalSubscriberTerminalKey *subkey;
1207 subkey = malloc(sizeof(BalSubscriberTerminalKey));
1208 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
1209 bal_subscriber_terminal_key__init(subkey);
1210 balIndCfg->terminal_sub_term_act_fail->key = subkey;
1211
1212 balIndCfg->terminal_sub_term_act_fail->key->has_intf_id = BAL_GRPC_PRES;
1213 balIndCfg->terminal_sub_term_act_fail->key->intf_id = sub_term_act_fail_ind->key.intf_id;
1214 balIndCfg->terminal_sub_term_act_fail->key->has_sub_term_id = BAL_GRPC_PRES;
1215 balIndCfg->terminal_sub_term_act_fail->key->sub_term_id = sub_term_act_fail_ind->key.sub_term_id;
1216
1217 BalSubscriberTerminalSubTermActFailData *subTermActFailIndData;
1218 subTermActFailIndData = malloc(sizeof(BalSubscriberTerminalSubTermActFailData));
1219 memset(subTermActFailIndData, 0, sizeof(BalSubscriberTerminalSubTermActFailData));
1220 bal_subscriber_terminal_sub_term_act_fail_data__init(subTermActFailIndData);
1221 balIndCfg->terminal_sub_term_act_fail->data = subTermActFailIndData;
1222
1223 balIndCfg->terminal_sub_term_act_fail->data->has_fail_reason = BAL_GRPC_PRES;
1224 balIndCfg->terminal_sub_term_act_fail->data->fail_reason = sub_term_act_fail_ind->data.fail_reason;
1225
1226 list_node *bal_indication_node = malloc(sizeof(list_node));
1227 bal_indication_node->bal_indication = balIndCfg;
1228
1229 pthread_mutex_lock(&bal_ind_queue_lock);
1230 add_bal_indication_node(bal_indication_node);
1231 pthread_mutex_unlock(&bal_ind_queue_lock);
1232 }
1233 return result;
1234}
1235
1236/********************************************************************\
1237 * Function : bal_sub_term_sufi_indication_cb *
1238 * Description : This function will handle sufi indication *
1239 * *
1240 ********************************************************************/
1241bcmos_errno bal_sub_term_sufi_indication_cb(bcmbal_obj *obj)
1242{
1243 bcmos_errno result = BCM_ERR_OK;
1244 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1245 bcmbal_subscriber_terminal_auto_id_sufi != obj->subgroup)
1246 {
1247 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
1248 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1249 result = BCM_ERR_INTERNAL;
1250 }
1251 else
1252 {
1253 BalIndications *balIndCfg;
1254 balIndCfg = malloc(sizeof(BalIndications));
1255 memset(balIndCfg, 0, sizeof(BalIndications));
1256 bal_indications__init(balIndCfg);
1257 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_SUFI;
1258 balIndCfg->has_objtype = BAL_GRPC_PRES;
1259 balIndCfg->objtype = obj->obj_type;
1260 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1261 balIndCfg->sub_group = obj->subgroup;
1262 balIndCfg->device_id = voltha_device_id;
1263
1264 bcmbal_subscriber_terminal_sufi *sub_sufi_ind =
1265 (bcmbal_subscriber_terminal_sufi *)obj;
1266
1267 BalSubscriberTerminalSufi *subSufiInd;
1268 subSufiInd = malloc(sizeof(BalSubscriberTerminalSufi));
1269 memset(subSufiInd, 0, sizeof(BalSubscriberTerminalSufi));
1270 bal_subscriber_terminal_sufi__init(subSufiInd);
1271 balIndCfg->terminal_sufi= subSufiInd;
1272
1273 /*'hdr' field is not parsed by voltha adapter, hence not filled */
1274
1275 BalSubscriberTerminalKey *subkey;
1276 subkey = malloc(sizeof(BalSubscriberTerminalKey));
1277 memset(subkey, 0, sizeof(BalSubscriberTerminalKey));
1278 bal_subscriber_terminal_key__init(subkey);
1279 balIndCfg->terminal_sufi->key = subkey;
1280
1281 balIndCfg->terminal_sufi->key->has_intf_id = BAL_GRPC_PRES;
1282 balIndCfg->terminal_sufi->key->intf_id = sub_sufi_ind->key.intf_id;
1283 balIndCfg->terminal_sufi->key->has_sub_term_id = BAL_GRPC_PRES;
1284 balIndCfg->terminal_sufi->key->sub_term_id = sub_sufi_ind->key.sub_term_id;
1285
1286 BalSubscriberTerminalSufiData *subSufiIndData;
1287 subSufiIndData = malloc(sizeof(BalSubscriberTerminalSufiData));
1288 memset(subSufiIndData, 0, sizeof(BalSubscriberTerminalSufiData));
1289 bal_subscriber_terminal_sufi_data__init(subSufiIndData);
1290 balIndCfg->terminal_sufi->data = subSufiIndData;
1291
1292 balIndCfg->terminal_sufi->data->has_sufi_status = BAL_GRPC_PRES;
1293 balIndCfg->terminal_sufi->data->sufi_status = sub_sufi_ind->data.sufi_status;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301294
VoLTHA753536e2017-11-02 20:15:09 +05301295 list_node *bal_indication_node = malloc(sizeof(list_node));
1296 bal_indication_node->bal_indication = balIndCfg;
1297
1298 pthread_mutex_lock(&bal_ind_queue_lock);
1299 add_bal_indication_node(bal_indication_node);
1300 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301301 }
1302
1303 return result;
1304}
1305
1306/********************************************************************\
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001307 * Function : bal_sub_term_tiwi_indication_cb *
1308 * Description : This function will handle tiwi indication *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301309 * *
1310 ********************************************************************/
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001311bcmos_errno bal_sub_term_tiwi_indication_cb(bcmbal_obj *obj)
1312{
1313 bcmos_errno result = BCM_ERR_OK;
1314 if(BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL != obj->obj_type ||
1315 BCMBAL_SUBSCRIBER_TERMINAL_AUTO_ID_TIWI != obj->subgroup)
1316 {
1317 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
1318 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1319 result = BCM_ERR_INTERNAL;
1320 }
1321 else
1322 {
1323 BalIndications *balIndCfg;
1324 balIndCfg = malloc(sizeof(BalIndications));
1325 memset(balIndCfg, 0, sizeof(BalIndications));
1326 bal_indications__init(balIndCfg);
1327 balIndCfg->u_case = BAL_INDICATIONS__U_TERMINAL_TIWI;
1328 balIndCfg->has_objtype = BAL_GRPC_PRES;
1329 balIndCfg->objtype = obj->obj_type;
1330 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1331 balIndCfg->sub_group = obj->subgroup;
1332 balIndCfg->device_id = voltha_device_id;
1333
1334 bcmbal_subscriber_terminal_tiwi *sub_term_tiwi =
1335 (bcmbal_subscriber_terminal_tiwi *)obj;
1336
1337 BalSubscriberTerminalTiwi *subTermTiwi;
1338 subTermTiwi = malloc(sizeof(BalSubscriberTerminalTiwi));
1339 memset(subTermTiwi, 0, sizeof(BalSubscriberTerminalTiwi));
1340 bal_subscriber_terminal_tiwi__init(subTermTiwi);
1341 balIndCfg->terminal_tiwi = subTermTiwi;
1342
1343 /*'hdr' field is not parsed by voltha adapter, hence not filled */
1344
1345 BalSubscriberTerminalKey *sub_term_key;
1346 sub_term_key = malloc(sizeof(BalSubscriberTerminalKey));
1347 memset(sub_term_key, 0, sizeof(BalSubscriberTerminalKey));
1348 bal_subscriber_terminal_key__init(sub_term_key);
1349 balIndCfg->terminal_tiwi->key = sub_term_key;
1350
1351 balIndCfg->terminal_tiwi->key->has_sub_term_id = BAL_GRPC_PRES;
1352 balIndCfg->terminal_tiwi->key->sub_term_id = sub_term_tiwi->key.sub_term_id;
1353 balIndCfg->terminal_tiwi->key->has_intf_id = BAL_GRPC_PRES;
1354 balIndCfg->terminal_tiwi->key->intf_id = sub_term_tiwi->key.intf_id;
1355
1356 BalSubscriberTerminalTiwiData *sub_term_tiwi_data;
1357 sub_term_tiwi_data = malloc(sizeof(BalSubscriberTerminalTiwiData));
1358 memset(sub_term_tiwi_data, 0, sizeof(BalSubscriberTerminalTiwiData));
1359 bal_subscriber_terminal_tiwi_data__init(sub_term_tiwi_data);
1360 balIndCfg->terminal_tiwi->data = sub_term_tiwi_data;
1361
1362 balIndCfg->terminal_tiwi->data->has_tiwi_status = BAL_GRPC_PRES;
1363 balIndCfg->terminal_tiwi->data->tiwi_status = sub_term_tiwi->data.tiwi_status;
1364
1365 balIndCfg->terminal_tiwi->data->has_drift_value = BAL_GRPC_PRES;
1366 balIndCfg->terminal_tiwi->data->drift_value = sub_term_tiwi->data.drift_value;
1367
1368 list_node *bal_indication_node = malloc(sizeof(list_node));
1369 bal_indication_node->bal_indication = balIndCfg;
1370
1371 pthread_mutex_lock(&bal_ind_queue_lock);
1372 add_bal_indication_node(bal_indication_node);
1373 pthread_mutex_unlock(&bal_ind_queue_lock);
1374 }
1375
1376 return result;
1377}
1378
1379/********************************************************************\
1380 * Function : bal_tm_sched_auto_id_oper_status_change_cb *
1381 * Description : This function will handle tm sched operation status*
1382 * change indication *
1383 * *
1384 ********************************************************************/
1385bcmos_errno bal_tm_sched_auto_id_oper_status_change_cb(bcmbal_obj *obj)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301386{
1387 bcmos_errno result = BCM_ERR_OK;
1388
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301389 if(BCMBAL_OBJ_ID_TM_SCHED != obj->obj_type ||
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001390 bcmbal_tm_sched_auto_id_oper_status_change != obj->subgroup)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301391 {
Kim Kempfafa1ab42017-11-13 09:31:47 -08001392 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301393 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1394 result = BCM_ERR_INTERNAL;
1395 }
1396 else
1397 {
VoLTHA753536e2017-11-02 20:15:09 +05301398 BalIndications *balIndCfg;
1399 balIndCfg = malloc(sizeof(BalIndications));
1400 memset(balIndCfg, 0, sizeof(BalIndications));
1401 bal_indications__init(balIndCfg);
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001402 balIndCfg->u_case = BAL_INDICATIONS__U_TM_SCHED_OPER_STATS_CHANGE;
VoLTHA753536e2017-11-02 20:15:09 +05301403 balIndCfg->has_objtype = BAL_GRPC_PRES;
1404 balIndCfg->objtype = obj->obj_type;
1405 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1406 balIndCfg->sub_group = obj->subgroup;
1407 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301408
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001409 bcmbal_tm_sched_oper_status_change *tm_sched_osc =
1410 (bcmbal_tm_sched_oper_status_change *)obj;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301411
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001412 BalTmSchedOperStatusChange *tmSchedOsc;
1413 tmSchedOsc = malloc(sizeof(BalTmSchedOperStatusChange));
1414 memset(tmSchedOsc, 0, sizeof(BalTmSchedOperStatusChange));
1415 bal_tm_sched_oper_status_change__init(tmSchedOsc);
1416 balIndCfg->tm_sched_oper_stats_change = tmSchedOsc;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301417
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001418 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301419
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001420 BalTmSchedKey *tmSchedKey;
1421 tmSchedKey = malloc(sizeof(BalTmSchedKey));
1422 memset(tmSchedKey, 0, sizeof(BalTmSchedKey));
1423 bal_tm_sched_key__init(tmSchedKey);
1424 balIndCfg->tm_sched_oper_stats_change->key = tmSchedKey;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301425
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001426 balIndCfg->tm_sched_oper_stats_change->key->has_dir = BAL_GRPC_PRES;
1427 balIndCfg->tm_sched_oper_stats_change->key->dir = tm_sched_osc->key.dir;
1428 balIndCfg->tm_sched_oper_stats_change->key->has_id = BAL_GRPC_PRES;
1429 balIndCfg->tm_sched_oper_stats_change->key->id = tm_sched_osc->key.id;
1430
1431 BalTmSchedOperStatusChangeData *tmschedOscData;
1432 tmschedOscData = malloc(sizeof(BalTmSchedOperStatusChangeData));
1433 memset(tmschedOscData, 0, sizeof(BalTmSchedOperStatusChangeData));
1434 bal_tm_sched_oper_status_change_data__init(tmschedOscData);
1435 balIndCfg->tm_sched_oper_stats_change->data = tmschedOscData;
1436
1437 balIndCfg->tm_sched_oper_stats_change->data->has_new_oper_status = BAL_GRPC_PRES;
1438 balIndCfg->tm_sched_oper_stats_change->data->new_oper_status =
1439 tm_sched_osc->data.new_oper_status;
1440 balIndCfg->tm_sched_oper_stats_change->data->has_old_oper_status = BAL_GRPC_PRES;
1441 balIndCfg->tm_sched_oper_stats_change->data->old_oper_status =
1442 tm_sched_osc->data.old_oper_status;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301443
VoLTHA753536e2017-11-02 20:15:09 +05301444 list_node *bal_indication_node = malloc(sizeof(list_node));
1445 bal_indication_node->bal_indication = balIndCfg;
1446
1447 pthread_mutex_lock(&bal_ind_queue_lock);
1448 add_bal_indication_node(bal_indication_node);
1449 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301450 }
1451
1452 return result;
1453}
1454
1455/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301456 * Function : bal_packet_data_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301457 * Description : This function will handle the indications for *
1458 * Packet Data indication *
1459 * *
1460 ********************************************************************/
1461bcmos_errno bal_packet_data_indication_cb(bcmbal_obj *obj)
1462{
1463 bcmos_errno result = BCM_ERR_OK;
1464
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301465 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301466 bcmbal_packet_auto_id_bearer_channel_rx != obj->subgroup)
1467 {
Kim Kempfafa1ab42017-11-13 09:31:47 -08001468 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301469 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1470 result = BCM_ERR_INTERNAL;
1471 }
1472 else
1473 {
1474 /*bcmos_mutex_lock(&bal_ind_lock);-- Need to define bcm independent mutex*/
1475
VoLTHA753536e2017-11-02 20:15:09 +05301476 BalIndications *balIndCfg;
1477 balIndCfg = malloc(sizeof(BalIndications));
1478 memset(balIndCfg, 0, sizeof(BalIndications));
1479 bal_indications__init(balIndCfg);
1480 balIndCfg->u_case = BAL_INDICATIONS__U_PKT_DATA;
1481 balIndCfg->has_objtype = BAL_GRPC_PRES;
1482 balIndCfg->objtype = obj->obj_type;
1483 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1484 balIndCfg->sub_group = obj->subgroup;
1485 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301486
VoLTHA753536e2017-11-02 20:15:09 +05301487 BalPacketBearerChannelRx *rxChannel;
1488 rxChannel = malloc(sizeof(BalPacketBearerChannelRx));
1489 memset(rxChannel, 0, sizeof(BalPacketBearerChannelRx));
1490 bal_packet_bearer_channel_rx__init(rxChannel);
1491 balIndCfg->pktdata = rxChannel;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301492
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001493 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301494
VoLTHA753536e2017-11-02 20:15:09 +05301495 BalPacketKey *packetkey;
1496 packetkey = malloc(sizeof(BalPacketKey));
1497 memset(packetkey, 0, sizeof(BalPacketKey));
1498 bal_packet_key__init(packetkey);
1499 balIndCfg->pktdata->key = packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301500
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301501 bcmbal_packet_bearer_channel_rx *rx_channel =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301502 (bcmbal_packet_bearer_channel_rx *)obj;
1503
VoLTHA753536e2017-11-02 20:15:09 +05301504 balIndCfg->pktdata->key->has_reserved = BAL_GRPC_PRES;
1505 balIndCfg->pktdata->key->reserved = rx_channel->key.reserved;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301506
VoLTHA753536e2017-11-02 20:15:09 +05301507 BalDest *PktSndDest;
1508 PktSndDest = malloc(sizeof(BalDest));
1509 memset(PktSndDest, 0, sizeof(BalDest));
1510 bal_dest__init(PktSndDest);
1511 balIndCfg->pktdata->key->packet_send_dest = PktSndDest;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301512
VoLTHA753536e2017-11-02 20:15:09 +05301513 balIndCfg->pktdata->key->packet_send_dest->has_type = BAL_GRPC_PRES;
1514 balIndCfg->pktdata->key->packet_send_dest->type =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301515 rx_channel->key.packet_send_dest.type;
1516 switch( rx_channel->key.packet_send_dest.type)
1517 {
1518 case BCMBAL_DEST_TYPE_NNI:
1519 {
VoLTHA753536e2017-11-02 20:15:09 +05301520 balIndCfg->pktdata->key->packet_send_dest->u_case = BAL_DEST__U_NNI;
1521 BalDestNni *balNni;
1522 balNni = malloc(sizeof(BalDestNni));
1523 memset(balNni, 0, sizeof(BalDestNni));
1524 bal_dest_nni__init(balNni);
1525 balIndCfg->pktdata->key->packet_send_dest->nni = balNni;
1526 balIndCfg->pktdata->key->packet_send_dest->nni->has_intf_id = BAL_GRPC_PRES;
1527 balIndCfg->pktdata->key->packet_send_dest->nni->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301528 rx_channel->key.packet_send_dest.u.nni.intf_id;
1529 }
1530 break;
1531 case BCMBAL_DEST_TYPE_SUB_TERM:
1532 {
VoLTHA753536e2017-11-02 20:15:09 +05301533 balIndCfg->pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SUB_TERM;
1534 BalDestSubTerm *balSubTerm;
1535 balSubTerm = malloc(sizeof(BalDestSubTerm));
1536 memset(balSubTerm, 0, sizeof(BalDestSubTerm));
1537 bal_dest_sub_term__init(balSubTerm);
1538 balIndCfg->pktdata->key->packet_send_dest->sub_term = balSubTerm;
1539 balIndCfg->pktdata->key->packet_send_dest->sub_term->has_sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301540 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301541 balIndCfg->pktdata->key->packet_send_dest->sub_term->sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301542 rx_channel->key.packet_send_dest.u.sub_term.sub_term_id;
VoLTHA753536e2017-11-02 20:15:09 +05301543 balIndCfg->pktdata->key->packet_send_dest->sub_term->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301544 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301545 balIndCfg->pktdata->key->packet_send_dest->sub_term->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301546 rx_channel->key.packet_send_dest.u.sub_term.intf_id;
1547 }
1548 break;
1549 case BCMBAL_DEST_TYPE_SVC_PORT:
1550 {
VoLTHA753536e2017-11-02 20:15:09 +05301551 balIndCfg->pktdata->key->packet_send_dest->u_case = BAL_DEST__U_SVC_PORT;
1552 BalDestSvcPort *balSvcPort;
1553 balSvcPort = malloc(sizeof(BalDestSvcPort));
1554 memset(balSvcPort, 0, sizeof(BalDestSvcPort));
1555 bal_dest_svc_port__init(balSvcPort);
1556 balIndCfg->pktdata->key->packet_send_dest->svc_port = balSvcPort;
1557 balIndCfg->pktdata->key->packet_send_dest->svc_port->has_svc_port_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301558 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301559 balIndCfg->pktdata->key->packet_send_dest->svc_port->svc_port_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301560 rx_channel->key.packet_send_dest.u.svc_port.svc_port_id;
VoLTHA753536e2017-11-02 20:15:09 +05301561 balIndCfg->pktdata->key->packet_send_dest->svc_port->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301562 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301563 balIndCfg->pktdata->key->packet_send_dest->svc_port->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301564 rx_channel->key.packet_send_dest.u.svc_port.intf_id;
1565 }
1566 break;
1567 default:
1568 {
VoLTHA753536e2017-11-02 20:15:09 +05301569 balIndCfg->pktdata->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301570 }
1571 break;
1572 }
1573
VoLTHA753536e2017-11-02 20:15:09 +05301574 BalPacketBearerChannelRxData *pkdData;
1575 pkdData = malloc(sizeof(BalPacketBearerChannelRxData));
1576 memset(pkdData, 0, sizeof(BalPacketBearerChannelRxData));
1577 bal_packet_bearer_channel_rx_data__init(pkdData);
1578 balIndCfg->pktdata->data = pkdData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301579
VoLTHA753536e2017-11-02 20:15:09 +05301580 balIndCfg->pktdata->data->has_flow_id = BAL_GRPC_PRES;
1581 balIndCfg->pktdata->data->flow_id = rx_channel->data.flow_id;
1582 balIndCfg->pktdata->data->has_flow_type = BAL_GRPC_PRES;
1583 balIndCfg->pktdata->data->flow_type = rx_channel->data.flow_type;
1584 balIndCfg->pktdata->data->has_intf_id = BAL_GRPC_PRES;
1585 balIndCfg->pktdata->data->intf_id = rx_channel->data.intf_id;
1586 balIndCfg->pktdata->data->has_intf_type = BAL_GRPC_PRES;
1587 balIndCfg->pktdata->data->intf_type = rx_channel->data.intf_type;
1588 balIndCfg->pktdata->data->has_svc_port = BAL_GRPC_PRES;
1589 balIndCfg->pktdata->data->svc_port = rx_channel->data.svc_port;
1590 balIndCfg->pktdata->data->has_flow_cookie = BAL_GRPC_PRES;
1591 balIndCfg->pktdata->data->flow_cookie = rx_channel->data.flow_cookie;
1592 balIndCfg->pktdata->data->has_pkt = BAL_GRPC_PRES;
1593 balIndCfg->pktdata->data->pkt.len = rx_channel->data.pkt.len;
1594 balIndCfg->pktdata->data->pkt.data = (uint8_t *)malloc((balIndCfg->pktdata->data->pkt.len)*sizeof(uint8_t));
1595 memcpy(balIndCfg->pktdata->data->pkt.data, rx_channel->data.pkt.val, balIndCfg->pktdata->data->pkt.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301596
1597 /*bcmos_mutex_unlock(&bal_ind_lock);-- Need to define bcm independent mutex*/
1598
VoLTHA753536e2017-11-02 20:15:09 +05301599 list_node *bal_indication_node = malloc(sizeof(list_node));
1600 bal_indication_node->bal_indication = balIndCfg;
1601
1602 pthread_mutex_lock(&bal_ind_queue_lock);
1603 add_bal_indication_node(bal_indication_node);
1604 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301605 }
1606
1607 return result;
1608}
1609
1610/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301611 * Function : bal_omci_data_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301612 * Description : This function will handle the indications for *
1613 * OMCI Data Response *
1614 * *
1615 ********************************************************************/
1616bcmos_errno bal_omci_data_indication_cb(bcmbal_obj *obj)
1617{
1618 bcmos_errno result = BCM_ERR_OK;
1619
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301620 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301621 bcmbal_packet_auto_id_itu_omci_channel_rx != obj->subgroup)
1622 {
Kim Kempfafa1ab42017-11-13 09:31:47 -08001623 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301624 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1625 result = BCM_ERR_INTERNAL;
1626 }
1627 else
1628 {
Kim Kempfafa1ab42017-11-13 09:31:47 -08001629 ASFVOLT_LOG(ASFVOLT_DEBUG, "Received OMCI response via BAL APIs");
VoLTHA753536e2017-11-02 20:15:09 +05301630 BalIndications *balIndCfg;
1631 balIndCfg = malloc(sizeof(BalIndications));
1632 memset(balIndCfg, 0, sizeof(BalIndications));
1633 bal_indications__init(balIndCfg);
1634 balIndCfg->u_case = BAL_INDICATIONS__U_BAL_OMCI_RESP;
1635 balIndCfg->has_objtype = BAL_GRPC_PRES;
1636 balIndCfg->objtype = obj->obj_type;
1637 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1638 balIndCfg->sub_group = obj->subgroup;
1639 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301640
VoLTHA753536e2017-11-02 20:15:09 +05301641 BalPacketItuOmciChannelRx *omciChannel;
1642 omciChannel = malloc(sizeof(BalPacketItuOmciChannelRx));
1643 memset(omciChannel, 0, sizeof(BalPacketItuOmciChannelRx));
1644 bal_packet_itu_omci_channel_rx__init(omciChannel);
1645 balIndCfg->balomciresp = omciChannel;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301646
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001647 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301648
VoLTHA753536e2017-11-02 20:15:09 +05301649 BalPacketKey *packetkey;
1650 packetkey = malloc(sizeof(BalPacketKey));
1651 memset(packetkey, 0, sizeof(BalPacketKey));
1652 bal_packet_key__init(packetkey);
1653 balIndCfg->balomciresp->key = packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301654
VoLTHA753536e2017-11-02 20:15:09 +05301655 BalPacketItuOmciChannelRxData *omciData;
1656 omciData = malloc(sizeof(BalPacketItuOmciChannelRxData));
1657 memset(omciData, 0, sizeof(BalPacketItuOmciChannelRxData));
1658 bal_packet_itu_omci_channel_rx_data__init(omciData);
1659 balIndCfg->balomciresp->data = omciData;
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301660
1661 bcmbal_packet_itu_omci_channel_rx *omci_channel =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301662 (bcmbal_packet_itu_omci_channel_rx *)obj;
1663
VoLTHA753536e2017-11-02 20:15:09 +05301664 balIndCfg->balomciresp->data->has_pkt = BAL_GRPC_PRES;
1665 balIndCfg->balomciresp->data->pkt.len = omci_channel->data.pkt.len;
1666 balIndCfg->balomciresp->data->pkt.data = (uint8_t *)malloc((omci_channel->data.pkt.len)*sizeof(uint8_t));
1667 memcpy(balIndCfg->balomciresp->data->pkt.data, omci_channel->data.pkt.val,
1668 balIndCfg->balomciresp->data->pkt.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301669
VoLTHA753536e2017-11-02 20:15:09 +05301670 balIndCfg->balomciresp->key->has_reserved = BAL_GRPC_PRES;
1671 balIndCfg->balomciresp->key->reserved = omci_channel->key.reserved;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301672
VoLTHA753536e2017-11-02 20:15:09 +05301673 BalDest *PktSndDest;
1674 PktSndDest = malloc(sizeof(BalDest));
1675 memset(PktSndDest, 0, sizeof(BalDest));
1676 bal_dest__init(PktSndDest);
1677 balIndCfg->balomciresp->key->packet_send_dest = PktSndDest;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301678
VoLTHA753536e2017-11-02 20:15:09 +05301679 balIndCfg->balomciresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
1680 balIndCfg->balomciresp->key->packet_send_dest->type =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301681 omci_channel->key.packet_send_dest.type;
1682 switch( omci_channel->key.packet_send_dest.type)
1683 {
1684 case BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL:
1685 {
VoLTHA753536e2017-11-02 20:15:09 +05301686 balIndCfg->balomciresp->key->packet_send_dest->u_case = BAL_DEST__U_ITU_OMCI_CHANNEL;
1687 BalItuOmciChannel *balOmci;
1688 balOmci = malloc(sizeof(BalItuOmciChannel));
1689 memset(balOmci, 0, sizeof(BalItuOmciChannel));
1690 bal_itu_omci_channel__init(balOmci);
1691 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel = balOmci;
1692 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel->has_sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301693 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301694 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301695 omci_channel->key.packet_send_dest.u.itu_omci_channel.sub_term_id;
VoLTHA753536e2017-11-02 20:15:09 +05301696 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301697 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301698 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301699 omci_channel->key.packet_send_dest.u.itu_omci_channel.intf_id;
Kim Kempfafa1ab42017-11-13 09:31:47 -08001700 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d",
VoLTHA753536e2017-11-02 20:15:09 +05301701 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301702 }
1703 break;
1704 default:
1705 {
VoLTHA753536e2017-11-02 20:15:09 +05301706 balIndCfg->balomciresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301707 }
1708 break;
1709 }
1710
Kim Kempfafa1ab42017-11-13 09:31:47 -08001711 ASFVOLT_HEX2LOG(ASFVOLT_DEBUG, "OMCI Response with %zd bytes is ",
1712 balIndCfg->balomciresp->data->pkt.data, balIndCfg->balomciresp->data->pkt.len);
1713
1714 ASFVOLT_LOG(ASFVOLT_DEBUG, "OMCI Response for ONU id %d",
VoLTHA753536e2017-11-02 20:15:09 +05301715 balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel->sub_term_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -08001716
VoLTHA753536e2017-11-02 20:15:09 +05301717 list_node *bal_indication_node = malloc(sizeof(list_node));
1718 bal_indication_node->bal_indication = balIndCfg;
1719
1720 pthread_mutex_lock(&bal_ind_queue_lock);
1721 add_bal_indication_node(bal_indication_node);
1722 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301723 }
1724
1725 return result;
1726}
1727
1728/********************************************************************\
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301729 * Function : bal_oam_data_indication_cb *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301730 * Description : This function will handle the indications for *
1731 * OAM Data Response *
1732 * *
1733 ********************************************************************/
1734bcmos_errno bal_oam_data_indication_cb(bcmbal_obj *obj)
1735{
1736 bcmos_errno result = BCM_ERR_OK;
1737
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301738 if(BCMBAL_OBJ_ID_PACKET != obj->obj_type ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301739 bcmbal_packet_auto_id_ieee_oam_channel_rx != obj->subgroup)
1740 {
Kim Kempfafa1ab42017-11-13 09:31:47 -08001741 ASFVOLT_LOG(ASFVOLT_ERROR, "Processing BAL API '%s' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301742 bcmbal_objtype_str(obj->obj_type), bcmos_strerror(obj->status));
1743 result = BCM_ERR_INTERNAL;
1744 }
1745 else
1746 {
VoLTHA753536e2017-11-02 20:15:09 +05301747 BalIndications *balIndCfg;
1748 balIndCfg = malloc(sizeof(BalIndications));
1749 memset(balIndCfg, 0, sizeof(BalIndications));
1750 bal_indications__init(balIndCfg);
1751 balIndCfg->u_case = BAL_INDICATIONS__U_BAL_OAM_RESP;
1752 balIndCfg->has_objtype = BAL_GRPC_PRES;
1753 balIndCfg->objtype = obj->obj_type;
1754 balIndCfg->has_sub_group = BAL_GRPC_PRES;
1755 balIndCfg->sub_group = obj->subgroup;
1756 balIndCfg->device_id = voltha_device_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301757
VoLTHA753536e2017-11-02 20:15:09 +05301758 BalPacketIeeeOamChannelRx *oamChannel;
1759 oamChannel = malloc(sizeof(BalPacketIeeeOamChannelRx));
1760 memset(oamChannel, 0, sizeof(BalPacketIeeeOamChannelRx));
1761 bal_packet_ieee_oam_channel_rx__init(oamChannel);
1762 balIndCfg->baloamresp = oamChannel;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301763
Girish Gowdru9ebd8b22018-09-26 03:21:03 -07001764 /*'hdr' field is not parsed by voltha adapter, hence not filled */
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301765
VoLTHA753536e2017-11-02 20:15:09 +05301766 BalPacketKey *packetkey;
1767 packetkey = malloc(sizeof(BalPacketKey));
1768 memset(packetkey, 0, sizeof(BalPacketKey));
1769 bal_packet_key__init(packetkey);
1770 balIndCfg->baloamresp->key = packetkey;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301771
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301772 bcmbal_packet_ieee_oam_channel_rx *oam_channel =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301773 (bcmbal_packet_ieee_oam_channel_rx *)obj;
1774
VoLTHA753536e2017-11-02 20:15:09 +05301775 balIndCfg->baloamresp->key->has_reserved = BAL_GRPC_PRES;
1776 balIndCfg->baloamresp->key->reserved = oam_channel->key.reserved;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301777
VoLTHA753536e2017-11-02 20:15:09 +05301778 BalDest *PktSndDest;
1779 PktSndDest = malloc(sizeof(BalDest));
1780 memset(PktSndDest, 0, sizeof(BalDest));
1781 bal_dest__init(PktSndDest);
1782 balIndCfg->baloamresp->key->packet_send_dest = PktSndDest;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301783
VoLTHA753536e2017-11-02 20:15:09 +05301784 balIndCfg->baloamresp->key->packet_send_dest->has_type = BAL_GRPC_PRES;
1785 balIndCfg->baloamresp->key->packet_send_dest->type =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301786 oam_channel->key.packet_send_dest.type;
1787 switch( oam_channel->key.packet_send_dest.type)
1788 {
1789 case BCMBAL_DEST_TYPE_IEEE_OAM_CHANNEL:
1790 {
VoLTHA753536e2017-11-02 20:15:09 +05301791 balIndCfg->baloamresp->key->packet_send_dest->u_case = BAL_DEST__U_IEEE_OAM_CHANNEL;
1792 BalIeeeOamChannel *balOam;
1793 balOam = malloc(sizeof(BalIeeeOamChannel));
1794 memset(balOam, 0, sizeof(BalIeeeOamChannel));
1795 bal_ieee_oam_channel__init(balOam);
1796 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel = balOam;
1797 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->has_intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301798 BAL_GRPC_PRES;
VoLTHA753536e2017-11-02 20:15:09 +05301799 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->intf_id =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301800 oam_channel->key.packet_send_dest.u.ieee_oam_channel.intf_id;
VoLTHA753536e2017-11-02 20:15:09 +05301801 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->has_mac_address = BAL_GRPC_PRES;
1802 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len =
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301803 (BCMOS_ETH_ALEN)*sizeof(oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8);
VoLTHA753536e2017-11-02 20:15:09 +05301804 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.data =
1805 (uint8_t *)malloc((balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len)*sizeof(uint8_t));
1806 memcpy(balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.data,
Rajeswara Raob2e441c2017-09-20 16:40:21 +05301807 oam_channel->key.packet_send_dest.u.ieee_oam_channel.mac_address.u8,
VoLTHA753536e2017-11-02 20:15:09 +05301808 balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel->mac_address.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301809
1810 }
1811 break;
1812 default:
1813 {
VoLTHA753536e2017-11-02 20:15:09 +05301814 balIndCfg->baloamresp->key->packet_send_dest->u_case = BAL_DEST__U__NOT_SET;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301815 }
1816 break;
1817 }
1818
VoLTHA753536e2017-11-02 20:15:09 +05301819 BalPacketIeeeOamChannelRxData *oamData;
1820 oamData = malloc(sizeof(BalPacketIeeeOamChannelRxData));
1821 memset(oamData, 0, sizeof(BalPacketIeeeOamChannelRxData));
1822 bal_packet_ieee_oam_channel_rx_data__init(oamData);
1823 balIndCfg->baloamresp->data = oamData;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301824
VoLTHA753536e2017-11-02 20:15:09 +05301825 balIndCfg->baloamresp->data->pkt.len = oam_channel->data.pkt.len;
1826 balIndCfg->baloamresp->data->pkt.data = (uint8_t *)malloc((balIndCfg->baloamresp->data->pkt.len)*sizeof(uint8_t));
1827 memcpy(balIndCfg->baloamresp->data->pkt.data, oam_channel->data.pkt.val,
1828 balIndCfg->baloamresp->data->pkt.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301829
VoLTHA753536e2017-11-02 20:15:09 +05301830 list_node *bal_indication_node = malloc(sizeof(list_node));
1831 bal_indication_node->bal_indication = balIndCfg;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301832
VoLTHA753536e2017-11-02 20:15:09 +05301833 pthread_mutex_lock(&bal_ind_queue_lock);
1834 add_bal_indication_node(bal_indication_node);
1835 pthread_mutex_unlock(&bal_ind_queue_lock);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301836 }
1837
1838 return result;
1839}