22 static void ath9k_set_assoc_state(
struct ath_softc *
sc,
38 switch (mpdudensity) {
80 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
95 power_mode = sc->
sc_ah->power_mode;
112 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
136 if (ath9k_hw_btcoex_is_enabled(sc->
sc_ah))
137 ath9k_btcoex_stop_gen_timer(sc);
149 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
152 static void __ath_cancel_work(
struct ath_softc *sc)
159 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
160 if (ath9k_hw_mci_is_enabled(sc->
sc_ah))
165 static void ath_cancel_work(
struct ath_softc *sc)
167 __ath_cancel_work(sc);
171 static void ath_restart_work(
struct ath_softc *sc)
184 static bool ath_prepare_reset(
struct ath_softc *sc,
bool retry_tx,
bool flush)
195 ath9k_debug_samp_bb_mac(sc);
222 ath_err(common,
"Unable to restart recv logic\n");
243 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
246 ath_restart_work(sc);
261 struct ath_common *common = ath9k_hw_common(ah);
267 __ath_cancel_work(sc);
282 if (!ath_prepare_reset(sc, retry_tx, flush))
285 ath_dbg(common,
CONFIG,
"Reset to %u MHz, HT40: %d fastcc: %d\n",
291 "Unable to reset channel, reset status %d\n", r);
295 if (!ath_complete_reset(sc,
true))
317 r = ath_reset_internal(sc, hchan,
false);
327 an = (
struct ath_node *)sta->drv_priv;
329 #ifdef CONFIG_ATH9K_DEBUGFS
330 spin_lock(&sc->nodes_lock);
331 list_add(&an->list, &sc->nodes);
332 spin_unlock(&sc->nodes_lock);
340 sta->
ht_cap.ampdu_factor);
350 #ifdef CONFIG_ATH9K_DEBUGFS
351 spin_lock(&sc->nodes_lock);
353 spin_unlock(&sc->nodes_lock);
365 struct ath_common *common = ath9k_hw_common(ah);
377 if (status & ATH9K_INT_FATAL)
392 ath_dbg(common,
PS,
"TSFOOR - Sync with next Beacon\n");
395 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
403 if (status & rxmask) {
419 ath9k_btcoex_handle_interrupt(sc, status);
431 #define SCHED_INTR ( \
433 ATH9K_INT_BB_WATCHDOG | \
443 ATH9K_INT_GENTIMER | \
448 struct ath_common *common = ath9k_hw_common(ah);
476 ath9k_hw_getisr(ah, &status);
492 #ifdef CONFIG_PM_SLEEP
495 ath_dbg(common,
ANY,
"during WoW we got a BMISS\n");
553 tasklet_schedule(&sc->
intr_tq);
561 static int ath_reset(
struct ath_softc *sc,
bool retry_tx)
567 r = ath_reset_internal(sc,
NULL, retry_tx);
573 spin_lock_bh(&sc->
tx.txq[i].axq_lock);
575 spin_unlock_bh(&sc->
tx.txq[i].axq_lock);
587 #ifdef CONFIG_ATH9K_DEBUGFS
609 struct ath_common *common = ath9k_hw_common(ah);
615 "Starting driver with initial channel: %d MHz\n",
624 ath9k_hw_configpcipowersave(ah,
false);
640 "Unable to reset hardware; reset status %d (freq %u MHz)\n",
665 sc->
sc_ah->is_monitoring =
false;
667 if (!ath_complete_reset(sc,
false))
684 if (ah->
caps.pcie_lcr_extsync_en && common->
bus_ops->extn_synch_en)
685 common->
bus_ops->extn_synch_en(common);
713 "Add PM=1 for a TX frame while in PS mode\n");
730 "Sending PS-Poll to pick a buffered frame\n");
733 ath_dbg(common,
PS,
"Wake up to complete TX\n");
741 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
750 ath_err(common,
"TX while HW is in FULL_SLEEP mode\n");
755 txctl.txq = sc->
tx.txq_map[skb_get_queue_mapping(skb)];
756 txctl.sta = control->
sta;
758 ath_dbg(common, XMIT,
"transmitting packet, skb: %p\n", skb);
761 ath_dbg(common, XMIT,
"TX failed\n");
775 struct ath_common *common = ath9k_hw_common(ah);
819 ath_prepare_reset(sc,
false,
true);
832 ath9k_hw_configpcipowersave(ah,
true);
865 iter_data->
mask[i] &=
889 static void ath9k_sta_vif_iter(
void *data,
u8 *mac,
struct ieee80211_vif *vif)
892 struct ath_vif *avp = (
void *)vif->drv_priv;
898 ath9k_set_assoc_state(sc, vif);
908 struct ath_common *common = ath9k_hw_common(ah);
914 memset(iter_data, 0,
sizeof(*iter_data));
919 ath9k_vif_iter(iter_data, vif->
addr, vif);
927 static void ath9k_calculate_summary_state(
struct ieee80211_hw *hw,
932 struct ath_common *common = ath9k_hw_common(ah);
941 if (iter_data.
naps > 0) {
949 else if (iter_data.
nwds)
974 ath9k_sta_vif_iter, sc);
983 struct ath_common *common = ath9k_hw_common(ah);
991 ath9k_calculate_summary_state(hw, vif);
1001 static int ath9k_change_interface(
struct ieee80211_hw *hw,
1015 vif->
type = new_type;
1019 ath9k_calculate_summary_state(hw, vif);
1029 static void ath9k_remove_interface(
struct ieee80211_hw *hw,
1045 ath9k_calculate_summary_state(hw,
NULL);
1051 static void ath9k_enable_ps(
struct ath_softc *sc)
1054 struct ath_common *common = ath9k_hw_common(ah);
1064 ath_dbg(common,
PS,
"PowerSave enabled\n");
1067 static void ath9k_disable_ps(
struct ath_softc *sc)
1070 struct ath_common *common = ath9k_hw_common(ah);
1085 ath_dbg(common,
PS,
"PowerSave disabled\n");
1092 struct ath_common *common = ath9k_hw_common(ah);
1094 bool reset_channel =
false;
1102 ath_cancel_work(sc);
1103 ath9k_stop_btcoex(sc);
1105 ath9k_start_btcoex(sc);
1121 unsigned long flags;
1124 ath9k_enable_ps(sc);
1126 ath9k_disable_ps(sc);
1127 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
1133 sc->
sc_ah->is_monitoring =
true;
1136 sc->
sc_ah->is_monitoring =
false;
1144 unsigned long flags;
1155 spin_unlock_irqrestore(&common->
cc_lock, flags);
1161 if (ah->
curchan && (old_pos == pos))
1187 if (ath_set_channel(sc, hw, &sc->
sc_ah->channels[pos]) < 0) {
1188 ath_err(common,
"Unable to set channel\n");
1216 #define SUPPORTED_FILTERS \
1217 (FIF_PROMISC_IN_BSS | \
1222 FIF_BCN_PRBRESP_PROMISC | \
1227 static void ath9k_configure_filter(
struct ieee80211_hw *hw,
1228 unsigned int changed_flags,
1229 unsigned int *total_flags,
1238 sc->
rx.rxfilter = *total_flags;
1257 ath_node_attach(sc, sta, vif);
1268 static void ath9k_del_ps_key(
struct ath_softc *sc,
1288 ath9k_del_ps_key(sc, vif, sta);
1289 ath_node_detach(sc, sta);
1330 txq = sc->
tx.txq_map[queue];
1337 qi.tqi_aifs = params->
aifs;
1338 qi.tqi_cwmin = params->
cw_min;
1339 qi.tqi_cwmax = params->
cw_max;
1340 qi.tqi_burstTime = params->
txop * 32;
1343 "Configure tx [queue/halq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
1350 ath_err(common,
"TXQ Update failed\n");
1393 ath9k_del_ps_key(sc, vif, sta);
1402 if (sc->
sc_ah->sw_mgmt_crypto &&
1421 static void ath9k_set_assoc_state(
struct ath_softc *sc,
1425 struct ath_vif *avp = (
void *)vif->drv_priv;
1427 unsigned long flags;
1442 common->
curaid = bss_conf->aid;
1450 spin_unlock_irqrestore(&sc->
sc_pm_lock, flags);
1453 "Primary Station interface: %pM, BSSID: %pM\n",
1457 static void ath9k_bss_assoc_iter(
void *data,
u8 *mac,
struct ieee80211_vif *vif)
1465 if (bss_conf->
assoc)
1466 ath9k_set_assoc_state(sc, vif);
1469 static void ath9k_bss_info_changed(
struct ieee80211_hw *hw,
1475 (BSS_CHANGED_ASSOC | \
1476 BSS_CHANGED_IBSS | \
1477 BSS_CHANGED_BEACON_ENABLED)
1481 struct ath_common *common = ath9k_hw_common(ah);
1482 struct ath_vif *avp = (
void *)vif->drv_priv;
1501 ath9k_bss_assoc_iter, sc);
1537 sc->
beacon.slottime = slottime;
1545 if (changed & CHECK_ANI)
1629 ath_err(ath9k_hw_common(sc->
sc_ah),
"Unknown AMPDU action\n");
1644 unsigned long flags;
1661 spin_unlock_irqrestore(&common->
cc_lock, flags);
1669 spin_unlock_irqrestore(&common->
cc_lock, flags);
1689 static void ath9k_flush(
struct ieee80211_hw *hw,
bool drop)
1693 struct ath_common *common = ath9k_hw_common(ah);
1702 ath_dbg(common,
ANY,
"Device has been unplugged!\n");
1708 ath_dbg(common,
ANY,
"Device not present\n");
1713 for (j = 0; j < timeout; j++) {
1723 npend = ath9k_has_pending_frames(sc, &sc->
tx.txq[i]);
1740 ath_reset(sc,
false);
1750 static bool ath9k_tx_frames_pending(
struct ieee80211_hw *hw)
1759 if (ath9k_has_pending_frames(sc, &sc->
tx.txq[i]))
1765 static int ath9k_tx_last_beacon(
struct ieee80211_hw *hw)
1776 vif = sc->
beacon.bslot[0];
1783 avp = (
void *)vif->drv_priv;
1785 if (!sc->
beacon.tx_processed && !edma) {
1792 status = ath9k_hw_txprocdesc(ah, bf->
bf_desc, &
ts);
1796 sc->
beacon.tx_processed =
true;
1803 return sc->
beacon.tx_last;
1825 for (i = 0; cap &&
new; i++, cap >>= 1) {
1826 if (!(cap &
BIT(0)))
1838 static bool validate_antenna_mask(
struct ath_hw *ah,
u32 val)
1840 switch (val & 0x7) {
1846 return (ah->
caps.rx_chainmask == 1);
1857 if (ah->
caps.rx_chainmask != 1)
1860 if (!validate_antenna_mask(ah, rx_ant) || !tx_ant)
1866 if (ah->
caps.rx_chainmask == 1)
1890 #ifdef CONFIG_ATH9K_DEBUGFS
1894 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
1902 AMKSTR(d_tx_mpdus_queued),
1903 AMKSTR(d_tx_mpdus_completed),
1904 AMKSTR(d_tx_mpdu_xretries),
1905 AMKSTR(d_tx_aggregates),
1906 AMKSTR(d_tx_ampdus_queued_hw),
1907 AMKSTR(d_tx_ampdus_queued_sw),
1908 AMKSTR(d_tx_ampdus_completed),
1909 AMKSTR(d_tx_ampdu_retries),
1910 AMKSTR(d_tx_ampdu_xretries),
1911 AMKSTR(d_tx_fifo_underrun),
1912 AMKSTR(d_tx_op_exceeded),
1913 AMKSTR(d_tx_timer_expiry),
1914 AMKSTR(d_tx_desc_cfg_err),
1915 AMKSTR(d_tx_data_underrun),
1916 AMKSTR(d_tx_delim_underrun),
1918 "d_rx_decrypt_crc_err",
1921 "d_rx_pre_delim_crc_err",
1922 "d_rx_post_delim_crc_err",
1923 "d_rx_decrypt_busy_err",
1925 "d_rx_phyerr_radar",
1926 "d_rx_phyerr_ofdm_timing",
1927 "d_rx_phyerr_cck_timing",
1930 #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
1932 static void ath9k_get_et_strings(
struct ieee80211_hw *hw,
1937 memcpy(data, *ath9k_gstrings_stats,
1938 sizeof(ath9k_gstrings_stats));
1941 static int ath9k_get_et_sset_count(
struct ieee80211_hw *hw,
1945 return ATH9K_SSTATS_LEN;
1949 #define PR_QNUM(_n) (sc->tx.txq_map[_n]->axq_qnum)
1950 #define AWDATA(elem) \
1952 data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem; \
1953 data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem; \
1954 data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem; \
1955 data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem; \
1958 #define AWDATA_RX(elem) \
1960 data[i++] = sc->debug.stats.rxstats.elem; \
1963 static void ath9k_get_et_stats(
struct ieee80211_hw *hw,
1978 AWDATA_RX(rx_pkts_all);
1979 AWDATA_RX(rx_bytes_all);
1981 AWDATA(tx_pkts_all);
1982 AWDATA(tx_bytes_all);
1987 AWDATA(a_queued_hw);
1988 AWDATA(a_queued_sw);
1989 AWDATA(a_completed);
1992 AWDATA(fifo_underrun);
1995 AWDATA(desc_cfg_err);
1996 AWDATA(data_underrun);
1997 AWDATA(delim_underrun);
1999 AWDATA_RX(decrypt_crc_err);
2002 AWDATA_RX(pre_delim_crc_err);
2003 AWDATA_RX(post_delim_crc_err);
2004 AWDATA_RX(decrypt_busy_err);
2010 WARN_ON(i != ATH9K_SSTATS_LEN);
2018 #ifdef CONFIG_PM_SLEEP
2020 static void ath9k_wow_map_triggers(
struct ath_softc *sc,
2037 static void ath9k_wow_add_disassoc_deauth_pattern(
struct ath_softc *sc)
2040 struct ath_common *common = ath9k_hw_common(ah);
2042 int pattern_count = 0;
2085 dis_deauth_mask[i] = 0xff;
2088 dis_deauth_pattern[byte_cnt] = 0xa0;
2101 memcpy((dis_deauth_pattern + byte_cnt), common->
curbssid, ETH_ALEN);
2107 memcpy((dis_deauth_pattern + byte_cnt), common->
curbssid, ETH_ALEN);
2121 dis_deauth_mask[0] = 0xf0;
2127 dis_deauth_pattern[2] = 0xff;
2128 dis_deauth_pattern[3] = 0xff;
2130 dis_deauth_mask[0] = 0xfe;
2133 dis_deauth_mask[1] = 0x03;
2134 dis_deauth_mask[2] = 0xc0;
2136 dis_deauth_mask[0] = 0xef;
2137 dis_deauth_mask[1] = 0x3f;
2138 dis_deauth_mask[2] = 0x00;
2139 dis_deauth_mask[3] = 0xfc;
2142 ath_dbg(common, WOW,
"Adding disassoc/deauth patterns for WoW\n");
2145 pattern_count, byte_cnt);
2152 dis_deauth_pattern[0] = 0xC0;
2155 pattern_count, byte_cnt);
2159 static void ath9k_wow_add_pattern(
struct ath_softc *sc,
2176 wow_pattern = kzalloc(
sizeof(*wow_pattern),
GFP_KERNEL);
2214 struct ath_common *common = ath9k_hw_common(ah);
2215 u32 wow_triggers_enabled = 0;
2220 ath_cancel_work(sc);
2225 ath_dbg(common,
ANY,
"Device not present\n");
2231 ath_dbg(common, WOW,
"None of the WoW triggers enabled\n");
2236 if (!device_can_wakeup(sc->
dev)) {
2237 ath_dbg(common, WOW,
"device_can_wakeup failed, WoW is not enabled\n");
2251 ath_dbg(common, WOW,
"None of the STA vifs are associated\n");
2256 if (sc->
nvifs > 1) {
2257 ath_dbg(common, WOW,
"WoW for multivif is not yet supported\n");
2262 ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
2264 ath_dbg(common, WOW,
"WoW triggers enabled 0x%x\n",
2265 wow_triggers_enabled);
2269 ath9k_stop_btcoex(sc);
2275 ath9k_wow_add_disassoc_deauth_pattern(sc);
2278 ath9k_wow_add_pattern(sc, wowlan);
2286 sc->wow_intr_before_sleep = ah->
imask;
2305 ath_dbg(common,
ANY,
"WoW enabled in ath9k\n");
2317 struct ath_common *common = ath9k_hw_common(ah);
2327 ah->
imask = sc->wow_intr_before_sleep;
2343 ath_dbg(common,
ANY,
"Beacon miss interrupt picked up during WoW sleep\n");
2349 ath_dbg(common,
ANY,
"Waking up due to WoW triggers %s with WoW status = %x\n",
2353 ath_restart_work(sc);
2354 ath9k_start_btcoex(sc);
2376 .start = ath9k_start,
2378 .add_interface = ath9k_add_interface,
2379 .change_interface = ath9k_change_interface,
2380 .remove_interface = ath9k_remove_interface,
2381 .config = ath9k_config,
2382 .configure_filter = ath9k_configure_filter,
2383 .sta_add = ath9k_sta_add,
2384 .sta_remove = ath9k_sta_remove,
2385 .sta_notify = ath9k_sta_notify,
2386 .conf_tx = ath9k_conf_tx,
2387 .bss_info_changed = ath9k_bss_info_changed,
2388 .set_key = ath9k_set_key,
2389 .get_tsf = ath9k_get_tsf,
2390 .set_tsf = ath9k_set_tsf,
2391 .reset_tsf = ath9k_reset_tsf,
2392 .ampdu_action = ath9k_ampdu_action,
2393 .get_survey = ath9k_get_survey,
2395 .set_coverage_class = ath9k_set_coverage_class,
2396 .flush = ath9k_flush,
2397 .tx_frames_pending = ath9k_tx_frames_pending,
2398 .tx_last_beacon = ath9k_tx_last_beacon,
2399 .get_stats = ath9k_get_stats,
2400 .set_antenna = ath9k_set_antenna,
2401 .get_antenna = ath9k_get_antenna,
2403 #ifdef CONFIG_PM_SLEEP
2404 .suspend = ath9k_suspend,
2405 .resume = ath9k_resume,
2406 .set_wakeup = ath9k_set_wakeup,
2409 #ifdef CONFIG_ATH9K_DEBUGFS
2410 .get_et_sset_count = ath9k_get_et_sset_count,
2411 .get_et_stats = ath9k_get_et_stats,
2412 .get_et_strings = ath9k_get_et_strings,