comparison src/g23m-gprs/grlc/grlc_gffp.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
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 primitive handler functions for service
18 | GFF of entity GRLC.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRLC_GFFP_C
23 #define GRLC_GFFP_C
24 #endif
25
26 #define ENTITY_GRLC
27
28 /*==== INCLUDES =============================================================*/
29
30 #include <stdio.h>
31 #include "typedefs.h" /* to get Condat data types */
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 "prim.h" /* to get the definitions of used SAP and directions */
38 #include "message.h"
39 #include "grlc.h" /* to get the global entity definitions */
40 #include "grlc_gfff.h"
41 #include "grlc_f.h"
42 #include <string.h>
43 #include "grlc_rus.h"
44 #include "grlc_rds.h"
45 #include "grlc_func.h"
46 #include "grlc_tpcs.h"
47 #include "grlc_meass.h"
48 #include "cl_rlcmac.h"
49 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
50 #include "grlc_tms.h"
51 #endif
52
53 /*==== CONST ================================================================*/
54
55 #define BITS_PER_RADIO_BLOCK 456
56
57 /*==== LOCAL VARS ===========================================================*/
58
59 /*==== PRIVATE FUNCTIONS ====================================================*/
60
61 /*==== PUBLIC FUNCTIONS =====================================================*/
62 /*
63 +------------------------------------------------------------------------------
64 | Function : gff_mac_pwr_ctrl_ind
65 +------------------------------------------------------------------------------
66 | Description : Handles the primitive MAC_PWR_CTRL_IND
67 |
68 | Parameters : *mac_pwr_ctrl_ind - Ptr to primitive payload
69 |
70 +------------------------------------------------------------------------------
71 */
72 GLOBAL void gff_mac_pwr_ctrl_ind ( T_MAC_PWR_CTRL_IND * mac_pwr_ctrl_ind )
73 {
74 TRACE_FUNCTION( "gff_mac_pwr_ctrl_ind" );
75
76 #if defined _TARGET_ && !defined (NTRACE)
77
78 if( grlc_data->tpc.n_tpc_trace & M_TPC_TRACE_FUNCTION )
79 {
80 T_L1TEST_CALL_MPHP_POWER_CONTROL l1test_call;
81
82 UBYTE i;
83
84 l1test_call.assignment_id = ( U8 )mac_pwr_ctrl_ind->assignment_id;
85 l1test_call.crc_error = mac_pwr_ctrl_ind->crc_error;
86 l1test_call.bcch_level = ( S8 )mac_pwr_ctrl_ind->bcch_level;
87
88 for( i = 0; i < L1TEST_BURST_PER_BLOCK; i++ )
89 {
90 l1test_call.burst_level[i] = ( S8 )mac_pwr_ctrl_ind->burst_level[i];
91 l1test_call.radio_freq [i] = mac_pwr_ctrl_ind->radio_freq[i];
92 }
93
94 TRACE_MEMORY_PRIM ( hCommL1, hCommGRLC, L1TEST_CALL_MPHP_POWER_CONTROL,
95 &l1test_call, sizeof( T_L1TEST_CALL_MPHP_POWER_CONTROL ) );
96 }
97
98 #endif /* #if defined _TARGET_ && !defined (NTRACE) */
99
100 gff_clip_rxlev( &mac_pwr_ctrl_ind->bcch_level,
101 &mac_pwr_ctrl_ind->bcch_level, 1 );
102
103 gff_clip_rxlev( mac_pwr_ctrl_ind->burst_level,
104 mac_pwr_ctrl_ind->burst_level,
105 MAC_BURST_PER_BLOCK );
106
107 sig_gff_tpc_pwr_ctrl_ind( mac_pwr_ctrl_ind );
108
109 #if defined _TARGET_ && !defined (NTRACE)
110
111 if( grlc_data->tpc.n_tpc_trace & M_TPC_TRACE_FUNCTION )
112 {
113 T_L1TEST_RETURN_MPHP_POWER_CONTROL l1test_return;
114
115 tpc_get_pch( &l1test_return.pch[0] );
116
117 TRACE_MEMORY_PRIM ( hCommGRLC, hCommL1, L1TEST_RETURN_MPHP_POWER_CONTROL,
118 &l1test_return, sizeof( T_L1TEST_RETURN_MPHP_POWER_CONTROL ) );
119 }
120
121 #endif /* #if defined _TARGET_ && !defined (NTRACE) */
122
123 } /* gff_mac_pwr_ctrl_ind() */
124
125 /*
126 +------------------------------------------------------------------------------
127 | Function : gff_mac_data_ind
128 +------------------------------------------------------------------------------
129 | Description : Handles the primitive MAC_DATA_IND
130 |
131 | Parameters : *mac_data_ind - Ptr to primitive payload
132 |
133 +------------------------------------------------------------------------------
134 */
135 GLOBAL void gff_mac_data_ind ( T_MAC_DATA_IND * mac_data_ind )
136 {
137 UBYTE i;
138 USHORT rx_no;
139
140 TRACE_FUNCTION( "mac_data_ind" );
141
142 rx_no = grlc_data->func.dl_blocks.data_ptr.rx_no;
143
144 #ifdef _SIMULATION_
145 {
146 /*
147 * copy received primitive to grlc_data->func.mac_data_ind
148 */
149
150 TRACE_EVENT_P5("mac_data_ind fn=%ld tn= %d -> mask=%x UL_MASK=%x DL_MASK=%x"
151 ,mac_data_ind->fn
152 ,mac_data_ind->dl_data.tn
153 ,0x80>>mac_data_ind->dl_data.tn
154 ,grlc_data->ul_tn_mask
155 ,grlc_data->dl_tn_mask);
156
157 grlc_data->dl_fn = mac_data_ind->fn;
158 grlc_data->ul_fn = mac_data_ind->fn;
159 memcpy (
160 &(grlc_data->func.mac_data_ind),
161 mac_data_ind,
162 sizeof(T_MAC_DATA_IND));
163 PFREE(mac_data_ind);
164 mac_data_ind = &(grlc_data->func.mac_data_ind);
165 rx_no = 1;
166 }
167 #endif
168
169 switch( GET_STATE( GFF ) )
170 {
171 case GFF_ACTIVE:
172 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
173 case GFF_TWO_PHASE:
174 #endif
175 {
176 T_BER_IND ber_ind;
177
178 ber_ind.num_dl_blck = 0;
179
180 for(i=0; i< rx_no; i++)
181 {
182
183
184 #ifdef _TARGET_
185 {
186 /*
187 * copy next primitive to grlc_data->func.mac_data_ind
188 */
189 grlc_data->func.mac_data_ind.fn = grlc_data->func.dl_blocks.fn;
190 grlc_data->func.mac_data_ind.rx_no = grlc_data->func.dl_blocks.data_ptr.rx_no;
191 grlc_data->func.mac_data_ind.dl_data = grlc_data->func.dl_blocks.data_ptr.dl_data[i];
192 mac_data_ind = &(grlc_data->func.mac_data_ind);
193 }
194
195 TRACE_MEMORY_PRIM ( hCommL1, hCommGRLC, MAC_DATA_IND,
196 mac_data_ind, sizeof( T_MAC_DATA_IND ) );
197
198 #endif /* #ifdef _TARGET_ */
199
200 /*
201 * In Test mode B,if there is CRC error on the payload data the MS will,
202 * where required by the USF, transmit the decoded payload data. The block
203 * transmitted will be a valid uplink block format.
204 */
205
206 if( ( (mac_data_ind->dl_data.block_status & 0x0100) EQ 0x0000) OR ( (grlc_data->testmode.mode EQ CGRLC_LOOP) ) )
207 {
208 /*
209 * Only successfully decoded blocks shall be considered
210 */
211
212 if( gff_analyse_dl_data( mac_data_ind->fn, &( mac_data_ind->dl_data ) ) )
213 {
214 /*
215 * Only blocks intended for that MS shall be considered
216 */
217
218 if( ber_ind.num_dl_blck < MAC_MAX_DL_DATA_BLCKS )
219 {
220 ber_ind.be_info[ber_ind.num_dl_blck].total = BITS_PER_RADIO_BLOCK;
221
222 if( ( mac_data_ind->dl_data.block_status & 0x000F ) EQ 0x0006 )
223 {
224 /*
225 * If CS4 is used, the MS is allowed to report RXQUAL = 7,
226 * so just set the BER to 100%
227 */
228 ber_ind.be_info[ber_ind.num_dl_blck].fault =
229 BITS_PER_RADIO_BLOCK;
230 }
231 else
232 {
233 ber_ind.be_info[ber_ind.num_dl_blck].fault =
234 grlc_data->func.mac_data_ind.dl_data.d_nerr;
235 }
236
237 ber_ind.num_dl_blck++;
238 }
239 else
240 {
241 TRACE_ERROR( "be_info overflow in gff_mac_data_ind" );
242 }
243 }
244 }
245 else
246 {
247 TRACE_ERROR( "MAC_DATA_IND with bad CRC" );
248
249 TRACE_BINDUMP
250 ( hCommGRLC, TC_USER5,
251 cl_rlcmac_get_msg_name( D_MSG_TYPE_CRC_ERROR_c, RLC_MAC_ROUTE_DL ),
252 mac_data_ind->dl_data.dl_block, MAX_L2_FRAME_SIZE ); /*lint !e569*/
253
254 /* grlc_data->nr_of_crc_errors++; */
255 }
256 }
257
258 if( ber_ind.num_dl_blck NEQ 0 )
259 {
260 meas_sq_update( &ber_ind );
261 }
262 }
263 break;
264 default:
265 /*TRACE_ERROR( "MAC_DATA_IND unexpected" );*/
266 break;
267 }
268
269 /*call control of asyn part TARGET DEBUGGING*/
270 #if defined (_TARGET_)
271 grlc_data->dl_cnt_asyn = grlc_data->dl_cnt_syn;
272 #endif /* defined (_TARGET_) */
273
274 } /* gff_mac_data_ind() */
275
276
277
278 /*
279 +------------------------------------------------------------------------------
280 | Function : gff_mac_ready_ind
281 +------------------------------------------------------------------------------
282 | Description : Handles the primitive MAC_READY_IND
283 |
284 | Parameters : *mac_ready_ind - Ptr to primitive payload
285 |
286 +------------------------------------------------------------------------------
287 */
288 GLOBAL void gff_mac_ready_ind ( T_MAC_READY_IND * mac_ready_ind )
289 {
290 TRACE_FUNCTION( "mac_ready_ind" );
291
292 /*
293 * calculate the frame number from downlink call
294 */
295 #ifdef _TARGET_
296 {
297 ULONG current_dl_fn;
298 ULONG last_dl_fn;
299 ULONG last_ul_fn;
300 ULONG current_ul_fn;
301 BOOL trace_dl_gap = TRUE;
302
303 current_dl_fn = grlc_data->func.mac_ready_ind.fn;
304 last_dl_fn = grlc_data->last_dl_fn;
305 last_ul_fn = grlc_data->last_ul_fn;
306
307 grlc_data->func.mac_ready_ind.fn = grlc_data->ul_fn ;
308 current_ul_fn = grlc_data->ul_fn;
309
310 if(grlc_data->func.mac_ready_ind.last_poll_resp)
311 {
312 TRACE_EVENT_P5("POLL NOT SENT BY LAYER 1 fn=%ld last_poll_resp=0x%x np_fn=%ld,bs=%d,ind=%d"
313 ,grlc_data->func.mac_ready_ind.fn
314 ,grlc_data->func.mac_ready_ind.last_poll_resp
315 ,grlc_data->next_poll_fn
316 ,grlc_data->ul_poll_resp[0].block_status
317 ,grlc_data->ul_poll_pos_index);
318 }
319
320 /* handle gaps*/
321 if ((grlc_data->next_poll_fn EQ 2) OR (grlc_data->next_poll_fn EQ 1))
322 { /* last poll is sent*/
323 grlc_data->func.mac_ready_ind.last_poll_resp = 0; /* no ul gap for poll */
324 }
325 else if( grlc_data->ul_call_errors AND
326 (grlc_data->ul_fn_errors[grlc_data->ul_call_errors-1] EQ grlc_data->next_poll_fn ))
327 {
328 trace_dl_gap = FALSE;
329 TRACE_EVENT_P7("CALL ERR:c_dl_fn=%ld l_dl_fn=%ld c_ul_fn=%ld l_ul_fn=%ld callerr=%d err_fn=%ld lp_fn=%ld",
330 current_dl_fn,
331 last_dl_fn,
332 current_ul_fn,
333 last_ul_fn,
334 grlc_data->ul_call_errors,
335 grlc_data->ul_fn_errors[grlc_data->ul_call_errors-1],
336 grlc_data->next_poll_fn);
337
338 grlc_data->func.mac_ready_ind.last_poll_resp = 0xFF;
339 grlc_data->next_poll_fn =2 ;
340 }
341 else if(current_ul_fn >= grlc_data->next_poll_fn)
342 {
343 trace_dl_gap = FALSE;
344 TRACE_EVENT_P6("2UL GAP NO POLL:c_dl_fn=%ld l_dl_fn=%ld c_ul_fn=%ld l_ul_fn=%ld lpr=%d lp_fn=%ld",
345 current_dl_fn,
346 last_dl_fn,
347 current_ul_fn,
348 last_ul_fn,
349 grlc_data->func.mac_ready_ind.last_poll_resp,
350 grlc_data->next_poll_fn);
351
352 grlc_data->func.mac_ready_ind.last_poll_resp = 0xFF;
353 grlc_data->next_poll_fn =2 ;
354 }
355 else if((grlc_data->next_poll_fn > current_ul_fn) AND (current_ul_fn < 52)) /*fn overflow*/
356 {
357 trace_dl_gap = FALSE;
358 TRACE_EVENT_P6("3UL GAP NO POLL:c_dl_fn=%ld l_dl_fn=%ld c_ul_fn=%ld l_ul_fn=%ld lpr=%d lp_fn=%ld",
359 current_dl_fn,
360 last_dl_fn,
361 current_ul_fn,
362 last_ul_fn,
363 grlc_data->func.mac_ready_ind.last_poll_resp,
364 grlc_data->next_poll_fn);
365 grlc_data->func.mac_ready_ind.last_poll_resp = 0xFF;
366 grlc_data->next_poll_fn =2 ;
367 }
368
369 if( trace_dl_gap AND
370 ( ( current_dl_fn - last_dl_fn ) > 5 ) AND
371 ( grlc_data->dl_cnt_syn OR grlc_data->dl_fn_store[0] OR grlc_data->dl_fn_store[1] ) )
372 {
373 TRACE_EVENT_P2( "DL GAP: c_dl_fn=%ld l_dl_fn=%ld", current_dl_fn, last_dl_fn );
374 }
375 }
376 #endif /* _TARGET_ */
377
378 #ifdef _SIMULATION_
379 {
380 /*
381 * copy received primitive to grlc_data->func.mac_ready_ind
382 */
383 grlc_data->ul_fn = mac_ready_ind->fn;
384 memcpy (
385 &(grlc_data->func.mac_ready_ind),
386 mac_ready_ind,
387 sizeof(T_MAC_READY_IND));
388 PFREE(mac_ready_ind);
389 }
390 #endif
391
392
393 mac_ready_ind = &(grlc_data->func.mac_ready_ind);
394
395 #ifdef _TARGET_
396
397 TRACE_MEMORY_PRIM ( hCommL1, hCommGRLC, MAC_READY_IND,
398 mac_ready_ind, sizeof( T_MAC_READY_IND ) );
399
400 #endif /* #ifdef _TARGET_ */
401
402 /*
403 * handle ta value
404 */
405 gff_handle_continious_ta();
406
407
408 switch( GET_STATE(GFF) )
409 {
410 case GFF_ACTIVE:
411 if(grlc_data->tfi_change NEQ TFI_CHANGE_NULL)
412 {
413 grlc_activate_tfi(mac_ready_ind->fn);
414 }
415 grlc_data->ul_poll_pos_index = 0;
416 if(grlc_data->gff.rlc_status EQ RLC_STATUS_BOTH)
417 {
418 sig_gff_ru_mac_ready_ind(mac_ready_ind);
419 sig_gff_rd_mac_ready_ind(mac_ready_ind);
420 }
421 else if(grlc_data->gff.rlc_status EQ RLC_STATUS_UL)
422 sig_gff_ru_mac_ready_ind(mac_ready_ind);
423 else if(grlc_data->gff.rlc_status EQ RLC_STATUS_DL)
424 sig_gff_rd_mac_ready_ind(mac_ready_ind);
425 else
426 {
427 TRACE_ERROR("unknown rlc status: gff active but no tbf");
428 }
429 break;
430 #if defined REL99 AND defined TI_PS_FF_TBF_EST_PACCH
431 case GFF_TWO_PHASE:
432 grlc_data->ul_poll_pos_index = 0;
433 sig_gff_tm_mac_ready_ind_two_phase(mac_ready_ind);
434 break;
435 #endif
436 default:
437 /*TRACE_ERROR( "MAC_READY_IND unexpected" );*/
438 break;
439 }
440
441 #if defined (_TARGET_)
442 /*call control of asyn part*/
443 grlc_data->ul_cnt_asyn = grlc_data->ul_cnt_syn;
444 #endif /* defined (_TARGET_) */
445
446
447 } /* gff_mac_ready_ind() */
448
449 /*
450 +------------------------------------------------------------------------------
451 | Function : gff_l1test_call_mphp_power_control
452 +------------------------------------------------------------------------------
453 | Description : Handles the primitive L1TEST_CALL_MPHP_POWER_CONTROL
454 |
455 | Parameters : *mphp_power_control - Ptr to primitive payload
456 |
457 +------------------------------------------------------------------------------
458 */
459
460 #ifdef _SIMULATION_
461
462 GLOBAL void gff_l1test_call_mphp_power_control
463 ( T_L1TEST_CALL_MPHP_POWER_CONTROL *call_mphp_power_control )
464 {
465 PALLOC( return_mphp_power_control, L1TEST_RETURN_MPHP_POWER_CONTROL );
466
467 maca_power_control( call_mphp_power_control->assignment_id,
468 call_mphp_power_control->crc_error,
469 call_mphp_power_control->bcch_level,
470 call_mphp_power_control->radio_freq,
471 call_mphp_power_control->burst_level,
472 return_mphp_power_control->pch );
473
474 PSEND( hCommL1, return_mphp_power_control );
475
476 TRACE_FUNCTION( "gff_l1test_call_mphp_power_control" );
477
478 PFREE( call_mphp_power_control );
479
480 } /* gff_l1test_call_mphp_power_control() */
481
482 #endif /* #ifdef _SIMULATION_ */