comparison g23m/condat/ms/src/alr/alr_dedi.c @ 0:509db1a7b7b8

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