2021-02-27 07:42:50

by Ryder Lee

[permalink] [raw]
Subject: [PATCH 1/5] mt76: mt7615: fix CSA notification for DBDC

Add CSA notification for second phy.

Signed-off-by: Ryder Lee <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 24 +++++++++++++++----
.../net/wireless/mediatek/mt76/mt7615/mcu.h | 11 ++++++++-
2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 65c6ab14fe6f..44daee41aa6c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -372,6 +372,22 @@ mt7615_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
ieee80211_csa_finish(vif);
}

+static void
+mt7615_mcu_rx_csa_notify(struct mt7615_dev *dev, struct sk_buff *skb)
+{
+ struct mt76_phy *mphy = &dev->mt76.phy;
+ struct mt7615_mcu_csa_notify *c;
+
+ c = (struct mt7615_mcu_csa_notify *)skb->data;
+
+ if (c->band_idx && dev->mt76.phy2)
+ mphy = dev->mt76.phy2;
+
+ ieee80211_iterate_active_interfaces_atomic(mphy->hw,
+ IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7615_mcu_csa_finish, mphy->hw);
+}
+
static void
mt7615_mcu_rx_radar_detected(struct mt7615_dev *dev, struct sk_buff *skb)
{
@@ -380,7 +396,7 @@ mt7615_mcu_rx_radar_detected(struct mt7615_dev *dev, struct sk_buff *skb)

r = (struct mt7615_mcu_rdd_report *)skb->data;

- if (r->idx && dev->mt76.phy2)
+ if (r->band_idx && dev->mt76.phy2)
mphy = dev->mt76.phy2;

ieee80211_radar_detected(mphy->hw);
@@ -419,9 +435,7 @@ mt7615_mcu_rx_ext_event(struct mt7615_dev *dev, struct sk_buff *skb)
mt7615_mcu_rx_radar_detected(dev, skb);
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);
+ mt7615_mcu_rx_csa_notify(dev, skb);
break;
case MCU_EXT_EVENT_FW_LOG_2_HOST:
mt7615_mcu_rx_log_message(dev, skb);
@@ -2176,7 +2190,7 @@ int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd)
.center_chan2 = ieee80211_frequency_to_channel(freq2),
};

- if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
+ if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) &&
chandef->chan->dfs_state != NL80211_DFS_AVAILABLE)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
index 411ebb56baef..dbf72b1396c7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
@@ -176,10 +176,19 @@ struct mt7615_mcu_rxd {
u8 s2d_index;
};

+struct mt7615_mcu_csa_notify {
+ struct mt7615_mcu_rxd rxd;
+
+ u8 omac_idx;
+ u8 csa_count;
+ u8 band_idx;
+ u8 rsv;
+} __packed;
+
struct mt7615_mcu_rdd_report {
struct mt7615_mcu_rxd rxd;

- u8 idx;
+ u8 band_idx;
u8 long_detected;
u8 constant_prf_detected;
u8 staggered_prf_detected;
--
2.18.0


2021-02-27 07:42:51

by Ryder Lee

[permalink] [raw]
Subject: [PATCH 4/5] mt76: mt7915: stop ext_phy queue when mac reset happens

Stop Tx burst for ext_phy after mac reset.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 6b6ea33bd320..c653cd01b8d8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -1607,9 +1607,10 @@ void mt7915_mac_reset_work(struct work_struct *work)
set_bit(MT76_MCU_RESET, &dev->mphy.state);
wake_up(&dev->mt76.mcu.wait);
cancel_delayed_work_sync(&dev->mphy.mac_work);
- if (phy2)
+ if (phy2) {
+ set_bit(MT76_RESET, &phy2->mt76->state);
cancel_delayed_work_sync(&phy2->mt76->mac_work);
-
+ }
/* lock/unlock all queues to ensure that no tx is pending */
mt76_txq_schedule_all(&dev->mphy);
if (ext_phy)
@@ -1637,6 +1638,8 @@ void mt7915_mac_reset_work(struct work_struct *work)

clear_bit(MT76_MCU_RESET, &dev->mphy.state);
clear_bit(MT76_RESET, &dev->mphy.state);
+ if (phy2)
+ clear_bit(MT76_RESET, &phy2->mt76->state);

mt76_worker_enable(&dev->mt76.tx_worker);
napi_enable(&dev->mt76.tx_napi);
--
2.18.0

2021-02-27 07:47:57

by Ryder Lee

[permalink] [raw]
Subject: [PATCH 5/5] mt76: mt7915: fix PHY mode for DBDC

Fix PHY mode configuration for DBDC.

Signed-off-by: Ryder Lee <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 40 +++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 4abe32357edc..e0c03b7f278d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -147,9 +147,10 @@ mt7915_get_he_phy_cap(struct mt7915_phy *phy, struct ieee80211_vif *vif)
}

