Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /* |
2 | ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/os/linux/include/gl_os.h#2 $ | |
3 | */ | |
4 | ||
5 | /*! \file gl_os.h | |
6 | \brief List the external reference to OS for GLUE Layer. | |
7 | ||
8 | In this file we define the data structure - GLUE_INFO_T to store those objects | |
9 | we acquired from OS - e.g. TIMER, SPINLOCK, NET DEVICE ... . And all the | |
10 | external reference (header file, extern func() ..) to OS for GLUE Layer should | |
11 | also list down here. | |
12 | */ | |
13 | ||
14 | ||
15 | ||
16 | /* | |
17 | ** $Log: gl_os.h $ | |
18 | ** | |
19 | ** 08 20 2012 yuche.tsai | |
20 | ** NULL | |
21 | ** Fix possible KE issue. | |
22 | ** | |
23 | ** 08 20 2012 yuche.tsai | |
24 | ** [ALPS00339327] [Rose][6575JB][BSP Package][Free Test][KE][WIFI]There is no response when you tap the turn off/on button,wait a minutes, the device will reboot automatically and "KE" will pop up. | |
25 | ** Fix possible KE when netlink operate mgmt frame register. | |
26 | * | |
27 | * 04 12 2012 terry.wu | |
28 | * NULL | |
29 | * Add AEE message support | |
30 | * 1) Show AEE warning(red screen) if SDIO access error occurs | |
31 | ||
32 | * | |
33 | * 03 02 2012 terry.wu | |
34 | * NULL | |
35 | * Enable CFG80211 Support. | |
36 | * | |
37 | * 01 05 2012 wh.su | |
38 | * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function | |
39 | * Adding the related ioctl / wlan oid function to set the Tx power cfg. | |
40 | * | |
41 | * 12 13 2011 cm.chang | |
42 | * [WCXRP00001136] [All Wi-Fi][Driver] Add wake lock for pending timer | |
43 | * Add wake lock if timer timeout value is smaller than 5 seconds | |
44 | * | |
45 | * 11 18 2011 yuche.tsai | |
46 | * NULL | |
47 | * CONFIG P2P support RSSI query, default turned off. | |
48 | * | |
49 | * 11 16 2011 yuche.tsai | |
50 | * NULL | |
51 | * Avoid using work thread. | |
52 | * | |
53 | * 11 11 2011 yuche.tsai | |
54 | * NULL | |
55 | * Fix work thread cancel issue. | |
56 | * | |
57 | * 10 12 2011 wh.su | |
58 | * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP | |
59 | * adding the 802.11w related function and define . | |
60 | * | |
61 | * 09 29 2011 terry.wu | |
62 | * NULL | |
63 | * Show DRV_NAME by chip id. | |
64 | * | |
65 | * 04 18 2011 terry.wu | |
66 | * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED | |
67 | * Remove flag CFG_WIFI_DIRECT_MOVED. | |
68 | * | |
69 | * 03 29 2011 cp.wu | |
70 | * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space process for RESET_START and RESET_END events | |
71 | * implement kernel-to-userspace communication via generic netlink socket for whole-chip resetting mechanism | |
72 | * | |
73 | * 03 21 2011 cp.wu | |
74 | * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer | |
75 | * portability improvement | |
76 | * | |
77 | * 03 17 2011 chinglan.wang | |
78 | * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature | |
79 | * . | |
80 | * | |
81 | * 03 03 2011 jeffrey.chang | |
82 | * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue | |
83 | * support concurrent network | |
84 | * | |
85 | * 03 03 2011 jeffrey.chang | |
86 | * [WCXRP00000512] [MT6620 Wi-Fi][Driver] modify the net device relative functions to support the H/W multiple queue | |
87 | * modify net device relative functions to support multiple H/W queues | |
88 | * | |
89 | * 03 02 2011 wh.su | |
90 | * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code | |
91 | * Add security check code. | |
92 | * | |
93 | * 02 21 2011 cp.wu | |
94 | * [WCXRP00000482] [MT6620 Wi-Fi][Driver] Simplify logic for checking NVRAM existence in driver domain | |
95 | * simplify logic for checking NVRAM existence only once. | |
96 | * | |
97 | * 02 16 2011 jeffrey.chang | |
98 | * NULL | |
99 | * Add query ipv4 and ipv6 address during early suspend and late resume | |
100 | * | |
101 | * 02 10 2011 chinghwa.yu | |
102 | * [WCXRP00000065] Update BoW design and settings | |
103 | * Fix kernel API change issue. | |
104 | * Before ALPS 2.2 (2.2 included), kfifo_alloc() is | |
105 | * struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock); | |
106 | * After ALPS 2.3, kfifo_alloc() is changed to | |
107 | * int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask); | |
108 | * | |
109 | * 02 09 2011 wh.su | |
110 | * [WCXRP00000433] [MT6620 Wi-Fi][Driver] Remove WAPI structure define for avoid P2P module with structure miss-align pointer issue | |
111 | * always pre-allio WAPI related structure for align p2p module. | |
112 | * | |
113 | * 02 09 2011 terry.wu | |
114 | * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules | |
115 | * Halt p2p module init and exit until TxThread finished p2p register and unregister. | |
116 | * | |
117 | * 02 01 2011 cm.chang | |
118 | * [WCXRP00000415] [MT6620 Wi-Fi][Driver] Check if any memory leakage happens when uninitializing in DGB mode | |
119 | * . | |
120 | * | |
121 | * 01 27 2011 cm.chang | |
122 | * [WCXRP00000402] [MT6620 Wi-Fi][Driver] Enable MCR read/write by iwpriv by default | |
123 | * . | |
124 | * | |
125 | * 01 12 2011 cp.wu | |
126 | * [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP | |
127 | * implementation of separate BT_OVER_WIFI data path. | |
128 | * | |
129 | * 01 12 2011 cp.wu | |
130 | * [WCXRP00000356] [MT6620 Wi-Fi][Driver] fill mac header length for security frames 'cause hardware header translation needs such information | |
131 | * fill mac header length information for 802.1x frames. | |
132 | * | |
133 | * 01 11 2011 chinglan.wang | |
134 | * NULL | |
135 | * Modify to reslove the CR :[ALPS00028994] Use WEP security to connect Marvell 11N AP. Connection establish successfully. | |
136 | * Use the WPS function to connect AP, the privacy bit always is set to 1. | |
137 | * | |
138 | * 01 10 2011 cp.wu | |
139 | * [WCXRP00000349] [MT6620 Wi-Fi][Driver] make kalIoctl() of linux port as a thread safe API to avoid potential issues due to multiple access | |
140 | * use mutex to protect kalIoctl() for thread safe. | |
141 | * | |
142 | * 01 05 2011 cp.wu | |
143 | * [WCXRP00000283] [MT6620 Wi-Fi][Driver][Wi-Fi Direct] Implementation of interface for supporting Wi-Fi Direct Service Discovery | |
144 | * ioctl implementations for P2P Service Discovery | |
145 | * | |
146 | * 11 04 2010 wh.su | |
147 | * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID | |
148 | * adding the p2p random ssid support. | |
149 | * | |
150 | * 10 18 2010 cp.wu | |
151 | * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android | |
152 | * complete implementation of Android NVRAM access | |
153 | * | |
154 | * 09 28 2010 wh.su | |
155 | * NULL | |
156 | * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo. | |
157 | * | |
158 | * 09 23 2010 cp.wu | |
159 | * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check | |
160 | * add skeleton for NVRAM integration | |
161 | * | |
162 | * 09 13 2010 cp.wu | |
163 | * NULL | |
164 | * add waitq for poll() and read(). | |
165 | * | |
166 | * 09 07 2010 wh.su | |
167 | * NULL | |
168 | * adding the code for beacon/probe req/ probe rsp wsc ie at p2p. | |
169 | * | |
170 | * 09 06 2010 wh.su | |
171 | * NULL | |
172 | * let the p2p can set the privacy bit at beacon and rsn ie at assoc req at key handshake state. | |
173 | * | |
174 | * 09 03 2010 kevin.huang | |
175 | * NULL | |
176 | * Refine #include sequence and solve recursive/nested #include issue | |
177 | * | |
178 | * 09 01 2010 wh.su | |
179 | * NULL | |
180 | * adding the wapi support for integration test. | |
181 | * | |
182 | * 08 31 2010 kevin.huang | |
183 | * NULL | |
184 | * Use LINK LIST operation to process SCAN result | |
185 | * | |
186 | * 08 23 2010 cp.wu | |
187 | * NULL | |
188 | * revise constant definitions to be matched with implementation (original cmd-event definition is deprecated) | |
189 | * | |
190 | * 08 16 2010 cp.wu | |
191 | * NULL | |
192 | * P2P packets are now marked when being queued into driver, and identified later without checking MAC address | |
193 | * | |
194 | * 08 16 2010 cp.wu | |
195 | * NULL | |
196 | * revised implementation of Wi-Fi Direct io controls. | |
197 | * | |
198 | * 08 11 2010 cp.wu | |
199 | * NULL | |
200 | * 1) do not use in-stack variable for beacon updating. (for MAUI porting) | |
201 | * 2) extending scanning result to 64 instead of 48 | |
202 | * | |
203 | * 08 06 2010 cp.wu | |
204 | * NULL | |
205 | * driver hook modifications corresponding to ioctl interface change. | |
206 | * | |
207 | * 08 03 2010 cp.wu | |
208 | * NULL | |
209 | * [Wi-Fi Direct] add framework for driver hooks | |
210 | * | |
211 | * 08 02 2010 jeffrey.chang | |
212 | * NULL | |
213 | * 1) modify tx service thread to avoid busy looping | |
214 | * 2) add spin lock declartion for linux build | |
215 | * | |
216 | * 07 23 2010 jeffrey.chang | |
217 | * | |
218 | * add new KAL api | |
219 | * | |
220 | * 07 22 2010 jeffrey.chang | |
221 | * | |
222 | * modify tx thread and remove some spinlock | |
223 | * | |
224 | * 07 19 2010 jeffrey.chang | |
225 | * | |
226 | * add security frame pending count | |
227 | * | |
228 | * 07 08 2010 cp.wu | |
229 | * | |
230 | * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository. | |
231 | * | |
232 | * 06 06 2010 kevin.huang | |
233 | * [WPD00003832][MT6620 5931] Create driver base | |
234 | * [MT6620 5931] Create driver base | |
235 | * | |
236 | * 06 01 2010 cp.wu | |
237 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
238 | * add ioctl to configure scan mode for p2p connection | |
239 | * | |
240 | * 05 31 2010 cp.wu | |
241 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
242 | * add cfg80211 interface, which is to replace WE, for further extension | |
243 | * | |
244 | * 05 14 2010 cp.wu | |
245 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
246 | * add ioctl framework for Wi-Fi Direct by reusing wireless extension ioctls as well | |
247 | * | |
248 | * 05 11 2010 cp.wu | |
249 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
250 | * p2p ioctls revised. | |
251 | * | |
252 | * 05 11 2010 cp.wu | |
253 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
254 | * add ioctl for controlling p2p scan phase parameters | |
255 | * | |
256 | * 05 10 2010 cp.wu | |
257 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
258 | * implement basic wi-fi direct framework | |
259 | * | |
260 | * 05 07 2010 jeffrey.chang | |
261 | * [WPD00003826]Initial import for Linux port | |
262 | * prevent supplicant accessing driver during resume | |
263 | * | |
264 | * 05 07 2010 cp.wu | |
265 | * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support | |
266 | * add basic framework for implementating P2P driver hook. | |
267 | * | |
268 | * 05 05 2010 cp.wu | |
269 | * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support | |
270 | * change variable names for multiple physical link to match with coding convention | |
271 | * | |
272 | * 04 27 2010 cp.wu | |
273 | * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support | |
274 | * identify BT Over Wi-Fi Security frame and mark it as 802.1X frame | |
275 | * | |
276 | * 04 27 2010 cp.wu | |
277 | * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support | |
278 | * add multiple physical link support | |
279 | * | |
280 | * 04 27 2010 jeffrey.chang | |
281 | * [WPD00003826]Initial import for Linux port | |
282 | * 1) fix firmware download bug | |
283 | * 2) remove query statistics for acelerating firmware download | |
284 | * | |
285 | * 04 27 2010 jeffrey.chang | |
286 | * [WPD00003826]Initial import for Linux port | |
287 | * follow Linux's firmware framework, and remove unused kal API | |
288 | * | |
289 | * 04 23 2010 cp.wu | |
290 | * [WPD00001943]Create WiFi test driver framework on WinXP | |
291 | * surpress compiler warning | |
292 | * | |
293 | * 04 19 2010 jeffrey.chang | |
294 | * [WPD00003826]Initial import for Linux port | |
295 | * supporting power management | |
296 | * | |
297 | * 04 14 2010 jeffrey.chang | |
298 | * [WPD00003826]Initial import for Linux port | |
299 | * pvInformationBuffer and u4InformationBufferLength are no longer in glue | |
300 | * | |
301 | * 04 13 2010 cp.wu | |
302 | * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support | |
303 | * add framework for BT-over-Wi-Fi support. | |
304 | * * * * * * * * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability | |
305 | * * * * * * * * * * * * * * * * * * * * 2) command sequence number is now increased atomically | |
306 | * * * * * * * * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose | |
307 | * | |
308 | * 04 07 2010 cp.wu | |
309 | * [WPD00001943]Create WiFi test driver framework on WinXP | |
310 | * rWlanInfo should be placed at adapter rather than glue due to most operations | |
311 | * * * * * * * * * * are done in adapter layer. | |
312 | * | |
313 | * 04 06 2010 jeffrey.chang | |
314 | * [WPD00003826]Initial import for Linux port | |
315 | * Tag the packet for QoS on Tx path | |
316 | * | |
317 | * 04 06 2010 jeffrey.chang | |
318 | * [WPD00003826]Initial import for Linux port | |
319 | * (1)deliver the kalOidComplete status to upper layer | |
320 | * * (2) fix spin lock | |
321 | * | |
322 | * 04 06 2010 jeffrey.chang | |
323 | * [WPD00003826]Initial import for Linux port | |
324 | * add timeout check in the kalOidComplete | |
325 | * | |
326 | * 04 06 2010 jeffrey.chang | |
327 | * [WPD00003826]Initial import for Linux port | |
328 | * improve none-glue code portability | |
329 | * | |
330 | * 04 06 2010 cp.wu | |
331 | * [WPD00001943]Create WiFi test driver framework on WinXP | |
332 | * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved | |
333 | * | |
334 | * 04 06 2010 cp.wu | |
335 | * [WPD00001943]Create WiFi test driver framework on WinXP | |
336 | * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer | |
337 | * | |
338 | * 03 30 2010 jeffrey.chang | |
339 | * [WPD00003826]Initial import for Linux port | |
340 | * emulate NDIS Pending OID facility | |
341 | * | |
342 | * 03 26 2010 jeffrey.chang | |
343 | * [WPD00003826]Initial import for Linux port | |
344 | * [WPD00003826] Initial import for Linux port | |
345 | * adding firmware download related data type | |
346 | * | |
347 | * 03 25 2010 cp.wu | |
348 | * [WPD00001943]Create WiFi test driver framework on WinXP | |
349 | * 1) correct OID_802_11_CONFIGURATION with frequency setting behavior. | |
350 | * * * * the frequency is used for adhoc connection only | |
351 | * * * * 2) update with SD1 v0.9 CMD/EVENT documentation | |
352 | * | |
353 | * 03 25 2010 cp.wu | |
354 | * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support | |
355 | * add Bluetooth-over-Wifi frame header check | |
356 | * | |
357 | * 03 24 2010 jeffrey.chang | |
358 | * [WPD00003826]Initial import for Linux port | |
359 | * initial import for Linux port | |
360 | ** \main\maintrunk.MT5921\30 2009-10-20 17:38:31 GMT mtk01090 | |
361 | ** Refine driver unloading and clean up procedure. Block requests, stop main thread and clean up queued requests, and then stop hw. | |
362 | ** \main\maintrunk.MT5921\29 2009-10-08 10:33:33 GMT mtk01090 | |
363 | ** Avoid accessing private data of net_device directly. Replace with netdev_priv(). Add more checking for input parameters and pointers. | |
364 | ** \main\maintrunk.MT5921\28 2009-09-28 20:19:26 GMT mtk01090 | |
365 | ** Add private ioctl to carry OID structures. Restructure public/private ioctl interfaces to Linux kernel. | |
366 | ** \main\maintrunk.MT5921\27 2009-08-18 22:57:12 GMT mtk01090 | |
367 | ** Add Linux SDIO (with mmc core) support. | |
368 | ** Add Linux 2.6.21, 2.6.25, 2.6.26. | |
369 | ** Fix compile warning in Linux. | |
370 | ** \main\maintrunk.MT5921\26 2009-07-06 21:42:25 GMT mtk01088 | |
371 | ** fixed the compiling error at linux | |
372 | ** \main\maintrunk.MT5921\25 2009-07-06 20:51:46 GMT mtk01088 | |
373 | ** adding the wapi 1x ether type define | |
374 | ** \main\maintrunk.MT5921\24 2009-06-23 23:19:18 GMT mtk01090 | |
375 | ** Add build option BUILD_USE_EEPROM and compile option CFG_SUPPORT_EXT_CONFIG for NVRAM support | |
376 | ** \main\maintrunk.MT5921\23 2009-02-07 15:05:06 GMT mtk01088 | |
377 | ** add the privacy flag to ingo driver the supplicant selected ap's security | |
378 | ** \main\maintrunk.MT5921\22 2009-02-05 15:34:09 GMT mtk01088 | |
379 | ** fixed the compiling error for using bits marco for only one parameter | |
380 | ** \main\maintrunk.MT5921\21 2009-01-22 13:02:13 GMT mtk01088 | |
381 | ** data frame is or not 802.1x value share with tid, using the same reserved byte, provide the function to set and get | |
382 | ** \main\maintrunk.MT5921\20 2008-10-24 12:04:16 GMT mtk01088 | |
383 | ** move the config.h from precomp.h to here for lint check | |
384 | ** \main\maintrunk.MT5921\19 2008-09-22 23:19:02 GMT mtk01461 | |
385 | ** Update driver for code review | |
386 | ** \main\maintrunk.MT5921\18 2008-09-05 17:25:13 GMT mtk01461 | |
387 | ** Update Driver for Code Review | |
388 | ** \main\maintrunk.MT5921\17 2008-08-01 13:32:47 GMT mtk01084 | |
389 | ** Prevent redundent driver assertion in driver logic when BUS is detached | |
390 | ** \main\maintrunk.MT5921\16 2008-05-30 14:41:43 GMT mtk01461 | |
391 | ** Remove WMM Assoc Flag in KAL | |
392 | ** \main\maintrunk.MT5921\15 2008-05-29 14:16:25 GMT mtk01084 | |
393 | ** remoev un-used variable | |
394 | ** \main\maintrunk.MT5921\14 2008-05-03 15:17:14 GMT mtk01461 | |
395 | ** Add Media Status variable in Glue Layer | |
396 | ** \main\maintrunk.MT5921\13 2008-04-24 11:58:41 GMT mtk01461 | |
397 | ** change threshold to 256 | |
398 | ** \main\maintrunk.MT5921\12 2008-03-11 14:51:05 GMT mtk01461 | |
399 | ** Remove redundant GL_CONN_INFO_T | |
400 | ** \main\maintrunk.MT5921\11 2008-01-07 15:07:41 GMT mtk01461 | |
401 | ** Adjust the netif stop threshold to 150 | |
402 | ** \main\maintrunk.MT5921\10 2007-11-26 19:43:46 GMT mtk01461 | |
403 | ** Add OS_TIMESTAMP macro | |
404 | ** | |
405 | ** \main\maintrunk.MT5921\9 2007-11-07 18:38:38 GMT mtk01461 | |
406 | ** Move definition | |
407 | ** \main\maintrunk.MT5921\8 2007-11-02 01:04:00 GMT mtk01461 | |
408 | ** Unify TX Path for Normal and IBSS Power Save + IBSS neighbor learning | |
409 | ** Revision 1.5 2007/07/12 11:04:28 MTK01084 | |
410 | ** update macro to delay for ms order | |
411 | ** | |
412 | ** Revision 1.4 2007/07/05 07:25:34 MTK01461 | |
413 | ** Add Linux initial code, modify doc, add 11BB, RF init code | |
414 | ** | |
415 | ** Revision 1.3 2007/06/27 02:18:51 MTK01461 | |
416 | ** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API | |
417 | ** | |
418 | ** Revision 1.2 2007/06/25 06:16:24 MTK01461 | |
419 | ** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API | |
420 | ** | |
421 | */ | |
422 | ||
423 | #ifndef _GL_OS_H | |
424 | #define _GL_OS_H | |
425 | ||
426 | /******************************************************************************* | |
427 | * C O M P I L E R F L A G S | |
428 | ******************************************************************************** | |
429 | */ | |
430 | /*------------------------------------------------------------------------------ | |
431 | * Flags for LINUX(OS) dependent | |
432 | *------------------------------------------------------------------------------ | |
433 | */ | |
434 | #define CFG_MAX_WLAN_DEVICES 1 /* number of wlan card will coexist */ | |
435 | ||
436 | #define CFG_MAX_TXQ_NUM 4 /* number of tx queue for support multi-queue h/w */ | |
437 | ||
438 | ||
439 | #define CFG_USE_SPIN_LOCK_BOTTOM_HALF 0 /* 1: Enable use of SPIN LOCK Bottom Half for LINUX | |
440 | 0: Disable - use SPIN LOCK IRQ SAVE instead */ | |
441 | ||
442 | #define CFG_TX_PADDING_SMALL_ETH_PACKET 0 /* 1: Enable - Drop ethernet packet if it < 14 bytes. | |
443 | And pad ethernet packet with dummy 0 if it < 60 bytes. | |
444 | 0: Disable */ | |
445 | ||
446 | #define CFG_TX_STOP_NETIF_QUEUE_THRESHOLD 256 /* packets */ | |
447 | ||
448 | #define CFG_TX_STOP_NETIF_PER_QUEUE_THRESHOLD 512 /* packets */ | |
449 | #define CFG_TX_START_NETIF_PER_QUEUE_THRESHOLD 128 /* packets */ | |
450 | ||
451 | ||
452 | #define ETH_P_1X 0x888E | |
453 | #define IPTOS_PREC_OFFSET 5 | |
454 | #define USER_PRIORITY_DEFAULT 0 | |
455 | ||
456 | #define ETH_WPI_1X 0x88B4 | |
457 | ||
458 | #define ETH_HLEN 14 | |
459 | #define ETH_TYPE_LEN_OFFSET 12 | |
460 | #define ETH_P_IP 0x0800 | |
461 | #define ETH_P_1X 0x888E | |
462 | #define ETH_P_PRE_1X 0x88C7 | |
463 | ||
464 | #define IPVERSION 4 | |
465 | #define IP_HEADER_LEN 20 | |
466 | ||
467 | #define IPVH_VERSION_OFFSET 4 /* For Little-Endian */ | |
468 | #define IPVH_VERSION_MASK 0xF0 | |
469 | #define IPTOS_PREC_OFFSET 5 | |
470 | #define IPTOS_PREC_MASK 0xE0 | |
471 | ||
472 | #define SOURCE_PORT_LEN 2 | |
473 | /* NOTE(Kevin): Without IP Option Length */ | |
474 | #define LOOK_AHEAD_LEN (ETH_HLEN + IP_HEADER_LEN + SOURCE_PORT_LEN) | |
475 | ||
476 | /* 802.2 LLC/SNAP */ | |
477 | #define ETH_LLC_OFFSET (ETH_HLEN) | |
478 | #define ETH_LLC_LEN 3 | |
479 | #define ETH_LLC_DSAP_SNAP 0xAA | |
480 | #define ETH_LLC_SSAP_SNAP 0xAA | |
481 | #define ETH_LLC_CONTROL_UNNUMBERED_INFORMATION 0x03 | |
482 | ||
483 | /* Bluetooth SNAP */ | |
484 | #define ETH_SNAP_OFFSET (ETH_HLEN + ETH_LLC_LEN) | |
485 | #define ETH_SNAP_LEN 5 | |
486 | #define ETH_SNAP_BT_SIG_OUI_0 0x00 | |
487 | #define ETH_SNAP_BT_SIG_OUI_1 0x19 | |
488 | #define ETH_SNAP_BT_SIG_OUI_2 0x58 | |
489 | ||
490 | #define BOW_PROTOCOL_ID_SECURITY_FRAME 0x0003 | |
491 | ||
492 | ||
493 | #if defined(MT6620) | |
494 | #define CHIP_NAME "MT6620" | |
495 | #elif defined(MT5931) | |
496 | #define CHIP_NAME "MT5931" | |
497 | #elif defined(MT6628) | |
498 | #define CHIP_NAME "MT6628" | |
499 | #endif | |
500 | ||
501 | #define DRV_NAME "["CHIP_NAME"]: " | |
502 | ||
503 | /* Define if target platform is Android. | |
504 | * It should already be defined in Android kernel source | |
505 | */ | |
506 | #ifndef CONFIG_ANDROID | |
507 | #define CONFIG_ANDROID 0 | |
508 | #endif | |
509 | ||
510 | /* for CFG80211 IE buffering mechanism */ | |
511 | #define CFG_CFG80211_IE_BUF_LEN (512) | |
512 | ||
513 | /******************************************************************************* | |
514 | * E X T E R N A L R E F E R E N C E S | |
515 | ******************************************************************************** | |
516 | */ | |
517 | #include <linux/version.h> /* constant of kernel version */ | |
518 | ||
519 | #include <linux/kernel.h> /* bitops.h */ | |
520 | ||
521 | #include <linux/timer.h> /* struct timer_list */ | |
522 | #include <linux/jiffies.h> /* jiffies */ | |
523 | #include <linux/delay.h> /* udelay and mdelay macro */ | |
524 | ||
525 | #if CONFIG_ANDROID | |
526 | #include <linux/wakelock.h> | |
527 | #endif | |
528 | ||
529 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12) | |
530 | #include <linux/irq.h> /* IRQT_FALLING */ | |
531 | #endif | |
532 | ||
533 | #include <linux/netdevice.h> /* struct net_device, struct net_device_stats */ | |
534 | #include <linux/etherdevice.h> /* for eth_type_trans() function */ | |
535 | #include <linux/wireless.h> /* struct iw_statistics */ | |
536 | #include <linux/if_arp.h> | |
537 | #include <linux/inetdevice.h> /* struct in_device */ | |
538 | ||
539 | #include <linux/ip.h> /* struct iphdr */ | |
540 | ||
541 | #include <linux/string.h> /* for memcpy()/memset() function */ | |
542 | #include <linux/stddef.h> /* for offsetof() macro */ | |
543 | ||
544 | #include <linux/proc_fs.h> /* The proc filesystem constants/structures */ | |
545 | ||
546 | #include <linux/rtnetlink.h> /* for rtnl_lock() and rtnl_unlock() */ | |
547 | #include <linux/kthread.h> /* kthread_should_stop(), kthread_run() */ | |
548 | #include <asm/uaccess.h> /* for copy_from_user() */ | |
549 | #include <linux/fs.h> /* for firmware download */ | |
550 | #include <linux/vmalloc.h> | |
551 | ||
552 | #include <linux/kfifo.h> /* for kfifo interface */ | |
553 | #include <linux/cdev.h> /* for cdev interface */ | |
554 | ||
555 | #include <linux/firmware.h> /* for firmware download */ | |
556 | ||
557 | #if defined(_HIF_SDIO) | |
558 | #include <linux/mmc/sdio.h> | |
559 | #include <linux/mmc/sdio_func.h> | |
560 | #endif | |
561 | ||
562 | #include <linux/random.h> | |
563 | ||
564 | #include <linux/lockdep.h> | |
565 | ||
566 | #include <asm/io.h> /* readw and writew */ | |
567 | ||
568 | #if WIRELESS_EXT > 12 | |
569 | #include <net/iw_handler.h> | |
570 | #endif | |
571 | ||
572 | #include "version.h" | |
573 | #include "config.h" | |
574 | ||
575 | #if CFG_ENABLE_WIFI_DIRECT_CFG_80211 | |
576 | #include <linux/wireless.h> | |
577 | #include <net/cfg80211.h> | |
578 | #endif | |
579 | ||
580 | #include <linux/module.h> | |
581 | ||
582 | #include "gl_typedef.h" | |
583 | #include "typedef.h" | |
584 | #include "queue.h" | |
585 | #include "gl_kal.h" | |
586 | #if CFG_CHIP_RESET_SUPPORT | |
587 | #include "gl_rst.h" | |
588 | #endif | |
589 | #include "hif.h" | |
590 | ||
591 | ||
592 | #include "debug.h" | |
593 | ||
594 | #include "wlan_lib.h" | |
595 | #include "wlan_oid.h" | |
596 | ||
597 | #if CFG_ENABLE_AEE_MSG | |
598 | #include <linux/aee.h> | |
599 | #endif | |
600 | ||
601 | extern BOOLEAN fgIsBusAccessFailed; | |
602 | ||
603 | /******************************************************************************* | |
604 | * C O N S T A N T S | |
605 | ******************************************************************************** | |
606 | */ | |
607 | #define GLUE_FLAG_HALT BIT(0) | |
608 | #define GLUE_FLAG_INT BIT(1) | |
609 | #define GLUE_FLAG_OID BIT(2) | |
610 | #define GLUE_FLAG_TIMEOUT BIT(3) | |
611 | #define GLUE_FLAG_TXREQ BIT(4) | |
612 | #define GLUE_FLAG_SUB_MOD_INIT BIT(5) | |
613 | #define GLUE_FLAG_SUB_MOD_EXIT BIT(6) | |
614 | #define GLUE_FLAG_SUB_MOD_MULTICAST BIT(7) | |
615 | #define GLUE_FLAG_FRAME_FILTER BIT(8) | |
616 | #define GLUE_FLAG_HALT_BIT (0) | |
617 | #define GLUE_FLAG_INT_BIT (1) | |
618 | #define GLUE_FLAG_OID_BIT (2) | |
619 | #define GLUE_FLAG_TIMEOUT_BIT (3) | |
620 | #define GLUE_FLAG_TXREQ_BIT (4) | |
621 | #define GLUE_FLAG_SUB_MOD_INIT_BIT (5) | |
622 | #define GLUE_FLAG_SUB_MOD_EXIT_BIT (6) | |
623 | #define GLUE_FLAG_SUB_MOD_MULTICAST_BIT (7) | |
624 | #define GLUE_FLAG_FRAME_FILTER_BIT (8) | |
625 | ||
626 | ||
627 | ||
628 | #define GLUE_BOW_KFIFO_DEPTH (1024) | |
629 | /* #define GLUE_BOW_DEVICE_NAME "MT6620 802.11 AMP" */ | |
630 | #define GLUE_BOW_DEVICE_NAME "ampc0" | |
631 | ||
632 | ||
633 | /******************************************************************************* | |
634 | * D A T A T Y P E S | |
635 | ******************************************************************************** | |
636 | */ | |
637 | typedef struct _GL_WPA_INFO_T { | |
638 | UINT_32 u4WpaVersion; | |
639 | UINT_32 u4KeyMgmt; | |
640 | UINT_32 u4CipherGroup; | |
641 | UINT_32 u4CipherPairwise; | |
642 | UINT_32 u4AuthAlg; | |
643 | BOOLEAN fgPrivacyInvoke; | |
644 | #if CFG_SUPPORT_802_11W | |
645 | UINT_32 u4Mfp; | |
646 | #endif | |
647 | } GL_WPA_INFO_T, *P_GL_WPA_INFO_T; | |
648 | ||
649 | typedef enum _ENUM_RSSI_TRIGGER_TYPE { | |
650 | ENUM_RSSI_TRIGGER_NONE, | |
651 | ENUM_RSSI_TRIGGER_GREATER, | |
652 | ENUM_RSSI_TRIGGER_LESS, | |
653 | ENUM_RSSI_TRIGGER_TRIGGERED, | |
654 | ENUM_RSSI_TRIGGER_NUM | |
655 | } ENUM_RSSI_TRIGGER_TYPE; | |
656 | ||
657 | #if CFG_ENABLE_WIFI_DIRECT | |
658 | typedef enum _ENUM_SUB_MODULE_IDX_T { | |
659 | P2P_MODULE = 0, | |
660 | SUB_MODULE_NUM | |
661 | } ENUM_SUB_MODULE_IDX_T; | |
662 | ||
663 | typedef enum _ENUM_NET_REG_STATE_T { | |
664 | ENUM_NET_REG_STATE_UNREGISTERED, | |
665 | ENUM_NET_REG_STATE_REGISTERING, | |
666 | ENUM_NET_REG_STATE_REGISTERED, | |
667 | ENUM_NET_REG_STATE_UNREGISTERING, | |
668 | ENUM_NET_REG_STATE_NUM | |
669 | } ENUM_NET_REG_STATE_T; | |
670 | ||
671 | #endif | |
672 | ||
673 | typedef struct _GL_IO_REQ_T { | |
674 | QUE_ENTRY_T rQueEntry; | |
675 | /* wait_queue_head_t cmdwait_q; */ | |
676 | BOOL fgRead; | |
677 | BOOL fgWaitResp; | |
678 | #if CFG_ENABLE_WIFI_DIRECT | |
679 | BOOL fgIsP2pOid; | |
680 | #endif | |
681 | P_ADAPTER_T prAdapter; | |
682 | PFN_OID_HANDLER_FUNC pfnOidHandler; | |
683 | PVOID pvInfoBuf; | |
684 | UINT_32 u4InfoBufLen; | |
685 | PUINT_32 pu4QryInfoLen; | |
686 | WLAN_STATUS rStatus; | |
687 | UINT_32 u4Flag; | |
688 | } GL_IO_REQ_T, *P_GL_IO_REQ_T; | |
689 | ||
690 | #if CFG_ENABLE_BT_OVER_WIFI | |
691 | typedef struct _GL_BOW_INFO { | |
692 | BOOLEAN fgIsRegistered; | |
693 | dev_t u4DeviceNumber; /* dynamic device number */ | |
694 | /* struct kfifo *prKfifo; /* for buffering indicated events */ */ | |
695 | struct kfifo rKfifo; /* for buffering indicated events */ | |
696 | spinlock_t rSpinLock; /* spin lock for kfifo */ | |
697 | struct cdev cdev; | |
698 | UINT_32 u4FreqInKHz; /* frequency */ | |
699 | ||
700 | UINT_8 aucRole[CFG_BOW_PHYSICAL_LINK_NUM]; /* 0: Responder, 1: Initiator */ | |
701 | ENUM_BOW_DEVICE_STATE aeState[CFG_BOW_PHYSICAL_LINK_NUM]; | |
702 | PARAM_MAC_ADDRESS arPeerAddr[CFG_BOW_PHYSICAL_LINK_NUM]; | |
703 | ||
704 | wait_queue_head_t outq; | |
705 | ||
706 | #if CFG_BOW_SEPARATE_DATA_PATH | |
707 | /* Device handle */ | |
708 | struct net_device *prDevHandler; | |
709 | BOOLEAN fgIsNetRegistered; | |
710 | #endif | |
711 | ||
712 | } GL_BOW_INFO, *P_GL_BOW_INFO; | |
713 | #endif | |
714 | ||
715 | /* | |
716 | * type definition of pointer to p2p structure | |
717 | */ | |
718 | typedef struct _GL_P2P_INFO_T GL_P2P_INFO_T, *P_GL_P2P_INFO_T; | |
719 | ||
720 | struct _GLUE_INFO_T { | |
721 | /* Device handle */ | |
722 | struct net_device *prDevHandler; | |
723 | ||
724 | /* Device Index(index of arWlanDevInfo[]) */ | |
725 | INT_32 i4DevIdx; | |
726 | ||
727 | /* Device statistics */ | |
728 | struct net_device_stats rNetDevStats; | |
729 | ||
730 | /* Wireless statistics struct net_device */ | |
731 | struct iw_statistics rIwStats; | |
732 | ||
733 | /* spinlock to sync power save mechanism */ | |
734 | spinlock_t rSpinLock[SPIN_LOCK_NUM]; | |
735 | ||
736 | /* semaphore for ioctl */ | |
737 | struct semaphore ioctl_sem; | |
738 | ||
739 | UINT_32 u4Flag; /* GLUE_FLAG_XXX */ | |
740 | UINT_32 u4PendFlag; | |
741 | /* UINT_32 u4TimeoutFlag; */ | |
742 | UINT_32 u4OidCompleteFlag; | |
743 | UINT_32 u4ReadyFlag; /* check if card is ready */ | |
744 | ||
745 | /* Number of pending frames, also used for debuging if any frame is | |
746 | * missing during the process of unloading Driver. | |
747 | * | |
748 | * NOTE(Kevin): In Linux, we also use this variable as the threshold | |
749 | * for manipulating the netif_stop(wake)_queue() func. | |
750 | */ | |
751 | INT_32 ai4TxPendingFrameNumPerQueue[4][CFG_MAX_TXQ_NUM]; | |
752 | INT_32 i4TxPendingFrameNum; | |
753 | INT_32 i4TxPendingSecurityFrameNum; | |
754 | ||
755 | /* current IO request for kalIoctl */ | |
756 | GL_IO_REQ_T OidEntry; | |
757 | ||
758 | /* registry info */ | |
759 | REG_INFO_T rRegInfo; | |
760 | ||
761 | /* firmware */ | |
762 | struct firmware *prFw; | |
763 | ||
764 | /* Host interface related information */ | |
765 | /* defined in related hif header file */ | |
766 | GL_HIF_INFO_T rHifInfo; | |
767 | ||
768 | /*! \brief wext wpa related information */ | |
769 | GL_WPA_INFO_T rWpaInfo; | |
770 | ||
771 | ||
772 | /* Pointer to ADAPTER_T - main data structure of internal protocol stack */ | |
773 | P_ADAPTER_T prAdapter; | |
774 | ||
775 | #ifdef WLAN_INCLUDE_PROC | |
776 | struct proc_dir_entry *pProcRoot; | |
777 | #endif /* WLAN_INCLUDE_PROC */ | |
778 | ||
779 | /* Indicated media state */ | |
780 | ENUM_PARAM_MEDIA_STATE_T eParamMediaStateIndicated; | |
781 | ||
782 | /* Device power state D0~D3 */ | |
783 | PARAM_DEVICE_POWER_STATE ePowerState; | |
784 | ||
785 | struct completion rScanComp; /* indicate scan complete */ | |
786 | struct completion rHaltComp; /* indicate main thread halt complete */ | |
787 | struct completion rPendComp; /* indicate main thread halt complete */ | |
788 | #if CFG_ENABLE_WIFI_DIRECT | |
789 | struct completion rSubModComp; /*indicate sub module init or exit complete */ | |
790 | #endif | |
791 | WLAN_STATUS rPendStatus; | |
792 | ||
793 | QUE_T rTxQueue; | |
794 | ||
795 | ||
796 | /* OID related */ | |
797 | QUE_T rCmdQueue; | |
798 | /* PVOID pvInformationBuffer; */ | |
799 | /* UINT_32 u4InformationBufferLength; */ | |
800 | /* PVOID pvOidEntry; */ | |
801 | /* PUINT_8 pucIOReqBuff; */ | |
802 | /* QUE_T rIOReqQueue; */ | |
803 | /* QUE_T rFreeIOReqQueue; */ | |
804 | ||
805 | wait_queue_head_t waitq; | |
806 | struct task_struct *main_thread; | |
807 | ||
808 | struct timer_list tickfn; | |
809 | ||
810 | ||
811 | #if CFG_SUPPORT_EXT_CONFIG | |
812 | UINT_16 au2ExtCfg[256]; /* NVRAM data buffer */ | |
813 | UINT_32 u4ExtCfgLength; /* 0 means data is NOT valid */ | |
814 | #endif | |
815 | ||
816 | #if 1 /* CFG_SUPPORT_WAPI */ | |
817 | /* Should be large than the PARAM_WAPI_ASSOC_INFO_T */ | |
818 | UINT_8 aucWapiAssocInfoIEs[42]; | |
819 | UINT_16 u2WapiAssocInfoIESz; | |
820 | #endif | |
821 | ||
822 | #if CFG_ENABLE_BT_OVER_WIFI | |
823 | GL_BOW_INFO rBowInfo; | |
824 | #endif | |
825 | ||
826 | #if CFG_ENABLE_WIFI_DIRECT | |
827 | P_GL_P2P_INFO_T prP2PInfo; | |
828 | #if CFG_SUPPORT_P2P_RSSI_QUERY | |
829 | /* Wireless statistics struct net_device */ | |
830 | struct iw_statistics rP2pIwStats; | |
831 | #endif | |
832 | #endif | |
833 | BOOLEAN fgWpsActive; | |
834 | UINT_8 aucWSCIE[500]; /*for probe req */ | |
835 | UINT_16 u2WSCIELen; | |
836 | UINT_8 aucWSCAssocInfoIE[200]; /*for Assoc req */ | |
837 | UINT_16 u2WSCAssocInfoIELen; | |
838 | ||
839 | /* NVRAM availability */ | |
840 | BOOLEAN fgNvramAvailable; | |
841 | ||
842 | BOOLEAN fgMcrAccessAllowed; | |
843 | ||
844 | /* MAC Address Overriden by IOCTL */ | |
845 | BOOLEAN fgIsMacAddrOverride; | |
846 | PARAM_MAC_ADDRESS rMacAddrOverride; | |
847 | ||
848 | SET_TXPWR_CTRL_T rTxPwr; | |
849 | ||
850 | /* for cfg80211 scan done indication */ | |
851 | struct cfg80211_scan_request *prScanRequest; | |
852 | ||
853 | /* to indicate registered or not */ | |
854 | BOOLEAN fgIsRegistered; | |
855 | ||
856 | /* for cfg80211 connected indication */ | |
857 | UINT_32 u4RspIeLength; | |
858 | UINT_8 aucRspIe[CFG_CFG80211_IE_BUF_LEN]; | |
859 | ||
860 | UINT_32 u4ReqIeLength; | |
861 | UINT_8 aucReqIe[CFG_CFG80211_IE_BUF_LEN]; | |
862 | }; | |
863 | ||
864 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) | |
865 | /* linux 2.4 */ | |
866 | typedef void (*PFN_WLANISR) (int irq, void *dev_id, struct pt_regs *regs); | |
867 | #else | |
868 | typedef irqreturn_t(*PFN_WLANISR) (int irq, void *dev_id, struct pt_regs *regs); | |
869 | #endif | |
870 | ||
871 | typedef void (*PFN_LINUX_TIMER_FUNC) (unsigned long); | |
872 | ||
873 | ||
874 | /* generic sub module init/exit handler | |
875 | * now, we only have one sub module, p2p | |
876 | */ | |
877 | #if CFG_ENABLE_WIFI_DIRECT | |
878 | typedef BOOLEAN(*SUB_MODULE_INIT) (P_GLUE_INFO_T prGlueInfo); | |
879 | typedef BOOLEAN(*SUB_MODULE_EXIT) (P_GLUE_INFO_T prGlueInfo); | |
880 | ||
881 | typedef struct _SUB_MODULE_HANDLER { | |
882 | SUB_MODULE_INIT subModInit; | |
883 | SUB_MODULE_EXIT subModExit; | |
884 | BOOLEAN fgIsInited; | |
885 | } SUB_MODULE_HANDLER, *P_SUB_MODULE_HANDLER; | |
886 | ||
887 | #endif | |
888 | ||
889 | #if CONFIG_NL80211_TESTMODE | |
890 | ||
891 | typedef struct _NL80211_DRIVER_TEST_MODE_PARAMS { | |
892 | UINT_32 index; | |
893 | UINT_32 buflen; | |
894 | } NL80211_DRIVER_TEST_MODE_PARAMS, *P_NL80211_DRIVER_TEST_MODE_PARAMS; | |
895 | ||
896 | /*SW CMD */ | |
897 | typedef struct _NL80211_DRIVER_SW_CMD_PARAMS { | |
898 | NL80211_DRIVER_TEST_MODE_PARAMS hdr; | |
899 | UINT_8 set; | |
900 | unsigned long adr; | |
901 | unsigned long data; | |
902 | } NL80211_DRIVER_SW_CMD_PARAMS, *P_NL80211_DRIVER_SW_CMD_PARAMS; | |
903 | ||
904 | struct iw_encode_exts { | |
905 | __u32 ext_flags; /*!< IW_ENCODE_EXT_* */ | |
906 | __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /*!< LSB first */ | |
907 | __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /*!< LSB first */ | |
908 | __u8 addr[MAC_ADDR_LEN]; /*!< ff:ff:ff:ff:ff:ff for broadcast/multicast | |
909 | * (group) keys or unicast address for | |
910 | * individual keys */ | |
911 | __u16 alg; /*!< IW_ENCODE_ALG_* */ | |
912 | __u16 key_len; | |
913 | __u8 key[32]; | |
914 | }; | |
915 | ||
916 | /*SET KEY EXT */ | |
917 | typedef struct _NL80211_DRIVER_SET_KEY_EXTS { | |
918 | NL80211_DRIVER_TEST_MODE_PARAMS hdr; | |
919 | UINT_8 key_index; | |
920 | UINT_8 key_len; | |
921 | struct iw_encode_exts ext; | |
922 | } NL80211_DRIVER_SET_KEY_EXTS, *P_NL80211_DRIVER_SET_KEY_EXTS; | |
923 | ||
924 | ||
925 | #endif | |
926 | ||
927 | /******************************************************************************* | |
928 | * P U B L I C D A T A | |
929 | ******************************************************************************** | |
930 | */ | |
931 | ||
932 | /******************************************************************************* | |
933 | * P R I V A T E D A T A | |
934 | ******************************************************************************** | |
935 | */ | |
936 | ||
937 | /******************************************************************************* | |
938 | * M A C R O S | |
939 | ******************************************************************************** | |
940 | */ | |
941 | /*----------------------------------------------------------------------------*/ | |
942 | /* Macros of SPIN LOCK operations for using in Glue Layer */ | |
943 | /*----------------------------------------------------------------------------*/ | |
944 | #if CFG_USE_SPIN_LOCK_BOTTOM_HALF | |
945 | #define GLUE_SPIN_LOCK_DECLARATION() | |
946 | #define GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, rLockCategory) \ | |
947 | { \ | |
948 | if (rLockCategory < SPIN_LOCK_NUM) \ | |
949 | spin_lock_bh(&(prGlueInfo->rSpinLock[rLockCategory])); \ | |
950 | } | |
951 | #define GLUE_RELEASE_SPIN_LOCK(prGlueInfo, rLockCategory) \ | |
952 | { \ | |
953 | if (rLockCategory < SPIN_LOCK_NUM) \ | |
954 | spin_unlock_bh(&(prGlueInfo->rSpinLock[rLockCategory])); \ | |
955 | } | |
956 | #else /* !CFG_USE_SPIN_LOCK_BOTTOM_HALF */ | |
957 | #define GLUE_SPIN_LOCK_DECLARATION() UINT_32 __u4Flags = 0 | |
958 | #define GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, rLockCategory) \ | |
959 | { \ | |
960 | if (rLockCategory < SPIN_LOCK_NUM) \ | |
961 | spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \ | |
962 | } | |
963 | #define GLUE_RELEASE_SPIN_LOCK(prGlueInfo, rLockCategory) \ | |
964 | { \ | |
965 | if (rLockCategory < SPIN_LOCK_NUM) \ | |
966 | spin_unlock_irqrestore(&(prGlueInfo->rSpinLock[rLockCategory]), __u4Flags); \ | |
967 | } | |
968 | #endif /* !CFG_USE_SPIN_LOCK_BOTTOM_HALF */ | |
969 | ||
970 | ||
971 | /*----------------------------------------------------------------------------*/ | |
972 | /* Macros for accessing Reserved Fields of native packet */ | |
973 | /*----------------------------------------------------------------------------*/ | |
974 | #define GLUE_GET_PKT_QUEUE_ENTRY(_p) \ | |
975 | (&(((struct sk_buff *)(_p))->cb[0])) | |
976 | ||
977 | #define GLUE_GET_PKT_DESCRIPTOR(_prQueueEntry) \ | |
978 | ((P_NATIVE_PACKET) ((UINT_32)_prQueueEntry - offsetof(struct sk_buff, cb[0]))) | |
979 | ||
980 | #define GLUE_SET_PKT_FLAG_802_11(_p) \ | |
981 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) |= BIT(7)) | |
982 | ||
983 | #define GLUE_SET_PKT_FLAG_1X(_p) \ | |
984 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) |= BIT(6)) | |
985 | ||
986 | #define GLUE_SET_PKT_FLAG_PAL(_p) \ | |
987 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) |= BIT(5)) | |
988 | ||
989 | #define GLUE_SET_PKT_FLAG_P2P(_p) \ | |
990 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) |= BIT(4)) | |
991 | ||
992 | ||
993 | ||
994 | #define GLUE_SET_PKT_TID(_p, _tid) \ | |
995 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) |= (((UINT_8)((_tid) & (BITS(0, 3)))))) | |
996 | ||
997 | ||
998 | #define GLUE_SET_PKT_FRAME_LEN(_p, _u2PayloadLen) \ | |
999 | (*((PUINT_16) & (((struct sk_buff *)(_p))->cb[6])) = (UINT_16)(_u2PayloadLen)) | |
1000 | ||
1001 | #define GLUE_GET_PKT_FRAME_LEN(_p) \ | |
1002 | (*((PUINT_16) & (((struct sk_buff *)(_p))->cb[6])) ) | |
1003 | ||
1004 | ||
1005 | #define GLUE_GET_PKT_IS_802_11(_p) \ | |
1006 | ((*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) ) & (BIT(7))) | |
1007 | ||
1008 | #define GLUE_GET_PKT_IS_1X(_p) \ | |
1009 | ((*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) ) & (BIT(6))) | |
1010 | ||
1011 | #define GLUE_GET_PKT_TID(_p) \ | |
1012 | ((*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) ) & (BITS(0, 3))) | |
1013 | ||
1014 | ||
1015 | #define GLUE_GET_PKT_IS_PAL(_p) \ | |
1016 | ((*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) ) & (BIT(5))) | |
1017 | ||
1018 | #define GLUE_GET_PKT_IS_P2P(_p) \ | |
1019 | ((*((PUINT_8) & (((struct sk_buff *)(_p))->cb[4])) ) & (BIT(4))) | |
1020 | ||
1021 | ||
1022 | #define GLUE_SET_PKT_HEADER_LEN(_p, _ucMacHeaderLen) \ | |
1023 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[5])) = (UINT_8)(_ucMacHeaderLen)) | |
1024 | ||
1025 | #define GLUE_GET_PKT_HEADER_LEN(_p) \ | |
1026 | (*((PUINT_8) & (((struct sk_buff *)(_p))->cb[5])) ) | |
1027 | ||
1028 | #define GLUE_SET_PKT_ARRIVAL_TIME(_p, _rSysTime) \ | |
1029 | (*((POS_SYSTIME) & (((struct sk_buff *)(_p))->cb[8])) = (OS_SYSTIME)(_rSysTime)) | |
1030 | ||
1031 | #define GLUE_GET_PKT_ARRIVAL_TIME(_p) \ | |
1032 | (*((POS_SYSTIME) & (((struct sk_buff *)(_p))->cb[8])) ) | |
1033 | ||
1034 | /* Check validity of prDev, private data, and pointers */ | |
1035 | #define GLUE_CHK_DEV(prDev) \ | |
1036 | ((prDev && *((P_GLUE_INFO_T *) netdev_priv(prDev))) ? TRUE : FALSE) | |
1037 | ||
1038 | #define GLUE_CHK_PR2(prDev, pr2) \ | |
1039 | ((GLUE_CHK_DEV(prDev) && pr2) ? TRUE : FALSE) | |
1040 | ||
1041 | #define GLUE_CHK_PR3(prDev, pr2, pr3) \ | |
1042 | ((GLUE_CHK_PR2(prDev, pr2) && pr3) ? TRUE : FALSE) | |
1043 | ||
1044 | #define GLUE_CHK_PR4(prDev, pr2, pr3, pr4) \ | |
1045 | ((GLUE_CHK_PR3(prDev, pr2, pr3) && pr4) ? TRUE : FALSE) | |
1046 | ||
1047 | #define GLUE_SET_EVENT(pr) \ | |
1048 | kalSetEvent(pr) | |
1049 | ||
1050 | #define GLUE_INC_REF_CNT(_refCount) atomic_inc((atomic_t *)&(_refCount)) | |
1051 | #define GLUE_DEC_REF_CNT(_refCount) atomic_dec((atomic_t *)&(_refCount)) | |
1052 | ||
1053 | ||
1054 | #define DbgPrint(...) | |
1055 | /******************************************************************************* | |
1056 | * F U N C T I O N D E C L A R A T I O N S | |
1057 | ******************************************************************************** | |
1058 | */ | |
1059 | #ifdef WLAN_INCLUDE_PROC | |
1060 | INT_32 procRemoveProcfs(struct net_device *prDev, char *pucDevName); | |
1061 | ||
1062 | INT_32 procInitProcfs(struct net_device *prDev, char *pucDevName); | |
1063 | #endif /* WLAN_INCLUDE_PROC */ | |
1064 | ||
1065 | #if CFG_ENABLE_BT_OVER_WIFI | |
1066 | BOOLEAN glRegisterAmpc(P_GLUE_INFO_T prGlueInfo); | |
1067 | ||
1068 | BOOLEAN glUnregisterAmpc(P_GLUE_INFO_T prGlueInfo); | |
1069 | #endif | |
1070 | ||
1071 | #if CFG_ENABLE_WIFI_DIRECT | |
1072 | ||
1073 | VOID wlanSubModRunInit(P_GLUE_INFO_T prGlueInfo); | |
1074 | ||
1075 | VOID wlanSubModRunExit(P_GLUE_INFO_T prGlueInfo); | |
1076 | ||
1077 | BOOLEAN wlanSubModInit(P_GLUE_INFO_T prGlueInfo); | |
1078 | ||
1079 | BOOLEAN wlanSubModExit(P_GLUE_INFO_T prGlueInfo); | |
1080 | ||
1081 | VOID | |
1082 | wlanSubModRegisterInitExit(SUB_MODULE_INIT rSubModInit, | |
1083 | SUB_MODULE_EXIT rSubModExit, ENUM_SUB_MODULE_IDX_T eSubModIdx); | |
1084 | ||
1085 | BOOLEAN wlanExportGlueInfo(P_GLUE_INFO_T *prGlueInfoExpAddr); | |
1086 | ||
1087 | BOOLEAN wlanIsLaunched(VOID); | |
1088 | ||
1089 | void p2pSetMulticastListWorkQueueWrapper(P_GLUE_INFO_T prGlueInfo); | |
1090 | ||
1091 | ||
1092 | ||
1093 | #endif | |
1094 | ||
1095 | /******************************************************************************* | |
1096 | * F U N C T I O N S | |
1097 | ******************************************************************************** | |
1098 | */ | |
1099 | ||
1100 | #endif /* _GL_OS_H */ |