diff options
author | Avinash Patil <patila@marvell.com> | 2015-02-13 07:11:08 -0500 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2015-02-27 03:12:44 -0500 |
commit | 31def91b3a192bd414d87b3a408de34eed94d616 (patch) | |
tree | 16c8b41024c1a91138ada14cc577c3627037c61e /drivers/net/wireless/mwifiex | |
parent | 1c4c24eb7e96b3f8aeb9a2b7937ed7bb33aadd69 (diff) |
mwifiex: DMA alignment for RX packets
This patch adds support for DMA alignment of sk_buffs
allocated for RX.
Patch also adds support to modify skb allocation flags.
Signed-off-by: Marc Yang <yangyang@marvell.com>
Signed-off-by: Qingshui Gao <gaoqs@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r-- | drivers/net/wireless/mwifiex/decl.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/main.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/pcie.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/sdio.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/util.c | 23 |
5 files changed, 35 insertions, 4 deletions
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h index 88d0eade6bb1..cf2fa110e251 100644 --- a/drivers/net/wireless/mwifiex/decl.h +++ b/drivers/net/wireless/mwifiex/decl.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #define MWIFIEX_MAX_BSS_NUM (3) | 33 | #define MWIFIEX_MAX_BSS_NUM (3) |
34 | 34 | ||
35 | #define MWIFIEX_DMA_ALIGN_SZ 64 | 35 | #define MWIFIEX_DMA_ALIGN_SZ 64 |
36 | #define MWIFIEX_RX_HEADROOM 64 | ||
36 | #define MAX_TXPD_SZ 32 | 37 | #define MAX_TXPD_SZ 32 |
37 | #define INTF_HDR_ALIGN 4 | 38 | #define INTF_HDR_ALIGN 4 |
38 | 39 | ||
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 2089a3084043..16be45e9a66a 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h | |||
@@ -140,6 +140,9 @@ enum { | |||
140 | 140 | ||
141 | #define MWIFIEX_DRV_INFO_SIZE_MAX 0x40000 | 141 | #define MWIFIEX_DRV_INFO_SIZE_MAX 0x40000 |
142 | 142 | ||
143 | /* Address alignment */ | ||
144 | #define MWIFIEX_ALIGN_ADDR(p, a) (((long)(p) + (a) - 1) & ~((a) - 1)) | ||
145 | |||
143 | struct mwifiex_dbg { | 146 | struct mwifiex_dbg { |
144 | u32 num_cmd_host_to_card_failure; | 147 | u32 num_cmd_host_to_card_failure; |
145 | u32 num_cmd_sleep_cfm_host_to_card_failure; | 148 | u32 num_cmd_sleep_cfm_host_to_card_failure; |
@@ -1418,6 +1421,7 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv, | |||
1418 | u8 rx_rate, u8 ht_info); | 1421 | u8 rx_rate, u8 ht_info); |
1419 | 1422 | ||
1420 | void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter); | 1423 | void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter); |
1424 | void *mwifiex_alloc_rx_buf(int rx_len, gfp_t flags); | ||
1421 | 1425 | ||
1422 | #ifdef CONFIG_DEBUG_FS | 1426 | #ifdef CONFIG_DEBUG_FS |
1423 | void mwifiex_debugfs_init(void); | 1427 | void mwifiex_debugfs_init(void); |
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 0640bd67077c..4b463c3b9906 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c | |||
@@ -498,7 +498,8 @@ static int mwifiex_init_rxq_ring(struct mwifiex_adapter *adapter) | |||
498 | 498 | ||
499 | for (i = 0; i < MWIFIEX_MAX_TXRX_BD; i++) { | 499 | for (i = 0; i < MWIFIEX_MAX_TXRX_BD; i++) { |
500 | /* Allocate skb here so that firmware can DMA data from it */ | 500 | /* Allocate skb here so that firmware can DMA data from it */ |
501 | skb = dev_alloc_skb(MWIFIEX_RX_DATA_BUF_SIZE); | 501 | skb = mwifiex_alloc_rx_buf(MWIFIEX_RX_DATA_BUF_SIZE, |
502 | GFP_KERNEL | GFP_DMA); | ||
502 | if (!skb) { | 503 | if (!skb) { |
503 | dev_err(adapter->dev, | 504 | dev_err(adapter->dev, |
504 | "Unable to allocate skb for RX ring.\n"); | 505 | "Unable to allocate skb for RX ring.\n"); |
@@ -1297,7 +1298,8 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) | |||
1297 | } | 1298 | } |
1298 | } | 1299 | } |
1299 | 1300 | ||
1300 | skb_tmp = dev_alloc_skb(MWIFIEX_RX_DATA_BUF_SIZE); | 1301 | skb_tmp = mwifiex_alloc_rx_buf(MWIFIEX_RX_DATA_BUF_SIZE, |
1302 | GFP_KERNEL | GFP_DMA); | ||
1301 | if (!skb_tmp) { | 1303 | if (!skb_tmp) { |
1302 | dev_err(adapter->dev, | 1304 | dev_err(adapter->dev, |
1303 | "Unable to allocate skb.\n"); | 1305 | "Unable to allocate skb.\n"); |
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 78a9e863a934..57d85ab442bf 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c | |||
@@ -1357,7 +1357,7 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) | |||
1357 | return -1; | 1357 | return -1; |
1358 | rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE); | 1358 | rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE); |
1359 | 1359 | ||
1360 | skb = dev_alloc_skb(rx_len); | 1360 | skb = mwifiex_alloc_rx_buf(rx_len, GFP_KERNEL | GFP_DMA); |
1361 | if (!skb) | 1361 | if (!skb) |
1362 | return -1; | 1362 | return -1; |
1363 | 1363 | ||
@@ -1454,7 +1454,8 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) | |||
1454 | } | 1454 | } |
1455 | rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE); | 1455 | rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE); |
1456 | 1456 | ||
1457 | skb = dev_alloc_skb(rx_len); | 1457 | skb = mwifiex_alloc_rx_buf(rx_len, |
1458 | GFP_KERNEL | GFP_DMA); | ||
1458 | 1459 | ||
1459 | if (!skb) { | 1460 | if (!skb) { |
1460 | dev_err(adapter->dev, "%s: failed to alloc skb", | 1461 | dev_err(adapter->dev, "%s: failed to alloc skb", |
diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c index 47e215b6d5f5..2148a573396b 100644 --- a/drivers/net/wireless/mwifiex/util.c +++ b/drivers/net/wireless/mwifiex/util.c | |||
@@ -631,3 +631,26 @@ void mwifiex_hist_data_reset(struct mwifiex_private *priv) | |||
631 | for (ix = 0; ix < MWIFIEX_MAX_SIG_STRENGTH; ix++) | 631 | for (ix = 0; ix < MWIFIEX_MAX_SIG_STRENGTH; ix++) |
632 | atomic_set(&phist_data->sig_str[ix], 0); | 632 | atomic_set(&phist_data->sig_str[ix], 0); |
633 | } | 633 | } |
634 | |||
635 | void *mwifiex_alloc_rx_buf(int rx_len, gfp_t flags) | ||
636 | { | ||
637 | struct sk_buff *skb; | ||
638 | int buf_len, pad; | ||
639 | |||
640 | buf_len = rx_len + MWIFIEX_RX_HEADROOM + MWIFIEX_DMA_ALIGN_SZ; | ||
641 | |||
642 | skb = __dev_alloc_skb(buf_len, flags); | ||
643 | |||
644 | if (!skb) | ||
645 | return NULL; | ||
646 | |||
647 | skb_reserve(skb, MWIFIEX_RX_HEADROOM); | ||
648 | |||
649 | pad = MWIFIEX_ALIGN_ADDR(skb->data, MWIFIEX_DMA_ALIGN_SZ) - | ||
650 | (long)skb->data; | ||
651 | |||
652 | skb_reserve(skb, pad); | ||
653 | |||
654 | return skb; | ||
655 | } | ||
656 | EXPORT_SYMBOL_GPL(mwifiex_alloc_rx_buf); | ||