wifi: mt76: mt7915: initialize rssi on adding stations
Subsystems (3)
Felix Fietkau
maintainerPATCH 1/13 wifi: mt76: mt7915: initialize rssi on adding stations
Improves initial rate selection after connecting
--- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/main.c +4 -0
@@ -744,6 +744,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;bool ext_phy = mvif->phy != &dev->phy;int ret, idx; +u32 addr; idx =mt76_wcid_alloc (dev->mt76.wcid_mask,MT7915_WTBL_STA );if (idx <0 )
@@ -767,6 +768,9 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,if (ret)return ret; + addr =mt7915_mac_wtbl_lmac_addr (dev, msta->wcid.idx,30 ); +mt76_rmw_field (dev, addr,GENMASK (7 ,0 ),0xa0 ); +return mt7915_mcu_add_rate_ctrl (dev, vif, sta, false); }
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 2/13 wifi: mt76: replace skb_put with skb_put_zero
Avoid potentially reusing uninitialized data
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 10 +++++----- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +5 -5
@@ -257,7 +257,7 @@ mt76_connac_mcu_add_nested_tlv(struct sk_buff *skb, int tag, int len, };u16 ntlv; - ptlv =skb_put (skb, len); + ptlv =skb_put_zero (skb, len);memcpy (ptlv, &tlv,sizeof (tlv)); ntlv =le16_to_cpu (ntlv_hdr->tlv_num);
@@ -1670,7 +1670,7 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,set_bit (MT76_HW_SCANNING , &phy->state); mvif->scan_seq_num = (mvif->scan_seq_num +1 ) &0x7f ; - req = (struct mt76_connac_hw_scan_req *)skb_put (skb,sizeof (*req)); + req = (struct mt76_connac_hw_scan_req *)skb_put_zero (skb,sizeof (*req)); req->seq_num = mvif->scan_seq_num | mvif->band_idx <<7 ; req->bss_idx = mvif->idx;
@@ -1798,7 +1798,7 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy, mvif->scan_seq_num = (mvif->scan_seq_num +1 ) &0x7f ; - req = (struct mt76_connac_sched_scan_req *)skb_put (skb,sizeof (*req)); + req = (struct mt76_connac_sched_scan_req *)skb_put_zero (skb,sizeof (*req)); req->version =1 ; req->seq_num = mvif->scan_seq_num | mvif->band_idx <<7 ;
@@ -2321,7 +2321,7 @@ int mt76_connac_mcu_update_gtk_rekey(struct ieee80211_hw *hw,return -ENOMEM ;skb_put_data (skb, &hdr,sizeof (hdr)); - gtk_tlv = (struct mt76_connac_gtk_rekey_tlv *)skb_put (skb, + gtk_tlv = (struct mt76_connac_gtk_rekey_tlv *)skb_put_zero (skb,sizeof (*gtk_tlv)); gtk_tlv->tag =cpu_to_le16 (UNI_OFFLOAD_OFFLOAD_GTK_REKEY ); gtk_tlv->len =cpu_to_le16 (sizeof (*gtk_tlv));
@@ -2446,7 +2446,7 @@ mt76_connac_mcu_set_wow_pattern(struct mt76_dev *dev,return -ENOMEM ;skb_put_data (skb, &hdr,sizeof (hdr)); - ptlv = (struct mt76_connac_wow_pattern_tlv *)skb_put (skb,sizeof (*ptlv)); + ptlv = (struct mt76_connac_wow_pattern_tlv *)skb_put_zero (skb,sizeof (*ptlv)); ptlv->tag =cpu_to_le16 (UNI_SUSPEND_WOW_PATTERN ); ptlv->len =cpu_to_le16 (sizeof (*ptlv)); ptlv->data_len = pattern->pattern_len;
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +1 -1
@@ -424,7 +424,7 @@ mt7915_mcu_add_nested_subtlv(struct sk_buff *skb, int sub_tag, int sub_len, .len = cpu_to_le16(sub_len), }; - ptlv =skb_put (skb, sub_len); + ptlv =skb_put_zero (skb, sub_len);memcpy (ptlv, &tlv,sizeof (tlv));le16_add_cpu (sub_ntlv,1 );
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 3/13 wifi: mt76: fix tx packet loss when scanning on DBDC
In reply to Felix FietkauWhen queueing packets, only the MT76_RESET flag of the primary PHY is checked. If the primary PHY is scanning or changing channels, this can lead to packet loss for tx on the second PHY.
Fix this by passing the phy to the .tx_queue_skb op and using it to check the correct flag.
--- drivers/net/wireless/mediatek/mt76/dma.c | 5 +++-- drivers/net/wireless/mediatek/mt76/mt76.h | 4 ++-- drivers/net/wireless/mediatek/mt76/sdio.c | 3 ++- drivers/net/wireless/mediatek/mt76/testmode.c | 2 +- drivers/net/wireless/mediatek/mt76/tx.c | 2 +- drivers/net/wireless/mediatek/mt76/usb.c | 3 ++- 6 files changed, 11 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +3 -2
@@ -532,7 +532,7 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q, }static int -mt76_dma_tx_queue_skb (struct mt76_dev *dev,struct mt76_queue *q, +mt76_dma_tx_queue_skb (struct mt76_phy *phy,struct mt76_queue *q,enum mt76_txq_id qid,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_sta *sta) {
@@ -542,6 +542,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,struct mt76_tx_info tx_info = { .skb = skb, }; +struct mt76_dev *dev = phy->dev;struct ieee80211_hw *hw;int len, n =0 , ret = -ENOMEM ;struct mt76_txwi_cache *t;
@@ -549,7 +550,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,dma_addr_t addr;u8 *txwi; -if (test_bit (MT76_RESET , &dev->phy.state)) +if (test_bit (MT76_RESET , &phy->state)) goto free_skb; t =mt76_get_txwi (dev);
drivers/net/wireless/mediatek/mt76/mt76.h +2 -2
@@ -256,7 +256,7 @@ struct mt76_queue_ops { int idx, int n_desc, int bufsize, u32 ring_base); -int (*tx_queue_skb)(struct mt76_dev *dev,struct mt76_queue *q, +int (*tx_queue_skb)(struct mt76_phy *phy,struct mt76_queue *q,enum mt76_txq_id qid,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_sta *sta);
@@ -1127,7 +1127,7 @@ static inline int mt76_wed_dma_setup(struct mt76_dev *dev, struct mt76_queue *q,#define mt76_init_queues (dev, ...) (dev)->mt76.queue_ops->init(&((dev)->mt76), __VA_ARGS__)#define mt76_queue_alloc (dev, ...) (dev)->mt76.queue_ops->alloc(&((dev)->mt76), __VA_ARGS__)#define mt76_tx_queue_skb_raw (dev, ...) (dev)->mt76.queue_ops->tx_queue_skb_raw(&((dev)->mt76), __VA_ARGS__) -#define mt76_tx_queue_skb (dev, ...) (dev)->mt76.queue_ops->tx_queue_skb(&((dev)->mt76), __VA_ARGS__) +#define mt76_tx_queue_skb (dev, ...) (dev)->mt76.queue_ops->tx_queue_skb(&((dev)->mphy), __VA_ARGS__)#define mt76_queue_rx_reset (dev, ...) (dev)->mt76.queue_ops->rx_reset(&((dev)->mt76), __VA_ARGS__)#define mt76_queue_tx_cleanup (dev, ...) (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__)#define mt76_queue_rx_cleanup (dev, ...) (dev)->mt76.queue_ops->rx_cleanup(&((dev)->mt76), __VA_ARGS__)
drivers/net/wireless/mediatek/mt76/sdio.c +2 -1
@@ -514,13 +514,14 @@ static void mt76s_tx_status_data(struct mt76_worker *worker) }static int -mt76s_tx_queue_skb (struct mt76_dev *dev,struct mt76_queue *q, +mt76s_tx_queue_skb (struct mt76_phy *phy,struct mt76_queue *q,enum mt76_txq_id qid,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_sta *sta) {struct mt76_tx_info tx_info = { .skb = skb, }; +struct mt76_dev *dev = phy->dev;int err, len = skb->len;u16 idx = q->head;
drivers/net/wireless/mediatek/mt76/testmode.c +1 -1
@@ -53,7 +53,7 @@ void mt76_testmode_tx_pending(struct mt76_phy *phy) q->queued < q->ndesc / 2) {int ret; - ret = dev->queue_ops->tx_queue_skb (dev, q, qid,skb_get (skb), + ret = dev->queue_ops->tx_queue_skb (phy, q, qid,skb_get (skb), wcid,NULL );if (ret <0 )break ;
drivers/net/wireless/mediatek/mt76/tx.c +1 -1
@@ -308,7 +308,7 @@ __mt76_tx_queue_skb(struct mt76_phy *phy, int qid, struct sk_buff *skb,int idx; non_aql = !info->tx_time_est; - idx = dev->queue_ops->tx_queue_skb (dev, q, qid, skb, wcid, sta); + idx = dev->queue_ops->tx_queue_skb (phy, q, qid, skb, wcid, sta);if (idx <0 || !sta)return idx;
drivers/net/wireless/mediatek/mt76/usb.c +2 -1
@@ -850,13 +850,14 @@ mt76u_tx_setup_buffers(struct mt76_dev *dev, struct sk_buff *skb, }static int -mt76u_tx_queue_skb (struct mt76_dev *dev,struct mt76_queue *q, +mt76u_tx_queue_skb (struct mt76_phy *phy,struct mt76_queue *q,enum mt76_txq_id qid,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_sta *sta) {struct mt76_tx_info tx_info = { .skb = skb, }; +struct mt76_dev *dev = phy->dev;u16 idx = q->head;int err;
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 4/13 wifi: mt76: mt7915: fix mcu command format for mt7915 tx stats
In reply to Felix FietkauFrom: Peter Chiu <[email protected]>
The mcu command format are different for mt7915 and mt7986. Fix the mt7915_mcu_wed_wa_tx_stats to support mt7915 and mt7986.
--- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +24 -12
@@ -3801,30 +3801,38 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx) {struct {__le32 cmd; -__le32 num; -__le32 __rsv; -__le16 wlan_idx; - } req = { +__le32 arg0; +__le32 arg1; +__le16 arg2; + } __packed req = { .cmd =cpu_to_le32 (0x15 ), - .num =cpu_to_le32 (1 ), - .wlan_idx =cpu_to_le16 (wlan_idx), };struct mt7915_mcu_wa_tx_stat { -__le16 wlan_idx; -u8 __rsv[2 ]; +__le16 wcid; +u8 __rsv2[2 ];/* tx_bytes is deprecated since WA byte counter uses u32, * which easily leads to overflow. */ __le32 tx_bytes;__le32 tx_packets; - } *res; + } __packed *res;struct mt76_wcid *wcid;struct sk_buff *skb; -int ret; +int ret, len; +u16 ret_wcid; + +if (is_mt7915 (&dev->mt76)) { + req.arg0 =cpu_to_le32 (wlan_idx); + len =sizeof (req) -sizeof (req.arg2); + }else { + req.arg0 =cpu_to_le32 (1 ); + req.arg2 =cpu_to_le16 (wlan_idx); + len =sizeof (req); + } ret =mt76_mcu_send_and_get_msg (&dev->mt76,MCU_WA_PARAM_CMD (QUERY ), - &req,sizeof (req), true, &skb); + &req, len, true, &skb);if (ret)return ret;
@@ -3833,7 +3841,11 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx) res = (struct mt7915_mcu_wa_tx_stat *)skb->data; -if (le16_to_cpu (res->wlan_idx) != wlan_idx) { + ret_wcid =le16_to_cpu (res->wcid); +if (is_mt7915 (&dev->mt76)) + ret_wcid &=0xff ; + +if (ret_wcid != wlan_idx) { ret = -EINVAL ; goto out; }
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 5/13 wifi: mt76: mt7915: fix bogus Tx/Rx airtime duration values
In reply to Felix FietkauFrom: Henry Yen <[email protected]>
Do not report measurements if the airtime counter was cleared since the last update (possibly by firmware)
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +9 -2
@@ -140,8 +140,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) msta->airtime_ac[i] =mt76_rr (dev, addr); msta->airtime_ac[i +4 ] =mt76_rr (dev, addr +4 ); - tx_time[i] = msta->airtime_ac[i] - tx_last; - rx_time[i] = msta->airtime_ac[i +4 ] - rx_last; +if (msta->airtime_ac[i] <= tx_last) + tx_time[i] =0 ; +else + tx_time[i] = msta->airtime_ac[i] - tx_last; + +if (msta->airtime_ac[i +4 ] <= rx_last) + rx_time[i] =0 ; +else + rx_time[i] = msta->airtime_ac[i +4 ] - rx_last;if ((tx_last | rx_last) &BIT (30 )) clear = true;
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 6/13 wifi: mt76: mt7915: fix HE PHY capabilities IE for station mode
In reply to Felix FietkauFrom: Howard Hsu <[email protected]>
Set correct beamformer capabilities for station vif in HE PHY capabilities IE.
--- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +6 -2
@@ -934,11 +934,10 @@ mt7915_set_stream_he_txbf_caps(struct mt7915_phy *phy,/* the maximum cap is 4 x 3, (Nr, Nc) = (3, 2) */ elem->phy_cap_info[7 ] |=min_t (int, sts -1 ,2 ) <<3 ; -if (vif !=NL80211_IFTYPE_AP ) +if (vif !=NL80211_IFTYPE_AP && vif !=NL80211_IFTYPE_STATION )return ; elem->phy_cap_info[3 ] |=IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER ; - elem->phy_cap_info[4 ] |=IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER ; c =FIELD_PREP (IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK , sts -1 );
@@ -947,6 +946,11 @@ mt7915_set_stream_he_txbf_caps(struct mt7915_phy *phy, sts_160 - 1); elem->phy_cap_info[5 ] |= c; +if (vif !=NL80211_IFTYPE_AP ) +return ; + + elem->phy_cap_info[4 ] |=IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER ; + c =IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB |IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB ; elem->phy_cap_info[6 ] |= c;
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 7/13 wifi: mt76: mt7915: only set MT76_MCU_RESET for the main phy
In reply to Felix FietkauFrom: Bo Jiao <[email protected]>
The MT76_MCU_RESET flag is only read on the main phy.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1 -3
@@ -1345,10 +1345,8 @@ mt7915_mac_restart(struct mt7915_dev *dev)set_bit (MT76_RESET , &dev->mphy.state);set_bit (MT76_MCU_RESET , &dev->mphy.state);wake_up (&dev->mt76.mcu.wait); -if (ext_phy) { +if (ext_phy)set_bit (MT76_RESET , &ext_phy->state); -set_bit (MT76_MCU_RESET , &ext_phy->state); - }/* lock/unlock all queues to ensure that no tx is pending */ mt76_txq_schedule_all (&dev->mphy);
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 8/13 wifi: mt76: mt7996: only set MT76_MCU_RESET for the main phy
In reply to Felix FietkauThe MT76_MCU_RESET flag is only read on the main phy.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -6
@@ -1655,14 +1655,10 @@ mt7996_mac_restart(struct mt7996_dev *dev)set_bit (MT76_RESET , &dev->mphy.state);set_bit (MT76_MCU_RESET , &dev->mphy.state);wake_up (&dev->mt76.mcu.wait); -if (phy2) { +if (phy2)set_bit (MT76_RESET , &phy2->mt76->state); -set_bit (MT76_MCU_RESET , &phy2->mt76->state); - } -if (phy3) { +if (phy3)set_bit (MT76_RESET , &phy3->mt76->state); -set_bit (MT76_MCU_RESET , &phy3->mt76->state); - }/* lock/unlock all queues to ensure that no tx is pending */ mt76_txq_schedule_all (&dev->mphy);
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 9/13 wifi: mt76: mt7915: add support for disabling in-band discovery
In reply to Felix FietkauFrom: MeiChia Chiu <[email protected]>
Send an update to the MCU whenever the settings change
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +2 -3
@@ -1919,8 +1919,7 @@ mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, bcn = (struct bss_info_bcn *)tlv; bcn->enable = true; -if (changed &BSS_CHANGED_FILS_DISCOVERY && - vif->bss_conf.fils_discovery.max_interval) { +if (changed &BSS_CHANGED_FILS_DISCOVERY ) { interval = vif->bss_conf.fils_discovery.max_interval; skb =ieee80211_get_fils_discovery_tmpl (hw, vif); } else if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP &&
@@ -1957,7 +1956,7 @@ mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, discov->tx_type = !!(changed &BSS_CHANGED_FILS_DISCOVERY ); discov->tx_interval = interval; discov->prob_rsp_len =cpu_to_le16 (MT_TXD_SIZE + skb->len); - discov->enable = true; + discov->enable = !!interval; buf = (u8 *)sub_tlv +sizeof (*discov);
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 10/13 wifi: mt76: mt7915: add mt7986, mt7916 and mt7981 pre-calibration
In reply to Felix FietkauFrom: Peter Chiu <[email protected]>
Add pre-calibration for mt7986 and mt7916. It has different data size with mt7915. Group cal needs 54k and 94k for 2G + 5G and 2G + 6G, respectively. DPD cal needs 300k.
--- .../wireless/mediatek/mt76/mt7915/eeprom.c | 16 ++- .../wireless/mediatek/mt76/mt7915/eeprom.h | 47 +++++++- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 113 ++++++++++++++---- .../wireless/mediatek/mt76/mt7915/mt7915.h | 4 + 4 files changed, 147 insertions(+), 33 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +7 -9
@@ -9,28 +9,26 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev) {struct mt76_dev *mdev = &dev->mt76;u8 *eeprom = mdev->eeprom.data; -u32 val = eeprom[MT_EE_DO_PRE_CAL ]; -u32 offs; +u32 offs =is_mt7915 (&dev->mt76) ?MT_EE_DO_PRE_CAL :MT_EE_DO_PRE_CAL_V2 ; +u32 size, val = eeprom[offs];int ret; -if (!dev->flash_mode) +if (!dev->flash_mode || !val)return 0 ; -if (val != (MT_EE_WIFI_CAL_DPD |MT_EE_WIFI_CAL_GROUP )) -return 0 ; + size =mt7915_get_cal_group_size (dev) +mt7915_get_cal_dpd_size (dev); - val =MT_EE_CAL_GROUP_SIZE +MT_EE_CAL_DPD_SIZE ; - dev->cal =devm_kzalloc (mdev->dev, val,GFP_KERNEL ); + dev->cal =devm_kzalloc (mdev->dev, size,GFP_KERNEL );if (!dev->cal)return -ENOMEM ; offs =is_mt7915 (&dev->mt76) ?MT_EE_PRECAL :MT_EE_PRECAL_V2 ; - ret =mt76_get_of_data_from_mtd (mdev, dev->cal, offs, val); + ret =mt76_get_of_data_from_mtd (mdev, dev->cal, offs, size);if (!ret)return ret; -return mt76_get_of_data_from_nvmem (mdev, dev->cal,"precal" , val); +return mt76_get_of_data_from_nvmem (mdev, dev->cal,"precal" , size); }static int mt7915_check_eeprom (struct mt7915_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.h +44 -3
66 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +92 -21
175 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +4 -0
@@ -302,6 +302,10 @@ struct mt7915_dev {struct rchan *relay_fwlog;void *cal; +u32 cur_prek_offset; +u8 dpd_chan_num_2g; +u8 dpd_chan_num_5g; +u8 dpd_chan_num_6g;struct {u8 debug_wm;
Signature · 1 line
2.43.0
Re: [PATCH 10/13] wifi: mt76: mt7915: add mt7986, mt7916 and mt7981 pre-calibration
Quoted 11 lines · Felix Fietkau
From: Peter Chiu <[email protected]>
Add pre-calibration for mt7986 and mt7916. It has different data size with mt7915. Group cal needs 54k and 94k for 2G + 5G and 2G + 6G, respectively. DPD cal needs 300k.
Signed-off-by Peter Chiu <[email protected]>Signed-off-by StanleyYP Wang <[email protected]>Signed-off-by Felix Fietkau <[email protected]>---
[...]
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c static int mt7915_find_freq_idx(const u16 *freqs, int n_freqs, u16 cur) · line 2950
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +2
-2-static int mt7915_dpd_freq_idx (u16 freq,u8 bw) +static int mt7915_dpd_freq_idx (struct mt7915_dev *dev,u16 freq,u8 bw) { -static const u16 freq_list[] = { +const u16 freq_list_v1[] = {5180 ,5200 ,5220 ,5240 ,5260 ,5280 ,5300 ,5320 ,5500 ,5520 ,5540 ,5560 ,
'static const' would be better than 'const', because 'static const' is only a copy of rodata, but 'const' is a copy of rodata plus a local copy in stack.
Felix Fietkau
maintainerPATCH 11/13 wifi: mt76: mt7915: add fallback in case of missing precal data
In reply to Felix FietkauWhen pre-calibration data is missing, do not fail the driver probe. Instead, just print a warning and fall back to regular calibration.
--- .../net/wireless/mediatek/mt76/mt7915/eeprom.c | 15 ++++++++++----- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +10 -5
@@ -28,7 +28,15 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev)if (!ret)return ret; -return mt76_get_of_data_from_nvmem (mdev, dev->cal,"precal" , size); + ret =mt76_get_of_data_from_nvmem (mdev, dev->cal,"precal" , size); +if (!ret) +return ret; + +dev_warn (mdev->dev,"missing precal data, size=%d\n" , size); +devm_kfree (mdev->dev, dev->cal); + dev->cal =NULL ; + +return ret; }static int mt7915_check_eeprom (struct mt7915_dev *dev)
@@ -254,10 +262,7 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)return ret; } - ret =mt7915_eeprom_load_precal (dev); -if (ret) -return ret; - +mt7915_eeprom_load_precal (dev);mt7915_eeprom_parse_hw_cap (dev, &dev->phy);memcpy (dev->mphy.macaddr, dev->mt76.eeprom.data +MT_EE_MAC_ADDR ,ETH_ALEN );
drivers/net/wireless/mediatek/mt76/mt7915/init.c +1 -1
@@ -823,7 +823,7 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2)if (ret <0 )return ret; -if (dev->flash_mode) { +if (dev->cal) { ret =mt7915_mcu_apply_group_cal (dev);if (ret)return ret;
drivers/net/wireless/mediatek/mt76/mt7915/main.c +1 -1
@@ -329,7 +329,7 @@ int mt7915_set_channel(struct mt7915_phy *phy)mt76_set_channel (phy->mt76); -if (dev->flash_mode) { +if (dev->cal) { ret =mt7915_mcu_apply_tx_dpd (phy);if (ret) goto out;
Signature · 1 line
2.43.0
Re: [PATCH 11/13] wifi: mt76: mt7915: add fallback in case of missing precal data
Quoted 15 lines · Felix Fietkau
When pre-calibration data is missing, do not fail the driver probe. Instead, just print a warning and fall back to regular calibration.
Signed-off-by Felix Fietkau <[email protected]>--- .../net/wireless/mediatek/mt76/mt7915/eeprom.c | 15 ++++++++++----- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 2 +- drivers/net/wireless/mediatek/mt76/mt7915/main.c | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-)drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +0
-0
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c static int mt7915_eeprom_load_precal(struct mt7915_dev *dev) · line 36
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +6
-1@@ -28,7 +28,15 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev)if (!ret)return ret; -return mt76_get_of_data_from_nvmem (mdev, dev->cal,"precal" , size); + ret =mt76_get_of_data_from_nvmem (mdev, dev->cal,"precal" , size); +if (!ret) +return ret; + +dev_warn (mdev->dev,"missing precal data, size=%d\n" , size); +devm_kfree (mdev->dev, dev->cal);
if you are going to devm_kfree the memory for this case, why not also for the mt76_get_of_data_from_mtd() failure case?
Quoted 7 lines
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +3
-0+ dev->cal =NULL ; + +return ret; }static int mt7915_check_eeprom (struct mt7915_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c int mt7915_eeprom_init(struct mt7915_dev *dev) · line 265
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +1
-4@@ -254,10 +262,7 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)return ret; } - ret =mt7915_eeprom_load_precal (dev); -if (ret) -return ret; - +mt7915_eeprom_load_precal (dev);
if you're not going to check the status, why not make it a void function?
Re: [PATCH 11/13] wifi: mt76: mt7915: add fallback in case of missing precal data
Quoted 2 lines · Jeff Johnson
if you are going to
devm_kfreethe memory for this case, why not also for themt76_get_of_data_from_mtd()failure case?
ignore that comment -- obviously that was the success case and the failure ace comes here
Felix Fietkau
maintainerPATCH 12/13 wifi: mt76: mt7603: fix tx queue of loopback packets
In reply to Felix FietkauUse the correct WMM AC queue instead of the MGMT one to fix potential issues with aggregation sequence number tracking. Drop non-bufferable packets.
--- .../net/wireless/mediatek/mt76/mt7603/dma.c | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/dma.c +32 -14
@@ -4,6 +4,13 @@#include "mac.h" #include "../dma.h" +static const u8 wmm_queue_map[] = { + [IEEE80211_AC_BK ] =0 , + [IEEE80211_AC_BE ] =1 , + [IEEE80211_AC_VI ] =2 , + [IEEE80211_AC_VO ] =3 , +}; +static void mt7603_rx_loopback_skb (struct mt7603_dev *dev,struct sk_buff *skb) {
@@ -22,10 +29,10 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb)struct ieee80211_sta *sta;struct mt7603_sta *msta;struct mt76_wcid *wcid; +u8 tid =0 , hwq =0 ;void *priv;int idx;u32 val; -u8 tid =0 ;if (skb->len <MT_TXD_SIZE +sizeof (struct ieee80211_hdr )) goto free;
@@ -42,19 +49,36 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) goto free; priv = msta = container_of(wcid, struct mt7603_sta, wcid); - val =le32_to_cpu (txd[0 ]); - val &= ~(MT_TXD0_P_IDX |MT_TXD0_Q_IDX ); - val |=FIELD_PREP (MT_TXD0_Q_IDX ,MT_TX_HW_QUEUE_MGMT ); - txd[0 ] =cpu_to_le32 (val); sta = container_of(priv, struct ieee80211_sta, drv_priv); hdr = (struct ieee80211_hdr *)&skb->data[MT_TXD_SIZE ]; -if (ieee80211_is_data_qos (hdr->frame_control)) + + hwq = wmm_queue_map[IEEE80211_AC_BE ]; +if (ieee80211_is_data_qos (hdr->frame_control)) { tid = *ieee80211_get_qos_ctl (hdr) & -IEEE80211_QOS_CTL_TAG1D_MASK ; -skb_set_queue_mapping (skb, tid_to_ac[tid]); +IEEE80211_QOS_CTL_TAG1D_MASK ; +u8 qid = tid_to_ac[tid]; + hwq = wmm_queue_map[qid]; +skb_set_queue_mapping (skb, qid); + }else if (ieee80211_is_data (hdr->frame_control)) { +skb_set_queue_mapping (skb,IEEE80211_AC_BE ); + hwq = wmm_queue_map[IEEE80211_AC_BE ]; + }else { +skb_pull (skb,MT_TXD_SIZE ); +if (!ieee80211_is_bufferable_mmpdu (skb)) + goto free; +skb_push (skb,MT_TXD_SIZE ); +skb_set_queue_mapping (skb,MT_TXQ_PSD ); + hwq =MT_TX_HW_QUEUE_MGMT ; + } +ieee80211_sta_set_buffered (sta, tid, true); + val =le32_to_cpu (txd[0 ]); + val &= ~(MT_TXD0_P_IDX |MT_TXD0_Q_IDX ); + val |=FIELD_PREP (MT_TXD0_Q_IDX , hwq); + txd[0 ] =cpu_to_le32 (val); +spin_lock_bh (&dev->ps_lock);__skb_queue_tail (&msta->psq, skb);if (skb_queue_len (&msta->psq) >=64 ) {
@@ -151,12 +175,6 @@ static int mt7603_poll_tx(struct napi_struct *napi, int budget)int mt7603_dma_init (struct mt7603_dev *dev) { -static const u8 wmm_queue_map[] = { - [IEEE80211_AC_BK ] =0 , - [IEEE80211_AC_BE ] =1 , - [IEEE80211_AC_VI ] =2 , - [IEEE80211_AC_VO ] =3 , - };int ret;int i;
Signature · 1 line
2.43.0
Felix Fietkau
maintainerPATCH 13/13 wifi: mt76: mt7603: add wpdma tx eof flag for PSE client reset
In reply to Felix FietkauThis flag is needed for the PSE client reset. Fixes watchdog reset issues.
--- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +1 -0
@@ -1393,6 +1393,7 @@ void mt7603_pse_client_reset(struct mt7603_dev *dev) MT_CLIENT_RESET_TX_R_E_2_S);/* Start PSE client TX abort */ +mt76_set (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_FORCE_TX_EOF );mt76_set (dev, addr,MT_CLIENT_RESET_TX_R_E_1 );mt76_poll_msec (dev, addr,MT_CLIENT_RESET_TX_R_E_1_S ,MT_CLIENT_RESET_TX_R_E_1_S ,500 );
Signature · 1 line
2.43.0