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 acc_term_fsm.h |
| 34 | * @brief Code to support the BAL Access Terminal FSM |
| 35 | * |
| 36 | * @defgroup access_terminal Access Terminal |
| 37 | * @ingroup core |
| 38 | */ |
| 39 | |
| 40 | |
| 41 | #ifndef ACC_TERM_FSM_H |
| 42 | #define ACC_TERM_FSM_H |
| 43 | |
| 44 | /*@{*/ |
| 45 | |
| 46 | #include <bcm_topo.h> |
| 47 | #include <bal_api.h> |
| 48 | #include <sub_term_fsm.h> |
| 49 | #include <tm_sched_fsm.h> |
| 50 | |
| 51 | |
| 52 | /** An enumeration of the access-terminal FSM events. |
| 53 | */ |
| 54 | typedef enum |
| 55 | { |
| 56 | ACC_TERM_FSM_EVENT_TYPE_NONE = -1, |
| 57 | ACC_TERM_FSM_EVENT_TYPE_ADMIN_UP , |
| 58 | ACC_TERM_FSM_EVENT_TYPE_ADMIN_DN , |
| 59 | ACC_TERM_FSM_EVENT_TYPE_INT_ADMIN_UP , |
| 60 | ACC_TERM_FSM_EVENT_TYPE_INT_ADMIN_DN , |
| 61 | ACC_TERM_FSM_EVENT_TYPE_UTIL_MSG , |
| 62 | ACC_TERM_FSM_EVENT_TYPE_UTIL_AUTO_MSG , |
| 63 | ACC_TERM_FSM_EVENT_TYPE_TIMEOUT , |
| 64 | |
| 65 | |
| 66 | ACC_TERM_FSM_EVENT_TYPE__LAST, |
| 67 | ACC_TERM_FSM_EVENT_TYPE__NUM_OF |
| 68 | } acc_term_fsm_event_type; |
| 69 | |
| 70 | |
| 71 | /** An enumeration of the access-terminal FSM states. |
| 72 | */ |
| 73 | typedef enum |
| 74 | { |
| 75 | ACC_TERM_FSM_STATE_NONE = -1, |
| 76 | ACC_TERM_FSM_STATE_NULL , |
| 77 | ACC_TERM_FSM_STATE_ADDING , |
| 78 | ACC_TERM_FSM_STATE_ADDED , |
| 79 | ACC_TERM_FSM_STATE_REMOVING , |
| 80 | |
| 81 | ACC_TERM_FSM_STATE__LAST, |
| 82 | ACC_TERM_FSM_STATE__NUM_OF |
| 83 | } acc_term_fsm_state; |
| 84 | |
| 85 | /** |
| 86 | * A structure that defines the information associated with an |
| 87 | * access-terminal FSM event |
| 88 | */ |
| 89 | typedef struct acc_term_fsm_event |
| 90 | { |
| 91 | acc_term_fsm_event_type event_type; /**< An FSM event */ |
| 92 | void *msg; /**< A pointer to the message being processed by the FSM during an event */ |
| 93 | } acc_term_fsm_event; |
| 94 | |
| 95 | /** |
| 96 | * @brief A temporary set of definitions to support access-terminal interfaces. |
| 97 | * This should be replaced by a more generic mapping method. |
| 98 | * @note The max PON interface of 16 is a practical limit that access term will support for now. |
| 99 | */ |
| 100 | #define NUM_SUPPORTED_SUBSCRIBER_INTERFACES (16) |
| 101 | #define NUM_SUPPORTED_NNI_INTERFACES (BCM_TOPO_MAX_NNI_PORTS) |
| 102 | #define NUM_SUPPORTED_INTERFACES (NUM_SUPPORTED_SUBSCRIBER_INTERFACES + NUM_SUPPORTED_NNI_INTERFACES) |
| 103 | /** invalid interface index - used for any error in mapping port type/id to interface index */ |
| 104 | #define INVALID_INTERFACE_INDEX (NUM_SUPPORTED_INTERFACES) |
| 105 | |
| 106 | #define BAL_ACC_TERM_MAX_FLOWS_PER_PON (1024) |
| 107 | #define BAL_ACC_TERM_MAX_FLOWS (NUM_SUPPORTED_SUBSCRIBER_INTERFACES * BAL_ACC_TERM_MAX_FLOWS_PER_PON) |
| 108 | |
| 109 | typedef struct sub_term_id_entry |
| 110 | { |
| 111 | bcmbal_sub_id sub_term_id; |
| 112 | TAILQ_ENTRY(sub_term_id_entry) next; /**< TAILQ link */ |
| 113 | }sub_term_id_entry; |
| 114 | |
| 115 | /** |
| 116 | * Two interface objects associated with the access-terminal. |
| 117 | * One stores the API requests, and one records the current |
| 118 | * state of the object. |
| 119 | */ |
| 120 | typedef struct acc_term_interface |
| 121 | { |
| 122 | bcmbal_interface_cfg current_int_obj_info; /**< The current information for this interface (used for GET) */ |
| 123 | bcmbal_interface_cfg api_req_int_obj_info; /**< The last interface object info received from the Public API */ |
| 124 | uint16_t num_sub_terms_on_int; /**< The number of subscriber terminals on this interface */ |
| 125 | TAILQ_HEAD(sub_term_id_list_head, sub_term_id_entry) sub_term_id_list; |
| 126 | } acc_term_interface; |
| 127 | |
| 128 | /** |
| 129 | * The interface key of the instance being manipulated, and an array of interface objects associated |
| 130 | * with an access terminal instance. |
| 131 | */ |
| 132 | typedef struct acc_term_interface_info |
| 133 | { |
| 134 | acc_term_interface interface[NUM_SUPPORTED_INTERFACES]; /**< All interface instances */ |
| 135 | |
| 136 | }acc_term_interface_info; |
| 137 | |
| 138 | |
| 139 | /** |
| 140 | * An structure defining an access terminal instance and its associated interfaces |
| 141 | */ |
| 142 | typedef struct acc_term_inst |
| 143 | { |
| 144 | /**< The current information for this access-terminal (used for GET) */ |
| 145 | bcmbal_access_terminal_cfg current_acc_term_obj_info; |
| 146 | |
| 147 | /**< The last access-terminal object info received from the Public API */ |
| 148 | bcmbal_access_terminal_cfg api_req_acc_term_obj_info; |
| 149 | |
| 150 | acc_term_fsm_state fsm_state; /**< The access-terminal FSM state */ |
| 151 | acc_term_interface_info intf_info; /**< The access-terminal interfaces */ |
| 152 | bcmos_timer timer_info; /**< A structure used for the state machine timeout timer */ |
| 153 | |
| 154 | } acc_term_inst; |
| 155 | |
| 156 | |
| 157 | /*--- external function declarations ---*/ |
| 158 | extern bcmos_errno process_access_terminal_object(void *msg_payload); |
| 159 | |
| 160 | extern bcmos_errno process_access_terminal_util_msg(void *msg_payload); |
| 161 | |
| 162 | extern bcmos_errno process_interface_object(void *msg_payload); |
| 163 | |
| 164 | extern bcmos_errno process_interface_util_msg(void *msg_payload); |
| 165 | |
| 166 | extern bcmos_errno bcmbal_interface_sub_term_list_add(bcmbal_subscriber_terminal_key sub_term_key); |
| 167 | |
| 168 | extern bcmos_errno bcmbal_interface_sub_term_list_remove(bcmbal_subscriber_terminal_key sub_term_key); |
| 169 | |
| 170 | extern void access_terminal_fsm_init(void); |
| 171 | |
| 172 | extern bcmbal_status bcmbal_interface_status_get(bcmbal_interface_key key); |
| 173 | |
| 174 | extern bcmbal_status bcmbal_get_intf_oper_status_from_admin_state (bcmbal_state intf_admin_state); |
| 175 | |
| 176 | extern uint32_t bcmbal_port_type_and_id_to_interface_index(bcmbal_intf_type intf_type, |
| 177 | bcmbal_intf_id intf_id); |
| 178 | extern bcmbal_status acc_term_status_get(void); |
| 179 | |
| 180 | extern bcmos_errno bcmbal_interface_sub_term_list_entry_add(bcmbal_subscriber_terminal_key sub_term_key); |
| 181 | |
| 182 | extern bcmos_errno bcmbal_interface_sub_term_list_entry_remove(bcmbal_subscriber_terminal_key sub_term_key); |
| 183 | |
| 184 | extern bcmos_errno bcmbal_interface_tm_get(bcmbal_interface_key key, bcmbal_tm_sched_id *id); |
| 185 | |
| 186 | extern bcmos_errno interface_tm_sched_unset(bcmbal_interface_key intf_key, bcmbal_tm_sched_key sched_key); |
| 187 | |
| 188 | extern bcmos_errno bcmbal_tm_sched_interface_tm_auto_create(bcmbal_interface_cfg *p_interface_info); |
| 189 | |
| 190 | extern bcmos_errno bcmbal_tm_sched_set_interface_owner(bcmbal_interface_key interface_key, tm_sched_inst *p_tm_sched_inst); |
| 191 | |
| 192 | extern bcmos_errno bcmbal_tm_sched_set_sub_term_owner( bcmbal_tm_sched_key tm_sched_key, const bcmbal_subscriber_terminal_cfg *p_sub_term_cfg); |
| 193 | |
| 194 | |
| 195 | /*@}*/ |
| 196 | |
| 197 | #endif /*ACC_TERM_FSM_H */ |
| 198 | |
| 199 | |