blob: ad2d5ff19ff32153b1cd3ff26712839749c36fc1 [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) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000425 openolt::Indication ind;
426 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
427 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
428
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000429 switch (msg->obj_type) {
430 case BCMOLT_OBJ_ID_PON_INTERFACE:
431 switch (msg->subgroup) {
432 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
433 {
434 bcmolt_pon_interface_key *key =
435 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000436
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530437 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000438 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000439
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000440 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000441
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000442 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
443 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000444
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000445 onu_disc_ind->set_intf_id(key->pon_ni);
446 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
447 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
448 onu_disc_ind->set_allocated_serial_number(serial_number);
449 ind.set_allocated_onu_disc_ind(onu_disc_ind);
450 break;
451 }
452 }
453 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000454
455 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000456 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000457}
458
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000459static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000460 openolt::Indication ind;
461 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000462
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000463 switch (msg->obj_type) {
464 case BCMOLT_OBJ_ID_ONU:
465 switch (msg->subgroup) {
466 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
467 {
468 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
469 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000470
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530471 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000472 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000473
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000474 omci_ind->set_intf_id(key->pon_ni);
475 omci_ind->set_onu_id(key->onu_id);
476 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
477
478 ind.set_allocated_omci_ind(omci_ind);
479 break;
480 }
481 }
482 }
483
Shad Ansari01b0e652018-04-05 21:02:53 +0000484 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000485 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000486}
487
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000488static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000489 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000490
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000491 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800492 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000493 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800494 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000495 {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700496 int32_t gemport_id;
Jason Huang09b73ea2020-01-08 17:52:05 +0800497 bcmolt_access_control_receive_eth_packet *pkt =
498 (bcmolt_access_control_receive_eth_packet*)msg;
499 bcmolt_access_control_receive_eth_packet_data *pkt_data =
500 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000501
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700502 // Set the gemport_id to be passed to is_packet_allowed function
503 gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id;
504
505 // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet.
506 if (! is_packet_allowed(pkt_data, gemport_id) ) {
507 OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n");
508 bcmolt_msg_free(msg);
509 return;
510 }
511 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Jason Huang09b73ea2020-01-08 17:52:05 +0800512 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
513 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
514 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000515 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800516 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700517 if (pkt_data->svc_port_id != BCMOLT_SERVICE_PORT_ID_INVALID) { // case of packet-in from the PON interface
518 pon_gem pg((uint32_t)pkt_data->interface_ref.intf_id, pkt_data->svc_port_id);
519 // Find to onu-uni mapping for the pon-gem key
520 bcmos_fastlock_lock(&pon_gem_to_onu_uni_map_lock);
521 auto it = pon_gem_to_onu_uni_map.find(pg);
522 bcmos_fastlock_unlock(&pon_gem_to_onu_uni_map_lock, 0);
523 if (it == pon_gem_to_onu_uni_map.end()) {
524 bcmolt_msg_free(msg);
525 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);
526 return;
527 }
528 pkt_ind->set_onu_id(std::get<0>(it->second));
529 pkt_ind->set_uni_id(std::get<1>(it->second));
530 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000531 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500532
Jason Huang09b73ea2020-01-08 17:52:05 +0800533 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700534 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",
535 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 +0800536 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700537 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
538 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
Jason Huang09b73ea2020-01-08 17:52:05 +0800539 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000540 }
541 }
542 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500543
Shad Ansari5fe93682018-04-26 05:24:19 +0000544 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000545 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000546}
547
Girish Gowdra96461052019-11-22 20:13:59 +0530548static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
549
550 switch (msg->obj_type) {
551 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
552 switch (msg->subgroup) {
553 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
554 {
555 bcmolt_itupon_alloc_configuration_completed *pkt =
556 (bcmolt_itupon_alloc_configuration_completed*)msg;
557 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
558 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
559
560 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
561 alloc_cfg_complete_result res;
562 res.pon_intf_id = pkt->key.pon_ni;
563 res.alloc_id = pkt->key.alloc_id;
564
565 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
566 switch (pkt_data->new_state) {
567 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
568 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
569 break;
570 case BCMOLT_ACTIVATION_STATE_INACTIVE:
571 res.state = ALLOC_OBJECT_STATE_INACTIVE;
572 break;
573 case BCMOLT_ACTIVATION_STATE_PROCESSING:
574 res.state = ALLOC_OBJECT_STATE_PROCESSING;
575 break;
576 case BCMOLT_ACTIVATION_STATE_ACTIVE:
577 res.state = ALLOC_OBJECT_STATE_ACTIVE;
578 break;
579 default:
580 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
581 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
582 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
583 }
584 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",
585 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
586
587 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
588 // Push the result from BAL to queue
589 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
590 if (it == alloc_cfg_compltd_map.end()) {
591 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
592 bcmolt_msg_free(msg);
593 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);
594 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
595 return;
596 }
597 if (it->second) {
598 // Push the result
599 it->second->push(res);
600 }
601 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
602 }
603 }
604 }
605
606 bcmolt_msg_free(msg);
607}
608
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +0530609static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
610
611 switch (msg->obj_type) {
612 case BCMOLT_OBJ_ID_ITUPON_GEM:
613 switch (msg->subgroup) {
614 case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
615 {
616 bcmolt_itupon_gem_configuration_completed *pkt =
617 (bcmolt_itupon_gem_configuration_completed*)msg;
618 bcmolt_itupon_gem_configuration_completed_data *pkt_data =
619 &((bcmolt_itupon_gem_configuration_completed*)msg)->data;
620
621 gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id);
622 gem_cfg_complete_result res;
623 res.pon_intf_id = pkt->key.pon_ni;
624 res.gem_port_id = pkt->key.gem_port_id;
625
626 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL;
627 switch (pkt_data->new_state) {
628 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
629 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
630 break;
631 case BCMOLT_ACTIVATION_STATE_INACTIVE:
632 res.state = GEM_OBJECT_STATE_INACTIVE;
633 break;
634 case BCMOLT_ACTIVATION_STATE_PROCESSING:
635 res.state = GEM_OBJECT_STATE_PROCESSING;
636 break;
637 case BCMOLT_ACTIVATION_STATE_ACTIVE:
638 res.state = GEM_OBJECT_STATE_ACTIVE;
639 break;
640 default:
641 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n",
642 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state);
643 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
644 }
645 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",
646 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state);
647
648 uint32_t gem_cfg_key_check_counter = 1;
649 std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it;
650 while(true) {
651 bcmos_fastlock_lock(&gem_cfg_wait_lock);
652 // Push the result from BAL to queue
653 it = gem_cfg_compltd_map.find(key);
654
655 if (it != gem_cfg_compltd_map.end()) {
656 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
657 break;
658 } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) {
659 /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion
660 by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication
661 to Queue by 6ms.*/
662 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
663 bcmos_usleep(6000);
664 } else {
665 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
666 bcmolt_msg_free(msg);
667 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);
668 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
669 return;
670 }
671 gem_cfg_key_check_counter++;
672 }
673
674 bcmos_fastlock_lock(&gem_cfg_wait_lock);
675 if (it->second) {
676 // Push the result
677 it->second->push(res);
678 }
679 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
680 }
681 }
682 }
683
684 bcmolt_msg_free(msg);
685}
686
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000687static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000688 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000689 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
690 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000691}
692
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000693static void FlowIndication(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 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 TmQIndication(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, "traffic mgmt queue 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 TmSchedIndication(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 sheduler 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 McastGroupIndication(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, "mcast group 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 OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400718 openolt::Indication ind;
719 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
720 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
721
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000722 switch (msg->obj_type) {
723 case BCMOLT_OBJ_ID_ONU:
724 switch (msg->subgroup) {
725 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
726 {
727 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
728 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400729
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000730 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
731 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400732
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000733 sufi_ind->set_intf_id(key->pon_ni);
734 sufi_ind->set_onu_id(key->onu_id);
735 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
736 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400737
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000738 ind.set_allocated_alarm_ind(alarm_ind);
739 }
740 }
741 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400742
743 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000744 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400745}
746
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000747static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400748 openolt::Indication ind;
749 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
750 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
751
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000752 switch (msg->obj_type) {
753 case BCMOLT_OBJ_ID_ONU:
754 switch (msg->subgroup) {
755 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
756 {
757 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
758 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400759
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000760 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
761 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400762
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000763 sdi_ind->set_intf_id(key->pon_ni);
764 sdi_ind->set_onu_id(key->onu_id);
765 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
766 sdi_ind->set_inverse_bit_error_rate(data->ber);
767 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400768
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000769 ind.set_allocated_alarm_ind(alarm_ind);
770 }
771 }
772 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400773
774 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000775 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400776}
777
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000778static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400779 openolt::Indication ind;
780 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
781 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
782
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000783 switch (msg->obj_type) {
784 case BCMOLT_OBJ_ID_ONU:
785 switch (msg->subgroup) {
786 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
787 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530788 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000789 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400790
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000791 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",
792 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400793
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000794 dowi_ind->set_intf_id(key->pon_ni);
795 dowi_ind->set_onu_id(key->onu_id);
796 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
797 dowi_ind->set_drift(data->drift_value);
798 dowi_ind->set_new_eqd(data->new_eqd);
799 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400800
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000801 ind.set_allocated_alarm_ind(alarm_ind);
802 }
803 }
804 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400805
806 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000807 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400808}
809
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000810static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400811 openolt::Indication ind;
812 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
813 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
814
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000815 switch (msg->obj_type) {
816 case BCMOLT_OBJ_ID_ONU:
817 switch (msg->subgroup) {
818 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
819 {
820 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
821 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400822
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000823 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
824 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400825
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000826 looci_ind->set_intf_id(key->pon_ni);
827 looci_ind->set_onu_id(key->onu_id);
828 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
829 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400830
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000831 ind.set_allocated_alarm_ind(alarm_ind);
832 }
833 }
834 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400835
836 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000837 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400838}
839
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000840static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400841 openolt::Indication ind;
842 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
843 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
844
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000845 switch (msg->obj_type) {
846 case BCMOLT_OBJ_ID_ONU:
847 switch (msg->subgroup) {
848 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
849 {
850 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
851 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400852
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000853 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
854 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400855
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000856 sfi_ind->set_intf_id(key->pon_ni);
857 sfi_ind->set_onu_id(key->onu_id);
858 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
859 sfi_ind->set_inverse_bit_error_rate(data->ber);
860 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400861
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000862 ind.set_allocated_alarm_ind(alarm_ind);
863 }
864 }
865 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400866
867 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000868 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400869}
870
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000871static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400872 openolt::Indication ind;
873 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
874 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
875
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000876 switch (msg->obj_type) {
877 case BCMOLT_OBJ_ID_ONU:
878 switch (msg->subgroup) {
879 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
880 {
881 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
882 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400883
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000884 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
885 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400886
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000887 tiwi_ind->set_intf_id(key->pon_ni);
888 tiwi_ind->set_onu_id(key->onu_id);
889 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
890 tiwi_ind->set_drift(data->drift_value);
891 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400892
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000893 ind.set_allocated_alarm_ind(alarm_ind);
894 }
895 }
896 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400897
898 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000899 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400900}
901
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530902static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400903 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530904 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
905
906 switch (msg->obj_type) {
907 case BCMOLT_OBJ_ID_ONU:
908 switch (msg->subgroup) {
909 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
910 {
911 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
912 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
913
914 onu_ind->set_intf_id(key->pon_ni);
915 onu_ind->set_onu_id(key->onu_id);
916 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
917 onu_ind->set_oper_state("up");
918 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
919 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530920 switch (data->fail_reason) {
921 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
922 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
923 break;
924 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
925 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
926 break;
927 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
928 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
929 break;
930 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
931 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
932 break;
933 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
934 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
935 break;
936 default:
937 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
938 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530939 // Setting the admin_state state field based on a valid onu_id does not make any sense.
940 // The adapter too does not seem to interpret this seriously.
941 // Legacy code, lets keep this as is for now.
942 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
943 ind.set_allocated_onu_ind(onu_ind);
944 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
945 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
946 (key->onu_id)?"up":"down");
947 }
948 }
949 }
950
951 oltIndQ.push(ind);
952 bcmolt_msg_free(msg);
953}
954
Jason Huang93430532020-02-04 17:16:02 +0800955static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
956 openolt::Indication ind;
957 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
958 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
959
960 switch (msg->obj_type) {
961 case BCMOLT_OBJ_ID_ONU:
962 switch (msg->subgroup) {
963 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
964 {
965 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
966 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
967
968 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
969 key->pon_ni, key->onu_id, data->alarm_status);
970
971 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
972 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
973 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
974 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
975
976 ind.set_allocated_alarm_ind(alarm_ind);
977 }
978 }
979 }
980
981 oltIndQ.push(ind);
982 bcmolt_msg_free(msg);
983}
984
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800985static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +0800986 openolt::Indication ind;
987 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
988 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
989
990 switch (msg->obj_type) {
991 case BCMOLT_OBJ_ID_ONU:
992 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800993 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +0800994 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800995 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
996 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 +0800997
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800998 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
999 switch (data->stat)
1000 {
1001 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1002 uint64_t rdi_errors;
1003 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1004 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1005 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1006 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1007 rdi_err_ind->set_rdi_error_count(rdi_errors);
1008 rdi_err_ind->set_status("on");
1009 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1010 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1011 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1012 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1013 break;
1014 /* It is a further requirement
1015 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1016 uint64_t bip_errors;
1017 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1018 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1019 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1020 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1021 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1022 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1023 break;
1024 */
1025 }
1026 ind.set_allocated_alarm_ind(alarm_ind);
1027 }
Jason Huang93430532020-02-04 17:16:02 +08001028 }
1029 }
1030 }
1031
1032 oltIndQ.push(ind);
1033 bcmolt_msg_free(msg);
1034}
1035
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001036static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1037 openolt::Indication ind;
1038 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1039 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +08001040
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001041 switch (msg->obj_type) {
1042 case BCMOLT_OBJ_ID_ONU:
1043 switch (msg->subgroup) {
1044 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
1045 {
1046 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
1047 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
1048
1049 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
1050 switch (data->stat)
1051 {
1052 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1053 uint64_t rdi_errors;
1054 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1055
1056 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1057 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1058 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1059 rdi_err_ind->set_rdi_error_count(rdi_errors);
1060 rdi_err_ind->set_status("off");
1061 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1062 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1063 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1064 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1065 break;
1066 /* It is a further requirement
1067 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1068 uint64_t bip_errors;
1069 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1070 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1071 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1072 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
1073 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1074 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1075 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1076 break;
1077 */
1078 }
1079 ind.set_allocated_alarm_ind(alarm_ind);
1080 }
1081 }
1082 }
1083 }
1084
1085 oltIndQ.push(ind);
1086 bcmolt_msg_free(msg);
1087}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301088
1089static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1090 openolt::Indication ind;
1091
1092 openolt::Indication onu_ind;
1093 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001094
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001095 switch (msg->obj_type) {
1096 case BCMOLT_OBJ_ID_ONU:
1097 switch (msg->subgroup) {
1098 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1099 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301100 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1101 bcmolt_onu_onu_deactivation_completed_data *data =
1102 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001103
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301104 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1105 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001106
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301107 onu_ind_data->set_intf_id(key->pon_ni);
1108 onu_ind_data->set_onu_id(key->onu_id);
1109 onu_ind_data->set_oper_state("down");
1110 onu_ind_data->set_admin_state("down");
1111 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301112
1113 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1114 onu_deactivate_complete_result res;
1115 res.pon_intf_id = (uint32_t)key->pon_ni;
1116 res.onu_id = (uint32_t) key->onu_id;
1117 res.result = data->status;
1118 res.reason = data->fail_reason;
1119
1120 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1121 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1122
1123 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1124 // Push the result from BAL to queue
1125 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1126 if (it == onu_deact_compltd_map.end()) {
1127 // 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 -08001128 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1129 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1130 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301131 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 +05301132 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301133 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001134 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301135 // Push the result
1136 it->second->push(res);
1137 }
1138 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001139 }
1140 }
1141 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001142
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301143 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001144 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001145}
1146
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001147static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1148 switch (msg->obj_type) {
1149 case BCMOLT_OBJ_ID_ONU:
1150 switch (msg->subgroup) {
1151 case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED:
1152 {
1153 bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key;
1154 bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data;
1155 double rx_power_mean_dbm = 0.0;
1156
1157 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n",
1158 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1159
1160 if (data->status == BCMOLT_RESULT_SUCCESS) {
1161 auto trx_eeprom_reader =
1162#ifdef ASGVOLT64
1163 TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni};
1164#else
1165 TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni};
1166#endif
1167 auto power = trx_eeprom_reader.read_power_mean_dbm();
1168
1169 if (power.second) {
1170 rx_power_mean_dbm = power.first.first;
1171 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm);
1172 } else {
1173 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n");
1174 }
1175 } else {
1176 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure");
1177 }
1178
1179 // for internal use insert into map
1180 onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id);
1181 onu_rssi_complete_result res;
1182 res.pon_intf_id = (uint32_t)key->pon_ni;
1183 res.onu_id = (uint32_t)key->onu_id;
1184 res.status = bcmolt_result_to_string(data->status);
1185 res.reason = data->fail_reason;
1186 res.rx_power_mean_dbm = rx_power_mean_dbm;
1187
1188 bcmos_fastlock_lock(&onu_rssi_wait_lock);
1189 auto it = onu_rssi_compltd_map.find(onu_key);
1190 if (it == onu_rssi_compltd_map.end()) {
1191 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n",
1192 key->pon_ni, key->onu_id);
1193 } else if (it->second) {
1194 it->second->push(res);
1195 } else {
1196 OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n",
1197 key->pon_ni, key->onu_id);
1198 }
1199 bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0);
1200 }
1201 }
1202 }
1203
1204 bcmolt_msg_free(msg);
1205}
1206
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001207/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001208bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1209 openolt::Indication ind;
1210 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1211 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1212
1213 bcmbal_subscriber_terminal_key *key =
1214 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1215
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001216 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001217 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001218
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001219 onu_proc_error_ind->set_intf_id(key->intf_id);
1220 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1221
1222 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1223 ind.set_allocated_alarm_ind(alarm_ind);
1224
1225 oltIndQ.push(ind);
1226 return BCM_ERR_OK;
1227}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001228*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001229
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001230static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1231
1232 switch (msg->obj_type) {
1233 case BCMOLT_OBJ_ID_GROUP:
1234 switch (msg->subgroup) {
1235 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1236 {
1237 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1238 bcmolt_group_complete_members_update_data *data =
1239 &((bcmolt_group_complete_members_update*)msg)->data;
1240
1241 if (data->result == BCMOLT_RESULT_SUCCESS) {
1242 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1243 } else {
1244 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1245 }
1246 }
1247 }
1248 }
1249 bcmolt_msg_free(msg);
1250}
1251
Shad Ansari01b0e652018-04-05 21:02:53 +00001252Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001253 bcmolt_rx_cfg rx_cfg = {};
1254 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001255
1256 if (subscribed) {
1257 return Status::OK;
1258 }
1259
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001260 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1261 rx_cfg.rx_cb = OltOperIndication;
1262 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1263 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1264 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1265 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301266 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001267 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001268
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001269 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1270 rx_cfg.rx_cb = OltOperIndication;
1271 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1272 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1273 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1274 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301275 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001276 "Olt disconnection complete state indication subscribe failed");
1277
1278 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1279 rx_cfg.rx_cb = OltOperIndication;
1280 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1281 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1282 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1283 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301284 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001285 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001286
1287 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001288 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1289 rx_cfg.rx_cb = LosIndication;
1290 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1291 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1292 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1293 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001294 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001295
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001296 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1297 rx_cfg.rx_cb = IfOperIndication;
1298 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1299 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1300 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1301 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301302 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001303 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001304
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001305 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1306 rx_cfg.rx_cb = IfOperIndication;
1307 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1308 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1309 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1310 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301311 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001312 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001313
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001314 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1315 rx_cfg.rx_cb = OnuAlarmIndication;
1316 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1317 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1318 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1319 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001320 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001321
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001322 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1323 rx_cfg.rx_cb = OnuAlarmIndication;
1324 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1325 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1326 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1327 if(rc != BCM_ERR_OK)
1328 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1329
1330 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1331 rx_cfg.rx_cb = OnuDyingGaspIndication;
1332 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1333 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1334 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1335 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001336 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001337
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001338 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1339 rx_cfg.rx_cb = OnuDiscoveryIndication;
1340 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1341 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1342 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1343 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001344 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001345
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001346 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001347 rx_cfg.rx_cb = OnuStartupFailureIndication;
1348 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1349 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1350 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1351 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301352 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001353 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001354
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001355 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1356 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1357 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1358 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1359 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1360 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001361 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001362
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001363 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1364 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1365 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1366 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1367 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1368 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001369 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001370
1371 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001372 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1373 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1374 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1375 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1376 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1377 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001378 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001379
1380 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001381 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1382 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1383 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1384 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1385 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1386 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001387 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001388
1389 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001390 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1391 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1392 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1393 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1394 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1395 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001396 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001397
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301398 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001399 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301400 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1401 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1402 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1403 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1404 if(rc != BCM_ERR_OK)
1405 return Status(grpc::StatusCode::INTERNAL,
1406 "onu activation completed indication subscribe failed");
1407
1408 /* ONU Deactivation Completed Indication */
1409 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1410 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001411 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1412 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1413 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1414 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301415 return Status(grpc::StatusCode::INTERNAL,
1416 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001417
Jason Huang93430532020-02-04 17:16:02 +08001418 /* ONU Loss of Key Sync Indiction */
1419 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1420 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1421 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1422 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1423 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1424 if(rc != BCM_ERR_OK)
1425 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1426
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001427 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001428 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001429 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001430 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001431 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001432 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1433 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001434 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1435
1436 /* ONU ITU-PON Cleared Stats Indiction */
1437 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1438 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1439 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1440 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1441 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1442 if(rc != BCM_ERR_OK)
1443 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001444
Jason Huang09b73ea2020-01-08 17:52:05 +08001445 /* Packet-In by Access_Control */
1446 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001447 rx_cfg.rx_cb = PacketIndication;
1448 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001449 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001450 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1451 if(rc != BCM_ERR_OK)
1452 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001453
Girish Gowdra96461052019-11-22 20:13:59 +05301454 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1455 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1456 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1457 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1458 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1459 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001460 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +05301461
1462 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM;
1463 rx_cfg.rx_cb = ItuPonGemConfigCompletedInd;
1464 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1465 rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed;
1466 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1467 if(rc != BCM_ERR_OK)
1468 return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301469
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001470 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1471 rx_cfg.rx_cb = GroupIndication;
1472 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1473 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1474 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1475 if(rc != BCM_ERR_OK)
1476 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1477
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001478 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1479 rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication;
1480 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1481 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed;
1482 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1483 if(rc != BCM_ERR_OK)
1484 return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed");
1485
Shad Ansari01b0e652018-04-05 21:02:53 +00001486 subscribed = true;
1487
1488 return Status::OK;
1489}