comparison g23m-gsm/dl/dl_dcch0.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : DL_DCCH0
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 defines the functions for the stand alone
18 | dedicated control channel (SDCCH) and the fast dedicated
19 | control channel (FACCH) each with SAPI 0 of the component DL
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef DL_DCCH0_C
24 #define DL_DCCH0_C
25
26 #include "config.h"
27 #include "fixedconf.h"
28 #include "condat-features.h"
29
30 #define ENTITY_DL
31
32 /*==== INCLUDES ===================================================*/
33 #include "typedefs.h"
34 #include "string.h"
35 #include "vsi.h"
36 #include "pconst.cdg"
37 #include "custom.h"
38 #include "gsm.h"
39 #include "mon_dl.h"
40 #include "prim.h"
41 #include "pei.h"
42 #include "tok.h"
43 #include "ccdapi.h"
44 #include "dl.h"
45 #include "dl_trc.h"
46
47 /*==== EXPORT =====================================================*/
48 /*==== PRIVAT =====================================================*/
49 LOCAL void dcch0_resume_reconnect_req (T_PRIM * prim,
50 U8 ch_type);
51 /*==== VARIABLES ==================================================*/
52 /*==== FUNCTIONS ==================================================*/
53 /*
54 +--------------------------------------------------------------------+
55 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
56 | STATE : code ROUTINE : sdcch0_init_dl_data |
57 +--------------------------------------------------------------------+
58
59 PURPOSE : Initialisation of DCCH data (SAPI 0) for an instance.
60
61 */
62
63 GLOBAL void dcch0_init_dl_data (void)
64 {
65 GET_INSTANCE_DATA;
66 T_CCH *pcch = &dl_data->cch[C_DCCH0];
67
68 TRACE_FUNCTION ("dcch0_init_dl_data()");
69
70 memset (pcch, 0, sizeof (T_CCH));
71
72 dcch3_init_dl_data (); /*Disabling SAPI 3 connections */
73
74 com_clear_queue (PS_SAPI_0);
75 dl_data->rr_short_pd_buffer.l_buf = 0;
76
77 if (dl_data->dcch0_in_msg)
78 {
79 COM_FREE_POINTER (dl_data->dcch0_in_msg);
80 dl_data->dcch0_in_msg = NULL;
81 }
82
83 dl_data->RR_dedicated = FALSE;
84 dl_data->dcch0_ch_type = 0;
85 dl_data->dcch0_disc_request = FALSE;
86
87 #if defined(DELAYED_SABM)
88 dl_data->dcch0_sabm_delay = 0;
89 dl_data->dcch0_sabm_flag = NOT_PRESENT_8BIT;
90 #endif /* DELAYED_SABM */
91 #if defined(DELAYED_RELEASE_IND)
92 dl_data->release_ind_delay = 0;
93 dl_data->release_ind_ch_type = NOT_PRESENT_8BIT;
94 #endif /* DELAYED_RELEASE_IND */
95 set_channel_state(C_DCCH0, STATE_IDLE_DL);
96
97 sacch0_init_dl_data ();
98 }
99
100 #if defined(DELAYED_SABM)
101 GLOBAL void dcch0_delay_sabm (T_CCH *pcch)
102 {
103 GET_INSTANCE_DATA;
104 BOOL send_sabm = FALSE;
105
106 if (dl_data->dcch0_sabm_flag EQ NOT_PRESENT_8BIT)
107 {
108 if ((pcch->ch_type EQ L2_CHANNEL_FACCH_F) OR (pcch->ch_type EQ L2_CHANNEL_FACCH_H))
109 { /* start delay */
110 pcch->vtx = EMPTY_CMD; /* send dummy only */
111 dl_data->dcch0_sabm_flag = SABM_CMD;
112 dl_data->dcch0_sabm_delay = DL_FACCH_SABM_DELAY_VALUE;
113 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, pcch->ch_type, "delay SABM on FACCH");
114 }
115 else
116 { /* but for FACCH only */
117 send_sabm = TRUE;
118 }
119 }
120 else /* this part is called also called during uplink opportunity */
121 { /* pending delay */
122 if (dl_data->dcch0_sabm_delay > 0)
123 {
124 dl_data->dcch0_sabm_delay--;
125 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, pcch->ch_type, "pending delayed SABM");
126 }
127 else
128 {/* finishing delay, send SABM with the current (next) uplink opportunity */
129 #if !defined(DL_TRACE_ENABLED)
130 TRACE_EVENT ("delayed SABM");
131 #endif /* ! DL_TRACE_ENABLED*/
132 dl_data->dcch0_sabm_flag = NOT_PRESENT_8BIT;
133 send_sabm = TRUE;
134 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, pcch->ch_type, "send delayed SABM");
135 }
136 }
137
138 if (send_sabm)
139 {
140 pcch->vtx = SABM_CMD;
141 pcch->time_flag = TRUE;
142 pcch->rc = 0;
143 set_channel_state (C_DCCH0, STATE_CONTENTION_RESOLUTION);
144 }
145 }
146
147
148 #endif /* DELAYED_SABM */
149
150 /*
151 +--------------------------------------------------------------------+
152 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
153 | STATE : code ROUTINE : sdcch0_establish_req |
154 +--------------------------------------------------------------------+
155
156 PURPOSE : Establish Request for SDCCH SAPI 0.
157
158 */
159
160 GLOBAL void dcch0_establish_req (T_DL_ESTABLISH_REQ * est_req)
161 {
162 GET_INSTANCE_DATA;
163 T_CCH *pcch = &dl_data->cch[C_DCCH0];
164
165 TRACE_FUNCTION ("sdcch0_establish_req()");
166
167 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, est_req->ch_type, "est req");
168
169 dl_data->dcch0_ch_type = pcch->ch_type = est_req->ch_type;
170 TRACE_EVENT_WIN_P1 ("set dcch0_ch_type=%s", CH_TYPE_NAME[dl_data->dcch0_ch_type]);
171
172 dl_data->dcch0_unserved = com_queue_awaiting_transmission (PS_SAPI_0) ?
173 DL_UNSERVED : DL_ALL_DONE;
174 switch (dl_data->state[C_DCCH0])
175 {
176 case STATE_IDLE_DL:
177 /*
178 * initialize sacch buffer
179 */
180 dl_data->sacch_act_buffer = meas_report_no_nc;
181 dl_data->sacch_last_buffer= meas_report_no_nc;
182
183 com_clear_queue (PS_SAPI_0);
184 pcch->contention_resolution = TRUE;
185 dl_data->dcch0_queue.switch_buffer = (T_DL_DATA_REQ*)est_req;
186 dl_data->dcch0_disc_request = FALSE;
187 #if defined(DELAYED_SABM)
188 dcch0_delay_sabm(pcch);
189 #else /* DELAYED_SABM */
190 pcch->vtx = SABM_CMD;
191 pcch->time_flag = TRUE;
192 pcch->rc = 0;
193 set_channel_state (C_DCCH0, STATE_CONTENTION_RESOLUTION);
194 #endif /* DELAYED_SABM */
195 TRACE_EVENT_WIN_P5 ("EST_REQ: %s SAPI=%u vtx=%s (%s#%u)", CH_TYPE_NAME[pcch->ch_type],
196 est_req->sapi, VTX_NAME[pcch->vtx],
197 __FILE10__, __LINE__);
198 #if defined(DELAYED_SABM)
199 dcch0_delay_sabm(pcch);
200 #endif /* DELAYED_SABM */
201 break;
202
203 case STATE_MULTIPLE_FRAME_ESTABLISHED:
204 case STATE_TIMER_RECOVERY:
205 if (est_req->sdu.l_buf EQ 0)
206 {
207 dcch3_init_dl_data (); /*Disabling SAPI 3 connections */
208 com_clear_queue (PS_SAPI_0);
209 pcch->T200_counter = 0;
210 pcch->contention_resolution = FALSE;
211 pcch->vtx = SABM_CMD;
212 pcch->time_flag = TRUE;
213 pcch->rc = 0;
214 set_channel_state (C_DCCH0, STATE_CONTENTION_RESOLUTION);
215 TRACE_EVENT_WIN_P5 ("EST_REQ: %s SAPI=%u vtx=%s (%s#%u)", CH_TYPE_NAME[pcch->ch_type],
216 est_req->sapi, VTX_NAME[pcch->vtx],
217 __FILE10__, __LINE__);
218 }
219 else
220 {
221 dcch0_mdl_release_req ();
222 }
223 COM_FREE_POINTER (est_req);
224 break;
225
226 default:
227 COM_FREE_POINTER (est_req);
228 dcch0_mdl_release_req ();
229 break;
230 }
231 }
232
233 /*
234 +--------------------------------------------------------------------+
235 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
236 | STATE : code ROUTINE : sdcch0_resume_req |
237 +--------------------------------------------------------------------+
238
239 PURPOSE : Resume Request for SDCCH (SAPI 0).
240
241 */
242
243 GLOBAL void dcch0_resume_req (T_DL_RESUME_REQ * resume_req)
244 {
245
246 TRACE_FUNCTION ("dcch0_resume_req()");
247
248 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, resume_req->ch_type, "resume req");
249
250 dcch0_resume_reconnect_req( (T_PRIM *)D2P(resume_req), resume_req->ch_type);
251 }
252
253 /*
254 +--------------------------------------------------------------------+
255 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
256 | STATE : code ROUTINE : sdcch0_reconnect_req |
257 +--------------------------------------------------------------------+
258
259 PURPOSE : Reconnect Request for SDCCH (SAPI 0).
260
261 */
262
263 GLOBAL void dcch0_reconnect_req (T_DL_RECONNECT_REQ * reconnect_req)
264 {
265
266 TRACE_FUNCTION ("dcch0_reconnect_req()");
267
268 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, reconnect_req->ch_type, "reconn req");
269
270 dcch0_resume_reconnect_req( (T_PRIM *)D2P (reconnect_req),reconnect_req->ch_type);
271 }
272
273 /*
274 +--------------------------------------------------------------------+
275 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
276 | STATE : code ROUTINE : dcch0_res_recon_req |
277 +--------------------------------------------------------------------+
278
279 PURPOSE : This function processes Resume Request and Reconnect Request
280 for SDCCH (SAPI 0).
281
282 */
283 LOCAL void dcch0_resume_reconnect_req (T_PRIM * prim,
284 U8 ch_type)
285 {
286 GET_INSTANCE_DATA;
287 TRACE_FUNCTION ("dcch0_resume_reconnect_req()");
288
289 switch (dl_data->state[C_DCCH0])
290 {
291 case STATE_SUSPENDED:
292 case STATE_IDLE_DL:
293 {
294 T_CCH *pcch = &dl_data->cch[C_DCCH0];
295
296 dl_data->dcch0_ch_type = pcch->ch_type = ch_type;
297
298 TRACE_EVENT_WIN_P1 ("set dcch0_ch_type=%s", CH_TYPE_NAME[dl_data->dcch0_ch_type]);
299
300 com_restore_queue(PS_SAPI_0, (T_DL_DATA_REQ*)P2D(prim));
301
302 pcch->contention_resolution = FALSE;
303
304 #if defined(DELAYED_SABM)
305 dcch0_delay_sabm(dl_data, pcch);
306 #else /* DELAYED_SABM */
307 pcch->vtx = SABM_CMD;
308 pcch->time_flag = TRUE;
309 pcch->rc = 0;
310 set_channel_state (C_DCCH0, STATE_CONTENTION_RESOLUTION);
311 #endif /* DELAYED_SABM */
312
313 if(prim->custom.opc EQ DL_RECONNECT_REQ)
314 {
315 TRACE_EVENT_WIN_P5 ("RECONN_REQ: %s SAPI=%u vtx=%s (%s#%u)", CH_TYPE_NAME[pcch->ch_type],
316 PS_SAPI_0, VTX_NAME[pcch->vtx],
317 __FILE10__, __LINE__);
318 }
319 else
320 {
321 TRACE_EVENT_WIN_P5 ("RESUME_REQ: %s SAPI=%u vtx=%s (%s#%u)", CH_TYPE_NAME[pcch->ch_type],
322 PS_SAPI_0, VTX_NAME[pcch->vtx],
323 __FILE10__, __LINE__);
324
325 /* invalid measurement report first */
326 sacch0_reset_meas ();
327 }
328 break;
329 }
330 default:
331 {
332 COM_FREE_POINTER (P2D(prim));
333 }
334 break;
335 }/* endswitch */
336 }
337
338 /*
339 +--------------------------------------------------------------------+
340 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
341 | STATE : code ROUTINE : sdcch0_release_req |
342 +--------------------------------------------------------------------+
343
344 PURPOSE : Release Request for SDCCH (SAPI 0).
345
346 */
347
348 GLOBAL BOOL dcch0_release_req (T_DL_RELEASE_REQ * release_req)
349 {
350 GET_INSTANCE_DATA;
351 BOOL bFree = TRUE;
352
353 TRACE_FUNCTION ("dcch0_release_req()");
354
355 if (release_req->mode EQ DL_LOCAL_END_RELEASE)
356 {
357 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, release_req->ch_type, "local end release req");
358 dcch0_init_dl_data ();
359 bFree = FALSE;
360 }
361 else
362 {
363 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, release_req->ch_type, "normal release req");
364 dl_data->cch[C_DCCH0].ch_type = release_req->ch_type;
365 switch (dl_data->state[C_DCCH0])
366 {
367 default:
368 bFree = FALSE;
369 break;
370
371 case STATE_CONTENTION_RESOLUTION:
372 case STATE_MULTIPLE_FRAME_ESTABLISHED:
373 case STATE_TIMER_RECOVERY:
374 if (!dl_data->dcch0_disc_request AND (dl_data->cch[C_DCCH0].vtx EQ RR_CMD))
375 {
376 dl_data->dcch0_disc_request = TRUE;
377 dcch3_init_dl_data (); /*Disabling SAPI 3 connections */
378 }
379 else
380 {
381 dcch3_init_dl_data (); /*Disabling SAPI 3 connections */
382 com_prepare_DISC (C_DCCH0, release_req->sapi);
383 }
384 break;
385
386 case STATE_AWAITING_RELEASE:
387 dl_data->cch[C_DCCH0].T200_counter = 0;
388 break;
389 }
390 }
391
392 if (bFree EQ FALSE)
393 {
394 PREUSE (release_req, release_cnf, DL_RELEASE_CNF);
395 release_cnf->indication =
396 com_queue_awaiting_transmission (PS_SAPI_0) ? DL_UNSERVED : DL_ALL_DONE;
397 PSENDX (RR, release_cnf);
398 dcch0_init_dl_data ();
399 }
400
401 return bFree;
402 }
403
404 /*
405 +--------------------------------------------------------------------+
406 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
407 | STATE : code ROUTINE : sdcch0_mdl_release_req |
408 +--------------------------------------------------------------------+
409
410 PURPOSE : Release Request from Mobility Management for SDCCH (SAPI 0).
411
412 */
413
414 GLOBAL void dcch0_mdl_release_req (void)
415 {
416 GET_INSTANCE_DATA;
417 TRACE_FUNCTION ("dcch0_mdl_release_req()");
418
419 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, dl_data->cch[C_DCCH0].ch_type, "mdl rel req");
420
421 switch (dl_data->state[C_DCCH0])
422 {
423 case STATE_CONTENTION_RESOLUTION:
424 case STATE_AWAITING_RELEASE:
425 drr_dl_release_cnf (dl_data->cch[C_DCCH0].ch_type, PS_SAPI_0, TRUE);
426 break;
427 case STATE_MULTIPLE_FRAME_ESTABLISHED:
428 case STATE_TIMER_RECOVERY:
429 drr_dl_release_ind (dl_data->cch[C_DCCH0].ch_type, PS_SAPI_0, NOT_PRESENT_8BIT, TRUE);
430 break;
431 default:
432 break;
433 }
434 }
435
436 /*
437 +--------------------------------------------------------------------+
438 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
439 | STATE : code ROUTINE : sdcch0_suspend_req |
440 +--------------------------------------------------------------------+
441
442 PURPOSE : Suspend Request for SDCCH (SAPI 0).
443
444 */
445
446 GLOBAL void dcch0_suspend_req (T_DL_SUSPEND_REQ * suspend_req)
447 {
448 GET_INSTANCE_DATA;
449 T_CCH *pcch = &dl_data->cch[C_DCCH0];
450
451 TRACE_FUNCTION ("dcch0_suspend_req()");
452
453 DL_OFFLINE_TRACE (TRACE_DL_EVENT, C_DCCH0, suspend_req->ch_type, "suspend req");
454
455 pcch->ch_type = suspend_req->ch_type;
456
457 TRACE_EVENT_WIN_P1 ("reset dcch0_ch_type=%s ->0", CH_TYPE_NAME[dl_data->dcch0_ch_type]);
458 dl_data->dcch0_ch_type = 0;
459
460 switch (dl_data->state[C_DCCH0])
461 {
462 case STATE_CONTENTION_RESOLUTION:
463 case STATE_MULTIPLE_FRAME_ESTABLISHED:
464 case STATE_TIMER_RECOVERY:
465 case STATE_AWAITING_RELEASE:
466 pcch->T200_counter = 0;
467 pcch->time_flag = FALSE;
468 pcch->contention_resolution = FALSE;
469 set_channel_state (C_DCCH0, STATE_SUSPENDED);
470 dcch3_init_dl_data (); /* Disabling SAPI 3 connections */
471
472 #if 0 /* yes, from now DL sends measurement reports also in suspended state */
473 /*
474 * no further measurement reports
475 */
476 sacch0_reset_meas (dl_data);
477 #endif /* 0|1 */
478 break;
479
480 default:
481 TRACE_EVENT ("INVALID SUSPEND STATE");
482 break;
483 }
484 COM_FREE_POINTER (suspend_req);
485
486 TRACE_EVENT_WIN_P5 ("SUSPEND_REQ: %s SAPI=%u vtx=%s (%s#%u)", CH_TYPE_NAME[pcch->ch_type],
487 PS_SAPI_0, VTX_NAME[pcch->vtx],
488 __FILE10__, __LINE__);
489 }
490
491 /*
492 +--------------------------------------------------------------------+
493 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
494 | STATE : code ROUTINE : dcch0_check_disc |
495 +--------------------------------------------------------------------+
496
497 PURPOSE : DISC command frame on DCCH0.
498
499 */
500
501 GLOBAL int dcch0_check_disc (int send)
502 {
503 GET_INSTANCE_DATA;
504 TRACE_FUNCTION ("dcch0_check_disc()");
505
506 if (dl_data->dcch0_disc_request AND !(dl_data->cch[C_DCCH0].vtx EQ RR_CMD))
507 {
508 dcch3_init_dl_data (); /*Disabling SAPI 3 connections */
509 com_prepare_DISC (C_DCCH0, PS_SAPI_0);
510 dl_data->dcch0_disc_request = FALSE;
511 #if defined(DELAYED_SABM)
512 dl_data->dcch0_sabm_flag = NOT_PRESENT_8BIT; /* delete pending delayed SABM */
513 #endif /* DELAYED_SABM */
514 return uplink_awaiting_release (C_DCCH0, PS_SAPI_0);
515 }
516 else
517 return send;
518 }
519
520 /*
521 +--------------------------------------------------------------------+
522 | PROJECT : GSM-PS (6147) MODULE : DL_SDCCH |
523 | STATE : code ROUTINE : dcch0_data_req |
524 +--------------------------------------------------------------------+
525
526 PURPOSE : Data Request on SDCCH (SAPI 0).
527
528 */
529
530 GLOBAL void dcch0_data_req (T_DL_DATA_REQ * data_req)
531 {
532 GET_INSTANCE_DATA;
533 TRACE_FUNCTION ("sdcch0_data_req()");
534
535 dl_data->cch[C_DCCH0].ch_type = data_req->ch_type;
536
537 switch (dl_data->state[C_DCCH0])
538 {
539 case STATE_MULTIPLE_FRAME_ESTABLISHED:
540 case STATE_TIMER_RECOVERY:
541 case STATE_SUSPENDED:
542 case STATE_CONTENTION_RESOLUTION:
543 com_store_queue (PS_SAPI_0, data_req);
544 break;
545
546 default:
547 COM_FREE_POINTER (data_req);
548 break;
549 }
550 }
551
552 #endif /* !DL_DCCH0_C */