comparison src/g23m-gprs/sndcp/sndcp_sup.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 : sndcp_sup.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 | functions to handles the incoming primitives as described in
19 | the SDL-documentation (SU-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 /*---- HISTORY --------------------------------------------------------------*/
24
25
26 #define ENTITY_SNDCP
27
28 /*==== INCLUDES =============================================================*/
29
30 #include "typedefs.h" /* to get Condat data types */
31 #include "vsi.h" /* to get a lot of macros */
32 #include "macdef.h"
33 #include "prim.h" /* to get the definitions of used SAP and directions */
34
35 #include "dti.h"
36
37 #include "sndcp.h" /* to get the global entity definitions */
38 #include "sndcp_f.h" /* to get the functions to access the global arrays*/
39
40 #include "sndcp_suf.h" /* to get internal functions of service su */
41 #include "sndcp_nus.h" /* to get signal functions to service nu */
42
43 /*==== CONST ================================================================*/
44
45 /*==== LOCAL VARS ===========================================================*/
46
47 /*==== PRIVATE FUNCTIONS ====================================================*/
48
49 /*==== PUBLIC FUNCTIONS =====================================================*/
50
51
52
53
54 #ifdef _SNDCP_DTI_2_
55 /*
56 +------------------------------------------------------------------------------
57 | Function : su_ll_unitready_ind
58 +------------------------------------------------------------------------------
59 | Description : Handles the primitive LL_UNITREADY_IND
60 |
61 | Parameters : *ll_unitready_ind - Ptr to primitive payload
62 |
63 +------------------------------------------------------------------------------
64 */
65 GLOBAL void su_ll_unitready_ind ( T_LL_UNITREADY_IND *ll_unitready_ind )
66 {
67 U8 sapi_index = 0;
68
69
70 TRACE_FUNCTION( "su_ll_unitready_ind" );
71 #ifdef FLOW_TRACE
72 sndcp_trace_flow_control(FLOW_TRACE_SNDCP,
73 FLOW_TRACE_UP,
74 FLOW_TRACE_BOTTOM,
75 TRUE);
76 #endif
77 /*
78 * set service instance according to sapi in primitive
79 */
80 sndcp_get_sapi_index(ll_unitready_ind->sapi, &sapi_index);
81 sndcp_data->su = & sndcp_data->su_base[sapi_index];
82
83 switch( GET_STATE( SU ) )
84 {
85 case SU_LLC_NOT_RECEPTIVE_SUSPEND:
86 /*
87 * Is queue with outgoing LL_UNITDESC_REQs empty?
88 */
89 if (sndcp_data->su->ll_unitdesc_q_read ==
90 sndcp_data->su->ll_unitdesc_q_write) {
91 if (sndcp_data->su->cia_state == CIA_IDLE) {
92 su_next_sn_unitdata_req(ll_unitready_ind->sapi);
93 }
94 }
95 SET_STATE(SU, SU_LLC_RECEPTIVE_SUSPEND);
96 break;
97 case SU_LLC_RECEPTIVE_SUSPEND:
98 break;
99 case SU_LLC_NOT_RECEPTIVE:
100 /*
101 * Is queue with outgoing LL_UNITDESC_REQs empty?
102 */
103 if (sndcp_data->su->ll_unitdesc_q_read ==
104 sndcp_data->su->ll_unitdesc_q_write) {
105
106 SET_STATE(SU, SU_LLC_RECEPTIVE);
107 if (sndcp_data->su->cia_state == CIA_IDLE) {
108 su_next_sn_unitdata_req(ll_unitready_ind->sapi);
109 }
110
111 } else { /* sndcp_data->su.ll_unitdesc_q is not empty */
112 /*
113 * Send next ll_unitdesc_req from queue.
114 */
115 U8 ll_unitdesc_seg_pos;
116 U8 ll_unitdesc_nsapi;
117 U8 ll_unitdesc_sapi;
118
119 T_LL_UNITDESC_REQ* ll_unitdesc_req =
120 sndcp_data->su->ll_unitdesc_q[sndcp_data->su->ll_unitdesc_q_read];
121
122 sndcp_data->su->ll_unitdesc_q[sndcp_data->su->ll_unitdesc_q_read] =
123 NULL;
124
125 sndcp_data->su->ll_unitdesc_q_read =
126 (sndcp_data->su->ll_unitdesc_q_read + 1) %
127 SNDCP_SEGMENT_NUMBERS_UNACK;
128
129 #ifdef SNDCP_TRACE_ALL
130 TRACE_EVENT("uplink with sn header at LL SAP: ");
131 TRACE_EVENT_P1("%d octets",
132 ll_unitdesc_req->desc_list3.list_len);
133
134 sndcp_trace_desc_list3_content(ll_unitdesc_req->desc_list3);
135
136 #endif
137 #ifdef FLOW_TRACE
138 sndcp_trace_flow_control(FLOW_TRACE_SNDCP,
139 FLOW_TRACE_UP,
140 FLOW_TRACE_BOTTOM,
141 FALSE);
142 #endif
143 ll_unitdesc_seg_pos = ll_unitdesc_req->seg_pos;
144 ll_unitdesc_nsapi = su_get_nsapi(ll_unitdesc_req);
145 ll_unitdesc_sapi = ll_unitdesc_req->sapi;
146
147
148 #ifdef _SIMULATION_
149 su_send_ll_unitdata_req_test(ll_unitdesc_req);
150 #else /* _SIMULATION_ */
151 PSEND(hCommLLC, ll_unitdesc_req);
152 #endif /* _SIMULATION_ */
153
154 if ((ll_unitdesc_seg_pos & SEG_POS_LAST) > 0) {
155 sig_su_nu_ready_ind( ll_unitdesc_nsapi );
156 su_next_sn_unitdata_req( ll_unitdesc_sapi );
157 sndcp_data->su->cia_state = CIA_IDLE;
158 }
159
160 } /* sndcp_data->su.ll_unitdesc_q is not empty */
161 break;
162 case SU_LLC_RECEPTIVE:
163 break;
164 default:
165 TRACE_ERROR( "LL_UNITREADY_IND unexpected" );
166 break;
167 }
168 if (ll_unitready_ind != NULL) {
169 PFREE(ll_unitready_ind);
170 }
171
172 } /* su_ll_unitready_ind() */
173 #else /* _SNDCP_DTI_2_ */
174 /*
175 +------------------------------------------------------------------------------
176 | Function : su_ll_unitready_ind
177 +------------------------------------------------------------------------------
178 | Description : Handles the primitive LL_UNITREADY_IND
179 |
180 | Parameters : *ll_unitready_ind - Ptr to primitive payload
181 |
182 +------------------------------------------------------------------------------
183 */
184 GLOBAL void su_ll_unitready_ind ( T_LL_UNITREADY_IND *ll_unitready_ind )
185 {
186 UBYTE sapi_index = 0;
187
188
189 TRACE_FUNCTION( "su_ll_unitready_ind" );
190 #ifdef FLOW_TRACE
191 sndcp_trace_flow_control(FLOW_TRACE_SNDCP,
192 FLOW_TRACE_UP,
193 FLOW_TRACE_BOTTOM,
194 TRUE);
195 #endif
196 /*
197 * set service instance according to sapi in primitive
198 */
199 sndcp_get_sapi_index(ll_unitready_ind->sapi, &sapi_index);
200 sndcp_data->su = & sndcp_data->su_base[sapi_index];
201
202 switch( GET_STATE( SU ) )
203 {
204 case SU_LLC_NOT_RECEPTIVE_SUSPEND:
205 /*
206 * Is queue with outgoing LL_UNITDATA_REQs empty?
207 */
208 if (sndcp_data->su->ll_unitdata_q_read ==
209 sndcp_data->su->ll_unitdata_q_write) {
210 if (sndcp_data->su->cia_state == CIA_IDLE) {
211 su_next_sn_unitdata_req(ll_unitready_ind->sapi);
212 }
213 }
214 SET_STATE(SU, SU_LLC_RECEPTIVE_SUSPEND);
215 break;
216 case SU_LLC_RECEPTIVE_SUSPEND:
217 break;
218 case SU_LLC_NOT_RECEPTIVE:
219 /*
220 * Is queue with outgoing LL_UNITDATA_REQs empty?
221 */
222 if (sndcp_data->su->ll_unitdata_q_read ==
223 sndcp_data->su->ll_unitdata_q_write) {
224
225 SET_STATE(SU, SU_LLC_RECEPTIVE);
226 if (sndcp_data->su->cia_state == CIA_IDLE) {
227 su_next_sn_unitdata_req(ll_unitready_ind->sapi);
228 }
229
230 } else { /* sndcp_data->su.ll_unitdata_q is not empty */
231 /*
232 * Send next ll_unitdata_req from queue.
233 */
234 UBYTE ll_unitdata_seg_pos;
235 UBYTE ll_unitdata_nsapi;
236 UBYTE ll_unitdata_sapi;
237
238 T_LL_UNITDATA_REQ* ll_unitdata_req =
239 sndcp_data->su->ll_unitdata_q[sndcp_data->su->ll_unitdata_q_read];
240
241 sndcp_data->su->ll_unitdata_q[sndcp_data->su->ll_unitdata_q_read] =
242 NULL;
243
244 sndcp_data->su->ll_unitdata_q_read =
245 (sndcp_data->su->ll_unitdata_q_read + 1) %
246 SNDCP_SEGMENT_NUMBERS_UNACK;
247
248 #ifdef SNDCP_TRACE_ALL
249 TRACE_EVENT("uplink with sn header at LL SAP: ");
250 TRACE_EVENT_P1("%d octets",
251 (ll_unitdata_req->sdu.l_buf + 7) / 8);
252
253
254 sndcp_trace_sdu(& ll_unitdata_req->sdu);
255 #endif
256 #ifdef FLOW_TRACE
257 sndcp_trace_flow_control(FLOW_TRACE_SNDCP,
258 FLOW_TRACE_UP,
259 FLOW_TRACE_BOTTOM,
260 FALSE);
261 #endif
262 ll_unitdata_seg_pos = ll_unitdata_req->seg_pos;
263 ll_unitdata_nsapi = su_get_nsapi(ll_unitdata_req);
264 ll_unitdata_sapi = ll_unitdata_req->sapi;
265
266 PSEND (hCommLLC, ll_unitdata_req);
267
268 if ((ll_unitdata_seg_pos & SEG_POS_LAST) > 0) {
269 sig_su_nu_ready_ind( ll_unitdata_nsapi );
270 su_next_sn_unitdata_req( ll_unitdata_sapi );
271 sndcp_data->su->cia_state = CIA_IDLE;
272 }
273
274 } /* sndcp_data->su.ll_unitdata_q is not empty */
275 break;
276 case SU_LLC_RECEPTIVE:
277 break;
278 default:
279 TRACE_ERROR( "LL_UNITREADY_IND unexpected" );
280 break;
281 }
282 if (ll_unitready_ind != NULL) {
283 PFREE(ll_unitready_ind);
284 }
285
286 } /* su_ll_unitready_ind() */
287 #endif /* _SNDCP_DTI_2_ */
288
289
290