static u8
-mt7915_get_phy_mode(struct mt7915_dev *dev, struct ieee80211_vif *vif,
- enum nl80211_band band, struct ieee80211_sta *sta)
+mt7915_get_phy_mode(struct mt76_phy *mphy, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
{
+ enum nl80211_band band = mphy->chandef.chan->band;
struct ieee80211_sta_ht_cap *ht_cap;
struct ieee80211_sta_vht_cap *vht_cap;
const struct ieee80211_sta_he_cap *he_cap;
@@ -161,12 +162,8 @@ mt7915_get_phy_mode(struct mt7915_dev *dev, struct ieee80211_vif *vif,
he_cap = &sta->he_cap;
} else {
struct ieee80211_supported_band *sband;
- struct mt7915_phy *phy;
- struct mt7915_vif *mvif;

- mvif = (struct mt7915_vif *)vif->drv_priv;
- phy = mvif->band_idx ? mt7915_ext_phy(dev) : &dev->phy;
- sband = phy->mt76->hw->wiphy->bands[band];
+ sband = mphy->hw->wiphy->bands[band];

ht_cap = &sband->ht_cap;
vht_cap = &sband->vht_cap;
@@ -676,8 +673,6 @@ mt7915_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
struct mt7915_phy *phy, bool enable)
{
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
- struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
- enum nl80211_band band = chandef->chan->band;
struct bss_info_basic *bss;
u16 wlan_idx = mvif->sta.wcid.idx;
u32 type = NETWORK_INFRA;
@@ -727,7 +722,7 @@ mt7915_mcu_bss_basic_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
memcpy(bss->bssid, vif->bss_conf.bssid, ETH_ALEN);
bss->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int);
bss->dtim_period = vif->bss_conf.dtim_period;
- bss->phy_mode = mt7915_get_phy_mode(phy->dev, vif, band, NULL);
+ bss->phy_mode = mt7915_get_phy_mode(phy->mt76, vif, NULL);
} else {
memcpy(bss->bssid, phy->mt76->macaddr, ETH_ALEN);
}
@@ -2069,25 +2064,30 @@ mt7915_mcu_add_txbf(struct mt7915_dev *dev, struct ieee80211_vif *vif,

static void
mt7915_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7915_dev *dev,
- struct ieee80211_vif *vif,
- struct ieee80211_sta *sta)
+ struct ieee80211_vif *vif, struct ieee80211_sta *sta)
{
- struct cfg80211_chan_def *chandef = &dev->mphy.chandef;
+ struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
+ struct mt76_phy *mphy = &dev->mphy;
+ enum nl80211_band band;
struct sta_rec_ra *ra;
struct tlv *tlv;
- enum nl80211_band band = chandef->chan->band;
- u32 supp_rate = sta->supp_rates[band];
- int n_rates = hweight32(supp_rate);
- u32 cap = sta->wme ? STA_CAP_WMM : 0;
+ u32 supp_rate, n_rates, cap = sta->wme ? STA_CAP_WMM : 0;
u8 i, nss = sta->rx_nss, mcs = 0;

tlv = mt7915_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra));
-
ra = (struct sta_rec_ra *)tlv;
+
+ if (msta->wcid.ext_phy && dev->mt76.phy2)
+ mphy = dev->mt76.phy2;
+
+ band = mphy->chandef.chan->band;
+ supp_rate = sta->supp_rates[band];
+ n_rates = hweight32(supp_rate);
+
ra->valid = true;
ra->auto_rate = true;
- ra->phy_mode = mt7915_get_phy_mode(dev, vif, band, sta);
- ra->channel = chandef->chan->hw_value;
+ ra->phy_mode = mt7915_get_phy_mode(mphy, vif, sta);
+ ra->channel = mphy->chandef.chan->hw_value;
ra->bw = sta->bandwidth;
ra->rate_len = n_rates;
ra->phy.bw = sta->bandwidth;
--
2.18.0

2021-02-27 07:49:40

by Ryder Lee

[permalink] [raw]
Subject: [PATCH 3/5] mt76: mt7915: fix CSA notification for DBDC

Add CSA notification for second phy.

Signed-off-by: Ryder Lee <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 24 +++++++++++++++----
.../net/wireless/mediatek/mt76/mt7915/mcu.h | 11 ++++++++-
2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 6c429a2b15c5..4abe32357edc 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -336,6 +336,22 @@ mt7915_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
ieee80211_csa_finish(vif);
}

