blob: 3d7cf729bf7f938d99d3cdda21c0da4187fa80cf [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 sub_term_fsm.h
34 * @brief Code to support the BAL Subscriber Terminal FSM
35 *
36 * @defgroup sub_terminal Subscriber Terminal
37 * @ingroup core
38 */
39
40
41#ifndef SUB_TERM_FSM_H
42#define SUB_TERM_FSM_H
43
44/*@{*/
45
46#include <bal_api.h>
47
48/* The current implementation supports a global pool of
49 * ONU instances.
50 */
51#define NUM_SUPPORTED_SUB_TERMS (4096)
52
53typedef enum
54{
55 SUB_TERM_FSM_EVENT_TYPE_NONE = -1,
56 SUB_TERM_FSM_EVENT_TYPE_ADMIN_UP ,
57 SUB_TERM_FSM_EVENT_TYPE_ADMIN_DN ,
58 SUB_TERM_FSM_EVENT_TYPE_REMOVE ,
59 SUB_TERM_FSM_EVENT_TYPE_UTIL_MSG ,
60 SUB_TERM_FSM_EVENT_TYPE_UTIL_AUTO_MSG ,
61
62
63 SUB_TERM_FSM_EVENT_TYPE__LAST,
64 SUB_TERM_FSM_EVENT_TYPE__NUM_OF
65} sub_term_fsm_event_type;
66
67
68
69typedef enum
70{
71 SUB_TERM_FSM_STATE_NONE = -1,
72 SUB_TERM_FSM_STATE_NULL ,
73 SUB_TERM_FSM_STATE_CONFIGURING ,
74 SUB_TERM_FSM_STATE_CONFIGURED ,
75 SUB_TERM_FSM_STATE_REMOVING ,
76
77
78 SUB_TERM_FSM_STATE__LAST,
79 SUB_TERM_FSM_STATE__NUM_OF
80} sub_term_fsm_state;
81
82
83typedef enum
84{
85 SUB_TERM_FLAG_ANY = 1, /**< ONLY USED in the sub_term get argument */
86 SUB_TERM_FLAG_ACTIVE , /**< A sub_term is on the active list */
87 SUB_TERM_FLAG_FREE /**< A sub_term is on the free list */
88} sub_term_flag;
89
90
91typedef struct sub_term_fsm_event
92{
93 sub_term_fsm_event_type event_type; /**< The sub_term FSM event */
94 void *msg;
95} sub_term_fsm_event;
96
97
98typedef struct svc_port_id_entry
99{
100 bcmbal_service_port_id svc_port_id;
101 uint8_t ref_count; /**< A count of the number of re-uses of this svc_port_id on this subscriber terminal */
102 TAILQ_ENTRY(svc_port_id_entry) next ; /**< TAILQ link */
103}svc_port_id_entry;
104
105typedef struct agg_port_id_entry
106{
107 bcmbal_aggregation_port_id agg_port_id;
108 uint8_t ref_count; /**< A count of the number of re-uses of this agg_port_id on this subscriber terminal */
109 TAILQ_ENTRY(agg_port_id_entry) next ; /**< TAILQ link */
110}agg_port_id_entry;
111
112typedef struct sub_term_inst sub_term_inst;
113struct sub_term_inst
114{
115 bcmbal_subscriber_terminal_cfg current_sub_term_info; /**< The current information for this sub_term (used for GET) */
116 bcmbal_subscriber_terminal_cfg api_req_sub_term_info; /**< The last sub_term object info received from the Public API */
117 sub_term_fsm_state fsm_state; /**< The sub_term instance FSM state */
118 uint16_t num_svc_port_ids; /**< The number of bearer traffic GEMs on this subscriber terminal */
119 TAILQ_HEAD(svc_port_id_list_head, svc_port_id_entry) svc_port_id_list; /* A list of svc_port_ids on this subscriber terminal */
120 uint16_t num_agg_port_ids; /**< The number of alloc ids on this subscriber terminal */
121 TAILQ_HEAD(agg_port_id_list_head, agg_port_id_entry) agg_port_id_list; /* A list of svc_port_ids on this subscriber terminal */
122 TAILQ_ENTRY(sub_term_inst) sub_term_inst_next ; /**< TAILQ link for active list and free list management */
123};
124
125
126/*
127 * Sub_Term FSM data structures
128 */
129typedef struct sub_term_fsm_ctx
130{
131 /* Lists of free sub_term entries and active sub_term entries
132 */
133 TAILQ_HEAD(free_sub_term_list_head, sub_term_inst) free_sub_term_list;
134
135 TAILQ_HEAD(active_sub_term_list_head, sub_term_inst) active_sub_term_list;
136
137} sub_term_fsm_ctx;
138
139
140/*
141 * Function declarations
142 */
143extern bcmos_errno sub_term_fsm_init(void);
144
145extern bcmos_errno sub_term_fsm_finish(void);
146
147extern bcmos_errno process_subscriber_terminal_object(void *msg_payload);
148
149extern bcmos_errno process_subscriber_terminal_util_msg(void *msg_payload);
150
151extern sub_term_inst *sub_term_inst_get(bcmbal_subscriber_terminal_key *key,
152 sub_term_flag sub_term_flag);
153
154extern bcmos_errno sub_term_svc_port_id_get(bcmbal_sub_id sub_term_id,
155 uint16_t access_int_id,
156 bcmbal_service_port_id *p_svc_port_id);
157
158extern bcmos_errno bcmbal_sub_term_svc_port_id_list_entry_add(sub_term_inst *p_sub_term_inst,
159 bcmbal_service_port_id svc_port_id);
160
161extern bcmos_errno bcmbal_sub_term_svc_port_id_list_entry_remove(sub_term_inst *p_sub_term_inst,
162 bcmbal_service_port_id svc_port_id);
163
164bcmos_errno bcmbal_sub_term_agg_port_id_list_entry_add(sub_term_inst *p_sub_term_inst,
165 bcmbal_aggregation_port_id agg_port_id);
166
167bcmos_errno bcmbal_sub_term_agg_port_id_list_entry_remove(sub_term_inst *p_sub_term_inst,
168 bcmbal_aggregation_port_id agg_port_id);
169
170bcmos_errno bcmbal_sub_term_check_agg_port_in_use(sub_term_inst *p_sub_term_inst,
171 bcmbal_aggregation_port_id agg_port_id);
172
173bcmos_errno bcmbal_sub_term_check_svc_port_in_use(sub_term_inst *p_sub_term_inst,
174 bcmbal_service_port_id svc_port_id);
175
176
177
178/*@}*/
179
180#endif /*SUB_TERM_FSM_H */
181
182