comparison src/g23m-gprs/upm/upm_link_control.c @ 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 : UPM
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: Link Control state machine implementation in the UPM entity.
17 | For design details, see:
18 | 8010.939 UPM Detailed Specification
19 +---------------------------------------------------------------------------*/
20
21 /*==== DECLARATION CONTROL =================================================*/
22
23
24 /*==== INCLUDES =============================================================*/
25
26 #include "upm.h"
27
28 #ifdef TI_UMTS
29 #include "upm_rab_control.h"
30 #endif /* TI_UMTS */
31
32 #ifdef TI_GPRS
33 #include "upm_sndcp_control.h"
34 #endif /* TI_GPRS */
35
36 #include "upm_sm_output_handler.h"
37
38 /*==== CONSTS ===============================================================*/
39
40 /*==== TYPES ================================================================*/
41
42 typedef void (*T_UPM_LINK_CONTROL_TRANSITION_FUNC)(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
43
44 typedef struct {
45 #ifdef DEBUG
46 T_UPM_LINK_CONTROL_EVENT event;
47 #endif /* DEBUG */
48 T_UPM_LINK_CONTROL_TRANSITION_FUNC func;
49 } T_UPM_LINK_CONTROL_TRANSITION;
50
51 /*==== LOCALS ===============================================================*/
52
53 static void state_event_error (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
54 static void ignored (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
55 static void handle_sm_activate_started_ind (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
56 static void handle_dti_closed (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
57 #ifdef TI_UMTS
58 static void go_to_S2 (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
59 static void handle_sm_activate_ind_in_umts (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
60 static void handle_sm_modify_ind_in_umts (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
61 static void handle_deactivate_in_umts (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
62 static void handle_rab_released_abnormal (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
63 static void handle_rab_released_normal (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
64 #endif /* TI_UMTS */
65 #ifdef TI_GPRS
66 static void handle_sm_activate_ind_in_gsm (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
67 static void handle_llc_link_established (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
68 static void handle_sm_modify_ind_in_gsm (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
69 static void handle_modify_response_in_gsm (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
70 static void handle_deactivate_in_gsm (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
71 static void handle_deactivate_without_link_in_gsm (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
72 static void handle_llc_release_normal (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
73 static void handle_llc_release_abnormal (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
74 static void handle_gsm_qos_store(struct T_CONTEXT_DATA *ptr_context_data,
75 U8 sapi, U8 radio_prio, U8 pkt_flow_id,
76 T_PS_ctrl_qos ctrl_qos, T_PS_qos *qos);
77 #endif /* TI_GPRS */
78 #ifdef TI_DUAL_MODE
79 static void go_to_S8 (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
80 static void handle_rat_change_to_gsm_without_context (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
81 static void handle_rat_change_to_gsm (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
82 static void handle_rab_established_in_S6 (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
83 static void handle_rat_change_to_umts_without_context (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
84 static void handle_rat_change_to_umts_while_establishing(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
85 static void handle_rat_change_to_umts (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
86 #else
87 #define handle_rat_change_to_gsm_without_context state_event_error
88 #define handle_rat_change_to_gsm state_event_error
89 #define handle_rat_change_to_umts_without_context state_event_error
90 #define handle_rat_change_to_umts_while_establishing state_event_error
91 #define handle_rat_change_to_umts state_event_error
92 #endif /* TI_DUAL_MODE */
93 static void upm_link_mark_nsapi_deactivated(U8 nsapi);
94
95 /***********************************************************************
96 * State/Transition Table
97 */
98 static const T_UPM_LINK_CONTROL_TRANSITION
99 transition[UPM_LINK_CONTROL_NUMBER_OF_STATES]
100 [UPM_LINK_CONTROL_NUMBER_OF_EVENTS] =
101 {
102 { /* S0: UPM_LINK_RELEASED */
103 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, handle_sm_activate_started_ind),
104 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
105 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, state_event_error),
106 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
107 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, state_event_error),
108 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
109 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
110 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
111 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
112 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, state_event_error),
113 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, state_event_error)
114 },
115 #ifdef TI_UMTS
116 { /* S1: UPM_LINK_ESTABLISHING_RAB */
117 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
118 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
119 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_umts),
120 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
121 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
122 M_TRANSITION(UPM_I_RAB_ESTABLISHED, go_to_S2),
123 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
124 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
125 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
126 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, state_event_error),
127 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, handle_rat_change_to_gsm_without_context)
128 },
129 { /* S2: UPM_LINK_AWAITING_ACTIVATE_UMTS */
130 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
131 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, handle_sm_activate_ind_in_umts),
132 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_umts),
133 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
134 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
135 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
136 M_TRANSITION(UPM_I_RAB_RELEASED, handle_rab_released_abnormal),
137 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
138 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
139 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, state_event_error),
140 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, state_event_error)
141 },
142 { /* S3: UPM_LINK_RAB_ESTABLISHED */
143 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
144 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
145 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_umts),
146 M_TRANSITION(UPM_P_SM_MODIFY_IND, handle_sm_modify_ind_in_umts),
147 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
148 M_TRANSITION(UPM_I_RAB_ESTABLISHED, ignored),
149 M_TRANSITION(UPM_I_RAB_RELEASED, handle_rab_released_abnormal),
150 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
151 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
152 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, ignored),
153 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, handle_rat_change_to_gsm)
154 },
155 { /* S4: UPM_LINK_RELEASING_RAB */
156 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
157 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
158 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, state_event_error),
159 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
160 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, state_event_error),
161 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
162 M_TRANSITION(UPM_I_RAB_RELEASED, handle_rab_released_normal),
163 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
164 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
165 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, state_event_error),
166 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, ignored)
167 },
168 #endif /* TI_UMTS */
169 #ifdef TI_DUAL_MODE
170 { /* S5: UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM */
171 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
172 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
173 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_gsm),
174 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
175 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
176 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
177 M_TRANSITION(UPM_I_RAB_RELEASED, ignored),
178 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, go_to_S8),
179 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
180 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, handle_llc_release_abnormal),
181 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, state_event_error)
182 },
183 { /* S6: UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL */
184 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
185 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
186 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_umts),
187 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
188 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
189 M_TRANSITION(UPM_I_RAB_ESTABLISHED, handle_rab_established_in_S6),
190 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
191 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
192 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
193 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, ignored),
194 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, handle_rat_change_to_gsm)
195 },
196 #endif /* TI_DUAL_MODE */
197 #ifdef TI_GPRS
198 { /* S7: UPM_LINK_AWAITING_ACTIVATE_GSM */
199 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
200 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, handle_sm_activate_ind_in_gsm),
201 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_without_link_in_gsm),
202 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
203 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
204 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
205 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
206 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
207 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
208 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, state_event_error),
209 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, handle_rat_change_to_umts_without_context)
210 },
211 { /* S8: UPM_LINK_ESTABLISHING_LLC_LINK */
212 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
213 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
214 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_gsm),
215 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
216 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
217 M_TRANSITION(UPM_I_RAB_ESTABLISHED, ignored),
218 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
219 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, handle_llc_link_established),
220 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
221 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, handle_llc_release_abnormal),
222 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, handle_rat_change_to_umts_while_establishing)
223 },
224 { /* S9: UPM_LINK_LLC_LINK_ESTABLISHED */
225 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
226 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
227 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, handle_deactivate_in_gsm),
228 M_TRANSITION(UPM_P_SM_MODIFY_IND, handle_sm_modify_ind_in_gsm),
229 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, handle_dti_closed),
230 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
231 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
232 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
233 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, handle_modify_response_in_gsm),
234 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, handle_llc_release_abnormal),
235 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, handle_rat_change_to_umts)
236 },
237 { /* S10: UPM_LINK_RELEASING_LLC_LINK */
238 M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND, state_event_error),
239 M_TRANSITION(UPM_P_SM_ACTIVATE_IND, state_event_error),
240 M_TRANSITION(UPM_P_SM_DEACTIVATE_IND, state_event_error),
241 M_TRANSITION(UPM_P_SM_MODIFY_IND, state_event_error),
242 M_TRANSITION(UPM_I_LINK_DTI_CLOSED, state_event_error),
243 M_TRANSITION(UPM_I_RAB_ESTABLISHED, state_event_error),
244 M_TRANSITION(UPM_I_RAB_RELEASED, state_event_error),
245 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
246 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED, state_event_error),
247 M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED, handle_llc_release_normal),
248 M_TRANSITION(UPM_I_LINK_RAT_CHANGED, ignored)
249 }
250 #endif /* TI_GPRS */
251 };
252
253 /*==== PRIVATE FUNCTIONS ====================================================*/
254
255 /*
256 +------------------------------------------------------------------------------
257 | Function : link_control_goto_state
258 +------------------------------------------------------------------------------
259 | Description : Move to the state specified in the new_state parameter
260 |
261 | Parameters : ptr_context_data - Context data
262 | new_state - New state
263 +------------------------------------------------------------------------------
264 */
265 static void link_control_goto_state(struct T_CONTEXT_DATA *ptr_context_data,
266 T_UPM_LINK_CONTROL_STATE new_state)
267 {
268 ptr_context_data->link_control_state = new_state;
269 }
270
271 /*
272 +------------------------------------------------------------------------------
273 | Function : link_control_state
274 +------------------------------------------------------------------------------
275 | Description : Return the state in which Link Control is in for this
276 | context instanse.
277 |
278 | Parameters : ptr_context_data - Context data
279 +------------------------------------------------------------------------------
280 */
281 static T_UPM_LINK_CONTROL_STATE
282 link_control_state(struct T_CONTEXT_DATA *ptr_context_data)
283 {
284 return ptr_context_data->link_control_state;
285 }
286
287 /*
288 +------------------------------------------------------------------------------
289 | Function : state_event_error
290 +------------------------------------------------------------------------------
291 | Description : General function used to report state event errors.
292 |
293 | Parameters : ptr_context_data - Not used
294 | data - Not used
295 +------------------------------------------------------------------------------
296 */
297 static void state_event_error(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
298 {
299 (void)TRACE_ERROR("UPM Link Control: STATE EVENT ERROR!");
300 }
301
302 /*
303 +------------------------------------------------------------------------------
304 | Function : ignored
305 +------------------------------------------------------------------------------
306 | Description : General function used for transitions that shall be ignored
307 |
308 | Parameters : ptr_context_data - Not used
309 | data - Not used
310 +------------------------------------------------------------------------------
311 */
312 static void ignored(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
313 {
314 (void)TRACE_FUNCTION("UPM Link Control: Event ignored.");
315 }
316
317 /*
318 +------------------------------------------------------------------------------
319 | Function : go_to_S*
320 +------------------------------------------------------------------------------
321 | Description : General functions for simple state transitions
322 |
323 | Parameters : ptr_context_data - Not used
324 | data - Not used
325 +------------------------------------------------------------------------------
326 */
327 #ifdef TI_UMTS
328 static void go_to_S2(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
329 {
330 /* (void)TRACE_FUNCTION("UPM Link Control: Transition to UPM LINK AWAITING ACTIVATE UMTS state"); */
331 link_control_goto_state(ptr_context_data, UPM_LINK_AWAITING_ACTIVATE_UMTS);
332 }
333 #endif /* TI_UMTS */
334
335 #ifdef TI_DUAL_MODE
336 static void go_to_S8(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
337 {
338 /* (void)TRACE_FUNCTION("UPM Link Control: Transition to UPM LINK LLC LINK ESTABLISHED state"); */
339 link_control_goto_state(ptr_context_data, UPM_LINK_LLC_LINK_ESTABLISHED);
340 }
341 #endif /* TI_DUAL_MODE */
342
343 /*
344 +------------------------------------------------------------------------------
345 | Function : handle_sm_activate_started_ind
346 +------------------------------------------------------------------------------
347 | Description : Handle SM_ACTIVATE_STARTED_IND primitive. Examines RAT,
348 | and moves to GSM or UTMS state. Starts RAB in UMTS.
349 |
350 | Parameters : ptr_context_data - Context data
351 | data - SM_ACTIVATE_STARTED_IND primitive (unused)
352 +------------------------------------------------------------------------------
353 */
354 static void handle_sm_activate_started_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ /*@unused@*/ void *data)
355 {
356 (void)TRACE_FUNCTION("UPM Link Control: handle_sm_activate_started_ind");
357
358 #ifdef TI_DUAL_MODE
359 /* Examine RAT: */
360 if (upm_get_current_rat() == PS_RAT_GSM)
361 #endif /* TI_DUAL_MODE */
362 #ifdef TI_GPRS
363 {
364 /* GSM: Do nothing until SM_ACTIVATE_IND arrives. Just change state. */
365 link_control_goto_state(ptr_context_data, UPM_LINK_AWAITING_ACTIVATE_GSM);
366 }
367 #endif /* TI_GPRS */
368 #ifdef TI_DUAL_MODE
369 else if (upm_get_current_rat() == PS_RAT_UMTS_FDD)
370 #endif /* TI_DUAL_MODE */
371 #ifdef TI_UMTS
372 {
373 /* UMTS: Order RAB Control to await RAB establishment, and change state. */
374 link_control_goto_state(ptr_context_data, UPM_LINK_ESTABLISHING_RAB);
375 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_INITIAL_ESTABLISH, NULL);
376 }
377 #endif /* TI_UMTS */
378 }
379
380 /*
381 +------------------------------------------------------------------------------
382 | Function : handle_dti_closed
383 +------------------------------------------------------------------------------
384 | Description : Handle UPM_I_LINK_DTI_CLOSED
385 |
386 | Parameters : ptr_context_data - Context data
387 | data - Not used
388 +------------------------------------------------------------------------------
389 */
390 static void handle_dti_closed(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
391 {
392 T_PS_sapi llc_sapi;
393
394 (void)TRACE_FUNCTION("UPM Link Control: handle_dti_closed");
395
396 #ifdef TI_GPRS
397 llc_sapi = (T_PS_sapi)ptr_context_data->gprs_data.sndcp_llc_sapi;
398 #else
399 llc_sapi = PS_SAPI_0; /* SAPI not assigned [3G 24.008, 6.1.3.1.1] */
400 #endif /* TI_GPRS */
401
402 /* Send SM_STATUS_REQ, and expect control plane to take action. */
403 send_sm_status_req(upm_nsapi2nsapi_set(ptr_context_data->nsapi),
404 llc_sapi,
405 CAUSE_is_from_upm, (U16)CAUSE_UPM_DTI_DISCONNECT);
406 }
407
408 /*
409 +------------------------------------------------------------------------------
410 | Function : handle_sm_activate_ind_in_utms
411 +------------------------------------------------------------------------------
412 | Description : Handle SM_ACTIVATE_IND primitive while in UMTS RAT.
413 |
414 | Parameters : ptr_context_data - Context data
415 | data - SM_ACTIVATE_IND primitive
416 +------------------------------------------------------------------------------
417 */
418 #ifdef TI_UMTS
419 static void handle_sm_activate_ind_in_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
420 {
421 T_SM_ACTIVATE_IND *prim = (T_SM_ACTIVATE_IND *)data;
422
423 (void)TRACE_FUNCTION("UPM Link Control: handle_sm_activate_ind_in_umts");
424
425 TRACE_ASSERT( data != NULL );
426
427 #ifdef TI_DUAL_MODE
428 /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
429 handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
430 (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
431 #endif /* TI_DUAL_MODE */
432
433 /* Send SM_ACTIVATE_RES */
434 send_sm_activate_res(ptr_context_data, ((T_SN_ACTIVATE_CNF*)data));
435
436 /* Go to state UPM LINK RAB ESTABLISHED */
437 link_control_goto_state(ptr_context_data, UPM_LINK_RAB_ESTABLISHED);
438
439 /* Store QoS parameter as needed in RAB Control */
440 upm_rab_control(ptr_context_data, UPM_I_RAB_MODIFY, &(prim->qos.qos_r99));
441
442 /* Inform Uplink and Downlink state machines of link up. */
443 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_UP, NULL);
444 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_UP, NULL);
445 }
446 #endif /* TI_UMTS */
447
448 /*
449 +------------------------------------------------------------------------------
450 | Function : handle_sm_modify_ind_in_utms
451 +------------------------------------------------------------------------------
452 | Description : Handle SM_MODIFY_IND primitive while in UMTS RAT.
453 |
454 | Parameters : ptr_context_data - Context data
455 | data - SM_MODIFY_IND primitive
456 +------------------------------------------------------------------------------
457 */
458 #ifdef TI_UMTS
459 static void handle_sm_modify_ind_in_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
460 {
461 T_SM_MODIFY_IND *prim = (T_SM_MODIFY_IND *)data;
462
463 (void)TRACE_FUNCTION("UPM Link Control: handle_sm_modify_ind_in_umts");
464
465 TRACE_ASSERT( data != NULL );
466
467 #ifdef TI_DUAL_MODE
468 /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
469 handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
470 (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
471 #endif
472
473 /* Store QoS parameter as needed in RAB Control */
474 upm_rab_control(ptr_context_data, UPM_I_RAB_MODIFY,
475 &(prim->qos.qos_r99));
476
477 /* Send SM_MODIFY_RES */
478 send_sm_modify_res(ptr_context_data);
479 }
480 #endif /* TI_UMTS */
481
482 /*
483 +------------------------------------------------------------------------------
484 | Function : handle_deactivate_in_umts
485 +------------------------------------------------------------------------------
486 | Description : Handle SM_DEACTIVATE_IND primitive while in UMTS RAT.
487 |
488 | Parameters : ptr_context_data - Context data
489 | data - Local release flag (Not used in UMTS)
490 +------------------------------------------------------------------------------
491 */
492 #ifdef TI_UMTS
493 static void handle_deactivate_in_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
494 {
495 (void)TRACE_FUNCTION("UPM Link Control: handle_deactivate_in_umts");
496
497 /* Go to state UPM LINK RELEASING RAB */
498 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASING_RAB);
499
500 /* Terminate Uplink and Downlink state machines. */
501 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
502 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
503
504 /* Order RAB Control to await RAB release. */
505 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_RELEASE, NULL);
506 }
507 #endif /* TI_UMTS */
508
509 /*
510 +------------------------------------------------------------------------------
511 | Function : handle_rab_released_abnormal
512 +------------------------------------------------------------------------------
513 | Description : Handle UPM_I_RAB_RELEASED when not expected
514 |
515 | Parameters : ptr_context_data - Context data
516 | data - Not used
517 +------------------------------------------------------------------------------
518 */
519 #ifdef TI_UMTS
520 static void handle_rab_released_abnormal(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
521 {
522 (void)TRACE_FUNCTION("UPM Link Control: handle_rab_released_abnormal");
523
524 /* Go to state UPM LINK RELEASED */
525 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
526
527 /* Terminate Uplink and Downlink state machines. */
528 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
529 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
530 }
531 #endif /* TI_UMTS */
532
533 /*
534 +------------------------------------------------------------------------------
535 | Function : handle_rab_released_normal
536 +------------------------------------------------------------------------------
537 | Description : Handle UPM_I_RAB_RELEASED during normal deactivation
538 |
539 | Parameters : ptr_context_data - Context data
540 | data - Not used
541 +------------------------------------------------------------------------------
542 */
543 #ifdef TI_UMTS
544 static void handle_rab_released_normal(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
545 {
546 (void)TRACE_FUNCTION("UPM Link Control: handle_rab_released_normal");
547
548 /* SM_DEACTIVATE_RES sent from dispatcher; groups responses for all NSAPIs */
549 /* send_sm_deactivate_res( ... ); */
550 upm_link_mark_nsapi_deactivated(ptr_context_data->nsapi);
551
552 /* Go to state UPM LINK RELEASED */
553 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
554 }
555 #endif /* TI_UMTS */
556
557 /*
558 +------------------------------------------------------------------------------
559 | Function : handle_sm_activate_ind_in_gsm
560 +------------------------------------------------------------------------------
561 | Description : Handle SM_ACTIVATE_IND in S7
562 |
563 | Parameters : ptr_context_data - Context data
564 | data - Not used
565 +------------------------------------------------------------------------------
566 */
567 #ifdef TI_GPRS
568 static void handle_sm_activate_ind_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
569 {
570 T_SM_ACTIVATE_IND *prim = (T_SM_ACTIVATE_IND *)data;
571
572 (void)TRACE_FUNCTION("UPM Link Control: handle_sm_activate_ind_in_gsm");
573
574 TRACE_ASSERT(prim != NULL);
575
576 /*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
577 /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
578 handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
579 (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
580
581 /* Go to state UPM LINK ESTABLISHING LLC LINK */
582 link_control_goto_state(ptr_context_data, UPM_LINK_ESTABLISHING_LLC_LINK);
583
584 /* Order SNDCP Control to establish LLC link */
585
586 /* Pass compression parameter fields only if they are present */
587 if( (((T_SM_ACTIVATE_IND *)data)->v_comp_params == TRUE) )
588 {
589 upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_ESTABLISH_LLC_LINK,
590 &((T_SM_ACTIVATE_IND *)data)->comp_params);
591 } else {
592 upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_ESTABLISH_LLC_LINK, NULL);
593 }
594 }
595 #endif /* TI_GPRS */
596
597 /*
598 +------------------------------------------------------------------------------
599 | Function : handle_llc_link_established
600 +------------------------------------------------------------------------------
601 | Description : Handle UPM_I_LLC_LINK_ESTABLISHED in S8
602 |
603 | Parameters : ptr_context_data - Context data
604 | data - Not used
605 +------------------------------------------------------------------------------
606 */
607 #ifdef TI_GPRS
608 static void handle_llc_link_established(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
609 {
610 (void)TRACE_FUNCTION("UPM Link Control: handle_llc_link_established");
611
612 send_sm_activate_res(ptr_context_data, ((T_SN_ACTIVATE_CNF*)data));
613
614 /* Go to state UPM LINK LLC LINK ESTABLISHED */
615 link_control_goto_state(ptr_context_data, UPM_LINK_LLC_LINK_ESTABLISHED);
616
617 #ifndef UPM_WITHOUT_USER_PLANE
618 /* Report initial LINK UP to Uplink Data */
619 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_UP, NULL);
620
621 /* Report link up to Downlink Data Control. This triggers flow control
622 * initialization towards SNDCP. */
623 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_UP, NULL);
624 #endif /* UPM_WITHOUT_USER_PLANE */
625 }
626 #endif /* TI_GPRS */
627
628 /*
629 +------------------------------------------------------------------------------
630 | Function : handle_sm_modify_ind_in_gsm
631 +------------------------------------------------------------------------------
632 | Description : Handle SM_MODIFY_IND primitive while in GSM RAT.
633 |
634 | Parameters : ptr_context_data - Context data
635 | data - SM_MODIFY_IND primitive
636 +------------------------------------------------------------------------------
637 */
638 #ifdef TI_GPRS
639 static void handle_sm_modify_ind_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
640 {
641 T_SM_MODIFY_IND *prim = (T_SM_MODIFY_IND *)data;
642
643 (void)TRACE_FUNCTION("UPM Link Control: handle_sm_modify_ind_in_gsm");
644
645 TRACE_ASSERT( data != NULL );
646
647 /*lint -e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
648 /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
649 handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
650 (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
651
652 /* SNDCP Control constructs a modify primitive to SNDCP */
653 upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_MODIFY_LLC_LINK,
654 &((T_SM_MODIFY_IND *)data)->qos.qos_r99);
655 /*lint +e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
656
657 }
658 #endif /* TI_GPRS */
659
660 /*
661 +------------------------------------------------------------------------------
662 | Function : handle_modify_response_in_gsm
663 +------------------------------------------------------------------------------
664 | Description : Handle UPM_I_SNDCP_LLC_LINK_MODIFIED
665 |
666 | Parameters : ptr_context_data - Context data
667 | data - Not used
668 +------------------------------------------------------------------------------
669 */
670 #ifdef TI_GPRS
671 static void handle_modify_response_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
672 {
673 (void)TRACE_FUNCTION("UPM Link Control: handle_modify_response_in_gsm");
674
675 /* Send SM_MODIFY_RES */
676 send_sm_modify_res(ptr_context_data);
677 }
678 #endif /* TI_GPRS */
679
680 /*
681 +------------------------------------------------------------------------------
682 | Function : handle_deactivate_in_gsm
683 +------------------------------------------------------------------------------
684 | Description : Handle SM_DEACTIVATE_IND while active in GSM RAT
685 |
686 | Parameters : ptr_context_data - Context data
687 | data - Local flag (rel_ind)
688 +------------------------------------------------------------------------------
689 */
690 #ifdef TI_GPRS
691 static void handle_deactivate_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
692 {
693 (void)TRACE_FUNCTION("UPM Link Control: handle_deactivate_in_gsm");
694
695 /* Go to state UPM LINK RELEASING LLC LINK */
696 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASING_LLC_LINK);
697
698 #ifndef UPM_WITHOUT_USER_PLANE
699 /* Terminate Uplink and Downlink state machines. */
700 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
701 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
702 #endif /* UPM_WITHOUT_USER_PLANE */
703
704 /* SNDCP Control constructs a deactivate primitive for SNDCP */
705 upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_RELEASE_LLC_LINK, data);
706 }
707 #endif /* TI_GPRS */
708
709 /*
710 +------------------------------------------------------------------------------
711 | Function : handle_deactivate_without_link_in_gsm
712 +------------------------------------------------------------------------------
713 | Description : Handle SM_DEACTIVATE_IND in GSM, when no link exists (S5)
714 |
715 | Parameters : ptr_context_data - Context data
716 | data - Not used
717 +------------------------------------------------------------------------------
718 */
719 #ifdef TI_GPRS
720 static void handle_deactivate_without_link_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
721 {
722 (void)TRACE_FUNCTION("UPM Link Control: handle_deactivate_without_link_in_gsm");
723
724 /* SM_DEACTIVATE_RES sent in dispatcher. One primitive for all NSAPIs. */
725 /* send_sm_deactivate_res( ... ); */
726 upm_link_mark_nsapi_deactivated(ptr_context_data->nsapi);
727
728 /* Go to state UPM LINK RELEASED */
729 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
730 }
731 #endif /* TI_GPRS */
732
733 /*
734 +------------------------------------------------------------------------------
735 | Function : handle_llc_release_normal
736 +------------------------------------------------------------------------------
737 | Description : Handle UPM_I_SNDCP_LLC_LINK_RELEASED in S10
738 |
739 | Parameters : ptr_context_data - Context data
740 | data - Not used
741 +------------------------------------------------------------------------------
742 */
743 #ifdef TI_GPRS
744 static void handle_llc_release_normal(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
745 {
746 (void)TRACE_FUNCTION("UPM Link Control: handle_llc_release_normal");
747
748 /* SM_DEACTIVATE_RES sent in dispatcher. One primitive for all NSAPIs. */
749 /* send_sm_deactivate_res( ... ); */
750 upm_link_mark_nsapi_deactivated(ptr_context_data->nsapi);
751
752 /* Go to state UPM LINK RELEASED */
753 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
754 }
755 #endif /* TI_GPRS */
756
757 /*
758 +------------------------------------------------------------------------------
759 | Function : handle_llc_release_abnormal
760 +------------------------------------------------------------------------------
761 | Description : Handle UPM_I_SNDCP_LLC_LINK_RELEASED in state other than S10
762 |
763 | Parameters : ptr_context_data - Context data
764 | data - SN_STATUS_IND primitive (unused)
765 +------------------------------------------------------------------------------
766 */
767 #ifdef TI_GPRS
768 static void handle_llc_release_abnormal(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ /*@unused@*/ void *data)
769 {
770 (void)TRACE_FUNCTION("UPM Link Control: handle_llc_release_abnormal");
771
772 /* SM_STATUS_REQ sent once for all affected NSAPIs in sndcp_control. */
773 /* send_sm_status_req(...) */
774
775 /* Go to state UPM LINK RELEASED */
776 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
777
778 #ifndef UPM_WITHOUT_USER_PLANE
779 /* Terminate Uplink and Downlink state machines. */
780 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
781 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
782 #endif /* UPM_WITHOUT_USER_PLANE */
783 }
784 #endif /* TI_GPRS */
785
786 /*
787 +------------------------------------------------------------------------------
788 | Function : handle_rat_change_to_gsm_without_context
789 +------------------------------------------------------------------------------
790 | Description : Handle UPM_I_LINK_RAT_CHANGED(GSM) in S1 or S2
791 |
792 | Parameters : ptr_context_data - Context Data
793 | data - GSM/UMTS
794 +------------------------------------------------------------------------------
795 */
796 #ifdef TI_DUAL_MODE
797 static void handle_rat_change_to_gsm_without_context(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
798 {
799 (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_gsm_without_context");
800 TRACE_ASSERT( (T_PS_rat)data == PS_RAT_GSM );
801
802 /* Go to state UPM LINK AWAITING ACTIVATE GSM */
803 link_control_goto_state(ptr_context_data, UPM_LINK_AWAITING_ACTIVATE_GSM);
804
805 /* Order RAB Control to await RAB release,
806 * or to stop awaiting RAB establish */
807 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_RELEASE, NULL);
808 }
809 #endif /* TI_DUAL_MODE */
810
811 /*
812 +------------------------------------------------------------------------------
813 | Function : handle_rat_change_to_gsm
814 +------------------------------------------------------------------------------
815 | Description : Handle UPM_I_LINK_RAT_CHANGED(GSM) in S3
816 |
817 | Parameters : ptr_context_data - Context data
818 | data - GSM/UMTS
819 +------------------------------------------------------------------------------
820 */
821 #ifdef TI_DUAL_MODE
822 static void handle_rat_change_to_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
823 {
824 (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_gsm");
825
826 TRACE_ASSERT( (T_PS_rat)data == PS_RAT_GSM );
827
828 /* Go to state UPM LINK COMPLETING RAT CHANGE TO GSM */
829 link_control_goto_state(ptr_context_data, UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM);
830
831 /* Order RAB Control to await RAB release */
832 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_RELEASE, NULL);
833
834 /* Order SNDCP Control to await LLC link establishment */
835 upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_AWAIT_ESTABLISH, NULL);
836 }
837 #endif /* TI_DUAL_MODE */
838
839 /*
840 +------------------------------------------------------------------------------
841 | Function : handle_rab_established_in_S6
842 +------------------------------------------------------------------------------
843 | Description : Handle UPM_I_RAB_ESTABLISHED in S7
844 |
845 | Parameters : ptr_context_data - Context data
846 | data - Not used
847 +------------------------------------------------------------------------------
848 */
849 #ifdef TI_DUAL_MODE
850 static void handle_rab_established_in_S6(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
851 {
852 (void)TRACE_FUNCTION("UPM Link Control: handle_rab_established_in_S6");
853
854 /* Go to state UPM LINK RAB ESTABLISHED */
855 link_control_goto_state(ptr_context_data, UPM_LINK_RAB_ESTABLISHED);
856
857 /* Send SM_ACTIVATE_RES */
858 send_sm_activate_res(ptr_context_data, ((T_SN_ACTIVATE_CNF*)data));
859
860 /* Inform Uplink and Downlink state machines. */
861 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_UP, NULL);
862 upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_UP, NULL);
863 }
864 #endif /* TI_DUAL_MODE */
865
866 /*
867 +------------------------------------------------------------------------------
868 | Function : handle_rat_change_to_umts_without_context
869 +------------------------------------------------------------------------------
870 | Description : Handle UPM_I_LINK_RAT_CHANGED(UMTS) in S7
871 |
872 | Parameters : ptr_context_data - Context data
873 | data - GSM/UMTS
874 +------------------------------------------------------------------------------
875 */
876 #ifdef TI_DUAL_MODE
877 static void handle_rat_change_to_umts_without_context(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
878 {
879 (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_umts_without_context");
880
881 TRACE_ASSERT( (T_PS_rat)data == PS_RAT_UMTS_FDD );
882
883 /* Go to state UPM LINK ESTABLISHING RAB */
884 link_control_goto_state(ptr_context_data, UPM_LINK_ESTABLISHING_RAB);
885
886 /* Order RAB Control to await RAB establishment */
887 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_INITIAL_ESTABLISH, NULL);
888 }
889 #endif /* TI_DUAL_MODE */
890
891 /*
892 +------------------------------------------------------------------------------
893 | Function : handle_rat_change_to_umts_without_context
894 +------------------------------------------------------------------------------
895 | Description : Handle UPM_I_LINK_RAT_CHANGED(UMTS) in S8
896 |
897 | Parameters : ptr_context_data - Context data
898 | data - GSM/UMTS
899 +------------------------------------------------------------------------------
900 */
901 #ifdef TI_DUAL_MODE
902 static void handle_rat_change_to_umts_while_establishing(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
903 {
904 (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_umts_while_establishing");
905
906 TRACE_ASSERT( (T_PS_rat)data == PS_RAT_UMTS_FDD );
907
908 /* Go to state UPM LINK COMPLETING RAT CHANGE TO UMTS INITIAL */
909 link_control_goto_state(ptr_context_data, UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL);
910
911 /* Order RAB Control to await RAB establishment */
912 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_INITIAL_ESTABLISH, NULL);
913 }
914 #endif /* TI_DUAL_MODE */
915
916 /*
917 +------------------------------------------------------------------------------
918 | Function : handle_rat_change_to_umts
919 +------------------------------------------------------------------------------
920 | Description : Handle UPM_I_LINK_RAT_CHANGED(UMTS) in S9
921 |
922 | Parameters : ptr_context_data - Context data
923 | data - GSM/UMTS
924 +------------------------------------------------------------------------------
925 */
926 #ifdef TI_DUAL_MODE
927 static void handle_rat_change_to_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
928 {
929 (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_umts");
930
931 TRACE_ASSERT( (T_PS_rat)data == PS_RAT_UMTS_FDD );
932
933 /* Go to state UPM LINK RAB ESTABLISHED*/
934 link_control_goto_state(ptr_context_data, UPM_LINK_RAB_ESTABLISHED);
935
936 /* Order RAB Control to await RAB establishment */
937 upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_ESTABLISH, NULL);
938 }
939 #endif /* TI_DUAL_MODE */
940
941 /*
942 +------------------------------------------------------------------------------
943 | Function : handle_gsm_qos_store
944 +------------------------------------------------------------------------------
945 | Description : Store GSM-RAT relevant QoS parameters for the NSAPI
946 |
947 | Parameters : ptr_context_data - Context data
948 | qos - R99 format QoS data
949 +------------------------------------------------------------------------------
950 */
951 #ifdef TI_GPRS
952 static void handle_gsm_qos_store(struct T_CONTEXT_DATA *ptr_context_data,
953 U8 sapi, U8 radio_prio, U8 pkt_flow_id,
954 T_PS_ctrl_qos ctrl_qos, T_PS_qos *qos)
955 {
956 struct T_UPM_CONTEXT_DATA_GPRS *gprs_data = &ptr_context_data->gprs_data;
957
958 (void)TRACE_FUNCTION("UPM Link Control: handle_gsm_qos_store");
959
960 gprs_data->sndcp_llc_sapi = sapi;
961 gprs_data->sndcp_radio_prio = radio_prio;
962
963 /* [3G 24.008] version 6 says to keep PFI if omitted. */
964 if (pkt_flow_id != (U8)PS_PKT_FLOW_ID_NOT_PRES) {
965 gprs_data->pkt_flow_id = pkt_flow_id;
966 }
967
968 if (ctrl_qos == PS_is_R97)
969 {
970 gprs_data->sndcp_delay = qos->qos_r97.delay;
971 gprs_data->sndcp_relclass = qos->qos_r97.relclass;
972 gprs_data->sndcp_peak_bitrate = qos->qos_r97.peak;
973 gprs_data->sndcp_preced = qos->qos_r97.preced;
974 gprs_data->sndcp_mean = qos->qos_r97.mean;
975 } else if (ctrl_qos == PS_is_R99) {
976 T_PS_qos_r97 temp_qos_r97;
977
978 cl_qos_convert_r99_to_r97(&qos->qos_r99, &temp_qos_r97);
979
980 gprs_data->sndcp_delay = temp_qos_r97.delay;
981 gprs_data->sndcp_relclass = temp_qos_r97.relclass;
982 gprs_data->sndcp_peak_bitrate = temp_qos_r97.peak;
983 gprs_data->sndcp_preced = temp_qos_r97.preced;
984 gprs_data->sndcp_mean = temp_qos_r97.mean;
985 } else {
986 (void)TRACE_ERROR("Link Control (handle_gsm_qos_store): Invalid QoS union controller!");
987 }
988 }
989 #endif /* TI_GPRS */
990 /*
991 +------------------------------------------------------------------------------
992 | Function : upm_link_mark_nsapi_deactivated
993 +------------------------------------------------------------------------------
994 | Description : Helper function to group nsapis in SM_DEACTIVATE_RES
995 |
996 | Parameters : nsapi - NSAPI
997 +------------------------------------------------------------------------------
998 */
999 static U16 nsapis_to_deactivate = 0, nsapis_currently_deactivated = 0;
1000
1001 static void upm_link_mark_nsapi_deactivated(U8 nsapi)
1002 {
1003 (void)TRACE_FUNCTION("UPM Link Control: upm_link_mark_nsapi_deactivated");
1004
1005 nsapis_currently_deactivated |= upm_nsapi2nsapi_set(nsapi);
1006
1007 if (nsapis_currently_deactivated == nsapis_to_deactivate)
1008 {
1009 send_sm_deactivate_res(nsapis_to_deactivate);
1010 /* All context requested deactivated have been deactivated */
1011 /* Zero out store */
1012 nsapis_to_deactivate = 0;
1013 nsapis_currently_deactivated = 0;
1014 }
1015 }
1016
1017 /*==== PUBLIC FUNCTIONS =====================================================*/
1018
1019 /*
1020 +------------------------------------------------------------------------------
1021 | Function : upm_is_link_released
1022 +------------------------------------------------------------------------------
1023 | Description : Link Control state query function. Return TRUE if Link Control
1024 | is in state UPM LINK RELEASED; returns FALSE otherwise.
1025 |
1026 | Parameters : ptr_context_data - Pointer to context data
1027 +------------------------------------------------------------------------------
1028 */
1029 BOOL upm_is_link_released(struct T_CONTEXT_DATA *ptr_context_data)
1030 {
1031 TRACE_ASSERT(ptr_context_data != NULL);
1032
1033 if (link_control_state(ptr_context_data) == UPM_LINK_RELEASED)
1034 {
1035 (void)TRACE_FUNCTION("UPM Link Control: upm_is_link_released (TRUE)");
1036 return TRUE;
1037 } else {
1038 (void)TRACE_FUNCTION("UPM Link Control: upm_is_link_released (FALSE)");
1039 return FALSE;
1040 }
1041 }
1042
1043 /*
1044 +------------------------------------------------------------------------------
1045 | Function : upm_link_dispatch_sm_deactivate_ind
1046 +------------------------------------------------------------------------------
1047 | Description : Dispatch SM_DEACTIVATE_IND
1048 |
1049 | Parameters : sm_deactivate_ind - received primitive
1050 +------------------------------------------------------------------------------
1051 */
1052 void upm_link_dispatch_sm_deactivate_ind(T_SM_DEACTIVATE_IND *sm_deactivate_ind)
1053 {
1054 int nsapi;
1055 struct T_CONTEXT_DATA *ptr_context_data;
1056
1057 (void)TRACE_FUNCTION("UPM Link Control: upm_link_dispatch_sm_deactivate_ind");
1058
1059 /* Add NSAPI to nsapi_set to deactivate */
1060 nsapis_to_deactivate |= sm_deactivate_ind->nsapi_set;
1061
1062 for (nsapi = (int)NAS_NSAPI_5; nsapi < NAS_SIZE_NSAPI; nsapi++)
1063 {
1064 if ( (sm_deactivate_ind->nsapi_set & upm_nsapi2nsapi_set(nsapi)) != 0)
1065 {
1066 ptr_context_data = upm_get_context_data_from_nsapi(nsapi);
1067 if (ptr_context_data != NULL)
1068 {
1069 if (upm_is_link_released(ptr_context_data))
1070 {
1071 nsapis_currently_deactivated |= upm_nsapi2nsapi_set(nsapi);
1072 } else {
1073 upm_link_control(ptr_context_data, UPM_P_SM_DEACTIVATE_IND,
1074 (void *)sm_deactivate_ind->rel_ind);
1075 }
1076
1077 upm_check_for_released_context_and_release(ptr_context_data);
1078 } else {
1079 (void)TRACE_ERROR("Tried to deactivate non-existent context!");
1080 }
1081 }
1082 } /* for */
1083 }
1084
1085 /*
1086 +------------------------------------------------------------------------------
1087 | Function : upm_link_control_init
1088 +------------------------------------------------------------------------------
1089 | Description : Link Control state machine initialization function
1090 |
1091 | Parameters : ptr_context_data - Pointer to context data
1092 +------------------------------------------------------------------------------
1093 */
1094 void upm_link_control_init(struct T_CONTEXT_DATA *ptr_context_data)
1095 {
1096 (void)TRACE_FUNCTION("UPM Link Control: upm_link_control_init");
1097
1098 TRACE_ASSERT(ptr_context_data != NULL);
1099
1100 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
1101
1102 /* Zero out store for deactivation synchronization */
1103 nsapis_to_deactivate = 0;
1104 nsapis_currently_deactivated = 0;
1105 }
1106
1107 /*
1108 +------------------------------------------------------------------------------
1109 | Function : upm_link_control_exit
1110 +------------------------------------------------------------------------------
1111 | Description : Link Control state machine exit function
1112 |
1113 | Parameters : ptr_context_data - Pointer to context data
1114 +------------------------------------------------------------------------------
1115 */
1116 void upm_link_control_exit(struct T_CONTEXT_DATA *ptr_context_data)
1117 {
1118 (void)TRACE_FUNCTION("UPM Link Control: upm_link_control_exit");
1119
1120 TRACE_ASSERT(ptr_context_data != NULL);
1121
1122 link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
1123 }
1124
1125 /*
1126 +------------------------------------------------------------------------------
1127 | Function : upm_link_control
1128 +------------------------------------------------------------------------------
1129 | Description : Link Control state machine
1130 |
1131 | Parameters : ptr_context_data - Pointer to context data
1132 | event - Internal event (see upm_link_control.h)
1133 | data - Event dependent parameter
1134 +------------------------------------------------------------------------------
1135 */
1136 void upm_link_control (struct T_CONTEXT_DATA *ptr_context_data,
1137 T_UPM_LINK_CONTROL_EVENT event,
1138 /*@null@*/ void *data)
1139 {
1140 #ifdef DEBUG
1141 T_UPM_LINK_CONTROL_STATE old_state;
1142 /*@observer@*/ /*@notnull@*/
1143 static const char *state_name[UPM_LINK_CONTROL_NUMBER_OF_STATES] = {
1144 "S0_UPM_LINK_RELEASED",
1145 #ifdef TI_UMTS
1146 "S1_UPM_LINK_ESTABLISHING_RAB",
1147 "S2_UPM_LINK_AWAITING_ACTIVATE_UMTS",
1148 "S3_UPM_LINK_RAB_ESTABLISHED",
1149 "S4_UPM_LINK_RELEASING_RAB",
1150 #endif /* TI_UMTS */
1151 #ifdef TI_DUAL_MODE
1152 "S5_UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM",
1153 "S6_UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL",
1154 #endif /* TI_DUAL_MODE */
1155 #ifdef TI_GPRS
1156 "S7_UPM_LINK_AWAITING_ACTIVATE_GSM",
1157 "S8_UPM_LINK_ESTABLISHING_LLC_LINK",
1158 "S9_UPM_LINK_LLC_LINK_ESTABLISHED",
1159 "S10_UPM_LINK_RELEASING_LLC_LINK"
1160 #endif /* TI_GPRS */
1161 };
1162 /*@observer@*/ /*@notnull@*/
1163 static const char *event_name[UPM_LINK_CONTROL_NUMBER_OF_EVENTS] = {
1164 "UPM_P_SM_ACTIVATE_STARTED_IND",
1165 "UPM_P_SM_ACTIVATE_IND",
1166 "UPM_P_SM_DEACTIVATE_IND",
1167 "UPM_P_SM_MODIFY_IND",
1168 "UPM_I_LINK_DTI_CLOSED",
1169 "UPM_I_RAB_ESTABLISHED",
1170 "UPM_I_RAB_RELEASED",
1171 "UPM_I_SNDCP_LLC_LINK_ESTABLISHED",
1172 "UPM_I_SNDCP_LLC_LINK_MODIFIED",
1173 "UPM_I_SNDCP_LLC_LINK_RELEASED",
1174 "UPM_I_LINK_RAT_CHANGED"
1175 };
1176
1177 TRACE_ASSERT(ptr_context_data != NULL);
1178 TRACE_ASSERT(event < UPM_LINK_CONTROL_NUMBER_OF_EVENTS);
1179
1180 old_state = link_control_state(ptr_context_data);
1181 TRACE_ASSERT(old_state < UPM_LINK_CONTROL_NUMBER_OF_STATES);
1182
1183 if (transition[(U16)old_state][(U16)event].event != event)
1184 {
1185 (void)TRACE_ERROR("Event table error in upm_link_control!");
1186 }
1187 #endif /* DEBUG */
1188
1189 transition[(U16)link_control_state(ptr_context_data)][(U16)event].func(ptr_context_data, data);
1190
1191 #ifdef DEBUG
1192 (void)TRACE_EVENT_P4("LINK #%d: %s => %s to %s",
1193 ptr_context_data->nsapi,
1194 event_name[(U16)event],
1195 state_name[(U16)old_state],
1196 state_name[(U16)link_control_state(ptr_context_data)]);
1197 #endif /* DEBUG */
1198 }
1199
1200 /*==== END OF FILE ==========================================================*/