comparison src/g23m-gprs/grr/grr_tcf.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 : GRR
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 local functions for service TC of
18 | entity GRR.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRR_TCF_C
23 #define GRR_TCF_C
24 #endif
25
26 #define ENTITY_GRR
27
28 /*==== INCLUDES =============================================================*/
29
30 #include <stdio.h>
31 #include <string.h>
32
33 #include "typedefs.h" /* to get Condat data types */
34 #include "vsi.h" /* to get a lot of macros */
35 #include "macdef.h"
36 #include "gprs.h"
37 #include "gsm.h" /* to get a lot of macros */
38 #include "ccdapi.h" /* to get CCD API */
39 #include "cnf_grr.h" /* to get cnf-definitions */
40 #include "mon_grr.h" /* to get mon-definitions */
41 #include "prim.h" /* to get the definitions of used SAP and directions */
42 #include "message.h" /* to get air message definitions */
43 #include "grr.h" /* to get the global entity definitions */
44
45 #include "grr_f.h" /* to get Process GRR global function definitions */
46 #include "grr_tcf.h" /* to get Service TC global function definitions */
47 #include "grr_tcs.h" /* to get Service TC inter signal definitions */
48 #include "grr_ctrls.h" /* to get interface to service CTRL */
49 #include "grr_cpaps.h" /* to get interface to service CPAP */
50 #include "grr_meass.h" /* to get the definitions for interference measurements */
51 #include "cl_rlcmac.h"
52
53 /*==== CONST ================================================================*/
54
55 typedef enum
56 {
57 GRR_STORE_TYPE_NONE,
58 GRR_STORE_TYPE_TN_ALLOC_PWR,
59 GRR_STORE_TYPE_ALF_GAM,
60 GRR_STORE_TYPE_PWR_PAR
61 } T_GRR_STORE_TYPE;
62
63 /*
64 * used in tc_calc_req
65 *
66 */
67 #define RANDOM_VALUE 0xAAAA
68
69 #define RANDOM_2BIT (RANDOM_VALUE & 0x0003)
70 #define RANDOM_3BIT (RANDOM_VALUE & 0x0007)
71 #define RANDOM_5BIT (RANDOM_VALUE & 0x001F)
72
73 #define ONE_PHASE_MASK_11BIT (0x0000 | RANDOM_3BIT )
74 #define SHORT_ACCESS_MASK_11BIT (0x0400 | RANDOM_3BIT )
75 #define TWO_PHASE_MASK_11BIT (0x0600 | RANDOM_3BIT )
76 #define PAGE_RESPONSE_MASK_11BIT (0x0620 | RANDOM_5BIT )
77 #define CELL_UPDATE_MASK_11BIT (0x0640 | RANDOM_5BIT )
78 #define MM_PROCEDURE_MASK_11BIT (0x0660 | RANDOM_5BIT )
79 #define SINGLE_BLOCK_MASK_11BIT (0x0680 | RANDOM_5BIT )
80
81 #define ONE_PHASE_MASK_8BIT (0x0080 | RANDOM_2BIT )
82 #define SHORT_ACCESS_MASK_8BIT (0x0000 | RANDOM_3BIT )
83 #define TWO_PHASE_MASK_8BIT (0x0040 | RANDOM_3BIT )
84 #define PAGE_RESPONSE_MASK_8BIT (0x0048 | RANDOM_3BIT )
85 #define CELL_UPDATE_MASK_8BIT (0x0050 | RANDOM_3BIT )
86 #define MM_PROCEDURE_MASK_8BIT (0x0058 | RANDOM_3BIT )
87 #define SINGLE_BLOCK_MASK_8BIT (0x0060 | RANDOM_3BIT )
88
89 /*
90 * used in tc_handle_ra_con
91 */
92 const UBYTE max_retrans_table[4] = {1,2,4,7};
93
94 const UBYTE tx_int_table[16] = {2,3,4,5,6,7,8,9,10,12,14,16,20,25,32,50};
95
96 const UBYTE s_table[16] = {12,15,20,30,41,55,76,109,163,217,
97 S_VALUE_RESERVED,S_VALUE_RESERVED,S_VALUE_RESERVED,
98 S_VALUE_RESERVED,S_VALUE_RESERVED,S_VALUE_RESERVED };
99
100
101
102 /*==== DIAGNOSTICS ==========================================================*/
103
104 /*==== LOCAL VARS ===========================================================*/
105
106
107 /*==== PRIVATE FUNCTIONS ====================================================*/
108
109 LOCAL void tc_set_da_assignment (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i);
110 LOCAL void tc_set_fa_assignment (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i);
111 LOCAL void tc_set_dl_assignment (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i);
112
113 LOCAL void tc_close_gaps_in_ctrl_blk_seq( UBYTE index );
114
115 LOCAL void tc_prepare_send_tbf_release_req( T_TBF_TYPE tbf_type );
116
117 LOCAL BOOL tc_check_and_save_freq (void);
118
119 LOCAL USHORT grr_convert_11bit_2_etsi ( USHORT eleven_bit );
120
121 LOCAL USHORT tc_one_phase_mask_11bit (void)
122 {
123 #ifdef _TARGET_
124 return (0x0000 | (USHORT)grr_random_value(PCR_RND_INDEX, 8));
125 #else
126 return ONE_PHASE_MASK_11BIT;
127 #endif
128 }
129
130 LOCAL SHORT tc_short_access_mask_11bit (void)
131 {
132 #ifdef _TARGET_
133 return (0x0400 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
134 #else
135 return SHORT_ACCESS_MASK_11BIT;
136 #endif
137 }
138
139 LOCAL SHORT tc_two_phase_mask_11bit (void)
140 {
141 #ifdef _TARGET_
142 return (0x0600 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
143 #else
144 return TWO_PHASE_MASK_11BIT;
145 #endif
146 }
147
148 LOCAL SHORT tc_page_response_mask_11bit (void)
149 {
150 #ifdef _TARGET_
151 return (0x0620 | (USHORT)grr_random_value(PCR_RND_INDEX, 32) );
152 #else
153 return PAGE_RESPONSE_MASK_11BIT;
154 #endif
155 }
156
157 LOCAL SHORT tc_cell_update_mask_11bit (void)
158 {
159 #ifdef _TARGET_
160 return (0x0640 | (USHORT)grr_random_value(PCR_RND_INDEX, 32) );
161 #else
162 return CELL_UPDATE_MASK_11BIT;
163 #endif
164 }
165
166 LOCAL SHORT tc_mm_procedure_mask_11bit (void)
167 {
168 #ifdef _TARGET_
169 return (0x0660 |(USHORT)grr_random_value(PCR_RND_INDEX, 32) );
170 #else
171 return MM_PROCEDURE_MASK_11BIT;
172 #endif
173 }
174
175 LOCAL SHORT tc_single_block_mask_11bit (void)
176 {
177 #ifdef _TARGET_
178 return (0x0680 | (USHORT)grr_random_value(PCR_RND_INDEX, 32) );
179 #else
180 return SINGLE_BLOCK_MASK_11BIT;
181 #endif
182 }
183
184 LOCAL SHORT tc_one_phase_mask_8bit (void)
185 {
186 #ifdef _TARGET_
187 return (0x0080 | (USHORT)grr_random_value(PCR_RND_INDEX, 4) );
188 #else
189 return ONE_PHASE_MASK_8BIT;
190 #endif
191 }
192
193 LOCAL SHORT tc_short_access_mask_8bit (void)
194 {
195 #ifdef _TARGET_
196 return (0x0000 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
197 #else
198 return SHORT_ACCESS_MASK_8BIT;
199 #endif
200 }
201
202 LOCAL SHORT tc_two_phase_mask_8bit (void)
203 {
204 #ifdef _TARGET_
205 return (0x0040 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
206 #else
207 return TWO_PHASE_MASK_8BIT;
208 #endif
209 }
210
211 LOCAL SHORT tc_page_response_mask_8bit (void)
212 {
213 #ifdef _TARGET_
214 return (0x0048 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
215 #else
216 return PAGE_RESPONSE_MASK_8BIT;
217 #endif
218 }
219
220 LOCAL SHORT tc_cell_update_mask_8bit (void)
221 {
222 #ifdef _TARGET_
223 return (0x0050 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
224 #else
225 return CELL_UPDATE_MASK_8BIT;
226 #endif
227 }
228
229 LOCAL SHORT tc_mm_procedure_mask_8bit (void)
230 {
231 #ifdef _TARGET_
232 return (0x0058 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
233 #else
234 return MM_PROCEDURE_MASK_8BIT;
235 #endif
236 }
237 LOCAL SHORT tc_single_block_mask_8bit (void)
238 {
239 #ifdef _TARGET_
240 return (0x0060 | (USHORT)grr_random_value(PCR_RND_INDEX, 8) );
241 #else
242 return SINGLE_BLOCK_MASK_8BIT;
243 #endif
244 }
245
246 /*
247 +------------------------------------------------------------------------------
248 | Function : tc_set_hopping_par
249 +------------------------------------------------------------------------------
250 | Description : This function handles the frequency parameters in a ul or dl
251 | assignment or ts reconfigure.
252 |
253 | Parameters : ptr2prim - pointer to the MPHP_ASSIGNMENT_REQ prim
254 | that has to be set up.
255 | freq_par - pointer to the received frequency parameter struct.
256 |
257 +------------------------------------------------------------------------------
258 */
259 GLOBAL BOOL tc_set_hopping_par ( T_freq_par *freq_par )
260 {
261 BOOL result = FALSE;
262 T_p_frequency_par frequency_par;
263
264 TRACE_FUNCTION( "tc_set_hopping_par" );
265
266 memset( &frequency_par, 0, sizeof( frequency_par ) );
267
268 if(freq_par->v_indi_encod)
269 {
270 result = grr_validate_ma_num_in_freq_par(freq_par,GRR_FREQ_PARAM_RECEIVED_IN_ASSIGNMENT);
271
272 if(result)
273 {
274 result = grr_create_freq_list( freq_par->indi_encod.ma_num,
275 freq_par->indi_encod.maio,
276 &frequency_par.p_chan_sel,
277 &frequency_par.p_freq_list );
278 }
279 else
280 {
281 TRACE_ERROR("error creating frequency list");
282 result = FALSE;
283 }
284
285 } /* if(freq_par->v_indi_encod) */
286 else if(freq_par->v_di_encod1)
287 {
288 memcpy(&psc_db->gprs_ms_alloc_in_assignment.gprs_ms_alloc_ie,
289 &freq_par->di_encod1.gprs_ms_alloc_ie, sizeof(T_gprs_ms_alloc_ie));
290
291 psc_db->gprs_ms_alloc_in_assignment.ma_num = MA_NUMBER_4_ASSIGNMENT;
292 psc_db->rfl[MAX_RFL].num = NOT_SET;
293
294 result = grr_create_freq_list( psc_db->gprs_ms_alloc_in_assignment.ma_num,
295 freq_par->di_encod1.maio,
296 &frequency_par.p_chan_sel,
297 &frequency_par.p_freq_list );
298 } /* if(freq_par->v_di_encod1) */
299 else if(freq_par->v_di_encod2)
300 {
301 /*
302 * processing of T_freq_par from assignment and non-assignment messages
303 * when direct encoding 2 is used, should be done in same object module as
304 * this involvs use of static array variables which are local to the
305 * object module they are used in(_local_dummy_list and _local_rfl_contents.
306 * Hence processing for both assignment and non-assignement messages is done
307 * in grr_f.c. If they are put in different files, we will have to duplicate
308 * the static arrays.
309 */
310 result =
311 grr_cnv_freq_para_in_assignment_direct_enc_2(&frequency_par,freq_par);
312
313 } /* if(freq_par->v_di_encod2) */
314 else
315 {
316 TRACE_ERROR("FATAL ERROR: no frequency params in ul assignment!");
317 }
318
319 if( result EQ TRUE )
320 {
321 grr_data->tc.freq_set.freq_par = frequency_par;
322 grr_data->tc.freq_set.tsc = freq_par->tsc;
323 }
324
325 grr_data->tc.v_freq_set = result;
326
327 return ( result );
328 }/* tc_set_hopping_par */
329
330
331
332 /*
333 +------------------------------------------------------------------------------
334 | Function : tc_get_send_nb_prim_and_set_freq
335 +------------------------------------------------------------------------------
336 | Description : This function allocates a primitve depending on the hopping status
337 | and sets the frequency parameter of T_MPHP_SINGLE_BLOCK_REQ
338 |
339 | Parameters :
340 |
341 +------------------------------------------------------------------------------
342 */
343 LOCAL T_MPHP_SINGLE_BLOCK_REQ * tc_get_send_nb_prim_and_set_freq ( void )
344 {
345 PALLOC( mphp_single_block_req, MPHP_SINGLE_BLOCK_REQ );
346
347 TRACE_FUNCTION( "tc_get_send_nb_prim_and_set_freq" );
348
349 memset( mphp_single_block_req, 0, sizeof( T_MPHP_SINGLE_BLOCK_REQ ) );
350
351 mphp_single_block_req->tsc = grr_data->tc.freq_set.tsc;
352
353 grr_set_freq_par( &mphp_single_block_req->p_frequency_par );
354
355 return( mphp_single_block_req );
356 }/* tc_get_send_nb_prim_and_set_freq */
357
358 /*
359 +------------------------------------------------------------------------------
360 | Function : tc_check_and_save_freq
361 +------------------------------------------------------------------------------
362 | Description : This function check if the freq_par is valid or not..
363 | If it is hopping case, save the hoppinging freq.
364 |
365 | Parameters : void
366 |
367 +------------------------------------------------------------------------------
368 */
369 LOCAL BOOL tc_check_and_save_freq (void)
370 {
371 MCAST(d_dl_assign,D_DL_ASSIGN); /* T_D_DL_ASSIGN T_D_UL_ASSIGN T_D_TS_RECONFIG */
372 MCAST(d_ul_assign,D_UL_ASSIGN);
373 MCAST(d_ts_reconfig,D_TS_RECONFIG);
374
375 BOOL result = FALSE;
376 T_freq_par *freq_par = NULL;
377 BOOL mode_check = FALSE;
378
379 TRACE_FUNCTION( "tc_check_and_save_freq" );
380
381 /*
382 * store frequeny parameters, if present.
383 * If not present, take from data base
384 */
385 switch(d_dl_assign->msg_type)
386 {
387 case D_DL_ASSIGN: /* T_D_DL_ASSIGN */
388 if(d_dl_assign->pda_trnc_grp.v_freq_par)
389 { /* replace possibly earlier stored freq params */
390 freq_par = &d_dl_assign->pda_trnc_grp.freq_par;
391 }
392 if((grr_data->tbf_type EQ CGRLC_TBF_MODE_UL) OR (grr_data->tbf_type EQ CGRLC_TBF_MODE_DL_UL) )
393 {
394 mode_check = TRUE;
395 }
396 break;
397 case D_UL_ASSIGN: /* T_D_UL_ASSIGN */
398 if(d_ul_assign->v_freq_par)
399 { /* replace possibly earlier stored freq params */
400 freq_par = &d_ul_assign->freq_par;
401 }
402 if((grr_data->tbf_type EQ CGRLC_TBF_MODE_DL) OR (grr_data->tbf_type EQ CGRLC_TBF_MODE_DL_UL))
403 {
404 mode_check = TRUE;
405 }
406
407 break;
408 case D_TS_RECONFIG: /* T_D_TS_RECONFIG */
409 if(d_ts_reconfig->v_freq_par)
410 { /* replace possibly earlier stored freq params */
411 freq_par = &d_ts_reconfig->freq_par;
412 }
413 break;
414 case D_UL_ACK: /* T_D_UL_ACK */
415 break;
416 default:
417 TRACE_ERROR ( "Wrong message type in _decodedMsg" );
418 break;
419
420 }
421 /* If frequency parameter element present, assigns frequency parameters to the
422 uplink TBF. If this information element is not present the mobile station
423 shall use its previously assigned frequency parameters.*/
424
425 if( freq_par )/* save the hopping frequency */
426 {
427 if(freq_par->v_arfcn) /*static*/
428 {
429 T_FREQ_SET temp_freq_set;
430 temp_freq_set.freq_par.p_chan_sel.hopping = FALSE;
431 temp_freq_set.tsc = freq_par->tsc;
432 temp_freq_set.freq_par.p_chan_sel.p_rf_ch.arfcn = grr_g23_arfcn_to_l1(freq_par->arfcn);
433
434 /* variable needed by hopping case must be reset.*/
435 memset(&(temp_freq_set.freq_par.p_freq_list.p_rf_chan_no.p_radio_freq), 0, sizeof(temp_freq_set.freq_par.p_freq_list.p_rf_chan_no.p_radio_freq));
436 temp_freq_set.freq_par.p_freq_list.p_rf_chan_cnt = 0;
437
438 if ( mode_check EQ TRUE )
439 {
440 /* checking the params already exist or not */
441 if ( ( grr_data->tc.freq_set.freq_par.p_chan_sel.hopping EQ FALSE)
442 AND (temp_freq_set.tsc EQ grr_data->tc.freq_set.tsc)
443 AND ( temp_freq_set.freq_par.p_chan_sel.p_rf_ch.arfcn EQ
444 grr_data->tc.freq_set.freq_par.p_chan_sel.p_rf_ch.arfcn ) )
445 {
446 TRACE_EVENT ("Frequency parameters are same");
447 result = TRUE;
448 }
449 else
450 {
451 TRACE_EVENT ("Frequency parameters are changed, So discard it");
452 result = FALSE;
453 }
454 }
455 else
456 {
457 /* If it is new entry, storing in the grr_data */
458 result = TRUE;
459 grr_data->tc.v_freq_set = TRUE;
460 grr_data->tc.freq_set = temp_freq_set;
461 }
462 }
463 else
464 { /* hopping cases */
465 result = tc_set_hopping_par( freq_par );
466 }
467 }
468 else if ( grr_data->tc.v_freq_set )/* if it is a two phase assignment or there is already another TBF running*/
469 {
470 result = TRUE;
471 }
472 else
473 {
474 result = FALSE;
475 TRACE_ERROR("FATAL ERROR: no freq params in assignment but needed!");
476 }
477
478 if(result EQ TRUE)
479 {
480 grr_data->pwr_ctrl_valid_flags.v_glbl_pwr_ctrl_param = TRUE;
481 grr_data->pwr_ctrl_valid_flags.v_freq_param = TRUE;
482 }
483
484 return(result);
485
486 }/* tc_check_and_save_freq */
487
488
489
490
491 /*
492 +------------------------------------------------------------------------------
493 | Function : tc_set_da_assignment
494 +------------------------------------------------------------------------------
495 | Description : This function sets some parameter of T_MPHP_ASSIGNMENT_REQ is
496 | case of uplink dynamic allocation.
497 |
498 | Parameters : ptr2prim_i - ptr to MPHP_ASSIGNMENT_REQ
499 |
500 +------------------------------------------------------------------------------
501 */
502 LOCAL void tc_set_da_assignment (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i)
503 {
504 MCAST(d_ul_assign,D_UL_ASSIGN);/* T_D_UL_ASSIGN */
505 MCAST(d_ts_reconfig,D_TS_RECONFIG);
506
507 TRACE_FUNCTION( "tc_set_da_assignment" );
508
509 if( d_ul_assign->msg_type EQ D_UL_ASSIGN_c)
510 {
511
512 /*
513 * timing advance
514 */
515 grr_handle_ta ( d_ul_assign->pta.v_ta_value,
516 d_ul_assign->pta.ta_value,
517 d_ul_assign->pta.v_ta_index_tn,
518 d_ul_assign->pta.ta_index_tn.ta_index,
519 d_ul_assign->pta.ta_index_tn.ta_tn,
520 0xFF,
521 0,
522 0,
523 &ptr2prim_i->p_timing_advance);
524
525 /* bts output power control */
526 if(d_ul_assign->dyn_alloc_p.v_p0)
527 {
528 ptr2prim_i->p_dl_power.p0 = d_ul_assign->dyn_alloc_p.p0;
529 ptr2prim_i->p_dl_power.pr_mode = d_ul_assign->dyn_alloc_p.pr_mode;
530 /* dynamic allocation must use mode a */
531 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode = MODE_A;
532 }
533 else
534 {
535 ptr2prim_i->p_dl_power.p0 = 0xff; /* 0xff -> invalid value */
536 /* -> pr_mode and bts_pwr_ctl_mode don't care */
537 }
538
539 /*
540 * TBF starting time
541 */
542 if(d_ul_assign->dyn_alloc_p.v_tbf_s_time)
543 {
544 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
545 if(d_ul_assign->dyn_alloc_p.tbf_s_time.v_abs)
546 {
547 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ul_assign->dyn_alloc_p.tbf_s_time.abs);
548 }
549 else if (d_ul_assign->dyn_alloc_p.tbf_s_time.v_rel)
550 {
551 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
552 d_ul_assign->dyn_alloc_p.tbf_s_time.rel);
553 }
554 else
555 { /* this shall never happen */
556 ptr2prim_i->p_tbf_start.fn = grr_data->dl_fn;
557 TRACE_ERROR("UL v_start_tbf but either rel nor abs tbf included");
558 }
559 }
560 else if(grr_data->l1_del_tbf_start_fn NEQ GRR_INVALID_FN)
561 {
562 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
563 ptr2prim_i->p_tbf_start.fn = grr_data->l1_del_tbf_start_fn;
564 }
565 else
566 {
567 ptr2prim_i->p_tbf_start.tbf_start_present = 0;
568 }
569
570 /*
571 * mac mode
572 */
573 if (d_ul_assign->dyn_alloc_p.xdyn_alloc)
574 {
575 ptr2prim_i->mac_mode = EDA;
576 }
577 else
578 {
579 ptr2prim_i->mac_mode = DA;
580 }
581
582 /*
583 * uplink allocation structure
584 */
585 if(d_ul_assign->dyn_alloc_p.v_ul_tfi_assign)
586 {
587 ptr2prim_i->p_ul_alloc.ul_tfi = d_ul_assign->dyn_alloc_p.ul_tfi_assign;
588 }
589 else
590 {
591 ptr2prim_i->p_ul_alloc.ul_tfi = grr_data->uplink_tbf.tfi;
592 }
593 ptr2prim_i->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
594
595
596 /*
597 * dynamic allocation structure
598 */
599 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_gran =
600 d_ul_assign->dyn_alloc_p.usf_grant;
601
602 if(d_ul_assign->dyn_alloc_p.v_tn_alloc EQ 1)
603 {
604 UBYTE i;
605 for(i = 0;i < 8;i++)
606 {
607 if(d_ul_assign->dyn_alloc_p.tn_alloc[i].v_usf)
608 {
609 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
610 d_ul_assign->dyn_alloc_p.tn_alloc[i].usf;
611 }
612 }
613 }
614 else if (d_ul_assign->dyn_alloc_p.v_tn_alloc_pwr)
615 {
616 UBYTE i;
617
618 for(i = 0;i < 8;i++)
619 {
620 if(d_ul_assign->dyn_alloc_p.tn_alloc_pwr.usf_array[i].v_usf_g)
621 {
622 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
623 d_ul_assign->dyn_alloc_p.tn_alloc_pwr.usf_array[i].usf_g.usf;
624 }
625 }
626
627 grr_store_type_tn_alloc_pwr( &d_ul_assign->dyn_alloc_p.tn_alloc_pwr );
628 }
629 else
630 {
631 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[0] = 5;
632 TRACE_EVENT("USF-Error: set (hardcoded) USF_TN0 = 0x05");
633 }
634
635 }
636 else if ( d_ts_reconfig->msg_type EQ D_TS_RECONFIG_c)
637 {
638 /*
639 * timing advance is handled in tc_set_dl_assignment
640 */
641 /* grr_handle_ta ( d_ts_reconfig->gpta.v_ta_value,
642 d_ts_reconfig->gpta.ta_value,
643 d_ts_reconfig->gpta.v_ul_ta_index,
644 d_ts_reconfig->gpta.ul_ta_index,
645 d_ts_reconfig->gpta.ul_ta_tn,
646 0,
647 0,
648 0,
649 ptr2prim_i->p_timing_advance);
650
651 */
652 /* bts output power control */
653 if(d_ts_reconfig->dyn_alloc_ts.v_p0)
654 {
655 ptr2prim_i->p_dl_power.p0 = d_ts_reconfig->dyn_alloc_ts.p0;
656 ptr2prim_i->p_dl_power.pr_mode = d_ts_reconfig->dyn_alloc_ts.pr_mode;
657 /* dynamic allocation must use mode a */
658 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode = MODE_A;
659 }
660 else
661 {
662 ptr2prim_i->p_dl_power.p0 = 0xff; /* 0xff -> invalid value */
663 /* -> pr_mode and bts_pwr_ctl_mode don't care */
664 }
665
666 /*
667 * TBF starting time
668 */
669 if(d_ts_reconfig->dyn_alloc_ts.v_tbf_s_time)
670 {
671 ptr2prim_i->p_tbf_start.tbf_start_present= 1;
672 if(d_ts_reconfig->dyn_alloc_ts.tbf_s_time.v_abs)
673 {
674 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ts_reconfig->dyn_alloc_ts.tbf_s_time.abs);
675 }
676 else if (d_ts_reconfig->dyn_alloc_ts.tbf_s_time.v_rel)
677 {
678 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
679 d_ts_reconfig->dyn_alloc_ts.tbf_s_time.rel);
680 }
681 else
682 { /* this shall never happen */
683 ptr2prim_i->p_tbf_start.fn = grr_data->dl_fn%FN_MAX;
684 TRACE_ERROR("TS RECON UL v_start_tbf but either rel nor abs tbf included");
685 }
686 }
687 else if(grr_data->l1_del_tbf_start_fn NEQ GRR_INVALID_FN)
688 {
689 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
690 ptr2prim_i->p_tbf_start.fn = grr_data->l1_del_tbf_start_fn;
691 }
692 else
693 {
694 ptr2prim_i->p_tbf_start.tbf_start_present = 0;
695 }
696
697
698 /*
699 * mac mode
700 */
701 if (d_ts_reconfig->dyn_alloc_ts.xdyn_alloc)
702 {
703 ptr2prim_i->mac_mode = EDA;
704 }
705 else
706 {
707 ptr2prim_i->mac_mode = DA;
708 }
709
710 /*
711 * uplink allocation structure
712 */
713 if(d_ts_reconfig->v_ul_tfi)
714 {
715 ptr2prim_i->p_ul_alloc.ul_tfi = d_ts_reconfig->ul_tfi;
716 }
717 else
718 {
719 ptr2prim_i->p_ul_alloc.ul_tfi = grr_data->uplink_tbf.tfi;
720 }
721 ptr2prim_i->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
722
723
724 /*
725 * dynamic allocation structure
726 */
727 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_gran = d_ts_reconfig->dyn_alloc_ts.usf_grant;
728
729 if(d_ts_reconfig->dyn_alloc_ts.v_tn_alloc EQ 1)
730 {
731 UBYTE i;
732 for(i = 0;i < 8;i++)
733 {
734 if(d_ts_reconfig->dyn_alloc_ts.tn_alloc[i].v_usf)
735 {
736 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
737 d_ts_reconfig->dyn_alloc_ts.tn_alloc[i].usf;
738 }
739 }
740 }
741 else if (d_ts_reconfig->dyn_alloc_ts.v_tn_alloc_pwr)
742 {
743 UBYTE i;
744
745 for(i = 0;i < 8;i++)
746 {
747 if(d_ts_reconfig->dyn_alloc_ts.tn_alloc_pwr.usf_array[i].v_usf_g)
748 {
749 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
750 d_ts_reconfig->dyn_alloc_ts.tn_alloc_pwr.usf_array[i].usf_g.usf;
751 }
752 }
753
754 grr_store_type_tn_alloc_pwr( &d_ts_reconfig->dyn_alloc_ts.tn_alloc_pwr );
755 }
756 else
757 {
758 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[0] = 5;
759 TRACE_EVENT("USF-Error: set (hardcoded) USF_TN0 = 0x05");
760 }
761 }
762 else
763 {
764 TRACE_ERROR ( "Wrong message type in _decodedCtrlMsg" );
765 }
766
767 if(ptr2prim_i->p_tbf_start.tbf_start_present)
768 grr_data->uplink_tbf.tbf_start_fn = ptr2prim_i->p_tbf_start.fn;
769 else
770 grr_data->uplink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
771
772 grr_data->uplink_tbf.st_tfi = ptr2prim_i->p_ul_alloc.ul_tfi;
773
774
775
776 return;
777 }/*tc_set_da_assignment*/
778
779
780 /*
781 +------------------------------------------------------------------------------
782 | Function : tc_calc_fa_bitmap
783 +------------------------------------------------------------------------------
784 | Description : This function calculates rhe allocation bitmap in
785 | case of fixed allocation
786 |
787 | Parameters : blks_or_blkps - indicates if blocks(0) or block periods(1) is used
788 | len - len of the allocation bitmap
789 | ptr2_alloc_map - ptr to the allocation bitmap array
790 | ptr2_fix_alloc - ptr to the fixed allocation struct
791 |
792 +------------------------------------------------------------------------------
793 */
794 GLOBAL void tc_calc_fa_bitmap (ULONG tbf_start,
795 UBYTE blks_or_blkps,
796 USHORT len,
797 UBYTE * ptr2_alloc_map,
798 T_p_fixed_alloc * ptr2_fix_alloc)
799 {
800 UBYTE i;
801 UBYTE help;
802 UBYTE tn[8];
803 UBYTE x,y;
804 UBYTE len_1;
805 USHORT index;
806
807 TRACE_FUNCTION( "tc_calc_fa_bitmap" );
808
809 /*
810 TRACE_EVENT_P9("FA bitmap: start_fn=%ld, blk=%d len=%ld bitmap: %d %d %d %d %d %d",
811 tbf_start,
812 blks_or_blkps,
813 len,
814 ptr2_alloc_map[0],
815 ptr2_alloc_map[1],
816 ptr2_alloc_map[2],
817 ptr2_alloc_map[3],
818 ptr2_alloc_map[4],
819 ptr2_alloc_map[5]);
820
821 TRACE_EVENT_P9("%d %d %d %d %d %d %d %d %d",
822 ptr2_alloc_map[6],
823 ptr2_alloc_map[7],
824 ptr2_alloc_map[8],
825 ptr2_alloc_map[9],
826 ptr2_alloc_map[10],
827 ptr2_alloc_map[11],
828 ptr2_alloc_map[12],
829 ptr2_alloc_map[13],
830 ptr2_alloc_map[14]);
831
832 TRACE_EVENT_P9("%d %d %d %d %d %d %d %d %d",
833 ptr2_alloc_map[15],
834 ptr2_alloc_map[16],
835 ptr2_alloc_map[17],
836 ptr2_alloc_map[18],
837 ptr2_alloc_map[19],
838 ptr2_alloc_map[20],
839 ptr2_alloc_map[21],
840 ptr2_alloc_map[22],
841 ptr2_alloc_map[23]);
842 TRACE_EVENT_P9("%d %d %d %d %d %d %d %d %d",
843 ptr2_alloc_map[24],
844 ptr2_alloc_map[25],
845 ptr2_alloc_map[26],
846 ptr2_alloc_map[27],
847 ptr2_alloc_map[28],
848 ptr2_alloc_map[29],
849 ptr2_alloc_map[30],
850 ptr2_alloc_map[31],
851 ptr2_alloc_map[32]);
852 */
853 memset( tn, 0, sizeof(tn) );
854
855 if(blks_or_blkps)
856 {
857 /*
858 * block periods are used
859 */
860 for(i=0;i<len;i++)
861 {
862 if(ptr2_alloc_map[i])
863 {
864 ptr2_fix_alloc->bitmap[i] = grr_data->uplink_tbf.ts_usage;
865 }
866 else
867 ptr2_fix_alloc->bitmap[i] = 0;
868 }
869 ptr2_fix_alloc->size_bitmap = (UBYTE)len;
870 }
871 else
872 {
873 UBYTE L;
874 /*
875 * blocks are used
876 */
877 /*
878 * determinate the timeslot positions
879 */
880 help = grr_data->uplink_tbf.ts_usage;
881 index = 0;
882 for(i=0;i<=7;i++)
883 {
884 if(help >= (0x80 >> i))
885 {
886 tn[index]=i;
887 index++;
888 help -= (0x80 >> i);
889 }
890 }
891 memset(ptr2_fix_alloc->bitmap,0,sizeof(ptr2_fix_alloc->bitmap));
892 L = len - 1;
893 for(i=0;i<=L;i++)
894 {
895 if(ptr2_alloc_map[i])
896 {
897 x = i / grr_data->uplink_tbf.nts;
898 y = i % grr_data->uplink_tbf.nts;
899 ptr2_fix_alloc->bitmap[x] |= 0x80 >> tn[y];
900 }
901 }
902 ptr2_fix_alloc->size_bitmap = (UBYTE)len / grr_data->uplink_tbf.nts;
903 }
904 /*
905 * set fa_ctrl
906 */
907
908
909 grr_data->tc.fa_ctrl.fa_type = FA_BITMAP;
910
911
912 grr_data->tc.fa_ctrl.current_alloc.alloc_start_fn = tbf_start;
913
914 /* store end of fixed allocation */
915 len_1 = ptr2_fix_alloc->size_bitmap - 1;
916 grr_data->tc.fa_ctrl.current_alloc.alloc_end_fn =
917 grr_decode_tbf_start_rel(grr_data->tc.fa_ctrl.current_alloc.alloc_start_fn,(USHORT)(len_1-1));
918
919 memcpy( &grr_data->tc.fa_ctrl.current_alloc.alloc,
920 ptr2_fix_alloc,
921 sizeof(T_p_fixed_alloc));
922
923 /* TRACE_EVENT_P9("L1 bitmap %d %d %d %d %d %d %d %d %d",
924 ptr2_fix_alloc->bitmap[0],
925 ptr2_fix_alloc->bitmap[1],
926 ptr2_fix_alloc->bitmap[2],
927 ptr2_fix_alloc->bitmap[3],
928 ptr2_fix_alloc->bitmap[4],
929 ptr2_fix_alloc->bitmap[5],
930 ptr2_fix_alloc->bitmap[6],
931 ptr2_fix_alloc->bitmap[7],
932 ptr2_fix_alloc->bitmap[8]);
933
934 TRACE_EVENT_P9("%d %d %d %d %d %d %d %d %d",
935 ptr2_fix_alloc->bitmap[9],
936 ptr2_fix_alloc->bitmap[10],
937 ptr2_fix_alloc->bitmap[11],
938 ptr2_fix_alloc->bitmap[12],
939 ptr2_fix_alloc->bitmap[13],
940 ptr2_fix_alloc->bitmap[14],
941 ptr2_fix_alloc->bitmap[15],
942 ptr2_fix_alloc->bitmap[16],
943 ptr2_fix_alloc->bitmap[17]);
944 TRACE_EVENT_P9("%d %d %d %d %d %d %d %d %d",
945 ptr2_fix_alloc->bitmap[18],
946 ptr2_fix_alloc->bitmap[19],
947 ptr2_fix_alloc->bitmap[20],
948 ptr2_fix_alloc->bitmap[21],
949 ptr2_fix_alloc->bitmap[22],
950 ptr2_fix_alloc->bitmap[23],
951 ptr2_fix_alloc->bitmap[24],
952 ptr2_fix_alloc->bitmap[25],
953 ptr2_fix_alloc->bitmap[26]);
954 */
955 } /* tc_calc_fa_bitmap() */
956
957 /*
958 +------------------------------------------------------------------------------
959 | Function : tc_handle_final_alloc
960 +------------------------------------------------------------------------------
961 | Description : This function handles the final allocation bit.
962 |
963 | Parameters : -
964 |
965 +------------------------------------------------------------------------------
966 */
967 GLOBAL void tc_handle_final_alloc (UBYTE final_allocation)
968 {
969
970 TRACE_FUNCTION( "tc_handle_final_alloc" );
971
972
973
974 } /* tc_handle_final_alloc() */
975
976 /*
977 +------------------------------------------------------------------------------
978 | Function : tc_set_fa_assignment
979 +------------------------------------------------------------------------------
980 | Description : This function sets some parameter of T_MPHP_ASSIGNMENT_REQ is
981 | case of fixed allocation
982 |
983 | Parameters : ptr2prim_i - ptr to MPHP_ASSIGNMENT_REQ
984 |
985 +------------------------------------------------------------------------------
986 */
987 LOCAL void tc_set_fa_assignment (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i)
988 {
989 /* ULONG var; */
990 MCAST(d_ul_assign,D_UL_ASSIGN); /* T_D_UL_ASSIGN */
991 MCAST(d_ts_reconfig,D_TS_RECONFIG); /* T_TS_RECONFIG */
992 MCAST(d_ul_ack,D_UL_ACK); /* T_D_UL_ACK */
993
994
995
996
997 TRACE_FUNCTION( "tc_set_fa_assignment" );
998
999 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
1000 if((d_ul_assign->msg_type EQ D_UL_ASSIGN_c) AND
1001 (ptr2prim_i->assign_cmd EQ UL_TP_ACCESS))
1002 {
1003 /* training sequence code */
1004 ptr2prim_i->tsc = d_ul_assign->freq_par.tsc;
1005
1006 /* handle timing advance */
1007 grr_handle_ta ( d_ul_assign->pta.v_ta_value,
1008 d_ul_assign->pta.ta_value,
1009 d_ul_assign->pta.v_ta_index_tn,
1010 d_ul_assign->pta.ta_index_tn.ta_index,
1011 d_ul_assign->pta.ta_index_tn.ta_tn,
1012 0xFF,
1013 0,
1014 0,
1015 &ptr2prim_i->p_timing_advance);
1016
1017 /* Mac mode */
1018 ptr2prim_i->mac_mode = FA;
1019
1020 /* Handle single block allocation */
1021 if(d_ul_assign->v_sin_alloc EQ TRUE )
1022 {
1023 /* timeslot mask */
1024 ptr2prim_i->p_ul_alloc.ts_mask = 0x80>>d_ul_assign->sin_alloc.tn;
1025
1026 /* PO, BTS_POWER_MODE and PR_ MODE */
1027 if(d_ul_assign->sin_alloc.v_bts_pwr_ctrl EQ TRUE )
1028 {
1029 ptr2prim_i->p_dl_power.p0 =
1030 d_ul_assign->sin_alloc.bts_pwr_ctrl.p0;
1031
1032 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode =
1033 d_ul_assign->sin_alloc.bts_pwr_ctrl.mode;
1034
1035 ptr2prim_i->p_dl_power.pr_mode =
1036 d_ul_assign->sin_alloc.bts_pwr_ctrl.pr_mode;
1037 }
1038 else
1039 {
1040 ptr2prim_i->p_dl_power.p0 = 0xff;
1041 }
1042
1043 /* Downlink Control Timeslot */
1044 ptr2prim_i->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = d_ul_assign->sin_alloc.tn;
1045
1046 /*
1047 * handle TBF starting time
1048 * is always present in single block allocation
1049 */
1050 if(d_ul_assign->sin_alloc.tbf_s_time.v_abs)
1051 {
1052 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ul_assign->sin_alloc.tbf_s_time.abs);
1053 if(!grr_check_if_tbf_start_is_elapsed ( ptr2prim_i->p_tbf_start.fn, grr_data->ul_fn))
1054 {
1055 /*Allocated Number of time slots are 1 */
1056 ptr2prim_i->p_ul_alloc.p_fixed_alloc.size_bitmap = 1;
1057 ptr2prim_i->p_tbf_start.tbf_start_present=TRUE;
1058 ptr2prim_i->p_ul_alloc.p_fixed_alloc.bitmap[0] = 0x80 >> d_ul_assign->sin_alloc.tn;
1059 }
1060 else
1061 {
1062 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
1063 }
1064 }
1065 else if (d_ul_assign->sin_alloc.tbf_s_time.v_rel)
1066 {
1067 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
1068 (USHORT)(d_ul_assign->sin_alloc.tbf_s_time.rel));
1069 if(!grr_check_if_tbf_start_is_elapsed ( ptr2prim_i->p_tbf_start.fn, grr_data->ul_fn))
1070 {
1071 /*Allocated Number of time slots are 1 */
1072 ptr2prim_i->p_ul_alloc.p_fixed_alloc.size_bitmap = 1;
1073 ptr2prim_i->p_tbf_start.tbf_start_present=TRUE;
1074 ptr2prim_i->p_ul_alloc.p_fixed_alloc.bitmap[0] = 0x80 >> d_ul_assign->sin_alloc.tn;
1075 }
1076 else
1077 {
1078 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
1079 }
1080 }
1081 }/* single block */
1082 }
1083 else
1084 #endif
1085 if( d_ul_assign->msg_type EQ D_UL_ASSIGN_c)
1086 {
1087 /*
1088 * timing advance
1089 */
1090
1091 grr_handle_ta ( d_ul_assign->pta.v_ta_value,
1092 d_ul_assign->pta.ta_value,
1093 d_ul_assign->pta.v_ta_index_tn,
1094 d_ul_assign->pta.ta_index_tn.ta_index,
1095 d_ul_assign->pta.ta_index_tn.ta_tn,
1096 0xFF,
1097 0,
1098 0,
1099 &ptr2prim_i->p_timing_advance);
1100
1101 if(d_ul_assign->f_alloc_ul.v_bts_pwr_ctrl)
1102 {
1103 ptr2prim_i->p_dl_power.p0 = d_ul_assign->f_alloc_ul.bts_pwr_ctrl.p0;
1104 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode =
1105 d_ul_assign->f_alloc_ul.bts_pwr_ctrl.mode;
1106 ptr2prim_i->p_dl_power.pr_mode =
1107 d_ul_assign->f_alloc_ul.bts_pwr_ctrl.pr_mode;
1108 }
1109 else
1110 {
1111 ptr2prim_i->p_dl_power.p0 = 0xff;
1112 }
1113
1114 /*
1115 * mac mode
1116 */
1117 ptr2prim_i->mac_mode = FA;
1118 /*
1119 * uplink allocation structure
1120 */
1121 if(d_ul_assign->f_alloc_ul.v_ul_tfi_assign)
1122 {
1123 ptr2prim_i->p_ul_alloc.ul_tfi = d_ul_assign->f_alloc_ul.ul_tfi_assign;
1124 }
1125 else
1126 {
1127 ptr2prim_i->p_ul_alloc.ul_tfi = grr_data->uplink_tbf.tfi;
1128 }
1129 ptr2prim_i->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
1130 /*
1131 * fixed allocation structure
1132 * half duplex mode is ignored, only valid for MS class 19 to 29
1133 */
1134
1135 /*
1136 * TBF STARTING TIME for fixed allocation structure
1137 */
1138 if(d_ul_assign->f_alloc_ul.tbf_s_time.v_abs)
1139 {
1140 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ul_assign->f_alloc_ul.tbf_s_time.abs);
1141 }
1142 else if (d_ul_assign->f_alloc_ul.tbf_s_time.v_rel)
1143 {
1144 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
1145 d_ul_assign->f_alloc_ul.tbf_s_time.rel);
1146 }
1147 else
1148 { /* this shall never happen */
1149 ptr2prim_i->p_tbf_start.fn = (grr_data->dl_fn+13)%FN_MAX;
1150 TRACE_ERROR("NO STARTING TIME IN FIXED ALLOCATION!!");
1151 }
1152 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
1153 /*
1154 * Downlink Control Timeslot
1155 */
1156 ptr2prim_i->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = d_ul_assign->f_alloc_ul.dl_ctrl_ts;
1157 grr_data->tc.fa_ctrl.dl_ctrl_ts = d_ul_assign->f_alloc_ul.dl_ctrl_ts;
1158 /*
1159 * ALLOCATION BITMAP
1160 */
1161 if(d_ul_assign->f_alloc_ul.v_block_struct)
1162 {
1163 tc_calc_fa_bitmap(ptr2prim_i->p_tbf_start.fn, /*starting time of cuurent tbf*/
1164 d_ul_assign->f_alloc_ul.block_struct.bl_o_bl_per,/* blocks or block periods*/
1165 d_ul_assign->f_alloc_ul.block_struct.a_map_len, /* bitmap length*/
1166 d_ul_assign->f_alloc_ul.block_struct.alloc_map, /* ptr to alloc struct*/
1167 &ptr2prim_i->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1168 }
1169 else if(d_ul_assign->f_alloc_ul.v_alloc_map)
1170 {
1171 tc_calc_fa_bitmap(ptr2prim_i->p_tbf_start.fn, /*starting time of cuurent tbf*/
1172 0, /* blocks : default*/
1173 d_ul_assign->f_alloc_ul.c_alloc_map, /* bitmap length*/
1174 d_ul_assign->f_alloc_ul.alloc_map, /* ptr to alloc struct*/
1175 &ptr2prim_i->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1176 }
1177 /*
1178 * check final allocation
1179 */
1180 grr_data->tc.fa_ctrl.current_alloc.final_alloc = d_ul_assign->f_alloc_ul.final_alloc;
1181 }
1182 else if ( d_ts_reconfig->msg_type EQ D_TS_RECONFIG_c)
1183 {
1184 /*
1185 * timing advance is handled in tc_set_dl_assignment
1186 */
1187
1188 if(d_ts_reconfig->f_alloc_re.v_bts_pwr_ctrl)
1189 {
1190 ptr2prim_i->p_dl_power.p0 = d_ts_reconfig->f_alloc_re.bts_pwr_ctrl.p0;
1191 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode =
1192 d_ts_reconfig->f_alloc_re.bts_pwr_ctrl.mode;
1193 ptr2prim_i->p_dl_power.pr_mode =
1194 d_ts_reconfig->f_alloc_re.bts_pwr_ctrl.pr_mode;
1195 }
1196 else
1197 {
1198 ptr2prim_i->p_dl_power.p0 = 0xff;
1199 }
1200
1201 /*
1202 * mac mode
1203 */
1204 ptr2prim_i->mac_mode = FA;
1205 /*
1206 * uplink allocation structure
1207 */
1208 if(d_ts_reconfig->v_ul_tfi)
1209 {
1210 ptr2prim_i->p_ul_alloc.ul_tfi = d_ts_reconfig->ul_tfi;
1211 }
1212 else
1213 {
1214 ptr2prim_i->p_ul_alloc.ul_tfi = grr_data->uplink_tbf.tfi;
1215 }
1216 ptr2prim_i->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
1217 /*
1218 * fixed allocation structure
1219 * half duplex mode is ignored, only valid for MS class 19 to 29
1220 */
1221 /*
1222 * TBF STARTING TIME for fixed allocation structure
1223 */
1224 if(d_ts_reconfig->f_alloc_re.tbf_s_time.v_abs)
1225 {
1226 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ts_reconfig->f_alloc_re.tbf_s_time.abs);
1227 }
1228 else if (d_ts_reconfig->f_alloc_re.tbf_s_time.v_rel)
1229 {
1230 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
1231 d_ts_reconfig->f_alloc_re.tbf_s_time.rel);
1232 }
1233 else
1234 { /* this shall never happen */
1235 ptr2prim_i->p_tbf_start.fn = (grr_data->dl_fn+13)%FN_MAX;
1236 TRACE_ERROR("NO STARTING TIME IN FIXED ALLOCATION!!");
1237 }
1238 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
1239 /*
1240 * Downlink Control Timeslot
1241 */
1242 ptr2prim_i->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = d_ts_reconfig->f_alloc_re.dl_ctrl_ts;
1243 grr_data->tc.fa_ctrl.dl_ctrl_ts = d_ts_reconfig->f_alloc_re.dl_ctrl_ts;
1244 /*
1245 * ALLOCATION BITMAP
1246 */
1247 if(d_ts_reconfig->f_alloc_re.v_block_struct)
1248 {
1249 tc_calc_fa_bitmap(ptr2prim_i->p_tbf_start.fn, /*starting time of cuurent tbf*/
1250 d_ts_reconfig->f_alloc_re.block_struct.bl_o_bl_per, /* blocks or block periods*/
1251 d_ts_reconfig->f_alloc_re.block_struct.a_map_len, /* bitmap length*/
1252 d_ts_reconfig->f_alloc_re.block_struct.alloc_map, /* ptr to alloc struct*/
1253 &ptr2prim_i->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1254 }
1255 else if(d_ts_reconfig->f_alloc_re.v_alloc_map)
1256 {
1257 tc_calc_fa_bitmap(ptr2prim_i->p_tbf_start.fn, /*starting time of cuurent tbf*/
1258 0, /* blocks : default*/
1259 d_ts_reconfig->f_alloc_re.c_alloc_map, /* bitmap length*/
1260 d_ts_reconfig->f_alloc_re.alloc_map, /* ptr to alloc struct*/
1261 &ptr2prim_i->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1262 }
1263 /*
1264 * check final allocation
1265 */
1266 grr_data->tc.fa_ctrl.current_alloc.final_alloc = d_ts_reconfig->f_alloc_re.final_alloc;
1267 }
1268 else if ( d_ul_ack->msg_type EQ D_UL_ACK_c)
1269 {
1270 /*
1271 * Timing Advance in packet uplink ack/nack with fixed allocation
1272 */
1273 if(d_ul_ack->gprs_ul_ack_nack_info.v_pta)
1274 {
1275 grr_handle_ta ( d_ul_ack->gprs_ul_ack_nack_info.pta.v_ta_value,
1276 d_ul_ack->gprs_ul_ack_nack_info.pta.ta_value,
1277 d_ul_ack->gprs_ul_ack_nack_info.pta.v_ta_index_tn,
1278 d_ul_ack->gprs_ul_ack_nack_info.pta.ta_index_tn.ta_index,
1279 d_ul_ack->gprs_ul_ack_nack_info.pta.ta_index_tn.ta_tn,
1280 0xFF,
1281 0,
1282 0,
1283 &ptr2prim_i->p_timing_advance);
1284 }
1285 else
1286 {
1287 grr_handle_ta ( 0,
1288 0,
1289 0xFF,
1290 0,
1291 0,
1292 0xFF,
1293 0,
1294 0,
1295 &ptr2prim_i->p_timing_advance);
1296 }
1297
1298 /*
1299 * mac mode
1300 */
1301 ptr2prim_i->mac_mode = FA;
1302 /*
1303 * uplink allocation structure
1304 */
1305
1306 /*no change, therefore take from database*/
1307 ptr2prim_i->p_ul_alloc.ul_tfi = grr_data->uplink_tbf.tfi;
1308 ptr2prim_i->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
1309 /*
1310 * fixed allocation structure
1311 * half duplex mode is ignored, only valid for MS class 19 to 29
1312 */
1313 /*
1314 * TBF STARTING TIME for fixed allocation structure
1315 */
1316 if(d_ul_ack->gprs_ul_ack_nack_info.v_f_alloc_ack AND d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.v_fa_s2)
1317 {
1318 if(d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.tbf_s_time.v_abs)
1319 {
1320 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.tbf_s_time.abs);
1321 }
1322 else if (d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.tbf_s_time.v_rel)
1323 {
1324 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
1325 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.tbf_s_time.rel);
1326 }
1327 else
1328 { /* this shall never happen */
1329 ptr2prim_i->p_tbf_start.fn = (grr_data->dl_fn+13)%FN_MAX;
1330 TRACE_ERROR("NO STARTING TIME IN FIXED ALLOCATION!! struct problem");
1331 }
1332 }
1333 else
1334 { /* this shall never happen */
1335 ptr2prim_i->p_tbf_start.fn = (grr_data->dl_fn+13)%FN_MAX;
1336 TRACE_ERROR("NO STARTING TIME IN FIXED ALLOCATION!!");
1337 }
1338 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
1339
1340
1341 /*
1342 * Downlink Control Timeslot, take from database
1343 */
1344 ptr2prim_i->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = grr_data->tc.fa_ctrl.dl_ctrl_ts;
1345 /*
1346 * ALLOCATION BITMAP
1347 */
1348 if(d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.v_block_struct)
1349 {
1350 tc_calc_fa_bitmap(ptr2prim_i->p_tbf_start.fn, /* starting time of cuurent tbf*/
1351 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.block_struct.bl_o_bl_per,/* blocks or block periods*/
1352 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.block_struct.a_map_len, /* bitmap length */
1353 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.block_struct.alloc_map, /* ptr to alloc struct*/
1354 &ptr2prim_i->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1355 }
1356 else if(d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.v_alloc_map)
1357 {
1358 tc_calc_fa_bitmap(ptr2prim_i->p_tbf_start.fn, /*starting time of cuurent tbf*/
1359 0, /* blocks : default*/
1360 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.c_alloc_map, /* bitmap length*/
1361 d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.fa_s2.alloc_map, /* ptr to alloc struct*/
1362 &ptr2prim_i->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1363 }
1364 /*
1365 * check final allocation
1366 */
1367 grr_data->tc.fa_ctrl.current_alloc.final_alloc = d_ul_ack->gprs_ul_ack_nack_info.f_alloc_ack.final_alloc;
1368 }
1369 else
1370 {
1371 TRACE_ERROR ( "Wrong message type in _decodedCtrlMsg" );
1372 }
1373
1374 if(ptr2prim_i->p_tbf_start.tbf_start_present)
1375 grr_data->uplink_tbf.tbf_start_fn = ptr2prim_i->p_tbf_start.fn;
1376 else
1377 grr_data->uplink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
1378
1379 grr_data->uplink_tbf.st_tfi = ptr2prim_i->p_ul_alloc.ul_tfi;
1380
1381
1382 return;
1383 } /* tc_set_fa_assignment() */
1384
1385
1386 /*
1387 +------------------------------------------------------------------------------
1388 | Function : tc_set_dl_assignment
1389 +------------------------------------------------------------------------------
1390 | Description : This function sets some parameter of T_MPHP_ASSIGNMENT_REQ is
1391 | case of downlink allocation
1392 |
1393 | Parameters : ptr2prim_i - ptr to MPHP_ASSIGNMENT_REQ
1394 |
1395 +------------------------------------------------------------------------------
1396 */
1397 LOCAL void tc_set_dl_assignment (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i)
1398 {
1399 MCAST(d_dl_assign, D_DL_ASSIGN); /* T_D_DL_ASSIGN */
1400 MCAST(d_ts_reconfig,D_TS_RECONFIG);
1401
1402 TRACE_FUNCTION( "tc_set_dl_assignment" );
1403 if( d_dl_assign->msg_type EQ D_DL_ASSIGN_c)
1404 {
1405 /*
1406 * timing advance
1407 */
1408 grr_handle_ta ( d_dl_assign->pta.v_ta_value,
1409 d_dl_assign->pta.ta_value,
1410 0xFF,
1411 0,
1412 0,
1413 d_dl_assign->pta.v_ta_index_tn,
1414 d_dl_assign->pta.ta_index_tn.ta_index,
1415 d_dl_assign->pta.ta_index_tn.ta_tn,
1416 &ptr2prim_i->p_timing_advance);
1417 /*
1418 * TBF starting time
1419 */
1420
1421 if(d_dl_assign->pda_trnc_grp.v_tbf_s_time)
1422 {
1423 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
1424 if(d_dl_assign->pda_trnc_grp.tbf_s_time.v_abs)
1425 {
1426 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_dl_assign->pda_trnc_grp.tbf_s_time.abs);
1427 }
1428 else if (d_dl_assign->pda_trnc_grp.tbf_s_time.v_rel)
1429 {
1430 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
1431 d_dl_assign->pda_trnc_grp.tbf_s_time.rel);
1432 }
1433 else
1434 { /* this shall never happen */
1435 ptr2prim_i->p_tbf_start.fn = grr_data->dl_fn%FN_MAX;
1436 TRACE_ERROR("DL v_start_tbf but either rel nor abs tbf included");
1437 }
1438 }
1439 else if(grr_data->l1_del_tbf_start_fn NEQ GRR_INVALID_FN)
1440 {
1441 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
1442 ptr2prim_i->p_tbf_start.fn = grr_data->l1_del_tbf_start_fn;
1443 }
1444 else
1445 {
1446 ptr2prim_i->p_tbf_start.tbf_start_present = 0;
1447 }
1448
1449
1450 if(d_dl_assign->v_bts_pwr_ctrl)
1451 {
1452 ptr2prim_i->p_dl_power.p0 = d_dl_assign->bts_pwr_ctrl.p0;
1453 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode = d_dl_assign->bts_pwr_ctrl.mode;
1454 ptr2prim_i->p_dl_power.pr_mode = d_dl_assign->bts_pwr_ctrl.pr_mode;
1455 }
1456 else
1457 {
1458 ptr2prim_i->p_dl_power.p0 = 0xff;
1459 }
1460 /*
1461 * mac mode
1462 */
1463 ptr2prim_i->mac_mode = d_dl_assign->mac_mode;
1464
1465 /*
1466 * downlink allocation structure
1467 */
1468 if(d_dl_assign->pda_trnc_grp.v_dl_tfi_assign)
1469 {
1470 ptr2prim_i->p_dl_alloc.dl_tfi = d_dl_assign->pda_trnc_grp.dl_tfi_assign;
1471 }
1472 else
1473 {
1474 ptr2prim_i->p_dl_alloc.dl_tfi = grr_data->downlink_tbf.tfi;
1475 }
1476 ptr2prim_i->p_dl_alloc.ts_mask = d_dl_assign->ts_alloc;
1477
1478 }
1479 else if ( d_ts_reconfig->msg_type EQ D_TS_RECONFIG_c)
1480 {
1481 /* TS Reconfigure allways contains ul assign -> TBF starting time
1482 * is handled there
1483 */
1484 if(d_ts_reconfig->v_dl_tfi)
1485 {
1486 ptr2prim_i->p_dl_alloc.dl_tfi = d_ts_reconfig->dl_tfi;
1487 }
1488 else
1489 {
1490 ptr2prim_i->p_dl_alloc.dl_tfi = grr_data->downlink_tbf.tfi;
1491 }
1492 ptr2prim_i->p_dl_alloc.ts_mask = grr_data->downlink_tbf.ts_usage;
1493 /*
1494 * timing advance
1495 */
1496 grr_handle_ta ( d_ts_reconfig->gpta.v_ta_value,
1497 d_ts_reconfig->gpta.ta_value,
1498 d_ts_reconfig->gpta.v_ul_ta_index,
1499 d_ts_reconfig->gpta.ul_ta_index,
1500 d_ts_reconfig->gpta.ul_ta_tn,
1501 d_ts_reconfig->gpta.v_dl_ta_index,
1502 d_ts_reconfig->gpta.dl_ta_index,
1503 d_ts_reconfig->gpta.dl_ta_tn,
1504 &ptr2prim_i->p_timing_advance);
1505 }
1506 else
1507 {
1508 TRACE_ERROR ( "Wrong message type in _decodedCtrlMsg" );
1509 }
1510
1511
1512 if(ptr2prim_i->p_tbf_start.tbf_start_present)
1513 grr_data->downlink_tbf.tbf_start_fn = ptr2prim_i->p_tbf_start.fn;
1514 else
1515 grr_data->downlink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
1516
1517 grr_data->downlink_tbf.st_tfi = ptr2prim_i->p_dl_alloc.dl_tfi;
1518 grr_data->downlink_tbf.polling_bit = 0xFF;
1519
1520
1521
1522 return;
1523 } /* tc_set_dl_assignment() */
1524
1525
1526
1527 /*==== PUBLIC FUNCTIONS =====================================================*/
1528
1529
1530
1531 /*
1532 +------------------------------------------------------------------------------
1533 | Function : tc_gen_rand
1534 +------------------------------------------------------------------------------
1535 | Description : This function generates a random value between db.prach.s
1536 | and (db.prach.tx_int -1)
1537 |
1538 | Parameters : void
1539 |
1540 +------------------------------------------------------------------------------
1541 */
1542 GLOBAL USHORT tc_gen_rand ( void )
1543 {
1544 USHORT result ;
1545 UBYTE i;
1546 TRACE_FUNCTION( "tc_gen_rand" );
1547
1548 /*
1549 * the "-1" defined in ETS 04.60 will be done by tc_random_value()
1550 *
1551 */
1552 i = tx_int_table[psc_db->prach.tx_int];
1553
1554 result = (USHORT)grr_random_value (S_T_RND_INDEX, i );
1555
1556 result += s_table[psc_db->prach.s_prach];
1557
1558 #ifndef _TARGET_
1559 TRACE_EVENT_P2("S, S+1 ..:%d tx_init:%d",result, i);
1560 #endif /* _TARGET_ */
1561
1562 return (result);
1563
1564 } /* tc_gen_rand() */
1565
1566
1567
1568 /*
1569 +------------------------------------------------------------------------------
1570 | Function : tc_calc_req
1571 +------------------------------------------------------------------------------
1572 | Description : The function tc_calc_req() generate the message
1573 | Packet Access Request.
1574 |
1575 | Parameters : void
1576 |
1577 +------------------------------------------------------------------------------
1578 */
1579 GLOBAL USHORT tc_calc_req ( void )
1580 {
1581 USHORT channel_request_data = 0;
1582
1583 TRACE_FUNCTION( "tc_calc_req" );
1584
1585 switch(psc_db->gprs_cell_opt.ab_type)
1586 {
1587 case AB_8_BIT:
1588 switch(grr_data->uplink_tbf.access_type)
1589 {
1590 case CGRLC_AT_ONE_PHASE:
1591 channel_request_data = tc_one_phase_mask_8bit();
1592 channel_request_data |= ((grr_get_gprs_ms_class( )-1)<<2);
1593 break;
1594 case CGRLC_AT_SHORT_ACCESS:
1595 channel_request_data = tc_short_access_mask_8bit();
1596 channel_request_data |= ((grr_data->uplink_tbf.nr_blocks-1)<<3);
1597 break;
1598 case CGRLC_AT_TWO_PHASE:
1599 channel_request_data=tc_two_phase_mask_8bit();
1600 break;
1601 case CGRLC_AT_PAGE_RESPONSE:
1602 channel_request_data=tc_page_response_mask_8bit();
1603 break;
1604 case CGRLC_AT_CELL_UPDATE:
1605 channel_request_data=tc_cell_update_mask_8bit();
1606 break;
1607 case CGRLC_AT_MM_PROCEDURE:
1608 channel_request_data=tc_mm_procedure_mask_8bit();
1609 break;
1610 case CGRLC_AT_SINGLE_BLOCK:
1611 channel_request_data=tc_single_block_mask_8bit();
1612 break;
1613 default:
1614 break;
1615 }
1616 break;
1617
1618 case AB_11_BIT:
1619 switch(grr_data->uplink_tbf.access_type)
1620 {
1621 case CGRLC_AT_ONE_PHASE:
1622 channel_request_data=tc_one_phase_mask_11bit();
1623 channel_request_data |= ((grr_get_gprs_ms_class( )-1)<<5);
1624 channel_request_data |= (grr_data->uplink_tbf.prio<<3);
1625 break;
1626 case CGRLC_AT_SHORT_ACCESS:
1627 channel_request_data=tc_short_access_mask_11bit();
1628 channel_request_data |= (grr_data->uplink_tbf.prio<<3);
1629 channel_request_data |= ((grr_data->uplink_tbf.nr_blocks-1)<<5);
1630 break;
1631 case CGRLC_AT_TWO_PHASE:
1632 channel_request_data=tc_two_phase_mask_11bit();
1633 channel_request_data |= (grr_data->uplink_tbf.prio<<3);
1634 break;
1635 case CGRLC_AT_PAGE_RESPONSE:
1636 channel_request_data=tc_page_response_mask_11bit();
1637 break;
1638 case CGRLC_AT_CELL_UPDATE:
1639 channel_request_data=tc_cell_update_mask_11bit();
1640 break;
1641 case CGRLC_AT_MM_PROCEDURE:
1642 channel_request_data=tc_mm_procedure_mask_11bit();
1643 break;
1644 case CGRLC_AT_SINGLE_BLOCK:
1645 channel_request_data=tc_single_block_mask_11bit();
1646 break;
1647 default:
1648 channel_request_data = 0;
1649 break;
1650 }
1651 channel_request_data = grr_convert_11bit_2_etsi(channel_request_data);
1652 TRACE_EVENT_P1("11 bit Channel Request: 0x%X", channel_request_data);
1653 break;
1654 default:
1655 break;
1656 }
1657 return(channel_request_data);
1658
1659 } /* tc_calc_req() */
1660
1661
1662
1663 /*
1664 +------------------------------------------------------------------------------
1665 | Function : tc_check_p_level
1666 +------------------------------------------------------------------------------
1667 | Description : The function tc_check_p_level() checks the p-level for the
1668 | PDU's radio priority aigainst a random value and returns
1669 | wheather to send the random access or to continue with
1670 | calculating.
1671 |
1672 | Parameters : void
1673 |
1674 +------------------------------------------------------------------------------
1675 */
1676 GLOBAL T_CHECK_P_LEVEL tc_check_p_level ( void )
1677 {
1678 UBYTE p_level,i;
1679 T_CHECK_P_LEVEL result;
1680 TRACE_FUNCTION( "tc_check_p_level" );
1681
1682 /*
1683 * get value between 0 and 15
1684 */
1685 i = (UBYTE) grr_random_value (PLEV_RND_INDEX, 16);
1686
1687 p_level = psc_db->prach.pers_lev.plev[grr_data->uplink_tbf.prio];
1688
1689 if(p_level EQ 15)
1690 {
1691 /*
1692 * transmission in every case forbitten, because refer to ETS the value 0xf
1693 * have to be interpreted as 16 and i is in every case more little (0 <= i <= 15).
1694 * This case should be avoided (dead lock!) and have to be checked
1695 * in tc_start_access()
1696 */
1697 TRACE_ERROR("unexpected persistence_level_value");
1698 result = C_P_LEVEL_DO_NOT_SEND;
1699 }
1700 else
1701 {
1702 result = ( (i >= p_level) ? C_P_LEVEL_SEND : C_P_LEVEL_DO_NOT_SEND );
1703 }
1704
1705 return( result );
1706
1707 } /* tc_check_p_level() */
1708
1709
1710
1711 /*
1712 +------------------------------------------------------------------------------
1713 | Function : tc_send_assign_req
1714 +------------------------------------------------------------------------------
1715 | Description : The function tc_send_assign_req() builds MPHP_ASSIGNMENT_REQ
1716 | and send it.
1717 |
1718 | Parameters : tbf_type_i - type of TBF that is to activate
1719 |
1720 +------------------------------------------------------------------------------
1721 */
1722 GLOBAL void tc_send_assign_req ( T_TBF_TYPE tbf_type_i )
1723 {
1724
1725 TRACE_FUNCTION( "tc_send_assign_req" );
1726 {
1727 T_MPHP_ASSIGNMENT_REQ * ptr2prim;//=NULL;
1728
1729 ptr2prim=tc_set_freq();
1730
1731 grr_set_tbf_cfg_req_param( ptr2prim );
1732
1733 switch( tbf_type_i )
1734 {
1735 case CGRLC_TBF_MODE_DL:
1736 ptr2prim->assign_cmd = DL_ASSIGNMENT;
1737 tc_set_dl_assignment(ptr2prim);
1738 break;
1739 case CGRLC_TBF_MODE_UL:
1740 ptr2prim->assign_cmd = UL_ASSIGNMENT;
1741 if(grr_data->uplink_tbf.mac_mode EQ DA)
1742 tc_set_da_assignment(ptr2prim);
1743 else
1744 tc_set_fa_assignment(ptr2prim);
1745 break;
1746 case CGRLC_TBF_MODE_DL_UL:
1747 ptr2prim->assign_cmd = UL_DL_ASSIGNMENT;
1748 if(grr_data->uplink_tbf.mac_mode EQ DA)
1749 tc_set_da_assignment(ptr2prim);
1750 else
1751 tc_set_fa_assignment(ptr2prim);
1752 tc_set_dl_assignment(ptr2prim);
1753 break;
1754 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
1755 case CGRLC_TBF_MODE_2PA:
1756 ptr2prim->assign_cmd = UL_TP_ACCESS;
1757 tc_set_fa_assignment(ptr2prim);
1758 break;
1759 #endif
1760 default:
1761 break;
1762 } /* switch (tbf_type_i) */
1763 PSEND(hCommL1,ptr2prim);
1764
1765 }
1766 } /* tc_send_assign_req() */
1767
1768
1769
1770 /*
1771 +------------------------------------------------------------------------------
1772 | Function : tc_send_tbf_rel
1773 +------------------------------------------------------------------------------
1774 | Description : The function tc_send_tbf_rel() builds MPHP_TBF_RELEASE_REQ
1775 | and send it.
1776 |
1777 | Parameters : TBP-Type - that have to be deleted
1778 |
1779 +------------------------------------------------------------------------------
1780 */
1781 GLOBAL void tc_send_tbf_rel ( T_TBF_TYPE tbf_i )
1782 {
1783 UBYTE dummy = grr_data->tc.num_of_rels_running;
1784
1785 TRACE_FUNCTION( "tc_send_tbf_rel" );
1786
1787 tc_prepare_send_tbf_release_req( tbf_i );
1788
1789 {
1790 T_RELEASE_STATE rel_state= REL_PERFORMED;
1791
1792 if(dummy NEQ grr_data->tc.num_of_rels_running)
1793 {
1794 rel_state = REL_RUNNING;
1795 }
1796 sig_tc_ctrl_rel_state(rel_state);
1797 }
1798
1799
1800 } /* tc_send_tbf_rel() */
1801
1802
1803
1804 /*
1805 +------------------------------------------------------------------------------
1806 | Function : tc_send_pdch_rel
1807 +------------------------------------------------------------------------------
1808 | Description : The function tc_send_pdch_rel() builds MPHP_PDCH_RELEASE_REQ
1809 | and send it.
1810 |
1811 | Parameters : void
1812 |
1813 +------------------------------------------------------------------------------
1814 */
1815 GLOBAL void tc_send_pdch_rel ( UBYTE ts_available )
1816 {
1817 PALLOC(mphp_pdch_release_req,MPHP_PDCH_RELEASE_REQ);
1818
1819 TRACE_FUNCTION( "tc_send_pdch_rel" );
1820
1821 mphp_pdch_release_req->assign_id = 0;
1822 mphp_pdch_release_req->ts_mask = ts_available;
1823 PSEND(hCommL1,mphp_pdch_release_req);
1824
1825 } /* tc_send_pdch_rel() */
1826
1827
1828
1829 /*
1830 +------------------------------------------------------------------------------
1831 | Function : tc_abort_tbf
1832 +------------------------------------------------------------------------------
1833 | Description : The function tc_abort_tbf() stops a TBF.
1834 |
1835 | Parameters : tbf_i - TBF type to abort
1836 |
1837 +------------------------------------------------------------------------------
1838 */
1839 GLOBAL void tc_abort_tbf ( T_TBF_TYPE tbf_i )
1840 {
1841
1842 TRACE_FUNCTION( "tc_abort_tbf" );
1843
1844 switch( tbf_i )
1845 {
1846 case CGRLC_TBF_MODE_NULL:
1847 TRACE_EVENT("NULL TBF active: check if tbf starting time is running");
1848 tc_cgrlc_ul_tbf_res ( CGRLC_TBF_MODE_ACCESS_FAILED, CGRLC_PRIM_STATUS_NULL );
1849 break;
1850 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
1851 case CGRLC_TBF_MODE_2PA:
1852 tc_send_tbf_rel(tbf_i);
1853 tc_cgrlc_tbf_rel_req(tbf_i,CGRLC_TBF_REL_ABNORMAL,CGRLC_STARTING_TIME_NOT_PRESENT);
1854 tc_deactivate_tbf(tbf_i);
1855 break;
1856 #endif
1857 case CGRLC_TBF_MODE_UL:
1858 tc_send_tbf_rel(tbf_i);
1859 tc_cgrlc_tbf_rel_req(tbf_i,CGRLC_TBF_REL_ABNORMAL,CGRLC_STARTING_TIME_NOT_PRESENT);
1860 tc_deactivate_tbf(tbf_i);
1861 break;
1862 case CGRLC_TBF_MODE_DL:
1863 tc_send_tbf_rel(tbf_i);
1864 tc_cgrlc_tbf_rel_req(tbf_i,CGRLC_TBF_REL_ABNORMAL,CGRLC_STARTING_TIME_NOT_PRESENT);
1865 tc_deactivate_tbf(tbf_i);
1866 break;
1867 case CGRLC_TBF_MODE_DL_UL:
1868 tc_send_tbf_rel(tbf_i);
1869 tc_cgrlc_tbf_rel_req(tbf_i,CGRLC_TBF_REL_ABNORMAL,CGRLC_STARTING_TIME_NOT_PRESENT);
1870 tc_deactivate_tbf(tbf_i);
1871 break;
1872 default:
1873 TRACE_ERROR ( "tc_abort_tbf: TBF type is invalid" );
1874 break;
1875 }
1876 } /* tc_abort_tbf() */
1877
1878
1879
1880
1881
1882 /*
1883 +------------------------------------------------------------------------------
1884 | Function : tc_build_res_req
1885 +------------------------------------------------------------------------------
1886 | Description : The function tc_build_res_req() builds Packet Resource Request.
1887 |
1888 | Parameters : reason_i - the reason for building that packet resouce
1889 | reallocation
1890 | src_info_i - indicates where to get the carrier information
1891 | regarding the assigned TBF
1892 |
1893 +------------------------------------------------------------------------------
1894 */
1895 GLOBAL void tc_build_res_req (T_U_RESOURCE_REQ *ptr2res_req,
1896 T_REASON_BUILD reason_i,
1897 T_SRC_TBF_INFO src_info_i )
1898 {
1899 UBYTE change_mark;
1900
1901 TRACE_FUNCTION( "tc_build_res_req" );
1902
1903
1904 memset(ptr2res_req,0,sizeof(T_U_RESOURCE_REQ) );
1905
1906 /* processing of messsage type */
1907 ptr2res_req->msg_type = U_RESOURCE_REQ_c;
1908
1909 /* processing of change mark */
1910 if( grr_is_pbcch_present( ) )
1911 {
1912 change_mark = psc_db->psi2_params.psi2_change_mark;
1913 }
1914 else
1915 {
1916 change_mark = psc_db->psi13_params.si13_change_mark;
1917 }
1918
1919 if( change_mark EQ NOT_SET )
1920 {
1921 ptr2res_req->v_ma_ch_mark = 0;
1922 }
1923 else
1924 {
1925 ptr2res_req->v_ma_ch_mark = 1;
1926 ptr2res_req->ma_ch_mark = change_mark;
1927 }
1928
1929
1930 if(reason_i EQ R_BUILD_2PHASE_ACCESS)
1931 {
1932 /* 1 - processing of ACCESS_TYPE */
1933 ptr2res_req->v_access_type = 1;
1934 ptr2res_req->access_type = TWO_PHASE;
1935
1936 /* 2 - processing of global TFI and TLLI */
1937 ptr2res_req->flag = 1;
1938 ptr2res_req->v_glob_tfi = 0;
1939 ptr2res_req->v_tlli_value = 1;
1940
1941 grr_set_buf_tlli( &ptr2res_req->tlli_value, grr_data->db.ms_id.new_tlli );
1942
1943 /* 3 - processing of radio access capabilities */
1944 if( rr_csf_get_radio_access_capability( &ptr2res_req->ra_cap ) EQ 0 )
1945 {
1946 ptr2res_req->v_ra_cap = TRUE;
1947 }
1948 else
1949 {
1950 ptr2res_req->v_ra_cap = FALSE;
1951
1952 TRACE_ERROR( "tc_build_res_req: radio access capabilities invalid" );
1953 }
1954 /* 4 - processing of channel request description */
1955 ptr2res_req->chan_req_des.peak_thr_class = (UBYTE) grr_data->uplink_tbf.peak;
1956 ptr2res_req->chan_req_des.radio_prio = grr_data->uplink_tbf.prio;
1957 if(grr_data->uplink_tbf.prim_type EQ CGRLC_LLC_PRIM_TYPE_UNITDATA_REQ)
1958 {
1959 ptr2res_req->chan_req_des.rlc_mode = CGRLC_RLC_MODE_UACK;
1960 }
1961 else
1962 {
1963 ptr2res_req->chan_req_des.rlc_mode = CGRLC_RLC_MODE_ACK;
1964 }
1965 ptr2res_req->chan_req_des.llc_pdu_type = LLC_NOT_ACK;
1966 ptr2res_req->chan_req_des.rlc_octet_cnt = grr_data->uplink_tbf.rlc_oct_cnt;
1967
1968 /* 5 - processing of signal variance */
1969 ptr2res_req->v_signvar = FALSE;
1970 }
1971
1972 /* processing of C value */
1973 {
1974 ptr2res_req->c_value = meas_c_get_value( );
1975 }
1976
1977 /* processing of relative interference levels */
1978 {
1979 T_p_frequency_par freq_par;
1980 T_MEAS_IM_CARRIER ma;
1981
1982 switch( src_info_i )
1983 {
1984 case( SRC_TBF_INFO_RE_ASSIGN ):
1985 case( SRC_TBF_INFO_IMM_ASSIGN ):
1986 case( SRC_TBF_INFO_UL_ASSIGN ):
1987 grr_set_freq_par( &freq_par );
1988 meas_im_set_carrier( &ma, &freq_par );
1989 break;
1990
1991 default:
1992 TRACE_ASSERT( src_info_i EQ SRC_TBF_INFO_RE_ASSIGN OR
1993 src_info_i EQ SRC_TBF_INFO_IMM_ASSIGN OR
1994 src_info_i EQ SRC_TBF_INFO_UL_ASSIGN );
1995 break;
1996 }
1997
1998 meas_im_get_rel_i_level( &ma, &ptr2res_req->ilev );
1999 }
2000
2001 #ifdef REL99
2002 ptr2res_req->v_release_99_str_prr = FALSE;
2003 ptr2res_req->release_99_str_prr.flag = 0;
2004 ptr2res_req->release_99_str_prr.flag2 = 0;
2005 ptr2res_req->release_99_str_prr.v_pfi = 0;
2006 ptr2res_req->release_99_str_prr.add_ms_rac = 0;
2007 ptr2res_req->release_99_str_prr.retrans_of_prr = 0;
2008 #endif
2009
2010 } /* tc_build_res_req() */
2011
2012
2013 /*
2014 +------------------------------------------------------------------------------
2015 | Function : tc_eval_pdch_rel
2016 +------------------------------------------------------------------------------
2017 | Description : The function tc_eval_pdch_rel() evaluate a
2018 | Packet PDCH Release.
2019 |
2020 | Parameters : slot_i - the slot where the message was received
2021 |
2022 +------------------------------------------------------------------------------
2023 */
2024 GLOBAL T_EVAL_PDCH_REL tc_eval_pdch_rel ( UBYTE slot_i )
2025 {
2026 MCAST(d_pdch_release,D_PDCH_RELEASE); /* T_D_PDCH_RELEASE */
2027
2028 UBYTE mask,help=0xFF, help2=0xFF;
2029 T_EVAL_PDCH_REL result=E_PDCH_REL_NULL;
2030
2031 TRACE_FUNCTION( "tc_eval_pdch_rel" );
2032
2033 if(!d_pdch_release->v_ts_available)
2034 {
2035 mask = 0x80;
2036 mask >>= slot_i;
2037 mask ^= 0xFF;
2038 TRACE_EVENT_P7("NO TS PDCH REL: slot=%d ->mask=%x ul=%x st_ul=%x dl=%x st_dl=%x c_fn=%ld"
2039 ,slot_i
2040 ,mask
2041 ,grr_data->uplink_tbf.ts_mask
2042 ,grr_data->uplink_tbf.ts_usage
2043 ,grr_data->downlink_tbf.ts_mask
2044 ,grr_data->downlink_tbf.ts_usage
2045 , grr_data->ul_fn);
2046 }
2047 else
2048 {
2049 mask = d_pdch_release->ts_available;
2050 TRACE_EVENT_P7("ts PDCH REL: mask=%x ul=%x st_ul=%x dl=%x st_dl=%x c_fn=%ld"
2051 ,slot_i
2052 ,mask
2053 ,grr_data->uplink_tbf.ts_mask
2054 ,grr_data->uplink_tbf.ts_usage
2055 ,grr_data->downlink_tbf.ts_mask
2056 ,grr_data->downlink_tbf.ts_usage
2057 , grr_data->ul_fn);
2058 }
2059 grr_data->pdch_rel_ts_mask = mask;
2060
2061 switch(grr_data->tbf_type)
2062 {
2063 case CGRLC_TBF_MODE_UL:
2064 help = grr_data->uplink_tbf.ts_mask;
2065 grr_data->uplink_tbf.ts_mask &= mask;
2066 if(!grr_data->uplink_tbf.ts_mask)
2067 {
2068 result = E_PDCH_REL_RELEASE_UL;
2069 }
2070 else if(grr_data->uplink_tbf.ts_mask NEQ help)
2071 {
2072 grr_data->uplink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->uplink_tbf.ts_mask);
2073 result = E_PDCH_REL_RECONF;
2074 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_UL,CGRLC_PRIM_STATUS_NULL);
2075 }
2076 else
2077 {
2078 TRACE_EVENT("NO change in pdch rel for ul tbf");
2079 result = E_PDCH_REL_NULL;
2080 }
2081 break;
2082 case CGRLC_TBF_MODE_DL:
2083 help = grr_data->downlink_tbf.ts_mask;
2084 grr_data->downlink_tbf.ts_mask &= mask;
2085 if(!grr_data->downlink_tbf.ts_mask)
2086 {
2087 result = E_PDCH_REL_RELEASE_DL;
2088 }
2089 else if(grr_data->downlink_tbf.ts_mask NEQ help)
2090 {
2091 grr_data->downlink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->downlink_tbf.ts_mask);
2092 tc_cgrlc_dl_tbf_req();
2093 result = E_PDCH_REL_RECONF;
2094 }
2095 else
2096 {
2097 TRACE_EVENT("NO change in pdch rel for dl tbf");
2098 result = E_PDCH_REL_IGNORE;
2099 }
2100 break;
2101 case CGRLC_TBF_MODE_DL_UL:
2102 help = grr_data->uplink_tbf.ts_mask;
2103 help2 = grr_data->downlink_tbf.ts_mask;
2104 grr_data->uplink_tbf.ts_mask &= mask;
2105 grr_data->downlink_tbf.ts_mask &= mask;
2106 if( !handle_ms_cap(UL_DL_ASSIGNMENT))
2107 {
2108 result = E_PDCH_REL_RELEASE_BOTH;
2109 TRACE_EVENT_P3("MS CLASS ERROR in PDCH assignment ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2110 grr_data->uplink_tbf.ts_mask,
2111 grr_data->downlink_tbf.ts_mask,
2112 mask);
2113 }
2114 else if(!grr_data->downlink_tbf.ts_mask AND !grr_data->uplink_tbf.ts_mask)
2115 {
2116 result = E_PDCH_REL_RELEASE_BOTH;
2117 TRACE_EVENT_P3("rel of UL and DL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2118 grr_data->uplink_tbf.ts_mask,
2119 grr_data->downlink_tbf.ts_mask,
2120 mask);
2121 }
2122 else if(!grr_data->downlink_tbf.ts_mask)
2123 { /*DL release*/
2124 if(grr_data->uplink_tbf.ts_mask EQ help)
2125 { /* no change for uplink*/
2126 result = E_PDCH_REL_RELEASE_DL;
2127 TRACE_EVENT_P3("rel of DL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2128 grr_data->uplink_tbf.ts_mask,
2129 grr_data->downlink_tbf.ts_mask,
2130 mask);
2131 }
2132 else
2133 { /*uplink reconfigure*/
2134 result = E_PDCH_REL_RELEASE_DL_RECONF_UL;
2135 grr_data->uplink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->uplink_tbf.ts_mask);
2136 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_UL,CGRLC_PRIM_STATUS_NULL);
2137 TRACE_EVENT_P3("rel of DL, conf UL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2138 grr_data->uplink_tbf.ts_mask,
2139 grr_data->downlink_tbf.ts_mask,
2140 mask);
2141 }
2142 }
2143 else if(!grr_data->uplink_tbf.ts_mask)
2144 { /*UL release*/
2145 if(grr_data->downlink_tbf.ts_mask EQ help2)
2146 { /* no change for downlink*/
2147 result = E_PDCH_REL_RELEASE_UL;
2148 TRACE_EVENT_P3("rel of UL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2149 grr_data->uplink_tbf.ts_mask,
2150 grr_data->downlink_tbf.ts_mask,
2151 mask);
2152 }
2153 else
2154 { /*downlink reconfigure*/
2155 result = E_PDCH_REL_RELEASE_UL_RECONF_DL;
2156 grr_data->downlink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->downlink_tbf.ts_mask);
2157 tc_cgrlc_dl_tbf_req();
2158 TRACE_EVENT_P3("rel of UL, conf DL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2159 grr_data->uplink_tbf.ts_mask,
2160 grr_data->downlink_tbf.ts_mask,
2161 mask);
2162 }
2163 }
2164 else if(grr_data->downlink_tbf.ts_mask NEQ help2)
2165 { /*change in DL*/
2166 result = E_PDCH_REL_RECONF;
2167 grr_data->downlink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->downlink_tbf.ts_mask);
2168 tc_cgrlc_dl_tbf_req();
2169 if(grr_data->uplink_tbf.ts_mask EQ help)
2170 { /* no change for uplink*/
2171 TRACE_EVENT_P3("conf of DL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2172 grr_data->uplink_tbf.ts_mask,
2173 grr_data->downlink_tbf.ts_mask,
2174 mask);
2175 }
2176 else
2177 { /*uplink reconfigure*/
2178 grr_data->uplink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->uplink_tbf.ts_mask);
2179 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_UL,CGRLC_PRIM_STATUS_NULL);
2180 TRACE_EVENT_P3("conf ofDL/UL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2181 grr_data->uplink_tbf.ts_mask,
2182 grr_data->downlink_tbf.ts_mask,
2183 mask);
2184 }
2185 }
2186 else
2187 { /* no change in DL*/
2188 if(grr_data->uplink_tbf.ts_mask EQ help)
2189 { /* no change for uplink*/
2190 result = E_PDCH_REL_IGNORE;
2191 TRACE_EVENT_P3("NO conf UL/DL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2192 grr_data->uplink_tbf.ts_mask,
2193 grr_data->downlink_tbf.ts_mask,
2194 mask);
2195 }
2196 else
2197 { /*uplink reconfigure*/
2198 result = E_PDCH_REL_RECONF;
2199 grr_data->uplink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->uplink_tbf.ts_mask);
2200 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_UL,CGRLC_PRIM_STATUS_NULL);
2201 TRACE_EVENT_P3("conf of UL ul_mask=%x, dl_mask=%x, pdch_mask=%x",
2202 grr_data->uplink_tbf.ts_mask,
2203 grr_data->downlink_tbf.ts_mask,
2204 mask);
2205 }
2206 }
2207 break;
2208 default:
2209 TRACE_ERROR("unknown tbf type in tc_eval_pdch_rel");
2210 break;
2211 }
2212 return(result);
2213
2214 } /* tc_eval_pdch_rel() */
2215
2216
2217
2218 /*
2219 +------------------------------------------------------------------------------
2220 | Function : tc_eval_ul_assign
2221 +------------------------------------------------------------------------------
2222 | Description : The function tc_eval_ul_assign() evaluates a
2223 | Packet Uplink Assignment.
2224 |
2225 | Parameters : void
2226 |
2227 +------------------------------------------------------------------------------
2228 */
2229 GLOBAL T_EVAL_UL_ASSIGN tc_eval_ul_assign ( void )
2230 {
2231 MCAST(d_ul_assign,D_UL_ASSIGN); /* T_D_UL_ASSIGN */
2232 T_EVAL_UL_ASSIGN result = E_UL_ASSIGN_NULL;
2233 UBYTE tx_slots = 0;
2234 UBYTE i,mask;
2235
2236 T_GRR_STORE_TYPE grr_store_type = GRR_STORE_TYPE_NONE;
2237
2238 TRACE_FUNCTION( "tc_eval_ul_assign" );
2239
2240 #ifdef REL99
2241 if(d_ul_assign->egprs_flag)
2242 {
2243
2244 TRACE_ERROR("EGPRS TBF received in UL ASSIGNMENT");
2245
2246 if(grr_data->tbf_type EQ CGRLC_TBF_MODE_NULL)
2247 {
2248 /* TBF is not active. Handling abnormal case
2249 * 7.1.4 If the mobile station has been assigned a TBF in EGPRS mode and
2250 * the MS does not support EGPRS, or has been assigned an MCS (e.g. 8-PSK
2251 * in the Uplink) that the MS does not support, the MS shall return to packet
2252 * idle mode and notify higher layers (TBF establishment failure)
2253 */
2254 return E_UL_ASSIGN_ERROR_RA;
2255 }
2256 else
2257 {
2258 /* TBF is active. Handling abnormal case
2259 * 8.7 While a TBF is in progress, if a mobile station receives a
2260 * PACKET UPLINK ASSIGNMENT, PACKET UPLINK ACK/NACK or PACKET TIMESLOT RECONFIGURE
2261 * message with message escape bit indicating EGPRS (resp. GPRS) contents whereas
2262 * the current TBF mode is GPRS (resp. EGPRS), the mobile station shall ignore the
2263 * message.
2264 */
2265 return E_UL_ASSIGN_IGNORE;
2266 }
2267 }
2268 #endif
2269
2270 /*
2271 * Handle mac mode
2272 */
2273 switch( grr_data->tbf_type )
2274 {
2275 case CGRLC_TBF_MODE_DL:
2276 grr_data->uplink_tbf.ti = 0; /* contention resolution NOT required */
2277
2278 /*lint -fallthrough*/
2279
2280 case CGRLC_TBF_MODE_NULL:
2281 if(d_ul_assign->v_dyn_alloc_p)
2282 {
2283 if(!d_ul_assign->dyn_alloc_p.xdyn_alloc)
2284 grr_data->uplink_tbf.mac_mode = DA;
2285 else
2286 {
2287 grr_data->uplink_tbf.mac_mode = EDA;
2288 }
2289 }
2290 else if(d_ul_assign->v_f_alloc_ul)
2291 grr_data->uplink_tbf.mac_mode = FA;
2292 break;
2293 case CGRLC_TBF_MODE_UL:
2294 if( grr_data->uplink_tbf.mac_mode NEQ DA AND
2295 d_ul_assign->v_dyn_alloc_p
2296 )
2297 {
2298 TRACE_ERROR("dynamic alloc received while fixed is running in uplink");
2299 return E_UL_ASSIGN_ERROR_RA;
2300 }
2301 else if( grr_data->uplink_tbf.mac_mode NEQ FA AND
2302 d_ul_assign->v_f_alloc_ul
2303 )
2304 {
2305 TRACE_ERROR("fixed alloc received while dynamic is running in uplink");
2306 return E_UL_ASSIGN_ERROR_RA;
2307 }
2308 break;
2309 default:
2310 break;
2311 }
2312 grr_data->uplink_tbf.cs_mode = d_ul_assign->chan_coding_cmd;
2313 grr_data->uplink_tbf.tlli_cs_mode = d_ul_assign->tlli_chan_coding;
2314 grr_data->uplink_tbf.polling_bit = 0xFF;
2315
2316 if(d_ul_assign->v_dyn_alloc_p)
2317 {
2318 if( grr_data->uplink_tbf.mac_mode NEQ DA)
2319 {
2320 result = E_UL_ASSIGN_ERROR_RA;
2321 TRACE_ERROR("dyn alloc received but diff mac mode");
2322 TRACE_EVENT_P3("MAC_MODE: ms=%d, Ex.DA=%d tbf_mode=%d"
2323 ,grr_data->uplink_tbf.mac_mode
2324 ,d_ul_assign->dyn_alloc_p.xdyn_alloc
2325 ,grr_data->tbf_type);
2326 }
2327 else
2328 {
2329 result = E_UL_ASSIGN_DYNAMIC;
2330 /* SZML-TC/071*/
2331
2332 if (d_ul_assign->dyn_alloc_p.v_rlc_db_granted)/* close-ended TBF*/
2333 {
2334 UBYTE data_size=20;
2335
2336 switch( grr_data->uplink_tbf.cs_mode)
2337 {
2338 case CGRLC_CS_MODE_1:
2339 data_size = 20;
2340 break;
2341 case CGRLC_CS_MODE_2:
2342 data_size = 30;
2343 break;
2344 case CGRLC_CS_MODE_3:
2345 data_size = 36;
2346 break;
2347 case CGRLC_CS_MODE_4:
2348 data_size = 50;
2349 break;
2350 default:
2351 TRACE_ERROR("unknown Coding Scheme");
2352 break;
2353 }
2354 data_size -= grr_data->uplink_tbf.ti*4; /* CR TLLI */
2355
2356 grr_data->uplink_tbf.rlc_db_granted = (d_ul_assign->dyn_alloc_p.rlc_db_granted + 9);
2357
2358 if (grr_data->uplink_tbf.rlc_db_granted * data_size < grr_data->uplink_tbf.rlc_oct_cnt)
2359 /* granted rlc blocks in bytes are not enough to transmit the first pdu*/
2360 {
2361 result = E_UL_ASSIGN_ERROR_RA;
2362 TRACE_EVENT_P3("granted rlc blocks are not enough to transmit the first pdu rlc_g=%ld sdu_len =%ld data_size=%d"
2363 ,grr_data->uplink_tbf.rlc_db_granted * data_size
2364 ,grr_data->uplink_tbf.rlc_oct_cnt
2365 ,data_size);
2366 return(result);
2367 }
2368 }
2369 else
2370 {
2371 /*
2372 * open ended TBF
2373 */
2374 grr_data->uplink_tbf.rlc_db_granted = 0;
2375 }
2376
2377 grr_data->uplink_tbf.ts_usage = 0;
2378
2379 if(d_ul_assign->dyn_alloc_p.v_tn_alloc)
2380 {
2381 for(i = 0,mask = 0x80;i < 8;i++)
2382 {
2383 if(d_ul_assign->dyn_alloc_p.tn_alloc[i].v_usf)
2384 {
2385 grr_data->uplink_tbf.ts_usage |= mask;
2386 tx_slots++;
2387 }
2388 mask >>= 1;
2389 }
2390 }
2391 else if(d_ul_assign->dyn_alloc_p.v_tn_alloc_pwr)
2392 {
2393 for(i = 0,mask = 0x80;i < 8;i++)
2394 {
2395 if(d_ul_assign->dyn_alloc_p.tn_alloc_pwr.usf_array[i].v_usf_g)
2396 {
2397
2398 grr_data->uplink_tbf.ts_usage |= mask;
2399 tx_slots++;
2400 }
2401 mask >>= 1;
2402 }
2403
2404 grr_store_type = GRR_STORE_TYPE_TN_ALLOC_PWR;
2405 }
2406 grr_data->uplink_tbf.nts = tx_slots;
2407 }
2408 }
2409 else if(d_ul_assign->v_sin_alloc)
2410 {
2411 if( grr_data->tc.v_sb_without_tbf )
2412 {
2413 result = E_UL_ASSIGN_SB_WITHOUT_TBF;
2414 }
2415 else
2416 {
2417 result = E_UL_ASSIGN_SB_2PHASE_ACCESS ;
2418 grr_data->uplink_tbf.ti = 0;
2419 }
2420
2421 /*
2422 * estimate timeslot
2423 */
2424 grr_data->uplink_tbf.ts_usage = (0x80 >> d_ul_assign->sin_alloc.tn);
2425 tx_slots=1;
2426 grr_data->uplink_tbf.nts = tx_slots;
2427
2428 if(d_ul_assign->sin_alloc.v_alf_gam)
2429 {
2430 grr_store_type = GRR_STORE_TYPE_ALF_GAM;
2431 }
2432
2433 /* starting time allready elapsed? */
2434 if(d_ul_assign->sin_alloc.tbf_s_time.v_abs)
2435 {
2436 ULONG fn_out;
2437 fn_out = grr_decode_tbf_start_abs(&d_ul_assign->sin_alloc.tbf_s_time.abs);
2438 TRACE_EVENT_P5("eval_ul fn_out:%ld fn_in:%d %d %d data->fn:%ld",
2439 fn_out,
2440 d_ul_assign->sin_alloc.tbf_s_time.abs.t1,
2441 d_ul_assign->sin_alloc.tbf_s_time.abs.t2,
2442 d_ul_assign->sin_alloc.tbf_s_time.abs.t3,
2443 grr_data->dl_fn);
2444 if(grr_check_if_tbf_start_is_elapsed ( fn_out, grr_data->ul_fn))
2445 {
2446 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
2447 TRACE_EVENT_P2("CPAP SBR TBF ST ELAPSED st=%ld c_fn=%ld ", fn_out,grr_data->ul_fn);
2448 result = E_UL_ASSIGN_ERROR_RA;
2449 }
2450 }
2451 else if(d_ul_assign->sin_alloc.tbf_s_time.v_rel AND !d_ul_assign->sin_alloc.tbf_s_time.rel)
2452 {
2453 TRACE_ERROR("rel. TBF Starting time in single block allocation k=0 NOT ALLOWED");
2454 TRACE_EVENT_P1("k=%d ", d_ul_assign->sin_alloc.tbf_s_time.rel);
2455 result = E_UL_ASSIGN_ERROR_RA;
2456 }
2457 else if(!d_ul_assign->sin_alloc.tbf_s_time.v_rel)
2458 {
2459 TRACE_ERROR("NO TBF Starting time in single block allocation ");
2460 TRACE_EVENT_P2("v_abs=%d v_rel=%d ", d_ul_assign->sin_alloc.tbf_s_time.v_abs
2461 , d_ul_assign->sin_alloc.tbf_s_time.v_rel);
2462 result = E_UL_ASSIGN_ERROR_RA;
2463 }
2464 }
2465 else if(d_ul_assign->v_f_alloc_ul)
2466 {
2467 if( grr_data->uplink_tbf.mac_mode EQ DA )
2468 {
2469 result = E_UL_ASSIGN_ERROR_RA;
2470 TRACE_ERROR("fixed alloc received while dynamic is running in uplink");
2471 }
2472 else
2473 {
2474 result = E_UL_ASSIGN_FIXED;
2475 grr_data->uplink_tbf.ts_usage = 0;
2476 tx_slots=0;
2477 if(d_ul_assign->f_alloc_ul.v_ts_alloc)
2478 {
2479 grr_data->uplink_tbf.ts_usage = d_ul_assign->f_alloc_ul.ts_alloc;
2480 /*calculate number of timeslots*/
2481 tx_slots = grr_calc_nr_of_set_bits(grr_data->uplink_tbf.ts_usage);
2482 }
2483 else if(d_ul_assign->f_alloc_ul.v_pwr_par)
2484 {
2485 for(i = 0,mask = 0x80;i < 8;i++)
2486 {
2487 if(d_ul_assign->f_alloc_ul.pwr_par.gamma_tn[i].v_gamma)
2488 {
2489 grr_data->uplink_tbf.ts_usage |= mask;
2490 tx_slots++;
2491 }
2492 mask >>= 1;
2493 }
2494
2495 grr_store_type = GRR_STORE_TYPE_PWR_PAR;
2496 }
2497 grr_data->uplink_tbf.nts = tx_slots;
2498 }
2499 }
2500 else
2501 {
2502 TRACE_ERROR ("Packet Uplink Assignment without allocation type - corrupt airmessage!");
2503 }
2504
2505 if( !handle_ms_cap(UL_ASSIGNMENT) )
2506 {
2507 result = E_UL_ASSIGN_ERROR_RA;
2508 TRACE_EVENT("tc_eval_.. will return E_UL_ASSIGN_ERROR_RA (tx_slots wrong)");
2509 }
2510
2511 if ( !tc_check_and_save_freq ())
2512 {
2513 if ((grr_data->tbf_type EQ CGRLC_TBF_MODE_DL) OR (grr_data->tbf_type EQ CGRLC_TBF_MODE_DL_UL) )
2514 {
2515 result = E_UL_ASSIGN_IGNORE;
2516 TRACE_EVENT("tc_eval_.. will return E_UL_ASSIGN_IGNORE , DL ACTIVE (frequencies wrong)");
2517 }
2518 else
2519 {
2520 result = E_UL_ASSIGN_ERROR_RA;
2521 TRACE_EVENT("tc_eval_.. will return E_UL_ASSIGN_ERROR_RA (frequencies wrong)");
2522 }
2523 return result;
2524 }
2525
2526 if( result NEQ E_UL_ASSIGN_ERROR_RA AND
2527 result NEQ E_UL_ASSIGN_NULL )
2528 {
2529 switch( grr_store_type )
2530 {
2531 case GRR_STORE_TYPE_TN_ALLOC_PWR:
2532 grr_store_type_tn_alloc_pwr( &d_ul_assign->dyn_alloc_p.tn_alloc_pwr );
2533 break;
2534
2535 case GRR_STORE_TYPE_ALF_GAM:
2536 grr_store_type_alf_gam( &d_ul_assign->sin_alloc.alf_gam,
2537 d_ul_assign->sin_alloc.tn );
2538 break;
2539
2540 case GRR_STORE_TYPE_PWR_PAR:
2541 grr_store_type_pwr_par( &d_ul_assign->f_alloc_ul.pwr_par, FALSE );
2542 break;
2543
2544 default:
2545 /* do nothing */
2546 break;
2547 }
2548 }
2549
2550 return(result);
2551 } /* tc_eval_ul_assign() */
2552
2553
2554
2555 /*
2556 +------------------------------------------------------------------------------
2557 | Function : tc_eval_dl_assign
2558 +------------------------------------------------------------------------------
2559 | Description : The function tc_eval_dl_assign() evaluates a
2560 | Packet Downlink Assignment.
2561 |
2562 | Parameters : void
2563 |
2564 +------------------------------------------------------------------------------
2565 */
2566 GLOBAL T_EVAL_DL_ASSIGN tc_eval_dl_assign ()
2567 {
2568 MCAST(d_dl_assign,D_DL_ASSIGN); /* T_D_DL_ASSIGN */
2569 T_EVAL_DL_ASSIGN result = E_DL_ASSIGN_IGNORE;
2570
2571 TRACE_FUNCTION( "tc_eval_dl_assign" );
2572
2573 /* SZML-TC/072: check for things that results in E_DL_ASSIGN_ERROR_RA */
2574
2575
2576
2577 grr_data->downlink_tbf.ctrl_ack_bit= 0;
2578
2579 /*
2580 * compare uplink and new assigned downlink mac mode
2581 * and set downlink mac mode
2582 */
2583 switch( grr_data->tbf_type )
2584 {
2585 case CGRLC_TBF_MODE_NULL:
2586 grr_data->downlink_tbf.mac_mode = d_dl_assign->mac_mode;
2587 grr_data->downlink_tbf.t3192 = FALSE; /* indicates if t3192 is running*/
2588 grr_data->downlink_tbf.rlc_mode = d_dl_assign->rlc_mode;
2589
2590 result = E_DL_ASSIGN;
2591 break;
2592 case CGRLC_TBF_MODE_UL:
2593 grr_data->downlink_tbf.mac_mode = d_dl_assign->mac_mode;
2594 grr_data->downlink_tbf.t3192 = FALSE; /* indicates if t3192 is running*/
2595 grr_data->downlink_tbf.rlc_mode = d_dl_assign->rlc_mode;
2596
2597 /*lint -fallthrough*/
2598 case CGRLC_TBF_MODE_DL_UL:
2599 if(d_dl_assign->mac_mode NEQ grr_data->uplink_tbf.mac_mode)
2600 {
2601 result = E_DL_ASSIGN_IGNORE;
2602 TRACE_EVENT_P2("Ignore DL_ASS, Diff MAC Mode UL=%d DL=%d ",grr_data->uplink_tbf.mac_mode,d_dl_assign->mac_mode);
2603 return result;
2604 }
2605 if ((grr_data->downlink_tbf.rlc_mode NEQ d_dl_assign->rlc_mode) AND !d_dl_assign->ctrl_ack)
2606 {
2607 TRACE_ERROR("Diff rlc mode in downlink ass..aborting tbf");
2608 result = E_DL_ASSIGN_ABORT_DL;
2609 return result;
2610 }
2611 grr_data->downlink_tbf.rlc_mode = d_dl_assign->rlc_mode;
2612 result = E_DL_ASSIGN;
2613 break;
2614 case CGRLC_TBF_MODE_DL:
2615 if ((grr_data->downlink_tbf.rlc_mode NEQ d_dl_assign->rlc_mode) AND !d_dl_assign->ctrl_ack)
2616 {
2617 TRACE_ERROR("Diff rlc mode in downlink ass..aborting tbf");
2618 result = E_DL_ASSIGN_ABORT_DL;
2619 return result;
2620 }
2621 grr_data->downlink_tbf.rlc_mode = d_dl_assign->rlc_mode;
2622 result = E_DL_ASSIGN;
2623 break;
2624 default:
2625 result = E_DL_ASSIGN;
2626 break;
2627 }
2628
2629 /*
2630 * compare old and new mac mode for downlink
2631 */
2632 if ( d_dl_assign->mac_mode EQ FA_HALF_DUPLEX)
2633 {
2634 result = E_DL_ASSIGN_IGNORE;
2635 TRACE_EVENT( "DL ASS: Half duplex not supported" );
2636 return result;
2637 }
2638 else if(d_dl_assign->mac_mode NEQ grr_data->downlink_tbf.mac_mode)
2639 {
2640 result = E_DL_ASSIGN_IGNORE;
2641 TRACE_EVENT_P3( "DL ASS: current mac mode= %d differs from commanded =%d tbf_type=%d"
2642 ,grr_data->downlink_tbf.mac_mode
2643 ,d_dl_assign->mac_mode
2644 ,grr_data->tbf_type );
2645 return result;
2646 }
2647
2648
2649 /*
2650 * ckeck if tfi is present while no downlink tbf is active
2651 */
2652 switch( grr_data->tbf_type )
2653 {
2654 case CGRLC_TBF_MODE_UL:
2655 case CGRLC_TBF_MODE_NULL:
2656 if(!d_dl_assign->pda_trnc_grp.v_dl_tfi_assign)
2657 {
2658 result = E_DL_ASSIGN_IGNORE;
2659 TRACE_EVENT("Ignore DL_ASS, no dl_tfi in P DL Ass(no dl tbf active) ");
2660 return result;
2661 }
2662 result = E_DL_ASSIGN;
2663 break;
2664 default:
2665 result = E_DL_ASSIGN;
2666 break;
2667 }
2668
2669
2670 if(d_dl_assign->ctrl_ack)
2671 {
2672 if(grr_data->downlink_tbf.t3192)
2673 {
2674 grr_data->downlink_tbf.ctrl_ack_bit= 1;
2675 grr_data->downlink_tbf.t3192 = FALSE; /* indicates if t3192 is running*/
2676
2677 }
2678 else
2679 {
2680 result = E_DL_ASSIGN_IGNORE;
2681 TRACE_EVENT("DL ASS IGNORED, ctrl ack bit set but t3192 is not running");
2682 return result;
2683 }
2684 }
2685 else if(grr_data->downlink_tbf.t3192)
2686 {
2687 TRACE_EVENT("DL assignment:ctrl ack bit is not set but t3192 is running");
2688 }
2689
2690 grr_data->downlink_tbf.ts_usage = d_dl_assign->ts_alloc;
2691 grr_data->downlink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->downlink_tbf.ts_usage);
2692 if( !handle_ms_cap(DL_ASSIGNMENT))
2693 {
2694 result = E_DL_ASSIGN_ERROR_RA;
2695 TRACE_EVENT("tc_eval_.. will return E_DL_ASSIGN_ERROR_RA (ms class error)");
2696 return result;
2697 }
2698
2699 if( tc_check_and_save_freq( ) EQ FALSE )
2700 {
2701 if ((grr_data->tbf_type EQ CGRLC_TBF_MODE_UL) OR (grr_data->tbf_type EQ CGRLC_TBF_MODE_DL_UL))
2702 {
2703 result = E_DL_ASSIGN_IGNORE;
2704 TRACE_EVENT("tc_eval_.. will return E_DL_ASSIGN_IGNORE , UL ACTIVE (frequencies wrong)");
2705 }
2706 else
2707 {
2708 result = E_DL_ASSIGN_ERROR_RA;
2709 TRACE_EVENT("tc_eval_.. will return E_DL_ASSIGN_ERROR_RA (frequencies wrong)");
2710 }
2711 return result;
2712 }
2713
2714 if( d_dl_assign->pda_trnc_grp.v_pwr_par EQ TRUE )
2715 {
2716 grr_store_type_pwr_par( &d_dl_assign->pda_trnc_grp.pwr_par, FALSE );
2717 }
2718
2719 return(result);
2720 } /* tc_eval_dl_assign() */
2721
2722
2723
2724 /*
2725 +------------------------------------------------------------------------------
2726 | Function : tc_eval_access_rej
2727 +------------------------------------------------------------------------------
2728 | Description : The function tc_eval_access_rej() evaluates a
2729 | Packet Access Reject.
2730 |
2731 | Parameters : void
2732 |
2733 +------------------------------------------------------------------------------
2734 */
2735 GLOBAL T_EVAL_ACCESS_REJ tc_eval_access_rej ( ULONG * t3172_value_i)
2736 {
2737 MCAST(d_access_rej,D_ACCESS_REJ);
2738 T_EVAL_ACCESS_REJ result = E_ACCESS_REJ_NULL;
2739
2740 TRACE_FUNCTION( "tc_eval_access_rej" );
2741 /*SZML-TC/122*/
2742
2743 if(d_access_rej->reject.v_wait)
2744 {
2745 result = E_ACCESS_REJ_WAIT;
2746
2747 *t3172_value_i = d_access_rej->reject.wait.wait_ind;
2748 if( d_access_rej->reject.wait.waitsize )
2749 {
2750 *t3172_value_i *= 20;
2751 }
2752 else
2753 {
2754 *t3172_value_i *= 1000;
2755 }
2756 }
2757 else
2758 {
2759 result = E_ACCESS_REJ_NO_WAIT;
2760 }
2761
2762 return(result);
2763
2764 } /* tc_eval_access_rej() */
2765
2766
2767
2768 /*
2769 +------------------------------------------------------------------------------
2770 | Function : tc_send_ra_req
2771 +------------------------------------------------------------------------------
2772 | Description : The function tc_send_ra_req() starts the build-process for a
2773 | Packet Access Request and send a MPHP_RA_REQ.
2774 |
2775 | Parameters : void
2776 |
2777 +------------------------------------------------------------------------------
2778 */
2779 GLOBAL void tc_send_ra_req ( void )
2780 {
2781 TRACE_FUNCTION( "tc_send_ra_req" );
2782
2783
2784 while( (grr_data->tc.n_acc_req <
2785 max_retrans_table[psc_db->prach.max_retrans[grr_data->uplink_tbf.prio]]+1)
2786 AND (tc_check_p_level() EQ C_P_LEVEL_DO_NOT_SEND) )
2787 {
2788 TRACE_EVENT("C_P_LEVEL_DO_NOT_SEND");
2789 grr_data->tc.n_acc_req++;
2790 }
2791
2792
2793 if (grr_data->tc.n_acc_req <
2794 max_retrans_table[psc_db->prach.max_retrans[grr_data->uplink_tbf.prio]]+1)
2795 {
2796 PALLOC(mphp_ra_req,MPHP_RA_REQ);
2797 memset(mphp_ra_req,0x00,sizeof(T_MPHP_RA_REQ));
2798 /*
2799 * The powervalue txpwr_max_cch in DB is always a useful value.
2800 * The value is set by PSI. First a useful initial value.
2801 * After that a value from RR and after reception of PSI3 txpwr_max_cch
2802 * is set to a value from the scell-structure.
2803 */
2804
2805 mphp_ra_req->txpwr =
2806 grr_get_ms_txpwr_max_cch
2807 ( psc_db->pbcch.bcch.arfcn,
2808 grr_data->meas.pwr_offset,
2809 psc_db->scell_par.cr_par_1.cr_pow_par.gprs_ms_txpwr_max_cch );
2810
2811 if(grr_data->tc.sending_req EQ TRUE)
2812 {
2813 mphp_ra_req->rand = (USHORT)tc_gen_rand();
2814 }
2815 else
2816 {
2817 /* The first PCR may be sent immediately when ready. Only the second PCR */
2818 /* needs a random value which has to have uniform probability distribution */
2819 mphp_ra_req->rand = 1;
2820 }
2821 mphp_ra_req->channel_request_data = tc_calc_req();
2822 mphp_ra_req->bs_prach_blks = psc_db->pccch.bs_prach_blks;
2823 mphp_ra_req->burst_type = psc_db->gprs_cell_opt.ab_type;
2824
2825 {
2826 UBYTE channel_request_data[RLC_MAC_MAX_LEN_CHANNEL_REQ];
2827
2828 channel_request_data[0] = ( mphp_ra_req->channel_request_data >> 8 );
2829 channel_request_data[1] = ( UBYTE )mphp_ra_req->channel_request_data;
2830
2831 TRACE_BINDUMP
2832 ( hCommGRR, TC_USER4,
2833 cl_rlcmac_get_msg_name( U_MSG_TYPE_CHANNEL_REQ_c, RLC_MAC_ROUTE_UL ),
2834 channel_request_data, RLC_MAC_MAX_LEN_CHANNEL_REQ ); /*lint !e569*/
2835 }
2836
2837 PSEND(hCommL1,mphp_ra_req);
2838 grr_data->tc.sending_req = TRUE;
2839 }
2840 else
2841 {
2842 vsi_t_start(GRR_handle,T3170,tc_get_t3170_value());
2843 vsi_t_stop(GRR_handle,T3186);
2844 tc_send_ra_stop_req();
2845
2846 }
2847
2848
2849 } /* tc_send_ra_req() */
2850
2851
2852
2853 /*
2854 +------------------------------------------------------------------------------
2855 | Function : tc_send_ra_stop_req
2856 +------------------------------------------------------------------------------
2857 | Description : The function tc_send_ra_stop_req() stops the
2858 | sending of packet access requests.
2859 |
2860 | Parameters : void
2861 |
2862 +------------------------------------------------------------------------------
2863 */
2864 GLOBAL void tc_send_ra_stop_req ( void )
2865 {
2866 TRACE_FUNCTION( "tc_send_ra_stop_req" );
2867
2868 /*
2869 * This timer might be run - in case of MPHP_RA_CON has not been received by GRR.
2870 * If it does not run the stop-command will be ignored by vsi.
2871 */
2872 vsi_t_stop(GRR_handle,T3186);
2873
2874 if(grr_data->tc.sending_req)
2875 {
2876 PALLOC(mphp_ra_stop_req,MPHP_RA_STOP_REQ);
2877 PSEND(hCommL1,mphp_ra_stop_req);
2878 /*
2879 * reset number of access in this procedure
2880 */
2881 grr_data->tc.n_acc_req =0;
2882
2883 /*
2884 * to make sure that TC only stops
2885 * the sending procedure if it
2886 * is running
2887 */
2888 grr_data->tc.sending_req = FALSE;
2889 }
2890
2891 } /* tc_send_ra_stop_req() */
2892
2893
2894
2895 /*
2896 +------------------------------------------------------------------------------
2897 | Function : tc_send_polling_res
2898 +------------------------------------------------------------------------------
2899 | Description : The function tc_send_polling_res() sends the primitive
2900 | MPHP_POLLING_RESPONSE_REQ.
2901 |
2902 | Parameters : ctrl_ack_type_i - indicates if normal or access burst shall sent
2903 | rrbp_i - depending on this variable the send frame number is computed
2904 | fn_i - frame number where Packet Polling Request was received
2905 | ctrl_ack_i - this value is sent within the pca, depends frim mac header
2906 |
2907 +------------------------------------------------------------------------------
2908 */
2909 GLOBAL void tc_send_polling_res (UBYTE poll_type_i, ULONG fn_i, UBYTE rrbp_i,UBYTE ctrl_ack_i )
2910 {
2911 PALLOC( mphp_polling_response_req, MPHP_POLLING_RESPONSE_REQ );
2912
2913 TRACE_FUNCTION( "tc_send_polling_res" );
2914
2915 mphp_polling_response_req->fn = grr_calc_new_poll_pos( fn_i, rrbp_i );
2916
2917 mphp_polling_response_req->txpwr =
2918 grr_get_ms_txpwr_max_cch
2919 ( psc_db->pbcch.bcch.arfcn,
2920 grr_data->meas.pwr_offset,
2921 psc_db->scell_par.cr_par_1.cr_pow_par.gprs_ms_txpwr_max_cch );
2922
2923 if(poll_type_i EQ CGRLC_POLL_RES_NB)
2924 {
2925 mphp_polling_response_req->poll_resp_type = POLL_RESP_NB_CS1;
2926 memset( mphp_polling_response_req->poll_data,
2927 0x2b,
2928 sizeof(mphp_polling_response_req->poll_data) );
2929 mphp_polling_response_req->poll_data[23] = 0 ; /* Byte is not used, set to 0 for test purposes */
2930
2931 /* code without CCD, air message buffer is used by other service*/
2932 mphp_polling_response_req->poll_data[0] = 0x40 | grr_data->r_bit;
2933 mphp_polling_response_req->poll_data[1] = 0x04 |((UBYTE)(grr_data->db.ms_id.new_tlli>>30));
2934 mphp_polling_response_req->poll_data[2] = ((UBYTE)(grr_data->db.ms_id.new_tlli>>22));
2935 mphp_polling_response_req->poll_data[3] = ((UBYTE)(grr_data->db.ms_id.new_tlli>>14));
2936 mphp_polling_response_req->poll_data[4] = ((UBYTE)(grr_data->db.ms_id.new_tlli>>06));
2937 mphp_polling_response_req->poll_data[5] = ((UBYTE)(grr_data->db.ms_id.new_tlli<<2)) + ctrl_ack_i;
2938
2939 /*
2940 * get TA from paxket uplink/downlink assignment
2941 */
2942 if(grr_data->ta_params.ta_value EQ 0xFF)
2943 {
2944 MCAST( d_ul_assign, D_UL_ASSIGN );
2945 MCAST( d_dl_assign, D_DL_ASSIGN);
2946
2947 if(( d_dl_assign->msg_type EQ D_DL_ASSIGN_c) AND
2948 d_dl_assign->pta.v_ta_value)
2949
2950 {
2951 mphp_polling_response_req->ta_index = d_dl_assign->pta.ta_value;
2952 }
2953 else if(( d_ul_assign->msg_type EQ D_UL_ASSIGN_c) AND
2954 d_ul_assign->pta.v_ta_value)
2955 {
2956 mphp_polling_response_req->ta_index = d_ul_assign->pta.ta_value;
2957 }
2958 else
2959 {
2960 TRACE_ERROR("NO TA IN MPHP_POLLING_REQ");
2961 TRACE_EVENT_P5("msg_typ=%d, v_pta_dl=%d v_pta_ul=%d v_ptai_dl=%d v_ptai_ul=%d"
2962 ,d_ul_assign->msg_type
2963 ,d_dl_assign->pta.v_ta_value
2964 ,d_ul_assign->pta.v_ta_value
2965 ,d_dl_assign->pta.v_ta_index_tn
2966 ,d_ul_assign->pta.v_ta_index_tn);
2967 }
2968
2969 }
2970 else
2971 {
2972 mphp_polling_response_req->ta_index = grr_data->ta_params.ta_value;
2973 TRACE_EVENT_P1("valid ta in database at sending MPHP_POLLING_RES_REQ ta=%d",grr_data->ta_params.ta_value);
2974 }
2975
2976 TRACE_BINDUMP
2977 ( hCommGRR, TC_USER4,
2978 cl_rlcmac_get_msg_name
2979 ( ( UBYTE )( mphp_polling_response_req->poll_data[1] >> 2 ), RLC_MAC_ROUTE_UL ),
2980 mphp_polling_response_req->poll_data, MAX_L2_FRAME_SIZE ); /*lint !e569*/
2981 }
2982 else
2983 {
2984 USHORT data;
2985
2986 /*
2987 * initalize channel request data array
2988 */
2989 memset( mphp_polling_response_req->poll_data,
2990 0,
2991 sizeof(mphp_polling_response_req->poll_data) );
2992
2993 /*
2994 * format is four access bursts
2995 */
2996 if(psc_db->gprs_cell_opt.ab_type EQ AB_8_BIT)
2997 {
2998 /*
2999 * 8 Bit access burst
3000 */
3001 mphp_polling_response_req->poll_resp_type = POLL_RESP_AB_8_BIT;
3002 data =0x0000;
3003 data|=0x7f;
3004 /*TRACE_EVENT_P1("POLL_RESP_8BIT_AB: FN %Ld", mphp_polling_response_req->fn);*/
3005 }
3006 else
3007 {
3008 /*
3009 * 11 Bit access burst
3010 */
3011
3012 mphp_polling_response_req->poll_resp_type = POLL_RESP_AB_11_BIT;
3013 data = (0x07<<8);
3014 data|=0xe7;
3015
3016 data = grr_convert_11bit_2_etsi(data);
3017 /*TRACE_EVENT_P1("POLL_RESP_11BIT_AB: FN %Ld", mphp_polling_response_req->fn);*/
3018 }
3019
3020 mphp_polling_response_req->poll_data[0]= (UBYTE)(data & 0x00ff);
3021 mphp_polling_response_req->poll_data[1]= (UBYTE)((data & 0xff00) >> 8);
3022
3023 TRACE_BINDUMP
3024 ( hCommGRR, TC_USER4,
3025 cl_rlcmac_get_msg_name( U_MSG_TYPE_CHANNEL_REQ_c, RLC_MAC_ROUTE_UL ),
3026 mphp_polling_response_req->poll_data,
3027 RLC_MAC_MAX_LEN_CHANNEL_REQ ); /*lint !e569*/
3028 }
3029
3030 PSEND( hCommL1, mphp_polling_response_req );
3031
3032 } /* tc_send_polling_res() */
3033
3034
3035
3036 /*
3037 +------------------------------------------------------------------------------
3038 | Function : tc_send_single_block
3039 +------------------------------------------------------------------------------
3040 | Description : The function tc_send_single_block() sends the primitive
3041 | MPHP_SINGLE_BLOCK_REQ with measurement report.
3042 |
3043 | Parameters : void
3044 |
3045 +------------------------------------------------------------------------------
3046 */
3047 GLOBAL void tc_send_single_block ( void )
3048 {
3049 MCAST(d_ul_assign,D_UL_ASSIGN);
3050 T_MPHP_SINGLE_BLOCK_REQ * ptr2prim;
3051
3052 TRACE_FUNCTION( "tc_send_single_block" );
3053
3054 ptr2prim = tc_get_send_nb_prim_and_set_freq( );
3055
3056 ptr2prim->assign_id = 0;
3057 ptr2prim->purpose = SINGLE_BLOCK_TRANSFER_UL;
3058 ptr2prim->pc_meas_chan = psc_db->g_pwr_par.pc_meas_chan;
3059 ptr2prim->burst_type = ( psc_db->gprs_cell_opt.ab_type EQ AB_8_BIT )
3060 ? AB_8_BIT : AB_11_BIT;
3061 /* timing advance */
3062 if (d_ul_assign->pta.v_ta_value)
3063 {
3064 ptr2prim->p_timing_advance.ta_value = d_ul_assign->pta.ta_value;
3065 }
3066 else
3067 {
3068 ptr2prim->p_timing_advance.ta_value = 0xff;
3069 }
3070
3071 if(d_ul_assign->pta.v_ta_index_tn)
3072 {
3073 ptr2prim->p_timing_advance.ta_index = d_ul_assign->pta.ta_index_tn.ta_index;
3074 }
3075 else
3076 {
3077 ptr2prim->p_timing_advance.ta_index = 0xff;
3078 }
3079
3080 /* trainings sequence */
3081 ptr2prim->tsc = d_ul_assign->freq_par.tsc;
3082
3083 /* handle TBF starting time (is always present in single block allocation) */
3084 if(d_ul_assign->sin_alloc.tbf_s_time.v_abs)
3085 {
3086 ptr2prim->p_tbf_start.tbf_start_present = 1;
3087 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ul_assign->sin_alloc.tbf_s_time.abs);
3088 if(grr_check_if_tbf_start_is_elapsed ( ptr2prim->p_tbf_start.fn, grr_data->ul_fn))
3089 { /* SZML-TC/077: drop message, enter pim */
3090 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
3091 TRACE_EVENT_P2("CPAP SBR TBF ST ELAPSED st=%ld c_fn=%ld ", ptr2prim->p_tbf_start.fn,grr_data->ul_fn);
3092 }
3093 }
3094 else if (d_ul_assign->sin_alloc.tbf_s_time.v_rel)
3095 {
3096 ptr2prim->p_tbf_start.tbf_start_present = 1;
3097 /*
3098 * For the relative position set d_ul_assign->sin_alloc.tbf_s_time.rel-1, because grr_data->fn is
3099 * received from mphp_data_ind. This fn is the current fn, and not the received fn.
3100 */
3101 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
3102 (USHORT)(d_ul_assign->sin_alloc.tbf_s_time.rel));
3103 }
3104 else
3105 {
3106 TRACE_ERROR("TBF Starting time is missing in single block allocation!");
3107 /* SZML-TC/078: drop message, enter pim ! */
3108 }
3109
3110 /* timeslot number */
3111 ptr2prim->tn=d_ul_assign->sin_alloc.tn;
3112
3113 /* put measurement report into buffer */
3114 tc_cpy_ctrl_blk_to_buffer( ptr2prim->l2_frame );
3115
3116 sig_tc_meas_update_pch( );
3117
3118 TRACE_BINDUMP
3119 ( hCommGRR, TC_USER4,
3120 cl_rlcmac_get_msg_name
3121 ( ( UBYTE )( ptr2prim->l2_frame[1] >> 2 ), RLC_MAC_ROUTE_UL ),
3122 ptr2prim->l2_frame, MAX_L2_FRAME_SIZE ); /*lint !e569*/
3123
3124 PSEND(hCommL1,ptr2prim);
3125 } /* tc_send_single_block() */
3126
3127
3128
3129 /*
3130 +------------------------------------------------------------------------------
3131 | Function : tc_send_resource_request_p
3132 +------------------------------------------------------------------------------
3133 | Description : The function tc_send_resource_request_p() sends the primitive
3134 | MPHP_SINGLE_BLOCK_REQ with Packet Resource Request for
3135 | two phase access due to reception of airmessage packet uplink
3136 | assignment.
3137 |
3138 | Parameters : void
3139 |
3140 +------------------------------------------------------------------------------
3141 */
3142 GLOBAL void tc_send_resource_request_p ( void )
3143 {
3144 MCAST(d_ul_assign,D_UL_ASSIGN);
3145
3146 T_MPHP_SINGLE_BLOCK_REQ * ptr2prim;
3147
3148 TRACE_FUNCTION( "tc_send_resource_request_p" );
3149
3150
3151 ptr2prim = tc_get_send_nb_prim_and_set_freq( );
3152
3153 /*
3154 * mark that single block is because of two phase access procedure
3155 */
3156 ptr2prim->assign_id = 0;
3157 ptr2prim->purpose = TWO_PHASE_ACESS;
3158 ptr2prim->pc_meas_chan = psc_db->g_pwr_par.pc_meas_chan;
3159 ptr2prim->burst_type = (psc_db->gprs_cell_opt.ab_type EQ AB_8_BIT)
3160 ?AB_8_BIT
3161 :AB_11_BIT;
3162
3163 if (d_ul_assign->pta.v_ta_value)
3164 {
3165 ptr2prim->p_timing_advance.ta_value = d_ul_assign->pta.ta_value;
3166 }
3167 else
3168 {
3169 ptr2prim->p_timing_advance.ta_value = 0xff;
3170 }
3171
3172 if(d_ul_assign->pta.v_ta_index_tn)
3173 {
3174 ptr2prim->p_timing_advance.ta_index =d_ul_assign->pta.ta_index_tn.ta_index;
3175 }
3176 else
3177 {
3178 ptr2prim->p_timing_advance.ta_index =0xff;
3179 }
3180
3181 /*
3182 * trainings sequence
3183 */
3184 ptr2prim->tsc = d_ul_assign->freq_par.tsc;
3185
3186
3187 /*
3188 * handle TBF starting time
3189 * is always present in single block allocation
3190 */
3191 if(d_ul_assign->sin_alloc.tbf_s_time.v_abs)
3192 {
3193 ptr2prim->p_tbf_start.tbf_start_present = 1;
3194 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_abs(&d_ul_assign->sin_alloc.tbf_s_time.abs);
3195 if(grr_check_if_tbf_start_is_elapsed ( ptr2prim->p_tbf_start.fn, grr_data->ul_fn))
3196 { /* SZML-TC/079 */
3197 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
3198 TRACE_EVENT_P2("CPAP SBR TBF ST ELAPSED st=%ld c_fn=%ld ", ptr2prim->p_tbf_start.fn,grr_data->ul_fn);
3199 }
3200 TRACE_EVENT_P5("res_req fn_out:%ld fn_in:%d %d %d data->fn:%ld",
3201 ptr2prim->p_tbf_start.fn,
3202 d_ul_assign->sin_alloc.tbf_s_time.abs.t1,
3203 d_ul_assign->sin_alloc.tbf_s_time.abs.t2,
3204 d_ul_assign->sin_alloc.tbf_s_time.abs.t3,
3205 grr_data->dl_fn);
3206 }
3207 else if (d_ul_assign->sin_alloc.tbf_s_time.v_rel)
3208 {
3209 ptr2prim->p_tbf_start.tbf_start_present = 1;
3210 /*
3211 * For the relative position set d_ul_assign->sin_alloc.tbf_s_time.rel-1, because grr_data->fn is
3212 * received from mphp_data_ind. This fn is the current fn, and not the received fn.
3213 */
3214 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_rel(grr_data->dl_fn,
3215 (USHORT)(d_ul_assign->sin_alloc.tbf_s_time.rel));
3216 TRACE_EVENT_P3("REL: ST_TIME for PRR: fn_i=%ld rel=%ld fn_out=%ld"
3217 ,grr_data->dl_fn
3218 ,d_ul_assign->sin_alloc.tbf_s_time.rel
3219 ,ptr2prim->p_tbf_start.fn);
3220 }
3221 else
3222 {
3223 TRACE_ERROR("TBF Starting time is missing in single block allocation!");
3224 }
3225
3226 ptr2prim->tn = d_ul_assign->sin_alloc.tn;
3227
3228 {
3229 T_U_RESOURCE_REQ resource_req;
3230
3231 tc_build_res_req( &resource_req,
3232 R_BUILD_2PHASE_ACCESS,
3233 SRC_TBF_INFO_UL_ASSIGN );
3234
3235 grr_encode_ul_ctrl_block( ptr2prim->l2_frame, ( UBYTE* )&resource_req );
3236 }
3237
3238 sig_tc_meas_update_pch( );
3239
3240 TRACE_BINDUMP
3241 ( hCommGRR, TC_USER4,
3242 cl_rlcmac_get_msg_name
3243 ( ( UBYTE )( ptr2prim->l2_frame[1] >> 2 ), RLC_MAC_ROUTE_UL ),
3244 ptr2prim->l2_frame, MAX_L2_FRAME_SIZE ); /*lint !e569*/
3245
3246 PSEND(hCommL1,ptr2prim);
3247
3248 return;
3249
3250 } /* tc_send_resource_request_p() */
3251
3252
3253 /*
3254 +------------------------------------------------------------------------------
3255 | Function : tc_handle_ra_con
3256 +------------------------------------------------------------------------------
3257 | Description : The function tc_handle_ra_con() checks wheather there is to send
3258 | another Packet Access Request or not.
3259 |
3260 | Parameters : void
3261 +------------------------------------------------------------------------------
3262 */
3263 GLOBAL T_HANDLE_RA_CON tc_handle_ra_con ( void )
3264 {
3265 T_HANDLE_RA_CON result;
3266 UBYTE max_retrans;
3267 TRACE_FUNCTION( "tc_handle_ra_con" );
3268
3269
3270 /*
3271 * stop T3186 becauce packet access request was sent
3272 */
3273
3274
3275 /*
3276 * get current max. retransmissson value
3277 */
3278 max_retrans
3279 = max_retrans_table[psc_db->prach.max_retrans[grr_data->uplink_tbf.prio]];
3280
3281 if(grr_data->tc.n_acc_req >= max_retrans + 1)
3282 {
3283 result = H_RA_CON_STOP_REQ;
3284 vsi_t_start(GRR_handle,T3170,tc_get_t3170_value());
3285 vsi_t_stop(GRR_handle,T3186);
3286 }
3287 else
3288 {
3289 result = H_RA_CON_CONTINUE;
3290 }
3291
3292
3293 return(result);
3294
3295 } /* tc_handle_ra_con() */
3296
3297
3298
3299
3300
3301
3302
3303 /*
3304 +------------------------------------------------------------------------------
3305 | Function : tc_init
3306 +------------------------------------------------------------------------------
3307 | Description : The function tc_init() initialize the TC data structure.
3308 |
3309 | Parameters : void
3310 |
3311 +------------------------------------------------------------------------------
3312 */
3313 GLOBAL void tc_init ( void )
3314 {
3315 UBYTE i;
3316
3317 TRACE_FUNCTION( "tc_init" );
3318
3319 /*
3320 * set some values
3321 */
3322 grr_data->tc.disable_callback_func = NULL;
3323 grr_data->tc.disable_class = CGRLC_DISABLE_CLASS_CR;
3324 grr_data->tbf_type = CGRLC_TBF_MODE_NULL;
3325 grr_data->tc.dcch_present = FALSE;
3326 grr_data->tc.v_freq_set = FALSE;
3327
3328 /*
3329 * values for fixed alloc
3330 */
3331 grr_data->tc.fa_ctrl.fa_type = FA_NO_CURRENT;
3332 grr_data->tc.fa_ctrl.repeat_alloc = FALSE;
3333 grr_data->tc.fa_ctrl.ts_overr = 0;
3334
3335 grr_data->tc.num_of_rels_running = 0;
3336
3337 /* initialize the relevant data for uplink control block */
3338 grr_data->tc.v_sb_without_tbf = FALSE;
3339
3340 grr_data->tc.ul_ctrl_blk.seq[0] = MAX_CTRL_BLK_NUM;
3341
3342 for( i = 0; i < MAX_CTRL_BLK_NUM; i++ )
3343 {
3344 grr_data->tc.ul_ctrl_blk.blk[i].state = BLK_STATE_NONE;
3345 grr_data->tc.ul_ctrl_blk.blk[i].owner = CGRLC_BLK_OWNER_NONE;
3346 }
3347
3348 grr_data->tc.two_2p_w_4_tbf_con = TRUE;
3349
3350
3351 grr_data->tc.two_2p_w_4_tbf_con = TRUE;
3352
3353 /*
3354 * Initialise service name (uses define SERVICE_NAME_* in GRR.H);
3355 */
3356
3357 INIT_STATE(TC,TC_ACCESS_DISABLED);
3358 /*
3359 * initialize primitive queue
3360 */
3361
3362 grr_data->tc.p_assign = NULL;
3363
3364 grr_data->uplink_tbf.ts_mask = 0;
3365 grr_data->uplink_tbf.ts_usage = 0;
3366 grr_data->downlink_tbf.ts_mask = 0;
3367 grr_data->downlink_tbf.ts_usage = 0;
3368 grr_data->tc.n_acc_req = 0;
3369
3370 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3371 grr_data->tc.tbf_est_pacch = FALSE;
3372 #endif
3373
3374 } /* tc_init() */
3375
3376
3377
3378
3379
3380 /*
3381 +------------------------------------------------------------------------------
3382 | Function : tc_handle_error_pim
3383 +------------------------------------------------------------------------------
3384 | Description : The function tc_handle_error_pim() ...
3385 |
3386 | Parameters : void
3387 |
3388 +------------------------------------------------------------------------------
3389 */
3390 GLOBAL void tc_handle_error_pim ( void )
3391 {
3392 TRACE_FUNCTION( "tc_handle_error_pim" );
3393 TRACE_EVENT( "tc_handle_error_pim" );
3394
3395 if( grr_data->tc.v_sb_without_tbf )
3396 {
3397 tc_set_stop_ctrl_blk( FALSE, CGRLC_BLK_OWNER_NONE, 0 );
3398
3399 tc_cgrlc_access_status_req();
3400 }
3401 else
3402 {
3403 tc_cgrlc_ul_tbf_res ( CGRLC_TBF_MODE_ESTABLISHMENT_FAILURE, CGRLC_PRIM_STATUS_ONE );
3404 }
3405
3406 } /* tc_handle_error_pim() */
3407
3408 /*
3409 +------------------------------------------------------------------------------
3410 | Function : tc_handle_error_ra
3411 +------------------------------------------------------------------------------
3412 | Description : The function tc_handle_error_ra() handles actions related
3413 | to errors that leads to randam access procedure
3414 |
3415 | Parameters : void
3416 |
3417 +------------------------------------------------------------------------------
3418 */
3419 GLOBAL void tc_handle_error_ra ( void )
3420 {
3421 TRACE_FUNCTION( "tc_handle_error_ra" );
3422
3423
3424 /*
3425 * - called in case of contention resulution failed in RU
3426 * - t3168 expires contention resulution failed in 2P-Access
3427 * - If the mobile station has been assigned more PDCHs than it supports according
3428 * to its MS multislot class, the mobile station shall reinitiate the packet access
3429 * procedure unless it has already been repeated 4 times. In that
3430 * case, TBF failure has occurred.
3431 */
3432
3433 /*
3434 * cancel access procedure if running
3435 */
3436 if(grr_is_pbcch_present()
3437 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3438 AND !grr_data->tc.tbf_est_pacch
3439 #endif
3440 )
3441 {
3442 tc_send_ra_stop_req();
3443 }
3444
3445 /*
3446 * Kill TBF if running
3447 */
3448 tc_abort_tbf(grr_data->tbf_type);
3449
3450 SET_STATE(TC,TC_PIM);
3451
3452
3453
3454 } /* tc_handle_error_ra() */
3455
3456 /*
3457 +------------------------------------------------------------------------------
3458 | Function : tc_activate_tbf
3459 +------------------------------------------------------------------------------
3460 | Description : The function tc_activate_tbf() set the assigned TBF
3461 | into the data structures
3462 |
3463 | Parameters : tbf_type_i - type of TBF to deactivate
3464 |
3465 +------------------------------------------------------------------------------
3466 */
3467 GLOBAL void tc_activate_tbf ( T_TBF_TYPE tbf_type_i )
3468 {
3469 TRACE_FUNCTION( "tc_activate_tbf" );
3470
3471 /*
3472 * Reset of n_acc_req_procedures because of the fact that number of
3473 * access procedures during pacet access procedures must not considered in
3474 * a error with random access occured during running TBF.
3475 */
3476 /* grr_data->tc.n_acc_req_procedures = 0;*/
3477
3478 switch( tbf_type_i )
3479 {
3480
3481 case CGRLC_TBF_MODE_UL:
3482 switch( grr_data->tbf_type )
3483 {
3484 case CGRLC_TBF_MODE_DL:
3485 grr_data->tbf_type = CGRLC_TBF_MODE_DL_UL;
3486 break;
3487 case CGRLC_TBF_MODE_NULL:
3488 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3489 case CGRLC_TBF_MODE_2PA:
3490 #endif
3491 grr_data->tbf_type = CGRLC_TBF_MODE_UL;
3492 break;
3493 default:
3494 break;
3495 }
3496 break;
3497
3498 case CGRLC_TBF_MODE_DL:
3499 switch( grr_data->tbf_type )
3500 {
3501 case CGRLC_TBF_MODE_UL:
3502 grr_data->tbf_type = CGRLC_TBF_MODE_DL_UL;
3503 break;
3504 case CGRLC_TBF_MODE_NULL:
3505 grr_data->tbf_type = CGRLC_TBF_MODE_DL;
3506 break;
3507 default:
3508 break;
3509 }
3510 break;
3511 case CGRLC_TBF_MODE_DL_UL:
3512 switch( grr_data->tbf_type )
3513 {
3514 case CGRLC_TBF_MODE_UL:
3515 case CGRLC_TBF_MODE_DL:
3516 case CGRLC_TBF_MODE_DL_UL:
3517 grr_data->tbf_type = CGRLC_TBF_MODE_DL_UL;
3518 break;
3519 default:
3520 {
3521 TRACE_ERROR("FATAL ERROR: tc_activate_tbf called with wrong tbf_type");
3522 }
3523 break;
3524 }
3525 break;
3526 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3527 case CGRLC_TBF_MODE_2PA:
3528 switch( grr_data->tbf_type )
3529 {
3530 case CGRLC_TBF_MODE_UL:
3531 if (grr_data->tc.tbf_est_pacch)
3532 {
3533 grr_data->tbf_type = CGRLC_TBF_MODE_2PA;
3534 }
3535 else
3536 {
3537 TRACE_ERROR("FATAL ERROR: tc_activate_tbf called with wrong tbf_type");
3538 }
3539 break;
3540
3541 default:
3542 TRACE_ERROR("FATAL ERROR: tc_activate_tbf called with wrong tbf_type:CGRLC_TBF_MODE_2PA");
3543 break;
3544 }
3545 break;
3546 #endif
3547 default:
3548 {
3549 TRACE_ERROR("FATAL ERROR: tc_activate_tbf called with wrong tbf_type");
3550 }
3551 break;
3552 } /* switch (tbf_type_i) */
3553
3554
3555 } /* tc_activate_tbf() */
3556
3557
3558 /*
3559 +------------------------------------------------------------------------------
3560 | Function : tc_deactivate_tbf
3561 +------------------------------------------------------------------------------
3562 | Description : The function tc_deactivate_tbf() removes a TBF logical from TC
3563 | end estimates how to continue.
3564 |
3565 | Parameters : void
3566 |
3567 +------------------------------------------------------------------------------
3568 */
3569 GLOBAL void tc_deactivate_tbf ( T_TBF_TYPE tbf_i )
3570 {
3571 TRACE_FUNCTION( "tc_deactivate_tbf" );
3572
3573 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3574 if((tbf_i EQ CGRLC_TBF_MODE_UL) OR
3575 (tbf_i EQ CGRLC_TBF_MODE_2PA ))
3576 {
3577 grr_data->tc.tbf_est_pacch = FALSE;
3578 }
3579 #endif
3580
3581 switch( grr_data->tbf_type )
3582 {
3583
3584 case CGRLC_TBF_MODE_DL_UL:
3585 switch( tbf_i )
3586 {
3587 case CGRLC_TBF_MODE_UL:
3588 grr_data->tbf_type = CGRLC_TBF_MODE_DL;
3589 break;
3590 case CGRLC_TBF_MODE_DL:
3591 grr_data->tbf_type = CGRLC_TBF_MODE_UL;
3592 break;
3593 case CGRLC_TBF_MODE_DL_UL:
3594 grr_data->tbf_type = CGRLC_TBF_MODE_NULL;
3595 break;
3596 }
3597 break;
3598
3599 case CGRLC_TBF_MODE_DL:
3600 case CGRLC_TBF_MODE_UL:
3601 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3602 case CGRLC_TBF_MODE_2PA:
3603 #endif
3604 grr_data->tbf_type = CGRLC_TBF_MODE_NULL;
3605 break;
3606
3607 default:
3608 break;
3609 }
3610
3611 switch( grr_data->tbf_type )
3612 {
3613 case CGRLC_TBF_MODE_DL:
3614 SET_STATE(TC,TC_TBF_ACTIVE);
3615 /*
3616 * downlink tbf is running --> TC_TBF_ACTIVE
3617 */
3618 break;
3619
3620 case CGRLC_TBF_MODE_UL:
3621 /*
3622 * uplink tbf is running, no state change required
3623 */
3624 break;
3625
3626 case CGRLC_TBF_MODE_NULL:
3627 SET_STATE(TC,TC_PIM);
3628 /*
3629 * no tbf is running, enter TC_PIM
3630 */
3631 break;
3632
3633 default:
3634 break;
3635 }
3636
3637
3638 } /* tc_deactivate_tbf() */
3639
3640
3641 /*
3642 +------------------------------------------------------------------------------
3643 | Function : tc_start_timer_t3172
3644 +------------------------------------------------------------------------------
3645 | Description : The function tc_start_timer_t3172()
3646 | SZML-TC/085 this timer start
3647 | caused p access reject will be done
3648 | with cell reselection procedures
3649 |
3650 | Parameters : none
3651 |
3652 +------------------------------------------------------------------------------
3653 */
3654 GLOBAL void tc_start_timer_t3172 ( ULONG t3172_value_i )
3655 {
3656
3657 if(t3172_value_i > 10000)
3658 {
3659 TRACE_EVENT_P1( "T3172 start %d s", (t3172_value_i/1000));
3660 }
3661 else
3662 {
3663 TRACE_EVENT_P1( "T3172 start %d ms", t3172_value_i);
3664 }
3665 vsi_t_start(GRR_handle,T3172_1,t3172_value_i);
3666
3667 } /* tc_start_timer_t3172() */
3668
3669
3670
3671 /*
3672 +------------------------------------------------------------------------------
3673 | Function : tc_handle_tbf_start
3674 |------------------------------------------------------------------------------
3675 | Description : The function tc_handle_tbf_start() handles the TBF-Starting-
3676 | Time in a Packet Uplink Assignment.
3677 |
3678 | Parameters : tbf_type - type of tbf to be handled,
3679 | tbf_wait - pointer to variable to store the calculated timmer
3680 | value
3681 +------------------------------------------------------------------------------
3682 */
3683 GLOBAL void tc_handle_tbf_start( T_TBF_TYPE tbf_type )
3684 {
3685 TRACE_FUNCTION( "tc_handle_tbf_start" );
3686
3687
3688 tc_send_assign_req(tbf_type);
3689 tc_activate_tbf(tbf_type);
3690
3691 if((tbf_type EQ CGRLC_TBF_MODE_UL))
3692 {
3693 vsi_t_stop(GRR_handle,T3162);
3694 vsi_t_stop(GRR_handle,T3168);
3695 vsi_t_stop(GRR_handle,T3170);
3696 vsi_t_stop(GRR_handle,T3186);
3697
3698 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_UL,CGRLC_PRIM_STATUS_NULL);
3699 }
3700 else if(tbf_type EQ CGRLC_TBF_MODE_DL)
3701 {
3702 tc_cgrlc_dl_tbf_req();
3703 if(grr_data->tc.v_sb_without_tbf EQ TRUE)
3704 {
3705 /*When Single Block is request for Measurement Report
3706 but network has sent the DL assignment, then this measurement report
3707 is sent to GRLC to be sent as normal control block*/
3708 tc_send_control_msg_to_grlc();
3709 grr_data->tc.v_sb_without_tbf = FALSE;
3710 }
3711 }
3712 else if(tbf_type EQ CGRLC_TBF_MODE_DL_UL)
3713 {
3714 vsi_t_stop(GRR_handle,T3168);
3715 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_UL,CGRLC_PRIM_STATUS_NULL);
3716 tc_cgrlc_dl_tbf_req();
3717 }
3718 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
3719 else if(tbf_type EQ CGRLC_TBF_MODE_2PA)
3720 {
3721 tc_cgrlc_ul_tbf_res(CGRLC_TBF_MODE_2PA,CGRLC_PRIM_STATUS_NULL);
3722 }
3723 #endif
3724 } /* tc_handle_tbf_start() */
3725
3726 /*
3727 +------------------------------------------------------------------------------
3728 | Function : tc_prepare_handle_tbf_start
3729 |------------------------------------------------------------------------------
3730 | Description :
3731 |
3732 | Parameters :
3733 +------------------------------------------------------------------------------
3734 */
3735 GLOBAL void tc_prepare_handle_tbf_start ( T_TBF_TYPE tbf_type,
3736 UBYTE new_state,
3737 UBYTE old_state )
3738 {
3739 MCAST( p_d_dl_assign, D_DL_ASSIGN );
3740
3741 TRACE_FUNCTION( "tc_prepare_handle_tbf_start" );
3742
3743 if( grr_is_pbcch_present( ) AND
3744 (
3745 old_state EQ TC_PIM OR
3746 old_state EQ TC_WAIT_ASSIGN OR
3747 old_state EQ TC_WAIT_2P_ASSIGN OR
3748 old_state EQ TC_POLLING OR
3749 old_state EQ TC_WAIT_STOP_TASK_CNF
3750 )
3751 )
3752 {
3753 UBYTE ccch_read;
3754
3755 if( p_d_dl_assign->msg_type EQ D_DL_ASSIGN )
3756 {
3757 ccch_read = ( p_d_dl_assign->pda_trnc_grp.v_tbf_s_time ? DONT_STOP_CCCH : STOP_CCCH );
3758 }
3759 else
3760 {
3761 MCAST( p_d_ul_assign, D_UL_ASSIGN );
3762
3763 if( ( p_d_ul_assign->v_dyn_alloc_p AND
3764 p_d_ul_assign->dyn_alloc_p.v_tbf_s_time ) OR
3765 p_d_ul_assign->v_sin_alloc OR
3766 p_d_ul_assign->v_f_alloc_ul )
3767 {
3768 ccch_read = DONT_STOP_CCCH;
3769 }
3770 else
3771 {
3772 ccch_read = STOP_CCCH;
3773 }
3774 }
3775
3776 grr_data->tc.last_eval_assign.ccch_read = ccch_read;
3777 grr_data->tc.last_eval_assign.tbf_type = tbf_type;
3778 grr_data->tc.last_eval_assign.state = new_state;
3779
3780 SET_STATE( TC, TC_WAIT_STOP_TASK_CNF );
3781
3782 tc_malloc_assign( );
3783 if(old_state NEQ TC_WAIT_STOP_TASK_CNF)
3784 {
3785 sig_tc_ctrl_set_pckt_mode( GLBL_PCKT_MODE_ASSIGNED, ccch_read );
3786 }
3787 }
3788 else
3789 {
3790 tc_handle_tbf_start( tbf_type );
3791
3792 #ifdef _TARGET_
3793
3794 if( p_d_dl_assign->msg_type EQ D_DL_ASSIGN AND
3795 grr_data->downlink_tbf.tbf_start_fn NEQ 0xFFFFFFFF )
3796 {
3797 sig_tc_ctrl_set_pckt_mode( GLBL_PCKT_MODE_ACCESS, TASK_STOP_DUMMY_VALUE );
3798 }
3799
3800 #endif
3801
3802 }
3803 } /* tc_prepare_handle_tbf_start() */
3804 /*
3805 +------------------------------------------------------------------------------
3806 | Function : tc_set_fa_bitmap
3807 +------------------------------------------------------------------------------
3808 | Description : sets fixed allocation bitmap for requested allocation after
3809 | receiving a repeat allocation with ts_override
3810 |
3811 | Parameters : void
3812 |
3813 +------------------------------------------------------------------------------
3814 */
3815 GLOBAL USHORT tc_set_fa_bitmap( UBYTE ts_mask, T_FIX_ALLOC* ptr_alloc)
3816 {
3817 UBYTE i;
3818 USHORT tx_slots=0;
3819 TRACE_FUNCTION( "tc_set_fa_bitmap" );
3820
3821 if (ts_mask)
3822 {
3823 /*
3824 * add new time slots to current allocation
3825 */
3826 for(i=0;i<grr_data->tc.fa_ctrl.current_alloc.alloc.size_bitmap;i++)
3827 {
3828 ptr_alloc->alloc.bitmap[i] = grr_data->tc.fa_ctrl.current_alloc.alloc.bitmap[i] | ts_mask;
3829 }
3830 }
3831
3832 return (tx_slots);
3833
3834 } /* tc_set_fa_bitmap() */
3835
3836
3837 /*
3838 +------------------------------------------------------------------------------
3839 | Function : tc_send_ul_repeat_alloc_req
3840 +------------------------------------------------------------------------------
3841 | Description : send the primitive MPHP_REPEAT_UL_FIXED_ALLOC_REQ
3842 |
3843 | Parameters : void
3844 |
3845 +------------------------------------------------------------------------------
3846 */
3847 GLOBAL void tc_send_ul_repeat_alloc_req( void)
3848 {
3849 PALLOC(ptr_2prim,MPHP_REPEAT_UL_FIXED_ALLOC_REQ);
3850
3851 TRACE_FUNCTION( "tc_send_ul_repeat_alloc_req" );
3852
3853 ptr_2prim->repeat_alloc = grr_data->tc.fa_ctrl.repeat_alloc;
3854 ptr_2prim->ts_override = grr_data->tc.fa_ctrl.ts_overr;
3855
3856 if(grr_data->tc.fa_ctrl.repeat_alloc)
3857 {
3858 ptr_2prim->p_tbf_start.tbf_start_present = 1;
3859 ptr_2prim->p_tbf_start.fn = grr_data->tc.fa_ctrl.current_alloc.alloc_start_fn;
3860 }
3861 else
3862 {
3863 ptr_2prim->p_tbf_start.tbf_start_present = 0;
3864 ptr_2prim->p_tbf_start.fn = 0xffffffff;
3865 }
3866 PSEND(hCommL1,ptr_2prim);
3867
3868 } /* tc_send_ul_repeat_alloc_req() */
3869
3870
3871
3872
3873 /*
3874 +------------------------------------------------------------------------------
3875 | Function : tc_eval_ts_reconf
3876 +------------------------------------------------------------------------------
3877 | Description : The function tc_eval_ts_reconf() evaluates a
3878 | Packet Timeslot reconfigure.
3879 |
3880 | Parameters : void
3881 |
3882 +------------------------------------------------------------------------------
3883 */
3884 GLOBAL T_EVAL_TS_RECONFIG tc_eval_ts_reconf ( void )
3885 {
3886 MCAST(d_ts_reconfig,D_TS_RECONFIG); /* T_D_TS_RECONFIG */
3887 T_EVAL_TS_RECONFIG result = E_TS_IGNORE;
3888 UBYTE tx_slots;
3889 UBYTE i,mask;
3890
3891 T_GRR_STORE_TYPE grr_store_type = GRR_STORE_TYPE_NONE;
3892
3893 TRACE_FUNCTION( "tc_eval_ts_reconf" );
3894
3895 grr_data->downlink_tbf.ctrl_ack_bit = 0;
3896
3897 #ifdef REL99
3898 /* This function is called only when TBF is active. Handling abnormal case
3899 * 8.7 While a TBF is in progress, if a mobile station receives a
3900 * PACKET UPLINK ASSIGNMENT, PACKET UPLINK ACK/NACK or PACKET TIMESLOT RECONFIGURE
3901 * message with message escape bit indicating EGPRS (resp. GPRS) contents whereas
3902 * the current TBF mode is GPRS (resp. EGPRS), the mobile station shall ignore the
3903 * message.
3904 */
3905 if(d_ts_reconfig->egprs_flag)
3906 {
3907 TRACE_ERROR( " EGPRS TBF received in TS_RECONFIGURE " );
3908 return E_TS_IGNORE;
3909 }
3910 #endif
3911
3912 switch(grr_data->tbf_type)
3913 {
3914 case CGRLC_TBF_MODE_UL:
3915 /*
3916 * reassignment of uplink and downlink assignment
3917 */
3918 grr_data->downlink_tbf.mac_mode = grr_data->uplink_tbf.mac_mode;
3919 grr_data->downlink_tbf.t3192 = FALSE; /* indicates if t3192 is running*/
3920 grr_data->downlink_tbf.rlc_mode = d_ts_reconfig->dl_rlc_mode;
3921
3922 if(d_ts_reconfig->v_dl_tfi EQ 0)
3923 {
3924 TRACE_ERROR( "No downlnik assignment in TS_RECONFIGURE " );
3925 result = E_TS_RECONFIG_ERROR_RA;
3926 return result;
3927 }
3928 if((d_ts_reconfig->v_dyn_alloc_ts EQ 1) AND
3929 grr_data->uplink_tbf.mac_mode EQ FIXED_ALLOCATION)
3930 {
3931 TRACE_ERROR( "fixed alloc expected but dynamic alloc received" );
3932 result = E_TS_RECONFIG_ERROR_RA;
3933 return result;
3934 }
3935 if(d_ts_reconfig->v_f_alloc_re EQ 1 AND
3936 grr_data->uplink_tbf.mac_mode EQ DYNAMIC_ALLOCATION)
3937 {
3938 TRACE_ERROR( "dynamic alloc expected but fixed alloc received" );
3939 result = E_TS_RECONFIG_ERROR_RA;
3940 return result;
3941 }
3942 result = E_TS_UL_REASSIG_NEW_DL;
3943 break;
3944 case CGRLC_TBF_MODE_DL:
3945 grr_data->uplink_tbf.ti = 0; /* contention resolution NOT required */
3946 if(d_ts_reconfig->v_dyn_alloc_ts)
3947 {
3948 if(d_ts_reconfig->dyn_alloc_ts.xdyn_alloc)
3949 grr_data->uplink_tbf.mac_mode =EDA;
3950 else
3951 grr_data->uplink_tbf.mac_mode =DA;
3952 }
3953 else if(d_ts_reconfig->v_f_alloc_re)
3954 {
3955 grr_data->uplink_tbf.mac_mode = FA;
3956 }
3957 /*
3958 * downlink tbf active,
3959 * assignment of uplink and downlink reassignment
3960 */
3961 if(d_ts_reconfig->v_ul_tfi EQ 0)
3962 {
3963 TRACE_ERROR( "No uplnik tfi in TS_RECONFIGURE" );
3964 result = E_TS_RECONFIG_ERROR_RA;
3965 return result;
3966 }
3967 if ((grr_data->downlink_tbf.rlc_mode NEQ d_ts_reconfig->dl_rlc_mode) AND !d_ts_reconfig->ctrl_ack)
3968 {
3969 TRACE_ERROR("Diff rlc mode in TS_RECONFIGURE..msg rejected..aborting");
3970 result = E_TS_RECONFIG_ERROR_RA;
3971 return result;
3972 }
3973 grr_data->downlink_tbf.rlc_mode = d_ts_reconfig->dl_rlc_mode;
3974 result = E_TS_NEW_UL_DL_REASSIG;
3975 break;
3976 case CGRLC_TBF_MODE_DL_UL:
3977
3978 if((d_ts_reconfig->v_dyn_alloc_ts EQ 1) AND
3979 grr_data->uplink_tbf.mac_mode EQ FIXED_ALLOCATION)
3980 {
3981 TRACE_ERROR( "fixed alloc expected but dynamic alloc received" );
3982 result = E_TS_RECONFIG_ERROR_RA;
3983 return result;
3984 }
3985 if(d_ts_reconfig->v_f_alloc_re EQ 1 AND
3986 grr_data->uplink_tbf.mac_mode EQ DYNAMIC_ALLOCATION)
3987 {
3988 TRACE_ERROR( "dynamic alloc expected but fixed alloc received" );
3989 result = E_TS_RECONFIG_ERROR_RA;
3990 return result;
3991 }
3992 if ((grr_data->downlink_tbf.rlc_mode NEQ d_ts_reconfig->dl_rlc_mode) AND !d_ts_reconfig->ctrl_ack)
3993 {
3994 TRACE_ERROR("Diff rlc mode in TS_RECONFIGURE..msg rejected..aborting");
3995 result = E_TS_RECONFIG_ERROR_RA;
3996 return result;
3997 }
3998 grr_data->downlink_tbf.rlc_mode = d_ts_reconfig->dl_rlc_mode;
3999 result = E_TS_UL_REASSIG_DL_REASSIG;
4000 break;
4001 default:
4002 {
4003 TRACE_ERROR( " tc_eval_ts_reconf unexpected" );
4004 return E_TS_IGNORE;
4005 }
4006 }
4007
4008 /*
4009 * set DOWNLINK data base
4010 */
4011
4012 grr_data->downlink_tbf.ts_usage = d_ts_reconfig->dl_tn_alloc;
4013 grr_data->downlink_tbf.nts = grr_calc_nr_of_set_bits(grr_data->downlink_tbf.ts_usage);
4014
4015 if(d_ts_reconfig->ctrl_ack)
4016 {
4017 if(grr_data->downlink_tbf.t3192)
4018 {
4019 grr_data->downlink_tbf.ctrl_ack_bit= 1;
4020 grr_data->downlink_tbf.t3192 = FALSE;
4021 }
4022 else
4023 {
4024 result = E_TS_RECONFIG_ERROR_RA;
4025 TRACE_EVENT("TS_RECONF INVALID->error_ra, ctrl ack bit set but t3192 is not running");
4026 return result;
4027 }
4028 }
4029
4030 /*
4031 * set UPLINK data base
4032 */
4033 grr_data->uplink_tbf.cs_mode = d_ts_reconfig->chan_coding_cmd;
4034 grr_data->uplink_tbf.tlli_cs_mode = 1;
4035 grr_data->uplink_tbf.polling_bit = 0xFF;
4036 grr_data->uplink_tbf.ti = 0;
4037
4038 /*
4039 * set glob parameters
4040 */
4041
4042 if(d_ts_reconfig->v_freq_par)
4043 {
4044 /* SZML-TC/091 */
4045 /*
4046 * here is also to consider a possiblely existing dl_tbf slot ussage:SZML-TC/092
4047 */
4048 }
4049 if(d_ts_reconfig->v_dyn_alloc_ts)
4050 {
4051 tx_slots = 0;
4052 grr_data->uplink_tbf.ts_usage = 0;
4053 if(d_ts_reconfig->dyn_alloc_ts.v_tn_alloc)
4054 {
4055 for(i = 0,mask = 0x80;i < 8;i++)
4056 {
4057 if(d_ts_reconfig->dyn_alloc_ts.tn_alloc[i].v_usf)
4058 {
4059 grr_data->uplink_tbf.ts_usage |= mask;
4060 tx_slots++;
4061 }
4062 mask >>= 1;
4063 }
4064 }
4065 else if(d_ts_reconfig->dyn_alloc_ts.v_tn_alloc_pwr)
4066 {
4067 for(i = 0,mask = 0x80;i < 8;i++)
4068 {
4069 if(d_ts_reconfig->dyn_alloc_ts.tn_alloc_pwr.usf_array[i].v_usf_g)
4070 {
4071 grr_data->uplink_tbf.ts_usage |= mask;
4072 tx_slots++;
4073 }
4074 mask >>= 1;
4075 }
4076
4077 grr_store_type = GRR_STORE_TYPE_TN_ALLOC_PWR;
4078 }
4079 grr_data->uplink_tbf.nts = tx_slots;
4080 }
4081 else if(d_ts_reconfig->v_f_alloc_re)
4082 {
4083 grr_data->uplink_tbf.ts_usage = 0;
4084 tx_slots=0;
4085 if(d_ts_reconfig->f_alloc_re.v_ul_ts_alloc)
4086 {
4087 grr_data->uplink_tbf.ts_usage = d_ts_reconfig->f_alloc_re.ul_ts_alloc;
4088 /*calculate number of timeslots*/
4089 tx_slots = grr_calc_nr_of_set_bits(grr_data->uplink_tbf.ts_usage);
4090 }
4091 else if(d_ts_reconfig->f_alloc_re.v_pwr_par)
4092 {
4093 for(i = 0,mask = 0x80;i < 8;i++)
4094 {
4095 if(d_ts_reconfig->f_alloc_re.pwr_par.gamma_tn[i].v_gamma)
4096 {
4097 grr_data->uplink_tbf.ts_usage |= mask;
4098 tx_slots++;
4099 }
4100 mask >>= 1;
4101 }
4102
4103 grr_store_type = GRR_STORE_TYPE_PWR_PAR;
4104 }
4105 grr_data->uplink_tbf.nts = tx_slots;
4106 }
4107 else
4108 {
4109 TRACE_ERROR ("Packet Timeslot Reconfigure without allocation type - corrupt airmessage!");
4110 }
4111
4112 if( !handle_ms_cap(UL_DL_ASSIGNMENT) )
4113 {
4114 result = E_TS_RECONFIG_ERROR_RA;
4115 TRACE_EVENT("tc_eval_.. will return E_TS_RECONFIG_ERROR_RA (ms class error)");
4116 }
4117
4118 if( tc_check_and_save_freq( ) EQ FALSE )
4119 {
4120 result = E_TS_RECONFIG_ERROR_RA;
4121 TRACE_EVENT("tc_eval_.. will return E_TS_RECONFIG_ERROR_RA (frequencies wrong)");
4122 }
4123
4124 if( result NEQ E_TS_RECONFIG_ERROR_RA AND
4125 result NEQ E_TS_IGNORE )
4126 {
4127 switch( grr_store_type )
4128 {
4129 case GRR_STORE_TYPE_TN_ALLOC_PWR:
4130 grr_store_type_tn_alloc_pwr( &d_ts_reconfig->dyn_alloc_ts.tn_alloc_pwr );
4131 break;
4132
4133 case GRR_STORE_TYPE_PWR_PAR:
4134 grr_store_type_pwr_par( &d_ts_reconfig->f_alloc_re.pwr_par, FALSE );
4135 break;
4136
4137 default:
4138 /* do nothing */
4139 break;
4140 }
4141 }
4142
4143 return result;
4144 } /* tc_eval_ts_reconf() */
4145
4146
4147
4148
4149
4150
4151
4152
4153 /*
4154 +------------------------------------------------------------------------------
4155 | Function : tc_stop_timer_t3172
4156 +------------------------------------------------------------------------------
4157 | Description : The function tc_stop_timer_t3172()
4158 | SZML-TC/094 this timer start
4159 | caused p access reject will be done
4160 | with cell reselection procedures
4161 |
4162 | Parameters : none
4163 |
4164 +------------------------------------------------------------------------------
4165 */
4166 GLOBAL void tc_stop_timer_t3172 ( void )
4167 {
4168 TRACE_FUNCTION( "tc_stop_timer_t3172" );
4169
4170 vsi_t_stop(GRR_handle,T3172_1);
4171
4172 } /* tc_stop_timer_t3172() */
4173
4174 /*
4175 +------------------------------------------------------------------------------
4176 | Function : tc_close_gaps_in_ctrl_blk_seq
4177 +------------------------------------------------------------------------------
4178 | Description : The function tc_close_gaps_in_ctrl_blk_seq reorders the queue
4179 | holding the order which is used to identify the next control
4180 | block to sent.
4181 |
4182 | Parameters : index - at this index the reordering starts
4183 |
4184 +------------------------------------------------------------------------------
4185 */
4186 LOCAL void tc_close_gaps_in_ctrl_blk_seq ( UBYTE index )
4187 {
4188 TRACE_FUNCTION( "tc_close_gaps_in_ctrl_blk_seq" );
4189
4190 while( index < MAX_CTRL_BLK_NUM AND
4191 grr_data->tc.ul_ctrl_blk.seq[index] NEQ MAX_CTRL_BLK_NUM )
4192 {
4193 grr_data->tc.ul_ctrl_blk.seq[index-1] = grr_data->tc.ul_ctrl_blk.seq[index];
4194
4195 index++;
4196 }
4197
4198 grr_data->tc.ul_ctrl_blk.seq[index-1] = MAX_CTRL_BLK_NUM;
4199
4200 } /* tc_close_gaps_in_ctrl_blk_seq() */
4201
4202 /*
4203 +------------------------------------------------------------------------------
4204 | Function : tc_store_ctrl_blk
4205 +------------------------------------------------------------------------------
4206 | Description :
4207 |
4208 | Parameters :
4209 |
4210 +------------------------------------------------------------------------------
4211 */
4212 GLOBAL BOOL tc_store_ctrl_blk ( T_BLK_OWNER blk_owner, void *blk_struct )
4213 {
4214 UBYTE i; /* used for counting */
4215 BOOL result = FALSE; /* indicates whether control block is */
4216 /* stored successfully or not */
4217 T_BLK_INDEX blk_index; /* index to the control block buffer */
4218
4219 TRACE_FUNCTION( "tc_store_ctrl_msg" );
4220
4221 /*
4222 * we have to find a free buffer for the control block which is
4223 * indicated by the index to the control block buffer
4224 */
4225 blk_index = MAX_CTRL_BLK_NUM;
4226
4227 switch( blk_owner )
4228 {
4229 case( CGRLC_BLK_OWNER_CTRL ):
4230 if( grr_data->tc.ul_ctrl_blk.blk[BLK_INDEX_CTRL].state EQ BLK_STATE_NONE )
4231 {
4232 blk_index = BLK_INDEX_CTRL;
4233 }
4234 break;
4235
4236 case( CGRLC_BLK_OWNER_CS ):
4237 if( grr_data->tc.ul_ctrl_blk.blk[BLK_INDEX_CS].state EQ BLK_STATE_NONE )
4238 {
4239 blk_index = BLK_INDEX_CS;
4240 }
4241 break;
4242
4243 case( CGRLC_BLK_OWNER_TM ):
4244 if( grr_data->tc.ul_ctrl_blk.blk[BLK_INDEX_TC].state EQ BLK_STATE_NONE )
4245 {
4246 blk_index = BLK_INDEX_TC;
4247 }
4248 break;
4249
4250 case( CGRLC_BLK_OWNER_MEAS ):
4251
4252 blk_index = BLK_INDEX_MEAS;
4253
4254 while( blk_index < MAX_CTRL_BLK_NUM AND
4255 grr_data->tc.ul_ctrl_blk.blk[blk_index].state NEQ BLK_STATE_NONE )
4256 {
4257 blk_index++;
4258 }
4259 break;
4260
4261 default:
4262 /* do nothing */
4263 break;
4264 }
4265
4266 /*
4267 * check whether the control block buffer is free,
4268 */
4269 if( blk_index < MAX_CTRL_BLK_NUM )
4270 {
4271 /*
4272 * check the queue holding the order which is used to identify the next
4273 * control block to send
4274 */
4275 i = 0;
4276
4277 while( i < MAX_CTRL_BLK_NUM AND
4278 grr_data->tc.ul_ctrl_blk.seq[i] NEQ MAX_CTRL_BLK_NUM )
4279 {
4280 i++;
4281 }
4282
4283 /*
4284 * check whether there is a free entry in the order queue,
4285 * in case the check fails, there is something wrong with the concept
4286 */
4287 if( i < MAX_CTRL_BLK_NUM )
4288 {
4289 /*
4290 * store the control block data and state in the queues
4291 */
4292 grr_encode_ul_ctrl_block
4293 ( ( UBYTE* )&grr_data->tc.ul_ctrl_blk.blk[blk_index].data[0],
4294 ( UBYTE* )blk_struct );
4295
4296 grr_data->tc.ul_ctrl_blk.blk[blk_index].state = BLK_STATE_ALLOCATED;
4297 grr_data->tc.ul_ctrl_blk.blk[blk_index].owner = blk_owner;
4298 grr_data->tc.ul_ctrl_blk.seq[i] = blk_index;
4299
4300 if( i < MAX_CTRL_BLK_NUM - 1 )
4301 {
4302 grr_data->tc.ul_ctrl_blk.seq[i+1] = MAX_CTRL_BLK_NUM;
4303 }
4304
4305 result = TRUE;
4306 }
4307 else
4308 {
4309 TRACE_ERROR( "tc_store_ctrl_blk: no free entry in queue found" );
4310 }
4311 }
4312
4313 if( result EQ FALSE )
4314 {
4315 if( blk_owner EQ CGRLC_BLK_OWNER_MEAS )
4316 {
4317 TRACE_EVENT( "tc_store_ctrl_blk: no table entry allocated" );
4318 }
4319 else
4320 {
4321 TRACE_ERROR( "tc_store_ctrl_blk: no table entry allocated" );
4322 }
4323 }
4324
4325 return( result );
4326
4327 } /* tc_store_ctrl_blk() */
4328
4329 /*
4330 +------------------------------------------------------------------------------
4331 | Function : tc_cancel_ctrl_blk
4332 +------------------------------------------------------------------------------
4333 | Description :
4334 |
4335 | Parameters :
4336 |
4337 +------------------------------------------------------------------------------
4338 */
4339 GLOBAL BOOL tc_cancel_ctrl_blk ( T_BLK_OWNER blk_owner )
4340 {
4341 BOOL result = FALSE;
4342 UBYTE i = 0;
4343 UBYTE blk_index = grr_data->tc.ul_ctrl_blk.seq[i];
4344
4345 TRACE_FUNCTION( "tc_cancel_ctrl_blk" );
4346
4347
4348 while( blk_index NEQ MAX_CTRL_BLK_NUM AND
4349 result EQ FALSE )
4350 {
4351 if( grr_data->tc.ul_ctrl_blk.blk[blk_index].owner EQ blk_owner AND
4352 grr_data->tc.ul_ctrl_blk.blk[blk_index].state EQ BLK_STATE_ALLOCATED )
4353 {
4354 /*
4355 * mark the entry in the queue as free
4356 */
4357 grr_data->tc.ul_ctrl_blk.blk[blk_index].state = BLK_STATE_NONE;
4358 grr_data->tc.ul_ctrl_blk.blk[blk_index].owner = CGRLC_BLK_OWNER_NONE;
4359
4360 tc_close_gaps_in_ctrl_blk_seq( (UBYTE)( i + 1 ) );
4361
4362 /*
4363 * notify owner of the control block, TC always runs in unacknowledged mode
4364 */
4365 if( blk_owner NEQ CGRLC_BLK_OWNER_TM )
4366 {
4367 sig_tc_ctrl_control_block_result( blk_owner, FALSE );
4368 }
4369
4370 result = TRUE;
4371 }
4372
4373 i++;
4374 if( i < MAX_CTRL_BLK_NUM )
4375 {
4376 blk_index = grr_data->tc.ul_ctrl_blk.seq[i];
4377 }
4378 else
4379 {
4380 blk_index = MAX_CTRL_BLK_NUM;
4381 }
4382 }
4383
4384 if( result EQ FALSE )
4385 {
4386 TRACE_EVENT( "tc_cancel_ctrl_blk: no block found" );
4387 }
4388
4389 return( result );
4390
4391 } /* tc_cancel_ctrl_blk() */
4392
4393 /*
4394 +------------------------------------------------------------------------------
4395 | Function : tc_set_start_ctrl_blk
4396 +------------------------------------------------------------------------------
4397 | Description :
4398 |
4399 | Parameters :
4400 |
4401 +------------------------------------------------------------------------------
4402 */
4403 GLOBAL UBYTE* tc_set_start_ctrl_blk ( UBYTE *index )
4404 {
4405 UBYTE i = 0;
4406 T_BLK_INDEX blk_index = MAX_CTRL_BLK_NUM;
4407
4408 TRACE_FUNCTION( "tc_set_start_ctrl_blk" );
4409
4410 while( i < MAX_CTRL_BLK_NUM AND
4411 grr_data->tc.ul_ctrl_blk.seq[i] NEQ MAX_CTRL_BLK_NUM AND
4412 blk_index EQ MAX_CTRL_BLK_NUM )
4413 {
4414 blk_index = grr_data->tc.ul_ctrl_blk.seq[i];
4415
4416 if( grr_data->tc.ul_ctrl_blk.blk[blk_index].state EQ BLK_STATE_ALLOCATED )
4417 {
4418 grr_data->tc.ul_ctrl_blk.blk[blk_index].state = BLK_STATE_SENT_REQ;
4419
4420 /*
4421 * the control block was encoded without having correct information
4422 * about the value of the R bit. So we have to set the correct value now.
4423 */
4424 grr_data->tc.ul_ctrl_blk.blk[blk_index].data[0] =
4425 grr_get_ul_ctrl_block_header( grr_data->r_bit );
4426 }
4427 else
4428 {
4429 blk_index = MAX_CTRL_BLK_NUM;
4430 }
4431
4432 i++;
4433 }
4434
4435 *index = blk_index;
4436
4437 return( blk_index EQ MAX_CTRL_BLK_NUM ?
4438 NULL : grr_data->tc.ul_ctrl_blk.blk[blk_index].data );
4439
4440 } /* tc_set_start_ctrl_blk() */
4441
4442 /*
4443 +------------------------------------------------------------------------------
4444 | Function : tc_set_stop_ctrl_blk
4445 +------------------------------------------------------------------------------
4446 | Description :
4447 |
4448 | Parameters :
4449 |
4450 +------------------------------------------------------------------------------
4451 */
4452 GLOBAL T_BLK_INDEX tc_set_stop_ctrl_blk
4453 ( BOOL is_tx_success, T_BLK_OWNER srch_owner, T_BLK_INDEX start_index )
4454 {
4455 T_BLK_INDEX blk_index = grr_data->tc.ul_ctrl_blk.seq[start_index];
4456 T_BLK_INDEX nxt_index;
4457
4458 TRACE_FUNCTION( "tc_set_stop_ctrl_blk" );
4459
4460 if( blk_index < MAX_CTRL_BLK_NUM )
4461 {
4462 T_BLK_OWNER blk_owner = grr_data->tc.ul_ctrl_blk.blk[blk_index].owner;
4463
4464 if( srch_owner EQ CGRLC_BLK_OWNER_NONE OR
4465 srch_owner EQ blk_owner )
4466 {
4467 /*
4468 * mark the entry in the queue as free
4469 */
4470 grr_data->tc.ul_ctrl_blk.blk[blk_index].state = BLK_STATE_NONE;
4471 grr_data->tc.ul_ctrl_blk.blk[blk_index].owner = CGRLC_BLK_OWNER_NONE;
4472
4473 tc_close_gaps_in_ctrl_blk_seq( 1 );
4474
4475 /*
4476 * notify owner of the control block, TC always runs in unacknowledged mode
4477 */
4478 if( blk_owner NEQ CGRLC_BLK_OWNER_TM )
4479 {
4480 sig_tc_ctrl_control_block_result( blk_owner, is_tx_success );
4481 }
4482
4483 nxt_index = start_index;
4484 }
4485 else
4486 {
4487 nxt_index = start_index + 1;
4488 }
4489 }
4490 else
4491 {
4492 nxt_index = MAX_CTRL_BLK_NUM;
4493 }
4494
4495 return( nxt_index );
4496
4497 } /* tc_set_stop_ctrl_blk() */
4498
4499 /*
4500 +------------------------------------------------------------------------------
4501 | Function : tc_set_stop_tc_ctrl_blk
4502 +------------------------------------------------------------------------------
4503 | Description :
4504 |
4505 | Parameters :
4506 |
4507 +------------------------------------------------------------------------------
4508 */
4509 GLOBAL void tc_set_stop_tc_ctrl_blk ( void )
4510 {
4511 T_BLK_INDEX start_index = 0;
4512
4513 TRACE_FUNCTION( "tc_set_stop_tc_ctrl_blk" );
4514
4515 while
4516 (
4517 ( start_index = tc_set_stop_ctrl_blk( FALSE, CGRLC_BLK_OWNER_TM, start_index ) )
4518 NEQ MAX_CTRL_BLK_NUM
4519 ){};
4520 } /* tc_set_stop_tc_ctrl_blk() */
4521
4522 /*
4523 +------------------------------------------------------------------------------
4524 | Function : tc_set_stop_all_ctrl_blk
4525 +------------------------------------------------------------------------------
4526 | Description :
4527 |
4528 | Parameters :
4529 |
4530 +------------------------------------------------------------------------------
4531 */
4532 GLOBAL void tc_set_stop_all_ctrl_blk ( void )
4533 {
4534 T_BLK_INDEX start_index = 0;
4535
4536 TRACE_FUNCTION( "tc_set_stop_all_ctrl_blk" );
4537
4538 while
4539 (
4540 ( start_index = tc_set_stop_ctrl_blk( FALSE,
4541 CGRLC_BLK_OWNER_NONE,
4542 start_index ) ) NEQ MAX_CTRL_BLK_NUM
4543 ){};
4544 } /* tc_set_stop_all_ctrl_blk() */
4545
4546
4547 /*
4548 +------------------------------------------------------------------------------
4549 | Function : tc_check_access_is_needed
4550 +------------------------------------------------------------------------------
4551 | Description : The function tc_check_access_is_needed () ....
4552 |
4553 | Parameters : void
4554 |
4555 +------------------------------------------------------------------------------
4556 */
4557 GLOBAL void tc_check_access_is_needed ( T_CHECK_ACCESS_CAUSE cause )
4558 {
4559 TRACE_FUNCTION( "tc_check_access_is_needed " );
4560
4561 if( ((grr_t_status( T3172_1 ) > 0) OR (grr_t_status( T3170 ) > 0) ) AND
4562 (grr_t_status( T3176 ) EQ 0))
4563 {
4564 if( cause EQ CAC_T3170_EXPIRED )
4565 {
4566 sig_tc_ctrl_set_pckt_mode( GLBL_PCKT_MODE_IDLE, TASK_STOP_DUMMY_VALUE );
4567 }
4568
4569 TRACE_EVENT_P3("ACCESS_REJ RUNNING t3170=%d t3172=%d t3176=%d",grr_t_status( T3170 )
4570 ,grr_t_status( T3172_1 )
4571 ,grr_t_status( T3176 ));
4572 return;
4573 }
4574
4575 switch(grr_data->tbf_type)
4576 {
4577 case CGRLC_TBF_MODE_NULL:
4578 if(grr_data->tc.num_of_rels_running)
4579 {
4580 TRACE_EVENT_P1("WAIT FOR %d REL CON ", grr_data->tc.num_of_rels_running);
4581 return;
4582 }
4583 SET_STATE( TC, TC_WAIT_STOP_TASK_CNF );
4584 sig_tc_ctrl_set_pckt_mode( GLBL_PCKT_MODE_ACCESS, TASK_STOP_DUMMY_VALUE );
4585
4586
4587 break;
4588 case CGRLC_TBF_MODE_DL:
4589 case CGRLC_TBF_MODE_UL:
4590 case CGRLC_TBF_MODE_DL_UL:
4591 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
4592 case CGRLC_TBF_MODE_2PA:
4593 #endif
4594 break;
4595 default:
4596 TRACE_ERROR("unknown tbf type during uplink access");
4597 break;
4598 }
4599 } /* tc_check_access_is_needed */
4600
4601 /*
4602 +------------------------------------------------------------------------------
4603 | Function : tc_stop_normal_burst_req
4604 +------------------------------------------------------------------------------
4605 | Description : this function sends the primitive MPHP_STOP_SINGLE_BLOCK_REQ
4606 |
4607 | Parameters :
4608 |
4609 +------------------------------------------------------------------------------
4610 */
4611 GLOBAL void tc_stop_normal_burst_req ( void )
4612 {
4613 TRACE_FUNCTION( "tc_stop_normal_burst_req" );
4614
4615 {
4616 PALLOC(mphp_stop_single_block_req,MPHP_STOP_SINGLE_BLOCK_REQ);
4617 PSEND(hCommL1,mphp_stop_single_block_req);
4618 }
4619 } /* tc_stop_normal_burst_req() */
4620
4621
4622
4623 /*
4624 +------------------------------------------------------------------------------
4625 | Function : tc_malloc_assign
4626 +------------------------------------------------------------------------------
4627 | Description : The function tc_malloc_assign() ....
4628 |
4629 | Parameters :
4630 |
4631 +------------------------------------------------------------------------------
4632 */
4633 GLOBAL void tc_malloc_assign ( void )
4634 {
4635 MCAST( p_d_dl_assign, D_DL_ASSIGN );
4636
4637 TRACE_FUNCTION( "tc_malloc_assign" );
4638
4639 if( grr_data->tc.p_assign EQ NULL )
4640 {
4641 if( p_d_dl_assign->msg_type EQ D_DL_ASSIGN )
4642 {
4643 MALLOC( grr_data->tc.p_assign, sizeof( T_D_DL_ASSIGN ) );
4644 }
4645 else
4646 {
4647 MALLOC( grr_data->tc.p_assign, sizeof( T_D_UL_ASSIGN ) );
4648 }
4649 }
4650 else
4651 {
4652 TRACE_ERROR( "tc_malloc_assign: fatal error, memory reallocation not implemented" );
4653 }
4654
4655 if( p_d_dl_assign->msg_type EQ D_DL_ASSIGN )
4656 {
4657 *grr_data->tc.p_assign = *( ( T_D_DL_ASSIGN * )_decodedMsg );
4658 }
4659 else
4660 {
4661 *( ( T_D_UL_ASSIGN * )grr_data->tc.p_assign ) = *( ( T_D_UL_ASSIGN * )_decodedMsg );
4662 }
4663 } /* tc_malloc_assign() */
4664
4665 /*
4666 +------------------------------------------------------------------------------
4667 | Function : tc_mfree_assign
4668 +------------------------------------------------------------------------------
4669 | Description : The function tc_mfree_assign() ....
4670 |
4671 | Parameters :
4672 |
4673 +------------------------------------------------------------------------------
4674 */
4675 GLOBAL void tc_mfree_assign ( BOOL restore_data )
4676 {
4677 TRACE_FUNCTION( "tc_mfree_assign" );
4678
4679 if( grr_data->tc.p_assign NEQ NULL )
4680 {
4681 if( restore_data )
4682 {
4683 if( grr_data->tc.p_assign->msg_type EQ D_DL_ASSIGN )
4684 {
4685 *( ( T_D_DL_ASSIGN * )_decodedMsg ) = *grr_data->tc.p_assign;
4686 }
4687 else
4688 {
4689 *( ( T_D_UL_ASSIGN * )_decodedMsg ) = *( ( T_D_UL_ASSIGN * )grr_data->tc.p_assign );
4690 }
4691 }
4692
4693 MFREE( grr_data->tc.p_assign );
4694 grr_data->tc.p_assign = NULL;
4695 }
4696 else
4697 {
4698 TRACE_ERROR( "tc_mfree_assign: fatal error, no memory allocated" );
4699 }
4700 } /* tc_mfree_assign() */
4701
4702 /*
4703 +------------------------------------------------------------------------------
4704 | Function : tc_prepare_send_tbf_release_req
4705 +------------------------------------------------------------------------------
4706 | Description : The function tc_prepare_send_tbf_release_req() ....
4707 |
4708 | Parameters :
4709 |
4710 +------------------------------------------------------------------------------
4711 */
4712 LOCAL void tc_prepare_send_tbf_release_req( T_TBF_TYPE tbf_type )
4713 {
4714 TRACE_FUNCTION( "tc_prepare_send_tbf_release_req" );
4715
4716 if( grr_is_pbcch_present( ) AND tbf_type EQ grr_data->tbf_type )
4717 {
4718 grr_data->tc.last_tbf_type = tbf_type;
4719
4720 grr_data->tc.num_of_rels_running++;
4721
4722 sig_tc_ctrl_set_pckt_mode( GLBL_PCKT_MODE_RELEASED, TASK_STOP_DUMMY_VALUE );
4723 }
4724 else
4725 {
4726 tc_send_tbf_release_req( tbf_type, TRUE );
4727 }
4728 } /* tc_prepare_send_tbf_release_req() */
4729
4730 /*
4731 +------------------------------------------------------------------------------
4732 | Function : tc_send_tbf_release_req
4733 +------------------------------------------------------------------------------
4734 | Description : The function tc_send_tbf_release_req() ....
4735 |
4736 | Parameters :
4737 |
4738 +------------------------------------------------------------------------------
4739 */
4740 GLOBAL void tc_send_tbf_release_req( T_TBF_TYPE tbf_type, BOOL is_synchron )
4741 {
4742 UBYTE rel_req_tbf_type;
4743 UBYTE transid;
4744
4745 TRACE_FUNCTION( "tc_send_tbf_release_req" );
4746
4747 switch( tbf_type )
4748 {
4749 case CGRLC_TBF_MODE_UL: rel_req_tbf_type = UL_ASSIGNMENT; break;
4750 case CGRLC_TBF_MODE_DL: rel_req_tbf_type = DL_ASSIGNMENT; break;
4751 case CGRLC_TBF_MODE_DL_UL: rel_req_tbf_type = UL_DL_ASSIGNMENT; break;
4752 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
4753 case CGRLC_TBF_MODE_2PA: rel_req_tbf_type = UL_TP_ACCESS; break;
4754 #endif
4755
4756 default:
4757 TRACE_ERROR( "tc_send_tbf_release_req: unknown tbf type" );
4758 return;
4759 }
4760
4761 {
4762 PALLOC(mphp_tbf_release_req,MPHP_TBF_RELEASE_REQ);
4763 mphp_tbf_release_req->tbf_type = rel_req_tbf_type;
4764 PSEND(hCommL1,mphp_tbf_release_req);
4765
4766 if( is_synchron )
4767 {
4768 grr_data->tc.num_of_rels_running++;
4769 }
4770 }
4771
4772 switch(rel_req_tbf_type)
4773 {
4774 case UL_ASSIGNMENT:
4775 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
4776 case UL_TP_ACCESS:
4777 #endif
4778 memset(&grr_data->uplink_tbf,0xEE,sizeof(T_UL_TBF));
4779 grr_data->test_mode = CGRLC_NO_TEST_MODE;
4780 break;
4781 case DL_ASSIGNMENT:
4782 transid = grr_data->downlink_tbf.trans_id;
4783 memset(&grr_data->downlink_tbf,0xEE,sizeof(T_DL_TBF));
4784 grr_data->downlink_tbf.trans_id = transid;
4785 break;
4786 case UL_DL_ASSIGNMENT:
4787 transid = grr_data->downlink_tbf.trans_id;
4788 memset(&grr_data->uplink_tbf,0xEE,sizeof(T_UL_TBF));
4789 memset(&grr_data->downlink_tbf,0xEE,sizeof(T_DL_TBF));
4790 grr_data->test_mode = CGRLC_NO_TEST_MODE;
4791 grr_data->downlink_tbf.trans_id = transid;
4792 break;
4793 }
4794
4795
4796
4797 } /* tc_send_tbf_release_req() */
4798
4799
4800
4801 /*
4802 +------------------------------------------------------------------------------
4803 | Function : tc_get_t3170_value
4804 +------------------------------------------------------------------------------
4805 | Description : The function tc_get_t3170_value() calculates T3170 and returns it
4806 |
4807 | Parameters : return T_TIME
4808 |
4809 +------------------------------------------------------------------------------
4810 */
4811 GLOBAL T_TIME tc_get_t3170_value(void)
4812 {
4813 T_TIME t3170_value;
4814
4815 t3170_value = s_table[psc_db->prach.s_prach];
4816
4817 if(S_VALUE_RESERVED EQ t3170_value)
4818 t3170_value = 0;
4819
4820 t3170_value *= 2;
4821 t3170_value += tx_int_table[psc_db->prach.tx_int];
4822 /* T3170 value = TX_INT + 2 * S from prach control parameters */
4823 /* see gsm 04.60 13.1 */
4824 t3170_value *= 5; /* 1 tdma frame ~ 5ms */
4825 TRACE_EVENT_P1("T3170: %ld", t3170_value);
4826 return t3170_value;
4827 }
4828
4829
4830
4831
4832 /*
4833 +------------------------------------------------------------------------------
4834 | Function : tc_call_disable_callback_func
4835 +------------------------------------------------------------------------------
4836 | Description :
4837 |
4838 | Parameters :
4839 |
4840 +------------------------------------------------------------------------------
4841 */
4842 GLOBAL void tc_call_disable_callback_func ( void )
4843 {
4844 if( grr_data->tc.disable_callback_func NEQ NULL )
4845 {
4846 T_TC_DISABLE_CALLBACK_FUNC disable_callback_func;
4847
4848 TRACE_EVENT( "Call disable_callback_func after TBF release" );
4849
4850 disable_callback_func = grr_data->tc.disable_callback_func;
4851 grr_data->tc.disable_callback_func = NULL;
4852
4853 disable_callback_func( );
4854 }
4855 } /* tc_call_disable_callback_func */
4856
4857 /*
4858 +------------------------------------------------------------------------------
4859 | Function : tc_set_freq
4860 +------------------------------------------------------------------------------
4861 | Description : This function allocates a primitve depending on the hopping status
4862 | and sets the frequency parameter of T_MPHP_ASSIGNMENT_REQ
4863 |
4864 | Parameters : void
4865 |
4866 +------------------------------------------------------------------------------
4867 */
4868 GLOBAL T_MPHP_ASSIGNMENT_REQ * tc_set_freq ( void )
4869 {
4870 PALLOC( ptr2prim, MPHP_ASSIGNMENT_REQ );
4871
4872 TRACE_FUNCTION( "tc_set_freq" );
4873
4874 memset( ptr2prim, 0, sizeof( T_MPHP_ASSIGNMENT_REQ ) );
4875
4876 ptr2prim->tsc = grr_data->tc.freq_set.tsc;
4877
4878 grr_set_freq_par( &ptr2prim->p_frequency_par );
4879
4880 return( ptr2prim );
4881 }/* tc_set_freq */
4882
4883 /*
4884 +------------------------------------------------------------------------------
4885 | Function : tc_cgrlc_disable_req
4886 +------------------------------------------------------------------------------
4887 | Description : This function allocates sends the the primtive CGRLC_DISABLE_REQ
4888 | to GRLC
4889 |
4890 | Parameters : prim_st - indicates if a primitive shall be deleted or not
4891 |
4892 +------------------------------------------------------------------------------
4893 */
4894 GLOBAL void tc_cgrlc_disable_req ( UBYTE prim_st )
4895 {
4896 PALLOC(cgrlc_disable_req,CGRLC_DISABLE_REQ); /*T_CGRLC_DISABLE_REQ*/
4897
4898 TRACE_FUNCTION( "tc_cgrlc_disable_req" );
4899
4900 cgrlc_disable_req->disable_class = grr_data->tc.disable_class;
4901 cgrlc_disable_req->prim_status = prim_st;
4902
4903 PSEND(hCommGRLC,cgrlc_disable_req);
4904
4905 }/* tc_cgrlc_disable_req */
4906
4907
4908 /*
4909 +------------------------------------------------------------------------------
4910 | Function : tc_cgrlc_ul_tbf_res
4911 +------------------------------------------------------------------------------
4912 | Description : This function
4913 |
4914 | Parameters :
4915 |
4916 +------------------------------------------------------------------------------
4917 */
4918
4919 GLOBAL void tc_cgrlc_ul_tbf_res ( UBYTE tbf_mode, UBYTE prim_status )
4920 {
4921 PALLOC(cgrlc_ul_tbf_res,CGRLC_UL_TBF_RES); /*T_CGRLC_UL_TBF_RES*/
4922
4923 TRACE_FUNCTION( "tc_cgrlc_ul_tbf_res" );
4924
4925 cgrlc_ul_tbf_res->starting_time = grr_data->uplink_tbf.tbf_start_fn;
4926 cgrlc_ul_tbf_res->tbf_mode = tbf_mode;
4927 cgrlc_ul_tbf_res->prim_status = prim_status;
4928 cgrlc_ul_tbf_res->polling_bit = grr_data->uplink_tbf.polling_bit;
4929 cgrlc_ul_tbf_res->cs_mode = grr_data->uplink_tbf.cs_mode;
4930 cgrlc_ul_tbf_res->mac_mode = grr_data->uplink_tbf.mac_mode;
4931 cgrlc_ul_tbf_res->nts_max = grr_data->uplink_tbf.nts;
4932 cgrlc_ul_tbf_res->rlc_db_granted= grr_data->uplink_tbf.rlc_db_granted;
4933
4934 if(grr_data->uplink_tbf.ts_usage)
4935 {
4936 cgrlc_ul_tbf_res->tn_mask = grr_data->uplink_tbf.ts_usage;
4937 }
4938 else
4939 {
4940 cgrlc_ul_tbf_res->tn_mask = grr_data->uplink_tbf.ts_mask;
4941 TRACE_EVENT("UL tn mask passed to grlc instead of ts_usage");
4942 }
4943
4944 if(grr_data->uplink_tbf.st_tfi EQ 0xFF)
4945 cgrlc_ul_tbf_res->tfi = grr_data->uplink_tbf.tfi;
4946 else
4947 cgrlc_ul_tbf_res->tfi = grr_data->uplink_tbf.st_tfi;
4948
4949 cgrlc_ul_tbf_res->ti = grr_data->uplink_tbf.ti;
4950 cgrlc_ul_tbf_res->bs_cv_max = psc_db->gprs_cell_opt.bs_cv_max;
4951 cgrlc_ul_tbf_res->tlli_cs_mode = grr_data->uplink_tbf.tlli_cs_mode;
4952 cgrlc_ul_tbf_res->r_bit = grr_data->r_bit;
4953
4954 if(cgrlc_ul_tbf_res->mac_mode EQ FA)
4955 {
4956 cgrlc_ul_tbf_res->fix_alloc_struct.bitmap_len = grr_data->tc.fa_ctrl.current_alloc.alloc.size_bitmap;
4957 cgrlc_ul_tbf_res->fix_alloc_struct.end_fn = grr_data->tc.fa_ctrl.current_alloc.alloc_end_fn;
4958 cgrlc_ul_tbf_res->fix_alloc_struct.final_alloc = grr_data->tc.fa_ctrl.current_alloc.final_alloc;
4959 memcpy (cgrlc_ul_tbf_res->fix_alloc_struct.bitmap_array,
4960 grr_data->tc.fa_ctrl.current_alloc.alloc.bitmap,
4961 MAX_ALLOC_BITMAP);
4962 }
4963
4964 grr_prcs_pwr_ctrl ( &cgrlc_ul_tbf_res->pwr_ctrl, FALSE );
4965
4966 /*Reset the GRR database for parameters which are used only once*/
4967 grr_data->uplink_tbf.polling_bit=0xFF;
4968
4969 PSEND(hCommGRLC,cgrlc_ul_tbf_res);
4970
4971 }/* tc_cgrlc_ul_tbf_res */
4972
4973
4974
4975 /*
4976 +------------------------------------------------------------------------------
4977 | Function : tc_cgrlc_access_status_req
4978 +------------------------------------------------------------------------------
4979 | Description : This function
4980 |
4981 | Parameters :
4982 |
4983 +------------------------------------------------------------------------------
4984 */
4985
4986 GLOBAL void tc_cgrlc_access_status_req ( void )
4987 {
4988 PALLOC(cgrlc_access_status_req,CGRLC_ACCESS_STATUS_REQ); /*T_CGRLC_ACCESS_STATUS_REQ*/
4989
4990 TRACE_FUNCTION( "tc_cgrlc_access_status_req" );
4991
4992 PSEND(hCommGRLC,cgrlc_access_status_req);
4993
4994 }/* tc_cgrlc_access_status_req*/
4995
4996
4997 /*
4998 +------------------------------------------------------------------------------
4999 | Function : tc_send_control_msg_to_grlc
5000 +------------------------------------------------------------------------------
5001 | Description : This function
5002 |
5003 | Parameters :
5004 |
5005 +------------------------------------------------------------------------------
5006 */
5007
5008 GLOBAL void tc_send_control_msg_to_grlc ( void )
5009 {
5010 UBYTE i= 0;
5011
5012 TRACE_FUNCTION( "tc_send_control_msg_to_grlc" );
5013
5014
5015 while( i < MAX_CTRL_BLK_NUM AND
5016 grr_data->tc.ul_ctrl_blk.seq[i] NEQ MAX_CTRL_BLK_NUM )
5017 {
5018 if( grr_data->tc.ul_ctrl_blk.blk[grr_data->tc.ul_ctrl_blk.seq[i]].state
5019 EQ BLK_STATE_ALLOCATED )
5020 {
5021 PALLOC(cgrlc_data_req,CGRLC_DATA_REQ); /* T_CGRLC_DATA_REQ */
5022
5023
5024 cgrlc_data_req->blk_owner = grr_data->tc.ul_ctrl_blk.blk[grr_data->tc.ul_ctrl_blk.seq[i]].owner;
5025
5026 memcpy(cgrlc_data_req->data_array,grr_data->tc.ul_ctrl_blk.blk[grr_data->tc.ul_ctrl_blk.seq[i]].data,23);
5027
5028 PSEND(hCommGRLC,cgrlc_data_req);
5029
5030 /* remove control block */
5031
5032 tc_cancel_ctrl_blk(grr_data->tc.ul_ctrl_blk.blk[grr_data->tc.ul_ctrl_blk.seq[i]].owner);
5033 }
5034 }
5035
5036
5037 }/* tc_send_control_msg_to_grlc*/
5038
5039 /*
5040 +------------------------------------------------------------------------------
5041 | Function : tc_cgrlc_dl_tbf_req
5042 +------------------------------------------------------------------------------
5043 | Description : This function
5044 |
5045 | Parameters :
5046 |
5047 +------------------------------------------------------------------------------
5048 */
5049
5050 GLOBAL void tc_cgrlc_dl_tbf_req ( void )
5051 {
5052 PALLOC(cgrlc_dl_tbf_req,CGRLC_DL_TBF_REQ); /*T_CGRLC_DL_TBF_REQ*/
5053
5054
5055 TRACE_FUNCTION( "tc_cgrlc_dl_tbf_req" );
5056
5057 grr_data->downlink_tbf.trans_id++;
5058
5059 cgrlc_dl_tbf_req->starting_time = grr_data->downlink_tbf.tbf_start_fn;
5060 cgrlc_dl_tbf_req->rlc_mode = grr_data->downlink_tbf.rlc_mode;
5061 cgrlc_dl_tbf_req->mac_mode = grr_data->downlink_tbf.mac_mode;
5062 cgrlc_dl_tbf_req->polling_bit = grr_data->downlink_tbf.polling_bit;
5063 cgrlc_dl_tbf_req->nts_max = grr_data->downlink_tbf.nts;
5064
5065 if(grr_data->downlink_tbf.ts_usage)
5066 {
5067 cgrlc_dl_tbf_req->tn_mask = grr_data->downlink_tbf.ts_usage;
5068 grr_data->downlink_tbf.ts_mask = grr_data->downlink_tbf.ts_usage; /* set before starting time is elapsed */
5069 }
5070 else
5071 {
5072 cgrlc_dl_tbf_req->tn_mask = grr_data->downlink_tbf.ts_mask;
5073 TRACE_EVENT("DL tn mask passed to grlc instead of ts_usage");
5074 }
5075
5076
5077 if(grr_data->downlink_tbf.st_tfi EQ 0xFF)
5078 cgrlc_dl_tbf_req->tfi = grr_data->downlink_tbf.tfi;
5079 else
5080 cgrlc_dl_tbf_req->tfi = grr_data->downlink_tbf.st_tfi;
5081
5082 cgrlc_dl_tbf_req->t3192_val = psc_db->gprs_cell_opt.t3192;
5083 cgrlc_dl_tbf_req->ctrl_ack_bit = grr_data->downlink_tbf.ctrl_ack_bit;
5084
5085 grr_prcs_pwr_ctrl ( &cgrlc_dl_tbf_req->pwr_ctrl, FALSE );
5086
5087 /*Reset the GRR database for parameters which are used only once*/
5088 grr_data->downlink_tbf.ctrl_ack_bit=0;
5089 grr_data->downlink_tbf.polling_bit=0xFF;
5090
5091 PSEND(hCommGRLC,cgrlc_dl_tbf_req);
5092
5093
5094 }/* tc_cgrlc_dl_tbf_req*/
5095
5096
5097 /*
5098 +------------------------------------------------------------------------------
5099 | Function : tc_cgrlc_tbf_rel_res
5100 +------------------------------------------------------------------------------
5101 | Description : This function
5102 |
5103 | Parameters :
5104 |
5105 +------------------------------------------------------------------------------
5106 */
5107
5108 GLOBAL void tc_cgrlc_tbf_rel_res ( UBYTE tbf_type )
5109 {
5110 PALLOC(cgrlc_tbf_rel_res,CGRLC_TBF_REL_RES);
5111
5112 TRACE_FUNCTION( "tc_cgrlc_tbf_rel_res" );
5113
5114 switch( tbf_type )
5115 {
5116 case DL_ASSIGNMENT: cgrlc_tbf_rel_res->tbf_mode = CGRLC_TBF_MODE_DL; break;
5117 case UL_ASSIGNMENT: cgrlc_tbf_rel_res->tbf_mode = CGRLC_TBF_MODE_UL; break;
5118 case UL_DL_ASSIGNMENT: cgrlc_tbf_rel_res->tbf_mode = CGRLC_TBF_MODE_DL_UL; break;
5119 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
5120 case UL_TP_ACCESS: cgrlc_tbf_rel_res->tbf_mode = CGRLC_TBF_MODE_2PA; break;
5121 #endif
5122 }
5123
5124 PSEND(hCommGRLC,cgrlc_tbf_rel_res);
5125
5126 }/* tc_cgrlc_tbf_rel_res*/
5127
5128
5129
5130
5131 /*
5132 +------------------------------------------------------------------------------
5133 | Function : tc_cgrlc_tbf_rel_req
5134 +------------------------------------------------------------------------------
5135 | Description : This function
5136 |
5137 | Parameters :
5138 |
5139 +------------------------------------------------------------------------------
5140 */
5141
5142 GLOBAL void tc_cgrlc_tbf_rel_req ( UBYTE tbf_type, UBYTE rel_cause, ULONG rel_fn )
5143 {
5144 PALLOC(cgrlc_tbf_rel_req,CGRLC_TBF_REL_REQ); /*T_CGRLC_TBF_REL_REQ*/
5145
5146 TRACE_FUNCTION( "tc_cgrlc_tbf_rel_req" );
5147
5148 cgrlc_tbf_rel_req->tbf_mode = tbf_type;
5149 cgrlc_tbf_rel_req->tbf_rel_cause = rel_cause;
5150 cgrlc_tbf_rel_req->rel_fn = rel_fn;
5151
5152 PSEND(hCommGRLC,cgrlc_tbf_rel_req);
5153
5154 }/* tc_cgrlc_tbf_rel_req*/
5155
5156
5157
5158 /*
5159 +------------------------------------------------------------------------------
5160 | Function : tc_cgrlc_enable_req
5161 +------------------------------------------------------------------------------
5162 | Description : This function sends the primitive cgrlc_enable_req to GRLC
5163 |
5164 | Parameters : queue_mode - indicates the queue mode
5165 | cu_cause - indicates if cell update is required or not
5166 |
5167 +------------------------------------------------------------------------------
5168 */
5169
5170 GLOBAL void tc_cgrlc_enable_req ( UBYTE queue_mode,
5171 UBYTE cu_cause,
5172 BOOL cell_has_changed,
5173 UBYTE enable_cause )
5174 {
5175
5176 PALLOC(cgrlc_enable_req,CGRLC_ENABLE_REQ); /*T_CGRLC_ENABLE_REQ*/
5177
5178 TRACE_FUNCTION( "tc_cgrlc_enable_req" );
5179
5180 cgrlc_enable_req->enable_cause = enable_cause;
5181 cgrlc_enable_req->queue_mode = queue_mode;
5182 cgrlc_enable_req->cu_cause = cu_cause; /* cell update request will be handled sig_ctrl_tc_enable_grlc */
5183 /*************Burst type handling********************************/
5184 cgrlc_enable_req->burst_type = psc_db->gprs_cell_opt.ctrl_ack_type;
5185 cgrlc_enable_req->ab_type = psc_db->gprs_cell_opt.ab_type;
5186
5187 /*************Counter N3102 handling*****************************/
5188 cgrlc_enable_req->v_pan_struct = psc_db->gprs_cell_opt.v_pan_struct;
5189 cgrlc_enable_req->pan_struct.inc = psc_db->gprs_cell_opt.pan_struct.inc;
5190 cgrlc_enable_req->pan_struct.dec = psc_db->gprs_cell_opt.pan_struct.dec;
5191 if(cell_has_changed)
5192 cgrlc_enable_req->pan_struct.pmax = (psc_db->gprs_cell_opt.pan_struct.pmax + 1 ) *4;
5193 else
5194 cgrlc_enable_req->pan_struct.pmax = CGRLC_NO_UPDATE_N3102;
5195
5196 cgrlc_enable_req->ul_tlli = grr_data->db.ms_id.new_tlli;
5197 cgrlc_enable_req->dl_tlli = grr_data->db.ms_id.received_tlli;
5198
5199 cgrlc_enable_req->t3168_val = psc_db->gprs_cell_opt.t3168;
5200
5201 if(grr_is_pbcch_present())
5202
5203 {
5204 cgrlc_enable_req->change_mark = psc_db->psi2_params.psi2_change_mark;
5205 if(grr_data->ms.access_ctrl_class & ~psc_db->prach.ac_class)
5206 {
5207 cgrlc_enable_req->ac_class = CGRLC_PCCCH_AC_ALLOWED;
5208 }
5209 else
5210 {
5211 cgrlc_enable_req->ac_class = CGRLC_PCCCH_AC_NOT_ALLOWED;
5212 TRACE_EVENT_P3("ACCESS NOT ALLOWED PBCCH: ms_acc=%d prach_ac=%d tc_state=%d"
5213 ,grr_data->ms.access_ctrl_class
5214 ,psc_db->prach.ac_class
5215 ,grr_data->tc.state);
5216 }
5217 }
5218 else
5219 {
5220 cgrlc_enable_req->change_mark = psc_db->psi13_params.si13_change_mark;
5221 if(grr_data->ms.access_ctrl_class & ~psc_db->prach.ac_class)
5222 {
5223 cgrlc_enable_req->ac_class = psc_db->net_ctrl.priority_access_thr;
5224 }
5225 else
5226 {
5227 cgrlc_enable_req->ac_class = CGRLC_PCCCH_AC_NOT_ALLOWED;
5228 TRACE_EVENT_P3("ACCESS NOT ALLOWED CCCH: ms_acc=%d prach_ac=%d tc_state=%d"
5229 ,grr_data->ms.access_ctrl_class
5230 ,psc_db->prach.ac_class
5231 ,grr_data->tc.state);
5232 }
5233 }
5234
5235 #ifdef REL99
5236 cgrlc_enable_req->pfi_support = psc_db->gprs_cell_opt.gprs_ext_bits.gprs_ext_info.pfc_feature_mode;
5237 cgrlc_enable_req->nw_rel = psc_db->network_rel; /*Network Release Order*/
5238 #endif
5239
5240 PSEND(hCommGRLC,cgrlc_enable_req);
5241
5242 }/* tc_cgrlc_enable_req*/
5243
5244 /*
5245 +------------------------------------------------------------------------------
5246 | Function : grr_convert_11bit_2_etsi
5247 +------------------------------------------------------------------------------
5248 | Description : Converts the 11 bit access burst value into ETSI format
5249 |
5250 | Parameters : In: eleven bit value
5251 | Out: converted eleven bit
5252 |
5253 +------------------------------------------------------------------------------
5254 */
5255 LOCAL USHORT grr_convert_11bit_2_etsi ( USHORT eleven_bit )
5256 {
5257 USHORT etsi11bit;
5258 USHORT dummy1 = 0, dummy2 = 0;
5259
5260 TRACE_FUNCTION( "grr_convert_11bit_2_etsi" );
5261
5262 /*
5263 * 11 Bit access burst
5264 * b: bit
5265 * b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
5266 * should be sent to the network -according 04.60 and 0404- in the
5267 * following 16-bit format:
5268 * 0 0 0 0 0 b2 b1 b0 b10 b9 b8 b7 b6 b5 b4 b3
5269 */
5270
5271 /*
5272 * get b2 b1 b0
5273 */
5274 dummy1 = 0x0007 & eleven_bit;
5275
5276 /*
5277 * shift it 8 bits to left
5278 */
5279 dummy1 = ( dummy1 << 8 );
5280
5281 /*
5282 * get b10 b9 b8 b7 b6 b5 b4 b3
5283 */
5284 dummy2 = 0xFFF8 & eleven_bit;
5285
5286 /*
5287 * shift it 3 bits to right
5288 */
5289 dummy2 = ( dummy2 >> 3 );
5290
5291 /*
5292 * compose dummy1 and dummy2 to the target 16-bit format
5293 */
5294 etsi11bit = dummy1 | dummy2;
5295
5296 return etsi11bit;
5297
5298 } /* grr_convert_11bit_2_etsi() */