comparison g23m-gsm/rr/rr_attp.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This module defines the functions for the attachment
18 | capability of the module Radio Resource.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef RR_ATTP_C
23 #define RR_ATTP_C
24
25 #include "config.h"
26 #include "fixedconf.h"
27 #include "condat-features.h"
28
29 #define ENTITY_RR
30
31 /*==== INCLUDES ===================================================*/
32
33 #include <string.h>
34 #include <stdlib.h>
35 #include <stddef.h> /* offsetof */
36 #include "typedefs.h"
37 #include "pcm.h"
38 #include "pconst.cdg"
39 #include "mconst.cdg"
40 #include "message.h"
41 #include "ccdapi.h"
42 #include "vsi.h"
43 #include "custom.h"
44 #include "gsm.h"
45 #include "prim.h"
46 #include "cnf_rr.h"
47 #include "tok.h"
48 #include "rr.h"
49 #include "rr_em.h"
50 #include "cl_shrd.h"
51
52 #if defined (_SIMULATION_)
53 #include <stdio.h>
54 #endif
55
56
57 /*==== EXPORT =====================================================*/
58
59 /*==== PRIVATE =====================================================*/
60 /*==== PROTOTYPES =================================================*/
61
62 LOCAL void att_align_sc_meas (T_MPH_MEASUREMENT_IND * mph_meas_ind,
63 UBYTE index);
64
65 /*==== VARIABLES ==================================================*/
66 /*
67 * -------------------------------------------------------------------
68 * PRIMITIVE Processing functions
69 * -------------------------------------------------------------------
70 */
71
72 /*
73 +--------------------------------------------------------------------+
74 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
75 | STATE : code ROUTINE : att_mph_error_ind |
76 +--------------------------------------------------------------------+
77
78 PURPOSE : Process the primitive MPH_ERROR_IND received from PL.
79
80 */
81
82 #define MAX_ERROR_CS 9
83 #define MAX_ERROR_IDLE 4
84
85 GLOBAL void att_mph_error_ind (T_MPH_ERROR_IND *mph_error_ind)
86 {
87 GET_INSTANCE_DATA;
88 UBYTE index;
89
90 TRACE_FUNCTION ("att_mph_error_ind()");
91
92 switch (GET_STATE (STATE_ATT))
93 {
94 case ATT_CS2:
95 /*
96 * during cell selection
97 */
98 switch (mph_error_ind->cs)
99 {
100 case CS_BCCH_READ_ERROR:
101 /*
102 * BCCH read error
103 */
104 rr_data->bcch_error++;
105 if (rr_data->bcch_error EQ MAX_ERROR_CS)
106 {
107 /*
108 * maximum of BCCH read errors reached
109 * start next sync request if possible
110 */
111 rr_data->bcch_error = 0;
112 srv_clear_list (&rr_data->cr_data.cd.ncell_list);
113 if (cs_sync_next ())
114 {
115 SET_STATE (STATE_ATT, ATT_CS1);
116 }
117 break;
118 }
119 break;
120
121 case CS_DOWN_LINK_FAIL:
122 /*
123 * downlink failure,
124 * layer 1 has received too many undecodable paging messages
125 * that means the synchronisation to the BS is lost
126 */
127 TRACE_EVENT ("downlink failure");
128
129 EM_DOWNLINK_FAILURE;
130
131 /*
132 * stop the controlling timer
133 */
134 TIMERSTOP (T_RESELECT);
135
136 /*
137 * start cell selection, actually its questionable
138 * if this ever happens, maybe except for the primitive crossing
139 * case
140 */
141 /*XY:n don't inform GRR, but call start_cs anyway */
142 #ifdef GPRS
143 att_start_cell_selection_gprs ((UBYTE)(rr_data->sc_data.mm_started),FULL_SEARCH_MODE);
144 #else
145 att_start_cell_selection (rr_data->sc_data.mm_started, CS_NOT_PARALLEL,FULL_SEARCH_MODE);
146 #endif
147 break;
148
149 }
150 break;
151
152 case ATT_CS3:
153 /*
154 * during cell reselection
155 */
156 switch (mph_error_ind->cs)
157 {
158 case CS_BCCH_READ_ERROR:
159 /*
160 * BCCH read error
161 */
162 rr_data->bcch_error++;
163 TRACE_EVENT_P2 ("bcch_error=%u (%u)", rr_data->bcch_error, MAX_ERROR_CS);
164 if (rr_data->bcch_error EQ MAX_ERROR_CS)
165 {
166 /*
167 * the maximum of read errors is reached
168 * try the next cell for cell reselection
169 */
170 #ifdef GPRS
171 if(rr_data->gprs_data.cr_pbcch_active EQ TRUE)
172 {
173 att_cell_reselection_gprs_failed();
174 }
175 else
176 {
177 #endif
178 rr_data->bcch_error = 0;
179 rr_data->pag_rec = FALSE;
180 srv_clear_stored_prim (MPH_PAGING_IND);
181 att_continue_cell_reselect ();
182 #ifdef GPRS
183 }
184 #endif
185 }
186 break;
187
188 case CS_DOWN_LINK_FAIL:
189 /*
190 * downlink failure,
191 * layer 1 has received too many undecodable paging messages
192 * that means the synchronisation to the BS is lost
193 */
194 TRACE_EVENT ("downlink failure");
195 EM_DOWNLINK_FAILURE;
196
197 /*
198 * try the next candidate for the cell reselection
199 */
200 att_continue_cell_reselect () ;
201 break;
202
203 case CS_NC_SYNC_FAILED:
204 /*
205 * Cell has no valid synchronization information
206 */
207 TRACE_EVENT ("No Valid Sync info");
208
209 /*
210 * try the next candidate for the cell reselection
211 */
212 att_continue_cell_reselect () ;
213 break;
214
215 }
216 break;
217
218 case ATT_DEDICATED:
219 /*
220 * during dedicated mode
221 */
222 switch (mph_error_ind->cs)
223 {
224 case CS_RADIO_LINK_FAIL:
225 /*
226 * radio link failure.
227 * That means layer 1 has received too many
228 * undecodable SACCH blocks in the downlink
229 * The synchronisation to the BS is lost.
230 */
231 TRACE_EVENT ("radio link failure");
232
233 /*
234 * dynamic configuration command : IHO
235 * Lock the DUT to the cell it is already camping -
236 * Ignore the Radio Link Failures.
237 */
238
239 if(rr_data->dyn_config.iho AND (rr_data->sc_data.ch_mode EQ CM_AMR))
240 {
241 TRACE_EVENT("MPH_ERROR_IND : IHO");
242 }
243 else
244 {
245 EM_RADIO_LINK_FAILURE;
246
247 rr_data->net_lost = TRUE;
248
249 /*
250 * Inform MM about the radio link failure and
251 * start cell reslection
252 */
253 att_code_rr_abort_ind (RRCS_ABORT_RAD_LNK_FAIL);
254 att_stop_dedicated();
255 }
256 break;
257 }
258 break;
259
260 case ATT_IDLE:
261 case ATT_CON_EST:
262 /*
263 * during idle mode or connection establishment
264 */
265 switch (mph_error_ind->cs)
266 {
267 case CS_BCCH_READ_ERROR:
268 /*
269 * A BCCH read error has occured.
270 * It is checked whether the BCCH reading
271 * is done for a PLMN search activity
272 * originated by RR, else it is ignored.
273 */
274 index = att_get_index (mph_error_ind->arfcn);
275 if (index EQ CR_INDEX)
276 {
277 rr_data->bcch_error++;
278 if (rr_data->bcch_error EQ MAX_ERROR_IDLE)
279 {
280 /*
281 * if the maximum of read errors is reached
282 * the next cell is tried.
283 */
284 rr_data->bcch_error = 0;
285 TIMERSTOP (T_RESELECT);
286 srv_clear_list (&rr_data->cr_data.cd.ncell_list);
287 cs_sync_next ();
288 }
289 break;
290 }
291 break;
292
293 case CS_DOWN_LINK_FAIL:
294 /*
295 * downlink failure
296 */
297 TRACE_EVENT ("downlink failure");
298 EM_DOWNLINK_FAILURE;
299
300 rr_data->net_lost = TRUE;
301
302 if(GET_STATE (STATE_ATT) EQ ATT_CON_EST)
303 {
304 switch (rr_data->ms_data.establish_cause)
305 {
306 #ifdef GPRS
307 case ESTCS_GPRS_1P:
308 case ESTCS_GPRS_SB:
309 case ESTCS_GPRS_PAGING:
310 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
311 break;
312 case ESTCS_PAGING:
313 dat_rr_release_ind(RRCS_ABNORM_UNSPEC, 0);
314 #else
315 case ESTCS_PAGING:
316 #endif
317 break;
318 default:
319 dat_rr_release_ind(RRCS_ABNORM_UNSPEC, 0);
320 break;
321 }
322 }
323
324 /*
325 * Only start reselection, if isnīt any PLMN search active
326 */
327 if (rr_data->start_cell_reselection)
328 {
329 /*XY:n inform GRR, and wait for CR_RSP
330 should only happen in PIM_BCCH */
331 #ifdef GPRS
332 att_start_cell_reselection_gprs (CELL_RESELECTION);
333 #else
334 att_start_cell_reselection (CELL_RESELECTION);
335 #endif
336 }
337 break;
338
339 }
340 break;
341
342 default:
343 break;
344 }
345
346
347 PFREE (mph_error_ind);
348 }
349
350 /*
351 +--------------------------------------------------------------------+
352 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
353 | STATE : code ROUTINE : att_mph_sync_ind |
354 +--------------------------------------------------------------------+
355
356 PURPOSE : Process the primitive MPH_SYNC_IND received from PL.
357
358 */
359
360 GLOBAL void att_mph_sync_ind (T_MPH_SYNC_IND *mph_sync_ind)
361 {
362 GET_INSTANCE_DATA;
363 TRACE_FUNCTION ("att_mph_sync_ind()");
364
365 switch (GET_STATE (STATE_ATT))
366 {
367 case ATT_CS2:
368 case ATT_CS3:
369 if (mph_sync_ind->cs EQ CS_SYS_INFO_1_NOT_NEEDED)
370 {
371 /*
372 * layer 1 indicates that system information message type 1
373 * is not available. Update the bitmap of the read messages.
374 */
375 att_set_sys_info_read (SYS_INFO_1_READ, CR_INDEX);
376 }
377 #ifdef GPRS
378 else if(mph_sync_ind->cs EQ CS_SCELL_IS_SYNCED)
379 {
380 if(rr_data->gprs_data.cr_pbcch_active)
381 {
382 PALLOC(sync_ind, RRGRR_SYNC_IND);
383 sync_ind->sync_res = SYNC_OK;
384 PSENDX(GRR, sync_ind);
385
386 SET_STATE(STATE_GPRS,GPRS_PIM_PBCCH);
387 rr_data->gprs_data.cr_pbcch_active = FALSE;
388 rr_data->nc_data[CR_INDEX].arfcn = NOT_PRESENT_16BIT;
389 SET_STATE (STATE_ATT, ATT_IDLE);
390 }
391 }
392 #endif
393 break;
394
395 #ifdef GPRS
396 case ATT_IDLE:
397 {
398 T_GPRS_DATA *gprs_data = &rr_data->gprs_data;
399 T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req = gprs_data->rrgrr_ext_meas_req;
400 T_RRGRR_EXT_MEAS_CNF *rrgrr_ext_meas_cnf = gprs_data->rrgrr_ext_meas_cnf;
401
402 if ( mph_sync_ind->cs EQ CS_STOP_PLMN_SEARCH AND
403 rrgrr_ext_meas_req NEQ NULL )
404 {
405 rrgrr_ext_meas_cnf->call_ref = rrgrr_ext_meas_req->call_ref;
406 if ( gprs_data->ext_meas_ctrl & EXT_MEAS_RESET )
407 rrgrr_ext_meas_cnf->xmeas_cause = EXT_MEAS_RESET;
408 else
409 rrgrr_ext_meas_cnf->xmeas_cause = EXT_MEAS_OK;
410
411 att_ext_meas_end(FALSE);
412 SET_STATE (STATE_CELL_SEL, CS_IDLE);
413 PSENDX ( GRR, rrgrr_ext_meas_cnf );
414 }
415 }
416 break;
417 #endif
418
419 default:
420 break;
421 }
422 PFREE (mph_sync_ind);
423 }
424
425 /*
426 +--------------------------------------------------------------------+
427 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
428 | STATE : code ROUTINE : att_mph_measurement_ind |
429 +--------------------------------------------------------------------+
430
431 PURPOSE : Process MPH_MEASUREMENT_IND received from layer 1.
432
433 */
434
435 GLOBAL void att_mph_measurement_ind (T_MPH_MEASUREMENT_IND *mph_measurement_ind)
436 {
437 GET_INSTANCE_DATA;
438 TRACE_FUNCTION ("att_mph_measurement_ind()");
439
440 /*
441 * Defines the time in frame numbers from the last measurements.
442 */
443 rr_data->ms_data.fn_offset = (ULONG)mph_measurement_ind->fn_offset;
444
445 switch (GET_STATE (STATE_ATT))
446 {
447 case ATT_CS2:
448 /*
449 * FTA problem with 20.19 testcase
450 * This function is used to eliminate poor serving cell
451 * RX level values due to spurious measurements.
452 */
453 #if defined(_SIMULATION_)
454 TRACE_EVENT_WIN_P5 ("ATT_CS2: MPH_MEASUREMENT_IND[%u] rx=%d %svalid (NC%u[%u])",
455 mph_measurement_ind->arfcn, mph_measurement_ind->rx_lev_full,
456 mph_measurement_ind->valid ? "" : "in", SC_INDEX,
457 rr_data->nc_data[SC_INDEX].arfcn);
458 #endif
459 att_align_sc_meas (mph_measurement_ind, SC_INDEX);
460 break;
461
462 case ATT_CS3:
463 /*
464 * clear the barrier for the candidate if exists and
465 * update the fieldstrength value
466 */
467 #if defined(_SIMULATION_)
468 TRACE_EVENT_WIN_P5 ("ATT_CS3: MPH_MEASUREMENT_IND[%u] rx=%d %svalid (NC%u[%u])",
469 mph_measurement_ind->arfcn, mph_measurement_ind->rx_lev_full,
470 mph_measurement_ind->valid ? "" : "in",
471 CR_INDEX, rr_data->nc_data[CR_INDEX].arfcn);
472 #endif
473 reset_tnnn (CR_INDEX);
474 // rr_data->nc_data[CR_INDEX].rxlev = mph_measurement_ind->rx_lev_full;
475 att_align_sc_meas (mph_measurement_ind, CR_INDEX);
476 break;
477
478 case ATT_DEDICATED:
479
480 if (mph_measurement_ind->valid)
481 {
482 /*
483 * if the measurement report is valid, store it
484 * for later use (building of measurement message
485 * and ranking of cells if coming back to idle mode).
486 */
487 memcpy (&rr_data->ms_data.measurement_report, mph_measurement_ind,
488 sizeof (T_MPH_MEASUREMENT_IND));
489
490 /*Store most recently received timing advance for SC*/
491 rr_data->sc_data.new_ta = rr_data->ms_data.measurement_report.otd/2;
492 att_set_tim_advance_info();
493 /*
494 * This function is used to eliminate poor serving cell
495 * RX level values due to spurious measurements.
496 */
497 att_align_sc_meas (mph_measurement_ind, SC_INDEX);
498
499 /*
500 * Set fieldstrength in dedicated mode, use rxlev sub due to DTX
501 */
502 #ifdef FF_PS_RSSI
503 RX_SetValue (mph_measurement_ind->rx_lev_sub,
504 mph_measurement_ind->rx_qual_sub,
505 RX_ACCE_UNAVAILABLE);
506 #else
507 RX_SetValue (mph_measurement_ind->rx_lev_sub);
508 #endif
509 }
510
511 reset_tnnn (SC_INDEX);
512
513 /*
514 * increase power on time to delete forbidden
515 * location area list after 12 hours
516 */
517 att_increase_power_on_time ((USHORT)(rr_data->ms_data.fn_offset /
518 PERIOD_1_SEC));
519
520 /*
521 * build the uplink SACCH message Measurement Report
522 */
523 #if defined (REL99) && defined (TI_PS_FF_EMR)
524 if ( ((rr_data->sc_data.enh_para_status EQ ENH_PARA_IDLE) OR
525 (rr_data->sc_data.enh_para_status EQ ENH_PARA_DEDICATED)) AND
526 rr_data->sc_data.emr_data_current.rep_type EQ REP_TYPE_ENH )
527 dat_code_enh_measure_report (mph_measurement_ind);
528 else
529 #endif
530 dat_code_measure_report (mph_measurement_ind);
531 break;
532
533 case ATT_IDLE:
534 #ifdef GPRS
535 #if defined (REL99) && defined (TI_PS_FF_EMR)
536 rr_data->sc_data.emr_data_current.scale_used_last =
537 mph_measurement_ind->scale_used;
538 #endif
539 if(att_check_sync_results(mph_measurement_ind))
540 return;
541 #endif
542 /*
543 * special trick for FTA testcase 20.7.
544 * The first paging is delayed until the
545 * first measurement from layer 1 arrives.
546 */
547 rr_data->first_meas_received = TRUE;
548
549 /*
550 * two dynamic configs to perform
551 * fast or slow cell reselection in the lab
552 */
553 if (rr_data->dyn_config.fcr)
554 mph_measurement_ind->rx_lev_full = 0;
555
556 if (rr_data->dyn_config.scr)
557 {
558 rr_data->dyn_config.scr++;
559 if (rr_data->dyn_config.scr < mph_measurement_ind->rx_lev_full)
560 mph_measurement_ind->rx_lev_full -= rr_data->dyn_config.scr;
561 else
562 mph_measurement_ind->rx_lev_full = 0;
563 }
564
565 if (mph_measurement_ind->valid)
566 {
567 /*
568 * if the measurement report from layer 1 is valid
569 *
570 * set RX value
571 */
572 #ifdef FF_PS_RSSI
573 RX_SetValue (mph_measurement_ind->rx_lev_full,
574 mph_measurement_ind->rx_qual_full,
575 rr_data->nc_data[SC_INDEX].select_para.rxlev_access_min);
576 #else
577 RX_SetValue (mph_measurement_ind->rx_lev_full);
578 #endif
579
580 /*
581 * store the measurement report for later use, remove
582 * bad neighbourcells and analyze the data from layer 1
583 * (remove cells which are not inside the report,
584 * store new cells, update counter etc.).
585 */
586 mph_measurement_ind->rx_lev_sub = mph_measurement_ind->rx_lev_full;
587 memcpy (&rr_data->ms_data.measurement_report, mph_measurement_ind,
588 sizeof (T_MPH_MEASUREMENT_IND));
589
590 /* L1 always report BCCH RXLev as Zero in Idle mode, so copy
591 * BCCH RXLev as receivied level (rx_lev_full) on BCCH
592 * This will be used when we go into dedicated mode
593 * And comback to Idle mode within 480MS Or
594 * Dedicated mode was very-short duration and
595 * RR didn't receive any valid measurement report into
596 * dedicate mode. If we don't do this Cell-Reselction
597 * will fail as rr_data->nc_data[SC_INDEX].rxlev will be zero
598 * Because it is assigned as bcch_rxlev_of_sc of measurement_report
599 * in function att_build_back_from_dedicated.
600 */
601 rr_data->ms_data.measurement_report.bcch_rxlev_of_sc = mph_measurement_ind->rx_lev_full;
602
603 att_remove_bad_ncell (mph_measurement_ind);
604 att_analyze_measure_report (mph_measurement_ind);
605
606 if( rr_data->c_ncell_bcch EQ NOT_INITIALISED )
607 rr_data->c_ncell_bcch = mph_measurement_ind->ncells.no_of_ncells;
608
609 if( (rr_data->c_ncell_bcch EQ 0) AND (rr_data->resel_pending EQ TRUE) )
610 {
611 PFREE (mph_measurement_ind);
612 #ifdef GPRS
613 att_start_cell_reselection_gprs(CELL_RESELECTION_RACH);
614 #else
615 att_start_cell_reselection(CELL_RESELECTION_RACH);
616 #endif
617 rr_data->resel_pending = FALSE;
618 rr_data->c_ncell_bcch = NOT_INITIALISED;
619 return;
620 }
621 /*
622 * check whether a paging has been stored before receiving
623 * the measurement from layer 1.
624 */
625 if (rr_data->pag_rec)
626 {
627 srv_use_stored_prim ();
628 rr_data->pag_rec = FALSE;
629 }
630
631 /*
632 * delay cell reselection if network search is still ongoing
633 * or RR initiated plmn search has started.
634 */
635 att_check_reselect_decision (rr_data->start_cell_reselection);
636
637 /*
638 * increase power on time to delete forbidden
639 * location area list after 12 hours
640 */
641 att_increase_power_on_time ((USHORT)(rr_data->ms_data.fn_offset /
642 PERIOD_1_SEC));
643
644 }
645 break;
646
647 case ATT_CON_EST:
648 /*
649 * Measurements from layer 1 during connection establishment
650 */
651 if (mph_measurement_ind->valid)
652 {
653 /*
654 * store the measurement report for later use, remove
655 * bad neighbourcells and analyze the data from layer 1
656 * (remove cells which are not inside the report,
657 * store new cells, update counter etc.).
658 */
659 mph_measurement_ind->rx_lev_sub = mph_measurement_ind->rx_lev_full;
660 memcpy (&rr_data->ms_data.measurement_report, mph_measurement_ind,
661 sizeof (T_MPH_MEASUREMENT_IND));
662
663 /* L1 always report BCCH RXLev as Zero in Connection Establishment
664 * mode, so copy BCCH RXLev as receivied level (rx_lev_full).
665 * This will be used when we go into dedicated mode
666 * And comback to Idle mode within 480MS Or
667 * Dedicated mode was very-short duration and
668 * RR didn't receive any valid measurement report into
669 * dedicate mode. If we don't do this Cell-Reselction
670 * will fail as rr_data->nc_data[SC_INDEX].rxlev will be zero
671 * Because it is assigned as bcch_rxlev_of_sc of measurement_report
672 * in function att_build_back_from_dedicated.
673 */
674 rr_data->ms_data.measurement_report.bcch_rxlev_of_sc = mph_measurement_ind->rx_lev_full;
675
676 att_remove_bad_ncell (mph_measurement_ind);
677 att_analyze_measure_report (mph_measurement_ind);
678
679 /*
680 * make a cell reselection decision, but do not start it.
681 */
682 att_check_reselect_decision (FALSE);
683
684 /*
685 * increase power on time to delete forbidden
686 * location area list after 12 hours
687 */
688 att_increase_power_on_time ((USHORT)(rr_data->ms_data.fn_offset /
689 PERIOD_1_SEC));
690 }
691 break;
692
693 default:
694 break;
695 }
696 PFREE (mph_measurement_ind);
697 }
698
699 /*
700 +--------------------------------------------------------------------+
701 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
702 | STATE : code ROUTINE : att_rr_activate_req |
703 +--------------------------------------------------------------------+
704
705 PURPOSE : Process the primitive RR_ACTIVATE_REQ received from MM.
706
707 */
708
709 GLOBAL void att_rr_activate_req (T_RR_ACTIVATE_REQ *rr_activate_req)
710 {
711 GET_INSTANCE_DATA;
712 #ifdef GPRS
713 T_loc_area_ident * lai = &rr_data->nc_data[SC_INDEX].lai;
714 #endif /* GPRS */
715
716 TRACE_FUNCTION ("att_rr_activate_req()");
717
718 /*
719 * set cell test operation
720 */
721 rr_data->cell_test_operation = rr_activate_req->cell_test;
722 rr_data->cs_data.check_hplmn = rr_activate_req->check_hplmn;
723 TRACE_EVENT_P1 ( "Cell Test Operation =%d", rr_data->cell_test_operation );
724
725 switch (GET_STATE (STATE_ATT))
726 {
727 case ATT_NULL:
728 #ifdef GPRS
729 if(rr_activate_req->gprs_indication AND
730 rr_data->gprs_data.start_proc EQ START_PROC_NOTHING)
731 {
732 att_set_gprs_indication(rr_activate_req->gprs_indication);
733 att_rrgrr_cr_ind(CR_NORMAL);
734 rr_data->gprs_data.start_proc = START_PROC_ACTIVATE_REQ;
735 if ( srv_check_stored_prim (RR_ACTIVATE_REQ) )
736 srv_clear_stored_prim(RR_ACTIVATE_REQ);
737
738 if( !srv_store_prim ((T_PRIM *)D2P(rr_activate_req)) )
739 {
740 /*
741 * primitive already in queue or storing failed
742 */
743 PFREE (rr_activate_req);
744 }
745 /* on CR_RSP use_stored_prim is called */
746 }
747 else
748 att_handle_rr_act_req (TRUE, rr_activate_req);
749 #else
750 att_handle_rr_act_req (TRUE, rr_activate_req);
751 #endif
752 break;
753
754 case ATT_CS_INIT:
755 #ifdef GPRS
756 if(rr_activate_req->gprs_indication AND
757 rr_data->gprs_data.start_proc EQ START_PROC_NOTHING)
758 {
759 TRACE_EVENT("Activating GPRS in ATT_CS_INIT");
760 att_set_gprs_indication(rr_activate_req->gprs_indication);
761 att_rrgrr_cr_ind(CR_NORMAL);
762 rr_data->gprs_data.start_proc = START_PROC_ACTIVATE_REQ;
763 /* go ahead for storing the activate_req message */
764 }
765 else
766 {
767 #endif
768 att_handle_rr_act_req (FALSE, rr_activate_req);
769 break;
770 #ifdef GPRS
771 }
772 #endif
773 /*lint -fallthrough*/
774
775 case ATT_CS1:
776 if ( GET_STATE (STATE_CELL_SEL) EQ CS_IDLE_ACTIVE )
777 {
778 #ifdef GPRS
779 if(rr_activate_req->gprs_indication AND
780 rr_data->gprs_data.start_proc EQ START_PROC_NOTHING AND
781 rr_data->ms_data.req_mm_service EQ FUNC_LIM_SERV_ST_SRCH)
782 {
783 TRACE_EVENT("Activating GPRS in ATT_CS1");
784 att_set_gprs_indication(rr_activate_req->gprs_indication);
785 att_rrgrr_cr_ind(CR_NORMAL);
786 rr_data->gprs_data.start_proc = START_PROC_ACTIVATE_REQ;
787 /* go ahead for storing the activate_req message */
788 }
789 else
790 {
791 #endif
792 att_handle_rr_act_req (FALSE, rr_activate_req);
793 return;
794 #ifdef GPRS
795 }
796 #endif
797 }
798 /*lint -fallthrough*/
799 case ATT_CS3:
800 case ATT_DEDICATED:
801 /*
802 * store rr activate request during cell reselection and while dedicated
803 * only store the latest instance of an ACTIVATE_REQ
804 */
805 if ( srv_check_stored_prim (RR_ACTIVATE_REQ) )
806 srv_clear_stored_prim(RR_ACTIVATE_REQ);
807
808 if( !srv_store_prim ((T_PRIM *)D2P(rr_activate_req)) )
809 {
810 /*
811 * primitive already in queue or storing failed
812 */
813 PFREE (rr_activate_req);
814 }
815 break;
816 case ATT_CS2:
817 case ATT_NO_SERVICE:
818 case ATT_IDLE:
819 case ATT_CON_EST:
820
821 #ifdef GPRS
822
823 if(rr_activate_req->gprs_indication AND
824 rr_activate_req->op.func NEQ FUNC_NET_SRCH_BY_MMI AND
825 rr_data->gprs_data.start_proc EQ START_PROC_NOTHING)
826 {
827 if(
828 ( rr_data->ms_data.operation_mode EQ
829 ( (rr_activate_req->op.ts << 7) + (rr_activate_req->op.m << 6) +
830 (rr_activate_req->op.sim_ins << 5)
831 )
832 )
833 AND
834 ( rr_data->ms_data.req_mm_service EQ rr_activate_req->op.func)
835 AND
836 ( GET_STATE(STATE_GPRS) EQ GPRS_NULL)
837 AND
838 ( rr_data->nc_data[SC_INDEX].si13_loc_ind NEQ SI13_NOT_PRESENT )
839 AND
840 (GET_STATE(STATE_ATT) EQ ATT_IDLE )
841 AND
842 (dat_plmn_equal_req ( lai->mcc,
843 lai->mnc,
844 rr_activate_req->plmn.mcc,
845 rr_activate_req->plmn.mnc) )
846 )
847 {
848 TRACE_EVENT("gprs activation - cell reselection to same cell");
849 rr_data->gprs_data.start_proc = START_PROC_GPRS_ACT;
850 rr_data->sc_data.selection_type = CELL_RESELECTION_ON_GPRS_ACT;
851 att_set_gprs_indication(rr_activate_req->gprs_indication);
852 PFREE (rr_activate_req);
853 }
854 else
855 {
856 rr_data->gprs_data.start_proc = START_PROC_ACTIVATE_REQ;
857 att_set_gprs_indication(rr_activate_req->gprs_indication);
858
859 /* on CR_RSP use_stored_prim is called */
860 if ( srv_check_stored_prim (RR_ACTIVATE_REQ) )
861 srv_clear_stored_prim(RR_ACTIVATE_REQ);
862 if( !srv_store_prim ((T_PRIM *)D2P(rr_activate_req)) )
863 {
864
865 /*
866 * primitive already in queue or storing failed
867 */
868 PFREE (rr_activate_req);
869 }
870 }
871
872 att_rrgrr_cr_ind(CR_NORMAL);
873 }
874 else if (rr_activate_req->op.func EQ FUNC_NET_SRCH_BY_MMI AND
875 (GET_STATE(STATE_GPRS) EQ GPRS_PTM_BCCH OR
876 GET_STATE(STATE_GPRS) EQ GPRS_PTM_PBCCH OR
877 GET_STATE(STATE_GPRS) EQ GPRS_PAM_BCCH OR
878 GET_STATE(STATE_GPRS) EQ GPRS_PAM_PBCCH ))
879 {
880 rr_data->gprs_data.start_proc = START_PROC_NOTHING;
881 /*
882 * send Please Retry to the MMI instead of
883 * storing the primitive
884 */
885 rr_data->sc_data.found_entries = 0;
886 att_code_rr_abort_ind(RRCS_ABORT_PTM);
887 PFREE (rr_activate_req);
888 }
889 else if (rr_activate_req->op.func EQ FUNC_NET_SRCH_BY_MMI)
890 {
891 /* this is a parallel search, don't inform GRR */
892 rr_data->gprs_data.start_proc = START_PROC_NOTHING;
893 att_handle_rr_act_req (FALSE, rr_activate_req);
894 }
895 else if(
896 (rr_activate_req->gprs_indication EQ FALSE) AND
897 (rr_activate_req->op.func NEQ FUNC_NET_SRCH_BY_MMI) AND
898 (GET_STATE(STATE_ATT) EQ ATT_IDLE ) AND
899 (rr_data->ms_data.req_mm_service EQ rr_activate_req->op.func) AND
900 (
901 rr_data->ms_data.operation_mode EQ
902 ((rr_activate_req->op.ts << 7)+(rr_activate_req->op.m << 6)+(rr_activate_req->op.sim_ins << 5))
903 ) AND
904 (GET_STATE(STATE_GPRS) EQ GPRS_PIM_BCCH)
905 )
906 {
907 att_set_gprs_indication(rr_activate_req->gprs_indication);
908 att_set_sys_info_read(SYS_INFO_13_READ, SC_INDEX);
909 att_build_idle_req(SC_INDEX, MODE_SYS_INFO_CHANGE);
910 att_code_rr_act_cnf();
911 PFREE(rr_activate_req);
912 }
913 else /* called after, the CR_RSP is received or
914 if GPRS is not activated */
915 att_handle_rr_act_req (FALSE, rr_activate_req);
916 #else
917 att_handle_rr_act_req (FALSE, rr_activate_req);
918 #endif
919 break;
920
921 default:
922 PFREE (rr_activate_req);
923 break;
924 }
925 }
926
927 /*
928 +--------------------------------------------------------------------+
929 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
930 | STATE : code ROUTINE : att_rr_deactivate_req |
931 +--------------------------------------------------------------------+
932
933 PURPOSE : Process the primitive RR_DEACTIVATE_REQ received from MM.
934
935 */
936
937 GLOBAL void att_rr_deactivate_req (T_RR_DEACTIVATE_REQ *rr_deactivate_req)
938 {
939 GET_INSTANCE_DATA;
940 UBYTE tim_idx;
941 PREUSE (rr_deactivate_req, mph_deactivate_req, MPH_DEACTIVATE_REQ);
942
943 TRACE_FUNCTION ("att_rr_deactivate_req()");
944
945 EM_DEACTIVATION;
946
947 #if defined(_SIMULATION_FFS_)
948 if(!dat_test_sim_available())
949 {
950 /* store the white list from RAM to FFS */
951 if(rr_data->ms_data.rr_service EQ FULL_SERVICE)
952 {
953 cs_store_white_list();
954 }
955
956 /* store the Black list from RAM to FFS */
957 cs_store_black_list();
958 }
959 #endif
960
961 /*
962 * stop any timer which might be running
963 */
964 for (tim_idx = 0; tim_idx < NUM_OF_RR_TIMERS; tim_idx++)
965 TIMERSTOP (tim_idx);
966 /*
967 * reset process states and initialize the
968 * gsm related data.
969 */
970 dat_att_null ();
971 att_init_gsm_data ();
972 #ifdef GPRS
973 gprs_init_gprs_data();
974 #endif
975
976 cs_init_process();
977 SET_STATE (STATE_ATT, ATT_NULL);
978
979 /*
980 * deactivate layer 1
981 */
982 PSENDX (PL, mph_deactivate_req);
983 }
984
985 /*
986 +--------------------------------------------------------------------+
987 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
988 | STATE : code ROUTINE : att_rr_sync_req |
989 +--------------------------------------------------------------------+
990
991 PURPOSE : Process the primitive RR_SYNC_REQ received from MM.
992
993 */
994
995 GLOBAL void att_rr_sync_req (T_RR_SYNC_REQ *rr_sync_req)
996 {
997 GET_INSTANCE_DATA;
998 TRACE_FUNCTION ("att_rr_sync_req()");
999
1000 TRACE_EVENT_P2 ("RR_SYNC_REQ cs=%x att st=%u", rr_sync_req->synccs, GET_STATE (STATE_ATT));
1001
1002 if ((rr_sync_req->synccs NEQ NOT_PRESENT_16BIT) AND
1003 (rr_sync_req->synccs NEQ SYNCCS_LAI_ALLOW))
1004 {
1005 rr_data->mode_after_dedi = MODE_CELL_RESELECTION;
1006 TRACE_EVENT ("rr_sync_req: MODE_CELL_RESELECTION");
1007 #if defined(DL_TRACE_ENABLED)
1008 {
1009 sprintf (dl_trace_buf, "sync_req cs=%04x ->mode=%u #%u:%s",
1010 rr_sync_req->synccs, rr_data->mode_after_dedi, __LINE__, __FILE__);
1011 DL_OFFLINE_TRACE (dl_trace_buf);
1012 }
1013 #endif /* DL_TRACE_ENABLED */
1014 }
1015
1016 if (rr_sync_req->kcv.v_kc)
1017 {
1018 /*
1019 * change of cipher parameter
1020 */
1021 memcpy (rr_data->ms_data.new_kc, &rr_sync_req->kcv.kc, KC_STRING_SIZE);
1022 rr_data->ms_data.cksn = rr_sync_req->cksn;
1023 }/*if v_kc*/
1024
1025 if (rr_sync_req->tmsi_struct.v_mid)
1026 {
1027 /*
1028 * change of TMSI (a new value is defined)
1029 */
1030 rr_data->ms_data.tmsi_available = TRUE;
1031 rr_data->ms_data.tmsi_binary = rr_sync_req->tmsi_struct.tmsi_dig;
1032 /*
1033 * forward the new TMSI to layer 1
1034 */
1035 att_mph_identity_req ();
1036 }/* if v_mid*/
1037
1038 if (rr_sync_req->op.v_op)
1039 {
1040 /*
1041 * change of the operation mode, typically
1042 * change from automatic to manual mode
1043 */
1044 rr_data->ms_data.operation_mode =
1045 (rr_sync_req->op.ts << SHIFT_FOR_SIM_TYPE) +
1046 (rr_sync_req->op.m << SHIFT_FOR_SEARCH_OFFSET) +
1047 (rr_sync_req->op.sim_ins << SHIFT_FOR_SIM_INSERTED);
1048 att_set_func (rr_sync_req->op.func);
1049
1050 switch (GET_STATE (STATE_ATT))
1051 {
1052 case ATT_NO_SERVICE:
1053 case ATT_IDLE:
1054 case ATT_CON_EST:
1055 /*
1056 * changes from automatic to manual mode and vice versa
1057 * may lead to start or stop of HPLMN search.
1058 */
1059 if (rr_data->ms_data.rr_service EQ FULL_SERVICE)
1060 att_start_registration_timer ();
1061 break;
1062 default:
1063 break;
1064 }/*STATE_ATT*/
1065
1066 }/*if v_op*/
1067
1068 switch (GET_STATE (STATE_ATT))
1069 {
1070 case ATT_CS1:
1071 switch (rr_sync_req->synccs)
1072 {
1073 case SYNCCS_TMSI_CKSN_KC_INVAL:
1074 case SYNCCS_TMSI_CKSN_KC_INVAL_NO_PAG:
1075 /*
1076 * store the primitive during cell selection (power measurements)
1077 */
1078 if (!srv_store_prim ((T_PRIM *)D2P(rr_sync_req)))
1079 {
1080 PFREE (rr_sync_req);
1081 }/*if*/
1082 return;
1083 default:
1084 break;
1085 }/*synccs*/
1086 break;
1087
1088 case ATT_CS2:
1089 switch (rr_sync_req->synccs)
1090 {
1091 case SYNCCS_TMSI_CKSN_KC_INVAL:
1092 case SYNCCS_TMSI_CKSN_KC_INVAL_NO_PAG:
1093 /*
1094 * location updating reject or authentication
1095 * failure indicates that a new start of the cell
1096 * selection is needed.
1097 */
1098 TIMERSTOP (T_RESELECT);
1099 /*XY:n don't inform GRR , but call start_cs anyway */
1100 #ifdef GPRS
1101 att_start_cell_selection_gprs (RR_ORIGINATED,FULL_SEARCH_MODE);
1102 #else
1103 att_start_cell_selection (RR_ORIGINATED, CS_NOT_PARALLEL,FULL_SEARCH_MODE);
1104 #endif
1105 break;
1106 default:
1107 break;
1108 }/*synccs*/
1109 break;
1110
1111 case ATT_CS3:
1112 case ATT_DEDICATED:
1113 case ATT_NO_SERVICE:
1114 case ATT_IDLE:
1115 case ATT_CON_EST:
1116 switch (rr_sync_req->synccs)
1117 {
1118 case SYNCCS_TMSI_CKSN_KC_INVAL:
1119 /*
1120 * clear TMSI, CKSN and KC
1121 */
1122 att_clear_reg_without_imsi ();
1123 break;
1124
1125 case SYNCCS_TMSI_CKSN_KC_INVAL_NO_PAG:
1126 /*
1127 * clear TMSI, IMSI, CKSN and KC
1128 */
1129 att_clear_registration_data ();
1130 break;
1131 default:
1132 break;
1133 }/*synccs*/
1134 break;
1135
1136 default:
1137 break;/*state*/
1138 }/*STATE_ATT*/
1139
1140 switch (rr_sync_req->synccs)
1141 {
1142 case SYNCCS_EPLMN_LIST:
1143 /*
1144 * If sync info contains an EPLMN list
1145 * then this is copied regardless of state.
1146 * When EPLMN is not available stored EPLMN
1147 * is marked as invalid.
1148 */
1149 att_copy_eplmn_list(&rr_sync_req->eq_plmn_list);
1150 break;
1151
1152 case SYNCCS_LAI_ALLOW:
1153
1154 /* Store Last Registered PLMN data from the white list */
1155 rr_data->cs_data.last_reg_plmn.v_plmn = V_PLMN_PRES;
1156
1157 memcpy (rr_data->cs_data.last_reg_plmn.mcc, rr_data->cs_data.white_list.last_sc_lac.mcc, SIZE_MCC);
1158 memcpy (rr_data->cs_data.last_reg_plmn.mnc, rr_data->cs_data.white_list.last_sc_lac.mnc, SIZE_MNC);
1159
1160 TRACE_EVENT("LRPLMN copied from white list");
1161
1162 /*
1163 * successful end of location updating request,
1164 * remove lai from forbidden list if stored
1165 */
1166 att_rem_lai_from_forb_list (&rr_sync_req->plmn,
1167 rr_sync_req->lac);
1168 break;
1169
1170 case SYNCCS_LAI_NOT_ALLOW:
1171 /*
1172 * location updating reject, lai must be added to the
1173 * forbidden lai list.
1174 */
1175 att_add_to_forb_list (FORBIDDEN_LIST_NORMAL,
1176 &rr_sync_req->plmn,
1177 rr_sync_req->lac);
1178 /* Specifications 24.008 (section 4.4.4.7) -
1179 * # 12: (Location Area not allowed);
1180 * The MS shall perform a cell selection when back to the MM IDLE state
1181 * according to 3GPP TS 03.22 and 3GPP TS 25.304.
1182 */
1183 rr_data->ms_data.req_mm_service = FUNC_NET_SRCH_BY_MMI;
1184 att_start_cell_selection (RR_ORIGINATED, CS_PARALLEL,NORMAL_SEARCH_MODE);
1185
1186 break;
1187
1188 case SYNCCS_LAI_NOT_ALLOW_FOR_ROAMING:
1189 /*
1190 * location updating reject, lai must be added to the
1191 * forbidden lai list for roaming.
1192 */
1193 att_add_to_forb_list (FORBIDDEN_LIST_ROAMING,
1194 &rr_sync_req->plmn,
1195 rr_sync_req->lac);
1196 break;
1197
1198 case SYNCCS_TMSI_INVAL:
1199 /*
1200 * TMSI is invalid. Clear in RR and inform layer 1
1201 */
1202 rr_data->ms_data.tmsi_available = FALSE;
1203 att_mph_identity_req ();
1204 break;
1205
1206 case SYNCCS_LIMITED_SERVICE:
1207 /* Plmn received matches with LRPLMN, flush LRPLMN */
1208 if (rr_sync_req->plmn.v_plmn EQ V_PLMN_PRES)
1209 {
1210 if(!memcmp(rr_sync_req->plmn.mcc, rr_data->cs_data.last_reg_plmn.mcc, SIZE_MCC) AND
1211 !memcmp(rr_sync_req->plmn.mnc, rr_data->cs_data.last_reg_plmn.mnc, SIZE_MNC)
1212 )
1213 {
1214 rr_data->cs_data.last_reg_plmn.v_plmn = V_PLMN_NOT_PRES;
1215 TRACE_EVENT ("LRPLMN Cleared");
1216 }
1217 }
1218
1219 /*
1220 * Indication to RR that only limited service
1221 * is possible due to location updating reject cause
1222 */
1223 rr_data->ms_data.rr_service = LIMITED_SERVICE;
1224 TRACE_EVENT_P7 ("CLEAR plmn, (old MCC/MNC=%x%x%x/%x%x%x) #%u",
1225 rr_data->ms_data.plmn.mcc[0],
1226 rr_data->ms_data.plmn.mcc[1],
1227 rr_data->ms_data.plmn.mcc[2],
1228 rr_data->ms_data.plmn.mnc[0],
1229 rr_data->ms_data.plmn.mnc[1],
1230 rr_data->ms_data.plmn.mnc[2],
1231 __LINE__);
1232 memset (&rr_data->ms_data.plmn, 0, sizeof (T_plmn));
1233 att_set_rr_service_info();
1234
1235 switch (GET_STATE (STATE_ATT))
1236 {
1237 case ATT_NO_SERVICE:
1238 case ATT_IDLE:
1239 case ATT_CON_EST:
1240 att_start_registration_timer();
1241 break;
1242 default:
1243 break;
1244 }/*STATE_ATT*/
1245
1246 #ifdef GPRS
1247 if(att_gprs_is_avail())
1248 {
1249 /*XY: inform GRR, and wait for CR_RSP */
1250 /* att_rrgrr_cr_ind(CR_NORMAL); */
1251 /* rr_data->gprs_data.start_proc = START_PROC_ENTER_LIMITED; */
1252
1253 /*
1254 * During cell reselection, we should not send the primitive
1255 * RRGRR_GPRS_SI13_IND to GRR to inform Limited Service.
1256 * As this primitive is also used to mark the end of cell reselection.
1257 */
1258 if( GET_STATE(STATE_ATT) NEQ ATT_CS3)
1259 att_signal_gprs_support();
1260 /* action will follow after cr_rsp */
1261 }
1262 #endif
1263
1264 break;
1265
1266 case SYNCCS_ACCC:
1267 rr_data->ms_data.access_classes = rr_sync_req->accc;
1268 break; /* SIM's access class by SAT changed */
1269
1270 default:
1271 if(!rr_sync_req->op.v_op OR
1272 !rr_sync_req->kcv.v_kc OR
1273 !rr_sync_req->tmsi_struct.v_mid)
1274 TRACE_ERROR ("Unexpected sync event");
1275 break;
1276 }/*synccs*/
1277
1278 PFREE (rr_sync_req);
1279
1280 }/*att_rr_sync_reg*/
1281
1282 /*
1283 +--------------------------------------------------------------------+
1284 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1285 | STATE : code ROUTINE : att_mph_meas_rep_cnf |
1286 +--------------------------------------------------------------------+
1287
1288 PURPOSE : Process the primitive mph_meas_rep_cnf from ALR.
1289
1290 */
1291
1292 #ifdef GPRS
1293 GLOBAL void att_mph_meas_rep_cnf(T_MPH_MEAS_REP_CNF* mph_meas_rep_cnf)
1294 {
1295 UBYTE count;
1296 PALLOC(rrgrr_meas_rep_cnf, RRGRR_MEAS_REP_CNF);
1297 TRACE_FUNCTION("rrgrr_meas_rep_cnf()");
1298
1299 /*lint -e661 (Possible access of out-of-bounds pointer (26 beyond end of data) by operator '[') */
1300 /*lint -e662 (Possible creation of out-of-bounds pointer (26 beyond end of data) by operator '[') */
1301 for(count=0;count<RRGRR_MEAS_REP_LIST_SIZE;count++)
1302 {
1303 rrgrr_meas_rep_cnf->meas_res[count].arfcn = mph_meas_rep_cnf->meas_rep[count].arfcn;
1304 rrgrr_meas_rep_cnf->meas_res[count].bsic = mph_meas_rep_cnf->meas_rep[count].bsic;
1305 rrgrr_meas_rep_cnf->meas_res[count].rxlev = mph_meas_rep_cnf->meas_rep[count].rx_lev;
1306 }
1307 PFREE(mph_meas_rep_cnf);
1308 PSENDX( GRR, rrgrr_meas_rep_cnf );
1309 /*lint +e662 (Possible creation of out-of-bounds pointer (26 beyond end of data) by operator '[') */
1310 /*lint +e661 (Possible access of out-of-bounds pointer (26 beyond end of data) by operator '[') */
1311 }
1312 #endif
1313
1314
1315
1316 /*
1317 +--------------------------------------------------------------------+
1318 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1319 | STATE : code ROUTINE : att_mph_meas_order_cnf |
1320 +--------------------------------------------------------------------+
1321
1322 PURPOSE :
1323
1324 */
1325
1326 GLOBAL void att_mph_meas_order_cnf (T_MPH_MEAS_ORDER_CNF* meas)
1327 {
1328 PFREE(meas);
1329 }
1330
1331 /*
1332 +--------------------------------------------------------------------+
1333 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1334 | STATE : code ROUTINE : att_align_sc_meas |
1335 +--------------------------------------------------------------------+
1336
1337 PURPOSE :
1338
1339 index == SC_INDEX: In this case the function is used to eliminate
1340 poor serving cell RX level values due to
1341 spurious measurements.
1342
1343 This function is related to FTA test case 20.19.
1344
1345 index == CR_INDEX: In this case the function is used to set the
1346 right aligned level of a delayed measurement report
1347 during cell reselection (ATT_CS3) to the cell
1348 with the CR_INDEX.
1349
1350 */
1351
1352 LOCAL void att_align_sc_meas (T_MPH_MEASUREMENT_IND * mph_meas_ind,
1353 UBYTE index)
1354 {
1355 GET_INSTANCE_DATA;
1356 UBYTE i;
1357
1358 TRACE_FUNCTION ("att_align_sc_meas()");
1359
1360 if (mph_meas_ind->valid)
1361 {
1362 if (rr_data->nc_data[index].arfcn EQ mph_meas_ind->arfcn)
1363 {
1364 /*
1365 * update the serving cell or cr cell fieldstrength
1366 */
1367 #if defined(_SIMULATION_)
1368 TRACE_EVENT_WIN_P3 ("att_align_sc_meas(idx=%u): SC/CR=[%u], rx=%d",
1369 index, mph_meas_ind->arfcn, mph_meas_ind->rx_lev_full);
1370 #endif
1371 rr_data->nc_data[index].rxlev = mph_meas_ind->rx_lev_full;
1372 }
1373 else
1374 {
1375 /*
1376 * check all neighbourcells
1377 */
1378 for (i=0;i<mph_meas_ind->ncells.no_of_ncells;i++)
1379 {
1380 /*
1381 * if the cell is also inside the neighbourcells, take
1382 * this fieldstrength value.
1383 */
1384 if (mph_meas_ind->ncells.arfcn[i] EQ rr_data->nc_data[index].arfcn)
1385 {
1386 #if defined(_SIMULATION_)
1387 TRACE_EVENT_WIN_P3 ("att_align_sc_meas(idx=%u): nc[%u] found, rx=%d",
1388 index, mph_meas_ind->ncells.arfcn[i], mph_meas_ind->ncells.rx_lev[i]);
1389 #endif
1390 rr_data->nc_data[index].rxlev = mph_meas_ind->ncells.rx_lev[i];
1391 return;
1392 }
1393 }
1394 }
1395 }
1396 }
1397
1398 /*
1399 +--------------------------------------------------------------------+
1400 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1401 | STATE : code ROUTINE : att_rr_sync_hplmn_req |
1402 +--------------------------------------------------------------------+
1403
1404 PURPOSE : Process the primitive RR_SYNC_HPLMN_REQ received from MM.
1405
1406 */
1407
1408 GLOBAL void att_rr_sync_hplmn_req (T_RR_SYNC_HPLMN_REQ *rr_sync_hplmn_req)
1409 {
1410 GET_INSTANCE_DATA;
1411 TRACE_FUNCTION ("att_rr_sync_hplmn_req()");
1412 memcpy (&rr_data->ms_data.ahplmn, &rr_sync_hplmn_req->plmn, sizeof (T_plmn));
1413 rr_data->ms_data.v_eq_plmn = FALSE;
1414 memset(&rr_data->ms_data.eq_plmn_list, 0xFF, SIZE_EPLMN);
1415 PFREE(rr_sync_hplmn_req);
1416 }
1417
1418 #if defined FF_EOTD
1419 /*
1420 +--------------------------------------------------------------------+
1421 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1422 | STATE : code ROUTINE : att_mph_ncell_pos_ind |
1423 +--------------------------------------------------------------------+
1424
1425 PURPOSE : Process the primitive MPH_NCELL_POS_IND received from PL.
1426
1427 */
1428
1429 GLOBAL void att_mph_ncell_pos_ind (T_MPH_NCELL_POS_IND *mph_ncell_pos_ind)
1430 {
1431 GET_INSTANCE_DATA;
1432 TRACE_FUNCTION ("att_mph_ncell_pos_ind()");
1433
1434 if ( mph_ncell_pos_ind->eotd_res EQ EOTD_SUCC )
1435 {
1436 /* Forward input primitive to LC adding some parameters */
1437
1438 T_loc_area_ident *loc_area_ident;
1439 T_NC_DATA *sc;
1440 int i,n;
1441
1442 PALLOC (rrlc_meas_ind, RRLC_MEAS_IND);
1443
1444 sc = &rr_data->nc_data[SC_INDEX];
1445 loc_area_ident = &sc->lai;
1446
1447 memcpy ( &rrlc_meas_ind->mcc[0], &loc_area_ident->mcc[0], 3 * sizeof rrlc_meas_ind->mcc[0]);
1448 memcpy ( &rrlc_meas_ind->mnc[0], &loc_area_ident->mnc[0], 3 * sizeof rrlc_meas_ind->mnc[0]);
1449 rrlc_meas_ind->lac = loc_area_ident->lac;
1450 rrlc_meas_ind->cell_id = sc->cell_id;
1451 rrlc_meas_ind->req_id = mph_ncell_pos_ind->req_id;
1452 rrlc_meas_ind->tav = mph_ncell_pos_ind->ta;
1453 rrlc_meas_ind->fn = mph_ncell_pos_ind->fn;
1454 rrlc_meas_ind->eotd_sc_res = mph_ncell_pos_ind->eotd_sc_res;
1455 rrlc_meas_ind->eotd_sc_res1 = mph_ncell_pos_ind->eotd_sc_res1;
1456 n =
1457 rrlc_meas_ind->c_eotd_nc_res = mph_ncell_pos_ind->c_eotd_nc_res;
1458 for ( i = 0; i < n; ++i )
1459 rrlc_meas_ind->eotd_nc_res[i] = mph_ncell_pos_ind->eotd_nc_res[i];
1460
1461 if ( GET_STATE (STATE_ATT) EQ ATT_DEDICATED
1462 #ifdef GPRS
1463 OR (GET_STATE (STATE_ATT) EQ ATT_IDLE AND
1464 GET_STATE(STATE_GPRS) EQ GPRS_PTM_BCCH AND
1465 GET_STATE(STATE_GPRS) EQ GPRS_PTM_PBCCH )
1466 #endif
1467 )
1468 rrlc_meas_ind->eotd_mode = EOTD_DEDIC;
1469 else
1470 rrlc_meas_ind->eotd_mode = EOTD_IDLE;
1471
1472 /*
1473 * If this is a response to an explicit position measurement request,
1474 * then reset the flag which enables handover indications to LC.
1475 */
1476
1477 if ( rr_data->eotd_req_id NEQ NOT_PRESENT_16BIT AND
1478 rr_data->eotd_req_id EQ mph_ncell_pos_ind->req_id )
1479 rr_data->eotd_req_id = NOT_PRESENT_16BIT;
1480
1481 PSENDX (LC, rrlc_meas_ind);
1482 }
1483 else
1484 {
1485 PALLOC (rrlc_error_ind, RRLC_ERROR_IND);
1486 rrlc_error_ind->cause = LCS_WRONG_BTS; /* exact cause is unclear, assume wrong BTS */
1487 PSENDX (LC, rrlc_error_ind);
1488 }
1489 PFREE(mph_ncell_pos_ind);
1490 }
1491 #endif /* FF_EOTD */
1492
1493 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT
1494 GLOBAL void att_mph_init_rr_ind(T_MPH_INIT_RR_IND* mph_init_rr_ind)
1495 {
1496 GET_INSTANCE_DATA;
1497 UBYTE freq_bands;
1498 T_rf_power *rfp = &rr_data->ms_data.rf_cap.rf_power;
1499
1500 TRACE_FUNCTION ("att_mph_init_rr_ind()");
1501 rr_csf_get_freq_bands (&freq_bands);
1502 if (mph_init_rr_ind->freq_bands NEQ freq_bands)
1503 {
1504 TRACE_EVENT_P2 ("FFS data %x, doesn't match L1 compilation flag %x", freq_bands, mph_init_rr_ind->freq_bands);
1505 TRACE_ERROR ("FFS data doesn't match L1 compilation flag");
1506 TRACE_ASSERT (freq_bands NEQ mph_init_rr_ind->freq_bands);
1507 }
1508
1509 if (rfp->pow_class4[IDX_PWRCLASS_900].pow_class NEQ mph_init_rr_ind->pclass_900 OR
1510 rfp->pow_class4[IDX_PWRCLASS_850].pow_class NEQ mph_init_rr_ind->pclass_850 OR
1511 rfp->pow_class4[IDX_PWRCLASS_1800].pow_class NEQ mph_init_rr_ind->pclass_1800 OR
1512 rfp->pow_class4[IDX_PWRCLASS_1900].pow_class NEQ mph_init_rr_ind->pclass_1900)
1513 {
1514 TRACE_EVENT ("FFS Power Class info doesn't match L1 Powe Class info");
1515 TRACE_ERROR ("FFS Power Class info doesn't match L1 Powe Class info");
1516 TRACE_ASSERT (mph_init_rr_ind->pclass_900 NEQ rfp->pow_class4[IDX_PWRCLASS_900].pow_class);
1517 }
1518 PFREE(mph_init_rr_ind);
1519 }
1520 #endif
1521
1522 #endif