blob: 1939e60d31acfa8dcd6ef38f79f7e211809cb98a [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"
24
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040025#include <string>
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040026
Shad Ansari01b0e652018-04-05 21:02:53 +000027extern "C"
28{
29#include <bcmos_system.h>
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000030#include <bcmolt_api.h>
31#include <bcmolt_host_api.h>
32#include <bcmolt_api_model_api_structs.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000033}
34
35using grpc::Status;
36
Shad Ansari627b5782018-08-13 22:49:32 +000037extern Queue<openolt::Indication> oltIndQ;
Girish Gowdra96461052019-11-22 20:13:59 +053038extern std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *> alloc_cfg_compltd_map;
39extern bcmos_fastlock alloc_cfg_wait_lock;
Shad Ansari01b0e652018-04-05 21:02:53 +000040
41bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080042uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000043#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000044
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000045static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000046
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000047#define INTERFACE_STATE_IF_DOWN(state) \
48 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
49 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
50 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
51#define INTERFACE_STATE_IF_UP(state) \
52 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
53#define ONU_STATE_IF_DOWN(state) \
54 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
55 state == BCMOLT_ONU_OPERATION_DISABLE || \
56 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
57#define ONU_STATE_IF_UP(state) \
58 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053059#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000060 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053061#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000062 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
63#define SET_OPER_STATE(indication,state) \
64 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
65 indication->set_oper_state("down")
66#define GET_FLOW_TYPE(type) \
67 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
68 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
69 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
70
71std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050072{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000073 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050074 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000075 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050076 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000077 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
78 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050079 }
80 return "unknown";
81}
82
Jason Huang09b73ea2020-01-08 17:52:05 +080083std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000084{
Jason Huang09b73ea2020-01-08 17:52:05 +080085 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000086 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080087 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000088 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080089 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000090 return "host";
91 }
92 return "unknown";
93}
94
Jason Huang5d9ab1a2020-04-15 16:53:49 +080095inline uint64_t get_pon_stats_alarms_data(bcmolt_interface pon_ni, bcmolt_onu_id onu_id, bcmolt_onu_itu_pon_stats_data_id stat) {
96 bcmos_errno err;
97 bcmolt_onu_itu_pon_stats itu_pon_stat; /* declare main API struct */
98 bcmolt_onu_key key = {}; /* declare key */
99 bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE; /* declare 'clear on read' flag */
100
101 key.pon_ni = pon_ni;
102 key.onu_id = onu_id;
103
104 /* Initialize the API struct. */
105 BCMOLT_STAT_INIT(&itu_pon_stat, onu, itu_pon_stats, key);
106 switch (stat) {
107 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
108 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, rdi_errors);
109 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
110 if (err) {
111 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get rdi_errors, err = %s\n", bcmos_strerror(err));
112 return err;
113 }
114 return itu_pon_stat.data.rdi_errors;
115 /* It is a further requirement
116 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
117 BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, bip_errors);
118 err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE);
119 if (err) {
120 OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get bip_errors, err = %s\n", bcmos_strerror(err));
121 return err;
122 }
123 return itu_pon_stat.data.bip_errors;
124 */
125 default:
126 return BCM_ERR_INTERNAL;
127 }
128
129 return err;
130}
131
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000132/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -0700133 bcmbal_subscriber_terminal_key key;
134 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
135 uint8_t *list_mem;// to fetch config details for ONU
136 bcmos_errno err = BCM_ERR_OK;
137
138 key.sub_term_id =onu_id;
139 key.intf_id = intf_id;
140 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
141
142 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
143
144 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
145 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
146 memset(reg_id, '\0', MAX_REGID_LENGTH);
147
148 //set memory to use for variable-sized lists
149 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
150
151 if (list_mem == NULL)
152 {
153 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
154 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
155 return reg_id;
156 }
157
158 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
159 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
160
161 //call API
162 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
163
164 if (err != BCM_ERR_OK)
165 {
166 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
167 key.sub_term_id, key.intf_id);
168 free(list_mem);
169 return reg_id;
170 }
171
172 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
173 key.sub_term_id, key.intf_id);
174
175 for (int i=0; i<MAX_REGID_LENGTH ; i++){
176 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
177 }
178
179 free(list_mem);
180 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000181}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700182
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000183static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000184 openolt::Indication ind;
185 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500186 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500187
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000188 switch (msg->subgroup) {
189 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
190 admin_state = "up";
191 olt_ind->set_oper_state("up");
192 break;
193 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
194 admin_state = "down";
195 olt_ind->set_oper_state("down");
196 break;
197 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
198 admin_state = "failure";
199 olt_ind->set_oper_state("failure");
200 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000201 }
202 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500203
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000204 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
205 /* register for omci indication */
206 {
207 bcmolt_rx_cfg rx_cfg = {};
208 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
209 rx_cfg.rx_cb = OmciIndication;
210 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
211 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
212 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000213 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500214 state.activate();
215 }
216 else {
217 state.deactivate();
218 }
219
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000220 oltIndQ.push(ind);
221 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000222}
223
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000224static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000225 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400226 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
227 openolt::LosIndication* los_ind = new openolt::LosIndication;
228
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000229 switch (msg->obj_type) {
230 case BCMOLT_OBJ_ID_PON_INTERFACE:
231 switch (msg->subgroup) {
232 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
233 {
234 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
235 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
236 BCMOLT_INTERFACE_TYPE_PON);
237 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400238
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530239 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000240 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400241
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000242 los_ind->set_intf_id(intf_id);
243 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400244
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000245 alarm_ind->set_allocated_los_ind(los_ind);
246 ind.set_allocated_alarm_ind(alarm_ind);
247 break;
248 }
249 }
250 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400251
252 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000253 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000254}
255
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000256static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700257 openolt::Indication ind;
258 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
259
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530260 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000261 case BCMOLT_OBJ_ID_PON_INTERFACE:
262 switch (msg->subgroup) {
263 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530264 {
265 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000266 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530267 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000268 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700269
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000270 intf_ind->set_intf_id(key->pon_ni);
271 SET_OPER_STATE(intf_ind, data->new_state);
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530272
273 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n",
274 bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str());
275
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000276 ind.set_allocated_intf_ind(intf_ind);
277 break;
278 }
279 }
280 break;
281 case BCMOLT_OBJ_ID_NNI_INTERFACE:
282 switch (msg->subgroup) {
283 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
284 {
285 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
286 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530287 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000288 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530289 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000290 &((bcmolt_nni_interface_state_change *)msg)->data;
291
292 intf_ind->set_intf_id(key->id);
293 SET_OPER_STATE(intf_ind, data->new_state);
294 ind.set_allocated_intf_ind(intf_ind);
295 break;
296 }
297 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700298 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700299
300 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000301 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700302}
303
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000304static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000305 openolt::Indication ind;
306 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000307
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000308 switch (msg->obj_type) {
309 case BCMOLT_OBJ_ID_PON_INTERFACE:
310 switch (msg->subgroup) {
311 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
312 {
313 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
314 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
315 intf_oper_ind->set_intf_id(key->pon_ni);
316 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
317 SET_OPER_STATE(intf_oper_ind, data->new_state);
318 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
319 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
320 ind.set_allocated_intf_oper_ind(intf_oper_ind);
321 break;
322 }
323 }
324 case BCMOLT_OBJ_ID_NNI_INTERFACE:
325 switch (msg->subgroup) {
326 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
327 {
328 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
329 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
330 bcmolt_interface intf_id = key->id;
331 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
332 intf_oper_ind->set_intf_id(key->id);
333 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530334 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000335 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
336 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
337 ind.set_allocated_intf_oper_ind(intf_oper_ind);
338 break;
339 }
340 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000341 }
342
Shad Ansari01b0e652018-04-05 21:02:53 +0000343 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000344 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000345}
346
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000347static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000348 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400349 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
350 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
351
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000352 switch (msg->obj_type) {
353 case BCMOLT_OBJ_ID_ONU:
354 switch (msg->subgroup) {
355 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
356 {
Jason Huang93430532020-02-04 17:16:02 +0800357 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
358 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530359
360 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
361
362 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());
363
Jason Huang93430532020-02-04 17:16:02 +0800364 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
365 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
366 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
367 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
368 onu_alarm_ind->set_intf_id(key->pon_ni);
369 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000370 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
371 ind.set_allocated_alarm_ind(alarm_ind);
372 break;
373 }
374 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
375 {
Jason Huang93430532020-02-04 17:16:02 +0800376 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
377 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
378 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
379 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
380 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
381 onu_alarm_ind->set_intf_id(key->pon_ni);
382 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000383 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
384 ind.set_allocated_alarm_ind(alarm_ind);
385 break;
386 }
387 }
388 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400389
390 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000391 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000392}
393
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000394static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000395 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400396 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000397 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400398
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000399 switch (msg->obj_type) {
400 case BCMOLT_OBJ_ID_ONU:
401 switch (msg->subgroup) {
402 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
403 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500404 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500405 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
406
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530407 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
408
409 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
410 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
411
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500412 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500413 dgi_ind->set_intf_id(key->pon_ni);
414 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400415
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000416 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
417 ind.set_allocated_alarm_ind(alarm_ind);
418 break;
419 }
420 }
421 }
nickc063ffd2018-05-22 14:35:28 -0400422
423 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000424 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000425}
426
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000427static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000428 openolt::Indication ind;
429 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
430 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
431
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000432 switch (msg->obj_type) {
433 case BCMOLT_OBJ_ID_PON_INTERFACE:
434 switch (msg->subgroup) {
435 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
436 {
437 bcmolt_pon_interface_key *key =
438 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000439
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530440 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000441 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000442
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000443 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000444
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000445 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
446 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000447
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000448 onu_disc_ind->set_intf_id(key->pon_ni);
449 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
450 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
451 onu_disc_ind->set_allocated_serial_number(serial_number);
452 ind.set_allocated_onu_disc_ind(onu_disc_ind);
453 break;
454 }
455 }
456 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000457
458 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000459 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000460}
461
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000462static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000463 openolt::Indication ind;
464 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000465
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000466 switch (msg->obj_type) {
467 case BCMOLT_OBJ_ID_ONU:
468 switch (msg->subgroup) {
469 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
470 {
471 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
472 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000473
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530474 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000475 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000476
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000477 omci_ind->set_intf_id(key->pon_ni);
478 omci_ind->set_onu_id(key->onu_id);
479 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
480
481 ind.set_allocated_omci_ind(omci_ind);
482 break;
483 }
484 }
485 }
486
Shad Ansari01b0e652018-04-05 21:02:53 +0000487 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000488 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000489}
490
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000491static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000492 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000493 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
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 {
Jason Huang09b73ea2020-01-08 17:52:05 +0800500 bcmolt_access_control_receive_eth_packet *pkt =
501 (bcmolt_access_control_receive_eth_packet*)msg;
502 bcmolt_access_control_receive_eth_packet_data *pkt_data =
503 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000504
Jason Huang09b73ea2020-01-08 17:52:05 +0800505 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
506 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
507 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000508 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800509 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000510 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500511
Jason Huang09b73ea2020-01-08 17:52:05 +0800512 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
513 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
514 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
515 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
516 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
517 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
518 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000519 }
520 }
521 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500522
Shad Ansari5fe93682018-04-26 05:24:19 +0000523 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000524 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000525}
526
Girish Gowdra96461052019-11-22 20:13:59 +0530527static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
528
529 switch (msg->obj_type) {
530 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
531 switch (msg->subgroup) {
532 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
533 {
534 bcmolt_itupon_alloc_configuration_completed *pkt =
535 (bcmolt_itupon_alloc_configuration_completed*)msg;
536 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
537 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
538
539 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
540 alloc_cfg_complete_result res;
541 res.pon_intf_id = pkt->key.pon_ni;
542 res.alloc_id = pkt->key.alloc_id;
543
544 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
545 switch (pkt_data->new_state) {
546 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
547 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
548 break;
549 case BCMOLT_ACTIVATION_STATE_INACTIVE:
550 res.state = ALLOC_OBJECT_STATE_INACTIVE;
551 break;
552 case BCMOLT_ACTIVATION_STATE_PROCESSING:
553 res.state = ALLOC_OBJECT_STATE_PROCESSING;
554 break;
555 case BCMOLT_ACTIVATION_STATE_ACTIVE:
556 res.state = ALLOC_OBJECT_STATE_ACTIVE;
557 break;
558 default:
559 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
560 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
561 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
562 }
563 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",
564 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
565
566 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
567 // Push the result from BAL to queue
568 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
569 if (it == alloc_cfg_compltd_map.end()) {
570 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
571 bcmolt_msg_free(msg);
572 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);
573 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
574 return;
575 }
576 if (it->second) {
577 // Push the result
578 it->second->push(res);
579 }
580 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
581 }
582 }
583 }
584
585 bcmolt_msg_free(msg);
586}
587
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000588static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000589 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000590 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
591 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000592}
593
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000594static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000595 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000596 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
597 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000598}
599
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000600static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000601 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000602 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
603 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000604}
605
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000606static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000607 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000608 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
609 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000610}
611
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000612static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000613 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000614 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
615 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000616}
617
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000618static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400619 openolt::Indication ind;
620 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
621 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
622
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000623 switch (msg->obj_type) {
624 case BCMOLT_OBJ_ID_ONU:
625 switch (msg->subgroup) {
626 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
627 {
628 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
629 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400630
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000631 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
632 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400633
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000634 sufi_ind->set_intf_id(key->pon_ni);
635 sufi_ind->set_onu_id(key->onu_id);
636 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
637 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400638
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000639 ind.set_allocated_alarm_ind(alarm_ind);
640 }
641 }
642 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400643
644 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000645 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400646}
647
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000648static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400649 openolt::Indication ind;
650 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
651 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
652
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000653 switch (msg->obj_type) {
654 case BCMOLT_OBJ_ID_ONU:
655 switch (msg->subgroup) {
656 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
657 {
658 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
659 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400660
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000661 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
662 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400663
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000664 sdi_ind->set_intf_id(key->pon_ni);
665 sdi_ind->set_onu_id(key->onu_id);
666 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
667 sdi_ind->set_inverse_bit_error_rate(data->ber);
668 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400669
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000670 ind.set_allocated_alarm_ind(alarm_ind);
671 }
672 }
673 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400674
675 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000676 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400677}
678
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000679static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400680 openolt::Indication ind;
681 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
682 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
683
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000684 switch (msg->obj_type) {
685 case BCMOLT_OBJ_ID_ONU:
686 switch (msg->subgroup) {
687 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
688 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530689 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000690 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400691
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000692 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",
693 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400694
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000695 dowi_ind->set_intf_id(key->pon_ni);
696 dowi_ind->set_onu_id(key->onu_id);
697 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
698 dowi_ind->set_drift(data->drift_value);
699 dowi_ind->set_new_eqd(data->new_eqd);
700 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400701
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000702 ind.set_allocated_alarm_ind(alarm_ind);
703 }
704 }
705 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706
707 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000708 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400709}
710
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000711static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400712 openolt::Indication ind;
713 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
714 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
715
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000716 switch (msg->obj_type) {
717 case BCMOLT_OBJ_ID_ONU:
718 switch (msg->subgroup) {
719 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
720 {
721 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
722 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400723
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000724 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
725 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400726
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000727 looci_ind->set_intf_id(key->pon_ni);
728 looci_ind->set_onu_id(key->onu_id);
729 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
730 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400731
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000732 ind.set_allocated_alarm_ind(alarm_ind);
733 }
734 }
735 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400736
737 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000738 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400739}
740
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000741static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400742 openolt::Indication ind;
743 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
744 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
745
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000746 switch (msg->obj_type) {
747 case BCMOLT_OBJ_ID_ONU:
748 switch (msg->subgroup) {
749 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
750 {
751 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
752 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400753
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000754 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
755 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400756
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000757 sfi_ind->set_intf_id(key->pon_ni);
758 sfi_ind->set_onu_id(key->onu_id);
759 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
760 sfi_ind->set_inverse_bit_error_rate(data->ber);
761 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400762
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000763 ind.set_allocated_alarm_ind(alarm_ind);
764 }
765 }
766 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400767
768 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000769 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400770}
771
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000772static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400773 openolt::Indication ind;
774 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
775 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
776
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000777 switch (msg->obj_type) {
778 case BCMOLT_OBJ_ID_ONU:
779 switch (msg->subgroup) {
780 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
781 {
782 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
783 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400784
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000785 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
786 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400787
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000788 tiwi_ind->set_intf_id(key->pon_ni);
789 tiwi_ind->set_onu_id(key->onu_id);
790 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
791 tiwi_ind->set_drift(data->drift_value);
792 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400793
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000794 ind.set_allocated_alarm_ind(alarm_ind);
795 }
796 }
797 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400798
799 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000800 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400801}
802
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530803static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400804 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530805 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
806
807 switch (msg->obj_type) {
808 case BCMOLT_OBJ_ID_ONU:
809 switch (msg->subgroup) {
810 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
811 {
812 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
813 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
814
815 onu_ind->set_intf_id(key->pon_ni);
816 onu_ind->set_onu_id(key->onu_id);
817 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
818 onu_ind->set_oper_state("up");
819 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
820 onu_ind->set_oper_state("down");
kesavand88fdddd2020-09-04 12:06:34 +0530821 switch (data->fail_reason) {
822 case BCMOLT_ACTIVATION_FAIL_REASON_RANGING:
823 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING);
824 break;
825 case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION:
826 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION);
827 break;
828 case BCMOLT_ACTIVATION_FAIL_REASON_LOS:
829 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS);
830 break;
831 case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM:
832 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM);
833 break;
834 case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER:
835 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER);
836 break;
837 default:
838 onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE);
839 }
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530840 // Setting the admin_state state field based on a valid onu_id does not make any sense.
841 // The adapter too does not seem to interpret this seriously.
842 // Legacy code, lets keep this as is for now.
843 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
844 ind.set_allocated_onu_ind(onu_ind);
845 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
846 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
847 (key->onu_id)?"up":"down");
848 }
849 }
850 }
851
852 oltIndQ.push(ind);
853 bcmolt_msg_free(msg);
854}
855
Jason Huang93430532020-02-04 17:16:02 +0800856static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
857 openolt::Indication ind;
858 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
859 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
860
861 switch (msg->obj_type) {
862 case BCMOLT_OBJ_ID_ONU:
863 switch (msg->subgroup) {
864 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
865 {
866 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
867 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
868
869 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
870 key->pon_ni, key->onu_id, data->alarm_status);
871
872 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
873 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
874 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
875 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
876
877 ind.set_allocated_alarm_ind(alarm_ind);
878 }
879 }
880 }
881
882 oltIndQ.push(ind);
883 bcmolt_msg_free(msg);
884}
885
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800886static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Jason Huang93430532020-02-04 17:16:02 +0800887 openolt::Indication ind;
888 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
889 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
890
891 switch (msg->obj_type) {
892 case BCMOLT_OBJ_ID_ONU:
893 switch (msg->subgroup) {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800894 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED:
Jason Huang93430532020-02-04 17:16:02 +0800895 {
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800896 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key;
897 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 +0800898
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800899 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) {
900 switch (data->stat)
901 {
902 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
903 uint64_t rdi_errors;
904 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
905 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
906 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
907 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
908 rdi_err_ind->set_rdi_error_count(rdi_errors);
909 rdi_err_ind->set_status("on");
910 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
911 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
912 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
913 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
914 break;
915 /* It is a further requirement
916 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
917 uint64_t bip_errors;
918 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
919 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
920 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
921 OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \
922 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
923 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
924 break;
925 */
926 }
927 ind.set_allocated_alarm_ind(alarm_ind);
928 }
Jason Huang93430532020-02-04 17:16:02 +0800929 }
930 }
931 }
932
933 oltIndQ.push(ind);
934 bcmolt_msg_free(msg);
935}
936
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800937static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
938 openolt::Indication ind;
939 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
940 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
Jason Huang93430532020-02-04 17:16:02 +0800941
Jason Huang5d9ab1a2020-04-15 16:53:49 +0800942 switch (msg->obj_type) {
943 case BCMOLT_OBJ_ID_ONU:
944 switch (msg->subgroup) {
945 case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED:
946 {
947 bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key;
948 bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data;
949
950 if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) {
951 switch (data->stat)
952 {
953 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS:
954 uint64_t rdi_errors;
955 openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication;
956
957 rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
958 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
959 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
960 rdi_err_ind->set_rdi_error_count(rdi_errors);
961 rdi_err_ind->set_status("off");
962 onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind);
963 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
964 rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors);
965 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
966 break;
967 /* It is a further requirement
968 case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS:
969 uint64_t bip_errors;
970 bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat);
971 onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni);
972 onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id);
973 onu_itu_pon_stats_ind->set_bip_errors(bip_errors);
974 OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \
975 bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors);
976 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
977 break;
978 */
979 }
980 ind.set_allocated_alarm_ind(alarm_ind);
981 }
982 }
983 }
984 }
985
986 oltIndQ.push(ind);
987 bcmolt_msg_free(msg);
988}
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530989
990static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
991 openolt::Indication ind;
992
993 openolt::Indication onu_ind;
994 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400995
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000996 switch (msg->obj_type) {
997 case BCMOLT_OBJ_ID_ONU:
998 switch (msg->subgroup) {
999 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
1000 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301001 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
1002 bcmolt_onu_onu_deactivation_completed_data *data =
1003 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001004
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301005 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
1006 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001007
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301008 onu_ind_data->set_intf_id(key->pon_ni);
1009 onu_ind_data->set_onu_id(key->onu_id);
1010 onu_ind_data->set_oper_state("down");
1011 onu_ind_data->set_admin_state("down");
1012 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301013
1014 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
1015 onu_deactivate_complete_result res;
1016 res.pon_intf_id = (uint32_t)key->pon_ni;
1017 res.onu_id = (uint32_t) key->onu_id;
1018 res.result = data->status;
1019 res.reason = data->fail_reason;
1020
1021 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
1022 key->pon_ni, key->onu_id, data->status, data->fail_reason);
1023
1024 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
1025 // Push the result from BAL to queue
1026 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
1027 if (it == onu_deact_compltd_map.end()) {
1028 // 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 -08001029 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
1030 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
1031 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +05301032 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 +05301033 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301034 }
Girish Gowdra6675fa02020-03-03 20:27:50 -08001035 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +05301036 // Push the result
1037 it->second->push(res);
1038 }
1039 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001040 }
1041 }
1042 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001043
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301044 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001045 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001046}
1047
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001048/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001049bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
1050 openolt::Indication ind;
1051 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
1052 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
1053
1054 bcmbal_subscriber_terminal_key *key =
1055 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
1056
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001057 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001058 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001059
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001060 onu_proc_error_ind->set_intf_id(key->intf_id);
1061 onu_proc_error_ind->set_onu_id(key->sub_term_id);
1062
1063 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
1064 ind.set_allocated_alarm_ind(alarm_ind);
1065
1066 oltIndQ.push(ind);
1067 return BCM_ERR_OK;
1068}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001069*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001070
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001071static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
1072
1073 switch (msg->obj_type) {
1074 case BCMOLT_OBJ_ID_GROUP:
1075 switch (msg->subgroup) {
1076 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
1077 {
1078 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
1079 bcmolt_group_complete_members_update_data *data =
1080 &((bcmolt_group_complete_members_update*)msg)->data;
1081
1082 if (data->result == BCMOLT_RESULT_SUCCESS) {
1083 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
1084 } else {
1085 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
1086 }
1087 }
1088 }
1089 }
1090 bcmolt_msg_free(msg);
1091}
1092
Shad Ansari01b0e652018-04-05 21:02:53 +00001093Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001094 bcmolt_rx_cfg rx_cfg = {};
1095 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +00001096
1097 if (subscribed) {
1098 return Status::OK;
1099 }
1100
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001101 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1102 rx_cfg.rx_cb = OltOperIndication;
1103 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1104 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
1105 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1106 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301107 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001108 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001109
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001110 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1111 rx_cfg.rx_cb = OltOperIndication;
1112 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1113 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
1114 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1115 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301116 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001117 "Olt disconnection complete state indication subscribe failed");
1118
1119 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
1120 rx_cfg.rx_cb = OltOperIndication;
1121 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1122 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
1123 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1124 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301125 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001126 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001127
1128 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001129 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1130 rx_cfg.rx_cb = LosIndication;
1131 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1132 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1133 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1134 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001135 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001136
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001137 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1138 rx_cfg.rx_cb = IfOperIndication;
1139 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1140 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1141 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1142 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301143 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001144 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001145
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001146 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1147 rx_cfg.rx_cb = IfOperIndication;
1148 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1149 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1150 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1151 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301152 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001153 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001154
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001155 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1156 rx_cfg.rx_cb = OnuAlarmIndication;
1157 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1158 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1159 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1160 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001161 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001162
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001163 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1164 rx_cfg.rx_cb = OnuAlarmIndication;
1165 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1166 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1167 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1168 if(rc != BCM_ERR_OK)
1169 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1170
1171 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1172 rx_cfg.rx_cb = OnuDyingGaspIndication;
1173 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1174 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1175 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1176 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001177 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001178
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001179 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1180 rx_cfg.rx_cb = OnuDiscoveryIndication;
1181 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1182 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1183 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1184 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001185 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001186
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001187 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001188 rx_cfg.rx_cb = OnuStartupFailureIndication;
1189 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1190 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1191 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1192 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301193 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001194 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001195
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001196 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1197 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1198 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1199 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1200 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1201 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001202 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001203
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001204 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1205 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1206 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1207 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1208 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1209 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001210 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001211
1212 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001213 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1214 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1215 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1216 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1217 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1218 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001219 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001220
1221 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001222 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1223 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1224 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1225 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1226 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1227 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001228 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001229
1230 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001231 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1232 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1233 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1234 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1235 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1236 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001237 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001238
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301239 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001240 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301241 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1242 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1243 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1244 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1245 if(rc != BCM_ERR_OK)
1246 return Status(grpc::StatusCode::INTERNAL,
1247 "onu activation completed indication subscribe failed");
1248
1249 /* ONU Deactivation Completed Indication */
1250 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1251 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001252 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1253 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1254 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1255 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301256 return Status(grpc::StatusCode::INTERNAL,
1257 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001258
Jason Huang93430532020-02-04 17:16:02 +08001259 /* ONU Loss of Key Sync Indiction */
1260 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1261 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1262 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1263 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1264 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1265 if(rc != BCM_ERR_OK)
1266 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1267
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001268 /* ONU ITU-PON Raised Stats Indiction */
Jason Huang93430532020-02-04 17:16:02 +08001269 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001270 rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication;
Jason Huang93430532020-02-04 17:16:02 +08001271 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001272 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised;
Jason Huang93430532020-02-04 17:16:02 +08001273 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1274 if(rc != BCM_ERR_OK)
Jason Huang5d9ab1a2020-04-15 16:53:49 +08001275 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed");
1276
1277 /* ONU ITU-PON Cleared Stats Indiction */
1278 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1279 rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication;
1280 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1281 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared;
1282 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1283 if(rc != BCM_ERR_OK)
1284 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed");
Jason Huang93430532020-02-04 17:16:02 +08001285
Jason Huang09b73ea2020-01-08 17:52:05 +08001286 /* Packet-In by Access_Control */
1287 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001288 rx_cfg.rx_cb = PacketIndication;
1289 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001290 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001291 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1292 if(rc != BCM_ERR_OK)
1293 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001294
Girish Gowdra96461052019-11-22 20:13:59 +05301295 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1296 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1297 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1298 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1299 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1300 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001301 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301302
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001303 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1304 rx_cfg.rx_cb = GroupIndication;
1305 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1306 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1307 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1308 if(rc != BCM_ERR_OK)
1309 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1310
Shad Ansari01b0e652018-04-05 21:02:53 +00001311 subscribed = true;
1312
1313 return Status::OK;
1314}