blob: 040726027217730e2071a48e108fb304d6a359ed [file] [log] [blame]
Shad Ansari01b0e652018-04-05 21:02:53 +00001/*
Girish Gowdraa707e7c2019-11-07 11:36:13 +05302 * Copyright 2018-present Open Networking Foundation
Shad Ansari01b0e652018-04-05 21:02:53 +00003
Girish Gowdraa707e7c2019-11-07 11:36:13 +05304 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Shad Ansari01b0e652018-04-05 21:02:53 +00007
Girish Gowdraa707e7c2019-11-07 11:36:13 +05308 * http://www.apache.org/licenses/LICENSE-2.0
Shad Ansari01b0e652018-04-05 21:02:53 +00009
Girish Gowdraa707e7c2019-11-07 11:36:13 +053010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Shad Ansari01b0e652018-04-05 21:02:53 +000017#include "indications.h"
Shad Ansarib7b0ced2018-05-11 21:53:32 +000018#include "core.h"
Girish Gowdraddf9a162020-01-27 12:56:27 +053019#include "core_data.h"
20#include "core_utils.h"
Nicolas Palpacuer0f19b1a2018-06-07 17:29:31 -040021#include "stats_collection.h"
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040022#include "translation.h"
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040023#include "state.h"
Orhan Kupusogluec57af02021-05-12 12:38:17 +000024#include "trx_eeprom_reader.h"
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040025
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040026#include <string>
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040027
Shad Ansari01b0e652018-04-05 21:02:53 +000028extern "C"
29{
30#include <bcmos_system.h>
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000031#include <bcmolt_api.h>
32#include <bcmolt_host_api.h>
33#include <bcmolt_api_model_api_structs.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000034}
35
36using grpc::Status;
37
Shad Ansari01b0e652018-04-05 21:02:53 +000038bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080039uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000040#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000041
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000042static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000043
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000044#define INTERFACE_STATE_IF_DOWN(state) \
45 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
46 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
47 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
48#define INTERFACE_STATE_IF_UP(state) \
49 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
50#define ONU_STATE_IF_DOWN(state) \
51 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
52 state == BCMOLT_ONU_OPERATION_DISABLE || \
53 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
54#define ONU_STATE_IF_UP(state) \
55 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053056#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000057 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053058#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000059 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
60#define SET_OPER_STATE(indication,state) \
61 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
62 indication->set_oper_state("down")
63#define GET_FLOW_TYPE(type) \
64 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
65 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
66 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
67
68std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050069{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000070 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050071 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000072 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000074 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
75 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050076 }
77 return "unknown";
78}
79
Jason Huang09b73ea2020-01-08 17:52:05 +080080std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000081{
Jason Huang09b73ea2020-01-08 17:52:05 +080082 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000083 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080084 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000085 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080086 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087 return "host";
88 }
89 return "unknown";
90}
91
Jason Huang5d9ab1a2020-04-15 16:53:49 +080092inline uint64_t get_pon_stats_alarms_data(bcmolt_interface pon_ni, bcmolt_onu_id onu_id, bcmolt_onu_itu_pon_stats_data_id stat) {
93 bcmos_errno err;
94 bcmolt_onu_itu_pon_stats itu_pon_stat; /* declare main API struct */
95 bcmolt_onu_key key = {}; /* declare key */
96 bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE; /* declare 'clear on read' flag */
97
98 key.pon_ni = pon_ni;
99 key.onu_id = onu_id;
100
101 /* Initialize the API struct. */
102 BCMOLT_STAT_INIT(&itu_pon_stat, onu, itu_pon_stats, key);
103 switch (stat) {
104 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
105 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, rdi_errors);
106 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
107 if (err) {
108 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get rdi_errors, err = %s\n", bcmos_strerror(err));
109 return err;
110 }
111 return itu_pon_stat.data.rdi_errors;
112 /* It is a further requirement
113 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
114 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, bip_errors);
115 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
116 if (err) {
117 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get bip_errors, err = %s\n", bcmos_strerror(err));
118 return err;
119 }
120 return itu_pon_stat.data.bip_errors;
121 */
122 default:
123 return BCM_ERR_INTERNAL;
124 }
125
126 return err;
127}
128
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000129/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -0700130 bcmbal_subscriber_terminal_key key;
131 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
132 uint8_t *list_mem;// to fetch config details for ONU
133 bcmos_errno err = BCM_ERR_OK;
134
135 key.sub_term_id =onu_id;
136 key.intf_id = intf_id;
137 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
138
139 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
140
141 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
142 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
143 memset(reg_id, '\0', MAX_REGID_LENGTH);
144
145 //set memory to use for variable-sized lists
146 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
147
148 if (list_mem == NULL)
149 {
150 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
151 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
152 return reg_id;
153 }
154
155 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
156 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
157
158 //call API
159 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
160
161 if (err != BCM_ERR_OK)
162 {
163 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
164 key.sub_term_id, key.intf_id);
165 free(list_mem);
166 return reg_id;
167 }
168
169 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
170 key.sub_term_id, key.intf_id);
171
172 for (int i=0; i<MAX_REGID_LENGTH ; i++){
173 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
174 }
175
176 free(list_mem);
177 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000178}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700179
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000180static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000181 openolt::Indication ind;
182 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500183 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500184
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000185 switch (msg->subgroup) {
186 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
187 admin_state = "up";
188 olt_ind->set_oper_state("up");
189 break;
190 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
191 admin_state = "down";
192 olt_ind->set_oper_state("down");
193 break;
194 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
195 admin_state = "failure";
196 olt_ind->set_oper_state("failure");
197 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000198 }
199 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500200
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000201 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
202 /* register for omci indication */
203 {
204 bcmolt_rx_cfg rx_cfg = {};
205 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
206 rx_cfg.rx_cb = OmciIndication;
207 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
208 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
209 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000210 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500211 state.activate();
212 }
213 else {
214 state.deactivate();
215 }
216
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000217 oltIndQ.push(ind);
218 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000219}
220
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000221static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000222 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400223 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
224 openolt::LosIndication* los_ind = new openolt::LosIndication;
225
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000226 switch (msg->obj_type) {
227 case BCMOLT_OBJ_ID_PON_INTERFACE:
228 switch (msg->subgroup) {
229 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
230 {
231 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
232 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
233 BCMOLT_INTERFACE_TYPE_PON);
234 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400235
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530236 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000237 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400238
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000239 los_ind->set_intf_id(intf_id);
240 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400241
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000242 alarm_ind->set_allocated_los_ind(los_ind);
243 ind.set_allocated_alarm_ind(alarm_ind);
244 break;
245 }
246 }
247 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400248
249 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000250 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000251}
252
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000253static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700254 openolt::Indication ind;
255 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
256
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530257 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000258 case BCMOLT_OBJ_ID_PON_INTERFACE:
259 switch (msg->subgroup) {
260 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530261 {
262 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000263 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530264 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000265 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700266
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000267 intf_ind->set_intf_id(key->pon_ni);
268 SET_OPER_STATE(intf_ind, data->new_state);
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530269
270 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n",
271 bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str());
272
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000273 ind.set_allocated_intf_ind(intf_ind);
274 break;
275 }
276 }
277 break;
278 case BCMOLT_OBJ_ID_NNI_INTERFACE:
279 switch (msg->subgroup) {
280 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
281 {
282 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
283 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530284 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000285 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530286 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000287 &((bcmolt_nni_interface_state_change *)msg)->data;
288
289 intf_ind->set_intf_id(key->id);
290 SET_OPER_STATE(intf_ind, data->new_state);
291 ind.set_allocated_intf_ind(intf_ind);
292 break;
293 }
294 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700295 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700296
297 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000298 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700299}
300
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000301static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000302 openolt::Indication ind;
303 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000304
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000305 switch (msg->obj_type) {
306 case BCMOLT_OBJ_ID_PON_INTERFACE:
307 switch (msg->subgroup) {
308 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
309 {
310 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
311 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
312 intf_oper_ind->set_intf_id(key->pon_ni);
313 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
314 SET_OPER_STATE(intf_oper_ind, data->new_state);
315 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
316 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
317 ind.set_allocated_intf_oper_ind(intf_oper_ind);
318 break;
319 }
320 }
321 case BCMOLT_OBJ_ID_NNI_INTERFACE:
322 switch (msg->subgroup) {
323 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
324 {
325 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
326 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
327 bcmolt_interface intf_id = key->id;
328 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
329 intf_oper_ind->set_intf_id(key->id);
330 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530331 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000332 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
333 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
334 ind.set_allocated_intf_oper_ind(intf_oper_ind);
335 break;
336 }
337 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000338 }
339
Shad Ansari01b0e652018-04-05 21:02:53 +0000340 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000341 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000342}
343
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000344static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000345 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400346 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
347 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
348
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000349 switch (msg->obj_type) {
350 case BCMOLT_OBJ_ID_ONU:
351 switch (msg->subgroup) {
352 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
353 {
Jason Huang93430532020-02-04 17:16:02 +0800354 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
355 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530356
357 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
358
359 OPENOLT_LOG(INFO, openolt_log_id, "onu alarm indication, pon_ni %d, onu_id %d, port_no %d, los_status %s, lob_status %s, lopc_miss_status %s, lopc_mic_error_status %s\n", key->pon_ni, key->onu_id, port_no, alarm_status_to_string(data->xgpon_onu_alarm.losi).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lobi).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error).c_str());
360
Jason Huang93430532020-02-04 17:16:02 +0800361 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
362 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
363 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
364 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
365 onu_alarm_ind->set_intf_id(key->pon_ni);
366 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000367 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
368 ind.set_allocated_alarm_ind(alarm_ind);
369 break;
370 }
371 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
372 {
Jason Huang93430532020-02-04 17:16:02 +0800373 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
374 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
375 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
376 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
377 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
378 onu_alarm_ind->set_intf_id(key->pon_ni);
379 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000380 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
381 ind.set_allocated_alarm_ind(alarm_ind);
382 break;
383 }
384 }
385 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400386
387 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000388 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000389}
390
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000391static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000392 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400393 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000394 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400395
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000396 switch (msg->obj_type) {
397 case BCMOLT_OBJ_ID_ONU:
398 switch (msg->subgroup) {
399 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
400 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500401 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500402 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
403
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530404 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
405
406 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
407 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
408
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500409 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500410 dgi_ind->set_intf_id(key->pon_ni);
411 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400412
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000413 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
414 ind.set_allocated_alarm_ind(alarm_ind);
415 break;
416 }
417 }
418 }
nickc063ffd2018-05-22 14:35:28 -0400419
420 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000421 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000422}
423
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000424static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000425 openolt::Indication ind;
426 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
427 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
428
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000429 switch (msg->obj_type) {
430 case BCMOLT_OBJ_ID_PON_INTERFACE:
431 switch (msg->subgroup) {
432 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
433 {
434 bcmolt_pon_interface_key *key =
435 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000436
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530437 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000438 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000439
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000440 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000441
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000442 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
443 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000444
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000445 onu_disc_ind->set_intf_id(key->pon_ni);
446 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
447 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
448 onu_disc_ind->set_allocated_serial_number(serial_number);
449 ind.set_allocated_onu_disc_ind(onu_disc_ind);
450 break;
451 }
452 }
453 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000454
455 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000456 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000457}
458
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000459static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000460 openolt::Indication ind;
461 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000462
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000463 switch (msg->obj_type) {
464 case BCMOLT_OBJ_ID_ONU:
465 switch (msg->subgroup) {
466 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
467 {
468 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
469 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000470
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530471 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000472 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000473
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000474 omci_ind->set_intf_id(key->pon_ni);
475 omci_ind->set_onu_id(key->onu_id);
476 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
477
478 ind.set_allocated_omci_ind(omci_ind);
479 break;
480 }
481 }
482 }
483
Shad Ansari01b0e652018-04-05 21:02:53 +0000484 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000485 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000486}
487
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000488static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000489 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000490
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000491 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800492 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000493 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800494 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000495 {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700496 int32_t gemport_id;
Jason Huang09b73ea2020-01-08 17:52:05 +0800497 bcmolt_access_control_receive_eth_packet *pkt =
498 (bcmolt_access_control_receive_eth_packet*)msg;
499 bcmolt_access_control_receive_eth_packet_data *pkt_data =
500 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000501
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700502 // Set the gemport_id to be passed to is_packet_allowed function
503 gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id;
504
505 // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet.
506 if (! is_packet_allowed(pkt_data, gemport_id) ) {
507 OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n");
508 bcmolt_msg_free(msg);
509 return;
510 }
511 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Jason Huang09b73ea2020-01-08 17:52:05 +0800512 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
513 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
514 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000515 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800516 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000517 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500518
Jason Huang09b73ea2020-01-08 17:52:05 +0800519 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
520 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
521 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
522 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700523 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d \n",
524 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
Jason Huang09b73ea2020-01-08 17:52:05 +0800525 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000526 }
527 }
528 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500529
Shad Ansari5fe93682018-04-26 05:24:19 +0000530 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000531 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000532}
533
Girish Gowdra96461052019-11-22 20:13:59 +0530534static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
535
536 switch (msg->obj_type) {
537 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
538 switch (msg->subgroup) {
539 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
540 {
541 bcmolt_itupon_alloc_configuration_completed *pkt =
542 (bcmolt_itupon_alloc_configuration_completed*)msg;
543 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
544 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
545
546 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
547 alloc_cfg_complete_result res;
548 res.pon_intf_id = pkt->key.pon_ni;
549 res.alloc_id = pkt->key.alloc_id;
550
551 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
552 switch (pkt_data->new_state) {
553 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
554 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
555 break;
556 case BCMOLT_ACTIVATION_STATE_INACTIVE:
557 res.state = ALLOC_OBJECT_STATE_INACTIVE;
558 break;
559 case BCMOLT_ACTIVATION_STATE_PROCESSING:
560 res.state = ALLOC_OBJECT_STATE_PROCESSING;
561 break;
562 case BCMOLT_ACTIVATION_STATE_ACTIVE:
563 res.state = ALLOC_OBJECT_STATE_ACTIVE;
564 break;
565 default:
566 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
567 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
568 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
569 }
570 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",
571 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
572
573 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
574 // Push the result from BAL to queue
575 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
576 if (it == alloc_cfg_compltd_map.end()) {
577 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
578 bcmolt_msg_free(msg);
579 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);
580 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
581 return;
582 }
583 if (it->second) {
584 // Push the result
585 it->second->push(res);
586 }
587 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
588 }
589 }
590 }
591
592 bcmolt_msg_free(msg);
593}
594
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +0530595static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
596
597 switch (msg->obj_type) {
598 case BCMOLT_OBJ_ID_ITUPON_GEM:
599 switch (msg->subgroup) {
600 case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
601 {
602 bcmolt_itupon_gem_configuration_completed *pkt =
603 (bcmolt_itupon_gem_configuration_completed*)msg;
604 bcmolt_itupon_gem_configuration_completed_data *pkt_data =
605 &((bcmolt_itupon_gem_configuration_completed*)msg)->data;
606
607 gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id);
608 gem_cfg_complete_result res;
609 res.pon_intf_id = pkt->key.pon_ni;
610 res.gem_port_id = pkt->key.gem_port_id;
611
612 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL;
613 switch (pkt_data->new_state) {
614 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
615 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
616 break;
617 case BCMOLT_ACTIVATION_STATE_INACTIVE:
618 res.state = GEM_OBJECT_STATE_INACTIVE;
619 break;
620 case BCMOLT_ACTIVATION_STATE_PROCESSING:
621 res.state = GEM_OBJECT_STATE_PROCESSING;
622 break;
623 case BCMOLT_ACTIVATION_STATE_ACTIVE:
624 res.state = GEM_OBJECT_STATE_ACTIVE;
625 break;
626 default:
627 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n",
628 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state);
629 res.state = GEM_OBJECT_STATE_NOT_CONFIGURED;
630 }
631 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",
632 pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state);
633
634 uint32_t gem_cfg_key_check_counter = 1;
635 std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it;
636 while(true) {
637 bcmos_fastlock_lock(&gem_cfg_wait_lock);
638 // Push the result from BAL to queue
639 it = gem_cfg_compltd_map.find(key);
640
641 if (it != gem_cfg_compltd_map.end()) {
642 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
643 break;
644 } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) {
645 /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion
646 by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication
647 to Queue by 6ms.*/
648 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
649 bcmos_usleep(6000);
650 } else {
651 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
652 bcmolt_msg_free(msg);
653 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);
654 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
655 return;
656 }
657 gem_cfg_key_check_counter++;
658 }
659
660 bcmos_fastlock_lock(&gem_cfg_wait_lock);
661 if (it->second) {
662 // Push the result
663 it->second->push(res);
664 }
665 bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0);
666 }
667 }
668 }
669
670 bcmolt_msg_free(msg);
671}
672
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000673static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000674 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000675 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
676 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000677}
678
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000679static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000680 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000681 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
682 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000683}
684
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000685static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000686 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000687 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
688 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000689}
690
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000691static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000692 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000693 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
694 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000695}
696
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000697static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000698 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000699 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
700 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000701}
702
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000703static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400704 openolt::Indication ind;
705 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
706 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
707
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000708 switch (msg->obj_type) {
709 case BCMOLT_OBJ_ID_ONU:
710 switch (msg->subgroup) {
711 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
712 {
713 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
714 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400715
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000716 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
717 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400718
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000719 sufi_ind->set_intf_id(key->pon_ni);
720 sufi_ind->set_onu_id(key->onu_id);
721 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
722 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400723
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000724 ind.set_allocated_alarm_ind(alarm_ind);
725 }
726 }
727 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400728
729 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000730 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400731}
732
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000733static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400734 openolt::Indication ind;
735 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
736 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
737
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000738 switch (msg->obj_type) {
739 case BCMOLT_OBJ_ID_ONU:
740 switch (msg->subgroup) {
741 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
742 {
743 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
744 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400745
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000746 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
747 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400748
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000749 sdi_ind->set_intf_id(key->pon_ni);
750 sdi_ind->set_onu_id(key->onu_id);
751 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
752 sdi_ind->set_inverse_bit_error_rate(data->ber);
753 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400754
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000755 ind.set_allocated_alarm_ind(alarm_ind);
756 }
757 }
758 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400759
760 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000761 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400762}
763
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000764static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400765 openolt::Indication ind;
766 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
767 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
768
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000769 switch (msg->obj_type) {
770 case BCMOLT_OBJ_ID_ONU:
771 switch (msg->subgroup) {
772 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
773 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530774 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000775 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400776
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000777 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",
778 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400779
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000780 dowi_ind->set_intf_id(key->pon_ni);
781 dowi_ind->set_onu_id(key->onu_id);
782 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
783 dowi_ind->set_drift(data->drift_value);
784 dowi_ind->set_new_eqd(data->new_eqd);
785 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400786
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000787 ind.set_allocated_alarm_ind(alarm_ind);
788 }
789 }
790 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400791
792 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000793 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400794}
795
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000796static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400797 openolt::Indication ind;
798 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
799 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
800
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000801 switch (msg->obj_type) {
802 case BCMOLT_OBJ_ID_ONU:
803 switch (msg->subgroup) {
804 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
805 {
806 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
807 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400808
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000809 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
810 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400811
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000812 looci_ind->set_intf_id(key->pon_ni);
813 looci_ind->set_onu_id(key->onu_id);
814 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
815 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400816
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000817 ind.set_allocated_alarm_ind(alarm_ind);
818 }
819 }
820 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400821
822 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000823 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400824}
825
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000826static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400827 openolt::Indication ind;
828 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
829 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
830
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000831 switch (msg->obj_type) {
832 case BCMOLT_OBJ_ID_ONU:
833 switch (msg->subgroup) {
834 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
835 {
836 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
837 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400838
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000839 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
840 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400841
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000842 sfi_ind->set_intf_id(key->pon_ni);
843 sfi_ind->set_onu_id(key->onu_id);
844 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
845 sfi_ind->set_inverse_bit_error_rate(data->ber);
846 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400847
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000848 ind.set_allocated_alarm_ind(alarm_ind);
849 }
850 }
851 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400852
853 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000854 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400855}
856
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000857static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400858 openolt::Indication ind;
859 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
860 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
861
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000862 switch (msg->obj_type) {
863 case BCMOLT_OBJ_ID_ONU:
864 switch (msg->subgroup) {
865 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
866 {
867 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
868 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400869
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000870 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
871 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400872
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000873 tiwi_ind->set_intf_id(key->pon_ni);
874 tiwi_ind->set_onu_id(key->onu_id);
875 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
876 tiwi_ind->set_drift(data->drift_value);
877 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400878
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000879 ind.set_allocated_alarm_ind(alarm_ind);
880 }
881 }
882 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400883
884 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000885 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400886}
887
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530888static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400889 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530890 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
891
892 switch (msg->obj_type) {
893 case BCMOLT_OBJ_ID_ONU:
894 switch (msg->subgroup) {
895 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
896 {
897 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
898 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
899
900 onu_ind->set_intf_id(key->pon_ni);
901 onu_ind->set_onu_id(key->onu_id);
902 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
903 onu_ind->set_oper_state("up");
904 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
905 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530906 switch (data->fail_reason) {
907 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
908 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
909 break;
910 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
911 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
912 break;
913 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
914 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
915 break;
916 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
917 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
918 break;
919 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
920 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
921 break;
922 default:
923 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
924 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530925 // Setting the admin_state state field based on a valid onu_id does not make any sense.
926 // The adapter too does not seem to interpret this seriously.
927 // Legacy code, lets keep this as is for now.
928 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
929 ind.set_allocated_onu_ind(onu_ind);
930 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
931 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
932 (key->onu_id)?"up":"down");
933 }
934 }
935 }
936
937 oltIndQ.push(ind);
938 bcmolt_msg_free(msg);
939}
940
Jason Huang93430532020-02-04 17:16:02 +0800941static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
942 openolt::Indication ind;
943 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
944 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
945
946 switch (msg->obj_type) {
947 case BCMOLT_OBJ_ID_ONU:
948 switch (msg->subgroup) {
949 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
950 {
951 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
952 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
953
954 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
955 key->pon_ni, key->onu_id, data->alarm_status);
956
957 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
958 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
959 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
960 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
961
962 ind.set_allocated_alarm_ind(alarm_ind);
963 }
964 }
965 }
966
967 oltIndQ.push(ind);
968 bcmolt_msg_free(msg);
969}
970
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800971static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +0800972 openolt::Indication ind;
973 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
974 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
975
976 switch (msg->obj_type) {
977 case BCMOLT_OBJ_ID_ONU:
978 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800979 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +0800980 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800981 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
982 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 +0800983
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800984 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
985 switch (data->stat)
986 {
987 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
988 uint64_t rdi_errors;
989 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
990 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
991 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
992 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
993 rdi_err_ind->set_rdi_error_count(rdi_errors);
994 rdi_err_ind->set_status("on");
995 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
996 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
997 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
998 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
999 break;
1000 /* It is a further requirement
1001 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1002 uint64_t bip_errors;
1003 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1004 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1005 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1006 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
1007 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1008 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1009 break;
1010 */
1011 }
1012 ind.set_allocated_alarm_ind(alarm_ind);
1013 }
Jason Huang93430532020-02-04 17:16:02 +08001014 }
1015 }
1016 }
1017
1018 oltIndQ.push(ind);
1019 bcmolt_msg_free(msg);
1020}
1021
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001022static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1023 openolt::Indication ind;
1024 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1025 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +08001026
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001027 switch (msg->obj_type) {
1028 case BCMOLT_OBJ_ID_ONU:
1029 switch (msg->subgroup) {
1030 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
1031 {
1032 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
1033 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
1034
1035 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
1036 switch (data->stat)
1037 {
1038 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
1039 uint64_t rdi_errors;
1040 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
1041
1042 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1043 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1044 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1045 rdi_err_ind->set_rdi_error_count(rdi_errors);
1046 rdi_err_ind->set_status("off");
1047 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
1048 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1049 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
1050 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1051 break;
1052 /* It is a further requirement
1053 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
1054 uint64_t bip_errors;
1055 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
1056 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
1057 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
1058 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
1059 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
1060 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
1061 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
1062 break;
1063 */
1064 }
1065 ind.set_allocated_alarm_ind(alarm_ind);
1066 }
1067 }
1068 }
1069 }
1070
1071 oltIndQ.push(ind);
1072 bcmolt_msg_free(msg);
1073}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301074
1075static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1076 openolt::Indication ind;
1077
1078 openolt::Indication onu_ind;
1079 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001080
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001081 switch (msg->obj_type) {
1082 case BCMOLT_OBJ_ID_ONU:
1083 switch (msg->subgroup) {
1084 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1085 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301086 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1087 bcmolt_onu_onu_deactivation_completed_data *data =
1088 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001089
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301090 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1091 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001092
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301093 onu_ind_data->set_intf_id(key->pon_ni);
1094 onu_ind_data->set_onu_id(key->onu_id);
1095 onu_ind_data->set_oper_state("down");
1096 onu_ind_data->set_admin_state("down");
1097 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301098
1099 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1100 onu_deactivate_complete_result res;
1101 res.pon_intf_id = (uint32_t)key->pon_ni;
1102 res.onu_id = (uint32_t) key->onu_id;
1103 res.result = data->status;
1104 res.reason = data->fail_reason;
1105
1106 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1107 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1108
1109 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1110 // Push the result from BAL to queue
1111 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1112 if (it == onu_deact_compltd_map.end()) {
1113 // 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 -08001114 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1115 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1116 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301117 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 +05301118 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301119 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001120 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301121 // Push the result
1122 it->second->push(res);
1123 }
1124 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001125 }
1126 }
1127 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001128
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301129 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001130 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001131}
1132
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001133static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1134 switch (msg->obj_type) {
1135 case BCMOLT_OBJ_ID_ONU:
1136 switch (msg->subgroup) {
1137 case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED:
1138 {
1139 bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key;
1140 bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data;
1141 double rx_power_mean_dbm = 0.0;
1142
1143 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n",
1144 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1145
1146 if (data->status == BCMOLT_RESULT_SUCCESS) {
1147 auto trx_eeprom_reader =
1148#ifdef ASGVOLT64
1149 TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni};
1150#else
1151 TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni};
1152#endif
1153 auto power = trx_eeprom_reader.read_power_mean_dbm();
1154
1155 if (power.second) {
1156 rx_power_mean_dbm = power.first.first;
1157 OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm);
1158 } else {
1159 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n");
1160 }
1161 } else {
1162 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure");
1163 }
1164
1165 // for internal use insert into map
1166 onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id);
1167 onu_rssi_complete_result res;
1168 res.pon_intf_id = (uint32_t)key->pon_ni;
1169 res.onu_id = (uint32_t)key->onu_id;
1170 res.status = bcmolt_result_to_string(data->status);
1171 res.reason = data->fail_reason;
1172 res.rx_power_mean_dbm = rx_power_mean_dbm;
1173
1174 bcmos_fastlock_lock(&onu_rssi_wait_lock);
1175 auto it = onu_rssi_compltd_map.find(onu_key);
1176 if (it == onu_rssi_compltd_map.end()) {
1177 OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n",
1178 key->pon_ni, key->onu_id);
1179 } else if (it->second) {
1180 it->second->push(res);
1181 } else {
1182 OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n",
1183 key->pon_ni, key->onu_id);
1184 }
1185 bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0);
1186 }
1187 }
1188 }
1189
1190 bcmolt_msg_free(msg);
1191}
1192
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001193/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001194bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1195 openolt::Indication ind;
1196 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1197 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1198
1199 bcmbal_subscriber_terminal_key *key =
1200 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1201
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001202 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001203 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001204
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001205 onu_proc_error_ind->set_intf_id(key->intf_id);
1206 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1207
1208 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1209 ind.set_allocated_alarm_ind(alarm_ind);
1210
1211 oltIndQ.push(ind);
1212 return BCM_ERR_OK;
1213}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001214*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001215
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001216static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1217
1218 switch (msg->obj_type) {
1219 case BCMOLT_OBJ_ID_GROUP:
1220 switch (msg->subgroup) {
1221 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1222 {
1223 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1224 bcmolt_group_complete_members_update_data *data =
1225 &((bcmolt_group_complete_members_update*)msg)->data;
1226
1227 if (data->result == BCMOLT_RESULT_SUCCESS) {
1228 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1229 } else {
1230 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1231 }
1232 }
1233 }
1234 }
1235 bcmolt_msg_free(msg);
1236}
1237
Shad Ansari01b0e652018-04-05 21:02:53 +00001238Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001239 bcmolt_rx_cfg rx_cfg = {};
1240 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001241
1242 if (subscribed) {
1243 return Status::OK;
1244 }
1245
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001246 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1247 rx_cfg.rx_cb = OltOperIndication;
1248 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1249 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1250 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1251 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301252 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001253 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001254
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001255 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1256 rx_cfg.rx_cb = OltOperIndication;
1257 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1258 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1259 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1260 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301261 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001262 "Olt disconnection complete state indication subscribe failed");
1263
1264 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1265 rx_cfg.rx_cb = OltOperIndication;
1266 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1267 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1268 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1269 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301270 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001271 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001272
1273 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001274 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1275 rx_cfg.rx_cb = LosIndication;
1276 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1277 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1278 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1279 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001280 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001281
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001282 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1283 rx_cfg.rx_cb = IfOperIndication;
1284 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1285 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1286 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1287 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301288 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001289 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001290
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001291 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1292 rx_cfg.rx_cb = IfOperIndication;
1293 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1294 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1295 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1296 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301297 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001298 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001299
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001300 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1301 rx_cfg.rx_cb = OnuAlarmIndication;
1302 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1303 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1304 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1305 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001306 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001307
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001308 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1309 rx_cfg.rx_cb = OnuAlarmIndication;
1310 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1311 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1312 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1313 if(rc != BCM_ERR_OK)
1314 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1315
1316 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1317 rx_cfg.rx_cb = OnuDyingGaspIndication;
1318 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1319 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1320 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1321 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001322 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001323
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001324 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1325 rx_cfg.rx_cb = OnuDiscoveryIndication;
1326 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1327 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1328 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1329 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001330 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001331
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001332 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001333 rx_cfg.rx_cb = OnuStartupFailureIndication;
1334 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1335 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1336 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1337 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301338 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001339 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001340
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001341 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1342 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1343 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1344 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1345 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1346 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001347 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001348
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001349 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1350 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1351 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1352 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1353 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1354 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001355 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001356
1357 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001358 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1359 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1360 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1361 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1362 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1363 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001364 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001365
1366 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001367 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1368 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1369 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1370 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1371 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1372 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001373 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001374
1375 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001376 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1377 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1378 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1379 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1380 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1381 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001382 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001383
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301384 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001385 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301386 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1387 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1388 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1389 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1390 if(rc != BCM_ERR_OK)
1391 return Status(grpc::StatusCode::INTERNAL,
1392 "onu activation completed indication subscribe failed");
1393
1394 /* ONU Deactivation Completed Indication */
1395 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1396 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001397 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1398 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1399 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1400 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301401 return Status(grpc::StatusCode::INTERNAL,
1402 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001403
Jason Huang93430532020-02-04 17:16:02 +08001404 /* ONU Loss of Key Sync Indiction */
1405 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1406 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1407 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1408 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1409 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1410 if(rc != BCM_ERR_OK)
1411 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1412
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001413 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001414 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001415 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001416 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001417 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001418 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1419 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001420 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1421
1422 /* ONU ITU-PON Cleared Stats Indiction */
1423 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1424 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1425 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1426 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1427 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1428 if(rc != BCM_ERR_OK)
1429 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001430
Jason Huang09b73ea2020-01-08 17:52:05 +08001431 /* Packet-In by Access_Control */
1432 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001433 rx_cfg.rx_cb = PacketIndication;
1434 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001435 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001436 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1437 if(rc != BCM_ERR_OK)
1438 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001439
Girish Gowdra252f4972020-09-07 21:24:01 -07001440#ifndef SCALE_AND_PERF
Girish Gowdra96461052019-11-22 20:13:59 +05301441 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1442 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1443 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1444 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1445 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1446 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001447 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Thiyagarajan Subramanie976fcf2021-05-07 22:46:57 +05301448
1449 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM;
1450 rx_cfg.rx_cb = ItuPonGemConfigCompletedInd;
1451 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1452 rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed;
1453 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1454 if(rc != BCM_ERR_OK)
1455 return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed");
Girish Gowdra252f4972020-09-07 21:24:01 -07001456#endif
Girish Gowdra96461052019-11-22 20:13:59 +05301457
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001458 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1459 rx_cfg.rx_cb = GroupIndication;
1460 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1461 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1462 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1463 if(rc != BCM_ERR_OK)
1464 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1465
Orhan Kupusogluec57af02021-05-12 12:38:17 +00001466 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1467 rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication;
1468 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1469 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed;
1470 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1471 if(rc != BCM_ERR_OK)
1472 return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed");
1473
Shad Ansari01b0e652018-04-05 21:02:53 +00001474 subscribed = true;
1475
1476 return Status::OK;
1477}