18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef HOSTAP_WLAN_H 38c2ecf20Sopenharmony_ci#define HOSTAP_WLAN_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 68c2ecf20Sopenharmony_ci#include <linux/wireless.h> 78c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 88c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 98c2ecf20Sopenharmony_ci#include <linux/mutex.h> 108c2ecf20Sopenharmony_ci#include <linux/refcount.h> 118c2ecf20Sopenharmony_ci#include <net/iw_handler.h> 128c2ecf20Sopenharmony_ci#include <net/ieee80211_radiotap.h> 138c2ecf20Sopenharmony_ci#include <net/lib80211.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "hostap_config.h" 168c2ecf20Sopenharmony_ci#include "hostap_common.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define MAX_PARM_DEVICES 8 198c2ecf20Sopenharmony_ci#define PARM_MIN_MAX "1-" __MODULE_STRING(MAX_PARM_DEVICES) 208c2ecf20Sopenharmony_ci#define DEF_INTS -1, -1, -1, -1, -1, -1, -1 218c2ecf20Sopenharmony_ci#define GET_INT_PARM(var,idx) var[var[idx] < 0 ? 0 : idx] 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* Specific skb->protocol value that indicates that the packet already contains 258c2ecf20Sopenharmony_ci * txdesc header. 268c2ecf20Sopenharmony_ci * FIX: This might need own value that would be allocated especially for Prism2 278c2ecf20Sopenharmony_ci * txdesc; ETH_P_CONTROL is commented as "Card specific control frames". 288c2ecf20Sopenharmony_ci * However, these skb's should have only minimal path in the kernel side since 298c2ecf20Sopenharmony_ci * prism2_send_mgmt() sends these with dev_queue_xmit() to prism2_tx(). */ 308c2ecf20Sopenharmony_ci#define ETH_P_HOSTAP ETH_P_CONTROL 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header 338c2ecf20Sopenharmony_ci * (from linux-wlan-ng) */ 348c2ecf20Sopenharmony_cistruct linux_wlan_ng_val { 358c2ecf20Sopenharmony_ci u32 did; 368c2ecf20Sopenharmony_ci u16 status, len; 378c2ecf20Sopenharmony_ci u32 data; 388c2ecf20Sopenharmony_ci} __packed; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct linux_wlan_ng_prism_hdr { 418c2ecf20Sopenharmony_ci u32 msgcode, msglen; 428c2ecf20Sopenharmony_ci char devname[16]; 438c2ecf20Sopenharmony_ci struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal, 448c2ecf20Sopenharmony_ci noise, rate, istx, frmlen; 458c2ecf20Sopenharmony_ci} __packed; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistruct linux_wlan_ng_cap_hdr { 488c2ecf20Sopenharmony_ci __be32 version; 498c2ecf20Sopenharmony_ci __be32 length; 508c2ecf20Sopenharmony_ci __be64 mactime; 518c2ecf20Sopenharmony_ci __be64 hosttime; 528c2ecf20Sopenharmony_ci __be32 phytype; 538c2ecf20Sopenharmony_ci __be32 channel; 548c2ecf20Sopenharmony_ci __be32 datarate; 558c2ecf20Sopenharmony_ci __be32 antenna; 568c2ecf20Sopenharmony_ci __be32 priority; 578c2ecf20Sopenharmony_ci __be32 ssi_type; 588c2ecf20Sopenharmony_ci __be32 ssi_signal; 598c2ecf20Sopenharmony_ci __be32 ssi_noise; 608c2ecf20Sopenharmony_ci __be32 preamble; 618c2ecf20Sopenharmony_ci __be32 encoding; 628c2ecf20Sopenharmony_ci} __packed; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct hostap_radiotap_rx { 658c2ecf20Sopenharmony_ci struct ieee80211_radiotap_header hdr; 668c2ecf20Sopenharmony_ci __le64 tsft; 678c2ecf20Sopenharmony_ci u8 rate; 688c2ecf20Sopenharmony_ci u8 padding; 698c2ecf20Sopenharmony_ci __le16 chan_freq; 708c2ecf20Sopenharmony_ci __le16 chan_flags; 718c2ecf20Sopenharmony_ci s8 dbm_antsignal; 728c2ecf20Sopenharmony_ci s8 dbm_antnoise; 738c2ecf20Sopenharmony_ci} __packed; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */ 768c2ecf20Sopenharmony_ci#define LWNG_CAPHDR_VERSION 0x80211001 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct hfa384x_rx_frame { 798c2ecf20Sopenharmony_ci /* HFA384X RX frame descriptor */ 808c2ecf20Sopenharmony_ci __le16 status; /* HFA384X_RX_STATUS_ flags */ 818c2ecf20Sopenharmony_ci __le32 time; /* timestamp, 1 microsecond resolution */ 828c2ecf20Sopenharmony_ci u8 silence; /* 27 .. 154; seems to be 0 */ 838c2ecf20Sopenharmony_ci u8 signal; /* 27 .. 154 */ 848c2ecf20Sopenharmony_ci u8 rate; /* 10, 20, 55, or 110 */ 858c2ecf20Sopenharmony_ci u8 rxflow; 868c2ecf20Sopenharmony_ci __le32 reserved; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci /* 802.11 */ 898c2ecf20Sopenharmony_ci __le16 frame_control; 908c2ecf20Sopenharmony_ci __le16 duration_id; 918c2ecf20Sopenharmony_ci u8 addr1[ETH_ALEN]; 928c2ecf20Sopenharmony_ci u8 addr2[ETH_ALEN]; 938c2ecf20Sopenharmony_ci u8 addr3[ETH_ALEN]; 948c2ecf20Sopenharmony_ci __le16 seq_ctrl; 958c2ecf20Sopenharmony_ci u8 addr4[ETH_ALEN]; 968c2ecf20Sopenharmony_ci __le16 data_len; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci /* 802.3 */ 998c2ecf20Sopenharmony_ci u8 dst_addr[ETH_ALEN]; 1008c2ecf20Sopenharmony_ci u8 src_addr[ETH_ALEN]; 1018c2ecf20Sopenharmony_ci __be16 len; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci /* followed by frame data; max 2304 bytes */ 1048c2ecf20Sopenharmony_ci} __packed; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistruct hfa384x_tx_frame { 1088c2ecf20Sopenharmony_ci /* HFA384X TX frame descriptor */ 1098c2ecf20Sopenharmony_ci __le16 status; /* HFA384X_TX_STATUS_ flags */ 1108c2ecf20Sopenharmony_ci __le16 reserved1; 1118c2ecf20Sopenharmony_ci __le16 reserved2; 1128c2ecf20Sopenharmony_ci __le32 sw_support; 1138c2ecf20Sopenharmony_ci u8 retry_count; /* not yet implemented */ 1148c2ecf20Sopenharmony_ci u8 tx_rate; /* Host AP only; 0 = firmware, or 10, 20, 55, 110 */ 1158c2ecf20Sopenharmony_ci __le16 tx_control; /* HFA384X_TX_CTRL_ flags */ 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci /* 802.11 */ 1188c2ecf20Sopenharmony_ci __le16 frame_control; /* parts not used */ 1198c2ecf20Sopenharmony_ci __le16 duration_id; 1208c2ecf20Sopenharmony_ci u8 addr1[ETH_ALEN]; 1218c2ecf20Sopenharmony_ci u8 addr2[ETH_ALEN]; /* filled by firmware */ 1228c2ecf20Sopenharmony_ci u8 addr3[ETH_ALEN]; 1238c2ecf20Sopenharmony_ci __le16 seq_ctrl; /* filled by firmware */ 1248c2ecf20Sopenharmony_ci u8 addr4[ETH_ALEN]; 1258c2ecf20Sopenharmony_ci __le16 data_len; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci /* 802.3 */ 1288c2ecf20Sopenharmony_ci u8 dst_addr[ETH_ALEN]; 1298c2ecf20Sopenharmony_ci u8 src_addr[ETH_ALEN]; 1308c2ecf20Sopenharmony_ci __be16 len; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci /* followed by frame data; max 2304 bytes */ 1338c2ecf20Sopenharmony_ci} __packed; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cistruct hfa384x_rid_hdr 1378c2ecf20Sopenharmony_ci{ 1388c2ecf20Sopenharmony_ci __le16 len; 1398c2ecf20Sopenharmony_ci __le16 rid; 1408c2ecf20Sopenharmony_ci} __packed; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* Macro for converting signal levels (range 27 .. 154) to wireless ext 1448c2ecf20Sopenharmony_ci * dBm value with some accuracy */ 1458c2ecf20Sopenharmony_ci#define HFA384X_LEVEL_TO_dBm(v) 0x100 + (v) * 100 / 255 - 100 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#define HFA384X_LEVEL_TO_dBm_sign(v) (v) * 100 / 255 - 100 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistruct hfa384x_scan_request { 1508c2ecf20Sopenharmony_ci __le16 channel_list; 1518c2ecf20Sopenharmony_ci __le16 txrate; /* HFA384X_RATES_* */ 1528c2ecf20Sopenharmony_ci} __packed; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistruct hfa384x_hostscan_request { 1558c2ecf20Sopenharmony_ci __le16 channel_list; 1568c2ecf20Sopenharmony_ci __le16 txrate; 1578c2ecf20Sopenharmony_ci __le16 target_ssid_len; 1588c2ecf20Sopenharmony_ci u8 target_ssid[32]; 1598c2ecf20Sopenharmony_ci} __packed; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistruct hfa384x_join_request { 1628c2ecf20Sopenharmony_ci u8 bssid[ETH_ALEN]; 1638c2ecf20Sopenharmony_ci __le16 channel; 1648c2ecf20Sopenharmony_ci} __packed; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistruct hfa384x_info_frame { 1678c2ecf20Sopenharmony_ci __le16 len; 1688c2ecf20Sopenharmony_ci __le16 type; 1698c2ecf20Sopenharmony_ci} __packed; 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistruct hfa384x_comm_tallies { 1728c2ecf20Sopenharmony_ci __le16 tx_unicast_frames; 1738c2ecf20Sopenharmony_ci __le16 tx_multicast_frames; 1748c2ecf20Sopenharmony_ci __le16 tx_fragments; 1758c2ecf20Sopenharmony_ci __le16 tx_unicast_octets; 1768c2ecf20Sopenharmony_ci __le16 tx_multicast_octets; 1778c2ecf20Sopenharmony_ci __le16 tx_deferred_transmissions; 1788c2ecf20Sopenharmony_ci __le16 tx_single_retry_frames; 1798c2ecf20Sopenharmony_ci __le16 tx_multiple_retry_frames; 1808c2ecf20Sopenharmony_ci __le16 tx_retry_limit_exceeded; 1818c2ecf20Sopenharmony_ci __le16 tx_discards; 1828c2ecf20Sopenharmony_ci __le16 rx_unicast_frames; 1838c2ecf20Sopenharmony_ci __le16 rx_multicast_frames; 1848c2ecf20Sopenharmony_ci __le16 rx_fragments; 1858c2ecf20Sopenharmony_ci __le16 rx_unicast_octets; 1868c2ecf20Sopenharmony_ci __le16 rx_multicast_octets; 1878c2ecf20Sopenharmony_ci __le16 rx_fcs_errors; 1888c2ecf20Sopenharmony_ci __le16 rx_discards_no_buffer; 1898c2ecf20Sopenharmony_ci __le16 tx_discards_wrong_sa; 1908c2ecf20Sopenharmony_ci __le16 rx_discards_wep_undecryptable; 1918c2ecf20Sopenharmony_ci __le16 rx_message_in_msg_fragments; 1928c2ecf20Sopenharmony_ci __le16 rx_message_in_bad_msg_fragments; 1938c2ecf20Sopenharmony_ci} __packed; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cistruct hfa384x_comm_tallies32 { 1968c2ecf20Sopenharmony_ci __le32 tx_unicast_frames; 1978c2ecf20Sopenharmony_ci __le32 tx_multicast_frames; 1988c2ecf20Sopenharmony_ci __le32 tx_fragments; 1998c2ecf20Sopenharmony_ci __le32 tx_unicast_octets; 2008c2ecf20Sopenharmony_ci __le32 tx_multicast_octets; 2018c2ecf20Sopenharmony_ci __le32 tx_deferred_transmissions; 2028c2ecf20Sopenharmony_ci __le32 tx_single_retry_frames; 2038c2ecf20Sopenharmony_ci __le32 tx_multiple_retry_frames; 2048c2ecf20Sopenharmony_ci __le32 tx_retry_limit_exceeded; 2058c2ecf20Sopenharmony_ci __le32 tx_discards; 2068c2ecf20Sopenharmony_ci __le32 rx_unicast_frames; 2078c2ecf20Sopenharmony_ci __le32 rx_multicast_frames; 2088c2ecf20Sopenharmony_ci __le32 rx_fragments; 2098c2ecf20Sopenharmony_ci __le32 rx_unicast_octets; 2108c2ecf20Sopenharmony_ci __le32 rx_multicast_octets; 2118c2ecf20Sopenharmony_ci __le32 rx_fcs_errors; 2128c2ecf20Sopenharmony_ci __le32 rx_discards_no_buffer; 2138c2ecf20Sopenharmony_ci __le32 tx_discards_wrong_sa; 2148c2ecf20Sopenharmony_ci __le32 rx_discards_wep_undecryptable; 2158c2ecf20Sopenharmony_ci __le32 rx_message_in_msg_fragments; 2168c2ecf20Sopenharmony_ci __le32 rx_message_in_bad_msg_fragments; 2178c2ecf20Sopenharmony_ci} __packed; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_cistruct hfa384x_scan_result_hdr { 2208c2ecf20Sopenharmony_ci __le16 reserved; 2218c2ecf20Sopenharmony_ci __le16 scan_reason; 2228c2ecf20Sopenharmony_ci#define HFA384X_SCAN_IN_PROGRESS 0 /* no results available yet */ 2238c2ecf20Sopenharmony_ci#define HFA384X_SCAN_HOST_INITIATED 1 2248c2ecf20Sopenharmony_ci#define HFA384X_SCAN_FIRMWARE_INITIATED 2 2258c2ecf20Sopenharmony_ci#define HFA384X_SCAN_INQUIRY_FROM_HOST 3 2268c2ecf20Sopenharmony_ci} __packed; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci#define HFA384X_SCAN_MAX_RESULTS 32 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_cistruct hfa384x_scan_result { 2318c2ecf20Sopenharmony_ci __le16 chid; 2328c2ecf20Sopenharmony_ci __le16 anl; 2338c2ecf20Sopenharmony_ci __le16 sl; 2348c2ecf20Sopenharmony_ci u8 bssid[ETH_ALEN]; 2358c2ecf20Sopenharmony_ci __le16 beacon_interval; 2368c2ecf20Sopenharmony_ci __le16 capability; 2378c2ecf20Sopenharmony_ci __le16 ssid_len; 2388c2ecf20Sopenharmony_ci u8 ssid[32]; 2398c2ecf20Sopenharmony_ci u8 sup_rates[10]; 2408c2ecf20Sopenharmony_ci __le16 rate; 2418c2ecf20Sopenharmony_ci} __packed; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_cistruct hfa384x_hostscan_result { 2448c2ecf20Sopenharmony_ci __le16 chid; 2458c2ecf20Sopenharmony_ci __le16 anl; 2468c2ecf20Sopenharmony_ci __le16 sl; 2478c2ecf20Sopenharmony_ci u8 bssid[ETH_ALEN]; 2488c2ecf20Sopenharmony_ci __le16 beacon_interval; 2498c2ecf20Sopenharmony_ci __le16 capability; 2508c2ecf20Sopenharmony_ci __le16 ssid_len; 2518c2ecf20Sopenharmony_ci u8 ssid[32]; 2528c2ecf20Sopenharmony_ci u8 sup_rates[10]; 2538c2ecf20Sopenharmony_ci __le16 rate; 2548c2ecf20Sopenharmony_ci __le16 atim; 2558c2ecf20Sopenharmony_ci} __packed; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_cistruct comm_tallies_sums { 2588c2ecf20Sopenharmony_ci unsigned int tx_unicast_frames; 2598c2ecf20Sopenharmony_ci unsigned int tx_multicast_frames; 2608c2ecf20Sopenharmony_ci unsigned int tx_fragments; 2618c2ecf20Sopenharmony_ci unsigned int tx_unicast_octets; 2628c2ecf20Sopenharmony_ci unsigned int tx_multicast_octets; 2638c2ecf20Sopenharmony_ci unsigned int tx_deferred_transmissions; 2648c2ecf20Sopenharmony_ci unsigned int tx_single_retry_frames; 2658c2ecf20Sopenharmony_ci unsigned int tx_multiple_retry_frames; 2668c2ecf20Sopenharmony_ci unsigned int tx_retry_limit_exceeded; 2678c2ecf20Sopenharmony_ci unsigned int tx_discards; 2688c2ecf20Sopenharmony_ci unsigned int rx_unicast_frames; 2698c2ecf20Sopenharmony_ci unsigned int rx_multicast_frames; 2708c2ecf20Sopenharmony_ci unsigned int rx_fragments; 2718c2ecf20Sopenharmony_ci unsigned int rx_unicast_octets; 2728c2ecf20Sopenharmony_ci unsigned int rx_multicast_octets; 2738c2ecf20Sopenharmony_ci unsigned int rx_fcs_errors; 2748c2ecf20Sopenharmony_ci unsigned int rx_discards_no_buffer; 2758c2ecf20Sopenharmony_ci unsigned int tx_discards_wrong_sa; 2768c2ecf20Sopenharmony_ci unsigned int rx_discards_wep_undecryptable; 2778c2ecf20Sopenharmony_ci unsigned int rx_message_in_msg_fragments; 2788c2ecf20Sopenharmony_ci unsigned int rx_message_in_bad_msg_fragments; 2798c2ecf20Sopenharmony_ci}; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cistruct hfa384x_regs { 2838c2ecf20Sopenharmony_ci u16 cmd; 2848c2ecf20Sopenharmony_ci u16 evstat; 2858c2ecf20Sopenharmony_ci u16 offset0; 2868c2ecf20Sopenharmony_ci u16 offset1; 2878c2ecf20Sopenharmony_ci u16 swsupport0; 2888c2ecf20Sopenharmony_ci}; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci#if defined(PRISM2_PCCARD) || defined(PRISM2_PLX) 2928c2ecf20Sopenharmony_ci/* I/O ports for HFA384X Controller access */ 2938c2ecf20Sopenharmony_ci#define HFA384X_CMD_OFF 0x00 2948c2ecf20Sopenharmony_ci#define HFA384X_PARAM0_OFF 0x02 2958c2ecf20Sopenharmony_ci#define HFA384X_PARAM1_OFF 0x04 2968c2ecf20Sopenharmony_ci#define HFA384X_PARAM2_OFF 0x06 2978c2ecf20Sopenharmony_ci#define HFA384X_STATUS_OFF 0x08 2988c2ecf20Sopenharmony_ci#define HFA384X_RESP0_OFF 0x0A 2998c2ecf20Sopenharmony_ci#define HFA384X_RESP1_OFF 0x0C 3008c2ecf20Sopenharmony_ci#define HFA384X_RESP2_OFF 0x0E 3018c2ecf20Sopenharmony_ci#define HFA384X_INFOFID_OFF 0x10 3028c2ecf20Sopenharmony_ci#define HFA384X_CONTROL_OFF 0x14 3038c2ecf20Sopenharmony_ci#define HFA384X_SELECT0_OFF 0x18 3048c2ecf20Sopenharmony_ci#define HFA384X_SELECT1_OFF 0x1A 3058c2ecf20Sopenharmony_ci#define HFA384X_OFFSET0_OFF 0x1C 3068c2ecf20Sopenharmony_ci#define HFA384X_OFFSET1_OFF 0x1E 3078c2ecf20Sopenharmony_ci#define HFA384X_RXFID_OFF 0x20 3088c2ecf20Sopenharmony_ci#define HFA384X_ALLOCFID_OFF 0x22 3098c2ecf20Sopenharmony_ci#define HFA384X_TXCOMPLFID_OFF 0x24 3108c2ecf20Sopenharmony_ci#define HFA384X_SWSUPPORT0_OFF 0x28 3118c2ecf20Sopenharmony_ci#define HFA384X_SWSUPPORT1_OFF 0x2A 3128c2ecf20Sopenharmony_ci#define HFA384X_SWSUPPORT2_OFF 0x2C 3138c2ecf20Sopenharmony_ci#define HFA384X_EVSTAT_OFF 0x30 3148c2ecf20Sopenharmony_ci#define HFA384X_INTEN_OFF 0x32 3158c2ecf20Sopenharmony_ci#define HFA384X_EVACK_OFF 0x34 3168c2ecf20Sopenharmony_ci#define HFA384X_DATA0_OFF 0x36 3178c2ecf20Sopenharmony_ci#define HFA384X_DATA1_OFF 0x38 3188c2ecf20Sopenharmony_ci#define HFA384X_AUXPAGE_OFF 0x3A 3198c2ecf20Sopenharmony_ci#define HFA384X_AUXOFFSET_OFF 0x3C 3208c2ecf20Sopenharmony_ci#define HFA384X_AUXDATA_OFF 0x3E 3218c2ecf20Sopenharmony_ci#endif /* PRISM2_PCCARD || PRISM2_PLX */ 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci#ifdef PRISM2_PCI 3248c2ecf20Sopenharmony_ci/* Memory addresses for ISL3874 controller access */ 3258c2ecf20Sopenharmony_ci#define HFA384X_CMD_OFF 0x00 3268c2ecf20Sopenharmony_ci#define HFA384X_PARAM0_OFF 0x04 3278c2ecf20Sopenharmony_ci#define HFA384X_PARAM1_OFF 0x08 3288c2ecf20Sopenharmony_ci#define HFA384X_PARAM2_OFF 0x0C 3298c2ecf20Sopenharmony_ci#define HFA384X_STATUS_OFF 0x10 3308c2ecf20Sopenharmony_ci#define HFA384X_RESP0_OFF 0x14 3318c2ecf20Sopenharmony_ci#define HFA384X_RESP1_OFF 0x18 3328c2ecf20Sopenharmony_ci#define HFA384X_RESP2_OFF 0x1C 3338c2ecf20Sopenharmony_ci#define HFA384X_INFOFID_OFF 0x20 3348c2ecf20Sopenharmony_ci#define HFA384X_CONTROL_OFF 0x28 3358c2ecf20Sopenharmony_ci#define HFA384X_SELECT0_OFF 0x30 3368c2ecf20Sopenharmony_ci#define HFA384X_SELECT1_OFF 0x34 3378c2ecf20Sopenharmony_ci#define HFA384X_OFFSET0_OFF 0x38 3388c2ecf20Sopenharmony_ci#define HFA384X_OFFSET1_OFF 0x3C 3398c2ecf20Sopenharmony_ci#define HFA384X_RXFID_OFF 0x40 3408c2ecf20Sopenharmony_ci#define HFA384X_ALLOCFID_OFF 0x44 3418c2ecf20Sopenharmony_ci#define HFA384X_TXCOMPLFID_OFF 0x48 3428c2ecf20Sopenharmony_ci#define HFA384X_PCICOR_OFF 0x4C 3438c2ecf20Sopenharmony_ci#define HFA384X_SWSUPPORT0_OFF 0x50 3448c2ecf20Sopenharmony_ci#define HFA384X_SWSUPPORT1_OFF 0x54 3458c2ecf20Sopenharmony_ci#define HFA384X_SWSUPPORT2_OFF 0x58 3468c2ecf20Sopenharmony_ci#define HFA384X_PCIHCR_OFF 0x5C 3478c2ecf20Sopenharmony_ci#define HFA384X_EVSTAT_OFF 0x60 3488c2ecf20Sopenharmony_ci#define HFA384X_INTEN_OFF 0x64 3498c2ecf20Sopenharmony_ci#define HFA384X_EVACK_OFF 0x68 3508c2ecf20Sopenharmony_ci#define HFA384X_DATA0_OFF 0x6C 3518c2ecf20Sopenharmony_ci#define HFA384X_DATA1_OFF 0x70 3528c2ecf20Sopenharmony_ci#define HFA384X_AUXPAGE_OFF 0x74 3538c2ecf20Sopenharmony_ci#define HFA384X_AUXOFFSET_OFF 0x78 3548c2ecf20Sopenharmony_ci#define HFA384X_AUXDATA_OFF 0x7C 3558c2ecf20Sopenharmony_ci#define HFA384X_PCI_M0_ADDRH_OFF 0x80 3568c2ecf20Sopenharmony_ci#define HFA384X_PCI_M0_ADDRL_OFF 0x84 3578c2ecf20Sopenharmony_ci#define HFA384X_PCI_M0_LEN_OFF 0x88 3588c2ecf20Sopenharmony_ci#define HFA384X_PCI_M0_CTL_OFF 0x8C 3598c2ecf20Sopenharmony_ci#define HFA384X_PCI_STATUS_OFF 0x98 3608c2ecf20Sopenharmony_ci#define HFA384X_PCI_M1_ADDRH_OFF 0xA0 3618c2ecf20Sopenharmony_ci#define HFA384X_PCI_M1_ADDRL_OFF 0xA4 3628c2ecf20Sopenharmony_ci#define HFA384X_PCI_M1_LEN_OFF 0xA8 3638c2ecf20Sopenharmony_ci#define HFA384X_PCI_M1_CTL_OFF 0xAC 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci/* PCI bus master control bits (these are undocumented; based on guessing and 3668c2ecf20Sopenharmony_ci * experimenting..) */ 3678c2ecf20Sopenharmony_ci#define HFA384X_PCI_CTL_FROM_BAP (BIT(5) | BIT(1) | BIT(0)) 3688c2ecf20Sopenharmony_ci#define HFA384X_PCI_CTL_TO_BAP (BIT(5) | BIT(0)) 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci#endif /* PRISM2_PCI */ 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci/* Command codes for CMD reg. */ 3748c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_INIT 0x00 3758c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_ENABLE 0x01 3768c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_DISABLE 0x02 3778c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_ALLOC 0x0A 3788c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_TRANSMIT 0x0B 3798c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_INQUIRE 0x11 3808c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_ACCESS 0x21 3818c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_ACCESS_WRITE (0x21 | BIT(8)) 3828c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_DOWNLOAD 0x22 3838c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_READMIF 0x30 3848c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_WRITEMIF 0x31 3858c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_TEST 0x38 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci#define HFA384X_CMDCODE_MASK 0x3F 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci/* Test mode operations */ 3908c2ecf20Sopenharmony_ci#define HFA384X_TEST_CHANGE_CHANNEL 0x08 3918c2ecf20Sopenharmony_ci#define HFA384X_TEST_MONITOR 0x0B 3928c2ecf20Sopenharmony_ci#define HFA384X_TEST_STOP 0x0F 3938c2ecf20Sopenharmony_ci#define HFA384X_TEST_CFG_BITS 0x15 3948c2ecf20Sopenharmony_ci#define HFA384X_TEST_CFG_BIT_ALC BIT(3) 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci#define HFA384X_CMD_BUSY BIT(15) 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci#define HFA384X_CMD_TX_RECLAIM BIT(8) 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci#define HFA384X_OFFSET_ERR BIT(14) 4018c2ecf20Sopenharmony_ci#define HFA384X_OFFSET_BUSY BIT(15) 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci/* ProgMode for download command */ 4058c2ecf20Sopenharmony_ci#define HFA384X_PROGMODE_DISABLE 0 4068c2ecf20Sopenharmony_ci#define HFA384X_PROGMODE_ENABLE_VOLATILE 1 4078c2ecf20Sopenharmony_ci#define HFA384X_PROGMODE_ENABLE_NON_VOLATILE 2 4088c2ecf20Sopenharmony_ci#define HFA384X_PROGMODE_PROGRAM_NON_VOLATILE 3 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci#define HFA384X_AUX_MAGIC0 0xfe01 4118c2ecf20Sopenharmony_ci#define HFA384X_AUX_MAGIC1 0xdc23 4128c2ecf20Sopenharmony_ci#define HFA384X_AUX_MAGIC2 0xba45 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci#define HFA384X_AUX_PORT_DISABLED 0 4158c2ecf20Sopenharmony_ci#define HFA384X_AUX_PORT_DISABLE BIT(14) 4168c2ecf20Sopenharmony_ci#define HFA384X_AUX_PORT_ENABLE BIT(15) 4178c2ecf20Sopenharmony_ci#define HFA384X_AUX_PORT_ENABLED (BIT(14) | BIT(15)) 4188c2ecf20Sopenharmony_ci#define HFA384X_AUX_PORT_MASK (BIT(14) | BIT(15)) 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci#define PRISM2_PDA_SIZE 1024 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci/* Events; EvStat, Interrupt mask (IntEn), and acknowledge bits (EvAck) */ 4248c2ecf20Sopenharmony_ci#define HFA384X_EV_TICK BIT(15) 4258c2ecf20Sopenharmony_ci#define HFA384X_EV_WTERR BIT(14) 4268c2ecf20Sopenharmony_ci#define HFA384X_EV_INFDROP BIT(13) 4278c2ecf20Sopenharmony_ci#ifdef PRISM2_PCI 4288c2ecf20Sopenharmony_ci#define HFA384X_EV_PCI_M1 BIT(9) 4298c2ecf20Sopenharmony_ci#define HFA384X_EV_PCI_M0 BIT(8) 4308c2ecf20Sopenharmony_ci#endif /* PRISM2_PCI */ 4318c2ecf20Sopenharmony_ci#define HFA384X_EV_INFO BIT(7) 4328c2ecf20Sopenharmony_ci#define HFA384X_EV_DTIM BIT(5) 4338c2ecf20Sopenharmony_ci#define HFA384X_EV_CMD BIT(4) 4348c2ecf20Sopenharmony_ci#define HFA384X_EV_ALLOC BIT(3) 4358c2ecf20Sopenharmony_ci#define HFA384X_EV_TXEXC BIT(2) 4368c2ecf20Sopenharmony_ci#define HFA384X_EV_TX BIT(1) 4378c2ecf20Sopenharmony_ci#define HFA384X_EV_RX BIT(0) 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci/* HFA384X Information frames */ 4418c2ecf20Sopenharmony_ci#define HFA384X_INFO_HANDOVERADDR 0xF000 /* AP f/w ? */ 4428c2ecf20Sopenharmony_ci#define HFA384X_INFO_HANDOVERDEAUTHADDR 0xF001 /* AP f/w 1.3.7 */ 4438c2ecf20Sopenharmony_ci#define HFA384X_INFO_COMMTALLIES 0xF100 4448c2ecf20Sopenharmony_ci#define HFA384X_INFO_SCANRESULTS 0xF101 4458c2ecf20Sopenharmony_ci#define HFA384X_INFO_CHANNELINFORESULTS 0xF102 /* AP f/w only */ 4468c2ecf20Sopenharmony_ci#define HFA384X_INFO_HOSTSCANRESULTS 0xF103 4478c2ecf20Sopenharmony_ci#define HFA384X_INFO_LINKSTATUS 0xF200 4488c2ecf20Sopenharmony_ci#define HFA384X_INFO_ASSOCSTATUS 0xF201 /* ? */ 4498c2ecf20Sopenharmony_ci#define HFA384X_INFO_AUTHREQ 0xF202 /* ? */ 4508c2ecf20Sopenharmony_ci#define HFA384X_INFO_PSUSERCNT 0xF203 /* ? */ 4518c2ecf20Sopenharmony_ci#define HFA384X_INFO_KEYIDCHANGED 0xF204 /* ? */ 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_cienum { HFA384X_LINKSTATUS_CONNECTED = 1, 4548c2ecf20Sopenharmony_ci HFA384X_LINKSTATUS_DISCONNECTED = 2, 4558c2ecf20Sopenharmony_ci HFA384X_LINKSTATUS_AP_CHANGE = 3, 4568c2ecf20Sopenharmony_ci HFA384X_LINKSTATUS_AP_OUT_OF_RANGE = 4, 4578c2ecf20Sopenharmony_ci HFA384X_LINKSTATUS_AP_IN_RANGE = 5, 4588c2ecf20Sopenharmony_ci HFA384X_LINKSTATUS_ASSOC_FAILED = 6 }; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_cienum { HFA384X_PORTTYPE_BSS = 1, HFA384X_PORTTYPE_WDS = 2, 4618c2ecf20Sopenharmony_ci HFA384X_PORTTYPE_PSEUDO_IBSS = 3, HFA384X_PORTTYPE_IBSS = 0, 4628c2ecf20Sopenharmony_ci HFA384X_PORTTYPE_HOSTAP = 6 }; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci#define HFA384X_RATES_1MBPS BIT(0) 4658c2ecf20Sopenharmony_ci#define HFA384X_RATES_2MBPS BIT(1) 4668c2ecf20Sopenharmony_ci#define HFA384X_RATES_5MBPS BIT(2) 4678c2ecf20Sopenharmony_ci#define HFA384X_RATES_11MBPS BIT(3) 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci#define HFA384X_ROAMING_FIRMWARE 1 4708c2ecf20Sopenharmony_ci#define HFA384X_ROAMING_HOST 2 4718c2ecf20Sopenharmony_ci#define HFA384X_ROAMING_DISABLED 3 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci#define HFA384X_WEPFLAGS_PRIVACYINVOKED BIT(0) 4748c2ecf20Sopenharmony_ci#define HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED BIT(1) 4758c2ecf20Sopenharmony_ci#define HFA384X_WEPFLAGS_HOSTENCRYPT BIT(4) 4768c2ecf20Sopenharmony_ci#define HFA384X_WEPFLAGS_HOSTDECRYPT BIT(7) 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_MSGTYPE (BIT(15) | BIT(14) | BIT(13)) 4798c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_PCF BIT(12) 4808c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_MACPORT (BIT(10) | BIT(9) | BIT(8)) 4818c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_UNDECR BIT(1) 4828c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_FCSERR BIT(0) 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_GET_MSGTYPE(s) \ 4858c2ecf20Sopenharmony_ci(((s) & HFA384X_RX_STATUS_MSGTYPE) >> 13) 4868c2ecf20Sopenharmony_ci#define HFA384X_RX_STATUS_GET_MACPORT(s) \ 4878c2ecf20Sopenharmony_ci(((s) & HFA384X_RX_STATUS_MACPORT) >> 8) 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_cienum { HFA384X_RX_MSGTYPE_NORMAL = 0, HFA384X_RX_MSGTYPE_RFC1042 = 1, 4908c2ecf20Sopenharmony_ci HFA384X_RX_MSGTYPE_BRIDGETUNNEL = 2, HFA384X_RX_MSGTYPE_MGMT = 4 }; 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci#define HFA384X_TX_CTRL_ALT_RTRY BIT(5) 4948c2ecf20Sopenharmony_ci#define HFA384X_TX_CTRL_802_11 BIT(3) 4958c2ecf20Sopenharmony_ci#define HFA384X_TX_CTRL_802_3 0 4968c2ecf20Sopenharmony_ci#define HFA384X_TX_CTRL_TX_EX BIT(2) 4978c2ecf20Sopenharmony_ci#define HFA384X_TX_CTRL_TX_OK BIT(1) 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci#define HFA384X_TX_STATUS_RETRYERR BIT(0) 5008c2ecf20Sopenharmony_ci#define HFA384X_TX_STATUS_AGEDERR BIT(1) 5018c2ecf20Sopenharmony_ci#define HFA384X_TX_STATUS_DISCON BIT(2) 5028c2ecf20Sopenharmony_ci#define HFA384X_TX_STATUS_FORMERR BIT(3) 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci/* HFA3861/3863 (BBP) Control Registers */ 5058c2ecf20Sopenharmony_ci#define HFA386X_CR_TX_CONFIGURE 0x12 /* CR9 */ 5068c2ecf20Sopenharmony_ci#define HFA386X_CR_RX_CONFIGURE 0x14 /* CR10 */ 5078c2ecf20Sopenharmony_ci#define HFA386X_CR_A_D_TEST_MODES2 0x1A /* CR13 */ 5088c2ecf20Sopenharmony_ci#define HFA386X_CR_MANUAL_TX_POWER 0x3E /* CR31 */ 5098c2ecf20Sopenharmony_ci#define HFA386X_CR_MEASURED_TX_POWER 0x74 /* CR58 */ 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci#define PRISM2_TXFID_COUNT 8 5158c2ecf20Sopenharmony_ci#define PRISM2_DATA_MAXLEN 2304 5168c2ecf20Sopenharmony_ci#define PRISM2_TXFID_LEN (PRISM2_DATA_MAXLEN + sizeof(struct hfa384x_tx_frame)) 5178c2ecf20Sopenharmony_ci#define PRISM2_TXFID_EMPTY 0xffff 5188c2ecf20Sopenharmony_ci#define PRISM2_TXFID_RESERVED 0xfffe 5198c2ecf20Sopenharmony_ci#define PRISM2_DUMMY_FID 0xffff 5208c2ecf20Sopenharmony_ci#define MAX_SSID_LEN 32 5218c2ecf20Sopenharmony_ci#define MAX_NAME_LEN 32 /* this is assumed to be equal to MAX_SSID_LEN */ 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci#define PRISM2_DUMP_RX_HDR BIT(0) 5248c2ecf20Sopenharmony_ci#define PRISM2_DUMP_TX_HDR BIT(1) 5258c2ecf20Sopenharmony_ci#define PRISM2_DUMP_TXEXC_HDR BIT(2) 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_cistruct hostap_tx_callback_info { 5288c2ecf20Sopenharmony_ci u16 idx; 5298c2ecf20Sopenharmony_ci void (*func)(struct sk_buff *, int ok, void *); 5308c2ecf20Sopenharmony_ci void *data; 5318c2ecf20Sopenharmony_ci struct hostap_tx_callback_info *next; 5328c2ecf20Sopenharmony_ci}; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci/* IEEE 802.11 requires that STA supports concurrent reception of at least 5368c2ecf20Sopenharmony_ci * three fragmented frames. This define can be increased to support more 5378c2ecf20Sopenharmony_ci * concurrent frames, but it should be noted that each entry can consume about 5388c2ecf20Sopenharmony_ci * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ 5398c2ecf20Sopenharmony_ci#define PRISM2_FRAG_CACHE_LEN 4 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_cistruct prism2_frag_entry { 5428c2ecf20Sopenharmony_ci unsigned long first_frag_time; 5438c2ecf20Sopenharmony_ci unsigned int seq; 5448c2ecf20Sopenharmony_ci unsigned int last_frag; 5458c2ecf20Sopenharmony_ci struct sk_buff *skb; 5468c2ecf20Sopenharmony_ci u8 src_addr[ETH_ALEN]; 5478c2ecf20Sopenharmony_ci u8 dst_addr[ETH_ALEN]; 5488c2ecf20Sopenharmony_ci}; 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_cistruct hostap_cmd_queue { 5528c2ecf20Sopenharmony_ci struct list_head list; 5538c2ecf20Sopenharmony_ci wait_queue_head_t compl; 5548c2ecf20Sopenharmony_ci volatile enum { CMD_SLEEP, CMD_CALLBACK, CMD_COMPLETED } type; 5558c2ecf20Sopenharmony_ci void (*callback)(struct net_device *dev, long context, u16 resp0, 5568c2ecf20Sopenharmony_ci u16 res); 5578c2ecf20Sopenharmony_ci long context; 5588c2ecf20Sopenharmony_ci u16 cmd, param0, param1; 5598c2ecf20Sopenharmony_ci u16 resp0, res; 5608c2ecf20Sopenharmony_ci volatile int issued, issuing; 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci refcount_t usecnt; 5638c2ecf20Sopenharmony_ci int del_req; 5648c2ecf20Sopenharmony_ci}; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci/* options for hw_shutdown */ 5678c2ecf20Sopenharmony_ci#define HOSTAP_HW_NO_DISABLE BIT(0) 5688c2ecf20Sopenharmony_ci#define HOSTAP_HW_ENABLE_CMDCOMPL BIT(1) 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_citypedef struct local_info local_info_t; 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_cistruct prism2_helper_functions { 5738c2ecf20Sopenharmony_ci /* these functions are defined in hardware model specific files 5748c2ecf20Sopenharmony_ci * (hostap_{cs,plx,pci}.c */ 5758c2ecf20Sopenharmony_ci int (*card_present)(local_info_t *local); 5768c2ecf20Sopenharmony_ci void (*cor_sreset)(local_info_t *local); 5778c2ecf20Sopenharmony_ci void (*genesis_reset)(local_info_t *local, int hcr); 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci /* the following functions are from hostap_hw.c, but they may have some 5808c2ecf20Sopenharmony_ci * hardware model specific code */ 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci /* FIX: low-level commands like cmd might disappear at some point to 5838c2ecf20Sopenharmony_ci * make it easier to change them if needed (e.g., cmd would be replaced 5848c2ecf20Sopenharmony_ci * with write_mif/read_mif/testcmd/inquire); at least get_rid and 5858c2ecf20Sopenharmony_ci * set_rid might move to hostap_{cs,plx,pci}.c */ 5868c2ecf20Sopenharmony_ci int (*cmd)(struct net_device *dev, u16 cmd, u16 param0, u16 *param1, 5878c2ecf20Sopenharmony_ci u16 *resp0); 5888c2ecf20Sopenharmony_ci void (*read_regs)(struct net_device *dev, struct hfa384x_regs *regs); 5898c2ecf20Sopenharmony_ci int (*get_rid)(struct net_device *dev, u16 rid, void *buf, int len, 5908c2ecf20Sopenharmony_ci int exact_len); 5918c2ecf20Sopenharmony_ci int (*set_rid)(struct net_device *dev, u16 rid, void *buf, int len); 5928c2ecf20Sopenharmony_ci int (*hw_enable)(struct net_device *dev, int initial); 5938c2ecf20Sopenharmony_ci int (*hw_config)(struct net_device *dev, int initial); 5948c2ecf20Sopenharmony_ci void (*hw_reset)(struct net_device *dev); 5958c2ecf20Sopenharmony_ci void (*hw_shutdown)(struct net_device *dev, int no_disable); 5968c2ecf20Sopenharmony_ci int (*reset_port)(struct net_device *dev); 5978c2ecf20Sopenharmony_ci void (*schedule_reset)(local_info_t *local); 5988c2ecf20Sopenharmony_ci int (*download)(local_info_t *local, 5998c2ecf20Sopenharmony_ci struct prism2_download_param *param); 6008c2ecf20Sopenharmony_ci int (*tx)(struct sk_buff *skb, struct net_device *dev); 6018c2ecf20Sopenharmony_ci int (*set_tim)(struct net_device *dev, int aid, int set); 6028c2ecf20Sopenharmony_ci const struct proc_ops *read_aux_proc_ops; 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_ci int need_tx_headroom; /* number of bytes of headroom needed before 6058c2ecf20Sopenharmony_ci * IEEE 802.11 header */ 6068c2ecf20Sopenharmony_ci enum { HOSTAP_HW_PCCARD, HOSTAP_HW_PLX, HOSTAP_HW_PCI } hw_type; 6078c2ecf20Sopenharmony_ci}; 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_cistruct prism2_download_data { 6118c2ecf20Sopenharmony_ci u32 dl_cmd; 6128c2ecf20Sopenharmony_ci u32 start_addr; 6138c2ecf20Sopenharmony_ci u32 num_areas; 6148c2ecf20Sopenharmony_ci struct prism2_download_data_area { 6158c2ecf20Sopenharmony_ci u32 addr; /* wlan card address */ 6168c2ecf20Sopenharmony_ci u32 len; 6178c2ecf20Sopenharmony_ci u8 *data; /* allocated data */ 6188c2ecf20Sopenharmony_ci } data[]; 6198c2ecf20Sopenharmony_ci}; 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci#define HOSTAP_MAX_BSS_COUNT 64 6238c2ecf20Sopenharmony_ci#define MAX_WPA_IE_LEN 64 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_cistruct hostap_bss_info { 6268c2ecf20Sopenharmony_ci struct list_head list; 6278c2ecf20Sopenharmony_ci unsigned long last_update; 6288c2ecf20Sopenharmony_ci unsigned int count; 6298c2ecf20Sopenharmony_ci u8 bssid[ETH_ALEN]; 6308c2ecf20Sopenharmony_ci u16 capab_info; 6318c2ecf20Sopenharmony_ci u8 ssid[32]; 6328c2ecf20Sopenharmony_ci size_t ssid_len; 6338c2ecf20Sopenharmony_ci u8 wpa_ie[MAX_WPA_IE_LEN]; 6348c2ecf20Sopenharmony_ci size_t wpa_ie_len; 6358c2ecf20Sopenharmony_ci u8 rsn_ie[MAX_WPA_IE_LEN]; 6368c2ecf20Sopenharmony_ci size_t rsn_ie_len; 6378c2ecf20Sopenharmony_ci int chan; 6388c2ecf20Sopenharmony_ci int included; 6398c2ecf20Sopenharmony_ci}; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci/* Per radio private Host AP data - shared by all net devices interfaces used 6438c2ecf20Sopenharmony_ci * by each radio (wlan#, wlan#ap, wlan#sta, WDS). 6448c2ecf20Sopenharmony_ci * ((struct hostap_interface *) netdev_priv(dev))->local points to this 6458c2ecf20Sopenharmony_ci * structure. */ 6468c2ecf20Sopenharmony_cistruct local_info { 6478c2ecf20Sopenharmony_ci struct module *hw_module; 6488c2ecf20Sopenharmony_ci int card_idx; 6498c2ecf20Sopenharmony_ci int dev_enabled; 6508c2ecf20Sopenharmony_ci int master_dev_auto_open; /* was master device opened automatically */ 6518c2ecf20Sopenharmony_ci int num_dev_open; /* number of open devices */ 6528c2ecf20Sopenharmony_ci struct net_device *dev; /* master radio device */ 6538c2ecf20Sopenharmony_ci struct net_device *ddev; /* main data device */ 6548c2ecf20Sopenharmony_ci struct list_head hostap_interfaces; /* Host AP interface list (contains 6558c2ecf20Sopenharmony_ci * struct hostap_interface entries) 6568c2ecf20Sopenharmony_ci */ 6578c2ecf20Sopenharmony_ci rwlock_t iface_lock; /* hostap_interfaces read lock; use write lock 6588c2ecf20Sopenharmony_ci * when removing entries from the list. 6598c2ecf20Sopenharmony_ci * TX and RX paths can use read lock. */ 6608c2ecf20Sopenharmony_ci spinlock_t cmdlock, baplock, lock, irq_init_lock; 6618c2ecf20Sopenharmony_ci struct mutex rid_bap_mtx; 6628c2ecf20Sopenharmony_ci u16 infofid; /* MAC buffer id for info frame */ 6638c2ecf20Sopenharmony_ci /* txfid, intransmitfid, next_txtid, and next_alloc are protected by 6648c2ecf20Sopenharmony_ci * txfidlock */ 6658c2ecf20Sopenharmony_ci spinlock_t txfidlock; 6668c2ecf20Sopenharmony_ci int txfid_len; /* length of allocated TX buffers */ 6678c2ecf20Sopenharmony_ci u16 txfid[PRISM2_TXFID_COUNT]; /* buffer IDs for TX frames */ 6688c2ecf20Sopenharmony_ci /* buffer IDs for intransmit frames or PRISM2_TXFID_EMPTY if 6698c2ecf20Sopenharmony_ci * corresponding txfid is free for next TX frame */ 6708c2ecf20Sopenharmony_ci u16 intransmitfid[PRISM2_TXFID_COUNT]; 6718c2ecf20Sopenharmony_ci int next_txfid; /* index to the next txfid to be checked for 6728c2ecf20Sopenharmony_ci * availability */ 6738c2ecf20Sopenharmony_ci int next_alloc; /* index to the next intransmitfid to be checked for 6748c2ecf20Sopenharmony_ci * allocation events */ 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci /* bitfield for atomic bitops */ 6778c2ecf20Sopenharmony_ci#define HOSTAP_BITS_TRANSMIT 0 6788c2ecf20Sopenharmony_ci#define HOSTAP_BITS_BAP_TASKLET 1 6798c2ecf20Sopenharmony_ci#define HOSTAP_BITS_BAP_TASKLET2 2 6808c2ecf20Sopenharmony_ci unsigned long bits; 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci struct ap_data *ap; 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci char essid[MAX_SSID_LEN + 1]; 6858c2ecf20Sopenharmony_ci char name[MAX_NAME_LEN + 1]; 6868c2ecf20Sopenharmony_ci int name_set; 6878c2ecf20Sopenharmony_ci u16 channel_mask; /* mask of allowed channels */ 6888c2ecf20Sopenharmony_ci u16 scan_channel_mask; /* mask of channels to be scanned */ 6898c2ecf20Sopenharmony_ci struct comm_tallies_sums comm_tallies; 6908c2ecf20Sopenharmony_ci struct proc_dir_entry *proc; 6918c2ecf20Sopenharmony_ci int iw_mode; /* operating mode (IW_MODE_*) */ 6928c2ecf20Sopenharmony_ci int pseudo_adhoc; /* 0: IW_MODE_ADHOC is real 802.11 compliant IBSS 6938c2ecf20Sopenharmony_ci * 1: IW_MODE_ADHOC is "pseudo IBSS" */ 6948c2ecf20Sopenharmony_ci char bssid[ETH_ALEN]; 6958c2ecf20Sopenharmony_ci int channel; 6968c2ecf20Sopenharmony_ci int beacon_int; 6978c2ecf20Sopenharmony_ci int dtim_period; 6988c2ecf20Sopenharmony_ci int mtu; 6998c2ecf20Sopenharmony_ci int frame_dump; /* dump RX/TX frame headers, PRISM2_DUMP_ flags */ 7008c2ecf20Sopenharmony_ci int fw_tx_rate_control; 7018c2ecf20Sopenharmony_ci u16 tx_rate_control; 7028c2ecf20Sopenharmony_ci u16 basic_rates; 7038c2ecf20Sopenharmony_ci int hw_resetting; 7048c2ecf20Sopenharmony_ci int hw_ready; 7058c2ecf20Sopenharmony_ci int hw_reset_tries; /* how many times reset has been tried */ 7068c2ecf20Sopenharmony_ci int hw_downloading; 7078c2ecf20Sopenharmony_ci int shutdown; 7088c2ecf20Sopenharmony_ci int pri_only; 7098c2ecf20Sopenharmony_ci int no_pri; /* no PRI f/w present */ 7108c2ecf20Sopenharmony_ci int sram_type; /* 8 = x8 SRAM, 16 = x16 SRAM, -1 = unknown */ 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci enum { 7138c2ecf20Sopenharmony_ci PRISM2_TXPOWER_AUTO = 0, PRISM2_TXPOWER_OFF, 7148c2ecf20Sopenharmony_ci PRISM2_TXPOWER_FIXED, PRISM2_TXPOWER_UNKNOWN 7158c2ecf20Sopenharmony_ci } txpower_type; 7168c2ecf20Sopenharmony_ci int txpower; /* if txpower_type == PRISM2_TXPOWER_FIXED */ 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_ci /* command queue for hfa384x_cmd(); protected with cmdlock */ 7198c2ecf20Sopenharmony_ci struct list_head cmd_queue; 7208c2ecf20Sopenharmony_ci /* max_len for cmd_queue; in addition, cmd_callback can use two 7218c2ecf20Sopenharmony_ci * additional entries to prevent sleeping commands from stopping 7228c2ecf20Sopenharmony_ci * transmits */ 7238c2ecf20Sopenharmony_ci#define HOSTAP_CMD_QUEUE_MAX_LEN 16 7248c2ecf20Sopenharmony_ci int cmd_queue_len; /* number of entries in cmd_queue */ 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci /* if card timeout is detected in interrupt context, reset_queue is 7278c2ecf20Sopenharmony_ci * used to schedule card reseting to be done in user context */ 7288c2ecf20Sopenharmony_ci struct work_struct reset_queue; 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_ci /* For scheduling a change of the promiscuous mode RID */ 7318c2ecf20Sopenharmony_ci int is_promisc; 7328c2ecf20Sopenharmony_ci struct work_struct set_multicast_list_queue; 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci struct work_struct set_tim_queue; 7358c2ecf20Sopenharmony_ci struct list_head set_tim_list; 7368c2ecf20Sopenharmony_ci spinlock_t set_tim_lock; 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci int wds_max_connections; 7398c2ecf20Sopenharmony_ci int wds_connections; 7408c2ecf20Sopenharmony_ci#define HOSTAP_WDS_BROADCAST_RA BIT(0) 7418c2ecf20Sopenharmony_ci#define HOSTAP_WDS_AP_CLIENT BIT(1) 7428c2ecf20Sopenharmony_ci#define HOSTAP_WDS_STANDARD_FRAME BIT(2) 7438c2ecf20Sopenharmony_ci u32 wds_type; 7448c2ecf20Sopenharmony_ci u16 tx_control; /* flags to be used in TX description */ 7458c2ecf20Sopenharmony_ci int manual_retry_count; /* -1 = use f/w default; otherwise retry count 7468c2ecf20Sopenharmony_ci * to be used with all frames */ 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci struct iw_statistics wstats; 7498c2ecf20Sopenharmony_ci unsigned long scan_timestamp; /* Time started to scan */ 7508c2ecf20Sopenharmony_ci enum { 7518c2ecf20Sopenharmony_ci PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1, 7528c2ecf20Sopenharmony_ci PRISM2_MONITOR_CAPHDR = 2, PRISM2_MONITOR_RADIOTAP = 3 7538c2ecf20Sopenharmony_ci } monitor_type; 7548c2ecf20Sopenharmony_ci int monitor_allow_fcserr; 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci int hostapd; /* whether user space daemon, hostapd, is used for AP 7578c2ecf20Sopenharmony_ci * management */ 7588c2ecf20Sopenharmony_ci int hostapd_sta; /* whether hostapd is used with an extra STA interface 7598c2ecf20Sopenharmony_ci */ 7608c2ecf20Sopenharmony_ci struct net_device *apdev; 7618c2ecf20Sopenharmony_ci struct net_device_stats apdevstats; 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci char assoc_ap_addr[ETH_ALEN]; 7648c2ecf20Sopenharmony_ci struct net_device *stadev; 7658c2ecf20Sopenharmony_ci struct net_device_stats stadevstats; 7668c2ecf20Sopenharmony_ci 7678c2ecf20Sopenharmony_ci#define WEP_KEYS 4 7688c2ecf20Sopenharmony_ci#define WEP_KEY_LEN 13 7698c2ecf20Sopenharmony_ci struct lib80211_crypt_info crypt_info; 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ci int open_wep; /* allow unencrypted frames */ 7728c2ecf20Sopenharmony_ci int host_encrypt; 7738c2ecf20Sopenharmony_ci int host_decrypt; 7748c2ecf20Sopenharmony_ci int privacy_invoked; /* force privacy invoked flag even if no keys are 7758c2ecf20Sopenharmony_ci * configured */ 7768c2ecf20Sopenharmony_ci int fw_encrypt_ok; /* whether firmware-based WEP encrypt is working 7778c2ecf20Sopenharmony_ci * in Host AP mode (STA f/w 1.4.9 or newer) */ 7788c2ecf20Sopenharmony_ci int bcrx_sta_key; /* use individual keys to override default keys even 7798c2ecf20Sopenharmony_ci * with RX of broad/multicast frames */ 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_ci struct prism2_frag_entry frag_cache[PRISM2_FRAG_CACHE_LEN]; 7828c2ecf20Sopenharmony_ci unsigned int frag_next_idx; 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci int ieee_802_1x; /* is IEEE 802.1X used */ 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_ci int antsel_tx, antsel_rx; 7878c2ecf20Sopenharmony_ci int rts_threshold; /* dot11RTSThreshold */ 7888c2ecf20Sopenharmony_ci int fragm_threshold; /* dot11FragmentationThreshold */ 7898c2ecf20Sopenharmony_ci int auth_algs; /* PRISM2_AUTH_ flags */ 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci int enh_sec; /* cnfEnhSecurity options (broadcast SSID hide/ignore) */ 7928c2ecf20Sopenharmony_ci int tallies32; /* 32-bit tallies in use */ 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_ci struct prism2_helper_functions *func; 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci u8 *pda; 7978c2ecf20Sopenharmony_ci int fw_ap; 7988c2ecf20Sopenharmony_ci#define PRISM2_FW_VER(major, minor, variant) \ 7998c2ecf20Sopenharmony_ci(((major) << 16) | ((minor) << 8) | variant) 8008c2ecf20Sopenharmony_ci u32 sta_fw_ver; 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci /* Tasklets for handling hardware IRQ related operations outside hw IRQ 8038c2ecf20Sopenharmony_ci * handler */ 8048c2ecf20Sopenharmony_ci struct tasklet_struct bap_tasklet; 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci struct tasklet_struct info_tasklet; 8078c2ecf20Sopenharmony_ci struct sk_buff_head info_list; /* info frames as skb's for 8088c2ecf20Sopenharmony_ci * info_tasklet */ 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_ci struct hostap_tx_callback_info *tx_callback; /* registered TX callbacks 8118c2ecf20Sopenharmony_ci */ 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci struct tasklet_struct rx_tasklet; 8148c2ecf20Sopenharmony_ci struct sk_buff_head rx_list; 8158c2ecf20Sopenharmony_ci 8168c2ecf20Sopenharmony_ci struct tasklet_struct sta_tx_exc_tasklet; 8178c2ecf20Sopenharmony_ci struct sk_buff_head sta_tx_exc_list; 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci int host_roaming; 8208c2ecf20Sopenharmony_ci unsigned long last_join_time; /* time of last JoinRequest */ 8218c2ecf20Sopenharmony_ci struct hfa384x_hostscan_result *last_scan_results; 8228c2ecf20Sopenharmony_ci int last_scan_results_count; 8238c2ecf20Sopenharmony_ci enum { PRISM2_SCAN, PRISM2_HOSTSCAN } last_scan_type; 8248c2ecf20Sopenharmony_ci struct work_struct info_queue; 8258c2ecf20Sopenharmony_ci unsigned long pending_info; /* bit field of pending info_queue items */ 8268c2ecf20Sopenharmony_ci#define PRISM2_INFO_PENDING_LINKSTATUS 0 8278c2ecf20Sopenharmony_ci#define PRISM2_INFO_PENDING_SCANRESULTS 1 8288c2ecf20Sopenharmony_ci int prev_link_status; /* previous received LinkStatus info */ 8298c2ecf20Sopenharmony_ci int prev_linkstatus_connected; 8308c2ecf20Sopenharmony_ci u8 preferred_ap[ETH_ALEN]; /* use this AP if possible */ 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci#ifdef PRISM2_CALLBACK 8338c2ecf20Sopenharmony_ci void *callback_data; /* Can be used in callbacks; e.g., allocate 8348c2ecf20Sopenharmony_ci * on enable event and free on disable event. 8358c2ecf20Sopenharmony_ci * Host AP driver code does not touch this. */ 8368c2ecf20Sopenharmony_ci#endif /* PRISM2_CALLBACK */ 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci wait_queue_head_t hostscan_wq; 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ci /* Passive scan in Host AP mode */ 8418c2ecf20Sopenharmony_ci struct timer_list passive_scan_timer; 8428c2ecf20Sopenharmony_ci int passive_scan_interval; /* in seconds, 0 = disabled */ 8438c2ecf20Sopenharmony_ci int passive_scan_channel; 8448c2ecf20Sopenharmony_ci enum { PASSIVE_SCAN_WAIT, PASSIVE_SCAN_LISTEN } passive_scan_state; 8458c2ecf20Sopenharmony_ci 8468c2ecf20Sopenharmony_ci struct timer_list tick_timer; 8478c2ecf20Sopenharmony_ci unsigned long last_tick_timer; 8488c2ecf20Sopenharmony_ci unsigned int sw_tick_stuck; 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_ci /* commsQuality / dBmCommsQuality data from periodic polling; only 8518c2ecf20Sopenharmony_ci * valid for Managed and Ad-hoc modes */ 8528c2ecf20Sopenharmony_ci unsigned long last_comms_qual_update; 8538c2ecf20Sopenharmony_ci int comms_qual; /* in some odd unit.. */ 8548c2ecf20Sopenharmony_ci int avg_signal; /* in dB (note: negative) */ 8558c2ecf20Sopenharmony_ci int avg_noise; /* in dB (note: negative) */ 8568c2ecf20Sopenharmony_ci struct work_struct comms_qual_update; 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ci /* RSSI to dBm adjustment (for RX descriptor fields) */ 8598c2ecf20Sopenharmony_ci int rssi_to_dBm; /* subtract from RSSI to get approximate dBm value */ 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_ci /* BSS list / protected by local->lock */ 8628c2ecf20Sopenharmony_ci struct list_head bss_list; 8638c2ecf20Sopenharmony_ci int num_bss_info; 8648c2ecf20Sopenharmony_ci int wpa; /* WPA support enabled */ 8658c2ecf20Sopenharmony_ci int tkip_countermeasures; 8668c2ecf20Sopenharmony_ci int drop_unencrypted; 8678c2ecf20Sopenharmony_ci /* Generic IEEE 802.11 info element to be added to 8688c2ecf20Sopenharmony_ci * ProbeResp/Beacon/(Re)AssocReq */ 8698c2ecf20Sopenharmony_ci u8 *generic_elem; 8708c2ecf20Sopenharmony_ci size_t generic_elem_len; 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci#ifdef PRISM2_DOWNLOAD_SUPPORT 8738c2ecf20Sopenharmony_ci /* Persistent volatile download data */ 8748c2ecf20Sopenharmony_ci struct prism2_download_data *dl_pri; 8758c2ecf20Sopenharmony_ci struct prism2_download_data *dl_sec; 8768c2ecf20Sopenharmony_ci#endif /* PRISM2_DOWNLOAD_SUPPORT */ 8778c2ecf20Sopenharmony_ci 8788c2ecf20Sopenharmony_ci#ifdef PRISM2_IO_DEBUG 8798c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_SIZE 10000 8808c2ecf20Sopenharmony_ci u32 io_debug[PRISM2_IO_DEBUG_SIZE]; 8818c2ecf20Sopenharmony_ci int io_debug_head; 8828c2ecf20Sopenharmony_ci int io_debug_enabled; 8838c2ecf20Sopenharmony_ci#endif /* PRISM2_IO_DEBUG */ 8848c2ecf20Sopenharmony_ci 8858c2ecf20Sopenharmony_ci /* Pointer to hardware model specific (cs,pci,plx) private data. */ 8868c2ecf20Sopenharmony_ci void *hw_priv; 8878c2ecf20Sopenharmony_ci}; 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci 8908c2ecf20Sopenharmony_ci/* Per interface private Host AP data 8918c2ecf20Sopenharmony_ci * Allocated for each net device that Host AP uses (wlan#, wlan#ap, wlan#sta, 8928c2ecf20Sopenharmony_ci * WDS) and netdev_priv(dev) points to this structure. */ 8938c2ecf20Sopenharmony_cistruct hostap_interface { 8948c2ecf20Sopenharmony_ci struct list_head list; /* list entry in Host AP interface list */ 8958c2ecf20Sopenharmony_ci struct net_device *dev; /* pointer to this device */ 8968c2ecf20Sopenharmony_ci struct local_info *local; /* pointer to shared private data */ 8978c2ecf20Sopenharmony_ci struct net_device_stats stats; 8988c2ecf20Sopenharmony_ci struct iw_spy_data spy_data; /* iwspy support */ 8998c2ecf20Sopenharmony_ci struct iw_public_data wireless_data; 9008c2ecf20Sopenharmony_ci 9018c2ecf20Sopenharmony_ci enum { 9028c2ecf20Sopenharmony_ci HOSTAP_INTERFACE_MASTER, 9038c2ecf20Sopenharmony_ci HOSTAP_INTERFACE_MAIN, 9048c2ecf20Sopenharmony_ci HOSTAP_INTERFACE_AP, 9058c2ecf20Sopenharmony_ci HOSTAP_INTERFACE_STA, 9068c2ecf20Sopenharmony_ci HOSTAP_INTERFACE_WDS, 9078c2ecf20Sopenharmony_ci } type; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_ci union { 9108c2ecf20Sopenharmony_ci struct hostap_interface_wds { 9118c2ecf20Sopenharmony_ci u8 remote_addr[ETH_ALEN]; 9128c2ecf20Sopenharmony_ci } wds; 9138c2ecf20Sopenharmony_ci } u; 9148c2ecf20Sopenharmony_ci}; 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_ci 9178c2ecf20Sopenharmony_ci#define HOSTAP_SKB_TX_DATA_MAGIC 0xf08a36a2 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ci/* 9208c2ecf20Sopenharmony_ci * TX meta data - stored in skb->cb buffer, so this must not be increased over 9218c2ecf20Sopenharmony_ci * the 48-byte limit. 9228c2ecf20Sopenharmony_ci * THE PADDING THIS STARTS WITH IS A HORRIBLE HACK THAT SHOULD NOT LIVE 9238c2ecf20Sopenharmony_ci * TO SEE THE DAY. 9248c2ecf20Sopenharmony_ci */ 9258c2ecf20Sopenharmony_cistruct hostap_skb_tx_data { 9268c2ecf20Sopenharmony_ci unsigned int __padding_for_default_qdiscs; 9278c2ecf20Sopenharmony_ci u32 magic; /* HOSTAP_SKB_TX_DATA_MAGIC */ 9288c2ecf20Sopenharmony_ci u8 rate; /* transmit rate */ 9298c2ecf20Sopenharmony_ci#define HOSTAP_TX_FLAGS_WDS BIT(0) 9308c2ecf20Sopenharmony_ci#define HOSTAP_TX_FLAGS_BUFFERED_FRAME BIT(1) 9318c2ecf20Sopenharmony_ci#define HOSTAP_TX_FLAGS_ADD_MOREDATA BIT(2) 9328c2ecf20Sopenharmony_ci u8 flags; /* HOSTAP_TX_FLAGS_* */ 9338c2ecf20Sopenharmony_ci u16 tx_cb_idx; 9348c2ecf20Sopenharmony_ci struct hostap_interface *iface; 9358c2ecf20Sopenharmony_ci unsigned long jiffies; /* queueing timestamp */ 9368c2ecf20Sopenharmony_ci unsigned short ethertype; 9378c2ecf20Sopenharmony_ci}; 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_ci 9408c2ecf20Sopenharmony_ci#ifndef PRISM2_NO_DEBUG 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci#define DEBUG_FID BIT(0) 9438c2ecf20Sopenharmony_ci#define DEBUG_PS BIT(1) 9448c2ecf20Sopenharmony_ci#define DEBUG_FLOW BIT(2) 9458c2ecf20Sopenharmony_ci#define DEBUG_AP BIT(3) 9468c2ecf20Sopenharmony_ci#define DEBUG_HW BIT(4) 9478c2ecf20Sopenharmony_ci#define DEBUG_EXTRA BIT(5) 9488c2ecf20Sopenharmony_ci#define DEBUG_EXTRA2 BIT(6) 9498c2ecf20Sopenharmony_ci#define DEBUG_PS2 BIT(7) 9508c2ecf20Sopenharmony_ci#define DEBUG_MASK (DEBUG_PS | DEBUG_AP | DEBUG_HW | DEBUG_EXTRA) 9518c2ecf20Sopenharmony_ci#define PDEBUG(n, args...) \ 9528c2ecf20Sopenharmony_cido { if ((n) & DEBUG_MASK) printk(KERN_DEBUG args); } while (0) 9538c2ecf20Sopenharmony_ci#define PDEBUG2(n, args...) \ 9548c2ecf20Sopenharmony_cido { if ((n) & DEBUG_MASK) printk(args); } while (0) 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci#else /* PRISM2_NO_DEBUG */ 9578c2ecf20Sopenharmony_ci 9588c2ecf20Sopenharmony_ci#define PDEBUG(n, args...) 9598c2ecf20Sopenharmony_ci#define PDEBUG2(n, args...) 9608c2ecf20Sopenharmony_ci 9618c2ecf20Sopenharmony_ci#endif /* PRISM2_NO_DEBUG */ 9628c2ecf20Sopenharmony_ci 9638c2ecf20Sopenharmony_cienum { BAP0 = 0, BAP1 = 1 }; 9648c2ecf20Sopenharmony_ci 9658c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_INB 0 9668c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_INW 1 9678c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_INSW 2 9688c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_OUTB 3 9698c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_OUTW 4 9708c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_OUTSW 5 9718c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_ERROR 6 9728c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_CMD_INTERRUPT 7 9738c2ecf20Sopenharmony_ci 9748c2ecf20Sopenharmony_ci#ifdef PRISM2_IO_DEBUG 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci#define PRISM2_IO_DEBUG_ENTRY(cmd, reg, value) \ 9778c2ecf20Sopenharmony_ci(((cmd) << 24) | ((reg) << 16) | value) 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_cistatic inline void prism2_io_debug_add(struct net_device *dev, int cmd, 9808c2ecf20Sopenharmony_ci int reg, int value) 9818c2ecf20Sopenharmony_ci{ 9828c2ecf20Sopenharmony_ci struct hostap_interface *iface = netdev_priv(dev); 9838c2ecf20Sopenharmony_ci local_info_t *local = iface->local; 9848c2ecf20Sopenharmony_ci 9858c2ecf20Sopenharmony_ci if (!local->io_debug_enabled) 9868c2ecf20Sopenharmony_ci return; 9878c2ecf20Sopenharmony_ci 9888c2ecf20Sopenharmony_ci local->io_debug[local->io_debug_head] = jiffies & 0xffffffff; 9898c2ecf20Sopenharmony_ci if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE) 9908c2ecf20Sopenharmony_ci local->io_debug_head = 0; 9918c2ecf20Sopenharmony_ci local->io_debug[local->io_debug_head] = 9928c2ecf20Sopenharmony_ci PRISM2_IO_DEBUG_ENTRY(cmd, reg, value); 9938c2ecf20Sopenharmony_ci if (++local->io_debug_head >= PRISM2_IO_DEBUG_SIZE) 9948c2ecf20Sopenharmony_ci local->io_debug_head = 0; 9958c2ecf20Sopenharmony_ci} 9968c2ecf20Sopenharmony_ci 9978c2ecf20Sopenharmony_ci 9988c2ecf20Sopenharmony_cistatic inline void prism2_io_debug_error(struct net_device *dev, int err) 9998c2ecf20Sopenharmony_ci{ 10008c2ecf20Sopenharmony_ci struct hostap_interface *iface = netdev_priv(dev); 10018c2ecf20Sopenharmony_ci local_info_t *local = iface->local; 10028c2ecf20Sopenharmony_ci unsigned long flags; 10038c2ecf20Sopenharmony_ci 10048c2ecf20Sopenharmony_ci if (!local->io_debug_enabled) 10058c2ecf20Sopenharmony_ci return; 10068c2ecf20Sopenharmony_ci 10078c2ecf20Sopenharmony_ci spin_lock_irqsave(&local->lock, flags); 10088c2ecf20Sopenharmony_ci prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_ERROR, 0, err); 10098c2ecf20Sopenharmony_ci if (local->io_debug_enabled == 1) { 10108c2ecf20Sopenharmony_ci local->io_debug_enabled = 0; 10118c2ecf20Sopenharmony_ci printk(KERN_DEBUG "%s: I/O debug stopped\n", dev->name); 10128c2ecf20Sopenharmony_ci } 10138c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&local->lock, flags); 10148c2ecf20Sopenharmony_ci} 10158c2ecf20Sopenharmony_ci 10168c2ecf20Sopenharmony_ci#else /* PRISM2_IO_DEBUG */ 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_cistatic inline void prism2_io_debug_add(struct net_device *dev, int cmd, 10198c2ecf20Sopenharmony_ci int reg, int value) 10208c2ecf20Sopenharmony_ci{ 10218c2ecf20Sopenharmony_ci} 10228c2ecf20Sopenharmony_ci 10238c2ecf20Sopenharmony_cistatic inline void prism2_io_debug_error(struct net_device *dev, int err) 10248c2ecf20Sopenharmony_ci{ 10258c2ecf20Sopenharmony_ci} 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci#endif /* PRISM2_IO_DEBUG */ 10288c2ecf20Sopenharmony_ci 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci#ifdef PRISM2_CALLBACK 10318c2ecf20Sopenharmony_cienum { 10328c2ecf20Sopenharmony_ci /* Called when card is enabled */ 10338c2ecf20Sopenharmony_ci PRISM2_CALLBACK_ENABLE, 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ci /* Called when card is disabled */ 10368c2ecf20Sopenharmony_ci PRISM2_CALLBACK_DISABLE, 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci /* Called when RX/TX starts/ends */ 10398c2ecf20Sopenharmony_ci PRISM2_CALLBACK_RX_START, PRISM2_CALLBACK_RX_END, 10408c2ecf20Sopenharmony_ci PRISM2_CALLBACK_TX_START, PRISM2_CALLBACK_TX_END 10418c2ecf20Sopenharmony_ci}; 10428c2ecf20Sopenharmony_civoid prism2_callback(local_info_t *local, int event); 10438c2ecf20Sopenharmony_ci#else /* PRISM2_CALLBACK */ 10448c2ecf20Sopenharmony_ci#define prism2_callback(d, e) do { } while (0) 10458c2ecf20Sopenharmony_ci#endif /* PRISM2_CALLBACK */ 10468c2ecf20Sopenharmony_ci 10478c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 10488c2ecf20Sopenharmony_ci 10498c2ecf20Sopenharmony_ci#endif /* HOSTAP_WLAN_H */ 1050