Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1 | /* |
| 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 Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 18 | #include "core.h" |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 19 | #include "utils.h" |
Nicolas Palpacuer | 0f19b1a | 2018-06-07 17:29:31 -0400 | [diff] [blame] | 20 | #include "stats_collection.h" |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 21 | #include "translation.h" |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 22 | #include "state.h" |
| 23 | |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 24 | #include <string> |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 25 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 26 | extern "C" |
| 27 | { |
| 28 | #include <bcmos_system.h> |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 29 | #include <bcmolt_api.h> |
| 30 | #include <bcmolt_host_api.h> |
| 31 | #include <bcmolt_api_model_api_structs.h> |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | using grpc::Status; |
| 35 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 36 | extern Queue<openolt::Indication> oltIndQ; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 37 | //Queue<openolt::Indication*> oltIndQ; |
| 38 | |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 39 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 40 | bool subscribed = false; |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 41 | uint32_t nni_intf_id = 0; |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 42 | #define current_device 0 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 43 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 44 | static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 45 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 46 | #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 Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 58 | #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 Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 62 | #define SET_OPER_STATE(indication,state) \ |
| 63 | (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \ |
| 64 | indication->set_oper_state("down") |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 65 | #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 Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 69 | |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 70 | std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type) |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 71 | { |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 72 | if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) { |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 73 | return "nni"; |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 74 | } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) { |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 75 | return "pon"; |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 76 | } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) { |
| 77 | return "host"; |
| 78 | } |
| 79 | return "unknown"; |
| 80 | } |
| 81 | |
| 82 | std::string bcmolt_to_grpc_flow_intf_type(bcmolt_flow_interface_type intf_type) |
| 83 | { |
| 84 | if (intf_type == BCMOLT_FLOW_INTERFACE_TYPE_NNI) { |
| 85 | return "nni"; |
| 86 | } else if (intf_type == BCMOLT_FLOW_INTERFACE_TYPE_PON) { |
| 87 | return "pon"; |
| 88 | } else if (intf_type == BCMOLT_FLOW_INTERFACE_TYPE_HOST) { |
| 89 | return "host"; |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 90 | } |
| 91 | return "unknown"; |
| 92 | } |
| 93 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 94 | static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 95 | openolt::Indication ind; |
| 96 | openolt::OltIndication* olt_ind = new openolt::OltIndication; |
| 97 | Status status; |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 98 | std::string admin_state; |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 99 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 100 | switch (msg->subgroup) { |
| 101 | case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE: |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 102 | admin_state = "up"; |
| 103 | olt_ind->set_oper_state("up"); |
| 104 | break; |
| 105 | case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE: |
| 106 | admin_state = "down"; |
| 107 | olt_ind->set_oper_state("down"); |
| 108 | break; |
| 109 | case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE: |
| 110 | admin_state = "failure"; |
| 111 | olt_ind->set_oper_state("failure"); |
| 112 | break; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 113 | } |
| 114 | ind.set_allocated_olt_ind(olt_ind); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 115 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 116 | if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) { |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 117 | /* register for omci indication */ |
| 118 | { |
| 119 | bcmolt_rx_cfg rx_cfg = {}; |
| 120 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 121 | rx_cfg.rx_cb = OmciIndication; |
| 122 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet; |
| 123 | rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT; |
| 124 | bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 125 | } |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 126 | state.activate(); |
| 127 | } |
| 128 | else { |
| 129 | state.deactivate(); |
| 130 | } |
| 131 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 132 | oltIndQ.push(ind); |
| 133 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 134 | } |
| 135 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 136 | static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 137 | openolt::Indication ind; |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 138 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 139 | openolt::LosIndication* los_ind = new openolt::LosIndication; |
| 140 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 141 | switch (msg->obj_type) { |
| 142 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 143 | switch (msg->subgroup) { |
| 144 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS: |
| 145 | { |
| 146 | bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg; |
| 147 | int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni, |
| 148 | BCMOLT_INTERFACE_TYPE_PON); |
| 149 | std::string status = alarm_status_to_string(bcm_los_ind->data.status); |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 150 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 151 | OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 152 | bcm_los_ind->key.pon_ni, intf_id, status.c_str()); |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 153 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 154 | los_ind->set_intf_id(intf_id); |
| 155 | los_ind->set_status(status); |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 156 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 157 | alarm_ind->set_allocated_los_ind(los_ind); |
| 158 | ind.set_allocated_alarm_ind(alarm_ind); |
| 159 | break; |
| 160 | } |
| 161 | } |
| 162 | } |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 163 | |
| 164 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 165 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 168 | static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 169 | openolt::Indication ind; |
| 170 | openolt::IntfIndication* intf_ind = new openolt::IntfIndication; |
| 171 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 172 | switch (msg->obj_type) { |
| 173 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 174 | switch (msg->subgroup) { |
| 175 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED: |
| 176 | { |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 177 | bcmolt_pon_interface_key *key = |
| 178 | &((bcmolt_pon_interface_state_change_completed*)msg)->key; |
| 179 | bcmolt_pon_interface_state_change_completed_data *data = |
| 180 | &((bcmolt_pon_interface_state_change_completed*)msg)->data; |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 181 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 182 | intf_ind->set_intf_id(key->pon_ni); |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 183 | SET_OPER_STATE(intf_ind, data->new_state); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 184 | ind.set_allocated_intf_ind(intf_ind); |
| 185 | break; |
| 186 | } |
| 187 | } |
| 188 | break; |
| 189 | case BCMOLT_OBJ_ID_NNI_INTERFACE: |
| 190 | switch (msg->subgroup) { |
| 191 | case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE: |
| 192 | { |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 193 | OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 194 | ((bcmolt_nni_interface_state_change *)msg)->key.id); |
| 195 | bcmolt_nni_interface_key *key = |
| 196 | &((bcmolt_nni_interface_state_change *)msg)->key; |
| 197 | bcmolt_nni_interface_state_change_data *data = |
| 198 | &((bcmolt_nni_interface_state_change *)msg)->data; |
| 199 | |
| 200 | intf_ind->set_intf_id(key->id); |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 201 | SET_OPER_STATE(intf_ind, data->new_state); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 202 | ind.set_allocated_intf_ind(intf_ind); |
| 203 | break; |
| 204 | } |
| 205 | } |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 206 | } |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 207 | |
| 208 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 209 | bcmolt_msg_free(msg); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 212 | static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 213 | openolt::Indication ind; |
| 214 | openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 215 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 216 | switch (msg->obj_type) { |
| 217 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 218 | switch (msg->subgroup) { |
| 219 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED: |
| 220 | { |
| 221 | bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key; |
| 222 | bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data; |
| 223 | intf_oper_ind->set_intf_id(key->pon_ni); |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 224 | intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON)); |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 225 | SET_OPER_STATE(intf_oper_ind, data->new_state); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 226 | OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 227 | intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str()); |
| 228 | ind.set_allocated_intf_oper_ind(intf_oper_ind); |
| 229 | break; |
| 230 | } |
| 231 | } |
| 232 | case BCMOLT_OBJ_ID_NNI_INTERFACE: |
| 233 | switch (msg->subgroup) { |
| 234 | case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE: |
| 235 | { |
| 236 | bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key; |
| 237 | bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data; |
| 238 | bcmolt_interface intf_id = key->id; |
| 239 | bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI; |
| 240 | intf_oper_ind->set_intf_id(key->id); |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 241 | intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI)); |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 242 | SET_OPER_STATE(intf_oper_ind, data->new_state); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 243 | OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 244 | intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str()); |
| 245 | ind.set_allocated_intf_oper_ind(intf_oper_ind); |
| 246 | break; |
| 247 | } |
| 248 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 249 | } |
| 250 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 251 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 252 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 253 | } |
| 254 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 255 | static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 256 | openolt::Indication ind; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 257 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 258 | openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication; |
| 259 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 260 | switch (msg->obj_type) { |
| 261 | case BCMOLT_OBJ_ID_ONU: |
| 262 | switch (msg->subgroup) { |
| 263 | case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM: |
| 264 | { |
| 265 | bcmolt_xgpon_onu_alarms *onu_alarms = |
| 266 | &((bcmolt_onu_xgpon_alarm_data *)msg)->xgpon_onu_alarm; |
| 267 | onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi)); |
| 268 | onu_alarm_ind->set_lob_status(alarm_status_to_string(onu_alarms->lobi)); |
| 269 | onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string( |
| 270 | onu_alarms->lopci_miss)); |
| 271 | onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string( |
| 272 | onu_alarms->lopci_mic_error)); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 273 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 274 | alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind); |
| 275 | ind.set_allocated_alarm_ind(alarm_ind); |
| 276 | break; |
| 277 | } |
| 278 | case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM: |
| 279 | { |
| 280 | bcmolt_gpon_onu_alarms *onu_alarms = |
| 281 | &((bcmolt_onu_gpon_alarm_data *)msg)->gpon_onu_alarm; |
| 282 | onu_alarm_ind->set_los_status(alarm_status_to_string(onu_alarms->losi)); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 283 | /* TODO: need to set lofi and loami |
| 284 | onu_alarm_ind->set_lof_status(alarm_status_to_string(onu_alarms->lofi)); |
| 285 | onu_alarm_ind->set_loami_status(alarm_status_to_string( |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 286 | onu_alarms->loami)); |
| 287 | */ |
| 288 | alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind); |
| 289 | ind.set_allocated_alarm_ind(alarm_ind); |
| 290 | break; |
| 291 | } |
| 292 | } |
| 293 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 294 | |
| 295 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 296 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 299 | static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 300 | openolt::Indication ind; |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 301 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 302 | openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication; |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 303 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 304 | switch (msg->obj_type) { |
| 305 | case BCMOLT_OBJ_ID_ONU: |
| 306 | switch (msg->subgroup) { |
| 307 | case BCMOLT_ONU_AUTO_SUBGROUP_DGI: |
| 308 | { |
| 309 | bcmolt_onu_dgi_data* dgi_data = (bcmolt_onu_dgi_data *)msg; |
| 310 | dgi_ind->set_status(alarm_status_to_string(dgi_data->alarm_status)); |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 311 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 312 | alarm_ind->set_allocated_dying_gasp_ind(dgi_ind); |
| 313 | ind.set_allocated_alarm_ind(alarm_ind); |
| 314 | break; |
| 315 | } |
| 316 | } |
| 317 | } |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 318 | |
| 319 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 320 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 323 | static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 324 | openolt::Indication ind; |
| 325 | openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication; |
| 326 | openolt::SerialNumber* serial_number = new openolt::SerialNumber; |
| 327 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 328 | switch (msg->obj_type) { |
| 329 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 330 | switch (msg->subgroup) { |
| 331 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED: |
| 332 | { |
| 333 | bcmolt_pon_interface_key *key = |
| 334 | &((bcmolt_pon_interface_onu_discovered *)msg)->key; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 335 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 336 | bcmolt_pon_interface_onu_discovered_data *data = |
| 337 | &((bcmolt_pon_interface_onu_discovered *)msg)->data; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 338 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 339 | bcmolt_serial_number *in_serial_number = &(data->serial_number); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 340 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 341 | OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 342 | key->pon_ni, serial_number_to_str(in_serial_number).c_str()); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 343 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 344 | onu_disc_ind->set_intf_id(key->pon_ni); |
| 345 | serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4); |
| 346 | serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8); |
| 347 | onu_disc_ind->set_allocated_serial_number(serial_number); |
| 348 | ind.set_allocated_onu_disc_ind(onu_disc_ind); |
| 349 | break; |
| 350 | } |
| 351 | } |
| 352 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 353 | |
| 354 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 355 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 358 | static void OnuIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 359 | openolt::Indication ind; |
| 360 | openolt::OnuIndication* onu_ind = new openolt::OnuIndication; |
| 361 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 362 | switch (msg->obj_type) { |
| 363 | case BCMOLT_OBJ_ID_ONU: |
| 364 | switch (msg->subgroup) { |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 365 | case BCMOLT_ONU_AUTO_SUBGROUP_RANGING_COMPLETED: |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 366 | { |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 367 | bcmolt_onu_key *key = &((bcmolt_onu_ranging_completed*)msg)->key; |
| 368 | bcmolt_onu_ranging_completed_data *data = &((bcmolt_onu_ranging_completed*)msg)->data; |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 369 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 370 | onu_ind->set_intf_id(key->pon_ni); |
| 371 | onu_ind->set_onu_id(key->onu_id); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 372 | if (ONU_RANGING_STATE_IF_UP(data->status)) |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 373 | onu_ind->set_oper_state("up"); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 374 | if (ONU_RANGING_STATE_IF_DOWN(data->status)) |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 375 | onu_ind->set_oper_state("down"); |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 376 | (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 377 | ind.set_allocated_onu_ind(onu_ind); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 378 | OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n", |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 379 | key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down", |
| 380 | (key->onu_id)?"up":"down"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 381 | } |
| 382 | } |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 383 | } |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 384 | |
| 385 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 386 | bcmolt_msg_free(msg); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 387 | } |
| 388 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 389 | static void OnuOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 390 | openolt::Indication ind; |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 391 | openolt::OnuIndication* onu_ind = new openolt::OnuIndication; |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 392 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 393 | switch (msg->obj_type) { |
| 394 | case BCMOLT_OBJ_ID_ONU: |
| 395 | switch (msg->subgroup) { |
| 396 | case BCMOLT_ONU_AUTO_SUBGROUP_STATE_CHANGE: |
| 397 | { |
| 398 | bcmolt_onu_key *key = &((bcmolt_onu_state_change*)msg)->key; |
| 399 | bcmolt_onu_state_change_data *data = &((bcmolt_onu_state_change*)msg)->data; |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 400 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 401 | onu_ind->set_intf_id(key->pon_ni); |
| 402 | onu_ind->set_onu_id(key->onu_id); |
| 403 | if (ONU_STATE_IF_UP(data->new_onu_state)) |
| 404 | onu_ind->set_oper_state("up"); |
| 405 | if (ONU_STATE_IF_DOWN(data->new_onu_state)) |
| 406 | onu_ind->set_oper_state("down"); |
| 407 | ind.set_allocated_onu_ind(onu_ind); |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 408 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 409 | OPENOLT_LOG(INFO, openolt_log_id, "onu oper state indication, intf_id %d, onu_id %d, old oper state %d, new oper state %s\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 410 | key->pon_ni, key->onu_id, data->new_onu_state, onu_ind->oper_state().c_str()); |
| 411 | } |
| 412 | } |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 413 | } |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 414 | |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 415 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 416 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 419 | static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 420 | openolt::Indication ind; |
| 421 | openolt::OmciIndication* omci_ind = new openolt::OmciIndication; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 422 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 423 | switch (msg->obj_type) { |
| 424 | case BCMOLT_OBJ_ID_ONU: |
| 425 | switch (msg->subgroup) { |
| 426 | case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET: |
| 427 | { |
| 428 | bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key; |
| 429 | bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 430 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 431 | OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 432 | key->pon_ni, key->onu_id); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 433 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 434 | omci_ind->set_intf_id(key->pon_ni); |
| 435 | omci_ind->set_onu_id(key->onu_id); |
| 436 | omci_ind->set_pkt(data->buffer.arr, data->buffer.len); |
| 437 | |
| 438 | ind.set_allocated_omci_ind(omci_ind); |
| 439 | break; |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 444 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 445 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 448 | static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 449 | openolt::Indication ind; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 450 | openolt::PacketIndication* pkt_ind = new openolt::PacketIndication; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 451 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 452 | switch (msg->obj_type) { |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 453 | case BCMOLT_OBJ_ID_FLOW: |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 454 | switch (msg->subgroup) { |
| 455 | case BCMOLT_FLOW_AUTO_SUBGROUP_RECEIVE_ETH_PACKET: |
| 456 | { |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 457 | bcmolt_flow_receive_eth_packet *pkt = |
| 458 | (bcmolt_flow_receive_eth_packet*)msg; |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 459 | bcmolt_flow_receive_eth_packet_data *pkt_data = |
| 460 | &((bcmolt_flow_receive_eth_packet*)msg)->data; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 461 | |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 462 | uint32_t port_no = GetPortNum_(pkt->key.flow_id); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 463 | pkt_ind->set_intf_type(bcmolt_to_grpc_flow_intf_type((bcmolt_flow_interface_type)get_flow_status(pkt->key.flow_id, pkt->key.flow_type, INGRESS_INTF_TYPE))); |
| 464 | pkt_ind->set_intf_id(get_flow_status(pkt->key.flow_id, pkt->key.flow_type, INGRESS_INTF_ID)); |
| 465 | pkt_ind->set_gemport_id(get_flow_status(pkt->key.flow_id, pkt->key.flow_type, SVC_PORT_ID)); |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 466 | pkt_ind->set_flow_id(pkt->key.flow_id); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 467 | pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len); |
| 468 | pkt_ind->set_port_no(port_no); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 469 | pkt_ind->set_cookie(get_flow_status(pkt->key.flow_id, pkt->key.flow_type, COOKIE)); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 470 | ind.set_allocated_pkt_ind(pkt_ind); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 471 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 472 | OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d, egress intf_type %s, egress intf_id %lu, svc_port %d, flow_type %s, flow_id %d, port_no %d, cookie %"PRIu64"\n", |
| 473 | pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), |
| 474 | bcmolt_to_grpc_flow_intf_type((bcmolt_flow_interface_type)get_flow_status(pkt->key.flow_id, pkt->key.flow_type, EGRESS_INTF_TYPE)).c_str(), |
| 475 | get_flow_status(pkt->key.flow_id, pkt->key.flow_type, EGRESS_INTF_ID), |
| 476 | pkt_ind->gemport_id(), GET_FLOW_TYPE(pkt->key.flow_type), |
Jason Huang | 439d24f | 2019-06-26 03:25:05 +0800 | [diff] [blame] | 477 | pkt_ind->flow_id(), port_no, pkt_ind->cookie()); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 478 | } |
| 479 | } |
| 480 | } |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 481 | |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 482 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 483 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 484 | } |
| 485 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 486 | static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 487 | openolt::Indication ind; |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 488 | OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 489 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 490 | } |
| 491 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 492 | static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 493 | openolt::Indication ind; |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 494 | OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 495 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 496 | } |
| 497 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 498 | static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 499 | openolt::Indication ind; |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 500 | OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 501 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 502 | } |
| 503 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 504 | static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 505 | openolt::Indication ind; |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 506 | OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 507 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 510 | static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 511 | openolt::Indication ind; |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 512 | OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n"); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 513 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 514 | } |
| 515 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 516 | static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 517 | openolt::Indication ind; |
| 518 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 519 | openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication; |
| 520 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 521 | switch (msg->obj_type) { |
| 522 | case BCMOLT_OBJ_ID_ONU: |
| 523 | switch (msg->subgroup) { |
| 524 | case BCMOLT_ONU_AUTO_SUBGROUP_SUFI: |
| 525 | { |
| 526 | bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key; |
| 527 | bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 528 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 529 | OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 530 | key->pon_ni, key->onu_id, data->alarm_status); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 531 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 532 | sufi_ind->set_intf_id(key->pon_ni); |
| 533 | sufi_ind->set_onu_id(key->onu_id); |
| 534 | sufi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 535 | alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 536 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 537 | ind.set_allocated_alarm_ind(alarm_ind); |
| 538 | } |
| 539 | } |
| 540 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 541 | |
| 542 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 543 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 544 | } |
| 545 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 546 | static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 547 | openolt::Indication ind; |
| 548 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 549 | openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication; |
| 550 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 551 | switch (msg->obj_type) { |
| 552 | case BCMOLT_OBJ_ID_ONU: |
| 553 | switch (msg->subgroup) { |
| 554 | case BCMOLT_ONU_AUTO_SUBGROUP_SDI: |
| 555 | { |
| 556 | bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key; |
| 557 | bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 558 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 559 | OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 560 | key->pon_ni, key->onu_id, data->alarm_status, data->ber); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 561 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 562 | sdi_ind->set_intf_id(key->pon_ni); |
| 563 | sdi_ind->set_onu_id(key->onu_id); |
| 564 | sdi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 565 | sdi_ind->set_inverse_bit_error_rate(data->ber); |
| 566 | alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 567 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 568 | ind.set_allocated_alarm_ind(alarm_ind); |
| 569 | } |
| 570 | } |
| 571 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 572 | |
| 573 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 574 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 575 | } |
| 576 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 577 | static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 578 | openolt::Indication ind; |
| 579 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 580 | openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication; |
| 581 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 582 | switch (msg->obj_type) { |
| 583 | case BCMOLT_OBJ_ID_ONU: |
| 584 | switch (msg->subgroup) { |
| 585 | case BCMOLT_ONU_AUTO_SUBGROUP_DOWI: |
| 586 | { |
| 587 | bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key; |
| 588 | bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 589 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 590 | OPENOLT_LOG(WARNING, openolt_log_id, "onu drift of window indication, intf_id %d, onu_id %d, alarm %d, drift %d, new_eqd %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 591 | key->pon_ni, key->onu_id, data->alarm_status, data->drift_value, data->new_eqd); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 592 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 593 | dowi_ind->set_intf_id(key->pon_ni); |
| 594 | dowi_ind->set_onu_id(key->onu_id); |
| 595 | dowi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 596 | dowi_ind->set_drift(data->drift_value); |
| 597 | dowi_ind->set_new_eqd(data->new_eqd); |
| 598 | alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 599 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 600 | ind.set_allocated_alarm_ind(alarm_ind); |
| 601 | } |
| 602 | } |
| 603 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 604 | |
| 605 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 606 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 607 | } |
| 608 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 609 | static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 610 | openolt::Indication ind; |
| 611 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 612 | openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication; |
| 613 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 614 | switch (msg->obj_type) { |
| 615 | case BCMOLT_OBJ_ID_ONU: |
| 616 | switch (msg->subgroup) { |
| 617 | case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI: |
| 618 | { |
| 619 | bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key; |
| 620 | bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 621 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 622 | OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 623 | key->pon_ni, key->onu_id, data->alarm_status); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 624 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 625 | looci_ind->set_intf_id(key->pon_ni); |
| 626 | looci_ind->set_onu_id(key->onu_id); |
| 627 | looci_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 628 | alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 629 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 630 | ind.set_allocated_alarm_ind(alarm_ind); |
| 631 | } |
| 632 | } |
| 633 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 634 | |
| 635 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 636 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 637 | } |
| 638 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 639 | static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 640 | openolt::Indication ind; |
| 641 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 642 | openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication; |
| 643 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 644 | switch (msg->obj_type) { |
| 645 | case BCMOLT_OBJ_ID_ONU: |
| 646 | switch (msg->subgroup) { |
| 647 | case BCMOLT_ONU_AUTO_SUBGROUP_SFI: |
| 648 | { |
| 649 | bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key; |
| 650 | bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 651 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 652 | OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 653 | key->pon_ni, key->onu_id, data->alarm_status, data->ber); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 654 | |
| 655 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 656 | sfi_ind->set_intf_id(key->pon_ni); |
| 657 | sfi_ind->set_onu_id(key->onu_id); |
| 658 | sfi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 659 | sfi_ind->set_inverse_bit_error_rate(data->ber); |
| 660 | alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 661 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 662 | ind.set_allocated_alarm_ind(alarm_ind); |
| 663 | } |
| 664 | } |
| 665 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 666 | |
| 667 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 668 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 669 | } |
| 670 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 671 | static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 672 | openolt::Indication ind; |
| 673 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 674 | openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning; |
| 675 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 676 | switch (msg->obj_type) { |
| 677 | case BCMOLT_OBJ_ID_ONU: |
| 678 | switch (msg->subgroup) { |
| 679 | case BCMOLT_ONU_AUTO_SUBGROUP_TIWI: |
| 680 | { |
| 681 | bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key; |
| 682 | bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 683 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 684 | OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 685 | key->pon_ni, key->onu_id, data->alarm_status, data->drift_value); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 686 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 687 | tiwi_ind->set_intf_id(key->pon_ni); |
| 688 | tiwi_ind->set_onu_id(key->onu_id); |
| 689 | tiwi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 690 | tiwi_ind->set_drift(data->drift_value); |
| 691 | alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 692 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 693 | ind.set_allocated_alarm_ind(alarm_ind); |
| 694 | } |
| 695 | } |
| 696 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 697 | |
| 698 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 699 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 700 | } |
| 701 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 702 | static void OnuActivationFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 703 | openolt::Indication ind; |
| 704 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 705 | openolt::OnuActivationFailureIndication* activation_fail_ind = new openolt::OnuActivationFailureIndication; |
| 706 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 707 | switch (msg->obj_type) { |
| 708 | case BCMOLT_OBJ_ID_ONU: |
| 709 | switch (msg->subgroup) { |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 710 | case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED: |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 711 | { |
| 712 | bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key; |
| 713 | bcmolt_onu_onu_activation_completed_data *data = |
| 714 | &((bcmolt_onu_onu_activation_completed*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 715 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 716 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d\n", |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 717 | key->pon_ni, key->onu_id, data->fail_reason); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 718 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 719 | activation_fail_ind->set_intf_id(key->pon_ni); |
| 720 | activation_fail_ind->set_onu_id(key->onu_id); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 721 | activation_fail_ind->set_fail_reason(data->fail_reason); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 722 | alarm_ind->set_allocated_onu_activation_fail_ind(activation_fail_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 723 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 724 | ind.set_allocated_alarm_ind(alarm_ind); |
| 725 | } |
| 726 | } |
| 727 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 728 | |
| 729 | oltIndQ.push(ind); |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 730 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 731 | } |
| 732 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 733 | /* removed by BAL v3.0 |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 734 | bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) { |
| 735 | openolt::Indication ind; |
| 736 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 737 | openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication; |
| 738 | |
| 739 | bcmbal_subscriber_terminal_key *key = |
| 740 | &(((bcmbal_subscriber_terminal_processing_error*)obj)->key); |
| 741 | |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 742 | OPENOLT_LOG(WARNING, openolt_log_id, "onu processing error indication, intf_id %d, onu_id %d\n", |
Nicolas Palpacuer | 967438f | 2018-09-07 14:41:54 -0400 | [diff] [blame] | 743 | key->intf_id, key->sub_term_id); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 744 | |
| 745 | |
| 746 | onu_proc_error_ind->set_intf_id(key->intf_id); |
| 747 | onu_proc_error_ind->set_onu_id(key->sub_term_id); |
| 748 | |
| 749 | alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind); |
| 750 | ind.set_allocated_alarm_ind(alarm_ind); |
| 751 | |
| 752 | oltIndQ.push(ind); |
| 753 | return BCM_ERR_OK; |
| 754 | } |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 755 | */ |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 756 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 757 | Status SubscribeIndication() { |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 758 | bcmolt_rx_cfg rx_cfg = {}; |
| 759 | bcmos_errno rc; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 760 | |
| 761 | if (subscribed) { |
| 762 | return Status::OK; |
| 763 | } |
| 764 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 765 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 766 | rx_cfg.rx_cb = OltOperIndication; |
| 767 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 768 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete; |
| 769 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 770 | if(rc != BCM_ERR_OK) |
| 771 | return Status(grpc::StatusCode::INTERNAL, |
| 772 | "Olt connection complete state indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 773 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 774 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 775 | rx_cfg.rx_cb = OltOperIndication; |
| 776 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 777 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete; |
| 778 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 779 | if(rc != BCM_ERR_OK) |
| 780 | return Status(grpc::StatusCode::INTERNAL, |
| 781 | "Olt disconnection complete state indication subscribe failed"); |
| 782 | |
| 783 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 784 | rx_cfg.rx_cb = OltOperIndication; |
| 785 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 786 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure; |
| 787 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 788 | if(rc != BCM_ERR_OK) |
| 789 | return Status(grpc::StatusCode::INTERNAL, |
| 790 | "Olt connection failure state indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 791 | |
| 792 | /* Interface LOS indication */ |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 793 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 794 | rx_cfg.rx_cb = LosIndication; |
| 795 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 796 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los; |
| 797 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 798 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 799 | return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 800 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 801 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 802 | rx_cfg.rx_cb = IfOperIndication; |
| 803 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 804 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed; |
| 805 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 806 | if(rc != BCM_ERR_OK) |
| 807 | return Status(grpc::StatusCode::INTERNAL, |
| 808 | "PON Interface operations state change indication subscribe failed"); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 809 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 810 | rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE; |
| 811 | rx_cfg.rx_cb = IfOperIndication; |
| 812 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 813 | rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change; |
| 814 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 815 | if(rc != BCM_ERR_OK) |
| 816 | return Status(grpc::StatusCode::INTERNAL, |
| 817 | "NNI Interface operations state change indication subscribe failed"); |
| 818 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 819 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 820 | rx_cfg.rx_cb = OnuAlarmIndication; |
| 821 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 822 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm; |
| 823 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 824 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 825 | return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 826 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 827 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 828 | rx_cfg.rx_cb = OnuAlarmIndication; |
| 829 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 830 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm; |
| 831 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 832 | if(rc != BCM_ERR_OK) |
| 833 | return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed"); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 834 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 835 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 836 | rx_cfg.rx_cb = OnuDyingGaspIndication; |
| 837 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 838 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi; |
| 839 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 840 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 841 | return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 842 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 843 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 844 | rx_cfg.rx_cb = OnuDiscoveryIndication; |
| 845 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 846 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered; |
| 847 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 848 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 849 | return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 850 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 851 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 852 | rx_cfg.rx_cb = OnuIndication; |
| 853 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 854 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_ranging_completed; |
| 855 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 856 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 857 | if(rc != BCM_ERR_OK) |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 858 | return Status(grpc::StatusCode::INTERNAL, "onu indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 859 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 860 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 861 | rx_cfg.rx_cb = OnuStartupFailureIndication; |
| 862 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 863 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi; |
| 864 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 865 | if(rc != BCM_ERR_OK) |
| 866 | return Status(grpc::StatusCode::INTERNAL, |
| 867 | "onu startup failure indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 868 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 869 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 870 | rx_cfg.rx_cb = OnuSignalDegradeIndication; |
| 871 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 872 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi; |
| 873 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 874 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 875 | return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 876 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 877 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 878 | rx_cfg.rx_cb = OnuDriftOfWindowIndication; |
| 879 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 880 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi; |
| 881 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 882 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 883 | return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 884 | |
| 885 | /* LOOCI indication */ |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 886 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 887 | rx_cfg.rx_cb = OnuLossOfOmciChannelIndication; |
| 888 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 889 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci; |
| 890 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 891 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 892 | return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 893 | |
| 894 | /* SFI indication */ |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 895 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 896 | rx_cfg.rx_cb = OnuSignalsFailureIndication; |
| 897 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 898 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi; |
| 899 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 900 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 901 | return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 902 | |
| 903 | /* TIWI indication */ |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 904 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 905 | rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication; |
| 906 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 907 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi; |
| 908 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 909 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 910 | return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed"); |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 911 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 912 | /* ONU Activation Failure Indiction */ |
| 913 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 914 | rx_cfg.rx_cb = OnuActivationFailureIndication; |
| 915 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 916 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed; |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 917 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 918 | if(rc != BCM_ERR_OK) |
| 919 | return Status(grpc::StatusCode::INTERNAL, |
| 920 | "onu activation falaire indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 921 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 922 | rx_cfg.obj_type = BCMOLT_OBJ_ID_FLOW; |
| 923 | rx_cfg.rx_cb = PacketIndication; |
| 924 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 925 | rx_cfg.subgroup = bcmolt_flow_auto_subgroup_receive_eth_packet; |
| 926 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 927 | if(rc != BCM_ERR_OK) |
| 928 | return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 929 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 930 | subscribed = true; |
| 931 | |
| 932 | return Status::OK; |
| 933 | } |