Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | /* |
| 2 | <:copyright-BRCM:2016:DUAL/GPL:standard |
| 3 | |
| 4 | Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Unless you and Broadcom execute a separate written software license |
| 8 | agreement governing use of this software, this software is licensed |
| 9 | to you under the terms of the GNU General Public License version 2 |
| 10 | (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 11 | with the following added to such license: |
| 12 | |
| 13 | As a special exception, the copyright holders of this software give |
| 14 | you permission to link this software with independent modules, and |
| 15 | to copy and distribute the resulting executable under terms of your |
| 16 | choice, provided that you also meet, for each linked independent |
| 17 | module, the terms and conditions of the license of that module. |
| 18 | An independent module is a module which is not derived from this |
| 19 | software. The special exception does not apply to any modifications |
| 20 | of the software. |
| 21 | |
| 22 | Not withstanding the above, under no circumstances may you combine |
| 23 | this software in any way with any other Broadcom software provided |
| 24 | under a license other than the GPL, without Broadcom's express prior |
| 25 | written consent. |
| 26 | |
| 27 | :> |
| 28 | */ |
| 29 | |
| 30 | #include <bcmolt_host_api.h> |
| 31 | #include "bcmolt_user_appl_ps.h" |
| 32 | #include "bcmolt_user_appl_ps_internal.h" |
| 33 | |
| 34 | static bcmos_errno ps_handle_ni_los( |
| 35 | const bcmolt_ps_global_cfg *global_cfg, |
| 36 | const bcmolt_ps_pon *pon, |
| 37 | const bcmolt_xgpon_ni_los *ind) |
| 38 | { |
| 39 | if (ind->data.status == BCMOLT_STATUS_OFF) |
| 40 | { |
| 41 | PS_INFO("<%d:%d> LoS alarm cleared\n", pon->device_id, pon->pon_id); |
| 42 | return BCM_ERR_OK; |
| 43 | } |
| 44 | |
| 45 | PS_INFO("<%d:%d> LoS alarm raised\n", pon->device_id, pon->pon_id); |
| 46 | |
| 47 | if (global_cfg->switch_condition == BCMOLT_PS_SWITCH_CONDITION_MANUAL) |
| 48 | { |
| 49 | /* don't react to the switch if we're in manual switch mode */ |
| 50 | return BCM_ERR_OK; |
| 51 | } |
| 52 | else |
| 53 | { |
| 54 | return bcmolt_ps_switch_perform(pon); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | static bcmos_errno ps_handle_ni_state_changed( |
| 59 | const bcmolt_ps_pon *partner, |
| 60 | const bcmolt_xgpon_ni_state_change_completed *ind) |
| 61 | { |
| 62 | bcmolt_xgpon_ni_key key = { partner->pon_id }; |
| 63 | bcmolt_xgpon_ni_set_pon_state oper; |
| 64 | |
| 65 | BCMOLT_OPER_INIT(&oper, xgpon_ni, set_pon_state, key); |
| 66 | |
| 67 | if (ind->data.previous_state == BCMOLT_PON_STATE_INACTIVE && |
| 68 | ind->data.new_state == BCMOLT_PON_STATE_ACTIVE_WORKING) |
| 69 | { |
| 70 | PS_INFO("%s: activating PON <%d:%d>\n", __FUNCTION__, partner->device_id, key.pon_ni); |
| 71 | BCMOLT_OPER_PROP_SET(&oper, xgpon_ni, set_pon_state, pon_state, BCMOLT_PON_OPERATION_ACTIVE_STANDBY); |
| 72 | } |
| 73 | else if (ind->data.previous_state == BCMOLT_PON_STATE_ACTIVE_WORKING && |
| 74 | ind->data.new_state == BCMOLT_PON_STATE_INACTIVE) |
| 75 | { |
| 76 | PS_INFO("%s: deactivating PON <%d:%d>\n", __FUNCTION__, partner->device_id, key.pon_ni); |
| 77 | BCMOLT_OPER_PROP_SET(&oper, xgpon_ni, set_pon_state, pon_state, BCMOLT_PON_OPERATION_INACTIVE); |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | /* only change the standby PON's state if we're pre-provisioning the working PON |
| 82 | (the switchover is handled separately) */ |
| 83 | return BCM_ERR_OK; |
| 84 | } |
| 85 | |
| 86 | return bcmolt_oper_submit(partner->device_id, &oper.hdr); |
| 87 | } |
| 88 | |
| 89 | static bcmos_errno ps_handle_ni_traffic_resume( |
| 90 | const bcmolt_ps_pon *pon, |
| 91 | const bcmolt_xgpon_ni_protection_switching_traffic_resume *ind) |
| 92 | { |
| 93 | uint32_t after_us = bcmos_timestamp(); |
| 94 | uint32_t before_us = ps_get_last_switch_start_time_us(); |
| 95 | uint32_t time_taken_us = (after_us > before_us) ? after_us - before_us : before_us - after_us; |
| 96 | const char *traffic_resume_result_str = NULL; |
| 97 | |
| 98 | switch (ind->data.result) |
| 99 | { |
| 100 | case BCMOLT_TRAFFIC_RESUME_RESULT_SUCCESS: |
| 101 | traffic_resume_result_str = "success"; |
| 102 | break; |
| 103 | case BCMOLT_TRAFFIC_RESUME_RESULT_FAILURE: |
| 104 | traffic_resume_result_str = "failure"; |
| 105 | break; |
| 106 | case BCMOLT_TRAFFIC_RESUME_RESULT_SUSPECTED_LOS: |
| 107 | traffic_resume_result_str = "suspected_los"; |
| 108 | break; |
| 109 | default: |
| 110 | break; |
| 111 | } |
| 112 | |
| 113 | PS_INFO( |
| 114 | "<%d:%d> Traffic resume %s. Time since start of switch: %d ms.\n", |
| 115 | pon->device_id, |
| 116 | pon->pon_id, |
| 117 | traffic_resume_result_str, |
| 118 | time_taken_us / 1000); |
| 119 | |
| 120 | return BCM_ERR_OK; |
| 121 | } |
| 122 | |
| 123 | static bcmos_errno ps_handle_ni_onus_ranged( |
| 124 | const bcmolt_ps_pon *partner, |
| 125 | const bcmolt_xgpon_ni_protection_switching_onus_ranged *ind) |
| 126 | { |
| 127 | uint32_t i; |
| 128 | bcmos_errno last_err = BCM_ERR_OK; |
| 129 | |
| 130 | /* apply all of the new ONU EQDs to the standby PON */ |
| 131 | for (i = 0; i < ind->data.onus.len; i++) |
| 132 | { |
| 133 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->data.onus.val[i].onu_id }; |
| 134 | bcmolt_xgpon_onu_cfg cfg; |
| 135 | bcmos_errno err; |
| 136 | |
| 137 | PS_INFO( |
| 138 | "%s: updating EQD <%d:%d> ONU %d -> %d\n", |
| 139 | __FUNCTION__, |
| 140 | partner->device_id, |
| 141 | key.pon_ni, |
| 142 | key.onu_id, |
| 143 | ind->data.onus.val[i].eqd); |
| 144 | |
| 145 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 146 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, ranging_time, ind->data.onus.val[i].eqd); |
| 147 | err = bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 148 | if (err != BCM_ERR_OK) |
| 149 | { |
| 150 | PS_ERR("EQD update failed: %s\n", bcmos_strerror(err)); |
| 151 | last_err = err; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | return last_err; |
| 156 | } |
| 157 | |
| 158 | static bcmos_errno ps_handle_onu_ranging_completed( |
| 159 | const bcmolt_ps_pon *partner, |
| 160 | const bcmolt_xgpon_onu_ranging_completed *ind) |
| 161 | { |
| 162 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 163 | bcmolt_xgpon_onu_cfg cfg; |
| 164 | |
| 165 | /* only react to success indications */ |
| 166 | if (ind->data.status != BCMOLT_RESULT_SUCCESS) |
| 167 | { |
| 168 | return BCM_ERR_OK; |
| 169 | } |
| 170 | |
| 171 | PS_INFO( |
| 172 | "%s: updating EQD <%d:%d> ONU %d -> %d\n", |
| 173 | __FUNCTION__, |
| 174 | partner->device_id, |
| 175 | key.pon_ni, |
| 176 | key.onu_id, |
| 177 | ind->data.eqd); |
| 178 | |
| 179 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 180 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, ranging_time, ind->data.eqd); |
| 181 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 182 | } |
| 183 | |
| 184 | static bcmos_errno ps_handle_onu_key_exchange_completed( |
| 185 | const bcmolt_ps_pon *pon, |
| 186 | const bcmolt_ps_pon *partner, |
| 187 | const bcmolt_xgpon_onu_key_exchange_completed *ind) |
| 188 | { |
| 189 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 190 | bcmolt_xgpon_onu_cfg cfg; |
| 191 | |
| 192 | PS_INFO("%s: updating AES key <%d:%d> ONU %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.onu_id); |
| 193 | |
| 194 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 195 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, current_encryption_key, ind->data.new_key); |
| 196 | return bcmolt_cfg_set(pon->device_id, &cfg.hdr); |
| 197 | } |
| 198 | |
| 199 | static bcmos_errno ps_handle_onu_activation_completed( |
| 200 | const bcmolt_ps_pon *pon, |
| 201 | const bcmolt_ps_pon *partner, |
| 202 | const bcmolt_xgpon_onu_onu_activation_completed *ind) |
| 203 | { |
| 204 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 205 | bcmolt_xgpon_onu_cfg cfg; |
| 206 | bcmolt_xgpon_onu_set_onu_state oper; |
| 207 | bcmos_errno err; |
| 208 | |
| 209 | /* only react to success indications */ |
| 210 | if (ind->data.status != BCMOLT_RESULT_SUCCESS) |
| 211 | { |
| 212 | return BCM_ERR_OK; |
| 213 | } |
| 214 | |
| 215 | PS_INFO( |
| 216 | "%s: provisioning registration ID / keys for newly-activated ONU <%d:%d> ONU %d\n", |
| 217 | __FUNCTION__, |
| 218 | partner->device_id, |
| 219 | key.pon_ni, |
| 220 | key.onu_id); |
| 221 | |
| 222 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 223 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, registration_id, ind->data.registration_id); |
| 224 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, registration_encryption_keys, ind->data.registration_encryption_keys); |
| 225 | err = bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 226 | if (err != BCM_ERR_OK) |
| 227 | { |
| 228 | return err; |
| 229 | } |
| 230 | |
| 231 | PS_INFO("%s: activating <%d:%d> ONU %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.onu_id); |
| 232 | |
| 233 | BCMOLT_OPER_INIT(&oper, xgpon_onu, set_onu_state, key); |
| 234 | BCMOLT_OPER_PROP_SET(&oper, xgpon_onu, set_onu_state, onu_state, BCMOLT_ONU_OPERATION_ACTIVE); |
| 235 | return bcmolt_oper_submit(partner->device_id, &oper.hdr); |
| 236 | } |
| 237 | |
| 238 | static bcmos_errno ps_handle_onu_deactivation_completed( |
| 239 | const bcmolt_ps_pon *partner, |
| 240 | const bcmolt_xgpon_onu_onu_deactivation_completed *ind) |
| 241 | { |
| 242 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 243 | bcmolt_xgpon_onu_set_onu_state oper; |
| 244 | |
| 245 | /* Note: we react to this indication whether or not the deactivation was successful. Failure indicates that the |
| 246 | * ONU didn't respond to the deactivation, but we still remove the ONU from OLT hardware so it must be mirrored. */ |
| 247 | |
| 248 | PS_INFO("%s: deactivating <%d:%d> ONU %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.onu_id); |
| 249 | |
| 250 | BCMOLT_OPER_INIT(&oper, xgpon_onu, set_onu_state, key); |
| 251 | BCMOLT_OPER_PROP_SET(&oper, xgpon_onu, set_onu_state, onu_state, BCMOLT_ONU_OPERATION_INACTIVE); |
| 252 | return bcmolt_oper_submit(partner->device_id, &oper.hdr); |
| 253 | } |
| 254 | |
| 255 | static bcmos_errno ps_handle_onu_enable_completed( |
| 256 | const bcmolt_ps_pon *partner, |
| 257 | const bcmolt_xgpon_onu_onu_enable_completed *ind) |
| 258 | { |
| 259 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 260 | bcmolt_xgpon_onu_set_onu_state oper; |
| 261 | |
| 262 | /* don't try to mirror broadcast enable/disable */ |
| 263 | if (key.onu_id == BCMOLT_XGPON_ONU_ID_INVALID) |
| 264 | { |
| 265 | return BCM_ERR_OK; |
| 266 | } |
| 267 | |
| 268 | PS_INFO("%s: enabling <%d:%d> ONU %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.onu_id); |
| 269 | |
| 270 | BCMOLT_OPER_INIT(&oper, xgpon_onu, set_onu_state, key); |
| 271 | BCMOLT_OPER_PROP_SET(&oper, xgpon_onu, set_onu_state, onu_state, BCMOLT_ONU_OPERATION_ENABLE); |
| 272 | return bcmolt_oper_submit(partner->device_id, &oper.hdr); |
| 273 | } |
| 274 | |
| 275 | static bcmos_errno ps_handle_onu_disable_completed( |
| 276 | const bcmolt_ps_pon *partner, |
| 277 | const bcmolt_xgpon_onu_onu_disable_completed *ind) |
| 278 | { |
| 279 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 280 | bcmolt_xgpon_onu_set_onu_state oper; |
| 281 | |
| 282 | /* don't try to mirror broadcast enable/disable */ |
| 283 | if (key.onu_id == BCMOLT_XGPON_ONU_ID_INVALID) |
| 284 | { |
| 285 | return BCM_ERR_OK; |
| 286 | } |
| 287 | |
| 288 | PS_INFO("%s: disabling <%d:%d> ONU %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.onu_id); |
| 289 | |
| 290 | BCMOLT_OPER_INIT(&oper, xgpon_onu, set_onu_state, key); |
| 291 | BCMOLT_OPER_PROP_SET(&oper, xgpon_onu, set_onu_state, onu_state, BCMOLT_ONU_OPERATION_DISABLE); |
| 292 | return bcmolt_oper_submit(partner->device_id, &oper.hdr); |
| 293 | } |
| 294 | |
| 295 | static void ps_alarm_state_init(bcmolt_xgpon_onu_alarm_state *alarm_state) |
| 296 | { |
| 297 | alarm_state->losi = BCMOLT_STATUS_NO_CHANGE; |
| 298 | alarm_state->lobi = BCMOLT_STATUS_NO_CHANGE; |
| 299 | alarm_state->lopci = BCMOLT_STATUS_NO_CHANGE; |
| 300 | alarm_state->lopci_mic_error = BCMOLT_STATUS_NO_CHANGE; |
| 301 | alarm_state->looci = BCMOLT_STATUS_NO_CHANGE; |
| 302 | alarm_state->tiwi = BCMOLT_STATUS_NO_CHANGE; |
| 303 | alarm_state->dowi = BCMOLT_STATUS_NO_CHANGE; |
| 304 | alarm_state->sufi = BCMOLT_STATUS_NO_CHANGE; |
| 305 | alarm_state->sfi = BCMOLT_STATUS_NO_CHANGE; |
| 306 | alarm_state->sdi = BCMOLT_STATUS_NO_CHANGE; |
| 307 | alarm_state->dfi = BCMOLT_STATUS_NO_CHANGE; |
| 308 | alarm_state->dgi = BCMOLT_STATUS_NO_CHANGE; |
| 309 | alarm_state->pqsi = BCMOLT_STATUS_NO_CHANGE; |
| 310 | } |
| 311 | |
| 312 | static bcmos_errno ps_handle_onu_alarm(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_onu_alarm *ind) |
| 313 | { |
| 314 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 315 | bcmolt_xgpon_onu_cfg cfg; |
| 316 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 317 | |
| 318 | ps_alarm_state_init(&alarm_state); |
| 319 | alarm_state.losi = ind->data.onu_alarm.losi; |
| 320 | alarm_state.lobi = ind->data.onu_alarm.lobi; |
| 321 | alarm_state.lopci = ind->data.onu_alarm.lopci_miss; |
| 322 | alarm_state.lopci_mic_error = ind->data.onu_alarm.lopci_mic_error; |
| 323 | |
| 324 | PS_INFO( |
| 325 | "%s: updating ONU alarms <%d:%d> ONU %d\n", |
| 326 | __FUNCTION__, |
| 327 | partner->device_id, |
| 328 | key.pon_ni, |
| 329 | key.onu_id); |
| 330 | |
| 331 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 332 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 333 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 334 | } |
| 335 | |
| 336 | static bcmos_errno ps_handle_onu_dowi(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_dowi *ind) |
| 337 | { |
| 338 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 339 | bcmolt_xgpon_onu_cfg cfg; |
| 340 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 341 | |
| 342 | PS_INFO( |
| 343 | "%s: updating DOWi <%d:%d> ONU %d -> %d (EQD %d)\n", |
| 344 | __FUNCTION__, |
| 345 | partner->device_id, |
| 346 | key.pon_ni, |
| 347 | key.onu_id, |
| 348 | ind->data.alarm_status, |
| 349 | ind->data.new_eqd); |
| 350 | |
| 351 | ps_alarm_state_init(&alarm_state); |
| 352 | alarm_state.dowi = ind->data.alarm_status; |
| 353 | |
| 354 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 355 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 356 | |
| 357 | if (ind->data.alarm_status == BCMOLT_STATUS_ON) |
| 358 | { |
| 359 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, ranging_time, ind->data.new_eqd); |
| 360 | } |
| 361 | |
| 362 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 363 | } |
| 364 | |
| 365 | static bcmos_errno ps_handle_onu_sfi(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_sfi *ind) |
| 366 | { |
| 367 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 368 | bcmolt_xgpon_onu_cfg cfg; |
| 369 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 370 | |
| 371 | PS_INFO( |
| 372 | "%s: updating SFI <%d:%d> ONU %d -> %d\n", |
| 373 | __FUNCTION__, |
| 374 | partner->device_id, |
| 375 | key.pon_ni, |
| 376 | key.onu_id, |
| 377 | ind->data.alarm_status); |
| 378 | |
| 379 | ps_alarm_state_init(&alarm_state); |
| 380 | alarm_state.sfi = ind->data.alarm_status; |
| 381 | |
| 382 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 383 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 384 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 385 | } |
| 386 | |
| 387 | static bcmos_errno ps_handle_onu_sdi(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_sdi *ind) |
| 388 | { |
| 389 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 390 | bcmolt_xgpon_onu_cfg cfg; |
| 391 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 392 | |
| 393 | PS_INFO( |
| 394 | "%s: updating SDi <%d:%d> ONU %d -> %d\n", |
| 395 | __FUNCTION__, |
| 396 | partner->device_id, |
| 397 | key.pon_ni, |
| 398 | key.onu_id, |
| 399 | ind->data.alarm_status); |
| 400 | |
| 401 | ps_alarm_state_init(&alarm_state); |
| 402 | alarm_state.sdi = ind->data.alarm_status; |
| 403 | |
| 404 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 405 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 406 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 407 | } |
| 408 | |
| 409 | static bcmos_errno ps_handle_onu_dfi(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_dfi *ind) |
| 410 | { |
| 411 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 412 | bcmolt_xgpon_onu_cfg cfg; |
| 413 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 414 | |
| 415 | PS_INFO( |
| 416 | "%s: updating DFi <%d:%d> ONU %d -> %d\n", |
| 417 | __FUNCTION__, |
| 418 | partner->device_id, |
| 419 | key.pon_ni, |
| 420 | key.onu_id, |
| 421 | ind->data.alarm_status); |
| 422 | |
| 423 | ps_alarm_state_init(&alarm_state); |
| 424 | alarm_state.dfi = ind->data.alarm_status; |
| 425 | |
| 426 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 427 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 428 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 429 | } |
| 430 | |
| 431 | static bcmos_errno ps_handle_onu_sufi(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_sufi *ind) |
| 432 | { |
| 433 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 434 | bcmolt_xgpon_onu_cfg cfg; |
| 435 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 436 | |
| 437 | PS_INFO( |
| 438 | "%s: updating SUFi <%d:%d> ONU %d -> %d\n", |
| 439 | __FUNCTION__, |
| 440 | partner->device_id, |
| 441 | key.pon_ni, |
| 442 | key.onu_id, |
| 443 | ind->data.alarm_status); |
| 444 | |
| 445 | ps_alarm_state_init(&alarm_state); |
| 446 | alarm_state.sufi = ind->data.alarm_status; |
| 447 | |
| 448 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 449 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 450 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 451 | } |
| 452 | |
| 453 | static bcmos_errno ps_handle_onu_tiwi(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_tiwi *ind) |
| 454 | { |
| 455 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 456 | bcmolt_xgpon_onu_cfg cfg; |
| 457 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 458 | |
| 459 | PS_INFO( |
| 460 | "%s: updating TIWi <%d:%d> ONU %d -> %d\n", |
| 461 | __FUNCTION__, |
| 462 | partner->device_id, |
| 463 | key.pon_ni, |
| 464 | key.onu_id, |
| 465 | ind->data.alarm_status); |
| 466 | |
| 467 | ps_alarm_state_init(&alarm_state); |
| 468 | alarm_state.tiwi = ind->data.alarm_status; |
| 469 | |
| 470 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 471 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 472 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 473 | } |
| 474 | |
| 475 | static bcmos_errno ps_handle_onu_looci(const bcmolt_ps_pon *partner, const bcmolt_xgpon_onu_looci *ind) |
| 476 | { |
| 477 | bcmolt_xgpon_onu_key key = { partner->pon_id, ind->key.onu_id }; |
| 478 | bcmolt_xgpon_onu_cfg cfg; |
| 479 | bcmolt_xgpon_onu_alarm_state alarm_state; |
| 480 | |
| 481 | PS_INFO( |
| 482 | "%s: updating LOOCi <%d:%d> ONU %d -> %d\n", |
| 483 | __FUNCTION__, |
| 484 | partner->device_id, |
| 485 | key.pon_ni, |
| 486 | key.onu_id, |
| 487 | ind->data.alarm_status); |
| 488 | |
| 489 | ps_alarm_state_init(&alarm_state); |
| 490 | alarm_state.looci = ind->data.alarm_status; |
| 491 | |
| 492 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 493 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, alarm_state, alarm_state); |
| 494 | return bcmolt_cfg_set(partner->device_id, &cfg.hdr); |
| 495 | } |
| 496 | |
| 497 | static bcmos_errno ps_handle_alloc_id_configuration_completed( |
| 498 | const bcmolt_ps_pon *partner, |
| 499 | const bcmolt_xgpon_alloc_configuration_completed *ind) |
| 500 | { |
| 501 | bcmolt_xgpon_alloc_key key = { partner->pon_id, ind->key.alloc_id }; |
| 502 | bcmolt_xgpon_alloc_set_state oper; |
| 503 | |
| 504 | BCMOLT_OPER_INIT(&oper, xgpon_alloc, set_state, key); |
| 505 | |
| 506 | if (ind->data.new_state == BCMOLT_ALLOC_STATE_ACTIVE) |
| 507 | { |
| 508 | /* only react to success indications */ |
| 509 | if (ind->data.status != BCMOLT_RESULT_SUCCESS) |
| 510 | { |
| 511 | return BCM_ERR_OK; |
| 512 | } |
| 513 | |
| 514 | PS_INFO("%s: activating <%d:%d> alloc %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.alloc_id); |
| 515 | BCMOLT_OPER_PROP_SET(&oper, xgpon_alloc, set_state, state, BCMOLT_ALLOC_OPERATION_ACTIVATE); |
| 516 | } |
| 517 | else if (ind->data.new_state == BCMOLT_ALLOC_STATE_INACTIVE) |
| 518 | { |
| 519 | PS_INFO("%s: deactivating <%d:%d> alloc %d\n", __FUNCTION__, partner->device_id, key.pon_ni, key.alloc_id); |
| 520 | BCMOLT_OPER_PROP_SET(&oper, xgpon_alloc, set_state, state, BCMOLT_ALLOC_OPERATION_DEACTIVATE); |
| 521 | } |
| 522 | else /* ind->data.new_state is something else (e.g. unprovisioned, if the alloc was cleared) */ |
| 523 | { |
| 524 | return BCM_ERR_OK; |
| 525 | } |
| 526 | |
| 527 | return bcmolt_oper_submit(partner->device_id, &oper.hdr); |
| 528 | } |
| 529 | |
| 530 | bcmos_errno ps_process_ind_xgpon(const bcmolt_ps_pon *pon, const bcmolt_auto *ind) |
| 531 | { |
| 532 | bcmos_errno err; |
| 533 | bcmolt_ps_pon_state state; |
| 534 | bcmolt_ps_pon partner; |
| 535 | bcmolt_ps_global_cfg global_cfg; |
| 536 | |
| 537 | err = bcmolt_ps_global_cfg_get(&global_cfg); |
| 538 | if (err != BCM_ERR_OK) |
| 539 | { |
| 540 | return err; |
| 541 | } |
| 542 | |
| 543 | if (global_cfg.mirror_mode != BCMOLT_PS_MIRROR_MODE_AUTO && |
| 544 | ind->hdr.subgroup != BCMOLT_XGPON_NI_AUTO_ID_LOS) |
| 545 | { |
| 546 | /* only handle most indications while in mirror mode 'auto', but perform a switchover on LoS in any case */ |
| 547 | return BCM_ERR_OK; |
| 548 | } |
| 549 | |
| 550 | err = bcmolt_ps_pon_state_get(pon, &state, &partner); |
| 551 | if (err != BCM_ERR_OK) |
| 552 | { |
| 553 | return err; |
| 554 | } |
| 555 | |
| 556 | if (state != BCMOLT_PS_PON_STATE_WORKING) |
| 557 | { |
| 558 | return BCM_ERR_OK; /* ignore indications from PONs that aren't protected working */ |
| 559 | } |
| 560 | |
| 561 | switch (ind->hdr.obj_type) |
| 562 | { |
| 563 | case BCMOLT_OBJ_ID_XGPON_NI: |
| 564 | switch (ind->hdr.subgroup) |
| 565 | { |
| 566 | case BCMOLT_XGPON_NI_AUTO_ID_LOS: |
| 567 | return ps_handle_ni_los(&global_cfg, pon, ((const bcmolt_xgpon_ni_los *)ind)); |
| 568 | case BCMOLT_XGPON_NI_AUTO_ID_STATE_CHANGE_COMPLETED: |
| 569 | return ps_handle_ni_state_changed(&partner, ((const bcmolt_xgpon_ni_state_change_completed *)ind)); |
| 570 | case BCMOLT_XGPON_NI_AUTO_ID_PROTECTION_SWITCHING_TRAFFIC_RESUME: |
| 571 | return ps_handle_ni_traffic_resume(pon, ((const bcmolt_xgpon_ni_protection_switching_traffic_resume *)ind)); |
| 572 | case BCMOLT_XGPON_NI_AUTO_ID_PROTECTION_SWITCHING_ONUS_RANGED: |
| 573 | return ps_handle_ni_onus_ranged(&partner, ((const bcmolt_xgpon_ni_protection_switching_onus_ranged *)ind)); |
| 574 | default: |
| 575 | return BCM_ERR_OK; /* silently ignore all other NI indications */ |
| 576 | } |
| 577 | |
| 578 | case BCMOLT_OBJ_ID_XGPON_ONU: |
| 579 | switch (ind->hdr.subgroup) |
| 580 | { |
| 581 | case BCMOLT_XGPON_ONU_AUTO_ID_RANGING_COMPLETED: |
| 582 | return ps_handle_onu_ranging_completed(&partner, ((const bcmolt_xgpon_onu_ranging_completed *)ind)); |
| 583 | case BCMOLT_XGPON_ONU_AUTO_ID_KEY_EXCHANGE_COMPLETED: |
| 584 | return ps_handle_onu_key_exchange_completed( |
| 585 | pon, |
| 586 | &partner, |
| 587 | ((const bcmolt_xgpon_onu_key_exchange_completed *)ind)); |
| 588 | case BCMOLT_XGPON_ONU_AUTO_ID_ONU_ACTIVATION_COMPLETED: |
| 589 | return ps_handle_onu_activation_completed( |
| 590 | pon, |
| 591 | &partner, |
| 592 | ((const bcmolt_xgpon_onu_onu_activation_completed *)ind)); |
| 593 | case BCMOLT_XGPON_ONU_AUTO_ID_ONU_DEACTIVATION_COMPLETED: |
| 594 | return ps_handle_onu_deactivation_completed( |
| 595 | &partner, |
| 596 | ((const bcmolt_xgpon_onu_onu_deactivation_completed *)ind)); |
| 597 | case BCMOLT_XGPON_ONU_AUTO_ID_ONU_ENABLE_COMPLETED: |
| 598 | return ps_handle_onu_enable_completed(&partner, ((const bcmolt_xgpon_onu_onu_enable_completed *)ind)); |
| 599 | case BCMOLT_XGPON_ONU_AUTO_ID_ONU_DISABLE_COMPLETED: |
| 600 | return ps_handle_onu_disable_completed(&partner, ((const bcmolt_xgpon_onu_onu_disable_completed *)ind)); |
| 601 | case BCMOLT_XGPON_ONU_AUTO_ID_ONU_ALARM: |
| 602 | return ps_handle_onu_alarm(&partner, ((const bcmolt_xgpon_onu_onu_alarm *)ind)); |
| 603 | case BCMOLT_XGPON_ONU_AUTO_ID_DOWI: |
| 604 | return ps_handle_onu_dowi(&partner, ((const bcmolt_xgpon_onu_dowi *)ind)); |
| 605 | case BCMOLT_XGPON_ONU_AUTO_ID_SFI: |
| 606 | return ps_handle_onu_sfi(&partner, ((const bcmolt_xgpon_onu_sfi *)ind)); |
| 607 | case BCMOLT_XGPON_ONU_AUTO_ID_SDI: |
| 608 | return ps_handle_onu_sdi(&partner, ((const bcmolt_xgpon_onu_sdi *)ind)); |
| 609 | case BCMOLT_XGPON_ONU_AUTO_ID_DFI: |
| 610 | return ps_handle_onu_dfi(&partner, ((const bcmolt_xgpon_onu_dfi *)ind)); |
| 611 | case BCMOLT_XGPON_ONU_AUTO_ID_SUFI: |
| 612 | return ps_handle_onu_sufi(&partner, ((const bcmolt_xgpon_onu_sufi *)ind)); |
| 613 | case BCMOLT_XGPON_ONU_AUTO_ID_TIWI: |
| 614 | return ps_handle_onu_tiwi(&partner, ((const bcmolt_xgpon_onu_tiwi *)ind)); |
| 615 | case BCMOLT_XGPON_ONU_AUTO_ID_LOOCI: |
| 616 | return ps_handle_onu_looci(&partner, ((const bcmolt_xgpon_onu_looci *)ind)); |
| 617 | default: |
| 618 | return BCM_ERR_OK; /* silently ignore all other ONU indications */ |
| 619 | } |
| 620 | |
| 621 | case BCMOLT_OBJ_ID_XGPON_ALLOC: |
| 622 | switch (ind->hdr.subgroup) |
| 623 | { |
| 624 | case BCMOLT_XGPON_ALLOC_AUTO_ID_CONFIGURATION_COMPLETED: |
| 625 | return ps_handle_alloc_id_configuration_completed( |
| 626 | &partner, |
| 627 | ((const bcmolt_xgpon_alloc_configuration_completed *)ind)); |
| 628 | default: |
| 629 | return BCM_ERR_OK; /* silently ignore all other alloc indications */ |
| 630 | } |
| 631 | |
| 632 | default: |
| 633 | return BCM_ERR_NOT_SUPPORTED; /* someone else needs to handle this indication */ |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | bcmos_errno ps_move_to_standby_xgpon(const bcmolt_ps_pon *pon) |
| 638 | { |
| 639 | bcmolt_xgpon_ni_set_pon_state set_pon_state; |
| 640 | bcmolt_xgpon_ni_key key = { (bcmolt_xgpon_ni)pon->pon_id }; |
| 641 | |
| 642 | BCMOLT_OPER_INIT(&set_pon_state, xgpon_ni, set_pon_state, key); |
| 643 | BCMOLT_OPER_PROP_SET(&set_pon_state, xgpon_ni, set_pon_state, pon_state, BCMOLT_PON_OPERATION_ACTIVE_STANDBY); |
| 644 | return bcmolt_oper_submit(pon->device_id, &set_pon_state.hdr); |
| 645 | } |
| 646 | |
| 647 | bcmos_errno ps_move_to_working_xgpon(const bcmolt_ps_pon *pon) |
| 648 | { |
| 649 | bcmolt_xgpon_ni_set_pon_state set_pon_state; |
| 650 | bcmolt_xgpon_ni_key key = { (bcmolt_xgpon_ni)pon->pon_id }; |
| 651 | |
| 652 | BCMOLT_OPER_INIT(&set_pon_state, xgpon_ni, set_pon_state, key); |
| 653 | BCMOLT_OPER_PROP_SET(&set_pon_state, xgpon_ni, set_pon_state, pon_state, BCMOLT_PON_OPERATION_ACTIVE_WORKING); |
| 654 | return bcmolt_oper_submit(pon->device_id, &set_pon_state.hdr); |
| 655 | } |