blob: 7c1c90dbc96bebe08f2b860b4dfb7d584555be71 [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
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040041
Shad Ansari01b0e652018-04-05 21:02:53 +000042bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080043uint32_t nni_intf_id = 0;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000044#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000045
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000046static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000047
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000048#define INTERFACE_STATE_IF_DOWN(state) \
49 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
50 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
51 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
52#define INTERFACE_STATE_IF_UP(state) \
53 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
54#define ONU_STATE_IF_DOWN(state) \
55 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
56 state == BCMOLT_ONU_OPERATION_DISABLE || \
57 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
58#define ONU_STATE_IF_UP(state) \
59 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053060#define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000061 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +053062#define ONU_ACTIVATION_COMPLETED_FAIL(state) \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000063 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
64#define SET_OPER_STATE(indication,state) \
65 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
66 indication->set_oper_state("down")
67#define GET_FLOW_TYPE(type) \
68 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
69 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
70 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
71
72std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073{
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000074 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050075 return "nni";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000076 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050077 return "pon";
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000078 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
79 return "host";
Craig Lutgen88a22ad2018-10-04 12:30:46 -050080 }
81 return "unknown";
82}
83
Jason Huang09b73ea2020-01-08 17:52:05 +080084std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000085{
Jason Huang09b73ea2020-01-08 17:52:05 +080086 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087 return "nni";
Jason Huang09b73ea2020-01-08 17:52:05 +080088 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000089 return "pon";
Jason Huang09b73ea2020-01-08 17:52:05 +080090 } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000091 return "host";
92 }
93 return "unknown";
94}
95
96/*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){
Girish Gowdru376b33c2019-05-06 21:46:31 -070097 bcmbal_subscriber_terminal_key key;
98 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
99 uint8_t *list_mem;// to fetch config details for ONU
100 bcmos_errno err = BCM_ERR_OK;
101
102 key.sub_term_id =onu_id;
103 key.intf_id = intf_id;
104 BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id);
105
106 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key);
107
108 BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties);
109 char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH);
110 memset(reg_id, '\0', MAX_REGID_LENGTH);
111
112 //set memory to use for variable-sized lists
113 list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE);
114
115 if (list_mem == NULL)
116 {
117 BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \
118 cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id);
119 return reg_id;
120 }
121
122 memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE);
123 BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE);
124
125 //call API
126 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr);
127
128 if (err != BCM_ERR_OK)
129 {
130 BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)",
131 key.sub_term_id, key.intf_id);
132 free(list_mem);
133 return reg_id;
134 }
135
136 BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)",
137 key.sub_term_id, key.intf_id);
138
139 for (int i=0; i<MAX_REGID_LENGTH ; i++){
140 reg_id[i]=sub_term_obj.data.registration_id.arr[i];
141 }
142
143 free(list_mem);
144 return reg_id;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000145}*/
Girish Gowdru376b33c2019-05-06 21:46:31 -0700146
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000147static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000148 openolt::Indication ind;
149 openolt::OltIndication* olt_ind = new openolt::OltIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500150 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500151
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000152 switch (msg->subgroup) {
153 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
154 admin_state = "up";
155 olt_ind->set_oper_state("up");
156 break;
157 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
158 admin_state = "down";
159 olt_ind->set_oper_state("down");
160 break;
161 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
162 admin_state = "failure";
163 olt_ind->set_oper_state("failure");
164 break;
Shad Ansari01b0e652018-04-05 21:02:53 +0000165 }
166 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500167
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000168 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
169 /* register for omci indication */
170 {
171 bcmolt_rx_cfg rx_cfg = {};
172 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
173 rx_cfg.rx_cb = OmciIndication;
174 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
175 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
176 bcmolt_ind_subscribe(current_device, &rx_cfg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000177 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500178 state.activate();
179 }
180 else {
181 state.deactivate();
182 }
183
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000184 oltIndQ.push(ind);
185 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000186}
187
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000188static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000189 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400190 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
191 openolt::LosIndication* los_ind = new openolt::LosIndication;
192
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000193 switch (msg->obj_type) {
194 case BCMOLT_OBJ_ID_PON_INTERFACE:
195 switch (msg->subgroup) {
196 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
197 {
198 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
199 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
200 BCMOLT_INTERFACE_TYPE_PON);
201 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400202
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530203 OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000204 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400205
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000206 los_ind->set_intf_id(intf_id);
207 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400208
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000209 alarm_ind->set_allocated_los_ind(los_ind);
210 ind.set_allocated_alarm_ind(alarm_ind);
211 break;
212 }
213 }
214 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400215
216 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000217 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000218}
219
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000220static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700221 openolt::Indication ind;
222 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
223
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530224 switch (msg->obj_type) {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000225 case BCMOLT_OBJ_ID_PON_INTERFACE:
226 switch (msg->subgroup) {
227 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530228 {
229 bcmolt_pon_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000230 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530231 bcmolt_pon_interface_state_change_completed_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000232 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700233
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000234 intf_ind->set_intf_id(key->pon_ni);
235 SET_OPER_STATE(intf_ind, data->new_state);
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530236
237 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n",
238 bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str());
239
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000240 ind.set_allocated_intf_ind(intf_ind);
241 break;
242 }
243 }
244 break;
245 case BCMOLT_OBJ_ID_NNI_INTERFACE:
246 switch (msg->subgroup) {
247 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
248 {
249 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
250 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530251 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000252 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530253 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000254 &((bcmolt_nni_interface_state_change *)msg)->data;
255
256 intf_ind->set_intf_id(key->id);
257 SET_OPER_STATE(intf_ind, data->new_state);
258 ind.set_allocated_intf_ind(intf_ind);
259 break;
260 }
261 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700262 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700263
264 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000265 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700266}
267
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000268static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000269 openolt::Indication ind;
270 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000271
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000272 switch (msg->obj_type) {
273 case BCMOLT_OBJ_ID_PON_INTERFACE:
274 switch (msg->subgroup) {
275 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
276 {
277 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
278 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
279 intf_oper_ind->set_intf_id(key->pon_ni);
280 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
281 SET_OPER_STATE(intf_oper_ind, data->new_state);
282 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
283 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
284 ind.set_allocated_intf_oper_ind(intf_oper_ind);
285 break;
286 }
287 }
288 case BCMOLT_OBJ_ID_NNI_INTERFACE:
289 switch (msg->subgroup) {
290 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
291 {
292 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
293 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
294 bcmolt_interface intf_id = key->id;
295 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
296 intf_oper_ind->set_intf_id(key->id);
297 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530298 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000299 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
300 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
301 ind.set_allocated_intf_oper_ind(intf_oper_ind);
302 break;
303 }
304 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000305 }
306
Shad Ansari01b0e652018-04-05 21:02:53 +0000307 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000308 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000309}
310
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000311static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000312 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400313 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
314 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
315
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000316 switch (msg->obj_type) {
317 case BCMOLT_OBJ_ID_ONU:
318 switch (msg->subgroup) {
319 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
320 {
Jason Huang93430532020-02-04 17:16:02 +0800321 bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data;
322 bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key;
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530323
324 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
325
326 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());
327
Jason Huang93430532020-02-04 17:16:02 +0800328 onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi));
329 onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi));
330 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss));
331 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error));
332 onu_alarm_ind->set_intf_id(key->pon_ni);
333 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000334 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
335 ind.set_allocated_alarm_ind(alarm_ind);
336 break;
337 }
338 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
339 {
Jason Huang93430532020-02-04 17:16:02 +0800340 bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data;
341 bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key;
342 onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi));
343 onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi));
344 onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami));
345 onu_alarm_ind->set_intf_id(key->pon_ni);
346 onu_alarm_ind->set_onu_id(key->onu_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000347 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
348 ind.set_allocated_alarm_ind(alarm_ind);
349 break;
350 }
351 }
352 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400353
354 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000355 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000356}
357
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000358static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000359 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400360 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000361 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400362
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000363 switch (msg->obj_type) {
364 case BCMOLT_OBJ_ID_ONU:
365 switch (msg->subgroup) {
366 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
367 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500368 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500369 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
370
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530371 int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON);
372
373 OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n",
374 key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str());
375
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500376 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500377 dgi_ind->set_intf_id(key->pon_ni);
378 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400379
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000380 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
381 ind.set_allocated_alarm_ind(alarm_ind);
382 break;
383 }
384 }
385 }
nickc063ffd2018-05-22 14:35:28 -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 OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000392 openolt::Indication ind;
393 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
394 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
395
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000396 switch (msg->obj_type) {
397 case BCMOLT_OBJ_ID_PON_INTERFACE:
398 switch (msg->subgroup) {
399 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
400 {
401 bcmolt_pon_interface_key *key =
402 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000403
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530404 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000405 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000406
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000407 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000408
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000409 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
410 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000411
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000412 onu_disc_ind->set_intf_id(key->pon_ni);
413 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
414 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
415 onu_disc_ind->set_allocated_serial_number(serial_number);
416 ind.set_allocated_onu_disc_ind(onu_disc_ind);
417 break;
418 }
419 }
420 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000421
422 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000423 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000424}
425
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000426static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000427 openolt::Indication ind;
428 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000429
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000430 switch (msg->obj_type) {
431 case BCMOLT_OBJ_ID_ONU:
432 switch (msg->subgroup) {
433 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
434 {
435 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
436 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000437
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530438 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000439 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000440
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000441 omci_ind->set_intf_id(key->pon_ni);
442 omci_ind->set_onu_id(key->onu_id);
443 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
444
445 ind.set_allocated_omci_ind(omci_ind);
446 break;
447 }
448 }
449 }
450
Shad Ansari01b0e652018-04-05 21:02:53 +0000451 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000452 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000453}
454
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000455static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000456 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000457 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000458
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000459 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800460 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000461 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800462 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000463 {
Jason Huang09b73ea2020-01-08 17:52:05 +0800464 bcmolt_access_control_receive_eth_packet *pkt =
465 (bcmolt_access_control_receive_eth_packet*)msg;
466 bcmolt_access_control_receive_eth_packet_data *pkt_data =
467 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000468
Jason Huang09b73ea2020-01-08 17:52:05 +0800469 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
470 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
471 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000472 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800473 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000474 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500475
Jason Huang09b73ea2020-01-08 17:52:05 +0800476 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
477 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
478 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
479 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
480 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
481 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
482 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000483 }
484 }
485 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500486
Shad Ansari5fe93682018-04-26 05:24:19 +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
Girish Gowdra96461052019-11-22 20:13:59 +0530491static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
492
493 switch (msg->obj_type) {
494 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
495 switch (msg->subgroup) {
496 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
497 {
498 bcmolt_itupon_alloc_configuration_completed *pkt =
499 (bcmolt_itupon_alloc_configuration_completed*)msg;
500 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
501 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
502
503 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
504 alloc_cfg_complete_result res;
505 res.pon_intf_id = pkt->key.pon_ni;
506 res.alloc_id = pkt->key.alloc_id;
507
508 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
509 switch (pkt_data->new_state) {
510 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
511 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
512 break;
513 case BCMOLT_ACTIVATION_STATE_INACTIVE:
514 res.state = ALLOC_OBJECT_STATE_INACTIVE;
515 break;
516 case BCMOLT_ACTIVATION_STATE_PROCESSING:
517 res.state = ALLOC_OBJECT_STATE_PROCESSING;
518 break;
519 case BCMOLT_ACTIVATION_STATE_ACTIVE:
520 res.state = ALLOC_OBJECT_STATE_ACTIVE;
521 break;
522 default:
523 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
524 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
525 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
526 }
527 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",
528 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
529
530 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
531 // Push the result from BAL to queue
532 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
533 if (it == alloc_cfg_compltd_map.end()) {
534 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
535 bcmolt_msg_free(msg);
536 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);
537 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
538 return;
539 }
540 if (it->second) {
541 // Push the result
542 it->second->push(res);
543 }
544 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
545 }
546 }
547 }
548
549 bcmolt_msg_free(msg);
550}
551
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000552static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000553 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000554 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
555 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000556}
557
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000558static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000559 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000560 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
561 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000562}
563
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000564static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000565 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000566 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
567 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000568}
569
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000570static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000571 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000572 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
573 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000574}
575
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000576static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000577 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000578 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
579 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000580}
581
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000582static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400583 openolt::Indication ind;
584 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
585 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
586
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000587 switch (msg->obj_type) {
588 case BCMOLT_OBJ_ID_ONU:
589 switch (msg->subgroup) {
590 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
591 {
592 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
593 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400594
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000595 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
596 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400597
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000598 sufi_ind->set_intf_id(key->pon_ni);
599 sufi_ind->set_onu_id(key->onu_id);
600 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
601 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400602
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000603 ind.set_allocated_alarm_ind(alarm_ind);
604 }
605 }
606 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400607
608 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000609 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400610}
611
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000612static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400613 openolt::Indication ind;
614 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
615 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
616
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000617 switch (msg->obj_type) {
618 case BCMOLT_OBJ_ID_ONU:
619 switch (msg->subgroup) {
620 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
621 {
622 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
623 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400624
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000625 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
626 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400627
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000628 sdi_ind->set_intf_id(key->pon_ni);
629 sdi_ind->set_onu_id(key->onu_id);
630 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
631 sdi_ind->set_inverse_bit_error_rate(data->ber);
632 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400633
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000634 ind.set_allocated_alarm_ind(alarm_ind);
635 }
636 }
637 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400638
639 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000640 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400641}
642
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000643static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644 openolt::Indication ind;
645 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
646 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
647
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000648 switch (msg->obj_type) {
649 case BCMOLT_OBJ_ID_ONU:
650 switch (msg->subgroup) {
651 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
652 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530653 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000654 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400655
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000656 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",
657 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400658
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000659 dowi_ind->set_intf_id(key->pon_ni);
660 dowi_ind->set_onu_id(key->onu_id);
661 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
662 dowi_ind->set_drift(data->drift_value);
663 dowi_ind->set_new_eqd(data->new_eqd);
664 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400665
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000666 ind.set_allocated_alarm_ind(alarm_ind);
667 }
668 }
669 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400670
671 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000672 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400673}
674
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000675static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400676 openolt::Indication ind;
677 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
678 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
679
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000680 switch (msg->obj_type) {
681 case BCMOLT_OBJ_ID_ONU:
682 switch (msg->subgroup) {
683 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
684 {
685 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
686 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400687
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000688 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
689 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400690
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000691 looci_ind->set_intf_id(key->pon_ni);
692 looci_ind->set_onu_id(key->onu_id);
693 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
694 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400695
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000696 ind.set_allocated_alarm_ind(alarm_ind);
697 }
698 }
699 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400700
701 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000702 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400703}
704
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000705static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706 openolt::Indication ind;
707 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
708 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
709
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000710 switch (msg->obj_type) {
711 case BCMOLT_OBJ_ID_ONU:
712 switch (msg->subgroup) {
713 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
714 {
715 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
716 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400717
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000718 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
719 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400720
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000721 sfi_ind->set_intf_id(key->pon_ni);
722 sfi_ind->set_onu_id(key->onu_id);
723 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
724 sfi_ind->set_inverse_bit_error_rate(data->ber);
725 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400726
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000727 ind.set_allocated_alarm_ind(alarm_ind);
728 }
729 }
730 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400731
732 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000733 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400734}
735
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000736static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400737 openolt::Indication ind;
738 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
739 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
740
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000741 switch (msg->obj_type) {
742 case BCMOLT_OBJ_ID_ONU:
743 switch (msg->subgroup) {
744 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
745 {
746 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
747 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400748
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000749 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
750 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400751
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000752 tiwi_ind->set_intf_id(key->pon_ni);
753 tiwi_ind->set_onu_id(key->onu_id);
754 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
755 tiwi_ind->set_drift(data->drift_value);
756 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400757
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000758 ind.set_allocated_alarm_ind(alarm_ind);
759 }
760 }
761 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400762
763 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000764 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400765}
766
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530767static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400768 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530769 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
770
771 switch (msg->obj_type) {
772 case BCMOLT_OBJ_ID_ONU:
773 switch (msg->subgroup) {
774 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
775 {
776 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
777 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
778
779 onu_ind->set_intf_id(key->pon_ni);
780 onu_ind->set_onu_id(key->onu_id);
781 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
782 onu_ind->set_oper_state("up");
783 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
784 onu_ind->set_oper_state("down");
785 // Setting the admin_state state field based on a valid onu_id does not make any sense.
786 // The adapter too does not seem to interpret this seriously.
787 // Legacy code, lets keep this as is for now.
788 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
789 ind.set_allocated_onu_ind(onu_ind);
790 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
791 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
792 (key->onu_id)?"up":"down");
793 }
794 }
795 }
796
797 oltIndQ.push(ind);
798 bcmolt_msg_free(msg);
799}
800
Jason Huang93430532020-02-04 17:16:02 +0800801static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
802 openolt::Indication ind;
803 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
804 openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication;
805
806 switch (msg->obj_type) {
807 case BCMOLT_OBJ_ID_ONU:
808 switch (msg->subgroup) {
809 case BCMOLT_ONU_AUTO_SUBGROUP_LOKI:
810 {
811 bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key;
812 bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data;
813
814 OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n",
815 key->pon_ni, key->onu_id, data->alarm_status);
816
817 loss_of_sync_fail_ind->set_intf_id(key->pon_ni);
818 loss_of_sync_fail_ind->set_onu_id(key->onu_id);
819 loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status));
820 alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind);
821
822 ind.set_allocated_alarm_ind(alarm_ind);
823 }
824 }
825 }
826
827 oltIndQ.push(ind);
828 bcmolt_msg_free(msg);
829}
830
831static void OnuItuPonStatsIndication(bcmolt_devid olt, bcmolt_msg *msg) {
832 openolt::Indication ind;
833 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
834 openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication;
835
836 switch (msg->obj_type) {
837 case BCMOLT_OBJ_ID_ONU:
838 switch (msg->subgroup) {
839 case BCMOLT_ONU_STAT_SUBGROUP_ITU_PON_STATS:
840 {
841 bcmolt_onu_key *key = &((bcmolt_onu_itu_pon_stats*)msg)->key;
842 bcmolt_onu_itu_pon_stats_data *data = &((bcmolt_onu_itu_pon_stats*)msg)->data;
843
844 OPENOLT_LOG(INFO, openolt_log_id, "Got onu rdi erros, intf_id %d, onu_id %d, rdi_errors %"PRIu64"\n",
845 key->pon_ni, key->onu_id, data->rdi_errors);
846
847 onu_itu_pon_stats_ind->set_intf_id(key->pon_ni);
848 onu_itu_pon_stats_ind->set_onu_id(key->onu_id);
849 onu_itu_pon_stats_ind->set_rdi_errors(data->rdi_errors);
850 alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind);
851
852 ind.set_allocated_alarm_ind(alarm_ind);
853 }
854 }
855 }
856
857 oltIndQ.push(ind);
858 bcmolt_msg_free(msg);
859}
860
861
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530862
863static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
864 openolt::Indication ind;
865
866 openolt::Indication onu_ind;
867 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400868
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000869 switch (msg->obj_type) {
870 case BCMOLT_OBJ_ID_ONU:
871 switch (msg->subgroup) {
872 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
873 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530874 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
875 bcmolt_onu_onu_deactivation_completed_data *data =
876 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400877
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530878 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
879 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400880
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530881 onu_ind_data->set_intf_id(key->pon_ni);
882 onu_ind_data->set_onu_id(key->onu_id);
883 onu_ind_data->set_oper_state("down");
884 onu_ind_data->set_admin_state("down");
885 onu_ind.set_allocated_onu_ind(onu_ind_data);
Girish Gowdra7a79dae2020-02-10 18:22:11 +0530886
887 onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id);
888 onu_deactivate_complete_result res;
889 res.pon_intf_id = (uint32_t)key->pon_ni;
890 res.onu_id = (uint32_t) key->onu_id;
891 res.result = data->status;
892 res.reason = data->fail_reason;
893
894 OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n",
895 key->pon_ni, key->onu_id, data->status, data->fail_reason);
896
897 bcmos_fastlock_lock(&onu_deactivate_wait_lock);
898 // Push the result from BAL to queue
899 std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key);
900 if (it == onu_deact_compltd_map.end()) {
901 // 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 -0800902 // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where
903 // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application.
904 // The application has to take care handling spurious indications.
Thiyagarajan Subramaniad463232020-02-28 19:10:43 +0530905 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 +0530906 key->pon_ni, key->onu_id);
Girish Gowdra7a79dae2020-02-10 18:22:11 +0530907 }
Girish Gowdra6675fa02020-03-03 20:27:50 -0800908 else if (it->second) {
Girish Gowdra7a79dae2020-02-10 18:22:11 +0530909 // Push the result
910 it->second->push(res);
911 }
912 bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000913 }
914 }
915 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400916
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530917 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000918 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400919}
920
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000921/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400922bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
923 openolt::Indication ind;
924 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
925 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
926
927 bcmbal_subscriber_terminal_key *key =
928 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
929
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000930 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400931 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400932
933
934 onu_proc_error_ind->set_intf_id(key->intf_id);
935 onu_proc_error_ind->set_onu_id(key->sub_term_id);
936
937 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
938 ind.set_allocated_alarm_ind(alarm_ind);
939
940 oltIndQ.push(ind);
941 return BCM_ERR_OK;
942}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000943*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400944
Burak Gurdagc78b9e12019-11-29 11:14:51 +0000945static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
946
947 switch (msg->obj_type) {
948 case BCMOLT_OBJ_ID_GROUP:
949 switch (msg->subgroup) {
950 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
951 {
952 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
953 bcmolt_group_complete_members_update_data *data =
954 &((bcmolt_group_complete_members_update*)msg)->data;
955
956 if (data->result == BCMOLT_RESULT_SUCCESS) {
957 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
958 } else {
959 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
960 }
961 }
962 }
963 }
964 bcmolt_msg_free(msg);
965}
966
Shad Ansari01b0e652018-04-05 21:02:53 +0000967Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000968 bcmolt_rx_cfg rx_cfg = {};
969 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000970
971 if (subscribed) {
972 return Status::OK;
973 }
974
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000975 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
976 rx_cfg.rx_cb = OltOperIndication;
977 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
978 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
979 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
980 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530981 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000982 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000983
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000984 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
985 rx_cfg.rx_cb = OltOperIndication;
986 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
987 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
988 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
989 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530990 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000991 "Olt disconnection complete state indication subscribe failed");
992
993 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
994 rx_cfg.rx_cb = OltOperIndication;
995 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
996 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
997 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
998 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530999 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001000 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001001
1002 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001003 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1004 rx_cfg.rx_cb = LosIndication;
1005 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1006 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
1007 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1008 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001009 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001010
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001011 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1012 rx_cfg.rx_cb = IfOperIndication;
1013 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1014 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
1015 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1016 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301017 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001018 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001019
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001020 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
1021 rx_cfg.rx_cb = IfOperIndication;
1022 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1023 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
1024 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1025 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301026 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001027 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001028
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001029 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1030 rx_cfg.rx_cb = OnuAlarmIndication;
1031 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1032 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
1033 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1034 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001035 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001036
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001037 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1038 rx_cfg.rx_cb = OnuAlarmIndication;
1039 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1040 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
1041 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1042 if(rc != BCM_ERR_OK)
1043 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
1044
1045 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1046 rx_cfg.rx_cb = OnuDyingGaspIndication;
1047 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1048 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
1049 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1050 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001051 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001052
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001053 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
1054 rx_cfg.rx_cb = OnuDiscoveryIndication;
1055 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1056 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
1057 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1058 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +00001059 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001060
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001061 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001062 rx_cfg.rx_cb = OnuStartupFailureIndication;
1063 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1064 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
1065 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1066 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301067 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001068 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +00001069
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001070 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1071 rx_cfg.rx_cb = OnuSignalDegradeIndication;
1072 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1073 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
1074 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1075 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001076 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001077
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001078 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1079 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
1080 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1081 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
1082 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1083 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001084 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001085
1086 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001087 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1088 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
1089 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1090 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
1091 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1092 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001093 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001094
1095 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001096 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1097 rx_cfg.rx_cb = OnuSignalsFailureIndication;
1098 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1099 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1100 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1101 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001102 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001103
1104 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001105 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1106 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1107 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1108 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1109 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1110 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001111 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001112
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301113 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001114 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301115 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1116 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1117 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1118 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1119 if(rc != BCM_ERR_OK)
1120 return Status(grpc::StatusCode::INTERNAL,
1121 "onu activation completed indication subscribe failed");
1122
1123 /* ONU Deactivation Completed Indication */
1124 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1125 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001126 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1127 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1128 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1129 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301130 return Status(grpc::StatusCode::INTERNAL,
1131 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001132
Jason Huang93430532020-02-04 17:16:02 +08001133 /* ONU Loss of Key Sync Indiction */
1134 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1135 rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication;
1136 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1137 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki;
1138 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1139 if(rc != BCM_ERR_OK)
1140 return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed");
1141
1142 /* ONU ITU-PON Stats Indiction */
1143 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1144 rx_cfg.rx_cb = OnuItuPonStatsIndication;
1145 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1146 rx_cfg.subgroup = bcmolt_onu_stat_subgroup_itu_pon_stats;
1147 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1148 if(rc != BCM_ERR_OK)
1149 return Status(grpc::StatusCode::INTERNAL, "onu itu-pon stats indication subscribe failed");
1150
Jason Huang09b73ea2020-01-08 17:52:05 +08001151 /* Packet-In by Access_Control */
1152 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001153 rx_cfg.rx_cb = PacketIndication;
1154 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001155 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001156 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1157 if(rc != BCM_ERR_OK)
1158 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001159
Girish Gowdra96461052019-11-22 20:13:59 +05301160 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1161 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1162 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1163 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1164 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1165 if(rc != BCM_ERR_OK)
Jason Huang93430532020-02-04 17:16:02 +08001166 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed");
Girish Gowdra96461052019-11-22 20:13:59 +05301167
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001168 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1169 rx_cfg.rx_cb = GroupIndication;
1170 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1171 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1172 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1173 if(rc != BCM_ERR_OK)
1174 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1175
Shad Ansari01b0e652018-04-05 21:02:53 +00001176 subscribed = true;
1177
1178 return Status::OK;
1179}