Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * <:copyright-BRCM:2016:DUAL/GPL:standard |
| 4 | * |
| 5 | * Copyright (c) 2016 Broadcom |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * Unless you and Broadcom execute a separate written software license |
| 9 | * agreement governing use of this software, this software is licensed |
| 10 | * to you under the terms of the GNU General Public License version 2 |
| 11 | * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 12 | * with the following added to such license: |
| 13 | * |
| 14 | * As a special exception, the copyright holders of this software give |
| 15 | * you permission to link this software with independent modules, and |
| 16 | * to copy and distribute the resulting executable under terms of your |
| 17 | * choice, provided that you also meet, for each linked independent |
| 18 | * module, the terms and conditions of the license of that module. |
| 19 | * An independent module is a module which is not derived from this |
| 20 | * software. The special exception does not apply to any modifications |
| 21 | * of the software. |
| 22 | * |
| 23 | * Not withstanding the above, under no circumstances may you combine |
| 24 | * this software in any way with any other Broadcom software provided |
| 25 | * under a license other than the GPL, without Broadcom's express prior |
| 26 | * written consent. |
| 27 | * |
| 28 | * :> |
| 29 | * |
| 30 | *****************************************************************************/ |
| 31 | |
| 32 | /** |
| 33 | * @file bal_mac_util_xgpon.c |
| 34 | * |
| 35 | * @brief mac util interfaces definition used by Bal Core, for xgpon |
| 36 | * |
| 37 | * This file expose the APIs to the core to configure the mac |
| 38 | * with regarding to the operation of access terminal, interface, subscriber terminal and flow. |
| 39 | * |
| 40 | * @addtogroup mac_util |
| 41 | */ |
| 42 | |
| 43 | /*@{*/ |
| 44 | |
| 45 | #include <bal_mac_util.h> |
| 46 | #include <bal_mac_util_common_itu_pon.h> |
| 47 | |
| 48 | |
| 49 | static bcmos_errno mac_util_indication_handle_for_xgpon_ni (bcmolt_devid device_id, bcmolt_msg *p_msg); |
| 50 | static bcmos_errno mac_util_indication_handle_for_xgpon_onu (bcmolt_devid device_id, bcmolt_msg *p_msg); |
| 51 | static bcmos_errno mac_util_indication_handle_for_xgpon_alloc_id (bcmolt_devid device_id, bcmolt_msg *p_msg); |
| 52 | |
| 53 | /* On XG-PON1 there is no indication such as GEM port configuration completed. |
| 54 | * GEM configuration at the ONU is taken care of completely by OMCI without any PLOAM sent from the OLT |
| 55 | * */ |
| 56 | |
| 57 | /** |
| 58 | * @brief array stores the list of xgpon (XG-PON1) related auto indications from Maple to subscribe |
| 59 | */ |
| 60 | static mac_util_ind_obj_and_handlers mac_util_xgpon_ind_handlers[] = |
| 61 | { |
| 62 | {BCMOLT_OBJ_ID_XGPON_NI, "BCMOLT_OBJ_ID_XGPON_NI", mac_util_indication_handle_for_xgpon_ni}, |
| 63 | {BCMOLT_OBJ_ID_XGPON_ONU, "BCMOLT_OBJ_ID_XGPON_ONU", mac_util_indication_handle_for_xgpon_onu}, |
| 64 | {BCMOLT_OBJ_ID_XGPON_ALLOC, "BCMOLT_OBJ_ID_XGPON_ALLOC", mac_util_indication_handle_for_xgpon_alloc_id}, |
| 65 | }; |
| 66 | |
| 67 | /** |
| 68 | * @brief Map bal XGPON transceiver type to bcm68620 transceiver type |
| 69 | */ |
| 70 | static bcmolt_xgpon_trx_type mac_xgpon_bal_trx_type2bcm68620_trx_type(bcmbal_trx_type bal_trx_type) |
| 71 | { |
| 72 | bcmolt_xgpon_trx_type trx_type = BCMOLT_XGPON_TRX_TYPE__NUM_OF; |
| 73 | |
| 74 | if (BCMBAL_TRX_TYPE_XGPON_LTH_7222_PC == bal_trx_type) |
| 75 | { |
| 76 | trx_type = BCMOLT_XGPON_TRX_TYPE_LTH_7222_PC; |
| 77 | } |
| 78 | else if (BCMBAL_TRX_TYPE_XGPON_LTH_7226_PC == bal_trx_type) |
| 79 | { |
| 80 | trx_type = BCMOLT_XGPON_TRX_TYPE_LTH_7226_PC; |
| 81 | } |
| 82 | else if (BCMBAL_TRX_TYPE_XGPON_LTH_5302_PC == bal_trx_type) |
| 83 | { |
| 84 | trx_type = BCMOLT_XGPON_TRX_TYPE_LTH_5302_PC; |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | trx_type = BCMOLT_XGPON_TRX_TYPE_USER_DEFINED; |
| 89 | } |
| 90 | |
| 91 | return trx_type; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @brief all the maple indication handlers for xgpon |
| 96 | * |
| 97 | * @param device_id the maple device id generating the current indication |
| 98 | * @param p_msg pointer to the maple indication message |
| 99 | * |
| 100 | */ |
| 101 | bcmos_errno mac_util_handle_all_olt_ind_for_xgpon (bcmolt_devid device_id, bcmolt_msg *p_msg) |
| 102 | { |
| 103 | BCM_LOG(DEBUG, log_id_mac_util, |
| 104 | "mac_util_indication_cb received indication obj=%d/%s group=%d subgroup=%d\n", |
| 105 | p_msg->obj_type, mac_util_indication_get_obj_type_str(p_msg->obj_type, mac_util_xgpon_ind_handlers, BCM_SIZEOFARRAY(mac_util_xgpon_ind_handlers)), |
| 106 | p_msg->group, p_msg->subgroup); |
| 107 | |
| 108 | return mac_util_handle_indication(device_id, p_msg, mac_util_xgpon_ind_handlers, BCM_SIZEOFARRAY(mac_util_xgpon_ind_handlers)); |
| 109 | } |
| 110 | |
| 111 | |
| 112 | /** |
| 113 | * @brief Handler function for Maple auto indications for xgpon (XG-PON1) NI |
| 114 | * |
| 115 | * @param device_id the maple device id generating the current indication |
| 116 | * @param p_msg pointer to the maple indication message |
| 117 | * |
| 118 | * @return bcmos_errno |
| 119 | */ |
| 120 | static bcmos_errno mac_util_indication_handle_for_xgpon_ni (bcmolt_devid device_id, bcmolt_msg *p_msg) |
| 121 | { |
| 122 | bcmos_errno rc = BCM_ERR_OK; |
| 123 | uint32_t logical_pon; |
| 124 | |
| 125 | do |
| 126 | { |
| 127 | |
| 128 | /* PON activation */ |
| 129 | if (BCMOLT_XGPON_NI_AUTO_ID_STATE_CHANGE_COMPLETED == p_msg->subgroup) |
| 130 | { |
| 131 | bcmolt_xgpon_ni_state_change_completed * p_ind = (bcmolt_xgpon_ni_state_change_completed*)p_msg; |
| 132 | |
| 133 | rc = bcm_topo_pon_get_physical2logical(device_id, p_ind->key.pon_ni, &logical_pon); |
| 134 | if (BCM_ERR_OK != rc) |
| 135 | { |
| 136 | BCM_LOG(ERROR, log_id_mac_util, |
| 137 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_ind->key.pon_ni, bcmos_strerror(rc)); |
| 138 | break; |
| 139 | } |
| 140 | |
| 141 | BCM_LOG(INFO, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), "Pon if %d is %s.\n", logical_pon, |
| 142 | BCMOLT_PON_STATE_ACTIVE_WORKING == p_ind->data.new_state ? "up" : "down"); |
| 143 | |
| 144 | mac_util_report_if_event(logical_pon, BCMBAL_INTF_TYPE_PON, p_msg->err, |
| 145 | p_ind->data.result, p_ind->data.new_state); |
| 146 | |
| 147 | } |
| 148 | else if(BCMOLT_XGPON_NI_AUTO_CFG_ID_ONU_DISCOVERED == p_msg->subgroup) |
| 149 | { |
| 150 | bcmolt_xgpon_ni_onu_discovered *p_ind = |
| 151 | (bcmolt_xgpon_ni_onu_discovered *)p_msg; |
| 152 | |
| 153 | rc = bcm_topo_pon_get_physical2logical(device_id, p_ind->key.pon_ni, &logical_pon); |
| 154 | if (BCM_ERR_OK != rc) |
| 155 | { |
| 156 | BCM_LOG(ERROR, log_id_mac_util, |
| 157 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_ind->key.pon_ni, bcmos_strerror(rc)); |
| 158 | break; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 163 | "Pon if %d found ONU serial number " |
| 164 | "%c%c%c%c%d%d%d%d%d%d%d%d\n", |
| 165 | logical_pon, |
| 166 | p_ind->data.serial_number.vendor_id[0], |
| 167 | p_ind->data.serial_number.vendor_id[1], |
| 168 | p_ind->data.serial_number.vendor_id[2], |
| 169 | p_ind->data.serial_number.vendor_id[3], |
| 170 | p_ind->data.serial_number.vendor_specific[0]>>4 & 0x0f, |
| 171 | p_ind->data.serial_number.vendor_specific[0] & 0x0f, |
| 172 | p_ind->data.serial_number.vendor_specific[1]>>4 & 0x0f, |
| 173 | p_ind->data.serial_number.vendor_specific[1] & 0x0f, |
| 174 | p_ind->data.serial_number.vendor_specific[2]>>4 & 0x0f, |
| 175 | p_ind->data.serial_number.vendor_specific[2] & 0x0f, |
| 176 | p_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f, |
| 177 | p_ind->data.serial_number.vendor_specific[3] & 0x0f |
| 178 | ); |
| 179 | |
| 180 | /* if we got something from MAC HW, then it has to be PON interface */ |
| 181 | mac_util_report_sub_term_event(logical_pon, |
| 182 | p_ind->data.onu_id, |
| 183 | &p_ind->data.serial_number, |
| 184 | BAL_UTIL_OPER_SUB_TERM_DISCOVERY, |
| 185 | p_msg->err, BCM_ERR_OK, |
| 186 | BCMOLT_ACTIVATION_FAIL_REASON_NONE, BCMBAL_INVALID_TUNNEL_ID); |
| 187 | } |
| 188 | |
| 189 | else |
| 190 | { |
| 191 | /* just get the pon key by typecasting to a dummy structure */ |
| 192 | bcmolt_xgpon_ni_key *p_pon_key = &(((bcmolt_xgpon_ni_state_change_completed*)p_msg)->key); |
| 193 | |
| 194 | rc = bcm_topo_pon_get_physical2logical(device_id, p_pon_key->pon_ni, &logical_pon); |
| 195 | if (BCM_ERR_OK != rc) |
| 196 | { |
| 197 | BCM_LOG(ERROR, log_id_mac_util, |
| 198 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_pon_key->pon_ni, bcmos_strerror(rc)); |
| 199 | break; |
| 200 | } |
| 201 | |
| 202 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 203 | "Unhandled message indication for obj XGPON_NI group %d " |
| 204 | "subgroup %d (Ignored)\n", p_msg->group, p_msg->subgroup); |
| 205 | } |
| 206 | } |
| 207 | while(0); |
| 208 | |
| 209 | return rc; |
| 210 | } |
| 211 | |
| 212 | |
| 213 | /** |
| 214 | * @brief Handler function for Maple auto indications for xgpon (XG-PON1) ONU |
| 215 | * |
| 216 | * @param device_id the maple device id generating the current indication |
| 217 | * @param p_msg pointer to the maple indication message |
| 218 | * |
| 219 | * @return bcmos_errno |
| 220 | */ |
| 221 | static bcmos_errno mac_util_indication_handle_for_xgpon_onu (bcmolt_devid device_id, bcmolt_msg *p_msg) |
| 222 | { |
| 223 | bcmos_errno rc = BCM_ERR_OK; |
| 224 | uint32_t logical_pon; |
| 225 | |
| 226 | /* just get the pon key by typecasting to a dummy structure */ |
| 227 | bcmolt_xgpon_onu_key *p_xgpon_onu_key = &(((bcmolt_xgpon_onu_onu_activation_completed*)p_msg)->key); |
| 228 | do |
| 229 | { |
| 230 | if (BCMOLT_XGPON_ONU_AUTO_CFG_ID_ONU_ACTIVATION_COMPLETED == p_msg->subgroup) |
| 231 | { |
| 232 | bcmolt_xgpon_onu_onu_activation_completed *p_ind = (bcmolt_xgpon_onu_onu_activation_completed*) p_msg; |
| 233 | |
| 234 | rc = bcm_topo_pon_get_physical2logical(device_id, p_ind->key.pon_ni, &logical_pon); |
| 235 | if (BCM_ERR_OK != rc) |
| 236 | { |
| 237 | BCM_LOG(ERROR, log_id_mac_util, |
| 238 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_ind->key.pon_ni, bcmos_strerror(rc)); |
| 239 | break; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | BCM_LOG(INFO, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 244 | "sub_term %d (PON%d) activation indication (%s)\n", |
| 245 | p_ind->key.onu_id, |
| 246 | logical_pon, |
| 247 | bcmos_strerror(p_msg->err)); |
| 248 | |
| 249 | mac_util_report_sub_term_event(logical_pon, |
| 250 | p_ind->key.onu_id, |
| 251 | (bcmolt_serial_number *)NULL, |
| 252 | BAL_UTIL_OPER_SUB_TERM_ADD, |
| 253 | p_msg->err, p_ind->data.status, |
| 254 | p_ind->data.fail_reason, BCMBAL_INVALID_TUNNEL_ID); |
| 255 | |
| 256 | } |
| 257 | else if(BCMOLT_XGPON_ONU_AUTO_CFG_ID_ONU_DEACTIVATION_COMPLETED == p_msg->subgroup) |
| 258 | { |
| 259 | bcmolt_xgpon_onu_onu_deactivation_completed *p_ind = (bcmolt_xgpon_onu_onu_deactivation_completed*) p_msg; |
| 260 | rc = bcm_topo_pon_get_physical2logical(device_id, p_ind->key.pon_ni, &logical_pon); |
| 261 | if (BCM_ERR_OK != rc) |
| 262 | { |
| 263 | BCM_LOG(ERROR, log_id_mac_util, |
| 264 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_ind->key.pon_ni, bcmos_strerror(rc)); |
| 265 | break; |
| 266 | } |
| 267 | |
| 268 | BCM_LOG(INFO, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 269 | "sub_term %d (PON%d) deactivation indication (%s)\n", |
| 270 | p_ind->key.onu_id, |
| 271 | p_ind->key.pon_ni, |
| 272 | bcmos_strerror(p_msg->err)); |
| 273 | |
| 274 | mac_util_report_sub_term_event(logical_pon, |
| 275 | p_ind->key.onu_id, |
| 276 | (bcmolt_serial_number *)NULL, |
| 277 | BAL_UTIL_OPER_SUB_TERM_REMOVE, |
| 278 | p_msg->err, p_ind->data.status, |
| 279 | MAC_UTIL_DEACTIVATION_FAIL_REASON_NONE, BCMBAL_INVALID_TUNNEL_ID); |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | rc = bcm_topo_pon_get_physical2logical(device_id, p_xgpon_onu_key->pon_ni, &logical_pon); |
| 284 | if (BCM_ERR_OK != rc) |
| 285 | { |
| 286 | BCM_LOG(ERROR, log_id_mac_util, |
| 287 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_xgpon_onu_key->pon_ni, bcmos_strerror(rc)); |
| 288 | break; |
| 289 | } |
| 290 | |
| 291 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 292 | "Unhandled message indication for obj XGPON_ONU group %d " |
| 293 | "subgroup %d (Ignored)\n", p_msg->group, p_msg->subgroup); |
| 294 | break; |
| 295 | } |
| 296 | |
| 297 | rc = mac_util_update_flows_w_sub_term_update(logical_pon, p_xgpon_onu_key->onu_id, maple_xgpon_mac_check_gem_port_id, maple_xgpon_mac_get_alloc_id_config); |
| 298 | if (BCM_ERR_OK != rc) |
| 299 | { |
| 300 | BCM_LOG(ERROR, log_id_mac_util, |
| 301 | "Failed to update related flows pon_id = %d onu_id = %d (%s)\n", logical_pon, p_xgpon_onu_key->onu_id, bcmos_strerror(rc)); |
| 302 | break; |
| 303 | } |
| 304 | |
| 305 | }while(0); |
| 306 | |
| 307 | return rc; |
| 308 | } |
| 309 | |
| 310 | |
| 311 | /** |
| 312 | * @brief Handler function for Maple auto indications for xgpon (XG-PON1) Alloc Id |
| 313 | * |
| 314 | * @param device_id the maple device id generating the current indication |
| 315 | * @param p_msg pointer to the maple indication message |
| 316 | * |
| 317 | * @return bcmos_errno |
| 318 | */ |
| 319 | static bcmos_errno mac_util_indication_handle_for_xgpon_alloc_id (bcmolt_devid device_id, bcmolt_msg *p_msg) |
| 320 | { |
| 321 | bcmos_errno rc = BCM_ERR_OK; |
| 322 | uint32_t logical_pon; |
| 323 | tm_sched_inst* p_tm_sched_inst = NULL; |
| 324 | do |
| 325 | { |
| 326 | if (BCMOLT_XGPON_ALLOC_AUTO_CFG_ID_CONFIGURATION_COMPLETED == p_msg->subgroup) |
| 327 | { |
| 328 | bcmolt_xgpon_alloc_configuration_completed *p_ind = (bcmolt_xgpon_alloc_configuration_completed*) p_msg; |
| 329 | rc = bcm_topo_pon_get_physical2logical(device_id, p_ind->key.pon_ni, &logical_pon); |
| 330 | if (BCM_ERR_OK != rc) |
| 331 | { |
| 332 | BCM_LOG(ERROR, log_id_mac_util, |
| 333 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_ind->key.pon_ni, bcmos_strerror(rc)); |
| 334 | |
| 335 | break; |
| 336 | } |
| 337 | |
| 338 | /* Find tn_mode inst owned by that alloc_id and ni */ |
| 339 | p_tm_sched_inst = tm_sched_find_agg_port_node(logical_pon, p_ind->key.alloc_id); |
| 340 | if (NULL == p_tm_sched_inst ) |
| 341 | { |
| 342 | BCM_LOG(ERROR, log_id_mac_util, |
| 343 | "Failed to find tm sched owned by that agg port (intf %d id %d)\n", logical_pon,p_ind->key.alloc_id); |
| 344 | rc = BCM_ERR_NOENT; |
| 345 | break; |
| 346 | |
| 347 | } |
| 348 | |
| 349 | /*the tm owned by that alloc found, update it with the ind*/ |
| 350 | mac_util_report_tm_sched_set_indication(p_tm_sched_inst->req_tm_sched_info.key ,p_msg->err, p_ind->data.status); |
| 351 | |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | /* just get the pon key by typecasting to a dummy structure */ |
| 356 | bcmolt_xgpon_alloc_key *p_pon_key = &(((bcmolt_xgpon_alloc_configuration_completed*)p_msg)->key); |
| 357 | |
| 358 | rc = bcm_topo_pon_get_physical2logical(device_id, p_pon_key->pon_ni, &logical_pon); |
| 359 | if (BCM_ERR_OK != rc) |
| 360 | { |
| 361 | BCM_LOG(ERROR, log_id_mac_util, |
| 362 | "Failed to get logical if from physical if (device_id %d physical %d ) (%s)\n", device_id, p_pon_key->pon_ni, bcmos_strerror(rc)); |
| 363 | break; |
| 364 | } |
| 365 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 366 | "Unhandled message indication for obj XGPON_ALLOC group %d " |
| 367 | "subgroup %d (Ignored)\n", p_msg->group, p_msg->subgroup); |
| 368 | } |
| 369 | |
| 370 | } |
| 371 | while (0); |
| 372 | return rc; |
| 373 | } |
| 374 | |
| 375 | |
| 376 | /** |
| 377 | * @brief Maple auto indication register for specific xgpon (XG-PON1) based indications |
| 378 | * |
| 379 | * @param p_rx_cfg handler config structure |
| 380 | * @param device_id specific device id (for multiple devices support) |
| 381 | * |
| 382 | * @return bcmos_errno |
| 383 | */ |
| 384 | bcmos_errno mac_util_register_for_xgpon_auto_indications (struct bcmolt_rx_cfg *p_rx_cfg, bcmolt_devid device_id) |
| 385 | { |
| 386 | return _mac_util_register_for_auto_indications (p_rx_cfg, mac_util_xgpon_ind_handlers, BCM_SIZEOFARRAY(mac_util_xgpon_ind_handlers),device_id); |
| 387 | } |
| 388 | |
| 389 | |
| 390 | /** |
| 391 | * @brief common access terminal set for 10G pon if |
| 392 | */ |
| 393 | |
| 394 | bcmos_errno mac_util_access_terminal_set_for_10G_itu_pon (bcmolt_device_cfg dev_cfg, bcmolt_devid device_id) |
| 395 | { |
| 396 | bcmos_errno rc; |
| 397 | bcmolt_device_nni_speed nni_speed_cfg; |
| 398 | |
| 399 | #ifdef QAX_SWITCH |
| 400 | /* until speed is configurable through topology settings hardcode it based on switch type */ |
| 401 | BCM_LOG(INFO, log_id_mac_util, "nni speed is: 10G\n"); |
| 402 | nni_speed_cfg.first_half = BCMOLT_NNI_SPEED_GBPS_10; |
| 403 | nni_speed_cfg.second_half = BCMOLT_NNI_SPEED_GBPS_10; |
| 404 | BCMOLT_CFG_PROP_SET(&dev_cfg, device, nni_speed, nni_speed_cfg); |
| 405 | #endif |
| 406 | |
| 407 | rc = bcmolt_cfg_set(device_id, &dev_cfg.hdr); |
| 408 | |
| 409 | return rc; |
| 410 | } |
| 411 | |
| 412 | |
| 413 | /** |
| 414 | * @brief access terminal set for xgpon1_8 |
| 415 | */ |
| 416 | bcmos_errno mac_util_access_terminal_set_for_xgpon_8 (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id) |
| 417 | { |
| 418 | bcmos_errno rc; |
| 419 | bcmolt_device_key key = {}; |
| 420 | bcmolt_device_cfg dev_cfg; |
| 421 | |
| 422 | rc = maple_access_terminal_set_common(p_acc_term, op_type, device_id); |
| 423 | if (rc != BCM_ERR_OK) |
| 424 | return rc; |
| 425 | |
| 426 | BCMOLT_CFG_INIT(&dev_cfg, device, key); |
| 427 | BCMOLT_CFG_PROP_SET(&dev_cfg, device, system_mode, BCMOLT_SYSTEM_MODE_XGPON_1__8_X); |
| 428 | |
| 429 | rc = mac_util_access_terminal_set_for_10G_itu_pon(dev_cfg,device_id); |
| 430 | if (rc != BCM_ERR_OK) |
| 431 | return rc; |
| 432 | |
| 433 | return maple_access_terminal_connect_common(device_id); |
| 434 | } |
| 435 | |
| 436 | |
| 437 | /** |
| 438 | * @brief access terminal set for xgs_2_10 |
| 439 | */ |
| 440 | bcmos_errno mac_util_access_terminal_set_for_xgs (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id) |
| 441 | { |
| 442 | bcmos_errno rc; |
| 443 | bcmolt_device_key key = {}; |
| 444 | bcmolt_device_cfg dev_cfg; |
| 445 | |
| 446 | rc = maple_access_terminal_set_common(p_acc_term, op_type, device_id); |
| 447 | if (rc != BCM_ERR_OK) |
| 448 | return rc; |
| 449 | |
| 450 | BCMOLT_CFG_INIT(&dev_cfg, device, key); |
| 451 | BCMOLT_CFG_PROP_SET(&dev_cfg, device, system_mode, BCMOLT_SYSTEM_MODE_XGS__2_X_10_G); |
| 452 | |
| 453 | rc = mac_util_access_terminal_set_for_10G_itu_pon(dev_cfg, device_id); |
| 454 | if (rc != BCM_ERR_OK) |
| 455 | return rc; |
| 456 | |
| 457 | return maple_access_terminal_connect_common(device_id); |
| 458 | } |
| 459 | |
| 460 | |
| 461 | /** |
| 462 | * @brief post access terminal up configurations on Maple |
| 463 | */ |
| 464 | bcmos_errno mac_util_access_terminal_post_indication_set_for_xgpon_xgs(bcmolt_devid device_id) |
| 465 | { |
| 466 | bcmos_errno rc = BCM_ERR_OK; |
| 467 | bcmolt_devid dummy; |
| 468 | uint32_t physical_if_id; |
| 469 | uint32_t logical_pon = BCM_TOPO_PON_INVALID; |
| 470 | bcmolt_xgpon_ni_key ni_key = {}; |
| 471 | bcmolt_xgpon_ni_cfg ni_cfg = {}; |
| 472 | bcmolt_automatic_onu_deactivation automatic_onu_deactivation = {}; |
| 473 | bcmolt_xgpon_sn_acquisition sn_acquisition_cfg = {}; |
| 474 | bcmolt_xgpon_ni_auto_cfg xgpon_ni_auto_cfg = {}; /* main auto cfg api struct */ |
| 475 | |
| 476 | /* configure one time settings for all the interfaces on this device */ |
| 477 | BCM_TOPO_DEV_FOR_EACH_PON(device_id, logical_pon) |
| 478 | { |
| 479 | /* get physical interface from logical interface */ |
| 480 | rc = bcm_topo_pon_get_logical2physical (logical_pon, &dummy, &physical_if_id); |
| 481 | if (BCM_ERR_OK != rc) |
| 482 | { |
| 483 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 484 | "Failed to get physical if from logical if (%s)\n", bcmos_strerror(rc)); |
| 485 | break; |
| 486 | } |
| 487 | |
| 488 | ni_key.pon_ni = physical_if_id; |
| 489 | |
| 490 | /* Set the SN acquisition mode to enable */ |
| 491 | BCMOLT_CFG_INIT(&ni_cfg, xgpon_ni, ni_key); |
| 492 | |
| 493 | sn_acquisition_cfg.control = BCMOLT_CONTROL_STATE_ENABLE; |
| 494 | sn_acquisition_cfg.interval = 5000; |
| 495 | sn_acquisition_cfg.onu_post_discovery_mode = BCMOLT_ONU_POST_DISCOVERY_MODE_NONE; |
| 496 | sn_acquisition_cfg.burst_profile = 0; /* Ranging burst profile - No FEC */ |
| 497 | BCMOLT_CFG_PROP_SET(&ni_cfg, xgpon_ni, sn_acquisition, sn_acquisition_cfg); |
| 498 | |
| 499 | /* Unlike GPON, the default behavior on Maple for XG-PON1 is not to deactivate the ONU in the below cases |
| 500 | * so here we specifically configure the Maple to behave on XG-PON1 as it does on GPON */ |
| 501 | automatic_onu_deactivation.ack_timeout = BCMOS_TRUE; |
| 502 | automatic_onu_deactivation.loki = BCMOS_TRUE; |
| 503 | automatic_onu_deactivation.los = BCMOS_TRUE; |
| 504 | automatic_onu_deactivation.onu_alarms = BCMOS_TRUE; |
| 505 | automatic_onu_deactivation.sfi = BCMOS_TRUE; |
| 506 | automatic_onu_deactivation.tiwi = BCMOS_TRUE; |
| 507 | BCMOLT_CFG_PROP_SET(&ni_cfg, xgpon_ni, automatic_onu_deactivation, automatic_onu_deactivation); |
| 508 | |
| 509 | rc = bcmolt_cfg_set(device_id, &ni_cfg.hdr); |
| 510 | if (rc != BCM_ERR_OK) |
| 511 | { |
| 512 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 513 | "Failed to set sn acquisition and automatic onu deactivation configuration (%s)," |
| 514 | " device_id=%d, ni_key.pon_ni=%d, err_text=%s)\n", |
| 515 | bcmos_strerror(rc), device_id, ni_key.pon_ni, ni_cfg.hdr.hdr.err_text); |
| 516 | break; |
| 517 | } |
| 518 | |
| 519 | |
| 520 | /* turn off the auto indication messages for xgpon_ni.serial_number_acquisition_cycle_start */ |
| 521 | BCMOLT_AUTO_CFG_INIT(&xgpon_ni_auto_cfg, xgpon_ni, ni_key); |
| 522 | BCMOLT_AUTO_CFG_PROP_SET(&xgpon_ni_auto_cfg, xgpon_ni, serial_number_acquisition_cycle_start, BCMOS_FALSE); |
| 523 | rc = bcmolt_auto_cfg_set(device_id, &xgpon_ni_auto_cfg.hdr); |
| 524 | if (rc != BCM_ERR_OK) |
| 525 | { |
| 526 | BCM_LOG(WARNING, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(logical_pon), |
| 527 | "bcmolt_auto_cfg_set for xgpon_ni.serial_number_acquisition_cycle_start, Failed (%s), err_text=%s)\n", |
| 528 | bcmos_strerror(rc), xgpon_ni_auto_cfg.hdr.hdr.err_text); |
| 529 | |
| 530 | /* ignore any error, just continue anyway */ |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | return rc; |
| 535 | } |
| 536 | |
| 537 | |
| 538 | /** |
| 539 | * @brief Command Set setup routine for interface up to mac application for xgpon (XG-PON1) |
| 540 | * |
| 541 | * This routine is called by if_fsm in the BAL core to initialize the command |
| 542 | * set to up the interface of the mac application. The cmdset actually |
| 543 | * consists of two commands, one is to send the if up request message to the mac |
| 544 | * App and handle the relevant response, the other is to handle the indication message |
| 545 | * from the mac APP when the operation is completed. |
| 546 | * |
| 547 | * @param p_interface_inst Pointer to interface instance |
| 548 | * @param op_type Operation type on access terminal/interface instance |
| 549 | * |
| 550 | * @return bcmos_errno |
| 551 | * |
| 552 | */ |
| 553 | bcmos_errno mac_util_interface_set_for_xgpon(acc_term_interface *p_interface_inst, bal_util_oper_if op_type) |
| 554 | { |
| 555 | bcmos_errno rc = BCM_ERR_OK; |
| 556 | |
| 557 | bcmbal_interface_cfg *p_interface_req = &(p_interface_inst->api_req_int_obj_info); |
| 558 | bcmbal_interface_key intf_key = p_interface_req->key; |
| 559 | |
| 560 | do |
| 561 | { |
| 562 | bcmolt_devid device_id; |
| 563 | uint32_t physical_if_id; |
| 564 | |
| 565 | /* get physical interface from logical interface */ |
| 566 | rc = bcm_topo_pon_get_logical2physical (intf_key.intf_id, &device_id, &physical_if_id); |
| 567 | if (BCM_ERR_OK != rc) |
| 568 | { |
| 569 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(intf_key.intf_id), |
| 570 | "Failed to get physical if from logical if (%s)\n", bcmos_strerror(rc)); |
| 571 | break; |
| 572 | } |
| 573 | |
| 574 | bcmolt_xgpon_ni_set_pon_state oper_ni; |
| 575 | bcmolt_xgpon_ni_key ni_key = { .pon_ni = physical_if_id }; |
| 576 | bcmolt_xgpon_trx_cfg cfg = {}; |
| 577 | bcmolt_xgpon_trx_key trx_key = { .pon_ni = physical_if_id }; |
| 578 | bcmolt_xgpon_trx_type trx_type; |
| 579 | |
| 580 | if (BAL_UTIL_OPER_IF_UP == op_type) |
| 581 | { |
| 582 | |
| 583 | /* set the pon_ni transceiver configuration */ |
| 584 | BCMOLT_CFG_INIT(&cfg, xgpon_trx, trx_key); |
| 585 | |
| 586 | /* Get the current default burst profiles */ |
| 587 | rc = bcmolt_cfg_get(device_id, &cfg.hdr); |
| 588 | if (rc != BCM_ERR_OK) |
| 589 | { |
| 590 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(intf_key.intf_id), |
| 591 | "Failed to get trx configuration (%s), err_text=%s\n", bcmos_strerror(rc), cfg.hdr.hdr.err_text); |
| 592 | break; |
| 593 | } |
| 594 | |
| 595 | /* If the user didn't specify a transceiver, then use the default */ |
| 596 | if (BCMOS_TRUE != BCMBAL_CFG_PROP_IS_SET(p_interface_req, interface, transceiver_type)) |
| 597 | { |
| 598 | if(BCM_TOPO_PON_MODE_XGPON == bcm_topo_pon_get_pon_mode(intf_key.intf_id)) |
| 599 | { |
| 600 | /* The user didn't choose a transceiver type, so override it here |
| 601 | * with the default value for XGPON |
| 602 | */ |
| 603 | BCMBAL_CFG_PROP_SET(p_interface_req, interface, transceiver_type, BCMBAL_MAC_UTIL_TRX_TYPE_DEFAULT_XGPON); |
| 604 | } |
| 605 | else if (BCM_TOPO_PON_MODE_XGS == bcm_topo_pon_get_pon_mode(intf_key.intf_id)) |
| 606 | { |
| 607 | /* The user didn't choose a transceiver type, so override it here |
| 608 | * with the default value for XGS |
| 609 | */ |
| 610 | BCMBAL_CFG_PROP_SET(p_interface_req, interface, transceiver_type, BCMBAL_MAC_UTIL_TRX_TYPE_DEFAULT_XGS); |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | /* Set the (default or chosen) transceiver configuration into the MAC device */ |
| 615 | |
| 616 | trx_type = mac_xgpon_bal_trx_type2bcm68620_trx_type(p_interface_req->data.transceiver_type); |
| 617 | |
| 618 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_trx, transceiver_type, trx_type); |
| 619 | |
| 620 | rc = bcmolt_cfg_set(device_id, &cfg.hdr); |
| 621 | if (rc != BCM_ERR_OK) |
| 622 | { |
| 623 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(intf_key.intf_id), |
| 624 | "Failed to set trx configuration (%s), err_text=%s\n", bcmos_strerror(rc), cfg.hdr.hdr.err_text); |
| 625 | break; |
| 626 | } |
| 627 | |
| 628 | /* No need to Configure pon_ni Inter-working on XG-PON1 as |
| 629 | * direct mode is the only option available on this system mode |
| 630 | */ |
| 631 | } |
| 632 | |
| 633 | |
| 634 | /* invoke the pon_ni state change to the requested state */ |
| 635 | BCMOLT_OPER_INIT(&oper_ni, xgpon_ni, set_pon_state, ni_key); |
| 636 | BCMOLT_OPER_PROP_SET(&oper_ni, xgpon_ni, set_pon_state, pon_state, |
| 637 | (BAL_UTIL_OPER_IF_UP == op_type) ? |
| 638 | BCMOLT_PON_OPERATION_ACTIVE_WORKING : BCMOLT_PON_OPERATION_INACTIVE); |
| 639 | |
| 640 | rc = bcmolt_oper_submit(device_id, &oper_ni.hdr); |
| 641 | if (rc != BCM_ERR_OK) |
| 642 | { |
| 643 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(intf_key.intf_id), |
| 644 | "Failed to %s (submit) pon interface (%s), err_text=%s\n", |
| 645 | (BAL_UTIL_OPER_IF_UP == op_type) ? "activate" : "deactivate", |
| 646 | bcmos_strerror(rc), oper_ni.hdr.hdr.err_text); |
| 647 | } |
| 648 | |
| 649 | } while (0); |
| 650 | |
| 651 | if (BCM_ERR_OK == rc) |
| 652 | { |
| 653 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(intf_key.intf_id), |
| 654 | "Submitted INTERFACE-%s operation for IF %d\n", |
| 655 | (BAL_UTIL_OPER_IF_UP == op_type) ? "UP" : "DOWN", |
| 656 | intf_key.intf_id); |
| 657 | } |
| 658 | |
| 659 | return rc; |
| 660 | } |
| 661 | |
| 662 | |
| 663 | /** |
| 664 | * @brief mac_util_validate_subscriber_terminal_info_for_xgpon (XG-PON1) |
| 665 | * |
| 666 | * This routine is used to validate all input attributes required for a sub term setting |
| 667 | * received from core for GPON |
| 668 | * |
| 669 | * @param p_sub_term_req A pointer to a subscriber terminal object |
| 670 | * |
| 671 | * @return bcmos_errno |
| 672 | */ |
| 673 | bcmos_errno mac_util_validate_subscriber_terminal_info_for_xgpon(const bcmbal_subscriber_terminal_cfg *p_sub_term_req) |
| 674 | { |
| 675 | if(BCMBAL_STATE_UP == p_sub_term_req->data.admin_state) |
| 676 | { |
| 677 | if (!BCMBAL_CFG_PROP_IS_SET (p_sub_term_req, subscriber_terminal, serial_number)) |
| 678 | { |
| 679 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 680 | "Serial number is a mandatory parameter for a xgpon subscriber terminal, and it is not set\n"); |
| 681 | return BCM_ERR_MANDATORY_PARM_IS_MISSING; |
| 682 | } |
| 683 | |
| 684 | if (!BCMBAL_CFG_PROP_IS_SET(p_sub_term_req, subscriber_terminal, registration_id)) |
| 685 | { |
| 686 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 687 | "Registration id is a mandatory parameter for a xgpon subscriber terminal, and it is not set\n"); |
| 688 | return BCM_ERR_MANDATORY_PARM_IS_MISSING; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | return BCM_ERR_OK; |
| 693 | } |
| 694 | |
| 695 | |
| 696 | /** |
| 697 | * @brief Command Set setup routine for subscriber terminal connect to mac application for xgpon (XG-PON1) |
| 698 | * |
| 699 | * This routine is called by sub_term_fsm in the BAL core to initialize the command |
| 700 | * set to connect the subscriber terminal of the mac application. The cmdset actually |
| 701 | * consists of two commands, one is to send the sub_term request message to the mac |
| 702 | * App and handle the relevant response, the other is to handle the indication message |
| 703 | * from the mac APP when the operation is completed. |
| 704 | * |
| 705 | * @param p_sub_term_inst A pointer to a subscriber terminal instance |
| 706 | * @param op_type Type of operation being performed on the subscriber terminal instance |
| 707 | * @param is_post_discovery Used for ADD, indicates if this is a request after a ONU discovery |
| 708 | * |
| 709 | * @return bcmos_errno |
| 710 | * |
| 711 | * @note we configure Maple for ONU in 2 stages: |
| 712 | * \li Stage 1: do cfg_set with the serial num, password, omci port, as part of first sub_term_set from Core |
| 713 | * \li Stage 2: set the ONU state to ACTIVE using oper_submit, as part of second sub_term_set from Core (after |
| 714 | * receiving a Discovery indication) |
| 715 | */ |
| 716 | bcmos_errno mac_util_subscriber_terminal_set_for_xgpon(sub_term_inst *p_sub_term_inst, bal_util_oper_sub_term op_type, bcmos_bool is_post_discovery) |
| 717 | { |
| 718 | bcmos_errno rc = BCM_ERR_OK; |
| 719 | |
| 720 | bcmbal_subscriber_terminal_cfg *p_sub_term_req = &p_sub_term_inst->api_req_sub_term_info; |
| 721 | |
| 722 | do |
| 723 | { |
| 724 | bcmolt_devid device_id; |
| 725 | uint32_t physical_if_id; |
| 726 | /* get physical interface from logical interface */ |
| 727 | rc = bcm_topo_pon_get_logical2physical (p_sub_term_req->key.intf_id, &device_id, &physical_if_id); |
| 728 | if (BCM_ERR_OK != rc) |
| 729 | { |
| 730 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 731 | "Failed to get physical if from logical if (%s)\n", bcmos_strerror(rc)); |
| 732 | break; |
| 733 | } |
| 734 | |
| 735 | bcmolt_xgpon_onu_cfg cfg = {}; |
| 736 | bcmolt_xgpon_onu_cfg onu_cfg_get = {}; |
| 737 | bcmolt_xgpon_onu_set_onu_state oper = {}; |
| 738 | bcmolt_xgpon_onu_key key = {}; |
| 739 | bcmolt_onu_operation new_onu_state; |
| 740 | |
| 741 | /* set the onu key - set it to the physical if id */ |
| 742 | key.pon_ni = physical_if_id; |
| 743 | key.onu_id = p_sub_term_req->key.sub_term_id; |
| 744 | |
| 745 | /* set the onu key */ |
| 746 | BCMOLT_CFG_INIT(&cfg, xgpon_onu, key); |
| 747 | |
| 748 | /* invoke onu state change operation to the new state */ |
| 749 | BCMOLT_OPER_INIT(&oper, xgpon_onu, set_onu_state, key); |
| 750 | |
| 751 | if(BAL_UTIL_OPER_SUB_TERM_CLEAR == op_type) |
| 752 | { |
| 753 | /* Delete the configuration of the ONU */ |
| 754 | rc = bcmolt_cfg_clear(device_id, &cfg.hdr); |
| 755 | if (BCM_ERR_OK != rc) |
| 756 | { |
| 757 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 758 | "Failed to clear onu configuration(%s)\n", |
| 759 | bcmos_strerror(rc)); |
| 760 | } |
| 761 | |
| 762 | /* No indication from Maple will result from the clear operation |
| 763 | * so fake it here |
| 764 | */ |
| 765 | mac_util_report_sub_term_event(p_sub_term_req->key.intf_id, |
| 766 | p_sub_term_req->key.sub_term_id, |
| 767 | (bcmolt_serial_number *)NULL, |
| 768 | BAL_UTIL_OPER_SUB_TERM_CLEAR, |
| 769 | rc, rc, |
| 770 | MAC_UTIL_DEACTIVATION_FAIL_REASON_NONE, BCMBAL_INVALID_TUNNEL_ID); |
| 771 | |
| 772 | /* No further processing is required for the CLEAR operation */ |
| 773 | break; |
| 774 | |
| 775 | |
| 776 | } |
| 777 | else if(BAL_UTIL_OPER_SUB_TERM_ADD == op_type) |
| 778 | { |
| 779 | /* first do a get, to see if onu is in active state already */ |
| 780 | BCMOLT_CFG_INIT(&onu_cfg_get, xgpon_onu, key); |
| 781 | BCMOLT_CFG_PROP_GET(&onu_cfg_get, xgpon_onu, onu_state); |
| 782 | rc = bcmolt_cfg_get(device_id, &onu_cfg_get.hdr); |
| 783 | if (rc != BCM_ERR_OK) |
| 784 | { |
| 785 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 786 | "Failed to get onu configuration(%s), err_text=%s, ... continue to configure\n", |
| 787 | bcmos_strerror(rc), onu_cfg_get.hdr.hdr.err_text); |
| 788 | |
| 789 | /* don't break, but continue with the set anyways */ |
| 790 | } |
| 791 | else |
| 792 | { |
| 793 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 794 | "%s: ONU state = %d, [pon_ni=%d, onu_id=%d], BEFORE doing cfg_set on Maple\n", |
| 795 | __FUNCTION__, onu_cfg_get.data.onu_state, onu_cfg_get.key.pon_ni, onu_cfg_get.key.onu_id); |
| 796 | } |
| 797 | |
| 798 | |
| 799 | if ((BCM_ERR_OK == rc) && (BCMOLT_ONU_STATE_ACTIVE == onu_cfg_get.data.onu_state)) |
| 800 | { |
| 801 | BCM_LOG(INFO, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 802 | "%s: ONU already in active state during ADD. Skipping further config\n", |
| 803 | __FUNCTION__); |
| 804 | |
| 805 | mac_util_report_sub_term_event(p_sub_term_req->key.intf_id, |
| 806 | p_sub_term_req->key.sub_term_id, |
| 807 | (bcmolt_serial_number *)NULL, |
| 808 | BAL_UTIL_OPER_SUB_TERM_ADD, |
| 809 | rc, rc, |
| 810 | BCMOLT_ACTIVATION_FAIL_REASON_NONE, BCMBAL_INVALID_TUNNEL_ID); |
| 811 | break; |
| 812 | } |
| 813 | |
| 814 | |
| 815 | /* set the SN & Registration ID only if it being configured for the first time */ |
| 816 | if (BCMOS_FALSE == is_post_discovery) |
| 817 | { |
| 818 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, serial_number, |
| 819 | *((bcmolt_serial_number *)&p_sub_term_req->data.serial_number)); |
| 820 | |
| 821 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, registration_id, |
| 822 | *((bcmolt_arr_u8_36 *)&p_sub_term_req->data.registration_id)); |
| 823 | |
| 824 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, registration_id_auto_learning, BCMOS_TRUE); |
| 825 | |
| 826 | /* Ranging burst profile - No FEC */ |
| 827 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, ranging_burst_profile, 0); |
| 828 | |
| 829 | /* Data burst profile - No FEC */ |
| 830 | BCMOLT_CFG_PROP_SET(&cfg, xgpon_onu, data_burst_profile, 1); |
| 831 | |
| 832 | |
| 833 | /* XG-PON1 - No need to set US FEC - it is part of the burst profile */ |
| 834 | /* XG-PON1 - No need to set ONU management channel port as it is identical to the ONU ID*/ |
| 835 | |
| 836 | rc = bcmolt_cfg_set(device_id, &cfg.hdr); |
| 837 | if (rc != BCM_ERR_OK) |
| 838 | { |
| 839 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 840 | "Failed to set onu configuration(%s), err_text=%s\n", |
| 841 | bcmos_strerror(rc), cfg.hdr.hdr.err_text); |
| 842 | break; |
| 843 | } |
| 844 | |
| 845 | /** |
| 846 | * @note If this is first time set for ADD, then skip setting the ONU state for now. |
| 847 | * Wait until ONU Discovery is received. |
| 848 | */ |
| 849 | break; |
| 850 | } |
| 851 | |
| 852 | /* |
| 853 | * Set the new onu state for the ADD operation |
| 854 | */ |
| 855 | BCM_LOG(DEBUG, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 856 | "Setting ONU state to active\n"); |
| 857 | |
| 858 | new_onu_state = BCMOLT_ONU_OPERATION_ACTIVE; |
| 859 | } |
| 860 | else if (BAL_UTIL_OPER_SUB_TERM_REMOVE == op_type) |
| 861 | { |
| 862 | /* If the ONU is not present, then it will never respond to the deactivate command |
| 863 | * with an indication, so just allow the FSM to continue as if it did. |
| 864 | */ |
| 865 | if(BCMBAL_STATUS_NOT_PRESENT != p_sub_term_inst->current_sub_term_info.data.oper_status) |
| 866 | { |
| 867 | /* |
| 868 | * Set the new onu state for the REMOVE operation |
| 869 | */ |
| 870 | BCM_LOG(INFO, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 871 | "Setting ONU state to IN-active\n"); |
| 872 | |
| 873 | new_onu_state = BCMOLT_ONU_OPERATION_INACTIVE; |
| 874 | } |
| 875 | } |
| 876 | else /* This should never happen */ |
| 877 | { |
| 878 | BCM_LOG(ERROR, log_id_mac_util, "Bad request from core\n"); |
| 879 | rc = BCM_ERR_INTERNAL; |
| 880 | break; |
| 881 | } |
| 882 | |
| 883 | /* Do oper_submit to set the ONU state */ |
| 884 | BCMOLT_OPER_PROP_SET(&oper, xgpon_onu, set_onu_state, onu_state, new_onu_state); |
| 885 | rc = bcmolt_oper_submit(device_id, &oper.hdr); |
| 886 | if (BCM_ERR_OK != rc) |
| 887 | { |
| 888 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 889 | "bcmolt_oper_submit Failed for onu state Failed (%s), err_text=%s\n", |
| 890 | bcmos_strerror(rc), &(oper.hdr.hdr.err_text[0])); |
| 891 | } |
| 892 | |
| 893 | |
| 894 | /* If the ONU is not present, then it will never respond to the deactivate command |
| 895 | * with an indication, so just allow the FSM to continue as if it did. |
| 896 | */ |
| 897 | if((BCMOLT_ONU_OPERATION_INACTIVE == new_onu_state) && |
| 898 | (BCMBAL_STATUS_NOT_PRESENT == p_sub_term_inst->current_sub_term_info.data.oper_status)) |
| 899 | { |
| 900 | mac_util_report_sub_term_event(p_sub_term_req->key.intf_id, |
| 901 | p_sub_term_req->key.sub_term_id, |
| 902 | (bcmolt_serial_number *)NULL, |
| 903 | BAL_UTIL_OPER_SUB_TERM_REMOVE, |
| 904 | rc, rc, |
| 905 | MAC_UTIL_DEACTIVATION_FAIL_REASON_NONE, BCMBAL_INVALID_TUNNEL_ID); |
| 906 | } |
| 907 | |
| 908 | } while (0); |
| 909 | |
| 910 | |
| 911 | |
| 912 | if (rc == BCM_ERR_STATE) |
| 913 | { |
| 914 | BCM_LOG(INFO, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 915 | "%s failed to set state, possibly because interface is not configured yet, pon fiber disconnect, or onu disconnect: rc = %s (%d)\n", |
| 916 | __FUNCTION__, |
| 917 | bcmos_strerror(rc), rc); |
| 918 | } |
| 919 | else if (BCM_ERR_OK != rc) |
| 920 | { |
| 921 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_sub_term_req->key.intf_id), |
| 922 | "%s Failed: rc = %s (%d)\n", |
| 923 | __FUNCTION__, |
| 924 | bcmos_strerror(rc), rc); |
| 925 | } |
| 926 | |
| 927 | return rc; |
| 928 | } |
| 929 | |
| 930 | |
| 931 | /** |
| 932 | * @brief validate_flow_info for xgpon (XG-PON1) |
| 933 | * |
| 934 | * This routine is used to validate all input attributes required for a flow |
| 935 | * setting received from core for XG-PON1 |
| 936 | * |
| 937 | * @param p_flow_req A pointer to a flow object |
| 938 | * |
| 939 | * @return bcmos_errno |
| 940 | */ |
| 941 | bcmos_errno mac_util_validate_flow_info_for_xgpon (const bcmbal_flow_cfg *p_flow_req) |
| 942 | { |
| 943 | bcmos_errno rc = BCM_ERR_OK; |
| 944 | |
| 945 | if (p_flow_req->key.flow_type == BCMBAL_FLOW_TYPE_UPSTREAM) |
| 946 | { |
| 947 | if (!BCMBAL_CFG_PROP_IS_SET(p_flow_req, flow, agg_port_id)) |
| 948 | { |
| 949 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 950 | "agg port id is a mandatory parameter for an US flow, and it is not set\n"); |
| 951 | rc = BCM_ERR_MANDATORY_PARM_IS_MISSING; |
| 952 | } |
| 953 | |
| 954 | } |
| 955 | |
| 956 | return rc; |
| 957 | } |
| 958 | /* As there is no indication on gem port configuration completion, for xgpon |
| 959 | we will have to initiate querying it right after configuring it and retrieve the gem port state. |
| 960 | we can not assume it is activated (for example if the onu is not present) |
| 961 | */ |
| 962 | static bcmos_errno maple_mac_xgpon_update_svc_port_ind_flag (bcmbal_flow_cfg *p_flow_req, flow_list_entry *p_mac_util_flow_entry) |
| 963 | { |
| 964 | bcmos_errno rc = BCM_ERR_OK; |
| 965 | bcmolt_xgpon_gem_port_key gem_key = {}; |
| 966 | bcmolt_xgpon_gem_port_cfg gem_cfg = {}; |
| 967 | bcmolt_devid device_id; |
| 968 | uint32_t physical_if_id; |
| 969 | |
| 970 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(p_flow_req->data.access_int_id, device_id, physical_if_id); |
| 971 | |
| 972 | /* set the gem port object key */ |
| 973 | gem_key.pon_ni = physical_if_id; |
| 974 | gem_key.gem_port_id = p_flow_req->data.svc_port_id; |
| 975 | BCMOLT_CFG_INIT(&gem_cfg, xgpon_gem_port, gem_key); |
| 976 | BCMOLT_CFG_PROP_GET(&gem_cfg, xgpon_gem_port, all_properties); |
| 977 | |
| 978 | rc = bcmolt_cfg_get(device_id, &gem_cfg.hdr); |
| 979 | if(BCM_ERR_OK != rc) |
| 980 | { |
| 981 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 982 | "%s FAILED to gem xgpon_gem_port configuration : device_id = %d if_id = %d gem_port_id = %d \n", |
| 983 | __FUNCTION__, |
| 984 | device_id, p_flow_req->data.access_int_id, p_flow_req->data.svc_port_id); |
| 985 | |
| 986 | return rc; |
| 987 | } |
| 988 | |
| 989 | if ( BCMOLT_XGPON_GEM_PORT_STATE_ACTIVE == gem_cfg.data.gem_port_state) |
| 990 | { |
| 991 | p_mac_util_flow_entry->is_waiting_for_svc_port_active = BCMOS_FALSE; |
| 992 | } |
| 993 | return rc; |
| 994 | } |
| 995 | |
| 996 | /** |
| 997 | * @brief flow set for xgpon (XG-PON1) |
| 998 | * @param p_flow_req pointer to flow request structure from core |
| 999 | * @param op_type ADD, REMOVE or CLEAR |
| 1000 | * @param p_flow_core core FSM DB flow context passed as a cookie |
| 1001 | * |
| 1002 | * @return errno error |
| 1003 | * |
| 1004 | * @todo shift this out to mac specific files |
| 1005 | */ |
| 1006 | bcmos_errno mac_util_flow_set_for_xgpon (bcmbal_flow_cfg *p_flow_req, bal_util_oper_flow op_type, flow_inst *p_flow_core) |
| 1007 | { |
| 1008 | bcmos_errno rc = BCM_ERR_OK; |
| 1009 | uint16_t per_flow_mode_vlan_id = 0; /* hold the value of the vlan tag to use in per-flow mode */ |
| 1010 | uint8_t pbits_val = 0; |
| 1011 | flow_list_entry *p_mac_util_flow_entry = NULL; |
| 1012 | |
| 1013 | /* Check the operation id */ |
| 1014 | if ((BAL_UTIL_OPER_FLOW_ADD != op_type) && |
| 1015 | (BAL_UTIL_OPER_FLOW_REMOVE != op_type) && |
| 1016 | (BAL_UTIL_OPER_FLOW_CLEAR != op_type)) |
| 1017 | { |
| 1018 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 1019 | "Unexpected mac_util flow operation %d \n", op_type); |
| 1020 | return BCM_ERR_PARM; |
| 1021 | } |
| 1022 | |
| 1023 | /* flow Add or Modify */ |
| 1024 | if (BAL_UTIL_OPER_FLOW_ADD == op_type) |
| 1025 | { |
| 1026 | switch (p_flow_req->key.flow_type) |
| 1027 | { |
| 1028 | /* unicast flows */ |
| 1029 | case BCMBAL_FLOW_TYPE_UPSTREAM: |
| 1030 | case BCMBAL_FLOW_TYPE_DOWNSTREAM: |
| 1031 | { |
| 1032 | if (p_flow_req->data.classifier.o_pbits) |
| 1033 | { |
| 1034 | /* o_pbits can only take one p-bit value */ |
| 1035 | pbits_val = p_flow_req->data.classifier.o_pbits; |
| 1036 | } |
| 1037 | else |
| 1038 | { |
| 1039 | pbits_val = 0; |
| 1040 | } |
| 1041 | |
| 1042 | /* create a gem port id and relevant flow for a single pbit, or with no pbit */ |
| 1043 | /* pass on the op type also to specify if it is FLOW_ADD OR FLOW_MODIFY */ |
| 1044 | rc = maple_mac_unicast_flow_add(p_flow_req, pbits_val, per_flow_mode_vlan_id, op_type, &p_mac_util_flow_entry); |
| 1045 | if ((BCM_ERR_OK != rc) || (NULL == p_mac_util_flow_entry)) |
| 1046 | { |
| 1047 | break; |
| 1048 | } |
| 1049 | |
| 1050 | /* mark flow configuration to device completed */ |
| 1051 | mac_util_mark_flow_config_complete(p_mac_util_flow_entry); |
| 1052 | rc = maple_mac_xgpon_update_svc_port_ind_flag (p_flow_req, p_mac_util_flow_entry); |
| 1053 | |
| 1054 | } |
| 1055 | break; |
| 1056 | |
| 1057 | case BCMBAL_FLOW_TYPE_BROADCAST: |
| 1058 | { |
| 1059 | rc = maple_mac_broadcast_flow_add(p_flow_req, per_flow_mode_vlan_id, op_type, &p_mac_util_flow_entry); |
| 1060 | } |
| 1061 | break; |
| 1062 | |
| 1063 | default: |
| 1064 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 1065 | "Unknown flow type %d\n", |
| 1066 | p_flow_req->key.flow_type); |
| 1067 | rc = BCM_ERR_PARM; |
| 1068 | break; |
| 1069 | } |
| 1070 | } |
| 1071 | else if ((BAL_UTIL_OPER_FLOW_REMOVE == op_type) || |
| 1072 | (BAL_UTIL_OPER_FLOW_CLEAR == op_type)) |
| 1073 | { |
| 1074 | /* find the flow */ |
| 1075 | p_mac_util_flow_entry = _mac_util_db_flow_get_w_flow_key(p_flow_req->data.access_int_id, &(p_flow_req->key)); |
| 1076 | if (NULL == p_mac_util_flow_entry) |
| 1077 | { |
| 1078 | rc = BCM_ERR_NOENT; |
| 1079 | if (BAL_UTIL_OPER_FLOW_CLEAR != op_type) |
| 1080 | { |
| 1081 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 1082 | "%s: NULL mac util flow entry to remove: flow id: %d, flow_type: %s\n", |
| 1083 | __FUNCTION__, |
| 1084 | p_flow_req->key.flow_id, |
| 1085 | (p_flow_req->key.flow_type == BCMBAL_FLOW_TYPE_UPSTREAM ? "up":"down")); |
| 1086 | } |
| 1087 | |
| 1088 | goto exit; |
| 1089 | } |
| 1090 | |
| 1091 | switch (p_flow_req->key.flow_type) |
| 1092 | { |
| 1093 | /* unicast flows */ |
| 1094 | case BCMBAL_FLOW_TYPE_UPSTREAM: |
| 1095 | case BCMBAL_FLOW_TYPE_DOWNSTREAM: |
| 1096 | { |
| 1097 | /** Remove unicast GEM/Alloc Id from Maple and flow entry from local database */ |
| 1098 | rc = maple_mac_unicast_flow_remove(p_flow_req, op_type, p_mac_util_flow_entry); |
| 1099 | if (BCM_ERR_OK != rc) |
| 1100 | { |
| 1101 | break; |
| 1102 | } |
| 1103 | |
| 1104 | /* mark flow De-configuration to device completed */ |
| 1105 | mac_util_mark_flow_config_complete(p_mac_util_flow_entry); |
| 1106 | } |
| 1107 | break; |
| 1108 | |
| 1109 | case BCMBAL_FLOW_TYPE_BROADCAST: |
| 1110 | { |
| 1111 | rc = maple_mac_broadcast_flow_remove(p_flow_req, per_flow_mode_vlan_id, op_type, p_mac_util_flow_entry); |
| 1112 | } |
| 1113 | break; |
| 1114 | |
| 1115 | default: |
| 1116 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 1117 | "Unknown flow type %d\n", |
| 1118 | p_flow_req->key.flow_type); |
| 1119 | rc = BCM_ERR_PARM; |
| 1120 | break; |
| 1121 | } |
| 1122 | |
| 1123 | } /* Flow Remove */ |
| 1124 | else |
| 1125 | { |
| 1126 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(p_flow_req->data.access_int_id), |
| 1127 | "Unknown flow op type %d for flow id/type = %d/%d\n", |
| 1128 | op_type, p_flow_req->key.flow_id, p_flow_req->key.flow_type); |
| 1129 | rc = BCM_ERR_PARM; |
| 1130 | } |
| 1131 | |
| 1132 | exit: |
| 1133 | if (BCM_ERR_OK == rc) |
| 1134 | { |
| 1135 | /* |
| 1136 | * Check flow entry flags to see if an indication to Core should be triggered immediately: |
| 1137 | * (Special handling for flow configuration, for the case no device configuration is needed, |
| 1138 | * and/or no indication from device is expected - could be the case of a single/multiple |
| 1139 | * gem ports used for us and ds, and us was already configured. |
| 1140 | * - send the flow ind immediately |
| 1141 | */ |
| 1142 | check_send_flow_bal_ind_msg(p_mac_util_flow_entry, BCM_ERR_OK, BCMOLT_RESULT_SUCCESS); |
| 1143 | } |
| 1144 | else |
| 1145 | { |
| 1146 | if ((BCM_ERR_NOENT == rc) && (BAL_UTIL_OPER_FLOW_CLEAR == op_type)) |
| 1147 | { |
| 1148 | /* |
| 1149 | * For flow CLEAR, and if no flow entry is found, then fake an indication success to Core, |
| 1150 | * for it to execute the flow state machine. |
| 1151 | * The reasons for flow entry not found could be because the flow was already admin-ed Down. |
| 1152 | * Admin-down of a flow causes mac util to clear flow config and flow instance from itself |
| 1153 | * and the maple HW. However, Core FSM still keeps it's flow instance during admin down state. |
| 1154 | */ |
| 1155 | mac_util_report_flow_remove_success (p_flow_req->key, p_flow_req->data.access_int_id, op_type); |
| 1156 | rc = BCM_ERR_OK; |
| 1157 | } |
| 1158 | } |
| 1159 | //else if there was an error during config, just return a failure; no need to send back indication for that. |
| 1160 | |
| 1161 | |
| 1162 | return rc; |
| 1163 | } |
| 1164 | |
| 1165 | bcmos_errno maple_xgpon_mac_check_gem_port_id(uint32_t if_id, uint32_t onu_id, uint16_t svc_port_id, |
| 1166 | bcmos_bool *is_configured, bcmos_bool *is_activated) |
| 1167 | { |
| 1168 | bcmos_errno rc = BCM_ERR_OK; |
| 1169 | bcmolt_xgpon_gem_port_key gem_key = {}; |
| 1170 | bcmolt_xgpon_gem_port_cfg gem_cfg = {}; |
| 1171 | bcmolt_devid device_id; |
| 1172 | uint32_t physical_if_id; |
| 1173 | |
| 1174 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(if_id, device_id, physical_if_id); |
| 1175 | |
| 1176 | /* set the gem port object key */ |
| 1177 | gem_key.pon_ni = physical_if_id; |
| 1178 | gem_key.gem_port_id = svc_port_id; |
| 1179 | BCMOLT_CFG_INIT(&gem_cfg, xgpon_gem_port, gem_key); |
| 1180 | BCMOLT_CFG_PROP_GET(&gem_cfg, xgpon_gem_port, all_properties); |
| 1181 | |
| 1182 | rc = bcmolt_cfg_get(device_id, &gem_cfg.hdr); |
| 1183 | if(BCM_ERR_OK != rc) |
| 1184 | { |
| 1185 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1186 | "%s FAILED to gem xgpon_gem_port configuration : device_id = %d if_id = %d gem_port_id = %d \n", |
| 1187 | __FUNCTION__, |
| 1188 | device_id, if_id, svc_port_id); |
| 1189 | return rc; |
| 1190 | } |
| 1191 | |
| 1192 | /* may be configured; does gem belong to same onu ? */ |
| 1193 | if (BCMOLT_XGPON_GEM_PORT_STATE_NOT_CONFIGURED != gem_cfg.data.gem_port_state && onu_id != gem_cfg.data.onu_id) |
| 1194 | { |
| 1195 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1196 | "%s FAILED, onu id mismatch: svc_port_id = %d if_id = %d is already assigned to onu_id = %d (not to onu id %d) \n", |
| 1197 | __FUNCTION__, |
| 1198 | svc_port_id, if_id, gem_cfg.data.onu_id, onu_id); |
| 1199 | return BCM_ERR_PARM; |
| 1200 | } |
| 1201 | *is_configured = BCMOLT_XGPON_GEM_PORT_STATE_NOT_CONFIGURED != gem_cfg.data.gem_port_state; |
| 1202 | *is_activated = BCMOLT_XGPON_GEM_PORT_STATE_ACTIVE == gem_cfg.data.gem_port_state; |
| 1203 | |
| 1204 | return rc; |
| 1205 | } |
| 1206 | |
| 1207 | |
| 1208 | bcmos_errno maple_xgpon_gem_port_id_add(uint32_t if_id, uint16_t svc_port_id, uint32_t onu_id, bcmolt_gem_port_configuration *configuration) |
| 1209 | { |
| 1210 | bcmos_errno rc = BCM_ERR_OK; |
| 1211 | bcmolt_xgpon_gem_port_key gem_key = {}; |
| 1212 | bcmolt_xgpon_gem_port_cfg gem_cfg = {}; |
| 1213 | bcmolt_devid device_id; |
| 1214 | uint32_t physical_if_id; |
| 1215 | |
| 1216 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(if_id, device_id, physical_if_id); |
| 1217 | |
| 1218 | /* set the gem port object key */ |
| 1219 | gem_key.pon_ni = physical_if_id; |
| 1220 | gem_key.gem_port_id = svc_port_id; |
| 1221 | BCMOLT_CFG_INIT(&gem_cfg, xgpon_gem_port, gem_key); |
| 1222 | |
| 1223 | /* set the gem port configuration */ |
| 1224 | if (onu_id < BCMOLT_XGPON_ONU_ID_ANY) |
| 1225 | { |
| 1226 | BCMOLT_CFG_PROP_SET(&gem_cfg, xgpon_gem_port, onu_id, onu_id); |
| 1227 | BCMOLT_CFG_PROP_SET(&gem_cfg, xgpon_gem_port, upstream_destination_queue, |
| 1228 | BCMOLT_US_GEM_PORT_DESTINATION_DATA); |
| 1229 | } |
| 1230 | BCMOLT_CFG_PROP_SET(&gem_cfg, xgpon_gem_port, encryption_mode, |
| 1231 | BCMOLT_CONTROL_STATE_DISABLE); |
| 1232 | BCMOLT_CFG_PROP_SET(&gem_cfg, xgpon_gem_port, configuration, *configuration); |
| 1233 | BCMOLT_CFG_PROP_SET(&gem_cfg, xgpon_gem_port, control, BCMOLT_CONTROL_STATE_ENABLE); |
| 1234 | |
| 1235 | rc = bcmolt_cfg_set(device_id, &gem_cfg.hdr); |
| 1236 | if(BCM_ERR_OK != rc) |
| 1237 | { |
| 1238 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1239 | "%s FAILED: rc=%s (%d), svc_port_id = %d if_id = %d onu_id = %d, err_text=%s\n", |
| 1240 | __FUNCTION__, |
| 1241 | bcmos_strerror(rc), rc, svc_port_id, if_id, onu_id, gem_cfg.hdr.hdr.err_text); |
| 1242 | } |
| 1243 | |
| 1244 | return rc; |
| 1245 | } |
| 1246 | |
| 1247 | |
| 1248 | bcmos_errno maple_xgpon_gem_port_id_remove(uint32_t if_id, uint16_t svc_port_id) |
| 1249 | { |
| 1250 | bcmos_errno rc = BCM_ERR_OK; |
| 1251 | bcmolt_xgpon_gem_port_key gem_key = {}; |
| 1252 | bcmolt_xgpon_gem_port_cfg gem_cfg = {}; |
| 1253 | bcmolt_devid device_id; |
| 1254 | uint32_t physical_if_id; |
| 1255 | |
| 1256 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(if_id, device_id, physical_if_id); |
| 1257 | |
| 1258 | gem_key.pon_ni = physical_if_id; |
| 1259 | gem_key.gem_port_id = svc_port_id; |
| 1260 | BCMOLT_CFG_INIT(&gem_cfg, xgpon_gem_port, gem_key); |
| 1261 | rc = bcmolt_cfg_clear(device_id, &gem_cfg.hdr); |
| 1262 | if (BCM_ERR_OK != rc) |
| 1263 | { |
| 1264 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), "%s failed with error %s\n",__FUNCTION__, bcmos_strerror(rc)); |
| 1265 | } |
| 1266 | |
| 1267 | return rc; |
| 1268 | } |
| 1269 | |
| 1270 | |
| 1271 | bcmos_errno maple_xgpon_mac_get_alloc_id_config (uint32_t if_id, uint32_t onu_id, uint16_t agg_id, bcmolt_alloc_state *alloc_id_state) |
| 1272 | |
| 1273 | { |
| 1274 | bcmos_errno rc = BCM_ERR_OK; |
| 1275 | bcmolt_xgpon_alloc_key alloc_key = {}; |
| 1276 | bcmolt_xgpon_alloc_cfg alloc_cfg = {}; |
| 1277 | bcmolt_devid device_id; |
| 1278 | uint32_t physical_if_id; |
| 1279 | |
| 1280 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(if_id, device_id, physical_if_id); |
| 1281 | |
| 1282 | /* set the alloc-id key */ |
| 1283 | alloc_key.pon_ni = physical_if_id; |
| 1284 | alloc_key.alloc_id = agg_id; |
| 1285 | BCMOLT_CFG_INIT(&alloc_cfg, xgpon_alloc, alloc_key); |
| 1286 | BCMOLT_CFG_PROP_GET(&alloc_cfg, xgpon_alloc, all_properties); |
| 1287 | |
| 1288 | rc = bcmolt_cfg_get(device_id, &alloc_cfg.hdr); |
| 1289 | if(BCM_ERR_OK != rc) |
| 1290 | { |
| 1291 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1292 | "%s: FAILED in bcmolt_cfg_get rc = %s, agg_id = %d if_id = %d\n", |
| 1293 | __FUNCTION__, |
| 1294 | bcmos_strerror(rc), agg_id, if_id); |
| 1295 | |
| 1296 | return rc; |
| 1297 | } |
| 1298 | |
| 1299 | /* may be configured; does alloc id belong to the expected onu ? */ |
| 1300 | if (alloc_cfg.data.state != BCMOLT_ALLOC_STATE_NOT_CONFIGURED |
| 1301 | && alloc_cfg.data.onu_id != onu_id) |
| 1302 | { |
| 1303 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1304 | "%s FAILED, onu id mismatch: agg_id = %d if_id = %d is set to onu %d NOT to onu_id = %d\n", |
| 1305 | __FUNCTION__, |
| 1306 | agg_id, if_id, alloc_cfg.data.onu_id, onu_id); |
| 1307 | |
| 1308 | return BCM_ERR_PARM; |
| 1309 | } |
| 1310 | *alloc_id_state = alloc_cfg.data.state; |
| 1311 | |
| 1312 | return BCM_ERR_OK; |
| 1313 | } |
| 1314 | |
| 1315 | |
| 1316 | bcmos_errno maple_xgpon_us_alloc_id_add(uint32_t if_id, uint32_t onu_id, uint16_t agg_id, bcmolt_pon_alloc_sla agg_sla) |
| 1317 | { |
| 1318 | bcmos_errno rc = BCM_ERR_OK; |
| 1319 | bcmolt_xgpon_alloc_key alloc_key = {}; |
| 1320 | bcmolt_xgpon_alloc_cfg alloc_cfg = {}; |
| 1321 | bcmolt_devid device_id; |
| 1322 | uint32_t physical_if_id; |
| 1323 | |
| 1324 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(if_id, device_id, physical_if_id); |
| 1325 | |
| 1326 | |
| 1327 | /* set the alloc-id key */ |
| 1328 | alloc_key.pon_ni = physical_if_id; |
| 1329 | alloc_key.alloc_id = agg_id; |
| 1330 | BCMOLT_CFG_INIT(&alloc_cfg, xgpon_alloc, alloc_key); |
| 1331 | |
| 1332 | BCMOLT_CFG_PROP_SET(&alloc_cfg, xgpon_alloc, sla, agg_sla); |
| 1333 | /* set the alloc-id - onu assignment */ |
| 1334 | BCMOLT_CFG_PROP_SET(&alloc_cfg, xgpon_alloc, onu_id, onu_id); |
| 1335 | |
| 1336 | rc = bcmolt_cfg_set(device_id, &alloc_cfg.hdr); |
| 1337 | if(BCM_ERR_OK != rc) |
| 1338 | { |
| 1339 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1340 | "%s: rc = %s, agg_id = %d if_id = %d, sla = {g bw: %d, max bw: %d, cb_nrt_bw: %d, cb_rt_bw: %d}\n", |
| 1341 | __FUNCTION__, |
| 1342 | bcmos_strerror(rc), agg_id, if_id, |
| 1343 | agg_sla.guaranteed_bw, agg_sla.maximum_bw, agg_sla.cbr_nrt_bw, agg_sla.cbr_rt_bw); |
| 1344 | |
| 1345 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), |
| 1346 | "err_text = %s\n", |
| 1347 | alloc_cfg.hdr.hdr.err_text); |
| 1348 | } |
| 1349 | return rc; |
| 1350 | } |
| 1351 | |
| 1352 | |
| 1353 | bcmos_errno maple_xgpon_us_alloc_id_remove(uint32_t if_id, uint16_t agg_id) |
| 1354 | { |
| 1355 | bcmos_errno rc = BCM_ERR_OK; |
| 1356 | bcmolt_xgpon_alloc_key alloc_key = {}; |
| 1357 | bcmolt_xgpon_alloc_cfg alloc_cfg = {}; |
| 1358 | bcmolt_devid device_id; |
| 1359 | uint32_t physical_if_id; |
| 1360 | |
| 1361 | GET_DEVICE_ID_AND_PHYSICAL_ID_FROM_IF_ID(if_id, device_id, physical_if_id); |
| 1362 | |
| 1363 | /* set the alloc-id key */ |
| 1364 | alloc_key.pon_ni = physical_if_id; |
| 1365 | alloc_key.alloc_id = agg_id; |
| 1366 | BCMOLT_CFG_INIT(&alloc_cfg, xgpon_alloc, alloc_key); |
| 1367 | |
| 1368 | rc = bcmolt_cfg_clear(device_id, &alloc_cfg.hdr); |
| 1369 | if (BCM_ERR_OK != rc) |
| 1370 | { |
| 1371 | BCM_LOG(ERROR, MAC_UTIL_GET_LOG_ID_FOR_PON_IF(if_id), "%s failed with error %s\n",__FUNCTION__, bcmos_strerror(rc)); |
| 1372 | } |
| 1373 | return rc; |
| 1374 | } |
| 1375 | |
| 1376 | /** |
| 1377 | * @brief group set for xgpon (XG-PON1) |
| 1378 | * @param p_group_req pointer to group request structure from core |
| 1379 | * @param op_type ADD, REMOVE or SET |
| 1380 | * @param p_group_inst pointer to the Core Group Object instance |
| 1381 | * |
| 1382 | * @return errno error |
| 1383 | * |
| 1384 | * @todo shift this out to mac specific files |
| 1385 | */ |
| 1386 | bcmos_errno mac_util_group_set_for_xgpon (bcmbal_group_cfg *p_group_req, bal_util_oper_group op_type, group_inst *p_group_inst) |
| 1387 | { |
| 1388 | bcmos_errno rc = BCM_ERR_OK; |
| 1389 | uint16_t svc_port_id; |
| 1390 | uint32_t if_id, i, ref_count; |
| 1391 | bcmolt_gem_port_configuration configuration = {0}; |
| 1392 | |
| 1393 | /* Check the operation id */ |
| 1394 | if ((BAL_UTIL_OPER_GROUP_ADD != op_type) && |
| 1395 | (BAL_UTIL_OPER_GROUP_REMOVE != op_type) && |
| 1396 | (BAL_UTIL_OPER_GROUP_SET != op_type)) |
| 1397 | { |
| 1398 | BCM_LOG(ERROR, log_id_mac_util, |
| 1399 | "Unexpected mac_util xgpon group operation %d \n", op_type); |
| 1400 | return BCM_ERR_PARM; |
| 1401 | } |
| 1402 | |
| 1403 | configuration.direction = BCMOLT_GEM_PORT_DIRECTION_DOWNSTREAM; |
| 1404 | configuration.type = BCMOLT_GEM_PORT_TYPE_MULTICAST; |
| 1405 | |
| 1406 | /* for group SET operation, first remove the old multicast GEM */ |
| 1407 | if (BAL_UTIL_OPER_GROUP_SET == op_type) |
| 1408 | { |
| 1409 | bcmbal_group_cfg *p_group_rem_req; |
| 1410 | /* use the Core DB for existing members - store in current_flow_info */ |
| 1411 | p_group_rem_req = &p_group_inst->current_group_info; |
| 1412 | for(i=0; i< p_group_rem_req->data.members.len; i++) |
| 1413 | { |
| 1414 | if_id = p_group_rem_req->data.members.val[i].intf_id; |
| 1415 | svc_port_id = p_group_rem_req->data.members.val[i].svc_port_id; |
| 1416 | /* svc_port_id may be 0 in the current info when the group had no owner. |
| 1417 | skip the remove if that is the case */ |
| 1418 | if(svc_port_id) |
| 1419 | { |
| 1420 | rc = rsc_mgr_gem_get_ref_count(if_id, svc_port_id, &ref_count); |
| 1421 | if(BCM_ERR_OK != rc) |
| 1422 | { |
| 1423 | BCM_LOG(ERROR, log_id_mac_util, |
| 1424 | "mac_util xgpon group get reference count on interface %d (gem %d) failed \n", if_id, svc_port_id); |
| 1425 | return rc; |
| 1426 | } |
| 1427 | /* if other group is referencing the same GEM (ref_count > 1), do not call Mac API to remove it. |
| 1428 | The core will ask Resource Manger to decrease the counter if everything is good */ |
| 1429 | if ( ref_count == 1) |
| 1430 | { |
| 1431 | rc = maple_xgpon_gem_port_id_remove(if_id, svc_port_id); |
| 1432 | |
| 1433 | if(BCM_ERR_OK != rc) |
| 1434 | { |
| 1435 | BCM_LOG(ERROR, log_id_mac_util, |
| 1436 | "mac_util xgpon group set operation SET on remove interface %d (gem %d) failed \n", if_id, svc_port_id); |
| 1437 | return rc; |
| 1438 | } |
| 1439 | } |
| 1440 | else if ( ref_count == 0) |
| 1441 | { |
| 1442 | BCM_LOG(WARNING, log_id_mac_util, |
| 1443 | "mac_util xgpon group operation SET on interface %d (gem %d) remove with 0 reference count \n", if_id, svc_port_id); |
| 1444 | } |
| 1445 | } |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | /* walk through every member interface */ |
| 1450 | for(i=0; i< p_group_req->data.members.len; i++) |
| 1451 | { |
| 1452 | if_id = p_group_req->data.members.val[i].intf_id; |
| 1453 | svc_port_id = p_group_req->data.members.val[i].svc_port_id; |
| 1454 | /* group Add */ |
| 1455 | if (BAL_UTIL_OPER_GROUP_ADD == op_type || BAL_UTIL_OPER_GROUP_SET == op_type) |
| 1456 | { |
| 1457 | rc = maple_xgpon_gem_port_id_add(if_id, svc_port_id, MAC_UTIL_DUMMY_ONU_ID_FOR_MULTICAST_GEM, &configuration); |
| 1458 | } |
| 1459 | else if (BAL_UTIL_OPER_GROUP_REMOVE == op_type) |
| 1460 | { |
| 1461 | rc = rsc_mgr_gem_get_ref_count(if_id, svc_port_id, &ref_count); |
| 1462 | if(BCM_ERR_OK != rc) |
| 1463 | { |
| 1464 | BCM_LOG(ERROR, log_id_mac_util, |
| 1465 | "mac_util xgpon group REM get reference count on interface %d (gem %d) failed \n", if_id, svc_port_id); |
| 1466 | break; |
| 1467 | } |
| 1468 | /* if other group is referencing the same GEM (ref_count > 1), do not call Mac API to remove it. |
| 1469 | The core will ask Resource Manger to decrease the counter if everything is good */ |
| 1470 | if ( ref_count == 1) |
| 1471 | { |
| 1472 | rc = maple_xgpon_gem_port_id_remove(if_id, svc_port_id); |
| 1473 | } |
| 1474 | else if ( ref_count == 0) |
| 1475 | { |
| 1476 | BCM_LOG(WARNING, log_id_mac_util, |
| 1477 | "mac_util xgpon group operation REM on interface %d (gem %d) remove with 0 reference count \n", if_id, svc_port_id); |
| 1478 | } |
| 1479 | } |
| 1480 | |
| 1481 | if(BCM_ERR_OK != rc) |
| 1482 | { |
| 1483 | BCM_LOG(ERROR, log_id_mac_util, |
| 1484 | "mac_util xgpon group set of operation %d on interface %d (gem %d) failed \n", op_type, if_id, svc_port_id); |
| 1485 | break; |
| 1486 | } |
| 1487 | } |
| 1488 | |
| 1489 | return rc; |
| 1490 | } |
| 1491 | |
| 1492 | |
| 1493 | /*@}*/ |