hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/net/mac80211/status.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2002-2005, Instant802 Networks, Inc.
34 * Copyright 2005-2006, Devicescape Software, Inc.
45 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
56 * Copyright 2008-2010 Johannes Berg <johannes@sipsolutions.net>
67 * Copyright 2013-2014 Intel Mobile Communications GmbH
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129
1310 #include <linux/export.h>
....@@ -52,7 +49,8 @@
5249 int ac;
5350
5451 if (info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
55
- IEEE80211_TX_CTL_AMPDU)) {
52
+ IEEE80211_TX_CTL_AMPDU |
53
+ IEEE80211_TX_CTL_HW_80211_ENCAP)) {
5654 ieee80211_free_txskb(&local->hw, skb);
5755 return;
5856 }
....@@ -69,8 +67,8 @@
6967
7068 info->control.jiffies = jiffies;
7169 info->control.vif = &sta->sdata->vif;
72
- info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING |
73
- IEEE80211_TX_INTFL_RETRANSMISSION;
70
+ info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING;
71
+ info->flags |= IEEE80211_TX_INTFL_RETRANSMISSION;
7472 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
7573
7674 sta->status_stats.filtered++;
....@@ -187,18 +185,6 @@
187185 struct ieee80211_mgmt *mgmt = (void *) skb->data;
188186 struct ieee80211_local *local = sta->local;
189187 struct ieee80211_sub_if_data *sdata = sta->sdata;
190
- struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
191
-
192
- if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
193
- sta->status_stats.last_ack = jiffies;
194
- if (txinfo->status.is_valid_ack_signal) {
195
- sta->status_stats.last_ack_signal =
196
- (s8)txinfo->status.ack_signal;
197
- sta->status_stats.ack_signal_filled = true;
198
- ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
199
- -txinfo->status.ack_signal);
200
- }
201
- }
202188
203189 if (ieee80211_is_data_qos(mgmt->frame_control)) {
204190 struct ieee80211_hdr *hdr = (void *) skb->data;
....@@ -257,16 +243,22 @@
257243 tid_tx->bar_pending = true;
258244 }
259245
260
-static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info)
246
+static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info,
247
+ struct ieee80211_tx_status *status)
261248 {
262249 int len = sizeof(struct ieee80211_radiotap_header);
263250
264251 /* IEEE80211_RADIOTAP_RATE rate */
265
- if (info->status.rates[0].idx >= 0 &&
266
- !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
267
- RATE_INFO_FLAGS_DMG |
268
- RATE_INFO_FLAGS_EDMG |
269
- IEEE80211_TX_RC_VHT_MCS)))
252
+ if (status && status->rate && !(status->rate->flags &
253
+ (RATE_INFO_FLAGS_MCS |
254
+ RATE_INFO_FLAGS_DMG |
255
+ RATE_INFO_FLAGS_EDMG |
256
+ RATE_INFO_FLAGS_VHT_MCS |
257
+ RATE_INFO_FLAGS_HE_MCS)))
258
+ len += 2;
259
+ else if (info->status.rates[0].idx >= 0 &&
260
+ !(info->status.rates[0].flags &
261
+ (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS)))
270262 len += 2;
271263
272264 /* IEEE80211_RADIOTAP_TX_FLAGS */
....@@ -277,7 +269,14 @@
277269
278270 /* IEEE80211_RADIOTAP_MCS
279271 * IEEE80211_RADIOTAP_VHT */
280
- if (info->status.rates[0].idx >= 0) {
272
+ if (status && status->rate) {
273
+ if (status->rate->flags & RATE_INFO_FLAGS_MCS)
274
+ len += 3;
275
+ else if (status->rate->flags & RATE_INFO_FLAGS_VHT_MCS)
276
+ len = ALIGN(len, 2) + 12;
277
+ else if (status->rate->flags & RATE_INFO_FLAGS_HE_MCS)
278
+ len = ALIGN(len, 2) + 12;
279
+ } else if (info->status.rates[0].idx >= 0) {
281280 if (info->status.rates[0].flags & IEEE80211_TX_RC_MCS)
282281 len += 3;
283282 else if (info->status.rates[0].flags & IEEE80211_TX_RC_VHT_MCS)
....@@ -291,12 +290,14 @@
291290 ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
292291 struct ieee80211_supported_band *sband,
293292 struct sk_buff *skb, int retry_count,
294
- int rtap_len, int shift)
293
+ int rtap_len, int shift,
294
+ struct ieee80211_tx_status *status)
295295 {
296296 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
297297 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
298298 struct ieee80211_radiotap_header *rthdr;
299299 unsigned char *pos;
300
+ u16 legacy_rate = 0;
300301 u16 txflags;
301302
302303 rthdr = skb_push(skb, rtap_len);
....@@ -315,16 +316,23 @@
315316 */
316317
317318 /* IEEE80211_RADIOTAP_RATE */
318
- if (info->status.rates[0].idx >= 0 &&
319
- !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
319
+
320
+ if (status && status->rate) {
321
+ if (!(status->rate->flags & (RATE_INFO_FLAGS_MCS |
320322 RATE_INFO_FLAGS_DMG |
321323 RATE_INFO_FLAGS_EDMG |
322
- IEEE80211_TX_RC_VHT_MCS))) {
323
- u16 rate;
324
+ RATE_INFO_FLAGS_VHT_MCS |
325
+ RATE_INFO_FLAGS_HE_MCS)))
326
+ legacy_rate = status->rate->legacy;
327
+ } else if (info->status.rates[0].idx >= 0 &&
328
+ !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
329
+ IEEE80211_TX_RC_VHT_MCS)))
330
+ legacy_rate =
331
+ sband->bitrates[info->status.rates[0].idx].bitrate;
324332
333
+ if (legacy_rate) {
325334 rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE);
326
- rate = sband->bitrates[info->status.rates[0].idx].bitrate;
327
- *pos = DIV_ROUND_UP(rate, 5 * (1 << shift));
335
+ *pos = DIV_ROUND_UP(legacy_rate, 5 * (1 << shift));
328336 /* padding for tx flags */
329337 pos += 2;
330338 }
....@@ -348,7 +356,140 @@
348356 *pos = retry_count;
349357 pos++;
350358
351
- if (info->status.rates[0].idx < 0)
359
+ if (status && status->rate &&
360
+ (status->rate->flags & RATE_INFO_FLAGS_MCS)) {
361
+ rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS);
362
+ pos[0] = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
363
+ IEEE80211_RADIOTAP_MCS_HAVE_GI |
364
+ IEEE80211_RADIOTAP_MCS_HAVE_BW;
365
+ if (status->rate->flags & RATE_INFO_FLAGS_SHORT_GI)
366
+ pos[1] |= IEEE80211_RADIOTAP_MCS_SGI;
367
+ if (status->rate->bw == RATE_INFO_BW_40)
368
+ pos[1] |= IEEE80211_RADIOTAP_MCS_BW_40;
369
+ pos[2] = status->rate->mcs;
370
+ pos += 3;
371
+ } else if (status && status->rate &&
372
+ (status->rate->flags & RATE_INFO_FLAGS_VHT_MCS)) {
373
+ u16 known = local->hw.radiotap_vht_details &
374
+ (IEEE80211_RADIOTAP_VHT_KNOWN_GI |
375
+ IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH);
376
+
377
+ rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_VHT);
378
+
379
+ /* required alignment from rthdr */
380
+ pos = (u8 *)rthdr + ALIGN(pos - (u8 *)rthdr, 2);
381
+
382
+ /* u16 known - IEEE80211_RADIOTAP_VHT_KNOWN_* */
383
+ put_unaligned_le16(known, pos);
384
+ pos += 2;
385
+
386
+ /* u8 flags - IEEE80211_RADIOTAP_VHT_FLAG_* */
387
+ if (status->rate->flags & RATE_INFO_FLAGS_SHORT_GI)
388
+ *pos |= IEEE80211_RADIOTAP_VHT_FLAG_SGI;
389
+ pos++;
390
+
391
+ /* u8 bandwidth */
392
+ switch (status->rate->bw) {
393
+ case RATE_INFO_BW_160:
394
+ *pos = 11;
395
+ break;
396
+ case RATE_INFO_BW_80:
397
+ *pos = 4;
398
+ break;
399
+ case RATE_INFO_BW_40:
400
+ *pos = 1;
401
+ break;
402
+ default:
403
+ *pos = 0;
404
+ break;
405
+ }
406
+ pos++;
407
+
408
+ /* u8 mcs_nss[4] */
409
+ *pos = (status->rate->mcs << 4) | status->rate->nss;
410
+ pos += 4;
411
+
412
+ /* u8 coding */
413
+ pos++;
414
+ /* u8 group_id */
415
+ pos++;
416
+ /* u16 partial_aid */
417
+ pos += 2;
418
+ } else if (status && status->rate &&
419
+ (status->rate->flags & RATE_INFO_FLAGS_HE_MCS)) {
420
+ struct ieee80211_radiotap_he *he;
421
+
422
+ rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_HE);
423
+
424
+ /* required alignment from rthdr */
425
+ pos = (u8 *)rthdr + ALIGN(pos - (u8 *)rthdr, 2);
426
+ he = (struct ieee80211_radiotap_he *)pos;
427
+
428
+ he->data1 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU |
429
+ IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN |
430
+ IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN |
431
+ IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN);
432
+
433
+ he->data2 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN);
434
+
435
+#define HE_PREP(f, val) le16_encode_bits(val, IEEE80211_RADIOTAP_HE_##f)
436
+
437
+ he->data6 |= HE_PREP(DATA6_NSTS, status->rate->nss);
438
+
439
+#define CHECK_GI(s) \
440
+ BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA5_GI_##s != \
441
+ (int)NL80211_RATE_INFO_HE_GI_##s)
442
+
443
+ CHECK_GI(0_8);
444
+ CHECK_GI(1_6);
445
+ CHECK_GI(3_2);
446
+
447
+ he->data3 |= HE_PREP(DATA3_DATA_MCS, status->rate->mcs);
448
+ he->data3 |= HE_PREP(DATA3_DATA_DCM, status->rate->he_dcm);
449
+
450
+ he->data5 |= HE_PREP(DATA5_GI, status->rate->he_gi);
451
+
452
+ switch (status->rate->bw) {
453
+ case RATE_INFO_BW_20:
454
+ he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
455
+ IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ);
456
+ break;
457
+ case RATE_INFO_BW_40:
458
+ he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
459
+ IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ);
460
+ break;
461
+ case RATE_INFO_BW_80:
462
+ he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
463
+ IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ);
464
+ break;
465
+ case RATE_INFO_BW_160:
466
+ he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
467
+ IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ);
468
+ break;
469
+ case RATE_INFO_BW_HE_RU:
470
+#define CHECK_RU_ALLOC(s) \
471
+ BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_##s##T != \
472
+ NL80211_RATE_INFO_HE_RU_ALLOC_##s + 4)
473
+
474
+ CHECK_RU_ALLOC(26);
475
+ CHECK_RU_ALLOC(52);
476
+ CHECK_RU_ALLOC(106);
477
+ CHECK_RU_ALLOC(242);
478
+ CHECK_RU_ALLOC(484);
479
+ CHECK_RU_ALLOC(996);
480
+ CHECK_RU_ALLOC(2x996);
481
+
482
+ he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
483
+ status->rate->he_ru_alloc + 4);
484
+ break;
485
+ default:
486
+ WARN_ONCE(1, "Invalid SU BW %d\n", status->rate->bw);
487
+ }
488
+
489
+ pos += sizeof(struct ieee80211_radiotap_he);
490
+ }
491
+
492
+ if ((status && status->rate) || info->status.rates[0].idx < 0)
352493 return;
353494
354495 /* IEEE80211_RADIOTAP_MCS
....@@ -487,20 +628,35 @@
487628 u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie;
488629 struct ieee80211_sub_if_data *sdata;
489630 struct ieee80211_hdr *hdr = (void *)skb->data;
631
+ __be16 ethertype = 0;
632
+
633
+ if (skb->len >= ETH_HLEN && skb->protocol == cpu_to_be16(ETH_P_802_3))
634
+ skb_copy_bits(skb, 2 * ETH_ALEN, &ethertype, ETH_TLEN);
490635
491636 rcu_read_lock();
492637 sdata = ieee80211_sdata_from_skb(local, skb);
493638 if (sdata) {
494
- if (ieee80211_is_any_nullfunc(hdr->frame_control))
639
+ if (ethertype == sdata->control_port_protocol ||
640
+ ethertype == cpu_to_be16(ETH_P_PREAUTH))
641
+ cfg80211_control_port_tx_status(&sdata->wdev,
642
+ cookie,
643
+ skb->data,
644
+ skb->len,
645
+ acked,
646
+ GFP_ATOMIC);
647
+ else if (ieee80211_is_any_nullfunc(hdr->frame_control))
495648 cfg80211_probe_status(sdata->dev, hdr->addr1,
496649 cookie, acked,
497650 info->status.ack_signal,
498651 info->status.is_valid_ack_signal,
499652 GFP_ATOMIC);
500
- else
653
+ else if (ieee80211_is_mgmt(hdr->frame_control))
501654 cfg80211_mgmt_tx_status(&sdata->wdev, cookie,
502655 skb->data, skb->len,
503656 acked, GFP_ATOMIC);
657
+ else
658
+ pr_warn("Unknown status report in ack skb\n");
659
+
504660 }
505661 rcu_read_unlock();
506662
....@@ -517,11 +673,25 @@
517673 struct sk_buff *skb, bool dropped)
518674 {
519675 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
676
+ u16 tx_time_est = ieee80211_info_get_tx_time_est(info);
520677 struct ieee80211_hdr *hdr = (void *)skb->data;
521678 bool acked = info->flags & IEEE80211_TX_STAT_ACK;
522679
523680 if (dropped)
524681 acked = false;
682
+
683
+ if (tx_time_est) {
684
+ struct sta_info *sta;
685
+
686
+ rcu_read_lock();
687
+
688
+ sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
689
+ ieee80211_sta_update_pending_airtime(local, sta,
690
+ skb_get_queue_mapping(skb),
691
+ tx_time_est,
692
+ true);
693
+ rcu_read_unlock();
694
+ }
525695
526696 if (info->flags & IEEE80211_TX_INTFL_MLME_CONN_TX) {
527697 struct ieee80211_sub_if_data *sdata;
....@@ -574,12 +744,16 @@
574744 * - current throughput (higher value for higher tpt)?
575745 */
576746 #define STA_LOST_PKT_THRESHOLD 50
747
+#define STA_LOST_PKT_TIME HZ /* 1 sec since last ACK */
577748 #define STA_LOST_TDLS_PKT_THRESHOLD 10
578749 #define STA_LOST_TDLS_PKT_TIME (10*HZ) /* 10secs since last ACK */
579750
580751 static void ieee80211_lost_packet(struct sta_info *sta,
581752 struct ieee80211_tx_info *info)
582753 {
754
+ unsigned long pkt_time = STA_LOST_PKT_TIME;
755
+ unsigned int pkt_thr = STA_LOST_PKT_THRESHOLD;
756
+
583757 /* If driver relies on its own algorithm for station kickout, skip
584758 * mac80211 packet loss mechanism.
585759 */
....@@ -592,21 +766,20 @@
592766 return;
593767
594768 sta->status_stats.lost_packets++;
595
- if (!sta->sta.tdls &&
596
- sta->status_stats.lost_packets < STA_LOST_PKT_THRESHOLD)
597
- return;
769
+ if (sta->sta.tdls) {
770
+ pkt_time = STA_LOST_TDLS_PKT_TIME;
771
+ pkt_thr = STA_LOST_PKT_THRESHOLD;
772
+ }
598773
599774 /*
600775 * If we're in TDLS mode, make sure that all STA_LOST_TDLS_PKT_THRESHOLD
601776 * of the last packets were lost, and that no ACK was received in the
602777 * last STA_LOST_TDLS_PKT_TIME ms, before triggering the CQM packet-loss
603778 * mechanism.
779
+ * For non-TDLS, use STA_LOST_PKT_THRESHOLD and STA_LOST_PKT_TIME
604780 */
605
- if (sta->sta.tdls &&
606
- (sta->status_stats.lost_packets < STA_LOST_TDLS_PKT_THRESHOLD ||
607
- time_before(jiffies,
608
- sta->status_stats.last_tdls_pkt_time +
609
- STA_LOST_TDLS_PKT_TIME)))
781
+ if (sta->status_stats.lost_packets < pkt_thr ||
782
+ !time_after(jiffies, sta->status_stats.last_pkt_time + pkt_time))
610783 return;
611784
612785 cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
....@@ -618,7 +791,6 @@
618791 struct ieee80211_tx_info *info,
619792 int *retry_count)
620793 {
621
- int rates_idx = -1;
622794 int count = -1;
623795 int i;
624796
....@@ -640,18 +812,18 @@
640812
641813 count += info->status.rates[i].count;
642814 }
643
- rates_idx = i - 1;
644815
645816 if (count < 0)
646817 count = 0;
647818
648819 *retry_count = count;
649
- return rates_idx;
820
+ return i - 1;
650821 }
651822
652823 void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
653824 struct ieee80211_supported_band *sband,
654
- int retry_count, int shift, bool send_to_cooked)
825
+ int retry_count, int shift, bool send_to_cooked,
826
+ struct ieee80211_tx_status *status)
655827 {
656828 struct sk_buff *skb2;
657829 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
....@@ -660,14 +832,14 @@
660832 int rtap_len;
661833
662834 /* send frame to monitor interfaces now */
663
- rtap_len = ieee80211_tx_radiotap_len(info);
835
+ rtap_len = ieee80211_tx_radiotap_len(info, status);
664836 if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
665837 pr_err("ieee80211_tx_status: headroom too small\n");
666838 dev_kfree_skb(skb);
667839 return;
668840 }
669841 ieee80211_add_tx_radiotap_header(local, sband, skb, retry_count,
670
- rtap_len, shift);
842
+ rtap_len, shift, status);
671843
672844 /* XXX: is this sufficient for BPF? */
673845 skb_reset_mac_header(skb);
....@@ -707,7 +879,8 @@
707879 }
708880
709881 static void __ieee80211_tx_status(struct ieee80211_hw *hw,
710
- struct ieee80211_tx_status *status)
882
+ struct ieee80211_tx_status *status,
883
+ int rates_idx, int retry_count)
711884 {
712885 struct sk_buff *skb = status->skb;
713886 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
....@@ -716,15 +889,12 @@
716889 struct sta_info *sta;
717890 __le16 fc;
718891 struct ieee80211_supported_band *sband;
719
- int retry_count;
720
- int rates_idx;
721892 bool send_to_cooked;
722893 bool acked;
894
+ bool noack_success;
723895 struct ieee80211_bar *bar;
724896 int shift = 0;
725897 int tid = IEEE80211_NUM_TIDS;
726
-
727
- rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
728898
729899 sband = local->hw.wiphy->bands[info->band];
730900 fc = hdr->frame_control;
....@@ -737,21 +907,14 @@
737907 clear_sta_flag(sta, WLAN_STA_SP);
738908
739909 acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
910
+ noack_success = !!(info->flags &
911
+ IEEE80211_TX_STAT_NOACK_TRANSMITTED);
740912
741913 /* mesh Peer Service Period support */
742914 if (ieee80211_vif_is_mesh(&sta->sdata->vif) &&
743915 ieee80211_is_data_qos(fc))
744916 ieee80211_mpsp_trigger_process(
745917 ieee80211_get_qos_ctl(hdr), sta, true, acked);
746
-
747
- if (!acked && test_sta_flag(sta, WLAN_STA_PS_STA)) {
748
- /*
749
- * The STA is in power save mode, so assume
750
- * that this TX packet failed because of that.
751
- */
752
- ieee80211_handle_filtered_frame(local, sta, skb);
753
- return;
754
- }
755918
756919 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL) &&
757920 (ieee80211_is_data(hdr->frame_control)) &&
....@@ -800,45 +963,17 @@
800963 if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
801964 ieee80211_handle_filtered_frame(local, sta, skb);
802965 return;
803
- } else {
804
- if (!acked)
805
- sta->status_stats.retry_failed++;
806
- sta->status_stats.retry_count += retry_count;
966
+ } else if (ieee80211_is_data_present(fc)) {
967
+ if (!acked && !noack_success)
968
+ sta->status_stats.msdu_failed[tid]++;
807969
808
- if (ieee80211_is_data_present(fc)) {
809
- if (!acked)
810
- sta->status_stats.msdu_failed[tid]++;
811
-
812
- sta->status_stats.msdu_retries[tid] +=
813
- retry_count;
814
- }
970
+ sta->status_stats.msdu_retries[tid] +=
971
+ retry_count;
815972 }
816
-
817
- rate_control_tx_status(local, sband, status);
818
- if (ieee80211_vif_is_mesh(&sta->sdata->vif))
819
- ieee80211s_update_metric(local, sta, status);
820973
821974 if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
822975 ieee80211_frame_acked(sta, skb);
823976
824
- if ((sta->sdata->vif.type == NL80211_IFTYPE_STATION) &&
825
- ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
826
- ieee80211_sta_tx_notify(sta->sdata, (void *) skb->data,
827
- acked, info->status.tx_time);
828
-
829
- if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
830
- if (info->flags & IEEE80211_TX_STAT_ACK) {
831
- if (sta->status_stats.lost_packets)
832
- sta->status_stats.lost_packets = 0;
833
-
834
- /* Track when last TDLS packet was ACKed */
835
- if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
836
- sta->status_stats.last_tdls_pkt_time =
837
- jiffies;
838
- } else {
839
- ieee80211_lost_packet(sta, info);
840
- }
841
- }
842977 }
843978
844979 /* SNMP counters
....@@ -897,12 +1032,16 @@
8971032 * with this test...
8981033 */
8991034 if (!local->monitors && (!send_to_cooked || !local->cooked_mntrs)) {
900
- dev_kfree_skb(skb);
1035
+ if (status->free_list)
1036
+ list_add_tail(&skb->list, status->free_list);
1037
+ else
1038
+ dev_kfree_skb(skb);
9011039 return;
9021040 }
9031041
9041042 /* send to monitor interfaces */
905
- ieee80211_tx_monitor(local, skb, sband, retry_count, shift, send_to_cooked);
1043
+ ieee80211_tx_monitor(local, skb, sband, retry_count, shift,
1044
+ send_to_cooked, status);
9061045 }
9071046
9081047 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
....@@ -913,21 +1052,15 @@
9131052 .skb = skb,
9141053 .info = IEEE80211_SKB_CB(skb),
9151054 };
916
- struct rhlist_head *tmp;
9171055 struct sta_info *sta;
9181056
9191057 rcu_read_lock();
9201058
921
- for_each_sta_info(local, hdr->addr1, sta, tmp) {
922
- /* skip wrong virtual interface */
923
- if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr))
924
- continue;
925
-
1059
+ sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
1060
+ if (sta)
9261061 status.sta = &sta->sta;
927
- break;
928
- }
9291062
930
- __ieee80211_tx_status(hw, &status);
1063
+ ieee80211_tx_status_ext(hw, &status);
9311064 rcu_read_unlock();
9321065 }
9331066 EXPORT_SYMBOL(ieee80211_tx_status);
....@@ -938,17 +1071,36 @@
9381071 struct ieee80211_local *local = hw_to_local(hw);
9391072 struct ieee80211_tx_info *info = status->info;
9401073 struct ieee80211_sta *pubsta = status->sta;
1074
+ struct sk_buff *skb = status->skb;
9411075 struct ieee80211_supported_band *sband;
942
- int retry_count;
1076
+ struct sta_info *sta = NULL;
1077
+ int rates_idx, retry_count;
9431078 bool acked, noack_success;
1079
+ u16 tx_time_est;
9441080
945
- if (status->skb)
946
- return __ieee80211_tx_status(hw, status);
1081
+ if (pubsta) {
1082
+ sta = container_of(pubsta, struct sta_info, sta);
9471083
948
- if (!status->sta)
949
- return;
1084
+ if (status->rate)
1085
+ sta->tx_stats.last_rate_info = *status->rate;
1086
+ }
9501087
951
- ieee80211_tx_get_rates(hw, info, &retry_count);
1088
+ if (skb && (tx_time_est =
1089
+ ieee80211_info_get_tx_time_est(IEEE80211_SKB_CB(skb))) > 0) {
1090
+ /* Do this here to avoid the expensive lookup of the sta
1091
+ * in ieee80211_report_used_skb().
1092
+ */
1093
+ ieee80211_sta_update_pending_airtime(local, sta,
1094
+ skb_get_queue_mapping(skb),
1095
+ tx_time_est,
1096
+ true);
1097
+ ieee80211_info_set_tx_time_est(IEEE80211_SKB_CB(skb), 0);
1098
+ }
1099
+
1100
+ if (!status->info)
1101
+ goto free;
1102
+
1103
+ rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
9521104
9531105 sband = hw->wiphy->bands[info->band];
9541106
....@@ -956,33 +1108,62 @@
9561108 noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED);
9571109
9581110 if (pubsta) {
959
- struct sta_info *sta;
1111
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
9601112
961
- sta = container_of(pubsta, struct sta_info, sta);
962
-
963
- if (!acked)
1113
+ if (!acked && !noack_success)
9641114 sta->status_stats.retry_failed++;
9651115 sta->status_stats.retry_count += retry_count;
9661116
967
- if (acked) {
968
- sta->status_stats.last_ack = jiffies;
1117
+ if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
1118
+ if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1119
+ skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP))
1120
+ ieee80211_sta_tx_notify(sdata, (void *) skb->data,
1121
+ acked, info->status.tx_time);
9691122
970
- if (sta->status_stats.lost_packets)
971
- sta->status_stats.lost_packets = 0;
1123
+ if (acked) {
1124
+ sta->status_stats.last_ack = jiffies;
9721125
973
- /* Track when last TDLS packet was ACKed */
974
- if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
975
- sta->status_stats.last_tdls_pkt_time = jiffies;
976
- } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
977
- return;
978
- } else {
979
- ieee80211_lost_packet(sta, info);
1126
+ if (sta->status_stats.lost_packets)
1127
+ sta->status_stats.lost_packets = 0;
1128
+
1129
+ /* Track when last packet was ACKed */
1130
+ sta->status_stats.last_pkt_time = jiffies;
1131
+
1132
+ /* Reset connection monitor */
1133
+ if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1134
+ unlikely(sdata->u.mgd.probe_send_count > 0))
1135
+ sdata->u.mgd.probe_send_count = 0;
1136
+
1137
+ if (info->status.is_valid_ack_signal) {
1138
+ sta->status_stats.last_ack_signal =
1139
+ (s8)info->status.ack_signal;
1140
+ sta->status_stats.ack_signal_filled = true;
1141
+ ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
1142
+ -info->status.ack_signal);
1143
+ }
1144
+ } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
1145
+ /*
1146
+ * The STA is in power save mode, so assume
1147
+ * that this TX packet failed because of that.
1148
+ */
1149
+ if (skb)
1150
+ ieee80211_handle_filtered_frame(local, sta, skb);
1151
+ return;
1152
+ } else if (noack_success) {
1153
+ /* nothing to do here, do not account as lost */
1154
+ } else {
1155
+ ieee80211_lost_packet(sta, info);
1156
+ }
9801157 }
9811158
9821159 rate_control_tx_status(local, sband, status);
9831160 if (ieee80211_vif_is_mesh(&sta->sdata->vif))
9841161 ieee80211s_update_metric(local, sta, status);
9851162 }
1163
+
1164
+ if (skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP))
1165
+ return __ieee80211_tx_status(hw, status, rates_idx,
1166
+ retry_count);
9861167
9871168 if (acked || noack_success) {
9881169 I802_DEBUG_INC(local->dot11TransmittedFrameCount);
....@@ -995,9 +1176,62 @@
9951176 } else {
9961177 I802_DEBUG_INC(local->dot11FailedCount);
9971178 }
1179
+
1180
+free:
1181
+ if (!skb)
1182
+ return;
1183
+
1184
+ ieee80211_report_used_skb(local, skb, false);
1185
+ if (status->free_list)
1186
+ list_add_tail(&skb->list, status->free_list);
1187
+ else
1188
+ dev_kfree_skb(skb);
9981189 }
9991190 EXPORT_SYMBOL(ieee80211_tx_status_ext);
10001191
1192
+void ieee80211_tx_rate_update(struct ieee80211_hw *hw,
1193
+ struct ieee80211_sta *pubsta,
1194
+ struct ieee80211_tx_info *info)
1195
+{
1196
+ struct ieee80211_local *local = hw_to_local(hw);
1197
+ struct ieee80211_supported_band *sband = hw->wiphy->bands[info->band];
1198
+ struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
1199
+ struct ieee80211_tx_status status = {
1200
+ .info = info,
1201
+ .sta = pubsta,
1202
+ };
1203
+
1204
+ rate_control_tx_status(local, sband, &status);
1205
+
1206
+ if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1207
+ sta->tx_stats.last_rate = info->status.rates[0];
1208
+}
1209
+EXPORT_SYMBOL(ieee80211_tx_rate_update);
1210
+
1211
+void ieee80211_tx_status_8023(struct ieee80211_hw *hw,
1212
+ struct ieee80211_vif *vif,
1213
+ struct sk_buff *skb)
1214
+{
1215
+ struct ieee80211_sub_if_data *sdata;
1216
+ struct ieee80211_tx_status status = {
1217
+ .skb = skb,
1218
+ .info = IEEE80211_SKB_CB(skb),
1219
+ };
1220
+ struct sta_info *sta;
1221
+
1222
+ sdata = vif_to_sdata(vif);
1223
+
1224
+ rcu_read_lock();
1225
+
1226
+ if (!ieee80211_lookup_ra_sta(sdata, skb, &sta) && !IS_ERR(sta))
1227
+ status.sta = &sta->sta;
1228
+
1229
+ ieee80211_tx_status_ext(hw, &status);
1230
+
1231
+ rcu_read_unlock();
1232
+}
1233
+EXPORT_SYMBOL(ieee80211_tx_status_8023);
1234
+
10011235 void ieee80211_report_low_ack(struct ieee80211_sta *pubsta, u32 num_packets)
10021236 {
10031237 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);