25 #include <linux/module.h>
33 #include <linux/slab.h>
35 #include <linux/sched.h>
54 #define WL1271_BOOT_RETRIES 3
56 #define WL1271_BOOT_RETRIES 3
58 static char *fwlog_param;
59 static bool bug_on_recovery;
60 static bool no_recovery;
62 static void __wl1271_op_remove_interface(
struct wl1271 *wl,
64 bool reset_tx_queues);
65 static void wlcore_op_stop_locked(
struct wl1271 *wl);
66 static void wl1271_free_ap_keys(
struct wl1271 *wl,
struct wl12xx_vif *wlvif);
68 static int wl12xx_set_authorized(
struct wl1271 *wl,
92 static int wl1271_reg_notify(
struct wiphy *
wiphy,
114 static int wl1271_set_rx_streaming(
struct wl1271 *wl,
struct wl12xx_vif *wlvif,
148 (wl->
conf.rx_streaming.always ||
150 ret = wl1271_set_rx_streaming(wl, wlvif,
true);
152 ret = wl1271_set_rx_streaming(wl, wlvif,
false);
171 (!wl->
conf.rx_streaming.always &&
175 if (!wl->
conf.rx_streaming.interval)
182 ret = wl1271_set_rx_streaming(wl, wlvif,
true);
196 static void wl1271_rx_streaming_disable_work(
struct work_struct *work)
212 ret = wl1271_set_rx_streaming(wl, wlvif,
false);
222 static void wl1271_rx_streaming_timer(
unsigned long data)
241 static void wl12xx_tx_watchdog_work(
struct work_struct *work)
264 wl->
conf.tx.tx_watchdog_timeout);
275 wl->
conf.tx.tx_watchdog_timeout);
289 wl->
conf.tx.tx_watchdog_timeout,
295 wl1271_error(
"Tx stuck (in FW) for %d ms. Starting recovery",
296 wl->
conf.tx.tx_watchdog_timeout);
303 static void wlcore_adjust_conf(
struct wl1271 *wl)
307 if (!
strcmp(fwlog_param,
"continuous")) {
309 }
else if (!
strcmp(fwlog_param,
"ondemand")) {
311 }
else if (!
strcmp(fwlog_param,
"dbgpins")) {
314 }
else if (!
strcmp(fwlog_param,
"disable")) {
315 wl->
conf.fwlog.mem_blocks = 0;
318 wl1271_error(
"Unknown fwlog parameter %s", fwlog_param);
323 static void wl12xx_irq_ps_regulate_link(
struct wl1271 *wl,
327 bool fw_ps, single_sta;
348 static void wl12xx_irq_update_links_status(
struct wl1271 *wl,
361 "link ps prev 0x%x cur 0x%x changed 0x%x",
369 lnk = &wl->
links[hlid];
370 cnt = status->
counters.tx_lnk_free_pkts[hlid] -
376 wl12xx_irq_ps_regulate_link(wl, wlvif, hlid,
381 static int wlcore_fw_status(
struct wl1271 *wl,
388 int avail, freed_blocks;
402 "drv_rx_counter = %d, tx_results_counter = %d)",
411 (status_2->
counters.tx_released_pkts[
i] -
461 wl12xx_irq_update_links_status(wl, wlvif, status_2);
472 static void wl1271_flush_deferred_work(
struct wl1271 *wl)
478 ieee80211_rx_ni(wl->
hw, skb);
482 ieee80211_tx_status_ni(wl->
hw, skb);
485 static void wl1271_netstack_work(
struct work_struct *work)
491 wl1271_flush_deferred_work(wl);
495 #define WL1271_IRQ_MAX_LOOPS 256
497 static int wlcore_irq_locked(
struct wl1271 *wl)
503 unsigned int defer_count;
522 while (!done && loopcount--) {
535 wlcore_hw_tx_immediate_compl(wl);
545 wl1271_error(
"HW watchdog interrupt received! starting recovery.");
555 "starting recovery.");
573 wl1271_tx_total_queue_count(wl) > 0) {
574 spin_unlock_irqrestore(&wl->
wl_lock, flags);
583 spin_unlock_irqrestore(&wl->
wl_lock, flags);
587 ret = wlcore_hw_tx_delayed_compl(wl);
595 wl1271_flush_deferred_work(wl);
614 "WL1271_ACX_INTR_INIT_COMPLETE");
638 ret = wlcore_irq_locked(wl);
646 wl1271_tx_total_queue_count(wl) > 0)
648 spin_unlock_irqrestore(&wl->
wl_lock, flags);
662 static void wl12xx_vif_count_iter(
void *
data,
u8 *
mac,
677 memset(data, 0,
sizeof(*data));
681 wl12xx_vif_count_iter, data);
684 static int wl12xx_fetch_firmware(
struct wl1271 *wl,
bool plt)
716 wl1271_error(
"could not get firmware %s: %d", fw_name, ret);
721 wl1271_error(
"firmware size is not multiple of 32 bits: %zu",
733 wl1271_error(
"could not allocate memory for the firmware");
765 while (len < maxlen) {
766 if (memblock[len] == 0)
768 if (len + memblock[len] + 1 > maxlen)
770 len += memblock[len] + 1;
783 #define WLCORE_FW_LOG_END 0x2000000
785 static void wl12xx_read_fwlog_panic(
struct wl1271 *wl)
794 (wl->
conf.fwlog.mem_blocks == 0))
825 offset =
sizeof(
addr);
847 }
while (addr && (addr != end_of_log));
855 static void wlcore_print_recovery(
struct wl1271 *wl)
861 wl1271_info(
"Hardware recovery in progress. FW ver: %s",
862 wl->
chip.fw_ver_str);
877 wl1271_info(
"pc: 0x%x, hint_sts: 0x%08x", pc, hint_sts);
883 static void wl1271_recovery_work(
struct work_struct *work)
896 wl12xx_read_fwlog_panic(wl);
897 wlcore_print_recovery(wl);
904 wl1271_info(
"No recovery (chosen on module load). Fw will remain stuck.");
932 vif = wl12xx_wlvif_to_vif(wlvif);
933 __wl1271_op_remove_interface(wl, vif,
false);
936 wlcore_op_stop_locked(wl);
952 static int wlcore_fw_wakeup(
struct wl1271 *wl)
957 static int wl1271_setup(
struct wl1271 *wl)
978 static int wl12xx_set_power_on(
struct wl1271 *wl)
983 ret = wl1271_power_on(wl);
995 ret = wlcore_fw_wakeup(wl);
1003 wl1271_power_off(wl);
1007 static int wl12xx_chip_wakeup(
struct wl1271 *wl,
bool plt)
1011 ret = wl12xx_set_power_on(wl);
1031 ret = wl1271_setup(wl);
1035 ret = wl12xx_fetch_firmware(wl, plt);
1046 struct wiphy *wiphy = wl->
hw->wiphy;
1048 static const char*
const PLT_MODE[] = {
1062 "in off state: %d", wl->
state);
1073 ret = wl12xx_chip_wakeup(wl,
true);
1077 ret = wl->
ops->plt_init(wl);
1084 wl->
chip.fw_ver_str);
1094 wl1271_power_off(wl);
1100 wl1271_error(
"firmware boot in PLT mode failed despite %d retries",
1132 "state: %d", wl->
state);
1139 wl1271_flush_deferred_work(wl);
1147 wl1271_power_off(wl);
1168 unsigned long flags;
1173 wlvif = wl12xx_vif_to_data(vif);
1175 mapping = skb_get_queue_mapping(skb);
1176 q = wl1271_tx_get_queue(mapping);
1225 spin_unlock_irqrestore(&wl->
wl_lock, flags);
1230 unsigned long flags;
1237 q = wl1271_tx_get_queue(skb_get_queue_mapping(wl->
dummy_packet));
1242 spin_unlock_irqrestore(&wl->
wl_lock, flags);
1260 #define TOTAL_TX_DUMMY_PACKET_SIZE (ALIGN(1400, 512))
1262 static struct sk_buff *wl12xx_alloc_dummy_packet(
struct wl1271 *wl)
1266 unsigned int dummy_packet_size;
1280 memset(hdr, 0,
sizeof(*hdr));
1285 memset(
skb_put(skb, dummy_packet_size), 0, dummy_packet_size);
1291 skb_set_queue_mapping(skb, 0);
1302 int num_fields = 0, in_field = 0, fields_size = 0;
1303 int i, pattern_len = 0;
1327 fields_size += pattern_len +
1336 fields_size += pattern_len +
1410 int i, fields_size = 0;
1413 fields_size += filter->
fields[i].len +
1443 static int wl1271_convert_wowlan_pattern_to_rx_filter(
1460 while (i < p->pattern_len) {
1507 static int wl1271_configure_wowlan(
struct wl1271 *wl,
1513 ret = wl1271_acx_default_rx_filter_enable(wl, 0,
1530 ret = wl1271_validate_wowlan_pattern(&wow->
patterns[i]);
1537 ret = wl1271_acx_default_rx_filter_enable(wl, 0,
FILTER_SIGNAL);
1552 ret = wl1271_convert_wowlan_pattern_to_rx_filter(p, &filter);
1555 "wowlan pattern %d", i);
1566 ret = wl1271_acx_default_rx_filter_enable(wl, 1,
FILTER_DROP);
1572 static int wl1271_configure_suspend_sta(
struct wl1271 *wl,
1585 ret = wl1271_configure_wowlan(wl, wow);
1589 if ((wl->
conf.conn.suspend_wake_up_event ==
1590 wl->
conf.conn.wake_up_event) &&
1591 (wl->
conf.conn.suspend_listen_interval ==
1592 wl->
conf.conn.listen_interval))
1596 wl->
conf.conn.suspend_wake_up_event,
1597 wl->
conf.conn.suspend_listen_interval);
1600 wl1271_error(
"suspend: set wake up conditions failed: %d", ret);
1609 static int wl1271_configure_suspend_ap(
struct wl1271 *wl,
1629 static int wl1271_configure_suspend(
struct wl1271 *wl,
1634 return wl1271_configure_suspend_sta(wl, wlvif, wow);
1636 return wl1271_configure_suspend_ap(wl, wlvif);
1640 static void wl1271_configure_resume(
struct wl1271 *wl,
1647 if ((!is_ap) && (!is_sta))
1658 wl1271_configure_wowlan(wl,
NULL);
1660 if ((wl->
conf.conn.suspend_wake_up_event ==
1661 wl->
conf.conn.wake_up_event) &&
1662 (wl->
conf.conn.suspend_listen_interval ==
1663 wl->
conf.conn.listen_interval))
1667 wl->
conf.conn.wake_up_event,
1668 wl->
conf.conn.listen_interval);
1703 ret = wl1271_configure_suspend(wl, wlvif, wow);
1737 unsigned long flags;
1738 bool run_irq_work =
false, pending_recovery;
1752 run_irq_work =
true;
1753 spin_unlock_irqrestore(&wl->
wl_lock, flags);
1763 "run postponed irq_work directly");
1766 if (!pending_recovery) {
1767 ret = wlcore_irq_locked(wl);
1775 if (pending_recovery) {
1782 wl1271_configure_resume(wl, wlvif);
1811 static void wlcore_op_stop_locked(
struct wl1271 *wl)
1840 wl1271_flush_deferred_work(wl);
1852 wl1271_power_off(wl);
1916 wlcore_op_stop_locked(wl);
1921 static int wl12xx_allocate_rate_policy(
struct wl1271 *wl,
u8 *
idx)
1933 static void wl12xx_free_rate_policy(
struct wl1271 *wl,
u8 *idx)
1942 static int wlcore_allocate_klv_template(
struct wl1271 *wl,
u8 *idx)
1954 static void wlcore_free_klv_template(
struct wl1271 *wl,
u8 *idx)
1989 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
1995 switch (ieee80211_vif_type_p2p(vif)) {
2024 wl12xx_allocate_rate_policy(wl, &wlvif->
sta.basic_rate_idx);
2025 wl12xx_allocate_rate_policy(wl, &wlvif->
sta.ap_rate_idx);
2026 wl12xx_allocate_rate_policy(wl, &wlvif->
sta.p2p_rate_idx);
2027 wlcore_allocate_klv_template(wl, &wlvif->
sta.klv_template_id);
2035 wl12xx_allocate_rate_policy(wl, &wlvif->
ap.mgmt_rate_idx);
2036 wl12xx_allocate_rate_policy(wl, &wlvif->
ap.bcast_rate_idx);
2038 wl12xx_allocate_rate_policy(wl,
2039 &wlvif->
ap.ucast_rate_idx[i]);
2065 wl1271_rx_streaming_enable_work);
2067 wl1271_rx_streaming_disable_work);
2068 INIT_LIST_HEAD(&wlvif->
list);
2071 (
unsigned long) wlvif);
2075 static bool wl12xx_init_fw(
struct wl1271 *wl)
2078 bool booted =
false;
2079 struct wiphy *wiphy = wl->
hw->wiphy;
2084 ret = wl12xx_chip_wakeup(wl,
false);
2088 ret = wl->
ops->boot(wl);
2109 wl1271_flush_deferred_work(wl);
2113 wl1271_power_off(wl);
2117 wl1271_error(
"firmware boot failed despite %d retries",
2144 static bool wl12xx_dev_role_started(
struct wl12xx_vif *wlvif)
2156 static bool wl12xx_need_fw_change(
struct wl1271 *wl,
2161 u8 vif_count = vif_counter_data.
counter;
2192 static void wl12xx_force_active_psm(
struct wl1271 *wl)
2201 static int wl1271_op_add_interface(
struct ieee80211_hw *hw,
2205 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2206 struct vif_counter_data vif_count;
2209 bool booted =
false;
2215 ieee80211_vif_type_p2p(vif), vif->
addr);
2217 wl12xx_get_vif_count(hw, vif, &vif_count);
2236 ret = wl12xx_init_vif_data(wl, vif);
2241 role_type = wl12xx_get_role_type(wl, wlvif);
2247 if (wl12xx_need_fw_change(wl, vif_count,
true)) {
2248 wl12xx_force_active_psm(wl);
2266 booted = wl12xx_init_fw(wl);
2297 static void __wl1271_op_remove_interface(
struct wl1271 *wl,
2299 bool reset_tx_queues)
2301 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2339 if (wl12xx_dev_role_started(wlvif))
2356 wl12xx_free_rate_policy(wl, &wlvif->
sta.basic_rate_idx);
2357 wl12xx_free_rate_policy(wl, &wlvif->
sta.ap_rate_idx);
2358 wl12xx_free_rate_policy(wl, &wlvif->
sta.p2p_rate_idx);
2359 wlcore_free_klv_template(wl, &wlvif->
sta.klv_template_id);
2363 wl12xx_free_rate_policy(wl, &wlvif->
ap.mgmt_rate_idx);
2364 wl12xx_free_rate_policy(wl, &wlvif->
ap.bcast_rate_idx);
2366 wl12xx_free_rate_policy(wl,
2367 &wlvif->
ap.ucast_rate_idx[i]);
2368 wl1271_free_ap_keys(wl, wlvif);
2377 memset(wlvif->
ap.sta_hlid_map, 0,
sizeof(wlvif->
ap.sta_hlid_map));
2395 u8 sta_auth = wl->
conf.conn.sta_sleep_auth;
2417 static void wl1271_op_remove_interface(
struct ieee80211_hw *hw,
2421 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2423 struct vif_counter_data vif_count;
2425 wl12xx_get_vif_count(hw, vif, &vif_count);
2440 __wl1271_op_remove_interface(wl, vif,
true);
2444 if (wl12xx_need_fw_change(wl, vif_count,
false)) {
2445 wl12xx_force_active_psm(wl);
2453 static int wl12xx_op_change_interface(
struct ieee80211_hw *hw,
2461 wl1271_op_remove_interface(hw, vif);
2463 vif->
type = new_type;
2465 ret = wl1271_op_add_interface(hw, vif);
2524 wlvif->
sta.klv_template_id,
2546 wlvif->
sta.klv_template_id,
2562 static void wl1271_set_band_rate(
struct wl1271 *wl,
struct wl12xx_vif *wlvif)
2568 static int wl1271_sta_handle_idle(
struct wl1271 *wl,
struct wl12xx_vif *wlvif,
2574 if (idle == cur_idle)
2579 if (wl12xx_dev_role_started(wlvif)) {
2618 (wlvif->
channel != channel) ||
2630 wl1271_set_band_rate(wl, wlvif);
2643 wl1271_set_band_rate(wl, wlvif);
2660 wl12xx_dev_role_started(wlvif) &&
2682 if (wl->
conf.conn.forced_ps) {
2684 ps_mode_str =
"forced";
2687 ps_mode_str =
"auto";
2751 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
2769 ret = wl12xx_config_vif(wl, wlvif, conf, changed);
2814 return (
u64)(
unsigned long)fp;
2817 #define WL1271_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
2820 FIF_BCN_PRBRESP_PROMISC | \
2824 static void wl1271_op_configure_filter(
struct ieee80211_hw *hw,
2825 unsigned int changed,
2826 unsigned int *total,
u64 multicast)
2835 " total %x", changed, *total);
2879 static int wl1271_record_ap_key(
struct wl1271 *wl,
struct wl12xx_vif *wlvif,
2897 if (wlvif->
ap.recorded_keys[i] ==
NULL)
2900 if (wlvif->
ap.recorded_keys[i]->id ==
id) {
2906 if (i == MAX_NUM_KEYS)
2909 ap_key = kzalloc(
sizeof(*ap_key),
GFP_KERNEL);
2921 wlvif->
ap.recorded_keys[
i] = ap_key;
2925 static void wl1271_free_ap_keys(
struct wl1271 *wl,
struct wl12xx_vif *wlvif)
2930 kfree(wlvif->
ap.recorded_keys[i]);
2931 wlvif->
ap.recorded_keys[
i] =
NULL;
2935 static int wl1271_ap_init_hwenc(
struct wl1271 *wl,
struct wl12xx_vif *wlvif)
2939 bool wep_key_added =
false;
2943 if (wlvif->
ap.recorded_keys[i] ==
NULL)
2946 key = wlvif->
ap.recorded_keys[
i];
2949 hlid = wlvif->
ap.bcast_hlid;
2960 wep_key_added =
true;
2963 if (wep_key_added) {
2965 wlvif->
ap.bcast_hlid);
2971 wl1271_free_ap_keys(wl, wlvif);
2977 u8 key_size,
const u8 *key,
u32 tx_seq_32,
2989 hlid = wl_sta->
hlid;
2991 hlid = wlvif->
ap.bcast_hlid;
3002 ret = wl1271_record_ap_key(wl, wlvif,
id,
3004 key, hlid, tx_seq_32,
3008 id, key_type, key_size,
3009 key, hlid, tx_seq_32,
3018 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
3021 addr = sta ? sta->
addr : bcast_addr;
3023 if (is_zero_ether_addr(addr)) {
3032 if (action ==
KEY_REMOVE && !is_broadcast_ether_addr(addr))
3041 id, key_type, key_size,
3042 key, addr, tx_seq_32,
3067 bool might_change_spare =
3071 if (might_change_spare) {
3087 goto out_wake_queues;
3092 goto out_wake_queues;
3094 ret = wlcore_hw_set_key(wl, cmd, vif, sta, key_conf);
3099 if (might_change_spare)
3112 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3126 switch (key_conf->
cipher) {
3161 key_conf->
keyidx, key_type,
3163 tx_seq_32, tx_seq_16, sta);
3174 (sta || key_type ==
KEY_WEP) &&
3187 key_conf->
keyidx, key_type,
3217 ssid = req->
ssids[0].ssid;
3218 len = req->
ssids[0].ssid_len;
3253 static void wl1271_op_cancel_hw_scan(
struct ieee80211_hw *hw,
3299 static int wl1271_op_sched_scan_start(
struct ieee80211_hw *hw,
3305 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3338 static void wl1271_op_sched_scan_stop(
struct ieee80211_hw *hw,
3342 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3391 static int wl1271_op_set_rts_threshold(
struct ieee80211_hw *hw,
u32 value)
3424 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3445 static void wl12xx_remove_ie(
struct sk_buff *skb,
u8 eid,
int ieoffset)
3450 skb->
len - ieoffset);
3455 memmove(ie, next, end - next);
3459 static void wl12xx_remove_vendor_ie(
struct sk_buff *skb,
3460 unsigned int oui,
u8 oui_type,
3466 skb->
data + ieoffset,
3467 skb->
len - ieoffset);
3472 memmove(ie, next, end - next);
3476 static int wl1271_ap_set_probe_resp_tmpl(
struct wl1271 *wl,
u32 rates,
3479 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3504 static int wl1271_ap_set_probe_resp_tmpl_legacy(
struct wl1271 *wl,
3507 size_t probe_rsp_len,
3510 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3513 int ssid_ie_offset, ie_offset, templ_len;
3533 probe_rsp_len - ie_offset);
3539 ssid_ie_offset = ptr - probe_rsp_data;
3540 ptr += (ptr[1] + 2);
3542 memcpy(probe_rsp_templ, probe_rsp_data, ssid_ie_offset);
3546 probe_rsp_templ[ssid_ie_offset + 1] = bss_conf->
ssid_len;
3547 memcpy(probe_rsp_templ + ssid_ie_offset + 2,
3549 templ_len = ssid_ie_offset + 2 + bss_conf->
ssid_len;
3551 memcpy(probe_rsp_templ + ssid_ie_offset + 2 + bss_conf->
ssid_len,
3552 ptr, probe_rsp_len - (ptr - probe_rsp_data));
3553 templ_len += probe_rsp_len - (ptr - probe_rsp_data);
3562 static int wl1271_bss_erp_info_changed(
struct wl1271 *wl,
3567 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3605 static int wlcore_set_beacon_template(
struct wl1271 *wl,
3609 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3625 ret = wl1271_ssid_set(vif, beacon, ieoffset);
3627 dev_kfree_skb(beacon);
3638 dev_kfree_skb(beacon);
3667 ret = wl1271_ap_set_probe_resp_tmpl_legacy(wl, vif,
3678 dev_kfree_skb(beacon);
3686 static int wl1271_bss_beacon_info_changed(
struct wl1271 *wl,
3691 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3705 wl1271_ap_set_probe_resp_tmpl(wl, rate, vif);
3709 ret = wlcore_set_beacon_template(wl, vif, is_ap);
3721 static void wl1271_bss_info_changed_ap(
struct wl1271 *wl,
3726 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3747 ret = wl1271_ap_set_probe_resp_tmpl(wl, wlvif->
basic_rate, vif);
3751 ret = wlcore_set_beacon_template(wl, vif,
true);
3756 ret = wl1271_bss_beacon_info_changed(wl, vif, bss_conf, changed);
3767 ret = wl1271_ap_init_hwenc(wl, wlvif);
3788 ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed);
3808 static void wl1271_bss_info_changed_sta(
struct wl1271 *wl,
3813 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3814 bool do_join =
false, set_assoc =
false;
3816 bool ibss_joined =
false;
3817 u32 sta_rate_set = 0;
3820 bool sta_exists =
false;
3824 ret = wl1271_bss_beacon_info_changed(wl, vif, bss_conf,
3837 wl1271_unjoin(wl, wlvif);
3841 if ((changed & BSS_CHANGED_BEACON_INT) && ibss_joined)
3845 if ((changed & BSS_CHANGED_BEACON) && ibss_joined)
3848 if ((changed & BSS_CHANGED_BEACON_ENABLED) && ibss_joined) {
3856 ret = wl1271_sta_handle_idle(wl, wlvif, bss_conf->
idle);
3862 bool enable =
false;
3874 if (!is_zero_ether_addr(bss_conf->
bssid)) {
3891 sta_rate_set = sta->
supp_rates[wl->
hw->conf.channel->band];
3892 if (sta->
ht_cap.ht_supported)
3896 sta_ht_cap = sta->
ht_cap;
3904 if (bss_conf->
assoc) {
3907 wlvif->
aid = bss_conf->
aid;
3951 u.probe_req.variable);
3952 wl1271_ssid_set(vif, wlvif->
probereq, ieoffset);
3973 wl1271_set_band_rate(wl, wlvif);
4012 wl1271_unjoin(wl, wlvif);
4013 if (!bss_conf->
idle)
4019 if (changed & BSS_CHANGED_IBSS) {
4040 ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed);
4045 ret = wl1271_join(wl, wlvif, set_assoc);
4058 wl12xx_set_authorized(wl, wlvif);
4064 if (wl12xx_dev_role_started(wlvif)) {
4073 if ((changed & BSS_CHANGED_HT) &&
4086 else if (changed & BSS_CHANGED_ASSOC) {
4100 if ((changed & BSS_CHANGED_HT) &&
4114 wlvif->
sta.qos = bss_conf->
qos;
4149 static void wl1271_op_bss_info_changed(
struct ieee80211_hw *hw,
4155 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4166 if (!is_ap && (changed & BSS_CHANGED_ASSOC))
4169 if (is_ap && (changed & BSS_CHANGED_BEACON_ENABLED) &&
4186 wl1271_bss_info_changed_ap(wl, vif, bss_conf, changed);
4188 wl1271_bss_info_changed_sta(wl, vif, bss_conf, changed);
4201 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4233 wl1271_tx_get_queue(queue),
4251 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4278 static int wl1271_op_get_survey(
struct ieee80211_hw *hw,
int idx,
4291 static int wl1271_allocate_sta(
struct wl1271 *wl,
4338 static int wl12xx_sta_add(
struct wl1271 *wl,
4348 ret = wl1271_allocate_sta(wl, wlvif, sta);
4353 hlid = wl_sta->
hlid;
4362 static int wl12xx_sta_remove(
struct wl1271 *wl,
4384 static int wl12xx_update_sta_state(
struct wl1271 *wl,
4397 hlid = wl_sta->
hlid;
4403 return wl12xx_sta_add(wl, wlvif, sta);
4410 wl12xx_sta_remove(wl, wlvif, sta);
4430 return wl12xx_set_authorized(wl, wlvif);
4443 static int wl12xx_op_sta_state(
struct ieee80211_hw *hw,
4450 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4454 sta->
aid, old_state, new_state);
4467 ret = wl12xx_update_sta_state(wl, wlvif, sta, old_state, new_state);
4472 if (new_state < old_state)
4477 static int wl1271_op_ampdu_action(
struct ieee80211_hw *hw,
4484 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4503 hlid = wlvif->
sta.hlid;
4504 ba_bitmap = &wlvif->
sta.ba_rx_bitmap;
4509 hlid = wl_sta->
hlid;
4510 ba_bitmap = &wl->
links[hlid].ba_bitmap;
4536 if (*ba_bitmap &
BIT(tid)) {
4546 *ba_bitmap |=
BIT(tid);
4552 if (!(*ba_bitmap &
BIT(tid))) {
4558 "no active RX BA session on tid: %d",
4567 *ba_bitmap &= ~
BIT(tid);
4583 wl1271_error(
"Incorrect ampdu action id=%x\n", action);
4595 static int wl12xx_set_bitrate_mask(
struct ieee80211_hw *hw,
4599 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4625 wl1271_set_band_rate(wl, wlvif);
4638 static void wl12xx_op_channel_switch(
struct ieee80211_hw *hw,
4679 static void wlcore_op_flush(
struct ieee80211_hw *hw,
bool drop)
4686 static bool wl1271_tx_frames_pending(
struct ieee80211_hw *hw)
4697 ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->
tx_frames_cnt > 0);
4749 { .hw_value = 1, .center_freq = 2412, .max_power = 25 },
4750 { .hw_value = 2, .center_freq = 2417, .max_power = 25 },
4751 { .hw_value = 3, .center_freq = 2422, .max_power = 25 },
4752 { .hw_value = 4, .center_freq = 2427, .max_power = 25 },
4753 { .hw_value = 5, .center_freq = 2432, .max_power = 25 },
4754 { .hw_value = 6, .center_freq = 2437, .max_power = 25 },
4755 { .hw_value = 7, .center_freq = 2442, .max_power = 25 },
4756 { .hw_value = 8, .center_freq = 2447, .max_power = 25 },
4757 { .hw_value = 9, .center_freq = 2452, .max_power = 25 },
4758 { .hw_value = 10, .center_freq = 2457, .max_power = 25 },
4759 { .hw_value = 11, .center_freq = 2462, .max_power = 25 },
4760 { .hw_value = 12, .center_freq = 2467, .max_power = 25 },
4761 { .hw_value = 13, .center_freq = 2472, .max_power = 25 },
4762 { .hw_value = 14, .center_freq = 2484, .max_power = 25 },
4767 .channels = wl1271_channels,
4769 .bitrates = wl1271_rates,
4803 { .hw_value = 7, .center_freq = 5035, .max_power = 25 },
4804 { .hw_value = 8, .center_freq = 5040, .max_power = 25 },
4805 { .hw_value = 9, .center_freq = 5045, .max_power = 25 },
4806 { .hw_value = 11, .center_freq = 5055, .max_power = 25 },
4807 { .hw_value = 12, .center_freq = 5060, .max_power = 25 },
4808 { .hw_value = 16, .center_freq = 5080, .max_power = 25 },
4809 { .hw_value = 34, .center_freq = 5170, .max_power = 25 },
4810 { .hw_value = 36, .center_freq = 5180, .max_power = 25 },
4811 { .hw_value = 38, .center_freq = 5190, .max_power = 25 },
4812 { .hw_value = 40, .center_freq = 5200, .max_power = 25 },
4813 { .hw_value = 42, .center_freq = 5210, .max_power = 25 },
4814 { .hw_value = 44, .center_freq = 5220, .max_power = 25 },
4815 { .hw_value = 46, .center_freq = 5230, .max_power = 25 },
4816 { .hw_value = 48, .center_freq = 5240, .max_power = 25 },
4817 { .hw_value = 52, .center_freq = 5260, .max_power = 25 },
4818 { .hw_value = 56, .center_freq = 5280, .max_power = 25 },
4819 { .hw_value = 60, .center_freq = 5300, .max_power = 25 },
4820 { .hw_value = 64, .center_freq = 5320, .max_power = 25 },
4821 { .hw_value = 100, .center_freq = 5500, .max_power = 25 },
4822 { .hw_value = 104, .center_freq = 5520, .max_power = 25 },
4823 { .hw_value = 108, .center_freq = 5540, .max_power = 25 },
4824 { .hw_value = 112, .center_freq = 5560, .max_power = 25 },
4825 { .hw_value = 116, .center_freq = 5580, .max_power = 25 },
4826 { .hw_value = 120, .center_freq = 5600, .max_power = 25 },
4827 { .hw_value = 124, .center_freq = 5620, .max_power = 25 },
4828 { .hw_value = 128, .center_freq = 5640, .max_power = 25 },
4829 { .hw_value = 132, .center_freq = 5660, .max_power = 25 },
4830 { .hw_value = 136, .center_freq = 5680, .max_power = 25 },
4831 { .hw_value = 140, .center_freq = 5700, .max_power = 25 },
4832 { .hw_value = 149, .center_freq = 5745, .max_power = 25 },
4833 { .hw_value = 153, .center_freq = 5765, .max_power = 25 },
4834 { .hw_value = 157, .center_freq = 5785, .max_power = 25 },
4835 { .hw_value = 161, .center_freq = 5805, .max_power = 25 },
4836 { .hw_value = 165, .center_freq = 5825, .max_power = 25 },
4840 .channels = wl1271_channels_5ghz,
4841 .n_channels =
ARRAY_SIZE(wl1271_channels_5ghz),
4842 .bitrates = wl1271_rates_5ghz,
4847 .start = wl1271_op_start,
4848 .stop = wlcore_op_stop,
4849 .add_interface = wl1271_op_add_interface,
4850 .remove_interface = wl1271_op_remove_interface,
4851 .change_interface = wl12xx_op_change_interface,
4853 .suspend = wl1271_op_suspend,
4854 .resume = wl1271_op_resume,
4856 .config = wl1271_op_config,
4857 .prepare_multicast = wl1271_op_prepare_multicast,
4858 .configure_filter = wl1271_op_configure_filter,
4860 .set_key = wlcore_op_set_key,
4861 .hw_scan = wl1271_op_hw_scan,
4862 .cancel_hw_scan = wl1271_op_cancel_hw_scan,
4863 .sched_scan_start = wl1271_op_sched_scan_start,
4864 .sched_scan_stop = wl1271_op_sched_scan_stop,
4865 .bss_info_changed = wl1271_op_bss_info_changed,
4866 .set_frag_threshold = wl1271_op_set_frag_threshold,
4867 .set_rts_threshold = wl1271_op_set_rts_threshold,
4868 .conf_tx = wl1271_op_conf_tx,
4869 .get_tsf = wl1271_op_get_tsf,
4870 .get_survey = wl1271_op_get_survey,
4871 .sta_state = wl12xx_op_sta_state,
4872 .ampdu_action = wl1271_op_ampdu_action,
4873 .tx_frames_pending = wl1271_tx_frames_pending,
4874 .set_bitrate_mask = wl12xx_set_bitrate_mask,
4875 .channel_switch = wl12xx_op_channel_switch,
4876 .flush = wlcore_op_flush,
4911 len =
snprintf(buf, len,
"%d\n\n0 - off\n1 - on\n",
4921 const char *buf,
size_t count)
4927 ret = kstrtoul(buf, 10, &res);
4958 wl1271_sysfs_show_bt_coex_state,
4959 wl1271_sysfs_store_bt_coex_state);
4961 static ssize_t wl1271_sysfs_show_hw_pg_ver(
struct device *dev,
4981 wl1271_sysfs_show_hw_pg_ver,
NULL);
5042 .attr = {.name =
"fwlog", .mode =
S_IRUSR},
5043 .read = wl1271_sysfs_read_fwlog,
5046 static void wl1271_connection_loss_work(
struct work_struct *work)
5067 vif = wl12xx_wlvif_to_vif(wlvif);
5074 static void wl12xx_derive_mac_addresses(
struct wl1271 *wl,
u32 oui,
u32 nic)
5113 static int wl12xx_get_hw_info(
struct wl1271 *wl)
5117 ret = wl12xx_set_power_on(wl);
5132 if (wl->
ops->get_mac)
5133 ret = wl->
ops->get_mac(wl);
5136 wl1271_power_off(wl);
5140 static int wl1271_register_hw(
struct wl1271 *wl)
5143 u32 oui_addr = 0, nic_addr = 0;
5156 (nvs_ptr[11] << 16) + (nvs_ptr[10] << 8) + nvs_ptr[6];
5158 (nvs_ptr[5] << 16) + (nvs_ptr[4] << 8) + nvs_ptr[3];
5162 if (oui_addr == 0 && nic_addr == 0) {
5168 wl12xx_derive_mac_addresses(wl, oui_addr, nic_addr);
5172 wl1271_error(
"unable to register mac80211 hw: %d", ret);
5186 static void wl1271_unregister_hw(
struct wl1271 *wl)
5210 wlcore_iface_combinations[] = {
5212 .num_different_channels = 1,
5213 .max_interfaces = 3,
5214 .limits = wlcore_iface_limits,
5219 static int wl1271_init_ieee80211(
struct wl1271 *wl)
5221 static const u32 cipher_suites[] = {
5237 wl->
hw->channel_change_time = 10000;
5238 wl->
hw->max_listen_interval = wl->
conf.conn.max_listen_interval;
5253 wl->
hw->wiphy->cipher_suites = cipher_suites;
5254 wl->
hw->wiphy->n_cipher_suites =
ARRAY_SIZE(cipher_suites);
5259 wl->
hw->wiphy->max_scan_ssids = 1;
5260 wl->
hw->wiphy->max_sched_scan_ssids = 16;
5261 wl->
hw->wiphy->max_match_sets = 16;
5285 sizeof(wl1271_band_2ghz));
5290 sizeof(wl1271_band_5ghz));
5301 wl->
hw->max_rates = 1;
5303 wl->
hw->wiphy->reg_notifier = wl1271_reg_notify;
5307 wl->
hw->wiphy->probe_resp_offload =
5313 wl->
hw->wiphy->iface_combinations = wlcore_iface_combinations;
5314 wl->
hw->wiphy->n_iface_combinations =
5317 SET_IEEE80211_DEV(wl->
hw, wl->
dev);
5322 wl->
hw->max_rx_aggregation_subframes = wl->
conf.ht.rx_ba_win_size;
5327 #define WL1271_DEFAULT_CHANNEL 0
5346 memset(wl, 0,
sizeof(*wl));
5352 goto err_priv_alloc;
5361 skb_queue_head_init(&wl->
links[j].tx_queue[i]);
5373 wl1271_connection_loss_work);
5433 goto err_dummy_packet;
5465 return ERR_PTR(ret);
5505 static irqreturn_t wl12xx_hardirq(
int irq,
void *cookie)
5508 unsigned long flags;
5526 spin_unlock_irqrestore(&wl->
wl_lock, flags);
5529 spin_unlock_irqrestore(&wl->
wl_lock, flags);
5539 unsigned long irqflags;
5556 ret = wl->
ops->setup(wl);
5563 wlcore_adjust_conf(wl);
5584 ret = enable_irq_wake(wl->
irq);
5590 wl->
hw->wiphy->wowlan.n_patterns =
5592 wl->
hw->wiphy->wowlan.pattern_min_len = 1;
5593 wl->
hw->wiphy->wowlan.pattern_max_len =
5600 ret = wl12xx_get_hw_info(wl);
5606 ret = wl->
ops->identify_chip(wl);
5610 ret = wl1271_init_ieee80211(wl);
5614 ret = wl1271_register_hw(wl);
5621 wl1271_error(
"failed to create sysfs file bt_coex_state");
5629 goto out_bt_coex_state;
5649 wl1271_unregister_hw(wl);
5671 platform_set_drvdata(pdev, wl);
5677 wl1271_error(
"request_firmware_nowait failed: %d", ret);
5687 struct wl1271 *wl = platform_get_drvdata(pdev);
5695 disable_irq_wake(wl->
irq);
5697 wl1271_unregister_hw(wl);
5712 "FW logger options: continuous, ondemand, dbgpins or disable");
5718 MODULE_PARM_DESC(no_recovery,
"Prevent HW recovery. FW will remain stuck.");