blob: ad71cee95349ee5a5b572b9899741e2ee326e0a3 [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 Huangd33b4d82019-05-15 18:22:57 +080062
63std::string bcmbal_to_grpc_intf_type(bcmolt_interface_type intf_type)
Craig Lutgen88a22ad2018-10-04 12:30:46 -050064{
Jason Huangd33b4d82019-05-15 18:22:57 +080065 if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050066 return "nni";
Jason Huangd33b4d82019-05-15 18:22:57 +080067 } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050068 return "pon";
69 }
70 return "unknown";
71}
72
Jason Huangd33b4d82019-05-15 18:22:57 +080073static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +000074 openolt::Indication ind;
75 openolt::OltIndication* olt_ind = new openolt::OltIndication;
76 Status status;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050077 std::string admin_state;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050078
Jason Huangd33b4d82019-05-15 18:22:57 +080079 switch (msg->subgroup) {
80 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE:
Jason Huangd33b4d82019-05-15 18:22:57 +080081 admin_state = "up";
82 olt_ind->set_oper_state("up");
83 break;
84 case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE:
85 admin_state = "down";
86 olt_ind->set_oper_state("down");
87 break;
88 case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE:
89 admin_state = "failure";
90 olt_ind->set_oper_state("failure");
91 break;
Shad Ansari01b0e652018-04-05 21:02:53 +000092 }
93 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050094
Jason Huangd33b4d82019-05-15 18:22:57 +080095 if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) {
Jason Huangd33b4d82019-05-15 18:22:57 +080096 /* register for omci indication */
97 {
98 bcmolt_rx_cfg rx_cfg = {};
99 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
100 rx_cfg.rx_cb = OmciIndication;
101 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet;
102 rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT;
103 bcmolt_ind_subscribe(current_device, &rx_cfg);
104 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500105 state.activate();
106 }
107 else {
108 state.deactivate();
109 }
110
Jason Huangd33b4d82019-05-15 18:22:57 +0800111 oltIndQ.push(ind);
112 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000113}
114
Jason Huangd33b4d82019-05-15 18:22:57 +0800115static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000116 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400117 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
118 openolt::LosIndication* los_ind = new openolt::LosIndication;
119
Jason Huangd33b4d82019-05-15 18:22:57 +0800120 switch (msg->obj_type) {
121 case BCMOLT_OBJ_ID_PON_INTERFACE:
122 switch (msg->subgroup) {
123 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS:
124 {
125 bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg;
126 int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni,
127 BCMOLT_INTERFACE_TYPE_PON);
128 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400129
Jason Huangd33b4d82019-05-15 18:22:57 +0800130 BCM_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n",
131 bcm_los_ind->key.pon_ni, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400132
Jason Huangd33b4d82019-05-15 18:22:57 +0800133 los_ind->set_intf_id(intf_id);
134 los_ind->set_status(status);
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400135
Jason Huangd33b4d82019-05-15 18:22:57 +0800136 alarm_ind->set_allocated_los_ind(los_ind);
137 ind.set_allocated_alarm_ind(alarm_ind);
138 break;
139 }
140 }
141 }
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400142
143 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800144 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000145}
146
Jason Huangd33b4d82019-05-15 18:22:57 +0800147static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700148 openolt::Indication ind;
149 openolt::IntfIndication* intf_ind = new openolt::IntfIndication;
150
Jason Huangd33b4d82019-05-15 18:22:57 +0800151 switch (msg->obj_type) {
152 case BCMOLT_OBJ_ID_PON_INTERFACE:
153 switch (msg->subgroup) {
154 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
155 {
Jason Huangd33b4d82019-05-15 18:22:57 +0800156 bcmolt_pon_interface_key *key =
157 &((bcmolt_pon_interface_state_change_completed*)msg)->key;
158 bcmolt_pon_interface_state_change_completed_data *data =
159 &((bcmolt_pon_interface_state_change_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700160
Jason Huangd33b4d82019-05-15 18:22:57 +0800161 intf_ind->set_intf_id(key->pon_ni);
162 if (INTERFACE_STATE_IF_UP(data->new_state))
163 intf_ind->set_oper_state("up");
164 if (INTERFACE_STATE_IF_DOWN(data->new_state))
165 intf_ind->set_oper_state("down");
166 ind.set_allocated_intf_ind(intf_ind);
167 break;
168 }
169 }
170 break;
171 case BCMOLT_OBJ_ID_NNI_INTERFACE:
172 switch (msg->subgroup) {
173 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
174 {
175 BCM_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n",
176 ((bcmolt_nni_interface_state_change *)msg)->key.id);
177 bcmolt_nni_interface_key *key =
178 &((bcmolt_nni_interface_state_change *)msg)->key;
179 bcmolt_nni_interface_state_change_data *data =
180 &((bcmolt_nni_interface_state_change *)msg)->data;
181
182 intf_ind->set_intf_id(key->id);
183 if (INTERFACE_STATE_IF_UP(data->new_state))
184 intf_ind->set_oper_state("up");
185 if (INTERFACE_STATE_IF_DOWN(data->new_state))
186 intf_ind->set_oper_state("down");
187 ind.set_allocated_intf_ind(intf_ind);
188 break;
189 }
190 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700191 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700192
193 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800194 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700195}
196
Jason Huangd33b4d82019-05-15 18:22:57 +0800197static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000198 openolt::Indication ind;
199 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000200
Jason Huangd33b4d82019-05-15 18:22:57 +0800201 switch (msg->obj_type) {
202 case BCMOLT_OBJ_ID_PON_INTERFACE:
203 switch (msg->subgroup) {
204 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED:
205 {
206 bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key;
207 bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data;
208 intf_oper_ind->set_intf_id(key->pon_ni);
209 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON));
210 if (INTERFACE_STATE_IF_UP(data->new_state))
211 intf_oper_ind->set_oper_state("up");
212 if (INTERFACE_STATE_IF_DOWN(data->new_state))
213 intf_oper_ind->set_oper_state("down");
Shad Ansari01b0e652018-04-05 21:02:53 +0000214
Jason Huangd33b4d82019-05-15 18:22:57 +0800215 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
216 intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str());
217 ind.set_allocated_intf_oper_ind(intf_oper_ind);
218 break;
219 }
220 }
221 case BCMOLT_OBJ_ID_NNI_INTERFACE:
222 switch (msg->subgroup) {
223 case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE:
224 {
225 bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key;
226 bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data;
227 bcmolt_interface intf_id = key->id;
228 bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI;
229 intf_oper_ind->set_intf_id(key->id);
230 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI));
231
232 if (INTERFACE_STATE_IF_UP(data->new_state))
233 intf_oper_ind->set_oper_state("up");
234 if (INTERFACE_STATE_IF_DOWN(data->new_state))
235 intf_oper_ind->set_oper_state("down");
236
237 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n",
238 intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str());
239 ind.set_allocated_intf_oper_ind(intf_oper_ind);
240 break;
241 }
242 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000243 }
244
Shad Ansari01b0e652018-04-05 21:02:53 +0000245 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800246 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000247}
248
Jason Huangd33b4d82019-05-15 18:22:57 +0800249static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000250 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400251 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
252 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
253
Jason Huangd33b4d82019-05-15 18:22:57 +0800254 switch (msg->obj_type) {
255 case BCMOLT_OBJ_ID_ONU:
256 switch (msg->subgroup) {
257 case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM:
258 {
259 bcmolt_xgpon_onu_alarms *onu_alarms =
260 &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm;
261 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
262 onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi));
263 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(
264 onu_alarms->lopci_miss));
265 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(
266 onu_alarms->lopci_mic_error));
267
268 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
269 ind.set_allocated_alarm_ind(alarm_ind);
270 break;
271 }
272 case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM:
273 {
274 bcmolt_gpon_onu_alarms *onu_alarms =
275 &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm;
276 onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi));
277 /* TODO: need to set lofi and loami
278 onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi));
279 onu_alarm_ind->set_loami_status(alarm_status_to_string(
280 onu_alarms->loami));
281 */
282 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
283 ind.set_allocated_alarm_ind(alarm_ind);
284 break;
285 }
286 }
287 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400288
289 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800290 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000291}
292
Jason Huangd33b4d82019-05-15 18:22:57 +0800293static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000294 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400295 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
Jason Huangd33b4d82019-05-15 18:22:57 +0800296 openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400297
Jason Huangd33b4d82019-05-15 18:22:57 +0800298 switch (msg->obj_type) {
299 case BCMOLT_OBJ_ID_ONU:
300 switch (msg->subgroup) {
301 case BCMOLT_ONU_AUTO_SUBGROUP_DGI:
302 {
303 bcmolt_onu_dgi_data* dgi_data = (bcmolt_onu_dgi_data *)msg;
304 dgi_ind->set_status(alarm_status_to_string(dgi_data->alarm_status));
nickc063ffd2018-05-22 14:35:28 -0400305
Jason Huangd33b4d82019-05-15 18:22:57 +0800306 alarm_ind->set_allocated_dying_gasp_ind(dgi_ind);
307 ind.set_allocated_alarm_ind(alarm_ind);
308 break;
309 }
310 }
311 }
nickc063ffd2018-05-22 14:35:28 -0400312
313 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800314 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000315}
316
Jason Huangd33b4d82019-05-15 18:22:57 +0800317static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000318 openolt::Indication ind;
319 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
320 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
321
Jason Huangd33b4d82019-05-15 18:22:57 +0800322 switch (msg->obj_type) {
323 case BCMOLT_OBJ_ID_PON_INTERFACE:
324 switch (msg->subgroup) {
325 case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED:
326 {
327 bcmolt_pon_interface_key *key =
328 &((bcmolt_pon_interface_onu_discovered *)msg)->key;
Shad Ansari01b0e652018-04-05 21:02:53 +0000329
Jason Huangd33b4d82019-05-15 18:22:57 +0800330 bcmolt_pon_interface_onu_discovered_data *data =
331 &((bcmolt_pon_interface_onu_discovered *)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000332
Jason Huangd33b4d82019-05-15 18:22:57 +0800333 bcmolt_serial_number *in_serial_number = &(data->serial_number);
Shad Ansari01b0e652018-04-05 21:02:53 +0000334
Jason Huangd33b4d82019-05-15 18:22:57 +0800335 BCM_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n",
336 key->pon_ni, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000337
Jason Huangd33b4d82019-05-15 18:22:57 +0800338 onu_disc_ind->set_intf_id(key->pon_ni);
339 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4);
340 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8);
341 onu_disc_ind->set_allocated_serial_number(serial_number);
342 ind.set_allocated_onu_disc_ind(onu_disc_ind);
343 break;
344 }
345 }
346 }
Shad Ansari01b0e652018-04-05 21:02:53 +0000347
348 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800349 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000350}
351
Jason Huangd33b4d82019-05-15 18:22:57 +0800352static void OnuIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700353 openolt::Indication ind;
354 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
355
Jason Huangd33b4d82019-05-15 18:22:57 +0800356 switch (msg->obj_type) {
357 case BCMOLT_OBJ_ID_ONU:
358 switch (msg->subgroup) {
Jason Huangb1fad572019-05-28 19:02:30 +0800359 case BCMOLT_ONU_AUTO_SUBGROUP_RANGING_COMPLETED:
Jason Huangd33b4d82019-05-15 18:22:57 +0800360 {
Jason Huangb1fad572019-05-28 19:02:30 +0800361 bcmolt_onu_key *key = &((bcmolt_onu_ranging_completed*)msg)->key;
362 bcmolt_onu_ranging_completed_data *data = &((bcmolt_onu_ranging_completed*)msg)->data;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700363
Jason Huangb1fad572019-05-28 19:02:30 +0800364 BCM_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s\n",
365 key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700366
Jason Huangd33b4d82019-05-15 18:22:57 +0800367 onu_ind->set_intf_id(key->pon_ni);
368 onu_ind->set_onu_id(key->onu_id);
Jason Huangb1fad572019-05-28 19:02:30 +0800369 if (ONU_RANGING_STATE_IF_UP(data->status))
Jason Huangd33b4d82019-05-15 18:22:57 +0800370 onu_ind->set_oper_state("up");
Jason Huangb1fad572019-05-28 19:02:30 +0800371 if (ONU_RANGING_STATE_IF_DOWN(data->status))
Jason Huangd33b4d82019-05-15 18:22:57 +0800372 onu_ind->set_oper_state("down");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700373
Jason Huangd33b4d82019-05-15 18:22:57 +0800374 ind.set_allocated_onu_ind(onu_ind);
375 }
376 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700377 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700378
379 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800380 bcmolt_msg_free(msg);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700381}
382
Jason Huangd33b4d82019-05-15 18:22:57 +0800383static void OnuOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000384 openolt::Indication ind;
nickc063ffd2018-05-22 14:35:28 -0400385 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
nickc063ffd2018-05-22 14:35:28 -0400386
Jason Huangd33b4d82019-05-15 18:22:57 +0800387 switch (msg->obj_type) {
388 case BCMOLT_OBJ_ID_ONU:
389 switch (msg->subgroup) {
390 case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE:
391 {
392 bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key;
393 bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data;
nickc063ffd2018-05-22 14:35:28 -0400394
Jason Huangd33b4d82019-05-15 18:22:57 +0800395 onu_ind->set_intf_id(key->pon_ni);
396 onu_ind->set_onu_id(key->onu_id);
397 if (ONU_STATE_IF_UP(data->new_onu_state))
398 onu_ind->set_oper_state("up");
399 if (ONU_STATE_IF_DOWN(data->new_onu_state))
400 onu_ind->set_oper_state("down");
401 ind.set_allocated_onu_ind(onu_ind);
nickc063ffd2018-05-22 14:35:28 -0400402
Jason Huangd33b4d82019-05-15 18:22:57 +0800403 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",
404 key->pon_ni, key->onu_id, data->new_onu_state, onu_ind->oper_state().c_str());
405 }
406 }
nickc063ffd2018-05-22 14:35:28 -0400407 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500408
nickc063ffd2018-05-22 14:35:28 -0400409 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800410 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000411}
412
Jason Huangd33b4d82019-05-15 18:22:57 +0800413static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000414 openolt::Indication ind;
415 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000416
Jason Huangd33b4d82019-05-15 18:22:57 +0800417 switch (msg->obj_type) {
418 case BCMOLT_OBJ_ID_ONU:
419 switch (msg->subgroup) {
420 case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET:
421 {
422 bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key;
423 bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data;
Shad Ansari01b0e652018-04-05 21:02:53 +0000424
Jason Huangd33b4d82019-05-15 18:22:57 +0800425 BCM_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n",
426 key->pon_ni, key->onu_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000427
Jason Huangd33b4d82019-05-15 18:22:57 +0800428 omci_ind->set_intf_id(key->pon_ni);
429 omci_ind->set_onu_id(key->onu_id);
430 omci_ind->set_pkt(data->buffer.arr, data->buffer.len);
431
432 ind.set_allocated_omci_ind(omci_ind);
433 break;
434 }
435 }
436 }
437
Shad Ansari01b0e652018-04-05 21:02:53 +0000438 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800439 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000440}
441
Jason Huangd33b4d82019-05-15 18:22:57 +0800442static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000443 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000444 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000445
Jason Huangd33b4d82019-05-15 18:22:57 +0800446 switch (msg->obj_type) {
447 case BCMOLT_OBJ_ID_ONU:
448 switch (msg->subgroup) {
449 case BCMOLT_FLOW_AUTO_SUBGROUP_RECEIVE_ETH_PACKET:
450 {
451 bcmolt_flow_key *key = &((bcmolt_flow_cfg*)msg)->key;
452 bcmolt_flow_cfg_data *data = &((bcmolt_flow_cfg*)msg)->data;
453 bcmolt_flow_receive_eth_packet_data *pkt_data =
454 &((bcmolt_flow_receive_eth_packet*)msg)->data;
Shad Ansari5fe93682018-04-26 05:24:19 +0000455
Jason Huangd33b4d82019-05-15 18:22:57 +0800456 uint32_t port_no = GetPortNum_(key->flow_id);
457 pkt_ind->set_intf_type(bcmbal_to_grpc_intf_type((bcmolt_interface_type)data->ingress_intf.intf_type));
458 pkt_ind->set_intf_id(data->ingress_intf.intf_id);
459 pkt_ind->set_gemport_id(data->svc_port_id);
460 pkt_ind->set_flow_id(key->flow_id);
461 pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len);
462 pkt_ind->set_port_no(port_no);
463 pkt_ind->set_cookie(data->cookie);
464 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500465
Jason Huangd33b4d82019-05-15 18:22:57 +0800466 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",
467 pkt_ind->intf_type().c_str(), data->ingress_intf.intf_id, data->svc_port_id, key->flow_id, port_no, data->cookie);
468 }
469 }
470 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500471
Shad Ansari5fe93682018-04-26 05:24:19 +0000472 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800473 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000474}
475
Jason Huangd33b4d82019-05-15 18:22:57 +0800476static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000477 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400478 BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800479 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000480}
481
Jason Huangd33b4d82019-05-15 18:22:57 +0800482static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000483 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400484 BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800485 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000486}
487
Jason Huangd33b4d82019-05-15 18:22:57 +0800488static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000489 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400490 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800491 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000492}
493
Jason Huangd33b4d82019-05-15 18:22:57 +0800494static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000495 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400496 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800497 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000498}
499
Jason Huangd33b4d82019-05-15 18:22:57 +0800500static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000501 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400502 BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
Jason Huangd33b4d82019-05-15 18:22:57 +0800503 bcmolt_msg_free(msg);
Shad Ansari01b0e652018-04-05 21:02:53 +0000504}
505
Jason Huangd33b4d82019-05-15 18:22:57 +0800506static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400507 openolt::Indication ind;
508 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
509 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
510
Jason Huangd33b4d82019-05-15 18:22:57 +0800511 switch (msg->obj_type) {
512 case BCMOLT_OBJ_ID_ONU:
513 switch (msg->subgroup) {
514 case BCMOLT_ONU_AUTO_SUBGROUP_SUFI:
515 {
516 bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key;
517 bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400518
Jason Huangd33b4d82019-05-15 18:22:57 +0800519 BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
520 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400521
Jason Huangd33b4d82019-05-15 18:22:57 +0800522 sufi_ind->set_intf_id(key->pon_ni);
523 sufi_ind->set_onu_id(key->onu_id);
524 sufi_ind->set_status(alarm_status_to_string(data->alarm_status));
525 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400526
Jason Huangd33b4d82019-05-15 18:22:57 +0800527 ind.set_allocated_alarm_ind(alarm_ind);
528 }
529 }
530 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400531
532 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800533 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400534}
535
Jason Huangd33b4d82019-05-15 18:22:57 +0800536static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400537 openolt::Indication ind;
538 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
539 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
540
Jason Huangd33b4d82019-05-15 18:22:57 +0800541 switch (msg->obj_type) {
542 case BCMOLT_OBJ_ID_ONU:
543 switch (msg->subgroup) {
544 case BCMOLT_ONU_AUTO_SUBGROUP_SDI:
545 {
546 bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key;
547 bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400548
Jason Huangd33b4d82019-05-15 18:22:57 +0800549 BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
550 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400551
Jason Huangd33b4d82019-05-15 18:22:57 +0800552 sdi_ind->set_intf_id(key->pon_ni);
553 sdi_ind->set_onu_id(key->onu_id);
554 sdi_ind->set_status(alarm_status_to_string(data->alarm_status));
555 sdi_ind->set_inverse_bit_error_rate(data->ber);
556 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400557
Jason Huangd33b4d82019-05-15 18:22:57 +0800558 ind.set_allocated_alarm_ind(alarm_ind);
559 }
560 }
561 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400562
563 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800564 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400565}
566
Jason Huangd33b4d82019-05-15 18:22:57 +0800567static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400568 openolt::Indication ind;
569 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
570 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
571
Jason Huangd33b4d82019-05-15 18:22:57 +0800572 switch (msg->obj_type) {
573 case BCMOLT_OBJ_ID_ONU:
574 switch (msg->subgroup) {
575 case BCMOLT_ONU_AUTO_SUBGROUP_DOWI:
576 {
577 bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key;
578 bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400579
Jason Huangd33b4d82019-05-15 18:22:57 +0800580 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",
581 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400582
Jason Huangd33b4d82019-05-15 18:22:57 +0800583 dowi_ind->set_intf_id(key->pon_ni);
584 dowi_ind->set_onu_id(key->onu_id);
585 dowi_ind->set_status(alarm_status_to_string(data->alarm_status));
586 dowi_ind->set_drift(data->drift_value);
587 dowi_ind->set_new_eqd(data->new_eqd);
588 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400589
Jason Huangd33b4d82019-05-15 18:22:57 +0800590 ind.set_allocated_alarm_ind(alarm_ind);
591 }
592 }
593 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400594
595 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800596 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400597}
598
Jason Huangd33b4d82019-05-15 18:22:57 +0800599static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400600 openolt::Indication ind;
601 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
602 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
603
Jason Huangd33b4d82019-05-15 18:22:57 +0800604 switch (msg->obj_type) {
605 case BCMOLT_OBJ_ID_ONU:
606 switch (msg->subgroup) {
607 case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI:
608 {
609 bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key;
610 bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400611
Jason Huangd33b4d82019-05-15 18:22:57 +0800612 BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
613 key->pon_ni, key->onu_id, data->alarm_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400614
Jason Huangd33b4d82019-05-15 18:22:57 +0800615 looci_ind->set_intf_id(key->pon_ni);
616 looci_ind->set_onu_id(key->onu_id);
617 looci_ind->set_status(alarm_status_to_string(data->alarm_status));
618 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400619
Jason Huangd33b4d82019-05-15 18:22:57 +0800620 ind.set_allocated_alarm_ind(alarm_ind);
621 }
622 }
623 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400624
625 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800626 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400627}
628
Jason Huangd33b4d82019-05-15 18:22:57 +0800629static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400630 openolt::Indication ind;
631 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
632 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
633
Jason Huangd33b4d82019-05-15 18:22:57 +0800634 switch (msg->obj_type) {
635 case BCMOLT_OBJ_ID_ONU:
636 switch (msg->subgroup) {
637 case BCMOLT_ONU_AUTO_SUBGROUP_SFI:
638 {
639 bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key;
640 bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400641
Jason Huangd33b4d82019-05-15 18:22:57 +0800642 BCM_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
643 key->pon_ni, key->onu_id, data->alarm_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400644
645
Jason Huangd33b4d82019-05-15 18:22:57 +0800646 sfi_ind->set_intf_id(key->pon_ni);
647 sfi_ind->set_onu_id(key->onu_id);
648 sfi_ind->set_status(alarm_status_to_string(data->alarm_status));
649 sfi_ind->set_inverse_bit_error_rate(data->ber);
650 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400651
Jason Huangd33b4d82019-05-15 18:22:57 +0800652 ind.set_allocated_alarm_ind(alarm_ind);
653 }
654 }
655 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400656
657 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800658 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400659}
660
Jason Huangd33b4d82019-05-15 18:22:57 +0800661static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400662 openolt::Indication ind;
663 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
664 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
665
Jason Huangd33b4d82019-05-15 18:22:57 +0800666 switch (msg->obj_type) {
667 case BCMOLT_OBJ_ID_ONU:
668 switch (msg->subgroup) {
669 case BCMOLT_ONU_AUTO_SUBGROUP_TIWI:
670 {
671 bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key;
672 bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400673
Jason Huangd33b4d82019-05-15 18:22:57 +0800674 BCM_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
675 key->pon_ni, key->onu_id, data->alarm_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400676
Jason Huangd33b4d82019-05-15 18:22:57 +0800677 tiwi_ind->set_intf_id(key->pon_ni);
678 tiwi_ind->set_onu_id(key->onu_id);
679 tiwi_ind->set_status(alarm_status_to_string(data->alarm_status));
680 tiwi_ind->set_drift(data->drift_value);
681 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400682
Jason Huangd33b4d82019-05-15 18:22:57 +0800683 ind.set_allocated_alarm_ind(alarm_ind);
684 }
685 }
686 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400687
688 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800689 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400690}
691
Jason Huangd33b4d82019-05-15 18:22:57 +0800692static void OnuActivationFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) {
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400693 openolt::Indication ind;
694 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
695 openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication;
696
Jason Huangd33b4d82019-05-15 18:22:57 +0800697 switch (msg->obj_type) {
698 case BCMOLT_OBJ_ID_ONU:
699 switch (msg->subgroup) {
Jason Huangb1fad572019-05-28 19:02:30 +0800700 case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED:
Jason Huangd33b4d82019-05-15 18:22:57 +0800701 {
702 bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key;
703 bcmolt_onu_onu_activation_completed_data *data =
704 &((bcmolt_onu_onu_activation_completed*)msg)->data;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400705
Jason Huangb1fad572019-05-28 19:02:30 +0800706 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 +0800707 key->pon_ni, key->onu_id, data->fail_reason);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400708
Jason Huangd33b4d82019-05-15 18:22:57 +0800709 activation_fail_ind->set_intf_id(key->pon_ni);
710 activation_fail_ind->set_onu_id(key->onu_id);
Jason Huangb1fad572019-05-28 19:02:30 +0800711 activation_fail_ind->set_fail_reason(data->fail_reason);
Jason Huangd33b4d82019-05-15 18:22:57 +0800712 alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400713
Jason Huangd33b4d82019-05-15 18:22:57 +0800714 ind.set_allocated_alarm_ind(alarm_ind);
715 }
716 }
717 }
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400718
719 oltIndQ.push(ind);
Jason Huangd33b4d82019-05-15 18:22:57 +0800720 bcmolt_msg_free(msg);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400721}
722
Jason Huangd33b4d82019-05-15 18:22:57 +0800723/* removed by BAL v3.0
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400724bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
725 openolt::Indication ind;
726 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
727 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
728
729 bcmbal_subscriber_terminal_key *key =
730 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
731
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400732 BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
733 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400734
735
736 onu_proc_error_ind->set_intf_id(key->intf_id);
737 onu_proc_error_ind->set_onu_id(key->sub_term_id);
738
739 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
740 ind.set_allocated_alarm_ind(alarm_ind);
741
742 oltIndQ.push(ind);
743 return BCM_ERR_OK;
744}
Jason Huangd33b4d82019-05-15 18:22:57 +0800745*/
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400746
Shad Ansari01b0e652018-04-05 21:02:53 +0000747Status SubscribeIndication() {
Jason Huangd33b4d82019-05-15 18:22:57 +0800748 bcmolt_rx_cfg rx_cfg = {};
749 bcmos_errno rc;
Shad Ansari01b0e652018-04-05 21:02:53 +0000750
751 if (subscribed) {
752 return Status::OK;
753 }
754
Jason Huangd33b4d82019-05-15 18:22:57 +0800755 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
756 rx_cfg.rx_cb = OltOperIndication;
757 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
758 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete;
759 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
760 if(rc != BCM_ERR_OK)
761 return Status(grpc::StatusCode::INTERNAL,
762 "Olt connection complete state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000763
Jason Huangd33b4d82019-05-15 18:22:57 +0800764 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
765 rx_cfg.rx_cb = OltOperIndication;
766 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
767 rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete;
768 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
769 if(rc != BCM_ERR_OK)
770 return Status(grpc::StatusCode::INTERNAL,
771 "Olt disconnection complete state indication subscribe failed");
772
773 rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE;
774 rx_cfg.rx_cb = OltOperIndication;
775 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
776 rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure;
777 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
778 if(rc != BCM_ERR_OK)
779 return Status(grpc::StatusCode::INTERNAL,
780 "Olt connection failure state indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000781
782 /* Interface LOS indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800783 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
784 rx_cfg.rx_cb = LosIndication;
785 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
786 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los;
787 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
788 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000789 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000790
Jason Huangd33b4d82019-05-15 18:22:57 +0800791 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
792 rx_cfg.rx_cb = IfOperIndication;
793 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
794 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
795 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
796 if(rc != BCM_ERR_OK)
797 return Status(grpc::StatusCode::INTERNAL,
798 "PON Interface operations state change indication subscribe failed");
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700799
Jason Huangd33b4d82019-05-15 18:22:57 +0800800 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
801 rx_cfg.rx_cb = IfIndication;
802 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
803 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed;
804 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
805 if(rc != BCM_ERR_OK)
806 return Status(grpc::StatusCode::INTERNAL, "PON Interface indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000807
Jason Huangd33b4d82019-05-15 18:22:57 +0800808 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
809 rx_cfg.rx_cb = IfOperIndication;
810 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
811 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
812 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
813 if(rc != BCM_ERR_OK)
814 return Status(grpc::StatusCode::INTERNAL,
815 "NNI Interface operations state change indication subscribe failed");
816
817 rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE;
818 rx_cfg.rx_cb = IfIndication;
819 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
820 rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change;
821 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
822 if(rc != BCM_ERR_OK)
823 return Status(grpc::StatusCode::INTERNAL, "NNI Interface indication subscribe failed");
824
825 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
826 rx_cfg.rx_cb = OnuAlarmIndication;
827 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
828 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm;
829 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
830 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000831 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000832
Jason Huangd33b4d82019-05-15 18:22:57 +0800833 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
834 rx_cfg.rx_cb = OnuAlarmIndication;
835 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
836 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm;
837 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
838 if(rc != BCM_ERR_OK)
839 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
840
841 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
842 rx_cfg.rx_cb = OnuDyingGaspIndication;
843 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
844 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi;
845 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
846 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000847 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000848
Jason Huangd33b4d82019-05-15 18:22:57 +0800849 rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE;
850 rx_cfg.rx_cb = OnuDiscoveryIndication;
851 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
852 rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered;
853 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
854 if(rc != BCM_ERR_OK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000855 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000856
Jason Huangd33b4d82019-05-15 18:22:57 +0800857 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
858 rx_cfg.rx_cb = OnuIndication;
859 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huangb1fad572019-05-28 19:02:30 +0800860 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_ranging_completed;
861
Jason Huangd33b4d82019-05-15 18:22:57 +0800862 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
863 if(rc != BCM_ERR_OK)
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700864 return Status(grpc::StatusCode::INTERNAL, "onu indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000865
Jason Huangd33b4d82019-05-15 18:22:57 +0800866 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
867 rx_cfg.rx_cb = OnuOperIndication;
868 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
869 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_state_change;
870 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
871 if(rc != BCM_ERR_OK)
872 return Status(grpc::StatusCode::INTERNAL,
873 "onu operational state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000874
Jason Huangd33b4d82019-05-15 18:22:57 +0800875 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
876 rx_cfg.rx_cb = OnuStartupFailureIndication;
877 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
878 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi;
879 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
880 if(rc != BCM_ERR_OK)
881 return Status(grpc::StatusCode::INTERNAL,
882 "onu startup failure indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000883
Jason Huangd33b4d82019-05-15 18:22:57 +0800884 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
885 rx_cfg.rx_cb = OnuSignalDegradeIndication;
886 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
887 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi;
888 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
889 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400890 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400891
Jason Huangd33b4d82019-05-15 18:22:57 +0800892 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
893 rx_cfg.rx_cb = OnuDriftOfWindowIndication;
894 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
895 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi;
896 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
897 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400898 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400899
900 /* LOOCI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800901 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
902 rx_cfg.rx_cb = OnuLossOfOmciChannelIndication;
903 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
904 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci;
905 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
906 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400907 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400908
909 /* SFI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800910 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
911 rx_cfg.rx_cb = OnuSignalsFailureIndication;
912 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
913 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi;
914 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
915 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400916 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400917
918 /* TIWI indication */
Jason Huangd33b4d82019-05-15 18:22:57 +0800919 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
920 rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication;
921 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
922 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi;
923 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
924 if(rc != BCM_ERR_OK)
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400925 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
Jason Huangd33b4d82019-05-15 18:22:57 +0800926
927 /* ONU Activation Failure Indiction */
928 rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU;
929 rx_cfg.rx_cb = OnuActivationFailureIndication;
930 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
Jason Huangb1fad572019-05-28 19:02:30 +0800931 rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed;
Jason Huangd33b4d82019-05-15 18:22:57 +0800932 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
933 if(rc != BCM_ERR_OK)
934 return Status(grpc::StatusCode::INTERNAL,
935 "onu activation falaire indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400936
Jason Huangd33b4d82019-05-15 18:22:57 +0800937 rx_cfg.obj_type = BCMOLT_OBJ_ID_FLOW;
938 rx_cfg.rx_cb = PacketIndication;
939 rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE;
940 rx_cfg.subgroup = bcmolt_flow_auto_subgroup_receive_eth_packet;
941 rc = bcmolt_ind_subscribe(current_device, &rx_cfg);
942 if(rc != BCM_ERR_OK)
943 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400944
Shad Ansari01b0e652018-04-05 21:02:53 +0000945 subscribed = true;
946
947 return Status::OK;
948}