X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=carlfw%2Fsrc%2Fwlan.c;h=942df83148fa61ff4e24f34d49c0f6e97603be4a;hb=6614f805fda27b63bad3e75a12432b436c0d2681;hp=b81b74f687941c330d872dc7f8974f7eccd6fbf2;hpb=bf38ae52cd2ec91f5abeadc00c4e17fc647c2bc0;p=carl9170fw.git diff --git a/carlfw/src/wlan.c b/carlfw/src/wlan.c index b81b74f..942df83 100644 --- a/carlfw/src/wlan.c +++ b/carlfw/src/wlan.c @@ -358,7 +358,7 @@ static bool wlan_tx_status(struct dma_queue *queue, { struct carl9170_tx_superframe *super = get_super(desc); unsigned int qidx = super->s.queue; - bool txfail, success; + bool txfail = false, success; success = true; @@ -438,21 +438,22 @@ static bool wlan_tx_status(struct dma_queue *queue, unhide_super(desc); -#ifdef CONFIG_CARL9170FW_HANDLE_BACK_REQ - if (unlikely(super == (void *) &dma_mem.reserved.ba)) { - fw.wlan.ba_desc = desc; - fw.wlan.ba_desc_available = 1; + if (unlikely(super == fw.wlan.fw_desc_data)) { + fw.wlan.fw_desc = desc; + fw.wlan.fw_desc_available = 1; + if (fw.wlan.fw_desc_callback) + fw.wlan.fw_desc_callback(super, success); + return true; } -#endif /* CONFIG_CARL9170FW_HANDLE_BACK_REQ */ - - wlan_tx_complete(super, success); #ifdef CONFIG_CARL9170FW_CAB_QUEUE if (unlikely(super->s.cab)) fw.wlan.cab_queue_len[super->s.vif_id]--; #endif /* CONFIG_CARL9170FW_CAB_QUEUE */ + wlan_tx_complete(super, success); + /* recycle freed descriptors */ dma_reclaim(&fw.pta.down_queue, desc); down_trigger(); @@ -502,7 +503,24 @@ void __hot wlan_tx(struct dma_desc *desc) wlan_trigger(BIT(super->s.queue)); } -#ifdef CONFIG_CARL9170FW_HANDLE_BACK_REQ +static void wlan_tx_fw(struct carl9170_tx_superdesc *super) +{ + if (!fw.wlan.fw_desc_available) + return; + + fw.wlan.fw_desc_available = 0; + + /* Format BlockAck */ + fw.wlan.fw_desc->status = AR9170_OWN_BITS_SW; + fw.wlan.fw_desc->ctrl = AR9170_CTRL_FS_BIT | AR9170_CTRL_LS_BIT; + fw.wlan.fw_desc->totalLen = fw.wlan.fw_desc->dataSize = super->len; + fw.wlan.fw_desc_data = fw.wlan.fw_desc->dataAddr = super; + fw.wlan.fw_desc->nextAddr = fw.wlan.fw_desc->lastAddr = + fw.wlan.fw_desc; + + wlan_tx(fw.wlan.fw_desc); +} + static void wlan_send_buffered_ba(void) { struct carl9170_tx_ba_superframe *baf = &dma_mem.reserved.ba.ba; @@ -513,25 +531,16 @@ static void wlan_send_buffered_ba(void) return; /* there's no point to continue when the ba_desc is not available. */ - if (!fw.wlan.ba_desc_available) + if (!fw.wlan.fw_desc_available) return; ctx = &fw.wlan.ba_cache[fw.wlan.ba_head_idx]; fw.wlan.ba_head_idx++; fw.wlan.ba_head_idx %= CONFIG_CARL9170FW_BACK_REQS_NUM; - /* Format BlockAck */ - fw.wlan.ba_desc->status = 0; - fw.wlan.ba_desc->ctrl = AR9170_CTRL_FS_BIT | AR9170_CTRL_LS_BIT; - fw.wlan.ba_desc_available = 0; - fw.wlan.ba_desc->nextAddr = fw.wlan.ba_desc->lastAddr = - fw.wlan.ba_desc; - - baf->s.len = fw.wlan.ba_desc->totalLen = fw.wlan.ba_desc->dataSize = - sizeof(struct carl9170_tx_superdesc) + - sizeof(struct ar9170_tx_hwdesc) + - sizeof(struct ieee80211_ba); - + baf->s.len = sizeof(struct carl9170_tx_superdesc) + + sizeof(struct ar9170_tx_hwdesc) + + sizeof(struct ieee80211_ba); baf->s.ri[0].tries = 1; baf->s.queue = AR9170_TXQ_VO; baf->f.hdr.length = sizeof(struct ieee80211_ba) + FCS_LEN; @@ -563,8 +572,7 @@ static void wlan_send_buffered_ba(void) */ ba->control = ctx->control | cpu_to_le16(1); ba->start_seq_num = ctx->start_seq_num; - - wlan_tx(fw.wlan.ba_desc); + wlan_tx_fw(&baf->s); } static struct carl9170_bar_ctx *wlan_get_bar_cache_buffer(void) @@ -629,7 +637,6 @@ static void handle_bar(struct dma_desc *desc, struct ieee80211_hdr *hdr, ctx->phy = cpu_to_le32(0x2cc301); } } -#endif /* CONFIG_CARL9170FW_HANDLE_BACK_REQ */ static void wlan_check_rx_overrun(void) { @@ -829,9 +836,7 @@ static unsigned int wlan_rx_filter(struct dma_desc *desc) } else if (ieee80211_is_ctl(hdr->frame_control)) { switch (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) { case IEEE80211_STYPE_BACK_REQ: -#ifdef CONFIG_CARL9170FW_HANDLE_BACK_REQ handle_bar(desc, hdr, data_len, mac_err); -#endif /* CONFIG_CARL9170FW_HANDLE_BACK_REQ */ /* fallthrough */ rx_filter |= CARL9170_RX_FILTER_CTL_BACKR; break; @@ -962,6 +967,38 @@ void wlan_modify_beacon(const unsigned int vif, wlan_assign_seq((struct ieee80211_hdr *)addr, vif); } + +static void wlan_send_buffered_cab(void) +{ + unsigned int i; + + for (i = 0; i < CARL9170_INTF_NUM; i++) { + if (unlikely(fw.wlan.cab_flush_trigger[i] == CARL9170_CAB_TRIGGER_ARMED)) { + /* + * This is hardcoded into carl9170usb driver. + * + * The driver must set the PRETBTT event to beacon_interval - + * CARL9170_PRETBTT_KUS (usually 6) Kus. + * + * But still, we can only do so much about 802.11-2007 9.3.2.1 & + * 11.2.1.6. Let's hope the current solution is adequate enough. + */ + + if (is_after_msecs(fw.wlan.cab_flush_time, (CARL9170_TBTT_DELTA))) { + wlan_cab_flush_queue(i); + + /* + * This prevents the code from sending new BC/MC frames + * which were queued after the previous buffered traffic + * has been sent out... They will have to wait until the + * next DTIM beacon comes along. + */ + fw.wlan.cab_flush_trigger[i] = CARL9170_CAB_TRIGGER_DEFER; + } + } + + } +} #endif /* CONFIG_CARL9170FW_CAB_QUEUE */ static void handle_beacon_config(void) @@ -1009,41 +1046,12 @@ static void handle_radar(void) static void wlan_janitor(void) { #ifdef CONFIG_CARL9170FW_CAB_QUEUE - unsigned int i; - - for (i = 0; i < CARL9170_INTF_NUM; i++) { - if (unlikely(fw.wlan.cab_flush_trigger[i] == CARL9170_CAB_TRIGGER_ARMED)) { - /* - * This is hardcoded into carl9170usb driver. - * - * The driver must set the PRETBTT event to beacon_interval - - * CARL9170_PRETBTT_KUS (usually 6) Kus. - * - * But still, we can only do so much about 802.11-2007 9.3.2.1 & - * 11.2.1.6. Let's hope the current solution is adequate enough. - */ - - if (is_after_msecs(fw.wlan.cab_flush_time, (CARL9170_TBTT_DELTA))) { - wlan_cab_flush_queue(i); - - /* - * This prevents the code from sending new BC/MC frames - * which were queued after the previous buffered traffic - * has been sent out... They will have to wait until the - * next DTIM beacon comes along. - */ - fw.wlan.cab_flush_trigger[i] = CARL9170_CAB_TRIGGER_DEFER; - } - } - - } + wlan_send_buffered_cab(); #endif /* CONFIG_CARL9170FW_CAB_QUEUE */ wlan_send_buffered_tx_status(); -#ifdef CONFIG_CARL9170FW_HANDLE_BACK_REQ wlan_send_buffered_ba(); -#endif /* CONFIG_CARL9170FW_HANDLE_BACK_REQ */ } void handle_wlan(void)