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