|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of the DWlanLogicalDevice class. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 18 % |
|
20 */ |
|
21 |
|
22 #include "WlLddWlanLddConfig.h" |
|
23 #include "WlanLogicalDevice.h" |
|
24 #include "WlanLogicalChannel.h" |
|
25 #include "wlanlddcommon.h" |
|
26 #include "osachunk.h" |
|
27 #include <kern_priv.h> |
|
28 |
|
29 const TUint KWlanParseMask = KDeviceAllowUnit | KDeviceAllowPhysicalDevice; |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 DECLARE_STANDARD_LDD() |
|
36 { |
|
37 TraceDump(INIT_LEVEL, ("WLANLDD: allocate logical device object")); |
|
38 |
|
39 // alloc the device |
|
40 |
|
41 #ifndef RD_WLAN_DDK |
|
42 return new DWlanLogicalDevice; |
|
43 |
|
44 #else |
|
45 DWlanLogicalDevice* logicalDevice( new DWlanLogicalDevice ); |
|
46 |
|
47 if ( !(logicalDevice->IsValid()) ) |
|
48 { |
|
49 // something went wrong |
|
50 delete logicalDevice; |
|
51 logicalDevice = NULL; |
|
52 } |
|
53 |
|
54 return logicalDevice; |
|
55 #endif |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 DWlanLogicalDevice::DWlanLogicalDevice() |
|
63 : |
|
64 iDfcQ( NULL ), |
|
65 #ifndef RD_WLAN_DDK |
|
66 iMutex( NULL ), |
|
67 #else |
|
68 iOsa( NULL ), |
|
69 #endif |
|
70 iUseCachedMemory( EFalse ), |
|
71 iRxFrameMemoryPool( NULL ), |
|
72 iRxBufAlignmentPadding( 0 ) |
|
73 { |
|
74 TraceDump(INIT_LEVEL, (("WLANLDD: DWlanLogicalDevice Ctor: 0x%08x"), this)); |
|
75 |
|
76 iParseMask = KWlanParseMask; |
|
77 iUnitsMask = KWlanUnitsAllowedMask; |
|
78 |
|
79 TraceDump(INIT_LEVEL, (("iUnitsMask: 0x%08x"), iUnitsMask)); |
|
80 TraceDump(INIT_LEVEL, (("iParseMask: 0x%08x"), iParseMask)); |
|
81 |
|
82 iVersion = TVersion(KWlanDriverMajorVersion,KWlanDriverMinorVersion,KWlanDriverBuildVersion); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 DWlanLogicalDevice::~DWlanLogicalDevice() |
|
90 { |
|
91 TraceDump(INIT_LEVEL, ("WLANLDD: DWlanLogicalDevice dtor")); |
|
92 |
|
93 delete iRxFrameMemoryPool; |
|
94 iRxFrameMemoryPool = NULL; |
|
95 |
|
96 #ifndef RD_WLAN_DDK |
|
97 |
|
98 if ( iMutex ) |
|
99 { |
|
100 TraceDump(MUTEX, ("WLANLDD: DWlanLogicalDevice dtor: close the mutex")); |
|
101 iMutex->Close( NULL ); |
|
102 iMutex = NULL; |
|
103 } |
|
104 |
|
105 #else |
|
106 |
|
107 if ( iOsa ) |
|
108 { |
|
109 TraceDump(MEMORY, (("WLANLDD: delete WlanOsa: 0x%08x"), |
|
110 reinterpret_cast<TUint32>(iOsa))); |
|
111 |
|
112 delete iOsa; |
|
113 iOsa = NULL; |
|
114 } |
|
115 |
|
116 #endif // RD_WLAN_DDK |
|
117 |
|
118 if( iDfcQ ) |
|
119 { |
|
120 TraceDump(MEMORY, (("WLANLDD: delete DFC queue: 0x%08x"), |
|
121 reinterpret_cast<TUint32>(iDfcQ))); |
|
122 |
|
123 iDfcQ->Destroy(); |
|
124 } |
|
125 |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 TInt DWlanLogicalDevice::Create( DLogicalChannelBase *&aChannel ) |
|
133 { |
|
134 TraceDump(INIT_LEVEL, ("WLANLDD: DWlanLogicalDevice::Create")); |
|
135 |
|
136 TInt ret = KErrNoMemory; |
|
137 |
|
138 // UMAC exists we may proceed |
|
139 |
|
140 aChannel = |
|
141 |
|
142 #ifndef RD_WLAN_DDK |
|
143 new DWlanLogicalChannel( |
|
144 *this, |
|
145 iUmac, |
|
146 *iDfcQ, |
|
147 *iMutex, |
|
148 iSharedMemoryChunk, |
|
149 iRxFrameMemoryPool ); |
|
150 #else |
|
151 new DWlanLogicalChannel( |
|
152 *this, |
|
153 iUmac, |
|
154 *iDfcQ, |
|
155 iOsa, |
|
156 iSharedMemoryChunk, |
|
157 iRxFrameMemoryPool ); |
|
158 #endif |
|
159 |
|
160 if ( aChannel ) |
|
161 { |
|
162 ret = KErrNone; |
|
163 } |
|
164 else |
|
165 { |
|
166 // allocation failed |
|
167 TraceDump(WARNING_LEVEL, |
|
168 ("WLANLDD: DWlanLogicalDevice::Create: logical channel allocation failure")); |
|
169 } |
|
170 |
|
171 return ret; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TInt DWlanLogicalDevice::Install() |
|
179 { |
|
180 TraceDump(INIT_LEVEL, ("WLANLDD: DWlanLogicalDevice::Install")); |
|
181 |
|
182 _LIT(KWlanDdThreadName, "WlanDdThread"); |
|
183 const TInt KWlanDdThreadPriority = 27; |
|
184 TInt ret( 0 ); |
|
185 |
|
186 // create our own DFC queue (and thread) |
|
187 ret = Kern::DynamicDfcQCreate( |
|
188 iDfcQ, |
|
189 KWlanDdThreadPriority, |
|
190 KWlanDdThreadName ); |
|
191 |
|
192 if ( ret != KErrNone ) |
|
193 { |
|
194 TraceDump(ERROR_LEVEL, |
|
195 ("WLANLDD: DWlanLogicalDevice::Install: DFC queue creation failed -> aborting")); |
|
196 return ret; |
|
197 } |
|
198 else |
|
199 { |
|
200 TraceDump(MEMORY, (("WLANLDD: new DFC queue: 0x%08x"), |
|
201 reinterpret_cast<TUint32>(iDfcQ))); |
|
202 } |
|
203 |
|
204 #ifndef RD_WLAN_DDK |
|
205 ret = Kern::MutexCreate( iMutex, KNullDesC, KMutexOrdGeneral7); |
|
206 TraceDump(MUTEX, |
|
207 (("WLANLDD: DWlanLogicalDevice::Install: mutex create; status: %d"), |
|
208 ret)); |
|
209 |
|
210 if ( ret ) |
|
211 { |
|
212 // mutex creation failed |
|
213 TraceDump(ERROR_LEVEL, |
|
214 ("WLANLDD: DWlanLogicalDevice::Install: mutex creation failed -> aborting")); |
|
215 ret = KErrGeneral; |
|
216 } |
|
217 |
|
218 #else |
|
219 |
|
220 // create OSA |
|
221 |
|
222 iOsa = new WlanOsa(); |
|
223 |
|
224 if ( iOsa ) |
|
225 { |
|
226 TraceDump(MEMORY, (("WLANLDD: new WlanOsa: 0x%08x"), |
|
227 reinterpret_cast<TUint32>(iOsa))); |
|
228 |
|
229 if ( !( iOsa->IsValid() ) ) |
|
230 { |
|
231 // OSA is not valid. That's fatal |
|
232 // OSA object instance will be deallocated in the destructor |
|
233 |
|
234 TraceDump(ERROR_LEVEL, |
|
235 ("WLANLDD: DWlanLogicalDevice::Install: osa not valid, abort")); |
|
236 |
|
237 ret = KErrGeneral; |
|
238 } |
|
239 } |
|
240 else |
|
241 { |
|
242 // allocation failed |
|
243 |
|
244 TraceDump(ERROR_LEVEL, |
|
245 ("WLANLDD: DWlanLogicalDevice::Install: osa alloc failed, abort")); |
|
246 ret = KErrNoMemory; |
|
247 } |
|
248 |
|
249 #endif |
|
250 |
|
251 if ( !ret ) |
|
252 { |
|
253 // init the UMac |
|
254 if ( iUmac.Init() ) |
|
255 { |
|
256 const TPtrC name= LDD_NAME; |
|
257 ret = SetName(&name); |
|
258 |
|
259 } |
|
260 else |
|
261 { |
|
262 TraceDump(WARNING_LEVEL, |
|
263 ("WLANLDD: DWlanLogicalDevice::Install: UMAC init failed -> aborting ")); |
|
264 |
|
265 ret = KErrGeneral; |
|
266 } |
|
267 } |
|
268 |
|
269 return ret; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 // --------------------------------------------------------------------------- |
|
275 // |
|
276 void DWlanLogicalDevice::GetCaps(TDes8& aDes) const |
|
277 { |
|
278 TraceDump(INIT_LEVEL, ("WLANLDD: DWlanLogicalDevice::GetCaps")); |
|
279 |
|
280 DWlanLogicalDevice::TCaps caps; |
|
281 caps.iVersion=iVersion; |
|
282 // write back to user mode |
|
283 Kern::InfoCopy( aDes, reinterpret_cast<TUint8*>(&caps), sizeof(caps) ); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 TBool DWlanLogicalDevice::UseCachedMemory() const |
|
291 { |
|
292 return iUseCachedMemory; |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 void DWlanLogicalDevice::UseCachedMemory( TBool aValue ) |
|
300 { |
|
301 iUseCachedMemory = aValue; |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void DWlanLogicalDevice::SetRxBufAlignmentPadding( |
|
309 TInt aRxBufAlignmentPadding ) |
|
310 { |
|
311 iRxBufAlignmentPadding = aRxBufAlignmentPadding; |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 TInt DWlanLogicalDevice::RxBufAlignmentPadding() const |
|
319 { |
|
320 return iRxBufAlignmentPadding; |
|
321 } |