FreeCalypso > hg > fc-magnetite
comparison src/g23m-gprs/grr/grr_pgs.c @ 183:219afcfc6250
src/g23m-gprs: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Oct 2016 04:24:13 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
182:f02d0a0e1849 | 183:219afcfc6250 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GPRS (8441) | |
4 | Modul : GRR | |
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 implements signal handler functions for service | |
18 | PG of entity GRR. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef GRR_PGS_C | |
23 #define GRR_PGS_C | |
24 #endif | |
25 | |
26 #define ENTITY_GRR | |
27 | |
28 /*==== INCLUDES =============================================================*/ | |
29 | |
30 #include "typedefs.h" /* to get Condat data types */ | |
31 | |
32 #include "vsi.h" /* to get a lot of macros */ | |
33 #include "macdef.h" | |
34 #include "gprs.h" | |
35 #include "gsm.h" /* to get a lot of macros */ | |
36 #include "ccdapi.h" /* to get CCD API */ | |
37 #include "cnf_grr.h" /* to get cnf-definitions */ | |
38 #include "mon_grr.h" /* to get mon-definitions */ | |
39 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
40 #include "message.h" | |
41 #include "grr.h" /* to get the global entity definitions */ | |
42 | |
43 | |
44 #include "grr_ctrls.h" /* */ | |
45 | |
46 #include "grr_f.h" /* to get the global functions */ | |
47 #include "grr_pgf.h" /* */ | |
48 | |
49 | |
50 /*==== CONST ================================================================*/ | |
51 | |
52 /*==== LOCAL VARS ===========================================================*/ | |
53 | |
54 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
55 | |
56 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
57 /* | |
58 +------------------------------------------------------------------------------ | |
59 | Function : sig_ctrl_pg_start | |
60 +------------------------------------------------------------------------------ | |
61 | Description : Handles the internal signal SIG_CTRL_PG_START | |
62 | PG has to manage the paging procedures according to network mode | |
63 | and presence of PBCCH channel | |
64 | Parameters : void | |
65 | | |
66 +------------------------------------------------------------------------------ | |
67 */ | |
68 GLOBAL void sig_ctrl_pg_start ( void ) | |
69 { | |
70 TRACE_ISIG( "sig_ctrl_pg_start" ); | |
71 | |
72 switch( GET_STATE( PG ) ) | |
73 { | |
74 case PG_TRANSFER: | |
75 TRACE_ERROR("SIG_CTRL_PG_START not expected in transfer mode"); | |
76 break; | |
77 case PG_NULL: | |
78 SET_STATE(PG, PG_IDLE); | |
79 | |
80 /*lint -fallthrough*/ | |
81 | |
82 default: | |
83 /* Because of having new cell or new PPCH */ | |
84 psc_db->last_pg_mode = psc_db->network_pg_mode = REORG_PAGING; | |
85 | |
86 pg_handle_idle_mode( NULL_IDLE ); | |
87 break; | |
88 } | |
89 | |
90 } /* sig_ctrl_pg_start() */ | |
91 | |
92 /* | |
93 +------------------------------------------------------------------------------ | |
94 | Function : sig_ctrl_pg_stop | |
95 +------------------------------------------------------------------------------ | |
96 | Description : Handles the internal signal SIG_CTRL_PG_STOP | |
97 | | |
98 | Parameters : void | |
99 | | |
100 +------------------------------------------------------------------------------ | |
101 */ | |
102 GLOBAL void sig_ctrl_pg_stop ( void ) | |
103 { | |
104 TRACE_ISIG( "sig_ctrl_pg_stop" ); | |
105 | |
106 grr_data->pg.packet_mode = PACKET_MODE_NULL; | |
107 SET_STATE(PG,PG_NULL); | |
108 pg_send_stop(); | |
109 psc_db->last_pg_mode = psc_db->network_pg_mode = REORG_PAGING; | |
110 } /* sig_ctrl_pg_stop() */ | |
111 | |
112 | |
113 | |
114 /* | |
115 +------------------------------------------------------------------------------ | |
116 | Function : sig_ctrl_pg_mode_ind | |
117 +------------------------------------------------------------------------------ | |
118 | Description : Handles the internal signal SIG_CTRL_PG_MODE_IND | |
119 This signal indicates whether the MS is in idle, transfer or access mode | |
120 | | |
121 | Parameters : packet_mode | |
122 | | |
123 +------------------------------------------------------------------------------ | |
124 */ | |
125 GLOBAL void sig_ctrl_pg_mode_ind ( T_PACKET_MODE packet_mode) | |
126 { | |
127 T_PACKET_MODE old_packet_mode; | |
128 | |
129 TRACE_ISIG( "sig_ctrl_pg_mode_ind" ); | |
130 | |
131 old_packet_mode = grr_data->pg.packet_mode; | |
132 grr_data->pg.packet_mode = packet_mode; | |
133 | |
134 switch( GET_STATE( PG ) ) | |
135 { | |
136 case PG_IDLE: | |
137 switch( packet_mode ) | |
138 { | |
139 case PACKET_MODE_PTM: | |
140 SET_STATE( PG, PG_TRANSFER ); | |
141 | |
142 pg_handle_transfer_mode( IDLE_PTM ); | |
143 break; | |
144 | |
145 case PACKET_MODE_PAM: | |
146 SET_STATE( PG, PG_ACCESS ); | |
147 | |
148 pg_handle_access_mode( ); | |
149 break; | |
150 | |
151 default: | |
152 break; | |
153 } | |
154 break; | |
155 | |
156 case PG_TRANSFER: | |
157 switch( packet_mode ) | |
158 { | |
159 case PACKET_MODE_PAM: | |
160 SET_STATE( PG, PG_ACCESS ); | |
161 | |
162 pg_handle_access_mode( ); | |
163 break; | |
164 | |
165 case PACKET_MODE_PIM: | |
166 SET_STATE( PG, PG_IDLE ); | |
167 | |
168 pg_handle_non_drx_timers( ); | |
169 pg_handle_idle_mode( PTM_IDLE ); | |
170 break; | |
171 | |
172 case PACKET_MODE_PTM: | |
173 //TODOif( grr_test_mode_active( ) ) | |
174 { | |
175 sig_pg_ctrl_stop_mon_ccch( ); | |
176 } | |
177 break; | |
178 } | |
179 break; | |
180 | |
181 case PG_ACCESS: | |
182 switch( packet_mode ) | |
183 { | |
184 case PACKET_MODE_PAM: | |
185 if( old_packet_mode EQ PACKET_MODE_2P_PTM ) | |
186 { | |
187 TRACE_EVENT( "PACKET_MODE_2P_PTM --> PACKET_MODE_PAM" ); | |
188 | |
189 pg_handle_access_mode( ); | |
190 } | |
191 break; | |
192 | |
193 case PACKET_MODE_2P_PTM: | |
194 /* | |
195 * Do not change the state to PG_TRANSFER because of transition rule | |
196 */ | |
197 TRACE_EVENT( "PACKET_MODE_2P_PTM in PG_ACCESS" ); | |
198 | |
199 pg_handle_transfer_mode( ACCESS_PTM ); | |
200 break; | |
201 | |
202 case PACKET_MODE_PIM: | |
203 SET_STATE( PG, PG_IDLE ); | |
204 | |
205 pg_handle_idle_mode( ACCESS_IDLE ); | |
206 break; | |
207 | |
208 case PACKET_MODE_PTM: | |
209 SET_STATE( PG, PG_TRANSFER ); | |
210 | |
211 pg_handle_transfer_mode( ACCESS_PTM ); | |
212 break; | |
213 } | |
214 break; | |
215 | |
216 default: | |
217 TRACE_ERROR( "SIG_CTRL_PG_MODE_IND unexpected" ); | |
218 break; | |
219 } | |
220 }/* sig_ctrl_pg_mode_ind() */ | |
221 | |
222 /* | |
223 +------------------------------------------------------------------------------ | |
224 | Function : sig_ctrl_pg_t3172_run | |
225 +------------------------------------------------------------------------------ | |
226 | Description : Handles the internal signal SIG_CTRL_PG_T3172_RUN | |
227 | | |
228 | Parameters : void | |
229 | | |
230 +------------------------------------------------------------------------------ | |
231 */ | |
232 GLOBAL void sig_ctrl_pg_t3172_run ( void) | |
233 { | |
234 TRACE_ISIG( "sig_ctrl_pg_t3172_run" ); | |
235 | |
236 } /* sig_ctrl_pg_t3172_run() */ | |
237 | |
238 | |
239 /* | |
240 +------------------------------------------------------------------------------ | |
241 | Function : sig_ctrl_pg_indication | |
242 +------------------------------------------------------------------------------ | |
243 | Description : Handles the internal signal SIG_CTRL_PG_INDICATION. This | |
244 | signal indicates paging for packet access | |
245 | | |
246 | Parameters : UBYTE paging_type (IMSI or PTMSI(GPRS TMSI)) | |
247 | | |
248 +------------------------------------------------------------------------------ | |
249 */ | |
250 GLOBAL void sig_ctrl_pg_indication ( UBYTE paging_type ) | |
251 { | |
252 UBYTE type; | |
253 | |
254 TRACE_ISIG( "sig_ctrl_pg_indication" ); | |
255 | |
256 type = (paging_type EQ RRGRR_IMSI)? GMMRR_IMSI: GMMRR_PTMSI; | |
257 | |
258 switch( GET_STATE( PG ) ) | |
259 { | |
260 case PG_IDLE: | |
261 sig_pg_ctrl_downlink_transfer ( type ); | |
262 break; | |
263 case PG_ACCESS: | |
264 /* ignore PAGING REQUEST messages indicating a packet paging procedure*/ | |
265 break; | |
266 default: | |
267 TRACE_ERROR( "SIG_CTRL_PG_INDICATION unexpected" ); | |
268 break; | |
269 } | |
270 } /* sig_ctrl_pg_indication() */ | |
271 | |
272 /* | |
273 +------------------------------------------------------------------------------ | |
274 | Function : sig_ctrl_pg_rr_est | |
275 +------------------------------------------------------------------------------ | |
276 | Description : Handles the internal signal SIG_CTRL_PG_RR_EST. This | |
277 | signal indicates paging for RR connection. | |
278 | This signal makes no sense in case of Class C mobile | |
279 | | |
280 | Parameters : no parameters | |
281 | | |
282 +------------------------------------------------------------------------------ | |
283 */ | |
284 GLOBAL void sig_ctrl_pg_rr_est ( void) | |
285 { | |
286 | |
287 TRACE_ISIG( "sig_ctrl_pg_rr_est" ); | |
288 | |
289 if(grr_data->ms.class_of_mode EQ GMMRR_CLASS_CG) | |
290 { | |
291 TRACE_ERROR("CLASS_CG MS has received a RR_EST "); | |
292 } | |
293 else | |
294 { | |
295 switch( GET_STATE( PG ) ) | |
296 { | |
297 case PG_NULL: | |
298 case PG_IDLE: | |
299 case PG_ACCESS: | |
300 /* inform CTRL resp. GMM about the RR connection establishment request: | |
301 * GMM has to decide whether accept the request or not | |
302 */ | |
303 sig_pg_ctrl_rr_est_req(PG_ON_CCCH); | |
304 break; | |
305 case PG_TRANSFER: | |
306 if(grr_data->pg.nmo EQ GMMRR_NET_MODE_II) | |
307 { | |
308 TRACE_EVENT(" CS call in GMMRR_NET_MODE_II transfer mode"); | |
309 sig_pg_ctrl_rr_est_req(PG_ON_CCCH); | |
310 } | |
311 else | |
312 { | |
313 TRACE_EVENT_P1("CS call in transfer mode NMO_%d", grr_data->pg.nmo+1); | |
314 } | |
315 break; | |
316 default: | |
317 TRACE_ERROR( "SIG_CTRL_PG_RR_EST unexpected" ); | |
318 break; | |
319 } | |
320 } | |
321 } /* sig_ctrl_pg_indication() */ | |
322 | |
323 | |
324 | |
325 /* | |
326 +------------------------------------------------------------------------------ | |
327 | Function : sig_gfp_pg_req | |
328 +------------------------------------------------------------------------------ | |
329 | Description : Handles | |
330 | | |
331 | Parameters : void | |
332 | | |
333 +------------------------------------------------------------------------------ | |
334 */ | |
335 GLOBAL void sig_gfp_pg_req ( void ) | |
336 { | |
337 MCAST( d_paging_req, D_PAGING_REQ ); | |
338 | |
339 UBYTE state = GET_STATE( PG ); | |
340 | |
341 TRACE_ISIG( "sig_gfp_pg_req" ); | |
342 | |
343 switch( state ) | |
344 { | |
345 case PG_IDLE: | |
346 case PG_TRANSFER: | |
347 case PG_ACCESS: | |
348 pg_process_pp_req( d_paging_req, state ); | |
349 break; | |
350 default: | |
351 TRACE_ERROR( "sig_gfp_pg_req: page mode has no meaning in this state" ); | |
352 break; | |
353 } | |
354 } /* sig_gfp_pg_req() */ | |
355 | |
356 /* | |
357 +------------------------------------------------------------------------------ | |
358 | Function : sig_gfp_pg_mode | |
359 +------------------------------------------------------------------------------ | |
360 | Description : Handles | |
361 | | |
362 | Parameters : UBYTE page_mode: requested page mode | |
363 | BOOL ms_paging_group: paging belongs to MS paging group | |
364 | | |
365 +------------------------------------------------------------------------------ | |
366 */ | |
367 GLOBAL void sig_gfp_pg_mode ( UBYTE page_mode, BOOL ms_paging_group ) | |
368 { | |
369 TRACE_ISIG( "sig_gfp_pg_mode" ); | |
370 | |
371 if( ms_paging_group ) | |
372 { | |
373 switch( GET_STATE( PG ) ) | |
374 { | |
375 case PG_IDLE: | |
376 if( page_mode NEQ SAME_PAGING ) | |
377 { | |
378 psc_db->network_pg_mode = page_mode; | |
379 } | |
380 | |
381 if( grr_is_non_drx_period( ) EQ FALSE AND | |
382 psc_db->last_pg_mode NEQ psc_db->network_pg_mode ) | |
383 { | |
384 /* | |
385 * To ensure that the paging mode is not set to page normal in other states | |
386 * than packet idle mode, the function grr_is_packet_idle_mode is called in | |
387 * advance. | |
388 * | |
389 * State PG_IDLE not necessarily means that GRR is in packet idle mode. In | |
390 * case GRR is currently executing the RRGRR_STOP_TASK_REQ/CNF procedure, | |
391 * just the services CPAP and TC changes their states. All other services | |
392 * remain in state IDLE, which is not quite correct. A similar scenario | |
393 * occurs during execution of the MPHP_ASSIGNMENT_REQ/CON procedure. | |
394 */ | |
395 if( grr_is_packet_idle_mode( ) EQ TRUE ) | |
396 { | |
397 pg_send_start( psc_db->network_pg_mode ); | |
398 } | |
399 else | |
400 { | |
401 TRACE_EVENT( "sig_gfp_pg_mode: Page mode set by next packet idle mode" ); | |
402 } | |
403 } | |
404 break; | |
405 | |
406 case PG_ACCESS: | |
407 if( page_mode NEQ SAME_PAGING ) | |
408 { | |
409 psc_db->network_pg_mode = page_mode; | |
410 } | |
411 break; | |
412 | |
413 default: | |
414 | |
415 #ifdef _SIMULATION_ | |
416 | |
417 TRACE_ERROR( "SIG_GFP_PG_MODE unexpected" ); | |
418 | |
419 #endif /* #ifdef _SIMULATION_ */ | |
420 | |
421 break; | |
422 } | |
423 } | |
424 } /* sig_gfp_pg_mode() */ | |
425 | |
426 /* | |
427 +------------------------------------------------------------------------------ | |
428 | Function : sig_gfp_pg_stop_pccch_con | |
429 +------------------------------------------------------------------------------ | |
430 | Description : Handles the internal signal SIG_GFP_PG_STOP_PCCCH_CON | |
431 | | |
432 | Parameters : mphp_stop_pccch_con: pointer to T_MPHP_STOP_PCCCH_CON | |
433 | | |
434 +------------------------------------------------------------------------------ | |
435 */ | |
436 GLOBAL void sig_gfp_pg_stop_pccch_con ( T_MPHP_STOP_PCCCH_CON *mphp_stop_pccch_con) | |
437 { | |
438 TRACE_ISIG( "sig_gfp_pg_stop_pccch_con" ); | |
439 } /* sig_gfp_pg_stop_pccch_con() */ | |
440 | |
441 /* | |
442 +------------------------------------------------------------------------------ | |
443 | Function : sig_cs_pg_start_t_nc2_ndrx | |
444 +------------------------------------------------------------------------------ | |
445 | Description : Handles the internal signal SIG_CS_PG_START_NC2_NDRX | |
446 | | |
447 | Parameters : void | |
448 | | |
449 +------------------------------------------------------------------------------ | |
450 */ | |
451 GLOBAL void sig_cs_pg_start_t_nc2_ndrx ( UBYTE nc_non_drx_period ) | |
452 { | |
453 TRACE_ISIG( "sig_cs_pg_start_t_nc2_ndrx" ); | |
454 | |
455 pg_start_t_nc2_ndrx( nc_non_drx_period ); | |
456 | |
457 } /* sig_cs_pg_start_t_nc2_ndrx() */ |