History

mac80211: Move reorder-sensitive TX handlers to after TXQ dequeue

The TXQ intermediate queues can cause packet reordering when more than one flow is active to a single station. Since some of the wifi-specific packet handling (notably sequence number and encryption handling) is sensitive to re-ordering, things break if they are applied before the TXQ. This splits up the TX handlers and fast_xmit logic into two parts: An early part and a late part. The former is applied before TXQ enqueue, and the latter after dequeue. The non-TXQ path just applies both parts at once. Because fragments shouldn't be split up or reordered, the fragmentation handler is run after dequeue. Any fragments are then kept in the TXQ and on subsequent dequeues they take precedence over dequeueing from the FQ structure. This approach avoids having to scatter special cases all over the place for when TXQ is enabled, at the cost of making the fast_xmit and TX handler code slightly more complex.

Toke Høiland-Jørgensen committed 10 years ago

Commit bb42f2d1 parent 3a537316 files · +230 −90Browse files

Unified · Split

6 files
  1. include/net/mac80211.h +2 −0
  2. net/mac80211/ieee80211_i.h +9 −0
  3. net/mac80211/rx.c +1 −3
  4. net/mac80211/sta_info.c +3 −7
  5. net/mac80211/tx.c +206 −78
  6. net/mac80211/util.c +9 −2
