blob: 664c79a342c9f999a7dfb3373b72878dd85dae30 [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)
58
59std::string bcmbal_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050060{
Jason Huangd33b4d82019-05-15 18:22:57 +080061 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050062 return "nni";
Jason Huangd33b4d82019-05-15 18:22:57 +080063 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050064 return "pon";
65 }
66 return "unknown";
67}
68
Jason Huangd33b4d82019-05-15 18:22:57 +080069static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +000070 openolt::Indication ind;
71 openolt::OltIndication* olt_ind = new openolt::OltIndication;
72 Status status;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050074
Jason Huangd33b4d82019-05-15 18:22:57 +080075 switch (msg->subgroup) {
76 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
77 ProbeDeviceCapabilities_();
78 admin_state = "up";
79 olt_ind->set_oper_state("up");
80 break;
81 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
82 admin_state = "down";
83 olt_ind->set_oper_state("down");
84 break;
85 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
86 admin_state = "failure";
87 olt_ind->set_oper_state("failure");
88 break;
Shad Ansari01b0e652018-04-05 21:02:53 +000089 }
90 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050091
Jason Huangd33b4d82019-05-15 18:22:57 +080092 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
93 // Enable all PON interfaces.
94 for (int i = 0; i < NumPonIf_(); i++) {
95 status = EnablePonIf_(i);
96 if (!status.ok()) {
97 // FIXME - raise alarm to report error in enabling PON
98 }
Shad Ansari01b0e652018-04-05 21:02:53 +000099 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000100
Jason Huangd33b4d82019-05-15 18:22:57 +0800101 // Enable all NNI interfaces.
102 for (int i = 0; i < NumNniIf_(); i++) {
103 status = EnableUplinkIf_(i);
104 if (!status.ok()) {
105 // FIXME - raise alarm to report error in enabling PON
106 }
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500107 }
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500108
Jason Huangd33b4d82019-05-15 18:22:57 +0800109 /* register for omci indication */
110 {
111 bcmolt_rx_cfg rx_cfg = {};
112 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
113 rx_cfg.rx_cb = OmciIndication;
114 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
115 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
116 bcmolt_ind_subscribe(current_device, &rx_cfg);
117 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000118
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500119 ProbePonIfTechnology_();
120 state.activate();
121 }
122 else {
123 state.deactivate();
124 }
125
Jason Huangd33b4d82019-05-15 18:22:57 +0800126 oltIndQ.push(ind);
127 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000128}
129
Jason Huangd33b4d82019-05-15 18:22:57 +0800130static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000131 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400132 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
133 openolt::LosIndication* los_ind = new openolt::LosIndication;
134
Jason Huangd33b4d82019-05-15 18:22:57 +0800135 switch (msg->obj_type) {
136 case BCMOLT_OBJ_ID_PON_INTERFACE:
137 switch (msg->subgroup) {
138 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
139 {
140 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
141 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
142 BCMOLT_INTERFACE_TYPE_PON);
143 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400144
Jason Huangd33b4d82019-05-15 18:22:57 +0800145 BCM_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
146 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400147
Jason Huangd33b4d82019-05-15 18:22:57 +0800148 los_ind->set_intf_id(intf_id);
149 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400150
Jason Huangd33b4d82019-05-15 18:22:57 +0800151 alarm_ind->set_allocated_los_ind(los_ind);
152 ind.set_allocated_alarm_ind(alarm_ind);
153 break;
154 }
155 }
156 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400157
158 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800159 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000160}
161
Jason Huangd33b4d82019-05-15 18:22:57 +0800162static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700163 openolt::Indication ind;
164 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
165
Jason Huangd33b4d82019-05-15 18:22:57 +0800166 switch (msg->obj_type) {
167 case BCMOLT_OBJ_ID_PON_INTERFACE:
168 switch (msg->subgroup) {
169 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
170 {
171 BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
172 ((bcmolt_pon_interface_state_change_completed *)msg)->key.pon_ni);
173 bcmolt_pon_interface_key *key =
174 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
175 bcmolt_pon_interface_state_change_completed_data *data =
176 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700177
Jason Huangd33b4d82019-05-15 18:22:57 +0800178 intf_ind->set_intf_id(key->pon_ni);
179 if (INTERFACE_STATE_IF_UP(data->new_state))
180 intf_ind->set_oper_state("up");
181 if (INTERFACE_STATE_IF_DOWN(data->new_state))
182 intf_ind->set_oper_state("down");
183 ind.set_allocated_intf_ind(intf_ind);
184 break;
185 }
186 }
187 break;
188 case BCMOLT_OBJ_ID_NNI_INTERFACE:
189 switch (msg->subgroup) {
190 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
191 {
192 BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
193 ((bcmolt_nni_interface_state_change *)msg)->key.id);
194 bcmolt_nni_interface_key *key =
195 &((bcmolt_nni_interface_state_change *)msg)->key;
196 bcmolt_nni_interface_state_change_data *data =
197 &((bcmolt_nni_interface_state_change *)msg)->data;
198
199 intf_ind->set_intf_id(key->id);
200 if (INTERFACE_STATE_IF_UP(data->new_state))
201 intf_ind->set_oper_state("up");
202 if (INTERFACE_STATE_IF_DOWN(data->new_state))
203 intf_ind->set_oper_state("down");
204 ind.set_allocated_intf_ind(intf_ind);
205 break;
206 }
207 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700208 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700209
210 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800211 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700212}
213
Jason Huangd33b4d82019-05-15 18:22:57 +0800214static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000215 openolt::Indication ind;
216 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000217
Jason Huangd33b4d82019-05-15 18:22:57 +0800218 switch (msg->obj_type) {
219 case BCMOLT_OBJ_ID_PON_INTERFACE:
220 switch (msg->subgroup) {
221 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
222 {
223 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
224 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
225 intf_oper_ind->set_intf_id(key->pon_ni);
226 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
227 if (INTERFACE_STATE_IF_UP(data->new_state))
228 intf_oper_ind->set_oper_state("up");
229 if (INTERFACE_STATE_IF_DOWN(data->new_state))
230 intf_oper_ind->set_oper_state("down");
Shad Ansari01b0e652018-04-05 21:02:53 +0000231
Jason Huangd33b4d82019-05-15 18:22:57 +0800232 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
233 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
234 ind.set_allocated_intf_oper_ind(intf_oper_ind);
235 break;
236 }
237 }
238 case BCMOLT_OBJ_ID_NNI_INTERFACE:
239 switch (msg->subgroup) {
240 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
241 {
242 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
243 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
244 bcmolt_interface intf_id = key->id;
245 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
246 intf_oper_ind->set_intf_id(key->id);
247 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
248
249 if (INTERFACE_STATE_IF_UP(data->new_state))
250 intf_oper_ind->set_oper_state("up");
251 if (INTERFACE_STATE_IF_DOWN(data->new_state))
252 intf_oper_ind->set_oper_state("down");
253
254 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
255 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
256 ind.set_allocated_intf_oper_ind(intf_oper_ind);
257 break;
258 }
259 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000260 }
261
Shad Ansari01b0e652018-04-05 21:02:53 +0000262 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800263 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000264}
265
Jason Huangd33b4d82019-05-15 18:22:57 +0800266static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000267 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400268 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
269 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
270
Jason Huangd33b4d82019-05-15 18:22:57 +0800271 switch (msg->obj_type) {
272 case BCMOLT_OBJ_ID_ONU:
273 switch (msg->subgroup) {
274 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
275 {
276 bcmolt_xgpon_onu_alarms *onu_alarms =
277 &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
278 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
279 onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
280 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
281 onu_alarms->lopci_miss));
282 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
283 onu_alarms->lopci_mic_error));
284
285 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
286 ind.set_allocated_alarm_ind(alarm_ind);
287 break;
288 }
289 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
290 {
291 bcmolt_gpon_onu_alarms *onu_alarms =
292 &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
293 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
294 /* TODO: need to set lofi and loami
295 onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
296 onu_alarm_ind->set_loami_status(alarm_status_to_string(
297 onu_alarms->loami));
298 */
299 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
300 ind.set_allocated_alarm_ind(alarm_ind);
301 break;
302 }
303 }
304 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400305
306 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800307 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000308}
309
Jason Huangd33b4d82019-05-15 18:22:57 +0800310static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000311 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400312 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Jason Huangd33b4d82019-05-15 18:22:57 +0800313 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400314
Jason Huangd33b4d82019-05-15 18:22:57 +0800315 switch (msg->obj_type) {
316 case BCMOLT_OBJ_ID_ONU:
317 switch (msg->subgroup) {
318 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
319 {
320 bcmolt_onu_dgi_data* dgi_data = (bcmolt_onu_dgi_data *)msg;
321 dgi_ind->set_status(alarm_status_to_string(dgi_data->alarm_status));
nickc063ffd2018-05-22 14:35:28 -0400322
Jason Huangd33b4d82019-05-15 18:22:57 +0800323 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
324 ind.set_allocated_alarm_ind(alarm_ind);
325 break;
326 }
327 }
328 }
nickc063ffd2018-05-22 14:35:28 -0400329
330 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800331 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000332}
333
Jason Huangd33b4d82019-05-15 18:22:57 +0800334static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000335 openolt::Indication ind;
336 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
337 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
338
Jason Huangd33b4d82019-05-15 18:22:57 +0800339 switch (msg->obj_type) {
340 case BCMOLT_OBJ_ID_PON_INTERFACE:
341 switch (msg->subgroup) {
342 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
343 {
344 bcmolt_pon_interface_key *key =
345 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000346
Jason Huangd33b4d82019-05-15 18:22:57 +0800347 bcmolt_pon_interface_onu_discovered_data *data =
348 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000349
Jason Huangd33b4d82019-05-15 18:22:57 +0800350 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000351
Jason Huangd33b4d82019-05-15 18:22:57 +0800352 BCM_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
353 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000354
Jason Huangd33b4d82019-05-15 18:22:57 +0800355 onu_disc_ind->set_intf_id(key->pon_ni);
356 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
357 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
358 onu_disc_ind->set_allocated_serial_number(serial_number);
359 ind.set_allocated_onu_disc_ind(onu_disc_ind);
360 break;
361 }
362 }
363 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000364
365 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800366 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000367}
368
Jason Huangd33b4d82019-05-15 18:22:57 +0800369static void OnuIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700370 openolt::Indication ind;
371 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
372
Jason Huangd33b4d82019-05-15 18:22:57 +0800373 switch (msg->obj_type) {
374 case BCMOLT_OBJ_ID_ONU:
375 switch (msg->subgroup) {
376 case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE:
377 {
378 bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key;
379 bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700380
Jason Huangd33b4d82019-05-15 18:22:57 +0800381 BCM_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %d\n", key->pon_ni, key->onu_id, data->new_onu_state);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700382
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");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700389
Jason Huangd33b4d82019-05-15 18:22:57 +0800390 ind.set_allocated_onu_ind(onu_ind);
391 }
392 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700393 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700394
395 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800396 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700397}
398
Jason Huangd33b4d82019-05-15 18:22:57 +0800399static void OnuOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000400 openolt::Indication ind;
nickc063ffd2018-05-22 14:35:28 -0400401 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
nickc063ffd2018-05-22 14:35:28 -0400402
Jason Huangd33b4d82019-05-15 18:22:57 +0800403 switch (msg->obj_type) {
404 case BCMOLT_OBJ_ID_ONU:
405 switch (msg->subgroup) {
406 case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE:
407 {
408 bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key;
409 bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data;
nickc063ffd2018-05-22 14:35:28 -0400410
Jason Huangd33b4d82019-05-15 18:22:57 +0800411 onu_ind->set_intf_id(key->pon_ni);
412 onu_ind->set_onu_id(key->onu_id);
413 if (ONU_STATE_IF_UP(data->new_onu_state))
414 onu_ind->set_oper_state("up");
415 if (ONU_STATE_IF_DOWN(data->new_onu_state))
416 onu_ind->set_oper_state("down");
417 ind.set_allocated_onu_ind(onu_ind);
nickc063ffd2018-05-22 14:35:28 -0400418
Jason Huangd33b4d82019-05-15 18:22:57 +0800419 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",
420 key->pon_ni, key->onu_id, data->new_onu_state, onu_ind->oper_state().c_str());
421 }
422 }
nickc063ffd2018-05-22 14:35:28 -0400423 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500424
nickc063ffd2018-05-22 14:35:28 -0400425 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800426 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000427}
428
Jason Huangd33b4d82019-05-15 18:22:57 +0800429static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000430 openolt::Indication ind;
431 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000432
Jason Huangd33b4d82019-05-15 18:22:57 +0800433 switch (msg->obj_type) {
434 case BCMOLT_OBJ_ID_ONU:
435 switch (msg->subgroup) {
436 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
437 {
438 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
439 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000440
Jason Huangd33b4d82019-05-15 18:22:57 +0800441 BCM_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
442 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000443
Jason Huangd33b4d82019-05-15 18:22:57 +0800444 omci_ind->set_intf_id(key->pon_ni);
445 omci_ind->set_onu_id(key->onu_id);
446 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
447
448 ind.set_allocated_omci_ind(omci_ind);
449 break;
450 }
451 }
452 }
453
Shad Ansari01b0e652018-04-05 21:02:53 +0000454 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800455 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000456}
457
Jason Huangd33b4d82019-05-15 18:22:57 +0800458static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000459 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000460 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000461
Jason Huangd33b4d82019-05-15 18:22:57 +0800462 switch (msg->obj_type) {
463 case BCMOLT_OBJ_ID_ONU:
464 switch (msg->subgroup) {
465 case BCMOLT_FLOW_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
466 {
467 bcmolt_flow_key *key = &((bcmolt_flow_cfg*)msg)->key;
468 bcmolt_flow_cfg_data *data = &((bcmolt_flow_cfg*)msg)->data;
469 bcmolt_flow_receive_eth_packet_data *pkt_data =
470 &((bcmolt_flow_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000471
Jason Huangd33b4d82019-05-15 18:22:57 +0800472 uint32_t port_no = GetPortNum_(key->flow_id);
473 pkt_ind->set_intf_type(bcmbal_to_grpc_intf_type((bcmolt_interface_type)data->ingress_intf.intf_type));
474 pkt_ind->set_intf_id(data->ingress_intf.intf_id);
475 pkt_ind->set_gemport_id(data->svc_port_id);
476 pkt_ind->set_flow_id(key->flow_id);
477 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
478 pkt_ind->set_port_no(port_no);
479 pkt_ind->set_cookie(data->cookie);
480 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500481
Jason Huangd33b4d82019-05-15 18:22:57 +0800482 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",
483 pkt_ind->intf_type().c_str(), data->ingress_intf.intf_id, data->svc_port_id, key->flow_id, port_no, data->cookie);
484 }
485 }
486 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500487
Shad Ansari5fe93682018-04-26 05:24:19 +0000488 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800489 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000490}
491
Jason Huangd33b4d82019-05-15 18:22:57 +0800492static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000493 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400494 BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800495 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000496}
497
Jason Huangd33b4d82019-05-15 18:22:57 +0800498static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000499 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400500 BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800501 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000502}
503
Jason Huangd33b4d82019-05-15 18:22:57 +0800504static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000505 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400506 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800507 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000508}
509
Jason Huangd33b4d82019-05-15 18:22:57 +0800510static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000511 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400512 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800513 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000514}
515
Jason Huangd33b4d82019-05-15 18:22:57 +0800516static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000517 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400518 BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800519 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000520}
521
Jason Huangd33b4d82019-05-15 18:22:57 +0800522static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400523 openolt::Indication ind;
524 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
525 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
526
Jason Huangd33b4d82019-05-15 18:22:57 +0800527 switch (msg->obj_type) {
528 case BCMOLT_OBJ_ID_ONU:
529 switch (msg->subgroup) {
530 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
531 {
532 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
533 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400534
Jason Huangd33b4d82019-05-15 18:22:57 +0800535 BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
536 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400537
Jason Huangd33b4d82019-05-15 18:22:57 +0800538 sufi_ind->set_intf_id(key->pon_ni);
539 sufi_ind->set_onu_id(key->onu_id);
540 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
541 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400542
Jason Huangd33b4d82019-05-15 18:22:57 +0800543 ind.set_allocated_alarm_ind(alarm_ind);
544 }
545 }
546 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400547
548 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800549 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400550}
551
Jason Huangd33b4d82019-05-15 18:22:57 +0800552static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400553 openolt::Indication ind;
554 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
555 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
556
Jason Huangd33b4d82019-05-15 18:22:57 +0800557 switch (msg->obj_type) {
558 case BCMOLT_OBJ_ID_ONU:
559 switch (msg->subgroup) {
560 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
561 {
562 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
563 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400564
Jason Huangd33b4d82019-05-15 18:22:57 +0800565 BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
566 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400567
Jason Huangd33b4d82019-05-15 18:22:57 +0800568 sdi_ind->set_intf_id(key->pon_ni);
569 sdi_ind->set_onu_id(key->onu_id);
570 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
571 sdi_ind->set_inverse_bit_error_rate(data->ber);
572 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400573
Jason Huangd33b4d82019-05-15 18:22:57 +0800574 ind.set_allocated_alarm_ind(alarm_ind);
575 }
576 }
577 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400578
579 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800580 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400581}
582
Jason Huangd33b4d82019-05-15 18:22:57 +0800583static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400584 openolt::Indication ind;
585 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
586 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
587
Jason Huangd33b4d82019-05-15 18:22:57 +0800588 switch (msg->obj_type) {
589 case BCMOLT_OBJ_ID_ONU:
590 switch (msg->subgroup) {
591 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
592 {
593 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
594 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400595
Jason Huangd33b4d82019-05-15 18:22:57 +0800596 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",
597 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400598
Jason Huangd33b4d82019-05-15 18:22:57 +0800599 dowi_ind->set_intf_id(key->pon_ni);
600 dowi_ind->set_onu_id(key->onu_id);
601 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
602 dowi_ind->set_drift(data->drift_value);
603 dowi_ind->set_new_eqd(data->new_eqd);
604 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400605
Jason Huangd33b4d82019-05-15 18:22:57 +0800606 ind.set_allocated_alarm_ind(alarm_ind);
607 }
608 }
609 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400610
611 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800612 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400613}
614
Jason Huangd33b4d82019-05-15 18:22:57 +0800615static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400616 openolt::Indication ind;
617 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
618 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
619
Jason Huangd33b4d82019-05-15 18:22:57 +0800620 switch (msg->obj_type) {
621 case BCMOLT_OBJ_ID_ONU:
622 switch (msg->subgroup) {
623 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
624 {
625 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
626 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400627
Jason Huangd33b4d82019-05-15 18:22:57 +0800628 BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
629 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400630
Jason Huangd33b4d82019-05-15 18:22:57 +0800631 looci_ind->set_intf_id(key->pon_ni);
632 looci_ind->set_onu_id(key->onu_id);
633 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
634 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400635
Jason Huangd33b4d82019-05-15 18:22:57 +0800636 ind.set_allocated_alarm_ind(alarm_ind);
637 }
638 }
639 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400640
641 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800642 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400643}
644
Jason Huangd33b4d82019-05-15 18:22:57 +0800645static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400646 openolt::Indication ind;
647 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
648 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
649
Jason Huangd33b4d82019-05-15 18:22:57 +0800650 switch (msg->obj_type) {
651 case BCMOLT_OBJ_ID_ONU:
652 switch (msg->subgroup) {
653 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
654 {
655 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
656 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400657
Jason Huangd33b4d82019-05-15 18:22:57 +0800658 BCM_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
659 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400660
661
Jason Huangd33b4d82019-05-15 18:22:57 +0800662 sfi_ind->set_intf_id(key->pon_ni);
663 sfi_ind->set_onu_id(key->onu_id);
664 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
665 sfi_ind->set_inverse_bit_error_rate(data->ber);
666 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400667
Jason Huangd33b4d82019-05-15 18:22:57 +0800668 ind.set_allocated_alarm_ind(alarm_ind);
669 }
670 }
671 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400672
673 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800674 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400675}
676
Jason Huangd33b4d82019-05-15 18:22:57 +0800677static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400678 openolt::Indication ind;
679 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
680 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
681
Jason Huangd33b4d82019-05-15 18:22:57 +0800682 switch (msg->obj_type) {
683 case BCMOLT_OBJ_ID_ONU:
684 switch (msg->subgroup) {
685 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
686 {
687 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
688 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400689
Jason Huangd33b4d82019-05-15 18:22:57 +0800690 BCM_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
691 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400692
Jason Huangd33b4d82019-05-15 18:22:57 +0800693 tiwi_ind->set_intf_id(key->pon_ni);
694 tiwi_ind->set_onu_id(key->onu_id);
695 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
696 tiwi_ind->set_drift(data->drift_value);
697 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400698
Jason Huangd33b4d82019-05-15 18:22:57 +0800699 ind.set_allocated_alarm_ind(alarm_ind);
700 }
701 }
702 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400703
704 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800705 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706}
707
Jason Huangd33b4d82019-05-15 18:22:57 +0800708static void OnuActivationFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400709 openolt::Indication ind;
710 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
711 openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication;
712
Jason Huangd33b4d82019-05-15 18:22:57 +0800713 switch (msg->obj_type) {
714 case BCMOLT_OBJ_ID_ONU:
715 switch (msg->subgroup) {
716 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED:
717 {
718 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
719 bcmolt_onu_onu_activation_completed_data *data =
720 &((bcmolt_onu_onu_activation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400721
Jason Huangd33b4d82019-05-15 18:22:57 +0800722 BCM_LOG(WARNING, openolt_log_id, "onu activation failure indication, intf_id %d, onu_id %d, fail_reason %d\n",
723 key->pon_ni, key->onu_id, data->fail_reason);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400724
Jason Huangd33b4d82019-05-15 18:22:57 +0800725 activation_fail_ind->set_intf_id(key->pon_ni);
726 activation_fail_ind->set_onu_id(key->onu_id);
727 alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400728
Jason Huangd33b4d82019-05-15 18:22:57 +0800729 ind.set_allocated_alarm_ind(alarm_ind);
730 }
731 }
732 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400733
734 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800735 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400736}
737
Jason Huangd33b4d82019-05-15 18:22:57 +0800738/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400739bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
740 openolt::Indication ind;
741 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
742 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
743
744 bcmbal_subscriber_terminal_key *key =
745 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
746
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400747 BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
748 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400749
750
751 onu_proc_error_ind->set_intf_id(key->intf_id);
752 onu_proc_error_ind->set_onu_id(key->sub_term_id);
753
754 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
755 ind.set_allocated_alarm_ind(alarm_ind);
756
757 oltIndQ.push(ind);
758 return BCM_ERR_OK;
759}
Jason Huangd33b4d82019-05-15 18:22:57 +0800760*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400761
Shad Ansari01b0e652018-04-05 21:02:53 +0000762Status SubscribeIndication() {
Jason Huangd33b4d82019-05-15 18:22:57 +0800763 bcmolt_rx_cfg rx_cfg = {};
764 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000765
766 if (subscribed) {
767 return Status::OK;
768 }
769
Jason Huangd33b4d82019-05-15 18:22:57 +0800770 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
771 rx_cfg.rx_cb = OltOperIndication;
772 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
773 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
774 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
775 if(rc != BCM_ERR_OK)
776 return Status(grpc::StatusCode::INTERNAL,
777 "Olt connection complete state 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_DEVICE;
780 rx_cfg.rx_cb = OltOperIndication;
781 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
782 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
783 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
784 if(rc != BCM_ERR_OK)
785 return Status(grpc::StatusCode::INTERNAL,
786 "Olt disconnection complete state indication subscribe failed");
787
788 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
789 rx_cfg.rx_cb = OltOperIndication;
790 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
791 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
792 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
793 if(rc != BCM_ERR_OK)
794 return Status(grpc::StatusCode::INTERNAL,
795 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000796
797 /* Interface LOS indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800798 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
799 rx_cfg.rx_cb = LosIndication;
800 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
801 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
802 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
803 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000804 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000805
Jason Huangd33b4d82019-05-15 18:22:57 +0800806 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
807 rx_cfg.rx_cb = IfOperIndication;
808 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
809 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
810 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
811 if(rc != BCM_ERR_OK)
812 return Status(grpc::StatusCode::INTERNAL,
813 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700814
Jason Huangd33b4d82019-05-15 18:22:57 +0800815 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
816 rx_cfg.rx_cb = IfIndication;
817 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
818 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
819 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
820 if(rc != BCM_ERR_OK)
821 return Status(grpc::StatusCode::INTERNAL, "PON Interface indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000822
Jason Huangd33b4d82019-05-15 18:22:57 +0800823 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
824 rx_cfg.rx_cb = IfOperIndication;
825 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
826 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
827 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
828 if(rc != BCM_ERR_OK)
829 return Status(grpc::StatusCode::INTERNAL,
830 "NNI Interface operations state change indication subscribe failed");
831
832 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
833 rx_cfg.rx_cb = IfIndication;
834 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
835 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
836 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
837 if(rc != BCM_ERR_OK)
838 return Status(grpc::StatusCode::INTERNAL, "NNI Interface indication subscribe failed");
839
840 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
841 rx_cfg.rx_cb = OnuAlarmIndication;
842 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
843 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
844 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
845 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000846 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000847
Jason Huangd33b4d82019-05-15 18:22:57 +0800848 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
849 rx_cfg.rx_cb = OnuAlarmIndication;
850 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
851 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
852 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
853 if(rc != BCM_ERR_OK)
854 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
855
856 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
857 rx_cfg.rx_cb = OnuDyingGaspIndication;
858 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
859 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
860 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
861 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000862 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000863
Jason Huangd33b4d82019-05-15 18:22:57 +0800864 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
865 rx_cfg.rx_cb = OnuDiscoveryIndication;
866 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
867 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
868 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
869 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000870 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000871
Jason Huangd33b4d82019-05-15 18:22:57 +0800872 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
873 rx_cfg.rx_cb = OnuIndication;
874 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
875 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_state_change;
876 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
877 if(rc != BCM_ERR_OK)
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700878 return Status(grpc::StatusCode::INTERNAL, "onu indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000879
Jason Huangd33b4d82019-05-15 18:22:57 +0800880 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
881 rx_cfg.rx_cb = OnuOperIndication;
882 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
883 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_state_change;
884 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
885 if(rc != BCM_ERR_OK)
886 return Status(grpc::StatusCode::INTERNAL,
887 "onu operational state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000888
Jason Huangd33b4d82019-05-15 18:22:57 +0800889 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
890 rx_cfg.rx_cb = OnuStartupFailureIndication;
891 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
892 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
893 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
894 if(rc != BCM_ERR_OK)
895 return Status(grpc::StatusCode::INTERNAL,
896 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000897
Jason Huangd33b4d82019-05-15 18:22:57 +0800898 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
899 rx_cfg.rx_cb = OnuSignalDegradeIndication;
900 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
901 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
902 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
903 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400904 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400905
Jason Huangd33b4d82019-05-15 18:22:57 +0800906 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
907 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
908 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
909 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
910 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
911 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400912 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400913
914 /* LOOCI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800915 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
916 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
917 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
918 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
919 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
920 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400921 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400922
923 /* SFI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800924 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
925 rx_cfg.rx_cb = OnuSignalsFailureIndication;
926 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
927 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
928 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
929 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400930 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400931
932 /* TIWI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800933 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
934 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
935 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
936 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
937 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
938 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400939 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Jason Huangd33b4d82019-05-15 18:22:57 +0800940
941 /* ONU Activation Failure Indiction */
942 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
943 rx_cfg.rx_cb = OnuActivationFailureIndication;
944 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
945 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed;
946 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
947 if(rc != BCM_ERR_OK)
948 return Status(grpc::StatusCode::INTERNAL,
949 "onu activation falaire indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400950
Jason Huangd33b4d82019-05-15 18:22:57 +0800951 rx_cfg.obj_type = BCMOLT_OBJ_ID_FLOW;
952 rx_cfg.rx_cb = PacketIndication;
953 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
954 rx_cfg.subgroup = bcmolt_flow_auto_subgroup_receive_eth_packet;
955 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
956 if(rc != BCM_ERR_OK)
957 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400958
Shad Ansari01b0e652018-04-05 21:02:53 +0000959 subscribed = true;
960
961 return Status::OK;
962}