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 flow_fsm.h |
| 34 | * @brief Code to support the BAL Flow FSM |
| 35 | * |
| 36 | * @defgroup flow Flow |
| 37 | * @ingroup core |
| 38 | */ |
| 39 | |
| 40 | #ifndef FLOW_FSM_H |
| 41 | #define FLOW_FSM_H |
| 42 | |
| 43 | /*@{*/ |
| 44 | |
| 45 | #include <bcmos_system.h> |
| 46 | #include <bal_api.h> |
| 47 | |
| 48 | #define FLOW_ALLOCATION_BLOCK_SIZE (16384) |
| 49 | |
| 50 | #define CORE_FSM_FLOW_TYPE_GET_STR(_fsm_flow_type) (BCMBAL_FLOW_TYPE_MULTICAST == (_fsm_flow_type) ? "Multicast":\ |
| 51 | BCMBAL_FLOW_TYPE_BROADCAST == (_fsm_flow_type) ? "Broadcast":\ |
| 52 | BCMBAL_FLOW_TYPE_DOWNSTREAM == (_fsm_flow_type) ? "Downstream":\ |
| 53 | BCMBAL_FLOW_TYPE_UPSTREAM == (_fsm_flow_type) ? "Upstream":"Invalid") |
| 54 | |
| 55 | |
| 56 | typedef enum |
| 57 | { |
| 58 | FLOW_FSM_EVENT_TYPE_NONE = -1, |
| 59 | FLOW_FSM_EVENT_TYPE_ADMIN_UP , |
| 60 | FLOW_FSM_EVENT_TYPE_ADMIN_DN , |
| 61 | FLOW_FSM_EVENT_TYPE_REMOVE , |
| 62 | FLOW_FSM_EVENT_TYPE_UTIL_MSG , |
| 63 | FLOW_FSM_EVENT_TYPE_UTIL_AUTO_MSG , |
| 64 | |
| 65 | |
| 66 | FLOW_FSM_EVENT_TYPE__LAST, |
| 67 | FLOW_FSM_EVENT_TYPE__NUM_OF |
| 68 | } flow_fsm_event_type; |
| 69 | |
| 70 | |
| 71 | |
| 72 | typedef enum |
| 73 | { |
| 74 | FLOW_FSM_STATE_NONE = -1, |
| 75 | FLOW_FSM_STATE_NULL , |
| 76 | FLOW_FSM_STATE_CONFIGURING , |
| 77 | FLOW_FSM_STATE_CONFIGURED , |
| 78 | FLOW_FSM_STATE_REMOVING , |
| 79 | |
| 80 | |
| 81 | FLOW_FSM_STATE__LAST, |
| 82 | FLOW_FSM_STATE__NUM_OF |
| 83 | } flow_fsm_state; |
| 84 | |
| 85 | |
| 86 | typedef enum |
| 87 | { |
| 88 | FLOW_FLAG_ACTIVE = 1<<0, /**< A flow is on the active list */ |
| 89 | FLOW_FLAG_FREE = 1<<1, /**< A flow is on the free list */ |
| 90 | FLOW_FLAG_ANY = (FLOW_FLAG_ACTIVE | FLOW_FLAG_FREE), /**< A flow is on either the active or free list */ |
| 91 | FLOW_FLAG_IGNORE_DIR = 1<<2 /**< Ignore direction during operation */ |
| 92 | } flow_flag; |
| 93 | |
| 94 | |
| 95 | typedef struct flow_fsm_event_t |
| 96 | { |
| 97 | flow_fsm_event_type event_type; /**< The flow fsm events */ |
| 98 | void *msg; |
| 99 | |
| 100 | /* other necessary information */ |
| 101 | } flow_fsm_event; |
| 102 | |
| 103 | |
| 104 | /* Flow state in MAC plugin */ |
| 105 | typedef enum |
| 106 | { |
| 107 | FLOW_MAC_STATE_NONE = 0x00, /**< Neither svc_id nor agg_id configured */ |
| 108 | FLOW_MAC_STATE_SVC = 1<<0, /**< SVC is configured */ |
| 109 | FLOW_MAC_STATE_AGG = 1<<1, /**< AGG is configured */ |
| 110 | FLOW_MAC_STATE_READY = (FLOW_MAC_STATE_SVC | FLOW_MAC_STATE_AGG) |
| 111 | } flow_mac_state; |
| 112 | |
| 113 | typedef struct flow_inst flow_inst; |
| 114 | struct flow_inst |
| 115 | { |
| 116 | bcmbal_flow_cfg current_flow_info; /**< The current information for this flow (used for GET) */ |
| 117 | bcmbal_flow_cfg api_req_flow_info; /**< The last flow object info received from the Public API */ |
| 118 | flow_fsm_state fsm_state; /**< The Flow FSM state */ |
| 119 | flow_mac_state mac_state; /**< Flow state from MAC point of view */ |
| 120 | struct flow_inst *p_peer_flow_inst; /**< Pointer to the linked flow in the opposite direction (if any) */ |
| 121 | struct sub_term_inst *p_sub_term_inst; /**< Pointer to subscriber terminal instance associated with this flow */ |
| 122 | bcmos_timer timer_info; /**< A structure used for the state machine timeout timer */ |
| 123 | TAILQ_ENTRY(flow_inst) flow_inst_next ; /**< TAILQ link */ |
| 124 | TAILQ_ENTRY(flow_inst) rsc_mgr_list_next ; /**< TAILQ link used for storing in Resource mgr list */ |
| 125 | }; |
| 126 | |
| 127 | |
| 128 | /* |
| 129 | * Flow FSM data structures |
| 130 | */ |
| 131 | typedef struct flow_fsm_ctx |
| 132 | { |
| 133 | /* Lists of free flow entries and active flow entries |
| 134 | */ |
| 135 | TAILQ_HEAD(free_flow_list_head, flow_inst) free_flow_list; |
| 136 | |
| 137 | TAILQ_HEAD(active_flow_list_head, flow_inst) active_flow_list; |
| 138 | |
| 139 | } flow_fsm_ctx; |
| 140 | |
| 141 | |
| 142 | /* |
| 143 | * Function declarations |
| 144 | */ |
| 145 | extern bcmos_errno flow_fsm_init(void); |
| 146 | extern bcmos_errno flow_fsm_finish(void); |
| 147 | |
| 148 | extern bcmos_errno process_flow_object(void *msg_payload); |
| 149 | |
| 150 | extern bcmos_errno process_flow_util_msg(void *msg_payload); |
| 151 | |
| 152 | extern flow_inst *flow_get_by_svc_id(uint16_t access_if_id, |
| 153 | bcmbal_flow_type type, |
| 154 | bcmbal_service_port_id svc_port_id); |
| 155 | |
| 156 | extern flow_inst *flow_get_by_agg_id(uint16_t access_if_id, |
| 157 | bcmbal_aggregation_port_id agg_port_id); |
| 158 | |
| 159 | extern bcmos_errno svc_port_id_for_sub_term_ds_flow_get(uint16_t access_if_id, |
| 160 | uint16_t sub_term_id, |
| 161 | uint16_t sub_term_uni, |
| 162 | uint16_t *svc_port_id); |
| 163 | |
| 164 | extern bcmbal_flow_cfg *flow_get_current_info_by_key(bcmbal_flow_key key); |
| 165 | |
| 166 | |
| 167 | /*@}*/ |
| 168 | |
| 169 | #endif /*FLOW_FSM_H */ |
| 170 | |