Lines Matching +full:duration +full:- +full:us
1 // SPDX-License-Identifier: ISC
4 * Copyright (C) 2021-2022 Intel Corporation
16 /* Number of kilo-symbols (symbols * 1024) for a packet with (bps) bits per
17 * symbol. We use k-symbols to avoid rounding in the _TIME macros below.
26 ((ksyms) * 4 * 18) / 20 : /* 3.6 us per sym */ \
27 ((ksyms) * 4) /* 4.0 us per sym */ \
30 /* Transmit duration for the raw data part of an average sized packet */
42 /* Transmission time (1024 usec) for a packet containing (ksyms) * k-symbols */
45 ((ksyms) * 16 * 17) / 20 : /* 13.6 us per sym */ \
47 ((ksyms) * 16 * 18) / 20 : /* 14.4 us per sym */ \
48 ((ksyms) * 16) /* 16.0 us per sym */ \
51 /* Transmit duration for the raw data part of an average sized packet */
75 * Define group sort order: HT40 -> SGI -> #streams
107 _streams - 1
111 #define GROUP_SHIFT(duration) \ argument
112 _MAX(0, 16 - __builtin_clz(duration))
118 .duration = { \
141 (_streams) - 1)
149 .duration = { \
186 (_streams) - 1)
191 .duration = { \
234 (_streams) - 1)
239 .duration = { \
291 u16 duration[MCS_GROUP_RATES]; member
488 u32 duration; in ieee80211_calc_legacy_rate_duration() local
491 duration = 144 + 48; /* preamble + PLCP */ in ieee80211_calc_legacy_rate_duration()
493 duration >>= 1; in ieee80211_calc_legacy_rate_duration()
495 duration += 10; /* SIFS */ in ieee80211_calc_legacy_rate_duration()
497 duration = 20 + 16; /* premable + SIFS */ in ieee80211_calc_legacy_rate_duration()
501 duration += (len * 10) / bitrate; in ieee80211_calc_legacy_rate_duration()
503 return duration; in ieee80211_calc_legacy_rate_duration()
510 bool sgi = status->enc_flags & RX_ENC_FLAG_SHORT_GI; in ieee80211_get_rate_duration()
513 u32 duration; in ieee80211_get_rate_duration() local
515 switch (status->bw) { in ieee80211_get_rate_duration()
536 switch (status->encoding) { in ieee80211_get_rate_duration()
538 streams = status->nss; in ieee80211_get_rate_duration()
539 idx = status->rate_idx; in ieee80211_get_rate_duration()
543 streams = ((status->rate_idx >> 3) & 3) + 1; in ieee80211_get_rate_duration()
544 idx = status->rate_idx & 7; in ieee80211_get_rate_duration()
548 streams = status->nss; in ieee80211_get_rate_duration()
549 idx = status->rate_idx; in ieee80211_get_rate_duration()
550 group = HE_GROUP_IDX(streams, status->he_gi, bw); in ieee80211_get_rate_duration()
553 streams = status->nss; in ieee80211_get_rate_duration()
554 idx = status->rate_idx; in ieee80211_get_rate_duration()
555 group = EHT_GROUP_IDX(streams, status->eht.gi, bw); in ieee80211_get_rate_duration()
562 switch (status->encoding) { in ieee80211_get_rate_duration()
577 duration = airtime_mcs_groups[group].duration[idx]; in ieee80211_get_rate_duration()
578 duration <<= airtime_mcs_groups[group].shift; in ieee80211_get_rate_duration()
581 return duration; in ieee80211_get_rate_duration()
590 u32 duration, overhead = 0; in ieee80211_calc_rx_airtime() local
592 if (status->encoding == RX_ENC_LEGACY) { in ieee80211_calc_rx_airtime()
594 bool sp = status->enc_flags & RX_ENC_FLAG_SHORTPRE; in ieee80211_calc_rx_airtime()
597 /* on 60GHz or sub-1GHz band, there are no legacy rates */ in ieee80211_calc_rx_airtime()
598 if (WARN_ON_ONCE(status->band == NL80211_BAND_60GHZ || in ieee80211_calc_rx_airtime()
599 status->band == NL80211_BAND_S1GHZ)) in ieee80211_calc_rx_airtime()
602 sband = hw->wiphy->bands[status->band]; in ieee80211_calc_rx_airtime()
603 if (!sband || status->rate_idx >= sband->n_bitrates) in ieee80211_calc_rx_airtime()
606 rate = &sband->bitrates[status->rate_idx]; in ieee80211_calc_rx_airtime()
607 cck = rate->flags & IEEE80211_RATE_MANDATORY_B; in ieee80211_calc_rx_airtime()
609 return ieee80211_calc_legacy_rate_duration(rate->bitrate, sp, in ieee80211_calc_rx_airtime()
613 duration = ieee80211_get_rate_duration(hw, status, &overhead); in ieee80211_calc_rx_airtime()
614 if (!duration) in ieee80211_calc_rx_airtime()
617 duration *= len; in ieee80211_calc_rx_airtime()
618 duration /= AVG_PKT_SIZE; in ieee80211_calc_rx_airtime()
619 duration /= 1024; in ieee80211_calc_rx_airtime()
621 return duration + overhead; in ieee80211_calc_rx_airtime()
629 struct ieee80211_supported_band *sband = hw->wiphy->bands[band]; in ieee80211_fill_rate_info()
635 stat->bw = ri->bw; in ieee80211_fill_rate_info()
636 stat->nss = ri->nss; in ieee80211_fill_rate_info()
637 stat->rate_idx = ri->mcs; in ieee80211_fill_rate_info()
639 if (ri->flags & RATE_INFO_FLAGS_EHT_MCS) in ieee80211_fill_rate_info()
640 stat->encoding = RX_ENC_EHT; in ieee80211_fill_rate_info()
641 else if (ri->flags & RATE_INFO_FLAGS_HE_MCS) in ieee80211_fill_rate_info()
642 stat->encoding = RX_ENC_HE; in ieee80211_fill_rate_info()
643 else if (ri->flags & RATE_INFO_FLAGS_VHT_MCS) in ieee80211_fill_rate_info()
644 stat->encoding = RX_ENC_VHT; in ieee80211_fill_rate_info()
645 else if (ri->flags & RATE_INFO_FLAGS_MCS) in ieee80211_fill_rate_info()
646 stat->encoding = RX_ENC_HT; in ieee80211_fill_rate_info()
648 stat->encoding = RX_ENC_LEGACY; in ieee80211_fill_rate_info()
650 if (ri->flags & RATE_INFO_FLAGS_SHORT_GI) in ieee80211_fill_rate_info()
651 stat->enc_flags |= RX_ENC_FLAG_SHORT_GI; in ieee80211_fill_rate_info()
653 switch (stat->encoding) { in ieee80211_fill_rate_info()
655 stat->eht.gi = ri->eht_gi; in ieee80211_fill_rate_info()
658 stat->he_gi = ri->he_gi; in ieee80211_fill_rate_info()
662 if (stat->encoding != RX_ENC_LEGACY) in ieee80211_fill_rate_info()
665 stat->rate_idx = 0; in ieee80211_fill_rate_info()
666 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_fill_rate_info()
667 if (ri->legacy != sband->bitrates[i].bitrate) in ieee80211_fill_rate_info()
670 stat->rate_idx = i; in ieee80211_fill_rate_info()
683 stat->band = band; in ieee80211_fill_rx_status()
689 return -1; in ieee80211_fill_rx_status()
691 if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) in ieee80211_fill_rx_status()
692 stat->bw = RATE_INFO_BW_160; in ieee80211_fill_rx_status()
693 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) in ieee80211_fill_rx_status()
694 stat->bw = RATE_INFO_BW_80; in ieee80211_fill_rx_status()
695 else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) in ieee80211_fill_rx_status()
696 stat->bw = RATE_INFO_BW_40; in ieee80211_fill_rx_status()
698 stat->bw = RATE_INFO_BW_20; in ieee80211_fill_rx_status()
700 stat->enc_flags = 0; in ieee80211_fill_rx_status()
701 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) in ieee80211_fill_rx_status()
702 stat->enc_flags |= RX_ENC_FLAG_SHORTPRE; in ieee80211_fill_rx_status()
703 if (rate->flags & IEEE80211_TX_RC_SHORT_GI) in ieee80211_fill_rx_status()
704 stat->enc_flags |= RX_ENC_FLAG_SHORT_GI; in ieee80211_fill_rx_status()
706 stat->rate_idx = rate->idx; in ieee80211_fill_rx_status()
707 if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { in ieee80211_fill_rx_status()
708 stat->encoding = RX_ENC_VHT; in ieee80211_fill_rx_status()
709 stat->rate_idx = ieee80211_rate_get_vht_mcs(rate); in ieee80211_fill_rx_status()
710 stat->nss = ieee80211_rate_get_vht_nss(rate); in ieee80211_fill_rx_status()
711 } else if (rate->flags & IEEE80211_TX_RC_MCS) { in ieee80211_fill_rx_status()
712 stat->encoding = RX_ENC_HT; in ieee80211_fill_rx_status()
714 stat->encoding = RX_ENC_LEGACY; in ieee80211_fill_rx_status()
737 u32 duration = 0; in ieee80211_calc_tx_airtime() local
740 for (i = 0; i < ARRAY_SIZE(info->status.rates); i++) { in ieee80211_calc_tx_airtime()
741 struct ieee80211_tx_rate *rate = &info->status.rates[i]; in ieee80211_calc_tx_airtime()
745 info->band, len); in ieee80211_calc_tx_airtime()
749 duration += cur_duration * rate->count; in ieee80211_calc_tx_airtime()
752 return duration; in ieee80211_calc_tx_airtime()
771 conf = rcu_dereference(vif->bss_conf.chanctx_conf); in ieee80211_calc_expected_tx_airtime()
773 band = conf->def.chan->band; in ieee80211_calc_expected_tx_airtime()
779 struct ieee80211_tx_rate *tx_rate = &sta->deflink.tx_stats.last_rate; in ieee80211_calc_expected_tx_airtime()
780 struct rate_info *ri = &sta->deflink.tx_stats.last_rate_info; in ieee80211_calc_expected_tx_airtime()
781 u32 duration, overhead; in ieee80211_calc_expected_tx_airtime() local
790 duration = ieee80211_get_rate_duration(hw, &stat, &overhead); in ieee80211_calc_expected_tx_airtime()
797 * assuming un-aggregated tx in all cases. in ieee80211_calc_expected_tx_airtime()
799 if (duration > 400 * 1024) /* <= VHT20 MCS2 1S */ in ieee80211_calc_expected_tx_airtime()
801 else if (duration > 250 * 1024) /* <= VHT20 MCS3 1S or MCS1 2S */ in ieee80211_calc_expected_tx_airtime()
803 else if (duration > 150 * 1024) /* <= VHT20 MCS5 1S or MCS2 2S */ in ieee80211_calc_expected_tx_airtime()
805 else if (duration > 70 * 1024) /* <= VHT20 MCS5 2S */ in ieee80211_calc_expected_tx_airtime()
808 duration > 20 * 1024) /* <= HE40 MCS6 2S */ in ieee80211_calc_expected_tx_airtime()
813 duration *= len; in ieee80211_calc_expected_tx_airtime()
814 duration /= AVG_PKT_SIZE; in ieee80211_calc_expected_tx_airtime()
815 duration /= 1024; in ieee80211_calc_expected_tx_airtime()
816 duration += (overhead >> agg_shift); in ieee80211_calc_expected_tx_airtime()
818 return max_t(u32, duration, 4); in ieee80211_calc_expected_tx_airtime()
824 /* No station to get latest rate from, so calculate the worst-case in ieee80211_calc_expected_tx_airtime()
825 * duration using the lowest configured basic rate. in ieee80211_calc_expected_tx_airtime()
827 sband = hw->wiphy->bands[band]; in ieee80211_calc_expected_tx_airtime()
829 basic_rates = vif->bss_conf.basic_rates; in ieee80211_calc_expected_tx_airtime()
830 short_pream = vif->bss_conf.use_short_preamble; in ieee80211_calc_expected_tx_airtime()
832 rateidx = basic_rates ? ffs(basic_rates) - 1 : 0; in ieee80211_calc_expected_tx_airtime()
833 rate = sband->bitrates[rateidx].bitrate; in ieee80211_calc_expected_tx_airtime()
834 cck = sband->bitrates[rateidx].flags & IEEE80211_RATE_MANDATORY_B; in ieee80211_calc_expected_tx_airtime()