comparison src/g23m-gprs/grlc/grlc_tpcs.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GPRS (8441)
4 | Modul : GRLC
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 | TPC of entity GRLC.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRLC_TPCS_C
23 #define GRLC_TPCS_C
24 #endif /* #ifndef GRLC_TPCS_C */
25
26 #define ENTITY_GRLC
27
28 /*==== INCLUDES =============================================================*/
29
30 #include <string.h>
31 #include "typedefs.h"
32 #include "vsi.h"
33 #include "macdef.h"
34 #include "gprs.h"
35 #include "gsm.h"
36 #include "ccdapi.h"
37 #include "prim.h"
38 #include "message.h"
39 #include "grlc.h"
40 #include "grlc_tpcg.h"
41 #include "grlc_tpcs.h"
42 #include "grlc_meass.h"
43
44 /*==== CONST ================================================================*/
45
46 /*==== DIAGNOSTICS ==========================================================*/
47
48 /*==== LOCAL VARS ===========================================================*/
49
50 /*==== PRIVATE FUNCTIONS ====================================================*/
51
52 LOCAL void tpc_update_pch ( void );
53 LOCAL void tpc_reset_fix_pwr_par ( void );
54
55 /*==== PUBLIC FUNCTIONS =====================================================*/
56 /*
57 +------------------------------------------------------------------------------
58 | Function : sig_pei_config_tpc_set_pwr_par
59 +------------------------------------------------------------------------------
60 | Description : ...
61 |
62 | Parameters : ...
63 |
64 +------------------------------------------------------------------------------
65 */
66 GLOBAL void sig_pei_config_tpc_set_pwr_par( UBYTE alpha, UBYTE gamma )
67 {
68 TRACE_ISIG( "sig_pei_config_tpc_set_pwr_par" );
69
70 if( alpha NEQ TPC_ALFGAM_NOT_PRESENT AND gamma NEQ TPC_ALFGAM_NOT_PRESENT )
71 {
72 UBYTE i; /* used for counting */
73
74 grlc_data->tpc.v_fix_pwr_par = TRUE;
75
76 /* process parameter alpha */
77 grlc_data->tpc.fix_pwr_par.alpha = alpha;
78
79 /* process parameter gamma */
80 for( i = 0; i < MAC_MAX_TIMESLOTS; i++ )
81 {
82 grlc_data->tpc.fix_pwr_par.gamma_ch[i] = gamma;
83 }
84 }
85 else
86 {
87 tpc_reset_fix_pwr_par( );
88 }
89 } /* sig_pei_config_tpc_set_pwr_par() */
90
91 /*
92 +------------------------------------------------------------------------------
93 | Function : sig_pei_config_tpc_fix_pcl
94 +------------------------------------------------------------------------------
95 | Description : ...
96 |
97 | Parameters : ...
98 |
99 +------------------------------------------------------------------------------
100 */
101 GLOBAL void sig_pei_config_tpc_fix_pcl ( UBYTE pcl )
102 {
103 TRACE_ISIG( "sig_pei_config_tpc_fix_pcl" );
104
105 grlc_data->tpc.fix_pcl = pcl;
106
107 } /* sig_pei_config_tpc_fix_pcl() */
108
109 /*
110 +------------------------------------------------------------------------------
111 | Function : sig_gff_tpc_pwr_ctrl_ind
112 +------------------------------------------------------------------------------
113 | Description : Handles the signal SIG_GFF_TPC_PWR_CTRL_IND
114 |
115 | Parameters : *mac_pwr_ctrl_ind - Ptr to primitive MAC_PWR_CTRL_IND
116 |
117 +------------------------------------------------------------------------------
118 */
119 GLOBAL void sig_gff_tpc_pwr_ctrl_ind ( T_MAC_PWR_CTRL_IND * mac_pwr_ctrl_ind )
120 {
121 TRACE_ISIG( "sig_gff_tpc_pwr_ctrl_ind" );
122
123 meas_c_val_update_ptm( mac_pwr_ctrl_ind,
124 &grlc_data->tpc.glbl_pwr_par,
125 &grlc_data->tm.freq_param );
126
127 meas_sv_update( mac_pwr_ctrl_ind,
128 &grlc_data->tpc.glbl_pwr_par,
129 &grlc_data->tm.freq_param );
130
131 tpc_update_pch( );
132
133 } /* sig_gff_tpc_pwr_ctrl_ind() */
134
135 /*
136 +------------------------------------------------------------------------------
137 | Function : sig_tm_tpc_update_pch
138 +------------------------------------------------------------------------------
139 | Description : Handles the signal SIG_TM_TPC_UPDATE_PCH
140 |
141 | Parameters :
142 |
143 +------------------------------------------------------------------------------
144 */
145 GLOBAL void sig_tm_tpc_update_pch ( void )
146 {
147 TRACE_ISIG( "sig_tm_tpc_update_pch" );
148
149 tpc_update_pch( );
150
151 } /* sig_tm_tpc_update_pch() */
152
153 /*
154 +------------------------------------------------------------------------------
155 | Function : tpc_grlc_init
156 +------------------------------------------------------------------------------
157 | Description : The function tpc_grlc_init() initialize the services TPC
158 |
159 | Parameters : void
160 |
161 +------------------------------------------------------------------------------
162 */
163 GLOBAL void tpc_grlc_init ( void )
164 {
165 TRACE_FUNCTION( "tpc_grlc_init" );
166
167 /* init power control parameter */
168 tpc_reset_fix_pwr_par( );
169
170 grlc_data->tpc.fix_pcl = TPC_SWITCHED_ON;
171
172 #if !defined (NTRACE)
173
174 grlc_data->tpc.n_tpc_trace = 0;
175
176 #endif /* #if !defined (NTRACE) */
177
178 } /* tpc_grlc_init() */
179
180 /*
181 +------------------------------------------------------------------------------
182 | Function : tpc_update_pch
183 +------------------------------------------------------------------------------
184 | Description : This function calculates the transmit output power
185 |
186 | Parameters : void
187 |
188 +------------------------------------------------------------------------------
189 */
190 LOCAL void tpc_update_pch ( void )
191 {
192 UBYTE *pch;
193 SHORT nop; /* nominal output power applied by the MS */
194 SHORT pms_max; /* maximum output power applied by the MS */
195
196 LONG summand;
197 LONG gamma_ch;
198 LONG c_value;
199
200 T_MS_PWR_CAP mspc; /* MS power capabilities */
201
202 T_C_FILTER *c_data = &grlc_data->meas.c_filter;
203 T_CGRLC_pwr_ctrl_param *pwr_par = &grlc_data->tpc.pwr_par;
204
205 UBYTE pcl; /* power control level */
206 UBYTE i; /* used for counting */
207
208 UBYTE alpha;
209
210 #if !defined (NTRACE)
211
212 BOOL tracing = FALSE;
213
214 #endif /* #if !defined (NTRACE) */
215
216 TRACE_FUNCTION( "tpc_update_pch" );
217
218 if( grlc_data->tpc.pch_buffer.pch_idx EQ PCH_IDX_A )
219 {
220 pch = &grlc_data->tpc.pch_buffer.pch_array[PCH_IDX_B].pch[0];
221 }
222 else
223 {
224 pch = &grlc_data->tpc.pch_buffer.pch_array[PCH_IDX_A].pch[0];
225 }
226
227 tpc_get_ms_pwr_cap( grlc_data->tm.freq_param.pdch_band, &mspc );
228
229 pms_max = grlc_data->tpc.glbl_pwr_par.pwr_max;
230
231 if( grlc_data->tpc.pwr_par.alpha NEQ CGRLC_ALPHA_INVALID )
232 {
233 alpha = grlc_data->tpc.pwr_par.alpha;
234 }
235 else
236 {
237 alpha = grlc_data->tpc.glbl_pwr_par.alpha;
238 }
239
240 if( grlc_data->tpc.fix_pcl NEQ TPC_SWITCHED_ON )
241 {
242
243 #if !defined (NTRACE)
244
245 for( i = 0; i < MAC_MAX_TIMESLOTS; i++ )
246 {
247 if( pch[i] NEQ grlc_data->tpc.fix_pcl )
248 {
249 tracing = TRUE;
250 }
251 }
252
253 #endif /* #if !defined (NTRACE) */
254
255 memset( pch, grlc_data->tpc.fix_pcl, MAC_MAX_TIMESLOTS );
256 }
257 else
258 {
259 /*
260 * select the used power parameter, either the data received
261 * from BSS or the data received by dynamic configuration
262 */
263 if( grlc_data->tpc.v_fix_pwr_par EQ TRUE )
264 {
265 pwr_par = &grlc_data->tpc.fix_pwr_par;
266 alpha = grlc_data->tpc.fix_pwr_par.alpha;
267 }
268
269 if( c_data->index EQ 0 AND alpha NEQ 0 )
270 {
271 pcl = tpc_get_pcl( mspc.p_control, pms_max );
272
273 #if !defined (NTRACE)
274
275 for( i = 0; i < MAC_MAX_TIMESLOTS; i++ )
276 {
277 if( pch[i] NEQ pcl )
278 {
279 tracing = TRUE;
280 }
281 }
282
283 #endif /* #if !defined (NTRACE) */
284
285 memset( pch, pcl, MAC_MAX_TIMESLOTS );
286 }
287 else
288 {
289 /* process parameter summand */
290 c_value = ( 63 * MEAS_ACRCY ) - c_data->value;
291 summand = ( MEAS_ACRCY * mspc.gamma_0 ) + ( ( alpha * c_value ) / 10 );
292
293 /* set the power control level for each timeslot */
294 for( i = 0; i < MAC_MAX_TIMESLOTS; i++ )
295 {
296 if( pwr_par->gamma_ch[i] NEQ CGRLC_GAMMA_INVALID )
297 {
298 gamma_ch = 2 * MEAS_ACRCY * pwr_par->gamma_ch[i];
299
300 nop = MINIMUM( summand - gamma_ch, pms_max * MEAS_ACRCY ) /
301 MEAS_ACRCY;
302
303 if( nop < mspc.pwr_min )
304 {
305 nop = mspc.pwr_min;
306 }
307 }
308 else
309 {
310 nop = pms_max;
311 }
312
313 pcl = tpc_get_pcl( mspc.p_control, nop );
314
315 #if !defined (NTRACE)
316
317 if( pch[i] NEQ pcl )
318 {
319 tracing = TRUE;
320 }
321
322 #endif /* #if !defined (NTRACE) */
323
324 pch[i] = pcl;
325 }
326 }
327 }
328
329 #if !defined (NTRACE)
330
331 if( ( grlc_data->tpc.n_tpc_trace & M_TPC_TRACE_STATIC ) OR
332 ( grlc_data->tpc.n_tpc_trace & M_TPC_TRACE_CHANGE AND
333 tracing EQ TRUE ) )
334 {
335 ULONG trace[8];
336
337 trace[0] = ( grlc_data->tpc.glbl_pwr_par.t_avg_t << 24 );
338 trace[0] |= ( grlc_data->tpc.glbl_pwr_par.pb << 16 );
339 trace[0] |= ( grlc_data->tpc.glbl_pwr_par.pc_meas_chan << 8 );
340 trace[0] |= ( grlc_data->tpc.glbl_pwr_par.pwr_max << 0 );
341
342 trace[1] = ( grlc_data->tm.freq_param.pdch_hopping << 24 );
343 trace[1] |= ( grlc_data->tm.freq_param.pdch_band << 16 );
344 trace[1] |= ( grlc_data->tpc.glbl_pwr_par.alpha << 8 );
345 trace[1] |= ( grlc_data->tpc.pwr_par.alpha << 0 );
346
347 trace[2] = ( grlc_data->tpc.fix_pwr_par.alpha << 24 );
348 trace[2] |= ( grlc_data->tpc.fix_pcl << 16 );
349 trace[2] |= ( grlc_data->tpc.pch_buffer.pch_idx << 8 );
350
351 trace[3] = 0x00000000;
352 trace[4] = 0x00000000;
353
354 for( i = 0; i < MAC_MAX_TIMESLOTS; i++ )
355 {
356 trace[( i / 4 ) + 3] |= ( pwr_par->gamma_ch[i] << ( 24 - ( 8 * ( i % 4 ) ) ) );
357 }
358
359 trace[5] = ( c_data->index << 16 );
360 trace[5] |= ( c_data->value << 0 );
361
362 trace[6] = ( pch[0] << 24 );
363 trace[6] |= ( pch[1] << 16 );
364 trace[6] |= ( pch[2] << 8 );
365 trace[6] |= ( pch[3] << 0 );
366
367 trace[7] = ( pch[4] << 24 );
368 trace[7] |= ( pch[5] << 16 );
369 trace[7] |= ( pch[6] << 8 );
370 trace[7] |= ( pch[7] << 0 );
371
372 TRACE_EVENT_P8( "TPC: %08X %08X %08X %08X %08X %08X %08X %08X",
373 trace[0], trace[1], trace[2], trace[3],
374 trace[4], trace[5], trace[6], trace[7] );
375 }
376
377 #endif /* #if !defined (NTRACE) */
378
379 if( grlc_data->tpc.pch_buffer.pch_idx EQ PCH_IDX_A )
380 {
381 grlc_data->tpc.pch_buffer.pch_idx = PCH_IDX_B;
382 }
383 else
384 {
385 grlc_data->tpc.pch_buffer.pch_idx = PCH_IDX_A;
386 }
387 } /* tpc_update_pch() */
388
389 /*
390 +------------------------------------------------------------------------------
391 | Function : tpc_get_pch
392 +------------------------------------------------------------------------------
393 | Description :
394 |
395 | Parameters :
396 |
397 +------------------------------------------------------------------------------
398 */
399 GLOBAL void tpc_get_pch ( UBYTE *pch_dest )
400 {
401 UBYTE *pch_src;
402
403 TRACE_FUNCTION( "tpc_get_pch" );
404
405 if( grlc_data->tpc.pch_buffer.pch_idx EQ PCH_IDX_A )
406 {
407 pch_src = &grlc_data->tpc.pch_buffer.pch_array[PCH_IDX_A].pch[0];
408 }
409 else
410 {
411 pch_src = &grlc_data->tpc.pch_buffer.pch_array[PCH_IDX_B].pch[0];
412 }
413
414 memcpy( pch_dest, pch_src, MAC_MAX_TIMESLOTS );
415
416 } /* tpc_get_pch() */
417
418 /*
419 +------------------------------------------------------------------------------
420 | Function : tpc_set_pwr_ctrl_param
421 +------------------------------------------------------------------------------
422 | Description :
423 |
424 | Parameters :
425 |
426 +------------------------------------------------------------------------------
427 */
428 GLOBAL void tpc_set_pwr_ctrl_param ( T_CGRLC_pwr_ctrl_param *pwr_ctrl_param )
429 {
430 TRACE_FUNCTION( "tpc_set_pwr_ctrl_param" );
431
432 grlc_data->tpc.pwr_par = *pwr_ctrl_param;
433
434 } /* tpc_set_pwr_ctrl_param() */
435
436 /*
437 +------------------------------------------------------------------------------
438 | Function : tpc_set_glbl_pwr_ctrl_param
439 +------------------------------------------------------------------------------
440 | Description :
441 |
442 | Parameters :
443 |
444 +------------------------------------------------------------------------------
445 */
446 GLOBAL void tpc_set_glbl_pwr_ctrl_param
447 ( T_CGRLC_glbl_pwr_ctrl_param *glbl_pwr_ctrl_param )
448 {
449 TRACE_FUNCTION( "tpc_set_glbl_pwr_ctrl_param" );
450
451 grlc_data->tpc.glbl_pwr_par = *glbl_pwr_ctrl_param;
452
453 } /* tpc_set_glbl_pwr_ctrl_param() */
454
455 /*
456 +------------------------------------------------------------------------------
457 | Function : tpc_reset_fix_pwr_par
458 +------------------------------------------------------------------------------
459 | Description :
460 |
461 | Parameters :
462 |
463 +------------------------------------------------------------------------------
464 */
465 LOCAL void tpc_reset_fix_pwr_par ( void )
466 {
467 UBYTE i; /* used for counting */
468
469 TRACE_FUNCTION( "tpc_reset_fix_pwr_par" );
470
471 grlc_data->tpc.v_fix_pwr_par = FALSE;
472
473 /* process parameter alpha */
474 grlc_data->tpc.fix_pwr_par.alpha = TPC_ALFGAM_NOT_PRESENT;
475
476 /* process parameter gamma */
477 for( i = 0; i < MAC_MAX_TIMESLOTS; i++ )
478 {
479 grlc_data->tpc.fix_pwr_par.gamma_ch[i] = TPC_ALFGAM_NOT_PRESENT;
480 }
481 } /* tpc_reset_fix_pwr_par() */