comparison src/g23m-gprs/llc/llc_uitxp.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 :
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 modul is part of the entity LLC and implements all
18 | functions to handles the incoming primitives as described in
19 | the SDL-documentation (UITX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_UITXP_C
24 #define LLC_UITXP_C
25 #endif
26
27 #define ENTITY_LLC
28
29 /*==== INCLUDES =============================================================*/
30
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 "cnf_llc.h" /* to get cnf-definitions */
37 #include "mon_llc.h" /* to get mon-definitions */
38 #include "prim.h" /* to get the definitions of used SAP and directions */
39 #include "llc.h" /* to get the global entity definitions */
40 #include "llc_f.h"
41 #include "llc_uitxf.h" /* to get local UITX functions */
42 #include "llc_txs.h" /* to get signal interface to TX */
43 #include <string.h> /* to get memcpy */
44 /*==== CONST ================================================================*/
45
46 /*==== LOCAL VARS ===========================================================*/
47
48 /*==== PRIVATE FUNCTIONS ====================================================*/
49
50 /*==== PUBLIC FUNCTIONS =====================================================*/
51
52 /*
53 +------------------------------------------------------------------------------
54 | Function : uitx_ll_unitdesc_req
55 +------------------------------------------------------------------------------
56 | Description : Handles the primitive LL_UNITDESC_REQ
57 |
58 | Parameters : *ll_unitdesc_req - Ptr to primitive payload
59 |
60 +------------------------------------------------------------------------------
61 */
62 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
63 defined(LL_2to1) */
64
65 GLOBAL void uitx_ll_unitdesc_req
66 (
67 #ifdef LL_DESC
68 T_LL_UNITDESC_REQ *ll_unitdesc_req_
69 #else
70 T_LL_UNITDATA_REQ *ll_unitdesc_req_
71 #endif
72 )
73 {
74 /*
75 * Indicates if the frame shall be ciphered or not (LL_CIPHER_ON/OFF).
76 */
77 UBYTE cipher;
78 T_FRAME_NUM used_nu;
79 ULONG used_oc;
80
81 TRACE_FUNCTION( "uitx_ll_unitdesc_req" );
82
83 {
84 /*
85 * PPASS added to let the FRAME know that the primitive has to be copied
86 * now for duplicating primiives. Otherwise the changed primitie will be duplicated
87 */
88 #ifdef LL_DESC
89 PPASS (ll_unitdesc_req_, ll_unitdesc_req, LL_UNITDESC_REQ);
90 #else
91 PPASS (ll_unitdesc_req_, ll_unitdesc_req, LL_UNITDATA_REQ);
92 #endif
93
94 SWITCH_LLC (ll_unitdesc_req->sapi);
95 #ifdef REL99
96 llc_data->cur_pfi = ll_unitdesc_req->pkt_flow_id; /* store current packet flow identifier */
97 TRACE_EVENT_P1("packet flow id = %d",ll_unitdesc_req->pkt_flow_id);
98 #endif
99
100 llc_data->cur_qos = ll_unitdesc_req->ll_qos; /* store current QoS */
101 llc_data->cur_radio_prio = ll_unitdesc_req->radio_prio; /* store current radio prioirity */
102 /* The stored PFI,QOS and radio priority is later used to copy to PFI,QOS and radio priority
103 respectively of control messages like SABM,DM,XID response,etc. */
104 TRACE_EVENT_P1("radio priority = %d",ll_unitdesc_req->radio_prio);
105 TRACE_EVENT_P1("peak throughput = %d",ll_unitdesc_req->ll_qos.peak);
106
107 /*
108 * Overwrite cipher request on all SAPIs except GMM. They don't
109 * know anything about ciphering in current design.
110 */
111 if (ll_unitdesc_req->sapi != LL_SAPI_1)
112 {
113 if (llc_data->ciphering_algorithm == LLGMM_CIPHER_NO_ALGORITHM)
114 cipher = LL_CIPHER_OFF;
115 else
116 cipher = LL_CIPHER_ON;
117 }
118 else
119 {
120 cipher = ll_unitdesc_req->cipher;
121 }
122
123 #ifdef LL_DESC
124 TRACE_3_PARA("s:%d len:%d c:%d", ll_unitdesc_req->sapi,
125 ll_unitdesc_req->desc_list3.list_len,
126 cipher );
127 #else
128 TRACE_3_PARA("s:%d len:%d c:%d", ll_unitdesc_req->sapi,
129 BYTELEN(ll_unitdesc_req->sdu.l_buf),
130 cipher );
131 #endif
132
133 /*
134 * Set up the attached counter to CCI_NO_ATTACHE.
135 */
136 ll_unitdesc_req->attached_counter = CCI_NO_ATTACHE;
137
138 #ifdef REL99
139 /*
140 * Packet flow identifier is passed transparantly if data request is from SNDCP.
141 * If data request is from GMM fill PFI = LL_PFI_SIGNALING,
142 * If data request is from GSMS fill PFI = LL_PFI_SMS
143 * for all other SAPs(if sapi 2 & 8 are supported in future) set pkt_flow_id is to LL_PKT_FLOW_ID_NOT_PRES,
144 * until specification are clarified.
145 */
146 switch(ll_unitdesc_req->sapi)
147 {
148
149 case LL_SAPI_3:
150 case LL_SAPI_5:
151 case LL_SAPI_9:
152 case LL_SAPI_11:
153 /*Packet flow identifier is passed transparantly if data request is from SNDCP.*/
154 break;
155
156 case LL_SAPI_1:
157 /*
158 * From 24.008 & 23.060 it is interpreted that for all signalling data, a
159 * predefined PFI LL_PFI_SIGNALING shall be used.
160 */
161 ll_unitdesc_req->pkt_flow_id = LL_PFI_SIGNALING;
162 ll_unitdesc_req->ll_qos.peak = LL_PEAK_256K;
163 break;
164
165 case LL_SAPI_7:
166 /*
167 * From 24.008 & 23.060 it is interpreted that for all SMS data, a
168 * predefined PFI LL_PFI_SMS shall be used.
169 */
170 ll_unitdesc_req->pkt_flow_id = LL_PFI_SMS;
171 break;
172
173 default:
174 /*
175 * It is possible when system support llc sapi 2 and 8.
176 * Fill PFI valuse it LL_PKT_FLOW_ID_NOT_PRES, until it is clarified in the specifications.
177 */
178 ll_unitdesc_req->pkt_flow_id = LL_PKT_FLOW_ID_NOT_PRES;
179 break;
180 }
181 #endif /* REL99 */
182 /*
183 * In case of SAPI 7 (GSMS) all requests has to use the relclass LL_RLC_PROT.
184 */
185 if (ll_unitdesc_req->sapi EQ LL_SAPI_7)
186 {
187 ll_unitdesc_req->ll_qos.relclass = LL_RLC_PROT;
188 }
189
190 switch (GET_STATE(UITX))
191 {
192 case UITX_ADM_READY:
193 /*
194 * NOTE: uitx_build_ui_header expects desc_list3 to already contain data.
195 * The header is inserted _before_ the data, so desc_list3.o_buf is being
196 * decremented.
197 */
198 uitx_build_ui_header
199 (
200 #ifdef LL_DESC
201 &ll_unitdesc_req->desc_list3,
202 #else
203 &ll_unitdesc_req->sdu,
204 #endif
205 MS_COMMAND,
206 ll_unitdesc_req->sapi,
207 llc_data->uitx->vu,
208 cipher,
209 ll_unitdesc_req->ll_qos.relclass
210 );
211
212 used_nu = llc_data->uitx->vu;
213 used_oc = llc_data->sapi->oc_ui_tx;
214
215 llc_data->uitx->vu ++;
216
217 if (llc_data->uitx->vu > MAX_SEQUENCE_NUMBER)
218 {
219 llc_data->uitx->vu = 0;
220 llc_data->sapi->oc_ui_tx += (MAX_SEQUENCE_NUMBER+1);
221 }
222
223 SET_STATE (UITX, UITX_ADM_NOT_READY);
224
225 if (ll_unitdesc_req->ll_qos.relclass EQ LL_RLC_PROT)
226 {
227 /*
228 * Label S_DATA
229 */
230 if (ll_unitdesc_req->sapi EQ LL_SAPI_1)
231 {
232 sig_uitx_tx_data_req (ll_unitdesc_req, cipher, GRLC_DTACS_MOBILITY_MANAGEMENT, used_nu, used_oc);
233 }
234 else
235 {
236 sig_uitx_tx_data_req (ll_unitdesc_req, cipher, GRLC_DTACS_DEF, used_nu, used_oc);
237 }
238 }
239 else /* LL_PROT/LL_NO_REL */
240 {
241 /*
242 * Label S_UNITDATA
243 */
244 sig_uitx_tx_unitdata_req (ll_unitdesc_req, cipher, used_nu, used_oc);
245 }
246 break;
247
248 case UITX_TLLI_UNASSIGNED_READY:
249 /*
250 * LLC is not capable of sending data in state TLLI_UNASSIGNED.
251 */
252 #ifdef LL_DESC
253 llc_cl_desc3_free((T_desc3*)ll_unitdesc_req->desc_list3.first);
254 #endif
255 PFREE (ll_unitdesc_req);
256
257 SET_STATE (UITX, UITX_TLLI_UNASSIGNED_NOT_READY);
258 break;
259
260 default:
261 #ifdef LL_DESC
262 llc_cl_desc3_free((T_desc3*)ll_unitdesc_req->desc_list3.first);
263 #endif
264 PFREE (ll_unitdesc_req);
265
266 TRACE_ERROR( "ll_unitdesc_req unexpected" );
267 break;
268 }
269 }
270 }/* uitx_ll_unitdesc_req */
271
272 /*#endif*/ /* CF_FAST_EXEC || _SIMULATION_ */
273
274 /*
275 +------------------------------------------------------------------------------
276 | Function : uitx_ll_unitdata_req
277 +------------------------------------------------------------------------------
278 | Description : Handles the primitive LL_UNITDATA_REQ
279 |
280 | Parameters : *ll_unitdata_req - Ptr to primitive payload
281 |
282 +------------------------------------------------------------------------------
283 */
284 #ifdef LL_DESC
285
286 #ifndef CF_FAST_EXEC
287
288 GLOBAL void uitx_ll_unitdata_req (T_LL_UNITDATA_REQ *ll_unitdata_req)
289 {
290 T_desc3 *desc3 = NULL;
291 U16 len, offset;
292 U8 *buf;
293
294 TRACE_FUNCTION( "uitx_ll_unitdata_req" );
295
296 /*
297 * Allocate primitive and fill in the structure elements
298 */
299 {
300 PALLOC(ll_unitdesc_req, LL_UNITDESC_REQ);
301
302 ll_unitdesc_req->sapi = ll_unitdata_req->sapi;
303 ll_unitdesc_req->tlli = ll_unitdata_req->tlli;
304 ll_unitdesc_req->ll_qos = ll_unitdata_req->ll_qos;
305 ll_unitdesc_req->cipher = ll_unitdata_req->cipher;
306 ll_unitdesc_req->radio_prio = ll_unitdata_req->radio_prio;
307 ll_unitdesc_req->seg_pos = ll_unitdata_req->seg_pos;
308 ll_unitdesc_req->attached_counter = ll_unitdata_req->attached_counter;
309 #ifdef REL99
310 ll_unitdesc_req->pkt_flow_id = ll_unitdata_req->pkt_flow_id;
311 #endif /* REL99 */
312 /*
313 * Allocate memory block for simulating desc2 (desc3->buffer) and set the values of the
314 * desc3-elements.
315 */
316 len = ll_unitdata_req->sdu.l_buf >> 3; /* BIT to BYTE */
317 offset = ll_unitdata_req->sdu.o_buf >> 3; /* BIT to BYTE */
318
319 desc3 = llc_palloc_desc(len, offset); /* Only one desc3 and buffer is allocated */
320
321 buf= (U8*)desc3->buffer;
322
323 memcpy(&buf[desc3->offset],
324 &ll_unitdata_req->sdu.buf[offset],
325 len);
326
327 ll_unitdesc_req->desc_list3.first = (U32)desc3;
328 ll_unitdesc_req->desc_list3.list_len = desc3->len;
329
330
331 /*
332 * Primitive is handled in uitx_ll_unitdesc_req
333 */
334 uitx_ll_unitdesc_req (ll_unitdesc_req);
335 }
336 PFREE(ll_unitdata_req);
337
338 } /* uitx_ll_unitdata_req() */
339
340 #endif /* CF_FAST_EXEC */
341
342 #endif /* LL_DESC */