blob: 681ed99aec468b1d1fc0559715df054862704361 [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;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000039#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000040
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000041static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000042
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000043#define INTERFACE_STATE_IF_DOWN(state) \
44 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
45 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
46 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
47#define INTERFACE_STATE_IF_UP(state) \
48 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
49#define ONU_STATE_IF_DOWN(state) \
50 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
51 state == BCMOLT_ONU_OPERATION_DISABLE || \
52 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
53#define ONU_STATE_IF_UP(state) \
54 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053055#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000056 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053057#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000058 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
59#define SET_OPER_STATE(indication,state) \
60 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
61 indication->set_oper_state("down")
62#define GET_FLOW_TYPE(type) \
63 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
64 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
65 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
66
67std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050068{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000069 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050070 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000071 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050072 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000073 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
74 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050075 }
76 return "unknown";
77}
78
Jason Huang09b73ea2020-01-08 17:52:05 +080079std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000080{
Jason Huang09b73ea2020-01-08 17:52:05 +080081 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000082 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080083 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000084 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080085 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000086 return "host";
87 }
88 return "unknown";
89}
90
Jason Huang5d9ab1a2020-04-15 16:53:49 +080091inline uint64_t get_pon_stats_alarms_data(bcmolt_interface pon_ni, bcmolt_onu_id onu_id, bcmolt_onu_itu_pon_stats_data_id stat) {
92 bcmos_errno err;
93 bcmolt_onu_itu_pon_stats itu_pon_stat; /* declare main API struct */
94 bcmolt_onu_key key = {}; /* declare key */
95 bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE; /* declare 'clear on read' flag */
96
97 key.pon_ni = pon_ni;
98 key.onu_id = onu_id;
99
100 /* Initialize the API struct. */
101 BCMOLT_STAT_INIT(&itu_pon_stat, onu, itu_pon_stats, key);
102 switch (stat) {
103 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
104 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, rdi_errors);
105 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
106 if (err) {
107 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get rdi_errors, err = %s\n", bcmos_strerror(err));
108 return err;
109 }
110 return itu_pon_stat.data.rdi_errors;
111 /* It is a further requirement
112 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
113 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, bip_errors);
114 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
115 if (err) {
116 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get bip_errors, err = %s\n", bcmos_strerror(err));
117 return err;
118 }
119 return itu_pon_stat.data.bip_errors;
120 */
121 default:
122 return BCM_ERR_INTERNAL;
123 }
124
125 return err;
126}
127
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000128/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -0700129 bcmbal_subscriber_terminal_key key;
130 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
131 uint8_t *list_mem;// to fetch config details for ONU
132 bcmos_errno err = BCM_ERR_OK;
133
134 key.sub_term_id =onu_id;
135 key.intf_id = intf_id;
136 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
137
138 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
139
140 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
141 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
142 memset(reg_id, '\0', MAX_REGID_LENGTH);
143
144 //set memory to use for variable-sized lists
145 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
146
147 if (list_mem == NULL)
148 {
149 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
150 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
151 return reg_id;
152 }
153
154 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
155 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
156
157 //call API
158 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
159
160 if (err != BCM_ERR_OK)
161 {
162 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
163 key.sub_term_id, key.intf_id);
164 free(list_mem);
165 return reg_id;
166 }
167
168 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
169 key.sub_term_id, key.intf_id);
170
171 for (int i=0; i<MAX_REGID_LENGTH ; i++){
172 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
173 }
174
175 free(list_mem);
176 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000177}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700178
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000179static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000180 openolt::Indication ind;
181 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500182 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500183
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000184 switch (msg->subgroup) {
185 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
186 admin_state = "up";
187 olt_ind->set_oper_state("up");
188 break;
189 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
190 admin_state = "down";
191 olt_ind->set_oper_state("down");
192 break;
193 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
194 admin_state = "failure";
195 olt_ind->set_oper_state("failure");
196 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000197 }
198 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500199
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000200 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
201 /* register for omci indication */
202 {
203 bcmolt_rx_cfg rx_cfg = {};
204 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
205 rx_cfg.rx_cb = OmciIndication;
206 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
207 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
208 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000209 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500210 state.activate();
211 }
212 else {
213 state.deactivate();
214 }
215
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000216 oltIndQ.push(ind);
217 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000218}
219
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000220static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000221 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400222 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
223 openolt::LosIndication* los_ind = new openolt::LosIndication;
224
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000225 switch (msg->obj_type) {
226 case BCMOLT_OBJ_ID_PON_INTERFACE:
227 switch (msg->subgroup) {
228 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
229 {
230 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
231 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
232 BCMOLT_INTERFACE_TYPE_PON);
233 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400234
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530235 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000236 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400237
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000238 los_ind->set_intf_id(intf_id);
239 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400240
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000241 alarm_ind->set_allocated_los_ind(los_ind);
242 ind.set_allocated_alarm_ind(alarm_ind);
243 break;
244 }
245 }
246 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400247
248 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000249 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000250}
251
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000252static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700253 openolt::Indication ind;
254 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
255
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530256 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000257 case BCMOLT_OBJ_ID_PON_INTERFACE:
258 switch (msg->subgroup) {
259 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530260 {
261 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000262 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530263 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000264 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700265
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000266 intf_ind->set_intf_id(key->pon_ni);
267 SET_OPER_STATE(intf_ind, data->new_state);
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530268
269 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n",
270 bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str());
271
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000272 ind.set_allocated_intf_ind(intf_ind);
273 break;
274 }
275 }
276 break;
277 case BCMOLT_OBJ_ID_NNI_INTERFACE:
278 switch (msg->subgroup) {
279 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
280 {
281 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
282 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530283 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000284 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530285 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000286 &((bcmolt_nni_interface_state_change *)msg)->data;
287
288 intf_ind->set_intf_id(key->id);
289 SET_OPER_STATE(intf_ind, data->new_state);
290 ind.set_allocated_intf_ind(intf_ind);
291 break;
292 }
293 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700294 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700295
296 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000297 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700298}
299
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000300static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000301 openolt::Indication ind;
302 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000303
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000304 switch (msg->obj_type) {
305 case BCMOLT_OBJ_ID_PON_INTERFACE:
306 switch (msg->subgroup) {
307 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
308 {
309 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
310 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
311 intf_oper_ind->set_intf_id(key->pon_ni);
312 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
313 SET_OPER_STATE(intf_oper_ind, data->new_state);
314 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
315 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
316 ind.set_allocated_intf_oper_ind(intf_oper_ind);
317 break;
318 }
319 }
320 case BCMOLT_OBJ_ID_NNI_INTERFACE:
321 switch (msg->subgroup) {
322 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
323 {
324 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
325 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
326 bcmolt_interface intf_id = key->id;
327 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
328 intf_oper_ind->set_intf_id(key->id);
329 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530330 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000331 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
332 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
333 ind.set_allocated_intf_oper_ind(intf_oper_ind);
334 break;
335 }
336 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000337 }
338
Shad Ansari01b0e652018-04-05 21:02:53 +0000339 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000340 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000341}
342
balaji.nagarajan394c7e42025-06-30 18:45:59 +0530343static void OnuDisableIndication(bcmolt_devid olt, bcmolt_msg *msg) {
344 openolt::Indication ind;
345 openolt::OnuDisabledIndication* onu_disable_ind = new openolt::OnuDisabledIndication;
346 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
347
348 switch (msg->obj_type) {
349 case BCMOLT_OBJ_ID_ONU:
350 switch (msg->subgroup) {
351 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DISABLE_COMPLETED:
352 {
353 bcmolt_onu_onu_disable_completed* onu = (bcmolt_onu_onu_disable_completed *)msg;
354 bcmolt_onu_key *key = &((bcmolt_onu_onu_disable_completed *)msg)->key;
355
356 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
357
358 bcmolt_serial_number *in_serial_number = &(onu->data.serial_number);
359
360
361 OPENOLT_LOG(INFO, openolt_log_id, "onu disable indication, pon_ni %d, onu_id %d, port_no %d, status %s, serial_number %s\n",
362 key->pon_ni, key->onu_id, port_no, bcmolt_result_to_string(onu->data.status).c_str(),serial_number_to_str(in_serial_number).c_str());
363
364 onu_disable_ind->set_intf_id(key->pon_ni);
365 onu_disable_ind->set_onu_id(key->onu_id);
366 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
367 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
368 onu_disable_ind->set_allocated_serial_number(serial_number);
369 ind.set_allocated_onu_disabled_ind(onu_disable_ind);
370 break;
371 }
372 }
373 }
374
375 oltIndQ.push(ind);
376 bcmolt_msg_free(msg);
377}
378
379static void OnuEnableIndication(bcmolt_devid olt, bcmolt_msg *msg) {
380 openolt::Indication ind;
381 openolt::OnuEnabledIndication* onu_enable_ind = new openolt::OnuEnabledIndication;
382 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
383
384 switch (msg->obj_type) {
385 case BCMOLT_OBJ_ID_ONU:
386 switch (msg->subgroup) {
387 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ENABLE_COMPLETED:
388 {
389 bcmolt_onu_onu_enable_completed* onu = (bcmolt_onu_onu_enable_completed *)msg;
390 bcmolt_onu_key *key = &((bcmolt_onu_onu_enable_completed *)msg)->key;
391
392 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
393 bcmolt_serial_number *in_serial_number = &(onu->data.serial_number);
394
395 OPENOLT_LOG(INFO, openolt_log_id, "onu enable indication, pon_ni %d, onu_id %d, port_no %d, serial_number %s\n",
396 key->pon_ni, key->onu_id, port_no,serial_number_to_str(in_serial_number).c_str());
397
398 onu_enable_ind->set_intf_id(key->pon_ni);
399 onu_enable_ind->set_onu_id(key->onu_id);
400 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
401 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
402 onu_enable_ind->set_allocated_serial_number(serial_number);
403
404 ind.set_allocated_onu_enabled_ind(onu_enable_ind);
405 break;
406 }
407 }
408 }
409
410 oltIndQ.push(ind);
411 bcmolt_msg_free(msg);
412}
413
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000414static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000415 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400416 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
417 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
418
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000419 switch (msg->obj_type) {
420 case BCMOLT_OBJ_ID_ONU:
421 switch (msg->subgroup) {
422 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
423 {
Jason Huang93430532020-02-04 17:16:02 +0800424 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
425 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530426
427 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
428
429 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());
430
Jason Huang93430532020-02-04 17:16:02 +0800431 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
432 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
433 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
434 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
435 onu_alarm_ind->set_intf_id(key->pon_ni);
436 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000437 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
438 ind.set_allocated_alarm_ind(alarm_ind);
439 break;
440 }
441 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
442 {
Jason Huang93430532020-02-04 17:16:02 +0800443 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
444 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
445 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
446 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
447 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
448 onu_alarm_ind->set_intf_id(key->pon_ni);
449 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000450 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
451 ind.set_allocated_alarm_ind(alarm_ind);
452 break;
453 }
454 }
455 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400456
457 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000458 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000459}
460
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000461static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000462 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400463 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000464 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400465
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000466 switch (msg->obj_type) {
467 case BCMOLT_OBJ_ID_ONU:
468 switch (msg->subgroup) {
469 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
470 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500471 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500472 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
473
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530474 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
475
476 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
477 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
478
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500479 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500480 dgi_ind->set_intf_id(key->pon_ni);
481 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400482
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000483 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
484 ind.set_allocated_alarm_ind(alarm_ind);
485 break;
486 }
487 }
488 }
nickc063ffd2018-05-22 14:35:28 -0400489
490 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 OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Abhilash Laxmeshwar3b190f02022-06-13 21:21:56 +0530495 //Ignore the onu discovery when agent is not connected to VOLTHA
496 if (!state.is_connected()) {
497 bcmolt_msg_free(msg);
498 return;
499 }
500
Shad Ansari01b0e652018-04-05 21:02:53 +0000501 openolt::Indication ind;
502 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
503 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
504
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000505 switch (msg->obj_type) {
506 case BCMOLT_OBJ_ID_PON_INTERFACE:
507 switch (msg->subgroup) {
508 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
509 {
510 bcmolt_pon_interface_key *key =
511 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000512
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530513 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000514 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000515
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000516 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000517
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000518 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
519 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000520
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000521 onu_disc_ind->set_intf_id(key->pon_ni);
522 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
523 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
524 onu_disc_ind->set_allocated_serial_number(serial_number);
525 ind.set_allocated_onu_disc_ind(onu_disc_ind);
526 break;
527 }
528 }
529 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000530
531 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000532 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000533}
534
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000535static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000536 openolt::Indication ind;
537 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000538
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000539 switch (msg->obj_type) {
540 case BCMOLT_OBJ_ID_ONU:
541 switch (msg->subgroup) {
542 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
543 {
544 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
545 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000546
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530547 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000548 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000549
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000550 omci_ind->set_intf_id(key->pon_ni);
551 omci_ind->set_onu_id(key->onu_id);
552 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
553
554 ind.set_allocated_omci_ind(omci_ind);
555 break;
556 }
557 }
558 }
559
Shad Ansari01b0e652018-04-05 21:02:53 +0000560 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000561 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000562}
563
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000564static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000565 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000566
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000567 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800568 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000569 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800570 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000571 {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700572 int32_t gemport_id;
Jason Huang09b73ea2020-01-08 17:52:05 +0800573 bcmolt_access_control_receive_eth_packet *pkt =
574 (bcmolt_access_control_receive_eth_packet*)msg;
575 bcmolt_access_control_receive_eth_packet_data *pkt_data =
576 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000577
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700578 // Set the gemport_id to be passed to is_packet_allowed function
579 gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id;
580
581 // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet.
582 if (! is_packet_allowed(pkt_data, gemport_id) ) {
583 OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n");
584 bcmolt_msg_free(msg);
585 return;
586 }
587 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Jason Huang09b73ea2020-01-08 17:52:05 +0800588 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
589 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
590 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000591 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800592 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700593 if (pkt_data->svc_port_id != BCMOLT_SERVICE_PORT_ID_INVALID) { // case of packet-in from the PON interface
594 pon_gem pg((uint32_t)pkt_data->interface_ref.intf_id, pkt_data->svc_port_id);
595 // Find to onu-uni mapping for the pon-gem key
596 bcmos_fastlock_lock(&pon_gem_to_onu_uni_map_lock);
597 auto it = pon_gem_to_onu_uni_map.find(pg);
598 bcmos_fastlock_unlock(&pon_gem_to_onu_uni_map_lock, 0);
599 if (it == pon_gem_to_onu_uni_map.end()) {
600 bcmolt_msg_free(msg);
601 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);
602 return;
603 }
604 pkt_ind->set_onu_id(std::get<0>(it->second));
605 pkt_ind->set_uni_id(std::get<1>(it->second));
606 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000607 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500608
Jason Huang09b73ea2020-01-08 17:52:05 +0800609 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700610 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",
611 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 +0800612 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700613 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
614 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
Jason Huang09b73ea2020-01-08 17:52:05 +0800615 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000616 }
617 }
618 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500619
Shad Ansari5fe93682018-04-26 05:24:19 +0000620 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000621 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000622}
623
Girish Gowdra96461052019-11-22 20:13:59 +0530624static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
625
626 switch (msg->obj_type) {
627 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
628 switch (msg->subgroup) {
629 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
630 {
631 bcmolt_itupon_alloc_configuration_completed *pkt =
632 (bcmolt_itupon_alloc_configuration_completed*)msg;
633 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
634 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
635
636 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
637 alloc_cfg_complete_result res;
638 res.pon_intf_id = pkt->key.pon_ni;
639 res.alloc_id = pkt->key.alloc_id;
640
641 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
642 switch (pkt_data->new_state) {
643 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
644 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
645 break;
646 case BCMOLT_ACTIVATION_STATE_INACTIVE:
647 res.state = ALLOC_OBJECT_STATE_INACTIVE;
648 break;
649 case BCMOLT_ACTIVATION_STATE_PROCESSING:
650 res.state = ALLOC_OBJECT_STATE_PROCESSING;
651 break;
652 case BCMOLT_ACTIVATION_STATE_ACTIVE:
653 res.state = ALLOC_OBJECT_STATE_ACTIVE;
654 break;
655 default:
656 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
657 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
658 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
659 }
660 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",
661 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
662
663 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
664 // Push the result from BAL to queue
665 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
666 if (it == alloc_cfg_compltd_map.end()) {
667 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
668 bcmolt_msg_free(msg);
669 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);
670 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
671 return;
672 }
673 if (it->second) {
674 // Push the result
675 it->second->push(res);
676 }
677 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
678 }
679 }
680 }
681
682 bcmolt_msg_free(msg);
683}
684
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +0530685static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
686
687 switch (msg->obj_type) {
688 case BCMOLT_OBJ_ID_ITUPON_GEM:
689 switch (msg->subgroup) {
690 case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
691 {
692 bcmolt_itupon_gem_configuration_completed *pkt =
693 (bcmolt_itupon_gem_configuration_completed*)msg;
694 bcmolt_itupon_gem_configuration_completed_data *pkt_data =
695 &((bcmolt_itupon_gem_configuration_completed*)msg)->data;
696
697 gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id);
698 gem_cfg_complete_result res;
699 res.pon_intf_id = pkt->key.pon_ni;
700 res.gem_port_id = pkt->key.gem_port_id;
701
702 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL;
703 switch (pkt_data->new_state) {
704 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
705 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
706 break;
707 case BCMOLT_ACTIVATION_STATE_INACTIVE:
708 res.state = GEM_OBJECT_STATE_INACTIVE;
709 break;
710 case BCMOLT_ACTIVATION_STATE_PROCESSING:
711 res.state = GEM_OBJECT_STATE_PROCESSING;
712 break;
713 case BCMOLT_ACTIVATION_STATE_ACTIVE:
714 res.state = GEM_OBJECT_STATE_ACTIVE;
715 break;
716 default:
717 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n",
718 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state);
719 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
720 }
721 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",
722 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state);
723
724 uint32_t gem_cfg_key_check_counter = 1;
725 std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it;
726 while(true) {
727 bcmos_fastlock_lock(&gem_cfg_wait_lock);
728 // Push the result from BAL to queue
729 it = gem_cfg_compltd_map.find(key);
730
731 if (it != gem_cfg_compltd_map.end()) {
732 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
733 break;
734 } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) {
735 /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion
736 by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication
737 to Queue by 6ms.*/
738 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
739 bcmos_usleep(6000);
740 } else {
741 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
742 bcmolt_msg_free(msg);
743 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);
744 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
745 return;
746 }
747 gem_cfg_key_check_counter++;
748 }
749
750 bcmos_fastlock_lock(&gem_cfg_wait_lock);
751 if (it->second) {
752 // Push the result
753 it->second->push(res);
754 }
755 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
756 }
757 }
758 }
759
760 bcmolt_msg_free(msg);
761}
762
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000763static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000764 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000765 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
766 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000767}
768
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000769static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000770 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000771 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
772 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000773}
774
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000775static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000776 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000777 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
778 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000779}
780
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000781static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000782 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000783 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
784 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000785}
786
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000787static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000788 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000789 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
790 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000791}
792
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000793static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400794 openolt::Indication ind;
795 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
796 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
797
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000798 switch (msg->obj_type) {
799 case BCMOLT_OBJ_ID_ONU:
800 switch (msg->subgroup) {
801 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
802 {
803 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
804 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400805
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000806 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
807 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400808
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000809 sufi_ind->set_intf_id(key->pon_ni);
810 sufi_ind->set_onu_id(key->onu_id);
811 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
812 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400813
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000814 ind.set_allocated_alarm_ind(alarm_ind);
815 }
816 }
817 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400818
819 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000820 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400821}
822
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000823static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400824 openolt::Indication ind;
825 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
826 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
827
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000828 switch (msg->obj_type) {
829 case BCMOLT_OBJ_ID_ONU:
830 switch (msg->subgroup) {
831 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
832 {
833 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
834 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400835
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000836 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
837 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400838
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000839 sdi_ind->set_intf_id(key->pon_ni);
840 sdi_ind->set_onu_id(key->onu_id);
841 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
842 sdi_ind->set_inverse_bit_error_rate(data->ber);
843 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400844
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000845 ind.set_allocated_alarm_ind(alarm_ind);
846 }
847 }
848 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400849
850 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000851 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400852}
853
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000854static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400855 openolt::Indication ind;
856 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
857 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
858
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000859 switch (msg->obj_type) {
860 case BCMOLT_OBJ_ID_ONU:
861 switch (msg->subgroup) {
862 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
863 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530864 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000865 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400866
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000867 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",
868 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400869
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000870 dowi_ind->set_intf_id(key->pon_ni);
871 dowi_ind->set_onu_id(key->onu_id);
872 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
873 dowi_ind->set_drift(data->drift_value);
874 dowi_ind->set_new_eqd(data->new_eqd);
875 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400876
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000877 ind.set_allocated_alarm_ind(alarm_ind);
878 }
879 }
880 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400881
882 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000883 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400884}
885
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000886static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400887 openolt::Indication ind;
888 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
889 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
890
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000891 switch (msg->obj_type) {
892 case BCMOLT_OBJ_ID_ONU:
893 switch (msg->subgroup) {
894 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
895 {
896 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
897 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400898
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000899 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
900 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400901
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000902 looci_ind->set_intf_id(key->pon_ni);
903 looci_ind->set_onu_id(key->onu_id);
904 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
905 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400906
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000907 ind.set_allocated_alarm_ind(alarm_ind);
908 }
909 }
910 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400911
912 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000913 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400914}
915
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000916static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400917 openolt::Indication ind;
918 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
919 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
920
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000921 switch (msg->obj_type) {
922 case BCMOLT_OBJ_ID_ONU:
923 switch (msg->subgroup) {
924 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
925 {
926 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
927 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400928
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000929 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
930 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400931
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000932 sfi_ind->set_intf_id(key->pon_ni);
933 sfi_ind->set_onu_id(key->onu_id);
934 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
935 sfi_ind->set_inverse_bit_error_rate(data->ber);
936 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400937
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000938 ind.set_allocated_alarm_ind(alarm_ind);
939 }
940 }
941 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400942
943 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000944 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400945}
946
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000947static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400948 openolt::Indication ind;
949 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
950 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
951
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000952 switch (msg->obj_type) {
953 case BCMOLT_OBJ_ID_ONU:
954 switch (msg->subgroup) {
955 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
956 {
957 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
958 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400959
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000960 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
961 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400962
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000963 tiwi_ind->set_intf_id(key->pon_ni);
964 tiwi_ind->set_onu_id(key->onu_id);
965 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
966 tiwi_ind->set_drift(data->drift_value);
967 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400968
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000969 ind.set_allocated_alarm_ind(alarm_ind);
970 }
971 }
972 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400973
974 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000975 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400976}
977
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530978static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400979 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530980 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
981
982 switch (msg->obj_type) {
983 case BCMOLT_OBJ_ID_ONU:
984 switch (msg->subgroup) {
985 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
986 {
987 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
988 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
989
990 onu_ind->set_intf_id(key->pon_ni);
991 onu_ind->set_onu_id(key->onu_id);
992 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
993 onu_ind->set_oper_state("up");
994 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
995 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530996 switch (data->fail_reason) {
997 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
998 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
999 break;
1000 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
1001 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
1002 break;
1003 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
1004 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
1005 break;
1006 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
1007 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
1008 break;
1009 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
1010 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
1011 break;
1012 default:
1013 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
1014 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301015 // Setting the admin_state state field based on a valid onu_id does not make any sense.
1016 // The adapter too does not seem to interpret this seriously.
1017 // Legacy code, lets keep this as is for now.
1018 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
1019 ind.set_allocated_onu_ind(onu_ind);
1020 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
1021 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
1022 (key->onu_id)?"up":"down");
1023 }
1024 }
1025 }
1026
1027 oltIndQ.push(ind);
1028 bcmolt_msg_free(msg);
1029}
1030
Jason Huang93430532020-02-04 17:16:02 +08001031static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1032 openolt::Indication ind;
1033 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1034 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
1035
1036 switch (msg->obj_type) {
1037 case BCMOLT_OBJ_ID_ONU:
1038 switch (msg->subgroup) {
1039 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
1040 {
1041 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
1042 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
1043
1044 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
1045 key->pon_ni, key->onu_id, data->alarm_status);
1046
1047 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
1048 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
1049 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
1050 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
1051
1052 ind.set_allocated_alarm_ind(alarm_ind);
1053 }
1054 }
1055 }
1056
1057 oltIndQ.push(ind);
1058 bcmolt_msg_free(msg);
1059}
1060
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001061static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +08001062 openolt::Indication ind;
1063 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1064 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
1065
1066 switch (msg->obj_type) {
1067 case BCMOLT_OBJ_ID_ONU:
1068 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001069 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +08001070 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001071 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
1072 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 +08001073
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001074 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
1075 switch (data->stat)
1076 {
1077 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1078 uint64_t rdi_errors;
1079 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1080 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1081 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1082 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1083 rdi_err_ind->set_rdi_error_count(rdi_errors);
1084 rdi_err_ind->set_status("on");
1085 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1086 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1087 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1088 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1089 break;
1090 /* It is a further requirement
1091 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1092 uint64_t bip_errors;
1093 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1094 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1095 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1096 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1097 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1098 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1099 break;
1100 */
1101 }
1102 ind.set_allocated_alarm_ind(alarm_ind);
1103 }
Jason Huang93430532020-02-04 17:16:02 +08001104 }
1105 }
1106 }
1107
1108 oltIndQ.push(ind);
1109 bcmolt_msg_free(msg);
1110}
1111
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001112static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1113 openolt::Indication ind;
1114 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1115 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +08001116
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001117 switch (msg->obj_type) {
1118 case BCMOLT_OBJ_ID_ONU:
1119 switch (msg->subgroup) {
1120 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
1121 {
1122 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
1123 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
1124
1125 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
1126 switch (data->stat)
1127 {
1128 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1129 uint64_t rdi_errors;
1130 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1131
1132 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1133 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1134 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1135 rdi_err_ind->set_rdi_error_count(rdi_errors);
1136 rdi_err_ind->set_status("off");
1137 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1138 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1139 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1140 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1141 break;
1142 /* It is a further requirement
1143 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1144 uint64_t bip_errors;
1145 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1146 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1147 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1148 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
1149 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1150 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1151 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1152 break;
1153 */
1154 }
1155 ind.set_allocated_alarm_ind(alarm_ind);
1156 }
1157 }
1158 }
1159 }
1160
1161 oltIndQ.push(ind);
1162 bcmolt_msg_free(msg);
1163}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301164
1165static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1166 openolt::Indication ind;
1167
1168 openolt::Indication onu_ind;
1169 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001170
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001171 switch (msg->obj_type) {
1172 case BCMOLT_OBJ_ID_ONU:
1173 switch (msg->subgroup) {
1174 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1175 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301176 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1177 bcmolt_onu_onu_deactivation_completed_data *data =
1178 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001179
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301180 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1181 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001182
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301183 onu_ind_data->set_intf_id(key->pon_ni);
1184 onu_ind_data->set_onu_id(key->onu_id);
1185 onu_ind_data->set_oper_state("down");
1186 onu_ind_data->set_admin_state("down");
1187 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301188
1189 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1190 onu_deactivate_complete_result res;
1191 res.pon_intf_id = (uint32_t)key->pon_ni;
1192 res.onu_id = (uint32_t) key->onu_id;
1193 res.result = data->status;
1194 res.reason = data->fail_reason;
1195
1196 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1197 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1198
1199 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1200 // Push the result from BAL to queue
1201 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1202 if (it == onu_deact_compltd_map.end()) {
1203 // 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 -08001204 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1205 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1206 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301207 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 +05301208 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301209 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001210 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301211 // Push the result
1212 it->second->push(res);
1213 }
1214 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001215 }
1216 }
1217 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001218
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301219 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001220 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001221}
1222
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001223static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1224 switch (msg->obj_type) {
1225 case BCMOLT_OBJ_ID_ONU:
1226 switch (msg->subgroup) {
1227 case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED:
1228 {
1229 bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key;
1230 bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data;
1231 double rx_power_mean_dbm = 0.0;
1232
1233 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n",
1234 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1235
1236 if (data->status == BCMOLT_RESULT_SUCCESS) {
1237 auto trx_eeprom_reader =
1238#ifdef ASGVOLT64
1239 TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni};
1240#else
1241 TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni};
1242#endif
1243 auto power = trx_eeprom_reader.read_power_mean_dbm();
1244
1245 if (power.second) {
1246 rx_power_mean_dbm = power.first.first;
1247 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm);
1248 } else {
1249 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n");
1250 }
1251 } else {
1252 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure");
1253 }
1254
1255 // for internal use insert into map
1256 onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id);
1257 onu_rssi_complete_result res;
1258 res.pon_intf_id = (uint32_t)key->pon_ni;
1259 res.onu_id = (uint32_t)key->onu_id;
1260 res.status = bcmolt_result_to_string(data->status);
1261 res.reason = data->fail_reason;
1262 res.rx_power_mean_dbm = rx_power_mean_dbm;
1263
1264 bcmos_fastlock_lock(&onu_rssi_wait_lock);
1265 auto it = onu_rssi_compltd_map.find(onu_key);
1266 if (it == onu_rssi_compltd_map.end()) {
1267 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n",
1268 key->pon_ni, key->onu_id);
1269 } else if (it->second) {
1270 it->second->push(res);
1271 } else {
1272 OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n",
1273 key->pon_ni, key->onu_id);
1274 }
1275 bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0);
1276 }
1277 }
1278 }
1279
1280 bcmolt_msg_free(msg);
1281}
1282
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001283/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001284bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1285 openolt::Indication ind;
1286 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1287 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1288
1289 bcmbal_subscriber_terminal_key *key =
1290 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1291
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001292 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001293 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001294
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001295 onu_proc_error_ind->set_intf_id(key->intf_id);
1296 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1297
1298 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1299 ind.set_allocated_alarm_ind(alarm_ind);
1300
1301 oltIndQ.push(ind);
1302 return BCM_ERR_OK;
1303}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001304*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001305
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001306static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1307
1308 switch (msg->obj_type) {
1309 case BCMOLT_OBJ_ID_GROUP:
1310 switch (msg->subgroup) {
1311 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1312 {
1313 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1314 bcmolt_group_complete_members_update_data *data =
1315 &((bcmolt_group_complete_members_update*)msg)->data;
1316
1317 if (data->result == BCMOLT_RESULT_SUCCESS) {
1318 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1319 } else {
1320 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1321 }
1322 }
1323 }
1324 }
1325 bcmolt_msg_free(msg);
1326}
1327
Shad Ansari01b0e652018-04-05 21:02:53 +00001328Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001329 bcmolt_rx_cfg rx_cfg = {};
1330 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001331
1332 if (subscribed) {
1333 return Status::OK;
1334 }
1335
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001336 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1337 rx_cfg.rx_cb = OltOperIndication;
1338 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1339 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1340 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1341 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301342 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001343 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001344
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001345 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1346 rx_cfg.rx_cb = OltOperIndication;
1347 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1348 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1349 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1350 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301351 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001352 "Olt disconnection complete state indication subscribe failed");
1353
1354 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1355 rx_cfg.rx_cb = OltOperIndication;
1356 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1357 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1358 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1359 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301360 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001361 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001362
1363 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001364 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1365 rx_cfg.rx_cb = LosIndication;
1366 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1367 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1368 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1369 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001370 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001371
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001372 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1373 rx_cfg.rx_cb = IfOperIndication;
1374 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1375 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1376 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1377 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301378 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001379 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001380
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001381 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1382 rx_cfg.rx_cb = IfOperIndication;
1383 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1384 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1385 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1386 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301387 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001388 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001389
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001390 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1391 rx_cfg.rx_cb = OnuAlarmIndication;
1392 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1393 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1394 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1395 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001396 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001397
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001398 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1399 rx_cfg.rx_cb = OnuAlarmIndication;
1400 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1401 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1402 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1403 if(rc != BCM_ERR_OK)
1404 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1405
1406 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1407 rx_cfg.rx_cb = OnuDyingGaspIndication;
1408 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1409 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1410 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1411 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001412 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001413
balaji.nagarajan394c7e42025-06-30 18:45:59 +05301414 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1415 rx_cfg.rx_cb = OnuDisableIndication;
1416 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1417 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_disable_completed;
1418 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1419 if(rc != BCM_ERR_OK)
1420 return Status(grpc::StatusCode::INTERNAL, "onu disable indication subscribe failed");
1421
1422 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1423 rx_cfg.rx_cb = OnuEnableIndication;
1424 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1425 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_enable_completed;
1426 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1427 if(rc != BCM_ERR_OK)
1428 return Status(grpc::StatusCode::INTERNAL, "onu enable indication subscribe failed");
1429
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001430 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1431 rx_cfg.rx_cb = OnuDiscoveryIndication;
1432 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1433 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1434 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1435 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001436 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001437
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001438 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001439 rx_cfg.rx_cb = OnuStartupFailureIndication;
1440 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1441 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1442 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1443 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301444 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001445 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001446
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001447 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1448 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1449 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1450 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1451 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1452 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001453 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001454
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001455 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1456 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1457 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1458 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1459 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1460 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001461 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001462
1463 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001464 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1465 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1466 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1467 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1468 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1469 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001470 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001471
1472 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001473 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1474 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1475 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1476 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1477 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1478 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001479 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001480
1481 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001482 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1483 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1484 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1485 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1486 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1487 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001488 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001489
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301490 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001491 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301492 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1493 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1494 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1495 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1496 if(rc != BCM_ERR_OK)
1497 return Status(grpc::StatusCode::INTERNAL,
1498 "onu activation completed indication subscribe failed");
1499
1500 /* ONU Deactivation Completed Indication */
1501 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1502 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001503 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1504 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1505 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1506 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301507 return Status(grpc::StatusCode::INTERNAL,
1508 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001509
Jason Huang93430532020-02-04 17:16:02 +08001510 /* ONU Loss of Key Sync Indiction */
1511 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1512 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1513 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1514 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1515 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1516 if(rc != BCM_ERR_OK)
1517 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1518
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001519 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001520 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001521 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001522 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001523 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001524 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1525 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001526 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1527
1528 /* ONU ITU-PON Cleared Stats Indiction */
1529 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1530 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1531 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1532 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1533 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1534 if(rc != BCM_ERR_OK)
1535 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001536
Jason Huang09b73ea2020-01-08 17:52:05 +08001537 /* Packet-In by Access_Control */
1538 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001539 rx_cfg.rx_cb = PacketIndication;
1540 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001541 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001542 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1543 if(rc != BCM_ERR_OK)
1544 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001545
Girish Gowdra96461052019-11-22 20:13:59 +05301546 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1547 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1548 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1549 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1550 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1551 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001552 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +05301553
1554 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM;
1555 rx_cfg.rx_cb = ItuPonGemConfigCompletedInd;
1556 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1557 rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed;
1558 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1559 if(rc != BCM_ERR_OK)
1560 return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301561
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001562 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1563 rx_cfg.rx_cb = GroupIndication;
1564 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1565 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1566 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1567 if(rc != BCM_ERR_OK)
1568 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1569
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001570 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1571 rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication;
1572 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1573 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed;
1574 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1575 if(rc != BCM_ERR_OK)
1576 return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed");
1577
Shad Ansari01b0e652018-04-05 21:02:53 +00001578 subscribed = true;
1579
1580 return Status::OK;
1581}