mac80211: support RX_FLAG_MACTIME_END
Subsystems (3)
PATCH v2 1/1 mac80211: support RX_FLAG_MACTIME_END
Allow drivers to indicate their mactime is at RX completion and adjust for this in mac80211. Also rename the existing RX_FLAG_MACTIME_MPDU to RX_FLAG_MACTIME_START to clarify its intent. Based on similar code by Johannes Berg.
---
v2:
Rename MACTIME_MPDU to MACTIME_START (Javier) Throw a warning if invalid combination is set (Javier) Use FCS_LEN and improve documentation (Johannes)
drivers/net/wireless/b43/xmit.c | 2 +- drivers/net/wireless/b43legacy/xmit.c | 2 +- drivers/net/wireless/brcm80211/brcmsmac/main.c | 2 +- drivers/net/wireless/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/iwlwifi/dvm/rx.c | 2 +- drivers/net/wireless/mac80211_hwsim.c | 2 +- drivers/net/wireless/p54/txrx.c | 2 +- drivers/net/wireless/rtl818x/rtl8180/dev.c | 2 +- drivers/net/wireless/rtl818x/rtl8187/dev.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 2 +- drivers/net/wireless/ti/wl1251/rx.c | 2 +- include/net/mac80211.h | 8 +++- net/mac80211/ibss.c | 29 +++----------- net/mac80211/ieee80211_i.h | 11 ++++++ net/mac80211/mesh_sync.c | 44 ++++----------------- net/mac80211/rx.c | 14 +++++-- net/mac80211/util.c | 50 ++++++++++++++++++++++++ 20 files changed, 104 insertions(+), 80 deletions(-)
drivers/net/wireless/b43/xmit.c +1 -1
@@ -796,7 +796,7 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) status.mactime += mactime;if (low_mactime_now <= mactime) status.mactime -=0x10000 ; - status.flag |=RX_FLAG_MACTIME_MPDU ; + status.flag |=RX_FLAG_MACTIME_START ; } chanid = (chanstat &B43_RX_CHAN_ID ) >>B43_RX_CHAN_ID_SHIFT ;
drivers/net/wireless/b43legacy/xmit.c +1 -1
@@ -557,7 +557,7 @@ void b43legacy_rx(struct b43legacy_wldev *dev, status.mactime += mactime;if (low_mactime_now <= mactime) status.mactime -=0x10000 ; - status.flag |=RX_FLAG_MACTIME_MPDU ; + status.flag |=RX_FLAG_MACTIME_START ; } chanid = (chanstat & B43legacy_RX_CHAN_ID) >>
drivers/net/wireless/brcm80211/brcmsmac/main.c +1 -1
@@ -7508,7 +7508,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh,/* fill in TSF and flag its presence */ rx_status->mactime =brcms_c_recover_tsf64 (wlc, rxh); - rx_status->flag |=RX_FLAG_MACTIME_MPDU ; + rx_status->flag |=RX_FLAG_MACTIME_START ; channel =BRCMS_CHAN_CHANNEL (rxh->RxChan);
drivers/net/wireless/iwlegacy/4965-mac.c +1 -1
@@ -686,7 +686,7 @@ il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb)/* TSF isn't reliable. In order to allow smooth user experience, * this W/A doesn't propagate it to the mac80211 */ -/*rx_status.flag |= RX_FLAG_MACTIME_MPDU; */ +/*rx_status.flag |= RX_FLAG_MACTIME_START; */ il->ucode_beacon_time =le32_to_cpu (phy_res->beacon_time_stamp);
drivers/net/wireless/iwlwifi/dvm/rx.c +1 -1
@@ -951,7 +951,7 @@ static int iwlagn_rx_reply_rx(struct iwl_priv *priv,/* TSF isn't reliable. In order to allow smooth user experience, * this W/A doesn't propagate it to the mac80211 */ -/*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ +/*rx_status.flag |= RX_FLAG_MACTIME_START;*/ priv->ucode_beacon_time =le32_to_cpu (phy_res->beacon_time_stamp);
drivers/net/wireless/mac80211_hwsim.c +1 -1
@@ -645,7 +645,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw, }memset (&rx_status,0 ,sizeof (rx_status)); - rx_status.flag |=RX_FLAG_MACTIME_MPDU ; + rx_status.flag |=RX_FLAG_MACTIME_START ; rx_status.freq = data->channel->center_freq; rx_status.band = data->channel->band; rx_status.rate_idx = info->control.rates[0 ].idx;
drivers/net/wireless/p54/txrx.c +1 -1
@@ -369,7 +369,7 @@ static int p54_rx_data(struct p54_common *priv, struct sk_buff *skb) rx_status->mactime = ((u64 )priv->tsf_high32) <<32 | tsf32; priv->tsf_low32 = tsf32; - rx_status->flag |=RX_FLAG_MACTIME_MPDU ; + rx_status->flag |=RX_FLAG_MACTIME_START ;if (hdr->flags &cpu_to_le16 (P54_HDR_FLAG_DATA_ALIGN )) header_len += hdr->align[0 ];
drivers/net/wireless/rtl818x/rtl8180/dev.c +1 -1
@@ -150,7 +150,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) rx_status.freq = dev->conf.channel->center_freq; rx_status.band = dev->conf.channel->band; rx_status.mactime =le64_to_cpu (entry->tsft); - rx_status.flag |=RX_FLAG_MACTIME_MPDU ; + rx_status.flag |=RX_FLAG_MACTIME_START ;if (flags &RTL818X_RX_DESC_FLAG_CRC32_ERR ) rx_status.flag |=RX_FLAG_FAILED_FCS_CRC ;
drivers/net/wireless/rtl818x/rtl8187/dev.c +1 -1
@@ -381,7 +381,7 @@ static void rtl8187_rx_cb(struct urb *urb) rx_status.rate_idx = rate; rx_status.freq = dev->conf.channel->center_freq; rx_status.band = dev->conf.channel->band; - rx_status.flag |=RX_FLAG_MACTIME_MPDU ; + rx_status.flag |=RX_FLAG_MACTIME_START ;if (flags &RTL818X_RX_DESC_FLAG_CRC32_ERR ) rx_status.flag |=RX_FLAG_FAILED_FCS_CRC ;memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status));
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +1 -1
@@ -559,7 +559,7 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,if (GET_RX_DESC_RXHT (pdesc)) rx_status->flag |=RX_FLAG_HT ; - rx_status->flag |=RX_FLAG_MACTIME_MPDU ; + rx_status->flag |=RX_FLAG_MACTIME_START ;if (stats->decrypted) rx_status->flag |=RX_FLAG_DECRYPTED ;
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1 -1
@@ -334,7 +334,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw, rx_status->flag |=RX_FLAG_40MHZ ;if (GET_RX_DESC_RX_HT (pdesc)) rx_status->flag |=RX_FLAG_HT ; - rx_status->flag |=RX_FLAG_MACTIME_MPDU ; + rx_status->flag |=RX_FLAG_MACTIME_START ;if (stats->decrypted) rx_status->flag |=RX_FLAG_DECRYPTED ; rx_status->rate_idx = rtlwifi_rate_mapping(hw,
drivers/net/wireless/rtlwifi/rtl8192de/trx.c +1 -1
@@ -509,7 +509,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats, rx_status->flag |=RX_FLAG_40MHZ ;if (GET_RX_DESC_RXHT (pdesc)) rx_status->flag |=RX_FLAG_HT ; - rx_status->flag |=RX_FLAG_MACTIME_MPDU ; + rx_status->flag |=RX_FLAG_MACTIME_START ;if (stats->decrypted) rx_status->flag |=RX_FLAG_DECRYPTED ; rx_status->rate_idx = rtlwifi_rate_mapping(hw,
drivers/net/wireless/rtlwifi/rtl8192se/trx.c +1 -1
@@ -553,7 +553,7 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,if (stats->is_ht) rx_status->flag |=RX_FLAG_HT ; - rx_status->flag |=RX_FLAG_MACTIME_MPDU ; + rx_status->flag |=RX_FLAG_MACTIME_START ;/* hw will set stats->decrypted true, if it finds the * frame is open data frame or mgmt frame,
drivers/net/wireless/ti/wl1251/rx.c +1 -1
@@ -81,7 +81,7 @@ static void wl1251_rx_status(struct wl1251 *wl, status->freq =ieee80211_channel_to_frequency (desc->channel, status->band); - status->flag |=RX_FLAG_MACTIME_MPDU ; + status->flag |=RX_FLAG_MACTIME_START ;if (desc->flags &RX_DESC_ENCRYPTION_MASK ) { status->flag |=RX_FLAG_IV_STRIPPED |RX_FLAG_MMIC_STRIPPED ;
include/net/mac80211.h +6 -2
@@ -700,10 +700,13 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)* the frame. * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on * the frame. -* @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime +* @RX_FLAG_MACTIME_START: The timestamp passed in the RX status (@mactime * field) is valid and contains the time the first symbol of the MPDU * was received. This is useful in monitor mode and for proper IBSS * merging. +* @RX_FLAG_MACTIME_END: The timestamp passed in the RX status (@mactime +* field) is valid and contains the time the last symbol of the MPDU +* (including FCS) was received. * @RX_FLAG_SHORTPRE: Short preamble was used for this frame * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
@@ -734,7 +737,7 @@ enum mac80211_rx_flags {RX_FLAG_IV_STRIPPED =BIT (4 ),RX_FLAG_FAILED_FCS_CRC =BIT (5 ),RX_FLAG_FAILED_PLCP_CRC =BIT (6 ), -RX_FLAG_MACTIME_MPDU =BIT (7 ), +RX_FLAG_MACTIME_START =BIT (7 ),RX_FLAG_SHORTPRE =BIT (8 ),RX_FLAG_HT =BIT (9 ), RX_FLAG_40MHZ = BIT(10),
@@ -748,6 +751,7 @@ enum mac80211_rx_flags {RX_FLAG_AMPDU_IS_LAST =BIT (18 ),RX_FLAG_AMPDU_DELIM_CRC_ERROR =BIT (19 ),RX_FLAG_AMPDU_DELIM_CRC_KNOWN =BIT (20 ), + RX_FLAG_MACTIME_END = BIT(21), };/**
net/mac80211/ibss.c +5 -24
@@ -543,30 +543,11 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,if (ether_addr_equal (cbss->bssid, sdata->u.ibss.bssid)) goto put_bss; -if (rx_status->flag &RX_FLAG_MACTIME_MPDU ) { -/* -* For correct IBSS merging we need mactime; since mactime is -* defined as the time the first data symbol of the frame hits -* the PHY, and the timestamp of the beacon is defined as "the -* time that the data symbol containing the first bit of the -* timestamp is transmitted to the PHY plus the transmitting -* STA's delays through its local PHY from the MAC-PHY -* interface to its interface with the WM" (802.11 11.1.2) -* - equals the time this bit arrives at the receiver - we have -* to take into account the offset between the two. -* -* E.g. at 1 MBit that means mactime is 192 usec earlier -* (=24 bytes * 8 usecs/byte) than the beacon timestamp. -*/ -int rate; - -if (rx_status->flag &RX_FLAG_HT ) - rate =65 ;/* TODO: HT rates */ -else - rate = local->hw.wiphy->bands[band]-> - bitrates[rx_status->rate_idx].bitrate; - - rx_timestamp = rx_status->mactime + (24 *8 *10 / rate); +if (ieee80211_have_rx_timestamp (rx_status)) { +/* time when timestamp field was received */ + rx_timestamp = +ieee80211_calculate_rx_timestamp (local, rx_status, + len +FCS_LEN ,24 ); }else {/* * second best option: get current TSF
net/mac80211/ieee80211_i.h +11 -0
@@ -1251,7 +1251,18 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)is_broadcast_ether_addr (raddr); } +static inline bool +ieee80211_have_rx_timestamp (struct ieee80211_rx_status *status) +{ +WARN_ON_ONCE (status->flag &RX_FLAG_MACTIME_START && + status->flag &RX_FLAG_MACTIME_END ); +return status->flag & (RX_FLAG_MACTIME_START |RX_FLAG_MACTIME_END ); +} +u64 ieee80211_calculate_rx_timestamp (struct ieee80211_local *local, +struct ieee80211_rx_status *status, +unsigned int mpdu_len, +unsigned int mpdu_offset);int ieee80211_hw_config (struct ieee80211_local *local,u32 changed);void ieee80211_tx_set_protected (struct ieee80211_tx_data *tx); void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
net/mac80211/mesh_sync.c +7 -37
50 lines not on this page · raw message
net/mac80211/rx.c +11 -3
@@ -82,7 +82,7 @@ ieee80211_rx_radiotap_len(struct ieee80211_local *local,/* always present fields */ len =sizeof (struct ieee80211_radiotap_header ) +9 ; -if (status->flag &RX_FLAG_MACTIME_MPDU ) +if (ieee80211_have_rx_timestamp (status)) len +=8 ;if (local->hw.flags &IEEE80211_HW_SIGNAL_DBM ) len +=1 ;
@@ -118,6 +118,11 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,struct ieee80211_radiotap_header *rthdr;unsigned char *pos;u16 rx_flags =0 ; +int mpdulen; + + mpdulen = skb->len; +if (!(has_fcs && (local->hw.flags &IEEE80211_HW_RX_INCLUDES_FCS ))) + mpdulen +=FCS_LEN ; rthdr = (struct ieee80211_radiotap_header *)skb_push (skb, rtap_len);memset (rthdr,0 , rtap_len);
@@ -135,8 +140,11 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,/* the order of the following fields is important */ /* IEEE80211_RADIOTAP_TSFT */ -if (status->flag &RX_FLAG_MACTIME_MPDU ) { -put_unaligned_le64 (status->mactime, pos); +if (ieee80211_have_rx_timestamp (status)) { +put_unaligned_le64 ( +ieee80211_calculate_rx_timestamp (local, status, + mpdulen,0 ), + pos); rthdr->it_present |=cpu_to_le32 (1 <<IEEE80211_RADIOTAP_TSFT ); pos +=8 ;
net/mac80211/util.c +50 -0
53 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 4 lines · Thomas Pedersen
Allow drivers to indicate their mactime is at RX completion and adjust for this in mac80211. Also rename the existing
RX_FLAG_MACTIME_MPDUtoRX_FLAG_MACTIME_STARTto clarify its intent. Based on similar code by Johannes Berg.
Applied, but I had to fix up the patch to apply on mac80211-next, and even had to make it compile by adjusting the Atheros drivers ...
johannes
Quoted 8 lines · Johannes Berg
Quoted 4 lines · Thomas Pedersen
Allow drivers to indicate their mactime is at RX completion and adjust for this in mac80211. Also rename the existing
RX_FLAG_MACTIME_MPDUtoRX_FLAG_MACTIME_STARTto clarify its intent. Based on similar code by Johannes Berg.Applied, but I had to fix up the patch to apply on mac80211-next, and even had to make it compile by adjusting the Atheros drivers ...
Rats. It applied on wireless-testing. In the future, submitted mac80211 patches should be rebased onto mac80211-next?
Thomas
Quoted 8 lines · Johannes Berg
Quoted 4 lines · Thomas Pedersen
Allow drivers to indicate their mactime is at RX completion and adjust for this in mac80211. Also rename the existing
RX_FLAG_MACTIME_MPDUtoRX_FLAG_MACTIME_STARTto clarify its intent. Based on similar code by Johannes Berg.Applied, but I had to fix up the patch to apply on mac80211-next, and even had to make it compile by adjusting the Atheros drivers ...
Ok the ath9k compile was my fault. Sorry about that.
Thomas
Johannes Berg
maintainerQuoted 8 lines · Thomas Pedersen
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Thomas Pedersen
Allow drivers to indicate their mactime is at RX completion and adjust for this in mac80211. Also rename the existing
RX_FLAG_MACTIME_MPDUtoRX_FLAG_MACTIME_STARTto clarify its intent. Based on similar code by Johannes Berg.
Quoted 5 lines
Quoted 2 lines
Applied, but I had to fix up the patch to apply on mac80211-next, and even had to make it compile by adjusting the Atheros drivers ...
Rats. It applied on wireless-testing. In the future, submitted mac80211 patches should be rebased onto mac80211-next?
Honestly, wireless-testing usually works, it's just that John hasn't pulled for a while and there's a whole bunch of stuff in mac80211-next right now. No biggie to fix up really, though I think you should've fixed up the Atheros drivers :)
johannes