carl9170 firmware: general purpose desc for internal use
authorChristian Lamparter <chunkeey@googlemail.com>
Sat, 7 May 2011 14:42:47 +0000 (16:42 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Sat, 7 May 2011 14:54:46 +0000 (16:54 +0200)
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 <chunkeey@googlemail.com>
carlfw/include/carl9170.h
carlfw/src/dma.c
carlfw/src/wlan.c

index cbfa611b7e761ec2c6ae67b11ad6f668afac440e..b4a7fe72f2a4a453b7fdb3a246290c4852ced8fc 100644 (file)
@@ -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;
 
index 18c57ce1392e45405a0a75f0a45a7a5429035e2e..8630f98afba6809a94e40eaac4587fc8dd32b4d8 100644 (file)
@@ -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;
 }
 
 /*
index caf9b6d9201161c86cfea542a78c6a9264f5c3ef..1909de1db86fe7819c22055107619245e9ee10bf 100644 (file)
@@ -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)