blob: eb7570f878eee75e29e3a8563e27e56dd19d7b82 [file] [log] [blame]
Shad Ansari01b0e652018-04-05 21:02:53 +00001/*
2 Copyright (C) 2018 Open Networking Foundation
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "indications.h"
Shad Ansarib7b0ced2018-05-11 21:53:32 +000018#include "core.h"
Shad Ansari01b0e652018-04-05 21:02:53 +000019#include "utils.h"
Nicolas Palpacuer0f19b1a2018-06-07 17:29:31 -040020#include "stats_collection.h"
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040021#include "translation.h"
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040022#include "state.h"
23
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -040024#include <string>
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040025
Shad Ansari01b0e652018-04-05 21:02:53 +000026extern "C"
27{
28#include <bcmos_system.h>
Jason Huangd33b4d82019-05-15 18:22:57 +080029#include <bcmolt_api.h>
30#include <bcmolt_host_api.h>
31#include <bcmolt_api_model_api_structs.h>
Shad Ansari01b0e652018-04-05 21:02:53 +000032}
33
34using grpc::Status;
35
Shad Ansari627b5782018-08-13 22:49:32 +000036extern Queue<openolt::Indication> oltIndQ;
Shad Ansari01b0e652018-04-05 21:02:53 +000037//Queue<openolt::Indication*> oltIndQ;
38
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040039
Shad Ansari01b0e652018-04-05 21:02:53 +000040bool subscribed = false;
Girish Gowdruc8ed2ef2019-02-13 08:18:44 -080041uint32_t nni_intf_id = 0;
Jason Huangd33b4d82019-05-15 18:22:57 +080042#define current_device 0
Shad Ansari01b0e652018-04-05 21:02:53 +000043
Jason Huangd33b4d82019-05-15 18:22:57 +080044static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg);
Shad Ansari01b0e652018-04-05 21:02:53 +000045
Jason Huangd33b4d82019-05-15 18:22:57 +080046#define INTERFACE_STATE_IF_DOWN(state) \
47 ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \
48 state == BCMOLT_INTERFACE_STATE_PROCESSING || \
49 state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
50#define INTERFACE_STATE_IF_UP(state) \
51 ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE)
52#define ONU_STATE_IF_DOWN(state) \
53 ((state == BCMOLT_ONU_OPERATION_INACTIVE || \
54 state == BCMOLT_ONU_OPERATION_DISABLE || \
55 state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE)
56#define ONU_STATE_IF_UP(state) \
57 ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE)
Jason Huangb1fad572019-05-28 19:02:30 +080058#define ONU_RANGING_STATE_IF_UP(state) \
59 ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
60#define ONU_RANGING_STATE_IF_DOWN(state) \
61 ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE)
Jason Huang88795222019-06-13 19:28:44 +080062#define SET_OPER_STATE(indication,state) \
63 (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \
64 indication->set_oper_state("down")
Jason Huangd33b4d82019-05-15 18:22:57 +080065
66std::string bcmbal_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050067{
Jason Huangd33b4d82019-05-15 18:22:57 +080068 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050069 return "nni";
Jason Huangd33b4d82019-05-15 18:22:57 +080070 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050071 return "pon";
72 }
73 return "unknown";
74}
75
Jason Huangd33b4d82019-05-15 18:22:57 +080076static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +000077 openolt::Indication ind;
78 openolt::OltIndication* olt_ind = new openolt::OltIndication;
79 Status status;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050080 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050081
Jason Huangd33b4d82019-05-15 18:22:57 +080082 switch (msg->subgroup) {
83 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
Jason Huangd33b4d82019-05-15 18:22:57 +080084 admin_state = "up";
85 olt_ind->set_oper_state("up");
86 break;
87 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
88 admin_state = "down";
89 olt_ind->set_oper_state("down");
90 break;
91 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
92 admin_state = "failure";
93 olt_ind->set_oper_state("failure");
94 break;
Shad Ansari01b0e652018-04-05 21:02:53 +000095 }
96 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050097
Jason Huangd33b4d82019-05-15 18:22:57 +080098 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
Jason Huangd33b4d82019-05-15 18:22:57 +080099 /* register for omci indication */
100 {
101 bcmolt_rx_cfg rx_cfg = {};
102 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
103 rx_cfg.rx_cb = OmciIndication;
104 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
105 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
106 bcmolt_ind_subscribe(current_device, &rx_cfg);
107 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500108 state.activate();
109 }
110 else {
111 state.deactivate();
112 }
113
Jason Huangd33b4d82019-05-15 18:22:57 +0800114 oltIndQ.push(ind);
115 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000116}
117
Jason Huangd33b4d82019-05-15 18:22:57 +0800118static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000119 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400120 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
121 openolt::LosIndication* los_ind = new openolt::LosIndication;
122
Jason Huangd33b4d82019-05-15 18:22:57 +0800123 switch (msg->obj_type) {
124 case BCMOLT_OBJ_ID_PON_INTERFACE:
125 switch (msg->subgroup) {
126 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
127 {
128 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
129 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
130 BCMOLT_INTERFACE_TYPE_PON);
131 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400132
Jason Huangd33b4d82019-05-15 18:22:57 +0800133 BCM_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
134 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400135
Jason Huangd33b4d82019-05-15 18:22:57 +0800136 los_ind->set_intf_id(intf_id);
137 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400138
Jason Huangd33b4d82019-05-15 18:22:57 +0800139 alarm_ind->set_allocated_los_ind(los_ind);
140 ind.set_allocated_alarm_ind(alarm_ind);
141 break;
142 }
143 }
144 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400145
146 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800147 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000148}
149
Jason Huangd33b4d82019-05-15 18:22:57 +0800150static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700151 openolt::Indication ind;
152 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
153
Jason Huangd33b4d82019-05-15 18:22:57 +0800154 switch (msg->obj_type) {
155 case BCMOLT_OBJ_ID_PON_INTERFACE:
156 switch (msg->subgroup) {
157 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
158 {
Jason Huangd33b4d82019-05-15 18:22:57 +0800159 bcmolt_pon_interface_key *key =
160 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
161 bcmolt_pon_interface_state_change_completed_data *data =
162 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700163
Jason Huangd33b4d82019-05-15 18:22:57 +0800164 intf_ind->set_intf_id(key->pon_ni);
Jason Huang88795222019-06-13 19:28:44 +0800165 SET_OPER_STATE(intf_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800166 ind.set_allocated_intf_ind(intf_ind);
167 break;
168 }
169 }
170 break;
171 case BCMOLT_OBJ_ID_NNI_INTERFACE:
172 switch (msg->subgroup) {
173 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
174 {
175 BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
176 ((bcmolt_nni_interface_state_change *)msg)->key.id);
177 bcmolt_nni_interface_key *key =
178 &((bcmolt_nni_interface_state_change *)msg)->key;
179 bcmolt_nni_interface_state_change_data *data =
180 &((bcmolt_nni_interface_state_change *)msg)->data;
181
182 intf_ind->set_intf_id(key->id);
Jason Huang88795222019-06-13 19:28:44 +0800183 SET_OPER_STATE(intf_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800184 ind.set_allocated_intf_ind(intf_ind);
185 break;
186 }
187 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700188 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700189
190 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800191 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700192}
193
Jason Huangd33b4d82019-05-15 18:22:57 +0800194static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000195 openolt::Indication ind;
196 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000197
Jason Huangd33b4d82019-05-15 18:22:57 +0800198 switch (msg->obj_type) {
199 case BCMOLT_OBJ_ID_PON_INTERFACE:
200 switch (msg->subgroup) {
201 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
202 {
203 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
204 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
205 intf_oper_ind->set_intf_id(key->pon_ni);
206 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
Jason Huang88795222019-06-13 19:28:44 +0800207 SET_OPER_STATE(intf_oper_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800208 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
209 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
210 ind.set_allocated_intf_oper_ind(intf_oper_ind);
211 break;
212 }
213 }
214 case BCMOLT_OBJ_ID_NNI_INTERFACE:
215 switch (msg->subgroup) {
216 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
217 {
218 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
219 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
220 bcmolt_interface intf_id = key->id;
221 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
222 intf_oper_ind->set_intf_id(key->id);
223 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Jason Huang88795222019-06-13 19:28:44 +0800224 SET_OPER_STATE(intf_oper_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800225 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
226 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
227 ind.set_allocated_intf_oper_ind(intf_oper_ind);
228 break;
229 }
230 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000231 }
232
Shad Ansari01b0e652018-04-05 21:02:53 +0000233 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800234 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000235}
236
Jason Huangd33b4d82019-05-15 18:22:57 +0800237static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000238 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400239 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
240 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
241
Jason Huangd33b4d82019-05-15 18:22:57 +0800242 switch (msg->obj_type) {
243 case BCMOLT_OBJ_ID_ONU:
244 switch (msg->subgroup) {
245 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
246 {
247 bcmolt_xgpon_onu_alarms *onu_alarms =
248 &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
249 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
250 onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
251 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
252 onu_alarms->lopci_miss));
253 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
254 onu_alarms->lopci_mic_error));
255
256 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
257 ind.set_allocated_alarm_ind(alarm_ind);
258 break;
259 }
260 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
261 {
262 bcmolt_gpon_onu_alarms *onu_alarms =
263 &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
264 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
265 /* TODO: need to set lofi and loami
266 onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
267 onu_alarm_ind->set_loami_status(alarm_status_to_string(
268 onu_alarms->loami));
269 */
270 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
271 ind.set_allocated_alarm_ind(alarm_ind);
272 break;
273 }
274 }
275 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400276
277 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800278 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000279}
280
Jason Huangd33b4d82019-05-15 18:22:57 +0800281static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000282 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400283 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Jason Huangd33b4d82019-05-15 18:22:57 +0800284 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400285
Jason Huangd33b4d82019-05-15 18:22:57 +0800286 switch (msg->obj_type) {
287 case BCMOLT_OBJ_ID_ONU:
288 switch (msg->subgroup) {
289 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
290 {
291 bcmolt_onu_dgi_data* dgi_data = (bcmolt_onu_dgi_data *)msg;
292 dgi_ind->set_status(alarm_status_to_string(dgi_data->alarm_status));
nickc063ffd2018-05-22 14:35:28 -0400293
Jason Huangd33b4d82019-05-15 18:22:57 +0800294 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
295 ind.set_allocated_alarm_ind(alarm_ind);
296 break;
297 }
298 }
299 }
nickc063ffd2018-05-22 14:35:28 -0400300
301 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800302 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000303}
304
Jason Huangd33b4d82019-05-15 18:22:57 +0800305static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000306 openolt::Indication ind;
307 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
308 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
309
Jason Huangd33b4d82019-05-15 18:22:57 +0800310 switch (msg->obj_type) {
311 case BCMOLT_OBJ_ID_PON_INTERFACE:
312 switch (msg->subgroup) {
313 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
314 {
315 bcmolt_pon_interface_key *key =
316 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000317
Jason Huangd33b4d82019-05-15 18:22:57 +0800318 bcmolt_pon_interface_onu_discovered_data *data =
319 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000320
Jason Huangd33b4d82019-05-15 18:22:57 +0800321 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000322
Jason Huangd33b4d82019-05-15 18:22:57 +0800323 BCM_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
324 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000325
Jason Huangd33b4d82019-05-15 18:22:57 +0800326 onu_disc_ind->set_intf_id(key->pon_ni);
327 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
328 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
329 onu_disc_ind->set_allocated_serial_number(serial_number);
330 ind.set_allocated_onu_disc_ind(onu_disc_ind);
331 break;
332 }
333 }
334 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000335
336 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800337 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000338}
339
Jason Huangd33b4d82019-05-15 18:22:57 +0800340static void OnuIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700341 openolt::Indication ind;
342 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
343
Jason Huangd33b4d82019-05-15 18:22:57 +0800344 switch (msg->obj_type) {
345 case BCMOLT_OBJ_ID_ONU:
346 switch (msg->subgroup) {
Jason Huangb1fad572019-05-28 19:02:30 +0800347 case BCMOLT_ONU_AUTO_SUBGROUP_RANGING_COMPLETED:
Jason Huangd33b4d82019-05-15 18:22:57 +0800348 {
Jason Huangb1fad572019-05-28 19:02:30 +0800349 bcmolt_onu_key *key = &((bcmolt_onu_ranging_completed*)msg)->key;
350 bcmolt_onu_ranging_completed_data *data = &((bcmolt_onu_ranging_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700351
Jason Huangd33b4d82019-05-15 18:22:57 +0800352 onu_ind->set_intf_id(key->pon_ni);
353 onu_ind->set_onu_id(key->onu_id);
Jason Huangb1fad572019-05-28 19:02:30 +0800354 if (ONU_RANGING_STATE_IF_UP(data->status))
Jason Huangd33b4d82019-05-15 18:22:57 +0800355 onu_ind->set_oper_state("up");
Jason Huangb1fad572019-05-28 19:02:30 +0800356 if (ONU_RANGING_STATE_IF_DOWN(data->status))
Jason Huangd33b4d82019-05-15 18:22:57 +0800357 onu_ind->set_oper_state("down");
Jason Huang88795222019-06-13 19:28:44 +0800358 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
Jason Huangd33b4d82019-05-15 18:22:57 +0800359 ind.set_allocated_onu_ind(onu_ind);
Jason Huang88795222019-06-13 19:28:44 +0800360 BCM_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
361 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
362 (key->onu_id)?"up":"down");
Jason Huangd33b4d82019-05-15 18:22:57 +0800363 }
364 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700365 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700366
367 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800368 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700369}
370
Jason Huangd33b4d82019-05-15 18:22:57 +0800371static void OnuOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000372 openolt::Indication ind;
nickc063ffd2018-05-22 14:35:28 -0400373 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
nickc063ffd2018-05-22 14:35:28 -0400374
Jason Huangd33b4d82019-05-15 18:22:57 +0800375 switch (msg->obj_type) {
376 case BCMOLT_OBJ_ID_ONU:
377 switch (msg->subgroup) {
378 case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE:
379 {
380 bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key;
381 bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data;
nickc063ffd2018-05-22 14:35:28 -0400382
Jason Huangd33b4d82019-05-15 18:22:57 +0800383 onu_ind->set_intf_id(key->pon_ni);
384 onu_ind->set_onu_id(key->onu_id);
385 if (ONU_STATE_IF_UP(data->new_onu_state))
386 onu_ind->set_oper_state("up");
387 if (ONU_STATE_IF_DOWN(data->new_onu_state))
388 onu_ind->set_oper_state("down");
389 ind.set_allocated_onu_ind(onu_ind);
nickc063ffd2018-05-22 14:35:28 -0400390
Jason Huangd33b4d82019-05-15 18:22:57 +0800391 BCM_LOG(INFO, openolt_log_id, "onu oper state indication, intf_id %d, onu_id %d, old oper state %d, new oper state %s\n",
392 key->pon_ni, key->onu_id, data->new_onu_state, onu_ind->oper_state().c_str());
393 }
394 }
nickc063ffd2018-05-22 14:35:28 -0400395 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500396
nickc063ffd2018-05-22 14:35:28 -0400397 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800398 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000399}
400
Jason Huangd33b4d82019-05-15 18:22:57 +0800401static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000402 openolt::Indication ind;
403 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000404
Jason Huangd33b4d82019-05-15 18:22:57 +0800405 switch (msg->obj_type) {
406 case BCMOLT_OBJ_ID_ONU:
407 switch (msg->subgroup) {
408 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
409 {
410 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
411 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000412
Jason Huangd33b4d82019-05-15 18:22:57 +0800413 BCM_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
414 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000415
Jason Huangd33b4d82019-05-15 18:22:57 +0800416 omci_ind->set_intf_id(key->pon_ni);
417 omci_ind->set_onu_id(key->onu_id);
418 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
419
420 ind.set_allocated_omci_ind(omci_ind);
421 break;
422 }
423 }
424 }
425
Shad Ansari01b0e652018-04-05 21:02:53 +0000426 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800427 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000428}
429
Jason Huangd33b4d82019-05-15 18:22:57 +0800430static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000431 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000432 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000433
Jason Huangd33b4d82019-05-15 18:22:57 +0800434 switch (msg->obj_type) {
435 case BCMOLT_OBJ_ID_ONU:
436 switch (msg->subgroup) {
437 case BCMOLT_FLOW_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
438 {
439 bcmolt_flow_key *key = &((bcmolt_flow_cfg*)msg)->key;
440 bcmolt_flow_cfg_data *data = &((bcmolt_flow_cfg*)msg)->data;
441 bcmolt_flow_receive_eth_packet_data *pkt_data =
442 &((bcmolt_flow_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000443
Jason Huangd33b4d82019-05-15 18:22:57 +0800444 uint32_t port_no = GetPortNum_(key->flow_id);
445 pkt_ind->set_intf_type(bcmbal_to_grpc_intf_type((bcmolt_interface_type)data->ingress_intf.intf_type));
446 pkt_ind->set_intf_id(data->ingress_intf.intf_id);
447 pkt_ind->set_gemport_id(data->svc_port_id);
448 pkt_ind->set_flow_id(key->flow_id);
449 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
450 pkt_ind->set_port_no(port_no);
451 pkt_ind->set_cookie(data->cookie);
452 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500453
Jason Huangd33b4d82019-05-15 18:22:57 +0800454 BCM_LOG(INFO, openolt_log_id, "packet indication, intf_type %s, intf_id %d, svc_port %d, flow_id %d port_no %d cookie %lu\n",
455 pkt_ind->intf_type().c_str(), data->ingress_intf.intf_id, data->svc_port_id, key->flow_id, port_no, data->cookie);
456 }
457 }
458 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500459
Shad Ansari5fe93682018-04-26 05:24:19 +0000460 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800461 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000462}
463
Jason Huangd33b4d82019-05-15 18:22:57 +0800464static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000465 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400466 BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800467 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000468}
469
Jason Huangd33b4d82019-05-15 18:22:57 +0800470static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000471 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400472 BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800473 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000474}
475
Jason Huangd33b4d82019-05-15 18:22:57 +0800476static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000477 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400478 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800479 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000480}
481
Jason Huangd33b4d82019-05-15 18:22:57 +0800482static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000483 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400484 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800485 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000486}
487
Jason Huangd33b4d82019-05-15 18:22:57 +0800488static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000489 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400490 BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800491 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000492}
493
Jason Huangd33b4d82019-05-15 18:22:57 +0800494static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400495 openolt::Indication ind;
496 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
497 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
498
Jason Huangd33b4d82019-05-15 18:22:57 +0800499 switch (msg->obj_type) {
500 case BCMOLT_OBJ_ID_ONU:
501 switch (msg->subgroup) {
502 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
503 {
504 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
505 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400506
Jason Huangd33b4d82019-05-15 18:22:57 +0800507 BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
508 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400509
Jason Huangd33b4d82019-05-15 18:22:57 +0800510 sufi_ind->set_intf_id(key->pon_ni);
511 sufi_ind->set_onu_id(key->onu_id);
512 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
513 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400514
Jason Huangd33b4d82019-05-15 18:22:57 +0800515 ind.set_allocated_alarm_ind(alarm_ind);
516 }
517 }
518 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400519
520 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800521 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400522}
523
Jason Huangd33b4d82019-05-15 18:22:57 +0800524static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400525 openolt::Indication ind;
526 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
527 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
528
Jason Huangd33b4d82019-05-15 18:22:57 +0800529 switch (msg->obj_type) {
530 case BCMOLT_OBJ_ID_ONU:
531 switch (msg->subgroup) {
532 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
533 {
534 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
535 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400536
Jason Huangd33b4d82019-05-15 18:22:57 +0800537 BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
538 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400539
Jason Huangd33b4d82019-05-15 18:22:57 +0800540 sdi_ind->set_intf_id(key->pon_ni);
541 sdi_ind->set_onu_id(key->onu_id);
542 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
543 sdi_ind->set_inverse_bit_error_rate(data->ber);
544 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400545
Jason Huangd33b4d82019-05-15 18:22:57 +0800546 ind.set_allocated_alarm_ind(alarm_ind);
547 }
548 }
549 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400550
551 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800552 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400553}
554
Jason Huangd33b4d82019-05-15 18:22:57 +0800555static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400556 openolt::Indication ind;
557 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
558 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
559
Jason Huangd33b4d82019-05-15 18:22:57 +0800560 switch (msg->obj_type) {
561 case BCMOLT_OBJ_ID_ONU:
562 switch (msg->subgroup) {
563 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
564 {
565 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
566 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400567
Jason Huangd33b4d82019-05-15 18:22:57 +0800568 BCM_LOG(WARNING, openolt_log_id, "onu drift of window indication, intf_id %d, onu_id %d, alarm %d, drift %d, new_eqd %d\n",
569 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400570
Jason Huangd33b4d82019-05-15 18:22:57 +0800571 dowi_ind->set_intf_id(key->pon_ni);
572 dowi_ind->set_onu_id(key->onu_id);
573 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
574 dowi_ind->set_drift(data->drift_value);
575 dowi_ind->set_new_eqd(data->new_eqd);
576 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400577
Jason Huangd33b4d82019-05-15 18:22:57 +0800578 ind.set_allocated_alarm_ind(alarm_ind);
579 }
580 }
581 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400582
583 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800584 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400585}
586
Jason Huangd33b4d82019-05-15 18:22:57 +0800587static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400588 openolt::Indication ind;
589 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
590 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
591
Jason Huangd33b4d82019-05-15 18:22:57 +0800592 switch (msg->obj_type) {
593 case BCMOLT_OBJ_ID_ONU:
594 switch (msg->subgroup) {
595 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
596 {
597 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
598 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400599
Jason Huangd33b4d82019-05-15 18:22:57 +0800600 BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
601 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400602
Jason Huangd33b4d82019-05-15 18:22:57 +0800603 looci_ind->set_intf_id(key->pon_ni);
604 looci_ind->set_onu_id(key->onu_id);
605 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
606 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400607
Jason Huangd33b4d82019-05-15 18:22:57 +0800608 ind.set_allocated_alarm_ind(alarm_ind);
609 }
610 }
611 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400612
613 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800614 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400615}
616
Jason Huangd33b4d82019-05-15 18:22:57 +0800617static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400618 openolt::Indication ind;
619 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
620 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
621
Jason Huangd33b4d82019-05-15 18:22:57 +0800622 switch (msg->obj_type) {
623 case BCMOLT_OBJ_ID_ONU:
624 switch (msg->subgroup) {
625 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
626 {
627 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
628 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400629
Jason Huangd33b4d82019-05-15 18:22:57 +0800630 BCM_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
631 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400632
633
Jason Huangd33b4d82019-05-15 18:22:57 +0800634 sfi_ind->set_intf_id(key->pon_ni);
635 sfi_ind->set_onu_id(key->onu_id);
636 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
637 sfi_ind->set_inverse_bit_error_rate(data->ber);
638 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400639
Jason Huangd33b4d82019-05-15 18:22:57 +0800640 ind.set_allocated_alarm_ind(alarm_ind);
641 }
642 }
643 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644
645 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800646 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400647}
648
Jason Huangd33b4d82019-05-15 18:22:57 +0800649static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400650 openolt::Indication ind;
651 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
652 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
653
Jason Huangd33b4d82019-05-15 18:22:57 +0800654 switch (msg->obj_type) {
655 case BCMOLT_OBJ_ID_ONU:
656 switch (msg->subgroup) {
657 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
658 {
659 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
660 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400661
Jason Huangd33b4d82019-05-15 18:22:57 +0800662 BCM_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
663 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400664
Jason Huangd33b4d82019-05-15 18:22:57 +0800665 tiwi_ind->set_intf_id(key->pon_ni);
666 tiwi_ind->set_onu_id(key->onu_id);
667 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
668 tiwi_ind->set_drift(data->drift_value);
669 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400670
Jason Huangd33b4d82019-05-15 18:22:57 +0800671 ind.set_allocated_alarm_ind(alarm_ind);
672 }
673 }
674 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400675
676 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800677 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400678}
679
Jason Huangd33b4d82019-05-15 18:22:57 +0800680static void OnuActivationFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400681 openolt::Indication ind;
682 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
683 openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication;
684
Jason Huangd33b4d82019-05-15 18:22:57 +0800685 switch (msg->obj_type) {
686 case BCMOLT_OBJ_ID_ONU:
687 switch (msg->subgroup) {
Jason Huangb1fad572019-05-28 19:02:30 +0800688 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
Jason Huangd33b4d82019-05-15 18:22:57 +0800689 {
690 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
691 bcmolt_onu_onu_activation_completed_data *data =
692 &((bcmolt_onu_onu_activation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400693
Jason Huangb1fad572019-05-28 19:02:30 +0800694 BCM_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d\n",
Jason Huangd33b4d82019-05-15 18:22:57 +0800695 key->pon_ni, key->onu_id, data->fail_reason);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400696
Jason Huangd33b4d82019-05-15 18:22:57 +0800697 activation_fail_ind->set_intf_id(key->pon_ni);
698 activation_fail_ind->set_onu_id(key->onu_id);
Jason Huangb1fad572019-05-28 19:02:30 +0800699 activation_fail_ind->set_fail_reason(data->fail_reason);
Jason Huangd33b4d82019-05-15 18:22:57 +0800700 alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400701
Jason Huangd33b4d82019-05-15 18:22:57 +0800702 ind.set_allocated_alarm_ind(alarm_ind);
703 }
704 }
705 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706
707 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800708 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400709}
710
Jason Huangd33b4d82019-05-15 18:22:57 +0800711/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400712bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
713 openolt::Indication ind;
714 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
715 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
716
717 bcmbal_subscriber_terminal_key *key =
718 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
719
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400720 BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
721 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400722
723
724 onu_proc_error_ind->set_intf_id(key->intf_id);
725 onu_proc_error_ind->set_onu_id(key->sub_term_id);
726
727 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
728 ind.set_allocated_alarm_ind(alarm_ind);
729
730 oltIndQ.push(ind);
731 return BCM_ERR_OK;
732}
Jason Huangd33b4d82019-05-15 18:22:57 +0800733*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400734
Shad Ansari01b0e652018-04-05 21:02:53 +0000735Status SubscribeIndication() {
Jason Huangd33b4d82019-05-15 18:22:57 +0800736 bcmolt_rx_cfg rx_cfg = {};
737 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000738
739 if (subscribed) {
740 return Status::OK;
741 }
742
Jason Huangd33b4d82019-05-15 18:22:57 +0800743 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
744 rx_cfg.rx_cb = OltOperIndication;
745 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
746 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
747 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
748 if(rc != BCM_ERR_OK)
749 return Status(grpc::StatusCode::INTERNAL,
750 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000751
Jason Huangd33b4d82019-05-15 18:22:57 +0800752 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
753 rx_cfg.rx_cb = OltOperIndication;
754 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
755 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
756 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
757 if(rc != BCM_ERR_OK)
758 return Status(grpc::StatusCode::INTERNAL,
759 "Olt disconnection complete state indication subscribe failed");
760
761 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
762 rx_cfg.rx_cb = OltOperIndication;
763 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
764 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
765 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
766 if(rc != BCM_ERR_OK)
767 return Status(grpc::StatusCode::INTERNAL,
768 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000769
770 /* Interface LOS indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800771 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
772 rx_cfg.rx_cb = LosIndication;
773 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
774 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
775 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
776 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000777 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000778
Jason Huangd33b4d82019-05-15 18:22:57 +0800779 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
780 rx_cfg.rx_cb = IfOperIndication;
781 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
782 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
783 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
784 if(rc != BCM_ERR_OK)
785 return Status(grpc::StatusCode::INTERNAL,
786 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700787
Jason Huangd33b4d82019-05-15 18:22:57 +0800788 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
789 rx_cfg.rx_cb = IfOperIndication;
790 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
791 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
792 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
793 if(rc != BCM_ERR_OK)
794 return Status(grpc::StatusCode::INTERNAL,
795 "NNI Interface operations state change indication subscribe failed");
796
Jason Huangd33b4d82019-05-15 18:22:57 +0800797 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
798 rx_cfg.rx_cb = OnuAlarmIndication;
799 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
800 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
801 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
802 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000803 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000804
Jason Huangd33b4d82019-05-15 18:22:57 +0800805 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
806 rx_cfg.rx_cb = OnuAlarmIndication;
807 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
808 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
809 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
810 if(rc != BCM_ERR_OK)
811 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
812
813 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
814 rx_cfg.rx_cb = OnuDyingGaspIndication;
815 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
816 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
817 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
818 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000819 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000820
Jason Huangd33b4d82019-05-15 18:22:57 +0800821 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
822 rx_cfg.rx_cb = OnuDiscoveryIndication;
823 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
824 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
825 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
826 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000827 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000828
Jason Huangd33b4d82019-05-15 18:22:57 +0800829 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
830 rx_cfg.rx_cb = OnuIndication;
831 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huangb1fad572019-05-28 19:02:30 +0800832 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_ranging_completed;
833
Jason Huangd33b4d82019-05-15 18:22:57 +0800834 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
835 if(rc != BCM_ERR_OK)
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700836 return Status(grpc::StatusCode::INTERNAL, "onu indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000837
Jason Huangd33b4d82019-05-15 18:22:57 +0800838 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huangd33b4d82019-05-15 18:22:57 +0800839 rx_cfg.rx_cb = OnuStartupFailureIndication;
840 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
841 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
842 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
843 if(rc != BCM_ERR_OK)
844 return Status(grpc::StatusCode::INTERNAL,
845 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000846
Jason Huangd33b4d82019-05-15 18:22:57 +0800847 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
848 rx_cfg.rx_cb = OnuSignalDegradeIndication;
849 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
850 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
851 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
852 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400853 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400854
Jason Huangd33b4d82019-05-15 18:22:57 +0800855 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
856 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
857 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
858 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
859 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
860 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400861 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400862
863 /* LOOCI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800864 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
865 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
866 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
867 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
868 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
869 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400870 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400871
872 /* SFI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800873 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
874 rx_cfg.rx_cb = OnuSignalsFailureIndication;
875 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
876 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
877 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
878 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400879 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400880
881 /* TIWI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800882 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
883 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
884 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
885 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
886 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
887 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400888 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Jason Huangd33b4d82019-05-15 18:22:57 +0800889
890 /* ONU Activation Failure Indiction */
891 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
892 rx_cfg.rx_cb = OnuActivationFailureIndication;
893 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huangb1fad572019-05-28 19:02:30 +0800894 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
Jason Huangd33b4d82019-05-15 18:22:57 +0800895 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
896 if(rc != BCM_ERR_OK)
897 return Status(grpc::StatusCode::INTERNAL,
898 "onu activation falaire indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400899
Jason Huangd33b4d82019-05-15 18:22:57 +0800900 rx_cfg.obj_type = BCMOLT_OBJ_ID_FLOW;
901 rx_cfg.rx_cb = PacketIndication;
902 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
903 rx_cfg.subgroup = bcmolt_flow_auto_subgroup_receive_eth_packet;
904 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
905 if(rc != BCM_ERR_OK)
906 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400907
Shad Ansari01b0e652018-04-05 21:02:53 +0000908 subscribed = true;
909
910 return Status::OK;
911}