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