blob: d938ea4e9acaa2e0341feaddbd7494f35b1555e9 [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 Huang439d24f2019-06-26 03:25:05 +080065#define GET_FLOW_TYPE(type) \
66 (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \
67 (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \
68 (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown"
Jason Huangd33b4d82019-05-15 18:22:57 +080069
Jason Huang439d24f2019-06-26 03:25:05 +080070std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050071{
Jason Huangd33b4d82019-05-15 18:22:57 +080072 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050073 return "nni";
Jason Huangd33b4d82019-05-15 18:22:57 +080074 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050075 return "pon";
76 }
77 return "unknown";
78}
79
Jason Huangd33b4d82019-05-15 18:22:57 +080080static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +000081 openolt::Indication ind;
82 openolt::OltIndication* olt_ind = new openolt::OltIndication;
83 Status status;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050084 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050085
Jason Huangd33b4d82019-05-15 18:22:57 +080086 switch (msg->subgroup) {
87 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
Jason Huangd33b4d82019-05-15 18:22:57 +080088 admin_state = "up";
89 olt_ind->set_oper_state("up");
90 break;
91 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
92 admin_state = "down";
93 olt_ind->set_oper_state("down");
94 break;
95 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
96 admin_state = "failure";
97 olt_ind->set_oper_state("failure");
98 break;
Shad Ansari01b0e652018-04-05 21:02:53 +000099 }
100 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500101
Jason Huangd33b4d82019-05-15 18:22:57 +0800102 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
Jason Huangd33b4d82019-05-15 18:22:57 +0800103 /* register for omci indication */
104 {
105 bcmolt_rx_cfg rx_cfg = {};
106 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
107 rx_cfg.rx_cb = OmciIndication;
108 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
109 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
110 bcmolt_ind_subscribe(current_device, &rx_cfg);
111 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500112 state.activate();
113 }
114 else {
115 state.deactivate();
116 }
117
Jason Huangd33b4d82019-05-15 18:22:57 +0800118 oltIndQ.push(ind);
119 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000120}
121
Jason Huangd33b4d82019-05-15 18:22:57 +0800122static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000123 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400124 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
125 openolt::LosIndication* los_ind = new openolt::LosIndication;
126
Jason Huangd33b4d82019-05-15 18:22:57 +0800127 switch (msg->obj_type) {
128 case BCMOLT_OBJ_ID_PON_INTERFACE:
129 switch (msg->subgroup) {
130 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
131 {
132 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
133 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
134 BCMOLT_INTERFACE_TYPE_PON);
135 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400136
Jason Huangd33b4d82019-05-15 18:22:57 +0800137 BCM_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
138 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400139
Jason Huangd33b4d82019-05-15 18:22:57 +0800140 los_ind->set_intf_id(intf_id);
141 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400142
Jason Huangd33b4d82019-05-15 18:22:57 +0800143 alarm_ind->set_allocated_los_ind(los_ind);
144 ind.set_allocated_alarm_ind(alarm_ind);
145 break;
146 }
147 }
148 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400149
150 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800151 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000152}
153
Jason Huangd33b4d82019-05-15 18:22:57 +0800154static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700155 openolt::Indication ind;
156 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
157
Jason Huangd33b4d82019-05-15 18:22:57 +0800158 switch (msg->obj_type) {
159 case BCMOLT_OBJ_ID_PON_INTERFACE:
160 switch (msg->subgroup) {
161 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
162 {
Jason Huangd33b4d82019-05-15 18:22:57 +0800163 bcmolt_pon_interface_key *key =
164 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
165 bcmolt_pon_interface_state_change_completed_data *data =
166 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700167
Jason Huangd33b4d82019-05-15 18:22:57 +0800168 intf_ind->set_intf_id(key->pon_ni);
Jason Huang88795222019-06-13 19:28:44 +0800169 SET_OPER_STATE(intf_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800170 ind.set_allocated_intf_ind(intf_ind);
171 break;
172 }
173 }
174 break;
175 case BCMOLT_OBJ_ID_NNI_INTERFACE:
176 switch (msg->subgroup) {
177 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
178 {
179 BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
180 ((bcmolt_nni_interface_state_change *)msg)->key.id);
181 bcmolt_nni_interface_key *key =
182 &((bcmolt_nni_interface_state_change *)msg)->key;
183 bcmolt_nni_interface_state_change_data *data =
184 &((bcmolt_nni_interface_state_change *)msg)->data;
185
186 intf_ind->set_intf_id(key->id);
Jason Huang88795222019-06-13 19:28:44 +0800187 SET_OPER_STATE(intf_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800188 ind.set_allocated_intf_ind(intf_ind);
189 break;
190 }
191 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700192 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700193
194 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800195 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700196}
197
Jason Huangd33b4d82019-05-15 18:22:57 +0800198static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000199 openolt::Indication ind;
200 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000201
Jason Huangd33b4d82019-05-15 18:22:57 +0800202 switch (msg->obj_type) {
203 case BCMOLT_OBJ_ID_PON_INTERFACE:
204 switch (msg->subgroup) {
205 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
206 {
207 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
208 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
209 intf_oper_ind->set_intf_id(key->pon_ni);
Jason Huang439d24f2019-06-26 03:25:05 +0800210 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
Jason Huang88795222019-06-13 19:28:44 +0800211 SET_OPER_STATE(intf_oper_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800212 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
213 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
214 ind.set_allocated_intf_oper_ind(intf_oper_ind);
215 break;
216 }
217 }
218 case BCMOLT_OBJ_ID_NNI_INTERFACE:
219 switch (msg->subgroup) {
220 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
221 {
222 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
223 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
224 bcmolt_interface intf_id = key->id;
225 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
226 intf_oper_ind->set_intf_id(key->id);
Jason Huang439d24f2019-06-26 03:25:05 +0800227 intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
Jason Huang88795222019-06-13 19:28:44 +0800228 SET_OPER_STATE(intf_oper_ind, data->new_state);
Jason Huangd33b4d82019-05-15 18:22:57 +0800229 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
230 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
231 ind.set_allocated_intf_oper_ind(intf_oper_ind);
232 break;
233 }
234 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000235 }
236
Shad Ansari01b0e652018-04-05 21:02:53 +0000237 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800238 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000239}
240
Jason Huangd33b4d82019-05-15 18:22:57 +0800241static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000242 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400243 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
244 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
245
Jason Huangd33b4d82019-05-15 18:22:57 +0800246 switch (msg->obj_type) {
247 case BCMOLT_OBJ_ID_ONU:
248 switch (msg->subgroup) {
249 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
250 {
251 bcmolt_xgpon_onu_alarms *onu_alarms =
252 &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
253 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
254 onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
255 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
256 onu_alarms->lopci_miss));
257 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
258 onu_alarms->lopci_mic_error));
259
260 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
261 ind.set_allocated_alarm_ind(alarm_ind);
262 break;
263 }
264 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
265 {
266 bcmolt_gpon_onu_alarms *onu_alarms =
267 &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
268 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
269 /* TODO: need to set lofi and loami
270 onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
271 onu_alarm_ind->set_loami_status(alarm_status_to_string(
272 onu_alarms->loami));
273 */
274 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
275 ind.set_allocated_alarm_ind(alarm_ind);
276 break;
277 }
278 }
279 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400280
281 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800282 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000283}
284
Jason Huangd33b4d82019-05-15 18:22:57 +0800285static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000286 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400287 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Jason Huangd33b4d82019-05-15 18:22:57 +0800288 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400289
Jason Huangd33b4d82019-05-15 18:22:57 +0800290 switch (msg->obj_type) {
291 case BCMOLT_OBJ_ID_ONU:
292 switch (msg->subgroup) {
293 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
294 {
295 bcmolt_onu_dgi_data* dgi_data = (bcmolt_onu_dgi_data *)msg;
296 dgi_ind->set_status(alarm_status_to_string(dgi_data->alarm_status));
nickc063ffd2018-05-22 14:35:28 -0400297
Jason Huangd33b4d82019-05-15 18:22:57 +0800298 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
299 ind.set_allocated_alarm_ind(alarm_ind);
300 break;
301 }
302 }
303 }
nickc063ffd2018-05-22 14:35:28 -0400304
305 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800306 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000307}
308
Jason Huangd33b4d82019-05-15 18:22:57 +0800309static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000310 openolt::Indication ind;
311 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
312 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
313
Jason Huangd33b4d82019-05-15 18:22:57 +0800314 switch (msg->obj_type) {
315 case BCMOLT_OBJ_ID_PON_INTERFACE:
316 switch (msg->subgroup) {
317 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
318 {
319 bcmolt_pon_interface_key *key =
320 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000321
Jason Huangd33b4d82019-05-15 18:22:57 +0800322 bcmolt_pon_interface_onu_discovered_data *data =
323 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000324
Jason Huangd33b4d82019-05-15 18:22:57 +0800325 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000326
Jason Huangd33b4d82019-05-15 18:22:57 +0800327 BCM_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
328 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000329
Jason Huangd33b4d82019-05-15 18:22:57 +0800330 onu_disc_ind->set_intf_id(key->pon_ni);
331 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
332 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
333 onu_disc_ind->set_allocated_serial_number(serial_number);
334 ind.set_allocated_onu_disc_ind(onu_disc_ind);
335 break;
336 }
337 }
338 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000339
340 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800341 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000342}
343
Jason Huangd33b4d82019-05-15 18:22:57 +0800344static void OnuIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700345 openolt::Indication ind;
346 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
347
Jason Huangd33b4d82019-05-15 18:22:57 +0800348 switch (msg->obj_type) {
349 case BCMOLT_OBJ_ID_ONU:
350 switch (msg->subgroup) {
Jason Huangb1fad572019-05-28 19:02:30 +0800351 case BCMOLT_ONU_AUTO_SUBGROUP_RANGING_COMPLETED:
Jason Huangd33b4d82019-05-15 18:22:57 +0800352 {
Jason Huangb1fad572019-05-28 19:02:30 +0800353 bcmolt_onu_key *key = &((bcmolt_onu_ranging_completed*)msg)->key;
354 bcmolt_onu_ranging_completed_data *data = &((bcmolt_onu_ranging_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700355
Jason Huangd33b4d82019-05-15 18:22:57 +0800356 onu_ind->set_intf_id(key->pon_ni);
357 onu_ind->set_onu_id(key->onu_id);
Jason Huangb1fad572019-05-28 19:02:30 +0800358 if (ONU_RANGING_STATE_IF_UP(data->status))
Jason Huangd33b4d82019-05-15 18:22:57 +0800359 onu_ind->set_oper_state("up");
Jason Huangb1fad572019-05-28 19:02:30 +0800360 if (ONU_RANGING_STATE_IF_DOWN(data->status))
Jason Huangd33b4d82019-05-15 18:22:57 +0800361 onu_ind->set_oper_state("down");
Jason Huang88795222019-06-13 19:28:44 +0800362 (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down");
Jason Huangd33b4d82019-05-15 18:22:57 +0800363 ind.set_allocated_onu_ind(onu_ind);
Jason Huang88795222019-06-13 19:28:44 +0800364 BCM_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n",
365 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down",
366 (key->onu_id)?"up":"down");
Jason Huangd33b4d82019-05-15 18:22:57 +0800367 }
368 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700369 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700370
371 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800372 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700373}
374
Jason Huangd33b4d82019-05-15 18:22:57 +0800375static void OnuOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000376 openolt::Indication ind;
nickc063ffd2018-05-22 14:35:28 -0400377 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
nickc063ffd2018-05-22 14:35:28 -0400378
Jason Huangd33b4d82019-05-15 18:22:57 +0800379 switch (msg->obj_type) {
380 case BCMOLT_OBJ_ID_ONU:
381 switch (msg->subgroup) {
382 case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE:
383 {
384 bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key;
385 bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data;
nickc063ffd2018-05-22 14:35:28 -0400386
Jason Huangd33b4d82019-05-15 18:22:57 +0800387 onu_ind->set_intf_id(key->pon_ni);
388 onu_ind->set_onu_id(key->onu_id);
389 if (ONU_STATE_IF_UP(data->new_onu_state))
390 onu_ind->set_oper_state("up");
391 if (ONU_STATE_IF_DOWN(data->new_onu_state))
392 onu_ind->set_oper_state("down");
393 ind.set_allocated_onu_ind(onu_ind);
nickc063ffd2018-05-22 14:35:28 -0400394
Jason Huangd33b4d82019-05-15 18:22:57 +0800395 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",
396 key->pon_ni, key->onu_id, data->new_onu_state, onu_ind->oper_state().c_str());
397 }
398 }
nickc063ffd2018-05-22 14:35:28 -0400399 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500400
nickc063ffd2018-05-22 14:35:28 -0400401 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800402 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000403}
404
Jason Huangd33b4d82019-05-15 18:22:57 +0800405static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000406 openolt::Indication ind;
407 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000408
Jason Huangd33b4d82019-05-15 18:22:57 +0800409 switch (msg->obj_type) {
410 case BCMOLT_OBJ_ID_ONU:
411 switch (msg->subgroup) {
412 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
413 {
414 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
415 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000416
Jason Huangd33b4d82019-05-15 18:22:57 +0800417 BCM_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
418 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000419
Jason Huangd33b4d82019-05-15 18:22:57 +0800420 omci_ind->set_intf_id(key->pon_ni);
421 omci_ind->set_onu_id(key->onu_id);
422 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
423
424 ind.set_allocated_omci_ind(omci_ind);
425 break;
426 }
427 }
428 }
429
Shad Ansari01b0e652018-04-05 21:02:53 +0000430 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800431 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000432}
433
Jason Huangd33b4d82019-05-15 18:22:57 +0800434static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000435 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000436 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000437
Jason Huangd33b4d82019-05-15 18:22:57 +0800438 switch (msg->obj_type) {
Jason Huang439d24f2019-06-26 03:25:05 +0800439 case BCMOLT_OBJ_ID_FLOW:
Jason Huangd33b4d82019-05-15 18:22:57 +0800440 switch (msg->subgroup) {
441 case BCMOLT_FLOW_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
442 {
Jason Huang439d24f2019-06-26 03:25:05 +0800443 bcmolt_flow_receive_eth_packet *pkt =
444 (bcmolt_flow_receive_eth_packet*)msg;
Jason Huangd33b4d82019-05-15 18:22:57 +0800445 bcmolt_flow_receive_eth_packet_data *pkt_data =
446 &((bcmolt_flow_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000447
Jason Huang439d24f2019-06-26 03:25:05 +0800448 uint32_t port_no = GetPortNum_(pkt->key.flow_id);
449 pkt_ind->set_intf_type(bcmolt_to_grpc_intf_type((bcmolt_interface_type)get_flow_status(pkt->key.flow_id, INTF_TYPE)));
450 pkt_ind->set_intf_id(get_flow_status(pkt->key.flow_id, INTF_ID));
451 pkt_ind->set_gemport_id(get_flow_status(pkt->key.flow_id, SVC_PORT_ID));
452 pkt_ind->set_flow_id(pkt->key.flow_id);
Jason Huangd33b4d82019-05-15 18:22:57 +0800453 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
454 pkt_ind->set_port_no(port_no);
Jason Huang439d24f2019-06-26 03:25:05 +0800455 pkt_ind->set_cookie(get_flow_status(pkt->key.flow_id, COOKIE));
Jason Huangd33b4d82019-05-15 18:22:57 +0800456 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500457
Jason Huang439d24f2019-06-26 03:25:05 +0800458 BCM_LOG(INFO, openolt_log_id, "packet indication, intf_type %s, intf_id %d, svc_port %d, flow_type %s, flow_id %d, port_no %d, cookie %"PRIu64"\n",
459 pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_ind->gemport_id(), GET_FLOW_TYPE(pkt->key.flow_type),
460 pkt_ind->flow_id(), port_no, pkt_ind->cookie());
Jason Huangd33b4d82019-05-15 18:22:57 +0800461 }
462 }
463 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500464
Shad Ansari5fe93682018-04-26 05:24:19 +0000465 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800466 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000467}
468
Jason Huangd33b4d82019-05-15 18:22:57 +0800469static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000470 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400471 BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800472 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000473}
474
Jason Huangd33b4d82019-05-15 18:22:57 +0800475static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000476 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400477 BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800478 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000479}
480
Jason Huangd33b4d82019-05-15 18:22:57 +0800481static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000482 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400483 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800484 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000485}
486
Jason Huangd33b4d82019-05-15 18:22:57 +0800487static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000488 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400489 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800490 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000491}
492
Jason Huangd33b4d82019-05-15 18:22:57 +0800493static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000494 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400495 BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800496 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000497}
498
Jason Huangd33b4d82019-05-15 18:22:57 +0800499static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400500 openolt::Indication ind;
501 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
502 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
503
Jason Huangd33b4d82019-05-15 18:22:57 +0800504 switch (msg->obj_type) {
505 case BCMOLT_OBJ_ID_ONU:
506 switch (msg->subgroup) {
507 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
508 {
509 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
510 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400511
Jason Huangd33b4d82019-05-15 18:22:57 +0800512 BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
513 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400514
Jason Huangd33b4d82019-05-15 18:22:57 +0800515 sufi_ind->set_intf_id(key->pon_ni);
516 sufi_ind->set_onu_id(key->onu_id);
517 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
518 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400519
Jason Huangd33b4d82019-05-15 18:22:57 +0800520 ind.set_allocated_alarm_ind(alarm_ind);
521 }
522 }
523 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400524
525 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800526 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400527}
528
Jason Huangd33b4d82019-05-15 18:22:57 +0800529static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400530 openolt::Indication ind;
531 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
532 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
533
Jason Huangd33b4d82019-05-15 18:22:57 +0800534 switch (msg->obj_type) {
535 case BCMOLT_OBJ_ID_ONU:
536 switch (msg->subgroup) {
537 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
538 {
539 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
540 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400541
Jason Huangd33b4d82019-05-15 18:22:57 +0800542 BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
543 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400544
Jason Huangd33b4d82019-05-15 18:22:57 +0800545 sdi_ind->set_intf_id(key->pon_ni);
546 sdi_ind->set_onu_id(key->onu_id);
547 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
548 sdi_ind->set_inverse_bit_error_rate(data->ber);
549 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400550
Jason Huangd33b4d82019-05-15 18:22:57 +0800551 ind.set_allocated_alarm_ind(alarm_ind);
552 }
553 }
554 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400555
556 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800557 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400558}
559
Jason Huangd33b4d82019-05-15 18:22:57 +0800560static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400561 openolt::Indication ind;
562 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
563 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
564
Jason Huangd33b4d82019-05-15 18:22:57 +0800565 switch (msg->obj_type) {
566 case BCMOLT_OBJ_ID_ONU:
567 switch (msg->subgroup) {
568 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
569 {
570 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
571 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400572
Jason Huangd33b4d82019-05-15 18:22:57 +0800573 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",
574 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400575
Jason Huangd33b4d82019-05-15 18:22:57 +0800576 dowi_ind->set_intf_id(key->pon_ni);
577 dowi_ind->set_onu_id(key->onu_id);
578 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
579 dowi_ind->set_drift(data->drift_value);
580 dowi_ind->set_new_eqd(data->new_eqd);
581 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400582
Jason Huangd33b4d82019-05-15 18:22:57 +0800583 ind.set_allocated_alarm_ind(alarm_ind);
584 }
585 }
586 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400587
588 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800589 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400590}
591
Jason Huangd33b4d82019-05-15 18:22:57 +0800592static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400593 openolt::Indication ind;
594 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
595 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
596
Jason Huangd33b4d82019-05-15 18:22:57 +0800597 switch (msg->obj_type) {
598 case BCMOLT_OBJ_ID_ONU:
599 switch (msg->subgroup) {
600 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
601 {
602 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
603 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400604
Jason Huangd33b4d82019-05-15 18:22:57 +0800605 BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
606 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400607
Jason Huangd33b4d82019-05-15 18:22:57 +0800608 looci_ind->set_intf_id(key->pon_ni);
609 looci_ind->set_onu_id(key->onu_id);
610 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
611 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400612
Jason Huangd33b4d82019-05-15 18:22:57 +0800613 ind.set_allocated_alarm_ind(alarm_ind);
614 }
615 }
616 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400617
618 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800619 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400620}
621
Jason Huangd33b4d82019-05-15 18:22:57 +0800622static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400623 openolt::Indication ind;
624 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
625 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
626
Jason Huangd33b4d82019-05-15 18:22:57 +0800627 switch (msg->obj_type) {
628 case BCMOLT_OBJ_ID_ONU:
629 switch (msg->subgroup) {
630 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
631 {
632 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
633 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400634
Jason Huangd33b4d82019-05-15 18:22:57 +0800635 BCM_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
636 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400637
638
Jason Huangd33b4d82019-05-15 18:22:57 +0800639 sfi_ind->set_intf_id(key->pon_ni);
640 sfi_ind->set_onu_id(key->onu_id);
641 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
642 sfi_ind->set_inverse_bit_error_rate(data->ber);
643 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644
Jason Huangd33b4d82019-05-15 18:22:57 +0800645 ind.set_allocated_alarm_ind(alarm_ind);
646 }
647 }
648 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400649
650 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800651 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400652}
653
Jason Huangd33b4d82019-05-15 18:22:57 +0800654static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400655 openolt::Indication ind;
656 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
657 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
658
Jason Huangd33b4d82019-05-15 18:22:57 +0800659 switch (msg->obj_type) {
660 case BCMOLT_OBJ_ID_ONU:
661 switch (msg->subgroup) {
662 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
663 {
664 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
665 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400666
Jason Huangd33b4d82019-05-15 18:22:57 +0800667 BCM_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
668 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400669
Jason Huangd33b4d82019-05-15 18:22:57 +0800670 tiwi_ind->set_intf_id(key->pon_ni);
671 tiwi_ind->set_onu_id(key->onu_id);
672 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
673 tiwi_ind->set_drift(data->drift_value);
674 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400675
Jason Huangd33b4d82019-05-15 18:22:57 +0800676 ind.set_allocated_alarm_ind(alarm_ind);
677 }
678 }
679 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400680
681 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800682 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400683}
684
Jason Huangd33b4d82019-05-15 18:22:57 +0800685static void OnuActivationFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400686 openolt::Indication ind;
687 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
688 openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication;
689
Jason Huangd33b4d82019-05-15 18:22:57 +0800690 switch (msg->obj_type) {
691 case BCMOLT_OBJ_ID_ONU:
692 switch (msg->subgroup) {
Jason Huangb1fad572019-05-28 19:02:30 +0800693 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
Jason Huangd33b4d82019-05-15 18:22:57 +0800694 {
695 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
696 bcmolt_onu_onu_activation_completed_data *data =
697 &((bcmolt_onu_onu_activation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400698
Jason Huangb1fad572019-05-28 19:02:30 +0800699 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 +0800700 key->pon_ni, key->onu_id, data->fail_reason);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400701
Jason Huangd33b4d82019-05-15 18:22:57 +0800702 activation_fail_ind->set_intf_id(key->pon_ni);
703 activation_fail_ind->set_onu_id(key->onu_id);
Jason Huangb1fad572019-05-28 19:02:30 +0800704 activation_fail_ind->set_fail_reason(data->fail_reason);
Jason Huangd33b4d82019-05-15 18:22:57 +0800705 alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400706
Jason Huangd33b4d82019-05-15 18:22:57 +0800707 ind.set_allocated_alarm_ind(alarm_ind);
708 }
709 }
710 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400711
712 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800713 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400714}
715
Jason Huangd33b4d82019-05-15 18:22:57 +0800716/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400717bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
718 openolt::Indication ind;
719 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
720 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
721
722 bcmbal_subscriber_terminal_key *key =
723 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
724
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400725 BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
726 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400727
728
729 onu_proc_error_ind->set_intf_id(key->intf_id);
730 onu_proc_error_ind->set_onu_id(key->sub_term_id);
731
732 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
733 ind.set_allocated_alarm_ind(alarm_ind);
734
735 oltIndQ.push(ind);
736 return BCM_ERR_OK;
737}
Jason Huangd33b4d82019-05-15 18:22:57 +0800738*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400739
Shad Ansari01b0e652018-04-05 21:02:53 +0000740Status SubscribeIndication() {
Jason Huangd33b4d82019-05-15 18:22:57 +0800741 bcmolt_rx_cfg rx_cfg = {};
742 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000743
744 if (subscribed) {
745 return Status::OK;
746 }
747
Jason Huangd33b4d82019-05-15 18:22:57 +0800748 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
749 rx_cfg.rx_cb = OltOperIndication;
750 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
751 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
752 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
753 if(rc != BCM_ERR_OK)
754 return Status(grpc::StatusCode::INTERNAL,
755 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000756
Jason Huangd33b4d82019-05-15 18:22:57 +0800757 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
758 rx_cfg.rx_cb = OltOperIndication;
759 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
760 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
761 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
762 if(rc != BCM_ERR_OK)
763 return Status(grpc::StatusCode::INTERNAL,
764 "Olt disconnection complete state indication subscribe failed");
765
766 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
767 rx_cfg.rx_cb = OltOperIndication;
768 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
769 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
770 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
771 if(rc != BCM_ERR_OK)
772 return Status(grpc::StatusCode::INTERNAL,
773 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000774
775 /* Interface LOS indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800776 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
777 rx_cfg.rx_cb = LosIndication;
778 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
779 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
780 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
781 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000782 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000783
Jason Huangd33b4d82019-05-15 18:22:57 +0800784 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
785 rx_cfg.rx_cb = IfOperIndication;
786 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
787 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
788 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
789 if(rc != BCM_ERR_OK)
790 return Status(grpc::StatusCode::INTERNAL,
791 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700792
Jason Huangd33b4d82019-05-15 18:22:57 +0800793 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
794 rx_cfg.rx_cb = IfOperIndication;
795 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
796 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
797 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
798 if(rc != BCM_ERR_OK)
799 return Status(grpc::StatusCode::INTERNAL,
800 "NNI Interface operations state change indication subscribe failed");
801
Jason Huangd33b4d82019-05-15 18:22:57 +0800802 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
803 rx_cfg.rx_cb = OnuAlarmIndication;
804 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
805 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
806 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
807 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000808 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000809
Jason Huangd33b4d82019-05-15 18:22:57 +0800810 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
811 rx_cfg.rx_cb = OnuAlarmIndication;
812 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
813 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
814 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
815 if(rc != BCM_ERR_OK)
816 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
817
818 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
819 rx_cfg.rx_cb = OnuDyingGaspIndication;
820 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
821 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
822 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
823 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000824 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000825
Jason Huangd33b4d82019-05-15 18:22:57 +0800826 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
827 rx_cfg.rx_cb = OnuDiscoveryIndication;
828 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
829 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
830 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
831 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000832 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000833
Jason Huangd33b4d82019-05-15 18:22:57 +0800834 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
835 rx_cfg.rx_cb = OnuIndication;
836 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huangb1fad572019-05-28 19:02:30 +0800837 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_ranging_completed;
838
Jason Huangd33b4d82019-05-15 18:22:57 +0800839 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
840 if(rc != BCM_ERR_OK)
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700841 return Status(grpc::StatusCode::INTERNAL, "onu indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000842
Jason Huangd33b4d82019-05-15 18:22:57 +0800843 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
Jason Huangd33b4d82019-05-15 18:22:57 +0800844 rx_cfg.rx_cb = OnuStartupFailureIndication;
845 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
846 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
847 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
848 if(rc != BCM_ERR_OK)
849 return Status(grpc::StatusCode::INTERNAL,
850 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000851
Jason Huangd33b4d82019-05-15 18:22:57 +0800852 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
853 rx_cfg.rx_cb = OnuSignalDegradeIndication;
854 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
855 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
856 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
857 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400858 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400859
Jason Huangd33b4d82019-05-15 18:22:57 +0800860 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
861 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
862 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
863 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
864 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
865 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400866 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400867
868 /* LOOCI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800869 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
870 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
871 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
872 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
873 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
874 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400875 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400876
877 /* SFI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800878 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
879 rx_cfg.rx_cb = OnuSignalsFailureIndication;
880 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
881 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
882 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
883 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400884 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400885
886 /* TIWI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800887 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
888 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
889 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
890 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
891 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
892 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400893 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Jason Huangd33b4d82019-05-15 18:22:57 +0800894
895 /* ONU Activation Failure Indiction */
896 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
897 rx_cfg.rx_cb = OnuActivationFailureIndication;
898 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huangb1fad572019-05-28 19:02:30 +0800899 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
Jason Huangd33b4d82019-05-15 18:22:57 +0800900 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
901 if(rc != BCM_ERR_OK)
902 return Status(grpc::StatusCode::INTERNAL,
903 "onu activation falaire indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400904
Jason Huangd33b4d82019-05-15 18:22:57 +0800905 rx_cfg.obj_type = BCMOLT_OBJ_ID_FLOW;
906 rx_cfg.rx_cb = PacketIndication;
907 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
908 rx_cfg.subgroup = bcmolt_flow_auto_subgroup_receive_eth_packet;
909 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
910 if(rc != BCM_ERR_OK)
911 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400912
Shad Ansari01b0e652018-04-05 21:02:53 +0000913 subscribed = true;
914
915 return Status::OK;
916}