comparison src/g23m-gprs/grlc/grlc_func.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 : 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 modul is part of the entity GRLC and implements all
18 | functions according to 921bis.doc
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef GRLC_FUNC_C
23 #define GRLC_FUNC_C
24 #endif
25
26
27 #define ENTITY_GRLC
28
29
30 /*==== INCLUDES =============================================================*/
31
32
33 #include <string.h>
34 #include "typedefs.h" /* to get Condat data types */
35 #include "vsi.h" /* to get a lot of macros */
36 #include "macdef.h"
37 #include "gprs.h"
38 #include "gsm.h" /* to get a lot of macros */
39 #include "ccdapi.h" /* to get CCD API */
40 #include "prim.h" /* to get the definitions of used SAP and directions */
41 #include "message.h" /* to get air message definitions */
42 #include "grlc.h" /* to get the global entity definitions */
43 #include "grlc_func.h" /* to check the function */
44 #include "grlc_f.h" /* to get the global entity definitions */
45 #include "grlc_tpcs.h"
46
47 /* patch to avoid overwriting of primitives in global variable QueueMsg[] */
48 #undef VSI_CALLER_SINGLE
49 #define VSI_CALLER_SINGLE 0
50
51
52 /*==== CONST ================================================================*/
53
54 /*==== DIAGNOSTICS ==========================================================*/
55
56 /*==== LOCAL VARS ===========================================================*/
57
58 /*==== PRIVATE FUNCTIONS ====================================================*/
59 /*
60 +------------------------------------------------------------------------------
61 | Function : maca_power_control
62 +------------------------------------------------------------------------------
63 | Description : The function maca_power_control() is described in 921bis.doc
64 |
65 | Parameters : see 921bis.doc
66 |
67 +------------------------------------------------------------------------------
68 */
69 GLOBAL void maca_power_control ( UWORD8 assignment_id,
70 BOOL crc_error,
71 WORD8 bcch_level,
72 UWORD16 radio_freq[MAC_BURST_PER_BLOCK],
73 WORD8 burst_level[MAC_BURST_PER_BLOCK],
74 UWORD8 *pch )
75 {
76 UBYTE i; /* used for counting */
77
78 tpc_get_pch( pch );
79
80 grlc_data->func.mac_pwr_ctrl_ind.assignment_id = assignment_id;
81 grlc_data->func.mac_pwr_ctrl_ind.crc_error = ( crc_error ? GRLC_CRC_FAIL : GRLC_CRC_PASS );
82 grlc_data->func.mac_pwr_ctrl_ind.bcch_level = bcch_level;
83
84 for( i = 0; i < MAC_BURST_PER_BLOCK; i++ )
85 {
86 grlc_data->func.mac_pwr_ctrl_ind.burst_level[i] = burst_level[i];
87 grlc_data->func.mac_pwr_ctrl_ind.radio_freq [i] = radio_freq[i];
88 }
89
90 PSIGNAL( hCommGRLC, MAC_PWR_CTRL_IND, &grlc_data->func.mac_pwr_ctrl_ind );
91
92 return;
93 } /* maca_power_control() */
94
95 #ifdef _TARGET_
96
97 UWORD32 lst_dl_frame_nr;
98
99
100 /*
101 +------------------------------------------------------------------------------
102 | Function : rlc_uplink
103 +------------------------------------------------------------------------------
104 | Description : The function rlc_uplink() is described in 921bis.doc
105 |
106 | Parameters : see 921bis.doc
107 |
108 +------------------------------------------------------------------------------
109 */
110 GLOBAL void rlc_uplink ( UWORD8 assignment_id,
111 UWORD8 tx_data_no,
112 UWORD32 fn,
113 UWORD8 timing_advance_value,
114 T_ul_poll_resp * ul_poll_response,
115 T_ul_data * ul_data,
116 BOOL allocation_exhausted)
117 {
118 UWORD8 i;
119 API *pollptr = (API*)ul_poll_response;
120 API *outptr = (API*)ul_data;
121
122
123 grlc_data->last_ul_fn = fn;
124 grlc_data->ul_fn_store[(grlc_data->ul_cnt_syn%CALL_ERROR_NR_OF_ST_FN)] = fn;
125
126 if(grlc_data->ul_cnt_syn NEQ grlc_data->ul_cnt_asyn)
127 {
128 grlc_data->ul_fn_errors[(grlc_data->ul_cnt_syn%CALL_ERROR_NR_OF_ST_FN)] = fn;
129 grlc_data->ul_fn_errors[(grlc_data->ul_call_errors%CALL_ERROR_NR_OF_ST_FN)] = fn;
130
131 /* Increment the Call_Error and wraparrond if it exceed CALL_ERROR_NR_OF_ST_FN */
132 grlc_data->ul_call_errors = ((grlc_data->ul_call_errors%CALL_ERROR_NR_OF_ST_FN)+1);
133 }
134
135 grlc_data->func.mac_ready_ind.nts = tx_data_no;
136 grlc_data->func.mac_ready_ind.ta_value = timing_advance_value;
137
138 /*****copy Poll blocks**************************************************/
139 if(fn EQ grlc_data->next_poll_fn)
140 {
141 i=0;
142 while(grlc_data->ul_poll_resp[i].block_status)
143 {
144 pollptr[i*15] = grlc_data->ul_poll_resp[i].block_status;
145 pollptr[i*15+1] = grlc_data->ul_poll_resp[i].tn;
146 memcpy( (UBYTE*)&pollptr[i*15+2],
147 (UBYTE*)grlc_data->ul_poll_resp[i].ul_block,
148 12 * sizeof(API) ); /*lint !e419*/
149 pollptr[15*(i+1)] = 0x0000; /* Poll None*/
150 i++;
151 }
152 grlc_data->ul_poll_resp[0].block_status = 0;
153 grlc_data->next_poll_fn = 2;
154 }
155 else
156 {
157 pollptr[0] = 0x0000; /* Poll None*/
158 }
159
160
161 /*****copy data blocks**************************************************/
162
163 outptr[0] = 0;
164 if(grlc_data->ta_value NEQ 0xFF)
165 {
166 for(i=0;i<tx_data_no;i++)
167 {
168 outptr[i*29] = grlc_data->ru.ul_data[i].block_status;
169 memcpy( (UBYTE*)&outptr[1+(i*29)],
170 (UBYTE*)grlc_data->ru.ul_data[i].ul_block,
171 28 * sizeof(API) ); /*lint !e419*/
172 outptr[(i+1)*29] = 0;
173 }
174 }
175
176 /*call control of syn part*/
177 grlc_data->ul_cnt_syn++;
178
179 return;
180 } /* rlc_uplink() */
181
182
183 /*
184 +------------------------------------------------------------------------------
185 | Function : rlc_downlink
186 +------------------------------------------------------------------------------
187 | Description : The function rlc_downlink() is described in 921bis.doc
188 |
189 | Parameters : see 921bis.doc
190 |
191 +------------------------------------------------------------------------------
192 */
193 GLOBAL void rlc_downlink ( UWORD8 assignment_id,
194 UWORD32 fn,
195 T_dl_struct *data_ptr,
196 UWORD8 rlc_blocks_sent,
197 UWORD8 last_poll_response)
198 {
199 API * in_ptr = (API*) (data_ptr);
200 BOOL send_psginal;
201 UBYTE i,pos = 0, call_err = 0, crc_cnt=0;
202
203
204 grlc_data->last_dl_fn = lst_dl_frame_nr;
205 lst_dl_frame_nr = fn;
206 grlc_data->dl_fn_store[(grlc_data->dl_cnt_syn%CALL_ERROR_NR_OF_ST_FN)] = fn-4;
207
208 if(grlc_data->dl_cnt_syn NEQ grlc_data->dl_cnt_asyn)
209 {
210 grlc_data->dl_fn_errors[(grlc_data->dl_cnt_syn%CALL_ERROR_NR_OF_ST_FN)] = fn-4;
211 grlc_data->dl_call_errors++;
212 }
213
214 grlc_data->dl_fn = fn-4;
215 grlc_data->func.dl_blocks.fn = fn-4;
216 grlc_data->func.dl_blocks.data_ptr.rx_no = 0;
217 send_psginal = FALSE;
218 if(grlc_data->dl_cnt_syn EQ grlc_data->dl_cnt_asyn)
219 {
220 for (i = 0; i < data_ptr->rx_no; i++)
221 {
222 /*
223 * In Test mode B,if there is CRC error on the payload data the MS will,
224 * where required by the USF, transmit the decoded payload data. The block
225 * transmitted will be a valid uplink block format.
226 */
227
228 if(((in_ptr[31 * i + 1] & 0x0100) EQ 0x0000) OR (grlc_data->testmode.mode EQ CGRLC_LOOP) )
229 {
230 send_psginal = TRUE;
231 grlc_data->func.dl_blocks.data_ptr.rx_no++;
232 #ifdef TI_PS_16BIT_CPY
233 api_memcpy(&grlc_data->func.dl_blocks.data_ptr.dl_data[pos],
234 &in_ptr[31 * i + 1],
235 31 * sizeof(API) ); /*lint !e420*/
236 #else
237 memcpy(&grlc_data->func.dl_blocks.data_ptr.dl_data[pos],
238 &in_ptr[31 * i + 1],
239 31 * sizeof(API) ); /*lint !e420*/
240 #endif
241 pos++;
242 }
243 else
244 { /* CRC error */
245 grlc_data->nr_of_crc_errors++;
246 crc_cnt++;
247 }
248 }
249 }
250 else
251 { /* call error */
252 grlc_data->dl_cnt_asyn = grlc_data->dl_cnt_syn;
253 call_err = 0xFF;
254 TRACE_ERROR("DL CALL ERROR");
255 }
256
257 grlc_data->dl_cnt_syn++;
258
259 if(send_psginal)
260 {
261 PSIGNAL(hCommGRLC,MAC_DATA_IND, (&grlc_data->func.mac_data_ind) );
262 }
263 else
264 {
265 grlc_data->dl_cnt_asyn++; /*no signal to GFF, inc asynchronus counter*/
266 if(data_ptr->rx_no NEQ crc_cnt)
267 {
268 TRACE_EVENT_P3("NO DL DATA: rx_no= %d crc_err=%d call_err= %d",data_ptr->rx_no, crc_cnt,call_err);
269 }
270 }
271
272 /* new interface */
273 grlc_data->func.mac_ready_ind.rlc_blocks_sent = rlc_blocks_sent;
274 grlc_data->func.mac_ready_ind.last_poll_resp = last_poll_response;
275 grlc_data->func.mac_ready_ind.fn = fn;
276 grlc_data->ul_fn = fn;
277
278 /* adapte uplink framenumber from downlink framenumber */
279 if((grlc_data->ul_fn % 13) EQ 12)
280 grlc_data->ul_fn++;
281 grlc_data->ul_fn %= FN_MAX;
282
283 PSIGNAL(hCommGRLC, MAC_READY_IND, &(grlc_data->func.mac_ready_ind));
284
285 return;
286 } /* rlc_downlink() */
287
288
289 #endif /* _TARGET_ */