blob: 1240cf1f37afb26e113b7d0ae313e32cbde6f0b2 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/******************************************************************************
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_queue_fsm.h
34 * @brief Code to support the BAL tm_queue FSM
35 *
36 */
37
38#ifndef TM_QUEUE_FSM_H
39#define TM_QUEUE_FSM_H
40
41/*@{*/
42
43#include <bcmos_system.h>
44#include <bal_api.h>
45
46/* set the total pool size of available tm queue to 4k */
47#define TM_QUEUE_ALLOCATION_BLOCK_SIZE (4096)
48
49typedef enum
50{
51 TM_QUEUE_FSM_EVENT_TYPE_NONE = -1,
52 TM_QUEUE_FSM_EVENT_TYPE_CREATE ,
53 TM_QUEUE_FSM_EVENT_TYPE_DESTROY ,
54 TM_QUEUE_FSM_EVENT_TYPE_UTIL_MSG ,
55
56 TM_QUEUE_FSM_EVENT_TYPE__LAST,
57 TM_QUEUE_FSM_EVENT_TYPE__NUM_OF
58} tm_queue_fsm_event_type;
59
60
61
62typedef enum
63{
64 TM_QUEUE_FSM_STATE_NONE = -1,
65 TM_QUEUE_FSM_STATE_NULL ,
66 TM_QUEUE_FSM_STATE_INACTIVE ,
67 TM_QUEUE_FSM_STATE_ACTIVE ,
68 TM_QUEUE_FSM_STATE_IN_USE ,
69 TM_QUEUE_FSM_STATE_DELETING ,
70
71 TM_QUEUE_FSM_STATE__LAST,
72 TM_QUEUE_FSM_STATE__NUM_OF
73} tm_queue_fsm_state;
74
75
76typedef enum
77{
78 TM_QUEUE_FLAG_ACTIVE = 1<<0, /**< A tm_queue is on the active list */
79 TM_QUEUE_FLAG_FREE = 1<<1, /**< A tm_queue is on the free list */
80 TM_QUEUE_FLAG_ANY = (TM_QUEUE_FLAG_ACTIVE | TM_QUEUE_FLAG_FREE), /**< A tm_queue is on either the active or free list */
81} tm_queue_flag;
82
83
84typedef struct tm_queue_fsm_event_t
85{
86 tm_queue_fsm_event_type event_type; /**< The tm_queue fsm events */
87 void *msg;
88
89 /* other necessary information */
90} tm_queue_fsm_event;
91
92
93typedef struct tm_queue_inst tm_queue_inst;
94struct tm_queue_inst
95{
96 bcmbal_tm_queue_cfg current_tm_queue_info; /**< The current information for this tm queue (used for GET) */
97 bcmbal_tm_queue_cfg api_req_tm_queue_info; /**< The tm queue object info received from the Public API */
98 tm_queue_fsm_state fsm_state; /**< The tm queue FSM state */
99
100 TAILQ_ENTRY(tm_queue_inst) tm_queue_inst_next; /**< TAILQ link */
101};
102
103
104/*
105 * tm_queue FSM data structures
106 */
107typedef struct tm_queue_fsm_ctx
108{
109 /* Lists of free tm_queue entries and active tm_queue entries
110 */
111 TAILQ_HEAD(free_tm_queue_list_head, tm_queue_inst) free_tm_queue_list;
112
113 TAILQ_HEAD(active_tm_queue_list_head, tm_queue_inst) active_tm_queue_list;
114
115} tm_queue_fsm_ctx;
116
117
118/* Function declarations */
119
120extern bcmos_errno tm_queue_fsm_init(void);
121extern bcmos_errno tm_queue_fsm_finish(void);
122extern bcmos_errno process_tm_queue_object(void *msg_payload);
123
124extern tm_queue_inst *tm_queue_inst_get(bcmbal_tm_queue_key key, tm_queue_flag search_flag);
125extern bcmos_errno bcmbal_tm_queue_auto_create(bcmbal_tm_queue_cfg tm_queue_default_cfg);
126extern bcmos_errno bcmbal_tm_queue_set_owner(bcmbal_tm_queue_key key);
127extern bcmos_errno bcmbal_tm_queue_unset_owner(bcmbal_tm_queue_key key);
128
129extern bcmos_errno bcmbal_tm_queue_activate(tm_queue_inst *p_tm_queue_inst);
130extern bcmos_errno bcmbal_tm_queue_deactivate(tm_queue_inst *p_tm_queue_inst);
131extern bcmos_errno bcmbal_tm_queue_use_set(tm_queue_inst *p_tm_queue_inst, bcmos_bool is_in_use);
132extern bcmos_errno bcmbal_tm_queue_destroy(tm_queue_inst *p_tm_queue_inst, bcmos_bool remove_from_node);
133
134
135
136/*@}*/
137
138#endif /*TM_QUEUE_FSM_H */
139