comparison src/g23m-gsm/rr/rr_attg.c @ 104:27a4235405c6

src/g23m-gsm: import from LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 04 Oct 2016 18:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
103:76d139c7a25e 104:27a4235405c6
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 holds the functions for handling primitives
18 | sent from entity GRR to entity RR and vice versa.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef RR_GPRS_C
23 #define RR_GPRS_C
24
25 #ifdef GPRS
26
27 #define ENTITY_RR
28
29 /*==== INCLUDES ===================================================*/
30
31 #include <string.h>
32 #include <stddef.h>
33 #include "typedefs.h"
34 #include "pcm.h"
35 #include "pconst.cdg"
36 #include "mconst.cdg"
37 #include "message.h"
38 #include "vsi.h"
39 #include "custom.h"
40 #include "gsm.h"
41 #include "prim.h"
42 #include "pei.h"
43 #include "tok.h"
44 #include "rr_gprs.h"
45 #include "rr.h"
46 #include "rr_em.h"
47
48 static void att_get_scell_info (T_serving_cell_info* sc, UBYTE idx);
49 static void att_gprs_store_nc_mode(T_D_SYS_INFO_13* sys_info_13);
50 #ifdef REL99
51 static void att_gprs_store_nw_release(T_D_SYS_INFO_13* sys_info_13);
52 #endif
53
54 static T_NC_DATA* is_nc_in_list(USHORT arfcn);
55 static T_NC_DATA* find_empty_slot_in_list(void);
56 static BOOL rr_ext_meas_can_start ( void );
57 /*
58 +--------------------------------------------------------------------+
59 | PROJECT : GSM-PS (6147) MODULE : RR_GPRS |
60 | STATE : code ROUTINE : att_for_sysinfo_type13 |
61 +--------------------------------------------------------------------+
62
63 PURPOSE : Checks GPRS availability of cell
64 */
65 void att_for_sysinfo_type13 (T_MPH_UNITDATA_IND* data_ind,
66 T_D_SYS_INFO_13* sys_info_13)
67 {
68 GET_INSTANCE_DATA;
69 /*
70 * get the storage area by checking the channel number
71 */
72 UBYTE index = att_get_index (data_ind->arfcn);
73 TRACE_FUNCTION("att_for_sysinfo_type13");
74 switch(GET_STATE(STATE_ATT))
75 {
76 case ATT_CS2:
77 /*
78 * during cell selection
79 * only CR_INDEX is taken in account
80 */
81 if (index EQ CR_INDEX)
82 {
83 switch(GET_STATE(STATE_GPRS))
84 {
85 case GPRS_ACTIVATED:
86 case GPRS_PIM_BCCH:
87 case GPRS_DEDI_SDCCH:
88 if(sys_info_13->si13_rest_oct.v_si13_info AND
89 sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
90 {
91 SET_STATE(STATE_GPRS, GPRS_PIM_PBCCH);
92 }
93 else
94 {
95 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
96 /*
97 * check the NC mode, this is the default
98 * value of the NW which can be overriden
99 * by a Packet Measurement Order.
100 * In CS2 we can always use the value provided
101 * by the NW
102 */
103 att_gprs_store_nc_mode(sys_info_13);
104 }
105 break;
106 case GPRS_PIM_PBCCH:
107 TRACE_EVENT("GPRS config changed during CS2!");
108 if(sys_info_13->si13_rest_oct.v_si13_info AND
109 !sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
110 {
111 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
112 }
113 break;
114 default:
115 break;
116 }
117
118 gprs_rrgrr_store_sdu(rr_data->gprs_data.si13_sdu, &data_ind->sdu);
119 att_set_sys_info_read (SYS_INFO_13_READ, CR_INDEX);
120 #ifdef REL99
121 att_gprs_store_nw_release(sys_info_13);
122 #endif
123 att_check_bcch_carrier_si ();
124 }
125 break;
126 case ATT_CS3:
127 /*
128 * during cell reselection
129 * only CR_INDEX is taken in account
130 */
131 if (index EQ CR_INDEX)
132 {
133 switch(GET_STATE(STATE_GPRS))
134 {
135 case GPRS_ACTIVATED:
136 case GPRS_PIM_BCCH:
137 if(sys_info_13->si13_rest_oct.v_si13_info AND
138 sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
139 {
140 SET_STATE(STATE_GPRS, GPRS_PIM_PBCCH);
141 }
142 else
143 {
144 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
145 /*
146 * check the NC mode, this is the default
147 * value of the NW which can be overriden
148 * by a Packet Measurement Order.
149 * In CS3 we can always use the value provided
150 * by the NW
151 */
152 att_gprs_store_nc_mode(sys_info_13);
153 }
154 break;
155 case GPRS_PIM_PBCCH:
156 if(sys_info_13->si13_rest_oct.v_si13_info AND
157 !sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
158 {
159 TRACE_EVENT("GPRS config changed during CS3!");
160 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
161 }
162 break;
163 default:
164 break;
165 }
166
167 gprs_rrgrr_store_sdu(rr_data->gprs_data.si13_sdu, &data_ind->sdu);
168 att_set_sys_info_read (SYS_INFO_13_READ, CR_INDEX);
169 #ifdef REL99
170 att_gprs_store_nw_release(sys_info_13);
171 #endif
172
173 att_check_neighbourcell_si_reestab();
174
175 }
176 break;
177 case ATT_CON_EST:
178 case ATT_IDLE:
179 switch (index)
180 {
181 case SC_INDEX:
182 /* now we want to send the SI13 to GRR */
183 if(/*rr_data->ms_data.rr_service EQ LIMITED_SERVICE OR*/
184 !att_gprs_is_avail())
185 return;
186
187 switch(GET_STATE(STATE_GPRS))
188 {
189 case GPRS_ACTIVATED:
190 if((rr_data->sc_data.selection_type EQ CELL_RESELECTION_ON_GPRS_ACT) AND
191 (rr_data->sc_data.cd.sys_info_read EQ ALL_SYS_INFO_READ))
192 {
193 TRACE_EVENT(" CELL_RESELECTION_ON_GPRS_ACT should end");
194 TIMERSTOP(T_RESELECT);
195 }
196
197 if(sys_info_13->si13_rest_oct.v_si13_info AND
198 sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
199 {
200 if(rr_data->sc_data.cd.sys_info_read EQ ALL_SYS_INFO_READ)
201 {
202 att_gprs_stop_pl();
203 }
204 SET_STATE(STATE_GPRS, GPRS_PIM_PBCCH);
205 }
206 else
207 {
208 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
209 if(rr_data->sc_data.cd.sys_info_read EQ ALL_SYS_INFO_READ)
210 {
211 att_build_idle_req(SC_INDEX, MODE_SYS_INFO_CHANGE);
212 }
213 /*
214 * check the NC mode, this is the default
215 * value of the NW which can be overriden
216 * by a Packet Measurement Order.
217 *
218 */
219 att_gprs_store_nc_mode(sys_info_13);
220 }
221 break;
222 case GPRS_PIM_BCCH:
223 case GPRS_PTM_BCCH:
224 /*
225 * check the NC mode, this is the default
226 * value of the NW which can be overriden
227 * by a Packet Measurement Order.
228 *
229 */
230 att_gprs_store_nc_mode(sys_info_13);
231 /* XXX */
232 /*
233 * Right now it not clear what how the activation of PBCCH
234 * should be handled in RR/GRR
235 */
236 if (GET_STATE(STATE_GPRS) EQ GPRS_PTM_BCCH)
237 break;
238
239 if(sys_info_13->si13_rest_oct.v_si13_info AND
240 sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
241 {
242 att_gprs_stop_pl();
243 SET_STATE(STATE_GPRS, GPRS_PIM_PBCCH);
244 }
245 break;
246 case GPRS_PIM_PBCCH:
247 if(sys_info_13->si13_rest_oct.v_si13_info AND
248 !sys_info_13->si13_rest_oct.si13_info.v_pbcch_des)
249 {
250 /*XXX not possible actually */
251 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
252 }
253 break;
254 default:
255 break;
256 }
257
258 /*
259 * GRR requests reading of SI13 every 30 seconds
260 * pass the SI13 to GRR, for further evaluation
261 */
262 TRACE_EVENT("idle sc");
263 TRACE_EVENT_P1("sys_info_read %d", rr_data->sc_data.cd.sys_info_read);
264 gprs_rrgrr_store_sdu(rr_data->gprs_data.si13_sdu, &data_ind->sdu);
265 att_set_sys_info_read (SYS_INFO_13_READ, SC_INDEX);
266
267 #ifdef REL99
268 att_gprs_store_nw_release(sys_info_13);
269 #endif
270 att_signal_gprs_support();
271 break;
272 case NOT_PRESENT_8BIT:
273 /*
274 * unexpected channel number
275 */
276 break;
277 default:
278 /*
279 * neighbour cell, ignore.
280 * si13 info is not needed, at first
281 * maybe get PBCCH info later
282 */
283 break;
284 }
285 break;
286 default:
287 break;
288 }
289 }
290
291 /*
292 +-----------------------------------------------------------------------------+
293 | PROJECT : GSM-GPRS () MODULE : RR_GPRS |
294 | STATE : code ROUTINE : att_set_gprs_indication |
295 +-----------------------------------------------------------------------------+
296
297 PURPOSE : sets a flag indicating whether GPRS is wanted by upper layer
298 or not.
299
300 */
301 void att_set_gprs_indication (UBYTE gprs_indic)
302 {
303 GET_INSTANCE_DATA;
304 TRACE_FUNCTION ("att_set_gprs_indication()");
305
306 /*
307 * store parameter from MM
308 */
309 rr_data->gprs_data.gprs_indic = gprs_indic;
310
311 if(rr_data->gprs_data.gprs_indic)
312 {
313 SET_STATE(STATE_GPRS, GPRS_ACTIVATED);
314 TRACE_EVENT("MM wants GPRS");
315 }
316 else
317 {
318 SET_STATE(STATE_GPRS, GPRS_NULL);
319 rr_data->gprs_data.ready_state = FALSE; /* Standby */
320 }
321 }
322
323
324 /*
325 +--------------------------------------------------------------------+
326 | PROJECT : GSM-PS (6147) MODULE : RR_GPRS |
327 | STATE : code ROUTINE : att_check_gprs_supp |
328 +--------------------------------------------------------------------+
329
330 PURPOSE : Checks GPRS availability of cell and sets the internal
331 flag
332 */
333 void att_check_gprs_supp (UBYTE v_gprs_ind, T_gprs_indic * data)
334 {
335 GET_INSTANCE_DATA;
336 TRACE_FUNCTION ("att_check_gprs_supp ()");
337
338 /*
339 * if rest octets for GPRS are available
340 * and GPRS support is requested by MM
341 */
342 switch(GET_STATE(STATE_GPRS))
343 {
344 case GPRS_NULL:
345 if(GET_STATE(STATE_ATT) EQ ATT_CS2 OR
346 GET_STATE(STATE_ATT) EQ ATT_CS3)
347 att_set_sys_info_read(SYS_INFO_13_READ, CR_INDEX);
348 else
349 att_set_sys_info_read(SYS_INFO_13_READ, SC_INDEX);
350 break;
351 case GPRS_ACTIVATED:
352 if(GET_STATE(STATE_ATT) EQ ATT_CS2 OR
353 GET_STATE(STATE_ATT) EQ ATT_CS3)
354 {
355 if(v_gprs_ind)
356 {
357 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
358 /*
359 * If System Info 13 is send on extended BCCH,
360 * request reading, else it is reading on normal BCCH
361 */
362 if(data->si13_pos EQ SI13_ON_BCCH_EXT)
363 {
364 PALLOC(mon_ctrl, MPH_MON_CTRL_REQ);
365
366 mon_ctrl->action = START_MON_EBCCH;
367 mon_ctrl->si_to_read = UPDATE_SI13;
368
369 PSENDX(PL, mon_ctrl);
370 }
371 /* else we will read it on NBCCH */
372 }
373 else
374 {
375 /* no state change */
376 att_set_sys_info_read(SYS_INFO_13_READ, CR_INDEX);
377 }
378 }
379 /*
380 * when GPRS is activated in idle this will be handled
381 * when the SI13 is received
382 */
383 break;
384 case GPRS_PIM_BCCH:
385 case GPRS_PIM_PBCCH:
386 if(!v_gprs_ind)
387 {
388 SET_STATE(STATE_GPRS, GPRS_ACTIVATED);
389 att_set_sys_info_read(SYS_INFO_13_READ, SC_INDEX);
390 if(GET_STATE(STATE_ATT) EQ ATT_IDLE)
391 {
392 /*XY:n inform GRR, and wait for CR_RSP */
393 att_rrgrr_cr_ind(CR_ABNORMAL);
394 rr_data->gprs_data.start_proc = START_PROC_CFG_CHG;
395 }
396 }
397 else
398 {
399 /*
400 * If System Info 13 is send on extended BCCH,
401 * request reading, else it is reading on normal BCCH
402 */
403 if(data->si13_pos EQ SI13_ON_BCCH_EXT)
404 {
405 PALLOC(mon_ctrl, MPH_MON_CTRL_REQ);
406 mon_ctrl->action = START_MON_EBCCH;
407 mon_ctrl->si_to_read = UPDATE_SI13;
408 PSENDX(PL, mon_ctrl);
409 }
410 /* else we will read it on NBCCH */
411 }
412 break;
413 default:
414 break;
415 }
416 }
417
418 /*
419 +--------------------------------------------------------------------+
420 | PROJECT : GSM-PS (6147) MODULE : RR_GPRS |
421 | STATE : code ROUTINE : att_signal_gprs_support |
422 +--------------------------------------------------------------------+
423
424 PURPOSE : Signal GPRS support to GRR
425 */
426 void att_signal_gprs_support (void)
427 {
428 GET_INSTANCE_DATA;
429 PALLOC_SDU(rrgrr_gprs_si13_ind, RRGRR_GPRS_SI13_IND, MAX_L2_FRAME_SIZE * BITS_PER_BYTE);
430 TRACE_FUNCTION ("att_signal_gprs_support()");
431 /*
432 * gprs_support : Y Y X N N
433 * rr_service : F L N F L
434 * sdu : Y Y - - -
435 * servng_cell_info:
436 */
437
438 if(GET_STATE(STATE_ATT) EQ ATT_IDLE AND
439 rr_data->sc_data.cd.sys_info_read NEQ ALL_SYS_INFO_READ)
440 {
441 PFREE(rrgrr_gprs_si13_ind);
442 return;
443 }
444
445 if((GET_STATE(STATE_GPRS) NEQ GPRS_ACTIVATED AND
446 GET_STATE(STATE_GPRS) NEQ GPRS_NULL) AND
447 !(rr_data->ms_data.rr_service EQ NO_SERVICE)
448 )
449 {
450 rrgrr_gprs_si13_ind->cause = GPRS_SUPPORTED;
451
452 /*
453 * copy message content
454 */
455 gprs_rrgrr_fill_from_stored_sdu(&rrgrr_gprs_si13_ind->sdu,
456 rr_data->gprs_data.si13_sdu);
457
458 TRACE_EVENT_P4 ("cs=%u C[%d] bsic=%u #%u",
459 rrgrr_gprs_si13_ind->cause,
460 rrgrr_gprs_si13_ind->serving_cell_info.bcch_arfcn,
461 rrgrr_gprs_si13_ind->serving_cell_info.bcch_bsic,
462 __LINE__);
463
464 /*
465 * set system information state
466 */
467 rrgrr_gprs_si13_ind->si_states.si1_state = SI1_RECEIVED;
468 rrgrr_gprs_si13_ind->si_states.si3_state = SI3_RECEIVED;
469 rrgrr_gprs_si13_ind->si_states.si13_state = SI13_RECEIVED;
470 }
471 else
472 {
473 rrgrr_gprs_si13_ind->cause = GPRS_NOT_SUPPORTED;
474 }
475
476 /*When BA (BCCH) list is modified by PMO/PCCO, this is just for RR, RR should not inform
477 GRR as it would have already formed the list. Sending this new list will change all the
478 index, as GRR would assume it to be new BA(BCCH). When New BA(BCCH) is received then this flag
479 would be reset and GRR should update the BA list*/
480
481 if(rr_data->gprs_data.ba_bcch_modified AND (GET_STATE(STATE_ATT) NEQ ATT_CS3))
482 {
483 rrgrr_gprs_si13_ind->serving_cell_info.arfcn[0]= RRGRR_INVALID_ARFCN;
484 }
485 else
486 {
487 memcpy(rrgrr_gprs_si13_ind->serving_cell_info.arfcn, rr_data->act_ncell_list,
488 sizeof(rrgrr_gprs_si13_ind->serving_cell_info.arfcn));
489 }
490
491
492 att_get_scell_info(&rrgrr_gprs_si13_ind->serving_cell_info, SC_INDEX);
493
494 /* we have found a cell, reset cr flag*/
495 rr_data->gprs_data.cr_pbcch_active = FALSE;
496
497 #if defined (REL99) AND defined (TI_PS_FF_EMR)
498 rrgrr_gprs_si13_ind->serving_cell_info.ba_ind = rr_data->sc_data.ba_index;
499 #endif
500
501 PSENDX(GRR, rrgrr_gprs_si13_ind);
502 }
503
504 /*
505 +-----------------------------------------------------------------------------+
506 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
507 | STATE : code ROUTINE : att_add_ptmsi |
508 +-----------------------------------------------------------------------------+
509
510 PURPOSE : Add the ptmsi if GPRS is supported.
511
512 */
513 void att_add_ptmsi (T_MPH_IDENTITY_REQ * mph_identity_req)
514 {
515 GET_INSTANCE_DATA;
516 TRACE_FUNCTION ("att_add_ptmsi()");
517
518 /*
519 * check availability of GPRS
520 */
521 switch (GET_STATE(STATE_GPRS))
522 {
523 case GPRS_NULL:
524 mph_identity_req->mid.v_ptmsi = FALSE;
525 mph_identity_req->mid.ptmsi = 0L;
526
527
528 mph_identity_req->mid.v_ptmsi2 = FALSE;
529 mph_identity_req->mid.ptmsi2 = 0L;
530 break;
531 default:
532 if (rr_data->gprs_data.ptmsi EQ 0xFFFFFFFF OR
533 rr_data->gprs_data.ptmsi EQ 0L)
534 {
535 mph_identity_req->mid.v_ptmsi = FALSE;
536 mph_identity_req->mid.ptmsi = 0L;
537 }
538 else
539 {
540 mph_identity_req->mid.v_ptmsi = TRUE;
541 mph_identity_req->mid.ptmsi = rr_data->gprs_data.ptmsi;
542 }
543 /*the candidate PTMSI has to be checked also*/
544 if (rr_data->gprs_data.ptmsi2 EQ 0xFFFFFFFF OR
545 rr_data->gprs_data.ptmsi2 EQ 0L)
546 {
547 mph_identity_req->mid.v_ptmsi2 = FALSE;
548 mph_identity_req->mid.ptmsi2 = 0L;
549 }
550 else
551 {
552 mph_identity_req->mid.v_ptmsi2 = TRUE;
553 mph_identity_req->mid.ptmsi2 = rr_data->gprs_data.ptmsi2;
554 }
555 break;
556 }
557 }
558
559 /*
560 +-----------------------------------------------------------------------------+
561 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
562 | STATE : code ROUTINE : att_rrgrr_cr_ind |
563 +-----------------------------------------------------------------------------+
564
565 PURPOSE :
566 IN :
567 OUT :
568
569 */
570
571 void att_rrgrr_cr_ind (UBYTE type)
572 {
573 GET_INSTANCE_DATA;
574 /*
575 * Following cases are possible:
576 * BCCH always CR_ABNORMAL
577 * after con est fail, after dedi, normal cr in idle and ptm,
578 * plmn search,activate req, cell selection
579 * PBCCH:
580 * after con est fail(CR_REQ_CANDIDATE),
581 * activate_req (CR_NORMAL)
582 * after dedi (CR_ABNORMAL)
583 * after imm_ass_rej (CR_SUSPENDED_IDLE)
584 */
585 if(GET_STATE(STATE_GPRS) NEQ GPRS_NULL)
586 {
587 PALLOC(cr_ind, RRGRR_CR_IND);
588 cr_ind->cr_type = type;
589 TRACE_EVENT("cr_ind");
590 PSENDX(GRR, cr_ind);
591 }
592 else
593 {
594 TRACE_EVENT("cr already active");
595 }
596 }
597
598 /*
599 +-----------------------------------------------------------------------------+
600 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
601 | STATE : code ROUTINE : att_rrgrr_cr_req |
602 +-----------------------------------------------------------------------------+
603
604 PURPOSE :
605
606 */
607 void att_rrgrr_cr_req (T_RRGRR_CR_REQ *cr_req)
608 {
609 GET_INSTANCE_DATA;
610 int gprs_state;
611
612 TRACE_FUNCTION ("gprs_rrgrr_cell_reselection_req ()");
613
614 gprs_state = GET_STATE(STATE_GPRS);
615
616 TRACE_EVENT_P3 ("RRGRR_CR_REQ %u [%u] st=%u",
617 cr_req->cr_type, cr_req->arfcn, gprs_state);
618 TRACE_EVENT_P6 ( "r MCC/MNC=%x%x%x/%x%x%x",
619 rr_data->ms_data.plmn.mcc[0],
620 rr_data->ms_data.plmn.mcc[1],
621 rr_data->ms_data.plmn.mcc[2],
622 rr_data->ms_data.plmn.mnc[0],
623 rr_data->ms_data.plmn.mnc[1],
624 rr_data->ms_data.plmn.mnc[2]);
625
626 switch(gprs_state)
627 {
628 case GPRS_PAM_PBCCH:
629 case GPRS_ACTIVATED:
630 case GPRS_PIM_PBCCH:
631 case GPRS_PTM_PBCCH:
632 case GPRS_SUSPENDED_PBCCH:
633 switch(cr_req->cr_type)
634 {
635 case CR_NEW:
636 {
637 UBYTE i;
638 UBYTE found=0;
639 for(i=0; i<6;i++)
640 {
641 if(rr_data->nc_data[i].arfcn EQ cr_req->arfcn AND
642 rr_data->nc_data[i].bsic EQ cr_req->bsic)
643 {
644 found=1;
645 break;
646 }
647 }
648
649 if(!found) { TRACE_ERROR("cr_req(NEW): data does not match");}
650
651 memset (&rr_data->nc_data[CR_INDEX],
652 0,
653 sizeof (T_NC_DATA));
654 rr_data->gprs_data.cr_pbcch_active = TRUE;
655 rr_data->nc_data[CR_INDEX].arfcn = cr_req->arfcn;
656 rr_data->nc_data[CR_INDEX].bsic = cr_req->bsic;
657
658 if (rr_data->ms_data.req_mm_service EQ FUNC_NET_SRCH_BY_MMI)
659 {
660 /*inform MM and stop everything*/
661 /*
662 * send Please Retry to the MMI
663 */
664 rr_data->sc_data.found_entries = 0;
665 att_code_rr_abort_ind (RRCS_ABORT_CEL_SEL_FAIL);
666 }
667
668 if( ! rr_data->gprs_data.cr_pcco_active )
669 att_start_cell_reselection_pbcch(MODE_CELL_RESELECTION);
670 else
671 {
672 att_init_cell_selection(CELL_RESELECTION, RR_ORIGINATED);
673 rr_data->dyn_config.fcr = 0;
674 rr_data->dyn_config.scr = 0;
675 rr_data->bcch_error = 0;
676 rr_data->pag_rec = FALSE;
677 srv_clear_stored_prim (MPH_PAGING_IND);
678 gprs_init_data_cr();
679 dat_att_null();
680
681 SET_STATE (STATE_ATT, ATT_CS3);
682 att_build_idle_req (CR_INDEX, MODE_CELL_RESELECTION);
683 }
684 break;
685 }
686 case CR_NEW_NOT_SYNCED:
687 {
688 /*
689 * a Packet Cell Change Order for a cell which
690 * is not in the BA list has been requested by the NW
691 */
692 PALLOC (mph_bsic_req, MPH_BSIC_REQ);
693 {
694 PALLOC (mph_sync_req, MPH_SYNC_REQ);
695 mph_sync_req->cs = CS_START_PCCO;
696 PSENDX (PL, mph_sync_req);
697 }
698 TRACE_EVENT("cco w/ not synced");
699
700 /*
701 * remember we got a CR_REQ, will be used
702 * on reception of the BSIC_CNF and the UNITDATA_IND
703 */
704 rr_data->gprs_data.cr_pbcch_active = TRUE;
705 SET_STATE (STATE_CELL_SEL, CS_CCO);
706 /* avoid reacting to PAGINGs and ESTABLISH_REQ */
707 dat_att_null();
708 SET_STATE (STATE_ATT, ATT_CS3);
709
710 cs_set_all();
711 rr_data->gprs_data.bsic = cr_req->bsic;
712 rr_data->gprs_data.arfcn = mph_bsic_req->arfcn = cr_req->arfcn;
713 PSENDX (PL, mph_bsic_req);
714 }
715 break;
716 case CR_CS:
717 if (rr_data->gprs_data.cr_pcco_active EQ FALSE)
718 rr_data->gprs_data.cr_pbcch_active = TRUE;
719 else
720 rr_data->gprs_data.cr_pcco_active = FALSE;
721
722
723 if (rr_data->ms_data.req_mm_service EQ FUNC_NET_SRCH_BY_MMI)
724 {
725 /*inform MM and stop everything*/
726 /*
727 * send Please Retry to the MMI
728 */
729 rr_data->sc_data.found_entries = 0;
730 att_code_rr_abort_ind (RRCS_ABORT_CEL_SEL_FAIL);
731 }
732 /*XY:n don't inform GRR */
733 att_start_cell_selection(RR_ORIGINATED, CS_NOT_PARALLEL,NORMAL_SEARCH_MODE);
734 break;
735 case CR_CONT:
736 att_continue_cell_reselect ();
737 break;
738 case CR_COMPLETE:
739 /*
740 * we have a PBCCH and GRR has read it
741 * we inform MM now
742 */
743 if( rr_data->gprs_data.cr_pcco_active EQ FALSE )
744 {
745 PALLOC(mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
746 mph_mon_ctrl_req->action = ENTER_PIM_PBCCH;
747 PSENDX (PL, mph_mon_ctrl_req);
748 }
749 rr_data->gprs_data.cr_pcco_active = FALSE;
750
751 /* initialize the ba_bcch_modified value when Cell reselection is done */
752 rr_data->gprs_data.ba_bcch_modified= FALSE;
753
754 dat_att_cell_selected ();
755 SET_STATE (STATE_ATT, ATT_IDLE);
756 dat_send_bcchinfo_mm (rr_data->cr_data.cr_white_list.si2);
757
758
759
760 if(rr_data->ms_data.rr_service EQ LIMITED_SERVICE AND
761 rr_data->ms_data.req_mm_service EQ FUNC_PLMN_SRCH)
762 {
763 att_copy_old_lai_rac(SC_INDEX);
764 #if 0
765 memcpy (&rr_data->old_lai, &rr_data->nc_data[SC_INDEX].lai,
766 sizeof(T_loc_area_ident));
767 rr_data->old_cell_id = rr_data->nc_data[SC_INDEX].cell_id;
768 #endif
769 att_code_rr_abort_ind (RRCS_ABORT_CEL_SEL_FAIL);
770 }
771 else
772 {
773 if (rr_data->sc_data.mm_started)
774 att_code_rr_act_cnf ();
775 else
776 att_code_rr_act_ind ();
777 }
778
779 /*
780 * This instruction disdurbs test case 20.7
781 * unclear why it is coded here
782 *
783 rr_data->first_meas_received = TRUE;
784 TRACE_EVENT("first_meas_received set to TRUE(rr_attg.c)");
785 */
786 /*
787 * Start registration timer if needed
788 */
789 att_start_registration_timer ();
790 att_mph_identity_req ();
791 #ifdef REL99
792 if(rr_data->ms_data.rr_service EQ FULL_SERVICE) att_config_cbch ();
793 #else
794 if(rr_data->ms_data.rr_service EQ FULL_SERVICE) att_build_cbch ();
795 #endif
796 srv_use_stored_prim ();
797 /*
798 * if the cell reselection has been started after a dedicated connection
799 * attempt with failed SABM / UA content a second attempt is started
800 * immediately.
801 */
802 if (rr_data->repeat_est)
803 {
804 rr_data->repeat_est = FALSE;
805 dat_start_immediate_assign (rr_data->ms_data.establish_cause);
806 }
807 break;
808 default:
809 break;
810
811 }
812 break;
813 case GPRS_PTM_BCCH:
814 if( (cr_req->cr_type EQ CR_NEW) ||
815 (cr_req->cr_type EQ CR_NEW_NOT_SYNCED))
816 {
817 UBYTE i;
818 UBYTE found=0;
819 for(i=0; i<6;i++)
820 {
821 if(rr_data->nc_data[i].arfcn EQ cr_req->arfcn AND
822 rr_data->nc_data[i].bsic EQ cr_req->bsic)
823 {
824 found=1;
825 break;
826 }
827 }
828 memset (&rr_data->nc_data[CR_INDEX], 0, sizeof (T_NC_DATA));
829 rr_data->nc_data[CR_INDEX].arfcn = cr_req->arfcn;
830 rr_data->nc_data[CR_INDEX].bsic = cr_req->bsic;
831 if (rr_data->ms_data.req_mm_service EQ FUNC_NET_SRCH_BY_MMI)
832 {
833 /*inform MM and stop everything*/
834 /*
835 * send Please Retry to the MMI
836 */
837 rr_data->sc_data.found_entries = 0;
838 att_code_rr_abort_ind (RRCS_ABORT_CEL_SEL_FAIL);
839 }
840
841 rr_data->gprs_data.cr_pcco_active = TRUE;
842
843 if(!found)
844 {
845 /*
846 * a Packet Cell Change Order for a cell which
847 * is not in the BA list has been requested by the NW
848 */
849 PALLOC (mph_bsic_req, MPH_BSIC_REQ);
850 {
851 PALLOC (mph_sync_req, MPH_SYNC_REQ);
852 mph_sync_req->cs = CS_START_PCCO;
853 PSENDX (PL, mph_sync_req);
854 }
855 TRACE_EVENT("cco w/ not synced");
856
857
858 SET_STATE (STATE_CELL_SEL, CS_CCO);
859 /* avoid reacting to PAGINGs and ESTABLISH_REQ */
860 dat_att_null();
861 SET_STATE (STATE_ATT, ATT_CS3);
862
863 cs_set_all();
864 rr_data->gprs_data.bsic = cr_req->bsic;
865 rr_data->gprs_data.arfcn = mph_bsic_req->arfcn = cr_req->arfcn;
866 PSENDX (PL, mph_bsic_req);
867 }
868 else
869 {
870 att_init_cell_selection(CELL_RESELECTION, RR_ORIGINATED);
871 rr_data->dyn_config.fcr = 0;
872 rr_data->dyn_config.scr = 0;
873 rr_data->bcch_error = 0;
874 rr_data->pag_rec = FALSE;
875 srv_clear_stored_prim (MPH_PAGING_IND);
876 gprs_init_data_cr();
877 dat_att_null();
878
879 SET_STATE (STATE_ATT, ATT_CS3);
880 att_build_idle_req (CR_INDEX, MODE_CELL_RESELECTION);
881 }
882 }
883 break;
884 case GPRS_PIM_BCCH:
885 /*
886 * we have a BCCH
887 * we have informed GRR of this (with additional info that we
888 * have Full or Limited service)
889 * we inform MM now
890 */
891 switch(cr_req->cr_type)
892 {
893 case CR_COMPLETE:
894 case CR_NEW:
895 case CR_NEW_NOT_SYNCED:
896 case CR_CS:
897 case CR_CONT:
898 dat_att_cell_selected ();
899 SET_STATE (STATE_ATT, ATT_IDLE);
900 dat_send_bcchinfo_mm (rr_data->cr_data.cr_white_list.si2);
901
902 if(rr_data->ms_data.rr_service EQ LIMITED_SERVICE AND
903 rr_data->ms_data.req_mm_service EQ FUNC_PLMN_SRCH)
904 {
905
906 att_copy_old_lai_rac(SC_INDEX);
907 #if 0
908 memcpy (&rr_data->old_lai, &rr_data->nc_data[SC_INDEX].lai,
909 sizeof(T_loc_area_ident));
910 rr_data->old_cell_id = rr_data->nc_data[SC_INDEX].cell_id;
911 #endif
912 att_code_rr_abort_ind (RRCS_ABORT_CEL_SEL_FAIL);
913 }
914 else
915 {
916 if (rr_data->sc_data.mm_started)
917 att_code_rr_act_cnf ();
918 else
919 att_code_rr_act_ind ();
920 }
921
922 /*
923 * Start registration timer if needed
924 */
925 att_start_registration_timer ();
926 att_mph_identity_req ();
927 srv_use_stored_prim ();
928 /*
929 * if the cell reselection has been started after a dedicated connection
930 * attempt with failed SABM / UA content a second attempt is started
931 * immediately.
932 */
933 if (rr_data->repeat_est)
934 {
935 rr_data->repeat_est = FALSE;
936 dat_start_immediate_assign (rr_data->ms_data.establish_cause);
937 }
938 break;
939 default:
940 break;
941 }
942 break;
943 case GPRS_PAM_BCCH:
944 TRACE_EVENT("CR during PA");
945 break;
946 default:
947 break;
948 }
949 PFREE (cr_req);
950 }
951
952 /*
953 +-----------------------------------------------------------------------------+
954 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
955 | STATE : code ROUTINE : att_rrgrr_stop_mon_ccch_req |
956 +-----------------------------------------------------------------------------+
957
958 PURPOSE : Process the primitive RRGRR_STOP_MON_CCCH_REQ received from GRR.
959 This primitive indicates to the RR that the monitoring of CCCH
960 should be stopped. This is only a signal, no parameters needed.
961 This signal is forwarded to ALR.
962
963 */
964 /*
965 * This is reqiured for Testmode A
966 */
967 /*lint -esym(526,grlc_test_mode_active) : not defined | defined in GRR */
968 EXTERN UBYTE grlc_test_mode_active(void);
969
970 void att_rrgrr_stop_mon_ccch_req (T_RRGRR_STOP_MON_CCCH_REQ* stop_mon)
971 {
972 GET_INSTANCE_DATA;
973 TRACE_FUNCTION ("att_rrgrr_stop_mon_ccch_req ()");
974
975 switch(GET_STATE(STATE_GPRS))
976 {
977 /*
978 * This case is necessary to stop ccch monitoring in STATE_GPRS=GPRS_PTM
979 * during Testmode A/B
980 */
981 case GPRS_PTM_BCCH:
982 if(grlc_test_mode_active())
983 {
984 PALLOC(mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
985 mph_mon_ctrl_req->action = STOP_MON_CCCH;
986 PSENDX (PL, mph_mon_ctrl_req);
987 TRACE_EVENT("STOP_MON_CCCH during TESTMODE !!");
988 }
989 break;
990 case GPRS_PIM_BCCH:
991 case GPRS_PIM_PBCCH:
992 case GPRS_PAM_PBCCH:
993 case GPRS_PTM_PBCCH:
994 case GPRS_PAM_BCCH:
995 TRACE_EVENT("stop ccch");
996 break;
997 default:
998 break;
999 }
1000
1001 PFREE (stop_mon);
1002 }
1003
1004 /*
1005 +-----------------------------------------------------------------------------+
1006 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
1007 | STATE : code ROUTINE : att_rrgrr_start_mon_ccch_req |
1008 +-----------------------------------------------------------------------------+
1009
1010 PURPOSE : Process the primitive RRGRR_START_MON_CCCH_REQ received from GRR.
1011 This primitive indicates to the RR that the monitoring of CCCH
1012 should be started. This is only a signal, no parameters needed.
1013 This signal is forwarded to ALR.
1014
1015 */
1016 void att_rrgrr_start_mon_ccch_req (T_RRGRR_START_MON_CCCH_REQ*
1017 mon_req)
1018 {
1019 GET_INSTANCE_DATA;
1020 TRACE_EVENT ("att_rrgrr_start_mon_ccch_req ()");
1021 /*
1022 * store split paging cycle
1023 */
1024 if (mon_req->split_pg EQ RRGRR_NO_DRX)
1025 rr_data->gprs_data.split_pg=256;
1026 else
1027 rr_data->gprs_data.split_pg=mon_req->split_pg;
1028
1029 switch(GET_STATE(STATE_GPRS))
1030 {
1031 case GPRS_PIM_BCCH:
1032 TRACE_EVENT("GPRS_PIM_BCCH");
1033 if(mon_req->pag_mode EQ PAG_MODE_DEFAULT AND
1034 rr_data->gprs_data.page_mode EQ PAG_MODE_REORG)
1035 {
1036 /*
1037 * go back to normal page mode
1038 */
1039 rr_data->gprs_data.page_mode = PAG_MODE_DEFAULT;
1040 att_build_idle_req (SC_INDEX, MODE_SYS_INFO_CHANGE);
1041 }
1042 if(mon_req->pag_mode EQ PAG_MODE_PTM_NP)
1043 {
1044 /*
1045 * we may have received dl assignment in reog idle mode
1046 * we shopuld directly switch to transfer mode with:
1047 * NORMAL_PAGING
1048 */
1049 SET_STATE(STATE_GPRS, GPRS_PTM_BCCH);
1050 SET_STATE(STATE_ATT, ATT_IDLE);
1051 SET_STATE(STATE_DAT, DAT_IDLE);
1052
1053 att_build_idle_req(SC_INDEX, MODE_PACKET_TRANSFER);
1054 {
1055 PALLOC(mon_ctrl, MPH_MON_CTRL_REQ);
1056 mon_ctrl->action = START_MON_CCCH;
1057 mon_ctrl->si_to_read = 0;
1058 PSENDX(PL, mon_ctrl);
1059 }
1060 }
1061 break;
1062 case GPRS_PTM_BCCH:
1063 /*
1064 * set page_mode to REORG if NON_DRX_TIMER is used
1065 * set page_mode to DEFAULT if NON_DRX_TIMER is not used or 0
1066 */
1067 TRACE_EVENT("GPRS_PTM");
1068 if(mon_req->pag_mode EQ PAG_MODE_PTM_NP)
1069 {
1070 PALLOC(mon_ctrl, MPH_MON_CTRL_REQ);
1071 mon_ctrl->action = START_MON_CCCH;
1072 mon_ctrl->si_to_read = 0;
1073 PSENDX(PL, mon_ctrl);
1074 }
1075 else if(mon_req->pag_mode EQ PAG_MODE_PIM_NP)
1076 {
1077 /*
1078 * Go into idle mode but start ONLY CCCH reading with the following order:
1079 * start with REORG and then switch to NORMAL paging
1080 */
1081 TRACE_EVENT("PTM->IDLE: CCCH reorg+normal");
1082 }
1083 else
1084 {
1085 rr_data->gprs_data.page_mode = mon_req->pag_mode;
1086 SET_STATE (STATE_GPRS, GPRS_PIM_BCCH);
1087 att_return_to_idle();
1088
1089 /* Transition from PTM to PIM state. PBCCH is not present in the
1090 * cell. Check if the previous PTM state was used for routing Area update.
1091 * start black list search to look for inactive carriers
1092 * Cell-Selection Improvement LLD - 4.1.4.3
1093 */
1094 if((rr_data->ms_data.establish_cause EQ ESTCS_GPRS_1P) AND
1095 (rr_data->cs_data.black_list_search_pending EQ TRUE))
1096 {
1097
1098 rr_data->cs_data.black_list_search_pending = FALSE;
1099
1100 if(cs_check_region(rr_data->cs_data.region))
1101 {
1102 /* Do not start Black list search,when Black list database is empty */
1103 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT
1104 if (rr_data->cs_data.region EQ BOTH_REGIONS)
1105 {
1106 if(srv_is_list_set(&rr_data->cs_data.black_list.list[EUROPEAN_REGION]) OR
1107 srv_is_list_set(&rr_data->cs_data.black_list.list[AMERICAN_REGION]))
1108 {
1109 att_start_cell_selection(RR_ORIGINATED,CS_PARALLEL,BLACK_LIST_SEARCH_MODE);
1110 }
1111 else
1112 {
1113 TRACE_EVENT("Black List empty");
1114 }
1115 }
1116 #else
1117 if(srv_is_list_set(
1118 &rr_data->cs_data.black_list.list[rr_data->cs_data.region]))
1119 {
1120 att_start_cell_selection(RR_ORIGINATED,CS_PARALLEL,BLACK_LIST_SEARCH_MODE);
1121 }
1122 #endif
1123 else
1124 {
1125 #ifdef TI_PS_FF_QUAD_BAND_SUPPORT
1126 if(srv_is_list_set(
1127 &rr_data->cs_data.black_list.list[rr_data->cs_data.region]))
1128 {
1129 att_start_cell_selection(RR_ORIGINATED,CS_PARALLEL,BLACK_LIST_SEARCH_MODE);
1130 }
1131 else
1132 #endif
1133 {
1134 TRACE_EVENT("Black List empty");
1135 }
1136 }
1137 }
1138 }
1139 }
1140 break;
1141 case GPRS_PAM_BCCH:
1142 rr_data->gprs_data.page_mode = mon_req->pag_mode;
1143 SET_STATE (STATE_GPRS, GPRS_PIM_BCCH);
1144 att_return_to_idle();
1145 break;
1146 case GPRS_PAM_PBCCH:
1147 //break;
1148 case GPRS_PTM_PBCCH:
1149 case GPRS_PIM_PBCCH:
1150 {
1151 PALLOC(mon_ctrl, MPH_MON_CTRL_REQ);
1152 mon_ctrl->action = START_MON_CCCH;
1153 mon_ctrl->si_to_read = 0;
1154
1155 PSENDX(PL, mon_ctrl);
1156 SET_STATE(STATE_DAT, DAT_IDLE); /* allow reception of pagings */
1157 }
1158 break;
1159 default:
1160 TRACE_EVENT("start_mon_ccch_req not handled");
1161 break;
1162 }
1163 PFREE (mon_req);
1164 }
1165
1166 /*
1167 +-----------------------------------------------------------------------------+
1168 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
1169 | STATE : code ROUTINE : att_rrgrr_start_mon_bcch_req |
1170 +-----------------------------------------------------------------------------+
1171
1172 PURPOSE : Process the primitive RRGRR_START_MON_BCCH_REQ received from GRR.
1173 This primitive indicates to the RR to read SI. This primitive
1174 contains the parameter which indicates to the SI to read on BCCH.
1175 This signal is forwarded to ALR.
1176
1177 */
1178 void att_rrgrr_start_mon_bcch_req (T_RRGRR_START_MON_BCCH_REQ
1179 *rrgrr_start_mon_bcch_req)
1180 {
1181 GET_INSTANCE_DATA;
1182 TRACE_EVENT ("att_rrgrr_start_mon_bcch_req ()");
1183 switch (GET_STATE(STATE_GPRS))
1184 {
1185 case GPRS_PIM_BCCH:
1186 case GPRS_PIM_PBCCH:
1187 case GPRS_PAM_PBCCH:
1188 case GPRS_PTM_PBCCH:
1189 case GPRS_PTM_BCCH:
1190 {
1191 UBYTE si_to_read = rrgrr_start_mon_bcch_req->si_to_read;
1192 USHORT sys_info_read = rr_data->sc_data.cd.sys_info_read;
1193 PALLOC ( mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
1194
1195 TRACE_EVENT_P1 ( "rrgrr_start_mon_bcch_req->si_to_read = %d",
1196 rrgrr_start_mon_bcch_req->si_to_read );
1197
1198 mph_mon_ctrl_req->action = START_MON_NBCCH;
1199 switch ( si_to_read )
1200 {
1201 case UNSPECIFIED_SI:
1202 sys_info_read = 0;
1203 break;
1204 case UPDATE_SI1:
1205 sys_info_read &= ~ SYS_INFO_1_READ;
1206 break;
1207 case UPDATE_SI2_SI2BIS_OR_SI2TER:
1208 sys_info_read &= ~ (SYS_INFO_2_READ | SYS_INFO_2BIS_READ | SYS_INFO_2TER_READ);
1209 #if defined (REL99) AND defined (TI_PS_FF_EMR)
1210 /*Once SI-2,2Bis,2Ter are read, we can configure ALR for acquiring SI-2quater*/
1211 if ( (rr_data->sc_data.cd.si2quater_status NEQ SI2QUATER_ABSENT ) AND
1212 (rr_data->sc_data.cd.si2quater_pos EQ SI2QUATER_ON_EBCCH) )
1213 rr_data->sc_data.cd.si2quater_status = SI2QUATER_CONFIGURE;
1214 #endif
1215 break;
1216 case UPDATE_SI3_SI4_SI7_OR_SI8:
1217 sys_info_read &= ~ (SYS_INFO_3_READ | SYS_INFO_4_READ );
1218 break;
1219 case UPDATE_SI9:
1220 /* no support of SI 9 */
1221 break;
1222 case COMPLETE_SI:
1223 sys_info_read = 0;
1224 break;
1225 case UPDATE_SI13:
1226 sys_info_read &= ~ SYS_INFO_13_READ;
1227 if(rr_data->nc_data[SC_INDEX].si13_loc_ind EQ EXTENDED_BCCH)
1228 {
1229 mph_mon_ctrl_req->action = START_MON_EBCCH;
1230 }
1231 break;
1232 default:
1233 break;
1234 }
1235 rr_data->sc_data.cd.sys_info_read = sys_info_read;
1236 TRACE_EVENT_P1("st_bcch:sys_info_read %d",
1237 rr_data->sc_data.cd.sys_info_read);
1238 mph_mon_ctrl_req->si_to_read = si_to_read;
1239 PSENDX (PL, mph_mon_ctrl_req);
1240 }
1241 break;
1242 case GPRS_ACTIVATED:
1243 if(GET_STATE(STATE_ATT) EQ ATT_IDLE)
1244 att_signal_gprs_support();
1245 break;
1246 default:
1247 break;
1248 }
1249 PFREE (rrgrr_start_mon_bcch_req);
1250 }
1251
1252 /*
1253 +-----------------------------------------------------------------------------+
1254 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
1255 | STATE : code ROUTINE : att_convert_idle_c31_cr |
1256 +-----------------------------------------------------------------------------+
1257
1258 PURPOSE :
1259
1260 */
1261 GLOBAL void att_convert_idle_c31_cr(UBYTE index)
1262 {
1263 GET_INSTANCE_DATA;
1264 TRACE_EVENT_P2("att_convert_idle_c31_cr called for index=%d conversion = %d", index,
1265 rr_data->nc_data[index].v_cr_par);
1266 switch(rr_data->nc_data[index].v_cr_par)
1267 {
1268 case CR_PAR_VALID:
1269
1270 /*
1271 * For the first neighbour cell in the message where the struct exists,
1272 * the following default values shall be used for missing parameters:
1273 * GPRS_RXLEV_ACCESS_MIN = Serving cell RXLEV_ACCESS_MIN
1274 * GPRS_MS_TXPWR_MAX_CCH = Serving cell MS_TXPWR_MAX_CCH
1275 * GPRS_TEMPORARY_OFFSET = Serving cell TEMPORARY_OFFSET
1276 * GPRS_PENALTY_TIME = Serving cell PENALTY_TIME
1277 * GPRS_RESELECT_OFFSET = 0
1278 * HCS_THR = infinity
1279 * PRIORITY_CLASS = undefined
1280 * SI13_PBCCH_LOCATION = undefined
1281 *
1282 */
1283 if( rr_data->nc_data[index].cr_par.gprs_rxlev_access_min EQ
1284 GPRS_RXLEV_ACCESS_MIN_INVALID)
1285 rr_data->nc_data[index].cr_par.gprs_rxlev_access_min =
1286 rr_data->nc_data[SC_INDEX].select_para.rxlev_access_min;
1287
1288 if(rr_data->nc_data[index].cr_par.gprs_ms_txpwr_max_cch EQ
1289 GPRS_MS_TXPWR_MAX_CCH_INVALID)
1290 rr_data->nc_data[index].cr_par.gprs_ms_txpwr_max_cch =
1291 rr_data->nc_data[SC_INDEX].select_para.ms_txpwr_max_cch;
1292
1293 if(rr_data->nc_data[index].cr_par.gprs_temporary_offset EQ
1294 GPRS_TEMPORARY_OFFSET_INVALID)
1295 rr_data->nc_data[index].cr_par.gprs_temporary_offset =
1296 rr_data->nc_data[SC_INDEX].c2_par.temp_offset;
1297
1298 if(rr_data->nc_data[index].cr_par.gprs_penalty_time EQ
1299 GPRS_PENALTY_TIME_INVALID)
1300 rr_data->nc_data[index].cr_par.gprs_penalty_time =
1301 rr_data->nc_data[SC_INDEX].c2_par.penalty_time * 2;
1302
1303 if(rr_data->nc_data[index].cr_par.gprs_reselect_offset EQ
1304 GPRS_RESEL_OFF_INVALID)
1305 rr_data->nc_data[index].cr_par.gprs_reselect_offset =
1306 GPRS_RESEL_OFF_DEFAULT;
1307
1308 /*
1309 * 31 is the maximum 5 bit value.
1310 * hcs_thr = 31 , means infinity
1311 */
1312 if(rr_data->nc_data[index].cr_par.hcs_thr EQ
1313 GPRS_HCS_THR_INVALID)
1314 {
1315 rr_data->nc_data[index].cr_par.hcs_thr = 31;
1316 }
1317 /* priority class remains undefined */
1318 break;
1319 case CR_PAR_INVALID:
1320 /*
1321 * initialise values
1322 * conversion of idle mode parameters to GPRS cell reselection parameters
1323 * GPRS_RXLEV_ACCESS_MIN = RXLEV_ACCESS_MIN
1324 * GPRS_MS_TXPWR_MAX_CCH = MS_TXPWR_MAX_CCH
1325 * C31 = 0
1326 * GPRS_RESELECT_OFFSET(n) =
1327 * CELL_RESELECT_OFFSET(n) - CELL_RESELECT_OFFSET(s)
1328 * GPRS_TEMPORARY_OFFSET = TEMPORARY OFFSET
1329 * GPRS_PENALTY_TIME = PENALTY_TIME
1330 * PRIORITY_CLASS = 0
1331 * C32_QUAL = 0
1332 * GPRS_CELL_RESELECT_HYSTERESIS = CELL_RESELECT_HYSTERESIS
1333 * RA_RESELECT_HYSTERESIS = CELL_RESELECT_HYSTERESIS
1334 */
1335
1336 rr_data->nc_data[index].cr_par.gprs_rxlev_access_min =
1337 rr_data->nc_data[index].select_para.rxlev_access_min;
1338 rr_data->nc_data[index].cr_par.gprs_ms_txpwr_max_cch =
1339 rr_data->nc_data[index].select_para.ms_txpwr_max_cch;
1340
1341 /*
1342 * NOTE: If PENALTY_TIME = 11111 for a cell,
1343 * the sign of CELL_RESELECT_OFFSET shall be changed
1344 * and TEMPORARY OFFSET set to 0 for that cell.
1345 */
1346 if( rr_data->nc_data[index].c2_par.penalty_time EQ 31)
1347 {
1348 rr_data->nc_data[index].cr_par.gprs_temporary_offset =
1349 GPRS_RESEL_OFF_DEFAULT;
1350 }
1351 else
1352 {
1353 rr_data->nc_data[index].cr_par.gprs_temporary_offset =
1354 rr_data->nc_data[index].c2_par.temp_offset;
1355 }
1356
1357 rr_data->nc_data[index].cr_par.priority_class = 0;
1358 rr_data->nc_data[index].cr_par.gprs_penalty_time =
1359 rr_data->nc_data[index].c2_par.penalty_time;
1360 rr_data->nc_data[index].cr_par.gprs_penalty_time *= 2;
1361
1362 if( rr_data->nc_data[index].bcch_status NEQ DECODED )
1363 TRACE_EVENT_P1("Error BCCH in NOT DECODED for arfcn %d in att_convert_idle_cr" ,
1364 rr_data->nc_data[index].arfcn);
1365 break;
1366 default :
1367 break;
1368
1369 }
1370 }
1371 /*
1372 +--------------------------------------------------------------------+
1373 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1374 | STATE : code ROUTINE : att_insert_c31_cr_data_in_cell |
1375 +--------------------------------------------------------------------+
1376
1377 PURPOSE : To store T_cr_par in rr_data->nc_data
1378
1379 */
1380
1381 GLOBAL void att_insert_c31_cr_data_in_cell (UBYTE index)
1382 {
1383 GET_INSTANCE_DATA;
1384 UBYTE i;
1385 TRACE_EVENT_P1("att_insert_c31_cr_data_in_cell called for arfcn=%d" ,
1386 rr_data->nc_data[index].arfcn );
1387
1388
1389 rr_data->nc_data[index].v_cr_par = CR_PAR_INVALID;
1390 for( i = 0; i < rr_data->gprs_data.num_add_freq_list; i++ )
1391 {
1392 if( rr_data->nc_data[index].arfcn EQ rr_data->gprs_data.add_freq_lists[i].arfcn )
1393 {
1394 if( rr_data->gprs_data.add_freq_lists[i].v_cr_par )
1395 {
1396 TRACE_EVENT_P2(" Cr_par found for arfcn =%d, index in add freq list = %d",
1397 rr_data->nc_data[index].arfcn, i);
1398 rr_data->nc_data[index].v_cr_par = CR_PAR_VALID;
1399 memcpy( & (rr_data->nc_data[index].cr_par),
1400 & (rr_data->gprs_data.add_freq_lists[i].cr_par),
1401 sizeof( T_cr_par) );
1402 att_convert_idle_c31_cr(index);
1403 }
1404 else
1405 {
1406 TRACE_EVENT_P1("Cr_par found for arfcn =%d in add freq list", rr_data->nc_data[index].arfcn);
1407 if( rr_data->nc_data[index].bcch_status EQ DECODED)
1408 att_convert_idle_c31_cr(index);
1409 }
1410 return;
1411 }
1412 }
1413 if( rr_data->nc_data[index].bcch_status EQ DECODED)
1414 att_convert_idle_c31_cr(index);
1415 }
1416
1417 /*
1418 +-----------------------------------------------------------------------------+
1419 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
1420 | STATE : code ROUTINE : att_init_c31_cr_par |
1421 +-----------------------------------------------------------------------------+
1422
1423 PURPOSE :
1424
1425 */
1426 static void att_init_nc_data_c31_cr_par(void)
1427 {
1428 GET_INSTANCE_DATA;
1429 UBYTE index = 0;
1430 TRACE_EVENT(" att_init_nc_data_c31_cr_par called");
1431 for(index = 0; index <= SC_INDEX; index++)
1432 {
1433 rr_data->nc_data[index].v_cr_par = CR_PAR_INVALID;
1434
1435 if( rr_data->nc_data[index].bcch_status NEQ EMPTY )
1436 {
1437 att_insert_c31_cr_data_in_cell(index);
1438 }
1439 }
1440 }
1441
1442
1443 /*
1444 +-----------------------------------------------------------------------------+
1445 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
1446 | STATE : code ROUTINE : att_init_cr_c31_data |
1447 +-----------------------------------------------------------------------------+
1448
1449 PURPOSE :
1450
1451 */
1452 static void att_init_cr_c31_data(void)
1453 {
1454 GET_INSTANCE_DATA;
1455 UBYTE i = 0;
1456 UBYTE first_valid_par = 0;
1457 UBYTE valid_found = FALSE;
1458
1459 for( ; (i < rr_data->gprs_data.num_add_freq_list) AND (valid_found EQ FALSE) ; i++)
1460 {
1461 if( rr_data->gprs_data.add_freq_lists[i].v_cr_par)
1462 {
1463 valid_found = TRUE;
1464 first_valid_par = i;
1465 }
1466 }
1467
1468 if( valid_found )
1469 {
1470 for( i = first_valid_par + 1 ; i < rr_data->gprs_data.num_add_freq_list ; i++)
1471 {
1472 if( rr_data->gprs_data.add_freq_lists[i].v_cr_par EQ FALSE )
1473 {
1474 /* entire structure is missing */
1475 rr_data->gprs_data.add_freq_lists[i].v_cr_par = TRUE;
1476 memcpy(& (rr_data->gprs_data.add_freq_lists[i].cr_par),
1477 & (rr_data->gprs_data.add_freq_lists[i-1].cr_par), sizeof(T_cr_par));
1478 }
1479 else
1480 {
1481 /* a part of the structure may be missing */
1482 if( rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_rxlev_access_min EQ
1483 GPRS_RXLEV_ACCESS_MIN_INVALID)
1484 rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_rxlev_access_min =
1485 rr_data->gprs_data.add_freq_lists[i-1].cr_par.gprs_rxlev_access_min;
1486
1487 if(rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_ms_txpwr_max_cch EQ
1488 GPRS_MS_TXPWR_MAX_CCH_INVALID)
1489 rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_ms_txpwr_max_cch =
1490 rr_data->gprs_data.add_freq_lists[i-1].cr_par.gprs_ms_txpwr_max_cch;
1491
1492 if(rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_temporary_offset EQ
1493 GPRS_TEMPORARY_OFFSET_INVALID )
1494 rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_temporary_offset =
1495 rr_data->gprs_data.add_freq_lists[i-1].cr_par.gprs_temporary_offset;
1496
1497 if(rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_penalty_time EQ
1498 GPRS_PENALTY_TIME_INVALID)
1499 rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_penalty_time =
1500 rr_data->gprs_data.add_freq_lists[i-1].cr_par.gprs_penalty_time;
1501
1502 if(rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_reselect_offset EQ
1503 GPRS_RESEL_OFF_INVALID)
1504 rr_data->gprs_data.add_freq_lists[i].cr_par.gprs_reselect_offset =
1505 rr_data->gprs_data.add_freq_lists[i-1].cr_par.gprs_reselect_offset;
1506
1507 if(rr_data->gprs_data.add_freq_lists[i].cr_par.hcs_thr EQ
1508 GPRS_HCS_THR_INVALID )
1509 rr_data->gprs_data.add_freq_lists[i].cr_par.hcs_thr =
1510 rr_data->gprs_data.add_freq_lists[i-1].cr_par.hcs_thr;
1511
1512 if(rr_data->gprs_data.add_freq_lists[i].cr_par.priority_class EQ
1513 GPRS_PRIORITY_CLASS_INVALID)
1514 rr_data->gprs_data.add_freq_lists[i].cr_par.priority_class =
1515 rr_data->gprs_data.add_freq_lists[i-1].cr_par.priority_class;
1516
1517 if(rr_data->gprs_data.add_freq_lists[i].cr_par.si13_location EQ
1518 SI13_LOC_INVALID)
1519 rr_data->gprs_data.add_freq_lists[i].cr_par.si13_location =
1520 rr_data->gprs_data.add_freq_lists[i-1].cr_par.si13_location;
1521
1522 if(rr_data->gprs_data.add_freq_lists[i].cr_par.psi1_repeat_period EQ
1523 PSI1_RPT_PRD_INVALID )
1524 rr_data->gprs_data.add_freq_lists[i].cr_par.psi1_repeat_period =
1525 rr_data->gprs_data.add_freq_lists[i-1].cr_par.psi1_repeat_period;
1526
1527 if(rr_data->gprs_data.add_freq_lists[i].cr_par.pbcch_location EQ
1528 PBCCH_LOC_INVALID )
1529 rr_data->gprs_data.add_freq_lists[i].cr_par.pbcch_location =
1530 rr_data->gprs_data.add_freq_lists[i-1].cr_par.pbcch_location;
1531
1532 }
1533 }
1534 }
1535
1536 }
1537
1538 /*
1539 +--------------------------------------------------------------------+
1540 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1541 | STATE : code ROUTINE : att_calculate_c31_c32 |
1542 +--------------------------------------------------------------------+
1543
1544 PURPOSE : calculates C31 and C32 criterion of cell reselection is still valid.
1545
1546 */
1547
1548 GLOBAL void att_calculate_c31_c32 (UBYTE index)
1549 {
1550 GET_INSTANCE_DATA;
1551 USHORT h;
1552 T_NC_DATA *rrd;
1553 T_NC_DATA *sc_ptr;
1554
1555 UBYTE prios, prion;
1556 /*lint -esym(526,p_res_off) : not defined | defined in GRR */
1557 extern const SHORT p_res_off[];
1558
1559 /* C1 = A - MAX(B,0) */
1560 /* A = RLA_P - GPRS_RXLEV _ACCESS_MIN */
1561 /* B = GPRS_MS_TXPWR_MAX_CCH - P */
1562 /* P = max MS RF output power */
1563
1564 /* C31 = RLA_P(s) - HCS_THR(s) (serving cell) */
1565 /* C31 = RLA_P(n) - HCS_THR(n) - TO(n)*L(n) (neighbour cell) */
1566 /* TO(n) = GPRS_TEMPORARY_OFFSET(n) * H( GPRS_PENALTY_TIME(N) - T(n) ) */
1567 /* L(n) = 0 if PRIORITY_CLASS(n) = PRIORITY_CLASS(s) */
1568 /* 1 if PRIORITY_CLASS(n) = PRIORITY_CLASS(s) */
1569
1570 /* C32(s) = C1(s) */
1571 /* C32(n) = C1(n) + GPRS_RESELECT OFFSET(n) - TO(n)*(1-L(n)) */
1572 /* TO(n) = GPRS_TEMPORARY_OFFSET(n) * H( GPRS_PENALTY_TIME(N) - T(n) ) */
1573 /* L(n) = 0 if PRIORITY_CLASS(n) = PRIORITY_CLASS(s) */
1574 /* 1 if PRIORITY_CLASS(n) = PRIORITY_CLASS(s) */
1575 /* H(n) = 0 for x < 0 */
1576 /* 1 for x >= 0 */
1577
1578 TRACE_FUNCTION ("att_calculate_c31_c32()");
1579
1580 /*
1581 * get a pointer to the data of the cell
1582 */
1583 rrd = &(rr_data->nc_data[index]);
1584
1585 att_calculate_c1(index);
1586
1587 TRACE_EVENT_P5("arfcn = %d, C1 = %d, rxlev = %d, GPRS_RXLEV _ACCESS_MIN = %d, GPRS_MS_TXPWR_MAX_CCH = %d",
1588 rrd->arfcn, rrd->c1,
1589 rrd->rxlev,
1590 rrd->cr_par.gprs_rxlev_access_min,
1591 rrd->cr_par.gprs_ms_txpwr_max_cch);
1592
1593 TRACE_EVENT_P3 ("hcs thr = %d, prion = %d, valid = %d",
1594 rrd->cr_par.hcs_thr, rrd->cr_par.priority_class , rrd->v_cr_par);
1595
1596 if( rrd->v_cr_par EQ CR_PAR_INVALID)
1597 {
1598 rrd->c31 = 0; /* conversion of idle mode to GPRS cell reselection parameters */
1599 }
1600 else
1601 {
1602 rrd->c31 = rrd->rxlev;
1603 if( rrd->cr_par.hcs_thr NEQ 31 )
1604 rrd->c31 -= ( 2 * rrd->cr_par.hcs_thr );
1605 else
1606 rrd->c31 = -32768;
1607 }
1608
1609 rrd->c32 = rrd->c1;
1610
1611 /* C31 = RLA_P(s) - HCS_THR(s) (serving cell) */
1612 /* C32(s) = C1(s) */
1613
1614 TRACE_EVENT_P1("C31 = %d", rrd->c31);
1615
1616 if( index EQ SC_INDEX )
1617 return;
1618
1619 sc_ptr = &rr_data->nc_data[SC_INDEX];
1620 prios = (sc_ptr->cr_par.priority_class NEQ GPRS_PRIORITY_CLASS_INVALID) ?
1621 sc_ptr->cr_par.priority_class : (UBYTE) 0;
1622
1623 prion = (rrd->cr_par.priority_class NEQ GPRS_PRIORITY_CLASS_INVALID ) ?
1624 rrd->cr_par.priority_class : (UBYTE) 0;
1625
1626 if( rr_data->nc_data[index].v_cr_par EQ CR_PAR_INVALID)
1627 {
1628 /*
1629 * conversion of idle mode paramter to GPRS cell reselection parameters.
1630 * the conversion for GPRS_RESELECTION_OFFSET is done here.
1631 * the coversion of other parameters are done as
1632 * part of the function att_calculate_c1()
1633 *
1634 * GPRS_RESELECT_OFFSET(n) =
1635 * CELL_RESELECT_OFFSET(n) - CELL_RESELECT_OFFSET(s)
1636 *
1637 * NOTE: If PENALTY_TIME = 11111 for a cell,
1638 * the sign of CELL_RESELECT_OFFSET shall be changed
1639 *
1640 */
1641 SHORT nc_sign = 1;
1642 SHORT sc_sign = 1;
1643
1644
1645 if(rrd->cr_par.gprs_penalty_time EQ 31 )
1646 {
1647 nc_sign = -1;
1648 }
1649 if(sc_ptr->cr_par.gprs_penalty_time EQ 31 )
1650 {
1651 sc_sign = -1;
1652 }
1653 rrd->c32 += (USHORT)(nc_sign * 2 * rrd->c2_par.cell_reselect_offset ) -
1654 (USHORT)(sc_sign * 2 * sc_ptr->c2_par.cell_reselect_offset);
1655 TRACE_EVENT_P5(" nc_sign =%d, sc_sign =%d, nc_rese_off=%d, sc_res_off=%d, c31=%d",
1656 nc_sign, sc_sign, rrd->c2_par.cell_reselect_offset, sc_ptr->c2_par.cell_reselect_offset,
1657 rrd->c32);
1658 }
1659 else
1660 {
1661 /* a valid paramter for GPRS_RESELECT_OFFSET is received */
1662 rrd->c32 += p_res_off[rrd->cr_par.gprs_reselect_offset];
1663 TRACE_EVENT_P3(" gprs_reselect_offset = %d, c32 = %d, res off index =%d",
1664 p_res_off[rrd->cr_par.gprs_reselect_offset], rrd->c32, rrd->cr_par.gprs_reselect_offset);
1665 }
1666 /* c32_qual is not known, if there is no PCCCH */
1667
1668
1669 /*
1670 * Calculate x for H(x) and set H(x)
1671 */
1672 TRACE_EVENT_P2("penalty time = %d, avail time = %d", (rrd->cr_par.gprs_penalty_time + 1) * 10, rrd->avail_time/PERIOD_1_SEC );
1673 if ((USHORT)((rrd->cr_par.gprs_penalty_time + 1) * 10) >=
1674 (USHORT)(rrd->avail_time/PERIOD_1_SEC))
1675 h = TRUE;
1676 else
1677 h = FALSE;
1678
1679 if (h)
1680 {
1681 SHORT *criterion;
1682 TRACE_EVENT_P3("penalty timer not expired: %d offset will be applied to (prios)%d NEQ (prion)%d (if 0 c31, if 1 C32 )",
1683 10 * rrd->cr_par.gprs_temporary_offset,
1684 prios, prion);
1685 if( prios NEQ prion )
1686 {
1687 criterion = & (rrd->c31);
1688 }
1689 else
1690 {
1691 criterion = & (rrd->c32);
1692 }
1693 if( rrd->cr_par.gprs_temporary_offset EQ 7 )
1694 {
1695 *criterion = -32768;
1696 }
1697 else
1698 {
1699 *criterion -= 10 * rrd->cr_par.gprs_temporary_offset;
1700 }
1701 }
1702 else
1703 {
1704 TRACE_EVENT("penalty timer expired");
1705 }
1706 if( rrd->cr_par.same_ra_as_serving_cell NEQ SAME_RA_AS_SCELL)
1707 {
1708 TRACE_EVENT(" cell is NOT SAME_RA_AS_SCELL");
1709 rrd->c32 -= 2 * rrd->select_para.cell_resel_hyst ;
1710 }
1711 else if(rr_data->gprs_data.ready_state)
1712 {
1713 /* MS in ready state*/
1714 TRACE_EVENT(" MS in ready state");
1715 rrd->c32 -= (SHORT)2 * rrd->select_para.cell_resel_hyst ;
1716 /* C31 hyst not known */
1717 }
1718 if ( IS_TIMER_ACTIVE (T_NO_RESELECT) )
1719 {
1720 rrd->c32 -= 5;
1721 }
1722 }
1723
1724 /*
1725 +--------------------------------------------------------------------+
1726 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1727 | STATE : code ROUTINE : att_get_next_best_c32_index |
1728 +--------------------------------------------------------------------+
1729
1730 PURPOSE : This function returns the index of a target cell, for reselection.
1731 If no target cell is available then NO_AVAILABLE is returned.
1732 The parameter c31_calculated, indicates if C31 and C32 are already calculated.
1733
1734 */
1735 GLOBAL UBYTE att_get_next_best_c32_index (BOOL c31_calculated)
1736 {
1737 GET_INSTANCE_DATA;
1738 UBYTE max_result = SC_INDEX;
1739 UBYTE result = NO_AVAILABLE;
1740 UBYTE i;
1741 T_cr_par *ncell_first, *ncell_next, *scell_ptr;
1742 BOOL c31_bc, c31_nc, c31_sc;
1743
1744 TRACE_FUNCTION ("att_get_next_best_c32_index()");
1745
1746 switch (rr_data->sc_data.selection_type)
1747 {
1748 case BACK_FROM_DEDICATED:
1749 case BACK_FROM_DEDICATED_RLF:
1750 case CELL_RESELECTION_CR:
1751 case CELL_RESELECTION_RACH:
1752
1753 /* not valid */
1754 break;
1755
1756 default:
1757 /*
1758 * Normal Cell reselection
1759 *
1760 */
1761 if( ! c31_calculated )
1762 {
1763 att_calculate_c31_c32(SC_INDEX);
1764 for (i = 0; i < SC_INDEX; i++)
1765 {
1766 if (rr_data->nc_data[i].bcch_status EQ DECODED)
1767 {
1768 att_calculate_c31_c32 (i);
1769 }
1770 }
1771 }
1772 TRACE_EVENT_P1("Scell = %d", rr_data->nc_data[SC_INDEX].arfcn);
1773 for(i=0;i<=SC_INDEX; i++)
1774 {
1775 if( rr_data->nc_data[i].bcch_status EQ DECODED )
1776 {
1777 ncell_first = &rr_data->nc_data[i].cr_par;
1778 TRACE_EVENT_P6("First best Cell(arfcn=%d), C1=%d,C31=%d,C32=%d,Priority class =%d,hcs_thr=%d",
1779 rr_data->nc_data[i].arfcn,
1780 rr_data->nc_data[i].c1,
1781 rr_data->nc_data[i].c31,
1782 rr_data->nc_data[i].c32,
1783 ncell_first->priority_class,
1784 ncell_first->hcs_thr );
1785 }
1786 }
1787
1788 /*
1789 * Now find the the first one which is not previously used
1790 */
1791 for (i = 0; (i < SC_INDEX) AND (max_result EQ SC_INDEX) ; i++)
1792 {
1793 if ( (!rr_data->nc_data[i].c32_used) AND
1794 rr_data->nc_data[i].bcch_status EQ DECODED AND
1795 rr_data->nc_data[i].c1 > 0)
1796 {
1797 max_result = i;
1798 }
1799 }
1800 if( max_result EQ SC_INDEX )
1801 {
1802 return NO_AVAILABLE;
1803 }
1804 ncell_first = &( rr_data->nc_data[max_result].cr_par);
1805 c31_bc = ( (rr_data->nc_data[max_result].c31 >= 0) AND
1806 (ncell_first->priority_class NEQ GPRS_PRIORITY_CLASS_INVALID) );
1807
1808 /* choose the best cell */
1809 for (i = max_result+1; i < 6 ; i++)
1810 {
1811 if (
1812 (!rr_data->nc_data[i].c32_used) AND
1813 (rr_data->nc_data[i].bcch_status EQ DECODED) AND
1814 (rr_data->nc_data[i].c1) > 0
1815 )
1816 {
1817 ncell_next = &( rr_data->nc_data[i].cr_par);
1818 c31_nc = ( (rr_data->nc_data[i].c31 >= 0) AND
1819 (ncell_next->priority_class NEQ GPRS_PRIORITY_CLASS_INVALID ));
1820 if(
1821 (
1822 c31_bc AND
1823 c31_nc AND
1824 (ncell_next->priority_class EQ ncell_first->priority_class ) AND
1825 (rr_data->nc_data[i].c32 > rr_data->nc_data[max_result].c32)
1826 )
1827 OR
1828 (
1829 c31_bc AND
1830 c31_nc AND
1831 (ncell_next->priority_class > ncell_first->priority_class )
1832 )
1833 )
1834 {
1835 /* prioritized cell reselection must be done */
1836 max_result = i;
1837 ncell_first = ncell_next;
1838 }
1839 else if ( !c31_bc )
1840 {
1841 if( c31_nc)
1842 {
1843 c31_bc = c31_nc;
1844 max_result = i;
1845 ncell_first = ncell_next;
1846 }
1847 else if ( rr_data->nc_data[i].c32 > rr_data->nc_data[max_result].c32 )
1848 {
1849 /* no prioritized cell found yet */
1850 max_result = i;
1851 ncell_first = ncell_next;
1852 }
1853 }
1854 }
1855 }
1856
1857 /* compare with Serving cell */
1858 scell_ptr = &( rr_data->nc_data[SC_INDEX].cr_par);
1859 c31_sc = ( (rr_data->nc_data[SC_INDEX].c31 >= 0 ) AND
1860 (scell_ptr->priority_class NEQ GPRS_PRIORITY_CLASS_INVALID));
1861 TRACE_EVENT_P2("c31_sc=%d and c31_bc=%d",c31_sc, c31_bc);
1862 if(
1863 (
1864 c31_sc AND
1865 c31_bc AND
1866 (ncell_first->priority_class EQ scell_ptr->priority_class) AND
1867 (rr_data->nc_data[max_result].c32 > rr_data->nc_data[SC_INDEX].c32)
1868 )
1869 OR
1870 (
1871 c31_sc AND
1872 c31_bc AND
1873 (ncell_first->priority_class > scell_ptr->priority_class)
1874 )
1875 OR
1876 ( c31_bc AND !c31_sc )
1877 OR
1878 (
1879 !c31_bc AND
1880 !c31_sc AND
1881 (rr_data->nc_data[max_result].c32 > rr_data->nc_data[SC_INDEX].c32)
1882 )
1883 )
1884 {
1885 result = max_result;
1886 }
1887 else
1888 {
1889 result = NO_AVAILABLE;
1890 }
1891 }
1892
1893 /*
1894 * return the index of the highest C2.
1895 */
1896 return result;
1897 }
1898
1899
1900 /*
1901 +--------------------------------------------------------------------+
1902 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1903 | STATE : code ROUTINE : att_check_c31_reselect_decision|
1904 +--------------------------------------------------------------------+
1905
1906 PURPOSE :
1907
1908 */
1909
1910 GLOBAL void att_check_c31_reselect_decision (UBYTE start_now)
1911 {
1912 GET_INSTANCE_DATA;
1913 UBYTE index;
1914 UBYTE delta = 1;
1915 TRACE_FUNCTION("att_check_c31_reselect_decision()");
1916 index = att_get_next_best_c32_index(TRUE);
1917 while( index NEQ NO_AVAILABLE )
1918 {
1919 /* found a suitable cell to reselect */
1920 TRACE_EVENT_P1("found a cell %d", index);
1921 /*
1922 * Check cell barred status before going
1923 * into Cell Reselection state.
1924 * This will actually also be checked again
1925 * in att_check_cell but the CRH value will
1926 * not be used for subsequent ncells leading
1927 * to false CR's. We check it here
1928 * to use CRH for the next cell if needed.
1929 */
1930 /* Implements RR Clone findings #8 */
1931 if(att_cell_barred_status_cr_no_cr( index))
1932 delta =0;
1933
1934 /*
1935 * Do not trigger a cell reselection decision on meas. report
1936 * receipt if the cell belong to a LA not allowed for roaming.
1937 * According to 3.22 chapter 3.5.4 cell reselection on a
1938 * forbidden LA for regional provision of service is allowed.
1939 */
1940 if (rr_data->ms_data.rr_service EQ FULL_SERVICE)
1941 {
1942 if (!dat_roam_forb_lai_check(index))
1943 delta = 0;
1944 #if defined(_SIMULATION_)
1945 TRACE_EVENT_WIN_P1 ("delta=%d", delta);
1946 #endif
1947 }
1948
1949 if (delta > 0)
1950 {
1951 if (start_now)
1952 {
1953 att_start_cell_reselection_gprs(CELL_RESELECTION_NC);
1954 }
1955 return;
1956 }
1957 rr_data->nc_data[index].c32_used = TRUE;
1958 index = att_get_next_best_c32_index(TRUE);
1959 }
1960 TRACE_EVENT(" index == NO_AVAILABLE in function att_check_c31_reselect_decision");
1961
1962
1963 }
1964
1965
1966 /*
1967 +--------------------------------------------------------------------+
1968 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
1969 | STATE : code ROUTINE : att_check_cell_c31 |
1970 +--------------------------------------------------------------------+
1971
1972 PURPOSE : if a cell reselection decision has been taken based on C31
1973 and C32 criterion , this function looks for a candidate for cell
1974 reselection taking in account several requirements.
1975 The reselect_index stores the index of the RR storage area
1976 for the neighbourcell. The return value indicates whether a
1977 cell has been found or not.
1978 */
1979
1980
1981 GLOBAL BOOL att_check_cell_c31 (void)
1982 {
1983 GET_INSTANCE_DATA;
1984 BOOL cell_ok = FALSE;
1985
1986 TRACE_FUNCTION ("att_check_cell_c31()");
1987
1988 /*
1989 * while no suitable candidate has been found,
1990 * but still possible cells available.
1991 */
1992 while (rr_data->reselect_index NEQ NO_AVAILABLE AND ! cell_ok)
1993 {
1994 /*
1995 * calculate the cell reselection criterion C31 and C32 for the candidate
1996 */
1997 //att_calculate_c31_c32(rr_data->reselect_index);
1998 /*
1999 * attempting reselection. Mark used
2000 */
2001 rr_data->nc_data[rr_data->reselect_index].c32_used = TRUE;
2002
2003 /*
2004 * Cell should not be barred.
2005 * If GPRS cell reselection parameters are received, look for CELL_BAR_ACCESS_2
2006 * else SI3 RACH parameters would indicate cell barred
2007 */
2008 if( rr_data->nc_data[rr_data->reselect_index].v_cr_par EQ CR_PAR_VALID)
2009 {
2010 TRACE_EVENT_P2("Cell Barred arfcn = %d, barred = %d",
2011 rr_data->nc_data[rr_data->reselect_index].arfcn,
2012 rr_data->nc_data[rr_data->reselect_index].cr_par.cell_bar_access_2 );
2013 cell_ok = (rr_data->nc_data[rr_data->reselect_index].cr_par.cell_bar_access_2
2014 EQ CBA_2_NORMAL) ? TRUE : FALSE;
2015 }
2016 else
2017 {
2018 /* Implements RR Clone findings #8 */
2019 cell_ok = !att_cell_barred_status_cr_no_cr (rr_data->reselect_index);
2020 }
2021 /*
2022 * 1. the cell shall be not temporarily excluded (tnnn e.g. after random access
2023 * failure).
2024 * 2. C31-C32 parameters are still valid
2025 */
2026 if( cell_ok )
2027 cell_ok = ( ! is_tnnn (rr_data->reselect_index) AND
2028 att_check_c31_criterion(rr_data->reselect_index) );
2029
2030 if ((cell_ok) AND (rr_data->ms_data.rr_service EQ FULL_SERVICE))
2031 {
2032 if(rr_data->nc_data[rr_data->reselect_index].v_cr_par EQ CR_PAR_VALID)
2033 {
2034 cell_ok = (rr_data->nc_data[rr_data->reselect_index].cr_par.exc_acc
2035 EQ EXC_ACC_NORMAL) ? TRUE : FALSE;
2036 }
2037 else
2038 cell_ok = dat_roam_forb_lai_check (rr_data->reselect_index);
2039 }
2040
2041 if (cell_ok)
2042 {
2043 /*
2044 * suitable cell has been found
2045 */
2046 TRACE_EVENT ("use neighbour cell");
2047
2048 /*
2049 * configure layer 1 for cell reselection
2050 */
2051 TRACE_EVENT_P2 ("config L1 for CR [%d]->[%d]",
2052 rr_data->nc_data[SC_INDEX].arfcn,
2053 rr_data->nc_data[rr_data->reselect_index].arfcn);
2054
2055 rr_data->gprs_data.ready_state = FALSE; /* Standby */
2056
2057 att_start_cr_in_pl(rr_data->reselect_index);
2058 }
2059 else
2060 {
2061 /*
2062 * cell is not suitable. Look for another cell.
2063 */
2064 rr_data->reselect_index =
2065 att_get_next_best_c32_index(TRUE);
2066 }
2067 }
2068
2069 /*
2070 * return whether a cell has been found or not.
2071 */
2072 return cell_ok;
2073 }
2074
2075 /*
2076 +--------------------------------------------------------------------+
2077 | PROJECT : GSM-PS (6147) MODULE : RR_ATT |
2078 | STATE : code ROUTINE : att_check_c31_criterion |
2079 +--------------------------------------------------------------------+
2080
2081 PURPOSE : returns TRUE if C31 and C32 criterion of cell reselection is still valid.
2082
2083 */
2084 GLOBAL BOOL att_check_c31_criterion(UBYTE index)
2085 {
2086 GET_INSTANCE_DATA;
2087 T_cr_par *ncell_ptr, *scell_ptr;
2088 BOOL c31_bc, c31_sc;
2089
2090 att_calculate_c31_c32(index);
2091
2092 ncell_ptr = & rr_data->nc_data[index].cr_par;
2093 scell_ptr = & rr_data->nc_data[SC_INDEX].cr_par;
2094
2095 c31_bc = ((rr_data->nc_data[index].c31 >= 0) AND
2096 (ncell_ptr->priority_class NEQ GPRS_PRIORITY_CLASS_INVALID ));
2097 c31_sc = ( (rr_data->nc_data[SC_INDEX].c31 >= 0 ) AND
2098 (scell_ptr->priority_class NEQ GPRS_PRIORITY_CLASS_INVALID));
2099 /*
2100 * check for C32 values, depending on priority
2101 */
2102
2103 if(
2104 (
2105 c31_sc AND
2106 c31_bc AND
2107 (ncell_ptr->priority_class > scell_ptr->priority_class)
2108 )
2109 OR
2110 (
2111 c31_sc AND
2112 c31_bc AND
2113 (ncell_ptr->priority_class EQ scell_ptr->priority_class) AND
2114 (rr_data->nc_data[index].c32 > rr_data->nc_data[SC_INDEX].c32)
2115 )
2116 OR
2117
2118 (
2119 c31_bc AND (!c31_sc)
2120 )
2121 OR
2122 (
2123 (!c31_sc) AND
2124 (!c31_bc) AND
2125 (rr_data->nc_data[index].c32 > rr_data->nc_data[SC_INDEX].c32)
2126 )
2127 )
2128 {
2129 return TRUE;
2130 }
2131 return FALSE;
2132 }
2133
2134 /*
2135 +-----------------------------------------------------------------------------+
2136 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
2137 | STATE : code ROUTINE : att_rrgrr_update_ba_req |
2138 +-----------------------------------------------------------------------------+
2139
2140 PURPOSE :
2141
2142 */
2143 void att_rrgrr_update_ba_req(T_RRGRR_UPDATE_BA_REQ* ba_req)
2144 {
2145 GET_INSTANCE_DATA;
2146 UBYTE i;
2147 T_LIST new_list;
2148 T_CELL_DATA * cd;
2149
2150 TRACE_EVENT ("update_ba");
2151 switch(GET_STATE(STATE_GPRS))
2152 {
2153 case GPRS_PIM_BCCH:
2154 case GPRS_PTM_BCCH:
2155 case GPRS_PIM_PBCCH:
2156 case GPRS_PAM_PBCCH:
2157 case GPRS_PTM_PBCCH:
2158 #if 0
2159 if (ba_req->cell_type EQ SYNC_SCELL)
2160 #endif
2161 cd = &rr_data->sc_data.cd;
2162 #if 0 /* this is not used anymore but it still in the SAp for some time */
2163 else
2164 cd = &rr_data->cr_data.cd;
2165 #endif
2166
2167 if(!rr_data->gprs_data.ba_bcch_modified)
2168 srv_copy_list (&rr_data->ba_ncell_list, &cd->ncell_list, sizeof (T_LIST));
2169
2170
2171 /* store GPRS cell reselection parameters */
2172 memcpy(rr_data->gprs_data.add_freq_lists, ba_req->add_freq_list,
2173 sizeof(T_add_freq_list) * RRGRR_BA_LIST_SIZE );
2174
2175 srv_copy_list (&new_list, &rr_data->ba_ncell_list, sizeof (T_LIST));
2176
2177
2178 if( ba_req->add_freq_list[0].arfcn NEQ NOT_PRESENT_16BIT )
2179 rr_data->gprs_data.use_c31 = FALSE;
2180
2181 for(i=0;
2182 i<RRGRR_BA_LIST_SIZE AND ba_req->add_freq_list[i].arfcn NEQ NOT_PRESENT_16BIT;
2183 i++)
2184 {
2185 /*add*/
2186 srv_set_channel (&new_list, ba_req->add_freq_list[i].arfcn);
2187
2188 if((ba_req->add_freq_list[i].v_cr_par) AND ( ba_req->cell_type EQ SYNC_SCELL))
2189 {
2190 rr_data->gprs_data.use_c31 = TRUE;
2191 TRACE_EVENT("use_c31 turned TRUE");
2192 }
2193 }
2194
2195 if( rr_data->gprs_data.use_c31)
2196 {
2197 rr_data->gprs_data.num_add_freq_list = i;
2198 TRACE_EVENT_P1("number of added arfcn = %d", i);
2199 att_init_cr_c31_data();
2200 att_init_nc_data_c31_cr_par();
2201 }
2202 else
2203 {
2204 rr_data->gprs_data.num_add_freq_list = 0;
2205 }
2206
2207 for(i=0;
2208 i<RRGRR_BA_LIST_SIZE AND ba_req->rm_freq_list[i].arfcn NEQ NOT_PRESENT_16BIT;
2209 i++)
2210 {
2211 /*remove*/
2212 srv_unset_channel(&new_list, ba_req->rm_freq_list[i].arfcn);
2213 }
2214
2215 /*
2216 * The NC2 indication in the Packet Measurement Order
2217 * overrides the setting in the SI13
2218 */
2219 rr_data->gprs_data.nc_mode_of_pmo = ba_req->nc_mode;
2220 rr_data->gprs_data.ba_bcch_modified=TRUE;
2221
2222 if (srv_compare_list (&cd->ncell_list, &new_list) EQ FALSE)
2223 {
2224 /* both lists are different or it is the first one */
2225 srv_copy_list (&cd->ncell_list,
2226 &new_list,
2227 sizeof (T_LIST));
2228
2229 /* forward new neighbour cell list to layer 1 if
2230 * changes shall be indicated
2231 */
2232 if (ba_req->cell_type EQ SYNC_SCELL)
2233 {
2234 att_remove_bad_rr_data_ncells();
2235 att_code_mph_ncell_req (SC_INDEX);
2236 #if defined (REL99) AND defined (TI_PS_FF_EMR)
2237 /*BA(BCCH) is modified by GRR, this list now loses the
2238 indices' sync that it has with NW, so can no longer use it
2239 when moved to dedicated mode, for reporting*/
2240 rr_data->sc_data.ba_list_idle = FALSE;
2241 rr_data->sc_data.enh_para_status = ENH_PARA_INVALID_STATE;
2242 for_set_default_emr_data(&rr_data->sc_data.emr_data_current);
2243 for_set_default_emr_data(&rr_data->sc_data.emr_data_temp);
2244 #endif
2245 }
2246 }
2247 break;
2248 default:
2249 break;
2250 }
2251 PFREE(ba_req);
2252 }
2253
2254 /*
2255 +-----------------------------------------------------------------------------+
2256 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
2257 | STATE : code ROUTINE : att_rrgrr_meas_rep_req |
2258 +-----------------------------------------------------------------------------+
2259
2260 PURPOSE :
2261
2262 */
2263
2264 void att_rrgrr_meas_rep_req (T_RRGRR_MEAS_REP_REQ* rrgrr_meas_rep_req)
2265 {
2266 PALLOC(mph_meas_rep_req,MPH_MEAS_REP_REQ);
2267 TRACE_FUNCTION("rrgrr_meas_rep_req()");
2268 mph_meas_rep_req->cause = rrgrr_meas_rep_req->meas_cause;
2269 PFREE(rrgrr_meas_rep_req);
2270 PSENDX(PL,mph_meas_rep_req);
2271 }
2272
2273 /*
2274 +-----------------------------------------------------------------------------+
2275 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
2276 | STATE : code ROUTINE : att_check_sync_results |
2277 +-----------------------------------------------------------------------------+
2278
2279 PURPOSE :
2280
2281 */
2282 BOOL att_check_sync_results(T_MPH_MEASUREMENT_IND* mph_measurement_ind)
2283 {
2284 UBYTE i=0;
2285 T_NC_DATA* pnc = NULL;
2286
2287 if(mph_measurement_ind->gprs_sync EQ SYNC_RESULTS)
2288 {
2289 PALLOC(bsic_ind, RRGRR_NCELL_SYNC_IND);
2290 TRACE_EVENT ("check_sync_res:TRUE");
2291
2292 for(; i < mph_measurement_ind->ncells.no_of_ncells ;i++)
2293 {
2294 bsic_ind->sync_result[i].arfcn = mph_measurement_ind->ncells.arfcn[i];
2295
2296 if(mph_measurement_ind->ncells.bsic[i] EQ NOT_PRESENT_8BIT OR
2297 mph_measurement_ind->ncells.bsic[i] EQ MPH_BSIC_UNKNOWN)
2298 {
2299 if((pnc = is_nc_in_list(mph_measurement_ind->ncells.arfcn[i]))
2300 NEQ NULL)
2301 {
2302 pnc->arfcn = NOT_PRESENT_16BIT;
2303 pnc->bcch_status = EMPTY;
2304 }
2305 if(mph_measurement_ind->ncells.bsic[i] EQ NOT_PRESENT_8BIT)
2306 bsic_ind->sync_result[i].sb_flag = NO_SB_FOUND;
2307 else
2308 bsic_ind->sync_result[i].sb_flag = SB_UNKNOWN; /*UNKNOWN*/
2309
2310 }
2311 else
2312 {
2313 /* cell with BSIC */
2314 if( (pnc = is_nc_in_list(mph_measurement_ind->ncells.arfcn[i])) NEQ NULL)
2315 {
2316 /*found -> update if needed */
2317 pnc->bsic = bsic_ind->sync_result[i].bsic =
2318 mph_measurement_ind->ncells.bsic[i];
2319 pnc->bcch_status=NON_DECODED;
2320 }
2321 else
2322 {
2323 /*add*/
2324 pnc = find_empty_slot_in_list();
2325 if(pnc)
2326 {
2327 pnc->bsic = bsic_ind->sync_result[i].bsic =
2328 mph_measurement_ind->ncells.bsic[i];
2329 pnc->arfcn = mph_measurement_ind->ncells.arfcn[i];
2330 pnc->bcch_status=NON_DECODED;
2331 }
2332 }
2333 bsic_ind->sync_result[i].sb_flag = SB_FOUND;
2334 }
2335 }
2336 if(i>0)
2337 {
2338 for(/*dont init i*/; i < RRGRR_MAX_RSLT_NCELL_SYNC_IND; i++)
2339 {
2340 bsic_ind->sync_result[i].arfcn = NOT_PRESENT_16BIT;
2341 }
2342
2343 PSENDX(GRR, bsic_ind);
2344 }
2345 else
2346 {
2347 PFREE(bsic_ind);
2348 }
2349
2350 PFREE(mph_measurement_ind);
2351 return TRUE;
2352 }
2353 return FALSE;
2354 }
2355
2356 /*
2357 +-----------------------------------------------------------------------------+
2358 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
2359 | STATE : code ROUTINE : att_check_bsic |
2360 +-----------------------------------------------------------------------------+
2361
2362 PURPOSE :
2363
2364 */
2365 void att_check_bsic(T_RRGRR_NCELL_SYNC_REQ* check_bsic)
2366 {
2367 GET_INSTANCE_DATA;
2368 #if defined (TI_PS_FF_RTD) AND defined (REL99)
2369 T_rr_enh_para *p_cur = &rr_data->sc_data.emr_data_current;
2370 #endif /* #if defined (TI_PS_FF_RTD) AND defined (REL99) */
2371
2372 TRACE_EVENT ("acq_bsic");
2373
2374 switch(GET_STATE(STATE_GPRS))
2375 {
2376 case GPRS_PIM_PBCCH:
2377 case GPRS_PTM_PBCCH:
2378 case GPRS_PAM_PBCCH:
2379 {
2380 #if defined (TI_PS_FF_RTD) AND defined (REL99)
2381 UBYTE i,j;
2382 #else
2383 UBYTE i;
2384 #endif /* #if defined (TI_PS_FF_RTD) AND defined (REL99) */
2385 PALLOC(ncell_req, MPH_NEIGHBOURCELL_REQ);
2386 if(check_bsic->sync_type EQ SYNC_RECONFIRM)
2387 ncell_req->sync_only = RECONFIRM_SYNC_LIST;
2388 else
2389 ncell_req->sync_only = SYNC_LIST;
2390 memset(ncell_req->arfcn, NOT_PRESENT_8BIT, 2*MAX_NEIGHBOURCELLS);
2391
2392 for(i=0;
2393 i<RRGRR_MAX_ARFCN_NCELL_SYNC_REQ AND
2394 #if defined (TI_PS_FF_RTD) AND defined (REL99)
2395 check_bsic->ncell_sync_list[i].arfcn
2396 #else
2397 check_bsic->arfcn[i]
2398 #endif /* #if defined (TI_PS_FF_RTD) AND defined (REL99) */
2399 NEQ NOT_PRESENT_16BIT; i++)
2400 {
2401 #if defined (TI_PS_FF_RTD) AND defined (REL99)
2402 ncell_req->arfcn[i] = check_bsic->ncell_sync_list[i].arfcn;
2403 #else
2404 ncell_req->arfcn[i] = check_bsic->arfcn[i];
2405 #endif /* #if defined (TI_PS_FF_RTD) AND defined (REL99) */
2406 #if defined (TI_PS_FF_RTD) AND defined (REL99)
2407 for(j = 0;j < check_bsic->ncell_sync_list[i].c_rtd;j++)
2408 p_cur->enh_para.enh_cell_list[i].rtd[j] = check_bsic->ncell_sync_list[i].rtd[j];
2409 p_cur->enh_para.enh_cell_list[i].v_rtd = check_bsic->ncell_sync_list[i].v_rtd;
2410 p_cur->enh_para.enh_cell_list[i].c_rtd = check_bsic->ncell_sync_list[i].c_rtd;
2411 #endif /* #if defined (TI_PS_FF_RTD) AND defined (REL99) */
2412 }
2413 #if defined (TI_PS_FF_RTD) AND defined (REL99)
2414 attf_send_enh_para_to_alr(p_cur->rep_type,&p_cur->enh_para);
2415 #endif /* #if defined (TI_PS_FF_RTD) AND defined (REL99) */
2416
2417 PSENDX(PL, ncell_req);
2418 }
2419 break;
2420 default:
2421 break;
2422 }
2423 PFREE(check_bsic);
2424 }
2425
2426 static T_NC_DATA* is_nc_in_list(USHORT arfcn)
2427 {
2428 GET_INSTANCE_DATA;
2429 T_NC_DATA* p_nc = &rr_data->nc_data[0];
2430 T_NC_DATA* p_nc_l = &rr_data->nc_data[6];
2431 for(; p_nc < p_nc_l;p_nc++)
2432 if(p_nc->arfcn EQ arfcn) return p_nc;
2433 return NULL;
2434 }
2435
2436 static T_NC_DATA* find_empty_slot_in_list(void)
2437 {
2438 GET_INSTANCE_DATA;
2439 T_NC_DATA* p_nc = &rr_data->nc_data[0];
2440 T_NC_DATA* p_nc_l = &rr_data->nc_data[6];
2441 for(; p_nc < p_nc_l;p_nc++)
2442 if(p_nc->bcch_status EQ EMPTY) return p_nc;
2443 return NULL;
2444 }
2445 /*
2446 +-----------------------------------------------------------------------------+
2447 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
2448 | STATE : code ROUTINE : att_is_gprs_avail |
2449 +-----------------------------------------------------------------------------+
2450
2451 PURPOSE :
2452
2453 */
2454 BOOL att_gprs_is_avail(void)
2455 {
2456 GET_INSTANCE_DATA;
2457 if(GET_STATE(STATE_GPRS) NEQ GPRS_NULL)
2458 return TRUE;
2459 else
2460 return FALSE;
2461 }
2462
2463 BOOL att_gprs_cell_has_pbcch(void)
2464 {
2465 GET_INSTANCE_DATA;
2466 UBYTE st = GET_STATE(STATE_GPRS);
2467
2468 switch(st)
2469 {
2470 case GPRS_PIM_PBCCH:
2471 case GPRS_PAM_PBCCH:
2472 case GPRS_PTM_PBCCH:
2473 case GPRS_SUSPENDED_PBCCH:
2474 return TRUE;
2475 default:
2476 return FALSE;
2477 }
2478 }
2479
2480 void att_gprs_stop_pl (void)
2481 {
2482 GET_INSTANCE_DATA;
2483 att_build_classmark_req ();
2484 att_build_idle_req(SC_INDEX, MODE_CONFIG_PL);
2485
2486 #if defined (REL99) AND defined (TI_PS_FF_EMR)
2487 /*reset SI-2quater information and enhanced parameters if present
2488 when PBCCH is present*/
2489 rr_data->sc_data.cd.si2quater_status = SI2QUATER_ABSENT;
2490 rr_data->sc_data.cd.si2quater_pos = 0;
2491 memset (rr_data->sc_data.rep_count, NOT_PRESENT_8BIT, MAX_NEIGHBOURCELLS);
2492 for_set_default_emr_data(&rr_data->sc_data.emr_data_current);
2493 rr_data->sc_data.enh_para_status = ENH_PARA_INVALID_STATE;
2494 rr_data->sc_data.ba_list_ded = rr_data->sc_data.ba_list_idle = FALSE;
2495 #endif
2496
2497 /*
2498 * use neighbour cell list from system info 2/2bis/2ter
2499 */
2500 memset (rr_data->act_ncell_list, 0xFF, 2*MAX_NEIGHBOURCELLS);
2501 srv_create_list (&rr_data->sc_data.cd.ncell_list,
2502 rr_data->act_ncell_list, MAX_NEIGHBOURCELLS, FALSE, 0);
2503 }
2504
2505 /*
2506 +-----------------------------------------------------------------------------+
2507 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
2508 | STATE : code ROUTINE : att_gprs_cr_rsp |
2509 +-----------------------------------------------------------------------------+
2510
2511 PURPOSE :
2512
2513 */
2514 void att_gprs_cr_rsp(T_RRGRR_CR_RSP* cr_rsp)
2515 {
2516 GET_INSTANCE_DATA;
2517 TRACE_FUNCTION("att_gprs_cr_rsp()");
2518 switch(rr_data->gprs_data.start_proc)
2519 {
2520 case START_PROC_ACTIVATE_REQ:
2521 srv_use_stored_prim();
2522 break;
2523 case START_PROC_ENTER_LIMITED:
2524 att_signal_gprs_support();
2525 if(att_gprs_cell_has_pbcch())
2526 {
2527 /*
2528 * RR is now in idle and configures L1 for
2529 * BCCH only
2530 */
2531 SET_STATE(STATE_GPRS, GPRS_PIM_BCCH);
2532 switch(GET_STATE(STATE_ATT))
2533 {
2534 case ATT_IDLE:
2535 case ATT_CON_EST:
2536 att_build_idle_req(SC_INDEX, MODE_SYS_INFO_CHANGE);
2537 break;
2538 default:
2539 break;
2540 }
2541 }
2542 else
2543 {
2544 switch(GET_STATE(STATE_GPRS))
2545 {
2546 case GPRS_PTM_BCCH:
2547 case GPRS_PAM_BCCH:
2548 /*
2549 * Due to the CR_IND GRR has released the TBF so we
2550 * have to correctly enter idle mode
2551 * to respect transition rules
2552 */
2553 rr_data->gprs_data.page_mode = PAG_MODE_DEFAULT;
2554 SET_STATE (STATE_GPRS, GPRS_PIM_BCCH);
2555 att_return_to_idle();
2556 break;
2557 default:
2558 break;
2559 }
2560 }
2561 break;
2562 case START_PROC_NORMAL_CR:
2563 att_start_cell_reselection (rr_data->gprs_data.cr_type);
2564 break;
2565 case START_PROC_NORMAL_CS:
2566 att_start_cell_selection (rr_data->gprs_data.cr_orig, CS_NOT_PARALLEL,
2567 rr_data->cs_data.current_search_mode);
2568 break;
2569 case START_PROC_CFG_CHG: /*XXX not ok*/
2570 att_signal_gprs_support();
2571 break;
2572 case START_PROC_GPRS_ACT:
2573 {
2574 PALLOC ( mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
2575 TRACE_EVENT("START_PROC_GPRS_ACT----- ");
2576
2577 rr_data->sc_data.mm_started = MM_ORIGINATED;
2578
2579 if((rr_data->sc_data.cd.sys_info_read EQ ALL_SYS_INFO_READ) OR
2580 ((rr_data->sc_data.cd.sys_info_read | SYS_INFO_13_READ) EQ ALL_SYS_INFO_READ))
2581 {
2582 rr_data->sc_data.cd.sys_info_read &= ~(SYS_INFO_13_READ);
2583 mph_mon_ctrl_req->si_to_read = UPDATE_SI13;
2584
2585 if( rr_data->nc_data[SC_INDEX].si13_loc_ind EQ NORMAL_BCCH)
2586 {
2587 mph_mon_ctrl_req->action = START_MON_NBCCH;
2588 mph_mon_ctrl_req->si_to_read = UPDATE_SI13_GSM;
2589 }
2590 else
2591 mph_mon_ctrl_req->action = START_MON_EBCCH;
2592 }
2593 else
2594 {
2595 TRACE_EVENT ("START_PROC_GPRS_ACT: Read Complete SI");
2596 rr_data->sc_data.cd.sys_info_read = NO_SYS_INFO_READ;
2597 mph_mon_ctrl_req->si_to_read = COMPLETE_SI;
2598 mph_mon_ctrl_req->action = START_MON_NBCCH;
2599 }
2600
2601 PSENDX (PL, mph_mon_ctrl_req);
2602 TIMERSTART (T_RESELECT, TRESELECT_VALUE);
2603 }
2604 break;
2605 default:
2606 break;
2607 }
2608 rr_data->gprs_data.start_proc = START_PROC_NOTHING;
2609 PFREE(cr_rsp);
2610 }
2611
2612 void att_gprs_sync_req( T_RRGRR_SYNC_REQ *sync_req)
2613 {
2614 GET_INSTANCE_DATA;
2615 switch(GET_STATE(STATE_GPRS))
2616 {
2617 case GPRS_PIM_PBCCH:
2618 case GPRS_PTM_PBCCH:
2619 {
2620 memset (&rr_data->nc_data[CR_INDEX],
2621 0,
2622 sizeof (T_NC_DATA));
2623
2624 rr_data->nc_data[CR_INDEX].arfcn = sync_req->arfcn;
2625 rr_data->nc_data[CR_INDEX].bsic = sync_req->bsic;
2626 att_start_cell_reselection_pbcch(MODE_CELL_RESELECTION_SYNC_ONLY);
2627 }
2628 break;
2629 default:
2630 break;
2631 }
2632 PFREE(sync_req);
2633 }
2634
2635 void att_start_cell_reselection_gprs(UBYTE mode)
2636 {
2637 GET_INSTANCE_DATA;
2638 /*set start proc */
2639 if(att_gprs_is_avail())
2640 {
2641 UBYTE st = GET_STATE(STATE_ATT);
2642 if(st NEQ ATT_CS3 AND
2643 st NEQ ATT_CS2 AND
2644 st NEQ ATT_CS1)
2645 {
2646 att_rrgrr_cr_ind(CR_ABNORMAL);
2647 rr_data->gprs_data.start_proc = START_PROC_NORMAL_CR;
2648 rr_data->gprs_data.cr_type = mode;
2649 return;
2650 }
2651 }
2652 att_start_cell_reselection(mode);
2653 }
2654
2655 void att_start_cell_selection_gprs(UBYTE originator,UBYTE search_mode)
2656 {
2657 GET_INSTANCE_DATA;
2658 /*set start proc*/
2659 if(att_gprs_is_avail())
2660 {
2661 UBYTE st = GET_STATE(STATE_ATT);
2662 if(st NEQ ATT_CS3 AND
2663 st NEQ ATT_CS2 AND
2664 st NEQ ATT_CS1)
2665 {
2666 if(originator EQ MM_ORIGINATED)
2667 {
2668 TRACE_EVENT("start_cs_gprs: MM_ORIG!");
2669 att_rrgrr_cr_ind(CR_NORMAL);
2670 }
2671 else
2672 {
2673 att_rrgrr_cr_ind(CR_ABNORMAL);
2674 EM_FMM_RESEL_START_IND;
2675 }
2676
2677 CS_SET_CURRENT_SEARCH_MODE(search_mode);
2678 rr_data->gprs_data.start_proc = START_PROC_NORMAL_CS;
2679 rr_data->gprs_data.cr_orig = originator;
2680 return;
2681 }
2682 }
2683 att_start_cell_selection(originator, CS_NOT_PARALLEL,search_mode);
2684 }
2685
2686
2687 void att_gprs_idle_req(T_MPH_IDLE_REQ* idle_req)
2688 {
2689 GET_INSTANCE_DATA;
2690 /*
2691 * At this point it is necessary to do the following things:
2692 * o send a CR_IND (optional)
2693 * o set the parameter gprs_support (if needed, the default has already
2694 been set before)
2695 * o set the parameter reorg_only (if needed)
2696 */
2697 switch(idle_req->mod)
2698 {
2699 case MODE_CELL_SELECTION:
2700 if(GET_STATE(STATE_GPRS) EQ GPRS_NULL OR
2701 GET_STATE(STATE_GPRS) EQ GPRS_ACTIVATED)
2702 {
2703 idle_req->gprs_support = MPH_GPRS_PROCS_NOT_USED;
2704 }
2705 else
2706 {
2707 idle_req->gprs_support = MPH_GPRS_PROCS_USED;
2708
2709 if(rr_data->gprs_data.page_mode EQ PAG_MODE_REORG)
2710 idle_req->reorg_only = REORG_ONLY;
2711 else
2712 idle_req->reorg_only = NORMAL_PGM;
2713
2714
2715 }
2716 break;
2717 case MODE_CONFIG_PL:
2718 idle_req->gprs_support = MPH_GPRS_PROCS_USED;
2719 break;
2720 case MODE_SYS_INFO_CHANGE:
2721 if(GET_STATE(STATE_GPRS) EQ GPRS_NULL OR
2722 GET_STATE(STATE_GPRS) EQ GPRS_ACTIVATED OR
2723 rr_data->ms_data.rr_service EQ LIMITED_SERVICE)
2724 {
2725 idle_req->gprs_support = MPH_GPRS_PROCS_NOT_USED;
2726 }
2727 else
2728 {
2729 idle_req->gprs_support = MPH_GPRS_PROCS_USED;
2730 idle_req->reorg_only = NORMAL_PGM;
2731
2732 }
2733 break;
2734 default:
2735 break;
2736 }
2737 }
2738
2739 BOOL att_gprs_check_ncell(void)
2740 {
2741 GET_INSTANCE_DATA;
2742 BOOL cell_ok;
2743 BOOL cell_barred;
2744 BOOL check_nw;
2745 BOOL roam_forb;
2746 BOOL plmn_equal;
2747
2748 TRACE_EVENT_P1 ("att_gprs_check_ncell() cr_pbcch_active=%d",
2749 rr_data->gprs_data.cr_pbcch_active);
2750
2751 if((rr_data->gprs_data.cr_pbcch_active) OR (rr_data->gprs_data.cr_pcco_active))
2752 {
2753
2754 /* Implements RR Clone findings #8 */
2755 cell_barred = !att_cell_barred_status_cr_no_cr (CR_INDEX);
2756
2757 check_nw = att_check_network (&rr_data->nc_data[CR_INDEX].lai);
2758 roam_forb = dat_roam_forb_lai_check (CR_INDEX);
2759 plmn_equal = dat_plmn_equal_req (rr_data->nc_data[CR_INDEX].lai.mcc,
2760 rr_data->nc_data[CR_INDEX].lai.mnc,
2761 rr_data->ms_data.plmn.mcc,
2762 rr_data->ms_data.plmn.mnc);
2763
2764 TRACE_EVENT_P6 ( "r MCC/MNC=%x%x%x/%x%x%x",
2765 rr_data->ms_data.plmn.mcc[0],
2766 rr_data->ms_data.plmn.mcc[1],
2767 rr_data->ms_data.plmn.mcc[2],
2768 rr_data->ms_data.plmn.mnc[0],
2769 rr_data->ms_data.plmn.mnc[1],
2770 rr_data->ms_data.plmn.mnc[2]);
2771 TRACE_EVENT_P6 ( "i MCC/MNC=%x%x%x/%x%x%x",
2772 rr_data->nc_data[CR_INDEX].lai.mcc[0],
2773 rr_data->nc_data[CR_INDEX].lai.mcc[1],
2774 rr_data->nc_data[CR_INDEX].lai.mcc[2],
2775 rr_data->nc_data[CR_INDEX].lai.mnc[0],
2776 rr_data->nc_data[CR_INDEX].lai.mnc[1],
2777 rr_data->nc_data[CR_INDEX].lai.mnc[2]);
2778 TRACE_EVENT_P5 ("[%u] cb %d nw %d ro %d pl %d", rr_data->nc_data[CR_INDEX].arfcn,
2779 cell_barred, check_nw, roam_forb, plmn_equal);
2780
2781 cell_ok = cell_barred AND check_nw AND roam_forb AND plmn_equal;
2782 if (cell_ok)
2783 {
2784 TRACE_EVENT_P2 ("NEW SC [%d]->[%d]",
2785 rr_data->nc_data[SC_INDEX].arfcn,
2786 rr_data->nc_data[CR_INDEX].arfcn);
2787
2788 if(rr_data->ms_data.rr_service EQ LIMITED_SERVICE AND
2789 rr_data->ms_data.req_mm_service NEQ FUNC_LIM_SERV_ST_SRCH)
2790 {
2791 /*
2792 * We are in LIMITED service.
2793 * If the req_mm_service is FUNC_LIM_SERV_ST_SRCH we
2794 * will stay in LIMITED.
2795 * If we are in limited because of forbidden LAI we
2796 * enter FULL SERVICE.
2797 */
2798 rr_data->ms_data.rr_service = FULL_SERVICE;
2799 }
2800
2801 /* TIMERSTOP (T_RESELECT);*/
2802 att_copy_cr_data ();
2803 memcpy (&rr_data->sc_data.cd, &rr_data->cr_data.cd,
2804 sizeof (T_CELL_DATA));
2805 if (rr_data->old_serving_cell < SC_INDEX)
2806 rr_data->nc_data[rr_data->old_serving_cell].avail_time =
2807 PERIOD_700_SEC;
2808 rr_data->nc_data[CR_INDEX].arfcn = NOT_PRESENT_16BIT;
2809
2810 rr_data->gprs_data.cr_pbcch_active = FALSE;
2811 if(GET_STATE(STATE_GPRS) EQ GPRS_PIM_BCCH OR
2812 GET_STATE(STATE_GPRS) EQ GPRS_ACTIVATED)
2813 {
2814 att_set_pl_in_idle_mode ();
2815 }
2816 else if (att_gprs_cell_has_pbcch())
2817 {
2818 att_gprs_stop_pl();
2819 }
2820 att_signal_gprs_support();
2821
2822 /* XXX ???
2823 * set a barrier of 15 seconds for the next cell reselection
2824 * if it was a cell reselection due to C2(NC) > C2(SC)
2825 */
2826 if (rr_data->sc_data.selection_type EQ CELL_RESELECTION_NC)
2827 TIMERSTART (T_NO_RESELECT, THIRTY_SEC/2);
2828 }
2829 else
2830 {
2831 /*
2832 * inform GRR that the currently chosen cell
2833 * not suitable and wait for the next rrgrr_cr_req
2834 */
2835 att_cell_reselection_gprs_failed();
2836 }
2837 return TRUE;
2838 }
2839 else
2840 {
2841 return FALSE;
2842 }
2843
2844 }
2845
2846 void att_cell_reselection_gprs_failed(void)
2847 {
2848 GET_INSTANCE_DATA;
2849 PALLOC_SDU(gprs_ind, RRGRR_GPRS_SI13_IND, MAX_L2_FRAME_SIZE * BITS_PER_BYTE);
2850 gprs_ind->cause = GPRS_CELL_NOT_SUITABLE;
2851 gprs_ind->serving_cell_info.bcch_arfcn = rr_data->nc_data[CR_INDEX].arfcn;
2852 gprs_ind->serving_cell_info.bcch_bsic = rr_data->nc_data[CR_INDEX].bsic;
2853
2854 TRACE_EVENT_P4 ("cs=%u C[%d] bsic=%u #%u",
2855 gprs_ind->cause,
2856 gprs_ind->serving_cell_info.bcch_arfcn,
2857 gprs_ind->serving_cell_info.bcch_bsic,
2858 __LINE__);
2859
2860 SET_STATE(STATE_GPRS, GPRS_PIM_PBCCH);
2861 PSENDX(GRR, gprs_ind);
2862 }
2863
2864 void att_gprs_start_task (T_RRGRR_START_TASK_REQ* start_task)
2865 {
2866 GET_INSTANCE_DATA;
2867 switch(GET_STATE(STATE_GPRS))
2868 {
2869 case GPRS_PIM_PBCCH:
2870 case GPRS_PAM_PBCCH:
2871 case GPRS_PTM_PBCCH:
2872 switch(start_task->state)
2873 {
2874 case TASK_STATE_PTM:
2875 {
2876 PALLOC(mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
2877 mph_mon_ctrl_req->action = ENTER_PTM_PBCCH;
2878 PSENDX (PL, mph_mon_ctrl_req);
2879 SET_STATE(STATE_GPRS, GPRS_PTM_PBCCH);
2880 }
2881 break;
2882 case TASK_STATE_PIM:
2883 {
2884 PALLOC(mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
2885 mph_mon_ctrl_req->action = ENTER_PIM_PBCCH;
2886 PSENDX (PL, mph_mon_ctrl_req);
2887 SET_STATE(STATE_GPRS, GPRS_PIM_PBCCH);
2888 #ifdef REL99
2889 if(rr_data->gprs_data.cbch_info_rxvd_in_ptm)
2890 {
2891 rr_data->gprs_data.cbch_info_rxvd_in_ptm = FALSE;
2892 att_config_cbch();
2893 }
2894 #endif
2895 }
2896 break;
2897 case TASK_STATE_PAM:
2898 {
2899 SET_STATE(STATE_GPRS, GPRS_PAM_PBCCH);
2900 }
2901 break;
2902 default:
2903 break;
2904 }
2905 break;
2906 case GPRS_PIM_BCCH:
2907 case GPRS_PAM_BCCH:
2908 case GPRS_PTM_BCCH:
2909 switch(start_task->state)
2910 {
2911 case TASK_STATE_PTM:
2912 {
2913 PALLOC(mph_mon_ctrl_req, MPH_MON_CTRL_REQ );
2914 mph_mon_ctrl_req->action = ENTER_PTM_BCCH;
2915 PSENDX (PL, mph_mon_ctrl_req);
2916 }
2917 break;
2918 default:
2919 break;
2920 }
2921 break;
2922 default:
2923 break;
2924 }
2925
2926 {
2927 PALLOC(stop_cnf, RRGRR_START_TASK_CNF);
2928 PSENDX(GRR, stop_cnf);
2929 }
2930
2931 PFREE(start_task);
2932 }
2933
2934 void att_start_cell_reselection_pbcch(UBYTE mode)
2935 {
2936 GET_INSTANCE_DATA;
2937 att_init_cell_selection(CELL_RESELECTION, RR_ORIGINATED);
2938 att_init_pl_status ();
2939 rr_data->bcch_error = 0;
2940 rr_data->dyn_config.fcr = 0;
2941 rr_data->dyn_config.scr = 0;
2942 rr_data->bcch_error = 0;
2943 rr_data->pag_rec = FALSE;
2944 srv_clear_stored_prim (MPH_PAGING_IND);
2945 gprs_init_data_cr();
2946 srv_clear_list (&rr_data->cr_data.cd.ncell_list);
2947 dat_att_null();
2948 rr_data->gprs_data.cr_pbcch_active = TRUE;
2949 SET_STATE (STATE_ATT, ATT_CS3);
2950 att_build_idle_req (CR_INDEX, mode);
2951 }
2952
2953 /*
2954 +------------------------------------------------------------------------------
2955 | Function : rr_ext_meas_can_start
2956 +------------------------------------------------------------------------------
2957 | Description : Check if the Ext Meas procedure can be performed.
2958 |
2959 | Parameters : none
2960 |
2961 +------------------------------------------------------------------------------
2962 */
2963 static BOOL rr_ext_meas_can_start ( void )
2964 {
2965 GET_INSTANCE_DATA;
2966 if( GET_STATE(STATE_ATT) EQ ATT_IDLE )
2967 {
2968 if(
2969 (GET_STATE(STATE_GPRS) EQ GPRS_PIM_BCCH)
2970 OR
2971 (GET_STATE ( STATE_GPRS ) EQ GPRS_PIM_PBCCH)
2972 )
2973 return TRUE;
2974 }
2975 return FALSE;
2976 }
2977
2978 /*
2979 +------------------------------------------------------------------------------
2980 | Function : att_rrgrr_ext_meas_req
2981 +------------------------------------------------------------------------------
2982 | Description : Start Extended Measurement (GPRS) at RR.
2983 |
2984 | Parameters : *rrgrr_ext_meas_req - Frequencies to be measured
2985 |
2986 +------------------------------------------------------------------------------
2987 */
2988 GLOBAL void att_rrgrr_ext_meas_req ( T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req )
2989 {
2990 GET_INSTANCE_DATA;
2991 T_GPRS_DATA *gprs_data = &rr_data->gprs_data;
2992 UBYTE i,n;
2993 T_arfcn_idx *s;
2994 USHORT *d;
2995
2996 /* Store the primitive 'rrgrr_ext_meas_req' during the Ext Meas procedure. */
2997
2998 if ( gprs_data->rrgrr_ext_meas_req NEQ NULL AND
2999 gprs_data->rrgrr_ext_meas_req NEQ rrgrr_ext_meas_req )
3000 {
3001 PFREE ( gprs_data->rrgrr_ext_meas_req );
3002 }
3003 gprs_data->rrgrr_ext_meas_req = rrgrr_ext_meas_req;
3004
3005 if ( rr_ext_meas_can_start() )
3006 {
3007 PALLOC ( mph_ext_meas_req, MPH_EXT_MEAS_REQ );
3008
3009 SET_STATE (STATE_CELL_SEL, CS_XMEAS);
3010
3011 n = rrgrr_ext_meas_req->c_arfcn_idx;
3012 if ( n > RRGRR_MAX_ARFCN_EXT_MEAS )
3013 {
3014 n = RRGRR_MAX_ARFCN_EXT_MEAS;
3015 TRACE_ERROR ( "cut freq list (in)" );
3016 }
3017 if ( n > MAX_CHANNELS )
3018 {
3019 n = MAX_CHANNELS;
3020 TRACE_ERROR ( "cut freq list (out)" );
3021 }
3022
3023 mph_ext_meas_req->num_of_chan = n;
3024 d = &mph_ext_meas_req->arfcn[0];
3025 s = &rrgrr_ext_meas_req->arfcn_idx[0];
3026
3027 for ( i = 0; i < n; ++i, ++s, ++d )
3028 *d = s->arfcn;
3029
3030 /* Other elements of mph_ext_meas_req remain uninitialized here (set in ALR). */
3031 mph_ext_meas_req->freq_bands = cs_get_freq_band(FALSE);
3032 gprs_data->ext_meas_ctrl = 0;
3033 PSENDX (PL, mph_ext_meas_req);
3034 }
3035 else
3036 {
3037 PALLOC ( rrgrr_ext_meas_cnf, RRGRR_EXT_MEAS_CNF );
3038 rrgrr_ext_meas_cnf->c_xmeas_res = 0;
3039 rrgrr_ext_meas_cnf->xmeas_cause = EXT_MEAS_RESET;
3040 rrgrr_ext_meas_cnf->call_ref = rrgrr_ext_meas_req->call_ref;
3041 PSENDX ( GRR, rrgrr_ext_meas_cnf );
3042 PFREE ( rrgrr_ext_meas_req );
3043 gprs_data->rrgrr_ext_meas_req = NULL;
3044 }
3045 return;
3046 }
3047
3048 /*
3049 +------------------------------------------------------------------------------
3050 | Function : rr_ext_meas_idx
3051 +------------------------------------------------------------------------------
3052 | Description : Retrieve InDeX associated to ARFCN during
3053 | Extended Measurement (GPRS).
3054 |
3055 | Parameters : ARFCN - channel number in 'rrgrr_ext_meas_req'
3056 |
3057 +------------------------------------------------------------------------------
3058 */
3059 GLOBAL UBYTE rr_ext_meas_idx (USHORT arfcn )
3060 {
3061 GET_INSTANCE_DATA;
3062 UBYTE i,n;
3063 T_arfcn_idx *arfcn_idx;
3064 T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req;
3065
3066 rrgrr_ext_meas_req = rr_data->gprs_data.rrgrr_ext_meas_req;
3067 if ( rrgrr_ext_meas_req EQ NULL )
3068 {
3069 return NOT_PRESENT_8BIT;
3070 }
3071
3072 n = rrgrr_ext_meas_req->c_arfcn_idx;
3073 arfcn_idx = &rrgrr_ext_meas_req->arfcn_idx[0];
3074 for ( i = 0; i < n; ++i, ++arfcn_idx )
3075 {
3076 if ( arfcn_idx->arfcn EQ arfcn )
3077 return arfcn_idx->idx;
3078 }
3079
3080 return NOT_PRESENT_8BIT;
3081 }
3082
3083 /*
3084 +------------------------------------------------------------------------------
3085 | Function : rr_ext_meas_end
3086 +------------------------------------------------------------------------------
3087 | Description : Deallocate memory used during Extended Measurement (GPRS).
3088 | This function is called in three scenarios:
3089 | (1) System start (pei_init)
3090 | (2) Cell Change triggered via gprs_init_gprs_data
3091 | (3) End of Extended Measurement procedure
3092 |
3093 | Parameters : none
3094 |
3095 +------------------------------------------------------------------------------
3096 */
3097 GLOBAL void att_ext_meas_end ( BOOL destory_rrgrr_ext_meas_cnf )
3098 {
3099 GET_INSTANCE_DATA;
3100 /* Note : If att_ext_meas_end is called via gprs_init_gprs_data and
3101 * Ext Meas is running, then a repsonse from Lower Layers is still
3102 * to be expected, which will be ignored. */
3103
3104 T_GPRS_DATA *gprs_data = &rr_data->gprs_data;
3105
3106 if ( gprs_data->rrgrr_ext_meas_req NEQ NULL )
3107 {
3108 PFREE ( gprs_data->rrgrr_ext_meas_req );
3109 gprs_data->rrgrr_ext_meas_req = NULL;
3110 }
3111
3112 if ( gprs_data->rrgrr_ext_meas_cnf NEQ NULL )
3113 {
3114 if ( destory_rrgrr_ext_meas_cnf )
3115 {
3116 PFREE ( gprs_data->rrgrr_ext_meas_cnf );
3117 }
3118 gprs_data->rrgrr_ext_meas_cnf = NULL;
3119 }
3120
3121 if ( gprs_data->mph_ext_meas_cnf NEQ NULL )
3122 {
3123 PFREE ( gprs_data->mph_ext_meas_cnf );
3124 gprs_data->mph_ext_meas_cnf = NULL;
3125 }
3126
3127 if ( (gprs_data->ext_meas_ctrl & EXT_MEAS_START_CR) NEQ 0 )
3128 {
3129 /* handle the outstanding Cell Reselection request */
3130 gprs_data->ext_meas_ctrl &= ~EXT_MEAS_START_CR;
3131 att_start_cell_reselection(rr_data->sc_data.selection_type);
3132 }
3133
3134 gprs_data->ext_meas_ctrl = 0;
3135 }
3136
3137 /*
3138 +------------------------------------------------------------------------------
3139 | Function : att_ext_meas_next_bsic
3140 +------------------------------------------------------------------------------
3141 | Description : Check for next BSIC scanning during Extended Measurement.
3142 | If all BSICs are scanned, then a response is sent to GRR.
3143 |
3144 | Parameters : none
3145 |
3146 +------------------------------------------------------------------------------
3147 */
3148 GLOBAL void att_ext_meas_next_bsic (void)
3149 {
3150 GET_INSTANCE_DATA;
3151 T_GPRS_DATA *gprs_data = &rr_data->gprs_data;
3152 T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req = gprs_data->rrgrr_ext_meas_req;
3153 T_RRGRR_EXT_MEAS_CNF *rrgrr_ext_meas_cnf = gprs_data->rrgrr_ext_meas_cnf;
3154 T_MPH_EXT_MEAS_CNF *mph_ext_meas_cnf = gprs_data->mph_ext_meas_cnf;
3155 UBYTE n = gprs_data->mph_ext_meas_num;
3156 UBYTE stop = gprs_data->ext_meas_ctrl & EXT_MEAS_RESET;
3157
3158 if ( (rrgrr_ext_meas_req->report_type EQ REP_TYPE_1 OR
3159 rrgrr_ext_meas_req->report_type EQ REP_TYPE_2 ) AND
3160 rrgrr_ext_meas_cnf->c_xmeas_res >= 6 OR
3161 rrgrr_ext_meas_cnf->c_xmeas_res >= RRGRR_MAX_ARFCN_EXT_MEAS OR
3162 n >= mph_ext_meas_cnf->num_of_chan OR
3163 stop )
3164 {
3165 /* stop PLMN search at lower layers */
3166
3167 PALLOC (mph_sync_req, MPH_SYNC_REQ);
3168 mph_sync_req->cs = CS_STOP_PLMN_SEARCH;
3169 PSENDX (PL, mph_sync_req);
3170 }
3171 else
3172 {
3173 PALLOC ( mph_bsic_req, MPH_BSIC_REQ );
3174 mph_bsic_req->arfcn = mph_ext_meas_cnf->arfcn[n];
3175 PSENDX ( PL, mph_bsic_req );
3176 }
3177 }
3178
3179 /*
3180 +------------------------------------------------------------------------------
3181 | Function : att_mph_ext_meas_cnf
3182 +------------------------------------------------------------------------------
3183 | Description : Evaluate rxlev during Start Extended Measurement (GPRS).
3184 |
3185 | Parameters : *mph_ext_meas_cnf - ARFCNs and RXLEVs from MPH
3186 |
3187 +------------------------------------------------------------------------------
3188 */
3189 GLOBAL void att_mph_ext_meas_cnf ( T_MPH_EXT_MEAS_CNF *mph_ext_meas_cnf )
3190 {
3191 GET_INSTANCE_DATA;
3192 T_GPRS_DATA *gprs_data = &rr_data->gprs_data;
3193 T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req = gprs_data->rrgrr_ext_meas_req;
3194
3195 /* Check that Ext Meas is still active at RR */
3196
3197 if ( rrgrr_ext_meas_req NEQ NULL )
3198 {
3199 PALLOC ( rrgrr_ext_meas_cnf, RRGRR_EXT_MEAS_CNF );
3200 gprs_data->rrgrr_ext_meas_cnf = rrgrr_ext_meas_cnf;
3201
3202 /* Depending on the Reporting Type either obtain BSICs or respond immediately. */
3203
3204 if ( rrgrr_ext_meas_req->report_type EQ REP_TYPE_1 OR
3205 rrgrr_ext_meas_req->report_type EQ REP_TYPE_2 )
3206 {
3207 /* allocate RRGRR_EXT_MEAS_CNF, save mph_ext_meas_cnf and send initial BSIC_REQ */
3208
3209 rrgrr_ext_meas_cnf->c_xmeas_res = 0;
3210
3211 gprs_data->mph_ext_meas_cnf = mph_ext_meas_cnf;
3212 gprs_data->mph_ext_meas_num = 0;
3213
3214 att_ext_meas_next_bsic();
3215 }
3216 else
3217 {
3218 /* With REP_TYPE_3 no BSIC scanning is needed, RRGRR_EXT_MEAS_CNF is sent. */
3219 /* Note: the premature end of the Ext Meas procedure could have been requested, */
3220 /* but this 'normal' procedure end is performed instead (now). */
3221
3222 UBYTE i,n;
3223 T_xmeas_res *xmeas_res;
3224 PALLOC (mph_sync_req, MPH_SYNC_REQ);
3225
3226 n = mph_ext_meas_cnf->num_of_chan;
3227 if ( n > RRGRR_MAX_ARFCN_EXT_MEAS )
3228 {
3229 n = RRGRR_MAX_ARFCN_EXT_MEAS;
3230 TRACE_ERROR ( "cut freq list (meas_cnf)" );
3231 }
3232
3233 rrgrr_ext_meas_cnf->c_xmeas_res = n;
3234
3235 xmeas_res = &rrgrr_ext_meas_cnf->xmeas_res[0];
3236 for ( i = 0; i < n; ++i, ++xmeas_res )
3237 {
3238 USHORT arfcn = mph_ext_meas_cnf->arfcn[i] & ARFCN_MASK;
3239 UBYTE idx = rr_ext_meas_idx ( arfcn );
3240
3241 xmeas_res->arfcn_idx.arfcn = arfcn;
3242 xmeas_res->arfcn_idx.idx = idx;
3243 xmeas_res->rxlev = mph_ext_meas_cnf->rx_lev[i];
3244 xmeas_res->bsic = 0;
3245 }
3246 PFREE(mph_ext_meas_cnf);
3247 mph_sync_req->cs = CS_STOP_PLMN_SEARCH;
3248 PSENDX (PL, mph_sync_req);
3249 }
3250 }
3251 else
3252 {
3253 PFREE(mph_ext_meas_cnf);
3254 }
3255 return;
3256 }
3257
3258 /*
3259 +------------------------------------------------------------------------------
3260 | Function : att_rrgrr_ext_meas_stop_req
3261 +------------------------------------------------------------------------------
3262 | Description : Premature stop of Extended Measurement (GPRS).
3263 |
3264 | Parameters : *rrgrr_ext_meas_stop_req - Signal.
3265 |
3266 +------------------------------------------------------------------------------
3267 */
3268 GLOBAL void att_rrgrr_ext_meas_stop_req ( T_RRGRR_EXT_MEAS_STOP_REQ *rrgrr_ext_meas_stop_req)
3269 {
3270 GET_INSTANCE_DATA;
3271 T_GPRS_DATA *gprs_data = &rr_data->gprs_data;
3272 T_RRGRR_EXT_MEAS_REQ *rrgrr_ext_meas_req = gprs_data->rrgrr_ext_meas_req;
3273
3274 if (rrgrr_ext_meas_stop_req)
3275 PFREE ( rrgrr_ext_meas_stop_req );
3276
3277 if ( rrgrr_ext_meas_req EQ NULL )
3278 return;
3279
3280 gprs_data->ext_meas_ctrl |= EXT_MEAS_RESET;
3281
3282 /* Continue the stop of the Ext Meas procedure with the next response from Lower Layers. */
3283 }
3284
3285 /*
3286 +------------------------------------------------------------------------------
3287 | Function : att_rrgrr_standby_ind
3288 +------------------------------------------------------------------------------
3289 | Description : Store information that MS is in Standby State.
3290 |
3291 | Parameters : T_RRGRR_STANDBY_STATE_IND
3292 |
3293 +------------------------------------------------------------------------------
3294 */
3295 void att_rrgrr_standby_ind(T_RRGRR_STANDBY_STATE_IND* stdby)
3296 {
3297 GET_INSTANCE_DATA;
3298 rr_data->gprs_data.ready_state = FALSE;
3299 PFREE(stdby);
3300 }
3301
3302 /*
3303 +------------------------------------------------------------------------------
3304 | Function : att_rrgrr_ready_ind
3305 +------------------------------------------------------------------------------
3306 | Description : Store information that MS is in Ready State.
3307 |
3308 | Parameters : T_RRGRR_READY_STATE_IND
3309 |
3310 +------------------------------------------------------------------------------
3311 */
3312 void att_rrgrr_ready_ind(T_RRGRR_READY_STATE_IND* rdy)
3313 {
3314 GET_INSTANCE_DATA;
3315 rr_data->gprs_data.ready_state = TRUE;
3316 PFREE(rdy);
3317 }
3318
3319 #ifdef REL99
3320 /*
3321 +------------------------------------------------------------------------------
3322 | Function : att_rrgrr_cbch_info_ind
3323 +------------------------------------------------------------------------------
3324 | Description : Stores the CBCH configuration received from GRR.
3325 | This information corresponds to the cbch channel
3326 | description received on PBCCH.
3327 | This primitive upates RR with latest CBCH information
3328 | whenever new PSI8, PSI2 or PSI13 is received by GRR
3329 | in PIM or PTM. This primitive should not come when
3330 | the mobile has camped on a R97/98 network.
3331 |
3332 | Parameters : cbch_inf points to RRGRR_CBCH_INFO_IND primitive.
3333 |
3334 +------------------------------------------------------------------------------
3335 */
3336 void att_rrgrr_cbch_info_ind(T_RRGRR_CBCH_INFO_IND* cbch_inf)
3337 {
3338 GET_INSTANCE_DATA;
3339 /* we should now be in R-99 network and in a cell having
3340 * pbcch. Otherwise this message should not be received.
3341 */
3342 TRACE_FUNCTION("att_rrgrr_cbch_info_ind");
3343 if(att_gprs_get_nw_release() AND att_gprs_cell_has_pbcch())
3344 {
3345 /* Store the CBCH configuration in serving cell context */
3346 TRACE_EVENT("CBCH info on PBCCH received");
3347 rr_data->gprs_data.cbch_psi_valid = TRUE;
3348 memcpy(&(rr_data->gprs_data.cbch_psi8),&(cbch_inf->cbch),sizeof(T_cbch));
3349 if( GET_STATE(STATE_ATT) EQ ATT_IDLE)
3350 {
3351 att_config_cbch();
3352 }
3353 }
3354 else
3355 {
3356 TRACE_ERROR( " CBCH Info received when PBCCH not present or when in R97 cell");
3357
3358 }
3359 PFREE(cbch_inf);
3360 }
3361 #endif
3362
3363 /*
3364 +------------------------------------------------------------------------------
3365 | Function : is_nc2_used
3366 +------------------------------------------------------------------------------
3367 | Description : Check if the cell reselection should be done
3368 | or not.
3369 | Parameters : none
3370 | Return Value: TRUE -> don't do cell reselection
3371 | FALSE -> do cell reselection
3372 +------------------------------------------------------------------------------
3373 */
3374 BOOL is_nc2_used(void)
3375 {
3376 GET_INSTANCE_DATA;
3377 BOOL ret = FALSE;
3378 UBYTE st = GET_STATE(STATE_GPRS);
3379
3380 TRACE_FUNCTION("is_nc2_used()");
3381 if (st EQ GPRS_NULL OR
3382 st EQ GPRS_ACTIVATED)
3383 return ret;
3384 /*
3385 * Check:
3386 * Ready State
3387 * NC mode of PMO
3388 * NC mode of SI13
3389 */
3390 TRACE_EVENT_P3("nc2: rdy: %d, pmo_nc: %d, si13 nc: %d",
3391 rr_data->gprs_data.ready_state,
3392 rr_data->gprs_data.nc_mode_of_pmo,
3393 rr_data->gprs_data.is_nc2_used_in_si13);
3394
3395 if(rr_data->gprs_data.ready_state)
3396 {
3397 /* we are in READY */
3398 if(rr_data->gprs_data.nc_mode_of_pmo NEQ NC_MODE_RESET)
3399 {
3400 if(rr_data->gprs_data.nc_mode_of_pmo EQ NC2_USED)
3401 ret = TRUE;
3402 else
3403 ret = FALSE;
3404 }
3405 else
3406 {
3407 /* use SI13 NC mode */
3408 ret = rr_data->gprs_data.is_nc2_used_in_si13;
3409 }
3410 }
3411 else
3412 {
3413 /* we are in STANDBY */
3414 /* in STANDBY NC mode is not used */
3415 ret = FALSE;
3416 }
3417 return ret;
3418 }
3419
3420 #ifdef REL99
3421 /*
3422 +------------------------------------------------------------------------------
3423 | Function : att_gprs_get_nw_release
3424 +------------------------------------------------------------------------------
3425 | Description : returns the network release received in SI 13
3426 | Parameters : none
3427 | Return Value: RR_GPRS_R97, RR_GPRS_R99 depending on the network
3428 | release.
3429 +------------------------------------------------------------------------------
3430 */
3431 UBYTE att_gprs_get_nw_release(void)
3432 {
3433 GET_INSTANCE_DATA;
3434 return rr_data->gprs_data.nw_release;
3435 }
3436 #endif
3437
3438 /*===========================================================================*/
3439 /* */
3440 /* */
3441 /* L O C A L S */
3442 /* */
3443 /* */
3444 /*===========================================================================*/
3445
3446 /*
3447 +-----------------------------------------------------------------------------+
3448 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
3449 | STATE : code ROUTINE : att_get_scell_info |
3450 +-----------------------------------------------------------------------------+
3451
3452 PURPOSE : fill the serving cell struct
3453
3454 */
3455 static void att_get_scell_info (T_serving_cell_info* sc, UBYTE idx)
3456 {
3457 GET_INSTANCE_DATA;
3458
3459 sc->gprs_ms_txpwr_max_cch = rr_data->nc_data[idx].select_para.ms_txpwr_max_cch;
3460 sc->gprs_rxlev_access_min = rr_data->nc_data[idx].select_para.rxlev_access_min;
3461 sc->bcch_arfcn = rr_data->nc_data[idx].arfcn;
3462 sc->bcch_bsic = rr_data->nc_data[idx].bsic;
3463 sc->ac_class = rr_data->nc_data[idx].rach.ac;
3464 /* air-interface coding */
3465 sc->pwr_offset = (UBYTE)(rr_data->nc_data[idx].c2_par.power_off_ind ?
3466 rr_data->nc_data[idx].c2_par.power_off : 0);
3467
3468 if (!(dat_forb_lai_check (SC_INDEX) AND
3469 dat_roam_forb_lai_check (SC_INDEX)))
3470 sc->limited = 1;
3471 else
3472 sc->limited = (UBYTE)(rr_data->ms_data.rr_service EQ LIMITED_SERVICE);
3473
3474 sc->rr_cell_env.plmn.v_plmn = TRUE;
3475
3476 memcpy (sc->rr_cell_env.plmn.mcc, rr_data->nc_data[idx].lai.mcc, SIZE_MCC);
3477 memcpy (sc->rr_cell_env.plmn.mnc, rr_data->nc_data[idx].lai.mnc, SIZE_MNC);
3478
3479 sc->rr_cell_env.lac = rr_data->nc_data[idx].lai.lac;
3480 sc->rr_cell_env.cid = rr_data->nc_data[idx].cell_id;
3481
3482 sc->bs_pa_mfrms = rr_data->nc_data[idx].control_descr.bs_pa_mfrms;
3483 }
3484
3485 /*
3486 +-----------------------------------------------------------------------------+
3487 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
3488 | STATE : code ROUTINE : att_gprs_store_nc_mode |
3489 +-----------------------------------------------------------------------------+
3490
3491 PURPOSE : store the NC mode of SI13
3492
3493 */
3494 static void att_gprs_store_nc_mode(T_D_SYS_INFO_13* sys_info_13)
3495 {
3496 GET_INSTANCE_DATA;
3497 if( !sys_info_13->si13_rest_oct.si13_info.flag1 AND
3498 sys_info_13->si13_rest_oct.si13_info.nco EQ NCO_NET_RESEL)
3499 {
3500 rr_data->gprs_data.is_nc2_used_in_si13 = TRUE;
3501 }
3502 else
3503 {
3504 rr_data->gprs_data.is_nc2_used_in_si13 = FALSE;
3505 }
3506 }
3507
3508 #ifdef REL99
3509 /*
3510 +-----------------------------------------------------------------------------+
3511 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
3512 | STATE : code ROUTINE : att_gprs_store_nw_release |
3513 +-----------------------------------------------------------------------------+
3514
3515 PURPOSE : stores the network release received in si13
3516
3517 */
3518 static void att_gprs_store_nw_release(T_D_SYS_INFO_13* sys_info_13)
3519 {
3520 GET_INSTANCE_DATA;
3521 if(sys_info_13->si13_rest_oct.v_si13_info)
3522 {
3523 if(sys_info_13->si13_rest_oct.si13_info.v_sgsnr)
3524 {
3525 rr_data->gprs_data.nw_release = RR_GPRS_R99;
3526 }
3527 else
3528 {
3529 rr_data->gprs_data.nw_release = RR_GPRS_R97;
3530 }
3531 }
3532 else
3533 {
3534 rr_data->gprs_data.nw_release = RR_GPRS_R97;
3535 }
3536 }
3537
3538 #ifdef TI_PS_FF_EMR
3539 /*
3540 +-----------------------------------------------------------------------------+
3541 | PROJECT : GSM-GPRS (6147) MODULE : RR_GPRS |
3542 | STATE : code ROUTINE : attg_send_enh_para_to_grr |
3543 +-----------------------------------------------------------------------------+
3544
3545 PURPOSE : To format and send a primitive indicating enhanced measurement parameters
3546 received from SI-2quater.
3547 */
3548 GLOBAL void att_send_enh_para_to_grr(T_rr_enh_para *p_src)
3549 {
3550 PALLOC(p_enh,RRGRR_SI2QUATER_IND);
3551 TRACE_FUNCTION("att_send_enh_para_to_grr");
3552 p_enh->rep_type = p_src->grr_rep_type;
3553 p_enh->enh_para_struct = p_src->enh_para;
3554 p_enh->nc_para_struct = p_src->nc_para;
3555 PSENDX(GRR, p_enh);
3556 return;
3557 }
3558 #endif
3559 #endif
3560
3561 #endif /* GPRS */
3562 #endif /* !RR_GPRS_C */