comparison src/g23m-gsm/dl/dl_drr.c @ 104:27a4235405c6

src/g23m-gsm: import from LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 04 Oct 2016 18:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
103:76d139c7a25e 104:27a4235405c6
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : DL_DRR
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 distributing
18 | all primitives of the upper layers.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef DL_DRR_C
23 #define DL_DRR_C
24
25 #define ENTITY_DL
26
27 /*==== INCLUDES ===================================================*/
28 #include "typedefs.h"
29 #include <string.h>
30 #include "vsi.h"
31 #include "pconst.cdg"
32 #include "custom.h"
33 #include "gsm.h"
34 #include "mon_dl.h"
35 #include "prim.h"
36 #include "pei.h"
37 #include "tok.h"
38 #include "ccdapi.h"
39 #include "dl.h"
40 #include "dl_em.h"
41 #include "dl_trc.h"
42
43 /*==== EXPORT =====================================================*/
44
45 /*==== PRIVAT =====================================================*/
46 /*==== VARIABLES ==================================================*/
47 /*==== FUNCTIONS ==================================================*/
48 /*
49 +--------------------------------------------------------------------+
50 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
51 | STATE : code ROUTINE : drr_dl_establish_req |
52 +--------------------------------------------------------------------+
53
54 PURPOSE : Reception of a DL_ESTABLISH_REQ primitive.
55
56 */
57
58 GLOBAL void drr_dl_establish_req (T_DL_ESTABLISH_REQ * est_req)
59 {
60 BOOL fRelease;
61 BOOL fInfoAvailable;
62 GET_INSTANCE_DATA;
63
64 TRACE_FUNCTION ("drr_dl_establish_req()");
65
66 if (est_req)
67 {
68 fRelease = FALSE;
69 fInfoAvailable = (est_req->sdu.l_buf NEQ 0);
70
71 TRACE_EVENT_WIN_P3 ("DL_ESTABLISH_REQ ch=%u SAPI=%u fInfoAvailable=%d",
72 est_req->ch_type, est_req->sapi, fInfoAvailable);
73
74 switch (est_req->ch_type)
75 {
76 case L2_CHANNEL_FACCH_F:
77 case L2_CHANNEL_FACCH_H:
78 if ((est_req->sapi EQ 0)/* AND (fInfoAvailable)*/)
79 {
80 dcch0_establish_req (est_req);
81 }
82 else
83 fRelease = TRUE;
84 break;
85 case L2_CHANNEL_SACCH:
86 if ((dl_data->RR_dedicated) AND (est_req->sapi EQ 3) AND (!fInfoAvailable))
87 {
88 dcch3_establish_req (est_req);
89 }
90 else
91 fRelease = TRUE;
92 break;
93 case L2_CHANNEL_SDCCH:
94 if ((est_req->sapi EQ 0)/* AND (fInfoAvailable)*/)
95 {
96 dcch0_establish_req (est_req);
97 }
98 else if ((est_req->sapi EQ 3) AND (!fInfoAvailable))
99 {
100 dcch3_establish_req (est_req);
101 }
102 else
103 fRelease = TRUE;
104 break;
105 default:
106 fRelease = TRUE;
107 break;
108 }/* endswitch */
109
110 if (fRelease)
111 {
112 PREUSE (est_req, rel_ind, DL_RELEASE_IND);
113 #ifndef DL_2TO1
114 rel_ind->cs = NOT_PRESENT_8BIT;
115 #else
116 rel_ind->ps_cause.ctrl_value = CAUSE_is_from_dl;
117 rel_ind->ps_cause.value.dl_cause = NOT_PRESENT_8BIT;
118 #endif /*DL_2TO1*/
119 PSENDX (RR, rel_ind);
120 }
121 }
122 }
123
124 /*
125 +--------------------------------------------------------------------+
126 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
127 | STATE : code ROUTINE : drr_dl_establish_ind |
128 +--------------------------------------------------------------------+
129
130 PURPOSE : Send of a DL_ESTABLISH_IND primitive.
131
132 */
133
134 GLOBAL void drr_dl_establish_ind (UBYTE ch_type,
135 UBYTE sapi, UBYTE indication)
136 {
137 GET_INSTANCE_DATA;
138 #if defined(INVOKE_SIGNAL)
139 if (dl_data->interrupt_context)
140 {
141 sig_invoke_drr_dl_establish_ind (ch_type, sapi, indication);
142 return;
143 }
144 else
145 #endif /* INVOKE_SIGNAL */
146 {
147 PALLOC (est_ind, DL_ESTABLISH_IND);
148
149 TRACE_FUNCTION ("drr_dl_establish_ind()");
150
151 est_ind->ch_type = ch_type;
152 est_ind->sapi = sapi;
153 est_ind->indication = indication;
154 PSENDX (RR, est_ind);
155 }
156 }
157
158 /*
159 +--------------------------------------------------------------------+
160 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
161 | STATE : code ROUTINE : drr_dl_resume_req |
162 +--------------------------------------------------------------------+
163
164 PURPOSE : Reception of a DL_RESUME_REQ primitive.
165
166 */
167
168 GLOBAL void drr_dl_resume_req (T_DL_RESUME_REQ * resume_req)
169 {
170 TRACE_FUNCTION ("drr_dl_resume_req()");
171
172 if (resume_req)
173 {
174 switch (resume_req->ch_type)
175 {
176 case L2_CHANNEL_FACCH_F:
177 case L2_CHANNEL_FACCH_H:
178 case L2_CHANNEL_SDCCH:
179 dcch0_resume_req (resume_req);
180 break;
181 default:
182 COM_FREE_POINTER (resume_req);
183 break;
184 }
185 }
186 }
187
188 /*
189 +--------------------------------------------------------------------+
190 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
191 | STATE : code ROUTINE : drr_dl_reconnect_req |
192 +--------------------------------------------------------------------+
193
194 PURPOSE : Reception of a DL_RECONNECT_REQ primitive.
195
196 */
197
198 GLOBAL void drr_dl_reconnect_req (T_DL_RECONNECT_REQ * reconnect_req)
199 {
200 TRACE_FUNCTION ("drr_dl_reconnect_req()");
201
202 if (reconnect_req)
203 {
204 switch (reconnect_req->ch_type)
205 {
206 case L2_CHANNEL_FACCH_F:
207 case L2_CHANNEL_FACCH_H:
208 case L2_CHANNEL_SDCCH:
209 dcch0_reconnect_req (reconnect_req);
210 break;
211 default:
212 COM_FREE_POINTER (reconnect_req);
213 break;
214 }
215 }
216 }
217
218 /*
219 +--------------------------------------------------------------------+
220 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
221 | STATE : code ROUTINE : drr_dl_release_req |
222 +--------------------------------------------------------------------+
223
224 PURPOSE : Reception of a DL_RELEASE_REQ primitive.
225
226 */
227
228 GLOBAL void drr_dl_release_req (T_DL_RELEASE_REQ * release_req)
229 {
230 TRACE_FUNCTION ("drr_dl_release_req()");
231
232
233 if (release_req)
234 {
235 BOOL bFree = TRUE;
236
237 #if !defined(LATE_LEAVING_DEDICATED)
238 com_leave_dedicated (release_req->ch_type);
239 #endif /* LATE_LEAVING_DEDICATED */
240
241 switch (release_req->ch_type)
242 {
243 case L2_CHANNEL_FACCH_F:
244 case L2_CHANNEL_FACCH_H:
245 case L2_CHANNEL_SDCCH:
246 case L2_CHANNEL_SACCH:
247
248 DL_OFFLINE_TRACE (TRACE_DL_EVENT,
249 release_req->sapi EQ PS_SAPI_0 ? C_DCCH0 : C_DCCH3,
250 release_req->ch_type, "Release Req");
251
252 if (release_req->sapi EQ PS_SAPI_0)
253 {
254 bFree = dcch0_release_req (release_req);
255 }
256 else if (release_req->sapi EQ PS_SAPI_3)
257 {
258 bFree = dcch3_release_req (release_req);
259 }
260 break;
261 default:
262 DL_OFFLINE_TRACE (TRACE_DL_EVENT, TRACE_CH_UNKNOWN, release_req->ch_type, "Release Req");
263 break;
264 }
265
266 if (bFree)
267 {
268 COM_FREE_POINTER (release_req);
269 }
270 }
271 }
272 #ifndef DL_2TO1
273 /*
274 +--------------------------------------------------------------------+
275 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
276 | STATE : code ROUTINE : drr_mdl_release_req |
277 +--------------------------------------------------------------------+
278
279 PURPOSE : Reception of a MDL_RELEASE_REQ primitive.
280
281 */
282
283 GLOBAL void drr_mdl_release_req (T_MDL_RELEASE_REQ * release_req)
284 {
285 TRACE_FUNCTION ("drr_mdl_release_req()");
286
287 if (release_req)
288 {
289 switch (release_req->sapi)
290 {
291 case DL_SAPI_0:
292 dcch0_mdl_release_req ();
293 break;
294 case DL_SAPI_3:
295 dcch3_mdl_release_req ();
296 break;
297
298 default:
299 break;
300 }
301 }
302
303 COM_FREE_POINTER (release_req);
304 }
305 #endif /* DL_2TO1*/
306 /*
307 +--------------------------------------------------------------------+
308 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
309 | STATE : code ROUTINE : drr_dl_suspend_req |
310 +--------------------------------------------------------------------+
311
312 PURPOSE : Reception of a DL_SUSPEND_REQ primitive.
313
314 */
315
316 GLOBAL void drr_dl_suspend_req (T_DL_SUSPEND_REQ * suspend_req)
317 {
318 TRACE_FUNCTION ("drr_dl_suspend_req()");
319
320 if (suspend_req)
321 {
322
323 switch (suspend_req->ch_type)
324 {
325 case L2_CHANNEL_FACCH_F:
326 case L2_CHANNEL_FACCH_H:
327 case L2_CHANNEL_SDCCH:
328 dcch0_suspend_req (suspend_req);
329 break;
330 default:
331 COM_FREE_POINTER (suspend_req);
332 break;
333 }
334
335
336 DL_EM_LINK_SUSPENDED;
337
338 }
339 }
340
341 /*
342 +--------------------------------------------------------------------+
343 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
344 | STATE : code ROUTINE : drr_dl_data_req |
345 +--------------------------------------------------------------------+
346
347 PURPOSE : Reception of a DL_DATA_REQ primitive.
348
349 */
350
351 GLOBAL void drr_dl_data_req (T_DL_DATA_REQ * data_req)
352 {
353 TRACE_FUNCTION ("drr_dl_data_req()");
354
355 if (data_req)
356 {
357 switch (data_req->ch_type)
358 {
359 case L2_CHANNEL_FACCH_F:
360 case L2_CHANNEL_FACCH_H:
361 case L2_CHANNEL_SDCCH:
362 case L2_CHANNEL_SACCH:
363 if (data_req->sapi EQ 3)
364 {
365 dcch3_data_req (data_req);
366 }
367 else
368 {
369 dcch0_data_req (data_req);
370 }
371 break;
372
373 default:
374 COM_FREE_POINTER (data_req);
375 break;
376 }
377 }
378
379 }
380
381 /*
382 +--------------------------------------------------------------------+
383 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
384 | STATE : code ROUTINE : drr_dl_data_ind |
385 +--------------------------------------------------------------------+
386
387 PURPOSE : Send of a DL_DATA_IND primitive.
388
389 */
390
391 GLOBAL void drr_dl_data_ind (UBYTE sapi, ULONG fn)
392 {
393 GET_INSTANCE_DATA;
394 TRACE_EVENT_WIN_P2 ("drr_dl_data_ind(,SAPI=%u): in_msg=%08x",
395 sapi, (sapi EQ PS_SAPI_0) ? dl_data->dcch0_in_msg : dl_data->dcch3_in_msg);
396
397 com_l3trace (TRACE_DOWNLINK, sapi,
398 (UBYTE *)((sapi EQ PS_SAPI_0) ? dl_data->dcch0_in_msg : dl_data->dcch3_in_msg));
399
400 TRACE_FUNCTION ("drr_dl_data_ind()");
401
402 if (fn EQ NOT_PRESENT_32BIT)
403 fn = dl_data->fn;
404
405 if (sapi EQ PS_SAPI_0)
406 {
407 if (dl_data->dcch0_in_msg)
408 {
409 dl_data->dcch0_in_msg->fn = fn;
410 PSENDX (RR, dl_data->dcch0_in_msg);
411 dl_data->dcch0_in_msg = NULL;
412 }
413 else
414 {
415 TRACE_EVENT_WIN ("dcch0_in_msg = NULL");
416 }
417 }
418 else
419 {
420 if (dl_data->dcch3_in_msg)
421 {
422 dl_data->dcch3_in_msg->fn = fn;
423 PSENDX (RR, dl_data->dcch3_in_msg);
424 dl_data->dcch3_in_msg = NULL;
425 }
426 else
427 {
428 TRACE_EVENT_WIN ("dcch3_in_msg = NULL");
429 }
430 }
431 }
432
433 /*
434 +--------------------------------------------------------------------+
435 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
436 | STATE : code ROUTINE : drr_dl_data_ind |
437 +--------------------------------------------------------------------+
438
439 PURPOSE : Indicates the acknowledgement of an uplinked message by
440 a DL_DATA_CNF primitive (only if it have been requested by L3).
441
442 */
443
444 GLOBAL void drr_dl_data_cnf (UBYTE sapi)
445 {
446 GET_INSTANCE_DATA;
447 #if defined(INVOKE_SIGNAL)
448 if (dl_data->interrupt_context)
449 {
450 sig_invoke_drr_dl_data_cnf (sapi);
451 return;
452 }
453 else
454 #endif /* INVOKE_SIGNAL */
455 {
456 PALLOC (dl_data_cnf, DL_DATA_CNF);
457 T_QUEUE * queue;
458
459 TRACE_FUNCTION ("drr_dl_data_cnf()");
460
461 if (sapi EQ PS_SAPI_0)
462 {
463 queue = &dl_data->dcch0_queue;
464 }
465 else
466 {
467 queue = &dl_data->dcch3_queue;
468 }
469
470 dl_data_cnf->ch_type = queue->sending_buffer->ch_type;
471 dl_data_cnf->sapi = queue->sending_buffer->sapi;
472 dl_data_cnf->cnf = queue->sending_buffer->cnf;
473 PSENDX (RR, dl_data_cnf);
474
475 COM_FREE_QUEUE_BUFFER (queue, INDEX_SENDING_BUFFER);
476 }
477 }
478
479 /*
480 +--------------------------------------------------------------------+
481 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
482 | STATE : code ROUTINE : drr_dl_unitdata_req |
483 +--------------------------------------------------------------------+
484
485 PURPOSE : Reception of a DL_UNITDATA_REQ primitive.
486
487 */
488
489 GLOBAL void drr_dl_unitdata_req (T_DL_UNITDATA_REQ * unitdata_req)
490 {
491 TRACE_FUNCTION ("drr_dl_unitdata_req()");
492
493 if (unitdata_req)
494 {
495 GET_INSTANCE_DATA;
496 /*lint -e420 (Warning -- Apparent access beyond array) */
497 memcpy (&dl_data->sacch_act_buffer, &unitdata_req->sdu, sizeof (T_FRAME));
498 /*lint +e420 (Warning -- Apparent access beyond array) */
499 dl_data->sacch_mode = 0;
500
501 COM_FREE_POINTER (unitdata_req);
502 }
503 }
504
505
506 /*
507 +--------------------------------------------------------------------+
508 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
509 | STATE : code ROUTINE : drr_dl_unitdata_ind |
510 +--------------------------------------------------------------------+
511
512 PURPOSE : Send of a DL_UNITDATA_IND primitive.
513
514 */
515
516 GLOBAL void drr_dl_unitdata_ind (UBYTE error_flag, UBYTE * layer1head,
517 UBYTE * layer3msg, UBYTE length, ULONG fn)
518 {
519 GET_INSTANCE_DATA;
520 #define UNITDATA_OFFSET 1
521 #if 0 /* happens in primitive context only */
522 #if defined(INVOKE_SIGNAL)
523 if (dl_data->interrupt_context)
524 {
525 sig_invoke_drr_dl_unitdata_ind (dl_data, error_flag, layer1head, layer3msg, length, fn);
526 return;
527 }
528 #endif /* INVOKE_SIGNAL */
529 #endif /* 0 */
530
531 TRACE_FUNCTION ("drr_dl_unitdata_ind()");
532
533 /* limit length of UI frame, because they could be invalid */
534 if (length > DL_N201_SACCH_A_B)
535 length = DL_N201_SACCH_A_B;
536
537 if ((layer3msg AND length) OR (error_flag NEQ VALID_BLOCK))
538 {
539 PALLOC_SDU (unitdata_ind, DL_UNITDATA_IND,
540 (USHORT)(((USHORT)length + UNITDATA_OFFSET) * BITS_PER_BYTE));
541
542 unitdata_ind->error_flag = error_flag;
543 unitdata_ind->pwr_lev = layer1head[0];
544 unitdata_ind->ta = layer1head[1];
545 unitdata_ind->sdu.o_buf = UNITDATA_OFFSET * BITS_PER_BYTE;
546 unitdata_ind->sdu.l_buf = length * BITS_PER_BYTE;
547 memset (&unitdata_ind->sdu.buf[0], 0, UNITDATA_OFFSET);
548 #ifdef DL_2TO1
549 /* build a pseudo length octet (for check in RR rr_msg_accept_sacch_normal) */
550 unitdata_ind->sdu.buf[UNITDATA_OFFSET-1] = (length << 2) | 0x01;
551 #endif /* DL_2TO1 */
552 if (error_flag EQ VALID_BLOCK)
553 /*lint -e668 (Warning -- Possibly passing a null pointer) */
554 /*lint -e669 (Warning -- Possible data overrun) */
555 memcpy (&unitdata_ind->sdu.buf[UNITDATA_OFFSET], layer3msg, length);
556 /*lint +e669 (Warning -- Possible data overrun) */
557 /*lint +e668 (Warning -- Possibly passing a null pointer) */
558
559
560 if (fn EQ NOT_PRESENT_32BIT)
561 fn = dl_data->fn;
562 unitdata_ind->fn = fn;
563
564 if (error_flag NEQ VALID_BLOCK)
565 {
566 DL_OFFLINE_TRACE(TRACE_DL_EVENT, C_DCCH0, L2_CHANNEL_SACCH, "inv UNITDATA_IND");
567 }
568 else
569 {
570 com_l3trace (TRACE_UACK_DN, L2_CHANNEL_SACCH, layer3msg);
571 }
572
573 PSENDX (RR, unitdata_ind);
574 }
575
576 #undef UNITDATA_OFFSET
577 }
578
579
580 /*
581 +--------------------------------------------------------------------+
582 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
583 | STATE : code ROUTINE : drr_dl_short_unitdata_req |
584 +--------------------------------------------------------------------+
585
586 PURPOSE : Reception of a DL_SHORT_UNITDATA_REQ primitive.
587
588 */
589
590 GLOBAL void drr_dl_short_unitdata_req (T_DL_SHORT_UNITDATA_REQ * short_unitdata_req)
591 {
592 TRACE_FUNCTION ("drr_dl_short_unitdata_req()");
593
594 if (short_unitdata_req)
595 {
596 GET_INSTANCE_DATA;
597 /*lint -e420 (Warning -- Apparent access beyond array) */
598 /*lint -e420 (Warning -- Apparent access beyond array) */
599 memcpy (&dl_data->rr_short_pd_buffer, &short_unitdata_req->sdu, sizeof (T_FRAME));
600 /*lint +e420 (Warning -- Apparent access beyond array) */
601 #ifndef DL_2TO1
602 dl_data->rr_short_pd_ch_type = short_unitdata_req->ch_type;
603 #else
604 dl_data->rr_short_pd_ch_type = short_unitdata_req->l2_channel;
605 #endif
606
607 COM_FREE_POINTER (short_unitdata_req);
608 }
609 }
610
611
612 /*
613 +--------------------------------------------------------------------+
614 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
615 | STATE : code ROUTINE : drr_dl_short_unitdata_ind |
616 +--------------------------------------------------------------------+
617
618 PURPOSE : Send of a DL_SHORT_UNITDATA_IND primitive.
619
620 */
621
622 GLOBAL void drr_dl_short_unitdata_ind (UBYTE ch_type,
623 UBYTE error_flag, UBYTE * layer1head,
624 UBYTE * layer3msg, UBYTE length, ULONG fn)
625 {
626 GET_INSTANCE_DATA;
627 #define SHORT_UNITDATA_OFFSET 1
628 #if defined(INVOKE_SIGNAL)
629 if (dl_data->interrupt_context)
630 {
631 sig_invoke_drr_dl_short_unitdata_ind (ch_type, error_flag,
632 layer1head, layer3msg, length, fn);
633 return;
634 }
635 #endif /* INVOKE_SIGNAL */
636
637 TRACE_FUNCTION ("drr_dl_short_unitdata_ind()");
638
639 if (layer3msg)
640 {
641 PALLOC_SDU (short_unitdata_ind, DL_SHORT_UNITDATA_IND,
642 (USHORT)((length + SHORT_UNITDATA_OFFSET) * BITS_PER_BYTE));
643
644 short_unitdata_ind->ch_type = ch_type;
645 short_unitdata_ind->error_flag = error_flag;
646 if (ch_type EQ L2_CHANNEL_SACCH)
647 {
648 short_unitdata_ind->pwr_lev = layer1head[0];
649 short_unitdata_ind->ta = layer1head[1];
650 }
651 else
652 {
653 short_unitdata_ind->pwr_lev = 0;
654 short_unitdata_ind->ta = 0;
655 }
656 short_unitdata_ind->sdu.o_buf = SHORT_UNITDATA_OFFSET * BITS_PER_BYTE;
657 short_unitdata_ind->sdu.l_buf = length * BITS_PER_BYTE;
658 memset (&short_unitdata_ind->sdu.buf[0], 0, SHORT_UNITDATA_OFFSET);
659 memcpy (&short_unitdata_ind->sdu.buf[SHORT_UNITDATA_OFFSET], layer3msg, length);
660
661 if (fn EQ NOT_PRESENT_32BIT)
662 fn = dl_data->fn;
663 short_unitdata_ind->fn = fn;
664 if (error_flag NEQ VALID_BLOCK)
665 {
666 DL_OFFLINE_TRACE(TRACE_DL_EVENT, C_DCCH0, ch_type, "inv SHORT_UNITDATA_IND");
667 }
668 else
669 {
670 com_l3trace (TRACE_UACK_DN, ch_type, layer3msg);
671 }
672 PSENDX (RR, short_unitdata_ind);
673 }
674
675 #undef SHORT_UNITDATA_OFFSET
676 }
677
678
679 /*
680 +--------------------------------------------------------------------+
681 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
682 | STATE : code ROUTINE : drr_dl_establish_cnf |
683 +--------------------------------------------------------------------+
684
685 PURPOSE : Send of a DL_ESTABLISH_CNF primitive.
686
687 */
688
689 GLOBAL void drr_dl_establish_cnf (UBYTE ch_type, UBYTE sapi)
690 {
691 GET_INSTANCE_DATA;
692 #if defined(INVOKE_SIGNAL)
693 if (dl_data->interrupt_context)
694 {
695 sig_invoke_drr_dl_establish_cnf (ch_type, sapi);
696 return;
697 }
698 else
699 #endif /* INVOKE_SIGNAL */
700 {
701 PALLOC (dl_establish_cnf, DL_ESTABLISH_CNF);
702
703 TRACE_FUNCTION ("drr_dl_establish_cnf()");
704 dl_establish_cnf->ch_type = ch_type;
705 dl_establish_cnf->sapi = sapi;
706 dl_establish_cnf->indication = sapi EQ PS_SAPI_0 ?
707 dl_data->dcch0_unserved : dl_data->dcch3_unserved;
708 PSENDX (RR, dl_establish_cnf);
709
710 DL_EM_CHANNEL_ESTABLISHMENT_PASSED;
711
712 if (!dl_data->RR_dedicated)
713 {
714 /* first uplink on SACCH after the first establishment is an empty frame */
715 if (sapi EQ PS_SAPI_0)
716 {
717 /* the SAPI value of the next SACCH frame depends on the next awaiting frame */
718 TRACE_EVENT_WIN_P1 ("sacch_last_uplink_sapi:=%u->3", dl_data->sacch_last_uplink_sapi);
719 dl_data->sacch_last_uplink_sapi = NOT_PRESENT_8BIT;
720 }
721
722 /* RR is entering the dedicated mode */
723 dl_data->RR_dedicated = TRUE;
724 DL_OFFLINE_TRACE(TRACE_DL_EVENT, sapi EQ PS_SAPI_0 ? C_DCCH0 : C_DCCH3,
725 ch_type, "RR_dedicated:=TRUE");
726 }
727 }
728 }/* endfunc drr_dl_establish_cnf */
729
730 /*
731 +--------------------------------------------------------------------+
732 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
733 | STATE : code ROUTINE : drr_dl_release_ind |
734 +--------------------------------------------------------------------+
735
736 PURPOSE : Send of a DL_RELEASE_IND primitive.
737
738 */
739
740 GLOBAL void drr_dl_release_ind (UBYTE ch_type,
741 UBYTE sapi, UBYTE cs, BOOL init)
742 {
743 GET_INSTANCE_DATA;
744 #if defined(INVOKE_SIGNAL)
745 if (dl_data->interrupt_context)
746 {
747 sig_invoke_drr_dl_release_ind (ch_type, sapi, cs, init);
748 return;
749 }
750 else
751 #endif /* INVOKE_SIGNAL */
752 {
753 PALLOC (dl_release_ind, DL_RELEASE_IND);/* T_DL_RELEASE_IND */
754
755 TRACE_FUNCTION ("drr_dl_release_ind()");
756
757 dl_release_ind->ch_type = ch_type;
758 dl_release_ind->sapi = sapi;
759 #ifndef DL_2TO1
760 dl_release_ind->cs = cs;
761 #else
762 dl_release_ind->ps_cause.ctrl_value = CAUSE_is_from_dl;
763 dl_release_ind->ps_cause.value.dl_cause = cs;
764 #endif /*DL_2TO1*/
765
766 #if defined (DL_TRACE_ENABLED)
767 switch (ch_type)
768 {
769 case L2_CHANNEL_FACCH_F:
770 case L2_CHANNEL_FACCH_H:
771 case L2_CHANNEL_SDCCH:
772 DL_OFFLINE_TRACE (TRACE_DL_EVENT,
773 sapi EQ PS_SAPI_0 ? C_DCCH0 : C_DCCH3, ch_type, "Release Ind");
774 break;
775 case L2_CHANNEL_SACCH:
776 DL_OFFLINE_TRACE (TRACE_DL_EVENT, sapi EQ PS_SAPI_0 ? C_DCCH0 : C_DCCH3, ch_type,
777 sapi EQ PS_SAPI_0 ? "Release Ind" : "Release Ind SAPI=3");
778 break;
779 }
780 #endif /* DL_TRACE_ENABLED */
781
782 #if defined(DELAYED_RELEASE_IND)
783 {
784 GET_INSTANCE_DATA;
785 dl_data->release_ind_ch_type = NOT_PRESENT_8BIT;
786 }
787 #endif /* DELAYED_RELEASE_IND */
788 PSENDX (RR, dl_release_ind);
789
790 if (init)
791 {
792 if (sapi EQ DL_SAPI_0)
793 {
794 dcch0_init_dl_data ();/* reset data link layer for SAPI=0 and 3 */
795 }
796 else if (sapi EQ DL_SAPI_3)
797 {
798 dcch3_init_dl_data ();/* reset data link layer for SAPI=3 only */
799 }
800 }
801 }
802
803 }/* endfunc drr_dl_release_ind */
804
805 /*
806 +--------------------------------------------------------------------+
807 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
808 | STATE : code ROUTINE : drr_dl_release_cnf |
809 +--------------------------------------------------------------------+
810
811 PURPOSE : Send of a DL_RELEASE_CNF primitive.
812
813 */
814
815 GLOBAL void drr_dl_release_cnf (UBYTE ch_type,
816 UBYTE sapi, BOOL init)
817 {
818 GET_INSTANCE_DATA;
819 #if defined(INVOKE_SIGNAL)
820 if (dl_data->interrupt_context)
821 {
822 sig_invoke_drr_dl_release_cnf (ch_type, sapi, init);
823 return;
824 }
825 else
826 #endif /* INVOKE_SIGNAL */
827 {
828 PALLOC (dl_release_cnf, DL_RELEASE_CNF);
829
830 TRACE_FUNCTION ("drr_dl_release_cnf()");
831 dl_release_cnf->ch_type = ch_type;
832 dl_release_cnf->sapi = sapi;
833
834 DL_EM_LINK_RELEASE;
835
836 PSENDX (RR, dl_release_cnf);
837
838 if (init)
839 {
840 if (sapi EQ DL_SAPI_0)
841 {
842 dcch0_init_dl_data ();/* reset data link layer for SAPI=0 and 3 */
843 }
844 else if (sapi EQ DL_SAPI_3)
845 {
846 dcch3_init_dl_data ();/* reset data link layer for SAPI=3 only */
847 }
848 }
849 }
850 }/* endfunc drr_dl_release_cnf */
851
852 /*
853 +--------------------------------------------------------------------+
854 | PROJECT : GSM-PS (6147) MODULE : DL_DRR |
855 | STATE : code ROUTINE : drr_error_ind |
856 +--------------------------------------------------------------------+
857
858 PURPOSE : Release after error.
859
860 */
861
862 GLOBAL void drr_error_ind (UBYTE ch_type, UBYTE sapi)
863 {
864 GET_INSTANCE_DATA;
865 #if defined(INVOKE_SIGNAL)
866 if (dl_data->interrupt_context)
867 {
868 sig_invoke_drr_error_ind (ch_type, sapi);
869 return;
870 }
871 #endif /* INVOKE_SIGNAL */
872
873 TRACE_FUNCTION ("drr_error_ind()");
874 DL_OFFLINE_TRACE (TRACE_DL_EVENT, TRACE_CH_UNKNOWN, ch_type, "error_ind ");
875
876 /*
877 * not a real error indication, instead a release ind to RR and release req for myself
878 */
879 drr_dl_release_ind (ch_type, sapi, NOT_PRESENT_8BIT, FALSE);
880 if (((sapi EQ DL_SAPI_0) AND (dl_data->state[C_DCCH0] > STATE_IDLE_DL))
881 OR
882 ((sapi EQ DL_SAPI_3) AND (dl_data->state[C_DCCH3] > STATE_IDLE_DL)))
883 {
884 PALLOC (release_req, DL_RELEASE_REQ);
885 release_req->ch_type = ch_type;
886 release_req->sapi = sapi;
887 release_req->mode = DL_NORMAL_RELEASE;
888 drr_dl_release_req (release_req);
889 }
890 }
891
892 #endif /* DL_DRR_C */