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