2011-06-06 09:26:05

by Yogesh Ashok Powar

[permalink] [raw]
Subject: [PATCH 0/4] AMSDU TX optimization

This patch series optimizes AMSDU TX path.

Yogesh Ashok Powar (4):
mwifiex: Remove list traversal in mwifiex_num_pkts_in_txq
mwifiex: Remove redundant skb_queue_empty checks
mwifiex: Adding check for enough space before padding
mwifiex: disable transmission buffer aggregation for AMSDU packets

drivers/net/wireless/mwifiex/11n_aggr.c | 54 +++++++++++++++++++------------
drivers/net/wireless/mwifiex/main.h | 1 +
drivers/net/wireless/mwifiex/wmm.c | 30 +++--------------
3 files changed, 40 insertions(+), 45 deletions(-)

--
1.7.3.5



2011-06-06 09:34:01

by Yogesh Ashok Powar

[permalink] [raw]
Subject: [PATCH 4/4] mwifiex: disable transmission buffer aggregation for AMSDU packets

Padding per MSDU will affect the length of next packet and hence
the exact length of next packet is uncertain here.

Also, aggregation of transmission buffer, while downloading the
data to the card, wont gain much on the AMSDU packets as the AMSDU
packets utilizes the transmission buffer space to the maximum
(adapter->tx_buf_size).

Signed-off-by: Yogesh Ashok Powar <[email protected]>
---
drivers/net/wireless/mwifiex/11n_aggr.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
index 25312e4..1a453a6 100644
--- a/drivers/net/wireless/mwifiex/11n_aggr.c
+++ b/drivers/net/wireless/mwifiex/11n_aggr.c
@@ -233,11 +233,19 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,

skb_push(skb_aggr, headroom);

- tx_param.next_pkt_len = ((pra_list->total_pkts_size) ?
- (((pra_list->total_pkts_size) >
- adapter->tx_buf_size) ? adapter->
- tx_buf_size : pra_list->total_pkts_size +
- LLC_SNAP_LEN + sizeof(struct txpd)) : 0);
+ /*
+ * Padding per MSDU will affect the length of next
+ * packet and hence the exact length of next packet
+ * is uncertain here.
+ *
+ * Also, aggregation of transmission buffer, while
+ * downloading the data to the card, wont gain much
+ * on the AMSDU packets as the AMSDU packets utilizes
+ * the transmission buffer space to the maximum
+ * (adapter->tx_buf_size).
+ */
+ tx_param.next_pkt_len = 0;
+
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA,
skb_aggr->data,
skb_aggr->len, &tx_param);
--
1.7.3.5


2011-06-06 09:30:41

by Yogesh Ashok Powar

[permalink] [raw]
Subject: [PATCH 2/4] mwifiex: Remove redundant skb_queue_empty checks

The check of skb list empty before calling skb_peek and skb_dequeue is
redundant. These functions returns NULL if the list is empty.

Signed-off-by: Yogesh Ashok Powar <[email protected]>
---
drivers/net/wireless/mwifiex/11n_aggr.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
index 84d2c76..aee3491 100644
--- a/drivers/net/wireless/mwifiex/11n_aggr.c
+++ b/drivers/net/wireless/mwifiex/11n_aggr.c
@@ -164,12 +164,13 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
struct mwifiex_tx_param tx_param;
struct txpd *ptx_pd = NULL;

- if (skb_queue_empty(&pra_list->skb_head)) {
+ skb_src = skb_peek(&pra_list->skb_head);
+ if (!skb_src) {
spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock,
ra_list_flags);
return 0;
}
- skb_src = skb_peek(&pra_list->skb_head);
+
tx_info_src = MWIFIEX_SKB_TXCB(skb_src);
skb_aggr = dev_alloc_skb(adapter->tx_buf_size);
if (!skb_aggr) {
@@ -188,10 +189,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
+ LLC_SNAP_LEN)
<= adapter->tx_buf_size)) {

- if (!skb_queue_empty(&pra_list->skb_head))
- skb_src = skb_dequeue(&pra_list->skb_head);
- else
- skb_src = NULL;
+ skb_src = skb_dequeue(&pra_list->skb_head);

if (skb_src) {
pra_list->total_pkts_size -= skb_src->len;
@@ -214,10 +212,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
return -1;
}

- if (!skb_queue_empty(&pra_list->skb_head))
- skb_src = skb_peek(&pra_list->skb_head);
- else
- skb_src = NULL;
+ skb_src = skb_peek(&pra_list->skb_head);
}

spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, ra_list_flags);
--
1.7.3.5


2011-06-06 09:32:44

by Yogesh Ashok Powar

[permalink] [raw]
Subject: [PATCH 3/4] mwifiex: adding check for enough space before padding

All MSDUs, except the last one in an AMSDU, should end up at 4
bytes boundary. There is need to check if enough skb_tailroom
space exists before padding the skb.

Also re-arranging code for better readablity.

Signed-off-by: Yogesh Ashok Powar <[email protected]>
---
drivers/net/wireless/mwifiex/11n_aggr.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
index aee3491..25312e4 100644
--- a/drivers/net/wireless/mwifiex/11n_aggr.c
+++ b/drivers/net/wireless/mwifiex/11n_aggr.c
@@ -185,16 +185,15 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
tx_info_aggr->bss_index = tx_info_src->bss_index;
skb_aggr->priority = skb_src->priority;

