From: Sujith Manoharan Date: Sun, 28 Apr 2013 21:01:37 +0530 Subject: [ath9k-devel] [PATCH 19/20] ath10k: Simplify excessively nested HTT structure layout In-Reply-To: <1367163098-22787-1-git-send-email-sujith@msujith.org> References: <1367163098-22787-1-git-send-email-sujith@msujith.org> Message-ID: <1367163098-22787-19-git-send-email-sujith@msujith.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org From: Sujith Manoharan There are various sructures inside HTT/RX_RING that contain very few elements. Simplify these. Signed-off-by: Sujith Manoharan --- drivers/net/wireless/ath/ath10k/htt.c | 2 +- drivers/net/wireless/ath/ath10k/htt.h | 48 +++++++++++++------------------- drivers/net/wireless/ath/ath10k/htt_rx.c | 37 ++++++++++++------------ 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt.c b/drivers/net/wireless/ath/ath10k/htt.c index 1b92f84..09acb00 100644 --- a/drivers/net/wireless/ath/ath10k/htt.c +++ b/drivers/net/wireless/ath/ath10k/htt.c @@ -200,7 +200,7 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar) return NULL; htt->ar = ar; - htt->cfg.max_throughput_mbps = 800; + htt->max_throughput_mbps = 800; /* * Connect to HTC service. diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h index bd3b0b4..e4bac01 100644 --- a/drivers/net/wireless/ath/ath10k/htt.h +++ b/drivers/net/wireless/ath/ath10k/htt.h @@ -1090,38 +1090,35 @@ struct htt_rx_info { bool fcs_err; }; +#define HTT_MAX_NUM_PENDING_TX 512 /* FIXME: find proper value? */ + struct ath10k_htt { struct ath10k *ar; enum ath10k_htc_ep_id eid; - struct { - int max_throughput_mbps; - } cfg; - + int max_throughput_mbps; u8 target_version_major; u8 target_version_minor; struct completion target_version_received; struct { - struct { - /* - * Ring of network buffer objects - This ring is - * used exclusively by the host SW. This ring - * mirrors the dev_addrs_ring that is shared - * between the host SW and the MAC HW. The host SW - * uses this netbufs ring to locate the network - * buffer objects whose data buffers the HW has - * filled. - */ - struct sk_buff **netbufs_ring; - /* - * Ring of buffer addresses - - * This ring holds the "physical" device address of the - * rx buffers the host SW provides for the MAC HW to - * fill. - */ - __le32 *paddrs_ring; - } buf; + /* + * Ring of network buffer objects - This ring is + * used exclusively by the host SW. This ring + * mirrors the dev_addrs_ring that is shared + * between the host SW and the MAC HW. The host SW + * uses this netbufs ring to locate the network + * buffer objects whose data buffers the HW has + * filled. + */ + struct sk_buff **netbufs_ring; + /* + * Ring of buffer addresses - + * This ring holds the "physical" device address of the + * rx buffers the host SW provides for the MAC HW to + * fill. + */ + __le32 *paddrs_ring; /* * Base address of ring, as a "physical" device address @@ -1168,11 +1165,6 @@ struct ath10k_htt { unsigned int prefetch_len; - struct { - int htc_err_cnt; - } stats; - -#define HTT_MAX_NUM_PENDING_TX 512 /* FIXME: find proper value? */ spinlock_t tx_lock; struct sk_buff *pending_tx[HTT_MAX_NUM_PENDING_TX]; DECLARE_BITMAP(used_msdu_ids, HTT_MAX_NUM_PENDING_TX); diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index a310dde..95ffcc2 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -237,7 +237,7 @@ static int ath10k_htt_rx_ring_size(struct ath10k_htt *htt) /* 1e6 bps/mbps / 1e3 ms per sec = 1000 */ size = - htt->cfg.max_throughput_mbps + + htt->max_throughput_mbps + 1000 / (8 * HTT_RX_AVG_FRM_BYTES) * HTT_RX_HOST_LATENCY_MAX_MS; @@ -258,7 +258,7 @@ static int ath10k_htt_rx_ring_fill_level(struct ath10k_htt *htt) /* 1e6 bps/mbps / 1e3 ms per sec = 1000 */ size = - htt->cfg.max_throughput_mbps * + htt->max_throughput_mbps * 1000 / (8 * HTT_RX_AVG_FRM_BYTES) * HTT_RX_HOST_LATENCY_WORST_LIKELY_MS; @@ -316,8 +316,8 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num) } ATH10K_SKB_CB(skb)->paddr = paddr; - htt->rx_ring.buf.netbufs_ring[idx] = skb; - htt->rx_ring.buf.paddrs_ring[idx] = __cpu_to_le32(paddr); + htt->rx_ring.netbufs_ring[idx] = skb; + htt->rx_ring.paddrs_ring[idx] = __cpu_to_le32(paddr); htt->rx_ring.fill_cnt++; num--; @@ -360,21 +360,21 @@ void ath10k_htt_rx_detach(struct ath10k_htt *htt) while (sw_rd_idx != __le32_to_cpu(*(htt->rx_ring.alloc_idx.vaddr))) { struct sk_buff *skb = - htt->rx_ring.buf.netbufs_ring[sw_rd_idx]; + htt->rx_ring.netbufs_ring[sw_rd_idx]; struct ath10k_skb_cb *cb = ATH10K_SKB_CB(skb); dma_unmap_single(htt->ar->dev, cb->paddr, skb->len + skb_tailroom(skb), DMA_FROM_DEVICE); - dev_kfree_skb_any(htt->rx_ring.buf.netbufs_ring[sw_rd_idx]); + dev_kfree_skb_any(htt->rx_ring.netbufs_ring[sw_rd_idx]); sw_rd_idx++; sw_rd_idx &= htt->rx_ring.size_mask; } dma_free_coherent(htt->ar->dev, (htt->rx_ring.size * - sizeof(htt->rx_ring.buf.paddrs_ring)), - htt->rx_ring.buf.paddrs_ring, + sizeof(htt->rx_ring.paddrs_ring)), + htt->rx_ring.paddrs_ring, htt->rx_ring.base_paddr); dma_free_coherent(htt->ar->dev, @@ -382,7 +382,7 @@ void ath10k_htt_rx_detach(struct ath10k_htt *htt) htt->rx_ring.alloc_idx.vaddr, htt->rx_ring.alloc_idx.paddr); - kfree(htt->rx_ring.buf.netbufs_ring); + kfree(htt->rx_ring.netbufs_ring); } static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct ath10k_htt *htt) @@ -396,7 +396,7 @@ static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct ath10k_htt *htt) ath10k_warn("htt rx ring is empty!\n"); idx = htt->rx_ring.sw_rd_idx.msdu_payld; - msdu = htt->rx_ring.buf.netbufs_ring[idx]; + msdu = htt->rx_ring.netbufs_ring[idx]; idx++; idx &= htt->rx_ring.size_mask; @@ -611,19 +611,19 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt) */ htt->rx_ring.fill_level = ath10k_htt_rx_ring_fill_level(htt); - htt->rx_ring.buf.netbufs_ring = + htt->rx_ring.netbufs_ring = kmalloc(htt->rx_ring.size * sizeof(struct sk_buff *), GFP_KERNEL); - if (!htt->rx_ring.buf.netbufs_ring) + if (!htt->rx_ring.netbufs_ring) goto fail1; vaddr = dma_alloc_coherent(htt->ar->dev, - (htt->rx_ring.size * sizeof(htt->rx_ring.buf.paddrs_ring)), + (htt->rx_ring.size * sizeof(htt->rx_ring.paddrs_ring)), &paddr, GFP_DMA); if (!vaddr) goto fail2; - htt->rx_ring.buf.paddrs_ring = vaddr; + htt->rx_ring.paddrs_ring = vaddr; htt->rx_ring.base_paddr = paddr; vaddr = dma_alloc_coherent(htt->ar->dev, @@ -646,16 +646,17 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt) ath10k_htt_rx_ring_fill_n(htt, htt->rx_ring.fill_level); spin_unlock_bh(&htt->rx_ring.lock); + ath10k_dbg(ATH10K_DBG_HTT, "HTT RX ring size: %d, fill_level: %d\n", + htt->rx_ring.size, htt->rx_ring.fill_level); return 0; - fail3: dma_free_coherent(htt->ar->dev, (htt->rx_ring.size * - sizeof(htt->rx_ring.buf.paddrs_ring)), - htt->rx_ring.buf.paddrs_ring, + sizeof(htt->rx_ring.paddrs_ring)), + htt->rx_ring.paddrs_ring, htt->rx_ring.base_paddr); fail2: - kfree(htt->rx_ring.buf.netbufs_ring); + kfree(htt->rx_ring.netbufs_ring); fail1: return -ENOMEM; } -- 1.8.2.2