+static void
+mt7915_mcu_rx_csa_notify(struct mt7915_dev *dev, struct sk_buff *skb)
+{
+ struct mt76_phy *mphy = &dev->mt76.phy;
+ struct mt7915_mcu_csa_notify *c;
+
+ c = (struct mt7915_mcu_csa_notify *)skb->data;
+
+ if (c->band_idx && dev->mt76.phy2)
+ mphy = dev->mt76.phy2;
+
+ ieee80211_iterate_active_interfaces_atomic(mphy->hw,
+ IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7915_mcu_csa_finish, mphy->hw);
+}
+
static void
mt7915_mcu_rx_radar_detected(struct mt7915_dev *dev, struct sk_buff *skb)
{
@@ -344,7 +360,7 @@ mt7915_mcu_rx_radar_detected(struct mt7915_dev *dev, struct sk_buff *skb)

r = (struct mt7915_mcu_rdd_report *)skb->data;

- if (r->idx && dev->mt76.phy2)
+ if (r->band_idx && dev->mt76.phy2)
mphy = dev->mt76.phy2;

ieee80211_radar_detected(mphy->hw);
@@ -511,9 +527,7 @@ mt7915_mcu_rx_ext_event(struct mt7915_dev *dev, struct sk_buff *skb)
mt7915_mcu_rx_radar_detected(dev, skb);
break;
case MCU_EXT_EVENT_CSA_NOTIFY:
- ieee80211_iterate_active_interfaces_atomic(dev->mt76.hw,
- IEEE80211_IFACE_ITER_RESUME_ALL,
- mt7915_mcu_csa_finish, dev);
+ mt7915_mcu_rx_csa_notify(dev, skb);
break;
case MCU_EXT_EVENT_RATE_REPORT:
mt7915_mcu_tx_rate_report(dev, skb);
@@ -3219,7 +3233,7 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
}
#endif

- if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
+ if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) &&
chandef->chan->dfs_state != NL80211_DFS_AVAILABLE)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
index 2a2f7bf2c94b..4a932140a7c3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
@@ -68,10 +68,19 @@ struct mt7915_mcu_rxd {
u8 s2d_index;
};

