···9292 ---help---9393 Support for the N-PHY.94949595- This enables support for devices with N-PHY revision up to 2.9595+ This enables support for devices with N-PHY.96969797 Say N if you expect high stability and performance. Saying Y will not9898 affect other devices support and may provide support for basic needs.
···533533534534void iwlagn_temperature(struct iwl_priv *priv)535535{536536- /* store temperature from statistics (in Celsius) */537537- priv->temperature =538538- le32_to_cpu(priv->_agn.statistics.general.common.temperature);536536+ /* store temperature from correct statistics (in Celsius) */537537+ priv->temperature = le32_to_cpu((iwl_bt_statistics(priv)) ?538538+ priv->_agn.statistics_bt.general.common.temperature :539539+ priv->_agn.statistics.general.common.temperature);539540 iwl_tt_handler(priv);540541}541542···993992 }994993995994 return -1;996996-}997997-998998-/* Calc max signal level (dBm) among 3 possible receivers */999999-static inline int iwlagn_calc_rssi(struct iwl_priv *priv,10001000- struct iwl_rx_phy_res *rx_resp)10011001-{10021002- return priv->cfg->ops->utils->calc_rssi(priv, rx_resp);10031003-}10041004-10051005-static u32 iwlagn_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)10061006-{10071007- u32 decrypt_out = 0;10081008-10091009- if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) ==10101010- RX_RES_STATUS_STATION_FOUND)10111011- decrypt_out |= (RX_RES_STATUS_STATION_FOUND |10121012- RX_RES_STATUS_NO_STATION_INFO_MISMATCH);10131013-10141014- decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK);10151015-10161016- /* packet was not encrypted */10171017- if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==10181018- RX_RES_STATUS_SEC_TYPE_NONE)10191019- return decrypt_out;10201020-10211021- /* packet was encrypted with unknown alg */10221022- if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==10231023- RX_RES_STATUS_SEC_TYPE_ERR)10241024- return decrypt_out;10251025-10261026- /* decryption was not done in HW */10271027- if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) !=10281028- RX_MPDU_RES_STATUS_DEC_DONE_MSK)10291029- return decrypt_out;10301030-10311031- switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {10321032-10331033- case RX_RES_STATUS_SEC_TYPE_CCMP:10341034- /* alg is CCM: check MIC only */10351035- if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK))10361036- /* Bad MIC */10371037- decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;10381038- else10391039- decrypt_out |= RX_RES_STATUS_DECRYPT_OK;10401040-10411041- break;10421042-10431043- case RX_RES_STATUS_SEC_TYPE_TKIP:10441044- if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) {10451045- /* Bad TTAK */10461046- decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;10471047- break;10481048- }10491049- /* fall through if TTAK OK */10501050- default:10511051- if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))10521052- decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;10531053- else10541054- decrypt_out |= RX_RES_STATUS_DECRYPT_OK;10551055- break;10561056- }10571057-10581058- IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n",10591059- decrypt_in, decrypt_out);10601060-10611061- return decrypt_out;10621062-}10631063-10641064-static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,10651065- struct ieee80211_hdr *hdr,10661066- u16 len,10671067- u32 ampdu_status,10681068- struct iwl_rx_mem_buffer *rxb,10691069- struct ieee80211_rx_status *stats)10701070-{10711071- struct sk_buff *skb;10721072- __le16 fc = hdr->frame_control;10731073-10741074- /* We only process data packets if the interface is open */10751075- if (unlikely(!priv->is_open)) {10761076- IWL_DEBUG_DROP_LIMIT(priv,10771077- "Dropping packet while interface is not open.\n");10781078- return;10791079- }10801080-10811081- /* In case of HW accelerated crypto and bad decryption, drop */10821082- if (!priv->cfg->mod_params->sw_crypto &&10831083- iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats))10841084- return;10851085-10861086- skb = dev_alloc_skb(128);10871087- if (!skb) {10881088- IWL_ERR(priv, "dev_alloc_skb failed\n");10891089- return;10901090- }10911091-10921092- skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len);10931093-10941094- iwl_update_stats(priv, false, fc, len);10951095- memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));10961096-10971097- ieee80211_rx(priv->hw, skb);10981098- priv->alloc_rxb_page--;10991099- rxb->page = NULL;11001100-}11011101-11021102-/* Called for REPLY_RX (legacy ABG frames), or11031103- * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */11041104-void iwlagn_rx_reply_rx(struct iwl_priv *priv,11051105- struct iwl_rx_mem_buffer *rxb)11061106-{11071107- struct ieee80211_hdr *header;11081108- struct ieee80211_rx_status rx_status;11091109- struct iwl_rx_packet *pkt = rxb_addr(rxb);11101110- struct iwl_rx_phy_res *phy_res;11111111- __le32 rx_pkt_status;11121112- struct iwl_rx_mpdu_res_start *amsdu;11131113- u32 len;11141114- u32 ampdu_status;11151115- u32 rate_n_flags;11161116-11171117- /**11181118- * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently.11191119- * REPLY_RX: physical layer info is in this buffer11201120- * REPLY_RX_MPDU_CMD: physical layer info was sent in separate11211121- * command and cached in priv->last_phy_res11221122- *11231123- * Here we set up local variables depending on which command is11241124- * received.11251125- */11261126- if (pkt->hdr.cmd == REPLY_RX) {11271127- phy_res = (struct iwl_rx_phy_res *)pkt->u.raw;11281128- header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res)11291129- + phy_res->cfg_phy_cnt);11301130-11311131- len = le16_to_cpu(phy_res->byte_count);11321132- rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) +11331133- phy_res->cfg_phy_cnt + len);11341134- ampdu_status = le32_to_cpu(rx_pkt_status);11351135- } else {11361136- if (!priv->_agn.last_phy_res_valid) {11371137- IWL_ERR(priv, "MPDU frame without cached PHY data\n");11381138- return;11391139- }11401140- phy_res = &priv->_agn.last_phy_res;11411141- amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw;11421142- header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu));11431143- len = le16_to_cpu(amsdu->byte_count);11441144- rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len);11451145- ampdu_status = iwlagn_translate_rx_status(priv,11461146- le32_to_cpu(rx_pkt_status));11471147- }11481148-11491149- if ((unlikely(phy_res->cfg_phy_cnt > 20))) {11501150- IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n",11511151- phy_res->cfg_phy_cnt);11521152- return;11531153- }11541154-11551155- if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) ||11561156- !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {11571157- IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n",11581158- le32_to_cpu(rx_pkt_status));11591159- return;11601160- }11611161-11621162- /* This will be used in several places later */11631163- rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);11641164-11651165- /* rx_status carries information about the packet to mac80211 */11661166- rx_status.mactime = le64_to_cpu(phy_res->timestamp);11671167- rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?11681168- IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;11691169- rx_status.freq =11701170- ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),11711171- rx_status.band);11721172- rx_status.rate_idx =11731173- iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);11741174- rx_status.flag = 0;11751175-11761176- /* TSF isn't reliable. In order to allow smooth user experience,11771177- * this W/A doesn't propagate it to the mac80211 */11781178- /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/11791179-11801180- priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);11811181-11821182- /* Find max signal strength (dBm) among 3 antenna/receiver chains */11831183- rx_status.signal = iwlagn_calc_rssi(priv, phy_res);11841184-11851185- iwl_dbg_log_rx_data_frame(priv, len, header);11861186- IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",11871187- rx_status.signal, (unsigned long long)rx_status.mactime);11881188-11891189- /*11901190- * "antenna number"11911191- *11921192- * It seems that the antenna field in the phy flags value11931193- * is actually a bit field. This is undefined by radiotap,11941194- * it wants an actual antenna number but I always get "7"11951195- * for most legacy frames I receive indicating that the11961196- * same frame was received on all three RX chains.11971197- *11981198- * I think this field should be removed in favor of a11991199- * new 802.11n radiotap field "RX chains" that is defined12001200- * as a bitmask.12011201- */12021202- rx_status.antenna =12031203- (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK)12041204- >> RX_RES_PHY_FLAGS_ANTENNA_POS;12051205-12061206- /* set the preamble flag if appropriate */12071207- if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)12081208- rx_status.flag |= RX_FLAG_SHORTPRE;12091209-12101210- /* Set up the HT phy flags */12111211- if (rate_n_flags & RATE_MCS_HT_MSK)12121212- rx_status.flag |= RX_FLAG_HT;12131213- if (rate_n_flags & RATE_MCS_HT40_MSK)12141214- rx_status.flag |= RX_FLAG_40MHZ;12151215- if (rate_n_flags & RATE_MCS_SGI_MSK)12161216- rx_status.flag |= RX_FLAG_SHORT_GI;12171217-12181218- iwlagn_pass_packet_to_mac80211(priv, header, len, ampdu_status,12191219- rxb, &rx_status);12201220-}12211221-12221222-/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).12231223- * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */12241224-void iwlagn_rx_reply_rx_phy(struct iwl_priv *priv,12251225- struct iwl_rx_mem_buffer *rxb)12261226-{12271227- struct iwl_rx_packet *pkt = rxb_addr(rxb);12281228- priv->_agn.last_phy_res_valid = true;12291229- memcpy(&priv->_agn.last_phy_res, pkt->u.raw,12301230- sizeof(struct iwl_rx_phy_res));1231995}12329961233997static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
+2-176
drivers/net/wireless/iwlwifi/iwl-agn.c
···424424 return 0;425425}426426427427-/******************************************************************************428428- *429429- * Generic RX handler implementations430430- *431431- ******************************************************************************/432432-static void iwl_rx_reply_alive(struct iwl_priv *priv,433433- struct iwl_rx_mem_buffer *rxb)434434-{435435- struct iwl_rx_packet *pkt = rxb_addr(rxb);436436- struct iwl_alive_resp *palive;437437- struct delayed_work *pwork;438438-439439- palive = &pkt->u.alive_frame;440440-441441- IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision "442442- "0x%01X 0x%01X\n",443443- palive->is_valid, palive->ver_type,444444- palive->ver_subtype);445445-446446- if (palive->ver_subtype == INITIALIZE_SUBTYPE) {447447- IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");448448- memcpy(&priv->card_alive_init,449449- &pkt->u.alive_frame,450450- sizeof(struct iwl_init_alive_resp));451451- pwork = &priv->init_alive_start;452452- } else {453453- IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");454454- memcpy(&priv->card_alive, &pkt->u.alive_frame,455455- sizeof(struct iwl_alive_resp));456456- pwork = &priv->alive_start;457457- }458458-459459- /* We delay the ALIVE response by 5ms to460460- * give the HW RF Kill time to activate... */461461- if (palive->is_valid == UCODE_VALID_OK)462462- queue_delayed_work(priv->workqueue, pwork,463463- msecs_to_jiffies(5));464464- else {465465- IWL_WARN(priv, "%s uCode did not respond OK.\n",466466- (palive->ver_subtype == INITIALIZE_SUBTYPE) ?467467- "init" : "runtime");468468- /*469469- * If fail to load init uCode,470470- * let's try to load the init uCode again.471471- * We should not get into this situation, but if it472472- * does happen, we should not move on and loading "runtime"473473- * without proper calibrate the device.474474- */475475- if (palive->ver_subtype == INITIALIZE_SUBTYPE)476476- priv->ucode_type = UCODE_NONE;477477- queue_work(priv->workqueue, &priv->restart);478478- }479479-}480480-481427static void iwl_bg_beacon_update(struct work_struct *work)482428{483429 struct iwl_priv *priv =···658712 }659713}660714661661-static void iwlagn_rx_beacon_notif(struct iwl_priv *priv,662662- struct iwl_rx_mem_buffer *rxb)663663-{664664- struct iwl_rx_packet *pkt = rxb_addr(rxb);665665- struct iwlagn_beacon_notif *beacon = (void *)pkt->u.raw;666666-#ifdef CONFIG_IWLWIFI_DEBUG667667- u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status);668668- u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);669669-670670- IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d "671671- "tsf:0x%.8x%.8x rate:%d\n",672672- status & TX_STATUS_MSK,673673- beacon->beacon_notify_hdr.failure_frame,674674- le32_to_cpu(beacon->ibss_mgr_status),675675- le32_to_cpu(beacon->high_tsf),676676- le32_to_cpu(beacon->low_tsf), rate);677677-#endif678678-679679- priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);680680-681681- if (!test_bit(STATUS_EXIT_PENDING, &priv->status))682682- queue_work(priv->workqueue, &priv->beacon_update);683683-}684684-685685-/* Handle notification from uCode that card's power state is changing686686- * due to software, hardware, or critical temperature RFKILL */687687-static void iwl_rx_card_state_notif(struct iwl_priv *priv,688688- struct iwl_rx_mem_buffer *rxb)689689-{690690- struct iwl_rx_packet *pkt = rxb_addr(rxb);691691- u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);692692- unsigned long status = priv->status;693693-694694- IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",695695- (flags & HW_CARD_DISABLED) ? "Kill" : "On",696696- (flags & SW_CARD_DISABLED) ? "Kill" : "On",697697- (flags & CT_CARD_DISABLED) ?698698- "Reached" : "Not reached");699699-700700- if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |701701- CT_CARD_DISABLED)) {702702-703703- iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,704704- CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);705705-706706- iwl_write_direct32(priv, HBUS_TARG_MBX_C,707707- HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);708708-709709- if (!(flags & RXON_CARD_DISABLED)) {710710- iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,711711- CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);712712- iwl_write_direct32(priv, HBUS_TARG_MBX_C,713713- HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);714714- }715715- if (flags & CT_CARD_DISABLED)716716- iwl_tt_enter_ct_kill(priv);717717- }718718- if (!(flags & CT_CARD_DISABLED))719719- iwl_tt_exit_ct_kill(priv);720720-721721- if (flags & HW_CARD_DISABLED)722722- set_bit(STATUS_RF_KILL_HW, &priv->status);723723- else724724- clear_bit(STATUS_RF_KILL_HW, &priv->status);725725-726726-727727- if (!(flags & RXON_CARD_DISABLED))728728- iwl_scan_cancel(priv);729729-730730- if ((test_bit(STATUS_RF_KILL_HW, &status) !=731731- test_bit(STATUS_RF_KILL_HW, &priv->status)))732732- wiphy_rfkill_set_hw_state(priv->hw->wiphy,733733- test_bit(STATUS_RF_KILL_HW, &priv->status));734734- else735735- wake_up_interruptible(&priv->wait_command_queue);736736-}737737-738715static void iwl_bg_tx_flush(struct work_struct *work)739716{740717 struct iwl_priv *priv =···674805 IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n");675806 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);676807 }677677-}678678-679679-/**680680- * iwl_setup_rx_handlers - Initialize Rx handler callbacks681681- *682682- * Setup the RX handlers for each of the reply types sent from the uCode683683- * to the host.684684- *685685- * This function chains into the hardware specific files for them to setup686686- * any hardware specific handlers as well.687687- */688688-static void iwl_setup_rx_handlers(struct iwl_priv *priv)689689-{690690- priv->rx_handlers[REPLY_ALIVE] = iwl_rx_reply_alive;691691- priv->rx_handlers[REPLY_ERROR] = iwl_rx_reply_error;692692- priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_rx_csa;693693- priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] =694694- iwl_rx_spectrum_measure_notif;695695- priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_rx_pm_sleep_notif;696696- priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] =697697- iwl_rx_pm_debug_statistics_notif;698698- priv->rx_handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif;699699-700700- /*701701- * The same handler is used for both the REPLY to a discrete702702- * statistics request from the host as well as for the periodic703703- * statistics notifications (after received beacons) from the uCode.704704- */705705- priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl_reply_statistics;706706- priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl_rx_statistics;707707-708708- iwl_setup_rx_scan_handlers(priv);709709-710710- /* status change handler */711711- priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl_rx_card_state_notif;712712-713713- priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] =714714- iwl_rx_missed_beacon_notif;715715- /* Rx handlers */716716- priv->rx_handlers[REPLY_RX_PHY_CMD] = iwlagn_rx_reply_rx_phy;717717- priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwlagn_rx_reply_rx;718718- /* block ack */719719- priv->rx_handlers[REPLY_COMPRESSED_BA] = iwlagn_rx_reply_compressed_ba;720720- /* Set up hardware specific Rx handlers */721721- priv->cfg->ops->lib->rx_handler_setup(priv);722808}723809724810/**···37363912 IWL_DELAY_NEXT_FORCE_RF_RESET;37373913 priv->force_reset[IWL_FW_RESET].reset_duration =37383914 IWL_DELAY_NEXT_FORCE_FW_RELOAD;39153915+39163916+ priv->rx_statistics_jiffies = jiffies;3739391737403918 /* Choose which receivers/antennas to use */37413919 if (priv->cfg->ops->hcmd->set_rxon_chain)
···12611261 /* track IBSS manager (last beacon) status */12621262 u32 ibss_manager;1263126312641264- /* storing the jiffies when the plcp error rate is received */12651265- unsigned long plcp_jiffies;12641264+ /* jiffies when last recovery from statistics was performed */12651265+ unsigned long rx_statistics_jiffies;1266126612671267 /* force reset */12681268 struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
+558-103
drivers/net/wireless/iwlwifi/iwl-rx.c
···29293030#include <linux/etherdevice.h>3131#include <linux/slab.h>3232+#include <linux/sched.h>3233#include <net/mac80211.h>3334#include <asm/unaligned.h>3435#include "iwl-eeprom.h"···3938#include "iwl-io.h"4039#include "iwl-helpers.h"4140#include "iwl-agn-calib.h"4242-/************************** RX-FUNCTIONS ****************************/4141+#include "iwl-agn.h"4242+4343+/******************************************************************************4444+ *4545+ * RX path functions4646+ *4747+ ******************************************************************************/4848+4349/*4450 * Rx theory of operation4551 *···219211 return -ENOMEM;220212}221213222222-void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,214214+/******************************************************************************215215+ *216216+ * Generic RX handler implementations217217+ *218218+ ******************************************************************************/219219+220220+static void iwl_rx_reply_alive(struct iwl_priv *priv,221221+ struct iwl_rx_mem_buffer *rxb)222222+{223223+ struct iwl_rx_packet *pkt = rxb_addr(rxb);224224+ struct iwl_alive_resp *palive;225225+ struct delayed_work *pwork;226226+227227+ palive = &pkt->u.alive_frame;228228+229229+ IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision "230230+ "0x%01X 0x%01X\n",231231+ palive->is_valid, palive->ver_type,232232+ palive->ver_subtype);233233+234234+ if (palive->ver_subtype == INITIALIZE_SUBTYPE) {235235+ IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");236236+ memcpy(&priv->card_alive_init,237237+ &pkt->u.alive_frame,238238+ sizeof(struct iwl_init_alive_resp));239239+ pwork = &priv->init_alive_start;240240+ } else {241241+ IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");242242+ memcpy(&priv->card_alive, &pkt->u.alive_frame,243243+ sizeof(struct iwl_alive_resp));244244+ pwork = &priv->alive_start;245245+ }246246+247247+ /* We delay the ALIVE response by 5ms to248248+ * give the HW RF Kill time to activate... */249249+ if (palive->is_valid == UCODE_VALID_OK)250250+ queue_delayed_work(priv->workqueue, pwork,251251+ msecs_to_jiffies(5));252252+ else {253253+ IWL_WARN(priv, "%s uCode did not respond OK.\n",254254+ (palive->ver_subtype == INITIALIZE_SUBTYPE) ?255255+ "init" : "runtime");256256+ /*257257+ * If fail to load init uCode,258258+ * let's try to load the init uCode again.259259+ * We should not get into this situation, but if it260260+ * does happen, we should not move on and loading "runtime"261261+ * without proper calibrate the device.262262+ */263263+ if (palive->ver_subtype == INITIALIZE_SUBTYPE)264264+ priv->ucode_type = UCODE_NONE;265265+ queue_work(priv->workqueue, &priv->restart);266266+ }267267+}268268+269269+static void iwl_rx_reply_error(struct iwl_priv *priv,270270+ struct iwl_rx_mem_buffer *rxb)271271+{272272+ struct iwl_rx_packet *pkt = rxb_addr(rxb);273273+274274+ IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) "275275+ "seq 0x%04X ser 0x%08X\n",276276+ le32_to_cpu(pkt->u.err_resp.error_type),277277+ get_cmd_string(pkt->u.err_resp.cmd_id),278278+ pkt->u.err_resp.cmd_id,279279+ le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num),280280+ le32_to_cpu(pkt->u.err_resp.error_info));281281+}282282+283283+static void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)284284+{285285+ struct iwl_rx_packet *pkt = rxb_addr(rxb);286286+ struct iwl_csa_notification *csa = &(pkt->u.csa_notif);287287+ /*288288+ * MULTI-FIXME289289+ * See iwl_mac_channel_switch.290290+ */291291+ struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];292292+ struct iwl_rxon_cmd *rxon = (void *)&ctx->active;293293+294294+ if (priv->switch_rxon.switch_in_progress) {295295+ if (!le32_to_cpu(csa->status) &&296296+ (csa->channel == priv->switch_rxon.channel)) {297297+ rxon->channel = csa->channel;298298+ ctx->staging.channel = csa->channel;299299+ IWL_DEBUG_11H(priv, "CSA notif: channel %d\n",300300+ le16_to_cpu(csa->channel));301301+ iwl_chswitch_done(priv, true);302302+ } else {303303+ IWL_ERR(priv, "CSA notif (fail) : channel %d\n",304304+ le16_to_cpu(csa->channel));305305+ iwl_chswitch_done(priv, false);306306+ }307307+ }308308+}309309+310310+311311+static void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,223312 struct iwl_rx_mem_buffer *rxb)224313{225314 struct iwl_rx_packet *pkt = rxb_addr(rxb);···330225331226 memcpy(&priv->measure_report, report, sizeof(*report));332227 priv->measurement_status |= MEASUREMENT_READY;228228+}229229+230230+static void iwl_rx_pm_sleep_notif(struct iwl_priv *priv,231231+ struct iwl_rx_mem_buffer *rxb)232232+{233233+#ifdef CONFIG_IWLWIFI_DEBUG234234+ struct iwl_rx_packet *pkt = rxb_addr(rxb);235235+ struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);236236+ IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",237237+ sleep->pm_sleep_mode, sleep->pm_wakeup_src);238238+#endif239239+}240240+241241+static void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv,242242+ struct iwl_rx_mem_buffer *rxb)243243+{244244+ struct iwl_rx_packet *pkt = rxb_addr(rxb);245245+ u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;246246+ IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "247247+ "notification for %s:\n", len,248248+ get_cmd_string(pkt->hdr.cmd));249249+ iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len);250250+}251251+252252+static void iwl_rx_beacon_notif(struct iwl_priv *priv,253253+ struct iwl_rx_mem_buffer *rxb)254254+{255255+ struct iwl_rx_packet *pkt = rxb_addr(rxb);256256+ struct iwlagn_beacon_notif *beacon = (void *)pkt->u.raw;257257+#ifdef CONFIG_IWLWIFI_DEBUG258258+ u16 status = le16_to_cpu(beacon->beacon_notify_hdr.status.status);259259+ u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);260260+261261+ IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d "262262+ "tsf:0x%.8x%.8x rate:%d\n",263263+ status & TX_STATUS_MSK,264264+ beacon->beacon_notify_hdr.failure_frame,265265+ le32_to_cpu(beacon->ibss_mgr_status),266266+ le32_to_cpu(beacon->high_tsf),267267+ le32_to_cpu(beacon->low_tsf), rate);268268+#endif269269+270270+ priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);271271+272272+ if (!test_bit(STATUS_EXIT_PENDING, &priv->status))273273+ queue_work(priv->workqueue, &priv->beacon_update);333274}334275335276/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */···449298 * When the plcp error is exceeding the thresholds, reset the radio450299 * to improve the throughput.451300 */452452-static bool iwl_good_plcp_health(struct iwl_priv *priv, struct iwl_rx_packet *pkt)301301+static bool iwl_good_plcp_health(struct iwl_priv *priv,302302+ struct iwl_rx_packet *pkt, unsigned int msecs)453303{454454- bool rc = true;455455- int combined_plcp_delta;456456- unsigned int plcp_msec;457457- unsigned long plcp_received_jiffies;304304+ int delta;305305+ int threshold = priv->cfg->base_params->plcp_delta_threshold;458306459459- if (priv->cfg->base_params->plcp_delta_threshold ==460460- IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {307307+ if (threshold == IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) {461308 IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n");462462- return rc;309309+ return true;463310 }464311465465- /*466466- * check for plcp_err and trigger radio reset if it exceeds467467- * the plcp error threshold plcp_delta.468468- */469469- plcp_received_jiffies = jiffies;470470- plcp_msec = jiffies_to_msecs((long) plcp_received_jiffies -471471- (long) priv->plcp_jiffies);472472- priv->plcp_jiffies = plcp_received_jiffies;473473- /*474474- * check to make sure plcp_msec is not 0 to prevent division475475- * by zero.476476- */477477- if (plcp_msec) {478478- struct statistics_rx_phy *ofdm;479479- struct statistics_rx_ht_phy *ofdm_ht;312312+ if (iwl_bt_statistics(priv)) {313313+ struct statistics_rx_bt *cur, *old;480314481481- if (iwl_bt_statistics(priv)) {482482- ofdm = &pkt->u.stats_bt.rx.ofdm;483483- ofdm_ht = &pkt->u.stats_bt.rx.ofdm_ht;484484- combined_plcp_delta =485485- (le32_to_cpu(ofdm->plcp_err) -486486- le32_to_cpu(priv->_agn.statistics_bt.487487- rx.ofdm.plcp_err)) +488488- (le32_to_cpu(ofdm_ht->plcp_err) -489489- le32_to_cpu(priv->_agn.statistics_bt.490490- rx.ofdm_ht.plcp_err));491491- } else {492492- ofdm = &pkt->u.stats.rx.ofdm;493493- ofdm_ht = &pkt->u.stats.rx.ofdm_ht;494494- combined_plcp_delta =495495- (le32_to_cpu(ofdm->plcp_err) -496496- le32_to_cpu(priv->_agn.statistics.497497- rx.ofdm.plcp_err)) +498498- (le32_to_cpu(ofdm_ht->plcp_err) -499499- le32_to_cpu(priv->_agn.statistics.500500- rx.ofdm_ht.plcp_err));501501- }315315+ cur = &pkt->u.stats_bt.rx;316316+ old = &priv->_agn.statistics_bt.rx;502317503503- if ((combined_plcp_delta > 0) &&504504- ((combined_plcp_delta * 100) / plcp_msec) >505505- priv->cfg->base_params->plcp_delta_threshold) {506506- /*507507- * if plcp_err exceed the threshold,508508- * the following data is printed in csv format:509509- * Text: plcp_err exceeded %d,510510- * Received ofdm.plcp_err,511511- * Current ofdm.plcp_err,512512- * Received ofdm_ht.plcp_err,513513- * Current ofdm_ht.plcp_err,514514- * combined_plcp_delta,515515- * plcp_msec516516- */517517- IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, "518518- "%u, %u, %u, %u, %d, %u mSecs\n",519519- priv->cfg->base_params->plcp_delta_threshold,520520- le32_to_cpu(ofdm->plcp_err),521521- le32_to_cpu(ofdm->plcp_err),522522- le32_to_cpu(ofdm_ht->plcp_err),523523- le32_to_cpu(ofdm_ht->plcp_err),524524- combined_plcp_delta, plcp_msec);318318+ delta = le32_to_cpu(cur->ofdm.plcp_err) -319319+ le32_to_cpu(old->ofdm.plcp_err) +320320+ le32_to_cpu(cur->ofdm_ht.plcp_err) -321321+ le32_to_cpu(old->ofdm_ht.plcp_err);322322+ } else {323323+ struct statistics_rx *cur, *old;525324526526- rc = false;527527- }325325+ cur = &pkt->u.stats.rx;326326+ old = &priv->_agn.statistics.rx;327327+328328+ delta = le32_to_cpu(cur->ofdm.plcp_err) -329329+ le32_to_cpu(old->ofdm.plcp_err) +330330+ le32_to_cpu(cur->ofdm_ht.plcp_err) -331331+ le32_to_cpu(old->ofdm_ht.plcp_err);528332 }529529- return rc;333333+334334+ /* Can be negative if firmware reseted statistics */335335+ if (delta <= 0)336336+ return true;337337+338338+ if ((delta * 100 / msecs) > threshold) {339339+ IWL_DEBUG_RADIO(priv,340340+ "plcp health threshold %u delta %d msecs %u\n",341341+ threshold, delta, msecs);342342+ return false;343343+ }344344+345345+ return true;530346}531347532532-static void iwl_recover_from_statistics(struct iwl_priv *priv, struct iwl_rx_packet *pkt)348348+static void iwl_recover_from_statistics(struct iwl_priv *priv,349349+ struct iwl_rx_packet *pkt)533350{534351 const struct iwl_mod_params *mod_params = priv->cfg->mod_params;352352+ unsigned int msecs;353353+ unsigned long stamp;535354536536- if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||537537- !iwl_is_any_associated(priv))355355+ if (test_bit(STATUS_EXIT_PENDING, &priv->status))356356+ return;357357+358358+ stamp = jiffies;359359+ msecs = jiffies_to_msecs(stamp - priv->rx_statistics_jiffies);360360+361361+ /* Only gather statistics and update time stamp when not associated */362362+ if (!iwl_is_any_associated(priv))363363+ goto out;364364+365365+ /* Do not check/recover when do not have enough statistics data */366366+ if (msecs < 99)538367 return;539368540369 if (mod_params->ack_check && !iwl_good_ack_health(priv, pkt)) {···523392 return;524393 }525394526526- if (mod_params->plcp_check && !iwl_good_plcp_health(priv, pkt))395395+ if (mod_params->plcp_check && !iwl_good_plcp_health(priv, pkt, msecs))527396 iwl_force_reset(priv, IWL_RF_RESET, false);397397+398398+out:399399+ if (iwl_bt_statistics(priv))400400+ memcpy(&priv->_agn.statistics_bt, &pkt->u.stats_bt,401401+ sizeof(priv->_agn.statistics_bt));402402+ else403403+ memcpy(&priv->_agn.statistics, &pkt->u.stats,404404+ sizeof(priv->_agn.statistics));405405+406406+ priv->rx_statistics_jiffies = stamp;528407}529408530409/* Calculate noise level, based on measurements during network silence just···583442 last_rx_noise);584443}585444586586-#ifdef CONFIG_IWLWIFI_DEBUGFS587445/*588446 * based on the assumption of all statistics counter are in DWORD589447 * FIXME: This function is for debugging, do not deal with···591451static void iwl_accumulative_statistics(struct iwl_priv *priv,592452 __le32 *stats)593453{454454+#ifdef CONFIG_IWLWIFI_DEBUGFS594455 int i, size;595456 __le32 *prev_stats;596457 u32 *accum_stats;···639498 accum_tx->tx_power.ant_a = tx->tx_power.ant_a;640499 accum_tx->tx_power.ant_b = tx->tx_power.ant_b;641500 accum_tx->tx_power.ant_c = tx->tx_power.ant_c;642642-}643501#endif502502+}644503645645-#define REG_RECALIB_PERIOD (60)646646-647647-void iwl_rx_statistics(struct iwl_priv *priv,504504+static void iwl_rx_statistics(struct iwl_priv *priv,648505 struct iwl_rx_mem_buffer *rxb)649506{507507+ const int reg_recalib_period = 60;650508 int change;651509 struct iwl_rx_packet *pkt = rxb_addr(rxb);652510···662522 STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=663523 (pkt->u.stats_bt.flag &664524 STATISTICS_REPLY_FLG_HT40_MODE_MSK)));665665-#ifdef CONFIG_IWLWIFI_DEBUGFS666666- iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats_bt);667667-#endif668525526526+ iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats_bt);669527 } else {670528 IWL_DEBUG_RX(priv,671529 "Statistics notification received (%d vs %d).\n",···677539 STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=678540 (pkt->u.stats.flag &679541 STATISTICS_REPLY_FLG_HT40_MODE_MSK)));680680-#ifdef CONFIG_IWLWIFI_DEBUGFS681681- iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);682682-#endif683542543543+ iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);684544 }685545686546 iwl_recover_from_statistics(priv, pkt);687547688688- if (iwl_bt_statistics(priv))689689- memcpy(&priv->_agn.statistics_bt, &pkt->u.stats_bt,690690- sizeof(priv->_agn.statistics_bt));691691- else692692- memcpy(&priv->_agn.statistics, &pkt->u.stats,693693- sizeof(priv->_agn.statistics));694694-695548 set_bit(STATUS_STATISTICS, &priv->status);696549697550 /* Reschedule the statistics timer to occur in698698- * REG_RECALIB_PERIOD seconds to ensure we get a551551+ * reg_recalib_period seconds to ensure we get a699552 * thermal update even if the uCode doesn't give700553 * us one */701554 mod_timer(&priv->statistics_periodic, jiffies +702702- msecs_to_jiffies(REG_RECALIB_PERIOD * 1000));555555+ msecs_to_jiffies(reg_recalib_period * 1000));703556704557 if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) &&705558 (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) {···701572 priv->cfg->ops->lib->temp_ops.temperature(priv);702573}703574704704-void iwl_reply_statistics(struct iwl_priv *priv,705705- struct iwl_rx_mem_buffer *rxb)575575+static void iwl_rx_reply_statistics(struct iwl_priv *priv,576576+ struct iwl_rx_mem_buffer *rxb)706577{707578 struct iwl_rx_packet *pkt = rxb_addr(rxb);708579···726597 iwl_rx_statistics(priv, rxb);727598}728599729729-void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,730730- struct iwl_rx_mem_buffer *rxb)600600+/* Handle notification from uCode that card's power state is changing601601+ * due to software, hardware, or critical temperature RFKILL */602602+static void iwl_rx_card_state_notif(struct iwl_priv *priv,603603+ struct iwl_rx_mem_buffer *rxb)604604+{605605+ struct iwl_rx_packet *pkt = rxb_addr(rxb);606606+ u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);607607+ unsigned long status = priv->status;608608+609609+ IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n",610610+ (flags & HW_CARD_DISABLED) ? "Kill" : "On",611611+ (flags & SW_CARD_DISABLED) ? "Kill" : "On",612612+ (flags & CT_CARD_DISABLED) ?613613+ "Reached" : "Not reached");614614+615615+ if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |616616+ CT_CARD_DISABLED)) {617617+618618+ iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,619619+ CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);620620+621621+ iwl_write_direct32(priv, HBUS_TARG_MBX_C,622622+ HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);623623+624624+ if (!(flags & RXON_CARD_DISABLED)) {625625+ iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,626626+ CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);627627+ iwl_write_direct32(priv, HBUS_TARG_MBX_C,628628+ HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);629629+ }630630+ if (flags & CT_CARD_DISABLED)631631+ iwl_tt_enter_ct_kill(priv);632632+ }633633+ if (!(flags & CT_CARD_DISABLED))634634+ iwl_tt_exit_ct_kill(priv);635635+636636+ if (flags & HW_CARD_DISABLED)637637+ set_bit(STATUS_RF_KILL_HW, &priv->status);638638+ else639639+ clear_bit(STATUS_RF_KILL_HW, &priv->status);640640+641641+642642+ if (!(flags & RXON_CARD_DISABLED))643643+ iwl_scan_cancel(priv);644644+645645+ if ((test_bit(STATUS_RF_KILL_HW, &status) !=646646+ test_bit(STATUS_RF_KILL_HW, &priv->status)))647647+ wiphy_rfkill_set_hw_state(priv->hw->wiphy,648648+ test_bit(STATUS_RF_KILL_HW, &priv->status));649649+ else650650+ wake_up_interruptible(&priv->wait_command_queue);651651+}652652+653653+static void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,654654+ struct iwl_rx_mem_buffer *rxb)731655732656{733657 struct iwl_rx_packet *pkt = rxb_addr(rxb);···800618 }801619}802620621621+/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).622622+ * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */623623+static void iwl_rx_reply_rx_phy(struct iwl_priv *priv,624624+ struct iwl_rx_mem_buffer *rxb)625625+{626626+ struct iwl_rx_packet *pkt = rxb_addr(rxb);627627+628628+ priv->_agn.last_phy_res_valid = true;629629+ memcpy(&priv->_agn.last_phy_res, pkt->u.raw,630630+ sizeof(struct iwl_rx_phy_res));631631+}632632+803633/*804634 * returns non-zero if packet should be dropped805635 */806806-int iwl_set_decrypted_flag(struct iwl_priv *priv,807807- struct ieee80211_hdr *hdr,808808- u32 decrypt_res,809809- struct ieee80211_rx_status *stats)636636+static int iwl_set_decrypted_flag(struct iwl_priv *priv,637637+ struct ieee80211_hdr *hdr,638638+ u32 decrypt_res,639639+ struct ieee80211_rx_status *stats)810640{811641 u16 fc = le16_to_cpu(hdr->frame_control);812642···862668 break;863669 }864670 return 0;671671+}672672+673673+static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv,674674+ struct ieee80211_hdr *hdr,675675+ u16 len,676676+ u32 ampdu_status,677677+ struct iwl_rx_mem_buffer *rxb,678678+ struct ieee80211_rx_status *stats)679679+{680680+ struct sk_buff *skb;681681+ __le16 fc = hdr->frame_control;682682+683683+ /* We only process data packets if the interface is open */684684+ if (unlikely(!priv->is_open)) {685685+ IWL_DEBUG_DROP_LIMIT(priv,686686+ "Dropping packet while interface is not open.\n");687687+ return;688688+ }689689+690690+ /* In case of HW accelerated crypto and bad decryption, drop */691691+ if (!priv->cfg->mod_params->sw_crypto &&692692+ iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats))693693+ return;694694+695695+ skb = dev_alloc_skb(128);696696+ if (!skb) {697697+ IWL_ERR(priv, "dev_alloc_skb failed\n");698698+ return;699699+ }700700+701701+ skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len);702702+703703+ iwl_update_stats(priv, false, fc, len);704704+ memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));705705+706706+ ieee80211_rx(priv->hw, skb);707707+ priv->alloc_rxb_page--;708708+ rxb->page = NULL;709709+}710710+711711+static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)712712+{713713+ u32 decrypt_out = 0;714714+715715+ if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) ==716716+ RX_RES_STATUS_STATION_FOUND)717717+ decrypt_out |= (RX_RES_STATUS_STATION_FOUND |718718+ RX_RES_STATUS_NO_STATION_INFO_MISMATCH);719719+720720+ decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK);721721+722722+ /* packet was not encrypted */723723+ if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==724724+ RX_RES_STATUS_SEC_TYPE_NONE)725725+ return decrypt_out;726726+727727+ /* packet was encrypted with unknown alg */728728+ if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) ==729729+ RX_RES_STATUS_SEC_TYPE_ERR)730730+ return decrypt_out;731731+732732+ /* decryption was not done in HW */733733+ if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) !=734734+ RX_MPDU_RES_STATUS_DEC_DONE_MSK)735735+ return decrypt_out;736736+737737+ switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) {738738+739739+ case RX_RES_STATUS_SEC_TYPE_CCMP:740740+ /* alg is CCM: check MIC only */741741+ if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK))742742+ /* Bad MIC */743743+ decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;744744+ else745745+ decrypt_out |= RX_RES_STATUS_DECRYPT_OK;746746+747747+ break;748748+749749+ case RX_RES_STATUS_SEC_TYPE_TKIP:750750+ if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) {751751+ /* Bad TTAK */752752+ decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK;753753+ break;754754+ }755755+ /* fall through if TTAK OK */756756+ default:757757+ if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK))758758+ decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC;759759+ else760760+ decrypt_out |= RX_RES_STATUS_DECRYPT_OK;761761+ break;762762+ }763763+764764+ IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n",765765+ decrypt_in, decrypt_out);766766+767767+ return decrypt_out;768768+}769769+770770+/* Called for REPLY_RX (legacy ABG frames), or771771+ * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */772772+static void iwl_rx_reply_rx(struct iwl_priv *priv,773773+ struct iwl_rx_mem_buffer *rxb)774774+{775775+ struct ieee80211_hdr *header;776776+ struct ieee80211_rx_status rx_status;777777+ struct iwl_rx_packet *pkt = rxb_addr(rxb);778778+ struct iwl_rx_phy_res *phy_res;779779+ __le32 rx_pkt_status;780780+ struct iwl_rx_mpdu_res_start *amsdu;781781+ u32 len;782782+ u32 ampdu_status;783783+ u32 rate_n_flags;784784+785785+ /**786786+ * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently.787787+ * REPLY_RX: physical layer info is in this buffer788788+ * REPLY_RX_MPDU_CMD: physical layer info was sent in separate789789+ * command and cached in priv->last_phy_res790790+ *791791+ * Here we set up local variables depending on which command is792792+ * received.793793+ */794794+ if (pkt->hdr.cmd == REPLY_RX) {795795+ phy_res = (struct iwl_rx_phy_res *)pkt->u.raw;796796+ header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res)797797+ + phy_res->cfg_phy_cnt);798798+799799+ len = le16_to_cpu(phy_res->byte_count);800800+ rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) +801801+ phy_res->cfg_phy_cnt + len);802802+ ampdu_status = le32_to_cpu(rx_pkt_status);803803+ } else {804804+ if (!priv->_agn.last_phy_res_valid) {805805+ IWL_ERR(priv, "MPDU frame without cached PHY data\n");806806+ return;807807+ }808808+ phy_res = &priv->_agn.last_phy_res;809809+ amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw;810810+ header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu));811811+ len = le16_to_cpu(amsdu->byte_count);812812+ rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len);813813+ ampdu_status = iwl_translate_rx_status(priv,814814+ le32_to_cpu(rx_pkt_status));815815+ }816816+817817+ if ((unlikely(phy_res->cfg_phy_cnt > 20))) {818818+ IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n",819819+ phy_res->cfg_phy_cnt);820820+ return;821821+ }822822+823823+ if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) ||824824+ !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {825825+ IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n",826826+ le32_to_cpu(rx_pkt_status));827827+ return;828828+ }829829+830830+ /* This will be used in several places later */831831+ rate_n_flags = le32_to_cpu(phy_res->rate_n_flags);832832+833833+ /* rx_status carries information about the packet to mac80211 */834834+ rx_status.mactime = le64_to_cpu(phy_res->timestamp);835835+ rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?836836+ IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;837837+ rx_status.freq =838838+ ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),839839+ rx_status.band);840840+ rx_status.rate_idx =841841+ iwlagn_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);842842+ rx_status.flag = 0;843843+844844+ /* TSF isn't reliable. In order to allow smooth user experience,845845+ * this W/A doesn't propagate it to the mac80211 */846846+ /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/847847+848848+ priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);849849+850850+ /* Find max signal strength (dBm) among 3 antenna/receiver chains */851851+ rx_status.signal = priv->cfg->ops->utils->calc_rssi(priv, phy_res);852852+853853+ iwl_dbg_log_rx_data_frame(priv, len, header);854854+ IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",855855+ rx_status.signal, (unsigned long long)rx_status.mactime);856856+857857+ /*858858+ * "antenna number"859859+ *860860+ * It seems that the antenna field in the phy flags value861861+ * is actually a bit field. This is undefined by radiotap,862862+ * it wants an actual antenna number but I always get "7"863863+ * for most legacy frames I receive indicating that the864864+ * same frame was received on all three RX chains.865865+ *866866+ * I think this field should be removed in favor of a867867+ * new 802.11n radiotap field "RX chains" that is defined868868+ * as a bitmask.869869+ */870870+ rx_status.antenna =871871+ (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK)872872+ >> RX_RES_PHY_FLAGS_ANTENNA_POS;873873+874874+ /* set the preamble flag if appropriate */875875+ if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)876876+ rx_status.flag |= RX_FLAG_SHORTPRE;877877+878878+ /* Set up the HT phy flags */879879+ if (rate_n_flags & RATE_MCS_HT_MSK)880880+ rx_status.flag |= RX_FLAG_HT;881881+ if (rate_n_flags & RATE_MCS_HT40_MSK)882882+ rx_status.flag |= RX_FLAG_40MHZ;883883+ if (rate_n_flags & RATE_MCS_SGI_MSK)884884+ rx_status.flag |= RX_FLAG_SHORT_GI;885885+886886+ iwl_pass_packet_to_mac80211(priv, header, len, ampdu_status,887887+ rxb, &rx_status);888888+}889889+890890+/**891891+ * iwl_setup_rx_handlers - Initialize Rx handler callbacks892892+ *893893+ * Setup the RX handlers for each of the reply types sent from the uCode894894+ * to the host.895895+ */896896+void iwl_setup_rx_handlers(struct iwl_priv *priv)897897+{898898+ void (**handlers)(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);899899+900900+ handlers = priv->rx_handlers;901901+902902+ handlers[REPLY_ALIVE] = iwl_rx_reply_alive;903903+ handlers[REPLY_ERROR] = iwl_rx_reply_error;904904+ handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_rx_csa;905905+ handlers[SPECTRUM_MEASURE_NOTIFICATION] = iwl_rx_spectrum_measure_notif;906906+ handlers[PM_SLEEP_NOTIFICATION] = iwl_rx_pm_sleep_notif;907907+ handlers[PM_DEBUG_STATISTIC_NOTIFIC] = iwl_rx_pm_debug_statistics_notif;908908+ handlers[BEACON_NOTIFICATION] = iwl_rx_beacon_notif;909909+910910+ /*911911+ * The same handler is used for both the REPLY to a discrete912912+ * statistics request from the host as well as for the periodic913913+ * statistics notifications (after received beacons) from the uCode.914914+ */915915+ handlers[REPLY_STATISTICS_CMD] = iwl_rx_reply_statistics;916916+ handlers[STATISTICS_NOTIFICATION] = iwl_rx_statistics;917917+918918+ iwl_setup_rx_scan_handlers(priv);919919+920920+ handlers[CARD_STATE_NOTIFICATION] = iwl_rx_card_state_notif;921921+ handlers[MISSED_BEACONS_NOTIFICATION] = iwl_rx_missed_beacon_notif;922922+923923+ /* Rx handlers */924924+ handlers[REPLY_RX_PHY_CMD] = iwl_rx_reply_rx_phy;925925+ handlers[REPLY_RX_MPDU_CMD] = iwl_rx_reply_rx;926926+927927+ /* block ack */928928+ handlers[REPLY_COMPRESSED_BA] = iwlagn_rx_reply_compressed_ba;929929+930930+ /* Set up hardware specific Rx handlers */931931+ priv->cfg->ops->lib->rx_handler_setup(priv);865932}
···10561056 }10571057 memset(rxq->rxd, 0, size);1058105810591059- rxq->buf = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->buf), GFP_KERNEL);10591059+ rxq->buf = kcalloc(MWL8K_RX_DESCS, sizeof(*rxq->buf), GFP_KERNEL);10601060 if (rxq->buf == NULL) {10611061 wiphy_err(hw->wiphy, "failed to alloc RX skbuff list\n");10621062 pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma);10631063 return -ENOMEM;10641064 }10651065- memset(rxq->buf, 0, MWL8K_RX_DESCS * sizeof(*rxq->buf));1066106510671066 for (i = 0; i < MWL8K_RX_DESCS; i++) {10681067 int desc_size;···13461347 }13471348 memset(txq->txd, 0, size);1348134913491349- txq->skb = kmalloc(MWL8K_TX_DESCS * sizeof(*txq->skb), GFP_KERNEL);13501350+ txq->skb = kcalloc(MWL8K_TX_DESCS, sizeof(*txq->skb), GFP_KERNEL);13501351 if (txq->skb == NULL) {13511352 wiphy_err(hw->wiphy, "failed to alloc TX skbuff list\n");13521353 pci_free_consistent(priv->pdev, size, txq->txd, txq->txd_dma);13531354 return -ENOMEM;13541355 }13551355- memset(txq->skb, 0, MWL8K_TX_DESCS * sizeof(*txq->skb));1356135613571357 for (i = 0; i < MWL8K_TX_DESCS; i++) {13581358 struct mwl8k_tx_desc *tx_desc;
+2-3
drivers/net/wireless/p54/Kconfig
···4343 tristate "Prism54 SPI (stlc45xx) support"4444 depends on P54_COMMON && SPI_MASTER && GENERIC_HARDIRQS4545 ---help---4646- This driver is for stlc4550 or stlc4560 based wireless chips.4747- This driver is experimental, untested and will probably only work on4848- Nokia's N800/N810 Portable Internet Tablet.4646+ This driver is for stlc4550 or stlc4560 based wireless chips4747+ such as Nokia's N800/N810 Portable Internet Tablet.49485049 If you choose to build a module, it'll be called p54spi.5150
···493493 rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e1f);494494 rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00);495495496496- if (rt2x00_rt(rt2x00dev, RT5390)) {497497- rt2800_register_read(rt2x00dev, AUX_CTRL, ®);498498- rt2x00_set_field32(®, AUX_CTRL_FORCE_PCIE_CLK, 1);499499- rt2x00_set_field32(®, AUX_CTRL_WAKE_PCIE_EN, 1);500500- rt2800_register_write(rt2x00dev, AUX_CTRL, reg);501501- }496496+ if (rt2x00_rt(rt2x00dev, RT5390)) {497497+ rt2800_register_read(rt2x00dev, AUX_CTRL, ®);498498+ rt2x00_set_field32(®, AUX_CTRL_FORCE_PCIE_CLK, 1);499499+ rt2x00_set_field32(®, AUX_CTRL_WAKE_PCIE_EN, 1);500500+ rt2800_register_write(rt2x00dev, AUX_CTRL, reg);501501+ }502502503503 rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);504504···726726727727 while (kfifo_get(&rt2x00dev->txstatus_fifo, &status)) {728728 qid = rt2x00_get_field32(status, TX_STA_FIFO_PID_QUEUE);729729- if (qid >= QID_RX) {729729+ if (unlikely(qid >= QID_RX)) {730730 /*731731 * Unknown queue, this shouldn't happen. Just drop732732 * this tx status.···736736 break;737737 }738738739739- queue = rt2x00queue_get_queue(rt2x00dev, qid);739739+ queue = rt2x00queue_get_tx_queue(rt2x00dev, qid);740740 if (unlikely(queue == NULL)) {741741 /*742742 * The queue is NULL, this shouldn't happen. Stop···747747 break;748748 }749749750750- if (rt2x00queue_empty(queue)) {750750+ if (unlikely(rt2x00queue_empty(queue))) {751751 /*752752 * The queue is empty. Stop processing here753753 * and drop the tx status.···765765static void rt2800pci_enable_interrupt(struct rt2x00_dev *rt2x00dev,766766 struct rt2x00_field32 irq_field)767767{768768- unsigned long flags;769768 u32 reg;770769771770 /*772771 * Enable a single interrupt. The interrupt mask register773772 * access needs locking.774773 */775775- spin_lock_irqsave(&rt2x00dev->irqmask_lock, flags);774774+ spin_lock_irq(&rt2x00dev->irqmask_lock);776775 rt2800_register_read(rt2x00dev, INT_MASK_CSR, ®);777776 rt2x00_set_field32(®, irq_field, 1);778777 rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg);779779- spin_unlock_irqrestore(&rt2x00dev->irqmask_lock, flags);778778+ spin_unlock_irq(&rt2x00dev->irqmask_lock);780779}781780782781static void rt2800pci_txstatus_tasklet(unsigned long data)···835836 *836837 * Furthermore we don't disable the TX_FIFO_STATUS837838 * interrupt here but leave it enabled so that the TX_STA_FIFO838838- * can also be read while the interrupt thread gets executed.839839+ * can also be read while the tx status tasklet gets executed.839840 *840841 * Since we have only one producer and one consumer we don't841842 * need to lock the kfifo.···861862{862863 struct rt2x00_dev *rt2x00dev = dev_instance;863864 u32 reg, mask;864864- unsigned long flags;865865866866 /* Read status and ACK all interrupts */867867 rt2800_register_read(rt2x00dev, INT_SOURCE_CSR, ®);···903905 * Disable all interrupts for which a tasklet was scheduled right now,904906 * the tasklet will reenable the appropriate interrupts.905907 */906906- spin_lock_irqsave(&rt2x00dev->irqmask_lock, flags);908908+ spin_lock(&rt2x00dev->irqmask_lock);907909 rt2800_register_read(rt2x00dev, INT_MASK_CSR, ®);908910 reg &= mask;909911 rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg);910910- spin_unlock_irqrestore(&rt2x00dev->irqmask_lock, flags);912912+ spin_unlock(&rt2x00dev->irqmask_lock);911913912914 return IRQ_HANDLED;913915}···977979 if (!modparam_nohwcrypt)978980 __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);979981 __set_bit(DRIVER_SUPPORT_LINK_TUNING, &rt2x00dev->flags);982982+ __set_bit(DRIVER_REQUIRE_HT_TX_DESC, &rt2x00dev->flags);980983981984 /*982985 * Set the rssi offset.···11341135 { PCI_DEVICE(0x1814, 0x3593), PCI_DEVICE_DATA(&rt2800pci_ops) },11351136#endif11361137#ifdef CONFIG_RT2800PCI_RT53XX11371137- { PCI_DEVICE(0x1814, 0x5390), PCI_DEVICE_DATA(&rt2800pci_ops) },11381138+ { PCI_DEVICE(0x1814, 0x5390), PCI_DEVICE_DATA(&rt2800pci_ops) },11381139#endif11391140 { 0, }11401141};
+1
drivers/net/wireless/rt2x00/rt2800usb.c
···565565 __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);566566 __set_bit(DRIVER_SUPPORT_LINK_TUNING, &rt2x00dev->flags);567567 __set_bit(DRIVER_SUPPORT_WATCHDOG, &rt2x00dev->flags);568568+ __set_bit(DRIVER_REQUIRE_HT_TX_DESC, &rt2x00dev->flags);568569569570 /*570571 * Set the rssi offset.
+19-7
drivers/net/wireless/rt2x00/rt2x00.h
···467467 const u8 *address;468468469469 u32 bssidx;470470- u32 aid;471470472471 u8 key[16];473472 u8 tx_mic[8];···661662 DRIVER_REQUIRE_L2PAD,662663 DRIVER_REQUIRE_TXSTATUS_FIFO,663664 DRIVER_REQUIRE_TASKLET_CONTEXT,665665+ DRIVER_REQUIRE_SW_SEQNO,666666+ DRIVER_REQUIRE_HT_TX_DESC,664667665668 /*666669 * Driver features···887886 struct work_struct txdone_work;888887889888 /*890890- * Data queue arrays for RX, TX and Beacon.891891- * The Beacon array also contains the Atim queue892892- * if that is supported by the device.889889+ * Data queue arrays for RX, TX, Beacon and ATIM.893890 */894891 unsigned int data_queues;895892 struct data_queue *rx;896893 struct data_queue *tx;897894 struct data_queue *bcn;895895+ struct data_queue *atim;898896899897 /*900898 * Firmware image.···10631063void rt2x00queue_unmap_skb(struct queue_entry *entry);1064106410651065/**10661066- * rt2x00queue_get_queue - Convert queue index to queue pointer10661066+ * rt2x00queue_get_tx_queue - Convert tx queue index to queue pointer10671067 * @rt2x00dev: Pointer to &struct rt2x00_dev.10681068 * @queue: rt2x00 queue index (see &enum data_queue_qid).10691069+ *10701070+ * Returns NULL for non tx queues.10691071 */10701070-struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,10711071- const enum data_queue_qid queue);10721072+static inline struct data_queue *10731073+rt2x00queue_get_tx_queue(struct rt2x00_dev *rt2x00dev,10741074+ const enum data_queue_qid queue)10751075+{10761076+ if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx)10771077+ return &rt2x00dev->tx[queue];10781078+10791079+ if (queue == QID_ATIM)10801080+ return rt2x00dev->atim;10811081+10821082+ return NULL;10831083+}1072108410731085/**10741086 * rt2x00queue_get_entry - Get queue entry where the given index points to.
+10-18
drivers/net/wireless/rt2x00/rt2x00ht.c
···3838 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data;39394040 if (tx_info->control.sta)4141- txdesc->mpdu_density =4141+ txdesc->u.ht.mpdu_density =4242 tx_info->control.sta->ht_cap.ampdu_density;43434444- txdesc->ba_size = 7; /* FIXME: What value is needed? */4444+ txdesc->u.ht.ba_size = 7; /* FIXME: What value is needed? */45454646- txdesc->stbc =4646+ txdesc->u.ht.stbc =4747 (tx_info->flags & IEEE80211_TX_CTL_STBC) >> IEEE80211_TX_CTL_STBC_SHIFT;48484949 /*···5151 * mcs rate to be used5252 */5353 if (txrate->flags & IEEE80211_TX_RC_MCS) {5454- txdesc->mcs = txrate->idx;5454+ txdesc->u.ht.mcs = txrate->idx;55555656 /*5757 * MIMO PS should be set to 1 for STA's using dynamic SM PS5858 * when using more then one tx stream (>MCS7).5959 */6060- if (tx_info->control.sta && txdesc->mcs > 7 &&6060+ if (tx_info->control.sta && txdesc->u.ht.mcs > 7 &&6161 ((tx_info->control.sta->ht_cap.cap &6262 IEEE80211_HT_CAP_SM_PS) >>6363 IEEE80211_HT_CAP_SM_PS_SHIFT) ==6464 WLAN_HT_CAP_SM_PS_DYNAMIC)6565 __set_bit(ENTRY_TXD_HT_MIMO_PS, &txdesc->flags);6666 } else {6767- txdesc->mcs = rt2x00_get_rate_mcs(hwrate->mcs);6767+ txdesc->u.ht.mcs = rt2x00_get_rate_mcs(hwrate->mcs);6868 if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)6969- txdesc->mcs |= 0x08;6969+ txdesc->u.ht.mcs |= 0x08;7070 }71717272 /*···7676 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU &&7777 !(tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))7878 __set_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags);7979-8080- /*8181- * Determine HT Mix/Greenfield rate mode8282- */8383- if (txrate->flags & IEEE80211_TX_RC_MCS)8484- txdesc->rate_mode = RATE_MODE_HT_MIX;8585- if (txrate->flags & IEEE80211_TX_RC_GREEN_FIELD)8686- txdesc->rate_mode = RATE_MODE_HT_GREENFIELD;87798880 /*8981 * Set 40Mhz mode if necessary (for legacy rates this will···97105 * for frames not transmitted with TXOP_HTTXOP98106 */99107 if (ieee80211_is_mgmt(hdr->frame_control))100100- txdesc->txop = TXOP_BACKOFF;108108+ txdesc->u.ht.txop = TXOP_BACKOFF;101109 else if (!(tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT))102102- txdesc->txop = TXOP_SIFS;110110+ txdesc->u.ht.txop = TXOP_SIFS;103111 else104104- txdesc->txop = TXOP_HTTXOP;112112+ txdesc->u.ht.txop = TXOP_HTTXOP;105113}106114107115u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev,
+9-11
drivers/net/wireless/rt2x00/rt2x00mac.c
···116116 goto exit_fail;117117118118 /*119119- * Determine which queue to put packet on.119119+ * Use the ATIM queue if appropriate and present.120120 */121121 if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&122122 test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags))123123- queue = rt2x00queue_get_queue(rt2x00dev, QID_ATIM);124124- else125125- queue = rt2x00queue_get_queue(rt2x00dev, qid);123123+ qid = QID_ATIM;124124+125125+ queue = rt2x00queue_get_tx_queue(rt2x00dev, qid);126126 if (unlikely(!queue)) {127127 ERROR(rt2x00dev,128128 "Attempt to send packet over invalid queue %d.\n"···149149 goto exit_fail;150150 }151151152152- if (rt2x00queue_write_tx_frame(queue, skb, false))152152+ if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))153153 goto exit_fail;154154155155 if (rt2x00queue_threshold(queue))···190190{191191 struct rt2x00_dev *rt2x00dev = hw->priv;192192 struct rt2x00_intf *intf = vif_to_intf(vif);193193- struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, QID_BEACON);193193+ struct data_queue *queue = rt2x00dev->bcn;194194 struct queue_entry *entry = NULL;195195 unsigned int i;196196···518518519519 crypto.cmd = cmd;520520521521- if (sta) {522522- /* some drivers need the AID */523523- crypto.aid = sta->aid;521521+ if (sta)524522 crypto.address = sta->addr;525525- } else523523+ else526524 crypto.address = bcast_addr;527525528526 if (crypto.cipher == CIPHER_TKIP)···690692 struct rt2x00_dev *rt2x00dev = hw->priv;691693 struct data_queue *queue;692694693693- queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);695695+ queue = rt2x00queue_get_tx_queue(rt2x00dev, queue_idx);694696 if (unlikely(!queue))695697 return -EINVAL;696698
+51-58
drivers/net/wireless/rt2x00/rt2x00queue.c
···221221 struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);222222 unsigned long irqflags;223223224224- if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) ||225225- unlikely(!tx_info->control.vif))224224+ if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))225225+ return;226226+227227+ __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);228228+229229+ if (!test_bit(DRIVER_REQUIRE_SW_SEQNO, &entry->queue->rt2x00dev->flags))226230 return;227231228232 /*229229- * Hardware should insert sequence counter.230230- * FIXME: We insert a software sequence counter first for231231- * hardware that doesn't support hardware sequence counting.233233+ * The hardware is not able to insert a sequence number. Assign a234234+ * software generated one here.232235 *233236 * This is wrong because beacons are not getting sequence234237 * numbers assigned properly.···249246250247 spin_unlock_irqrestore(&intf->seqlock, irqflags);251248252252- __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);253249}254250255251static void rt2x00queue_create_tx_descriptor_plcp(struct queue_entry *entry,···262260 unsigned int duration;263261 unsigned int residual;264262263263+ /*264264+ * Determine with what IFS priority this frame should be send.265265+ * Set ifs to IFS_SIFS when the this is not the first fragment,266266+ * or this fragment came after RTS/CTS.267267+ */268268+ if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))269269+ txdesc->u.plcp.ifs = IFS_BACKOFF;270270+ else271271+ txdesc->u.plcp.ifs = IFS_SIFS;272272+265273 /* Data length + CRC + Crypto overhead (IV/EIV/ICV/MIC) */266274 data_length = entry->skb->len + 4;267275 data_length += rt2x00crypto_tx_overhead(rt2x00dev, entry->skb);···280268 * PLCP setup281269 * Length calculation depends on OFDM/CCK rate.282270 */283283- txdesc->signal = hwrate->plcp;284284- txdesc->service = 0x04;271271+ txdesc->u.plcp.signal = hwrate->plcp;272272+ txdesc->u.plcp.service = 0x04;285273286274 if (hwrate->flags & DEV_RATE_OFDM) {287287- txdesc->length_high = (data_length >> 6) & 0x3f;288288- txdesc->length_low = data_length & 0x3f;275275+ txdesc->u.plcp.length_high = (data_length >> 6) & 0x3f;276276+ txdesc->u.plcp.length_low = data_length & 0x3f;289277 } else {290278 /*291279 * Convert length to microseconds.···300288 * Check if we need to set the Length Extension301289 */302290 if (hwrate->bitrate == 110 && residual <= 30)303303- txdesc->service |= 0x80;291291+ txdesc->u.plcp.service |= 0x80;304292 }305293306306- txdesc->length_high = (duration >> 8) & 0xff;307307- txdesc->length_low = duration & 0xff;294294+ txdesc->u.plcp.length_high = (duration >> 8) & 0xff;295295+ txdesc->u.plcp.length_low = duration & 0xff;308296309297 /*310298 * When preamble is enabled we should set the311299 * preamble bit for the signal.312300 */313301 if (txrate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)314314- txdesc->signal |= 0x08;302302+ txdesc->u.plcp.signal |= 0x08;315303 }316304}317305···321309 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;322310 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb);323311 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data;324324- struct ieee80211_rate *rate =325325- ieee80211_get_tx_rate(rt2x00dev->hw, tx_info);326326- const struct rt2x00_rate *hwrate;312312+ struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0];313313+ struct ieee80211_rate *rate;314314+ const struct rt2x00_rate *hwrate = NULL;327315328316 memset(txdesc, 0, sizeof(*txdesc));329317···383371 ieee80211_is_probe_resp(hdr->frame_control))384372 __set_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags);385373386386- /*387387- * Determine with what IFS priority this frame should be send.388388- * Set ifs to IFS_SIFS when the this is not the first fragment,389389- * or this fragment came after RTS/CTS.390390- */391374 if ((tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) &&392392- !test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)) {375375+ !test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags))393376 __set_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags);394394- txdesc->ifs = IFS_BACKOFF;395395- } else396396- txdesc->ifs = IFS_SIFS;397377398378 /*399379 * Determine rate modulation.400380 */401401- hwrate = rt2x00_get_rate(rate->hw_value);402402- txdesc->rate_mode = RATE_MODE_CCK;403403- if (hwrate->flags & DEV_RATE_OFDM)404404- txdesc->rate_mode = RATE_MODE_OFDM;381381+ if (txrate->flags & IEEE80211_TX_RC_GREEN_FIELD)382382+ txdesc->rate_mode = RATE_MODE_HT_GREENFIELD;383383+ else if (txrate->flags & IEEE80211_TX_RC_MCS)384384+ txdesc->rate_mode = RATE_MODE_HT_MIX;385385+ else {386386+ rate = ieee80211_get_tx_rate(rt2x00dev->hw, tx_info);387387+ hwrate = rt2x00_get_rate(rate->hw_value);388388+ if (hwrate->flags & DEV_RATE_OFDM)389389+ txdesc->rate_mode = RATE_MODE_OFDM;390390+ else391391+ txdesc->rate_mode = RATE_MODE_CCK;392392+ }405393406394 /*407395 * Apply TX descriptor handling by components408396 */409397 rt2x00crypto_create_tx_descriptor(entry, txdesc);410410- rt2x00ht_create_tx_descriptor(entry, txdesc, hwrate);411398 rt2x00queue_create_tx_descriptor_seq(entry, txdesc);412412- rt2x00queue_create_tx_descriptor_plcp(entry, txdesc, hwrate);399399+400400+ if (test_bit(DRIVER_REQUIRE_HT_TX_DESC, &rt2x00dev->flags))401401+ rt2x00ht_create_tx_descriptor(entry, txdesc, hwrate);402402+ else403403+ rt2x00queue_create_tx_descriptor_plcp(entry, txdesc, hwrate);413404}414405415406static int rt2x00queue_write_tx_data(struct queue_entry *entry,···704689 }705690}706691EXPORT_SYMBOL_GPL(rt2x00queue_for_each_entry);707707-708708-struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,709709- const enum data_queue_qid queue)710710-{711711- int atim = test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);712712-713713- if (queue == QID_RX)714714- return rt2x00dev->rx;715715-716716- if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx)717717- return &rt2x00dev->tx[queue];718718-719719- if (!rt2x00dev->bcn)720720- return NULL;721721-722722- if (queue == QID_BEACON)723723- return &rt2x00dev->bcn[0];724724- else if (queue == QID_ATIM && atim)725725- return &rt2x00dev->bcn[1];726726-727727- return NULL;728728-}729729-EXPORT_SYMBOL_GPL(rt2x00queue_get_queue);730692731693struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue,732694 enum queue_index index)···10801088 goto exit;1081108910821090 if (test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags)) {10831083- status = rt2x00queue_alloc_entries(&rt2x00dev->bcn[1],10911091+ status = rt2x00queue_alloc_entries(rt2x00dev->atim,10841092 rt2x00dev->ops->atim);10851093 if (status)10861094 goto exit;···11541162 rt2x00dev->rx = queue;11551163 rt2x00dev->tx = &queue[1];11561164 rt2x00dev->bcn = &queue[1 + rt2x00dev->ops->tx_queues];11651165+ rt2x00dev->atim = req_atim ? &queue[2 + rt2x00dev->ops->tx_queues] : NULL;1157116611581167 /*11591168 * Initialize queue parameters.···11711178 tx_queue_for_each(rt2x00dev, queue)11721179 rt2x00queue_init(rt2x00dev, queue, qid++);1173118011741174- rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[0], QID_BEACON);11811181+ rt2x00queue_init(rt2x00dev, rt2x00dev->bcn, QID_BEACON);11751182 if (req_atim)11761176- rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[1], QID_ATIM);11831183+ rt2x00queue_init(rt2x00dev, rt2x00dev->atim, QID_ATIM);1177118411781185 return 0;11791186}
···869869 /* The RTL8187 returns the retry count through register 0xFFFA. In870870 * addition, it appears to be a cumulative retry count, not the871871 * value for the current TX packet. When multiple TX entries are872872- * queued, the retry count will be valid for the last one in the queue.873873- * The "error" should not matter for purposes of rate setting. */872872+ * waiting in the queue, the retry count will be the total for all.873873+ * The "error" may matter for purposes of rate setting, but there is874874+ * no other choice with this hardware.875875+ */874876 struct rtl8187_priv *priv = container_of(work, struct rtl8187_priv,875877 work.work);876878 struct ieee80211_tx_info *info;877879 struct ieee80211_hw *dev = priv->dev;878880 static u16 retry;879881 u16 tmp;882882+ u16 avg_retry;883883+ int length;880884881885 mutex_lock(&priv->conf_mutex);882886 tmp = rtl818x_ioread16(priv, (__le16 *)0xFFFA);887887+ length = skb_queue_len(&priv->b_tx_status.queue);888888+ if (unlikely(!length))889889+ length = 1;890890+ if (unlikely(tmp < retry))891891+ tmp = retry;892892+ avg_retry = (tmp - retry) / length;883893 while (skb_queue_len(&priv->b_tx_status.queue) > 0) {884894 struct sk_buff *old_skb;885895886896 old_skb = skb_dequeue(&priv->b_tx_status.queue);887897 info = IEEE80211_SKB_CB(old_skb);888888- info->status.rates[0].count = tmp - retry + 1;898898+ info->status.rates[0].count = avg_retry + 1;899899+ if (info->status.rates[0].count > RETRY_COUNT)900900+ info->flags &= ~IEEE80211_TX_STAT_ACK;889901 ieee80211_tx_status_irqsafe(dev, old_skb);890902 }891903 retry = tmp;···943931 rtl818x_iowrite32(priv, &priv->map->TX_CONF,944932 RTL818X_TX_CONF_HW_SEQNUM |945933 RTL818X_TX_CONF_DISREQQSIZE |946946- (7 << 8 /* short retry limit */) |947947- (7 << 0 /* long retry limit */) |934934+ (RETRY_COUNT << 8 /* short retry limit */) |935935+ (RETRY_COUNT << 0 /* long retry limit */) |948936 (7 << 21 /* MAX TX DMA */));949937 rtl8187_init_urbs(dev);950938 rtl8187b_init_status_urb(dev);···13881376 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |13891377 IEEE80211_HW_SIGNAL_DBM |13901378 IEEE80211_HW_RX_INCLUDES_FCS;13791379+ /* Initialize rate-control variables */13801380+ dev->max_rates = 1;13811381+ dev->max_rate_tries = RETRY_COUNT;1391138213921383 eeprom.data = dev;13931384 eeprom.register_read = rtl8187_eeprom_register_read;
···9999100100 mutex_lock(&wl->mutex);101101102102- ret = wl1271_ps_elp_wakeup(wl, false);102102+ ret = wl1271_ps_elp_wakeup(wl);103103 if (ret < 0)104104 goto out;105105
···304304 .rx_block_num = 70,305305 .tx_min_block_num = 40,306306 .dynamic_memory = 0,307307- .min_req_tx_blocks = 104,307307+ .min_req_tx_blocks = 100,308308 .min_req_rx_blocks = 22,309309 .tx_min = 27,310310 }···374374 if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))375375 goto out;376376377377- ret = wl1271_ps_elp_wakeup(wl, false);377377+ ret = wl1271_ps_elp_wakeup(wl);378378 if (ret < 0)379379 goto out;380380···635635 (s64)le32_to_cpu(status->fw_localtime);636636}637637638638-#define WL1271_IRQ_MAX_LOOPS 10638638+static void wl1271_flush_deferred_work(struct wl1271 *wl)639639+{640640+ struct sk_buff *skb;639641640640-static void wl1271_irq_work(struct work_struct *work)642642+ /* Pass all received frames to the network stack */643643+ while ((skb = skb_dequeue(&wl->deferred_rx_queue)))644644+ ieee80211_rx_ni(wl->hw, skb);645645+646646+ /* Return sent skbs to the network stack */647647+ while ((skb = skb_dequeue(&wl->deferred_tx_queue)))648648+ ieee80211_tx_status(wl->hw, skb);649649+}650650+651651+static void wl1271_netstack_work(struct work_struct *work)652652+{653653+ struct wl1271 *wl =654654+ container_of(work, struct wl1271, netstack_work);655655+656656+ do {657657+ wl1271_flush_deferred_work(wl);658658+ } while (skb_queue_len(&wl->deferred_rx_queue));659659+}660660+661661+#define WL1271_IRQ_MAX_LOOPS 256662662+663663+irqreturn_t wl1271_irq(int irq, void *cookie)641664{642665 int ret;643666 u32 intr;644667 int loopcount = WL1271_IRQ_MAX_LOOPS;668668+ struct wl1271 *wl = (struct wl1271 *)cookie;669669+ bool done = false;670670+ unsigned int defer_count;645671 unsigned long flags;646646- struct wl1271 *wl =647647- container_of(work, struct wl1271, irq_work);672672+673673+ /* TX might be handled here, avoid redundant work */674674+ set_bit(WL1271_FLAG_TX_PENDING, &wl->flags);675675+ cancel_work_sync(&wl->tx_work);648676649677 mutex_lock(&wl->mutex);650678···681653 if (unlikely(wl->state == WL1271_STATE_OFF))682654 goto out;683655684684- ret = wl1271_ps_elp_wakeup(wl, true);656656+ ret = wl1271_ps_elp_wakeup(wl);685657 if (ret < 0)686658 goto out;687659688688- spin_lock_irqsave(&wl->wl_lock, flags);689689- while (test_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags) && loopcount) {690690- clear_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags);691691- spin_unlock_irqrestore(&wl->wl_lock, flags);692692- loopcount--;660660+ while (!done && loopcount--) {661661+ /*662662+ * In order to avoid a race with the hardirq, clear the flag663663+ * before acknowledging the chip. Since the mutex is held,664664+ * wl1271_ps_elp_wakeup cannot be called concurrently.665665+ */666666+ clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);667667+ smp_mb__after_clear_bit();693668694669 wl1271_fw_status(wl, wl->fw_status);695670 intr = le32_to_cpu(wl->fw_status->common.intr);671671+ intr &= WL1271_INTR_MASK;696672 if (!intr) {697697- wl1271_debug(DEBUG_IRQ, "Zero interrupt received.");698698- spin_lock_irqsave(&wl->wl_lock, flags);673673+ done = true;699674 continue;700675 }701701-702702- intr &= WL1271_INTR_MASK;703676704677 if (unlikely(intr & WL1271_ACX_INTR_WATCHDOG)) {705678 wl1271_error("watchdog interrupt received! "···711682 goto out;712683 }713684714714- if (intr & WL1271_ACX_INTR_DATA) {685685+ if (likely(intr & WL1271_ACX_INTR_DATA)) {715686 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_DATA");687687+688688+ wl1271_rx(wl, &wl->fw_status->common);689689+690690+ /* Check if any tx blocks were freed */691691+ spin_lock_irqsave(&wl->wl_lock, flags);692692+ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&693693+ wl->tx_queue_count) {694694+ spin_unlock_irqrestore(&wl->wl_lock, flags);695695+ /*696696+ * In order to avoid starvation of the TX path,697697+ * call the work function directly.698698+ */699699+ wl1271_tx_work_locked(wl);700700+ } else {701701+ spin_unlock_irqrestore(&wl->wl_lock, flags);702702+ }716703717704 /* check for tx results */718705 if (wl->fw_status->common.tx_results_counter !=719706 (wl->tx_results_count & 0xff))720707 wl1271_tx_complete(wl);721708722722- /* Check if any tx blocks were freed */723723- if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&724724- wl->tx_queue_count) {725725- /*726726- * In order to avoid starvation of the TX path,727727- * call the work function directly.728728- */729729- wl1271_tx_work_locked(wl);730730- }731731-732732- wl1271_rx(wl, &wl->fw_status->common);709709+ /* Make sure the deferred queues don't get too long */710710+ defer_count = skb_queue_len(&wl->deferred_tx_queue) +711711+ skb_queue_len(&wl->deferred_rx_queue);712712+ if (defer_count > WL1271_DEFERRED_QUEUE_LIMIT)713713+ wl1271_flush_deferred_work(wl);733714 }734715735716 if (intr & WL1271_ACX_INTR_EVENT_A) {···758719759720 if (intr & WL1271_ACX_INTR_HW_AVAILABLE)760721 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_HW_AVAILABLE");761761-762762- spin_lock_irqsave(&wl->wl_lock, flags);763722 }764764-765765- if (test_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags))766766- ieee80211_queue_work(wl->hw, &wl->irq_work);767767- else768768- clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);769769- spin_unlock_irqrestore(&wl->wl_lock, flags);770723771724 wl1271_ps_elp_sleep(wl);772725773726out:727727+ spin_lock_irqsave(&wl->wl_lock, flags);728728+ /* In case TX was not handled here, queue TX work */729729+ clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);730730+ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&731731+ wl->tx_queue_count)732732+ ieee80211_queue_work(wl->hw, &wl->tx_work);733733+ spin_unlock_irqrestore(&wl->wl_lock, flags);734734+774735 mutex_unlock(&wl->mutex);736736+737737+ return IRQ_HANDLED;775738}739739+EXPORT_SYMBOL_GPL(wl1271_irq);776740777741static int wl1271_fetch_firmware(struct wl1271 *wl)778742{···1016974 goto out;10179751018976irq_disable:10191019- wl1271_disable_interrupts(wl);1020977 mutex_unlock(&wl->mutex);1021978 /* Unlocking the mutex in the middle of handling is1022979 inherently unsafe. In this case we deem it safe to do,···1024983 work function will not do anything.) Also, any other1025984 possible concurrent operations will fail due to the1026985 current state, hence the wl1271 struct should be safe. */10271027- cancel_work_sync(&wl->irq_work);986986+ wl1271_disable_interrupts(wl);987987+ wl1271_flush_deferred_work(wl);988988+ cancel_work_sync(&wl->netstack_work);1028989 mutex_lock(&wl->mutex);1029990power_off:1030991 wl1271_power_off(wl);···10531010 goto out;10541011 }1055101210561056- wl1271_disable_interrupts(wl);10571013 wl1271_power_off(wl);1058101410591015 wl->state = WL1271_STATE_OFF;10601016 wl->rx_counter = 0;1061101710621018 mutex_unlock(&wl->mutex);10631063- cancel_work_sync(&wl->irq_work);10191019+ wl1271_disable_interrupts(wl);10201020+ wl1271_flush_deferred_work(wl);10211021+ cancel_work_sync(&wl->netstack_work);10641022 cancel_work_sync(&wl->recovery_work);10651023 mutex_lock(&wl->mutex);10661024out:···10851041 int q;10861042 u8 hlid = 0;1087104310441044+ q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));10451045+10461046+ if (wl->bss_type == BSS_TYPE_AP_BSS)10471047+ hlid = wl1271_tx_get_hlid(skb);10481048+10881049 spin_lock_irqsave(&wl->wl_lock, flags);10501050+10891051 wl->tx_queue_count++;1090105210911053 /*···11041054 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);11051055 }1106105611071107- spin_unlock_irqrestore(&wl->wl_lock, flags);11081108-11091057 /* queue the packet */11101110- q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));11111058 if (wl->bss_type == BSS_TYPE_AP_BSS) {11121112- hlid = wl1271_tx_get_hlid(skb);11131059 wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q);11141060 skb_queue_tail(&wl->links[hlid].tx_queue[q], skb);11151061 } else {···11171071 * before that, the tx_work will not be initialized!11181072 */1119107311201120- if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags))10741074+ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&10751075+ !test_bit(WL1271_FLAG_TX_PENDING, &wl->flags))11211076 ieee80211_queue_work(wl->hw, &wl->tx_work);10771077+10781078+ spin_unlock_irqrestore(&wl->wl_lock, flags);11221079}1123108011241081static struct notifier_block wl1271_dev_notifier = {···12181169 break;1219117012201171irq_disable:12211221- wl1271_disable_interrupts(wl);12221172 mutex_unlock(&wl->mutex);12231173 /* Unlocking the mutex in the middle of handling is12241174 inherently unsafe. In this case we deem it safe to do,···12261178 work function will not do anything.) Also, any other12271179 possible concurrent operations will fail due to the12281180 current state, hence the wl1271 struct should be safe. */12291229- cancel_work_sync(&wl->irq_work);11811181+ wl1271_disable_interrupts(wl);11821182+ wl1271_flush_deferred_work(wl);11831183+ cancel_work_sync(&wl->netstack_work);12301184 mutex_lock(&wl->mutex);12311185power_off:12321186 wl1271_power_off(wl);···1294124412951245 wl->state = WL1271_STATE_OFF;1296124612971297- wl1271_disable_interrupts(wl);12981298-12991247 mutex_unlock(&wl->mutex);1300124812491249+ wl1271_disable_interrupts(wl);12501250+ wl1271_flush_deferred_work(wl);13011251 cancel_delayed_work_sync(&wl->scan_complete_work);13021302- cancel_work_sync(&wl->irq_work);12521252+ cancel_work_sync(&wl->netstack_work);13031253 cancel_work_sync(&wl->tx_work);13041254 cancel_delayed_work_sync(&wl->pspoll_work);13051255 cancel_delayed_work_sync(&wl->elp_work);···1575152515761526 is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);1577152715781578- ret = wl1271_ps_elp_wakeup(wl, false);15281528+ ret = wl1271_ps_elp_wakeup(wl);15791529 if (ret < 0)15801530 goto out;15811531···17311681 if (unlikely(wl->state == WL1271_STATE_OFF))17321682 goto out;1733168317341734- ret = wl1271_ps_elp_wakeup(wl, false);16841684+ ret = wl1271_ps_elp_wakeup(wl);17351685 if (ret < 0)17361686 goto out;17371687···19601910 goto out_unlock;19611911 }1962191219631963- ret = wl1271_ps_elp_wakeup(wl, false);19131913+ ret = wl1271_ps_elp_wakeup(wl);19641914 if (ret < 0)19651915 goto out_unlock;19661916···20632013 goto out;20642014 }2065201520662066- ret = wl1271_ps_elp_wakeup(wl, false);20162016+ ret = wl1271_ps_elp_wakeup(wl);20672017 if (ret < 0)20682018 goto out;20692019···20892039 goto out;20902040 }2091204120922092- ret = wl1271_ps_elp_wakeup(wl, false);20422042+ ret = wl1271_ps_elp_wakeup(wl);20932043 if (ret < 0)20942044 goto out;20952045···21172067 goto out;21182068 }2119206921202120- ret = wl1271_ps_elp_wakeup(wl, false);20702070+ ret = wl1271_ps_elp_wakeup(wl);21212071 if (ret < 0)21222072 goto out;21232073···25962546 if (unlikely(wl->state == WL1271_STATE_OFF))25972547 goto out;2598254825992599- ret = wl1271_ps_elp_wakeup(wl, false);25492549+ ret = wl1271_ps_elp_wakeup(wl);26002550 if (ret < 0)26012551 goto out;26022552···26512601 conf_tid->apsd_conf[0] = 0;26522602 conf_tid->apsd_conf[1] = 0;26532603 } else {26542654- ret = wl1271_ps_elp_wakeup(wl, false);26042604+ ret = wl1271_ps_elp_wakeup(wl);26552605 if (ret < 0)26562606 goto out;26572607···26972647 if (unlikely(wl->state == WL1271_STATE_OFF))26982648 goto out;2699264927002700- ret = wl1271_ps_elp_wakeup(wl, false);26502650+ ret = wl1271_ps_elp_wakeup(wl);27012651 if (ret < 0)27022652 goto out;27032653···27862736 if (ret < 0)27872737 goto out;2788273827892789- ret = wl1271_ps_elp_wakeup(wl, false);27392739+ ret = wl1271_ps_elp_wakeup(wl);27902740 if (ret < 0)27912741 goto out_free_sta;27922742···28292779 if (WARN_ON(!test_bit(id, wl->ap_hlid_map)))28302780 goto out;2831278128322832- ret = wl1271_ps_elp_wakeup(wl, false);27822782+ ret = wl1271_ps_elp_wakeup(wl);28332783 if (ret < 0)28342784 goto out;28352785···28622812 goto out;28632813 }2864281428652865- ret = wl1271_ps_elp_wakeup(wl, false);28152815+ ret = wl1271_ps_elp_wakeup(wl);28662816 if (ret < 0)28672817 goto out;28682818···32263176 if (wl->state == WL1271_STATE_OFF)32273177 goto out;3228317832293229- ret = wl1271_ps_elp_wakeup(wl, false);31793179+ ret = wl1271_ps_elp_wakeup(wl);32303180 if (ret < 0)32313181 goto out;32323182···34263376 for (j = 0; j < AP_MAX_LINKS; j++)34273377 skb_queue_head_init(&wl->links[j].tx_queue[i]);3428337833793379+ skb_queue_head_init(&wl->deferred_rx_queue);33803380+ skb_queue_head_init(&wl->deferred_tx_queue);33813381+34293382 INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work);34303383 INIT_DELAYED_WORK(&wl->pspoll_work, wl1271_pspoll_work);34313431- INIT_WORK(&wl->irq_work, wl1271_irq_work);33843384+ INIT_WORK(&wl->netstack_work, wl1271_netstack_work);34323385 INIT_WORK(&wl->tx_work, wl1271_tx_work);34333386 INIT_WORK(&wl->recovery_work, wl1271_recovery_work);34343387 INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work);···34573404 wl->last_tx_hlid = 0;34583405 wl->ap_ps_map = 0;34593406 wl->ap_fw_ps_map = 0;34073407+ wl->quirks = 0;3460340834613409 memset(wl->tx_frames_map, 0, sizeof(wl->tx_frames_map));34623410 for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
+3-3
drivers/net/wireless/wl12xx/ps.c
···6969 }7070}71717272-int wl1271_ps_elp_wakeup(struct wl1271 *wl, bool chip_awake)7272+int wl1271_ps_elp_wakeup(struct wl1271 *wl)7373{7474 DECLARE_COMPLETION_ONSTACK(compl);7575 unsigned long flags;···8787 * the completion variable in one entity.8888 */8989 spin_lock_irqsave(&wl->wl_lock, flags);9090- if (work_pending(&wl->irq_work) || chip_awake)9090+ if (test_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags))9191 pending = true;9292 else9393 wl->elp_compl = &compl;···149149 case STATION_ACTIVE_MODE:150150 default:151151 wl1271_debug(DEBUG_PSM, "leaving psm");152152- ret = wl1271_ps_elp_wakeup(wl, false);152152+ ret = wl1271_ps_elp_wakeup(wl);153153 if (ret < 0)154154 return ret;155155
···464464465465 while ((skb = wl1271_skb_dequeue(wl))) {466466 if (!woken_up) {467467- ret = wl1271_ps_elp_wakeup(wl, false);467467+ ret = wl1271_ps_elp_wakeup(wl);468468 if (ret < 0)469469 goto out_ack;470470 woken_up = true;···506506 sent_packets = true;507507 }508508 if (sent_packets) {509509- /* interrupt the firmware with the new packets */510510- wl1271_write32(wl, WL1271_HOST_WR_ACCESS, wl->tx_packets_count);509509+ /*510510+ * Interrupt the firmware with the new packets. This is only511511+ * required for older hardware revisions512512+ */513513+ if (wl->quirks & WL12XX_QUIRK_END_OF_TRANSACTION)514514+ wl1271_write32(wl, WL1271_HOST_WR_ACCESS,515515+ wl->tx_packets_count);516516+511517 wl1271_handle_tx_low_watermark(wl);512518 }513519···589583 result->rate_class_index, result->status);590584591585 /* return the packet to the stack */592592- ieee80211_tx_status(wl->hw, skb);586586+ skb_queue_tail(&wl->deferred_tx_queue, skb);587587+ ieee80211_queue_work(wl->hw, &wl->netstack_work);593588 wl1271_free_tx_id(wl, result->id);594589}595590···694687 */695688 wl1271_handle_tx_low_watermark(wl);696689697697- for (i = 0; i < ACX_TX_DESCRIPTORS; i++)698698- if (wl->tx_frames[i] != NULL) {699699- skb = wl->tx_frames[i];700700- wl1271_free_tx_id(wl, i);701701- wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);702702- info = IEEE80211_SKB_CB(skb);703703- info->status.rates[0].idx = -1;704704- info->status.rates[0].count = 0;705705- ieee80211_tx_status(wl->hw, skb);690690+ for (i = 0; i < ACX_TX_DESCRIPTORS; i++) {691691+ if (wl->tx_frames[i] == NULL)692692+ continue;693693+694694+ skb = wl->tx_frames[i];695695+ wl1271_free_tx_id(wl, i);696696+ wl1271_debug(DEBUG_TX, "freeing skb 0x%p", skb);697697+698698+ /* Remove private headers before passing the skb to mac80211 */699699+ info = IEEE80211_SKB_CB(skb);700700+ skb_pull(skb, sizeof(struct wl1271_tx_hw_descr));701701+ if (info->control.hw_key &&702702+ info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {703703+ int hdrlen = ieee80211_get_hdrlen_from_skb(skb);704704+ memmove(skb->data + WL1271_TKIP_IV_SPACE, skb->data,705705+ hdrlen);706706+ skb_pull(skb, WL1271_TKIP_IV_SPACE);706707 }708708+709709+ info->status.rates[0].idx = -1;710710+ info->status.rates[0].count = 0;711711+712712+ ieee80211_tx_status(wl->hw, skb);713713+ }707714}708715709716#define WL1271_TX_FLUSH_TIMEOUT 500000
+22-6
drivers/net/wireless/wl12xx/wl12xx.h
···130130131131132132133133-#define WL1271_FW_NAME "wl1271-fw-2.bin"134134-#define WL1271_AP_FW_NAME "wl1271-fw-ap.bin"133133+#define WL1271_FW_NAME "ti-connectivity/wl1271-fw-2.bin"134134+#define WL1271_AP_FW_NAME "ti-connectivity/wl1271-fw-ap.bin"135135136136-#define WL1271_NVS_NAME "wl1271-nvs.bin"136136+#define WL1271_NVS_NAME "ti-connectivity/wl1271-nvs.bin"137137138138#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))139139#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))···317317 WL1271_FLAG_JOINED,318318 WL1271_FLAG_GPIO_POWER,319319 WL1271_FLAG_TX_QUEUE_STOPPED,320320+ WL1271_FLAG_TX_PENDING,320321 WL1271_FLAG_IN_ELP,321322 WL1271_FLAG_PSM,322323 WL1271_FLAG_PSM_REQUESTED,323323- WL1271_FLAG_IRQ_PENDING,324324 WL1271_FLAG_IRQ_RUNNING,325325 WL1271_FLAG_IDLE,326326 WL1271_FLAG_IDLE_REQUESTED,···404404 struct sk_buff_head tx_queue[NUM_TX_QUEUES];405405 int tx_queue_count;406406407407+ /* Frames received, not handled yet by mac80211 */408408+ struct sk_buff_head deferred_rx_queue;409409+410410+ /* Frames sent, not returned yet to mac80211 */411411+ struct sk_buff_head deferred_tx_queue;412412+407413 struct work_struct tx_work;408414409415 /* Pending TX frames */···430424 /* Intermediate buffer, used for packet aggregation */431425 u8 *aggr_buf;432426433433- /* The target interrupt mask */434434- struct work_struct irq_work;427427+ /* Network stack work */428428+ struct work_struct netstack_work;435429436430 /* Hardware recovery work */437431 struct work_struct recovery_work;···541535542536 /* AP-mode - a bitmap of links currently in PS mode in mac80211 */543537 unsigned long ap_ps_map;538538+539539+ /* Quirks of specific hardware revisions */540540+ unsigned int quirks;544541};545542546543struct wl1271_station {···562553#define WL1271_TX_QUEUE_LOW_WATERMARK 10563554#define WL1271_TX_QUEUE_HIGH_WATERMARK 25564555556556+#define WL1271_DEFERRED_QUEUE_LIMIT 64557557+565558/* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power566559 on in case is has been shut down shortly before */567560#define WL1271_PRE_POWER_ON_SLEEP 20 /* in milliseconds */···572561/* Macros to handle wl1271.sta_rate_set */573562#define HW_BG_RATES_MASK 0xffff574563#define HW_HT_RATES_OFFSET 16564564+565565+/* Quirks */566566+567567+/* Each RX/TX transaction requires an end-of-transaction transfer */568568+#define WL12XX_QUIRK_END_OF_TRANSACTION BIT(0)575569576570#endif
+1-2
drivers/net/wireless/wl12xx/wl12xx_80211.h
···55555656/* This really should be 8, but not for our firmware */5757#define MAX_SUPPORTED_RATES 325858-#define COUNTRY_STRING_LEN 35958#define MAX_COUNTRY_TRIPLETS 3260596160/* Headers */···989999100struct wl12xx_ie_country {100101 struct wl12xx_ie_header header;101101- u8 country_string[COUNTRY_STRING_LEN];102102+ u8 country_string[IEEE80211_COUNTRY_STRING_LEN];102103 struct country_triplet triplets[MAX_COUNTRY_TRIPLETS];103104} __packed;104105
+3
include/linux/ieee80211.h
···13251325/* Although the spec says 8 I'm seeing 6 in practice */13261326#define IEEE80211_COUNTRY_IE_MIN_LEN 61327132713281328+/* The Country String field of the element shall be 3 octets in length */13291329+#define IEEE80211_COUNTRY_STRING_LEN 313301330+13281331/*13291332 * For regulatory extension stuff see IEEE 802.11-200713301333 * Annex I (page 1141) and Annex J (page 1147). Also
···221221 tristate222222223223config AVERAGE224224- bool224224+ bool "Averaging functions"225225+ help226226+ This option is provided for the case where no in-kernel-tree227227+ modules require averaging functions, but a module built outside228228+ the kernel tree does. Such modules that use library averaging229229+ functions require Y here.230230+231231+ If unsure, say N.225232226233endmenu
···380380381381 trace_api_restart_hw(local);382382383383+ wiphy_info(hw->wiphy,384384+ "Hardware restart was requested\n");385385+383386 /* use this reason, ieee80211_reconfig will unblock it */384387 ieee80211_stop_queues_by_reason(hw,385388 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
+6-13
net/mac80211/rc80211_minstrel_ht.c
···415415 mi->sample_count--;416416 }417417418418- if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) {418418+ if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)419419 mi->sample_packets += info->status.ampdu_len;420420- minstrel_next_sample_idx(mi);421421- }422420423421 for (i = 0; !last; i++) {424422 last = (i == IEEE80211_TX_MAX_RATES - 1) ||···517519 rate->count = mr->retry_count;518520519521 rate->flags = IEEE80211_TX_RC_MCS | group->flags;520520- if (txrc->short_preamble)521521- rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;522522- if (txrc->rts || rtscts)522522+ if (rtscts)523523 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;524524 rate->idx = index % MCS_GROUP_RATES + (group->streams - 1) * MCS_GROUP_RATES;525525}···549553 sample_idx = sample_table[mg->column][mg->index];550554 mr = &mg->rates[sample_idx];551555 sample_idx += mi->sample_group * MCS_GROUP_RATES;556556+ minstrel_next_sample_idx(mi);552557553558 /*554559 * When not using MRR, do not sample if the probability is already555560 * higher than 95% to avoid wasting airtime556561 */557562 if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))558558- goto next;563563+ return -1;559564560565 /*561566 * Make sure that lower rates get sampled only occasionally,···565568 if (minstrel_get_duration(sample_idx) >566569 minstrel_get_duration(mi->max_tp_rate)) {567570 if (mr->sample_skipped < 20)568568- goto next;571571+ return -1;569572570573 if (mi->sample_slow++ > 2)571571- goto next;574574+ return -1;572575 }573576574577 return sample_idx;575575-576576-next:577577- minstrel_next_sample_idx(mi);578578- return -1;579578}580579581580static void
-3
net/mac80211/rc80211_pid.h
···2424/* Fixed point arithmetic shifting amount. */2525#define RC_PID_ARITH_SHIFT 826262727-/* Fixed point arithmetic factor. */2828-#define RC_PID_ARITH_FACTOR (1 << RC_PID_ARITH_SHIFT)2929-3027/* Proportional PID component coefficient. */3128#define RC_PID_COEFF_P 153229/* Integral PID component coefficient. */
+24-40
net/mac80211/scan.c
···258258 return true;259259}260260261261-static bool __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,261261+static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,262262 bool was_hw_scan)263263{264264 struct ieee80211_local *local = hw_to_local(hw);265265+ bool on_oper_chan;266266+ bool enable_beacons = false;265267266268 lockdep_assert_held(&local->mtx);267269···277275 aborted = true;278276279277 if (WARN_ON(!local->scan_req))280280- return false;278278+ return;281279282280 if (was_hw_scan && !aborted && ieee80211_prep_hw_scan(local)) {283281 int rc = drv_hw_scan(local, local->scan_sdata, local->hw_scan_req);284282 if (rc == 0)285285- return false;283283+ return;286284 }287285288286 kfree(local->hw_scan_req);···296294 local->scanning = 0;297295 local->scan_channel = NULL;298296299299- return true;300300-}301301-302302-static void __ieee80211_scan_completed_finish(struct ieee80211_hw *hw,303303- bool was_hw_scan)304304-{305305- struct ieee80211_local *local = hw_to_local(hw);306306- bool on_oper_chan;307307- bool enable_beacons = false;308308-309309- mutex_lock(&local->mtx);310297 on_oper_chan = ieee80211_cfg_on_oper_channel(local);311298312312- WARN_ON(local->scanning & (SCAN_SW_SCANNING | SCAN_HW_SCANNING));313313-314314- if (was_hw_scan || !on_oper_chan) {315315- if (WARN_ON(local->scan_channel))316316- local->scan_channel = NULL;299299+ if (was_hw_scan || !on_oper_chan)317300 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);318318- } else301301+ else319302 /* Set power back to normal operating levels. */320303 ieee80211_hw_config(local, 0);321304···318331 }319332320333 ieee80211_recalc_idle(local);321321- mutex_unlock(&local->mtx);322334323335 ieee80211_mlme_notify_scan_completed(local);324336 ieee80211_ibss_notify_scan_completed(local);···672686{673687 struct ieee80211_local *local =674688 container_of(work, struct ieee80211_local, scan_work.work);675675- struct ieee80211_sub_if_data *sdata = local->scan_sdata;689689+ struct ieee80211_sub_if_data *sdata;676690 unsigned long next_delay = 0;677677- bool aborted, hw_scan, finish;691691+ bool aborted, hw_scan;678692679693 mutex_lock(&local->mtx);694694+695695+ sdata = local->scan_sdata;680696681697 if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {682698 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);···743755 } while (next_delay == 0);744756745757 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);746746- mutex_unlock(&local->mtx);747747- return;758758+ goto out;748759749760out_complete:750761 hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);751751- finish = __ieee80211_scan_completed(&local->hw, aborted, hw_scan);752752- mutex_unlock(&local->mtx);753753- if (finish)754754- __ieee80211_scan_completed_finish(&local->hw, hw_scan);755755- return;756756-762762+ __ieee80211_scan_completed(&local->hw, aborted, hw_scan);757763out:758764 mutex_unlock(&local->mtx);759765}···817835void ieee80211_scan_cancel(struct ieee80211_local *local)818836{819837 bool abortscan;820820- bool finish = false;821838822839 /*823840 * We are only canceling software scan, or deferred scan that was not···836855837856 mutex_lock(&local->mtx);838857 abortscan = local->scan_req && !test_bit(SCAN_HW_SCANNING, &local->scanning);839839- if (abortscan)840840- finish = __ieee80211_scan_completed(&local->hw, true, false);841841- mutex_unlock(&local->mtx);842842-843858 if (abortscan) {844844- /* The scan is canceled, but stop work from being pending */845845- cancel_delayed_work_sync(&local->scan_work);859859+ /*860860+ * The scan is canceled, but stop work from being pending.861861+ *862862+ * If the work is currently running, it must be blocked on863863+ * the mutex, but we'll set scan_sdata = NULL and it'll864864+ * simply exit once it acquires the mutex.865865+ */866866+ cancel_delayed_work(&local->scan_work);867867+ /* and clean up */868868+ __ieee80211_scan_completed(&local->hw, true, false);846869 }847847- if (finish)848848- __ieee80211_scan_completed_finish(&local->hw, false);870870+ mutex_unlock(&local->mtx);849871}
···6363/* To trigger userspace events */6464static struct platform_device *reg_pdev;65656666+static struct device_type reg_device_type = {6767+ .uevent = reg_device_uevent,6868+};6969+6670/*6771 * Central wireless core regulatory domains, we only need two,6872 * the current one and a world regulatory domain in case we have no···366362367363/*368364 * This lets us keep regulatory code which is updated on a regulatory369369- * basis in userspace.365365+ * basis in userspace. Country information is filled in by366366+ * reg_device_uevent370367 */371368static int call_crda(const char *alpha2)372369{373373- char country_env[9 + 2] = "COUNTRY=";374374- char *envp[] = {375375- country_env,376376- NULL377377- };378378-379370 if (!is_world_regdom((char *) alpha2))380371 pr_info("Calling CRDA for country: %c%c\n",381372 alpha2[0], alpha2[1]);···380381 /* query internal regulatory database (if it exists) */381382 reg_regdb_query(alpha2);382383383383- country_env[8] = alpha2[0];384384- country_env[9] = alpha2[1];385385-386386- return kobject_uevent_env(®_pdev->dev.kobj, KOBJ_CHANGE, envp);384384+ return kobject_uevent(®_pdev->dev.kobj, KOBJ_CHANGE);387385}388386389387/* Used by nl80211 before kmalloc'ing our regulatory domain */···20832087 return r;20842088}2085208920902090+#ifdef CONFIG_HOTPLUG20912091+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)20922092+{20932093+ if (last_request && !last_request->processed) {20942094+ if (add_uevent_var(env, "COUNTRY=%c%c",20952095+ last_request->alpha2[0],20962096+ last_request->alpha2[1]))20972097+ return -ENOMEM;20982098+ }20992099+21002100+ return 0;21012101+}21022102+#else21032103+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)21042104+{21052105+ return -ENODEV;21062106+}21072107+#endif /* CONFIG_HOTPLUG */21082108+20862109/* Caller must hold cfg80211_mutex */20872110void reg_device_remove(struct wiphy *wiphy)20882111{···21322117 reg_pdev = platform_device_register_simple("regulatory", 0, NULL, 0);21332118 if (IS_ERR(reg_pdev))21342119 return PTR_ERR(reg_pdev);21202120+21212121+ reg_pdev->dev.type = ®_device_type;2135212221362123 spin_lock_init(®_requests_lock);21372124 spin_lock_init(®_pending_beacons_lock);