r8192U.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. /*
  2. * This is part of rtl8187 OpenSource driver.
  3. * Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com>
  4. * Released under the terms of GPL (General Public Licence)
  5. *
  6. * Parts of this driver are based on the GPL part of the
  7. * official realtek driver
  8. *
  9. * Parts of this driver are based on the rtl8192 driver skeleton
  10. * from Patric Schenke & Andres Salomon
  11. *
  12. * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
  13. *
  14. * We want to thank the Authors of those projects and the Ndiswrapper
  15. * project Authors.
  16. */
  17. #ifndef R819xU_H
  18. #define R819xU_H
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/ioport.h>
  22. #include <linux/sched.h>
  23. #include <linux/types.h>
  24. #include <linux/slab.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/usb.h>
  27. #include <linux/etherdevice.h>
  28. #include <linux/delay.h>
  29. #include <linux/rtnetlink.h>
  30. #include <linux/wireless.h>
  31. #include <linux/timer.h>
  32. #include <linux/proc_fs.h>
  33. #include <linux/if_arp.h>
  34. #include <linux/random.h>
  35. #include <asm/io.h>
  36. #include "ieee80211/ieee80211.h"
  37. #define RTL8192U
  38. #define RTL819xU_MODULE_NAME "rtl819xU"
  39. /* HW security */
  40. #define FALSE 0
  41. #define TRUE 1
  42. #define MAX_KEY_LEN 61
  43. #define KEY_BUF_SIZE 5
  44. #define BIT0 0x00000001
  45. #define BIT1 0x00000002
  46. #define BIT2 0x00000004
  47. #define BIT3 0x00000008
  48. #define BIT4 0x00000010
  49. #define BIT5 0x00000020
  50. #define BIT6 0x00000040
  51. #define BIT7 0x00000080
  52. #define BIT8 0x00000100
  53. #define BIT9 0x00000200
  54. #define BIT10 0x00000400
  55. #define BIT11 0x00000800
  56. #define BIT12 0x00001000
  57. #define BIT13 0x00002000
  58. #define BIT14 0x00004000
  59. #define BIT15 0x00008000
  60. #define BIT16 0x00010000
  61. #define BIT17 0x00020000
  62. #define BIT18 0x00040000
  63. #define BIT19 0x00080000
  64. #define BIT20 0x00100000
  65. #define BIT21 0x00200000
  66. #define BIT22 0x00400000
  67. #define BIT23 0x00800000
  68. #define BIT24 0x01000000
  69. #define BIT25 0x02000000
  70. #define BIT26 0x04000000
  71. #define BIT27 0x08000000
  72. #define BIT28 0x10000000
  73. #define BIT29 0x20000000
  74. #define BIT30 0x40000000
  75. #define BIT31 0x80000000
  76. #define Rx_Smooth_Factor 20
  77. #define DMESG(x, a...)
  78. #define DMESGW(x, a...)
  79. #define DMESGE(x, a...)
  80. extern u32 rt_global_debug_component;
  81. #define RT_TRACE(component, x, args...) \
  82. do { \
  83. if (rt_global_debug_component & component) \
  84. pr_debug("RTL8192U: " x "\n", ##args); \
  85. } while (0)
  86. #define COMP_TRACE BIT0 /* Function call tracing. */
  87. #define COMP_DBG BIT1
  88. #define COMP_INIT BIT2 /* Driver initialization/halt/reset. */
  89. #define COMP_RECV BIT3 /* Receive data path. */
  90. #define COMP_SEND BIT4 /* Send data path. */
  91. #define COMP_IO BIT5
  92. /* 802.11 Power Save mode or System/Device Power state. */
  93. #define COMP_POWER BIT6
  94. /* 802.11 link related: join/start BSS, leave BSS. */
  95. #define COMP_EPROM BIT7
  96. #define COMP_SWBW BIT8 /* Bandwidth switch. */
  97. #define COMP_POWER_TRACKING BIT9 /* 8190 TX Power Tracking */
  98. #define COMP_TURBO BIT10 /* Turbo Mode */
  99. #define COMP_QOS BIT11
  100. #define COMP_RATE BIT12 /* Rate Adaptive mechanism */
  101. #define COMP_RM BIT13 /* Radio Measurement */
  102. #define COMP_DIG BIT14
  103. #define COMP_PHY BIT15
  104. #define COMP_CH BIT16 /* Channel setting debug */
  105. #define COMP_TXAGC BIT17 /* Tx power */
  106. #define COMP_HIPWR BIT18 /* High Power Mechanism */
  107. #define COMP_HALDM BIT19 /* HW Dynamic Mechanism */
  108. #define COMP_SEC BIT20 /* Event handling */
  109. #define COMP_LED BIT21
  110. #define COMP_RF BIT22
  111. #define COMP_RXDESC BIT23 /* Rx desc information for SD3 debug */
  112. /* 11n or 8190 specific code */
  113. #define COMP_FIRMWARE BIT24 /* Firmware downloading */
  114. #define COMP_HT BIT25 /* 802.11n HT related information */
  115. #define COMP_AMSDU BIT26 /* A-MSDU Debugging */
  116. #define COMP_SCAN BIT27
  117. #define COMP_DOWN BIT29 /* rm driver module */
  118. #define COMP_RESET BIT30 /* Silent reset */
  119. #define COMP_ERR BIT31 /* Error out, always on */
  120. #define RTL819x_DEBUG
  121. #ifdef RTL819x_DEBUG
  122. #define RTL8192U_ASSERT(expr) \
  123. do { \
  124. if (!(expr)) { \
  125. pr_debug("Assertion failed! %s, %s, %s, line = %d\n", \
  126. #expr, __FILE__, __func__, __LINE__); \
  127. } \
  128. } while (0)
  129. /*
  130. * Debug out data buf.
  131. * If you want to print DATA buffer related BA,
  132. * please set ieee80211_debug_level to DATA|BA
  133. */
  134. #define RT_DEBUG_DATA(level, data, datalen) \
  135. do { \
  136. if ((rt_global_debug_component & (level)) == (level)) { \
  137. int i; \
  138. u8 *pdata = (u8 *) data; \
  139. pr_debug("RTL8192U: %s()\n", __func__); \
  140. for (i = 0; i < (int)(datalen); i++) { \
  141. printk("%2x ", pdata[i]); \
  142. if ((i+1)%16 == 0) \
  143. printk("\n"); \
  144. } \
  145. printk("\n"); \
  146. } \
  147. } while (0)
  148. #else
  149. #define RTL8192U_ASSERT(expr) do {} while (0)
  150. #define RT_DEBUG_DATA(level, data, datalen) do {} while (0)
  151. #endif /* RTL8169_DEBUG */
  152. /* Queue Select Value in TxDesc */
  153. #define QSLT_BK 0x1
  154. #define QSLT_BE 0x0
  155. #define QSLT_VI 0x4
  156. #define QSLT_VO 0x6
  157. #define QSLT_BEACON 0x10
  158. #define QSLT_HIGH 0x11
  159. #define QSLT_MGNT 0x12
  160. #define QSLT_CMD 0x13
  161. #define DESC90_RATE1M 0x00
  162. #define DESC90_RATE2M 0x01
  163. #define DESC90_RATE5_5M 0x02
  164. #define DESC90_RATE11M 0x03
  165. #define DESC90_RATE6M 0x04
  166. #define DESC90_RATE9M 0x05
  167. #define DESC90_RATE12M 0x06
  168. #define DESC90_RATE18M 0x07
  169. #define DESC90_RATE24M 0x08
  170. #define DESC90_RATE36M 0x09
  171. #define DESC90_RATE48M 0x0a
  172. #define DESC90_RATE54M 0x0b
  173. #define DESC90_RATEMCS0 0x00
  174. #define DESC90_RATEMCS1 0x01
  175. #define DESC90_RATEMCS2 0x02
  176. #define DESC90_RATEMCS3 0x03
  177. #define DESC90_RATEMCS4 0x04
  178. #define DESC90_RATEMCS5 0x05
  179. #define DESC90_RATEMCS6 0x06
  180. #define DESC90_RATEMCS7 0x07
  181. #define DESC90_RATEMCS8 0x08
  182. #define DESC90_RATEMCS9 0x09
  183. #define DESC90_RATEMCS10 0x0a
  184. #define DESC90_RATEMCS11 0x0b
  185. #define DESC90_RATEMCS12 0x0c
  186. #define DESC90_RATEMCS13 0x0d
  187. #define DESC90_RATEMCS14 0x0e
  188. #define DESC90_RATEMCS15 0x0f
  189. #define DESC90_RATEMCS32 0x20
  190. #define RTL819X_DEFAULT_RF_TYPE RF_1T2R
  191. #define IEEE80211_WATCH_DOG_TIME 2000
  192. #define PHY_Beacon_RSSI_SLID_WIN_MAX 10
  193. /* For Tx Power Tracking */
  194. #define OFDM_Table_Length 19
  195. #define CCK_Table_length 12
  196. /* For rtl819x */
  197. typedef struct _tx_desc_819x_usb {
  198. /* DWORD 0 */
  199. u16 PktSize;
  200. u8 Offset;
  201. u8 Reserved0:3;
  202. u8 CmdInit:1;
  203. u8 LastSeg:1;
  204. u8 FirstSeg:1;
  205. u8 LINIP:1;
  206. u8 OWN:1;
  207. /* DWORD 1 */
  208. u8 TxFWInfoSize;
  209. u8 RATid:3;
  210. u8 DISFB:1;
  211. u8 USERATE:1;
  212. u8 MOREFRAG:1;
  213. u8 NoEnc:1;
  214. u8 PIFS:1;
  215. u8 QueueSelect:5;
  216. u8 NoACM:1;
  217. u8 Reserved1:2;
  218. u8 SecCAMID:5;
  219. u8 SecDescAssign:1;
  220. u8 SecType:2;
  221. /* DWORD 2 */
  222. u16 TxBufferSize;
  223. u8 ResvForPaddingLen:7;
  224. u8 Reserved3:1;
  225. u8 Reserved4;
  226. /* DWORD 3, 4, 5 */
  227. u32 Reserved5;
  228. u32 Reserved6;
  229. u32 Reserved7;
  230. } tx_desc_819x_usb, *ptx_desc_819x_usb;
  231. #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
  232. typedef struct _tx_desc_819x_usb_aggr_subframe {
  233. /* DWORD 0 */
  234. u16 PktSize;
  235. u8 Offset;
  236. u8 TxFWInfoSize;
  237. /* DWORD 1 */
  238. u8 RATid:3;
  239. u8 DISFB:1;
  240. u8 USERATE:1;
  241. u8 MOREFRAG:1;
  242. u8 NoEnc:1;
  243. u8 PIFS:1;
  244. u8 QueueSelect:5;
  245. u8 NoACM:1;
  246. u8 Reserved1:2;
  247. u8 SecCAMID:5;
  248. u8 SecDescAssign:1;
  249. u8 SecType:2;
  250. u8 PacketID:7;
  251. u8 OWN:1;
  252. } tx_desc_819x_usb_aggr_subframe, *ptx_desc_819x_usb_aggr_subframe;
  253. #endif
  254. typedef struct _tx_desc_cmd_819x_usb {
  255. /* DWORD 0 */
  256. u16 Reserved0;
  257. u8 Reserved1;
  258. u8 Reserved2:3;
  259. u8 CmdInit:1;
  260. u8 LastSeg:1;
  261. u8 FirstSeg:1;
  262. u8 LINIP:1;
  263. u8 OWN:1;
  264. /* DOWRD 1 */
  265. u8 TxFWInfoSize;
  266. u8 Reserved3;
  267. u8 QueueSelect;
  268. u8 Reserved4;
  269. /* DOWRD 2 */
  270. u16 TxBufferSize;
  271. u16 Reserved5;
  272. /* DWORD 3, 4, 5 */
  273. u32 Reserved6;
  274. u32 Reserved7;
  275. u32 Reserved8;
  276. } tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb;
  277. typedef struct _tx_fwinfo_819x_usb {
  278. /* DOWRD 0 */
  279. u8 TxRate:7;
  280. u8 CtsEnable:1;
  281. u8 RtsRate:7;
  282. u8 RtsEnable:1;
  283. u8 TxHT:1;
  284. u8 Short:1; /* Error out, always on */
  285. u8 TxBandwidth:1; /* Used for HT MCS rate only */
  286. u8 TxSubCarrier:2; /* Used for legacy OFDM rate only */
  287. u8 STBC:2;
  288. u8 AllowAggregation:1;
  289. /* Interpret RtsRate field as high throughput data rate */
  290. u8 RtsHT:1;
  291. u8 RtsShort:1; /* Short PLCP for CCK or short GI for 11n MCS */
  292. u8 RtsBandwidth:1; /* Used for HT MCS rate only */
  293. u8 RtsSubcarrier:2;/* Used for legacy OFDM rate only */
  294. u8 RtsSTBC:2;
  295. /* Enable firmware to recalculate and assign packet duration */
  296. u8 EnableCPUDur:1;
  297. /* DWORD 1 */
  298. u32 RxMF:2;
  299. u32 RxAMD:3;
  300. /* 1 indicate Tx info gathered by firmware and returned by Rx Cmd */
  301. u32 TxPerPktInfoFeedback:1;
  302. u32 Reserved1:2;
  303. u32 TxAGCOffSet:4;
  304. u32 TxAGCSign:1;
  305. u32 Tx_INFO_RSVD:6;
  306. u32 PacketID:13;
  307. } tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb;
  308. typedef struct rtl8192_rx_info {
  309. struct urb *urb;
  310. struct net_device *dev;
  311. u8 out_pipe;
  312. } rtl8192_rx_info ;
  313. typedef struct rx_desc_819x_usb {
  314. /* DOWRD 0 */
  315. u16 Length:14;
  316. u16 CRC32:1;
  317. u16 ICV:1;
  318. u8 RxDrvInfoSize;
  319. u8 Shift:2;
  320. u8 PHYStatus:1;
  321. u8 SWDec:1;
  322. u8 Reserved1:4;
  323. /* DWORD 1 */
  324. u32 Reserved2;
  325. } rx_desc_819x_usb, *prx_desc_819x_usb;
  326. #ifdef USB_RX_AGGREGATION_SUPPORT
  327. typedef struct _rx_desc_819x_usb_aggr_subframe {
  328. /* DOWRD 0 */
  329. u16 Length:14;
  330. u16 CRC32:1;
  331. u16 ICV:1;
  332. u8 Offset;
  333. u8 RxDrvInfoSize;
  334. /* DOWRD 1 */
  335. u8 Shift:2;
  336. u8 PHYStatus:1;
  337. u8 SWDec:1;
  338. u8 Reserved1:4;
  339. u8 Reserved2;
  340. u16 Reserved3;
  341. } rx_desc_819x_usb_aggr_subframe, *prx_desc_819x_usb_aggr_subframe;
  342. #endif
  343. typedef struct rx_drvinfo_819x_usb {
  344. /* DWORD 0 */
  345. u16 Reserved1:12;
  346. u16 PartAggr:1;
  347. u16 FirstAGGR:1;
  348. u16 Reserved2:2;
  349. u8 RxRate:7;
  350. u8 RxHT:1;
  351. u8 BW:1;
  352. u8 SPLCP:1;
  353. u8 Reserved3:2;
  354. u8 PAM:1;
  355. u8 Mcast:1;
  356. u8 Bcast:1;
  357. u8 Reserved4:1;
  358. /* DWORD 1 */
  359. u32 TSFL;
  360. } rx_drvinfo_819x_usb, *prx_drvinfo_819x_usb;
  361. /* Support till 64 bit bus width OS */
  362. #define MAX_DEV_ADDR_SIZE 8
  363. /* For RTL8190 */
  364. #define MAX_FIRMWARE_INFORMATION_SIZE 32
  365. #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE)
  366. #define ENCRYPTION_MAX_OVERHEAD 128
  367. #define USB_HWDESC_HEADER_LEN sizeof(tx_desc_819x_usb)
  368. #define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
  369. #define MAX_FRAGMENT_COUNT 8
  370. #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
  371. #define MAX_TRANSMIT_BUFFER_SIZE 32000
  372. #else
  373. #define MAX_TRANSMIT_BUFFER_SIZE 8000
  374. #endif
  375. #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
  376. #define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb))
  377. #endif
  378. /* Octets for crc32 (FCS, ICV) */
  379. #define scrclng 4
  380. typedef enum rf_optype {
  381. RF_OP_By_SW_3wire = 0,
  382. RF_OP_By_FW,
  383. RF_OP_MAX
  384. } rf_op_type;
  385. /* 8190 Loopback Mode definition */
  386. typedef enum _rtl819xUsb_loopback {
  387. RTL819xU_NO_LOOPBACK = 0,
  388. RTL819xU_MAC_LOOPBACK = 1,
  389. RTL819xU_DMA_LOOPBACK = 2,
  390. RTL819xU_CCK_LOOPBACK = 3,
  391. } rtl819xUsb_loopback_e;
  392. /* due to rtl8192 firmware */
  393. typedef enum _desc_packet_type_e {
  394. DESC_PACKET_TYPE_INIT = 0,
  395. DESC_PACKET_TYPE_NORMAL = 1,
  396. } desc_packet_type_e;
  397. typedef enum _firmware_status {
  398. FW_STATUS_0_INIT = 0,
  399. FW_STATUS_1_MOVE_BOOT_CODE = 1,
  400. FW_STATUS_2_MOVE_MAIN_CODE = 2,
  401. FW_STATUS_3_TURNON_CPU = 3,
  402. FW_STATUS_4_MOVE_DATA_CODE = 4,
  403. FW_STATUS_5_READY = 5,
  404. } firmware_status_e;
  405. typedef struct _rt_firmare_seg_container {
  406. u16 seg_size;
  407. u8 *seg_ptr;
  408. } fw_seg_container, *pfw_seg_container;
  409. typedef struct _rt_firmware {
  410. firmware_status_e firmware_status;
  411. u16 cmdpacket_frag_thresold;
  412. #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
  413. u8 firmware_buf[RTL8190_MAX_FIRMWARE_CODE_SIZE];
  414. u16 firmware_buf_size;
  415. } rt_firmware, *prt_firmware;
  416. /* Add this to 9100 bytes to receive A-MSDU from RT-AP */
  417. #define MAX_RECEIVE_BUFFER_SIZE 9100
  418. typedef struct _rt_firmware_info_819xUsb {
  419. u8 sz_info[16];
  420. } rt_firmware_info_819xUsb, *prt_firmware_info_819xUsb;
  421. /* Firmware Queue Layout */
  422. #define NUM_OF_FIRMWARE_QUEUE 10
  423. #define NUM_OF_PAGES_IN_FW 0x100
  424. #ifdef USE_ONE_PIPE
  425. #define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x000
  426. #define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x000
  427. #define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x0ff
  428. #define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x000
  429. #define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
  430. #define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x0
  431. #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x00
  432. #define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
  433. #define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x0
  434. #define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x00
  435. #else
  436. #define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x020
  437. #define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x020
  438. #define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x040
  439. #define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x040
  440. #define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
  441. #define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x4
  442. #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x20
  443. #define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
  444. #define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x4
  445. #define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x18
  446. #endif
  447. #define APPLIED_RESERVED_QUEUE_IN_FW 0x80000000
  448. #define RSVD_FW_QUEUE_PAGE_BK_SHIFT 0x00
  449. #define RSVD_FW_QUEUE_PAGE_BE_SHIFT 0x08
  450. #define RSVD_FW_QUEUE_PAGE_VI_SHIFT 0x10
  451. #define RSVD_FW_QUEUE_PAGE_VO_SHIFT 0x18
  452. #define RSVD_FW_QUEUE_PAGE_MGNT_SHIFT 0x10
  453. #define RSVD_FW_QUEUE_PAGE_CMD_SHIFT 0x08
  454. #define RSVD_FW_QUEUE_PAGE_BCN_SHIFT 0x00
  455. #define RSVD_FW_QUEUE_PAGE_PUB_SHIFT 0x08
  456. /*
  457. * =================================================================
  458. * =================================================================
  459. */
  460. #define EPROM_93c46 0
  461. #define EPROM_93c56 1
  462. #define DEFAULT_FRAG_THRESHOLD 2342U
  463. #define MIN_FRAG_THRESHOLD 256U
  464. #define DEFAULT_BEACONINTERVAL 0x64U
  465. #define DEFAULT_BEACON_ESSID "Rtl819xU"
  466. #define DEFAULT_SSID ""
  467. #define DEFAULT_RETRY_RTS 7
  468. #define DEFAULT_RETRY_DATA 7
  469. #define PRISM_HDR_SIZE 64
  470. #define PHY_RSSI_SLID_WIN_MAX 100
  471. typedef enum _WIRELESS_MODE {
  472. WIRELESS_MODE_UNKNOWN = 0x00,
  473. WIRELESS_MODE_A = 0x01,
  474. WIRELESS_MODE_B = 0x02,
  475. WIRELESS_MODE_G = 0x04,
  476. WIRELESS_MODE_AUTO = 0x08,
  477. WIRELESS_MODE_N_24G = 0x10,
  478. WIRELESS_MODE_N_5G = 0x20
  479. } WIRELESS_MODE;
  480. #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30)
  481. typedef struct buffer {
  482. struct buffer *next;
  483. u32 *buf;
  484. } buffer;
  485. typedef struct rtl_reg_debug {
  486. unsigned int cmd;
  487. struct {
  488. unsigned char type;
  489. unsigned char addr;
  490. unsigned char page;
  491. unsigned char length;
  492. } head;
  493. unsigned char buf[0xff];
  494. } rtl_reg_debug;
  495. typedef struct _rt_9x_tx_rate_history {
  496. u32 cck[4];
  497. u32 ofdm[8];
  498. u32 ht_mcs[4][16];
  499. } rt_tx_rahis_t, *prt_tx_rahis_t;
  500. typedef struct _RT_SMOOTH_DATA_4RF {
  501. char elements[4][100]; /* array to store values */
  502. u32 index; /* index to current array to store */
  503. u32 TotalNum; /* num of valid elements */
  504. u32 TotalVal[4]; /* sum of valid elements */
  505. } RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF;
  506. /* This maybe changed for D-cut larger aggregation size */
  507. #define MAX_8192U_RX_SIZE 8192
  508. /* Stats seems messed up, clean it ASAP */
  509. typedef struct Stats {
  510. unsigned long txrdu;
  511. unsigned long rxok;
  512. unsigned long rxframgment;
  513. unsigned long rxurberr;
  514. unsigned long rxstaterr;
  515. /* 0: Total, 1: OK, 2: CRC, 3: ICV */
  516. unsigned long received_rate_histogram[4][32];
  517. /* 0: Long preamble/GI, 1: Short preamble/GI */
  518. unsigned long received_preamble_GI[2][32];
  519. /* level: (<4K), (4K~8K), (8K~16K), (16K~32K), (32K~64K) */
  520. unsigned long rx_AMPDUsize_histogram[5];
  521. /* level: (<5), (5~10), (10~20), (20~40), (>40) */
  522. unsigned long rx_AMPDUnum_histogram[5];
  523. unsigned long numpacket_matchbssid;
  524. unsigned long numpacket_toself;
  525. unsigned long num_process_phyinfo;
  526. unsigned long numqry_phystatus;
  527. unsigned long numqry_phystatusCCK;
  528. unsigned long numqry_phystatusHT;
  529. /* 0: 20M, 1: funn40M, 2: upper20M, 3: lower20M, 4: duplicate */
  530. unsigned long received_bwtype[5];
  531. unsigned long txnperr;
  532. unsigned long txnpdrop;
  533. unsigned long txresumed;
  534. unsigned long txnpokint;
  535. unsigned long txoverflow;
  536. unsigned long txlpokint;
  537. unsigned long txlpdrop;
  538. unsigned long txlperr;
  539. unsigned long txbeokint;
  540. unsigned long txbedrop;
  541. unsigned long txbeerr;
  542. unsigned long txbkokint;
  543. unsigned long txbkdrop;
  544. unsigned long txbkerr;
  545. unsigned long txviokint;
  546. unsigned long txvidrop;
  547. unsigned long txvierr;
  548. unsigned long txvookint;
  549. unsigned long txvodrop;
  550. unsigned long txvoerr;
  551. unsigned long txbeaconokint;
  552. unsigned long txbeacondrop;
  553. unsigned long txbeaconerr;
  554. unsigned long txmanageokint;
  555. unsigned long txmanagedrop;
  556. unsigned long txmanageerr;
  557. unsigned long txdatapkt;
  558. unsigned long txfeedback;
  559. unsigned long txfeedbackok;
  560. unsigned long txoktotal;
  561. unsigned long txokbytestotal;
  562. unsigned long txokinperiod;
  563. unsigned long txmulticast;
  564. unsigned long txbytesmulticast;
  565. unsigned long txbroadcast;
  566. unsigned long txbytesbroadcast;
  567. unsigned long txunicast;
  568. unsigned long txbytesunicast;
  569. unsigned long rxoktotal;
  570. unsigned long rxbytesunicast;
  571. unsigned long txfeedbackfail;
  572. unsigned long txerrtotal;
  573. unsigned long txerrbytestotal;
  574. unsigned long txerrmulticast;
  575. unsigned long txerrbroadcast;
  576. unsigned long txerrunicast;
  577. unsigned long txretrycount;
  578. unsigned long txfeedbackretry;
  579. u8 last_packet_rate;
  580. unsigned long slide_signal_strength[100];
  581. unsigned long slide_evm[100];
  582. /* For recording sliding window's RSSI value */
  583. unsigned long slide_rssi_total;
  584. /* For recording sliding window's EVM value */
  585. unsigned long slide_evm_total;
  586. /* Transformed in dbm. Beautified signal strength for UI, not correct */
  587. long signal_strength;
  588. long signal_quality;
  589. long last_signal_strength_inpercent;
  590. /* Correct smoothed ss in dbm, only used in driver
  591. * to report real power now */
  592. long recv_signal_power;
  593. u8 rx_rssi_percentage[4];
  594. u8 rx_evm_percentage[2];
  595. long rxSNRdB[4];
  596. rt_tx_rahis_t txrate;
  597. /* For beacon RSSI */
  598. u32 Slide_Beacon_pwdb[100];
  599. u32 Slide_Beacon_Total;
  600. RT_SMOOTH_DATA_4RF cck_adc_pwdb;
  601. u32 CurrentShowTxate;
  602. } Stats;
  603. /* Bandwidth Offset */
  604. #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
  605. #define HAL_PRIME_CHNL_OFFSET_LOWER 1
  606. #define HAL_PRIME_CHNL_OFFSET_UPPER 2
  607. typedef struct ChnlAccessSetting {
  608. u16 SIFS_Timer;
  609. u16 DIFS_Timer;
  610. u16 SlotTimeTimer;
  611. u16 EIFS_Timer;
  612. u16 CWminIndex;
  613. u16 CWmaxIndex;
  614. } *PCHANNEL_ACCESS_SETTING, CHANNEL_ACCESS_SETTING;
  615. typedef struct _BB_REGISTER_DEFINITION {
  616. /* set software control: 0x870~0x877 [8 bytes] */
  617. u32 rfintfs;
  618. /* readback data: 0x8e0~0x8e7 [8 bytes] */
  619. u32 rfintfi;
  620. /* output data: 0x860~0x86f [16 bytes] */
  621. u32 rfintfo;
  622. /* output enable: 0x860~0x86f [16 bytes] */
  623. u32 rfintfe;
  624. /* LSSI data: 0x840~0x84f [16 bytes] */
  625. u32 rf3wireOffset;
  626. /* BB Band Select: 0x878~0x87f [8 bytes] */
  627. u32 rfLSSI_Select;
  628. /* Tx gain stage: 0x80c~0x80f [4 bytes] */
  629. u32 rfTxGainStage;
  630. /* wire parameter control1: 0x820~0x823, 0x828~0x82b,
  631. * 0x830~0x833, 0x838~0x83b [16 bytes] */
  632. u32 rfHSSIPara1;
  633. /* wire parameter control2: 0x824~0x827, 0x82c~0x82f,
  634. * 0x834~0x837, 0x83c~0x83f [16 bytes] */
  635. u32 rfHSSIPara2;
  636. /* Tx Rx antenna control: 0x858~0x85f [16 bytes] */
  637. u32 rfSwitchControl;
  638. /* AGC parameter control1: 0xc50~0xc53, 0xc58~0xc5b,
  639. * 0xc60~0xc63, 0xc68~0xc6b [16 bytes] */
  640. u32 rfAGCControl1;
  641. /* AGC parameter control2: 0xc54~0xc57, 0xc5c~0xc5f,
  642. * 0xc64~0xc67, 0xc6c~0xc6f [16 bytes] */
  643. u32 rfAGCControl2;
  644. /* OFDM Rx IQ imbalance matrix: 0xc14~0xc17, 0xc1c~0xc1f,
  645. * 0xc24~0xc27, 0xc2c~0xc2f [16 bytes] */
  646. u32 rfRxIQImbalance;
  647. /* Rx IQ DC offset and Rx digital filter, Rx DC notch filter:
  648. * 0xc10~0xc13, 0xc18~0xc1b,
  649. * 0xc20~0xc23, 0xc28~0xc2b [16 bytes] */
  650. u32 rfRxAFE;
  651. /* OFDM Tx IQ imbalance matrix: 0xc80~0xc83, 0xc88~0xc8b,
  652. * 0xc90~0xc93, 0xc98~0xc9b [16 bytes] */
  653. u32 rfTxIQImbalance;
  654. /* Tx IQ DC Offset and Tx DFIR type:
  655. * 0xc84~0xc87, 0xc8c~0xc8f,
  656. * 0xc94~0xc97, 0xc9c~0xc9f [16 bytes] */
  657. u32 rfTxAFE;
  658. /* LSSI RF readback data: 0x8a0~0x8af [16 bytes] */
  659. u32 rfLSSIReadBack;
  660. } BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T;
  661. typedef enum _RT_RF_TYPE_819xU {
  662. RF_TYPE_MIN = 0,
  663. RF_8225,
  664. RF_8256,
  665. RF_8258,
  666. RF_PSEUDO_11N = 4,
  667. } RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
  668. typedef struct _rate_adaptive {
  669. u8 rate_adaptive_disabled;
  670. u8 ratr_state;
  671. u16 reserve;
  672. u32 high_rssi_thresh_for_ra;
  673. u32 high2low_rssi_thresh_for_ra;
  674. u8 low2high_rssi_thresh_for_ra40M;
  675. u32 low_rssi_thresh_for_ra40M;
  676. u8 low2high_rssi_thresh_for_ra20M;
  677. u32 low_rssi_thresh_for_ra20M;
  678. u32 upper_rssi_threshold_ratr;
  679. u32 middle_rssi_threshold_ratr;
  680. u32 low_rssi_threshold_ratr;
  681. u32 low_rssi_threshold_ratr_40M;
  682. u32 low_rssi_threshold_ratr_20M;
  683. u8 ping_rssi_enable;
  684. u32 ping_rssi_ratr;
  685. u32 ping_rssi_thresh_for_ra;
  686. u32 last_ratr;
  687. } rate_adaptive, *prate_adaptive;
  688. #define TxBBGainTableLength 37
  689. #define CCKTxBBGainTableLength 23
  690. typedef struct _txbbgain_struct {
  691. long txbb_iq_amplifygain;
  692. u32 txbbgain_value;
  693. } txbbgain_struct, *ptxbbgain_struct;
  694. typedef struct _ccktxbbgain_struct {
  695. /* The value is from a22 to a29, one byte one time is much safer */
  696. u8 ccktxbb_valuearray[8];
  697. } ccktxbbgain_struct, *pccktxbbgain_struct;
  698. typedef struct _init_gain {
  699. u8 xaagccore1;
  700. u8 xbagccore1;
  701. u8 xcagccore1;
  702. u8 xdagccore1;
  703. u8 cca;
  704. } init_gain, *pinit_gain;
  705. typedef struct _phy_ofdm_rx_status_report_819xusb {
  706. u8 trsw_gain_X[4];
  707. u8 pwdb_all;
  708. u8 cfosho_X[4];
  709. u8 cfotail_X[4];
  710. u8 rxevm_X[2];
  711. u8 rxsnr_X[4];
  712. u8 pdsnr_X[2];
  713. u8 csi_current_X[2];
  714. u8 csi_target_X[2];
  715. u8 sigevm;
  716. u8 max_ex_pwr;
  717. u8 sgi_en;
  718. u8 rxsc_sgien_exflg;
  719. } phy_sts_ofdm_819xusb_t;
  720. typedef struct _phy_cck_rx_status_report_819xusb {
  721. /* For CCK rate descriptor. This is an unsigned 8:1 variable.
  722. * LSB bit presend 0.5. And MSB 7 bts presend a signed value.
  723. * Range from -64~+63.5. */
  724. u8 adc_pwdb_X[4];
  725. u8 sq_rpt;
  726. u8 cck_agc_rpt;
  727. } phy_sts_cck_819xusb_t;
  728. typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag {
  729. u8 reserved:4;
  730. u8 rxsc:2;
  731. u8 sgi_en:1;
  732. u8 ex_intf_flag:1;
  733. } phy_ofdm_rx_status_rxsc_sgien_exintfflag;
  734. typedef enum _RT_CUSTOMER_ID {
  735. RT_CID_DEFAULT = 0,
  736. RT_CID_8187_ALPHA0 = 1,
  737. RT_CID_8187_SERCOMM_PS = 2,
  738. RT_CID_8187_HW_LED = 3,
  739. RT_CID_8187_NETGEAR = 4,
  740. RT_CID_WHQL = 5,
  741. RT_CID_819x_CAMEO = 6,
  742. RT_CID_819x_RUNTOP = 7,
  743. RT_CID_819x_Senao = 8,
  744. RT_CID_TOSHIBA = 9,
  745. RT_CID_819x_Netcore = 10,
  746. RT_CID_Nettronix = 11,
  747. RT_CID_DLINK = 12,
  748. RT_CID_PRONET = 13,
  749. } RT_CUSTOMER_ID, *PRT_CUSTOMER_ID;
  750. /*
  751. * ==========================================================================
  752. * LED customization.
  753. * ==========================================================================
  754. */
  755. typedef enum _LED_STRATEGY_8190 {
  756. SW_LED_MODE0, /* SW control 1 LED via GPIO0. It is default option. */
  757. SW_LED_MODE1, /* SW control for PCI Express */
  758. SW_LED_MODE2, /* SW control for Cameo. */
  759. SW_LED_MODE3, /* SW control for RunTop. */
  760. SW_LED_MODE4, /* SW control for Netcore. */
  761. /* HW control 2 LEDs, LED0 and LED1 (4 different control modes) */
  762. HW_LED,
  763. } LED_STRATEGY_8190, *PLED_STRATEGY_8190;
  764. typedef enum _RESET_TYPE {
  765. RESET_TYPE_NORESET = 0x00,
  766. RESET_TYPE_NORMAL = 0x01,
  767. RESET_TYPE_SILENT = 0x02
  768. } RESET_TYPE;
  769. /* The simple tx command OP code. */
  770. typedef enum _tag_TxCmd_Config_Index {
  771. TXCMD_TXRA_HISTORY_CTRL = 0xFF900000,
  772. TXCMD_RESET_TX_PKT_BUFF = 0xFF900001,
  773. TXCMD_RESET_RX_PKT_BUFF = 0xFF900002,
  774. TXCMD_SET_TX_DURATION = 0xFF900003,
  775. TXCMD_SET_RX_RSSI = 0xFF900004,
  776. TXCMD_SET_TX_PWR_TRACKING = 0xFF900005,
  777. TXCMD_XXXX_CTRL,
  778. } DCMD_TXCMD_OP;
  779. typedef struct r8192_priv {
  780. struct usb_device *udev;
  781. /* For maintain info from eeprom */
  782. short epromtype;
  783. u16 eeprom_vid;
  784. u16 eeprom_pid;
  785. u8 eeprom_CustomerID;
  786. u8 eeprom_ChannelPlan;
  787. RT_CUSTOMER_ID CustomerID;
  788. LED_STRATEGY_8190 LedStrategy;
  789. u8 txqueue_to_outpipemap[9];
  790. int irq;
  791. struct ieee80211_device *ieee80211;
  792. /* O: rtl8192, 1: rtl8185 V B/C, 2: rtl8185 V D */
  793. short card_8192;
  794. /* If TCR reports card V B/C, this discriminates */
  795. u8 card_8192_version;
  796. short enable_gpio0;
  797. enum card_type {
  798. PCI, MINIPCI, CARDBUS, USB
  799. } card_type;
  800. short hw_plcp_len;
  801. short plcp_preamble_mode;
  802. spinlock_t irq_lock;
  803. spinlock_t tx_lock;
  804. struct mutex mutex;
  805. u16 irq_mask;
  806. short chan;
  807. short sens;
  808. short max_sens;
  809. short up;
  810. /* If 1, allow bad crc frame, reception in monitor mode */
  811. short crcmon;
  812. struct semaphore wx_sem;
  813. struct semaphore rf_sem; /* Used to lock rf write operation */
  814. u8 rf_type; /* 0: 1T2R, 1: 2T4R */
  815. RT_RF_TYPE_819xU rf_chip;
  816. short (*rf_set_sens)(struct net_device *dev, short sens);
  817. u8 (*rf_set_chan)(struct net_device *dev, u8 ch);
  818. void (*rf_close)(struct net_device *dev);
  819. void (*rf_init)(struct net_device *dev);
  820. short promisc;
  821. /* Stats */
  822. struct Stats stats;
  823. struct iw_statistics wstats;
  824. /* RX stuff */
  825. struct urb **rx_urb;
  826. struct urb **rx_cmd_urb;
  827. #ifdef THOMAS_BEACON
  828. u32 *oldaddr;
  829. #endif
  830. #ifdef THOMAS_TASKLET
  831. atomic_t irt_counter; /* count for irq_rx_tasklet */
  832. #endif
  833. #ifdef JACKSON_NEW_RX
  834. struct sk_buff **pp_rxskb;
  835. int rx_inx;
  836. #endif
  837. struct sk_buff_head rx_queue;
  838. struct sk_buff_head skb_queue;
  839. struct work_struct qos_activate;
  840. short tx_urb_index;
  841. atomic_t tx_pending[0x10]; /* UART_PRIORITY + 1 */
  842. struct tasklet_struct irq_rx_tasklet;
  843. struct urb *rxurb_task;
  844. /* Tx Related variables */
  845. u16 ShortRetryLimit;
  846. u16 LongRetryLimit;
  847. u32 TransmitConfig;
  848. u8 RegCWinMin; /* For turbo mode CW adaptive */
  849. u32 LastRxDescTSFHigh;
  850. u32 LastRxDescTSFLow;
  851. /* Rx Related variables */
  852. u16 EarlyRxThreshold;
  853. u32 ReceiveConfig;
  854. u8 AcmControl;
  855. u8 RFProgType;
  856. u8 retry_data;
  857. u8 retry_rts;
  858. u16 rts;
  859. struct ChnlAccessSetting ChannelAccessSetting;
  860. struct work_struct reset_wq;
  861. /**********************************************************/
  862. /* For rtl819xUsb */
  863. u16 basic_rate;
  864. u8 short_preamble;
  865. u8 slot_time;
  866. bool bDcut;
  867. bool bCurrentRxAggrEnable;
  868. u8 Rf_Mode; /* For Firmware RF -R/W switch */
  869. prt_firmware pFirmware;
  870. rtl819xUsb_loopback_e LoopbackMode;
  871. u16 EEPROMTxPowerDiff;
  872. u8 EEPROMThermalMeter;
  873. u8 EEPROMPwDiff;
  874. u8 EEPROMCrystalCap;
  875. u8 EEPROM_Def_Ver;
  876. u8 EEPROMTxPowerLevelCCK; /* CCK channel 1~14 */
  877. u8 EEPROMTxPowerLevelCCK_V1[3];
  878. u8 EEPROMTxPowerLevelOFDM24G[3]; /* OFDM 2.4G channel 1~14 */
  879. u8 EEPROMTxPowerLevelOFDM5G[24]; /* OFDM 5G */
  880. /* PHY related */
  881. BB_REGISTER_DEFINITION_T PHYRegDef[4]; /* Radio A/B/C/D */
  882. /* Read/write are allow for following hardware information variables */
  883. u32 MCSTxPowerLevelOriginalOffset[6];
  884. u32 CCKTxPowerLevelOriginalOffset;
  885. u8 TxPowerLevelCCK[14]; /* CCK channel 1~14 */
  886. u8 TxPowerLevelOFDM24G[14]; /* OFDM 2.4G channel 1~14 */
  887. u8 TxPowerLevelOFDM5G[14]; /* OFDM 5G */
  888. u32 Pwr_Track;
  889. u8 TxPowerDiff;
  890. u8 AntennaTxPwDiff[2]; /* Antenna gain offset, 0: B, 1: C, 2: D */
  891. u8 CrystalCap;
  892. u8 ThermalMeter[2]; /* index 0: RFIC0, index 1: RFIC1 */
  893. u8 CckPwEnl;
  894. /* Use to calculate PWBD */
  895. u8 bCckHighPower;
  896. long undecorated_smoothed_pwdb;
  897. /* For set channel */
  898. u8 SwChnlInProgress;
  899. u8 SwChnlStage;
  900. u8 SwChnlStep;
  901. u8 SetBWModeInProgress;
  902. HT_CHANNEL_WIDTH CurrentChannelBW;
  903. u8 ChannelPlan;
  904. /* 8190 40MHz mode */
  905. /* Control channel sub-carrier */
  906. u8 nCur40MhzPrimeSC;
  907. /* Test for shorten RF configuration time.
  908. * We save RF reg0 in this variable to reduce RF reading. */
  909. u32 RfReg0Value[4];
  910. u8 NumTotalRFPath;
  911. bool brfpath_rxenable[4];
  912. /* RF set related */
  913. bool SetRFPowerStateInProgress;
  914. struct timer_list watch_dog_timer;
  915. /* For dynamic mechanism */
  916. /* Tx Power Control for Near/Far Range */
  917. bool bdynamic_txpower;
  918. bool bDynamicTxHighPower;
  919. bool bDynamicTxLowPower;
  920. bool bLastDTPFlag_High;
  921. bool bLastDTPFlag_Low;
  922. bool bstore_last_dtpflag;
  923. /* Define to discriminate on High power State or
  924. * on sitesurvey to change Tx gain index */
  925. bool bstart_txctrl_bydtp;
  926. rate_adaptive rate_adaptive;
  927. /* TX power tracking
  928. * OPEN/CLOSE TX POWER TRACKING */
  929. txbbgain_struct txbbgain_table[TxBBGainTableLength];
  930. u8 txpower_count; /* For 6 sec do tracking again */
  931. bool btxpower_trackingInit;
  932. u8 OFDM_index;
  933. u8 CCK_index;
  934. /* CCK TX Power Tracking */
  935. ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength];
  936. ccktxbbgain_struct cck_txbbgain_ch14_table[CCKTxBBGainTableLength];
  937. u8 rfa_txpowertrackingindex;
  938. u8 rfa_txpowertrackingindex_real;
  939. u8 rfa_txpowertracking_default;
  940. u8 rfc_txpowertrackingindex;
  941. u8 rfc_txpowertrackingindex_real;
  942. s8 cck_present_attentuation;
  943. u8 cck_present_attentuation_20Mdefault;
  944. u8 cck_present_attentuation_40Mdefault;
  945. char cck_present_attentuation_difference;
  946. bool btxpower_tracking;
  947. bool bcck_in_ch14;
  948. bool btxpowerdata_readfromEEPORM;
  949. u16 TSSI_13dBm;
  950. init_gain initgain_backup;
  951. u8 DefaultInitialGain[4];
  952. /* For EDCA Turbo mode */
  953. bool bis_any_nonbepkts;
  954. bool bcurrent_turbo_EDCA;
  955. bool bis_cur_rdlstate;
  956. struct timer_list fsync_timer;
  957. bool bfsync_processing; /* 500ms Fsync timer is active or not */
  958. u32 rate_record;
  959. u32 rateCountDiffRecord;
  960. u32 ContinueDiffCount;
  961. bool bswitch_fsync;
  962. u8 framesync;
  963. u32 framesyncC34;
  964. u8 framesyncMonitor;
  965. u16 nrxAMPDU_size;
  966. u8 nrxAMPDU_aggr_num;
  967. /* For gpio */
  968. bool bHwRadioOff;
  969. u32 reset_count;
  970. bool bpbc_pressed;
  971. u32 txpower_checkcnt;
  972. u32 txpower_tracking_callback_cnt;
  973. u8 thermal_read_val[40];
  974. u8 thermal_readback_index;
  975. u32 ccktxpower_adjustcnt_not_ch14;
  976. u32 ccktxpower_adjustcnt_ch14;
  977. u8 tx_fwinfo_force_subcarriermode;
  978. u8 tx_fwinfo_force_subcarrierval;
  979. /* For silent reset */
  980. RESET_TYPE ResetProgress;
  981. bool bForcedSilentReset;
  982. bool bDisableNormalResetCheck;
  983. u16 TxCounter;
  984. u16 RxCounter;
  985. int IrpPendingCount;
  986. bool bResetInProgress;
  987. bool force_reset;
  988. u8 InitialGainOperateType;
  989. u16 SifsTime;
  990. /* Define work item */
  991. struct delayed_work update_beacon_wq;
  992. struct delayed_work watch_dog_wq;
  993. struct delayed_work txpower_tracking_wq;
  994. struct delayed_work rfpath_check_wq;
  995. struct delayed_work gpio_change_rf_wq;
  996. struct delayed_work initialgain_operate_wq;
  997. struct workqueue_struct *priv_wq;
  998. } r8192_priv;
  999. /* For rtl8187B */
  1000. typedef enum{
  1001. BULK_PRIORITY = 0x01,
  1002. LOW_PRIORITY,
  1003. NORM_PRIORITY,
  1004. VO_PRIORITY,
  1005. VI_PRIORITY,
  1006. BE_PRIORITY,
  1007. BK_PRIORITY,
  1008. RSVD2,
  1009. RSVD3,
  1010. BEACON_PRIORITY,
  1011. HIGH_PRIORITY,
  1012. MANAGE_PRIORITY,
  1013. RSVD4,
  1014. RSVD5,
  1015. UART_PRIORITY
  1016. } priority_t;
  1017. typedef enum {
  1018. NIC_8192U = 1,
  1019. NIC_8190P = 2,
  1020. NIC_8192E = 3,
  1021. } nic_t;
  1022. bool init_firmware(struct net_device *dev);
  1023. short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
  1024. short rtl8192_tx(struct net_device *dev, struct sk_buff *skb);
  1025. u32 read_cam(struct net_device *dev, u8 addr);
  1026. void write_cam(struct net_device *dev, u8 addr, u32 data);
  1027. int read_nic_byte(struct net_device *dev, int x, u8 *data);
  1028. int read_nic_byte_E(struct net_device *dev, int x, u8 *data);
  1029. int read_nic_dword(struct net_device *dev, int x, u32 *data);
  1030. int read_nic_word(struct net_device *dev, int x, u16 *data);
  1031. void write_nic_byte(struct net_device *dev, int x, u8 y);
  1032. void write_nic_byte_E(struct net_device *dev, int x, u8 y);
  1033. void write_nic_word(struct net_device *dev, int x, u16 y);
  1034. void write_nic_dword(struct net_device *dev, int x, u32 y);
  1035. void force_pci_posting(struct net_device *dev);
  1036. void rtl8192_rtx_disable(struct net_device *);
  1037. void rtl8192_rx_enable(struct net_device *);
  1038. void rtl8192_tx_enable(struct net_device *);
  1039. void rtl8192_disassociate(struct net_device *dev);
  1040. void rtl8185_set_rf_pins_enable(struct net_device *dev, u32 a);
  1041. void rtl8192_set_anaparam(struct net_device *dev, u32 a);
  1042. void rtl8185_set_anaparam2(struct net_device *dev, u32 a);
  1043. void rtl8192_update_msr(struct net_device *dev);
  1044. int rtl8192_down(struct net_device *dev);
  1045. int rtl8192_up(struct net_device *dev);
  1046. void rtl8192_commit(struct net_device *dev);
  1047. void rtl8192_set_chan(struct net_device *dev, short ch);
  1048. void write_phy(struct net_device *dev, u8 adr, u8 data);
  1049. void write_phy_cck(struct net_device *dev, u8 adr, u32 data);
  1050. void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data);
  1051. void rtl8185_tx_antenna(struct net_device *dev, u8 ant);
  1052. void rtl8192_set_rxconf(struct net_device *dev);
  1053. extern void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate);
  1054. void EnableHWSecurityConfig8192(struct net_device *dev);
  1055. void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
  1056. #endif