blob: 078d6739262412bed5bc183efa683dfcb8a8c047 [file] [log] [blame]
Shad Ansari01b0e652018-04-05 21:02:53 +00001/*
Girish Gowdraa707e7c2019-11-07 11:36:13 +05302 * Copyright 2018-present Open Networking Foundation
Shad Ansari01b0e652018-04-05 21:02:53 +00003
Girish Gowdraa707e7c2019-11-07 11:36:13 +05304 * 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
Shad Ansari01b0e652018-04-05 21:02:53 +00007
Girish Gowdraa707e7c2019-11-07 11:36:13 +05308 * http://www.apache.org/licenses/LICENSE-2.0
Shad Ansari01b0e652018-04-05 21:02:53 +00009
Girish Gowdraa707e7c2019-11-07 11:36:13 +053010 * 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
Shad Ansari01b0e652018-04-05 21:02:53 +000017#include "indications.h"
Shad Ansarib7b0ced2018-05-11 21:53:32 +000018#include "core.h"
Girish Gowdraddf9a162020-01-27 12:56:27 +053019#include "core_data.h"
20#include "core_utils.h"
Nicolas Palpacuer0f19b1a2018-06-07 17:29:31 -040021#include "stats_collection.h"
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040022#include "translation.h"
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040023#include "state.h"
24
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040025#include <string>
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040026
Shad Ansari01b0e652018-04-05 21:02:53 +000027extern "C"
28{
29#include <bcmos_system.h>
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000030#include <bcmolt_api.h>
31#include <bcmolt_host_api.h>
32#include <bcmolt_api_model_api_structs.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000033}
34
35using grpc::Status;
36
Shad Ansari627b5782018-08-13 22:49:32 +000037extern Queue<openolt::Indication> oltIndQ;
Girish Gowdra96461052019-11-22 20:13:59 +053038extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map;
39extern bcmos_fastlock alloc_cfg_wait_lock;
Shad Ansari01b0e652018-04-05 21:02:53 +000040
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040041
Shad Ansari01b0e652018-04-05 21:02:53 +000042bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080043uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000044#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000045
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000046static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000047
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000048#define INTERFACE_STATE_IF_DOWN(state) \
49 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
50 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
51 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
52#define INTERFACE_STATE_IF_UP(state) \
53 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
54#define ONU_STATE_IF_DOWN(state) \
55 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
56 state == BCMOLT_ONU_OPERATION_DISABLE || \
57 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
58#define ONU_STATE_IF_UP(state) \
59 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053060#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000061 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053062#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000063 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
64#define SET_OPER_STATE(indication,state) \
65 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
66 indication->set_oper_state("down")
67#define GET_FLOW_TYPE(type) \
68 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
69 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
70 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
71
72std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000074 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050075 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000076 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050077 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000078 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
79 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050080 }
81 return "unknown";
82}
83
Jason Huang09b73ea2020-01-08 17:52:05 +080084std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000085{
Jason Huang09b73ea2020-01-08 17:52:05 +080086 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080088 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000089 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080090 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000091 return "host";
92 }
93 return "unknown";
94}
95
96/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -070097 bcmbal_subscriber_terminal_key key;
98 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
99 uint8_t *list_mem;// to fetch config details for ONU
100 bcmos_errno err = BCM_ERR_OK;
101
102 key.sub_term_id =onu_id;
103 key.intf_id = intf_id;
104 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
105
106 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
107
108 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
109 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
110 memset(reg_id, '\0', MAX_REGID_LENGTH);
111
112 //set memory to use for variable-sized lists
113 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
114
115 if (list_mem == NULL)
116 {
117 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
118 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
119 return reg_id;
120 }
121
122 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
123 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
124
125 //call API
126 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
127
128 if (err != BCM_ERR_OK)
129 {
130 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
131 key.sub_term_id, key.intf_id);
132 free(list_mem);
133 return reg_id;
134 }
135
136 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
137 key.sub_term_id, key.intf_id);
138
139 for (int i=0; i<MAX_REGID_LENGTH ; i++){
140 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
141 }
142
143 free(list_mem);
144 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000145}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700146
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000147static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000148 openolt::Indication ind;
149 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500150 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500151
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000152 switch (msg->subgroup) {
153 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
154 admin_state = "up";
155 olt_ind->set_oper_state("up");
156 break;
157 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
158 admin_state = "down";
159 olt_ind->set_oper_state("down");
160 break;
161 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
162 admin_state = "failure";
163 olt_ind->set_oper_state("failure");
164 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000165 }
166 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500167
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000168 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
169 /* register for omci indication */
170 {
171 bcmolt_rx_cfg rx_cfg = {};
172 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
173 rx_cfg.rx_cb = OmciIndication;
174 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
175 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
176 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000177 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500178 state.activate();
179 }
180 else {
181 state.deactivate();
182 }
183
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000184 oltIndQ.push(ind);
185 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000186}
187
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000188static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000189 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400190 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
191 openolt::LosIndication* los_ind = new openolt::LosIndication;
192
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000193 switch (msg->obj_type) {
194 case BCMOLT_OBJ_ID_PON_INTERFACE:
195 switch (msg->subgroup) {
196 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
197 {
198 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
199 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
200 BCMOLT_INTERFACE_TYPE_PON);
201 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400202
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530203 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000204 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400205
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000206 los_ind->set_intf_id(intf_id);
207 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400208
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000209 alarm_ind->set_allocated_los_ind(los_ind);
210 ind.set_allocated_alarm_ind(alarm_ind);
211 break;
212 }
213 }
214 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400215
216 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000217 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000218}
219
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000220static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700221 openolt::Indication ind;
222 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
223
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530224 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000225 case BCMOLT_OBJ_ID_PON_INTERFACE:
226 switch (msg->subgroup) {
227 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530228 {
229 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000230 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530231 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000232 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700233
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000234 intf_ind->set_intf_id(key->pon_ni);
235 SET_OPER_STATE(intf_ind, data->new_state);
236 ind.set_allocated_intf_ind(intf_ind);
237 break;
238 }
239 }
240 break;
241 case BCMOLT_OBJ_ID_NNI_INTERFACE:
242 switch (msg->subgroup) {
243 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
244 {
245 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
246 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530247 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000248 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530249 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000250 &((bcmolt_nni_interface_state_change *)msg)->data;
251
252 intf_ind->set_intf_id(key->id);
253 SET_OPER_STATE(intf_ind, data->new_state);
254 ind.set_allocated_intf_ind(intf_ind);
255 break;
256 }
257 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700258 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700259
260 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000261 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700262}
263
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000264static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000265 openolt::Indication ind;
266 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000267
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000268 switch (msg->obj_type) {
269 case BCMOLT_OBJ_ID_PON_INTERFACE:
270 switch (msg->subgroup) {
271 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
272 {
273 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
274 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
275 intf_oper_ind->set_intf_id(key->pon_ni);
276 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
277 SET_OPER_STATE(intf_oper_ind, data->new_state);
278 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
279 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
280 ind.set_allocated_intf_oper_ind(intf_oper_ind);
281 break;
282 }
283 }
284 case BCMOLT_OBJ_ID_NNI_INTERFACE:
285 switch (msg->subgroup) {
286 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
287 {
288 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
289 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
290 bcmolt_interface intf_id = key->id;
291 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
292 intf_oper_ind->set_intf_id(key->id);
293 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530294 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000295 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
296 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
297 ind.set_allocated_intf_oper_ind(intf_oper_ind);
298 break;
299 }
300 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000301 }
302
Shad Ansari01b0e652018-04-05 21:02:53 +0000303 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000304 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000305}
306
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000307static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000308 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400309 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
310 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
311
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000312 switch (msg->obj_type) {
313 case BCMOLT_OBJ_ID_ONU:
314 switch (msg->subgroup) {
315 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
316 {
Jason Huang93430532020-02-04 17:16:02 +0800317 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
318 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
319 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
320 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
321 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
322 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
323 onu_alarm_ind->set_intf_id(key->pon_ni);
324 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000325 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
326 ind.set_allocated_alarm_ind(alarm_ind);
327 break;
328 }
329 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
330 {
Jason Huang93430532020-02-04 17:16:02 +0800331 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
332 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
333 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
334 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
335 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
336 onu_alarm_ind->set_intf_id(key->pon_ni);
337 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000338 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
339 ind.set_allocated_alarm_ind(alarm_ind);
340 break;
341 }
342 }
343 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400344
345 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000346 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000347}
348
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000349static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000350 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400351 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000352 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400353
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000354 switch (msg->obj_type) {
355 case BCMOLT_OBJ_ID_ONU:
356 switch (msg->subgroup) {
357 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
358 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500359 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500360 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
361
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500362 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500363 dgi_ind->set_intf_id(key->pon_ni);
364 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400365
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000366 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
367 ind.set_allocated_alarm_ind(alarm_ind);
368 break;
369 }
370 }
371 }
nickc063ffd2018-05-22 14:35:28 -0400372
373 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000374 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000375}
376
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000377static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000378 openolt::Indication ind;
379 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
380 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
381
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000382 switch (msg->obj_type) {
383 case BCMOLT_OBJ_ID_PON_INTERFACE:
384 switch (msg->subgroup) {
385 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
386 {
387 bcmolt_pon_interface_key *key =
388 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000389
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530390 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000391 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000392
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000393 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000394
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000395 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
396 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000397
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000398 onu_disc_ind->set_intf_id(key->pon_ni);
399 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
400 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
401 onu_disc_ind->set_allocated_serial_number(serial_number);
402 ind.set_allocated_onu_disc_ind(onu_disc_ind);
403 break;
404 }
405 }
406 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000407
408 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000409 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000410}
411
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000412static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000413 openolt::Indication ind;
414 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000415
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000416 switch (msg->obj_type) {
417 case BCMOLT_OBJ_ID_ONU:
418 switch (msg->subgroup) {
419 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
420 {
421 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
422 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000423
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530424 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000425 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000426
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000427 omci_ind->set_intf_id(key->pon_ni);
428 omci_ind->set_onu_id(key->onu_id);
429 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
430
431 ind.set_allocated_omci_ind(omci_ind);
432 break;
433 }
434 }
435 }
436
Shad Ansari01b0e652018-04-05 21:02:53 +0000437 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000438 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000439}
440
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000441static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000442 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000443 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000444
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000445 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800446 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000447 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800448 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000449 {
Jason Huang09b73ea2020-01-08 17:52:05 +0800450 bcmolt_access_control_receive_eth_packet *pkt =
451 (bcmolt_access_control_receive_eth_packet*)msg;
452 bcmolt_access_control_receive_eth_packet_data *pkt_data =
453 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000454
Jason Huang09b73ea2020-01-08 17:52:05 +0800455 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
456 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
457 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000458 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800459 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000460 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500461
Jason Huang09b73ea2020-01-08 17:52:05 +0800462 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
463 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
464 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
465 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
466 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
467 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
468 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000469 }
470 }
471 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500472
Shad Ansari5fe93682018-04-26 05:24:19 +0000473 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000474 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000475}
476
Girish Gowdra96461052019-11-22 20:13:59 +0530477static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
478
479 switch (msg->obj_type) {
480 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
481 switch (msg->subgroup) {
482 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
483 {
484 bcmolt_itupon_alloc_configuration_completed *pkt =
485 (bcmolt_itupon_alloc_configuration_completed*)msg;
486 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
487 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
488
489 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
490 alloc_cfg_complete_result res;
491 res.pon_intf_id = pkt->key.pon_ni;
492 res.alloc_id = pkt->key.alloc_id;
493
494 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
495 switch (pkt_data->new_state) {
496 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
497 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
498 break;
499 case BCMOLT_ACTIVATION_STATE_INACTIVE:
500 res.state = ALLOC_OBJECT_STATE_INACTIVE;
501 break;
502 case BCMOLT_ACTIVATION_STATE_PROCESSING:
503 res.state = ALLOC_OBJECT_STATE_PROCESSING;
504 break;
505 case BCMOLT_ACTIVATION_STATE_ACTIVE:
506 res.state = ALLOC_OBJECT_STATE_ACTIVE;
507 break;
508 default:
509 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
510 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
511 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
512 }
513 OPENOLT_LOG(INFO, openolt_log_id, "received itu pon alloc cfg complete ind, pon intf %u, alloc_id %u, status %u, new_state %u\n",
514 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
515
516 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
517 // Push the result from BAL to queue
518 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
519 if (it == alloc_cfg_compltd_map.end()) {
520 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
521 bcmolt_msg_free(msg);
522 OPENOLT_LOG(ERROR, openolt_log_id, "alloc config key not found for alloc_id = %u, pon_intf = %u\n", pkt->key.alloc_id, pkt->key.pon_ni);
523 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
524 return;
525 }
526 if (it->second) {
527 // Push the result
528 it->second->push(res);
529 }
530 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
531 }
532 }
533 }
534
535 bcmolt_msg_free(msg);
536}
537
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000538static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000539 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000540 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
541 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000542}
543
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000544static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000545 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000546 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
547 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000548}
549
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000550static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000551 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000552 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
553 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000554}
555
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000556static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000557 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000558 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
559 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000560}
561
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000562static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000563 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000564 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
565 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000566}
567
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000568static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400569 openolt::Indication ind;
570 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
571 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
572
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000573 switch (msg->obj_type) {
574 case BCMOLT_OBJ_ID_ONU:
575 switch (msg->subgroup) {
576 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
577 {
578 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
579 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400580
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000581 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
582 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400583
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000584 sufi_ind->set_intf_id(key->pon_ni);
585 sufi_ind->set_onu_id(key->onu_id);
586 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
587 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400588
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000589 ind.set_allocated_alarm_ind(alarm_ind);
590 }
591 }
592 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400593
594 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000595 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400596}
597
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000598static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400599 openolt::Indication ind;
600 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
601 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
602
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000603 switch (msg->obj_type) {
604 case BCMOLT_OBJ_ID_ONU:
605 switch (msg->subgroup) {
606 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
607 {
608 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
609 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400610
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000611 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
612 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400613
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000614 sdi_ind->set_intf_id(key->pon_ni);
615 sdi_ind->set_onu_id(key->onu_id);
616 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
617 sdi_ind->set_inverse_bit_error_rate(data->ber);
618 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400619
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000620 ind.set_allocated_alarm_ind(alarm_ind);
621 }
622 }
623 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400624
625 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000626 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400627}
628
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000629static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400630 openolt::Indication ind;
631 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
632 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
633
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000634 switch (msg->obj_type) {
635 case BCMOLT_OBJ_ID_ONU:
636 switch (msg->subgroup) {
637 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
638 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530639 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000640 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400641
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000642 OPENOLT_LOG(WARNING, openolt_log_id, "onu drift of window indication, intf_id %d, onu_id %d, alarm %d, drift %d, new_eqd %d\n",
643 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000645 dowi_ind->set_intf_id(key->pon_ni);
646 dowi_ind->set_onu_id(key->onu_id);
647 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
648 dowi_ind->set_drift(data->drift_value);
649 dowi_ind->set_new_eqd(data->new_eqd);
650 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400651
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000652 ind.set_allocated_alarm_ind(alarm_ind);
653 }
654 }
655 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400656
657 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000658 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400659}
660
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000661static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400662 openolt::Indication ind;
663 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
664 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
665
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000666 switch (msg->obj_type) {
667 case BCMOLT_OBJ_ID_ONU:
668 switch (msg->subgroup) {
669 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
670 {
671 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
672 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400673
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000674 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
675 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400676
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000677 looci_ind->set_intf_id(key->pon_ni);
678 looci_ind->set_onu_id(key->onu_id);
679 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
680 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400681
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000682 ind.set_allocated_alarm_ind(alarm_ind);
683 }
684 }
685 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400686
687 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000688 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400689}
690
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000691static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400692 openolt::Indication ind;
693 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
694 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
695
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000696 switch (msg->obj_type) {
697 case BCMOLT_OBJ_ID_ONU:
698 switch (msg->subgroup) {
699 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
700 {
701 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
702 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400703
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000704 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
705 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000707 sfi_ind->set_intf_id(key->pon_ni);
708 sfi_ind->set_onu_id(key->onu_id);
709 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
710 sfi_ind->set_inverse_bit_error_rate(data->ber);
711 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400712
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000713 ind.set_allocated_alarm_ind(alarm_ind);
714 }
715 }
716 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400717
718 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000719 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400720}
721
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000722static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400723 openolt::Indication ind;
724 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
725 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
726
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000727 switch (msg->obj_type) {
728 case BCMOLT_OBJ_ID_ONU:
729 switch (msg->subgroup) {
730 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
731 {
732 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
733 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400734
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000735 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
736 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400737
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000738 tiwi_ind->set_intf_id(key->pon_ni);
739 tiwi_ind->set_onu_id(key->onu_id);
740 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
741 tiwi_ind->set_drift(data->drift_value);
742 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400743
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000744 ind.set_allocated_alarm_ind(alarm_ind);
745 }
746 }
747 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400748
749 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000750 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400751}
752
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530753static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400754 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530755 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
756
757 switch (msg->obj_type) {
758 case BCMOLT_OBJ_ID_ONU:
759 switch (msg->subgroup) {
760 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
761 {
762 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
763 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
764
765 onu_ind->set_intf_id(key->pon_ni);
766 onu_ind->set_onu_id(key->onu_id);
767 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
768 onu_ind->set_oper_state("up");
769 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
770 onu_ind->set_oper_state("down");
771 // Setting the admin_state state field based on a valid onu_id does not make any sense.
772 // The adapter too does not seem to interpret this seriously.
773 // Legacy code, lets keep this as is for now.
774 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
775 ind.set_allocated_onu_ind(onu_ind);
776 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
777 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
778 (key->onu_id)?"up":"down");
779 }
780 }
781 }
782
783 oltIndQ.push(ind);
784 bcmolt_msg_free(msg);
785}
786
Jason Huang93430532020-02-04 17:16:02 +0800787static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
788 openolt::Indication ind;
789 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
790 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
791
792 switch (msg->obj_type) {
793 case BCMOLT_OBJ_ID_ONU:
794 switch (msg->subgroup) {
795 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
796 {
797 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
798 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
799
800 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
801 key->pon_ni, key->onu_id, data->alarm_status);
802
803 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
804 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
805 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
806 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
807
808 ind.set_allocated_alarm_ind(alarm_ind);
809 }
810 }
811 }
812
813 oltIndQ.push(ind);
814 bcmolt_msg_free(msg);
815}
816
817static void OnuItuPonStatsIndication(bcmolt_devid olt, bcmolt_msg *msg) {
818 openolt::Indication ind;
819 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
820 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
821
822 switch (msg->obj_type) {
823 case BCMOLT_OBJ_ID_ONU:
824 switch (msg->subgroup) {
825 case BCMOLT_ONU_STAT_SUBGROUP_ITU_PON_STATS:
826 {
827 bcmolt_onu_key *key = &((bcmolt_onu_itu_pon_stats*)msg)->key;
828 bcmolt_onu_itu_pon_stats_data *data = &((bcmolt_onu_itu_pon_stats*)msg)->data;
829
830 OPENOLT_LOG(INFO, openolt_log_id, "Got onu rdi erros, intf_id %d, onu_id %d, rdi_errors %"PRIu64"\n",
831 key->pon_ni, key->onu_id, data->rdi_errors);
832
833 onu_itu_pon_stats_ind->set_intf_id(key->pon_ni);
834 onu_itu_pon_stats_ind->set_onu_id(key->onu_id);
835 onu_itu_pon_stats_ind->set_rdi_errors(data->rdi_errors);
836 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
837
838 ind.set_allocated_alarm_ind(alarm_ind);
839 }
840 }
841 }
842
843 oltIndQ.push(ind);
844 bcmolt_msg_free(msg);
845}
846
847
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530848
849static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
850 openolt::Indication ind;
851
852 openolt::Indication onu_ind;
853 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400854
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000855 switch (msg->obj_type) {
856 case BCMOLT_OBJ_ID_ONU:
857 switch (msg->subgroup) {
858 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
859 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530860 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
861 bcmolt_onu_onu_deactivation_completed_data *data =
862 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400863
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530864 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
865 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400866
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530867 onu_ind_data->set_intf_id(key->pon_ni);
868 onu_ind_data->set_onu_id(key->onu_id);
869 onu_ind_data->set_oper_state("down");
870 onu_ind_data->set_admin_state("down");
871 onu_ind.set_allocated_onu_ind(onu_ind_data);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000872 }
873 }
874 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400875
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530876 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000877 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400878}
879
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000880/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400881bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
882 openolt::Indication ind;
883 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
884 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
885
886 bcmbal_subscriber_terminal_key *key =
887 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
888
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000889 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400890 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400891
892
893 onu_proc_error_ind->set_intf_id(key->intf_id);
894 onu_proc_error_ind->set_onu_id(key->sub_term_id);
895
896 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
897 ind.set_allocated_alarm_ind(alarm_ind);
898
899 oltIndQ.push(ind);
900 return BCM_ERR_OK;
901}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000902*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400903
Burak Gurdagc78b9e12019-11-29 11:14:51 +0000904static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
905
906 switch (msg->obj_type) {
907 case BCMOLT_OBJ_ID_GROUP:
908 switch (msg->subgroup) {
909 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
910 {
911 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
912 bcmolt_group_complete_members_update_data *data =
913 &((bcmolt_group_complete_members_update*)msg)->data;
914
915 if (data->result == BCMOLT_RESULT_SUCCESS) {
916 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
917 } else {
918 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
919 }
920 }
921 }
922 }
923 bcmolt_msg_free(msg);
924}
925
Shad Ansari01b0e652018-04-05 21:02:53 +0000926Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000927 bcmolt_rx_cfg rx_cfg = {};
928 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000929
930 if (subscribed) {
931 return Status::OK;
932 }
933
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000934 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
935 rx_cfg.rx_cb = OltOperIndication;
936 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
937 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
938 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
939 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530940 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000941 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000942
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000943 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
944 rx_cfg.rx_cb = OltOperIndication;
945 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
946 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
947 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
948 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530949 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000950 "Olt disconnection complete state indication subscribe failed");
951
952 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
953 rx_cfg.rx_cb = OltOperIndication;
954 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
955 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
956 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
957 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530958 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000959 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000960
961 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000962 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
963 rx_cfg.rx_cb = LosIndication;
964 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
965 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
966 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
967 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000968 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000969
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000970 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
971 rx_cfg.rx_cb = IfOperIndication;
972 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
973 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
974 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
975 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530976 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000977 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700978
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000979 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
980 rx_cfg.rx_cb = IfOperIndication;
981 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
982 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
983 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
984 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530985 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000986 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000987
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000988 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
989 rx_cfg.rx_cb = OnuAlarmIndication;
990 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
991 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
992 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
993 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000994 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000995
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000996 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
997 rx_cfg.rx_cb = OnuAlarmIndication;
998 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
999 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1000 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1001 if(rc != BCM_ERR_OK)
1002 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1003
1004 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1005 rx_cfg.rx_cb = OnuDyingGaspIndication;
1006 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1007 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1008 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1009 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001010 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001011
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001012 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1013 rx_cfg.rx_cb = OnuDiscoveryIndication;
1014 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1015 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1016 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1017 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001018 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001019
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001020 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001021 rx_cfg.rx_cb = OnuStartupFailureIndication;
1022 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1023 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1024 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1025 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301026 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001027 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001028
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001029 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1030 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1031 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1032 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1033 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1034 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001035 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001036
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001037 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1038 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1039 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1040 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1041 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1042 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001043 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001044
1045 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001046 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1047 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1048 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1049 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1050 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1051 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001052 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001053
1054 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001055 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1056 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1057 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1058 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1059 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1060 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001061 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001062
1063 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001064 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1065 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1066 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1067 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1068 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1069 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001070 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001071
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301072 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001073 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301074 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1075 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1076 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1077 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1078 if(rc != BCM_ERR_OK)
1079 return Status(grpc::StatusCode::INTERNAL,
1080 "onu activation completed indication subscribe failed");
1081
1082 /* ONU Deactivation Completed Indication */
1083 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1084 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001085 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1086 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1087 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1088 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301089 return Status(grpc::StatusCode::INTERNAL,
1090 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001091
Jason Huang93430532020-02-04 17:16:02 +08001092 /* ONU Loss of Key Sync Indiction */
1093 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1094 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1095 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1096 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1097 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1098 if(rc != BCM_ERR_OK)
1099 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1100
1101 /* ONU ITU-PON Stats Indiction */
1102 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1103 rx_cfg.rx_cb = OnuItuPonStatsIndication;
1104 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1105 rx_cfg.subgroup = bcmolt_onu_stat_subgroup_itu_pon_stats;
1106 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1107 if(rc != BCM_ERR_OK)
1108 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon stats indication subscribe failed");
1109
Jason Huang09b73ea2020-01-08 17:52:05 +08001110 /* Packet-In by Access_Control */
1111 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001112 rx_cfg.rx_cb = PacketIndication;
1113 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001114 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001115 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1116 if(rc != BCM_ERR_OK)
1117 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001118
Girish Gowdra96461052019-11-22 20:13:59 +05301119 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1120 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1121 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1122 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1123 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1124 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001125 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301126
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001127 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1128 rx_cfg.rx_cb = GroupIndication;
1129 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1130 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1131 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1132 if(rc != BCM_ERR_OK)
1133 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1134
Shad Ansari01b0e652018-04-05 21:02:53 +00001135 subscribed = true;
1136
1137 return Status::OK;
1138}