From 03a8cf510dbef554b55403da7547607f7e326368 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 7 May 2011 16:42:47 +0200 Subject: [PATCH] carl9170 firmware: general purpose desc for internal use the new fw_desc can be used by any service routine within the firmware to generate frames within the firmware. Signed-off-by: Christian Lamparter --- carlfw/include/carl9170.h | 12 ++++++--- carlfw/src/dma.c | 7 +++--- carlfw/src/wlan.c | 52 +++++++++++++++++++++++---------------- 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/carlfw/include/carl9170.h b/carlfw/include/carl9170.h index cbfa611..b4a7fe7 100644 --- a/carlfw/include/carl9170.h +++ b/carlfw/include/carl9170.h @@ -69,6 +69,8 @@ enum carl9170_suspend_mode { CARL9170_AWAKE_HOST, }; +typedef void (*fw_desc_callback_t)(void *, const bool); + /* * This platform - being an odd 32-bit architecture - prefers to * have 32-Bit variables. @@ -129,11 +131,15 @@ struct firmware_context_struct { tx_status_tail_idx; struct carl9170_tx_status tx_status_cache[CARL9170_TX_STATUS_NUM]; + /* internal descriptor for use within the service routines */ + struct dma_desc *fw_desc; + unsigned int fw_desc_available; + void *fw_desc_data; + fw_desc_callback_t fw_desc_callback; + /* BA(R) Request Handler */ - struct dma_desc *ba_desc; struct carl9170_bar_ctx ba_cache[CONFIG_CARL9170FW_BACK_REQS_NUM]; - unsigned int ba_desc_available, - ba_tail_idx, + unsigned int ba_tail_idx, ba_head_idx; } wlan; diff --git a/carlfw/src/dma.c b/carlfw/src/dma.c index 18c57ce..8630f98 100644 --- a/carlfw/src/dma.c +++ b/carlfw/src/dma.c @@ -81,7 +81,7 @@ void dma_init_descriptors(void) fw.wlan.tx_retry.head = fw.wlan.tx_retry.terminator = &dma_mem.terminator[i++]; fw.wlan.rx_queue.head = fw.wlan.rx_queue.terminator = &dma_mem.terminator[i++]; fw.usb.int_desc = &dma_mem.terminator[i++]; - fw.wlan.ba_desc = &dma_mem.terminator[i++]; + fw.wlan.fw_desc = &dma_mem.terminator[i++]; #ifdef CONFIG_CARL9170FW_CAB_QUEUE /* GCC bug ? */ @@ -132,9 +132,8 @@ void dma_init_descriptors(void) /* rsp is now available for use */ fw.usb.int_desc_available = 1; - fw.wlan.ba_desc->dataAddr = (void *) &dma_mem.reserved.ba; - memset(DESC_PAYLOAD(fw.wlan.ba_desc), 0, 128); - fw.wlan.ba_desc_available = 1; + memset(DESC_PAYLOAD(fw.wlan.fw_desc), 0, 128); + fw.wlan.fw_desc_available = 1; } /* diff --git a/carlfw/src/wlan.c b/carlfw/src/wlan.c index caf9b6d..1909de1 100644 --- a/carlfw/src/wlan.c +++ b/carlfw/src/wlan.c @@ -438,19 +438,22 @@ static bool wlan_tx_status(struct dma_queue *queue, unhide_super(desc); - 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; } - 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(); @@ -500,6 +503,24 @@ void __hot wlan_tx(struct dma_desc *desc) wlan_trigger(BIT(super->s.queue)); } +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; @@ -510,26 +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; - fw.wlan.ba_desc_available = 0; - 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 = AR9170_OWN_BITS_SW; - fw.wlan.ba_desc->ctrl = AR9170_CTRL_FS_BIT | AR9170_CTRL_LS_BIT; - 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; @@ -561,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) -- 2.31.1