aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00queue.c
diff options
context:
space:
mode:
authorGertjan van Wingerde <gwingerde@kpnplanet.nl>2008-06-06 16:54:12 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-14 12:17:57 -0400
commit239c249d06b0c68ae06b10d9d6ad1f8e7f39452b (patch)
tree6d59d08b738406c525f084d043b9dfd91e711fb1 /drivers/net/wireless/rt2x00/rt2x00queue.c
parentd56d453a1dd85aff08fe6965f395049725fdb04e (diff)
rt2x00: Centralize RX packet alignment handling in rt2x00lib.
When rt2x00pci will be switched over to dynamically mapped skb's instead of statically allocated DMA buffers, it no longer can handle alignment of RX packets in a copy step, and needs to implement the same scheme as rt2x00usb does. In order to make the patch on dynamically mapped skb's smaller, already centralize the alignment handling into rt2x00lib. This allows us to move more code in rt2x00lib, and thus remove code duplication between rt2x00usb and rt2x00pci. Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00queue.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 493066519ef3..2f3dd1d91a12 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -29,6 +29,45 @@
29#include "rt2x00.h" 29#include "rt2x00.h"
30#include "rt2x00lib.h" 30#include "rt2x00lib.h"
31 31
32struct sk_buff *rt2x00queue_alloc_rxskb(struct data_queue *queue)
33{
34 struct sk_buff *skb;
35 unsigned int frame_size;
36 unsigned int reserved_size;
37
38 /*
39 * The frame size includes descriptor size, because the
40 * hardware directly receive the frame into the skbuffer.
41 */
42 frame_size = queue->data_size + queue->desc_size;
43
44 /*
45 * For the allocation we should keep a few things in mind:
46 * 1) 4byte alignment of 802.11 payload
47 *
48 * For (1) we need at most 4 bytes to guarentee the correct
49 * alignment. We are going to optimize the fact that the chance
50 * that the 802.11 header_size % 4 == 2 is much bigger then
51 * anything else. However since we need to move the frame up
52 * to 3 bytes to the front, which means we need to preallocate
53 * 6 bytes.
54 */
55 reserved_size = 6;
56
57 /*
58 * Allocate skbuffer.
59 */
60 skb = dev_alloc_skb(frame_size + reserved_size);
61 if (!skb)
62 return NULL;
63
64 skb_reserve(skb, reserved_size);
65 skb_put(skb, frame_size);
66
67 return skb;
68}
69EXPORT_SYMBOL_GPL(rt2x00queue_alloc_rxskb);
70
32void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, 71void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
33 struct txentry_desc *txdesc) 72 struct txentry_desc *txdesc)
34{ 73{