aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex
diff options
context:
space:
mode:
authorYogesh Ashok Powar <yogeshp@marvell.com>2011-07-07 20:37:09 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-07-08 11:47:16 -0400
commite156103cee78a1dd1c0d14efe08aa36fc9285013 (patch)
tree5b45b7448b5ffb0043a27dee8e34902e8a7ad002 /drivers/net/wireless/mwifiex
parent38869d79e5b498bd35c9967231dfb01cdd301bf5 (diff)
mwifiex: 4-byte alignment in mwifiex_process_sta_txpd()
In XMIT path, the skb that we get from the kernel itself is not aligned with 4-byte boundary on some embedded platforms. Had it not been the presence of tx_pkt_offset field in txpd, 4 byte memory alignment was not possible without memmove of entire skb. And that would have increased MIPS instead of reducing. With this patch few memory cycles can be saved while fetching interface header and txpd structure because of 4 bytes memory alignment. Reported-by: Philip Rakity <prakity@marvell.com> Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com> Tested-by: Philip Rakity <prakity@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r--drivers/net/wireless/mwifiex/decl.h4
-rw-r--r--drivers/net/wireless/mwifiex/sta_tx.c13
2 files changed, 12 insertions, 5 deletions
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h
index 0e90b0986ed8..94ddc9038cb3 100644
--- a/drivers/net/wireless/mwifiex/decl.h
+++ b/drivers/net/wireless/mwifiex/decl.h
@@ -30,7 +30,9 @@
30 30
31#define MWIFIEX_MAX_BSS_NUM (1) 31#define MWIFIEX_MAX_BSS_NUM (1)
32 32
33#define MWIFIEX_MIN_DATA_HEADER_LEN 32 /* (sizeof(mwifiex_txpd)) */ 33#define MWIFIEX_MIN_DATA_HEADER_LEN 36 /* sizeof(mwifiex_txpd)
34 * + 4 byte alignment
35 */
34 36
35#define MWIFIEX_MAX_TX_BASTREAM_SUPPORTED 2 37#define MWIFIEX_MAX_TX_BASTREAM_SUPPORTED 2
36#define MWIFIEX_MAX_RX_BASTREAM_SUPPORTED 16 38#define MWIFIEX_MAX_RX_BASTREAM_SUPPORTED 16
diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c
index fa6221bc9104..1822bfad8896 100644
--- a/drivers/net/wireless/mwifiex/sta_tx.c
+++ b/drivers/net/wireless/mwifiex/sta_tx.c
@@ -47,6 +47,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
47 struct mwifiex_adapter *adapter = priv->adapter; 47 struct mwifiex_adapter *adapter = priv->adapter;
48 struct txpd *local_tx_pd; 48 struct txpd *local_tx_pd;
49 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb); 49 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb);
50 u8 pad;
50 51
51 if (!skb->len) { 52 if (!skb->len) {
52 dev_err(adapter->dev, "Tx: bad packet length: %d\n", 53 dev_err(adapter->dev, "Tx: bad packet length: %d\n",
@@ -55,15 +56,19 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
55 return skb->data; 56 return skb->data;
56 } 57 }
57 58
58 BUG_ON(skb_headroom(skb) < (sizeof(*local_tx_pd) + INTF_HEADER_LEN)); 59 /* If skb->data is not aligned; add padding */
59 skb_push(skb, sizeof(*local_tx_pd)); 60 pad = (4 - (((void *)skb->data - NULL) & 0x3)) % 4;
61
62 BUG_ON(skb_headroom(skb) < (sizeof(*local_tx_pd) + INTF_HEADER_LEN
63 + pad));
64 skb_push(skb, sizeof(*local_tx_pd) + pad);
60 65
61 local_tx_pd = (struct txpd *) skb->data; 66 local_tx_pd = (struct txpd *) skb->data;
62 memset(local_tx_pd, 0, sizeof(struct txpd)); 67 memset(local_tx_pd, 0, sizeof(struct txpd));
63 local_tx_pd->bss_num = priv->bss_num; 68 local_tx_pd->bss_num = priv->bss_num;
64 local_tx_pd->bss_type = priv->bss_type; 69 local_tx_pd->bss_type = priv->bss_type;
65 local_tx_pd->tx_pkt_length = cpu_to_le16((u16) (skb->len - 70 local_tx_pd->tx_pkt_length = cpu_to_le16((u16) (skb->len -
66 sizeof(struct txpd))); 71 (sizeof(struct txpd) + pad)));
67 72
68 local_tx_pd->priority = (u8) skb->priority; 73 local_tx_pd->priority = (u8) skb->priority;
69 local_tx_pd->pkt_delay_2ms = 74 local_tx_pd->pkt_delay_2ms =
@@ -88,7 +93,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
88 } 93 }
89 94
90 /* Offset of actual data */ 95 /* Offset of actual data */
91 local_tx_pd->tx_pkt_offset = cpu_to_le16(sizeof(struct txpd)); 96 local_tx_pd->tx_pkt_offset = cpu_to_le16(sizeof(struct txpd) + pad);
92 97
93 /* make space for INTF_HEADER_LEN */ 98 /* make space for INTF_HEADER_LEN */
94 skb_push(skb, INTF_HEADER_LEN); 99 skb_push(skb, INTF_HEADER_LEN);