wifi: mm81x: monitor mode and rx improvements
Lachlan Hodges
maintainercover wifi: mm81x: monitor mode and rx improvements
Hi,
This set adds basic S1G monitor mode reporting and some improvements to the Rx path and bug fix for sharing sband across modules.
lachlan
Lachlan Hodges (3):
wifi: mm81x: provide the station to mac80211 on rx
wifi: mm81x: add monitor mode support
wifi: mm81x: copy new sband for each module
.../net/wireless/morsemicro/mm81x/command.c | 5 +- drivers/net/wireless/morsemicro/mm81x/core.h | 16 +- drivers/net/wireless/morsemicro/mm81x/mac.c | 285 ++++++++++++++---- 3 files changed, 246 insertions(+), 60 deletions(-)
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH 1/3 wifi: mm81x: provide the station to mac80211 on rx
Right now we look up the station on rx to update its average RSSI but then hand the frame to mac80211 without it, leaving mac80211 to look the station up again. Use ieee80211_rx_napi() and rework the code a bit so we pass the station directly to mac80211 to prevent another lookup.
--- drivers/net/wireless/morsemicro/mm81x/mac.c | 34 ++++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/net/wireless/morsemicro/mm81x/mac.c +16 -18
@@ -1926,22 +1926,13 @@ static void mm81x_rx_h_fill_status(struct mm81x *mors, rx_status->enc_flags |=RX_ENC_FLAG_SHORT_GI ; } -static void mm81x_rx_h_update_sta (struct ieee80211_vif *vif, -struct ieee80211_hdr *hdr, +static void mm81x_rx_h_update_sta (struct ieee80211_sta *sta,struct ieee80211_rx_status *rx_status) { -struct ieee80211_sta *sta; -struct mm81x_sta *msta; -u8 *lookup =ieee80211_is_s1g_beacon (hdr->frame_control) ? hdr->addr1 : - hdr->addr2; +struct mm81x_sta *msta = (void *)sta->drv_priv;lockdep_assert_in_rcu_read_lock (); - sta =ieee80211_find_sta (vif, lookup); -if (!sta) -return ; - - msta = (void *)sta->drv_priv;if (msta->avg_rssi) { msta->avg_rssi =CALC_AVG_RSSI (msta->avg_rssi, rx_status->signal);
@@ -1969,9 +1960,11 @@ void mm81x_mac_rx_skb(struct mm81x *mors, struct sk_buff *skb, struct mm81x_skb_rx_status *hdr_rx_status) {struct ieee80211_vif *vif; +struct ieee80211_sta *sta =NULL ;struct ieee80211_hw *hw = mors->hw;struct ieee80211_rx_status rx_status;struct ieee80211_hdr *hdr = (void *)skb->data; +u8 *lookup;memset (&rx_status,0 ,sizeof (rx_status));
@@ -1980,19 +1973,24 @@ void mm81x_mac_rx_skb(struct mm81x *mors, struct sk_buff *skb,return ; } + lookup =ieee80211_is_s1g_beacon (hdr->frame_control) ? hdr->addr1 : + hdr->addr2; +mm81x_rx_h_fill_status (mors, hdr_rx_status, &rx_status, skb); +memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status));scoped_guard (rcu) { vif =mm81x_rx_h_skb_get_vif (mors, skb, hdr_rx_status); -if (!vif) - goto rx; +if (vif) { + sta =ieee80211_find_sta (vif, lookup); +if (sta) +mm81x_rx_h_update_sta (sta, &rx_status); + } -mm81x_rx_h_update_sta (vif, hdr, &rx_status); +local_bh_disable (); +ieee80211_rx_napi (hw, sta ? &sta->deflink :NULL , skb,NULL ); +local_bh_enable (); } - -rx: -memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status)); -ieee80211_rx_ni (hw, skb); }static void mm81x_mac_flush_queues (struct mm81x *mors)
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH 2/3 wifi: mm81x: add monitor mode support
In reply to Lachlan HodgesIntroduce monitor mode support by extending the command to add a monitor interface to the firmware and inserting the S1G radiotap TLV. Also rework the .configure_filter() callback to better handle frame filtering when we are in monitor mode. This implementation works best as a standalone sniffer currently, as support is yet to be added in mac80211 to handle building the radiotap for tx frames (i.e if you bind a monitor interface to an existing station or AP).
Right now the S1G radiotap header is not really complete and lacks the ability to convey the frequency offset and correct NDP reporting. The process to amend the S1G TLV will begin after this initial support is complete.
--- .../net/wireless/morsemicro/mm81x/command.c | 5 +- drivers/net/wireless/morsemicro/mm81x/core.h | 16 +- drivers/net/wireless/morsemicro/mm81x/mac.c | 208 +++++++++++++++--- 3 files changed, 195 insertions(+), 34 deletions(-)
drivers/net/wireless/morsemicro/mm81x/command.c +4 -1
@@ -262,6 +262,9 @@ int mm81x_cmd_add_if(struct mm81x *mors, u16 *vif_id, const u8 *addr,case NL80211_IFTYPE_AP : req.interface_type =cpu_to_le32 (HOST_CMD_INTERFACE_TYPE_AP );break ; +case NL80211_IFTYPE_MONITOR : + req.interface_type =cpu_to_le32 (HOST_CMD_INTERFACE_TYPE_MON ); +break ;default :return -EOPNOTSUPP ; }
@@ -458,7 +461,7 @@ int mm81x_cmd_cfg_multicast_filter(struct mm81x *mors, struct mm81x_vif *mors_vif) {struct host_cmd_req_mcast_filter *req; -struct mcast_filter *filter = mors->mcast_filter; +struct mm81x_mcast_filter *filter = mors->mcast_filter;u16 filter_list_len =sizeof (filter->addr_list[0 ]) * filter->count;u16 alloc_len = filter_list_len +sizeof (*req);int ret =0 ;
drivers/net/wireless/morsemicro/mm81x/core.h +14 -2
@@ -225,7 +225,7 @@ struct mm81x_stale_tx_status {struct timer_list timer; }; -struct mcast_filter { +struct mm81x_mcast_filter {u8 count;/* * Integer representation of the last four bytes of a multicast MAC
@@ -335,6 +335,18 @@ struct mm81x {struct ieee80211_vif __rcu *vifs[MM81X_MAX_IF ]; +/* +* Groups A-MPDU subframes for monitor reporting. The firmware stamps +* every subframe of an A-MPDU with the same receive timestamp, so a +* change in timestamp starts a new reference. +*/ +struct { +u64 timestamp; +u32 reference; + } rx_ampdu; + +bool monitor_en; +/* @mm81x_state_flags */ unsigned long state_flags;
@@ -377,7 +389,7 @@ struct mm81x {wait_queue_head_t tx_empty_waitq;struct cfg80211_chan_def chandef; -struct mcast_filter *mcast_filter; +struct mm81x_mcast_filter *mcast_filter;atomic_t num_bcn_vifs;unsigned long beacon_irqs_enabled;u8 drv_priv[]__aligned(sizeof(void *)) ;
drivers/net/wireless/morsemicro/mm81x/mac.c +177 -31
313 lines not on this page · raw message
Signature · 1 line
2.43.0
Lachlan Hodges
maintainerPATCH 3/3 wifi: mm81x: copy new sband for each module
In reply to Lachlan Hodgesthe sband information existed as a single static struct and was directly modified in place by both the stack and the driver. If the regdom was ever changed to 00 where all the S1G channels are NO_IR and a bus module then removed, these flags would remain even after changing the regdom and prevent channels from being used.
Instead, make sure we copy the sband each time we init our mac80211 hw such that when a bus module is removed the state is reset and flags don't persist.
--- drivers/net/wireless/morsemicro/mm81x/mac.c | 45 ++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-)
drivers/net/wireless/morsemicro/mm81x/mac.c +36 -9
@@ -84,7 +84,7 @@ .max_power = 30, \ } -static struct ieee80211_channel mors_s1ghz_channels[] = { +static const struct ieee80211_channel mors_s1ghz_channels[] = {CHANS1G (1 ,902 ,500 ,IEEE80211_CHAN_S1G_NO_PRIMARY ),CHANS1G (3 ,903 ,500 ,0 ),CHANS1G (5 ,904 ,500 ,0 ),
@@ -115,11 +115,9 @@ static struct ieee80211_channel mors_s1ghz_channels[] = {/* clang-format on */ -static struct ieee80211_supported_band mors_band_s1ghz = { +static const struct ieee80211_supported_band mors_band_s1ghz = { .band =NL80211_BAND_S1GHZ , .s1g_cap.s1g = true, - .channels = mors_s1ghz_channels, - .n_channels =ARRAY_SIZE (mors_s1ghz_channels), .bitrates =NULL , .n_bitrates =0 , .s1g_cap.cap[4 ] =0x80 /* STA type sensor only for AP & STA */
@@ -269,8 +267,10 @@ static void mm81x_mac_check_fw_disabled_chans(struct ieee80211_hw *hw)u32 i;struct mm81x *mors = hw->priv;struct host_cmd_resp_get_disabled_channels *resp; +struct ieee80211_supported_band *sband = + hw->wiphy->bands[NL80211_BAND_S1GHZ ];u32 resp_len =sizeof (struct host_cmd_disabled_channel_entry ) * -ARRAY_SIZE (mors_s1ghz_channels) + + sband->n_channels +sizeof (*resp); resp =kzalloc (resp_len,GFP_KERNEL );
@@ -283,8 +283,8 @@ static void mm81x_mac_check_fw_disabled_chans(struct ieee80211_hw *hw)if (ret) goto out; -for (i =0 ; i <ARRAY_SIZE (mors_s1ghz_channels); i++) { -struct ieee80211_channel *ch = &mors_s1ghz_channels[i]; +for (i =0 ; i < sband->n_channels; i++) { +struct ieee80211_channel *ch = &sband->channels[i];if (ch->flags &IEEE80211_CHAN_DISABLED )continue ;
@@ -337,7 +337,8 @@ static int mm81x_tx_h_get_max_tx_bw(struct mm81x *mors)static void mm81x_mac_caps_init (struct mm81x *mors) {struct mm81x_fw_caps *fw_caps = &mors->fw_caps; -struct ieee80211_sta_s1g_cap *s1g = &mors_band_s1ghz.s1g_cap; +struct ieee80211_sta_s1g_cap *s1g = + &mors->hw->wiphy->bands[NL80211_BAND_S1GHZ ]->s1g_cap;#define __FW_CAP_N (_n, _cap, _bit) \ do { \
@@ -2470,7 +2471,6 @@ static void mm81x_mac_config_hw(struct mm81x *mors)for (i =0 ; i <NUM_NL80211_BANDS ; i++) hw->wiphy->bands[i] =NULL ; - hw->wiphy->bands[NL80211_BAND_S1GHZ ] = &mors_band_s1ghz; hw->wiphy->interface_modes =BIT (NL80211_IFTYPE_AP ) |BIT (NL80211_IFTYPE_STATION ); hw->wiphy->reg_notifier = mm81x_reg_notifier;
@@ -2548,6 +2548,28 @@ static void mm81x_mac_stale_tx_status_timer_init(struct mm81x *mors)timer_setup (&mors->stale_status.timer, mm81x_stale_tx_status_timer,0 ); } +static int mm81x_mac_set_sband (struct mm81x *mors) +{ +struct ieee80211_supported_band *sband; + + sband =devm_kmemdup (mors->dev, &mors_band_s1ghz,sizeof (*sband), +GFP_KERNEL ); +if (!sband) +return -ENOMEM ; + + sband->channels =devm_kmemdup_array (mors->dev, mors_s1ghz_channels, +ARRAY_SIZE (mors_s1ghz_channels), +sizeof (*mors_s1ghz_channels), +GFP_KERNEL ); +if (!sband->channels) +return -ENOMEM ; + + sband->n_channels =ARRAY_SIZE (mors_s1ghz_channels); + mors->hw->wiphy->bands[NL80211_BAND_S1GHZ ] = sband; + +return 0 ; +} +int mm81x_mac_register (struct mm81x *mors) {int ret;
@@ -2562,6 +2584,11 @@ int mm81x_mac_register(struct mm81x *mors)return ret;mm81x_mac_config_hw (mors); + + ret =mm81x_mac_set_sband (mors); +if (ret) +return ret; +mm81x_mac_hw_scan_init (mors);mm81x_mac_stale_tx_status_timer_init (mors);
Signature · 1 line
2.43.0