提交 fb55f4d1 编写于 作者: I Ivo van Doorn 提交者: John W. Linville

rt2x00: Fix TX status reporting

The tx_status enumeration was broken since the introduction
of rt61pci. That driver uses different values to report the
status of the tx action.
This would lead to frames that were reported as success but
actually failed to be send out, or frames that were neither
successfull or failure which were reported as failure.

Fix this by change the TX status reporting and more explicitely
check for failure or success. Note that a third possibility is
added "unknown". Not all hardware (USB) can report the actual
TX status, for rt61pci some frames will receive this status
because the TXdone handler is never called for those frames.
This unknown will now be handled as neither success or failure,
so we no longer increment the failure counter while this conclusion
could not be determined from the real status of the frame.
Signed-off-by: NIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 5a6e5999
...@@ -1137,7 +1137,18 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev, ...@@ -1137,7 +1137,18 @@ static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev,
/* /*
* Obtain the status about this packet. * Obtain the status about this packet.
*/ */
txdesc.status = rt2x00_get_field32(word, TXD_W0_RESULT); txdesc.flags = 0;
switch (rt2x00_get_field32(word, TXD_W0_RESULT)) {
case 0: /* Success */
case 1: /* Success with retry */
__set_bit(TXDONE_SUCCESS, &txdesc.flags);
break;
case 2: /* Failure, excessive retries */
__set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags);
/* Don't break, this is a failed frame! */
default: /* Failure */
__set_bit(TXDONE_FAILURE, &txdesc.flags);
}
txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT); txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT);
rt2x00pci_txdone(rt2x00dev, entry, &txdesc); rt2x00pci_txdone(rt2x00dev, entry, &txdesc);
......
...@@ -1292,7 +1292,18 @@ static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev, ...@@ -1292,7 +1292,18 @@ static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev,
/* /*
* Obtain the status about this packet. * Obtain the status about this packet.
*/ */
txdesc.status = rt2x00_get_field32(word, TXD_W0_RESULT); txdesc.flags = 0;
switch (rt2x00_get_field32(word, TXD_W0_RESULT)) {
case 0: /* Success */
case 1: /* Success with retry */
__set_bit(TXDONE_SUCCESS, &txdesc.flags);
break;
case 2: /* Failure, excessive retries */
__set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags);
/* Don't break, this is a failed frame! */
default: /* Failure */
__set_bit(TXDONE_FAILURE, &txdesc.flags);
}
txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT); txdesc.retry = rt2x00_get_field32(word, TXD_W0_RETRY_COUNT);
rt2x00pci_txdone(rt2x00dev, entry, &txdesc); rt2x00pci_txdone(rt2x00dev, entry, &txdesc);
......
...@@ -496,38 +496,36 @@ void rt2x00lib_txdone(struct queue_entry *entry, ...@@ -496,38 +496,36 @@ void rt2x00lib_txdone(struct queue_entry *entry,
struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
struct skb_frame_desc *skbdesc; struct skb_frame_desc *skbdesc;
struct ieee80211_tx_status tx_status; struct ieee80211_tx_status tx_status;
int success = !!(txdesc->status == TX_SUCCESS ||
txdesc->status == TX_SUCCESS_RETRY);
int fail = !!(txdesc->status == TX_FAIL_RETRY ||
txdesc->status == TX_FAIL_INVALID ||
txdesc->status == TX_FAIL_OTHER);
/* /*
* Update TX statistics. * Update TX statistics.
*/ */
rt2x00dev->link.qual.tx_success += success; rt2x00dev->link.qual.tx_success +=
rt2x00dev->link.qual.tx_failed += txdesc->retry + fail; test_bit(TXDONE_SUCCESS, &txdesc->flags);
rt2x00dev->link.qual.tx_failed +=
txdesc->retry + !!test_bit(TXDONE_FAILURE, &txdesc->flags);
/* /*
* Initialize TX status * Initialize TX status
*/ */
tx_status.flags = 0; tx_status.flags = 0;
tx_status.ack_signal = 0; tx_status.ack_signal = 0;
tx_status.excessive_retries = (txdesc->status == TX_FAIL_RETRY); tx_status.excessive_retries =
test_bit(TXDONE_EXCESSIVE_RETRY, &txdesc->flags);
tx_status.retry_count = txdesc->retry; tx_status.retry_count = txdesc->retry;
memcpy(&tx_status.control, txdesc->control, sizeof(*txdesc->control)); memcpy(&tx_status.control, txdesc->control, sizeof(*txdesc->control));
if (!(tx_status.control.flags & IEEE80211_TXCTL_NO_ACK)) { if (!(tx_status.control.flags & IEEE80211_TXCTL_NO_ACK)) {
if (success) if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
tx_status.flags |= IEEE80211_TX_STATUS_ACK; tx_status.flags |= IEEE80211_TX_STATUS_ACK;
else else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
rt2x00dev->low_level_stats.dot11ACKFailureCount++; rt2x00dev->low_level_stats.dot11ACKFailureCount++;
} }
if (tx_status.control.flags & IEEE80211_TXCTL_USE_RTS_CTS) { if (tx_status.control.flags & IEEE80211_TXCTL_USE_RTS_CTS) {
if (success) if (test_bit(TXDONE_SUCCESS, &txdesc->flags))
rt2x00dev->low_level_stats.dot11RTSSuccessCount++; rt2x00dev->low_level_stats.dot11RTSSuccessCount++;
else else if (test_bit(TXDONE_FAILURE, &txdesc->flags))
rt2x00dev->low_level_stats.dot11RTSFailureCount++; rt2x00dev->low_level_stats.dot11RTSFailureCount++;
} }
...@@ -546,7 +544,7 @@ void rt2x00lib_txdone(struct queue_entry *entry, ...@@ -546,7 +544,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
ieee80211_tx_status_irqsafe(rt2x00dev->hw, ieee80211_tx_status_irqsafe(rt2x00dev->hw,
entry->skb, &tx_status); entry->skb, &tx_status);
else else
dev_kfree_skb(entry->skb); dev_kfree_skb_irq(entry->skb);
entry->skb = NULL; entry->skb = NULL;
} }
EXPORT_SYMBOL_GPL(rt2x00lib_txdone); EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
......
...@@ -167,6 +167,22 @@ struct rxdone_entry_desc { ...@@ -167,6 +167,22 @@ struct rxdone_entry_desc {
int dev_flags; int dev_flags;
}; };
/**
* enum txdone_entry_desc_flags: Flags for &struct txdone_entry_desc
*
* @TXDONE_UNKNOWN: Hardware could not determine success of transmission.
* @TXDONE_SUCCESS: Frame was successfully send
* @TXDONE_FAILURE: Frame was not successfully send
* @TXDONE_EXCESSIVE_RETRY: In addition to &TXDONE_FAILURE, the
* frame transmission failed due to excessive retries.
*/
enum txdone_entry_desc_flags {
TXDONE_UNKNOWN = 1 << 0,
TXDONE_SUCCESS = 1 << 1,
TXDONE_FAILURE = 1 << 2,
TXDONE_EXCESSIVE_RETRY = 1 << 3,
};
/** /**
* struct txdone_entry_desc: TX done entry descriptor * struct txdone_entry_desc: TX done entry descriptor
* *
...@@ -174,12 +190,12 @@ struct rxdone_entry_desc { ...@@ -174,12 +190,12 @@ struct rxdone_entry_desc {
* after the device is done with transmission. * after the device is done with transmission.
* *
* @control: Control structure which was used to transmit the frame. * @control: Control structure which was used to transmit the frame.
* @status: TX status (See &enum tx_status). * @flags: TX done flags (See &enum txdone_entry_desc_flags).
* @retry: Retry count. * @retry: Retry count.
*/ */
struct txdone_entry_desc { struct txdone_entry_desc {
struct ieee80211_tx_control *control; struct ieee80211_tx_control *control;
int status; unsigned long flags;
int retry; int retry;
}; };
......
...@@ -26,17 +26,6 @@ ...@@ -26,17 +26,6 @@
#ifndef RT2X00REG_H #ifndef RT2X00REG_H
#define RT2X00REG_H #define RT2X00REG_H
/*
* TX result flags.
*/
enum tx_status {
TX_SUCCESS = 0,
TX_SUCCESS_RETRY = 1,
TX_FAIL_RETRY = 2,
TX_FAIL_INVALID = 3,
TX_FAIL_OTHER = 4,
};
/* /*
* Antenna values * Antenna values
*/ */
......
...@@ -147,8 +147,17 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb) ...@@ -147,8 +147,17 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
/* /*
* Obtain the status about this packet. * 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
* was succesfully pushed to the hardware, we have no
* way to determine the transmission status right now.
* (Only indirectly by looking at the failed TX counters
* in the register).
*/ */
txdesc.status = !urb->status ? TX_SUCCESS : TX_FAIL_RETRY; if (!urb->status)
__set_bit(TXDONE_UNKNOWN, &txdesc.flags);
else
__set_bit(TXDONE_FAILURE, &txdesc.flags);
txdesc.retry = 0; txdesc.retry = 0;
txdesc.control = &priv_tx->control; txdesc.control = &priv_tx->control;
......
...@@ -1764,7 +1764,8 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) ...@@ -1764,7 +1764,8 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev)
"TX status report missed for entry %d\n", "TX status report missed for entry %d\n",
entry_done->entry_idx); entry_done->entry_idx);
txdesc.status = TX_FAIL_OTHER; txdesc.flags = 0;
__set_bit(TXDONE_UNKNOWN, &txdesc.flags);
txdesc.retry = 0; txdesc.retry = 0;
rt2x00pci_txdone(rt2x00dev, entry_done, &txdesc); rt2x00pci_txdone(rt2x00dev, entry_done, &txdesc);
...@@ -1774,7 +1775,17 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev) ...@@ -1774,7 +1775,17 @@ static void rt61pci_txdone(struct rt2x00_dev *rt2x00dev)
/* /*
* Obtain the status about this packet. * Obtain the status about this packet.
*/ */
txdesc.status = rt2x00_get_field32(reg, STA_CSR4_TX_RESULT); txdesc.flags = 0;
switch (rt2x00_get_field32(reg, STA_CSR4_TX_RESULT)) {
case 0: /* Success, maybe with retry */
__set_bit(TXDONE_SUCCESS, &txdesc.flags);
break;
case 6: /* Failure, excessive retries */
__set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags);
/* Don't break, this is a failed frame! */
default: /* Failure */
__set_bit(TXDONE_FAILURE, &txdesc.flags);
}
txdesc.retry = rt2x00_get_field32(reg, STA_CSR4_RETRY_COUNT); txdesc.retry = rt2x00_get_field32(reg, STA_CSR4_RETRY_COUNT);
rt2x00pci_txdone(rt2x00dev, entry, &txdesc); rt2x00pci_txdone(rt2x00dev, entry, &txdesc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册