Skip to contentSkip to conversation

mac80211_hwsim: support parent TSF feature

PATCH Superseded James Prestwood 2 participants 2 messages Nov 19, 2019 – Nov 22, 2019 Networking drivers (wireless)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211_hwsim: support parent TSF feature

Only iwlwifi actually enables this feature, but the support for sending parent TSF/BSSID values already exists in nl80211. This patch sets the appropriate flag and mactime values in rx_status so that the parent TSF value gets included in the scan results.

---
 drivers/net/wireless/mac80211_hwsim.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/wireless/mac80211_hwsim.c +15 -0
index 772e54f0696f..01b2ac9707cc 100644
@@ -2825,6 +2825,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
 			       NL80211_FEATURE_DYNAMIC_SMPS |
 			       NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
 	wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
+	wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_BSS_PARENT_TSF);
 
 	hw->wiphy->interface_modes = param->iftypes;
 
@@ -3237,6 +3238,8 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
 	int frame_data_len;
 	void *frame_data;
 	struct sk_buff *skb = NULL;
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb_2->data;
+	u64 now;
 
 	if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] ||
 	    !info->attrs[HWSIM_ATTR_FRAME] ||
@@ -3299,6 +3302,18 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
 	rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]);
 	rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]);
 
+	if (ieee80211_is_beacon(hdr->frame_control) ||
+	    ieee80211_is_probe_resp(hdr->frame_control)) {
+		rx_status.boottime_ns = ktime_get_boottime_ns();
+		now = data2->abs_bcn_ts;
+	} else {
+		now = mac80211_hwsim_get_tsf_raw();
+	}
+
+	rx_status.mactime = now + data2->tsf_offset;
+
+	rx_status.flag |= RX_FLAG_MACTIME_START;
+
 	memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
 	data2->rx_pkts++;
 	data2->rx_bytes += skb->len;
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Please split this patch. The only thing actually related to what your commit log mentions is the first part setting the nl80211 feature bit.

The rest is just porting some existing code to the wmediumd code path.

johannes