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>
33 #include "wl12xx_80211.h"
37 int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif,
38 u8 wake_up_event, u8 listen_interval)
40 struct acx_wake_up_condition *wake_up;
43 wl1271_debug(DEBUG_ACX, "acx wake up conditions (wake_up_event %d listen_interval %d)",
44 wake_up_event, listen_interval);
46 wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
52 wake_up->role_id = wlvif->role_id;
53 wake_up->wake_up_event = wake_up_event;
54 wake_up->listen_interval = listen_interval;
56 ret = wl1271_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
57 wake_up, sizeof(*wake_up));
59 wl1271_warning("could not set wake up conditions: %d", ret);
68 int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
70 struct acx_sleep_auth *auth;
73 wl1271_debug(DEBUG_ACX, "acx sleep auth");
75 auth = kzalloc(sizeof(*auth), GFP_KERNEL);
81 auth->sleep_auth = sleep_auth;
83 ret = wl1271_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
90 int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif,
93 struct acx_current_tx_power *acx;
96 wl1271_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr %d", power);
98 if (power < 0 || power > 25)
101 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
107 acx->role_id = wlvif->role_id;
108 acx->current_tx_power = power * 10;
110 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
112 wl1271_warning("configure of tx power failed: %d", ret);
121 int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif)
123 struct acx_feature_config *feature;
126 wl1271_debug(DEBUG_ACX, "acx feature cfg");
128 feature = kzalloc(sizeof(*feature), GFP_KERNEL);
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;
139 ret = wl1271_cmd_configure(wl, ACX_FEATURE_CFG,
140 feature, sizeof(*feature));
142 wl1271_error("Couldnt set HW encryption");
151 int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map,
156 wl1271_debug(DEBUG_ACX, "acx mem map");
158 ret = wl1271_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
165 int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl)
167 struct acx_rx_msdu_lifetime *acx;
170 wl1271_debug(DEBUG_ACX, "acx rx msdu life time");
172 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
178 acx->lifetime = cpu_to_le32(wl->conf.rx.rx_msdu_life_time);
179 ret = wl1271_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
182 wl1271_warning("failed to set rx msdu life time: %d", ret);
191 int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif,
192 enum acx_slot_type slot_time)
194 struct acx_slot *slot;
197 wl1271_debug(DEBUG_ACX, "acx slot");
199 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
205 slot->role_id = wlvif->role_id;
206 slot->wone_index = STATION_WONE_INDEX;
207 slot->slot_time = slot_time;
209 ret = wl1271_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
211 wl1271_warning("failed to set slot time: %d", ret);
220 int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif,
221 bool enable, void *mc_list, u32 mc_list_len)
223 struct acx_dot11_grp_addr_tbl *acx;
226 wl1271_debug(DEBUG_ACX, "acx group address tbl");
228 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
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);
240 ret = wl1271_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
243 wl1271_warning("failed to set group addr table: %d", ret);
252 int wl1271_acx_service_period_timeout(struct wl1271 *wl,
253 struct wl12xx_vif *wlvif)
255 struct acx_rx_timeout *rx_timeout;
258 rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
264 wl1271_debug(DEBUG_ACX, "acx service period timeout");
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);
270 ret = wl1271_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
271 rx_timeout, sizeof(*rx_timeout));
273 wl1271_warning("failed to set service period timeout: %d",
283 int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif,
286 struct acx_rts_threshold *rts;
290 * If the RTS threshold is not configured or out of range, use the
293 if (rts_threshold > IEEE80211_MAX_RTS_THRESHOLD)
294 rts_threshold = wl->conf.rx.rts_threshold;
296 wl1271_debug(DEBUG_ACX, "acx rts threshold: %d", rts_threshold);
298 rts = kzalloc(sizeof(*rts), GFP_KERNEL);
304 rts->role_id = wlvif->role_id;
305 rts->threshold = cpu_to_le16((u16)rts_threshold);
307 ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
309 wl1271_warning("failed to set rts threshold: %d", ret);
318 int wl1271_acx_dco_itrim_params(struct wl1271 *wl)
320 struct acx_dco_itrim_params *dco;
321 struct conf_itrim_settings *c = &wl->conf.itrim;
324 wl1271_debug(DEBUG_ACX, "acx dco itrim parameters");
326 dco = kzalloc(sizeof(*dco), GFP_KERNEL);
332 dco->enable = c->enable;
333 dco->timeout = cpu_to_le32(c->timeout);
335 ret = wl1271_cmd_configure(wl, ACX_SET_DCO_ITRIM_PARAMS,
338 wl1271_warning("failed to set dco itrim parameters: %d", ret);
347 int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif,
350 struct acx_beacon_filter_option *beacon_filter = NULL;
353 wl1271_debug(DEBUG_ACX, "acx beacon filter opt");
356 wl->conf.conn.bcn_filt_mode == CONF_BCN_FILT_MODE_DISABLED)
359 beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
360 if (!beacon_filter) {
365 beacon_filter->role_id = wlvif->role_id;
366 beacon_filter->enable = enable_filter;
369 * When set to zero, and the filter is enabled, beacons
370 * without the unicast TIM bit set are dropped.
372 beacon_filter->max_num_beacons = 0;
374 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
375 beacon_filter, sizeof(*beacon_filter));
377 wl1271_warning("failed to set beacon filter opt: %d", ret);
382 kfree(beacon_filter);
386 int wl1271_acx_beacon_filter_table(struct wl1271 *wl,
387 struct wl12xx_vif *wlvif)
389 struct acx_beacon_filter_ie_table *ie_table;
392 bool vendor_spec = false;
394 wl1271_debug(DEBUG_ACX, "acx beacon filter table");
396 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
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;
410 if (r->ie == WLAN_EID_VENDOR_SPECIFIC) {
411 /* only one vendor specific ie allowed */
415 /* for vendor specific rules configure the
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;
430 ret = wl1271_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
431 ie_table, sizeof(*ie_table));
433 wl1271_warning("failed to set beacon filter table: %d", ret);
442 #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
444 int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif,
447 struct acx_conn_monit_params *acx;
448 u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE;
449 u32 timeout = ACX_CONN_MONIT_DISABLE_VALUE;
452 wl1271_debug(DEBUG_ACX, "acx connection monitor parameters: %s",
453 enable ? "enabled" : "disabled");
455 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
462 threshold = wl->conf.conn.synch_fail_thold;
463 timeout = wl->conf.conn.bss_lose_timeout;
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);
470 ret = wl1271_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
473 wl1271_warning("failed to set connection monitor "
474 "parameters: %d", ret);
484 int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
486 struct acx_bt_wlan_coex *pta;
489 wl1271_debug(DEBUG_ACX, "acx sg enable");
491 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
498 pta->enable = wl->conf.sg.state;
500 pta->enable = CONF_SG_DISABLE;
502 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
504 wl1271_warning("failed to set softgemini enable: %d", ret);
513 int wl12xx_acx_sg_cfg(struct wl1271 *wl)
515 struct acx_bt_wlan_coex_param *param;
516 struct conf_sg_settings *c = &wl->conf.sg;
519 wl1271_debug(DEBUG_ACX, "acx sg cfg");
521 param = kzalloc(sizeof(*param), GFP_KERNEL);
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;
532 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
534 wl1271_warning("failed to set sg config: %d", ret);
543 int wl1271_acx_cca_threshold(struct wl1271 *wl)
545 struct acx_energy_detection *detection;
548 wl1271_debug(DEBUG_ACX, "acx cca threshold");
550 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
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;
559 ret = wl1271_cmd_configure(wl, ACX_CCA_THRESHOLD,
560 detection, sizeof(*detection));
562 wl1271_warning("failed to set cca threshold: %d", ret);
569 int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif)
571 struct acx_beacon_broadcast *bb;
574 wl1271_debug(DEBUG_ACX, "acx bcn dtim options");
576 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
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;
588 ret = wl1271_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
590 wl1271_warning("failed to set rx config: %d", ret);
599 int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid)
601 struct acx_aid *acx_aid;
604 wl1271_debug(DEBUG_ACX, "acx aid");
606 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
612 acx_aid->role_id = wlvif->role_id;
613 acx_aid->aid = cpu_to_le16(aid);
615 ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
617 wl1271_warning("failed to set aid: %d", ret);
626 int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask)
628 struct acx_event_mask *mask;
631 wl1271_debug(DEBUG_ACX, "acx event mbox mask");
633 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
639 /* high event mask is unused */
640 mask->high_event_mask = cpu_to_le32(0xffffffff);
641 mask->event_mask = cpu_to_le32(event_mask);
643 ret = wl1271_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
644 mask, sizeof(*mask));
646 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret);
655 int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif,
656 enum acx_preamble_type preamble)
658 struct acx_preamble *acx;
661 wl1271_debug(DEBUG_ACX, "acx_set_preamble");
663 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
669 acx->role_id = wlvif->role_id;
670 acx->preamble = preamble;
672 ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
674 wl1271_warning("Setting of preamble failed: %d", ret);
683 int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif,
684 enum acx_ctsprotect_type ctsprotect)
686 struct acx_ctsprotect *acx;
689 wl1271_debug(DEBUG_ACX, "acx_set_ctsprotect");
691 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
697 acx->role_id = wlvif->role_id;
698 acx->ctsprotect = ctsprotect;
700 ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
702 wl1271_warning("Setting of ctsprotect failed: %d", ret);
711 int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats)
715 wl1271_debug(DEBUG_ACX, "acx statistics");
717 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats,
720 wl1271_warning("acx statistics failed: %d", ret);
727 int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif)
729 struct acx_rate_policy *acx;
730 struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf;
733 wl1271_debug(DEBUG_ACX, "acx rate policies");
735 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
742 wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x",
743 wlvif->basic_rate, wlvif->rate_set);
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;
752 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
754 wl1271_warning("Setting of rate policies failed: %d", ret);
758 /* configure one AP supported rate class */
759 acx->rate_policy_idx = cpu_to_le32(wlvif->sta.ap_rate_idx);
760 acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set);
761 acx->rate_policy.short_retry_limit = c->short_retry_limit;
762 acx->rate_policy.long_retry_limit = c->long_retry_limit;
763 acx->rate_policy.aflags = c->aflags;
765 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
767 wl1271_warning("Setting of rate policies failed: %d", ret);
772 * configure one rate class for basic p2p operations.
773 * (p2p packets should always go out with OFDM rates, even
774 * if we are currently connected to 11b AP)
776 acx->rate_policy_idx = cpu_to_le32(wlvif->sta.p2p_rate_idx);
777 acx->rate_policy.enabled_rates =
778 cpu_to_le32(CONF_TX_RATE_MASK_BASIC_P2P);
779 acx->rate_policy.short_retry_limit = c->short_retry_limit;
780 acx->rate_policy.long_retry_limit = c->long_retry_limit;
781 acx->rate_policy.aflags = c->aflags;
783 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
785 wl1271_warning("Setting of rate policies failed: %d", ret);
794 int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c,
797 struct acx_rate_policy *acx;
800 wl1271_debug(DEBUG_ACX, "acx ap rate policy %d rates 0x%x",
801 idx, c->enabled_rates);
803 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
809 acx->rate_policy.enabled_rates = cpu_to_le32(c->enabled_rates);
810 acx->rate_policy.short_retry_limit = c->short_retry_limit;
811 acx->rate_policy.long_retry_limit = c->long_retry_limit;
812 acx->rate_policy.aflags = c->aflags;
814 acx->rate_policy_idx = cpu_to_le32(idx);
816 ret = wl1271_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
818 wl1271_warning("Setting of ap rate policy failed: %d", ret);
827 int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif,
828 u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop)
830 struct acx_ac_cfg *acx;
833 wl1271_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
834 "aifs %d txop %d", ac, cw_min, cw_max, aifsn, txop);
836 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
843 acx->role_id = wlvif->role_id;
845 acx->cw_min = cw_min;
846 acx->cw_max = cpu_to_le16(cw_max);
848 acx->tx_op_limit = cpu_to_le16(txop);
850 ret = wl1271_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
852 wl1271_warning("acx ac cfg failed: %d", ret);
861 int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif,
862 u8 queue_id, u8 channel_type,
863 u8 tsid, u8 ps_scheme, u8 ack_policy,
864 u32 apsd_conf0, u32 apsd_conf1)
866 struct acx_tid_config *acx;
869 wl1271_debug(DEBUG_ACX, "acx tid config");
871 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
878 acx->role_id = wlvif->role_id;
879 acx->queue_id = queue_id;
880 acx->channel_type = channel_type;
882 acx->ps_scheme = ps_scheme;
883 acx->ack_policy = ack_policy;
884 acx->apsd_conf[0] = cpu_to_le32(apsd_conf0);
885 acx->apsd_conf[1] = cpu_to_le32(apsd_conf1);
887 ret = wl1271_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
889 wl1271_warning("Setting of tid config failed: %d", ret);
898 int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold)
900 struct acx_frag_threshold *acx;
904 * If the fragmentation is not configured or out of range, use the
907 if (frag_threshold > IEEE80211_MAX_FRAG_THRESHOLD)
908 frag_threshold = wl->conf.tx.frag_threshold;
910 wl1271_debug(DEBUG_ACX, "acx frag threshold: %d", frag_threshold);
912 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
919 acx->frag_threshold = cpu_to_le16((u16)frag_threshold);
920 ret = wl1271_cmd_configure(wl, ACX_FRAG_CFG, acx, sizeof(*acx));
922 wl1271_warning("Setting of frag threshold failed: %d", ret);
931 int wl1271_acx_tx_config_options(struct wl1271 *wl)
933 struct acx_tx_config_options *acx;
936 wl1271_debug(DEBUG_ACX, "acx tx config options");
938 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
945 acx->tx_compl_timeout = cpu_to_le16(wl->conf.tx.tx_compl_timeout);
946 acx->tx_compl_threshold = cpu_to_le16(wl->conf.tx.tx_compl_threshold);
947 ret = wl1271_cmd_configure(wl, ACX_TX_CONFIG_OPT, acx, sizeof(*acx));
949 wl1271_warning("Setting of tx options failed: %d", ret);
958 int wl12xx_acx_mem_cfg(struct wl1271 *wl)
960 struct wl12xx_acx_config_memory *mem_conf;
961 struct conf_memory_settings *mem;
964 wl1271_debug(DEBUG_ACX, "wl1271 mem cfg");
966 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
972 if (wl->chip.id == CHIP_ID_1283_PG20)
973 mem = &wl->conf.mem_wl128x;
975 mem = &wl->conf.mem_wl127x;
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(ACX_TX_DESCRIPTORS);
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;
989 ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
992 wl1271_warning("wl1271 mem config failed: %d", ret);
1001 int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
1003 struct wl1271_acx_host_config_bitmap *bitmap_conf;
1006 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
1012 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
1014 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
1015 bitmap_conf, sizeof(*bitmap_conf));
1017 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
1027 int wl1271_acx_init_mem_config(struct wl1271 *wl)
1031 wl->target_mem_map = kzalloc(sizeof(struct wl1271_acx_mem_map),
1033 if (!wl->target_mem_map) {
1034 wl1271_error("couldn't allocate target memory map");
1038 /* we now ask for the firmware built memory map */
1039 ret = wl1271_acx_mem_map(wl, (void *)wl->target_mem_map,
1040 sizeof(struct wl1271_acx_mem_map));
1042 wl1271_error("couldn't retrieve firmware memory map");
1043 kfree(wl->target_mem_map);
1044 wl->target_mem_map = NULL;
1048 /* initialize TX block book keeping */
1049 wl->tx_blocks_available =
1050 le32_to_cpu(wl->target_mem_map->num_tx_mem_blocks);
1051 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1052 wl->tx_blocks_available);
1057 int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
1059 struct wl1271_acx_rx_config_opt *rx_conf;
1062 wl1271_debug(DEBUG_ACX, "wl1271 rx interrupt config");
1064 rx_conf = kzalloc(sizeof(*rx_conf), GFP_KERNEL);
1070 rx_conf->threshold = cpu_to_le16(wl->conf.rx.irq_pkt_threshold);
1071 rx_conf->timeout = cpu_to_le16(wl->conf.rx.irq_timeout);
1072 rx_conf->mblk_threshold = cpu_to_le16(wl->conf.rx.irq_blk_threshold);
1073 rx_conf->queue_type = wl->conf.rx.queue_type;
1075 ret = wl1271_cmd_configure(wl, ACX_RX_CONFIG_OPT, rx_conf,
1078 wl1271_warning("wl1271 rx config opt failed: %d", ret);
1087 int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1090 struct wl1271_acx_bet_enable *acx = NULL;
1093 wl1271_debug(DEBUG_ACX, "acx bet enable");
1095 if (enable && wl->conf.conn.bet_enable == CONF_BET_MODE_DISABLE)
1098 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1104 acx->role_id = wlvif->role_id;
1105 acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE;
1106 acx->max_consecutive = wl->conf.conn.bet_max_consecutive;
1108 ret = wl1271_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
1110 wl1271_warning("acx bet enable failed: %d", ret);
1119 int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1120 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 = wlvif->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, struct wl12xx_vif *wlvif,
1183 struct wl1271_acx_keep_alive_mode *acx = NULL;
1186 wl1271_debug(DEBUG_ACX, "acx keep alive mode: %d", enable);
1188 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1194 acx->role_id = wlvif->role_id;
1195 acx->enabled = enable;
1197 ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx));
1199 wl1271_warning("acx keep alive mode failed: %d", ret);
1208 int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1209 u8 index, u8 tpl_valid)
1211 struct wl1271_acx_keep_alive_config *acx = NULL;
1214 wl1271_debug(DEBUG_ACX, "acx keep alive config");
1216 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1222 acx->role_id = wlvif->role_id;
1223 acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval);
1225 acx->tpl_validation = tpl_valid;
1226 acx->trigger = ACX_KEEP_ALIVE_NO_TX;
1228 ret = wl1271_cmd_configure(wl, ACX_SET_KEEP_ALIVE_CONFIG,
1231 wl1271_warning("acx keep alive config failed: %d", ret);
1240 int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1241 bool enable, s16 thold, u8 hyst)
1243 struct wl1271_acx_rssi_snr_trigger *acx = NULL;
1246 wl1271_debug(DEBUG_ACX, "acx rssi snr trigger");
1248 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1254 wlvif->last_rssi_event = -1;
1256 acx->role_id = wlvif->role_id;
1257 acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing);
1258 acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON;
1259 acx->type = WL1271_ACX_TRIG_TYPE_EDGE;
1261 acx->enable = WL1271_ACX_TRIG_ENABLE;
1263 acx->enable = WL1271_ACX_TRIG_DISABLE;
1265 acx->index = WL1271_ACX_TRIG_IDX_RSSI;
1266 acx->dir = WL1271_ACX_TRIG_DIR_BIDIR;
1267 acx->threshold = cpu_to_le16(thold);
1268 acx->hysteresis = hyst;
1270 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_TRIGGER, acx, sizeof(*acx));
1272 wl1271_warning("acx rssi snr trigger setting failed: %d", ret);
1281 int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl,
1282 struct wl12xx_vif *wlvif)
1284 struct wl1271_acx_rssi_snr_avg_weights *acx = NULL;
1285 struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger;
1288 wl1271_debug(DEBUG_ACX, "acx rssi snr avg weights");
1290 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1296 acx->role_id = wlvif->role_id;
1297 acx->rssi_beacon = c->avg_weight_rssi_beacon;
1298 acx->rssi_data = c->avg_weight_rssi_data;
1299 acx->snr_beacon = c->avg_weight_snr_beacon;
1300 acx->snr_data = c->avg_weight_snr_data;
1302 ret = wl1271_cmd_configure(wl, ACX_RSSI_SNR_WEIGHTS, acx, sizeof(*acx));
1304 wl1271_warning("acx rssi snr trigger weights failed: %d", ret);
1313 int wl1271_acx_set_ht_capabilities(struct wl1271 *wl,
1314 struct ieee80211_sta_ht_cap *ht_cap,
1315 bool allow_ht_operation, u8 hlid)
1317 struct wl1271_acx_ht_capabilities *acx;
1319 u32 ht_capabilites = 0;
1321 wl1271_debug(DEBUG_ACX, "acx ht capabilities setting "
1322 "sta supp: %d sta cap: %d", ht_cap->ht_supported,
1325 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1331 if (allow_ht_operation && ht_cap->ht_supported) {
1332 /* no need to translate capabilities - use the spec values */
1333 ht_capabilites = ht_cap->cap;
1336 * this bit is not employed by the spec but only by FW to
1337 * indicate peer HT support
1339 ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
1341 /* get data from A-MPDU parameters field */
1342 acx->ampdu_max_length = ht_cap->ampdu_factor;
1343 acx->ampdu_min_spacing = ht_cap->ampdu_density;
1347 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
1349 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_CAP, acx, sizeof(*acx));
1351 wl1271_warning("acx ht capabilities setting failed: %d", ret);
1360 int wl1271_acx_set_ht_information(struct wl1271 *wl,
1361 struct wl12xx_vif *wlvif,
1362 u16 ht_operation_mode)
1364 struct wl1271_acx_ht_information *acx;
1367 wl1271_debug(DEBUG_ACX, "acx ht information setting");
1369 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1375 acx->role_id = wlvif->role_id;
1376 acx->ht_protection =
1377 (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION);
1379 acx->gf_protection =
1380 !!(ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
1381 acx->ht_tx_burst_limit = 0;
1382 acx->dual_cts_protection = 0;
1384 ret = wl1271_cmd_configure(wl, ACX_HT_BSS_OPERATION, acx, sizeof(*acx));
1387 wl1271_warning("acx ht information setting failed: %d", ret);
1396 /* Configure BA session initiator/receiver parameters setting in the FW. */
1397 int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl,
1398 struct wl12xx_vif *wlvif)
1400 struct wl1271_acx_ba_initiator_policy *acx;
1403 wl1271_debug(DEBUG_ACX, "acx ba initiator policy");
1405 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1411 /* set for the current role */
1412 acx->role_id = wlvif->role_id;
1413 acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap;
1414 acx->win_size = wl->conf.ht.tx_ba_win_size;
1415 acx->inactivity_timeout = wl->conf.ht.inactivity_timeout;
1417 ret = wl1271_cmd_configure(wl,
1418 ACX_BA_SESSION_INIT_POLICY,
1422 wl1271_warning("acx ba initiator policy failed: %d", ret);
1431 /* setup BA session receiver setting in the FW. */
1432 int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index,
1433 u16 ssn, bool enable, u8 peer_hlid)
1435 struct wl1271_acx_ba_receiver_setup *acx;
1438 wl1271_debug(DEBUG_ACX, "acx ba receiver session setting");
1440 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1446 acx->hlid = peer_hlid;
1447 acx->tid = tid_index;
1448 acx->enable = enable;
1449 acx->win_size = wl->conf.ht.rx_ba_win_size;
1452 ret = wl1271_cmd_configure(wl, ACX_BA_SESSION_RX_SETUP, acx,
1455 wl1271_warning("acx ba receiver session failed: %d", ret);
1464 int wl12xx_acx_tsf_info(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1467 struct wl12xx_acx_fw_tsf_information *tsf_info;
1470 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
1476 tsf_info->role_id = wlvif->role_id;
1478 ret = wl1271_cmd_interrogate(wl, ACX_TSF_INFO,
1479 tsf_info, sizeof(*tsf_info));
1481 wl1271_warning("acx tsf info interrogate failed");
1485 *mactime = le32_to_cpu(tsf_info->current_tsf_low) |
1486 ((u64) le32_to_cpu(tsf_info->current_tsf_high) << 32);
1493 int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1496 struct wl1271_acx_ps_rx_streaming *rx_streaming;
1497 u32 conf_queues, enable_queues;
1500 wl1271_debug(DEBUG_ACX, "acx ps rx streaming");
1502 rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL);
1503 if (!rx_streaming) {
1508 conf_queues = wl->conf.rx_streaming.queues;
1510 enable_queues = conf_queues;
1514 for (i = 0; i < 8; i++) {
1516 * Skip non-changed queues, to avoid redundant acxs.
1517 * this check assumes conf.rx_streaming.queues can't
1518 * be changed while rx_streaming is enabled.
1520 if (!(conf_queues & BIT(i)))
1523 rx_streaming->role_id = wlvif->role_id;
1524 rx_streaming->tid = i;
1525 rx_streaming->enable = enable_queues & BIT(i);
1526 rx_streaming->period = wl->conf.rx_streaming.interval;
1527 rx_streaming->timeout = wl->conf.rx_streaming.interval;
1529 ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING,
1531 sizeof(*rx_streaming));
1533 wl1271_warning("acx ps rx streaming failed: %d", ret);
1538 kfree(rx_streaming);
1542 int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif)
1544 struct wl1271_acx_ap_max_tx_retry *acx = NULL;
1547 wl1271_debug(DEBUG_ACX, "acx ap max tx retry");
1549 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1553 acx->role_id = wlvif->role_id;
1554 acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries);
1556 ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx));
1558 wl1271_warning("acx ap max tx retry failed: %d", ret);
1567 int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif)
1569 struct wl1271_acx_config_ps *config_ps;
1572 wl1271_debug(DEBUG_ACX, "acx config ps");
1574 config_ps = kzalloc(sizeof(*config_ps), GFP_KERNEL);
1580 config_ps->exit_retries = wl->conf.conn.psm_exit_retries;
1581 config_ps->enter_retries = wl->conf.conn.psm_entry_retries;
1582 config_ps->null_data_rate = cpu_to_le32(wlvif->basic_rate);
1584 ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps,
1585 sizeof(*config_ps));
1588 wl1271_warning("acx config ps failed: %d", ret);
1597 int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr)
1599 struct wl1271_acx_inconnection_sta *acx = NULL;
1602 wl1271_debug(DEBUG_ACX, "acx set inconnaction sta %pM", addr);
1604 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1608 memcpy(acx->addr, addr, ETH_ALEN);
1610 ret = wl1271_cmd_configure(wl, ACX_UPDATE_INCONNECTION_STA_LIST,
1613 wl1271_warning("acx set inconnaction sta failed: %d", ret);
1622 int wl1271_acx_fm_coex(struct wl1271 *wl)
1624 struct wl1271_acx_fm_coex *acx;
1627 wl1271_debug(DEBUG_ACX, "acx fm coex setting");
1629 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1635 acx->enable = wl->conf.fm_coex.enable;
1636 acx->swallow_period = wl->conf.fm_coex.swallow_period;
1637 acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1;
1638 acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2;
1639 acx->m_divider_fref_set_1 =
1640 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1);
1641 acx->m_divider_fref_set_2 =
1642 cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2);
1643 acx->coex_pll_stabilization_time =
1644 cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time);
1645 acx->ldo_stabilization_time =
1646 cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time);
1647 acx->fm_disturbed_band_margin =
1648 wl->conf.fm_coex.fm_disturbed_band_margin;
1649 acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff;
1651 ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx));
1653 wl1271_warning("acx fm coex setting failed: %d", ret);
1662 int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl)
1664 struct wl12xx_acx_set_rate_mgmt_params *acx = NULL;
1665 struct conf_rate_policy_settings *conf = &wl->conf.rate;
1668 wl1271_debug(DEBUG_ACX, "acx set rate mgmt params");
1670 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1674 acx->index = ACX_RATE_MGMT_ALL_PARAMS;
1675 acx->rate_retry_score = cpu_to_le16(conf->rate_retry_score);
1676 acx->per_add = cpu_to_le16(conf->per_add);
1677 acx->per_th1 = cpu_to_le16(conf->per_th1);
1678 acx->per_th2 = cpu_to_le16(conf->per_th2);
1679 acx->max_per = cpu_to_le16(conf->max_per);
1680 acx->inverse_curiosity_factor = conf->inverse_curiosity_factor;
1681 acx->tx_fail_low_th = conf->tx_fail_low_th;
1682 acx->tx_fail_high_th = conf->tx_fail_high_th;
1683 acx->per_alpha_shift = conf->per_alpha_shift;
1684 acx->per_add_shift = conf->per_add_shift;
1685 acx->per_beta1_shift = conf->per_beta1_shift;
1686 acx->per_beta2_shift = conf->per_beta2_shift;
1687 acx->rate_check_up = conf->rate_check_up;
1688 acx->rate_check_down = conf->rate_check_down;
1689 memcpy(acx->rate_retry_policy, conf->rate_retry_policy,
1690 sizeof(acx->rate_retry_policy));
1692 ret = wl1271_cmd_configure(wl, ACX_SET_RATE_MGMT_PARAMS,
1695 wl1271_warning("acx set rate mgmt params failed: %d", ret);
1704 int wl12xx_acx_config_hangover(struct wl1271 *wl)
1706 struct wl12xx_acx_config_hangover *acx;
1707 struct conf_hangover_settings *conf = &wl->conf.hangover;
1710 wl1271_debug(DEBUG_ACX, "acx config hangover");
1712 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1718 acx->recover_time = cpu_to_le32(conf->recover_time);
1719 acx->hangover_period = conf->hangover_period;
1720 acx->dynamic_mode = conf->dynamic_mode;
1721 acx->early_termination_mode = conf->early_termination_mode;
1722 acx->max_period = conf->max_period;
1723 acx->min_period = conf->min_period;
1724 acx->increase_delta = conf->increase_delta;
1725 acx->decrease_delta = conf->decrease_delta;
1726 acx->quiet_time = conf->quiet_time;
1727 acx->increase_time = conf->increase_time;
1728 acx->window_size = acx->window_size;
1730 ret = wl1271_cmd_configure(wl, ACX_CONFIG_HANGOVER, acx,
1734 wl1271_warning("acx config hangover failed: %d", ret);