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