diff mbox series

[v2,2/2] mac80211_hwsim: set rx_status mactime/flag for wmediumd path

Message ID 20191122170612.8123-2-prestwoj@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series [v2,1/2] mac80211_hwsim: enable parent TSF feature | expand

Commit Message

James Prestwood Nov. 22, 2019, 5:06 p.m. UTC
This patch sets the required rx_status mactime and flags in order for
the parent TSF value to be calculated and sent to userspace. This is
already done elsewhere, but this patch allows this to work for the
wmediumd code path.
---
 drivers/net/wireless/mac80211_hwsim.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Johannes Berg Nov. 22, 2019, 5:15 p.m. UTC | #1
On Fri, 2019-11-22 at 09:06 -0800, James Prestwood wrote:
> This patch sets the required rx_status mactime and flags in order for
> the parent TSF value to be calculated and sent to userspace. This is
> already done elsewhere, but this patch allows this to work for the
> wmediumd code path.
> 

:)

Now you just need a s-o-b.

johannes
diff mbox series

Patch

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index e9bc599481d4..01b2ac9707cc 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3238,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] ||
@@ -3300,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;