rt2x00: Further fixes and cleanups.
v2 cover rt2x00: Further fixes and cleanups.
Another set of rt2x00 fixes and cleanups.
Most of the patches are working towards a nice cleanup in which rt2x00 starts properly reserving room in skbs for descriptors instead of fiddling with pointers.
Also one fix for rt61pci that no-one ever hit, whereby, for beacons, rt61pci wrote part of the tx descriptor out-of-bounds.
These patches can also be pulled from:
git://git.gwingerde.nl/rt2x00-next-2.6.git
v2:
- Handled Ivo's feedback.
- Added a new patch to the series (as part of Ivo's feedback handling) on moving declaration of rt2x00debug_dump_frame to rt2x00.h.
- Reordered the patches to have the small preparatory patches in the beginning of the series, and the real functional patches towards the end.
Gertjan van Wingerde (10):
rt2x00: Consistently name skb frame descriptor skbdesc.
rt2x00: In debugfs frame dumping allow the TX descriptor to be part of the skb.
rt2x00: Dump beacons under a different identifier than TX frames.
rt2x00: Move rt2x00debug_dump_frame declaration to rt2x00.h.
rt2x00: Fix beacon descriptor writing for rt61pci.
rt2x00: Re-order tx descriptor writing code in drivers.
rt2x00: Simplify TXD handling of beacons.
rt2x00: Push beacon TX descriptor writing to drivers.
rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
rt2x00: Properly reserve room for descriptors in skbs.
drivers/net/wireless/rt2x00/rt2400pci.c | 41 ++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 41 ++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 67 ++++++++++++++--------- drivers/net/wireless/rt2x00/rt2800lib.c | 3 +- drivers/net/wireless/rt2x00/rt2800lib.h | 2 +- drivers/net/wireless/rt2x00/rt2800pci.c | 58 +++++++++++++------- drivers/net/wireless/rt2x00/rt2800usb.c | 34 ++++++++++-- drivers/net/wireless/rt2x00/rt2x00.h | 9 +++ drivers/net/wireless/rt2x00/rt2x00debug.c | 23 +++++--- drivers/net/wireless/rt2x00/rt2x00debug.h | 34 ++++++++++++ drivers/net/wireless/rt2x00/rt2x00dev.c | 5 -- drivers/net/wireless/rt2x00/rt2x00dump.h | 3 + drivers/net/wireless/rt2x00/rt2x00lib.h | 40 -------------- drivers/net/wireless/rt2x00/rt2x00pci.c | 49 +++++++++++++++-- drivers/net/wireless/rt2x00/rt2x00pci.h | 8 +++ drivers/net/wireless/rt2x00/rt2x00queue.c | 39 +------------- drivers/net/wireless/rt2x00/rt2x00queue.h | 3 + drivers/net/wireless/rt2x00/rt2x00usb.c | 19 +++---- drivers/net/wireless/rt2x00/rt61pci.c | 49 ++++++++++++----- drivers/net/wireless/rt2x00/rt73usb.c | 83 +++++++++++++++++------------ 20 files changed, 365 insertions(+), 245 deletions(-)
PATCH v2 1/10 rt2x00: Consistently name skb frame descriptor skbdesc.
The skb frame descriptor is called everywhere skbdesc, except in one place in rt2x00debug_dump_frame. Change that occurence to have consistent naming.
--- drivers/net/wireless/rt2x00/rt2x00debug.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/wireless/rt2x00/rt2x00debug.c +7 -6
@@ -155,7 +155,7 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, enum rt2x00_dump_type type, struct sk_buff *skb) { struct rt2x00debug_intf *intf = rt2x00dev->debugfs_intf; -struct skb_frame_desc *desc =get_skb_frame_desc (skb); +struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb);struct sk_buff *skbcopy;struct rt2x00dump_hdr *dump_hdr;struct timeval timestamp;
@@ -170,7 +170,7 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,return ; } - skbcopy =alloc_skb (sizeof (*dump_hdr) + desc->desc_len + skb->len, + skbcopy =alloc_skb (sizeof (*dump_hdr) + skbdesc->desc_len + skb->len,GFP_ATOMIC );if (!skbcopy) {DEBUG (rt2x00dev,"Failed to copy skb for dump.\n" );
@@ -180,18 +180,19 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, dump_hdr = (struct rt2x00dump_hdr *)skb_put (skbcopy,sizeof (*dump_hdr)); dump_hdr->version =cpu_to_le32 (DUMP_HEADER_VERSION ); dump_hdr->header_length =cpu_to_le32 (sizeof (*dump_hdr)); - dump_hdr->desc_length =cpu_to_le32 (desc->desc_len); + dump_hdr->desc_length =cpu_to_le32 (skbdesc->desc_len); dump_hdr->data_length =cpu_to_le32 (skb->len); dump_hdr->chip_rt =cpu_to_le16 (rt2x00dev->chip.rt); dump_hdr->chip_rf =cpu_to_le16 (rt2x00dev->chip.rf); dump_hdr->chip_rev =cpu_to_le16 (rt2x00dev->chip.rev); dump_hdr->type =cpu_to_le16 (type); - dump_hdr->queue_index = desc->entry->queue->qid; - dump_hdr->entry_index = desc->entry->entry_idx; + dump_hdr->queue_index = skbdesc->entry->queue->qid; + dump_hdr->entry_index = skbdesc->entry->entry_idx; dump_hdr->timestamp_sec =cpu_to_le32 (timestamp.tv_sec); dump_hdr->timestamp_usec =cpu_to_le32 (timestamp.tv_usec); -memcpy (skb_put (skbcopy, desc->desc_len), desc->desc, desc->desc_len); +memcpy (skb_put (skbcopy, skbdesc->desc_len), skbdesc->desc, + skbdesc->desc_len);memcpy (skb_put (skbcopy, skb->len), skb->data, skb->len);skb_queue_tail (&intf->frame_dump_skbqueue, skbcopy);
Signature · 1 line
1.7.1
PATCH v2 2/10 rt2x00: In debugfs frame dumping allow the TX descriptor to be part of the skb.
In reply to Gertjan van WingerdePreparation for futher cleanups in the area of properly maintaining the skb data without fiddling with the skb->data pointer.
--- drivers/net/wireless/rt2x00/rt2x00debug.c | 14 ++++++++++---- drivers/net/wireless/rt2x00/rt2x00queue.h | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/net/wireless/rt2x00/rt2x00debug.c +10 -4
@@ -159,6 +159,7 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,struct sk_buff *skbcopy;struct rt2x00dump_hdr *dump_hdr;struct timeval timestamp; +u32 data_len;do_gettimeofday (×tamp);
@@ -170,7 +171,11 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,return ; } - skbcopy =alloc_skb (sizeof (*dump_hdr) + skbdesc->desc_len + skb->len, + data_len = skb->len; +if (skbdesc->flags &SKBDESC_DESC_IN_SKB ) + data_len -= skbdesc->desc_len; + + skbcopy =alloc_skb (sizeof (*dump_hdr) + skbdesc->desc_len + data_len,GFP_ATOMIC );if (!skbcopy) {DEBUG (rt2x00dev,"Failed to copy skb for dump.\n" );
@@ -181,7 +186,7 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, dump_hdr->version =cpu_to_le32 (DUMP_HEADER_VERSION ); dump_hdr->header_length =cpu_to_le32 (sizeof (*dump_hdr)); dump_hdr->desc_length =cpu_to_le32 (skbdesc->desc_len); - dump_hdr->data_length =cpu_to_le32 (skb->len); + dump_hdr->data_length =cpu_to_le32 (data_len); dump_hdr->chip_rt =cpu_to_le16 (rt2x00dev->chip.rt); dump_hdr->chip_rf =cpu_to_le16 (rt2x00dev->chip.rf); dump_hdr->chip_rev =cpu_to_le16 (rt2x00dev->chip.rev);
@@ -191,8 +196,9 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, dump_hdr->timestamp_sec =cpu_to_le32 (timestamp.tv_sec); dump_hdr->timestamp_usec =cpu_to_le32 (timestamp.tv_usec); -memcpy (skb_put (skbcopy, skbdesc->desc_len), skbdesc->desc, - skbdesc->desc_len); +if (!(skbdesc->flags &SKBDESC_DESC_IN_SKB )) +memcpy (skb_put (skbcopy, skbdesc->desc_len), skbdesc->desc, + skbdesc->desc_len);memcpy (skb_put (skbcopy, skb->len), skb->data, skb->len);skb_queue_tail (&intf->frame_dump_skbqueue, skbcopy);
drivers/net/wireless/rt2x00/rt2x00queue.h +3 -0
@@ -94,12 +94,15 @@ enum data_queue_qid {* mac80211 but was stripped for processing by the driver. * @SKBDESC_NOT_MAC80211: Frame didn't originate from mac80211, * don't try to pass it back. +* @SKBDESC_DESC_IN_SKB: The descriptor is at the start of the +* skb, instead of in the desc field. */ enum skb_frame_desc_flags {SKBDESC_DMA_MAPPED_RX =1 <<0 ,SKBDESC_DMA_MAPPED_TX =1 <<1 ,SKBDESC_IV_STRIPPED =1 <<2 ,SKBDESC_NOT_MAC80211 =1 <<3 , +SKBDESC_DESC_IN_SKB =1 <<4 , };/**
Signature · 1 line
1.7.1
PATCH v2 3/10 rt2x00: Dump beacons under a different identifier than TX frames.
In reply to Gertjan van WingerdeThis allows for specific identification of beacons in the debugfs frame stream.
Preparation for later differences between dumped TX frames and dumped beacons.
--- drivers/net/wireless/rt2x00/rt2x00dump.h | 3 +++ drivers/net/wireless/rt2x00/rt2x00queue.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dump.h +3 -0
@@ -62,11 +62,14 @@* the tx event which has either succeeded or failed. A frame * with this type should also have been reported with as a * %DUMP_FRAME_TX frame. +* @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the +* hardware. */ enum rt2x00_dump_type {DUMP_FRAME_RXDONE =1 ,DUMP_FRAME_TX =2 ,DUMP_FRAME_TXDONE =3 , +DUMP_FRAME_BEACON =4 , };/**
drivers/net/wireless/rt2x00/rt2x00queue.c +4 -1
@@ -420,6 +420,7 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, {struct data_queue *queue = entry->queue;struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; +enum rt2x00_dump_type dump_type; rt2x00dev->ops->lib->write_tx_desc (rt2x00dev, entry->skb, txdesc);
@@ -427,7 +428,9 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,* All processing on the frame has been completed, this means * it is now ready to be dumped to userspace through debugfs. */ -rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_TX , entry->skb); + dump_type = (txdesc->queue ==QID_BEACON ) ? +DUMP_FRAME_BEACON :DUMP_FRAME_TX ; +rt2x00debug_dump_frame (rt2x00dev, dump_type, entry->skb); } static void rt2x00queue_kick_tx_queue(struct queue_entry *entry,
Signature · 1 line
1.7.1
PATCH v2 4/10 rt2x00: Move rt2x00debug_dump_frame declaration to rt2x00.h.
In reply to Gertjan van WingerdeThis allows rt2x00debug_dump_frame to be used from everywhere.
This is preparation for beacon writing clean ups.
--- drivers/net/wireless/rt2x00/rt2x00.h | 35 +++++++++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00debug.c | 1 + drivers/net/wireless/rt2x00/rt2x00dump.h | 20 ---------------- drivers/net/wireless/rt2x00/rt2x00lib.h | 10 -------- 4 files changed, 36 insertions(+), 30 deletions(-)
drivers/net/wireless/rt2x00/rt2x00.h +35 -0
@@ -1015,6 +1015,41 @@ struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, enum queue_index index);/* +* Debugfs handlers. +*/ +/** +* enum rt2x00_dump_type - Frame type +* +* These values are used for the indicate the type of frame that is being +* dumped: +* @DUMP_FRAME_RXDONE: This frame has been received by the hardware. +* @DUMP_FRAME_TX: This frame is queued for transmission to the hardware. +* @DUMP_FRAME_TXDONE: This frame indicates the device has handled +* the tx event which has either succeeded or failed. A frame +* with this type should also have been reported with as a +* %DUMP_FRAME_TX frame. +* @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the +* hardware. +*/ +enum rt2x00_dump_type { +DUMP_FRAME_RXDONE =1 , +DUMP_FRAME_TX =2 , +DUMP_FRAME_TXDONE =3 , +DUMP_FRAME_BEACON =4 , +}; + +#ifdef CONFIG_RT2X00_LIB_DEBUGFS +void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, +enum rt2x00_dump_type type,struct sk_buff *skb); +#else +static inline void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, +enum rt2x00_dump_type type, +struct sk_buff *skb) +{ +} +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ + +/* * Interrupt context handlers. */ void rt2x00lib_beacondone (struct rt2x00_dev *rt2x00dev);
drivers/net/wireless/rt2x00/rt2x00debug.c +1 -0
@@ -210,6 +210,7 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,if (!test_bit (FRAME_DUMP_FILE_OPEN , &intf->frame_dump_flags))skb_queue_purge (&intf->frame_dump_skbqueue); } +EXPORT_SYMBOL_GPL (rt2x00debug_dump_frame);static int rt2x00debug_file_open (struct inode *inode,struct file *file) {
drivers/net/wireless/rt2x00/rt2x00dump.h +0 -20
@@ -53,26 +53,6 @@*/ /** -* enum rt2x00_dump_type - Frame type -* -* These values are used for the @type member of &rt2x00dump_hdr. -* @DUMP_FRAME_RXDONE: This frame has been received by the hardware. -* @DUMP_FRAME_TX: This frame is queued for transmission to the hardware. -* @DUMP_FRAME_TXDONE: This frame indicates the device has handled -* the tx event which has either succeeded or failed. A frame -* with this type should also have been reported with as a -* %DUMP_FRAME_TX frame. -* @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the -* hardware. -*/ -enum rt2x00_dump_type { -DUMP_FRAME_RXDONE =1 , -DUMP_FRAME_TX =2 , -DUMP_FRAME_TXDONE =3 , -DUMP_FRAME_BEACON =4 , -}; - -/** * struct rt2x00dump_hdr - Dump frame header * * Each frame dumped to the debugfs file starts with this header
drivers/net/wireless/rt2x00/rt2x00lib.h +0 -10
@@ -27,8 +27,6 @@#ifndef RT2X00LIB_H #define RT2X00LIB_H -#include "rt2x00dump.h" -/* * Interval defines */
@@ -296,8 +294,6 @@ static inline void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)#ifdef CONFIG_RT2X00_LIB_DEBUGFS void rt2x00debug_register (struct rt2x00_dev *rt2x00dev);void rt2x00debug_deregister (struct rt2x00_dev *rt2x00dev); -void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, -enum rt2x00_dump_type type,struct sk_buff *skb);void rt2x00debug_update_crypto (struct rt2x00_dev *rt2x00dev,struct rxdone_entry_desc *rxdesc);#else
@@ -309,12 +305,6 @@ static inline void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev) { } -static inline void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, -enum rt2x00_dump_type type, -struct sk_buff *skb) -{ -} -static inline void rt2x00debug_update_crypto (struct rt2x00_dev *rt2x00dev,struct rxdone_entry_desc *rxdesc) {
Signature · 1 line
1.7.1
Re: [PATCH v2 04/10] rt2x00: Move rt2x00debug_dump_frame declaration to rt2x00.h.
Quoted 32 lines · Gertjan van Wingerde
This allows
rt2x00debug_dump_frameto be used from everywhere.This is preparation for beacon writing clean ups.
Signed-off-by Gertjan van Wingerde <[email protected]>---
drivers/net/wireless/rt2x00/rt2x00.h | 35 +++++++++++++++++++++++++++++drivers/net/wireless/rt2x00/rt2x00debug.c| 1 +drivers/net/wireless/rt2x00/rt2x00dump.h| 20 ----------------drivers/net/wireless/rt2x00/rt2x00lib.h| 10 --------4 files changed, 36 insertions(+), 30 deletions(-)drivers/net/wireless/rt2x00/rt2x00.h +12
-0@@ -1015,6 +1015,41 @@ struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, enum queue_index index); /* +* Debugfs handlers. +*/ +/** +* enum rt2x00_dump_type - Frame type +* +* These values are used for the indicate the type of frame that is being +* dumped: +* @DUMP_FRAME_RXDONE: This frame has been received by the hardware. +* @DUMP_FRAME_TX: This frame is queued for transmission to the hardware. +* @DUMP_FRAME_TXDONE: This frame indicates the device has handled +* the tx event which has either succeeded or failed. A frame +* with this type should also have been reported with as a
drivers/net/wireless/rt2x00/rt2x00.h struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, · line 1039
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2x00.h +10
-0+* %DUMP_FRAME_TX frame. +* @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the +* hardware. +*/ +enum rt2x00_dump_type { + DUMP_FRAME_RXDONE = 1, + DUMP_FRAME_TX = 2, + DUMP_FRAME_TXDONE = 3, + DUMP_FRAME_BEACON = 4, +};
Can't this stay in rt2x00dump.h? The rt2x00dump.h is part of the public interface towards
userspace which can use these defined to determine the frame type. We can safely include this header in rt2x00.h since it contains the public interface anyway.
drivers/net/wireless/rt2x00/rt2x00.h struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, · line 1050
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2x00.h +10
-0+#ifdef CONFIG_RT2X00_LIB_DEBUGFS +void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, + enum rt2x00_dump_type type, struct sk_buff *skb); +#else +static inline void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, + enum rt2x00_dump_type type, + struct sk_buff *skb) +{ +} +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
Could you add some documentation to this function?
Thanks,
Ivo
Re: [PATCH v2 04/10] rt2x00: Move rt2x00debug_dump_frame declaration to rt2x00.h.
Quoted 42 lines · Ivo Van Doorn
Quoted 40 lines · Gertjan van Wingerde
This allows
rt2x00debug_dump_frameto be used from everywhere.This is preparation for beacon writing clean ups.
Signed-off-by Gertjan van Wingerde <[email protected]>--- drivers/net/wireless/rt2x00/rt2x00.h | 35 +++++++++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00debug.c | 1 + drivers/net/wireless/rt2x00/rt2x00dump.h | 20 ---------------- drivers/net/wireless/rt2x00/rt2x00lib.h | 10 -------- 4 files changed, 36 insertions(+), 30 deletions(-)drivers/net/wireless/rt2x00/rt2x00.h +20
-0@@ -1015,6 +1015,41 @@ struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, enum queue_index index);/* +* Debugfs handlers. +*/ +/** +* enum rt2x00_dump_type - Frame type +* +* These values are used for the indicate the type of frame that is being +* dumped: +* @DUMP_FRAME_RXDONE: This frame has been received by the hardware. +* @DUMP_FRAME_TX: This frame is queued for transmission to the hardware. +* @DUMP_FRAME_TXDONE: This frame indicates the device has handled +* the tx event which has either succeeded or failed. A frame +* with this type should also have been reported with as a +* %DUMP_FRAME_TX frame. +* @DUMP_FRAME_BEACON: This beacon frame is queued for transmission to the +* hardware. +*/ +enum rt2x00_dump_type { +DUMP_FRAME_RXDONE =1 , +DUMP_FRAME_TX =2 , +DUMP_FRAME_TXDONE =3 ,
Quoted 8 lines
drivers/net/wireless/rt2x00/rt2x00.h struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, · line 1039
Quoted 2 lines
drivers/net/wireless/rt2x00/rt2x00.h +2
-0+ DUMP_FRAME_BEACON = 4, +};Can't this stay in
rt2x00dump.h? Thert2x00dump.his part of the public interface towards
userspace which can use these defined to determine the frame type. We can safely include this header inrt2x00.hsince it contains the public interface anyway.
Hmpf, it looks like there is a lot of unspecified assumptions about the placement of information in files and for some functionality. We must get better in documenting this.
Although it is a bit strange to have a public interface to userspace defined this deep in the kernel source tree, I'll move it back and put a big fat comment is there that this actually is the public interface towards userspace and that all this information is to be kept together.
Quoted 14 lines
drivers/net/wireless/rt2x00/rt2x00.h struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, · line 1050
Quoted 11 lines
drivers/net/wireless/rt2x00/rt2x00.h +10
-0+#ifdef CONFIG_RT2X00_LIB_DEBUGFS +void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, +enum rt2x00_dump_type type,struct sk_buff *skb); +#else +static inline void rt2x00debug_dump_frame (struct rt2x00_dev *rt2x00dev, +enum rt2x00_dump_type type, +struct sk_buff *skb) +{ +} +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ Could you add some documentation to this function?
Off course I can; although that is a bit more than just moving declarations ;-)
---
Gertjan.
PATCH v2 5/10 rt2x00: Fix beacon descriptor writing for rt61pci.
In reply to Gertjan van WingerdeThe buffer address descriptor word is not part of the TXINFO structure needed for beacons. The current writing of that word for beacons is therefore an out-of-bounds write.
Fix this by only writing the buffer address descriptor word for TX queues.
--- drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/rt2x00/rt61pci.c +5 -5
@@ -1801,12 +1801,12 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_set_field32 (&word,TXD_W5_WAITING_DMA_DONE_INT ,1 );rt2x00_desc_write (txd,5 , word); -rt2x00_desc_read (txd,6 , &word); -rt2x00_set_field32 (&word,TXD_W6_BUFFER_PHYSICAL_ADDRESS , - skbdesc->skb_dma); -rt2x00_desc_write (txd,6 , word); +if (txdesc->queue !=QID_BEACON ) { +rt2x00_desc_read (txd,6 , &word); +rt2x00_set_field32 (&word,TXD_W6_BUFFER_PHYSICAL_ADDRESS , + skbdesc->skb_dma); +rt2x00_desc_write (txd,6 , word); -if (skbdesc->desc_len >TXINFO_SIZE ) {rt2x00_desc_read (txd,11 , &word);rt2x00_set_field32 (&word,TXD_W11_BUFFER_LENGTH0 , txdesc->length);
Signature · 1 line
1.7.1
PATCH v2 6/10 rt2x00: Re-order tx descriptor writing code in drivers.
In reply to Gertjan van WingerdeWhere possible, write the tx descriptor words from start to end, to follow a logical ordering of words.
Where this is not possible (in rt2400pci, rt2500pci and rt61pci) add a comment as to why word 0 needs to be written last.
--- drivers/net/wireless/rt2x00/rt2400pci.c | 5 +++ drivers/net/wireless/rt2x00/rt2500pci.c | 5 +++ drivers/net/wireless/rt2x00/rt2500usb.c | 36 +++++++++++----------- drivers/net/wireless/rt2x00/rt61pci.c | 5 +++ drivers/net/wireless/rt2x00/rt73usb.c | 52 +++++++++++++++--------------- 5 files changed, 59 insertions(+), 44 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +5 -0
@@ -1039,6 +1039,11 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_set_field32 (&word,TXD_W3_PLCP_LENGTH_HIGH_BUSY ,1 );rt2x00_desc_write (txd,4 , word); +/* +* Writing TXD word 0 must the last to prevent a race condition with +* the device, whereby the device may take hold of the TXD before we +* finished updating it. +*/ rt2x00_desc_read (txd,0 , &word);rt2x00_set_field32 (&word,TXD_W0_OWNER_NIC ,1 );rt2x00_set_field32 (&word,TXD_W0_VALID ,1 );
drivers/net/wireless/rt2x00/rt2500pci.c +5 -0
@@ -1193,6 +1193,11 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags));rt2x00_desc_write (txd,10 , word); +/* +* Writing TXD word 0 must the last to prevent a race condition with +* the device, whereby the device may take hold of the TXD before we +* finished updating it. +*/ rt2x00_desc_read (txd,0 , &word);rt2x00_set_field32 (&word,TXD_W0_OWNER_NIC ,1 );rt2x00_set_field32 (&word,TXD_W0_VALID ,1 );
drivers/net/wireless/rt2x00/rt2500usb.c +18 -18
@@ -1039,6 +1039,24 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,/* * Start writing the descriptor words. */ +rt2x00_desc_read (txd,0 , &word); +rt2x00_set_field32 (&word,TXD_W0_RETRY_LIMIT , txdesc->retry_limit); +rt2x00_set_field32 (&word,TXD_W0_MORE_FRAG , +test_bit (ENTRY_TXD_MORE_FRAG , &txdesc->flags)); +rt2x00_set_field32 (&word,TXD_W0_ACK , +test_bit (ENTRY_TXD_ACK , &txdesc->flags)); +rt2x00_set_field32 (&word,TXD_W0_TIMESTAMP , +test_bit (ENTRY_TXD_REQ_TIMESTAMP , &txdesc->flags)); +rt2x00_set_field32 (&word,TXD_W0_OFDM , + (txdesc->rate_mode ==RATE_MODE_OFDM )); +rt2x00_set_field32 (&word,TXD_W0_NEW_SEQ , +test_bit (ENTRY_TXD_FIRST_FRAGMENT , &txdesc->flags)); +rt2x00_set_field32 (&word,TXD_W0_IFS , txdesc->ifs); +rt2x00_set_field32 (&word,TXD_W0_DATABYTE_COUNT , txdesc->length); +rt2x00_set_field32 (&word,TXD_W0_CIPHER , !!txdesc->cipher); +rt2x00_set_field32 (&word,TXD_W0_KEY_ID , txdesc->key_idx); +rt2x00_desc_write (txd,0 , word); +rt2x00_desc_read (txd,1 , &word);rt2x00_set_field32 (&word,TXD_W1_IV_OFFSET , txdesc->iv_offset);rt2x00_set_field32 (&word,TXD_W1_AIFS , txdesc->aifs);
@@ -1057,24 +1075,6 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,_rt2x00_desc_write (txd,3 , skbdesc->iv[0 ]);_rt2x00_desc_write (txd,4 , skbdesc->iv[1 ]); } - -rt2x00_desc_read (txd,0 , &word); -rt2x00_set_field32 (&word,TXD_W0_RETRY_LIMIT , txdesc->retry_limit); -rt2x00_set_field32 (&word,TXD_W0_MORE_FRAG , -test_bit (ENTRY_TXD_MORE_FRAG , &txdesc->flags)); -rt2x00_set_field32 (&word,TXD_W0_ACK , -test_bit (ENTRY_TXD_ACK , &txdesc->flags)); -rt2x00_set_field32 (&word,TXD_W0_TIMESTAMP , -test_bit (ENTRY_TXD_REQ_TIMESTAMP , &txdesc->flags)); -rt2x00_set_field32 (&word,TXD_W0_OFDM , - (txdesc->rate_mode ==RATE_MODE_OFDM )); -rt2x00_set_field32 (&word,TXD_W0_NEW_SEQ , -test_bit (ENTRY_TXD_FIRST_FRAGMENT , &txdesc->flags)); -rt2x00_set_field32 (&word,TXD_W0_IFS , txdesc->ifs); -rt2x00_set_field32 (&word,TXD_W0_DATABYTE_COUNT , txdesc->length); -rt2x00_set_field32 (&word,TXD_W0_CIPHER , !!txdesc->cipher); -rt2x00_set_field32 (&word,TXD_W0_KEY_ID , txdesc->key_idx); -rt2x00_desc_write (txd,0 , word); }/*
drivers/net/wireless/rt2x00/rt61pci.c +5 -0
@@ -1813,6 +1813,11 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_desc_write (txd,11 , word); } +/* +* Writing TXD word 0 must the last to prevent a race condition with +* the device, whereby the device may take hold of the TXD before we +* finished updating it. +*/ rt2x00_desc_read (txd,0 , &word);rt2x00_set_field32 (&word,TXD_W0_OWNER_NIC ,1 );rt2x00_set_field32 (&word,TXD_W0_VALID ,1 );
drivers/net/wireless/rt2x00/rt73usb.c +26 -26
64 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 7/10 rt2x00: Simplify TXD handling of beacons.
In reply to Gertjan van WingerdeThe handling of tx descriptors for beacons can be simplified by updating write_tx_desc implementations of each driver to write directly to the queue entry descriptor instead of to a provided memory area. This is also a preparation for further clean ups where descriptors are properly reserved in the skb instead of fiddling with the skb data pointer.
--- drivers/net/wireless/rt2x00/rt2400pci.c | 21 +++++++++------------ drivers/net/wireless/rt2x00/rt2500pci.c | 21 +++++++++------------ drivers/net/wireless/rt2x00/rt2500usb.c | 21 ++++++++++++--------- drivers/net/wireless/rt2x00/rt2800pci.c | 14 ++++++++++---- drivers/net/wireless/rt2x00/rt2800usb.c | 8 +++++++- drivers/net/wireless/rt2x00/rt2x00pci.c | 9 --------- drivers/net/wireless/rt2x00/rt2x00queue.c | 10 ---------- drivers/net/wireless/rt2x00/rt2x00usb.c | 8 -------- drivers/net/wireless/rt2x00/rt61pci.c | 20 +++++++++++++------- drivers/net/wireless/rt2x00/rt73usb.c | 21 ++++++++++++--------- 10 files changed, 72 insertions(+), 81 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +9 -12
@@ -1006,15 +1006,15 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb);struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; -__le32 *txd = skbdesc->desc; +__le32 *txd = entry_priv->desc;u32 word;/* * Start writing the descriptor words. */ -rt2x00_desc_read (entry_priv->desc,1 , &word); +rt2x00_desc_read (txd,1 , &word);rt2x00_set_field32 (&word,TXD_W1_BUFFER_ADDRESS , skbdesc->skb_dma); -rt2x00_desc_write (entry_priv->desc,1 , word); +rt2x00_desc_write (txd,1 , word);rt2x00_desc_read (txd,2 , &word);rt2x00_set_field32 (&word,TXD_W2_BUFFER_LENGTH , txdesc->length);
@@ -1059,6 +1059,12 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_set_field32 (&word,TXD_W0_RETRY_MODE ,test_bit (ENTRY_TXD_RETRY_MODE , &txdesc->flags));rt2x00_desc_write (txd,0 , word); + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txd; + skbdesc->desc_len =TXD_DESC_SIZE ; }/*
@@ -1081,15 +1087,6 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,rt2x00_set_field32 (®,CSR14_BEACON_GEN ,0 );rt2x00pci_register_write (rt2x00dev,CSR14 , reg); -/* -* Replace rt2x00lib allocated descriptor with the -* pointer to the _real_ hardware descriptor. -* After that, map the beacon to DMA and update the -* descriptor. -*/ -memcpy (entry_priv->desc, skbdesc->desc, skbdesc->desc_len); - skbdesc->desc = entry_priv->desc; -rt2x00queue_map_txskb (rt2x00dev, entry->skb);rt2x00_desc_read (entry_priv->desc,1 , &word);
drivers/net/wireless/rt2x00/rt2500pci.c +9 -12
@@ -1164,15 +1164,15 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb);struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; -__le32 *txd = skbdesc->desc; +__le32 *txd = entry_priv->desc;u32 word;/* * Start writing the descriptor words. */ -rt2x00_desc_read (entry_priv->desc,1 , &word); +rt2x00_desc_read (txd,1 , &word);rt2x00_set_field32 (&word,TXD_W1_BUFFER_ADDRESS , skbdesc->skb_dma); -rt2x00_desc_write (entry_priv->desc,1 , word); +rt2x00_desc_write (txd,1 , word);rt2x00_desc_read (txd,2 , &word);rt2x00_set_field32 (&word,TXD_W2_IV_OFFSET ,IEEE80211_HEADER );
@@ -1216,6 +1216,12 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_set_field32 (&word,TXD_W0_DATABYTE_COUNT , txdesc->length);rt2x00_set_field32 (&word,TXD_W0_CIPHER_ALG ,CIPHER_NONE );rt2x00_desc_write (txd,0 , word); + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txd; + skbdesc->desc_len =TXD_DESC_SIZE ; }/*
@@ -1238,15 +1244,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,rt2x00_set_field32 (®,CSR14_BEACON_GEN ,0 );rt2x00pci_register_write (rt2x00dev,CSR14 , reg); -/* -* Replace rt2x00lib allocated descriptor with the -* pointer to the _real_ hardware descriptor. -* After that, map the beacon to DMA and update the -* descriptor. -*/ -memcpy (entry_priv->desc, skbdesc->desc, skbdesc->desc_len); - skbdesc->desc = entry_priv->desc; -rt2x00queue_map_txskb (rt2x00dev, entry->skb);rt2x00_desc_read (entry_priv->desc,1 , &word);
drivers/net/wireless/rt2x00/rt2500usb.c +12 -9
@@ -1033,7 +1033,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txd = skbdesc->desc; +__le32 *txd = (__le32 *)(skb->data -TXD_DESC_SIZE );u32 word;/*
@@ -1075,6 +1075,12 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,_rt2x00_desc_write (txd,3 , skbdesc->iv[0 ]);_rt2x00_desc_write (txd,4 , skbdesc->iv[1 ]); } + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txd; + skbdesc->desc_len =TXD_DESC_SIZE ; }/*
@@ -1088,19 +1094,11 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;struct usb_device *usb_dev =to_usb_device_intf (rt2x00dev->dev);struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data; -struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb);int pipe =usb_sndbulkpipe (usb_dev, entry->queue->usb_endpoint);int length;u16 reg, reg0;/* -* Add the descriptor in front of the skb. -*/ -skb_push (entry->skb, entry->queue->desc_size); -memcpy (entry->skb->data, skbdesc->desc, skbdesc->desc_len); - skbdesc->desc = entry->skb->data; - -/* * Disable beaconing while we are reloading the beacon data, * otherwise we might be sending out invalid data. */
@@ -1109,6 +1107,11 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,rt2500usb_register_write (rt2x00dev,TXRX_CSR19 , reg);/* +* Take the descriptor in front of the skb into account. +*/ +skb_push (entry->skb,TXD_DESC_SIZE ); + +/* * USB devices cannot blindly pass the skb->len as the * length of the data to usb_fill_bulk_urb. Pass the skb * to the driver to determine what the length should be.
drivers/net/wireless/rt2x00/rt2800pci.c +10 -4
@@ -633,7 +633,8 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txd = skbdesc->desc; +struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; +__le32 *txd = entry_priv->desc;u32 word;/*
@@ -657,15 +658,14 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));rt2x00_set_field32 (&word,TXD_W1_BURST ,test_bit (ENTRY_TXD_BURST , &txdesc->flags)); -rt2x00_set_field32 (&word,TXD_W1_SD_LEN0 , - rt2x00dev->ops->extra_tx_headroom); +rt2x00_set_field32 (&word,TXD_W1_SD_LEN0 ,TXWI_DESC_SIZE );rt2x00_set_field32 (&word,TXD_W1_LAST_SEC0 ,0 );rt2x00_set_field32 (&word,TXD_W1_DMA_DONE ,0 );rt2x00_desc_write (txd,1 , word);rt2x00_desc_read (txd,2 , &word);rt2x00_set_field32 (&word,TXD_W2_SD_PTR1 , - skbdesc->skb_dma + rt2x00dev->ops->extra_tx_headroom); + skbdesc->skb_dma +TXWI_DESC_SIZE );rt2x00_desc_write (txd,2 , word);rt2x00_desc_read (txd,3 , &word);
@@ -673,6 +673,12 @@ static void rt2800pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));rt2x00_set_field32 (&word,TXD_W3_QSEL ,2 );rt2x00_desc_write (txd,3 , word); + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txd; + skbdesc->desc_len =TXD_DESC_SIZE ; }/*
drivers/net/wireless/rt2x00/rt2800usb.c +7 -1
@@ -400,7 +400,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txi = skbdesc->desc; +__le32 *txi = (__le32 *)(skb->data -TXWI_DESC_SIZE -TXINFO_DESC_SIZE );u32 word;/*
@@ -422,6 +422,12 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_set_field32 (&word,TXINFO_W0_USB_DMA_TX_BURST ,test_bit (ENTRY_TXD_BURST , &txdesc->flags));rt2x00_desc_write (txi,0 , word); + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txi; + skbdesc->desc_len =TXINFO_DESC_SIZE +TXWI_DESC_SIZE ; }/*
drivers/net/wireless/rt2x00/rt2x00pci.c +0 -9
@@ -66,8 +66,6 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; -struct queue_entry_priv_pci *entry_priv = entry->priv_data; -struct skb_frame_desc *skbdesc;/* * This should not happen, we already checked the entry
@@ -82,13 +80,6 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry,return -EINVAL ; } -/* -* Fill in skb descriptor -*/ - skbdesc =get_skb_frame_desc (entry->skb); - skbdesc->desc = entry_priv->desc; - skbdesc->desc_len = entry->queue->desc_size; -return 0 ; }EXPORT_SYMBOL_GPL (rt2x00pci_write_tx_data);
drivers/net/wireless/rt2x00/rt2x00queue.c +0 -10
@@ -555,7 +555,6 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,struct rt2x00_intf *intf =vif_to_intf (vif);struct skb_frame_desc *skbdesc;struct txentry_desc txdesc; -__le32 desc[16 ];if (unlikely (!intf->beacon))return -ENOBUFS ;
@@ -588,19 +587,10 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,rt2x00queue_create_tx_descriptor (intf->beacon, &txdesc);/* -* For the descriptor we use a local array from where the -* driver can move it to the correct location required for -* the hardware. -*/ -memset (desc,0 ,sizeof (desc)); - -/* * Fill in skb descriptor */ skbdesc =get_skb_frame_desc (intf->beacon->skb);memset (skbdesc,0 ,sizeof (*skbdesc)); - skbdesc->desc = desc; - skbdesc->desc_len = intf->beacon->queue->desc_size; skbdesc->entry = intf->beacon;/*
drivers/net/wireless/rt2x00/rt2x00usb.c +0 -8
@@ -221,7 +221,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;struct usb_device *usb_dev =to_usb_device_intf (rt2x00dev->dev);struct queue_entry_priv_usb *entry_priv = entry->priv_data; -struct skb_frame_desc *skbdesc;u32 length;/*
@@ -231,13 +230,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,memset (entry->skb->data,0 , entry->queue->desc_size);/* -* Fill in skb descriptor -*/ - skbdesc =get_skb_frame_desc (entry->skb); - skbdesc->desc = entry->skb->data; - skbdesc->desc_len = entry->queue->desc_size; - -/* * USB devices cannot blindly pass the skb->len as the * length of the data to usb_fill_bulk_urb. Pass the skb * to the driver to determine what the length should be.
drivers/net/wireless/rt2x00/rt61pci.c +13 -7
@@ -1763,7 +1763,8 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txd = skbdesc->desc; +struct queue_entry_priv_pci *entry_priv = skbdesc->entry->priv_data; +__le32 *txd = entry_priv->desc;u32 word;/*
@@ -1842,6 +1843,13 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, test_bit(ENTRY_TXD_BURST, &txdesc->flags));rt2x00_set_field32 (&word,TXD_W0_CIPHER_ALG , txdesc->cipher);rt2x00_desc_write (txd,0 , word); + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txd; + skbdesc->desc_len = + (txdesc->queue ==QID_BEACON ) ?TXINFO_SIZE :TXD_DESC_SIZE ; }/*
@@ -1851,7 +1859,7 @@ static void rt61pci_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; -struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb); +struct queue_entry_priv_pci *entry_priv = entry->priv_data;unsigned int beacon_base;u32 reg;
@@ -1867,11 +1875,9 @@ static void rt61pci_write_beacon(struct queue_entry *entry,* Write entire beacon with descriptor to register. */ beacon_base =HW_BEACON_OFFSET (entry->entry_idx); -rt2x00pci_register_multiwrite (rt2x00dev, - beacon_base, - skbdesc->desc, skbdesc->desc_len); -rt2x00pci_register_multiwrite (rt2x00dev, - beacon_base + skbdesc->desc_len, +rt2x00pci_register_multiwrite (rt2x00dev, beacon_base, + entry_priv->desc,TXINFO_SIZE ); +rt2x00pci_register_multiwrite (rt2x00dev, beacon_base +TXINFO_SIZE , entry->skb->data, entry->skb->len);/*
drivers/net/wireless/rt2x00/rt73usb.c +12 -9
@@ -1440,7 +1440,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txd = skbdesc->desc; +__le32 *txd = (__le32 *)(skb->data -TXD_DESC_SIZE );u32 word;/*
@@ -1499,6 +1499,12 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, TXPOWER_TO_DEV(rt2x00dev->tx_power));rt2x00_set_field32 (&word,TXD_W5_WAITING_DMA_DONE_INT ,1 );rt2x00_desc_write (txd,5 , word); + +/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = txd; + skbdesc->desc_len =TXD_DESC_SIZE ; }/*
@@ -1508,18 +1514,10 @@ static void rt73usb_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; -struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb);unsigned int beacon_base;u32 reg;/* -* Add the descriptor in front of the skb. -*/ -skb_push (entry->skb, entry->queue->desc_size); -memcpy (entry->skb->data, skbdesc->desc, skbdesc->desc_len); - skbdesc->desc = entry->skb->data; - -/* * Disable beaconing while we are reloading the beacon data, * otherwise we might be sending out invalid data. */
@@ -1528,6 +1526,11 @@ static void rt73usb_write_beacon(struct queue_entry *entry,rt2x00usb_register_write (rt2x00dev,TXRX_CSR9 , reg);/* +* Take the descriptor in front of the skb into account. +*/ +skb_push (entry->skb,TXD_DESC_SIZE ); + +/* * Write entire beacon with descriptor to register. */ beacon_base =HW_BEACON_OFFSET (entry->entry_idx);
Signature · 1 line
1.7.1
PATCH v2 8/10 rt2x00: Push beacon TX descriptor writing to drivers.
In reply to Gertjan van WingerdeNot all the devices require a TX descriptor to be written (i.e. rt2800 device don't require them). Push down the creation of the TX descriptor to the device drivers so that they can decide for themselves whether a TX descriptor is to be created.
--- drivers/net/wireless/rt2x00/rt2400pci.c | 15 +++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 15 +++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 10 ++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 16 ++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 16 ++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00queue.c | 10 +--------- drivers/net/wireless/rt2x00/rt61pci.c | 10 ++++++++++ drivers/net/wireless/rt2x00/rt73usb.c | 10 ++++++++++ 8 files changed, 81 insertions(+), 21 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +9 -6
@@ -1074,9 +1074,6 @@ static void rt2400pci_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; -struct queue_entry_priv_pci *entry_priv = entry->priv_data; -struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb); -u32 word;u32 reg;/*
@@ -1089,9 +1086,15 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,rt2x00queue_map_txskb (rt2x00dev, entry->skb); -rt2x00_desc_read (entry_priv->desc,1 , &word); -rt2x00_set_field32 (&word,TXD_W1_BUFFER_ADDRESS , skbdesc->skb_dma); -rt2x00_desc_write (entry_priv->desc,1 , word); +/* +* Write the TX descriptor for the beacon. +*/ +rt2400pci_write_tx_desc (rt2x00dev, entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb);/* * Enable beaconing again.
drivers/net/wireless/rt2x00/rt2500pci.c +9 -6
@@ -1231,9 +1231,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; -struct queue_entry_priv_pci *entry_priv = entry->priv_data; -struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb); -u32 word;u32 reg;/*
@@ -1246,9 +1243,15 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,rt2x00queue_map_txskb (rt2x00dev, entry->skb); -rt2x00_desc_read (entry_priv->desc,1 , &word); -rt2x00_set_field32 (&word,TXD_W1_BUFFER_ADDRESS , skbdesc->skb_dma); -rt2x00_desc_write (entry_priv->desc,1 , word); +/* +* Write the TX descriptor for the beacon. +*/ +rt2500pci_write_tx_desc (rt2x00dev, entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb);/* * Enable beaconing again.
drivers/net/wireless/rt2x00/rt2500usb.c +10 -0
@@ -1107,6 +1107,16 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,rt2500usb_register_write (rt2x00dev,TXRX_CSR19 , reg);/* +* Write the TX descriptor for the beacon. +*/ +rt2500usb_write_tx_desc (rt2x00dev, entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb); + +/* * Take the descriptor in front of the skb into account. */ skb_push (entry->skb,TXD_DESC_SIZE );
drivers/net/wireless/rt2x00/rt2800pci.c +16 -0
@@ -688,6 +688,7 @@ static void rt2800pci_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; +struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb);unsigned int beacon_base;u32 reg;
@@ -700,9 +701,24 @@ static void rt2800pci_write_beacon(struct queue_entry *entry,rt2800_register_write (rt2x00dev,BCN_TIME_CFG , reg);/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = entry->skb->data -TXWI_DESC_SIZE ; + skbdesc->desc_len =TXWI_DESC_SIZE ; + +/* * Add the TXWI for the beacon to the skb. */ rt2800_write_txwi (entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb); + +/* +* Adjust skb to take TXWI into account. +*/ skb_push (entry->skb,TXWI_DESC_SIZE );/*
drivers/net/wireless/rt2x00/rt2800usb.c +16 -0
@@ -437,6 +437,7 @@ static void rt2800usb_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc) {struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; +struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb);unsigned int beacon_base;u32 reg;
@@ -449,9 +450,24 @@ static void rt2800usb_write_beacon(struct queue_entry *entry,rt2800_register_write (rt2x00dev,BCN_TIME_CFG , reg);/* +* Register descriptor details in skb frame descriptor. +*/ + skbdesc->desc = entry->skb->data -TXWI_DESC_SIZE ; + skbdesc->desc_len =TXWI_DESC_SIZE ; + +/* * Add the TXWI for the beacon to the skb. */ rt2800_write_txwi (entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb); + +/* +* Adjust skb to take TXWI into account. +*/ skb_push (entry->skb,TXWI_DESC_SIZE );/*
drivers/net/wireless/rt2x00/rt2x00queue.c +1 -9
@@ -420,7 +420,6 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry, {struct data_queue *queue = entry->queue;struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; -enum rt2x00_dump_type dump_type; rt2x00dev->ops->lib->write_tx_desc (rt2x00dev, entry->skb, txdesc);
@@ -428,9 +427,7 @@ static void rt2x00queue_write_tx_descriptor(struct queue_entry *entry,* All processing on the frame has been completed, this means * it is now ready to be dumped to userspace through debugfs. */ - dump_type = (txdesc->queue ==QID_BEACON ) ? -DUMP_FRAME_BEACON :DUMP_FRAME_TX ; -rt2x00debug_dump_frame (rt2x00dev, dump_type, entry->skb); +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_TX , entry->skb); } static void rt2x00queue_kick_tx_queue(struct queue_entry *entry,
@@ -594,11 +591,6 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, skbdesc->entry = intf->beacon;/* -* Write TX descriptor into reserved room in front of the beacon. -*/ -rt2x00queue_write_tx_descriptor (intf->beacon, &txdesc); - -/* * Send beacon to hardware and enable beacon genaration.. */ rt2x00dev->ops->lib->write_beacon (intf->beacon, &txdesc);
drivers/net/wireless/rt2x00/rt61pci.c +10 -0
@@ -1872,6 +1872,16 @@ static void rt61pci_write_beacon(struct queue_entry *entry,rt2x00pci_register_write (rt2x00dev,TXRX_CSR9 , reg);/* +* Write the TX descriptor for the beacon. +*/ +rt61pci_write_tx_desc (rt2x00dev, entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb); + +/* * Write entire beacon with descriptor to register. */ beacon_base =HW_BEACON_OFFSET (entry->entry_idx);
drivers/net/wireless/rt2x00/rt73usb.c +10 -0
@@ -1526,6 +1526,16 @@ static void rt73usb_write_beacon(struct queue_entry *entry,rt2x00usb_register_write (rt2x00dev,TXRX_CSR9 , reg);/* +* Write the TX descriptor for the beacon. +*/ +rt73usb_write_tx_desc (rt2x00dev, entry->skb, txdesc); + +/* +* Dump beacon to userspace through debugfs. +*/ +rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb); + +/* * Take the descriptor in front of the skb into account. */ skb_push (entry->skb,TXD_DESC_SIZE );
Signature · 1 line
1.7.1
Re: [PATCH v2 08/10] rt2x00: Push beacon TX descriptor writing to drivers.
Quoted 6 lines · Gertjan van Wingerde
Not all the devices require a TX descriptor to be written (i.e. rt2800 device don't require them). Push down the creation of the TX descriptor to the device drivers so that they can decide for themselves whether a TX descriptor is to be created.
Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH v2 9/10 rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
In reply to Gertjan van WingerdeFor rt2800 reverse the calling order of rt2x00pci_write_data and rt2800pci_write_data. Currently rt2800pci_write_data calls rt2x00pci_write_data as there can be only 1 driver callback function specified by the driver. Reverse this calling order by introducing a new driver callback function, called write_tx_datadesc, which is called from the bus-specific write_tx_data functions.
Preparation for futher cleanups in the skb data handling of rt2x00.
--- drivers/net/wireless/rt2x00/rt2800pci.c | 15 ++++----------- drivers/net/wireless/rt2x00/rt2x00.h | 2 ++ drivers/net/wireless/rt2x00/rt2x00pci.c | 6 ++++++ drivers/net/wireless/rt2x00/rt2x00usb.c | 6 ++++++ 4 files changed, 18 insertions(+), 11 deletions(-)
drivers/net/wireless/rt2x00/rt2800pci.c +4 -11
@@ -613,18 +613,10 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,/* * TX descriptor initialization */ -static int rt2800pci_write_tx_data (struct queue_entry * entry, -struct txentry_desc *txdesc) +static void rt2800pci_write_tx_datadesc (struct queue_entry * entry, +struct txentry_desc *txdesc) { -int ret; - - ret =rt2x00pci_write_tx_data (entry, txdesc); -if (ret) -return ret; -rt2800_write_txwi (entry->skb, txdesc); - -return 0 ; }
@@ -1079,7 +1071,8 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { .reset_tuner = rt2800_reset_tuner, .link_tuner = rt2800_link_tuner, .write_tx_desc = rt2800pci_write_tx_desc, - .write_tx_data = rt2800pci_write_tx_data, + .write_tx_data = rt2x00pci_write_tx_data, + .write_tx_datadesc = rt2800pci_write_tx_datadesc, .write_beacon = rt2800pci_write_beacon, .kick_tx_queue = rt2800pci_kick_tx_queue, .kill_tx_queue = rt2800pci_kill_tx_queue,
drivers/net/wireless/rt2x00/rt2x00.h +2 -0
@@ -551,6 +551,8 @@ struct rt2x00lib_ops { struct txentry_desc *txdesc);int (*write_tx_data) (struct queue_entry *entry,struct txentry_desc *txdesc); +void (*write_tx_datadesc) (struct queue_entry *entry, +struct txentry_desc *txdesc);void (*write_beacon) (struct queue_entry *entry,struct txentry_desc *txdesc);int (*get_tx_data_len) (struct queue_entry *entry);
drivers/net/wireless/rt2x00/rt2x00pci.c +6 -0
@@ -80,6 +80,12 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry,return -EINVAL ; } +/* +* Call the driver's write_tx_datadesc function, if it exists. +*/ +if (rt2x00dev->ops->lib->write_tx_datadesc) + rt2x00dev->ops->lib->write_tx_datadesc (entry, txdesc); +return 0 ; }EXPORT_SYMBOL_GPL (rt2x00pci_write_tx_data);
drivers/net/wireless/rt2x00/rt2x00usb.c +6 -0
@@ -247,6 +247,12 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry,*/ skb_pull (entry->skb, entry->queue->desc_size); +/* +* Call the driver's write_tx_datadesc function, if it exists. +*/ +if (rt2x00dev->ops->lib->write_tx_datadesc) + rt2x00dev->ops->lib->write_tx_datadesc (entry, txdesc); +return 0 ; }EXPORT_SYMBOL_GPL (rt2x00usb_write_tx_data);
Signature · 1 line
1.7.1
Re: [PATCH v2 09/10] rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
Quoted 9 lines · Gertjan van Wingerde
For rt2800 reverse the calling order of
rt2x00pci_write_dataandrt2800pci_write_data. Currentlyrt2800pci_write_datacallsrt2x00pci_write_dataas there can be only 1 driver callback function specified by the driver. Reverse this calling order by introducing a new driver callback function, calledwrite_tx_datadesc, which is called from the bus-specificwrite_tx_datafunctions.
Preparation for futher cleanups in the skb data handling of rt2x00.Signed-off-by Gertjan van Wingerde <[email protected]>
PATCH v2 10/10 rt2x00: Properly reserve room for descriptors in skbs.
In reply to Gertjan van WingerdeInstead of fiddling with the skb->data pointer and thereby risking out of bounds accesses, properly reserve the space needed in an skb for descriptors.
--- drivers/net/wireless/rt2x00/rt2400pci.c | 2 +- drivers/net/wireless/rt2x00/rt2500pci.c | 2 +- drivers/net/wireless/rt2x00/rt2500usb.c | 14 ++++++---- drivers/net/wireless/rt2x00/rt2800lib.c | 3 +- drivers/net/wireless/rt2x00/rt2800lib.h | 2 +- drivers/net/wireless/rt2x00/rt2800pci.c | 23 ++++++++-------- drivers/net/wireless/rt2x00/rt2800usb.c | 22 +++++++++------ drivers/net/wireless/rt2x00/rt2x00.h | 7 +++++ drivers/net/wireless/rt2x00/rt2x00dev.c | 5 --- drivers/net/wireless/rt2x00/rt2x00lib.h | 7 ----- drivers/net/wireless/rt2x00/rt2x00pci.c | 40 +++++++++++++++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00pci.h | 8 ++++++ drivers/net/wireless/rt2x00/rt2x00queue.c | 24 +---------------- drivers/net/wireless/rt2x00/rt2x00usb.c | 11 +++---- drivers/net/wireless/rt2x00/rt61pci.c | 4 +- drivers/net/wireless/rt2x00/rt73usb.c | 14 ++++++---- 16 files changed, 109 insertions(+), 79 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +1 -1
@@ -1227,7 +1227,7 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev, } txdesc.retry =rt2x00_get_field32 (word,TXD_W0_RETRY_COUNT ); -rt2x00lib_txdone (entry, &txdesc); +rt2x00pci_txdone (entry, &txdesc); } }
drivers/net/wireless/rt2x00/rt2500pci.c +1 -1
@@ -1363,7 +1363,7 @@ static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev, } txdesc.retry =rt2x00_get_field32 (word,TXD_W0_RETRY_COUNT ); -rt2x00lib_txdone (entry, &txdesc); +rt2x00pci_txdone (entry, &txdesc); } }
drivers/net/wireless/rt2x00/rt2500usb.c +8 -6
@@ -1033,7 +1033,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txd = (__le32 *)(skb->data -TXD_DESC_SIZE ); +__le32 *txd = (__le32 *) skb->data;u32 word;/*
@@ -1079,6 +1079,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,/* * Register descriptor details in skb frame descriptor. */ + skbdesc->flags |=SKBDESC_DESC_IN_SKB ; skbdesc->desc = txd; skbdesc->desc_len =TXD_DESC_SIZE ; }
@@ -1107,6 +1108,12 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,rt2500usb_register_write (rt2x00dev,TXRX_CSR19 , reg);/* +* Add space for the descriptor in front of the skb. +*/ +skb_push (entry->skb,TXD_DESC_SIZE ); +memset (entry->skb->data,0 ,TXD_DESC_SIZE ); + +/* * Write the TX descriptor for the beacon. */ rt2500usb_write_tx_desc (rt2x00dev, entry->skb, txdesc);
@@ -1117,11 +1124,6 @@ static void rt2500usb_write_beacon(struct queue_entry *entry,rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb);/* -* Take the descriptor in front of the skb into account. -*/ -skb_push (entry->skb,TXD_DESC_SIZE ); - -/* * USB devices cannot blindly pass the skb->len as the * length of the data to usb_fill_bulk_urb. Pass the skb * to the driver to determine what the length should be.
drivers/net/wireless/rt2x00/rt2800lib.c +1 -2
@@ -281,9 +281,8 @@ int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev) }EXPORT_SYMBOL_GPL (rt2800_wait_wpdma_ready); -void rt2800_write_txwi (struct sk_buff *skb,struct txentry_desc *txdesc) +void rt2800_write_txwi (__le32 *txwi,struct txentry_desc *txdesc) { -__le32 *txwi = (__le32 *)(skb->data -TXWI_DESC_SIZE );u32 word;/*
drivers/net/wireless/rt2x00/rt2800lib.h +1 -1
@@ -111,7 +111,7 @@ void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, const u8 command, const u8 token, const u8 arg0, const u8 arg1); -void rt2800_write_txwi (struct sk_buff *skb,struct txentry_desc *txdesc); +void rt2800_write_txwi (__le32 *txwi,struct txentry_desc *txdesc);void rt2800_process_rxwi (struct sk_buff *skb,struct rxdone_entry_desc *txdesc);extern const struct rt2x00debug rt2800_rt2x00debug;
drivers/net/wireless/rt2x00/rt2800pci.c +12 -11
@@ -616,7 +616,7 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,static void rt2800pci_write_tx_datadesc (struct queue_entry * entry,struct txentry_desc *txdesc) { -rt2800_write_txwi (entry->skb, txdesc); +rt2800_write_txwi ((__le32 *) entry->skb->data, txdesc); }
@@ -693,15 +693,22 @@ static void rt2800pci_write_beacon(struct queue_entry *entry,rt2800_register_write (rt2x00dev,BCN_TIME_CFG , reg);/* +* Add space for the TXWI in front of the skb. +*/ +skb_push (entry->skb,TXWI_DESC_SIZE ); +memset (entry->skb,0 ,TXWI_DESC_SIZE ); + +/* * Register descriptor details in skb frame descriptor. */ - skbdesc->desc = entry->skb->data -TXWI_DESC_SIZE ; + skbdesc->flags |=SKBDESC_DESC_IN_SKB ; + skbdesc->desc = entry->skb->data; skbdesc->desc_len =TXWI_DESC_SIZE ;/* * Add the TXWI for the beacon to the skb. */ -rt2800_write_txwi (entry->skb, txdesc); +rt2800_write_txwi ((__le32 *)entry->skb->data, txdesc);/* * Dump beacon to userspace through debugfs.
@@ -709,11 +716,6 @@ static void rt2800pci_write_beacon(struct queue_entry *entry,rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb);/* -* Adjust skb to take TXWI into account. -*/ -skb_push (entry->skb,TXWI_DESC_SIZE ); - -/* * Write entire beacon with TXWI to register. */ beacon_base =HW_BEACON_OFFSET (entry->entry_idx);
@@ -888,8 +890,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)/* Check if we got a match by looking at WCID/ACK/PID * fields */ - txwi = (__le32 *)(entry->skb->data - - rt2x00dev->ops->extra_tx_headroom); + txwi = (__le32 *) entry->skb->data;rt2x00_desc_read (txwi,1 , &word); tx_wcid =rt2x00_get_field32 (word,TXWI_W1_WIRELESS_CLI_ID );
@@ -934,7 +935,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)__set_bit (TXDONE_FALLBACK , &txdesc.flags); -rt2x00lib_txdone (entry, &txdesc); +rt2x00pci_txdone (entry, &txdesc); } }
drivers/net/wireless/rt2x00/rt2800usb.c +13 -9
@@ -400,13 +400,14 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txi = (__le32 *)(skb->data -TXWI_DESC_SIZE -TXINFO_DESC_SIZE ); +__le32 *txi = (__le32 *) skb->data; +__le32 *txwi = (__le32 *) (skb->data +TXINFO_DESC_SIZE );u32 word;/* * Initialize TXWI descriptor */ -rt2800_write_txwi (skb, txdesc); +rt2800_write_txwi (txwi, txdesc);/* * Initialize TXINFO descriptor
@@ -426,6 +427,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,/* * Register descriptor details in skb frame descriptor. */ + skbdesc->flags |=SKBDESC_DESC_IN_SKB ; skbdesc->desc = txi; skbdesc->desc_len =TXINFO_DESC_SIZE +TXWI_DESC_SIZE ; }
@@ -450,15 +452,22 @@ static void rt2800usb_write_beacon(struct queue_entry *entry,rt2800_register_write (rt2x00dev,BCN_TIME_CFG , reg);/* +* Add space for the TXWI in front of the skb. +*/ +skb_push (entry->skb,TXWI_DESC_SIZE ); +memset (entry->skb,0 ,TXWI_DESC_SIZE ); + +/* * Register descriptor details in skb frame descriptor. */ - skbdesc->desc = entry->skb->data -TXWI_DESC_SIZE ; + skbdesc->flags |=SKBDESC_DESC_IN_SKB ; + skbdesc->desc = entry->skb->data; skbdesc->desc_len =TXWI_DESC_SIZE ;/* * Add the TXWI for the beacon to the skb. */ -rt2800_write_txwi (entry->skb, txdesc); +rt2800_write_txwi ((__le32 *) entry->skb->data, txdesc);/* * Dump beacon to userspace through debugfs.
@@ -466,11 +475,6 @@ static void rt2800usb_write_beacon(struct queue_entry *entry,rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb);/* -* Adjust skb to take TXWI into account. -*/ -skb_push (entry->skb,TXWI_DESC_SIZE ); - -/* * Write entire beacon with descriptor to register. */ beacon_base =HW_BEACON_OFFSET (entry->entry_idx);
drivers/net/wireless/rt2x00/rt2x00.h +7 -0
@@ -1001,6 +1001,13 @@ static inline bool rt2x00_is_soc(struct rt2x00_dev *rt2x00dev)void rt2x00queue_map_txskb (struct rt2x00_dev *rt2x00dev,struct sk_buff *skb);/** +* rt2x00queue_unmap_skb - Unmap a skb from DMA. +* @rt2x00dev: Pointer to &struct rt2x00_dev. +* @skb: The skb to unmap. +*/ +void rt2x00queue_unmap_skb (struct rt2x00_dev *rt2x00dev,struct sk_buff *skb); + +/** * rt2x00queue_get_queue - Convert queue index to queue pointer * @rt2x00dev: Pointer to &struct rt2x00_dev. * @queue: rt2x00 queue index (see &enum data_queue_qid).
drivers/net/wireless/rt2x00/rt2x00dev.c +0 -5
@@ -210,11 +210,6 @@ void rt2x00lib_txdone(struct queue_entry *entry,bool success;/* -* Unmap the skb. -*/ -rt2x00queue_unmap_skb (rt2x00dev, entry->skb); - -/* * Remove L2 padding which was added during */ if (test_bit (DRIVER_REQUIRE_L2PAD , &rt2x00dev->flags))
drivers/net/wireless/rt2x00/rt2x00lib.h +0 -7
@@ -105,13 +105,6 @@ struct sk_buff *rt2x00queue_alloc_rxskb(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry);/** -* rt2x00queue_unmap_skb - Unmap a skb from DMA. -* @rt2x00dev: Pointer to &struct rt2x00_dev. -* @skb: The skb to unmap. -*/ -void rt2x00queue_unmap_skb (struct rt2x00_dev *rt2x00dev,struct sk_buff *skb); - -/** * rt2x00queue_free_skb - free a skb * @rt2x00dev: Pointer to &struct rt2x00_dev. * @skb: The skb to free.
drivers/net/wireless/rt2x00/rt2x00pci.c +40 -0
@@ -81,11 +81,23 @@ int rt2x00pci_write_tx_data(struct queue_entry *entry, }/* +* Add the requested extra tx headroom in front of the skb. +*/ +skb_push (entry->skb, rt2x00dev->ops->extra_tx_headroom); +memset (entry->skb->data,0 , rt2x00dev->ops->extra_tx_headroom); + +/* * Call the driver's write_tx_datadesc function, if it exists. */ if (rt2x00dev->ops->lib->write_tx_datadesc) rt2x00dev->ops->lib->write_tx_datadesc (entry, txdesc); +/* +* Map the skb to DMA. +*/ +if (test_bit (DRIVER_REQUIRE_DMA , &rt2x00dev->flags)) +rt2x00queue_map_txskb (rt2x00dev, entry->skb); +return 0 ; }EXPORT_SYMBOL_GPL (rt2x00pci_write_tx_data);
@@ -93,6 +105,34 @@ EXPORT_SYMBOL_GPL(rt2x00pci_write_tx_data);/* * TX/RX data handlers. */ +void rt2x00pci_txdone (struct queue_entry *entry, +struct txdone_entry_desc *txdesc) +{ +struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; +struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb); + +/* +* Unmap the skb. +*/ +rt2x00queue_unmap_skb (rt2x00dev, entry->skb); + +/* +* Remove the extra tx headroom from the skb. +*/ +skb_pull (entry->skb, rt2x00dev->ops->extra_tx_headroom); + +/* +* Signal that the TX descriptor is no longer in the skb. +*/ + skbdesc->flags &= ~SKBDESC_DESC_IN_SKB ; + +/* +* Pass on to rt2x00lib. +*/ +rt2x00lib_txdone (entry, txdesc); +} +EXPORT_SYMBOL_GPL (rt2x00pci_txdone); +void rt2x00pci_rxdone (struct rt2x00_dev *rt2x00dev) {struct data_queue *queue = rt2x00dev->rx;
drivers/net/wireless/rt2x00/rt2x00pci.h +8 -0
@@ -109,6 +109,14 @@ struct queue_entry_priv_pci { };/** +* rt2x00pci_txdone - Handle TX done events. +* @entry: The queue entry for which a TX done event was received. +* @txdesc: The TX done descriptor for the entry. +*/ +void rt2x00pci_txdone (struct queue_entry *entry, +struct txdone_entry_desc *txdesc); + +/** * rt2x00pci_rxdone - Handle RX done events * @rt2x00dev: Device pointer, see &struct rt2x00_dev. */
drivers/net/wireless/rt2x00/rt2x00queue.c +2 -22
@@ -99,21 +99,8 @@ void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -/* -* If device has requested headroom, we should make sure that -* is also mapped to the DMA so it can be used for transfering -* additional descriptor information to the hardware. -*/ -skb_push (skb, rt2x00dev->ops->extra_tx_headroom); - skbdesc->skb_dma =dma_map_single (rt2x00dev->dev, skb->data, skb->len,DMA_TO_DEVICE ); - -/* -* Restore data pointer to original location again. -*/ -skb_pull (skb, rt2x00dev->ops->extra_tx_headroom); - skbdesc->flags |=SKBDESC_DMA_MAPPED_TX ; }EXPORT_SYMBOL_GPL (rt2x00queue_map_txskb);
@@ -129,16 +116,12 @@ void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) }if (skbdesc->flags &SKBDESC_DMA_MAPPED_TX ) { -/* -* Add headroom to the skb length, it has been removed -* by the driver, but it was actually mapped to DMA. -*/ -dma_unmap_single (rt2x00dev->dev, skbdesc->skb_dma, - skb->len + rt2x00dev->ops->extra_tx_headroom, +dma_unmap_single (rt2x00dev->dev, skbdesc->skb_dma, skb->len,DMA_TO_DEVICE ); skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX ; } } +EXPORT_SYMBOL_GPL (rt2x00queue_unmap_skb);void rt2x00queue_free_skb (struct rt2x00_dev *rt2x00dev,struct sk_buff *skb) {
@@ -533,9 +516,6 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,return -EIO ; } -if (test_bit (DRIVER_REQUIRE_DMA , &queue->rt2x00dev->flags)) -rt2x00queue_map_txskb (queue->rt2x00dev, skb); -set_bit (ENTRY_DATA_PENDING , &entry->flags);rt2x00queue_index_inc (queue,Q_INDEX );
drivers/net/wireless/rt2x00/rt2x00usb.c +5 -6
@@ -197,6 +197,11 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)return ;/* +* Remove the descriptor from the front of the skb. +*/ +skb_pull (entry->skb, entry->queue->desc_size); + +/* * Obtain the status about this packet. * Note that when the status is 0 it does not mean the * frame was send out correctly. It only means the frame
@@ -242,12 +247,6 @@ int rt2x00usb_write_tx_data(struct queue_entry *entry, rt2x00usb_interrupt_txdone, entry);/* -* Make sure the skb->data pointer points to the frame, not the -* descriptor. -*/ -skb_pull (entry->skb, entry->queue->desc_size); - -/* * Call the driver's write_tx_datadesc function, if it exists. */ if (rt2x00dev->ops->lib->write_tx_datadesc)
drivers/net/wireless/rt2x00/rt61pci.c +2 -2
@@ -2108,7 +2108,7 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev)__set_bit (TXDONE_UNKNOWN , &txdesc.flags); txdesc.retry =0 ; -rt2x00lib_txdone (entry_done, &txdesc); +rt2x00pci_txdone (entry_done, &txdesc); entry_done =rt2x00queue_get_entry (queue,Q_INDEX_DONE ); }
@@ -2128,7 +2128,7 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) } txdesc.retry =rt2x00_get_field32 (reg,STA_CSR4_RETRY_COUNT ); -rt2x00lib_txdone (entry, &txdesc); +rt2x00pci_txdone (entry, &txdesc); } }
drivers/net/wireless/rt2x00/rt73usb.c +8 -6
@@ -1440,7 +1440,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, struct txentry_desc *txdesc) {struct skb_frame_desc *skbdesc =get_skb_frame_desc (skb); -__le32 *txd = (__le32 *)(skb->data -TXD_DESC_SIZE ); +__le32 *txd = (__le32 *) skb->data;u32 word;/*
@@ -1503,6 +1503,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,/* * Register descriptor details in skb frame descriptor. */ + skbdesc->flags |=SKBDESC_DESC_IN_SKB ; skbdesc->desc = txd; skbdesc->desc_len =TXD_DESC_SIZE ; }
@@ -1526,6 +1527,12 @@ static void rt73usb_write_beacon(struct queue_entry *entry,rt2x00usb_register_write (rt2x00dev,TXRX_CSR9 , reg);/* +* Add space for the descriptor in front of the skb. +*/ +skb_push (entry->skb,TXD_DESC_SIZE ); +memset (entry->skb->data,0 ,TXD_DESC_SIZE ); + +/* * Write the TX descriptor for the beacon. */ rt73usb_write_tx_desc (rt2x00dev, entry->skb, txdesc);
@@ -1536,11 +1543,6 @@ static void rt73usb_write_beacon(struct queue_entry *entry,rt2x00debug_dump_frame (rt2x00dev,DUMP_FRAME_BEACON , entry->skb);/* -* Take the descriptor in front of the skb into account. -*/ -skb_push (entry->skb,TXD_DESC_SIZE ); - -/* * Write entire beacon with descriptor to register. */ beacon_base =HW_BEACON_OFFSET (entry->entry_idx);
Signature · 1 line
1.7.1