diff mbox series

[2/2] wifi: mt76: mt7921: fix the wrong rate pickup for the chanctx driver

Message ID 7c7c2c1f0584e8dd016bc2bf8de88684fcc7679c.1690232804.git.objelf@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] wifi: mt76: move struct ieee80211_chanctx_conf up to struct mt76_vif | expand

Commit Message

Sean Wang July 24, 2023, 9:19 p.m. UTC
From: Sean Wang <sean.wang@mediatek.com>

The variable band should be determined by the ieee80211_chanctx_conf when
the driver is a kind of chanctx one e.g mt7921 and mt7922 driver so we
added the extension to mt76_connac2_mac_tx_rate_val by distinguishing if
it can support chanctx to fix the incorrect rate pickup.

Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c        | 9 +++++++--
 drivers/net/wireless/mediatek/mt76/mt76.h            | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 7 +++++--
 3 files changed, 14 insertions(+), 5 deletions(-)

Comments

David Ruth July 27, 2023, 3:43 a.m. UTC | #1
Reviewed-by: David Ruth <druth@chromium.org>
Tested-by: David Ruth <druth@chromium.org>

On Mon, Jul 24, 2023 at 5:20 PM <sean.wang@mediatek.com> wrote:
>
> From: Sean Wang <sean.wang@mediatek.com>
>
> The variable band should be determined by the ieee80211_chanctx_conf when
> the driver is a kind of chanctx one e.g mt7921 and mt7922 driver so we
> added the extension to mt76_connac2_mac_tx_rate_val by distinguishing if
> it can support chanctx to fix the incorrect rate pickup.
>
> Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support")
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mac80211.c        | 9 +++++++--
>  drivers/net/wireless/mediatek/mt76/mt76.h            | 3 ++-
>  drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 7 +++++--
>  3 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
> index c0ff36a98bed..d622a2916c0e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mac80211.c
> +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
> @@ -1698,11 +1698,16 @@ mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
>  }
>  EXPORT_SYMBOL_GPL(mt76_init_queue);
>
> -u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)
> +u16 mt76_calculate_default_rate(struct mt76_phy *phy,
> +                               struct ieee80211_vif *vif, int rateidx)
>  {
> +       struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
> +       struct cfg80211_chan_def *chandef = mvif->ctx ?
> +                                           &mvif->ctx->def :
> +                                           &phy->chandef;
>         int offset = 0;
>
> -       if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
> +       if (chandef->chan->band != NL80211_BAND_2GHZ)
>                 offset = 4;
>
>         /* pick the lowest rate for hidden nodes */
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index bf9c781ff48c..a292e15224e1 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -1100,7 +1100,8 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len);
>  struct mt76_queue *
>  mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
>                 int ring_base, u32 flags);
> -u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx);
> +u16 mt76_calculate_default_rate(struct mt76_phy *phy,
> +                               struct ieee80211_vif *vif, int rateidx);
>  static inline int mt76_init_tx_queue(struct mt76_phy *phy, int qid, int idx,
>                                      int n_desc, int ring_base, u32 flags)
>  {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
> index ee5177fd6dde..d91f5548dc02 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
> @@ -310,7 +310,10 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
>                                  struct ieee80211_vif *vif,
>                                  bool beacon, bool mcast)
>  {
> -       u8 nss = 0, mode = 0, band = mphy->chandef.chan->band;
> +       struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
> +       struct cfg80211_chan_def *chandef = mvif->ctx ?
> +                                           &mvif->ctx->def : &mphy->chandef;
> +       u8 nss = 0, mode = 0, band = chandef->chan->band;
>         int rateidx = 0, mcast_rate;
>
>         if (!vif)
> @@ -343,7 +346,7 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
>                 rateidx = ffs(vif->bss_conf.basic_rates) - 1;
>
>  legacy:
> -       rateidx = mt76_calculate_default_rate(mphy, rateidx);
> +       rateidx = mt76_calculate_default_rate(mphy, vif, rateidx);
>         mode = rateidx >> 8;
>         rateidx &= GENMASK(7, 0);
>  out:
> --
> 2.25.1
>
Kalle Valo July 27, 2023, 6:25 a.m. UTC | #2
David Ruth <druth@chromium.org> writes:

> Reviewed-by: David Ruth <druth@chromium.org>
> Tested-by: David Ruth <druth@chromium.org>

Please don't top post and edit your quotes, otherwise use of patchwork
becomes horrible for us maintainers.
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index c0ff36a98bed..d622a2916c0e 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1698,11 +1698,16 @@  mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
 }
 EXPORT_SYMBOL_GPL(mt76_init_queue);
 
-u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)
+u16 mt76_calculate_default_rate(struct mt76_phy *phy,
+				struct ieee80211_vif *vif, int rateidx)
 {
+	struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+	struct cfg80211_chan_def *chandef = mvif->ctx ?
+					    &mvif->ctx->def :
+					    &phy->chandef;
 	int offset = 0;
 
-	if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
+	if (chandef->chan->band != NL80211_BAND_2GHZ)
 		offset = 4;
 
 	/* pick the lowest rate for hidden nodes */
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index bf9c781ff48c..a292e15224e1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1100,7 +1100,8 @@  int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len);
 struct mt76_queue *
 mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
 		int ring_base, u32 flags);
-u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx);
+u16 mt76_calculate_default_rate(struct mt76_phy *phy,
+				struct ieee80211_vif *vif, int rateidx);
 static inline int mt76_init_tx_queue(struct mt76_phy *phy, int qid, int idx,
 				     int n_desc, int ring_base, u32 flags)
 {
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
index ee5177fd6dde..d91f5548dc02 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
@@ -310,7 +310,10 @@  u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
 				 struct ieee80211_vif *vif,
 				 bool beacon, bool mcast)
 {
-	u8 nss = 0, mode = 0, band = mphy->chandef.chan->band;
+	struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+	struct cfg80211_chan_def *chandef = mvif->ctx ?
+					    &mvif->ctx->def : &mphy->chandef;
+	u8 nss = 0, mode = 0, band = chandef->chan->band;
 	int rateidx = 0, mcast_rate;
 
 	if (!vif)
@@ -343,7 +346,7 @@  u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
 		rateidx = ffs(vif->bss_conf.basic_rates) - 1;
 
 legacy:
-	rateidx = mt76_calculate_default_rate(mphy, rateidx);
+	rateidx = mt76_calculate_default_rate(mphy, vif, rateidx);
 	mode = rateidx >> 8;
 	rateidx &= GENMASK(7, 0);
 out: