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