diff mbox series

wifi: mt76: mt7921: fix the wrong rate selected in fw for the chanctx driver

Message ID 4b2ee1382896dd7ff27ecbef6e1ad496edccd3ad.1694129223.git.objelf@gmail.com
State New
Headers show
Series wifi: mt76: mt7921: fix the wrong rate selected in fw for the chanctx driver | expand

Commit Message

Sean Wang Sept. 7, 2023, 11:32 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 and
mt76_connac_get_he_phy_cap for the firmware can select the proper rate.

Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

David Ruth Sept. 8, 2023, 2:02 a.m. UTC | #1
Tested-by: David Ruth <druth@chromium.org>
kernel test robot Sept. 8, 2023, 5:35 a.m. UTC | #2
Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.5 next-20230907]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-mediatek-com/wifi-mt76-mt7921-fix-the-wrong-rate-selected-in-fw-for-the-chanctx-driver/20230908-073344
base:   linus/master
patch link:    https://lore.kernel.org/r/4b2ee1382896dd7ff27ecbef6e1ad496edccd3ad.1694129223.git.objelf%40gmail.com
patch subject: [PATCH] wifi: mt76: mt7921: fix the wrong rate selected in fw for the chanctx driver
config: i386-randconfig-016-20230908 (https://download.01.org/0day-ci/archive/20230908/202309081348.IepiSKwy-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230908/202309081348.IepiSKwy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309081348.IepiSKwy-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:833:44: error: no member named 'ctx' in 'struct mt76_vif'
           struct cfg80211_chan_def *chandef = mvif->ctx ?
                                               ~~~~  ^
   drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:834:17: error: no member named 'ctx' in 'struct mt76_vif'
                                               &mvif->ctx->def : &mphy->chandef;
                                                ~~~~  ^
   drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:1375:44: error: no member named 'ctx' in 'struct mt76_vif'
           struct cfg80211_chan_def *chandef = mvif->ctx ?
                                               ~~~~  ^
   drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:1376:17: error: no member named 'ctx' in 'struct mt76_vif'
                                               &mvif->ctx->def : &phy->chandef;
                                                ~~~~  ^
   4 errors generated.


vim +833 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

   826	
   827	void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
   828				     struct ieee80211_sta *sta,
   829				     struct ieee80211_vif *vif,
   830				     u8 rcpi, u8 sta_state)
   831	{
   832		struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
 > 833		struct cfg80211_chan_def *chandef = mvif->ctx ?
   834						    &mvif->ctx->def : &mphy->chandef;
   835		enum nl80211_band band = chandef->chan->band;
   836		struct mt76_dev *dev = mphy->dev;
   837		struct sta_rec_ra_info *ra_info;
   838		struct sta_rec_state *state;
   839		struct sta_rec_phy *phy;
   840		struct tlv *tlv;
   841		u16 supp_rates;
   842	
   843		/* starec ht */
   844		if (sta->deflink.ht_cap.ht_supported) {
   845			struct sta_rec_ht *ht;
   846	
   847			tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));
   848			ht = (struct sta_rec_ht *)tlv;
   849			ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap);
   850		}
   851	
   852		/* starec vht */
   853		if (sta->deflink.vht_cap.vht_supported) {
   854			struct sta_rec_vht *vht;
   855			int len;
   856	
   857			len = is_mt7921(dev) ? sizeof(*vht) : sizeof(*vht) - 4;
   858			tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, len);
   859			vht = (struct sta_rec_vht *)tlv;
   860			vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
   861			vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map;
   862			vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map;
   863		}
   864	
   865		/* starec uapsd */
   866		mt76_connac_mcu_sta_uapsd(skb, vif, sta);
   867	
   868		if (!is_mt7921(dev))
   869			return;
   870	
   871		if (sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)
   872			mt76_connac_mcu_sta_amsdu_tlv(skb, sta, vif);
   873	
   874		/* starec he */
   875		if (sta->deflink.he_cap.has_he) {
   876			mt76_connac_mcu_sta_he_tlv(skb, sta);
   877			mt76_connac_mcu_sta_he_tlv_v2(skb, sta);
   878			if (band == NL80211_BAND_6GHZ &&
   879			    sta_state == MT76_STA_INFO_STATE_ASSOC) {
   880				struct sta_rec_he_6g_capa *he_6g_capa;
   881	
   882				tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_6G,
   883							      sizeof(*he_6g_capa));
   884				he_6g_capa = (struct sta_rec_he_6g_capa *)tlv;
   885				he_6g_capa->capa = sta->deflink.he_6ghz_capa.capa;
   886			}
   887		}
   888	
   889		tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_PHY, sizeof(*phy));
   890		phy = (struct sta_rec_phy *)tlv;
   891		phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta);
   892		phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates);
   893		phy->rcpi = rcpi;
   894		phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR,
   895					sta->deflink.ht_cap.ampdu_factor) |
   896			     FIELD_PREP(IEEE80211_HT_AMPDU_PARM_DENSITY,
   897					sta->deflink.ht_cap.ampdu_density);
   898	
   899		tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info));
   900		ra_info = (struct sta_rec_ra_info *)tlv;
   901	
   902		supp_rates = sta->deflink.supp_rates[band];
   903		if (band == NL80211_BAND_2GHZ)
   904			supp_rates = FIELD_PREP(RA_LEGACY_OFDM, supp_rates >> 4) |
   905				     FIELD_PREP(RA_LEGACY_CCK, supp_rates & 0xf);
   906		else
   907			supp_rates = FIELD_PREP(RA_LEGACY_OFDM, supp_rates);
   908	
   909		ra_info->legacy = cpu_to_le16(supp_rates);
   910	
   911		if (sta->deflink.ht_cap.ht_supported)
   912			memcpy(ra_info->rx_mcs_bitmask,
   913			       sta->deflink.ht_cap.mcs.rx_mask,
   914			       HT_MCS_MASK_NUM);
   915	
   916		tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_STATE, sizeof(*state));
   917		state = (struct sta_rec_state *)tlv;
   918		state->state = sta_state;
   919	
   920		if (sta->deflink.vht_cap.vht_supported) {
   921			state->vht_opmode = sta->deflink.bandwidth;
   922			state->vht_opmode |= (sta->deflink.rx_nss - 1) <<
   923				IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT;
   924		}
   925	}
   926	EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_tlv);
   927
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index 0f0a519f956f..8274a57e1f0f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -829,7 +829,9 @@  void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
 			     struct ieee80211_vif *vif,
 			     u8 rcpi, u8 sta_state)
 {
-	struct cfg80211_chan_def *chandef = &mphy->chandef;
+	struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+	struct cfg80211_chan_def *chandef = mvif->ctx ?
+					    &mvif->ctx->def : &mphy->chandef;
 	enum nl80211_band band = chandef->chan->band;
 	struct mt76_dev *dev = mphy->dev;
 	struct sta_rec_ra_info *ra_info;
@@ -1369,7 +1371,10 @@  EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode_ext);
 const struct ieee80211_sta_he_cap *
 mt76_connac_get_he_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif)
 {
-	enum nl80211_band band = phy->chandef.chan->band;
+	struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+	struct cfg80211_chan_def *chandef = mvif->ctx ?
+					    &mvif->ctx->def : &phy->chandef;
+	enum nl80211_band band = chandef->chan->band;
 	struct ieee80211_supported_band *sband;
 
 	sband = phy->hw->wiphy->bands[band];