blob: b4eeb581b9b7a9830bae34135815651b67e57d07 [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);
236 ind.set_allocated_intf_ind(intf_ind);
237 break;
238 }
239 }
240 break;
241 case BCMOLT_OBJ_ID_NNI_INTERFACE:
242 switch (msg->subgroup) {
243 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
244 {
245 OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
246 ((bcmolt_nni_interface_state_change *)msg)->key.id);
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530247 bcmolt_nni_interface_key *key =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000248 &((bcmolt_nni_interface_state_change *)msg)->key;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530249 bcmolt_nni_interface_state_change_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000250 &((bcmolt_nni_interface_state_change *)msg)->data;
251
252 intf_ind->set_intf_id(key->id);
253 SET_OPER_STATE(intf_ind, data->new_state);
254 ind.set_allocated_intf_ind(intf_ind);
255 break;
256 }
257 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700258 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700259
260 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000261 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700262}
263
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000264static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000265 openolt::Indication ind;
266 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000267
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000268 switch (msg->obj_type) {
269 case BCMOLT_OBJ_ID_PON_INTERFACE:
270 switch (msg->subgroup) {
271 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
272 {
273 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
274 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
275 intf_oper_ind->set_intf_id(key->pon_ni);
276 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
277 SET_OPER_STATE(intf_oper_ind, data->new_state);
278 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
279 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
280 ind.set_allocated_intf_oper_ind(intf_oper_ind);
281 break;
282 }
283 }
284 case BCMOLT_OBJ_ID_NNI_INTERFACE:
285 switch (msg->subgroup) {
286 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
287 {
288 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
289 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
290 bcmolt_interface intf_id = key->id;
291 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
292 intf_oper_ind->set_intf_id(key->id);
293 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530294 SET_OPER_STATE(intf_oper_ind, data->new_state);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000295 OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
296 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
297 ind.set_allocated_intf_oper_ind(intf_oper_ind);
298 break;
299 }
300 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000301 }
302
Shad Ansari01b0e652018-04-05 21:02:53 +0000303 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000304 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000305}
306
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000307static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000308 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400309 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
310 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
311
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000312 switch (msg->obj_type) {
313 case BCMOLT_OBJ_ID_ONU:
314 switch (msg->subgroup) {
315 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
316 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530317 bcmolt_xgpon_onu_alarms *onu_alarms =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000318 &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
319 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
320 onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
321 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
322 onu_alarms->lopci_miss));
323 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
324 onu_alarms->lopci_mic_error));
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400325
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000326 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
327 ind.set_allocated_alarm_ind(alarm_ind);
328 break;
329 }
330 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
331 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530332 bcmolt_gpon_onu_alarms *onu_alarms =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000333 &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
334 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530335 /* TODO: need to set lofi and loami
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000336 onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
337 onu_alarm_ind->set_loami_status(alarm_status_to_string(
338 onu_alarms->loami));
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530339 */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000340 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
341 ind.set_allocated_alarm_ind(alarm_ind);
342 break;
343 }
344 }
345 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400346
347 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000348 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000349}
350
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000351static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000352 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400353 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000354 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400355
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000356 switch (msg->obj_type) {
357 case BCMOLT_OBJ_ID_ONU:
358 switch (msg->subgroup) {
359 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
360 {
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500361 bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg;
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500362 bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key;
363
Chaitrashree G Sd8feddd2020-01-20 21:42:40 -0500364 dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status));
Chaitrashree G S7bc19ce2020-01-28 18:27:42 -0500365 dgi_ind->set_intf_id(key->pon_ni);
366 dgi_ind->set_onu_id(key->onu_id);
nickc063ffd2018-05-22 14:35:28 -0400367
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000368 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
369 ind.set_allocated_alarm_ind(alarm_ind);
370 break;
371 }
372 }
373 }
nickc063ffd2018-05-22 14:35:28 -0400374
375 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000376 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000377}
378
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000379static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000380 openolt::Indication ind;
381 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
382 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
383
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000384 switch (msg->obj_type) {
385 case BCMOLT_OBJ_ID_PON_INTERFACE:
386 switch (msg->subgroup) {
387 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
388 {
389 bcmolt_pon_interface_key *key =
390 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000391
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530392 bcmolt_pon_interface_onu_discovered_data *data =
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000393 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000394
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000395 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000396
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000397 OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
398 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000399
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000400 onu_disc_ind->set_intf_id(key->pon_ni);
401 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
402 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
403 onu_disc_ind->set_allocated_serial_number(serial_number);
404 ind.set_allocated_onu_disc_ind(onu_disc_ind);
405 break;
406 }
407 }
408 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000409
410 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000411 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000412}
413
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000414static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000415 openolt::Indication ind;
416 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000417
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000418 switch (msg->obj_type) {
419 case BCMOLT_OBJ_ID_ONU:
420 switch (msg->subgroup) {
421 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
422 {
423 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
424 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000425
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530426 OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000427 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000428
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000429 omci_ind->set_intf_id(key->pon_ni);
430 omci_ind->set_onu_id(key->onu_id);
431 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
432
433 ind.set_allocated_omci_ind(omci_ind);
434 break;
435 }
436 }
437 }
438
Shad Ansari01b0e652018-04-05 21:02:53 +0000439 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000440 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000441}
442
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000443static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000444 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000445 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000446
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000447 switch (msg->obj_type) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800448 case BCMOLT_OBJ_ID_ACCESS_CONTROL:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000449 switch (msg->subgroup) {
Jason Huang09b73ea2020-01-08 17:52:05 +0800450 case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000451 {
Jason Huang09b73ea2020-01-08 17:52:05 +0800452 bcmolt_access_control_receive_eth_packet *pkt =
453 (bcmolt_access_control_receive_eth_packet*)msg;
454 bcmolt_access_control_receive_eth_packet_data *pkt_data =
455 &((bcmolt_access_control_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000456
Jason Huang09b73ea2020-01-08 17:52:05 +0800457 pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type(
458 (bcmolt_interface_type)pkt_data->interface_ref.intf_type));
459 pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000460 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
Jason Huang09b73ea2020-01-08 17:52:05 +0800461 //pkt_ind->set_gemport_id(getPacketInGemPort(pkt->key.id));
462 pkt_ind->set_gemport_id(pkt_data->svc_port_id);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000463 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500464
Jason Huang09b73ea2020-01-08 17:52:05 +0800465 if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) {
466 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d\n",
467 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_data->svc_port_id);
468 } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) {
469 OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n",
470 pkt_ind->intf_type().c_str(), pkt_ind->intf_id());
471 }
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000472 }
473 }
474 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500475
Shad Ansari5fe93682018-04-26 05:24:19 +0000476 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000477 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000478}
479
Girish Gowdra96461052019-11-22 20:13:59 +0530480static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) {
481
482 switch (msg->obj_type) {
483 case BCMOLT_OBJ_ID_ITUPON_ALLOC:
484 switch (msg->subgroup) {
485 case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED:
486 {
487 bcmolt_itupon_alloc_configuration_completed *pkt =
488 (bcmolt_itupon_alloc_configuration_completed*)msg;
489 bcmolt_itupon_alloc_configuration_completed_data *pkt_data =
490 &((bcmolt_itupon_alloc_configuration_completed*)msg)->data;
491
492 alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id);
493 alloc_cfg_complete_result res;
494 res.pon_intf_id = pkt->key.pon_ni;
495 res.alloc_id = pkt->key.alloc_id;
496
497 pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL;
498 switch (pkt_data->new_state) {
499 case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED:
500 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
501 break;
502 case BCMOLT_ACTIVATION_STATE_INACTIVE:
503 res.state = ALLOC_OBJECT_STATE_INACTIVE;
504 break;
505 case BCMOLT_ACTIVATION_STATE_PROCESSING:
506 res.state = ALLOC_OBJECT_STATE_PROCESSING;
507 break;
508 case BCMOLT_ACTIVATION_STATE_ACTIVE:
509 res.state = ALLOC_OBJECT_STATE_ACTIVE;
510 break;
511 default:
512 OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n",
513 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state);
514 res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED;
515 }
516 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",
517 pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state);
518
519 bcmos_fastlock_lock(&alloc_cfg_wait_lock);
520 // Push the result from BAL to queue
521 std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key);
522 if (it == alloc_cfg_compltd_map.end()) {
523 // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key.
524 bcmolt_msg_free(msg);
525 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);
526 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
527 return;
528 }
529 if (it->second) {
530 // Push the result
531 it->second->push(res);
532 }
533 bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0);
534 }
535 }
536 }
537
538 bcmolt_msg_free(msg);
539}
540
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000541static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000542 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000543 OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
544 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000545}
546
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000547static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000548 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000549 OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n");
550 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000551}
552
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000553static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000554 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000555 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
556 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000557}
558
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000559static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000560 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000561 OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
562 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000563}
564
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000565static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000566 openolt::Indication ind;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000567 OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
568 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000569}
570
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000571static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400572 openolt::Indication ind;
573 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
574 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
575
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000576 switch (msg->obj_type) {
577 case BCMOLT_OBJ_ID_ONU:
578 switch (msg->subgroup) {
579 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
580 {
581 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
582 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400583
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000584 OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
585 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400586
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000587 sufi_ind->set_intf_id(key->pon_ni);
588 sufi_ind->set_onu_id(key->onu_id);
589 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
590 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400591
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000592 ind.set_allocated_alarm_ind(alarm_ind);
593 }
594 }
595 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400596
597 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000598 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400599}
600
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000601static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400602 openolt::Indication ind;
603 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
604 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
605
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000606 switch (msg->obj_type) {
607 case BCMOLT_OBJ_ID_ONU:
608 switch (msg->subgroup) {
609 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
610 {
611 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
612 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400613
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000614 OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
615 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400616
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000617 sdi_ind->set_intf_id(key->pon_ni);
618 sdi_ind->set_onu_id(key->onu_id);
619 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
620 sdi_ind->set_inverse_bit_error_rate(data->ber);
621 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400622
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000623 ind.set_allocated_alarm_ind(alarm_ind);
624 }
625 }
626 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400627
628 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000629 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400630}
631
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000632static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400633 openolt::Indication ind;
634 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
635 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
636
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000637 switch (msg->obj_type) {
638 case BCMOLT_OBJ_ID_ONU:
639 switch (msg->subgroup) {
640 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
641 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530642 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000643 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000645 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",
646 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400647
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000648 dowi_ind->set_intf_id(key->pon_ni);
649 dowi_ind->set_onu_id(key->onu_id);
650 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
651 dowi_ind->set_drift(data->drift_value);
652 dowi_ind->set_new_eqd(data->new_eqd);
653 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400654
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000655 ind.set_allocated_alarm_ind(alarm_ind);
656 }
657 }
658 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400659
660 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000661 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400662}
663
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000664static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400665 openolt::Indication ind;
666 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
667 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
668
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000669 switch (msg->obj_type) {
670 case BCMOLT_OBJ_ID_ONU:
671 switch (msg->subgroup) {
672 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
673 {
674 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
675 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400676
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000677 OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
678 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400679
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000680 looci_ind->set_intf_id(key->pon_ni);
681 looci_ind->set_onu_id(key->onu_id);
682 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
683 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400684
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000685 ind.set_allocated_alarm_ind(alarm_ind);
686 }
687 }
688 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400689
690 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000691 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400692}
693
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000694static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400695 openolt::Indication ind;
696 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
697 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
698
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000699 switch (msg->obj_type) {
700 case BCMOLT_OBJ_ID_ONU:
701 switch (msg->subgroup) {
702 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
703 {
704 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
705 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000707 OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
708 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400709
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000710 sfi_ind->set_intf_id(key->pon_ni);
711 sfi_ind->set_onu_id(key->onu_id);
712 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
713 sfi_ind->set_inverse_bit_error_rate(data->ber);
714 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400715
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000716 ind.set_allocated_alarm_ind(alarm_ind);
717 }
718 }
719 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400720
721 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000722 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400723}
724
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000725static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400726 openolt::Indication ind;
727 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
728 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
729
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000730 switch (msg->obj_type) {
731 case BCMOLT_OBJ_ID_ONU:
732 switch (msg->subgroup) {
733 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
734 {
735 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
736 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400737
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000738 OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
739 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400740
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000741 tiwi_ind->set_intf_id(key->pon_ni);
742 tiwi_ind->set_onu_id(key->onu_id);
743 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
744 tiwi_ind->set_drift(data->drift_value);
745 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400746
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000747 ind.set_allocated_alarm_ind(alarm_ind);
748 }
749 }
750 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400751
752 oltIndQ.push(ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000753 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400754}
755
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530756static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400757 openolt::Indication ind;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530758 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
759
760 switch (msg->obj_type) {
761 case BCMOLT_OBJ_ID_ONU:
762 switch (msg->subgroup) {
763 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
764 {
765 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
766 bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data;
767
768 onu_ind->set_intf_id(key->pon_ni);
769 onu_ind->set_onu_id(key->onu_id);
770 if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status))
771 onu_ind->set_oper_state("up");
772 if (ONU_ACTIVATION_COMPLETED_FAIL(data->status))
773 onu_ind->set_oper_state("down");
774 // Setting the admin_state state field based on a valid onu_id does not make any sense.
775 // The adapter too does not seem to interpret this seriously.
776 // Legacy code, lets keep this as is for now.
777 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
778 ind.set_allocated_onu_ind(onu_ind);
779 OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
780 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
781 (key->onu_id)?"up":"down");
782 }
783 }
784 }
785
786 oltIndQ.push(ind);
787 bcmolt_msg_free(msg);
788}
789
790
791static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
792 openolt::Indication ind;
793
794 openolt::Indication onu_ind;
795 openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400796
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000797 switch (msg->obj_type) {
798 case BCMOLT_OBJ_ID_ONU:
799 switch (msg->subgroup) {
800 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
801 {
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530802 bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key;
803 bcmolt_onu_onu_deactivation_completed_data *data =
804 &((bcmolt_onu_onu_deactivation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400805
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530806 OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n",
807 key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str());
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400808
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530809 onu_ind_data->set_intf_id(key->pon_ni);
810 onu_ind_data->set_onu_id(key->onu_id);
811 onu_ind_data->set_oper_state("down");
812 onu_ind_data->set_admin_state("down");
813 onu_ind.set_allocated_onu_ind(onu_ind_data);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000814 }
815 }
816 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400817
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530818 oltIndQ.push(onu_ind);
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000819 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400820}
821
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000822/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400823bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
824 openolt::Indication ind;
825 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
826 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
827
828 bcmbal_subscriber_terminal_key *key =
829 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
830
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000831 OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400832 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400833
834
835 onu_proc_error_ind->set_intf_id(key->intf_id);
836 onu_proc_error_ind->set_onu_id(key->sub_term_id);
837
838 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
839 ind.set_allocated_alarm_ind(alarm_ind);
840
841 oltIndQ.push(ind);
842 return BCM_ERR_OK;
843}
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000844*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400845
Burak Gurdagc78b9e12019-11-29 11:14:51 +0000846static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
847
848 switch (msg->obj_type) {
849 case BCMOLT_OBJ_ID_GROUP:
850 switch (msg->subgroup) {
851 case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE:
852 {
853 bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key;
854 bcmolt_group_complete_members_update_data *data =
855 &((bcmolt_group_complete_members_update*)msg)->data;
856
857 if (data->result == BCMOLT_RESULT_SUCCESS) {
858 OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id);
859 } else {
860 OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason);
861 }
862 }
863 }
864 }
865 bcmolt_msg_free(msg);
866}
867
Shad Ansari01b0e652018-04-05 21:02:53 +0000868Status SubscribeIndication() {
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000869 bcmolt_rx_cfg rx_cfg = {};
870 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000871
872 if (subscribed) {
873 return Status::OK;
874 }
875
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000876 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
877 rx_cfg.rx_cb = OltOperIndication;
878 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
879 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
880 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
881 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530882 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000883 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000884
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000885 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
886 rx_cfg.rx_cb = OltOperIndication;
887 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
888 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
889 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
890 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530891 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000892 "Olt disconnection complete state indication subscribe failed");
893
894 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
895 rx_cfg.rx_cb = OltOperIndication;
896 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
897 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
898 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
899 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530900 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000901 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000902
903 /* Interface LOS indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000904 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
905 rx_cfg.rx_cb = LosIndication;
906 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
907 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
908 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
909 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000910 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000911
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000912 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
913 rx_cfg.rx_cb = IfOperIndication;
914 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
915 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
916 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
917 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530918 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000919 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700920
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000921 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
922 rx_cfg.rx_cb = IfOperIndication;
923 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
924 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
925 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
926 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530927 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000928 "NNI Interface operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000929
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000930 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
931 rx_cfg.rx_cb = OnuAlarmIndication;
932 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
933 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
934 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
935 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000936 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000937
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000938 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
939 rx_cfg.rx_cb = OnuAlarmIndication;
940 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
941 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
942 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
943 if(rc != BCM_ERR_OK)
944 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
945
946 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
947 rx_cfg.rx_cb = OnuDyingGaspIndication;
948 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
949 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
950 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
951 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000952 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000953
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000954 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
955 rx_cfg.rx_cb = OnuDiscoveryIndication;
956 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
957 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
958 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
959 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000960 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000961
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000962 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000963 rx_cfg.rx_cb = OnuStartupFailureIndication;
964 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
965 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
966 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
967 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +0530968 return Status(grpc::StatusCode::INTERNAL,
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000969 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000970
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000971 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
972 rx_cfg.rx_cb = OnuSignalDegradeIndication;
973 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
974 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
975 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
976 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400977 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400978
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000979 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
980 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
981 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
982 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
983 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
984 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400985 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400986
987 /* LOOCI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000988 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
989 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
990 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
991 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
992 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
993 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400994 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400995
996 /* SFI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000997 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
998 rx_cfg.rx_cb = OnuSignalsFailureIndication;
999 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1000 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
1001 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1002 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001003 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001004
1005 /* TIWI indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001006 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1007 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
1008 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1009 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
1010 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1011 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001012 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001013
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301014 /* ONU Activation Completed Indication */
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001015 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301016 rx_cfg.rx_cb = OnuActivationCompletedIndication;
1017 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1018 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
1019 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1020 if(rc != BCM_ERR_OK)
1021 return Status(grpc::StatusCode::INTERNAL,
1022 "onu activation completed indication subscribe failed");
1023
1024 /* ONU Deactivation Completed Indication */
1025 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
1026 rx_cfg.rx_cb = OnuDeactivationCompletedIndication;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001027 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1028 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
1029 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1030 if(rc != BCM_ERR_OK)
Girish Gowdra0c0b5c02019-12-16 14:11:08 +05301031 return Status(grpc::StatusCode::INTERNAL,
1032 "onu deactivation indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001033
Jason Huang09b73ea2020-01-08 17:52:05 +08001034 /* Packet-In by Access_Control */
1035 rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001036 rx_cfg.rx_cb = PacketIndication;
1037 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huang09b73ea2020-01-08 17:52:05 +08001038 rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet;
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +00001039 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1040 if(rc != BCM_ERR_OK)
1041 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -04001042
Girish Gowdra96461052019-11-22 20:13:59 +05301043 rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC;
1044 rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd;
1045 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1046 rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed;
1047 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1048 if(rc != BCM_ERR_OK)
1049 return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration \
1050Complete Indication subscribe failed");
1051
Burak Gurdagc78b9e12019-11-29 11:14:51 +00001052 rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP;
1053 rx_cfg.rx_cb = GroupIndication;
1054 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
1055 rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update;
1056 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
1057 if(rc != BCM_ERR_OK)
1058 return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed");
1059
Shad Ansari01b0e652018-04-05 21:02:53 +00001060 subscribed = true;
1061
1062 return Status::OK;
1063}