]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: report boottime of receiving beacon and probe response
authorZong-Zhe Yang <kevin_yang@realtek.com>
Wed, 18 Jun 2025 12:46:48 +0000 (20:46 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Tue, 24 Jun 2025 06:38:53 +0000 (14:38 +0800)
Userspace tools will parse NL80211_BSS_LAST_SEEN_BOOTTIME (if any) for a
more accurate timing when a BSS was seen. For example, iw, wpa_supplicant.
For beacon and probe response, fill RX boottime_ns in ieee80211_rx_status.
And for certain, it shouldn't count the waiting time for the PPDU status,
i.e. the possible buffering time of a frame in driver.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250618124649.11436-6-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.c

index 0babf5472195447c9dbe71680d7a5db01766d90c..1f5639a5d1663239585306b38666205ec05cf60d 100644 (file)
@@ -2796,9 +2796,11 @@ static void rtw89_core_stats_sta_rx_status(struct rtw89_dev *rtwdev,
 }
 
 static void rtw89_core_update_rx_status(struct rtw89_dev *rtwdev,
+                                       struct sk_buff *skb,
                                        struct rtw89_rx_desc_info *desc_info,
                                        struct ieee80211_rx_status *rx_status)
 {
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
        const struct cfg80211_chan_def *chandef =
                rtw89_chandef_get(rtwdev, RTW89_CHANCTX_0);
        u16 data_rate;
@@ -2810,6 +2812,10 @@ static void rtw89_core_update_rx_status(struct rtw89_dev *rtwdev,
        rx_status->freq = chandef->chan->center_freq;
        rx_status->band = chandef->chan->band;
 
+       if (ieee80211_is_beacon(hdr->frame_control) ||
+           ieee80211_is_probe_resp(hdr->frame_control))
+               rx_status->boottime_ns = ktime_get_boottime_ns();
+
        if (rtwdev->scanning &&
            RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw)) {
                const struct rtw89_chan *cur = rtw89_scan_chan_get(rtwdev);
@@ -2966,7 +2972,7 @@ void rtw89_core_rx(struct rtw89_dev *rtwdev,
 
        rx_status = IEEE80211_SKB_RXCB(skb);
        memset(rx_status, 0, sizeof(*rx_status));
-       rtw89_core_update_rx_status(rtwdev, desc_info, rx_status);
+       rtw89_core_update_rx_status(rtwdev, skb, desc_info, rx_status);
        rtw89_core_rx_pkt_hdl(rtwdev, skb, desc_info);
        if (desc_info->long_rxdesc &&
            BIT(desc_info->frame_type) & PPDU_FILTER_BITMAP)