comparison src/g23m-gprs/grr/grr_cpapf.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 CPAP of
18 | entity GRR.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRR_CPAPF_C
23 #define GRR_CPAPF_C
24 #endif
25
26 #define ENTITY_GRR
27
28 /*==== INCLUDES =============================================================*/
29
30 #include <string.h>
31 #include "typedefs.h" /* to get Condat data types */
32
33 #include "vsi.h" /* to get a lot of macros */
34 #include "macdef.h"
35 #include "gprs.h"
36 #include "gsm.h" /* to get a lot of macros */
37 #include "ccdapi.h" /* to get CCD API */
38 #include "cnf_grr.h" /* to get cnf-definitions */
39 #include "mon_grr.h" /* to get mon-definitions */
40 #include "prim.h" /* to get the definitions of used SAP and directions */
41 #include "message.h"
42 #include "pcm.h" /* to get a lot of macros */
43 #include "grr.h" /* to get the global entity definitions */
44 #include "grr_f.h" /* to get the global function definitions */
45 #include "grr_tcf.h" /* to get the tc function definitions */
46 #include "grr_tcs.h" /* to get the tc sig function definitions */
47 #include "grr_cpapf.h"
48 #include "grr_meass.h" /* to get the definitions for interference measurements */
49
50 /*==== CONST ================================================================*/
51
52 /*==== LOCAL VARS ===========================================================*/
53
54 /*==== PRIVATE FUNCTIONS ====================================================*/
55
56 LOCAL void cpap_set_da_assignment_pdch (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i);
57 LOCAL void cpap_set_dl_assignment_pdch (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i);
58 LOCAL BOOL cpap_check_and_save_freq (void);
59
60
61 /*==== PUBLIC FUNCTIONS =====================================================*/
62
63
64
65 /*
66 +------------------------------------------------------------------------------
67 | Function : cpap_init
68 +------------------------------------------------------------------------------
69 | Description : The function cpap_init() ....
70 |
71 | Parameters : void
72 |
73 +------------------------------------------------------------------------------
74 */
75 GLOBAL void cpap_init ( void )
76 {
77 TRACE_FUNCTION( "cpap_init" );
78
79 INIT_STATE(CPAP,CPAP_IDLE);
80 grr_data->cpap.new_tbf_type = CGRLC_TBF_MODE_NULL;
81 grr_data->cpap.v_tma_ia = FALSE;
82 grr_data->cpap.p_d_imm_assign = NULL;
83 } /* cpap_init() */
84
85
86 /*
87 +------------------------------------------------------------------------------
88 | Function : cpap_eval_ia
89 +------------------------------------------------------------------------------
90 | Description : The function cpap_eval_ia() ....
91 |
92 | Parameters : void
93 |
94 +------------------------------------------------------------------------------
95 */
96 GLOBAL T_EVAL_IA cpap_eval_ia ( void )
97 {
98 MCAST(d_imm_assign,D_IMM_ASSIGN);/* T_D_IMM_ASSIGN T_U_CTRL_ACK */
99 T_EVAL_IA result = E_IA_NULL;
100 T_tfi_ass_alloc * p_tfi_ass;
101 TRACE_FUNCTION( "cpap_eval_ia" );
102
103 if(d_imm_assign->tma EQ TMA_1)
104 {
105 /* the 1st message is only delivered by rr if the 2nd message has arrived */
106 /* with correct request reference so it has not to be checked here again */
107 result = E_IA_TMA; /* 1st part of TWO MESSAGE ASSIGNMENT */
108 }
109 else if(d_imm_assign->d_t EQ D_T_DED)
110 {
111 result = E_IA_DCCH;
112 }
113 else if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
114 d_imm_assign->ia_rest_oct.ia_assign_par.v_pck_upl_ass_ia AND
115 d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia.v_tfi_ass_alloc)
116 {
117 T_pck_upl_ass_ia *pck_upl_ass_ia =
118 &(d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia);
119 p_tfi_ass = &(pck_upl_ass_ia->tfi_ass_alloc); /* more contents than before*/
120
121 grr_data->uplink_tbf.ts_usage = (0x80>>d_imm_assign->pck_chan_desc.tn);
122 grr_data->uplink_tbf.nts = 1;
123 /*
124 * handle polling bit
125 */
126 if(p_tfi_ass->poll AND
127 (!grr_check_if_tbf_start_is_elapsed(grr_decode_tbf_start_abs((T_abs *)&d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia.tfi_ass_alloc.tbf_start_time ),grr_data->ul_fn)))
128 grr_data->uplink_tbf.polling_bit = d_imm_assign->pck_chan_desc.tn;
129 else
130 grr_data->uplink_tbf.polling_bit = 0xFF;
131
132 grr_data->uplink_tbf.cs_mode = p_tfi_ass->ccm;
133 grr_data->uplink_tbf.tlli_cs_mode = p_tfi_ass->tlli_bcc;
134
135
136
137 if(p_tfi_ass->allo_flag EQ 0) /* Dynamic Allocation */
138 {
139 if(p_tfi_ass->v_usf AND p_tfi_ass->v_usf_gran)
140 {
141 result = E_IA_UL; /* Dynamic Allocation */
142 grr_data->uplink_tbf.mac_mode = CGRLC_MAC_MODE_DA;
143 }
144 else /* dynamic alloc but no usf value */
145 {
146 result = E_IA_ERROR_RA;
147 TRACE_ERROR("dynamic alloc but no usf value!");
148 }
149 }
150 else /*fixed alloc*/
151 if (p_tfi_ass->v_allo_len5 AND p_tfi_ass->v_allo_bmp5 AND
152 p_tfi_ass->v_tbf_start_time)
153 {
154 result = E_IA_UL; /* Fixed Allocation */
155 grr_data->uplink_tbf.mac_mode = CGRLC_MAC_MODE_FA;
156 }
157 else /* fixed alloc but no alloc bitmap or tbf starting time */
158 {
159 result = E_IA_ERROR_RA;
160 TRACE_ERROR("fixed alloc but no alloc bitmap or tbf starting time!");
161 }
162
163 if (!cpap_check_and_save_freq())
164 {
165 result = E_IA_ERROR_RA;
166 TRACE_EVENT("cpap_eval_ia: return E_IA_ERROR_RA (frequencies wrong)");
167 }
168
169 if( result NEQ E_IA_ERROR_RA )
170 {
171 /* process power control parameter */
172 grr_store_type_pck_upl_ass_ia( p_tfi_ass,
173 d_imm_assign->pck_chan_desc.tn );
174 }
175 }
176 else if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
177 d_imm_assign->ia_rest_oct.ia_assign_par.v_pck_upl_ass_ia AND
178 d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia.v_sngl_block_alloc)
179 { /* single block */
180 T_sngl_block_alloc *sngl_block_ass =
181 &d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia.sngl_block_alloc;
182
183 if( grr_data->tc.v_sb_without_tbf )
184 {
185 result = E_IA_SB_WITHOUT_TBF;
186 }
187 else
188 {
189 result = E_IA_SB_2PHASE_ACCESS;
190 }
191
192 if (!cpap_check_and_save_freq())
193 {
194 result = E_IA_ERROR_RA;
195 TRACE_EVENT("cpap_eval_ia: return E_IA_ERROR_RA (frequencies wrong)");
196 }
197
198 if( result NEQ E_IA_ERROR_RA )
199 {
200 /* process power control parameter */
201 grr_store_type_pck_snbl_ass_ia( sngl_block_ass,
202 d_imm_assign->pck_chan_desc.tn );
203 }
204 }
205 else if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
206 d_imm_assign->ia_rest_oct.ia_assign_par.v_ia_2nd_part)
207 {
208 result = E_IA_TMA_SECOND;
209 }
210 else
211 {
212 result = E_IA_ERROR_RA;
213 TRACE_ERROR("corrupted message recieved!");
214 }
215 return(result);
216 } /* cpap_eval_ia() */
217
218
219
220
221 /*
222 +------------------------------------------------------------------------------
223 | Function : cpap_eval_ia_dl
224 +------------------------------------------------------------------------------
225 | Description : The function cpap_eval_ia_dl() ....
226 |
227 | Parameters : void
228 |
229 +------------------------------------------------------------------------------
230 */
231 GLOBAL T_EVAL_IA_DL cpap_eval_ia_dl ( void )
232 {
233 MCAST(d_imm_assign,D_IMM_ASSIGN);/* T_D_IMM_ASSIGN */
234 T_EVAL_IA_DL result = E_IA_DL_IGNORE;
235 T_pck_downl_ass_ia * p_dl_assign;
236
237 TRACE_FUNCTION( "cpap_eval_ia_dl" );
238
239 if(d_imm_assign->d_t EQ D_T_DED)
240 {
241 result = E_IA_DL_DCCH;
242 }
243 else if(d_imm_assign->tma EQ TMA_1)
244 {
245 /* the 1st message is only delivered by rr if the 2nd message has arrived */
246 /* with correct request reference so it has not to be checked here again */
247 if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
248 d_imm_assign->ia_rest_oct.ia_assign_par.v_pck_downl_ass_ia AND
249 d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia.v_tfi_ass_rlc)
250 {
251 p_dl_assign =
252 &(d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia);
253 if(grr_check_all_tlli((BUF_tlli_value *)&(p_dl_assign->ded_tlli)))
254 {
255 result = E_IA_DL_TMA;
256 }
257 else
258 {
259 result = E_IA_DL_NOT_OURS;
260 }
261 }
262 else
263 {
264 result = E_IA_DL_IGNORE;
265 TRACE_ERROR("the 1st message is only delivered by rr if the 2nd message has arrived");
266 }
267 }
268 else if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
269 d_imm_assign->ia_rest_oct.ia_assign_par.v_pck_downl_ass_ia AND
270 d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia.v_tfi_ass_rlc)
271 {
272 p_dl_assign =
273 &(d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia);
274 if(grr_check_all_tlli((BUF_tlli_value *)&(p_dl_assign->ded_tlli)))
275 {
276 result = E_IA_DL_ASSIGN;
277 grr_data->downlink_tbf.ts_usage = (0x80>>d_imm_assign->pck_chan_desc.tn);
278 grr_data->downlink_tbf.nts = 1;
279 /*
280 * handle polling bit
281 */
282 if(p_dl_assign->tfi_ass_rlc.poll AND
283 (!grr_check_if_tbf_start_is_elapsed(grr_decode_tbf_start_abs((T_abs *)&d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia.tbf_start_time ),grr_data->ul_fn)))
284 grr_data->downlink_tbf.polling_bit = d_imm_assign->pck_chan_desc.tn;
285 else
286 grr_data->downlink_tbf.polling_bit = 0xFF;
287
288 grr_data->downlink_tbf.mac_mode = DA; /* by default set to */
289 grr_data->downlink_tbf.t3192 = FALSE; /* indicates if t3192 is running*/
290 grr_data->downlink_tbf.rlc_mode = p_dl_assign->tfi_ass_rlc.rlc_mode;
291 grr_data->downlink_tbf.ctrl_ack_bit= 0;
292
293 if (!cpap_check_and_save_freq())
294 {
295 result = E_IA_DL_IGNORE;
296 TRACE_EVENT("cpap_eval_ia_dl: return E_IA_DL_IGNORE (frequencies wrong)");
297 }
298
299 if( result EQ E_IA_DL_ASSIGN )
300 {
301 grr_store_type_tfi_ass_rlc( &p_dl_assign->tfi_ass_rlc,
302 d_imm_assign->pck_chan_desc.tn );
303 }
304 }
305 else
306 {
307 result = E_IA_DL_NOT_OURS;
308 }
309 }
310 else if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
311 d_imm_assign->ia_rest_oct.ia_assign_par.v_pck_downl_ass_ia AND
312 d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia.v_tbf_start_time)
313 {
314 p_dl_assign =
315 &(d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia);
316 if(grr_check_all_tlli((BUF_tlli_value *)&(p_dl_assign->ded_tlli)))
317 {
318 result = E_IA_DL_SB;
319 if (!cpap_check_and_save_freq())
320 {
321 result = E_IA_DL_IGNORE;
322 TRACE_EVENT("cpap_eval_ia_dl: return E_IA_DL_IGNORE (frequencies wrong)");
323 }
324 }
325 else
326 {
327 result = E_IA_DL_NOT_OURS;
328 }
329 }
330 else if(d_imm_assign->ia_rest_oct.v_ia_assign_par AND
331 d_imm_assign->ia_rest_oct.ia_assign_par.v_ia_2nd_part)
332 {
333 result = E_IA_DL_TMA_SECOND;
334 }
335
336 if(result EQ E_IA_DL_IGNORE)
337 {
338 TRACE_ERROR("None of the if switches were reached LINE 330 cpapf");
339 }
340 return(result);
341 } /* cpap_eval_ia_dl() */
342
343
344 /*
345 +------------------------------------------------------------------------------
346 | Function : cpap_eval_pdch_assignment
347 +------------------------------------------------------------------------------
348 | Description : The function cpap_eval_pdch_assignment() ....
349 |
350 | Parameters : void
351 |
352 +------------------------------------------------------------------------------
353 */
354 GLOBAL T_EVAL_PDCH_ASSIGN cpap_eval_pdch_assignment ( void )
355 {
356 MCAST(d_pdch_ass_cmd,D_PDCH_ASS_CMD);/* T_D_PDCH_ASS_CMD */
357 T_EVAL_PDCH_ASSIGN result = E_PDCH_ASSIGN_IGNORE;
358
359 TRACE_FUNCTION( "cpap_eval_pdch_assignment" );
360
361 if(d_pdch_ass_cmd->msg_type EQ D_PDCH_ASS_CMD)
362 {
363 if(!(d_pdch_ass_cmd->v_pck_ul_ass OR d_pdch_ass_cmd->v_pck_dl_ass))
364 {
365 result = E_PDCH_ASSIGN_ERROR;
366 TRACE_ERROR("no Packet Assignment included in message");
367 }
368 else if(d_pdch_ass_cmd->v_pck_ul_ass AND d_pdch_ass_cmd->pck_ul_ass.v_dyn_alloc)
369 {
370 UBYTE tx_slots = 0, ts_usage = 0,i,mask;
371 grr_data->uplink_tbf.mac_mode = CGRLC_MAC_MODE_DA;
372 result = E_PDCH_ASSIGN_UL;
373 if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.v_tagged_usf_tn)
374 {
375 for(i = 0,mask = 0x80;i < 8;i++)
376 {
377 if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.tagged_usf_tn[i].v_usf)
378 {
379 ts_usage |= mask;
380 tx_slots++;
381 }
382 mask >>= 1;
383 }
384 }
385 else if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.v_usf_gamma_csn1)
386 {
387 for(i = 0,mask = 0x80;i < 8;i++)
388 {
389 if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.usf_gamma_csn1[i].v_usf_gamma)
390 {
391 ts_usage |= mask;
392 tx_slots++;
393 }
394 mask >>= 1;
395 }
396 }
397 grr_store_type_dyn_alloc( &d_pdch_ass_cmd->pck_ul_ass.dyn_alloc );
398
399 grr_data->uplink_tbf.ts_usage = ts_usage;
400 grr_data->uplink_tbf.nts = tx_slots;
401 if( !handle_ms_cap(UL_ASSIGNMENT) )
402 {
403 result = E_PDCH_ASSIGN_ERROR;
404 TRACE_ERROR("too much or no timeslot(s) assigned!");
405 }
406 }
407 else if(d_pdch_ass_cmd->v_pck_ul_ass AND
408 d_pdch_ass_cmd->pck_ul_ass.v_single_alloc)
409 {
410 result = E_PDCH_ASSIGN_SB;
411 if( d_pdch_ass_cmd->pck_ul_ass.single_alloc.v_alpha_gamma EQ TRUE )
412 {
413 grr_store_type_alpha_gamma
414 ( &d_pdch_ass_cmd->pck_ul_ass.single_alloc.alpha_gamma,
415 d_pdch_ass_cmd->pck_ul_ass.single_alloc.tn );
416 }
417
418 /* SZML-CPAP/029 */
419 }
420 else if(d_pdch_ass_cmd->v_pck_ul_ass AND
421 d_pdch_ass_cmd->pck_ul_ass.v_fix_alloc)
422 {
423 result = E_PDCH_ASSIGN_UL;
424 grr_data->uplink_tbf.mac_mode = CGRLC_MAC_MODE_FA;
425 if( d_pdch_ass_cmd->pck_ul_ass.fix_alloc.v_pwr_ctrl EQ TRUE )
426 {
427 grr_store_type_pwr_ctrl( &d_pdch_ass_cmd->pck_ul_ass.fix_alloc.pwr_ctrl );
428 }
429
430 /* SZML-CPAP/030 */
431 }
432 else if(d_pdch_ass_cmd->v_pck_dl_ass)
433 {
434 result = E_PDCH_ASSIGN_DL;
435 if( d_pdch_ass_cmd->pck_dl_ass.v_pwr_ctrl EQ TRUE )
436 {
437 grr_store_type_pwr_ctrl( &d_pdch_ass_cmd->pck_dl_ass.pwr_ctrl );
438 }
439
440 /* SZML-CPAP/031 */
441 }
442 }
443 else
444 {
445 TRACE_ERROR("wrong message type!");
446 }
447 return(result);
448 } /* cpap_eval_pdch_assignment() */
449
450
451 /*
452 +------------------------------------------------------------------------------
453 | Function : cpap_build_gprs_data_request
454 +------------------------------------------------------------------------------
455 | Description : The function cpap_build_gprs_data_request() ....
456 |
457 | Parameters : void
458 |
459 +------------------------------------------------------------------------------
460 */
461 GLOBAL void cpap_build_gprs_data_request (T_RRGRR_GPRS_DATA_REQ *rrgrr_gprs_data_req)
462 {
463 /* T_D_RR_INIT_REQ */ /* T_PRIM_QUEUE */
464 /* T_D_IMM_ASSIGN */ /* T_GRR_DATA_REQ */
465
466 TRACE_FUNCTION( "cpap_build_gprs_data_request" );
467
468 rrgrr_gprs_data_req->new_ptmsi = grr_data->db.ms_id.new_ptmsi;
469 rrgrr_gprs_data_req->old_ptmsi = grr_data->db.ms_id.old_ptmsi;
470
471 rrgrr_gprs_data_req->tlli = grr_data->db.ms_id.new_tlli;
472 rrgrr_gprs_data_req->rai = grr_data->db.ms_id.rai;
473 rrgrr_gprs_data_req->mac_req = DA;
474 rrgrr_gprs_data_req->cs_req = COD_S_1;
475 rrgrr_gprs_data_req->p_chan_req_des.mo_mt = OR_TY_MO;
476 if( grr_data->tc.v_sb_without_tbf )
477 {
478 rrgrr_gprs_data_req->p_chan_req_des.llc_type = LLC_NOT_ACK;
479 rrgrr_gprs_data_req->p_chan_req_des.rlc_mode_req = RLC_UNACK_MODE;
480 rrgrr_gprs_data_req->p_chan_req_des.prio = RADIO_PRIO_4;
481 rrgrr_gprs_data_req->p_chan_req_des.req_bwd = 80;/* 8000 bit/s */
482 rrgrr_gprs_data_req->p_chan_req_des.rlc_octets = 22;/* one RLC/MAC block */
483 }
484 else
485 {
486 UBYTE i=0;
487 USHORT j =1;
488 if(grr_data->uplink_tbf.prim_type EQ CGRLC_LLC_PRIM_TYPE_DATA_REQ)
489 { /* CGRLC_LLC_PRIM_TYPE_DATA_REQ */
490 rrgrr_gprs_data_req->p_chan_req_des.llc_type = LLC_NOT_ACK;
491 rrgrr_gprs_data_req->p_chan_req_des.rlc_mode_req = RLC_ACK_MODE;
492 }
493 else
494 { /* CGRLC_LLC_PRIM_TYPE_UNITDATA_REQ*/
495 rrgrr_gprs_data_req->p_chan_req_des.llc_type = LLC_IS_ACK;
496 rrgrr_gprs_data_req->p_chan_req_des.rlc_mode_req = RLC_UNACK_MODE;
497 }
498 rrgrr_gprs_data_req->p_chan_req_des.prio = grr_data->uplink_tbf.prio;
499
500 rrgrr_gprs_data_req->p_chan_req_des.req_bwd = 0;
501
502 for(i=2; i<=grr_data->uplink_tbf.peak;i++)
503 {
504 j *= 2;
505 }
506 if(grr_data->uplink_tbf.peak)
507 rrgrr_gprs_data_req->p_chan_req_des.req_bwd = j*80;
508
509 rrgrr_gprs_data_req->p_chan_req_des.rlc_octets = grr_data->uplink_tbf.rlc_oct_cnt;
510 }
511
512 rrgrr_gprs_data_req->gprs_meas_results.c_value = meas_c_get_value( );
513 rrgrr_gprs_data_req->gprs_meas_results.rxqual = 0;
514 rrgrr_gprs_data_req->gprs_meas_results.sign_var = 0;
515
516 } /* cpap_build_gprs_data_request() */
517
518
519
520
521 /*
522 +------------------------------------------------------------------------------
523 | Function : cpap_send_ass_fail
524 +------------------------------------------------------------------------------
525 | Description : The function cpap_send_ass_fail() ....
526 |
527 | Parameters : void
528 |
529 +------------------------------------------------------------------------------
530 */
531 GLOBAL void cpap_send_ass_fail (UBYTE cause)
532 {
533 TRACE_FUNCTION( "cpap_send_ass_fail" );
534 {
535 PALLOC_SDU(rrgrr_data_req,RRGRR_DATA_REQ,3*8);
536
537 rrgrr_data_req->sdu.l_buf = 3*8;
538 rrgrr_data_req->sdu.o_buf = 0;
539 rrgrr_data_req->sdu.buf[0] = 0x06; /* protocol discriminator & skip indicator */
540 rrgrr_data_req->sdu.buf[1] = U_ASSIGN_FAIL; /* message type */ /*lint !e415*/
541 rrgrr_data_req->sdu.buf[2] = cause; /* RRC_CHANNEL_MODE*/ /* assignment failure cause */ /*lint !e415 !e416*/
542 sig_cpap_tc_dcch_data_req(rrgrr_data_req);
543 }
544 } /* cpap_send_ass_fail() */
545
546
547 /*
548 +------------------------------------------------------------------------------
549 | Function : cpap_send_assign_req_pdch
550 +------------------------------------------------------------------------------
551 | Description : The function cpap_send_assign_req_pdch() builds MPHP_ASSIGNMENT_REQ
552 | and send it.
553 |
554 | Parameters : tbf_type_i - type of TBF that is to activate
555 |
556 +------------------------------------------------------------------------------
557 */
558 GLOBAL void cpap_send_assign_req_pdch (T_TBF_TYPE tbf_type_i)
559 {
560 TRACE_FUNCTION( "cpap_send_assign_req_pdch" );
561 {
562 PALLOC(ptr2prim,MPHP_ASSIGNMENT_REQ);
563
564 memset(ptr2prim,0,sizeof(T_MPHP_ASSIGNMENT_REQ));
565
566 grr_set_tbf_cfg_req_param( ptr2prim );
567
568 switch( tbf_type_i )
569 {
570 case CGRLC_TBF_MODE_UL:
571 ptr2prim->assign_cmd = UL_ASSIGNMENT;
572 if(grr_data->uplink_tbf.mac_mode EQ CGRLC_MAC_MODE_DA)
573 cpap_set_da_assignment_pdch(ptr2prim);
574 else
575 {
576 /* SZML-CPAP/032 */
577 }
578
579 sig_cpap_tc_assign_pdch(ptr2prim, PDCH_UL_ASS_CMD);
580 break;
581 case CGRLC_TBF_MODE_DL:
582 ptr2prim->assign_cmd = DL_ASSIGNMENT;
583 cpap_set_dl_assignment_pdch(ptr2prim);
584 sig_cpap_tc_assign_pdch(ptr2prim, PDCH_DL_ASS_CMD);
585 break;
586 default:
587 PFREE(ptr2prim);
588 TRACE_ERROR ( "unknown tbf type!" );
589 break;
590 } /* switch (tbf_type_i) */
591 }
592 } /* cpap_send_assign_req_pdch() */
593
594
595 /*
596 +------------------------------------------------------------------------------
597 | Function : cpap_set_da_assignment_pdch
598 +------------------------------------------------------------------------------
599 | Description : This function sets some parameter of MPHP_ASSIGFNMENT_REQ in
600 | case of uplink dynamic allocation.
601 |
602 | Parameters : ptr2prim_i - ptr to mphp_assignment_req
603 |
604 +------------------------------------------------------------------------------
605 */
606 LOCAL void cpap_set_da_assignment_pdch (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i)
607 {
608 UBYTE i;
609 MCAST(d_pdch_ass_cmd,D_PDCH_ASS_CMD); /* T_D_PDCH_ASS_CMD */
610 /* T_D_IMM_ASSIGN */
611
612 TRACE_FUNCTION( "cpap_set_da_assignment_pdch" );
613 if( d_pdch_ass_cmd->msg_type EQ D_PDCH_ASS_CMD)
614 {
615 /* bts downlink power control parameters */
616 if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.v_p0)
617 ptr2prim_i->p_dl_power.p0 = d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.p0;
618 else
619 ptr2prim_i->p_dl_power.p0 = 0xff;
620 /* dynamic allocation must use mode a */
621 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode = MODE_A;
622 ptr2prim_i->p_dl_power.pr_mode = PR_MODE_A_ONE;
623 /*
624 * timing advance
625 */
626 if(d_pdch_ass_cmd->pck_ul_ass.pck_ta.v_ta)
627 {
628 ptr2prim_i->p_timing_advance.ta_value =
629 d_pdch_ass_cmd->pck_ul_ass.pck_ta.ta;
630 }
631 else
632 {
633 ptr2prim_i->p_timing_advance.ta_value = 0xff;
634 }
635 if(d_pdch_ass_cmd->pck_ul_ass.pck_ta.v_ta_idx_nm)
636 {
637 ptr2prim_i->p_timing_advance.ta_index =
638 d_pdch_ass_cmd->pck_ul_ass.pck_ta.ta_idx_nm.ta_idx;
639 ptr2prim_i->p_timing_advance.tn =
640 d_pdch_ass_cmd->pck_ul_ass.pck_ta.ta_idx_nm.ta_nm;
641 }
642 else
643 {
644 ptr2prim_i->p_timing_advance.ta_index = 0xff;
645 ptr2prim_i->p_timing_advance.tn = 0xff;
646 }
647 /*
648 * trainings sequence
649 */
650 ptr2prim_i->tsc = d_pdch_ass_cmd->chan_desc.tsc;
651 /*
652 * frequency parameters
653 */
654 if(!d_pdch_ass_cmd->chan_desc.hop)
655 {
656 if(d_pdch_ass_cmd->chan_desc.v_arfcn)
657 {
658 ptr2prim_i->p_frequency_par.p_chan_sel.hopping=0;
659 memset(ptr2prim_i->p_frequency_par.p_freq_list.p_rf_chan_no.p_radio_freq,0,MPHP_NUMC_MA);
660 ptr2prim_i->p_frequency_par.p_chan_sel.p_rf_ch.arfcn =
661 grr_g23_arfcn_to_l1(d_pdch_ass_cmd->chan_desc.arfcn);
662 }
663 }
664 /* SZML-CPAP/002 */
665 /* SZML-CPAP/003 */
666 /*
667 * mac mode
668 */
669 ptr2prim_i->mac_mode =
670 (d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.ext_dyn_all)? EDA:DA;
671 /*
672 * uplink allocation structure
673 */
674 if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.v_tfi)
675 ptr2prim_i->p_ul_alloc.ul_tfi = d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.tfi;
676 else
677 ptr2prim_i->p_ul_alloc.ul_tfi = grr_data->uplink_tbf.tfi;
678 ptr2prim_i->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
679 /*
680 * dynamic allocation structure
681 */
682 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_gran =
683 d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.usf_gran;
684 if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.v_tagged_usf_tn)
685 {
686 for(i = 0;i < 8;i++)
687 {
688 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
689 d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.tagged_usf_tn[i].usf;
690 }
691 }
692 else if(d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.v_usf_gamma_csn1)
693 {
694 for(i = 0;i < 8;i++)
695 {
696 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
697 d_pdch_ass_cmd->pck_ul_ass.dyn_alloc.usf_gamma_csn1[i].usf_gamma.usf;
698 }
699 }
700 else
701 {
702 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[0] = 5;
703 TRACE_EVENT("USF-Error: set (hardcoded) USF_TN0 = 0x05");
704 }
705 /*
706 * TBF starting time
707 */
708 if(d_pdch_ass_cmd->v_start_time)
709 {
710 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
711 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs *)&d_pdch_ass_cmd->start_time);
712 if(d_pdch_ass_cmd->v_chan_desc_before)
713 {
714 PALLOC(ptr2prim2,MPHP_ASSIGNMENT_REQ);
715 memset(ptr2prim2,0,sizeof(T_MPHP_ASSIGNMENT_REQ));
716
717 grr_set_tbf_cfg_req_param( ptr2prim2 );
718
719 ptr2prim2->assign_cmd = UL_ASSIGNMENT;
720 ptr2prim2->p_dl_power.p0 = ptr2prim_i->p_dl_power.p0;
721 ptr2prim2->p_dl_power.bts_pwr_ctl_mode =
722 ptr2prim_i->p_dl_power.bts_pwr_ctl_mode;
723 ptr2prim2->p_dl_power.pr_mode = ptr2prim_i->p_dl_power.pr_mode;
724 ptr2prim2->p_timing_advance.ta_value =
725 ptr2prim_i->p_timing_advance.ta_value;
726 ptr2prim2->p_timing_advance.ta_index =
727 ptr2prim_i->p_timing_advance.ta_index;
728 ptr2prim2->p_timing_advance.tn = ptr2prim_i->p_timing_advance.tn;
729 /* trainings sequence */
730 ptr2prim2->tsc = d_pdch_ass_cmd->chan_desc_before.tsc;
731 /* frequency parameters */
732 if(!d_pdch_ass_cmd->chan_desc_before.hop)
733 {
734 if(d_pdch_ass_cmd->chan_desc_before.v_arfcn)
735 {
736 ptr2prim_i->p_frequency_par.p_chan_sel.hopping=0;
737 memset(ptr2prim_i->p_frequency_par.p_freq_list.p_rf_chan_no.p_radio_freq,0,MPHP_NUMC_MA);
738 ptr2prim_i->p_frequency_par.p_chan_sel.p_rf_ch.arfcn =
739 grr_g23_arfcn_to_l1(d_pdch_ass_cmd->chan_desc_before.arfcn);
740 }
741 }
742 /* SZML-CPAP/004 */
743 /* SZML-CPAP/005 */
744 /* mac mode */
745 ptr2prim2->mac_mode = ptr2prim_i->mac_mode;
746 /* uplink allocation structure */
747 /* take from grr_data to avoide mistakes */
748 ptr2prim2->p_ul_alloc.ul_tfi = ptr2prim_i->p_ul_alloc.ul_tfi;
749 ptr2prim2->p_ul_alloc.ts_mask = ptr2prim_i->p_ul_alloc.ts_mask;
750 /* dynamic allocation structure */
751 ptr2prim2->p_ul_alloc.p_dynamic_alloc.usf_gran =
752 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_gran;
753 for(i = 0;i < 8;i++)
754 {
755 ptr2prim2->p_ul_alloc.p_dynamic_alloc.usf_table[i] =
756 ptr2prim_i->p_ul_alloc.p_dynamic_alloc.usf_table[i];
757 }
758 ptr2prim2->p_tbf_start.tbf_start_present = 0;
759 sig_cpap_tc_assign_pdch(ptr2prim2, PDCH_UL_ASS_CMD);
760 } /* if(d_pdch_ass_cmd->v_chan_desc_before) */
761 }
762 else /* if(d_pdch_ass_cmd->v_start_time) */
763 {
764 ptr2prim_i->p_tbf_start.tbf_start_present = 0;
765 ptr2prim_i->p_tbf_start.fn = 0xFFFFFFFF;
766 }
767 }
768 else /* if( d_pdch_ass_cmd->msg_type EQ D_PDCH_ASS_CMD) */
769 {
770 TRACE_ERROR ( "Wrong message type in _decodedCtrlMsg" );
771 }
772
773
774 if(ptr2prim_i->p_tbf_start.tbf_start_present)
775 grr_data->uplink_tbf.tbf_start_fn = ptr2prim_i->p_tbf_start.fn;
776 else
777 grr_data->uplink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
778
779 grr_data->uplink_tbf.st_tfi = ptr2prim_i->p_ul_alloc.ul_tfi;
780 grr_data->uplink_tbf.mac_mode = DA;
781
782 return;
783 } /* cpap_set_da_assignment_pdch */
784
785
786
787
788
789 /*
790 +------------------------------------------------------------------------------
791 | Function : cpap_set_dl_assignment_pdch
792 +------------------------------------------------------------------------------
793 | Description : This function sets some parameter of T_MPHP_ASSIGNMENT_REQ is
794 | case of ia downlink allocation
795 |
796 | Parameters : ptr2prim_i - ptr to MPHP_ASSIGNMENT_REQ
797 |
798 +------------------------------------------------------------------------------
799 */
800 LOCAL void cpap_set_dl_assignment_pdch (T_MPHP_ASSIGNMENT_REQ * ptr2prim_i)
801 {
802 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
803 T_pck_downl_ass_ia *ptr2dl_assign;
804
805 TRACE_FUNCTION( "cpap_set_dl_assignment_pdch" );
806 if( d_imm_assign->msg_type EQ D_IMM_ASSIGN)
807 {
808 ptr2dl_assign =
809 &d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia;
810 /*
811 * timing advance
812 */
813 if (ptr2dl_assign->tfi_ass_rlc.ta_valid)
814 {
815 ptr2prim_i->p_timing_advance.ta_value = d_imm_assign->time_advance.ta;
816 }
817 else
818 {
819 ptr2prim_i->p_timing_advance.ta_value = 0xff;
820 }
821 if(ptr2dl_assign->v_ta_idx)
822 {
823 ptr2prim_i->p_timing_advance.ta_index = ptr2dl_assign->ta_idx;
824 ptr2prim_i->p_timing_advance.tn = d_imm_assign->pck_chan_desc.tn;
825 }
826 else
827 {
828 ptr2prim_i->p_timing_advance.ta_index = 0xff;
829 ptr2prim_i->p_timing_advance.tn = 0xff;
830 }
831 /*
832 * trainings sequence
833 */
834 ptr2prim_i->tsc = d_imm_assign->pck_chan_desc.tsc;
835 /*
836 * TBF starting time
837 */
838 if(ptr2dl_assign->v_tbf_start_time)
839 {
840 ptr2prim_i->p_tbf_start.tbf_start_present = 1;
841 ptr2prim_i->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs *)&ptr2dl_assign->tbf_start_time);
842 }
843 else
844 {
845 ptr2prim_i->p_tbf_start.tbf_start_present = 0;
846 }
847 /*
848 * mac mode
849 */
850 ptr2prim_i->mac_mode = DA;
851 /*
852 * downlink allocation structure
853 */
854 ptr2prim_i->p_dl_alloc.dl_tfi = grr_data->downlink_tbf.tfi; /* take from grr_data to avoide mistakes */
855 ptr2prim_i->p_dl_alloc.ts_mask = grr_data->downlink_tbf.ts_usage;
856
857
858 if(ptr2prim_i->p_tbf_start.tbf_start_present)
859 grr_data->downlink_tbf.tbf_start_fn = ptr2prim_i->p_tbf_start.fn;
860 else
861 grr_data->downlink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
862
863 grr_data->downlink_tbf.st_tfi = ptr2prim_i->p_dl_alloc.dl_tfi;
864 grr_data->downlink_tbf.mac_mode = DA;
865
866 }
867 return;
868 } /* cpap_set_dl_assignment_pdch() */
869
870
871 /*
872 +------------------------------------------------------------------------------
873 | Function : cpap_send_assign_req_ia
874 +------------------------------------------------------------------------------
875 | Description : The function cpap_send_assign_req_ia() builds MPHP_ASSIGNMENT_REQ
876 | and send it.
877 |
878 | Parameters : tbf_type_i - type of TBF that is to activate
879 |
880 +------------------------------------------------------------------------------
881 */
882 GLOBAL BOOL cpap_send_assign_req_ia ( T_TBF_TYPE tbf_type_i )
883 {
884 T_MPHP_ASSIGNMENT_REQ *ptr2prim = NULL;
885
886 TRACE_FUNCTION( "cpap_send_assign_req_ia" );
887
888 ptr2prim = tc_set_freq();
889 if(NULL EQ ptr2prim)
890 {
891 return FALSE;
892 }
893
894 grr_set_tbf_cfg_req_param( ptr2prim );
895
896 switch( tbf_type_i )
897 {
898 case CGRLC_TBF_MODE_UL:
899 ptr2prim->assign_cmd = UL_ASSIGNMENT;
900 if(grr_data->uplink_tbf.mac_mode EQ CGRLC_MAC_MODE_DA)
901 cpap_set_da_assignment_ia(ptr2prim);
902 else if(!cpap_set_fa_assignment_ia(ptr2prim))
903 {
904 PFREE(ptr2prim);
905 return FALSE;
906 }
907 sig_cpap_tc_assign_pdch( ptr2prim, IA_UL );
908 break;
909 case CGRLC_TBF_MODE_DL:
910 ptr2prim->assign_cmd = DL_ASSIGNMENT;
911 cpap_set_dl_assignment_ia(ptr2prim);
912 sig_cpap_tc_assign_pdch( ptr2prim, IA_DL );
913 break;
914 default:
915 return FALSE;
916 } /* switch (tbf_type_i) */
917 return TRUE;
918 } /* cpap_send_assign_req_ia() */
919
920
921 /*
922 +------------------------------------------------------------------------------
923 | Function : cpap_set_da_assignment_ia
924 +------------------------------------------------------------------------------
925 | Description : This function sets some parameter of MPHP_ASSIGFNMENT_REQ in
926 | case of uplink dynamic allocation.
927 |
928 | Parameters : ptr2prim_i - ptr to mphp_assignment_req
929 |
930 +------------------------------------------------------------------------------
931 */
932 GLOBAL void cpap_set_da_assignment_ia (T_MPHP_ASSIGNMENT_REQ *ptr2prim)
933 {
934 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
935 T_pck_upl_ass_ia *ptr2ul_assign;
936
937 TRACE_FUNCTION( "cpap_set_da_assignment_ia" );
938
939 if( d_imm_assign->msg_type EQ D_IMM_ASSIGN)
940 {
941 /*
942 * timing advance
943 */
944 ptr2ul_assign =
945 &d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia;
946 if(ptr2ul_assign->v_tfi_ass_alloc AND ptr2ul_assign->tfi_ass_alloc.v_p0_prmode)
947 {
948 ptr2prim->p_dl_power.p0 = ptr2ul_assign->tfi_ass_alloc.p0_prmode.p0;
949 ptr2prim->p_dl_power.pr_mode =
950 ptr2ul_assign->tfi_ass_alloc.p0_prmode.pr_mode;
951 }
952 else
953 {
954 ptr2prim->p_dl_power.p0 = 0xff;
955 }
956 /* Timing Advance */
957 grr_data->ta_params.ta_valid = TRUE;
958 grr_handle_ta ( 1, /* always present in Immediate Assignment*/
959 d_imm_assign->time_advance.ta,
960 ptr2ul_assign->tfi_ass_alloc.v_ta_idx,
961 ptr2ul_assign->tfi_ass_alloc.ta_idx,
962 d_imm_assign->pck_chan_desc.tn,
963 0xFF,
964 0,
965 0,
966 &ptr2prim->p_timing_advance);
967
968 /* TBF starting time */
969 if(ptr2ul_assign->tfi_ass_alloc.v_tbf_start_time)
970 {
971 ptr2prim->p_tbf_start.tbf_start_present = 1;
972 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs *)&ptr2ul_assign->tfi_ass_alloc.tbf_start_time);
973 }
974 else
975 {
976 ptr2prim->p_tbf_start.tbf_start_present = 0;
977 }
978 /*
979 * mac mode
980 */
981 ptr2prim->mac_mode = DA;
982 /*
983 * uplink allocation structure
984 */
985 /* take from grr_data to avoide mistakes */
986 ptr2prim->p_ul_alloc.ul_tfi = ptr2ul_assign->tfi_ass_alloc.tfi;
987 ptr2prim->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
988 /*
989 * dynamic allocation structure
990 */
991 ptr2prim->p_ul_alloc.p_dynamic_alloc.usf_gran =
992 ptr2ul_assign->tfi_ass_alloc.usf_gran;
993 if(ptr2ul_assign->tfi_ass_alloc.v_usf)
994 {
995 ptr2prim->p_ul_alloc.p_dynamic_alloc.usf_table[
996 d_imm_assign->pck_chan_desc.tn] = ptr2ul_assign->tfi_ass_alloc.usf;
997 }
998 else
999 {
1000 ptr2prim->p_ul_alloc.p_dynamic_alloc.usf_table[
1001 d_imm_assign->pck_chan_desc.tn] = 5;
1002 TRACE_EVENT("USF-Error: set (hardcoded) USF_TN0 = 0x05");
1003 }
1004 }
1005 else
1006 {
1007 TRACE_ERROR ( "Wrong message type in _decodedCtrlMsg" );
1008 }
1009
1010
1011 if(ptr2prim->p_tbf_start.tbf_start_present)
1012 grr_data->uplink_tbf.tbf_start_fn = ptr2prim->p_tbf_start.fn;
1013 else
1014 grr_data->uplink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
1015
1016 grr_data->uplink_tbf.st_tfi = ptr2prim->p_ul_alloc.ul_tfi;
1017 grr_data->uplink_tbf.mac_mode = DA;
1018
1019
1020 return;
1021 } /* cpap_set_da_assignment_ia */
1022
1023
1024 /*
1025 +------------------------------------------------------------------------------
1026 | Function : cpap_set_fa_assignment_ia
1027 +------------------------------------------------------------------------------
1028 | Description : This function sets some parameter of MPHP_ASSIGFNMENT_REQ in
1029 | case of uplink fixed allocation.
1030 |
1031 | Parameters : ptr2prim_i - ptr to mphp_assignment_req
1032 |
1033 +------------------------------------------------------------------------------
1034 */
1035 GLOBAL UBYTE cpap_set_fa_assignment_ia (T_MPHP_ASSIGNMENT_REQ *ptr2prim)
1036 {
1037 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
1038 T_pck_upl_ass_ia *ptr2ul_assign;
1039
1040 TRACE_FUNCTION( "cpap_set_fa_assignment_ia" );
1041
1042 ptr2ul_assign =
1043 &d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia;
1044 if( d_imm_assign->msg_type EQ D_IMM_ASSIGN)
1045 {
1046 /* PO, BTS_POWER_MODE and PR_ MODE */
1047 if(ptr2ul_assign->v_tfi_ass_alloc AND ptr2ul_assign->tfi_ass_alloc.v_p0_bts_prmode)
1048 {
1049 ptr2prim->p_dl_power.p0 = ptr2ul_assign->tfi_ass_alloc.p0_bts_prmode.p0;
1050 ptr2prim->p_dl_power.bts_pwr_ctl_mode = ptr2ul_assign->tfi_ass_alloc.p0_bts_prmode.pwr_ctrl_mode;
1051 ptr2prim->p_dl_power.pr_mode = ptr2ul_assign->tfi_ass_alloc.p0_bts_prmode.pr_mode;
1052 }
1053 else
1054 {
1055 ptr2prim->p_dl_power.p0 = 0xff;
1056 }
1057 /*
1058 * timing advance
1059 */
1060 grr_data->ta_params.ta_valid = TRUE;
1061 grr_handle_ta ( 1, /* always present in Immediate Assignment*/
1062 d_imm_assign->time_advance.ta,
1063 ptr2ul_assign->tfi_ass_alloc.v_ta_idx,
1064 ptr2ul_assign->tfi_ass_alloc.ta_idx,
1065 d_imm_assign->pck_chan_desc.tn,
1066 0xFF,
1067 0,
1068 0,
1069 &ptr2prim->p_timing_advance);
1070 /*
1071 * mac mode
1072 */
1073 ptr2prim->mac_mode = FA;
1074 /*
1075 * uplink allocation structure
1076 */
1077 /* take from grr_data to avoide mistakes */
1078 ptr2prim->p_ul_alloc.ul_tfi = ptr2ul_assign->tfi_ass_alloc.tfi;
1079 ptr2prim->p_ul_alloc.ts_mask = grr_data->uplink_tbf.ts_usage;
1080 /* TBF starting time */
1081 if(ptr2ul_assign->tfi_ass_alloc.v_tbf_start_time)
1082 {
1083 ptr2prim->p_tbf_start.tbf_start_present = 1;
1084 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs *)&ptr2ul_assign->tfi_ass_alloc.tbf_start_time);
1085 }
1086 else
1087 {
1088 TRACE_ERROR("IA FIX ALLOC WITHOUT TBF STARTING TIME");
1089 return FALSE;
1090 }
1091 /*
1092 * DOWNLINK_CONTROL_TIMESLOT parameter shall always indicate a timeslot number
1093 * which is used for TBF uplink. GSM 04.60 Chapter 8.1.1.3.4
1094 */
1095 switch(grr_data->uplink_tbf.ts_usage)
1096 {
1097 case 1:
1098 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 7;
1099 break;
1100 case 2:
1101 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 6;
1102 break;
1103 case 4:
1104 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 5;
1105 break;
1106 case 8:
1107 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 4;
1108 break;
1109 case 16:
1110 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 3;
1111 break;
1112 case 32:
1113 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 2;
1114 break;
1115 case 64:
1116 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 1;
1117 break;
1118 case 128:
1119 ptr2prim->p_ul_alloc.p_fixed_alloc.dl_ctrl_ts = 0;
1120 break;
1121 }
1122
1123 /*
1124 * ALLOCATION BITMAP tc function call not allowed
1125 */
1126 grr_data->tc.fa_ctrl.fa_type = FA_NO_CURRENT;
1127 tc_calc_fa_bitmap(ptr2prim->p_tbf_start.fn, /* starting time of cuurent tbf*/
1128 1, /* block periods*/
1129 ptr2ul_assign->tfi_ass_alloc.allo_len5, /* bitmap length */
1130 ptr2ul_assign->tfi_ass_alloc.allo_bmp5, /* ptr to alloc struct*/
1131 &ptr2prim->p_ul_alloc.p_fixed_alloc); /* ptr to fix sttruct*/
1132 }
1133 else
1134 {
1135 TRACE_ERROR ( "Wrong message type in _decodedCtrlMsg" );
1136 }
1137
1138
1139 if(ptr2prim->p_tbf_start.tbf_start_present)
1140 grr_data->uplink_tbf.tbf_start_fn = ptr2prim->p_tbf_start.fn;
1141 else
1142 grr_data->uplink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
1143
1144 grr_data->uplink_tbf.st_tfi = ptr2prim->p_ul_alloc.ul_tfi;
1145 grr_data->uplink_tbf.mac_mode = FA;
1146
1147 return TRUE;
1148 } /* cpap_set_fa_assignment_ia */
1149
1150
1151 /*
1152 +------------------------------------------------------------------------------
1153 | Function : cpap_set_dl_assignment_ia
1154 +------------------------------------------------------------------------------
1155 | Description : This function sets some parameter of T_MPHP_ASSIGNMENT_REQ is
1156 | case of ia downlink allocation
1157 |
1158 | Parameters : ptr2prim_i - ptr to MPHP_ASSIGNMENT_REQ
1159 |
1160 +------------------------------------------------------------------------------
1161 */
1162 GLOBAL void cpap_set_dl_assignment_ia (T_MPHP_ASSIGNMENT_REQ *ptr2prim)
1163 {
1164 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
1165 T_pck_downl_ass_ia *ptr2dl_assign;
1166 TRACE_FUNCTION( "cpap_set_dl_assignment_ia" );
1167 if( d_imm_assign->msg_type EQ D_IMM_ASSIGN)
1168 {
1169 ptr2dl_assign = &d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia;
1170 if(ptr2dl_assign->v_p0_bts_prmode)
1171 {
1172 ptr2prim->p_dl_power.p0 = ptr2dl_assign->p0_bts_prmode.p0;
1173 ptr2prim->p_dl_power.bts_pwr_ctl_mode =
1174 ptr2dl_assign->p0_bts_prmode.pwr_ctrl_mode;
1175 ptr2prim->p_dl_power.pr_mode = ptr2dl_assign->p0_bts_prmode.pr_mode;
1176 }
1177 else
1178 {
1179 ptr2prim->p_dl_power.p0 = 0xff;
1180 }
1181 /*
1182 * timing advance
1183 */
1184 grr_handle_ta ( ptr2dl_assign->tfi_ass_rlc.ta_valid,
1185 d_imm_assign->time_advance.ta,
1186 0xFF,
1187 0,
1188 0,
1189 ptr2dl_assign->v_ta_idx,
1190 ptr2dl_assign->ta_idx,
1191 d_imm_assign->pck_chan_desc.tn,
1192 &ptr2prim->p_timing_advance);
1193 /*
1194 * TBF starting time
1195 */
1196 if(ptr2dl_assign->v_tbf_start_time)
1197 {
1198 ptr2prim->p_tbf_start.tbf_start_present = 1;
1199 ptr2prim->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs *)&ptr2dl_assign->tbf_start_time);
1200 }
1201 else
1202 {
1203 ptr2prim->p_tbf_start.tbf_start_present = 0;
1204 }
1205
1206 /* SZML-CPAP/008 */
1207 ptr2prim->mac_mode = DA;
1208 /*
1209 * downlink allocation structure
1210 */
1211 ptr2prim->p_dl_alloc.dl_tfi = ptr2dl_assign->tfi_ass_rlc.tfi;
1212 ptr2prim->p_dl_alloc.ts_mask = grr_data->downlink_tbf.ts_usage;
1213
1214
1215 if(ptr2prim->p_tbf_start.tbf_start_present)
1216 grr_data->downlink_tbf.tbf_start_fn = ptr2prim->p_tbf_start.fn;
1217 else
1218 grr_data->downlink_tbf.tbf_start_fn = CGRLC_STARTING_TIME_NOT_PRESENT;
1219
1220 grr_data->downlink_tbf.st_tfi = ptr2prim->p_dl_alloc.dl_tfi;
1221
1222 }
1223 return;
1224 } /* cpap_set_dl_assignment_ia() */
1225
1226
1227 /*
1228 +------------------------------------------------------------------------------
1229 | Function : cpap_send_resource_request_ia
1230 +------------------------------------------------------------------------------
1231 | Description : The function cpap_send_resource_request_ia() sends the primitive
1232 | MPHP_SINGLE_BLOCK_REQ with Packet Resource Request
1233 | for two phase access due to the reception of a Immediate
1234 | Assignment message.
1235 |
1236 | Parameters : void
1237 |
1238 +------------------------------------------------------------------------------
1239 */
1240 GLOBAL UBYTE cpap_send_resource_request_ia ( void )
1241 {
1242 {
1243 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
1244
1245 T_pck_upl_ass_ia *ptr2ul_assign;
1246 UBYTE frame[23];
1247 ULONG start_fn;
1248
1249
1250 TRACE_FUNCTION( "cpap_send_resource_request_ia" );
1251
1252 ptr2ul_assign = &d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia;
1253
1254 start_fn = grr_decode_tbf_start_abs((T_abs *)&ptr2ul_assign->sngl_block_alloc.tbf_start_time);
1255 if( !(grr_check_if_tbf_start_is_elapsed ( start_fn, grr_data->ul_fn)))
1256 {
1257 T_U_RESOURCE_REQ resource_req;
1258 sig_cpap_tc_build_res_req( &resource_req );
1259 grr_encode_ul_ctrl_block( frame, ( UBYTE* )&resource_req );
1260 }
1261 else
1262 {
1263 TRACE_ERROR("TBF Starting time is elpased in single block allocation!");
1264 return FALSE;
1265 }
1266 {
1267 PALLOC(ptr2prim,MPHP_SINGLE_BLOCK_REQ);
1268 memcpy( ptr2prim->l2_frame, frame, 23 );
1269 ptr2prim->p_tbf_start.tbf_start_present = 1;
1270 ptr2prim->p_tbf_start.fn = start_fn;
1271
1272 if( ptr2ul_assign->v_sngl_block_alloc AND ptr2ul_assign->sngl_block_alloc.v_p0_bts_prmode )
1273 {
1274 ptr2prim->p_dl_power.p0 = ptr2ul_assign->sngl_block_alloc.p0_bts_prmode.p0;
1275 ptr2prim->p_dl_power.bts_pwr_ctl_mode = ptr2ul_assign->sngl_block_alloc.p0_bts_prmode.pwr_ctrl_mode;
1276 ptr2prim->p_dl_power.pr_mode = ptr2ul_assign->sngl_block_alloc.p0_bts_prmode.pr_mode;
1277 }
1278 else
1279 {
1280 ptr2prim->p_dl_power.p0 = 0xff;
1281 }
1282
1283 /*
1284 * mark that single block is because of two phase access procedure
1285 */
1286 ptr2prim->purpose = TWO_PHASE_ACESS;
1287 ptr2prim->pc_meas_chan = psc_db->g_pwr_par.pc_meas_chan;
1288 ptr2prim->burst_type = (psc_db->gprs_cell_opt.ab_type EQ AB_8_BIT)
1289 ?AB_8_BIT
1290 :AB_11_BIT;
1291
1292 grr_handle_ta ( 1, /*Ta is mandatory in immediate assignment*/
1293 d_imm_assign->time_advance.ta,
1294 0,
1295 0,
1296 0,
1297 0,
1298 0,
1299 0,
1300 &ptr2prim->p_timing_advance);
1301
1302 /*
1303 * trainings sequence
1304 */
1305 ptr2prim->tsc = d_imm_assign->pck_chan_desc.tsc;
1306 ptr2prim->tn = d_imm_assign->pck_chan_desc.tn;
1307
1308 /*
1309 * frequency parameters
1310 */
1311 grr_set_freq_par( &ptr2prim->p_frequency_par );
1312 sig_cpap_tc_assign_sb( ( void* )ptr2prim, TWO_PHASE_ACESS );
1313 }
1314 return TRUE;
1315 }
1316 } /* cpap_send_resource_request_ia() */
1317
1318
1319 /*
1320 +------------------------------------------------------------------------------
1321 | Function : cpap_send_single_block_without_tbf
1322 +------------------------------------------------------------------------------
1323 | Description : The function cpap_send_single_block_without_tbf() sends
1324 | the primitive MPHP_SINGLE_BLOCK_REQ with single
1325 | block request without TBF establishment due to the reception
1326 | of an immediate assignment message.
1327 |
1328 | Parameters : void
1329 |
1330 +------------------------------------------------------------------------------
1331 */
1332 GLOBAL UBYTE cpap_send_single_block_without_tbf ( void )
1333 {
1334 PALLOC( prim, MPHP_SINGLE_BLOCK_REQ );
1335 {
1336 MCAST( d_imm_assign, D_IMM_ASSIGN );
1337
1338 T_pck_upl_ass_ia *assign;
1339 UBYTE result = FALSE;
1340
1341 TRACE_FUNCTION( "cpap_send_single_block_without_tbf" );
1342
1343 assign = &d_imm_assign->ia_rest_oct.ia_assign_par.pck_upl_ass_ia;
1344
1345 if( assign->v_sngl_block_alloc AND assign->sngl_block_alloc.v_p0_bts_prmode )
1346 {
1347 prim->p_dl_power.p0 = assign->sngl_block_alloc.p0_bts_prmode.p0;
1348 prim->p_dl_power.bts_pwr_ctl_mode = assign->sngl_block_alloc.p0_bts_prmode.pwr_ctrl_mode;
1349 prim->p_dl_power.pr_mode = assign->sngl_block_alloc.p0_bts_prmode.pr_mode;
1350 }
1351 else
1352 {
1353 prim->p_dl_power.p0 = 0xff;
1354 }
1355
1356 /*
1357 * mark that single block is because of two phase access procedure
1358 */
1359 prim->purpose = SINGLE_BLOCK_TRANSFER_UL;
1360 prim->pc_meas_chan = psc_db->g_pwr_par.pc_meas_chan;
1361 prim->burst_type = ( psc_db->gprs_cell_opt.ab_type EQ AB_8_BIT )
1362 ? AB_8_BIT : AB_11_BIT;
1363
1364 prim->p_timing_advance.ta_value = d_imm_assign->time_advance.ta;
1365
1366 grr_data->ta_params.ta_value = d_imm_assign->time_advance.ta;
1367 grr_data->ta_params.ta_valid = TRUE;
1368
1369 if( assign->tfi_ass_alloc.v_ta_idx )
1370 {
1371 prim->p_timing_advance.ta_index = assign->tfi_ass_alloc.ta_idx;
1372 prim->p_timing_advance.tn = d_imm_assign->pck_chan_desc.tn;
1373 }
1374 else
1375 {
1376 prim->p_timing_advance.ta_index = 0xff;
1377 prim->p_timing_advance.tn = 0xff;
1378 }
1379
1380 /*
1381 * trainings sequence
1382 */
1383 prim->tsc = d_imm_assign->pck_chan_desc.tsc;
1384
1385 /*
1386 TRACE_EVENT_P4( "request_ia1 tn:%d tsc: %d p0:%d pr_mode:%d",
1387 d_imm_assign->pck_chan_desc.tn, prim->tsc,
1388 prim->p_dl_power.p0, prim->p_dl_power.pr_mode );
1389 */
1390
1391
1392 /* SZML-CPAP/009 */
1393 /*
1394 * handle TBF starting time is always present in single block allocation,
1395 * otherwise something is wrong
1396 */
1397
1398 if( assign->v_sngl_block_alloc)
1399 {
1400 prim->p_tbf_start.tbf_start_present = 1;
1401 prim->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs*) &assign->sngl_block_alloc.tbf_start_time);
1402 if(grr_check_if_tbf_start_is_elapsed ( prim->p_tbf_start.fn, grr_data->ul_fn))
1403 {
1404 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
1405 TRACE_EVENT_P2("CPAP SBR TBF ST ELAPSED st=%ld c_fn=%ld ", prim->p_tbf_start.fn,grr_data->dl_fn);
1406 }
1407 else
1408 {
1409 result = TRUE;
1410 }
1411 }
1412
1413 if( result )
1414 {
1415 tc_cpy_ctrl_blk_to_buffer( prim->l2_frame );
1416
1417 prim->tsc = grr_data->tc.freq_set.tsc;
1418 prim->tn = d_imm_assign->pck_chan_desc.tn;
1419
1420 /*
1421 * frequency parameters
1422 */
1423 grr_set_freq_par( &prim->p_frequency_par );
1424 sig_cpap_tc_assign_sb( (void*)prim, SINGLE_BLOCK_TRANSFER_UL );
1425
1426 /*
1427 TRACE_EVENT_P8("request_ia2 tn:%d tsc: %d ta:%d arfcn:%ld : nr: %d p0:%d pr:%d ctrl:%d",
1428 prim_i->tn,
1429 prim_i->tsc,
1430 prim_i->p_timing_advance,
1431 prim_i->p_chan_sel.p_rf_ch.arfcn,
1432 prim_i->ptr2prim->p_frequency_par.p_freq_list.p_rf_chan_cnt,
1433 prim_i->p_dl_power.p0,
1434 prim_i->p_dl_power.pr_mode,
1435 prim_i->p_dl_power.bts_pwr_ctl_mode);
1436 */
1437 }
1438 else
1439 {
1440 PFREE(prim);
1441 }
1442
1443 return result;
1444 }
1445 } /* cpap_send_single_block_without_tbf() */
1446
1447
1448 /*
1449 +------------------------------------------------------------------------------
1450 | Function : cpap_send_receive_normal_burst
1451 +------------------------------------------------------------------------------
1452 | Description : The function cpap_send_receive_normal_burst() sends the
1453 | primitive MPHP_SINGLE_BLOCK_REQ to receive a single packet
1454 | control block on the specified radio resource.
1455 |
1456 | Parameters : void
1457 |
1458 +------------------------------------------------------------------------------
1459 */
1460 GLOBAL UBYTE cpap_send_receive_normal_burst ( void )
1461 {
1462 MCAST( d_imm_assign, D_IMM_ASSIGN );
1463
1464 T_pck_downl_ass_ia *ptr2dl_assign =
1465 &d_imm_assign->ia_rest_oct.ia_assign_par.pck_downl_ass_ia;
1466 UBYTE result = FALSE;
1467
1468 PALLOC( mphp_single_block_req, MPHP_SINGLE_BLOCK_REQ );
1469
1470 TRACE_FUNCTION( "cpap_send_receive_normal_burst" );
1471
1472 memset( mphp_single_block_req, 0, sizeof( T_MPHP_SINGLE_BLOCK_REQ ) );
1473
1474 mphp_single_block_req->assign_id = 0;
1475 grr_data->tc.last_rec_nb_id = mphp_single_block_req->assign_id;
1476 mphp_single_block_req->purpose = SINGLE_BLOCK_TRANSFER_DL;
1477 mphp_single_block_req->tsc = grr_data->tc.freq_set.tsc;
1478 mphp_single_block_req->tn = d_imm_assign->pck_chan_desc.tn;
1479
1480 grr_set_freq_par( &mphp_single_block_req->p_frequency_par );
1481
1482 if( ptr2dl_assign->v_p0_bts_prmode )
1483 {
1484 mphp_single_block_req->p_dl_power.p0 = ptr2dl_assign->p0_bts_prmode.p0;
1485 mphp_single_block_req->p_dl_power.bts_pwr_ctl_mode =
1486 ptr2dl_assign->p0_bts_prmode.pwr_ctrl_mode;
1487 mphp_single_block_req->p_dl_power.pr_mode = ptr2dl_assign->p0_bts_prmode.pr_mode;
1488 }
1489 else
1490 {
1491 mphp_single_block_req->p_dl_power.p0 = 0xff;
1492 mphp_single_block_req->p_dl_power.bts_pwr_ctl_mode = 0xff;
1493 mphp_single_block_req->p_dl_power.pr_mode = 0xff;
1494 }
1495
1496 mphp_single_block_req->pc_meas_chan = psc_db->g_pwr_par.pc_meas_chan;
1497 mphp_single_block_req->burst_type = (psc_db->gprs_cell_opt.ab_type EQ AB_8_BIT)
1498 ?AB_8_BIT
1499 :AB_11_BIT;
1500
1501 /* a downlink single block don't need timing advance!! */
1502 mphp_single_block_req->p_timing_advance.ta_value = 0xff;
1503 mphp_single_block_req->p_timing_advance.ta_index = 0xff;
1504 mphp_single_block_req->p_timing_advance.tn = 0xff;
1505 /*
1506 * handle TBF starting time
1507 * is always present in single block allocation (otherwise something is wrong)
1508 */
1509 if(ptr2dl_assign->v_tbf_start_time)
1510 {
1511 mphp_single_block_req->p_tbf_start.tbf_start_present = 1;
1512 mphp_single_block_req->p_tbf_start.fn = grr_decode_tbf_start_abs((T_abs *)&ptr2dl_assign->tbf_start_time);
1513 if(grr_check_if_tbf_start_is_elapsed ( mphp_single_block_req->p_tbf_start.fn, grr_data->ul_fn))
1514 {
1515 TRACE_ERROR("TBF Starting time is ELAPSED in single block allocation!");
1516 TRACE_EVENT_P2("CPAP SBR TBF ST ELAPSED st=%ld c_fn=%ld ", mphp_single_block_req->p_tbf_start.fn,grr_data->dl_fn);
1517 }
1518 else
1519 {
1520 result = TRUE;
1521 grr_data->tc.last_rec_nb_fn = mphp_single_block_req->p_tbf_start.fn;
1522 }
1523 }
1524 else
1525 {
1526 TRACE_ERROR("TBF Starting time is missing in single block allocation!");
1527 /* SZML-CPAP/013 */
1528 }
1529
1530 if(result)
1531 {
1532 sig_cpap_tc_assign_sb((void*)mphp_single_block_req,SINGLE_BLOCK_TRANSFER_DL);
1533 }
1534 else
1535 {
1536 PFREE(mphp_single_block_req);
1537 TRACE_ERROR("SINGLE BLOCK STARTING TIME HAS ALREADY BEEN ELAPSED");
1538 }
1539
1540 return result;
1541 } /* cpap_send_receive_normal_burst() */
1542
1543
1544 /*
1545 +------------------------------------------------------------------------------
1546 | Function : cpap_store_ia_message
1547 +------------------------------------------------------------------------------
1548 | Description : The function cpap_store_ia_message() stores the 1st message of
1549 | a two message assignment.
1550 |
1551 | Parameters : void
1552 |
1553 +------------------------------------------------------------------------------
1554 */
1555 GLOBAL void cpap_store_ia_message ( void )
1556 {
1557 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
1558
1559 TRACE_FUNCTION( "cpap_store_ia_message" );
1560
1561 memcpy(&grr_data->cpap.tma_ia, d_imm_assign, sizeof(T_D_IMM_ASSIGN));
1562 grr_data->cpap.v_tma_ia = TRUE;
1563
1564 } /* cpap_store_ia_message() */
1565
1566
1567 /*
1568 +------------------------------------------------------------------------------
1569 | Function : cpap_join_tma_messages
1570 +------------------------------------------------------------------------------
1571 | Description : The function cpap_join_tma_messages() join the stored 1st and
1572 | the 2nd message of a two message assignment.
1573 |
1574 | Parameters : void
1575 |
1576 +------------------------------------------------------------------------------
1577 */
1578 GLOBAL void cpap_join_tma_messages ( void )
1579 {
1580 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
1581
1582 TRACE_FUNCTION( "cpap_join_tma_messages" );
1583
1584 /* the 2nd message contains only the packet channel description and the
1585 * mobile allocation if needed.
1586 */
1587
1588 d_imm_assign->tma = TMA_0;
1589 d_imm_assign->page_mode.pm = grr_data->cpap.tma_ia.page_mode.pm;
1590 d_imm_assign->time_advance.ta = grr_data->cpap.tma_ia.time_advance.ta;
1591 if(grr_data->cpap.tma_ia.v_start_time)
1592 {
1593 d_imm_assign->v_start_time = TRUE;
1594 d_imm_assign->start_time.t1 = grr_data->cpap.tma_ia.start_time.t1;
1595 d_imm_assign->start_time.t2 = grr_data->cpap.tma_ia.start_time.t2;
1596 d_imm_assign->start_time.t3 = grr_data->cpap.tma_ia.start_time.t3;
1597 }
1598 memcpy( &d_imm_assign->ia_rest_oct,
1599 &grr_data->cpap.tma_ia.ia_rest_oct,
1600 sizeof(T_ia_rest_oct) );
1601 grr_data->cpap.v_tma_ia = FALSE;
1602
1603 } /* cpap_join_tma_messages() */
1604
1605 /*
1606 +------------------------------------------------------------------------------
1607 | Function : cpap_malloc_ia
1608 +------------------------------------------------------------------------------
1609 | Description : The function cpap_malloc_ia() ....
1610 |
1611 | Parameters :
1612 |
1613 +------------------------------------------------------------------------------
1614 */
1615 GLOBAL void cpap_malloc_ia ( void )
1616 {
1617 TRACE_FUNCTION( "cpap_malloc_ia" );
1618
1619 if( grr_data->cpap.p_d_imm_assign EQ NULL )
1620 {
1621 MALLOC( grr_data->cpap.p_d_imm_assign, sizeof( T_D_IMM_ASSIGN ) );
1622 }
1623 else
1624 {
1625 TRACE_ERROR( "cpap_malloc_ia: fatal error, memory reallocation not implemented" );
1626 }
1627
1628 *grr_data->cpap.p_d_imm_assign = *( ( T_D_IMM_ASSIGN * )_decodedMsg );
1629
1630 } /* cpap_malloc_ia() */
1631
1632 /*
1633 +------------------------------------------------------------------------------
1634 | Function : cpap_mfree_ia
1635 +------------------------------------------------------------------------------
1636 | Description : The function cpap_mfree_ia() ....
1637 |
1638 | Parameters :
1639 |
1640 +------------------------------------------------------------------------------
1641 */
1642 GLOBAL void cpap_mfree_ia ( BOOL restore_data )
1643 {
1644 TRACE_FUNCTION( "cpap_mfree_ia" );
1645
1646 if( grr_data->cpap.p_d_imm_assign NEQ NULL )
1647 {
1648 if( restore_data )
1649 {
1650 *( ( T_D_IMM_ASSIGN * )_decodedMsg ) = *grr_data->cpap.p_d_imm_assign;
1651 }
1652
1653 MFREE( grr_data->cpap.p_d_imm_assign );
1654 grr_data->cpap.p_d_imm_assign = NULL;
1655 }
1656 else
1657 {
1658 TRACE_ERROR( "cpap_mfree_ia: fatal error, no memory allocated" );
1659 }
1660 } /* cpap_mfree_ia() */
1661
1662 /*
1663 +------------------------------------------------------------------------------
1664 | Function : cpap_check_and_save_freq
1665 +------------------------------------------------------------------------------
1666 | Description : This function check if the freq_par is valid or not..
1667 | If it is hopping case, save the hoppinging freq.
1668 |
1669 | Parameters : void
1670 |
1671 +------------------------------------------------------------------------------
1672 */
1673 LOCAL BOOL cpap_check_and_save_freq (void)
1674 {
1675 MCAST(d_imm_assign,D_IMM_ASSIGN); /* T_D_IMM_ASSIGN */
1676 T_pck_chan_desc *chan_desc = &d_imm_assign->pck_chan_desc;
1677 T_mob_alloc *mob_alloc = &d_imm_assign->mob_alloc;
1678 BOOL result = FALSE;
1679 T_freq_par freq_par;
1680 TRACE_FUNCTION( "cpap_check_and_save_freq" );
1681
1682 if(chan_desc->hop OR (!chan_desc->hop AND chan_desc->indir))
1683 { /* hopping*/
1684
1685 if (chan_desc->indir)
1686 {
1687 /* indirect encoding */
1688 /* set up tc's freq_par struct */
1689 memset(&freq_par,0,sizeof(T_freq_par));
1690 freq_par.v_indi_encod = TRUE;
1691 freq_par.indi_encod.maio = chan_desc->maio;
1692 freq_par.tsc = chan_desc->tsc;
1693 freq_par.indi_encod.ma_num =
1694 chan_desc->ma_num + MA_NUMBER_4_PSI13_OR_CELL_ALLOC;
1695 if( chan_desc->v_ch_mark1)
1696 {
1697 freq_par.indi_encod.v_chamge_ma_sub = TRUE;
1698 freq_par.indi_encod.chamge_ma_sub.cm1 = chan_desc->ch_mark1;
1699 }
1700
1701 result = tc_set_hopping_par( &freq_par );
1702 }
1703 else if( chan_desc->v_maio AND chan_desc->v_hsn )
1704 { /* direct encoding */
1705
1706 UBYTE i;
1707 memset(&freq_par,0,sizeof(T_freq_par));
1708 freq_par.v_di_encod1 = TRUE;
1709 freq_par.di_encod1.maio = chan_desc->maio;
1710 freq_par.tsc = chan_desc->tsc;
1711 freq_par.di_encod1.gprs_ms_alloc_ie.hsn = chan_desc->hsn;
1712
1713 if(0 NEQ mob_alloc->c_mac)
1714 {
1715 freq_par.di_encod1.gprs_ms_alloc_ie.v_ma_struct = TRUE;
1716 freq_par.di_encod1.gprs_ms_alloc_ie.ma_struct.c_ma_map
1717 = mob_alloc->c_mac*8;
1718 freq_par.di_encod1.gprs_ms_alloc_ie.ma_struct.ma_len =
1719 (mob_alloc->c_mac*8)-1;
1720 for(i = 0;i < (mob_alloc->c_mac*8);i++)
1721 { /* convert bitbuffer type of rr to type of grr */
1722 freq_par.di_encod1.gprs_ms_alloc_ie.ma_struct.ma_map[i]
1723 = (mob_alloc->mac[i/8]>>(7-(i%8)))&0x01;
1724 }
1725 }
1726
1727 result = tc_set_hopping_par( &freq_par );
1728 }
1729 else
1730 { /* corrupted message decoding */
1731 grr_data->tc.v_freq_set = FALSE;
1732 result = FALSE;
1733 }
1734
1735 }
1736 else if(chan_desc->v_arfcn)
1737 {
1738 /* absolut radio frequency channel number */
1739 grr_data->tc.v_freq_set = TRUE;
1740 result = TRUE;
1741 grr_data->tc.freq_set.freq_par.p_chan_sel.hopping = FALSE;
1742 grr_data->tc.freq_set.tsc = chan_desc->tsc;
1743 grr_data->tc.freq_set.freq_par.p_chan_sel.p_rf_ch.arfcn = grr_g23_arfcn_to_l1(chan_desc->arfcn);
1744 /* set up tc's freq_par struct */
1745 memset(&grr_data->tc.freq_set.freq_par.p_freq_list.p_rf_chan_no.p_radio_freq,0,sizeof(grr_data->tc.freq_set.freq_par.p_freq_list.p_rf_chan_no.p_radio_freq));
1746 grr_data->tc.freq_set.freq_par.p_freq_list.p_rf_chan_cnt = 0;
1747 }
1748 else
1749 {
1750 grr_data->tc.v_freq_set = FALSE;
1751 result = FALSE;
1752 }
1753
1754 grr_data->pwr_ctrl_valid_flags.v_glbl_pwr_ctrl_param = TRUE;
1755 grr_data->pwr_ctrl_valid_flags.v_freq_param = TRUE;
1756
1757 return result;
1758 } /* cpap_check_and_save_freq */
1759
1760
1761
1762