comparison src/g23m-gprs/upm/upm_sndcp_control.c @ 197:2cf312e56ee7

src/g23m-gprs/upm: import from LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 Oct 2016 01:21:46 +0000
parents
children
comparison
equal deleted inserted replaced
196:a04cde1fb771 197:2cf312e56ee7
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: SNDCP 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 /*==== INCLUDES =============================================================*/
24
25 #include "upm.h"
26
27 #include "upm_sndcp_control.h"
28 #include "upm_sndcp_output_handler.h"
29 #include "upm_aci_output_handler.h"
30 #include "upm_sm_output_handler.h"
31 #include "upm_mm_output_handler.h"
32
33 /*==== CONSTS ===============================================================*/
34
35 /*==== TYPES ================================================================*/
36
37 typedef void (*T_UPM_SNDCP_CONTROL_TRANSITION_FUNC)(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
38
39 typedef struct {
40 #ifdef DEBUG
41 T_UPM_SNDCP_CONTROL_EVENT event;
42 #endif /* DEBUG */
43 T_UPM_SNDCP_CONTROL_TRANSITION_FUNC func;
44 } T_UPM_SNDCP_CONTROL_TRANSITION;
45
46 /*==== LOCALS ===============================================================*/
47
48 static void state_event_error (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
49 static void ignored (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
50 static void handle_passive_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
51 static void handle_active_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
52 static void handle_passive_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
53 static void handle_active_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
54 static void handle_deactivate (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
55 static void handle_sn_deactivate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
56 static void handle_modify_llc_link(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
57 static void handle_sn_modify_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
58 static void handle_mmpm_sequence_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
59 static void handle_status_ind (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
60
61 /***********************************************************************
62 * State/Transition Table
63 */
64 static const T_UPM_SNDCP_CONTROL_TRANSITION
65 transition[UPM_SNDCP_CONTROL_NUMBER_OF_STATES]
66 [UPM_LINK_CONTROL_NUMBER_OF_EVENTS] =
67 {
68 { /* S0: UPM SNDCP INACTIVE */
69 M_TRANSITION(UPM_P_SN_ACTIVATE_CNF, state_event_error),
70 M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF, state_event_error),
71 M_TRANSITION(UPM_P_SN_MODIFY_CNF, state_event_error),
72 M_TRANSITION(UPM_P_SN_STATUS_IND, state_event_error),
73 M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND, state_event_error),
74 M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH, handle_passive_activate),
75 M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, handle_active_activate),
76 M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK, state_event_error),
77 M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK, state_event_error)
78 },
79 { /* S1: UPM SNDCP AWAIT ACTIVATE */
80 M_TRANSITION(UPM_P_SN_ACTIVATE_CNF, handle_passive_activate_cnf),
81 M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF, state_event_error),
82 M_TRANSITION(UPM_P_SN_MODIFY_CNF, state_event_error),
83 M_TRANSITION(UPM_P_SN_STATUS_IND, handle_status_ind),
84 M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND, state_event_error),
85 M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH, state_event_error),
86 M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
87 M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK, state_event_error),
88 M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK, handle_deactivate)
89 },
90 { /* S2: UPM SNDCP ACTIVATING */
91 M_TRANSITION(UPM_P_SN_ACTIVATE_CNF, handle_active_activate_cnf),
92 M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF, state_event_error),
93 M_TRANSITION(UPM_P_SN_MODIFY_CNF, state_event_error),
94 M_TRANSITION(UPM_P_SN_STATUS_IND, handle_status_ind),
95 M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND, state_event_error),
96 M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH, state_event_error),
97 M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
98 M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK, state_event_error),
99 M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK, handle_deactivate)
100 },
101 { /* S3: UPM SNDCP ACTIVE */
102 M_TRANSITION(UPM_P_SN_ACTIVATE_CNF, state_event_error),
103 M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF, state_event_error),
104 M_TRANSITION(UPM_P_SN_MODIFY_CNF, state_event_error),
105 M_TRANSITION(UPM_P_SN_STATUS_IND, handle_status_ind),
106 M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND, handle_mmpm_sequence_ind),
107 M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH, state_event_error),
108 M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
109 M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK, handle_modify_llc_link),
110 M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK, handle_deactivate)
111 },
112 { /* S4: UPM SNDCP MODIFYING */
113 M_TRANSITION(UPM_P_SN_ACTIVATE_CNF, state_event_error),
114 M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF, state_event_error),
115 M_TRANSITION(UPM_P_SN_MODIFY_CNF, handle_sn_modify_cnf),
116 M_TRANSITION(UPM_P_SN_STATUS_IND, handle_status_ind),
117 M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND, handle_mmpm_sequence_ind),
118 M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH, state_event_error),
119 M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
120 M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK, state_event_error),
121 M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK, handle_deactivate)
122 },
123 { /* S5: UPM SNDCP DEACTIVATING */
124 M_TRANSITION(UPM_P_SN_ACTIVATE_CNF, state_event_error),
125 M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF, handle_sn_deactivate_cnf),
126 M_TRANSITION(UPM_P_SN_MODIFY_CNF, ignored),
127 M_TRANSITION(UPM_P_SN_STATUS_IND, handle_status_ind),
128 M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND, state_event_error),
129 M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH, state_event_error),
130 M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
131 M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK, state_event_error),
132 M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK, ignored)
133 }
134 };
135
136 /*==== PRIVATE FUNCTIONS ====================================================*/
137
138 /*
139 +------------------------------------------------------------------------------
140 | Function : state_event_error
141 +------------------------------------------------------------------------------
142 | Description : General function used to report state event errors.
143 |
144 | Parameters : ptr_context_data - Not used
145 | data - Not used
146 +------------------------------------------------------------------------------
147 */
148 static void state_event_error(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
149 {
150 (void)TRACE_ERROR("UPM SNDCP Control: STATE EVENT ERROR!");
151 }
152
153 /*
154 +------------------------------------------------------------------------------
155 | Function : ignored
156 +------------------------------------------------------------------------------
157 | Description : General function used for transitions that shall be ignored
158 |
159 | Parameters : ptr_context_data - Not used
160 | data - Not used
161 +------------------------------------------------------------------------------
162 */
163 static void ignored (/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
164 {
165 (void)TRACE_FUNCTION("UPM SNDCP Control: Event ignored.");
166 }
167
168 /*
169 +------------------------------------------------------------------------------
170 | Function : handle_passive_activate
171 +------------------------------------------------------------------------------
172 | Description : Handle UPM_I_SNDCP_AWAIT_ESTABLISH in S0
173 |
174 | Parameters : ptr_context_data - Context data
175 | data - Pointer to compression parameters
176 +------------------------------------------------------------------------------
177 */
178 static void handle_passive_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
179 {
180 (void)TRACE_FUNCTION("handle_passive_activate");
181
182 /* Send SN_ACTIVATE_REQ with establish flag == FALSE */
183 send_sn_activate_req(ptr_context_data, (T_NAS_comp_params *)data, FALSE);
184
185 /* Go to state UPM SNDCP AWAIT ACTIVATE */
186 ptr_context_data->sndcp_control_state = UPM_SNDCP_AWAIT_ACTIVATE;
187
188 #ifndef UPM_WITHOUT_USER_PLANE
189 /* Suspend Uplink Data */
190 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_SUSPEND,
191 (void *)UPM_LINK);
192 #endif /* UPM_WITHOUT_USER_PLANE */
193 }
194
195 /*
196 +------------------------------------------------------------------------------
197 | Function : handle_active_activate
198 +------------------------------------------------------------------------------
199 | Description : Handle UPM_I_SNDCP_ESTABLISH_LLC_LINK in S0
200 |
201 | Parameters : ptr_context_data - Context data
202 | data - Pointer to compression parameters
203 +------------------------------------------------------------------------------
204 */
205 static void handle_active_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
206 {
207 (void)TRACE_FUNCTION("handle_active_activate");
208
209 /* Send SN_ACTIVATE_REQ with establish flag == TRUE */
210 send_sn_activate_req(ptr_context_data, (T_NAS_comp_params *)data, TRUE);
211
212 /* Go to state UPM SNDCP ACTIVATING */
213 ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVATING;
214 }
215
216 /*
217 +------------------------------------------------------------------------------
218 | Function : handle_passive_activate_cnf
219 +------------------------------------------------------------------------------
220 | Description : Handle UPM_P_SN_ACTIVATE_CNF in S1
221 |
222 | Parameters : ptr_context_data - Context data
223 | data - Not used
224 +------------------------------------------------------------------------------
225 */
226 static void handle_passive_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
227 {
228 (void)TRACE_FUNCTION("handle_passive_activate_cnf");
229
230 /* Go to state UPM SNDCP ACTIVE */
231 ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVE;
232
233 #ifndef UPM_WITHOUT_USER_PLANE
234 /* Resume Uplink Data */
235 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_RESUME,
236 (void *)UPM_LINK);
237 #endif /* UPM_WITHOUT_USER_PLANE */
238
239 /* Report link establishment to Link Control */
240 upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_ESTABLISHED, NULL);
241 }
242
243 /*
244 +------------------------------------------------------------------------------
245 | Function : handle_active_activate_cnf
246 +------------------------------------------------------------------------------
247 | Description : Handle UPM_P_SN_ACTIVATE_CNF in S2
248 |
249 | Parameters : ptr_context_data - Context data
250 | data - Not used
251 +------------------------------------------------------------------------------
252 */
253 static void handle_active_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
254 {
255 (void)TRACE_FUNCTION("handle_active_activate_cnf");
256
257 /* Go to state UPM SNDCP ACTIVE */
258 ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVE;
259
260 /* Report link establishment to Link Control */
261 upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_ESTABLISHED,
262 ((T_SN_ACTIVATE_CNF*)data)); /*To pass comp params*/
263 }
264
265 /*
266 +------------------------------------------------------------------------------
267 | Function : handle_deactivate
268 +------------------------------------------------------------------------------
269 | Description : Handle UPM_I_SNDCP_RELEASE_LLC_LINK in S1, S2, S3, or S4.
270 |
271 | Parameters : ptr_context_data - Context data
272 | data - Local flag (rel_ind)
273 +------------------------------------------------------------------------------
274 */
275 static void handle_deactivate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
276 {
277 U32 rel_ind = (U32)data;
278 (void)TRACE_FUNCTION("handle_deactivate");
279
280 /* SN_DEACTIVATE_REQ no longer sent in dispatcher function, so send here. */
281 send_sn_deactivate_req( ptr_context_data->nsapi, (U8)rel_ind);
282
283 /* Go to state UPM SNDCP DEACTIVATING */
284 ptr_context_data->sndcp_control_state = UPM_SNDCP_DEACTIVATING;
285 }
286
287 /*
288 +------------------------------------------------------------------------------
289 | Function : handle_sn_deactivate_cnf
290 +------------------------------------------------------------------------------
291 | Description : Handle UPM_P_SN_DEACTIVATE_CNF in S5
292 |
293 | Parameters : ptr_context_data - Context data
294 | data - Not used
295 +------------------------------------------------------------------------------
296 */
297 static void handle_sn_deactivate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
298 {
299 (void)TRACE_FUNCTION("handle_sn_deactivate_cnf");
300
301 /* Go to state UPM SNDCP INACTIVE */
302 ptr_context_data->sndcp_control_state = UPM_SNDCP_INACTIVE;
303
304 /* Report LLC link release to Link Control */
305 upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_RELEASED, NULL);
306 }
307
308 /*
309 +------------------------------------------------------------------------------
310 | Function : handle_modify_llc_link
311 +------------------------------------------------------------------------------
312 | Description : Handle UPM_I_SNDCP_MODIFY_LLC_LINK
313 |
314 | Parameters : ptr_context_data - Context data
315 | data - Not used
316 +------------------------------------------------------------------------------
317 */
318 static void handle_modify_llc_link(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
319 {
320 (void)TRACE_FUNCTION("handle_modify_llc_link");
321
322 /* At this point, relevant flags in Context Data have been set by Link Control */
323
324 /* Send SN_MODIFY_REQ */
325 send_sn_modify_req(ptr_context_data);
326
327 /* Go to state UPM SNDCP MODIFYING */
328 ptr_context_data->sndcp_control_state = UPM_SNDCP_MODIFYING;
329 }
330
331 /*
332 +------------------------------------------------------------------------------
333 | Function : handle_sn_modify_cnf
334 +------------------------------------------------------------------------------
335 | Description : Handle UPM_P_SN_MODIFY_CNF in S4
336 |
337 | Parameters : ptr_context_data - Context data
338 | data - Not used
339 +------------------------------------------------------------------------------
340 */
341 static void handle_sn_modify_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
342 {
343 (void)TRACE_FUNCTION("handle_sn_modify_cnf");
344
345 /* Go to state UPM SNDCP ACTIVE */
346 ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVE;
347
348 /* Report LLC link modification completion to Link Control */
349 upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_MODIFIED, NULL);
350 }
351
352
353 /*
354 +------------------------------------------------------------------------------
355 | Function : handle_mmpm_sequence_ind
356 +------------------------------------------------------------------------------
357 | Description : Handle UPM_P_MMPM_SEQUENCE_IND
358 |
359 | Parameters : ptr_context_data - Context data
360 | data - sequence number
361 +------------------------------------------------------------------------------
362 */
363 static void handle_mmpm_sequence_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
364 {
365 U32 seq_no = (U32)data;
366 (void)TRACE_FUNCTION("handle_mmpm_sequence_ind");
367
368 /* Set sequence number for this NSAPI */
369 upm_set_sequence_number(ptr_context_data, (U8)seq_no);
370
371 #ifndef UPM_WITHOUT_USER_PLANE
372 /* Uplink Data Control should discard data older than the sequence number
373 * given in data for this NSAPI. */
374 upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_DISCARD,
375 data);
376 #endif /* UPM_WITHOUT_USER_PLANE */
377 }
378
379 /*
380 +------------------------------------------------------------------------------
381 | Function : handle_status_ind
382 +------------------------------------------------------------------------------
383 | Description : Handle UPM_P_SN_STATUS_IND
384 |
385 | Parameters : ptr_context_data - Context data
386 | data - SN_STATUS_IND primitive
387 +------------------------------------------------------------------------------
388 */
389 static void handle_status_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
390 {
391 (void)TRACE_FUNCTION("handle_status_ind");
392
393 TRACE_ASSERT( data != NULL );
394
395 /* If cause is any other than NO_PEER_RESPONSE, SNDCP Control should
396 * deactivate SNDCP. */
397 /*lint -e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
398 if ( (((T_SN_STATUS_IND *)data)->ps_cause.ctrl_value != CAUSE_is_from_llc ||
399 ((T_SN_STATUS_IND *)data)->ps_cause.value.llc_cause
400 !=(U16)CAUSE_LLC_NO_PEER_RES ) &&
401 (((T_SN_STATUS_IND *)data)->ps_cause.ctrl_value != CAUSE_is_from_sndcp ||
402 ((T_SN_STATUS_IND *)data)->ps_cause.value.sn_cause
403 != (U16)CAUSE_SN_NO_PEER_RESPONSE ) )
404 {
405 /* Go to state UPM SNDCP INACTIVE */
406 ptr_context_data->sndcp_control_state = UPM_SNDCP_INACTIVE;
407
408 /*lint +e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
409 /* Report link release to Link Control */
410 upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_RELEASED, data);
411 }
412 }
413
414 /*==== PUBLIC FUNCTIONS =====================================================*/
415
416 /*
417 +------------------------------------------------------------------------------
418 | Function : upm_sndcp_dispatch_mmpm_sequence_ind
419 +------------------------------------------------------------------------------
420 | Description : Helper function for Dispatcher. Dispatches MMPM_SEQUENCE_IND
421 |
422 | Parameters : ptr_prim_data - Pointer to primitive
423 +------------------------------------------------------------------------------
424 */
425 void upm_sndcp_dispatch_mmpm_sequence_ind(T_MMPM_SEQUENCE_IND *ptr_prim_data)
426 {
427 int entries;
428 T_MMPM_npdu_list *entry;
429
430 (void)TRACE_FUNCTION("upm_sndcp_dispatch_mmpm_sequence_ind");
431
432 entries = (int)ptr_prim_data->c_npdu_list;
433 entry = ptr_prim_data->npdu_list;
434
435 /* Loop over NSAPIs in primitive, and store sequence numbers. */
436 while (entries > 0) {
437 struct T_CONTEXT_DATA *context;
438
439 context = upm_get_context_data_from_nsapi(entry->nsapi);
440 if (context != NULL) {
441 upm_sndcp_control(context, UPM_P_MMPM_SEQUENCE_IND,
442 (void *)entry->receive_n_pdu_number_val);
443 } else {
444 (void)TRACE_ERROR("Received sequence numbers for non-existent context!");
445 }
446
447 entries--;
448 }
449
450 send_sn_sequence_req(ptr_prim_data);
451 }
452
453 /*
454 +------------------------------------------------------------------------------
455 | Function : upm_sndcp_dispatch_sn_status_ind
456 +------------------------------------------------------------------------------
457 | Description : Helper function for Dispatcher. Dispatches SN_STATUS_IND
458 |
459 | Parameters : ptr_prim_data - Pointer to primitive
460 +------------------------------------------------------------------------------
461 */
462 void upm_sndcp_dispatch_sn_status_ind(T_SN_STATUS_IND *prim)
463 {
464 int nsapi;
465 struct T_CONTEXT_DATA *context;
466
467 (void)TRACE_FUNCTION("upm_sndcp_dispatch_sn_status_ind");
468
469 /* If cause is any other than NO_PEER_RESPONSE, SNDCP Control should
470 * deactivate SNDCP and inform Session Management. */
471 if ( (prim->ps_cause.ctrl_value != CAUSE_is_from_llc ||
472 prim->ps_cause.value.llc_cause != (U16)CAUSE_LLC_NO_PEER_RES ) &&
473 (prim->ps_cause.ctrl_value != CAUSE_is_from_sndcp ||
474 prim->ps_cause.value.sn_cause != (U16)CAUSE_SN_NO_PEER_RESPONSE )
475 ) {
476 /* Alert state machine */
477 for (nsapi = (int)NAS_NSAPI_5; nsapi < NAS_SIZE_NSAPI; nsapi++) {
478 if ( (prim->nsapi_set & upm_nsapi2nsapi_set(nsapi)) != 0 ) {
479 context = upm_get_context_data_from_nsapi(nsapi);
480 if (context != NULL) {
481 upm_sndcp_control(context, UPM_P_SN_STATUS_IND, prim);
482
483 /* Release context data if applicable (link and DTI both down) */
484 upm_check_for_released_context_and_release(context);
485 }
486 }
487 }
488
489 /* Inform Session Management -- Once for all NSAPIs affected */
490 send_sm_status_req(prim->nsapi_set, (T_PS_sapi)prim->sapi,
491 prim->ps_cause.ctrl_value, prim->ps_cause.value.sn_cause);
492 }
493 /* No action if cause is NO_PEER_RESPONSE */
494 }
495
496 /*
497 +------------------------------------------------------------------------------
498 | Function : upm_sndcp_dispatch_sn_sequence_cnf
499 +------------------------------------------------------------------------------
500 | Description : Helper function for Dispatcher. Dispatches SN_SEQUENCE_CNF
501 |
502 | Parameters : ptr_prim_data - Pointer to primitive
503 +------------------------------------------------------------------------------
504 */
505 void upm_sndcp_dispatch_sn_sequence_cnf(T_SN_SEQUENCE_CNF *prim)
506 {
507 (void)TRACE_FUNCTION("upm_sndcp_dispatch_sn_sequence_cnf");
508
509 /* No action needed but forwarding sequence numbers to MM */
510 send_mmpm_sequence_res(prim);
511 }
512
513 /*
514 +------------------------------------------------------------------------------
515 | Function : upm_sndcp_dispatch_sn_count_cnf
516 +------------------------------------------------------------------------------
517 | Description : Helper function for Dispatcher. Dispatches SN_COUNT_CNF
518 |
519 | Parameters : prim - Pointer to primitive
520 +------------------------------------------------------------------------------
521 */
522 void upm_sndcp_dispatch_sn_count_cnf(T_SN_COUNT_CNF *prim)
523 {
524 (void)TRACE_FUNCTION("upm_sndcp_dispatch_sn_count_cnf");
525
526 /* No action needed but forwarding as UPM_COUNT_CNF */
527 send_upm_count_cnf(prim->nsapi, prim->octets_uplink, prim->octets_downlink,
528 prim->packets_uplink, prim->packets_downlink);
529 }
530
531 /*
532 +------------------------------------------------------------------------------
533 | Function : upm_sndcp_dispatch_upm_count_req
534 +------------------------------------------------------------------------------
535 | Description : Helper function for Dispatcher. Dispatches UPM_COUNT_REQ
536 |
537 | Parameters : prim - Pointer to primitive
538 +------------------------------------------------------------------------------
539 */
540 void upm_sndcp_dispatch_upm_count_req(T_UPM_COUNT_REQ *prim)
541 {
542 (void)TRACE_FUNCTION("upm_sndcp_dispatch_upm_count_req");
543
544 /* No action needed but forwarding as SN_COUNT_REQ */
545 send_sn_count_req(prim->nsapi, prim->reset);
546 }
547
548 /*
549 +------------------------------------------------------------------------------
550 | Function : upm_sndcp_control_init
551 +------------------------------------------------------------------------------
552 | Description : SNDCP Control state machine initialization function
553 |
554 | Parameters : ptr_context_data - Pointer to context data
555 +------------------------------------------------------------------------------
556 */
557 void upm_sndcp_control_init(struct T_CONTEXT_DATA *ptr_context_data)
558 {
559 (void)TRACE_FUNCTION("upm_sndcp_control_init");
560
561 TRACE_ASSERT(ptr_context_data != NULL);
562 /*lint -e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
563 ptr_context_data->sndcp_control_state = UPM_SNDCP_INACTIVE;
564 ptr_context_data->gprs_data.pkt_flow_id = (U8)PS_PKT_FLOW_ID_NOT_PRES;
565 /*lint +e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
566 }
567
568 /*
569 +------------------------------------------------------------------------------
570 | Function : upm_sndcp_control_exit
571 +------------------------------------------------------------------------------
572 | Description : SNDCP Control state machine exit function
573 |
574 | Parameters : ptr_context_data - Pointer to context data
575 +------------------------------------------------------------------------------
576 */
577 void upm_sndcp_control_exit(struct T_CONTEXT_DATA *ptr_context_data)
578 {
579 (void)TRACE_FUNCTION("upm_sndcp_control_exit");
580
581 TRACE_ASSERT(ptr_context_data != NULL);
582 /*lint -e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
583 ptr_context_data->sndcp_control_state = UPM_SNDCP_INACTIVE;
584 ptr_context_data->gprs_data.pkt_flow_id = (U8)PS_PKT_FLOW_ID_NOT_PRES;
585 /*lint +e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
586 }
587
588 /*
589 +------------------------------------------------------------------------------
590 | Function : upm_sndcp_control
591 +------------------------------------------------------------------------------
592 | Description : SNDCP Control state machine
593 |
594 | Parameters : ptr_context_data - Pointer to context data
595 | event - Internal event (see upm_sndcp_control.h)
596 | data - Event dependent parameter
597 +------------------------------------------------------------------------------
598 */
599 void upm_sndcp_control (struct T_CONTEXT_DATA *ptr_context_data,
600 T_UPM_SNDCP_CONTROL_EVENT event,
601 /*@null@*/ void* data)
602 {
603 #ifdef DEBUG
604 T_UPM_SNDCP_CONTROL_STATE old_state;
605 /*@observer@*/
606 static const char *state_name[UPM_SNDCP_CONTROL_NUMBER_OF_STATES] = {
607 "S0_UPM_SNDCP_INACTIVE",
608 "S1_UPM_SNDCP_AWAIT_ACTIVATE",
609 "S2_UPM_SNDCP_ACTIVATING",
610 "S3_UPM_SNDCP_ACTIVE",
611 "S4_UPM_SNDCP_MODIFYING",
612 "S5_UPM_SNDCP_DEACTIVATING"
613 };
614 /*@observer@*/
615 static const char *event_name[UPM_LINK_CONTROL_NUMBER_OF_EVENTS] = {
616 "UPM_P_SN_ACTIVATE_CNF",
617 "UPM_P_SN_DEACTIVATE_CNF",
618 "UPM_P_SN_MODIFY_CNF",
619 "UPM_P_SN_STATUS_IND",
620 "UPM_P_MMPM_SEQUENCE_IND",
621 "UPM_I_SNDCP_AWAIT_ESTABLISH",
622 "UPM_I_SNDCP_ESTABLISH_LLC_LINK",
623 "UPM_I_SNDCP_MODIFY_LLC_LINK",
624 "UPM_I_SNDCP_RELEASE_LLC_LINK"
625 };
626
627 TRACE_ASSERT(ptr_context_data != NULL);
628 TRACE_ASSERT(event < UPM_SNDCP_CONTROL_NUMBER_OF_EVENTS);
629
630 old_state = ptr_context_data->sndcp_control_state;
631
632 if (transition[(U16)old_state][(U16)event].event != event) {
633 (void)TRACE_ERROR("Event table error in upm_sndcp_control!");
634 }
635 #endif /* DEBUG */
636
637 transition[(U16)ptr_context_data->sndcp_control_state][(U16)event].func(ptr_context_data, data);
638
639 #ifdef DEBUG
640 (void)TRACE_EVENT_P4("SNDCP #%d: %s => %s to %s",
641 ptr_context_data->nsapi,
642 event_name[(U16)event],
643 state_name[(U16)old_state],
644 state_name[(U16)ptr_context_data->sndcp_control_state]);
645 #endif /* DEBUG */
646 }
647
648 /*==== END OF FILE ==========================================================*/