aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/tx.c
diff options
context:
space:
mode:
authorIdo Yariv <ido@wizery.com>2011-03-31 04:06:58 -0400
committerLuciano Coelho <coelho@ti.com>2011-04-19 09:49:18 -0400
commit0da13da767cd568c1fe2a7b5b936e86e521b5ae7 (patch)
tree7c629a516bb90567e60041b4273d4dd92395d0e8 /drivers/net/wireless/wl12xx/tx.c
parentd29633b40e6afc6b4276a4e381bc532cc84be104 (diff)
wl12xx: Clean up the block size alignment code
Simplify and clean up the block size alignment code: 1. Set the block size according to the padding field type, as it cannot exceed the maximum value this field can hold. 2. Move the alignment code into a function instead of duplicating it in multiple places. 3. In the current implementation, the block_size member can be misleading because a zero value actually means that there's no need to align. Declare a block size alignment quirk instead. Signed-off-by: Ido Yariv <ido@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/tx.c')
-rw-r--r--drivers/net/wireless/wl12xx/tx.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c
index 7686bc1ff16a..ba69ba7051fa 100644
--- a/drivers/net/wireless/wl12xx/tx.c
+++ b/drivers/net/wireless/wl12xx/tx.c
@@ -149,6 +149,15 @@ u8 wl1271_tx_get_hlid(struct sk_buff *skb)
149 } 149 }
150} 150}
151 151
152static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl,
153 unsigned int packet_length)
154{
155 if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT)
156 return ALIGN(packet_length, WL12XX_BUS_BLOCK_SIZE);
157 else
158 return ALIGN(packet_length, WL1271_TX_ALIGN_TO);
159}
160
152static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, 161static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
153 u32 buf_offset, u8 hlid) 162 u32 buf_offset, u8 hlid)
154{ 163{
@@ -174,10 +183,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
174 183
175 /* approximate the number of blocks required for this packet 184 /* approximate the number of blocks required for this packet
176 in the firmware */ 185 in the firmware */
177 if (wl->block_size) 186 len = wl12xx_calc_packet_alignment(wl, total_len);
178 len = ALIGN(total_len, wl->block_size);
179 else
180 len = total_len;
181 187
182 total_blocks = (len + TX_HW_BLOCK_SIZE - 1) / TX_HW_BLOCK_SIZE + 188 total_blocks = (len + TX_HW_BLOCK_SIZE - 1) / TX_HW_BLOCK_SIZE +
183 spare_blocks; 189 spare_blocks;
@@ -291,9 +297,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
291 tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY; 297 tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY;
292 desc->reserved = 0; 298 desc->reserved = 0;
293 299
294 if (wl->block_size) { 300 aligned_len = wl12xx_calc_packet_alignment(wl, skb->len);
295 aligned_len = ALIGN(skb->len, wl->block_size);
296 301
302 if (wl->chip.id == CHIP_ID_1283_PG20) {
297 desc->wl128x_mem.extra_bytes = aligned_len - skb->len; 303 desc->wl128x_mem.extra_bytes = aligned_len - skb->len;
298 desc->length = cpu_to_le16(aligned_len >> 2); 304 desc->length = cpu_to_le16(aligned_len >> 2);
299 305
@@ -306,8 +312,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
306 } else { 312 } else {
307 int pad; 313 int pad;
308 314
309 /* align the length (and store in terms of words) */ 315 /* Store the aligned length in terms of words */
310 aligned_len = ALIGN(skb->len, WL1271_TX_ALIGN_TO);
311 desc->length = cpu_to_le16(aligned_len >> 2); 316 desc->length = cpu_to_le16(aligned_len >> 2);
312 317
313 /* calculate number of padding bytes */ 318 /* calculate number of padding bytes */
@@ -386,10 +391,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb,
386 * In special cases, we want to align to a specific block size 391 * In special cases, we want to align to a specific block size
387 * (eg. for wl128x with SDIO we align to 256). 392 * (eg. for wl128x with SDIO we align to 256).
388 */ 393 */
389 if (wl->block_size) 394 total_len = wl12xx_calc_packet_alignment(wl, skb->len);
390 total_len = ALIGN(skb->len, wl->block_size);
391 else
392 total_len = ALIGN(skb->len, WL1271_TX_ALIGN_TO);
393 395
394 memcpy(wl->aggr_buf + buf_offset, skb->data, skb->len); 396 memcpy(wl->aggr_buf + buf_offset, skb->data, skb->len);
395 memset(wl->aggr_buf + buf_offset + skb->len, 0, total_len - skb->len); 397 memset(wl->aggr_buf + buf_offset + skb->len, 0, total_len - skb->len);