diff mbox series

[RFC,4/7] mac80211: add freq_offset to RX status

Message ID 20200401062150.3324-5-thomas@adapt-ip.com (mailing list archive)
State RFC
Delegated to: Johannes Berg
Headers show
Series add a KHz component to wireless channels | expand

Commit Message

Thomas Pedersen April 1, 2020, 6:21 a.m. UTC
RX status needs a KHz component, so add freq_offset. We
can make ampdu_reference u16 since it is probably
sufficient to be able to distinguish 64k different
A-MPDUs.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
---
 include/net/mac80211.h | 10 +++++++++-
 net/mac80211/mlme.c    |  6 ++++--
 net/mac80211/rx.c      |  1 +
 net/mac80211/scan.c    |  3 ++-
 4 files changed, 16 insertions(+), 4 deletions(-)

Comments

Johannes Berg April 1, 2020, 7:08 a.m. UTC | #1
On Tue, 2020-03-31 at 23:21 -0700, Thomas Pedersen wrote:
> RX status needs a KHz component, so add freq_offset. We
> can make ampdu_reference u16 since it is probably
> sufficient to be able to distinguish 64k different
> A-MPDUs.

Is that necessary? Reads like we have 2 bytes free there?

And we only need 13 bits for the frequency (up to 8192 MHz, 60 GHz isn't
supported), so we could take out a few fractional ones for the S1G part?

Dunno, I mean, we probably also don't need the A-MPDU reference, even
radiotap doesn't make much representation on this, but it sort of
implies that it should be unique in a capture file, for which 16 bits
wouldn't be enough? (should probably clarify that though and say that
you should look only "close by" or something?)

johannes
Thomas Pedersen April 1, 2020, 5:58 p.m. UTC | #2
On 4/1/20 12:08 AM, Johannes Berg wrote:
> On Tue, 2020-03-31 at 23:21 -0700, Thomas Pedersen wrote:
>> RX status needs a KHz component, so add freq_offset. We
>> can make ampdu_reference u16 since it is probably
>> sufficient to be able to distinguish 64k different
>> A-MPDUs.
> 
> Is that necessary? Reads like we have 2 bytes free there?

Indeed there is, maybe this wasn't the case on 4.9 where I originally
wrote this patch.

> And we only need 13 bits for the frequency (up to 8192 MHz, 60 GHz isn't
> supported), so we could take out a few fractional ones for the S1G part?

Makes sense, and yeah we really don't need 2 whole bytes to essentially
express "+0.5 MHz". Will shorten the frequency and just use a single bit
indicating offset or not.

> Dunno, I mean, we probably also don't need the A-MPDU reference, even
> radiotap doesn't make much representation on this, but it sort of
> implies that it should be unique in a capture file, for which 16 bits
> wouldn't be enough? (should probably clarify that though and say that
> you should look only "close by" or something?)

Yeah. I'll drop this for now, but maybe the space will come in handy in
the future.
diff mbox series

Patch

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b6b4de0e4b5e..459ec57248fc 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1333,6 +1333,7 @@  enum mac80211_rx_encoding {
  * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  *	This field must be set for management frames, but isn't strictly needed
  *	for data (other) frames - for those it only affects radiotap reporting.
+ * @freq_offset: positive KHz component of @freq.
  * @signal: signal strength when receiving this frame, either in dBm, in dB or
  *	unspecified depending on the hardware capabilities flags
  *	@IEEE80211_HW_SIGNAL_*
@@ -1361,9 +1362,10 @@  struct ieee80211_rx_status {
 	u64 mactime;
 	u64 boottime_ns;
 	u32 device_timestamp;
-	u32 ampdu_reference;
 	u32 flag;
+	u16 ampdu_reference;
 	u16 freq;
+	u16 freq_offset;
 	u8 enc_flags;
 	u8 encoding:2, bw:3, he_ru:3;
 	u8 he_gi:2, he_dcm:1;
@@ -1379,6 +1381,12 @@  struct ieee80211_rx_status {
 	u8 zero_length_psdu_type;
 };
 
+static inline u32
+ieee80211_rx_status_to_khz(struct ieee80211_rx_status *rx_status)
+{
+	return MHZ_TO_KHZ(rx_status->freq) + rx_status->freq_offset;
+}
+
 /**
  * struct ieee80211_vendor_radiotap - vendor radiotap data information
  * @present: presence bitmap for this vendor namespace
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 4eebee49bb7d..e5bcd786e333 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -3669,7 +3669,8 @@  static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
 
 	sdata_assert_lock(sdata);
 
-	channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
+	channel = ieee80211_get_channel_khz(local->hw.wiphy,
+				ieee80211_rx_status_to_khz(rx_status));
 	if (!channel)
 		return;
 
@@ -3885,7 +3886,8 @@  static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
 		return;
 	}
 
-	if (rx_status->freq != chanctx_conf->def.chan->center_freq) {
+	if (rx_status->freq != chanctx_conf->def.chan->center_freq ||
+	    rx_status->freq_offset != chanctx_conf->def.chan->freq_offset) {
 		rcu_read_unlock();
 		return;
 	}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 91a13aee4378..0b6dca4c0c7d 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -412,6 +412,7 @@  ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
 	pos++;
 
 	/* IEEE80211_RADIOTAP_CHANNEL */
+	/* TODO: frequency offset in KHz */
 	put_unaligned_le16(status->freq, pos);
 	pos += 2;
 	if (status->bw == RATE_INFO_BW_10)
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 4d14118dddca..5db15996524f 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -275,7 +275,8 @@  void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
 			return;
 	}
 
-	channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
+	channel = ieee80211_get_channel_khz(local->hw.wiphy,
+					ieee80211_rx_status_to_khz(rx_status));
 
 	if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
 		return;