comparison src/aci2/aci/psa_pktiop.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +------------------------------------------------------------------------------
3 | File: psa_pktiop.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +------------------------------------------------------------------------------
16 | Purpose: This module defines the processing functions for the
17 | primitives send to the protocol stack adapter by the
18 | packet i/o managment (MNPKTIO).
19 +------------------------------------------------------------------------------
20 */
21
22 #ifdef GPRS
23 #ifdef FF_PKTIO
24 #ifndef PSA_PKTIOP_C
25 #define PSA_PKTIOP_C
26 #endif
27
28 #include "aci_all.h"
29 /*==== INCLUDES ===================================================*/
30 #include "dti.h" /* functionality of the dti library */
31 #include "aci_cmh.h"
32 #include "ati_cmd.h"
33 #include "aci_cmd.h"
34 #include "aci_lst.h"
35 #include "aci_mem.h"
36 #include "aci.h"
37 #include "psa.h"
38 #include "psa_pktio.h"
39
40 #include "cmh.h"
41 /*#include "dti_mng.h"*/
42 #include "dti_conn_mng.h"
43 #include "dti_cntrl_mng.h"
44 #include "cmh_pktio.h"
45
46
47 /*==== CONSTANTS ==================================================*/
48
49
50 /*==== TYPES ======================================================*/
51 GLOBAL T_ACI_LIST *pktio_dev_list=NULL;
52
53
54 /*==== EXPORT =====================================================*/
55
56
57 /*==== VARIABLES ==================================================*/
58
59
60 /*==== FUNCTIONS ==================================================*/
61 LOCAL BOOL find_pkt_dev_no ( UBYTE deviceNum, void * elem );
62 LOCAL BOOL mng_pkt_dev_list ( T_PKT_CONNECT_IND *pkt_connect_ind );
63 /*
64 +----------------------------------------------------------------------+
65 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
66 | STATE : finished ROUTINE : find_pkt_dev_no |
67 +----------------------------------------------------------------------+
68
69 PURPOSE : search pktio device number in pktio device list
70 */
71 LOCAL BOOL find_pkt_dev_no ( UBYTE deviceNum, void * elem )
72 {
73 T_ACI_PKTIO *compared = (T_ACI_PKTIO *)elem;
74
75 if (compared NEQ NULL)
76 if (compared->device_no EQ deviceNum )
77 return TRUE;
78 return FALSE;
79 }
80
81 /*
82 +----------------------------------------------------------------------+
83 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
84 | STATE : finished ROUTINE : mng_pkt_dev_list |
85 +----------------------------------------------------------------------+
86
87 PURPOSE : manage pktio device list
88 */
89 LOCAL BOOL mng_pkt_dev_list ( T_PKT_CONNECT_IND *pkt_connect_ind )
90 {
91 T_ACI_PKTIO * msg_ptr = NULL;
92
93 if(pktio_dev_list EQ NULL)
94 {/* there is no pktio device list */
95 pktio_dev_list = new_list();
96 }
97 msg_ptr = find_element(pktio_dev_list, pkt_connect_ind->device_no,
98 find_pkt_dev_no);
99 if(msg_ptr EQ NULL)
100 {/* added new device */
101 if((pkt_connect_ind->dio_dcb.convergence >= DTI_CPBLTY_CMD )
102 AND
103 (pkt_connect_ind->dio_dcb.convergence <=(DTI_CPBLTY_CMD|DTI_CPBLTY_PKT|DTI_CPBLTY_SER)))
104 {
105 ACI_MALLOC(msg_ptr,sizeof(T_ACI_PKTIO));
106 msg_ptr->device_no = pkt_connect_ind->device_no;
107 memcpy(&msg_ptr->pktio_cap, &pkt_connect_ind->dio_dcb,sizeof(T_ACI_PKTIO_CAP));
108 insert_list(pktio_dev_list,msg_ptr);
109 return (TRUE);
110 }
111 else
112 {/* neither CMD, SER nor PKT mode */
113 return (FALSE);
114 }
115 }
116 else
117 {/* new DIO capabilities for existing device */
118 return (FALSE);
119 }
120 }
121
122 /*
123 +----------------------------------------------------------------------+
124 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
125 | STATE : finished ROUTINE : psa_pkt_connect_ind |
126 +----------------------------------------------------------------------+
127
128 PURPOSE : processes the PKT_CONNECTION_IND primitive send by PKTIO.
129 add new device to pktio device list
130 register the DIO capabilities in ACI
131 */
132 GLOBAL const void psa_pkt_connect_ind ( T_PKT_CONNECT_IND *pkt_connect_ind )
133 {
134 T_ACI_PKTIO * msg_ptr;
135
136 TRACE_FUNCTION ("psa_pkt_connect_ind()");
137
138 if(mng_pkt_dev_list(pkt_connect_ind) EQ TRUE)
139 {
140 msg_ptr = find_element(pktio_dev_list, pkt_connect_ind->device_no,
141 find_pkt_dev_no);
142 cmhPKT_Ind(msg_ptr);
143 }
144 else
145 {/* second PKT_CONNECT_IND from same device or wrong convergence (mode) in
146 DIO capabilities */
147 psaPKT_ConnectRej(pkt_connect_ind->device_no);
148 }
149 /* free the primitive buffer */
150 PFREE (pkt_connect_ind);
151 }
152
153 /*
154 +----------------------------------------------------------------------+
155 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
156 | STATE : finished ROUTINE : psa_pkt_disconnect_ind |
157 +----------------------------------------------------------------------+
158
159 PURPOSE : processes the PKT_DISCONNECTION_IND primitive send by PKTIO.
160 Removes the device from the pktio device list.
161 */
162 GLOBAL const void psa_pkt_disconnect_ind ( T_PKT_DISCONNECT_IND *
163 pkt_disconnect_ind )
164 {
165
166 TRACE_FUNCTION ("psa_pkt_disconnect_ind()");
167
168 remove_element(pktio_dev_list, pkt_disconnect_ind->device_no, find_pkt_dev_no);
169
170 /* free the primitive buffer */
171 PFREE (pkt_disconnect_ind);
172 }
173
174 /*
175 +----------------------------------------------------------------------+
176 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
177 | STATE : finished ROUTINE : psa_pkt_dti_close_cnf |
178 +----------------------------------------------------------------------+
179
180 PURPOSE : processes the PKT_DTI_CLOSE_CNF primitive send by PKTIO.
181 this confirms the dti disconnection requested by PKT_DTI_CLOSE_REQ
182 */
183 GLOBAL const void psa_pkt_dti_close_cnf ( T_PKT_DTI_CLOSE_CNF *
184 pkt_dti_close_cnf )
185 {
186 T_ACI_PKTIO * msg_ptr;
187
188 TRACE_FUNCTION ("psa_pkt_dti_close_cnf()");
189 msg_ptr = find_element(pktio_dev_list, pkt_dti_close_cnf->device_no,
190 find_pkt_dev_no);
191 /* if the device_no does not exist in the pktio_dev_list
192 the primitive is ignored */
193 if(msg_ptr NEQ NULL)
194 {
195 cmhPKT_Close(pkt_dti_close_cnf->device_no, DTI_CLOSE_CNF);
196 }
197 /* free the primitive buffer */
198 PFREE (pkt_dti_close_cnf);
199 }
200
201 /*
202 +----------------------------------------------------------------------+
203 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
204 | STATE : finished ROUTINE : psa_pkt_dti_close_ind |
205 +----------------------------------------------------------------------+
206
207 PURPOSE : processes the PKT_DTI_CLOSE_IND primitive send by PKTIO.
208 this indicates the dti disconnection caused by the DIO driver
209 */
210 GLOBAL const void psa_pkt_dti_close_ind ( T_PKT_DTI_CLOSE_IND *
211 pkt_dti_close_ind )
212 {
213 T_ACI_PKTIO * msg_ptr;
214
215 TRACE_FUNCTION ("psa_pkt_dti_close_ind()");
216
217 msg_ptr = find_element(pktio_dev_list, pkt_dti_close_ind->device_no,
218 find_pkt_dev_no);
219 /* if the device_no does not exist in the pktio_dev_list
220 the primitive is ignored */
221 if(msg_ptr NEQ NULL)
222 {
223 cmhPKT_Close(pkt_dti_close_ind->device_no, DTI_CLOSE_IND);
224 }
225 /* free the primitive buffer */
226 PFREE (pkt_dti_close_ind);
227 }
228
229 /*
230 +----------------------------------------------------------------------+
231 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
232 | STATE : finished ROUTINE : psa_pkt_dti_open_cnf |
233 +----------------------------------------------------------------------+
234
235 PURPOSE : processes the PKT_DTI_OPEN_CNF primitive send by PKTIO.
236 this confirms the dti connection requested by PKT_DTI_OPEN_REQ
237 */
238 GLOBAL const void psa_pkt_dti_open_cnf ( T_PKT_DTI_OPEN_CNF *
239 pkt_dti_open_cnf )
240 {
241 T_ACI_PKTIO * msg_ptr;
242
243 TRACE_FUNCTION ("psa_pkt_dti_open_cnf()");
244
245 msg_ptr = find_element(pktio_dev_list, pkt_dti_open_cnf->device_no,
246 find_pkt_dev_no);
247 /* if the device_no does not exist in the pktio_dev_list
248 the primitive is ignored */
249 if(msg_ptr NEQ NULL)
250 {
251 switch(pkt_dti_open_cnf->cause)
252 {
253 case PKTCS_SUCCESS:
254 cmhPKT_OpenCnf(pkt_dti_open_cnf->device_no,DTI_OK);
255 break;
256 case PKTCS_INVALID_PARAMS:
257 case PKTCS_INVALID_PEER:
258 case PKTCS_DISCONNECT:
259 case PKTCS_INTERNAL_DRV_ERROR:
260 default:
261 cmhPKT_OpenCnf(pkt_dti_open_cnf->device_no,DTI_ERROR);
262 break;
263 }
264 }
265 /* free the primitive buffer */
266 PFREE (pkt_dti_open_cnf);
267 }
268
269 /*
270 +----------------------------------------------------------------------+
271 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOP |
272 | STATE : finished ROUTINE : psa_pkt_modify_cnf |
273 +----------------------------------------------------------------------+
274
275 PURPOSE : processes the PKT_MODIFY_CNF primitive send by PKTIO.
276 this confirms the modification fo channel parameters
277 requested by PKT_MODIFY_REQ
278 */
279 GLOBAL const void psa_pkt_modify_cnf ( T_PKT_MODIFY_CNF *pkt_modify_cnf )
280 {
281 TRACE_FUNCTION ("psa_pkt_modify_cnf()");
282
283 /* free the primitive buffer */
284 PFREE (pkt_modify_cnf);
285 }
286 #endif /* FF_PKTIO */
287 #endif /* GPRS */
288 /*==== EOF =========================================================*/