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 tm_sched_fsm.h |
| 34 | * @brief Code to support the BAL TM Sched FSM |
| 35 | * |
| 36 | */ |
| 37 | |
| 38 | #ifndef TM_SCHED_FSM_H |
| 39 | #define TM_SCHED_FSM_H |
| 40 | |
| 41 | /*@{*/ |
| 42 | |
| 43 | #include <bcmos_system.h> |
| 44 | #include <bal_api.h> |
| 45 | #include <tm_queue_fsm.h> |
| 46 | |
| 47 | /* set the total pool size of available tm sched instances to 4k */ |
| 48 | #define TM_SCHED_ALLOCATION_BLOCK_SIZE (4096) |
| 49 | |
| 50 | typedef enum |
| 51 | { |
| 52 | TM_SCHED_FSM_EVENT_TYPE_NONE = -1, |
| 53 | TM_SCHED_FSM_EVENT_TYPE_CREATE , |
| 54 | TM_SCHED_FSM_EVENT_TYPE_DESTROY , |
| 55 | TM_SCHED_FSM_EVENT_TYPE_ASSIGN , |
| 56 | TM_SCHED_FSM_EVENT_TYPE_UTIL_MSG , |
| 57 | |
| 58 | TM_SCHED_FSM_EVENT_TYPE__LAST, |
| 59 | TM_SCHED_FSM_EVENT_TYPE__NUM_OF |
| 60 | } tm_sched_fsm_event_type; |
| 61 | |
| 62 | |
| 63 | |
| 64 | typedef enum |
| 65 | { |
| 66 | TM_SCHED_FSM_STATE_NONE = -1, |
| 67 | TM_SCHED_FSM_STATE_NULL , |
| 68 | TM_SCHED_FSM_STATE_INACTIVE , |
| 69 | TM_SCHED_FSM_STATE_ASSIGNED , |
| 70 | TM_SCHED_FSM_STATE_ACTIVE , |
| 71 | TM_SCHED_FSM_STATE_DELETING , |
| 72 | |
| 73 | TM_SCHED_FSM_STATE__LAST, |
| 74 | TM_SCHED_FSM_STATE__NUM_OF |
| 75 | } tm_sched_fsm_state; |
| 76 | |
| 77 | |
| 78 | typedef enum |
| 79 | { |
| 80 | TM_SCHED_FLAG_ACTIVE = 1<<0, /**< A tm_sched is on the active list */ |
| 81 | TM_SCHED_FLAG_FREE = 1<<1, /**< A tm_sched is on the free list */ |
| 82 | TM_SCHED_FLAG_ANY = (TM_SCHED_FLAG_ACTIVE | TM_SCHED_FLAG_FREE), /**< A tm_sched is on either the active or free list */ |
| 83 | } tm_sched_flag; |
| 84 | |
| 85 | |
| 86 | typedef struct tm_sched_fsm_event_t |
| 87 | { |
| 88 | tm_sched_fsm_event_type event_type; /**< The tm_sched fsm events */ |
| 89 | void *msg; |
| 90 | |
| 91 | /* other necessary information */ |
| 92 | } tm_sched_fsm_event; |
| 93 | |
| 94 | typedef struct queue_entry |
| 95 | { |
| 96 | bcmbal_tm_queue_id queue_id; |
| 97 | TAILQ_ENTRY(queue_entry) next; /**< TAILQ link */ |
| 98 | }queue_entry; |
| 99 | |
| 100 | typedef struct sub_sched_entry |
| 101 | { |
| 102 | bcmbal_tm_sched_id sched_id; |
| 103 | TAILQ_ENTRY(sub_sched_entry) next; /**< TAILQ link */ |
| 104 | }sub_sched_entry; |
| 105 | |
| 106 | typedef struct tm_sched_inst tm_sched_inst; |
| 107 | struct tm_sched_inst |
| 108 | { |
| 109 | bcmbal_tm_sched_cfg current_tm_sched_info; /**< The current information for this tm_sched (used for GET) */ |
| 110 | bcmbal_tm_sched_cfg req_tm_sched_info; /**< The last tm_sched object info received from the Public API */ |
| 111 | uint16_t num_queues_on_node; /**< The number of queues attached to this node */ |
| 112 | TAILQ_HEAD(queues_list_head, queue_entry) queues_list; |
| 113 | uint16_t num_sub_scheds_on_node; /**< The number of sub schedulers for this tm sched */ |
| 114 | TAILQ_HEAD(sub_scheds_list_head, sub_sched_entry) sub_scheds_list; |
| 115 | tm_sched_fsm_state fsm_state; /**< The tm_sched FSM state */ |
| 116 | TAILQ_ENTRY(tm_sched_inst) tm_sched_inst_next; /**< TAILQ link */ |
| 117 | }; |
| 118 | |
| 119 | |
| 120 | /* |
| 121 | * Group FSM data structures |
| 122 | */ |
| 123 | typedef struct tm_sched_fsm_ctx |
| 124 | { |
| 125 | /* Lists of free tm_sched entries and active tm_sched entries |
| 126 | */ |
| 127 | TAILQ_HEAD(free_tm_sched_list_head, tm_sched_inst) free_tm_sched_list; |
| 128 | |
| 129 | TAILQ_HEAD(active_tm_sched_list_head, tm_sched_inst) active_tm_sched_list; |
| 130 | |
| 131 | } tm_sched_fsm_ctx; |
| 132 | |
| 133 | |
| 134 | /* Function declarations */ |
| 135 | |
| 136 | extern bcmos_errno tm_sched_fsm_init(void); |
| 137 | extern bcmos_errno tm_sched_fsm_finish(void); |
| 138 | extern bcmos_errno process_tm_sched_util_msg(void *msg_payload); |
| 139 | extern bcmos_errno process_tm_sched_object(void *msg_payload); |
| 140 | |
| 141 | tm_sched_inst *tm_sched_inst_get(bcmbal_tm_sched_key key, tm_sched_flag search_flag); |
| 142 | bcmos_errno bcmbal_tm_sched_auto_create(bcmbal_tm_sched_cfg cfg, tm_sched_inst **p_tm_sched_inst); |
| 143 | bcmos_errno bcmbal_tm_sched_set_owner(tm_sched_inst *p_tm_sched_inst); |
| 144 | bcmos_errno bcmbal_tm_sched_unset_owner(tm_sched_inst *p_tm_sched_inst); |
| 145 | bcmos_errno bcmbal_tm_sched_set_queue(tm_queue_inst *p_tm_queue_inst); |
| 146 | bcmos_errno bcmbal_tm_sched_remove_queue(tm_queue_inst *p_tm_queue_inst); |
| 147 | tm_sched_inst * tm_sched_find_agg_port_node(uint8_t intf_id, bcmbal_aggregation_port_id agg_port_id); |
| 148 | bcmos_errno bcmbal_tm_sched_fsm_active_destroy(tm_sched_inst *p_tm_sched_inst); |
| 149 | |
| 150 | |
| 151 | |
| 152 | #define TM_SCHED_DIR_TO_STR(dir) ((dir) == BCMBAL_TM_SCHED_DIR_DS ? "ds" : "us") |
| 153 | /*@}*/ |
| 154 | |
| 155 | #endif /*TM_SCHED_FSM_H */ |
| 156 | |