comparison g23m-gsm/alr/alr_dedi.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children b76c78b62e5e
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS
4 | Modul : alr_DEDI
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Modul defines the SDL process Dedicated_Control.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ALR_DEDI_C
22 #define ALR_DEDI_C
23
24 #include "config.h"
25 #include "fixedconf.h"
26 #include "condat-features.h"
27
28 #define ENTITY_PL
29
30 /*==== INCLUDES ===================================================*/
31 #include <string.h>
32 #include <stdlib.h>
33 #include <ctype.h>
34 #include "typedefs.h"
35 #include "pconst.cdg"
36 #include "mconst.cdg"
37 #include "message.h"
38 #include "ccdapi.h"
39 #include "vsi.h"
40 #include "custom.h"
41 #include "gsm.h"
42 #include "prim.h"
43 #include "cnf_alr.h"
44 #include "mon_alr.h"
45 #include "pei.h"
46 #include "tok.h"
47
48 #include "pcm.h"
49 #ifdef GPRS
50 #include "alr_gprs.h"
51 #endif
52
53 #include "alr.h"
54 #include "alr_em.h"
55
56 /*=== Constrains =======================================*/
57
58 #define TCH_F_INDEX 1
59 #ifdef FF_L23_A5_3
60 #define KLEN 8
61 #endif
62
63 /*==== EXPORT =====================================================*/
64 /*==== PRIVAT =====================================================*/
65 LOCAL UBYTE dedi_channel_mode (UBYTE channel_mode, UBYTE channel_type);
66 LOCAL void dedi_convert_chan_desc (T_channel_desc * channel_desc);
67 LOCAL void dedi_convert_frequency_list (T_frequency_list * frequency_list);
68 LOCAL UBYTE dedi_conversion_needed (void);
69 LOCAL void dedi_chan_ass_fail (void);
70 LOCAL void dedi_pdch_ass_fail (void);
71 LOCAL void dedi_cco_fail (void);
72 LOCAL void dedi_handover_fail (void);
73 LOCAL void dedi_async_handover (T_MPH_DEDICATED_REQ *dedicated_req);
74 LOCAL void dedi_chan_ass (T_MPH_DEDICATED_REQ *dedicated_req);
75 LOCAL void dedi_fill_ma (USHORT *ma, T_frequency_list *rf);
76 LOCAL void dedi_imm_ass (T_MPH_DEDICATED_REQ *dedicated_req);
77 LOCAL void dedi_pdch_ass (T_MPH_DEDICATED_REQ *dedicated_req);
78 LOCAL void dedi_pre_sync_handover (T_MPH_DEDICATED_REQ *dedicated_req);
79 LOCAL void dedi_sync_handover (T_MPH_DEDICATED_REQ *dedicated_req);
80 #if defined (REL99) && defined (FF_BHO)
81 LOCAL void dedi_reset_bho_data(void);
82 LOCAL void dedi_set_ho_type(ULONG *fn, ULONG *tn, UBYTE *ho_type);
83 #endif
84
85 LOCAL void dedi_chan_type_sel (T_ch_type *ch_type,
86 T_chan_sel *chan_sel,
87 T_frequency_list *frequency_list);
88 LOCAL void dedi_chan_type_desc (T_MPH_DEDICATED_REQ *dedicated_req,
89 T_channel_desc_1_bef_sti *channel_desc_1_bef_sti,
90 T_frequency_list *frequency_list_bef_sti);
91 LOCAL void dedi_set_amr_conf (T_amr_configuration *amr_con, T_amr_conf *amr_conf);
92
93 /*==== VARIABLES ==================================================*/
94 LOCAL UBYTE actual_channel;
95
96 /*==== FUNCTIONS ==================================================*/
97
98 #if defined (WIN32)
99 #define TRACING
100 #endif
101
102 #if defined (TRACING)
103 #define ALR_TRACE_DEDI(a) ALR_TRACE(a)
104 #else
105 #define ALR_TRACE_DEDI(a)
106 #endif
107
108 #if defined (TRACING)
109 #define ALR_TRACE_DEDI_DTX(a1) TRACE_EVENT_P1 ("DTX = %d", a1);
110 #define ALR_TRACE_DEDI_PARA(h, rf, _ch, sub, _tno, _tsc, _ta, _st, _dtx, _maio)\
111 {if (h){\
112 TRACE_EVENT_P9 ("immass:hop[%04x] ch/s=%u/%u tno=%u tsc=%u ta=%u st=%u dtx=%u maio=%u",\
113 rf, _ch, sub, _tno, _tsc, _ta, _st, _dtx, _maio);\
114 }else{\
115 TRACE_EVENT_P9 ("immass:[%u] ch/s=%u/%u tno=%u tsc=%u ta=%u st=%u dtx=%u maio=%u",\
116 rf, _ch, sub, _tno, _tsc, _ta, _st, _dtx, _maio);}}
117 #define ALR_TRACE_DEDI_HO_1(p1,p2,p3,p4,p5,p6) \
118 TRACE_EVENT_P6 ("d rf=%d bsic=%d sti=%d ch2=%d ch=%d tsc=%d",\
119 p1, p2, p3, p4, p5, p6)
120 #define ALR_TRACE_DEDI_HO_2(p1,p2,p3,p4,p5,p6) \
121 TRACE_EVENT_P6 ("d tn=%d arf=%d pow=%d ref=%d acc=%d nci=%d", \
122 p1, p2, p3, p4, p5, p6)
123 #define ALR_TRACE_DEDI_HO_3(p1,p2,p3,p4,p5,p6) \
124 TRACE_EVENT_P6 ("d mode=%d power=%d dtx=%d rlt=%d tav=%d pwrc=%d", \
125 p1, p2, p3, p4, p5, p6)
126 #define ALR_TRACE_DEDI_HO_4(p1,p2,p3) \
127 TRACE_EVENT_P3 ("d mode=%d stat=%d algo=%d", p1, p2, p3);
128 #define ALR_TRACE_DEDI_HO_5(p1,p2,p3,p4,p5,p6) \
129 TRACE_EVENT_P6 ("a h=%d maio=0x%x hsn=%d chty=%d subch=%d tno=%d", \
130 p1, p2, p3, p4, p5, p6)
131 #define ALR_TRACE_DEDI_HO_6(p1,p2,p3,p4,p5,p6) \
132 TRACE_EVENT_P6 ("a tsc=%d txpwr=%d ho_acc=%d sti_p=%d ncc=%d bcc=%d", \
133 p1, p2, p3, p4, p5, p6)
134 #define ALR_TRACE_DEDI_HO_7(p1,p2,p3,p4) \
135 TRACE_EVENT_P4 ("a rf=%d chmo1=%d ciphmo=%d a5=%d", \
136 p1, p2, p3, p4)
137 #define ALR_TRACE_DEDI_FREQ_LIST() TRACE_EVENT_P2 ("HOP = %d %d", \
138 frequency_list->rf_chan_no.radio_freq[j], \
139 ARFCN_TO_L1 (frequency_list->rf_chan_no.radio_freq[j]))
140
141 #else
142
143 #define ALR_TRACE_DEDI_DTX(d)
144 #define ALR_TRACE_DEDI_PARA(hop,p1,p2,p3,p4,p5,p6,p7,p8,p9)
145 #define ALR_TRACE_DEDI_HO_1(p1,p2,p3,p4,p5,p6)
146 #define ALR_TRACE_DEDI_HO_2(p1,p2,p3,p4,p5,p6)
147 #define ALR_TRACE_DEDI_HO_3(p1,p2,p3,p4,p5,p6)
148 #define ALR_TRACE_DEDI_HO_4(p1,p2,p3)
149 #define ALR_TRACE_DEDI_HO_5(p1,p2,p3,p4,p5,p6)
150 #define ALR_TRACE_DEDI_HO_6(p1,p2,p3,p4,p5,p6)
151 #define ALR_TRACE_DEDI_HO_7(p1,p2,p3,p4)
152 #define ALR_TRACE_DEDI_FREQ_LIST()
153
154 #endif
155
156
157
158 /*
159 +--------------------------------------------------------------------+
160 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
161 | STATE : code ROUTINE : dedi_init |
162 +--------------------------------------------------------------------+
163
164 PURPOSE : Initialize Dedicated Control Process.
165
166 */
167
168 GLOBAL void dedi_init (void)
169 {
170 GET_INSTANCE_DATA;
171 alr_data->state[STATE_DEDI] = DEDI_INACTIVE;
172 }
173
174
175
176 /*
177 +--------------------------------------------------------------------+
178 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
179 | STATE : code ROUTINE : dedi_req |
180 +--------------------------------------------------------------------+
181
182 PURPOSE : Process signal dedi_req from SDL process Main_Control.
183 RR configures a dedicated channel.
184
185 */
186
187 /*
188 * Conversion Channel Type Air Interface to TI definition
189 */
190
191 LOCAL const UBYTE CH_TYPE [16] =
192 {
193 0, /* undefined */
194 1, /* TCH fullrate */
195 2, /* TCH halfrate (0) */
196 2, /* TCH halfrate (1) */
197 3, /* SDCCH/4 (0) */
198 3, /* SDCCH/4 (1) */
199 3, /* SDCCH/4 (2) */
200 3, /* SDCCH/4 (3) */
201 4, /* SDCCH/8 (0) */
202 4, /* SDCCH/8 (1) */
203 4, /* SDCCH/8 (2) */
204 4, /* SDCCH/8 (3) */
205 4, /* SDCCH/8 (4) */
206 4, /* SDCCH/8 (5) */
207 4, /* SDCCH/8 (6) */
208 4 /* SDCCH/8 (7) */
209 };
210
211
212 /*
213 * Conversion Sub Channel Air Interface to TI definition
214 */
215
216 LOCAL const UBYTE SUB_TYPE [16] =
217 {
218 0, /* undefined */
219 0, /* TCH fullrate */
220 0, /* TCH halfrate (0) */
221 1, /* TCH halfrate (1) */
222 0, /* SDCCH/4 (0) */
223 1, /* SDCCH/4 (1) */
224 2, /* SDCCH/4 (2) */
225 3, /* SDCCH/4 (3) */
226 0, /* SDCCH/8 (0) */
227 1, /* SDCCH/8 (1) */
228 2, /* SDCCH/8 (2) */
229 3, /* SDCCH/8 (3) */
230 4, /* SDCCH/8 (4) */
231 5, /* SDCCH/8 (5) */
232 6, /* SDCCH/8 (6) */
233 7 /* SDCCH/8 (7) */
234 };
235
236 GLOBAL void dedi_req (T_MPH_DEDICATED_REQ * dedicated_req)
237 {
238 GET_INSTANCE_DATA;
239 /*
240 * RR signals which procedure is processed
241 */
242 USHORT mode = dedicated_req->mod;
243
244 switch (mode)
245 {
246 case MODE_SYS_INFO_CHANGE:
247 /*
248 * Changed values for DTX, PWRC and Radio Link Timeout
249 */
250 ALR_TRACE_DEDI_DTX(dedicated_req->tr_para.dtx);
251
252 nc_update_dedicated (dedicated_req->tr_para.dtx,
253 dedicated_req->tr_para.pwrc);
254 alr_data->dedi_data.rlt = alr_data->dedi_data.act_rlt = (UBYTE)((dedicated_req->tr_para.rlt + 1) * 4);
255
256 ALR_EM_SET_EM_ACT_RLT;
257
258 break;
259 case MODE_IMM_ASSIGN:
260 /*
261 * Immediate Assignment Procedure
262 */
263 dedi_imm_ass (dedicated_req);
264 break;
265 case MODE_CHAN_ASSIGN:
266 /*
267 * Intracell Handover
268 */
269 dedi_chan_ass (dedicated_req);
270 /*
271 * reset radio link timeout counter
272 */
273 alr_data->dedi_data.act_rlt = alr_data->dedi_data.rlt;
274
275 ALR_EM_SET_EM_ACT_RLT;
276
277 break;
278 #ifdef GPRS
279 case MODE_PDCH_ASSIGN:
280 /*
281 * Packet Data CHannel Assignment
282 */
283 dedi_pdch_ass (dedicated_req);
284 break;
285 #endif
286 case MODE_ASYNC_HANDOVER:
287 case MODE_SYNC_HANDOVER:
288 case MODE_PRE_SYNC_HANDOVER:
289 {
290 #if !defined (REL99) || !defined (FF_BHO)
291 ULONG dummy1, dummy2;
292 if( nc_get_fn_time(dedicated_req->arfcn, &dummy1, &dummy2) EQ FALSE)
293 {
294 /*
295 * Timing Information not present for the cell
296 */
297 ALR_TRACE_DEDI("Handover to a cell - whose SYNC is not done");
298 ma_dedi_cnf(DEDI_RES_CELL_NOT_SYNC);
299 }
300 else
301 #endif
302 {
303 nc_suspend_handover();
304 switch(mode)
305 {
306 case MODE_ASYNC_HANDOVER:
307 /*
308 * Asynchronous handover
309 */
310 dedi_async_handover (dedicated_req);
311 break;
312 case MODE_SYNC_HANDOVER:
313 /*
314 * Synchronous handover
315 */
316 dedi_sync_handover (dedicated_req);
317 break;
318 case MODE_PRE_SYNC_HANDOVER:
319 /*
320 * Pre-synchronous handover
321 */
322 dedi_pre_sync_handover (dedicated_req);
323 break;
324 default :
325 break;
326 }
327 alr_data->dedi_data.act_rlt = alr_data->dedi_data.rlt;
328 ALR_EM_SET_EM_ACT_RLT;
329 }
330 }
331 break;
332 default:
333 break;
334 }
335 }
336
337 /*
338 +--------------------------------------------------------------------+
339 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
340 | STATE : code ROUTINE : dedi_fail_req |
341 +--------------------------------------------------------------------+
342
343 PURPOSE : Process signal dedi_fail_req from SDL process Main_Control.
344 RR signals that going back to the old channel after channel
345 assignment or handover is necessary.
346
347 */
348
349 GLOBAL void dedi_fail_req (void)
350 {
351 GET_INSTANCE_DATA;
352 /*
353 * RR signals which procedure is running
354 */
355 switch (alr_data->dedi_data.act_mode)
356 {
357 case MODE_CHAN_ASSIGN:
358 /*
359 * channel assignment procedure
360 */
361 dedi_chan_ass_fail ();
362 break;
363 case MODE_PDCH_ASSIGN:
364 dedi_pdch_ass_fail();
365 break;
366 case MODE_CELL_CHANGE_ORDER:
367 dedi_cco_fail();
368 break;
369 case MODE_ASYNC_HANDOVER:
370 case MODE_SYNC_HANDOVER:
371 case MODE_PRE_SYNC_HANDOVER:
372 case MODE_PSEUDO_SYNC_HANDOVER:
373 /*
374 * one of the handover procedures
375 */
376 dedi_handover_fail ();
377 break;
378 default:
379 break;
380 }
381 }
382
383 /*
384 +--------------------------------------------------------------------+
385 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
386 | STATE : code ROUTINE : dedi_ta_fail_ind |
387 +--------------------------------------------------------------------+
388
389 PURPOSE : Process signal dedi_ta_fail_ind from SDL process
390 Main_Control.
391 Layer 1 signals that the timing advance is out of
392 range during handover. This will be forwarded to RR and
393 switching back to the old channel is initiated by RR.
394
395 */
396
397 GLOBAL void dedi_ta_fail_ind (void)
398 {
399 ma_dedi_cnf (DEDI_RES_TA_OUT_OF_RANGE);
400 }
401
402 /*
403 +--------------------------------------------------------------------+
404 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
405 | STATE : code ROUTINE : dedi_ho_finished |
406 +--------------------------------------------------------------------+
407
408 PURPOSE : Process signal dedi_ho_finished from SDL process
409 Main_Control.
410 Layer 1 signals that the handover has finished successful.
411 This is forwarded to RR which starts resumption of the
412 link on the new channel.
413
414 */
415
416 GLOBAL void dedi_ho_finished (T_MPHC_HANDOVER_FINISHED* ho_finished)
417 {
418 GET_INSTANCE_DATA;
419 ma_clean_dedi_sys_buffer ();
420 switch (ho_finished->cause)
421 {
422 case HO_COMPLETE:
423 ALR_TRACE_DEDI ("Handover to new cell complete");
424 #if defined (REL99) && defined (FF_BHO)
425 if (alr_data->dedi_data.ho_type EQ HOT_BLIND)
426 {
427 T_NC* pcell;
428 /*Add the new SC to BA if not present earlier*/
429 if (alr_data->dedi_data.bho_cell_index EQ NOT_PRESENT_16BIT)
430 {
431 alr_data->dedi_data.bho_cell_index =
432 nc_find_serving_cell_entry(alr_data->serving_cell);
433 }
434 pcell = &alr_data->nc_data.cell[alr_data->dedi_data.bho_cell_index];
435 pcell->frame_offset = ho_finished->fn_offset;
436 pcell->time_align = ho_finished->time_alignment;
437 nc_set_status(alr_data->dedi_data.bho_cell_index, FB_SB_SYNC);
438 /*Now update the timing information w.r.t the blind cell*/
439 nc_update_list(pcell->ba_arfcn);
440 dedi_reset_bho_data();
441 nc_resume_dedicated();
442 }
443 #endif
444 ma_dedi_cnf (DEDI_RES_OK);
445 break;
446 case HO_TIMEOUT:
447 ALR_TRACE_DEDI ("Handover failed due to T3124 expiry (=>Phy_info not received)");
448 #if defined (REL99) && defined (FF_BHO)
449 /*Restore timing info only in case of Regular HO
450 No need to restore timing info in case of Blind HO
451 since we haven't updated timing info yet */
452 if (alr_data->dedi_data.ho_type EQ HOT_BLIND)
453 dedi_reset_bho_data();
454 else
455 #endif
456 nc_update_list (alr_data->dedi_data.old_bcch); /* Check if this is required??? */
457 ma_dedi_cnf (DEDI_RES_TIMEOUT);
458 break;
459 #if defined (REL99) && defined (FF_BHO)
460 case HO_SYNC_FAIL:
461 ALR_TRACE_DEDI ("Handover failed: BSIC error");
462 dedi_reset_bho_data();
463 ma_dedi_cnf (DEDI_RES_CELL_NOT_SYNC);
464 break;
465 #endif
466 default:
467 break;
468
469 }
470 }
471
472 /*
473 +--------------------------------------------------------------------+
474 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
475 | STATE : code ROUTINE : dedi_chan_ass_fail |
476 +--------------------------------------------------------------------+
477
478 PURPOSE : Process Channel Assignment Failure (back to old
479 dedicated channel).
480 In fact this is a new configuration of the layer 1. The
481 parameters of the old channel are stored in TI++.
482
483 */
484
485 LOCAL void dedi_chan_ass_fail (void)
486 {
487 GET_INSTANCE_DATA;
488 PALLOC (chan_ass, MPHC_CHANNEL_ASSIGN_REQ);
489
490 memset (chan_ass, 0, sizeof (T_MPHC_CHANNEL_ASSIGN_REQ));
491
492 if (alr_data->dedi_data.redef_starting_time.start_time_present)
493 {
494 /*
495 * Special case: frequency redefinition values ares stored.
496 */
497 memcpy (&chan_ass->channel_desc_1,
498 &alr_data->dedi_data.redef_channel_desc,
499 sizeof (T_channel_desc));
500 memcpy (&chan_ass->frequency_list,
501 &alr_data->dedi_data.redef_frequency_list,
502 sizeof (T_frequency_list));
503 memcpy (&chan_ass->channel_desc_1_bef_sti,
504 &alr_data->dedi_data.old_channel_desc,
505 sizeof (T_channel_desc));
506 memcpy (&chan_ass->frequency_list_bef_sti,
507 &alr_data->dedi_data.old_frequency_list,
508 sizeof (T_frequency_list));
509 memcpy (&chan_ass->starting_time,
510 &alr_data->dedi_data.redef_starting_time,
511 sizeof (T_starting_time));
512
513 /*
514 * convert channel numbers if needed
515 */
516 if (dedi_conversion_needed ())
517 {
518 dedi_convert_chan_desc ((T_channel_desc *)&chan_ass->channel_desc_1);
519 dedi_convert_frequency_list (&chan_ass->frequency_list);
520 dedi_convert_chan_desc ((T_channel_desc *)&chan_ass->channel_desc_1_bef_sti);
521 dedi_convert_frequency_list ((T_frequency_list *)&chan_ass->frequency_list_bef_sti);
522 }
523 }
524 else
525 {
526 /*
527 * Normal case
528 */
529 memcpy (&chan_ass->channel_desc_1,
530 &alr_data->dedi_data.old_channel_desc,
531 sizeof (T_channel_desc));
532 memcpy (&chan_ass->frequency_list,
533 &alr_data->dedi_data.old_frequency_list,
534 sizeof (T_frequency_list));
535
536 /*
537 * convert channel numbers if needed
538 */
539 if (dedi_conversion_needed ())
540 {
541 dedi_convert_chan_desc ((T_channel_desc *)&chan_ass->channel_desc_1);
542 dedi_convert_frequency_list (&chan_ass->frequency_list);
543 }
544 }
545
546 chan_ass->txpwr = alr_data->dedi_data.old_power;
547 chan_ass->cipher_mode = alr_data->dedi_data.old_cipher_mode;
548 chan_ass->channel_mode_1 = alr_data->dedi_data.old_channel_mode;
549 chan_ass->a5_algorithm = alr_data->dedi_data.old_a5_algorithm;
550 chan_ass->cipher_key = alr_data->dedi_data.old_cipher_key;
551 chan_ass->dtx_allowed = alr_data->dedi_data.old_dtx_allowed;
552 chan_ass->amr_configuration = alr_data->dedi_data.old_amr_configuration;
553
554 /*
555 * store actual channel for layer 2 channel decision
556 */
557 actual_channel = alr_data->dedi_data.old_channel;
558
559 /*
560 * store actual channel parameter in ALR. In fact they are
561 * the old values.
562 */
563 if (alr_data->dedi_data.redef_starting_time.start_time_present)
564 {
565 /*
566 * Special case: frequency redefinition values ares stored.
567 */
568 memcpy (&alr_data->dedi_data.act_channel_desc,
569 &alr_data->dedi_data.redef_channel_desc,
570 sizeof (T_channel_desc));
571 memcpy (&alr_data->dedi_data.act_frequency_list,
572 &alr_data->dedi_data.redef_frequency_list,
573 sizeof (T_frequency_list));
574 }
575 else
576 {
577 /*
578 * Normal case
579 */
580 memcpy (&alr_data->dedi_data.act_channel_desc,
581 &alr_data->dedi_data.old_channel_desc,
582 sizeof (T_channel_desc));
583 memcpy (&alr_data->dedi_data.act_frequency_list,
584 &alr_data->dedi_data.old_frequency_list,
585 sizeof (T_frequency_list));
586 }
587 alr_data->dedi_data.act_power = alr_data->dedi_data.old_power;
588 alr_data->dedi_data.act_cipher_mode = alr_data->dedi_data.old_cipher_mode;
589 alr_data->dedi_data.act_channel_mode = alr_data->dedi_data.old_channel_mode;
590 alr_data->dedi_data.act_a5_algorithm = alr_data->dedi_data.old_a5_algorithm;
591 alr_data->dedi_data.act_cipher_key = alr_data->dedi_data.old_cipher_key;
592 alr_data->dedi_data.act_dtx_allowed = alr_data->dedi_data.old_dtx_allowed;
593 alr_data->dedi_data.act_amr_configuration = alr_data->dedi_data.old_amr_configuration;
594 alr_data->dedi_data.act_mode = MODE_CHAN_ASS_FAIL;
595
596 /*
597 * send data to layer 1
598 */
599 ma_dedi_chan_ass_req (chan_ass);
600 }
601
602 /*
603 +--------------------------------------------------------------------+
604 | PROJECT : GSM-PS (8403) MODULE : alr_dedi |
605 | STATE : code ROUTINE : dedi_pdch_ass_fail |
606 +--------------------------------------------------------------------+
607
608 PURPOSE : PDCH Assignment Failure (back to old
609 dedicated channel).
610
611 Use the channel configuration in alr_data->dedi_data.act* with
612 MPHC-IMMED-ASSIGN-REQ. With the subsequent MPHC-IMMED-ASSIGN-CON
613 alr_data->dedi_data.temp* is NOT assigned to alr_data->dedi_data.act*,
614 refer to function dedi_imm_ass_cnf.
615 The actual switch back to the original channel is performed via
616 a channel assignment procedure carried out by dedi_chan_ass_fail
617 which is called in dedi_imm_ass_cnf.
618 */
619
620 LOCAL void dedi_pdch_ass_fail (void)
621 {
622 GET_INSTANCE_DATA;
623 T_DEDI_DATA *d = &alr_data->dedi_data;
624 PALLOC (immed_assign_req, MPHC_IMMED_ASSIGN_REQ);
625
626 memset ( immed_assign_req, 0 , sizeof *immed_assign_req );
627
628 immed_assign_req->channel_desc = d->old_channel_desc;
629 immed_assign_req->timing_advance = (UBYTE)alr_data->nc_data.tav;
630 immed_assign_req->frequency_list = d->old_frequency_list;
631 immed_assign_req->starting_time = d->old_starting_time;
632 immed_assign_req->frequency_list_bef_sti = d->old_frequency_list_bef_sti;
633 immed_assign_req->maio_bef_sti = d->old_channel_desc.chan_sel.rf_channel.maio;
634 /*
635 immed_assign_req->bcch_allocation = ... not used in current implementation
636 immed_assign_req->ba_id = ... not used in current implementation
637 */
638 immed_assign_req->dtx_allowed = d->old_dtx_allowed;
639 immed_assign_req->pwrc = d->old_pwrc;
640
641 SET_STATE (STATE_DEDI, DEDI_IMM_ASS_RECONN);
642 PSENDX (L1, immed_assign_req);
643 }
644
645 /*
646 +--------------------------------------------------------------------+
647 | PROJECT : GSM-PS (8403) MODULE : alr_dedi |
648 | STATE : code ROUTINE : dedi_cco_fail |
649 +--------------------------------------------------------------------+
650
651 PURPOSE : Cell Change Order Failure (back to old
652 dedicated channel).
653
654 */
655
656 LOCAL void dedi_cco_fail (void)
657 {
658 dedi_pdch_ass_fail();
659 }
660
661 /*
662 +--------------------------------------------------------------------+
663 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
664 | STATE : code ROUTINE : dedi_handover_fail |
665 +--------------------------------------------------------------------+
666
667 PURPOSE : Process Handover Failure (back to old
668 dedicated channel).
669 For handover switching back is carried out
670 autonomously by layer 1. Only the configuration
671 data in ALR is updated to the parameters of the
672 old channel.
673
674 */
675
676 LOCAL void dedi_handover_fail (void)
677 {
678 GET_INSTANCE_DATA;
679
680 /*
681 * store actual channel value for layer 2 channel selection
682 */
683 actual_channel = alr_data->dedi_data.old_channel;
684
685 /*
686 * update actual channel parameters to the old values
687 */
688 alr_data->serving_cell = alr_data->dedi_data.act_bcch = alr_data->dedi_data.old_bcch;
689 alr_data->dedi_data.act_channel_desc = alr_data->dedi_data.old_channel_desc;
690 alr_data->dedi_data.act_frequency_list = alr_data->dedi_data.old_frequency_list;
691 alr_data->dedi_data.act_cipher_mode = alr_data->dedi_data.old_cipher_mode;
692 alr_data->dedi_data.act_channel_mode = alr_data->dedi_data.old_channel_mode;
693 alr_data->dedi_data.act_a5_algorithm = alr_data->dedi_data.old_a5_algorithm;
694 alr_data->dedi_data.act_cipher_key = alr_data->dedi_data.old_cipher_key;
695 alr_data->dedi_data.act_amr_configuration = alr_data->dedi_data.old_amr_configuration;
696 alr_data->dedi_data.act_mode = MODE_HANDOVER_FAIL;
697
698 /*
699 * Inform layer 1 about handover failure
700 */
701 nc_suspend_handover();
702 ma_dedi_ho_fail_req ();
703 }
704
705 /*
706 +--------------------------------------------------------------------+
707 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
708 | STATE : code ROUTINE : dedi_imm_ass |
709 +--------------------------------------------------------------------+
710
711 PURPOSE : Converts MPH_DEDICATED_REQ to MPHC_IMMED_ASSIGN_REQ.
712 This function is used during Immediate Assignment procedure.
713
714 */
715
716 LOCAL void dedi_imm_ass (T_MPH_DEDICATED_REQ *dedicated_req)
717 {
718 GET_INSTANCE_DATA;
719 T_DEDI_DATA *dd = &alr_data->dedi_data;
720 PALLOC (imm_ass, MPHC_IMMED_ASSIGN_REQ); /* T_MPHC_IMMED_ASSIGN_REQ */
721
722 ALR_EM_CONFIGURE_IMMIDIATE_ASSIGNMENT;
723
724 memset (imm_ass, 0, sizeof (T_MPHC_IMMED_ASSIGN_REQ));
725 if (dedicated_req->ch_type.h EQ 1)
726 {
727 /*
728 * with frequency hopping
729 */
730 imm_ass->channel_desc.chan_sel.h = 1;
731 imm_ass->channel_desc.chan_sel.rf_channel.maio =
732 dedicated_req->ch_type.maio;
733 imm_ass->channel_desc.chan_sel.rf_channel.hsn =
734 dedicated_req->ch_type.hsn;
735 dedi_fill_ma (dedicated_req->ch_type.ma, &imm_ass->frequency_list);
736 dedi_fill_ma (dedicated_req->ch_type2.ma,
737 (T_frequency_list *)&imm_ass->frequency_list_bef_sti);
738 }
739 else
740 {
741 ALR_TRACE_DEDI ("no hopping");
742 /*
743 * Avoid the union, arfcn is mapped to maio and hsn
744 * in the non-hopping case.
745 */
746 imm_ass->channel_desc.chan_sel.h = 0;
747 imm_ass->channel_desc.chan_sel.rf_channel.maio =
748 (UBYTE)(dedicated_req->ch_type.arfcn & 0xFF);
749 imm_ass->channel_desc.chan_sel.rf_channel.hsn =
750 (UBYTE)((dedicated_req->ch_type.arfcn >> 8) & 0xFF);
751 }
752
753 /*
754 * set the actual channel for layer 2 channel selection
755 */
756 actual_channel = imm_ass->channel_desc.channel_type =
757 CH_TYPE [dedicated_req->ch_type.ch];
758 /*
759 * set the rest of parameters
760 */
761 imm_ass->channel_desc.sub_channel = SUB_TYPE [dedicated_req->ch_type.ch];
762 imm_ass->channel_desc.timeslot_no = dedicated_req->ch_type.tn;
763 imm_ass->channel_desc.tsc = dedicated_req->ch_type.tsc;
764 imm_ass->timing_advance = dedicated_req->tr_para.tav;
765 nc_store_tav(dedicated_req->tr_para.tav);
766 imm_ass->starting_time.start_time_present = dedicated_req->start.v_start;
767 imm_ass->starting_time.start_time.t1 = dedicated_req->start.t1;
768 imm_ass->starting_time.start_time.t3 = dedicated_req->start.t3;
769 imm_ass->starting_time.start_time.t2 = dedicated_req->start.t2;
770 imm_ass->maio_bef_sti = dedicated_req->ch_type2.maio;
771 imm_ass->dtx_allowed = dedicated_req->tr_para.dtx;
772 /*
773 * calculate radio link timeout value
774 */
775 dd->rlt = dd->act_rlt = (UBYTE)((dedicated_req->tr_para.rlt + 1) * 4);
776
777 ALR_EM_SET_EM_ACT_RLT_2;
778
779 memset (&imm_ass->bcch_allocation, 0, sizeof (T_bcch_allocation));
780 imm_ass->ba_id = ALR_BA_LOW;
781 imm_ass->pwrc = dedicated_req->tr_para.pwrc;
782 /*
783 * store new parameters as temporary channel configuration
784 */
785 dd->temp_bcch = dedicated_req->arfcn;
786 dd->temp_channel_desc = imm_ass->channel_desc;
787 dd->temp_channel_mode = dedi_channel_mode (MODE_SIG_ONLY, 0);
788 dd->temp_frequency_list = imm_ass->frequency_list;
789 dd->temp_starting_time = imm_ass->starting_time;
790 dd->temp_frequency_list_bef_sti = imm_ass->frequency_list_bef_sti;
791 dd->temp_channel_desc_bef_sti = imm_ass->channel_desc;
792 dd->temp_channel_desc_bef_sti.chan_sel.rf_channel.maio
793 = imm_ass->maio_bef_sti;
794 dd->temp_pwrc = imm_ass->pwrc;
795 dd->temp_cipher_mode = CI_NO_CIPHERING;
796 dd->temp_a5_algorithm = 0;
797 memset ( &dd->temp_cipher_key, 0, sizeof (T_cipher_key) );
798
799 SET_STATE (STATE_DEDI, DEDI_IMM_ASS);
800
801 /*
802 * convert channel numbers if needed
803 */
804 if (dedi_conversion_needed ())
805 {
806 dedi_convert_chan_desc (&imm_ass->channel_desc);
807 dedi_convert_frequency_list (&imm_ass->frequency_list);
808 dedi_convert_frequency_list ((T_frequency_list *)&imm_ass->frequency_list_bef_sti);
809 }
810
811 /*
812 * send parameters to layer 1
813 */
814 ALR_TRACE_DEDI_PARA(imm_ass->channel_desc.chan_sel.h,
815 imm_ass->channel_desc.chan_sel.rf_channel.maio+
816 (imm_ass->channel_desc.chan_sel.rf_channel.hsn<<8),
817 imm_ass->channel_desc.channel_type,
818 imm_ass->channel_desc.sub_channel,
819 imm_ass->channel_desc.timeslot_no,
820 imm_ass->channel_desc.tsc,
821 imm_ass->timing_advance,
822 imm_ass->starting_time.start_time_present,
823 imm_ass->dtx_allowed,
824 imm_ass->maio_bef_sti);
825
826 ma_dedi_imm_ass_req (imm_ass);
827 }
828
829 #ifdef FF_L23_A5_3
830 /*
831 +--------------------------------------------------------------------+
832 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
833 | STATE : code ROUTINE : dedi_cyclically_repeat_kc |
834 +--------------------------------------------------------------------+
835
836 PURPOSE : This function is used to cyclically repeat the Kc.
837
838 */
839 LOCAL void dedi_cyclically_repeat_kc (UBYTE *to_kc, UBYTE *from_kc, U8 klen)
840 {
841 UBYTE i;
842
843 if (klen < KC_STRING_SIZE)
844 {
845 for(i=klen ; i < KC_STRING_SIZE ; i++)
846 {
847 to_kc[i]=from_kc[i-klen];
848 }
849 }
850
851 }
852 #endif
853
854 /*
855 +--------------------------------------------------------------------+
856 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
857 | STATE : code ROUTINE : dedi_chan_ass |
858 +--------------------------------------------------------------------+
859
860 PURPOSE : Converts MPH_DEDICATED_REQ to MPHC_CHANNEL_ASSIGN_REQ.
861 This function is used during channel assignment procedure.
862
863 */
864
865 LOCAL void dedi_chan_ass (T_MPH_DEDICATED_REQ *dedicated_req)
866 {
867 GET_INSTANCE_DATA;
868
869 PALLOC (chan_ass, MPHC_CHANNEL_ASSIGN_REQ);
870
871 ALR_EM_CONFIGURE_CHANNEL_ASSIGNMENT;
872
873 memset (chan_ass, 0, sizeof (T_MPHC_CHANNEL_ASSIGN_REQ));
874 dedi_chan_type_sel(&dedicated_req->ch_type,
875 &(chan_ass->channel_desc_1.chan_sel),
876 &chan_ass->frequency_list);
877 /*
878 * fill the layer 1 structure
879 */
880 alr_data->dedi_data.temp_channel =
881 chan_ass->channel_desc_1.channel_type =
882 CH_TYPE [dedicated_req->ch_type.ch];
883 chan_ass->channel_desc_1.sub_channel =
884 SUB_TYPE [dedicated_req->ch_type.ch];
885 chan_ass->channel_desc_1.timeslot_no = dedicated_req->ch_type.tn;
886 chan_ass->channel_desc_1.tsc = dedicated_req->ch_type.tsc;
887 chan_ass->txpwr = cut_power_value (dedicated_req->tr_para.power,
888 dedicated_req);
889 chan_ass->channel_mode_1 = dedi_channel_mode(dedicated_req->tr_para.mode,
890 alr_data->dedi_data.temp_channel);
891 chan_ass->amr_configuration.noise_suppression_control_bit = dedicated_req->amr_conf.nscb;
892 chan_ass->amr_configuration.initial_codec_mode_indicator = dedicated_req->amr_conf.icmi;
893 chan_ass->amr_configuration.initial_codec_mode = dedicated_req->amr_conf.st_mode;
894 chan_ass->amr_configuration.active_codec_set = dedicated_req->amr_conf.acs;
895 /* Traces only needed for IOT session */
896 TRACE_EVENT_P1("*AMR NSCB %d", chan_ass->amr_configuration.noise_suppression_control_bit);
897 TRACE_EVENT_P1("*AMR ICMI %d", chan_ass->amr_configuration.initial_codec_mode_indicator);
898 TRACE_EVENT_P1("*AMR ICM %d", chan_ass->amr_configuration.initial_codec_mode);
899 TRACE_EVENT_P1("*AMR ACS %d", chan_ass->amr_configuration.active_codec_set);
900 dedi_set_amr_conf(&chan_ass->amr_configuration, &dedicated_req->amr_conf);
901 chan_ass->starting_time.start_time_present =
902 dedicated_req->start.v_start;
903 chan_ass->starting_time.start_time.t1 =
904 dedicated_req->start.t1;
905 chan_ass->starting_time.start_time.t3 =
906 dedicated_req->start.t3;
907 chan_ass->starting_time.start_time.t2 =
908 dedicated_req->start.t2;
909
910 if (dedicated_req->ch_type2.ch NEQ NOT_PRESENT_8BIT)
911 {
912 dedi_chan_type_sel(&dedicated_req->ch_type2,
913 &(chan_ass->channel_desc_1_bef_sti.chan_sel),
914 (T_frequency_list *)&chan_ass->frequency_list_bef_sti);
915 chan_ass->channel_desc_1_bef_sti.channel_type =
916 CH_TYPE [dedicated_req->ch_type2.ch];
917 chan_ass->channel_desc_1_bef_sti.sub_channel =
918 SUB_TYPE [dedicated_req->ch_type2.ch];
919 chan_ass->channel_desc_1_bef_sti.timeslot_no =
920 dedicated_req->ch_type2.tn;
921 chan_ass->channel_desc_1_bef_sti.tsc =
922 dedicated_req->ch_type2.tsc;
923 }
924 chan_ass->cipher_mode = dedicated_req->ciph.stat;
925 chan_ass->a5_algorithm = dedicated_req->ciph.algo;
926 memcpy (&chan_ass->cipher_key, dedicated_req->ciph.kc, KC_STRING_SIZE);
927 #ifdef FF_L23_A5_3
928 dedi_cyclically_repeat_kc ((UBYTE *)&chan_ass->cipher_key, (UBYTE *)dedicated_req->ciph.kc, KLEN);
929 #endif
930 chan_ass->dtx_allowed = dedicated_req->tr_para.dtx;
931
932 /*
933 * store the new configuration as temporary configuration
934 */
935 alr_data->dedi_data.temp_bcch = dedicated_req->arfcn;
936 memcpy (&alr_data->dedi_data.temp_channel_desc,
937 &chan_ass->channel_desc_1,
938 sizeof (T_channel_desc));
939 alr_data->dedi_data.temp_channel_mode = chan_ass->channel_mode_1;
940 alr_data->dedi_data.temp_frequency_list = chan_ass->frequency_list;
941 alr_data->dedi_data.temp_cipher_mode = chan_ass->cipher_mode;
942 alr_data->dedi_data.temp_a5_algorithm = chan_ass->a5_algorithm;
943 alr_data->dedi_data.temp_cipher_key = chan_ass->cipher_key;
944 alr_data->dedi_data.temp_power = chan_ass->txpwr;
945 alr_data->dedi_data.temp_dtx_allowed = chan_ass->dtx_allowed;
946 alr_data->dedi_data.act_mode = MODE_CHAN_ASSIGN;
947 alr_data->dedi_data.temp_amr_configuration = chan_ass->amr_configuration;
948
949 /*
950 * convert channel numbers if needed
951 */
952 if (dedi_conversion_needed ())
953 {
954 dedi_convert_chan_desc ((T_channel_desc *)&chan_ass->channel_desc_1);
955 dedi_convert_chan_desc ((T_channel_desc *)&chan_ass->channel_desc_1_bef_sti);
956 dedi_convert_frequency_list (&chan_ass->frequency_list);
957 dedi_convert_frequency_list ((T_frequency_list *)&chan_ass->frequency_list_bef_sti);
958 }
959
960 /*
961 * inform layer 1 about the new channel configuration
962 */
963 ma_dedi_chan_ass_req (chan_ass);
964 }
965
966 /*
967 +--------------------------------------------------------------------+
968 | PROJECT : GSM-PS (8403) MODULE : alr_dedi |
969 | STATE : code ROUTINE : dedi_pdch_ass |
970 +--------------------------------------------------------------------+
971
972 PURPOSE : "Deactivation of previously assigned channels (layer1)"
973 according to GSM 04.18, clause 3.4.19 during a
974 PDCH Assignment procedure.
975
976 */
977
978 LOCAL void dedi_pdch_ass (T_MPH_DEDICATED_REQ *dedicated_req)
979 {
980 GET_INSTANCE_DATA;
981 T_DEDI_DATA *d = &alr_data->dedi_data;
982
983 /*
984 * The PDCH Assignment Procedure is similar to the Channel Assignment
985 * Procedure. Both are perfomred in dedicated state in order to switch
986 * to a 'new' channel. "Normal operation" is suspend during the procedure.
987 * In case of failure the old channel is activated and the message
988 * ASSIGNMENT FAILURE is sent.
989 */
990
991 ma_stop_active_procs ( STOP_PCH_READING );
992
993 /* Current state is now DEDI_INACTIVE.
994 * In Layer 1 SDCCH or TCH is stopped. In order to re-activate the channel
995 * (failure to TBF establishment), the Current Channel Configuration must be
996 * stored. This configuration will then be used to re-establish the channel.
997 * The Current Channel Configuration is provided in the last successful
998 * Immediate Assignment, Channel Assignment or Handover in the variables
999 * alr_data->dedi_data.act***. The re-activation can be done with the
1000 * Immediate Assignment Procedure followed by a Channel Assignment Procedure.
1001 * However there is the prerequisite that L1 must be in Idle Mode to perform
1002 * Immediate Assignment. This will be achieved by sending MPH-IDLE-REQ.
1003 */
1004
1005 d->old_channel = actual_channel;
1006 d->old_bcch = d->act_bcch;
1007 d->old_channel_desc = d->act_channel_desc;
1008 d->old_channel_mode = d->act_channel_mode;
1009 d->old_frequency_list = d->act_frequency_list;
1010 d->old_starting_time = d->act_starting_time;
1011 d->old_frequency_list_bef_sti = d->act_frequency_list_bef_sti;
1012 d->old_channel_desc_bef_sti = d->act_channel_desc_bef_sti;
1013 d->old_pwrc = d->act_pwrc;
1014 d->old_cipher_mode = d->act_cipher_mode;
1015 d->old_a5_algorithm = d->act_a5_algorithm;
1016 d->old_cipher_key = d->act_cipher_key;
1017 d->old_power = d->act_power;
1018 d->old_dtx_allowed = d->act_dtx_allowed;
1019
1020 /*
1021 * Save the activation mode for Resume / Reconnection
1022 */
1023 alr_data->dedi_data.act_mode = MODE_PDCH_ASSIGN;
1024 }
1025
1026 /*
1027 +--------------------------------------------------------------------+
1028 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1029 | STATE : code ROUTINE : dedi_async_handover |
1030 +--------------------------------------------------------------------+
1031
1032 PURPOSE : Converts MPH_DEDICATED_REQ to MPHC_ASYNC_HO_REQ.
1033 This function is used during asynchronous handover.
1034
1035 */
1036
1037 LOCAL void dedi_async_handover (T_MPH_DEDICATED_REQ * dedicated_req)
1038 {
1039 GET_INSTANCE_DATA;
1040
1041 PALLOC (async, MPHC_ASYNC_HO_REQ);
1042
1043 ALR_EM_CONFIGURE_HANDOVER(EM_HANDOVER_ASYNC);
1044
1045 memset (async, 0, sizeof (T_MPHC_ASYNC_HO_REQ));
1046 if (dedicated_req->ch_type.h EQ 1)
1047 {
1048 ALR_TRACE_DEDI ("hopping");
1049 /*
1050 * new channel with frequency hopping.
1051 */
1052 async->handover_command.channel_desc_1.chan_sel.h = 1;
1053 async->handover_command.channel_desc_1.chan_sel.rf_channel.maio =
1054 dedicated_req->ch_type.maio;
1055 async->handover_command.channel_desc_1.chan_sel.rf_channel.hsn =
1056 dedicated_req->ch_type.hsn;
1057 dedi_fill_ma (dedicated_req->ch_type.ma,
1058 &async->handover_command.frequency_list);
1059 }
1060 else
1061 {
1062 ALR_TRACE_DEDI ("no hop");
1063 /*
1064 * Avoid the union in the non-hopping case. Mapping
1065 * of arfcn to maio and hsn.
1066 */
1067 async->handover_command.channel_desc_1.chan_sel.h = 0;
1068 async->handover_command.channel_desc_1.chan_sel.rf_channel.maio =
1069 (UBYTE)(dedicated_req->ch_type.arfcn & 0xFF);
1070 async->handover_command.channel_desc_1.chan_sel.rf_channel.hsn =
1071 (UBYTE)((dedicated_req->ch_type.arfcn >> 8) & 0xFF);
1072 }
1073
1074 /*
1075 * convert the parameters to the layer 1 structure
1076 */
1077 alr_data->dedi_data.temp_channel = async->handover_command.channel_desc_1.channel_type = CH_TYPE [dedicated_req->ch_type.ch];
1078 async->handover_command.channel_desc_1.sub_channel = SUB_TYPE [dedicated_req->ch_type.ch];
1079 async->handover_command.channel_desc_1.timeslot_no = dedicated_req->ch_type.tn;
1080 async->handover_command.channel_desc_1.tsc = dedicated_req->ch_type.tsc;
1081 async->handover_command.txpwr = cut_power_value (dedicated_req->ho_param.ho_pow, dedicated_req);
1082 async->handover_command.ho_acc = dedicated_req->ho_param.ho_ref;
1083 async->handover_command.starting_time.start_time_present = dedicated_req->start.v_start;
1084 if (dedicated_req->start.v_start)
1085 {
1086 ALR_TRACE_DEDI ("start time");
1087
1088 async->handover_command.starting_time.start_time.t1 = dedicated_req->start.t1;
1089 async->handover_command.starting_time.start_time.t3 = dedicated_req->start.t3;
1090 async->handover_command.starting_time.start_time.t2 = dedicated_req->start.t2;
1091 }
1092 async->handover_command.cell_description.ncc = (UBYTE)(dedicated_req->bsic >> 3);
1093 async->handover_command.cell_description.bcc = (UBYTE)(dedicated_req->bsic & 7);
1094 async->handover_command.cell_description.bcch_carrier = ARFCN_TO_L1 (dedicated_req->arfcn);
1095 async->handover_command.channel_mode_1 =
1096 dedi_channel_mode (dedicated_req->tr_para.mode,
1097 alr_data->dedi_data.temp_channel);
1098 async->amr_configuration.noise_suppression_control_bit = dedicated_req->amr_conf.nscb;
1099 async->amr_configuration.initial_codec_mode_indicator = dedicated_req->amr_conf.icmi;
1100 async->amr_configuration.initial_codec_mode = dedicated_req->amr_conf.st_mode;
1101 async->amr_configuration.active_codec_set = dedicated_req->amr_conf.acs;
1102 /* Traces only needed for IOT session */
1103 TRACE_EVENT_P1("*AMR NSCB %d", async->amr_configuration.noise_suppression_control_bit);
1104 TRACE_EVENT_P1("*AMR ICMI %d", async->amr_configuration.initial_codec_mode_indicator);
1105 TRACE_EVENT_P1("*AMR ICM %d", async->amr_configuration.initial_codec_mode);
1106 TRACE_EVENT_P1("*AMR ACS %d", async->amr_configuration.active_codec_set);
1107 dedi_set_amr_conf( &async->amr_configuration, &dedicated_req->amr_conf);
1108
1109 if (dedicated_req->start.v_start AND
1110 dedicated_req->ch_type2.ch NEQ NOT_PRESENT_8BIT)
1111 {
1112 ALR_TRACE_DEDI ("bef sti");
1113 /*
1114 * before starting time elements are available
1115 */
1116
1117 dedi_chan_type_sel (&dedicated_req->ch_type2,
1118 &(async->handover_command.channel_desc_1_bef_sti.chan_sel),
1119 (T_frequency_list *)&async->handover_command.frequency_list_bef_sti);
1120
1121 async->handover_command.channel_desc_1_bef_sti.channel_type = CH_TYPE [dedicated_req->ch_type2.ch];
1122 async->handover_command.channel_desc_1_bef_sti.sub_channel = SUB_TYPE [dedicated_req->ch_type2.ch];
1123 async->handover_command.channel_desc_1_bef_sti.timeslot_no = dedicated_req->ch_type2.tn;
1124 async->handover_command.channel_desc_1_bef_sti.tsc = dedicated_req->ch_type2.tsc;
1125 }
1126 async->handover_command.cipher_mode = dedicated_req->ciph.stat;
1127 async->handover_command.a5_algorithm = dedicated_req->ciph.algo;
1128 memcpy (&async->cipher_key, dedicated_req->ciph.kc, KC_STRING_SIZE);
1129 #ifdef FF_L23_A5_3
1130 dedi_cyclically_repeat_kc ((UBYTE *)&async->cipher_key, (UBYTE *)dedicated_req->ciph.kc, KLEN);
1131 #endif
1132
1133 /*
1134 * store the new parameters as temporary configuration.
1135 */
1136 alr_data->dedi_data.temp_bcch = dedicated_req->arfcn;
1137 memcpy (&alr_data->dedi_data.temp_channel_desc, &async->handover_command.channel_desc_1, sizeof (T_channel_desc));
1138 alr_data->dedi_data.temp_channel_mode = async->handover_command.channel_mode_1;
1139 alr_data->dedi_data.temp_frequency_list = async->handover_command.frequency_list;
1140 alr_data->dedi_data.temp_cipher_mode = async->handover_command.cipher_mode;
1141 alr_data->dedi_data.temp_a5_algorithm = async->handover_command.a5_algorithm;
1142 alr_data->dedi_data.temp_cipher_key = async->cipher_key;
1143 alr_data->dedi_data.temp_power = async->handover_command.txpwr;
1144 alr_data->dedi_data.temp_bsic = dedicated_req->bsic;
1145 alr_data->dedi_data.temp_amr_configuration = async->amr_configuration;
1146 alr_data->dedi_data.act_mode = MODE_ASYNC_HANDOVER;
1147
1148 #if defined (REL99) && defined (FF_BHO)
1149 dedi_set_ho_type ((ULONG *)&async->fn_offset, (ULONG *)&async->time_alignmnt, &async->handover_type);
1150 #else
1151 nc_get_fn_time (alr_data->dedi_data.temp_bcch, (ULONG *)&async->fn_offset, (ULONG *)&async->time_alignmnt);
1152 #endif
1153
1154 /*
1155 * convert channel numbers if needed
1156 */
1157 if (dedi_conversion_needed ())
1158 {
1159 dedi_convert_chan_desc ((T_channel_desc *)&async->handover_command.channel_desc_1);
1160 dedi_convert_chan_desc ((T_channel_desc *)&async->handover_command.channel_desc_1_bef_sti);
1161 dedi_convert_frequency_list (&async->handover_command.frequency_list);
1162 dedi_convert_frequency_list ((T_frequency_list *)&async->handover_command.frequency_list_bef_sti);
1163 }
1164 /*
1165 * forward the parameters to layer 1
1166 */
1167 ALR_TRACE_DEDI_HO_1 (dedicated_req->arfcn,
1168 dedicated_req->bsic,
1169 dedicated_req->start.v_start,
1170 dedicated_req->ch_type2.ch,
1171 dedicated_req->ch_type.ch,
1172 dedicated_req->ch_type.tsc);
1173 ALR_TRACE_DEDI_HO_2 (dedicated_req->ch_type.tn,
1174 dedicated_req->ch_type.arfcn,
1175 dedicated_req->ho_param.ho_pow,
1176 dedicated_req->ho_param.ho_ref,
1177 dedicated_req->ho_param.ho_acc_type,
1178 dedicated_req->ho_param.ho_nci);
1179 ALR_TRACE_DEDI_HO_3 (dedicated_req->tr_para.mode,
1180 dedicated_req->tr_para.power,
1181 dedicated_req->tr_para.dtx,
1182 dedicated_req->tr_para.rlt,
1183 dedicated_req->tr_para.tav,
1184 dedicated_req->tr_para.pwrc);
1185 ALR_TRACE_DEDI_HO_4 (dedicated_req->tr_para.mode,
1186 dedicated_req->ciph.stat,
1187 dedicated_req->ciph.algo);
1188 ALR_TRACE_DEDI_HO_5 (async->handover_command.channel_desc_1.chan_sel.h,
1189 async->handover_command.channel_desc_1.chan_sel.rf_channel.maio,
1190 async->handover_command.channel_desc_1.chan_sel.rf_channel.hsn,
1191 async->handover_command.channel_desc_1.channel_type,
1192 async->handover_command.channel_desc_1.sub_channel,
1193 async->handover_command.channel_desc_1.timeslot_no);
1194 ALR_TRACE_DEDI_HO_6 (async->handover_command.channel_desc_1.tsc,
1195 async->handover_command.txpwr,
1196 async->handover_command.ho_acc,
1197 async->handover_command.starting_time.start_time_present,
1198 async->handover_command.cell_description.ncc,
1199 async->handover_command.cell_description.bcc);
1200 ALR_TRACE_DEDI_HO_7 (async->handover_command.cell_description.bcch_carrier,
1201 async->handover_command.channel_mode_1,
1202 async->handover_command.cipher_mode,
1203 async->handover_command.a5_algorithm);
1204
1205 ma_dedi_async_ho_req (async);
1206 }
1207
1208
1209 /*
1210 +--------------------------------------------------------------------+
1211 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1212 | STATE : code ROUTINE : dedi_sync_handover |
1213 +--------------------------------------------------------------------+
1214
1215 PURPOSE : Converts MPH_DEDICATED_REQ to MPHC_SYNC_HO_REQ.
1216 This function is used during synchronous handover.
1217
1218 */
1219
1220 LOCAL void dedi_sync_handover (T_MPH_DEDICATED_REQ *dedicated_req)
1221 {
1222 GET_INSTANCE_DATA;
1223
1224 PALLOC (sync, MPHC_SYNC_HO_REQ);
1225
1226 ALR_EM_CONFIGURE_HANDOVER(EM_HANDOVER_SYNC);
1227
1228 memset (sync, 0, sizeof (T_MPHC_SYNC_HO_REQ));
1229 dedi_chan_type_sel(&dedicated_req->ch_type,
1230 &(sync->handover_command.channel_desc_1.chan_sel),
1231 &(sync->handover_command.frequency_list));
1232 /*
1233 * fill layer 1 structure with the new parameters
1234 */
1235 alr_data->dedi_data.temp_channel =
1236 sync->handover_command.channel_desc_1.channel_type =
1237 CH_TYPE [dedicated_req->ch_type.ch];
1238 sync->handover_command.channel_desc_1.sub_channel =
1239 SUB_TYPE [dedicated_req->ch_type.ch];
1240 sync->handover_command.channel_desc_1.timeslot_no =
1241 dedicated_req->ch_type.tn;
1242 sync->handover_command.channel_desc_1.tsc = dedicated_req->ch_type.tsc;
1243 sync->handover_command.txpwr =
1244 cut_power_value (dedicated_req->ho_param.ho_pow, dedicated_req);
1245 sync->handover_command.ho_acc = dedicated_req->ho_param.ho_ref;
1246 sync->handover_command.starting_time.start_time_present =
1247 dedicated_req->start.v_start;
1248 sync->handover_command.starting_time.start_time.t1 =
1249 dedicated_req->start.t1;
1250 sync->handover_command.starting_time.start_time.t3 =
1251 dedicated_req->start.t3;
1252 sync->handover_command.starting_time.start_time.t2 =
1253 dedicated_req->start.t2;
1254
1255 sync->nci = dedicated_req->ho_param.ho_nci;
1256 sync->handover_command.cell_description.ncc =
1257 (UBYTE)(dedicated_req->bsic >> 3);
1258 sync->handover_command.cell_description.bcc =
1259 (UBYTE)(dedicated_req->bsic & 7);
1260 sync->handover_command.cell_description.bcch_carrier =
1261 ARFCN_TO_L1(dedicated_req->arfcn);
1262 sync->handover_command.channel_mode_1 =
1263 dedi_channel_mode (dedicated_req->tr_para.mode,
1264 alr_data->dedi_data.temp_channel);
1265 sync->amr_configuration.noise_suppression_control_bit = dedicated_req->amr_conf.nscb;
1266 sync->amr_configuration.initial_codec_mode_indicator = dedicated_req->amr_conf.icmi;
1267 sync->amr_configuration.initial_codec_mode = dedicated_req->amr_conf.st_mode;
1268 sync->amr_configuration.active_codec_set = dedicated_req->amr_conf.acs;
1269 /* Traces only needed for IOT session */
1270 TRACE_EVENT_P1("*AMR NSCB %d", sync->amr_configuration.noise_suppression_control_bit);
1271 TRACE_EVENT_P1("*AMR ICMI %d", sync->amr_configuration.initial_codec_mode_indicator);
1272 TRACE_EVENT_P1("*AMR ICM %d", sync->amr_configuration.initial_codec_mode);
1273 TRACE_EVENT_P1("*AMR ACS %d", sync->amr_configuration.active_codec_set);
1274 dedi_set_amr_conf(&sync->amr_configuration, &dedicated_req->amr_conf);
1275 dedi_chan_type_desc (dedicated_req,
1276 (T_channel_desc_1_bef_sti *)&(sync->handover_command.channel_desc_1_bef_sti),
1277 (T_frequency_list *)&sync->handover_command.frequency_list_bef_sti);
1278 sync->handover_command.cipher_mode = dedicated_req->ciph.stat;
1279 sync->handover_command.a5_algorithm = dedicated_req->ciph.algo;
1280 memcpy (&sync->cipher_key, dedicated_req->ciph.kc, KC_STRING_SIZE);
1281 #ifdef FF_L23_A5_3
1282 dedi_cyclically_repeat_kc ((UBYTE *)&sync->cipher_key, (UBYTE *)dedicated_req->ciph.kc, KLEN);
1283 #endif
1284
1285 /*
1286 * store the new values as temporary configuration
1287 */
1288 alr_data->dedi_data.temp_bcch = dedicated_req->arfcn;
1289 memcpy (&alr_data->dedi_data.temp_channel_desc,
1290 &sync->handover_command.channel_desc_1,
1291 sizeof (T_channel_desc));
1292 alr_data->dedi_data.temp_channel_mode =
1293 sync->handover_command.channel_mode_1;
1294 alr_data->dedi_data.temp_frequency_list =
1295 sync->handover_command.frequency_list;
1296 alr_data->dedi_data.temp_cipher_mode =
1297 sync->handover_command.cipher_mode;
1298 alr_data->dedi_data.temp_a5_algorithm =
1299 sync->handover_command.a5_algorithm;
1300 alr_data->dedi_data.temp_cipher_key =
1301 sync->cipher_key;
1302 alr_data->dedi_data.temp_power = sync->handover_command.txpwr;
1303 alr_data->dedi_data.temp_bsic = dedicated_req->bsic;
1304 alr_data->dedi_data.temp_amr_configuration = sync->amr_configuration;
1305 alr_data->dedi_data.act_mode = MODE_SYNC_HANDOVER;
1306
1307 #if defined (REL99) && defined (FF_BHO)
1308 dedi_set_ho_type ((ULONG *)&sync->fn_offset, (ULONG *)&sync->time_alignmnt, &sync->handover_type);
1309 #else
1310 nc_get_fn_time (alr_data->dedi_data.temp_bcch,
1311 (ULONG *)&sync->fn_offset,
1312 (ULONG *)&sync->time_alignmnt);
1313 #endif
1314
1315 /*
1316 * convert channel numbers if needed
1317 */
1318 if (dedi_conversion_needed ())
1319 {
1320 dedi_convert_chan_desc ((T_channel_desc *)&sync->handover_command.channel_desc_1);
1321 dedi_convert_chan_desc ((T_channel_desc *)&sync->handover_command.channel_desc_1_bef_sti);
1322 dedi_convert_frequency_list (&sync->handover_command.frequency_list);
1323 dedi_convert_frequency_list ((T_frequency_list *)&sync->handover_command.frequency_list_bef_sti);
1324 }
1325 /*
1326 * forward the new configuration to layer 1
1327 */
1328 ma_dedi_sync_ho_req (sync);
1329 }
1330
1331 /*
1332 +--------------------------------------------------------------------+
1333 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1334 | STATE : code ROUTINE : dedi_pre_sync_handover |
1335 +--------------------------------------------------------------------+
1336
1337 PURPOSE : Converts MPH_DEDICATED_REQ to MPHC_PRE_SYNC_HO_REQ.
1338 This function is used during pre-synchronous handover.
1339
1340 */
1341
1342 LOCAL void dedi_pre_sync_handover (T_MPH_DEDICATED_REQ *dedicated_req)
1343 {
1344 GET_INSTANCE_DATA;
1345
1346 PALLOC (presync, MPHC_PRE_SYNC_HO_REQ);
1347
1348 ALR_EM_CONFIGURE_HANDOVER(EM_HANDOVER_PRE_SYNC);
1349
1350 memset (presync, 0, sizeof (T_MPHC_PRE_SYNC_HO_REQ));
1351 dedi_chan_type_sel(&dedicated_req->ch_type,
1352 &(presync->handover_command.channel_desc_1.chan_sel),
1353 &(presync->handover_command.frequency_list));
1354
1355 /*
1356 * fill layer 1 structure with the new parameters
1357 */
1358 alr_data->dedi_data.temp_channel =
1359 presync->handover_command.channel_desc_1.channel_type =
1360 CH_TYPE [dedicated_req->ch_type.ch];
1361 presync->handover_command.channel_desc_1.sub_channel =
1362 SUB_TYPE [dedicated_req->ch_type.ch];
1363 presync->handover_command.channel_desc_1.timeslot_no =
1364 dedicated_req->ch_type.tn;
1365 presync->handover_command.channel_desc_1.tsc = dedicated_req->ch_type.tsc;
1366 presync->handover_command.txpwr =
1367 cut_power_value (dedicated_req->ho_param.ho_pow, dedicated_req);
1368 presync->handover_command.ho_acc = dedicated_req->ho_param.ho_ref;
1369 presync->handover_command.starting_time.start_time_present =
1370 dedicated_req->start.v_start;
1371 presync->handover_command.starting_time.start_time.t1 =
1372 dedicated_req->start.t1;
1373 presync->handover_command.starting_time.start_time.t3 =
1374 dedicated_req->start.t3;
1375 presync->handover_command.starting_time.start_time.t2 =
1376 dedicated_req->start.t2;
1377 presync->handover_command.cell_description.ncc =
1378 (UBYTE)(dedicated_req->bsic >> 3);
1379 presync->handover_command.cell_description.bcc =
1380 (UBYTE)(dedicated_req->bsic & 7);
1381 presync->handover_command.cell_description.bcch_carrier =
1382 ARFCN_TO_L1(dedicated_req->arfcn);
1383 presync->nci = dedicated_req->ho_param.ho_nci;
1384 presync->handover_command.channel_mode_1 =
1385 dedi_channel_mode (dedicated_req->tr_para.mode,
1386 alr_data->dedi_data.temp_channel);
1387 presync->amr_configuration.noise_suppression_control_bit = dedicated_req->amr_conf.nscb;
1388 presync->amr_configuration.initial_codec_mode_indicator = dedicated_req->amr_conf.icmi;
1389 presync->amr_configuration.initial_codec_mode = dedicated_req->amr_conf.st_mode;
1390 presync->amr_configuration.active_codec_set = dedicated_req->amr_conf.acs;
1391 /* Traces only needed for IOT session */
1392 TRACE_EVENT_P1("*AMR NSCB %d", presync->amr_configuration.noise_suppression_control_bit);
1393 TRACE_EVENT_P1("*AMR ICMI %d", presync->amr_configuration.initial_codec_mode_indicator);
1394 TRACE_EVENT_P1("*AMR ICM %d", presync->amr_configuration.initial_codec_mode);
1395 TRACE_EVENT_P1("*AMR ACS %d", presync->amr_configuration.active_codec_set);
1396 dedi_set_amr_conf(&presync->amr_configuration, &dedicated_req->amr_conf);
1397 presync->timing_advance_valid = TRUE;
1398 presync->timing_advance = dedicated_req->tr_para.tav;
1399
1400 dedi_chan_type_desc (dedicated_req,
1401 (T_channel_desc_1_bef_sti *)&(presync->handover_command.channel_desc_1_bef_sti),
1402 (T_frequency_list *)&presync->handover_command.frequency_list_bef_sti);
1403 presync->handover_command.cipher_mode = dedicated_req->ciph.stat;
1404 presync->handover_command.a5_algorithm = dedicated_req->ciph.algo;
1405 memcpy (&presync->cipher_key, dedicated_req->ciph.kc, KC_STRING_SIZE);
1406 #ifdef FF_L23_A5_3
1407 dedi_cyclically_repeat_kc ((UBYTE *)&presync->cipher_key, (UBYTE *)dedicated_req->ciph.kc, KLEN);
1408 #endif
1409
1410 /*
1411 * store the new parameters as temporary configuration.
1412 */
1413 alr_data->dedi_data.temp_bcch = dedicated_req->arfcn;
1414 memcpy (&alr_data->dedi_data.temp_channel_desc,
1415 &presync->handover_command.channel_desc_1,
1416 sizeof (T_channel_desc));
1417 alr_data->dedi_data.temp_channel_mode =
1418 presync->handover_command.channel_mode_1;
1419 alr_data->dedi_data.temp_frequency_list =
1420 presync->handover_command.frequency_list;
1421 alr_data->dedi_data.temp_cipher_mode =
1422 presync->handover_command.cipher_mode;
1423 alr_data->dedi_data.temp_a5_algorithm =
1424 presync->handover_command.a5_algorithm;
1425 alr_data->dedi_data.temp_cipher_key =
1426 presync->cipher_key;
1427 alr_data->dedi_data.temp_power = presync->handover_command.txpwr;
1428 alr_data->dedi_data.temp_bsic = dedicated_req->bsic;
1429 alr_data->dedi_data.temp_amr_configuration = presync->amr_configuration;
1430 alr_data->dedi_data.act_mode = MODE_PRE_SYNC_HANDOVER;
1431
1432 #if defined (REL99) && defined (FF_BHO)
1433 dedi_set_ho_type ((ULONG *)&presync->fn_offset,
1434 (ULONG *)&presync->time_alignmnt, &presync->handover_type);
1435 #else
1436 nc_get_fn_time (alr_data->dedi_data.temp_bcch,
1437 (ULONG *)&presync->fn_offset,
1438 (ULONG *)&presync->time_alignmnt);
1439 #endif
1440
1441 /*
1442 * convert channel numbers if needed
1443 */
1444 if (dedi_conversion_needed ())
1445 {
1446 dedi_convert_chan_desc ((T_channel_desc *)&presync->handover_command.channel_desc_1);
1447 dedi_convert_chan_desc ((T_channel_desc *)&presync->handover_command.channel_desc_1_bef_sti);
1448 dedi_convert_frequency_list (&presync->handover_command.frequency_list);
1449 dedi_convert_frequency_list ((T_frequency_list *)&presync->handover_command.frequency_list_bef_sti);
1450 }
1451 /*
1452 * forward the parameters to layer 1
1453 */
1454 ma_dedi_pre_sync_ho_req (presync);
1455 }
1456
1457 /*
1458 +--------------------------------------------------------------------+
1459 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1460 | STATE : code ROUTINE : dedi_freq_redef_req |
1461 +--------------------------------------------------------------------+
1462
1463 PURPOSE : Process signal dedi_freq_redef_req from SDL Process
1464 alr_MAIN.
1465 This function is used during frequency redefinition.
1466
1467 */
1468
1469 GLOBAL void dedi_freq_redef_req (T_MPH_FREQ_REDEF_REQ *freq)
1470 {
1471 GET_INSTANCE_DATA;
1472 PALLOC (change, MPHC_CHANGE_FREQUENCY);
1473
1474 ALR_EM_CONFIGURE_FREQUENCY_REDEFINITION;
1475
1476 memset (change, 0, sizeof (T_MPHC_CHANGE_FREQUENCY));
1477 dedi_chan_type_sel(&freq->ch_type,
1478 &(change->channel_desc.chan_sel),
1479 &change->frequency_list);
1480
1481 /*
1482 * fill layer 1 structure with the parameters.
1483 */
1484 change->channel_desc.channel_type = CH_TYPE [freq->ch_type.ch];
1485 change->channel_desc.sub_channel = SUB_TYPE [freq->ch_type.ch];
1486 change->channel_desc.timeslot_no = freq->ch_type.tn;
1487 change->channel_desc.tsc = freq->ch_type.tsc;
1488 change->starting_time.start_time_present = freq->start.v_start;
1489 change->starting_time.start_time.t1 = freq->start.t1;
1490 change->starting_time.start_time.t3 = freq->start.t3;
1491 change->starting_time.start_time.t2 = freq->start.t2;
1492
1493 /*
1494 * store new values as temporary configuration
1495 */
1496 alr_data->dedi_data.redef_channel_desc = change->channel_desc;
1497 alr_data->dedi_data.redef_frequency_list = change->frequency_list;
1498 alr_data->dedi_data.redef_starting_time = change->starting_time;
1499
1500 /*
1501 * convert channel numbers if needed
1502 */
1503 if (dedi_conversion_needed ())
1504 {
1505 dedi_convert_chan_desc (&change->channel_desc);
1506 dedi_convert_frequency_list (&change->frequency_list);
1507 }
1508 /*
1509 * forward parameters to layer 1
1510 */
1511 ma_dedi_change_freq_req (change);
1512
1513 }
1514
1515 /*
1516 +--------------------------------------------------------------------+
1517 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1518 | STATE : code ROUTINE : dedi_chan_mode_req |
1519 +--------------------------------------------------------------------+
1520
1521 PURPOSE : Process signal dedi_chan_mode_req from SDL Process
1522 alr_MAIN.
1523 This function is used during channel mode modify procedure.
1524
1525 */
1526
1527 GLOBAL void dedi_chan_mode_req (T_MPH_CHANNEL_MODE_REQ *ch_mode)
1528 {
1529 GET_INSTANCE_DATA;
1530 int i;
1531 PALLOC (chm, MPHC_CHANNEL_MODE_MODIFY_REQ);
1532
1533 ALR_EM_CONFIGURE_CHANNEL_MODE_MODIFY;
1534
1535 memset (chm, 0, sizeof (T_MPHC_CHANNEL_MODE_MODIFY_REQ));
1536 /*
1537 * convert parameters
1538 */
1539 chm->sub_channel = SUB_TYPE [ch_mode->ch];
1540 alr_data->dedi_data.act_channel_mode =
1541 chm->channel_mode = dedi_channel_mode (ch_mode->mode,
1542 actual_channel);
1543
1544 /*
1545 * set multirate configuration parameters
1546 */
1547 if(ch_mode->mode EQ CM_AMR)
1548 {
1549 alr_data->dedi_data.act_amr_configuration.noise_suppression_control_bit =
1550 chm->amr_configuration.noise_suppression_control_bit = ch_mode->amr_conf.nscb;
1551 alr_data->dedi_data.act_amr_configuration.initial_codec_mode_indicator =
1552 chm->amr_configuration.initial_codec_mode_indicator = ch_mode->amr_conf.icmi;
1553 alr_data->dedi_data.act_amr_configuration.initial_codec_mode =
1554 chm->amr_configuration.initial_codec_mode = ch_mode->amr_conf.st_mode;
1555 alr_data->dedi_data.act_amr_configuration.active_codec_set =
1556 chm->amr_configuration.active_codec_set = ch_mode->amr_conf.acs;
1557
1558 /* Traces only needed for IOT session */
1559 TRACE_EVENT_P1("*AMR NSCB %d", chm->amr_configuration.noise_suppression_control_bit);
1560 TRACE_EVENT_P1("*AMR ICMI %d", chm->amr_configuration.initial_codec_mode_indicator);
1561 TRACE_EVENT_P1("*AMR ICM %d", chm->amr_configuration.initial_codec_mode);
1562 TRACE_EVENT_P1("*AMR ACS %d", chm->amr_configuration.active_codec_set);
1563 for (i=0; i<ch_mode->amr_conf.c_cod_prop; i++)
1564 {
1565 memcpy(&alr_data->dedi_data.act_amr_configuration.threshold[i], &ch_mode->amr_conf.cod_prop[i].codec_thr, 1);
1566 memcpy(&alr_data->dedi_data.act_amr_configuration.hysteresis[i], &ch_mode->amr_conf.cod_prop[i].codec_hyst, 1);
1567
1568 memcpy(&chm->amr_configuration.threshold[i], &ch_mode->amr_conf.cod_prop[i].codec_thr, 1);
1569 memcpy(&chm->amr_configuration.hysteresis[i], &ch_mode->amr_conf.cod_prop[i].codec_hyst, 1);
1570 TRACE_EVENT_P2("*AMR threshold[%d] %d", i, chm->amr_configuration.threshold[i]);
1571 TRACE_EVENT_P2("*AMR hysteresis[%d] %d", i, chm->amr_configuration.hysteresis[i]);
1572 }
1573 }
1574
1575 /*
1576 * forward new channel mode to layer 1
1577 */
1578 ma_dedi_chan_mode_req (chm);
1579 }
1580
1581 /*
1582 +--------------------------------------------------------------------+
1583 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1584 | STATE : code ROUTINE : dedi_ciph_req |
1585 +--------------------------------------------------------------------+
1586
1587 PURPOSE : Process signal dedi_ciph_req from SDL Process
1588 alr_MAIN.
1589 This function is used during cipher mode setting procedure.
1590
1591 */
1592
1593 GLOBAL void dedi_ciph_req (T_MPH_CIPHERING_REQ *ciph_req)
1594 {
1595 GET_INSTANCE_DATA;
1596 PALLOC (set_ciph, MPHC_SET_CIPHERING_REQ);
1597
1598 ALR_EM_CONFIGURE_CIPHER_MODE_SETTING;
1599
1600 memset (set_ciph, 0, sizeof (T_MPHC_SET_CIPHERING_REQ));
1601 /*
1602 * convert the parameters to the layer 1 structure
1603 */
1604 set_ciph->cipher_mode = ciph_req->ciph.stat;
1605 set_ciph->a5_algorithm = ciph_req->ciph.algo;
1606 memcpy (set_ciph->new_ciph_param.A, ciph_req->ciph.kc, KC_STRING_SIZE);
1607 #ifdef FF_L23_A5_3
1608 dedi_cyclically_repeat_kc ((UBYTE *)set_ciph->new_ciph_param.A, (UBYTE *)ciph_req->ciph.kc, KLEN);
1609 #endif
1610
1611 alr_data->dedi_data.act_cipher_mode = set_ciph->cipher_mode;
1612 alr_data->dedi_data.act_a5_algorithm = set_ciph->a5_algorithm;
1613 memcpy (&alr_data->dedi_data.act_cipher_key,
1614 &set_ciph->new_ciph_param, KC_STRING_SIZE);
1615 #ifdef FF_L23_A5_3
1616 dedi_cyclically_repeat_kc ((UBYTE *)&alr_data->dedi_data.act_cipher_key,
1617 (UBYTE *)&set_ciph->new_ciph_param, KLEN);
1618 #endif
1619
1620 /*
1621 * forward the parameters to layer 1
1622 */
1623 ma_dedi_ciph_req (set_ciph);
1624 }
1625
1626
1627 /*
1628 +--------------------------------------------------------------------+
1629 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1630 | STATE : code ROUTINE : dedi_imm_ass_cnf |
1631 +--------------------------------------------------------------------+
1632
1633 PURPOSE : Process signal dedi_imm_ass_cnf from SDL process
1634 Main_Control.
1635 Layer 1 confirms the configuration of a dedicated
1636 channel during the immediate assignment procedure.
1637
1638 */
1639
1640 GLOBAL void dedi_imm_ass_cnf (void)
1641 {
1642 GET_INSTANCE_DATA;
1643 T_DEDI_DATA * d = &alr_data->dedi_data;
1644
1645 if (GET_STATE (STATE_DEDI) EQ DEDI_IMM_ASS)
1646 {
1647 /*
1648 * the response of layer 1 is expected
1649 */
1650 ma_clean_dedi_sys_buffer ();
1651 SET_STATE (STATE_DEDI, DEDI_ACTIVE);
1652 /*
1653 * store temporary parameters as actual channel configuration
1654 */
1655 d->act_bcch = d->temp_bcch;
1656 d->act_channel_desc = d->temp_channel_desc;
1657 d->act_channel_mode = d->temp_channel_mode;
1658 d->act_frequency_list = d->temp_frequency_list;
1659 d->act_starting_time = d->temp_starting_time;
1660 d->act_frequency_list_bef_sti = d->temp_frequency_list_bef_sti;
1661 d->act_channel_desc_bef_sti = d->temp_channel_desc_bef_sti;
1662 d->act_pwrc = d->temp_pwrc;
1663 d->act_cipher_mode = d->temp_cipher_mode;
1664 d->act_a5_algorithm = d->temp_a5_algorithm;
1665 d->act_cipher_key = d->temp_cipher_key;
1666 d->act_power = cut_power_value (alr_data->rach_data.max_tx_pwr_ccch, NULL);
1667 /*
1668 * Send a MPH_DEDICATED_CNF to RR to
1669 * start the establishment of the
1670 * layer 2 connection.
1671 */
1672 ma_dedi_cnf (DEDICATED_SUCCESS);
1673 }
1674 else
1675 if (GET_STATE (STATE_DEDI) EQ DEDI_IMM_ASS_RECONN)
1676 {
1677 ma_clean_dedi_sys_buffer ();
1678 dedi_chan_ass_fail(); /* act_mode will take on MODE_CHAN_ASS_FAIL */
1679 SET_STATE (STATE_DEDI, DEDI_ACTIVE);
1680 }
1681 }
1682
1683 /*
1684 +--------------------------------------------------------------------+
1685 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1686 | STATE : code ROUTINE : dedi_change_freq_cnf |
1687 +--------------------------------------------------------------------+
1688
1689 PURPOSE : Process signal dedi_change_freq_cnf from SDL process
1690 Main_Control.
1691 Layer 1 confirms setting of the new parameters during
1692 a frequency redefinition procedure.
1693 */
1694
1695 GLOBAL void dedi_change_freq_cnf (void)
1696 {
1697 GET_INSTANCE_DATA;
1698 T_DEDI_DATA *d = &alr_data->dedi_data;
1699
1700 d->act_channel_desc = d->redef_channel_desc;
1701 d->act_frequency_list = d->redef_frequency_list;
1702 memset (&d->redef_channel_desc, 0, sizeof (T_channel_desc));
1703 memset (&d->redef_frequency_list, 0, sizeof (T_frequency_list));
1704 memset (&d->redef_starting_time, 0, sizeof (T_starting_time));
1705 ma_clean_dedi_sys_buffer ();
1706 }
1707
1708 /*
1709 +--------------------------------------------------------------------+
1710 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1711 | STATE : code ROUTINE : dedi_chan_ass_cnf |
1712 +--------------------------------------------------------------------+
1713
1714 PURPOSE : Process signal dedi_chan_ass_cnf from SDL process
1715 Main_Control.
1716 Layer 1 confirms setting of a new channel configuration
1717 during a channel assignment procedure.
1718
1719 */
1720
1721 GLOBAL void dedi_chan_ass_cnf (void)
1722 {
1723 GET_INSTANCE_DATA;
1724 if (GET_STATE (STATE_DEDI) EQ DEDI_ACTIVE)
1725 {
1726 if (alr_data->dedi_data.act_mode EQ MODE_CHAN_ASSIGN)
1727 {
1728 /*
1729 * the response of layer 1 was exspected in the
1730 * positive case of switching to a new channel.
1731 */
1732 T_DEDI_DATA *d = &alr_data->dedi_data;
1733
1734 /*
1735 * store actual parameters as old parameters
1736 */
1737 d->old_channel = actual_channel;
1738 d->old_bcch = d->act_bcch;
1739 d->old_channel_desc = d->act_channel_desc;
1740 d->old_channel_mode = d->act_channel_mode;
1741 d->old_frequency_list = d->act_frequency_list;
1742 d->old_cipher_mode = d->act_cipher_mode;
1743 d->old_a5_algorithm = d->act_a5_algorithm;
1744 d->old_cipher_key = d->act_cipher_key;
1745 d->old_power = d->act_power;
1746 d->old_dtx_allowed = d->act_dtx_allowed;
1747 d->old_amr_configuration = d->act_amr_configuration;
1748
1749 /*
1750 * store temporary parameters as actual channel configuration
1751 */
1752 actual_channel = d->temp_channel;
1753 d->act_bcch = d->temp_bcch;
1754 d->act_channel_desc = d->temp_channel_desc;
1755 d->act_channel_mode = d->temp_channel_mode;
1756 d->act_frequency_list = d->temp_frequency_list;
1757 d->act_cipher_mode = d->temp_cipher_mode;
1758 d->act_a5_algorithm = d->temp_a5_algorithm;
1759 d->act_cipher_key = d->temp_cipher_key;
1760 d->act_power = d->temp_power;
1761 d->act_dtx_allowed = d->temp_dtx_allowed;
1762 d->act_amr_configuration = d->temp_amr_configuration;
1763 ma_dedi_cnf (DEDICATED_SUCCESS);
1764 }
1765 else
1766 /*
1767 * the response of layer 1 was exspected in the
1768 * negative case of switching to the old channel.
1769 */
1770 {
1771 ma_dedi_fail_cnf ();
1772 memset (&alr_data->dedi_data.redef_channel_desc, 0, sizeof (T_channel_desc));
1773 memset (&alr_data->dedi_data.redef_frequency_list, 0, sizeof (T_frequency_list));
1774 memset (&alr_data->dedi_data.redef_starting_time, 0, sizeof (T_starting_time));
1775 }
1776 }
1777 }
1778
1779 /*
1780 +--------------------------------------------------------------------+
1781 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1782 | STATE : code ROUTINE : dedi_ho_fail_cnf |
1783 +--------------------------------------------------------------------+
1784
1785 PURPOSE : Process signal dedi_ho_fail_cnf from SDL process
1786 Main_Control.
1787 Layer 1 signals that the handover has failed.
1788
1789 */
1790
1791 GLOBAL void dedi_ho_fail_cnf (void)
1792 {
1793 GET_INSTANCE_DATA;
1794 /*
1795 * recalculate all timing advances to the old bcch.
1796 */
1797 nc_update_list (alr_data->dedi_data.act_bcch);
1798 /*
1799 * signal dedicated failure to RR
1800 */
1801 nc_resume_dedicated();
1802 ma_dedi_fail_cnf ();
1803 }
1804
1805 /*
1806 +--------------------------------------------------------------------+
1807 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1808 | STATE : code ROUTINE : dedi_fill_ma |
1809 +--------------------------------------------------------------------+
1810
1811 PURPOSE : Fills a frequency list for layer 1.
1812 Condat's representation is a list of USHORT with
1813 0xFFFF as delimiter.
1814 TI's representation is different from this.
1815
1816 */
1817
1818 LOCAL void dedi_fill_ma (USHORT * ma,
1819 T_frequency_list * rf)
1820 {
1821 UBYTE i = 0;
1822
1823 memset (rf, 0, sizeof (T_frequency_list));
1824
1825 while (ma[i] NEQ NOT_PRESENT_16BIT AND
1826 i < MAX_MA_CARRIER)
1827 {
1828 rf->rf_chan_no.radio_freq[i] = ma[i];
1829 i++;
1830 rf->rf_chan_cnt++;
1831 }
1832 }
1833
1834 /*
1835 +--------------------------------------------------------------------+
1836 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1837 | STATE : code ROUTINE : dedi_tch_loop_req |
1838 +--------------------------------------------------------------------+
1839
1840 PURPOSE : Process signal dedi_tch_loop_req from SDL Process
1841 alr_MAIN.
1842
1843 */
1844
1845 GLOBAL void dedi_tch_loop_req (T_MPH_TCH_LOOP_REQ *tloop)
1846 {
1847 GET_INSTANCE_DATA;
1848 if (tloop->tch_loop EQ NOT_PRESENT_8BIT)
1849 {
1850 /*
1851 * Open TCH loop
1852 */
1853 ma_dedi_open_tch_loop_req ();
1854 #ifdef FF_EM_MODE
1855 ALR_EM_CONFIGURE_TCH_LOOP(EM_TCH_OPEN);
1856 #endif
1857 }
1858 else
1859 {
1860 /*
1861 * Close TCH loop
1862 */
1863 PALLOC (loop, OML1_CLOSE_TCH_LOOP_REQ);
1864
1865 /*
1866 * Format of tch_loop in according to 3GPP 04.14, 8.1 CLOSE_TCH_LOOP_CMD
1867 */
1868 loop->sub_channel = alr_data->dedi_data.act_channel_desc.sub_channel;
1869 loop->frame_erasure = tloop->tch_loop;
1870
1871 ma_dedi_close_tch_loop_req (loop);
1872 #ifdef FF_EM_MODE
1873 ALR_EM_CONFIGURE_TCH_LOOP(EM_TCH_CLOSE);
1874 #endif
1875 }
1876 }
1877
1878
1879 /*
1880 +--------------------------------------------------------------------+
1881 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1882 | STATE : code ROUTINE : dedi_dai_req |
1883 +--------------------------------------------------------------------+
1884
1885 PURPOSE : Process signal dedi_dai_req from SDL Process
1886 alr_MAIN.
1887 RR requests configuration of the digital audio interface.
1888
1889 */
1890
1891 GLOBAL void dedi_dai_req (T_MPH_DAI_REQ * dai)
1892 {
1893
1894 if (dai->device EQ DAI_NO_TEST)
1895 {
1896 /*
1897 * Stop DAI test
1898 */
1899 ma_dedi_stop_dai_req ();
1900
1901 ALR_EM_CONFIGURE_DAI_TESTING(EM_DAI_STOP);
1902
1903 }
1904 else
1905 {
1906 PALLOC (dai_req, OML1_START_DAI_TEST_REQ);
1907
1908 /*
1909 * Start DAI test
1910 */
1911 dai_req->tested_device = dai->device;
1912 ma_dedi_start_dai_req (dai_req);
1913
1914 ALR_EM_CONFIGURE_DAI_TESTING(EM_DAI_START);
1915
1916 }
1917 }
1918
1919 /*
1920 +--------------------------------------------------------------------+
1921 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1922 | STATE : code ROUTINE : dedi_channel_mode |
1923 +--------------------------------------------------------------------+
1924
1925 PURPOSE : The function converts the channel mode representation
1926 from Condat's notation (equal to GSM) to TI's values.
1927
1928 */
1929
1930 LOCAL UBYTE dedi_channel_mode (UBYTE channel_mode, UBYTE channel_type)
1931 {
1932 switch (channel_mode)
1933 {
1934 case MODE_SIG_ONLY: /* signalling only */
1935 return CM_SIGNALLING_ONLY;
1936
1937 case MODE_SPEECH_VER1: /* Speech */
1938 if (channel_type EQ CH_TYPE[TCH_F_INDEX]) /* TCH fullrate */
1939 return CM_TCH_FS; /* TCH fullrate speech */
1940 else
1941 return CM_TCH_HS; /* TCH halfrate speech */
1942
1943 case MODE_DATA_12_0: /* Data 12 k */
1944 return CM_TCH_96;
1945
1946 case MODE_DATA_6_0: /* Data 6 k */
1947 if (channel_type EQ CH_TYPE[TCH_F_INDEX]) /* TCH fullrate */
1948 return CM_TCH_F_48; /* TCH fullrate data 6 k */
1949 else
1950 return CM_TCH_H_48; /* TCH halfrate data 6 k */
1951
1952 case MODE_DATA_3_6: /* Data 3.6 k */
1953 if (channel_type EQ CH_TYPE[TCH_F_INDEX]) /* TCH fullrate */
1954 return CM_TCH_F_24; /* TCH fullrate data 3.6 k */
1955 else
1956 return CM_TCH_H_24; /* TCH halfrate data 3.6 k */
1957
1958 case MODE_DATA_14_5: /* Data 14.5 k */
1959 return CM_TCH_144; /* TCH fullrate data 14.5 k*/
1960
1961 case MODE_SPEECH_VER2: /* enhanced full rate */
1962 return CM_TCH_EFR;
1963
1964 case MODE_SPEECH_VER3: /* adaptiv multi-rate */
1965 if (channel_type EQ CH_TYPE[TCH_F_INDEX]) /* TCH fullrate */
1966 return CM_TCH_AFS; /* TCH/AFS fullrate */
1967 else
1968 return CM_TCH_AHS; /* TCH/AHS halfrate */
1969
1970 default:
1971 return CM_SIGNALLING_ONLY; /* all other set to signalling only */
1972 }
1973 }
1974
1975 /*
1976 +------------------------------ --------------------------------------+
1977 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
1978 | STATE : code ROUTINE : dedi_increment_rlt |
1979 +--------------------------------------------------------------------+
1980
1981 PURPOSE : A valid block has received on SACCH. The radio
1982 link counter is incremented if possible.
1983
1984 */
1985
1986 GLOBAL void dedi_increment_rlt (void)
1987 {
1988 GET_INSTANCE_DATA;
1989 /*
1990 * increase radio link timeout counter if necessary
1991 */
1992 if (alr_data->dedi_data.act_rlt NEQ alr_data->dedi_data.rlt)
1993 {
1994 alr_data->dedi_data.act_rlt += 2;
1995
1996 if (alr_data->dedi_data.act_rlt > alr_data->dedi_data.rlt)
1997 alr_data->dedi_data.act_rlt = alr_data->dedi_data.rlt;
1998 #if !defined NTRACE
1999 trc_mon_counter_dedi (alr_data->dedi_data.act_rlt,
2000 alr_data->dedi_data.rlt);
2001 #endif /* (!defined NTRACE) */
2002
2003 ALR_EM_SET_EM_ACT_RLT;
2004 }
2005 }
2006
2007 /*
2008 +--------------------------------------------------------------------+
2009 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
2010 | STATE : code ROUTINE : dedi_decrement_rlt |
2011 +--------------------------------------------------------------------+
2012
2013 PURPOSE : An invalid block has received on SACCH. The radio
2014 link counter is decremented. If the value is zero
2015 an error indication is send to RR.
2016 */
2017
2018 GLOBAL void dedi_decrement_rlt (void)
2019 {
2020 GET_INSTANCE_DATA;
2021
2022 /*
2023 * invalid block received. Decrement radio link timeout counter.
2024 */
2025 if (alr_data->dedi_data.act_rlt > 1)
2026 {
2027 #if !defined NTRACE
2028 trc_mon_counter_dedi (alr_data->dedi_data.act_rlt,
2029 alr_data->dedi_data.rlt);
2030 #endif /* (!defined NTRACE */
2031 alr_data->dedi_data.act_rlt--;
2032
2033 ALR_EM_SET_EM_ACT_RLT;
2034
2035 }
2036 else
2037 {
2038 /*
2039 * radio link failure detected
2040 */
2041 ma_error_ind (CS_RADIO_LINK_FAIL, alr_data->serving_cell);
2042 alr_data->dedi_data.act_rlt = alr_data->dedi_data.rlt;
2043 #if !defined NTRACE
2044 trc_mon_counter_dedi (alr_data->dedi_data.act_rlt,
2045 alr_data->dedi_data.rlt);
2046 #endif
2047
2048 ALR_EM_SET_EM_ACT_RLT;
2049
2050 }
2051 }
2052
2053 /*
2054 +--------------------------------------------------------------------+
2055 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
2056 | STATE : code ROUTINE : dedi_convert_frequency_list|
2057 +--------------------------------------------------------------------+
2058
2059 PURPOSE : converts the channel numbers of a frequency list
2060 in the non-hopping case for DCS 1800 channel numbers
2061 in the dualband variants.
2062 */
2063
2064 LOCAL void dedi_convert_frequency_list (T_frequency_list * frequency_list)
2065 {
2066 UBYTE i, j;
2067
2068 i = (UBYTE)frequency_list->rf_chan_cnt;
2069
2070 if (i >= 64)
2071 i = 63;
2072
2073 ALR_TRACE_DEDI ("-----------");
2074
2075 for (j = 0; j < i; j++)
2076 {
2077 ALR_TRACE_DEDI_FREQ_LIST ();
2078
2079 frequency_list->rf_chan_no.radio_freq[j] =
2080 ARFCN_TO_L1 (frequency_list->rf_chan_no.radio_freq[j]);
2081 }
2082 }
2083
2084 /*
2085 +--------------------------------------------------------------------+
2086 | PROJECT : GSM-PS (8403) MODULE : ALR_DEDI |
2087 | STATE : code ROUTINE : dedi_stop |
2088 +--------------------------------------------------------------------+
2089
2090 PURPOSE : Process signal dedi_stop from SDL process Main_Control.
2091 This signal stops all dedicated activities of ALR.
2092
2093 */
2094
2095 GLOBAL void dedi_stop (void)
2096 {
2097 GET_INSTANCE_DATA;
2098 if (GET_STATE (STATE_DEDI) NEQ DEDI_INACTIVE)
2099 {
2100 /*
2101 * if dedicated mode is active,
2102 * the process and layer 1 are set to idle.
2103 */
2104 SET_STATE (STATE_DEDI, DEDI_INACTIVE);
2105 ma_dedi_stop_req ();
2106 alr_data->dedi_data.act_mode = NOT_PRESENT_8BIT;
2107 }
2108 }
2109
2110 /*
2111 +--------------------------------------------------------------------+
2112 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
2113 | STATE : code ROUTINE : dedi_convert_chan_desc |
2114 +--------------------------------------------------------------------+
2115
2116 PURPOSE : converts the channel number of a channel description
2117 in the non-hopping case for DCS 1800 channel numbers
2118 in the dualband variants.
2119 */
2120
2121 LOCAL void dedi_convert_chan_desc (T_channel_desc * channel_desc)
2122 {
2123 USHORT channel;
2124
2125 if (channel_desc->chan_sel.h EQ 0)
2126 {
2127 channel = (USHORT)(channel_desc->chan_sel.rf_channel.maio +
2128 (channel_desc->chan_sel.rf_channel.hsn << 8));
2129 channel_desc->chan_sel.rf_channel.maio =
2130 (UBYTE)(ARFCN_TO_L1(channel) & 0xFF);
2131 channel_desc->chan_sel.rf_channel.hsn =
2132 (UBYTE)(ARFCN_TO_L1(channel) >> 8);
2133 }
2134 }
2135
2136 /*
2137 +--------------------------------------------------------------------+
2138 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
2139 | STATE : code ROUTINE : dedi_conversion_needed |
2140 +--------------------------------------------------------------------+
2141
2142 PURPOSE : Checks whether conversion is needed or not.
2143
2144 */
2145
2146 LOCAL UBYTE dedi_conversion_needed (void)
2147 {
2148 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT
2149 if ((std EQ STD_1900) OR
2150 (std EQ STD_850_900_1900) OR
2151 (std EQ STD_900_1900) OR
2152 #else
2153 if ((std EQ STD_EGSM) OR
2154 (std EQ STD_DUAL) OR
2155 (std EQ STD_DUAL_EGSM) OR
2156 #endif
2157 (std EQ STD_DUAL_US))
2158 return TRUE;
2159 else
2160 return FALSE;
2161 }
2162
2163 #if defined (REL99) && defined (FF_BHO)
2164 /*
2165 +--------------------------------------------------------------------+
2166 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
2167 | STATE : code ROUTINE : dedi_reset_bho_data |
2168 +--------------------------------------------------------------------+
2169
2170 PURPOSE : To reset Blind handover variables in ALR context.
2171 */
2172 LOCAL void dedi_reset_bho_data(void)
2173 {
2174 GET_INSTANCE_DATA;
2175 alr_data->dedi_data.ho_type = HOT_NONE;
2176 alr_data->dedi_data.bho_cell_index = NOT_PRESENT_16BIT;
2177 }
2178
2179 /*
2180 +--------------------------------------------------------------------+
2181 | PROJECT : GSM-PS (8403) MODULE : alr_DEDI |
2182 | STATE : code ROUTINE : dedi_set_ho_type |
2183 +--------------------------------------------------------------------+
2184
2185 PURPOSE : To reset Blind handover variables in ALR context.
2186 */
2187 LOCAL void dedi_set_ho_type(ULONG *fn, ULONG *tn, UBYTE *ho_type)
2188 {
2189 GET_INSTANCE_DATA;
2190 if(nc_get_fn_time (alr_data->dedi_data.temp_bcch, fn, tn))
2191 {
2192 *ho_type = HOT_REGULAR;
2193 alr_data->dedi_data.ho_type = HOT_REGULAR;
2194 }
2195 else
2196 {
2197 /*Setting Handover type as blind handover*/
2198 *ho_type = HOT_BLIND;
2199 alr_data->dedi_data.ho_type = HOT_BLIND;
2200 TRACE_EVENT("Handover Type is Blind");
2201 }
2202 }
2203 #endif
2204
2205
2206 /*
2207 +--------------------------------------------------------------------+
2208 | PROJECT : MODULE : alr_DEDI |
2209 | STATE :code ROUTINE : dedi_chan_type_sel |
2210 +--------------------------------------------------------------------+
2211
2212 PURPOSE : Function replacing the common code from
2213 "_chan_ass, _sync_handover, _pre__sync_handover &
2214 _freq_redef_req" functions.
2215
2216 */
2217 LOCAL void dedi_chan_type_sel (T_ch_type *ch_type,
2218 T_chan_sel *chan_sel,
2219 T_frequency_list *frequency_list)
2220 {
2221 ALR_TRACE_DEDI ("dedi_chan_type_sel");
2222 if (ch_type->h EQ 1)
2223 {
2224 /*
2225 * with frequency hopping
2226 */
2227 chan_sel->h = 1;
2228 chan_sel->rf_channel.maio = ch_type->maio;
2229 chan_sel->rf_channel.hsn = ch_type->hsn;
2230 dedi_fill_ma (ch_type->ma, frequency_list);
2231 }
2232 else
2233 {
2234 /*
2235 * Avoid the union in the non-hopping case and
2236 * map arfcn to maio and hsn.
2237 */
2238 chan_sel->h = 0;
2239 chan_sel->rf_channel.maio = (UBYTE)((ch_type->arfcn) & 0xFF);
2240 chan_sel->rf_channel.hsn = (UBYTE)(((ch_type->arfcn) >> 8) & 0xFF);
2241 }
2242 }
2243
2244 /*
2245 +--------------------------------------------------------------------+
2246 | PROJECT : MODULE : alr_DEDI |
2247 | STATE :code ROUTINE : dedi_chan_type_desc |
2248 +--------------------------------------------------------------------+
2249
2250 PURPOSE : Function replacing the common code from
2251 "_chan_ass, _sync_handover, _pre__sync_handover &
2252 _freq_redef_req" functions.
2253
2254 */
2255
2256 LOCAL void dedi_chan_type_desc (T_MPH_DEDICATED_REQ *dedicated_req,
2257 T_channel_desc_1_bef_sti *channel_desc_1_bef_sti,
2258 T_frequency_list *frequency_list_bef_sti)
2259 {
2260 ALR_TRACE_DEDI ("dedi_chan_type_desc");
2261 if (dedicated_req->start.v_start AND
2262 dedicated_req->ch_type2.ch NEQ NOT_PRESENT_8BIT)
2263 {
2264 if(dedicated_req->ch_type2.h EQ 1)
2265 {
2266 channel_desc_1_bef_sti->chan_sel.h = 1;
2267 channel_desc_1_bef_sti->chan_sel.rf_channel.maio = dedicated_req->ch_type2.maio;
2268 channel_desc_1_bef_sti->chan_sel.rf_channel.hsn = dedicated_req->ch_type2.hsn;
2269 dedi_fill_ma (dedicated_req->ch_type2.ma, frequency_list_bef_sti);
2270 }
2271 else
2272 {
2273 /*
2274 *nAvoid the union !!!
2275 */
2276 channel_desc_1_bef_sti->chan_sel.h = 0;
2277 channel_desc_1_bef_sti->chan_sel.rf_channel.maio =
2278 (UBYTE)(dedicated_req->ch_type2.arfcn & 0xFF);
2279 channel_desc_1_bef_sti->chan_sel.rf_channel.hsn =
2280 (UBYTE)((dedicated_req->ch_type2.arfcn >> 8) & 0xFF);
2281 }
2282 channel_desc_1_bef_sti->channel_type = CH_TYPE [dedicated_req->ch_type2.ch];
2283 channel_desc_1_bef_sti->sub_channel = SUB_TYPE [dedicated_req->ch_type2.ch];
2284 channel_desc_1_bef_sti->timeslot_no = dedicated_req->ch_type2.tn;
2285 channel_desc_1_bef_sti->tsc = dedicated_req->ch_type2.tsc;
2286 }
2287 }
2288
2289 /*
2290 +--------------------------------------------------------------------+
2291 | PROJECT : MODULE : alr_DEDI |
2292 | STATE :code ROUTINE : dedi_ho_cnf |
2293 +--------------------------------------------------------------------+
2294
2295 PURPOSE : Function replacing the common code from
2296 "pre_sync, async & sync _ho_cnf" functions.
2297
2298 */
2299 GLOBAL void dedi_ho_cnf (T_HO_TYPE ho_type)
2300 {
2301 GET_INSTANCE_DATA;
2302 T_DEDI_DATA *d = &alr_data->dedi_data;
2303 ALR_TRACE_DEDI ("dedi_ho_conf");
2304 /*
2305 * All timing advances are now calculated relative
2306 * to the new dedicated channel only in case of Regular HO.
2307 * In case of Blind HO, timing info will be updated when received
2308 * from L1 in HO_FINISHED primitive.
2309 */
2310 #if defined (REL99) && defined (FF_BHO)
2311 if (alr_data->dedi_data.ho_type EQ HOT_REGULAR )
2312 #endif
2313 nc_update_list (alr_data->dedi_data.temp_bcch);
2314 ma_clean_dedi_sys_buffer ();
2315 /*
2316 * store actual parameters as old parameters
2317 */
2318 d->old_channel = actual_channel;
2319 d->old_bcch = d->act_bcch;
2320 d->old_bsic = alr_data->bsic;
2321 d->old_channel_desc = d->act_channel_desc;
2322 d->old_channel_mode = d->act_channel_mode;
2323 d->old_frequency_list = d->act_frequency_list;
2324 d->old_cipher_mode = d->act_cipher_mode;
2325 d->old_a5_algorithm = d->act_a5_algorithm;
2326 d->old_cipher_key = d->act_cipher_key;
2327 d->old_power = d->act_power;
2328 d->old_amr_configuration = d->act_amr_configuration;
2329 /*
2330 * store temporary parameters as actual channel configuration
2331 */
2332 actual_channel = d->temp_channel;
2333
2334 alr_data->serving_cell = d->act_bcch = d->temp_bcch;
2335 alr_data->sc_band = get_band(d->act_bcch);
2336 alr_data->bsic = alr_data->dedi_data.temp_bsic;
2337 d->act_channel_desc = d->temp_channel_desc;
2338 d->act_channel_mode = d->temp_channel_mode;
2339 d->act_frequency_list = d->temp_frequency_list;
2340 d->act_cipher_mode = d->temp_cipher_mode;
2341 d->act_a5_algorithm = d->temp_a5_algorithm;
2342 d->act_cipher_key = d->temp_cipher_key;
2343 d->act_power = d->temp_power;
2344 if (ho_type EQ HO_TYPE_SYNC)
2345 d->act_amr_configuration = d->temp_amr_configuration;
2346 else if (ho_type EQ HO_TYPE_PRE_SYNC OR ho_type EQ HO_TYPE_ASYNC)
2347 d->old_amr_configuration = d->act_amr_configuration;
2348 if (alr_data->nc_data.dtx)
2349 nc_update_dedicated (alr_data->nc_data.dtx,
2350 alr_data->nc_data.pwrc);
2351 #if defined (REL99) && defined (FF_BHO)
2352 if (alr_data->dedi_data.ho_type EQ HOT_REGULAR )
2353 #endif
2354 nc_resume_dedicated();
2355 }
2356
2357 /*
2358 +--------------------------------------------------------------------+
2359 | PROJECT : MODULE : alr_DEDI |
2360 | STATE :code ROUTINE : dedi_set_amr_conf |
2361 +--------------------------------------------------------------------+
2362
2363 PURPOSE : Function replacing the common code for "amr_conf".
2364
2365 */
2366
2367 LOCAL void dedi_set_amr_conf (T_amr_configuration *amr_con, T_amr_conf *amr_conf)
2368 {
2369 UBYTE i;
2370 ALR_TRACE_DEDI ("dedi_set_amr_conf");
2371 for (i=0; i<amr_conf->c_cod_prop; i++)
2372 {
2373 memcpy(&(amr_con->threshold[i]), &amr_conf->cod_prop[i].codec_thr, 1);
2374 memcpy(&(amr_con->hysteresis[i]), &amr_conf->cod_prop[i].codec_hyst, 1);
2375 TRACE_EVENT_P2("*AMR threshold[%d] %d", i, amr_con->threshold[i]);
2376 TRACE_EVENT_P2("*AMR hysteresis[%d] %d", i, amr_con->hysteresis[i]);
2377 }
2378 }
2379 #endif