include/net/mac80211.h+2−0
@@ -715,6 +715,7 @@ enum mac80211_tx_info_flags { · 714 unmodified lines
715 * frame (PS-Poll or uAPSD).715 * frame (PS-Poll or uAPSD).
716 * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information716 * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
717 * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame717 * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
718 * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
718 *719 *
719 * These flags are used in tx_info->control.flags.720 * These flags are used in tx_info->control.flags.
720 */721 */
@@ -723,6 +724,7 @@ enum mac80211_tx_control_flags { · 2 unmodified lines
723 IEEE80211_TX_CTRL_PS_RESPONSE = BIT(1),724 IEEE80211_TX_CTRL_PS_RESPONSE = BIT(1),
724 IEEE80211_TX_CTRL_RATE_INJECT = BIT(2),725 IEEE80211_TX_CTRL_RATE_INJECT = BIT(2),
725 IEEE80211_TX_CTRL_AMSDU = BIT(3),726 IEEE80211_TX_CTRL_AMSDU = BIT(3),
727 IEEE80211_TX_CTRL_FAST_XMIT = BIT(4),
726};728};
727 729
728/*730/*
net/mac80211/ieee80211_i.h+9−0
@@ -815,12 +815,14 @@ enum txq_info_flags { · 814 unmodified lines
815 * @def_flow: used as a fallback flow when a packet destined to @tin hashes to815 * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
816 * a fq_flow which is already owned by a different tin816 * a fq_flow which is already owned by a different tin
817 * @def_cvars: codel vars for @def_flow817 * @def_cvars: codel vars for @def_flow
818 * @frags: used to keep fragments created after dequeue
818 */819 */
819struct txq_info {820struct txq_info {
820 struct fq_tin tin;821 struct fq_tin tin;
821 struct fq_flow def_flow;822 struct fq_flow def_flow;
822 struct codel_vars def_cvars;823 struct codel_vars def_cvars;
823 struct codel_stats cstats;824 struct codel_stats cstats;
825 struct sk_buff_head frags;
824 unsigned long flags;826 unsigned long flags;
825 827
826 /* keep last! */828 /* keep last! */
@@ -1498,6 +1500,13 @@ static inline struct txq_info *to_txq_info(struct ieee80211_txq *txq) · 671 unmodified lines
1498 return container_of(txq, struct txq_info, txq);1500 return container_of(txq, struct txq_info, txq);
1499}1501}
1500 1502
1503static inline bool txq_has_queue(struct ieee80211_txq *txq)
1504{
1505 struct txq_info *txqi = to_txq_info(txq);
1506
1507 return !(skb_queue_empty(&txqi->frags) && !txqi->tin.backlog_packets);
1508}
1509
1501static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)1510static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
1502{1511{
1503 return ether_addr_equal(raddr, addr) ||1512 return ether_addr_equal(raddr, addr) ||
net/mac80211/rx.c+1−3
@@ -1323,9 +1323,7 @@ static void sta_ps_start(struct sta_info *sta) · 1322 unmodified lines
1323 return;1323 return;
1324 1324
1325 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {1325 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {
1326 struct txq_info *txqi = to_txq_info(sta->sta.txq[tid]);1326 if (txq_has_queue(sta->sta.txq[tid]))
1327
1328 if (txqi->tin.backlog_packets)
1329 set_bit(tid, &sta->txq_buffered_tids);1327 set_bit(tid, &sta->txq_buffered_tids);
1330 else1328 else
1331 clear_bit(tid, &sta->txq_buffered_tids);1329 clear_bit(tid, &sta->txq_buffered_tids);
net/mac80211/sta_info.c+3−7
@@ -1212,12 +1212,10 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) · 1211 unmodified lines
1212 1212
1213 if (sta->sta.txq[0]) {1213 if (sta->sta.txq[0]) {
1214 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {1214 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
1215 struct txq_info *txqi = to_txq_info(sta->sta.txq[i]);1215 if (!txq_has_queue(sta->sta.txq[i]))
1216
1217 if (!txqi->tin.backlog_packets)
1218 continue;1216 continue;
1219 1217
1220 drv_wake_tx_queue(local, txqi);1218 drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
1221 }1219 }
1222 }1220 }
1223 1221
@@ -1649,9 +1647,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, · 425 unmodified lines
1649 return;1647 return;
1650 1648
1651 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {1649 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {
1652 struct txq_info *txqi = to_txq_info(sta->sta.txq[tid]);1650 if (!(tids & BIT(tid)) || txq_has_queue(sta->sta.txq[tid]))
1653
1654 if (!(tids & BIT(tid)) || txqi->tin.backlog_packets)
1655 continue;1651 continue;
1656 1652
1657 sta_info_recalc_tim(sta);1653 sta_info_recalc_tim(sta);
net/mac80211/tx.c+206−78
@@ -853,8 +853,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) · 852 unmodified lines
853 tid = *qc & IEEE80211_QOS_CTL_TID_MASK;853 tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
854 tx->sta->tx_stats.msdu[tid]++;854 tx->sta->tx_stats.msdu[tid]++;
855 855
856 if (!tx->sta->sta.txq[0])856 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
857 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
858 857
859 return TX_CONTINUE;858 return TX_CONTINUE;
860}859}
@@ -1404,6 +1403,7 @@ void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata, · 543 unmodified lines
1404 fq_flow_init(&txqi->def_flow);1403 fq_flow_init(&txqi->def_flow);
1405 codel_vars_init(&txqi->def_cvars);1404 codel_vars_init(&txqi->def_cvars);
1406 codel_stats_init(&txqi->cstats);1405 codel_stats_init(&txqi->cstats);
1406 __skb_queue_head_init(&txqi->frags);
1407 1407
1408 txqi->txq.vif = &sdata->vif;1408 txqi->txq.vif = &sdata->vif;
1409 1409
@@ -1426,6 +1426,7 @@ void ieee80211_txq_purge(struct ieee80211_local *local, · 16 unmodified lines
1426 struct fq_tin *tin = &txqi->tin;1426 struct fq_tin *tin = &txqi->tin;
1427 1427
1428 fq_tin_reset(fq, tin, fq_skb_free_func);1428 fq_tin_reset(fq, tin, fq_skb_free_func);
1429 ieee80211_purge_tx_queue(&local->hw, &txqi->frags);
1429}1430}
1430 1431
1431int ieee80211_txq_setup_flows(struct ieee80211_local *local)1432int ieee80211_txq_setup_flows(struct ieee80211_local *local)
@@ -1495,6 +1496,47 @@ void ieee80211_txq_teardown_flows(struct ieee80211_local *local) · 63 unmodified lines
1495 spin_unlock_bh(&fq->lock);1496 spin_unlock_bh(&fq->lock);
1496}1497}
1497 1498
1499static bool ieee80211_queue_skb(struct ieee80211_local *local,
1500 struct ieee80211_sub_if_data *sdata,
1501 struct sta_info *sta,
1502 struct sk_buff *skb)
1503{
1504 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1505 struct fq *fq = &local->fq;
1506 struct ieee80211_vif *vif;
1507 struct txq_info *txqi;
1508 struct ieee80211_sta *pubsta;
1509
1510 if (!local->ops->wake_tx_queue ||
1511 sdata->vif.type == NL80211_IFTYPE_MONITOR)
1512 return false;
1513
1514 if (sta && sta->uploaded)
1515 pubsta = &sta->sta;
1516 else
1517 pubsta = NULL;
1518
1519 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1520 sdata = container_of(sdata->bss,
1521 struct ieee80211_sub_if_data, u.ap);
1522
1523 vif = &sdata->vif;
1524 txqi = ieee80211_get_txq(local, vif, pubsta, skb);
1525
1526 if (!txqi)
1527 return false;
1528
1529 info->control.vif = vif;
1530
1531 spin_lock_bh(&fq->lock);
1532 ieee80211_txq_enqueue(local, txqi, skb);
1533 spin_unlock_bh(&fq->lock);
1534
1535 drv_wake_tx_queue(local, txqi);
1536
1537 return true;
1538}
1539
1498static bool ieee80211_tx_frags(struct ieee80211_local *local,1540static bool ieee80211_tx_frags(struct ieee80211_local *local,
1499 struct ieee80211_vif *vif,1541 struct ieee80211_vif *vif,
1500 struct ieee80211_sta *sta,1542 struct ieee80211_sta *sta,
@@ -1502,9 +1544,7 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local, · 1 unmodified line
1502 bool txpending)1544 bool txpending)
1503{1545{
1504 struct ieee80211_tx_control control = {};1546 struct ieee80211_tx_control control = {};
1505 struct fq *fq = &local->fq;
1506 struct sk_buff *skb, *tmp;1547 struct sk_buff *skb, *tmp;
1507 struct txq_info *txqi;
1508 unsigned long flags;1548 unsigned long flags;
1509 1549
1510 skb_queue_walk_safe(skbs, skb, tmp) {1550 skb_queue_walk_safe(skbs, skb, tmp) {
@@ -1519,21 +1559,6 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local, · 8 unmodified lines
1519 }1559 }
1520#endif1560#endif
1521 1561
1522 txqi = ieee80211_get_txq(local, vif, sta, skb);
1523 if (txqi) {
1524 info->control.vif = vif;
1525
1526 __skb_unlink(skb, skbs);
1527
1528 spin_lock_bh(&fq->lock);
1529 ieee80211_txq_enqueue(local, txqi, skb);
1530 spin_unlock_bh(&fq->lock);
1531
1532 drv_wake_tx_queue(local, txqi);
1533
1534 continue;
1535 }
1536
1537 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);1562 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
1538 if (local->queue_stop_reasons[q] ||1563 if (local->queue_stop_reasons[q] ||
1539 (!txpending && !skb_queue_empty(&local->pending[q]))) {1564 (!txpending && !skb_queue_empty(&local->pending[q]))) {
@@ -1654,10 +1679,13 @@ static bool __ieee80211_tx(struct ieee80211_local *local, · 114 unmodified lines
1654/*1679/*
1655 * Invoke TX handlers, return 0 on success and non-zero if the1680 * Invoke TX handlers, return 0 on success and non-zero if the
1656 * frame was dropped or queued.1681 * frame was dropped or queued.
1682 *
1683 * The handlers are split into an early and late part. The latter is everything
1684 * that can be sensitive to reordering, and will be deferred to after packets
1685 * are dequeued from the intermediate queues (when they are enabled).
1657 */1686 */
1658static int invoke_tx_handlers(struct ieee80211_tx_data *tx)1687static int invoke_tx_handlers_early(struct ieee80211_tx_data *tx)
1659{1688{
1660 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
1661 ieee80211_tx_result res = TX_DROP;1689 ieee80211_tx_result res = TX_DROP;
1662 1690
1663#define CALL_TXH(txh) \1691#define CALL_TXH(txh) \
@@ -1675,6 +1703,31 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) · 11 unmodified lines
1675 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))1703 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
1676 CALL_TXH(ieee80211_tx_h_rate_ctrl);1704 CALL_TXH(ieee80211_tx_h_rate_ctrl);
1677 1705
1706 txh_done:
1707 if (unlikely(res == TX_DROP)) {
1708 I802_DEBUG_INC(tx->local->tx_handlers_drop);
1709 if (tx->skb)
1710 ieee80211_free_txskb(&tx->local->hw, tx->skb);
1711 else
1712 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs);
1713 return -1;
1714 } else if (unlikely(res == TX_QUEUED)) {
1715 I802_DEBUG_INC(tx->local->tx_handlers_queued);
1716 return -1;
1717 }
1718
1719 return 0;
1720}
1721
1722/*
1723 * Late handlers can be called while the sta lock is held. Handlers that can
1724 * cause packets to be generated will cause deadlock!
1725 */
1726static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx)
1727{
1728 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
1729 ieee80211_tx_result res = TX_CONTINUE;
1730
1678 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) {1731 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) {
1679 __skb_queue_tail(&tx->skbs, tx->skb);1732 __skb_queue_tail(&tx->skbs, tx->skb);
1680 tx->skb = NULL;1733 tx->skb = NULL;
@@ -1707,6 +1760,15 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) · 26 unmodified lines
1707 return 0;1760 return 0;
1708}1761}
1709 1762
1763static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
1764{
1765 int r = invoke_tx_handlers_early(tx);
1766
1767 if (r)
1768 return r;
1769 return invoke_tx_handlers_late(tx);
1770}
1771
1710bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,1772bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,
1711 struct ieee80211_vif *vif, struct sk_buff *skb,1773 struct ieee80211_vif *vif, struct sk_buff *skb,
1712 int band, struct ieee80211_sta **sta)1774 int band, struct ieee80211_sta **sta)
@@ -1781,7 +1843,13 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, · 68 unmodified lines
1781 info->hw_queue =1843 info->hw_queue =
1782 sdata->vif.hw_queue[skb_get_queue_mapping(skb)];1844 sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
1783 1845
1784 if (!invoke_tx_handlers(&tx))1846 if (invoke_tx_handlers_early(&tx))
1847 return false;
1848
1849 if (ieee80211_queue_skb(local, sdata, tx.sta, tx.skb))
1850 return true;
1851
1852 if (!invoke_tx_handlers_late(&tx))
1785 result = __ieee80211_tx(local, &tx.skbs, led_len,1853 result = __ieee80211_tx(local, &tx.skbs, led_len,
1786 tx.sta, txpending);1854 tx.sta, txpending);
1787 1855
@@ -3125,8 +3193,71 @@ out: · 1337 unmodified lines
3125 return ret;3193 return ret;
3126}3194}
3127 3195
3196/*
3197 * Can be called while the sta lock is held. Anything that can cause packets to
3198 * be generated will cause deadlock!
3199 */
3200static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
3201 struct sta_info *sta, u8 pn_offs,
3202 struct ieee80211_key *key,
3203 struct sk_buff *skb)
3204{
3205 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3206 struct ieee80211_hdr *hdr = (void *)skb->data;
3207 u8 tid = IEEE80211_NUM_TIDS;
3208
3209 if (key)
3210 info->control.hw_key = &key->conf;
3211
3212 ieee80211_tx_stats(skb->dev, skb->len);
3213
3214 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
3215 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
3216 *ieee80211_get_qos_ctl(hdr) = tid;
3217 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
3218 } else {
3219 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
3220 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
3221 sdata->sequence_number += 0x10;
3222 }
3223
3224 if (skb_shinfo(skb)->gso_size)
3225 sta->tx_stats.msdu[tid] +=
3226 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
3227 else
3228 sta->tx_stats.msdu[tid]++;
3229
3230 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
3231
3232 /* statistics normally done by ieee80211_tx_h_stats (but that
3233 * has to consider fragmentation, so is more complex)
3234 */
3235 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
3236 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
3237
3238 if (pn_offs) {
3239 u64 pn;
3240 u8 *crypto_hdr = skb->data + pn_offs;
3241
3242 switch (key->conf.cipher) {
3243 case WLAN_CIPHER_SUITE_CCMP:
3244 case WLAN_CIPHER_SUITE_CCMP_256:
3245 case WLAN_CIPHER_SUITE_GCMP:
3246 case WLAN_CIPHER_SUITE_GCMP_256:
3247 pn = atomic64_inc_return(&key->conf.tx_pn);
3248 crypto_hdr[0] = pn;
3249 crypto_hdr[1] = pn >> 8;
3250 crypto_hdr[4] = pn >> 16;
3251 crypto_hdr[5] = pn >> 24;
3252 crypto_hdr[6] = pn >> 32;
3253 crypto_hdr[7] = pn >> 40;
3254 break;
3255 }
3256 }
3257}
3258
3128static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,3259static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
3129 struct net_device *dev, struct sta_info *sta,3260 struct sta_info *sta,
3130 struct ieee80211_fast_tx *fast_tx,3261 struct ieee80211_fast_tx *fast_tx,
3131 struct sk_buff *skb)3262 struct sk_buff *skb)
3132{3263{
@@ -3177,8 +3308,6 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, · 44 unmodified lines
3177 return true;3308 return true;
3178 }3309 }
3179 3310
3180 ieee80211_tx_stats(dev, skb->len + extra_head);
3181
3182 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) &&3311 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) &&
3183 ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb))3312 ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb))
3184 return true;3313 return true;
@@ -3207,24 +3336,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, · 22 unmodified lines
3207 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT |3336 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT |
3208 IEEE80211_TX_CTL_DONTFRAG |3337 IEEE80211_TX_CTL_DONTFRAG |
3209 (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0);3338 (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0);
3210 3339 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT;
3211 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
3212 *ieee80211_get_qos_ctl(hdr) = tid;
3213 if (!sta->sta.txq[0])
3214 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
3215 } else {
3216 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
3217 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
3218 sdata->sequence_number += 0x10;
3219 }
3220
3221 if (skb_shinfo(skb)->gso_size)
3222 sta->tx_stats.msdu[tid] +=
3223 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
3224 else
3225 sta->tx_stats.msdu[tid]++;
3226
3227 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
3228 3340
3229 __skb_queue_head_init(&tx.skbs);3341 __skb_queue_head_init(&tx.skbs);
3230 3342
@@ -3234,9 +3346,6 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, · 3 unmodified lines
3234 tx.sta = sta;3346 tx.sta = sta;
3235 tx.key = fast_tx->key;3347 tx.key = fast_tx->key;
3236 3348
3237 if (fast_tx->key)
3238 info->control.hw_key = &fast_tx->key->conf;
3239
3240 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {3349 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3241 tx.skb = skb;3350 tx.skb = skb;
3242 r = ieee80211_tx_h_rate_ctrl(&tx);3351 r = ieee80211_tx_h_rate_ctrl(&tx);
@@ -3250,31 +3359,11 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, · 7 unmodified lines
3250 }3359 }
3251 }3360 }
3252 3361
3253 /* statistics normally done by ieee80211_tx_h_stats (but that3362 if (ieee80211_queue_skb(local, sdata, sta, skb))
3254 * has to consider fragmentation, so is more complex)3363 return true;
3255 */
3256 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
3257 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
3258 3364
3259 if (fast_tx->pn_offs) {3365 ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
3260 u64 pn;3366 fast_tx->key, skb);
3261 u8 *crypto_hdr = skb->data + fast_tx->pn_offs;
3262
3263 switch (fast_tx->key->conf.cipher) {
3264 case WLAN_CIPHER_SUITE_CCMP:
3265 case WLAN_CIPHER_SUITE_CCMP_256:
3266 case WLAN_CIPHER_SUITE_GCMP:
3267 case WLAN_CIPHER_SUITE_GCMP_256:
3268 pn = atomic64_inc_return(&fast_tx->key->conf.tx_pn);
3269 crypto_hdr[0] = pn;
3270 crypto_hdr[1] = pn >> 8;
3271 crypto_hdr[4] = pn >> 16;
3272 crypto_hdr[5] = pn >> 24;
3273 crypto_hdr[6] = pn >> 32;
3274 crypto_hdr[7] = pn >> 40;
3275 break;
3276 }
3277 }
3278 3367
3279 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)3368 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
3280 sdata = container_of(sdata->bss,3369 sdata = container_of(sdata->bss,
@@ -3294,12 +3383,21 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, · 13 unmodified lines
3294 struct sk_buff *skb = NULL;3383 struct sk_buff *skb = NULL;
3295 struct fq *fq = &local->fq;3384 struct fq *fq = &local->fq;
3296 struct fq_tin *tin = &txqi->tin;3385 struct fq_tin *tin = &txqi->tin;
3386 struct ieee80211_tx_info *info;
3387 struct ieee80211_tx_data tx;
3388 ieee80211_tx_result r;
3297 3389
3298 spin_lock_bh(&fq->lock);3390 spin_lock_bh(&fq->lock);
3299 3391
3300 if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags))3392 if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags))
3301 goto out;3393 goto out;
3302 3394
3395 /* Make sure fragments stay together. */
3396 skb = __skb_dequeue(&txqi->frags);
3397 if (skb)
3398 goto out;
3399
3400begin:
3303 skb = fq_tin_dequeue(fq, tin, fq_tin_dequeue_func);3401 skb = fq_tin_dequeue(fq, tin, fq_tin_dequeue_func);
3304 if (!skb)3402 if (!skb)
3305 goto out;3403 goto out;
@@ -3307,16 +3405,46 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, · 1 unmodified line
3307 ieee80211_set_skb_vif(skb, txqi);3405 ieee80211_set_skb_vif(skb, txqi);
3308 3406
3309 hdr = (struct ieee80211_hdr *)skb->data;3407 hdr = (struct ieee80211_hdr *)skb->data;
3310 if (txq->sta && ieee80211_is_data_qos(hdr->frame_control)) {3408 info = IEEE80211_SKB_CB(skb);
3409
3410 memset(&tx, 0, sizeof(tx));
3411 __skb_queue_head_init(&tx.skbs);
3412 tx.local = local;
3413 tx.skb = skb;
3414 tx.sdata = vif_to_sdata(info->control.vif);
3415
3416 if (txq->sta)
3417 tx.sta = container_of(txq->sta, struct sta_info, sta);
3418
3419 /*
3420 * The key can be removed while the packet was queued, so need to call
3421 * this here to get the current key.
3422 */
3423 r = ieee80211_tx_h_select_key(&tx);
3424 if (r != TX_CONTINUE) {
3425 ieee80211_free_txskb(&local->hw, skb);
3426 goto begin;
3427 }
3428
3429 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) {
3311 struct sta_info *sta = container_of(txq->sta, struct sta_info,3430 struct sta_info *sta = container_of(txq->sta, struct sta_info,
3312 sta);3431 sta);
3313 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);3432 u8 pn_offs = 0;
3314 3433
3315 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, txq->tid);3434 if (tx.key &&
3316 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags))3435 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
3317 info->flags |= IEEE80211_TX_CTL_AMPDU;3436 pn_offs = ieee80211_hdrlen(hdr->frame_control);
3318 else3437
3319 info->flags &= ~IEEE80211_TX_CTL_AMPDU;3438 ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
3439 tx.key, skb);
3440 } else {
3441 if (invoke_tx_handlers_late(&tx))
3442 goto begin;
3443
3444 skb = __skb_dequeue(&tx.skbs);
3445
3446 if (!skb_queue_empty(&tx.skbs))
3447 skb_queue_splice_tail(&tx.skbs, &txqi->frags);
3320 }3448 }
3321 3449
3322out:3450out:
@@ -3354,7 +3482,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, · 31 unmodified lines
3354 fast_tx = rcu_dereference(sta->fast_tx);3482 fast_tx = rcu_dereference(sta->fast_tx);
3355 3483
3356 if (fast_tx &&3484 if (fast_tx &&
3357 ieee80211_xmit_fast(sdata, dev, sta, fast_tx, skb))3485 ieee80211_xmit_fast(sdata, sta, fast_tx, skb))
3358 goto out;3486 goto out;
3359 }3487 }
3360 3488
net/mac80211/util.c+9−2
@@ -3441,11 +3441,18 @@ void ieee80211_txq_get_depth(struct ieee80211_txq *txq, · 3440 unmodified lines
3441 unsigned long *byte_cnt)3441 unsigned long *byte_cnt)
3442{3442{
3443 struct txq_info *txqi = to_txq_info(txq);3443 struct txq_info *txqi = to_txq_info(txq);
3444 u32 frag_cnt = 0, frag_bytes = 0;
3445 struct sk_buff *skb;
3446
3447 skb_queue_walk(&txqi->frags, skb) {
3448 frag_cnt++;
3449 frag_bytes += skb->len;
3450 }
3444 3451
3445 if (frame_cnt)3452 if (frame_cnt)
3446 *frame_cnt = txqi->tin.backlog_packets;3453 *frame_cnt = txqi->tin.backlog_packets + frag_cnt;
3447 3454
3448 if (byte_cnt)3455 if (byte_cnt)
3449 *byte_cnt = txqi->tin.backlog_bytes;3456 *byte_cnt = txqi->tin.backlog_bytes + frag_bytes;
3450}3457}
3451EXPORT_SYMBOL(ieee80211_txq_get_depth);3458EXPORT_SYMBOL(ieee80211_txq_get_depth);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t