blob: 5807c0b3c4074fec0117ac4dd8fb39264b2d566c [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>
29#include <bal_api.h>
30#include <bal_api_end.h>
31}
32
33using grpc::Status;
34
Shad Ansari627b5782018-08-13 22:49:32 +000035extern Queue<openolt::Indication> oltIndQ;
Shad Ansari01b0e652018-04-05 21:02:53 +000036//Queue<openolt::Indication*> oltIndQ;
37
Nicolas Palpacuer3cad49d2018-07-02 14:03:24 -040038
Shad Ansari01b0e652018-04-05 21:02:53 +000039bool subscribed = false;
40
41bcmos_errno OmciIndication(bcmbal_obj *obj);
42
Craig Lutgen88a22ad2018-10-04 12:30:46 -050043std::string bcmbal_to_grpc_intf_type(bcmbal_intf_type intf_type)
44{
45 if (intf_type == BCMBAL_INTF_TYPE_NNI) {
46 return "nni";
47 } else if (intf_type == BCMBAL_INTF_TYPE_PON) {
48 return "pon";
49 }
50 return "unknown";
51}
52
53bcmos_errno OltOperIndication(bcmbal_obj *obj) {
Shad Ansari01b0e652018-04-05 21:02:53 +000054 openolt::Indication ind;
55 openolt::OltIndication* olt_ind = new openolt::OltIndication;
56 Status status;
57
Shad Ansaricb004c52018-05-30 18:07:23 +000058 bcmbal_access_terminal_oper_status_change *acc_term_ind = (bcmbal_access_terminal_oper_status_change *)obj;
Craig Lutgen88a22ad2018-10-04 12:30:46 -050059 std::string admin_state;
60 if (acc_term_ind->data.admin_state == BCMBAL_STATE_UP) {
61 admin_state = "up";
62 } else {
63 admin_state = "down";
64 }
65
Shad Ansaricb004c52018-05-30 18:07:23 +000066 if (acc_term_ind->data.new_oper_status == BCMBAL_STATUS_UP) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -050067 // Determine device capabilities before transitionto acive state
68 ProbeDeviceCapabilities_();
Shad Ansari01b0e652018-04-05 21:02:53 +000069 olt_ind->set_oper_state("up");
70 } else {
71 olt_ind->set_oper_state("down");
72 }
73 ind.set_allocated_olt_ind(olt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050074
75 BCM_LOG(INFO, openolt_log_id, "Olt oper status indication, admin_state: %s oper_state: %s\n",
76 admin_state.c_str(),
77 olt_ind->oper_state().c_str());
78
Shad Ansari01b0e652018-04-05 21:02:53 +000079 oltIndQ.push(ind);
80
Craig Lutgen88a22ad2018-10-04 12:30:46 -050081 // Enable all PON interfaces.
82 //
83 for (int i = 0; i < NumPonIf_(); i++) {
Shad Ansari01b0e652018-04-05 21:02:53 +000084 status = EnablePonIf_(i);
85 if (!status.ok()) {
86 // FIXME - raise alarm to report error in enabling PON
87 }
88 }
89
Craig Lutgend0bae9b2018-10-18 18:02:07 -050090 // Enable all NNI interfaces.
91 //
92 for (int i = 0; i < NumNniIf_(); i++) {
93 status = EnableUplinkIf_(i);
94 if (!status.ok()) {
95 // FIXME - raise alarm to report error in enabling PON
96 }
97 }
98
Shad Ansari01b0e652018-04-05 21:02:53 +000099 /* register for omci indication */
100 {
101 bcmbal_cb_cfg cb_cfg = {};
102 uint16_t ind_subgroup;
103
104 cb_cfg.module = BCMOS_MODULE_ID_NONE;
105 cb_cfg.obj_type = BCMBAL_OBJ_ID_PACKET;
106 ind_subgroup = BCMBAL_IND_SUBGROUP(packet, itu_omci_channel_rx);
107 cb_cfg.p_object_key_info = NULL;
108 cb_cfg.p_subgroup = &ind_subgroup;
109 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OmciIndication;
110 bcmbal_subscribe_ind(0, &cb_cfg);
111 }
112
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500113 if (acc_term_ind->data.new_oper_status == BCMBAL_STATUS_UP) {
114 ProbePonIfTechnology_();
115 state.activate();
116 }
117 else {
118 state.deactivate();
119 }
120
Shad Ansari01b0e652018-04-05 21:02:53 +0000121 return BCM_ERR_OK;
122}
123
124bcmos_errno LosIndication(bcmbal_obj *obj) {
125 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400126 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
127 openolt::LosIndication* los_ind = new openolt::LosIndication;
128
129 bcmbal_interface_los* bcm_los_ind = (bcmbal_interface_los *) obj;
130 int intf_id = interface_key_to_port_no(bcm_los_ind->key);
131 std::string status = alarm_status_to_string(bcm_los_ind->data.status);
132
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500133 BCM_LOG(INFO, openolt_log_id, "LOS indication : intf_type: %d intf_id: %d port: %d status %s\n",
134 bcm_los_ind->key.intf_type, bcm_los_ind->key.intf_id, intf_id, status.c_str());
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400135
136 los_ind->set_intf_id(intf_id);
137 los_ind->set_status(status);
138
139 alarm_ind->set_allocated_los_ind(los_ind);
140 ind.set_allocated_alarm_ind(alarm_ind);
141
142 oltIndQ.push(ind);
Shad Ansari01b0e652018-04-05 21:02:53 +0000143 return BCM_ERR_OK;
144}
145
Shad Ansari01b0e652018-04-05 21:02:53 +0000146bcmos_errno IfOperIndication(bcmbal_obj *obj) {
147 openolt::Indication ind;
148 openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500149 bcmbal_interface_oper_status_change* bcm_if_oper_ind = (bcmbal_interface_oper_status_change *) obj;
Shad Ansari01b0e652018-04-05 21:02:53 +0000150
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500151 intf_oper_ind->set_type(bcmbal_to_grpc_intf_type(bcm_if_oper_ind->key.intf_type));
152 intf_oper_ind->set_intf_id(bcm_if_oper_ind->key.intf_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000153
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500154 if (bcm_if_oper_ind->data.new_oper_status == BCMBAL_STATUS_UP) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000155 intf_oper_ind->set_oper_state("up");
156 } else {
157 intf_oper_ind->set_oper_state("down");
158 }
159
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500160 BCM_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %d, admin_state %d\n",
161 intf_oper_ind->type().c_str(),
162 bcm_if_oper_ind->key.intf_id,
163 intf_oper_ind->oper_state().c_str(),
164 bcm_if_oper_ind->data.admin_state);
165
Shad Ansari01b0e652018-04-05 21:02:53 +0000166 ind.set_allocated_intf_oper_ind(intf_oper_ind);
167
168 oltIndQ.push(ind);
169 return BCM_ERR_OK;
170}
171
172bcmos_errno OnuAlarmIndication(bcmbal_obj *obj) {
173 openolt::Indication ind;
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400174 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
175 openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication;
176
177 bcmbal_subscriber_terminal_key *key =
178 &((bcmbal_subscriber_terminal_sub_term_alarm*)obj)->key;
179
180 bcmbal_subscriber_terminal_alarms *alarms =
181 &(((bcmbal_subscriber_terminal_sub_term_alarm*)obj)->data.alarm);
182
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400183 BCM_LOG(WARNING, openolt_log_id, "onu alarm indication intf_id %d, onu_id %d, alarm: los %d, lob %d, lopc_miss %d, lopc_mic_error %d\n",
184 key->intf_id, key->sub_term_id, alarms->los, alarms->lob, alarms->lopc_miss, alarms->lopc_mic_error);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400185
186 onu_alarm_ind->set_intf_id(key->intf_id);
187 onu_alarm_ind->set_onu_id(key->sub_term_id);
188 onu_alarm_ind->set_los_status(alarm_status_to_string(alarms->los));
189 onu_alarm_ind->set_lob_status(alarm_status_to_string(alarms->lob));
190 onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(alarms->lopc_miss));
191 onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(alarms->lopc_mic_error));
192
193 alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind);
194 ind.set_allocated_alarm_ind(alarm_ind);
195
196 oltIndQ.push(ind);
Shad Ansari01b0e652018-04-05 21:02:53 +0000197 return BCM_ERR_OK;
198}
199
200bcmos_errno OnuDyingGaspIndication(bcmbal_obj *obj) {
201 openolt::Indication ind;
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400202 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
203 openolt::DyingGaspIndication* dg_ind = new openolt::DyingGaspIndication;
nickc063ffd2018-05-22 14:35:28 -0400204
205 bcmbal_subscriber_terminal_key *key =
206 &(((bcmbal_subscriber_terminal_dgi*)obj)->key);
207
208 bcmbal_subscriber_terminal_dgi_data *data =
209 &(((bcmbal_subscriber_terminal_dgi*)obj)->data);
210
211
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400212 BCM_LOG(WARNING, openolt_log_id, "onu dying-gasp indication, intf_id %d, onu_id %d, alarm %d\n",
213 key->intf_id, key->sub_term_id, data->dgi_status);
nickc063ffd2018-05-22 14:35:28 -0400214
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400215 dg_ind->set_intf_id(key->intf_id);
216 dg_ind->set_onu_id(key->sub_term_id);
217 dg_ind->set_status(alarm_status_to_string(data->dgi_status));
nickc063ffd2018-05-22 14:35:28 -0400218
Nicolas Palpacuera32f4c32018-06-28 12:55:10 -0400219 alarm_ind->set_allocated_dying_gasp_ind(dg_ind);
220 ind.set_allocated_alarm_ind(alarm_ind);
nickc063ffd2018-05-22 14:35:28 -0400221
222 oltIndQ.push(ind);
Shad Ansari01b0e652018-04-05 21:02:53 +0000223 return BCM_ERR_OK;
224}
225
226bcmos_errno OnuDiscoveryIndication(bcmbal_cfg *obj) {
227 openolt::Indication ind;
228 openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication;
229 openolt::SerialNumber* serial_number = new openolt::SerialNumber;
230
231 bcmbal_subscriber_terminal_key *key =
232 &(((bcmbal_subscriber_terminal_sub_term_disc*)obj)->key);
233
234 bcmbal_subscriber_terminal_sub_term_disc_data *data =
235 &(((bcmbal_subscriber_terminal_sub_term_disc*)obj)->data);
236
237 bcmbal_serial_number *in_serial_number = &(data->serial_number);
238
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400239 BCM_LOG(INFO, openolt_log_id, "onu discover indication, intf_id %d, serial_number %s\n",
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500240 key->intf_id, serial_number_to_str(in_serial_number).c_str());
Shad Ansari01b0e652018-04-05 21:02:53 +0000241
242 onu_disc_ind->set_intf_id(key->intf_id);
243 serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id), 4);
244 serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific), 8);
245 onu_disc_ind->set_allocated_serial_number(serial_number);
246 ind.set_allocated_onu_disc_ind(onu_disc_ind);
247
248 oltIndQ.push(ind);
249
250 return BCM_ERR_OK;
251}
252
Shad Ansari01b0e652018-04-05 21:02:53 +0000253bcmos_errno OnuOperIndication(bcmbal_obj *obj) {
254 openolt::Indication ind;
nickc063ffd2018-05-22 14:35:28 -0400255 openolt::OnuIndication* onu_ind = new openolt::OnuIndication;
nickc063ffd2018-05-22 14:35:28 -0400256
257 bcmbal_subscriber_terminal_key *key =
258 &(((bcmbal_subscriber_terminal_oper_status_change*)obj)->key);
259
260 bcmbal_subscriber_terminal_oper_status_change_data *data =
261 &(((bcmbal_subscriber_terminal_oper_status_change*)obj)->data);
262
nickc063ffd2018-05-22 14:35:28 -0400263 onu_ind->set_intf_id(key->intf_id);
264 onu_ind->set_onu_id(key->sub_term_id);
Craig Lutgen19512312018-11-02 10:14:46 -0500265 if (data->new_oper_status == BCMBAL_STATUS_UP) {
nickc063ffd2018-05-22 14:35:28 -0400266 onu_ind->set_oper_state("up");
267 } else {
268 onu_ind->set_oper_state("down");
269 }
270 if (data->admin_state == BCMBAL_STATE_UP) {
271 onu_ind->set_admin_state("up");
272 } else {
273 onu_ind->set_admin_state("down");
274 }
275
276 ind.set_allocated_onu_ind(onu_ind);
277
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500278 BCM_LOG(INFO, openolt_log_id, "onu oper state indication, intf_id %d, onu_id %d, old oper state %d, new oper state %s, admin_state %s\n",
279 key->intf_id, key->sub_term_id, data->old_oper_status, onu_ind->oper_state().c_str(), onu_ind->admin_state().c_str());
280
nickc063ffd2018-05-22 14:35:28 -0400281 oltIndQ.push(ind);
Shad Ansari01b0e652018-04-05 21:02:53 +0000282 return BCM_ERR_OK;
283}
284
285bcmos_errno OmciIndication(bcmbal_obj *obj) {
286 openolt::Indication ind;
287 openolt::OmciIndication* omci_ind = new openolt::OmciIndication;
Shad Ansari5fe93682018-04-26 05:24:19 +0000288 bcmbal_packet_itu_omci_channel_rx *in =
Shad Ansari01b0e652018-04-05 21:02:53 +0000289 (bcmbal_packet_itu_omci_channel_rx *)obj;
290
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400291 BCM_LOG(DEBUG, omci_log_id, "OMCI indication: intf_id %d, onu_id %d\n",
292 in->key.packet_send_dest.u.itu_omci_channel.intf_id,
293 in->key.packet_send_dest.u.itu_omci_channel.sub_term_id);
Shad Ansari01b0e652018-04-05 21:02:53 +0000294
Shad Ansari5fe93682018-04-26 05:24:19 +0000295 omci_ind->set_intf_id(in->key.packet_send_dest.u.itu_omci_channel.intf_id);
296 omci_ind->set_onu_id(in->key.packet_send_dest.u.itu_omci_channel.sub_term_id);
297 omci_ind->set_pkt(in->data.pkt.val, in->data.pkt.len);
Shad Ansari01b0e652018-04-05 21:02:53 +0000298
299 ind.set_allocated_omci_ind(omci_ind);
300 oltIndQ.push(ind);
301
302 return BCM_ERR_OK;
303}
304
Shad Ansari5fe93682018-04-26 05:24:19 +0000305bcmos_errno PacketIndication(bcmbal_obj *obj) {
Shad Ansari01b0e652018-04-05 21:02:53 +0000306 openolt::Indication ind;
Shad Ansari5fe93682018-04-26 05:24:19 +0000307 openolt::PacketIndication* pkt_ind = new openolt::PacketIndication;
308 bcmbal_packet_bearer_channel_rx *in = (bcmbal_packet_bearer_channel_rx *)obj;
309
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500310 pkt_ind->set_intf_type(bcmbal_to_grpc_intf_type(in->data.intf_type));
Shad Ansari5fe93682018-04-26 05:24:19 +0000311 pkt_ind->set_intf_id(in->data.intf_id);
312 pkt_ind->set_gemport_id(in->data.svc_port);
313 pkt_ind->set_flow_id(in->data.flow_id);
314 pkt_ind->set_pkt(in->data.pkt.val, in->data.pkt.len);
315
316 ind.set_allocated_pkt_ind(pkt_ind);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500317
318 BCM_LOG(INFO, openolt_log_id, "packet indication, intf_type %s, intf_id %d, svc_port %d, flow_id %d\n",
319 pkt_ind->intf_type().c_str(), in->data.intf_id, in->data.svc_port, in->data.flow_id);
320
Shad Ansari5fe93682018-04-26 05:24:19 +0000321 oltIndQ.push(ind);
322
Shad Ansari01b0e652018-04-05 21:02:53 +0000323 return BCM_ERR_OK;
324}
325
326bcmos_errno FlowOperIndication(bcmbal_obj *obj) {
327 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400328 BCM_LOG(DEBUG, openolt_log_id, "flow oper state indication\n");
Shad Ansari01b0e652018-04-05 21:02:53 +0000329 return BCM_ERR_OK;
330}
331
332bcmos_errno FlowIndication(bcmbal_obj *obj) {
333 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400334 BCM_LOG(DEBUG, openolt_log_id, "flow indication\n");
Shad Ansari01b0e652018-04-05 21:02:53 +0000335 return BCM_ERR_OK;
336}
337
338bcmos_errno TmQIndication(bcmbal_obj *obj) {
339 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400340 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n");
Shad Ansari01b0e652018-04-05 21:02:53 +0000341 return BCM_ERR_OK;
342}
343
344bcmos_errno TmSchedIndication(bcmbal_obj *obj) {
345 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400346 BCM_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n");
Shad Ansari01b0e652018-04-05 21:02:53 +0000347 return BCM_ERR_OK;
348}
349
350bcmos_errno McastGroupIndication(bcmbal_obj *obj) {
351 openolt::Indication ind;
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400352 BCM_LOG(DEBUG, openolt_log_id, "mcast group indication\n");
Shad Ansari01b0e652018-04-05 21:02:53 +0000353 return BCM_ERR_OK;
354}
355
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400356bcmos_errno OnuStartupFailureIndication(bcmbal_obj *obj) {
357 openolt::Indication ind;
358 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
359 openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication;
360
361 bcmbal_subscriber_terminal_key *key =
362 &(((bcmbal_subscriber_terminal_sufi*)obj)->key);
363
364 bcmbal_subscriber_terminal_sufi_data *data =
365 &(((bcmbal_subscriber_terminal_sufi*)obj)->data);
366
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400367 BCM_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n",
368 key->intf_id, key->sub_term_id, data->sufi_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400369
370 sufi_ind->set_intf_id(key->intf_id);
371 sufi_ind->set_onu_id(key->sub_term_id);
372 sufi_ind->set_status(alarm_status_to_string(data->sufi_status));
373
374 alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind);
375 ind.set_allocated_alarm_ind(alarm_ind);
376
377 oltIndQ.push(ind);
378 return BCM_ERR_OK;
379}
380
381bcmos_errno OnuSignalDegradeIndication(bcmbal_obj *obj) {
382 openolt::Indication ind;
383 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
384 openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication;
385
386 bcmbal_subscriber_terminal_key *key =
387 &(((bcmbal_subscriber_terminal_sdi*)obj)->key);
388
389 bcmbal_subscriber_terminal_sdi_data *data =
390 &(((bcmbal_subscriber_terminal_sdi*)obj)->data);
391
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400392 BCM_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
393 key->intf_id, key->sub_term_id, data->sdi_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400394
395 sdi_ind->set_intf_id(key->intf_id);
396 sdi_ind->set_onu_id(key->sub_term_id);
397 sdi_ind->set_status(alarm_status_to_string(data->sdi_status));
398 sdi_ind->set_inverse_bit_error_rate(data->ber);
399
400 alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind);
401 ind.set_allocated_alarm_ind(alarm_ind);
402
403 oltIndQ.push(ind);
404 return BCM_ERR_OK;
405}
406
407bcmos_errno OnuDriftOfWindowIndication(bcmbal_obj *obj) {
408 openolt::Indication ind;
409 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
410 openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication;
411
412 bcmbal_subscriber_terminal_key *key =
413 &(((bcmbal_subscriber_terminal_dowi*)obj)->key);
414
415 bcmbal_subscriber_terminal_dowi_data *data =
416 &(((bcmbal_subscriber_terminal_dowi*)obj)->data);
417
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400418 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",
419 key->intf_id, key->sub_term_id, data->dowi_status, data->drift_value, data->new_eqd);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400420
421 dowi_ind->set_intf_id(key->intf_id);
422 dowi_ind->set_onu_id(key->sub_term_id);
423 dowi_ind->set_status(alarm_status_to_string(data->dowi_status));
424 dowi_ind->set_drift(data->drift_value);
425 dowi_ind->set_new_eqd(data->new_eqd);
426
427 alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind);
428 ind.set_allocated_alarm_ind(alarm_ind);
429
430 oltIndQ.push(ind);
431 return BCM_ERR_OK;
432}
433
434bcmos_errno OnuLossOfOmciChannelIndication(bcmbal_obj *obj) {
435 openolt::Indication ind;
436 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
437 openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication;
438
439 bcmbal_subscriber_terminal_key *key =
440 &(((bcmbal_subscriber_terminal_looci*)obj)->key);
441
442 bcmbal_subscriber_terminal_looci_data *data =
443 &(((bcmbal_subscriber_terminal_looci*)obj)->data);
444
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400445 BCM_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n",
446 key->intf_id, key->sub_term_id, data->looci_status);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400447
448 looci_ind->set_intf_id(key->intf_id);
449 looci_ind->set_onu_id(key->sub_term_id);
450 looci_ind->set_status(alarm_status_to_string(data->looci_status));
451
452 alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind);
453 ind.set_allocated_alarm_ind(alarm_ind);
454
455 oltIndQ.push(ind);
456 return BCM_ERR_OK;
457}
458
459bcmos_errno OnuSignalsFailureIndication(bcmbal_obj *obj) {
460 openolt::Indication ind;
461 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
462 openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication;
463
464 bcmbal_subscriber_terminal_key *key =
465 &(((bcmbal_subscriber_terminal_sfi*)obj)->key);
466
467 bcmbal_subscriber_terminal_sfi_data *data =
468 &(((bcmbal_subscriber_terminal_sfi*)obj)->data);
469
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400470 BCM_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n",
471 key->intf_id, key->sub_term_id, data->sfi_status, data->ber);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400472
473
474 sfi_ind->set_intf_id(key->intf_id);
475 sfi_ind->set_onu_id(key->sub_term_id);
476 sfi_ind->set_status(alarm_status_to_string(data->sfi_status));
477 sfi_ind->set_inverse_bit_error_rate(data->ber);
478
479 alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind);
480 ind.set_allocated_alarm_ind(alarm_ind);
481
482 oltIndQ.push(ind);
483 return BCM_ERR_OK;
484}
485
486bcmos_errno OnuTransmissionInterferenceWarningIndication(bcmbal_obj *obj) {
487 openolt::Indication ind;
488 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
489 openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning;
490
491 bcmbal_subscriber_terminal_key *key =
492 &(((bcmbal_subscriber_terminal_tiwi*)obj)->key);
493
494 bcmbal_subscriber_terminal_tiwi_data *data =
495 &(((bcmbal_subscriber_terminal_tiwi*)obj)->data);
496
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400497 BCM_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n",
498 key->intf_id, key->sub_term_id, data->tiwi_status, data->drift_value);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400499
500 tiwi_ind->set_intf_id(key->intf_id);
501 tiwi_ind->set_onu_id(key->sub_term_id);
502 tiwi_ind->set_status(alarm_status_to_string(data->tiwi_status));
503 tiwi_ind->set_drift(data->drift_value);
504
505 alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind);
506 ind.set_allocated_alarm_ind(alarm_ind);
507
508 oltIndQ.push(ind);
509 return BCM_ERR_OK;
510}
511
512bcmos_errno OnuActivationFailureIndication(bcmbal_obj *obj) {
513 openolt::Indication ind;
514 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
515 openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication;
516
517 bcmbal_subscriber_terminal_key *key =
518 &(((bcmbal_subscriber_terminal_sub_term_act_fail*)obj)->key);
519
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400520 BCM_LOG(WARNING, openolt_log_id, "onu activation failure indication, intf_id %d, onu_id %d\n",
521 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400522
523
524 activation_fail_ind->set_intf_id(key->intf_id);
525 activation_fail_ind->set_onu_id(key->sub_term_id);
526
527 alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind);
528 ind.set_allocated_alarm_ind(alarm_ind);
529
530 oltIndQ.push(ind);
531 return BCM_ERR_OK;
532}
533
534bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) {
535 openolt::Indication ind;
536 openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication;
537 openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication;
538
539 bcmbal_subscriber_terminal_key *key =
540 &(((bcmbal_subscriber_terminal_processing_error*)obj)->key);
541
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400542 BCM_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n",
543 key->intf_id, key->sub_term_id);
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400544
545
546 onu_proc_error_ind->set_intf_id(key->intf_id);
547 onu_proc_error_ind->set_onu_id(key->sub_term_id);
548
549 alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind);
550 ind.set_allocated_alarm_ind(alarm_ind);
551
552 oltIndQ.push(ind);
553 return BCM_ERR_OK;
554}
555
Shad Ansari01b0e652018-04-05 21:02:53 +0000556Status SubscribeIndication() {
557 bcmbal_cb_cfg cb_cfg = {};
558 uint16_t ind_subgroup;
559
560 if (subscribed) {
561 return Status::OK;
562 }
563
564 cb_cfg.module = BCMOS_MODULE_ID_NONE;
565
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500566 /* OLT device operational state change indication */
Shad Ansari01b0e652018-04-05 21:02:53 +0000567 cb_cfg.obj_type = BCMBAL_OBJ_ID_ACCESS_TERMINAL;
Shad Ansaricb004c52018-05-30 18:07:23 +0000568 ind_subgroup = bcmbal_access_terminal_auto_id_oper_status_change;
Shad Ansari01b0e652018-04-05 21:02:53 +0000569 cb_cfg.p_subgroup = &ind_subgroup;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500570 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OltOperIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000571 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500572 return Status(grpc::StatusCode::INTERNAL, "Olt operations state change indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000573 }
574
575 /* Interface LOS indication */
576 cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE;
577 ind_subgroup = bcmbal_interface_auto_id_los;
578 cb_cfg.p_subgroup = &ind_subgroup;
579 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)LosIndication;
580 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
581 return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed");
582 }
583
Shad Ansari01b0e652018-04-05 21:02:53 +0000584 /* Interface operational state change indication */
585 cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE;
586 ind_subgroup = bcmbal_interface_auto_id_oper_status_change;
587 cb_cfg.p_subgroup = &ind_subgroup;
588 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)IfOperIndication;
589 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
590 return Status(grpc::StatusCode::INTERNAL, "Interface operations state change indication subscribe failed");
591 }
592
593 /* onu alarm indication */
594 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
595 ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_alarm;
596 cb_cfg.p_subgroup = &ind_subgroup;
597 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuAlarmIndication;
598 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
599 return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed");
600 }
601
602 /* onu dying-gasp indication */
603 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
604 ind_subgroup = bcmbal_subscriber_terminal_auto_id_dgi;
605 cb_cfg.p_subgroup = &ind_subgroup;
606 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuDyingGaspIndication;
607 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
608 return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed");
609 }
610
611 /* onu discovery indication */
612 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
613 ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_disc;
614 cb_cfg.p_subgroup = &ind_subgroup;
615 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuDiscoveryIndication;
616 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
617 return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed");
618 }
619
Shad Ansari01b0e652018-04-05 21:02:53 +0000620 /* onu operational state change indication */
621 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
622 ind_subgroup = bcmbal_subscriber_terminal_auto_id_oper_status_change;
623 cb_cfg.p_subgroup = &ind_subgroup;
624 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuOperIndication;
625 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
626 return Status(grpc::StatusCode::INTERNAL, "onu operational state change indication subscribe failed");
627 }
628
Shad Ansari5fe93682018-04-26 05:24:19 +0000629 /* Packet (bearer) indication */
Shad Ansari01b0e652018-04-05 21:02:53 +0000630 cb_cfg.obj_type = BCMBAL_OBJ_ID_PACKET;
631 ind_subgroup = bcmbal_packet_auto_id_bearer_channel_rx;
632 cb_cfg.p_subgroup = &ind_subgroup;
Shad Ansari5fe93682018-04-26 05:24:19 +0000633 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)PacketIndication;
Shad Ansari01b0e652018-04-05 21:02:53 +0000634 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
Shad Ansari5fe93682018-04-26 05:24:19 +0000635 return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed");
Shad Ansari01b0e652018-04-05 21:02:53 +0000636 }
637
638 /* Flow Operational State Change */
639 cb_cfg.obj_type = BCMBAL_OBJ_ID_FLOW;
640 ind_subgroup = bcmbal_flow_auto_id_oper_status_change;
641 cb_cfg.p_subgroup = &ind_subgroup;
642 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)FlowOperIndication;
643 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
644 return Status(grpc::StatusCode::INTERNAL, "Flow operational state change indication subscribe failed");
645 }
Shad Ansaricb004c52018-05-30 18:07:23 +0000646#if 0
Shad Ansari01b0e652018-04-05 21:02:53 +0000647 /* Flow Indication */
648 cb_cfg.obj_type = BCMBAL_OBJ_ID_FLOW;
649 ind_subgroup = bcmbal_flow_auto_id_ind;
650 cb_cfg.p_subgroup = &ind_subgroup;
651 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)FlowIndication;
652 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
653 return Status(grpc::StatusCode::INTERNAL, "Flow indication subscribe failed");
654 }
655
656 /* TM queue indication */
657 cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_QUEUE;
658 ind_subgroup = bcmbal_tm_queue_auto_id_ind;
659 cb_cfg.p_subgroup = &ind_subgroup;
660 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)TmQIndication;
661 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
662 return Status(grpc::StatusCode::INTERNAL, "Traffic mgmt queue indication subscribe failed");
663 }
Shad Ansaricb004c52018-05-30 18:07:23 +0000664#endif
Shad Ansari01b0e652018-04-05 21:02:53 +0000665
666 /* TM sched indication */
667 cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_SCHED;
Shad Ansaricb004c52018-05-30 18:07:23 +0000668 ind_subgroup = bcmbal_tm_sched_auto_id_oper_status_change;
Shad Ansari01b0e652018-04-05 21:02:53 +0000669 cb_cfg.p_subgroup = &ind_subgroup;
670 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)TmSchedIndication;
671 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
672 return Status(grpc::StatusCode::INTERNAL, "Traffic mgmt queue indication subscribe failed");
673 }
674
Shad Ansaricb004c52018-05-30 18:07:23 +0000675#if 0
Shad Ansari01b0e652018-04-05 21:02:53 +0000676 /* Multicast group indication */
677 cb_cfg.obj_type = BCMBAL_OBJ_ID_GROUP;
678 ind_subgroup = bcmbal_group_auto_id_ind;
679 cb_cfg.p_subgroup = &ind_subgroup;
680 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)McastGroupIndication;
681 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
682 return Status(grpc::StatusCode::INTERNAL, "Multicast group indication subscribe failed");
683 }
Shad Ansaricb004c52018-05-30 18:07:23 +0000684#endif
Shad Ansari01b0e652018-04-05 21:02:53 +0000685
Nicolas Palpacuerde4325b2018-07-03 11:18:42 -0400686
687 /* ONU startup failure indication */
688 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
689 ind_subgroup = bcmbal_subscriber_terminal_auto_id_sufi;
690 cb_cfg.p_subgroup = &ind_subgroup;
691 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuStartupFailureIndication;
692 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
693 return Status(grpc::StatusCode::INTERNAL, "onu startup failure indication subscribe failed");
694 }
695
696 /* SDI indication */
697 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
698 ind_subgroup = bcmbal_subscriber_terminal_auto_id_sdi;
699 cb_cfg.p_subgroup = &ind_subgroup;
700 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuSignalDegradeIndication;
701 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
702 return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed");
703 }
704
705 /* DOWI indication */
706 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
707 ind_subgroup = bcmbal_subscriber_terminal_auto_id_dowi;
708 cb_cfg.p_subgroup = &ind_subgroup;
709 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuDriftOfWindowIndication;
710 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
711 return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed");
712 }
713
714 /* LOOCI indication */
715 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
716 ind_subgroup = bcmbal_subscriber_terminal_auto_id_looci;
717 cb_cfg.p_subgroup = &ind_subgroup;
718 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuLossOfOmciChannelIndication;
719 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
720 return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed");
721 }
722
723 /* SFI indication */
724 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
725 ind_subgroup = bcmbal_subscriber_terminal_auto_id_sfi;
726 cb_cfg.p_subgroup = &ind_subgroup;
727 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuSignalsFailureIndication;
728 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
729 return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed");
730 }
731
732 /* TIWI indication */
733 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
734 ind_subgroup = bcmbal_subscriber_terminal_auto_id_tiwi;
735 cb_cfg.p_subgroup = &ind_subgroup;
736 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuTransmissionInterferenceWarningIndication;
737 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
738 return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed");
739 }
740
741 /* TIWI indication */
742 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
743 ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_act_fail;
744 cb_cfg.p_subgroup = &ind_subgroup;
745 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuActivationFailureIndication;
746 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
747 return Status(grpc::StatusCode::INTERNAL, "onu activation falaire indication subscribe failed");
748 }
749
750 /* ONU processing error indication */
751 cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL;
752 ind_subgroup = bcmbal_subscriber_terminal_auto_id_processing_error;
753 cb_cfg.p_subgroup = &ind_subgroup;
754 cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)OnuProcessingErrorIndication;
755 if (BCM_ERR_OK != bcmbal_subscribe_ind(DEFAULT_ATERM_ID, &cb_cfg)) {
756 return Status(grpc::StatusCode::INTERNAL, "onu processing error indication subscribe failed");
757 }
758
Shad Ansari01b0e652018-04-05 21:02:53 +0000759 subscribed = true;
760
761 return Status::OK;
762}