Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl1271 |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 Nokia Corporation |
| 5 | * |
| 6 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | * |
| 22 | */ |
| 23 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 24 | #include "acx.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/platform_device.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 28 | #include <linux/spi/spi.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 30 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 31 | #include "wl12xx.h" |
Luciano Coelho | 0f4e312 | 2011-10-07 11:02:42 +0300 | [diff] [blame] | 32 | #include "debug.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 33 | #include "wl12xx_80211.h" |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 34 | #include "reg.h" |
| 35 | #include "ps.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 36 | |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 37 | int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 38 | u8 wake_up_event, u8 listen_interval) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 39 | { |
| 40 | struct acx_wake_up_condition *wake_up; |
| 41 | int ret; |
| 42 | |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 43 | wl1271_debug(DEBUG_ACX, "acx wake up conditions (wake_up_event %d listen_interval %d)", |
| 44 | wake_up_event, listen_interval); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 45 | |
| 46 | wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL); |
| 47 | if (!wake_up) { |
| 48 | ret = -ENOMEM; |
| 49 | goto out; |
| 50 | } |
| 51 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 52 | wake_up->role_id = wlvif->role_id; |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 53 | wake_up->wake_up_event = wake_up_event; |
| 54 | wake_up->listen_interval = listen_interval; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 55 | |
| 56 | ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS, |
| 57 | wake_up, sizeof(*wake_up)); |
| 58 | if (ret < 0) { |
| 59 | wl1271_warning("could not set wake up conditions: %d", ret); |
| 60 | goto out; |
| 61 | } |
| 62 | |
| 63 | out: |
| 64 | kfree(wake_up); |
| 65 | return ret; |
| 66 | } |
| 67 | |
| 68 | int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth) |
| 69 | { |
| 70 | struct acx_sleep_auth *auth; |
| 71 | int ret; |
| 72 | |
| 73 | wl1271_debug(DEBUG_ACX, "acx sleep auth"); |
| 74 | |
| 75 | auth = kzalloc(sizeof(*auth), GFP_KERNEL); |
| 76 | if (!auth) { |
| 77 | ret = -ENOMEM; |
| 78 | goto out; |
| 79 | } |
| 80 | |
| 81 | auth->sleep_auth = sleep_auth; |
| 82 | |
| 83 | ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth)); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 84 | |
| 85 | out: |
| 86 | kfree(auth); |
| 87 | return ret; |
| 88 | } |
| 89 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 90 | int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 91 | int power) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 92 | { |
| 93 | struct acx_current_tx_power *acx; |
| 94 | int ret; |
| 95 | |
Arik Nemtsov | 097f882 | 2011-06-27 22:06:34 +0300 | [diff] [blame] | 96 | wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 97 | |
| 98 | if (power < 0 || power > 25) |
| 99 | return -EINVAL; |
| 100 | |
| 101 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 102 | if (!acx) { |
| 103 | ret = -ENOMEM; |
| 104 | goto out; |
| 105 | } |
| 106 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 107 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | 6f6b5d4 | 2010-02-22 08:38:42 +0200 | [diff] [blame] | 108 | acx->current_tx_power = power * 10; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 109 | |
| 110 | ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); |
| 111 | if (ret < 0) { |
| 112 | wl1271_warning("configure of tx power failed: %d", ret); |
| 113 | goto out; |
| 114 | } |
| 115 | |
| 116 | out: |
| 117 | kfree(acx); |
| 118 | return ret; |
| 119 | } |
| 120 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 121 | int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 122 | { |
| 123 | struct acx_feature_config *feature; |
| 124 | int ret; |
| 125 | |
| 126 | wl1271_debug(DEBUG_ACX, "acx feature cfg"); |
| 127 | |
| 128 | feature = kzalloc(sizeof(*feature), GFP_KERNEL); |
| 129 | if (!feature) { |
| 130 | ret = -ENOMEM; |
| 131 | goto out; |
| 132 | } |
| 133 | |
| 134 | /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 135 | feature->role_id = wlvif->role_id; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 136 | feature->data_flow_options = 0; |
| 137 | feature->options = 0; |
| 138 | |
| 139 | ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG, |
| 140 | feature, sizeof(*feature)); |
| 141 | if (ret < 0) { |
| 142 | wl1271_error("Couldnt set HW encryption"); |
| 143 | goto out; |
| 144 | } |
| 145 | |
| 146 | out: |
| 147 | kfree(feature); |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map, |
| 152 | size_t len) |
| 153 | { |
| 154 | int ret; |
| 155 | |
| 156 | wl1271_debug(DEBUG_ACX, "acx mem map"); |
| 157 | |
| 158 | ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); |
| 159 | if (ret < 0) |
| 160 | return ret; |
| 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | |
Juuso Oikarinen | 8793f9b | 2009-10-13 12:47:40 +0300 | [diff] [blame] | 165 | int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 166 | { |
| 167 | struct acx_rx_msdu_lifetime *acx; |
| 168 | int ret; |
| 169 | |
| 170 | wl1271_debug(DEBUG_ACX, "acx rx msdu life time"); |
| 171 | |
| 172 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 173 | if (!acx) { |
| 174 | ret = -ENOMEM; |
| 175 | goto out; |
| 176 | } |
| 177 | |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 178 | acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 179 | ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME, |
| 180 | acx, sizeof(*acx)); |
| 181 | if (ret < 0) { |
| 182 | wl1271_warning("failed to set rx msdu life time: %d", ret); |
| 183 | goto out; |
| 184 | } |
| 185 | |
| 186 | out: |
| 187 | kfree(acx); |
| 188 | return ret; |
| 189 | } |
| 190 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 191 | int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 192 | enum acx_slot_type slot_time) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 193 | { |
| 194 | struct acx_slot *slot; |
| 195 | int ret; |
| 196 | |
| 197 | wl1271_debug(DEBUG_ACX, "acx slot"); |
| 198 | |
| 199 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
| 200 | if (!slot) { |
| 201 | ret = -ENOMEM; |
| 202 | goto out; |
| 203 | } |
| 204 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 205 | slot->role_id = wlvif->role_id; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 206 | slot->wone_index = STATION_WONE_INDEX; |
| 207 | slot->slot_time = slot_time; |
| 208 | |
| 209 | ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot)); |
| 210 | if (ret < 0) { |
| 211 | wl1271_warning("failed to set slot time: %d", ret); |
| 212 | goto out; |
| 213 | } |
| 214 | |
| 215 | out: |
| 216 | kfree(slot); |
| 217 | return ret; |
| 218 | } |
| 219 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 220 | int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 221 | bool enable, void *mc_list, u32 mc_list_len) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 222 | { |
| 223 | struct acx_dot11_grp_addr_tbl *acx; |
| 224 | int ret; |
| 225 | |
| 226 | wl1271_debug(DEBUG_ACX, "acx group address tbl"); |
| 227 | |
| 228 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 229 | if (!acx) { |
| 230 | ret = -ENOMEM; |
| 231 | goto out; |
| 232 | } |
| 233 | |
| 234 | /* MAC filtering */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 235 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 236 | acx->enabled = enable; |
| 237 | acx->num_groups = mc_list_len; |
| 238 | memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 239 | |
| 240 | ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL, |
| 241 | acx, sizeof(*acx)); |
| 242 | if (ret < 0) { |
| 243 | wl1271_warning("failed to set group addr table: %d", ret); |
| 244 | goto out; |
| 245 | } |
| 246 | |
| 247 | out: |
| 248 | kfree(acx); |
| 249 | return ret; |
| 250 | } |
| 251 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 252 | int wl1271_acx_service_period_timeout(struct wl1271 *wl, |
| 253 | struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 254 | { |
| 255 | struct acx_rx_timeout *rx_timeout; |
| 256 | int ret; |
| 257 | |
| 258 | rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL); |
| 259 | if (!rx_timeout) { |
| 260 | ret = -ENOMEM; |
| 261 | goto out; |
| 262 | } |
| 263 | |
| 264 | wl1271_debug(DEBUG_ACX, "acx service period timeout"); |
| 265 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 266 | rx_timeout->role_id = wlvif->role_id; |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 267 | rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout); |
| 268 | rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 269 | |
| 270 | ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT, |
| 271 | rx_timeout, sizeof(*rx_timeout)); |
| 272 | if (ret < 0) { |
| 273 | wl1271_warning("failed to set service period timeout: %d", |
| 274 | ret); |
| 275 | goto out; |
| 276 | } |
| 277 | |
| 278 | out: |
| 279 | kfree(rx_timeout); |
| 280 | return ret; |
| 281 | } |
| 282 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 283 | int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 284 | u32 rts_threshold) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 285 | { |
| 286 | struct acx_rts_threshold *rts; |
| 287 | int ret; |
| 288 | |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 289 | /* |
| 290 | * If the RTS threshold is not configured or out of range, use the |
| 291 | * default value. |
| 292 | */ |
| 293 | if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD) |
| 294 | rts_threshold = wl->conf.rx.rts_threshold; |
| 295 | |
| 296 | wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 297 | |
| 298 | rts = kzalloc(sizeof(*rts), GFP_KERNEL); |
| 299 | if (!rts) { |
| 300 | ret = -ENOMEM; |
| 301 | goto out; |
| 302 | } |
| 303 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 304 | rts->role_id = wlvif->role_id; |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 305 | rts->threshold = cpu_to_le16((u16)rts_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 306 | |
| 307 | ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); |
| 308 | if (ret < 0) { |
| 309 | wl1271_warning("failed to set rts threshold: %d", ret); |
| 310 | goto out; |
| 311 | } |
| 312 | |
| 313 | out: |
| 314 | kfree(rts); |
| 315 | return ret; |
| 316 | } |
| 317 | |
Luciano Coelho | 6e92b41 | 2009-12-11 15:40:50 +0200 | [diff] [blame] | 318 | int wl1271_acx_dco_itrim_params(struct wl1271 *wl) |
| 319 | { |
| 320 | struct acx_dco_itrim_params *dco; |
| 321 | struct conf_itrim_settings *c = &wl->conf.itrim; |
| 322 | int ret; |
| 323 | |
| 324 | wl1271_debug(DEBUG_ACX, "acx dco itrim parameters"); |
| 325 | |
| 326 | dco = kzalloc(sizeof(*dco), GFP_KERNEL); |
| 327 | if (!dco) { |
| 328 | ret = -ENOMEM; |
| 329 | goto out; |
| 330 | } |
| 331 | |
| 332 | dco->enable = c->enable; |
| 333 | dco->timeout = cpu_to_le32(c->timeout); |
| 334 | |
| 335 | ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS, |
| 336 | dco, sizeof(*dco)); |
| 337 | if (ret < 0) { |
| 338 | wl1271_warning("failed to set dco itrim parameters: %d", ret); |
| 339 | goto out; |
| 340 | } |
| 341 | |
| 342 | out: |
| 343 | kfree(dco); |
| 344 | return ret; |
| 345 | } |
| 346 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 347 | int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 348 | bool enable_filter) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 349 | { |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 350 | struct acx_beacon_filter_option *beacon_filter = NULL; |
| 351 | int ret = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 352 | |
| 353 | wl1271_debug(DEBUG_ACX, "acx beacon filter opt"); |
| 354 | |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 355 | if (enable_filter && |
| 356 | wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED) |
| 357 | goto out; |
| 358 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 359 | beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL); |
| 360 | if (!beacon_filter) { |
| 361 | ret = -ENOMEM; |
| 362 | goto out; |
| 363 | } |
| 364 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 365 | beacon_filter->role_id = wlvif->role_id; |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 366 | beacon_filter->enable = enable_filter; |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 367 | |
| 368 | /* |
| 369 | * When set to zero, and the filter is enabled, beacons |
| 370 | * without the unicast TIM bit set are dropped. |
| 371 | */ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 372 | beacon_filter->max_num_beacons = 0; |
| 373 | |
| 374 | ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT, |
| 375 | beacon_filter, sizeof(*beacon_filter)); |
| 376 | if (ret < 0) { |
| 377 | wl1271_warning("failed to set beacon filter opt: %d", ret); |
| 378 | goto out; |
| 379 | } |
| 380 | |
| 381 | out: |
| 382 | kfree(beacon_filter); |
| 383 | return ret; |
| 384 | } |
| 385 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 386 | int wl1271_acx_beacon_filter_table(struct wl1271 *wl, |
| 387 | struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 388 | { |
| 389 | struct acx_beacon_filter_ie_table *ie_table; |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 390 | int i, idx = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 391 | int ret; |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 392 | bool vendor_spec = false; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 393 | |
| 394 | wl1271_debug(DEBUG_ACX, "acx beacon filter table"); |
| 395 | |
| 396 | ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL); |
| 397 | if (!ie_table) { |
| 398 | ret = -ENOMEM; |
| 399 | goto out; |
| 400 | } |
| 401 | |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 402 | /* configure default beacon pass-through rules */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 403 | ie_table->role_id = wlvif->role_id; |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 404 | ie_table->num_ie = 0; |
| 405 | for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) { |
| 406 | struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]); |
| 407 | ie_table->table[idx++] = r->ie; |
| 408 | ie_table->table[idx++] = r->rule; |
| 409 | |
| 410 | if (r->ie == WLAN_EID_VENDOR_SPECIFIC) { |
| 411 | /* only one vendor specific ie allowed */ |
| 412 | if (vendor_spec) |
| 413 | continue; |
| 414 | |
| 415 | /* for vendor specific rules configure the |
| 416 | additional fields */ |
| 417 | memcpy(&(ie_table->table[idx]), r->oui, |
| 418 | CONF_BCN_IE_OUI_LEN); |
| 419 | idx += CONF_BCN_IE_OUI_LEN; |
| 420 | ie_table->table[idx++] = r->type; |
| 421 | memcpy(&(ie_table->table[idx]), r->version, |
| 422 | CONF_BCN_IE_VER_LEN); |
| 423 | idx += CONF_BCN_IE_VER_LEN; |
| 424 | vendor_spec = true; |
| 425 | } |
| 426 | |
| 427 | ie_table->num_ie++; |
| 428 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 429 | |
| 430 | ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE, |
| 431 | ie_table, sizeof(*ie_table)); |
| 432 | if (ret < 0) { |
| 433 | wl1271_warning("failed to set beacon filter table: %d", ret); |
| 434 | goto out; |
| 435 | } |
| 436 | |
| 437 | out: |
| 438 | kfree(ie_table); |
| 439 | return ret; |
| 440 | } |
| 441 | |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 442 | #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff |
| 443 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 444 | int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 445 | bool enable) |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 446 | { |
| 447 | struct acx_conn_monit_params *acx; |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 448 | u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE; |
| 449 | u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE; |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 450 | int ret; |
| 451 | |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 452 | wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s", |
| 453 | enable ? "enabled" : "disabled"); |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 454 | |
| 455 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 456 | if (!acx) { |
| 457 | ret = -ENOMEM; |
| 458 | goto out; |
| 459 | } |
| 460 | |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 461 | if (enable) { |
| 462 | threshold = wl->conf.conn.synch_fail_thold; |
| 463 | timeout = wl->conf.conn.bss_lose_timeout; |
| 464 | } |
| 465 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 466 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | 6ccbb92 | 2010-03-26 12:53:23 +0200 | [diff] [blame] | 467 | acx->synch_fail_thold = cpu_to_le32(threshold); |
| 468 | acx->bss_lose_timeout = cpu_to_le32(timeout); |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 469 | |
| 470 | ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS, |
| 471 | acx, sizeof(*acx)); |
| 472 | if (ret < 0) { |
| 473 | wl1271_warning("failed to set connection monitor " |
| 474 | "parameters: %d", ret); |
| 475 | goto out; |
| 476 | } |
| 477 | |
| 478 | out: |
| 479 | kfree(acx); |
| 480 | return ret; |
| 481 | } |
| 482 | |
| 483 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 484 | int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 485 | { |
| 486 | struct acx_bt_wlan_coex *pta; |
| 487 | int ret; |
| 488 | |
| 489 | wl1271_debug(DEBUG_ACX, "acx sg enable"); |
| 490 | |
| 491 | pta = kzalloc(sizeof(*pta), GFP_KERNEL); |
| 492 | if (!pta) { |
| 493 | ret = -ENOMEM; |
| 494 | goto out; |
| 495 | } |
| 496 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 497 | if (enable) |
| 498 | pta->enable = wl->conf.sg.state; |
| 499 | else |
| 500 | pta->enable = CONF_SG_DISABLE; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 501 | |
| 502 | ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta)); |
| 503 | if (ret < 0) { |
| 504 | wl1271_warning("failed to set softgemini enable: %d", ret); |
| 505 | goto out; |
| 506 | } |
| 507 | |
| 508 | out: |
| 509 | kfree(pta); |
| 510 | return ret; |
| 511 | } |
| 512 | |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 513 | int wl12xx_acx_sg_cfg(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 514 | { |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 515 | struct acx_bt_wlan_coex_param *param; |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 516 | struct conf_sg_settings *c = &wl->conf.sg; |
Juuso Oikarinen | 1b00f54 | 2010-03-18 12:26:30 +0200 | [diff] [blame] | 517 | int i, ret; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 518 | |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 519 | wl1271_debug(DEBUG_ACX, "acx sg cfg"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 520 | |
| 521 | param = kzalloc(sizeof(*param), GFP_KERNEL); |
| 522 | if (!param) { |
| 523 | ret = -ENOMEM; |
| 524 | goto out; |
| 525 | } |
| 526 | |
| 527 | /* BT-WLAN coext parameters */ |
Eliad Peller | 3be4112 | 2011-08-14 13:17:19 +0300 | [diff] [blame] | 528 | for (i = 0; i < CONF_SG_PARAMS_MAX; i++) |
| 529 | param->params[i] = cpu_to_le32(c->params[i]); |
Juuso Oikarinen | 1b00f54 | 2010-03-18 12:26:30 +0200 | [diff] [blame] | 530 | param->param_idx = CONF_SG_PARAMS_ALL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 531 | |
| 532 | ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param)); |
| 533 | if (ret < 0) { |
| 534 | wl1271_warning("failed to set sg config: %d", ret); |
| 535 | goto out; |
| 536 | } |
| 537 | |
| 538 | out: |
| 539 | kfree(param); |
| 540 | return ret; |
| 541 | } |
| 542 | |
| 543 | int wl1271_acx_cca_threshold(struct wl1271 *wl) |
| 544 | { |
| 545 | struct acx_energy_detection *detection; |
| 546 | int ret; |
| 547 | |
| 548 | wl1271_debug(DEBUG_ACX, "acx cca threshold"); |
| 549 | |
| 550 | detection = kzalloc(sizeof(*detection), GFP_KERNEL); |
| 551 | if (!detection) { |
| 552 | ret = -ENOMEM; |
| 553 | goto out; |
| 554 | } |
| 555 | |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 556 | detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold); |
Juuso Oikarinen | 45b531a | 2009-10-13 12:47:41 +0300 | [diff] [blame] | 557 | detection->tx_energy_detection = wl->conf.tx.tx_energy_detection; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 558 | |
| 559 | ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD, |
| 560 | detection, sizeof(*detection)); |
Julia Lawall | f8afdf4 | 2011-08-12 13:31:30 -0400 | [diff] [blame] | 561 | if (ret < 0) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 562 | wl1271_warning("failed to set cca threshold: %d", ret); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 563 | |
| 564 | out: |
| 565 | kfree(detection); |
| 566 | return ret; |
| 567 | } |
| 568 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 569 | int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 570 | { |
| 571 | struct acx_beacon_broadcast *bb; |
| 572 | int ret; |
| 573 | |
| 574 | wl1271_debug(DEBUG_ACX, "acx bcn dtim options"); |
| 575 | |
| 576 | bb = kzalloc(sizeof(*bb), GFP_KERNEL); |
| 577 | if (!bb) { |
| 578 | ret = -ENOMEM; |
| 579 | goto out; |
| 580 | } |
| 581 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 582 | bb->role_id = wlvif->role_id; |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 583 | bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout); |
| 584 | bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout); |
Juuso Oikarinen | 51f2be2 | 2009-10-13 12:47:42 +0300 | [diff] [blame] | 585 | bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps; |
| 586 | bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 587 | |
| 588 | ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb)); |
| 589 | if (ret < 0) { |
| 590 | wl1271_warning("failed to set rx config: %d", ret); |
| 591 | goto out; |
| 592 | } |
| 593 | |
| 594 | out: |
| 595 | kfree(bb); |
| 596 | return ret; |
| 597 | } |
| 598 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 599 | int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 600 | { |
| 601 | struct acx_aid *acx_aid; |
| 602 | int ret; |
| 603 | |
| 604 | wl1271_debug(DEBUG_ACX, "acx aid"); |
| 605 | |
| 606 | acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL); |
| 607 | if (!acx_aid) { |
| 608 | ret = -ENOMEM; |
| 609 | goto out; |
| 610 | } |
| 611 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 612 | acx_aid->role_id = wlvif->role_id; |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 613 | acx_aid->aid = cpu_to_le16(aid); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 614 | |
| 615 | ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); |
| 616 | if (ret < 0) { |
| 617 | wl1271_warning("failed to set aid: %d", ret); |
| 618 | goto out; |
| 619 | } |
| 620 | |
| 621 | out: |
| 622 | kfree(acx_aid); |
| 623 | return ret; |
| 624 | } |
| 625 | |
| 626 | int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask) |
| 627 | { |
| 628 | struct acx_event_mask *mask; |
| 629 | int ret; |
| 630 | |
| 631 | wl1271_debug(DEBUG_ACX, "acx event mbox mask"); |
| 632 | |
| 633 | mask = kzalloc(sizeof(*mask), GFP_KERNEL); |
| 634 | if (!mask) { |
| 635 | ret = -ENOMEM; |
| 636 | goto out; |
| 637 | } |
| 638 | |
| 639 | /* high event mask is unused */ |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 640 | mask->high_event_mask = cpu_to_le32(0xffffffff); |
| 641 | mask->event_mask = cpu_to_le32(event_mask); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 642 | |
| 643 | ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK, |
| 644 | mask, sizeof(*mask)); |
| 645 | if (ret < 0) { |
| 646 | wl1271_warning("failed to set acx_event_mbox_mask: %d", ret); |
| 647 | goto out; |
| 648 | } |
| 649 | |
| 650 | out: |
| 651 | kfree(mask); |
| 652 | return ret; |
| 653 | } |
| 654 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 655 | int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 656 | enum acx_preamble_type preamble) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 657 | { |
| 658 | struct acx_preamble *acx; |
| 659 | int ret; |
| 660 | |
| 661 | wl1271_debug(DEBUG_ACX, "acx_set_preamble"); |
| 662 | |
| 663 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 664 | if (!acx) { |
| 665 | ret = -ENOMEM; |
| 666 | goto out; |
| 667 | } |
| 668 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 669 | acx->role_id = wlvif->role_id; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 670 | acx->preamble = preamble; |
| 671 | |
| 672 | ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); |
| 673 | if (ret < 0) { |
| 674 | wl1271_warning("Setting of preamble failed: %d", ret); |
| 675 | goto out; |
| 676 | } |
| 677 | |
| 678 | out: |
| 679 | kfree(acx); |
| 680 | return ret; |
| 681 | } |
| 682 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 683 | int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 684 | enum acx_ctsprotect_type ctsprotect) |
| 685 | { |
| 686 | struct acx_ctsprotect *acx; |
| 687 | int ret; |
| 688 | |
| 689 | wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect"); |
| 690 | |
| 691 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 692 | if (!acx) { |
| 693 | ret = -ENOMEM; |
| 694 | goto out; |
| 695 | } |
| 696 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 697 | acx->role_id = wlvif->role_id; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 698 | acx->ctsprotect = ctsprotect; |
| 699 | |
| 700 | ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); |
| 701 | if (ret < 0) { |
| 702 | wl1271_warning("Setting of ctsprotect failed: %d", ret); |
| 703 | goto out; |
| 704 | } |
| 705 | |
| 706 | out: |
| 707 | kfree(acx); |
| 708 | return ret; |
| 709 | } |
| 710 | |
| 711 | int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats) |
| 712 | { |
| 713 | int ret; |
| 714 | |
| 715 | wl1271_debug(DEBUG_ACX, "acx statistics"); |
| 716 | |
| 717 | ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats, |
| 718 | sizeof(*stats)); |
| 719 | if (ret < 0) { |
| 720 | wl1271_warning("acx statistics failed: %d", ret); |
| 721 | return -ENOMEM; |
| 722 | } |
| 723 | |
| 724 | return 0; |
| 725 | } |
| 726 | |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 727 | int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 728 | { |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 729 | struct acx_rate_policy *acx; |
Arik Nemtsov | 1e05a81 | 2010-10-16 17:44:51 +0200 | [diff] [blame] | 730 | struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 731 | int ret = 0; |
| 732 | |
| 733 | wl1271_debug(DEBUG_ACX, "acx rate policies"); |
| 734 | |
| 735 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 736 | |
| 737 | if (!acx) { |
| 738 | ret = -ENOMEM; |
| 739 | goto out; |
| 740 | } |
| 741 | |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 742 | wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x", |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 743 | wlvif->basic_rate, wlvif->rate_set); |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 744 | |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 745 | /* configure one basic rate class */ |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 746 | acx->rate_policy_idx = cpu_to_le32(wlvif->sta.basic_rate_idx); |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 747 | acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate); |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 748 | acx->rate_policy.short_retry_limit = c->short_retry_limit; |
| 749 | acx->rate_policy.long_retry_limit = c->long_retry_limit; |
| 750 | acx->rate_policy.aflags = c->aflags; |
| 751 | |
| 752 | ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); |
| 753 | if (ret < 0) { |
| 754 | wl1271_warning("Setting of rate policies failed: %d", ret); |
| 755 | goto out; |
| 756 | } |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 757 | |
| 758 | /* configure one AP supported rate class */ |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 759 | acx->rate_policy_idx = cpu_to_le32(wlvif->sta.ap_rate_idx); |
Eliad Peller | 30d0c8f | 2011-10-05 11:55:42 +0200 | [diff] [blame] | 760 | acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set); |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 761 | acx->rate_policy.short_retry_limit = c->short_retry_limit; |
| 762 | acx->rate_policy.long_retry_limit = c->long_retry_limit; |
| 763 | acx->rate_policy.aflags = c->aflags; |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 764 | |
Eliad Peller | 4b29886 | 2011-10-03 12:06:36 +0200 | [diff] [blame] | 765 | ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); |
| 766 | if (ret < 0) { |
| 767 | wl1271_warning("Setting of rate policies failed: %d", ret); |
| 768 | goto out; |
| 769 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 770 | |
Eliad Peller | 4b29886 | 2011-10-03 12:06:36 +0200 | [diff] [blame] | 771 | /* |
| 772 | * configure one rate class for basic p2p operations. |
| 773 | * (p2p packets should always go out with OFDM rates, even |
| 774 | * if we are currently connected to 11b AP) |
| 775 | */ |
Eliad Peller | e5a359f | 2011-10-10 10:13:15 +0200 | [diff] [blame] | 776 | acx->rate_policy_idx = cpu_to_le32(wlvif->sta.p2p_rate_idx); |
Eliad Peller | 4b29886 | 2011-10-03 12:06:36 +0200 | [diff] [blame] | 777 | acx->rate_policy.enabled_rates = |
| 778 | cpu_to_le32(CONF_TX_RATE_MASK_BASIC_P2P); |
| 779 | acx->rate_policy.short_retry_limit = c->short_retry_limit; |
| 780 | acx->rate_policy.long_retry_limit = c->long_retry_limit; |
| 781 | acx->rate_policy.aflags = c->aflags; |
Eliad Peller | 72c2d9e | 2011-02-02 09:59:37 +0200 | [diff] [blame] | 782 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 783 | ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); |
| 784 | if (ret < 0) { |
| 785 | wl1271_warning("Setting of rate policies failed: %d", ret); |
| 786 | goto out; |
| 787 | } |
| 788 | |
| 789 | out: |
| 790 | kfree(acx); |
| 791 | return ret; |
| 792 | } |
| 793 | |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 794 | int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c, |
| 795 | u8 idx) |
| 796 | { |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 797 | struct acx_rate_policy *acx; |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 798 | int ret = 0; |
| 799 | |
Arik Nemtsov | 70f4742 | 2011-04-18 14:15:25 +0300 | [diff] [blame] | 800 | wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x", |
| 801 | idx, c->enabled_rates); |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 802 | |
| 803 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 804 | if (!acx) { |
| 805 | ret = -ENOMEM; |
| 806 | goto out; |
| 807 | } |
| 808 | |
| 809 | acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates); |
| 810 | acx->rate_policy.short_retry_limit = c->short_retry_limit; |
| 811 | acx->rate_policy.long_retry_limit = c->long_retry_limit; |
| 812 | acx->rate_policy.aflags = c->aflags; |
| 813 | |
Eliad Peller | 1d4801f | 2011-01-16 10:07:10 +0100 | [diff] [blame] | 814 | acx->rate_policy_idx = cpu_to_le32(idx); |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 815 | |
| 816 | ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); |
| 817 | if (ret < 0) { |
| 818 | wl1271_warning("Setting of ap rate policy failed: %d", ret); |
| 819 | goto out; |
| 820 | } |
| 821 | |
| 822 | out: |
| 823 | kfree(acx); |
| 824 | return ret; |
| 825 | } |
| 826 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 827 | int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 828 | u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 829 | { |
| 830 | struct acx_ac_cfg *acx; |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 831 | int ret = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 832 | |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 833 | wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d " |
| 834 | "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 835 | |
| 836 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 837 | |
| 838 | if (!acx) { |
| 839 | ret = -ENOMEM; |
| 840 | goto out; |
| 841 | } |
| 842 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 843 | acx->role_id = wlvif->role_id; |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 844 | acx->ac = ac; |
| 845 | acx->cw_min = cw_min; |
| 846 | acx->cw_max = cpu_to_le16(cw_max); |
| 847 | acx->aifsn = aifsn; |
| 848 | acx->tx_op_limit = cpu_to_le16(txop); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 849 | |
Kalle Valo | 243eeb5 | 2010-02-18 13:25:39 +0200 | [diff] [blame] | 850 | ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx)); |
| 851 | if (ret < 0) { |
| 852 | wl1271_warning("acx ac cfg failed: %d", ret); |
| 853 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | out: |
| 857 | kfree(acx); |
| 858 | return ret; |
| 859 | } |
| 860 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 861 | int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 862 | u8 queue_id, u8 channel_type, |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 863 | u8 tsid, u8 ps_scheme, u8 ack_policy, |
| 864 | u32 apsd_conf0, u32 apsd_conf1) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 865 | { |
| 866 | struct acx_tid_config *acx; |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 867 | int ret = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 868 | |
| 869 | wl1271_debug(DEBUG_ACX, "acx tid config"); |
| 870 | |
| 871 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 872 | |
| 873 | if (!acx) { |
| 874 | ret = -ENOMEM; |
| 875 | goto out; |
| 876 | } |
| 877 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 878 | acx->role_id = wlvif->role_id; |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 879 | acx->queue_id = queue_id; |
| 880 | acx->channel_type = channel_type; |
| 881 | acx->tsid = tsid; |
| 882 | acx->ps_scheme = ps_scheme; |
| 883 | acx->ack_policy = ack_policy; |
| 884 | acx->apsd_conf[0] = cpu_to_le32(apsd_conf0); |
| 885 | acx->apsd_conf[1] = cpu_to_le32(apsd_conf1); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 886 | |
Kalle Valo | f2054df | 2010-02-18 13:25:40 +0200 | [diff] [blame] | 887 | ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx)); |
| 888 | if (ret < 0) { |
| 889 | wl1271_warning("Setting of tid config failed: %d", ret); |
| 890 | goto out; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | out: |
| 894 | kfree(acx); |
| 895 | return ret; |
| 896 | } |
| 897 | |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 898 | int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 899 | { |
| 900 | struct acx_frag_threshold *acx; |
| 901 | int ret = 0; |
| 902 | |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 903 | /* |
| 904 | * If the fragmentation is not configured or out of range, use the |
| 905 | * default value. |
| 906 | */ |
| 907 | if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD) |
| 908 | frag_threshold = wl->conf.tx.frag_threshold; |
| 909 | |
| 910 | wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 911 | |
| 912 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 913 | |
| 914 | if (!acx) { |
| 915 | ret = -ENOMEM; |
| 916 | goto out; |
| 917 | } |
| 918 | |
Arik Nemtsov | 5f704d1 | 2011-04-18 14:15:21 +0300 | [diff] [blame] | 919 | acx->frag_threshold = cpu_to_le16((u16)frag_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 920 | ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx)); |
| 921 | if (ret < 0) { |
| 922 | wl1271_warning("Setting of frag threshold failed: %d", ret); |
| 923 | goto out; |
| 924 | } |
| 925 | |
| 926 | out: |
| 927 | kfree(acx); |
| 928 | return ret; |
| 929 | } |
| 930 | |
| 931 | int wl1271_acx_tx_config_options(struct wl1271 *wl) |
| 932 | { |
| 933 | struct acx_tx_config_options *acx; |
| 934 | int ret = 0; |
| 935 | |
| 936 | wl1271_debug(DEBUG_ACX, "acx tx config options"); |
| 937 | |
| 938 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 939 | |
| 940 | if (!acx) { |
| 941 | ret = -ENOMEM; |
| 942 | goto out; |
| 943 | } |
| 944 | |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 945 | acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout); |
| 946 | acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 947 | ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx)); |
| 948 | if (ret < 0) { |
| 949 | wl1271_warning("Setting of tx options failed: %d", ret); |
| 950 | goto out; |
| 951 | } |
| 952 | |
| 953 | out: |
| 954 | kfree(acx); |
| 955 | return ret; |
| 956 | } |
| 957 | |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 958 | int wl12xx_acx_mem_cfg(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 959 | { |
Eliad Peller | 7f097988 | 2011-08-14 13:17:06 +0300 | [diff] [blame] | 960 | struct wl12xx_acx_config_memory *mem_conf; |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 961 | struct conf_memory_settings *mem; |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 962 | int ret; |
| 963 | |
| 964 | wl1271_debug(DEBUG_ACX, "wl1271 mem cfg"); |
| 965 | |
| 966 | mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL); |
| 967 | if (!mem_conf) { |
| 968 | ret = -ENOMEM; |
| 969 | goto out; |
| 970 | } |
| 971 | |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 972 | if (wl->chip.id == CHIP_ID_1283_PG20) |
| 973 | mem = &wl->conf.mem_wl128x; |
| 974 | else |
| 975 | mem = &wl->conf.mem_wl127x; |
| 976 | |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 977 | /* memory config */ |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 978 | mem_conf->num_stations = mem->num_stations; |
| 979 | mem_conf->rx_mem_block_num = mem->rx_block_num; |
| 980 | mem_conf->tx_min_mem_block_num = mem->tx_min_block_num; |
| 981 | mem_conf->num_ssid_profiles = mem->ssid_profiles; |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 982 | mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS); |
Shahar Levi | 13b107d | 2011-03-06 16:32:12 +0200 | [diff] [blame] | 983 | mem_conf->dyn_mem_enable = mem->dynamic_memory; |
| 984 | mem_conf->tx_free_req = mem->min_req_tx_blocks; |
| 985 | mem_conf->rx_free_req = mem->min_req_rx_blocks; |
| 986 | mem_conf->tx_min = mem->tx_min; |
Ido Yariv | 95dac04f | 2011-06-06 14:57:06 +0300 | [diff] [blame] | 987 | mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks; |
Eliad Peller | c8bde24 | 2011-02-02 09:59:35 +0200 | [diff] [blame] | 988 | |
| 989 | ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf, |
| 990 | sizeof(*mem_conf)); |
| 991 | if (ret < 0) { |
| 992 | wl1271_warning("wl1271 mem config failed: %d", ret); |
| 993 | goto out; |
| 994 | } |
| 995 | |
| 996 | out: |
| 997 | kfree(mem_conf); |
| 998 | return ret; |
| 999 | } |
| 1000 | |
Shahar Levi | 48a6147 | 2011-03-06 16:32:08 +0200 | [diff] [blame] | 1001 | int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap) |
| 1002 | { |
| 1003 | struct wl1271_acx_host_config_bitmap *bitmap_conf; |
| 1004 | int ret; |
| 1005 | |
| 1006 | bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL); |
| 1007 | if (!bitmap_conf) { |
| 1008 | ret = -ENOMEM; |
| 1009 | goto out; |
| 1010 | } |
| 1011 | |
| 1012 | bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap); |
| 1013 | |
| 1014 | ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP, |
| 1015 | bitmap_conf, sizeof(*bitmap_conf)); |
| 1016 | if (ret < 0) { |
| 1017 | wl1271_warning("wl1271 bitmap config opt failed: %d", ret); |
| 1018 | goto out; |
| 1019 | } |
| 1020 | |
| 1021 | out: |
| 1022 | kfree(bitmap_conf); |
| 1023 | |
| 1024 | return ret; |
| 1025 | } |
| 1026 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1027 | int wl1271_acx_init_mem_config(struct wl1271 *wl) |
| 1028 | { |
| 1029 | int ret; |
| 1030 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1031 | wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map), |
Juuso Oikarinen | 45b531a | 2009-10-13 12:47:41 +0300 | [diff] [blame] | 1032 | GFP_KERNEL); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1033 | if (!wl->target_mem_map) { |
| 1034 | wl1271_error("couldn't allocate target memory map"); |
| 1035 | return -ENOMEM; |
| 1036 | } |
| 1037 | |
| 1038 | /* we now ask for the firmware built memory map */ |
| 1039 | ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map, |
| 1040 | sizeof(struct wl1271_acx_mem_map)); |
| 1041 | if (ret < 0) { |
| 1042 | wl1271_error("couldn't retrieve firmware memory map"); |
| 1043 | kfree(wl->target_mem_map); |
| 1044 | wl->target_mem_map = NULL; |
| 1045 | return ret; |
| 1046 | } |
| 1047 | |
| 1048 | /* initialize TX block book keeping */ |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 1049 | wl->tx_blocks_available = |
| 1050 | le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1051 | wl1271_debug(DEBUG_TX, "available tx blocks: %d", |
| 1052 | wl->tx_blocks_available); |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | int wl1271_acx_init_rx_interrupt(struct wl1271 *wl) |
| 1058 | { |
| 1059 | struct wl1271_acx_rx_config_opt *rx_conf; |
| 1060 | int ret; |
| 1061 | |
| 1062 | wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config"); |
| 1063 | |
| 1064 | rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL); |
| 1065 | if (!rx_conf) { |
| 1066 | ret = -ENOMEM; |
| 1067 | goto out; |
| 1068 | } |
| 1069 | |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 1070 | rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold); |
| 1071 | rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout); |
| 1072 | rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold); |
Juuso Oikarinen | 8793f9b | 2009-10-13 12:47:40 +0300 | [diff] [blame] | 1073 | rx_conf->queue_type = wl->conf.rx.queue_type; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1074 | |
| 1075 | ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf, |
| 1076 | sizeof(*rx_conf)); |
| 1077 | if (ret < 0) { |
| 1078 | wl1271_warning("wl1271 rx config opt failed: %d", ret); |
| 1079 | goto out; |
| 1080 | } |
| 1081 | |
| 1082 | out: |
| 1083 | kfree(rx_conf); |
| 1084 | return ret; |
| 1085 | } |
Juuso Oikarinen | 3cfd6cf | 2009-10-12 15:08:52 +0300 | [diff] [blame] | 1086 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1087 | int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1088 | bool enable) |
Juuso Oikarinen | 11f70f9 | 2009-10-13 12:47:46 +0300 | [diff] [blame] | 1089 | { |
| 1090 | struct wl1271_acx_bet_enable *acx = NULL; |
| 1091 | int ret = 0; |
| 1092 | |
| 1093 | wl1271_debug(DEBUG_ACX, "acx bet enable"); |
| 1094 | |
| 1095 | if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE) |
| 1096 | goto out; |
| 1097 | |
| 1098 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1099 | if (!acx) { |
| 1100 | ret = -ENOMEM; |
| 1101 | goto out; |
| 1102 | } |
| 1103 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1104 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | 11f70f9 | 2009-10-13 12:47:46 +0300 | [diff] [blame] | 1105 | acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE; |
| 1106 | acx->max_consecutive = wl->conf.conn.bet_max_consecutive; |
| 1107 | |
| 1108 | ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx)); |
| 1109 | if (ret < 0) { |
| 1110 | wl1271_warning("acx bet enable failed: %d", ret); |
| 1111 | goto out; |
| 1112 | } |
| 1113 | |
| 1114 | out: |
| 1115 | kfree(acx); |
| 1116 | return ret; |
| 1117 | } |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 1118 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1119 | int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1120 | u8 enable, __be32 address) |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 1121 | { |
| 1122 | struct wl1271_acx_arp_filter *acx; |
| 1123 | int ret; |
| 1124 | |
Juuso Oikarinen | ca52a5e | 2010-07-08 17:50:02 +0300 | [diff] [blame] | 1125 | wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable); |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 1126 | |
| 1127 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1128 | if (!acx) { |
| 1129 | ret = -ENOMEM; |
| 1130 | goto out; |
| 1131 | } |
| 1132 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1133 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | eb887df | 2010-07-08 17:49:58 +0300 | [diff] [blame] | 1134 | acx->version = ACX_IPV4_VERSION; |
Juuso Oikarinen | ca52a5e | 2010-07-08 17:50:02 +0300 | [diff] [blame] | 1135 | acx->enable = enable; |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 1136 | |
Eliad Peller | c531277 | 2010-12-09 11:31:27 +0200 | [diff] [blame] | 1137 | if (enable) |
Juuso Oikarinen | ca52a5e | 2010-07-08 17:50:02 +0300 | [diff] [blame] | 1138 | memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE); |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 1139 | |
| 1140 | ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER, |
| 1141 | acx, sizeof(*acx)); |
| 1142 | if (ret < 0) { |
| 1143 | wl1271_warning("failed to set arp ip filter: %d", ret); |
| 1144 | goto out; |
| 1145 | } |
| 1146 | |
| 1147 | out: |
| 1148 | kfree(acx); |
| 1149 | return ret; |
| 1150 | } |
Juuso Oikarinen | 38ad2d8 | 2009-12-11 15:41:08 +0200 | [diff] [blame] | 1151 | |
| 1152 | int wl1271_acx_pm_config(struct wl1271 *wl) |
| 1153 | { |
| 1154 | struct wl1271_acx_pm_config *acx = NULL; |
| 1155 | struct conf_pm_config_settings *c = &wl->conf.pm_config; |
| 1156 | int ret = 0; |
| 1157 | |
| 1158 | wl1271_debug(DEBUG_ACX, "acx pm config"); |
| 1159 | |
| 1160 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1161 | if (!acx) { |
| 1162 | ret = -ENOMEM; |
| 1163 | goto out; |
| 1164 | } |
| 1165 | |
| 1166 | acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time); |
| 1167 | acx->host_fast_wakeup_support = c->host_fast_wakeup_support; |
| 1168 | |
| 1169 | ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx)); |
| 1170 | if (ret < 0) { |
| 1171 | wl1271_warning("acx pm config failed: %d", ret); |
| 1172 | goto out; |
| 1173 | } |
| 1174 | |
| 1175 | out: |
| 1176 | kfree(acx); |
| 1177 | return ret; |
| 1178 | } |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 1179 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1180 | int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1181 | bool enable) |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 1182 | { |
| 1183 | struct wl1271_acx_keep_alive_mode *acx = NULL; |
| 1184 | int ret = 0; |
| 1185 | |
| 1186 | wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable); |
| 1187 | |
| 1188 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1189 | if (!acx) { |
| 1190 | ret = -ENOMEM; |
| 1191 | goto out; |
| 1192 | } |
| 1193 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1194 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 1195 | acx->enabled = enable; |
| 1196 | |
| 1197 | ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx)); |
| 1198 | if (ret < 0) { |
| 1199 | wl1271_warning("acx keep alive mode failed: %d", ret); |
| 1200 | goto out; |
| 1201 | } |
| 1202 | |
| 1203 | out: |
| 1204 | kfree(acx); |
| 1205 | return ret; |
| 1206 | } |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1207 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1208 | int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1209 | u8 index, u8 tpl_valid) |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 1210 | { |
| 1211 | struct wl1271_acx_keep_alive_config *acx = NULL; |
| 1212 | int ret = 0; |
| 1213 | |
| 1214 | wl1271_debug(DEBUG_ACX, "acx keep alive config"); |
| 1215 | |
| 1216 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1217 | if (!acx) { |
| 1218 | ret = -ENOMEM; |
| 1219 | goto out; |
| 1220 | } |
| 1221 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1222 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | c189955 | 2010-03-26 12:53:32 +0200 | [diff] [blame] | 1223 | acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval); |
| 1224 | acx->index = index; |
| 1225 | acx->tpl_validation = tpl_valid; |
| 1226 | acx->trigger = ACX_KEEP_ALIVE_NO_TX; |
| 1227 | |
| 1228 | ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG, |
| 1229 | acx, sizeof(*acx)); |
| 1230 | if (ret < 0) { |
| 1231 | wl1271_warning("acx keep alive config failed: %d", ret); |
| 1232 | goto out; |
| 1233 | } |
| 1234 | |
| 1235 | out: |
| 1236 | kfree(acx); |
| 1237 | return ret; |
| 1238 | } |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1239 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1240 | int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1241 | bool enable, s16 thold, u8 hyst) |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1242 | { |
| 1243 | struct wl1271_acx_rssi_snr_trigger *acx = NULL; |
| 1244 | int ret = 0; |
| 1245 | |
| 1246 | wl1271_debug(DEBUG_ACX, "acx rssi snr trigger"); |
| 1247 | |
| 1248 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1249 | if (!acx) { |
| 1250 | ret = -ENOMEM; |
| 1251 | goto out; |
| 1252 | } |
| 1253 | |
Eliad Peller | 04324d9 | 2011-10-05 11:56:03 +0200 | [diff] [blame] | 1254 | wlvif->last_rssi_event = -1; |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1255 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1256 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1257 | acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing); |
| 1258 | acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON; |
| 1259 | acx->type = WL1271_ACX_TRIG_TYPE_EDGE; |
| 1260 | if (enable) |
| 1261 | acx->enable = WL1271_ACX_TRIG_ENABLE; |
| 1262 | else |
| 1263 | acx->enable = WL1271_ACX_TRIG_DISABLE; |
| 1264 | |
| 1265 | acx->index = WL1271_ACX_TRIG_IDX_RSSI; |
| 1266 | acx->dir = WL1271_ACX_TRIG_DIR_BIDIR; |
| 1267 | acx->threshold = cpu_to_le16(thold); |
| 1268 | acx->hysteresis = hyst; |
| 1269 | |
| 1270 | ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx)); |
| 1271 | if (ret < 0) { |
| 1272 | wl1271_warning("acx rssi snr trigger setting failed: %d", ret); |
| 1273 | goto out; |
| 1274 | } |
| 1275 | |
| 1276 | out: |
| 1277 | kfree(acx); |
| 1278 | return ret; |
| 1279 | } |
| 1280 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1281 | int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl, |
| 1282 | struct wl12xx_vif *wlvif) |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1283 | { |
| 1284 | struct wl1271_acx_rssi_snr_avg_weights *acx = NULL; |
| 1285 | struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger; |
| 1286 | int ret = 0; |
| 1287 | |
| 1288 | wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights"); |
| 1289 | |
| 1290 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1291 | if (!acx) { |
| 1292 | ret = -ENOMEM; |
| 1293 | goto out; |
| 1294 | } |
| 1295 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1296 | acx->role_id = wlvif->role_id; |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 1297 | acx->rssi_beacon = c->avg_weight_rssi_beacon; |
| 1298 | acx->rssi_data = c->avg_weight_rssi_data; |
| 1299 | acx->snr_beacon = c->avg_weight_snr_beacon; |
| 1300 | acx->snr_data = c->avg_weight_snr_data; |
| 1301 | |
| 1302 | ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx)); |
| 1303 | if (ret < 0) { |
| 1304 | wl1271_warning("acx rssi snr trigger weights failed: %d", ret); |
| 1305 | goto out; |
| 1306 | } |
| 1307 | |
| 1308 | out: |
| 1309 | kfree(acx); |
| 1310 | return ret; |
| 1311 | } |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 1312 | |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1313 | int wl1271_acx_set_ht_capabilities(struct wl1271 *wl, |
| 1314 | struct ieee80211_sta_ht_cap *ht_cap, |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 1315 | bool allow_ht_operation, u8 hlid) |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1316 | { |
| 1317 | struct wl1271_acx_ht_capabilities *acx; |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1318 | int ret = 0; |
Eliad Peller | 6177eae | 2010-12-22 12:38:52 +0100 | [diff] [blame] | 1319 | u32 ht_capabilites = 0; |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1320 | |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 1321 | wl1271_debug(DEBUG_ACX, "acx ht capabilities setting " |
| 1322 | "sta supp: %d sta cap: %d", ht_cap->ht_supported, |
| 1323 | ht_cap->cap); |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1324 | |
| 1325 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1326 | if (!acx) { |
| 1327 | ret = -ENOMEM; |
| 1328 | goto out; |
| 1329 | } |
| 1330 | |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 1331 | if (allow_ht_operation && ht_cap->ht_supported) { |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1332 | /* no need to translate capabilities - use the spec values */ |
| 1333 | ht_capabilites = ht_cap->cap; |
| 1334 | |
| 1335 | /* |
| 1336 | * this bit is not employed by the spec but only by FW to |
| 1337 | * indicate peer HT support |
| 1338 | */ |
| 1339 | ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION; |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1340 | |
| 1341 | /* get data from A-MPDU parameters field */ |
| 1342 | acx->ampdu_max_length = ht_cap->ampdu_factor; |
| 1343 | acx->ampdu_min_spacing = ht_cap->ampdu_density; |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1344 | } |
| 1345 | |
Arik Nemtsov | 0b932ab | 2011-08-14 13:17:27 +0300 | [diff] [blame] | 1346 | acx->hlid = hlid; |
Eliad Peller | 6177eae | 2010-12-22 12:38:52 +0100 | [diff] [blame] | 1347 | acx->ht_capabilites = cpu_to_le32(ht_capabilites); |
| 1348 | |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1349 | ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx)); |
| 1350 | if (ret < 0) { |
| 1351 | wl1271_warning("acx ht capabilities setting failed: %d", ret); |
| 1352 | goto out; |
| 1353 | } |
| 1354 | |
| 1355 | out: |
| 1356 | kfree(acx); |
| 1357 | return ret; |
| 1358 | } |
| 1359 | |
| 1360 | int wl1271_acx_set_ht_information(struct wl1271 *wl, |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1361 | struct wl12xx_vif *wlvif, |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1362 | u16 ht_operation_mode) |
| 1363 | { |
| 1364 | struct wl1271_acx_ht_information *acx; |
| 1365 | int ret = 0; |
| 1366 | |
| 1367 | wl1271_debug(DEBUG_ACX, "acx ht information setting"); |
| 1368 | |
| 1369 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1370 | if (!acx) { |
| 1371 | ret = -ENOMEM; |
| 1372 | goto out; |
| 1373 | } |
| 1374 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1375 | acx->role_id = wlvif->role_id; |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1376 | acx->ht_protection = |
| 1377 | (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION); |
| 1378 | acx->rifs_mode = 0; |
Helmut Schaa | 95a7761 | 2011-03-02 10:46:46 +0100 | [diff] [blame] | 1379 | acx->gf_protection = |
| 1380 | !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); |
Shahar Levi | c4db1c8 | 2010-10-13 16:09:40 +0200 | [diff] [blame] | 1381 | acx->ht_tx_burst_limit = 0; |
| 1382 | acx->dual_cts_protection = 0; |
| 1383 | |
| 1384 | ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx)); |
| 1385 | |
| 1386 | if (ret < 0) { |
| 1387 | wl1271_warning("acx ht information setting failed: %d", ret); |
| 1388 | goto out; |
| 1389 | } |
| 1390 | |
| 1391 | out: |
| 1392 | kfree(acx); |
| 1393 | return ret; |
| 1394 | } |
| 1395 | |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1396 | /* Configure BA session initiator/receiver parameters setting in the FW. */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1397 | int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, |
| 1398 | struct wl12xx_vif *wlvif) |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1399 | { |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1400 | struct wl1271_acx_ba_initiator_policy *acx; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1401 | int ret; |
| 1402 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1403 | wl1271_debug(DEBUG_ACX, "acx ba initiator policy"); |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1404 | |
| 1405 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1406 | if (!acx) { |
| 1407 | ret = -ENOMEM; |
| 1408 | goto out; |
| 1409 | } |
| 1410 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1411 | /* set for the current role */ |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1412 | acx->role_id = wlvif->role_id; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1413 | acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap; |
| 1414 | acx->win_size = wl->conf.ht.tx_ba_win_size; |
| 1415 | acx->inactivity_timeout = wl->conf.ht.inactivity_timeout; |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1416 | |
| 1417 | ret = wl1271_cmd_configure(wl, |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1418 | ACX_BA_SESSION_INIT_POLICY, |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1419 | acx, |
| 1420 | sizeof(*acx)); |
| 1421 | if (ret < 0) { |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1422 | wl1271_warning("acx ba initiator policy failed: %d", ret); |
Levi, Shahar | 4b7fac7 | 2011-01-23 07:27:22 +0100 | [diff] [blame] | 1423 | goto out; |
| 1424 | } |
| 1425 | |
| 1426 | out: |
| 1427 | kfree(acx); |
| 1428 | return ret; |
| 1429 | } |
| 1430 | |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 1431 | /* setup BA session receiver setting in the FW. */ |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1432 | int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, |
| 1433 | u16 ssn, bool enable, u8 peer_hlid) |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 1434 | { |
| 1435 | struct wl1271_acx_ba_receiver_setup *acx; |
| 1436 | int ret; |
| 1437 | |
| 1438 | wl1271_debug(DEBUG_ACX, "acx ba receiver session setting"); |
| 1439 | |
| 1440 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1441 | if (!acx) { |
| 1442 | ret = -ENOMEM; |
| 1443 | goto out; |
| 1444 | } |
| 1445 | |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1446 | acx->hlid = peer_hlid; |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 1447 | acx->tid = tid_index; |
| 1448 | acx->enable = enable; |
Arik Nemtsov | 0f9c825 | 2011-08-17 10:45:49 +0300 | [diff] [blame] | 1449 | acx->win_size = wl->conf.ht.rx_ba_win_size; |
Levi, Shahar | bbba3e6 | 2011-01-23 07:27:23 +0100 | [diff] [blame] | 1450 | acx->ssn = ssn; |
| 1451 | |
| 1452 | ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx, |
| 1453 | sizeof(*acx)); |
| 1454 | if (ret < 0) { |
| 1455 | wl1271_warning("acx ba receiver session failed: %d", ret); |
| 1456 | goto out; |
| 1457 | } |
| 1458 | |
| 1459 | out: |
| 1460 | kfree(acx); |
| 1461 | return ret; |
| 1462 | } |
| 1463 | |
Eliad Peller | 9c53114 | 2012-01-31 11:57:18 +0200 | [diff] [blame] | 1464 | int wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1465 | u64 *mactime) |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 1466 | { |
Eliad Peller | 9c53114 | 2012-01-31 11:57:18 +0200 | [diff] [blame] | 1467 | struct wl12xx_acx_fw_tsf_information *tsf_info; |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 1468 | int ret; |
| 1469 | |
| 1470 | tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL); |
| 1471 | if (!tsf_info) { |
| 1472 | ret = -ENOMEM; |
| 1473 | goto out; |
| 1474 | } |
| 1475 | |
Eliad Peller | 9c53114 | 2012-01-31 11:57:18 +0200 | [diff] [blame] | 1476 | tsf_info->role_id = wlvif->role_id; |
| 1477 | |
Juuso Oikarinen | bbbb538 | 2010-07-08 17:49:57 +0300 | [diff] [blame] | 1478 | ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO, |
| 1479 | tsf_info, sizeof(*tsf_info)); |
| 1480 | if (ret < 0) { |
| 1481 | wl1271_warning("acx tsf info interrogate failed"); |
| 1482 | goto out; |
| 1483 | } |
| 1484 | |
| 1485 | *mactime = le32_to_cpu(tsf_info->current_tsf_low) | |
| 1486 | ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32); |
| 1487 | |
| 1488 | out: |
| 1489 | kfree(tsf_info); |
| 1490 | return ret; |
| 1491 | } |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 1492 | |
Eliad Peller | 9eb599e | 2011-10-10 10:12:59 +0200 | [diff] [blame] | 1493 | int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 1494 | bool enable) |
Eliad Peller | f84673d | 2011-05-15 11:10:28 +0300 | [diff] [blame] | 1495 | { |
| 1496 | struct wl1271_acx_ps_rx_streaming *rx_streaming; |
| 1497 | u32 conf_queues, enable_queues; |
| 1498 | int i, ret = 0; |
| 1499 | |
| 1500 | wl1271_debug(DEBUG_ACX, "acx ps rx streaming"); |
| 1501 | |
| 1502 | rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL); |
| 1503 | if (!rx_streaming) { |
| 1504 | ret = -ENOMEM; |
| 1505 | goto out; |
| 1506 | } |
| 1507 | |
| 1508 | conf_queues = wl->conf.rx_streaming.queues; |
| 1509 | if (enable) |
| 1510 | enable_queues = conf_queues; |
| 1511 | else |
| 1512 | enable_queues = 0; |
| 1513 | |
| 1514 | for (i = 0; i < 8; i++) { |
| 1515 | /* |
| 1516 | * Skip non-changed queues, to avoid redundant acxs. |
| 1517 | * this check assumes conf.rx_streaming.queues can't |
| 1518 | * be changed while rx_streaming is enabled. |
| 1519 | */ |
| 1520 | if (!(conf_queues & BIT(i))) |
| 1521 | continue; |
| 1522 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1523 | rx_streaming->role_id = wlvif->role_id; |
Eliad Peller | f84673d | 2011-05-15 11:10:28 +0300 | [diff] [blame] | 1524 | rx_streaming->tid = i; |
| 1525 | rx_streaming->enable = enable_queues & BIT(i); |
| 1526 | rx_streaming->period = wl->conf.rx_streaming.interval; |
| 1527 | rx_streaming->timeout = wl->conf.rx_streaming.interval; |
| 1528 | |
| 1529 | ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING, |
| 1530 | rx_streaming, |
| 1531 | sizeof(*rx_streaming)); |
| 1532 | if (ret < 0) { |
| 1533 | wl1271_warning("acx ps rx streaming failed: %d", ret); |
| 1534 | goto out; |
| 1535 | } |
| 1536 | } |
| 1537 | out: |
| 1538 | kfree(rx_streaming); |
| 1539 | return ret; |
| 1540 | } |
| 1541 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1542 | int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 1543 | { |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame] | 1544 | struct wl1271_acx_ap_max_tx_retry *acx = NULL; |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 1545 | int ret; |
| 1546 | |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame] | 1547 | wl1271_debug(DEBUG_ACX, "acx ap max tx retry"); |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 1548 | |
| 1549 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1550 | if (!acx) |
| 1551 | return -ENOMEM; |
| 1552 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 1553 | acx->role_id = wlvif->role_id; |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame] | 1554 | acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries); |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 1555 | |
| 1556 | ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx)); |
| 1557 | if (ret < 0) { |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame] | 1558 | wl1271_warning("acx ap max tx retry failed: %d", ret); |
Arik Nemtsov | 79b223f | 2010-10-16 17:52:59 +0200 | [diff] [blame] | 1559 | goto out; |
| 1560 | } |
| 1561 | |
| 1562 | out: |
| 1563 | kfree(acx); |
| 1564 | return ret; |
| 1565 | } |
Eliad Peller | ee60833 | 2011-02-02 09:59:34 +0200 | [diff] [blame] | 1566 | |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 1567 | int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
Eliad Peller | ee60833 | 2011-02-02 09:59:34 +0200 | [diff] [blame] | 1568 | { |
| 1569 | struct wl1271_acx_config_ps *config_ps; |
| 1570 | int ret; |
| 1571 | |
| 1572 | wl1271_debug(DEBUG_ACX, "acx config ps"); |
| 1573 | |
| 1574 | config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL); |
| 1575 | if (!config_ps) { |
| 1576 | ret = -ENOMEM; |
| 1577 | goto out; |
| 1578 | } |
| 1579 | |
| 1580 | config_ps->exit_retries = wl->conf.conn.psm_exit_retries; |
| 1581 | config_ps->enter_retries = wl->conf.conn.psm_entry_retries; |
Eliad Peller | d2d66c5 | 2011-10-05 11:55:43 +0200 | [diff] [blame] | 1582 | config_ps->null_data_rate = cpu_to_le32(wlvif->basic_rate); |
Eliad Peller | ee60833 | 2011-02-02 09:59:34 +0200 | [diff] [blame] | 1583 | |
| 1584 | ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps, |
| 1585 | sizeof(*config_ps)); |
| 1586 | |
| 1587 | if (ret < 0) { |
| 1588 | wl1271_warning("acx config ps failed: %d", ret); |
| 1589 | goto out; |
| 1590 | } |
| 1591 | |
| 1592 | out: |
| 1593 | kfree(config_ps); |
| 1594 | return ret; |
| 1595 | } |
Arik Nemtsov | 99a2775 | 2011-02-23 00:22:25 +0200 | [diff] [blame] | 1596 | |
| 1597 | int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr) |
| 1598 | { |
| 1599 | struct wl1271_acx_inconnection_sta *acx = NULL; |
| 1600 | int ret; |
| 1601 | |
| 1602 | wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr); |
| 1603 | |
| 1604 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1605 | if (!acx) |
| 1606 | return -ENOMEM; |
| 1607 | |
| 1608 | memcpy(acx->addr, addr, ETH_ALEN); |
| 1609 | |
| 1610 | ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST, |
| 1611 | acx, sizeof(*acx)); |
| 1612 | if (ret < 0) { |
| 1613 | wl1271_warning("acx set inconnaction sta failed: %d", ret); |
| 1614 | goto out; |
| 1615 | } |
| 1616 | |
| 1617 | out: |
| 1618 | kfree(acx); |
| 1619 | return ret; |
| 1620 | } |
Shahar Levi | ff86843 | 2011-04-11 15:41:46 +0300 | [diff] [blame] | 1621 | |
| 1622 | int wl1271_acx_fm_coex(struct wl1271 *wl) |
| 1623 | { |
| 1624 | struct wl1271_acx_fm_coex *acx; |
| 1625 | int ret; |
| 1626 | |
| 1627 | wl1271_debug(DEBUG_ACX, "acx fm coex setting"); |
| 1628 | |
| 1629 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1630 | if (!acx) { |
| 1631 | ret = -ENOMEM; |
| 1632 | goto out; |
| 1633 | } |
| 1634 | |
| 1635 | acx->enable = wl->conf.fm_coex.enable; |
| 1636 | acx->swallow_period = wl->conf.fm_coex.swallow_period; |
| 1637 | acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1; |
| 1638 | acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2; |
| 1639 | acx->m_divider_fref_set_1 = |
| 1640 | cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1); |
| 1641 | acx->m_divider_fref_set_2 = |
| 1642 | cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2); |
| 1643 | acx->coex_pll_stabilization_time = |
| 1644 | cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time); |
| 1645 | acx->ldo_stabilization_time = |
| 1646 | cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time); |
| 1647 | acx->fm_disturbed_band_margin = |
| 1648 | wl->conf.fm_coex.fm_disturbed_band_margin; |
| 1649 | acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff; |
| 1650 | |
| 1651 | ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx)); |
| 1652 | if (ret < 0) { |
| 1653 | wl1271_warning("acx fm coex setting failed: %d", ret); |
| 1654 | goto out; |
| 1655 | } |
| 1656 | |
| 1657 | out: |
| 1658 | kfree(acx); |
| 1659 | return ret; |
| 1660 | } |
Eliad Peller | fa6ad9f | 2011-08-14 13:17:14 +0300 | [diff] [blame] | 1661 | |
| 1662 | int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl) |
| 1663 | { |
| 1664 | struct wl12xx_acx_set_rate_mgmt_params *acx = NULL; |
| 1665 | struct conf_rate_policy_settings *conf = &wl->conf.rate; |
| 1666 | int ret; |
| 1667 | |
| 1668 | wl1271_debug(DEBUG_ACX, "acx set rate mgmt params"); |
| 1669 | |
| 1670 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1671 | if (!acx) |
| 1672 | return -ENOMEM; |
| 1673 | |
| 1674 | acx->index = ACX_RATE_MGMT_ALL_PARAMS; |
| 1675 | acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score); |
| 1676 | acx->per_add = cpu_to_le16(conf->per_add); |
| 1677 | acx->per_th1 = cpu_to_le16(conf->per_th1); |
| 1678 | acx->per_th2 = cpu_to_le16(conf->per_th2); |
| 1679 | acx->max_per = cpu_to_le16(conf->max_per); |
| 1680 | acx->inverse_curiosity_factor = conf->inverse_curiosity_factor; |
| 1681 | acx->tx_fail_low_th = conf->tx_fail_low_th; |
| 1682 | acx->tx_fail_high_th = conf->tx_fail_high_th; |
| 1683 | acx->per_alpha_shift = conf->per_alpha_shift; |
| 1684 | acx->per_add_shift = conf->per_add_shift; |
| 1685 | acx->per_beta1_shift = conf->per_beta1_shift; |
| 1686 | acx->per_beta2_shift = conf->per_beta2_shift; |
| 1687 | acx->rate_check_up = conf->rate_check_up; |
| 1688 | acx->rate_check_down = conf->rate_check_down; |
| 1689 | memcpy(acx->rate_retry_policy, conf->rate_retry_policy, |
| 1690 | sizeof(acx->rate_retry_policy)); |
| 1691 | |
| 1692 | ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS, |
| 1693 | acx, sizeof(*acx)); |
| 1694 | if (ret < 0) { |
| 1695 | wl1271_warning("acx set rate mgmt params failed: %d", ret); |
| 1696 | goto out; |
| 1697 | } |
| 1698 | |
| 1699 | out: |
| 1700 | kfree(acx); |
| 1701 | return ret; |
| 1702 | } |
Eliad Peller | 9487775 | 2011-08-28 15:11:56 +0300 | [diff] [blame] | 1703 | |
| 1704 | int wl12xx_acx_config_hangover(struct wl1271 *wl) |
| 1705 | { |
| 1706 | struct wl12xx_acx_config_hangover *acx; |
| 1707 | struct conf_hangover_settings *conf = &wl->conf.hangover; |
| 1708 | int ret; |
| 1709 | |
| 1710 | wl1271_debug(DEBUG_ACX, "acx config hangover"); |
| 1711 | |
| 1712 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 1713 | if (!acx) { |
| 1714 | ret = -ENOMEM; |
| 1715 | goto out; |
| 1716 | } |
| 1717 | |
| 1718 | acx->recover_time = cpu_to_le32(conf->recover_time); |
| 1719 | acx->hangover_period = conf->hangover_period; |
| 1720 | acx->dynamic_mode = conf->dynamic_mode; |
| 1721 | acx->early_termination_mode = conf->early_termination_mode; |
| 1722 | acx->max_period = conf->max_period; |
| 1723 | acx->min_period = conf->min_period; |
| 1724 | acx->increase_delta = conf->increase_delta; |
| 1725 | acx->decrease_delta = conf->decrease_delta; |
| 1726 | acx->quiet_time = conf->quiet_time; |
| 1727 | acx->increase_time = conf->increase_time; |
| 1728 | acx->window_size = acx->window_size; |
| 1729 | |
| 1730 | ret = wl1271_cmd_configure(wl, ACX_CONFIG_HANGOVER, acx, |
| 1731 | sizeof(*acx)); |
| 1732 | |
| 1733 | if (ret < 0) { |
| 1734 | wl1271_warning("acx config hangover failed: %d", ret); |
| 1735 | goto out; |
| 1736 | } |
| 1737 | |
| 1738 | out: |
| 1739 | kfree(acx); |
| 1740 | return ret; |
| 1741 | |
| 1742 | } |