mac.c (dfc7743de1ebb5ff5c2ed323eaff1994da11abd9) mac.c (8910a4e5ba342ad661acb6f99fa14e0dd809465e)
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/devcoredump.h>
5#include <linux/etherdevice.h>
6#include <linux/timekeeping.h>
7#include "mt7921.h"
8#include "../dma.h"

--- 25 unchanged lines hidden (view full) ---

34 return NULL;
35
36 return &sta->vif->sta.wcid;
37}
38
39void mt7921_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps)
40{
41}
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/devcoredump.h>
5#include <linux/etherdevice.h>
6#include <linux/timekeeping.h>
7#include "mt7921.h"
8#include "../dma.h"

--- 25 unchanged lines hidden (view full) ---

34 return NULL;
35
36 return &sta->vif->sta.wcid;
37}
38
39void mt7921_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps)
40{
41}
42EXPORT_SYMBOL_GPL(mt7921_sta_ps);
42
43bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask)
44{
45 mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX,
46 FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, idx) | mask);
47
48 return mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY,
49 0, 5000);

--- 110 unchanged lines hidden (view full) ---

160 (RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) {
161 if (val & BIT(MT_WTBL_TXRX_RATE_G2 + bw))
162 rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
163 else
164 rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI;
165 }
166 }
167}
43
44bool mt7921_mac_wtbl_update(struct mt7921_dev *dev, int idx, u32 mask)
45{
46 mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX,
47 FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, idx) | mask);
48
49 return mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY,
50 0, 5000);

--- 110 unchanged lines hidden (view full) ---

161 (RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) {
162 if (val & BIT(MT_WTBL_TXRX_RATE_G2 + bw))
163 rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
164 else
165 rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI;
166 }
167 }
168}
169EXPORT_SYMBOL_GPL(mt7921_mac_sta_poll);
168
169static void
170mt7921_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
171 struct ieee80211_radiotap_he *he,
172 __le32 *rxv)
173{
174 u32 ru_h, ru_l;
175 u8 ru, offs = 0;

--- 735 unchanged lines hidden (view full) ---

911 rate |= FIELD_PREP(MT_TX_RATE_MODE, mode);
912
913 val = MT_TXD6_FIXED_BW |
914 FIELD_PREP(MT_TXD6_TX_RATE, rate);
915 txwi[6] |= cpu_to_le32(val);
916 txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
917 }
918}
170
171static void
172mt7921_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
173 struct ieee80211_radiotap_he *he,
174 __le32 *rxv)
175{
176 u32 ru_h, ru_l;
177 u8 ru, offs = 0;

--- 735 unchanged lines hidden (view full) ---

913 rate |= FIELD_PREP(MT_TX_RATE_MODE, mode);
914
915 val = MT_TXD6_FIXED_BW |
916 FIELD_PREP(MT_TXD6_TX_RATE, rate);
917 txwi[6] |= cpu_to_le32(val);
918 txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
919 }
920}
921EXPORT_SYMBOL_GPL(mt7921_mac_write_txwi);
919
920void mt7921_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
921{
922 struct mt7921_sta *msta;
923 u16 fc, tid;
924 u32 val;
925
926 if (!sta || !(sta->ht_cap.ht_supported || sta->he_cap.has_he))

--- 8 unchanged lines hidden (view full) ---

935 FIELD_GET(MT_TXD2_SUB_TYPE, val) << 4;
936 if (unlikely(fc != (IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA)))
937 return;
938
939 msta = (struct mt7921_sta *)sta->drv_priv;
940 if (!test_and_set_bit(tid, &msta->ampdu_state))
941 ieee80211_start_tx_ba_session(sta, tid, 0);
942}
922
923void mt7921_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
924{
925 struct mt7921_sta *msta;
926 u16 fc, tid;
927 u32 val;
928
929 if (!sta || !(sta->ht_cap.ht_supported || sta->he_cap.has_he))

--- 8 unchanged lines hidden (view full) ---

938 FIELD_GET(MT_TXD2_SUB_TYPE, val) << 4;
939 if (unlikely(fc != (IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA)))
940 return;
941
942 msta = (struct mt7921_sta *)sta->drv_priv;
943 if (!test_and_set_bit(tid, &msta->ampdu_state))
944 ieee80211_start_tx_ba_session(sta, tid, 0);
945}
946EXPORT_SYMBOL_GPL(mt7921_tx_check_aggr);
943
944static bool
945mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid,
946 __le32 *txs_data)
947{
948 struct ieee80211_supported_band *sband;
949 struct mt76_dev *mdev = &dev->mt76;
950 struct ieee80211_tx_info *info;

--- 172 unchanged lines hidden (view full) ---

1123 return;
1124 }
1125 fallthrough;
1126 default:
1127 dev_kfree_skb(skb);
1128 break;
1129 }
1130}
947
948static bool
949mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid,
950 __le32 *txs_data)
951{
952 struct ieee80211_supported_band *sband;
953 struct mt76_dev *mdev = &dev->mt76;
954 struct ieee80211_tx_info *info;

--- 172 unchanged lines hidden (view full) ---

1127 return;
1128 }
1129 fallthrough;
1130 default:
1131 dev_kfree_skb(skb);
1132 break;
1133 }
1134}
1135EXPORT_SYMBOL_GPL(mt7921_queue_rx_skb);
1131
1132void mt7921_mac_reset_counters(struct mt7921_phy *phy)
1133{
1134 struct mt7921_dev *dev = phy->dev;
1135 int i;
1136
1137 for (i = 0; i < 4; i++) {
1138 mt76_rr(dev, MT_TX_AGG_CNT(0, i));

--- 99 unchanged lines hidden (view full) ---

1238 return;
1239
1240 mt7921_phy_update_channel(mphy, 0);
1241 /* reset obss airtime */
1242 mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR);
1243
1244 mt76_connac_power_save_sched(mphy, &dev->pm);
1245}
1136
1137void mt7921_mac_reset_counters(struct mt7921_phy *phy)
1138{
1139 struct mt7921_dev *dev = phy->dev;
1140 int i;
1141
1142 for (i = 0; i < 4; i++) {
1143 mt76_rr(dev, MT_TX_AGG_CNT(0, i));

--- 99 unchanged lines hidden (view full) ---

1243 return;
1244
1245 mt7921_phy_update_channel(mphy, 0);
1246 /* reset obss airtime */
1247 mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR);
1248
1249 mt76_connac_power_save_sched(mphy, &dev->pm);
1250}
1251EXPORT_SYMBOL_GPL(mt7921_update_channel);
1246
1247static void
1248mt7921_vif_connect_iter(void *priv, u8 *mac,
1249 struct ieee80211_vif *vif)
1250{
1251 struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1252 struct mt7921_dev *dev = mvif->phy->dev;
1253

--- 216 unchanged lines hidden ---
1252
1253static void
1254mt7921_vif_connect_iter(void *priv, u8 *mac,
1255 struct ieee80211_vif *vif)
1256{
1257 struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
1258 struct mt7921_dev *dev = mvif->phy->dev;
1259

--- 216 unchanged lines hidden ---