rt2x00: Factor out RXWI processing to common rt2800 code.

RXWI processing is exactly the same for rt2800pci and rt2800usb, so
make it common code.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Gertjan van Wingerde 2010-05-08 23:40:22 +02:00 committed by John W. Linville
parent 59679b91d1
commit 2de64dd22d
4 changed files with 85 additions and 103 deletions

View File

@ -335,6 +335,50 @@ void rt2800_write_txwi(struct sk_buff *skb, struct txentry_desc *txdesc)
} }
EXPORT_SYMBOL_GPL(rt2800_write_txwi); EXPORT_SYMBOL_GPL(rt2800_write_txwi);
void rt2800_process_rxwi(struct sk_buff *skb, struct rxdone_entry_desc *rxdesc)
{
__le32 *rxwi = (__le32 *) skb->data;
u32 word;
rt2x00_desc_read(rxwi, 0, &word);
rxdesc->cipher = rt2x00_get_field32(word, RXWI_W0_UDF);
rxdesc->size = rt2x00_get_field32(word, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
rt2x00_desc_read(rxwi, 1, &word);
if (rt2x00_get_field32(word, RXWI_W1_SHORT_GI))
rxdesc->flags |= RX_FLAG_SHORT_GI;
if (rt2x00_get_field32(word, RXWI_W1_BW))
rxdesc->flags |= RX_FLAG_40MHZ;
/*
* Detect RX rate, always use MCS as signal type.
*/
rxdesc->dev_flags |= RXDONE_SIGNAL_MCS;
rxdesc->signal = rt2x00_get_field32(word, RXWI_W1_MCS);
rxdesc->rate_mode = rt2x00_get_field32(word, RXWI_W1_PHYMODE);
/*
* Mask of 0x8 bit to remove the short preamble flag.
*/
if (rxdesc->rate_mode == RATE_MODE_CCK)
rxdesc->signal &= ~0x8;
rt2x00_desc_read(rxwi, 2, &word);
rxdesc->rssi =
(rt2x00_get_field32(word, RXWI_W2_RSSI0) +
rt2x00_get_field32(word, RXWI_W2_RSSI1)) / 2;
/*
* Remove RXWI descriptor from start of buffer.
*/
skb_pull(skb, RXWI_DESC_SIZE);
}
EXPORT_SYMBOL_GPL(rt2800_process_rxwi);
#ifdef CONFIG_RT2X00_LIB_DEBUGFS #ifdef CONFIG_RT2X00_LIB_DEBUGFS
const struct rt2x00debug rt2800_rt2x00debug = { const struct rt2x00debug rt2800_rt2x00debug = {
.owner = THIS_MODULE, .owner = THIS_MODULE,

View File

@ -112,6 +112,7 @@ void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
const u8 arg0, const u8 arg1); const u8 arg0, const u8 arg1);
void rt2800_write_txwi(struct sk_buff *skb, struct txentry_desc *txdesc); void rt2800_write_txwi(struct sk_buff *skb, struct txentry_desc *txdesc);
void rt2800_process_rxwi(struct sk_buff *skb, struct rxdone_entry_desc *txdesc);
extern const struct rt2x00debug rt2800_rt2x00debug; extern const struct rt2x00debug rt2800_rt2x00debug;

View File

@ -770,20 +770,11 @@ static void rt2800pci_fill_rxdone(struct queue_entry *entry,
struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
struct queue_entry_priv_pci *entry_priv = entry->priv_data; struct queue_entry_priv_pci *entry_priv = entry->priv_data;
__le32 *rxd = entry_priv->desc; __le32 *rxd = entry_priv->desc;
__le32 *rxwi = (__le32 *)entry->skb->data; u32 word;
u32 rxd3;
u32 rxwi0;
u32 rxwi1;
u32 rxwi2;
u32 rxwi3;
rt2x00_desc_read(rxd, 3, &rxd3); rt2x00_desc_read(rxd, 3, &word);
rt2x00_desc_read(rxwi, 0, &rxwi0);
rt2x00_desc_read(rxwi, 1, &rxwi1);
rt2x00_desc_read(rxwi, 2, &rxwi2);
rt2x00_desc_read(rxwi, 3, &rxwi3);
if (rt2x00_get_field32(rxd3, RXD_W3_CRC_ERROR)) if (rt2x00_get_field32(word, RXD_W3_CRC_ERROR))
rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
/* /*
@ -791,10 +782,9 @@ static void rt2800pci_fill_rxdone(struct queue_entry *entry,
* decryption. This prevents us from correct providing * decryption. This prevents us from correct providing
* correct statistics through debugfs. * correct statistics through debugfs.
*/ */
rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF); rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W3_CIPHER_ERROR);
rxdesc->cipher_status = rt2x00_get_field32(rxd3, RXD_W3_CIPHER_ERROR);
if (rt2x00_get_field32(rxd3, RXD_W3_DECRYPTED)) { if (rt2x00_get_field32(word, RXD_W3_DECRYPTED)) {
/* /*
* Hardware has stripped IV/EIV data from 802.11 frame during * Hardware has stripped IV/EIV data from 802.11 frame during
* decryption. Unfortunately the descriptor doesn't contain * decryption. Unfortunately the descriptor doesn't contain
@ -809,47 +799,22 @@ static void rt2800pci_fill_rxdone(struct queue_entry *entry,
rxdesc->flags |= RX_FLAG_MMIC_ERROR; rxdesc->flags |= RX_FLAG_MMIC_ERROR;
} }
if (rt2x00_get_field32(rxd3, RXD_W3_MY_BSS)) if (rt2x00_get_field32(word, RXD_W3_MY_BSS))
rxdesc->dev_flags |= RXDONE_MY_BSS; rxdesc->dev_flags |= RXDONE_MY_BSS;
if (rt2x00_get_field32(rxd3, RXD_W3_L2PAD)) if (rt2x00_get_field32(word, RXD_W3_L2PAD))
rxdesc->dev_flags |= RXDONE_L2PAD; rxdesc->dev_flags |= RXDONE_L2PAD;
if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
rxdesc->flags |= RX_FLAG_SHORT_GI;
if (rt2x00_get_field32(rxwi1, RXWI_W1_BW))
rxdesc->flags |= RX_FLAG_40MHZ;
/* /*
* Detect RX rate, always use MCS as signal type. * Process the RXWI structure that is at the start of the buffer.
*/ */
rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; rt2800_process_rxwi(entry->skb, rxdesc);
rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
/*
* Mask of 0x8 bit to remove the short preamble flag.
*/
if (rxdesc->rate_mode == RATE_MODE_CCK)
rxdesc->signal &= ~0x8;
rxdesc->rssi =
(rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2;
rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
/* /*
* Set RX IDX in register to inform hardware that we have handled * Set RX IDX in register to inform hardware that we have handled
* this entry and it is available for reuse again. * this entry and it is available for reuse again.
*/ */
rt2800_register_write(rt2x00dev, RX_CRX_IDX, entry->entry_idx); rt2800_register_write(rt2x00dev, RX_CRX_IDX, entry->entry_idx);
/*
* Remove TXWI descriptor from start of buffer.
*/
skb_pull(entry->skb, RXWI_DESC_SIZE);
} }
/* /*

View File

@ -507,53 +507,45 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
{ {
struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
__le32 *rxi = (__le32 *)entry->skb->data; __le32 *rxi = (__le32 *)entry->skb->data;
__le32 *rxwi;
__le32 *rxd; __le32 *rxd;
u32 rxi0; u32 word;
u32 rxwi0;
u32 rxwi1;
u32 rxwi2;
u32 rxwi3;
u32 rxd0;
int rx_pkt_len; int rx_pkt_len;
/*
* RX frame format is :
* | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad |
* |<------------ rx_pkt_len -------------->|
*/
rt2x00_desc_read(rxi, 0, &rxi0);
rx_pkt_len = rt2x00_get_field32(rxi0, RXINFO_W0_USB_DMA_RX_PKT_LEN);
rxwi = (__le32 *)(entry->skb->data + RXINFO_DESC_SIZE);
/*
* FIXME : we need to check for rx_pkt_len validity
*/
rxd = (__le32 *)(entry->skb->data + RXINFO_DESC_SIZE + rx_pkt_len);
/* /*
* Copy descriptor to the skbdesc->desc buffer, making it safe from * Copy descriptor to the skbdesc->desc buffer, making it safe from
* moving of frame data in rt2x00usb. * moving of frame data in rt2x00usb.
*/ */
memcpy(skbdesc->desc, rxi, skbdesc->desc_len); memcpy(skbdesc->desc, rxi, skbdesc->desc_len);
/*
* RX frame format is :
* | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad |
* |<------------ rx_pkt_len -------------->|
*/
rt2x00_desc_read(rxi, 0, &word);
rx_pkt_len = rt2x00_get_field32(word, RXINFO_W0_USB_DMA_RX_PKT_LEN);
/*
* Remove the RXINFO structure from the sbk.
*/
skb_pull(entry->skb, RXINFO_DESC_SIZE);
/*
* FIXME: we need to check for rx_pkt_len validity
*/
rxd = (__le32 *)(entry->skb->data + rx_pkt_len);
/* /*
* It is now safe to read the descriptor on all architectures. * It is now safe to read the descriptor on all architectures.
*/ */
rt2x00_desc_read(rxwi, 0, &rxwi0); rt2x00_desc_read(rxd, 0, &word);
rt2x00_desc_read(rxwi, 1, &rxwi1);
rt2x00_desc_read(rxwi, 2, &rxwi2);
rt2x00_desc_read(rxwi, 3, &rxwi3);
rt2x00_desc_read(rxd, 0, &rxd0);
if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR)) if (rt2x00_get_field32(word, RXD_W0_CRC_ERROR))
rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
rxdesc->cipher = rt2x00_get_field32(rxwi0, RXWI_W0_UDF); rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W0_CIPHER_ERROR);
rxdesc->cipher_status = rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) { if (rt2x00_get_field32(word, RXD_W0_DECRYPTED)) {
/* /*
* Hardware has stripped IV/EIV data from 802.11 frame during * Hardware has stripped IV/EIV data from 802.11 frame during
* decryption. Unfortunately the descriptor doesn't contain * decryption. Unfortunately the descriptor doesn't contain
@ -568,41 +560,21 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
rxdesc->flags |= RX_FLAG_MMIC_ERROR; rxdesc->flags |= RX_FLAG_MMIC_ERROR;
} }
if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS)) if (rt2x00_get_field32(word, RXD_W0_MY_BSS))
rxdesc->dev_flags |= RXDONE_MY_BSS; rxdesc->dev_flags |= RXDONE_MY_BSS;
if (rt2x00_get_field32(rxd0, RXD_W0_L2PAD)) if (rt2x00_get_field32(word, RXD_W0_L2PAD))
rxdesc->dev_flags |= RXDONE_L2PAD; rxdesc->dev_flags |= RXDONE_L2PAD;
if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI)) /*
rxdesc->flags |= RX_FLAG_SHORT_GI; * Remove RXD descriptor from end of buffer.
*/
if (rt2x00_get_field32(rxwi1, RXWI_W1_BW)) skb_trim(entry->skb, rx_pkt_len);
rxdesc->flags |= RX_FLAG_40MHZ;
/* /*
* Detect RX rate, always use MCS as signal type. * Process the RXWI structure.
*/ */
rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; rt2800_process_rxwi(entry->skb, rxdesc);
rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
/*
* Mask of 0x8 bit to remove the short preamble flag.
*/
if (rxdesc->rate_mode == RATE_MODE_CCK)
rxdesc->signal &= ~0x8;
rxdesc->rssi =
(rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2;
rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
/*
* Remove RXWI descriptor from start of buffer.
*/
skb_pull(entry->skb, skbdesc->desc_len);
} }
/* /*