comparison src/g23m-fad/ppp/ppp_prxs.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
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 PPP and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (PRX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #define ENTITY_PPP
24
25 /*==== INCLUDES =============================================================*/
26
27 #include "typedefs.h" /* to get Condat data types */
28 #include "vsi.h" /* to get a lot of macros */
29 #include "macdef.h" /* to get a lot of macros */
30 #include "custom.h" /* to get a lot of macros */
31 /*lint -efile(766,gsm.h) */
32 #include "gsm.h" /* to get a lot of macros */
33 /*lint -efile(766,cnf_ppp.h) */
34 #include "cnf_ppp.h" /* to get cnf-definitions */
35 /*lint -efile(766,mon_ppp.h) */
36 #include "mon_ppp.h" /* to get mon-definitions */
37 #include "prim.h" /* to get the definitions of used SAP and directions */
38 #include "dti.h" /* to get the DTILIB definitions */
39 #include "ppp.h" /* to get the global entity definitions */
40
41 #include "ppp_arbf.h" /* to get arb functions */
42 #include "ppp_ftxs.h" /* to get signal interface from ftx */
43
44 #ifdef FF_STATUS_TE
45 #include "ste.h" /* To include function interface for TE status driver */
46 #include "gdi.h" /* To include driver type-defines */
47 #endif /* FF_STATUS_TE */
48
49 /*==== CONST ================================================================*/
50
51 /*==== LOCAL VARS ===========================================================*/
52
53 /*==== PRIVATE FUNCTIONS ====================================================*/
54
55 /*==== PUBLIC FUNCTIONS =====================================================*/
56
57 /*
58 +------------------------------------------------------------------------------
59 | Function : sig_ftx_prx_start_flow_req
60 +------------------------------------------------------------------------------
61 | Description : Handles the internal signal SIG_FTX_PRX_START_FLOW_REQ.
62 | It is sent in case the ftx service is able
63 | to send the next packet.
64 |
65 | Parameters : no parameters
66 |
67 +------------------------------------------------------------------------------
68 */
69 GLOBAL void sig_ftx_prx_start_flow_req ()
70 {
71 TRACE_ISIG( "sig_ftx_prx_start_flow_req" );
72
73 switch( GET_STATE( PPP_SERVICE_PRX ) )
74 {
75 case PRX_READY:
76 {
77 /*
78 * Tell DTILIB that PRX can start to receive data primitives again
79 */
80 dti_start(ppp_data->ppphDTI, PPP_INSTANCE, PROT_LAYER, PROT_CHANNEL);
81 }
82 break;
83
84 case PRX_NDTI:
85 /*
86 * store signal for later activation
87 */
88 SET_STATE( PPP_SERVICE_PRX, PRX_NDTI_START_FLOW );
89 break;
90
91 case PRX_NDTI_START_FLOW:
92 /*
93 * silently ignore duplicate signal..
94 */
95 break;
96
97 default:
98 TRACE_ERROR( "SIG_FTX_PRX_START_FLOW_REQ unexpected" );
99 break;
100 }
101 } /* sig_ftx_prx_start_flow_req() */
102
103
104
105 /*
106 +------------------------------------------------------------------------------
107 | Function : sig_ftx_prx_stop_flow_req
108 +------------------------------------------------------------------------------
109 | Description : Handles the internal signal SIG_FTX_PRX_STOP_FLOW_REQ.
110 | It is sent in case the ftx service is able
111 | to send the next packet.
112 |
113 | Parameters : no parameters
114 |
115 +------------------------------------------------------------------------------
116 */
117 GLOBAL void sig_ftx_prx_stop_flow_req ()
118 {
119 TRACE_ISIG( "sig_ftx_prx_stop_flow_req" );
120
121 switch( GET_STATE( PPP_SERVICE_PRX ) )
122 {
123 case PRX_READY:
124 /*
125 * Tell DTILIB that PRX does not want to receive data primitives
126 */
127 dti_stop(ppp_data->ppphDTI, PPP_INSTANCE, PROT_LAYER, PROT_CHANNEL);
128 break;
129
130 case PRX_NDTI_START_FLOW:
131 /*
132 * Send a stop signal to DTI
133 */
134 SET_STATE( PPP_SERVICE_PRX, PRX_NDTI );
135 break;
136
137 case PRX_NDTI:
138 /*
139 * silently ignore duplicate signal..
140 */
141 break;
142
143 default:
144 TRACE_ERROR( "SIG_PTX_PRX_STOP_FLOW_REQ unexpected" );
145 break;
146 }
147 } /* sig_ftx_prx_stop_flow_req() */
148
149
150
151 /*
152 +------------------------------------------------------------------------------
153 | Function : sig_ftx_prx_dead_mode_req
154 +------------------------------------------------------------------------------
155 | Description : Handles the release of buffered data in case of PPP link
156 | termination
157 |
158 | Parameters : None
159 |
160 +------------------------------------------------------------------------------
161 */
162 GLOBAL void sig_ftx_prx_dead_mode_req ()
163 {
164 TRACE_FUNCTION( "sig_ftx_prx_dead_mode_req()" );
165
166 #ifdef FF_STATUS_TE
167 /*
168 * Release buffered data - if any...
169 */
170 MFREE_DESC2(ppp_data->prx.TE_data_buffer_desc_list_first);
171 ppp_data->prx.TE_data_buffer_desc_list_first = NULL;
172 ppp_data->prx.TE_data_buffer_p_id = DTI_PID_UOS;
173 ppp_data->prx.TE_data_buffered = FALSE;
174 #endif /* FF_STATUS_TE */
175
176 switch( GET_STATE( PPP_SERVICE_PRX ) )
177 {
178 case PRX_READY:
179 case PRX_NDTI_START_FLOW:
180 case PRX_NDTI:
181 SET_STATE( PPP_SERVICE_PRX, PRX_DEAD );
182 break;
183
184 default:
185 TRACE_ERROR( "SIG_PTX_PRX_DEAD_MODE_REQ unexpected" );
186 break;
187 }
188 } /* sig_ftx_prx_dead_mode_req() */
189
190 /*
191 +------------------------------------------------------------------------------
192 | Function : sig_ftx_prx_ready_mode_req
193 +------------------------------------------------------------------------------
194 | Description : sets prx to ready mode
195
196 | Parameters : None
197 |
198 +------------------------------------------------------------------------------
199 */
200 GLOBAL void sig_ftx_prx_ready_mode_req ()
201 {
202 TRACE_FUNCTION( "sig_ftx_prx_ready_mode_req()" );
203
204 switch( GET_STATE( PPP_SERVICE_PRX ) )
205 {
206 case PRX_DEAD:
207 SET_STATE( PPP_SERVICE_PRX, PRX_NDTI );
208 break;
209
210 case PRX_DEAD_DTI:
211 SET_STATE( PPP_SERVICE_PRX, PRX_READY );
212 break;
213
214 default:
215 TRACE_ERROR( "SIG_FTX_PRX_READY_MODE_REQ unexpected" );
216 break;
217 }
218 } /* sig_ftx_prx_ready_mode_req() */
219
220
221 /*
222 +------------------------------------------------------------------------------
223 | Function : sig_arb_prx_dti_connected_req
224 +------------------------------------------------------------------------------
225 | Description : Handles the internal signal SIG_ARB_PRX_DTI_CONNECTED_REQ
226 |
227 | Parameters : no parameters
228 |
229 +------------------------------------------------------------------------------
230 */
231 GLOBAL void sig_arb_prx_dti_connected_req ()
232 {
233 TRACE_ISIG( "sig_arb_prx_dti_connected_req" );
234
235 switch( GET_STATE( PPP_SERVICE_PRX ) )
236 {
237 case PRX_DEAD:
238 SET_STATE( PPP_SERVICE_PRX, PRX_DEAD_DTI );
239 break;
240 case PRX_NDTI:
241 SET_STATE( PPP_SERVICE_PRX, PRX_READY );
242 break;
243 case PRX_NDTI_START_FLOW:
244 SET_STATE( PPP_SERVICE_PRX, PRX_READY );
245 /*
246 * Send a start signal to DTI
247 */
248 dti_start(ppp_data->ppphDTI, PPP_INSTANCE, PROT_LAYER, PROT_CHANNEL);
249 break;
250 default:
251 TRACE_ERROR( "SIG_ARB_PRX_DTI_CONNECTED_REQ unexpected" );
252 break;
253 }
254 } /* sig_arb_prx_dti_connected_req() */
255
256
257 /*
258 +------------------------------------------------------------------------------
259 | Function : sig_dti_prx_data_received_ind
260 +------------------------------------------------------------------------------
261 | Description : Handles the signal SIG_DTI_PRX_DATA_RECEIVED_IND
262 |
263 | Parameters : dti_data_ind - Ptr to primitive payload
264 |
265 +------------------------------------------------------------------------------
266 */
267 GLOBAL void sig_dti_prx_data_received_ind(T_DTI2_DATA_IND *dti_data_ind)
268 {
269 TRACE_FUNCTION( "sig_dti_prx_data_received_ind" );
270 PACCESS(dti_data_ind);
271
272 switch( GET_STATE( PPP_SERVICE_PRX ) )
273 {
274 case PRX_READY:
275 #ifdef FF_STATUS_TE
276 if(ppp_data->mode EQ PPP_SERVER)
277 {
278 /*
279 * Check if TE is awake and ready to receive data...
280 * DRV_OK means it's awake
281 * DRV_IN_PROGRESS means is was a sleep and processing a wake up
282 * - await callback when TE is awake
283 */
284 if (DRV_OK EQ STE_Write(STE_IDENTIFIER_POWER,
285 STE_POWER_ON,
286 STE_POWER_ON))
287 {
288 #ifdef _SIMULATION_
289 TRACE_EVENT( "Return DRV_OK from STE_Write()" );
290 #endif /* _SIMULATION_ */
291 sig_any_ftx_packet_req(dti_data_ind->p_id,
292 (T_desc2*)dti_data_ind->desc_list2.first);
293 }
294 else
295 {
296 #ifdef _SIMULATION_
297 TRACE_EVENT( "Return DRV_IN_PROCESS from STE_Write()" );
298 #endif /* _SIMULATION_ */
299 /*
300 * The TE is asleep and data can NOT be forwarded but must be buffered
301 * Buffer p_id and desc_list until TE is awake and ready
302 * but free old stored packets before
303 */
304 MFREE_DESC2(ppp_data->prx.TE_data_buffer_desc_list_first);
305 ppp_data->prx.TE_data_buffered = TRUE;
306 ppp_data->prx.TE_data_buffer_p_id = dti_data_req->p_id;
307 ppp_data->
308 prx.TE_data_buffer_desc_list_first = (T_desc2*)dti_data_req->
309 desc_list2.first;
310 }
311 }
312 else
313 #endif /* FF_STATUS_TE */
314 {
315 sig_any_ftx_packet_req(dti_data_ind->parameters.p_id,
316 (T_desc2*)dti_data_ind->desc_list2.first);
317 }
318 break;
319
320 default:
321 TRACE_ERROR( "DTI signal unexpected" );
322 arb_discard_packet((T_desc2*)dti_data_ind->desc_list2.first);
323 break;
324 }
325 PFREE (dti_data_ind);
326 } /* sig_dti_prx_data_received_ind() */
327
328
329
330 #ifdef FF_STATUS_TE
331 /*
332 +------------------------------------------------------------------------------
333 | Function : new_power_status_TE
334 +------------------------------------------------------------------------------
335 | Description : Handles the signal NEW_POWER_STATUS
336 |
337 | Parameters : None
338 |
339 +------------------------------------------------------------------------------
340 */
341 GLOBAL void new_power_status_TE ( void )
342 {
343 ULONG ste_power_status;
344 UBYTE temp_p_id;
345 T_desc2* temp_desc;
346 USHORT ret_value;
347
348 TRACE_FUNCTION( "new_power_status_TE" );
349
350 if (ppp_data->prx.TE_data_buffered)
351 {
352 /*
353 * Check if TE power status is ON or OFF...
354 */
355 ret_value = STE_Read(STE_IDENTIFIER_POWER, &ste_power_status);
356
357 if(ret_value NEQ DRV_OK)
358 {
359 TRACE_ERROR( "TE status driver error" );
360 }
361 /*
362 * If this read operation fails (return ERROR) there must be a
363 * driver problem so we do not care about the driver and forward the data.
364 * If power status of the TE is ON we also forward the data
365 * If driver is OK, there are buffered data and TE is powered OFF
366 * We try to turn on the TE. In case the write operation returns OK and
367 * not INPROCESS we also forward the data
368 */
369 if((ret_value NEQ DRV_OK) ||
370 (ste_power_status EQ STE_POWER_ON) ||
371 (DRV_OK EQ STE_Write(STE_IDENTIFIER_POWER,
372 STE_POWER_ON,
373 STE_POWER_ON)))
374 {
375 /*
376 * reset store variables
377 */
378 temp_desc = ppp_data->prx.TE_data_buffer_desc_list_first;
379 temp_p_id = ppp_data->prx.TE_data_buffer_p_id;
380 ppp_data->prx.TE_data_buffer_desc_list_first = NULL;
381 ppp_data->prx.TE_data_buffer_p_id = DTI_PID_UOS;
382 ppp_data->prx.TE_data_buffered = FALSE;
383 /*
384 * forward stored data
385 */
386 sig_any_ftx_packet_req(temp_p_id, temp_desc);
387 }
388 }
389 } /* new_power_status_TE() */
390 #endif /* FF_STATUS_TE */
391