- while (skb_src && ((skb_headroom(skb_aggr) + skb_src->len
- + LLC_SNAP_LEN)
- <= adapter->tx_buf_size)) {
+ do {
+ /* Check if AMSDU can accommodate this MSDU */
+ if (skb_tailroom(skb_aggr) < (skb_src->len + LLC_SNAP_LEN))
+ break;

skb_src = skb_dequeue(&pra_list->skb_head);

- if (skb_src) {
- pra_list->total_pkts_size -= skb_src->len;
- pra_list->total_pkts--;
- }
+ pra_list->total_pkts_size -= skb_src->len;
+ pra_list->total_pkts--;

atomic_dec(&priv->wmm.tx_pkts_queued);

@@ -212,8 +211,15 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
return -1;
}

+ if (skb_tailroom(skb_aggr) < pad) {
+ pad = 0;
+ break;
+ }
+ skb_put(skb_aggr, pad);
+
skb_src = skb_peek(&pra_list->skb_head);
- }
+
+ } while (skb_src);

spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, ra_list_flags);

--
1.7.3.5


2011-06-06 09:29:15

by Yogesh Ashok Powar

[permalink] [raw]
Subject: [PATCH 1/4] mwifiex: remove list traversal in mwifiex_num_pkts_in_txq

Instead of counting the number of packets in txq
for particular RA list before AMSDU creation,
maintain a counter which will keep track of the
same.

This will reduce some MIPS while generating AMSDU
traffic as we only have to check the counter instead
of traversing through skb list.

Signed-off-by: Yogesh Ashok Powar <[email protected]>
---
drivers/net/wireless/mwifiex/11n_aggr.c | 5 ++++-
drivers/net/wireless/mwifiex/main.h | 1 +
drivers/net/wireless/mwifiex/wmm.c | 30 ++++++------------------------
3 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
index f807447..84d2c76 100644
--- a/drivers/net/wireless/mwifiex/11n_aggr.c
+++ b/drivers/net/wireless/mwifiex/11n_aggr.c
@@ -193,8 +193,10 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
else
skb_src = NULL;

- if (skb_src)
+ if (skb_src) {
pra_list->total_pkts_size -= skb_src->len;
+ pra_list->total_pkts--;
+ }

atomic_dec(&priv->wmm.tx_pkts_queued);

@@ -258,6 +260,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
skb_queue_tail(&pra_list->skb_head, skb_aggr);

pra_list->total_pkts_size += skb_aggr->len;
+ pra_list->total_pkts++;

atomic_inc(&priv->wmm.tx_pkts_queued);

diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 89f9870..57b183a 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -181,6 +181,7 @@ struct mwifiex_ra_list_tbl {
struct sk_buff_head skb_head;
u8 ra[ETH_ALEN];
u32 total_pkts_size;
+ u32 total_pkts;
u32 is_11n_enabled;
};

diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index 91634da..67b2d0b 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -121,6 +121,7 @@ mwifiex_wmm_allocate_ralist_node(struct mwifiex_adapter *adapter, u8 *ra)
memcpy(ra_list->ra, ra, ETH_ALEN);

ra_list->total_pkts_size = 0;
+ ra_list->total_pkts = 0;

dev_dbg(adapter->dev, "info: allocated ra_list %p\n", ra_list);

@@ -645,6 +646,7 @@ mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter,
skb_queue_tail(&ra_list->skb_head, skb);

ra_list->total_pkts_size += skb->len;
+ ra_list->total_pkts++;

atomic_inc(&priv->wmm.tx_pkts_queued);

@@ -971,28 +973,6 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,
}

/*
- * This function gets the number of packets in the Tx queue of a
- * particular RA list.
- */
-static int
-mwifiex_num_pkts_in_txq(struct mwifiex_private *priv,
- struct mwifiex_ra_list_tbl *ptr, int max_buf_size)
-{
- int count = 0, total_size = 0;
- struct sk_buff *skb, *tmp;
-
- skb_queue_walk_safe(&ptr->skb_head, skb, tmp) {
- total_size += skb->len;
- if (total_size < max_buf_size)
- ++count;
- else
- break;
- }
-
- return count;
-}
-
-/*
* This function sends a single packet to firmware for transmission.
*/
static void
@@ -1019,6 +999,7 @@ mwifiex_send_single_packet(struct mwifiex_private *priv,
dev_dbg(adapter->dev, "data: dequeuing the packet %p %p\n", ptr, skb);

ptr->total_pkts_size -= skb->len;
+ ptr->total_pkts--;

if (!skb_queue_empty(&ptr->skb_head))
skb_next = skb_peek(&ptr->skb_head);
@@ -1044,6 +1025,7 @@ mwifiex_send_single_packet(struct mwifiex_private *priv,
skb_queue_tail(&ptr->skb_head, skb);

ptr->total_pkts_size += skb->len;
+ ptr->total_pkts++;
tx_info->flags |= MWIFIEX_BUF_FLAG_REQUEUED_PKT;
spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock,
ra_list_flags);
@@ -1231,9 +1213,9 @@ mwifiex_dequeue_tx_packet(struct mwifiex_adapter *adapter)
}
/* Minimum number of AMSDU */
#define MIN_NUM_AMSDU 2
+
if (mwifiex_is_amsdu_allowed(priv, tid) &&
- (mwifiex_num_pkts_in_txq(priv, ptr, adapter->tx_buf_size) >=
- MIN_NUM_AMSDU))
+ (ptr->total_pkts >= MIN_NUM_AMSDU))
mwifiex_11n_aggregate_pkt(priv, ptr, INTF_HEADER_LEN,
ptr_index, flags);
/* ra_list_spinlock has been freed in
--
1.7.3.5