hostap_wlan.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034
  1. #ifndef HOSTAP_WLAN_H
  2. #define HOSTAP_WLAN_H
  3. #include <linux/wireless.h>
  4. #include <linux/netdevice.h>
  5. #include <linux/mutex.h>
  6. #include <net/iw_handler.h>
  7. #include "hostap_config.h"
  8. #include "hostap_common.h"
  9. #define MAX_PARM_DEVICES 8
  10. #define PARM_MIN_MAX "1-" __MODULE_STRING(MAX_PARM_DEVICES)
  11. #define DEF_INTS -1, -1, -1, -1, -1, -1, -1
  12. #define GET_INT_PARM(var,idx) var[var[idx] < 0 ? 0 : idx]
  13. /* Specific skb->protocol value that indicates that the packet already contains
  14. * txdesc header.
  15. * FIX: This might need own value that would be allocated especially for Prism2
  16. * txdesc; ETH_P_CONTROL is commented as "Card specific control frames".
  17. * However, these skb's should have only minimal path in the kernel side since
  18. * prism2_send_mgmt() sends these with dev_queue_xmit() to prism2_tx(). */
  19. #define ETH_P_HOSTAP ETH_P_CONTROL
  20. /* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
  21. * (from linux-wlan-ng) */
  22. struct linux_wlan_ng_val {
  23. u32 did;
  24. u16 status, len;
  25. u32 data;
  26. } __attribute__ ((packed));
  27. struct linux_wlan_ng_prism_hdr {
  28. u32 msgcode, msglen;
  29. char devname[16];
  30. struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
  31. noise, rate, istx, frmlen;
  32. } __attribute__ ((packed));
  33. struct linux_wlan_ng_cap_hdr {
  34. u32 version;
  35. u32 length;
  36. u64 mactime;
  37. u64 hosttime;
  38. u32 phytype;
  39. u32 channel;
  40. u32 datarate;
  41. u32 antenna;
  42. u32 priority;
  43. u32 ssi_type;
  44. s32 ssi_signal;
  45. s32 ssi_noise;
  46. u32 preamble;
  47. u32 encoding;
  48. } __attribute__ ((packed));
  49. #define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
  50. #define LWNG_CAPHDR_VERSION 0x80211001
  51. struct hfa384x_rx_frame {
  52. /* HFA384X RX frame descriptor */
  53. u16 status; /* HFA384X_RX_STATUS_ flags */
  54. u32 time; /* timestamp, 1 microsecond resolution */
  55. u8 silence; /* 27 .. 154; seems to be 0 */
  56. u8 signal; /* 27 .. 154 */
  57. u8 rate; /* 10, 20, 55, or 110 */
  58. u8 rxflow;
  59. u32 reserved;
  60. /* 802.11 */
  61. u16 frame_control;
  62. u16 duration_id;
  63. u8 addr1[6];
  64. u8 addr2[6];
  65. u8 addr3[6];
  66. u16 seq_ctrl;
  67. u8 addr4[6];
  68. u16 data_len;
  69. /* 802.3 */
  70. u8 dst_addr[6];
  71. u8 src_addr[6];
  72. u16 len;
  73. /* followed by frame data; max 2304 bytes */
  74. } __attribute__ ((packed));
  75. struct hfa384x_tx_frame {
  76. /* HFA384X TX frame descriptor */
  77. u16 status; /* HFA384X_TX_STATUS_ flags */
  78. u16 reserved1;
  79. u16 reserved2;
  80. u32 sw_support;
  81. u8 retry_count; /* not yet implemented */
  82. u8 tx_rate; /* Host AP only; 0 = firmware, or 10, 20, 55, 110 */
  83. u16 tx_control; /* HFA384X_TX_CTRL_ flags */
  84. /* 802.11 */
  85. u16 frame_control; /* parts not used */
  86. u16 duration_id;
  87. u8 addr1[6];
  88. u8 addr2[6]; /* filled by firmware */
  89. u8 addr3[6];
  90. u16 seq_ctrl; /* filled by firmware */
  91. u8 addr4[6];
  92. u16 data_len;
  93. /* 802.3 */
  94. u8 dst_addr[6];
  95. u8 src_addr[6];
  96. u16 len;
  97. /* followed by frame data; max 2304 bytes */
  98. } __attribute__ ((packed));
  99. struct hfa384x_rid_hdr
  100. {
  101. u16 len;
  102. u16 rid;
  103. } __attribute__ ((packed));
  104. /* Macro for converting signal levels (range 27 .. 154) to wireless ext
  105. * dBm value with some accuracy */
  106. #define HFA384X_LEVEL_TO_dBm(v) 0x100 + (v) * 100 / 255 - 100
  107. #define HFA384X_LEVEL_TO_dBm_sign(v) (v) * 100 / 255 - 100
  108. struct hfa384x_scan_request {
  109. u16 channel_list;
  110. u16 txrate; /* HFA384X_RATES_* */
  111. } __attribute__ ((packed));
  112. struct hfa384x_hostscan_request {
  113. u16 channel_list;
  114. u16 txrate;
  115. u16 target_ssid_len;
  116. u8 target_ssid[32];
  117. } __attribute__ ((packed));
  118. struct hfa384x_join_request {
  119. u8 bssid[6];
  120. u16 channel;
  121. } __attribute__ ((packed));
  122. struct hfa384x_info_frame {
  123. u16 len;
  124. u16 type;
  125. } __attribute__ ((packed));
  126. struct hfa384x_comm_tallies {
  127. u16 tx_unicast_frames;
  128. u16 tx_multicast_frames;
  129. u16 tx_fragments;
  130. u16 tx_unicast_octets;
  131. u16 tx_multicast_octets;
  132. u16 tx_deferred_transmissions;
  133. u16 tx_single_retry_frames;
  134. u16 tx_multiple_retry_frames;
  135. u16 tx_retry_limit_exceeded;
  136. u16 tx_discards;
  137. u16 rx_unicast_frames;
  138. u16 rx_multicast_frames;
  139. u16 rx_fragments;
  140. u16 rx_unicast_octets;
  141. u16 rx_multicast_octets;
  142. u16 rx_fcs_errors;
  143. u16 rx_discards_no_buffer;
  144. u16 tx_discards_wrong_sa;
  145. u16 rx_discards_wep_undecryptable;
  146. u16 rx_message_in_msg_fragments;
  147. u16 rx_message_in_bad_msg_fragments;
  148. } __attribute__ ((packed));
  149. struct hfa384x_comm_tallies32 {
  150. u32 tx_unicast_frames;
  151. u32 tx_multicast_frames;
  152. u32 tx_fragments;
  153. u32 tx_unicast_octets;
  154. u32 tx_multicast_octets;
  155. u32 tx_deferred_transmissions;
  156. u32 tx_single_retry_frames;
  157. u32 tx_multiple_retry_frames;
  158. u32 tx_retry_limit_exceeded;
  159. u32 tx_discards;
  160. u32 rx_unicast_frames;
  161. u32 rx_multicast_frames;
  162. u32 rx_fragments;
  163. u32 rx_unicast_octets;
  164. u32 rx_multicast_octets;
  165. u32 rx_fcs_errors;
  166. u32 rx_discards_no_buffer;
  167. u32 tx_discards_wrong_sa;
  168. u32 rx_discards_wep_undecryptable;
  169. u32 rx_message_in_msg_fragments;
  170. u32 rx_message_in_bad_msg_fragments;
  171. } __attribute__ ((packed));
  172. struct hfa384x_scan_result_hdr {
  173. u16 reserved;
  174. u16 scan_reason;
  175. #define HFA384X_SCAN_IN_PROGRESS 0 /* no results available yet */
  176. #define HFA384X_SCAN_HOST_INITIATED 1
  177. #define HFA384X_SCAN_FIRMWARE_INITIATED 2
  178. #define HFA384X_SCAN_INQUIRY_FROM_HOST 3
  179. } __attribute__ ((packed));
  180. #define HFA384X_SCAN_MAX_RESULTS 32
  181. struct hfa384x_scan_result {
  182. u16 chid;
  183. u16 anl;
  184. u16 sl;
  185. u8 bssid[6];
  186. u16 beacon_interval;
  187. u16 capability;
  188. u16 ssid_len;
  189. u8 ssid[32];
  190. u8 sup_rates[10];
  191. u16 rate;
  192. } __attribute__ ((packed));
  193. struct hfa384x_hostscan_result {
  194. u16 chid;
  195. u16 anl;
  196. u16 sl;
  197. u8 bssid[6];
  198. u16 beacon_interval;
  199. u16 capability;
  200. u16 ssid_len;
  201. u8 ssid[32];
  202. u8 sup_rates[10];
  203. u16 rate;
  204. u16 atim;
  205. } __attribute__ ((packed));
  206. struct comm_tallies_sums {
  207. unsigned int tx_unicast_frames;
  208. unsigned int tx_multicast_frames;
  209. unsigned int tx_fragments;
  210. unsigned int tx_unicast_octets;
  211. unsigned int tx_multicast_octets;
  212. unsigned int tx_deferred_transmissions;
  213. unsigned int tx_single_retry_frames;
  214. unsigned int tx_multiple_retry_frames;
  215. unsigned int tx_retry_limit_exceeded;
  216. unsigned int tx_discards;
  217. unsigned int rx_unicast_frames;
  218. unsigned int rx_multicast_frames;
  219. unsigned int rx_fragments;
  220. unsigned int rx_unicast_octets;
  221. unsigned int rx_multicast_octets;
  222. unsigned int rx_fcs_errors;
  223. unsigned int rx_discards_no_buffer;
  224. unsigned int tx_discards_wrong_sa;
  225. unsigned int rx_discards_wep_undecryptable;
  226. unsigned int rx_message_in_msg_fragments;
  227. unsigned int rx_message_in_bad_msg_fragments;
  228. };
  229. struct hfa384x_regs {
  230. u16 cmd;
  231. u16 evstat;
  232. u16 offset0;
  233. u16 offset1;
  234. u16 swsupport0;
  235. };
  236. #if defined(PRISM2_PCCARD) || defined(PRISM2_PLX)
  237. /* I/O ports for HFA384X Controller access */
  238. #define HFA384X_CMD_OFF 0x00
  239. #define HFA384X_PARAM0_OFF 0x02
  240. #define HFA384X_PARAM1_OFF 0x04
  241. #define HFA384X_PARAM2_OFF 0x06
  242. #define HFA384X_STATUS_OFF 0x08
  243. #define HFA384X_RESP0_OFF 0x0A
  244. #define HFA384X_RESP1_OFF 0x0C
  245. #define HFA384X_RESP2_OFF 0x0E
  246. #define HFA384X_INFOFID_OFF 0x10
  247. #define HFA384X_CONTROL_OFF 0x14
  248. #define HFA384X_SELECT0_OFF 0x18
  249. #define HFA384X_SELECT1_OFF 0x1A
  250. #define HFA384X_OFFSET0_OFF 0x1C
  251. #define HFA384X_OFFSET1_OFF 0x1E
  252. #define HFA384X_RXFID_OFF 0x20
  253. #define HFA384X_ALLOCFID_OFF 0x22
  254. #define HFA384X_TXCOMPLFID_OFF 0x24
  255. #define HFA384X_SWSUPPORT0_OFF 0x28
  256. #define HFA384X_SWSUPPORT1_OFF 0x2A
  257. #define HFA384X_SWSUPPORT2_OFF 0x2C
  258. #define HFA384X_EVSTAT_OFF 0x30
  259. #define HFA384X_INTEN_OFF 0x32
  260. #define HFA384X_EVACK_OFF 0x34
  261. #define HFA384X_DATA0_OFF 0x36
  262. #define HFA384X_DATA1_OFF 0x38
  263. #define HFA384X_AUXPAGE_OFF 0x3A
  264. #define HFA384X_AUXOFFSET_OFF 0x3C
  265. #define HFA384X_AUXDATA_OFF 0x3E
  266. #endif /* PRISM2_PCCARD || PRISM2_PLX */
  267. #ifdef PRISM2_PCI
  268. /* Memory addresses for ISL3874 controller access */
  269. #define HFA384X_CMD_OFF 0x00
  270. #define HFA384X_PARAM0_OFF 0x04
  271. #define HFA384X_PARAM1_OFF 0x08
  272. #define HFA384X_PARAM2_OFF 0x0C
  273. #define HFA384X_STATUS_OFF 0x10
  274. #define HFA384X_RESP0_OFF 0x14
  275. #define HFA384X_RESP1_OFF 0x18
  276. #define HFA384X_RESP2_OFF 0x1C
  277. #define HFA384X_INFOFID_OFF 0x20
  278. #define HFA384X_CONTROL_OFF 0x28
  279. #define HFA384X_SELECT0_OFF 0x30
  280. #define HFA384X_SELECT1_OFF 0x34
  281. #define HFA384X_OFFSET0_OFF 0x38
  282. #define HFA384X_OFFSET1_OFF 0x3C
  283. #define HFA384X_RXFID_OFF 0x40
  284. #define HFA384X_ALLOCFID_OFF 0x44
  285. #define HFA384X_TXCOMPLFID_OFF 0x48
  286. #define HFA384X_PCICOR_OFF 0x4C
  287. #define HFA384X_SWSUPPORT0_OFF 0x50
  288. #define HFA384X_SWSUPPORT1_OFF 0x54
  289. #define HFA384X_SWSUPPORT2_OFF 0x58
  290. #define HFA384X_PCIHCR_OFF 0x5C
  291. #define HFA384X_EVSTAT_OFF 0x60
  292. #define HFA384X_INTEN_OFF 0x64
  293. #define HFA384X_EVACK_OFF 0x68
  294. #define HFA384X_DATA0_OFF 0x6C
  295. #define HFA384X_DATA1_OFF 0x70
  296. #define HFA384X_AUXPAGE_OFF 0x74
  297. #define HFA384X_AUXOFFSET_OFF 0x78
  298. #define HFA384X_AUXDATA_OFF 0x7C
  299. #define HFA384X_PCI_M0_ADDRH_OFF 0x80
  300. #define HFA384X_PCI_M0_ADDRL_OFF 0x84
  301. #define HFA384X_PCI_M0_LEN_OFF 0x88
  302. #define HFA384X_PCI_M0_CTL_OFF 0x8C
  303. #define HFA384X_PCI_STATUS_OFF 0x98
  304. #define HFA384X_PCI_M1_ADDRH_OFF 0xA0
  305. #define HFA384X_PCI_M1_ADDRL_OFF 0xA4
  306. #define HFA384X_PCI_M1_LEN_OFF 0xA8
  307. #define HFA384X_PCI_M1_CTL_OFF 0xAC
  308. /* PCI bus master control bits (these are undocumented; based on guessing and
  309. * experimenting..) */
  310. #define HFA384X_PCI_CTL_FROM_BAP (BIT(5) | BIT(1) | BIT(0))
  311. #define HFA384X_PCI_CTL_TO_BAP (BIT(5) | BIT(0))
  312. #endif /* PRISM2_PCI */
  313. /* Command codes for CMD reg. */
  314. #define HFA384X_CMDCODE_INIT 0x00
  315. #define HFA384X_CMDCODE_ENABLE 0x01
  316. #define HFA384X_CMDCODE_DISABLE 0x02
  317. #define HFA384X_CMDCODE_ALLOC 0x0A
  318. #define HFA384X_CMDCODE_TRANSMIT 0x0B
  319. #define HFA384X_CMDCODE_INQUIRE 0x11
  320. #define HFA384X_CMDCODE_ACCESS 0x21
  321. #define HFA384X_CMDCODE_ACCESS_WRITE (0x21 | BIT(8))
  322. #define HFA384X_CMDCODE_DOWNLOAD 0x22
  323. #define HFA384X_CMDCODE_READMIF 0x30
  324. #define HFA384X_CMDCODE_WRITEMIF 0x31
  325. #define HFA384X_CMDCODE_TEST 0x38
  326. #define HFA384X_CMDCODE_MASK 0x3F
  327. /* Test mode operations */
  328. #define HFA384X_TEST_CHANGE_CHANNEL 0x08
  329. #define HFA384X_TEST_MONITOR 0x0B
  330. #define HFA384X_TEST_STOP 0x0F
  331. #define HFA384X_TEST_CFG_BITS 0x15
  332. #define HFA384X_TEST_CFG_BIT_ALC BIT(3)
  333. #define HFA384X_CMD_BUSY BIT(15)
  334. #define HFA384X_CMD_TX_RECLAIM BIT(8)
  335. #define HFA384X_OFFSET_ERR BIT(14)
  336. #define HFA384X_OFFSET_BUSY BIT(15)
  337. /* ProgMode for download command */
  338. #define HFA384X_PROGMODE_DISABLE 0
  339. #define HFA384X_PROGMODE_ENABLE_VOLATILE 1
  340. #define HFA384X_PROGMODE_ENABLE_NON_VOLATILE 2
  341. #define HFA384X_PROGMODE_PROGRAM_NON_VOLATILE 3
  342. #define HFA384X_AUX_MAGIC0 0xfe01
  343. #define HFA384X_AUX_MAGIC1 0xdc23
  344. #define HFA384X_AUX_MAGIC2 0xba45
  345. #define HFA384X_AUX_PORT_DISABLED 0
  346. #define HFA384X_AUX_PORT_DISABLE BIT(14)
  347. #define HFA384X_AUX_PORT_ENABLE BIT(15)
  348. #define HFA384X_AUX_PORT_ENABLED (BIT(14) | BIT(15))
  349. #define HFA384X_AUX_PORT_MASK (BIT(14) | BIT(15))
  350. #define PRISM2_PDA_SIZE 1024
  351. /* Events; EvStat, Interrupt mask (IntEn), and acknowledge bits (EvAck) */
  352. #define HFA384X_EV_TICK BIT(15)
  353. #define HFA384X_EV_WTERR BIT(14)
  354. #define HFA384X_EV_INFDROP BIT(13)
  355. #ifdef PRISM2_PCI
  356. #define HFA384X_EV_PCI_M1 BIT(9)
  357. #define HFA384X_EV_PCI_M0 BIT(8)
  358. #endif /* PRISM2_PCI */
  359. #define HFA384X_EV_INFO BIT(7)
  360. #define HFA384X_EV_DTIM BIT(5)
  361. #define HFA384X_EV_CMD BIT(4)
  362. #define HFA384X_EV_ALLOC BIT(3)
  363. #define HFA384X_EV_TXEXC BIT(2)
  364. #define HFA384X_EV_TX BIT(1)
  365. #define HFA384X_EV_RX BIT(0)
  366. /* HFA384X Information frames */
  367. #define HFA384X_INFO_HANDOVERADDR 0xF000 /* AP f/w ? */
  368. #define HFA384X_INFO_HANDOVERDEAUTHADDR 0xF001 /* AP f/w 1.3.7 */
  369. #define HFA384X_INFO_COMMTALLIES 0xF100
  370. #define HFA384X_INFO_SCANRESULTS 0xF101
  371. #define HFA384X_INFO_CHANNELINFORESULTS 0xF102 /* AP f/w only */
  372. #define HFA384X_INFO_HOSTSCANRESULTS 0xF103
  373. #define HFA384X_INFO_LINKSTATUS 0xF200
  374. #define HFA384X_INFO_ASSOCSTATUS 0xF201 /* ? */
  375. #define HFA384X_INFO_AUTHREQ 0xF202 /* ? */
  376. #define HFA384X_INFO_PSUSERCNT 0xF203 /* ? */
  377. #define HFA384X_INFO_KEYIDCHANGED 0xF204 /* ? */
  378. enum { HFA384X_LINKSTATUS_CONNECTED = 1,
  379. HFA384X_LINKSTATUS_DISCONNECTED = 2,
  380. HFA384X_LINKSTATUS_AP_CHANGE = 3,
  381. HFA384X_LINKSTATUS_AP_OUT_OF_RANGE = 4,
  382. HFA384X_LINKSTATUS_AP_IN_RANGE = 5,
  383. HFA384X_LINKSTATUS_ASSOC_FAILED = 6 };
  384. enum { HFA384X_PORTTYPE_BSS = 1, HFA384X_PORTTYPE_WDS = 2,
  385. HFA384X_PORTTYPE_PSEUDO_IBSS = 3, HFA384X_PORTTYPE_IBSS = 0,
  386. HFA384X_PORTTYPE_HOSTAP = 6 };
  387. #define HFA384X_RATES_1MBPS BIT(0)
  388. #define HFA384X_RATES_2MBPS BIT(1)
  389. #define HFA384X_RATES_5MBPS BIT(2)
  390. #define HFA384X_RATES_11MBPS BIT(3)
  391. #define HFA384X_ROAMING_FIRMWARE 1
  392. #define HFA384X_ROAMING_HOST 2
  393. #define HFA384X_ROAMING_DISABLED 3
  394. #define HFA384X_WEPFLAGS_PRIVACYINVOKED BIT(0)
  395. #define HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED BIT(1)
  396. #define HFA384X_WEPFLAGS_HOSTENCRYPT BIT(4)
  397. #define HFA384X_WEPFLAGS_HOSTDECRYPT BIT(7)
  398. #define HFA384X_RX_STATUS_MSGTYPE (BIT(15) | BIT(14) | BIT(13))
  399. #define HFA384X_RX_STATUS_PCF BIT(12)
  400. #define HFA384X_RX_STATUS_MACPORT (BIT(10) | BIT(9) | BIT(8))
  401. #define HFA384X_RX_STATUS_UNDECR BIT(1)
  402. #define HFA384X_RX_STATUS_FCSERR BIT(0)
  403. #define HFA384X_RX_STATUS_GET_MSGTYPE(s) \
  404. (((s) & HFA384X_RX_STATUS_MSGTYPE) >> 13)
  405. #define HFA384X_RX_STATUS_GET_MACPORT(s) \
  406. (((s) & HFA384X_RX_STATUS_MACPORT) >> 8)
  407. enum { HFA384X_RX_MSGTYPE_NORMAL = 0, HFA384X_RX_MSGTYPE_RFC1042 = 1,
  408. HFA384X_RX_MSGTYPE_BRIDGETUNNEL = 2, HFA384X_RX_MSGTYPE_MGMT = 4 };
  409. #define HFA384X_TX_CTRL_ALT_RTRY BIT(5)
  410. #define HFA384X_TX_CTRL_802_11 BIT(3)
  411. #define HFA384X_TX_CTRL_802_3 0
  412. #define HFA384X_TX_CTRL_TX_EX BIT(2)
  413. #define HFA384X_TX_CTRL_TX_OK BIT(1)
  414. #define HFA384X_TX_STATUS_RETRYERR BIT(0)
  415. #define HFA384X_TX_STATUS_AGEDERR BIT(1)
  416. #define HFA384X_TX_STATUS_DISCON BIT(2)
  417. #define HFA384X_TX_STATUS_FORMERR BIT(3)
  418. /* HFA3861/3863 (BBP) Control Registers */
  419. #define HFA386X_CR_TX_CONFIGURE 0x12 /* CR9 */
  420. #define HFA386X_CR_RX_CONFIGURE 0x14 /* CR10 */
  421. #define HFA386X_CR_A_D_TEST_MODES2 0x1A /* CR13 */
  422. #define HFA386X_CR_MANUAL_TX_POWER 0x3E /* CR31 */
  423. #define HFA386X_CR_MEASURED_TX_POWER 0x74 /* CR58 */
  424. #ifdef __KERNEL__
  425. #define PRISM2_TXFID_COUNT 8
  426. #define PRISM2_DATA_MAXLEN 2304
  427. #define PRISM2_TXFID_LEN (PRISM2_DATA_MAXLEN + sizeof(struct hfa384x_tx_frame))
  428. #define PRISM2_TXFID_EMPTY 0xffff
  429. #define PRISM2_TXFID_RESERVED 0xfffe
  430. #define PRISM2_DUMMY_FID 0xffff
  431. #define MAX_SSID_LEN 32
  432. #define MAX_NAME_LEN 32 /* this is assumed to be equal to MAX_SSID_LEN */
  433. #define PRISM2_DUMP_RX_HDR BIT(0)
  434. #define PRISM2_DUMP_TX_HDR BIT(1)
  435. #define PRISM2_DUMP_TXEXC_HDR BIT(2)
  436. struct hostap_tx_callback_info {
  437. u16 idx;
  438. void (*func)(struct sk_buff *, int ok, void *);
  439. void *data;
  440. struct hostap_tx_callback_info *next;
  441. };
  442. /* IEEE 802.11 requires that STA supports concurrent reception of at least
  443. * three fragmented frames. This define can be increased to support more
  444. * concurrent frames, but it should be noted that each entry can consume about
  445. * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
  446. #define PRISM2_FRAG_CACHE_LEN 4
  447. struct prism2_frag_entry {
  448. unsigned long first_frag_time;
  449. unsigned int seq;
  450. unsigned int last_frag;
  451. struct sk_buff *skb;
  452. u8 src_addr[ETH_ALEN];
  453. u8 dst_addr[ETH_ALEN];
  454. };
  455. struct hostap_cmd_queue {
  456. struct list_head list;
  457. wait_queue_head_t compl;
  458. volatile enum { CMD_SLEEP, CMD_CALLBACK, CMD_COMPLETED } type;
  459. void (*callback)(struct net_device *dev, long context, u16 resp0,
  460. u16 res);
  461. long context;
  462. u16 cmd, param0, param1;
  463. u16 resp0, res;
  464. volatile int issued, issuing;
  465. atomic_t usecnt;
  466. int del_req;
  467. };
  468. /* options for hw_shutdown */
  469. #define HOSTAP_HW_NO_DISABLE BIT(0)
  470. #define HOSTAP_HW_ENABLE_CMDCOMPL BIT(1)
  471. typedef struct local_info local_info_t;
  472. struct prism2_helper_functions {
  473. /* these functions are defined in hardware model specific files
  474. * (hostap_{cs,plx,pci}.c */
  475. int (*card_present)(local_info_t *local);
  476. void (*cor_sreset)(local_info_t *local);
  477. void (*genesis_reset)(local_info_t *local, int hcr);
  478. /* the following functions are from hostap_hw.c, but they may have some
  479. * hardware model specific code */
  480. /* FIX: low-level commands like cmd might disappear at some point to
  481. * make it easier to change them if needed (e.g., cmd would be replaced
  482. * with write_mif/read_mif/testcmd/inquire); at least get_rid and
  483. * set_rid might move to hostap_{cs,plx,pci}.c */
  484. int (*cmd)(struct net_device *dev, u16 cmd, u16 param0, u16 *param1,
  485. u16 *resp0);
  486. void (*read_regs)(struct net_device *dev, struct hfa384x_regs *regs);
  487. int (*get_rid)(struct net_device *dev, u16 rid, void *buf, int len,
  488. int exact_len);
  489. int (*set_rid)(struct net_device *dev, u16 rid, void *buf, int len);
  490. int (*hw_enable)(struct net_device *dev, int initial);
  491. int (*hw_config)(struct net_device *dev, int initial);
  492. void (*hw_reset)(struct net_device *dev);
  493. void (*hw_shutdown)(struct net_device *dev, int no_disable);
  494. int (*reset_port)(struct net_device *dev);
  495. void (*schedule_reset)(local_info_t *local);
  496. int (*download)(local_info_t *local,
  497. struct prism2_download_param *param);
  498. int (*tx)(struct sk_buff *skb, struct net_device *dev);
  499. int (*set_tim)(struct net_device *dev, int aid, int set);
  500. int (*read_aux)(struct net_device *dev, unsigned addr, int len,
  501. u8 *buf);
  502. int need_tx_headroom; /* number of bytes of headroom needed before
  503. * IEEE 802.11 header */
  504. enum { HOSTAP_HW_PCCARD, HOSTAP_HW_PLX, HOSTAP_HW_PCI } hw_type;
  505. };
  506. struct prism2_download_data {
  507. u32 dl_cmd;
  508. u32 start_addr;
  509. u32 num_areas;
  510. struct prism2_download_data_area {
  511. u32 addr; /* wlan card address */
  512. u32 len;
  513. u8 *data; /* allocated data */
  514. } data[0];
  515. };
  516. #define HOSTAP_MAX_BSS_COUNT 64
  517. #define MAX_WPA_IE_LEN 64
  518. struct hostap_bss_info {
  519. struct list_head list;
  520. unsigned long last_update;
  521. unsigned int count;
  522. u8 bssid[ETH_ALEN];
  523. u16 capab_info;
  524. u8 ssid[32];
  525. size_t ssid_len;
  526. u8 wpa_ie[MAX_WPA_IE_LEN];
  527. size_t wpa_ie_len;
  528. u8 rsn_ie[MAX_WPA_IE_LEN];
  529. size_t rsn_ie_len;
  530. int chan;
  531. int included;
  532. };
  533. /* Per radio private Host AP data - shared by all net devices interfaces used
  534. * by each radio (wlan#, wlan#ap, wlan#sta, WDS).
  535. * ((struct hostap_interface *) netdev_priv(dev))->local points to this
  536. * structure. */
  537. struct local_info {
  538. struct module *hw_module;
  539. int card_idx;
  540. int dev_enabled;
  541. int master_dev_auto_open; /* was master device opened automatically */
  542. int num_dev_open; /* number of open devices */
  543. struct net_device *dev; /* master radio device */
  544. struct net_device *ddev; /* main data device */
  545. struct list_head hostap_interfaces; /* Host AP interface list (contains
  546. * struct hostap_interface entries)
  547. */
  548. rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock
  549. * when removing entries from the list.
  550. * TX and RX paths can use read lock. */
  551. spinlock_t cmdlock, baplock, lock;
  552. struct mutex rid_bap_mtx;
  553. u16 infofid; /* MAC buffer id for info frame */
  554. /* txfid, intransmitfid, next_txtid, and next_alloc are protected by
  555. * txfidlock */
  556. spinlock_t txfidlock;
  557. int txfid_len; /* length of allocated TX buffers */
  558. u16 txfid[PRISM2_TXFID_COUNT]; /* buffer IDs for TX frames */
  559. /* buffer IDs for intransmit frames or PRISM2_TXFID_EMPTY if
  560. * corresponding txfid is free for next TX frame */
  561. u16 intransmitfid[PRISM2_TXFID_COUNT];
  562. int next_txfid; /* index to the next txfid to be checked for
  563. * availability */
  564. int next_alloc; /* index to the next intransmitfid to be checked for
  565. * allocation events */
  566. /* bitfield for atomic bitops */
  567. #define HOSTAP_BITS_TRANSMIT 0
  568. #define HOSTAP_BITS_BAP_TASKLET 1
  569. #define HOSTAP_BITS_BAP_TASKLET2 2
  570. long bits;
  571. struct ap_data *ap;
  572. char essid[MAX_SSID_LEN + 1];
  573. char name[MAX_NAME_LEN + 1];
  574. int name_set;
  575. u16 channel_mask; /* mask of allowed channels */
  576. u16 scan_channel_mask; /* mask of channels to be scanned */
  577. struct comm_tallies_sums comm_tallies;
  578. struct net_device_stats stats;
  579. struct proc_dir_entry *proc;
  580. int iw_mode; /* operating mode (IW_MODE_*) */
  581. int pseudo_adhoc; /* 0: IW_MODE_ADHOC is real 802.11 compliant IBSS
  582. * 1: IW_MODE_ADHOC is "pseudo IBSS" */
  583. char bssid[ETH_ALEN];
  584. int channel;
  585. int beacon_int;
  586. int dtim_period;
  587. int mtu;
  588. int frame_dump; /* dump RX/TX frame headers, PRISM2_DUMP_ flags */
  589. int fw_tx_rate_control;
  590. u16 tx_rate_control;
  591. u16 basic_rates;
  592. int hw_resetting;
  593. int hw_ready;
  594. int hw_reset_tries; /* how many times reset has been tried */
  595. int hw_downloading;
  596. int shutdown;
  597. int pri_only;
  598. int no_pri; /* no PRI f/w present */
  599. int sram_type; /* 8 = x8 SRAM, 16 = x16 SRAM, -1 = unknown */
  600. enum {
  601. PRISM2_TXPOWER_AUTO = 0, PRISM2_TXPOWER_OFF,
  602. PRISM2_TXPOWER_FIXED, PRISM2_TXPOWER_UNKNOWN
  603. } txpower_type;
  604. int txpower; /* if txpower_type == PRISM2_TXPOWER_FIXED */
  605. /* command queue for hfa384x_cmd(); protected with cmdlock */
  606. struct list_head cmd_queue;
  607. /* max_len for cmd_queue; in addition, cmd_callback can use two
  608. * additional entries to prevent sleeping commands from stopping
  609. * transmits */
  610. #define HOSTAP_CMD_QUEUE_MAX_LEN 16
  611. int cmd_queue_len; /* number of entries in cmd_queue */
  612. /* if card timeout is detected in interrupt context, reset_queue is
  613. * used to schedule card reseting to be done in user context */
  614. struct work_struct reset_queue;
  615. /* For scheduling a change of the promiscuous mode RID */
  616. int is_promisc;
  617. struct work_struct set_multicast_list_queue;
  618. struct work_struct set_tim_queue;
  619. struct list_head set_tim_list;
  620. spinlock_t set_tim_lock;
  621. int wds_max_connections;
  622. int wds_connections;
  623. #define HOSTAP_WDS_BROADCAST_RA BIT(0)
  624. #define HOSTAP_WDS_AP_CLIENT BIT(1)
  625. #define HOSTAP_WDS_STANDARD_FRAME BIT(2)
  626. u32 wds_type;
  627. u16 tx_control; /* flags to be used in TX description */
  628. int manual_retry_count; /* -1 = use f/w default; otherwise retry count
  629. * to be used with all frames */
  630. struct iw_statistics wstats;
  631. unsigned long scan_timestamp; /* Time started to scan */
  632. enum {
  633. PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
  634. PRISM2_MONITOR_CAPHDR = 2
  635. } monitor_type;
  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 */