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) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 425 | openolt::Indication ind; |
| 426 | openolt::OnuDiscIndication* onu_disc_ind = new openolt::OnuDiscIndication; |
| 427 | openolt::SerialNumber* serial_number = new openolt::SerialNumber; |
| 428 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 429 | switch (msg->obj_type) { |
| 430 | case BCMOLT_OBJ_ID_PON_INTERFACE: |
| 431 | switch (msg->subgroup) { |
| 432 | case BCMOLT_PON_INTERFACE_AUTO_SUBGROUP_ONU_DISCOVERED: |
| 433 | { |
| 434 | bcmolt_pon_interface_key *key = |
| 435 | &((bcmolt_pon_interface_onu_discovered *)msg)->key; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 436 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 437 | bcmolt_pon_interface_onu_discovered_data *data = |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 438 | &((bcmolt_pon_interface_onu_discovered *)msg)->data; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 439 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 440 | bcmolt_serial_number *in_serial_number = &(data->serial_number); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 441 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 442 | OPENOLT_LOG(INFO, openolt_log_id, "onu discover indication, pon_ni %d, serial_number %s\n", |
| 443 | key->pon_ni, serial_number_to_str(in_serial_number).c_str()); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 444 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 445 | onu_disc_ind->set_intf_id(key->pon_ni); |
| 446 | serial_number->set_vendor_id(reinterpret_cast<const char *>(in_serial_number->vendor_id.arr), 4); |
| 447 | serial_number->set_vendor_specific(reinterpret_cast<const char *>(in_serial_number->vendor_specific.arr), 8); |
| 448 | onu_disc_ind->set_allocated_serial_number(serial_number); |
| 449 | ind.set_allocated_onu_disc_ind(onu_disc_ind); |
| 450 | break; |
| 451 | } |
| 452 | } |
| 453 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 454 | |
| 455 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 456 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 457 | } |
| 458 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 459 | static void OmciIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 460 | openolt::Indication ind; |
| 461 | openolt::OmciIndication* omci_ind = new openolt::OmciIndication; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 462 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 463 | switch (msg->obj_type) { |
| 464 | case BCMOLT_OBJ_ID_ONU: |
| 465 | switch (msg->subgroup) { |
| 466 | case BCMOLT_ONU_AUTO_SUBGROUP_OMCI_PACKET: |
| 467 | { |
| 468 | bcmolt_onu_key *key = &((bcmolt_onu_omci_packet*)msg)->key; |
| 469 | bcmolt_onu_omci_packet_data *data = &((bcmolt_onu_omci_packet*)msg)->data; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 470 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 471 | 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] | 472 | key->pon_ni, key->onu_id); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 473 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 474 | omci_ind->set_intf_id(key->pon_ni); |
| 475 | omci_ind->set_onu_id(key->onu_id); |
| 476 | omci_ind->set_pkt(data->buffer.arr, data->buffer.len); |
| 477 | |
| 478 | ind.set_allocated_omci_ind(omci_ind); |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 484 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 485 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 486 | } |
| 487 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 488 | static void PacketIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 489 | openolt::Indication ind; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 490 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 491 | switch (msg->obj_type) { |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 492 | case BCMOLT_OBJ_ID_ACCESS_CONTROL: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 493 | switch (msg->subgroup) { |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 494 | case BCMOLT_ACCESS_CONTROL_AUTO_SUBGROUP_RECEIVE_ETH_PACKET: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 495 | { |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 496 | int32_t gemport_id; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 497 | bcmolt_access_control_receive_eth_packet *pkt = |
| 498 | (bcmolt_access_control_receive_eth_packet*)msg; |
| 499 | bcmolt_access_control_receive_eth_packet_data *pkt_data = |
| 500 | &((bcmolt_access_control_receive_eth_packet*)msg)->data; |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 501 | |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 502 | // Set the gemport_id to be passed to is_packet_allowed function |
| 503 | gemport_id = pkt_data->svc_port_id == BCMOLT_SERVICE_PORT_ID_INVALID ? -1 : pkt_data->svc_port_id; |
| 504 | |
| 505 | // Allow the packet to host only if "is_packet_allowed" routine returns true, else drop the packet. |
| 506 | if (! is_packet_allowed(pkt_data, gemport_id) ) { |
| 507 | OPENOLT_LOG(WARNING, openolt_log_id, "packet not allowed to host\n"); |
| 508 | bcmolt_msg_free(msg); |
| 509 | return; |
| 510 | } |
| 511 | openolt::PacketIndication* pkt_ind = new openolt::PacketIndication; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 512 | pkt_ind->set_intf_type(bcmolt_to_grpc_interface_rf__intf_type( |
| 513 | (bcmolt_interface_type)pkt_data->interface_ref.intf_type)); |
| 514 | 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] | 515 | pkt_ind->set_pkt(pkt_data->buffer.arr, pkt_data->buffer.len); |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 516 | pkt_ind->set_gemport_id(pkt_data->svc_port_id); |
Girish Gowdra | eec0fc9 | 2021-05-12 15:37:55 -0700 | [diff] [blame] | 517 | if (pkt_data->svc_port_id != BCMOLT_SERVICE_PORT_ID_INVALID) { // case of packet-in from the PON interface |
| 518 | pon_gem pg((uint32_t)pkt_data->interface_ref.intf_id, pkt_data->svc_port_id); |
| 519 | // Find to onu-uni mapping for the pon-gem key |
| 520 | bcmos_fastlock_lock(&pon_gem_to_onu_uni_map_lock); |
| 521 | auto it = pon_gem_to_onu_uni_map.find(pg); |
| 522 | bcmos_fastlock_unlock(&pon_gem_to_onu_uni_map_lock, 0); |
| 523 | if (it == pon_gem_to_onu_uni_map.end()) { |
| 524 | bcmolt_msg_free(msg); |
| 525 | 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); |
| 526 | return; |
| 527 | } |
| 528 | pkt_ind->set_onu_id(std::get<0>(it->second)); |
| 529 | pkt_ind->set_uni_id(std::get<1>(it->second)); |
| 530 | } |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 531 | ind.set_allocated_pkt_ind(pkt_ind); |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 532 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 533 | if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_PON) { |
Girish Gowdra | eec0fc9 | 2021-05-12 15:37:55 -0700 | [diff] [blame] | 534 | 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", |
| 535 | 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] | 536 | } else if (pkt_data->interface_ref.intf_type == BCMOLT_INTERFACE_TYPE_NNI ) { |
Girish Gowdra | eec0fc9 | 2021-05-12 15:37:55 -0700 | [diff] [blame] | 537 | OPENOLT_LOG(INFO, openolt_log_id, "packet indication, ingress intf_type %s, ingress intf_id %d\n", |
| 538 | pkt_ind->intf_type().c_str(), pkt_ind->intf_id()); |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 539 | } |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | } |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 543 | |
Shad Ansari | 5fe9368 | 2018-04-26 05:24:19 +0000 | [diff] [blame] | 544 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 545 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 546 | } |
| 547 | |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 548 | static void ItuPonAllocConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) { |
| 549 | |
| 550 | switch (msg->obj_type) { |
| 551 | case BCMOLT_OBJ_ID_ITUPON_ALLOC: |
| 552 | switch (msg->subgroup) { |
| 553 | case BCMOLT_ITUPON_ALLOC_AUTO_SUBGROUP_CONFIGURATION_COMPLETED: |
| 554 | { |
| 555 | bcmolt_itupon_alloc_configuration_completed *pkt = |
| 556 | (bcmolt_itupon_alloc_configuration_completed*)msg; |
| 557 | bcmolt_itupon_alloc_configuration_completed_data *pkt_data = |
| 558 | &((bcmolt_itupon_alloc_configuration_completed*)msg)->data; |
| 559 | |
| 560 | alloc_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.alloc_id); |
| 561 | alloc_cfg_complete_result res; |
| 562 | res.pon_intf_id = pkt->key.pon_ni; |
| 563 | res.alloc_id = pkt->key.alloc_id; |
| 564 | |
| 565 | pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = ALLOC_CFG_STATUS_SUCCESS: res.status = ALLOC_CFG_STATUS_FAIL; |
| 566 | switch (pkt_data->new_state) { |
| 567 | case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED: |
| 568 | res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED; |
| 569 | break; |
| 570 | case BCMOLT_ACTIVATION_STATE_INACTIVE: |
| 571 | res.state = ALLOC_OBJECT_STATE_INACTIVE; |
| 572 | break; |
| 573 | case BCMOLT_ACTIVATION_STATE_PROCESSING: |
| 574 | res.state = ALLOC_OBJECT_STATE_PROCESSING; |
| 575 | break; |
| 576 | case BCMOLT_ACTIVATION_STATE_ACTIVE: |
| 577 | res.state = ALLOC_OBJECT_STATE_ACTIVE; |
| 578 | break; |
| 579 | default: |
| 580 | OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon alloc activation new_state, pon_intf %u, alloc_id %u, new_state %d\n", |
| 581 | pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->new_state); |
| 582 | res.state = ALLOC_OBJECT_STATE_NOT_CONFIGURED; |
| 583 | } |
| 584 | 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", |
| 585 | pkt->key.pon_ni, pkt->key.alloc_id, pkt_data->status, pkt_data->new_state); |
| 586 | |
| 587 | bcmos_fastlock_lock(&alloc_cfg_wait_lock); |
| 588 | // Push the result from BAL to queue |
| 589 | std::map<alloc_cfg_compltd_key, Queue<alloc_cfg_complete_result> *>::iterator it = alloc_cfg_compltd_map.find(key); |
| 590 | if (it == alloc_cfg_compltd_map.end()) { |
| 591 | // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key. |
| 592 | bcmolt_msg_free(msg); |
| 593 | 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); |
| 594 | bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0); |
| 595 | return; |
| 596 | } |
| 597 | if (it->second) { |
| 598 | // Push the result |
| 599 | it->second->push(res); |
| 600 | } |
| 601 | bcmos_fastlock_unlock(&alloc_cfg_wait_lock, 0); |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | bcmolt_msg_free(msg); |
| 607 | } |
| 608 | |
Thiyagarajan Subramani | e976fcf | 2021-05-07 22:46:57 +0530 | [diff] [blame] | 609 | static void ItuPonGemConfigCompletedInd(bcmolt_devid olt, bcmolt_msg *msg) { |
| 610 | |
| 611 | switch (msg->obj_type) { |
| 612 | case BCMOLT_OBJ_ID_ITUPON_GEM: |
| 613 | switch (msg->subgroup) { |
| 614 | case BCMOLT_ITUPON_GEM_AUTO_SUBGROUP_CONFIGURATION_COMPLETED: |
| 615 | { |
| 616 | bcmolt_itupon_gem_configuration_completed *pkt = |
| 617 | (bcmolt_itupon_gem_configuration_completed*)msg; |
| 618 | bcmolt_itupon_gem_configuration_completed_data *pkt_data = |
| 619 | &((bcmolt_itupon_gem_configuration_completed*)msg)->data; |
| 620 | |
| 621 | gem_cfg_compltd_key key((uint32_t)pkt->key.pon_ni, (uint32_t) pkt->key.gem_port_id); |
| 622 | gem_cfg_complete_result res; |
| 623 | res.pon_intf_id = pkt->key.pon_ni; |
| 624 | res.gem_port_id = pkt->key.gem_port_id; |
| 625 | |
| 626 | pkt_data->status == BCMOLT_RESULT_SUCCESS ? res.status = GEM_CFG_STATUS_SUCCESS: res.status = GEM_CFG_STATUS_FAIL; |
| 627 | switch (pkt_data->new_state) { |
| 628 | case BCMOLT_ACTIVATION_STATE_NOT_CONFIGURED: |
| 629 | res.state = GEM_OBJECT_STATE_NOT_CONFIGURED; |
| 630 | break; |
| 631 | case BCMOLT_ACTIVATION_STATE_INACTIVE: |
| 632 | res.state = GEM_OBJECT_STATE_INACTIVE; |
| 633 | break; |
| 634 | case BCMOLT_ACTIVATION_STATE_PROCESSING: |
| 635 | res.state = GEM_OBJECT_STATE_PROCESSING; |
| 636 | break; |
| 637 | case BCMOLT_ACTIVATION_STATE_ACTIVE: |
| 638 | res.state = GEM_OBJECT_STATE_ACTIVE; |
| 639 | break; |
| 640 | default: |
| 641 | OPENOLT_LOG(ERROR, openolt_log_id, "invalid itu pon gem activation new_state, pon_intf %u, gem_port_id %u, new_state %d\n", |
| 642 | pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->new_state); |
| 643 | res.state = GEM_OBJECT_STATE_NOT_CONFIGURED; |
| 644 | } |
| 645 | 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", |
| 646 | pkt->key.pon_ni, pkt->key.gem_port_id, pkt_data->status, pkt_data->new_state); |
| 647 | |
| 648 | uint32_t gem_cfg_key_check_counter = 1; |
| 649 | std::map<gem_cfg_compltd_key, Queue<gem_cfg_complete_result> *>::iterator it; |
| 650 | while(true) { |
| 651 | bcmos_fastlock_lock(&gem_cfg_wait_lock); |
| 652 | // Push the result from BAL to queue |
| 653 | it = gem_cfg_compltd_map.find(key); |
| 654 | |
| 655 | if (it != gem_cfg_compltd_map.end()) { |
| 656 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 657 | break; |
| 658 | } else if (it == gem_cfg_compltd_map.end() && gem_cfg_key_check_counter < MAX_GEM_CFG_KEY_CHECK) { |
| 659 | /*During removal of gemport, indication from BAL arriving soon even before we start waiting for gemport cfg completion |
| 660 | by pushing empty cfg_result for gem_cfg_compltd_key. To handle this scenario delaying to push gem cfg completion indication |
| 661 | to Queue by 6ms.*/ |
| 662 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 663 | bcmos_usleep(6000); |
| 664 | } else { |
| 665 | // could be case of spurious aysnc response, OR, the application timed-out waiting for response and cleared the key. |
| 666 | bcmolt_msg_free(msg); |
| 667 | 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); |
| 668 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 669 | return; |
| 670 | } |
| 671 | gem_cfg_key_check_counter++; |
| 672 | } |
| 673 | |
| 674 | bcmos_fastlock_lock(&gem_cfg_wait_lock); |
| 675 | if (it->second) { |
| 676 | // Push the result |
| 677 | it->second->push(res); |
| 678 | } |
| 679 | bcmos_fastlock_unlock(&gem_cfg_wait_lock, 0); |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | bcmolt_msg_free(msg); |
| 685 | } |
| 686 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 687 | static void FlowOperIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 688 | openolt::Indication ind; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 689 | OPENOLT_LOG(DEBUG, openolt_log_id, "flow oper state indication\n"); |
| 690 | bcmolt_msg_free(msg); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 691 | } |
| 692 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 693 | static void FlowIndication(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 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 TmQIndication(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, "traffic mgmt queue 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 TmSchedIndication(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 sheduler 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 McastGroupIndication(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, "mcast group 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 OnuStartupFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 718 | openolt::Indication ind; |
| 719 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 720 | openolt::OnuStartupFailureIndication* sufi_ind = new openolt::OnuStartupFailureIndication; |
| 721 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 722 | switch (msg->obj_type) { |
| 723 | case BCMOLT_OBJ_ID_ONU: |
| 724 | switch (msg->subgroup) { |
| 725 | case BCMOLT_ONU_AUTO_SUBGROUP_SUFI: |
| 726 | { |
| 727 | bcmolt_onu_key *key = &((bcmolt_onu_sufi*)msg)->key; |
| 728 | bcmolt_onu_sufi_data *data = &((bcmolt_onu_sufi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 729 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 730 | OPENOLT_LOG(WARNING, openolt_log_id, "onu startup failure indication, intf_id %d, onu_id %d, alarm %d\n", |
| 731 | key->pon_ni, key->onu_id, data->alarm_status); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 732 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 733 | sufi_ind->set_intf_id(key->pon_ni); |
| 734 | sufi_ind->set_onu_id(key->onu_id); |
| 735 | sufi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 736 | alarm_ind->set_allocated_onu_startup_fail_ind(sufi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 737 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 738 | ind.set_allocated_alarm_ind(alarm_ind); |
| 739 | } |
| 740 | } |
| 741 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 742 | |
| 743 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 744 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 745 | } |
| 746 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 747 | static void OnuSignalDegradeIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 748 | openolt::Indication ind; |
| 749 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 750 | openolt::OnuSignalDegradeIndication* sdi_ind = new openolt::OnuSignalDegradeIndication; |
| 751 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 752 | switch (msg->obj_type) { |
| 753 | case BCMOLT_OBJ_ID_ONU: |
| 754 | switch (msg->subgroup) { |
| 755 | case BCMOLT_ONU_AUTO_SUBGROUP_SDI: |
| 756 | { |
| 757 | bcmolt_onu_key *key = &((bcmolt_onu_sdi*)msg)->key; |
| 758 | bcmolt_onu_sdi_data *data = &((bcmolt_onu_sdi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 759 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 760 | OPENOLT_LOG(WARNING, openolt_log_id, "onu signal degrade indication, intf_id %d, onu_id %d, alarm %d, BER %d\n", |
| 761 | key->pon_ni, key->onu_id, data->alarm_status, data->ber); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 762 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 763 | sdi_ind->set_intf_id(key->pon_ni); |
| 764 | sdi_ind->set_onu_id(key->onu_id); |
| 765 | sdi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 766 | sdi_ind->set_inverse_bit_error_rate(data->ber); |
| 767 | alarm_ind->set_allocated_onu_signal_degrade_ind(sdi_ind); |
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 | ind.set_allocated_alarm_ind(alarm_ind); |
| 770 | } |
| 771 | } |
| 772 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 773 | |
| 774 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 775 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 776 | } |
| 777 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 778 | static void OnuDriftOfWindowIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 779 | openolt::Indication ind; |
| 780 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 781 | openolt::OnuDriftOfWindowIndication* dowi_ind = new openolt::OnuDriftOfWindowIndication; |
| 782 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 783 | switch (msg->obj_type) { |
| 784 | case BCMOLT_OBJ_ID_ONU: |
| 785 | switch (msg->subgroup) { |
| 786 | case BCMOLT_ONU_AUTO_SUBGROUP_DOWI: |
| 787 | { |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 788 | bcmolt_onu_key *key = &((bcmolt_onu_dowi*)msg)->key; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 789 | bcmolt_onu_dowi_data *data = &((bcmolt_onu_dowi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 790 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 791 | 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", |
| 792 | 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] | 793 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 794 | dowi_ind->set_intf_id(key->pon_ni); |
| 795 | dowi_ind->set_onu_id(key->onu_id); |
| 796 | dowi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 797 | dowi_ind->set_drift(data->drift_value); |
| 798 | dowi_ind->set_new_eqd(data->new_eqd); |
| 799 | alarm_ind->set_allocated_onu_drift_of_window_ind(dowi_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 800 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 801 | ind.set_allocated_alarm_ind(alarm_ind); |
| 802 | } |
| 803 | } |
| 804 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 805 | |
| 806 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 807 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 808 | } |
| 809 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 810 | static void OnuLossOfOmciChannelIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 811 | openolt::Indication ind; |
| 812 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 813 | openolt::OnuLossOfOmciChannelIndication* looci_ind = new openolt::OnuLossOfOmciChannelIndication; |
| 814 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 815 | switch (msg->obj_type) { |
| 816 | case BCMOLT_OBJ_ID_ONU: |
| 817 | switch (msg->subgroup) { |
| 818 | case BCMOLT_ONU_AUTO_SUBGROUP_LOOCI: |
| 819 | { |
| 820 | bcmolt_onu_key *key = &((bcmolt_onu_looci*)msg)->key; |
| 821 | bcmolt_onu_looci_data *data = &((bcmolt_onu_looci*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 822 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 823 | OPENOLT_LOG(WARNING, openolt_log_id, "onu loss of OMCI channel indication, intf_id %d, onu_id %d, alarm %d\n", |
| 824 | key->pon_ni, key->onu_id, data->alarm_status); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 825 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 826 | looci_ind->set_intf_id(key->pon_ni); |
| 827 | looci_ind->set_onu_id(key->onu_id); |
| 828 | looci_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 829 | alarm_ind->set_allocated_onu_loss_omci_ind(looci_ind); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 830 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 831 | ind.set_allocated_alarm_ind(alarm_ind); |
| 832 | } |
| 833 | } |
| 834 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 835 | |
| 836 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 837 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 838 | } |
| 839 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 840 | static void OnuSignalsFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 841 | openolt::Indication ind; |
| 842 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 843 | openolt::OnuSignalsFailureIndication* sfi_ind = new openolt::OnuSignalsFailureIndication; |
| 844 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 845 | switch (msg->obj_type) { |
| 846 | case BCMOLT_OBJ_ID_ONU: |
| 847 | switch (msg->subgroup) { |
| 848 | case BCMOLT_ONU_AUTO_SUBGROUP_SFI: |
| 849 | { |
| 850 | bcmolt_onu_key *key = &((bcmolt_onu_sfi*)msg)->key; |
| 851 | bcmolt_onu_sfi_data *data = &((bcmolt_onu_sfi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 852 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 853 | OPENOLT_LOG(WARNING, openolt_log_id, "onu signals failure indication, intf_id %d, onu_id %d, alarm %d, BER %d\n", |
| 854 | key->pon_ni, key->onu_id, data->alarm_status, data->ber); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 855 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 856 | sfi_ind->set_intf_id(key->pon_ni); |
| 857 | sfi_ind->set_onu_id(key->onu_id); |
| 858 | sfi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 859 | sfi_ind->set_inverse_bit_error_rate(data->ber); |
| 860 | alarm_ind->set_allocated_onu_signals_fail_ind(sfi_ind); |
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 | ind.set_allocated_alarm_ind(alarm_ind); |
| 863 | } |
| 864 | } |
| 865 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 866 | |
| 867 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 868 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 869 | } |
| 870 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 871 | static void OnuTransmissionInterferenceWarningIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 872 | openolt::Indication ind; |
| 873 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 874 | openolt::OnuTransmissionInterferenceWarning* tiwi_ind = new openolt::OnuTransmissionInterferenceWarning; |
| 875 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 876 | switch (msg->obj_type) { |
| 877 | case BCMOLT_OBJ_ID_ONU: |
| 878 | switch (msg->subgroup) { |
| 879 | case BCMOLT_ONU_AUTO_SUBGROUP_TIWI: |
| 880 | { |
| 881 | bcmolt_onu_key *key = &((bcmolt_onu_tiwi*)msg)->key; |
| 882 | bcmolt_onu_tiwi_data *data = &((bcmolt_onu_tiwi*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 883 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 884 | OPENOLT_LOG(WARNING, openolt_log_id, "onu transmission interference warning indication, intf_id %d, onu_id %d, alarm %d, drift %d\n", |
| 885 | key->pon_ni, key->onu_id, data->alarm_status, data->drift_value); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 886 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 887 | tiwi_ind->set_intf_id(key->pon_ni); |
| 888 | tiwi_ind->set_onu_id(key->onu_id); |
| 889 | tiwi_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 890 | tiwi_ind->set_drift(data->drift_value); |
| 891 | alarm_ind->set_allocated_onu_tiwi_ind(tiwi_ind); |
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 | ind.set_allocated_alarm_ind(alarm_ind); |
| 894 | } |
| 895 | } |
| 896 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 897 | |
| 898 | oltIndQ.push(ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 899 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 900 | } |
| 901 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 902 | static void OnuActivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 903 | openolt::Indication ind; |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 904 | openolt::OnuIndication* onu_ind = new openolt::OnuIndication; |
| 905 | |
| 906 | switch (msg->obj_type) { |
| 907 | case BCMOLT_OBJ_ID_ONU: |
| 908 | switch (msg->subgroup) { |
| 909 | case BCMOLT_ONU_AUTO_SUBGROUP_ONU_ACTIVATION_COMPLETED: |
| 910 | { |
| 911 | bcmolt_onu_key *key = &((bcmolt_onu_onu_activation_completed*)msg)->key; |
| 912 | bcmolt_onu_onu_activation_completed_data*data = &((bcmolt_onu_onu_activation_completed*)msg)->data; |
| 913 | |
| 914 | onu_ind->set_intf_id(key->pon_ni); |
| 915 | onu_ind->set_onu_id(key->onu_id); |
| 916 | if (ONU_ACTIVATION_COMPLETED_SUCCESS(data->status)) |
| 917 | onu_ind->set_oper_state("up"); |
| 918 | if (ONU_ACTIVATION_COMPLETED_FAIL(data->status)) |
| 919 | onu_ind->set_oper_state("down"); |
kesavand | 88fdddd | 2020-09-04 12:06:34 +0530 | [diff] [blame] | 920 | switch (data->fail_reason) { |
| 921 | case BCMOLT_ACTIVATION_FAIL_REASON_RANGING: |
| 922 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_RANGING); |
| 923 | break; |
| 924 | case BCMOLT_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION: |
| 925 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_PASSWORD_AUTHENTICATION); |
| 926 | break; |
| 927 | case BCMOLT_ACTIVATION_FAIL_REASON_LOS: |
| 928 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_LOS); |
| 929 | break; |
| 930 | case BCMOLT_ACTIVATION_FAIL_REASON_ONU_ALARM: |
| 931 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_ONU_ALARM); |
| 932 | break; |
| 933 | case BCMOLT_ACTIVATION_FAIL_REASON_SWITCH_OVER: |
| 934 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_SWITCH_OVER); |
| 935 | break; |
| 936 | default: |
| 937 | onu_ind->set_fail_reason(openolt::OnuIndication_ActivationFailReason_ONU_ACTIVATION_FAIL_REASON_NONE); |
| 938 | } |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 939 | // Setting the admin_state state field based on a valid onu_id does not make any sense. |
| 940 | // The adapter too does not seem to interpret this seriously. |
| 941 | // Legacy code, lets keep this as is for now. |
| 942 | (key->onu_id)?onu_ind->set_admin_state("up"):onu_ind->set_admin_state("down"); |
| 943 | ind.set_allocated_onu_ind(onu_ind); |
| 944 | OPENOLT_LOG(INFO, openolt_log_id, "onu indication, pon_ni %d, onu_id %d, onu_state %s, onu_admin %s\n", |
| 945 | key->pon_ni, key->onu_id, (data->status==BCMOLT_RESULT_SUCCESS)?"up":"down", |
| 946 | (key->onu_id)?"up":"down"); |
| 947 | } |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | oltIndQ.push(ind); |
| 952 | bcmolt_msg_free(msg); |
| 953 | } |
| 954 | |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 955 | static void OnuLossOfKeySyncFailureIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 956 | openolt::Indication ind; |
| 957 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 958 | openolt::OnuLossOfKeySyncFailureIndication* loss_of_sync_fail_ind = new openolt::OnuLossOfKeySyncFailureIndication; |
| 959 | |
| 960 | switch (msg->obj_type) { |
| 961 | case BCMOLT_OBJ_ID_ONU: |
| 962 | switch (msg->subgroup) { |
| 963 | case BCMOLT_ONU_AUTO_SUBGROUP_LOKI: |
| 964 | { |
| 965 | bcmolt_onu_key *key = &((bcmolt_onu_loki*)msg)->key; |
| 966 | bcmolt_onu_loki_data *data = &((bcmolt_onu_loki*)msg)->data; |
| 967 | |
| 968 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu loss of key sync, intf_id %d, onu_id %d, alarm_status %d\n", |
| 969 | key->pon_ni, key->onu_id, data->alarm_status); |
| 970 | |
| 971 | loss_of_sync_fail_ind->set_intf_id(key->pon_ni); |
| 972 | loss_of_sync_fail_ind->set_onu_id(key->onu_id); |
| 973 | loss_of_sync_fail_ind->set_status(alarm_status_to_string(data->alarm_status)); |
| 974 | alarm_ind->set_allocated_onu_loss_of_sync_fail_ind(loss_of_sync_fail_ind); |
| 975 | |
| 976 | ind.set_allocated_alarm_ind(alarm_ind); |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | oltIndQ.push(ind); |
| 982 | bcmolt_msg_free(msg); |
| 983 | } |
| 984 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 985 | static void OnuItuPonStatsAlarmRaisedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 986 | openolt::Indication ind; |
| 987 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 988 | openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication; |
| 989 | |
| 990 | switch (msg->obj_type) { |
| 991 | case BCMOLT_OBJ_ID_ONU: |
| 992 | switch (msg->subgroup) { |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 993 | case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_RAISED: |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 994 | { |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 995 | bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_raised*)msg)->key; |
| 996 | 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] | 997 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 998 | if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_RAISED_DATA_ID_STAT)) { |
| 999 | switch (data->stat) |
| 1000 | { |
| 1001 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS: |
| 1002 | uint64_t rdi_errors; |
| 1003 | openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication; |
| 1004 | rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1005 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1006 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1007 | rdi_err_ind->set_rdi_error_count(rdi_errors); |
| 1008 | rdi_err_ind->set_status("on"); |
| 1009 | onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind); |
| 1010 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \ |
| 1011 | rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors); |
| 1012 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1013 | break; |
| 1014 | /* It is a further requirement |
| 1015 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS: |
| 1016 | uint64_t bip_errors; |
| 1017 | bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1018 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1019 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1020 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu raised alarm indication, intf_id %d, onu_id %d, \ |
| 1021 | bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors); |
| 1022 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1023 | break; |
| 1024 | */ |
| 1025 | } |
| 1026 | ind.set_allocated_alarm_ind(alarm_ind); |
| 1027 | } |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | oltIndQ.push(ind); |
| 1033 | bcmolt_msg_free(msg); |
| 1034 | } |
| 1035 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1036 | static void OnuItuPonStatsAlarmClearedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1037 | openolt::Indication ind; |
| 1038 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 1039 | openolt::OnuItuPonStatsIndication* onu_itu_pon_stats_ind = new openolt::OnuItuPonStatsIndication; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1040 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1041 | switch (msg->obj_type) { |
| 1042 | case BCMOLT_OBJ_ID_ONU: |
| 1043 | switch (msg->subgroup) { |
| 1044 | case BCMOLT_ONU_AUTO_SUBGROUP_ITU_PON_STATS_ALARM_CLEARED: |
| 1045 | { |
| 1046 | bcmolt_onu_key *onu_key = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->key; |
| 1047 | bcmolt_onu_itu_pon_stats_alarm_cleared_data *data = &((bcmolt_onu_itu_pon_stats_alarm_cleared*)msg)->data; |
| 1048 | |
| 1049 | if (_BCMOLT_FIELD_MASK_BIT_IS_SET(data->presence_mask, BCMOLT_ONU_ITU_PON_STATS_ALARM_CLEARED_DATA_ID_STAT)) { |
| 1050 | switch (data->stat) |
| 1051 | { |
| 1052 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_RDI_ERRORS: |
| 1053 | uint64_t rdi_errors; |
| 1054 | openolt::RdiErrorIndication* rdi_err_ind = new openolt::RdiErrorIndication; |
| 1055 | |
| 1056 | rdi_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1057 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1058 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1059 | rdi_err_ind->set_rdi_error_count(rdi_errors); |
| 1060 | rdi_err_ind->set_status("off"); |
| 1061 | onu_itu_pon_stats_ind->set_allocated_rdi_error_ind(rdi_err_ind); |
| 1062 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \ |
| 1063 | rdi_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, rdi_errors); |
| 1064 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1065 | break; |
| 1066 | /* It is a further requirement |
| 1067 | case BCMOLT_ONU_ITU_PON_STATS_DATA_ID_BIP_ERRORS: |
| 1068 | uint64_t bip_errors; |
| 1069 | bip_errors = get_pon_stats_alarms_data(onu_key->pon_ni, onu_key->onu_id, data->stat); |
| 1070 | onu_itu_pon_stats_ind->set_intf_id(onu_key->pon_ni); |
| 1071 | onu_itu_pon_stats_ind->set_onu_id(onu_key->onu_id); |
| 1072 | onu_itu_pon_stats_ind->set_bip_errors(bip_errors); |
| 1073 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu cleared alarm indication, intf_id %d, onu_id %d, \ |
| 1074 | bip_errors %"PRIu64"\n", onu_key->pon_ni, onu_key->onu_id, bip_errors); |
| 1075 | alarm_ind->set_allocated_onu_itu_pon_stats_ind(onu_itu_pon_stats_ind); |
| 1076 | break; |
| 1077 | */ |
| 1078 | } |
| 1079 | ind.set_allocated_alarm_ind(alarm_ind); |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | } |
| 1084 | |
| 1085 | oltIndQ.push(ind); |
| 1086 | bcmolt_msg_free(msg); |
| 1087 | } |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1088 | |
| 1089 | static void OnuDeactivationCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1090 | openolt::Indication ind; |
| 1091 | |
| 1092 | openolt::Indication onu_ind; |
| 1093 | openolt::OnuIndication* onu_ind_data = new openolt::OnuIndication; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1094 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1095 | switch (msg->obj_type) { |
| 1096 | case BCMOLT_OBJ_ID_ONU: |
| 1097 | switch (msg->subgroup) { |
| 1098 | case BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED: |
| 1099 | { |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1100 | bcmolt_onu_key *key = &((bcmolt_onu_onu_deactivation_completed*)msg)->key; |
| 1101 | bcmolt_onu_onu_deactivation_completed_data *data = |
| 1102 | &((bcmolt_onu_onu_deactivation_completed*)msg)->data; |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1103 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1104 | OPENOLT_LOG(INFO, openolt_log_id, "Got onu deactivation, intf_id %d, onu_id %d, fail_reason %d, result_status %s\n", |
| 1105 | 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] | 1106 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1107 | onu_ind_data->set_intf_id(key->pon_ni); |
| 1108 | onu_ind_data->set_onu_id(key->onu_id); |
| 1109 | onu_ind_data->set_oper_state("down"); |
| 1110 | onu_ind_data->set_admin_state("down"); |
| 1111 | onu_ind.set_allocated_onu_ind(onu_ind_data); |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1112 | |
| 1113 | onu_deact_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t) key->onu_id); |
| 1114 | onu_deactivate_complete_result res; |
| 1115 | res.pon_intf_id = (uint32_t)key->pon_ni; |
| 1116 | res.onu_id = (uint32_t) key->onu_id; |
| 1117 | res.result = data->status; |
| 1118 | res.reason = data->fail_reason; |
| 1119 | |
| 1120 | OPENOLT_LOG(INFO, openolt_log_id, "received onu deactivate result, pon intf %u, onu_id %u, status %u, reason %u\n", |
| 1121 | key->pon_ni, key->onu_id, data->status, data->fail_reason); |
| 1122 | |
| 1123 | bcmos_fastlock_lock(&onu_deactivate_wait_lock); |
| 1124 | // Push the result from BAL to queue |
| 1125 | std::map<onu_deact_compltd_key, Queue<onu_deactivate_complete_result> *>::iterator it = onu_deact_compltd_map.find(onu_key); |
| 1126 | if (it == onu_deact_compltd_map.end()) { |
| 1127 | // 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] | 1128 | // OR most importantly, could be a case of ONU going down (reboot, PON cable plug-out) where |
| 1129 | // BCMOLT_ONU_AUTO_SUBGROUP_ONU_DEACTIVATION_COMPLETED is received without any explicit request from the application. |
| 1130 | // The application has to take care handling spurious indications. |
Thiyagarajan Subramani | ad46323 | 2020-02-28 19:10:43 +0530 | [diff] [blame] | 1131 | 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] | 1132 | key->pon_ni, key->onu_id); |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1133 | } |
Girish Gowdra | 6675fa0 | 2020-03-03 20:27:50 -0800 | [diff] [blame] | 1134 | else if (it->second) { |
Girish Gowdra | 7a79dae | 2020-02-10 18:22:11 +0530 | [diff] [blame] | 1135 | // Push the result |
| 1136 | it->second->push(res); |
| 1137 | } |
| 1138 | bcmos_fastlock_unlock(&onu_deactivate_wait_lock, 0); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1139 | } |
| 1140 | } |
| 1141 | } |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1142 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1143 | oltIndQ.push(onu_ind); |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1144 | bcmolt_msg_free(msg); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1145 | } |
| 1146 | |
Orhan Kupusoglu | ec57af0 | 2021-05-12 12:38:17 +0000 | [diff] [blame] | 1147 | static void OnuRssiMeasurementCompletedIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1148 | switch (msg->obj_type) { |
| 1149 | case BCMOLT_OBJ_ID_ONU: |
| 1150 | switch (msg->subgroup) { |
| 1151 | case BCMOLT_ONU_AUTO_SUBGROUP_RSSI_MEASUREMENT_COMPLETED: |
| 1152 | { |
| 1153 | bcmolt_onu_key *key = &((bcmolt_onu_rssi_measurement_completed*)msg)->key; |
| 1154 | bcmolt_onu_rssi_measurement_completed_data *data = &((bcmolt_onu_rssi_measurement_completed*)msg)->data; |
| 1155 | double rx_power_mean_dbm = 0.0; |
| 1156 | |
| 1157 | OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - pon_id: %d, onu_id: %d, status: %d, fail_reason: %d\n", |
| 1158 | key->pon_ni, key->onu_id, data->status, data->fail_reason); |
| 1159 | |
| 1160 | if (data->status == BCMOLT_RESULT_SUCCESS) { |
| 1161 | auto trx_eeprom_reader = |
| 1162 | #ifdef ASGVOLT64 |
| 1163 | TrxEepromReader{TrxEepromReader::DEVICE_GPON, TrxEepromReader::RX_POWER, key->pon_ni}; |
| 1164 | #else |
| 1165 | TrxEepromReader{TrxEepromReader::DEVICE_XGSPON, TrxEepromReader::RX_POWER, key->pon_ni}; |
| 1166 | #endif |
| 1167 | auto power = trx_eeprom_reader.read_power_mean_dbm(); |
| 1168 | |
| 1169 | if (power.second) { |
| 1170 | rx_power_mean_dbm = power.first.first; |
| 1171 | OPENOLT_LOG(INFO, openolt_log_id, "ONU RSSI Measurement Completed indication - rx_power_mean_dbm: %f\n", rx_power_mean_dbm); |
| 1172 | } else { |
| 1173 | OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - Rx power read failure\n"); |
| 1174 | } |
| 1175 | } else { |
| 1176 | OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed indication - failure"); |
| 1177 | } |
| 1178 | |
| 1179 | // for internal use insert into map |
| 1180 | onu_rssi_compltd_key onu_key((uint32_t)key->pon_ni, (uint32_t)key->onu_id); |
| 1181 | onu_rssi_complete_result res; |
| 1182 | res.pon_intf_id = (uint32_t)key->pon_ni; |
| 1183 | res.onu_id = (uint32_t)key->onu_id; |
| 1184 | res.status = bcmolt_result_to_string(data->status); |
| 1185 | res.reason = data->fail_reason; |
| 1186 | res.rx_power_mean_dbm = rx_power_mean_dbm; |
| 1187 | |
| 1188 | bcmos_fastlock_lock(&onu_rssi_wait_lock); |
| 1189 | auto it = onu_rssi_compltd_map.find(onu_key); |
| 1190 | if (it == onu_rssi_compltd_map.end()) { |
| 1191 | OPENOLT_LOG(ERROR, openolt_log_id, "ONU RSSI Measurement Completed key not found for pon intf %u, onu_id %u\n", |
| 1192 | key->pon_ni, key->onu_id); |
| 1193 | } else if (it->second) { |
| 1194 | it->second->push(res); |
| 1195 | } else { |
| 1196 | OPENOLT_LOG(WARNING, openolt_log_id, "ONU RSSI Measurement Completed queue not found for pon intf %u, onu_id %u\n", |
| 1197 | key->pon_ni, key->onu_id); |
| 1198 | } |
| 1199 | bcmos_fastlock_unlock(&onu_rssi_wait_lock, 0); |
| 1200 | } |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | bcmolt_msg_free(msg); |
| 1205 | } |
| 1206 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1207 | /* removed by BAL v3.0 |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1208 | bcmos_errno OnuProcessingErrorIndication(bcmbal_obj *obj) { |
| 1209 | openolt::Indication ind; |
| 1210 | openolt::AlarmIndication* alarm_ind = new openolt::AlarmIndication; |
| 1211 | openolt::OnuProcessingErrorIndication* onu_proc_error_ind = new openolt::OnuProcessingErrorIndication; |
| 1212 | |
| 1213 | bcmbal_subscriber_terminal_key *key = |
| 1214 | &(((bcmbal_subscriber_terminal_processing_error*)obj)->key); |
| 1215 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1216 | 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] | 1217 | key->intf_id, key->sub_term_id); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1218 | |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1219 | onu_proc_error_ind->set_intf_id(key->intf_id); |
| 1220 | onu_proc_error_ind->set_onu_id(key->sub_term_id); |
| 1221 | |
| 1222 | alarm_ind->set_allocated_onu_processing_error_ind(onu_proc_error_ind); |
| 1223 | ind.set_allocated_alarm_ind(alarm_ind); |
| 1224 | |
| 1225 | oltIndQ.push(ind); |
| 1226 | return BCM_ERR_OK; |
| 1227 | } |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1228 | */ |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1229 | |
Burak Gurdag | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 1230 | static void GroupIndication(bcmolt_devid olt, bcmolt_msg *msg) { |
| 1231 | |
| 1232 | switch (msg->obj_type) { |
| 1233 | case BCMOLT_OBJ_ID_GROUP: |
| 1234 | switch (msg->subgroup) { |
| 1235 | case BCMOLT_GROUP_AUTO_SUBGROUP_COMPLETE_MEMBERS_UPDATE: |
| 1236 | { |
| 1237 | bcmolt_group_key *key = &((bcmolt_group_complete_members_update*)msg)->key; |
| 1238 | bcmolt_group_complete_members_update_data *data = |
| 1239 | &((bcmolt_group_complete_members_update*)msg)->data; |
| 1240 | |
| 1241 | if (data->result == BCMOLT_RESULT_SUCCESS) { |
| 1242 | OPENOLT_LOG(INFO, openolt_log_id, "Complete members update indication for group %d (successful)\n", key->id); |
| 1243 | } else { |
| 1244 | OPENOLT_LOG(ERROR, openolt_log_id, "Complete members update indication for group %d (failed with reason %d)\n", key->id, data->fail_reason); |
| 1245 | } |
| 1246 | } |
| 1247 | } |
| 1248 | } |
| 1249 | bcmolt_msg_free(msg); |
| 1250 | } |
| 1251 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1252 | Status SubscribeIndication() { |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1253 | bcmolt_rx_cfg rx_cfg = {}; |
| 1254 | bcmos_errno rc; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1255 | |
| 1256 | if (subscribed) { |
| 1257 | return Status::OK; |
| 1258 | } |
| 1259 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1260 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 1261 | rx_cfg.rx_cb = OltOperIndication; |
| 1262 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1263 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_complete; |
| 1264 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1265 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1266 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1267 | "Olt connection complete state indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1268 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1269 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 1270 | rx_cfg.rx_cb = OltOperIndication; |
| 1271 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1272 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_disconnection_complete; |
| 1273 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1274 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1275 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1276 | "Olt disconnection complete state indication subscribe failed"); |
| 1277 | |
| 1278 | rx_cfg.obj_type = BCMOLT_OBJ_ID_DEVICE; |
| 1279 | rx_cfg.rx_cb = OltOperIndication; |
| 1280 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1281 | rx_cfg.subgroup = bcmolt_device_auto_subgroup_connection_failure; |
| 1282 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1283 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1284 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1285 | "Olt connection failure state indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1286 | |
| 1287 | /* Interface LOS indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1288 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 1289 | rx_cfg.rx_cb = LosIndication; |
| 1290 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1291 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_los; |
| 1292 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1293 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1294 | return Status(grpc::StatusCode::INTERNAL, "LOS indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1295 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1296 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 1297 | rx_cfg.rx_cb = IfOperIndication; |
| 1298 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1299 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_state_change_completed; |
| 1300 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1301 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1302 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1303 | "PON Interface operations state change indication subscribe failed"); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 1304 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1305 | rx_cfg.obj_type = BCMOLT_OBJ_ID_NNI_INTERFACE; |
| 1306 | rx_cfg.rx_cb = IfOperIndication; |
| 1307 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1308 | rx_cfg.subgroup = bcmolt_nni_interface_auto_subgroup_state_change; |
| 1309 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1310 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1311 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1312 | "NNI Interface operations state change indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1313 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1314 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1315 | rx_cfg.rx_cb = OnuAlarmIndication; |
| 1316 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1317 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_xgpon_alarm; |
| 1318 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1319 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1320 | return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1321 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1322 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1323 | rx_cfg.rx_cb = OnuAlarmIndication; |
| 1324 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1325 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_gpon_alarm; |
| 1326 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1327 | if(rc != BCM_ERR_OK) |
| 1328 | return Status(grpc::StatusCode::INTERNAL, "onu alarm indication subscribe failed"); |
| 1329 | |
| 1330 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1331 | rx_cfg.rx_cb = OnuDyingGaspIndication; |
| 1332 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1333 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dgi; |
| 1334 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1335 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1336 | return Status(grpc::StatusCode::INTERNAL, "onu dying-gasp indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1337 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1338 | rx_cfg.obj_type = BCMOLT_OBJ_ID_PON_INTERFACE; |
| 1339 | rx_cfg.rx_cb = OnuDiscoveryIndication; |
| 1340 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1341 | rx_cfg.subgroup = bcmolt_pon_interface_auto_subgroup_onu_discovered; |
| 1342 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1343 | if(rc != BCM_ERR_OK) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1344 | return Status(grpc::StatusCode::INTERNAL, "onu discovery indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1345 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1346 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1347 | rx_cfg.rx_cb = OnuStartupFailureIndication; |
| 1348 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1349 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sufi; |
| 1350 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1351 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1352 | return Status(grpc::StatusCode::INTERNAL, |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1353 | "onu startup failure indication subscribe failed"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1354 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1355 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1356 | rx_cfg.rx_cb = OnuSignalDegradeIndication; |
| 1357 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1358 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sdi; |
| 1359 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1360 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1361 | return Status(grpc::StatusCode::INTERNAL, "onu sdi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1362 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1363 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1364 | rx_cfg.rx_cb = OnuDriftOfWindowIndication; |
| 1365 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1366 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_dowi; |
| 1367 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1368 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1369 | return Status(grpc::StatusCode::INTERNAL, "onu dowi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1370 | |
| 1371 | /* LOOCI indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1372 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1373 | rx_cfg.rx_cb = OnuLossOfOmciChannelIndication; |
| 1374 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1375 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_looci; |
| 1376 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1377 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1378 | return Status(grpc::StatusCode::INTERNAL, "onu looci indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1379 | |
| 1380 | /* SFI indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1381 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1382 | rx_cfg.rx_cb = OnuSignalsFailureIndication; |
| 1383 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1384 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_sfi; |
| 1385 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1386 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1387 | return Status(grpc::StatusCode::INTERNAL, "onu sfi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1388 | |
| 1389 | /* TIWI indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1390 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1391 | rx_cfg.rx_cb = OnuTransmissionInterferenceWarningIndication; |
| 1392 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1393 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_tiwi; |
| 1394 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1395 | if(rc != BCM_ERR_OK) |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1396 | return Status(grpc::StatusCode::INTERNAL, "onu tiwi indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1397 | |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1398 | /* ONU Activation Completed Indication */ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1399 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1400 | rx_cfg.rx_cb = OnuActivationCompletedIndication; |
| 1401 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1402 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_activation_completed; |
| 1403 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1404 | if(rc != BCM_ERR_OK) |
| 1405 | return Status(grpc::StatusCode::INTERNAL, |
| 1406 | "onu activation completed indication subscribe failed"); |
| 1407 | |
| 1408 | /* ONU Deactivation Completed Indication */ |
| 1409 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1410 | rx_cfg.rx_cb = OnuDeactivationCompletedIndication; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1411 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1412 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_onu_deactivation_completed; |
| 1413 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1414 | if(rc != BCM_ERR_OK) |
Girish Gowdra | 0c0b5c0 | 2019-12-16 14:11:08 +0530 | [diff] [blame] | 1415 | return Status(grpc::StatusCode::INTERNAL, |
| 1416 | "onu deactivation indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1417 | |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1418 | /* ONU Loss of Key Sync Indiction */ |
| 1419 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1420 | rx_cfg.rx_cb = OnuLossOfKeySyncFailureIndication; |
| 1421 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1422 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_loki; |
| 1423 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1424 | if(rc != BCM_ERR_OK) |
| 1425 | return Status(grpc::StatusCode::INTERNAL, "onu loss of key sync indication subscribe failed"); |
| 1426 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1427 | /* ONU ITU-PON Raised Stats Indiction */ |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1428 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1429 | rx_cfg.rx_cb = OnuItuPonStatsAlarmRaisedIndication; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1430 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1431 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_raised; |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1432 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1433 | if(rc != BCM_ERR_OK) |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 1434 | return Status(grpc::StatusCode::INTERNAL, "onu itu-pon raised stats indication subscribe failed"); |
| 1435 | |
| 1436 | /* ONU ITU-PON Cleared Stats Indiction */ |
| 1437 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1438 | rx_cfg.rx_cb = OnuItuPonStatsAlarmClearedIndication; |
| 1439 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1440 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_itu_pon_stats_alarm_cleared; |
| 1441 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1442 | if(rc != BCM_ERR_OK) |
| 1443 | 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] | 1444 | |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1445 | /* Packet-In by Access_Control */ |
| 1446 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ACCESS_CONTROL; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1447 | rx_cfg.rx_cb = PacketIndication; |
| 1448 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 1449 | rx_cfg.subgroup = bcmolt_access_control_auto_subgroup_receive_eth_packet; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 1450 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1451 | if(rc != BCM_ERR_OK) |
| 1452 | return Status(grpc::StatusCode::INTERNAL, "Packet indication subscribe failed"); |
Nicolas Palpacuer | de4325b | 2018-07-03 11:18:42 -0400 | [diff] [blame] | 1453 | |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 1454 | #ifndef SCALE_AND_PERF |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 1455 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_ALLOC; |
| 1456 | rx_cfg.rx_cb = ItuPonAllocConfigCompletedInd; |
| 1457 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1458 | rx_cfg.subgroup = bcmolt_itupon_alloc_auto_subgroup_configuration_completed; |
| 1459 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1460 | if(rc != BCM_ERR_OK) |
Jason Huang | 9343053 | 2020-02-04 17:16:02 +0800 | [diff] [blame] | 1461 | 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] | 1462 | |
| 1463 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ITUPON_GEM; |
| 1464 | rx_cfg.rx_cb = ItuPonGemConfigCompletedInd; |
| 1465 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1466 | rx_cfg.subgroup = bcmolt_itupon_gem_auto_subgroup_configuration_completed; |
| 1467 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1468 | if(rc != BCM_ERR_OK) |
| 1469 | return Status(grpc::StatusCode::INTERNAL, "ITU PON Gem Configuration Complete Indication subscribe failed"); |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 1470 | #endif |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 1471 | |
Burak Gurdag | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 1472 | rx_cfg.obj_type = BCMOLT_OBJ_ID_GROUP; |
| 1473 | rx_cfg.rx_cb = GroupIndication; |
| 1474 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1475 | rx_cfg.subgroup = bcmolt_group_auto_subgroup_complete_members_update; |
| 1476 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1477 | if(rc != BCM_ERR_OK) |
| 1478 | return Status(grpc::StatusCode::INTERNAL, "Complete members update indication subscribe failed"); |
| 1479 | |
Orhan Kupusoglu | ec57af0 | 2021-05-12 12:38:17 +0000 | [diff] [blame] | 1480 | rx_cfg.obj_type = BCMOLT_OBJ_ID_ONU; |
| 1481 | rx_cfg.rx_cb = OnuRssiMeasurementCompletedIndication; |
| 1482 | rx_cfg.flags = BCMOLT_AUTO_FLAGS_NONE; |
| 1483 | rx_cfg.subgroup = bcmolt_onu_auto_subgroup_rssi_measurement_completed; |
| 1484 | rc = bcmolt_ind_subscribe(current_device, &rx_cfg); |
| 1485 | if(rc != BCM_ERR_OK) |
| 1486 | return Status(grpc::StatusCode::INTERNAL, "ONU RSSI Measurement indication subscription failed"); |
| 1487 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1488 | subscribed = true; |
| 1489 | |
| 1490 | return Status::OK; |
| 1491 | } |