blob: 11648ddd5017db3ef61168f5c4b494e36ad14ea4 [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"
Orhan Kupusogluec57af02021-05-12 12:38:17 +000024#include "trx_eeprom_reader.h"
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040025
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040026#include <string>
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040027
Shad Ansari01b0e652018-04-05 21:02:53 +000028extern "C"
29{
30#include <bcmos_system.h>
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000031#include <bcmolt_api.h>
32#include <bcmolt_host_api.h>
33#include <bcmolt_api_model_api_structs.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000034}
35
36using grpc::Status;
37
Shad Ansari01b0e652018-04-05 21:02:53 +000038bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080039uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000040#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000041
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000042static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000043
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000044#define INTERFACE_STATE_IF_DOWN(state) \
45 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
46 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
47 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
48#define INTERFACE_STATE_IF_UP(state) \
49 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
50#define ONU_STATE_IF_DOWN(state) \
51 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
52 state == BCMOLT_ONU_OPERATION_DISABLE || \
53 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
54#define ONU_STATE_IF_UP(state) \
55 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053056#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000057 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053058#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000059 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
60#define SET_OPER_STATE(indication,state) \
61 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
62 indication->set_oper_state("down")
63#define GET_FLOW_TYPE(type) \
64 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
65 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
66 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
67
68std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050069{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000070 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050071 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000072 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000074 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
75 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050076 }
77 return "unknown";
78}
79
Jason Huang09b73ea2020-01-08 17:52:05 +080080std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000081{
Jason Huang09b73ea2020-01-08 17:52:05 +080082 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000083 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080084 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000085 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080086 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087 return "host";
88 }
89 return "unknown";
90}
91
Jason Huang5d9ab1a2020-04-15 16:53:49 +080092inline uint64_t get_pon_stats_alarms_data(bcmolt_interface pon_ni, bcmolt_onu_id onu_id, bcmolt_onu_itu_pon_stats_data_id stat) {
93 bcmos_errno err;
94 bcmolt_onu_itu_pon_stats itu_pon_stat; /* declare main API struct */
95 bcmolt_onu_key key = {}; /* declare key */
96 bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE; /* declare 'clear on read' flag */
97
98 key.pon_ni = pon_ni;
99 key.onu_id = onu_id;
100
101 /* Initialize the API struct. */
102 BCMOLT_STAT_INIT(&itu_pon_stat, onu, itu_pon_stats, key);
103 switch (stat) {
104 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
105 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, rdi_errors);
106 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
107 if (err) {
108 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get rdi_errors, err = %s\n", bcmos_strerror(err));
109 return err;
110 }
111 return itu_pon_stat.data.rdi_errors;
112 /* It is a further requirement
113 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
114 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, bip_errors);
115 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
116 if (err) {
117 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get bip_errors, err = %s\n", bcmos_strerror(err));
118 return err;
119 }
120 return itu_pon_stat.data.bip_errors;
121 */
122 default:
123 return BCM_ERR_INTERNAL;
124 }
125
126 return err;
127}
128
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000129/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -0700130 bcmbal_subscriber_terminal_key key;
131 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
132 uint8_t *list_mem;// to fetch config details for ONU
133 bcmos_errno err = BCM_ERR_OK;
134
135 key.sub_term_id =onu_id;
136 key.intf_id = intf_id;
137 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
138
139 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
140
141 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
142 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
143 memset(reg_id, '\0', MAX_REGID_LENGTH);
144
145 //set memory to use for variable-sized lists
146 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
147
148 if (list_mem == NULL)
149 {
150 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
151 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
152 return reg_id;
153 }
154
155 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
156 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
157
158 //call API
159 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
160
161 if (err != BCM_ERR_OK)
162 {
163 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
164 key.sub_term_id, key.intf_id);
165 free(list_mem);
166 return reg_id;
167 }
168
169 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
170 key.sub_term_id, key.intf_id);
171
172 for (int i=0; i<MAX_REGID_LENGTH ; i++){
173 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
174 }
175
176 free(list_mem);
177 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000178}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700179
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000180static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000181 openolt::Indication ind;
182 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500183 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500184
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000185 switch (msg->subgroup) {
186 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
187 admin_state = "up";
188 olt_ind->set_oper_state("up");
189 break;
190 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
191 admin_state = "down";
192 olt_ind->set_oper_state("down");
193 break;
194 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
195 admin_state = "failure";
196 olt_ind->set_oper_state("failure");
197 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000198 }
199 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500200
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000201 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
202 /* register for omci indication */
203 {
204 bcmolt_rx_cfg rx_cfg = {};
205 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
206 rx_cfg.rx_cb = OmciIndication;
207 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
208 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
209 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000210 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500211 state.activate();
212 }
213 else {
214 state.deactivate();
215 }
216
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000217 oltIndQ.push(ind);
218 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000219}
220
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000221static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000222 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400223 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
224 openolt::LosIndication* los_ind = new openolt::LosIndication;
225
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000226 switch (msg->obj_type) {
227 case BCMOLT_OBJ_ID_PON_INTERFACE:
228 switch (msg->subgroup) {
229 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
230 {
231 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
232 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
233 BCMOLT_INTERFACE_TYPE_PON);
234 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400235
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530236 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000237 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400238
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000239 los_ind->set_intf_id(intf_id);
240 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400241
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000242 alarm_ind->set_allocated_los_ind(los_ind);
243 ind.set_allocated_alarm_ind(alarm_ind);
244 break;
245 }
246 }
247 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400248
249 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000250 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000251}
252
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000253static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700254 openolt::Indication ind;
255 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
256
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530257 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000258 case BCMOLT_OBJ_ID_PON_INTERFACE:
259 switch (msg->subgroup) {
260 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530261 {
262 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000263 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530264 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000265 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700266
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000267 intf_ind->set_intf_id(key->pon_ni);
268 SET_OPER_STATE(intf_ind, data->new_state);
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530269
270 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n",
271 bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str());
272
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000273 ind.set_allocated_intf_ind(intf_ind);
274 break;
275 }
276 }
277 break;
278 case BCMOLT_OBJ_ID_NNI_INTERFACE:
279 switch (msg->subgroup) {
280 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
281 {
282 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
283 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530284 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000285 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530286 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000287 &((bcmolt_nni_interface_state_change *)msg)->data;
288
289 intf_ind->set_intf_id(key->id);
290 SET_OPER_STATE(intf_ind, data->new_state);
291 ind.set_allocated_intf_ind(intf_ind);
292 break;
293 }
294 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700295 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700296
297 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000298 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700299}
300
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000301static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000302 openolt::Indication ind;
303 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000304
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000305 switch (msg->obj_type) {
306 case BCMOLT_OBJ_ID_PON_INTERFACE:
307 switch (msg->subgroup) {
308 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
309 {
310 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
311 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
312 intf_oper_ind->set_intf_id(key->pon_ni);
313 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
314 SET_OPER_STATE(intf_oper_ind, data->new_state);
315 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
316 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
317 ind.set_allocated_intf_oper_ind(intf_oper_ind);
318 break;
319 }
320 }
321 case BCMOLT_OBJ_ID_NNI_INTERFACE:
322 switch (msg->subgroup) {
323 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
324 {
325 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
326 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
327 bcmolt_interface intf_id = key->id;
328 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
329 intf_oper_ind->set_intf_id(key->id);
330 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530331 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000332 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
333 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
334 ind.set_allocated_intf_oper_ind(intf_oper_ind);
335 break;
336 }
337 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000338 }
339
Shad Ansari01b0e652018-04-05 21:02:53 +0000340 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000341 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000342}
343
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000344static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000345 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400346 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
347 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
348
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000349 switch (msg->obj_type) {
350 case BCMOLT_OBJ_ID_ONU:
351 switch (msg->subgroup) {
352 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
353 {
Jason Huang93430532020-02-04 17:16:02 +0800354 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
355 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530356
357 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
358
359 OPENOLT_LOG(INFO, openolt_log_id, "onu alarm indication, pon_ni %d, onu_id %d, port_no %d, los_status %s, lob_status %s, lopc_miss_status %s, lopc_mic_error_status %s\n", key->pon_ni, key->onu_id, port_no, alarm_status_to_string(data->xgpon_onu_alarm.losi).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lobi).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error).c_str());
360
Jason Huang93430532020-02-04 17:16:02 +0800361 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
362 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
363 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
364 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
365 onu_alarm_ind->set_intf_id(key->pon_ni);
366 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000367 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
368 ind.set_allocated_alarm_ind(alarm_ind);
369 break;
370 }
371 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
372 {
Jason Huang93430532020-02-04 17:16:02 +0800373 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
374 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
375 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
376 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
377 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
378 onu_alarm_ind->set_intf_id(key->pon_ni);
379 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000380 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
381 ind.set_allocated_alarm_ind(alarm_ind);
382 break;
383 }
384 }
385 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400386
387 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000388 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000389}
390
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000391static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000392 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400393 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000394 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400395
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000396 switch (msg->obj_type) {
397 case BCMOLT_OBJ_ID_ONU:
398 switch (msg->subgroup) {
399 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
400 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500401 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500402 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
403
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530404 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
405
406 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
407 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
408
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500409 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500410 dgi_ind->set_intf_id(key->pon_ni);
411 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400412
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000413 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
414 ind.set_allocated_alarm_ind(alarm_ind);
415 break;
416 }
417 }
418 }
nickc063ffd2018-05-22 14:35:28 -0400419
420 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000421 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000422}
423
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000424static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Abhilash Laxmeshwar3b190f02022-06-13 21:21:56 +0530425 //Ignore the onu discovery when agent is not connected to VOLTHA
426 if (!state.is_connected()) {
427 bcmolt_msg_free(msg);
428 return;
429 }
430
Shad Ansari01b0e652018-04-05 21:02:53 +0000431 openolt::Indication ind;
432 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
433 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
434
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000435 switch (msg->obj_type) {
436 case BCMOLT_OBJ_ID_PON_INTERFACE:
437 switch (msg->subgroup) {
438 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
439 {
440 bcmolt_pon_interface_key *key =
441 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000442
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530443 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000444 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000445
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000446 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000447
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000448 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
449 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000450
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000451 onu_disc_ind->set_intf_id(key->pon_ni);
452 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
453 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
454 onu_disc_ind->set_allocated_serial_number(serial_number);
455 ind.set_allocated_onu_disc_ind(onu_disc_ind);
456 break;
457 }
458 }
459 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000460
461 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000462 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000463}
464
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000465static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000466 openolt::Indication ind;
467 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000468
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000469 switch (msg->obj_type) {
470 case BCMOLT_OBJ_ID_ONU:
471 switch (msg->subgroup) {
472 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
473 {
474 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
475 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000476
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530477 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000478 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000479
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000480 omci_ind->set_intf_id(key->pon_ni);
481 omci_ind->set_onu_id(key->onu_id);
482 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
483
484 ind.set_allocated_omci_ind(omci_ind);
485 break;
486 }
487 }
488 }
489
Shad Ansari01b0e652018-04-05 21:02:53 +0000490 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000491 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000492}
493
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000494static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000495 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000496
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000497 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800498 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000499 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800500 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000501 {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700502 int32_t gemport_id;
Jason Huang09b73ea2020-01-08 17:52:05 +0800503 bcmolt_access_control_receive_eth_packet *pkt =
504 (bcmolt_access_control_receive_eth_packet*)msg;
505 bcmolt_access_control_receive_eth_packet_data *pkt_data =
506 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000507
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700508 // Set the gemport_id to be passed to is_packet_allowed function
509 gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id;
510
511 // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet.
512 if (! is_packet_allowed(pkt_data, gemport_id) ) {
513 OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n");
514 bcmolt_msg_free(msg);
515 return;
516 }
517 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Jason Huang09b73ea2020-01-08 17:52:05 +0800518 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
519 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
520 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000521 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800522 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700523 if (pkt_data->svc_port_id != BCMOLT_SERVICE_PORT_ID_INVALID) { // case of packet-in from the PON interface
524 pon_gem pg((uint32_t)pkt_data->interface_ref.intf_id, pkt_data->svc_port_id);
525 // Find to onu-uni mapping for the pon-gem key
526 bcmos_fastlock_lock(&pon_gem_to_onu_uni_map_lock);
527 auto it = pon_gem_to_onu_uni_map.find(pg);
528 bcmos_fastlock_unlock(&pon_gem_to_onu_uni_map_lock, 0);
529 if (it == pon_gem_to_onu_uni_map.end()) {
530 bcmolt_msg_free(msg);
531 OPENOLT_LOG(ERROR, openolt_log_id, "onu-uni reference not found for packet-in on gemport=%d, pon_intf_id=%d", pkt_data->svc_port_id, pkt_data->interface_ref.intf_id);
532 return;
533 }
534 pkt_ind->set_onu_id(std::get<0>(it->second));
535 pkt_ind->set_uni_id(std::get<1>(it->second));
536 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000537 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500538
Jason Huang09b73ea2020-01-08 17:52:05 +0800539 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700540 OPENOLT_LOG(INFO, openolt_log_id,"packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d, onu_id=%d, uni_id=%d\n",
541 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_ind->gemport_id(), pkt_ind->onu_id(), pkt_ind->uni_id());
Jason Huang09b73ea2020-01-08 17:52:05 +0800542 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700543 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
544 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
Jason Huang09b73ea2020-01-08 17:52:05 +0800545 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000546 }
547 }
548 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500549
Shad Ansari5fe93682018-04-26 05:24:19 +0000550 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000551 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000552}
553
Girish Gowdra96461052019-11-22 20:13:59 +0530554static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
555
556 switch (msg->obj_type) {
557 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
558 switch (msg->subgroup) {
559 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
560 {
561 bcmolt_itupon_alloc_configuration_completed *pkt =
562 (bcmolt_itupon_alloc_configuration_completed*)msg;
563 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
564 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
565
566 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
567 alloc_cfg_complete_result res;
568 res.pon_intf_id = pkt->key.pon_ni;
569 res.alloc_id = pkt->key.alloc_id;
570
571 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
572 switch (pkt_data->new_state) {
573 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
574 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
575 break;
576 case BCMOLT_ACTIVATION_STATE_INACTIVE:
577 res.state = ALLOC_OBJECT_STATE_INACTIVE;
578 break;
579 case BCMOLT_ACTIVATION_STATE_PROCESSING:
580 res.state = ALLOC_OBJECT_STATE_PROCESSING;
581 break;
582 case BCMOLT_ACTIVATION_STATE_ACTIVE:
583 res.state = ALLOC_OBJECT_STATE_ACTIVE;
584 break;
585 default:
586 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
587 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
588 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
589 }
590 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",
591 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
592
593 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
594 // Push the result from BAL to queue
595 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
596 if (it == alloc_cfg_compltd_map.end()) {
597 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
598 bcmolt_msg_free(msg);
599 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);
600 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
601 return;
602 }
603 if (it->second) {
604 // Push the result
605 it->second->push(res);
606 }
607 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
608 }
609 }
610 }
611
612 bcmolt_msg_free(msg);
613}
614
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +0530615static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
616
617 switch (msg->obj_type) {
618 case BCMOLT_OBJ_ID_ITUPON_GEM:
619 switch (msg->subgroup) {
620 case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
621 {
622 bcmolt_itupon_gem_configuration_completed *pkt =
623 (bcmolt_itupon_gem_configuration_completed*)msg;
624 bcmolt_itupon_gem_configuration_completed_data *pkt_data =
625 &((bcmolt_itupon_gem_configuration_completed*)msg)->data;
626
627 gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id);
628 gem_cfg_complete_result res;
629 res.pon_intf_id = pkt->key.pon_ni;
630 res.gem_port_id = pkt->key.gem_port_id;
631
632 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL;
633 switch (pkt_data->new_state) {
634 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
635 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
636 break;
637 case BCMOLT_ACTIVATION_STATE_INACTIVE:
638 res.state = GEM_OBJECT_STATE_INACTIVE;
639 break;
640 case BCMOLT_ACTIVATION_STATE_PROCESSING:
641 res.state = GEM_OBJECT_STATE_PROCESSING;
642 break;
643 case BCMOLT_ACTIVATION_STATE_ACTIVE:
644 res.state = GEM_OBJECT_STATE_ACTIVE;
645 break;
646 default:
647 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n",
648 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state);
649 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
650 }
651 OPENOLT_LOG(INFO, openolt_log_id, "received itu pon gem cfg complete ind, pon intf %u, gem_port_id %u, status %u, new_state %u\n",
652 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state);
653
654 uint32_t gem_cfg_key_check_counter = 1;
655 std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it;
656 while(true) {
657 bcmos_fastlock_lock(&gem_cfg_wait_lock);
658 // Push the result from BAL to queue
659 it = gem_cfg_compltd_map.find(key);
660
661 if (it != gem_cfg_compltd_map.end()) {
662 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
663 break;
664 } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) {
665 /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion
666 by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication
667 to Queue by 6ms.*/
668 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
669 bcmos_usleep(6000);
670 } else {
671 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
672 bcmolt_msg_free(msg);
673 OPENOLT_LOG(ERROR, openolt_log_id, "gem config key not found for gem_port_id = %u, pon_intf = %u\n", pkt->key.gem_port_id, pkt->key.pon_ni);
674 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
675 return;
676 }
677 gem_cfg_key_check_counter++;
678 }
679
680 bcmos_fastlock_lock(&gem_cfg_wait_lock);
681 if (it->second) {
682 // Push the result
683 it->second->push(res);
684 }
685 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
686 }
687 }
688 }
689
690 bcmolt_msg_free(msg);
691}
692
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000693static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000694 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000695 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
696 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000697}
698
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000699static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000700 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000701 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
702 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000703}
704
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000705static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000706 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000707 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
708 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000709}
710
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000711static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000712 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000713 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
714 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000715}
716
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000717static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000718 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000719 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
720 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000721}
722
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000723static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400724 openolt::Indication ind;
725 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
726 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
727
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000728 switch (msg->obj_type) {
729 case BCMOLT_OBJ_ID_ONU:
730 switch (msg->subgroup) {
731 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
732 {
733 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
734 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400735
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000736 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
737 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400738
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000739 sufi_ind->set_intf_id(key->pon_ni);
740 sufi_ind->set_onu_id(key->onu_id);
741 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
742 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_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
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000753static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400754 openolt::Indication ind;
755 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
756 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
757
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000758 switch (msg->obj_type) {
759 case BCMOLT_OBJ_ID_ONU:
760 switch (msg->subgroup) {
761 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
762 {
763 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
764 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400765
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000766 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
767 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400768
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000769 sdi_ind->set_intf_id(key->pon_ni);
770 sdi_ind->set_onu_id(key->onu_id);
771 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
772 sdi_ind->set_inverse_bit_error_rate(data->ber);
773 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400774
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000775 ind.set_allocated_alarm_ind(alarm_ind);
776 }
777 }
778 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400779
780 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000781 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400782}
783
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000784static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400785 openolt::Indication ind;
786 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
787 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
788
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000789 switch (msg->obj_type) {
790 case BCMOLT_OBJ_ID_ONU:
791 switch (msg->subgroup) {
792 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
793 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530794 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000795 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400796
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000797 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",
798 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400799
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000800 dowi_ind->set_intf_id(key->pon_ni);
801 dowi_ind->set_onu_id(key->onu_id);
802 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
803 dowi_ind->set_drift(data->drift_value);
804 dowi_ind->set_new_eqd(data->new_eqd);
805 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400806
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000807 ind.set_allocated_alarm_ind(alarm_ind);
808 }
809 }
810 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400811
812 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000813 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400814}
815
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000816static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400817 openolt::Indication ind;
818 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
819 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
820
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000821 switch (msg->obj_type) {
822 case BCMOLT_OBJ_ID_ONU:
823 switch (msg->subgroup) {
824 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
825 {
826 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
827 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400828
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000829 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
830 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400831
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000832 looci_ind->set_intf_id(key->pon_ni);
833 looci_ind->set_onu_id(key->onu_id);
834 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
835 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400836
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000837 ind.set_allocated_alarm_ind(alarm_ind);
838 }
839 }
840 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400841
842 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000843 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400844}
845
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000846static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400847 openolt::Indication ind;
848 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
849 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
850
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000851 switch (msg->obj_type) {
852 case BCMOLT_OBJ_ID_ONU:
853 switch (msg->subgroup) {
854 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
855 {
856 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
857 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400858
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000859 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
860 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400861
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000862 sfi_ind->set_intf_id(key->pon_ni);
863 sfi_ind->set_onu_id(key->onu_id);
864 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
865 sfi_ind->set_inverse_bit_error_rate(data->ber);
866 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400867
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000868 ind.set_allocated_alarm_ind(alarm_ind);
869 }
870 }
871 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400872
873 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000874 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400875}
876
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000877static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400878 openolt::Indication ind;
879 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
880 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
881
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000882 switch (msg->obj_type) {
883 case BCMOLT_OBJ_ID_ONU:
884 switch (msg->subgroup) {
885 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
886 {
887 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
888 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400889
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000890 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
891 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400892
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000893 tiwi_ind->set_intf_id(key->pon_ni);
894 tiwi_ind->set_onu_id(key->onu_id);
895 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
896 tiwi_ind->set_drift(data->drift_value);
897 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400898
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000899 ind.set_allocated_alarm_ind(alarm_ind);
900 }
901 }
902 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400903
904 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000905 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400906}
907
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530908static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400909 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530910 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
911
912 switch (msg->obj_type) {
913 case BCMOLT_OBJ_ID_ONU:
914 switch (msg->subgroup) {
915 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
916 {
917 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
918 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
919
920 onu_ind->set_intf_id(key->pon_ni);
921 onu_ind->set_onu_id(key->onu_id);
922 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
923 onu_ind->set_oper_state("up");
924 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
925 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530926 switch (data->fail_reason) {
927 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
928 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
929 break;
930 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
931 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
932 break;
933 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
934 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
935 break;
936 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
937 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
938 break;
939 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
940 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
941 break;
942 default:
943 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
944 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530945 // Setting the admin_state state field based on a valid onu_id does not make any sense.
946 // The adapter too does not seem to interpret this seriously.
947 // Legacy code, lets keep this as is for now.
948 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
949 ind.set_allocated_onu_ind(onu_ind);
950 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
951 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
952 (key->onu_id)?"up":"down");
953 }
954 }
955 }
956
957 oltIndQ.push(ind);
958 bcmolt_msg_free(msg);
959}
960
Jason Huang93430532020-02-04 17:16:02 +0800961static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
962 openolt::Indication ind;
963 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
964 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
965
966 switch (msg->obj_type) {
967 case BCMOLT_OBJ_ID_ONU:
968 switch (msg->subgroup) {
969 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
970 {
971 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
972 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
973
974 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
975 key->pon_ni, key->onu_id, data->alarm_status);
976
977 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
978 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
979 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
980 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
981
982 ind.set_allocated_alarm_ind(alarm_ind);
983 }
984 }
985 }
986
987 oltIndQ.push(ind);
988 bcmolt_msg_free(msg);
989}
990
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800991static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +0800992 openolt::Indication ind;
993 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
994 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
995
996 switch (msg->obj_type) {
997 case BCMOLT_OBJ_ID_ONU:
998 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800999 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +08001000 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001001 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
1002 bcmolt_onu_itu_pon_stats_alarm_raised_data *data = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->data;
Jason Huang93430532020-02-04 17:16:02 +08001003
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001004 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
1005 switch (data->stat)
1006 {
1007 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1008 uint64_t rdi_errors;
1009 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1010 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1011 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1012 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1013 rdi_err_ind->set_rdi_error_count(rdi_errors);
1014 rdi_err_ind->set_status("on");
1015 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1016 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1017 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1018 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1019 break;
1020 /* It is a further requirement
1021 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1022 uint64_t bip_errors;
1023 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1024 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1025 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1026 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1027 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1028 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1029 break;
1030 */
1031 }
1032 ind.set_allocated_alarm_ind(alarm_ind);
1033 }
Jason Huang93430532020-02-04 17:16:02 +08001034 }
1035 }
1036 }
1037
1038 oltIndQ.push(ind);
1039 bcmolt_msg_free(msg);
1040}
1041
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001042static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1043 openolt::Indication ind;
1044 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1045 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +08001046
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001047 switch (msg->obj_type) {
1048 case BCMOLT_OBJ_ID_ONU:
1049 switch (msg->subgroup) {
1050 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
1051 {
1052 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
1053 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
1054
1055 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
1056 switch (data->stat)
1057 {
1058 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1059 uint64_t rdi_errors;
1060 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1061
1062 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1063 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1064 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1065 rdi_err_ind->set_rdi_error_count(rdi_errors);
1066 rdi_err_ind->set_status("off");
1067 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1068 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1069 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1070 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1071 break;
1072 /* It is a further requirement
1073 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1074 uint64_t bip_errors;
1075 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1076 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1077 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1078 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
1079 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1080 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1081 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1082 break;
1083 */
1084 }
1085 ind.set_allocated_alarm_ind(alarm_ind);
1086 }
1087 }
1088 }
1089 }
1090
1091 oltIndQ.push(ind);
1092 bcmolt_msg_free(msg);
1093}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301094
1095static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1096 openolt::Indication ind;
1097
1098 openolt::Indication onu_ind;
1099 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001100
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001101 switch (msg->obj_type) {
1102 case BCMOLT_OBJ_ID_ONU:
1103 switch (msg->subgroup) {
1104 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1105 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301106 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1107 bcmolt_onu_onu_deactivation_completed_data *data =
1108 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001109
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301110 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1111 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001112
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301113 onu_ind_data->set_intf_id(key->pon_ni);
1114 onu_ind_data->set_onu_id(key->onu_id);
1115 onu_ind_data->set_oper_state("down");
1116 onu_ind_data->set_admin_state("down");
1117 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301118
1119 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1120 onu_deactivate_complete_result res;
1121 res.pon_intf_id = (uint32_t)key->pon_ni;
1122 res.onu_id = (uint32_t) key->onu_id;
1123 res.result = data->status;
1124 res.reason = data->fail_reason;
1125
1126 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1127 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1128
1129 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1130 // Push the result from BAL to queue
1131 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1132 if (it == onu_deact_compltd_map.end()) {
1133 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
Girish Gowdra6675fa02020-03-03 20:27:50 -08001134 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1135 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1136 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301137 OPENOLT_LOG(WARNING, openolt_log_id, "onu deactivate completed key not found for pon intf %u, onu_id %u\n",
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301138 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301139 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001140 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301141 // Push the result
1142 it->second->push(res);
1143 }
1144 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001145 }
1146 }
1147 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001148
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301149 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001150 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001151}
1152
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001153static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1154 switch (msg->obj_type) {
1155 case BCMOLT_OBJ_ID_ONU:
1156 switch (msg->subgroup) {
1157 case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED:
1158 {
1159 bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key;
1160 bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data;
1161 double rx_power_mean_dbm = 0.0;
1162
1163 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n",
1164 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1165
1166 if (data->status == BCMOLT_RESULT_SUCCESS) {
1167 auto trx_eeprom_reader =
1168#ifdef ASGVOLT64
1169 TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni};
1170#else
1171 TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni};
1172#endif
1173 auto power = trx_eeprom_reader.read_power_mean_dbm();
1174
1175 if (power.second) {
1176 rx_power_mean_dbm = power.first.first;
1177 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm);
1178 } else {
1179 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n");
1180 }
1181 } else {
1182 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure");
1183 }
1184
1185 // for internal use insert into map
1186 onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id);
1187 onu_rssi_complete_result res;
1188 res.pon_intf_id = (uint32_t)key->pon_ni;
1189 res.onu_id = (uint32_t)key->onu_id;
1190 res.status = bcmolt_result_to_string(data->status);
1191 res.reason = data->fail_reason;
1192 res.rx_power_mean_dbm = rx_power_mean_dbm;
1193
1194 bcmos_fastlock_lock(&onu_rssi_wait_lock);
1195 auto it = onu_rssi_compltd_map.find(onu_key);
1196 if (it == onu_rssi_compltd_map.end()) {
1197 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n",
1198 key->pon_ni, key->onu_id);
1199 } else if (it->second) {
1200 it->second->push(res);
1201 } else {
1202 OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n",
1203 key->pon_ni, key->onu_id);
1204 }
1205 bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0);
1206 }
1207 }
1208 }
1209
1210 bcmolt_msg_free(msg);
1211}
1212
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001213/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001214bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1215 openolt::Indication ind;
1216 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1217 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1218
1219 bcmbal_subscriber_terminal_key *key =
1220 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1221
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001222 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001223 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001224
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001225 onu_proc_error_ind->set_intf_id(key->intf_id);
1226 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1227
1228 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1229 ind.set_allocated_alarm_ind(alarm_ind);
1230
1231 oltIndQ.push(ind);
1232 return BCM_ERR_OK;
1233}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001234*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001235
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001236static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1237
1238 switch (msg->obj_type) {
1239 case BCMOLT_OBJ_ID_GROUP:
1240 switch (msg->subgroup) {
1241 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1242 {
1243 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1244 bcmolt_group_complete_members_update_data *data =
1245 &((bcmolt_group_complete_members_update*)msg)->data;
1246
1247 if (data->result == BCMOLT_RESULT_SUCCESS) {
1248 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1249 } else {
1250 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1251 }
1252 }
1253 }
1254 }
1255 bcmolt_msg_free(msg);
1256}
1257
Shad Ansari01b0e652018-04-05 21:02:53 +00001258Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001259 bcmolt_rx_cfg rx_cfg = {};
1260 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001261
1262 if (subscribed) {
1263 return Status::OK;
1264 }
1265
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001266 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1267 rx_cfg.rx_cb = OltOperIndication;
1268 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1269 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1270 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1271 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301272 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001273 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001274
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001275 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1276 rx_cfg.rx_cb = OltOperIndication;
1277 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1278 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1279 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1280 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301281 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001282 "Olt disconnection complete state indication subscribe failed");
1283
1284 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1285 rx_cfg.rx_cb = OltOperIndication;
1286 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1287 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1288 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1289 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301290 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001291 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001292
1293 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001294 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1295 rx_cfg.rx_cb = LosIndication;
1296 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1297 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1298 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1299 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001300 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001301
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001302 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1303 rx_cfg.rx_cb = IfOperIndication;
1304 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1305 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1306 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1307 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301308 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001309 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001310
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001311 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1312 rx_cfg.rx_cb = IfOperIndication;
1313 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1314 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1315 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1316 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301317 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001318 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001319
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001320 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1321 rx_cfg.rx_cb = OnuAlarmIndication;
1322 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1323 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1324 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1325 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001326 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001327
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001328 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1329 rx_cfg.rx_cb = OnuAlarmIndication;
1330 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1331 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1332 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1333 if(rc != BCM_ERR_OK)
1334 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1335
1336 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1337 rx_cfg.rx_cb = OnuDyingGaspIndication;
1338 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1339 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1340 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1341 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001342 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001343
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001344 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1345 rx_cfg.rx_cb = OnuDiscoveryIndication;
1346 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1347 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1348 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1349 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001350 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001351
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001352 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001353 rx_cfg.rx_cb = OnuStartupFailureIndication;
1354 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1355 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1356 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1357 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301358 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001359 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001360
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001361 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1362 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1363 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1364 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1365 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1366 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001367 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001368
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001369 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1370 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1371 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1372 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1373 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1374 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001375 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001376
1377 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001378 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1379 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1380 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1381 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1382 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1383 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001384 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001385
1386 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001387 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1388 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1389 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1390 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1391 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1392 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001393 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001394
1395 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001396 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1397 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1398 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1399 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1400 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1401 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001402 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001403
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301404 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001405 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301406 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1407 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1408 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1409 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1410 if(rc != BCM_ERR_OK)
1411 return Status(grpc::StatusCode::INTERNAL,
1412 "onu activation completed indication subscribe failed");
1413
1414 /* ONU Deactivation Completed Indication */
1415 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1416 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001417 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1418 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1419 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1420 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301421 return Status(grpc::StatusCode::INTERNAL,
1422 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001423
Jason Huang93430532020-02-04 17:16:02 +08001424 /* ONU Loss of Key Sync Indiction */
1425 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1426 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1427 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1428 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1429 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1430 if(rc != BCM_ERR_OK)
1431 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1432
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001433 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001434 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001435 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001436 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001437 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001438 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1439 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001440 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1441
1442 /* ONU ITU-PON Cleared Stats Indiction */
1443 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1444 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1445 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1446 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1447 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1448 if(rc != BCM_ERR_OK)
1449 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001450
Jason Huang09b73ea2020-01-08 17:52:05 +08001451 /* Packet-In by Access_Control */
1452 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001453 rx_cfg.rx_cb = PacketIndication;
1454 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001455 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001456 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1457 if(rc != BCM_ERR_OK)
1458 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001459
Girish Gowdra96461052019-11-22 20:13:59 +05301460 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1461 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1462 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1463 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1464 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1465 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001466 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +05301467
1468 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM;
1469 rx_cfg.rx_cb = ItuPonGemConfigCompletedInd;
1470 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1471 rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed;
1472 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1473 if(rc != BCM_ERR_OK)
1474 return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301475
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001476 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1477 rx_cfg.rx_cb = GroupIndication;
1478 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1479 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1480 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1481 if(rc != BCM_ERR_OK)
1482 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1483
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001484 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1485 rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication;
1486 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1487 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed;
1488 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1489 if(rc != BCM_ERR_OK)
1490 return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed");
1491
Shad Ansari01b0e652018-04-05 21:02:53 +00001492 subscribed = true;
1493
1494 return Status::OK;
1495}