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