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
->wake_up_event
= wl
->conf
.conn
.wake_up_event
;
50 wake_up
->listen_interval
= wl
->conf
.conn
.listen_interval
;
52 ret
= wl1271_cmd_configure(wl
, ACX_WAKE_UP_CONDITIONS
,
53 wake_up
, sizeof(*wake_up
));
55 wl1271_warning("could not set wake up conditions: %d", ret
);
64 int wl1271_acx_sleep_auth(struct wl1271
*wl
, u8 sleep_auth
)
66 struct acx_sleep_auth
*auth
;
69 wl1271_debug(DEBUG_ACX
, "acx sleep auth");
71 auth
= kzalloc(sizeof(*auth
), GFP_KERNEL
);
77 auth
->sleep_auth
= sleep_auth
;
79 ret
= wl1271_cmd_configure(wl
, ACX_SLEEP_AUTH
, auth
, sizeof(*auth
));
88 int wl1271_acx_tx_power(struct wl1271
*wl
, int power
)
90 struct acx_current_tx_power
*acx
;
93 wl1271_debug(DEBUG_ACX
, "acx dot11_cur_tx_pwr %d", power
);
95 if (power
< 0 || power
> 25)
98 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
104 acx
->current_tx_power
= power
* 10;
106 ret
= wl1271_cmd_configure(wl
, DOT11_CUR_TX_PWR
, acx
, sizeof(*acx
));
108 wl1271_warning("configure of tx power failed: %d", ret
);
117 int wl1271_acx_feature_cfg(struct wl1271
*wl
)
119 struct acx_feature_config
*feature
;
122 wl1271_debug(DEBUG_ACX
, "acx feature cfg");
124 feature
= kzalloc(sizeof(*feature
), GFP_KERNEL
);
130 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
131 feature
->data_flow_options
= 0;
132 feature
->options
= 0;
134 ret
= wl1271_cmd_configure(wl
, ACX_FEATURE_CFG
,
135 feature
, sizeof(*feature
));
137 wl1271_error("Couldnt set HW encryption");
146 int wl1271_acx_mem_map(struct wl1271
*wl
, struct acx_header
*mem_map
,
151 wl1271_debug(DEBUG_ACX
, "acx mem map");
153 ret
= wl1271_cmd_interrogate(wl
, ACX_MEM_MAP
, mem_map
, len
);
160 int wl1271_acx_rx_msdu_life_time(struct wl1271
*wl
)
162 struct acx_rx_msdu_lifetime
*acx
;
165 wl1271_debug(DEBUG_ACX
, "acx rx msdu life time");
167 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
173 acx
->lifetime
= cpu_to_le32(wl
->conf
.rx
.rx_msdu_life_time
);
174 ret
= wl1271_cmd_configure(wl
, DOT11_RX_MSDU_LIFE_TIME
,
177 wl1271_warning("failed to set rx msdu life time: %d", ret
);
186 int wl1271_acx_rx_config(struct wl1271
*wl
, u32 config
, u32 filter
)
188 struct acx_rx_config
*rx_config
;
191 wl1271_debug(DEBUG_ACX
, "acx rx config");
193 rx_config
= kzalloc(sizeof(*rx_config
), GFP_KERNEL
);
199 rx_config
->config_options
= cpu_to_le32(config
);
200 rx_config
->filter_options
= cpu_to_le32(filter
);
202 ret
= wl1271_cmd_configure(wl
, ACX_RX_CFG
,
203 rx_config
, sizeof(*rx_config
));
205 wl1271_warning("failed to set rx config: %d", ret
);
214 int wl1271_acx_pd_threshold(struct wl1271
*wl
)
216 struct acx_packet_detection
*pd
;
219 wl1271_debug(DEBUG_ACX
, "acx data pd threshold");
221 pd
= kzalloc(sizeof(*pd
), GFP_KERNEL
);
227 pd
->threshold
= cpu_to_le32(wl
->conf
.rx
.packet_detection_threshold
);
229 ret
= wl1271_cmd_configure(wl
, ACX_PD_THRESHOLD
, pd
, sizeof(*pd
));
231 wl1271_warning("failed to set pd threshold: %d", ret
);
240 int wl1271_acx_slot(struct wl1271
*wl
, enum acx_slot_type slot_time
)
242 struct acx_slot
*slot
;
245 wl1271_debug(DEBUG_ACX
, "acx slot");
247 slot
= kzalloc(sizeof(*slot
), GFP_KERNEL
);
253 slot
->wone_index
= STATION_WONE_INDEX
;
254 slot
->slot_time
= slot_time
;
256 ret
= wl1271_cmd_configure(wl
, ACX_SLOT
, slot
, sizeof(*slot
));
258 wl1271_warning("failed to set slot time: %d", ret
);
267 int wl1271_acx_group_address_tbl(struct wl1271
*wl
, bool enable
,
268 void *mc_list
, u32 mc_list_len
)
270 struct acx_dot11_grp_addr_tbl
*acx
;
273 wl1271_debug(DEBUG_ACX
, "acx group address tbl");
275 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
282 acx
->enabled
= enable
;
283 acx
->num_groups
= mc_list_len
;
284 memcpy(acx
->mac_table
, mc_list
, mc_list_len
* ETH_ALEN
);
286 ret
= wl1271_cmd_configure(wl
, DOT11_GROUP_ADDRESS_TBL
,
289 wl1271_warning("failed to set group addr table: %d", ret
);
298 int wl1271_acx_service_period_timeout(struct wl1271
*wl
)
300 struct acx_rx_timeout
*rx_timeout
;
303 rx_timeout
= kzalloc(sizeof(*rx_timeout
), GFP_KERNEL
);
309 wl1271_debug(DEBUG_ACX
, "acx service period timeout");
311 rx_timeout
->ps_poll_timeout
= cpu_to_le16(wl
->conf
.rx
.ps_poll_timeout
);
312 rx_timeout
->upsd_timeout
= cpu_to_le16(wl
->conf
.rx
.upsd_timeout
);
314 ret
= wl1271_cmd_configure(wl
, ACX_SERVICE_PERIOD_TIMEOUT
,
315 rx_timeout
, sizeof(*rx_timeout
));
317 wl1271_warning("failed to set service period timeout: %d",
327 int wl1271_acx_rts_threshold(struct wl1271
*wl
, u32 rts_threshold
)
329 struct acx_rts_threshold
*rts
;
333 * If the RTS threshold is not configured or out of range, use the
336 if (rts_threshold
> IEEE80211_MAX_RTS_THRESHOLD
)
337 rts_threshold
= wl
->conf
.rx
.rts_threshold
;
339 wl1271_debug(DEBUG_ACX
, "acx rts threshold: %d", rts_threshold
);
341 rts
= kzalloc(sizeof(*rts
), GFP_KERNEL
);
347 rts
->threshold
= cpu_to_le16((u16
)rts_threshold
);
349 ret
= wl1271_cmd_configure(wl
, DOT11_RTS_THRESHOLD
, rts
, sizeof(*rts
));
351 wl1271_warning("failed to set rts threshold: %d", ret
);
360 int wl1271_acx_dco_itrim_params(struct wl1271
*wl
)
362 struct acx_dco_itrim_params
*dco
;
363 struct conf_itrim_settings
*c
= &wl
->conf
.itrim
;
366 wl1271_debug(DEBUG_ACX
, "acx dco itrim parameters");
368 dco
= kzalloc(sizeof(*dco
), GFP_KERNEL
);
374 dco
->enable
= c
->enable
;
375 dco
->timeout
= cpu_to_le32(c
->timeout
);
377 ret
= wl1271_cmd_configure(wl
, ACX_SET_DCO_ITRIM_PARAMS
,
380 wl1271_warning("failed to set dco itrim parameters: %d", ret
);
389 int wl1271_acx_beacon_filter_opt(struct wl1271
*wl
, bool enable_filter
)
391 struct acx_beacon_filter_option
*beacon_filter
= NULL
;
394 wl1271_debug(DEBUG_ACX
, "acx beacon filter opt");
397 wl
->conf
.conn
.bcn_filt_mode
== CONF_BCN_FILT_MODE_DISABLED
)
400 beacon_filter
= kzalloc(sizeof(*beacon_filter
), GFP_KERNEL
);
401 if (!beacon_filter
) {
406 beacon_filter
->enable
= enable_filter
;
409 * When set to zero, and the filter is enabled, beacons
410 * without the unicast TIM bit set are dropped.
412 beacon_filter
->max_num_beacons
= 0;
414 ret
= wl1271_cmd_configure(wl
, ACX_BEACON_FILTER_OPT
,
415 beacon_filter
, sizeof(*beacon_filter
));
417 wl1271_warning("failed to set beacon filter opt: %d", ret
);
422 kfree(beacon_filter
);
426 int wl1271_acx_beacon_filter_table(struct wl1271
*wl
)
428 struct acx_beacon_filter_ie_table
*ie_table
;
431 bool vendor_spec
= false;
433 wl1271_debug(DEBUG_ACX
, "acx beacon filter table");
435 ie_table
= kzalloc(sizeof(*ie_table
), GFP_KERNEL
);
441 /* configure default beacon pass-through rules */
442 ie_table
->num_ie
= 0;
443 for (i
= 0; i
< wl
->conf
.conn
.bcn_filt_ie_count
; i
++) {
444 struct conf_bcn_filt_rule
*r
= &(wl
->conf
.conn
.bcn_filt_ie
[i
]);
445 ie_table
->table
[idx
++] = r
->ie
;
446 ie_table
->table
[idx
++] = r
->rule
;
448 if (r
->ie
== WLAN_EID_VENDOR_SPECIFIC
) {
449 /* only one vendor specific ie allowed */
453 /* for vendor specific rules configure the
455 memcpy(&(ie_table
->table
[idx
]), r
->oui
,
456 CONF_BCN_IE_OUI_LEN
);
457 idx
+= CONF_BCN_IE_OUI_LEN
;
458 ie_table
->table
[idx
++] = r
->type
;
459 memcpy(&(ie_table
->table
[idx
]), r
->version
,
460 CONF_BCN_IE_VER_LEN
);
461 idx
+= CONF_BCN_IE_VER_LEN
;
468 ret
= wl1271_cmd_configure(wl
, ACX_BEACON_FILTER_TABLE
,
469 ie_table
, sizeof(*ie_table
));
471 wl1271_warning("failed to set beacon filter table: %d", ret
);
480 #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff
482 int wl1271_acx_conn_monit_params(struct wl1271
*wl
, bool enable
)
484 struct acx_conn_monit_params
*acx
;
485 u32 threshold
= ACX_CONN_MONIT_DISABLE_VALUE
;
486 u32 timeout
= ACX_CONN_MONIT_DISABLE_VALUE
;
489 wl1271_debug(DEBUG_ACX
, "acx connection monitor parameters: %s",
490 enable
? "enabled" : "disabled");
492 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
499 threshold
= wl
->conf
.conn
.synch_fail_thold
;
500 timeout
= wl
->conf
.conn
.bss_lose_timeout
;
503 acx
->synch_fail_thold
= cpu_to_le32(threshold
);
504 acx
->bss_lose_timeout
= cpu_to_le32(timeout
);
506 ret
= wl1271_cmd_configure(wl
, ACX_CONN_MONIT_PARAMS
,
509 wl1271_warning("failed to set connection monitor "
510 "parameters: %d", ret
);
520 int wl1271_acx_sg_enable(struct wl1271
*wl
, bool enable
)
522 struct acx_bt_wlan_coex
*pta
;
525 wl1271_debug(DEBUG_ACX
, "acx sg enable");
527 pta
= kzalloc(sizeof(*pta
), GFP_KERNEL
);
534 pta
->enable
= wl
->conf
.sg
.state
;
536 pta
->enable
= CONF_SG_DISABLE
;
538 ret
= wl1271_cmd_configure(wl
, ACX_SG_ENABLE
, pta
, sizeof(*pta
));
540 wl1271_warning("failed to set softgemini enable: %d", ret
);
549 int wl1271_acx_sta_sg_cfg(struct wl1271
*wl
)
551 struct acx_sta_bt_wlan_coex_param
*param
;
552 struct conf_sg_settings
*c
= &wl
->conf
.sg
;
555 wl1271_debug(DEBUG_ACX
, "acx sg sta cfg");
557 param
= kzalloc(sizeof(*param
), GFP_KERNEL
);
563 /* BT-WLAN coext parameters */
564 for (i
= 0; i
< CONF_SG_STA_PARAMS_MAX
; i
++)
565 param
->params
[i
] = cpu_to_le32(c
->sta_params
[i
]);
566 param
->param_idx
= CONF_SG_PARAMS_ALL
;
568 ret
= wl1271_cmd_configure(wl
, ACX_SG_CFG
, param
, sizeof(*param
));
570 wl1271_warning("failed to set sg config: %d", ret
);
579 int wl1271_acx_ap_sg_cfg(struct wl1271
*wl
)
581 struct acx_ap_bt_wlan_coex_param
*param
;
582 struct conf_sg_settings
*c
= &wl
->conf
.sg
;
585 wl1271_debug(DEBUG_ACX
, "acx sg ap cfg");
587 param
= kzalloc(sizeof(*param
), GFP_KERNEL
);
593 /* BT-WLAN coext parameters */
594 for (i
= 0; i
< CONF_SG_AP_PARAMS_MAX
; i
++)
595 param
->params
[i
] = cpu_to_le32(c
->ap_params
[i
]);
596 param
->param_idx
= CONF_SG_PARAMS_ALL
;
598 ret
= wl1271_cmd_configure(wl
, ACX_SG_CFG
, param
, sizeof(*param
));
600 wl1271_warning("failed to set sg config: %d", ret
);
609 int wl1271_acx_cca_threshold(struct wl1271
*wl
)
611 struct acx_energy_detection
*detection
;
614 wl1271_debug(DEBUG_ACX
, "acx cca threshold");
616 detection
= kzalloc(sizeof(*detection
), GFP_KERNEL
);
622 detection
->rx_cca_threshold
= cpu_to_le16(wl
->conf
.rx
.rx_cca_threshold
);
623 detection
->tx_energy_detection
= wl
->conf
.tx
.tx_energy_detection
;
625 ret
= wl1271_cmd_configure(wl
, ACX_CCA_THRESHOLD
,
626 detection
, sizeof(*detection
));
628 wl1271_warning("failed to set cca threshold: %d", ret
);
637 int wl1271_acx_bcn_dtim_options(struct wl1271
*wl
)
639 struct acx_beacon_broadcast
*bb
;
642 wl1271_debug(DEBUG_ACX
, "acx bcn dtim options");
644 bb
= kzalloc(sizeof(*bb
), GFP_KERNEL
);
650 bb
->beacon_rx_timeout
= cpu_to_le16(wl
->conf
.conn
.beacon_rx_timeout
);
651 bb
->broadcast_timeout
= cpu_to_le16(wl
->conf
.conn
.broadcast_timeout
);
652 bb
->rx_broadcast_in_ps
= wl
->conf
.conn
.rx_broadcast_in_ps
;
653 bb
->ps_poll_threshold
= wl
->conf
.conn
.ps_poll_threshold
;
655 ret
= wl1271_cmd_configure(wl
, ACX_BCN_DTIM_OPTIONS
, bb
, sizeof(*bb
));
657 wl1271_warning("failed to set rx config: %d", ret
);
666 int wl1271_acx_aid(struct wl1271
*wl
, u16 aid
)
668 struct acx_aid
*acx_aid
;
671 wl1271_debug(DEBUG_ACX
, "acx aid");
673 acx_aid
= kzalloc(sizeof(*acx_aid
), GFP_KERNEL
);
679 acx_aid
->aid
= cpu_to_le16(aid
);
681 ret
= wl1271_cmd_configure(wl
, ACX_AID
, acx_aid
, sizeof(*acx_aid
));
683 wl1271_warning("failed to set aid: %d", ret
);
692 int wl1271_acx_event_mbox_mask(struct wl1271
*wl
, u32 event_mask
)
694 struct acx_event_mask
*mask
;
697 wl1271_debug(DEBUG_ACX
, "acx event mbox mask");
699 mask
= kzalloc(sizeof(*mask
), GFP_KERNEL
);
705 /* high event mask is unused */
706 mask
->high_event_mask
= cpu_to_le32(0xffffffff);
707 mask
->event_mask
= cpu_to_le32(event_mask
);
709 ret
= wl1271_cmd_configure(wl
, ACX_EVENT_MBOX_MASK
,
710 mask
, sizeof(*mask
));
712 wl1271_warning("failed to set acx_event_mbox_mask: %d", ret
);
721 int wl1271_acx_set_preamble(struct wl1271
*wl
, enum acx_preamble_type preamble
)
723 struct acx_preamble
*acx
;
726 wl1271_debug(DEBUG_ACX
, "acx_set_preamble");
728 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
734 acx
->preamble
= preamble
;
736 ret
= wl1271_cmd_configure(wl
, ACX_PREAMBLE_TYPE
, acx
, sizeof(*acx
));
738 wl1271_warning("Setting of preamble failed: %d", ret
);
747 int wl1271_acx_cts_protect(struct wl1271
*wl
,
748 enum acx_ctsprotect_type ctsprotect
)
750 struct acx_ctsprotect
*acx
;
753 wl1271_debug(DEBUG_ACX
, "acx_set_ctsprotect");
755 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
761 acx
->ctsprotect
= ctsprotect
;
763 ret
= wl1271_cmd_configure(wl
, ACX_CTS_PROTECTION
, acx
, sizeof(*acx
));
765 wl1271_warning("Setting of ctsprotect failed: %d", ret
);
774 int wl1271_acx_statistics(struct wl1271
*wl
, struct acx_statistics
*stats
)
778 wl1271_debug(DEBUG_ACX
, "acx statistics");
780 ret
= wl1271_cmd_interrogate(wl
, ACX_STATISTICS
, stats
,
783 wl1271_warning("acx statistics failed: %d", ret
);
790 int wl1271_acx_sta_rate_policies(struct wl1271
*wl
)
792 struct acx_sta_rate_policy
*acx
;
793 struct conf_tx_rate_class
*c
= &wl
->conf
.tx
.sta_rc_conf
;
797 wl1271_debug(DEBUG_ACX
, "acx rate policies");
799 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
806 /* configure one basic rate class */
807 idx
= ACX_TX_BASIC_RATE
;
808 acx
->rate_class
[idx
].enabled_rates
= cpu_to_le32(wl
->basic_rate
);
809 acx
->rate_class
[idx
].short_retry_limit
= c
->short_retry_limit
;
810 acx
->rate_class
[idx
].long_retry_limit
= c
->long_retry_limit
;
811 acx
->rate_class
[idx
].aflags
= c
->aflags
;
813 /* configure one AP supported rate class */
814 idx
= ACX_TX_AP_FULL_RATE
;
815 acx
->rate_class
[idx
].enabled_rates
= cpu_to_le32(wl
->rate_set
);
816 acx
->rate_class
[idx
].short_retry_limit
= c
->short_retry_limit
;
817 acx
->rate_class
[idx
].long_retry_limit
= c
->long_retry_limit
;
818 acx
->rate_class
[idx
].aflags
= c
->aflags
;
820 acx
->rate_class_cnt
= cpu_to_le32(ACX_TX_RATE_POLICY_CNT
);
822 wl1271_debug(DEBUG_ACX
, "basic_rate: 0x%x, full_rate: 0x%x",
823 acx
->rate_class
[ACX_TX_BASIC_RATE
].enabled_rates
,
824 acx
->rate_class
[ACX_TX_AP_FULL_RATE
].enabled_rates
);
826 ret
= wl1271_cmd_configure(wl
, ACX_RATE_POLICY
, acx
, sizeof(*acx
));
828 wl1271_warning("Setting of rate policies failed: %d", ret
);
837 int wl1271_acx_ap_rate_policy(struct wl1271
*wl
, struct conf_tx_rate_class
*c
,
840 struct acx_ap_rate_policy
*acx
;
843 wl1271_debug(DEBUG_ACX
, "acx ap rate policy %d rates 0x%x",
844 idx
, c
->enabled_rates
);
846 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
852 acx
->rate_policy
.enabled_rates
= cpu_to_le32(c
->enabled_rates
);
853 acx
->rate_policy
.short_retry_limit
= c
->short_retry_limit
;
854 acx
->rate_policy
.long_retry_limit
= c
->long_retry_limit
;
855 acx
->rate_policy
.aflags
= c
->aflags
;
857 acx
->rate_policy_idx
= cpu_to_le32(idx
);
859 ret
= wl1271_cmd_configure(wl
, ACX_RATE_POLICY
, acx
, sizeof(*acx
));
861 wl1271_warning("Setting of ap rate policy failed: %d", ret
);
870 int wl1271_acx_ac_cfg(struct wl1271
*wl
, u8 ac
, u8 cw_min
, u16 cw_max
,
873 struct acx_ac_cfg
*acx
;
876 wl1271_debug(DEBUG_ACX
, "acx ac cfg %d cw_ming %d cw_max %d "
877 "aifs %d txop %d", ac
, cw_min
, cw_max
, aifsn
, txop
);
879 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
887 acx
->cw_min
= cw_min
;
888 acx
->cw_max
= cpu_to_le16(cw_max
);
890 acx
->tx_op_limit
= cpu_to_le16(txop
);
892 ret
= wl1271_cmd_configure(wl
, ACX_AC_CFG
, acx
, sizeof(*acx
));
894 wl1271_warning("acx ac cfg failed: %d", ret
);
903 int wl1271_acx_tid_cfg(struct wl1271
*wl
, u8 queue_id
, u8 channel_type
,
904 u8 tsid
, u8 ps_scheme
, u8 ack_policy
,
905 u32 apsd_conf0
, u32 apsd_conf1
)
907 struct acx_tid_config
*acx
;
910 wl1271_debug(DEBUG_ACX
, "acx tid config");
912 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
919 acx
->queue_id
= queue_id
;
920 acx
->channel_type
= channel_type
;
922 acx
->ps_scheme
= ps_scheme
;
923 acx
->ack_policy
= ack_policy
;
924 acx
->apsd_conf
[0] = cpu_to_le32(apsd_conf0
);
925 acx
->apsd_conf
[1] = cpu_to_le32(apsd_conf1
);
927 ret
= wl1271_cmd_configure(wl
, ACX_TID_CFG
, acx
, sizeof(*acx
));
929 wl1271_warning("Setting of tid config failed: %d", ret
);
938 int wl1271_acx_frag_threshold(struct wl1271
*wl
, u32 frag_threshold
)
940 struct acx_frag_threshold
*acx
;
944 * If the fragmentation is not configured or out of range, use the
947 if (frag_threshold
> IEEE80211_MAX_FRAG_THRESHOLD
)
948 frag_threshold
= wl
->conf
.tx
.frag_threshold
;
950 wl1271_debug(DEBUG_ACX
, "acx frag threshold: %d", frag_threshold
);
952 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
959 acx
->frag_threshold
= cpu_to_le16((u16
)frag_threshold
);
960 ret
= wl1271_cmd_configure(wl
, ACX_FRAG_CFG
, acx
, sizeof(*acx
));
962 wl1271_warning("Setting of frag threshold failed: %d", ret
);
971 int wl1271_acx_tx_config_options(struct wl1271
*wl
)
973 struct acx_tx_config_options
*acx
;
976 wl1271_debug(DEBUG_ACX
, "acx tx config options");
978 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
985 acx
->tx_compl_timeout
= cpu_to_le16(wl
->conf
.tx
.tx_compl_timeout
);
986 acx
->tx_compl_threshold
= cpu_to_le16(wl
->conf
.tx
.tx_compl_threshold
);
987 ret
= wl1271_cmd_configure(wl
, ACX_TX_CONFIG_OPT
, acx
, sizeof(*acx
));
989 wl1271_warning("Setting of tx options failed: %d", ret
);
998 int wl1271_acx_ap_mem_cfg(struct wl1271
*wl
)
1000 struct wl1271_acx_ap_config_memory
*mem_conf
;
1001 struct conf_memory_settings
*mem
;
1004 wl1271_debug(DEBUG_ACX
, "wl1271 mem cfg");
1006 mem_conf
= kzalloc(sizeof(*mem_conf
), GFP_KERNEL
);
1012 if (wl
->chip
.id
== CHIP_ID_1283_PG20
)
1014 * FIXME: The 128x AP FW does not yet support dynamic memory.
1015 * Use the base memory configuration for 128x for now. This
1016 * should be fine tuned in the future.
1018 mem
= &wl
->conf
.mem_wl128x
;
1020 mem
= &wl
->conf
.mem_wl127x
;
1023 mem_conf
->num_stations
= mem
->num_stations
;
1024 mem_conf
->rx_mem_block_num
= mem
->rx_block_num
;
1025 mem_conf
->tx_min_mem_block_num
= mem
->tx_min_block_num
;
1026 mem_conf
->num_ssid_profiles
= mem
->ssid_profiles
;
1027 mem_conf
->total_tx_descriptors
= cpu_to_le32(ACX_TX_DESCRIPTORS
);
1029 ret
= wl1271_cmd_configure(wl
, ACX_MEM_CFG
, mem_conf
,
1032 wl1271_warning("wl1271 mem config failed: %d", ret
);
1041 int wl1271_acx_sta_mem_cfg(struct wl1271
*wl
)
1043 struct wl1271_acx_sta_config_memory
*mem_conf
;
1044 struct conf_memory_settings
*mem
;
1047 wl1271_debug(DEBUG_ACX
, "wl1271 mem cfg");
1049 mem_conf
= kzalloc(sizeof(*mem_conf
), GFP_KERNEL
);
1055 if (wl
->chip
.id
== CHIP_ID_1283_PG20
)
1056 mem
= &wl
->conf
.mem_wl128x
;
1058 mem
= &wl
->conf
.mem_wl127x
;
1061 mem_conf
->num_stations
= mem
->num_stations
;
1062 mem_conf
->rx_mem_block_num
= mem
->rx_block_num
;
1063 mem_conf
->tx_min_mem_block_num
= mem
->tx_min_block_num
;
1064 mem_conf
->num_ssid_profiles
= mem
->ssid_profiles
;
1065 mem_conf
->total_tx_descriptors
= cpu_to_le32(ACX_TX_DESCRIPTORS
);
1066 mem_conf
->dyn_mem_enable
= mem
->dynamic_memory
;
1067 mem_conf
->tx_free_req
= mem
->min_req_tx_blocks
;
1068 mem_conf
->rx_free_req
= mem
->min_req_rx_blocks
;
1069 mem_conf
->tx_min
= mem
->tx_min
;
1070 mem_conf
->fwlog_blocks
= wl
->conf
.fwlog
.mem_blocks
;
1072 ret
= wl1271_cmd_configure(wl
, ACX_MEM_CFG
, mem_conf
,
1075 wl1271_warning("wl1271 mem config failed: %d", ret
);
1084 int wl1271_acx_host_if_cfg_bitmap(struct wl1271
*wl
, u32 host_cfg_bitmap
)
1086 struct wl1271_acx_host_config_bitmap
*bitmap_conf
;
1089 bitmap_conf
= kzalloc(sizeof(*bitmap_conf
), GFP_KERNEL
);
1095 bitmap_conf
->host_cfg_bitmap
= cpu_to_le32(host_cfg_bitmap
);
1097 ret
= wl1271_cmd_configure(wl
, ACX_HOST_IF_CFG_BITMAP
,
1098 bitmap_conf
, sizeof(*bitmap_conf
));
1100 wl1271_warning("wl1271 bitmap config opt failed: %d", ret
);
1110 int wl1271_acx_init_mem_config(struct wl1271
*wl
)
1114 wl
->target_mem_map
= kzalloc(sizeof(struct wl1271_acx_mem_map
),
1116 if (!wl
->target_mem_map
) {
1117 wl1271_error("couldn't allocate target memory map");
1121 /* we now ask for the firmware built memory map */
1122 ret
= wl1271_acx_mem_map(wl
, (void *)wl
->target_mem_map
,
1123 sizeof(struct wl1271_acx_mem_map
));
1125 wl1271_error("couldn't retrieve firmware memory map");
1126 kfree(wl
->target_mem_map
);
1127 wl
->target_mem_map
= NULL
;
1131 /* initialize TX block book keeping */
1132 wl
->tx_blocks_available
=
1133 le32_to_cpu(wl
->target_mem_map
->num_tx_mem_blocks
);
1134 wl1271_debug(DEBUG_TX
, "available tx blocks: %d",
1135 wl
->tx_blocks_available
);
1140 int wl1271_acx_init_rx_interrupt(struct wl1271
*wl
)
1142 struct wl1271_acx_rx_config_opt
*rx_conf
;
1145 wl1271_debug(DEBUG_ACX
, "wl1271 rx interrupt config");
1147 rx_conf
= kzalloc(sizeof(*rx_conf
), GFP_KERNEL
);
1153 rx_conf
->threshold
= cpu_to_le16(wl
->conf
.rx
.irq_pkt_threshold
);
1154 rx_conf
->timeout
= cpu_to_le16(wl
->conf
.rx
.irq_timeout
);
1155 rx_conf
->mblk_threshold
= cpu_to_le16(wl
->conf
.rx
.irq_blk_threshold
);
1156 rx_conf
->queue_type
= wl
->conf
.rx
.queue_type
;
1158 ret
= wl1271_cmd_configure(wl
, ACX_RX_CONFIG_OPT
, rx_conf
,
1161 wl1271_warning("wl1271 rx config opt failed: %d", ret
);
1170 int wl1271_acx_bet_enable(struct wl1271
*wl
, bool enable
)
1172 struct wl1271_acx_bet_enable
*acx
= NULL
;
1175 wl1271_debug(DEBUG_ACX
, "acx bet enable");
1177 if (enable
&& wl
->conf
.conn
.bet_enable
== CONF_BET_MODE_DISABLE
)
1180 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1186 acx
->enable
= enable
? CONF_BET_MODE_ENABLE
: CONF_BET_MODE_DISABLE
;
1187 acx
->max_consecutive
= wl
->conf
.conn
.bet_max_consecutive
;
1189 ret
= wl1271_cmd_configure(wl
, ACX_BET_ENABLE
, acx
, sizeof(*acx
));
1191 wl1271_warning("acx bet enable failed: %d", ret
);
1200 int wl1271_acx_arp_ip_filter(struct wl1271
*wl
, u8 enable
, __be32 address
)
1202 struct wl1271_acx_arp_filter
*acx
;
1205 wl1271_debug(DEBUG_ACX
, "acx arp ip filter, enable: %d", enable
);
1207 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1213 acx
->version
= ACX_IPV4_VERSION
;
1214 acx
->enable
= enable
;
1217 memcpy(acx
->address
, &address
, ACX_IPV4_ADDR_SIZE
);
1219 ret
= wl1271_cmd_configure(wl
, ACX_ARP_IP_FILTER
,
1222 wl1271_warning("failed to set arp ip filter: %d", ret
);
1231 int wl1271_acx_pm_config(struct wl1271
*wl
)
1233 struct wl1271_acx_pm_config
*acx
= NULL
;
1234 struct conf_pm_config_settings
*c
= &wl
->conf
.pm_config
;
1237 wl1271_debug(DEBUG_ACX
, "acx pm config");
1239 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1245 acx
->host_clk_settling_time
= cpu_to_le32(c
->host_clk_settling_time
);
1246 acx
->host_fast_wakeup_support
= c
->host_fast_wakeup_support
;
1248 ret
= wl1271_cmd_configure(wl
, ACX_PM_CONFIG
, acx
, sizeof(*acx
));
1250 wl1271_warning("acx pm config failed: %d", ret
);
1259 int wl1271_acx_keep_alive_mode(struct wl1271
*wl
, bool enable
)
1261 struct wl1271_acx_keep_alive_mode
*acx
= NULL
;
1264 wl1271_debug(DEBUG_ACX
, "acx keep alive mode: %d", enable
);
1266 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1272 acx
->enabled
= enable
;
1274 ret
= wl1271_cmd_configure(wl
, ACX_KEEP_ALIVE_MODE
, acx
, sizeof(*acx
));
1276 wl1271_warning("acx keep alive mode failed: %d", ret
);
1285 int wl1271_acx_keep_alive_config(struct wl1271
*wl
, u8 index
, u8 tpl_valid
)
1287 struct wl1271_acx_keep_alive_config
*acx
= NULL
;
1290 wl1271_debug(DEBUG_ACX
, "acx keep alive config");
1292 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1298 acx
->period
= cpu_to_le32(wl
->conf
.conn
.keep_alive_interval
);
1300 acx
->tpl_validation
= tpl_valid
;
1301 acx
->trigger
= ACX_KEEP_ALIVE_NO_TX
;
1303 ret
= wl1271_cmd_configure(wl
, ACX_SET_KEEP_ALIVE_CONFIG
,
1306 wl1271_warning("acx keep alive config failed: %d", ret
);
1315 int wl1271_acx_rssi_snr_trigger(struct wl1271
*wl
, bool enable
,
1318 struct wl1271_acx_rssi_snr_trigger
*acx
= NULL
;
1321 wl1271_debug(DEBUG_ACX
, "acx rssi snr trigger");
1323 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1329 wl
->last_rssi_event
= -1;
1331 acx
->pacing
= cpu_to_le16(wl
->conf
.roam_trigger
.trigger_pacing
);
1332 acx
->metric
= WL1271_ACX_TRIG_METRIC_RSSI_BEACON
;
1333 acx
->type
= WL1271_ACX_TRIG_TYPE_EDGE
;
1335 acx
->enable
= WL1271_ACX_TRIG_ENABLE
;
1337 acx
->enable
= WL1271_ACX_TRIG_DISABLE
;
1339 acx
->index
= WL1271_ACX_TRIG_IDX_RSSI
;
1340 acx
->dir
= WL1271_ACX_TRIG_DIR_BIDIR
;
1341 acx
->threshold
= cpu_to_le16(thold
);
1342 acx
->hysteresis
= hyst
;
1344 ret
= wl1271_cmd_configure(wl
, ACX_RSSI_SNR_TRIGGER
, acx
, sizeof(*acx
));
1346 wl1271_warning("acx rssi snr trigger setting failed: %d", ret
);
1355 int wl1271_acx_rssi_snr_avg_weights(struct wl1271
*wl
)
1357 struct wl1271_acx_rssi_snr_avg_weights
*acx
= NULL
;
1358 struct conf_roam_trigger_settings
*c
= &wl
->conf
.roam_trigger
;
1361 wl1271_debug(DEBUG_ACX
, "acx rssi snr avg weights");
1363 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1369 acx
->rssi_beacon
= c
->avg_weight_rssi_beacon
;
1370 acx
->rssi_data
= c
->avg_weight_rssi_data
;
1371 acx
->snr_beacon
= c
->avg_weight_snr_beacon
;
1372 acx
->snr_data
= c
->avg_weight_snr_data
;
1374 ret
= wl1271_cmd_configure(wl
, ACX_RSSI_SNR_WEIGHTS
, acx
, sizeof(*acx
));
1376 wl1271_warning("acx rssi snr trigger weights failed: %d", ret
);
1385 int wl1271_acx_set_ht_capabilities(struct wl1271
*wl
,
1386 struct ieee80211_sta_ht_cap
*ht_cap
,
1387 bool allow_ht_operation
)
1389 struct wl1271_acx_ht_capabilities
*acx
;
1390 u8 mac_address
[ETH_ALEN
] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1392 u32 ht_capabilites
= 0;
1394 wl1271_debug(DEBUG_ACX
, "acx ht capabilities setting");
1396 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1402 /* Allow HT Operation ? */
1403 if (allow_ht_operation
) {
1405 WL1271_ACX_FW_CAP_HT_OPERATION
;
1406 if (ht_cap
->cap
& IEEE80211_HT_CAP_GRN_FLD
)
1408 WL1271_ACX_FW_CAP_GREENFIELD_FRAME_FORMAT
;
1409 if (ht_cap
->cap
& IEEE80211_HT_CAP_SGI_20
)
1411 WL1271_ACX_FW_CAP_SHORT_GI_FOR_20MHZ_PACKETS
;
1412 if (ht_cap
->cap
& IEEE80211_HT_CAP_LSIG_TXOP_PROT
)
1414 WL1271_ACX_FW_CAP_LSIG_TXOP_PROTECTION
;
1416 /* get data from A-MPDU parameters field */
1417 acx
->ampdu_max_length
= ht_cap
->ampdu_factor
;
1418 acx
->ampdu_min_spacing
= ht_cap
->ampdu_density
;
1421 memcpy(acx
->mac_address
, mac_address
, ETH_ALEN
);
1422 acx
->ht_capabilites
= cpu_to_le32(ht_capabilites
);
1424 ret
= wl1271_cmd_configure(wl
, ACX_PEER_HT_CAP
, acx
, sizeof(*acx
));
1426 wl1271_warning("acx ht capabilities setting failed: %d", ret
);
1435 int wl1271_acx_set_ht_information(struct wl1271
*wl
,
1436 u16 ht_operation_mode
)
1438 struct wl1271_acx_ht_information
*acx
;
1441 wl1271_debug(DEBUG_ACX
, "acx ht information setting");
1443 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1449 acx
->ht_protection
=
1450 (u8
)(ht_operation_mode
& IEEE80211_HT_OP_MODE_PROTECTION
);
1452 acx
->gf_protection
=
1453 !!(ht_operation_mode
& IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT
);
1454 acx
->ht_tx_burst_limit
= 0;
1455 acx
->dual_cts_protection
= 0;
1457 ret
= wl1271_cmd_configure(wl
, ACX_HT_BSS_OPERATION
, acx
, sizeof(*acx
));
1460 wl1271_warning("acx ht information setting failed: %d", ret
);
1469 /* Configure BA session initiator/receiver parameters setting in the FW. */
1470 int wl1271_acx_set_ba_session(struct wl1271
*wl
,
1471 enum ieee80211_back_parties direction
,
1472 u8 tid_index
, u8 policy
)
1474 struct wl1271_acx_ba_session_policy
*acx
;
1477 wl1271_debug(DEBUG_ACX
, "acx ba session setting");
1479 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1486 acx
->role_id
= 0xff;
1487 acx
->tid
= tid_index
;
1488 acx
->enable
= policy
;
1489 acx
->ba_direction
= direction
;
1491 switch (direction
) {
1492 case WLAN_BACK_INITIATOR
:
1493 acx
->win_size
= wl
->conf
.ht
.tx_ba_win_size
;
1494 acx
->inactivity_timeout
= wl
->conf
.ht
.inactivity_timeout
;
1496 case WLAN_BACK_RECIPIENT
:
1497 acx
->win_size
= RX_BA_WIN_SIZE
;
1498 acx
->inactivity_timeout
= 0;
1501 wl1271_error("Incorrect acx command id=%x\n", direction
);
1506 ret
= wl1271_cmd_configure(wl
,
1507 ACX_BA_SESSION_POLICY_CFG
,
1511 wl1271_warning("acx ba session setting failed: %d", ret
);
1520 /* setup BA session receiver setting in the FW. */
1521 int wl1271_acx_set_ba_receiver_session(struct wl1271
*wl
, u8 tid_index
, u16 ssn
,
1524 struct wl1271_acx_ba_receiver_setup
*acx
;
1527 wl1271_debug(DEBUG_ACX
, "acx ba receiver session setting");
1529 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1535 /* Single link for now */
1537 acx
->tid
= tid_index
;
1538 acx
->enable
= enable
;
1542 ret
= wl1271_cmd_configure(wl
, ACX_BA_SESSION_RX_SETUP
, acx
,
1545 wl1271_warning("acx ba receiver session failed: %d", ret
);
1554 int wl1271_acx_tsf_info(struct wl1271
*wl
, u64
*mactime
)
1556 struct wl1271_acx_fw_tsf_information
*tsf_info
;
1559 tsf_info
= kzalloc(sizeof(*tsf_info
), GFP_KERNEL
);
1565 ret
= wl1271_cmd_interrogate(wl
, ACX_TSF_INFO
,
1566 tsf_info
, sizeof(*tsf_info
));
1568 wl1271_warning("acx tsf info interrogate failed");
1572 *mactime
= le32_to_cpu(tsf_info
->current_tsf_low
) |
1573 ((u64
) le32_to_cpu(tsf_info
->current_tsf_high
) << 32);
1580 int wl1271_acx_ps_rx_streaming(struct wl1271
*wl
, bool enable
)
1582 struct wl1271_acx_ps_rx_streaming
*rx_streaming
;
1583 u32 conf_queues
, enable_queues
;
1586 wl1271_debug(DEBUG_ACX
, "acx ps rx streaming");
1588 rx_streaming
= kzalloc(sizeof(*rx_streaming
), GFP_KERNEL
);
1589 if (!rx_streaming
) {
1594 conf_queues
= wl
->conf
.rx_streaming
.queues
;
1596 enable_queues
= conf_queues
;
1600 for (i
= 0; i
< 8; i
++) {
1602 * Skip non-changed queues, to avoid redundant acxs.
1603 * this check assumes conf.rx_streaming.queues can't
1604 * be changed while rx_streaming is enabled.
1606 if (!(conf_queues
& BIT(i
)))
1609 rx_streaming
->tid
= i
;
1610 rx_streaming
->enable
= enable_queues
& BIT(i
);
1611 rx_streaming
->period
= wl
->conf
.rx_streaming
.interval
;
1612 rx_streaming
->timeout
= wl
->conf
.rx_streaming
.interval
;
1614 ret
= wl1271_cmd_configure(wl
, ACX_PS_RX_STREAMING
,
1616 sizeof(*rx_streaming
));
1618 wl1271_warning("acx ps rx streaming failed: %d", ret
);
1623 kfree(rx_streaming
);
1627 int wl1271_acx_ap_max_tx_retry(struct wl1271
*wl
)
1629 struct wl1271_acx_ap_max_tx_retry
*acx
= NULL
;
1632 wl1271_debug(DEBUG_ACX
, "acx ap max tx retry");
1634 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1638 acx
->max_tx_retry
= cpu_to_le16(wl
->conf
.tx
.max_tx_retries
);
1640 ret
= wl1271_cmd_configure(wl
, ACX_MAX_TX_FAILURE
, acx
, sizeof(*acx
));
1642 wl1271_warning("acx ap max tx retry failed: %d", ret
);
1651 int wl1271_acx_config_ps(struct wl1271
*wl
)
1653 struct wl1271_acx_config_ps
*config_ps
;
1656 wl1271_debug(DEBUG_ACX
, "acx config ps");
1658 config_ps
= kzalloc(sizeof(*config_ps
), GFP_KERNEL
);
1664 config_ps
->exit_retries
= wl
->conf
.conn
.psm_exit_retries
;
1665 config_ps
->enter_retries
= wl
->conf
.conn
.psm_entry_retries
;
1666 config_ps
->null_data_rate
= cpu_to_le32(wl
->basic_rate
);
1668 ret
= wl1271_cmd_configure(wl
, ACX_CONFIG_PS
, config_ps
,
1669 sizeof(*config_ps
));
1672 wl1271_warning("acx config ps failed: %d", ret
);
1681 int wl1271_acx_set_inconnection_sta(struct wl1271
*wl
, u8
*addr
)
1683 struct wl1271_acx_inconnection_sta
*acx
= NULL
;
1686 wl1271_debug(DEBUG_ACX
, "acx set inconnaction sta %pM", addr
);
1688 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1692 memcpy(acx
->addr
, addr
, ETH_ALEN
);
1694 ret
= wl1271_cmd_configure(wl
, ACX_UPDATE_INCONNECTION_STA_LIST
,
1697 wl1271_warning("acx set inconnaction sta failed: %d", ret
);
1706 int wl1271_acx_set_ap_beacon_filter(struct wl1271
*wl
, bool enable
)
1708 struct acx_ap_beacon_filter
*acx
= NULL
;
1711 wl1271_debug(DEBUG_ACX
, "acx set ap beacon filter: %d", enable
);
1713 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1717 acx
->enable
= enable
? 1 : 0;
1719 ret
= wl1271_cmd_configure(wl
, ACX_AP_BEACON_FILTER_OPT
,
1722 wl1271_warning("acx set ap beacon filter failed: %d", ret
);
1731 int wl1271_acx_fm_coex(struct wl1271
*wl
)
1733 struct wl1271_acx_fm_coex
*acx
;
1736 wl1271_debug(DEBUG_ACX
, "acx fm coex setting");
1738 acx
= kzalloc(sizeof(*acx
), GFP_KERNEL
);
1744 acx
->enable
= wl
->conf
.fm_coex
.enable
;
1745 acx
->swallow_period
= wl
->conf
.fm_coex
.swallow_period
;
1746 acx
->n_divider_fref_set_1
= wl
->conf
.fm_coex
.n_divider_fref_set_1
;
1747 acx
->n_divider_fref_set_2
= wl
->conf
.fm_coex
.n_divider_fref_set_2
;
1748 acx
->m_divider_fref_set_1
=
1749 cpu_to_le16(wl
->conf
.fm_coex
.m_divider_fref_set_1
);
1750 acx
->m_divider_fref_set_2
=
1751 cpu_to_le16(wl
->conf
.fm_coex
.m_divider_fref_set_2
);
1752 acx
->coex_pll_stabilization_time
=
1753 cpu_to_le32(wl
->conf
.fm_coex
.coex_pll_stabilization_time
);
1754 acx
->ldo_stabilization_time
=
1755 cpu_to_le16(wl
->conf
.fm_coex
.ldo_stabilization_time
);
1756 acx
->fm_disturbed_band_margin
=
1757 wl
->conf
.fm_coex
.fm_disturbed_band_margin
;
1758 acx
->swallow_clk_diff
= wl
->conf
.fm_coex
.swallow_clk_diff
;
1760 ret
= wl1271_cmd_configure(wl
, ACX_FM_COEX_CFG
, acx
, sizeof(*acx
));
1762 wl1271_warning("acx fm coex setting failed: %d", ret
);