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_common_itu_pon.h |
| 34 | * |
| 35 | * @brief mac util interfaces definition used by Bal Core, for ITU PON: GPON, XG-PON1, XGS-PON |
| 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 | |
| 47 | /** |
| 48 | * @brief Maple SLA bandwidth config request is aligned to 8000 Bytes/sec |
| 49 | * |
| 50 | * @note similar macros are defined in bcm_common_gpon.h embedded code. |
| 51 | */ |
| 52 | #define MAPLE_BW_GRANULARITY_BYTES 8000 |
| 53 | #define MAPLE_BW_GRANULARITY_BYTES_10G 16000 |
| 54 | #define MAPLE_MIN_BYTES_PER_SEC_FOR_DEFAULT_ALLOC_ID 32000 |
| 55 | #define SLA_BW_NKBYTES_ALIGNED(_rate, _us_rate_factor) \ |
| 56 | (_us_rate_factor) == 8 ? \ |
| 57 | ((((_rate) + MAPLE_BW_GRANULARITY_BYTES_10G-1) / MAPLE_BW_GRANULARITY_BYTES_10G) * MAPLE_BW_GRANULARITY_BYTES_10G) : \ |
| 58 | ((((_rate) + MAPLE_BW_GRANULARITY_BYTES-1) / MAPLE_BW_GRANULARITY_BYTES) * MAPLE_BW_GRANULARITY_BYTES) |
| 59 | |
| 60 | /* The thumb-rule is GPON PON capacity (155520000 Bps) divided by the maximum number of ONUs (128), rounded by granularity constraint. */ |
| 61 | #define SLA_GUARANTEED_BW_DEFAULT_BYTES_PER_SEC 1208000 |
| 62 | /* Like the default guaranteed BW, but since we are going to configure best-effort class, additional BW must be bigger than guaranteed BW in at least 32000. */ |
| 63 | #define SLA_MAX_BW_DEFAULT_BYTES_PER_SEC (SLA_GUARANTEED_BW_DEFAULT_BYTES_PER_SEC + MAPLE_MIN_BYTES_PER_SEC_FOR_DEFAULT_ALLOC_ID) |
| 64 | #define KILOBITS_PER_SEC2BYTES_PER_SEC(x) ((uint64_t)(x) * 1000 / 8) |
| 65 | |
| 66 | |
| 67 | char *mac_util_indication_get_obj_type_str (bcmolt_obj_id obj_type, mac_util_ind_obj_and_handlers handlers[], size_t handlers_size); |
| 68 | bcmos_errno mac_util_handle_indication (bcmolt_devid device_id, bcmolt_msg *p_msg, mac_util_ind_obj_and_handlers handlers[], size_t handlers_size); |
| 69 | bcmos_bool mac_util_check_flow_is_double_tag_remove_o_tag (const bcmbal_flow_cfg *p_flow_req); |
| 70 | void mac_util_assign_agg_port_sla (bcmbal_tm_sched_cfg *p_tm_sched_req, bcmolt_pon_alloc_sla *p_agg_sla); |
| 71 | |
| 72 | bcmos_errno maple_mac_unicast_flow_add (bcmbal_flow_cfg *p_flow, uint16_t pbit, uint16_t per_flow_mode_vlan_id, bal_util_oper_flow op_type, flow_list_entry **pp_mac_util_flow_entry); |
| 73 | bcmos_errno maple_mac_unicast_flow_remove (bcmbal_flow_cfg *p_flow, bal_util_oper_flow op_type, flow_list_entry *p_mac_util_flow_entry); |
| 74 | bcmos_errno maple_mac_broadcast_flow_add (bcmbal_flow_cfg *p_flow, uint16_t per_flow_mode_vlan_id, bal_util_oper_flow op_type, |
| 75 | flow_list_entry **pp_mac_util_flow_entry); |
| 76 | bcmos_errno maple_mac_broadcast_flow_remove (bcmbal_flow_cfg *p_flow, uint16_t per_flow_mode_vlan_id, bal_util_oper_flow op_type, flow_list_entry *p_mac_util_flow_entry); |
| 77 | void mac_util_mark_flow_config_complete(flow_list_entry *p_flow_entry); |
| 78 | bcmos_errno maple_gpon_mac_check_gem_port_id(uint32_t if_id, uint32_t onu_id, uint16_t svc_port_id, |
| 79 | bcmos_bool *is_configured, bcmos_bool *is_activated); |
| 80 | bcmos_errno maple_xgpon_mac_check_gem_port_id(uint32_t if_id, uint32_t onu_id, uint16_t svc_port_id, |
| 81 | bcmos_bool *is_configured, bcmos_bool *is_activated); |
| 82 | bcmos_errno maple_gpon_gem_port_id_add(uint32_t if_id, uint16_t svc_port_id, uint32_t onu_id, bcmolt_gem_port_configuration *configuration); |
| 83 | 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); |
| 84 | bcmos_errno maple_gpon_gem_port_id_remove(uint32_t if_id, uint16_t svc_port_id); |
| 85 | bcmos_errno maple_xgpon_gem_port_id_remove(uint32_t if_id, uint16_t svc_port_id); |
| 86 | bcmos_errno maple_gpon_mac_get_alloc_id_config (uint32_t if_id, uint32_t onu_id, uint16_t agg_id, bcmolt_alloc_state *alloc_id_state); |
| 87 | |
| 88 | 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); |
| 89 | |
| 90 | |
| 91 | bcmos_errno maple_gpon_us_alloc_id_add(uint32_t if_id, uint32_t onu_id, uint16_t agg_id, bcmolt_pon_alloc_sla agg_sla); |
| 92 | 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); |
| 93 | bcmos_errno maple_gpon_us_alloc_id_remove(uint32_t if_id, uint16_t agg_id); |
| 94 | bcmos_errno maple_xgpon_us_alloc_id_remove(uint32_t if_id, uint16_t agg_id); |
| 95 | |
| 96 | bcmos_errno maple_mac_agg_port_add(uint32_t if_id, uint32_t onu_id, uint16_t agg_id, bcmolt_pon_alloc_sla sla); |
| 97 | bcmos_errno maple_mac_agg_port_remove(uint32_t if_id, uint16_t agg_id); |
| 98 | |
| 99 | |
| 100 | |
| 101 | /* functions to register for specific auto indications from maple */ |
| 102 | bcmos_errno _mac_util_register_for_auto_indications (struct bcmolt_rx_cfg *p_rx_cfg, |
| 103 | mac_util_ind_obj_and_handlers obj_types_and_handlers[], uint16_t num_obj_types, bcmolt_devid device_id); |
| 104 | bcmos_errno mac_util_register_for_device_auto_indications (struct bcmolt_rx_cfg *p_rx_cfg, bcmolt_devid device_id); |
| 105 | bcmos_errno mac_util_register_for_gpon_auto_indications (struct bcmolt_rx_cfg *p_rx_cfg, bcmolt_devid device_id); |
| 106 | bcmos_errno mac_util_register_for_xgpon_auto_indications (struct bcmolt_rx_cfg *p_rx_cfg, bcmolt_devid device_id); |
| 107 | |
| 108 | |
| 109 | /** @brief generic struct for object set/validate handlers based on mac protocols */ |
| 110 | typedef bcmos_errno (*mac_util_bal_group_validate_handler) (const bcmbal_group_cfg *p_group_req); |
| 111 | typedef bcmos_errno (*mac_util_bal_group_set_handler) (bcmbal_group_cfg *p_group_req, bal_util_oper_group op_type, group_inst *p_group_context); |
| 112 | typedef bcmos_errno (*mac_util_bal_flow_validate_handler) (const bcmbal_flow_cfg *p_flow_req); |
| 113 | typedef bcmos_errno (*mac_util_bal_flow_set_handler) (bcmbal_flow_cfg *p_flow_req, bal_util_oper_flow op_type, flow_inst *p_flow_core); |
| 114 | typedef bcmos_errno (*mac_util_bal_sub_term_validate_handler) (const bcmbal_subscriber_terminal_cfg *p_sub_term_req); |
| 115 | typedef bcmos_errno (*mac_util_bal_sub_term_set_handler) (sub_term_inst *p_sub_term_inst, bal_util_oper_sub_term op_type, bcmos_bool is_post_discovery); |
| 116 | typedef bcmos_errno (*mac_util_bal_if_validate_handler) (acc_term_inst *p_acc_term, bal_util_oper_if op_type); |
| 117 | typedef bcmos_errno (*mac_util_bal_if_set_handler) (acc_term_interface *p_interface_inst, bal_util_oper_if op_type); |
| 118 | typedef bcmos_errno (*mac_util_bal_acc_term_set_handler) (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id); |
| 119 | typedef bcmos_errno (*mac_util_bal_acc_term_post_indication_set_handler) (bcmolt_devid device_id); |
| 120 | |
| 121 | |
| 122 | /** |
| 123 | * Structure for handler routines for different pon modes and loopback mode |
| 124 | */ |
| 125 | typedef struct |
| 126 | { |
| 127 | mac_util_bal_if_validate_handler if_validate; |
| 128 | mac_util_bal_if_set_handler if_set; |
| 129 | |
| 130 | mac_util_bal_sub_term_validate_handler sub_term_validate; |
| 131 | mac_util_bal_sub_term_set_handler sub_term_set; |
| 132 | |
| 133 | mac_util_bal_flow_validate_handler flow_validate; |
| 134 | mac_util_bal_flow_set_handler flow_set; |
| 135 | |
| 136 | mac_util_bal_group_validate_handler group_validate; |
| 137 | mac_util_bal_group_set_handler group_set; |
| 138 | |
| 139 | uint32_t sla_us_rate_factor; |
| 140 | } mac_util_handlers_per_pon_mode_t; |
| 141 | |
| 142 | |
| 143 | typedef bcmos_errno (* maple_mac_check_gem_port_id)(uint32_t if_id, uint32_t onu_id, uint16_t svc_port_id, |
| 144 | bcmos_bool *is_configured, bcmos_bool *is_activated); |
| 145 | |
| 146 | typedef bcmos_errno (* maple_mac_check_agg_port_id)(uint32_t if_id, uint32_t onu_id, uint16_t agg_id, bcmolt_alloc_state *alloc_id_state); |
| 147 | |
| 148 | |
| 149 | |
| 150 | /** access terminal set */ |
| 151 | bcmos_errno mac_util_access_terminal_set_for_gpon_16 (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id); |
| 152 | bcmos_errno mac_util_access_terminal_set_for_gpon_8 (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id); |
| 153 | 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); |
| 154 | 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); |
| 155 | bcmos_errno mac_util_access_terminal_set_for_10G_itu_pon (bcmolt_device_cfg dev_cfg, bcmolt_devid device_id); |
| 156 | |
| 157 | bcmos_errno mac_util_access_terminal_post_indication_set_for_gpon(bcmolt_devid device_id); |
| 158 | bcmos_errno mac_util_access_terminal_post_indication_set_for_xgpon_xgs(bcmolt_devid device_id); |
| 159 | |
| 160 | bcmos_errno mac_util_access_terminal_set_for_loopback (acc_term_inst *p_acc_term, bal_util_oper_acc_term op_type, bcmolt_devid device_id); |
| 161 | |
| 162 | bcmos_errno mac_util_update_flows_w_sub_term_update(uint32_t pon_if, uint32_t sub_term_id, maple_mac_check_gem_port_id check_gem_port_id_func, maple_mac_check_agg_port_id check_agg_port_id_func); |
| 163 | bcmos_errno maple_mac_util_agg_port_set(bcmbal_tm_sched_cfg *p_tm_sched_req, bal_util_oper_agg_port op_type, tm_sched_inst *p_tm_sched_inst); |
| 164 | |
| 165 | |
| 166 | |
| 167 | /** |
| 168 | * Structure for handler routines for diffrent system modes and loopback mode |
| 169 | */ |
| 170 | typedef struct |
| 171 | { |
| 172 | mac_util_bal_acc_term_set_handler acc_term_set; |
| 173 | mac_util_bal_acc_term_post_indication_set_handler acc_term_post_indication_set; |
| 174 | } mac_util_bal_req_handlers_for_system_mode_t; |
| 175 | #define MAC_UTIL_PMDB(pon) mac_util_bal_req_handlers_for_pon_mode[bcm_topo_pon_get_pon_mode((pon))] |
| 176 | |
| 177 | typedef struct |
| 178 | { |
| 179 | bcmolt_iwf_mode iwf_mode; |
| 180 | } mac_util_topo_pon_context; |
| 181 | |
| 182 | |
| 183 | |
| 184 | typedef struct |
| 185 | { |
| 186 | bcmolt_system_mode system_mode; |
| 187 | bcmos_bool is_connected; |
| 188 | } mac_util_device_context; |
| 189 | |
| 190 | typedef struct |
| 191 | { |
| 192 | mac_util_device_context devices[BCM_TOPO_MAX_NUM_OF_DEVS]; |
| 193 | bcmos_bool fail_reported; /*more that one device may fail to connect, we would like to send the fail event to core only once*/ |
| 194 | } mac_util_acc_term_connectivity; |
| 195 | |
| 196 | mac_util_acc_term_connectivity acc_term_connectivity; |
| 197 | |
| 198 | extern mac_util_handlers_per_pon_mode_t mac_util_bal_req_handlers_for_pon_mode[]; |
| 199 | |
| 200 | /*@}*/ |