2 * This file is part of wl1271
4 * Copyright (C) 2008-2009 Nokia Corporation
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
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.
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.
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
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
28 #include <linux/spi/spi.h>
29 #include <linux/slab.h>
32 #include "wl12xx_80211.h"
36 int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
38 struct acx_wake_up_condition *wake_up;
41 wl1271_debug(DEBUG_ACX, "acx wake up conditions");
43 wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
49 wake_up->role_id = wl->role_id;
50 wake_up->wake_up_event = wl->conf.conn.wake_up_event;
51 wake_up->listen_interval = wl->conf.conn.listen_interval;
53 ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
54 wake_up, sizeof(*wake_up));
56 wl1271_warning("could not set wake up conditions: %d", ret);
65 int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
67 struct acx_sleep_auth *auth;
70 wl1271_debug(DEBUG_ACX, "acx sleep auth");
72 auth = kzalloc(sizeof(*auth), GFP_KERNEL);
78 auth->sleep_auth = sleep_auth;
80 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
89 int wl1271_acx_tx_power(struct wl1271 *wl, int power)
91 struct acx_current_tx_power *acx;
94 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
96 if (power < 0 || power > 25)
99 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
105 acx->role_id = wl->role_id;
106 acx->current_tx_power = power * 10;
108 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
110 wl1271_warning("configure of tx power failed: %d", ret);
119 int wl1271_acx_feature_cfg(struct wl1271 *wl)
121 struct acx_feature_config *feature;
124 wl1271_debug(DEBUG_ACX, "acx feature cfg");
126 feature = kzalloc(sizeof(*feature), GFP_KERNEL);
132 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
133 feature->role_id = wl->role_id;
134 feature->data_flow_options = 0;
135 feature->options = 0;
137 ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
138 feature, sizeof(*feature));
140 wl1271_error("Couldnt set HW encryption");
149 int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
154 wl1271_debug(DEBUG_ACX, "acx mem map");
156 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
163 int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
165 struct acx_rx_msdu_lifetime *acx;
168 wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
170 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
176 acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
177 ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
180 wl1271_warning("failed to set rx msdu life time: %d", ret);
189 int wl1271_acx_pd_threshold(struct wl1271 *wl)
191 struct acx_packet_detection *pd;
194 wl1271_debug(DEBUG_ACX, "acx data pd threshold");
196 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
202 pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold);
204 ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
206 wl1271_warning("failed to set pd threshold: %d", ret);
215 int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time)
217 struct acx_slot *slot;
220 wl1271_debug(DEBUG_ACX, "acx slot");
222 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
228 slot->role_id = wl->role_id;
229 slot->wone_index = STATION_WONE_INDEX;
230 slot->slot_time = slot_time;
232 ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
234 wl1271_warning("failed to set slot time: %d", ret);
243 int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable,
244 void *mc_list, u32 mc_list_len)
246 struct acx_dot11_grp_addr_tbl *acx;
249 wl1271_debug(DEBUG_ACX, "acx group address tbl");
251 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
258 acx->role_id = wl->role_id;
259 acx->enabled = enable;
260 acx->num_groups = mc_list_len;
261 memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
263 ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
266 wl1271_warning("failed to set group addr table: %d", ret);
275 int wl1271_acx_service_period_timeout(struct wl1271 *wl)
277 struct acx_rx_timeout *rx_timeout;
280 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
286 wl1271_debug(DEBUG_ACX, "acx service period timeout");
288 rx_timeout->role_id = wl->role_id;
289 rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout);
290 rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout);
292 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
293 rx_timeout, sizeof(*rx_timeout));
295 wl1271_warning("failed to set service period timeout: %d",
305 int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold)
307 struct acx_rts_threshold *rts;
311 * If the RTS threshold is not configured or out of range, use the
314 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
315 rts_threshold = wl->conf.rx.rts_threshold;
317 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
319 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
325 rts->role_id = wl->role_id;
326 rts->threshold = cpu_to_le16((u16)rts_threshold);
328 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
330 wl1271_warning("failed to set rts threshold: %d", ret);
339 int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
341 struct acx_dco_itrim_params *dco;
342 struct conf_itrim_settings *c = &wl->conf.itrim;
345 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
347 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
353 dco->enable = c->enable;
354 dco->timeout = cpu_to_le32(c->timeout);
356 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
359 wl1271_warning("failed to set dco itrim parameters: %d", ret);
368 int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter)
370 struct acx_beacon_filter_option *beacon_filter = NULL;
373 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
376 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
379 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
380 if (!beacon_filter) {
385 beacon_filter->role_id = wl->role_id;
386 beacon_filter->enable = enable_filter;
389 * When set to zero, and the filter is enabled, beacons
390 * without the unicast TIM bit set are dropped.
392 beacon_filter->max_num_beacons = 0;
394 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
395 beacon_filter, sizeof(*beacon_filter));
397 wl1271_warning("failed to set beacon filter opt: %d", ret);
402 kfree(beacon_filter);
406 int wl1271_acx_beacon_filter_table(struct wl1271 *wl)
408 struct acx_beacon_filter_ie_table *ie_table;
411 bool vendor_spec = false;
413 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
415 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
421 /* configure default beacon pass-through rules */
422 ie_table->role_id = wl->role_id;
423 ie_table->num_ie = 0;
424 for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) {
425 struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]);
426 ie_table->table[idx++] = r->ie;
427 ie_table->table[idx++] = r->rule;
429 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
430 /* only one vendor specific ie allowed */
434 /* for vendor specific rules configure the
436 memcpy(&(ie_table->table[idx]), r->oui,
437 CONF_BCN_IE_OUI_LEN);
438 idx += CONF_BCN_IE_OUI_LEN;
439 ie_table->table[idx++] = r->type;
440 memcpy(&(ie_table->table[idx]), r->version,
441 CONF_BCN_IE_VER_LEN);
442 idx += CONF_BCN_IE_VER_LEN;
449 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
450 ie_table, sizeof(*ie_table));
452 wl1271_warning("failed to set beacon filter table: %d", ret);
461 #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
463 int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable)
465 struct acx_conn_monit_params *acx;
466 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
467 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
470 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
471 enable ? "enabled" : "disabled");
473 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
480 threshold = wl->conf.conn.synch_fail_thold;
481 timeout = wl->conf.conn.bss_lose_timeout;
484 acx->role_id = wl->role_id;
485 acx->synch_fail_thold = cpu_to_le32(threshold);
486 acx->bss_lose_timeout = cpu_to_le32(timeout);
488 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
491 wl1271_warning("failed to set connection monitor "
492 "parameters: %d", ret);
502 int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
504 struct acx_bt_wlan_coex *pta;
507 wl1271_debug(DEBUG_ACX, "acx sg enable");
509 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
516 pta->enable = wl->conf.sg.state;
518 pta->enable = CONF_SG_DISABLE;
520 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
522 wl1271_warning("failed to set softgemini enable: %d", ret);
531 int wl12xx_acx_sg_cfg(struct wl1271 *wl)
533 struct acx_bt_wlan_coex_param *param;
534 struct conf_sg_settings *c = &wl->conf.sg;
537 wl1271_debug(DEBUG_ACX, "acx sg cfg");
539 param = kzalloc(sizeof(*param), GFP_KERNEL);
545 /* BT-WLAN coext parameters */
546 for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
547 param->params[i] = cpu_to_le32(c->params[i]);
548 param->param_idx = CONF_SG_PARAMS_ALL;
550 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
552 wl1271_warning("failed to set sg config: %d", ret);
561 int wl1271_acx_cca_threshold(struct wl1271 *wl)
563 struct acx_energy_detection *detection;
566 wl1271_debug(DEBUG_ACX, "acx cca threshold");
568 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
574 detection->rx_cca_threshold = cpu_to_le16(wl->conf.rx.rx_cca_threshold);
575 detection->tx_energy_detection = wl->conf.tx.tx_energy_detection;
577 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
578 detection, sizeof(*detection));
580 wl1271_warning("failed to set cca threshold: %d", ret);
589 int wl1271_acx_bcn_dtim_options(struct wl1271 *wl)
591 struct acx_beacon_broadcast *bb;
594 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
596 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
602 bb->role_id = wl->role_id;
603 bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout);
604 bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout);
605 bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps;
606 bb->ps_poll_threshold = wl->conf.conn.ps_poll_threshold;
608 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
610 wl1271_warning("failed to set rx config: %d", ret);
619 int wl1271_acx_aid(struct wl1271 *wl, u16 aid)
621 struct acx_aid *acx_aid;
624 wl1271_debug(DEBUG_ACX, "acx aid");
626 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
632 acx_aid->role_id = wl->role_id;
633 acx_aid->aid = cpu_to_le16(aid);
635 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
637 wl1271_warning("failed to set aid: %d", ret);
646 int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
648 struct acx_event_mask *mask;
651 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
653 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
659 /* high event mask is unused */
660 mask->high_event_mask = cpu_to_le32(0xffffffff);
661 mask->event_mask = cpu_to_le32(event_mask);
663 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
664 mask, sizeof(*mask));
666 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
675 int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble)
677 struct acx_preamble *acx;
680 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
682 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
688 acx->role_id = wl->role_id;
689 acx->preamble = preamble;
691 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
693 wl1271_warning("Setting of preamble failed: %d", ret);
702 int wl1271_acx_cts_protect(struct wl1271 *wl,
703 enum acx_ctsprotect_type ctsprotect)
705 struct acx_ctsprotect *acx;
708 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
710 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
716 acx->role_id = wl->role_id;
717 acx->ctsprotect = ctsprotect;
719 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
721 wl1271_warning("Setting of ctsprotect failed: %d", ret);
730 int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
734 wl1271_debug(DEBUG_ACX, "acx statistics");
736 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
739 wl1271_warning("acx statistics failed: %d", ret);
746 int wl1271_acx_sta_rate_policies(struct wl1271 *wl)
748 struct acx_rate_policy *acx;
749 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
752 wl1271_debug(DEBUG_ACX, "acx rate policies");
754 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
761 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
762 wl->basic_rate, wl->rate_set);
764 /* configure one basic rate class */
765 acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE);
766 acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate);
767 acx->rate_policy.short_retry_limit = c->short_retry_limit;
768 acx->rate_policy.long_retry_limit = c->long_retry_limit;
769 acx->rate_policy.aflags = c->aflags;
771 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
773 wl1271_warning("Setting of rate policies failed: %d", ret);
777 /* configure one AP supported rate class */
778 acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE);
779 acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set);
780 acx->rate_policy.short_retry_limit = c->short_retry_limit;
781 acx->rate_policy.long_retry_limit = c->long_retry_limit;
782 acx->rate_policy.aflags = c->aflags;
786 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
788 wl1271_warning("Setting of rate policies failed: %d", ret);
797 int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
800 struct acx_rate_policy *acx;
803 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
804 idx, c->enabled_rates);
806 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
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;
817 acx->rate_policy_idx = cpu_to_le32(idx);
819 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
821 wl1271_warning("Setting of ap rate policy failed: %d", ret);
830 int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max,
833 struct acx_ac_cfg *acx;
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);
839 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
846 acx->role_id = wl->role_id;
848 acx->cw_min = cw_min;
849 acx->cw_max = cpu_to_le16(cw_max);
851 acx->tx_op_limit = cpu_to_le16(txop);
853 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
855 wl1271_warning("acx ac cfg failed: %d", ret);
864 int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type,
865 u8 tsid, u8 ps_scheme, u8 ack_policy,
866 u32 apsd_conf0, u32 apsd_conf1)
868 struct acx_tid_config *acx;
871 wl1271_debug(DEBUG_ACX, "acx tid config");
873 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
880 acx->role_id = wl->role_id;
881 acx->queue_id = queue_id;
882 acx->channel_type = channel_type;
884 acx->ps_scheme = ps_scheme;
885 acx->ack_policy = ack_policy;
886 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
887 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
889 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
891 wl1271_warning("Setting of tid config failed: %d", ret);
900 int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
902 struct acx_frag_threshold *acx;
906 * If the fragmentation is not configured or out of range, use the
909 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
910 frag_threshold = wl->conf.tx.frag_threshold;
912 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
914 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
921 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
922 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
924 wl1271_warning("Setting of frag threshold failed: %d", ret);
933 int wl1271_acx_tx_config_options(struct wl1271 *wl)
935 struct acx_tx_config_options *acx;
938 wl1271_debug(DEBUG_ACX, "acx tx config options");
940 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
947 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
948 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
949 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
951 wl1271_warning("Setting of tx options failed: %d", ret);
960 int wl12xx_acx_mem_cfg(struct wl1271 *wl)
962 struct wl12xx_acx_config_memory *mem_conf;
963 struct conf_memory_settings *mem;
966 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
968 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
974 if (wl->chip.id == CHIP_ID_1283_PG20)
975 mem = &wl->conf.mem_wl128x;
977 mem = &wl->conf.mem_wl127x;
980 mem_conf->num_stations = mem->num_stations;
981 mem_conf->rx_mem_block_num = mem->rx_block_num;
982 mem_conf->tx_min_mem_block_num = mem->tx_min_block_num;
983 mem_conf->num_ssid_profiles = mem->ssid_profiles;
984 mem_conf->total_tx_descriptors = cpu_to_le32(ACX_TX_DESCRIPTORS);
985 mem_conf->dyn_mem_enable = mem->dynamic_memory;
986 mem_conf->tx_free_req = mem->min_req_tx_blocks;
987 mem_conf->rx_free_req = mem->min_req_rx_blocks;
988 mem_conf->tx_min = mem->tx_min;
989 mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks;
991 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
994 wl1271_warning("wl1271 mem config failed: %d", ret);
1003 int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1005 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1008 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1014 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1016 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1017 bitmap_conf, sizeof(*bitmap_conf));
1019 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1029 int wl1271_acx_init_mem_config(struct wl1271 *wl)
1033 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
1035 if (!wl->target_mem_map) {
1036 wl1271_error("couldn't allocate target memory map");
1040 /* we now ask for the firmware built memory map */
1041 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1042 sizeof(struct wl1271_acx_mem_map));
1044 wl1271_error("couldn't retrieve firmware memory map");
1045 kfree(wl->target_mem_map);
1046 wl->target_mem_map = NULL;
1050 /* initialize TX block book keeping */
1051 wl->tx_blocks_available =
1052 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
1053 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1054 wl->tx_blocks_available);
1059 int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1061 struct wl1271_acx_rx_config_opt *rx_conf;
1064 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1066 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1072 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1073 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1074 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
1075 rx_conf->queue_type = wl->conf.rx.queue_type;
1077 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1080 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1089 int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable)
1091 struct wl1271_acx_bet_enable *acx = NULL;
1094 wl1271_debug(DEBUG_ACX, "acx bet enable");
1096 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1099 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1105 acx->role_id = wl->role_id;
1106 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1107 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1109 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1111 wl1271_warning("acx bet enable failed: %d", ret);
1120 int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address)
1122 struct wl1271_acx_arp_filter *acx;
1125 wl1271_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
1127 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1133 acx->role_id = wl->role_id;
1134 acx->version = ACX_IPV4_VERSION;
1135 acx->enable = enable;
1138 memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
1140 ret = wl1271_cmd_configure(wl, ACX_ARP_IP_FILTER,
1143 wl1271_warning("failed to set arp ip filter: %d", ret);
1152 int wl1271_acx_pm_config(struct wl1271 *wl)
1154 struct wl1271_acx_pm_config *acx = NULL;
1155 struct conf_pm_config_settings *c = &wl->conf.pm_config;
1158 wl1271_debug(DEBUG_ACX, "acx pm config");
1160 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1166 acx->host_clk_settling_time = cpu_to_le32(c->host_clk_settling_time);
1167 acx->host_fast_wakeup_support = c->host_fast_wakeup_support;
1169 ret = wl1271_cmd_configure(wl, ACX_PM_CONFIG, acx, sizeof(*acx));
1171 wl1271_warning("acx pm config failed: %d", ret);
1180 int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable)
1182 struct wl1271_acx_keep_alive_mode *acx = NULL;
1185 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1187 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1193 acx->role_id = wl->role_id;
1194 acx->enabled = enable;
1196 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1198 wl1271_warning("acx keep alive mode failed: %d", ret);
1207 int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid)
1209 struct wl1271_acx_keep_alive_config *acx = NULL;
1212 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1214 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1220 acx->role_id = wl->role_id;
1221 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1223 acx->tpl_validation = tpl_valid;
1224 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1226 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1229 wl1271_warning("acx keep alive config failed: %d", ret);
1238 int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable,
1241 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1244 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1246 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1252 wl->last_rssi_event = -1;
1254 acx->role_id = wl->role_id;
1255 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1256 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1257 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1259 acx->enable = WL1271_ACX_TRIG_ENABLE;
1261 acx->enable = WL1271_ACX_TRIG_DISABLE;
1263 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1264 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1265 acx->threshold = cpu_to_le16(thold);
1266 acx->hysteresis = hyst;
1268 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1270 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1279 int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl)
1281 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1282 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1285 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1287 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1293 acx->role_id = wl->role_id;
1294 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1295 acx->rssi_data = c->avg_weight_rssi_data;
1296 acx->snr_beacon = c->avg_weight_snr_beacon;
1297 acx->snr_data = c->avg_weight_snr_data;
1299 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1301 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1310 int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1311 struct ieee80211_sta_ht_cap *ht_cap,
1312 bool allow_ht_operation, u8 hlid)
1314 struct wl1271_acx_ht_capabilities *acx;
1316 u32 ht_capabilites = 0;
1318 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting "
1319 "sta supp: %d sta cap: %d", ht_cap->ht_supported,
1322 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1328 if (allow_ht_operation && ht_cap->ht_supported) {
1329 /* no need to translate capabilities - use the spec values */
1330 ht_capabilites = ht_cap->cap;
1333 * this bit is not employed by the spec but only by FW to
1334 * indicate peer HT support
1336 ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
1338 /* get data from A-MPDU parameters field */
1339 acx->ampdu_max_length = ht_cap->ampdu_factor;
1340 acx->ampdu_min_spacing = ht_cap->ampdu_density;
1344 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1346 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1348 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1357 int wl1271_acx_set_ht_information(struct wl1271 *wl,
1358 u16 ht_operation_mode)
1360 struct wl1271_acx_ht_information *acx;
1363 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1365 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1371 acx->role_id = wl->role_id;
1372 acx->ht_protection =
1373 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1375 acx->gf_protection =
1376 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
1377 acx->ht_tx_burst_limit = 0;
1378 acx->dual_cts_protection = 0;
1380 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1383 wl1271_warning("acx ht information setting failed: %d", ret);
1392 /* Configure BA session initiator/receiver parameters setting in the FW. */
1393 int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl)
1395 struct wl1271_acx_ba_initiator_policy *acx;
1398 wl1271_debug(DEBUG_ACX, "acx ba initiator policy");
1400 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1406 /* set for the current role */
1407 acx->role_id = wl->role_id;
1408 acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap;
1409 acx->win_size = wl->conf.ht.tx_ba_win_size;
1410 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
1412 ret = wl1271_cmd_configure(wl,
1413 ACX_BA_SESSION_INIT_POLICY,
1417 wl1271_warning("acx ba initiator policy failed: %d", ret);
1426 /* setup BA session receiver setting in the FW. */
1427 int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index,
1428 u16 ssn, bool enable, u8 peer_hlid)
1430 struct wl1271_acx_ba_receiver_setup *acx;
1433 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1435 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1441 acx->hlid = peer_hlid;
1442 acx->tid = tid_index;
1443 acx->enable = enable;
1444 acx->win_size = wl->conf.ht.rx_ba_win_size;
1447 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1450 wl1271_warning("acx ba receiver session failed: %d", ret);
1459 int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime)
1461 struct wl1271_acx_fw_tsf_information *tsf_info;
1464 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1470 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1471 tsf_info, sizeof(*tsf_info));
1473 wl1271_warning("acx tsf info interrogate failed");
1477 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1478 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1485 int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable)
1487 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1488 u32 conf_queues, enable_queues;
1491 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1493 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1494 if (!rx_streaming) {
1499 conf_queues = wl->conf.rx_streaming.queues;
1501 enable_queues = conf_queues;
1505 for (i = 0; i < 8; i++) {
1507 * Skip non-changed queues, to avoid redundant acxs.
1508 * this check assumes conf.rx_streaming.queues can't
1509 * be changed while rx_streaming is enabled.
1511 if (!(conf_queues & BIT(i)))
1514 rx_streaming->role_id = wl->role_id;
1515 rx_streaming->tid = i;
1516 rx_streaming->enable = enable_queues & BIT(i);
1517 rx_streaming->period = wl->conf.rx_streaming.interval;
1518 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1520 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1522 sizeof(*rx_streaming));
1524 wl1271_warning("acx ps rx streaming failed: %d", ret);
1529 kfree(rx_streaming);
1533 int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl)
1535 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
1538 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
1540 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1544 acx->role_id = wl->role_id;
1545 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
1547 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1549 wl1271_warning("acx ap max tx retry failed: %d", ret);
1558 int wl1271_acx_config_ps(struct wl1271 *wl)
1560 struct wl1271_acx_config_ps *config_ps;
1563 wl1271_debug(DEBUG_ACX, "acx config ps");
1565 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1571 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1572 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
1573 config_ps->null_data_rate = cpu_to_le32(wl->basic_rate);
1575 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1576 sizeof(*config_ps));
1579 wl1271_warning("acx config ps failed: %d", ret);
1588 int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1590 struct wl1271_acx_inconnection_sta *acx = NULL;
1593 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1595 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1599 memcpy(acx->addr, addr, ETH_ALEN);
1601 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1604 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1613 int wl1271_acx_fm_coex(struct wl1271 *wl)
1615 struct wl1271_acx_fm_coex *acx;
1618 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1620 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1626 acx->enable = wl->conf.fm_coex.enable;
1627 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1628 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1629 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1630 acx->m_divider_fref_set_1 =
1631 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1632 acx->m_divider_fref_set_2 =
1633 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1634 acx->coex_pll_stabilization_time =
1635 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1636 acx->ldo_stabilization_time =
1637 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1638 acx->fm_disturbed_band_margin =
1639 wl->conf.fm_coex.fm_disturbed_band_margin;
1640 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1642 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1644 wl1271_warning("acx fm coex setting failed: %d", ret);
1653 int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1655 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1656 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1659 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1661 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1665 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1666 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1667 acx->per_add = cpu_to_le16(conf->per_add);
1668 acx->per_th1 = cpu_to_le16(conf->per_th1);
1669 acx->per_th2 = cpu_to_le16(conf->per_th2);
1670 acx->max_per = cpu_to_le16(conf->max_per);
1671 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1672 acx->tx_fail_low_th = conf->tx_fail_low_th;
1673 acx->tx_fail_high_th = conf->tx_fail_high_th;
1674 acx->per_alpha_shift = conf->per_alpha_shift;
1675 acx->per_add_shift = conf->per_add_shift;
1676 acx->per_beta1_shift = conf->per_beta1_shift;
1677 acx->per_beta2_shift = conf->per_beta2_shift;
1678 acx->rate_check_up = conf->rate_check_up;
1679 acx->rate_check_down = conf->rate_check_down;
1680 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1681 sizeof(acx->rate_retry_policy));
1683 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1686 wl1271_warning("acx set rate mgmt params failed: %d", ret);