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