rt2x00: Further fixes and cleanups.
PATCH 1/9 rt2x00: Consistently name skb frame descriptor skbdesc.
In reply to Gertjan van WingerdeThe 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 2/9 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 7/9 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
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
Gertjan van Wingerde (9):
rt2x00: Consistently name skb frame descriptor skbdesc.
rt2x00: Fix beacon descriptor writing for rt61pci.
rt2x00: Re-order tx descriptor writing code in drivers.
rt2x00: Simplify TXD handling of beacons.
rt2x00: Dump beacons under a different identifier than TX frames.
rt2x00: Push beacon TX descriptor writing to drivers.
rt2x00: In debugfs frame dumping allow the TX descriptor to be part
of the skb.
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 | 42 ++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 42 ++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 68 ++++++++++++++--------- drivers/net/wireless/rt2x00/rt2800lib.c | 3 +- drivers/net/wireless/rt2x00/rt2800lib.h | 2 +- drivers/net/wireless/rt2x00/rt2800pci.c | 59 +++++++++++++------- drivers/net/wireless/rt2x00/rt2800usb.c | 35 +++++++++++-- drivers/net/wireless/rt2x00/rt2x00.h | 9 +++ drivers/net/wireless/rt2x00/rt2x00debug.c | 22 +++++--- drivers/net/wireless/rt2x00/rt2x00dev.c | 5 -- drivers/net/wireless/rt2x00/rt2x00dump.h | 3 + drivers/net/wireless/rt2x00/rt2x00lib.h | 7 --- 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 | 50 ++++++++++++----- drivers/net/wireless/rt2x00/rt73usb.c | 84 +++++++++++++++++------------ 19 files changed, 338 insertions(+), 211 deletions(-)
PATCH 3/9 rt2x00: Re-order tx descriptor writing code in drivers.
Where 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 4/9 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
@@ -552,7 +552,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 ;
@@ -585,19 +584,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 6/9 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 | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00debug.c | 1 + drivers/net/wireless/rt2x00/rt2x00queue.c | 10 +--------- drivers/net/wireless/rt2x00/rt61pci.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt73usb.c | 11 +++++++++++ 9 files changed, 89 insertions(+), 21 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +10 -6
@@ -33,6 +33,7 @@#include <linux/eeprom_93cx6.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
@@ -1074,9 +1075,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 +1087,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 +10 -6
@@ -33,6 +33,7 @@#include <linux/eeprom_93cx6.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2500pci.h"
@@ -1231,9 +1232,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 +1244,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 +11 -0
@@ -32,6 +32,7 @@#include <linux/usb.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00usb.h" #include "rt2500usb.h"
@@ -1107,6 +1108,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 +17 -0
@@ -42,6 +42,7 @@#include <linux/eeprom_93cx6.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2x00soc.h" #include "rt2800lib.h"
@@ -688,6 +689,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 +702,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 +17 -0
@@ -37,6 +37,7 @@#include <linux/usb.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00usb.h" #include "rt2800lib.h" #include "rt2800.h"
@@ -437,6 +438,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 +451,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/rt2x00debug.c +1 -0
@@ -204,6 +204,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/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 ; 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 +11 -0
@@ -34,6 +34,7 @@#include <linux/eeprom_93cx6.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt61pci.h"
@@ -1872,6 +1873,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 +11 -0
@@ -33,6 +33,7 @@#include <linux/usb.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00usb.h" #include "rt73usb.h"
@@ -1526,6 +1527,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
PATCH 9/9 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
@@ -1228,7 +1228,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
@@ -1364,7 +1364,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
@@ -1034,7 +1034,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;/*
@@ -1080,6 +1080,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 ; }
@@ -1108,6 +1109,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);
@@ -1118,11 +1125,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
@@ -617,7 +617,7 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,static void rt2800pci_add_tx_datadesc (struct queue_entry * entry,struct txentry_desc *txdesc) { -rt2800_write_txwi (entry->skb, txdesc); +rt2800_write_txwi ((__le32 *) entry->skb->data, txdesc); }
@@ -694,15 +694,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.
@@ -710,11 +717,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);
@@ -889,8 +891,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 );
@@ -935,7 +936,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
@@ -401,13 +401,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
@@ -427,6 +428,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 ; }
@@ -451,15 +453,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.
@@ -467,11 +476,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
@@ -107,13 +107,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 add_tx_datadesc function, if it exists. */ if (rt2x00dev->ops->lib->add_tx_datadesc) rt2x00dev->ops->lib->add_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 add_tx_datadesc function, if it exists. */ if (rt2x00dev->ops->lib->add_tx_datadesc)
drivers/net/wireless/rt2x00/rt61pci.c +2 -2
@@ -2109,7 +2109,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 ); }
@@ -2129,7 +2129,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
@@ -1441,7 +1441,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;/*
@@ -1504,6 +1504,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 ; }
@@ -1527,6 +1528,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);
@@ -1537,11 +1544,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
PATCH 8/9 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 add_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
@@ -614,18 +614,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_add_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 ; }
@@ -1080,7 +1072,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, + .add_tx_datadesc = rt2800pci_add_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 (*add_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 add_tx_datadesc function, if it exists. +*/ +if (rt2x00dev->ops->lib->add_tx_datadesc) + rt2x00dev->ops->lib->add_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 add_tx_datadesc function, if it exists. +*/ +if (rt2x00dev->ops->lib->add_tx_datadesc) + rt2x00dev->ops->lib->add_tx_datadesc (entry, txdesc); +return 0 ; }EXPORT_SYMBOL_GPL (rt2x00usb_write_tx_data);
Signature · 1 line
1.7.1
PATCH 5/9 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 ; 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
Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
In reply to Gertjan van WingerdeQuoted 23 lines · Gertjan van Wingerde
The 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.Signed-off-by Gertjan van Wingerde <[email protected]>---
drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++-----1 files changed, 5 insertions(+), 5 deletions(-)drivers/net/wireless/rt2x00/rt61pci.c +0
-4@@ -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);
drivers/net/wireless/rt2x00/rt61pci.c static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, · line 1812
Quoted 10 lines
drivers/net/wireless/rt2x00/rt61pci.c +5
-1+ 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);
Shouldn't the check for TXINFO_SIZE be used rather than explicitly checking for the QID?
Ivo
Re: [PATCH 1/9] rt2x00: Consistently name skb frame descriptor skbdesc.
In reply to Gertjan van WingerdeQuoted 5 lines · Gertjan van Wingerde
The skb frame descriptor is called everywhere skbdesc, except in one place in
rt2x00debug_dump_frame. Change that occurence to have consistent naming.Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 54 lines
---
drivers/net/wireless/rt2x00/rt2x00debug.c | 13 +++++++------1 files changed, 7 insertions(+), 6 deletions(-)drivers/net/wireless/rt2x00/rt2x00debug.c +7
-7@@ -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); --1.7.1
Re: [PATCH 5/9] rt2x00: Dump beacons under a different identifier than TX frames.
In reply to Gertjan van WingerdeQuoted 6 lines · Gertjan van Wingerde
This allows for specific identification of beacons in the debugfs frame stream.
Preparation for later differences between dumped TX frames and dumped beacons.Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 3/9] rt2x00: Re-order tx descriptor writing code in drivers.
In reply to Gertjan van WingerdeQuoted 6 lines · Gertjan van Wingerde
Where 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.Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 8/9] rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
In reply to Gertjan van WingerdeQuoted 42 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, calledadd_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]>---
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 +2
-10@@ -614,18 +614,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_add_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; }
drivers/net/wireless/rt2x00/rt2800pci.c static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { · line 1079
Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2
-1@@ -1080,7 +1072,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, + .add_tx_datadesc = rt2800pci_add_tx_datadesc, .write_beacon = rt2800pci_write_beacon, .kick_tx_queue = rt2800pci_kick_tx_queue, .kill_tx_queue = rt2800pci_kill_tx_queue,
Doesn't the name write_tx_datadesc make more sense?
Ivo
Re: [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers.
In reply to Gertjan van WingerdeQuoted 23 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]>---
drivers/net/wireless/rt2x00/rt2400pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++drivers/net/wireless/rt2x00/rt2x00debug.c | 1 +
drivers/net/wireless/rt2x00/rt2x00queue.c| 10 +---------drivers/net/wireless/rt2x00/rt61pci.c| 11 +++++++++++drivers/net/wireless/rt2x00/rt73usb.c| 11 +++++++++++9 files changed, 89 insertions(+), 21 deletions(-)drivers/net/wireless/rt2x00/rt2400pci.c +0
-0
drivers/net/wireless/rt2x00/rt2400pci.c line 38
Quoted 6 lines
drivers/net/wireless/rt2x00/rt2400pci.c +1
-0@@ -33,6 +33,7 @@ #include <linux/eeprom_93cx6.h> #include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
rt2x00lib.h must not be used in the drivers. It is for the rt2x00lib internal files only.
Quoted 16 lines
drivers/net/wireless/rt2x00/rt2400pci.c +0
-5@@ -1074,9 +1075,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 +1087,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);
drivers/net/wireless/rt2x00/rt2400pci.c static void rt2400pci_write_beacon(struct queue_entry *entry, · line 1098
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2400pci.c +9
-1- 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);
The goal for rt2x00debug was that the logic must be inside rt2x00lib as much as possible.
This can/should be moved into rt2x00lib where write_beacon() is being called.
Ivo
Re: [PATCH 9/9] rt2x00: Properly reserve room for descriptors in skbs.
In reply to Gertjan van WingerdeQuoted 5 lines · Gertjan van Wingerde
Instead of fiddling with the
skb->datapointer and thereby risking out of bounds accesses, properly reserve the space needed in an skb for descriptors.Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 4/9] rt2x00: Simplify TXD handling of beacons.
In reply to Gertjan van WingerdeQuoted 8 lines · Gertjan van Wingerde
The handling of tx descriptors for beacons can be simplified by updating
write_tx_descimplementations 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.Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 7/9] rt2x00: In debugfs frame dumping allow the TX descriptor to be part of the skb.
In reply to Gertjan van WingerdeQuoted 4 lines · Gertjan van Wingerde
Preparation for futher cleanups in the area of properly maintaining the skb data without fiddling with the
skb->datapointer.Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
In reply to Ivo Van DoornQuoted 31 lines · Ivo Van Doorn
Quoted 29 lines · Gertjan van Wingerde
The 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.Signed-off-by Gertjan van Wingerde <[email protected]>---
drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++-----1 files changed, 5 insertions(+), 5 deletions(-)drivers/net/wireless/rt2x00/rt61pci.c +5
-4@@ -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);
Quoted 8 lines
drivers/net/wireless/rt2x00/rt61pci.c static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, · line 1812
Quoted 4 lines
drivers/net/wireless/rt2x00/rt61pci.c +0
-1- if (skbdesc->desc_len > TXINFO_SIZE) { rt2x00_desc_read(txd, 11, &word); rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, txdesc->length);Shouldn't the check for
TXINFO_SIZEbe used rather than explicitly checking for the QID?
I agree that this is a change that didn't have to be made in this patch. However, after patch 4 of the series we cannot depend on the skbdesc->desc_len being set anymore, and we would have to depend on checking the QID anyway.
Note that in reality these two checks are completely equivalent with respect to the result.
---
Gertjan.
Re: [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers.
In reply to Ivo Van DoornQuoted 27 lines · Ivo Van Doorn
Quoted 25 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]>---
drivers/net/wireless/rt2x00/rt2400pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++drivers/net/wireless/rt2x00/rt2x00debug.c | 1 +
drivers/net/wireless/rt2x00/rt2x00queue.c| 10 +---------drivers/net/wireless/rt2x00/rt61pci.c| 11 +++++++++++drivers/net/wireless/rt2x00/rt73usb.c| 11 +++++++++++9 files changed, 89 insertions(+), 21 deletions(-)drivers/net/wireless/rt2x00/rt2400pci.c +0
-0@@ -33,6 +33,7 @@ #include <linux/eeprom_93cx6.h>
Quoted 7 lines
drivers/net/wireless/rt2x00/rt2400pci.c line 38
Quoted 4 lines
drivers/net/wireless/rt2x00/rt2400pci.c +1
-0#include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
rt2x00lib.hmust not be used in the drivers. It is for the rt2x00lib internal files only.
OK. This include is/was necessary for the rt2x00debug_dump_frame call. So this may be handled with your next issue.
Quoted 15 lines
Quoted 15 lines
drivers/net/wireless/rt2x00/rt2400pci.c +0
-3@@ -1074,9 +1075,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 +1087,15 @@ static void rt2400pci_write_beacon(struct queue_entry *entry, rt2x00queue_map_txskb(rt2x00dev, entry->skb);
Quoted 17 lines
drivers/net/wireless/rt2x00/rt2400pci.c static void rt2400pci_write_beacon(struct queue_entry *entry, · line 1098
Quoted 12 lines
drivers/net/wireless/rt2x00/rt2400pci.c +9
-3- 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);The goal for rt2x00debug was that the logic must be inside rt2x00lib as much as possible.
This can/should be moved into rt2x00lib wherewrite_beacon()is being called.
Yes, I wasn't too happy about this part about the patch, but couldn't find a better solution. The problem is that with the patch the frame cannot be dumped before the call to write_beacon, as the descriptor hasn't been set up yet. Also, it cannot be dumped after the call to write_beacon as most of the write_beacon functions actually free the skb with the beacon.
So, I ran out of ideas as to how to keep rt2x00debug only inside rt2x00lib. I'm open for suggestions, though.
---
Gertjan
Re: [PATCH 8/9] rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
In reply to Ivo Van DoornQuoted 43 lines · Ivo Van Doorn
Quoted 41 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, calledadd_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]>---
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 +2
-10@@ -614,18 +614,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_add_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; }
Quoted 13 lines
drivers/net/wireless/rt2x00/rt2800pci.c static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { · line 1079
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2
-1@@ -1080,7 +1072,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, + .add_tx_datadesc = rt2800pci_add_tx_datadesc, .write_beacon = rt2800pci_write_beacon, .kick_tx_queue = rt2800pci_kick_tx_queue, .kill_tx_queue = rt2800pci_kill_tx_queue,Doesn't the name
write_tx_datadescmake more sense?
The names are equivalent to me. But if that name makes more sense to you then I have no problem with changing the name of the callback function.
---
Gertjan
Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
In reply to Gertjan van WingerdeQuoted 41 lines · Gertjan van Wingerde
Quoted 31 lines · Ivo Van Doorn
Quoted 29 lines · Gertjan van Wingerde
The 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.Signed-off-by Gertjan van Wingerde <[email protected]>---
drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++-----1 files changed, 5 insertions(+), 5 deletions(-)drivers/net/wireless/rt2x00/rt61pci.c +5
-4@@ -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);Quoted 8 lines
drivers/net/wireless/rt2x00/rt61pci.c static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, · line 1812
Quoted 4 lines
drivers/net/wireless/rt2x00/rt61pci.c +0
-1- if (skbdesc->desc_len > TXINFO_SIZE) { rt2x00_desc_read(txd, 11, &word); rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, txdesc->length);Shouldn't the check for
TXINFO_SIZEbe used rather than explicitly checking for the QID?
Quoted 6 lines
I agree that this is a change that didn't have to be made in this patch. However, after patch 4 of the series we cannot depend on the
skbdesc->desc_lenbeing set anymore, and we would have to depend on checking the QID anyway.
Note that in reality these two checks are completely equivalent with respect to the result.
Hmm, is that a good idea? I mean we are using the skbdesc inside the function, but we can't be sure that one of the basic values contains the right value?
Ivo
Re: [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers.
In reply to Gertjan van WingerdeQuoted 72 lines · Gertjan van Wingerde
Quoted 27 lines · Ivo Van Doorn
Quoted 25 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]>---
drivers/net/wireless/rt2x00/rt2400pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++drivers/net/wireless/rt2x00/rt2x00debug.c | 1 +
drivers/net/wireless/rt2x00/rt2x00queue.c| 10 +---------drivers/net/wireless/rt2x00/rt61pci.c| 11 +++++++++++drivers/net/wireless/rt2x00/rt73usb.c| 11 +++++++++++9 files changed, 89 insertions(+), 21 deletions(-)drivers/net/wireless/rt2x00/rt2400pci.c +0
-0@@ -33,6 +33,7 @@ #include <linux/eeprom_93cx6.h>Quoted 7 lines
drivers/net/wireless/rt2x00/rt2400pci.c line 38
Quoted 4 lines
drivers/net/wireless/rt2x00/rt2400pci.c +1
-0#include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
rt2x00lib.hmust not be used in the drivers. It is for the rt2x00lib internal files only.OK. This include is/was necessary for the
rt2x00debug_dump_framecall. So this may be handled with your next issue.Quoted 15 lines
Quoted 15 lines
drivers/net/wireless/rt2x00/rt2400pci.c +0
-3@@ -1074,9 +1075,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 +1087,15 @@ static void rt2400pci_write_beacon(struct queue_entry *entry, rt2x00queue_map_txskb(rt2x00dev, entry->skb);Quoted 17 lines
drivers/net/wireless/rt2x00/rt2400pci.c static void rt2400pci_write_beacon(struct queue_entry *entry, · line 1098
Quoted 12 lines
drivers/net/wireless/rt2x00/rt2400pci.c +9
-3- 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);The goal for rt2x00debug was that the logic must be inside rt2x00lib as much as possible.
This can/should be moved into rt2x00lib wherewrite_beacon()is being called.
Quoted 8 lines
Yes, I wasn't too happy about this part about the patch, but couldn't find a better solution. The problem is that with the patch the frame cannot be dumped before the call to
write_beacon, as the descriptor hasn't been set up yet. Also, it cannot be dumped after the call towrite_beaconas most of thewrite_beaconfunctions actually free the skb with the beacon.
So, I ran out of ideas as to how to keep rt2x00debug only inside rt2x00lib. I'm open for suggestions, though.
Well ok, if there aren't obvious alternatives this change is fine. However, please move the declaration of rt2x00debug_dump_frame() into rt2x00.h? That way we don't have to include the rt2x00lib.h header.
Ivo
Re: [PATCH 8/9] rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
In reply to Gertjan van WingerdeQuoted 58 lines · Gertjan van Wingerde
Quoted 43 lines · Ivo Van Doorn
Quoted 41 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, calledadd_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]>---
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 +2
-10@@ -614,18 +614,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_add_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; }Quoted 13 lines
drivers/net/wireless/rt2x00/rt2800pci.c static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { · line 1079
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2
-1@@ -1080,7 +1072,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, + .add_tx_datadesc = rt2800pci_add_tx_datadesc, .write_beacon = rt2800pci_write_beacon, .kick_tx_queue = rt2800pci_kick_tx_queue, .kill_tx_queue = rt2800pci_kill_tx_queue,Doesn't the name
write_tx_datadescmake more sense?
Quoted 3 lines
The names are equivalent to me. But if that name makes more sense to you then I have no problem with changing the name of the callback function.
Yes please rename it. That way it fits in thewrite_tx_descwrite_tx_datawrite_tx_datadesc
Thanks,
Ivo
Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
In reply to Ivo Van DoornQuoted 50 lines · Ivo Van Doorn
Quoted 41 lines · Gertjan van Wingerde
Quoted 31 lines · Ivo Van Doorn
Quoted 29 lines · Gertjan van Wingerde
The 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.Signed-off-by Gertjan van Wingerde <[email protected]>--- drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)drivers/net/wireless/rt2x00/rt61pci.c +5
-4@@ -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);Quoted 8 lines
drivers/net/wireless/rt2x00/rt61pci.c static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, · line 1812
Quoted 4 lines
drivers/net/wireless/rt2x00/rt61pci.c +0
-1-if (skbdesc->desc_len >TXINFO_SIZE ) {rt2x00_desc_read (txd,11 , &word);rt2x00_set_field32 (&word,TXD_W11_BUFFER_LENGTH0 , txdesc->length);Shouldn't the check for
TXINFO_SIZEbe used rather than explicitly checking for the QID?Quoted 6 lines
I agree that this is a change that didn't have to be made in this patch. However, after patch 4 of the series we cannot depend on the
skbdesc->desc_lenbeing set anymore, and we would have to depend on checking the QID anyway.
Note that in reality these two checks are completely equivalent with respect to the result.
Quoted 4 lines
Hmm, is that a good idea? I mean we are using the skbdesc inside the function, but we can't be sure that one of the basic values contains the right value?
To be honest, the chipset drivers don't need the skbdesc->desc and skbdesc->desc_len at all. Based on the queue ID they already have everything they need to know to write a descriptor. As far as I can tell the only code that really needs those two fields is the rt2x00debug code, to dump a frame to userspace via debugfs.
As the dumping through debugfs is done after writing the TX descriptor, with this patch I changed the desc and desc_len fields of the skbdesc to be output of the write_tx_desc function (for the generic parts of the rt2x00 code) rather than being input.
Note that originally my plan was to get rid of the desc and desc_len field altogether, but for now I refrained from doing that.
---
Gertjan.
Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
Quoted 61 lines · Gertjan van Wingerde
Quoted 50 lines · Ivo Van Doorn
Quoted 41 lines · Gertjan van Wingerde
Quoted 31 lines · Ivo Van Doorn
Quoted 29 lines · Gertjan van Wingerde
The 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.Signed-off-by Gertjan van Wingerde <[email protected]>---
drivers/net/wireless/rt2x00/rt61pci.c | 10 +++++-----1 files changed, 5 insertions(+), 5 deletions(-)drivers/net/wireless/rt2x00/rt61pci.c +5
-4@@ -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);Quoted 8 lines
drivers/net/wireless/rt2x00/rt61pci.c static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, · line 1812
Quoted 4 lines
drivers/net/wireless/rt2x00/rt61pci.c +0
-1- if (skbdesc->desc_len > TXINFO_SIZE) { rt2x00_desc_read(txd, 11, &word); rt2x00_set_field32(&word, TXD_W11_BUFFER_LENGTH0, txdesc->length);Shouldn't the check for
TXINFO_SIZEbe used rather than explicitly checking for the QID?Quoted 6 lines
I agree that this is a change that didn't have to be made in this patch. However, after patch 4 of the series we cannot depend on the
skbdesc->desc_lenbeing set anymore, and we would have to depend on checking the QID anyway.
Note that in reality these two checks are completely equivalent with respect to the result.Quoted 4 lines
Hmm, is that a good idea? I mean we are using the skbdesc inside the function, but we can't be sure that one of the basic values contains the right value?
To be honest, the chipset drivers don't need the
skbdesc->descandskbdesc->desc_lenat all. Based on the queue ID they already have everything they need to know to write a descriptor. As far as I can tell the only code that really needs those two fields is the rt2x00debug code, to dump a frame to userspace via debugfs.
Quoted 6 lines
As the dumping through debugfs is done after writing the TX descriptor, with this patch I changed the desc and
desc_lenfields of the skbdesc to be output of thewrite_tx_descfunction (for the generic parts of the rt2x00 code) rather than being input.Note that originally my plan was to get rid of the desc and
desc_lenfield altogether, but for now I refrained from doing that.
Ah ok. Thanks for the explanation.
Ivo
Re: [PATCH 2/9] rt2x00: Fix beacon descriptor writing for rt61pci.
In reply to Gertjan van WingerdeQuoted 7 lines · Gertjan van Wingerde
The 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.Signed-off-by Gertjan van Wingerde <[email protected]>
Re: [PATCH 8/9] rt2x00: Reverse calling order of bus write_tx_desc and driver write_tx_desc.
In reply to Ivo Van DoornQuoted 60 lines · Ivo Van Doorn
Quoted 58 lines · Gertjan van Wingerde
Quoted 56 lines · Ivo Van Doorn
Quoted 42 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, calledadd_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]>--- 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 +2
-10@@ -614,18 +614,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_add_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 ; }drivers/net/wireless/rt2x00/rt2800pci.c static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { · line 1079
Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2
-1@@ -1080,7 +1072,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, + .add_tx_datadesc = rt2800pci_add_tx_datadesc, .write_beacon = rt2800pci_write_beacon, .kick_tx_queue = rt2800pci_kick_tx_queue, .kill_tx_queue = rt2800pci_kill_tx_queue,Doesn't the name
write_tx_datadescmake more sense?
Quoted 9 lines
Quoted 3 lines
The names are equivalent to me. But if that name makes more sense to you then I have no problem with changing the name of the callback function.
Yes please rename it. That way it fits in the
write_tx_descwrite_tx_datawrite_tx_datadesc
OK. Will do.
---
Gertjan
Re: [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers.
In reply to Ivo Van DoornQuoted 83 lines · Ivo Van Doorn
Quoted 72 lines · Gertjan van Wingerde
Quoted 27 lines · Ivo Van Doorn
Quoted 25 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]>--- drivers/net/wireless/rt2x00/rt2400pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00debug.c | 1 + drivers/net/wireless/rt2x00/rt2x00queue.c | 10 +--------- drivers/net/wireless/rt2x00/rt61pci.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt73usb.c | 11 +++++++++++ 9 files changed, 89 insertions(+), 21 deletions(-)drivers/net/wireless/rt2x00/rt2400pci.c +0
-0@@ -33,6 +33,7 @@#include <linux/eeprom_93cx6.h> Quoted 7 lines
drivers/net/wireless/rt2x00/rt2400pci.c line 38
Quoted 4 lines
drivers/net/wireless/rt2x00/rt2400pci.c +1
-0#include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
rt2x00lib.hmust not be used in the drivers. It is for the rt2x00lib internal files only.OK. This include is/was necessary for the
rt2x00debug_dump_framecall. So this may be handled with your next issue.Quoted 15 lines
Quoted 15 lines
drivers/net/wireless/rt2x00/rt2400pci.c +0
-3@@ -1074,9 +1075,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 +1087,15 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,rt2x00queue_map_txskb (rt2x00dev, entry->skb);Quoted 17 lines
drivers/net/wireless/rt2x00/rt2400pci.c static void rt2400pci_write_beacon(struct queue_entry *entry, · line 1098
Quoted 12 lines
drivers/net/wireless/rt2x00/rt2400pci.c +9
-3-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);The goal for rt2x00debug was that the logic must be inside rt2x00lib as much as possible.
This can/should be moved into rt2x00lib wherewrite_beacon()is being called.Quoted 8 lines
Yes, I wasn't too happy about this part about the patch, but couldn't find a better solution. The problem is that with the patch the frame cannot be dumped before the call to
write_beacon, as the descriptor hasn't been set up yet. Also, it cannot be dumped after the call towrite_beaconas most of thewrite_beaconfunctions actually free the skb with the beacon.
So, I ran out of ideas as to how to keep rt2x00debug only inside rt2x00lib. I'm open for suggestions, though.
Quoted 4 lines
Well ok, if there aren't obvious alternatives this change is fine. However, please move the declaration of
rt2x00debug_dump_frame()intort2x00.h? That way we don't have to include thert2x00lib.hheader.
The only alternative I can think of is to have the chipset driver clone the skb to have a private copy of the skb, so that the original one can be freed in the generic code. In that case the rt2x00debug_dump_frame call can be done from rt2x00queue code, after the write_beacon function has been called.
What do you think of that solution?
---
Gertjan.
Re: [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers.
Quoted 89 lines · Gertjan van Wingerde
Quoted 83 lines · Ivo Van Doorn
Quoted 72 lines · Gertjan van Wingerde
Quoted 27 lines · Ivo Van Doorn
Quoted 25 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]>---
drivers/net/wireless/rt2x00/rt2400pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++drivers/net/wireless/rt2x00/rt2x00debug.c | 1 +
drivers/net/wireless/rt2x00/rt2x00queue.c| 10 +---------drivers/net/wireless/rt2x00/rt61pci.c| 11 +++++++++++drivers/net/wireless/rt2x00/rt73usb.c| 11 +++++++++++9 files changed, 89 insertions(+), 21 deletions(-)drivers/net/wireless/rt2x00/rt2400pci.c +0
-0@@ -33,6 +33,7 @@ #include <linux/eeprom_93cx6.h>Quoted 7 lines
drivers/net/wireless/rt2x00/rt2400pci.c line 38
Quoted 4 lines
drivers/net/wireless/rt2x00/rt2400pci.c +1
-0#include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
rt2x00lib.hmust not be used in the drivers. It is for the rt2x00lib internal files only.OK. This include is/was necessary for the
rt2x00debug_dump_framecall. So this may be handled with your next issue.Quoted 15 lines
Quoted 15 lines
drivers/net/wireless/rt2x00/rt2400pci.c +0
-3@@ -1074,9 +1075,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 +1087,15 @@ static void rt2400pci_write_beacon(struct queue_entry *entry, rt2x00queue_map_txskb(rt2x00dev, entry->skb);Quoted 17 lines
drivers/net/wireless/rt2x00/rt2400pci.c static void rt2400pci_write_beacon(struct queue_entry *entry, · line 1098
Quoted 12 lines
drivers/net/wireless/rt2x00/rt2400pci.c +9
-3- 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);The goal for rt2x00debug was that the logic must be inside rt2x00lib as much as possible.
This can/should be moved into rt2x00lib wherewrite_beacon()is being called.Quoted 8 lines
Yes, I wasn't too happy about this part about the patch, but couldn't find a better solution. The problem is that with the patch the frame cannot be dumped before the call to
write_beacon, as the descriptor hasn't been set up yet. Also, it cannot be dumped after the call towrite_beaconas most of thewrite_beaconfunctions actually free the skb with the beacon.
So, I ran out of ideas as to how to keep rt2x00debug only inside rt2x00lib. I'm open for suggestions, though.Quoted 4 lines
Well ok, if there aren't obvious alternatives this change is fine. However, please move the declaration of
rt2x00debug_dump_frame()intort2x00.h? That way we don't have to include thert2x00lib.hheader.
Quoted 6 lines
The only alternative I can think of is to have the chipset driver clone the skb to have a private copy of the skb, so that the original one can be freed in the generic code. In that case the
rt2x00debug_dump_framecall can be done from rt2x00queue code, after thewrite_beaconfunction has been called.What do you think of that solution?
I think the extra cloning isn't really worth the effort. Since it is only needed for debugfs,
so the code in rt2x00queue must check for debugfs support, and debugfs code must be updated not to clone the frame again.
Overall I think it is in this case better to just do your change with calling the debugfs function from the driver, but moving the declaration of the function into rt2x00.h to prevent the inclusion of rt2x00lib.h into the drivers.
Ivo
Re: [PATCH 6/9] rt2x00: Push beacon TX descriptor writing to drivers.
Quoted 98 lines · Ivo Van Doorn
Quoted 89 lines · Gertjan van Wingerde
Quoted 83 lines · Ivo Van Doorn
Quoted 72 lines · Gertjan van Wingerde
Quoted 27 lines · Ivo Van Doorn
Quoted 25 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]>--- drivers/net/wireless/rt2x00/rt2400pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500pci.c | 16 ++++++++++------ drivers/net/wireless/rt2x00/rt2500usb.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt2800pci.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2800usb.c | 17 +++++++++++++++++ drivers/net/wireless/rt2x00/rt2x00debug.c | 1 + drivers/net/wireless/rt2x00/rt2x00queue.c | 10 +--------- drivers/net/wireless/rt2x00/rt61pci.c | 11 +++++++++++ drivers/net/wireless/rt2x00/rt73usb.c | 11 +++++++++++ 9 files changed, 89 insertions(+), 21 deletions(-)drivers/net/wireless/rt2x00/rt2400pci.c +0
-0@@ -33,6 +33,7 @@#include <linux/eeprom_93cx6.h> Quoted 7 lines
drivers/net/wireless/rt2x00/rt2400pci.c line 38
Quoted 4 lines
drivers/net/wireless/rt2x00/rt2400pci.c +1
-0#include "rt2x00.h" +#include "rt2x00lib.h" #include "rt2x00pci.h" #include "rt2400pci.h"
rt2x00lib.hmust not be used in the drivers. It is for the rt2x00lib internal files only.OK. This include is/was necessary for the
rt2x00debug_dump_framecall. So this may be handled with your next issue.Quoted 15 lines
Quoted 15 lines
drivers/net/wireless/rt2x00/rt2400pci.c +0
-3@@ -1074,9 +1075,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 +1087,15 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,rt2x00queue_map_txskb (rt2x00dev, entry->skb);Quoted 17 lines
drivers/net/wireless/rt2x00/rt2400pci.c static void rt2400pci_write_beacon(struct queue_entry *entry, · line 1098
Quoted 12 lines
drivers/net/wireless/rt2x00/rt2400pci.c +9
-3-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);The goal for rt2x00debug was that the logic must be inside rt2x00lib as much as possible.
This can/should be moved into rt2x00lib wherewrite_beacon()is being called.Quoted 8 lines
Yes, I wasn't too happy about this part about the patch, but couldn't find a better solution. The problem is that with the patch the frame cannot be dumped before the call to
write_beacon, as the descriptor hasn't been set up yet. Also, it cannot be dumped after the call towrite_beaconas most of thewrite_beaconfunctions actually free the skb with the beacon.
So, I ran out of ideas as to how to keep rt2x00debug only inside rt2x00lib. I'm open for suggestions, though.Quoted 4 lines
Well ok, if there aren't obvious alternatives this change is fine. However, please move the declaration of
rt2x00debug_dump_frame()intort2x00.h? That way we don't have to include thert2x00lib.hheader.Quoted 6 lines
The only alternative I can think of is to have the chipset driver clone the skb to have a private copy of the skb, so that the original one can be freed in the generic code. In that case the
rt2x00debug_dump_framecall can be done from rt2x00queue code, after thewrite_beaconfunction has been called.What do you think of that solution?
Quoted 9 lines
I think the extra cloning isn't really worth the effort. Since it is only needed for debugfs,
so the code in rt2x00queue must check for debugfs support, and debugfs code must be updated not to clone the frame again.Overall I think it is in this case better to just do your change with calling the debugfs function from the driver, but moving the declaration of the function into
rt2x00.hto prevent the inclusion ofrt2x00lib.hinto the drivers.
OK. I'll move the declaration to rt2x00.h.
---
Gertjan.