wbhal.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. #ifndef __WINBOND_WBHAL_S_H
  2. #define __WINBOND_WBHAL_S_H
  3. #include <linux/types.h>
  4. #include <linux/if_ether.h> /* for ETH_ALEN */
  5. #define HAL_LED_SET_MASK 0x001c
  6. #define HAL_LED_SET_SHIFT 2
  7. /* supported RF type */
  8. #define RF_MAXIM_2825 0
  9. #define RF_MAXIM_2827 1
  10. #define RF_MAXIM_2828 2
  11. #define RF_MAXIM_2829 3
  12. #define RF_MAXIM_V1 15
  13. #define RF_AIROHA_2230 16
  14. #define RF_AIROHA_7230 17
  15. #define RF_AIROHA_2230S 18
  16. #define RF_WB_242 33
  17. #define RF_WB_242_1 34
  18. #define RF_DECIDE_BY_INF 255
  19. /*
  20. * ----------------------------------------------------------------
  21. * The follow define connect to upper layer
  22. * User must modify for connection between HAL and upper layer
  23. * ----------------------------------------------------------------
  24. */
  25. /*
  26. * ==============================
  27. * Common define
  28. * ==============================
  29. */
  30. /* Bit 5 */
  31. #define HAL_USB_MODE_BURST(_H) (_H->SoftwareSet & 0x20)
  32. /* Scan interval */
  33. #define SCAN_MAX_CHNL_TIME (50)
  34. /* For TxL2 Frame typr recognise */
  35. #define FRAME_TYPE_802_3_DATA 0
  36. #define FRAME_TYPE_802_11_MANAGEMENT 1
  37. #define FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE 2
  38. #define FRAME_TYPE_802_11_CONTROL 3
  39. #define FRAME_TYPE_802_11_DATA 4
  40. #define FRAME_TYPE_PROMISCUOUS 5
  41. /* The follow definition is used for convert the frame------------ */
  42. #define DOT_11_SEQUENCE_OFFSET 22 /* Sequence control offset */
  43. #define DOT_3_TYPE_OFFSET 12
  44. #define DOT_11_MAC_HEADER_SIZE 24
  45. #define DOT_11_SNAP_SIZE 6
  46. #define DOT_11_TYPE_OFFSET 30 /* The start offset of 802.11 Frame. Type encapsulation. */
  47. #define DEFAULT_SIFSTIME 10
  48. #define DEFAULT_FRAGMENT_THRESHOLD 2346 /* No fragment */
  49. #define DEFAULT_MSDU_LIFE_TIME 0xffff
  50. #define LONG_PREAMBLE_PLUS_PLCPHEADER_TIME (144 + 48)
  51. #define SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME (72 + 24)
  52. #define PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION (16 + 4 + 6)
  53. #define Tsym 4
  54. /* Frame Type of Bits (2, 3)----------------------------------- */
  55. #define MAC_TYPE_MANAGEMENT 0x00
  56. #define MAC_TYPE_CONTROL 0x04
  57. #define MAC_TYPE_DATA 0x08
  58. #define MASK_FRAGMENT_NUMBER 0x000F
  59. #define SEQUENCE_NUMBER_SHIFT 4
  60. #define HAL_WOL_TYPE_WAKEUP_FRAME 0x01
  61. #define HAL_WOL_TYPE_MAGIC_PACKET 0x02
  62. #define HAL_KEYTYPE_WEP40 0
  63. #define HAL_KEYTYPE_WEP104 1
  64. #define HAL_KEYTYPE_TKIP 2 /* 128 bit key */
  65. #define HAL_KEYTYPE_AES_CCMP 3 /* 128 bit key */
  66. /* For VM state */
  67. enum {
  68. VM_STOP = 0,
  69. VM_RUNNING,
  70. VM_COMPLETED
  71. };
  72. /*
  73. * ================================
  74. * Normal Key table format
  75. * ================================
  76. */
  77. /* The order of KEY index is MAPPING_KEY_START_INDEX > GROUP_KEY_START_INDEX */
  78. #define MAX_KEY_TABLE 24 /* 24 entry for storing key data */
  79. #define GROUP_KEY_START_INDEX 4
  80. #define MAPPING_KEY_START_INDEX 8
  81. /*
  82. * =========================================
  83. * Descriptor
  84. * =========================================
  85. */
  86. #define MAX_DESCRIPTOR_BUFFER_INDEX 8 /* Have to multiple of 2 */
  87. #define FLAG_ERROR_TX_MASK 0x000000bf
  88. #define FLAG_ERROR_RX_MASK 0x0000083f
  89. #define FLAG_BAND_RX_MASK 0x10000000 /* Bit 28 */
  90. struct R00_descriptor {
  91. union {
  92. u32 value;
  93. #ifdef _BIG_ENDIAN_
  94. struct {
  95. u32 R00_packet_or_buffer_status:1;
  96. u32 R00_packet_in_fifo:1;
  97. u32 R00_RESERVED:2;
  98. u32 R00_receive_byte_count:12;
  99. u32 R00_receive_time_index:16;
  100. };
  101. #else
  102. struct {
  103. u32 R00_receive_time_index:16;
  104. u32 R00_receive_byte_count:12;
  105. u32 R00_RESERVED:2;
  106. u32 R00_packet_in_fifo:1;
  107. u32 R00_packet_or_buffer_status:1;
  108. };
  109. #endif
  110. };
  111. };
  112. struct T00_descriptor {
  113. union {
  114. u32 value;
  115. #ifdef _BIG_ENDIAN_
  116. struct {
  117. u32 T00_first_mpdu:1; /* for hardware use */
  118. u32 T00_last_mpdu:1; /* for hardware use */
  119. u32 T00_IsLastMpdu:1;/* 0:not 1:Yes for software used */
  120. u32 T00_IgnoreResult:1;/* The same mechanism with T00 setting. */
  121. u32 T00_RESERVED_ID:2;/* 3 bit ID reserved */
  122. u32 T00_tx_packet_id:4;
  123. u32 T00_RESERVED:4;
  124. u32 T00_header_length:6;
  125. u32 T00_frame_length:12;
  126. };
  127. #else
  128. struct {
  129. u32 T00_frame_length:12;
  130. u32 T00_header_length:6;
  131. u32 T00_RESERVED:4;
  132. u32 T00_tx_packet_id:4;
  133. u32 T00_RESERVED_ID:2; /* 3 bit ID reserved */
  134. u32 T00_IgnoreResult:1; /* The same mechanism with T00 setting. */
  135. u32 T00_IsLastMpdu:1; /* 0:not 1:Yes for software used */
  136. u32 T00_last_mpdu:1; /* for hardware use */
  137. u32 T00_first_mpdu:1; /* for hardware use */
  138. };
  139. #endif
  140. };
  141. };
  142. struct R01_descriptor {
  143. union {
  144. u32 value;
  145. #ifdef _BIG_ENDIAN_
  146. struct {
  147. u32 R01_RESERVED:3;
  148. u32 R01_mod_type:1;
  149. u32 R01_pre_type:1;
  150. u32 R01_data_rate:3;
  151. u32 R01_AGC_state:8;
  152. u32 R01_LNA_state:2;
  153. u32 R01_decryption_method:2;
  154. u32 R01_mic_error:1;
  155. u32 R01_replay:1;
  156. u32 R01_broadcast_frame:1;
  157. u32 R01_multicast_frame:1;
  158. u32 R01_directed_frame:1;
  159. u32 R01_receive_frame_antenna_selection:1;
  160. u32 R01_frame_receive_during_atim_window:1;
  161. u32 R01_protocol_version_error:1;
  162. u32 R01_authentication_frame_icv_error:1;
  163. u32 R01_null_key_to_authentication_frame:1;
  164. u32 R01_icv_error:1;
  165. u32 R01_crc_error:1;
  166. };
  167. #else
  168. struct {
  169. u32 R01_crc_error:1;
  170. u32 R01_icv_error:1;
  171. u32 R01_null_key_to_authentication_frame:1;
  172. u32 R01_authentication_frame_icv_error:1;
  173. u32 R01_protocol_version_error:1;
  174. u32 R01_frame_receive_during_atim_window:1;
  175. u32 R01_receive_frame_antenna_selection:1;
  176. u32 R01_directed_frame:1;
  177. u32 R01_multicast_frame:1;
  178. u32 R01_broadcast_frame:1;
  179. u32 R01_replay:1;
  180. u32 R01_mic_error:1;
  181. u32 R01_decryption_method:2;
  182. u32 R01_LNA_state:2;
  183. u32 R01_AGC_state:8;
  184. u32 R01_data_rate:3;
  185. u32 R01_pre_type:1;
  186. u32 R01_mod_type:1;
  187. u32 R01_RESERVED:3;
  188. };
  189. #endif
  190. };
  191. };
  192. struct T01_descriptor {
  193. union {
  194. u32 value;
  195. #ifdef _BIG_ENDIAN_
  196. struct {
  197. u32 T01_rts_cts_duration:16;
  198. u32 T01_fall_back_rate:3;
  199. u32 T01_add_rts:1;
  200. u32 T01_add_cts:1;
  201. u32 T01_modulation_type:1;
  202. u32 T01_plcp_header_length:1;
  203. u32 T01_transmit_rate:3;
  204. u32 T01_wep_id:2;
  205. u32 T01_add_challenge_text:1;
  206. u32 T01_inhibit_crc:1;
  207. u32 T01_loop_back_wep_mode:1;
  208. u32 T01_retry_abort_ebable:1;
  209. };
  210. #else
  211. struct {
  212. u32 T01_retry_abort_ebable:1;
  213. u32 T01_loop_back_wep_mode:1;
  214. u32 T01_inhibit_crc:1;
  215. u32 T01_add_challenge_text:1;
  216. u32 T01_wep_id:2;
  217. u32 T01_transmit_rate:3;
  218. u32 T01_plcp_header_length:1;
  219. u32 T01_modulation_type:1;
  220. u32 T01_add_cts:1;
  221. u32 T01_add_rts:1;
  222. u32 T01_fall_back_rate:3;
  223. u32 T01_rts_cts_duration:16;
  224. };
  225. #endif
  226. };
  227. };
  228. struct T02_descriptor {
  229. union {
  230. u32 value;
  231. #ifdef _BIG_ENDIAN_
  232. struct {
  233. u32 T02_IsLastMpdu:1; /* The same mechanism with T00 setting */
  234. u32 T02_IgnoreResult:1; /* The same mechanism with T00 setting. */
  235. u32 T02_RESERVED_ID:2; /* The same mechanism with T00 setting */
  236. u32 T02_Tx_PktID:4;
  237. u32 T02_MPDU_Cnt:4;
  238. u32 T02_RTS_Cnt:4;
  239. u32 T02_RESERVED:7;
  240. u32 T02_transmit_complete:1;
  241. u32 T02_transmit_abort_due_to_TBTT:1;
  242. u32 T02_effective_transmission_rate:1;
  243. u32 T02_transmit_without_encryption_due_to_wep_on_false:1;
  244. u32 T02_discard_due_to_null_wep_key:1;
  245. u32 T02_RESERVED_1:1;
  246. u32 T02_out_of_MaxTxMSDULiftTime:1;
  247. u32 T02_transmit_abort:1;
  248. u32 T02_transmit_fail:1;
  249. };
  250. #else
  251. struct {
  252. u32 T02_transmit_fail:1;
  253. u32 T02_transmit_abort:1;
  254. u32 T02_out_of_MaxTxMSDULiftTime:1;
  255. u32 T02_RESERVED_1:1;
  256. u32 T02_discard_due_to_null_wep_key:1;
  257. u32 T02_transmit_without_encryption_due_to_wep_on_false:1;
  258. u32 T02_effective_transmission_rate:1;
  259. u32 T02_transmit_abort_due_to_TBTT:1;
  260. u32 T02_transmit_complete:1;
  261. u32 T02_RESERVED:7;
  262. u32 T02_RTS_Cnt:4;
  263. u32 T02_MPDU_Cnt:4;
  264. u32 T02_Tx_PktID:4;
  265. u32 T02_RESERVED_ID:2; /* The same mechanism with T00 setting */
  266. u32 T02_IgnoreResult:1; /* The same mechanism with T00 setting. */
  267. u32 T02_IsLastMpdu:1; /* The same mechanism with T00 setting */
  268. };
  269. #endif
  270. };
  271. };
  272. struct wb35_descriptor { /* Skip length = 8 DWORD */
  273. /* ID for descriptor ---, The field doesn't be cleard in the operation of Descriptor definition */
  274. u8 Descriptor_ID;
  275. /* ----------------------The above region doesn't be cleared by DESCRIPTOR_RESET------ */
  276. u8 RESERVED[3];
  277. u16 FragmentThreshold;
  278. u8 InternalUsed; /* Only can be used by operation of descriptor definition */
  279. u8 Type; /* 0: 802.3 1:802.11 data frame 2:802.11 management frame */
  280. u8 PreambleMode;/* 0: short 1:long */
  281. u8 TxRate;
  282. u8 FragmentCount;
  283. u8 EapFix; /* For speed up key install */
  284. /* For R00 and T00 ------------------------------ */
  285. union {
  286. struct R00_descriptor R00;
  287. struct T00_descriptor T00;
  288. };
  289. /* For R01 and T01 ------------------------------ */
  290. union {
  291. struct R01_descriptor R01;
  292. struct T01_descriptor T01;
  293. };
  294. /* For R02 and T02 ------------------------------ */
  295. union {
  296. u32 R02;
  297. struct T02_descriptor T02;
  298. };
  299. /* For R03 and T03 ------------------------------ */
  300. /* For software used */
  301. union {
  302. u32 R03;
  303. u32 T03;
  304. struct {
  305. u8 buffer_number;
  306. u8 buffer_start_index;
  307. u16 buffer_total_size;
  308. };
  309. };
  310. /* For storing the buffer */
  311. u16 buffer_size[MAX_DESCRIPTOR_BUFFER_INDEX];
  312. void *buffer_address[MAX_DESCRIPTOR_BUFFER_INDEX];
  313. };
  314. #define MAX_TXVGA_EEPROM 9 /* How many word(u16) of EEPROM will be used for TxVGA */
  315. #define MAX_RF_PARAMETER 32
  316. struct txvga_for_50 {
  317. u8 ChanNo;
  318. u8 TxVgaValue;
  319. };
  320. /*
  321. * ==============================================
  322. * Device related include
  323. * ==============================================
  324. */
  325. #include "wb35reg_s.h"
  326. #include "wb35tx_s.h"
  327. #include "wb35rx_s.h"
  328. /* For Hal using ============================================ */
  329. struct hw_data {
  330. /* For compatible with 33 */
  331. u32 revision;
  332. u32 BB3c_cal; /* The value for Tx calibration comes from EEPROM */
  333. u32 BB54_cal; /* The value for Rx calibration comes from EEPROM */
  334. /* For surprise remove */
  335. u32 SurpriseRemove; /* 0: Normal 1: Surprise remove */
  336. u8 IsKeyPreSet;
  337. u8 CalOneTime;
  338. u8 VCO_trim;
  339. u32 FragCount;
  340. u32 DMAFix; /* V1_DMA_FIX The variable can be removed if driver want to save mem space for V2. */
  341. /*
  342. * ===============================================
  343. * Definition for MAC address
  344. * ===============================================
  345. */
  346. u8 PermanentMacAddress[ETH_ALEN + 2]; /* The Ethernet addr that are stored in EEPROM. + 2 to 8-byte alignment */
  347. u8 CurrentMacAddress[ETH_ALEN + 2]; /* The Enthernet addr that are in used. + 2 to 8-byte alignment */
  348. /*
  349. * =========================================
  350. * Definition for 802.11
  351. * =========================================
  352. */
  353. u8 *bssid_pointer; /* Used by hal_get_bssid for return value */
  354. u8 bssid[8]; /* Only 6 byte will be used. 8 byte is required for read buffer */
  355. u8 ssid[32]; /* maximum ssid length is 32 byte */
  356. u16 AID;
  357. u8 ssid_length;
  358. u8 Channel;
  359. u16 ListenInterval;
  360. u16 CapabilityInformation;
  361. u16 BeaconPeriod;
  362. u16 ProbeDelay;
  363. u8 bss_type;/* 0: IBSS_NET or 1:ESS_NET */
  364. u8 preamble;/* 0: short preamble, 1: long preamble */
  365. u8 slot_time_select; /* 9 or 20 value */
  366. u8 phy_type; /* Phy select */
  367. u32 phy_para[MAX_RF_PARAMETER];
  368. u32 phy_number;
  369. u32 CurrentRadioSw; /* 0:On 1:Off */
  370. u32 CurrentRadioHw; /* 0:On 1:Off */
  371. u8 *power_save_point; /* Used by hal_get_power_save_mode for return value */
  372. u8 cwmin;
  373. u8 desired_power_save;
  374. u8 dtim; /* Is running dtim */
  375. u8 mapping_key_replace_index; /* In Key table, the next index be replaced */
  376. u16 MaxReceiveLifeTime;
  377. u16 FragmentThreshold;
  378. u16 FragmentThreshold_tmp;
  379. u16 cwmax;
  380. u8 Key_slot[MAX_KEY_TABLE][8]; /* Ownership record for key slot. For Alignment */
  381. u32 Key_content[MAX_KEY_TABLE][12]; /* 10DW for each entry + 2 for burst command (Off and On valid bit) */
  382. u8 CurrentDefaultKeyIndex;
  383. u32 CurrentDefaultKeyLength;
  384. /*
  385. * ==================================================
  386. * Variable for each module
  387. * ==================================================
  388. */
  389. struct usb_device *udev;
  390. struct wb35_reg reg; /* Need Wb35Reg.h */
  391. struct wb35_tx Wb35Tx; /* Need Wb35Tx.h */
  392. struct wb35_rx Wb35Rx; /* Need Wb35Rx.h */
  393. struct timer_list LEDTimer; /* For LED */
  394. u32 LEDpoint; /* For LED */
  395. u32 dto_tx_retry_count;
  396. u32 dto_tx_frag_count;
  397. u32 rx_ok_count[13]; /* index=0: total rx ok */
  398. u32 rx_err_count[13]; /* index=0: total rx err */
  399. /* for Tx debug */
  400. u32 tx_TBTT_start_count;
  401. u32 tx_ETR_count;
  402. u32 tx_WepOn_false_count;
  403. u32 tx_Null_key_count;
  404. u32 tx_retry_count[8];
  405. u8 PowerIndexFromEEPROM; /* For 2412MHz */
  406. u8 power_index;
  407. u8 IsWaitJoinComplete; /* TRUE: set join request */
  408. u8 band;
  409. u16 SoftwareSet;
  410. u16 Reserved_s;
  411. u32 IsInitOK; /* 0: Driver starting 1: Driver init OK */
  412. /* For Phy calibration */
  413. s32 iq_rsdl_gain_tx_d2;
  414. s32 iq_rsdl_phase_tx_d2;
  415. u32 txvga_setting_for_cal;
  416. u8 TxVgaSettingInEEPROM[(((MAX_TXVGA_EEPROM * 2) + 3) & ~0x03)]; /* For EEPROM value */
  417. u8 TxVgaFor24[16]; /* Max is 14, 2 for alignment */
  418. struct txvga_for_50 TxVgaFor50[36]; /* 35 channels in 5G. 35x2 = 70 byte. 2 for alignments */
  419. u16 Scan_Interval;
  420. u16 RESERVED6;
  421. /* LED control */
  422. u32 LED_control;
  423. /*
  424. * LED_control 4 byte: Gray_Led_1[3] Gray_Led_0[2] Led[1] Led[0]
  425. * Gray_Led
  426. * For Led gray setting
  427. * Led
  428. * 0: normal control,
  429. * LED behavior will decide by EEPROM setting
  430. * 1: Turn off specific LED
  431. * 2: Always on specific LED
  432. * 3: slow blinking specific LED
  433. * 4: fast blinking specific LED
  434. * 5: WPS led control is set. Led0 is Red, Led1 id Green
  435. *
  436. * Led[1] is parameter for WPS LED mode
  437. * 1:InProgress
  438. * 2: Error
  439. * 3: Session overlap
  440. * 4: Success control
  441. */
  442. u32 LED_LinkOn; /* Turn LED on control */
  443. u32 LED_Scanning; /* Let LED in scan process control */
  444. u32 LED_Blinking; /* Temp variable for shining */
  445. u32 RxByteCountLast;
  446. u32 TxByteCountLast;
  447. /* For global timer */
  448. u32 time_count; /* TICK_TIME_100ms 1 = 100ms */
  449. };
  450. #endif