comparison src/g23m-gprs/grlc/grlc_tms.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 : GPRS (8441)
4 | Modul : GRLC
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 module implements signal handler functions for service
18 | TM of entity GRLC.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRLC_TMS_C
23 #define GRLC_TMS_C
24 #endif
25
26 #define ENTITY_GRLC
27
28 /*==== INCLUDES =============================================================*/
29
30 #include <string.h>
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 "ccdapi.h" /* to get CCD API */
37 #include "cnf_grlc.h" /* to get cnf-definitions */
38 #include "mon_grlc.h" /* to get mon-definitions */
39 #include "prim.h" /* to get the definitions of used SAP and directions */
40 #include "message.h" /* to get air message definitions */
41 #include "grlc.h" /* to get the global entity definitions */
42 #include "grlc_f.h" /* to get the global entity definitions */
43 #include "grlc_tmf.h" /* to get the service TM procedure definitions */
44 #include "grlc_tms.h" /* to get the service TM signal definitions */
45 #include "grlc_rus.h" /* to get the service RU signal definitions */
46 #include "grlc_rds.h" /* to get the service RD signal definitions */
47 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
48 #include "grlc_gffs.h"
49 #endif
50
51
52
53 /*==== CONST ================================================================*/
54
55 /*==== DIAGNOSTICS ==========================================================*/
56
57 /*==== LOCAL TYPES===========================================================*/
58
59 /*==== LOCAL VARS ===========================================================*/
60
61 /*==== PRIVATE FUNCTIONS ====================================================*/
62
63 /*==== PUBLIC FUNCTIONS =====================================================*/
64
65
66 /*
67 +------------------------------------------------------------------------------
68 | Function : tm_get_ctrl_blk
69 +------------------------------------------------------------------------------
70 | Description :
71 |
72 | Parameters :
73 |
74 +------------------------------------------------------------------------------
75 */
76 GLOBAL UBYTE* tm_get_ctrl_blk ( UBYTE *index, BOOL unacknowledged )
77 {
78 UBYTE *ctrl_blk;
79
80 TRACE_FUNCTION( "tm_get_ctrl_blk" );
81
82 ctrl_blk = tm_set_start_ctrl_blk( index );
83
84 if( unacknowledged )
85 {
86 /*
87 * in case the control blocks are send by the service RU, we are
88 * working in unacknowledged mode, so every block is transmitted
89 * succesfully
90 */
91 tm_set_stop_ctrl_blk( TRUE, CGRLC_BLK_OWNER_NONE, 0 );
92 }
93
94 return( ctrl_blk );
95
96 } /* tm_get_ctrl_blk() */
97
98 /*
99 +------------------------------------------------------------------------------
100 | Function : tm_is_ctrl_blk_rdy
101 +------------------------------------------------------------------------------
102 | Description :
103 |
104 | Parameters :
105 |
106 +------------------------------------------------------------------------------
107 */
108 GLOBAL BOOL tm_is_ctrl_blk_rdy ( UBYTE ack_cnt_meas_rpt, UBYTE ack_cnt_other )
109 {
110 BOOL result = FALSE;
111 T_BLK_INDEX blk_index = grlc_data->tm.ul_ctrl_blk.seq[0];
112
113 TRACE_FUNCTION( "tm_is_ctrl_blk_rdy" );
114
115 if( blk_index NEQ MAX_CTRL_BLK_NUM )
116 {
117 switch( grlc_data->tm.ul_ctrl_blk.blk[blk_index].owner )
118 {
119 case( CGRLC_BLK_OWNER_MEAS ):
120 case( CGRLC_BLK_OWNER_CS ): result = ( ack_cnt_meas_rpt EQ 0 ); break;
121 default : result = ( ack_cnt_other EQ 0 ); break;
122 }
123 }
124
125 return( result );
126
127 } /* tm_is_ctrl_blk_rdy() */
128
129 /*
130 +------------------------------------------------------------------------------
131 | Function : tm_get_num_ctrl_blck
132 +------------------------------------------------------------------------------
133 | Description : This function returns the number of allocated control blocks.
134 |
135 | Parameters :
136 |
137 +------------------------------------------------------------------------------
138 */
139 GLOBAL UBYTE tm_get_num_ctrl_blck ( void )
140 {
141 UBYTE i = 0; /* used for counting */
142 UBYTE num = 0; /* number of allocated control blocks */
143
144 TRACE_FUNCTION( "tm_get_num_ctrl_blck" );
145
146 while( i < MAX_CTRL_BLK_NUM AND
147 grlc_data->tm.ul_ctrl_blk.seq[i] NEQ MAX_CTRL_BLK_NUM )
148 {
149 if( grlc_data->tm.ul_ctrl_blk.blk[grlc_data->tm.ul_ctrl_blk.seq[i]].state
150 EQ BLK_STATE_ALLOCATED )
151 {
152 num++;
153 }
154
155 i++;
156 }
157
158 return( num );
159
160 } /* tm_get_num_ctrl_blck() */
161
162 /*
163 +------------------------------------------------------------------------------
164 | Function : tm_cpy_ctrl_blk_to_buffer
165 +------------------------------------------------------------------------------
166 | Description : This function ...
167 |
168 | Parameters :
169 |
170 +------------------------------------------------------------------------------
171 */
172 GLOBAL UBYTE tm_cpy_ctrl_blk_to_buffer( UBYTE *buffer )
173 {
174 UBYTE index;
175 UBYTE *ctrl_block = tm_get_ctrl_blk( &index, FALSE );
176
177 TRACE_FUNCTION( "tm_cpy_ctrl_blk_to_buffer" );
178
179 if( ctrl_block NEQ NULL )
180 {
181 memcpy( buffer, ctrl_block, BYTE_UL_CTRL_BLOCK );
182 }
183 else
184 {
185 TRACE_ERROR( "tm_cpy_ctrl_blk_to_buffer: ctrl_block EQ NULL" );
186 }
187
188 return( index );
189 } /* tm_cpy_ctrl_blk_to_buffer() */
190
191
192 /*==== SIGNAL FUNCTIONS =====================================================*/
193
194
195
196 /*
197 +------------------------------------------------------------------------------
198 | Function : sig_ru_tm_error_ra
199 +------------------------------------------------------------------------------
200 | Description : Handles the internal signal SIG_RU_TM_ERROR_RA
201 | in case of contention resulution failed in service RU
202 | refer to GSM0460v650 p35
203 |
204 | Parameters : void
205 |
206 +------------------------------------------------------------------------------
207 */
208
209 GLOBAL void sig_ru_tm_error_ra ( void )
210 {
211 TRACE_ISIG( "sig_ru_tm_error_ra" );
212
213 switch( GET_STATE( TM ) )
214 {
215 case TM_PTM:
216 if( grlc_data->testmode.mode EQ CGRLC_TEST_RANDOM OR
217 grlc_data->testmode.mode EQ CGRLC_LOOP )
218 {
219 tm_abort_tbf(grlc_data->tbf_type);
220 tm_delete_prim_queue();
221 SET_STATE(TM,TM_WAIT_4_PIM);
222 grlc_data->tm.n_acc_req_procedures = 0;
223 grlc_data->tm.n_res_req = 0; /* reset counter of resource requests during access */
224 }
225 else
226 {
227 tm_handle_error_ra();
228 }
229 break;
230 default:
231 TRACE_ERROR( "SIG_RU_TM_ERROR_RA unexpected" );
232 break;
233 }
234 } /* sig_ru_tm_error_ra() */
235
236
237
238
239 /*
240 +------------------------------------------------------------------------------
241 | Function : sig_ru_tm_cs
242 +------------------------------------------------------------------------------
243 | Description : Handles the internal signal SIG_RU_TM_CS
244 |
245 | Parameters : void
246 |
247 +------------------------------------------------------------------------------
248 */
249 GLOBAL void sig_ru_tm_cs ( void )
250 {
251 TRACE_ISIG( "sig_ru_tm_cs" );
252
253 switch( GET_STATE( TM ) )
254 {
255 case TM_PTM:
256 /*TRACE_EVENT_P1("CONT_RES:nacc set from %d to zero",grlc_data->tm.n_acc_req_procedures);*/
257 grlc_data->tm.n_acc_req_procedures = 0;
258 grlc_data->uplink_tbf.ti = 0;
259 {
260 PALLOC(prim,CGRLC_CONT_RES_DONE_IND);
261 PSEND(hCommGRR,prim);
262 }
263 break;
264 default:
265 TRACE_ERROR( "SIG_RU_TM_CS unexpected" );
266 break;
267 }
268 } /* sig_ru_tm_cs() */
269
270
271 /*
272 +------------------------------------------------------------------------------
273 | Function : sig_ru_tm_end_of_tbf
274 +------------------------------------------------------------------------------
275 | Description : Handles the internal signal SIG_RU_TM_END_OF_TBF
276 |
277 | Parameters : void
278 |
279 +------------------------------------------------------------------------------
280 */
281 GLOBAL void sig_ru_tm_end_of_tbf ( void )
282 {
283 TRACE_ISIG( "sig_ru_tm_end_of_tbf" );
284
285
286 /*
287 * TBF end handling for TEST_MODE
288 */
289
290
291 if((grlc_data->testmode.mode EQ CGRLC_TEST_RANDOM ) OR
292 (grlc_data->testmode.mode EQ CGRLC_LOOP ) )
293 {
294 grlc_delete_prim();
295 tm_handle_grlc_ready_ind();
296 }
297
298
299 switch( GET_STATE( TM ) )
300 {
301 case TM_PTM:
302 /* stop timer for sending chan req desc in dl ack/nack if running */
303 /*TRACE_EVENT_P1("End of tbf:nacc set from %d to zero",grlc_data->tm.n_acc_req_procedures);*/
304 grlc_data->tm.n_acc_req_procedures = 0;
305 grlc_data->tm.n_res_req = 0;
306 vsi_t_stop(GRLC_handle,T3168);
307 switch( grlc_data->tbf_type )
308 {
309 case TBF_TYPE_CONC:
310 case TBF_TYPE_UL:
311 tm_send_tbf_rel(TBF_TYPE_UL);
312 tm_deactivate_tbf(TBF_TYPE_UL);
313 break;
314 default:
315 break;
316 }
317 break;
318 default:
319 TRACE_ERROR( "SIG_RU_TM_END_OF_TBF unexpected" );
320 break;
321 }
322
323 switch(grlc_data->tbf_type)
324 {
325 case TBF_TYPE_NULL:
326 SET_STATE(TM,TM_WAIT_4_PIM);
327 break;
328 case TBF_TYPE_DL:
329 /*
330 * uplink tbf released, downlink is still running, a new pdu is uplink queue
331 */
332 tm_ul_tbf_ind();
333 break;
334 default:
335 TRACE_ERROR( "tm_deactivate_tbf did not work correct in sig_ru_tm_end_of_tbf" );
336 break;
337 }
338 } /* sig_ru_tm_end_of_tbf() */
339
340
341
342
343 /*
344 +------------------------------------------------------------------------------
345 | Function : sig_rd_tm_end_of_tbf
346 +------------------------------------------------------------------------------
347 | Description : Handles the internal signal SIG_RD_TM_END_OF_TBF
348 |
349 | Parameters : rel_ul - release UL TBF also. ( True,False)
350 |
351 +------------------------------------------------------------------------------
352 */
353 GLOBAL void sig_rd_tm_end_of_tbf ( BOOL rel_ul )
354 {
355 /* T_TIME dummy; */
356 TRACE_ISIG( "sig_rd_tm_end_of_tbf" );
357
358 switch( GET_STATE( TM ) )
359 {
360 case TM_PTM:
361 if( grlc_data->testmode.mode EQ CGRLC_LOOP )
362 {
363 TRACE_EVENT("TESTMODE B: Normal DL release ");
364 tm_send_tbf_rel(grlc_data->tbf_type);
365 sig_tm_ru_abrel(1, FALSE);
366 tm_deactivate_tbf(grlc_data->tbf_type);
367 tm_delete_prim_queue();
368 SET_STATE(TM,TM_WAIT_4_PIM);
369 grlc_data->tm.n_acc_req_procedures = 0;
370 grlc_data->tm.n_res_req = 0; /* reset counter of resource requests during access */
371 vsi_t_stop(GRLC_handle,T3168);
372 return;
373 }
374
375 if (rel_ul AND grlc_data->tbf_type EQ TBF_TYPE_CONC)
376 {
377 sig_tm_ru_abrel(1, FALSE);
378 tm_send_tbf_rel (grlc_data->tbf_type);
379 tm_deactivate_tbf(grlc_data->tbf_type);
380 grlc_data->tm.n_acc_req_procedures = 0;
381 grlc_data->tm.n_res_req = 0; /* reset counter of resource requests during access */
382 vsi_t_stop(GRLC_handle,T3168);
383 }
384 else
385 {
386 tm_send_tbf_rel (TBF_TYPE_DL);
387 tm_deactivate_tbf(TBF_TYPE_DL);
388 }
389
390 switch( grlc_data->tbf_type )
391 {
392 case TBF_TYPE_NULL:
393 SET_STATE(TM,TM_WAIT_4_PIM);
394 vsi_t_stop(GRLC_handle,T3168); /* stop timer for sending chan req desc in dl ack/nack if running */
395 break;
396 case TBF_TYPE_UL:
397 /*
398 * nothing to do, ul tbf is running
399 */
400 break;
401 default:
402 TRACE_ERROR( "tm_deactivate_tbf did not work correct in sig_rd_tm_end_of_tbf" );
403 break;
404 }
405 break;
406 default:
407 TRACE_ERROR( "SIG_RD_TM_END_OF_TBF unexpected" );
408 break;
409 }
410 } /* sig_rd_tm_end_of_tbf() */
411
412
413 /*
414 +------------------------------------------------------------------------------
415 | Function : sig_rd_tm_ul_req_cnf
416 +------------------------------------------------------------------------------
417 | Description : Handles the internal signal SIG_RD_TM_UL_REQ_CNF
418 | RD have to send that inter signal after it sends a Packet Downlink
419 | AckNack including Channel Request Description.
420 |
421 | Parameters : void
422 |
423 +------------------------------------------------------------------------------
424 */
425 GLOBAL void sig_rd_tm_ul_req_cnf ( void )
426 {
427 TRACE_ISIG( "sig_rd_tm_ul_req_cnf" );
428
429 switch( GET_STATE( TM ) )
430 {
431 case TM_PTM:
432 /*
433 TRACE_EVENT_P1("T3168 start: %d ms",((grlc_data->t3168_val)+1)*500);
434 */
435 vsi_t_start(GRLC_handle,T3168,((grlc_data->t3168_val)+1)*500);
436 break;
437 default:
438 TRACE_ERROR( "SIG_RD_TM_UL_REQ_CNF unexpected" );
439 break;
440 }
441 } /* sig_rd_tm_ul_req_cnf() */
442
443
444
445
446
447
448
449
450 /*
451 +------------------------------------------------------------------------------
452 | Function : sig_ru_tm_end_of_pdu
453 +------------------------------------------------------------------------------
454 | Description : Handles the internal signal SIG_RU_TM_END_OF_PDU
455 |
456 | Parameters : index_of_next_llc_pdu_i - next LLC-PDU to send
457 |
458 +------------------------------------------------------------------------------
459 */
460 GLOBAL void sig_ru_tm_end_of_pdu ( UBYTE index_of_next_llc_pdu_i )
461 {
462 TRACE_ISIG( "sig_ru_tm_end_of_pdu" );
463
464 switch( GET_STATE( TM ) )
465 {
466 case TM_PTM:
467 if(grlc_data->prim_queue[index_of_next_llc_pdu_i].re_allocation)
468 {
469 T_U_GRLC_RESOURCE_REQ resource_req; /*lint !e813*/
470
471 tm_ini_realloc(index_of_next_llc_pdu_i);
472 tm_build_res_req(&resource_req,
473 R_RE_ALLOC);
474 tm_store_ctrl_blk( CGRLC_BLK_OWNER_TM, ( void* )&resource_req );
475 }
476 break;
477 default:
478 TRACE_ERROR( "SIG_RU_TM_END_OF_PDU unexpected" );
479 break;
480 }
481 } /* sig_ru_tm_end_of_pdu() */
482
483
484 /*
485 +------------------------------------------------------------------------------
486 | Function : sig_ru_tm_prim_delete
487 +------------------------------------------------------------------------------
488 | Description : Handles the internal signal SIG_RU_TM_PRIM_DELETE
489 |
490 | Parameters : void
491 |
492 +------------------------------------------------------------------------------
493 */
494 GLOBAL void sig_ru_tm_prim_delete ( void )
495 {
496 TRACE_ISIG( "sig_ru_tm_prim_delete" );
497
498
499 switch( GET_STATE( TM ) )
500 {
501 case TM_PTM:
502 grlc_delete_prim();
503 if( (grlc_data->testmode.mode EQ CGRLC_TEST_RANDOM) AND
504 (grlc_data->testmode.n_pdu) )
505 {
506 /*
507 * queue one new pdu
508 */
509 TRACE_EVENT_P1("testmode a %ld pdus",grlc_data->testmode.n_pdu);
510 grlc_data->testmode.n_pdu--;
511 tm_queue_test_mode_prim(1);
512 }
513 tm_handle_grlc_ready_ind();
514 break;
515
516 default:
517 TRACE_ERROR( "SIG_RU_TM_PRIM_DELETE unexpected" );
518 break;
519 }
520 } /* sig_ru_tm_prim_delete() */
521
522
523
524
525
526 /*
527 +------------------------------------------------------------------------------
528 | Function : sig_ru_tm_ctrl_blk_sent
529 +------------------------------------------------------------------------------
530 | Description : Handles the internal signal SIG_RU_TM_CTRL_BLK_SENT
531 |
532 | Parameters :
533 |
534 +------------------------------------------------------------------------------
535 */
536 GLOBAL void sig_ru_tm_ctrl_blk_sent ( UBYTE index )
537 {
538 TRACE_ISIG( "sig_ru_tm_ctrl_blk_sent" );
539
540 if( index < MAX_CTRL_BLK_NUM )
541 {
542 UBYTE i = 0;
543
544 if( grlc_data->tm.ul_ctrl_blk.blk[index].owner EQ CGRLC_BLK_OWNER_TM )
545 {
546 grlc_data->tm.n_res_req++;
547
548 if((grlc_t_status(T3168) > 0))
549 {
550 #ifdef _SIMULATION_
551 TRACE_EVENT("prr is transmitted once again for re-allocation");
552 #endif
553 vsi_t_stop(GRLC_handle,T3168);
554 grlc_data->tm.n_res_req--;
555 }
556
557 TRACE_EVENT_P2("T3168 start: %d ms, n_acc=%d",((grlc_data->t3168_val)+1)*500, grlc_data->tm.n_res_req);
558 vsi_t_start(GRLC_handle,T3168,(grlc_data->t3168_val+1)*500);
559 }
560
561 while( i < MAX_CTRL_BLK_NUM AND
562 grlc_data->tm.ul_ctrl_blk.seq[i] NEQ MAX_CTRL_BLK_NUM AND
563 grlc_data->tm.ul_ctrl_blk.seq[i] NEQ index )
564 {
565 i++;
566 }
567
568 if( i < MAX_CTRL_BLK_NUM AND
569 grlc_data->tm.ul_ctrl_blk.seq[i] EQ index )
570 {
571 PALLOC(cgrlc_ctrl_msg_sent_ind,CGRLC_CTRL_MSG_SENT_IND);
572 PSEND(hCommGRR,cgrlc_ctrl_msg_sent_ind);
573 tm_set_stop_ctrl_blk( TRUE, CGRLC_BLK_OWNER_NONE, i );
574 }
575 else
576 {
577 TRACE_ERROR( "sig_ru_tm_ctrl_blk_sent: expected block not found" );
578 }
579 }
580 else
581 {
582 TRACE_ERROR( "sig_ru_tm_ctrl_blk_sent: index >= MAX_CTRL_BLK_NUM" );
583 }
584 } /* sig_ru_tm_ctrl_blk_sent() */
585
586
587
588
589
590 /*
591 +------------------------------------------------------------------------------
592 | Function : sig_ru_tm_repeat_alloc
593 +------------------------------------------------------------------------------
594 | Description : Handles the internal signal sig_ru_tm_repeat_alloc
595 |
596 | Parameters : void
597 |
598 +------------------------------------------------------------------------------
599 */
600 GLOBAL void sig_ru_tm_repeat_alloc( void )
601 {
602 MCAST(d_ul_ack,D_GRLC_UL_ACK);
603
604 TRACE_ISIG( "sig_ru_tm_repeat_alloc" );
605
606 switch( GET_STATE( TM ) )
607 {
608 case TM_PTM:
609 if(d_ul_ack->gprs_ul_ack_nack_info.v_f_alloc_ack EQ 0 )
610 {
611 /*
612 * if no fix alloc is present in last uplink ack/nack, delete any existing repeat alloc
613 */
614 if(grlc_data->uplink_tbf.fa_manag.fa_type EQ FA_REPEAT)
615 {
616 /*kill reapeat alloc, which is not yet started*/
617 grlc_data->uplink_tbf.fa_manag.fa_type = FA_NO_NEXT;
618 grlc_data->uplink_tbf.fa_manag.repeat_alloc = FALSE;
619 grlc_data->uplink_tbf.fa_manag.ul_res_sum -= grlc_data->uplink_tbf.fa_manag.next_alloc.ul_res_sum;
620 }
621 else if(grlc_data->uplink_tbf.fa_manag.fa_type EQ FA_NO_NEXT AND
622 grlc_data->uplink_tbf.fa_manag.repeat_alloc EQ TRUE )
623 {
624 T_RLC_VALUES rlc_val;
625 grlc_get_sdu_len_and_used_ts( &rlc_val);
626 grlc_data->uplink_tbf.fa_manag.ul_res_remain = grlc_data->uplink_tbf.fa_manag.ul_res_sum - rlc_val.cnt_ts;
627 if(grlc_data->uplink_tbf.fa_manag.ul_res_remain EQ grlc_data->uplink_tbf.fa_manag.current_alloc.ul_res_sum)
628 {
629 /*kill reapeat alloc if is mot yet started*/
630 grlc_data->uplink_tbf.fa_manag.fa_type = FA_NO_CURRENT;
631 grlc_data->uplink_tbf.fa_manag.repeat_alloc = FALSE;
632 grlc_data->uplink_tbf.fa_manag.ul_res_sum -= grlc_data->uplink_tbf.fa_manag.current_alloc.ul_res_sum;
633 }
634 }
635 return;
636 }
637 vsi_t_stop(GRLC_handle,T3188);
638
639 /*
640 * check if current allocation is active
641 */
642 if(grlc_data->uplink_tbf.fa_manag.fa_type EQ FA_NO_CURRENT AND
643 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.v_ts_overr )
644 {
645 ULONG next_start_fn;
646 ULONG next_end_fn;
647 /* repeat allocation in packet uplink ack/nack received,
648 * no fixed allocation active, find out the next natural boundary
649 * and store new allocation in current allocation
650 */
651 grlc_data->uplink_tbf.fa_manag.fa_type = FA_NO_NEXT;
652 grlc_data->uplink_tbf.fa_manag.repeat_alloc = TRUE;
653 grlc_data->uplink_tbf.fa_manag.current_alloc.ul_res_sum =
654 tm_set_fa_bitmap((UBYTE)(d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.ts_overr /*& grlc_data->uplink_tbf.ts_usage*/),
655 &grlc_data->uplink_tbf.fa_manag.current_alloc);
656 grlc_data->uplink_tbf.fa_manag.ul_res_sum += grlc_data->uplink_tbf.fa_manag.current_alloc.ul_res_sum;
657 /*find start of alloc (natural boundary of next allocation)*/
658 next_end_fn = grlc_data->uplink_tbf.fa_manag.current_alloc.alloc_end_fn;
659 do
660 {
661 USHORT len;
662 len = grlc_data->uplink_tbf.fa_manag.current_alloc.alloc.bitmap_len-1;
663 next_start_fn = grlc_decode_tbf_start_rel(next_end_fn,0);
664 next_end_fn = grlc_decode_tbf_start_rel(next_start_fn,(USHORT)(len-1));
665 if(grlc_data->ul_fn EQ next_start_fn)
666 break;
667 else if((next_end_fn > next_start_fn) AND
668 (grlc_data->ul_fn <= next_start_fn) AND
669 (grlc_data->ul_fn > next_start_fn) )
670 {
671 next_start_fn = grlc_decode_tbf_start_rel(next_end_fn,0);
672 next_end_fn = grlc_decode_tbf_start_rel(next_start_fn,(USHORT)(len-1));
673 break;
674 }
675 else if( (next_end_fn < next_start_fn) AND
676 (
677 ((next_end_fn >= grlc_data->ul_fn) AND (next_start_fn > grlc_data->ul_fn)) OR
678 ((next_end_fn < grlc_data->ul_fn) AND (next_start_fn < grlc_data->ul_fn))
679 )
680 )
681 {
682 next_start_fn = grlc_decode_tbf_start_rel(next_end_fn,0);
683 next_end_fn = grlc_decode_tbf_start_rel(next_start_fn,(USHORT)(len-1));
684 break;
685 }
686 }
687 while (1);
688 grlc_data->uplink_tbf.fa_manag.current_alloc.alloc_start_fn = next_start_fn;
689 grlc_data->uplink_tbf.fa_manag.current_alloc.alloc_end_fn = next_end_fn;
690 return;
691 }
692 else if(d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.v_ts_overr )
693 {
694 UBYTE len;
695 /* repeat allocation in packet uplink ack/nack received,
696 * current allocation is active, store new alloc in next alloc
697 * overwriting is possibe.
698 */
699 grlc_data->uplink_tbf.fa_manag.fa_type = FA_REPEAT;
700 grlc_data->uplink_tbf.fa_manag.repeat_alloc = TRUE;
701 grlc_data->uplink_tbf.fa_manag.next_alloc.ul_res_sum =
702 tm_set_fa_bitmap((UBYTE)(d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.ts_overr /*& grlc_data->uplink_tbf.ts_usage*/),&grlc_data->uplink_tbf.fa_manag.next_alloc);
703 grlc_data->uplink_tbf.fa_manag.ul_res_sum += grlc_data->uplink_tbf.fa_manag.next_alloc.ul_res_sum;
704
705 grlc_data->uplink_tbf.fa_manag.next_alloc.alloc_start_fn =
706 grlc_decode_tbf_start_rel(grlc_data->uplink_tbf.fa_manag.current_alloc.alloc_end_fn,0);
707 len = grlc_data->uplink_tbf.fa_manag.current_alloc.alloc.bitmap_len-1;
708 grlc_data->uplink_tbf.fa_manag.next_alloc.alloc_end_fn =
709 grlc_decode_tbf_start_rel(grlc_data->uplink_tbf.fa_manag.next_alloc.alloc_start_fn,
710 (USHORT)(len-1));
711 return;
712 }
713 grlc_data->uplink_tbf.fa_manag.repeat_alloc = FALSE;
714
715 break;
716 default:
717 TRACE_ERROR( "sig_ru_tm_repeat_alloc unexpected" );
718 break;
719 }
720 } /* sig_ru_tm_repeat_alloc() */
721
722
723 /*
724 +------------------------------------------------------------------------------
725 | Function : sig_ru_tm_end_of_fix_alloc
726 +------------------------------------------------------------------------------
727 | Description : Handles the internal signal sig_ru_tm_end_of_fix_alloc,
728 | received from ru if the end of a fixed allocation is reached.
729 |
730 | Parameters : void
731 |
732 +------------------------------------------------------------------------------
733 */
734 GLOBAL void sig_ru_tm_end_of_fix_alloc(void)
735 {
736 TRACE_ISIG( "sig_ru_tm_end_of_fix_alloc" );
737
738 switch( GET_STATE( TM ) )
739 {
740 case TM_PTM:
741 /*
742 * if no new allocation is present start timer T3188
743 * otherwise set next alloc to current alloc and update
744 * grr_data->uplink_tbf.end_fix_alloc_fn
745 */
746 if (grlc_data->uplink_tbf.fa_manag.fa_type EQ FA_NO_NEXT)
747 {
748 grlc_data->uplink_tbf.fa_manag.fa_type = FA_NO_CURRENT;
749 vsi_t_start(GRLC_handle,T3188,T3188_VALUE);
750 }
751 else if(grlc_data->uplink_tbf.fa_manag.fa_type EQ FA_BITMAP OR
752 grlc_data->uplink_tbf.fa_manag.fa_type EQ FA_REPEAT)
753 {
754 grlc_data->uplink_tbf.fa_manag.fa_type = FA_NO_NEXT;
755 grlc_data->uplink_tbf.fa_manag.repeat_alloc = FALSE;
756 grlc_data->uplink_tbf.fa_manag.current_alloc = grlc_data->uplink_tbf.fa_manag.next_alloc;
757 /*
758 * send packet rsource request if more uplink reseources is needed
759 */
760 tm_handle_final_alloc(0); /*calc ul resources*/
761 if(grlc_data->uplink_tbf.fa_manag.tbf_oct_cap_remain < grlc_data->uplink_tbf.fa_manag.tbf_oct_cnt)
762 {
763 T_U_GRLC_RESOURCE_REQ resource_req; /*lint !e813*/
764
765 /* send packet resource request*/
766 tm_build_res_req (&resource_req, R_FIX_RE_ALLOC);
767 }
768 }
769 break;
770 default:
771 TRACE_ERROR( "sig_ru_tm_end_of_fix_alloc unexpected" );
772 break;
773 }
774 } /* sig_ru_tm_end_of_fix_alloc() */
775
776
777 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
778 /*
779 +------------------------------------------------------------------------------
780 | Function : sig_ru_tm_ul_re_est_tbf
781 +------------------------------------------------------------------------------
782 | Description : Handles the internal signal SIG_RU_TM_UL_RE_EST_TBF
783 | RU have to send that inter signal after it has send resouurce request
784 | by sending PCA or PRR.
785 | Parameters : void
786 |
787 +------------------------------------------------------------------------------
788 */
789 GLOBAL void sig_ru_tm_ul_re_est_tbf ( void )
790 {
791
792 TRACE_ISIG( "sig_ru_tm_ul_re_est_tbf" );
793
794 switch( GET_STATE( TM ) )
795 {
796 case TM_PTM:
797 /* start T3168 timer */
798 vsi_t_start(GRLC_handle,T3168,((grlc_data->t3168_val)+1)*500);
799 TRACE_EVENT("sig_ru_tm_ul_re_est_tbf : Timer T3168 started for tbf on pacch");
800
801 /*GFF GFF_ACTIVE --> GFF_TWO_PHASE*/
802 sig_tm_gff_ul_deactivate();
803 sig_tm_gff_ul_activate(GFF_TWO_PHASE);
804
805
806 /* TBF_TYPE_UL --> TBF_TYPE_NULL --> TBF_TYPE_TP_ACCESS */
807
808 tm_deactivate_tbf(TBF_TYPE_UL);
809 tm_activate_tbf ( TBF_TYPE_TP_ACCESS );
810
811 grlc_data->uplink_tbf.ti = 0;
812 grlc_data->ul_tfi = 0xFF;
813
814 grlc_data->tm.pacch_prr_pca_sent = TRUE; /* PCA or PRR sent , 1st phase access*/
815
816 grlc_data->tm.n_acc_req_procedures = 0;
817 grlc_data->tm.n_res_req = 0;
818
819 grlc_data->pfi_value =
820 grlc_data->prim_queue[grlc_data->prim_start_tbf].prim_ptr->pkt_flow_id[0];
821
822
823 /* new rlc mode of tbf on pacch */
824 if ( grlc_data->prim_queue[grlc_data->prim_start_tbf].prim_type EQ
825 CGRLC_LLC_PRIM_TYPE_UNITDATA_REQ
826 )
827 {
828 grlc_data->uplink_tbf.rlc_mode = CGRLC_RLC_MODE_UACK;
829 }
830 else
831 {
832 grlc_data->uplink_tbf.rlc_mode = CGRLC_RLC_MODE_ACK;
833 }
834
835 {
836 PALLOC(cgrlc_ul_tbf_ind,CGRLC_UL_TBF_IND);
837 cgrlc_ul_tbf_ind->tbf_est_pacch = TRUE;
838 PSEND(hCommGRR,cgrlc_ul_tbf_ind);
839 }
840 break;
841 default:
842 TRACE_ERROR( "SIG_RU_TM_UL_RE_EST_TBF unexpected" );
843 break;
844 }
845 } /*sig_ru_tm_ul_re_est_tbf*/
846
847
848
849 /*
850 +------------------------------------------------------------------------------
851 | Function : sig_gff_tm_mac_ready_ind_two_phase
852 +------------------------------------------------------------------------------
853 | Description : Handles the internal signal SIG_GFF_TM_MAC_READY_IND_TWO_PHASE
854 |
855 | Parameters : mac_ready_ind describes the MAC_READY_IND primitive.
856 |
857 |
858 +------------------------------------------------------------------------------
859 */
860 void sig_gff_tm_mac_ready_ind_two_phase(T_MAC_READY_IND *mac_ready_ind)
861 {
862 TRACE_ISIG( "sig_gff_tm_mac_ready_ind_two_phase" );
863
864 switch( grlc_data->tbf_type )
865 {
866 case TBF_TYPE_TP_ACCESS:
867 if(mac_ready_ind->rlc_blocks_sent)
868 {
869 grlc_data->ru.ul_data[0].block_status = 0;
870
871 /*If the timer is not already running then start the timer*/
872 if(!(grlc_t_status(T3168) > 0))
873 {
874 /* This case would come in case when
875 * PRR has been sent in 2 phase access
876 */
877 vsi_t_start(GRLC_handle,T3168,((grlc_data->t3168_val)+1)*500);
878 TRACE_EVENT_P3( "2PA: PRR sent at fn=%ld t3168=%ld | st_fn=%ld "
879 ,mac_ready_ind->fn
880 ,grlc_t_status(T3168)
881 ,grlc_data->ul_tbf_start_time );
882 }
883 }
884 else
885 {
886 if(!(grlc_t_status(T3168) > 0) AND
887 grlc_data->ru.ul_data[0].block_status EQ 2) /* block still programmed but not sent */
888 {
889 /*Check if TBF starting time is elapsed*/
890 if(grlc_check_if_tbf_start_is_elapsed ( grlc_data->ul_tbf_start_time, mac_ready_ind->fn))
891 {
892 TRACE_EVENT_P3("WAITING FOR Packet Resource Req Sending over st=%ld fn=%ld, ta_val=%d",grlc_data->ul_tbf_start_time
893 ,mac_ready_ind->fn,grlc_data->ta_value);
894 tm_handle_error_ra();
895 return;
896 }
897 }
898 }
899 break;
900
901 default:
902 TRACE_ERROR( "SIG_GFF_TM_MAC_READY_IND_TWO_PHASE unexpected" );
903 break;
904 }
905 }
906 #endif
907