Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2010-2011 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifndef COMMON_H |
| 18 | #define COMMON_H |
| 19 | |
| 20 | #include <linux/netdevice.h> |
| 21 | |
| 22 | #define ATH6KL_MAX_IE 256 |
| 23 | |
| 24 | extern int ath6kl_printk(const char *level, const char *fmt, ...); |
| 25 | |
| 26 | #define A_CACHE_LINE_PAD 128 |
| 27 | |
| 28 | /* |
| 29 | * Reflects the version of binary interface exposed by ATH6KL target |
| 30 | * firmware. Needs to be incremented by 1 for any change in the firmware |
| 31 | * that requires upgrade of the driver on the host side for the change to |
| 32 | * work correctly |
| 33 | */ |
| 34 | #define ATH6KL_ABI_VERSION 1 |
| 35 | |
| 36 | #define SIGNAL_QUALITY_METRICS_NUM_MAX 2 |
| 37 | |
| 38 | enum { |
| 39 | SIGNAL_QUALITY_METRICS_SNR = 0, |
| 40 | SIGNAL_QUALITY_METRICS_RSSI, |
| 41 | SIGNAL_QUALITY_METRICS_ALL, |
| 42 | }; |
| 43 | |
| 44 | /* |
| 45 | * Data Path |
| 46 | */ |
| 47 | |
| 48 | #define WMI_MAX_TX_DATA_FRAME_LENGTH \ |
| 49 | (1500 + sizeof(struct wmi_data_hdr) + \ |
| 50 | sizeof(struct ethhdr) + \ |
| 51 | sizeof(struct ath6kl_llc_snap_hdr)) |
| 52 | |
| 53 | /* An AMSDU frame */ /* The MAX AMSDU length of AR6003 is 3839 */ |
| 54 | #define WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH \ |
| 55 | (3840 + sizeof(struct wmi_data_hdr) + \ |
| 56 | sizeof(struct ethhdr) + \ |
| 57 | sizeof(struct ath6kl_llc_snap_hdr)) |
| 58 | |
| 59 | #define EPPING_ALIGNMENT_PAD \ |
| 60 | (((sizeof(struct htc_frame_hdr) + 3) & (~0x3)) \ |
| 61 | - sizeof(struct htc_frame_hdr)) |
| 62 | |
| 63 | struct ath6kl_llc_snap_hdr { |
| 64 | u8 dsap; |
| 65 | u8 ssap; |
| 66 | u8 cntl; |
| 67 | u8 org_code[3]; |
| 68 | __be16 eth_type; |
| 69 | } __packed; |
| 70 | |
| 71 | enum crypto_type { |
| 72 | NONE_CRYPT = 0x01, |
| 73 | WEP_CRYPT = 0x02, |
| 74 | TKIP_CRYPT = 0x04, |
| 75 | AES_CRYPT = 0x08, |
| 76 | }; |
| 77 | |
| 78 | #define ATH6KL_NODE_HASHSIZE 32 |
| 79 | /* simple hash is enough for variation of macaddr */ |
| 80 | #define ATH6KL_NODE_HASH(addr) \ |
| 81 | (((const u8 *)(addr))[ETH_ALEN - 1] % \ |
| 82 | ATH6KL_NODE_HASHSIZE) |
| 83 | |
| 84 | /* |
| 85 | * Table of ath6kl_node instances. Each ieee80211com |
| 86 | * has at least one for holding the scan candidates. |
| 87 | * When operating as an access point or in ibss mode there |
| 88 | * is a second table for associated stations or neighbors. |
| 89 | */ |
| 90 | struct ath6kl_node_table { |
| 91 | void *nt_wmi; /* back reference */ |
| 92 | spinlock_t nt_nodelock; /* on node table */ |
| 93 | struct bss *nt_node_first; /* information of all nodes */ |
| 94 | struct bss *nt_node_last; /* information of all nodes */ |
| 95 | struct bss *nt_hash[ATH6KL_NODE_HASHSIZE]; |
| 96 | const char *nt_name; /* for debugging */ |
| 97 | u32 nt_node_age; /* node aging time */ |
| 98 | }; |
| 99 | |
| 100 | #define WLAN_NODE_INACT_TIMEOUT_MSEC 120000 |
| 101 | #define WLAN_NODE_INACT_CNT 4 |
| 102 | |
| 103 | struct ath6kl_common_ie { |
| 104 | u16 ie_chan; |
| 105 | u8 *ie_tstamp; |
| 106 | u8 *ie_ssid; |
| 107 | u8 *ie_rates; |
| 108 | u8 *ie_xrates; |
| 109 | u8 *ie_country; |
| 110 | u8 *ie_wpa; |
| 111 | u8 *ie_rsn; |
| 112 | u8 *ie_wmm; |
| 113 | u8 *ie_ath; |
| 114 | u16 ie_capInfo; |
| 115 | u16 ie_beaconInt; |
| 116 | u8 *ie_tim; |
| 117 | u8 *ie_chswitch; |
| 118 | u8 ie_erp; |
| 119 | u8 *ie_wsc; |
| 120 | u8 *ie_htcap; |
| 121 | u8 *ie_htop; |
| 122 | }; |
| 123 | |
| 124 | struct bss { |
| 125 | u8 ni_macaddr[ETH_ALEN]; |
| 126 | u8 ni_snr; |
| 127 | s16 ni_rssi; |
| 128 | struct bss *ni_list_next; |
| 129 | struct bss *ni_list_prev; |
| 130 | struct bss *ni_hash_next; |
| 131 | struct bss *ni_hash_prev; |
| 132 | struct ath6kl_common_ie ni_cie; |
| 133 | u8 *ni_buf; |
| 134 | u16 ni_framelen; |
| 135 | struct ath6kl_node_table *ni_table; |
| 136 | u32 ni_refcnt; |
| 137 | |
| 138 | u32 ni_tstamp; |
| 139 | u32 ni_actcnt; |
| 140 | }; |
| 141 | |
| 142 | struct htc_endpoint_credit_dist; |
| 143 | struct ath6kl; |
| 144 | enum htc_credit_dist_reason; |
| 145 | struct htc_credit_state_info; |
| 146 | |
| 147 | struct bss *wlan_node_alloc(int wh_size); |
| 148 | void wlan_node_free(struct bss *ni); |
| 149 | void wlan_setup_node(struct ath6kl_node_table *nt, struct bss *ni, |
| 150 | const u8 *mac_addr); |
| 151 | struct bss *wlan_find_node(struct ath6kl_node_table *nt, |
| 152 | const u8 *mac_addr); |
| 153 | void wlan_node_reclaim(struct ath6kl_node_table *nt, struct bss *ni); |
| 154 | void wlan_free_allnodes(struct ath6kl_node_table *nt); |
| 155 | void wlan_iterate_nodes(struct ath6kl_node_table *nt, |
| 156 | void (*f) (void *arg, struct bss *), |
| 157 | void *arg); |
| 158 | |
| 159 | void wlan_node_table_init(void *wmip, struct ath6kl_node_table *nt); |
| 160 | void wlan_node_table_cleanup(struct ath6kl_node_table *nt); |
| 161 | |
| 162 | void wlan_refresh_inactive_nodes(struct ath6kl_node_table *nt); |
| 163 | |
| 164 | struct bss *wlan_find_ssid_node(struct ath6kl_node_table *nt, u8 *ssid, |
| 165 | u32 ssid_len, bool is_wpa2, bool match_ssid); |
| 166 | |
| 167 | void wlan_node_return(struct ath6kl_node_table *nt, struct bss *ni); |
| 168 | |
| 169 | int ath6k_setup_credit_dist(void *htc_handle, |
| 170 | struct htc_credit_state_info *cred_info); |
| 171 | void ath6k_credit_distribute(struct htc_credit_state_info *cred_inf, |
| 172 | struct list_head *epdist_list, |
| 173 | enum htc_credit_dist_reason reason); |
| 174 | void ath6k_credit_init(struct htc_credit_state_info *cred_inf, |
| 175 | struct list_head *ep_list, |
| 176 | int tot_credits); |
| 177 | void ath6k_seek_credits(struct htc_credit_state_info *cred_inf, |
| 178 | struct htc_endpoint_credit_dist *ep_dist); |
| 179 | struct ath6kl *ath6kl_core_alloc(struct device *sdev); |
| 180 | int ath6kl_core_init(struct ath6kl *ar); |
| 181 | int ath6kl_unavail_ev(struct ath6kl *ar); |
| 182 | struct sk_buff *ath6kl_buf_alloc(int size); |
| 183 | #endif /* COMMON_H */ |