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 group_fsm.h |
| 34 | * @brief Code to support the BAL Group FSM |
| 35 | * |
| 36 | */ |
| 37 | |
| 38 | #ifndef GROUP_FSM_H |
| 39 | #define GROUP_FSM_H |
| 40 | |
| 41 | /*@{*/ |
| 42 | |
| 43 | #include <bcmos_system.h> |
| 44 | #include <bal_api.h> |
| 45 | |
| 46 | /* set the total number of available group to 4k */ |
| 47 | #define GROUP_ALLOCATION_BLOCK_SIZE (4095) |
| 48 | |
| 49 | typedef enum |
| 50 | { |
| 51 | GROUP_FSM_EVENT_TYPE_NONE = -1, |
| 52 | GROUP_FSM_EVENT_TYPE_CREATE , |
| 53 | GROUP_FSM_EVENT_TYPE_DESTROY , |
| 54 | GROUP_FSM_EVENT_TYPE_ADD , |
| 55 | GROUP_FSM_EVENT_TYPE_REMOVE , |
| 56 | GROUP_FSM_EVENT_TYPE_SET , |
| 57 | GROUP_FSM_EVENT_TYPE_UTIL_MSG , |
| 58 | |
| 59 | GROUP_FSM_EVENT_TYPE__LAST, |
| 60 | GROUP_FSM_EVENT_TYPE__NUM_OF |
| 61 | } group_fsm_event_type; |
| 62 | |
| 63 | |
| 64 | |
| 65 | typedef enum |
| 66 | { |
| 67 | GROUP_FSM_STATE_NONE = -1, |
| 68 | GROUP_FSM_STATE_NULL , |
| 69 | GROUP_FSM_STATE_CONFIGURING , |
| 70 | GROUP_FSM_STATE_CONFIGURED , |
| 71 | GROUP_FSM_STATE_DELETING , |
| 72 | |
| 73 | GROUP_FSM_STATE__LAST, |
| 74 | GROUP_FSM_STATE__NUM_OF |
| 75 | } group_fsm_state; |
| 76 | |
| 77 | |
| 78 | typedef enum |
| 79 | { |
| 80 | GROUP_FLAG_ACTIVE = 1<<0, /**< A group is on the active list */ |
| 81 | GROUP_FLAG_FREE = 1<<1, /**< A group is on the free list */ |
| 82 | GROUP_FLAG_ANY = (GROUP_FLAG_ACTIVE | GROUP_FLAG_FREE), /**< A group is on either the active or free list */ |
| 83 | } group_flag; |
| 84 | |
| 85 | |
| 86 | typedef struct group_fsm_event_t |
| 87 | { |
| 88 | group_fsm_event_type event_type; /**< The group fsm events */ |
| 89 | void *msg; |
| 90 | |
| 91 | /* other necessary information */ |
| 92 | } group_fsm_event; |
| 93 | |
| 94 | |
| 95 | typedef struct group_inst group_inst; |
| 96 | struct group_inst |
| 97 | { |
| 98 | bcmbal_group_cfg current_group_info; /**< The current information for this group (used for GET) */ |
| 99 | bcmbal_group_cfg api_req_group_info; /**< The last group object info received from the Public API */ |
| 100 | group_fsm_state fsm_state; /**< The group FSM state */ |
| 101 | bcmos_timer timer_info; /**< A structure used for the state machine timeout timer */ |
| 102 | TAILQ_ENTRY(group_inst) group_inst_next ; /**< TAILQ link */ |
| 103 | }; |
| 104 | |
| 105 | |
| 106 | /* |
| 107 | * Group FSM data structures |
| 108 | */ |
| 109 | typedef struct group_fsm_ctx |
| 110 | { |
| 111 | /* Lists of free group entries and active group entries |
| 112 | */ |
| 113 | TAILQ_HEAD(free_group_list_head, group_inst) free_group_list; |
| 114 | |
| 115 | TAILQ_HEAD(active_group_list_head, group_inst) active_group_list; |
| 116 | |
| 117 | } group_fsm_ctx; |
| 118 | |
| 119 | |
| 120 | /* Function declarations */ |
| 121 | |
| 122 | extern bcmos_errno group_fsm_init(void); |
| 123 | extern bcmos_errno group_fsm_finish(void); |
| 124 | extern bcmos_errno process_group_util_msg(void *msg_payload); |
| 125 | extern bcmos_errno process_group_object(void *msg_payload); |
| 126 | extern bcmos_bool group_is_active(bcmbal_group_key *p_group_key); |
| 127 | extern bcmos_errno group_owner_set(bcmbal_group_key group_key, bcmbal_group_owner group_owner); |
| 128 | extern bcmos_errno group_owner_get(bcmbal_group_key group_key, bcmbal_group_owner *p_group_owner); |
| 129 | |
| 130 | /*@}*/ |
| 131 | |
| 132 | #endif /*GROUP_FSM_H */ |
| 133 | |