comparison src/g23m-gprs/sm/sm.h @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*----------------------------------------------------------------------------
2 | Project : 3G PS
3 | Module : SM
4 +-----------------------------------------------------------------------------
5 | Copyright 2003 Texas Instruments.
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments .
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments.
15 +-----------------------------------------------------------------------------
16 | Purpose: Global definitions for the Session Management (SM) Entity.
17 | For design details, see:
18 | 8010.908 SM Detailed Specification
19 +---------------------------------------------------------------------------*/
20
21 /*==== DECLARATION CONTROL =================================================*/
22
23 #ifndef _SM_H
24 #define _SM_H
25
26 //TISH modified for MSIM
27 // #ifdef WIN32
28 // #define DEBUG
29 // #endif
30
31 /*#ifdef FF_EGPRS
32 #ifndef SM_EDGE
33 #define SM_EDGE
34 #endif
35 #endif */ /*FF_EGPRS*/
36
37 /*#ifdef SM_EDGE */
38 #define DEBUG_VERBOSE
39 /*#endif */ /*#ifdef SM_EDGE*/
40 /*==== INCLUDES =============================================================*/
41
42 #include <string.h>
43 #include <typedefs.h>
44 #include <vsi.h>
45 #include <gsm.h>
46 #include <gprs.h>
47 #include <prim.h>
48
49 /*#ifndef SM_EDGE
50 #include <trace.h>
51 #endif */
52
53 #ifdef DEBUG
54 #include "sm_debug.h"
55 #endif
56
57 struct T_SM_CONTEXT_DATA;
58
59 #include "sm_context_control.h"
60 #include "sm_context_deactivate_control.h"
61 #include "sm_network_control.h"
62 #include "sm_user_plane_control.h"
63 #include "sm_mm_output_handler.h"
64
65 /*==== CONSTS ===============================================================*/
66
67 /* CCD constant: Bit-offset from which to place coded data in buffer. */
68 #define ENCODE_OFFSET 16
69
70 /* Session Management Protocol Disciminator; Global (PS-wide) define? */
71 #define PD_SM 0x0a
72
73 /* Transaction Indentifier-related definitions */
74 #define SM_TI_MASK 0x7f
75 #define SM_TI_FLAG 0x80
76 #define SM_TI_NON_EXT_MASK 0x07
77 #define SM_TI_EXTEND_VALUE 0x07
78 #define SM_MAX_NON_EXT_TI 6
79 #define SM_MAX_EXT_TI 127
80 #define SM_TI_NONE 0xff
81 #define SM_HIGH_VALUE 255
82
83 /* Often-used constant: max NSAPI index after NSAPI 5 offset is subtracted */
84 #define SM_MAX_NSAPI_OFFSET ((int)NAS_SIZE_NSAPI - (int)NAS_NSAPI_5)
85
86 /* Frame parameter: Maximum timers used = number of concurrently active NSAPIs*/
87 #define SM_TIMER_MAX SM_MAX_NSAPI_OFFSET
88
89 enum SM_CONTEXT_FLAGS {
90 SM_CONTEXT_FLAG_COMP_PARAMS = 0x01,
91 SM_CONTEXT_FLAG_STARTED_DURING_SUSPEND = 0x02,
92 SM_CONTEXT_FLAG_SECONDARY_CONTEXT = 0x04,
93 SM_CONTEXT_FLAG_PENDING_DEALLOCATION = 0x08,
94 SM_CONTEXT_FLAG_PENDING_REACTIVATION = 0x10,
95 SM_CONTEXT_FLAG_PFI_PRESENT = 0x20
96 };
97
98 typedef enum {
99 SM_UPDATE_QOS = 0x01,
100 SM_UPDATE_QOS_DOWNGRADE = 0x02,
101 SM_UPDATE_ADDRESS = 0x04,
102 SM_UPDATE_COMP_PARAMS = 0x08,
103 SM_UPDATE_SAPI_RADIO_PRIO_PFI = 0x10
104 } T_SM_UPDATE_FLAGS;
105 /*==== TYPES ================================================================*/
106
107 typedef struct {
108 U8 c_pco_value;
109 U8 pco_value[1];
110 } T_SM_pco;
111
112 typedef struct {
113 U8 tft_precence_mask;
114 U8 c_tft_pf;
115 /*@only@*/ /*@null@*/
116 T_NAS_tft_pf *ptr_tft_pf;
117 } T_SM_tft;
118
119 typedef struct {
120 T_PS_ctrl_qos ctrl_qos;
121 T_PS_qos qos;
122 } T_SM_qos;
123
124 /*@abstract@*/ struct T_SM_CONTEXT_DATA {
125 U8 ti;
126 U8 nsapi;
127 U8 linked_ti;
128
129 U8 active_timer; /* T3380, T3381, or T3390 */
130 U8 timeouts;
131
132 U8 sapi; /* Managed by Network Control */
133 U8 radio_prio; /* Managed by Network Control */
134 U8 pdp_type; /* Managed by Network Control */
135 U8 pfi; /* Managed by Network Control */
136 U8 flags;
137
138 U8 qos_rank;
139
140 T_NAS_comp_params comp_params;
141
142 T_CAUSE_ps_cause aci_cause;
143 T_CAUSE_ps_cause nw_cause;
144
145 T_SM_CONTEXT_CONTROL_STATE context_control_state;
146 T_SM_CONTEXT_DEACTIVATE_CONTROL_STATE context_deactivate_control_state;
147 T_SM_NETWORK_CONTROL_STATE network_control_state;
148 T_SM_USER_PLANE_CONTROL_STATE user_plane_control_state;
149
150 /* Fields below allocated, managed, and deallocated by Network Control */
151 T_SM_qos minimum_qos;
152 T_SM_qos requested_qos;
153 T_SM_qos accepted_qos;
154
155 T_NAS_ip requested_address;
156 T_NAS_ip negotiated_address;
157
158 /*@null@*/ /*@only@*/ /*@reldef@*/
159 T_SMREG_apn *apn;
160 /*@null@*/ /*@only@*/ /*@reldef@*/
161 T_SM_pco *requested_pco;
162 /*@null@*/ /*@only@*/ /*@reldef@*/
163 T_SM_pco *negotiated_pco;
164 T_SM_tft requested_tft;
165 T_SM_tft active_tft;
166
167 /*@null@*/ /*@only@*/
168 T_sdu *coded_msg;
169 };
170
171 typedef struct {
172 T_PS_rat sm_current_rat;
173 T_PS_sgsn_rel sm_current_nw_release;
174 BOOL sm_suspended;
175 U16 sm_suspend_cause;
176 /*sm_suspend_cause stores the cause of SM suspension.
177 the value has meaning only when sm_suspended=true
178 at other places the value must be set to CAUSE_MM_SUCCESS*/
179 BOOL sm_attached;
180 U16 sm_context_activation_status;
181 U16 sm_nsapis_requested_deactivated;
182 U16 sm_nsapis_being_deactivated;
183 /*@only@*/ /*@reldef@*/
184 struct T_SM_CONTEXT_DATA *sm_context_array[SM_MAX_NSAPI_OFFSET];
185 /*@only@*/ /*@reldef@*/
186 struct T_SM_CONTEXT_DATA *sm_pending_mt_array[SM_MAX_NSAPI_OFFSET];
187 } T_SM_DATA;
188
189 #ifdef DEBUG
190 #define M_TRANSITION(_EVENT, _FUNC) {_EVENT, _FUNC}
191 #else
192 #define M_TRANSITION(_EVENT, _FUNC) {_FUNC}
193 #endif /* DEBUG */
194
195 /*==== EXPORTS ==============================================================*/
196
197 extern T_SM_DATA sm_data;
198
199 #define hCommACI sm_hCommACI /* Communication handle to ACI */
200 #define hCommMM sm_hCommMM /* Communication handle to MM */
201 #define hCommUPM sm_hCommUPM /* Communication handle to UPM */
202
203 /* Communication handles */
204 extern T_HANDLE hCommACI;
205 extern T_HANDLE hCommMM;
206 extern T_HANDLE hCommUPM;
207 extern T_HANDLE sm_handle;
208
209 #define VSI_CALLER sm_handle,
210 #define VSI_CALLER_SINGLE sm_handle
211
212 /* Uniquify pei_create() */
213 #define pei_create sm_pei_create
214 short sm_pei_create (T_PEI_INFO **info);
215
216 /*
217 * If all entities are linked into one module this definitions
218 * prefixes the global data with the enity name
219 */
220 #define _decodedMsg _sm_decodedMsg
221
222 /* CCD coding/decoding buffer */
223 extern U8 _decodedMsg [MAX_MSTRUCT_LEN_SM];
224
225 #include "sm_memory_handler.h"
226
227 /* Convenience functions relating to NSAPI handling */
228 U16 sm_nsapi2nsapi_set(int /*@alt U8@*/ nsapi) /*@*/;
229 U16 sm_add_nsapi_to_nsapi_set(int /*@alt U8@*/ nsapi, U16 nsapi_set) /*@*/;
230 U16 sm_remove_nsapi_from_nsapi_set(int /*@alt U8@*/ nsapi, U16 nsapi_set) /*@*/;
231 BOOL sm_is_nsapi_in_nsapi_set(int /*@alt U8,U16@*/ nsapi, U16 nsapi_set) /*@*/;
232
233 U16 /*@alt int@*/sm_nsapi_to_index(U16 /*@alt U8,int@*/nsapi) /*@*/;
234 U16 /*@alt int@*/sm_index_to_nsapi(U16 /*@alt U8,int@*/index) /*@*/;
235
236 /* Get/set current RAT and core network release */
237 T_PS_rat
238 /*@alt U8@*/ sm_get_current_rat(void);
239 void sm_set_current_rat(T_PS_rat rat);
240
241 T_PS_sgsn_rel
242 /*@alt U8@*/ sm_get_current_nw_release(void);
243 void sm_set_current_nw_release(T_PS_sgsn_rel sgsn_rel);
244
245 /* Query functions for global attached/suspended state */
246 BOOL sm_is_suspended(void);
247 BOOL sm_is_attached(void);
248
249 /* Set and query functions for context flags */
250 BOOL sm_is_secondary(struct T_SM_CONTEXT_DATA *context);
251 void sm_set_secondary(struct T_SM_CONTEXT_DATA *);
252 U16 sm_get_pdp_context_status(void);
253 void sm_set_started_during_suspend(struct T_SM_CONTEXT_DATA *context);
254 void sm_clear_started_during_suspend(struct T_SM_CONTEXT_DATA *context);
255 BOOL sm_is_started_during_suspend(struct T_SM_CONTEXT_DATA *context) /*@*/;
256 void sm_mark_context_for_deallocation(struct T_SM_CONTEXT_DATA *context);
257 BOOL sm_is_context_pending_deallocation(struct T_SM_CONTEXT_DATA *context);
258 void sm_set_context_pending_reactivation(struct T_SM_CONTEXT_DATA *, BOOL);
259 BOOL sm_is_context_pending_reactivation(struct T_SM_CONTEXT_DATA *context);
260 void sm_set_pfi_included(struct T_SM_CONTEXT_DATA *, BOOL);
261 BOOL sm_is_pfi_included(struct T_SM_CONTEXT_DATA *context);
262
263 BOOL sm_is_llc_sapi_valid(U8 llc_sapi, U8 ti);
264
265 BOOL sm_is_aci_update_required(T_SM_UPDATE_FLAGS update_flags);
266 BOOL sm_is_user_plane_update_required(T_SM_UPDATE_FLAGS update_flags);
267
268 void sm_set_nw_cause(struct T_SM_CONTEXT_DATA *context,
269 T_CAUSE_ctrl_value ctrl_cause, U16 cause);
270 /*@observer@*/
271 T_CAUSE_ps_cause*sm_get_nw_cause(struct T_SM_CONTEXT_DATA *context);
272
273 void sm_set_aci_cause(struct T_SM_CONTEXT_DATA *context,
274 T_CAUSE_ctrl_value ctrl_cause, U16 cause);
275 /*@observer@*/
276 T_CAUSE_ps_cause*sm_get_aci_cause(struct T_SM_CONTEXT_DATA *context);
277
278 #endif /* _SM_H */
279 /*==== END OF FILE ==========================================================*/