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