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