···713713 /*714714 * AP-mode - allow this number of TX retries to a station before an715715 * event is triggered from FW.716716+ * In AP-mode the hlids of unreachable stations are given in the717717+ * "sta_tx_retry_exceeded" member in the event mailbox.716718 */717717- u16 ap_max_tx_retries;719719+ u8 max_tx_retries;720720+721721+ /*722722+ * AP-mode - after this number of seconds a connected station is723723+ * considered inactive.724724+ */725725+ u16 ap_aging_period;718726719727 /*720728 * Configuration for TID parameters.
···214214 u32 vector;215215 bool beacon_loss = false;216216 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);217217+ bool disconnect_sta = false;218218+ unsigned long sta_bitmap = 0;217219218220 wl1271_event_mbox_dump(mbox);219221···295293 wl1271_debug(DEBUG_EVENT, "DUMMY_PACKET_ID_EVENT_ID");296294 if (wl->vif)297295 wl1271_tx_dummy_packet(wl);296296+ }297297+298298+ /*299299+ * "TX retries exceeded" has a different meaning according to mode.300300+ * In AP mode the offending station is disconnected.301301+ */302302+ if ((vector & MAX_TX_RETRY_EVENT_ID) && is_ap) {303303+ wl1271_debug(DEBUG_EVENT, "MAX_TX_RETRY_EVENT_ID");304304+ sta_bitmap |= le16_to_cpu(mbox->sta_tx_retry_exceeded);305305+ disconnect_sta = true;306306+ }307307+308308+ if ((vector & INACTIVE_STA_EVENT_ID) && is_ap) {309309+ wl1271_debug(DEBUG_EVENT, "INACTIVE_STA_EVENT_ID");310310+ sta_bitmap |= le16_to_cpu(mbox->sta_aging_status);311311+ disconnect_sta = true;312312+ }313313+314314+ if (is_ap && disconnect_sta) {315315+ u32 num_packets = wl->conf.tx.max_tx_retries;316316+ struct ieee80211_sta *sta;317317+ const u8 *addr;318318+ int h;319319+320320+ for (h = find_first_bit(&sta_bitmap, AP_MAX_LINKS);321321+ h < AP_MAX_LINKS;322322+ h = find_next_bit(&sta_bitmap, AP_MAX_LINKS, h+1)) {323323+ if (!wl1271_is_active_sta(wl, h))324324+ continue;325325+326326+ addr = wl->links[h].addr;327327+328328+ rcu_read_lock();329329+ sta = ieee80211_find_sta(wl->vif, addr);330330+ if (sta) {331331+ wl1271_debug(DEBUG_EVENT, "remove sta %d", h);332332+ ieee80211_report_low_ack(sta, num_packets);333333+ }334334+ rcu_read_unlock();335335+ }298336 }299337300338 if (wl->vif && beacon_loss)
+11-1
drivers/net/wireless/wl12xx/event.h
···5858 CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(17),5959 BSS_LOSE_EVENT_ID = BIT(18),6060 REGAINED_BSS_EVENT_ID = BIT(19),6161- ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID = BIT(20),6161+ MAX_TX_RETRY_EVENT_ID = BIT(20),6262 /* STA: dummy paket for dynamic mem blocks */6363 DUMMY_PACKET_EVENT_ID = BIT(21),6464 /* AP: STA remove complete */6565 STA_REMOVE_COMPLETE_EVENT_ID = BIT(21),6666 SOFT_GEMINI_SENSE_EVENT_ID = BIT(22),6767+ /* STA: SG prediction */6768 SOFT_GEMINI_PREDICTION_EVENT_ID = BIT(23),6969+ /* AP: Inactive STA */7070+ INACTIVE_STA_EVENT_ID = BIT(23),6871 SOFT_GEMINI_AVALANCHE_EVENT_ID = BIT(24),6972 PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(25),7073 DBG_EVENT_ID = BIT(26),···122119123120 /* AP FW only */124121 u8 hlid_removed;122122+123123+ /* a bitmap of hlids for stations that have been inactive too long */125124 __le16 sta_aging_status;125125+126126+ /* a bitmap of hlids for stations which didn't respond to TX */126127 __le16 sta_tx_retry_exceeded;127128128129 /*···149142void wl1271_event_mbox_config(struct wl1271 *wl);150143int wl1271_event_handle(struct wl1271 *wl, u8 mbox);151144void wl1271_pspoll_work(struct work_struct *work);145145+146146+/* Functions from main.c */147147+bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid);152148153149#endif
+6-1
drivers/net/wireless/wl12xx/init.c
···447447 if (ret < 0)448448 return ret;449449450450- ret = wl1271_acx_max_tx_retry(wl);450450+ ret = wl1271_acx_ap_max_tx_retry(wl);451451 if (ret < 0)452452 return ret;453453454454 ret = wl1271_acx_ap_mem_cfg(wl);455455+ if (ret < 0)456456+ return ret;457457+458458+ /* initialize Tx power */459459+ ret = wl1271_acx_tx_power(wl, wl->power_level);455460 if (ret < 0)456461 return ret;457462
+143-59
drivers/net/wireless/wl12xx/main.c
···210210 .tx_op_limit = 1504,211211 },212212 },213213- .ap_max_tx_retries = 100,213213+ .max_tx_retries = 100,214214+ .ap_aging_period = 300,214215 .tid_conf_count = 4,215216 .tid_conf = {216217 [CONF_TX_AC_BE] = {···824823 }825824}826825826826+static u32 wl1271_tx_allocated_blocks(struct wl1271 *wl)827827+{828828+ int i;829829+ u32 total_alloc_blocks = 0;830830+831831+ for (i = 0; i < NUM_TX_QUEUES; i++)832832+ total_alloc_blocks += wl->tx_allocated_blocks[i];833833+834834+ return total_alloc_blocks;835835+}836836+827837static void wl1271_fw_status(struct wl1271 *wl,828838 struct wl1271_fw_full_status *full_status)829839{830840 struct wl1271_fw_common_status *status = &full_status->common;831841 struct timespec ts;832842 u32 old_tx_blk_count = wl->tx_blocks_available;833833- u32 freed_blocks = 0;843843+ u32 freed_blocks = 0, ac_freed_blocks;834844 int i;835845836846 if (wl->bss_type == BSS_TYPE_AP_BSS) {···861849862850 /* update number of available TX blocks */863851 for (i = 0; i < NUM_TX_QUEUES; i++) {864864- freed_blocks += le32_to_cpu(status->tx_released_blks[i]) -865865- wl->tx_blocks_freed[i];852852+ ac_freed_blocks = le32_to_cpu(status->tx_released_blks[i]) -853853+ wl->tx_blocks_freed[i];854854+ freed_blocks += ac_freed_blocks;855855+856856+ wl->tx_allocated_blocks[i] -= ac_freed_blocks;866857867858 wl->tx_blocks_freed[i] =868859 le32_to_cpu(status->tx_released_blks[i]);869860 }870870-871871- wl->tx_allocated_blocks -= freed_blocks;872861873862 if (wl->bss_type == BSS_TYPE_AP_BSS) {874863 /* Update num of allocated TX blocks per link and ps status */875864 wl1271_irq_update_links_status(wl, &full_status->ap);876865 wl->tx_blocks_available += freed_blocks;877866 } else {878878- int avail = full_status->sta.tx_total - wl->tx_allocated_blocks;867867+ int avail = full_status->sta.tx_total -868868+ wl1271_tx_allocated_blocks(wl);879869880870 /*881871 * The FW might change the total number of TX memblocks before···992978 /* Check if any tx blocks were freed */993979 spin_lock_irqsave(&wl->wl_lock, flags);994980 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&995995- wl->tx_queue_count) {981981+ wl1271_tx_total_queue_count(wl) > 0) {996982 spin_unlock_irqrestore(&wl->wl_lock, flags);997983 /*998984 * In order to avoid starvation of the TX path,···10401026 /* In case TX was not handled here, queue TX work */10411027 clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);10421028 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&10431043- wl->tx_queue_count)10291029+ wl1271_tx_total_queue_count(wl) > 0)10441030 ieee80211_queue_work(wl->hw, &wl->tx_work);10451031 spin_unlock_irqrestore(&wl->wl_lock, flags);10461032···1240122612411227 wl1271_info("Hardware recovery in progress. FW ver: %s pc: 0x%x",12421228 wl->chip.fw_ver_str, wl1271_read32(wl, SCR_PAD4));12291229+12301230+ /*12311231+ * Advance security sequence number to overcome potential progress12321232+ * in the firmware during recovery. This doens't hurt if the network is12331233+ * not encrypted.12341234+ */12351235+ if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) ||12361236+ test_bit(WL1271_FLAG_AP_STARTED, &wl->flags))12371237+ wl->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING;1243123812441239 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))12451240 ieee80211_connection_loss(wl->vif);···14971474{14981475 struct wl1271 *wl = hw->priv;14991476 unsigned long flags;15001500- int q;14771477+ int q, mapping;15011478 u8 hlid = 0;1502147915031503- q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));14801480+ mapping = skb_get_queue_mapping(skb);14811481+ q = wl1271_tx_get_queue(mapping);1504148215051483 if (wl->bss_type == BSS_TYPE_AP_BSS)15061484 hlid = wl1271_tx_get_hlid(skb);1507148515081486 spin_lock_irqsave(&wl->wl_lock, flags);1509148715101510- wl->tx_queue_count++;14881488+ wl->tx_queue_count[q]++;1511148915121490 /*15131491 * The workqueue is slow to process the tx_queue and we need stop15141492 * the queue here, otherwise the queue will get too long.15151493 */15161516- if (wl->tx_queue_count >= WL1271_TX_QUEUE_HIGH_WATERMARK) {15171517- wl1271_debug(DEBUG_TX, "op_tx: stopping queues");15181518- ieee80211_stop_queues(wl->hw);15191519- set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);14941494+ if (wl->tx_queue_count[q] >= WL1271_TX_QUEUE_HIGH_WATERMARK) {14951495+ wl1271_debug(DEBUG_TX, "op_tx: stopping queues for q %d", q);14961496+ ieee80211_stop_queue(wl->hw, mapping);14971497+ set_bit(q, &wl->stopped_queues_map);15201498 }1521149915221500 /* queue the packet */···15431519int wl1271_tx_dummy_packet(struct wl1271 *wl)15441520{15451521 unsigned long flags;15221522+ int q = wl1271_tx_get_queue(skb_get_queue_mapping(wl->dummy_packet));1546152315471524 spin_lock_irqsave(&wl->wl_lock, flags);15481525 set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags);15491549- wl->tx_queue_count++;15261526+ wl->tx_queue_count[q]++;15501527 spin_unlock_irqrestore(&wl->wl_lock, flags);1551152815521529 /* The FW is low on RX memory blocks, so send the dummy packet asap */···16111586#ifdef CONFIG_PM16121587static int wl1271_configure_suspend_sta(struct wl1271 *wl)16131588{16141614- int ret;15891589+ int ret = 0;1615159016161591 mutex_lock(&wl->mutex);15921592+15931593+ if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))15941594+ goto out_unlock;1617159516181596 ret = wl1271_ps_elp_wakeup(wl);16191597 if (ret < 0)···1662163416631635static int wl1271_configure_suspend_ap(struct wl1271 *wl)16641636{16651665- int ret;16371637+ int ret = 0;1666163816671639 mutex_lock(&wl->mutex);16401640+16411641+ if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags))16421642+ goto out_unlock;1668164316691644 ret = wl1271_ps_elp_wakeup(wl);16701645 if (ret < 0)···17361705 }17371706 /* flush any remaining work */17381707 wl1271_debug(DEBUG_MAC80211, "flushing remaining works");17391739- flush_delayed_work(&wl->scan_complete_work);1740170817411709 /*17421710 * disable and re-enable interrupts in order to flush···20071977 wl->psm_entry_retry = 0;20081978 wl->power_level = WL1271_DEFAULT_POWER_LEVEL;20091979 wl->tx_blocks_available = 0;20102010- wl->tx_allocated_blocks = 0;20111980 wl->tx_results_count = 0;20121981 wl->tx_packets_count = 0;20132013- wl->tx_security_last_seq = 0;20142014- wl->tx_security_seq = 0;20151982 wl->time_offset = 0;20161983 wl->session_counter = 0;20171984 wl->rate_set = CONF_TX_RATE_MASK_BASIC;···20272000 */20282001 wl->flags = 0;2029200220302030- for (i = 0; i < NUM_TX_QUEUES; i++)20032003+ for (i = 0; i < NUM_TX_QUEUES; i++) {20312004 wl->tx_blocks_freed[i] = 0;20052005+ wl->tx_allocated_blocks[i] = 0;20062006+ }2032200720332008 wl1271_debugfs_reset(wl);20342009···21832154 clear_bit(WL1271_FLAG_JOINED, &wl->flags);21842155 memset(wl->bssid, 0, ETH_ALEN);2185215621572157+ /* reset TX security counters on a clean disconnect */21582158+ wl->tx_security_last_seq_lsb = 0;21592159+ wl->tx_security_seq = 0;21602160+21862161 /* stop filtering packets based on bssid */21872162 wl1271_configure_filters(wl, FIF_OTHER_BSS);21882163···22782245 wl->band = conf->channel->band;22792246 wl->channel = channel;22802247 }22482248+22492249+ if ((changed & IEEE80211_CONF_CHANGE_POWER))22502250+ wl->power_level = conf->power_level;2281225122822252 goto out;22832253 }···27872751 mutex_unlock(&wl->mutex);2788275227892753 return ret;27542754+}27552755+27562756+static void wl1271_op_cancel_hw_scan(struct ieee80211_hw *hw,27572757+ struct ieee80211_vif *vif)27582758+{27592759+ struct wl1271 *wl = hw->priv;27602760+ int ret;27612761+27622762+ wl1271_debug(DEBUG_MAC80211, "mac80211 cancel hw scan");27632763+27642764+ mutex_lock(&wl->mutex);27652765+27662766+ if (wl->state == WL1271_STATE_OFF)27672767+ goto out;27682768+27692769+ if (wl->scan.state == WL1271_SCAN_STATE_IDLE)27702770+ goto out;27712771+27722772+ ret = wl1271_ps_elp_wakeup(wl);27732773+ if (ret < 0)27742774+ goto out;27752775+27762776+ if (wl->scan.state != WL1271_SCAN_STATE_DONE) {27772777+ ret = wl1271_scan_stop(wl);27782778+ if (ret < 0)27792779+ goto out_sleep;27802780+ }27812781+ wl->scan.state = WL1271_SCAN_STATE_IDLE;27822782+ memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));27832783+ wl->scan.req = NULL;27842784+ ieee80211_scan_completed(wl->hw, true);27852785+27862786+out_sleep:27872787+ wl1271_ps_elp_sleep(wl);27882788+out:27892789+ mutex_unlock(&wl->mutex);27902790+27912791+ cancel_delayed_work_sync(&wl->scan_complete_work);27902792}2791279327922794static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw,···35893515 __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);35903516}3591351735183518+bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid)35193519+{35203520+ int id = hlid - WL1271_AP_STA_HLID_START;35213521+ return test_bit(id, wl->ap_hlid_map);35223522+}35233523+35923524static int wl1271_op_sta_add(struct ieee80211_hw *hw,35933525 struct ieee80211_vif *vif,35943526 struct ieee80211_sta *sta)···37533673 goto out;3754367437553675 /* packets are considered pending if in the TX queue or the FW */37563756- ret = (wl->tx_queue_count > 0) || (wl->tx_frames_cnt > 0);36763676+ ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0);3757367737583678 /* the above is appropriate for STA mode for PS purposes */37593679 WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS);···3916383639173837/* 5 GHz band channels for WL1273 */39183838static struct ieee80211_channel wl1271_channels_5ghz[] = {39193919- { .hw_value = 7, .center_freq = 5035},39203920- { .hw_value = 8, .center_freq = 5040},39213921- { .hw_value = 9, .center_freq = 5045},39223922- { .hw_value = 11, .center_freq = 5055},39233923- { .hw_value = 12, .center_freq = 5060},39243924- { .hw_value = 16, .center_freq = 5080},39253925- { .hw_value = 34, .center_freq = 5170},39263926- { .hw_value = 36, .center_freq = 5180},39273927- { .hw_value = 38, .center_freq = 5190},39283928- { .hw_value = 40, .center_freq = 5200},39293929- { .hw_value = 42, .center_freq = 5210},39303930- { .hw_value = 44, .center_freq = 5220},39313931- { .hw_value = 46, .center_freq = 5230},39323932- { .hw_value = 48, .center_freq = 5240},39333933- { .hw_value = 52, .center_freq = 5260},39343934- { .hw_value = 56, .center_freq = 5280},39353935- { .hw_value = 60, .center_freq = 5300},39363936- { .hw_value = 64, .center_freq = 5320},39373937- { .hw_value = 100, .center_freq = 5500},39383938- { .hw_value = 104, .center_freq = 5520},39393939- { .hw_value = 108, .center_freq = 5540},39403940- { .hw_value = 112, .center_freq = 5560},39413941- { .hw_value = 116, .center_freq = 5580},39423942- { .hw_value = 120, .center_freq = 5600},39433943- { .hw_value = 124, .center_freq = 5620},39443944- { .hw_value = 128, .center_freq = 5640},39453945- { .hw_value = 132, .center_freq = 5660},39463946- { .hw_value = 136, .center_freq = 5680},39473947- { .hw_value = 140, .center_freq = 5700},39483948- { .hw_value = 149, .center_freq = 5745},39493949- { .hw_value = 153, .center_freq = 5765},39503950- { .hw_value = 157, .center_freq = 5785},39513951- { .hw_value = 161, .center_freq = 5805},39523952- { .hw_value = 165, .center_freq = 5825},38393839+ { .hw_value = 7, .center_freq = 5035, .max_power = 25 },38403840+ { .hw_value = 8, .center_freq = 5040, .max_power = 25 },38413841+ { .hw_value = 9, .center_freq = 5045, .max_power = 25 },38423842+ { .hw_value = 11, .center_freq = 5055, .max_power = 25 },38433843+ { .hw_value = 12, .center_freq = 5060, .max_power = 25 },38443844+ { .hw_value = 16, .center_freq = 5080, .max_power = 25 },38453845+ { .hw_value = 34, .center_freq = 5170, .max_power = 25 },38463846+ { .hw_value = 36, .center_freq = 5180, .max_power = 25 },38473847+ { .hw_value = 38, .center_freq = 5190, .max_power = 25 },38483848+ { .hw_value = 40, .center_freq = 5200, .max_power = 25 },38493849+ { .hw_value = 42, .center_freq = 5210, .max_power = 25 },38503850+ { .hw_value = 44, .center_freq = 5220, .max_power = 25 },38513851+ { .hw_value = 46, .center_freq = 5230, .max_power = 25 },38523852+ { .hw_value = 48, .center_freq = 5240, .max_power = 25 },38533853+ { .hw_value = 52, .center_freq = 5260, .max_power = 25 },38543854+ { .hw_value = 56, .center_freq = 5280, .max_power = 25 },38553855+ { .hw_value = 60, .center_freq = 5300, .max_power = 25 },38563856+ { .hw_value = 64, .center_freq = 5320, .max_power = 25 },38573857+ { .hw_value = 100, .center_freq = 5500, .max_power = 25 },38583858+ { .hw_value = 104, .center_freq = 5520, .max_power = 25 },38593859+ { .hw_value = 108, .center_freq = 5540, .max_power = 25 },38603860+ { .hw_value = 112, .center_freq = 5560, .max_power = 25 },38613861+ { .hw_value = 116, .center_freq = 5580, .max_power = 25 },38623862+ { .hw_value = 120, .center_freq = 5600, .max_power = 25 },38633863+ { .hw_value = 124, .center_freq = 5620, .max_power = 25 },38643864+ { .hw_value = 128, .center_freq = 5640, .max_power = 25 },38653865+ { .hw_value = 132, .center_freq = 5660, .max_power = 25 },38663866+ { .hw_value = 136, .center_freq = 5680, .max_power = 25 },38673867+ { .hw_value = 140, .center_freq = 5700, .max_power = 25 },38683868+ { .hw_value = 149, .center_freq = 5745, .max_power = 25 },38693869+ { .hw_value = 153, .center_freq = 5765, .max_power = 25 },38703870+ { .hw_value = 157, .center_freq = 5785, .max_power = 25 },38713871+ { .hw_value = 161, .center_freq = 5805, .max_power = 25 },38723872+ { .hw_value = 165, .center_freq = 5825, .max_power = 25 },39533873};3954387439553875/* mapping to indexes for wl1271_rates_5ghz */···40103930 .tx = wl1271_op_tx,40113931 .set_key = wl1271_op_set_key,40123932 .hw_scan = wl1271_op_hw_scan,39333933+ .cancel_hw_scan = wl1271_op_cancel_hw_scan,40133934 .sched_scan_start = wl1271_op_sched_scan_start,40143935 .sched_scan_stop = wl1271_op_sched_scan_stop,40153936 .bss_info_changed = wl1271_op_bss_info_changed,···44084327 wl->quirks = 0;44094328 wl->platform_quirks = 0;44104329 wl->sched_scanning = false;43304330+ wl->tx_security_seq = 0;43314331+ wl->tx_security_last_seq_lsb = 0;43324332+44114333 setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer,44124334 (unsigned long) wl);44134335 wl->fwlog_size = 0;
+6-3
drivers/net/wireless/wl12xx/ps.c
···193193194194static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid)195195{196196- int i, filtered = 0;196196+ int i;197197 struct sk_buff *skb;198198 struct ieee80211_tx_info *info;199199 unsigned long flags;200200+ int filtered[NUM_TX_QUEUES];200201201202 /* filter all frames currently the low level queus for this hlid */202203 for (i = 0; i < NUM_TX_QUEUES; i++) {204204+ filtered[i] = 0;203205 while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) {204206 info = IEEE80211_SKB_CB(skb);205207 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;206208 info->status.rates[0].idx = -1;207209 ieee80211_tx_status_ni(wl->hw, skb);208208- filtered++;210210+ filtered[i]++;209211 }210212 }211213212214 spin_lock_irqsave(&wl->wl_lock, flags);213213- wl->tx_queue_count -= filtered;215215+ for (i = 0; i < NUM_TX_QUEUES; i++)216216+ wl->tx_queue_count[i] -= filtered[i];214217 spin_unlock_irqrestore(&wl->wl_lock, flags);215218216219 wl1271_handle_tx_low_watermark(wl);
+27
drivers/net/wireless/wl12xx/scan.c
···321321 return 0;322322}323323324324+int wl1271_scan_stop(struct wl1271 *wl)325325+{326326+ struct wl1271_cmd_header *cmd = NULL;327327+ int ret = 0;328328+329329+ if (WARN_ON(wl->scan.state == WL1271_SCAN_STATE_IDLE))330330+ return -EINVAL;331331+332332+ wl1271_debug(DEBUG_CMD, "cmd scan stop");333333+334334+ cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);335335+ if (!cmd) {336336+ ret = -ENOMEM;337337+ goto out;338338+ }339339+340340+ ret = wl1271_cmd_send(wl, CMD_STOP_SCAN, cmd,341341+ sizeof(*cmd), 0);342342+ if (ret < 0) {343343+ wl1271_error("cmd stop_scan failed");344344+ goto out;345345+ }346346+out:347347+ kfree(cmd);348348+ return ret;349349+}350350+324351static int325352wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,326353 struct cfg80211_sched_scan_request *req,
···166166 ret = pm_runtime_get_sync(&func->dev);167167 if (ret)168168 goto out;169169+ } else {170170+ /* Runtime PM is disabled: power up the card manually */171171+ ret = mmc_power_restore_host(func->card->host);172172+ if (ret < 0)173173+ goto out;169174 }170170-171171- /* Runtime PM might be disabled, so power up the card manually */172172- ret = mmc_power_restore_host(func->card->host);173173- if (ret < 0)174174- goto out;175175176176 sdio_claim_host(func);177177 sdio_enable_func(func);···188188 sdio_disable_func(func);189189 sdio_release_host(func);190190191191- /* Runtime PM might be disabled, so power off the card manually */191191+ /* Power off the card manually, even if runtime PM is enabled. */192192 ret = mmc_power_save_host(func->card->host);193193 if (ret < 0)194194 return ret;
+97-46
drivers/net/wireless/wl12xx/tx.c
···168168 u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra;169169 u32 len;170170 u32 total_blocks;171171- int id, ret = -EBUSY;171171+ int id, ret = -EBUSY, ac;172172 u32 spare_blocks;173173174174 if (unlikely(wl->quirks & WL12XX_QUIRK_USE_2_SPARE_BLOCKS))···206206 desc->id = id;207207208208 wl->tx_blocks_available -= total_blocks;209209- wl->tx_allocated_blocks += total_blocks;209209+210210+ ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb));211211+ wl->tx_allocated_blocks[ac] += total_blocks;210212211213 if (wl->bss_type == BSS_TYPE_AP_BSS)212214 wl->links[hlid].allocated_blks += total_blocks;···385383 if (ret < 0)386384 return ret;387385386386+ wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);387387+388388 if (wl->bss_type == BSS_TYPE_AP_BSS) {389389 wl1271_tx_ap_update_inconnection_sta(wl, skb);390390 wl1271_tx_regulate_link(wl, hlid);391391 } else {392392 wl1271_tx_update_filters(wl, skb);393393 }394394-395395- wl1271_tx_fill_hdr(wl, skb, extra, info, hlid);396394397395 /*398396 * The length of each packet is stored in terms of···444442void wl1271_handle_tx_low_watermark(struct wl1271 *wl)445443{446444 unsigned long flags;445445+ int i;447446448448- if (test_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags) &&449449- wl->tx_queue_count <= WL1271_TX_QUEUE_LOW_WATERMARK) {450450- /* firmware buffer has space, restart queues */451451- spin_lock_irqsave(&wl->wl_lock, flags);452452- ieee80211_wake_queues(wl->hw);453453- clear_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);454454- spin_unlock_irqrestore(&wl->wl_lock, flags);447447+ for (i = 0; i < NUM_TX_QUEUES; i++) {448448+ if (test_bit(i, &wl->stopped_queues_map) &&449449+ wl->tx_queue_count[i] <= WL1271_TX_QUEUE_LOW_WATERMARK) {450450+ /* firmware buffer has space, restart queues */451451+ spin_lock_irqsave(&wl->wl_lock, flags);452452+ ieee80211_wake_queue(wl->hw,453453+ wl1271_tx_get_mac80211_queue(i));454454+ clear_bit(i, &wl->stopped_queues_map);455455+ spin_unlock_irqrestore(&wl->wl_lock, flags);456456+ }455457 }458458+}459459+460460+static struct sk_buff_head *wl1271_select_queue(struct wl1271 *wl,461461+ struct sk_buff_head *queues)462462+{463463+ int i, q = -1;464464+ u32 min_blks = 0xffffffff;465465+466466+ /*467467+ * Find a non-empty ac where:468468+ * 1. There are packets to transmit469469+ * 2. The FW has the least allocated blocks470470+ */471471+ for (i = 0; i < NUM_TX_QUEUES; i++)472472+ if (!skb_queue_empty(&queues[i]) &&473473+ (wl->tx_allocated_blocks[i] < min_blks)) {474474+ q = i;475475+ min_blks = wl->tx_allocated_blocks[q];476476+ }477477+478478+ if (q == -1)479479+ return NULL;480480+481481+ return &queues[q];456482}457483458484static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl)459485{460486 struct sk_buff *skb = NULL;461487 unsigned long flags;488488+ struct sk_buff_head *queue;462489463463- skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_VO]);464464- if (skb)490490+ queue = wl1271_select_queue(wl, wl->tx_queue);491491+ if (!queue)465492 goto out;466466- skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_VI]);467467- if (skb)468468- goto out;469469- skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_BE]);470470- if (skb)471471- goto out;472472- skb = skb_dequeue(&wl->tx_queue[CONF_TX_AC_BK]);493493+494494+ skb = skb_dequeue(queue);473495474496out:475497 if (skb) {498498+ int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));476499 spin_lock_irqsave(&wl->wl_lock, flags);477477- wl->tx_queue_count--;500500+ wl->tx_queue_count[q]--;478501 spin_unlock_irqrestore(&wl->wl_lock, flags);479502 }480503···511484 struct sk_buff *skb = NULL;512485 unsigned long flags;513486 int i, h, start_hlid;487487+ struct sk_buff_head *queue;514488515489 /* start from the link after the last one */516490 start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS;···520492 for (i = 0; i < AP_MAX_LINKS; i++) {521493 h = (start_hlid + i) % AP_MAX_LINKS;522494523523- skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VO]);495495+ /* only consider connected stations */496496+ if (h >= WL1271_AP_STA_HLID_START &&497497+ !test_bit(h - WL1271_AP_STA_HLID_START, wl->ap_hlid_map))498498+ continue;499499+500500+ queue = wl1271_select_queue(wl, wl->links[h].tx_queue);501501+ if (!queue)502502+ continue;503503+504504+ skb = skb_dequeue(queue);524505 if (skb)525525- goto out;526526- skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_VI]);527527- if (skb)528528- goto out;529529- skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BE]);530530- if (skb)531531- goto out;532532- skb = skb_dequeue(&wl->links[h].tx_queue[CONF_TX_AC_BK]);533533- if (skb)534534- goto out;506506+ break;535507 }536508537537-out:538509 if (skb) {510510+ int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));539511 wl->last_tx_hlid = h;540512 spin_lock_irqsave(&wl->wl_lock, flags);541541- wl->tx_queue_count--;513513+ wl->tx_queue_count[q]--;542514 spin_unlock_irqrestore(&wl->wl_lock, flags);543515 } else {544516 wl->last_tx_hlid = 0;···559531560532 if (!skb &&561533 test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) {534534+ int q;535535+562536 skb = wl->dummy_packet;537537+ q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));563538 spin_lock_irqsave(&wl->wl_lock, flags);564564- wl->tx_queue_count--;539539+ wl->tx_queue_count[q]--;565540 spin_unlock_irqrestore(&wl->wl_lock, flags);566541 }567542···589558 }590559591560 spin_lock_irqsave(&wl->wl_lock, flags);592592- wl->tx_queue_count++;561561+ wl->tx_queue_count[q]++;593562 spin_unlock_irqrestore(&wl->wl_lock, flags);594563}595564···735704736705 wl->stats.retry_count += result->ack_failures;737706738738- /* update security sequence number */739739- wl->tx_security_seq += (result->lsb_security_sequence_number -740740- wl->tx_security_last_seq);741741- wl->tx_security_last_seq = result->lsb_security_sequence_number;707707+ /*708708+ * update sequence number only when relevant, i.e. only in709709+ * sessions of TKIP, AES and GEM (not in open or WEP sessions)710710+ */711711+ if (info->control.hw_key &&712712+ (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP ||713713+ info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP ||714714+ info->control.hw_key->cipher == WL1271_CIPHER_SUITE_GEM)) {715715+ u8 fw_lsb = result->tx_security_sequence_number_lsb;716716+ u8 cur_lsb = wl->tx_security_last_seq_lsb;717717+718718+ /*719719+ * update security sequence number, taking care of potential720720+ * wrap-around721721+ */722722+ wl->tx_security_seq += (fw_lsb - cur_lsb + 256) % 256;723723+ wl->tx_security_last_seq_lsb = fw_lsb;724724+ }742725743726 /* remove private header from packet */744727 skb_pull(skb, sizeof(struct wl1271_tx_hw_descr));···817772void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)818773{819774 struct sk_buff *skb;820820- int i, total = 0;775775+ int i;821776 unsigned long flags;822777 struct ieee80211_tx_info *info;778778+ int total[NUM_TX_QUEUES];823779824780 for (i = 0; i < NUM_TX_QUEUES; i++) {781781+ total[i] = 0;825782 while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) {826783 wl1271_debug(DEBUG_TX, "link freeing skb 0x%p", skb);827784 info = IEEE80211_SKB_CB(skb);828785 info->status.rates[0].idx = -1;829786 info->status.rates[0].count = 0;830787 ieee80211_tx_status_ni(wl->hw, skb);831831- total++;788788+ total[i]++;832789 }833790 }834791835792 spin_lock_irqsave(&wl->wl_lock, flags);836836- wl->tx_queue_count -= total;793793+ for (i = 0; i < NUM_TX_QUEUES; i++)794794+ wl->tx_queue_count[i] -= total[i];837795 spin_unlock_irqrestore(&wl->wl_lock, flags);838796839797 wl1271_handle_tx_low_watermark(wl);···871823 ieee80211_tx_status_ni(wl->hw, skb);872824 }873825 }826826+ wl->tx_queue_count[i] = 0;874827 }875828 }876829877877- wl->tx_queue_count = 0;830830+ wl->stopped_queues_map = 0;878831879832 /*880833 * Make sure the driver is at a consistent state, in case this···928879 while (!time_after(jiffies, timeout)) {929880 mutex_lock(&wl->mutex);930881 wl1271_debug(DEBUG_TX, "flushing tx buffer: %d %d",931931- wl->tx_frames_cnt, wl->tx_queue_count);932932- if ((wl->tx_frames_cnt == 0) && (wl->tx_queue_count == 0)) {882882+ wl->tx_frames_cnt,883883+ wl1271_tx_total_queue_count(wl));884884+ if ((wl->tx_frames_cnt == 0) &&885885+ (wl1271_tx_total_queue_count(wl) == 0)) {933886 mutex_unlock(&wl->mutex);934887 return;935888 }
+27-1
drivers/net/wireless/wl12xx/tx.h
···150150 (from 1st EDCA AIFS counter until TX Complete). */151151 __le32 medium_delay;152152 /* LS-byte of last TKIP seq-num (saved per AC for recovery). */153153- u8 lsb_security_sequence_number;153153+ u8 tx_security_sequence_number_lsb;154154 /* Retry count - number of transmissions without successful ACK.*/155155 u8 ack_failures;156156 /* The rate that succeeded getting ACK···180180 default:181181 return CONF_TX_AC_BE;182182 }183183+}184184+185185+static inline int wl1271_tx_get_mac80211_queue(int queue)186186+{187187+ switch (queue) {188188+ case CONF_TX_AC_VO:189189+ return 0;190190+ case CONF_TX_AC_VI:191191+ return 1;192192+ case CONF_TX_AC_BE:193193+ return 2;194194+ case CONF_TX_AC_BK:195195+ return 3;196196+ default:197197+ return 2;198198+ }199199+}200200+201201+static inline int wl1271_tx_total_queue_count(struct wl1271 *wl)202202+{203203+ int i, count = 0;204204+205205+ for (i = 0; i < NUM_TX_QUEUES; i++)206206+ count += wl->tx_queue_count[i];207207+208208+ return count;183209}184210185211void wl1271_tx_work(struct work_struct *work);
+16-8
drivers/net/wireless/wl12xx/wl12xx.h
···144144145145#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))146146#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))147147+#define WL1271_TX_SQN_POST_RECOVERY_PADDING 0xff147148148149#define WL1271_CIPHER_SUITE_GEM 0x00147201149150···173172#define WL1271_PS_STA_MAX_BLOCKS (2 * 9)174173175174#define WL1271_AP_BSS_INDEX 0176176-#define WL1271_AP_DEF_INACTIV_SEC 300177175#define WL1271_AP_DEF_BEACON_EXP 20178176179177#define ACX_TX_DESCRIPTORS 32···424424 /* Accounting for allocated / available TX blocks on HW */425425 u32 tx_blocks_freed[NUM_TX_QUEUES];426426 u32 tx_blocks_available;427427- u32 tx_allocated_blocks;427427+ u32 tx_allocated_blocks[NUM_TX_QUEUES];428428 u32 tx_results_count;429429430430 /* Transmitted TX packets counter for chipset interface */···438438439439 /* Frames scheduled for transmission, not handled yet */440440 struct sk_buff_head tx_queue[NUM_TX_QUEUES];441441- int tx_queue_count;441441+ int tx_queue_count[NUM_TX_QUEUES];442442+ long stopped_queues_map;442443443444 /* Frames received, not handled yet by mac80211 */444445 struct sk_buff_head deferred_rx_queue;···455454 struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS];456455 int tx_frames_cnt;457456458458- /* Security sequence number counters */459459- u8 tx_security_last_seq;460460- s64 tx_security_seq;457457+ /*458458+ * Security sequence number459459+ * bits 0-15: lower 16 bits part of sequence number460460+ * bits 16-47: higher 32 bits part of sequence number461461+ * bits 48-63: not in use462462+ */463463+ u64 tx_security_seq;464464+465465+ /* 8 bits of the last sequence number in use */466466+ u8 tx_security_last_seq_lsb;461467462468 /* FW Rx counter */463469 u32 rx_counter;···640632641633#define WL1271_DEFAULT_POWER_LEVEL 0642634643643-#define WL1271_TX_QUEUE_LOW_WATERMARK 10644644-#define WL1271_TX_QUEUE_HIGH_WATERMARK 25635635+#define WL1271_TX_QUEUE_LOW_WATERMARK 32636636+#define WL1271_TX_QUEUE_HIGH_WATERMARK 256645637646638#define WL1271_DEFERRED_QUEUE_LIMIT 64647639