Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1 | /* |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 3 | |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 7 | |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 9 | |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 17 | #include "indications.h" |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 18 | #include "core.h" |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 19 | #include "core_data.h" |
| 20 | #include "core_utils.h" |
Nicolas Palpacuer | 0f19b1a | 2018-06-07 17:29:31 -0400 | [diff] [blame] | 21 | #include "stats_collection.h" |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 22 | #include "translation.h" |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 23 | #include "state.h" |
Orhan Kupusoglu | ec57af0 | 2021-05-12 12:38:17 +0000 | [diff] [blame] | 24 | #include "trx_eeprom_reader.h" |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 25 | |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 26 | #include <string> |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 27 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 28 | extern "C" |
| 29 | { |
| 30 | #include <bcmos_system.h> |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 31 | #include <bcmolt_api.h> |
| 32 | #include <bcmolt_host_api.h> |
| 33 | #include <bcmolt_api_model_api_structs.h> |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | using grpc::Status; |
| 37 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 38 | bool subscribed = false; |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 39 | uint32_t nni_intf_id = 0; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 40 | #define current_device 0 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 41 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 42 | static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 43 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 44 | #define INTERFACE_STATE_IF_DOWN(state) \ |
| 45 | ((state == BCMOLT_INTERFACE_STATE_INACTIVE || \ |
| 46 | state == BCMOLT_INTERFACE_STATE_PROCESSING || \ |
| 47 | state == BCMOLT_INTERFACE_STATE_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE) |
| 48 | #define INTERFACE_STATE_IF_UP(state) \ |
| 49 | ((state == BCMOLT_INTERFACE_STATE_ACTIVE_WORKING) ? BCMOS_TRUE : BCMOS_FALSE) |
| 50 | #define ONU_STATE_IF_DOWN(state) \ |
| 51 | ((state == BCMOLT_ONU_OPERATION_INACTIVE || \ |
| 52 | state == BCMOLT_ONU_OPERATION_DISABLE || \ |
| 53 | state == BCMOLT_ONU_OPERATION_ACTIVE_STANDBY) ? BCMOS_TRUE : BCMOS_FALSE) |
| 54 | #define ONU_STATE_IF_UP(state) \ |
| 55 | ((state == BCMOLT_ONU_OPERATION_ACTIVE) ? BCMOS_TRUE : BCMOS_FALSE) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 56 | #define ONU_ACTIVATION_COMPLETED_SUCCESS(state) \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 57 | ((state == BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 58 | #define ONU_ACTIVATION_COMPLETED_FAIL(state) \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 59 | ((state != BCMOLT_RESULT_SUCCESS) ? BCMOS_TRUE : BCMOS_FALSE) |
| 60 | #define SET_OPER_STATE(indication,state) \ |
| 61 | (INTERFACE_STATE_IF_UP(state)) ? indication->set_oper_state("up") : \ |
| 62 | indication->set_oper_state("down") |
| 63 | #define GET_FLOW_TYPE(type) \ |
| 64 | (type == BCMOLT_FLOW_TYPE_UPSTREAM) ? "upstream" : \ |
| 65 | (type == BCMOLT_FLOW_TYPE_DOWNSTREAM) ? "downstream" : \ |
| 66 | (type == BCMOLT_FLOW_TYPE_MULTICAST) ? "multicast" : "unknown" |
| 67 | |
| 68 | std::string bcmolt_to_grpc_intf_type(bcmolt_interface_type intf_type) |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 69 | { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 70 | if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) { |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 71 | return "nni"; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 72 | } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) { |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 73 | return "pon"; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 74 | } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) { |
| 75 | return "host"; |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 76 | } |
| 77 | return "unknown"; |
| 78 | } |
| 79 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 80 | std::string bcmolt_to_grpc_interface_rf__intf_type(bcmolt_interface_type intf_type) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 81 | { |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 82 | if (intf_type == BCMOLT_INTERFACE_TYPE_NNI) { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 83 | return "nni"; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 84 | } else if (intf_type == BCMOLT_INTERFACE_TYPE_PON) { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 85 | return "pon"; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 86 | } else if (intf_type == BCMOLT_INTERFACE_TYPE_HOST) { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 87 | return "host"; |
| 88 | } |
| 89 | return "unknown"; |
| 90 | } |
| 91 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 92 | inline uint64_t get_pon_stats_alarms_data(bcmolt_interface pon_ni, bcmolt_onu_id onu_id, bcmolt_onu_itu_pon_stats_data_id stat) { |
| 93 | bcmos_errno err; |
| 94 | bcmolt_onu_itu_pon_stats itu_pon_stat; /* declare main API struct */ |
| 95 | bcmolt_onu_key key = {}; /* declare key */ |
| 96 | bcmolt_stat_flags clear_on_read = BCMOLT_STAT_FLAGS_NONE; /* declare 'clear on read' flag */ |
| 97 | |
| 98 | key.pon_ni = pon_ni; |
| 99 | key.onu_id = onu_id; |
| 100 | |
| 101 | /* Initialize the API struct. */ |
| 102 | BCMOLT_STAT_INIT(&itu_pon_stat, onu, itu_pon_stats, key); |
| 103 | switch (stat) { |
| 104 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS: |
| 105 | BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, rdi_errors); |
| 106 | err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE); |
| 107 | if (err) { |
| 108 | OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get rdi_errors, err = %s\n", bcmos_strerror(err)); |
| 109 | return err; |
| 110 | } |
| 111 | return itu_pon_stat.data.rdi_errors; |
| 112 | /* It is a further requirement |
| 113 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS: |
| 114 | BCMOLT_FIELD_SET_PRESENT(&itu_pon_stat.data, onu_itu_pon_stats_data, bip_errors); |
| 115 | err = bcmolt_stat_get(dev_id, &itu_pon_stat.hdr, clear_on_read ? BCMOLT_STAT_FLAGS_CLEAR_ON_READ : BCMOLT_STAT_FLAGS_NONE); |
| 116 | if (err) { |
| 117 | OPENOLT_LOG(ERROR, openolt_log_id, "Failed to get bip_errors, err = %s\n", bcmos_strerror(err)); |
| 118 | return err; |
| 119 | } |
| 120 | return itu_pon_stat.data.bip_errors; |
| 121 | */ |
| 122 | default: |
| 123 | return BCM_ERR_INTERNAL; |
| 124 | } |
| 125 | |
| 126 | return err; |
| 127 | } |
| 128 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 129 | /*std::string getOnuRegistrationId(uint32_t intf_id, uint32_t onu_id){ |
Girish Gowdru | 376b33c | 2019-05-06 21:46:31 -0700 | [diff] [blame] | 130 | bcmbal_subscriber_terminal_key key; |
| 131 | bcmbal_subscriber_terminal_cfg sub_term_obj = {}; |
| 132 | uint8_t *list_mem;// to fetch config details for ONU |
| 133 | bcmos_errno err = BCM_ERR_OK; |
| 134 | |
| 135 | key.sub_term_id =onu_id; |
| 136 | key.intf_id = intf_id; |
| 137 | BCM_LOG(INFO, openolt_log_id,"Processing subscriber terminal cfg get for: %d",key.intf_id); |
| 138 | |
| 139 | BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, key); |
| 140 | |
| 141 | BCMBAL_CFG_PROP_GET(&sub_term_obj, subscriber_terminal, all_properties); |
| 142 | char *reg_id = (char*)malloc(sizeof(char)*MAX_REGID_LENGTH); |
| 143 | memset(reg_id, '\0', MAX_REGID_LENGTH); |
| 144 | |
| 145 | //set memory to use for variable-sized lists |
| 146 | list_mem = (uint8_t*)malloc(BAL_DYNAMIC_LIST_BUFFER_SIZE); |
| 147 | |
| 148 | if (list_mem == NULL) |
| 149 | { |
| 150 | BCM_LOG(ERROR,openolt_log_id,"Memory allocation failed while handling subscriber terminal \ |
| 151 | cfg get subscriber_terminal_id(%d), Interface ID(%d)",key.sub_term_id, key.intf_id); |
| 152 | return reg_id; |
| 153 | } |
| 154 | |
| 155 | memset(list_mem, 0, BAL_DYNAMIC_LIST_BUFFER_SIZE); |
| 156 | BCMBAL_CFG_LIST_BUF_SET(&sub_term_obj, subscriber_terminal, list_mem, BAL_DYNAMIC_LIST_BUFFER_SIZE); |
| 157 | |
| 158 | //call API |
| 159 | err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &sub_term_obj.hdr); |
| 160 | |
| 161 | if (err != BCM_ERR_OK) |
| 162 | { |
| 163 | BCM_LOG(ERROR,openolt_log_id, "Failed to get information from BAL subscriber_terminal_id(%d), Interface ID(%d)", |
| 164 | key.sub_term_id, key.intf_id); |
| 165 | free(list_mem); |
| 166 | return reg_id; |
| 167 | } |
| 168 | |
| 169 | BCM_LOG(INFO,openolt_log_id, "Get Subscriber cfg sent to OLT for Subscriber Id(%d) on Interface(%d)", |
| 170 | key.sub_term_id, key.intf_id); |
| 171 | |
| 172 | for (int i=0; i<MAX_REGID_LENGTH ; i++){ |
| 173 | reg_id[i]=sub_term_obj.data.registration_id.arr[i]; |
| 174 | } |
| 175 | |
| 176 | free(list_mem); |
| 177 | return reg_id; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 178 | }*/ |
Girish Gowdru | 376b33c | 2019-05-06 21:46:31 -0700 | [diff] [blame] | 179 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 180 | static void OltOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 181 | openolt::Indication ind; |
| 182 | openolt::OltIndication* olt_ind = new openolt::OltIndication; |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 183 | std::string admin_state; |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 184 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 185 | switch (msg->subgroup) { |
| 186 | case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE: |
| 187 | admin_state = "up"; |
| 188 | olt_ind->set_oper_state("up"); |
| 189 | break; |
| 190 | case BCMOLT_DEVICE_AUTO_SUBGROUP_DISCONNECTION_COMPLETE: |
| 191 | admin_state = "down"; |
| 192 | olt_ind->set_oper_state("down"); |
| 193 | break; |
| 194 | case BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_FAILURE: |
| 195 | admin_state = "failure"; |
| 196 | olt_ind->set_oper_state("failure"); |
| 197 | break; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 198 | } |
| 199 | ind.set_allocated_olt_ind(olt_ind); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 200 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 201 | if (msg->subgroup == BCMOLT_DEVICE_AUTO_SUBGROUP_CONNECTION_COMPLETE) { |
| 202 | /* register for omci indication */ |
| 203 | { |
| 204 | bcmolt_rx_cfg rx_cfg = {}; |
| 205 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 206 | rx_cfg.rx_cb = OmciIndication; |
| 207 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_omci_packet; |
| 208 | rx_cfg.module = BCMOS_MODULE_ID_OMCI_TRANSPORT; |
| 209 | bcmolt_ind_subscribe(current_device, &rx_cfg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 210 | } |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 211 | state.activate(); |
| 212 | } |
| 213 | else { |
| 214 | state.deactivate(); |
| 215 | } |
| 216 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 217 | oltIndQ.push(ind); |
| 218 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 221 | static void LosIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 222 | openolt::Indication ind; |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 223 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 224 | openolt::LosIndication* los_ind = new openolt::LosIndication; |
| 225 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 226 | switch (msg->obj_type) { |
| 227 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 228 | switch (msg->subgroup) { |
| 229 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_LOS: |
| 230 | { |
| 231 | bcmolt_pon_interface_los* bcm_los_ind = (bcmolt_pon_interface_los *) msg; |
| 232 | int intf_id = interface_key_to_port_no(bcm_los_ind->key.pon_ni, |
| 233 | BCMOLT_INTERFACE_TYPE_PON); |
| 234 | std::string status = alarm_status_to_string(bcm_los_ind->data.status); |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 235 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 236 | OPENOLT_LOG(INFO, openolt_log_id, "LOS indication : intf_id: %d port: %d status %s\n", |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 237 | bcm_los_ind->key.pon_ni, intf_id, status.c_str()); |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 238 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 239 | los_ind->set_intf_id(intf_id); |
| 240 | los_ind->set_status(status); |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 241 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 242 | alarm_ind->set_allocated_los_ind(los_ind); |
| 243 | ind.set_allocated_alarm_ind(alarm_ind); |
| 244 | break; |
| 245 | } |
| 246 | } |
| 247 | } |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 248 | |
| 249 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 250 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 253 | static void IfIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 254 | openolt::Indication ind; |
| 255 | openolt::IntfIndication* intf_ind = new openolt::IntfIndication; |
| 256 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 257 | switch (msg->obj_type) { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 258 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 259 | switch (msg->subgroup) { |
| 260 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED: |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 261 | { |
| 262 | bcmolt_pon_interface_key *key = |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 263 | &((bcmolt_pon_interface_state_change_completed*)msg)->key; |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 264 | bcmolt_pon_interface_state_change_completed_data *data = |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 265 | &((bcmolt_pon_interface_state_change_completed*)msg)->data; |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 266 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 267 | intf_ind->set_intf_id(key->pon_ni); |
| 268 | SET_OPER_STATE(intf_ind, data->new_state); |
Thiyagarajan Subramani | ad46323 | 2020-02-28 19:10:43 +0530 | [diff] [blame] | 269 | |
| 270 | OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_type %s, intf_id %d, oper_state %s\n", |
| 271 | bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON).c_str(), key->pon_ni, intf_ind->oper_state().c_str()); |
| 272 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 273 | ind.set_allocated_intf_ind(intf_ind); |
| 274 | break; |
| 275 | } |
| 276 | } |
| 277 | break; |
| 278 | case BCMOLT_OBJ_ID_NNI_INTERFACE: |
| 279 | switch (msg->subgroup) { |
| 280 | case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE: |
| 281 | { |
| 282 | OPENOLT_LOG(INFO, openolt_log_id, "intf indication, intf_id: %d\n", |
| 283 | ((bcmolt_nni_interface_state_change *)msg)->key.id); |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 284 | bcmolt_nni_interface_key *key = |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 285 | &((bcmolt_nni_interface_state_change *)msg)->key; |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 286 | bcmolt_nni_interface_state_change_data *data = |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 287 | &((bcmolt_nni_interface_state_change *)msg)->data; |
| 288 | |
| 289 | intf_ind->set_intf_id(key->id); |
| 290 | SET_OPER_STATE(intf_ind, data->new_state); |
| 291 | ind.set_allocated_intf_ind(intf_ind); |
| 292 | break; |
| 293 | } |
| 294 | } |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 295 | } |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 296 | |
| 297 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 298 | bcmolt_msg_free(msg); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 301 | static void IfOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 302 | openolt::Indication ind; |
| 303 | openolt::IntfOperIndication* intf_oper_ind = new openolt::IntfOperIndication; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 304 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 305 | switch (msg->obj_type) { |
| 306 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 307 | switch (msg->subgroup) { |
| 308 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE_COMPLETED: |
| 309 | { |
| 310 | bcmolt_pon_interface_key *key = &((bcmolt_pon_interface_state_change_completed*)msg)->key; |
| 311 | bcmolt_pon_interface_state_change_completed_data *data = &((bcmolt_pon_interface_state_change_completed*)msg)->data; |
| 312 | intf_oper_ind->set_intf_id(key->pon_ni); |
| 313 | intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_PON)); |
| 314 | SET_OPER_STATE(intf_oper_ind, data->new_state); |
| 315 | OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n", |
| 316 | intf_oper_ind->type().c_str(), key->pon_ni, intf_oper_ind->oper_state().c_str()); |
| 317 | ind.set_allocated_intf_oper_ind(intf_oper_ind); |
| 318 | break; |
| 319 | } |
| 320 | } |
| 321 | case BCMOLT_OBJ_ID_NNI_INTERFACE: |
| 322 | switch (msg->subgroup) { |
| 323 | case BCMOLT_NNI_INTERFACE_AUTO_SUBGROUP_STATE_CHANGE: |
| 324 | { |
| 325 | bcmolt_nni_interface_key *key = &((bcmolt_nni_interface_state_change *)msg)->key; |
| 326 | bcmolt_nni_interface_state_change_data *data = &((bcmolt_nni_interface_state_change *)msg)->data; |
| 327 | bcmolt_interface intf_id = key->id; |
| 328 | bcmolt_interface_type intf_type = BCMOLT_INTERFACE_TYPE_NNI; |
| 329 | intf_oper_ind->set_intf_id(key->id); |
| 330 | intf_oper_ind->set_type(bcmolt_to_grpc_intf_type(BCMOLT_INTERFACE_TYPE_NNI)); |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 331 | SET_OPER_STATE(intf_oper_ind, data->new_state); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 332 | OPENOLT_LOG(INFO, openolt_log_id, "intf oper state indication, intf_type %s, intf_id %d, oper_state %s\n", |
| 333 | intf_oper_ind->type().c_str(), key->id, intf_oper_ind->oper_state().c_str()); |
| 334 | ind.set_allocated_intf_oper_ind(intf_oper_ind); |
| 335 | break; |
| 336 | } |
| 337 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 340 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 341 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 342 | } |
| 343 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 344 | static void OnuAlarmIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 345 | openolt::Indication ind; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 346 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 347 | openolt::OnuAlarmIndication* onu_alarm_ind = new openolt::OnuAlarmIndication; |
| 348 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 349 | switch (msg->obj_type) { |
| 350 | case BCMOLT_OBJ_ID_ONU: |
| 351 | switch (msg->subgroup) { |
| 352 | case BCMOLT_ONU_AUTO_SUBGROUP_XGPON_ALARM: |
| 353 | { |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 354 | bcmolt_onu_xgpon_alarm_data *data = &((bcmolt_onu_xgpon_alarm *)msg)->data; |
| 355 | bcmolt_onu_key *key = &((bcmolt_onu_xgpon_alarm *)msg)->key; |
Thiyagarajan Subramani | ad46323 | 2020-02-28 19:10:43 +0530 | [diff] [blame] | 356 | |
| 357 | int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON); |
| 358 | |
| 359 | OPENOLT_LOG(INFO, openolt_log_id, "onu alarm indication, pon_ni %d, onu_id %d, port_no %d, los_status %s, lob_status %s, lopc_miss_status %s, lopc_mic_error_status %s\n", key->pon_ni, key->onu_id, port_no, alarm_status_to_string(data->xgpon_onu_alarm.losi).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lobi).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss).c_str(), alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error).c_str()); |
| 360 | |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 361 | onu_alarm_ind->set_los_status(alarm_status_to_string(data->xgpon_onu_alarm.losi)); |
| 362 | onu_alarm_ind->set_lob_status(alarm_status_to_string(data->xgpon_onu_alarm.lobi)); |
| 363 | onu_alarm_ind->set_lopc_miss_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_miss)); |
| 364 | onu_alarm_ind->set_lopc_mic_error_status(alarm_status_to_string(data->xgpon_onu_alarm.lopci_mic_error)); |
| 365 | onu_alarm_ind->set_intf_id(key->pon_ni); |
| 366 | onu_alarm_ind->set_onu_id(key->onu_id); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 367 | alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind); |
| 368 | ind.set_allocated_alarm_ind(alarm_ind); |
| 369 | break; |
| 370 | } |
| 371 | case BCMOLT_ONU_AUTO_SUBGROUP_GPON_ALARM: |
| 372 | { |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 373 | bcmolt_onu_gpon_alarm_data *data = &((bcmolt_onu_gpon_alarm *)msg)->data; |
| 374 | bcmolt_onu_key *key = &((bcmolt_onu_gpon_alarm *)msg)->key; |
| 375 | onu_alarm_ind->set_los_status(alarm_status_to_string(data->gpon_onu_alarm.losi)); |
| 376 | onu_alarm_ind->set_lofi_status(alarm_status_to_string(data->gpon_onu_alarm.lofi)); |
| 377 | onu_alarm_ind->set_loami_status(alarm_status_to_string(data->gpon_onu_alarm.loami)); |
| 378 | onu_alarm_ind->set_intf_id(key->pon_ni); |
| 379 | onu_alarm_ind->set_onu_id(key->onu_id); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 380 | alarm_ind->set_allocated_onu_alarm_ind(onu_alarm_ind); |
| 381 | ind.set_allocated_alarm_ind(alarm_ind); |
| 382 | break; |
| 383 | } |
| 384 | } |
| 385 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 386 | |
| 387 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 388 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 389 | } |
| 390 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 391 | static void OnuDyingGaspIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 392 | openolt::Indication ind; |
Nicolas Palpacuer | a32f4c3 | 2018-06-28 12:55:10 -0400 | [diff] [blame] | 393 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 394 | openolt::DyingGaspIndication* dgi_ind = new openolt::DyingGaspIndication; |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 395 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 396 | switch (msg->obj_type) { |
| 397 | case BCMOLT_OBJ_ID_ONU: |
| 398 | switch (msg->subgroup) { |
| 399 | case BCMOLT_ONU_AUTO_SUBGROUP_DGI: |
| 400 | { |
Chaitrashree G S | d8feddd | 2020-01-20 21:42:40 -0500 | [diff] [blame] | 401 | bcmolt_onu_dgi* dgi_data = (bcmolt_onu_dgi *)msg; |
Chaitrashree G S | 7bc19ce | 2020-01-28 18:27:42 -0500 | [diff] [blame] | 402 | bcmolt_onu_key *key = &((bcmolt_onu_dgi *)msg)->key; |
| 403 | |
Thiyagarajan Subramani | ad46323 | 2020-02-28 19:10:43 +0530 | [diff] [blame] | 404 | int port_no = interface_key_to_port_no(key->pon_ni, BCMOLT_INTERFACE_TYPE_PON); |
| 405 | |
| 406 | OPENOLT_LOG(INFO, openolt_log_id, "onu dyinggasp indication, pon_ni %d, onu_id %d, port_no %d, status %s\n", |
| 407 | key->pon_ni, key->onu_id, port_no, alarm_status_to_string(dgi_data->data.alarm_status).c_str()); |
| 408 | |
Chaitrashree G S | d8feddd | 2020-01-20 21:42:40 -0500 | [diff] [blame] | 409 | dgi_ind->set_status(alarm_status_to_string(dgi_data->data.alarm_status)); |
Chaitrashree G S | 7bc19ce | 2020-01-28 18:27:42 -0500 | [diff] [blame] | 410 | dgi_ind->set_intf_id(key->pon_ni); |
| 411 | dgi_ind->set_onu_id(key->onu_id); |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 412 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 413 | alarm_ind->set_allocated_dying_gasp_ind(dgi_ind); |
| 414 | ind.set_allocated_alarm_ind(alarm_ind); |
| 415 | break; |
| 416 | } |
| 417 | } |
| 418 | } |
nick | c063ffd | 2018-05-22 14:35:28 -0400 | [diff] [blame] | 419 | |
| 420 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 421 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 422 | } |
| 423 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 424 | static void OnuDiscoveryIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Abhilash Laxmeshwar | 3b190f0 | 2022-06-13 21:21:56 +0530 | [diff] [blame] | 425 | //Ignore the onu discovery when agent is not connected to VOLTHA |
| 426 | if (!state.is_connected()) { |
| 427 | bcmolt_msg_free(msg); |
| 428 | return; |
| 429 | } |
| 430 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 431 | openolt::Indication ind; |
| 432 | openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication; |
| 433 | openolt::SerialNumber* serial_number = new openolt::SerialNumber; |
| 434 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 435 | switch (msg->obj_type) { |
| 436 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 437 | switch (msg->subgroup) { |
| 438 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED: |
| 439 | { |
| 440 | bcmolt_pon_interface_key *key = |
| 441 | &((bcmolt_pon_interface_onu_discovered *)msg)->key; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 442 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 443 | bcmolt_pon_interface_onu_discovered_data *data = |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 444 | &((bcmolt_pon_interface_onu_discovered *)msg)->data; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 445 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 446 | bcmolt_serial_number *in_serial_number = &(data->serial_number); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 447 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 448 | OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n", |
| 449 | key->pon_ni, serial_number_to_str(in_serial_number).c_str()); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 450 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 451 | onu_disc_ind->set_intf_id(key->pon_ni); |
| 452 | serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4); |
| 453 | serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8); |
| 454 | onu_disc_ind->set_allocated_serial_number(serial_number); |
| 455 | ind.set_allocated_onu_disc_ind(onu_disc_ind); |
| 456 | break; |
| 457 | } |
| 458 | } |
| 459 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 460 | |
| 461 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 462 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 465 | static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 466 | openolt::Indication ind; |
| 467 | openolt::OmciIndication* omci_ind = new openolt::OmciIndication; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 468 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 469 | switch (msg->obj_type) { |
| 470 | case BCMOLT_OBJ_ID_ONU: |
| 471 | switch (msg->subgroup) { |
| 472 | case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET: |
| 473 | { |
| 474 | bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key; |
| 475 | bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 476 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 477 | OPENOLT_LOG(DEBUG, omci_log_id, "OMCI indication: pon_ni %d, onu_id %d\n", |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 478 | key->pon_ni, key->onu_id); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 479 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 480 | omci_ind->set_intf_id(key->pon_ni); |
| 481 | omci_ind->set_onu_id(key->onu_id); |
| 482 | omci_ind->set_pkt(data->buffer.arr, data->buffer.len); |
| 483 | |
| 484 | ind.set_allocated_omci_ind(omci_ind); |
| 485 | break; |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 490 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 491 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 492 | } |
| 493 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 494 | static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 495 | openolt::Indication ind; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 496 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 497 | switch (msg->obj_type) { |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 498 | case BCMOLT_OBJ_ID_ACCESS_CONTROL: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 499 | switch (msg->subgroup) { |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 500 | case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 501 | { |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 502 | int32_t gemport_id; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 503 | bcmolt_access_control_receive_eth_packet *pkt = |
| 504 | (bcmolt_access_control_receive_eth_packet*)msg; |
| 505 | bcmolt_access_control_receive_eth_packet_data *pkt_data = |
| 506 | &((bcmolt_access_control_receive_eth_packet*)msg)->data; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 507 | |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 508 | // Set the gemport_id to be passed to is_packet_allowed function |
| 509 | gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id; |
| 510 | |
| 511 | // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet. |
| 512 | if (! is_packet_allowed(pkt_data, gemport_id) ) { |
| 513 | OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n"); |
| 514 | bcmolt_msg_free(msg); |
| 515 | return; |
| 516 | } |
| 517 | openolt::PacketIndication* pkt_ind = new openolt::PacketIndication; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 518 | pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type( |
| 519 | (bcmolt_interface_type)pkt_data->interface_ref.intf_type)); |
| 520 | pkt_ind->set_intf_id((bcmolt_interface_id)pkt_data->interface_ref.intf_id); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 521 | pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len); |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 522 | pkt_ind->set_gemport_id(pkt_data->svc_port_id); |
Girish Gowdra | eec0fc9 | 2021-05-12 15:37:55 -0700 | [diff] [blame] | 523 | if (pkt_data->svc_port_id != BCMOLT_SERVICE_PORT_ID_INVALID) { // case of packet-in from the PON interface |
| 524 | pon_gem pg((uint32_t)pkt_data->interface_ref.intf_id, pkt_data->svc_port_id); |
| 525 | // Find to onu-uni mapping for the pon-gem key |
| 526 | bcmos_fastlock_lock(&pon_gem_to_onu_uni_map_lock); |
| 527 | auto it = pon_gem_to_onu_uni_map.find(pg); |
| 528 | bcmos_fastlock_unlock(&pon_gem_to_onu_uni_map_lock, 0); |
| 529 | if (it == pon_gem_to_onu_uni_map.end()) { |
| 530 | bcmolt_msg_free(msg); |
| 531 | OPENOLT_LOG(ERROR, openolt_log_id, "onu-uni reference not found for packet-in on gemport=%d, pon_intf_id=%d", pkt_data->svc_port_id, pkt_data->interface_ref.intf_id); |
| 532 | return; |
| 533 | } |
| 534 | pkt_ind->set_onu_id(std::get<0>(it->second)); |
| 535 | pkt_ind->set_uni_id(std::get<1>(it->second)); |
| 536 | } |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 537 | ind.set_allocated_pkt_ind(pkt_ind); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 538 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 539 | if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) { |
Girish Gowdra | eec0fc9 | 2021-05-12 15:37:55 -0700 | [diff] [blame] | 540 | OPENOLT_LOG(INFO, openolt_log_id,"packet indication, ingress intf_type %s, ingress intf_id %d, gem_port %d, onu_id=%d, uni_id=%d\n", |
| 541 | pkt_ind->intf_type().c_str(), pkt_ind->intf_id(), pkt_ind->gemport_id(), pkt_ind->onu_id(), pkt_ind->uni_id()); |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 542 | } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) { |
Girish Gowdra | eec0fc9 | 2021-05-12 15:37:55 -0700 | [diff] [blame] | 543 | OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n", |
| 544 | pkt_ind->intf_type().c_str(), pkt_ind->intf_id()); |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 545 | } |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 546 | } |
| 547 | } |
| 548 | } |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 549 | |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 550 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 551 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 552 | } |
| 553 | |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 554 | static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) { |
| 555 | |
| 556 | switch (msg->obj_type) { |
| 557 | case BCMOLT_OBJ_ID_ITUPON_ALLOC: |
| 558 | switch (msg->subgroup) { |
| 559 | case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED: |
| 560 | { |
| 561 | bcmolt_itupon_alloc_configuration_completed *pkt = |
| 562 | (bcmolt_itupon_alloc_configuration_completed*)msg; |
| 563 | bcmolt_itupon_alloc_configuration_completed_data *pkt_data = |
| 564 | &((bcmolt_itupon_alloc_configuration_completed*)msg)->data; |
| 565 | |
| 566 | alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id); |
| 567 | alloc_cfg_complete_result res; |
| 568 | res.pon_intf_id = pkt->key.pon_ni; |
| 569 | res.alloc_id = pkt->key.alloc_id; |
| 570 | |
| 571 | pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL; |
| 572 | switch (pkt_data->new_state) { |
| 573 | case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED: |
| 574 | res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED; |
| 575 | break; |
| 576 | case BCMOLT_ACTIVATION_STATE_INACTIVE: |
| 577 | res.state = ALLOC_OBJECT_STATE_INACTIVE; |
| 578 | break; |
| 579 | case BCMOLT_ACTIVATION_STATE_PROCESSING: |
| 580 | res.state = ALLOC_OBJECT_STATE_PROCESSING; |
| 581 | break; |
| 582 | case BCMOLT_ACTIVATION_STATE_ACTIVE: |
| 583 | res.state = ALLOC_OBJECT_STATE_ACTIVE; |
| 584 | break; |
| 585 | default: |
| 586 | OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n", |
| 587 | pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state); |
| 588 | res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED; |
| 589 | } |
| 590 | OPENOLT_LOG(INFO, openolt_log_id, "received itu pon alloc cfg complete ind, pon intf %u, alloc_id %u, status %u, new_state %u\n", |
| 591 | pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state); |
| 592 | |
| 593 | bcmos_fastlock_lock(&alloc_cfg_wait_lock); |
| 594 | // Push the result from BAL to queue |
| 595 | std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key); |
| 596 | if (it == alloc_cfg_compltd_map.end()) { |
| 597 | // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key. |
| 598 | bcmolt_msg_free(msg); |
| 599 | OPENOLT_LOG(ERROR, openolt_log_id, "alloc config key not found for alloc_id = %u, pon_intf = %u\n", pkt->key.alloc_id, pkt->key.pon_ni); |
| 600 | bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0); |
| 601 | return; |
| 602 | } |
| 603 | if (it->second) { |
| 604 | // Push the result |
| 605 | it->second->push(res); |
| 606 | } |
| 607 | bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | bcmolt_msg_free(msg); |
| 613 | } |
| 614 | |
Thiyagarajan Subramani | e976fcf | 2021-05-07 22:46:57 +0530 | [diff] [blame] | 615 | static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) { |
| 616 | |
| 617 | switch (msg->obj_type) { |
| 618 | case BCMOLT_OBJ_ID_ITUPON_GEM: |
| 619 | switch (msg->subgroup) { |
| 620 | case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED: |
| 621 | { |
| 622 | bcmolt_itupon_gem_configuration_completed *pkt = |
| 623 | (bcmolt_itupon_gem_configuration_completed*)msg; |
| 624 | bcmolt_itupon_gem_configuration_completed_data *pkt_data = |
| 625 | &((bcmolt_itupon_gem_configuration_completed*)msg)->data; |
| 626 | |
| 627 | gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id); |
| 628 | gem_cfg_complete_result res; |
| 629 | res.pon_intf_id = pkt->key.pon_ni; |
| 630 | res.gem_port_id = pkt->key.gem_port_id; |
| 631 | |
| 632 | pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL; |
| 633 | switch (pkt_data->new_state) { |
| 634 | case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED: |
| 635 | res.state = GEM_OBJECT_STATE_NOT_CONFIGURED; |
| 636 | break; |
| 637 | case BCMOLT_ACTIVATION_STATE_INACTIVE: |
| 638 | res.state = GEM_OBJECT_STATE_INACTIVE; |
| 639 | break; |
| 640 | case BCMOLT_ACTIVATION_STATE_PROCESSING: |
| 641 | res.state = GEM_OBJECT_STATE_PROCESSING; |
| 642 | break; |
| 643 | case BCMOLT_ACTIVATION_STATE_ACTIVE: |
| 644 | res.state = GEM_OBJECT_STATE_ACTIVE; |
| 645 | break; |
| 646 | default: |
| 647 | OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n", |
| 648 | pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state); |
| 649 | res.state = GEM_OBJECT_STATE_NOT_CONFIGURED; |
| 650 | } |
| 651 | OPENOLT_LOG(INFO, openolt_log_id, "received itu pon gem cfg complete ind, pon intf %u, gem_port_id %u, status %u, new_state %u\n", |
| 652 | pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state); |
| 653 | |
| 654 | uint32_t gem_cfg_key_check_counter = 1; |
| 655 | std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it; |
| 656 | while(true) { |
| 657 | bcmos_fastlock_lock(&gem_cfg_wait_lock); |
| 658 | // Push the result from BAL to queue |
| 659 | it = gem_cfg_compltd_map.find(key); |
| 660 | |
| 661 | if (it != gem_cfg_compltd_map.end()) { |
| 662 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 663 | break; |
| 664 | } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) { |
| 665 | /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion |
| 666 | by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication |
| 667 | to Queue by 6ms.*/ |
| 668 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 669 | bcmos_usleep(6000); |
| 670 | } else { |
| 671 | // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key. |
| 672 | bcmolt_msg_free(msg); |
| 673 | OPENOLT_LOG(ERROR, openolt_log_id, "gem config key not found for gem_port_id = %u, pon_intf = %u\n", pkt->key.gem_port_id, pkt->key.pon_ni); |
| 674 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 675 | return; |
| 676 | } |
| 677 | gem_cfg_key_check_counter++; |
| 678 | } |
| 679 | |
| 680 | bcmos_fastlock_lock(&gem_cfg_wait_lock); |
| 681 | if (it->second) { |
| 682 | // Push the result |
| 683 | it->second->push(res); |
| 684 | } |
| 685 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | bcmolt_msg_free(msg); |
| 691 | } |
| 692 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 693 | static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 694 | openolt::Indication ind; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 695 | OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n"); |
| 696 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 697 | } |
| 698 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 699 | static void FlowIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 700 | openolt::Indication ind; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 701 | OPENOLT_LOG(DEBUG, openolt_log_id, "flow indication\n"); |
| 702 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 703 | } |
| 704 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 705 | static void TmQIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 706 | openolt::Indication ind; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 707 | OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt queue indication\n"); |
| 708 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 709 | } |
| 710 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 711 | static void TmSchedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 712 | openolt::Indication ind; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 713 | OPENOLT_LOG(DEBUG, openolt_log_id, "traffic mgmt sheduler indication\n"); |
| 714 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 715 | } |
| 716 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 717 | static void McastGroupIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 718 | openolt::Indication ind; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 719 | OPENOLT_LOG(DEBUG, openolt_log_id, "mcast group indication\n"); |
| 720 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 721 | } |
| 722 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 723 | static void OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 724 | openolt::Indication ind; |
| 725 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 726 | openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication; |
| 727 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 728 | switch (msg->obj_type) { |
| 729 | case BCMOLT_OBJ_ID_ONU: |
| 730 | switch (msg->subgroup) { |
| 731 | case BCMOLT_ONU_AUTO_SUBGROUP_SUFI: |
| 732 | { |
| 733 | bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key; |
| 734 | bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 735 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 736 | OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n", |
| 737 | key->pon_ni, key->onu_id, data->alarm_status); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 738 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 739 | sufi_ind->set_intf_id(key->pon_ni); |
| 740 | sufi_ind->set_onu_id(key->onu_id); |
| 741 | sufi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 742 | alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 743 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 744 | ind.set_allocated_alarm_ind(alarm_ind); |
| 745 | } |
| 746 | } |
| 747 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 748 | |
| 749 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 750 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 751 | } |
| 752 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 753 | static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 754 | openolt::Indication ind; |
| 755 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 756 | openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication; |
| 757 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 758 | switch (msg->obj_type) { |
| 759 | case BCMOLT_OBJ_ID_ONU: |
| 760 | switch (msg->subgroup) { |
| 761 | case BCMOLT_ONU_AUTO_SUBGROUP_SDI: |
| 762 | { |
| 763 | bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key; |
| 764 | bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 765 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 766 | OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n", |
| 767 | key->pon_ni, key->onu_id, data->alarm_status, data->ber); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 768 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 769 | sdi_ind->set_intf_id(key->pon_ni); |
| 770 | sdi_ind->set_onu_id(key->onu_id); |
| 771 | sdi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 772 | sdi_ind->set_inverse_bit_error_rate(data->ber); |
| 773 | alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 774 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 775 | ind.set_allocated_alarm_ind(alarm_ind); |
| 776 | } |
| 777 | } |
| 778 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 779 | |
| 780 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 781 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 782 | } |
| 783 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 784 | static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 785 | openolt::Indication ind; |
| 786 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 787 | openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication; |
| 788 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 789 | switch (msg->obj_type) { |
| 790 | case BCMOLT_OBJ_ID_ONU: |
| 791 | switch (msg->subgroup) { |
| 792 | case BCMOLT_ONU_AUTO_SUBGROUP_DOWI: |
| 793 | { |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 794 | bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 795 | bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 796 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 797 | 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", |
| 798 | 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] | 799 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 800 | dowi_ind->set_intf_id(key->pon_ni); |
| 801 | dowi_ind->set_onu_id(key->onu_id); |
| 802 | dowi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 803 | dowi_ind->set_drift(data->drift_value); |
| 804 | dowi_ind->set_new_eqd(data->new_eqd); |
| 805 | alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 806 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 807 | ind.set_allocated_alarm_ind(alarm_ind); |
| 808 | } |
| 809 | } |
| 810 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 811 | |
| 812 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 813 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 814 | } |
| 815 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 816 | static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 817 | openolt::Indication ind; |
| 818 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 819 | openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication; |
| 820 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 821 | switch (msg->obj_type) { |
| 822 | case BCMOLT_OBJ_ID_ONU: |
| 823 | switch (msg->subgroup) { |
| 824 | case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI: |
| 825 | { |
| 826 | bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key; |
| 827 | bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 828 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 829 | OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n", |
| 830 | key->pon_ni, key->onu_id, data->alarm_status); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 831 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 832 | looci_ind->set_intf_id(key->pon_ni); |
| 833 | looci_ind->set_onu_id(key->onu_id); |
| 834 | looci_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 835 | alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 836 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 837 | ind.set_allocated_alarm_ind(alarm_ind); |
| 838 | } |
| 839 | } |
| 840 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 841 | |
| 842 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 843 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 844 | } |
| 845 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 846 | static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 847 | openolt::Indication ind; |
| 848 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 849 | openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication; |
| 850 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 851 | switch (msg->obj_type) { |
| 852 | case BCMOLT_OBJ_ID_ONU: |
| 853 | switch (msg->subgroup) { |
| 854 | case BCMOLT_ONU_AUTO_SUBGROUP_SFI: |
| 855 | { |
| 856 | bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key; |
| 857 | bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 858 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 859 | OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n", |
| 860 | key->pon_ni, key->onu_id, data->alarm_status, data->ber); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 861 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 862 | sfi_ind->set_intf_id(key->pon_ni); |
| 863 | sfi_ind->set_onu_id(key->onu_id); |
| 864 | sfi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 865 | sfi_ind->set_inverse_bit_error_rate(data->ber); |
| 866 | alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 867 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 868 | ind.set_allocated_alarm_ind(alarm_ind); |
| 869 | } |
| 870 | } |
| 871 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 872 | |
| 873 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 874 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 875 | } |
| 876 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 877 | static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 878 | openolt::Indication ind; |
| 879 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 880 | openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning; |
| 881 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 882 | switch (msg->obj_type) { |
| 883 | case BCMOLT_OBJ_ID_ONU: |
| 884 | switch (msg->subgroup) { |
| 885 | case BCMOLT_ONU_AUTO_SUBGROUP_TIWI: |
| 886 | { |
| 887 | bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key; |
| 888 | bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 889 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 890 | OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n", |
| 891 | key->pon_ni, key->onu_id, data->alarm_status, data->drift_value); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 892 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 893 | tiwi_ind->set_intf_id(key->pon_ni); |
| 894 | tiwi_ind->set_onu_id(key->onu_id); |
| 895 | tiwi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 896 | tiwi_ind->set_drift(data->drift_value); |
| 897 | alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 898 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 899 | ind.set_allocated_alarm_ind(alarm_ind); |
| 900 | } |
| 901 | } |
| 902 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 903 | |
| 904 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 905 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 906 | } |
| 907 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 908 | static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 909 | openolt::Indication ind; |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 910 | openolt::OnuIndication* onu_ind = new openolt::OnuIndication; |
| 911 | |
| 912 | switch (msg->obj_type) { |
| 913 | case BCMOLT_OBJ_ID_ONU: |
| 914 | switch (msg->subgroup) { |
| 915 | case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED: |
| 916 | { |
| 917 | bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key; |
| 918 | bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data; |
| 919 | |
| 920 | onu_ind->set_intf_id(key->pon_ni); |
| 921 | onu_ind->set_onu_id(key->onu_id); |
| 922 | if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status)) |
| 923 | onu_ind->set_oper_state("up"); |
| 924 | if (ONU_ACTIVATION_COMPLETED_FAIL(data->status)) |
| 925 | onu_ind->set_oper_state("down"); |
kesavand | 88fdddd | 2020-09-04 12:06:34 +0530 | [diff] [blame] | 926 | switch (data->fail_reason) { |
| 927 | case BCMOLT_ACTIVATION_FAIL_REASON_RANGING: |
| 928 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING); |
| 929 | break; |
| 930 | case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION: |
| 931 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION); |
| 932 | break; |
| 933 | case BCMOLT_ACTIVATION_FAIL_REASON_LOS: |
| 934 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS); |
| 935 | break; |
| 936 | case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM: |
| 937 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM); |
| 938 | break; |
| 939 | case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER: |
| 940 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER); |
| 941 | break; |
| 942 | default: |
| 943 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE); |
| 944 | } |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 945 | // Setting the admin_state state field based on a valid onu_id does not make any sense. |
| 946 | // The adapter too does not seem to interpret this seriously. |
| 947 | // Legacy code, lets keep this as is for now. |
| 948 | (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down"); |
| 949 | ind.set_allocated_onu_ind(onu_ind); |
| 950 | OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n", |
| 951 | key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down", |
| 952 | (key->onu_id)?"up":"down"); |
| 953 | } |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | oltIndQ.push(ind); |
| 958 | bcmolt_msg_free(msg); |
| 959 | } |
| 960 | |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 961 | static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 962 | openolt::Indication ind; |
| 963 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 964 | openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication; |
| 965 | |
| 966 | switch (msg->obj_type) { |
| 967 | case BCMOLT_OBJ_ID_ONU: |
| 968 | switch (msg->subgroup) { |
| 969 | case BCMOLT_ONU_AUTO_SUBGROUP_LOKI: |
| 970 | { |
| 971 | bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key; |
| 972 | bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data; |
| 973 | |
| 974 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n", |
| 975 | key->pon_ni, key->onu_id, data->alarm_status); |
| 976 | |
| 977 | loss_of_sync_fail_ind->set_intf_id(key->pon_ni); |
| 978 | loss_of_sync_fail_ind->set_onu_id(key->onu_id); |
| 979 | loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 980 | alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind); |
| 981 | |
| 982 | ind.set_allocated_alarm_ind(alarm_ind); |
| 983 | } |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | oltIndQ.push(ind); |
| 988 | bcmolt_msg_free(msg); |
| 989 | } |
| 990 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 991 | static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 992 | openolt::Indication ind; |
| 993 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 994 | openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication; |
| 995 | |
| 996 | switch (msg->obj_type) { |
| 997 | case BCMOLT_OBJ_ID_ONU: |
| 998 | switch (msg->subgroup) { |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 999 | case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED: |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1000 | { |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1001 | bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key; |
| 1002 | bcmolt_onu_itu_pon_stats_alarm_raised_data *data = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->data; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1003 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1004 | if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) { |
| 1005 | switch (data->stat) |
| 1006 | { |
| 1007 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS: |
| 1008 | uint64_t rdi_errors; |
| 1009 | openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication; |
| 1010 | rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1011 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1012 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1013 | rdi_err_ind->set_rdi_error_count(rdi_errors); |
| 1014 | rdi_err_ind->set_status("on"); |
| 1015 | onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind); |
| 1016 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \ |
| 1017 | rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors); |
| 1018 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1019 | break; |
| 1020 | /* It is a further requirement |
| 1021 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS: |
| 1022 | uint64_t bip_errors; |
| 1023 | bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1024 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1025 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1026 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \ |
| 1027 | bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors); |
| 1028 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1029 | break; |
| 1030 | */ |
| 1031 | } |
| 1032 | ind.set_allocated_alarm_ind(alarm_ind); |
| 1033 | } |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1034 | } |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | oltIndQ.push(ind); |
| 1039 | bcmolt_msg_free(msg); |
| 1040 | } |
| 1041 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1042 | static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1043 | openolt::Indication ind; |
| 1044 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 1045 | openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1046 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1047 | switch (msg->obj_type) { |
| 1048 | case BCMOLT_OBJ_ID_ONU: |
| 1049 | switch (msg->subgroup) { |
| 1050 | case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED: |
| 1051 | { |
| 1052 | bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key; |
| 1053 | bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data; |
| 1054 | |
| 1055 | if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) { |
| 1056 | switch (data->stat) |
| 1057 | { |
| 1058 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS: |
| 1059 | uint64_t rdi_errors; |
| 1060 | openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication; |
| 1061 | |
| 1062 | rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1063 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1064 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1065 | rdi_err_ind->set_rdi_error_count(rdi_errors); |
| 1066 | rdi_err_ind->set_status("off"); |
| 1067 | onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind); |
| 1068 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \ |
| 1069 | rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors); |
| 1070 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1071 | break; |
| 1072 | /* It is a further requirement |
| 1073 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS: |
| 1074 | uint64_t bip_errors; |
| 1075 | bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1076 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1077 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1078 | onu_itu_pon_stats_ind->set_bip_errors(bip_errors); |
| 1079 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \ |
| 1080 | bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors); |
| 1081 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1082 | break; |
| 1083 | */ |
| 1084 | } |
| 1085 | ind.set_allocated_alarm_ind(alarm_ind); |
| 1086 | } |
| 1087 | } |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | oltIndQ.push(ind); |
| 1092 | bcmolt_msg_free(msg); |
| 1093 | } |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1094 | |
| 1095 | static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1096 | openolt::Indication ind; |
| 1097 | |
| 1098 | openolt::Indication onu_ind; |
| 1099 | openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1100 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1101 | switch (msg->obj_type) { |
| 1102 | case BCMOLT_OBJ_ID_ONU: |
| 1103 | switch (msg->subgroup) { |
| 1104 | case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED: |
| 1105 | { |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1106 | bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key; |
| 1107 | bcmolt_onu_onu_deactivation_completed_data *data = |
| 1108 | &((bcmolt_onu_onu_deactivation_completed*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1109 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1110 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n", |
| 1111 | key->pon_ni, key->onu_id, data->fail_reason, bcmolt_result_to_string(data->status).c_str()); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1112 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1113 | onu_ind_data->set_intf_id(key->pon_ni); |
| 1114 | onu_ind_data->set_onu_id(key->onu_id); |
| 1115 | onu_ind_data->set_oper_state("down"); |
| 1116 | onu_ind_data->set_admin_state("down"); |
| 1117 | onu_ind.set_allocated_onu_ind(onu_ind_data); |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1118 | |
| 1119 | onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id); |
| 1120 | onu_deactivate_complete_result res; |
| 1121 | res.pon_intf_id = (uint32_t)key->pon_ni; |
| 1122 | res.onu_id = (uint32_t) key->onu_id; |
| 1123 | res.result = data->status; |
| 1124 | res.reason = data->fail_reason; |
| 1125 | |
| 1126 | OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n", |
| 1127 | key->pon_ni, key->onu_id, data->status, data->fail_reason); |
| 1128 | |
| 1129 | bcmos_fastlock_lock(&onu_deactivate_wait_lock); |
| 1130 | // Push the result from BAL to queue |
| 1131 | std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key); |
| 1132 | if (it == onu_deact_compltd_map.end()) { |
| 1133 | // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key. |
Girish Gowdra | 6675fa0 | 2020-03-03 20:27:50 -0800 | [diff] [blame] | 1134 | // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where |
| 1135 | // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application. |
| 1136 | // The application has to take care handling spurious indications. |
Thiyagarajan Subramani | ad46323 | 2020-02-28 19:10:43 +0530 | [diff] [blame] | 1137 | OPENOLT_LOG(WARNING, openolt_log_id, "onu deactivate completed key not found for pon intf %u, onu_id %u\n", |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1138 | key->pon_ni, key->onu_id); |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1139 | } |
Girish Gowdra | 6675fa0 | 2020-03-03 20:27:50 -0800 | [diff] [blame] | 1140 | else if (it->second) { |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1141 | // Push the result |
| 1142 | it->second->push(res); |
| 1143 | } |
| 1144 | bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1145 | } |
| 1146 | } |
| 1147 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1148 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1149 | oltIndQ.push(onu_ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1150 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1151 | } |
| 1152 | |
Orhan Kupusoglu | ec57af0 | 2021-05-12 12:38:17 +0000 | [diff] [blame] | 1153 | static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1154 | switch (msg->obj_type) { |
| 1155 | case BCMOLT_OBJ_ID_ONU: |
| 1156 | switch (msg->subgroup) { |
| 1157 | case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED: |
| 1158 | { |
| 1159 | bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key; |
| 1160 | bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data; |
| 1161 | double rx_power_mean_dbm = 0.0; |
| 1162 | |
| 1163 | OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n", |
| 1164 | key->pon_ni, key->onu_id, data->status, data->fail_reason); |
| 1165 | |
| 1166 | if (data->status == BCMOLT_RESULT_SUCCESS) { |
| 1167 | auto trx_eeprom_reader = |
| 1168 | #ifdef ASGVOLT64 |
| 1169 | TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni}; |
| 1170 | #else |
| 1171 | TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni}; |
| 1172 | #endif |
| 1173 | auto power = trx_eeprom_reader.read_power_mean_dbm(); |
| 1174 | |
| 1175 | if (power.second) { |
| 1176 | rx_power_mean_dbm = power.first.first; |
| 1177 | OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm); |
| 1178 | } else { |
| 1179 | OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n"); |
| 1180 | } |
| 1181 | } else { |
| 1182 | OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure"); |
| 1183 | } |
| 1184 | |
| 1185 | // for internal use insert into map |
| 1186 | onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id); |
| 1187 | onu_rssi_complete_result res; |
| 1188 | res.pon_intf_id = (uint32_t)key->pon_ni; |
| 1189 | res.onu_id = (uint32_t)key->onu_id; |
| 1190 | res.status = bcmolt_result_to_string(data->status); |
| 1191 | res.reason = data->fail_reason; |
| 1192 | res.rx_power_mean_dbm = rx_power_mean_dbm; |
| 1193 | |
| 1194 | bcmos_fastlock_lock(&onu_rssi_wait_lock); |
| 1195 | auto it = onu_rssi_compltd_map.find(onu_key); |
| 1196 | if (it == onu_rssi_compltd_map.end()) { |
| 1197 | OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n", |
| 1198 | key->pon_ni, key->onu_id); |
| 1199 | } else if (it->second) { |
| 1200 | it->second->push(res); |
| 1201 | } else { |
| 1202 | OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n", |
| 1203 | key->pon_ni, key->onu_id); |
| 1204 | } |
| 1205 | bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0); |
| 1206 | } |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | bcmolt_msg_free(msg); |
| 1211 | } |
| 1212 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1213 | /* removed by BAL v3.0 |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1214 | bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) { |
| 1215 | openolt::Indication ind; |
| 1216 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 1217 | openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication; |
| 1218 | |
| 1219 | bcmbal_subscriber_terminal_key *key = |
| 1220 | &(((bcmbal_subscriber_terminal_processing_error*)obj)->key); |
| 1221 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1222 | 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] | 1223 | key->intf_id, key->sub_term_id); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1224 | |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1225 | onu_proc_error_ind->set_intf_id(key->intf_id); |
| 1226 | onu_proc_error_ind->set_onu_id(key->sub_term_id); |
| 1227 | |
| 1228 | alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind); |
| 1229 | ind.set_allocated_alarm_ind(alarm_ind); |
| 1230 | |
| 1231 | oltIndQ.push(ind); |
| 1232 | return BCM_ERR_OK; |
| 1233 | } |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1234 | */ |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1235 | |
Burak Gurdag | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 1236 | static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1237 | |
| 1238 | switch (msg->obj_type) { |
| 1239 | case BCMOLT_OBJ_ID_GROUP: |
| 1240 | switch (msg->subgroup) { |
| 1241 | case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE: |
| 1242 | { |
| 1243 | bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key; |
| 1244 | bcmolt_group_complete_members_update_data *data = |
| 1245 | &((bcmolt_group_complete_members_update*)msg)->data; |
| 1246 | |
| 1247 | if (data->result == BCMOLT_RESULT_SUCCESS) { |
| 1248 | OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id); |
| 1249 | } else { |
| 1250 | OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason); |
| 1251 | } |
| 1252 | } |
| 1253 | } |
| 1254 | } |
| 1255 | bcmolt_msg_free(msg); |
| 1256 | } |
| 1257 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1258 | Status SubscribeIndication() { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1259 | bcmolt_rx_cfg rx_cfg = {}; |
| 1260 | bcmos_errno rc; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1261 | |
| 1262 | if (subscribed) { |
| 1263 | return Status::OK; |
| 1264 | } |
| 1265 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1266 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 1267 | rx_cfg.rx_cb = OltOperIndication; |
| 1268 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1269 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete; |
| 1270 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1271 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1272 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1273 | "Olt connection complete state indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1274 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1275 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 1276 | rx_cfg.rx_cb = OltOperIndication; |
| 1277 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1278 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete; |
| 1279 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1280 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1281 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1282 | "Olt disconnection complete state indication subscribe failed"); |
| 1283 | |
| 1284 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 1285 | rx_cfg.rx_cb = OltOperIndication; |
| 1286 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1287 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure; |
| 1288 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1289 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1290 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1291 | "Olt connection failure state indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1292 | |
| 1293 | /* Interface LOS indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1294 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 1295 | rx_cfg.rx_cb = LosIndication; |
| 1296 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1297 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los; |
| 1298 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1299 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1300 | return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1301 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1302 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 1303 | rx_cfg.rx_cb = IfOperIndication; |
| 1304 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1305 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed; |
| 1306 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1307 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1308 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1309 | "PON Interface operations state change indication subscribe failed"); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 1310 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1311 | rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE; |
| 1312 | rx_cfg.rx_cb = IfOperIndication; |
| 1313 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1314 | rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change; |
| 1315 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1316 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1317 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1318 | "NNI Interface operations state change indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1319 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1320 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1321 | rx_cfg.rx_cb = OnuAlarmIndication; |
| 1322 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1323 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm; |
| 1324 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1325 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1326 | return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1327 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1328 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1329 | rx_cfg.rx_cb = OnuAlarmIndication; |
| 1330 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1331 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm; |
| 1332 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1333 | if(rc != BCM_ERR_OK) |
| 1334 | return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed"); |
| 1335 | |
| 1336 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1337 | rx_cfg.rx_cb = OnuDyingGaspIndication; |
| 1338 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1339 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi; |
| 1340 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1341 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1342 | return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1343 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1344 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 1345 | rx_cfg.rx_cb = OnuDiscoveryIndication; |
| 1346 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1347 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered; |
| 1348 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1349 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1350 | return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1351 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1352 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1353 | rx_cfg.rx_cb = OnuStartupFailureIndication; |
| 1354 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1355 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi; |
| 1356 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1357 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1358 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1359 | "onu startup failure indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1360 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1361 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1362 | rx_cfg.rx_cb = OnuSignalDegradeIndication; |
| 1363 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1364 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi; |
| 1365 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1366 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1367 | return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1368 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1369 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1370 | rx_cfg.rx_cb = OnuDriftOfWindowIndication; |
| 1371 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1372 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi; |
| 1373 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1374 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1375 | return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1376 | |
| 1377 | /* LOOCI indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1378 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1379 | rx_cfg.rx_cb = OnuLossOfOmciChannelIndication; |
| 1380 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1381 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci; |
| 1382 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1383 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1384 | return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1385 | |
| 1386 | /* SFI indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1387 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1388 | rx_cfg.rx_cb = OnuSignalsFailureIndication; |
| 1389 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1390 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi; |
| 1391 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1392 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1393 | return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1394 | |
| 1395 | /* TIWI indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1396 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1397 | rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication; |
| 1398 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1399 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi; |
| 1400 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1401 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1402 | return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1403 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1404 | /* ONU Activation Completed Indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1405 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1406 | rx_cfg.rx_cb = OnuActivationCompletedIndication; |
| 1407 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1408 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed; |
| 1409 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1410 | if(rc != BCM_ERR_OK) |
| 1411 | return Status(grpc::StatusCode::INTERNAL, |
| 1412 | "onu activation completed indication subscribe failed"); |
| 1413 | |
| 1414 | /* ONU Deactivation Completed Indication */ |
| 1415 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1416 | rx_cfg.rx_cb = OnuDeactivationCompletedIndication; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1417 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1418 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed; |
| 1419 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1420 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1421 | return Status(grpc::StatusCode::INTERNAL, |
| 1422 | "onu deactivation indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1423 | |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1424 | /* ONU Loss of Key Sync Indiction */ |
| 1425 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1426 | rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication; |
| 1427 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1428 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki; |
| 1429 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1430 | if(rc != BCM_ERR_OK) |
| 1431 | return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed"); |
| 1432 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1433 | /* ONU ITU-PON Raised Stats Indiction */ |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1434 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1435 | rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1436 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1437 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1438 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1439 | if(rc != BCM_ERR_OK) |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1440 | return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed"); |
| 1441 | |
| 1442 | /* ONU ITU-PON Cleared Stats Indiction */ |
| 1443 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1444 | rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication; |
| 1445 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1446 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared; |
| 1447 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1448 | if(rc != BCM_ERR_OK) |
| 1449 | return Status(grpc::StatusCode::INTERNAL, "onu itu-pon cleared stats indication subscribe failed"); |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1450 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1451 | /* Packet-In by Access_Control */ |
| 1452 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1453 | rx_cfg.rx_cb = PacketIndication; |
| 1454 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1455 | rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1456 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1457 | if(rc != BCM_ERR_OK) |
| 1458 | return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1459 | |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 1460 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC; |
| 1461 | rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd; |
| 1462 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1463 | rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed; |
| 1464 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1465 | if(rc != BCM_ERR_OK) |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1466 | return Status(grpc::StatusCode::INTERNAL, "ITU PON Alloc Configuration Complete Indication subscribe failed"); |
Thiyagarajan Subramani | e976fcf | 2021-05-07 22:46:57 +0530 | [diff] [blame] | 1467 | |
| 1468 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM; |
| 1469 | rx_cfg.rx_cb = ItuPonGemConfigCompletedInd; |
| 1470 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1471 | rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed; |
| 1472 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1473 | if(rc != BCM_ERR_OK) |
| 1474 | return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed"); |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 1475 | |
Burak Gurdag | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 1476 | rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP; |
| 1477 | rx_cfg.rx_cb = GroupIndication; |
| 1478 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1479 | rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update; |
| 1480 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1481 | if(rc != BCM_ERR_OK) |
| 1482 | return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed"); |
| 1483 | |
Orhan Kupusoglu | ec57af0 | 2021-05-12 12:38:17 +0000 | [diff] [blame] | 1484 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1485 | rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication; |
| 1486 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1487 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed; |
| 1488 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1489 | if(rc != BCM_ERR_OK) |
| 1490 | return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed"); |
| 1491 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1492 | subscribed = true; |
| 1493 | |
| 1494 | return Status::OK; |
| 1495 | } |