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