blob: 304cb452a8362ffb6bc8421057f86796e51481d5 [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 Ansari627b5782018-08-13 22:49:32 +000038extern Queue<openolt::Indication> oltIndQ;
Girish Gowdra96461052019-11-22 20:13:59 +053039extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map;
40extern bcmos_fastlock alloc_cfg_wait_lock;
Shad Ansari01b0e652018-04-05 21:02:53 +000041
42bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080043uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000044#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000045
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000046static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000047
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000048#define INTERFACE_STATE_IF_DOWN(state) \
49 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
50 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
51 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
52#define INTERFACE_STATE_IF_UP(state) \
53 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
54#define ONU_STATE_IF_DOWN(state) \
55 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
56 state == BCMOLT_ONU_OPERATION_DISABLE || \
57 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
58#define ONU_STATE_IF_UP(state) \
59 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053060#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000061 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053062#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000063 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
64#define SET_OPER_STATE(indication,state) \
65 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
66 indication->set_oper_state("down")
67#define GET_FLOW_TYPE(type) \
68 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
69 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
70 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
71
72std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000074 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050075 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000076 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050077 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000078 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
79 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050080 }
81 return "unknown";
82}
83
Jason Huang09b73ea2020-01-08 17:52:05 +080084std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000085{
Jason Huang09b73ea2020-01-08 17:52:05 +080086 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080088 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000089 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080090 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000091 return "host";
92 }
93 return "unknown";
94}
95
Jason Huang5d9ab1a2020-04-15 16:53:49 +080096inline uint64_t get_pon_stats_alarms_data(bcmolt_interface pon_ni, bcmolt_onu_id onu_id, bcmolt_onu_itu_pon_stats_data_id stat) {
97 bcmos_errno err;
98 bcmolt_onu_itu_pon_stats itu_pon_stat; /* declare main API struct */
99 bcmolt_onu_key key = {}; /* declare key */
100 bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE; /* declare 'clear on read' flag */
101
102 key.pon_ni = pon_ni;
103 key.onu_id = onu_id;
104
105 /* Initialize the API struct. */
106 BCMOLT_STAT_INIT(&itu_pon_stat, onu, itu_pon_stats, key);
107 switch (stat) {
108 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
109 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, rdi_errors);
110 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
111 if (err) {
112 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get rdi_errors, err = %s\n", bcmos_strerror(err));
113 return err;
114 }
115 return itu_pon_stat.data.rdi_errors;
116 /* It is a further requirement
117 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
118 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, bip_errors);
119 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
120 if (err) {
121 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get bip_errors, err = %s\n", bcmos_strerror(err));
122 return err;
123 }
124 return itu_pon_stat.data.bip_errors;
125 */
126 default:
127 return BCM_ERR_INTERNAL;
128 }
129
130 return err;
131}
132
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000133/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -0700134 bcmbal_subscriber_terminal_key key;
135 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
136 uint8_t *list_mem;// to fetch config details for ONU
137 bcmos_errno err = BCM_ERR_OK;
138
139 key.sub_term_id =onu_id;
140 key.intf_id = intf_id;
141 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
142
143 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
144
145 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
146 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
147 memset(reg_id, '\0', MAX_REGID_LENGTH);
148
149 //set memory to use for variable-sized lists
150 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
151
152 if (list_mem == NULL)
153 {
154 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
155 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
156 return reg_id;
157 }
158
159 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
160 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
161
162 //call API
163 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
164
165 if (err != BCM_ERR_OK)
166 {
167 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
168 key.sub_term_id, key.intf_id);
169 free(list_mem);
170 return reg_id;
171 }
172
173 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
174 key.sub_term_id, key.intf_id);
175
176 for (int i=0; i<MAX_REGID_LENGTH ; i++){
177 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
178 }
179
180 free(list_mem);
181 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000182}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700183
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000184static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000185 openolt::Indication ind;
186 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500187 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500188
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000189 switch (msg->subgroup) {
190 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
191 admin_state = "up";
192 olt_ind->set_oper_state("up");
193 break;
194 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
195 admin_state = "down";
196 olt_ind->set_oper_state("down");
197 break;
198 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
199 admin_state = "failure";
200 olt_ind->set_oper_state("failure");
201 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000202 }
203 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500204
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000205 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
206 /* register for omci indication */
207 {
208 bcmolt_rx_cfg rx_cfg = {};
209 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
210 rx_cfg.rx_cb = OmciIndication;
211 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
212 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
213 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000214 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500215 state.activate();
216 }
217 else {
218 state.deactivate();
219 }
220
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000221 oltIndQ.push(ind);
222 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000223}
224
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000225static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000226 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400227 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
228 openolt::LosIndication* los_ind = new openolt::LosIndication;
229
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000230 switch (msg->obj_type) {
231 case BCMOLT_OBJ_ID_PON_INTERFACE:
232 switch (msg->subgroup) {
233 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
234 {
235 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
236 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
237 BCMOLT_INTERFACE_TYPE_PON);
238 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400239
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530240 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000241 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400242
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000243 los_ind->set_intf_id(intf_id);
244 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400245
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000246 alarm_ind->set_allocated_los_ind(los_ind);
247 ind.set_allocated_alarm_ind(alarm_ind);
248 break;
249 }
250 }
251 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400252
253 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000254 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000255}
256
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000257static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700258 openolt::Indication ind;
259 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
260
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530261 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000262 case BCMOLT_OBJ_ID_PON_INTERFACE:
263 switch (msg->subgroup) {
264 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530265 {
266 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000267 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530268 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000269 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700270
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000271 intf_ind->set_intf_id(key->pon_ni);
272 SET_OPER_STATE(intf_ind, data->new_state);
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530273
274 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n",
275 bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str());
276
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000277 ind.set_allocated_intf_ind(intf_ind);
278 break;
279 }
280 }
281 break;
282 case BCMOLT_OBJ_ID_NNI_INTERFACE:
283 switch (msg->subgroup) {
284 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
285 {
286 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
287 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530288 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000289 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530290 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000291 &((bcmolt_nni_interface_state_change *)msg)->data;
292
293 intf_ind->set_intf_id(key->id);
294 SET_OPER_STATE(intf_ind, data->new_state);
295 ind.set_allocated_intf_ind(intf_ind);
296 break;
297 }
298 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700299 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700300
301 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000302 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700303}
304
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000305static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000306 openolt::Indication ind;
307 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000308
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000309 switch (msg->obj_type) {
310 case BCMOLT_OBJ_ID_PON_INTERFACE:
311 switch (msg->subgroup) {
312 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
313 {
314 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
315 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
316 intf_oper_ind->set_intf_id(key->pon_ni);
317 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
318 SET_OPER_STATE(intf_oper_ind, data->new_state);
319 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
320 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
321 ind.set_allocated_intf_oper_ind(intf_oper_ind);
322 break;
323 }
324 }
325 case BCMOLT_OBJ_ID_NNI_INTERFACE:
326 switch (msg->subgroup) {
327 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
328 {
329 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
330 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
331 bcmolt_interface intf_id = key->id;
332 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
333 intf_oper_ind->set_intf_id(key->id);
334 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530335 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000336 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
337 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
338 ind.set_allocated_intf_oper_ind(intf_oper_ind);
339 break;
340 }
341 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000342 }
343
Shad Ansari01b0e652018-04-05 21:02:53 +0000344 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000345 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000346}
347
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000348static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000349 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400350 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
351 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
352
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000353 switch (msg->obj_type) {
354 case BCMOLT_OBJ_ID_ONU:
355 switch (msg->subgroup) {
356 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
357 {
Jason Huang93430532020-02-04 17:16:02 +0800358 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
359 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530360
361 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
362
363 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());
364
Jason Huang93430532020-02-04 17:16:02 +0800365 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
366 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
367 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
368 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
369 onu_alarm_ind->set_intf_id(key->pon_ni);
370 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000371 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
372 ind.set_allocated_alarm_ind(alarm_ind);
373 break;
374 }
375 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
376 {
Jason Huang93430532020-02-04 17:16:02 +0800377 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
378 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
379 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
380 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
381 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
382 onu_alarm_ind->set_intf_id(key->pon_ni);
383 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000384 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
385 ind.set_allocated_alarm_ind(alarm_ind);
386 break;
387 }
388 }
389 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400390
391 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000392 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000393}
394
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000395static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000396 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400397 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000398 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400399
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000400 switch (msg->obj_type) {
401 case BCMOLT_OBJ_ID_ONU:
402 switch (msg->subgroup) {
403 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
404 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500405 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500406 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
407
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530408 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
409
410 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
411 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
412
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500413 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500414 dgi_ind->set_intf_id(key->pon_ni);
415 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400416
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000417 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
418 ind.set_allocated_alarm_ind(alarm_ind);
419 break;
420 }
421 }
422 }
nickc063ffd2018-05-22 14:35:28 -0400423
424 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000425 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000426}
427
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000428static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000429 openolt::Indication ind;
430 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
431 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
432
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000433 switch (msg->obj_type) {
434 case BCMOLT_OBJ_ID_PON_INTERFACE:
435 switch (msg->subgroup) {
436 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
437 {
438 bcmolt_pon_interface_key *key =
439 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000440
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530441 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000442 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000443
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000444 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000445
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000446 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
447 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000448
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000449 onu_disc_ind->set_intf_id(key->pon_ni);
450 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
451 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
452 onu_disc_ind->set_allocated_serial_number(serial_number);
453 ind.set_allocated_onu_disc_ind(onu_disc_ind);
454 break;
455 }
456 }
457 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000458
459 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000460 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000461}
462
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000463static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000464 openolt::Indication ind;
465 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000466
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000467 switch (msg->obj_type) {
468 case BCMOLT_OBJ_ID_ONU:
469 switch (msg->subgroup) {
470 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
471 {
472 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
473 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000474
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530475 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000476 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000477
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000478 omci_ind->set_intf_id(key->pon_ni);
479 omci_ind->set_onu_id(key->onu_id);
480 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
481
482 ind.set_allocated_omci_ind(omci_ind);
483 break;
484 }
485 }
486 }
487
Shad Ansari01b0e652018-04-05 21:02:53 +0000488 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000489 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000490}
491
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000492static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000493 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000494
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000495 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800496 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000497 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800498 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000499 {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700500 int32_t gemport_id;
Jason Huang09b73ea2020-01-08 17:52:05 +0800501 bcmolt_access_control_receive_eth_packet *pkt =
502 (bcmolt_access_control_receive_eth_packet*)msg;
503 bcmolt_access_control_receive_eth_packet_data *pkt_data =
504 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000505
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700506 // Set the gemport_id to be passed to is_packet_allowed function
507 gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id;
508
509 // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet.
510 if (! is_packet_allowed(pkt_data, gemport_id) ) {
511 OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n");
512 bcmolt_msg_free(msg);
513 return;
514 }
515 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Jason Huang09b73ea2020-01-08 17:52:05 +0800516 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
517 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
518 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000519 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800520 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000521 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500522
Jason Huang09b73ea2020-01-08 17:52:05 +0800523 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
524 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
525 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
526 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700527 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d \n",
528 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
Jason Huang09b73ea2020-01-08 17:52:05 +0800529 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000530 }
531 }
532 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500533
Shad Ansari5fe93682018-04-26 05:24:19 +0000534 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000535 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000536}
537
Girish Gowdra96461052019-11-22 20:13:59 +0530538static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
539
540 switch (msg->obj_type) {
541 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
542 switch (msg->subgroup) {
543 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
544 {
545 bcmolt_itupon_alloc_configuration_completed *pkt =
546 (bcmolt_itupon_alloc_configuration_completed*)msg;
547 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
548 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
549
550 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
551 alloc_cfg_complete_result res;
552 res.pon_intf_id = pkt->key.pon_ni;
553 res.alloc_id = pkt->key.alloc_id;
554
555 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
556 switch (pkt_data->new_state) {
557 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
558 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
559 break;
560 case BCMOLT_ACTIVATION_STATE_INACTIVE:
561 res.state = ALLOC_OBJECT_STATE_INACTIVE;
562 break;
563 case BCMOLT_ACTIVATION_STATE_PROCESSING:
564 res.state = ALLOC_OBJECT_STATE_PROCESSING;
565 break;
566 case BCMOLT_ACTIVATION_STATE_ACTIVE:
567 res.state = ALLOC_OBJECT_STATE_ACTIVE;
568 break;
569 default:
570 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
571 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
572 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
573 }
574 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",
575 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
576
577 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
578 // Push the result from BAL to queue
579 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
580 if (it == alloc_cfg_compltd_map.end()) {
581 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
582 bcmolt_msg_free(msg);
583 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);
584 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
585 return;
586 }
587 if (it->second) {
588 // Push the result
589 it->second->push(res);
590 }
591 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
592 }
593 }
594 }
595
596 bcmolt_msg_free(msg);
597}
598
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000599static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000600 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000601 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
602 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000603}
604
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000605static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000606 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000607 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
608 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000609}
610
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000611static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000612 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000613 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
614 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000615}
616
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000617static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000618 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000619 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
620 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000621}
622
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000623static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000624 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000625 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
626 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000627}
628
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000629static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400630 openolt::Indication ind;
631 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
632 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
633
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000634 switch (msg->obj_type) {
635 case BCMOLT_OBJ_ID_ONU:
636 switch (msg->subgroup) {
637 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
638 {
639 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
640 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400641
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000642 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
643 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000645 sufi_ind->set_intf_id(key->pon_ni);
646 sufi_ind->set_onu_id(key->onu_id);
647 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
648 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400649
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000650 ind.set_allocated_alarm_ind(alarm_ind);
651 }
652 }
653 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400654
655 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000656 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400657}
658
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000659static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400660 openolt::Indication ind;
661 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
662 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
663
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000664 switch (msg->obj_type) {
665 case BCMOLT_OBJ_ID_ONU:
666 switch (msg->subgroup) {
667 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
668 {
669 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
670 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400671
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000672 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
673 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400674
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000675 sdi_ind->set_intf_id(key->pon_ni);
676 sdi_ind->set_onu_id(key->onu_id);
677 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
678 sdi_ind->set_inverse_bit_error_rate(data->ber);
679 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400680
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000681 ind.set_allocated_alarm_ind(alarm_ind);
682 }
683 }
684 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400685
686 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000687 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400688}
689
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000690static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400691 openolt::Indication ind;
692 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
693 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
694
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000695 switch (msg->obj_type) {
696 case BCMOLT_OBJ_ID_ONU:
697 switch (msg->subgroup) {
698 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
699 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530700 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000701 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400702
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000703 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",
704 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400705
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000706 dowi_ind->set_intf_id(key->pon_ni);
707 dowi_ind->set_onu_id(key->onu_id);
708 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
709 dowi_ind->set_drift(data->drift_value);
710 dowi_ind->set_new_eqd(data->new_eqd);
711 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400712
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000713 ind.set_allocated_alarm_ind(alarm_ind);
714 }
715 }
716 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400717
718 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000719 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400720}
721
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000722static void OnuLossOfOmciChannelIndication(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::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
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_LOOCI:
731 {
732 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
733 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)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 loss of OMCI channel 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 looci_ind->set_intf_id(key->pon_ni);
739 looci_ind->set_onu_id(key->onu_id);
740 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
741 alarm_ind->set_allocated_onu_loss_omci_ind(looci_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 OnuSignalsFailureIndication(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::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
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_SFI:
761 {
762 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
763 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)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 signals failure 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 sfi_ind->set_intf_id(key->pon_ni);
769 sfi_ind->set_onu_id(key->onu_id);
770 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
771 sfi_ind->set_inverse_bit_error_rate(data->ber);
772 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_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 OnuTransmissionInterferenceWarningIndication(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::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
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_TIWI:
792 {
793 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
794 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)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 transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
797 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400798
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000799 tiwi_ind->set_intf_id(key->pon_ni);
800 tiwi_ind->set_onu_id(key->onu_id);
801 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
802 tiwi_ind->set_drift(data->drift_value);
803 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400804
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000805 ind.set_allocated_alarm_ind(alarm_ind);
806 }
807 }
808 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400809
810 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000811 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400812}
813
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530814static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400815 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530816 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
817
818 switch (msg->obj_type) {
819 case BCMOLT_OBJ_ID_ONU:
820 switch (msg->subgroup) {
821 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
822 {
823 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
824 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
825
826 onu_ind->set_intf_id(key->pon_ni);
827 onu_ind->set_onu_id(key->onu_id);
828 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
829 onu_ind->set_oper_state("up");
830 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
831 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530832 switch (data->fail_reason) {
833 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
834 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
835 break;
836 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
837 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
838 break;
839 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
840 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
841 break;
842 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
843 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
844 break;
845 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
846 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
847 break;
848 default:
849 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
850 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530851 // Setting the admin_state state field based on a valid onu_id does not make any sense.
852 // The adapter too does not seem to interpret this seriously.
853 // Legacy code, lets keep this as is for now.
854 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
855 ind.set_allocated_onu_ind(onu_ind);
856 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
857 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
858 (key->onu_id)?"up":"down");
859 }
860 }
861 }
862
863 oltIndQ.push(ind);
864 bcmolt_msg_free(msg);
865}
866
Jason Huang93430532020-02-04 17:16:02 +0800867static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
868 openolt::Indication ind;
869 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
870 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
871
872 switch (msg->obj_type) {
873 case BCMOLT_OBJ_ID_ONU:
874 switch (msg->subgroup) {
875 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
876 {
877 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
878 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
879
880 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
881 key->pon_ni, key->onu_id, data->alarm_status);
882
883 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
884 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
885 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
886 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
887
888 ind.set_allocated_alarm_ind(alarm_ind);
889 }
890 }
891 }
892
893 oltIndQ.push(ind);
894 bcmolt_msg_free(msg);
895}
896
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800897static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +0800898 openolt::Indication ind;
899 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
900 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
901
902 switch (msg->obj_type) {
903 case BCMOLT_OBJ_ID_ONU:
904 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800905 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +0800906 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800907 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
908 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 +0800909
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800910 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
911 switch (data->stat)
912 {
913 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
914 uint64_t rdi_errors;
915 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
916 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
917 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
918 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
919 rdi_err_ind->set_rdi_error_count(rdi_errors);
920 rdi_err_ind->set_status("on");
921 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
922 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
923 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
924 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
925 break;
926 /* It is a further requirement
927 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
928 uint64_t bip_errors;
929 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
930 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
931 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
932 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
933 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
934 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
935 break;
936 */
937 }
938 ind.set_allocated_alarm_ind(alarm_ind);
939 }
Jason Huang93430532020-02-04 17:16:02 +0800940 }
941 }
942 }
943
944 oltIndQ.push(ind);
945 bcmolt_msg_free(msg);
946}
947
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800948static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
949 openolt::Indication ind;
950 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
951 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +0800952
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800953 switch (msg->obj_type) {
954 case BCMOLT_OBJ_ID_ONU:
955 switch (msg->subgroup) {
956 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
957 {
958 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
959 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
960
961 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
962 switch (data->stat)
963 {
964 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
965 uint64_t rdi_errors;
966 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
967
968 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
969 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
970 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
971 rdi_err_ind->set_rdi_error_count(rdi_errors);
972 rdi_err_ind->set_status("off");
973 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
974 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
975 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
976 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
977 break;
978 /* It is a further requirement
979 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
980 uint64_t bip_errors;
981 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
982 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
983 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
984 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
985 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
986 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
987 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
988 break;
989 */
990 }
991 ind.set_allocated_alarm_ind(alarm_ind);
992 }
993 }
994 }
995 }
996
997 oltIndQ.push(ind);
998 bcmolt_msg_free(msg);
999}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301000
1001static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1002 openolt::Indication ind;
1003
1004 openolt::Indication onu_ind;
1005 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001006
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001007 switch (msg->obj_type) {
1008 case BCMOLT_OBJ_ID_ONU:
1009 switch (msg->subgroup) {
1010 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1011 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301012 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1013 bcmolt_onu_onu_deactivation_completed_data *data =
1014 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001015
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301016 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1017 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001018
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301019 onu_ind_data->set_intf_id(key->pon_ni);
1020 onu_ind_data->set_onu_id(key->onu_id);
1021 onu_ind_data->set_oper_state("down");
1022 onu_ind_data->set_admin_state("down");
1023 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301024
1025 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1026 onu_deactivate_complete_result res;
1027 res.pon_intf_id = (uint32_t)key->pon_ni;
1028 res.onu_id = (uint32_t) key->onu_id;
1029 res.result = data->status;
1030 res.reason = data->fail_reason;
1031
1032 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1033 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1034
1035 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1036 // Push the result from BAL to queue
1037 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1038 if (it == onu_deact_compltd_map.end()) {
1039 // 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 -08001040 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1041 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1042 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301043 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 +05301044 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301045 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001046 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301047 // Push the result
1048 it->second->push(res);
1049 }
1050 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001051 }
1052 }
1053 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001054
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301055 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001056 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001057}
1058
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001059static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1060 switch (msg->obj_type) {
1061 case BCMOLT_OBJ_ID_ONU:
1062 switch (msg->subgroup) {
1063 case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED:
1064 {
1065 bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key;
1066 bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data;
1067 double rx_power_mean_dbm = 0.0;
1068
1069 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n",
1070 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1071
1072 if (data->status == BCMOLT_RESULT_SUCCESS) {
1073 auto trx_eeprom_reader =
1074#ifdef ASGVOLT64
1075 TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni};
1076#else
1077 TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni};
1078#endif
1079 auto power = trx_eeprom_reader.read_power_mean_dbm();
1080
1081 if (power.second) {
1082 rx_power_mean_dbm = power.first.first;
1083 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm);
1084 } else {
1085 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n");
1086 }
1087 } else {
1088 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure");
1089 }
1090
1091 // for internal use insert into map
1092 onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id);
1093 onu_rssi_complete_result res;
1094 res.pon_intf_id = (uint32_t)key->pon_ni;
1095 res.onu_id = (uint32_t)key->onu_id;
1096 res.status = bcmolt_result_to_string(data->status);
1097 res.reason = data->fail_reason;
1098 res.rx_power_mean_dbm = rx_power_mean_dbm;
1099
1100 bcmos_fastlock_lock(&onu_rssi_wait_lock);
1101 auto it = onu_rssi_compltd_map.find(onu_key);
1102 if (it == onu_rssi_compltd_map.end()) {
1103 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n",
1104 key->pon_ni, key->onu_id);
1105 } else if (it->second) {
1106 it->second->push(res);
1107 } else {
1108 OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n",
1109 key->pon_ni, key->onu_id);
1110 }
1111 bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0);
1112 }
1113 }
1114 }
1115
1116 bcmolt_msg_free(msg);
1117}
1118
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001119/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001120bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1121 openolt::Indication ind;
1122 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1123 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1124
1125 bcmbal_subscriber_terminal_key *key =
1126 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1127
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001128 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001129 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001130
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001131 onu_proc_error_ind->set_intf_id(key->intf_id);
1132 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1133
1134 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1135 ind.set_allocated_alarm_ind(alarm_ind);
1136
1137 oltIndQ.push(ind);
1138 return BCM_ERR_OK;
1139}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001140*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001141
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001142static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1143
1144 switch (msg->obj_type) {
1145 case BCMOLT_OBJ_ID_GROUP:
1146 switch (msg->subgroup) {
1147 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1148 {
1149 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1150 bcmolt_group_complete_members_update_data *data =
1151 &((bcmolt_group_complete_members_update*)msg)->data;
1152
1153 if (data->result == BCMOLT_RESULT_SUCCESS) {
1154 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1155 } else {
1156 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1157 }
1158 }
1159 }
1160 }
1161 bcmolt_msg_free(msg);
1162}
1163
Shad Ansari01b0e652018-04-05 21:02:53 +00001164Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001165 bcmolt_rx_cfg rx_cfg = {};
1166 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001167
1168 if (subscribed) {
1169 return Status::OK;
1170 }
1171
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001172 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1173 rx_cfg.rx_cb = OltOperIndication;
1174 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1175 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1176 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1177 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301178 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001179 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001180
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001181 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1182 rx_cfg.rx_cb = OltOperIndication;
1183 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1184 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1185 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1186 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301187 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001188 "Olt disconnection complete state indication subscribe failed");
1189
1190 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1191 rx_cfg.rx_cb = OltOperIndication;
1192 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1193 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1194 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1195 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301196 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001197 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001198
1199 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001200 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1201 rx_cfg.rx_cb = LosIndication;
1202 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1203 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1204 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1205 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001206 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001207
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001208 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1209 rx_cfg.rx_cb = IfOperIndication;
1210 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1211 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1212 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1213 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301214 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001215 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001216
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001217 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1218 rx_cfg.rx_cb = IfOperIndication;
1219 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1220 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1221 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1222 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301223 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001224 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001225
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001226 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1227 rx_cfg.rx_cb = OnuAlarmIndication;
1228 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1229 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1230 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1231 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001232 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001233
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001234 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1235 rx_cfg.rx_cb = OnuAlarmIndication;
1236 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1237 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1238 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1239 if(rc != BCM_ERR_OK)
1240 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1241
1242 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1243 rx_cfg.rx_cb = OnuDyingGaspIndication;
1244 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1245 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1246 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1247 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001248 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001249
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001250 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1251 rx_cfg.rx_cb = OnuDiscoveryIndication;
1252 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1253 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1254 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1255 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001256 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001257
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001258 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001259 rx_cfg.rx_cb = OnuStartupFailureIndication;
1260 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1261 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1262 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1263 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301264 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001265 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001266
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001267 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1268 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1269 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1270 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1271 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1272 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001273 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001274
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001275 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1276 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1277 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1278 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1279 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1280 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001281 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001282
1283 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001284 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1285 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1286 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1287 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1288 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1289 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001290 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001291
1292 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001293 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1294 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1295 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1296 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1297 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1298 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001299 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001300
1301 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001302 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1303 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1304 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1305 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1306 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1307 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001308 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001309
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301310 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001311 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301312 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1313 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1314 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1315 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1316 if(rc != BCM_ERR_OK)
1317 return Status(grpc::StatusCode::INTERNAL,
1318 "onu activation completed indication subscribe failed");
1319
1320 /* ONU Deactivation Completed Indication */
1321 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1322 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001323 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1324 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1325 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1326 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301327 return Status(grpc::StatusCode::INTERNAL,
1328 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001329
Jason Huang93430532020-02-04 17:16:02 +08001330 /* ONU Loss of Key Sync Indiction */
1331 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1332 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1333 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1334 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1335 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1336 if(rc != BCM_ERR_OK)
1337 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1338
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001339 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001340 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001341 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001342 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001343 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001344 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1345 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001346 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1347
1348 /* ONU ITU-PON Cleared Stats Indiction */
1349 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1350 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1351 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1352 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1353 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1354 if(rc != BCM_ERR_OK)
1355 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001356
Jason Huang09b73ea2020-01-08 17:52:05 +08001357 /* Packet-In by Access_Control */
1358 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001359 rx_cfg.rx_cb = PacketIndication;
1360 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001361 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001362 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1363 if(rc != BCM_ERR_OK)
1364 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001365
Girish Gowdra252f4972020-09-07 21:24:01 -07001366#ifndef SCALE_AND_PERF
Girish Gowdra96461052019-11-22 20:13:59 +05301367 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1368 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1369 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1370 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1371 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1372 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001373 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Girish Gowdra252f4972020-09-07 21:24:01 -07001374#endif
Girish Gowdra96461052019-11-22 20:13:59 +05301375
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001376 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1377 rx_cfg.rx_cb = GroupIndication;
1378 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1379 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1380 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1381 if(rc != BCM_ERR_OK)
1382 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1383
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001384 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1385 rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication;
1386 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1387 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed;
1388 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1389 if(rc != BCM_ERR_OK)
1390 return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed");
1391
Shad Ansari01b0e652018-04-05 21:02:53 +00001392 subscribed = true;
1393
1394 return Status::OK;
1395}