blob: f24dca90d7e7c191b41b91badac10dc162732988 [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
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000343static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000344 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400345 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
346 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
347
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000348 switch (msg->obj_type) {
349 case BCMOLT_OBJ_ID_ONU:
350 switch (msg->subgroup) {
351 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
352 {
Jason Huang93430532020-02-04 17:16:02 +0800353 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
354 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530355
356 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
357
358 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());
359
Jason Huang93430532020-02-04 17:16:02 +0800360 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
361 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
362 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
363 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
364 onu_alarm_ind->set_intf_id(key->pon_ni);
365 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000366 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
367 ind.set_allocated_alarm_ind(alarm_ind);
368 break;
369 }
370 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
371 {
Jason Huang93430532020-02-04 17:16:02 +0800372 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
373 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
374 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
375 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
376 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
377 onu_alarm_ind->set_intf_id(key->pon_ni);
378 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000379 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
380 ind.set_allocated_alarm_ind(alarm_ind);
381 break;
382 }
383 }
384 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400385
386 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000387 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000388}
389
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000390static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000391 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400392 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000393 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400394
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000395 switch (msg->obj_type) {
396 case BCMOLT_OBJ_ID_ONU:
397 switch (msg->subgroup) {
398 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
399 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500400 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500401 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
402
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530403 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
404
405 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
406 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
407
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500408 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500409 dgi_ind->set_intf_id(key->pon_ni);
410 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400411
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000412 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
413 ind.set_allocated_alarm_ind(alarm_ind);
414 break;
415 }
416 }
417 }
nickc063ffd2018-05-22 14:35:28 -0400418
419 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000420 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000421}
422
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000423static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Abhilash Laxmeshwar3b190f02022-06-13 21:21:56 +0530424 //Ignore the onu discovery when agent is not connected to VOLTHA
425 if (!state.is_connected()) {
426 bcmolt_msg_free(msg);
427 return;
428 }
429
Shad Ansari01b0e652018-04-05 21:02:53 +0000430 openolt::Indication ind;
431 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
432 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
433
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000434 switch (msg->obj_type) {
435 case BCMOLT_OBJ_ID_PON_INTERFACE:
436 switch (msg->subgroup) {
437 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
438 {
439 bcmolt_pon_interface_key *key =
440 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000441
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530442 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000443 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000444
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000445 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000446
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000447 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
448 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000449
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000450 onu_disc_ind->set_intf_id(key->pon_ni);
451 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
452 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
453 onu_disc_ind->set_allocated_serial_number(serial_number);
454 ind.set_allocated_onu_disc_ind(onu_disc_ind);
455 break;
456 }
457 }
458 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000459
460 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000461 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000462}
463
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000464static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000465 openolt::Indication ind;
466 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000467
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000468 switch (msg->obj_type) {
469 case BCMOLT_OBJ_ID_ONU:
470 switch (msg->subgroup) {
471 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
472 {
473 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
474 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000475
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530476 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000477 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000478
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000479 omci_ind->set_intf_id(key->pon_ni);
480 omci_ind->set_onu_id(key->onu_id);
481 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
482
483 ind.set_allocated_omci_ind(omci_ind);
484 break;
485 }
486 }
487 }
488
Shad Ansari01b0e652018-04-05 21:02:53 +0000489 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000490 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000491}
492
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000493static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000494 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000495
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000496 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800497 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000498 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800499 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000500 {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700501 int32_t gemport_id;
Jason Huang09b73ea2020-01-08 17:52:05 +0800502 bcmolt_access_control_receive_eth_packet *pkt =
503 (bcmolt_access_control_receive_eth_packet*)msg;
504 bcmolt_access_control_receive_eth_packet_data *pkt_data =
505 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000506
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700507 // Set the gemport_id to be passed to is_packet_allowed function
508 gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id;
509
510 // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet.
511 if (! is_packet_allowed(pkt_data, gemport_id) ) {
512 OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n");
513 bcmolt_msg_free(msg);
514 return;
515 }
516 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Jason Huang09b73ea2020-01-08 17:52:05 +0800517 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
518 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
519 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000520 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800521 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700522 if (pkt_data->svc_port_id != BCMOLT_SERVICE_PORT_ID_INVALID) { // case of packet-in from the PON interface
523 pon_gem pg((uint32_t)pkt_data->interface_ref.intf_id, pkt_data->svc_port_id);
524 // Find to onu-uni mapping for the pon-gem key
525 bcmos_fastlock_lock(&pon_gem_to_onu_uni_map_lock);
526 auto it = pon_gem_to_onu_uni_map.find(pg);
527 bcmos_fastlock_unlock(&pon_gem_to_onu_uni_map_lock, 0);
528 if (it == pon_gem_to_onu_uni_map.end()) {
529 bcmolt_msg_free(msg);
530 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);
531 return;
532 }
533 pkt_ind->set_onu_id(std::get<0>(it->second));
534 pkt_ind->set_uni_id(std::get<1>(it->second));
535 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000536 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500537
Jason Huang09b73ea2020-01-08 17:52:05 +0800538 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700539 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",
540 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 +0800541 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
Girish Gowdraeec0fc92021-05-12 15:37:55 -0700542 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
543 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
Jason Huang09b73ea2020-01-08 17:52:05 +0800544 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000545 }
546 }
547 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500548
Shad Ansari5fe93682018-04-26 05:24:19 +0000549 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000550 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000551}
552
Girish Gowdra96461052019-11-22 20:13:59 +0530553static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
554
555 switch (msg->obj_type) {
556 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
557 switch (msg->subgroup) {
558 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
559 {
560 bcmolt_itupon_alloc_configuration_completed *pkt =
561 (bcmolt_itupon_alloc_configuration_completed*)msg;
562 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
563 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
564
565 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
566 alloc_cfg_complete_result res;
567 res.pon_intf_id = pkt->key.pon_ni;
568 res.alloc_id = pkt->key.alloc_id;
569
570 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
571 switch (pkt_data->new_state) {
572 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
573 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
574 break;
575 case BCMOLT_ACTIVATION_STATE_INACTIVE:
576 res.state = ALLOC_OBJECT_STATE_INACTIVE;
577 break;
578 case BCMOLT_ACTIVATION_STATE_PROCESSING:
579 res.state = ALLOC_OBJECT_STATE_PROCESSING;
580 break;
581 case BCMOLT_ACTIVATION_STATE_ACTIVE:
582 res.state = ALLOC_OBJECT_STATE_ACTIVE;
583 break;
584 default:
585 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
586 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
587 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
588 }
589 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",
590 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
591
592 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
593 // Push the result from BAL to queue
594 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
595 if (it == alloc_cfg_compltd_map.end()) {
596 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
597 bcmolt_msg_free(msg);
598 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);
599 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
600 return;
601 }
602 if (it->second) {
603 // Push the result
604 it->second->push(res);
605 }
606 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
607 }
608 }
609 }
610
611 bcmolt_msg_free(msg);
612}
613
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +0530614static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
615
616 switch (msg->obj_type) {
617 case BCMOLT_OBJ_ID_ITUPON_GEM:
618 switch (msg->subgroup) {
619 case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
620 {
621 bcmolt_itupon_gem_configuration_completed *pkt =
622 (bcmolt_itupon_gem_configuration_completed*)msg;
623 bcmolt_itupon_gem_configuration_completed_data *pkt_data =
624 &((bcmolt_itupon_gem_configuration_completed*)msg)->data;
625
626 gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id);
627 gem_cfg_complete_result res;
628 res.pon_intf_id = pkt->key.pon_ni;
629 res.gem_port_id = pkt->key.gem_port_id;
630
631 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL;
632 switch (pkt_data->new_state) {
633 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
634 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
635 break;
636 case BCMOLT_ACTIVATION_STATE_INACTIVE:
637 res.state = GEM_OBJECT_STATE_INACTIVE;
638 break;
639 case BCMOLT_ACTIVATION_STATE_PROCESSING:
640 res.state = GEM_OBJECT_STATE_PROCESSING;
641 break;
642 case BCMOLT_ACTIVATION_STATE_ACTIVE:
643 res.state = GEM_OBJECT_STATE_ACTIVE;
644 break;
645 default:
646 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n",
647 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state);
648 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
649 }
650 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",
651 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state);
652
653 uint32_t gem_cfg_key_check_counter = 1;
654 std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it;
655 while(true) {
656 bcmos_fastlock_lock(&gem_cfg_wait_lock);
657 // Push the result from BAL to queue
658 it = gem_cfg_compltd_map.find(key);
659
660 if (it != gem_cfg_compltd_map.end()) {
661 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
662 break;
663 } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) {
664 /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion
665 by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication
666 to Queue by 6ms.*/
667 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
668 bcmos_usleep(6000);
669 } else {
670 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
671 bcmolt_msg_free(msg);
672 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);
673 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
674 return;
675 }
676 gem_cfg_key_check_counter++;
677 }
678
679 bcmos_fastlock_lock(&gem_cfg_wait_lock);
680 if (it->second) {
681 // Push the result
682 it->second->push(res);
683 }
684 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
685 }
686 }
687 }
688
689 bcmolt_msg_free(msg);
690}
691
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000692static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000693 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000694 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
695 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000696}
697
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000698static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000699 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000700 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
701 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000702}
703
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000704static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000705 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000706 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
707 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000708}
709
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000710static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000711 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000712 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
713 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000714}
715
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000716static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000717 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000718 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
719 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000720}
721
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000722static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400723 openolt::Indication ind;
724 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
725 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
726
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000727 switch (msg->obj_type) {
728 case BCMOLT_OBJ_ID_ONU:
729 switch (msg->subgroup) {
730 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
731 {
732 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
733 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400734
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000735 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
736 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400737
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000738 sufi_ind->set_intf_id(key->pon_ni);
739 sufi_ind->set_onu_id(key->onu_id);
740 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
741 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400742
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000743 ind.set_allocated_alarm_ind(alarm_ind);
744 }
745 }
746 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400747
748 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000749 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400750}
751
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000752static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400753 openolt::Indication ind;
754 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
755 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
756
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000757 switch (msg->obj_type) {
758 case BCMOLT_OBJ_ID_ONU:
759 switch (msg->subgroup) {
760 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
761 {
762 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
763 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400764
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000765 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
766 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400767
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000768 sdi_ind->set_intf_id(key->pon_ni);
769 sdi_ind->set_onu_id(key->onu_id);
770 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
771 sdi_ind->set_inverse_bit_error_rate(data->ber);
772 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400773
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000774 ind.set_allocated_alarm_ind(alarm_ind);
775 }
776 }
777 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400778
779 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000780 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400781}
782
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000783static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400784 openolt::Indication ind;
785 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
786 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
787
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000788 switch (msg->obj_type) {
789 case BCMOLT_OBJ_ID_ONU:
790 switch (msg->subgroup) {
791 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
792 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530793 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000794 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400795
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000796 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",
797 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400798
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000799 dowi_ind->set_intf_id(key->pon_ni);
800 dowi_ind->set_onu_id(key->onu_id);
801 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
802 dowi_ind->set_drift(data->drift_value);
803 dowi_ind->set_new_eqd(data->new_eqd);
804 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400805
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000806 ind.set_allocated_alarm_ind(alarm_ind);
807 }
808 }
809 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400810
811 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000812 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400813}
814
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000815static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400816 openolt::Indication ind;
817 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
818 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
819
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000820 switch (msg->obj_type) {
821 case BCMOLT_OBJ_ID_ONU:
822 switch (msg->subgroup) {
823 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
824 {
825 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
826 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400827
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000828 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
829 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400830
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000831 looci_ind->set_intf_id(key->pon_ni);
832 looci_ind->set_onu_id(key->onu_id);
833 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
834 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400835
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000836 ind.set_allocated_alarm_ind(alarm_ind);
837 }
838 }
839 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400840
841 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000842 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400843}
844
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000845static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400846 openolt::Indication ind;
847 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
848 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
849
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000850 switch (msg->obj_type) {
851 case BCMOLT_OBJ_ID_ONU:
852 switch (msg->subgroup) {
853 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
854 {
855 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
856 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400857
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000858 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
859 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400860
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000861 sfi_ind->set_intf_id(key->pon_ni);
862 sfi_ind->set_onu_id(key->onu_id);
863 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
864 sfi_ind->set_inverse_bit_error_rate(data->ber);
865 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400866
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000867 ind.set_allocated_alarm_ind(alarm_ind);
868 }
869 }
870 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400871
872 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000873 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400874}
875
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000876static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400877 openolt::Indication ind;
878 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
879 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
880
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000881 switch (msg->obj_type) {
882 case BCMOLT_OBJ_ID_ONU:
883 switch (msg->subgroup) {
884 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
885 {
886 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
887 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400888
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000889 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
890 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400891
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000892 tiwi_ind->set_intf_id(key->pon_ni);
893 tiwi_ind->set_onu_id(key->onu_id);
894 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
895 tiwi_ind->set_drift(data->drift_value);
896 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400897
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000898 ind.set_allocated_alarm_ind(alarm_ind);
899 }
900 }
901 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400902
903 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000904 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400905}
906
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530907static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400908 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530909 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
910
911 switch (msg->obj_type) {
912 case BCMOLT_OBJ_ID_ONU:
913 switch (msg->subgroup) {
914 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
915 {
916 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
917 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
918
919 onu_ind->set_intf_id(key->pon_ni);
920 onu_ind->set_onu_id(key->onu_id);
921 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
922 onu_ind->set_oper_state("up");
923 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
924 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530925 switch (data->fail_reason) {
926 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
927 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
928 break;
929 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
930 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
931 break;
932 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
933 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
934 break;
935 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
936 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
937 break;
938 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
939 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
940 break;
941 default:
942 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
943 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530944 // Setting the admin_state state field based on a valid onu_id does not make any sense.
945 // The adapter too does not seem to interpret this seriously.
946 // Legacy code, lets keep this as is for now.
947 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
948 ind.set_allocated_onu_ind(onu_ind);
949 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
950 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
951 (key->onu_id)?"up":"down");
952 }
953 }
954 }
955
956 oltIndQ.push(ind);
957 bcmolt_msg_free(msg);
958}
959
Jason Huang93430532020-02-04 17:16:02 +0800960static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
961 openolt::Indication ind;
962 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
963 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
964
965 switch (msg->obj_type) {
966 case BCMOLT_OBJ_ID_ONU:
967 switch (msg->subgroup) {
968 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
969 {
970 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
971 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
972
973 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
974 key->pon_ni, key->onu_id, data->alarm_status);
975
976 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
977 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
978 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
979 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
980
981 ind.set_allocated_alarm_ind(alarm_ind);
982 }
983 }
984 }
985
986 oltIndQ.push(ind);
987 bcmolt_msg_free(msg);
988}
989
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800990static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +0800991 openolt::Indication ind;
992 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
993 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
994
995 switch (msg->obj_type) {
996 case BCMOLT_OBJ_ID_ONU:
997 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800998 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +0800999 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001000 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
1001 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 +08001002
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001003 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
1004 switch (data->stat)
1005 {
1006 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1007 uint64_t rdi_errors;
1008 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1009 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1010 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1011 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1012 rdi_err_ind->set_rdi_error_count(rdi_errors);
1013 rdi_err_ind->set_status("on");
1014 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1015 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1016 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1017 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1018 break;
1019 /* It is a further requirement
1020 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1021 uint64_t bip_errors;
1022 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1023 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1024 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1025 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1026 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1027 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1028 break;
1029 */
1030 }
1031 ind.set_allocated_alarm_ind(alarm_ind);
1032 }
Jason Huang93430532020-02-04 17:16:02 +08001033 }
1034 }
1035 }
1036
1037 oltIndQ.push(ind);
1038 bcmolt_msg_free(msg);
1039}
1040
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001041static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1042 openolt::Indication ind;
1043 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1044 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +08001045
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001046 switch (msg->obj_type) {
1047 case BCMOLT_OBJ_ID_ONU:
1048 switch (msg->subgroup) {
1049 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
1050 {
1051 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
1052 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
1053
1054 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
1055 switch (data->stat)
1056 {
1057 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1058 uint64_t rdi_errors;
1059 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1060
1061 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1062 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1063 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1064 rdi_err_ind->set_rdi_error_count(rdi_errors);
1065 rdi_err_ind->set_status("off");
1066 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1067 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1068 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1069 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1070 break;
1071 /* It is a further requirement
1072 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1073 uint64_t bip_errors;
1074 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1075 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1076 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1077 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
1078 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1079 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1080 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1081 break;
1082 */
1083 }
1084 ind.set_allocated_alarm_ind(alarm_ind);
1085 }
1086 }
1087 }
1088 }
1089
1090 oltIndQ.push(ind);
1091 bcmolt_msg_free(msg);
1092}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301093
1094static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1095 openolt::Indication ind;
1096
1097 openolt::Indication onu_ind;
1098 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001099
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001100 switch (msg->obj_type) {
1101 case BCMOLT_OBJ_ID_ONU:
1102 switch (msg->subgroup) {
1103 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1104 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301105 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1106 bcmolt_onu_onu_deactivation_completed_data *data =
1107 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001108
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301109 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1110 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001111
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301112 onu_ind_data->set_intf_id(key->pon_ni);
1113 onu_ind_data->set_onu_id(key->onu_id);
1114 onu_ind_data->set_oper_state("down");
1115 onu_ind_data->set_admin_state("down");
1116 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301117
1118 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1119 onu_deactivate_complete_result res;
1120 res.pon_intf_id = (uint32_t)key->pon_ni;
1121 res.onu_id = (uint32_t) key->onu_id;
1122 res.result = data->status;
1123 res.reason = data->fail_reason;
1124
1125 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1126 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1127
1128 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1129 // Push the result from BAL to queue
1130 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1131 if (it == onu_deact_compltd_map.end()) {
1132 // 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 -08001133 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1134 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1135 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301136 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 +05301137 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301138 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001139 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301140 // Push the result
1141 it->second->push(res);
1142 }
1143 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001144 }
1145 }
1146 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001147
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301148 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001149 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001150}
1151
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001152static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1153 switch (msg->obj_type) {
1154 case BCMOLT_OBJ_ID_ONU:
1155 switch (msg->subgroup) {
1156 case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED:
1157 {
1158 bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key;
1159 bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data;
1160 double rx_power_mean_dbm = 0.0;
1161
1162 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n",
1163 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1164
1165 if (data->status == BCMOLT_RESULT_SUCCESS) {
1166 auto trx_eeprom_reader =
1167#ifdef ASGVOLT64
1168 TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni};
1169#else
1170 TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni};
1171#endif
1172 auto power = trx_eeprom_reader.read_power_mean_dbm();
1173
1174 if (power.second) {
1175 rx_power_mean_dbm = power.first.first;
1176 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm);
1177 } else {
1178 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n");
1179 }
1180 } else {
1181 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure");
1182 }
1183
1184 // for internal use insert into map
1185 onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id);
1186 onu_rssi_complete_result res;
1187 res.pon_intf_id = (uint32_t)key->pon_ni;
1188 res.onu_id = (uint32_t)key->onu_id;
1189 res.status = bcmolt_result_to_string(data->status);
1190 res.reason = data->fail_reason;
1191 res.rx_power_mean_dbm = rx_power_mean_dbm;
1192
1193 bcmos_fastlock_lock(&onu_rssi_wait_lock);
1194 auto it = onu_rssi_compltd_map.find(onu_key);
1195 if (it == onu_rssi_compltd_map.end()) {
1196 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n",
1197 key->pon_ni, key->onu_id);
1198 } else if (it->second) {
1199 it->second->push(res);
1200 } else {
1201 OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n",
1202 key->pon_ni, key->onu_id);
1203 }
1204 bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0);
1205 }
1206 }
1207 }
1208
1209 bcmolt_msg_free(msg);
1210}
1211
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001212/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001213bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1214 openolt::Indication ind;
1215 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1216 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1217
1218 bcmbal_subscriber_terminal_key *key =
1219 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1220
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001221 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001222 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001223
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001224 onu_proc_error_ind->set_intf_id(key->intf_id);
1225 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1226
1227 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1228 ind.set_allocated_alarm_ind(alarm_ind);
1229
1230 oltIndQ.push(ind);
1231 return BCM_ERR_OK;
1232}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001233*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001234
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001235static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1236
1237 switch (msg->obj_type) {
1238 case BCMOLT_OBJ_ID_GROUP:
1239 switch (msg->subgroup) {
1240 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1241 {
1242 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1243 bcmolt_group_complete_members_update_data *data =
1244 &((bcmolt_group_complete_members_update*)msg)->data;
1245
1246 if (data->result == BCMOLT_RESULT_SUCCESS) {
1247 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1248 } else {
1249 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1250 }
1251 }
1252 }
1253 }
1254 bcmolt_msg_free(msg);
1255}
1256
Shad Ansari01b0e652018-04-05 21:02:53 +00001257Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001258 bcmolt_rx_cfg rx_cfg = {};
1259 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001260
1261 if (subscribed) {
1262 return Status::OK;
1263 }
1264
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001265 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1266 rx_cfg.rx_cb = OltOperIndication;
1267 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1268 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1269 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1270 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301271 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001272 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001273
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001274 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1275 rx_cfg.rx_cb = OltOperIndication;
1276 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1277 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1278 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1279 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301280 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001281 "Olt disconnection complete state indication subscribe failed");
1282
1283 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1284 rx_cfg.rx_cb = OltOperIndication;
1285 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1286 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1287 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1288 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301289 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001290 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001291
1292 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001293 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1294 rx_cfg.rx_cb = LosIndication;
1295 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1296 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1297 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1298 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001299 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001300
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001301 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1302 rx_cfg.rx_cb = IfOperIndication;
1303 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1304 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1305 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1306 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301307 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001308 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001309
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001310 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1311 rx_cfg.rx_cb = IfOperIndication;
1312 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1313 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1314 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1315 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301316 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001317 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001318
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001319 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1320 rx_cfg.rx_cb = OnuAlarmIndication;
1321 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1322 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1323 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1324 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001325 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001326
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001327 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1328 rx_cfg.rx_cb = OnuAlarmIndication;
1329 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1330 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1331 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1332 if(rc != BCM_ERR_OK)
1333 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1334
1335 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1336 rx_cfg.rx_cb = OnuDyingGaspIndication;
1337 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1338 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1339 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1340 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001341 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001342
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001343 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1344 rx_cfg.rx_cb = OnuDiscoveryIndication;
1345 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1346 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1347 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1348 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001349 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001350
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001351 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001352 rx_cfg.rx_cb = OnuStartupFailureIndication;
1353 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1354 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1355 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1356 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301357 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001358 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001359
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001360 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1361 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1362 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1363 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1364 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1365 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001366 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001367
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001368 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1369 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1370 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1371 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1372 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1373 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001374 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001375
1376 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001377 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1378 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1379 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1380 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1381 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1382 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001383 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001384
1385 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001386 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1387 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1388 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1389 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1390 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1391 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001392 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001393
1394 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001395 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1396 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1397 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1398 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1399 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1400 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001401 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001402
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301403 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001404 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301405 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1406 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1407 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1408 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1409 if(rc != BCM_ERR_OK)
1410 return Status(grpc::StatusCode::INTERNAL,
1411 "onu activation completed indication subscribe failed");
1412
1413 /* ONU Deactivation Completed Indication */
1414 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1415 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001416 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1417 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1418 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1419 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301420 return Status(grpc::StatusCode::INTERNAL,
1421 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001422
Jason Huang93430532020-02-04 17:16:02 +08001423 /* ONU Loss of Key Sync Indiction */
1424 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1425 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1426 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1427 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1428 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1429 if(rc != BCM_ERR_OK)
1430 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1431
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001432 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001433 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001434 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001435 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001436 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001437 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1438 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001439 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1440
1441 /* ONU ITU-PON Cleared Stats Indiction */
1442 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1443 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1444 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1445 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1446 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1447 if(rc != BCM_ERR_OK)
1448 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001449
Jason Huang09b73ea2020-01-08 17:52:05 +08001450 /* Packet-In by Access_Control */
1451 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001452 rx_cfg.rx_cb = PacketIndication;
1453 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001454 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001455 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1456 if(rc != BCM_ERR_OK)
1457 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001458
Girish Gowdra96461052019-11-22 20:13:59 +05301459 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1460 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1461 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1462 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1463 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1464 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001465 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +05301466
1467 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM;
1468 rx_cfg.rx_cb = ItuPonGemConfigCompletedInd;
1469 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1470 rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed;
1471 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1472 if(rc != BCM_ERR_OK)
1473 return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301474
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001475 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1476 rx_cfg.rx_cb = GroupIndication;
1477 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1478 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1479 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1480 if(rc != BCM_ERR_OK)
1481 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1482
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001483 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1484 rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication;
1485 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1486 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed;
1487 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1488 if(rc != BCM_ERR_OK)
1489 return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed");
1490
Shad Ansari01b0e652018-04-05 21:02:53 +00001491 subscribed = true;
1492
1493 return Status::OK;
1494}