hostap_wlan.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. #ifndef HOSTAP_WLAN_H
  2. #define HOSTAP_WLAN_H
  3. #include "hostap_config.h"
  4. #include "hostap_common.h"
  5. #define MAX_PARM_DEVICES 8
  6. #define PARM_MIN_MAX "1-" __MODULE_STRING(MAX_PARM_DEVICES)
  7. #define DEF_INTS -1, -1, -1, -1, -1, -1, -1
  8. #define GET_INT_PARM(var,idx) var[var[idx] < 0 ? 0 : idx]
  9. /* Specific skb->protocol value that indicates that the packet already contains
  10. * txdesc header.
  11. * FIX: This might need own value that would be allocated especially for Prism2
  12. * txdesc; ETH_P_CONTROL is commented as "Card specific control frames".
  13. * However, these skb's should have only minimal path in the kernel side since
  14. * prism2_send_mgmt() sends these with dev_queue_xmit() to prism2_tx(). */
  15. #define ETH_P_HOSTAP ETH_P_CONTROL
  16. /* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
  17. * (from linux-wlan-ng) */
  18. struct linux_wlan_ng_val {
  19. u32 did;
  20. u16 status, len;
  21. u32 data;
  22. } __attribute__ ((packed));
  23. struct linux_wlan_ng_prism_hdr {
  24. u32 msgcode, msglen;
  25. char devname[16];
  26. struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
  27. noise, rate, istx, frmlen;
  28. } __attribute__ ((packed));
  29. struct linux_wlan_ng_cap_hdr {
  30. u32 version;
  31. u32 length;
  32. u64 mactime;
  33. u64 hosttime;
  34. u32 phytype;
  35. u32 channel;
  36. u32 datarate;
  37. u32 antenna;
  38. u32 priority;
  39. u32 ssi_type;
  40. s32 ssi_signal;
  41. s32 ssi_noise;
  42. u32 preamble;
  43. u32 encoding;
  44. } __attribute__ ((packed));
  45. #define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
  46. #define LWNG_CAPHDR_VERSION 0x80211001
  47. struct hfa384x_rx_frame {
  48. /* HFA384X RX frame descriptor */
  49. u16 status; /* HFA384X_RX_STATUS_ flags */
  50. u32 time; /* timestamp, 1 microsecond resolution */
  51. u8 silence; /* 27 .. 154; seems to be 0 */
  52. u8 signal; /* 27 .. 154 */
  53. u8 rate; /* 10, 20, 55, or 110 */
  54. u8 rxflow;
  55. u32 reserved;
  56. /* 802.11 */
  57. u16 frame_control;
  58. u16 duration_id;
  59. u8 addr1[6];
  60. u8 addr2[6];
  61. u8 addr3[6];
  62. u16 seq_ctrl;
  63. u8 addr4[6];
  64. u16 data_len;
  65. /* 802.3 */
  66. u8 dst_addr[6];
  67. u8 src_addr[6];
  68. u16 len;
  69. /* followed by frame data; max 2304 bytes */
  70. } __attribute__ ((packed));
  71. struct hfa384x_tx_frame {
  72. /* HFA384X TX frame descriptor */
  73. u16 status; /* HFA384X_TX_STATUS_ flags */
  74. u16 reserved1;
  75. u16 reserved2;
  76. u32 sw_support;
  77. u8 retry_count; /* not yet implemented */
  78. u8 tx_rate; /* Host AP only; 0 = firmware, or 10, 20, 55, 110 */
  79. u16 tx_control; /* HFA384X_TX_CTRL_ flags */
  80. /* 802.11 */
  81. u16 frame_control; /* parts not used */
  82. u16 duration_id;
  83. u8 addr1[6];
  84. u8 addr2[6]; /* filled by firmware */
  85. u8 addr3[6];
  86. u16 seq_ctrl; /* filled by firmware */
  87. u8 addr4[6];
  88. u16 data_len;
  89. /* 802.3 */
  90. u8 dst_addr[6];
  91. u8 src_addr[6];
  92. u16 len;
  93. /* followed by frame data; max 2304 bytes */
  94. } __attribute__ ((packed));
  95. struct hfa384x_rid_hdr
  96. {
  97. u16 len;
  98. u16 rid;
  99. } __attribute__ ((packed));
  100. /* Macro for converting signal levels (range 27 .. 154) to wireless ext
  101. * dBm value with some accuracy */
  102. #define HFA384X_LEVEL_TO_dBm(v) 0x100 + (v) * 100 / 255 - 100
  103. #define HFA384X_LEVEL_TO_dBm_sign(v) (v) * 100 / 255 - 100
  104. struct hfa384x_scan_request {
  105. u16 channel_list;
  106. u16 txrate; /* HFA384X_RATES_* */
  107. } __attribute__ ((packed));
  108. struct hfa384x_hostscan_request {
  109. u16 channel_list;
  110. u16 txrate;
  111. u16 target_ssid_len;
  112. u8 target_ssid[32];
  113. } __attribute__ ((packed));
  114. struct hfa384x_join_request {
  115. u8 bssid[6];
  116. u16 channel;
  117. } __attribute__ ((packed));
  118. struct hfa384x_info_frame {
  119. u16 len;
  120. u16 type;
  121. } __attribute__ ((packed));
  122. struct hfa384x_comm_tallies {
  123. u16 tx_unicast_frames;
  124. u16 tx_multicast_frames;
  125. u16 tx_fragments;
  126. u16 tx_unicast_octets;
  127. u16 tx_multicast_octets;
  128. u16 tx_deferred_transmissions;
  129. u16 tx_single_retry_frames;
  130. u16 tx_multiple_retry_frames;
  131. u16 tx_retry_limit_exceeded;
  132. u16 tx_discards;
  133. u16 rx_unicast_frames;
  134. u16 rx_multicast_frames;
  135. u16 rx_fragments;
  136. u16 rx_unicast_octets;
  137. u16 rx_multicast_octets;
  138. u16 rx_fcs_errors;
  139. u16 rx_discards_no_buffer;
  140. u16 tx_discards_wrong_sa;
  141. u16 rx_discards_wep_undecryptable;
  142. u16 rx_message_in_msg_fragments;
  143. u16 rx_message_in_bad_msg_fragments;
  144. } __attribute__ ((packed));
  145. struct hfa384x_comm_tallies32 {
  146. u32 tx_unicast_frames;
  147. u32 tx_multicast_frames;
  148. u32 tx_fragments;
  149. u32 tx_unicast_octets;
  150. u32 tx_multicast_octets;
  151. u32 tx_deferred_transmissions;
  152. u32 tx_single_retry_frames;
  153. u32 tx_multiple_retry_frames;
  154. u32 tx_retry_limit_exceeded;
  155. u32 tx_discards;
  156. u32 rx_unicast_frames;
  157. u32 rx_multicast_frames;
  158. u32 rx_fragments;
  159. u32 rx_unicast_octets;
  160. u32 rx_multicast_octets;
  161. u32 rx_fcs_errors;
  162. u32 rx_discards_no_buffer;
  163. u32 tx_discards_wrong_sa;
  164. u32 rx_discards_wep_undecryptable;
  165. u32 rx_message_in_msg_fragments;
  166. u32 rx_message_in_bad_msg_fragments;
  167. } __attribute__ ((packed));
  168. struct hfa384x_scan_result_hdr {
  169. u16 reserved;
  170. u16 scan_reason;
  171. #define HFA384X_SCAN_IN_PROGRESS 0 /* no results available yet */
  172. #define HFA384X_SCAN_HOST_INITIATED 1
  173. #define HFA384X_SCAN_FIRMWARE_INITIATED 2
  174. #define HFA384X_SCAN_INQUIRY_FROM_HOST 3
  175. } __attribute__ ((packed));
  176. #define HFA384X_SCAN_MAX_RESULTS 32
  177. struct hfa384x_scan_result {
  178. u16 chid;
  179. u16 anl;
  180. u16 sl;
  181. u8 bssid[6];
  182. u16 beacon_interval;
  183. u16 capability;
  184. u16 ssid_len;
  185. u8 ssid[32];
  186. u8 sup_rates[10];
  187. u16 rate;
  188. } __attribute__ ((packed));
  189. struct hfa384x_hostscan_result {
  190. u16 chid;
  191. u16 anl;
  192. u16 sl;
  193. u8 bssid[6];
  194. u16 beacon_interval;
  195. u16 capability;
  196. u16 ssid_len;
  197. u8 ssid[32];
  198. u8 sup_rates[10];
  199. u16 rate;
  200. u16 atim;
  201. } __attribute__ ((packed));
  202. struct comm_tallies_sums {
  203. unsigned int tx_unicast_frames;
  204. unsigned int tx_multicast_frames;
  205. unsigned int tx_fragments;
  206. unsigned int tx_unicast_octets;
  207. unsigned int tx_multicast_octets;
  208. unsigned int tx_deferred_transmissions;
  209. unsigned int tx_single_retry_frames;
  210. unsigned int tx_multiple_retry_frames;
  211. unsigned int tx_retry_limit_exceeded;
  212. unsigned int tx_discards;
  213. unsigned int rx_unicast_frames;
  214. unsigned int rx_multicast_frames;
  215. unsigned int rx_fragments;
  216. unsigned int rx_unicast_octets;
  217. unsigned int rx_multicast_octets;
  218. unsigned int rx_fcs_errors;
  219. unsigned int rx_discards_no_buffer;
  220. unsigned int tx_discards_wrong_sa;
  221. unsigned int rx_discards_wep_undecryptable;
  222. unsigned int rx_message_in_msg_fragments;
  223. unsigned int rx_message_in_bad_msg_fragments;
  224. };
  225. struct hfa384x_regs {
  226. u16 cmd;
  227. u16 evstat;
  228. u16 offset0;
  229. u16 offset1;
  230. u16 swsupport0;
  231. };
  232. #if defined(PRISM2_PCCARD) || defined(PRISM2_PLX)
  233. /* I/O ports for HFA384X Controller access */
  234. #define HFA384X_CMD_OFF 0x00
  235. #define HFA384X_PARAM0_OFF 0x02
  236. #define HFA384X_PARAM1_OFF 0x04
  237. #define HFA384X_PARAM2_OFF 0x06
  238. #define HFA384X_STATUS_OFF 0x08
  239. #define HFA384X_RESP0_OFF 0x0A
  240. #define HFA384X_RESP1_OFF 0x0C
  241. #define HFA384X_RESP2_OFF 0x0E
  242. #define HFA384X_INFOFID_OFF 0x10
  243. #define HFA384X_CONTROL_OFF 0x14
  244. #define HFA384X_SELECT0_OFF 0x18
  245. #define HFA384X_SELECT1_OFF 0x1A
  246. #define HFA384X_OFFSET0_OFF 0x1C
  247. #define HFA384X_OFFSET1_OFF 0x1E
  248. #define HFA384X_RXFID_OFF 0x20
  249. #define HFA384X_ALLOCFID_OFF 0x22
  250. #define HFA384X_TXCOMPLFID_OFF 0x24
  251. #define HFA384X_SWSUPPORT0_OFF 0x28
  252. #define HFA384X_SWSUPPORT1_OFF 0x2A
  253. #define HFA384X_SWSUPPORT2_OFF 0x2C
  254. #define HFA384X_EVSTAT_OFF 0x30
  255. #define HFA384X_INTEN_OFF 0x32
  256. #define HFA384X_EVACK_OFF 0x34
  257. #define HFA384X_DATA0_OFF 0x36
  258. #define HFA384X_DATA1_OFF 0x38
  259. #define HFA384X_AUXPAGE_OFF 0x3A
  260. #define HFA384X_AUXOFFSET_OFF 0x3C
  261. #define HFA384X_AUXDATA_OFF 0x3E
  262. #endif /* PRISM2_PCCARD || PRISM2_PLX */
  263. #ifdef PRISM2_PCI
  264. /* Memory addresses for ISL3874 controller access */
  265. #define HFA384X_CMD_OFF 0x00
  266. #define HFA384X_PARAM0_OFF 0x04
  267. #define HFA384X_PARAM1_OFF 0x08
  268. #define HFA384X_PARAM2_OFF 0x0C
  269. #define HFA384X_STATUS_OFF 0x10
  270. #define HFA384X_RESP0_OFF 0x14
  271. #define HFA384X_RESP1_OFF 0x18
  272. #define HFA384X_RESP2_OFF 0x1C
  273. #define HFA384X_INFOFID_OFF 0x20
  274. #define HFA384X_CONTROL_OFF 0x28
  275. #define HFA384X_SELECT0_OFF 0x30
  276. #define HFA384X_SELECT1_OFF 0x34
  277. #define HFA384X_OFFSET0_OFF 0x38
  278. #define HFA384X_OFFSET1_OFF 0x3C
  279. #define HFA384X_RXFID_OFF 0x40
  280. #define HFA384X_ALLOCFID_OFF 0x44
  281. #define HFA384X_TXCOMPLFID_OFF 0x48
  282. #define HFA384X_PCICOR_OFF 0x4C
  283. #define HFA384X_SWSUPPORT0_OFF 0x50
  284. #define HFA384X_SWSUPPORT1_OFF 0x54
  285. #define HFA384X_SWSUPPORT2_OFF 0x58
  286. #define HFA384X_PCIHCR_OFF 0x5C
  287. #define HFA384X_EVSTAT_OFF 0x60
  288. #define HFA384X_INTEN_OFF 0x64
  289. #define HFA384X_EVACK_OFF 0x68
  290. #define HFA384X_DATA0_OFF 0x6C
  291. #define HFA384X_DATA1_OFF 0x70
  292. #define HFA384X_AUXPAGE_OFF 0x74
  293. #define HFA384X_AUXOFFSET_OFF 0x78
  294. #define HFA384X_AUXDATA_OFF 0x7C
  295. #define HFA384X_PCI_M0_ADDRH_OFF 0x80
  296. #define HFA384X_PCI_M0_ADDRL_OFF 0x84
  297. #define HFA384X_PCI_M0_LEN_OFF 0x88
  298. #define HFA384X_PCI_M0_CTL_OFF 0x8C
  299. #define HFA384X_PCI_STATUS_OFF 0x98
  300. #define HFA384X_PCI_M1_ADDRH_OFF 0xA0
  301. #define HFA384X_PCI_M1_ADDRL_OFF 0xA4
  302. #define HFA384X_PCI_M1_LEN_OFF 0xA8
  303. #define HFA384X_PCI_M1_CTL_OFF 0xAC
  304. /* PCI bus master control bits (these are undocumented; based on guessing and
  305. * experimenting..) */
  306. #define HFA384X_PCI_CTL_FROM_BAP (BIT(5) | BIT(1) | BIT(0))
  307. #define HFA384X_PCI_CTL_TO_BAP (BIT(5) | BIT(0))
  308. #endif /* PRISM2_PCI */
  309. /* Command codes for CMD reg. */
  310. #define HFA384X_CMDCODE_INIT 0x00
  311. #define HFA384X_CMDCODE_ENABLE 0x01
  312. #define HFA384X_CMDCODE_DISABLE 0x02
  313. #define HFA384X_CMDCODE_ALLOC 0x0A
  314. #define HFA384X_CMDCODE_TRANSMIT 0x0B
  315. #define HFA384X_CMDCODE_INQUIRE 0x11
  316. #define HFA384X_CMDCODE_ACCESS 0x21
  317. #define HFA384X_CMDCODE_ACCESS_WRITE (0x21 | BIT(8))
  318. #define HFA384X_CMDCODE_DOWNLOAD 0x22
  319. #define HFA384X_CMDCODE_READMIF 0x30
  320. #define HFA384X_CMDCODE_WRITEMIF 0x31
  321. #define HFA384X_CMDCODE_TEST 0x38
  322. #define HFA384X_CMDCODE_MASK 0x3F
  323. /* Test mode operations */
  324. #define HFA384X_TEST_CHANGE_CHANNEL 0x08
  325. #define HFA384X_TEST_MONITOR 0x0B
  326. #define HFA384X_TEST_STOP 0x0F
  327. #define HFA384X_TEST_CFG_BITS 0x15
  328. #define HFA384X_TEST_CFG_BIT_ALC BIT(3)
  329. #define HFA384X_CMD_BUSY BIT(15)
  330. #define HFA384X_CMD_TX_RECLAIM BIT(8)
  331. #define HFA384X_OFFSET_ERR BIT(14)
  332. #define HFA384X_OFFSET_BUSY BIT(15)
  333. /* ProgMode for download command */
  334. #define HFA384X_PROGMODE_DISABLE 0
  335. #define HFA384X_PROGMODE_ENABLE_VOLATILE 1
  336. #define HFA384X_PROGMODE_ENABLE_NON_VOLATILE 2
  337. #define HFA384X_PROGMODE_PROGRAM_NON_VOLATILE 3
  338. #define HFA384X_AUX_MAGIC0 0xfe01
  339. #define HFA384X_AUX_MAGIC1 0xdc23
  340. #define HFA384X_AUX_MAGIC2 0xba45
  341. #define HFA384X_AUX_PORT_DISABLED 0
  342. #define HFA384X_AUX_PORT_DISABLE BIT(14)
  343. #define HFA384X_AUX_PORT_ENABLE BIT(15)
  344. #define HFA384X_AUX_PORT_ENABLED (BIT(14) | BIT(15))
  345. #define HFA384X_AUX_PORT_MASK (BIT(14) | BIT(15))
  346. #define PRISM2_PDA_SIZE 1024
  347. /* Events; EvStat, Interrupt mask (IntEn), and acknowledge bits (EvAck) */
  348. #define HFA384X_EV_TICK BIT(15)
  349. #define HFA384X_EV_WTERR BIT(14)
  350. #define HFA384X_EV_INFDROP BIT(13)
  351. #ifdef PRISM2_PCI
  352. #define HFA384X_EV_PCI_M1 BIT(9)
  353. #define HFA384X_EV_PCI_M0 BIT(8)
  354. #endif /* PRISM2_PCI */
  355. #define HFA384X_EV_INFO BIT(7)
  356. #define HFA384X_EV_DTIM BIT(5)
  357. #define HFA384X_EV_CMD BIT(4)
  358. #define HFA384X_EV_ALLOC BIT(3)
  359. #define HFA384X_EV_TXEXC BIT(2)
  360. #define HFA384X_EV_TX BIT(1)
  361. #define HFA384X_EV_RX BIT(0)
  362. /* HFA384X Information frames */
  363. #define HFA384X_INFO_HANDOVERADDR 0xF000 /* AP f/w ? */
  364. #define HFA384X_INFO_HANDOVERDEAUTHADDR 0xF001 /* AP f/w 1.3.7 */
  365. #define HFA384X_INFO_COMMTALLIES 0xF100
  366. #define HFA384X_INFO_SCANRESULTS 0xF101
  367. #define HFA384X_INFO_CHANNELINFORESULTS 0xF102 /* AP f/w only */
  368. #define HFA384X_INFO_HOSTSCANRESULTS 0xF103
  369. #define HFA384X_INFO_LINKSTATUS 0xF200
  370. #define HFA384X_INFO_ASSOCSTATUS 0xF201 /* ? */
  371. #define HFA384X_INFO_AUTHREQ 0xF202 /* ? */
  372. #define HFA384X_INFO_PSUSERCNT 0xF203 /* ? */
  373. #define HFA384X_INFO_KEYIDCHANGED 0xF204 /* ? */
  374. enum { HFA384X_LINKSTATUS_CONNECTED = 1,
  375. HFA384X_LINKSTATUS_DISCONNECTED = 2,
  376. HFA384X_LINKSTATUS_AP_CHANGE = 3,
  377. HFA384X_LINKSTATUS_AP_OUT_OF_RANGE = 4,
  378. HFA384X_LINKSTATUS_AP_IN_RANGE = 5,
  379. HFA384X_LINKSTATUS_ASSOC_FAILED = 6 };
  380. enum { HFA384X_PORTTYPE_BSS = 1, HFA384X_PORTTYPE_WDS = 2,
  381. HFA384X_PORTTYPE_PSEUDO_IBSS = 3, HFA384X_PORTTYPE_IBSS = 0,
  382. HFA384X_PORTTYPE_HOSTAP = 6 };
  383. #define HFA384X_RATES_1MBPS BIT(0)
  384. #define HFA384X_RATES_2MBPS BIT(1)
  385. #define HFA384X_RATES_5MBPS BIT(2)
  386. #define HFA384X_RATES_11MBPS BIT(3)
  387. #define HFA384X_ROAMING_FIRMWARE 1
  388. #define HFA384X_ROAMING_HOST 2
  389. #define HFA384X_ROAMING_DISABLED 3
  390. #define HFA384X_WEPFLAGS_PRIVACYINVOKED BIT(0)
  391. #define HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED BIT(1)
  392. #define HFA384X_WEPFLAGS_HOSTENCRYPT BIT(4)
  393. #define HFA384X_WEPFLAGS_HOSTDECRYPT BIT(7)
  394. #define HFA384X_RX_STATUS_MSGTYPE (BIT(15) | BIT(14) | BIT(13))
  395. #define HFA384X_RX_STATUS_PCF BIT(12)
  396. #define HFA384X_RX_STATUS_MACPORT (BIT(10) | BIT(9) | BIT(8))
  397. #define HFA384X_RX_STATUS_UNDECR BIT(1)
  398. #define HFA384X_RX_STATUS_FCSERR BIT(0)
  399. #define HFA384X_RX_STATUS_GET_MSGTYPE(s) \
  400. (((s) & HFA384X_RX_STATUS_MSGTYPE) >> 13)
  401. #define HFA384X_RX_STATUS_GET_MACPORT(s) \
  402. (((s) & HFA384X_RX_STATUS_MACPORT) >> 8)
  403. enum { HFA384X_RX_MSGTYPE_NORMAL = 0, HFA384X_RX_MSGTYPE_RFC1042 = 1,
  404. HFA384X_RX_MSGTYPE_BRIDGETUNNEL = 2, HFA384X_RX_MSGTYPE_MGMT = 4 };
  405. #define HFA384X_TX_CTRL_ALT_RTRY BIT(5)
  406. #define HFA384X_TX_CTRL_802_11 BIT(3)
  407. #define HFA384X_TX_CTRL_802_3 0
  408. #define HFA384X_TX_CTRL_TX_EX BIT(2)
  409. #define HFA384X_TX_CTRL_TX_OK BIT(1)
  410. #define HFA384X_TX_STATUS_RETRYERR BIT(0)
  411. #define HFA384X_TX_STATUS_AGEDERR BIT(1)
  412. #define HFA384X_TX_STATUS_DISCON BIT(2)
  413. #define HFA384X_TX_STATUS_FORMERR BIT(3)
  414. /* HFA3861/3863 (BBP) Control Registers */
  415. #define HFA386X_CR_TX_CONFIGURE 0x12 /* CR9 */
  416. #define HFA386X_CR_RX_CONFIGURE 0x14 /* CR10 */
  417. #define HFA386X_CR_A_D_TEST_MODES2 0x1A /* CR13 */
  418. #define HFA386X_CR_MANUAL_TX_POWER 0x3E /* CR31 */
  419. #define HFA386X_CR_MEASURED_TX_POWER 0x74 /* CR58 */
  420. #ifdef __KERNEL__
  421. #define PRISM2_TXFID_COUNT 8
  422. #define PRISM2_DATA_MAXLEN 2304
  423. #define PRISM2_TXFID_LEN (PRISM2_DATA_MAXLEN + sizeof(struct hfa384x_tx_frame))
  424. #define PRISM2_TXFID_EMPTY 0xffff
  425. #define PRISM2_TXFID_RESERVED 0xfffe
  426. #define PRISM2_DUMMY_FID 0xffff
  427. #define MAX_SSID_LEN 32
  428. #define MAX_NAME_LEN 32 /* this is assumed to be equal to MAX_SSID_LEN */
  429. #define PRISM2_DUMP_RX_HDR BIT(0)
  430. #define PRISM2_DUMP_TX_HDR BIT(1)
  431. #define PRISM2_DUMP_TXEXC_HDR BIT(2)
  432. struct hostap_tx_callback_info {
  433. u16 idx;
  434. void (*func)(struct sk_buff *, int ok, void *);
  435. void *data;
  436. struct hostap_tx_callback_info *next;
  437. };
  438. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  439. * three fragmented frames. This define can be increased to support more
  440. * concurrent frames, but it should be noted that each entry can consume about
  441. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  442. #define PRISM2_FRAG_CACHE_LEN 4
  443. struct prism2_frag_entry {
  444. unsigned long first_frag_time;
  445. unsigned int seq;
  446. unsigned int last_frag;
  447. struct sk_buff *skb;
  448. u8 src_addr[ETH_ALEN];
  449. u8 dst_addr[ETH_ALEN];
  450. };
  451. struct hostap_cmd_queue {
  452. struct list_head list;
  453. wait_queue_head_t compl;
  454. volatile enum { CMD_SLEEP, CMD_CALLBACK, CMD_COMPLETED } type;
  455. void (*callback)(struct net_device *dev, long context, u16 resp0,
  456. u16 res);
  457. long context;
  458. u16 cmd, param0, param1;
  459. u16 resp0, res;
  460. volatile int issued, issuing;
  461. atomic_t usecnt;
  462. int del_req;
  463. };
  464. /* options for hw_shutdown */
  465. #define HOSTAP_HW_NO_DISABLE BIT(0)
  466. #define HOSTAP_HW_ENABLE_CMDCOMPL BIT(1)
  467. typedef struct local_info local_info_t;
  468. struct prism2_helper_functions {
  469. /* these functions are defined in hardware model specific files
  470. * (hostap_{cs,plx,pci}.c */
  471. int (*card_present)(local_info_t *local);
  472. void (*cor_sreset)(local_info_t *local);
  473. int (*dev_open)(local_info_t *local);
  474. int (*dev_close)(local_info_t *local);
  475. void (*genesis_reset)(local_info_t *local, int hcr);
  476. /* the following functions are from hostap_hw.c, but they may have some
  477. * hardware model specific code */
  478. /* FIX: low-level commands like cmd might disappear at some point to
  479. * make it easier to change them if needed (e.g., cmd would be replaced
  480. * with write_mif/read_mif/testcmd/inquire); at least get_rid and
  481. * set_rid might move to hostap_{cs,plx,pci}.c */
  482. int (*cmd)(struct net_device *dev, u16 cmd, u16 param0, u16 *param1,
  483. u16 *resp0);
  484. void (*read_regs)(struct net_device *dev, struct hfa384x_regs *regs);
  485. int (*get_rid)(struct net_device *dev, u16 rid, void *buf, int len,
  486. int exact_len);
  487. int (*set_rid)(struct net_device *dev, u16 rid, void *buf, int len);
  488. int (*hw_enable)(struct net_device *dev, int initial);
  489. int (*hw_config)(struct net_device *dev, int initial);
  490. void (*hw_reset)(struct net_device *dev);
  491. void (*hw_shutdown)(struct net_device *dev, int no_disable);
  492. int (*reset_port)(struct net_device *dev);
  493. void (*schedule_reset)(local_info_t *local);
  494. int (*download)(local_info_t *local,
  495. struct prism2_download_param *param);
  496. int (*tx)(struct sk_buff *skb, struct net_device *dev);
  497. int (*set_tim)(struct net_device *dev, int aid, int set);
  498. int (*read_aux)(struct net_device *dev, unsigned addr, int len,
  499. u8 *buf);
  500. int need_tx_headroom; /* number of bytes of headroom needed before
  501. * IEEE 802.11 header */
  502. enum { HOSTAP_HW_PCCARD, HOSTAP_HW_PLX, HOSTAP_HW_PCI } hw_type;
  503. };
  504. struct prism2_download_data {
  505. u32 dl_cmd;
  506. u32 start_addr;
  507. u32 num_areas;
  508. struct prism2_download_data_area {
  509. u32 addr; /* wlan card address */
  510. u32 len;
  511. u8 *data; /* allocated data */
  512. } data[0];
  513. };
  514. #define HOSTAP_MAX_BSS_COUNT 64
  515. #define MAX_WPA_IE_LEN 64
  516. struct hostap_bss_info {
  517. struct list_head list;
  518. unsigned long last_update;
  519. unsigned int count;
  520. u8 bssid[ETH_ALEN];
  521. u16 capab_info;
  522. u8 ssid[32];
  523. size_t ssid_len;
  524. u8 wpa_ie[MAX_WPA_IE_LEN];
  525. size_t wpa_ie_len;
  526. u8 rsn_ie[MAX_WPA_IE_LEN];
  527. size_t rsn_ie_len;
  528. int chan;
  529. int included;
  530. };
  531. /* Per radio private Host AP data - shared by all net devices interfaces used
  532. * by each radio (wlan#, wlan#ap, wlan#sta, WDS).
  533. * ((struct hostap_interface *) netdev_priv(dev))->local points to this
  534. * structure. */
  535. struct local_info {
  536. struct module *hw_module;
  537. int card_idx;
  538. int dev_enabled;
  539. int master_dev_auto_open; /* was master device opened automatically */
  540. int num_dev_open; /* number of open devices */
  541. struct net_device *dev; /* master radio device */
  542. struct net_device *ddev; /* main data device */
  543. struct list_head hostap_interfaces; /* Host AP interface list (contains
  544. * struct hostap_interface entries)
  545. */
  546. rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock
  547. * when removing entries from the list.
  548. * TX and RX paths can use read lock. */
  549. spinlock_t cmdlock, baplock, lock;
  550. struct semaphore rid_bap_sem;
  551. u16 infofid; /* MAC buffer id for info frame */
  552. /* txfid, intransmitfid, next_txtid, and next_alloc are protected by
  553. * txfidlock */
  554. spinlock_t txfidlock;
  555. int txfid_len; /* length of allocated TX buffers */
  556. u16 txfid[PRISM2_TXFID_COUNT]; /* buffer IDs for TX frames */
  557. /* buffer IDs for intransmit frames or PRISM2_TXFID_EMPTY if
  558. * corresponding txfid is free for next TX frame */
  559. u16 intransmitfid[PRISM2_TXFID_COUNT];
  560. int next_txfid; /* index to the next txfid to be checked for
  561. * availability */
  562. int next_alloc; /* index to the next intransmitfid to be checked for
  563. * allocation events */
  564. /* bitfield for atomic bitops */
  565. #define HOSTAP_BITS_TRANSMIT 0
  566. #define HOSTAP_BITS_BAP_TASKLET 1
  567. #define HOSTAP_BITS_BAP_TASKLET2 2
  568. long bits;
  569. struct ap_data *ap;
  570. char essid[MAX_SSID_LEN + 1];
  571. char name[MAX_NAME_LEN + 1];
  572. int name_set;
  573. u16 channel_mask; /* mask of allowed channels */
  574. u16 scan_channel_mask; /* mask of channels to be scanned */
  575. struct comm_tallies_sums comm_tallies;
  576. struct net_device_stats stats;
  577. struct proc_dir_entry *proc;
  578. int iw_mode; /* operating mode (IW_MODE_*) */
  579. int pseudo_adhoc; /* 0: IW_MODE_ADHOC is real 802.11 compliant IBSS
  580. * 1: IW_MODE_ADHOC is "pseudo IBSS" */
  581. char bssid[ETH_ALEN];
  582. int channel;
  583. int beacon_int;
  584. int dtim_period;
  585. int mtu;
  586. int frame_dump; /* dump RX/TX frame headers, PRISM2_DUMP_ flags */
  587. int fw_tx_rate_control;
  588. u16 tx_rate_control;
  589. u16 basic_rates;
  590. int hw_resetting;
  591. int hw_ready;
  592. int hw_reset_tries; /* how many times reset has been tried */
  593. int hw_downloading;
  594. int shutdown;
  595. int pri_only;
  596. int no_pri; /* no PRI f/w present */
  597. int sram_type; /* 8 = x8 SRAM, 16 = x16 SRAM, -1 = unknown */
  598. enum {
  599. PRISM2_TXPOWER_AUTO = 0, PRISM2_TXPOWER_OFF,
  600. PRISM2_TXPOWER_FIXED, PRISM2_TXPOWER_UNKNOWN
  601. } txpower_type;
  602. int txpower; /* if txpower_type == PRISM2_TXPOWER_FIXED */
  603. /* command queue for hfa384x_cmd(); protected with cmdlock */
  604. struct list_head cmd_queue;
  605. /* max_len for cmd_queue; in addition, cmd_callback can use two
  606. * additional entries to prevent sleeping commands from stopping
  607. * transmits */
  608. #define HOSTAP_CMD_QUEUE_MAX_LEN 16
  609. int cmd_queue_len; /* number of entries in cmd_queue */
  610. /* if card timeout is detected in interrupt context, reset_queue is
  611. * used to schedule card reseting to be done in user context */
  612. struct work_struct reset_queue;
  613. /* For scheduling a change of the promiscuous mode RID */
  614. int is_promisc;
  615. struct work_struct set_multicast_list_queue;
  616. struct work_struct set_tim_queue;
  617. struct list_head set_tim_list;
  618. spinlock_t set_tim_lock;
  619. int wds_max_connections;
  620. int wds_connections;
  621. #define HOSTAP_WDS_BROADCAST_RA BIT(0)
  622. #define HOSTAP_WDS_AP_CLIENT BIT(1)
  623. #define HOSTAP_WDS_STANDARD_FRAME BIT(2)
  624. u32 wds_type;
  625. u16 tx_control; /* flags to be used in TX description */
  626. int manual_retry_count; /* -1 = use f/w default; otherwise retry count
  627. * to be used with all frames */
  628. struct iw_statistics wstats;
  629. unsigned long scan_timestamp; /* Time started to scan */
  630. enum {
  631. PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
  632. PRISM2_MONITOR_CAPHDR = 2
  633. } monitor_type;
  634. int (*saved_eth_header_parse)(struct sk_buff *skb,
  635. unsigned char *haddr);
  636. int monitor_allow_fcserr;
  637. int hostapd; /* whether user space daemon, hostapd, is used for AP
  638. * management */
  639. int hostapd_sta; /* whether hostapd is used with an extra STA interface
  640. */
  641. struct net_device *apdev;
  642. struct net_device_stats apdevstats;
  643. char assoc_ap_addr[ETH_ALEN];
  644. struct net_device *stadev;
  645. struct net_device_stats stadevstats;
  646. #define WEP_KEYS 4
  647. #define WEP_KEY_LEN 13
  648. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  649. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  650. struct timer_list crypt_deinit_timer;
  651. struct list_head crypt_deinit_list;
  652. int open_wep; /* allow unencrypted frames */
  653. int host_encrypt;
  654. int host_decrypt;
  655. int privacy_invoked; /* force privacy invoked flag even if no keys are
  656. * configured */
  657. int fw_encrypt_ok; /* whether firmware-based WEP encrypt is working
  658. * in Host AP mode (STA f/w 1.4.9 or newer) */
  659. int bcrx_sta_key; /* use individual keys to override default keys even
  660. * with RX of broad/multicast frames */
  661. struct prism2_frag_entry frag_cache[PRISM2_FRAG_CACHE_LEN];
  662. unsigned int frag_next_idx;
  663. int ieee_802_1x; /* is IEEE 802.1X used */
  664. int antsel_tx, antsel_rx;
  665. int rts_threshold; /* dot11RTSThreshold */
  666. int fragm_threshold; /* dot11FragmentationThreshold */
  667. int auth_algs; /* PRISM2_AUTH_ flags */
  668. int enh_sec; /* cnfEnhSecurity options (broadcast SSID hide/ignore) */
  669. int tallies32; /* 32-bit tallies in use */
  670. struct prism2_helper_functions *func;
  671. u8 *pda;
  672. int fw_ap;
  673. #define PRISM2_FW_VER(major, minor, variant) \
  674. (((major) << 16) | ((minor) << 8) | variant)
  675. u32 sta_fw_ver;
  676. /* Tasklets for handling hardware IRQ related operations outside hw IRQ
  677. * handler */
  678. struct tasklet_struct bap_tasklet;
  679. struct tasklet_struct info_tasklet;
  680. struct sk_buff_head info_list; /* info frames as skb's for
  681. * info_tasklet */
  682. struct hostap_tx_callback_info *tx_callback; /* registered TX callbacks
  683. */
  684. struct tasklet_struct rx_tasklet;
  685. struct sk_buff_head rx_list;
  686. struct tasklet_struct sta_tx_exc_tasklet;
  687. struct sk_buff_head sta_tx_exc_list;
  688. int host_roaming;
  689. unsigned long last_join_time; /* time of last JoinRequest */
  690. struct hfa384x_hostscan_result *last_scan_results;
  691. int last_scan_results_count;
  692. enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type;
  693. struct work_struct info_queue;
  694. long pending_info; /* bit field of pending info_queue items */
  695. #define PRISM2_INFO_PENDING_LINKSTATUS 0
  696. #define PRISM2_INFO_PENDING_SCANRESULTS 1
  697. int prev_link_status; /* previous received LinkStatus info */
  698. int prev_linkstatus_connected;
  699. u8 preferred_ap[6]; /* use this AP if possible */
  700. #ifdef PRISM2_CALLBACK
  701. void *callback_data; /* Can be used in callbacks; e.g., allocate
  702. * on enable event and free on disable event.
  703. * Host AP driver code does not touch this. */
  704. #endif /* PRISM2_CALLBACK */
  705. wait_queue_head_t hostscan_wq;
  706. /* Passive scan in Host AP mode */
  707. struct timer_list passive_scan_timer;
  708. int passive_scan_interval; /* in seconds, 0 = disabled */
  709. int passive_scan_channel;
  710. enum { PASSIVE_SCAN_WAIT, PASSIVE_SCAN_LISTEN } passive_scan_state;
  711. struct timer_list tick_timer;
  712. unsigned long last_tick_timer;
  713. unsigned int sw_tick_stuck;
  714. /* commsQuality / dBmCommsQuality data from periodic polling; only
  715. * valid for Managed and Ad-hoc modes */
  716. unsigned long last_comms_qual_update;
  717. int comms_qual; /* in some odd unit.. */
  718. int avg_signal; /* in dB (note: negative) */
  719. int avg_noise; /* in dB (note: negative) */
  720. struct work_struct comms_qual_update;
  721. /* RSSI to dBm adjustment (for RX descriptor fields) */
  722. int rssi_to_dBm; /* substract from RSSI to get approximate dBm value */
  723. /* BSS list / protected by local->lock */
  724. struct list_head bss_list;
  725. int num_bss_info;
  726. int wpa; /* WPA support enabled */
  727. int tkip_countermeasures;
  728. int drop_unencrypted;
  729. /* Generic IEEE 802.11 info element to be added to
  730. * ProbeResp/Beacon/(Re)AssocReq */
  731. u8 *generic_elem;
  732. size_t generic_elem_len;
  733. #ifdef PRISM2_DOWNLOAD_SUPPORT
  734. /* Persistent volatile download data */
  735. struct prism2_download_data *dl_pri;
  736. struct prism2_download_data *dl_sec;
  737. #endif /* PRISM2_DOWNLOAD_SUPPORT */
  738. #ifdef PRISM2_IO_DEBUG
  739. #define PRISM2_IO_DEBUG_SIZE 10000
  740. u32 io_debug[PRISM2_IO_DEBUG_SIZE];
  741. int io_debug_head;
  742. int io_debug_enabled;
  743. #endif /* PRISM2_IO_DEBUG */
  744. /* Pointer to hardware model specific (cs,pci,plx) private data. */
  745. void *hw_priv;
  746. };
  747. /* Per interface private Host AP data
  748. * Allocated for each net device that Host AP uses (wlan#, wlan#ap, wlan#sta,
  749. * WDS) and netdev_priv(dev) points to this structure. */
  750. struct hostap_interface {
  751. struct list_head list; /* list entry in Host AP interface list */
  752. struct net_device *dev; /* pointer to this device */
  753. struct local_info *local; /* pointer to shared private data */
  754. struct net_device_stats stats;
  755. struct iw_spy_data spy_data; /* iwspy support */
  756. struct iw_public_data wireless_data;
  757. enum {
  758. HOSTAP_INTERFACE_MASTER,
  759. HOSTAP_INTERFACE_MAIN,
  760. HOSTAP_INTERFACE_AP,
  761. HOSTAP_INTERFACE_STA,
  762. HOSTAP_INTERFACE_WDS,
  763. } type;
  764. union {
  765. struct hostap_interface_wds {
  766. u8 remote_addr[ETH_ALEN];
  767. } wds;
  768. } u;
  769. };
  770. #define HOSTAP_SKB_TX_DATA_MAGIC 0xf08a36a2
  771. /*
  772. * TX meta data - stored in skb->cb buffer, so this must not be increased over
  773. * the 40-byte limit
  774. */
  775. struct hostap_skb_tx_data {
  776. u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */
  777. u8 rate; /* transmit rate */
  778. #define HOSTAP_TX_FLAGS_WDS BIT(0)
  779. #define HOSTAP_TX_FLAGS_BUFFERED_FRAME BIT(1)
  780. #define HOSTAP_TX_FLAGS_ADD_MOREDATA BIT(2)
  781. u8 flags; /* HOSTAP_TX_FLAGS_* */
  782. u16 tx_cb_idx;
  783. struct hostap_interface *iface;
  784. unsigned long jiffies; /* queueing timestamp */
  785. unsigned short ethertype;
  786. };
  787. #ifndef PRISM2_NO_DEBUG
  788. #define DEBUG_FID BIT(0)
  789. #define DEBUG_PS BIT(1)
  790. #define DEBUG_FLOW BIT(2)
  791. #define DEBUG_AP BIT(3)
  792. #define DEBUG_HW BIT(4)
  793. #define DEBUG_EXTRA BIT(5)
  794. #define DEBUG_EXTRA2 BIT(6)
  795. #define DEBUG_PS2 BIT(7)
  796. #define DEBUG_MASK (DEBUG_PS | DEBUG_AP | DEBUG_HW | DEBUG_EXTRA)
  797. #define PDEBUG(n, args...) \
  798. do { if ((n) & DEBUG_MASK) printk(KERN_DEBUG args); } while (0)
  799. #define PDEBUG2(n, args...) \
  800. do { if ((n) & DEBUG_MASK) printk(args); } while (0)
  801. #else /* PRISM2_NO_DEBUG */
  802. #define PDEBUG(n, args...)
  803. #define PDEBUG2(n, args...)
  804. #endif /* PRISM2_NO_DEBUG */
  805. enum { BAP0 = 0, BAP1 = 1 };
  806. #define PRISM2_IO_DEBUG_CMD_INB 0
  807. #define PRISM2_IO_DEBUG_CMD_INW 1
  808. #define PRISM2_IO_DEBUG_CMD_INSW 2
  809. #define PRISM2_IO_DEBUG_CMD_OUTB 3
  810. #define PRISM2_IO_DEBUG_CMD_OUTW 4
  811. #define PRISM2_IO_DEBUG_CMD_OUTSW 5
  812. #define PRISM2_IO_DEBUG_CMD_ERROR 6
  813. #define PRISM2_IO_DEBUG_CMD_INTERRUPT 7
  814. #ifdef PRISM2_IO_DEBUG
  815. #define PRISM2_IO_DEBUG_ENTRY(cmd, reg, value) \
  816. (((cmd) << 24) | ((reg) << 16) | value)
  817. static inline void prism2_io_debug_add(struct net_device *dev, int cmd,
  818. int reg, int value)
  819. {
  820. struct hostap_interface *iface = netdev_priv(dev);
  821. local_info_t *local = iface->local;
  822. if (!local->io_debug_enabled)
  823. return;
  824. local->io_debug[local->io_debug_head] = jiffies & 0xffffffff;
  825. if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE)
  826. local->io_debug_head = 0;
  827. local->io_debug[local->io_debug_head] =
  828. PRISM2_IO_DEBUG_ENTRY(cmd, reg, value);
  829. if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE)
  830. local->io_debug_head = 0;
  831. }
  832. static inline void prism2_io_debug_error(struct net_device *dev, int err)
  833. {
  834. struct hostap_interface *iface = netdev_priv(dev);
  835. local_info_t *local = iface->local;
  836. unsigned long flags;
  837. if (!local->io_debug_enabled)
  838. return;
  839. spin_lock_irqsave(&local->lock, flags);
  840. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_ERROR, 0, err);
  841. if (local->io_debug_enabled == 1) {
  842. local->io_debug_enabled = 0;
  843. printk(KERN_DEBUG "%s: I/O debug stopped\n", dev->name);
  844. }
  845. spin_unlock_irqrestore(&local->lock, flags);
  846. }
  847. #else /* PRISM2_IO_DEBUG */
  848. static inline void prism2_io_debug_add(struct net_device *dev, int cmd,
  849. int reg, int value)
  850. {
  851. }
  852. static inline void prism2_io_debug_error(struct net_device *dev, int err)
  853. {
  854. }
  855. #endif /* PRISM2_IO_DEBUG */
  856. #ifdef PRISM2_CALLBACK
  857. enum {
  858. /* Called when card is enabled */
  859. PRISM2_CALLBACK_ENABLE,
  860. /* Called when card is disabled */
  861. PRISM2_CALLBACK_DISABLE,
  862. /* Called when RX/TX starts/ends */
  863. PRISM2_CALLBACK_RX_START, PRISM2_CALLBACK_RX_END,
  864. PRISM2_CALLBACK_TX_START, PRISM2_CALLBACK_TX_END
  865. };
  866. void prism2_callback(local_info_t *local, int event);
  867. #else /* PRISM2_CALLBACK */
  868. #define prism2_callback(d, e) do { } while (0)
  869. #endif /* PRISM2_CALLBACK */
  870. #endif /* __KERNEL__ */
  871. #endif /* HOSTAP_WLAN_H */