comparison src/g23m-gprs/llc/llc_itxs.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
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 process internal signals as
19 | described in the SDL-documentation (ITX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_ITXS_C
24 #define LLC_ITXS_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_itxs.h" /* to get ITX signal definitions */
42 #include "llc_itxf.h" /* to get ITX function definitions */
43 #include "llc_itxt.h" /* to get ITX T201 function definitions */
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 /*==== PUBLIC FUNCTIONS =====================================================*/
52
53
54 /*
55 +------------------------------------------------------------------------------
56 | Function : sig_llme_itx_assign_req
57 +------------------------------------------------------------------------------
58 | Description : Handles the internal signal SIG_LLME_ITX_ASSIGN_REQ
59 |
60 | Parameters :
61 |
62 +------------------------------------------------------------------------------
63 */
64 GLOBAL void sig_llme_itx_assign_req (void)
65 {
66 TRACE_ISIG( "sig_llme_itx_assign_req" );
67
68 switch (GET_STATE(ITX))
69 {
70 case ITX_TLLI_UNASSIGNED:
71 /*
72 * Init Sapi
73 */
74 itx_init_sapi();
75 SET_STATE (ITX, ITX_TLLI_ASSIGNED);
76 break;
77
78 default:
79 TRACE_ERROR( "SIG_LLME_ITX_ASSIGN_REQ unexpected" );
80 break;
81 }
82 } /* sig_llme_itx_assign_req() */
83
84
85 /*
86 +------------------------------------------------------------------------------
87 | Function : sig_llme_itx_unassign_req
88 +------------------------------------------------------------------------------
89 | Description : Handles the internal signal SIG_LLME_ITX_UNASSIGN_REQ
90 |
91 | Parameters :
92 |
93 +------------------------------------------------------------------------------
94 */
95 GLOBAL void sig_llme_itx_unassign_req (void)
96 {
97 TRACE_ISIG( "sig_llme_itx_unassign_req" );
98
99 switch (GET_STATE(ITX))
100 {
101 case ITX_TLLI_UNASSIGNED:
102 /*
103 * Ignore unexpected signal.
104 */
105 break;
106
107 default:
108 TIMERSTOP (T201);
109 itx_s_queue_clean ();
110 itx_i_queue_clean ();
111 itx_init_sapi ();
112 SET_STATE (ITX, ITX_TLLI_UNASSIGNED);
113 break;
114 }
115 } /* sig_llme_itx_unassign_req() */
116
117
118 /*
119 +------------------------------------------------------------------------------
120 | Function : sig_llme_itx_reset_req
121 +------------------------------------------------------------------------------
122 | Description : Handles the internal signal SIG_LLME_ITX_RESET_REQ
123 |
124 | Parameters :
125 |
126 +------------------------------------------------------------------------------
127 */
128 GLOBAL void sig_llme_itx_reset_req (void)
129 {
130 TRACE_ISIG( "sig_llme_itx_reset_req" );
131
132 switch (GET_STATE(ITX))
133 {
134 case ITX_TLLI_UNASSIGNED:
135 case ITX_TLLI_ASSIGNED:
136 /*
137 * nothing to do
138 */
139 break;
140
141 case ITX_ABM:
142 case ITX_ABM_PEER_BUSY:
143 TIMERSTOP (T201);
144 itx_s_queue_clean ();
145 itx_i_queue_clean ();
146 itx_init_sapi ();
147 SET_STATE (ITX, ITX_TLLI_ASSIGNED);
148 break;
149
150 default:
151 TRACE_ERROR( "SIG_LLME_ITX_RESET_REQ unexpected" );
152 break;
153 }
154 } /* sig_llme_itx_reset_req() */
155
156
157 /*
158 +------------------------------------------------------------------------------
159 | Function : sig_llme_itx_abmest_req
160 +------------------------------------------------------------------------------
161 | Description : Handles the internal signal SIG_LLME_ITX_ABMEST_REQ
162 |
163 | Parameters :
164 |
165 +------------------------------------------------------------------------------
166 */
167 GLOBAL void sig_llme_itx_abmest_req (void)
168 {
169 TRACE_ISIG( "sig_llme_itx_abmest_req" );
170
171 switch (GET_STATE(ITX))
172 {
173 case ITX_TLLI_UNASSIGNED:
174 /*
175 * Ignore unexpected signal.
176 */
177 TRACE_ERROR( "SIG_LLME_ITX_ABMEST_REQ unexpected" );
178 break;
179
180 default:
181 TIMERSTOP (T201);
182 itx_s_queue_clean ();
183 itx_i_queue_clean ();
184 itx_init_sapi ();
185 itx_handle_ll_ready_ind (FALSE);
186 SET_STATE (ITX, ITX_ABM);
187 TRACE_1_INFO("ABM established s:%d", llc_data->current_sapi);
188 break;
189 }
190 } /* sig_llme_itx_abmest_req() */
191
192
193 /*
194 +------------------------------------------------------------------------------
195 | Function : sig_llme_itx_abmrel_req
196 +------------------------------------------------------------------------------
197 | Description : Handles the internal signal SIG_LLME_ITX_ABMREL_REQ
198 |
199 | Parameters :
200 |
201 +------------------------------------------------------------------------------
202 */
203 GLOBAL void sig_llme_itx_abmrel_req (void)
204 {
205 TRACE_ISIG( "sig_llme_itx_abmrel_req" );
206
207 switch (GET_STATE(ITX))
208 {
209 case ITX_TLLI_UNASSIGNED:
210 /*
211 * Ignore unexpected signal.
212 */
213 TRACE_ERROR( "SIG_LLME_ITX_ABMREL_REQ unexpected" );
214 break;
215
216 default:
217 TIMERSTOP (T201);
218 itx_s_queue_clean ();
219 itx_i_queue_clean ();
220 itx_init_sapi ();
221 SET_STATE (ITX, ITX_TLLI_ASSIGNED);
222 TRACE_1_INFO("ABM released s:%d", llc_data->current_sapi);
223 break;
224 }
225 } /* sig_llme_itx_abmrel_req() */
226
227
228
229 /*
230 +------------------------------------------------------------------------------
231 | Function : sig_llme_itx_suspend_req
232 +------------------------------------------------------------------------------
233 | Description : Handles the internal signal SIG_LLME_ITX_SUSPEND_REQ
234 |
235 | Parameters :
236 |
237 +------------------------------------------------------------------------------
238 */
239 GLOBAL void sig_llme_itx_suspend_req (void)
240 {
241 TRACE_ISIG( "sig_llme_itx_suspend_req" );
242
243 switch (GET_STATE(ITX))
244 {
245 case ITX_TLLI_UNASSIGNED:
246 case ITX_TLLI_ASSIGNED:
247 /*
248 * nothing to do
249 */
250 break;
251
252 case ITX_ABM:
253 case ITX_ABM_PEER_BUSY:
254 /*
255 * Reset T201, but do NOT reset t201_entry pointer
256 * because we have to restart T201 later!
257 */
258 TIMERSTOP (T201);
259 /* SET_STATE (ITX, SAME_STATE); */
260 break;
261
262 default:
263 TRACE_ERROR( "SIG_LLME_ITX_SUSPEND_REQ unexpected" );
264 break;
265 }
266 } /* sig_llme_itx_suspend_req() */
267
268
269 /*
270 +------------------------------------------------------------------------------
271 | Function : sig_llme_itx_resume_req
272 +------------------------------------------------------------------------------
273 | Description : Handles the internal signal SIG_LLME_ITX_RESUME_REQ
274 |
275 | Parameters :
276 |
277 +------------------------------------------------------------------------------
278 */
279 GLOBAL void sig_llme_itx_resume_req (void)
280 {
281 TRACE_ISIG( "sig_llme_itx_resume_req" );
282
283 switch (GET_STATE(ITX))
284 {
285 case ITX_TLLI_UNASSIGNED:
286 case ITX_TLLI_ASSIGNED:
287 /*
288 * nothing to do
289 */
290 break;
291
292 case ITX_ABM:
293 /*
294 * Restart T201 if a frame was associated to it.
295 * Do not increment frame retransmission counter.
296 */
297 if ( llc_data->itx->t201_entry != NULL )
298 {
299 TIMERSTART (T201, llc_data->t200->length);
300 }
301
302 /*
303 * Continue sending of frames
304 */
305 itx_send_next_frame (ABIT_NO_REQ);
306 break;
307
308 case ITX_ABM_PEER_BUSY:
309 /*
310 * Restart T201, but do not increment counter
311 */
312 TIMERSTART (T201, llc_data->t200->length);
313 break;
314
315 default:
316 TRACE_ERROR( "SIG_LLME_ITX_RESUME_REQ unexpected" );
317 break;
318 }
319 } /* sig_llme_itx_resume_req() */
320
321
322
323
324 /*
325 +------------------------------------------------------------------------------
326 | Function : sig_tx_itx_ready_ind
327 +------------------------------------------------------------------------------
328 | Description : Handles the internal signal SIG_TX_ITX_READY_IND
329 |
330 | Parameters :
331 |
332 +------------------------------------------------------------------------------
333 */
334 GLOBAL void sig_tx_itx_ready_ind (void)
335 {
336 TRACE_ISIG( "sig_tx_itx_ready_ind" );
337
338 switch (GET_STATE(ITX))
339 {
340 case ITX_TLLI_ASSIGNED:
341 llc_data->itx->tx_waiting = TRUE;
342 /* SET_STATE (ITX, SAME_STATE); */
343 break;
344
345 case ITX_ABM:
346 case ITX_ABM_PEER_BUSY:
347 llc_data->itx->tx_waiting = TRUE;
348 itx_send_next_frame (ABIT_NO_REQ);
349 /* SET_STATE (ITX, SAME_STATE); */
350 break;
351
352 default:
353 TRACE_ERROR( "SIG_TX_ITX_READY_IND unexpected" );
354 break;
355 }
356 } /* sig_tx_itx_ready_ind() */
357
358
359
360 /*
361 +------------------------------------------------------------------------------
362 | Function : sig_irx_itx_ack_ind
363 +------------------------------------------------------------------------------
364 | Description : Handles the internal signal SIG_IRX_ITX_ACK_IND
365 |
366 | Parameters :
367 |
368 +------------------------------------------------------------------------------
369 */
370 GLOBAL void sig_irx_itx_ack_ind (BOOL is_ack, T_FRAME_NUM num)
371 {
372 TRACE_ISIG( "sig_irx_itx_ack_ind" );
373
374 num %= (MAX_SEQUENCE_NUMBER+1);
375
376 #ifdef TRACE_EVE
377 {
378 if (is_ack == TRUE)
379 {
380 TRACE_1_INFO("got frame ack:%d", num);
381 }
382 else
383 {
384 TRACE_1_INFO("got frame request:%d", num);
385 }
386 }
387 #endif
388
389 switch (GET_STATE(ITX))
390 {
391 case ITX_ABM:
392 case ITX_ABM_PEER_BUSY:
393 /*
394 * Set frame acknowledge status in the ITX queue.
395 */
396 if (is_ack)
397 itx_i_queue_set_status (IQ_IS_ACK_FRAME, num);
398 else
399 itx_i_queue_set_status (IQ_RETR_FRAME, num);
400
401 /* SET_STATE (ITX, SAME_STATE); */
402 break;
403
404 default:
405 TRACE_ERROR( "SIG_IRX_ITX_ACK_IND unexpected" );
406 break;
407 }
408 } /* sig_irx_itx_ack_ind() */
409
410
411
412 /*
413 +------------------------------------------------------------------------------
414 | Function : sig_irx_itx_cnf_l3data_req
415 +------------------------------------------------------------------------------
416 | Description : Handles the internal signal SIG_IRX_ITX_CNF_L3DATA_REQ
417 |
418 | Parameters :
419 |
420 +------------------------------------------------------------------------------
421 */
422 GLOBAL void sig_irx_itx_cnf_l3data_req (void)
423 {
424 UBYTE state;
425 BOOL found;
426 BOOL data_retrieved = FALSE;
427 #ifdef LL_2to1
428 T_LL_reference1 reference;
429 #else
430 T_reference1 reference;
431 #endif
432
433 TRACE_ISIG( "sig_irx_itx_cnf_l3data_req" );
434
435 state = GET_STATE(ITX);
436
437 switch (state)
438 {
439 case ITX_ABM:
440 case ITX_ABM_PEER_BUSY:
441 /*
442 * Get all acknowledged frames from the ITX queue.
443 * If one or more are found, send an LL_DATA_CNF
444 * for each group of max LL_MAX_CNF L3-PDUs.
445 */
446 itx_i_queue_get_ready (&found, &reference, state);
447 data_retrieved = found;
448
449 /*
450 * Label LLC_ACK_IND
451 */
452
453 while (found)
454 {
455 int num_ref = 0;
456
457 PALLOC (ll_data_cnf, LL_DATA_CNF);
458
459 ll_data_cnf->sapi = llc_data->current_sapi;
460
461 do {
462
463 ll_data_cnf->reference1[num_ref] = reference;
464 num_ref++;
465
466 itx_i_queue_get_ready (&found, &reference, state);
467
468 } while (found && (num_ref < LLC_MAX_CNF));
469
470 ll_data_cnf->c_reference1 = num_ref;
471
472 TRACE_1_OUT_PARA("s:%d", ll_data_cnf->sapi );
473 PSEND (hCommSNDCP, ll_data_cnf);
474 }
475
476 /*
477 * If we have taken data from queue, check
478 * if a L3 ready indication is required
479 */
480 if (data_retrieved)
481 {
482 itx_handle_ll_ready_ind (data_retrieved);
483 }
484
485 /* SET_STATE (ITX, SAME_STATE); */
486 break;
487
488 default:
489 TRACE_ERROR( "SIG_IRX_ITX_CNF_L3DATA_REQ unexpected" );
490 break;
491 }
492 } /* sig_irx_itx_cnf_l3data_req() */
493
494
495 /*
496 +------------------------------------------------------------------------------
497 | Function : sig_irx_itx_trigger_ind
498 +------------------------------------------------------------------------------
499 | Description : Handles the internal signal SIG_IRX_ITX_TRIGGER_IND
500 |
501 | Parameters :
502 |
503 +------------------------------------------------------------------------------
504 */
505 GLOBAL void sig_irx_itx_trigger_ind (void)
506 {
507 TRACE_ISIG( "sig_irx_itx_trigger_ind" );
508
509 switch (GET_STATE(ITX))
510 {
511 case ITX_ABM:
512 case ITX_ABM_PEER_BUSY:
513 itx_send_next_frame (ABIT_NO_REQ);
514 /* SET_STATE (ITX, SAME_STATE); */
515 break;
516
517 default:
518 TRACE_ERROR( "SIG_IRX_ITX_TRIGGER_IND unexpected" );
519 break;
520 }
521 } /* sig_irx_itx_trigger_ind() */
522
523
524 /*
525 +------------------------------------------------------------------------------
526 | Function : sig_irx_itx_peer_busy_ind
527 +------------------------------------------------------------------------------
528 | Description : Handles the internal signal SIG_IRX_ITX_PEER_BUSY_IND
529 |
530 | Parameters :
531 |
532 +------------------------------------------------------------------------------
533 */
534 GLOBAL void sig_irx_itx_peer_busy_ind (void)
535 {
536 TRACE_ISIG( "sig_irx_itx_peer_busy_ind" );
537
538 switch (GET_STATE(ITX))
539 {
540 case ITX_ABM:
541 /*
542 * Start T201 to supervise peer busy condition,
543 * init T201 peer busy restart counter and change
544 * into peer busy state.
545 */
546 TIMERSTART (T201, llc_data->t200->length);
547 llc_data->itx->n_pb_retr = 0;
548 SET_STATE (ITX, ITX_ABM_PEER_BUSY);
549 TRACE_1_INFO("Peer Busy s:%d", llc_data->current_sapi);
550 break;
551
552 case ITX_ABM_PEER_BUSY:
553 /*
554 * Restart T201 to supervise peer busy condition,
555 * reset T201 peer busy restart counter.
556 */
557 TIMERSTART (T201, llc_data->t200->length);
558 llc_data->itx->n_pb_retr = 0;
559 break;
560
561 default:
562 TRACE_ERROR( "SIG_IRX_ITX_PEER_BUSY_IND unexpected" );
563 break;
564 }
565 } /* sig_irx_itx_peer_busy_ind() */
566
567
568
569 /*
570 +------------------------------------------------------------------------------
571 | Function : sig_irx_itx_peer_ready_ind
572 +------------------------------------------------------------------------------
573 | Description : Handles the internal signal SIG_IRX_ITX_PEER_READY_IND
574 |
575 | Parameters :
576 |
577 +------------------------------------------------------------------------------
578 */
579 GLOBAL void sig_irx_itx_peer_ready_ind (void)
580 {
581 TRACE_ISIG( "sig_irx_itx_peer_ready_ind" );
582
583 switch (GET_STATE(ITX))
584 {
585 case ITX_ABM:
586 /*
587 * ignore it
588 */
589 break;
590
591 case ITX_ABM_PEER_BUSY:
592 /*
593 * Clear peer busy condition
594 */
595 SET_STATE (ITX, ITX_ABM);
596
597 /*
598 * Restart T201 if a frame was associated to it.
599 * Do not increment frame retransmission counter.
600 */
601 if ( llc_data->itx->t201_entry != NULL )
602 {
603 TIMERSTART (T201, llc_data->t200->length);
604 }
605
606 /*
607 * Restart sending of frames
608 */
609 TRACE_1_INFO("Peer Ready s:%d", llc_data->current_sapi);
610 itx_send_next_frame (ABIT_NO_REQ);
611 break;
612
613 default:
614 TRACE_ERROR( "SIG_IRX_ITX_PEER_READY_IND unexpected" );
615 break;
616 }
617 } /* sig_irx_itx_peer_ready_ind() */
618
619
620
621 /*
622 +------------------------------------------------------------------------------
623 | Function : sig_irx_itx_send_rr_req
624 +------------------------------------------------------------------------------
625 | Description : Handles the internal signal SIG_IRX_ITX_SEND_RR_REQ
626 |
627 | Parameters :
628 |
629 +------------------------------------------------------------------------------
630 */
631 GLOBAL void sig_irx_itx_send_rr_req (T_ABIT_REQ_TYPE req_type)
632 {
633 TRACE_ISIG( "sig_irx_itx_send_rr_req" );
634
635 switch (GET_STATE(ITX))
636 {
637 case ITX_ABM:
638 case ITX_ABM_PEER_BUSY:
639 itx_s_queue_store (I_RR, req_type, llc_data->sapi->vr, NULL);
640 itx_send_next_frame (ABIT_NO_REQ);
641 /* SET_STATE (ITX, SAME_STATE); */
642 break;
643
644 default:
645 TRACE_ERROR( "SIG_IRX_ITX_SEND_RR_REQ unexpected" );
646 break;
647 }
648 } /* sig_irx_itx_send_rr_req() */
649
650
651 /*
652 +------------------------------------------------------------------------------
653 | Function : sig_irx_itx_send_ack_req
654 +------------------------------------------------------------------------------
655 | Description : Handles the internal signal SIG_IRX_ITX_SEND_ACK_REQ
656 |
657 | Parameters :
658 |
659 +------------------------------------------------------------------------------
660 */
661 GLOBAL void sig_irx_itx_send_ack_req (T_ABIT_REQ_TYPE req_type)
662 {
663 TRACE_ISIG( "sig_irx_itx_send_ack_req" );
664
665 switch (GET_STATE(ITX))
666 {
667 case ITX_ABM:
668 case ITX_ABM_PEER_BUSY:
669 itx_s_queue_store (I_ACK, req_type, llc_data->sapi->vr, NULL);
670 itx_send_next_frame (ABIT_NO_REQ);
671 /* SET_STATE (ITX, SAME_STATE); */
672 break;
673
674 default:
675 TRACE_ERROR( "SIG_IRX_ITX_SEND_ACK_REQ unexpected" );
676 break;
677 }
678 } /* sig_irx_itx_send_ack_req() */
679
680
681
682 /*
683 +------------------------------------------------------------------------------
684 | Function : sig_irx_itx_send_sack_req
685 +------------------------------------------------------------------------------
686 | Description : Handles the internal signal SIG_IRX_ITX_SEND_SACK_REQ
687 |
688 | Parameters :
689 |
690 +------------------------------------------------------------------------------
691 */
692 GLOBAL void sig_irx_itx_send_sack_req (T_ABIT_REQ_TYPE req_type, T_SACK_BITMAP* bitmap)
693 {
694 TRACE_ISIG( "sig_irx_itx_send_sack_req" );
695
696 switch (GET_STATE(ITX))
697 {
698 case ITX_ABM:
699 case ITX_ABM_PEER_BUSY:
700 itx_s_queue_store (I_SACK, req_type, llc_data->sapi->vr, bitmap);
701 itx_send_next_frame (ABIT_NO_REQ);
702 /* SET_STATE (ITX, SAME_STATE); */
703 break;
704
705 default:
706 TRACE_ERROR( "SIG_IRX_ITX_SEND_SACK_REQ unexpected" );
707 break;
708 }
709 } /* sig_irx_itx_send_sack_req() */
710
711
712
713
714 /*
715 +------------------------------------------------------------------------------
716 | Function : sig_irx_itx_send_rnr_req
717 +------------------------------------------------------------------------------
718 | Description : Handles the internal signal SIG_IRX_ITX_SEND_RNR_REQ
719 |
720 | Parameters :
721 |
722 +------------------------------------------------------------------------------
723 */
724 GLOBAL void sig_irx_itx_send_rnr_req (T_ABIT_REQ_TYPE req_type)
725 {
726 TRACE_ISIG( "sig_irx_itx_send_rnr_req" );
727
728 switch (GET_STATE(ITX))
729 {
730 case ITX_ABM:
731 case ITX_ABM_PEER_BUSY:
732 itx_s_queue_store (I_RNR, req_type, llc_data->sapi->vr, NULL);
733 itx_send_next_frame (ABIT_NO_REQ);
734 /* SET_STATE (ITX, SAME_STATE); */
735 break;
736
737 default:
738 TRACE_ERROR( "SIG_IRX_ITX_SEND_RNR_REQ unexpected" );
739 break;
740 }
741 } /* sig_irx_itx_send_rnr_req() */
742