comparison src/g23m-gprs/sndcp/sndcp_suf.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 : sndcp_suf.c
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 SNDCP and implements all
18 | procedures and functions as described in the
19 | SDL-documentation (SU-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 /*---- HISTORY --------------------------------------------------------------*/
24
25 #define ENTITY_SNDCP
26
27 /*==== INCLUDES =============================================================*/
28
29 #include "typedefs.h" /* to get Condat data types */
30 #include "vsi.h" /* to get a lot of macros */
31 #include "macdef.h"
32 #include "prim.h" /* to get the definitions of used SAP and directions */
33
34 #include "dti.h"
35
36 #include "sndcp.h" /* to get the global entity definitions */
37 #include "sndcp_f.h" /* to get the functions to access the global arrays*/
38
39 #include "sndcp_nus.h" /* to get signals to service nu */
40 #include "sndcp_cias.h" /* to get signals to service cia */
41
42 /*==== CONST ================================================================*/
43
44 /*==== LOCAL VARS ===========================================================*/
45
46 /*==== PRIVATE FUNCTIONS ====================================================*/
47
48 /*==== PUBLIC FUNCTIONS =====================================================*/
49 #ifdef _SNDCP_DTI_2_
50
51 /*
52 +------------------------------------------------------------------------------
53 | Function : su_get_nsapi
54 +------------------------------------------------------------------------------
55 | Description : finde the affected nsapi in sn-PDU.
56 |
57 | Parameters : ll_unitdata_req*
58 | Returns : the nsapi
59 |
60 +------------------------------------------------------------------------------
61 */
62 GLOBAL U8 su_get_nsapi (T_LL_UNITDESC_REQ* ll_unitdesc_req)
63 {
64 T_desc3* desc3 = NULL;
65 U8 * sndcp_header = NULL;
66
67 /* Get the descriptor describing the memory area with the sndcp header */
68
69 desc3 = (T_desc3*)ll_unitdesc_req->desc_list3.first;
70 sndcp_header = (U8*)desc3->buffer;
71
72 TRACE_FUNCTION( "su_get_nsapi" );
73
74 return (*(sndcp_header + ENCODE_OFFSET_BYTE)) & 0xf;
75 } /* sua_get_nsapi() */
76
77 #else /* _SNDCP_DTI_2_ */
78
79 /*
80 +------------------------------------------------------------------------------
81 | Function : su_get_nsapi
82 +------------------------------------------------------------------------------
83 | Description : finde the affected nsapi in sn-PDU.
84 |
85 | Parameters : ll_unitdata_req*
86 | Returns : the nsapi
87 |
88 +------------------------------------------------------------------------------
89 */
90 GLOBAL UBYTE su_get_nsapi (T_LL_UNITDATA_REQ* ll_unitdata_req)
91 {
92 USHORT octet_offset = (ll_unitdata_req->sdu.o_buf) >> 3;
93
94 TRACE_FUNCTION( "su_get_nsapi" );
95
96 return ll_unitdata_req->sdu.buf[octet_offset] & 0xf;
97
98 } /* su_get_nsapi() */
99
100 #endif /* _SNDCP_DTI_2_ */
101
102 /*
103 +------------------------------------------------------------------------------
104 | Function : su_init
105 +------------------------------------------------------------------------------
106 | Description : The function su_init() ....
107 |
108 | Parameters :
109 |
110 +------------------------------------------------------------------------------
111 */
112 GLOBAL void su_init (void)
113 {
114 TRACE_FUNCTION( "su_init" );
115
116 /*
117 * Not initialized:
118 * Members of sn_unitdata_q are not set to NULL.
119 * Members of npdu_number_q are not set to 0.
120 * Members of ll_unitdata_q are not set to NULL.
121 */
122
123 sndcp_data->su = & sndcp_data->su_base[0];
124 INIT_STATE(SU_0, SU_LLC_NOT_RECEPTIVE);
125 #ifdef SNDCP_2to1
126 sndcp_data->su->sapi = PS_SAPI_3;
127 #else
128 sndcp_data->su->sapi = LL_SAPI_3;
129 #endif /*SNDCP_2to1*/
130
131 sndcp_data->su = & sndcp_data->su_base[1];
132 INIT_STATE(SU_1, SU_LLC_NOT_RECEPTIVE);
133 #ifdef SNDCP_2to1
134 sndcp_data->su->sapi = PS_SAPI_5;
135 #else
136 sndcp_data->su->sapi = LL_SAPI_5;
137 #endif /*SNDCP_2to1*/
138
139 sndcp_data->su = & sndcp_data->su_base[2];
140 INIT_STATE(SU_2, SU_LLC_NOT_RECEPTIVE);
141 #ifdef SNDCP_2to1
142 sndcp_data->su->sapi = PS_SAPI_9;
143 #else
144 sndcp_data->su->sapi = LL_SAPI_9;
145 #endif /*SNDCP_2to1*/
146
147 sndcp_data->su = & sndcp_data->su_base[3];
148 INIT_STATE(SU_3, SU_LLC_NOT_RECEPTIVE);
149 #ifdef SNDCP_2to1
150 sndcp_data->su->sapi = PS_SAPI_11;
151 #else
152 sndcp_data->su->sapi = LL_SAPI_11;
153 #endif /*SNDCP_2to1*/
154 {
155 UBYTE sapi_index = 0;
156
157 for (sapi_index = 0; sapi_index < SNDCP_NUMBER_OF_SAPIS; sapi_index++) {
158 sndcp_data->su = & sndcp_data->su_base[sapi_index];
159 sndcp_data->su->n201_u = N201_U_DEFAULT;
160 sndcp_data->su->sn_unitdata_q_read = 0;
161 sndcp_data->su->sn_unitdata_q_write = 0;
162 #ifdef _SNDCP_DTI_2_
163 sndcp_data->su->ll_unitdesc_q_read = 0;
164 sndcp_data->su->ll_unitdesc_q_write = 0;
165 #else /* _SNDCP_DTI_2_ */
166 sndcp_data->su->ll_unitdata_q_read = 0;
167 sndcp_data->su->ll_unitdata_q_write = 0;
168 #endif /* _SNDCP_DTI_2_ */
169 sndcp_data->su->cia_state = CIA_IDLE;
170 }
171 }
172
173
174
175 } /* su_init() */
176
177
178 /*
179 +------------------------------------------------------------------------------
180 | Function : su_next_sn_unitdata_req
181 +------------------------------------------------------------------------------
182 | Description : If queue with sn_unitdata_req is
183 | not empty, send SIG_SU_CIA_DATA_REQ with next prim from sn_unitdata_req queue
184 |
185 | Parameters : sapi
186 | Pre : cia_state == CIA_IDLE
187 |
188 +------------------------------------------------------------------------------
189 */
190 GLOBAL void su_next_sn_unitdata_req (UBYTE sapi)
191 {
192 TRACE_FUNCTION( "su_next_sn_unitdata_req" );
193
194 if (sndcp_data->su->sn_unitdata_q_write !=
195 sndcp_data->su->sn_unitdata_q_read) {
196 /*
197 * Get sn_unitdata_req from queue.
198 */
199 T_SN_UNITDATA_REQ* sn_unitdata_req =
200 sndcp_data->su->sn_unitdata_q[sndcp_data->su->sn_unitdata_q_read];
201 /*
202 * Get npdu_number from queue.
203 */
204 USHORT npdu_num =
205 sndcp_data->su->npdu_number_q[sndcp_data->su->sn_unitdata_q_read];
206 UBYTE nsapi = sn_unitdata_req->nsapi;
207
208 sndcp_data->su->sn_unitdata_q[sndcp_data->su->sn_unitdata_q_read] = NULL;
209 sndcp_data->su->sn_unitdata_q_read =
210 (sndcp_data->su->sn_unitdata_q_read + 1 ) % SN_UNITDATA_Q_LEN;
211
212 /*
213 * Cia is now busy. Send data.
214 */
215 sndcp_data->su->cia_state = CIA_BUSY;
216 sig_su_cia_cia_comp_req(sn_unitdata_req,
217 npdu_num,
218 nsapi,
219 sapi);
220 } else if (sndcp_data->su->cia_state == CIA_IDLE) {
221 UBYTE nsapi = 0;
222
223 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) {
224 UBYTE used_sapi = 0;
225 BOOL used = FALSE;
226
227 sndcp_is_nsapi_used(nsapi, &used);
228 if (used) {
229 sndcp_get_nsapi_sapi(nsapi, &used_sapi);
230 if (used_sapi == sapi) {
231 sig_su_nu_ready_ind(nsapi);
232 }
233 }
234 }
235 }
236
237
238 } /* su_next_sn_unitdata_req() */
239