blob: c9f112eb94aabd3de9cd45af2b05fb6c855a6689 [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"
Shad Ansari01b0e652018-04-05 21:02:53 +000019#include "utils.h"
Nicolas Palpacuer0f19b1a2018-06-07 17:29:31 -040020#include "stats_collection.h"
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040021#include "translation.h"
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040022#include "state.h"
23
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040024#include <string>
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040025
Shad Ansari01b0e652018-04-05 21:02:53 +000026extern "C"
27{
28#include <bcmos_system.h>
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000029#include <bcmolt_api.h>
30#include <bcmolt_host_api.h>
31#include <bcmolt_api_model_api_structs.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000032}
33
34using grpc::Status;
35
Shad Ansari627b5782018-08-13 22:49:32 +000036extern Queue<openolt::Indication> oltIndQ;
Girish Gowdra96461052019-11-22 20:13:59 +053037extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map;
38extern bcmos_fastlock alloc_cfg_wait_lock;
Shad Ansari01b0e652018-04-05 21:02:53 +000039
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040040
Shad Ansari01b0e652018-04-05 21:02:53 +000041bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080042uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000043#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000044
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000045static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000046
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000047#define INTERFACE_STATE_IF_DOWN(state) \
48 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
49 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
50 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
51#define INTERFACE_STATE_IF_UP(state) \
52 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
53#define ONU_STATE_IF_DOWN(state) \
54 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
55 state == BCMOLT_ONU_OPERATION_DISABLE || \
56 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
57#define ONU_STATE_IF_UP(state) \
58 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053059#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000060 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053061#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000062 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
63#define SET_OPER_STATE(indication,state) \
64 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
65 indication->set_oper_state("down")
66#define GET_FLOW_TYPE(type) \
67 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
68 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
69 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
70
71std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050072{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000073 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050074 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000075 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050076 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000077 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
78 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050079 }
80 return "unknown";
81}
82
Jason Huang09b73ea2020-01-08 17:52:05 +080083std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000084{
Jason Huang09b73ea2020-01-08 17:52:05 +080085 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000086 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080087 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000088 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080089 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000090 return "host";
91 }
92 return "unknown";
93}
94
95/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -070096 bcmbal_subscriber_terminal_key key;
97 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
98 uint8_t *list_mem;// to fetch config details for ONU
99 bcmos_errno err = BCM_ERR_OK;
100
101 key.sub_term_id =onu_id;
102 key.intf_id = intf_id;
103 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
104
105 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
106
107 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
108 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
109 memset(reg_id, '\0', MAX_REGID_LENGTH);
110
111 //set memory to use for variable-sized lists
112 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
113
114 if (list_mem == NULL)
115 {
116 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
117 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
118 return reg_id;
119 }
120
121 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
122 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
123
124 //call API
125 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
126
127 if (err != BCM_ERR_OK)
128 {
129 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
130 key.sub_term_id, key.intf_id);
131 free(list_mem);
132 return reg_id;
133 }
134
135 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
136 key.sub_term_id, key.intf_id);
137
138 for (int i=0; i<MAX_REGID_LENGTH ; i++){
139 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
140 }
141
142 free(list_mem);
143 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000144}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700145
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000146static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000147 openolt::Indication ind;
148 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500149 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500150
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000151 switch (msg->subgroup) {
152 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
153 admin_state = "up";
154 olt_ind->set_oper_state("up");
155 break;
156 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
157 admin_state = "down";
158 olt_ind->set_oper_state("down");
159 break;
160 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
161 admin_state = "failure";
162 olt_ind->set_oper_state("failure");
163 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000164 }
165 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500166
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000167 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
168 /* register for omci indication */
169 {
170 bcmolt_rx_cfg rx_cfg = {};
171 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
172 rx_cfg.rx_cb = OmciIndication;
173 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
174 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
175 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000176 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500177 state.activate();
178 }
179 else {
180 state.deactivate();
181 }
182
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000183 oltIndQ.push(ind);
184 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000185}
186
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000187static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000188 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400189 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
190 openolt::LosIndication* los_ind = new openolt::LosIndication;
191
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000192 switch (msg->obj_type) {
193 case BCMOLT_OBJ_ID_PON_INTERFACE:
194 switch (msg->subgroup) {
195 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
196 {
197 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
198 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
199 BCMOLT_INTERFACE_TYPE_PON);
200 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400201
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530202 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000203 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400204
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000205 los_ind->set_intf_id(intf_id);
206 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400207
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000208 alarm_ind->set_allocated_los_ind(los_ind);
209 ind.set_allocated_alarm_ind(alarm_ind);
210 break;
211 }
212 }
213 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400214
215 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000216 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000217}
218
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000219static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700220 openolt::Indication ind;
221 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
222
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530223 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000224 case BCMOLT_OBJ_ID_PON_INTERFACE:
225 switch (msg->subgroup) {
226 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530227 {
228 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000229 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530230 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000231 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700232
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000233 intf_ind->set_intf_id(key->pon_ni);
234 SET_OPER_STATE(intf_ind, data->new_state);
235 ind.set_allocated_intf_ind(intf_ind);
236 break;
237 }
238 }
239 break;
240 case BCMOLT_OBJ_ID_NNI_INTERFACE:
241 switch (msg->subgroup) {
242 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
243 {
244 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
245 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530246 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000247 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530248 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000249 &((bcmolt_nni_interface_state_change *)msg)->data;
250
251 intf_ind->set_intf_id(key->id);
252 SET_OPER_STATE(intf_ind, data->new_state);
253 ind.set_allocated_intf_ind(intf_ind);
254 break;
255 }
256 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700257 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700258
259 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000260 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700261}
262
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000263static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000264 openolt::Indication ind;
265 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000266
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000267 switch (msg->obj_type) {
268 case BCMOLT_OBJ_ID_PON_INTERFACE:
269 switch (msg->subgroup) {
270 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
271 {
272 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
273 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
274 intf_oper_ind->set_intf_id(key->pon_ni);
275 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
276 SET_OPER_STATE(intf_oper_ind, data->new_state);
277 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
278 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
279 ind.set_allocated_intf_oper_ind(intf_oper_ind);
280 break;
281 }
282 }
283 case BCMOLT_OBJ_ID_NNI_INTERFACE:
284 switch (msg->subgroup) {
285 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
286 {
287 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
288 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
289 bcmolt_interface intf_id = key->id;
290 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
291 intf_oper_ind->set_intf_id(key->id);
292 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530293 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000294 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
295 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
296 ind.set_allocated_intf_oper_ind(intf_oper_ind);
297 break;
298 }
299 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000300 }
301
Shad Ansari01b0e652018-04-05 21:02:53 +0000302 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000303 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000304}
305
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000306static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000307 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400308 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
309 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
310
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000311 switch (msg->obj_type) {
312 case BCMOLT_OBJ_ID_ONU:
313 switch (msg->subgroup) {
314 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
315 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530316 bcmolt_xgpon_onu_alarms *onu_alarms =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000317 &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
318 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
319 onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
320 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
321 onu_alarms->lopci_miss));
322 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
323 onu_alarms->lopci_mic_error));
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400324
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 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530331 bcmolt_gpon_onu_alarms *onu_alarms =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000332 &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
333 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530334 /* TODO: need to set lofi and loami
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000335 onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
336 onu_alarm_ind->set_loami_status(alarm_status_to_string(
337 onu_alarms->loami));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530338 */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000339 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
340 ind.set_allocated_alarm_ind(alarm_ind);
341 break;
342 }
343 }
344 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400345
346 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000347 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000348}
349
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000350static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000351 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400352 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000353 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400354
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000355 switch (msg->obj_type) {
356 case BCMOLT_OBJ_ID_ONU:
357 switch (msg->subgroup) {
358 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
359 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500360 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500361 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
362
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500363 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500364 dgi_ind->set_intf_id(key->pon_ni);
365 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400366
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000367 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
368 ind.set_allocated_alarm_ind(alarm_ind);
369 break;
370 }
371 }
372 }
nickc063ffd2018-05-22 14:35:28 -0400373
374 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000375 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000376}
377
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000378static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000379 openolt::Indication ind;
380 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
381 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
382
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000383 switch (msg->obj_type) {
384 case BCMOLT_OBJ_ID_PON_INTERFACE:
385 switch (msg->subgroup) {
386 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
387 {
388 bcmolt_pon_interface_key *key =
389 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000390
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530391 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000392 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000393
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000394 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000395
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000396 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
397 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000398
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000399 onu_disc_ind->set_intf_id(key->pon_ni);
400 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
401 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
402 onu_disc_ind->set_allocated_serial_number(serial_number);
403 ind.set_allocated_onu_disc_ind(onu_disc_ind);
404 break;
405 }
406 }
407 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000408
409 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000410 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000411}
412
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000413static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000414 openolt::Indication ind;
415 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000416
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000417 switch (msg->obj_type) {
418 case BCMOLT_OBJ_ID_ONU:
419 switch (msg->subgroup) {
420 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
421 {
422 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
423 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000424
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530425 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000426 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000427
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000428 omci_ind->set_intf_id(key->pon_ni);
429 omci_ind->set_onu_id(key->onu_id);
430 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
431
432 ind.set_allocated_omci_ind(omci_ind);
433 break;
434 }
435 }
436 }
437
Shad Ansari01b0e652018-04-05 21:02:53 +0000438 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000439 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000440}
441
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000442static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000443 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000444 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000445
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000446 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800447 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000448 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800449 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000450 {
Jason Huang09b73ea2020-01-08 17:52:05 +0800451 bcmolt_access_control_receive_eth_packet *pkt =
452 (bcmolt_access_control_receive_eth_packet*)msg;
453 bcmolt_access_control_receive_eth_packet_data *pkt_data =
454 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000455
Jason Huang09b73ea2020-01-08 17:52:05 +0800456 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
457 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
458 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000459 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800460 //pkt_ind->set_gemport_id(getPacketInGemPort(pkt->key.id));
461 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000462 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500463
Jason Huang09b73ea2020-01-08 17:52:05 +0800464 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
465 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
466 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
467 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
468 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
469 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
470 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000471 }
472 }
473 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500474
Shad Ansari5fe93682018-04-26 05:24:19 +0000475 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000476 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000477}
478
Girish Gowdra96461052019-11-22 20:13:59 +0530479static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
480
481 switch (msg->obj_type) {
482 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
483 switch (msg->subgroup) {
484 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
485 {
486 bcmolt_itupon_alloc_configuration_completed *pkt =
487 (bcmolt_itupon_alloc_configuration_completed*)msg;
488 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
489 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
490
491 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
492 alloc_cfg_complete_result res;
493 res.pon_intf_id = pkt->key.pon_ni;
494 res.alloc_id = pkt->key.alloc_id;
495
496 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
497 switch (pkt_data->new_state) {
498 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
499 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
500 break;
501 case BCMOLT_ACTIVATION_STATE_INACTIVE:
502 res.state = ALLOC_OBJECT_STATE_INACTIVE;
503 break;
504 case BCMOLT_ACTIVATION_STATE_PROCESSING:
505 res.state = ALLOC_OBJECT_STATE_PROCESSING;
506 break;
507 case BCMOLT_ACTIVATION_STATE_ACTIVE:
508 res.state = ALLOC_OBJECT_STATE_ACTIVE;
509 break;
510 default:
511 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
512 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
513 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
514 }
515 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",
516 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
517
518 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
519 // Push the result from BAL to queue
520 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
521 if (it == alloc_cfg_compltd_map.end()) {
522 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
523 bcmolt_msg_free(msg);
524 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);
525 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
526 return;
527 }
528 if (it->second) {
529 // Push the result
530 it->second->push(res);
531 }
532 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
533 }
534 }
535 }
536
537 bcmolt_msg_free(msg);
538}
539
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000540static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000541 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000542 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
543 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000544}
545
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000546static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000547 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000548 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
549 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000550}
551
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000552static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000553 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000554 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
555 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000556}
557
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000558static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000559 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000560 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
561 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000562}
563
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000564static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000565 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000566 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
567 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000568}
569
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000570static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400571 openolt::Indication ind;
572 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
573 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
574
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000575 switch (msg->obj_type) {
576 case BCMOLT_OBJ_ID_ONU:
577 switch (msg->subgroup) {
578 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
579 {
580 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
581 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400582
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000583 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
584 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400585
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000586 sufi_ind->set_intf_id(key->pon_ni);
587 sufi_ind->set_onu_id(key->onu_id);
588 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
589 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400590
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000591 ind.set_allocated_alarm_ind(alarm_ind);
592 }
593 }
594 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400595
596 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000597 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400598}
599
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000600static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400601 openolt::Indication ind;
602 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
603 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
604
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000605 switch (msg->obj_type) {
606 case BCMOLT_OBJ_ID_ONU:
607 switch (msg->subgroup) {
608 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
609 {
610 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
611 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400612
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000613 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
614 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400615
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000616 sdi_ind->set_intf_id(key->pon_ni);
617 sdi_ind->set_onu_id(key->onu_id);
618 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
619 sdi_ind->set_inverse_bit_error_rate(data->ber);
620 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400621
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000622 ind.set_allocated_alarm_ind(alarm_ind);
623 }
624 }
625 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400626
627 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000628 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400629}
630
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000631static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400632 openolt::Indication ind;
633 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
634 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
635
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000636 switch (msg->obj_type) {
637 case BCMOLT_OBJ_ID_ONU:
638 switch (msg->subgroup) {
639 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
640 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530641 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000642 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400643
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000644 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",
645 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400646
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000647 dowi_ind->set_intf_id(key->pon_ni);
648 dowi_ind->set_onu_id(key->onu_id);
649 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
650 dowi_ind->set_drift(data->drift_value);
651 dowi_ind->set_new_eqd(data->new_eqd);
652 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400653
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000654 ind.set_allocated_alarm_ind(alarm_ind);
655 }
656 }
657 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400658
659 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000660 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400661}
662
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000663static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400664 openolt::Indication ind;
665 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
666 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
667
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000668 switch (msg->obj_type) {
669 case BCMOLT_OBJ_ID_ONU:
670 switch (msg->subgroup) {
671 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
672 {
673 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
674 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400675
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000676 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
677 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400678
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000679 looci_ind->set_intf_id(key->pon_ni);
680 looci_ind->set_onu_id(key->onu_id);
681 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
682 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400683
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000684 ind.set_allocated_alarm_ind(alarm_ind);
685 }
686 }
687 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400688
689 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000690 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400691}
692
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000693static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400694 openolt::Indication ind;
695 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
696 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
697
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000698 switch (msg->obj_type) {
699 case BCMOLT_OBJ_ID_ONU:
700 switch (msg->subgroup) {
701 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
702 {
703 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
704 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400705
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000706 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
707 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400708
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000709 sfi_ind->set_intf_id(key->pon_ni);
710 sfi_ind->set_onu_id(key->onu_id);
711 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
712 sfi_ind->set_inverse_bit_error_rate(data->ber);
713 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400714
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000715 ind.set_allocated_alarm_ind(alarm_ind);
716 }
717 }
718 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400719
720 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000721 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400722}
723
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000724static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400725 openolt::Indication ind;
726 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
727 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
728
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000729 switch (msg->obj_type) {
730 case BCMOLT_OBJ_ID_ONU:
731 switch (msg->subgroup) {
732 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
733 {
734 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
735 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400736
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000737 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
738 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400739
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000740 tiwi_ind->set_intf_id(key->pon_ni);
741 tiwi_ind->set_onu_id(key->onu_id);
742 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
743 tiwi_ind->set_drift(data->drift_value);
744 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400745
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000746 ind.set_allocated_alarm_ind(alarm_ind);
747 }
748 }
749 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400750
751 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000752 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400753}
754
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530755static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400756 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530757 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
758
759 switch (msg->obj_type) {
760 case BCMOLT_OBJ_ID_ONU:
761 switch (msg->subgroup) {
762 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
763 {
764 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
765 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
766
767 onu_ind->set_intf_id(key->pon_ni);
768 onu_ind->set_onu_id(key->onu_id);
769 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
770 onu_ind->set_oper_state("up");
771 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
772 onu_ind->set_oper_state("down");
773 // Setting the admin_state state field based on a valid onu_id does not make any sense.
774 // The adapter too does not seem to interpret this seriously.
775 // Legacy code, lets keep this as is for now.
776 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
777 ind.set_allocated_onu_ind(onu_ind);
778 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
779 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
780 (key->onu_id)?"up":"down");
781 }
782 }
783 }
784
785 oltIndQ.push(ind);
786 bcmolt_msg_free(msg);
787}
788
789
790static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
791 openolt::Indication ind;
792
793 openolt::Indication onu_ind;
794 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400795
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000796 switch (msg->obj_type) {
797 case BCMOLT_OBJ_ID_ONU:
798 switch (msg->subgroup) {
799 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
800 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530801 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
802 bcmolt_onu_onu_deactivation_completed_data *data =
803 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400804
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530805 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
806 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400807
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530808 onu_ind_data->set_intf_id(key->pon_ni);
809 onu_ind_data->set_onu_id(key->onu_id);
810 onu_ind_data->set_oper_state("down");
811 onu_ind_data->set_admin_state("down");
812 onu_ind.set_allocated_onu_ind(onu_ind_data);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000813 }
814 }
815 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400816
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530817 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000818 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400819}
820
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000821/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400822bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
823 openolt::Indication ind;
824 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
825 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
826
827 bcmbal_subscriber_terminal_key *key =
828 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
829
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000830 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400831 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400832
833
834 onu_proc_error_ind->set_intf_id(key->intf_id);
835 onu_proc_error_ind->set_onu_id(key->sub_term_id);
836
837 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
838 ind.set_allocated_alarm_ind(alarm_ind);
839
840 oltIndQ.push(ind);
841 return BCM_ERR_OK;
842}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000843*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400844
Burak Gurdagc78b9e12019-11-29 11:14:51 +0000845static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
846
847 switch (msg->obj_type) {
848 case BCMOLT_OBJ_ID_GROUP:
849 switch (msg->subgroup) {
850 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
851 {
852 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
853 bcmolt_group_complete_members_update_data *data =
854 &((bcmolt_group_complete_members_update*)msg)->data;
855
856 if (data->result == BCMOLT_RESULT_SUCCESS) {
857 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
858 } else {
859 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
860 }
861 }
862 }
863 }
864 bcmolt_msg_free(msg);
865}
866
Shad Ansari01b0e652018-04-05 21:02:53 +0000867Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000868 bcmolt_rx_cfg rx_cfg = {};
869 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000870
871 if (subscribed) {
872 return Status::OK;
873 }
874
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000875 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
876 rx_cfg.rx_cb = OltOperIndication;
877 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
878 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
879 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
880 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530881 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000882 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000883
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000884 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
885 rx_cfg.rx_cb = OltOperIndication;
886 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
887 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
888 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
889 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530890 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000891 "Olt disconnection complete state indication subscribe failed");
892
893 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
894 rx_cfg.rx_cb = OltOperIndication;
895 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
896 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
897 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
898 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530899 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000900 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000901
902 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000903 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
904 rx_cfg.rx_cb = LosIndication;
905 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
906 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
907 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
908 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000909 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000910
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000911 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
912 rx_cfg.rx_cb = IfOperIndication;
913 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
914 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
915 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
916 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530917 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000918 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700919
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000920 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
921 rx_cfg.rx_cb = IfOperIndication;
922 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
923 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
924 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
925 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530926 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000927 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000928
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000929 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
930 rx_cfg.rx_cb = OnuAlarmIndication;
931 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
932 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
933 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
934 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000935 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000936
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000937 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
938 rx_cfg.rx_cb = OnuAlarmIndication;
939 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
940 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
941 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
942 if(rc != BCM_ERR_OK)
943 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
944
945 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
946 rx_cfg.rx_cb = OnuDyingGaspIndication;
947 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
948 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
949 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
950 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000951 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000952
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000953 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
954 rx_cfg.rx_cb = OnuDiscoveryIndication;
955 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
956 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
957 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
958 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000959 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000960
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000961 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000962 rx_cfg.rx_cb = OnuStartupFailureIndication;
963 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
964 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
965 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
966 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530967 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000968 "onu startup failure 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_ONU;
971 rx_cfg.rx_cb = OnuSignalDegradeIndication;
972 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
973 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
974 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
975 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400976 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400977
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000978 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
979 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
980 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
981 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
982 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
983 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400984 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400985
986 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000987 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
988 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
989 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
990 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
991 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
992 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400993 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400994
995 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000996 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
997 rx_cfg.rx_cb = OnuSignalsFailureIndication;
998 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
999 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1000 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1001 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001002 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001003
1004 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001005 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1006 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1007 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1008 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1009 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1010 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001011 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001012
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301013 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001014 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301015 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1016 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1017 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1018 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1019 if(rc != BCM_ERR_OK)
1020 return Status(grpc::StatusCode::INTERNAL,
1021 "onu activation completed indication subscribe failed");
1022
1023 /* ONU Deactivation Completed Indication */
1024 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1025 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001026 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1027 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1028 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1029 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301030 return Status(grpc::StatusCode::INTERNAL,
1031 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001032
Jason Huang09b73ea2020-01-08 17:52:05 +08001033 /* Packet-In by Access_Control */
1034 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001035 rx_cfg.rx_cb = PacketIndication;
1036 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001037 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001038 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1039 if(rc != BCM_ERR_OK)
1040 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001041
Girish Gowdra96461052019-11-22 20:13:59 +05301042 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1043 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1044 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1045 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1046 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1047 if(rc != BCM_ERR_OK)
1048 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration \
1049Complete Indication subscribe failed");
1050
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001051 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1052 rx_cfg.rx_cb = GroupIndication;
1053 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1054 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1055 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1056 if(rc != BCM_ERR_OK)
1057 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1058
Shad Ansari01b0e652018-04-05 21:02:53 +00001059 subscribed = true;
1060
1061 return Status::OK;
1062}