comparison src/g23m-gprs/grlc/grlc_tmp.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
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 primitive handler functions for service
18 | TM of entity GRLC.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRLC_TMP_C
23 #define GRLC_TMP_C
24 #endif
25
26 #define ENTITY_GRLC
27
28 /*==== INCLUDES =============================================================*/
29
30 #include "typedefs.h" /* to get Condat data types */
31 #include "vsi.h" /* to get a lot of macros */
32 #include <string.h>
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 grlc global function definitions */
43 #include "grlc_rus.h" /* to get the service RU signal definitions */
44 #include "grlc_rds.h" /* to get the service RD signal definitions */
45 #include "grlc_tmf.h" /* to get the service TM functions definitions */
46 #include "grlc_meass.h" /* to get the service MEAS signal definitions */
47 #include "grlc_tpcs.h"
48 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
49 #include "grlc_tms.h"
50 #endif
51
52 /*==== CONST ================================================================*/
53
54 /*==== DIAGNOSTICS ==========================================================*/
55
56 /*==== LOCAL VARS ===========================================================*/
57
58 /*==== LOCAL TYPES ==========================================================*/
59
60 LOCAL void tm_uplink_data_req ( T_PRIM_TYPE prim_type,
61 void *llc_data_req );
62
63 /*==== PRIVATE FUNCTIONS ====================================================*/
64 /*
65 +------------------------------------------------------------------------------
66 | Function : tm_uplink_data_req
67 +------------------------------------------------------------------------------
68 | Description : Handles the primitives GRLC_DATA_REQ and GRLC_UNITDATA_REQ
69 |
70 | Parameters : *llc_data_req - Ptr to primitive payload
71 |
72 +------------------------------------------------------------------------------
73 */
74 LOCAL void tm_uplink_data_req ( T_PRIM_TYPE prim_type,
75 void *llc_data_req )
76 {
77 UBYTE state = GET_STATE( TM );
78 BOOL use_data_req;
79
80 T_GRLC_DATA_REQ *grlc_data_req = ( T_GRLC_DATA_REQ* )llc_data_req;
81 T_GRLC_UNITDATA_REQ *grlc_unitdata_req = ( T_GRLC_UNITDATA_REQ* )llc_data_req;
82
83 TRACE_FUNCTION( "tm_uplink_data_req" );
84
85 PACCESS( llc_data_req );
86
87 #ifdef FLOW_TRACE
88
89 sndcp_trace_flow_control
90 ( FLOW_TRACE_GRLC, FLOW_TRACE_UP, FLOW_TRACE_TOP, FALSE );
91
92 #endif
93
94 if(
95 (
96 grlc_test_mode_active( )
97 )
98 AND
99 (
100 ( prim_type EQ CGRLC_LLC_PRIM_TYPE_DATA_REQ AND
101 grlc_data_req->sapi NEQ GRLC_SAPI_TEST_MODE )
102 OR
103 ( prim_type EQ CGRLC_LLC_PRIM_TYPE_UNITDATA_REQ AND
104 grlc_unitdata_req->sapi NEQ GRLC_SAPI_TEST_MODE )
105 )
106 )
107 {
108 /*
109 * all LLC data requests are ignored during GPRS test mode
110 */
111 TRACE_EVENT( "tm_uplink_data_req: GPRS test mode active" );
112 PFREE( llc_data_req );
113
114 return;
115 }
116
117
118 if( prim_type EQ CGRLC_LLC_PRIM_TYPE_DATA_REQ AND
119 grlc_data->prim_start_tbf < PRIM_QUEUE_SIZE AND
120 ( grlc_data_req->cause EQ GRLC_DTACS_EMPTY_FRAME OR
121 grlc_data_req->cause EQ GRLC_DTACS_CELL_NOTIFI_NULL_FRAME ) )
122 {
123 TRACE_EVENT_P1("EMPTY FRAME RECEIVED, LLLC FRAME AVAILABLE, delete empty frame: sdu_len=%d", grlc_data_req->sdu.l_buf / 8);
124 grlc_data->tm.send_grlc_ready_ind = SEND_A_GRLC_READY_IND;
125 tm_handle_grlc_ready_ind( );
126 PFREE( llc_data_req );
127 return;
128 }
129
130
131
132 /*
133
134 if( prim_type EQ PRIM_TYPE_DATA_REQ )
135 {
136 TRACE_EVENT_P2( "tm_uplink_data_req: sdu_len=%ld data_req_cnt=%d",
137 grlc_data_req->sdu.l_buf / 8,
138 grlc_data->grlc_data_req_cnt );
139
140 TRACE_EVENT_P9( "tm_uplink_data_req: sapi=%d tlli=%lx delay=%d relc=%d peak=%d prec=%d mean=%d r_pri=%d cause=%d",
141 grlc_data_req->sapi,
142 grlc_data_req->tlli,
143 grlc_data_req->qos.delay,
144 grlc_data_req->qos.relclass,
145 grlc_data_req->qos.peak,
146 grlc_data_req->qos.preced,
147 grlc_data_req->qos.mean,
148 grlc_data_req->radio_prio,
149 grlc_data_req->cause );
150 }
151
152 */
153
154 grlc_data->tm.send_grlc_ready_ind = SEND_A_GRLC_READY_IND;
155
156 switch( state )
157 {
158 case TM_ACCESS_DISABLED:
159 case TM_ACCESS_PREPARED:
160 use_data_req =
161 (
162 grlc_data->tm.disable_class EQ CGRLC_DISABLE_CLASS_CR
163 )
164 AND
165 (
166 ( prim_type EQ CGRLC_LLC_PRIM_TYPE_DATA_REQ AND
167 grlc_data_req->cause EQ GRLC_DTACS_DEF )
168 OR
169 ( prim_type EQ CGRLC_LLC_PRIM_TYPE_UNITDATA_REQ )
170 );
171 break;
172
173 default:
174 use_data_req = tm_access_allowed ( grlc_data_req->radio_prio );
175 break;
176 }
177
178 if( use_data_req )
179 {
180 tm_data_req( prim_type, ( T_GRLC_DATA_REQ* )llc_data_req );
181 grlc_data->grlc_data_req_cnt++;
182
183 switch( state )
184 {
185 case TM_PIM:
186 tm_ul_tbf_ind();
187 break;
188
189 case TM_PTM:
190 tm_ul_tbf_ind();
191
192 if( grlc_data->tbf_type NEQ TBF_TYPE_DL )
193 {
194 /* uplink is active*/
195 sig_tm_ru_queue_status( );
196 }
197 break;
198
199 default:
200 /* do nothing */
201 break;
202 }
203 }
204 else
205 {
206 tm_cgrlc_status_ind( CGRLC_ACCESS_2_NETWORK_NOT_ALLOWED );
207 PFREE( llc_data_req );
208 }
209
210 tm_handle_grlc_ready_ind( );
211
212 } /* tm_uplink_data_req () */
213
214 /*==== PUBLIC FUNCTIONS =====================================================*/
215 /*
216 +------------------------------------------------------------------------------
217 | Function : tm_grlc_data_req
218 +------------------------------------------------------------------------------
219 | Description : Handles the primitive GRLC_DATA_REQ
220 |
221 | Parameters : *grlc_data_req - Ptr to primitive payload
222 |
223 +------------------------------------------------------------------------------
224 */
225 GLOBAL void tm_grlc_data_req ( T_GRLC_DATA_REQ *grlc_data_req )
226 {
227 TRACE_FUNCTION( "tm_grlc_data_req " );
228
229 tm_uplink_data_req( CGRLC_LLC_PRIM_TYPE_DATA_REQ, ( void* )grlc_data_req );
230
231 } /* tm_grlc_data_req () */
232
233 /*
234 +------------------------------------------------------------------------------
235 | Function : tm_grlc_unitdata_req
236 +------------------------------------------------------------------------------
237 | Description : Handles the primitive GRLC_UNITDATA_REQ
238 |
239 | Parameters : *grlc_unitdata_req - Ptr to primitive payload
240 |
241 +------------------------------------------------------------------------------
242 */
243 GLOBAL void tm_grlc_unitdata_req ( T_GRLC_UNITDATA_REQ *grlc_unitdata_req )
244 {
245 TRACE_FUNCTION( "tm_grlc_unitdata_req" );
246
247 tm_uplink_data_req( CGRLC_LLC_PRIM_TYPE_UNITDATA_REQ, ( void* )grlc_unitdata_req );
248
249 } /* tm_grlc_unitdata_req() */
250
251
252
253 /*
254 +------------------------------------------------------------------------------
255 | Function : tm_t3168
256 +------------------------------------------------------------------------------
257 | Description : Handles the primitive T3168
258 | This timer is involved in 3 Procedures
259 | 1) Two Phase Access Procedure
260 | 2) Uplink TBF Setup on existing Downlink TBF
261 | 3) Uplink Realloaction Procedure on existing Uplink TBF
262 |
263 | Parameters : void
264 |
265 +------------------------------------------------------------------------------
266 */
267 GLOBAL void tm_t3168 ( void )
268 {
269 TRACE_FUNCTION( "tm_t3168" );
270 TRACE_EVENT_P1("T3168 expired: n_acc=%d",grlc_data->tm.n_res_req);
271
272 /*
273 * The expiry of this timer may occure in 3 cases:
274 *
275 * a) uplink allocation during running downlink TBF --> GRLC
276 * b) two phase access procedure --> GRLC
277 * c) uplink reallocation procedure on uplink TBF or on concurent TBF(UL&DL) -->GRLC
278 *
279 */
280
281 switch( GET_STATE( TM ) )
282 {
283 case TM_PTM:
284 switch(grlc_data->tbf_type)
285 {
286 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
287 case TBF_TYPE_TP_ACCESS:
288 grlc_data->uplink_tbf.ti=1;
289 tm_handle_error_ra();
290 break;
291 #endif
292 case TBF_TYPE_DL:
293 /*
294 * cse a)
295 */
296 if(grlc_data->tm.n_res_req < 4) /* Is resource re-allocation is running? */
297 {
298 grlc_data->tm.n_res_req++;
299 tm_build_chan_req_des(&grlc_data->chan_req_des,
300 &grlc_data->prim_queue[grlc_data->prim_start_tbf]);
301 sig_tm_rd_ul_req();
302 }
303 else
304 { /* grlc_data->tm.n_res_req EQ 4
305 -> last Channel Request Description has been sent */
306 tm_handle_error_ra();
307 }
308 break;
309
310 case TBF_TYPE_UL:
311 case TBF_TYPE_CONC:
312 /*
313 * case c)
314 */
315 if(grlc_data->tm.n_res_req < 4) /* Is resource re-allocation is running? */
316 {
317 T_U_GRLC_RESOURCE_REQ resource_req;/*lint !e813*/
318
319 tm_build_res_req(&resource_req,
320 R_RE_ALLOC);
321 tm_store_ctrl_blk( CGRLC_BLK_OWNER_TM, ( void* )&resource_req );
322 }
323 else
324 { /*
325 * grlc_data->tm.n_res_req EQ 4 -> last resource request has been sent
326 * return to packet idle and indicate packet access failure to upper layers
327 */
328 while(grlc_data->prim_start_tbf < PRIM_QUEUE_SIZE_TOTAL)
329 {
330 grlc_delete_prim();
331 }
332 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
333 tm_abort_tbf(grlc_data->tbf_type);
334 grlc_data->tm.n_res_req = 0;
335 TRACE_EVENT("4x p. resource req. failed");
336 SET_STATE(TM,TM_WAIT_4_PIM);
337 }
338 break;
339 default:
340 /*
341 * Should never occure
342 */
343 TRACE_ERROR("T3168 expired, no task should not appear");
344 break;
345 }
346
347 break;
348
349 default:
350 TRACE_ERROR( "T3168 unexpected" );
351 break;
352 }
353
354 } /* tm_t3168() */
355
356
357 /*
358 +------------------------------------------------------------------------------
359 | Function : tm_t3188
360 +------------------------------------------------------------------------------
361 | Description : Handles the primitive T3188
362 |
363 | Parameters :
364 |
365 +------------------------------------------------------------------------------
366 */
367 GLOBAL void tm_t3188 ( void )
368 {
369 TRACE_FUNCTION( "tm_t3188" );
370
371
372 switch( GET_STATE( TM ) )
373 {
374 case TM_PTM:
375 /*
376 * perform abnormal release with random access
377 */
378 tm_handle_error_ra();
379 break;
380 default:
381 TRACE_ERROR( "tm_t3188 unexpected" );
382 break;
383 }
384
385 } /* tm_t3188() */
386
387
388 /*
389 +------------------------------------------------------------------------------
390 | Function : tm_grlc_activate_gmm_queue_req
391 +------------------------------------------------------------------------------
392 | Description : Handles the primitive GRLC_ACTIVATE_GMM_QUEUE_REQ
393 |
394 | Parameters :
395 |
396 +------------------------------------------------------------------------------
397 */
398 GLOBAL void tm_grlc_activate_gmm_queue_req ( T_GRLC_ACTIVATE_GMM_QUEUE_REQ *grlc_activate_gmm_queue_req )
399 {
400 TRACE_FUNCTION( "tm_grlc_activate_gmm_queue_req" );
401
402
403 switch( GET_STATE( TM ) )
404 {
405 case TM_ACCESS_DISABLED:
406 tm_get_gmm_prim_queue( );
407 break;
408
409 case TM_ACCESS_PREPARED:
410 SET_STATE( TM, TM_PIM );
411 sig_tm_ru_reset_poll_array();
412 tm_get_gmm_prim_queue( );
413 tm_handle_grlc_ready_ind( );
414 break;
415
416 default:
417 TRACE_ERROR( "GRLC_ACTIVATE_GMM_QUEUE_REQ unexpected" );
418 break;
419 }
420
421 PFREE( grlc_activate_gmm_queue_req );
422
423 } /* tm_grlc_activate_gmm_queue_req() */
424
425 /*
426 +------------------------------------------------------------------------------
427 | Function : tm_grlc_flush_data_req
428 +------------------------------------------------------------------------------
429 | Description : When LLC receives XID RESET during Inter-SGSN RAU procedure,
430 | LLC sends this primitive GRLC_FLUSH_DATA_REQ to GRLC to flush out LLC
431 | user data maintained in GRLC
432 |
433 | Parameters : void
434 |
435 +------------------------------------------------------------------------------
436 */
437
438 GLOBAL void tm_grlc_flush_data_req (T_GRLC_FLUSH_DATA_REQ *grlc_flush_data_req)
439 {
440
441 UBYTE i;
442 UBYTE temp_start_tbf;
443 UBYTE temp_start_free;
444
445 TRACE_FUNCTION( "tm_grlc_flush_data_req" );
446
447 TRACE_EVENT_P4(" ps=%d, pf=%d,sps=%d,spf=%d",
448 grlc_data->prim_start_tbf,
449 grlc_data->prim_start_free,
450 grlc_data->save_prim_start_tbf,
451 grlc_data->save_prim_start_free);
452
453
454 if(!grlc_data->gmm_procedure_is_running OR
455 !(grlc_data->prim_start_tbf >= PRIM_QUEUE_SIZE))
456 /* Check for the condition grlc_data->prim_start_tbf EQ 0xFF is not required since
457 * grlc_data->prim_start_tbf=0xFF implies there are no primitives in queue to flush out.
458 * LLC PDUs are flushed only when GMM queue is active dring Inter-SGSN RAU procedure */
459 {
460 TRACE_ERROR( "GRLC_FLUSH_DATA_REQ unexpected" );
461 PFREE(grlc_flush_data_req);
462 return;
463 }
464
465 /* Remember GMM primitives when gmm procedure is running*/
466 temp_start_tbf = grlc_data->prim_start_tbf;
467 temp_start_free = grlc_data->prim_start_free;
468
469 /* Retrieve the saved primitive values when LLC was suspended by GMM */
470 grlc_data->prim_start_tbf = grlc_data->save_prim_start_tbf;
471 grlc_data->prim_start_free = grlc_data->save_prim_start_free;
472
473 i = grlc_data->prim_start_tbf;
474
475 grlc_data->prim_user_data = 0;
476 while(i NEQ 0xFF)
477 {
478 grlc_data->prim_user_data += BYTELEN(grlc_data->prim_queue[i].prim_ptr->sdu.l_buf);
479 i = grlc_data->prim_queue[i].next;
480 }
481 grlc_data->tm.send_grlc_ready_ind = SEND_A_GRLC_READY_IND;
482
483 /* Delete all LLC primitives (user data) irrespective of going in same or new tbf */
484
485 do
486 {
487 grlc_delete_prim();
488 } while( (grlc_data->prim_start_tbf < PRIM_QUEUE_SIZE_TOTAL));
489
490
491 grlc_data->save_prim_start_tbf = grlc_data->prim_start_tbf;
492 if(grlc_data->prim_start_tbf NEQ 0xff)
493 {
494 TRACE_ASSERT(grlc_data->prim_start_tbf NEQ 0xff);
495 }
496
497 tm_handle_grlc_ready_ind();
498
499 /* The GMM primitive values are put back */
500 grlc_data->prim_start_tbf = temp_start_tbf;
501 grlc_data->prim_start_free = temp_start_free;
502
503
504 TRACE_EVENT_P4(" ps=%d, pf=%d,sps=%d,spf=%d",
505 grlc_data->prim_start_tbf,
506 grlc_data->prim_start_free,
507 grlc_data->save_prim_start_tbf,
508 grlc_data->save_prim_start_free);
509
510
511 PFREE(grlc_flush_data_req);
512
513 }
514
515
516 /*
517 +------------------------------------------------------------------------------
518 | Function : tm_cgrlc_enable_req
519 +------------------------------------------------------------------------------
520 | Description : Handles the primitive cgrlc_enable_req
521 |
522 | Parameters : void
523 |
524 +------------------------------------------------------------------------------
525 */
526 GLOBAL void tm_cgrlc_enable_req ( T_CGRLC_ENABLE_REQ *cgrlc_enable_req )
527 {
528 TRACE_FUNCTION( "tm_cgrlc_enable_req" );
529
530
531 switch( GET_STATE( TM ) )
532 {
533 case TM_ACCESS_DISABLED:
534 case TM_ACCESS_PREPARED:
535 if( cgrlc_enable_req->enable_cause EQ
536 CGRLC_ENAC_ABNORM_RELEASE_CRESELECT_FAILED )
537 {
538 SET_STATE( TM, TM_PIM );
539 sig_tm_ru_reset_poll_array();
540 tm_cgrlc_status_ind( CGRLC_RLC_MAC_ERROR );
541 tm_delete_prim_queue( );
542 }
543 else if(cgrlc_enable_req->queue_mode EQ CGRLC_QUEUE_MODE_GMM)
544 {
545 if(grlc_data->gmm_procedure_is_running )
546 {
547 SET_STATE(TM, TM_PIM);
548 tm_delete_prim_queue();
549 sig_tm_ru_reset_poll_array();
550 TRACE_EVENT_P2("LLC QUEUE IS DISABLED, DELETE GMM PRIM QUEUE ps=%d pf=%d",
551 grlc_data->prim_start_tbf,
552 grlc_data->prim_start_free);
553 }
554 else
555 {
556 SET_STATE( TM, TM_ACCESS_PREPARED );
557 }
558 }
559
560 /*lint -fallthrough*/
561
562 case TM_PIM:
563 case TM_PAM:
564 case TM_PTM:
565 case TM_WAIT_4_PIM:
566
567 grlc_data->tm.max_grlc_user_data = MAX_GRLC_USER_DATA ;
568
569 if(cgrlc_enable_req->queue_mode EQ CGRLC_QUEUE_MODE_LLC)
570 {
571 UBYTE state = GET_STATE( TM );
572
573 if( state EQ TM_ACCESS_DISABLED OR
574 state EQ TM_ACCESS_PREPARED )
575 {
576 SET_STATE( TM, TM_PIM );
577 sig_tm_ru_reset_poll_array();
578 }
579 if(grlc_data->gmm_procedure_is_running)
580 {
581 tm_get_llc_prim_queue();
582 if ( (tm_prim_queue_get_free_count() > 0) AND
583 (grlc_data->prim_user_data <= grlc_data->tm.max_grlc_user_data))
584 {
585 grlc_data->tm.send_grlc_ready_ind = SEND_A_GRLC_READY_IND;
586 }
587 else
588 {
589 grlc_data->tm.send_grlc_ready_ind = PRIM_QUEUE_FULL;
590 }
591 }
592 else
593 {
594 TRACE_EVENT("RESUME IS DONE");
595 }
596 /*
597 * check if cell update is required
598 */
599 if(cgrlc_enable_req->cu_cause EQ CGRLC_RA_CU)
600 {
601 TRACE_EVENT("CU REQ from GRR");
602 /*
603 * Delete Empty frames
604 */
605 if( grlc_data->prim_start_tbf < PRIM_QUEUE_SIZE AND
606 ( grlc_data->prim_queue[grlc_data->prim_start_tbf].prim_ptr->cause EQ GRLC_DTACS_EMPTY_FRAME OR
607 grlc_data->prim_queue[grlc_data->prim_start_tbf].prim_ptr->cause EQ GRLC_DTACS_CELL_NOTIFI_NULL_FRAME ) )
608 {
609 grlc_delete_prim();
610 TRACE_EVENT("CEll_res: delete prim");
611 }
612 grlc_data->uplink_tbf.access_type = CGRLC_AT_CELL_UPDATE;
613 }
614 tm_ul_tbf_ind();
615 tm_handle_grlc_ready_ind();
616
617 }
618
619 grlc_data->burst_type = cgrlc_enable_req->burst_type;
620 grlc_data->ab_type = cgrlc_enable_req->ab_type;
621 grlc_data->t3168_val = cgrlc_enable_req->t3168_val;
622 grlc_data->uplink_tbf.tlli = cgrlc_enable_req->ul_tlli;
623 grlc_data->uplink_tbf.ac_class = cgrlc_enable_req->ac_class;
624 grlc_data->downlink_tbf.tlli = cgrlc_enable_req->dl_tlli;
625 grlc_data->tm.change_mark = cgrlc_enable_req->change_mark;
626
627 #ifdef REL99
628 grlc_data->pfi_support = cgrlc_enable_req->pfi_support;
629 grlc_data->nw_rel = cgrlc_enable_req->nw_rel;
630 #endif
631 /*
632 * set N3102 to maximum value after cell reselction
633 */
634 if(cgrlc_enable_req->v_pan_struct)
635 {
636 if(cgrlc_enable_req->pan_struct.pmax NEQ CGRLC_NO_UPDATE_N3102)
637 {
638 grlc_data->pan_struct = cgrlc_enable_req->pan_struct;
639 grlc_data->N3102 = cgrlc_enable_req->pan_struct.pmax;
640 }
641 }
642 else
643 {
644 grlc_data->pan_struct = cgrlc_enable_req->pan_struct;
645 grlc_data->N3102 = 0xFF;
646 }
647 if( grlc_data->uplink_tbf.tlli EQ (0xffffffff))
648 {
649 TRACE_EVENT("GMM HAS UNASSIGNED GRR/GRLC, DELETE DATA QUEUE");
650 /*
651 * delete prim queue
652 */
653 while(grlc_data->prim_start_tbf < PRIM_QUEUE_SIZE_TOTAL)
654 {
655 grlc_delete_prim();
656 }
657 }
658 break;
659 default:
660 TRACE_ERROR( "CGRLC_ENABLE_REQ unexpected" );
661 break;
662 }
663 PFREE(cgrlc_enable_req);
664
665 } /* tm_cgrlc_enable_req() */
666
667
668
669 /*
670 +------------------------------------------------------------------------------
671 | Function : tm_cgrlc_disable_req
672 +------------------------------------------------------------------------------
673 | Description : Handles the primitive cgrlc_disable_req
674 |
675 | Parameters : void
676 |
677 +------------------------------------------------------------------------------
678 */
679 GLOBAL void tm_cgrlc_disable_req ( T_CGRLC_DISABLE_REQ *cgrlc_disable_req )
680 {
681 UBYTE state = GET_STATE( TM );
682
683 TRACE_FUNCTION( "tm_cgrlc_disable_req" );
684
685 grlc_data->tm.disable_class = cgrlc_disable_req->disable_class;
686
687 switch( state )
688 {
689 case TM_ACCESS_PREPARED:
690 SET_STATE(TM, TM_ACCESS_DISABLED);
691 break;
692
693 case TM_ACCESS_DISABLED:
694 /* nothing to do */
695 break;
696
697 case TM_PIM:
698 case TM_WAIT_4_PIM:
699 SET_STATE(TM, TM_ACCESS_DISABLED);
700
701 tm_handle_test_mode_cnf( grlc_test_mode_active( ) );
702
703 grlc_data->rel_type = REL_TYPE_NULL;
704 break;
705
706 case TM_PTM:
707 tm_abort_tbf(grlc_data->tbf_type);
708 /*
709 * delete all poll positions
710 */
711 sig_tm_ru_reset_poll_array();
712
713 /*lint -fallthrough*/
714
715 case TM_PAM:
716 SET_STATE(TM, TM_ACCESS_DISABLED);
717
718 tm_handle_test_mode_cnf( grlc_test_mode_active( ) );
719
720 grlc_data->rel_type = REL_TYPE_NULL;
721
722 if( state EQ TM_PAM AND cgrlc_disable_req->disable_class EQ CGRLC_DISABLE_CLASS_CR )
723 {
724 tm_cgrlc_status_ind( CGRLC_TBF_ESTABLISHMENT_FAILURE );
725 }
726 break;
727
728 default:
729 TRACE_ERROR( "CGRLC_DISABLE_REQ unexpected" );
730 break;
731 }
732
733 if(cgrlc_disable_req->prim_status EQ CGRLC_PRIM_STATUS_ONE)
734 {
735 grlc_delete_prim();
736 tm_handle_grlc_ready_ind();
737 }
738 else if(cgrlc_disable_req->prim_status EQ CGRLC_PRIM_STATUS_ALL)
739 {
740 tm_delete_prim_queue();
741 /* Reinitialize GRLC context
742 * 1. Delete Primitives
743 * 2. Abort TBF - (This is already done by GMMRR_SUSPEND_REQ)
744 * We reach this disable req only after releasing all TBFs
745 * 3. Reinitialize GRLC context */
746
747 TRACE_EVENT("Reinit GRLC");
748 grlc_init();
749 }
750
751
752 PFREE(cgrlc_disable_req);
753
754 } /* tm_cgrlc_disable_req() */
755
756
757 /*
758 +------------------------------------------------------------------------------
759 | Function : tm_cgrlc_ul_tbf_res
760 +------------------------------------------------------------------------------
761 | Description : Handles the primitive cgrlc_ul_tbf_res
762 |
763 | Parameters : void
764 |
765 +------------------------------------------------------------------------------
766 */
767 GLOBAL void tm_cgrlc_ul_tbf_res ( T_CGRLC_UL_TBF_RES *cgrlc_ul_tbf_res )
768 {
769 TRACE_FUNCTION( "tm_cgrlc_ul_tbf_res" );
770
771 tm_prcs_pwr_ctrl( &cgrlc_ul_tbf_res->pwr_ctrl );
772
773 /*
774 * Ignore the request for or modification of an UL TBF in case an UL TBF
775 * release request is currently sent to the data queue of GRR, it is just
776 * not yet processed, but TBF will be released anyway as one of the next
777 * steps.
778 */
779 if( ( grlc_data->rel_type & REL_TYPE_UL ) EQ REL_TYPE_UL )
780 {
781 TRACE_EVENT( "tm_cgrlc_ul_tbf_res: release of UL TBF requested in parallel" );
782
783 PFREE( cgrlc_ul_tbf_res );
784
785 return;
786 }
787
788 vsi_t_stop(GRLC_handle,T3168);
789 grlc_data->tm.n_res_req = 0;
790
791 switch( GET_STATE( TM ) )
792 {
793 case TM_PAM:
794 switch(cgrlc_ul_tbf_res->tbf_mode)
795 {
796 case CGRLC_TBF_MODE_ESTABLISHMENT_FAILURE: /* establishment failure */
797 SET_STATE(TM,TM_PIM);
798 grlc_delete_prim();
799 sig_tm_ru_reset_poll_array();
800 tm_cgrlc_status_ind(CGRLC_TBF_ESTABLISHMENT_FAILURE);
801 tm_handle_grlc_ready_ind();
802 tm_ul_tbf_ind();
803 break;
804 case CGRLC_TBF_MODE_ACCESS_FAILED:
805 if(cgrlc_ul_tbf_res->prim_status EQ CGRLC_PRIM_STATUS_ONE)
806 {
807 SET_STATE(TM,TM_PIM);
808 grlc_delete_prim();
809 sig_tm_ru_reset_poll_array();
810 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
811 tm_handle_grlc_ready_ind();
812 tm_ul_tbf_ind();
813 }
814 else if(cgrlc_ul_tbf_res->prim_status EQ CGRLC_PRIM_STATUS_ALL)
815 {
816 SET_STATE(TM,TM_PIM);
817 tm_delete_prim_queue();
818 sig_tm_ru_reset_poll_array();
819 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
820 tm_handle_grlc_ready_ind();
821 tm_ul_tbf_ind();
822 }
823 else if(cgrlc_ul_tbf_res->prim_status EQ CGRLC_PRIM_STATUS_TBF)
824 {
825 SET_STATE(TM,TM_PIM);
826 sig_tm_ru_reset_poll_array();
827 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
828 tm_delete_prim_queue();
829 tm_handle_grlc_ready_ind();
830 tm_ul_tbf_ind();
831 }
832 else
833 {
834 tm_handle_error_ra();
835 tm_ul_tbf_ind();
836 }
837 /*
838 * what happens to the existing tbfs
839 */
840 break;
841 case CGRLC_TBF_MODE_UL:
842 case CGRLC_TBF_MODE_TMA:
843 case CGRLC_TBF_MODE_TMB:
844 SET_STATE(TM,TM_PTM);
845 if((grlc_data->testmode.mode EQ CGRLC_TEST_RANDOM) OR
846 (grlc_data->testmode.mode EQ CGRLC_LOOP))
847 {
848 PALLOC(cgrlc_test_mode_ind,CGRLC_TEST_MODE_IND); /*T_CGRLC_TEST_MODE_IND*/
849 cgrlc_test_mode_ind->test_mode_flag = grlc_data->testmode.mode;
850 PSEND(hCommGRR,cgrlc_test_mode_ind);
851 }
852 grlc_data->uplink_tbf.cs_type = (T_CODING_SCHEME)cgrlc_ul_tbf_res->cs_mode;
853 grlc_data->uplink_tbf.mac_mode = cgrlc_ul_tbf_res->mac_mode;
854 grlc_data->uplink_tbf.nts = cgrlc_ul_tbf_res->nts_max;
855 grlc_data->uplink_tbf.ts_mask = cgrlc_ul_tbf_res->tn_mask;
856 grlc_data->uplink_tbf.ti = cgrlc_ul_tbf_res->ti;
857 grlc_data->uplink_tbf.tlli_cs_type = cgrlc_ul_tbf_res->tlli_cs_mode;
858 grlc_data->uplink_tbf.bs_cv_max = cgrlc_ul_tbf_res->bs_cv_max;
859 grlc_data->r_bit = cgrlc_ul_tbf_res->r_bit;
860
861 grlc_data->ul_tbf_start_time = cgrlc_ul_tbf_res->starting_time;
862 sig_tm_rd_ul_req_stop();
863 sig_tm_meas_ptm();
864
865 tm_activate_tbf ( TBF_TYPE_UL );
866
867 if(cgrlc_ul_tbf_res->mac_mode)
868 {
869 grlc_data->uplink_tbf.fa_manag.fa_type = FA_NO_CURRENT;
870 tm_store_fa_bitmap(&cgrlc_ul_tbf_res->fix_alloc_struct);
871 }
872
873
874 if(!grlc_data->uplink_tbf.ti)
875 grlc_data->tm.n_acc_req_procedures = 0;
876
877 grlc_data->tm.n_res_req = 0;
878
879 grlc_data->uplink_tbf.rlc_db_granted = cgrlc_ul_tbf_res->rlc_db_granted;
880
881 tm_tfi_handling (cgrlc_ul_tbf_res->starting_time,CGRLC_TBF_MODE_UL, cgrlc_ul_tbf_res->tfi, 0xFF);
882 sig_tm_ru_assign();
883 if(cgrlc_ul_tbf_res->polling_bit NEQ 0xFF)
884 tm_handle_polling_bit(cgrlc_ul_tbf_res->starting_time,cgrlc_ul_tbf_res->polling_bit);
885 break;
886 default:
887 TRACE_ERROR("unexpected tbf mode in ul_tbf_res");
888 break;
889 }
890 break;
891 case TM_PTM:
892 switch(cgrlc_ul_tbf_res->tbf_mode)
893 {
894 case CGRLC_TBF_MODE_ACCESS_FAILED:
895 if(cgrlc_ul_tbf_res->prim_status EQ CGRLC_PRIM_STATUS_ONE)
896 {
897 grlc_delete_prim();
898 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
899 tm_handle_grlc_ready_ind();
900 tm_ul_tbf_ind();
901 }
902 else if(cgrlc_ul_tbf_res->prim_status EQ CGRLC_PRIM_STATUS_ALL)
903 {
904 tm_delete_prim_queue();
905 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
906 tm_handle_grlc_ready_ind();
907 tm_ul_tbf_ind();
908 }
909 else if(cgrlc_ul_tbf_res->prim_status EQ CGRLC_PRIM_STATUS_TBF)
910 {
911 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
912 tm_delete_prim_queue();
913 tm_handle_grlc_ready_ind();
914 tm_ul_tbf_ind();
915 }
916 else
917 {
918 tm_cgrlc_status_ind(CGRLC_PACKET_ACCESS_FAILURE);
919 tm_handle_error_ra();
920 }
921 break;
922 case CGRLC_TBF_MODE_UL:
923 case CGRLC_TBF_MODE_TMA:
924 case CGRLC_TBF_MODE_TMB:
925 if((grlc_data->testmode.mode EQ CGRLC_TEST_RANDOM) OR
926 (grlc_data->testmode.mode EQ CGRLC_LOOP))
927 {
928 PALLOC(cgrlc_test_mode_ind,CGRLC_TEST_MODE_IND); /*T_CGRLC_TEST_MODE_IND*/
929 cgrlc_test_mode_ind->test_mode_flag = grlc_data->testmode.mode;
930 PSEND(hCommGRR,cgrlc_test_mode_ind);
931 }
932
933 grlc_data->uplink_tbf.cs_type = (T_CODING_SCHEME)cgrlc_ul_tbf_res->cs_mode;
934 grlc_data->uplink_tbf.mac_mode = cgrlc_ul_tbf_res->mac_mode;
935 grlc_data->uplink_tbf.nts = cgrlc_ul_tbf_res->nts_max;
936 grlc_data->uplink_tbf.ts_mask = cgrlc_ul_tbf_res->tn_mask;
937 grlc_data->uplink_tbf.ti = cgrlc_ul_tbf_res->ti;
938 grlc_data->uplink_tbf.tlli_cs_type = cgrlc_ul_tbf_res->tlli_cs_mode;
939 grlc_data->uplink_tbf.bs_cv_max = cgrlc_ul_tbf_res->bs_cv_max;
940
941 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
942 if(grlc_data->tbf_type EQ TBF_TYPE_TP_ACCESS)
943 {
944 grlc_data->uplink_tbf.rlc_db_granted = cgrlc_ul_tbf_res->rlc_db_granted;
945
946 if((grlc_data->testmode.mode EQ CGRLC_TEST_RANDOM) OR
947 (grlc_data->testmode.mode EQ CGRLC_LOOP))
948 {
949 PALLOC(cgrlc_test_mode_ind,CGRLC_TEST_MODE_IND); /*T_CGRLC_TEST_MODE_IND*/
950 cgrlc_test_mode_ind->test_mode_flag = grlc_data->testmode.mode;
951 PSEND(hCommGRR,cgrlc_test_mode_ind);
952 }
953 }
954 else
955 #endif
956 {
957 grlc_data->uplink_tbf.rlc_db_granted = 0;
958 }
959
960
961 grlc_data->tm.n_res_req = 0;
962
963 grlc_data->ul_tbf_start_time = cgrlc_ul_tbf_res->starting_time;
964 sig_tm_rd_ul_req_stop();
965
966 tm_activate_tbf ( TBF_TYPE_UL );
967
968 if(cgrlc_ul_tbf_res->mac_mode)
969 {
970 tm_store_fa_bitmap(&cgrlc_ul_tbf_res->fix_alloc_struct);
971 }
972
973 if(!grlc_data->uplink_tbf.ti)
974 grlc_data->tm.n_acc_req_procedures = 0;
975
976 tm_tfi_handling (cgrlc_ul_tbf_res->starting_time,CGRLC_TBF_MODE_UL, cgrlc_ul_tbf_res->tfi, 0xFF);
977
978 sig_tm_ru_assign();
979 break;
980 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
981 case CGRLC_TBF_MODE_2PA:
982 {
983 /*tbf establishment on PACCH*/
984 grlc_data->ul_tbf_start_time = cgrlc_ul_tbf_res->starting_time;
985 tm_send_prr_2p_ptm();
986 grlc_data->tm.pacch_prr_pca_sent = FALSE ; /* For Release of TBF , as two phase */
987 }
988 break;
989 #endif
990 default:
991 TRACE_ERROR("unexpected tbf mode in ul_tbf_res");
992 break;
993 }
994 break;
995 default:
996 TRACE_ERROR( "CGRLC_UL_TBF_RES unexpected" );
997 break;
998 }
999 PFREE(cgrlc_ul_tbf_res);
1000
1001 } /* tm_cgrlc_ul_tbf_res() */
1002
1003 /*
1004 +------------------------------------------------------------------------------
1005 | Function : tm_cgrlc_dl_tbf_req
1006 +------------------------------------------------------------------------------
1007 | Description : Handles the primitive cgrlc_dl_tbf_req
1008 |
1009 | Parameters : void
1010 |
1011 +------------------------------------------------------------------------------
1012 */
1013 GLOBAL void tm_cgrlc_dl_tbf_req ( T_CGRLC_DL_TBF_REQ *cgrlc_dl_tbf_req )
1014 {
1015 UBYTE rd_state=GET_STATE( RD );
1016 TRACE_FUNCTION( "tm_cgrlc_dl_tbf_req" );
1017
1018 tm_prcs_pwr_ctrl( &cgrlc_dl_tbf_req->pwr_ctrl );
1019 grlc_data->downlink_tbf.trans_id++;
1020
1021 /*
1022 * Ignore the request for or modification of an DL TBF in case an DL TBF
1023 * release request is currently sent to the data queue of GRR, it is just
1024 * not yet processed, but TBF will be released anyway as one of the next
1025 * steps.
1026 */
1027 if( ( grlc_data->rel_type & REL_TYPE_DL ) EQ REL_TYPE_DL )
1028 {
1029 /* The scenario T3192 expires before packet DL assignment message has been received
1030 is handled.*/
1031
1032 TRACE_EVENT( "tm_cgrlc_dl_tbf_req: release of DL TBF requested in parallel" );
1033
1034 TRACE_EVENT( "Exception: T3192 expiry before PDA race condition, verify this" );
1035 grlc_data->rel_type &= ( ~ ( REL_TYPE_DL ) );
1036
1037 }
1038
1039 switch( GET_STATE( TM ) )
1040 {
1041 case TM_PAM:
1042 case TM_PIM:
1043 case TM_WAIT_4_PIM:
1044 SET_STATE(TM,TM_PTM);
1045 grlc_data->r_bit = 0;
1046
1047 sig_tm_meas_ptm();
1048
1049 /*lint -fallthrough*/
1050
1051 case TM_PTM:
1052
1053 if(cgrlc_dl_tbf_req->ctrl_ack_bit)
1054 {
1055 TRACE_EVENT("GRLC ctrl ack bit set");
1056 if((grlc_data->tbf_type EQ TBF_TYPE_UL) OR
1057 (grlc_data->tbf_type EQ TBF_TYPE_NULL))
1058 {
1059 TRACE_EVENT("DL ass will not be discarded in GRLC");
1060 }
1061 {
1062 sig_tm_rd_nor_rel();
1063 tm_deactivate_tbf(TBF_TYPE_DL);
1064 grlc_data->dl_tfi = 0xFF;
1065 }
1066 }
1067 else if (!cgrlc_dl_tbf_req->ctrl_ack_bit AND
1068 (grlc_t_status(T3192) > 0) AND
1069 #ifdef _TARGET_
1070 (grlc_t_status(T3192) < 25)
1071 #else
1072 (grlc_t_status(T3192) < 65)
1073 #endif
1074 )
1075 {
1076 TRACE_EVENT_P1("XXXX accepting DL Ass T3192=%ld",grlc_t_status(T3192));
1077 if ( rd_state EQ RD_REL_ACK OR
1078 rd_state EQ RD_REL_UACK )
1079 {
1080 sig_tm_rd_nor_rel();
1081 tm_deactivate_tbf(TBF_TYPE_DL);
1082 grlc_data->dl_tfi = 0xFF;
1083 }
1084 }
1085
1086 grlc_data->downlink_tbf.rlc_mode = cgrlc_dl_tbf_req->rlc_mode;
1087 grlc_data->downlink_tbf.cs_type = (T_CODING_SCHEME)cgrlc_dl_tbf_req->cs_mode;
1088 grlc_data->downlink_tbf.mac_mode = cgrlc_dl_tbf_req->mac_mode;
1089 grlc_data->downlink_tbf.nts = cgrlc_dl_tbf_req->nts_max;
1090 grlc_data->downlink_tbf.ts_mask = cgrlc_dl_tbf_req->tn_mask;
1091 grlc_data->downlink_tbf.t3192_val = cgrlc_dl_tbf_req->t3192_val;
1092
1093 grlc_data->dl_tbf_start_time = cgrlc_dl_tbf_req->starting_time;
1094
1095 tm_activate_tbf ( TBF_TYPE_DL );
1096
1097 tm_tfi_handling (cgrlc_dl_tbf_req->starting_time,CGRLC_TBF_MODE_DL,0xFF,cgrlc_dl_tbf_req->tfi);
1098
1099 sig_tm_rd_assign();
1100
1101
1102 if(cgrlc_dl_tbf_req->polling_bit NEQ 0xFF)
1103 tm_handle_polling_bit(cgrlc_dl_tbf_req->starting_time,cgrlc_dl_tbf_req->polling_bit);
1104
1105
1106 tm_ul_tbf_ind(); /* dl tbf during access mode, ul tbf will be established over downlink*/
1107 break;
1108 default:
1109 {
1110 /* This shall never happen, but in case, GRLC shall inform GRR about the
1111 * immediate release of the TBF. Otherwise GRLC and GRR are running out
1112 * of synchronisation and the whole system hangs.
1113 */
1114 PALLOC( cgrlc_tbf_rel_ind, CGRLC_TBF_REL_IND );
1115
1116 TRACE_ERROR( "CGRLC_DL_TBF_REQ unexpected, so send release ind!" );
1117
1118 cgrlc_tbf_rel_ind->tbf_mode = CGRLC_TBF_MODE_DL;
1119 cgrlc_tbf_rel_ind->tbf_rel_cause = CGRLC_TBF_REL_ABNORMAL;
1120 cgrlc_tbf_rel_ind->v_c_value = FALSE;
1121 cgrlc_tbf_rel_ind->dl_trans_id = grlc_data->downlink_tbf.trans_id;
1122
1123 PSEND( hCommGRR, cgrlc_tbf_rel_ind );
1124 }
1125 break;
1126 }
1127 PFREE(cgrlc_dl_tbf_req);
1128
1129 } /* tm_cgrlc_dl_tbf_req() */
1130
1131 /*
1132 +------------------------------------------------------------------------------
1133 | Function : tm_cgrlc_tbf_rel_req
1134 +------------------------------------------------------------------------------
1135 | Description : Handles the primitive cgrlc_tbf_rel_req
1136 |
1137 | Parameters : void
1138 |
1139 +------------------------------------------------------------------------------
1140 */
1141 GLOBAL void tm_cgrlc_tbf_rel_req ( T_CGRLC_TBF_REL_REQ *cgrlc_tbf_rel_req )
1142 {
1143 BOOL rel_ul = FALSE;
1144 BOOL rel_dl = FALSE;
1145 BOOL mod_ul = FALSE;
1146 BOOL mod_dl = FALSE;
1147
1148
1149 TRACE_FUNCTION( "tm_cgrlc_tbf_rel_req" );
1150
1151
1152 switch( GET_STATE( TM ) )
1153 {
1154 case TM_PTM:
1155 /*
1156 * 1. abnomal release uplink --> immediate release
1157 * 2. normal release uplink --> normal tbf release after current pdu is transmitted
1158 * 3. abnormal release downlink no poll --> immediate release
1159 * 4. abnormal release downlink with poll--> release after poll is sent
1160 * release both tbfs in case of testmode B
1161 */
1162
1163 if( (cgrlc_tbf_rel_req->tbf_mode EQ CGRLC_TBF_MODE_UL) OR
1164 (cgrlc_tbf_rel_req->tbf_mode EQ CGRLC_TBF_MODE_DL_UL)
1165 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
1166 OR
1167 (cgrlc_tbf_rel_req->tbf_mode EQ CGRLC_TBF_MODE_2PA)
1168 #endif
1169 )
1170 {
1171 if(grlc_data->testmode.mode EQ CGRLC_LOOP)
1172 {
1173 rel_ul = TRUE;
1174 rel_dl = TRUE;
1175 }
1176 else
1177 {
1178 if(cgrlc_tbf_rel_req->tbf_rel_cause EQ CGRLC_TBF_REL_ABNORMAL)
1179 {
1180 rel_ul = TRUE;
1181 }
1182 else
1183 {
1184 mod_ul = TRUE;
1185 }
1186 }
1187
1188 }
1189 if( (cgrlc_tbf_rel_req->tbf_mode EQ CGRLC_TBF_MODE_DL) OR
1190 (cgrlc_tbf_rel_req->tbf_mode EQ CGRLC_TBF_MODE_DL_UL))
1191 {
1192 if(grlc_data->testmode.mode EQ CGRLC_LOOP)
1193 {
1194 rel_ul = TRUE;
1195 rel_dl = TRUE;
1196 }
1197 else
1198 {
1199 if(cgrlc_tbf_rel_req->rel_fn EQ CGRLC_STARTING_TIME_NOT_PRESENT)
1200 {
1201 rel_dl = TRUE;
1202 }
1203 else
1204 {
1205 mod_dl = TRUE;
1206 }
1207 }
1208
1209 }
1210
1211 if(mod_ul)
1212 {
1213 if(grlc_data->ru.next_prim < PRIM_QUEUE_SIZE_TOTAL)
1214 {
1215 grlc_data->prim_queue[grlc_data->ru.next_prim].start_new_tbf = 1;
1216 TRACE_EVENT_P5("QUEUE_STATUS BEFORE start=%d,next=%d active=%d rlc_oct=%ld sdu_len=%ld"
1217 ,grlc_data->prim_start_tbf
1218 ,grlc_data->ru.next_prim
1219 ,grlc_data->ru.active_prim
1220 ,grlc_data->ru.rlc_octet_cnt
1221 ,grlc_data->ru.sdu_len);
1222 sig_tm_ru_queue_status();
1223 TRACE_EVENT_P5("QUEUE_STATUS AFTER start=%d,next=%d active=%d rlc_oct=%ld sdu_len=%ld"
1224 ,grlc_data->prim_start_tbf
1225 ,grlc_data->ru.next_prim
1226 ,grlc_data->ru.active_prim
1227 ,grlc_data->ru.rlc_octet_cnt
1228 ,grlc_data->ru.sdu_len);
1229 }
1230 }
1231 if ( rel_ul AND
1232 (cgrlc_tbf_rel_req->rel_fn NEQ CGRLC_STARTING_TIME_NOT_PRESENT))
1233 {
1234 sig_tm_ru_abrel(cgrlc_tbf_rel_req->rel_fn, TRUE);
1235 mod_ul = TRUE;
1236 rel_ul = FALSE;
1237 }
1238
1239 if(mod_dl)
1240 {
1241 sig_tm_rd_abrel(cgrlc_tbf_rel_req->rel_fn, TRUE);
1242 }
1243
1244
1245 if(rel_dl AND rel_ul)
1246 {
1247 tm_abort_tbf(grlc_data->tbf_type);
1248 }
1249 else if(rel_dl)
1250 {
1251 tm_abort_tbf(TBF_TYPE_DL);
1252 }
1253 else if(rel_ul)
1254 {
1255 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
1256 if(grlc_data->tbf_type EQ TBF_TYPE_TP_ACCESS )
1257 tm_abort_tbf(TBF_TYPE_TP_ACCESS);
1258 else
1259 #endif
1260 tm_abort_tbf(TBF_TYPE_UL);
1261 }
1262
1263
1264 if(grlc_data->tbf_type EQ TBF_TYPE_NULL)
1265 {
1266 SET_STATE(TM,TM_WAIT_4_PIM);
1267 sig_tm_ru_reset_poll_array();
1268 }
1269 break;
1270 default:
1271 TRACE_ERROR( "CGRLC_TBF_REL_REQ unexpected" );
1272 break;
1273 }
1274 PFREE(cgrlc_tbf_rel_req);
1275
1276 } /* tm_cgrlc_tbf_rel_req() */
1277
1278 /*
1279 +------------------------------------------------------------------------------
1280 | Function : tm_cgrlc_tbf_rel_res
1281 +------------------------------------------------------------------------------
1282 | Description : Handles the primitive cgrlc_tbf_rel_res
1283 |
1284 | Parameters : void
1285 |
1286 +------------------------------------------------------------------------------
1287 */
1288 GLOBAL void tm_cgrlc_tbf_rel_res ( T_CGRLC_TBF_REL_RES *cgrlc_tbf_rel_res )
1289 {
1290
1291 #if !defined (NTRACE)
1292
1293 BOOL trace = FALSE;
1294 T_REL_TYPE rel_type = grlc_data->rel_type;
1295
1296 #endif /* #if !defined (NTRACE) */
1297
1298 TRACE_FUNCTION( "tm_cgrlc_tbf_rel_res" );
1299
1300 /*
1301 * Check for consistency: Only requested releases shall be indicated by GRR.
1302 */
1303 if( cgrlc_tbf_rel_res->tbf_mode EQ CGRLC_TBF_MODE_DL_UL OR
1304 cgrlc_tbf_rel_res->tbf_mode EQ CGRLC_TBF_MODE_DL )
1305 {
1306 if( ( grlc_data->rel_type & REL_TYPE_DL ) EQ REL_TYPE_DL )
1307 {
1308 grlc_data->rel_type &= ( ~ ( REL_TYPE_DL ) );
1309 }
1310
1311 #if !defined (NTRACE)
1312
1313 else
1314 {
1315 trace = TRUE;
1316 }
1317
1318 #endif /* #if !defined (NTRACE) */
1319
1320 }
1321
1322 /*
1323 * Check for consistency: Only requested releases shall be indicated by GRR.
1324 */
1325 if( cgrlc_tbf_rel_res->tbf_mode EQ CGRLC_TBF_MODE_DL_UL OR
1326 cgrlc_tbf_rel_res->tbf_mode EQ CGRLC_TBF_MODE_UL )
1327 {
1328 if( ( grlc_data->rel_type & REL_TYPE_UL ) EQ REL_TYPE_UL )
1329 {
1330 grlc_data->rel_type &= ( ~ ( REL_TYPE_UL ) );
1331 }
1332
1333 #if !defined (NTRACE)
1334
1335 else
1336 {
1337 trace = TRUE;
1338 }
1339
1340 #endif /* #if !defined (NTRACE) */
1341
1342 }
1343
1344 #if !defined (NTRACE)
1345
1346 /*
1347 * Inconsistency deteced.
1348 */
1349 if( trace EQ TRUE )
1350 {
1351 TRACE_EVENT_P3
1352 ( "tm_cgrlc_tbf_rel_res: unexpected release response - tbf_mode = %d, rel_type (old) = %d, rel_type (new) = %d",
1353 cgrlc_tbf_rel_res->tbf_mode, rel_type, grlc_data->rel_type );
1354 }
1355
1356 #endif /* #if !defined (NTRACE) */
1357
1358 if( grlc_data->rel_type EQ REL_TYPE_NULL )
1359 {
1360 switch( GET_STATE( TM ) )
1361 {
1362 case TM_ACCESS_DISABLED:
1363 case TM_ACCESS_PREPARED:
1364 break;
1365 case TM_WAIT_4_PIM:
1366 SET_STATE(TM,TM_PIM);
1367 sig_tm_ru_reset_poll_array();
1368 tm_handle_test_mode_cnf( grlc_data->testmode.mode EQ CGRLC_TEST_MODE_RELEASE );
1369 grlc_data->tm.n_res_req = 0;
1370
1371 /*lint -fallthrough*/
1372
1373 case TM_PIM:
1374 /*
1375 * reset ta value
1376 */
1377 grlc_data->ta_value = 0xFF;
1378
1379 /*lint -fallthrough*/
1380
1381 case TM_PTM:
1382 tm_ul_tbf_ind();
1383 break;
1384 default:
1385 TRACE_ERROR( "CGRLC_TBF_REL_RES unexpected" );
1386 break;
1387 }
1388 }
1389 PFREE(cgrlc_tbf_rel_res);
1390
1391 } /* tm_cgrlc_tbf_rel_res() */
1392
1393 /*
1394 +------------------------------------------------------------------------------
1395 | Function : tm_cgrlc_data_req
1396 +------------------------------------------------------------------------------
1397 | Description : Handles the primitive cgrlc_data_req
1398 |
1399 | Parameters : void
1400 |
1401 +------------------------------------------------------------------------------
1402 */
1403 GLOBAL void tm_cgrlc_data_req ( T_CGRLC_DATA_REQ *cgrlc_data_req )
1404 {
1405 TRACE_FUNCTION( "tm_cgrlc_data_req" );
1406
1407
1408 switch( GET_STATE( TM ) )
1409 {
1410 case TM_PAM:
1411 case TM_PTM:
1412 tm_store_ctrl_blk( cgrlc_data_req->blk_owner, ( void* )cgrlc_data_req->data_array ) ;
1413 break;
1414 default:
1415 TRACE_ERROR( "CGRLC_DATA_REQ unexpected" );
1416 break;
1417 }
1418 PFREE(cgrlc_data_req);
1419
1420 } /* tm_cgrlc_data_req() */
1421
1422 /*
1423 +------------------------------------------------------------------------------
1424 | Function : tm_cgrlc_poll_req
1425 +------------------------------------------------------------------------------
1426 | Description : Handles the primitive cgrlc_poll_req
1427 |
1428 | Parameters : void
1429 |
1430 +------------------------------------------------------------------------------
1431 */
1432 GLOBAL void tm_cgrlc_poll_req ( T_CGRLC_POLL_REQ *cgrlc_poll_req )
1433 {
1434 TRACE_FUNCTION( "tm_cgrlc_poll_req" );
1435
1436
1437 switch( GET_STATE( TM ) )
1438 {
1439 case TM_PAM:
1440 /*
1441 * handle cpap polling bit, no save pass directly to layer1, poll will
1442 * be sent with the first call
1443 */
1444
1445 grlc_data->next_poll_fn = cgrlc_poll_req->poll_fn;
1446 grlc_data->ul_poll_pos_index = 0;
1447
1448 if(grlc_data->burst_type NEQ CGRLC_BURST_TYPE_NB)
1449 {
1450 grlc_send_access_burst(cgrlc_poll_req->tn);
1451 }
1452 else
1453 {
1454 T_U_GRLC_CTRL_ACK u_ctrl_ack; /* built pca, do not use ccd, because IA is stored*/
1455 u_ctrl_ack.msg_type = U_GRLC_CTRL_ACK_c;
1456 u_ctrl_ack.pctrl_ack = cgrlc_poll_req->ctrl_ack;
1457 grlc_set_buf_tlli( &u_ctrl_ack.tlli_value, grlc_data->uplink_tbf.tlli );
1458
1459 grlc_send_normal_burst((UBYTE *)&u_ctrl_ack, NULL, cgrlc_poll_req->tn);
1460 }
1461
1462 break;
1463 case TM_PTM:
1464 grlc_save_poll_pos(cgrlc_poll_req->poll_fn,
1465 cgrlc_poll_req->tn,
1466 0xFF,
1467 cgrlc_poll_req->poll_b_type,
1468 cgrlc_poll_req->ctrl_ack);
1469 break;
1470 default:
1471 TRACE_ERROR( "CGRLC_POLL_REQ unexpected" );
1472 break;
1473 }
1474 PFREE(cgrlc_poll_req);
1475
1476 } /* tm_cgrlc_poll_req() */
1477
1478 /*
1479 +------------------------------------------------------------------------------
1480 | Function : tm_cgrlc_access_status_req
1481 +------------------------------------------------------------------------------
1482 | Description : Handles the primitive cgrlc_access_status_req
1483 |
1484 | Parameters : void
1485 |
1486 +------------------------------------------------------------------------------
1487 */
1488 GLOBAL void tm_cgrlc_access_status_req ( T_CGRLC_ACCESS_STATUS_REQ *cgrlc_access_status_req )
1489 {
1490 TRACE_FUNCTION( "tm_cgrlc_access_status_req" );
1491
1492
1493 switch( GET_STATE( TM ) )
1494 {
1495 case TM_PIM:
1496 case TM_PAM:
1497 tm_ul_tbf_ind();
1498 break;
1499 default:
1500 TRACE_ERROR( "CGRLC_ACCESS_STATUS_REQ unexpected" );
1501 break;
1502 }
1503 PFREE(cgrlc_access_status_req);
1504
1505 } /* tm_cgrlc_access_status_req() */
1506
1507 /*
1508 +------------------------------------------------------------------------------
1509 | Function : tm_cgrlc_test_mode_req
1510 +------------------------------------------------------------------------------
1511 | Description : Handles the primitive cgrlc_test_mode_req
1512 |
1513 | Parameters : void
1514 |
1515 +------------------------------------------------------------------------------
1516 */
1517 GLOBAL void tm_cgrlc_test_mode_req ( T_CGRLC_TEST_MODE_REQ *cgrlc_test_mode_req )
1518 {
1519 UBYTE pdus_to_queue;
1520 UBYTE count = 0;
1521
1522 TRACE_FUNCTION( "tm_cgrlc_test_mode_req" );
1523
1524 TRACE_EVENT_P1( "cgrlc_test_mode_req test mode is activ %x",cgrlc_test_mode_req->test_mode_flag);
1525
1526 switch( GET_STATE( TM ) )
1527 {
1528 case TM_PIM:
1529 case TM_PTM:
1530 /*
1531 * save the test mode data
1532 */
1533
1534 grlc_data->testmode.mode = cgrlc_test_mode_req->test_mode_flag;
1535
1536 grlc_data->testmode.n_pdu = (ULONG)cgrlc_test_mode_req->no_of_pdus;
1537 grlc_data->testmode.dl_ts_offset = cgrlc_test_mode_req->dl_timeslot_offset;
1538
1539
1540 if (grlc_data->testmode.mode EQ CGRLC_LOOP)
1541 {
1542 TRACE_EVENT("testmode b");
1543 switch(grlc_data->tbf_type)
1544 {
1545 case TBF_TYPE_DL:
1546 /*
1547 * request uplink tbf over existing DL
1548 */
1549 tm_queue_test_mode_prim(1);
1550 /*
1551 * set received buffer to special values
1552 */
1553 grlc_data->testmode.rec_data[0].block_status = 0xFEFE;
1554 grlc_data->testmode.rec_data[0].e_bit = 0xFE;
1555 memset(grlc_data->testmode.rec_data[0].payload, 0xFE,50);
1556 grlc_data->testmode.rec_data[1].block_status = 0xFEFE;
1557 grlc_data->testmode.rec_data[1].e_bit = 0xFE;
1558 memset(grlc_data->testmode.rec_data[1].payload, 0xFE,50);
1559 /*
1560 * If the "Downlink Timeslot Offset" is set to 3, TN3 shall be treated as the first downlink
1561 * timeslot if a TBF is established in TN3. If TN3 does not support a TBF, the first active
1562 * timeslot after TN3 shall be treated as the first downlink timeslot. The counting sequence
1563 * is continuous through TN7 and TN0.
1564 */
1565 while (!((0x80>>grlc_data->testmode.dl_ts_offset) & grlc_data->dl_tn_mask) && (count < 8))
1566 {
1567 if (grlc_data->testmode.dl_ts_offset > 7)
1568 grlc_data->testmode.dl_ts_offset = (UBYTE)-1;
1569 grlc_data->testmode.dl_ts_offset++;
1570 count++;
1571 }
1572 TRACE_EVENT_P1 ("downlink timeslot offset is %d", grlc_data->testmode.dl_ts_offset);
1573 break;
1574 default:
1575 TRACE_EVENT_P1("unexpected tbf type for testmode B:tbf_type=%d",grlc_data->tbf_type);
1576 break;
1577 }
1578
1579 }
1580 else /* it is testmode A with regular PDU amount */
1581 {
1582 if (grlc_data->testmode.n_pdu EQ 0)
1583 {
1584 /*
1585 * In case of Testmode A and 0 PDUs are requested the MS may
1586 * optionally interprete this as infinitive duration TBF.
1587 */
1588 TRACE_EVENT("testmode a infinite");
1589 grlc_data->testmode.n_pdu -= 1;
1590 }
1591 else
1592 {
1593 TRACE_EVENT_P1("testmode a %ld pdus",grlc_data->testmode.n_pdu);
1594 }
1595 /*
1596 * (PRIM_QUEUE_SIZE-1) to avoid the full prime queue situation in test mode.
1597 * It should also not be more then 50*64 byte, which are queue here.
1598 * The remainig PDUs will be queued when a PDU is completely transmitted.
1599 */
1600 if (grlc_data->testmode.n_pdu < (PEI_PRIM_QUEUE_SIZE/2))
1601 {
1602 pdus_to_queue = (UBYTE) grlc_data->testmode.n_pdu;
1603 grlc_data->testmode.n_pdu = 0;
1604 }
1605 else
1606 {
1607 pdus_to_queue = (PEI_PRIM_QUEUE_SIZE/2);
1608 grlc_data->testmode.n_pdu -= (PEI_PRIM_QUEUE_SIZE/2);
1609 }
1610 /*
1611 * generation of pseudo primitve to start the test mode tbf TBF
1612 */
1613 tm_queue_test_mode_prim(pdus_to_queue);
1614
1615 grlc_prbs(INITIALIZE, 0, 0);
1616 if(!grlc_data->testmode.ptr_test_data)
1617 {
1618 MALLOC(grlc_data->testmode.ptr_test_data,50/*Max. RLC Block Length*/);
1619 }
1620 }
1621
1622 break;
1623 default:
1624 TRACE_ERROR( "CGRLC_TEST_MODE_REQ unexpected" );
1625 TRACE_EVENT_P1("tm state %d", grlc_data->tm.state);
1626 break;
1627 }
1628
1629
1630 PFREE(cgrlc_test_mode_req);
1631
1632 } /* tm_cgrlc_test_mode_req() */
1633
1634
1635
1636 /*
1637 +------------------------------------------------------------------------------
1638 | Function : tm_cgrlc_test_end_req
1639 +------------------------------------------------------------------------------
1640 | Description : Handles the primitive CGRLC_TEST_END_REQ
1641 | GRLC have to leave the test mode. The leaving procedure is
1642 | finished with the transmission of GMMRR_TEST_MODE_CNF
1643 | Parameters : *gmmrr_suspend_req - Ptr to primitive payload
1644 |
1645 +------------------------------------------------------------------------------
1646 */
1647 GLOBAL void tm_cgrlc_test_end_req ( T_CGRLC_TEST_END_REQ *cgrlc_test_end_req )
1648 {
1649 TRACE_FUNCTION( "tm_cgrlc_test_end_req" );
1650
1651 tm_abort_tbf( grlc_data->tbf_type );
1652
1653 /*
1654 * delete all primitives in queue.
1655 */
1656 tm_delete_prim_queue();
1657
1658 SET_STATE(TM,TM_WAIT_4_PIM);
1659
1660 grlc_data->tm.n_acc_req_procedures = 0;
1661 grlc_data->tm.n_res_req = 0; /* reset counter of resource requests during access */
1662
1663 PFREE(cgrlc_test_end_req);
1664
1665 } /* tm_cgrlc_test_end_req() */
1666
1667
1668
1669 /*
1670 +------------------------------------------------------------------------------
1671 | Function : tm_cgrlc_ta_value_req
1672 +------------------------------------------------------------------------------
1673 | Description : Handles the primitive cgrlc_ta_value_req
1674 |
1675 | Parameters : void
1676 |
1677 +------------------------------------------------------------------------------
1678 */
1679 GLOBAL void tm_cgrlc_ta_value_req ( T_CGRLC_TA_VALUE_REQ *cgrlc_ta_value_req )
1680 {
1681 TRACE_FUNCTION( "tm_cgrlc_ta_value_req" );
1682
1683 grlc_data->ta_value = cgrlc_ta_value_req->ta_value;
1684
1685 PFREE(cgrlc_ta_value_req);
1686
1687 } /* tm_cgrlc_ta_value_req() */
1688
1689 /*
1690 +------------------------------------------------------------------------------
1691 | Function : tm_cgrlc_ready_timer_config_req
1692 +------------------------------------------------------------------------------
1693 | Description : Handles the primitive tm_cgrlc_ready_timer_config_req
1694 |
1695 | Parameters : void
1696 |
1697 +------------------------------------------------------------------------------
1698 */
1699 GLOBAL void tm_cgrlc_ready_timer_config_req
1700 ( T_CGRLC_READY_TIMER_CONFIG_REQ *cgrlc_ready_timer_config_req )
1701 {
1702 TRACE_FUNCTION( "tm_cgrlc_ready_timer_config_req" );
1703
1704 grlc_data->ready_timer.handling = READY_TIMER_HANDLING_ENABLED;
1705 grlc_data->ready_timer.value = cgrlc_ready_timer_config_req->t3314_val;
1706
1707 if( grlc_data->ready_timer.value EQ CGRLC_DEACTIVATED )
1708 {
1709 grlc_enter_ready_state( );
1710 }
1711
1712 PFREE(cgrlc_ready_timer_config_req);
1713
1714 } /* (tm_cgrlc_ready_timer_config_req) */
1715
1716 /*
1717 +------------------------------------------------------------------------------
1718 | Function : tm_cgrlc_force_to_standby_req
1719 +------------------------------------------------------------------------------
1720 | Description : Handles the primitive tm_cgrlc_force_to_standby_req
1721 |
1722 | Parameters : void
1723 |
1724 +------------------------------------------------------------------------------
1725 */
1726 GLOBAL void tm_cgrlc_force_to_standby_req
1727 ( T_CGRLC_FORCE_TO_STANDBY_REQ *cgrlc_force_to_standby_req )
1728 {
1729 TRACE_FUNCTION( "tm_cgrlc_force_to_standby_req" );
1730
1731 /*
1732 * By receiving this primitive the Ready Timer State will be forced to Standby and
1733 * the running Ready Timer will be stopped
1734 */
1735 grlc_enter_standby_state( );
1736
1737 PFREE(cgrlc_force_to_standby_req);
1738
1739 } /* (tm_cgrlc_force_to_standby_req) */
1740 /*
1741 +------------------------------------------------------------------------------
1742 | Function : tm_cgrlc_pwr_ctrl_req
1743 +------------------------------------------------------------------------------
1744 | Description :
1745 |
1746 | Parameters :
1747 |
1748 +------------------------------------------------------------------------------
1749 */
1750 GLOBAL void tm_cgrlc_pwr_ctrl_req ( T_CGRLC_PWR_CTRL_REQ *pwr_ctrl_req )
1751 {
1752 TRACE_FUNCTION( "tm_cgrlc_pwr_ctrl_req" );
1753
1754 tm_prcs_pwr_ctrl( &pwr_ctrl_req->pwr_ctrl );
1755
1756 PFREE( pwr_ctrl_req );
1757
1758 } /* tm_cgrlc_pwr_ctrl_req */