spin_lock_irqsave(&tx->sta->lock, flags);
state = &tx->sta->ampdu_mlme.tid_state_tx[tid];
- if (*state == HT_AGG_STATE_OPERATIONAL) {
+ if (*state == HT_AGG_STATE_OPERATIONAL)
info->flags |= IEEE80211_TX_CTL_AMPDU;
- if (local->hw.ampdu_queues)
- skb_set_queue_mapping(
- skb, tx->local->hw.queues +
- tx->sta->tid_to_tx_q[tid]);
- }
spin_unlock_irqrestore(&tx->sta->lock, flags);
}
}
static int __ieee80211_tx(struct ieee80211_local *local,
- struct ieee80211_tx_data *tx)
+ struct sk_buff **skbp,
+ struct sta_info *sta)
{
- struct sk_buff *skb = tx->skb, *next;
+ struct sk_buff *skb = *skbp, *next;
struct ieee80211_tx_info *info;
int ret;
bool fragm = false;
skb_get_queue_mapping(skb)))
return IEEE80211_TX_PENDING;
- if (fragm) {
- info = IEEE80211_SKB_CB(skb);
+ info = IEEE80211_SKB_CB(skb);
+
+ if (fragm)
info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT |
IEEE80211_TX_CTL_FIRST_FRAGMENT);
+
+ /*
+ * Internally, we need to have the queue mapping point to
+ * the real AC queue, not the virtual A-MPDU queue. This
+ * now finally sets the queue to what the driver wants.
+ * We will later move this down into the only driver that
+ * needs it, iwlwifi.
+ */
+ if (sta && local->hw.ampdu_queues &&
+ info->flags & IEEE80211_TX_CTL_AMPDU) {
+ unsigned long flags;
+ u8 *qc = ieee80211_get_qos_ctl((void *) skb->data);
+ int tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
+
+ spin_lock_irqsave(&sta->lock, flags);
+ skb_set_queue_mapping(skb, local->hw.queues +
+ sta->tid_to_tx_q[tid]);
+ spin_unlock_irqrestore(&sta->lock, flags);
}
next = skb->next;
ret = local->ops->tx(local_to_hw(local), skb);
if (ret != NETDEV_TX_OK)
return IEEE80211_TX_AGAIN;
- tx->skb = skb = next;
+ *skbp = skb = next;
ieee80211_led_tx(local, 1);
fragm = true;
}
struct ieee80211_tx_data tx;
ieee80211_tx_result res_prepare;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- int ret;
+ struct sk_buff *next;
+ unsigned long flags;
+ int ret, retries;
u16 queue;
queue = skb_get_queue_mapping(skb);
- WARN_ON(test_bit(queue, local->queues_pending));
+ WARN_ON(!skb_queue_empty(&local->pending[queue]));
if (unlikely(skb->len < 10)) {
dev_kfree_skb(skb);
if (invoke_tx_handlers(&tx))
goto out;
-retry:
- ret = __ieee80211_tx(local, &tx);
- if (ret) {
- struct ieee80211_tx_stored_packet *store;
-
+ retries = 0;
+ retry:
+ ret = __ieee80211_tx(local, &tx.skb, tx.sta);
+ switch (ret) {
+ case IEEE80211_TX_OK:
+ break;
+ case IEEE80211_TX_AGAIN:
/*
* Since there are no fragmented frames on A-MPDU
* queues, there's no reason for a driver to reject
* a frame there, warn and drop it.
*/
- if (ret != IEEE80211_TX_PENDING)
- if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
- goto drop;
+ if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU))
+ goto drop;
+ /* fall through */
+ case IEEE80211_TX_PENDING:
+ skb = tx.skb;
- store = &local->pending_packet[queue];
+ spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
- set_bit(queue, local->queues_pending);
- smp_mb();
- /*
- * When the driver gets out of buffers during sending of
- * fragments and calls ieee80211_stop_queue, the netif
- * subqueue is stopped. There is, however, a small window
- * in which the PENDING bit is not yet set. If a buffer
- * gets available in that window (i.e. driver calls
- * ieee80211_wake_queue), we would end up with ieee80211_tx
- * called with the PENDING bit still set. Prevent this by
- * continuing transmitting here when that situation is
- * possible to have happened.
- */
- if (!__netif_subqueue_stopped(local->mdev, queue)) {
- clear_bit(queue, local->queues_pending);
+ if (__netif_subqueue_stopped(local->mdev, queue)) {
+ do {
+ next = skb->next;
+ skb->next = NULL;
+ skb_queue_tail(&local->pending[queue], skb);
+ } while ((skb = next));
+
+ /*
+ * Make sure nobody will enable the queue on us
+ * (without going through the tasklet) nor disable the
+ * netdev queue underneath the pending handling code.
+ */
+ __set_bit(IEEE80211_QUEUE_STOP_REASON_PENDING,
+ &local->queue_stop_reasons[queue]);
+
+ spin_unlock_irqrestore(&local->queue_stop_reason_lock,
+ flags);
+ } else {
+ spin_unlock_irqrestore(&local->queue_stop_reason_lock,
+ flags);
+
+ retries++;
+ if (WARN(retries > 10, "tx refused but queue active"))
+ goto drop;
goto retry;
}
- store->skb = tx.skb;
}
out:
rcu_read_unlock();
skb = tx.skb;
while (skb) {
- struct sk_buff *next;
-
next = skb->next;
dev_kfree_skb(skb);
skb = next;
*/
void ieee80211_clear_tx_pending(struct ieee80211_local *local)
{
- struct sk_buff *skb;
int i;
- for (i = 0; i < local->hw.queues; i++) {
- if (!test_bit(i, local->queues_pending))
- continue;
-
- skb = local->pending_packet[i].skb;
- while (skb) {
- struct sk_buff *next;
-
- next = skb->next;
- dev_kfree_skb(skb);
- skb = next;
- }
- clear_bit(i, local->queues_pending);
- }
+ for (i = 0; i < local->hw.queues; i++)
+ skb_queue_purge(&local->pending[i]);
}
/*
{
struct ieee80211_local *local = (struct ieee80211_local *)data;
struct net_device *dev = local->mdev;
- struct ieee80211_tx_stored_packet *store;
- struct ieee80211_tx_data tx;
+ struct ieee80211_hdr *hdr;
+ unsigned long flags;
int i, ret;
+ bool next;
+ rcu_read_lock();
netif_tx_lock_bh(dev);
- for (i = 0; i < local->hw.queues; i++) {
- /* Check that this queue is ok */
- if (__netif_subqueue_stopped(local->mdev, i) &&
- !test_bit(i, local->queues_pending_run))
- continue;
- if (!test_bit(i, local->queues_pending)) {
- clear_bit(i, local->queues_pending_run);
- ieee80211_wake_queue(&local->hw, i);
+ for (i = 0; i < local->hw.queues; i++) {
+ /*
+ * If queue is stopped by something other than due to pending
+ * frames, or we have no pending frames, proceed to next queue.
+ */
+ spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
+ next = false;
+ if (local->queue_stop_reasons[i] !=
+ BIT(IEEE80211_QUEUE_STOP_REASON_PENDING) ||
+ skb_queue_empty(&local->pending[i]))
+ next = true;
+ spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
+
+ if (next)
continue;
- }
- clear_bit(i, local->queues_pending_run);
+ /*
+ * start the queue now to allow processing our packets,
+ * we're under the tx lock here anyway so nothing will
+ * happen as a result of this
+ */
netif_start_subqueue(local->mdev, i);
- store = &local->pending_packet[i];
- tx.flags = 0;
- tx.skb = store->skb;
- ret = __ieee80211_tx(local, &tx);
- store->skb = tx.skb;
- if (!ret) {
- clear_bit(i, local->queues_pending);
- ieee80211_wake_queue(&local->hw, i);
+ while (!skb_queue_empty(&local->pending[i])) {
+ struct sk_buff *skb = skb_dequeue(&local->pending[i]);
+ struct sta_info *sta;
+
+ hdr = (struct ieee80211_hdr *)skb->data;
+ sta = sta_info_get(local, hdr->addr1);
+
+ ret = __ieee80211_tx(local, &skb, sta);
+ if (ret != IEEE80211_TX_OK) {
+ skb_queue_head(&local->pending[i], skb);
+ break;
+ }
}
+
+ /* Start regular packet processing again. */
+ if (skb_queue_empty(&local->pending[i]))
+ ieee80211_wake_queue_by_reason(&local->hw, i,
+ IEEE80211_QUEUE_STOP_REASON_PENDING);
}
+
netif_tx_unlock_bh(dev);
+ rcu_read_unlock();
}
/* functions for drivers to get certain frames */