- * Update TX statistics.
- */
- tx_status->flags = 0;
- tx_status->ack_signal = 0;
- tx_status->excessive_retries = (status == TX_FAIL_RETRY);
- tx_status->retry_count = retry;
-
- if (!(tx_status->control.flags & IEEE80211_TXCTL_NO_ACK)) {
- if (status == TX_SUCCESS || status == TX_SUCCESS_RETRY)
- tx_status->flags |= IEEE80211_TX_STATUS_ACK;
- else
- stats->dot11ACKFailureCount++;
- }
-
- tx_status->queue_length = entry->ring->stats.limit;
- tx_status->queue_number = tx_status->control.queue;
-
- if (tx_status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) {
- if (status == TX_SUCCESS || status == TX_SUCCESS_RETRY)
- stats->dot11RTSSuccessCount++;
- else
- stats->dot11RTSFailureCount++;
- }
-
- /*
- * Send the tx_status to mac80211,
- * that method also cleans up the skb structure.
- */
- ieee80211_tx_status_irqsafe(rt2x00dev->hw, entry->skb, tx_status);
-
- entry->skb = NULL;
-}
-EXPORT_SYMBOL_GPL(rt2x00lib_txdone);
-
-void rt2x00lib_rxdone(struct data_entry *entry, char *data,
- const int size, const int signal, const int rssi, const int ofdm)
-{
- struct rt2x00_dev *rt2x00dev = entry->ring->rt2x00dev;
- struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
- struct ieee80211_hw_mode *mode;
- struct ieee80211_rate *rate;
- struct sk_buff *skb;
- unsigned int i;
- int val = 0;
-
- /*
- * Update RX statistics.
- */
- mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode];
- for (i = 0; i < mode->num_rates; i++) {
- rate = &mode->rates[i];
-
- /*
- * When frame was received with an OFDM bitrate,
- * the signal is the PLCP value. If it was received with
- * a CCK bitrate the signal is the rate in 0.5kbit/s.
- */
- if (!ofdm)
- val = DEVICE_GET_RATE_FIELD(rate->val, RATE);
- else
- val = DEVICE_GET_RATE_FIELD(rate->val, PLCP);
-
- if (val == signal) {
- /*
- * Check for preamble bit.
- */
- if (signal & 0x08)
- val = rate->val2;
- else
- val = rate->val;
- break;
- }
- }
-
- rx_status->rate = val;
- rx_status->ssi = rssi;
- rt2x00_update_link_rssi(&rt2x00dev->link, rssi);
-
- /*
- * Let's allocate a sk_buff where we can store the received data in,
- * note that if data is NULL, we still have to allocate a sk_buff
- * but that we should use that to replace the sk_buff which is already
- * inside the entry.
- */
- skb = dev_alloc_skb(size + NET_IP_ALIGN);
- if (!skb)
- return;
-
- skb_reserve(skb, NET_IP_ALIGN);
- skb_put(skb, size);
-
- if (data) {
- memcpy(skb->data, data, size);
- entry->skb = skb;
- skb = NULL;
- }
-
- ieee80211_rx_irqsafe(rt2x00dev->hw, entry->skb, rx_status);
- entry->skb = skb;
-}
-EXPORT_SYMBOL_GPL(rt2x00lib_rxdone);
-
-/*
- * TX descriptor initializer
- */
-void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
- struct data_entry *entry, struct data_desc *txd,
- struct ieee80211_hdr *ieee80211hdr, unsigned int length,
- struct ieee80211_tx_control *control)
-{
- struct data_entry_desc desc;
- int tx_rate;
- int bitrate;
- int duration;
- int residual;
- u16 frame_control;
- u16 seq_ctrl;
-
- /*
- * Identify queue
- */
- if (control->queue < rt2x00dev->hw->queues)
- desc.queue = control->queue;
- else
- desc.queue = 15;
-
- /*
- * Read required fields from ieee80211 header.
- */
- frame_control = le16_to_cpu(ieee80211hdr->frame_control);
- seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl);
-
- tx_rate = control->tx_rate;
-
- /*
- * Check if this is a rts frame