comparison src/g23m-gprs/llc/llc_llmep.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This modul is part of the entity LLC and implements all
18 | functions to handles the incoming primitives as described in
19 | the SDL-documentation (LLME-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_LLMEP_C
24 #define LLC_LLMEP_C
25 #endif
26
27 #define ENTITY_LLC
28
29 /*==== INCLUDES =============================================================*/
30
31 #include "typedefs.h" /* to get Condat data types */
32 #include "vsi.h" /* to get a lot of macros */
33 #include "macdef.h"
34 #include "gprs.h"
35 #include "gsm.h" /* to get a lot of macros */
36 #include "cnf_llc.h" /* to get cnf-definitions */
37 #include "mon_llc.h" /* to get mon-definitions */
38 #include "prim.h" /* to get the definitions of used SAP and directions */
39 #include "llc.h" /* to get the global entity definitions */
40
41 #include "llc_f.h" /* to get global functions, e.g. llc_init_parameters */
42 #include "llc_llmef.h" /* to get local LLME functions */
43 #include "llc_us.h" /* to get signal interface to U */
44 #include "llc_itxs.h" /* to get signal interface to ITX */
45 #include "llc_irxs.h" /* to get signal interface to IRX */
46 #include "llc_uitxs.h" /* to get signal interface to UITX */
47 #include "llc_uirxs.h" /* to get signal interface to UIRX */
48 #include "llc_t200s.h" /* to get signal interface to T200 */
49 #include "llc_txs.h" /* to get signal interface to TX */
50 #include "llc_rxs.h" /* to get signal interface to RX */
51
52 /*==== CONST ================================================================*/
53
54 /*==== LOCAL VARS ===========================================================*/
55
56 /*==== PRIVATE FUNCTIONS ====================================================*/
57
58 /*==== PUBLIC FUNCTIONS =====================================================*/
59
60
61
62 /*
63 +------------------------------------------------------------------------------
64 | Function : llme_llgmm_assign_req
65 +------------------------------------------------------------------------------
66 | Description : Handles the primitive LLGMM_ASSIGN_REQ
67 |
68 | Parameters : *llgmm_assign_req - Ptr to primitive payload
69 |
70 +------------------------------------------------------------------------------
71 */
72 GLOBAL void llme_llgmm_assign_req ( T_LLGMM_ASSIGN_REQ *llgmm_assign_req )
73 {
74 T_SAPI sapi;
75
76
77 TRACE_FUNCTION( "llme_llgmm_assign_req" );
78
79 switch( GET_STATE( LLME ) )
80 {
81 case LLME_TLLI_UNASSIGNED:
82 /*
83 * ATTENTION: Every ASSIGN_REQ primitive must contain a valid new_tlli
84 * when LLC is unassigned, otherwise it should be a protocol error...?
85 * Therefore this check could be omitted.
86 */
87 #ifdef LL_2to1
88 if (llgmm_assign_req->new_tlli == PS_TLLI_INVALID)
89 #else
90 if (llgmm_assign_req->new_tlli == LLGMM_TLLI_INVALID)
91 #endif
92 {
93 PFREE (llgmm_assign_req);
94 TRACE_ERROR ("LLME in state TLLI_UNASSIGNED and new_tlli is invalid!");
95 }
96 else /* LLGMM_TLLI_VALID */
97 {
98 TRACE_1_INFO("TLLI 0x%.8X assigned", llgmm_assign_req->new_tlli);
99
100 llc_data->tlli_new = llgmm_assign_req->new_tlli;
101 llc_data->tlli_old = llgmm_assign_req->old_tlli;
102
103 llme_init_cipher (llgmm_assign_req->llgmm_kc,
104 llgmm_assign_req->ciphering_algorithm);
105
106 PFREE (llgmm_assign_req);
107
108 /*
109 * Initialises the LLC layer parameters.
110 * NOTE: IOV-UI and IOV-I[] are initialised the second time with this
111 * function call because they were already set in llme_init_cipher().
112 */
113 llc_init_parameters();
114
115 /*
116 * Label ASSIGN
117 */
118
119 SET_STATE (LLME, LLME_TLLI_ASSIGNED);
120
121 /*
122 * ATTENTION:
123 * The following loop implies that all SAPIs are odd numbers beginning
124 * with 1!
125 */
126 #ifdef LL_2to1
127 for (sapi = PS_SAPI_1; sapi <= PS_SAPI_11; sapi += 2)
128 #else
129 for (sapi = LL_SAPI_1; sapi <= LL_SAPI_11; sapi += 2)
130 #endif
131 {
132 SWITCH_LLC (sapi);
133
134 sig_llme_u_assign_req();
135 sig_llme_uitx_assign_req();
136 sig_llme_uirx_assign_req();
137 sig_llme_t200_assign_req();
138
139 #ifdef LL_2to1
140 if ((sapi != PS_SAPI_1) && (sapi != PS_SAPI_7))
141 #else
142 if ((sapi != LL_SAPI_1) && (sapi != LL_SAPI_7))
143 #endif
144 {
145 sig_llme_itx_assign_req();
146 sig_llme_irx_assign_req();
147 }
148 }
149
150 sig_llme_rx_assign_req();
151 sig_llme_tx_assign_req();
152
153 llc_init_requested_xid();
154 }
155 break;
156
157 case LLME_TLLI_ASSIGNED_SUSPENDED:
158 /*
159 * No break
160 */
161 case LLME_TLLI_ASSIGNED:
162 llc_data->tlli_new = llgmm_assign_req->new_tlli;
163 llc_data->tlli_old = llgmm_assign_req->old_tlli;
164
165 llme_init_cipher (llgmm_assign_req->llgmm_kc,
166 llgmm_assign_req->ciphering_algorithm);
167
168 #ifdef LL_2to1
169 if (llgmm_assign_req->new_tlli EQ PS_TLLI_INVALID)
170 #else
171 if (llgmm_assign_req->new_tlli EQ LLGMM_TLLI_INVALID)
172 #endif
173 {
174 TRACE_0_INFO("TLLI unassigned");
175
176 /*
177 * Label UNASSIGN
178 */
179
180 SET_STATE (LLME, LLME_TLLI_UNASSIGNED);
181
182 /*
183 * ATTENTION:
184 * The following loop implies that all SAPIs are odd numbers beginning
185 * with 1!
186 */
187 #ifdef LL_2to1
188 for (sapi = PS_SAPI_1; sapi <= PS_SAPI_11; sapi += 2)
189 #else
190 for (sapi = LL_SAPI_1; sapi <= LL_SAPI_11; sapi += 2)
191 #endif
192 {
193 SWITCH_LLC (sapi);
194
195 sig_llme_u_unassign_req();
196 sig_llme_uitx_unassign_req();
197 sig_llme_uirx_unassign_req();
198 sig_llme_t200_unassign_req();
199
200 if ((sapi != LL_SAPI_1) && (sapi != LL_SAPI_7))
201 {
202 sig_llme_itx_unassign_req();
203 sig_llme_irx_unassign_req();
204 }
205 }
206
207 sig_llme_rx_unassign_req();
208 sig_llme_tx_unassign_req();
209
210 /*
211 * Clear suspended mode with unassign.
212 */
213 llc_data->suspended = FALSE;
214
215 /*
216 * In case we have suspended GRLC we have to resume GRLC to
217 * 'normal operation'
218 */
219 if (llc_data->grlc_suspended == TRUE)
220 {
221 /*
222 * Resume TX operation and indicate, that GRLC was suspened.
223 */
224 sig_llme_tx_resume_req (llc_data->grlc_suspended);
225
226 llc_data->grlc_suspended = FALSE;
227
228 /* {
229 PALLOC (grr_resume_req, GRR_RESUME_REQ);
230 PSEND (hCommGRR, grr_resume_req);
231 }*/
232 }
233
234 PFREE (llgmm_assign_req);
235 }
236 else /* LLGMM_TLLI_VALID */
237 {
238 TRACE_1_INFO("TLLI 0x%.8X (re-)assigned", llgmm_assign_req->new_tlli);
239 PFREE (llgmm_assign_req);
240 }
241 break;
242
243 default:
244 PFREE (llgmm_assign_req);
245 TRACE_ERROR( "LLGMM_ASSIGN_REQ unexpected" );
246 break;
247 }
248
249 } /* llme_llgmm_assign_req() */
250
251
252
253 /*
254 +------------------------------------------------------------------------------
255 | Function : llme_llgmm_trigger_req
256 +------------------------------------------------------------------------------
257 | Description : Handles the primitive LLGMM_TRIGGER_REQ
258 |
259 | Parameters : *llgmm_trigger_req - Ptr to primitive payload
260 |
261 +------------------------------------------------------------------------------
262 */
263 GLOBAL void llme_llgmm_trigger_req ( T_LLGMM_TRIGGER_REQ *llgmm_trigger_req )
264 {
265 TRACE_FUNCTION( "llme_llgmm_trigger_req" );
266
267 switch( GET_STATE( LLME ) )
268 {
269 case LLME_TLLI_ASSIGNED:
270 /* No break. */
271 case LLME_TLLI_ASSIGNED_SUSPENDED:
272 /*
273 * Switch LLC to SAPI 1 in case TX forwards the trigger request to UITX.
274 */
275 SWITCH_LLC (LL_SAPI_1);
276
277 sig_llme_tx_trigger_req (llgmm_trigger_req->trigger_cause);
278
279 PFREE (llgmm_trigger_req);
280 break;
281 default:
282 PFREE (llgmm_trigger_req);
283 TRACE_ERROR( "LLGMM_TRIGGER_REQ unexpected" );
284 break;
285 }
286
287 } /* llme_llgmm_trigger_req() */
288
289
290
291 /*
292 +------------------------------------------------------------------------------
293 | Function : llme_llgmm_suspend_req
294 +------------------------------------------------------------------------------
295 | Description : Handles the primitive LLGMM_SUSPEND_REQ
296 |
297 | Parameters : *llgmm_suspend_req - Ptr to primitive payload
298 |
299 +------------------------------------------------------------------------------
300 */
301 GLOBAL void llme_llgmm_suspend_req ( T_LLGMM_SUSPEND_REQ *llgmm_suspend_req )
302 {
303 T_SAPI sapi;
304
305
306 TRACE_FUNCTION( "llme_llgmm_suspend_req" );
307
308 TRACE_1_PARA("cause:%d", llgmm_suspend_req->susp_cause );
309
310 switch( GET_STATE( LLME ) )
311 {
312 case LLME_TLLI_ASSIGNED:
313 TRACE_0_INFO("LLC suspended");
314
315 /*
316 * Set global suspended indicator for the other services.
317 */
318 llc_data->suspended = TRUE;
319
320 SET_STATE (LLME, LLME_TLLI_ASSIGNED_SUSPENDED);
321
322 /*
323 * ATTENTION:
324 * The following loop implies that all the relevant SAPIs are the odd
325 * numbers from 3 to 11 (except 7)
326 */
327 for (sapi = LL_SAPI_3; sapi <= LL_SAPI_11; sapi += 2)
328 {
329 SWITCH_LLC (sapi);
330
331 if (sapi != LL_SAPI_7)
332 {
333 sig_llme_itx_suspend_req();
334 }
335 }
336
337 /*
338 * No break!
339 */
340 case LLME_TLLI_ASSIGNED_SUSPENDED:
341 /*
342 * In case of RAU suspend GRLC if not already done
343 */
344 if ( (llc_data->grlc_suspended == FALSE) AND
345 (llgmm_suspend_req->susp_cause == LLGMM_RAU) )
346 {
347 sig_llme_tx_suspend_req ();
348
349 llc_data->grlc_suspended = TRUE;
350
351 {
352 PALLOC (grlc_activate_gmm_queue_req, GRLC_ACTIVATE_GMM_QUEUE_REQ);
353 PSEND (hCommGRLC, grlc_activate_gmm_queue_req);
354 }
355 }
356
357 break;
358
359 default:
360 TRACE_ERROR( "LLGMM_SUSPEND_REQ unexpected" );
361 break;
362
363 }
364 if ( (llgmm_suspend_req->susp_cause == LLGMM_LIMITED) OR
365 (llgmm_suspend_req->susp_cause == LLGMM_NO_GPRS_SERVICE))
366 /* init current values */
367 #ifdef REL99
368 llc_data->cur_pfi = LL_PFI_SIGNALING;
369 #endif
370 llc_data->cur_qos.delay = LL_DELAY_SUB;
371 llc_data->cur_qos.relclass = LL_NO_REL;
372 llc_data->cur_qos.peak = LL_PEAK_SUB;
373 llc_data->cur_qos.preced = LL_PRECED_SUB;
374 llc_data->cur_qos.mean = LL_MEAN_SUB;
375 llc_data->cur_radio_prio = LL_RADIO_PRIO_1;
376 PFREE (llgmm_suspend_req);
377
378 } /* llme_llgmm_suspend_req() */
379
380
381
382 /*
383 +------------------------------------------------------------------------------
384 | Function : llme_llgmm_resume_req
385 +------------------------------------------------------------------------------
386 | Description : Handles the primitive LLGMM_RESUME_REQ
387 |
388 | Parameters : *llgmm_resume_req - Ptr to primitive payload
389 |
390 +------------------------------------------------------------------------------
391 */
392 GLOBAL void llme_llgmm_resume_req ( T_LLGMM_RESUME_REQ *llgmm_resume_req )
393 {
394 T_SAPI sapi;
395
396
397 TRACE_FUNCTION( "llme_llgmm_resume_req" );
398
399 switch( GET_STATE( LLME ) )
400 {
401 case LLME_TLLI_ASSIGNED_SUSPENDED:
402 TRACE_0_INFO("LLC resumed");
403
404 /*
405 * Clear global suspended indicator for the other services.
406 */
407 llc_data->suspended = FALSE;
408
409 SET_STATE (LLME, LLME_TLLI_ASSIGNED);
410
411 /*
412 * FIRST! indicate to TX that we resume normal operation and
413 * that LLC/GRLC flow control should be reseted in case GRLC was
414 * suspened.
415 */
416 sig_llme_tx_resume_req (llc_data->grlc_suspended);
417
418 /*
419 * Reset GRLC, if suspended, to 'normal operation'
420 */
421 if (llc_data->grlc_suspended == TRUE)
422 {
423 /* PALLOC (grr_resume_req, GRR_RESUME_REQ);
424 PSEND (hCommGRR, grr_resume_req);*/
425
426 llc_data->grlc_suspended = FALSE;
427 }
428
429 /*
430 * ATTENTION:
431 * The following loop implies that all the relevant SAPIs are the odd
432 * numbers from 3 to 11 (except 7)
433 */
434 for (sapi = LL_SAPI_3; sapi <= LL_SAPI_11; sapi += 2)
435 {
436 SWITCH_LLC (sapi);
437
438 if (sapi != LL_SAPI_7)
439 {
440 sig_llme_itx_resume_req();
441 }
442 }
443 break;
444
445 default:
446 TRACE_ERROR( "LLGMM_RESUME_REQ unexpected" );
447 break;
448 }
449
450 PFREE (llgmm_resume_req);
451
452 } /* llme_llgmm_resume_req() */
453