+struct mt7915_mcu_csa_notify {
+ struct mt7915_mcu_rxd rxd;
+
+ u8 omac_idx;
+ u8 csa_count;
+ u8 band_idx;
+ u8 rsv;
+} __packed;
+
struct mt7915_mcu_rdd_report {
struct mt7915_mcu_rxd rxd;

- u8 idx;
+ u8 band_idx;
u8 long_detected;
u8 constant_prf_detected;
u8 staggered_prf_detected;
--
2.18.0

2021-02-27 07:52:03

by Ryder Lee

[permalink] [raw]
Subject: [PATCH 2/5] mt76: mt7615: stop ext_phy queue when mac reset happens

Stop Tx burst for ext_phy after mac reset.

Signed-off-by: Ryder Lee <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index df2dc77a323a..0f613063c1ff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -2085,6 +2085,7 @@ void mt7615_mac_reset_work(struct work_struct *work)
del_timer_sync(&dev->phy.roc_timer);
cancel_work_sync(&dev->phy.roc_work);
if (phy2) {
+ set_bit(MT76_RESET, &phy2->mt76->state);
cancel_delayed_work_sync(&phy2->mt76->mac_work);
del_timer_sync(&phy2->roc_timer);
cancel_work_sync(&phy2->roc_work);
@@ -2118,6 +2119,8 @@ void mt7615_mac_reset_work(struct work_struct *work)

clear_bit(MT76_MCU_RESET, &dev->mphy.state);
clear_bit(MT76_RESET, &dev->mphy.state);
+ if (phy2)
+ clear_bit(MT76_RESET, &phy2->mt76->state);

mt76_worker_enable(&dev->mt76.tx_worker);
napi_enable(&dev->mt76.tx_napi);
--
2.18.0

2021-02-27 10:28:55

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH 2/5] mt76: mt7615: stop ext_phy queue when mac reset happens

> Stop Tx burst for ext_phy after mac reset.
>
> Signed-off-by: Ryder Lee <[email protected]>
> ---
> drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> index df2dc77a323a..0f613063c1ff 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> @@ -2085,6 +2085,7 @@ void mt7615_mac_reset_work(struct work_struct *work)
> del_timer_sync(&dev->phy.roc_timer);
> cancel_work_sync(&dev->phy.roc_work);
> if (phy2) {
> + set_bit(MT76_RESET, &phy2->mt76->state);

Hi Ryder,

since we run mt76_txq_schedule_all then and mt76_worker_disable few lines below, what is the point
of setting the state to RESET?

Regards,
Lorenzo

> cancel_delayed_work_sync(&phy2->mt76->mac_work);
> del_timer_sync(&phy2->roc_timer);
> cancel_work_sync(&phy2->roc_work);
> @@ -2118,6 +2119,8 @@ void mt7615_mac_reset_work(struct work_struct *work)
>
> clear_bit(MT76_MCU_RESET, &dev->mphy.state);
> clear_bit(MT76_RESET, &dev->mphy.state);
> + if (phy2)
> + clear_bit(MT76_RESET, &phy2->mt76->state);
>
> mt76_worker_enable(&dev->mt76.tx_worker);
> napi_enable(&dev->mt76.tx_napi);
> --
> 2.18.0
>


Attachments:
(No filename) (1.34 kB)
signature.asc (235.00 B)
Download all attachments

2021-02-27 10:29:21

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH 4/5] mt76: mt7915: stop ext_phy queue when mac reset happens

> Stop Tx burst for ext_phy after mac reset.
>
> Signed-off-by: Ryder Lee <[email protected]>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index 6b6ea33bd320..c653cd01b8d8 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -1607,9 +1607,10 @@ void mt7915_mac_reset_work(struct work_struct *work)
> set_bit(MT76_MCU_RESET, &dev->mphy.state);
> wake_up(&dev->mt76.mcu.wait);
> cancel_delayed_work_sync(&dev->mphy.mac_work);
> - if (phy2)
> + if (phy2) {
> + set_bit(MT76_RESET, &phy2->mt76->state);
> cancel_delayed_work_sync(&phy2->mt76->mac_work);

same question here as mt7615, do we really need this?

Regards,
Lorenzo

> -
> + }
> /* lock/unlock all queues to ensure that no tx is pending */
> mt76_txq_schedule_all(&dev->mphy);
> if (ext_phy)
> @@ -1637,6 +1638,8 @@ void mt7915_mac_reset_work(struct work_struct *work)
>
> clear_bit(MT76_MCU_RESET, &dev->mphy.state);
> clear_bit(MT76_RESET, &dev->mphy.state);
> + if (phy2)
> + clear_bit(MT76_RESET, &phy2->mt76->state);
>
> mt76_worker_enable(&dev->mt76.tx_worker);
> napi_enable(&dev->mt76.tx_napi);
> --
> 2.18.0
>


Attachments:
(No filename) (1.39 kB)
signature.asc (235.00 B)
Download all attachments

2021-02-27 13:46:45

by Ryder Lee

[permalink] [raw]
Subject: Re: [PATCH 2/5] mt76: mt7615: stop ext_phy queue when mac reset happens

On Sat, 2021-02-27 at 11:23 +0100, Lorenzo Bianconi wrote:
> > Stop Tx burst for ext_phy after mac reset.
> >
> > Signed-off-by: Ryder Lee <[email protected]>
> > ---
> > drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> > index df2dc77a323a..0f613063c1ff 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> > @@ -2085,6 +2085,7 @@ void mt7615_mac_reset_work(struct work_struct *work)
> > del_timer_sync(&dev->phy.roc_timer);
> > cancel_work_sync(&dev->phy.roc_work);
> > if (phy2) {
> > + set_bit(MT76_RESET, &phy2->mt76->state);
>
> Hi Ryder,
>
> since we run mt76_txq_schedule_all then and mt76_worker_disable few lines below, what is the point
> of setting the state to RESET?

Just in case mt76_txq_schedule_* still has the possibility to be called
by some other place at the time reset happens. Also, I think MT76_RESET
is more reliable to break Tx scheduling (from inside of the burst loop).

Ryder
>
> > cancel_delayed_work_sync(&phy2->mt76->mac_work);
> > del_timer_sync(&phy2->roc_timer);
> > cancel_work_sync(&phy2->roc_work);
> > @@ -2118,6 +2119,8 @@ void mt7615_mac_reset_work(struct work_struct *work)
> >
> > clear_bit(MT76_MCU_RESET, &dev->mphy.state);
> > clear_bit(MT76_RESET, &dev->mphy.state);
> > + if (phy2)
> > + clear_bit(MT76_RESET, &phy2->mt76->state);
> >
> > mt76_worker_enable(&dev->mt76.tx_worker);
> > napi_enable(&dev->mt76.tx_napi);
> > --
> > 2.18.0
> >