Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 1 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2 | /* |
| 3 | * This file is part of wl1271 |
| 4 | * |
Juuso Oikarinen | 8bf29b0 | 2010-02-18 13:25:51 +0200 | [diff] [blame] | 5 | * Copyright (C) 2008-2010 Nokia Corporation |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 6 | * |
| 7 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * version 2 as published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 21 | * 02110-1301 USA |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/module.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 26 | #include <linux/firmware.h> |
| 27 | #include <linux/delay.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 28 | #include <linux/spi/spi.h> |
| 29 | #include <linux/crc32.h> |
| 30 | #include <linux/etherdevice.h> |
Juuso Oikarinen | 1fba497 | 2009-10-08 21:56:32 +0300 | [diff] [blame] | 31 | #include <linux/vmalloc.h> |
Juuso Oikarinen | a1dd818 | 2010-03-18 12:26:31 +0200 | [diff] [blame] | 32 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 33 | #include <linux/slab.h> |
Ido Yariv | 341b7cd | 2011-03-31 10:07:01 +0200 | [diff] [blame] | 34 | #include <linux/wl12xx.h> |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 35 | #include <linux/sched.h> |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 36 | #include <linux/interrupt.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 37 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 38 | #include "wl12xx.h" |
Luciano Coelho | 0f4e312 | 2011-10-07 11:02:42 +0300 | [diff] [blame] | 39 | #include "debug.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 40 | #include "wl12xx_80211.h" |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 41 | #include "reg.h" |
| 42 | #include "io.h" |
| 43 | #include "event.h" |
| 44 | #include "tx.h" |
| 45 | #include "rx.h" |
| 46 | #include "ps.h" |
| 47 | #include "init.h" |
| 48 | #include "debugfs.h" |
| 49 | #include "cmd.h" |
| 50 | #include "boot.h" |
| 51 | #include "testmode.h" |
| 52 | #include "scan.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 53 | |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 54 | #define WL1271_BOOT_RETRIES 3 |
| 55 | |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 56 | static struct conf_drv_settings default_conf = { |
| 57 | .sg = { |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 58 | .params = { |
| 59 | [CONF_SG_ACL_BT_MASTER_MIN_BR] = 10, |
| 60 | [CONF_SG_ACL_BT_MASTER_MAX_BR] = 180, |
| 61 | [CONF_SG_ACL_BT_SLAVE_MIN_BR] = 10, |
| 62 | [CONF_SG_ACL_BT_SLAVE_MAX_BR] = 180, |
| 63 | [CONF_SG_ACL_BT_MASTER_MIN_EDR] = 10, |
| 64 | [CONF_SG_ACL_BT_MASTER_MAX_EDR] = 80, |
| 65 | [CONF_SG_ACL_BT_SLAVE_MIN_EDR] = 10, |
| 66 | [CONF_SG_ACL_BT_SLAVE_MAX_EDR] = 80, |
| 67 | [CONF_SG_ACL_WLAN_PS_MASTER_BR] = 8, |
| 68 | [CONF_SG_ACL_WLAN_PS_SLAVE_BR] = 8, |
| 69 | [CONF_SG_ACL_WLAN_PS_MASTER_EDR] = 20, |
| 70 | [CONF_SG_ACL_WLAN_PS_SLAVE_EDR] = 20, |
| 71 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_BR] = 20, |
| 72 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_BR] = 35, |
| 73 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_BR] = 16, |
| 74 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_BR] = 35, |
| 75 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_EDR] = 32, |
| 76 | [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_EDR] = 50, |
| 77 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_EDR] = 28, |
| 78 | [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_EDR] = 50, |
| 79 | [CONF_SG_ACL_ACTIVE_SCAN_WLAN_BR] = 10, |
| 80 | [CONF_SG_ACL_ACTIVE_SCAN_WLAN_EDR] = 20, |
| 81 | [CONF_SG_ACL_PASSIVE_SCAN_BT_BR] = 75, |
| 82 | [CONF_SG_ACL_PASSIVE_SCAN_WLAN_BR] = 15, |
| 83 | [CONF_SG_ACL_PASSIVE_SCAN_BT_EDR] = 27, |
| 84 | [CONF_SG_ACL_PASSIVE_SCAN_WLAN_EDR] = 17, |
| 85 | /* active scan params */ |
| 86 | [CONF_SG_AUTO_SCAN_PROBE_REQ] = 170, |
| 87 | [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50, |
| 88 | [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100, |
| 89 | /* passive scan params */ |
| 90 | [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_BR] = 800, |
| 91 | [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_EDR] = 200, |
| 92 | [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200, |
| 93 | /* passive scan in dual antenna params */ |
| 94 | [CONF_SG_CONSECUTIVE_HV3_IN_PASSIVE_SCAN] = 0, |
| 95 | [CONF_SG_BCN_HV3_COLLISION_THRESH_IN_PASSIVE_SCAN] = 0, |
| 96 | [CONF_SG_TX_RX_PROTECTION_BWIDTH_IN_PASSIVE_SCAN] = 0, |
| 97 | /* general params */ |
| 98 | [CONF_SG_STA_FORCE_PS_IN_BT_SCO] = 1, |
| 99 | [CONF_SG_ANTENNA_CONFIGURATION] = 0, |
| 100 | [CONF_SG_BEACON_MISS_PERCENT] = 60, |
| 101 | [CONF_SG_DHCP_TIME] = 5000, |
| 102 | [CONF_SG_RXT] = 1200, |
| 103 | [CONF_SG_TXT] = 1000, |
| 104 | [CONF_SG_ADAPTIVE_RXT_TXT] = 1, |
| 105 | [CONF_SG_GENERAL_USAGE_BIT_MAP] = 3, |
| 106 | [CONF_SG_HV3_MAX_SERVED] = 6, |
| 107 | [CONF_SG_PS_POLL_TIMEOUT] = 10, |
| 108 | [CONF_SG_UPSD_TIMEOUT] = 10, |
| 109 | [CONF_SG_CONSECUTIVE_CTS_THRESHOLD] = 2, |
| 110 | [CONF_SG_STA_RX_WINDOW_AFTER_DTIM] = 5, |
| 111 | [CONF_SG_STA_CONNECTION_PROTECTION_TIME] = 30, |
| 112 | /* AP params */ |
| 113 | [CONF_AP_BEACON_MISS_TX] = 3, |
| 114 | [CONF_AP_RX_WINDOW_AFTER_BEACON] = 10, |
| 115 | [CONF_AP_BEACON_WINDOW_INTERVAL] = 2, |
| 116 | [CONF_AP_CONNECTION_PROTECTION_TIME] = 0, |
| 117 | [CONF_AP_BT_ACL_VAL_BT_SERVE_TIME] = 25, |
| 118 | [CONF_AP_BT_ACL_VAL_WL_SERVE_TIME] = 25, |
Eliad Peller | 26612c4 | 2012-01-31 17:54:43 +0200 | [diff] [blame] | 119 | /* CTS Diluting params */ |
| 120 | [CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH] = 0, |
| 121 | [CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER] = 0, |
Arik Nemtsov | 801f870 | 2011-04-18 14:15:20 +0300 | [diff] [blame] | 122 | }, |
Juuso Oikarinen | 1b00f54 | 2010-03-18 12:26:30 +0200 | [diff] [blame] | 123 | .state = CONF_SG_PROTECTIVE, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 124 | }, |
| 125 | .rx = { |
| 126 | .rx_msdu_life_time = 512000, |
| 127 | .packet_detection_threshold = 0, |
| 128 | .ps_poll_timeout = 15, |
| 129 | .upsd_timeout = 15, |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 130 | .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD, |
Luciano Coelho | 3ed8f2c | 2009-12-11 15:40:54 +0200 | [diff] [blame] | 131 | .rx_cca_threshold = 0, |
| 132 | .irq_blk_threshold = 0xFFFF, |
| 133 | .irq_pkt_threshold = 0, |
| 134 | .irq_timeout = 600, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 135 | .queue_type = CONF_RX_QUEUE_TYPE_LOW_PRIORITY, |
| 136 | }, |
| 137 | .tx = { |
| 138 | .tx_energy_detection = 0, |
Arik Nemtsov | 1e05a81 | 2010-10-16 17:44:51 +0200 | [diff] [blame] | 139 | .sta_rc_conf = { |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 140 | .enabled_rates = 0, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 141 | .short_retry_limit = 10, |
| 142 | .long_retry_limit = 10, |
Arik Nemtsov | 1e05a81 | 2010-10-16 17:44:51 +0200 | [diff] [blame] | 143 | .aflags = 0, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 144 | }, |
| 145 | .ac_conf_count = 4, |
| 146 | .ac_conf = { |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 147 | [CONF_TX_AC_BE] = { |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 148 | .ac = CONF_TX_AC_BE, |
| 149 | .cw_min = 15, |
| 150 | .cw_max = 63, |
| 151 | .aifsn = 3, |
| 152 | .tx_op_limit = 0, |
| 153 | }, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 154 | [CONF_TX_AC_BK] = { |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 155 | .ac = CONF_TX_AC_BK, |
| 156 | .cw_min = 15, |
| 157 | .cw_max = 63, |
| 158 | .aifsn = 7, |
| 159 | .tx_op_limit = 0, |
| 160 | }, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 161 | [CONF_TX_AC_VI] = { |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 162 | .ac = CONF_TX_AC_VI, |
| 163 | .cw_min = 15, |
| 164 | .cw_max = 63, |
| 165 | .aifsn = CONF_TX_AIFS_PIFS, |
| 166 | .tx_op_limit = 3008, |
| 167 | }, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 168 | [CONF_TX_AC_VO] = { |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 169 | .ac = CONF_TX_AC_VO, |
| 170 | .cw_min = 15, |
| 171 | .cw_max = 63, |
| 172 | .aifsn = CONF_TX_AIFS_PIFS, |
| 173 | .tx_op_limit = 1504, |
| 174 | }, |
| 175 | }, |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame] | 176 | .max_tx_retries = 100, |
| 177 | .ap_aging_period = 300, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 178 | .tid_conf_count = 4, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 179 | .tid_conf = { |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 180 | [CONF_TX_AC_BE] = { |
| 181 | .queue_id = CONF_TX_AC_BE, |
| 182 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 183 | .tsid = CONF_TX_AC_BE, |
| 184 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 185 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 186 | .apsd_conf = {0, 0}, |
| 187 | }, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 188 | [CONF_TX_AC_BK] = { |
| 189 | .queue_id = CONF_TX_AC_BK, |
| 190 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 191 | .tsid = CONF_TX_AC_BK, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 192 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 193 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 194 | .apsd_conf = {0, 0}, |
| 195 | }, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 196 | [CONF_TX_AC_VI] = { |
| 197 | .queue_id = CONF_TX_AC_VI, |
| 198 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 199 | .tsid = CONF_TX_AC_VI, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 200 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 201 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 202 | .apsd_conf = {0, 0}, |
| 203 | }, |
Juuso Oikarinen | 9987a9d | 2010-09-01 11:31:12 +0200 | [diff] [blame] | 204 | [CONF_TX_AC_VO] = { |
| 205 | .queue_id = CONF_TX_AC_VO, |
| 206 | .channel_type = CONF_CHANNEL_TYPE_EDCF, |
| 207 | .tsid = CONF_TX_AC_VO, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 208 | .ps_scheme = CONF_PS_SCHEME_LEGACY, |
| 209 | .ack_policy = CONF_ACK_POLICY_LEGACY, |
| 210 | .apsd_conf = {0, 0}, |
| 211 | }, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 212 | }, |
| 213 | .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD, |
Luciano Coelho | 3ed8f2c | 2009-12-11 15:40:54 +0200 | [diff] [blame] | 214 | .tx_compl_timeout = 700, |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 215 | .tx_compl_threshold = 4, |
| 216 | .basic_rate = CONF_HW_BIT_RATE_1MBPS, |
| 217 | .basic_rate_5 = CONF_HW_BIT_RATE_6MBPS, |
Arik Nemtsov | 1e05a81 | 2010-10-16 17:44:51 +0200 | [diff] [blame] | 218 | .tmpl_short_retry_limit = 10, |
| 219 | .tmpl_long_retry_limit = 10, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 220 | }, |
| 221 | .conn = { |
| 222 | .wake_up_event = CONF_WAKE_UP_EVENT_DTIM, |
Juuso Oikarinen | 50c500a | 2010-04-01 11:38:22 +0300 | [diff] [blame] | 223 | .listen_interval = 1, |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 224 | .suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM, |
| 225 | .suspend_listen_interval = 3, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 226 | .bcn_filt_mode = CONF_BCN_FILT_MODE_ENABLED, |
Shahar Levi | bc76b94 | 2011-05-11 11:14:22 +0300 | [diff] [blame] | 227 | .bcn_filt_ie_count = 2, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 228 | .bcn_filt_ie = { |
| 229 | [0] = { |
| 230 | .ie = WLAN_EID_CHANNEL_SWITCH, |
| 231 | .rule = CONF_BCN_RULE_PASS_ON_APPEARANCE, |
Shahar Levi | bc76b94 | 2011-05-11 11:14:22 +0300 | [diff] [blame] | 232 | }, |
| 233 | [1] = { |
| 234 | .ie = WLAN_EID_HT_INFORMATION, |
| 235 | .rule = CONF_BCN_RULE_PASS_ON_CHANGE, |
| 236 | }, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 237 | }, |
Luciano Coelho | 3ed8f2c | 2009-12-11 15:40:54 +0200 | [diff] [blame] | 238 | .synch_fail_thold = 10, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 239 | .bss_lose_timeout = 100, |
| 240 | .beacon_rx_timeout = 10000, |
| 241 | .broadcast_timeout = 20000, |
| 242 | .rx_broadcast_in_ps = 1, |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 243 | .ps_poll_threshold = 10, |
Juuso Oikarinen | 11f70f9 | 2009-10-13 12:47:46 +0300 | [diff] [blame] | 244 | .bet_enable = CONF_BET_MODE_ENABLE, |
Ohad Ben-Cohen | 958b20e | 2011-03-14 18:53:10 +0200 | [diff] [blame] | 245 | .bet_max_consecutive = 50, |
Eliad Peller | a879ed7 | 2011-08-23 16:37:02 +0300 | [diff] [blame] | 246 | .psm_entry_retries = 8, |
Shahar Levi | 2370841 | 2011-04-13 14:52:50 +0300 | [diff] [blame] | 247 | .psm_exit_retries = 16, |
Juuso Oikarinen | 8eab7b4 | 2010-09-24 03:10:11 +0200 | [diff] [blame] | 248 | .psm_entry_nullfunc_retries = 3, |
Arik Nemtsov | d7b63b9 | 2012-02-28 00:41:34 +0200 | [diff] [blame] | 249 | .dynamic_ps_timeout = 200, |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 250 | .forced_ps = false, |
Juuso Oikarinen | 50c500a | 2010-04-01 11:38:22 +0300 | [diff] [blame] | 251 | .keep_alive_interval = 55000, |
| 252 | .max_listen_interval = 20, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 253 | }, |
Luciano Coelho | 6e92b41 | 2009-12-11 15:40:50 +0200 | [diff] [blame] | 254 | .itrim = { |
| 255 | .enable = false, |
| 256 | .timeout = 50000, |
Juuso Oikarinen | 38ad2d8 | 2009-12-11 15:41:08 +0200 | [diff] [blame] | 257 | }, |
| 258 | .pm_config = { |
| 259 | .host_clk_settling_time = 5000, |
| 260 | .host_fast_wakeup_support = false |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 261 | }, |
| 262 | .roam_trigger = { |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 263 | .trigger_pacing = 1, |
| 264 | .avg_weight_rssi_beacon = 20, |
| 265 | .avg_weight_rssi_data = 10, |
| 266 | .avg_weight_snr_beacon = 20, |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 267 | .avg_weight_snr_data = 10, |
Juuso Oikarinen | bea39d6 | 2010-09-21 08:14:31 +0200 | [diff] [blame] | 268 | }, |
| 269 | .scan = { |
| 270 | .min_dwell_time_active = 7500, |
| 271 | .max_dwell_time_active = 30000, |
Juuso Oikarinen | ea45b2c | 2011-01-24 07:01:54 +0100 | [diff] [blame] | 272 | .min_dwell_time_passive = 100000, |
| 273 | .max_dwell_time_passive = 100000, |
Juuso Oikarinen | bea39d6 | 2010-09-21 08:14:31 +0200 | [diff] [blame] | 274 | .num_probe_reqs = 2, |
Eyal Shapira | d647f2d | 2012-02-02 13:54:28 +0200 | [diff] [blame] | 275 | .split_scan_timeout = 50000, |
Juuso Oikarinen | bea39d6 | 2010-09-21 08:14:31 +0200 | [diff] [blame] | 276 | }, |
Luciano Coelho | 3a9d60e | 2011-05-10 14:06:31 +0300 | [diff] [blame] | 277 | .sched_scan = { |
| 278 | /* sched_scan requires dwell times in TU instead of TU/1000 */ |
Luciano Coelho | 221737d | 2011-09-02 14:28:22 +0300 | [diff] [blame] | 279 | .min_dwell_time_active = 30, |
| 280 | .max_dwell_time_active = 60, |
Luciano Coelho | 3a9d60e | 2011-05-10 14:06:31 +0300 | [diff] [blame] | 281 | .dwell_time_passive = 100, |
Luciano Coelho | 50a66d7 | 2011-05-27 15:34:47 +0300 | [diff] [blame] | 282 | .dwell_time_dfs = 150, |
Luciano Coelho | 3a9d60e | 2011-05-10 14:06:31 +0300 | [diff] [blame] | 283 | .num_probe_reqs = 2, |
| 284 | .rssi_threshold = -90, |
| 285 | .snr_threshold = 0, |
| 286 | }, |
Juuso Oikarinen | 644a486 | 2010-10-05 13:11:56 +0200 | [diff] [blame] | 287 | .rf = { |
| 288 | .tx_per_channel_power_compensation_2 = { |
| 289 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 290 | }, |
| 291 | .tx_per_channel_power_compensation_5 = { |
| 292 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 293 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 294 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 295 | }, |
| 296 | }, |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 297 | .ht = { |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 298 | .rx_ba_win_size = 8, |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 299 | .tx_ba_win_size = 64, |
| 300 | .inactivity_timeout = 10000, |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 301 | .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP, |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 302 | }, |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 303 | .mem_wl127x = { |
Eliad Peller | fe5ef09 | 2011-02-02 09:59:36 +0200 | [diff] [blame] | 304 | .num_stations = 1, |
| 305 | .ssid_profiles = 1, |
| 306 | .rx_block_num = 70, |
| 307 | .tx_min_block_num = 40, |
Ido Yariv | 4cf557f | 2011-04-18 16:45:10 +0300 | [diff] [blame] | 308 | .dynamic_memory = 1, |
Ido Yariv | b16d4b6 | 2011-03-01 15:14:44 +0200 | [diff] [blame] | 309 | .min_req_tx_blocks = 100, |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 310 | .min_req_rx_blocks = 22, |
| 311 | .tx_min = 27, |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 312 | }, |
| 313 | .mem_wl128x = { |
| 314 | .num_stations = 1, |
| 315 | .ssid_profiles = 1, |
| 316 | .rx_block_num = 40, |
| 317 | .tx_min_block_num = 40, |
| 318 | .dynamic_memory = 1, |
| 319 | .min_req_tx_blocks = 45, |
| 320 | .min_req_rx_blocks = 22, |
| 321 | .tx_min = 27, |
| 322 | }, |
Shahar Levi | ff86843 | 2011-04-11 15:41:46 +0300 | [diff] [blame] | 323 | .fm_coex = { |
| 324 | .enable = true, |
| 325 | .swallow_period = 5, |
| 326 | .n_divider_fref_set_1 = 0xff, /* default */ |
| 327 | .n_divider_fref_set_2 = 12, |
| 328 | .m_divider_fref_set_1 = 148, |
| 329 | .m_divider_fref_set_2 = 0xffff, /* default */ |
| 330 | .coex_pll_stabilization_time = 0xffffffff, /* default */ |
| 331 | .ldo_stabilization_time = 0xffff, /* default */ |
| 332 | .fm_disturbed_band_margin = 0xff, /* default */ |
| 333 | .swallow_clk_diff = 0xff, /* default */ |
| 334 | }, |
Eliad Peller | f84673d | 2011-05-15 11:10:28 +0300 | [diff] [blame] | 335 | .rx_streaming = { |
| 336 | .duration = 150, |
| 337 | .queues = 0x1, |
| 338 | .interval = 20, |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 339 | .always = 0, |
Eliad Peller | f84673d | 2011-05-15 11:10:28 +0300 | [diff] [blame] | 340 | }, |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 341 | .fwlog = { |
| 342 | .mode = WL12XX_FWLOG_ON_DEMAND, |
| 343 | .mem_blocks = 2, |
| 344 | .severity = 0, |
| 345 | .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED, |
| 346 | .output = WL12XX_FWLOG_OUTPUT_HOST, |
| 347 | .threshold = 0, |
| 348 | }, |
Luciano Coelho | afb7d3c | 2011-04-01 20:48:02 +0300 | [diff] [blame] | 349 | .hci_io_ds = HCI_IO_DS_6MA, |
Eliad Peller | fa6ad9f | 2011-08-14 13:17:14 +0300 | [diff] [blame] | 350 | .rate = { |
| 351 | .rate_retry_score = 32000, |
| 352 | .per_add = 8192, |
| 353 | .per_th1 = 2048, |
| 354 | .per_th2 = 4096, |
| 355 | .max_per = 8100, |
| 356 | .inverse_curiosity_factor = 5, |
| 357 | .tx_fail_low_th = 4, |
| 358 | .tx_fail_high_th = 10, |
| 359 | .per_alpha_shift = 4, |
| 360 | .per_add_shift = 13, |
| 361 | .per_beta1_shift = 10, |
| 362 | .per_beta2_shift = 8, |
| 363 | .rate_check_up = 2, |
| 364 | .rate_check_down = 12, |
| 365 | .rate_retry_policy = { |
| 366 | 0x00, 0x00, 0x00, 0x00, 0x00, |
| 367 | 0x00, 0x00, 0x00, 0x00, 0x00, |
| 368 | 0x00, 0x00, 0x00, |
| 369 | }, |
| 370 | }, |
Eliad Peller | 9487775 | 2011-08-28 15:11:56 +0300 | [diff] [blame] | 371 | .hangover = { |
| 372 | .recover_time = 0, |
| 373 | .hangover_period = 20, |
| 374 | .dynamic_mode = 1, |
| 375 | .early_termination_mode = 1, |
| 376 | .max_period = 20, |
| 377 | .min_period = 1, |
| 378 | .increase_delta = 1, |
| 379 | .decrease_delta = 2, |
| 380 | .quiet_time = 4, |
| 381 | .increase_time = 1, |
| 382 | .window_size = 16, |
| 383 | }, |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 384 | }; |
| 385 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 386 | static char *fwlog_param; |
Eliad Peller | 2a5bff0 | 2011-08-25 18:10:59 +0300 | [diff] [blame] | 387 | static bool bug_on_recovery; |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 388 | |
Arik Nemtsov | 7dece1c | 2011-04-18 14:15:28 +0300 | [diff] [blame] | 389 | static void __wl1271_op_remove_interface(struct wl1271 *wl, |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 390 | struct ieee80211_vif *vif, |
Arik Nemtsov | 7dece1c | 2011-04-18 14:15:28 +0300 | [diff] [blame] | 391 | bool reset_tx_queues); |
Eliad Peller | f027743 | 2011-10-10 10:13:14 +0200 | [diff] [blame] | 392 | static void wl1271_op_stop(struct ieee80211_hw *hw); |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 393 | static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 394 | |
Eliad Peller | 9fd6f21 | 2012-03-04 10:55:48 +0200 | [diff] [blame^] | 395 | static int wl12xx_set_authorized(struct wl1271 *wl, |
| 396 | struct wl12xx_vif *wlvif) |
Eliad Peller | ef4b29e | 2011-06-06 13:03:12 +0300 | [diff] [blame] | 397 | { |
| 398 | int ret; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 399 | |
Eliad Peller | 9fd6f21 | 2012-03-04 10:55:48 +0200 | [diff] [blame^] | 400 | if (WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS)) |
| 401 | return -EINVAL; |
| 402 | |
| 403 | if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) |
Eliad Peller | ef4b29e | 2011-06-06 13:03:12 +0300 | [diff] [blame] | 404 | return 0; |
| 405 | |
Eliad Peller | 8181aec | 2011-10-10 10:13:04 +0200 | [diff] [blame] | 406 | if (test_and_set_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags)) |
Eliad Peller | ef4b29e | 2011-06-06 13:03:12 +0300 | [diff] [blame] | 407 | return 0; |
| 408 | |
Eliad Peller | 154da67 | 2011-10-05 11:55:53 +0200 | [diff] [blame] | 409 | ret = wl12xx_cmd_set_peer_state(wl, wlvif->sta.hlid); |
Eliad Peller | ef4b29e | 2011-06-06 13:03:12 +0300 | [diff] [blame] | 410 | if (ret < 0) |
| 411 | return ret; |
| 412 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 413 | wl12xx_croc(wl, wlvif->role_id); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 414 | |
Eliad Peller | ef4b29e | 2011-06-06 13:03:12 +0300 | [diff] [blame] | 415 | wl1271_info("Association completed."); |
| 416 | return 0; |
| 417 | } |
Juuso Oikarinen | c2c192a | 2010-07-27 03:30:09 +0300 | [diff] [blame] | 418 | |
Juuso Oikarinen | b7417d9 | 2010-11-10 11:27:19 +0100 | [diff] [blame] | 419 | static int wl1271_reg_notify(struct wiphy *wiphy, |
Luciano Coelho | 573c67c | 2010-11-26 13:44:59 +0200 | [diff] [blame] | 420 | struct regulatory_request *request) |
| 421 | { |
Juuso Oikarinen | b7417d9 | 2010-11-10 11:27:19 +0100 | [diff] [blame] | 422 | struct ieee80211_supported_band *band; |
| 423 | struct ieee80211_channel *ch; |
| 424 | int i; |
| 425 | |
| 426 | band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 427 | for (i = 0; i < band->n_channels; i++) { |
| 428 | ch = &band->channels[i]; |
| 429 | if (ch->flags & IEEE80211_CHAN_DISABLED) |
| 430 | continue; |
| 431 | |
| 432 | if (ch->flags & IEEE80211_CHAN_RADAR) |
| 433 | ch->flags |= IEEE80211_CHAN_NO_IBSS | |
| 434 | IEEE80211_CHAN_PASSIVE_SCAN; |
| 435 | |
| 436 | } |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 441 | static int wl1271_set_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 442 | bool enable) |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 443 | { |
| 444 | int ret = 0; |
| 445 | |
| 446 | /* we should hold wl->mutex */ |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 447 | ret = wl1271_acx_ps_rx_streaming(wl, wlvif, enable); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 448 | if (ret < 0) |
| 449 | goto out; |
| 450 | |
| 451 | if (enable) |
Eliad Peller | 0744bdb | 2011-10-10 10:13:05 +0200 | [diff] [blame] | 452 | set_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 453 | else |
Eliad Peller | 0744bdb | 2011-10-10 10:13:05 +0200 | [diff] [blame] | 454 | clear_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 455 | out: |
| 456 | return ret; |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * this function is being called when the rx_streaming interval |
| 461 | * has beed changed or rx_streaming should be disabled |
| 462 | */ |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 463 | int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 464 | { |
| 465 | int ret = 0; |
| 466 | int period = wl->conf.rx_streaming.interval; |
| 467 | |
| 468 | /* don't reconfigure if rx_streaming is disabled */ |
Eliad Peller | 0744bdb | 2011-10-10 10:13:05 +0200 | [diff] [blame] | 469 | if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 470 | goto out; |
| 471 | |
| 472 | /* reconfigure/disable according to new streaming_period */ |
| 473 | if (period && |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 474 | test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 475 | (wl->conf.rx_streaming.always || |
| 476 | test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 477 | ret = wl1271_set_rx_streaming(wl, wlvif, true); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 478 | else { |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 479 | ret = wl1271_set_rx_streaming(wl, wlvif, false); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 480 | /* don't cancel_work_sync since we might deadlock */ |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 481 | del_timer_sync(&wlvif->rx_streaming_timer); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 482 | } |
| 483 | out: |
| 484 | return ret; |
| 485 | } |
| 486 | |
| 487 | static void wl1271_rx_streaming_enable_work(struct work_struct *work) |
| 488 | { |
| 489 | int ret; |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 490 | struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif, |
| 491 | rx_streaming_enable_work); |
| 492 | struct wl1271 *wl = wlvif->wl; |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 493 | |
| 494 | mutex_lock(&wl->mutex); |
| 495 | |
Eliad Peller | 0744bdb | 2011-10-10 10:13:05 +0200 | [diff] [blame] | 496 | if (test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags) || |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 497 | !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 498 | (!wl->conf.rx_streaming.always && |
| 499 | !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) |
| 500 | goto out; |
| 501 | |
| 502 | if (!wl->conf.rx_streaming.interval) |
| 503 | goto out; |
| 504 | |
| 505 | ret = wl1271_ps_elp_wakeup(wl); |
| 506 | if (ret < 0) |
| 507 | goto out; |
| 508 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 509 | ret = wl1271_set_rx_streaming(wl, wlvif, true); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 510 | if (ret < 0) |
| 511 | goto out_sleep; |
| 512 | |
| 513 | /* stop it after some time of inactivity */ |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 514 | mod_timer(&wlvif->rx_streaming_timer, |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 515 | jiffies + msecs_to_jiffies(wl->conf.rx_streaming.duration)); |
| 516 | |
| 517 | out_sleep: |
| 518 | wl1271_ps_elp_sleep(wl); |
| 519 | out: |
| 520 | mutex_unlock(&wl->mutex); |
| 521 | } |
| 522 | |
| 523 | static void wl1271_rx_streaming_disable_work(struct work_struct *work) |
| 524 | { |
| 525 | int ret; |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 526 | struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif, |
| 527 | rx_streaming_disable_work); |
| 528 | struct wl1271 *wl = wlvif->wl; |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 529 | |
| 530 | mutex_lock(&wl->mutex); |
| 531 | |
Eliad Peller | 0744bdb | 2011-10-10 10:13:05 +0200 | [diff] [blame] | 532 | if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 533 | goto out; |
| 534 | |
| 535 | ret = wl1271_ps_elp_wakeup(wl); |
| 536 | if (ret < 0) |
| 537 | goto out; |
| 538 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 539 | ret = wl1271_set_rx_streaming(wl, wlvif, false); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 540 | if (ret) |
| 541 | goto out_sleep; |
| 542 | |
| 543 | out_sleep: |
| 544 | wl1271_ps_elp_sleep(wl); |
| 545 | out: |
| 546 | mutex_unlock(&wl->mutex); |
| 547 | } |
| 548 | |
| 549 | static void wl1271_rx_streaming_timer(unsigned long data) |
| 550 | { |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 551 | struct wl12xx_vif *wlvif = (struct wl12xx_vif *)data; |
| 552 | struct wl1271 *wl = wlvif->wl; |
| 553 | ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_disable_work); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 554 | } |
| 555 | |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 556 | static void wl1271_conf_init(struct wl1271 *wl) |
| 557 | { |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 558 | |
| 559 | /* |
| 560 | * This function applies the default configuration to the driver. This |
| 561 | * function is invoked upon driver load (spi probe.) |
| 562 | * |
| 563 | * The configuration is stored in a run-time structure in order to |
| 564 | * facilitate for run-time adjustment of any of the parameters. Making |
| 565 | * changes to the configuration structure will apply the new values on |
| 566 | * the next interface up (wl1271_op_start.) |
| 567 | */ |
| 568 | |
| 569 | /* apply driver default configuration */ |
Juuso Oikarinen | 8a08048 | 2009-10-13 12:47:44 +0300 | [diff] [blame] | 570 | memcpy(&wl->conf, &default_conf, sizeof(default_conf)); |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 571 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 572 | /* Adjust settings according to optional module parameters */ |
| 573 | if (fwlog_param) { |
| 574 | if (!strcmp(fwlog_param, "continuous")) { |
| 575 | wl->conf.fwlog.mode = WL12XX_FWLOG_CONTINUOUS; |
| 576 | } else if (!strcmp(fwlog_param, "ondemand")) { |
| 577 | wl->conf.fwlog.mode = WL12XX_FWLOG_ON_DEMAND; |
| 578 | } else if (!strcmp(fwlog_param, "dbgpins")) { |
| 579 | wl->conf.fwlog.mode = WL12XX_FWLOG_CONTINUOUS; |
| 580 | wl->conf.fwlog.output = WL12XX_FWLOG_OUTPUT_DBG_PINS; |
| 581 | } else if (!strcmp(fwlog_param, "disable")) { |
| 582 | wl->conf.fwlog.mem_blocks = 0; |
| 583 | wl->conf.fwlog.output = WL12XX_FWLOG_OUTPUT_NONE; |
| 584 | } else { |
| 585 | wl1271_error("Unknown fwlog parameter %s", fwlog_param); |
| 586 | } |
| 587 | } |
| 588 | } |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 589 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 590 | static int wl1271_plt_init(struct wl1271 *wl) |
| 591 | { |
Eliad Peller | 188e7f5 | 2011-12-06 12:15:06 +0200 | [diff] [blame] | 592 | int ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 593 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 594 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 595 | ret = wl128x_cmd_general_parms(wl); |
| 596 | else |
| 597 | ret = wl1271_cmd_general_parms(wl); |
Luciano Coelho | 4a90406 | 2009-11-23 23:22:18 +0200 | [diff] [blame] | 598 | if (ret < 0) |
Luciano Coelho | cc7defa | 2009-11-23 23:22:16 +0200 | [diff] [blame] | 599 | return ret; |
| 600 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 601 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 602 | ret = wl128x_cmd_radio_parms(wl); |
| 603 | else |
| 604 | ret = wl1271_cmd_radio_parms(wl); |
Luciano Coelho | 4a90406 | 2009-11-23 23:22:18 +0200 | [diff] [blame] | 605 | if (ret < 0) |
Luciano Coelho | cc7defa | 2009-11-23 23:22:16 +0200 | [diff] [blame] | 606 | return ret; |
| 607 | |
Shahar Levi | 49d750ca | 2011-03-06 16:32:09 +0200 | [diff] [blame] | 608 | if (wl->chip.id != CHIP_ID_1283_PG20) { |
| 609 | ret = wl1271_cmd_ext_radio_parms(wl); |
| 610 | if (ret < 0) |
| 611 | return ret; |
| 612 | } |
Juuso Oikarinen | 644a486 | 2010-10-05 13:11:56 +0200 | [diff] [blame] | 613 | |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 614 | /* Chip-specific initializations */ |
| 615 | ret = wl1271_chip_specific_init(wl); |
| 616 | if (ret < 0) |
| 617 | return ret; |
| 618 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 619 | ret = wl1271_acx_init_mem_config(wl); |
| 620 | if (ret < 0) |
| 621 | return ret; |
| 622 | |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 623 | ret = wl12xx_acx_mem_cfg(wl); |
Gery Kahn | 1ec610e | 2011-02-01 03:03:08 -0600 | [diff] [blame] | 624 | if (ret < 0) |
| 625 | goto out_free_memmap; |
| 626 | |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 627 | /* Enable data path */ |
Luciano Coelho | 9421089 | 2009-12-11 15:40:55 +0200 | [diff] [blame] | 628 | ret = wl1271_cmd_data_path(wl, 1); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 629 | if (ret < 0) |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 630 | goto out_free_memmap; |
| 631 | |
| 632 | /* Configure for CAM power saving (ie. always active) */ |
| 633 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); |
| 634 | if (ret < 0) |
| 635 | goto out_free_memmap; |
| 636 | |
| 637 | /* configure PM */ |
| 638 | ret = wl1271_acx_pm_config(wl); |
| 639 | if (ret < 0) |
| 640 | goto out_free_memmap; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 641 | |
| 642 | return 0; |
Luciano Coelho | 12419cc | 2010-02-18 13:25:44 +0200 | [diff] [blame] | 643 | |
| 644 | out_free_memmap: |
| 645 | kfree(wl->target_mem_map); |
| 646 | wl->target_mem_map = NULL; |
| 647 | |
| 648 | return ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 649 | } |
| 650 | |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 651 | static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, |
| 652 | struct wl12xx_vif *wlvif, |
| 653 | u8 hlid, u8 tx_pkts) |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 654 | { |
Arik Nemtsov | da03209 | 2011-08-25 12:43:15 +0300 | [diff] [blame] | 655 | bool fw_ps, single_sta; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 656 | |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 657 | fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); |
Arik Nemtsov | da03209 | 2011-08-25 12:43:15 +0300 | [diff] [blame] | 658 | single_sta = (wl->active_sta_count == 1); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 659 | |
| 660 | /* |
| 661 | * Wake up from high level PS if the STA is asleep with too little |
Arik Nemtsov | 9b17f1b | 2011-08-14 13:17:35 +0300 | [diff] [blame] | 662 | * packets in FW or if the STA is awake. |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 663 | */ |
Arik Nemtsov | 9b17f1b | 2011-08-14 13:17:35 +0300 | [diff] [blame] | 664 | if (!fw_ps || tx_pkts < WL1271_PS_STA_MAX_PACKETS) |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 665 | wl12xx_ps_link_end(wl, wlvif, hlid); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 666 | |
Arik Nemtsov | da03209 | 2011-08-25 12:43:15 +0300 | [diff] [blame] | 667 | /* |
| 668 | * Start high-level PS if the STA is asleep with enough blocks in FW. |
| 669 | * Make an exception if this is the only connected station. In this |
| 670 | * case FW-memory congestion is not a problem. |
| 671 | */ |
| 672 | else if (!single_sta && fw_ps && tx_pkts >= WL1271_PS_STA_MAX_PACKETS) |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 673 | wl12xx_ps_link_start(wl, wlvif, hlid, true); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 674 | } |
| 675 | |
Arik Nemtsov | 9b17f1b | 2011-08-14 13:17:35 +0300 | [diff] [blame] | 676 | static void wl12xx_irq_update_links_status(struct wl1271 *wl, |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 677 | struct wl12xx_vif *wlvif, |
Arik Nemtsov | 9b17f1b | 2011-08-14 13:17:35 +0300 | [diff] [blame] | 678 | struct wl12xx_fw_status *status) |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 679 | { |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 680 | struct wl1271_link *lnk; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 681 | u32 cur_fw_ps_map; |
Arik Nemtsov | 9b17f1b | 2011-08-14 13:17:35 +0300 | [diff] [blame] | 682 | u8 hlid, cnt; |
| 683 | |
| 684 | /* TODO: also use link_fast_bitmap here */ |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 685 | |
| 686 | cur_fw_ps_map = le32_to_cpu(status->link_ps_bitmap); |
| 687 | if (wl->ap_fw_ps_map != cur_fw_ps_map) { |
| 688 | wl1271_debug(DEBUG_PSM, |
| 689 | "link ps prev 0x%x cur 0x%x changed 0x%x", |
| 690 | wl->ap_fw_ps_map, cur_fw_ps_map, |
| 691 | wl->ap_fw_ps_map ^ cur_fw_ps_map); |
| 692 | |
| 693 | wl->ap_fw_ps_map = cur_fw_ps_map; |
| 694 | } |
| 695 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 696 | for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, WL12XX_MAX_LINKS) { |
| 697 | lnk = &wl->links[hlid]; |
| 698 | cnt = status->tx_lnk_free_pkts[hlid] - lnk->prev_freed_pkts; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 699 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 700 | lnk->prev_freed_pkts = status->tx_lnk_free_pkts[hlid]; |
| 701 | lnk->allocated_pkts -= cnt; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 702 | |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 703 | wl12xx_irq_ps_regulate_link(wl, wlvif, hlid, |
| 704 | lnk->allocated_pkts); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 705 | } |
| 706 | } |
| 707 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 708 | static void wl12xx_fw_status(struct wl1271 *wl, |
| 709 | struct wl12xx_fw_status *status) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 710 | { |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 711 | struct wl12xx_vif *wlvif; |
Juuso Oikarinen | ac5e1e3 | 2010-02-22 08:38:38 +0200 | [diff] [blame] | 712 | struct timespec ts; |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 713 | u32 old_tx_blk_count = wl->tx_blocks_available; |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 714 | int avail, freed_blocks; |
Arik Nemtsov | bf54e30 | 2011-08-14 13:17:32 +0300 | [diff] [blame] | 715 | int i; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 716 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 717 | wl1271_raw_read(wl, FW_STATUS_ADDR, status, sizeof(*status), false); |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 718 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 719 | wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, " |
| 720 | "drv_rx_counter = %d, tx_results_counter = %d)", |
| 721 | status->intr, |
| 722 | status->fw_rx_counter, |
| 723 | status->drv_rx_counter, |
| 724 | status->tx_results_counter); |
| 725 | |
Arik Nemtsov | bf54e30 | 2011-08-14 13:17:32 +0300 | [diff] [blame] | 726 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
| 727 | /* prevent wrap-around in freed-packets counter */ |
Arik Nemtsov | 742246f | 2011-08-14 13:17:33 +0300 | [diff] [blame] | 728 | wl->tx_allocated_pkts[i] -= |
Arik Nemtsov | bf54e30 | 2011-08-14 13:17:32 +0300 | [diff] [blame] | 729 | (status->tx_released_pkts[i] - |
| 730 | wl->tx_pkts_freed[i]) & 0xff; |
| 731 | |
| 732 | wl->tx_pkts_freed[i] = status->tx_released_pkts[i]; |
| 733 | } |
| 734 | |
Arik Nemtsov | bdf91cf | 2011-08-14 13:17:34 +0300 | [diff] [blame] | 735 | /* prevent wrap-around in total blocks counter */ |
| 736 | if (likely(wl->tx_blocks_freed <= |
| 737 | le32_to_cpu(status->total_released_blks))) |
| 738 | freed_blocks = le32_to_cpu(status->total_released_blks) - |
| 739 | wl->tx_blocks_freed; |
| 740 | else |
| 741 | freed_blocks = 0x100000000LL - wl->tx_blocks_freed + |
| 742 | le32_to_cpu(status->total_released_blks); |
| 743 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 744 | wl->tx_blocks_freed = le32_to_cpu(status->total_released_blks); |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 745 | |
Arik Nemtsov | 7bb5d6c | 2011-08-14 13:17:00 +0300 | [diff] [blame] | 746 | wl->tx_allocated_blocks -= freed_blocks; |
| 747 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 748 | avail = le32_to_cpu(status->tx_total) - wl->tx_allocated_blocks; |
Ido Yariv | d2f4d47 | 2011-03-31 10:07:00 +0200 | [diff] [blame] | 749 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 750 | /* |
| 751 | * The FW might change the total number of TX memblocks before |
| 752 | * we get a notification about blocks being released. Thus, the |
| 753 | * available blocks calculation might yield a temporary result |
| 754 | * which is lower than the actual available blocks. Keeping in |
| 755 | * mind that only blocks that were allocated can be moved from |
| 756 | * TX to RX, tx_blocks_available should never decrease here. |
| 757 | */ |
| 758 | wl->tx_blocks_available = max((int)wl->tx_blocks_available, |
| 759 | avail); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 760 | |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 761 | /* if more blocks are available now, tx work can be scheduled */ |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 762 | if (wl->tx_blocks_available > old_tx_blk_count) |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 763 | clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 764 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 765 | /* for AP update num of allocated TX blocks per link and ps status */ |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 766 | wl12xx_for_each_wlvif_ap(wl, wlvif) { |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 767 | wl12xx_irq_update_links_status(wl, wlvif, status); |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 768 | } |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 769 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 770 | /* update the host-chipset time offset */ |
Juuso Oikarinen | ac5e1e3 | 2010-02-22 08:38:38 +0200 | [diff] [blame] | 771 | getnstimeofday(&ts); |
| 772 | wl->time_offset = (timespec_to_ns(&ts) >> 10) - |
| 773 | (s64)le32_to_cpu(status->fw_localtime); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 774 | } |
| 775 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 776 | static void wl1271_flush_deferred_work(struct wl1271 *wl) |
| 777 | { |
| 778 | struct sk_buff *skb; |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 779 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 780 | /* Pass all received frames to the network stack */ |
| 781 | while ((skb = skb_dequeue(&wl->deferred_rx_queue))) |
| 782 | ieee80211_rx_ni(wl->hw, skb); |
| 783 | |
| 784 | /* Return sent skbs to the network stack */ |
| 785 | while ((skb = skb_dequeue(&wl->deferred_tx_queue))) |
Eliad Peller | c27d3ac | 2011-06-07 10:40:39 +0300 | [diff] [blame] | 786 | ieee80211_tx_status_ni(wl->hw, skb); |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | static void wl1271_netstack_work(struct work_struct *work) |
| 790 | { |
| 791 | struct wl1271 *wl = |
| 792 | container_of(work, struct wl1271, netstack_work); |
| 793 | |
| 794 | do { |
| 795 | wl1271_flush_deferred_work(wl); |
| 796 | } while (skb_queue_len(&wl->deferred_rx_queue)); |
| 797 | } |
| 798 | |
| 799 | #define WL1271_IRQ_MAX_LOOPS 256 |
| 800 | |
Felipe Balbi | 4b32a2c | 2011-10-06 10:46:20 +0300 | [diff] [blame] | 801 | static irqreturn_t wl1271_irq(int irq, void *cookie) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 802 | { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 803 | int ret; |
Juuso Oikarinen | c15f63b | 2009-10-12 15:08:50 +0300 | [diff] [blame] | 804 | u32 intr; |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 805 | int loopcount = WL1271_IRQ_MAX_LOOPS; |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 806 | struct wl1271 *wl = (struct wl1271 *)cookie; |
| 807 | bool done = false; |
| 808 | unsigned int defer_count; |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 809 | unsigned long flags; |
| 810 | |
| 811 | /* TX might be handled here, avoid redundant work */ |
| 812 | set_bit(WL1271_FLAG_TX_PENDING, &wl->flags); |
| 813 | cancel_work_sync(&wl->tx_work); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 814 | |
Ido Yariv | 341b7cd | 2011-03-31 10:07:01 +0200 | [diff] [blame] | 815 | /* |
| 816 | * In case edge triggered interrupt must be used, we cannot iterate |
| 817 | * more than once without introducing race conditions with the hardirq. |
| 818 | */ |
| 819 | if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) |
| 820 | loopcount = 1; |
| 821 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 822 | mutex_lock(&wl->mutex); |
| 823 | |
| 824 | wl1271_debug(DEBUG_IRQ, "IRQ work"); |
| 825 | |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 826 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 827 | goto out; |
| 828 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 829 | ret = wl1271_ps_elp_wakeup(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 830 | if (ret < 0) |
| 831 | goto out; |
| 832 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 833 | while (!done && loopcount--) { |
| 834 | /* |
| 835 | * In order to avoid a race with the hardirq, clear the flag |
| 836 | * before acknowledging the chip. Since the mutex is held, |
| 837 | * wl1271_ps_elp_wakeup cannot be called concurrently. |
| 838 | */ |
| 839 | clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); |
| 840 | smp_mb__after_clear_bit(); |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 841 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 842 | wl12xx_fw_status(wl, wl->fw_status); |
| 843 | intr = le32_to_cpu(wl->fw_status->intr); |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 844 | intr &= WL1271_INTR_MASK; |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 845 | if (!intr) { |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 846 | done = true; |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 847 | continue; |
| 848 | } |
| 849 | |
Eliad Peller | ccc83b0 | 2010-10-27 14:09:57 +0200 | [diff] [blame] | 850 | if (unlikely(intr & WL1271_ACX_INTR_WATCHDOG)) { |
| 851 | wl1271_error("watchdog interrupt received! " |
| 852 | "starting recovery."); |
Ido Yariv | baacb9a | 2011-06-06 14:57:05 +0300 | [diff] [blame] | 853 | wl12xx_queue_recovery_work(wl); |
Eliad Peller | ccc83b0 | 2010-10-27 14:09:57 +0200 | [diff] [blame] | 854 | |
| 855 | /* restarting the chip. ignore any other interrupt. */ |
| 856 | goto out; |
| 857 | } |
| 858 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 859 | if (likely(intr & WL1271_ACX_INTR_DATA)) { |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 860 | wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_DATA"); |
| 861 | |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 862 | wl12xx_rx(wl, wl->fw_status); |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 863 | |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 864 | /* Check if any tx blocks were freed */ |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 865 | spin_lock_irqsave(&wl->wl_lock, flags); |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 866 | if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) && |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 867 | wl1271_tx_total_queue_count(wl) > 0) { |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 868 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 869 | /* |
| 870 | * In order to avoid starvation of the TX path, |
| 871 | * call the work function directly. |
| 872 | */ |
Eliad Peller | a32d0cd | 2011-10-10 10:12:55 +0200 | [diff] [blame] | 873 | wl1271_tx_work_locked(wl); |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 874 | } else { |
| 875 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 876 | } |
| 877 | |
Ido Yariv | 8aad246 | 2011-03-01 15:14:38 +0200 | [diff] [blame] | 878 | /* check for tx results */ |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 879 | if (wl->fw_status->tx_results_counter != |
Ido Yariv | 8aad246 | 2011-03-01 15:14:38 +0200 | [diff] [blame] | 880 | (wl->tx_results_count & 0xff)) |
| 881 | wl1271_tx_complete(wl); |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 882 | |
| 883 | /* Make sure the deferred queues don't get too long */ |
| 884 | defer_count = skb_queue_len(&wl->deferred_tx_queue) + |
| 885 | skb_queue_len(&wl->deferred_rx_queue); |
| 886 | if (defer_count > WL1271_DEFERRED_QUEUE_LIMIT) |
| 887 | wl1271_flush_deferred_work(wl); |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | if (intr & WL1271_ACX_INTR_EVENT_A) { |
| 891 | wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_EVENT_A"); |
| 892 | wl1271_event_handle(wl, 0); |
| 893 | } |
| 894 | |
| 895 | if (intr & WL1271_ACX_INTR_EVENT_B) { |
| 896 | wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_EVENT_B"); |
| 897 | wl1271_event_handle(wl, 1); |
| 898 | } |
| 899 | |
| 900 | if (intr & WL1271_ACX_INTR_INIT_COMPLETE) |
| 901 | wl1271_debug(DEBUG_IRQ, |
| 902 | "WL1271_ACX_INTR_INIT_COMPLETE"); |
| 903 | |
| 904 | if (intr & WL1271_ACX_INTR_HW_AVAILABLE) |
| 905 | wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_HW_AVAILABLE"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 906 | } |
| 907 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 908 | wl1271_ps_elp_sleep(wl); |
| 909 | |
| 910 | out: |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 911 | spin_lock_irqsave(&wl->wl_lock, flags); |
| 912 | /* In case TX was not handled here, queue TX work */ |
| 913 | clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags); |
| 914 | if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) && |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 915 | wl1271_tx_total_queue_count(wl) > 0) |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 916 | ieee80211_queue_work(wl->hw, &wl->tx_work); |
| 917 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 918 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 919 | mutex_unlock(&wl->mutex); |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 920 | |
| 921 | return IRQ_HANDLED; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 922 | } |
| 923 | |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 924 | struct vif_counter_data { |
| 925 | u8 counter; |
| 926 | |
| 927 | struct ieee80211_vif *cur_vif; |
| 928 | bool cur_vif_running; |
| 929 | }; |
| 930 | |
| 931 | static void wl12xx_vif_count_iter(void *data, u8 *mac, |
| 932 | struct ieee80211_vif *vif) |
| 933 | { |
| 934 | struct vif_counter_data *counter = data; |
| 935 | |
| 936 | counter->counter++; |
| 937 | if (counter->cur_vif == vif) |
| 938 | counter->cur_vif_running = true; |
| 939 | } |
| 940 | |
| 941 | /* caller must not hold wl->mutex, as it might deadlock */ |
| 942 | static void wl12xx_get_vif_count(struct ieee80211_hw *hw, |
| 943 | struct ieee80211_vif *cur_vif, |
| 944 | struct vif_counter_data *data) |
| 945 | { |
| 946 | memset(data, 0, sizeof(*data)); |
| 947 | data->cur_vif = cur_vif; |
| 948 | |
| 949 | ieee80211_iterate_active_interfaces(hw, |
| 950 | wl12xx_vif_count_iter, data); |
| 951 | } |
| 952 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 953 | static int wl12xx_fetch_firmware(struct wl1271 *wl, bool plt) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 954 | { |
| 955 | const struct firmware *fw; |
Arik Nemtsov | 166d504 | 2010-10-16 21:44:57 +0200 | [diff] [blame] | 956 | const char *fw_name; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 957 | enum wl12xx_fw_type fw_type; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 958 | int ret; |
| 959 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 960 | if (plt) { |
| 961 | fw_type = WL12XX_FW_TYPE_PLT; |
| 962 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 963 | fw_name = WL128X_PLT_FW_NAME; |
| 964 | else |
| 965 | fw_name = WL127X_PLT_FW_NAME; |
| 966 | } else { |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 967 | /* |
| 968 | * we can't call wl12xx_get_vif_count() here because |
| 969 | * wl->mutex is taken, so use the cached last_vif_count value |
| 970 | */ |
| 971 | if (wl->last_vif_count > 1) { |
| 972 | fw_type = WL12XX_FW_TYPE_MULTI; |
| 973 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 974 | fw_name = WL128X_FW_NAME_MULTI; |
| 975 | else |
| 976 | fw_name = WL127X_FW_NAME_MULTI; |
| 977 | } else { |
| 978 | fw_type = WL12XX_FW_TYPE_NORMAL; |
| 979 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 980 | fw_name = WL128X_FW_NAME_SINGLE; |
| 981 | else |
| 982 | fw_name = WL127X_FW_NAME_SINGLE; |
| 983 | } |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | if (wl->fw_type == fw_type) |
| 987 | return 0; |
Arik Nemtsov | 166d504 | 2010-10-16 21:44:57 +0200 | [diff] [blame] | 988 | |
| 989 | wl1271_debug(DEBUG_BOOT, "booting firmware %s", fw_name); |
| 990 | |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 991 | ret = request_firmware(&fw, fw_name, wl->dev); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 992 | |
| 993 | if (ret < 0) { |
Pontus Fuchs | 3589893 | 2011-11-30 15:35:09 +0100 | [diff] [blame] | 994 | wl1271_error("could not get firmware %s: %d", fw_name, ret); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 995 | return ret; |
| 996 | } |
| 997 | |
| 998 | if (fw->size % 4) { |
| 999 | wl1271_error("firmware size is not multiple of 32 bits: %zu", |
| 1000 | fw->size); |
| 1001 | ret = -EILSEQ; |
| 1002 | goto out; |
| 1003 | } |
| 1004 | |
Arik Nemtsov | 166d504 | 2010-10-16 21:44:57 +0200 | [diff] [blame] | 1005 | vfree(wl->fw); |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1006 | wl->fw_type = WL12XX_FW_TYPE_NONE; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1007 | wl->fw_len = fw->size; |
Juuso Oikarinen | 1fba497 | 2009-10-08 21:56:32 +0300 | [diff] [blame] | 1008 | wl->fw = vmalloc(wl->fw_len); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1009 | |
| 1010 | if (!wl->fw) { |
| 1011 | wl1271_error("could not allocate memory for the firmware"); |
| 1012 | ret = -ENOMEM; |
| 1013 | goto out; |
| 1014 | } |
| 1015 | |
| 1016 | memcpy(wl->fw, fw->data, wl->fw_len); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1017 | ret = 0; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1018 | wl->fw_type = fw_type; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1019 | out: |
| 1020 | release_firmware(fw); |
| 1021 | |
| 1022 | return ret; |
| 1023 | } |
| 1024 | |
| 1025 | static int wl1271_fetch_nvs(struct wl1271 *wl) |
| 1026 | { |
| 1027 | const struct firmware *fw; |
| 1028 | int ret; |
| 1029 | |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 1030 | ret = request_firmware(&fw, WL12XX_NVS_NAME, wl->dev); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1031 | |
| 1032 | if (ret < 0) { |
Pontus Fuchs | 3589893 | 2011-11-30 15:35:09 +0100 | [diff] [blame] | 1033 | wl1271_error("could not get nvs file %s: %d", WL12XX_NVS_NAME, |
| 1034 | ret); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1035 | return ret; |
| 1036 | } |
| 1037 | |
Shahar Levi | bc765bf | 2011-03-06 16:32:10 +0200 | [diff] [blame] | 1038 | wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1039 | |
| 1040 | if (!wl->nvs) { |
| 1041 | wl1271_error("could not allocate memory for the nvs file"); |
| 1042 | ret = -ENOMEM; |
| 1043 | goto out; |
| 1044 | } |
| 1045 | |
Juuso Oikarinen | 02fabb0 | 2010-08-19 04:41:15 +0200 | [diff] [blame] | 1046 | wl->nvs_len = fw->size; |
| 1047 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1048 | out: |
| 1049 | release_firmware(fw); |
| 1050 | |
| 1051 | return ret; |
| 1052 | } |
| 1053 | |
Ido Yariv | baacb9a | 2011-06-06 14:57:05 +0300 | [diff] [blame] | 1054 | void wl12xx_queue_recovery_work(struct wl1271 *wl) |
| 1055 | { |
| 1056 | if (!test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags)) |
| 1057 | ieee80211_queue_work(wl->hw, &wl->recovery_work); |
| 1058 | } |
| 1059 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 1060 | size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen) |
| 1061 | { |
| 1062 | size_t len = 0; |
| 1063 | |
| 1064 | /* The FW log is a length-value list, find where the log end */ |
| 1065 | while (len < maxlen) { |
| 1066 | if (memblock[len] == 0) |
| 1067 | break; |
| 1068 | if (len + memblock[len] + 1 > maxlen) |
| 1069 | break; |
| 1070 | len += memblock[len] + 1; |
| 1071 | } |
| 1072 | |
| 1073 | /* Make sure we have enough room */ |
| 1074 | len = min(len, (size_t)(PAGE_SIZE - wl->fwlog_size)); |
| 1075 | |
| 1076 | /* Fill the FW log file, consumed by the sysfs fwlog entry */ |
| 1077 | memcpy(wl->fwlog + wl->fwlog_size, memblock, len); |
| 1078 | wl->fwlog_size += len; |
| 1079 | |
| 1080 | return len; |
| 1081 | } |
| 1082 | |
| 1083 | static void wl12xx_read_fwlog_panic(struct wl1271 *wl) |
| 1084 | { |
| 1085 | u32 addr; |
| 1086 | u32 first_addr; |
| 1087 | u8 *block; |
| 1088 | |
| 1089 | if ((wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED) || |
| 1090 | (wl->conf.fwlog.mode != WL12XX_FWLOG_ON_DEMAND) || |
| 1091 | (wl->conf.fwlog.mem_blocks == 0)) |
| 1092 | return; |
| 1093 | |
| 1094 | wl1271_info("Reading FW panic log"); |
| 1095 | |
| 1096 | block = kmalloc(WL12XX_HW_BLOCK_SIZE, GFP_KERNEL); |
| 1097 | if (!block) |
| 1098 | return; |
| 1099 | |
| 1100 | /* |
| 1101 | * Make sure the chip is awake and the logger isn't active. |
| 1102 | * This might fail if the firmware hanged. |
| 1103 | */ |
| 1104 | if (!wl1271_ps_elp_wakeup(wl)) |
| 1105 | wl12xx_cmd_stop_fwlog(wl); |
| 1106 | |
| 1107 | /* Read the first memory block address */ |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 1108 | wl12xx_fw_status(wl, wl->fw_status); |
| 1109 | first_addr = le32_to_cpu(wl->fw_status->log_start_addr); |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 1110 | if (!first_addr) |
| 1111 | goto out; |
| 1112 | |
| 1113 | /* Traverse the memory blocks linked list */ |
| 1114 | addr = first_addr; |
| 1115 | do { |
| 1116 | memset(block, 0, WL12XX_HW_BLOCK_SIZE); |
| 1117 | wl1271_read_hwaddr(wl, addr, block, WL12XX_HW_BLOCK_SIZE, |
| 1118 | false); |
| 1119 | |
| 1120 | /* |
| 1121 | * Memory blocks are linked to one another. The first 4 bytes |
| 1122 | * of each memory block hold the hardware address of the next |
| 1123 | * one. The last memory block points to the first one. |
| 1124 | */ |
Eliad Peller | 4d56ad9 | 2011-08-14 13:17:05 +0300 | [diff] [blame] | 1125 | addr = le32_to_cpup((__le32 *)block); |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 1126 | if (!wl12xx_copy_fwlog(wl, block + sizeof(addr), |
| 1127 | WL12XX_HW_BLOCK_SIZE - sizeof(addr))) |
| 1128 | break; |
| 1129 | } while (addr && (addr != first_addr)); |
| 1130 | |
| 1131 | wake_up_interruptible(&wl->fwlog_waitq); |
| 1132 | |
| 1133 | out: |
| 1134 | kfree(block); |
| 1135 | } |
| 1136 | |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1137 | static void wl1271_recovery_work(struct work_struct *work) |
| 1138 | { |
| 1139 | struct wl1271 *wl = |
| 1140 | container_of(work, struct wl1271, recovery_work); |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 1141 | struct wl12xx_vif *wlvif; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 1142 | struct ieee80211_vif *vif; |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1143 | |
| 1144 | mutex_lock(&wl->mutex); |
| 1145 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1146 | if (wl->state != WL1271_STATE_ON || wl->plt) |
Eliad Peller | f027743 | 2011-10-10 10:13:14 +0200 | [diff] [blame] | 1147 | goto out_unlock; |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1148 | |
Ido Yariv | baacb9a | 2011-06-06 14:57:05 +0300 | [diff] [blame] | 1149 | /* Avoid a recursive recovery */ |
| 1150 | set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); |
| 1151 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 1152 | wl12xx_read_fwlog_panic(wl); |
| 1153 | |
Arik Nemtsov | 52dcaf5 | 2011-04-18 14:15:24 +0300 | [diff] [blame] | 1154 | wl1271_info("Hardware recovery in progress. FW ver: %s pc: 0x%x", |
| 1155 | wl->chip.fw_ver_str, wl1271_read32(wl, SCR_PAD4)); |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1156 | |
Eliad Peller | 2a5bff0 | 2011-08-25 18:10:59 +0300 | [diff] [blame] | 1157 | BUG_ON(bug_on_recovery); |
| 1158 | |
Oz Krakowski | b992c68 | 2011-06-26 10:36:02 +0300 | [diff] [blame] | 1159 | /* |
| 1160 | * Advance security sequence number to overcome potential progress |
| 1161 | * in the firmware during recovery. This doens't hurt if the network is |
| 1162 | * not encrypted. |
| 1163 | */ |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 1164 | wl12xx_for_each_wlvif(wl, wlvif) { |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 1165 | if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 1166 | test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 1167 | wlvif->tx_security_seq += |
| 1168 | WL1271_TX_SQN_POST_RECOVERY_PADDING; |
| 1169 | } |
Oz Krakowski | b992c68 | 2011-06-26 10:36:02 +0300 | [diff] [blame] | 1170 | |
Arik Nemtsov | 7dece1c | 2011-04-18 14:15:28 +0300 | [diff] [blame] | 1171 | /* Prevent spurious TX during FW restart */ |
| 1172 | ieee80211_stop_queues(wl->hw); |
| 1173 | |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 1174 | if (wl->sched_scanning) { |
| 1175 | ieee80211_sched_scan_stopped(wl->hw); |
| 1176 | wl->sched_scanning = false; |
| 1177 | } |
| 1178 | |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1179 | /* reboot the chipset */ |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 1180 | while (!list_empty(&wl->wlvif_list)) { |
| 1181 | wlvif = list_first_entry(&wl->wlvif_list, |
| 1182 | struct wl12xx_vif, list); |
| 1183 | vif = wl12xx_wlvif_to_vif(wlvif); |
| 1184 | __wl1271_op_remove_interface(wl, vif, false); |
| 1185 | } |
Eliad Peller | f027743 | 2011-10-10 10:13:14 +0200 | [diff] [blame] | 1186 | mutex_unlock(&wl->mutex); |
| 1187 | wl1271_op_stop(wl->hw); |
Ido Yariv | baacb9a | 2011-06-06 14:57:05 +0300 | [diff] [blame] | 1188 | |
| 1189 | clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); |
| 1190 | |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1191 | ieee80211_restart_hw(wl->hw); |
| 1192 | |
Arik Nemtsov | 7dece1c | 2011-04-18 14:15:28 +0300 | [diff] [blame] | 1193 | /* |
| 1194 | * Its safe to enable TX now - the queues are stopped after a request |
| 1195 | * to restart the HW. |
| 1196 | */ |
| 1197 | ieee80211_wake_queues(wl->hw); |
Eliad Peller | f027743 | 2011-10-10 10:13:14 +0200 | [diff] [blame] | 1198 | return; |
| 1199 | out_unlock: |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1200 | mutex_unlock(&wl->mutex); |
| 1201 | } |
| 1202 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1203 | static void wl1271_fw_wakeup(struct wl1271 *wl) |
| 1204 | { |
| 1205 | u32 elp_reg; |
| 1206 | |
| 1207 | elp_reg = ELPCTRL_WAKE_UP; |
Juuso Oikarinen | 7462141 | 2009-10-12 15:08:54 +0300 | [diff] [blame] | 1208 | wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1209 | } |
| 1210 | |
| 1211 | static int wl1271_setup(struct wl1271 *wl) |
| 1212 | { |
| 1213 | wl->fw_status = kmalloc(sizeof(*wl->fw_status), GFP_KERNEL); |
| 1214 | if (!wl->fw_status) |
| 1215 | return -ENOMEM; |
| 1216 | |
| 1217 | wl->tx_res_if = kmalloc(sizeof(*wl->tx_res_if), GFP_KERNEL); |
| 1218 | if (!wl->tx_res_if) { |
| 1219 | kfree(wl->fw_status); |
| 1220 | return -ENOMEM; |
| 1221 | } |
| 1222 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1223 | return 0; |
| 1224 | } |
| 1225 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 1226 | static int wl12xx_set_power_on(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1227 | { |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 1228 | int ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1229 | |
Juuso Oikarinen | 01ac17e | 2009-12-11 15:41:02 +0200 | [diff] [blame] | 1230 | msleep(WL1271_PRE_POWER_ON_SLEEP); |
Ohad Ben-Cohen | 2cc78ff | 2010-09-16 01:22:04 +0200 | [diff] [blame] | 1231 | ret = wl1271_power_on(wl); |
| 1232 | if (ret < 0) |
| 1233 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1234 | msleep(WL1271_POWER_ON_SLEEP); |
Teemu Paasikivi | 9b28072 | 2010-02-18 13:25:56 +0200 | [diff] [blame] | 1235 | wl1271_io_reset(wl); |
| 1236 | wl1271_io_init(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1237 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 1238 | wl1271_set_partition(wl, &wl12xx_part_table[PART_DOWN]); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1239 | |
| 1240 | /* ELP module wake up */ |
| 1241 | wl1271_fw_wakeup(wl); |
| 1242 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 1243 | out: |
| 1244 | return ret; |
| 1245 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1246 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1247 | static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt) |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 1248 | { |
| 1249 | int ret = 0; |
| 1250 | |
| 1251 | ret = wl12xx_set_power_on(wl); |
| 1252 | if (ret < 0) |
| 1253 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1254 | |
Luciano Coelho | e62c9ce | 2011-11-03 08:44:42 +0200 | [diff] [blame] | 1255 | /* |
| 1256 | * For wl127x based devices we could use the default block |
| 1257 | * size (512 bytes), but due to a bug in the sdio driver, we |
| 1258 | * need to set it explicitly after the chip is powered on. To |
| 1259 | * simplify the code and since the performance impact is |
| 1260 | * negligible, we use the same block size for all different |
| 1261 | * chip types. |
| 1262 | */ |
| 1263 | if (!wl1271_set_block_size(wl)) |
| 1264 | wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1265 | |
| 1266 | switch (wl->chip.id) { |
| 1267 | case CHIP_ID_1271_PG10: |
| 1268 | wl1271_warning("chip id 0x%x (1271 PG10) support is obsolete", |
| 1269 | wl->chip.id); |
| 1270 | |
| 1271 | ret = wl1271_setup(wl); |
| 1272 | if (ret < 0) |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1273 | goto out; |
Luciano Coelho | ce39def | 2011-11-03 08:44:41 +0200 | [diff] [blame] | 1274 | wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1275 | break; |
Luciano Coelho | ce39def | 2011-11-03 08:44:41 +0200 | [diff] [blame] | 1276 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1277 | case CHIP_ID_1271_PG20: |
| 1278 | wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)", |
| 1279 | wl->chip.id); |
| 1280 | |
| 1281 | ret = wl1271_setup(wl); |
| 1282 | if (ret < 0) |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1283 | goto out; |
Luciano Coelho | ce39def | 2011-11-03 08:44:41 +0200 | [diff] [blame] | 1284 | wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1285 | break; |
Luciano Coelho | ce39def | 2011-11-03 08:44:41 +0200 | [diff] [blame] | 1286 | |
Shahar Levi | 0830cee | 2011-03-06 16:32:20 +0200 | [diff] [blame] | 1287 | case CHIP_ID_1283_PG20: |
| 1288 | wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1283 PG20)", |
| 1289 | wl->chip.id); |
| 1290 | |
| 1291 | ret = wl1271_setup(wl); |
| 1292 | if (ret < 0) |
| 1293 | goto out; |
| 1294 | break; |
| 1295 | case CHIP_ID_1283_PG10: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1296 | default: |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1297 | wl1271_warning("unsupported chip id: 0x%x", wl->chip.id); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1298 | ret = -ENODEV; |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1299 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1300 | } |
| 1301 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1302 | ret = wl12xx_fetch_firmware(wl, plt); |
| 1303 | if (ret < 0) |
| 1304 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1305 | |
| 1306 | /* No NVS from netlink, try to get it from the filesystem */ |
| 1307 | if (wl->nvs == NULL) { |
| 1308 | ret = wl1271_fetch_nvs(wl); |
| 1309 | if (ret < 0) |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1310 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1311 | } |
| 1312 | |
| 1313 | out: |
| 1314 | return ret; |
| 1315 | } |
| 1316 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1317 | int wl1271_plt_start(struct wl1271 *wl) |
| 1318 | { |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1319 | int retries = WL1271_BOOT_RETRIES; |
Gery Kahn | 6f07b72 | 2011-07-18 14:21:49 +0300 | [diff] [blame] | 1320 | struct wiphy *wiphy = wl->hw->wiphy; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1321 | int ret; |
| 1322 | |
| 1323 | mutex_lock(&wl->mutex); |
| 1324 | |
| 1325 | wl1271_notice("power up"); |
| 1326 | |
| 1327 | if (wl->state != WL1271_STATE_OFF) { |
| 1328 | wl1271_error("cannot go into PLT state because not " |
| 1329 | "in off state: %d", wl->state); |
| 1330 | ret = -EBUSY; |
| 1331 | goto out; |
| 1332 | } |
| 1333 | |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1334 | while (retries) { |
| 1335 | retries--; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1336 | ret = wl12xx_chip_wakeup(wl, true); |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1337 | if (ret < 0) |
| 1338 | goto power_off; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1339 | |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1340 | ret = wl1271_boot(wl); |
| 1341 | if (ret < 0) |
| 1342 | goto power_off; |
| 1343 | |
| 1344 | ret = wl1271_plt_init(wl); |
| 1345 | if (ret < 0) |
| 1346 | goto irq_disable; |
| 1347 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1348 | wl->plt = true; |
| 1349 | wl->state = WL1271_STATE_ON; |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1350 | wl1271_notice("firmware booted in PLT mode (%s)", |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1351 | wl->chip.fw_ver_str); |
Luciano Coelho | e7ddf54 | 2011-03-10 15:24:57 +0200 | [diff] [blame] | 1352 | |
Gery Kahn | 6f07b72 | 2011-07-18 14:21:49 +0300 | [diff] [blame] | 1353 | /* update hw/fw version info in wiphy struct */ |
| 1354 | wiphy->hw_version = wl->chip.id; |
| 1355 | strncpy(wiphy->fw_version, wl->chip.fw_ver_str, |
| 1356 | sizeof(wiphy->fw_version)); |
| 1357 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1358 | goto out; |
| 1359 | |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1360 | irq_disable: |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1361 | mutex_unlock(&wl->mutex); |
| 1362 | /* Unlocking the mutex in the middle of handling is |
| 1363 | inherently unsafe. In this case we deem it safe to do, |
| 1364 | because we need to let any possibly pending IRQ out of |
| 1365 | the system (and while we are WL1271_STATE_OFF the IRQ |
| 1366 | work function will not do anything.) Also, any other |
| 1367 | possible concurrent operations will fail due to the |
| 1368 | current state, hence the wl1271 struct should be safe. */ |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 1369 | wl1271_disable_interrupts(wl); |
| 1370 | wl1271_flush_deferred_work(wl); |
| 1371 | cancel_work_sync(&wl->netstack_work); |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1372 | mutex_lock(&wl->mutex); |
| 1373 | power_off: |
| 1374 | wl1271_power_off(wl); |
| 1375 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1376 | |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 1377 | wl1271_error("firmware boot in PLT mode failed despite %d retries", |
| 1378 | WL1271_BOOT_RETRIES); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1379 | out: |
| 1380 | mutex_unlock(&wl->mutex); |
| 1381 | |
| 1382 | return ret; |
| 1383 | } |
| 1384 | |
Ido Yariv | f3df133 | 2012-01-11 09:42:39 +0200 | [diff] [blame] | 1385 | int wl1271_plt_stop(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1386 | { |
| 1387 | int ret = 0; |
| 1388 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1389 | wl1271_notice("power down"); |
| 1390 | |
Ido Yariv | 46b0cc9 | 2012-01-11 09:42:41 +0200 | [diff] [blame] | 1391 | /* |
| 1392 | * Interrupts must be disabled before setting the state to OFF. |
| 1393 | * Otherwise, the interrupt handler might be called and exit without |
| 1394 | * reading the interrupt status. |
| 1395 | */ |
| 1396 | wl1271_disable_interrupts(wl); |
Ido Yariv | f3df133 | 2012-01-11 09:42:39 +0200 | [diff] [blame] | 1397 | mutex_lock(&wl->mutex); |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1398 | if (!wl->plt) { |
Ido Yariv | f3df133 | 2012-01-11 09:42:39 +0200 | [diff] [blame] | 1399 | mutex_unlock(&wl->mutex); |
Ido Yariv | 46b0cc9 | 2012-01-11 09:42:41 +0200 | [diff] [blame] | 1400 | |
| 1401 | /* |
| 1402 | * This will not necessarily enable interrupts as interrupts |
| 1403 | * may have been disabled when op_stop was called. It will, |
| 1404 | * however, balance the above call to disable_interrupts(). |
| 1405 | */ |
| 1406 | wl1271_enable_interrupts(wl); |
| 1407 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1408 | wl1271_error("cannot power down because not in PLT " |
| 1409 | "state: %d", wl->state); |
| 1410 | ret = -EBUSY; |
| 1411 | goto out; |
| 1412 | } |
| 1413 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1414 | mutex_unlock(&wl->mutex); |
Ido Yariv | f3df133 | 2012-01-11 09:42:39 +0200 | [diff] [blame] | 1415 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 1416 | wl1271_flush_deferred_work(wl); |
| 1417 | cancel_work_sync(&wl->netstack_work); |
Juuso Oikarinen | 52b0e7a | 2010-09-21 06:23:31 +0200 | [diff] [blame] | 1418 | cancel_work_sync(&wl->recovery_work); |
Luciano Coelho | f6fbecc | 2012-01-11 09:42:42 +0200 | [diff] [blame] | 1419 | cancel_delayed_work_sync(&wl->elp_work); |
Ido Yariv | a454969 | 2012-01-11 09:42:40 +0200 | [diff] [blame] | 1420 | |
| 1421 | mutex_lock(&wl->mutex); |
| 1422 | wl1271_power_off(wl); |
Luciano Coelho | f6fbecc | 2012-01-11 09:42:42 +0200 | [diff] [blame] | 1423 | wl->flags = 0; |
| 1424 | wl->state = WL1271_STATE_OFF; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1425 | wl->plt = false; |
Luciano Coelho | f6fbecc | 2012-01-11 09:42:42 +0200 | [diff] [blame] | 1426 | wl->rx_counter = 0; |
Ido Yariv | a454969 | 2012-01-11 09:42:40 +0200 | [diff] [blame] | 1427 | mutex_unlock(&wl->mutex); |
| 1428 | |
Juuso Oikarinen | 4ae3fa8 | 2011-01-14 12:48:46 +0100 | [diff] [blame] | 1429 | out: |
| 1430 | return ret; |
| 1431 | } |
Juuso Oikarinen | 8c7f4f3 | 2010-09-21 06:23:29 +0200 | [diff] [blame] | 1432 | |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 1433 | static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1434 | { |
| 1435 | struct wl1271 *wl = hw->priv; |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 1436 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 1437 | struct ieee80211_vif *vif = info->control.vif; |
Eliad Peller | 0f16801 | 2011-10-11 13:52:25 +0200 | [diff] [blame] | 1438 | struct wl12xx_vif *wlvif = NULL; |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 1439 | unsigned long flags; |
Arik Nemtsov | 708bb3c | 2011-06-24 13:03:37 +0300 | [diff] [blame] | 1440 | int q, mapping; |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 1441 | u8 hlid; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1442 | |
Eliad Peller | 0f16801 | 2011-10-11 13:52:25 +0200 | [diff] [blame] | 1443 | if (vif) |
| 1444 | wlvif = wl12xx_vif_to_data(vif); |
| 1445 | |
Arik Nemtsov | 708bb3c | 2011-06-24 13:03:37 +0300 | [diff] [blame] | 1446 | mapping = skb_get_queue_mapping(skb); |
| 1447 | q = wl1271_tx_get_queue(mapping); |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 1448 | |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 1449 | hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 1450 | |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 1451 | spin_lock_irqsave(&wl->wl_lock, flags); |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 1452 | |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 1453 | /* queue the packet */ |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 1454 | if (hlid == WL12XX_INVALID_LINK_ID || |
Eliad Peller | 0f16801 | 2011-10-11 13:52:25 +0200 | [diff] [blame] | 1455 | (wlvif && !test_bit(hlid, wlvif->links_map))) { |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 1456 | wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); |
Eliad Peller | 5de8eef | 2011-12-13 15:26:38 +0200 | [diff] [blame] | 1457 | ieee80211_free_txskb(hw, skb); |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 1458 | goto out; |
Arik Nemtsov | a8c0ddb | 2011-02-23 00:22:26 +0200 | [diff] [blame] | 1459 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1460 | |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 1461 | wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q); |
| 1462 | skb_queue_tail(&wl->links[hlid].tx_queue[q], skb); |
| 1463 | |
Arik Nemtsov | 04b4d69 | 2011-08-14 13:17:39 +0300 | [diff] [blame] | 1464 | wl->tx_queue_count[q]++; |
| 1465 | |
| 1466 | /* |
| 1467 | * The workqueue is slow to process the tx_queue and we need stop |
| 1468 | * the queue here, otherwise the queue will get too long. |
| 1469 | */ |
| 1470 | if (wl->tx_queue_count[q] >= WL1271_TX_QUEUE_HIGH_WATERMARK) { |
| 1471 | wl1271_debug(DEBUG_TX, "op_tx: stopping queues for q %d", q); |
| 1472 | ieee80211_stop_queue(wl->hw, mapping); |
| 1473 | set_bit(q, &wl->stopped_queues_map); |
| 1474 | } |
| 1475 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1476 | /* |
| 1477 | * The chip specific setup must run before the first TX packet - |
| 1478 | * before that, the tx_work will not be initialized! |
| 1479 | */ |
| 1480 | |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 1481 | if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) && |
| 1482 | !test_bit(WL1271_FLAG_TX_PENDING, &wl->flags)) |
Ido Yariv | a522550 | 2010-10-12 14:49:10 +0200 | [diff] [blame] | 1483 | ieee80211_queue_work(wl->hw, &wl->tx_work); |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 1484 | |
Arik Nemtsov | 04216da | 2011-08-14 13:17:38 +0300 | [diff] [blame] | 1485 | out: |
Ido Yariv | b07d403 | 2011-03-01 15:14:43 +0200 | [diff] [blame] | 1486 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1487 | } |
| 1488 | |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1489 | int wl1271_tx_dummy_packet(struct wl1271 *wl) |
| 1490 | { |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1491 | unsigned long flags; |
Arik Nemtsov | 1462378 | 2011-08-28 15:11:57 +0300 | [diff] [blame] | 1492 | int q; |
| 1493 | |
| 1494 | /* no need to queue a new dummy packet if one is already pending */ |
| 1495 | if (test_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) |
| 1496 | return 0; |
| 1497 | |
| 1498 | q = wl1271_tx_get_queue(skb_get_queue_mapping(wl->dummy_packet)); |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1499 | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1500 | spin_lock_irqsave(&wl->wl_lock, flags); |
| 1501 | set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 1502 | wl->tx_queue_count[q]++; |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1503 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 1504 | |
| 1505 | /* The FW is low on RX memory blocks, so send the dummy packet asap */ |
| 1506 | if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) |
Eliad Peller | a32d0cd | 2011-10-10 10:12:55 +0200 | [diff] [blame] | 1507 | wl1271_tx_work_locked(wl); |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1508 | |
| 1509 | /* |
| 1510 | * If the FW TX is busy, TX work will be scheduled by the threaded |
| 1511 | * interrupt handler function |
| 1512 | */ |
| 1513 | return 0; |
| 1514 | } |
| 1515 | |
| 1516 | /* |
| 1517 | * The size of the dummy packet should be at least 1400 bytes. However, in |
| 1518 | * order to minimize the number of bus transactions, aligning it to 512 bytes |
| 1519 | * boundaries could be beneficial, performance wise |
| 1520 | */ |
| 1521 | #define TOTAL_TX_DUMMY_PACKET_SIZE (ALIGN(1400, 512)) |
| 1522 | |
Luciano Coelho | cf27d86 | 2011-04-01 21:08:23 +0300 | [diff] [blame] | 1523 | static struct sk_buff *wl12xx_alloc_dummy_packet(struct wl1271 *wl) |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1524 | { |
| 1525 | struct sk_buff *skb; |
| 1526 | struct ieee80211_hdr_3addr *hdr; |
| 1527 | unsigned int dummy_packet_size; |
| 1528 | |
| 1529 | dummy_packet_size = TOTAL_TX_DUMMY_PACKET_SIZE - |
| 1530 | sizeof(struct wl1271_tx_hw_descr) - sizeof(*hdr); |
| 1531 | |
| 1532 | skb = dev_alloc_skb(TOTAL_TX_DUMMY_PACKET_SIZE); |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1533 | if (!skb) { |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1534 | wl1271_warning("Failed to allocate a dummy packet skb"); |
| 1535 | return NULL; |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1536 | } |
| 1537 | |
| 1538 | skb_reserve(skb, sizeof(struct wl1271_tx_hw_descr)); |
| 1539 | |
| 1540 | hdr = (struct ieee80211_hdr_3addr *) skb_put(skb, sizeof(*hdr)); |
| 1541 | memset(hdr, 0, sizeof(*hdr)); |
| 1542 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1543 | IEEE80211_STYPE_NULLFUNC | |
| 1544 | IEEE80211_FCTL_TODS); |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1545 | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1546 | memset(skb_put(skb, dummy_packet_size), 0, dummy_packet_size); |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1547 | |
Luciano Coelho | 18b92ff | 2011-03-21 16:35:21 +0200 | [diff] [blame] | 1548 | /* Dummy packets require the TID to be management */ |
| 1549 | skb->priority = WL1271_TID_MGMT; |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1550 | |
| 1551 | /* Initialize all fields that might be used */ |
Hauke Mehrtens | 86c438f | 2011-04-26 23:27:44 +0200 | [diff] [blame] | 1552 | skb_set_queue_mapping(skb, 0); |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1553 | memset(IEEE80211_SKB_CB(skb), 0, sizeof(struct ieee80211_tx_info)); |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1554 | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1555 | return skb; |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 1556 | } |
| 1557 | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 1558 | |
Luciano Coelho | f634a4e | 2011-05-18 16:51:26 -0400 | [diff] [blame] | 1559 | #ifdef CONFIG_PM |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 1560 | static int wl1271_configure_suspend_sta(struct wl1271 *wl, |
| 1561 | struct wl12xx_vif *wlvif) |
| 1562 | { |
| 1563 | int ret = 0; |
| 1564 | |
| 1565 | mutex_lock(&wl->mutex); |
| 1566 | |
| 1567 | if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) |
| 1568 | goto out_unlock; |
| 1569 | |
| 1570 | ret = wl1271_ps_elp_wakeup(wl); |
| 1571 | if (ret < 0) |
| 1572 | goto out_unlock; |
| 1573 | |
| 1574 | ret = wl1271_acx_wake_up_conditions(wl, wlvif, |
| 1575 | wl->conf.conn.suspend_wake_up_event, |
| 1576 | wl->conf.conn.suspend_listen_interval); |
| 1577 | |
| 1578 | if (ret < 0) |
| 1579 | wl1271_error("suspend: set wake up conditions failed: %d", ret); |
| 1580 | |
| 1581 | |
| 1582 | wl1271_ps_elp_sleep(wl); |
| 1583 | |
| 1584 | out_unlock: |
| 1585 | mutex_unlock(&wl->mutex); |
| 1586 | return ret; |
| 1587 | |
| 1588 | } |
Eliad Peller | 9439064 | 2011-05-13 11:57:13 +0300 | [diff] [blame] | 1589 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1590 | static int wl1271_configure_suspend_ap(struct wl1271 *wl, |
| 1591 | struct wl12xx_vif *wlvif) |
Eliad Peller | 9439064 | 2011-05-13 11:57:13 +0300 | [diff] [blame] | 1592 | { |
Eliad Peller | e85d162 | 2011-06-27 13:06:43 +0300 | [diff] [blame] | 1593 | int ret = 0; |
Eliad Peller | 9439064 | 2011-05-13 11:57:13 +0300 | [diff] [blame] | 1594 | |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1595 | mutex_lock(&wl->mutex); |
| 1596 | |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 1597 | if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) |
Eliad Peller | e85d162 | 2011-06-27 13:06:43 +0300 | [diff] [blame] | 1598 | goto out_unlock; |
| 1599 | |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1600 | ret = wl1271_ps_elp_wakeup(wl); |
| 1601 | if (ret < 0) |
| 1602 | goto out_unlock; |
| 1603 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1604 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1605 | |
| 1606 | wl1271_ps_elp_sleep(wl); |
| 1607 | out_unlock: |
| 1608 | mutex_unlock(&wl->mutex); |
| 1609 | return ret; |
| 1610 | |
| 1611 | } |
| 1612 | |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 1613 | static int wl1271_configure_suspend(struct wl1271 *wl, |
| 1614 | struct wl12xx_vif *wlvif) |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1615 | { |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 1616 | if (wlvif->bss_type == BSS_TYPE_STA_BSS) |
| 1617 | return wl1271_configure_suspend_sta(wl, wlvif); |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 1618 | if (wlvif->bss_type == BSS_TYPE_AP_BSS) |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1619 | return wl1271_configure_suspend_ap(wl, wlvif); |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1620 | return 0; |
| 1621 | } |
| 1622 | |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 1623 | static void wl1271_configure_resume(struct wl1271 *wl, |
| 1624 | struct wl12xx_vif *wlvif) |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1625 | { |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 1626 | int ret = 0; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 1627 | bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS; |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 1628 | bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; |
Eliad Peller | 8a7cf3f | 2011-06-06 12:21:54 +0300 | [diff] [blame] | 1629 | |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 1630 | if ((!is_ap) && (!is_sta)) |
Eliad Peller | 9439064 | 2011-05-13 11:57:13 +0300 | [diff] [blame] | 1631 | return; |
| 1632 | |
| 1633 | mutex_lock(&wl->mutex); |
| 1634 | ret = wl1271_ps_elp_wakeup(wl); |
| 1635 | if (ret < 0) |
| 1636 | goto out; |
| 1637 | |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 1638 | if (is_sta) { |
| 1639 | ret = wl1271_acx_wake_up_conditions(wl, wlvif, |
| 1640 | wl->conf.conn.wake_up_event, |
| 1641 | wl->conf.conn.listen_interval); |
| 1642 | |
| 1643 | if (ret < 0) |
| 1644 | wl1271_error("resume: wake up conditions failed: %d", |
| 1645 | ret); |
| 1646 | |
| 1647 | } else if (is_ap) { |
| 1648 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); |
| 1649 | } |
Eliad Peller | 9439064 | 2011-05-13 11:57:13 +0300 | [diff] [blame] | 1650 | |
| 1651 | wl1271_ps_elp_sleep(wl); |
| 1652 | out: |
| 1653 | mutex_unlock(&wl->mutex); |
| 1654 | } |
| 1655 | |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 1656 | static int wl1271_op_suspend(struct ieee80211_hw *hw, |
| 1657 | struct cfg80211_wowlan *wow) |
| 1658 | { |
| 1659 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 1660 | struct wl12xx_vif *wlvif; |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1661 | int ret; |
| 1662 | |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 1663 | wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1664 | WARN_ON(!wow || !wow->any); |
Eliad Peller | f44e586 | 2011-05-13 11:57:11 +0300 | [diff] [blame] | 1665 | |
Arik Nemtsov | b9239b6 | 2012-02-28 00:41:33 +0200 | [diff] [blame] | 1666 | wl1271_tx_flush(wl); |
| 1667 | |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1668 | wl->wow_enabled = true; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 1669 | wl12xx_for_each_wlvif(wl, wlvif) { |
| 1670 | ret = wl1271_configure_suspend(wl, wlvif); |
| 1671 | if (ret < 0) { |
| 1672 | wl1271_warning("couldn't prepare device to suspend"); |
| 1673 | return ret; |
| 1674 | } |
Eliad Peller | f44e586 | 2011-05-13 11:57:11 +0300 | [diff] [blame] | 1675 | } |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1676 | /* flush any remaining work */ |
| 1677 | wl1271_debug(DEBUG_MAC80211, "flushing remaining works"); |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1678 | |
| 1679 | /* |
| 1680 | * disable and re-enable interrupts in order to flush |
| 1681 | * the threaded_irq |
| 1682 | */ |
| 1683 | wl1271_disable_interrupts(wl); |
| 1684 | |
| 1685 | /* |
| 1686 | * set suspended flag to avoid triggering a new threaded_irq |
| 1687 | * work. no need for spinlock as interrupts are disabled. |
| 1688 | */ |
| 1689 | set_bit(WL1271_FLAG_SUSPENDED, &wl->flags); |
| 1690 | |
| 1691 | wl1271_enable_interrupts(wl); |
| 1692 | flush_work(&wl->tx_work); |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1693 | flush_delayed_work(&wl->elp_work); |
| 1694 | |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 1695 | return 0; |
| 1696 | } |
| 1697 | |
| 1698 | static int wl1271_op_resume(struct ieee80211_hw *hw) |
| 1699 | { |
| 1700 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 1701 | struct wl12xx_vif *wlvif; |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1702 | unsigned long flags; |
| 1703 | bool run_irq_work = false; |
| 1704 | |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 1705 | wl1271_debug(DEBUG_MAC80211, "mac80211 resume wow=%d", |
| 1706 | wl->wow_enabled); |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1707 | WARN_ON(!wl->wow_enabled); |
Eliad Peller | f44e586 | 2011-05-13 11:57:11 +0300 | [diff] [blame] | 1708 | |
| 1709 | /* |
| 1710 | * re-enable irq_work enqueuing, and call irq_work directly if |
| 1711 | * there is a pending work. |
| 1712 | */ |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1713 | spin_lock_irqsave(&wl->wl_lock, flags); |
| 1714 | clear_bit(WL1271_FLAG_SUSPENDED, &wl->flags); |
| 1715 | if (test_and_clear_bit(WL1271_FLAG_PENDING_WORK, &wl->flags)) |
| 1716 | run_irq_work = true; |
| 1717 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
Eliad Peller | f44e586 | 2011-05-13 11:57:11 +0300 | [diff] [blame] | 1718 | |
Eliad Peller | 4a859df | 2011-06-06 12:21:52 +0300 | [diff] [blame] | 1719 | if (run_irq_work) { |
| 1720 | wl1271_debug(DEBUG_MAC80211, |
| 1721 | "run postponed irq_work directly"); |
| 1722 | wl1271_irq(0, wl); |
| 1723 | wl1271_enable_interrupts(wl); |
Eliad Peller | f44e586 | 2011-05-13 11:57:11 +0300 | [diff] [blame] | 1724 | } |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 1725 | wl12xx_for_each_wlvif(wl, wlvif) { |
| 1726 | wl1271_configure_resume(wl, wlvif); |
| 1727 | } |
Eliad Peller | ff91afc | 2011-06-06 12:21:53 +0300 | [diff] [blame] | 1728 | wl->wow_enabled = false; |
Eliad Peller | f44e586 | 2011-05-13 11:57:11 +0300 | [diff] [blame] | 1729 | |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 1730 | return 0; |
| 1731 | } |
Luciano Coelho | f634a4e | 2011-05-18 16:51:26 -0400 | [diff] [blame] | 1732 | #endif |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 1733 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1734 | static int wl1271_op_start(struct ieee80211_hw *hw) |
| 1735 | { |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 1736 | wl1271_debug(DEBUG_MAC80211, "mac80211 start"); |
| 1737 | |
| 1738 | /* |
| 1739 | * We have to delay the booting of the hardware because |
| 1740 | * we need to know the local MAC address before downloading and |
| 1741 | * initializing the firmware. The MAC address cannot be changed |
| 1742 | * after boot, and without the proper MAC address, the firmware |
| 1743 | * will not function properly. |
| 1744 | * |
| 1745 | * The MAC address is first known when the corresponding interface |
| 1746 | * is added. That is where we will initialize the hardware. |
| 1747 | */ |
| 1748 | |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 1749 | return 0; |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 1750 | } |
| 1751 | |
| 1752 | static void wl1271_op_stop(struct ieee80211_hw *hw) |
| 1753 | { |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 1754 | struct wl1271 *wl = hw->priv; |
| 1755 | int i; |
| 1756 | |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 1757 | wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 1758 | |
Ido Yariv | 46b0cc9 | 2012-01-11 09:42:41 +0200 | [diff] [blame] | 1759 | /* |
| 1760 | * Interrupts must be disabled before setting the state to OFF. |
| 1761 | * Otherwise, the interrupt handler might be called and exit without |
| 1762 | * reading the interrupt status. |
| 1763 | */ |
| 1764 | wl1271_disable_interrupts(wl); |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 1765 | mutex_lock(&wl->mutex); |
| 1766 | if (wl->state == WL1271_STATE_OFF) { |
| 1767 | mutex_unlock(&wl->mutex); |
Ido Yariv | 46b0cc9 | 2012-01-11 09:42:41 +0200 | [diff] [blame] | 1768 | |
| 1769 | /* |
| 1770 | * This will not necessarily enable interrupts as interrupts |
| 1771 | * may have been disabled when op_stop was called. It will, |
| 1772 | * however, balance the above call to disable_interrupts(). |
| 1773 | */ |
| 1774 | wl1271_enable_interrupts(wl); |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 1775 | return; |
| 1776 | } |
Ido Yariv | 46b0cc9 | 2012-01-11 09:42:41 +0200 | [diff] [blame] | 1777 | |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 1778 | /* |
| 1779 | * this must be before the cancel_work calls below, so that the work |
| 1780 | * functions don't perform further work. |
| 1781 | */ |
| 1782 | wl->state = WL1271_STATE_OFF; |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 1783 | mutex_unlock(&wl->mutex); |
| 1784 | |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 1785 | wl1271_flush_deferred_work(wl); |
| 1786 | cancel_delayed_work_sync(&wl->scan_complete_work); |
| 1787 | cancel_work_sync(&wl->netstack_work); |
| 1788 | cancel_work_sync(&wl->tx_work); |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 1789 | cancel_delayed_work_sync(&wl->elp_work); |
| 1790 | |
| 1791 | /* let's notify MAC80211 about the remaining pending TX frames */ |
| 1792 | wl12xx_tx_reset(wl, true); |
| 1793 | mutex_lock(&wl->mutex); |
| 1794 | |
| 1795 | wl1271_power_off(wl); |
| 1796 | |
| 1797 | wl->band = IEEE80211_BAND_2GHZ; |
| 1798 | |
| 1799 | wl->rx_counter = 0; |
| 1800 | wl->power_level = WL1271_DEFAULT_POWER_LEVEL; |
| 1801 | wl->tx_blocks_available = 0; |
| 1802 | wl->tx_allocated_blocks = 0; |
| 1803 | wl->tx_results_count = 0; |
| 1804 | wl->tx_packets_count = 0; |
| 1805 | wl->time_offset = 0; |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 1806 | wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; |
| 1807 | wl->ap_fw_ps_map = 0; |
| 1808 | wl->ap_ps_map = 0; |
| 1809 | wl->sched_scanning = false; |
| 1810 | memset(wl->roles_map, 0, sizeof(wl->roles_map)); |
| 1811 | memset(wl->links_map, 0, sizeof(wl->links_map)); |
| 1812 | memset(wl->roc_map, 0, sizeof(wl->roc_map)); |
| 1813 | wl->active_sta_count = 0; |
| 1814 | |
| 1815 | /* The system link is always allocated */ |
| 1816 | __set_bit(WL12XX_SYSTEM_HLID, wl->links_map); |
| 1817 | |
| 1818 | /* |
| 1819 | * this is performed after the cancel_work calls and the associated |
| 1820 | * mutex_lock, so that wl1271_op_add_interface does not accidentally |
| 1821 | * get executed before all these vars have been reset. |
| 1822 | */ |
| 1823 | wl->flags = 0; |
| 1824 | |
| 1825 | wl->tx_blocks_freed = 0; |
| 1826 | |
| 1827 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
| 1828 | wl->tx_pkts_freed[i] = 0; |
| 1829 | wl->tx_allocated_pkts[i] = 0; |
| 1830 | } |
| 1831 | |
| 1832 | wl1271_debugfs_reset(wl); |
| 1833 | |
| 1834 | kfree(wl->fw_status); |
| 1835 | wl->fw_status = NULL; |
| 1836 | kfree(wl->tx_res_if); |
| 1837 | wl->tx_res_if = NULL; |
| 1838 | kfree(wl->target_mem_map); |
| 1839 | wl->target_mem_map = NULL; |
| 1840 | |
| 1841 | mutex_unlock(&wl->mutex); |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 1842 | } |
| 1843 | |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 1844 | static int wl12xx_allocate_rate_policy(struct wl1271 *wl, u8 *idx) |
| 1845 | { |
| 1846 | u8 policy = find_first_zero_bit(wl->rate_policies_map, |
| 1847 | WL12XX_MAX_RATE_POLICIES); |
| 1848 | if (policy >= WL12XX_MAX_RATE_POLICIES) |
| 1849 | return -EBUSY; |
| 1850 | |
| 1851 | __set_bit(policy, wl->rate_policies_map); |
| 1852 | *idx = policy; |
| 1853 | return 0; |
| 1854 | } |
| 1855 | |
| 1856 | static void wl12xx_free_rate_policy(struct wl1271 *wl, u8 *idx) |
| 1857 | { |
| 1858 | if (WARN_ON(*idx >= WL12XX_MAX_RATE_POLICIES)) |
| 1859 | return; |
| 1860 | |
| 1861 | __clear_bit(*idx, wl->rate_policies_map); |
| 1862 | *idx = WL12XX_MAX_RATE_POLICIES; |
| 1863 | } |
| 1864 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 1865 | static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 1866 | { |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 1867 | switch (wlvif->bss_type) { |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 1868 | case BSS_TYPE_AP_BSS: |
Eliad Peller | fb0e707 | 2011-10-05 11:55:47 +0200 | [diff] [blame] | 1869 | if (wlvif->p2p) |
Eliad Peller | 045c745 | 2011-08-28 15:23:01 +0300 | [diff] [blame] | 1870 | return WL1271_ROLE_P2P_GO; |
| 1871 | else |
| 1872 | return WL1271_ROLE_AP; |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 1873 | |
| 1874 | case BSS_TYPE_STA_BSS: |
Eliad Peller | fb0e707 | 2011-10-05 11:55:47 +0200 | [diff] [blame] | 1875 | if (wlvif->p2p) |
Eliad Peller | 045c745 | 2011-08-28 15:23:01 +0300 | [diff] [blame] | 1876 | return WL1271_ROLE_P2P_CL; |
| 1877 | else |
| 1878 | return WL1271_ROLE_STA; |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 1879 | |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 1880 | case BSS_TYPE_IBSS: |
| 1881 | return WL1271_ROLE_IBSS; |
| 1882 | |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 1883 | default: |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 1884 | wl1271_error("invalid bss_type: %d", wlvif->bss_type); |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 1885 | } |
| 1886 | return WL12XX_INVALID_ROLE_TYPE; |
| 1887 | } |
| 1888 | |
Eliad Peller | 8358750 | 2011-10-10 10:12:53 +0200 | [diff] [blame] | 1889 | static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 1890 | { |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1891 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 1892 | int i; |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1893 | |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 1894 | /* clear everything but the persistent data */ |
| 1895 | memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent)); |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1896 | |
| 1897 | switch (ieee80211_vif_type_p2p(vif)) { |
| 1898 | case NL80211_IFTYPE_P2P_CLIENT: |
| 1899 | wlvif->p2p = 1; |
| 1900 | /* fall-through */ |
| 1901 | case NL80211_IFTYPE_STATION: |
| 1902 | wlvif->bss_type = BSS_TYPE_STA_BSS; |
| 1903 | break; |
| 1904 | case NL80211_IFTYPE_ADHOC: |
| 1905 | wlvif->bss_type = BSS_TYPE_IBSS; |
| 1906 | break; |
| 1907 | case NL80211_IFTYPE_P2P_GO: |
| 1908 | wlvif->p2p = 1; |
| 1909 | /* fall-through */ |
| 1910 | case NL80211_IFTYPE_AP: |
| 1911 | wlvif->bss_type = BSS_TYPE_AP_BSS; |
| 1912 | break; |
| 1913 | default: |
| 1914 | wlvif->bss_type = MAX_BSS_TYPE; |
| 1915 | return -EOPNOTSUPP; |
| 1916 | } |
| 1917 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1918 | wlvif->role_id = WL12XX_INVALID_ROLE_ID; |
Eliad Peller | 7edebf5 | 2011-10-05 11:55:52 +0200 | [diff] [blame] | 1919 | wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; |
Eliad Peller | afaf8bd | 2011-10-05 11:55:57 +0200 | [diff] [blame] | 1920 | wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 1921 | |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1922 | if (wlvif->bss_type == BSS_TYPE_STA_BSS || |
| 1923 | wlvif->bss_type == BSS_TYPE_IBSS) { |
| 1924 | /* init sta/ibss data */ |
| 1925 | wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 1926 | wl12xx_allocate_rate_policy(wl, &wlvif->sta.basic_rate_idx); |
| 1927 | wl12xx_allocate_rate_policy(wl, &wlvif->sta.ap_rate_idx); |
| 1928 | wl12xx_allocate_rate_policy(wl, &wlvif->sta.p2p_rate_idx); |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1929 | } else { |
| 1930 | /* init ap data */ |
| 1931 | wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; |
| 1932 | wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 1933 | wl12xx_allocate_rate_policy(wl, &wlvif->ap.mgmt_rate_idx); |
| 1934 | wl12xx_allocate_rate_policy(wl, &wlvif->ap.bcast_rate_idx); |
| 1935 | for (i = 0; i < CONF_TX_MAX_AC_COUNT; i++) |
| 1936 | wl12xx_allocate_rate_policy(wl, |
| 1937 | &wlvif->ap.ucast_rate_idx[i]); |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1938 | } |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 1939 | |
Eliad Peller | 8358750 | 2011-10-10 10:12:53 +0200 | [diff] [blame] | 1940 | wlvif->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; |
| 1941 | wlvif->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 1942 | wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 1943 | wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 1944 | wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; |
Eliad Peller | 6a89979 | 2011-10-05 11:55:58 +0200 | [diff] [blame] | 1945 | wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; |
| 1946 | |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 1947 | /* |
| 1948 | * mac80211 configures some values globally, while we treat them |
| 1949 | * per-interface. thus, on init, we have to copy them from wl |
| 1950 | */ |
| 1951 | wlvif->band = wl->band; |
Eliad Peller | 61f845f | 2011-10-10 10:13:10 +0200 | [diff] [blame] | 1952 | wlvif->channel = wl->channel; |
Eliad Peller | 6bd6502 | 2011-10-10 10:13:11 +0200 | [diff] [blame] | 1953 | wlvif->power_level = wl->power_level; |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 1954 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 1955 | INIT_WORK(&wlvif->rx_streaming_enable_work, |
| 1956 | wl1271_rx_streaming_enable_work); |
| 1957 | INIT_WORK(&wlvif->rx_streaming_disable_work, |
| 1958 | wl1271_rx_streaming_disable_work); |
Eliad Peller | 8762721 | 2011-10-10 10:12:54 +0200 | [diff] [blame] | 1959 | INIT_LIST_HEAD(&wlvif->list); |
Eliad Peller | 252efa4 | 2011-10-05 11:56:00 +0200 | [diff] [blame] | 1960 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 1961 | setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, |
| 1962 | (unsigned long) wlvif); |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 1963 | return 0; |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 1964 | } |
| 1965 | |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 1966 | static bool wl12xx_init_fw(struct wl1271 *wl) |
| 1967 | { |
| 1968 | int retries = WL1271_BOOT_RETRIES; |
| 1969 | bool booted = false; |
| 1970 | struct wiphy *wiphy = wl->hw->wiphy; |
| 1971 | int ret; |
| 1972 | |
| 1973 | while (retries) { |
| 1974 | retries--; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 1975 | ret = wl12xx_chip_wakeup(wl, false); |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 1976 | if (ret < 0) |
| 1977 | goto power_off; |
| 1978 | |
| 1979 | ret = wl1271_boot(wl); |
| 1980 | if (ret < 0) |
| 1981 | goto power_off; |
| 1982 | |
| 1983 | ret = wl1271_hw_init(wl); |
| 1984 | if (ret < 0) |
| 1985 | goto irq_disable; |
| 1986 | |
| 1987 | booted = true; |
| 1988 | break; |
| 1989 | |
| 1990 | irq_disable: |
| 1991 | mutex_unlock(&wl->mutex); |
| 1992 | /* Unlocking the mutex in the middle of handling is |
| 1993 | inherently unsafe. In this case we deem it safe to do, |
| 1994 | because we need to let any possibly pending IRQ out of |
| 1995 | the system (and while we are WL1271_STATE_OFF the IRQ |
| 1996 | work function will not do anything.) Also, any other |
| 1997 | possible concurrent operations will fail due to the |
| 1998 | current state, hence the wl1271 struct should be safe. */ |
| 1999 | wl1271_disable_interrupts(wl); |
| 2000 | wl1271_flush_deferred_work(wl); |
| 2001 | cancel_work_sync(&wl->netstack_work); |
| 2002 | mutex_lock(&wl->mutex); |
| 2003 | power_off: |
| 2004 | wl1271_power_off(wl); |
| 2005 | } |
| 2006 | |
| 2007 | if (!booted) { |
| 2008 | wl1271_error("firmware boot failed despite %d retries", |
| 2009 | WL1271_BOOT_RETRIES); |
| 2010 | goto out; |
| 2011 | } |
| 2012 | |
| 2013 | wl1271_info("firmware booted (%s)", wl->chip.fw_ver_str); |
| 2014 | |
| 2015 | /* update hw/fw version info in wiphy struct */ |
| 2016 | wiphy->hw_version = wl->chip.id; |
| 2017 | strncpy(wiphy->fw_version, wl->chip.fw_ver_str, |
| 2018 | sizeof(wiphy->fw_version)); |
| 2019 | |
| 2020 | /* |
| 2021 | * Now we know if 11a is supported (info from the NVS), so disable |
| 2022 | * 11a channels if not supported |
| 2023 | */ |
| 2024 | if (!wl->enable_11a) |
| 2025 | wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels = 0; |
| 2026 | |
| 2027 | wl1271_debug(DEBUG_MAC80211, "11a is %ssupported", |
| 2028 | wl->enable_11a ? "" : "not "); |
| 2029 | |
| 2030 | wl->state = WL1271_STATE_ON; |
| 2031 | out: |
| 2032 | return booted; |
| 2033 | } |
| 2034 | |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 2035 | static bool wl12xx_dev_role_started(struct wl12xx_vif *wlvif) |
| 2036 | { |
| 2037 | return wlvif->dev_hlid != WL12XX_INVALID_LINK_ID; |
| 2038 | } |
| 2039 | |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2040 | /* |
| 2041 | * Check whether a fw switch (i.e. moving from one loaded |
| 2042 | * fw to another) is needed. This function is also responsible |
| 2043 | * for updating wl->last_vif_count, so it must be called before |
| 2044 | * loading a non-plt fw (so the correct fw (single-role/multi-role) |
| 2045 | * will be used). |
| 2046 | */ |
| 2047 | static bool wl12xx_need_fw_change(struct wl1271 *wl, |
| 2048 | struct vif_counter_data vif_counter_data, |
| 2049 | bool add) |
| 2050 | { |
| 2051 | enum wl12xx_fw_type current_fw = wl->fw_type; |
| 2052 | u8 vif_count = vif_counter_data.counter; |
| 2053 | |
| 2054 | if (test_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags)) |
| 2055 | return false; |
| 2056 | |
| 2057 | /* increase the vif count if this is a new vif */ |
| 2058 | if (add && !vif_counter_data.cur_vif_running) |
| 2059 | vif_count++; |
| 2060 | |
| 2061 | wl->last_vif_count = vif_count; |
| 2062 | |
| 2063 | /* no need for fw change if the device is OFF */ |
| 2064 | if (wl->state == WL1271_STATE_OFF) |
| 2065 | return false; |
| 2066 | |
| 2067 | if (vif_count > 1 && current_fw == WL12XX_FW_TYPE_NORMAL) |
| 2068 | return true; |
| 2069 | if (vif_count <= 1 && current_fw == WL12XX_FW_TYPE_MULTI) |
| 2070 | return true; |
| 2071 | |
| 2072 | return false; |
| 2073 | } |
| 2074 | |
Eliad Peller | 3dee439 | 2012-02-06 12:47:56 +0200 | [diff] [blame] | 2075 | /* |
| 2076 | * Enter "forced psm". Make sure the sta is in psm against the ap, |
| 2077 | * to make the fw switch a bit more disconnection-persistent. |
| 2078 | */ |
| 2079 | static void wl12xx_force_active_psm(struct wl1271 *wl) |
| 2080 | { |
| 2081 | struct wl12xx_vif *wlvif; |
| 2082 | |
| 2083 | wl12xx_for_each_wlvif_sta(wl, wlvif) { |
| 2084 | wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE); |
| 2085 | } |
| 2086 | } |
| 2087 | |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 2088 | static int wl1271_op_add_interface(struct ieee80211_hw *hw, |
| 2089 | struct ieee80211_vif *vif) |
| 2090 | { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2091 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2092 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2093 | struct vif_counter_data vif_count; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2094 | int ret = 0; |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 2095 | u8 role_type; |
Eliad Peller | 71125ab | 2010-10-28 21:46:43 +0200 | [diff] [blame] | 2096 | bool booted = false; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2097 | |
Johannes Berg | ea08635 | 2012-01-19 09:29:58 +0100 | [diff] [blame] | 2098 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
| 2099 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; |
Johannes Berg | c1288b1 | 2012-01-19 09:29:57 +0100 | [diff] [blame] | 2100 | |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 2101 | wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", |
Eliad Peller | 045c745 | 2011-08-28 15:23:01 +0300 | [diff] [blame] | 2102 | ieee80211_vif_type_p2p(vif), vif->addr); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2103 | |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2104 | wl12xx_get_vif_count(hw, vif, &vif_count); |
| 2105 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2106 | mutex_lock(&wl->mutex); |
Eliad Peller | f750c82 | 2011-10-10 10:13:16 +0200 | [diff] [blame] | 2107 | ret = wl1271_ps_elp_wakeup(wl); |
| 2108 | if (ret < 0) |
| 2109 | goto out_unlock; |
| 2110 | |
Juuso Oikarinen | 13026de | 2011-03-29 16:43:50 +0300 | [diff] [blame] | 2111 | /* |
| 2112 | * in some very corner case HW recovery scenarios its possible to |
| 2113 | * get here before __wl1271_op_remove_interface is complete, so |
| 2114 | * opt out if that is the case. |
| 2115 | */ |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 2116 | if (test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags) || |
| 2117 | test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) { |
Juuso Oikarinen | 13026de | 2011-03-29 16:43:50 +0300 | [diff] [blame] | 2118 | ret = -EBUSY; |
| 2119 | goto out; |
| 2120 | } |
| 2121 | |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 2122 | |
Eliad Peller | 8358750 | 2011-10-10 10:12:53 +0200 | [diff] [blame] | 2123 | ret = wl12xx_init_vif_data(wl, vif); |
Eliad Peller | e936bbe | 2011-10-05 11:55:56 +0200 | [diff] [blame] | 2124 | if (ret < 0) |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 2125 | goto out; |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 2126 | |
Eliad Peller | 252efa4 | 2011-10-05 11:56:00 +0200 | [diff] [blame] | 2127 | wlvif->wl = wl; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2128 | role_type = wl12xx_get_role_type(wl, wlvif); |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 2129 | if (role_type == WL12XX_INVALID_ROLE_TYPE) { |
| 2130 | ret = -EINVAL; |
| 2131 | goto out; |
| 2132 | } |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2133 | |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2134 | if (wl12xx_need_fw_change(wl, vif_count, true)) { |
Eliad Peller | 3dee439 | 2012-02-06 12:47:56 +0200 | [diff] [blame] | 2135 | wl12xx_force_active_psm(wl); |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2136 | mutex_unlock(&wl->mutex); |
| 2137 | wl1271_recovery_work(&wl->recovery_work); |
| 2138 | return 0; |
| 2139 | } |
| 2140 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 2141 | /* |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2142 | * TODO: after the nvs issue will be solved, move this block |
| 2143 | * to start(), and make sure here the driver is ON. |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 2144 | */ |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2145 | if (wl->state == WL1271_STATE_OFF) { |
| 2146 | /* |
| 2147 | * we still need this in order to configure the fw |
| 2148 | * while uploading the nvs |
| 2149 | */ |
Luciano Coelho | 5e037e7 | 2011-12-23 09:32:17 +0200 | [diff] [blame] | 2150 | memcpy(wl->addresses[0].addr, vif->addr, ETH_ALEN); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2151 | |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2152 | booted = wl12xx_init_fw(wl); |
| 2153 | if (!booted) { |
| 2154 | ret = -EINVAL; |
| 2155 | goto out; |
Eliad Peller | 04e8079 | 2011-08-14 13:17:09 +0300 | [diff] [blame] | 2156 | } |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2157 | } |
Eliad Peller | 04e8079 | 2011-08-14 13:17:09 +0300 | [diff] [blame] | 2158 | |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2159 | if (wlvif->bss_type == BSS_TYPE_STA_BSS || |
| 2160 | wlvif->bss_type == BSS_TYPE_IBSS) { |
| 2161 | /* |
| 2162 | * The device role is a special role used for |
| 2163 | * rx and tx frames prior to association (as |
| 2164 | * the STA role can get packets only from |
| 2165 | * its associated bssid) |
| 2166 | */ |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 2167 | ret = wl12xx_cmd_role_enable(wl, vif->addr, |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2168 | WL1271_ROLE_DEVICE, |
| 2169 | &wlvif->dev_role_id); |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 2170 | if (ret < 0) |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2171 | goto out; |
Juuso Oikarinen | 9ccd921 | 2009-12-11 15:41:01 +0200 | [diff] [blame] | 2172 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2173 | |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2174 | ret = wl12xx_cmd_role_enable(wl, vif->addr, |
| 2175 | role_type, &wlvif->role_id); |
| 2176 | if (ret < 0) |
Eliad Peller | 71125ab | 2010-10-28 21:46:43 +0200 | [diff] [blame] | 2177 | goto out; |
Eliad Peller | 1d09547 | 2011-10-10 10:12:49 +0200 | [diff] [blame] | 2178 | |
| 2179 | ret = wl1271_init_vif_specific(wl, vif); |
| 2180 | if (ret < 0) |
| 2181 | goto out; |
Eliad Peller | 71125ab | 2010-10-28 21:46:43 +0200 | [diff] [blame] | 2182 | |
Eliad Peller | 8762721 | 2011-10-10 10:12:54 +0200 | [diff] [blame] | 2183 | list_add(&wlvif->list, &wl->wlvif_list); |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 2184 | set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags); |
Eliad Peller | a4e4130 | 2011-10-11 11:49:15 +0200 | [diff] [blame] | 2185 | |
| 2186 | if (wlvif->bss_type == BSS_TYPE_AP_BSS) |
| 2187 | wl->ap_count++; |
| 2188 | else |
| 2189 | wl->sta_count++; |
Juuso Oikarinen | eb5b28d | 2009-10-13 12:47:45 +0300 | [diff] [blame] | 2190 | out: |
Eliad Peller | f750c82 | 2011-10-10 10:13:16 +0200 | [diff] [blame] | 2191 | wl1271_ps_elp_sleep(wl); |
| 2192 | out_unlock: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2193 | mutex_unlock(&wl->mutex); |
| 2194 | |
| 2195 | return ret; |
| 2196 | } |
| 2197 | |
Arik Nemtsov | 7dece1c | 2011-04-18 14:15:28 +0300 | [diff] [blame] | 2198 | static void __wl1271_op_remove_interface(struct wl1271 *wl, |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2199 | struct ieee80211_vif *vif, |
Arik Nemtsov | 7dece1c | 2011-04-18 14:15:28 +0300 | [diff] [blame] | 2200 | bool reset_tx_queues) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2201 | { |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2202 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 2203 | int i, ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2204 | |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 2205 | wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2206 | |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 2207 | if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) |
| 2208 | return; |
| 2209 | |
Juuso Oikarinen | 13026de | 2011-03-29 16:43:50 +0300 | [diff] [blame] | 2210 | /* because of hardware recovery, we may get here twice */ |
| 2211 | if (wl->state != WL1271_STATE_ON) |
| 2212 | return; |
| 2213 | |
Juuso Oikarinen | 1b72aec | 2010-03-18 12:26:39 +0200 | [diff] [blame] | 2214 | wl1271_info("down"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2215 | |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 2216 | if (wl->scan.state != WL1271_SCAN_STATE_IDLE && |
| 2217 | wl->scan_vif == vif) { |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 2218 | wl->scan.state = WL1271_SCAN_STATE_IDLE; |
Luciano Coelho | 4a31c11 | 2011-03-21 23:16:14 +0200 | [diff] [blame] | 2219 | memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 2220 | wl->scan_vif = NULL; |
Juuso Oikarinen | b739a42 | 2010-10-26 13:24:38 +0200 | [diff] [blame] | 2221 | wl->scan.req = NULL; |
Juuso Oikarinen | 76a029f | 2010-07-29 04:54:45 +0300 | [diff] [blame] | 2222 | ieee80211_scan_completed(wl->hw, true); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2223 | } |
| 2224 | |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 2225 | if (!test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags)) { |
| 2226 | /* disable active roles */ |
| 2227 | ret = wl1271_ps_elp_wakeup(wl); |
| 2228 | if (ret < 0) |
| 2229 | goto deinit; |
| 2230 | |
Eliad Peller | b890f4c | 2011-12-18 20:25:44 +0200 | [diff] [blame] | 2231 | if (wlvif->bss_type == BSS_TYPE_STA_BSS || |
| 2232 | wlvif->bss_type == BSS_TYPE_IBSS) { |
| 2233 | if (wl12xx_dev_role_started(wlvif)) |
| 2234 | wl12xx_stop_dev(wl, wlvif); |
| 2235 | |
Eliad Peller | 7edebf5 | 2011-10-05 11:55:52 +0200 | [diff] [blame] | 2236 | ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id); |
Eliad Peller | 04e8079 | 2011-08-14 13:17:09 +0300 | [diff] [blame] | 2237 | if (ret < 0) |
| 2238 | goto deinit; |
| 2239 | } |
| 2240 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2241 | ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id); |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 2242 | if (ret < 0) |
| 2243 | goto deinit; |
| 2244 | |
| 2245 | wl1271_ps_elp_sleep(wl); |
| 2246 | } |
| 2247 | deinit: |
Arik Nemtsov | e51ae9b | 2011-08-14 13:17:21 +0300 | [diff] [blame] | 2248 | /* clear all hlids (except system_hlid) */ |
Eliad Peller | afaf8bd | 2011-10-05 11:55:57 +0200 | [diff] [blame] | 2249 | wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 2250 | |
| 2251 | if (wlvif->bss_type == BSS_TYPE_STA_BSS || |
| 2252 | wlvif->bss_type == BSS_TYPE_IBSS) { |
| 2253 | wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; |
| 2254 | wl12xx_free_rate_policy(wl, &wlvif->sta.basic_rate_idx); |
| 2255 | wl12xx_free_rate_policy(wl, &wlvif->sta.ap_rate_idx); |
| 2256 | wl12xx_free_rate_policy(wl, &wlvif->sta.p2p_rate_idx); |
| 2257 | } else { |
| 2258 | wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; |
| 2259 | wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; |
| 2260 | wl12xx_free_rate_policy(wl, &wlvif->ap.mgmt_rate_idx); |
| 2261 | wl12xx_free_rate_policy(wl, &wlvif->ap.bcast_rate_idx); |
| 2262 | for (i = 0; i < CONF_TX_MAX_AC_COUNT; i++) |
| 2263 | wl12xx_free_rate_policy(wl, |
| 2264 | &wlvif->ap.ucast_rate_idx[i]); |
| 2265 | } |
Eliad Peller | b78b47e | 2011-08-14 13:17:08 +0300 | [diff] [blame] | 2266 | |
Eliad Peller | d6a3cc2 | 2011-10-10 10:12:51 +0200 | [diff] [blame] | 2267 | wl12xx_tx_reset_wlvif(wl, wlvif); |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2268 | wl1271_free_ap_keys(wl, wlvif); |
Eliad Peller | e4120df | 2011-10-10 10:13:17 +0200 | [diff] [blame] | 2269 | if (wl->last_wlvif == wlvif) |
| 2270 | wl->last_wlvif = NULL; |
Eliad Peller | 8762721 | 2011-10-10 10:12:54 +0200 | [diff] [blame] | 2271 | list_del(&wlvif->list); |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 2272 | memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2273 | wlvif->role_id = WL12XX_INVALID_ROLE_ID; |
Eliad Peller | 7edebf5 | 2011-10-05 11:55:52 +0200 | [diff] [blame] | 2274 | wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; |
Luciano Coelho | d6e19d1 | 2009-10-12 15:08:43 +0300 | [diff] [blame] | 2275 | |
Eliad Peller | a4e4130 | 2011-10-11 11:49:15 +0200 | [diff] [blame] | 2276 | if (wlvif->bss_type == BSS_TYPE_AP_BSS) |
| 2277 | wl->ap_count--; |
| 2278 | else |
| 2279 | wl->sta_count--; |
| 2280 | |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 2281 | mutex_unlock(&wl->mutex); |
Eyal Shapira | d6bf9ad | 2012-01-31 11:57:20 +0200 | [diff] [blame] | 2282 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 2283 | del_timer_sync(&wlvif->rx_streaming_timer); |
| 2284 | cancel_work_sync(&wlvif->rx_streaming_enable_work); |
| 2285 | cancel_work_sync(&wlvif->rx_streaming_disable_work); |
Eliad Peller | f4df1bd | 2011-08-14 13:17:15 +0300 | [diff] [blame] | 2286 | |
Eliad Peller | baf6277 | 2011-10-10 10:12:52 +0200 | [diff] [blame] | 2287 | mutex_lock(&wl->mutex); |
Juuso Oikarinen | 52a2a37 | 2010-09-21 06:23:30 +0200 | [diff] [blame] | 2288 | } |
Juuso Oikarinen | bd9dc49 | 2010-04-09 11:07:26 +0300 | [diff] [blame] | 2289 | |
Juuso Oikarinen | 52a2a37 | 2010-09-21 06:23:30 +0200 | [diff] [blame] | 2290 | static void wl1271_op_remove_interface(struct ieee80211_hw *hw, |
| 2291 | struct ieee80211_vif *vif) |
| 2292 | { |
| 2293 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 2294 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2295 | struct wl12xx_vif *iter; |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2296 | struct vif_counter_data vif_count; |
| 2297 | bool cancel_recovery = true; |
Juuso Oikarinen | 52a2a37 | 2010-09-21 06:23:30 +0200 | [diff] [blame] | 2298 | |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2299 | wl12xx_get_vif_count(hw, vif, &vif_count); |
Juuso Oikarinen | 52a2a37 | 2010-09-21 06:23:30 +0200 | [diff] [blame] | 2300 | mutex_lock(&wl->mutex); |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 2301 | |
| 2302 | if (wl->state == WL1271_STATE_OFF || |
| 2303 | !test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) |
| 2304 | goto out; |
| 2305 | |
Juuso Oikarinen | 6735329 | 2010-11-18 15:19:02 +0200 | [diff] [blame] | 2306 | /* |
| 2307 | * wl->vif can be null here if someone shuts down the interface |
| 2308 | * just when hardware recovery has been started. |
| 2309 | */ |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2310 | wl12xx_for_each_wlvif(wl, iter) { |
| 2311 | if (iter != wlvif) |
| 2312 | continue; |
| 2313 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2314 | __wl1271_op_remove_interface(wl, vif, true); |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2315 | break; |
Juuso Oikarinen | 6735329 | 2010-11-18 15:19:02 +0200 | [diff] [blame] | 2316 | } |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2317 | WARN_ON(iter != wlvif); |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2318 | if (wl12xx_need_fw_change(wl, vif_count, false)) { |
Eliad Peller | 3dee439 | 2012-02-06 12:47:56 +0200 | [diff] [blame] | 2319 | wl12xx_force_active_psm(wl); |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2320 | wl12xx_queue_recovery_work(wl); |
| 2321 | cancel_recovery = false; |
| 2322 | } |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 2323 | out: |
Juuso Oikarinen | 6735329 | 2010-11-18 15:19:02 +0200 | [diff] [blame] | 2324 | mutex_unlock(&wl->mutex); |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2325 | if (cancel_recovery) |
| 2326 | cancel_work_sync(&wl->recovery_work); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2327 | } |
| 2328 | |
Eliad Peller | c0fad1b | 2011-12-19 12:00:03 +0200 | [diff] [blame] | 2329 | static int wl12xx_op_change_interface(struct ieee80211_hw *hw, |
| 2330 | struct ieee80211_vif *vif, |
| 2331 | enum nl80211_iftype new_type, bool p2p) |
| 2332 | { |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2333 | struct wl1271 *wl = hw->priv; |
| 2334 | int ret; |
| 2335 | |
| 2336 | set_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags); |
Eliad Peller | c0fad1b | 2011-12-19 12:00:03 +0200 | [diff] [blame] | 2337 | wl1271_op_remove_interface(hw, vif); |
| 2338 | |
| 2339 | vif->type = ieee80211_iftype_p2p(new_type, p2p); |
| 2340 | vif->p2p = p2p; |
Eliad Peller | 4549d09 | 2012-02-06 13:07:52 +0200 | [diff] [blame] | 2341 | ret = wl1271_op_add_interface(hw, vif); |
| 2342 | |
| 2343 | clear_bit(WL1271_FLAG_VIF_CHANGE_IN_PROGRESS, &wl->flags); |
| 2344 | return ret; |
Eliad Peller | c0fad1b | 2011-12-19 12:00:03 +0200 | [diff] [blame] | 2345 | } |
| 2346 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2347 | static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 2348 | bool set_assoc) |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2349 | { |
| 2350 | int ret; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2351 | bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2352 | |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 2353 | /* |
| 2354 | * One of the side effects of the JOIN command is that is clears |
| 2355 | * WPA/WPA2 keys from the chipset. Performing a JOIN while associated |
| 2356 | * to a WPA/WPA2 access point will therefore kill the data-path. |
Ohad Ben-Cohen | 8bf69aa | 2011-03-30 19:18:31 +0200 | [diff] [blame] | 2357 | * Currently the only valid scenario for JOIN during association |
| 2358 | * is on roaming, in which case we will also be given new keys. |
| 2359 | * Keep the below message for now, unless it starts bothering |
| 2360 | * users who really like to roam a lot :) |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 2361 | */ |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 2362 | if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 2363 | wl1271_info("JOIN while associated."); |
| 2364 | |
Eliad Peller | 5ec8a44 | 2012-02-02 12:22:09 +0200 | [diff] [blame] | 2365 | /* clear encryption type */ |
| 2366 | wlvif->encryption_type = KEY_NONE; |
| 2367 | |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 2368 | if (set_assoc) |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 2369 | set_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 2370 | |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 2371 | if (is_ibss) |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2372 | ret = wl12xx_cmd_role_start_ibss(wl, wlvif); |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 2373 | else |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2374 | ret = wl12xx_cmd_role_start_sta(wl, wlvif); |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2375 | if (ret < 0) |
| 2376 | goto out; |
| 2377 | |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 2378 | if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2379 | goto out; |
| 2380 | |
| 2381 | /* |
| 2382 | * The join command disable the keep-alive mode, shut down its process, |
| 2383 | * and also clear the template config, so we need to reset it all after |
| 2384 | * the join. The acx_aid starts the keep-alive process, and the order |
| 2385 | * of the commands below is relevant. |
| 2386 | */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2387 | ret = wl1271_acx_keep_alive_mode(wl, wlvif, true); |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2388 | if (ret < 0) |
| 2389 | goto out; |
| 2390 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2391 | ret = wl1271_acx_aid(wl, wlvif, wlvif->aid); |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2392 | if (ret < 0) |
| 2393 | goto out; |
| 2394 | |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 2395 | ret = wl12xx_cmd_build_klv_null_data(wl, wlvif); |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2396 | if (ret < 0) |
| 2397 | goto out; |
| 2398 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2399 | ret = wl1271_acx_keep_alive_config(wl, wlvif, |
| 2400 | CMD_TEMPL_KLV_IDX_NULL_DATA, |
Juuso Oikarinen | 82429d3 | 2010-04-28 09:50:01 +0300 | [diff] [blame] | 2401 | ACX_KEEP_ALIVE_TPL_VALID); |
| 2402 | if (ret < 0) |
| 2403 | goto out; |
| 2404 | |
| 2405 | out: |
| 2406 | return ret; |
| 2407 | } |
| 2408 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2409 | static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Luciano Coelho | c7f43e4 | 2009-12-11 15:40:44 +0200 | [diff] [blame] | 2410 | { |
| 2411 | int ret; |
| 2412 | |
Eliad Peller | 52630c5 | 2011-10-10 10:13:08 +0200 | [diff] [blame] | 2413 | if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) { |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2414 | struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); |
| 2415 | |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 2416 | wl12xx_cmd_stop_channel_switch(wl); |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2417 | ieee80211_chswitch_done(vif, false); |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 2418 | } |
| 2419 | |
Luciano Coelho | c7f43e4 | 2009-12-11 15:40:44 +0200 | [diff] [blame] | 2420 | /* to stop listening to a channel, we disconnect */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2421 | ret = wl12xx_cmd_role_stop_sta(wl, wlvif); |
Luciano Coelho | c7f43e4 | 2009-12-11 15:40:44 +0200 | [diff] [blame] | 2422 | if (ret < 0) |
| 2423 | goto out; |
| 2424 | |
Oz Krakowski | b992c68 | 2011-06-26 10:36:02 +0300 | [diff] [blame] | 2425 | /* reset TX security counters on a clean disconnect */ |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 2426 | wlvif->tx_security_last_seq_lsb = 0; |
| 2427 | wlvif->tx_security_seq = 0; |
Oz Krakowski | b992c68 | 2011-06-26 10:36:02 +0300 | [diff] [blame] | 2428 | |
Luciano Coelho | c7f43e4 | 2009-12-11 15:40:44 +0200 | [diff] [blame] | 2429 | out: |
| 2430 | return ret; |
| 2431 | } |
| 2432 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2433 | static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2434 | { |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 2435 | wlvif->basic_rate_set = wlvif->bitrate_masks[wlvif->band]; |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 2436 | wlvif->rate_set = wlvif->basic_rate_set; |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2437 | } |
| 2438 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2439 | static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 2440 | bool idle) |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2441 | { |
| 2442 | int ret; |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 2443 | bool cur_idle = !test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags); |
| 2444 | |
| 2445 | if (idle == cur_idle) |
| 2446 | return 0; |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2447 | |
| 2448 | if (idle) { |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2449 | /* no need to croc if we weren't busy (e.g. during boot) */ |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 2450 | if (wl12xx_dev_role_started(wlvif)) { |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 2451 | ret = wl12xx_stop_dev(wl, wlvif); |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2452 | if (ret < 0) |
| 2453 | goto out; |
| 2454 | } |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 2455 | wlvif->rate_set = |
| 2456 | wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
| 2457 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2458 | if (ret < 0) |
| 2459 | goto out; |
| 2460 | ret = wl1271_acx_keep_alive_config( |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2461 | wl, wlvif, CMD_TEMPL_KLV_IDX_NULL_DATA, |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2462 | ACX_KEEP_ALIVE_TPL_INVALID); |
| 2463 | if (ret < 0) |
| 2464 | goto out; |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 2465 | clear_bit(WLVIF_FLAG_IN_USE, &wlvif->flags); |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2466 | } else { |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 2467 | /* The current firmware only supports sched_scan in idle */ |
| 2468 | if (wl->sched_scanning) { |
| 2469 | wl1271_scan_sched_scan_stop(wl); |
| 2470 | ieee80211_sched_scan_stopped(wl->hw); |
| 2471 | } |
| 2472 | |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 2473 | ret = wl12xx_start_dev(wl, wlvif); |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2474 | if (ret < 0) |
| 2475 | goto out; |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 2476 | set_bit(WLVIF_FLAG_IN_USE, &wlvif->flags); |
Juuso Oikarinen | 0d58cbf | 2010-05-24 11:18:16 +0300 | [diff] [blame] | 2477 | } |
| 2478 | |
| 2479 | out: |
| 2480 | return ret; |
| 2481 | } |
| 2482 | |
Eliad Peller | 9f259c4 | 2011-10-10 10:13:12 +0200 | [diff] [blame] | 2483 | static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 2484 | struct ieee80211_conf *conf, u32 changed) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2485 | { |
Eliad Peller | 9f259c4 | 2011-10-10 10:13:12 +0200 | [diff] [blame] | 2486 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); |
| 2487 | int channel, ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2488 | |
| 2489 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
| 2490 | |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2491 | /* if the channel changes while joined, join again */ |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 2492 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL && |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 2493 | ((wlvif->band != conf->channel->band) || |
Eliad Peller | 61f845f | 2011-10-10 10:13:10 +0200 | [diff] [blame] | 2494 | (wlvif->channel != channel))) { |
Eliad Peller | c6930b0 | 2011-09-15 13:00:01 +0300 | [diff] [blame] | 2495 | /* send all pending packets */ |
Eliad Peller | a32d0cd | 2011-10-10 10:12:55 +0200 | [diff] [blame] | 2496 | wl1271_tx_work_locked(wl); |
Eliad Peller | 61f845f | 2011-10-10 10:13:10 +0200 | [diff] [blame] | 2497 | wlvif->band = conf->channel->band; |
| 2498 | wlvif->channel = channel; |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2499 | |
Arik Nemtsov | bee0ffe | 2010-10-16 19:17:02 +0200 | [diff] [blame] | 2500 | if (!is_ap) { |
| 2501 | /* |
| 2502 | * FIXME: the mac80211 should really provide a fixed |
| 2503 | * rate to use here. for now, just use the smallest |
| 2504 | * possible rate for the band as a fixed rate for |
| 2505 | * association frames and other control messages. |
| 2506 | */ |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 2507 | if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2508 | wl1271_set_band_rate(wl, wlvif); |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2509 | |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 2510 | wlvif->basic_rate = |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2511 | wl1271_tx_min_rate_get(wl, |
| 2512 | wlvif->basic_rate_set); |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 2513 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2514 | if (ret < 0) |
Arik Nemtsov | bee0ffe | 2010-10-16 19:17:02 +0200 | [diff] [blame] | 2515 | wl1271_warning("rate policy for channel " |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2516 | "failed %d", ret); |
Arik Nemtsov | bee0ffe | 2010-10-16 19:17:02 +0200 | [diff] [blame] | 2517 | |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 2518 | if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, |
| 2519 | &wlvif->flags)) { |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 2520 | if (wl12xx_dev_role_started(wlvif)) { |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2521 | /* roaming */ |
Eliad Peller | 7edebf5 | 2011-10-05 11:55:52 +0200 | [diff] [blame] | 2522 | ret = wl12xx_croc(wl, |
| 2523 | wlvif->dev_role_id); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2524 | if (ret < 0) |
Eliad Peller | 9f259c4 | 2011-10-10 10:13:12 +0200 | [diff] [blame] | 2525 | return ret; |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2526 | } |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 2527 | ret = wl1271_join(wl, wlvif, false); |
Arik Nemtsov | bee0ffe | 2010-10-16 19:17:02 +0200 | [diff] [blame] | 2528 | if (ret < 0) |
| 2529 | wl1271_warning("cmd join on channel " |
| 2530 | "failed %d", ret); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2531 | } else { |
| 2532 | /* |
| 2533 | * change the ROC channel. do it only if we are |
| 2534 | * not idle. otherwise, CROC will be called |
| 2535 | * anyway. |
| 2536 | */ |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 2537 | if (wl12xx_dev_role_started(wlvif) && |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2538 | !(conf->flags & IEEE80211_CONF_IDLE)) { |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 2539 | ret = wl12xx_stop_dev(wl, wlvif); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2540 | if (ret < 0) |
Eliad Peller | 9f259c4 | 2011-10-10 10:13:12 +0200 | [diff] [blame] | 2541 | return ret; |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2542 | |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 2543 | ret = wl12xx_start_dev(wl, wlvif); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2544 | if (ret < 0) |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 2545 | return ret; |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 2546 | } |
Arik Nemtsov | bee0ffe | 2010-10-16 19:17:02 +0200 | [diff] [blame] | 2547 | } |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 2548 | } |
| 2549 | } |
| 2550 | |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2551 | if ((changed & IEEE80211_CONF_CHANGE_PS) && !is_ap) { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2552 | |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2553 | if ((conf->flags & IEEE80211_CONF_PS) && |
| 2554 | test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 2555 | !test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) { |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2556 | |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 2557 | int ps_mode; |
| 2558 | char *ps_mode_str; |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2559 | |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 2560 | if (wl->conf.conn.forced_ps) { |
| 2561 | ps_mode = STATION_POWER_SAVE_MODE; |
| 2562 | ps_mode_str = "forced"; |
| 2563 | } else { |
| 2564 | ps_mode = STATION_AUTO_PS_MODE; |
| 2565 | ps_mode_str = "auto"; |
| 2566 | } |
| 2567 | |
| 2568 | wl1271_debug(DEBUG_PSM, "%s ps enabled", ps_mode_str); |
| 2569 | |
| 2570 | ret = wl1271_ps_set_mode(wl, wlvif, ps_mode); |
| 2571 | |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2572 | if (ret < 0) |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 2573 | wl1271_warning("enter %s ps failed %d", |
| 2574 | ps_mode_str, ret); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2575 | |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2576 | } else if (!(conf->flags & IEEE80211_CONF_PS) && |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 2577 | test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2578 | |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2579 | wl1271_debug(DEBUG_PSM, "auto ps disabled"); |
| 2580 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2581 | ret = wl1271_ps_set_mode(wl, wlvif, |
Eyal Shapira | 248a001 | 2012-01-31 11:57:23 +0200 | [diff] [blame] | 2582 | STATION_ACTIVE_MODE); |
Eyal Shapira | d18da7f | 2012-01-31 11:57:25 +0200 | [diff] [blame] | 2583 | if (ret < 0) |
| 2584 | wl1271_warning("exit auto ps failed %d", ret); |
| 2585 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2586 | } |
| 2587 | |
Eliad Peller | 6bd6502 | 2011-10-10 10:13:11 +0200 | [diff] [blame] | 2588 | if (conf->power_level != wlvif->power_level) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 2589 | ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2590 | if (ret < 0) |
Eliad Peller | 9f259c4 | 2011-10-10 10:13:12 +0200 | [diff] [blame] | 2591 | return ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2592 | |
Eliad Peller | 6bd6502 | 2011-10-10 10:13:11 +0200 | [diff] [blame] | 2593 | wlvif->power_level = conf->power_level; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2594 | } |
| 2595 | |
Eliad Peller | 9f259c4 | 2011-10-10 10:13:12 +0200 | [diff] [blame] | 2596 | return 0; |
| 2597 | } |
| 2598 | |
| 2599 | static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) |
| 2600 | { |
| 2601 | struct wl1271 *wl = hw->priv; |
| 2602 | struct wl12xx_vif *wlvif; |
| 2603 | struct ieee80211_conf *conf = &hw->conf; |
| 2604 | int channel, ret = 0; |
| 2605 | |
| 2606 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
| 2607 | |
| 2608 | wl1271_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d %s" |
| 2609 | " changed 0x%x", |
| 2610 | channel, |
| 2611 | conf->flags & IEEE80211_CONF_PS ? "on" : "off", |
| 2612 | conf->power_level, |
| 2613 | conf->flags & IEEE80211_CONF_IDLE ? "idle" : "in use", |
| 2614 | changed); |
| 2615 | |
| 2616 | /* |
| 2617 | * mac80211 will go to idle nearly immediately after transmitting some |
| 2618 | * frames, such as the deauth. To make sure those frames reach the air, |
| 2619 | * wait here until the TX queue is fully flushed. |
| 2620 | */ |
| 2621 | if ((changed & IEEE80211_CONF_CHANGE_IDLE) && |
| 2622 | (conf->flags & IEEE80211_CONF_IDLE)) |
| 2623 | wl1271_tx_flush(wl); |
| 2624 | |
| 2625 | mutex_lock(&wl->mutex); |
| 2626 | |
| 2627 | /* we support configuring the channel and band even while off */ |
| 2628 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { |
| 2629 | wl->band = conf->channel->band; |
| 2630 | wl->channel = channel; |
| 2631 | } |
| 2632 | |
| 2633 | if (changed & IEEE80211_CONF_CHANGE_POWER) |
| 2634 | wl->power_level = conf->power_level; |
| 2635 | |
| 2636 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 2637 | goto out; |
| 2638 | |
| 2639 | ret = wl1271_ps_elp_wakeup(wl); |
| 2640 | if (ret < 0) |
| 2641 | goto out; |
| 2642 | |
| 2643 | /* configure each interface */ |
| 2644 | wl12xx_for_each_wlvif(wl, wlvif) { |
| 2645 | ret = wl12xx_config_vif(wl, wlvif, conf, changed); |
| 2646 | if (ret < 0) |
| 2647 | goto out_sleep; |
| 2648 | } |
| 2649 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2650 | out_sleep: |
| 2651 | wl1271_ps_elp_sleep(wl); |
| 2652 | |
| 2653 | out: |
| 2654 | mutex_unlock(&wl->mutex); |
| 2655 | |
| 2656 | return ret; |
| 2657 | } |
| 2658 | |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2659 | struct wl1271_filter_params { |
| 2660 | bool enabled; |
| 2661 | int mc_list_length; |
| 2662 | u8 mc_list[ACX_MC_ADDRESS_GROUP_MAX][ETH_ALEN]; |
| 2663 | }; |
| 2664 | |
Jiri Pirko | 22bedad | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2665 | static u64 wl1271_op_prepare_multicast(struct ieee80211_hw *hw, |
| 2666 | struct netdev_hw_addr_list *mc_list) |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2667 | { |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2668 | struct wl1271_filter_params *fp; |
Jiri Pirko | 22bedad | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2669 | struct netdev_hw_addr *ha; |
Saravanan Dhanabal | 2c10bb9 | 2010-04-09 11:07:27 +0300 | [diff] [blame] | 2670 | struct wl1271 *wl = hw->priv; |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2671 | |
Saravanan Dhanabal | 2c10bb9 | 2010-04-09 11:07:27 +0300 | [diff] [blame] | 2672 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 2673 | return 0; |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2674 | |
Juuso Oikarinen | 7444113 | 2009-10-13 12:47:53 +0300 | [diff] [blame] | 2675 | fp = kzalloc(sizeof(*fp), GFP_ATOMIC); |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2676 | if (!fp) { |
| 2677 | wl1271_error("Out of memory setting filters."); |
| 2678 | return 0; |
| 2679 | } |
| 2680 | |
| 2681 | /* update multicast filtering parameters */ |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2682 | fp->mc_list_length = 0; |
Jiri Pirko | 22bedad | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2683 | if (netdev_hw_addr_list_count(mc_list) > ACX_MC_ADDRESS_GROUP_MAX) { |
| 2684 | fp->enabled = false; |
| 2685 | } else { |
| 2686 | fp->enabled = true; |
| 2687 | netdev_hw_addr_list_for_each(ha, mc_list) { |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2688 | memcpy(fp->mc_list[fp->mc_list_length], |
Jiri Pirko | 22bedad | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2689 | ha->addr, ETH_ALEN); |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2690 | fp->mc_list_length++; |
Jiri Pirko | 22bedad | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 2691 | } |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2692 | } |
| 2693 | |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2694 | return (u64)(unsigned long)fp; |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2695 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2696 | |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2697 | #define WL1271_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \ |
| 2698 | FIF_ALLMULTI | \ |
| 2699 | FIF_FCSFAIL | \ |
| 2700 | FIF_BCN_PRBRESP_PROMISC | \ |
| 2701 | FIF_CONTROL | \ |
| 2702 | FIF_OTHER_BSS) |
| 2703 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2704 | static void wl1271_op_configure_filter(struct ieee80211_hw *hw, |
| 2705 | unsigned int changed, |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 2706 | unsigned int *total, u64 multicast) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2707 | { |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2708 | struct wl1271_filter_params *fp = (void *)(unsigned long)multicast; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2709 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2710 | struct wl12xx_vif *wlvif; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2711 | |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2712 | int ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2713 | |
Arik Nemtsov | 7d05786 | 2010-10-16 19:25:35 +0200 | [diff] [blame] | 2714 | wl1271_debug(DEBUG_MAC80211, "mac80211 configure filter changed %x" |
| 2715 | " total %x", changed, *total); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2716 | |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2717 | mutex_lock(&wl->mutex); |
| 2718 | |
Saravanan Dhanabal | 2c10bb9 | 2010-04-09 11:07:27 +0300 | [diff] [blame] | 2719 | *total &= WL1271_SUPPORTED_FILTERS; |
| 2720 | changed &= WL1271_SUPPORTED_FILTERS; |
| 2721 | |
| 2722 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2723 | goto out; |
| 2724 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 2725 | ret = wl1271_ps_elp_wakeup(wl); |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2726 | if (ret < 0) |
| 2727 | goto out; |
| 2728 | |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 2729 | wl12xx_for_each_wlvif(wl, wlvif) { |
| 2730 | if (wlvif->bss_type != BSS_TYPE_AP_BSS) { |
| 2731 | if (*total & FIF_ALLMULTI) |
| 2732 | ret = wl1271_acx_group_address_tbl(wl, wlvif, |
| 2733 | false, |
| 2734 | NULL, 0); |
| 2735 | else if (fp) |
| 2736 | ret = wl1271_acx_group_address_tbl(wl, wlvif, |
| 2737 | fp->enabled, |
| 2738 | fp->mc_list, |
| 2739 | fp->mc_list_length); |
| 2740 | if (ret < 0) |
| 2741 | goto out_sleep; |
| 2742 | } |
Arik Nemtsov | 7d05786 | 2010-10-16 19:25:35 +0200 | [diff] [blame] | 2743 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2744 | |
Eliad Peller | 08c1d1c | 2011-08-14 13:17:04 +0300 | [diff] [blame] | 2745 | /* |
| 2746 | * the fw doesn't provide an api to configure the filters. instead, |
| 2747 | * the filters configuration is based on the active roles / ROC |
| 2748 | * state. |
| 2749 | */ |
Juuso Oikarinen | b54853f | 2009-10-13 12:47:59 +0300 | [diff] [blame] | 2750 | |
| 2751 | out_sleep: |
| 2752 | wl1271_ps_elp_sleep(wl); |
| 2753 | |
| 2754 | out: |
| 2755 | mutex_unlock(&wl->mutex); |
Juuso Oikarinen | 14b228a | 2010-03-18 12:26:43 +0200 | [diff] [blame] | 2756 | kfree(fp); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2757 | } |
| 2758 | |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2759 | static int wl1271_record_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 2760 | u8 id, u8 key_type, u8 key_size, |
| 2761 | const u8 *key, u8 hlid, u32 tx_seq_32, |
| 2762 | u16 tx_seq_16) |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2763 | { |
| 2764 | struct wl1271_ap_key *ap_key; |
| 2765 | int i; |
| 2766 | |
| 2767 | wl1271_debug(DEBUG_CRYPT, "record ap key id %d", (int)id); |
| 2768 | |
| 2769 | if (key_size > MAX_KEY_SIZE) |
| 2770 | return -EINVAL; |
| 2771 | |
| 2772 | /* |
| 2773 | * Find next free entry in ap_keys. Also check we are not replacing |
| 2774 | * an existing key. |
| 2775 | */ |
| 2776 | for (i = 0; i < MAX_NUM_KEYS; i++) { |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2777 | if (wlvif->ap.recorded_keys[i] == NULL) |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2778 | break; |
| 2779 | |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2780 | if (wlvif->ap.recorded_keys[i]->id == id) { |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2781 | wl1271_warning("trying to record key replacement"); |
| 2782 | return -EINVAL; |
| 2783 | } |
| 2784 | } |
| 2785 | |
| 2786 | if (i == MAX_NUM_KEYS) |
| 2787 | return -EBUSY; |
| 2788 | |
| 2789 | ap_key = kzalloc(sizeof(*ap_key), GFP_KERNEL); |
| 2790 | if (!ap_key) |
| 2791 | return -ENOMEM; |
| 2792 | |
| 2793 | ap_key->id = id; |
| 2794 | ap_key->key_type = key_type; |
| 2795 | ap_key->key_size = key_size; |
| 2796 | memcpy(ap_key->key, key, key_size); |
| 2797 | ap_key->hlid = hlid; |
| 2798 | ap_key->tx_seq_32 = tx_seq_32; |
| 2799 | ap_key->tx_seq_16 = tx_seq_16; |
| 2800 | |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2801 | wlvif->ap.recorded_keys[i] = ap_key; |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2802 | return 0; |
| 2803 | } |
| 2804 | |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2805 | static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2806 | { |
| 2807 | int i; |
| 2808 | |
| 2809 | for (i = 0; i < MAX_NUM_KEYS; i++) { |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2810 | kfree(wlvif->ap.recorded_keys[i]); |
| 2811 | wlvif->ap.recorded_keys[i] = NULL; |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2812 | } |
| 2813 | } |
| 2814 | |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2815 | static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2816 | { |
| 2817 | int i, ret = 0; |
| 2818 | struct wl1271_ap_key *key; |
| 2819 | bool wep_key_added = false; |
| 2820 | |
| 2821 | for (i = 0; i < MAX_NUM_KEYS; i++) { |
Eliad Peller | 7f97b48 | 2011-08-14 13:17:30 +0300 | [diff] [blame] | 2822 | u8 hlid; |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2823 | if (wlvif->ap.recorded_keys[i] == NULL) |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2824 | break; |
| 2825 | |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2826 | key = wlvif->ap.recorded_keys[i]; |
Eliad Peller | 7f97b48 | 2011-08-14 13:17:30 +0300 | [diff] [blame] | 2827 | hlid = key->hlid; |
| 2828 | if (hlid == WL12XX_INVALID_LINK_ID) |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2829 | hlid = wlvif->ap.bcast_hlid; |
Eliad Peller | 7f97b48 | 2011-08-14 13:17:30 +0300 | [diff] [blame] | 2830 | |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2831 | ret = wl1271_cmd_set_ap_key(wl, wlvif, KEY_ADD_OR_REPLACE, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2832 | key->id, key->key_type, |
| 2833 | key->key_size, key->key, |
Eliad Peller | 7f97b48 | 2011-08-14 13:17:30 +0300 | [diff] [blame] | 2834 | hlid, key->tx_seq_32, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2835 | key->tx_seq_16); |
| 2836 | if (ret < 0) |
| 2837 | goto out; |
| 2838 | |
| 2839 | if (key->key_type == KEY_WEP) |
| 2840 | wep_key_added = true; |
| 2841 | } |
| 2842 | |
| 2843 | if (wep_key_added) { |
Eliad Peller | f75c753f | 2011-10-05 11:55:59 +0200 | [diff] [blame] | 2844 | ret = wl12xx_cmd_set_default_wep_key(wl, wlvif->default_key, |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2845 | wlvif->ap.bcast_hlid); |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2846 | if (ret < 0) |
| 2847 | goto out; |
| 2848 | } |
| 2849 | |
| 2850 | out: |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2851 | wl1271_free_ap_keys(wl, wlvif); |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2852 | return ret; |
| 2853 | } |
| 2854 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2855 | static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 2856 | u16 action, u8 id, u8 key_type, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2857 | u8 key_size, const u8 *key, u32 tx_seq_32, |
| 2858 | u16 tx_seq_16, struct ieee80211_sta *sta) |
| 2859 | { |
| 2860 | int ret; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2861 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2862 | |
| 2863 | if (is_ap) { |
| 2864 | struct wl1271_station *wl_sta; |
| 2865 | u8 hlid; |
| 2866 | |
| 2867 | if (sta) { |
| 2868 | wl_sta = (struct wl1271_station *)sta->drv_priv; |
| 2869 | hlid = wl_sta->hlid; |
| 2870 | } else { |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2871 | hlid = wlvif->ap.bcast_hlid; |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2872 | } |
| 2873 | |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 2874 | if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2875 | /* |
| 2876 | * We do not support removing keys after AP shutdown. |
| 2877 | * Pretend we do to make mac80211 happy. |
| 2878 | */ |
| 2879 | if (action != KEY_ADD_OR_REPLACE) |
| 2880 | return 0; |
| 2881 | |
Eliad Peller | 170d0e6 | 2011-10-05 11:56:06 +0200 | [diff] [blame] | 2882 | ret = wl1271_record_ap_key(wl, wlvif, id, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2883 | key_type, key_size, |
| 2884 | key, hlid, tx_seq_32, |
| 2885 | tx_seq_16); |
| 2886 | } else { |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2887 | ret = wl1271_cmd_set_ap_key(wl, wlvif, action, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2888 | id, key_type, key_size, |
| 2889 | key, hlid, tx_seq_32, |
| 2890 | tx_seq_16); |
| 2891 | } |
| 2892 | |
| 2893 | if (ret < 0) |
| 2894 | return ret; |
| 2895 | } else { |
| 2896 | const u8 *addr; |
| 2897 | static const u8 bcast_addr[ETH_ALEN] = { |
| 2898 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 2899 | }; |
| 2900 | |
Guy Eilam | e9eb8cb | 2011-08-16 19:49:12 +0300 | [diff] [blame] | 2901 | /* |
| 2902 | * A STA set to GEM cipher requires 2 tx spare blocks. |
| 2903 | * Return to default value when GEM cipher key is removed |
| 2904 | */ |
| 2905 | if (key_type == KEY_GEM) { |
| 2906 | if (action == KEY_ADD_OR_REPLACE) |
| 2907 | wl->tx_spare_blocks = 2; |
| 2908 | else if (action == KEY_REMOVE) |
| 2909 | wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; |
| 2910 | } |
| 2911 | |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2912 | addr = sta ? sta->addr : bcast_addr; |
| 2913 | |
| 2914 | if (is_zero_ether_addr(addr)) { |
| 2915 | /* We dont support TX only encryption */ |
| 2916 | return -EOPNOTSUPP; |
| 2917 | } |
| 2918 | |
| 2919 | /* The wl1271 does not allow to remove unicast keys - they |
| 2920 | will be cleared automatically on next CMD_JOIN. Ignore the |
| 2921 | request silently, as we dont want the mac80211 to emit |
| 2922 | an error message. */ |
| 2923 | if (action == KEY_REMOVE && !is_broadcast_ether_addr(addr)) |
| 2924 | return 0; |
| 2925 | |
Eliad Peller | 010d3d3 | 2011-08-14 13:17:31 +0300 | [diff] [blame] | 2926 | /* don't remove key if hlid was already deleted */ |
| 2927 | if (action == KEY_REMOVE && |
Eliad Peller | 154da67 | 2011-10-05 11:55:53 +0200 | [diff] [blame] | 2928 | wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) |
Eliad Peller | 010d3d3 | 2011-08-14 13:17:31 +0300 | [diff] [blame] | 2929 | return 0; |
| 2930 | |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 2931 | ret = wl1271_cmd_set_sta_key(wl, wlvif, action, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2932 | id, key_type, key_size, |
| 2933 | key, addr, tx_seq_32, |
| 2934 | tx_seq_16); |
| 2935 | if (ret < 0) |
| 2936 | return ret; |
| 2937 | |
| 2938 | /* the default WEP key needs to be configured at least once */ |
| 2939 | if (key_type == KEY_WEP) { |
Eliad Peller | c690ec8 | 2011-08-14 13:17:07 +0300 | [diff] [blame] | 2940 | ret = wl12xx_cmd_set_default_wep_key(wl, |
Eliad Peller | f75c753f | 2011-10-05 11:55:59 +0200 | [diff] [blame] | 2941 | wlvif->default_key, |
| 2942 | wlvif->sta.hlid); |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2943 | if (ret < 0) |
| 2944 | return ret; |
| 2945 | } |
| 2946 | } |
| 2947 | |
| 2948 | return 0; |
| 2949 | } |
| 2950 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2951 | static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 2952 | struct ieee80211_vif *vif, |
| 2953 | struct ieee80211_sta *sta, |
| 2954 | struct ieee80211_key_conf *key_conf) |
| 2955 | { |
| 2956 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 2957 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2958 | int ret; |
Juuso Oikarinen | ac4e4ce | 2009-10-08 21:56:19 +0300 | [diff] [blame] | 2959 | u32 tx_seq_32 = 0; |
| 2960 | u16 tx_seq_16 = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2961 | u8 key_type; |
| 2962 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2963 | wl1271_debug(DEBUG_MAC80211, "mac80211 set key"); |
| 2964 | |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 2965 | wl1271_debug(DEBUG_CRYPT, "CMD: 0x%x sta: %p", cmd, sta); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2966 | wl1271_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x", |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 2967 | key_conf->cipher, key_conf->keyidx, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2968 | key_conf->keylen, key_conf->flags); |
| 2969 | wl1271_dump(DEBUG_CRYPT, "KEY: ", key_conf->key, key_conf->keylen); |
| 2970 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2971 | mutex_lock(&wl->mutex); |
| 2972 | |
Juuso Oikarinen | f8d9802 | 2010-10-26 13:24:39 +0200 | [diff] [blame] | 2973 | if (unlikely(wl->state == WL1271_STATE_OFF)) { |
| 2974 | ret = -EAGAIN; |
| 2975 | goto out_unlock; |
| 2976 | } |
| 2977 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 2978 | ret = wl1271_ps_elp_wakeup(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2979 | if (ret < 0) |
| 2980 | goto out_unlock; |
| 2981 | |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 2982 | switch (key_conf->cipher) { |
| 2983 | case WLAN_CIPHER_SUITE_WEP40: |
| 2984 | case WLAN_CIPHER_SUITE_WEP104: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2985 | key_type = KEY_WEP; |
| 2986 | |
| 2987 | key_conf->hw_key_idx = key_conf->keyidx; |
| 2988 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 2989 | case WLAN_CIPHER_SUITE_TKIP: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2990 | key_type = KEY_TKIP; |
| 2991 | |
| 2992 | key_conf->hw_key_idx = key_conf->keyidx; |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 2993 | tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); |
| 2994 | tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2995 | break; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 2996 | case WLAN_CIPHER_SUITE_CCMP: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 2997 | key_type = KEY_AES; |
| 2998 | |
Arik Nemtsov | 12d4b97 | 2011-10-23 08:21:54 +0200 | [diff] [blame] | 2999 | key_conf->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 3000 | tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); |
| 3001 | tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3002 | break; |
Juuso Oikarinen | 7a55724 | 2010-09-27 12:42:07 +0200 | [diff] [blame] | 3003 | case WL1271_CIPHER_SUITE_GEM: |
| 3004 | key_type = KEY_GEM; |
Eliad Peller | 48e93e4 | 2011-10-10 10:12:58 +0200 | [diff] [blame] | 3005 | tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); |
| 3006 | tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); |
Juuso Oikarinen | 7a55724 | 2010-09-27 12:42:07 +0200 | [diff] [blame] | 3007 | break; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3008 | default: |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 3009 | wl1271_error("Unknown key algo 0x%x", key_conf->cipher); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3010 | |
| 3011 | ret = -EOPNOTSUPP; |
| 3012 | goto out_sleep; |
| 3013 | } |
| 3014 | |
| 3015 | switch (cmd) { |
| 3016 | case SET_KEY: |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3017 | ret = wl1271_set_key(wl, wlvif, KEY_ADD_OR_REPLACE, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 3018 | key_conf->keyidx, key_type, |
| 3019 | key_conf->keylen, key_conf->key, |
| 3020 | tx_seq_32, tx_seq_16, sta); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3021 | if (ret < 0) { |
| 3022 | wl1271_error("Could not add or replace key"); |
| 3023 | goto out_sleep; |
| 3024 | } |
Eliad Peller | 5ec8a44 | 2012-02-02 12:22:09 +0200 | [diff] [blame] | 3025 | |
| 3026 | /* |
| 3027 | * reconfiguring arp response if the unicast (or common) |
| 3028 | * encryption key type was changed |
| 3029 | */ |
| 3030 | if (wlvif->bss_type == BSS_TYPE_STA_BSS && |
| 3031 | (sta || key_type == KEY_WEP) && |
| 3032 | wlvif->encryption_type != key_type) { |
| 3033 | wlvif->encryption_type = key_type; |
| 3034 | ret = wl1271_cmd_build_arp_rsp(wl, wlvif); |
| 3035 | if (ret < 0) { |
| 3036 | wl1271_warning("build arp rsp failed: %d", ret); |
| 3037 | goto out_sleep; |
| 3038 | } |
| 3039 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3040 | break; |
| 3041 | |
| 3042 | case DISABLE_KEY: |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3043 | ret = wl1271_set_key(wl, wlvif, KEY_REMOVE, |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 3044 | key_conf->keyidx, key_type, |
| 3045 | key_conf->keylen, key_conf->key, |
| 3046 | 0, 0, sta); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3047 | if (ret < 0) { |
| 3048 | wl1271_error("Could not remove key"); |
| 3049 | goto out_sleep; |
| 3050 | } |
| 3051 | break; |
| 3052 | |
| 3053 | default: |
| 3054 | wl1271_error("Unsupported key cmd 0x%x", cmd); |
| 3055 | ret = -EOPNOTSUPP; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3056 | break; |
| 3057 | } |
| 3058 | |
| 3059 | out_sleep: |
| 3060 | wl1271_ps_elp_sleep(wl); |
| 3061 | |
| 3062 | out_unlock: |
| 3063 | mutex_unlock(&wl->mutex); |
| 3064 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3065 | return ret; |
| 3066 | } |
| 3067 | |
| 3068 | static int wl1271_op_hw_scan(struct ieee80211_hw *hw, |
Johannes Berg | a060bbf | 2010-04-27 11:59:34 +0200 | [diff] [blame] | 3069 | struct ieee80211_vif *vif, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3070 | struct cfg80211_scan_request *req) |
| 3071 | { |
| 3072 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 7edebf5 | 2011-10-05 11:55:52 +0200 | [diff] [blame] | 3073 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
| 3074 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3075 | int ret; |
| 3076 | u8 *ssid = NULL; |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 3077 | size_t len = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3078 | |
| 3079 | wl1271_debug(DEBUG_MAC80211, "mac80211 hw scan"); |
| 3080 | |
| 3081 | if (req->n_ssids) { |
| 3082 | ssid = req->ssids[0].ssid; |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 3083 | len = req->ssids[0].ssid_len; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3084 | } |
| 3085 | |
| 3086 | mutex_lock(&wl->mutex); |
| 3087 | |
Juuso Oikarinen | b739a42 | 2010-10-26 13:24:38 +0200 | [diff] [blame] | 3088 | if (wl->state == WL1271_STATE_OFF) { |
| 3089 | /* |
| 3090 | * We cannot return -EBUSY here because cfg80211 will expect |
| 3091 | * a call to ieee80211_scan_completed if we do - in this case |
| 3092 | * there won't be any call. |
| 3093 | */ |
| 3094 | ret = -EAGAIN; |
| 3095 | goto out; |
| 3096 | } |
| 3097 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 3098 | ret = wl1271_ps_elp_wakeup(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3099 | if (ret < 0) |
| 3100 | goto out; |
| 3101 | |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 3102 | if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && |
| 3103 | test_bit(wlvif->role_id, wl->roc_map)) { |
| 3104 | /* don't allow scanning right now */ |
| 3105 | ret = -EBUSY; |
| 3106 | goto out_sleep; |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3107 | } |
| 3108 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 3109 | ret = wl1271_scan(hw->priv, vif, ssid, len, req); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3110 | out_sleep: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3111 | wl1271_ps_elp_sleep(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3112 | out: |
| 3113 | mutex_unlock(&wl->mutex); |
| 3114 | |
| 3115 | return ret; |
| 3116 | } |
| 3117 | |
Eliad Peller | 73ecce3 | 2011-06-27 13:06:45 +0300 | [diff] [blame] | 3118 | static void wl1271_op_cancel_hw_scan(struct ieee80211_hw *hw, |
| 3119 | struct ieee80211_vif *vif) |
| 3120 | { |
| 3121 | struct wl1271 *wl = hw->priv; |
| 3122 | int ret; |
| 3123 | |
| 3124 | wl1271_debug(DEBUG_MAC80211, "mac80211 cancel hw scan"); |
| 3125 | |
| 3126 | mutex_lock(&wl->mutex); |
| 3127 | |
| 3128 | if (wl->state == WL1271_STATE_OFF) |
| 3129 | goto out; |
| 3130 | |
| 3131 | if (wl->scan.state == WL1271_SCAN_STATE_IDLE) |
| 3132 | goto out; |
| 3133 | |
| 3134 | ret = wl1271_ps_elp_wakeup(wl); |
| 3135 | if (ret < 0) |
| 3136 | goto out; |
| 3137 | |
| 3138 | if (wl->scan.state != WL1271_SCAN_STATE_DONE) { |
| 3139 | ret = wl1271_scan_stop(wl); |
| 3140 | if (ret < 0) |
| 3141 | goto out_sleep; |
| 3142 | } |
| 3143 | wl->scan.state = WL1271_SCAN_STATE_IDLE; |
| 3144 | memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 3145 | wl->scan_vif = NULL; |
Eliad Peller | 73ecce3 | 2011-06-27 13:06:45 +0300 | [diff] [blame] | 3146 | wl->scan.req = NULL; |
| 3147 | ieee80211_scan_completed(wl->hw, true); |
| 3148 | |
| 3149 | out_sleep: |
| 3150 | wl1271_ps_elp_sleep(wl); |
| 3151 | out: |
| 3152 | mutex_unlock(&wl->mutex); |
| 3153 | |
| 3154 | cancel_delayed_work_sync(&wl->scan_complete_work); |
| 3155 | } |
| 3156 | |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 3157 | static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, |
| 3158 | struct ieee80211_vif *vif, |
| 3159 | struct cfg80211_sched_scan_request *req, |
| 3160 | struct ieee80211_sched_scan_ies *ies) |
| 3161 | { |
| 3162 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3163 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 3164 | int ret; |
| 3165 | |
| 3166 | wl1271_debug(DEBUG_MAC80211, "wl1271_op_sched_scan_start"); |
| 3167 | |
| 3168 | mutex_lock(&wl->mutex); |
| 3169 | |
Pontus Fuchs | 9e0dc89 | 2012-01-11 14:22:42 +0100 | [diff] [blame] | 3170 | if (wl->state == WL1271_STATE_OFF) { |
| 3171 | ret = -EAGAIN; |
| 3172 | goto out; |
| 3173 | } |
| 3174 | |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 3175 | ret = wl1271_ps_elp_wakeup(wl); |
| 3176 | if (ret < 0) |
| 3177 | goto out; |
| 3178 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3179 | ret = wl1271_scan_sched_scan_config(wl, wlvif, req, ies); |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 3180 | if (ret < 0) |
| 3181 | goto out_sleep; |
| 3182 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3183 | ret = wl1271_scan_sched_scan_start(wl, wlvif); |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 3184 | if (ret < 0) |
| 3185 | goto out_sleep; |
| 3186 | |
| 3187 | wl->sched_scanning = true; |
| 3188 | |
| 3189 | out_sleep: |
| 3190 | wl1271_ps_elp_sleep(wl); |
| 3191 | out: |
| 3192 | mutex_unlock(&wl->mutex); |
| 3193 | return ret; |
| 3194 | } |
| 3195 | |
| 3196 | static void wl1271_op_sched_scan_stop(struct ieee80211_hw *hw, |
| 3197 | struct ieee80211_vif *vif) |
| 3198 | { |
| 3199 | struct wl1271 *wl = hw->priv; |
| 3200 | int ret; |
| 3201 | |
| 3202 | wl1271_debug(DEBUG_MAC80211, "wl1271_op_sched_scan_stop"); |
| 3203 | |
| 3204 | mutex_lock(&wl->mutex); |
| 3205 | |
Pontus Fuchs | 9e0dc89 | 2012-01-11 14:22:42 +0100 | [diff] [blame] | 3206 | if (wl->state == WL1271_STATE_OFF) |
| 3207 | goto out; |
| 3208 | |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 3209 | ret = wl1271_ps_elp_wakeup(wl); |
| 3210 | if (ret < 0) |
| 3211 | goto out; |
| 3212 | |
| 3213 | wl1271_scan_sched_scan_stop(wl); |
| 3214 | |
| 3215 | wl1271_ps_elp_sleep(wl); |
| 3216 | out: |
| 3217 | mutex_unlock(&wl->mutex); |
| 3218 | } |
| 3219 | |
Arik Nemtsov | 68d069c | 2010-11-08 10:51:07 +0100 | [diff] [blame] | 3220 | static int wl1271_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value) |
| 3221 | { |
| 3222 | struct wl1271 *wl = hw->priv; |
| 3223 | int ret = 0; |
| 3224 | |
| 3225 | mutex_lock(&wl->mutex); |
| 3226 | |
| 3227 | if (unlikely(wl->state == WL1271_STATE_OFF)) { |
| 3228 | ret = -EAGAIN; |
| 3229 | goto out; |
| 3230 | } |
| 3231 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 3232 | ret = wl1271_ps_elp_wakeup(wl); |
Arik Nemtsov | 68d069c | 2010-11-08 10:51:07 +0100 | [diff] [blame] | 3233 | if (ret < 0) |
| 3234 | goto out; |
| 3235 | |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 3236 | ret = wl1271_acx_frag_threshold(wl, value); |
Arik Nemtsov | 68d069c | 2010-11-08 10:51:07 +0100 | [diff] [blame] | 3237 | if (ret < 0) |
| 3238 | wl1271_warning("wl1271_op_set_frag_threshold failed: %d", ret); |
| 3239 | |
| 3240 | wl1271_ps_elp_sleep(wl); |
| 3241 | |
| 3242 | out: |
| 3243 | mutex_unlock(&wl->mutex); |
| 3244 | |
| 3245 | return ret; |
| 3246 | } |
| 3247 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3248 | static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
| 3249 | { |
| 3250 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 3251 | struct wl12xx_vif *wlvif; |
Saravanan Dhanabal | aecb056 | 2010-04-09 11:07:28 +0300 | [diff] [blame] | 3252 | int ret = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3253 | |
| 3254 | mutex_lock(&wl->mutex); |
| 3255 | |
Juuso Oikarinen | f8d9802 | 2010-10-26 13:24:39 +0200 | [diff] [blame] | 3256 | if (unlikely(wl->state == WL1271_STATE_OFF)) { |
| 3257 | ret = -EAGAIN; |
Saravanan Dhanabal | aecb056 | 2010-04-09 11:07:28 +0300 | [diff] [blame] | 3258 | goto out; |
Juuso Oikarinen | f8d9802 | 2010-10-26 13:24:39 +0200 | [diff] [blame] | 3259 | } |
Saravanan Dhanabal | aecb056 | 2010-04-09 11:07:28 +0300 | [diff] [blame] | 3260 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 3261 | ret = wl1271_ps_elp_wakeup(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3262 | if (ret < 0) |
| 3263 | goto out; |
| 3264 | |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 3265 | wl12xx_for_each_wlvif(wl, wlvif) { |
| 3266 | ret = wl1271_acx_rts_threshold(wl, wlvif, value); |
| 3267 | if (ret < 0) |
| 3268 | wl1271_warning("set rts threshold failed: %d", ret); |
| 3269 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3270 | wl1271_ps_elp_sleep(wl); |
| 3271 | |
| 3272 | out: |
| 3273 | mutex_unlock(&wl->mutex); |
| 3274 | |
| 3275 | return ret; |
| 3276 | } |
| 3277 | |
Eliad Peller | 1fe9f16 | 2011-10-05 11:55:48 +0200 | [diff] [blame] | 3278 | static int wl1271_ssid_set(struct ieee80211_vif *vif, struct sk_buff *skb, |
Juuso Oikarinen | 2f6724b | 2010-11-24 08:16:57 +0200 | [diff] [blame] | 3279 | int offset) |
Juuso Oikarinen | 30240fc | 2010-02-18 13:25:38 +0200 | [diff] [blame] | 3280 | { |
Eliad Peller | 1fe9f16 | 2011-10-05 11:55:48 +0200 | [diff] [blame] | 3281 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | 889cb36 | 2011-05-01 09:56:45 +0300 | [diff] [blame] | 3282 | u8 ssid_len; |
| 3283 | const u8 *ptr = cfg80211_find_ie(WLAN_EID_SSID, skb->data + offset, |
| 3284 | skb->len - offset); |
Juuso Oikarinen | 30240fc | 2010-02-18 13:25:38 +0200 | [diff] [blame] | 3285 | |
Eliad Peller | 889cb36 | 2011-05-01 09:56:45 +0300 | [diff] [blame] | 3286 | if (!ptr) { |
| 3287 | wl1271_error("No SSID in IEs!"); |
| 3288 | return -ENOENT; |
Juuso Oikarinen | 30240fc | 2010-02-18 13:25:38 +0200 | [diff] [blame] | 3289 | } |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3290 | |
Eliad Peller | 889cb36 | 2011-05-01 09:56:45 +0300 | [diff] [blame] | 3291 | ssid_len = ptr[1]; |
| 3292 | if (ssid_len > IEEE80211_MAX_SSID_LEN) { |
| 3293 | wl1271_error("SSID is too long!"); |
| 3294 | return -EINVAL; |
| 3295 | } |
| 3296 | |
Eliad Peller | 1fe9f16 | 2011-10-05 11:55:48 +0200 | [diff] [blame] | 3297 | wlvif->ssid_len = ssid_len; |
| 3298 | memcpy(wlvif->ssid, ptr+2, ssid_len); |
Eliad Peller | 889cb36 | 2011-05-01 09:56:45 +0300 | [diff] [blame] | 3299 | return 0; |
Juuso Oikarinen | 30240fc | 2010-02-18 13:25:38 +0200 | [diff] [blame] | 3300 | } |
| 3301 | |
Eliad Peller | d48055d | 2011-09-15 12:07:04 +0300 | [diff] [blame] | 3302 | static void wl12xx_remove_ie(struct sk_buff *skb, u8 eid, int ieoffset) |
| 3303 | { |
| 3304 | int len; |
| 3305 | const u8 *next, *end = skb->data + skb->len; |
| 3306 | u8 *ie = (u8 *)cfg80211_find_ie(eid, skb->data + ieoffset, |
| 3307 | skb->len - ieoffset); |
| 3308 | if (!ie) |
| 3309 | return; |
| 3310 | len = ie[1] + 2; |
| 3311 | next = ie + len; |
| 3312 | memmove(ie, next, end - next); |
| 3313 | skb_trim(skb, skb->len - len); |
| 3314 | } |
| 3315 | |
Eliad Peller | 26b4bf2 | 2011-09-15 12:07:05 +0300 | [diff] [blame] | 3316 | static void wl12xx_remove_vendor_ie(struct sk_buff *skb, |
| 3317 | unsigned int oui, u8 oui_type, |
| 3318 | int ieoffset) |
| 3319 | { |
| 3320 | int len; |
| 3321 | const u8 *next, *end = skb->data + skb->len; |
| 3322 | u8 *ie = (u8 *)cfg80211_find_vendor_ie(oui, oui_type, |
| 3323 | skb->data + ieoffset, |
| 3324 | skb->len - ieoffset); |
| 3325 | if (!ie) |
| 3326 | return; |
| 3327 | len = ie[1] + 2; |
| 3328 | next = ie + len; |
| 3329 | memmove(ie, next, end - next); |
| 3330 | skb_trim(skb, skb->len - len); |
| 3331 | } |
| 3332 | |
Arik Nemtsov | 341f2c1 | 2011-11-22 19:52:59 +0200 | [diff] [blame] | 3333 | static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, u32 rates, |
| 3334 | struct ieee80211_vif *vif) |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3335 | { |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 3336 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3337 | struct sk_buff *skb; |
| 3338 | int ret; |
| 3339 | |
Arik Nemtsov | 341f2c1 | 2011-11-22 19:52:59 +0200 | [diff] [blame] | 3340 | skb = ieee80211_proberesp_get(wl->hw, vif); |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3341 | if (!skb) |
Arik Nemtsov | 341f2c1 | 2011-11-22 19:52:59 +0200 | [diff] [blame] | 3342 | return -EOPNOTSUPP; |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3343 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 3344 | ret = wl1271_cmd_template_set(wl, wlvif->role_id, |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3345 | CMD_TEMPL_AP_PROBE_RESPONSE, |
| 3346 | skb->data, |
| 3347 | skb->len, 0, |
| 3348 | rates); |
| 3349 | |
| 3350 | dev_kfree_skb(skb); |
| 3351 | return ret; |
| 3352 | } |
| 3353 | |
| 3354 | static int wl1271_ap_set_probe_resp_tmpl_legacy(struct wl1271 *wl, |
| 3355 | struct ieee80211_vif *vif, |
| 3356 | u8 *probe_rsp_data, |
| 3357 | size_t probe_rsp_len, |
| 3358 | u32 rates) |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3359 | { |
Eliad Peller | 1fe9f16 | 2011-10-05 11:55:48 +0200 | [diff] [blame] | 3360 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
| 3361 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3362 | u8 probe_rsp_templ[WL1271_CMD_TEMPL_MAX_SIZE]; |
| 3363 | int ssid_ie_offset, ie_offset, templ_len; |
| 3364 | const u8 *ptr; |
| 3365 | |
| 3366 | /* no need to change probe response if the SSID is set correctly */ |
Eliad Peller | 1fe9f16 | 2011-10-05 11:55:48 +0200 | [diff] [blame] | 3367 | if (wlvif->ssid_len > 0) |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 3368 | return wl1271_cmd_template_set(wl, wlvif->role_id, |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3369 | CMD_TEMPL_AP_PROBE_RESPONSE, |
| 3370 | probe_rsp_data, |
| 3371 | probe_rsp_len, 0, |
| 3372 | rates); |
| 3373 | |
| 3374 | if (probe_rsp_len + bss_conf->ssid_len > WL1271_CMD_TEMPL_MAX_SIZE) { |
| 3375 | wl1271_error("probe_rsp template too big"); |
| 3376 | return -EINVAL; |
| 3377 | } |
| 3378 | |
| 3379 | /* start searching from IE offset */ |
| 3380 | ie_offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); |
| 3381 | |
| 3382 | ptr = cfg80211_find_ie(WLAN_EID_SSID, probe_rsp_data + ie_offset, |
| 3383 | probe_rsp_len - ie_offset); |
| 3384 | if (!ptr) { |
| 3385 | wl1271_error("No SSID in beacon!"); |
| 3386 | return -EINVAL; |
| 3387 | } |
| 3388 | |
| 3389 | ssid_ie_offset = ptr - probe_rsp_data; |
| 3390 | ptr += (ptr[1] + 2); |
| 3391 | |
| 3392 | memcpy(probe_rsp_templ, probe_rsp_data, ssid_ie_offset); |
| 3393 | |
| 3394 | /* insert SSID from bss_conf */ |
| 3395 | probe_rsp_templ[ssid_ie_offset] = WLAN_EID_SSID; |
| 3396 | probe_rsp_templ[ssid_ie_offset + 1] = bss_conf->ssid_len; |
| 3397 | memcpy(probe_rsp_templ + ssid_ie_offset + 2, |
| 3398 | bss_conf->ssid, bss_conf->ssid_len); |
| 3399 | templ_len = ssid_ie_offset + 2 + bss_conf->ssid_len; |
| 3400 | |
| 3401 | memcpy(probe_rsp_templ + ssid_ie_offset + 2 + bss_conf->ssid_len, |
| 3402 | ptr, probe_rsp_len - (ptr - probe_rsp_data)); |
| 3403 | templ_len += probe_rsp_len - (ptr - probe_rsp_data); |
| 3404 | |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 3405 | return wl1271_cmd_template_set(wl, wlvif->role_id, |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3406 | CMD_TEMPL_AP_PROBE_RESPONSE, |
| 3407 | probe_rsp_templ, |
| 3408 | templ_len, 0, |
| 3409 | rates); |
| 3410 | } |
| 3411 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3412 | static int wl1271_bss_erp_info_changed(struct wl1271 *wl, |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3413 | struct ieee80211_vif *vif, |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3414 | struct ieee80211_bss_conf *bss_conf, |
| 3415 | u32 changed) |
| 3416 | { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3417 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3418 | int ret = 0; |
| 3419 | |
| 3420 | if (changed & BSS_CHANGED_ERP_SLOT) { |
| 3421 | if (bss_conf->use_short_slot) |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3422 | ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_SHORT); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3423 | else |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3424 | ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_LONG); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3425 | if (ret < 0) { |
| 3426 | wl1271_warning("Set slot time failed %d", ret); |
| 3427 | goto out; |
| 3428 | } |
| 3429 | } |
| 3430 | |
| 3431 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { |
| 3432 | if (bss_conf->use_short_preamble) |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3433 | wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_SHORT); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3434 | else |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3435 | wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_LONG); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3436 | } |
| 3437 | |
| 3438 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { |
| 3439 | if (bss_conf->use_cts_prot) |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3440 | ret = wl1271_acx_cts_protect(wl, wlvif, |
| 3441 | CTSPROTECT_ENABLE); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3442 | else |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3443 | ret = wl1271_acx_cts_protect(wl, wlvif, |
| 3444 | CTSPROTECT_DISABLE); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3445 | if (ret < 0) { |
| 3446 | wl1271_warning("Set ctsprotect failed %d", ret); |
| 3447 | goto out; |
| 3448 | } |
| 3449 | } |
| 3450 | |
| 3451 | out: |
| 3452 | return ret; |
| 3453 | } |
| 3454 | |
| 3455 | static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, |
| 3456 | struct ieee80211_vif *vif, |
| 3457 | struct ieee80211_bss_conf *bss_conf, |
| 3458 | u32 changed) |
| 3459 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3460 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3461 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3462 | int ret = 0; |
| 3463 | |
| 3464 | if ((changed & BSS_CHANGED_BEACON_INT)) { |
| 3465 | wl1271_debug(DEBUG_MASTER, "beacon interval updated: %d", |
| 3466 | bss_conf->beacon_int); |
| 3467 | |
Eliad Peller | 6a89979 | 2011-10-05 11:55:58 +0200 | [diff] [blame] | 3468 | wlvif->beacon_int = bss_conf->beacon_int; |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3469 | } |
| 3470 | |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3471 | if ((changed & BSS_CHANGED_AP_PROBE_RESP) && is_ap) { |
| 3472 | u32 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | 341f2c1 | 2011-11-22 19:52:59 +0200 | [diff] [blame] | 3473 | if (!wl1271_ap_set_probe_resp_tmpl(wl, rate, vif)) { |
| 3474 | wl1271_debug(DEBUG_AP, "probe response updated"); |
| 3475 | set_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags); |
| 3476 | } |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3477 | } |
| 3478 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3479 | if ((changed & BSS_CHANGED_BEACON)) { |
| 3480 | struct ieee80211_hdr *hdr; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3481 | u32 min_rate; |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3482 | int ieoffset = offsetof(struct ieee80211_mgmt, |
| 3483 | u.beacon.variable); |
| 3484 | struct sk_buff *beacon = ieee80211_beacon_get(wl->hw, vif); |
| 3485 | u16 tmpl_id; |
| 3486 | |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3487 | if (!beacon) { |
| 3488 | ret = -EINVAL; |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3489 | goto out; |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3490 | } |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3491 | |
| 3492 | wl1271_debug(DEBUG_MASTER, "beacon updated"); |
| 3493 | |
Eliad Peller | 1fe9f16 | 2011-10-05 11:55:48 +0200 | [diff] [blame] | 3494 | ret = wl1271_ssid_set(vif, beacon, ieoffset); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3495 | if (ret < 0) { |
| 3496 | dev_kfree_skb(beacon); |
| 3497 | goto out; |
| 3498 | } |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3499 | min_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3500 | tmpl_id = is_ap ? CMD_TEMPL_AP_BEACON : |
| 3501 | CMD_TEMPL_BEACON; |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 3502 | ret = wl1271_cmd_template_set(wl, wlvif->role_id, tmpl_id, |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3503 | beacon->data, |
| 3504 | beacon->len, 0, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3505 | min_rate); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3506 | if (ret < 0) { |
| 3507 | dev_kfree_skb(beacon); |
| 3508 | goto out; |
| 3509 | } |
| 3510 | |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3511 | /* |
| 3512 | * In case we already have a probe-resp beacon set explicitly |
| 3513 | * by usermode, don't use the beacon data. |
| 3514 | */ |
| 3515 | if (test_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags)) |
| 3516 | goto end_bcn; |
| 3517 | |
Eliad Peller | d48055d | 2011-09-15 12:07:04 +0300 | [diff] [blame] | 3518 | /* remove TIM ie from probe response */ |
| 3519 | wl12xx_remove_ie(beacon, WLAN_EID_TIM, ieoffset); |
| 3520 | |
Eliad Peller | 26b4bf2 | 2011-09-15 12:07:05 +0300 | [diff] [blame] | 3521 | /* |
| 3522 | * remove p2p ie from probe response. |
| 3523 | * the fw reponds to probe requests that don't include |
| 3524 | * the p2p ie. probe requests with p2p ie will be passed, |
| 3525 | * and will be responded by the supplicant (the spec |
| 3526 | * forbids including the p2p ie when responding to probe |
| 3527 | * requests that didn't include it). |
| 3528 | */ |
| 3529 | wl12xx_remove_vendor_ie(beacon, WLAN_OUI_WFA, |
| 3530 | WLAN_OUI_TYPE_WFA_P2P, ieoffset); |
| 3531 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3532 | hdr = (struct ieee80211_hdr *) beacon->data; |
| 3533 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 3534 | IEEE80211_STYPE_PROBE_RESP); |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3535 | if (is_ap) |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3536 | ret = wl1271_ap_set_probe_resp_tmpl_legacy(wl, vif, |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3537 | beacon->data, |
| 3538 | beacon->len, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3539 | min_rate); |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3540 | else |
Eliad Peller | cdaac62 | 2012-01-31 11:57:16 +0200 | [diff] [blame] | 3541 | ret = wl1271_cmd_template_set(wl, wlvif->role_id, |
Arik Nemtsov | 68eaaf6 | 2011-09-03 20:22:03 +0300 | [diff] [blame] | 3542 | CMD_TEMPL_PROBE_RESPONSE, |
| 3543 | beacon->data, |
| 3544 | beacon->len, 0, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3545 | min_rate); |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3546 | end_bcn: |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3547 | dev_kfree_skb(beacon); |
| 3548 | if (ret < 0) |
| 3549 | goto out; |
| 3550 | } |
| 3551 | |
| 3552 | out: |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3553 | if (ret != 0) |
| 3554 | wl1271_error("beacon info change failed: %d", ret); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3555 | return ret; |
| 3556 | } |
| 3557 | |
| 3558 | /* AP mode changes */ |
| 3559 | static void wl1271_bss_info_changed_ap(struct wl1271 *wl, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3560 | struct ieee80211_vif *vif, |
| 3561 | struct ieee80211_bss_conf *bss_conf, |
| 3562 | u32 changed) |
| 3563 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3564 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3565 | int ret = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3566 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3567 | if ((changed & BSS_CHANGED_BASIC_RATES)) { |
| 3568 | u32 rates = bss_conf->basic_rates; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3569 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3570 | wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 3571 | wlvif->band); |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 3572 | wlvif->basic_rate = wl1271_tx_min_rate_get(wl, |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3573 | wlvif->basic_rate_set); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3574 | |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3575 | ret = wl1271_init_ap_rates(wl, wlvif); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3576 | if (ret < 0) { |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 3577 | wl1271_error("AP rate policy change failed %d", ret); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3578 | goto out; |
Juuso Oikarinen | e0d8bbf | 2009-12-11 15:41:04 +0200 | [diff] [blame] | 3579 | } |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 3580 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 3581 | ret = wl1271_ap_init_templates(wl, vif); |
Arik Nemtsov | c45a85b | 2011-04-18 14:15:26 +0300 | [diff] [blame] | 3582 | if (ret < 0) |
| 3583 | goto out; |
Juuso Oikarinen | e0d8bbf | 2009-12-11 15:41:04 +0200 | [diff] [blame] | 3584 | } |
| 3585 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3586 | ret = wl1271_bss_beacon_info_changed(wl, vif, bss_conf, changed); |
| 3587 | if (ret < 0) |
| 3588 | goto out; |
| 3589 | |
| 3590 | if ((changed & BSS_CHANGED_BEACON_ENABLED)) { |
| 3591 | if (bss_conf->enable_beacon) { |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 3592 | if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3593 | ret = wl12xx_cmd_role_start_ap(wl, wlvif); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3594 | if (ret < 0) |
| 3595 | goto out; |
| 3596 | |
Eliad Peller | a8ab39a | 2011-10-05 11:55:54 +0200 | [diff] [blame] | 3597 | ret = wl1271_ap_init_hwenc(wl, wlvif); |
Arik Nemtsov | 7f179b4 | 2010-10-16 21:39:06 +0200 | [diff] [blame] | 3598 | if (ret < 0) |
| 3599 | goto out; |
Arik Nemtsov | cf42039 | 2011-08-14 13:17:37 +0300 | [diff] [blame] | 3600 | |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 3601 | set_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); |
Arik Nemtsov | cf42039 | 2011-08-14 13:17:37 +0300 | [diff] [blame] | 3602 | wl1271_debug(DEBUG_AP, "started AP"); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3603 | } |
| 3604 | } else { |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 3605 | if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3606 | ret = wl12xx_cmd_role_stop_ap(wl, wlvif); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3607 | if (ret < 0) |
| 3608 | goto out; |
| 3609 | |
Eliad Peller | 53d40d0 | 2011-10-10 10:13:02 +0200 | [diff] [blame] | 3610 | clear_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); |
Arik Nemtsov | 560f002 | 2011-11-08 18:46:54 +0200 | [diff] [blame] | 3611 | clear_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, |
| 3612 | &wlvif->flags); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3613 | wl1271_debug(DEBUG_AP, "stopped AP"); |
| 3614 | } |
| 3615 | } |
| 3616 | } |
| 3617 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3618 | ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3619 | if (ret < 0) |
| 3620 | goto out; |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 3621 | |
| 3622 | /* Handle HT information change */ |
| 3623 | if ((changed & BSS_CHANGED_HT) && |
| 3624 | (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3625 | ret = wl1271_acx_set_ht_information(wl, wlvif, |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 3626 | bss_conf->ht_operation_mode); |
| 3627 | if (ret < 0) { |
| 3628 | wl1271_warning("Set ht information failed %d", ret); |
| 3629 | goto out; |
| 3630 | } |
| 3631 | } |
| 3632 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3633 | out: |
| 3634 | return; |
| 3635 | } |
| 3636 | |
| 3637 | /* STA/IBSS mode changes */ |
| 3638 | static void wl1271_bss_info_changed_sta(struct wl1271 *wl, |
| 3639 | struct ieee80211_vif *vif, |
| 3640 | struct ieee80211_bss_conf *bss_conf, |
| 3641 | u32 changed) |
| 3642 | { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3643 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3644 | bool do_join = false, set_assoc = false; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3645 | bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 3646 | bool ibss_joined = false; |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 3647 | u32 sta_rate_set = 0; |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3648 | int ret; |
Luciano Coelho | 2d6e4e76 | 2011-01-11 19:07:21 +0100 | [diff] [blame] | 3649 | struct ieee80211_sta *sta; |
Arik Nemtsov | a100885 | 2011-02-12 23:24:20 +0200 | [diff] [blame] | 3650 | bool sta_exists = false; |
| 3651 | struct ieee80211_sta_ht_cap sta_ht_cap; |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3652 | |
| 3653 | if (is_ibss) { |
| 3654 | ret = wl1271_bss_beacon_info_changed(wl, vif, bss_conf, |
| 3655 | changed); |
| 3656 | if (ret < 0) |
| 3657 | goto out; |
| 3658 | } |
| 3659 | |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 3660 | if (changed & BSS_CHANGED_IBSS) { |
| 3661 | if (bss_conf->ibss_joined) { |
Eliad Peller | eee514e | 2011-10-10 10:13:01 +0200 | [diff] [blame] | 3662 | set_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags); |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 3663 | ibss_joined = true; |
| 3664 | } else { |
Eliad Peller | eee514e | 2011-10-10 10:13:01 +0200 | [diff] [blame] | 3665 | if (test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, |
Eliad Peller | 349345a | 2012-03-04 10:55:45 +0200 | [diff] [blame] | 3666 | &wlvif->flags)) |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3667 | wl1271_unjoin(wl, wlvif); |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 3668 | } |
| 3669 | } |
| 3670 | |
| 3671 | if ((changed & BSS_CHANGED_BEACON_INT) && ibss_joined) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3672 | do_join = true; |
| 3673 | |
| 3674 | /* Need to update the SSID (for filtering etc) */ |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 3675 | if ((changed & BSS_CHANGED_BEACON) && ibss_joined) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3676 | do_join = true; |
| 3677 | |
Eliad Peller | 227e81e | 2011-08-14 13:17:26 +0300 | [diff] [blame] | 3678 | if ((changed & BSS_CHANGED_BEACON_ENABLED) && ibss_joined) { |
Juuso Oikarinen | 5da11dc | 2010-03-26 12:53:24 +0200 | [diff] [blame] | 3679 | wl1271_debug(DEBUG_ADHOC, "ad-hoc beaconing: %s", |
| 3680 | bss_conf->enable_beacon ? "enabled" : "disabled"); |
| 3681 | |
Juuso Oikarinen | 5da11dc | 2010-03-26 12:53:24 +0200 | [diff] [blame] | 3682 | do_join = true; |
| 3683 | } |
| 3684 | |
Eliad Peller | 349345a | 2012-03-04 10:55:45 +0200 | [diff] [blame] | 3685 | if (changed & BSS_CHANGED_IDLE && !is_ibss) { |
Eliad Peller | c31e494 | 2011-10-23 08:21:55 +0200 | [diff] [blame] | 3686 | ret = wl1271_sta_handle_idle(wl, wlvif, bss_conf->idle); |
| 3687 | if (ret < 0) |
| 3688 | wl1271_warning("idle mode change failed %d", ret); |
| 3689 | } |
| 3690 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3691 | if ((changed & BSS_CHANGED_CQM)) { |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 3692 | bool enable = false; |
| 3693 | if (bss_conf->cqm_rssi_thold) |
| 3694 | enable = true; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3695 | ret = wl1271_acx_rssi_snr_trigger(wl, wlvif, enable, |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 3696 | bss_conf->cqm_rssi_thold, |
| 3697 | bss_conf->cqm_rssi_hyst); |
| 3698 | if (ret < 0) |
| 3699 | goto out; |
Eliad Peller | 04324d9 | 2011-10-05 11:56:03 +0200 | [diff] [blame] | 3700 | wlvif->rssi_thold = bss_conf->cqm_rssi_thold; |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 3701 | } |
| 3702 | |
Eliad Peller | 7db4ee6 | 2012-01-24 18:18:42 +0200 | [diff] [blame] | 3703 | if (changed & BSS_CHANGED_BSSID && |
| 3704 | (is_ibss || bss_conf->assoc)) |
Eliad Peller | cdf0949 | 2011-10-05 11:55:44 +0200 | [diff] [blame] | 3705 | if (!is_zero_ether_addr(bss_conf->bssid)) { |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 3706 | ret = wl12xx_cmd_build_null_data(wl, wlvif); |
Eliad Peller | fa287b8 | 2010-12-26 09:27:50 +0100 | [diff] [blame] | 3707 | if (ret < 0) |
| 3708 | goto out; |
Juuso Oikarinen | 30240fc | 2010-02-18 13:25:38 +0200 | [diff] [blame] | 3709 | |
Eliad Peller | 784f694 | 2011-10-05 11:55:39 +0200 | [diff] [blame] | 3710 | ret = wl1271_build_qos_null_data(wl, vif); |
Eliad Peller | fa287b8 | 2010-12-26 09:27:50 +0100 | [diff] [blame] | 3711 | if (ret < 0) |
| 3712 | goto out; |
Saravanan Dhanabal | 141418c | 2010-04-28 09:50:00 +0300 | [diff] [blame] | 3713 | |
Eliad Peller | fa287b8 | 2010-12-26 09:27:50 +0100 | [diff] [blame] | 3714 | /* Need to update the BSSID (for filtering etc) */ |
| 3715 | do_join = true; |
| 3716 | } |
Juuso Oikarinen | 30240fc | 2010-02-18 13:25:38 +0200 | [diff] [blame] | 3717 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3718 | if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_HT)) { |
| 3719 | rcu_read_lock(); |
| 3720 | sta = ieee80211_find_sta(vif, bss_conf->bssid); |
| 3721 | if (!sta) |
| 3722 | goto sta_not_found; |
| 3723 | |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 3724 | /* save the supp_rates of the ap */ |
| 3725 | sta_rate_set = sta->supp_rates[wl->hw->conf.channel->band]; |
| 3726 | if (sta->ht_cap.ht_supported) |
| 3727 | sta_rate_set |= |
| 3728 | (sta->ht_cap.mcs.rx_mask[0] << HW_HT_RATES_OFFSET); |
Arik Nemtsov | a100885 | 2011-02-12 23:24:20 +0200 | [diff] [blame] | 3729 | sta_ht_cap = sta->ht_cap; |
| 3730 | sta_exists = true; |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 3731 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3732 | sta_not_found: |
| 3733 | rcu_read_unlock(); |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 3734 | } |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 3735 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3736 | if ((changed & BSS_CHANGED_ASSOC)) { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3737 | if (bss_conf->assoc) { |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3738 | u32 rates; |
Juuso Oikarinen | 2f6724b | 2010-11-24 08:16:57 +0200 | [diff] [blame] | 3739 | int ieoffset; |
Eliad Peller | 6840e37 | 2011-10-05 11:55:50 +0200 | [diff] [blame] | 3740 | wlvif->aid = bss_conf->aid; |
Juuso Oikarinen | 69e5434 | 2010-05-07 11:39:00 +0300 | [diff] [blame] | 3741 | set_assoc = true; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3742 | |
Luciano Coelho | ae751ba | 2009-10-12 15:08:57 +0300 | [diff] [blame] | 3743 | /* |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3744 | * use basic rates from AP, and determine lowest rate |
| 3745 | * to use with control frames. |
| 3746 | */ |
| 3747 | rates = bss_conf->basic_rates; |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3748 | wlvif->basic_rate_set = |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3749 | wl1271_tx_enabled_rates_get(wl, rates, |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 3750 | wlvif->band); |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 3751 | wlvif->basic_rate = |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3752 | wl1271_tx_min_rate_get(wl, |
| 3753 | wlvif->basic_rate_set); |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 3754 | if (sta_rate_set) |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 3755 | wlvif->rate_set = |
| 3756 | wl1271_tx_enabled_rates_get(wl, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3757 | sta_rate_set, |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 3758 | wlvif->band); |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 3759 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3760 | if (ret < 0) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3761 | goto out; |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3762 | |
| 3763 | /* |
Luciano Coelho | ae751ba | 2009-10-12 15:08:57 +0300 | [diff] [blame] | 3764 | * with wl1271, we don't need to update the |
| 3765 | * beacon_int and dtim_period, because the firmware |
| 3766 | * updates it by itself when the first beacon is |
| 3767 | * received after a join. |
| 3768 | */ |
Eliad Peller | 6840e37 | 2011-10-05 11:55:50 +0200 | [diff] [blame] | 3769 | ret = wl1271_cmd_build_ps_poll(wl, wlvif, wlvif->aid); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3770 | if (ret < 0) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3771 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3772 | |
Juuso Oikarinen | c2b2d99 | 2010-03-26 12:53:28 +0200 | [diff] [blame] | 3773 | /* |
Juuso Oikarinen | 2f6724b | 2010-11-24 08:16:57 +0200 | [diff] [blame] | 3774 | * Get a template for hardware connection maintenance |
Juuso Oikarinen | c2b2d99 | 2010-03-26 12:53:28 +0200 | [diff] [blame] | 3775 | */ |
Eliad Peller | bddb29b | 2011-10-05 11:55:49 +0200 | [diff] [blame] | 3776 | dev_kfree_skb(wlvif->probereq); |
| 3777 | wlvif->probereq = wl1271_cmd_build_ap_probe_req(wl, |
Eliad Peller | 8358750 | 2011-10-10 10:12:53 +0200 | [diff] [blame] | 3778 | wlvif, |
Eliad Peller | bddb29b | 2011-10-05 11:55:49 +0200 | [diff] [blame] | 3779 | NULL); |
Juuso Oikarinen | 2f6724b | 2010-11-24 08:16:57 +0200 | [diff] [blame] | 3780 | ieoffset = offsetof(struct ieee80211_mgmt, |
| 3781 | u.probe_req.variable); |
Eliad Peller | bddb29b | 2011-10-05 11:55:49 +0200 | [diff] [blame] | 3782 | wl1271_ssid_set(vif, wlvif->probereq, ieoffset); |
Juuso Oikarinen | c2b2d99 | 2010-03-26 12:53:28 +0200 | [diff] [blame] | 3783 | |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 3784 | /* enable the connection monitoring feature */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3785 | ret = wl1271_acx_conn_monit_params(wl, wlvif, true); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3786 | if (ret < 0) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3787 | goto out; |
Juuso Oikarinen | d94cd29 | 2009-10-08 21:56:25 +0300 | [diff] [blame] | 3788 | } else { |
| 3789 | /* use defaults when not associated */ |
Eliad Peller | 30df14d | 2011-04-05 19:13:28 +0300 | [diff] [blame] | 3790 | bool was_assoc = |
Eliad Peller | ba8447f | 2011-10-10 10:13:00 +0200 | [diff] [blame] | 3791 | !!test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, |
| 3792 | &wlvif->flags); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3793 | bool was_ifup = |
Eliad Peller | 8181aec | 2011-10-10 10:13:04 +0200 | [diff] [blame] | 3794 | !!test_and_clear_bit(WLVIF_FLAG_STA_STATE_SENT, |
| 3795 | &wlvif->flags); |
Eliad Peller | 6840e37 | 2011-10-05 11:55:50 +0200 | [diff] [blame] | 3796 | wlvif->aid = 0; |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 3797 | |
Juuso Oikarinen | 2f6724b | 2010-11-24 08:16:57 +0200 | [diff] [blame] | 3798 | /* free probe-request template */ |
Eliad Peller | bddb29b | 2011-10-05 11:55:49 +0200 | [diff] [blame] | 3799 | dev_kfree_skb(wlvif->probereq); |
| 3800 | wlvif->probereq = NULL; |
Juuso Oikarinen | 2f6724b | 2010-11-24 08:16:57 +0200 | [diff] [blame] | 3801 | |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3802 | /* revert back to minimum rates for the current band */ |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3803 | wl1271_set_band_rate(wl, wlvif); |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 3804 | wlvif->basic_rate = |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3805 | wl1271_tx_min_rate_get(wl, |
| 3806 | wlvif->basic_rate_set); |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 3807 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3808 | if (ret < 0) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3809 | goto out; |
Juuso Oikarinen | ebba60c | 2010-04-01 11:38:20 +0300 | [diff] [blame] | 3810 | |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 3811 | /* disable connection monitor features */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3812 | ret = wl1271_acx_conn_monit_params(wl, wlvif, false); |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 3813 | |
| 3814 | /* Disable the keep-alive feature */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3815 | ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 3816 | if (ret < 0) |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3817 | goto out; |
Juuso Oikarinen | b84a7d3 | 2010-11-22 12:59:08 +0200 | [diff] [blame] | 3818 | |
| 3819 | /* restore the bssid filter and go to dummy bssid */ |
Eliad Peller | 30df14d | 2011-04-05 19:13:28 +0300 | [diff] [blame] | 3820 | if (was_assoc) { |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3821 | /* |
| 3822 | * we might have to disable roc, if there was |
| 3823 | * no IF_OPER_UP notification. |
| 3824 | */ |
| 3825 | if (!was_ifup) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3826 | ret = wl12xx_croc(wl, wlvif->role_id); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3827 | if (ret < 0) |
| 3828 | goto out; |
| 3829 | } |
| 3830 | /* |
| 3831 | * (we also need to disable roc in case of |
| 3832 | * roaming on the same channel. until we will |
| 3833 | * have a better flow...) |
| 3834 | */ |
Eliad Peller | 7edebf5 | 2011-10-05 11:55:52 +0200 | [diff] [blame] | 3835 | if (test_bit(wlvif->dev_role_id, wl->roc_map)) { |
| 3836 | ret = wl12xx_croc(wl, |
| 3837 | wlvif->dev_role_id); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3838 | if (ret < 0) |
| 3839 | goto out; |
| 3840 | } |
| 3841 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3842 | wl1271_unjoin(wl, wlvif); |
Eliad Peller | 8a6a84a | 2012-03-04 10:55:46 +0200 | [diff] [blame] | 3843 | if (!bss_conf->idle) |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 3844 | wl12xx_start_dev(wl, wlvif); |
Eliad Peller | 30df14d | 2011-04-05 19:13:28 +0300 | [diff] [blame] | 3845 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3846 | } |
| 3847 | } |
Juuso Oikarinen | 8a5a37a | 2009-10-08 21:56:24 +0300 | [diff] [blame] | 3848 | |
Eliad Peller | d192d26 | 2011-05-24 14:33:08 +0300 | [diff] [blame] | 3849 | if (changed & BSS_CHANGED_IBSS) { |
| 3850 | wl1271_debug(DEBUG_ADHOC, "ibss_joined: %d", |
| 3851 | bss_conf->ibss_joined); |
| 3852 | |
| 3853 | if (bss_conf->ibss_joined) { |
| 3854 | u32 rates = bss_conf->basic_rates; |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3855 | wlvif->basic_rate_set = |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 3856 | wl1271_tx_enabled_rates_get(wl, rates, |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 3857 | wlvif->band); |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 3858 | wlvif->basic_rate = |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3859 | wl1271_tx_min_rate_get(wl, |
| 3860 | wlvif->basic_rate_set); |
Eliad Peller | d192d26 | 2011-05-24 14:33:08 +0300 | [diff] [blame] | 3861 | |
Shahar Levi | 06b660e | 2011-09-05 13:54:36 +0300 | [diff] [blame] | 3862 | /* by default, use 11b + OFDM rates */ |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 3863 | wlvif->rate_set = CONF_TX_IBSS_DEFAULT_RATES; |
| 3864 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
Eliad Peller | d192d26 | 2011-05-24 14:33:08 +0300 | [diff] [blame] | 3865 | if (ret < 0) |
| 3866 | goto out; |
| 3867 | } |
| 3868 | } |
| 3869 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3870 | ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3871 | if (ret < 0) |
| 3872 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 3873 | |
Juuso Oikarinen | 8bf29b0 | 2010-02-18 13:25:51 +0200 | [diff] [blame] | 3874 | if (do_join) { |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 3875 | ret = wl1271_join(wl, wlvif, set_assoc); |
Juuso Oikarinen | 8bf29b0 | 2010-02-18 13:25:51 +0200 | [diff] [blame] | 3876 | if (ret < 0) { |
| 3877 | wl1271_warning("cmd join failed %d", ret); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3878 | goto out; |
Juuso Oikarinen | 8bf29b0 | 2010-02-18 13:25:51 +0200 | [diff] [blame] | 3879 | } |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3880 | |
| 3881 | /* ROC until connected (after EAPOL exchange) */ |
| 3882 | if (!is_ibss) { |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 3883 | ret = wl12xx_roc(wl, wlvif, wlvif->role_id); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3884 | if (ret < 0) |
| 3885 | goto out; |
| 3886 | |
Eliad Peller | 9fd6f21 | 2012-03-04 10:55:48 +0200 | [diff] [blame^] | 3887 | if (test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags)) |
| 3888 | wl12xx_set_authorized(wl, wlvif); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3889 | } |
| 3890 | /* |
| 3891 | * stop device role if started (we might already be in |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 3892 | * STA/IBSS role). |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3893 | */ |
Eliad Peller | 92e712d | 2011-12-18 20:25:43 +0200 | [diff] [blame] | 3894 | if (wl12xx_dev_role_started(wlvif)) { |
Eliad Peller | 679a673 | 2011-10-11 11:55:44 +0200 | [diff] [blame] | 3895 | ret = wl12xx_stop_dev(wl, wlvif); |
Eliad Peller | 251c177 | 2011-08-14 13:17:17 +0300 | [diff] [blame] | 3896 | if (ret < 0) |
| 3897 | goto out; |
| 3898 | } |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 3899 | } |
| 3900 | |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 3901 | /* Handle new association with HT. Do this after join. */ |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3902 | if (sta_exists) { |
| 3903 | if ((changed & BSS_CHANGED_HT) && |
| 3904 | (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 3905 | ret = wl1271_acx_set_ht_capabilities(wl, |
| 3906 | &sta_ht_cap, |
| 3907 | true, |
Eliad Peller | 154da67 | 2011-10-05 11:55:53 +0200 | [diff] [blame] | 3908 | wlvif->sta.hlid); |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3909 | if (ret < 0) { |
| 3910 | wl1271_warning("Set ht cap true failed %d", |
| 3911 | ret); |
| 3912 | goto out; |
| 3913 | } |
| 3914 | } |
| 3915 | /* handle new association without HT and disassociation */ |
| 3916 | else if (changed & BSS_CHANGED_ASSOC) { |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 3917 | ret = wl1271_acx_set_ht_capabilities(wl, |
| 3918 | &sta_ht_cap, |
| 3919 | false, |
Eliad Peller | 154da67 | 2011-10-05 11:55:53 +0200 | [diff] [blame] | 3920 | wlvif->sta.hlid); |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3921 | if (ret < 0) { |
| 3922 | wl1271_warning("Set ht cap false failed %d", |
| 3923 | ret); |
| 3924 | goto out; |
| 3925 | } |
| 3926 | } |
| 3927 | } |
| 3928 | |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 3929 | /* Handle HT information change. Done after join. */ |
| 3930 | if ((changed & BSS_CHANGED_HT) && |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3931 | (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 3932 | ret = wl1271_acx_set_ht_information(wl, wlvif, |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 3933 | bss_conf->ht_operation_mode); |
| 3934 | if (ret < 0) { |
| 3935 | wl1271_warning("Set ht information failed %d", ret); |
| 3936 | goto out; |
| 3937 | } |
| 3938 | } |
| 3939 | |
Eliad Peller | 76a74c8 | 2012-02-02 12:22:11 +0200 | [diff] [blame] | 3940 | /* Handle arp filtering. Done after join. */ |
| 3941 | if ((changed & BSS_CHANGED_ARP_FILTER) || |
| 3942 | (!is_ibss && (changed & BSS_CHANGED_QOS))) { |
| 3943 | __be32 addr = bss_conf->arp_addr_list[0]; |
| 3944 | wlvif->sta.qos = bss_conf->qos; |
| 3945 | WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS); |
| 3946 | |
| 3947 | if (bss_conf->arp_addr_cnt == 1 && |
| 3948 | bss_conf->arp_filter_enabled) { |
| 3949 | wlvif->ip_addr = addr; |
| 3950 | /* |
| 3951 | * The template should have been configured only upon |
| 3952 | * association. however, it seems that the correct ip |
| 3953 | * isn't being set (when sending), so we have to |
| 3954 | * reconfigure the template upon every ip change. |
| 3955 | */ |
| 3956 | ret = wl1271_cmd_build_arp_rsp(wl, wlvif); |
| 3957 | if (ret < 0) { |
| 3958 | wl1271_warning("build arp rsp failed: %d", ret); |
| 3959 | goto out; |
| 3960 | } |
| 3961 | |
| 3962 | ret = wl1271_acx_arp_ip_filter(wl, wlvif, |
| 3963 | (ACX_ARP_FILTER_ARP_FILTERING | |
| 3964 | ACX_ARP_FILTER_AUTO_ARP), |
| 3965 | addr); |
| 3966 | } else { |
| 3967 | wlvif->ip_addr = 0; |
| 3968 | ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr); |
| 3969 | } |
| 3970 | |
| 3971 | if (ret < 0) |
| 3972 | goto out; |
| 3973 | } |
| 3974 | |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3975 | out: |
| 3976 | return; |
| 3977 | } |
| 3978 | |
| 3979 | static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw, |
| 3980 | struct ieee80211_vif *vif, |
| 3981 | struct ieee80211_bss_conf *bss_conf, |
| 3982 | u32 changed) |
| 3983 | { |
| 3984 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 3985 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
| 3986 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 3987 | int ret; |
| 3988 | |
| 3989 | wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed 0x%x", |
| 3990 | (int)changed); |
| 3991 | |
| 3992 | mutex_lock(&wl->mutex); |
| 3993 | |
| 3994 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 3995 | goto out; |
| 3996 | |
Eliad Peller | 10c8cd0 | 2011-10-10 10:13:06 +0200 | [diff] [blame] | 3997 | if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))) |
| 3998 | goto out; |
| 3999 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 4000 | ret = wl1271_ps_elp_wakeup(wl); |
Arik Nemtsov | e78a287 | 2010-10-16 19:07:21 +0200 | [diff] [blame] | 4001 | if (ret < 0) |
| 4002 | goto out; |
| 4003 | |
| 4004 | if (is_ap) |
| 4005 | wl1271_bss_info_changed_ap(wl, vif, bss_conf, changed); |
| 4006 | else |
| 4007 | wl1271_bss_info_changed_sta(wl, vif, bss_conf, changed); |
| 4008 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4009 | wl1271_ps_elp_sleep(wl); |
| 4010 | |
| 4011 | out: |
| 4012 | mutex_unlock(&wl->mutex); |
| 4013 | } |
| 4014 | |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 4015 | static int wl1271_op_conf_tx(struct ieee80211_hw *hw, |
| 4016 | struct ieee80211_vif *vif, u16 queue, |
Kalle Valo | c6999d8 | 2010-02-18 13:25:41 +0200 | [diff] [blame] | 4017 | const struct ieee80211_tx_queue_params *params) |
| 4018 | { |
| 4019 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 4020 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Kalle Valo | 4695dc9 | 2010-03-18 12:26:38 +0200 | [diff] [blame] | 4021 | u8 ps_scheme; |
Arik Nemtsov | 488fc54 | 2010-10-16 20:33:45 +0200 | [diff] [blame] | 4022 | int ret = 0; |
Kalle Valo | c6999d8 | 2010-02-18 13:25:41 +0200 | [diff] [blame] | 4023 | |
| 4024 | mutex_lock(&wl->mutex); |
| 4025 | |
| 4026 | wl1271_debug(DEBUG_MAC80211, "mac80211 conf tx %d", queue); |
| 4027 | |
Kalle Valo | 4695dc9 | 2010-03-18 12:26:38 +0200 | [diff] [blame] | 4028 | if (params->uapsd) |
| 4029 | ps_scheme = CONF_PS_SCHEME_UPSD_TRIGGER; |
| 4030 | else |
| 4031 | ps_scheme = CONF_PS_SCHEME_LEGACY; |
| 4032 | |
Eliad Peller | 5b37ddf | 2011-12-18 20:25:40 +0200 | [diff] [blame] | 4033 | if (!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 4034 | goto out; |
Arik Nemtsov | 488fc54 | 2010-10-16 20:33:45 +0200 | [diff] [blame] | 4035 | |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 4036 | ret = wl1271_ps_elp_wakeup(wl); |
| 4037 | if (ret < 0) |
| 4038 | goto out; |
Arik Nemtsov | 488fc54 | 2010-10-16 20:33:45 +0200 | [diff] [blame] | 4039 | |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 4040 | /* |
| 4041 | * the txop is confed in units of 32us by the mac80211, |
| 4042 | * we need us |
| 4043 | */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 4044 | ret = wl1271_acx_ac_cfg(wl, wlvif, wl1271_tx_get_queue(queue), |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 4045 | params->cw_min, params->cw_max, |
| 4046 | params->aifs, params->txop << 5); |
| 4047 | if (ret < 0) |
| 4048 | goto out_sleep; |
| 4049 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 4050 | ret = wl1271_acx_tid_cfg(wl, wlvif, wl1271_tx_get_queue(queue), |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 4051 | CONF_CHANNEL_TYPE_EDCF, |
| 4052 | wl1271_tx_get_queue(queue), |
| 4053 | ps_scheme, CONF_ACK_POLICY_LEGACY, |
| 4054 | 0, 0); |
Kalle Valo | c82c1dd | 2010-02-18 13:25:47 +0200 | [diff] [blame] | 4055 | |
| 4056 | out_sleep: |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 4057 | wl1271_ps_elp_sleep(wl); |
Kalle Valo | c6999d8 | 2010-02-18 13:25:41 +0200 | [diff] [blame] | 4058 | |
| 4059 | out: |
| 4060 | mutex_unlock(&wl->mutex); |
| 4061 | |
| 4062 | return ret; |
| 4063 | } |
| 4064 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 4065 | static u64 wl1271_op_get_tsf(struct ieee80211_hw *hw, |
| 4066 | struct ieee80211_vif *vif) |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 4067 | { |
| 4068 | |
| 4069 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 9c53114 | 2012-01-31 11:57:18 +0200 | [diff] [blame] | 4070 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 4071 | u64 mactime = ULLONG_MAX; |
| 4072 | int ret; |
| 4073 | |
| 4074 | wl1271_debug(DEBUG_MAC80211, "mac80211 get tsf"); |
| 4075 | |
| 4076 | mutex_lock(&wl->mutex); |
| 4077 | |
Juuso Oikarinen | f8d9802 | 2010-10-26 13:24:39 +0200 | [diff] [blame] | 4078 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 4079 | goto out; |
| 4080 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 4081 | ret = wl1271_ps_elp_wakeup(wl); |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 4082 | if (ret < 0) |
| 4083 | goto out; |
| 4084 | |
Eliad Peller | 9c53114 | 2012-01-31 11:57:18 +0200 | [diff] [blame] | 4085 | ret = wl12xx_acx_tsf_info(wl, wlvif, &mactime); |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 4086 | if (ret < 0) |
| 4087 | goto out_sleep; |
| 4088 | |
| 4089 | out_sleep: |
| 4090 | wl1271_ps_elp_sleep(wl); |
| 4091 | |
| 4092 | out: |
| 4093 | mutex_unlock(&wl->mutex); |
| 4094 | return mactime; |
| 4095 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4096 | |
John W. Linville | ece550d | 2010-07-28 16:41:06 -0400 | [diff] [blame] | 4097 | static int wl1271_op_get_survey(struct ieee80211_hw *hw, int idx, |
| 4098 | struct survey_info *survey) |
| 4099 | { |
| 4100 | struct wl1271 *wl = hw->priv; |
| 4101 | struct ieee80211_conf *conf = &hw->conf; |
Juuso Oikarinen | b739a42 | 2010-10-26 13:24:38 +0200 | [diff] [blame] | 4102 | |
John W. Linville | ece550d | 2010-07-28 16:41:06 -0400 | [diff] [blame] | 4103 | if (idx != 0) |
| 4104 | return -ENOENT; |
Juuso Oikarinen | b739a42 | 2010-10-26 13:24:38 +0200 | [diff] [blame] | 4105 | |
John W. Linville | ece550d | 2010-07-28 16:41:06 -0400 | [diff] [blame] | 4106 | survey->channel = conf->channel; |
| 4107 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 4108 | survey->noise = wl->noise; |
Juuso Oikarinen | b739a42 | 2010-10-26 13:24:38 +0200 | [diff] [blame] | 4109 | |
John W. Linville | ece550d | 2010-07-28 16:41:06 -0400 | [diff] [blame] | 4110 | return 0; |
| 4111 | } |
| 4112 | |
Arik Nemtsov | 409622e | 2011-02-23 00:22:29 +0200 | [diff] [blame] | 4113 | static int wl1271_allocate_sta(struct wl1271 *wl, |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4114 | struct wl12xx_vif *wlvif, |
| 4115 | struct ieee80211_sta *sta) |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4116 | { |
| 4117 | struct wl1271_station *wl_sta; |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4118 | int ret; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4119 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4120 | |
| 4121 | if (wl->active_sta_count >= AP_MAX_STATIONS) { |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4122 | wl1271_warning("could not allocate HLID - too much stations"); |
| 4123 | return -EBUSY; |
| 4124 | } |
| 4125 | |
| 4126 | wl_sta = (struct wl1271_station *)sta->drv_priv; |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4127 | ret = wl12xx_allocate_link(wl, wlvif, &wl_sta->hlid); |
| 4128 | if (ret < 0) { |
| 4129 | wl1271_warning("could not allocate HLID - too many links"); |
| 4130 | return -EBUSY; |
| 4131 | } |
| 4132 | |
| 4133 | set_bit(wl_sta->hlid, wlvif->ap.sta_hlid_map); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 4134 | memcpy(wl->links[wl_sta->hlid].addr, sta->addr, ETH_ALEN); |
Arik Nemtsov | da03209 | 2011-08-25 12:43:15 +0300 | [diff] [blame] | 4135 | wl->active_sta_count++; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4136 | return 0; |
| 4137 | } |
| 4138 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4139 | void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4140 | { |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4141 | if (!test_bit(hlid, wlvif->ap.sta_hlid_map)) |
Arik Nemtsov | f1acea9 | 2011-08-25 12:43:17 +0300 | [diff] [blame] | 4142 | return; |
| 4143 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4144 | clear_bit(hlid, wlvif->ap.sta_hlid_map); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 4145 | memset(wl->links[hlid].addr, 0, ETH_ALEN); |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 4146 | wl->links[hlid].ba_bitmap = 0; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 4147 | __clear_bit(hlid, &wl->ap_ps_map); |
| 4148 | __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4149 | wl12xx_free_link(wl, wlvif, &hlid); |
Arik Nemtsov | da03209 | 2011-08-25 12:43:15 +0300 | [diff] [blame] | 4150 | wl->active_sta_count--; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4151 | } |
| 4152 | |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4153 | static int wl12xx_sta_add(struct wl1271 *wl, |
| 4154 | struct wl12xx_vif *wlvif, |
| 4155 | struct ieee80211_sta *sta) |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4156 | { |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4157 | struct wl1271_station *wl_sta; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4158 | int ret = 0; |
| 4159 | u8 hlid; |
| 4160 | |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4161 | wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); |
| 4162 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4163 | ret = wl1271_allocate_sta(wl, wlvif, sta); |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4164 | if (ret < 0) |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4165 | return ret; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4166 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4167 | wl_sta = (struct wl1271_station *)sta->drv_priv; |
| 4168 | hlid = wl_sta->hlid; |
| 4169 | |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 4170 | ret = wl12xx_cmd_add_peer(wl, wlvif, sta, hlid); |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4171 | if (ret < 0) |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4172 | wl1271_free_sta(wl, wlvif, hlid); |
Arik Nemtsov | 409622e | 2011-02-23 00:22:29 +0200 | [diff] [blame] | 4173 | |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4174 | return ret; |
| 4175 | } |
| 4176 | |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4177 | static int wl12xx_sta_remove(struct wl1271 *wl, |
| 4178 | struct wl12xx_vif *wlvif, |
| 4179 | struct ieee80211_sta *sta) |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4180 | { |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4181 | struct wl1271_station *wl_sta; |
| 4182 | int ret = 0, id; |
| 4183 | |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4184 | wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); |
| 4185 | |
| 4186 | wl_sta = (struct wl1271_station *)sta->drv_priv; |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 4187 | id = wl_sta->hlid; |
| 4188 | if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map))) |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4189 | return -EINVAL; |
| 4190 | |
| 4191 | ret = wl12xx_cmd_remove_peer(wl, wl_sta->hlid); |
| 4192 | if (ret < 0) |
| 4193 | return ret; |
| 4194 | |
| 4195 | wl1271_free_sta(wl, wlvif, wl_sta->hlid); |
| 4196 | return ret; |
| 4197 | } |
| 4198 | |
| 4199 | static int wl12xx_update_sta_state(struct wl1271 *wl, |
| 4200 | struct wl12xx_vif *wlvif, |
| 4201 | struct ieee80211_sta *sta, |
| 4202 | enum ieee80211_sta_state old_state, |
| 4203 | enum ieee80211_sta_state new_state) |
| 4204 | { |
| 4205 | struct wl1271_station *wl_sta; |
| 4206 | u8 hlid; |
| 4207 | bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS; |
| 4208 | bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; |
| 4209 | int ret; |
| 4210 | |
| 4211 | wl_sta = (struct wl1271_station *)sta->drv_priv; |
| 4212 | hlid = wl_sta->hlid; |
| 4213 | |
| 4214 | /* Add station (AP mode) */ |
| 4215 | if (is_ap && |
| 4216 | old_state == IEEE80211_STA_NOTEXIST && |
| 4217 | new_state == IEEE80211_STA_NONE) |
| 4218 | return wl12xx_sta_add(wl, wlvif, sta); |
| 4219 | |
| 4220 | /* Remove station (AP mode) */ |
| 4221 | if (is_ap && |
| 4222 | old_state == IEEE80211_STA_NONE && |
| 4223 | new_state == IEEE80211_STA_NOTEXIST) { |
| 4224 | /* must not fail */ |
| 4225 | wl12xx_sta_remove(wl, wlvif, sta); |
| 4226 | return 0; |
| 4227 | } |
| 4228 | |
| 4229 | /* Authorize station (AP mode) */ |
| 4230 | if (is_ap && |
| 4231 | new_state == IEEE80211_STA_AUTHORIZED) { |
| 4232 | ret = wl12xx_cmd_set_peer_state(wl, hlid); |
| 4233 | if (ret < 0) |
| 4234 | return ret; |
| 4235 | |
| 4236 | ret = wl1271_acx_set_ht_capabilities(wl, &sta->ht_cap, true, |
| 4237 | hlid); |
| 4238 | return ret; |
| 4239 | } |
| 4240 | |
Eliad Peller | 9fd6f21 | 2012-03-04 10:55:48 +0200 | [diff] [blame^] | 4241 | /* Authorize station */ |
| 4242 | if (is_sta && |
| 4243 | new_state == IEEE80211_STA_AUTHORIZED) { |
| 4244 | set_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags); |
| 4245 | return wl12xx_set_authorized(wl, wlvif); |
| 4246 | } |
| 4247 | |
| 4248 | if (is_sta && |
| 4249 | old_state == IEEE80211_STA_AUTHORIZED && |
| 4250 | new_state == IEEE80211_STA_ASSOC) { |
| 4251 | clear_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags); |
| 4252 | return 0; |
| 4253 | } |
| 4254 | |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4255 | return 0; |
| 4256 | } |
| 4257 | |
| 4258 | static int wl12xx_op_sta_state(struct ieee80211_hw *hw, |
| 4259 | struct ieee80211_vif *vif, |
| 4260 | struct ieee80211_sta *sta, |
| 4261 | enum ieee80211_sta_state old_state, |
| 4262 | enum ieee80211_sta_state new_state) |
| 4263 | { |
| 4264 | struct wl1271 *wl = hw->priv; |
| 4265 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
| 4266 | int ret; |
| 4267 | |
| 4268 | wl1271_debug(DEBUG_MAC80211, "mac80211 sta %d state=%d->%d", |
| 4269 | sta->aid, old_state, new_state); |
| 4270 | |
| 4271 | mutex_lock(&wl->mutex); |
| 4272 | |
| 4273 | if (unlikely(wl->state == WL1271_STATE_OFF)) { |
| 4274 | ret = -EBUSY; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4275 | goto out; |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4276 | } |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4277 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 4278 | ret = wl1271_ps_elp_wakeup(wl); |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4279 | if (ret < 0) |
| 4280 | goto out; |
| 4281 | |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4282 | ret = wl12xx_update_sta_state(wl, wlvif, sta, old_state, new_state); |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4283 | |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4284 | wl1271_ps_elp_sleep(wl); |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4285 | out: |
| 4286 | mutex_unlock(&wl->mutex); |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4287 | if (new_state < old_state) |
| 4288 | return 0; |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 4289 | return ret; |
| 4290 | } |
| 4291 | |
Luciano Coelho | 4623ec7 | 2011-03-21 19:26:41 +0200 | [diff] [blame] | 4292 | static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, |
| 4293 | struct ieee80211_vif *vif, |
| 4294 | enum ieee80211_ampdu_mlme_action action, |
| 4295 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, |
| 4296 | u8 buf_size) |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4297 | { |
| 4298 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 4299 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4300 | int ret; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 4301 | u8 hlid, *ba_bitmap; |
| 4302 | |
| 4303 | wl1271_debug(DEBUG_MAC80211, "mac80211 ampdu action %d tid %d", action, |
| 4304 | tid); |
| 4305 | |
| 4306 | /* sanity check - the fields in FW are only 8bits wide */ |
| 4307 | if (WARN_ON(tid > 0xFF)) |
| 4308 | return -ENOTSUPP; |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4309 | |
| 4310 | mutex_lock(&wl->mutex); |
| 4311 | |
| 4312 | if (unlikely(wl->state == WL1271_STATE_OFF)) { |
| 4313 | ret = -EAGAIN; |
| 4314 | goto out; |
| 4315 | } |
| 4316 | |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 4317 | if (wlvif->bss_type == BSS_TYPE_STA_BSS) { |
Eliad Peller | 154da67 | 2011-10-05 11:55:53 +0200 | [diff] [blame] | 4318 | hlid = wlvif->sta.hlid; |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 4319 | ba_bitmap = &wlvif->sta.ba_rx_bitmap; |
Eliad Peller | 536129c | 2011-10-05 11:55:45 +0200 | [diff] [blame] | 4320 | } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 4321 | struct wl1271_station *wl_sta; |
| 4322 | |
| 4323 | wl_sta = (struct wl1271_station *)sta->drv_priv; |
| 4324 | hlid = wl_sta->hlid; |
| 4325 | ba_bitmap = &wl->links[hlid].ba_bitmap; |
| 4326 | } else { |
| 4327 | ret = -EINVAL; |
| 4328 | goto out; |
| 4329 | } |
| 4330 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 4331 | ret = wl1271_ps_elp_wakeup(wl); |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4332 | if (ret < 0) |
| 4333 | goto out; |
| 4334 | |
Shahar Levi | 70559a0 | 2011-05-22 16:10:22 +0300 | [diff] [blame] | 4335 | wl1271_debug(DEBUG_MAC80211, "mac80211 ampdu: Rx tid %d action %d", |
| 4336 | tid, action); |
| 4337 | |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4338 | switch (action) { |
| 4339 | case IEEE80211_AMPDU_RX_START: |
Eliad Peller | d0802ab | 2011-10-05 11:56:04 +0200 | [diff] [blame] | 4340 | if (!wlvif->ba_support || !wlvif->ba_allowed) { |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4341 | ret = -ENOTSUPP; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 4342 | break; |
| 4343 | } |
| 4344 | |
| 4345 | if (wl->ba_rx_session_count >= RX_BA_MAX_SESSIONS) { |
| 4346 | ret = -EBUSY; |
| 4347 | wl1271_error("exceeded max RX BA sessions"); |
| 4348 | break; |
| 4349 | } |
| 4350 | |
| 4351 | if (*ba_bitmap & BIT(tid)) { |
| 4352 | ret = -EINVAL; |
| 4353 | wl1271_error("cannot enable RX BA session on active " |
| 4354 | "tid: %d", tid); |
| 4355 | break; |
| 4356 | } |
| 4357 | |
| 4358 | ret = wl12xx_acx_set_ba_receiver_session(wl, tid, *ssn, true, |
| 4359 | hlid); |
| 4360 | if (!ret) { |
| 4361 | *ba_bitmap |= BIT(tid); |
| 4362 | wl->ba_rx_session_count++; |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4363 | } |
| 4364 | break; |
| 4365 | |
| 4366 | case IEEE80211_AMPDU_RX_STOP: |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 4367 | if (!(*ba_bitmap & BIT(tid))) { |
| 4368 | ret = -EINVAL; |
| 4369 | wl1271_error("no active RX BA session on tid: %d", |
| 4370 | tid); |
| 4371 | break; |
| 4372 | } |
| 4373 | |
| 4374 | ret = wl12xx_acx_set_ba_receiver_session(wl, tid, 0, false, |
| 4375 | hlid); |
| 4376 | if (!ret) { |
| 4377 | *ba_bitmap &= ~BIT(tid); |
| 4378 | wl->ba_rx_session_count--; |
| 4379 | } |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4380 | break; |
| 4381 | |
| 4382 | /* |
| 4383 | * The BA initiator session management in FW independently. |
| 4384 | * Falling break here on purpose for all TX APDU commands. |
| 4385 | */ |
| 4386 | case IEEE80211_AMPDU_TX_START: |
| 4387 | case IEEE80211_AMPDU_TX_STOP: |
| 4388 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 4389 | ret = -EINVAL; |
| 4390 | break; |
| 4391 | |
| 4392 | default: |
| 4393 | wl1271_error("Incorrect ampdu action id=%x\n", action); |
| 4394 | ret = -EINVAL; |
| 4395 | } |
| 4396 | |
| 4397 | wl1271_ps_elp_sleep(wl); |
| 4398 | |
| 4399 | out: |
| 4400 | mutex_unlock(&wl->mutex); |
| 4401 | |
| 4402 | return ret; |
| 4403 | } |
| 4404 | |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4405 | static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, |
| 4406 | struct ieee80211_vif *vif, |
| 4407 | const struct cfg80211_bitrate_mask *mask) |
| 4408 | { |
Eliad Peller | 8358750 | 2011-10-10 10:12:53 +0200 | [diff] [blame] | 4409 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4410 | struct wl1271 *wl = hw->priv; |
Eliad Peller | d6fa37c | 2011-10-11 11:57:39 +0200 | [diff] [blame] | 4411 | int i, ret = 0; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4412 | |
| 4413 | wl1271_debug(DEBUG_MAC80211, "mac80211 set_bitrate_mask 0x%x 0x%x", |
| 4414 | mask->control[NL80211_BAND_2GHZ].legacy, |
| 4415 | mask->control[NL80211_BAND_5GHZ].legacy); |
| 4416 | |
| 4417 | mutex_lock(&wl->mutex); |
| 4418 | |
| 4419 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Eliad Peller | 8358750 | 2011-10-10 10:12:53 +0200 | [diff] [blame] | 4420 | wlvif->bitrate_masks[i] = |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4421 | wl1271_tx_enabled_rates_get(wl, |
| 4422 | mask->control[i].legacy, |
| 4423 | i); |
Eliad Peller | d6fa37c | 2011-10-11 11:57:39 +0200 | [diff] [blame] | 4424 | |
| 4425 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 4426 | goto out; |
| 4427 | |
| 4428 | if (wlvif->bss_type == BSS_TYPE_STA_BSS && |
| 4429 | !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { |
| 4430 | |
| 4431 | ret = wl1271_ps_elp_wakeup(wl); |
| 4432 | if (ret < 0) |
| 4433 | goto out; |
| 4434 | |
| 4435 | wl1271_set_band_rate(wl, wlvif); |
| 4436 | wlvif->basic_rate = |
| 4437 | wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
| 4438 | ret = wl1271_acx_sta_rate_policies(wl, wlvif); |
| 4439 | |
| 4440 | wl1271_ps_elp_sleep(wl); |
| 4441 | } |
| 4442 | out: |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4443 | mutex_unlock(&wl->mutex); |
| 4444 | |
Eliad Peller | d6fa37c | 2011-10-11 11:57:39 +0200 | [diff] [blame] | 4445 | return ret; |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4446 | } |
| 4447 | |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4448 | static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, |
| 4449 | struct ieee80211_channel_switch *ch_switch) |
| 4450 | { |
| 4451 | struct wl1271 *wl = hw->priv; |
Eliad Peller | 52630c5 | 2011-10-10 10:13:08 +0200 | [diff] [blame] | 4452 | struct wl12xx_vif *wlvif; |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4453 | int ret; |
| 4454 | |
| 4455 | wl1271_debug(DEBUG_MAC80211, "mac80211 channel switch"); |
| 4456 | |
Arik Nemtsov | b9239b6 | 2012-02-28 00:41:33 +0200 | [diff] [blame] | 4457 | wl1271_tx_flush(wl); |
| 4458 | |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4459 | mutex_lock(&wl->mutex); |
| 4460 | |
| 4461 | if (unlikely(wl->state == WL1271_STATE_OFF)) { |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 4462 | wl12xx_for_each_wlvif_sta(wl, wlvif) { |
| 4463 | struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); |
| 4464 | ieee80211_chswitch_done(vif, false); |
| 4465 | } |
| 4466 | goto out; |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4467 | } |
| 4468 | |
| 4469 | ret = wl1271_ps_elp_wakeup(wl); |
| 4470 | if (ret < 0) |
| 4471 | goto out; |
| 4472 | |
Eliad Peller | 52630c5 | 2011-10-10 10:13:08 +0200 | [diff] [blame] | 4473 | /* TODO: change mac80211 to pass vif as param */ |
| 4474 | wl12xx_for_each_wlvif_sta(wl, wlvif) { |
Eliad Peller | 8332f0f | 2012-01-31 11:57:19 +0200 | [diff] [blame] | 4475 | ret = wl12xx_cmd_channel_switch(wl, wlvif, ch_switch); |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4476 | |
Eliad Peller | 52630c5 | 2011-10-10 10:13:08 +0200 | [diff] [blame] | 4477 | if (!ret) |
| 4478 | set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags); |
| 4479 | } |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4480 | |
| 4481 | wl1271_ps_elp_sleep(wl); |
| 4482 | |
| 4483 | out: |
| 4484 | mutex_unlock(&wl->mutex); |
| 4485 | } |
| 4486 | |
Arik Nemtsov | 3343789 | 2011-04-26 23:35:39 +0300 | [diff] [blame] | 4487 | static bool wl1271_tx_frames_pending(struct ieee80211_hw *hw) |
| 4488 | { |
| 4489 | struct wl1271 *wl = hw->priv; |
| 4490 | bool ret = false; |
| 4491 | |
| 4492 | mutex_lock(&wl->mutex); |
| 4493 | |
| 4494 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 4495 | goto out; |
| 4496 | |
| 4497 | /* packets are considered pending if in the TX queue or the FW */ |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 4498 | ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0); |
Arik Nemtsov | 3343789 | 2011-04-26 23:35:39 +0300 | [diff] [blame] | 4499 | out: |
| 4500 | mutex_unlock(&wl->mutex); |
| 4501 | |
| 4502 | return ret; |
| 4503 | } |
| 4504 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4505 | /* can't be const, mac80211 writes to this */ |
| 4506 | static struct ieee80211_rate wl1271_rates[] = { |
| 4507 | { .bitrate = 10, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4508 | .hw_value = CONF_HW_BIT_RATE_1MBPS, |
| 4509 | .hw_value_short = CONF_HW_BIT_RATE_1MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4510 | { .bitrate = 20, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4511 | .hw_value = CONF_HW_BIT_RATE_2MBPS, |
| 4512 | .hw_value_short = CONF_HW_BIT_RATE_2MBPS, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4513 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 4514 | { .bitrate = 55, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4515 | .hw_value = CONF_HW_BIT_RATE_5_5MBPS, |
| 4516 | .hw_value_short = CONF_HW_BIT_RATE_5_5MBPS, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4517 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 4518 | { .bitrate = 110, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4519 | .hw_value = CONF_HW_BIT_RATE_11MBPS, |
| 4520 | .hw_value_short = CONF_HW_BIT_RATE_11MBPS, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4521 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 4522 | { .bitrate = 60, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4523 | .hw_value = CONF_HW_BIT_RATE_6MBPS, |
| 4524 | .hw_value_short = CONF_HW_BIT_RATE_6MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4525 | { .bitrate = 90, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4526 | .hw_value = CONF_HW_BIT_RATE_9MBPS, |
| 4527 | .hw_value_short = CONF_HW_BIT_RATE_9MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4528 | { .bitrate = 120, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4529 | .hw_value = CONF_HW_BIT_RATE_12MBPS, |
| 4530 | .hw_value_short = CONF_HW_BIT_RATE_12MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4531 | { .bitrate = 180, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4532 | .hw_value = CONF_HW_BIT_RATE_18MBPS, |
| 4533 | .hw_value_short = CONF_HW_BIT_RATE_18MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4534 | { .bitrate = 240, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4535 | .hw_value = CONF_HW_BIT_RATE_24MBPS, |
| 4536 | .hw_value_short = CONF_HW_BIT_RATE_24MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4537 | { .bitrate = 360, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4538 | .hw_value = CONF_HW_BIT_RATE_36MBPS, |
| 4539 | .hw_value_short = CONF_HW_BIT_RATE_36MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4540 | { .bitrate = 480, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4541 | .hw_value = CONF_HW_BIT_RATE_48MBPS, |
| 4542 | .hw_value_short = CONF_HW_BIT_RATE_48MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4543 | { .bitrate = 540, |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 4544 | .hw_value = CONF_HW_BIT_RATE_54MBPS, |
| 4545 | .hw_value_short = CONF_HW_BIT_RATE_54MBPS, }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4546 | }; |
| 4547 | |
Juuso Oikarinen | fa97f46 | 2010-11-10 11:27:20 +0100 | [diff] [blame] | 4548 | /* can't be const, mac80211 writes to this */ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4549 | static struct ieee80211_channel wl1271_channels[] = { |
Luciano Coelho | a2d0e3f | 2009-12-11 15:40:46 +0200 | [diff] [blame] | 4550 | { .hw_value = 1, .center_freq = 2412, .max_power = 25 }, |
Juuso Oikarinen | fa21c7a | 2010-08-10 08:22:02 +0200 | [diff] [blame] | 4551 | { .hw_value = 2, .center_freq = 2417, .max_power = 25 }, |
Juuso Oikarinen | fa97f46 | 2010-11-10 11:27:20 +0100 | [diff] [blame] | 4552 | { .hw_value = 3, .center_freq = 2422, .max_power = 25 }, |
| 4553 | { .hw_value = 4, .center_freq = 2427, .max_power = 25 }, |
| 4554 | { .hw_value = 5, .center_freq = 2432, .max_power = 25 }, |
Juuso Oikarinen | fa21c7a | 2010-08-10 08:22:02 +0200 | [diff] [blame] | 4555 | { .hw_value = 6, .center_freq = 2437, .max_power = 25 }, |
Juuso Oikarinen | fa97f46 | 2010-11-10 11:27:20 +0100 | [diff] [blame] | 4556 | { .hw_value = 7, .center_freq = 2442, .max_power = 25 }, |
| 4557 | { .hw_value = 8, .center_freq = 2447, .max_power = 25 }, |
| 4558 | { .hw_value = 9, .center_freq = 2452, .max_power = 25 }, |
Juuso Oikarinen | fa21c7a | 2010-08-10 08:22:02 +0200 | [diff] [blame] | 4559 | { .hw_value = 10, .center_freq = 2457, .max_power = 25 }, |
Juuso Oikarinen | fa97f46 | 2010-11-10 11:27:20 +0100 | [diff] [blame] | 4560 | { .hw_value = 11, .center_freq = 2462, .max_power = 25 }, |
| 4561 | { .hw_value = 12, .center_freq = 2467, .max_power = 25 }, |
| 4562 | { .hw_value = 13, .center_freq = 2472, .max_power = 25 }, |
Arik Nemtsov | 6c89b7b | 2011-01-18 20:39:52 +0100 | [diff] [blame] | 4563 | { .hw_value = 14, .center_freq = 2484, .max_power = 25 }, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4564 | }; |
| 4565 | |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4566 | /* mapping to indexes for wl1271_rates */ |
Tobias Klauser | a0ea949 | 2010-05-20 10:38:11 +0200 | [diff] [blame] | 4567 | static const u8 wl1271_rate_to_idx_2ghz[] = { |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4568 | /* MCS rates are used only with 11n */ |
Pontus Fuchs | defe02c | 2012-01-31 17:54:41 +0200 | [diff] [blame] | 4569 | 7, /* CONF_HW_RXTX_RATE_MCS7_SGI */ |
Shahar Levi | 1835785 | 2010-10-13 16:09:41 +0200 | [diff] [blame] | 4570 | 7, /* CONF_HW_RXTX_RATE_MCS7 */ |
| 4571 | 6, /* CONF_HW_RXTX_RATE_MCS6 */ |
| 4572 | 5, /* CONF_HW_RXTX_RATE_MCS5 */ |
| 4573 | 4, /* CONF_HW_RXTX_RATE_MCS4 */ |
| 4574 | 3, /* CONF_HW_RXTX_RATE_MCS3 */ |
| 4575 | 2, /* CONF_HW_RXTX_RATE_MCS2 */ |
| 4576 | 1, /* CONF_HW_RXTX_RATE_MCS1 */ |
| 4577 | 0, /* CONF_HW_RXTX_RATE_MCS0 */ |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4578 | |
| 4579 | 11, /* CONF_HW_RXTX_RATE_54 */ |
| 4580 | 10, /* CONF_HW_RXTX_RATE_48 */ |
| 4581 | 9, /* CONF_HW_RXTX_RATE_36 */ |
| 4582 | 8, /* CONF_HW_RXTX_RATE_24 */ |
| 4583 | |
| 4584 | /* TI-specific rate */ |
| 4585 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* CONF_HW_RXTX_RATE_22 */ |
| 4586 | |
| 4587 | 7, /* CONF_HW_RXTX_RATE_18 */ |
| 4588 | 6, /* CONF_HW_RXTX_RATE_12 */ |
| 4589 | 3, /* CONF_HW_RXTX_RATE_11 */ |
| 4590 | 5, /* CONF_HW_RXTX_RATE_9 */ |
| 4591 | 4, /* CONF_HW_RXTX_RATE_6 */ |
| 4592 | 2, /* CONF_HW_RXTX_RATE_5_5 */ |
| 4593 | 1, /* CONF_HW_RXTX_RATE_2 */ |
| 4594 | 0 /* CONF_HW_RXTX_RATE_1 */ |
| 4595 | }; |
| 4596 | |
Shahar Levi | e8b03a2 | 2010-10-13 16:09:39 +0200 | [diff] [blame] | 4597 | /* 11n STA capabilities */ |
| 4598 | #define HW_RX_HIGHEST_RATE 72 |
| 4599 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 4600 | #define WL12XX_HT_CAP { \ |
Shahar Levi | 871d0c3 | 2011-03-13 11:24:40 +0200 | [diff] [blame] | 4601 | .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | \ |
| 4602 | (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT), \ |
Shahar Levi | e8b03a2 | 2010-10-13 16:09:39 +0200 | [diff] [blame] | 4603 | .ht_supported = true, \ |
| 4604 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K, \ |
| 4605 | .ampdu_density = IEEE80211_HT_MPDU_DENSITY_8, \ |
| 4606 | .mcs = { \ |
| 4607 | .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, \ |
| 4608 | .rx_highest = cpu_to_le16(HW_RX_HIGHEST_RATE), \ |
| 4609 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED, \ |
| 4610 | }, \ |
| 4611 | } |
| 4612 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4613 | /* can't be const, mac80211 writes to this */ |
| 4614 | static struct ieee80211_supported_band wl1271_band_2ghz = { |
| 4615 | .channels = wl1271_channels, |
| 4616 | .n_channels = ARRAY_SIZE(wl1271_channels), |
| 4617 | .bitrates = wl1271_rates, |
| 4618 | .n_bitrates = ARRAY_SIZE(wl1271_rates), |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 4619 | .ht_cap = WL12XX_HT_CAP, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4620 | }; |
| 4621 | |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 4622 | /* 5 GHz data rates for WL1273 */ |
| 4623 | static struct ieee80211_rate wl1271_rates_5ghz[] = { |
| 4624 | { .bitrate = 60, |
| 4625 | .hw_value = CONF_HW_BIT_RATE_6MBPS, |
| 4626 | .hw_value_short = CONF_HW_BIT_RATE_6MBPS, }, |
| 4627 | { .bitrate = 90, |
| 4628 | .hw_value = CONF_HW_BIT_RATE_9MBPS, |
| 4629 | .hw_value_short = CONF_HW_BIT_RATE_9MBPS, }, |
| 4630 | { .bitrate = 120, |
| 4631 | .hw_value = CONF_HW_BIT_RATE_12MBPS, |
| 4632 | .hw_value_short = CONF_HW_BIT_RATE_12MBPS, }, |
| 4633 | { .bitrate = 180, |
| 4634 | .hw_value = CONF_HW_BIT_RATE_18MBPS, |
| 4635 | .hw_value_short = CONF_HW_BIT_RATE_18MBPS, }, |
| 4636 | { .bitrate = 240, |
| 4637 | .hw_value = CONF_HW_BIT_RATE_24MBPS, |
| 4638 | .hw_value_short = CONF_HW_BIT_RATE_24MBPS, }, |
| 4639 | { .bitrate = 360, |
| 4640 | .hw_value = CONF_HW_BIT_RATE_36MBPS, |
| 4641 | .hw_value_short = CONF_HW_BIT_RATE_36MBPS, }, |
| 4642 | { .bitrate = 480, |
| 4643 | .hw_value = CONF_HW_BIT_RATE_48MBPS, |
| 4644 | .hw_value_short = CONF_HW_BIT_RATE_48MBPS, }, |
| 4645 | { .bitrate = 540, |
| 4646 | .hw_value = CONF_HW_BIT_RATE_54MBPS, |
| 4647 | .hw_value_short = CONF_HW_BIT_RATE_54MBPS, }, |
| 4648 | }; |
| 4649 | |
Juuso Oikarinen | fa97f46 | 2010-11-10 11:27:20 +0100 | [diff] [blame] | 4650 | /* 5 GHz band channels for WL1273 */ |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 4651 | static struct ieee80211_channel wl1271_channels_5ghz[] = { |
Arik Nemtsov | 6cfa5cf | 2011-06-27 22:06:33 +0300 | [diff] [blame] | 4652 | { .hw_value = 7, .center_freq = 5035, .max_power = 25 }, |
| 4653 | { .hw_value = 8, .center_freq = 5040, .max_power = 25 }, |
| 4654 | { .hw_value = 9, .center_freq = 5045, .max_power = 25 }, |
| 4655 | { .hw_value = 11, .center_freq = 5055, .max_power = 25 }, |
| 4656 | { .hw_value = 12, .center_freq = 5060, .max_power = 25 }, |
| 4657 | { .hw_value = 16, .center_freq = 5080, .max_power = 25 }, |
| 4658 | { .hw_value = 34, .center_freq = 5170, .max_power = 25 }, |
| 4659 | { .hw_value = 36, .center_freq = 5180, .max_power = 25 }, |
| 4660 | { .hw_value = 38, .center_freq = 5190, .max_power = 25 }, |
| 4661 | { .hw_value = 40, .center_freq = 5200, .max_power = 25 }, |
| 4662 | { .hw_value = 42, .center_freq = 5210, .max_power = 25 }, |
| 4663 | { .hw_value = 44, .center_freq = 5220, .max_power = 25 }, |
| 4664 | { .hw_value = 46, .center_freq = 5230, .max_power = 25 }, |
| 4665 | { .hw_value = 48, .center_freq = 5240, .max_power = 25 }, |
| 4666 | { .hw_value = 52, .center_freq = 5260, .max_power = 25 }, |
| 4667 | { .hw_value = 56, .center_freq = 5280, .max_power = 25 }, |
| 4668 | { .hw_value = 60, .center_freq = 5300, .max_power = 25 }, |
| 4669 | { .hw_value = 64, .center_freq = 5320, .max_power = 25 }, |
| 4670 | { .hw_value = 100, .center_freq = 5500, .max_power = 25 }, |
| 4671 | { .hw_value = 104, .center_freq = 5520, .max_power = 25 }, |
| 4672 | { .hw_value = 108, .center_freq = 5540, .max_power = 25 }, |
| 4673 | { .hw_value = 112, .center_freq = 5560, .max_power = 25 }, |
| 4674 | { .hw_value = 116, .center_freq = 5580, .max_power = 25 }, |
| 4675 | { .hw_value = 120, .center_freq = 5600, .max_power = 25 }, |
| 4676 | { .hw_value = 124, .center_freq = 5620, .max_power = 25 }, |
| 4677 | { .hw_value = 128, .center_freq = 5640, .max_power = 25 }, |
| 4678 | { .hw_value = 132, .center_freq = 5660, .max_power = 25 }, |
| 4679 | { .hw_value = 136, .center_freq = 5680, .max_power = 25 }, |
| 4680 | { .hw_value = 140, .center_freq = 5700, .max_power = 25 }, |
| 4681 | { .hw_value = 149, .center_freq = 5745, .max_power = 25 }, |
| 4682 | { .hw_value = 153, .center_freq = 5765, .max_power = 25 }, |
| 4683 | { .hw_value = 157, .center_freq = 5785, .max_power = 25 }, |
| 4684 | { .hw_value = 161, .center_freq = 5805, .max_power = 25 }, |
| 4685 | { .hw_value = 165, .center_freq = 5825, .max_power = 25 }, |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 4686 | }; |
| 4687 | |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4688 | /* mapping to indexes for wl1271_rates_5ghz */ |
Tobias Klauser | a0ea949 | 2010-05-20 10:38:11 +0200 | [diff] [blame] | 4689 | static const u8 wl1271_rate_to_idx_5ghz[] = { |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4690 | /* MCS rates are used only with 11n */ |
Pontus Fuchs | defe02c | 2012-01-31 17:54:41 +0200 | [diff] [blame] | 4691 | 7, /* CONF_HW_RXTX_RATE_MCS7_SGI */ |
Shahar Levi | 1835785 | 2010-10-13 16:09:41 +0200 | [diff] [blame] | 4692 | 7, /* CONF_HW_RXTX_RATE_MCS7 */ |
| 4693 | 6, /* CONF_HW_RXTX_RATE_MCS6 */ |
| 4694 | 5, /* CONF_HW_RXTX_RATE_MCS5 */ |
| 4695 | 4, /* CONF_HW_RXTX_RATE_MCS4 */ |
| 4696 | 3, /* CONF_HW_RXTX_RATE_MCS3 */ |
| 4697 | 2, /* CONF_HW_RXTX_RATE_MCS2 */ |
| 4698 | 1, /* CONF_HW_RXTX_RATE_MCS1 */ |
| 4699 | 0, /* CONF_HW_RXTX_RATE_MCS0 */ |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4700 | |
| 4701 | 7, /* CONF_HW_RXTX_RATE_54 */ |
| 4702 | 6, /* CONF_HW_RXTX_RATE_48 */ |
| 4703 | 5, /* CONF_HW_RXTX_RATE_36 */ |
| 4704 | 4, /* CONF_HW_RXTX_RATE_24 */ |
| 4705 | |
| 4706 | /* TI-specific rate */ |
| 4707 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* CONF_HW_RXTX_RATE_22 */ |
| 4708 | |
| 4709 | 3, /* CONF_HW_RXTX_RATE_18 */ |
| 4710 | 2, /* CONF_HW_RXTX_RATE_12 */ |
| 4711 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* CONF_HW_RXTX_RATE_11 */ |
| 4712 | 1, /* CONF_HW_RXTX_RATE_9 */ |
| 4713 | 0, /* CONF_HW_RXTX_RATE_6 */ |
| 4714 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* CONF_HW_RXTX_RATE_5_5 */ |
| 4715 | CONF_HW_RXTX_RATE_UNSUPPORTED, /* CONF_HW_RXTX_RATE_2 */ |
| 4716 | CONF_HW_RXTX_RATE_UNSUPPORTED /* CONF_HW_RXTX_RATE_1 */ |
| 4717 | }; |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 4718 | |
| 4719 | static struct ieee80211_supported_band wl1271_band_5ghz = { |
| 4720 | .channels = wl1271_channels_5ghz, |
| 4721 | .n_channels = ARRAY_SIZE(wl1271_channels_5ghz), |
| 4722 | .bitrates = wl1271_rates_5ghz, |
| 4723 | .n_bitrates = ARRAY_SIZE(wl1271_rates_5ghz), |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 4724 | .ht_cap = WL12XX_HT_CAP, |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 4725 | }; |
| 4726 | |
Tobias Klauser | a0ea949 | 2010-05-20 10:38:11 +0200 | [diff] [blame] | 4727 | static const u8 *wl1271_band_rate_to_idx[] = { |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4728 | [IEEE80211_BAND_2GHZ] = wl1271_rate_to_idx_2ghz, |
| 4729 | [IEEE80211_BAND_5GHZ] = wl1271_rate_to_idx_5ghz |
| 4730 | }; |
| 4731 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4732 | static const struct ieee80211_ops wl1271_ops = { |
| 4733 | .start = wl1271_op_start, |
| 4734 | .stop = wl1271_op_stop, |
| 4735 | .add_interface = wl1271_op_add_interface, |
| 4736 | .remove_interface = wl1271_op_remove_interface, |
Eliad Peller | c0fad1b | 2011-12-19 12:00:03 +0200 | [diff] [blame] | 4737 | .change_interface = wl12xx_op_change_interface, |
Luciano Coelho | f634a4e | 2011-05-18 16:51:26 -0400 | [diff] [blame] | 4738 | #ifdef CONFIG_PM |
Eliad Peller | 402e4861 | 2011-05-13 11:57:09 +0300 | [diff] [blame] | 4739 | .suspend = wl1271_op_suspend, |
| 4740 | .resume = wl1271_op_resume, |
Luciano Coelho | f634a4e | 2011-05-18 16:51:26 -0400 | [diff] [blame] | 4741 | #endif |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4742 | .config = wl1271_op_config, |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 4743 | .prepare_multicast = wl1271_op_prepare_multicast, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4744 | .configure_filter = wl1271_op_configure_filter, |
| 4745 | .tx = wl1271_op_tx, |
| 4746 | .set_key = wl1271_op_set_key, |
| 4747 | .hw_scan = wl1271_op_hw_scan, |
Eliad Peller | 73ecce3 | 2011-06-27 13:06:45 +0300 | [diff] [blame] | 4748 | .cancel_hw_scan = wl1271_op_cancel_hw_scan, |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 4749 | .sched_scan_start = wl1271_op_sched_scan_start, |
| 4750 | .sched_scan_stop = wl1271_op_sched_scan_stop, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4751 | .bss_info_changed = wl1271_op_bss_info_changed, |
Arik Nemtsov | 68d069c | 2010-11-08 10:51:07 +0100 | [diff] [blame] | 4752 | .set_frag_threshold = wl1271_op_set_frag_threshold, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4753 | .set_rts_threshold = wl1271_op_set_rts_threshold, |
Kalle Valo | c6999d8 | 2010-02-18 13:25:41 +0200 | [diff] [blame] | 4754 | .conf_tx = wl1271_op_conf_tx, |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 4755 | .get_tsf = wl1271_op_get_tsf, |
John W. Linville | ece550d | 2010-07-28 16:41:06 -0400 | [diff] [blame] | 4756 | .get_survey = wl1271_op_get_survey, |
Eliad Peller | 2d6cf2b | 2012-03-04 10:55:47 +0200 | [diff] [blame] | 4757 | .sta_state = wl12xx_op_sta_state, |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 4758 | .ampdu_action = wl1271_op_ampdu_action, |
Arik Nemtsov | 3343789 | 2011-04-26 23:35:39 +0300 | [diff] [blame] | 4759 | .tx_frames_pending = wl1271_tx_frames_pending, |
Eliad Peller | af7fbb2 | 2011-09-19 13:51:42 +0300 | [diff] [blame] | 4760 | .set_bitrate_mask = wl12xx_set_bitrate_mask, |
Shahar Levi | 6d158ff | 2011-09-08 13:01:33 +0300 | [diff] [blame] | 4761 | .channel_switch = wl12xx_op_channel_switch, |
Kalle Valo | c8c9087 | 2010-02-18 13:25:53 +0200 | [diff] [blame] | 4762 | CFG80211_TESTMODE_CMD(wl1271_tm_cmd) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 4763 | }; |
| 4764 | |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4765 | |
Teemu Paasikivi | 6a2de93 | 2010-10-14 11:00:04 +0200 | [diff] [blame] | 4766 | u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band) |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4767 | { |
| 4768 | u8 idx; |
| 4769 | |
Teemu Paasikivi | 6a2de93 | 2010-10-14 11:00:04 +0200 | [diff] [blame] | 4770 | BUG_ON(band >= sizeof(wl1271_band_rate_to_idx)/sizeof(u8 *)); |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4771 | |
| 4772 | if (unlikely(rate >= CONF_HW_RXTX_RATE_MAX)) { |
| 4773 | wl1271_error("Illegal RX rate from HW: %d", rate); |
| 4774 | return 0; |
| 4775 | } |
| 4776 | |
Teemu Paasikivi | 6a2de93 | 2010-10-14 11:00:04 +0200 | [diff] [blame] | 4777 | idx = wl1271_band_rate_to_idx[band][rate]; |
Juuso Oikarinen | f876bb9 | 2010-03-26 12:53:11 +0200 | [diff] [blame] | 4778 | if (unlikely(idx == CONF_HW_RXTX_RATE_UNSUPPORTED)) { |
| 4779 | wl1271_error("Unsupported RX rate from HW: %d", rate); |
| 4780 | return 0; |
| 4781 | } |
| 4782 | |
| 4783 | return idx; |
| 4784 | } |
| 4785 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 4786 | static ssize_t wl1271_sysfs_show_bt_coex_state(struct device *dev, |
| 4787 | struct device_attribute *attr, |
| 4788 | char *buf) |
| 4789 | { |
| 4790 | struct wl1271 *wl = dev_get_drvdata(dev); |
| 4791 | ssize_t len; |
| 4792 | |
Juuso Oikarinen | 2f63b01 | 2010-08-10 06:38:35 +0200 | [diff] [blame] | 4793 | len = PAGE_SIZE; |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 4794 | |
| 4795 | mutex_lock(&wl->mutex); |
| 4796 | len = snprintf(buf, len, "%d\n\n0 - off\n1 - on\n", |
| 4797 | wl->sg_enabled); |
| 4798 | mutex_unlock(&wl->mutex); |
| 4799 | |
| 4800 | return len; |
| 4801 | |
| 4802 | } |
| 4803 | |
| 4804 | static ssize_t wl1271_sysfs_store_bt_coex_state(struct device *dev, |
| 4805 | struct device_attribute *attr, |
| 4806 | const char *buf, size_t count) |
| 4807 | { |
| 4808 | struct wl1271 *wl = dev_get_drvdata(dev); |
| 4809 | unsigned long res; |
| 4810 | int ret; |
| 4811 | |
Luciano Coelho | 6277ed6 | 2011-04-01 17:49:54 +0300 | [diff] [blame] | 4812 | ret = kstrtoul(buf, 10, &res); |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 4813 | if (ret < 0) { |
| 4814 | wl1271_warning("incorrect value written to bt_coex_mode"); |
| 4815 | return count; |
| 4816 | } |
| 4817 | |
| 4818 | mutex_lock(&wl->mutex); |
| 4819 | |
| 4820 | res = !!res; |
| 4821 | |
| 4822 | if (res == wl->sg_enabled) |
| 4823 | goto out; |
| 4824 | |
| 4825 | wl->sg_enabled = res; |
| 4826 | |
| 4827 | if (wl->state == WL1271_STATE_OFF) |
| 4828 | goto out; |
| 4829 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 4830 | ret = wl1271_ps_elp_wakeup(wl); |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 4831 | if (ret < 0) |
| 4832 | goto out; |
| 4833 | |
| 4834 | wl1271_acx_sg_enable(wl, wl->sg_enabled); |
| 4835 | wl1271_ps_elp_sleep(wl); |
| 4836 | |
| 4837 | out: |
| 4838 | mutex_unlock(&wl->mutex); |
| 4839 | return count; |
| 4840 | } |
| 4841 | |
| 4842 | static DEVICE_ATTR(bt_coex_state, S_IRUGO | S_IWUSR, |
| 4843 | wl1271_sysfs_show_bt_coex_state, |
| 4844 | wl1271_sysfs_store_bt_coex_state); |
| 4845 | |
Juuso Oikarinen | d717fd6 | 2010-05-07 11:38:58 +0300 | [diff] [blame] | 4846 | static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev, |
| 4847 | struct device_attribute *attr, |
| 4848 | char *buf) |
| 4849 | { |
| 4850 | struct wl1271 *wl = dev_get_drvdata(dev); |
| 4851 | ssize_t len; |
| 4852 | |
Juuso Oikarinen | 2f63b01 | 2010-08-10 06:38:35 +0200 | [diff] [blame] | 4853 | len = PAGE_SIZE; |
Juuso Oikarinen | d717fd6 | 2010-05-07 11:38:58 +0300 | [diff] [blame] | 4854 | |
| 4855 | mutex_lock(&wl->mutex); |
| 4856 | if (wl->hw_pg_ver >= 0) |
| 4857 | len = snprintf(buf, len, "%d\n", wl->hw_pg_ver); |
| 4858 | else |
| 4859 | len = snprintf(buf, len, "n/a\n"); |
| 4860 | mutex_unlock(&wl->mutex); |
| 4861 | |
| 4862 | return len; |
| 4863 | } |
| 4864 | |
Gery Kahn | 6f07b72 | 2011-07-18 14:21:49 +0300 | [diff] [blame] | 4865 | static DEVICE_ATTR(hw_pg_ver, S_IRUGO, |
Juuso Oikarinen | d717fd6 | 2010-05-07 11:38:58 +0300 | [diff] [blame] | 4866 | wl1271_sysfs_show_hw_pg_ver, NULL); |
| 4867 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 4868 | static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj, |
| 4869 | struct bin_attribute *bin_attr, |
| 4870 | char *buffer, loff_t pos, size_t count) |
| 4871 | { |
| 4872 | struct device *dev = container_of(kobj, struct device, kobj); |
| 4873 | struct wl1271 *wl = dev_get_drvdata(dev); |
| 4874 | ssize_t len; |
| 4875 | int ret; |
| 4876 | |
| 4877 | ret = mutex_lock_interruptible(&wl->mutex); |
| 4878 | if (ret < 0) |
| 4879 | return -ERESTARTSYS; |
| 4880 | |
| 4881 | /* Let only one thread read the log at a time, blocking others */ |
| 4882 | while (wl->fwlog_size == 0) { |
| 4883 | DEFINE_WAIT(wait); |
| 4884 | |
| 4885 | prepare_to_wait_exclusive(&wl->fwlog_waitq, |
| 4886 | &wait, |
| 4887 | TASK_INTERRUPTIBLE); |
| 4888 | |
| 4889 | if (wl->fwlog_size != 0) { |
| 4890 | finish_wait(&wl->fwlog_waitq, &wait); |
| 4891 | break; |
| 4892 | } |
| 4893 | |
| 4894 | mutex_unlock(&wl->mutex); |
| 4895 | |
| 4896 | schedule(); |
| 4897 | finish_wait(&wl->fwlog_waitq, &wait); |
| 4898 | |
| 4899 | if (signal_pending(current)) |
| 4900 | return -ERESTARTSYS; |
| 4901 | |
| 4902 | ret = mutex_lock_interruptible(&wl->mutex); |
| 4903 | if (ret < 0) |
| 4904 | return -ERESTARTSYS; |
| 4905 | } |
| 4906 | |
| 4907 | /* Check if the fwlog is still valid */ |
| 4908 | if (wl->fwlog_size < 0) { |
| 4909 | mutex_unlock(&wl->mutex); |
| 4910 | return 0; |
| 4911 | } |
| 4912 | |
| 4913 | /* Seeking is not supported - old logs are not kept. Disregard pos. */ |
| 4914 | len = min(count, (size_t)wl->fwlog_size); |
| 4915 | wl->fwlog_size -= len; |
| 4916 | memcpy(buffer, wl->fwlog, len); |
| 4917 | |
| 4918 | /* Make room for new messages */ |
| 4919 | memmove(wl->fwlog, wl->fwlog + len, wl->fwlog_size); |
| 4920 | |
| 4921 | mutex_unlock(&wl->mutex); |
| 4922 | |
| 4923 | return len; |
| 4924 | } |
| 4925 | |
| 4926 | static struct bin_attribute fwlog_attr = { |
| 4927 | .attr = {.name = "fwlog", .mode = S_IRUSR}, |
| 4928 | .read = wl1271_sysfs_read_fwlog, |
| 4929 | }; |
| 4930 | |
Luciano Coelho | 5e037e7 | 2011-12-23 09:32:17 +0200 | [diff] [blame] | 4931 | static bool wl12xx_mac_in_fuse(struct wl1271 *wl) |
| 4932 | { |
| 4933 | bool supported = false; |
| 4934 | u8 major, minor; |
| 4935 | |
| 4936 | if (wl->chip.id == CHIP_ID_1283_PG20) { |
| 4937 | major = WL128X_PG_GET_MAJOR(wl->hw_pg_ver); |
| 4938 | minor = WL128X_PG_GET_MINOR(wl->hw_pg_ver); |
| 4939 | |
| 4940 | /* in wl128x we have the MAC address if the PG is >= (2, 1) */ |
| 4941 | if (major > 2 || (major == 2 && minor >= 1)) |
| 4942 | supported = true; |
| 4943 | } else { |
| 4944 | major = WL127X_PG_GET_MAJOR(wl->hw_pg_ver); |
| 4945 | minor = WL127X_PG_GET_MINOR(wl->hw_pg_ver); |
| 4946 | |
| 4947 | /* in wl127x we have the MAC address if the PG is >= (3, 1) */ |
| 4948 | if (major == 3 && minor >= 1) |
| 4949 | supported = true; |
| 4950 | } |
| 4951 | |
| 4952 | wl1271_debug(DEBUG_PROBE, |
| 4953 | "PG Ver major = %d minor = %d, MAC %s present", |
| 4954 | major, minor, supported ? "is" : "is not"); |
| 4955 | |
| 4956 | return supported; |
| 4957 | } |
| 4958 | |
| 4959 | static void wl12xx_derive_mac_addresses(struct wl1271 *wl, |
| 4960 | u32 oui, u32 nic, int n) |
| 4961 | { |
| 4962 | int i; |
| 4963 | |
| 4964 | wl1271_debug(DEBUG_PROBE, "base address: oui %06x nic %06x, n %d", |
| 4965 | oui, nic, n); |
| 4966 | |
| 4967 | if (nic + n - 1 > 0xffffff) |
| 4968 | wl1271_warning("NIC part of the MAC address wraps around!"); |
| 4969 | |
| 4970 | for (i = 0; i < n; i++) { |
| 4971 | wl->addresses[i].addr[0] = (u8)(oui >> 16); |
| 4972 | wl->addresses[i].addr[1] = (u8)(oui >> 8); |
| 4973 | wl->addresses[i].addr[2] = (u8) oui; |
| 4974 | wl->addresses[i].addr[3] = (u8)(nic >> 16); |
| 4975 | wl->addresses[i].addr[4] = (u8)(nic >> 8); |
| 4976 | wl->addresses[i].addr[5] = (u8) nic; |
| 4977 | nic++; |
| 4978 | } |
| 4979 | |
| 4980 | wl->hw->wiphy->n_addresses = n; |
| 4981 | wl->hw->wiphy->addresses = wl->addresses; |
| 4982 | } |
| 4983 | |
| 4984 | static void wl12xx_get_fuse_mac(struct wl1271 *wl) |
| 4985 | { |
| 4986 | u32 mac1, mac2; |
| 4987 | |
| 4988 | wl1271_set_partition(wl, &wl12xx_part_table[PART_DRPW]); |
| 4989 | |
| 4990 | mac1 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_1); |
| 4991 | mac2 = wl1271_read32(wl, WL12XX_REG_FUSE_BD_ADDR_2); |
| 4992 | |
| 4993 | /* these are the two parts of the BD_ADDR */ |
| 4994 | wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) + |
| 4995 | ((mac1 & 0xff000000) >> 24); |
| 4996 | wl->fuse_nic_addr = mac1 & 0xffffff; |
| 4997 | |
| 4998 | wl1271_set_partition(wl, &wl12xx_part_table[PART_DOWN]); |
| 4999 | } |
| 5000 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 5001 | static int wl12xx_get_hw_info(struct wl1271 *wl) |
| 5002 | { |
| 5003 | int ret; |
| 5004 | u32 die_info; |
| 5005 | |
| 5006 | ret = wl12xx_set_power_on(wl); |
| 5007 | if (ret < 0) |
| 5008 | goto out; |
| 5009 | |
| 5010 | wl->chip.id = wl1271_read32(wl, CHIP_ID_B); |
| 5011 | |
| 5012 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 5013 | die_info = wl1271_top_reg_read(wl, WL128X_REG_FUSE_DATA_2_1); |
| 5014 | else |
| 5015 | die_info = wl1271_top_reg_read(wl, WL127X_REG_FUSE_DATA_2_1); |
| 5016 | |
| 5017 | wl->hw_pg_ver = (s8) (die_info & PG_VER_MASK) >> PG_VER_OFFSET; |
| 5018 | |
Luciano Coelho | 5e037e7 | 2011-12-23 09:32:17 +0200 | [diff] [blame] | 5019 | if (!wl12xx_mac_in_fuse(wl)) { |
| 5020 | wl->fuse_oui_addr = 0; |
| 5021 | wl->fuse_nic_addr = 0; |
| 5022 | } else { |
| 5023 | wl12xx_get_fuse_mac(wl); |
| 5024 | } |
| 5025 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 5026 | wl1271_power_off(wl); |
| 5027 | out: |
| 5028 | return ret; |
| 5029 | } |
| 5030 | |
Felipe Balbi | 4b32a2c | 2011-10-06 10:46:20 +0300 | [diff] [blame] | 5031 | static int wl1271_register_hw(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5032 | { |
| 5033 | int ret; |
Luciano Coelho | 5e037e7 | 2011-12-23 09:32:17 +0200 | [diff] [blame] | 5034 | u32 oui_addr = 0, nic_addr = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5035 | |
| 5036 | if (wl->mac80211_registered) |
| 5037 | return 0; |
| 5038 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 5039 | ret = wl12xx_get_hw_info(wl); |
| 5040 | if (ret < 0) { |
| 5041 | wl1271_error("couldn't get hw info"); |
| 5042 | goto out; |
| 5043 | } |
| 5044 | |
Arik Nemtsov | 31d26ec | 2010-10-16 21:49:52 +0200 | [diff] [blame] | 5045 | ret = wl1271_fetch_nvs(wl); |
| 5046 | if (ret == 0) { |
Shahar Levi | bc765bf | 2011-03-06 16:32:10 +0200 | [diff] [blame] | 5047 | /* NOTE: The wl->nvs->nvs element must be first, in |
| 5048 | * order to simplify the casting, we assume it is at |
| 5049 | * the beginning of the wl->nvs structure. |
| 5050 | */ |
| 5051 | u8 *nvs_ptr = (u8 *)wl->nvs; |
Arik Nemtsov | 31d26ec | 2010-10-16 21:49:52 +0200 | [diff] [blame] | 5052 | |
Luciano Coelho | 5e037e7 | 2011-12-23 09:32:17 +0200 | [diff] [blame] | 5053 | oui_addr = |
| 5054 | (nvs_ptr[11] << 16) + (nvs_ptr[10] << 8) + nvs_ptr[6]; |
| 5055 | nic_addr = |
| 5056 | (nvs_ptr[5] << 16) + (nvs_ptr[4] << 8) + nvs_ptr[3]; |
Arik Nemtsov | 31d26ec | 2010-10-16 21:49:52 +0200 | [diff] [blame] | 5057 | } |
| 5058 | |
Luciano Coelho | 5e037e7 | 2011-12-23 09:32:17 +0200 | [diff] [blame] | 5059 | /* if the MAC address is zeroed in the NVS derive from fuse */ |
| 5060 | if (oui_addr == 0 && nic_addr == 0) { |
| 5061 | oui_addr = wl->fuse_oui_addr; |
| 5062 | /* fuse has the BD_ADDR, the WLAN addresses are the next two */ |
| 5063 | nic_addr = wl->fuse_nic_addr + 1; |
| 5064 | } |
| 5065 | |
| 5066 | wl12xx_derive_mac_addresses(wl, oui_addr, nic_addr, 2); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5067 | |
| 5068 | ret = ieee80211_register_hw(wl->hw); |
| 5069 | if (ret < 0) { |
| 5070 | wl1271_error("unable to register mac80211 hw: %d", ret); |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 5071 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5072 | } |
| 5073 | |
| 5074 | wl->mac80211_registered = true; |
| 5075 | |
Eliad Peller | d60080a | 2010-11-24 12:53:16 +0200 | [diff] [blame] | 5076 | wl1271_debugfs_init(wl); |
| 5077 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5078 | wl1271_notice("loaded"); |
| 5079 | |
Luciano Coelho | 30c5dbd | 2012-01-18 14:53:22 +0200 | [diff] [blame] | 5080 | out: |
| 5081 | return ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5082 | } |
| 5083 | |
Felipe Balbi | 4b32a2c | 2011-10-06 10:46:20 +0300 | [diff] [blame] | 5084 | static void wl1271_unregister_hw(struct wl1271 *wl) |
Teemu Paasikivi | 3b56dd6 | 2010-03-18 12:26:46 +0200 | [diff] [blame] | 5085 | { |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 5086 | if (wl->plt) |
Ido Yariv | f3df133 | 2012-01-11 09:42:39 +0200 | [diff] [blame] | 5087 | wl1271_plt_stop(wl); |
Juuso Oikarinen | 4ae3fa8 | 2011-01-14 12:48:46 +0100 | [diff] [blame] | 5088 | |
Teemu Paasikivi | 3b56dd6 | 2010-03-18 12:26:46 +0200 | [diff] [blame] | 5089 | ieee80211_unregister_hw(wl->hw); |
| 5090 | wl->mac80211_registered = false; |
| 5091 | |
| 5092 | } |
Teemu Paasikivi | 3b56dd6 | 2010-03-18 12:26:46 +0200 | [diff] [blame] | 5093 | |
Felipe Balbi | 4b32a2c | 2011-10-06 10:46:20 +0300 | [diff] [blame] | 5094 | static int wl1271_init_ieee80211(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5095 | { |
Juuso Oikarinen | 7a55724 | 2010-09-27 12:42:07 +0200 | [diff] [blame] | 5096 | static const u32 cipher_suites[] = { |
| 5097 | WLAN_CIPHER_SUITE_WEP40, |
| 5098 | WLAN_CIPHER_SUITE_WEP104, |
| 5099 | WLAN_CIPHER_SUITE_TKIP, |
| 5100 | WLAN_CIPHER_SUITE_CCMP, |
| 5101 | WL1271_CIPHER_SUITE_GEM, |
| 5102 | }; |
| 5103 | |
Juuso Oikarinen | 1e2b797 | 2009-10-08 21:56:20 +0300 | [diff] [blame] | 5104 | /* The tx descriptor buffer and the TKIP space. */ |
Eliad Peller | 5ec8a44 | 2012-02-02 12:22:09 +0200 | [diff] [blame] | 5105 | wl->hw->extra_tx_headroom = WL1271_EXTRA_SPACE_TKIP + |
Juuso Oikarinen | 1e2b797 | 2009-10-08 21:56:20 +0300 | [diff] [blame] | 5106 | sizeof(struct wl1271_tx_hw_descr); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5107 | |
| 5108 | /* unit us */ |
| 5109 | /* FIXME: find a proper value */ |
| 5110 | wl->hw->channel_change_time = 10000; |
Juuso Oikarinen | 50c500a | 2010-04-01 11:38:22 +0300 | [diff] [blame] | 5111 | wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5112 | |
| 5113 | wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | |
Juuso Oikarinen | 0a34332 | 2010-02-22 08:38:41 +0200 | [diff] [blame] | 5114 | IEEE80211_HW_SUPPORTS_PS | |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 5115 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | |
Kalle Valo | 4695dc9 | 2010-03-18 12:26:38 +0200 | [diff] [blame] | 5116 | IEEE80211_HW_SUPPORTS_UAPSD | |
Juuso Oikarinen | a9af092 | 2010-03-26 12:53:30 +0200 | [diff] [blame] | 5117 | IEEE80211_HW_HAS_RATE_CONTROL | |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 5118 | IEEE80211_HW_CONNECTION_MONITOR | |
Luciano Coelho | 25eaea30 | 2011-05-02 12:37:33 +0300 | [diff] [blame] | 5119 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
Shahar Levi | fcd23b6 | 2011-05-11 12:12:56 +0300 | [diff] [blame] | 5120 | IEEE80211_HW_SPECTRUM_MGMT | |
Arik Nemtsov | 93f8c8e | 2011-08-30 09:34:01 +0300 | [diff] [blame] | 5121 | IEEE80211_HW_AP_LINK_PS | |
| 5122 | IEEE80211_HW_AMPDU_AGGREGATION | |
Eliad Peller | 79aba1b | 2012-02-02 13:15:35 +0200 | [diff] [blame] | 5123 | IEEE80211_HW_TX_AMPDU_SETUP_IN_HW | |
| 5124 | IEEE80211_HW_SCAN_WHILE_IDLE; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5125 | |
Juuso Oikarinen | 7a55724 | 2010-09-27 12:42:07 +0200 | [diff] [blame] | 5126 | wl->hw->wiphy->cipher_suites = cipher_suites; |
| 5127 | wl->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); |
| 5128 | |
Juuso Oikarinen | e0d8bbf | 2009-12-11 15:41:04 +0200 | [diff] [blame] | 5129 | wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
Eliad Peller | 045c745 | 2011-08-28 15:23:01 +0300 | [diff] [blame] | 5130 | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP) | |
| 5131 | BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5132 | wl->hw->wiphy->max_scan_ssids = 1; |
Luciano Coelho | 221737d | 2011-09-02 14:28:22 +0300 | [diff] [blame] | 5133 | wl->hw->wiphy->max_sched_scan_ssids = 16; |
| 5134 | wl->hw->wiphy->max_match_sets = 16; |
Guy Eilam | ea559b4 | 2010-12-09 16:54:59 +0200 | [diff] [blame] | 5135 | /* |
| 5136 | * Maximum length of elements in scanning probe request templates |
| 5137 | * should be the maximum length possible for a template, without |
| 5138 | * the IEEE80211 header of the template |
| 5139 | */ |
Ido Reis | c08e371 | 2012-02-02 13:54:27 +0200 | [diff] [blame] | 5140 | wl->hw->wiphy->max_scan_ie_len = WL1271_CMD_TEMPL_MAX_SIZE - |
Guy Eilam | ea559b4 | 2010-12-09 16:54:59 +0200 | [diff] [blame] | 5141 | sizeof(struct ieee80211_header); |
Luciano Coelho | a8aaaf5 | 2011-01-11 18:25:18 +0100 | [diff] [blame] | 5142 | |
Ido Reis | c08e371 | 2012-02-02 13:54:27 +0200 | [diff] [blame] | 5143 | wl->hw->wiphy->max_sched_scan_ie_len = WL1271_CMD_TEMPL_MAX_SIZE - |
Luciano Coelho | c9e79a4 | 2011-09-27 16:22:35 +0300 | [diff] [blame] | 5144 | sizeof(struct ieee80211_header); |
| 5145 | |
Eliad Peller | 1ec23f7 | 2011-08-25 14:26:54 +0300 | [diff] [blame] | 5146 | wl->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; |
| 5147 | |
Luciano Coelho | 4a31c11 | 2011-03-21 23:16:14 +0200 | [diff] [blame] | 5148 | /* make sure all our channels fit in the scanned_ch bitmask */ |
| 5149 | BUILD_BUG_ON(ARRAY_SIZE(wl1271_channels) + |
| 5150 | ARRAY_SIZE(wl1271_channels_5ghz) > |
| 5151 | WL1271_MAX_CHANNELS); |
Luciano Coelho | a8aaaf5 | 2011-01-11 18:25:18 +0100 | [diff] [blame] | 5152 | /* |
| 5153 | * We keep local copies of the band structs because we need to |
| 5154 | * modify them on a per-device basis. |
| 5155 | */ |
| 5156 | memcpy(&wl->bands[IEEE80211_BAND_2GHZ], &wl1271_band_2ghz, |
| 5157 | sizeof(wl1271_band_2ghz)); |
| 5158 | memcpy(&wl->bands[IEEE80211_BAND_5GHZ], &wl1271_band_5ghz, |
| 5159 | sizeof(wl1271_band_5ghz)); |
| 5160 | |
| 5161 | wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 5162 | &wl->bands[IEEE80211_BAND_2GHZ]; |
| 5163 | wl->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 5164 | &wl->bands[IEEE80211_BAND_5GHZ]; |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 5165 | |
Kalle Valo | 12bd894 | 2010-03-18 12:26:33 +0200 | [diff] [blame] | 5166 | wl->hw->queues = 4; |
Juuso Oikarinen | 31627dc | 2010-03-26 12:53:12 +0200 | [diff] [blame] | 5167 | wl->hw->max_rates = 1; |
Kalle Valo | 12bd894 | 2010-03-18 12:26:33 +0200 | [diff] [blame] | 5168 | |
Juuso Oikarinen | b7417d9 | 2010-11-10 11:27:19 +0100 | [diff] [blame] | 5169 | wl->hw->wiphy->reg_notifier = wl1271_reg_notify; |
| 5170 | |
Arik Nemtsov | 9c1b190 | 2011-11-08 18:46:55 +0200 | [diff] [blame] | 5171 | /* the FW answers probe-requests in AP-mode */ |
| 5172 | wl->hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; |
| 5173 | wl->hw->wiphy->probe_resp_offload = |
| 5174 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | |
| 5175 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | |
| 5176 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P; |
| 5177 | |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 5178 | SET_IEEE80211_DEV(wl->hw, wl->dev); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5179 | |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 5180 | wl->hw->sta_data_size = sizeof(struct wl1271_station); |
Eliad Peller | 87fbcb0 | 2011-10-05 11:55:41 +0200 | [diff] [blame] | 5181 | wl->hw->vif_data_size = sizeof(struct wl12xx_vif); |
Arik Nemtsov | f84f7d7 | 2010-10-16 20:21:23 +0200 | [diff] [blame] | 5182 | |
Luciano Coelho | 4c9cfa7 | 2011-01-12 14:27:03 +0100 | [diff] [blame] | 5183 | wl->hw->max_rx_aggregation_subframes = 8; |
| 5184 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5185 | return 0; |
| 5186 | } |
| 5187 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5188 | #define WL1271_DEFAULT_CHANNEL 0 |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5189 | |
Felipe Balbi | 4b32a2c | 2011-10-06 10:46:20 +0300 | [diff] [blame] | 5190 | static struct ieee80211_hw *wl1271_alloc_hw(void) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5191 | { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5192 | struct ieee80211_hw *hw; |
| 5193 | struct wl1271 *wl; |
Arik Nemtsov | a8c0ddb | 2011-02-23 00:22:26 +0200 | [diff] [blame] | 5194 | int i, j, ret; |
Ido Yariv | 1f37cbc | 2010-09-30 13:28:27 +0200 | [diff] [blame] | 5195 | unsigned int order; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5196 | |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 5197 | BUILD_BUG_ON(AP_MAX_STATIONS > WL12XX_MAX_LINKS); |
Arik Nemtsov | f80c2d1 | 2011-09-22 09:52:05 +0300 | [diff] [blame] | 5198 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5199 | hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); |
| 5200 | if (!hw) { |
| 5201 | wl1271_error("could not alloc ieee80211_hw"); |
Juuso Oikarinen | a1dd818 | 2010-03-18 12:26:31 +0200 | [diff] [blame] | 5202 | ret = -ENOMEM; |
Teemu Paasikivi | 3b56dd6 | 2010-03-18 12:26:46 +0200 | [diff] [blame] | 5203 | goto err_hw_alloc; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5204 | } |
| 5205 | |
| 5206 | wl = hw->priv; |
| 5207 | memset(wl, 0, sizeof(*wl)); |
| 5208 | |
Eliad Peller | 8762721 | 2011-10-10 10:12:54 +0200 | [diff] [blame] | 5209 | INIT_LIST_HEAD(&wl->wlvif_list); |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 5210 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5211 | wl->hw = hw; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5212 | |
Juuso Oikarinen | 6742f55 | 2010-12-13 09:52:37 +0200 | [diff] [blame] | 5213 | for (i = 0; i < NUM_TX_QUEUES; i++) |
Eliad Peller | c7ffb90 | 2011-10-05 11:56:05 +0200 | [diff] [blame] | 5214 | for (j = 0; j < WL12XX_MAX_LINKS; j++) |
Arik Nemtsov | a8c0ddb | 2011-02-23 00:22:26 +0200 | [diff] [blame] | 5215 | skb_queue_head_init(&wl->links[j].tx_queue[i]); |
| 5216 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 5217 | skb_queue_head_init(&wl->deferred_rx_queue); |
| 5218 | skb_queue_head_init(&wl->deferred_tx_queue); |
| 5219 | |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 5220 | INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work); |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 5221 | INIT_WORK(&wl->netstack_work, wl1271_netstack_work); |
Juuso Oikarinen | 117b38d | 2010-09-30 10:43:28 +0200 | [diff] [blame] | 5222 | INIT_WORK(&wl->tx_work, wl1271_tx_work); |
| 5223 | INIT_WORK(&wl->recovery_work, wl1271_recovery_work); |
| 5224 | INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work); |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 5225 | |
Eliad Peller | 92ef896 | 2011-06-07 12:50:46 +0300 | [diff] [blame] | 5226 | wl->freezable_wq = create_freezable_workqueue("wl12xx_wq"); |
| 5227 | if (!wl->freezable_wq) { |
| 5228 | ret = -ENOMEM; |
| 5229 | goto err_hw; |
| 5230 | } |
| 5231 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5232 | wl->channel = WL1271_DEFAULT_CHANNEL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5233 | wl->rx_counter = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5234 | wl->power_level = WL1271_DEFAULT_POWER_LEVEL; |
Juuso Oikarinen | 8a5a37a | 2009-10-08 21:56:24 +0300 | [diff] [blame] | 5235 | wl->band = IEEE80211_BAND_2GHZ; |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 5236 | wl->flags = 0; |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 5237 | wl->sg_enabled = true; |
Juuso Oikarinen | d717fd6 | 2010-05-07 11:38:58 +0300 | [diff] [blame] | 5238 | wl->hw_pg_ver = -1; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 5239 | wl->ap_ps_map = 0; |
| 5240 | wl->ap_fw_ps_map = 0; |
Ido Yariv | 606ea9f | 2011-03-01 15:14:39 +0200 | [diff] [blame] | 5241 | wl->quirks = 0; |
Ido Yariv | 341b7cd | 2011-03-31 10:07:01 +0200 | [diff] [blame] | 5242 | wl->platform_quirks = 0; |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 5243 | wl->sched_scanning = false; |
Guy Eilam | e9eb8cb | 2011-08-16 19:49:12 +0300 | [diff] [blame] | 5244 | wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; |
Eliad Peller | f4df1bd | 2011-08-14 13:17:15 +0300 | [diff] [blame] | 5245 | wl->system_hlid = WL12XX_SYSTEM_HLID; |
Arik Nemtsov | da03209 | 2011-08-25 12:43:15 +0300 | [diff] [blame] | 5246 | wl->active_sta_count = 0; |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 5247 | wl->fwlog_size = 0; |
| 5248 | init_waitqueue_head(&wl->fwlog_waitq); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5249 | |
Eliad Peller | f4df1bd | 2011-08-14 13:17:15 +0300 | [diff] [blame] | 5250 | /* The system link is always allocated */ |
| 5251 | __set_bit(WL12XX_SYSTEM_HLID, wl->links_map); |
| 5252 | |
Ido Yariv | 25eeb9e | 2010-10-12 16:20:06 +0200 | [diff] [blame] | 5253 | memset(wl->tx_frames_map, 0, sizeof(wl->tx_frames_map)); |
Juuso Oikarinen | be7078c | 2009-10-08 21:56:26 +0300 | [diff] [blame] | 5254 | for (i = 0; i < ACX_TX_DESCRIPTORS; i++) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5255 | wl->tx_frames[i] = NULL; |
| 5256 | |
| 5257 | spin_lock_init(&wl->wl_lock); |
| 5258 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5259 | wl->state = WL1271_STATE_OFF; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 5260 | wl->fw_type = WL12XX_FW_TYPE_NONE; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 5261 | mutex_init(&wl->mutex); |
| 5262 | |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5263 | /* Apply default driver configuration. */ |
| 5264 | wl1271_conf_init(wl); |
| 5265 | |
Ido Yariv | 1f37cbc | 2010-09-30 13:28:27 +0200 | [diff] [blame] | 5266 | order = get_order(WL1271_AGGR_BUFFER_SIZE); |
| 5267 | wl->aggr_buf = (u8 *)__get_free_pages(GFP_KERNEL, order); |
| 5268 | if (!wl->aggr_buf) { |
| 5269 | ret = -ENOMEM; |
Eliad Peller | 92ef896 | 2011-06-07 12:50:46 +0300 | [diff] [blame] | 5270 | goto err_wq; |
Ido Yariv | 1f37cbc | 2010-09-30 13:28:27 +0200 | [diff] [blame] | 5271 | } |
| 5272 | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 5273 | wl->dummy_packet = wl12xx_alloc_dummy_packet(wl); |
| 5274 | if (!wl->dummy_packet) { |
| 5275 | ret = -ENOMEM; |
| 5276 | goto err_aggr; |
| 5277 | } |
| 5278 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 5279 | /* Allocate one page for the FW log */ |
| 5280 | wl->fwlog = (u8 *)get_zeroed_page(GFP_KERNEL); |
| 5281 | if (!wl->fwlog) { |
| 5282 | ret = -ENOMEM; |
| 5283 | goto err_dummy_packet; |
| 5284 | } |
| 5285 | |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5286 | return hw; |
Juuso Oikarinen | a1dd818 | 2010-03-18 12:26:31 +0200 | [diff] [blame] | 5287 | |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 5288 | err_dummy_packet: |
| 5289 | dev_kfree_skb(wl->dummy_packet); |
| 5290 | |
Ido Yariv | 1f37cbc | 2010-09-30 13:28:27 +0200 | [diff] [blame] | 5291 | err_aggr: |
| 5292 | free_pages((unsigned long)wl->aggr_buf, order); |
| 5293 | |
Eliad Peller | 92ef896 | 2011-06-07 12:50:46 +0300 | [diff] [blame] | 5294 | err_wq: |
| 5295 | destroy_workqueue(wl->freezable_wq); |
| 5296 | |
Juuso Oikarinen | a1dd818 | 2010-03-18 12:26:31 +0200 | [diff] [blame] | 5297 | err_hw: |
Teemu Paasikivi | 3b56dd6 | 2010-03-18 12:26:46 +0200 | [diff] [blame] | 5298 | wl1271_debugfs_exit(wl); |
Teemu Paasikivi | 3b56dd6 | 2010-03-18 12:26:46 +0200 | [diff] [blame] | 5299 | ieee80211_free_hw(hw); |
| 5300 | |
| 5301 | err_hw_alloc: |
| 5302 | |
Juuso Oikarinen | a1dd818 | 2010-03-18 12:26:31 +0200 | [diff] [blame] | 5303 | return ERR_PTR(ret); |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5304 | } |
| 5305 | |
Felipe Balbi | 4b32a2c | 2011-10-06 10:46:20 +0300 | [diff] [blame] | 5306 | static int wl1271_free_hw(struct wl1271 *wl) |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5307 | { |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 5308 | /* Unblock any fwlog readers */ |
| 5309 | mutex_lock(&wl->mutex); |
| 5310 | wl->fwlog_size = -1; |
| 5311 | wake_up_interruptible_all(&wl->fwlog_waitq); |
| 5312 | mutex_unlock(&wl->mutex); |
| 5313 | |
Felipe Balbi | f79f890 | 2011-10-06 13:05:25 +0300 | [diff] [blame] | 5314 | device_remove_bin_file(wl->dev, &fwlog_attr); |
Gery Kahn | 6f07b72 | 2011-07-18 14:21:49 +0300 | [diff] [blame] | 5315 | |
Felipe Balbi | f79f890 | 2011-10-06 13:05:25 +0300 | [diff] [blame] | 5316 | device_remove_file(wl->dev, &dev_attr_hw_pg_ver); |
Gery Kahn | 6f07b72 | 2011-07-18 14:21:49 +0300 | [diff] [blame] | 5317 | |
Felipe Balbi | f79f890 | 2011-10-06 13:05:25 +0300 | [diff] [blame] | 5318 | device_remove_file(wl->dev, &dev_attr_bt_coex_state); |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 5319 | free_page((unsigned long)wl->fwlog); |
Ido Yariv | 990f5de | 2011-03-31 10:06:59 +0200 | [diff] [blame] | 5320 | dev_kfree_skb(wl->dummy_packet); |
Ido Yariv | 1f37cbc | 2010-09-30 13:28:27 +0200 | [diff] [blame] | 5321 | free_pages((unsigned long)wl->aggr_buf, |
| 5322 | get_order(WL1271_AGGR_BUFFER_SIZE)); |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5323 | |
| 5324 | wl1271_debugfs_exit(wl); |
| 5325 | |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5326 | vfree(wl->fw); |
| 5327 | wl->fw = NULL; |
Eliad Peller | 3fcdab7 | 2012-02-06 12:47:54 +0200 | [diff] [blame] | 5328 | wl->fw_type = WL12XX_FW_TYPE_NONE; |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5329 | kfree(wl->nvs); |
| 5330 | wl->nvs = NULL; |
| 5331 | |
| 5332 | kfree(wl->fw_status); |
| 5333 | kfree(wl->tx_res_if); |
Eliad Peller | 92ef896 | 2011-06-07 12:50:46 +0300 | [diff] [blame] | 5334 | destroy_workqueue(wl->freezable_wq); |
Teemu Paasikivi | c332a4b | 2010-02-18 13:25:57 +0200 | [diff] [blame] | 5335 | |
| 5336 | ieee80211_free_hw(wl->hw); |
| 5337 | |
| 5338 | return 0; |
| 5339 | } |
Teemu Paasikivi | 50b3eb4 | 2010-02-22 08:38:26 +0200 | [diff] [blame] | 5340 | |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 5341 | static irqreturn_t wl12xx_hardirq(int irq, void *cookie) |
| 5342 | { |
| 5343 | struct wl1271 *wl = cookie; |
| 5344 | unsigned long flags; |
| 5345 | |
| 5346 | wl1271_debug(DEBUG_IRQ, "IRQ"); |
| 5347 | |
| 5348 | /* complete the ELP completion */ |
| 5349 | spin_lock_irqsave(&wl->wl_lock, flags); |
| 5350 | set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); |
| 5351 | if (wl->elp_compl) { |
| 5352 | complete(wl->elp_compl); |
| 5353 | wl->elp_compl = NULL; |
| 5354 | } |
| 5355 | |
| 5356 | if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) { |
| 5357 | /* don't enqueue a work right now. mark it as pending */ |
| 5358 | set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags); |
| 5359 | wl1271_debug(DEBUG_IRQ, "should not enqueue work"); |
| 5360 | disable_irq_nosync(wl->irq); |
| 5361 | pm_wakeup_event(wl->dev, 0); |
| 5362 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 5363 | return IRQ_HANDLED; |
| 5364 | } |
| 5365 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 5366 | |
| 5367 | return IRQ_WAKE_THREAD; |
| 5368 | } |
| 5369 | |
Felipe Balbi | ce2a217 | 2011-10-05 14:12:55 +0300 | [diff] [blame] | 5370 | static int __devinit wl12xx_probe(struct platform_device *pdev) |
| 5371 | { |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 5372 | struct wl12xx_platform_data *pdata = pdev->dev.platform_data; |
| 5373 | struct ieee80211_hw *hw; |
| 5374 | struct wl1271 *wl; |
| 5375 | unsigned long irqflags; |
| 5376 | int ret = -ENODEV; |
| 5377 | |
| 5378 | hw = wl1271_alloc_hw(); |
| 5379 | if (IS_ERR(hw)) { |
| 5380 | wl1271_error("can't allocate hw"); |
| 5381 | ret = PTR_ERR(hw); |
| 5382 | goto out; |
| 5383 | } |
| 5384 | |
| 5385 | wl = hw->priv; |
| 5386 | wl->irq = platform_get_irq(pdev, 0); |
| 5387 | wl->ref_clock = pdata->board_ref_clock; |
| 5388 | wl->tcxo_clock = pdata->board_tcxo_clock; |
| 5389 | wl->platform_quirks = pdata->platform_quirks; |
| 5390 | wl->set_power = pdata->set_power; |
| 5391 | wl->dev = &pdev->dev; |
| 5392 | wl->if_ops = pdata->ops; |
| 5393 | |
| 5394 | platform_set_drvdata(pdev, wl); |
| 5395 | |
| 5396 | if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) |
| 5397 | irqflags = IRQF_TRIGGER_RISING; |
| 5398 | else |
| 5399 | irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; |
| 5400 | |
| 5401 | ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wl1271_irq, |
| 5402 | irqflags, |
| 5403 | pdev->name, wl); |
| 5404 | if (ret < 0) { |
| 5405 | wl1271_error("request_irq() failed: %d", ret); |
| 5406 | goto out_free_hw; |
| 5407 | } |
| 5408 | |
| 5409 | ret = enable_irq_wake(wl->irq); |
| 5410 | if (!ret) { |
| 5411 | wl->irq_wake_enabled = true; |
| 5412 | device_init_wakeup(wl->dev, 1); |
| 5413 | if (pdata->pwr_in_suspend) |
| 5414 | hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; |
| 5415 | |
| 5416 | } |
| 5417 | disable_irq(wl->irq); |
| 5418 | |
| 5419 | ret = wl1271_init_ieee80211(wl); |
| 5420 | if (ret) |
| 5421 | goto out_irq; |
| 5422 | |
| 5423 | ret = wl1271_register_hw(wl); |
| 5424 | if (ret) |
| 5425 | goto out_irq; |
| 5426 | |
Felipe Balbi | f79f890 | 2011-10-06 13:05:25 +0300 | [diff] [blame] | 5427 | /* Create sysfs file to control bt coex state */ |
| 5428 | ret = device_create_file(wl->dev, &dev_attr_bt_coex_state); |
| 5429 | if (ret < 0) { |
| 5430 | wl1271_error("failed to create sysfs file bt_coex_state"); |
| 5431 | goto out_irq; |
| 5432 | } |
| 5433 | |
| 5434 | /* Create sysfs file to get HW PG version */ |
| 5435 | ret = device_create_file(wl->dev, &dev_attr_hw_pg_ver); |
| 5436 | if (ret < 0) { |
| 5437 | wl1271_error("failed to create sysfs file hw_pg_ver"); |
| 5438 | goto out_bt_coex_state; |
| 5439 | } |
| 5440 | |
| 5441 | /* Create sysfs file for the FW log */ |
| 5442 | ret = device_create_bin_file(wl->dev, &fwlog_attr); |
| 5443 | if (ret < 0) { |
| 5444 | wl1271_error("failed to create sysfs file fwlog"); |
| 5445 | goto out_hw_pg_ver; |
| 5446 | } |
| 5447 | |
Felipe Balbi | ce2a217 | 2011-10-05 14:12:55 +0300 | [diff] [blame] | 5448 | return 0; |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 5449 | |
Felipe Balbi | f79f890 | 2011-10-06 13:05:25 +0300 | [diff] [blame] | 5450 | out_hw_pg_ver: |
| 5451 | device_remove_file(wl->dev, &dev_attr_hw_pg_ver); |
| 5452 | |
| 5453 | out_bt_coex_state: |
| 5454 | device_remove_file(wl->dev, &dev_attr_bt_coex_state); |
| 5455 | |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 5456 | out_irq: |
| 5457 | free_irq(wl->irq, wl); |
| 5458 | |
| 5459 | out_free_hw: |
| 5460 | wl1271_free_hw(wl); |
| 5461 | |
| 5462 | out: |
| 5463 | return ret; |
Felipe Balbi | ce2a217 | 2011-10-05 14:12:55 +0300 | [diff] [blame] | 5464 | } |
| 5465 | |
| 5466 | static int __devexit wl12xx_remove(struct platform_device *pdev) |
| 5467 | { |
Felipe Balbi | a390e85 | 2011-10-06 10:07:44 +0300 | [diff] [blame] | 5468 | struct wl1271 *wl = platform_get_drvdata(pdev); |
| 5469 | |
| 5470 | if (wl->irq_wake_enabled) { |
| 5471 | device_init_wakeup(wl->dev, 0); |
| 5472 | disable_irq_wake(wl->irq); |
| 5473 | } |
| 5474 | wl1271_unregister_hw(wl); |
| 5475 | free_irq(wl->irq, wl); |
| 5476 | wl1271_free_hw(wl); |
| 5477 | |
Felipe Balbi | ce2a217 | 2011-10-05 14:12:55 +0300 | [diff] [blame] | 5478 | return 0; |
| 5479 | } |
| 5480 | |
| 5481 | static const struct platform_device_id wl12xx_id_table[] __devinitconst = { |
Luciano Coelho | ccb6200 | 2011-10-07 15:54:15 +0300 | [diff] [blame] | 5482 | { "wl12xx", 0 }, |
Felipe Balbi | ce2a217 | 2011-10-05 14:12:55 +0300 | [diff] [blame] | 5483 | { } /* Terminating Entry */ |
| 5484 | }; |
| 5485 | MODULE_DEVICE_TABLE(platform, wl12xx_id_table); |
| 5486 | |
| 5487 | static struct platform_driver wl12xx_driver = { |
| 5488 | .probe = wl12xx_probe, |
| 5489 | .remove = __devexit_p(wl12xx_remove), |
| 5490 | .id_table = wl12xx_id_table, |
| 5491 | .driver = { |
Luciano Coelho | ccb6200 | 2011-10-07 15:54:15 +0300 | [diff] [blame] | 5492 | .name = "wl12xx_driver", |
Felipe Balbi | ce2a217 | 2011-10-05 14:12:55 +0300 | [diff] [blame] | 5493 | .owner = THIS_MODULE, |
| 5494 | } |
| 5495 | }; |
| 5496 | |
| 5497 | static int __init wl12xx_init(void) |
| 5498 | { |
| 5499 | return platform_driver_register(&wl12xx_driver); |
| 5500 | } |
| 5501 | module_init(wl12xx_init); |
| 5502 | |
| 5503 | static void __exit wl12xx_exit(void) |
| 5504 | { |
| 5505 | platform_driver_unregister(&wl12xx_driver); |
| 5506 | } |
| 5507 | module_exit(wl12xx_exit); |
| 5508 | |
Guy Eilam | 491bbd6 | 2011-01-12 10:33:29 +0100 | [diff] [blame] | 5509 | u32 wl12xx_debug_level = DEBUG_NONE; |
Eliad Peller | 17c1755 | 2010-12-12 12:15:35 +0200 | [diff] [blame] | 5510 | EXPORT_SYMBOL_GPL(wl12xx_debug_level); |
Guy Eilam | 491bbd6 | 2011-01-12 10:33:29 +0100 | [diff] [blame] | 5511 | module_param_named(debug_level, wl12xx_debug_level, uint, S_IRUSR | S_IWUSR); |
Eliad Peller | 17c1755 | 2010-12-12 12:15:35 +0200 | [diff] [blame] | 5512 | MODULE_PARM_DESC(debug_level, "wl12xx debugging level"); |
| 5513 | |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 5514 | module_param_named(fwlog, fwlog_param, charp, 0); |
Luciano Coelho | 2c882fa | 2012-02-07 12:37:33 +0200 | [diff] [blame] | 5515 | MODULE_PARM_DESC(fwlog, |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 5516 | "FW logger options: continuous, ondemand, dbgpins or disable"); |
| 5517 | |
Eliad Peller | 2a5bff0 | 2011-08-25 18:10:59 +0300 | [diff] [blame] | 5518 | module_param(bug_on_recovery, bool, S_IRUSR | S_IWUSR); |
| 5519 | MODULE_PARM_DESC(bug_on_recovery, "BUG() on fw recovery"); |
| 5520 | |
Teemu Paasikivi | 50b3eb4 | 2010-02-22 08:38:26 +0200 | [diff] [blame] | 5521 | MODULE_LICENSE("GPL"); |
Luciano Coelho | b1a48ca | 2011-02-22 14:19:28 +0200 | [diff] [blame] | 5522 | MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>"); |
Teemu Paasikivi | 50b3eb4 | 2010-02-22 08:38:26 +0200 | [diff] [blame] | 5523 | MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>"); |