PageRenderTime 60ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/source/kernel/android-2.6.35/drivers/staging/rtl8187se/ieee80211/ieee80211.h

https://bitbucket.org/tfzxyinhao/kindle-fire
C++ Header | 1484 lines | 954 code | 244 blank | 286 comment | 27 complexity | 8e2211cfcdc5ed50fa35bf0761a4d38d MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-3.0, 0BSD, MPL-2.0-no-copyleft-exception, GPL-2.0, LGPL-2.0, BSD-3-Clause, LGPL-2.1, Apache-2.0, AGPL-3.0, GPL-3.0
  1. /*
  2. * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
  3. * remains copyright by the original authors
  4. *
  5. * Portions of the merged code are based on Host AP (software wireless
  6. * LAN access point) driver for Intersil Prism2/2.5/3.
  7. *
  8. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  9. * <jkmaline@cc.hut.fi>
  10. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  11. *
  12. * Adaption to a generic IEEE 802.11 stack by James Ketrenos
  13. * <jketreno@linux.intel.com>
  14. * Copyright (c) 2004, Intel Corporation
  15. *
  16. * Modified for Realtek's wi-fi cards by Andrea Merello
  17. * <andreamrl@tiscali.it>
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License version 2 as
  21. * published by the Free Software Foundation. See README and COPYING for
  22. * more details.
  23. */
  24. #ifndef IEEE80211_H
  25. #define IEEE80211_H
  26. #include <linux/if_ether.h> /* ETH_ALEN */
  27. #include <linux/kernel.h> /* ARRAY_SIZE */
  28. #include <linux/version.h>
  29. #include <linux/jiffies.h>
  30. #include <linux/timer.h>
  31. #include <linux/sched.h>
  32. #include <linux/semaphore.h>
  33. #include <linux/wireless.h>
  34. #include <linux/ieee80211.h>
  35. #define KEY_TYPE_NA 0x0
  36. #define KEY_TYPE_WEP40 0x1
  37. #define KEY_TYPE_TKIP 0x2
  38. #define KEY_TYPE_CCMP 0x4
  39. #define KEY_TYPE_WEP104 0x5
  40. #define aSifsTime 10
  41. #define MGMT_QUEUE_NUM 5
  42. #define IEEE_CMD_SET_WPA_PARAM 1
  43. #define IEEE_CMD_SET_WPA_IE 2
  44. #define IEEE_CMD_SET_ENCRYPTION 3
  45. #define IEEE_CMD_MLME 4
  46. #define IEEE_PARAM_WPA_ENABLED 1
  47. #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
  48. #define IEEE_PARAM_DROP_UNENCRYPTED 3
  49. #define IEEE_PARAM_PRIVACY_INVOKED 4
  50. #define IEEE_PARAM_AUTH_ALGS 5
  51. #define IEEE_PARAM_IEEE_802_1X 6
  52. //It should consistent with the driver_XXX.c
  53. // David, 2006.9.26
  54. #define IEEE_PARAM_WPAX_SELECT 7
  55. //Added for notify the encryption type selection
  56. // David, 2006.9.26
  57. #define IEEE_PROTO_WPA 1
  58. #define IEEE_PROTO_RSN 2
  59. //Added for notify the encryption type selection
  60. // David, 2006.9.26
  61. #define IEEE_WPAX_USEGROUP 0
  62. #define IEEE_WPAX_WEP40 1
  63. #define IEEE_WPAX_TKIP 2
  64. #define IEEE_WPAX_WRAP 3
  65. #define IEEE_WPAX_CCMP 4
  66. #define IEEE_WPAX_WEP104 5
  67. #define IEEE_KEY_MGMT_IEEE8021X 1
  68. #define IEEE_KEY_MGMT_PSK 2
  69. #define IEEE_MLME_STA_DEAUTH 1
  70. #define IEEE_MLME_STA_DISASSOC 2
  71. #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
  72. #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
  73. #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
  74. #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
  75. #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
  76. #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
  77. #define IEEE_CRYPT_ALG_NAME_LEN 16
  78. //by amy for ps
  79. typedef struct ieee_param {
  80. u32 cmd;
  81. u8 sta_addr[ETH_ALEN];
  82. union {
  83. struct {
  84. u8 name;
  85. u32 value;
  86. } wpa_param;
  87. struct {
  88. u32 len;
  89. u8 reserved[32];
  90. u8 data[0];
  91. } wpa_ie;
  92. struct{
  93. int command;
  94. int reason_code;
  95. } mlme;
  96. struct {
  97. u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
  98. u8 set_tx;
  99. u32 err;
  100. u8 idx;
  101. u8 seq[8]; /* sequence counter (set: RX, get: TX) */
  102. u16 key_len;
  103. u8 key[0];
  104. } crypt;
  105. } u;
  106. }ieee_param;
  107. #define MSECS(t) msecs_to_jiffies(t)
  108. #define msleep_interruptible_rtl msleep_interruptible
  109. #define IEEE80211_DATA_LEN 2304
  110. /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
  111. 6.2.1.1.2.
  112. The figure in section 7.1.2 suggests a body size of up to 2312
  113. bytes is allowed, which is a bit confusing, I suspect this
  114. represents the 2304 bytes of real data, plus a possible 8 bytes of
  115. WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
  116. #define IEEE80211_3ADDR_LEN 24
  117. #define IEEE80211_4ADDR_LEN 30
  118. #define IEEE80211_FCS_LEN 4
  119. #define IEEE80211_HLEN IEEE80211_4ADDR_LEN
  120. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  121. #define IEEE80211_MGMT_HDR_LEN 24
  122. #define IEEE80211_DATA_HDR3_LEN 24
  123. #define IEEE80211_DATA_HDR4_LEN 30
  124. #define MIN_FRAG_THRESHOLD 256U
  125. #define MAX_FRAG_THRESHOLD 2346U
  126. /* Frame control field constants */
  127. #define IEEE80211_FCTL_DSTODS 0x0300 //added by david
  128. #define IEEE80211_FCTL_WEP 0x4000
  129. /* debug macros */
  130. #ifdef CONFIG_IEEE80211_DEBUG
  131. extern u32 ieee80211_debug_level;
  132. #define IEEE80211_DEBUG(level, fmt, args...) \
  133. do { if (ieee80211_debug_level & (level)) \
  134. printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
  135. in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
  136. #else
  137. #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
  138. #endif /* CONFIG_IEEE80211_DEBUG */
  139. /*
  140. * To use the debug system;
  141. *
  142. * If you are defining a new debug classification, simply add it to the #define
  143. * list here in the form of:
  144. *
  145. * #define IEEE80211_DL_xxxx VALUE
  146. *
  147. * shifting value to the left one bit from the previous entry. xxxx should be
  148. * the name of the classification (for example, WEP)
  149. *
  150. * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
  151. * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
  152. * to send output to that classification.
  153. *
  154. * To add your debug level to the list of levels seen when you perform
  155. *
  156. * % cat /proc/net/ipw/debug_level
  157. *
  158. * you simply need to add your entry to the ipw_debug_levels array.
  159. *
  160. * If you do not see debug_level in /proc/net/ipw then you do not have
  161. * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
  162. *
  163. */
  164. #define IEEE80211_DL_INFO (1<<0)
  165. #define IEEE80211_DL_WX (1<<1)
  166. #define IEEE80211_DL_SCAN (1<<2)
  167. #define IEEE80211_DL_STATE (1<<3)
  168. #define IEEE80211_DL_MGMT (1<<4)
  169. #define IEEE80211_DL_FRAG (1<<5)
  170. #define IEEE80211_DL_EAP (1<<6)
  171. #define IEEE80211_DL_DROP (1<<7)
  172. #define IEEE80211_DL_TX (1<<8)
  173. #define IEEE80211_DL_RX (1<<9)
  174. #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
  175. #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
  176. #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
  177. #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
  178. #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
  179. //#define IEEE_DEBUG_SCAN IEEE80211_WARNING
  180. #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
  181. #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
  182. #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
  183. #define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
  184. #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
  185. #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
  186. #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
  187. #include <linux/netdevice.h>
  188. #include <linux/wireless.h>
  189. #include <linux/if_arp.h> /* ARPHRD_ETHER */
  190. #ifndef WIRELESS_SPY
  191. #define WIRELESS_SPY // enable iwspy support
  192. #endif
  193. #include <net/iw_handler.h> // new driver API
  194. #ifndef ETH_P_PAE
  195. #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
  196. #endif /* ETH_P_PAE */
  197. #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
  198. #ifndef ETH_P_80211_RAW
  199. #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
  200. #endif
  201. /* IEEE 802.11 defines */
  202. #define P80211_OUI_LEN 3
  203. struct ieee80211_snap_hdr {
  204. u8 dsap; /* always 0xAA */
  205. u8 ssap; /* always 0xAA */
  206. u8 ctrl; /* always 0x03 */
  207. u8 oui[P80211_OUI_LEN]; /* organizational universal id */
  208. } __attribute__ ((packed));
  209. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  210. #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
  211. #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
  212. #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
  213. #define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
  214. #define WLAN_CAPABILITY_BSS (1<<0)
  215. #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
  216. #define IEEE80211_STATMASK_SIGNAL (1<<0)
  217. #define IEEE80211_STATMASK_RSSI (1<<1)
  218. #define IEEE80211_STATMASK_NOISE (1<<2)
  219. #define IEEE80211_STATMASK_RATE (1<<3)
  220. #define IEEE80211_STATMASK_WEMASK 0x7
  221. #define IEEE80211_CCK_MODULATION (1<<0)
  222. #define IEEE80211_OFDM_MODULATION (1<<1)
  223. #define IEEE80211_24GHZ_BAND (1<<0)
  224. #define IEEE80211_52GHZ_BAND (1<<1)
  225. #define IEEE80211_CCK_RATE_LEN 4
  226. #define IEEE80211_CCK_RATE_1MB 0x02
  227. #define IEEE80211_CCK_RATE_2MB 0x04
  228. #define IEEE80211_CCK_RATE_5MB 0x0B
  229. #define IEEE80211_CCK_RATE_11MB 0x16
  230. #define IEEE80211_OFDM_RATE_LEN 8
  231. #define IEEE80211_OFDM_RATE_6MB 0x0C
  232. #define IEEE80211_OFDM_RATE_9MB 0x12
  233. #define IEEE80211_OFDM_RATE_12MB 0x18
  234. #define IEEE80211_OFDM_RATE_18MB 0x24
  235. #define IEEE80211_OFDM_RATE_24MB 0x30
  236. #define IEEE80211_OFDM_RATE_36MB 0x48
  237. #define IEEE80211_OFDM_RATE_48MB 0x60
  238. #define IEEE80211_OFDM_RATE_54MB 0x6C
  239. #define IEEE80211_BASIC_RATE_MASK 0x80
  240. #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
  241. #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
  242. #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
  243. #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
  244. #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
  245. #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
  246. #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
  247. #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
  248. #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
  249. #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
  250. #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
  251. #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
  252. #define IEEE80211_CCK_RATES_MASK 0x0000000F
  253. #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
  254. IEEE80211_CCK_RATE_2MB_MASK)
  255. #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
  256. IEEE80211_CCK_RATE_5MB_MASK | \
  257. IEEE80211_CCK_RATE_11MB_MASK)
  258. #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
  259. #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
  260. IEEE80211_OFDM_RATE_12MB_MASK | \
  261. IEEE80211_OFDM_RATE_24MB_MASK)
  262. #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
  263. IEEE80211_OFDM_RATE_9MB_MASK | \
  264. IEEE80211_OFDM_RATE_18MB_MASK | \
  265. IEEE80211_OFDM_RATE_36MB_MASK | \
  266. IEEE80211_OFDM_RATE_48MB_MASK | \
  267. IEEE80211_OFDM_RATE_54MB_MASK)
  268. #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
  269. IEEE80211_CCK_DEFAULT_RATES_MASK)
  270. #define IEEE80211_NUM_OFDM_RATES 8
  271. #define IEEE80211_NUM_CCK_RATES 4
  272. #define IEEE80211_OFDM_SHIFT_MASK_A 4
  273. /* this is stolen and modified from the madwifi driver*/
  274. #define IEEE80211_FC0_TYPE_MASK 0x0c
  275. #define IEEE80211_FC0_TYPE_DATA 0x08
  276. #define IEEE80211_FC0_SUBTYPE_MASK 0xB0
  277. #define IEEE80211_FC0_SUBTYPE_QOS 0x80
  278. #define IEEE80211_QOS_HAS_SEQ(fc) \
  279. (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
  280. (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
  281. /* this is stolen from ipw2200 driver */
  282. #define IEEE_IBSS_MAC_HASH_SIZE 31
  283. struct ieee_ibss_seq {
  284. u8 mac[ETH_ALEN];
  285. u16 seq_num[17];
  286. u16 frag_num[17];
  287. unsigned long packet_time[17];
  288. struct list_head list;
  289. };
  290. /* NOTE: This data is for statistical purposes; not all hardware provides this
  291. * information for frames received. Not setting these will not cause
  292. * any adverse affects. */
  293. struct ieee80211_rx_stats {
  294. u32 mac_time[2];
  295. u8 signalstrength;
  296. s8 rssi;
  297. u8 signal;
  298. u8 noise;
  299. u16 rate; /* in 100 kbps */
  300. u8 received_channel;
  301. u8 control;
  302. u8 mask;
  303. u8 freq;
  304. u16 len;
  305. u8 nic_type;
  306. };
  307. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  308. * three fragmented frames. This define can be increased to support more
  309. * concurrent frames, but it should be noted that each entry can consume about
  310. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  311. #define IEEE80211_FRAG_CACHE_LEN 4
  312. struct ieee80211_frag_entry {
  313. unsigned long first_frag_time;
  314. unsigned int seq;
  315. unsigned int last_frag;
  316. struct sk_buff *skb;
  317. u8 src_addr[ETH_ALEN];
  318. u8 dst_addr[ETH_ALEN];
  319. };
  320. struct ieee80211_stats {
  321. unsigned int tx_unicast_frames;
  322. unsigned int tx_multicast_frames;
  323. unsigned int tx_fragments;
  324. unsigned int tx_unicast_octets;
  325. unsigned int tx_multicast_octets;
  326. unsigned int tx_deferred_transmissions;
  327. unsigned int tx_single_retry_frames;
  328. unsigned int tx_multiple_retry_frames;
  329. unsigned int tx_retry_limit_exceeded;
  330. unsigned int tx_discards;
  331. unsigned int rx_unicast_frames;
  332. unsigned int rx_multicast_frames;
  333. unsigned int rx_fragments;
  334. unsigned int rx_unicast_octets;
  335. unsigned int rx_multicast_octets;
  336. unsigned int rx_fcs_errors;
  337. unsigned int rx_discards_no_buffer;
  338. unsigned int tx_discards_wrong_sa;
  339. unsigned int rx_discards_undecryptable;
  340. unsigned int rx_message_in_msg_fragments;
  341. unsigned int rx_message_in_bad_msg_fragments;
  342. };
  343. struct ieee80211_device;
  344. #include "ieee80211_crypt.h"
  345. #define SEC_KEY_1 (1<<0)
  346. #define SEC_KEY_2 (1<<1)
  347. #define SEC_KEY_3 (1<<2)
  348. #define SEC_KEY_4 (1<<3)
  349. #define SEC_ACTIVE_KEY (1<<4)
  350. #define SEC_AUTH_MODE (1<<5)
  351. #define SEC_UNICAST_GROUP (1<<6)
  352. #define SEC_LEVEL (1<<7)
  353. #define SEC_ENABLED (1<<8)
  354. #define SEC_LEVEL_0 0 /* None */
  355. #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
  356. #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
  357. #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
  358. #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
  359. #define WEP_KEYS 4
  360. #define WEP_KEY_LEN 13
  361. #define WEP_KEY_LEN_MODIF 32
  362. struct ieee80211_security {
  363. u16 active_key:2,
  364. enabled:1,
  365. auth_mode:2,
  366. auth_algo:4,
  367. unicast_uses_group:1;
  368. u8 key_sizes[WEP_KEYS];
  369. u8 keys[WEP_KEYS][WEP_KEY_LEN_MODIF];
  370. u8 level;
  371. u16 flags;
  372. } __attribute__ ((packed));
  373. /*
  374. 802.11 data frame from AP
  375. ,-------------------------------------------------------------------.
  376. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
  377. |------|------|---------|---------|---------|------|---------|------|
  378. Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
  379. | | tion | (BSSID) | | | ence | data | |
  380. `-------------------------------------------------------------------'
  381. Total: 28-2340 bytes
  382. */
  383. /* Management Frame Information Element Types */
  384. enum {
  385. MFIE_TYPE_SSID = 0,
  386. MFIE_TYPE_RATES = 1,
  387. MFIE_TYPE_FH_SET = 2,
  388. MFIE_TYPE_DS_SET = 3,
  389. MFIE_TYPE_CF_SET = 4,
  390. MFIE_TYPE_TIM = 5,
  391. MFIE_TYPE_IBSS_SET = 6,
  392. MFIE_TYPE_COUNTRY = 7,
  393. MFIE_TYPE_CHALLENGE = 16,
  394. MFIE_TYPE_ERP = 42,
  395. MFIE_TYPE_RSN = 48,
  396. MFIE_TYPE_RATES_EX = 50,
  397. MFIE_TYPE_GENERIC = 221,
  398. };
  399. struct ieee80211_header_data {
  400. u16 frame_ctl;
  401. u16 duration_id;
  402. u8 addr1[6];
  403. u8 addr2[6];
  404. u8 addr3[6];
  405. u16 seq_ctrl;
  406. };
  407. struct ieee80211_hdr_4addr {
  408. u16 frame_ctl;
  409. u16 duration_id;
  410. u8 addr1[ETH_ALEN];
  411. u8 addr2[ETH_ALEN];
  412. u8 addr3[ETH_ALEN];
  413. u16 seq_ctl;
  414. u8 addr4[ETH_ALEN];
  415. } __attribute__ ((packed));
  416. struct ieee80211_hdr_3addrqos {
  417. u16 frame_ctl;
  418. u16 duration_id;
  419. u8 addr1[ETH_ALEN];
  420. u8 addr2[ETH_ALEN];
  421. u8 addr3[ETH_ALEN];
  422. u16 seq_ctl;
  423. u16 qos_ctl;
  424. } __attribute__ ((packed));
  425. struct ieee80211_hdr_4addrqos {
  426. u16 frame_ctl;
  427. u16 duration_id;
  428. u8 addr1[ETH_ALEN];
  429. u8 addr2[ETH_ALEN];
  430. u8 addr3[ETH_ALEN];
  431. u16 seq_ctl;
  432. u8 addr4[ETH_ALEN];
  433. u16 qos_ctl;
  434. } __attribute__ ((packed));
  435. struct ieee80211_info_element_hdr {
  436. u8 id;
  437. u8 len;
  438. } __attribute__ ((packed));
  439. struct ieee80211_info_element {
  440. u8 id;
  441. u8 len;
  442. u8 data[0];
  443. } __attribute__ ((packed));
  444. struct ieee80211_authentication {
  445. struct ieee80211_header_data header;
  446. u16 algorithm;
  447. u16 transaction;
  448. u16 status;
  449. //struct ieee80211_info_element_hdr info_element;
  450. } __attribute__ ((packed));
  451. struct ieee80211_disassoc_frame {
  452. struct ieee80211_hdr_3addr header;
  453. u16 reasoncode;
  454. } __attribute__ ((packed));
  455. struct ieee80211_probe_request {
  456. struct ieee80211_header_data header;
  457. /* struct ieee80211_info_element info_element; */
  458. } __attribute__ ((packed));
  459. struct ieee80211_probe_response {
  460. struct ieee80211_header_data header;
  461. u32 time_stamp[2];
  462. u16 beacon_interval;
  463. u16 capability;
  464. struct ieee80211_info_element info_element;
  465. } __attribute__ ((packed));
  466. struct ieee80211_assoc_request_frame {
  467. struct ieee80211_hdr_3addr header;
  468. u16 capability;
  469. u16 listen_interval;
  470. //u8 current_ap[ETH_ALEN];
  471. struct ieee80211_info_element_hdr info_element;
  472. } __attribute__ ((packed));
  473. struct ieee80211_assoc_response_frame {
  474. struct ieee80211_hdr_3addr header;
  475. u16 capability;
  476. u16 status;
  477. u16 aid;
  478. struct ieee80211_info_element info_element; /* supported rates */
  479. } __attribute__ ((packed));
  480. struct ieee80211_txb {
  481. u8 nr_frags;
  482. u8 encrypted;
  483. u16 reserved;
  484. u16 frag_size;
  485. u16 payload_size;
  486. struct sk_buff *fragments[0];
  487. };
  488. /* SWEEP TABLE ENTRIES NUMBER */
  489. #define MAX_SWEEP_TAB_ENTRIES 42
  490. #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
  491. /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
  492. * only use 8, and then use extended rates for the remaining supported
  493. * rates. Other APs, however, stick all of their supported rates on the
  494. * main rates information element... */
  495. #define MAX_RATES_LENGTH ((u8)12)
  496. #define MAX_RATES_EX_LENGTH ((u8)16)
  497. #define MAX_NETWORK_COUNT 128
  498. #define MAX_CHANNEL_NUMBER 165
  499. #define IEEE80211_SOFTMAC_SCAN_TIME 100 /* (HZ / 2) */
  500. #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
  501. #define CRC_LENGTH 4U
  502. #define MAX_WPA_IE_LEN 64
  503. #define NETWORK_EMPTY_ESSID (1 << 0)
  504. #define NETWORK_HAS_OFDM (1 << 1)
  505. #define NETWORK_HAS_CCK (1 << 2)
  506. struct ieee80211_wmm_ac_param {
  507. u8 ac_aci_acm_aifsn;
  508. u8 ac_ecwmin_ecwmax;
  509. u16 ac_txop_limit;
  510. };
  511. struct ieee80211_wmm_ts_info {
  512. u8 ac_dir_tid;
  513. u8 ac_up_psb;
  514. u8 reserved;
  515. } __attribute__ ((packed));
  516. struct ieee80211_wmm_tspec_elem {
  517. struct ieee80211_wmm_ts_info ts_info;
  518. u16 norm_msdu_size;
  519. u16 max_msdu_size;
  520. u32 min_serv_inter;
  521. u32 max_serv_inter;
  522. u32 inact_inter;
  523. u32 suspen_inter;
  524. u32 serv_start_time;
  525. u32 min_data_rate;
  526. u32 mean_data_rate;
  527. u32 peak_data_rate;
  528. u32 max_burst_size;
  529. u32 delay_bound;
  530. u32 min_phy_rate;
  531. u16 surp_band_allow;
  532. u16 medium_time;
  533. }__attribute__((packed));
  534. enum eap_type {
  535. EAP_PACKET = 0,
  536. EAPOL_START,
  537. EAPOL_LOGOFF,
  538. EAPOL_KEY,
  539. EAPOL_ENCAP_ASF_ALERT
  540. };
  541. static const char *eap_types[] = {
  542. [EAP_PACKET] = "EAP-Packet",
  543. [EAPOL_START] = "EAPOL-Start",
  544. [EAPOL_LOGOFF] = "EAPOL-Logoff",
  545. [EAPOL_KEY] = "EAPOL-Key",
  546. [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
  547. };
  548. static inline const char *eap_get_type(int type)
  549. {
  550. return (type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
  551. }
  552. struct eapol {
  553. u8 snap[6];
  554. u16 ethertype;
  555. u8 version;
  556. u8 type;
  557. u16 length;
  558. } __attribute__ ((packed));
  559. struct ieee80211_softmac_stats {
  560. unsigned int rx_ass_ok;
  561. unsigned int rx_ass_err;
  562. unsigned int rx_probe_rq;
  563. unsigned int tx_probe_rs;
  564. unsigned int tx_beacons;
  565. unsigned int rx_auth_rq;
  566. unsigned int rx_auth_rs_ok;
  567. unsigned int rx_auth_rs_err;
  568. unsigned int tx_auth_rq;
  569. unsigned int no_auth_rs;
  570. unsigned int no_ass_rs;
  571. unsigned int tx_ass_rq;
  572. unsigned int rx_ass_rq;
  573. unsigned int tx_probe_rq;
  574. unsigned int reassoc;
  575. unsigned int swtxstop;
  576. unsigned int swtxawake;
  577. };
  578. #define BEACON_PROBE_SSID_ID_POSITION 12
  579. /*
  580. * These are the data types that can make up management packets
  581. *
  582. u16 auth_algorithm;
  583. u16 auth_sequence;
  584. u16 beacon_interval;
  585. u16 capability;
  586. u8 current_ap[ETH_ALEN];
  587. u16 listen_interval;
  588. struct {
  589. u16 association_id:14, reserved:2;
  590. } __attribute__ ((packed));
  591. u32 time_stamp[2];
  592. u16 reason;
  593. u16 status;
  594. */
  595. #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
  596. #define IEEE80211_DEFAULT_BASIC_RATE 10
  597. enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
  598. #define MAX_SP_Len (WMM_all_frame << 4)
  599. #define IEEE80211_QOS_TID 0x0f
  600. #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
  601. #define MAX_IE_LEN 0xFF //+YJ,080625
  602. typedef struct _CHANNEL_LIST{
  603. u8 Channel[MAX_CHANNEL_NUMBER + 1];
  604. u8 Len;
  605. }CHANNEL_LIST, *PCHANNEL_LIST;
  606. //by amy for ps
  607. #define IEEE80211_WATCH_DOG_TIME 2000
  608. //by amy for ps
  609. //by amy for antenna
  610. #define ANTENNA_DIVERSITY_TIMER_PERIOD 1000 // 1000 m
  611. //by amy for antenna
  612. #define IEEE80211_DTIM_MBCAST 4
  613. #define IEEE80211_DTIM_UCAST 2
  614. #define IEEE80211_DTIM_VALID 1
  615. #define IEEE80211_DTIM_INVALID 0
  616. #define IEEE80211_PS_DISABLED 0
  617. #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
  618. #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
  619. #define IEEE80211_PS_ENABLE IEEE80211_DTIM_VALID
  620. //added by David for QoS 2006/6/30
  621. //#define WMM_Hang_8187
  622. #ifdef WMM_Hang_8187
  623. #undef WMM_Hang_8187
  624. #endif
  625. #define WME_AC_BE 0x00
  626. #define WME_AC_BK 0x01
  627. #define WME_AC_VI 0x02
  628. #define WME_AC_VO 0x03
  629. #define WME_ACI_MASK 0x03
  630. #define WME_AIFSN_MASK 0x03
  631. #define WME_AC_PRAM_LEN 16
  632. //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
  633. //#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
  634. #define UP2AC(up) ( \
  635. ((up) < 1) ? WME_AC_BE : \
  636. ((up) < 3) ? WME_AC_BK : \
  637. ((up) < 4) ? WME_AC_BE : \
  638. ((up) < 6) ? WME_AC_VI : \
  639. WME_AC_VO)
  640. //AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
  641. #define AC2UP(_ac) ( \
  642. ((_ac) == WME_AC_VO) ? 6 : \
  643. ((_ac) == WME_AC_VI) ? 5 : \
  644. ((_ac) == WME_AC_BK) ? 1 : \
  645. 0)
  646. #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
  647. struct ether_header {
  648. u8 ether_dhost[ETHER_ADDR_LEN];
  649. u8 ether_shost[ETHER_ADDR_LEN];
  650. u16 ether_type;
  651. } __attribute__((packed));
  652. #ifndef ETHERTYPE_PAE
  653. #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
  654. #endif
  655. #ifndef ETHERTYPE_IP
  656. #define ETHERTYPE_IP 0x0800 /* IP protocol */
  657. #endif
  658. struct ieee80211_network {
  659. /* These entries are used to identify a unique network */
  660. u8 bssid[ETH_ALEN];
  661. u8 channel;
  662. /* Ensure null-terminated for any debug msgs */
  663. u8 ssid[IW_ESSID_MAX_SIZE + 1];
  664. u8 ssid_len;
  665. /* These are network statistics */
  666. struct ieee80211_rx_stats stats;
  667. u16 capability;
  668. u8 rates[MAX_RATES_LENGTH];
  669. u8 rates_len;
  670. u8 rates_ex[MAX_RATES_EX_LENGTH];
  671. u8 rates_ex_len;
  672. unsigned long last_scanned;
  673. u8 mode;
  674. u8 flags;
  675. u32 last_associate;
  676. u32 time_stamp[2];
  677. u16 beacon_interval;
  678. u16 listen_interval;
  679. u16 atim_window;
  680. u8 wpa_ie[MAX_WPA_IE_LEN];
  681. size_t wpa_ie_len;
  682. u8 rsn_ie[MAX_WPA_IE_LEN];
  683. size_t rsn_ie_len;
  684. u8 dtim_period;
  685. u8 dtim_data;
  686. u32 last_dtim_sta_time[2];
  687. struct list_head list;
  688. //appeded for QoS
  689. u8 wmm_info;
  690. struct ieee80211_wmm_ac_param wmm_param[4];
  691. u8 QoS_Enable;
  692. u8 SignalStrength;
  693. //by amy 080312
  694. u8 HighestOperaRate;
  695. //by amy 080312
  696. u8 Turbo_Enable;//enable turbo mode, added by thomas
  697. u16 CountryIeLen;
  698. u8 CountryIeBuf[MAX_IE_LEN];
  699. };
  700. enum ieee80211_state {
  701. /* the card is not linked at all */
  702. IEEE80211_NOLINK = 0,
  703. /* IEEE80211_ASSOCIATING* are for BSS client mode
  704. * the driver shall not perform RX filtering unless
  705. * the state is LINKED.
  706. * The driver shall just check for the state LINKED and
  707. * defaults to NOLINK for ALL the other states (including
  708. * LINKED_SCANNING)
  709. */
  710. /* the association procedure will start (wq scheduling)*/
  711. IEEE80211_ASSOCIATING,
  712. IEEE80211_ASSOCIATING_RETRY,
  713. /* the association procedure is sending AUTH request*/
  714. IEEE80211_ASSOCIATING_AUTHENTICATING,
  715. /* the association procedure has successfully authentcated
  716. * and is sending association request
  717. */
  718. IEEE80211_ASSOCIATING_AUTHENTICATED,
  719. /* the link is ok. the card associated to a BSS or linked
  720. * to a ibss cell or acting as an AP and creating the bss
  721. */
  722. IEEE80211_LINKED,
  723. /* same as LINKED, but the driver shall apply RX filter
  724. * rules as we are in NO_LINK mode. As the card is still
  725. * logically linked, but it is doing a syncro site survey
  726. * then it will be back to LINKED state.
  727. */
  728. IEEE80211_LINKED_SCANNING,
  729. };
  730. #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
  731. #define DEFAULT_FTS 2346
  732. #define CFG_IEEE80211_RESERVE_FCS (1<<0)
  733. #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
  734. typedef struct tx_pending_t{
  735. int frag;
  736. struct ieee80211_txb *txb;
  737. }tx_pending_t;
  738. enum {
  739. COUNTRY_CODE_FCC = 0,
  740. COUNTRY_CODE_IC = 1,
  741. COUNTRY_CODE_ETSI = 2,
  742. COUNTRY_CODE_SPAIN = 3,
  743. COUNTRY_CODE_FRANCE = 4,
  744. COUNTRY_CODE_MKK = 5,
  745. COUNTRY_CODE_MKK1 = 6,
  746. COUNTRY_CODE_ISRAEL = 7,
  747. COUNTRY_CODE_TELEC = 8,
  748. COUNTRY_CODE_GLOBAL_DOMAIN = 9,
  749. COUNTRY_CODE_WORLD_WIDE_13_INDEX = 10
  750. };
  751. struct ieee80211_device {
  752. struct net_device *dev;
  753. /* Bookkeeping structures */
  754. struct net_device_stats stats;
  755. struct ieee80211_stats ieee_stats;
  756. struct ieee80211_softmac_stats softmac_stats;
  757. /* Probe / Beacon management */
  758. struct list_head network_free_list;
  759. struct list_head network_list;
  760. struct ieee80211_network *networks;
  761. int scans;
  762. int scan_age;
  763. int iw_mode; /* operating mode (IW_MODE_*) */
  764. spinlock_t lock;
  765. spinlock_t wpax_suitlist_lock;
  766. int tx_headroom; /* Set to size of any additional room needed at front
  767. * of allocated Tx SKBs */
  768. u32 config;
  769. /* WEP and other encryption related settings at the device level */
  770. int open_wep; /* Set to 1 to allow unencrypted frames */
  771. int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
  772. * WEP key changes */
  773. /* If the host performs {en,de}cryption, then set to 1 */
  774. int host_encrypt;
  775. int host_decrypt;
  776. int ieee802_1x; /* is IEEE 802.1X used */
  777. /* WPA data */
  778. int wpa_enabled;
  779. int drop_unencrypted;
  780. int tkip_countermeasures;
  781. int privacy_invoked;
  782. size_t wpa_ie_len;
  783. u8 *wpa_ie;
  784. u8 ap_mac_addr[6];
  785. u16 pairwise_key_type;
  786. u16 broadcast_key_type;
  787. struct list_head crypt_deinit_list;
  788. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  789. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  790. struct timer_list crypt_deinit_timer;
  791. int bcrx_sta_key; /* use individual keys to override default keys even
  792. * with RX of broad/multicast frames */
  793. /* Fragmentation structures */
  794. // each streaming contain a entry
  795. struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
  796. unsigned int frag_next_idx[17];
  797. u16 fts; /* Fragmentation Threshold */
  798. /* This stores infos for the current network.
  799. * Either the network we are associated in INFRASTRUCTURE
  800. * or the network that we are creating in MASTER mode.
  801. * ad-hoc is a mixture ;-).
  802. * Note that in infrastructure mode, even when not associated,
  803. * fields bssid and essid may be valid (if wpa_set and essid_set
  804. * are true) as thy carry the value set by the user via iwconfig
  805. */
  806. struct ieee80211_network current_network;
  807. enum ieee80211_state state;
  808. int short_slot;
  809. int mode; /* A, B, G */
  810. int modulation; /* CCK, OFDM */
  811. int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
  812. int abg_true; /* ABG flag */
  813. /* used for forcing the ibss workqueue to terminate
  814. * without wait for the syncro scan to terminate
  815. */
  816. short sync_scan_hurryup;
  817. void * pDot11dInfo;
  818. bool bGlobalDomain;
  819. // For Liteon Ch12~13 passive scan
  820. u8 MinPassiveChnlNum;
  821. u8 IbssStartChnl;
  822. int rate; /* current rate */
  823. int basic_rate;
  824. //FIXME: pleace callback, see if redundant with softmac_features
  825. short active_scan;
  826. /* this contains flags for selectively enable softmac support */
  827. u16 softmac_features;
  828. /* if the sequence control field is not filled by HW */
  829. u16 seq_ctrl[5];
  830. /* association procedure transaction sequence number */
  831. u16 associate_seq;
  832. /* AID for RTXed association responses */
  833. u16 assoc_id;
  834. /* power save mode related*/
  835. short ps;
  836. short sta_sleep;
  837. int ps_timeout;
  838. struct tasklet_struct ps_task;
  839. u32 ps_th;
  840. u32 ps_tl;
  841. short raw_tx;
  842. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  843. short queue_stop;
  844. short scanning;
  845. short proto_started;
  846. struct semaphore wx_sem;
  847. struct semaphore scan_sem;
  848. spinlock_t mgmt_tx_lock;
  849. spinlock_t beacon_lock;
  850. short beacon_txing;
  851. short wap_set;
  852. short ssid_set;
  853. u8 wpax_type_set; //{added by David, 2006.9.28}
  854. u32 wpax_type_notify; //{added by David, 2006.9.26}
  855. /* QoS related flag */
  856. char init_wmmparam_flag;
  857. /* for discarding duplicated packets in IBSS */
  858. struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
  859. /* for discarding duplicated packets in BSS */
  860. u16 last_rxseq_num[17]; /* rx seq previous per-tid */
  861. u16 last_rxfrag_num[17];/* tx frag previous per-tid */
  862. unsigned long last_packet_time[17];
  863. /* for PS mode */
  864. unsigned long last_rx_ps_time;
  865. /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
  866. struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
  867. int mgmt_queue_head;
  868. int mgmt_queue_tail;
  869. /* used if IEEE_SOFTMAC_TX_QUEUE is set */
  870. struct tx_pending_t tx_pending;
  871. /* used if IEEE_SOFTMAC_ASSOCIATE is set */
  872. struct timer_list associate_timer;
  873. /* used if IEEE_SOFTMAC_BEACONS is set */
  874. struct timer_list beacon_timer;
  875. struct work_struct associate_complete_wq;
  876. // struct work_struct associate_retry_wq;
  877. struct work_struct associate_procedure_wq;
  878. // struct work_struct softmac_scan_wq;
  879. struct work_struct wx_sync_scan_wq;
  880. struct work_struct wmm_param_update_wq;
  881. struct work_struct ps_request_tx_ack_wq;//for ps
  882. // struct work_struct hw_wakeup_wq;
  883. // struct work_struct hw_sleep_wq;
  884. // struct work_struct watch_dog_wq;
  885. bool bInactivePs;
  886. bool actscanning;
  887. bool beinretry;
  888. u16 ListenInterval;
  889. unsigned long NumRxDataInPeriod; //YJ,add,080828
  890. unsigned long NumRxBcnInPeriod; //YJ,add,080828
  891. unsigned long NumRxOkTotal;
  892. unsigned long NumRxUnicast;//YJ,add,080828,for keep alive
  893. bool bHwRadioOff;
  894. struct delayed_work softmac_scan_wq;
  895. struct delayed_work associate_retry_wq;
  896. struct delayed_work hw_wakeup_wq;
  897. struct delayed_work hw_sleep_wq;//+by amy 080324
  898. struct delayed_work watch_dog_wq;
  899. struct delayed_work sw_antenna_wq;
  900. struct delayed_work start_ibss_wq;
  901. //by amy for rate adaptive 080312
  902. struct delayed_work rate_adapter_wq;
  903. //by amy for rate adaptive
  904. struct delayed_work hw_dig_wq;
  905. struct delayed_work tx_pw_wq;
  906. //Added for RF power on power off by lizhaoming 080512
  907. struct delayed_work GPIOChangeRFWorkItem;
  908. struct workqueue_struct *wq;
  909. /* Callback functions */
  910. void (*set_security)(struct net_device *dev,
  911. struct ieee80211_security *sec);
  912. /* Used to TX data frame by using txb structs.
  913. * this is not used if in the softmac_features
  914. * is set the flag IEEE_SOFTMAC_TX_QUEUE
  915. */
  916. int (*hard_start_xmit)(struct ieee80211_txb *txb,
  917. struct net_device *dev);
  918. int (*reset_port)(struct net_device *dev);
  919. /* Softmac-generated frames (mamagement) are TXed via this
  920. * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
  921. * not set. As some cards may have different HW queues that
  922. * one might want to use for data and management frames
  923. * the option to have two callbacks might be useful.
  924. * This fucntion can't sleep.
  925. */
  926. int (*softmac_hard_start_xmit)(struct sk_buff *skb,
  927. struct net_device *dev);
  928. /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
  929. * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
  930. * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
  931. * then also management frames are sent via this callback.
  932. * This function can't sleep.
  933. */
  934. void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
  935. struct net_device *dev,int rate);
  936. /* stops the HW queue for DATA frames. Useful to avoid
  937. * waste time to TX data frame when we are reassociating
  938. * This function can sleep.
  939. */
  940. void (*data_hard_stop)(struct net_device *dev);
  941. /* OK this is complementar to data_poll_hard_stop */
  942. void (*data_hard_resume)(struct net_device *dev);
  943. /* ask to the driver to retune the radio .
  944. * This function can sleep. the driver should ensure
  945. * the radio has been swithced before return.
  946. */
  947. void (*set_chan)(struct net_device *dev,short ch);
  948. /* These are not used if the ieee stack takes care of
  949. * scanning (IEEE_SOFTMAC_SCAN feature set).
  950. * In this case only the set_chan is used.
  951. *
  952. * The syncro version is similar to the start_scan but
  953. * does not return until all channels has been scanned.
  954. * this is called in user context and should sleep,
  955. * it is called in a work_queue when swithcing to ad-hoc mode
  956. * or in behalf of iwlist scan when the card is associated
  957. * and root user ask for a scan.
  958. * the fucntion stop_scan should stop both the syncro and
  959. * background scanning and can sleep.
  960. * The fucntion start_scan should initiate the background
  961. * scanning and can't sleep.
  962. */
  963. void (*scan_syncro)(struct net_device *dev);
  964. void (*start_scan)(struct net_device *dev);
  965. void (*stop_scan)(struct net_device *dev);
  966. /* indicate the driver that the link state is changed
  967. * for example it may indicate the card is associated now.
  968. * Driver might be interested in this to apply RX filter
  969. * rules or simply light the LINK led
  970. */
  971. void (*link_change)(struct net_device *dev);
  972. /* these two function indicates to the HW when to start
  973. * and stop to send beacons. This is used when the
  974. * IEEE_SOFTMAC_BEACONS is not set. For now the
  975. * stop_send_bacons is NOT guaranteed to be called only
  976. * after start_send_beacons.
  977. */
  978. void (*start_send_beacons) (struct net_device *dev);
  979. void (*stop_send_beacons) (struct net_device *dev);
  980. /* power save mode related */
  981. void (*sta_wake_up) (struct net_device *dev);
  982. void (*ps_request_tx_ack) (struct net_device *dev);
  983. void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
  984. short (*ps_is_queue_empty) (struct net_device *dev);
  985. /* QoS related */
  986. //void (*wmm_param_update) (struct net_device *dev, u8 *ac_param);
  987. //void (*wmm_param_update) (struct ieee80211_device *ieee);
  988. /* This must be the last item so that it points to the data
  989. * allocated beyond this structure by alloc_ieee80211 */
  990. u8 priv[0];
  991. };
  992. #define IEEE_A (1<<0)
  993. #define IEEE_B (1<<1)
  994. #define IEEE_G (1<<2)
  995. #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
  996. /* Generate a 802.11 header */
  997. /* Uses the channel change callback directly
  998. * instead of [start/stop] scan callbacks
  999. */
  1000. #define IEEE_SOFTMAC_SCAN (1<<2)
  1001. /* Perform authentication and association handshake */
  1002. #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
  1003. /* Generate probe requests */
  1004. #define IEEE_SOFTMAC_PROBERQ (1<<4)
  1005. /* Generate respones to probe requests */
  1006. #define IEEE_SOFTMAC_PROBERS (1<<5)
  1007. /* The ieee802.11 stack will manages the netif queue
  1008. * wake/stop for the driver, taking care of 802.11
  1009. * fragmentation. See softmac.c for details. */
  1010. #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
  1011. /* Uses only the softmac_data_hard_start_xmit
  1012. * even for TX management frames.
  1013. */
  1014. #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
  1015. /* Generate beacons. The stack will enqueue beacons
  1016. * to the card
  1017. */
  1018. #define IEEE_SOFTMAC_BEACONS (1<<6)
  1019. static inline void *ieee80211_priv(struct net_device *dev)
  1020. {
  1021. return ((struct ieee80211_device *)netdev_priv(dev))->priv;
  1022. }
  1023. extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
  1024. {
  1025. /* Single white space is for Linksys APs */
  1026. if (essid_len == 1 && essid[0] == ' ')
  1027. return 1;
  1028. /* Otherwise, if the entire essid is 0, we assume it is hidden */
  1029. while (essid_len) {
  1030. essid_len--;
  1031. if (essid[essid_len] != '\0')
  1032. return 0;
  1033. }
  1034. return 1;
  1035. }
  1036. extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
  1037. {
  1038. /*
  1039. * It is possible for both access points and our device to support
  1040. * combinations of modes, so as long as there is one valid combination
  1041. * of ap/device supported modes, then return success
  1042. *
  1043. */
  1044. if ((mode & IEEE_A) &&
  1045. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  1046. (ieee->freq_band & IEEE80211_52GHZ_BAND))
  1047. return 1;
  1048. if ((mode & IEEE_G) &&
  1049. (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
  1050. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  1051. return 1;
  1052. if ((mode & IEEE_B) &&
  1053. (ieee->modulation & IEEE80211_CCK_MODULATION) &&
  1054. (ieee->freq_band & IEEE80211_24GHZ_BAND))
  1055. return 1;
  1056. return 0;
  1057. }
  1058. extern inline int ieee80211_get_hdrlen(u16 fc)
  1059. {
  1060. int hdrlen = 24;
  1061. switch (WLAN_FC_GET_TYPE(fc)) {
  1062. case IEEE80211_FTYPE_DATA:
  1063. if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
  1064. hdrlen = 30; /* Addr4 */
  1065. if(IEEE80211_QOS_HAS_SEQ(fc))
  1066. hdrlen += 2; /* QOS ctrl*/
  1067. break;
  1068. case IEEE80211_FTYPE_CTL:
  1069. switch (WLAN_FC_GET_STYPE(fc)) {
  1070. case IEEE80211_STYPE_CTS:
  1071. case IEEE80211_STYPE_ACK:
  1072. hdrlen = 10;
  1073. break;
  1074. default:
  1075. hdrlen = 16;
  1076. break;
  1077. }
  1078. break;
  1079. }
  1080. return hdrlen;
  1081. }
  1082. /* ieee80211.c */
  1083. extern void free_ieee80211(struct net_device *dev);
  1084. extern struct net_device *alloc_ieee80211(int sizeof_priv);
  1085. extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
  1086. /* ieee80211_tx.c */
  1087. extern int ieee80211_encrypt_fragment(
  1088. struct ieee80211_device *ieee,
  1089. struct sk_buff *frag,
  1090. int hdr_len);
  1091. extern int ieee80211_rtl_xmit(struct sk_buff *skb,
  1092. struct net_device *dev);
  1093. extern void ieee80211_txb_free(struct ieee80211_txb *);
  1094. /* ieee80211_rx.c */
  1095. extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
  1096. struct ieee80211_rx_stats *rx_stats);
  1097. extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
  1098. struct ieee80211_hdr_4addr *header,
  1099. struct ieee80211_rx_stats *stats);
  1100. /* ieee80211_wx.c */
  1101. extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
  1102. struct iw_request_info *info,
  1103. union iwreq_data *wrqu, char *key);
  1104. extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
  1105. struct iw_request_info *info,
  1106. union iwreq_data *wrqu, char *key);
  1107. extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
  1108. struct iw_request_info *info,
  1109. union iwreq_data *wrqu, char *key);
  1110. extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
  1111. struct iw_request_info *info,
  1112. union iwreq_data* wrqu, char *extra);
  1113. int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
  1114. struct iw_request_info *info,
  1115. struct iw_param *data, char *extra);
  1116. int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
  1117. struct iw_request_info *info,
  1118. union iwreq_data *wrqu, char *extra);
  1119. int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
  1120. /* ieee80211_softmac.c */
  1121. extern short ieee80211_is_54g(struct ieee80211_network net);
  1122. extern short ieee80211_is_shortslot(struct ieee80211_network net);
  1123. extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
  1124. struct ieee80211_rx_stats *rx_stats, u16 type,
  1125. u16 stype);
  1126. extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
  1127. extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
  1128. extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
  1129. extern void ieee80211_start_bss(struct ieee80211_device *ieee);
  1130. extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
  1131. extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
  1132. extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
  1133. extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
  1134. extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
  1135. extern void ieee80211_disassociate(struct ieee80211_device *ieee);
  1136. extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
  1137. extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
  1138. extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
  1139. extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
  1140. extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
  1141. extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
  1142. extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
  1143. extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
  1144. extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
  1145. extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
  1146. extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
  1147. extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
  1148. extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
  1149. extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
  1150. extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
  1151. extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
  1152. extern void SendDisassociation(struct ieee80211_device *ieee,u8* asSta,u8 asRsn);
  1153. extern void ieee80211_rtl_start_scan(struct ieee80211_device *ieee);
  1154. //Add for RF power on power off by lizhaoming 080512
  1155. extern void SendDisassociation(struct ieee80211_device *ieee,
  1156. u8* asSta,
  1157. u8 asRsn);
  1158. /* ieee80211_crypt_ccmp&tkip&wep.c */
  1159. extern void ieee80211_tkip_null(void);
  1160. extern void ieee80211_wep_null(void);
  1161. extern void ieee80211_ccmp_null(void);
  1162. /* ieee80211_softmac_wx.c */
  1163. extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
  1164. struct iw_request_info *info,
  1165. union iwreq_data *wrqu, char *ext);
  1166. extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
  1167. struct iw_request_info *info,
  1168. union iwreq_data *awrq,
  1169. char *extra);
  1170. extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
  1171. extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
  1172. struct iw_request_info *info,
  1173. union iwreq_data *wrqu, char *extra);
  1174. extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
  1175. struct iw_request_info *info,
  1176. union iwreq_data *wrqu, char *extra);
  1177. extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
  1178. union iwreq_data *wrqu, char *b);
  1179. extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
  1180. union iwreq_data *wrqu, char *b);
  1181. extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
  1182. struct iw_request_info *a,
  1183. union iwreq_data *wrqu, char *extra);
  1184. extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
  1185. union iwreq_data *wrqu, char *b);
  1186. extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
  1187. union iwreq_data *wrqu, char *b);
  1188. extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
  1189. union iwreq_data *wrqu, char *b);
  1190. extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
  1191. extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
  1192. struct iw_request_info *info,
  1193. union iwreq_data *wrqu, char *extra);
  1194. extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
  1195. struct iw_request_info *info,
  1196. union iwreq_data *wrqu, char *extra);
  1197. extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
  1198. struct iw_request_info *info,
  1199. union iwreq_data *wrqu, char *extra);
  1200. extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
  1201. struct iw_request_info *info,
  1202. union iwreq_data *wrqu, char *extra);
  1203. extern void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee);
  1204. extern void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr);
  1205. extern const long ieee80211_wlan_frequencies[];
  1206. extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
  1207. {
  1208. ieee->scans++;
  1209. }
  1210. extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
  1211. {
  1212. return ieee->scans;
  1213. }
  1214. static inline const char *escape_essid(const char *essid, u8 essid_len) {
  1215. static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
  1216. const char *s = essid;
  1217. char *d = escaped;
  1218. if (ieee80211_is_empty_essid(essid, essid_len)) {
  1219. memcpy(escaped, "<hidden>", sizeof("<hidden>"));
  1220. return escaped;
  1221. }
  1222. essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
  1223. while (essid_len--) {
  1224. if (*s == '\0') {
  1225. *d++ = '\\';
  1226. *d++ = '0';
  1227. s++;
  1228. } else {
  1229. *d++ = *s++;
  1230. }
  1231. }
  1232. *d = '\0';
  1233. return escaped;
  1234. }
  1235. #endif /* IEEE80211_H */