add hw dfs pattern detector support to mt7615 driver
Subsystems (2)
Lorenzo Bianconi
maintainercover add hw dfs pattern detector support to mt7615 driver
Introduce radar pattern detection support to mt7615 driver. Add Channel Switch Announcement support updating beacon template with CSA IE received from mac80211.
Please note I have tested this series just through the radar pattern test knob added to debugfs and not through I real radar signal generator.
Lorenzo Bianconi (6):
mt76: mt7615: introduce mt7615_regd_notifier
mt76: mt7615: add hw dfs pattern detector support
mt76: mt7615: do not perform txcalibration before cac is complited
mt76: mt7615: unlock dfs bands
mt76: mt7615: add csa support
mt76: mt7615: add radar pattern test knob to debugfs
.../wireless/mediatek/mt76/mt7615/Makefile | 3 +- .../wireless/mediatek/mt76/mt7615/debugfs.c | 38 +++++ .../net/wireless/mediatek/mt76/mt7615/dma.c | 2 +- .../net/wireless/mediatek/mt76/mt7615/init.c | 44 ++++-- .../net/wireless/mediatek/mt76/mt7615/mac.c | 88 +++++++++++ .../net/wireless/mediatek/mt76/mt7615/main.c | 19 +++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 147 ++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7615/mcu.h | 24 +++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 55 +++++++ 9 files changed, 392 insertions(+), 28 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
Signature · 1 line
2.21.0
Lorenzo Bianconi
maintainerPATCH 1/6 mt76: mt7615: introduce mt7615_regd_notifier
Introduce mt7615_regd_notifier callback. This is a preliminary patch to add radar detection support to mt7615 driver
--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +11 -0
@@ -208,6 +208,16 @@ mt7615_init_txpower(struct mt7615_dev *dev, } } +static void +mt7615_regd_notifier (struct wiphy *wiphy, +struct regulatory_request *request) +{ +struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy); +struct mt7615_dev *dev = hw->priv; + + dev->mt76.region = request->dfs_region; +} +int mt7615_register_device (struct mt7615_dev *dev) {struct ieee80211_hw *hw =mt76_hw (dev);
@@ -230,6 +240,7 @@ int mt7615_register_device(struct mt7615_dev *dev) wiphy->iface_combinations = if_comb; wiphy->n_iface_combinations =ARRAY_SIZE (if_comb); + wiphy->reg_notifier = mt7615_regd_notifier;ieee80211_hw_set (hw,SUPPORTS_REORDERING_BUFFER );ieee80211_hw_set (hw,TX_STATUS_NO_AMPDU_LEN );
Signature · 1 line
2.21.0
Lorenzo Bianconi
maintainerPATCH 2/6 mt76: mt7615: add hw dfs pattern detector support
In reply to Lorenzo BianconiAdd hw radar detection support to mt7615 driver in order to unlock dfs channels on 5GHz band
--- .../net/wireless/mediatek/mt76/mt7615/dma.c | 2 +- .../net/wireless/mediatek/mt76/mt7615/init.c | 17 ++++ .../net/wireless/mediatek/mt76/mt7615/mac.c | 88 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7615/main.c | 6 ++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 65 ++++++++++++++ .../net/wireless/mediatek/mt76/mt7615/mcu.h | 22 +++++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 46 ++++++++++ 7 files changed, 245 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/dma.c +1 -1
@@ -76,7 +76,7 @@ void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,mt7615_mac_tx_free (dev, skb);break ;case PKT_TYPE_RX_EVENT : -mt76_mcu_rx_event (&dev->mt76, skb); +mt7615_mcu_rx_event (dev, skb);break ;case PKT_TYPE_NORMAL :if (!mt7615_mac_fill_rx (dev, skb)) {
drivers/net/wireless/mediatek/mt76/mt7615/init.c +17 -0
@@ -163,6 +163,8 @@ static int mt7615_init_debugfs(struct mt7615_dev *dev)if (!dir)return -ENOMEM ; +debugfs_create_u32 ("dfs_hw_pattern" ,0400 , dir, &dev->hw_pattern); +return 0 ; }
@@ -214,8 +216,22 @@ mt7615_regd_notifier(struct wiphy *wiphy, {struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy);struct mt7615_dev *dev = hw->priv; +struct cfg80211_chan_def *chandef = &dev->mt76.chandef; + +if (request->dfs_region == dev->mt76.region) +return ; dev->mt76.region = request->dfs_region; + +if (!(chandef->chan->flags &IEEE80211_CHAN_RADAR )) +return ; + +mt7615_dfs_stop_radar_detector (dev); +if (request->dfs_region ==NL80211_DFS_UNSET ) +mt7615_mcu_rdd_cmd (dev,RDD_CAC_END ,MT_HW_RDD0 , +MT_RX_SEL0 ,0 ); +else +mt7615_dfs_start_radar_detector (dev); }int mt7615_register_device (struct mt7615_dev *dev)
@@ -254,6 +270,7 @@ int mt7615_register_device(struct mt7615_dev *dev)IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ ; dev->mt76.chainmask =0x404 ; dev->mt76.antenna_mask =0xf ; + dev->dfs_state =-1 ; wiphy->interface_modes =BIT (NL80211_IFTYPE_STATION ) | #ifdef CONFIG_MAC80211_MESH
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +88 -0
91 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7615/main.c +6 -0
@@ -137,12 +137,18 @@ static int mt7615_set_channel(struct mt7615_dev *dev)cancel_delayed_work_sync (&dev->mt76.mac_work);set_bit (MT76_RESET , &dev->mt76.state); +mt7615_dfs_check_channel (dev); +mt76_set_channel (&dev->mt76); ret =mt7615_mcu_set_channel (dev);if (ret)return ret; + ret =mt7615_dfs_init_radar_detector (dev); +if (ret <0 ) +return ret; +clear_bit (MT76_RESET , &dev->mt76.state);mt76_txq_schedule_all (&dev->mt76);
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +65 -0
77 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h +22 -0
@@ -23,6 +23,27 @@ struct mt7615_mcu_txd {u32 reserved[5 ]; } __packed__aligned(4) ; +/* event table */ +enum { +MCU_EVENT_TARGET_ADDRESS_LEN =0x01 , +MCU_EVENT_FW_START =0x01 , +MCU_EVENT_GENERIC =0x01 , +MCU_EVENT_ACCESS_REG =0x02 , +MCU_EVENT_MT_PATCH_SEM =0x04 , +MCU_EVENT_CH_PRIVILEGE =0x18 , +MCU_EVENT_EXT =0xed , +MCU_EVENT_RESTART_DL =0xef , +}; + +/* ext event table */ +enum { +MCU_EXT_EVENT_PS_SYNC =0x5 , +MCU_EXT_EVENT_FW_LOG_2_HOST =0x13 , +MCU_EXT_EVENT_THERMAL_PROTECT =0x22 , +MCU_EXT_EVENT_ASSERT_DUMP =0x23 , +MCU_EXT_EVENT_RDD_REPORT =0x3a , +}; +struct mt7615_mcu_rxd {__le32 rxd[4 ];
@@ -77,6 +98,7 @@ enum {MCU_EXT_CMD_EDCA_UPDATE =0x27 ,MCU_EXT_CMD_DEV_INFO_UPDATE =0x2A ,MCU_EXT_CMD_WTBL_UPDATE =0x32 , +MCU_EXT_CMD_SET_RDD_CTRL =0x3a ,MCU_EXT_CMD_PROTECT_CTRL =0x3e ,MCU_EXT_CMD_MAC_INIT_CTRL =0x46 , MCU_EXT_CMD_BCN_OFFLOAD = 0x49,
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +46 -0
69 lines not on this page · raw message
Signature · 1 line
2.21.0
Lorenzo Bianconi
maintainerPATCH 3/6 mt76: mt7615: do not perform txcalibration before cac is complited
In reply to Lorenzo BianconiDelay channel calibration after Channel Availability Check. Add some code cleanup to mt7615_mcu_set_channel
--- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +15 -10
@@ -1280,7 +1280,8 @@ int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev,int mt7615_mcu_set_channel (struct mt7615_dev *dev) { -struct cfg80211_chan_def *chdef = &dev->mt76.chandef; +struct cfg80211_chan_def *chandef = &dev->mt76.chandef; +int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;struct {u8 control_chan;u8 center_chan;
@@ -1299,17 +1300,20 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev)u8 rsv1[3 ];u8 txpower_sku[53 ];u8 rsv2[3 ]; - } req = {0}; + } req = { + .control_chan = chandef->chan->hw_value, + .center_chan = ieee80211_frequency_to_channel(freq1), + .tx_streams = (dev->mt76.chainmask >> 8) & 0xf, + .rx_streams_mask = dev->mt76.antenna_mask, + .center_chan2 = ieee80211_frequency_to_channel(freq2), + };int ret; - req.control_chan = chdef->chan->hw_value; - req.center_chan =ieee80211_frequency_to_channel (chdef->center_freq1); - req.tx_streams = (dev->mt76.chainmask >>8 ) &0xf ; - req.rx_streams_mask = dev->mt76.antenna_mask; - req.switch_reason =CH_SWITCH_NORMAL ; - req.band_idx =0 ; - req.center_chan2 =ieee80211_frequency_to_channel (chdef->center_freq2); - req.txpower_drop =0 ; +if ((chandef->chan->flags &IEEE80211_CHAN_RADAR ) && + chandef->chan->dfs_state !=NL80211_DFS_AVAILABLE ) + req.switch_reason =CH_SWITCH_DFS ; +else + req.switch_reason =CH_SWITCH_NORMAL ;switch (dev->mt76.chandef.width) {case NL80211_CHAN_WIDTH_40 :
@@ -1334,6 +1338,7 @@ int mt7615_mcu_set_channel(struct mt7615_dev *dev)case NL80211_CHAN_WIDTH_20 :default : req.bw =CMD_CBW_20MHZ ; +break ; }memset (req.txpower_sku,0x3f ,49 );
Signature · 1 line
2.21.0
Lorenzo Bianconi
maintainerPATCH 4/6 mt76: mt7615: unlock dfs bands
In reply to Lorenzo BianconiUnlock dfs channels since now mt7615 driver supports radar detection
--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +6 -0
@@ -152,6 +152,12 @@ static const struct ieee80211_iface_combination if_comb[] = { .max_interfaces = 4, .num_different_channels = 1, .beacon_int_infra_match = true, + .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | + BIT(NL80211_CHAN_WIDTH_80P80), } };
Signature · 1 line
2.21.0
Re: [PATCH 4/6] mt76: mt7615: unlock dfs bands
Quoted 12 lines · Lorenzo Bianconi
Unlock dfs channels since now mt7615 driver supports radar detection
Signed-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/wireless/mediatek/mt76/mt7615/init.c +0
-0
drivers/net/wireless/mediatek/mt76/mt7615/init.c static const struct ieee80211_iface_combination if_comb[] = { · line 160
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7615/init.c +6
-0@@ -152,6 +152,12 @@ static const struct ieee80211_iface_combination if_comb[] = { .max_interfaces = 4, .num_different_channels = 1, .beacon_int_infra_match = true, + .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | + BIT(NL80211_CHAN_WIDTH_80P80),
Isn't it questionable to enable these without any testing on real hardware? Getting DFS to work correctly is hard so I'm very suspicious about this.
Signature · 1 line
Kalle Valo
Re: [PATCH 4/6] mt76: mt7615: unlock dfs bands
Quoted 29 lines
Quoted 12 lines · Lorenzo Bianconi
Unlock dfs channels since now mt7615 driver supports radar detection
Signed-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/wireless/mediatek/mt76/mt7615/init.c +0
-0drivers/net/wireless/mediatek/mt76/mt7615/init.c static const struct ieee80211_iface_combination if_comb[] = { · line 160
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7615/init.c +6
-0@@ -152,6 +152,12 @@ static const struct ieee80211_iface_combination if_comb[] = { .max_interfaces = 4, .num_different_channels = 1, .beacon_int_infra_match = true, + .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | + BIT(NL80211_CHAN_WIDTH_80P80),Isn't it questionable to enable these without any testing on real hardware? Getting DFS to work correctly is hard so I'm very suspicious about this.
Quoted 2 lines
--
Kalle Valo
Hi Kalle,
unfortunately at the moment I am not able to run any tests with a real signal generator so I just ported the code from vendor sdk. I am pretty confident it works since the radar pattern detection is done in fw/hw so I guess it has been already tested in the vendor sdk but we can postpone this patch and apply just the rest of the series until we have some test results.
@Ryder: do you have the possibility to carry out some real tests?
Regards,
Lorenzo
Re: [PATCH 4/6] mt76: mt7615: unlock dfs bands
Quoted 32 lines · Lorenzo Bianconi
Quoted 29 lines
Quoted 12 lines · Lorenzo Bianconi
Unlock dfs channels since now mt7615 driver supports radar detection
Signed-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/wireless/mediatek/mt76/mt7615/init.c +0
-0drivers/net/wireless/mediatek/mt76/mt7615/init.c static const struct ieee80211_iface_combination if_comb[] = { · line 160
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7615/init.c +6
-0@@ -152,6 +152,12 @@ static const struct ieee80211_iface_combination if_comb[] = { .max_interfaces = 4, .num_different_channels = 1, .beacon_int_infra_match = true, + .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | + BIT(NL80211_CHAN_WIDTH_80P80),Isn't it questionable to enable these without any testing on real hardware? Getting DFS to work correctly is hard so I'm very suspicious about this.
Quoted 2 lines
--
Kalle Valo
Quoted 6 lines
Hi Kalle,
unfortunately at the moment I am not able to run any tests with a real signal generator so I just ported the code from vendor sdk. I am pretty confident it works since the radar pattern detection is done in fw/hw so I guess it has been already tested in the vendor sdk
DFS is really tricky to get it working right, so I'm not easily convinced :)
Quoted 2 lines
but we can postpone this patch and apply just the rest of the series until we have some test results.
Yeah, I think it would be best to drop this patch so that DFS is not enabled by default and apply this patch only after positive test results.
Signature · 1 line
Kalle Valo
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 4/6] mt76: mt7615: unlock dfs bands
Quoted 44 lines · Kalle Valo
Quoted 32 lines · Lorenzo Bianconi
Quoted 29 lines
Quoted 12 lines · Lorenzo Bianconi
Unlock dfs channels since now mt7615 driver supports radar detection
Signed-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/wireless/mediatek/mt76/mt7615/init.c +0
-0drivers/net/wireless/mediatek/mt76/mt7615/init.c static const struct ieee80211_iface_combination if_comb[] = { · line 160
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7615/init.c +6
-0@@ -152,6 +152,12 @@ static const struct ieee80211_iface_combination if_comb[] = { .max_interfaces = 4, .num_different_channels = 1, .beacon_int_infra_match = true, + .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | + BIT(NL80211_CHAN_WIDTH_80P80),Isn't it questionable to enable these without any testing on real hardware? Getting DFS to work correctly is hard so I'm very suspicious about this.
Quoted 2 lines
--
Kalle ValoQuoted 6 lines
Hi Kalle,
unfortunately at the moment I am not able to run any tests with a real signal generator so I just ported the code from vendor sdk. I am pretty confident it works since the radar pattern detection is done in fw/hw so I guess it has been already tested in the vendor sdk
DFS is really tricky to get it working right, so I'm not easily convinced :)
Quoted 7 lines
Quoted 2 lines
but we can postpone this patch and apply just the rest of the series until we have some test results.
Yeah, I think it would be best to drop this patch so that DFS is not enabled by default and apply this patch only after positive test results.
That's why I suggested Lorenzo to add this one - "[6/6] mt76: mt7615:
add radar pattern test knob to debugfs"
We can feed radar pattern through debugfs to test if a pattern is detected as radar pattern or not and verify the fw radar detection algorithm.
In this format:
RadarPulsePattern="3680128-2-245;3683878-2-245;3687628-2-245;3691378-2-245;3695128-2-245;3698878-2-245;3702628-2-245;3706378-2-245;3710128-2-245;3713878-2-245"
As for testing it on 'real hardware' I need to take some other time to borrow equipment.
Ryder
Re: [PATCH 4/6] mt76: mt7615: unlock dfs bands
Quoted 53 lines · Ryder Lee
Quoted 44 lines · Kalle Valo
Quoted 32 lines · Lorenzo Bianconi
Quoted 29 lines
Quoted 12 lines · Lorenzo Bianconi
Unlock dfs channels since now mt7615 driver supports radar detection
Signed-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7615/init.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/wireless/mediatek/mt76/mt7615/init.c +0
-0drivers/net/wireless/mediatek/mt76/mt7615/init.c static const struct ieee80211_iface_combination if_comb[] = { · line 160
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7615/init.c +6
-0@@ -152,6 +152,12 @@ static const struct ieee80211_iface_combination if_comb[] = { .max_interfaces = 4, .num_different_channels = 1, .beacon_int_infra_match = true, + .radar_detect_widths =BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | + BIT(NL80211_CHAN_WIDTH_80P80),Isn't it questionable to enable these without any testing on real hardware? Getting DFS to work correctly is hard so I'm very suspicious about this.
Quoted 2 lines
--
Kalle ValoQuoted 6 lines
Hi Kalle,
unfortunately at the moment I am not able to run any tests with a real signal generator so I just ported the code from vendor sdk. I am pretty confident it works since the radar pattern detection is done in fw/hw so I guess it has been already tested in the vendor sdk
DFS is really tricky to get it working right, so I'm not easily convinced :)
Quoted 7 lines
Quoted 2 lines
but we can postpone this patch and apply just the rest of the series until we have some test results.
Yeah, I think it would be best to drop this patch so that DFS is not enabled by default and apply this patch only after positive test results.
Quoted 6 lines
That's why I suggested Lorenzo to add this one - "[6/6] mt76: mt7615:
add radar pattern test knob to debugfs"We can feed radar pattern through debugfs to test if a pattern is detected as radar pattern or not and verify the fw radar detection algorithm.
Sure, that's nice for testing but does not guarantee that it works with real hardware as well. I take regulatory rules very seriously and that's why I'm extra careful here.
Signature · 1 line
Kalle Valo
Lorenzo Bianconi
maintainerPATCH 5/6 mt76: mt7615: add csa support
In reply to Lorenzo BianconiAdd Channel Switch Announcement support to mt7615 driver updating beacon template with CSA IE received from mac80211
--- .../net/wireless/mediatek/mt76/mt7615/init.c | 1 + .../net/wireless/mediatek/mt76/mt7615/main.c | 13 ++++++++++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 26 +++++++++++++++---- .../net/wireless/mediatek/mt76/mt7615/mcu.h | 1 + 4 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +1 -0
@@ -263,6 +263,7 @@ int mt7615_register_device(struct mt7615_dev *dev) wiphy->iface_combinations = if_comb; wiphy->n_iface_combinations =ARRAY_SIZE (if_comb); wiphy->reg_notifier = mt7615_regd_notifier; + wiphy->flags |=WIPHY_FLAG_HAS_CHANNEL_SWITCH ;ieee80211_hw_set (hw,SUPPORTS_REORDERING_BUFFER );ieee80211_hw_set (hw,TX_STATUS_NO_AMPDU_LEN );
drivers/net/wireless/mediatek/mt76/mt7615/main.c +13 -0
@@ -305,6 +305,18 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,mutex_unlock (&dev->mt76.mutex); } +static void +mt7615_channel_switch_beacon (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct cfg80211_chan_def *chandef) +{ +struct mt7615_dev *dev = hw->priv; + +mutex_lock (&dev->mt76.mutex); +mt7615_mcu_set_bcn (dev, vif, true); +mutex_unlock (&dev->mt76.mutex); +} +int mt7615_sta_add (struct mt76_dev *mdev,struct ieee80211_vif *vif,struct ieee80211_sta *sta) {
@@ -496,4 +508,5 @@ const struct ieee80211_ops mt7615_ops = { .sw_scan_complete = mt7615_sw_scan_complete, .release_buffered_frames = mt76_release_buffered_frames, .get_txpower = mt76_get_txpower, + .channel_switch_beacon = mt7615_channel_switch_beacon, };
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +21 -5
@@ -159,6 +159,13 @@ mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,return ret; } +static void +mt7615_mcu_csa_finish (void *priv,u8 *mac,struct ieee80211_vif *vif) +{ +if (vif->csa_active) +ieee80211_csa_finish (vif); +} +static void mt7615_mcu_rx_ext_event (struct mt7615_dev *dev,struct sk_buff *skb) {
@@ -169,6 +176,11 @@ mt7615_mcu_rx_ext_event(struct mt7615_dev *dev, struct sk_buff *skb)ieee80211_radar_detected (dev->mt76.hw); dev->hw_pattern++;break ; +case MCU_EXT_EVENT_CSA_NOTIFY : +ieee80211_iterate_active_interfaces_atomic (dev->mt76.hw, +IEEE80211_IFACE_ITER_RESUME_ALL , + mt7615_mcu_csa_finish, dev); +break ;default :break ; }
@@ -1143,6 +1155,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, {struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;struct mt76_wcid *wcid = &dev->mt76.global_wcid; +struct ieee80211_mutable_offsets offs;struct req {u8 omac_idx;u8 enable;
@@ -1163,13 +1176,10 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, .enable = en, .wlan_idx = wcid->idx, .band_idx = mvif->band_idx, - /* pky_type: 0 for bcn, 1 for tim */ - .pkt_type = 0, };struct sk_buff *skb; -u16 tim_off; - skb =ieee80211_beacon_get_tim (mt76_hw (dev), vif, &tim_off,NULL ); + skb =ieee80211_beacon_get_template (mt76_hw (dev), vif, &offs);if (!skb)return -EINVAL ;
@@ -1183,8 +1193,14 @@ int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif, 0, NULL);memcpy (req.pkt +MT_TXD_SIZE , skb->data, skb->len); req.pkt_len =cpu_to_le16 (MT_TXD_SIZE + skb->len); - req.tim_ie_pos =cpu_to_le16 (MT_TXD_SIZE + tim_off); + req.tim_ie_pos =cpu_to_le16 (MT_TXD_SIZE + offs.tim_offset); +if (offs.csa_counter_offs[0 ]) { +u16 csa_offs; + csa_offs =MT_TXD_SIZE + offs.csa_counter_offs[0 ] -4 ; + req.csa_ie_pos =cpu_to_le16 (csa_offs); + req.csa_cnt = skb->data[offs.csa_counter_offs[0 ]]; + }dev_kfree_skb (skb); return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_BCN_OFFLOAD,
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h +1 -0
@@ -42,6 +42,7 @@ enum {MCU_EXT_EVENT_THERMAL_PROTECT =0x22 ,MCU_EXT_EVENT_ASSERT_DUMP =0x23 ,MCU_EXT_EVENT_RDD_REPORT =0x3a , + MCU_EXT_EVENT_CSA_NOTIFY = 0x4f, }; struct mt7615_mcu_rxd {
Signature · 1 line
2.21.0
Lorenzo Bianconi
maintainerPATCH 6/6 mt76: mt7615: add radar pattern test knob to debugfs
In reply to Lorenzo BianconiIntroduce mt7615_mcu_rdd_send_pattern routine to trigger a radar pattern detection. Moreover move debugfs related routines in a dedicated source file.
--- .../wireless/mediatek/mt76/mt7615/Makefile | 3 +- .../wireless/mediatek/mt76/mt7615/debugfs.c | 38 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7615/init.c | 13 ------- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 31 +++++++++++++++ .../net/wireless/mediatek/mt76/mt7615/mcu.h | 1 + .../wireless/mediatek/mt76/mt7615/mt7615.h | 9 +++++ 6 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
drivers/net/wireless/mediatek/mt76/mt7615/Makefile +2 -1
@@ -2,4 +2,5 @@ obj-$(CONFIG_MT7615E) += mt7615e.o -mt7615e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o +mt7615e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \ + debugfs.o
drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: ISC */ + +#include "mt7615.h" + +static int +mt7615_radar_pattern_set (void *data,u64 val) +{ +struct mt7615_dev *dev = data; + +return mt7615_mcu_rdd_send_pattern (dev); +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_radar_pattern,NULL , + mt7615_radar_pattern_set,"%lld\n" ); + +int mt7615_init_debugfs (struct mt7615_dev *dev) +{ +struct dentry *dir; + + dir =mt76_register_debugfs (&dev->mt76); +if (!dir) +return -ENOMEM ; + +debugfs_create_u32 ("dfs_hw_pattern" ,0400 , dir, &dev->hw_pattern); +/* test pattern knobs */ +debugfs_create_u8 ("pattern_len" ,0600 , dir, + &dev->radar_pattern.n_pulses); +debugfs_create_u32 ("pulse_period" ,0600 , dir, + &dev->radar_pattern.period); +debugfs_create_u16 ("pulse_width" ,0600 , dir, + &dev->radar_pattern.width); +debugfs_create_u16 ("pulse_power" ,0600 , dir, + &dev->radar_pattern.power); +debugfs_create_file ("radar_trigger" ,0200 , dir, dev, + &fops_radar_pattern); + +return 0 ; +}
drivers/net/wireless/mediatek/mt76/mt7615/init.c +0 -13
@@ -161,19 +161,6 @@ static const struct ieee80211_iface_combination if_comb[] = { } }; -static int mt7615_init_debugfs (struct mt7615_dev *dev) -{ -struct dentry *dir; - - dir =mt76_register_debugfs (&dev->mt76); -if (!dir) -return -ENOMEM ; - -debugfs_create_u32 ("dfs_hw_pattern" ,0400 , dir, &dev->hw_pattern); - -return 0 ; -} -static void mt7615_init_txpower (struct mt7615_dev *dev,struct ieee80211_supported_band *sband)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +31 -0
@@ -1294,6 +1294,37 @@ int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev, &req, sizeof(req), true); } +int mt7615_mcu_rdd_send_pattern (struct mt7615_dev *dev) +{ +struct { +u8 pulse_num; +u8 rsv[3 ]; +struct { +u32 start_time; +u16 width; +s16 power; + } pattern[32 ]; + } req = { + .pulse_num = dev->radar_pattern.n_pulses, + }; +u32 start_time =ktime_to_ms (ktime_get_boottime ()); +int i; + +if (dev->radar_pattern.n_pulses >ARRAY_SIZE (req.pattern)) +return -EINVAL ; + +/* TODO: add some noise here */ +for (i =0 ; i < dev->radar_pattern.n_pulses; i++) { + req.pattern[i].width = dev->radar_pattern.width; + req.pattern[i].power = dev->radar_pattern.power; + req.pattern[i].start_time = start_time + + i * dev->radar_pattern.period; + } + +return __mt76_mcu_send_msg (&dev->mt76,MCU_EXT_CMD_SET_RDD_PATTERN , + &req,sizeof (req), false); +} +int mt7615_mcu_set_channel (struct mt7615_dev *dev) {struct cfg80211_chan_def *chandef = &dev->mt76.chandef;
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h +1 -0
@@ -104,6 +104,7 @@ enum {MCU_EXT_CMD_MAC_INIT_CTRL =0x46 ,MCU_EXT_CMD_BCN_OFFLOAD =0x49 ,MCU_EXT_CMD_SET_RX_PATH =0x4e , + MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d, }; enum {
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +9 -0
@@ -68,6 +68,12 @@ struct mt7615_dev {u32 vif_mask;u32 omac_mask; +struct { +u8 n_pulses; +u32 period; +u16 width; +s16 power; + } radar_pattern;u32 hw_pattern;int dfs_state;
@@ -177,6 +183,7 @@ int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev, u8 rx_sel, u8 val);int mt7615_dfs_start_radar_detector (struct mt7615_dev *dev);int mt7615_dfs_stop_radar_detector (struct mt7615_dev *dev); +int mt7615_mcu_rdd_send_pattern (struct mt7615_dev *dev);static inline void mt7615_dfs_check_channel (struct mt7615_dev *dev) {
@@ -240,4 +247,6 @@ void mt7615_txp_skb_unmap(struct mt76_dev *dev,int mt76_dfs_start_rdd (struct mt7615_dev *dev,bool force);int mt7615_dfs_init_radar_detector (struct mt7615_dev *dev); +int mt7615_init_debugfs (struct mt7615_dev *dev); +#endif
Signature · 1 line
2.21.0
Quoted 7 lines
Introduce radar pattern detection support to mt7615 driver. Add Channel Switch Announcement support updating beacon template with CSA IE received from mac80211.
Please note I have tested this series just through the radar pattern test knob added to debugfs and not through I real radar signal generator.
Changes since RFC:
- added Channel Switch Announcement support
Quoted 23 lines
Lorenzo Bianconi (6):
mt76: mt7615: introducemt7615_regd_notifier
mt76: mt7615: add hw dfs pattern detector support
mt76: mt7615: do not perform txcalibration before cac is complited
mt76: mt7615: unlock dfs bands
mt76: mt7615: add csa support
mt76: mt7615: add radar pattern test knob to debugfs.../wireless/mediatek/mt76/mt7615/Makefile | 3 +- .../wireless/mediatek/mt76/mt7615/debugfs.c | 38 +++++ .../net/wireless/mediatek/mt76/mt7615/dma.c | 2 +- .../net/wireless/mediatek/mt76/mt7615/init.c | 44 ++++-- .../net/wireless/mediatek/mt76/mt7615/mac.c | 88 +++++++++++ .../net/wireless/mediatek/mt76/mt7615/main.c | 19 +++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 147 ++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7615/mcu.h | 24 +++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 55 +++++++ 9 files changed, 392 insertions(+), 28 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c--
2.21.0
Quoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Introduce radar pattern detection support to mt7615 driver. Add Channel Switch Announcement support updating beacon template with CSA IE received from mac80211.
Please note I have tested this series just through the radar pattern test knob added to debugfs and not through I real radar signal generator.
Quoted 25 lines
Changes since RFC:
- added Channel Switch Announcement supportQuoted 22 lines
Lorenzo Bianconi (6):
mt76: mt7615: introducemt7615_regd_notifier
mt76: mt7615: add hw dfs pattern detector support
mt76: mt7615: do not perform txcalibration before cac is complited
mt76: mt7615: unlock dfs bands
mt76: mt7615: add csa support
mt76: mt7615: add radar pattern test knob to debugfs.../wireless/mediatek/mt76/mt7615/Makefile | 3 +- .../wireless/mediatek/mt76/mt7615/debugfs.c | 38 +++++ .../net/wireless/mediatek/mt76/mt7615/dma.c | 2 +- .../net/wireless/mediatek/mt76/mt7615/init.c | 44 ++++-- .../net/wireless/mediatek/mt76/mt7615/mac.c | 88 +++++++++++ .../net/wireless/mediatek/mt76/mt7615/main.c | 19 +++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 147 ++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7615/mcu.h | 24 +++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 55 +++++++ 9 files changed, 392 insertions(+), 28 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c--
2.21.0
Quoted 1 line
Quoted 1 line