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 | |
| 24 | #include "wl1271_acx.h" |
| 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/crc7.h> |
| 29 | #include <linux/spi/spi.h> |
| 30 | |
| 31 | #include "wl1271.h" |
| 32 | #include "wl12xx_80211.h" |
| 33 | #include "wl1271_reg.h" |
| 34 | #include "wl1271_spi.h" |
| 35 | #include "wl1271_ps.h" |
| 36 | |
| 37 | int wl1271_acx_wake_up_conditions(struct wl1271 *wl, u8 wake_up_event, |
| 38 | u8 listen_interval) |
| 39 | { |
| 40 | struct acx_wake_up_condition *wake_up; |
| 41 | int ret; |
| 42 | |
| 43 | wl1271_debug(DEBUG_ACX, "acx wake up conditions"); |
| 44 | |
| 45 | wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL); |
| 46 | if (!wake_up) { |
| 47 | ret = -ENOMEM; |
| 48 | goto out; |
| 49 | } |
| 50 | |
| 51 | wake_up->wake_up_event = wake_up_event; |
| 52 | wake_up->listen_interval = listen_interval; |
| 53 | |
| 54 | ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS, |
| 55 | wake_up, sizeof(*wake_up)); |
| 56 | if (ret < 0) { |
| 57 | wl1271_warning("could not set wake up conditions: %d", ret); |
| 58 | goto out; |
| 59 | } |
| 60 | |
| 61 | out: |
| 62 | kfree(wake_up); |
| 63 | return ret; |
| 64 | } |
| 65 | |
| 66 | int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth) |
| 67 | { |
| 68 | struct acx_sleep_auth *auth; |
| 69 | int ret; |
| 70 | |
| 71 | wl1271_debug(DEBUG_ACX, "acx sleep auth"); |
| 72 | |
| 73 | auth = kzalloc(sizeof(*auth), GFP_KERNEL); |
| 74 | if (!auth) { |
| 75 | ret = -ENOMEM; |
| 76 | goto out; |
| 77 | } |
| 78 | |
| 79 | auth->sleep_auth = sleep_auth; |
| 80 | |
| 81 | ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth)); |
| 82 | if (ret < 0) |
| 83 | return ret; |
| 84 | |
| 85 | out: |
| 86 | kfree(auth); |
| 87 | return ret; |
| 88 | } |
| 89 | |
| 90 | int wl1271_acx_fw_version(struct wl1271 *wl, char *buf, size_t len) |
| 91 | { |
| 92 | struct acx_revision *rev; |
| 93 | int ret; |
| 94 | |
| 95 | wl1271_debug(DEBUG_ACX, "acx fw rev"); |
| 96 | |
| 97 | rev = kzalloc(sizeof(*rev), GFP_KERNEL); |
| 98 | if (!rev) { |
| 99 | ret = -ENOMEM; |
| 100 | goto out; |
| 101 | } |
| 102 | |
| 103 | ret = wl1271_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev)); |
| 104 | if (ret < 0) { |
| 105 | wl1271_warning("ACX_FW_REV interrogate failed"); |
| 106 | goto out; |
| 107 | } |
| 108 | |
| 109 | /* be careful with the buffer sizes */ |
| 110 | strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); |
| 111 | |
| 112 | /* |
| 113 | * if the firmware version string is exactly |
| 114 | * sizeof(rev->fw_version) long or fw_len is less than |
| 115 | * sizeof(rev->fw_version) it won't be null terminated |
| 116 | */ |
| 117 | buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; |
| 118 | |
| 119 | out: |
| 120 | kfree(rev); |
| 121 | return ret; |
| 122 | } |
| 123 | |
| 124 | int wl1271_acx_tx_power(struct wl1271 *wl, int power) |
| 125 | { |
| 126 | struct acx_current_tx_power *acx; |
| 127 | int ret; |
| 128 | |
| 129 | wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr"); |
| 130 | |
| 131 | if (power < 0 || power > 25) |
| 132 | return -EINVAL; |
| 133 | |
| 134 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 135 | if (!acx) { |
| 136 | ret = -ENOMEM; |
| 137 | goto out; |
| 138 | } |
| 139 | |
| 140 | acx->current_tx_power = power * 10; |
| 141 | |
| 142 | ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); |
| 143 | if (ret < 0) { |
| 144 | wl1271_warning("configure of tx power failed: %d", ret); |
| 145 | goto out; |
| 146 | } |
| 147 | |
| 148 | out: |
| 149 | kfree(acx); |
| 150 | return ret; |
| 151 | } |
| 152 | |
| 153 | int wl1271_acx_feature_cfg(struct wl1271 *wl) |
| 154 | { |
| 155 | struct acx_feature_config *feature; |
| 156 | int ret; |
| 157 | |
| 158 | wl1271_debug(DEBUG_ACX, "acx feature cfg"); |
| 159 | |
| 160 | feature = kzalloc(sizeof(*feature), GFP_KERNEL); |
| 161 | if (!feature) { |
| 162 | ret = -ENOMEM; |
| 163 | goto out; |
| 164 | } |
| 165 | |
| 166 | /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ |
| 167 | feature->data_flow_options = 0; |
| 168 | feature->options = 0; |
| 169 | |
| 170 | ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG, |
| 171 | feature, sizeof(*feature)); |
| 172 | if (ret < 0) { |
| 173 | wl1271_error("Couldnt set HW encryption"); |
| 174 | goto out; |
| 175 | } |
| 176 | |
| 177 | out: |
| 178 | kfree(feature); |
| 179 | return ret; |
| 180 | } |
| 181 | |
| 182 | int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map, |
| 183 | size_t len) |
| 184 | { |
| 185 | int ret; |
| 186 | |
| 187 | wl1271_debug(DEBUG_ACX, "acx mem map"); |
| 188 | |
| 189 | ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); |
| 190 | if (ret < 0) |
| 191 | return ret; |
| 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl, u32 life_time) |
| 197 | { |
| 198 | struct acx_rx_msdu_lifetime *acx; |
| 199 | int ret; |
| 200 | |
| 201 | wl1271_debug(DEBUG_ACX, "acx rx msdu life time"); |
| 202 | |
| 203 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 204 | if (!acx) { |
| 205 | ret = -ENOMEM; |
| 206 | goto out; |
| 207 | } |
| 208 | |
| 209 | acx->lifetime = life_time; |
| 210 | ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME, |
| 211 | acx, sizeof(*acx)); |
| 212 | if (ret < 0) { |
| 213 | wl1271_warning("failed to set rx msdu life time: %d", ret); |
| 214 | goto out; |
| 215 | } |
| 216 | |
| 217 | out: |
| 218 | kfree(acx); |
| 219 | return ret; |
| 220 | } |
| 221 | |
| 222 | int wl1271_acx_rx_config(struct wl1271 *wl, u32 config, u32 filter) |
| 223 | { |
| 224 | struct acx_rx_config *rx_config; |
| 225 | int ret; |
| 226 | |
| 227 | wl1271_debug(DEBUG_ACX, "acx rx config"); |
| 228 | |
| 229 | rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL); |
| 230 | if (!rx_config) { |
| 231 | ret = -ENOMEM; |
| 232 | goto out; |
| 233 | } |
| 234 | |
| 235 | rx_config->config_options = config; |
| 236 | rx_config->filter_options = filter; |
| 237 | |
| 238 | ret = wl1271_cmd_configure(wl, ACX_RX_CFG, |
| 239 | rx_config, sizeof(*rx_config)); |
| 240 | if (ret < 0) { |
| 241 | wl1271_warning("failed to set rx config: %d", ret); |
| 242 | goto out; |
| 243 | } |
| 244 | |
| 245 | out: |
| 246 | kfree(rx_config); |
| 247 | return ret; |
| 248 | } |
| 249 | |
| 250 | int wl1271_acx_pd_threshold(struct wl1271 *wl) |
| 251 | { |
| 252 | struct acx_packet_detection *pd; |
| 253 | int ret; |
| 254 | |
| 255 | wl1271_debug(DEBUG_ACX, "acx data pd threshold"); |
| 256 | |
| 257 | pd = kzalloc(sizeof(*pd), GFP_KERNEL); |
| 258 | if (!pd) { |
| 259 | ret = -ENOMEM; |
| 260 | goto out; |
| 261 | } |
| 262 | |
| 263 | /* FIXME: threshold value not set */ |
| 264 | |
| 265 | ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd)); |
| 266 | if (ret < 0) { |
| 267 | wl1271_warning("failed to set pd threshold: %d", ret); |
| 268 | goto out; |
| 269 | } |
| 270 | |
| 271 | out: |
| 272 | kfree(pd); |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time) |
| 277 | { |
| 278 | struct acx_slot *slot; |
| 279 | int ret; |
| 280 | |
| 281 | wl1271_debug(DEBUG_ACX, "acx slot"); |
| 282 | |
| 283 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
| 284 | if (!slot) { |
| 285 | ret = -ENOMEM; |
| 286 | goto out; |
| 287 | } |
| 288 | |
| 289 | slot->wone_index = STATION_WONE_INDEX; |
| 290 | slot->slot_time = slot_time; |
| 291 | |
| 292 | ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot)); |
| 293 | if (ret < 0) { |
| 294 | wl1271_warning("failed to set slot time: %d", ret); |
| 295 | goto out; |
| 296 | } |
| 297 | |
| 298 | out: |
| 299 | kfree(slot); |
| 300 | return ret; |
| 301 | } |
| 302 | |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 303 | int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, |
| 304 | void *mc_list, u32 mc_list_len) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 305 | { |
| 306 | struct acx_dot11_grp_addr_tbl *acx; |
| 307 | int ret; |
| 308 | |
| 309 | wl1271_debug(DEBUG_ACX, "acx group address tbl"); |
| 310 | |
| 311 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 312 | if (!acx) { |
| 313 | ret = -ENOMEM; |
| 314 | goto out; |
| 315 | } |
| 316 | |
| 317 | /* MAC filtering */ |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 318 | acx->enabled = enable; |
| 319 | acx->num_groups = mc_list_len; |
| 320 | memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 321 | |
| 322 | ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL, |
| 323 | acx, sizeof(*acx)); |
| 324 | if (ret < 0) { |
| 325 | wl1271_warning("failed to set group addr table: %d", ret); |
| 326 | goto out; |
| 327 | } |
| 328 | |
| 329 | out: |
| 330 | kfree(acx); |
| 331 | return ret; |
| 332 | } |
| 333 | |
| 334 | int wl1271_acx_service_period_timeout(struct wl1271 *wl) |
| 335 | { |
| 336 | struct acx_rx_timeout *rx_timeout; |
| 337 | int ret; |
| 338 | |
| 339 | rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL); |
| 340 | if (!rx_timeout) { |
| 341 | ret = -ENOMEM; |
| 342 | goto out; |
| 343 | } |
| 344 | |
| 345 | wl1271_debug(DEBUG_ACX, "acx service period timeout"); |
| 346 | |
| 347 | rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF; |
| 348 | rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF; |
| 349 | |
| 350 | ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT, |
| 351 | rx_timeout, sizeof(*rx_timeout)); |
| 352 | if (ret < 0) { |
| 353 | wl1271_warning("failed to set service period timeout: %d", |
| 354 | ret); |
| 355 | goto out; |
| 356 | } |
| 357 | |
| 358 | out: |
| 359 | kfree(rx_timeout); |
| 360 | return ret; |
| 361 | } |
| 362 | |
| 363 | int wl1271_acx_rts_threshold(struct wl1271 *wl, u16 rts_threshold) |
| 364 | { |
| 365 | struct acx_rts_threshold *rts; |
| 366 | int ret; |
| 367 | |
| 368 | wl1271_debug(DEBUG_ACX, "acx rts threshold"); |
| 369 | |
| 370 | rts = kzalloc(sizeof(*rts), GFP_KERNEL); |
| 371 | if (!rts) { |
| 372 | ret = -ENOMEM; |
| 373 | goto out; |
| 374 | } |
| 375 | |
| 376 | rts->threshold = rts_threshold; |
| 377 | |
| 378 | ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); |
| 379 | if (ret < 0) { |
| 380 | wl1271_warning("failed to set rts threshold: %d", ret); |
| 381 | goto out; |
| 382 | } |
| 383 | |
| 384 | out: |
| 385 | kfree(rts); |
| 386 | return ret; |
| 387 | } |
| 388 | |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 389 | int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 390 | { |
| 391 | struct acx_beacon_filter_option *beacon_filter; |
| 392 | int ret; |
| 393 | |
| 394 | wl1271_debug(DEBUG_ACX, "acx beacon filter opt"); |
| 395 | |
| 396 | beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL); |
| 397 | if (!beacon_filter) { |
| 398 | ret = -ENOMEM; |
| 399 | goto out; |
| 400 | } |
| 401 | |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 402 | beacon_filter->enable = enable_filter; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 403 | beacon_filter->max_num_beacons = 0; |
| 404 | |
| 405 | ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT, |
| 406 | beacon_filter, sizeof(*beacon_filter)); |
| 407 | if (ret < 0) { |
| 408 | wl1271_warning("failed to set beacon filter opt: %d", ret); |
| 409 | goto out; |
| 410 | } |
| 411 | |
| 412 | out: |
| 413 | kfree(beacon_filter); |
| 414 | return ret; |
| 415 | } |
| 416 | |
| 417 | int wl1271_acx_beacon_filter_table(struct wl1271 *wl) |
| 418 | { |
| 419 | struct acx_beacon_filter_ie_table *ie_table; |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 420 | int idx = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 421 | int ret; |
| 422 | |
| 423 | wl1271_debug(DEBUG_ACX, "acx beacon filter table"); |
| 424 | |
| 425 | ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL); |
| 426 | if (!ie_table) { |
| 427 | ret = -ENOMEM; |
| 428 | goto out; |
| 429 | } |
| 430 | |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 431 | /* configure default beacon pass-through rules */ |
| 432 | ie_table->num_ie = 1; |
| 433 | ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN; |
| 434 | ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 435 | |
| 436 | ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE, |
| 437 | ie_table, sizeof(*ie_table)); |
| 438 | if (ret < 0) { |
| 439 | wl1271_warning("failed to set beacon filter table: %d", ret); |
| 440 | goto out; |
| 441 | } |
| 442 | |
| 443 | out: |
| 444 | kfree(ie_table); |
| 445 | return ret; |
| 446 | } |
| 447 | |
Juuso Oikarinen | 3441523 | 2009-10-08 21:56:33 +0300 | [diff] [blame] | 448 | int wl1271_acx_conn_monit_params(struct wl1271 *wl) |
| 449 | { |
| 450 | struct acx_conn_monit_params *acx; |
| 451 | int ret; |
| 452 | |
| 453 | wl1271_debug(DEBUG_ACX, "acx connection monitor parameters"); |
| 454 | |
| 455 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 456 | if (!acx) { |
| 457 | ret = -ENOMEM; |
| 458 | goto out; |
| 459 | } |
| 460 | |
| 461 | acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD; |
| 462 | acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT; |
| 463 | |
| 464 | ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS, |
| 465 | acx, sizeof(*acx)); |
| 466 | if (ret < 0) { |
| 467 | wl1271_warning("failed to set connection monitor " |
| 468 | "parameters: %d", ret); |
| 469 | goto out; |
| 470 | } |
| 471 | |
| 472 | out: |
| 473 | kfree(acx); |
| 474 | return ret; |
| 475 | } |
| 476 | |
| 477 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 478 | int wl1271_acx_sg_enable(struct wl1271 *wl) |
| 479 | { |
| 480 | struct acx_bt_wlan_coex *pta; |
| 481 | int ret; |
| 482 | |
| 483 | wl1271_debug(DEBUG_ACX, "acx sg enable"); |
| 484 | |
| 485 | pta = kzalloc(sizeof(*pta), GFP_KERNEL); |
| 486 | if (!pta) { |
| 487 | ret = -ENOMEM; |
| 488 | goto out; |
| 489 | } |
| 490 | |
| 491 | pta->enable = SG_ENABLE; |
| 492 | |
| 493 | ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta)); |
| 494 | if (ret < 0) { |
| 495 | wl1271_warning("failed to set softgemini enable: %d", ret); |
| 496 | goto out; |
| 497 | } |
| 498 | |
| 499 | out: |
| 500 | kfree(pta); |
| 501 | return ret; |
| 502 | } |
| 503 | |
| 504 | int wl1271_acx_sg_cfg(struct wl1271 *wl) |
| 505 | { |
| 506 | struct acx_bt_wlan_coex_param *param; |
| 507 | int ret; |
| 508 | |
| 509 | wl1271_debug(DEBUG_ACX, "acx sg cfg"); |
| 510 | |
| 511 | param = kzalloc(sizeof(*param), GFP_KERNEL); |
| 512 | if (!param) { |
| 513 | ret = -ENOMEM; |
| 514 | goto out; |
| 515 | } |
| 516 | |
| 517 | /* BT-WLAN coext parameters */ |
| 518 | param->min_rate = RATE_INDEX_24MBPS; |
| 519 | param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF; |
| 520 | param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF; |
| 521 | param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF; |
| 522 | param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF; |
| 523 | param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF; |
| 524 | param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF; |
| 525 | param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF; |
| 526 | param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF; |
| 527 | param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF; |
| 528 | param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF; |
| 529 | param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF; |
| 530 | param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF; |
| 531 | param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF; |
| 532 | param->antenna_type = PTA_ANTENNA_TYPE_DEF; |
| 533 | param->signal_type = PTA_SIGNALING_TYPE_DEF; |
| 534 | param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF; |
| 535 | param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF; |
| 536 | param->max_cts = PTA_MAX_NUM_CTS_DEF; |
| 537 | param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF; |
| 538 | param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF; |
| 539 | param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF; |
| 540 | param->wlan_elp_hp = PTA_ELP_HP_DEF; |
| 541 | param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF; |
| 542 | param->ack_mode_dual_ant = PTA_ACK_MODE_DEF; |
| 543 | param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF; |
| 544 | param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF; |
| 545 | param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF; |
| 546 | |
| 547 | ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param)); |
| 548 | if (ret < 0) { |
| 549 | wl1271_warning("failed to set sg config: %d", ret); |
| 550 | goto out; |
| 551 | } |
| 552 | |
| 553 | out: |
| 554 | kfree(param); |
| 555 | return ret; |
| 556 | } |
| 557 | |
| 558 | int wl1271_acx_cca_threshold(struct wl1271 *wl) |
| 559 | { |
| 560 | struct acx_energy_detection *detection; |
| 561 | int ret; |
| 562 | |
| 563 | wl1271_debug(DEBUG_ACX, "acx cca threshold"); |
| 564 | |
| 565 | detection = kzalloc(sizeof(*detection), GFP_KERNEL); |
| 566 | if (!detection) { |
| 567 | ret = -ENOMEM; |
| 568 | goto out; |
| 569 | } |
| 570 | |
| 571 | detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D; |
| 572 | detection->tx_energy_detection = 0; |
| 573 | |
| 574 | ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD, |
| 575 | detection, sizeof(*detection)); |
| 576 | if (ret < 0) { |
| 577 | wl1271_warning("failed to set cca threshold: %d", ret); |
| 578 | return ret; |
| 579 | } |
| 580 | |
| 581 | out: |
| 582 | kfree(detection); |
| 583 | return ret; |
| 584 | } |
| 585 | |
| 586 | int wl1271_acx_bcn_dtim_options(struct wl1271 *wl) |
| 587 | { |
| 588 | struct acx_beacon_broadcast *bb; |
| 589 | int ret; |
| 590 | |
| 591 | wl1271_debug(DEBUG_ACX, "acx bcn dtim options"); |
| 592 | |
| 593 | bb = kzalloc(sizeof(*bb), GFP_KERNEL); |
| 594 | if (!bb) { |
| 595 | ret = -ENOMEM; |
| 596 | goto out; |
| 597 | } |
| 598 | |
| 599 | bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE; |
| 600 | bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE; |
| 601 | bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE; |
| 602 | bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF; |
| 603 | |
| 604 | ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb)); |
| 605 | if (ret < 0) { |
| 606 | wl1271_warning("failed to set rx config: %d", ret); |
| 607 | goto out; |
| 608 | } |
| 609 | |
| 610 | out: |
| 611 | kfree(bb); |
| 612 | return ret; |
| 613 | } |
| 614 | |
| 615 | int wl1271_acx_aid(struct wl1271 *wl, u16 aid) |
| 616 | { |
| 617 | struct acx_aid *acx_aid; |
| 618 | int ret; |
| 619 | |
| 620 | wl1271_debug(DEBUG_ACX, "acx aid"); |
| 621 | |
| 622 | acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL); |
| 623 | if (!acx_aid) { |
| 624 | ret = -ENOMEM; |
| 625 | goto out; |
| 626 | } |
| 627 | |
| 628 | acx_aid->aid = aid; |
| 629 | |
| 630 | ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); |
| 631 | if (ret < 0) { |
| 632 | wl1271_warning("failed to set aid: %d", ret); |
| 633 | goto out; |
| 634 | } |
| 635 | |
| 636 | out: |
| 637 | kfree(acx_aid); |
| 638 | return ret; |
| 639 | } |
| 640 | |
| 641 | int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask) |
| 642 | { |
| 643 | struct acx_event_mask *mask; |
| 644 | int ret; |
| 645 | |
| 646 | wl1271_debug(DEBUG_ACX, "acx event mbox mask"); |
| 647 | |
| 648 | mask = kzalloc(sizeof(*mask), GFP_KERNEL); |
| 649 | if (!mask) { |
| 650 | ret = -ENOMEM; |
| 651 | goto out; |
| 652 | } |
| 653 | |
| 654 | /* high event mask is unused */ |
| 655 | mask->high_event_mask = 0xffffffff; |
| 656 | |
| 657 | mask->event_mask = event_mask; |
| 658 | |
| 659 | ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK, |
| 660 | mask, sizeof(*mask)); |
| 661 | if (ret < 0) { |
| 662 | wl1271_warning("failed to set acx_event_mbox_mask: %d", ret); |
| 663 | goto out; |
| 664 | } |
| 665 | |
| 666 | out: |
| 667 | kfree(mask); |
| 668 | return ret; |
| 669 | } |
| 670 | |
| 671 | int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble) |
| 672 | { |
| 673 | struct acx_preamble *acx; |
| 674 | int ret; |
| 675 | |
| 676 | wl1271_debug(DEBUG_ACX, "acx_set_preamble"); |
| 677 | |
| 678 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 679 | if (!acx) { |
| 680 | ret = -ENOMEM; |
| 681 | goto out; |
| 682 | } |
| 683 | |
| 684 | acx->preamble = preamble; |
| 685 | |
| 686 | ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); |
| 687 | if (ret < 0) { |
| 688 | wl1271_warning("Setting of preamble failed: %d", ret); |
| 689 | goto out; |
| 690 | } |
| 691 | |
| 692 | out: |
| 693 | kfree(acx); |
| 694 | return ret; |
| 695 | } |
| 696 | |
| 697 | int wl1271_acx_cts_protect(struct wl1271 *wl, |
| 698 | enum acx_ctsprotect_type ctsprotect) |
| 699 | { |
| 700 | struct acx_ctsprotect *acx; |
| 701 | int ret; |
| 702 | |
| 703 | wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect"); |
| 704 | |
| 705 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 706 | if (!acx) { |
| 707 | ret = -ENOMEM; |
| 708 | goto out; |
| 709 | } |
| 710 | |
| 711 | acx->ctsprotect = ctsprotect; |
| 712 | |
| 713 | ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); |
| 714 | if (ret < 0) { |
| 715 | wl1271_warning("Setting of ctsprotect failed: %d", ret); |
| 716 | goto out; |
| 717 | } |
| 718 | |
| 719 | out: |
| 720 | kfree(acx); |
| 721 | return ret; |
| 722 | } |
| 723 | |
| 724 | int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats) |
| 725 | { |
| 726 | int ret; |
| 727 | |
| 728 | wl1271_debug(DEBUG_ACX, "acx statistics"); |
| 729 | |
| 730 | ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats, |
| 731 | sizeof(*stats)); |
| 732 | if (ret < 0) { |
| 733 | wl1271_warning("acx statistics failed: %d", ret); |
| 734 | return -ENOMEM; |
| 735 | } |
| 736 | |
| 737 | return 0; |
| 738 | } |
| 739 | |
Juuso Oikarinen | 8a5a37a | 2009-10-08 21:56:24 +0300 | [diff] [blame] | 740 | int wl1271_acx_rate_policies(struct wl1271 *wl, u32 enabled_rates) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 741 | { |
| 742 | struct acx_rate_policy *acx; |
| 743 | int ret = 0; |
| 744 | |
| 745 | wl1271_debug(DEBUG_ACX, "acx rate policies"); |
| 746 | |
| 747 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 748 | |
| 749 | if (!acx) { |
| 750 | ret = -ENOMEM; |
| 751 | goto out; |
| 752 | } |
| 753 | |
| 754 | /* configure one default (one-size-fits-all) rate class */ |
| 755 | acx->rate_class_cnt = 1; |
Juuso Oikarinen | 8a5a37a | 2009-10-08 21:56:24 +0300 | [diff] [blame] | 756 | acx->rate_class[0].enabled_rates = enabled_rates; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 757 | acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT; |
| 758 | acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT; |
| 759 | acx->rate_class[0].aflags = 0; |
| 760 | |
| 761 | ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); |
| 762 | if (ret < 0) { |
| 763 | wl1271_warning("Setting of rate policies failed: %d", ret); |
| 764 | goto out; |
| 765 | } |
| 766 | |
| 767 | out: |
| 768 | kfree(acx); |
| 769 | return ret; |
| 770 | } |
| 771 | |
| 772 | int wl1271_acx_ac_cfg(struct wl1271 *wl) |
| 773 | { |
| 774 | struct acx_ac_cfg *acx; |
| 775 | int i, ret = 0; |
| 776 | |
| 777 | wl1271_debug(DEBUG_ACX, "acx access category config"); |
| 778 | |
| 779 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 780 | |
| 781 | if (!acx) { |
| 782 | ret = -ENOMEM; |
| 783 | goto out; |
| 784 | } |
| 785 | |
| 786 | /* |
| 787 | * FIXME: Configure each AC with appropriate values (most suitable |
| 788 | * values will probably be different for each AC. |
| 789 | */ |
| 790 | for (i = 0; i < WL1271_ACX_AC_COUNT; i++) { |
| 791 | acx->ac = i; |
| 792 | |
| 793 | /* |
| 794 | * FIXME: The following default values originate from |
| 795 | * the TI reference driver. What do they mean? |
| 796 | */ |
| 797 | acx->cw_min = 15; |
| 798 | acx->cw_max = 63; |
| 799 | acx->aifsn = 3; |
| 800 | acx->reserved = 0; |
| 801 | acx->tx_op_limit = 0; |
| 802 | |
| 803 | ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx)); |
| 804 | if (ret < 0) { |
| 805 | wl1271_warning("Setting of access category " |
| 806 | "config: %d", ret); |
| 807 | goto out; |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | out: |
| 812 | kfree(acx); |
| 813 | return ret; |
| 814 | } |
| 815 | |
| 816 | int wl1271_acx_tid_cfg(struct wl1271 *wl) |
| 817 | { |
| 818 | struct acx_tid_config *acx; |
| 819 | int i, ret = 0; |
| 820 | |
| 821 | wl1271_debug(DEBUG_ACX, "acx tid config"); |
| 822 | |
| 823 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 824 | |
| 825 | if (!acx) { |
| 826 | ret = -ENOMEM; |
| 827 | goto out; |
| 828 | } |
| 829 | |
| 830 | /* FIXME: configure each TID with a different AC reference */ |
| 831 | for (i = 0; i < WL1271_ACX_TID_COUNT; i++) { |
| 832 | acx->queue_id = i; |
| 833 | acx->tsid = WL1271_ACX_AC_BE; |
| 834 | acx->ps_scheme = WL1271_ACX_PS_SCHEME_LEGACY; |
| 835 | acx->ack_policy = WL1271_ACX_ACK_POLICY_LEGACY; |
| 836 | |
| 837 | ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx)); |
| 838 | if (ret < 0) { |
| 839 | wl1271_warning("Setting of tid config failed: %d", ret); |
| 840 | goto out; |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | out: |
| 845 | kfree(acx); |
| 846 | return ret; |
| 847 | } |
| 848 | |
| 849 | int wl1271_acx_frag_threshold(struct wl1271 *wl) |
| 850 | { |
| 851 | struct acx_frag_threshold *acx; |
| 852 | int ret = 0; |
| 853 | |
| 854 | wl1271_debug(DEBUG_ACX, "acx frag threshold"); |
| 855 | |
| 856 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 857 | |
| 858 | if (!acx) { |
| 859 | ret = -ENOMEM; |
| 860 | goto out; |
| 861 | } |
| 862 | |
| 863 | acx->frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD; |
| 864 | ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx)); |
| 865 | if (ret < 0) { |
| 866 | wl1271_warning("Setting of frag threshold failed: %d", ret); |
| 867 | goto out; |
| 868 | } |
| 869 | |
| 870 | out: |
| 871 | kfree(acx); |
| 872 | return ret; |
| 873 | } |
| 874 | |
| 875 | int wl1271_acx_tx_config_options(struct wl1271 *wl) |
| 876 | { |
| 877 | struct acx_tx_config_options *acx; |
| 878 | int ret = 0; |
| 879 | |
| 880 | wl1271_debug(DEBUG_ACX, "acx tx config options"); |
| 881 | |
| 882 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); |
| 883 | |
| 884 | if (!acx) { |
| 885 | ret = -ENOMEM; |
| 886 | goto out; |
| 887 | } |
| 888 | |
| 889 | acx->tx_compl_timeout = WL1271_ACX_TX_COMPL_TIMEOUT; |
| 890 | acx->tx_compl_threshold = WL1271_ACX_TX_COMPL_THRESHOLD; |
| 891 | ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx)); |
| 892 | if (ret < 0) { |
| 893 | wl1271_warning("Setting of tx options failed: %d", ret); |
| 894 | goto out; |
| 895 | } |
| 896 | |
| 897 | out: |
| 898 | kfree(acx); |
| 899 | return ret; |
| 900 | } |
| 901 | |
| 902 | int wl1271_acx_mem_cfg(struct wl1271 *wl) |
| 903 | { |
| 904 | struct wl1271_acx_config_memory *mem_conf; |
| 905 | int ret; |
| 906 | |
| 907 | wl1271_debug(DEBUG_ACX, "wl1271 mem cfg"); |
| 908 | |
| 909 | mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL); |
| 910 | if (!mem_conf) { |
| 911 | ret = -ENOMEM; |
| 912 | goto out; |
| 913 | } |
| 914 | |
| 915 | /* memory config */ |
| 916 | mem_conf->num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); |
| 917 | mem_conf->rx_mem_block_num = ACX_RX_MEM_BLOCKS; |
| 918 | mem_conf->tx_min_mem_block_num = ACX_TX_MIN_MEM_BLOCKS; |
| 919 | mem_conf->num_ssid_profiles = ACX_NUM_SSID_PROFILES; |
| 920 | mem_conf->total_tx_descriptors = ACX_TX_DESCRIPTORS; |
| 921 | |
| 922 | ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf, |
| 923 | sizeof(*mem_conf)); |
| 924 | if (ret < 0) { |
| 925 | wl1271_warning("wl1271 mem config failed: %d", ret); |
| 926 | goto out; |
| 927 | } |
| 928 | |
| 929 | out: |
| 930 | kfree(mem_conf); |
| 931 | return ret; |
| 932 | } |
| 933 | |
| 934 | int wl1271_acx_init_mem_config(struct wl1271 *wl) |
| 935 | { |
| 936 | int ret; |
| 937 | |
| 938 | ret = wl1271_acx_mem_cfg(wl); |
| 939 | if (ret < 0) |
| 940 | return ret; |
| 941 | |
| 942 | wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map), |
| 943 | GFP_KERNEL); |
| 944 | if (!wl->target_mem_map) { |
| 945 | wl1271_error("couldn't allocate target memory map"); |
| 946 | return -ENOMEM; |
| 947 | } |
| 948 | |
| 949 | /* we now ask for the firmware built memory map */ |
| 950 | ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map, |
| 951 | sizeof(struct wl1271_acx_mem_map)); |
| 952 | if (ret < 0) { |
| 953 | wl1271_error("couldn't retrieve firmware memory map"); |
| 954 | kfree(wl->target_mem_map); |
| 955 | wl->target_mem_map = NULL; |
| 956 | return ret; |
| 957 | } |
| 958 | |
| 959 | /* initialize TX block book keeping */ |
| 960 | wl->tx_blocks_available = wl->target_mem_map->num_tx_mem_blocks; |
| 961 | wl1271_debug(DEBUG_TX, "available tx blocks: %d", |
| 962 | wl->tx_blocks_available); |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | int wl1271_acx_init_rx_interrupt(struct wl1271 *wl) |
| 968 | { |
| 969 | struct wl1271_acx_rx_config_opt *rx_conf; |
| 970 | int ret; |
| 971 | |
| 972 | wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config"); |
| 973 | |
| 974 | rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL); |
| 975 | if (!rx_conf) { |
| 976 | ret = -ENOMEM; |
| 977 | goto out; |
| 978 | } |
| 979 | |
| 980 | rx_conf->threshold = WL1271_RX_INTR_THRESHOLD_DEF; |
| 981 | rx_conf->timeout = WL1271_RX_INTR_TIMEOUT_DEF; |
| 982 | rx_conf->mblk_threshold = USHORT_MAX; /* Disabled */ |
| 983 | rx_conf->queue_type = RX_QUEUE_TYPE_RX_LOW_PRIORITY; |
| 984 | |
| 985 | ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf, |
| 986 | sizeof(*rx_conf)); |
| 987 | if (ret < 0) { |
| 988 | wl1271_warning("wl1271 rx config opt failed: %d", ret); |
| 989 | goto out; |
| 990 | } |
| 991 | |
| 992 | out: |
| 993 | kfree(rx_conf); |
| 994 | return ret; |
| 995 | } |