hostap_wlan.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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. void (*genesis_reset)(local_info_t *local, int hcr);
  474. /* the following functions are from hostap_hw.c, but they may have some
  475. * hardware model specific code */
  476. /* FIX: low-level commands like cmd might disappear at some point to
  477. * make it easier to change them if needed (e.g., cmd would be replaced
  478. * with write_mif/read_mif/testcmd/inquire); at least get_rid and
  479. * set_rid might move to hostap_{cs,plx,pci}.c */
  480. int (*cmd)(struct net_device *dev, u16 cmd, u16 param0, u16 *param1,
  481. u16 *resp0);
  482. void (*read_regs)(struct net_device *dev, struct hfa384x_regs *regs);
  483. int (*get_rid)(struct net_device *dev, u16 rid, void *buf, int len,
  484. int exact_len);
  485. int (*set_rid)(struct net_device *dev, u16 rid, void *buf, int len);
  486. int (*hw_enable)(struct net_device *dev, int initial);
  487. int (*hw_config)(struct net_device *dev, int initial);
  488. void (*hw_reset)(struct net_device *dev);
  489. void (*hw_shutdown)(struct net_device *dev, int no_disable);
  490. int (*reset_port)(struct net_device *dev);
  491. void (*schedule_reset)(local_info_t *local);
  492. int (*download)(local_info_t *local,
  493. struct prism2_download_param *param);
  494. int (*tx)(struct sk_buff *skb, struct net_device *dev);
  495. int (*set_tim)(struct net_device *dev, int aid, int set);
  496. int (*read_aux)(struct net_device *dev, unsigned addr, int len,
  497. u8 *buf);
  498. int need_tx_headroom; /* number of bytes of headroom needed before
  499. * IEEE 802.11 header */
  500. enum { HOSTAP_HW_PCCARD, HOSTAP_HW_PLX, HOSTAP_HW_PCI } hw_type;
  501. };
  502. struct prism2_download_data {
  503. u32 dl_cmd;
  504. u32 start_addr;
  505. u32 num_areas;
  506. struct prism2_download_data_area {
  507. u32 addr; /* wlan card address */
  508. u32 len;
  509. u8 *data; /* allocated data */
  510. } data[0];
  511. };
  512. #define HOSTAP_MAX_BSS_COUNT 64
  513. #define MAX_WPA_IE_LEN 64
  514. struct hostap_bss_info {
  515. struct list_head list;
  516. unsigned long last_update;
  517. unsigned int count;
  518. u8 bssid[ETH_ALEN];
  519. u16 capab_info;
  520. u8 ssid[32];
  521. size_t ssid_len;
  522. u8 wpa_ie[MAX_WPA_IE_LEN];
  523. size_t wpa_ie_len;
  524. u8 rsn_ie[MAX_WPA_IE_LEN];
  525. size_t rsn_ie_len;
  526. int chan;
  527. int included;
  528. };
  529. /* Per radio private Host AP data - shared by all net devices interfaces used
  530. * by each radio (wlan#, wlan#ap, wlan#sta, WDS).
  531. * ((struct hostap_interface *) netdev_priv(dev))->local points to this
  532. * structure. */
  533. struct local_info {
  534. struct module *hw_module;
  535. int card_idx;
  536. int dev_enabled;
  537. int master_dev_auto_open; /* was master device opened automatically */
  538. int num_dev_open; /* number of open devices */
  539. struct net_device *dev; /* master radio device */
  540. struct net_device *ddev; /* main data device */
  541. struct list_head hostap_interfaces; /* Host AP interface list (contains
  542. * struct hostap_interface entries)
  543. */
  544. rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock
  545. * when removing entries from the list.
  546. * TX and RX paths can use read lock. */
  547. spinlock_t cmdlock, baplock, lock;
  548. struct semaphore rid_bap_sem;
  549. u16 infofid; /* MAC buffer id for info frame */
  550. /* txfid, intransmitfid, next_txtid, and next_alloc are protected by
  551. * txfidlock */
  552. spinlock_t txfidlock;
  553. int txfid_len; /* length of allocated TX buffers */
  554. u16 txfid[PRISM2_TXFID_COUNT]; /* buffer IDs for TX frames */
  555. /* buffer IDs for intransmit frames or PRISM2_TXFID_EMPTY if
  556. * corresponding txfid is free for next TX frame */
  557. u16 intransmitfid[PRISM2_TXFID_COUNT];
  558. int next_txfid; /* index to the next txfid to be checked for
  559. * availability */
  560. int next_alloc; /* index to the next intransmitfid to be checked for
  561. * allocation events */
  562. /* bitfield for atomic bitops */
  563. #define HOSTAP_BITS_TRANSMIT 0
  564. #define HOSTAP_BITS_BAP_TASKLET 1
  565. #define HOSTAP_BITS_BAP_TASKLET2 2
  566. long bits;
  567. struct ap_data *ap;
  568. char essid[MAX_SSID_LEN + 1];
  569. char name[MAX_NAME_LEN + 1];
  570. int name_set;
  571. u16 channel_mask; /* mask of allowed channels */
  572. u16 scan_channel_mask; /* mask of channels to be scanned */
  573. struct comm_tallies_sums comm_tallies;
  574. struct net_device_stats stats;
  575. struct proc_dir_entry *proc;
  576. int iw_mode; /* operating mode (IW_MODE_*) */
  577. int pseudo_adhoc; /* 0: IW_MODE_ADHOC is real 802.11 compliant IBSS
  578. * 1: IW_MODE_ADHOC is "pseudo IBSS" */
  579. char bssid[ETH_ALEN];
  580. int channel;
  581. int beacon_int;
  582. int dtim_period;
  583. int mtu;
  584. int frame_dump; /* dump RX/TX frame headers, PRISM2_DUMP_ flags */
  585. int fw_tx_rate_control;
  586. u16 tx_rate_control;
  587. u16 basic_rates;
  588. int hw_resetting;
  589. int hw_ready;
  590. int hw_reset_tries; /* how many times reset has been tried */
  591. int hw_downloading;
  592. int shutdown;
  593. int pri_only;
  594. int no_pri; /* no PRI f/w present */
  595. int sram_type; /* 8 = x8 SRAM, 16 = x16 SRAM, -1 = unknown */
  596. enum {
  597. PRISM2_TXPOWER_AUTO = 0, PRISM2_TXPOWER_OFF,
  598. PRISM2_TXPOWER_FIXED, PRISM2_TXPOWER_UNKNOWN
  599. } txpower_type;
  600. int txpower; /* if txpower_type == PRISM2_TXPOWER_FIXED */
  601. /* command queue for hfa384x_cmd(); protected with cmdlock */
  602. struct list_head cmd_queue;
  603. /* max_len for cmd_queue; in addition, cmd_callback can use two
  604. * additional entries to prevent sleeping commands from stopping
  605. * transmits */
  606. #define HOSTAP_CMD_QUEUE_MAX_LEN 16
  607. int cmd_queue_len; /* number of entries in cmd_queue */
  608. /* if card timeout is detected in interrupt context, reset_queue is
  609. * used to schedule card reseting to be done in user context */
  610. struct work_struct reset_queue;
  611. /* For scheduling a change of the promiscuous mode RID */
  612. int is_promisc;
  613. struct work_struct set_multicast_list_queue;
  614. struct work_struct set_tim_queue;
  615. struct list_head set_tim_list;
  616. spinlock_t set_tim_lock;
  617. int wds_max_connections;
  618. int wds_connections;
  619. #define HOSTAP_WDS_BROADCAST_RA BIT(0)
  620. #define HOSTAP_WDS_AP_CLIENT BIT(1)
  621. #define HOSTAP_WDS_STANDARD_FRAME BIT(2)
  622. u32 wds_type;
  623. u16 tx_control; /* flags to be used in TX description */
  624. int manual_retry_count; /* -1 = use f/w default; otherwise retry count
  625. * to be used with all frames */
  626. struct iw_statistics wstats;
  627. unsigned long scan_timestamp; /* Time started to scan */
  628. enum {
  629. PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
  630. PRISM2_MONITOR_CAPHDR = 2
  631. } monitor_type;
  632. int (*saved_eth_header_parse)(struct sk_buff *skb,
  633. unsigned char *haddr);
  634. int monitor_allow_fcserr;
  635. int hostapd; /* whether user space daemon, hostapd, is used for AP
  636. * management */
  637. int hostapd_sta; /* whether hostapd is used with an extra STA interface
  638. */
  639. struct net_device *apdev;
  640. struct net_device_stats apdevstats;
  641. char assoc_ap_addr[ETH_ALEN];
  642. struct net_device *stadev;
  643. struct net_device_stats stadevstats;
  644. #define WEP_KEYS 4
  645. #define WEP_KEY_LEN 13
  646. struct ieee80211_crypt_data *crypt[WEP_KEYS];
  647. int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
  648. struct timer_list crypt_deinit_timer;
  649. struct list_head crypt_deinit_list;
  650. int open_wep; /* allow unencrypted frames */
  651. int host_encrypt;
  652. int host_decrypt;
  653. int privacy_invoked; /* force privacy invoked flag even if no keys are
  654. * configured */
  655. int fw_encrypt_ok; /* whether firmware-based WEP encrypt is working
  656. * in Host AP mode (STA f/w 1.4.9 or newer) */
  657. int bcrx_sta_key; /* use individual keys to override default keys even
  658. * with RX of broad/multicast frames */
  659. struct prism2_frag_entry frag_cache[PRISM2_FRAG_CACHE_LEN];
  660. unsigned int frag_next_idx;
  661. int ieee_802_1x; /* is IEEE 802.1X used */
  662. int antsel_tx, antsel_rx;
  663. int rts_threshold; /* dot11RTSThreshold */
  664. int fragm_threshold; /* dot11FragmentationThreshold */
  665. int auth_algs; /* PRISM2_AUTH_ flags */
  666. int enh_sec; /* cnfEnhSecurity options (broadcast SSID hide/ignore) */
  667. int tallies32; /* 32-bit tallies in use */
  668. struct prism2_helper_functions *func;
  669. u8 *pda;
  670. int fw_ap;
  671. #define PRISM2_FW_VER(major, minor, variant) \
  672. (((major) << 16) | ((minor) << 8) | variant)
  673. u32 sta_fw_ver;
  674. /* Tasklets for handling hardware IRQ related operations outside hw IRQ
  675. * handler */
  676. struct tasklet_struct bap_tasklet;
  677. struct tasklet_struct info_tasklet;
  678. struct sk_buff_head info_list; /* info frames as skb's for
  679. * info_tasklet */
  680. struct hostap_tx_callback_info *tx_callback; /* registered TX callbacks
  681. */
  682. struct tasklet_struct rx_tasklet;
  683. struct sk_buff_head rx_list;
  684. struct tasklet_struct sta_tx_exc_tasklet;
  685. struct sk_buff_head sta_tx_exc_list;
  686. int host_roaming;
  687. unsigned long last_join_time; /* time of last JoinRequest */
  688. struct hfa384x_hostscan_result *last_scan_results;
  689. int last_scan_results_count;
  690. enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type;
  691. struct work_struct info_queue;
  692. long pending_info; /* bit field of pending info_queue items */
  693. #define PRISM2_INFO_PENDING_LINKSTATUS 0
  694. #define PRISM2_INFO_PENDING_SCANRESULTS 1
  695. int prev_link_status; /* previous received LinkStatus info */
  696. int prev_linkstatus_connected;
  697. u8 preferred_ap[6]; /* use this AP if possible */
  698. #ifdef PRISM2_CALLBACK
  699. void *callback_data; /* Can be used in callbacks; e.g., allocate
  700. * on enable event and free on disable event.
  701. * Host AP driver code does not touch this. */
  702. #endif /* PRISM2_CALLBACK */
  703. wait_queue_head_t hostscan_wq;
  704. /* Passive scan in Host AP mode */
  705. struct timer_list passive_scan_timer;
  706. int passive_scan_interval; /* in seconds, 0 = disabled */
  707. int passive_scan_channel;
  708. enum { PASSIVE_SCAN_WAIT, PASSIVE_SCAN_LISTEN } passive_scan_state;
  709. struct timer_list tick_timer;
  710. unsigned long last_tick_timer;
  711. unsigned int sw_tick_stuck;
  712. /* commsQuality / dBmCommsQuality data from periodic polling; only
  713. * valid for Managed and Ad-hoc modes */
  714. unsigned long last_comms_qual_update;
  715. int comms_qual; /* in some odd unit.. */
  716. int avg_signal; /* in dB (note: negative) */
  717. int avg_noise; /* in dB (note: negative) */
  718. struct work_struct comms_qual_update;
  719. /* RSSI to dBm adjustment (for RX descriptor fields) */
  720. int rssi_to_dBm; /* substract from RSSI to get approximate dBm value */
  721. /* BSS list / protected by local->lock */
  722. struct list_head bss_list;
  723. int num_bss_info;
  724. int wpa; /* WPA support enabled */
  725. int tkip_countermeasures;
  726. int drop_unencrypted;
  727. /* Generic IEEE 802.11 info element to be added to
  728. * ProbeResp/Beacon/(Re)AssocReq */
  729. u8 *generic_elem;
  730. size_t generic_elem_len;
  731. #ifdef PRISM2_DOWNLOAD_SUPPORT
  732. /* Persistent volatile download data */
  733. struct prism2_download_data *dl_pri;
  734. struct prism2_download_data *dl_sec;
  735. #endif /* PRISM2_DOWNLOAD_SUPPORT */
  736. #ifdef PRISM2_IO_DEBUG
  737. #define PRISM2_IO_DEBUG_SIZE 10000
  738. u32 io_debug[PRISM2_IO_DEBUG_SIZE];
  739. int io_debug_head;
  740. int io_debug_enabled;
  741. #endif /* PRISM2_IO_DEBUG */
  742. /* Pointer to hardware model specific (cs,pci,plx) private data. */
  743. void *hw_priv;
  744. };
  745. /* Per interface private Host AP data
  746. * Allocated for each net device that Host AP uses (wlan#, wlan#ap, wlan#sta,
  747. * WDS) and netdev_priv(dev) points to this structure. */
  748. struct hostap_interface {
  749. struct list_head list; /* list entry in Host AP interface list */
  750. struct net_device *dev; /* pointer to this device */
  751. struct local_info *local; /* pointer to shared private data */
  752. struct net_device_stats stats;
  753. struct iw_spy_data spy_data; /* iwspy support */
  754. struct iw_public_data wireless_data;
  755. enum {
  756. HOSTAP_INTERFACE_MASTER,
  757. HOSTAP_INTERFACE_MAIN,
  758. HOSTAP_INTERFACE_AP,
  759. HOSTAP_INTERFACE_STA,
  760. HOSTAP_INTERFACE_WDS,
  761. } type;
  762. union {
  763. struct hostap_interface_wds {
  764. u8 remote_addr[ETH_ALEN];
  765. } wds;
  766. } u;
  767. };
  768. #define HOSTAP_SKB_TX_DATA_MAGIC 0xf08a36a2
  769. /*
  770. * TX meta data - stored in skb->cb buffer, so this must not be increased over
  771. * the 40-byte limit
  772. */
  773. struct hostap_skb_tx_data {
  774. u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */
  775. u8 rate; /* transmit rate */
  776. #define HOSTAP_TX_FLAGS_WDS BIT(0)
  777. #define HOSTAP_TX_FLAGS_BUFFERED_FRAME BIT(1)
  778. #define HOSTAP_TX_FLAGS_ADD_MOREDATA BIT(2)
  779. u8 flags; /* HOSTAP_TX_FLAGS_* */
  780. u16 tx_cb_idx;
  781. struct hostap_interface *iface;
  782. unsigned long jiffies; /* queueing timestamp */
  783. unsigned short ethertype;
  784. };
  785. #ifndef PRISM2_NO_DEBUG
  786. #define DEBUG_FID BIT(0)
  787. #define DEBUG_PS BIT(1)
  788. #define DEBUG_FLOW BIT(2)
  789. #define DEBUG_AP BIT(3)
  790. #define DEBUG_HW BIT(4)
  791. #define DEBUG_EXTRA BIT(5)
  792. #define DEBUG_EXTRA2 BIT(6)
  793. #define DEBUG_PS2 BIT(7)
  794. #define DEBUG_MASK (DEBUG_PS | DEBUG_AP | DEBUG_HW | DEBUG_EXTRA)
  795. #define PDEBUG(n, args...) \
  796. do { if ((n) & DEBUG_MASK) printk(KERN_DEBUG args); } while (0)
  797. #define PDEBUG2(n, args...) \
  798. do { if ((n) & DEBUG_MASK) printk(args); } while (0)
  799. #else /* PRISM2_NO_DEBUG */
  800. #define PDEBUG(n, args...)
  801. #define PDEBUG2(n, args...)
  802. #endif /* PRISM2_NO_DEBUG */
  803. enum { BAP0 = 0, BAP1 = 1 };
  804. #define PRISM2_IO_DEBUG_CMD_INB 0
  805. #define PRISM2_IO_DEBUG_CMD_INW 1
  806. #define PRISM2_IO_DEBUG_CMD_INSW 2
  807. #define PRISM2_IO_DEBUG_CMD_OUTB 3
  808. #define PRISM2_IO_DEBUG_CMD_OUTW 4
  809. #define PRISM2_IO_DEBUG_CMD_OUTSW 5
  810. #define PRISM2_IO_DEBUG_CMD_ERROR 6
  811. #define PRISM2_IO_DEBUG_CMD_INTERRUPT 7
  812. #ifdef PRISM2_IO_DEBUG
  813. #define PRISM2_IO_DEBUG_ENTRY(cmd, reg, value) \
  814. (((cmd) << 24) | ((reg) << 16) | value)
  815. static inline void prism2_io_debug_add(struct net_device *dev, int cmd,
  816. int reg, int value)
  817. {
  818. struct hostap_interface *iface = netdev_priv(dev);
  819. local_info_t *local = iface->local;
  820. if (!local->io_debug_enabled)
  821. return;
  822. local->io_debug[local->io_debug_head] = jiffies & 0xffffffff;
  823. if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE)
  824. local->io_debug_head = 0;
  825. local->io_debug[local->io_debug_head] =
  826. PRISM2_IO_DEBUG_ENTRY(cmd, reg, value);
  827. if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE)
  828. local->io_debug_head = 0;
  829. }
  830. static inline void prism2_io_debug_error(struct net_device *dev, int err)
  831. {
  832. struct hostap_interface *iface = netdev_priv(dev);
  833. local_info_t *local = iface->local;
  834. unsigned long flags;
  835. if (!local->io_debug_enabled)
  836. return;
  837. spin_lock_irqsave(&local->lock, flags);
  838. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_ERROR, 0, err);
  839. if (local->io_debug_enabled == 1) {
  840. local->io_debug_enabled = 0;
  841. printk(KERN_DEBUG "%s: I/O debug stopped\n", dev->name);
  842. }
  843. spin_unlock_irqrestore(&local->lock, flags);
  844. }
  845. #else /* PRISM2_IO_DEBUG */
  846. static inline void prism2_io_debug_add(struct net_device *dev, int cmd,
  847. int reg, int value)
  848. {
  849. }
  850. static inline void prism2_io_debug_error(struct net_device *dev, int err)
  851. {
  852. }
  853. #endif /* PRISM2_IO_DEBUG */
  854. #ifdef PRISM2_CALLBACK
  855. enum {
  856. /* Called when card is enabled */
  857. PRISM2_CALLBACK_ENABLE,
  858. /* Called when card is disabled */
  859. PRISM2_CALLBACK_DISABLE,
  860. /* Called when RX/TX starts/ends */
  861. PRISM2_CALLBACK_RX_START, PRISM2_CALLBACK_RX_END,
  862. PRISM2_CALLBACK_TX_START, PRISM2_CALLBACK_TX_END
  863. };
  864. void prism2_callback(local_info_t *local, int event);
  865. #else /* PRISM2_CALLBACK */
  866. #define prism2_callback(d, e) do { } while (0)
  867. #endif /* PRISM2_CALLBACK */
  868. #endif /* __KERNEL__ */
  869. #endif /* HOSTAP_WLAN_H */