Skip to content

Commit b2d91fb

Browse files
Stanislaw GruszkaKalle Valo
authored andcommitted
mt76: unify sta structure part 2
Second part of unifying mt76x02_sta structure between mt76x0 and mt76x2. Signed-off-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent f5a7f12 commit b2d91fb

13 files changed

+36
-54
lines changed

drivers/net/wireless/mediatek/mt76/mt76x02_mac.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef __MT76X02_MAC_H
1919
#define __MT76X02_MAC_H
2020

21+
#include <linux/average.h>
22+
2123
struct mt76x02_tx_status {
2224
u8 valid:1;
2325
u8 success:1;
@@ -35,12 +37,17 @@ struct mt76x02_vif {
3537
struct mt76_wcid group_wcid;
3638
};
3739

40+
DECLARE_EWMA(signal, 10, 8);
41+
3842
struct mt76x02_sta {
3943
struct mt76_wcid wcid; /* must be first */
4044

4145
struct mt76x02_vif *vif;
4246
struct mt76x02_tx_status status;
4347
int n_frames;
48+
49+
struct ewma_signal rssi;
50+
int inactive_count;
4451
};
4552

4653
static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)

drivers/net/wireless/mediatek/mt76/mt76x2.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/mutex.h>
2828
#include <linux/bitops.h>
2929
#include <linux/kfifo.h>
30-
#include <linux/average.h>
3130

3231
#define MT7662_FIRMWARE "mt7662.bin"
3332
#define MT7662_ROM_PATCH "mt7662_rom_patch.bin"
@@ -51,8 +50,6 @@
5150
#include "mt76x2_mac.h"
5251
#include "mt76x2_dfs.h"
5352

54-
DECLARE_EWMA(signal, 10, 8)
55-
5653
struct mt76x2_mcu {
5754
struct mutex mutex;
5855

@@ -104,7 +101,7 @@ struct mt76x2_dev {
104101
int txpower_cur;
105102

106103
u8 txdone_seq;
107-
DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x2_tx_status);
104+
DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
108105

109106
struct mt76x2_mcu mcu;
110107
struct sk_buff *rx_head;
@@ -144,17 +141,6 @@ struct mt76x2_dev {
144141
struct mt76x2_dfs_pattern_detector dfs_pd;
145142
};
146143

147-
struct mt76x2_sta {
148-
struct mt76_wcid wcid; /* must be first */
149-
150-
struct mt76x02_vif *vif;
151-
struct mt76x2_tx_status status;
152-
int n_frames;
153-
154-
struct ewma_signal rssi;
155-
int inactive_count;
156-
};
157-
158144
static inline bool is_mt7612(struct mt76x2_dev *dev)
159145
{
160146
return mt76_chip(&dev->mt76) == 0x7612;
@@ -264,9 +250,9 @@ void mt76x2_tx_set_txpwr_auto(struct mt76x2_dev *dev, s8 txpwr);
264250
int mt76x2_insert_hdr_pad(struct sk_buff *skb);
265251

266252
bool mt76x2_mac_load_tx_status(struct mt76x2_dev *dev,
267-
struct mt76x2_tx_status *stat);
253+
struct mt76x02_tx_status *stat);
268254
void mt76x2_send_tx_status(struct mt76x2_dev *dev,
269-
struct mt76x2_tx_status *stat, u8 *update);
255+
struct mt76x02_tx_status *stat, u8 *update);
270256
void mt76x2_reset_wlan(struct mt76x2_dev *dev, bool enable);
271257
void mt76x2_init_txpower(struct mt76x2_dev *dev,
272258
struct ieee80211_supported_band *sband);

drivers/net/wireless/mediatek/mt76/mt76x2_common.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int mt76x2_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2424
enum ieee80211_ampdu_mlme_action action = params->action;
2525
struct ieee80211_sta *sta = params->sta;
2626
struct mt76x2_dev *dev = hw->priv;
27-
struct mt76x2_sta *msta = (struct mt76x2_sta *) sta->drv_priv;
27+
struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
2828
struct ieee80211_txq *txq = sta->txq[params->tid];
2929
u16 tid = params->tid;
3030
u16 *ssn = &params->ssn;
@@ -73,7 +73,7 @@ int mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
7373
struct ieee80211_sta *sta)
7474
{
7575
struct mt76x2_dev *dev = hw->priv;
76-
struct mt76x2_sta *msta = (struct mt76x2_sta *) sta->drv_priv;
76+
struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
7777
struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
7878
int ret = 0;
7979
int idx = 0;
@@ -114,7 +114,7 @@ int mt76x2_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
114114
struct ieee80211_sta *sta)
115115
{
116116
struct mt76x2_dev *dev = hw->priv;
117-
struct mt76x2_sta *msta = (struct mt76x2_sta *) sta->drv_priv;
117+
struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
118118
int idx = msta->wcid.idx;
119119
int i;
120120

@@ -146,7 +146,7 @@ int mt76x2_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
146146
{
147147
struct mt76x2_dev *dev = hw->priv;
148148
struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
149-
struct mt76x2_sta *msta;
149+
struct mt76x02_sta *msta;
150150
struct mt76_wcid *wcid;
151151
int idx = key->keyidx;
152152
int ret;
@@ -173,7 +173,7 @@ int mt76x2_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
173173
!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
174174
return -EOPNOTSUPP;
175175

176-
msta = sta ? (struct mt76x2_sta *) sta->drv_priv : NULL;
176+
msta = sta ? (struct mt76x02_sta *) sta->drv_priv : NULL;
177177
wcid = msta ? &msta->wcid : &mvif->group_wcid;
178178

179179
if (cmd == SET_KEY) {
@@ -256,7 +256,7 @@ void mt76x2_sta_rate_tbl_update(struct ieee80211_hw *hw,
256256
struct ieee80211_sta *sta)
257257
{
258258
struct mt76x2_dev *dev = hw->priv;
259-
struct mt76x2_sta *msta = (struct mt76x2_sta *) sta->drv_priv;
259+
struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
260260
struct ieee80211_sta_rates *rates = rcu_dereference(sta->rates);
261261
struct ieee80211_tx_rate rate = {};
262262

drivers/net/wireless/mediatek/mt76/mt76x2_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ int mt76x2_register_device(struct mt76x2_dev *dev)
533533
int fifo_size;
534534
int i, ret;
535535

536-
fifo_size = roundup_pow_of_two(32 * sizeof(struct mt76x2_tx_status));
536+
fifo_size = roundup_pow_of_two(32 * sizeof(struct mt76x02_tx_status));
537537
status_fifo = devm_kzalloc(dev->mt76.dev, fifo_size, GFP_KERNEL);
538538
if (!status_fifo)
539539
return -ENOMEM;

drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void mt76x2_init_device(struct mt76x2_dev *dev)
208208
hw->max_rate_tries = 1;
209209
hw->extra_tx_headroom = 2;
210210

211-
hw->sta_data_size = sizeof(struct mt76x2_sta);
211+
hw->sta_data_size = sizeof(struct mt76x02_sta);
212212
hw->vif_data_size = sizeof(struct mt76x02_vif);
213213

214214
ieee80211_hw_set(hw, SUPPORTS_HT_CCK_RATES);

drivers/net/wireless/mediatek/mt76/mt76x2_mac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void mt76x2_mac_set_bssid(struct mt76x2_dev *dev, u8 idx, const u8 *addr)
3030

3131
void mt76x2_mac_poll_tx_status(struct mt76x2_dev *dev, bool irq)
3232
{
33-
struct mt76x2_tx_status stat = {};
33+
struct mt76x02_tx_status stat = {};
3434
unsigned long flags;
3535
u8 update = 1;
3636
bool ret;
@@ -78,7 +78,7 @@ mt76x2_mac_queue_txdone(struct mt76x2_dev *dev, struct sk_buff *skb,
7878

7979
void mt76x2_mac_process_tx_status_fifo(struct mt76x2_dev *dev)
8080
{
81-
struct mt76x2_tx_status stat;
81+
struct mt76x02_tx_status stat;
8282
u8 update = 1;
8383

8484
while (kfifo_get(&dev->txstatus_fifo, &stat))

drivers/net/wireless/mediatek/mt76/mt76x2_mac.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ struct mt76x2_sta;
2525
struct mt76x02_vif;
2626
struct mt76x2_txwi;
2727

28-
struct mt76x2_tx_status {
29-
u8 valid:1;
30-
u8 success:1;
31-
u8 aggr:1;
32-
u8 ack_req:1;
33-
u8 wcid;
34-
u8 pktid;
35-
u8 retry;
36-
u16 rate;
37-
} __packed __aligned(2);
38-
3928
struct mt76x2_tx_info {
4029
unsigned long jiffies;
4130
u8 tries;

drivers/net/wireless/mediatek/mt76/mt76x2_mac_common.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void mt76x2_mac_stop(struct mt76x2_dev *dev, bool force)
5454
EXPORT_SYMBOL_GPL(mt76x2_mac_stop);
5555

5656
bool mt76x2_mac_load_tx_status(struct mt76x2_dev *dev,
57-
struct mt76x2_tx_status *stat)
57+
struct mt76x02_tx_status *stat)
5858
{
5959
u32 stat1, stat2;
6060

@@ -138,7 +138,7 @@ mt76x2_mac_process_tx_rate(struct ieee80211_tx_rate *txrate, u16 rate,
138138
static void
139139
mt76x2_mac_fill_tx_status(struct mt76x2_dev *dev,
140140
struct ieee80211_tx_info *info,
141-
struct mt76x2_tx_status *st, int n_frames)
141+
struct mt76x02_tx_status *st, int n_frames)
142142
{
143143
struct ieee80211_tx_rate *rate = info->status.rates;
144144
int cur_idx, last_rate;
@@ -178,12 +178,12 @@ mt76x2_mac_fill_tx_status(struct mt76x2_dev *dev,
178178
}
179179

180180
void mt76x2_send_tx_status(struct mt76x2_dev *dev,
181-
struct mt76x2_tx_status *stat, u8 *update)
181+
struct mt76x02_tx_status *stat, u8 *update)
182182
{
183183
struct ieee80211_tx_info info = {};
184184
struct ieee80211_sta *sta = NULL;
185185
struct mt76_wcid *wcid = NULL;
186-
struct mt76x2_sta *msta = NULL;
186+
struct mt76x02_sta *msta = NULL;
187187

188188
rcu_read_lock();
189189
if (stat->wcid < ARRAY_SIZE(dev->wcid))
@@ -192,7 +192,7 @@ void mt76x2_send_tx_status(struct mt76x2_dev *dev,
192192
if (wcid) {
193193
void *priv;
194194

195-
priv = msta = container_of(wcid, struct mt76x2_sta, wcid);
195+
priv = msta = container_of(wcid, struct mt76x02_sta, wcid);
196196
sta = container_of(priv, struct ieee80211_sta,
197197
drv_priv);
198198
}
@@ -472,7 +472,7 @@ int mt76x2_mac_get_rssi(struct mt76x2_dev *dev, s8 rssi, int chain)
472472
return rssi;
473473
}
474474

475-
static struct mt76x2_sta *
475+
static struct mt76x02_sta *
476476
mt76x2_rx_get_sta(struct mt76x2_dev *dev, u8 idx)
477477
{
478478
struct mt76_wcid *wcid;
@@ -484,11 +484,11 @@ mt76x2_rx_get_sta(struct mt76x2_dev *dev, u8 idx)
484484
if (!wcid)
485485
return NULL;
486486

487-
return container_of(wcid, struct mt76x2_sta, wcid);
487+
return container_of(wcid, struct mt76x02_sta, wcid);
488488
}
489489

490490
static struct mt76_wcid *
491-
mt76x2_rx_get_sta_wcid(struct mt76x2_dev *dev, struct mt76x2_sta *sta,
491+
mt76x2_rx_get_sta_wcid(struct mt76x2_dev *dev, struct mt76x02_sta *sta,
492492
bool unicast)
493493
{
494494
if (!sta)
@@ -505,7 +505,7 @@ int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb,
505505
{
506506
struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb;
507507
struct mt76x2_rxwi *rxwi = rxi;
508-
struct mt76x2_sta *sta;
508+
struct mt76x02_sta *sta;
509509
u32 rxinfo = le32_to_cpu(rxwi->rxinfo);
510510
u32 ctl = le32_to_cpu(rxwi->ctl);
511511
u16 rate = le16_to_cpu(rxwi->rate);

drivers/net/wireless/mediatek/mt76/mt76x2_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ mt76x2_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
202202
void
203203
mt76x2_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps)
204204
{
205-
struct mt76x2_sta *msta = (struct mt76x2_sta *) sta->drv_priv;
205+
struct mt76x02_sta *msta = (struct mt76x02_sta *) sta->drv_priv;
206206
struct mt76x2_dev *dev = container_of(mdev, struct mt76x2_dev, mt76);
207207
int idx = msta->wcid.idx;
208208

drivers/net/wireless/mediatek/mt76/mt76x2_phy_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ EXPORT_SYMBOL_GPL(mt76x2_phy_set_band);
303303

304304
int mt76x2_phy_get_min_avg_rssi(struct mt76x2_dev *dev)
305305
{
306-
struct mt76x2_sta *sta;
306+
struct mt76x02_sta *sta;
307307
struct mt76_wcid *wcid;
308308
int i, j, min_rssi = 0;
309309
s8 cur_rssi;
@@ -325,7 +325,7 @@ int mt76x2_phy_get_min_avg_rssi(struct mt76x2_dev *dev)
325325
if (!wcid)
326326
continue;
327327

328-
sta = container_of(wcid, struct mt76x2_sta, wcid);
328+
sta = container_of(wcid, struct mt76x02_sta, wcid);
329329
spin_lock(&dev->mt76.rx_lock);
330330
if (sta->inactive_count++ < 5)
331331
cur_rssi = ewma_signal_read(&sta->rssi);

drivers/net/wireless/mediatek/mt76/mt76x2_trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ DEFINE_EVENT(dev_txid_evt, mac_txdone_add,
7575

7676
TRACE_EVENT(mac_txstat_fetch,
7777
TP_PROTO(struct mt76x2_dev *dev,
78-
struct mt76x2_tx_status *stat),
78+
struct mt76x02_tx_status *stat),
7979

8080
TP_ARGS(dev, stat),
8181

drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ void mt76x2_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
2727
struct mt76_wcid *wcid = &dev->global_wcid;
2828

2929
if (control->sta) {
30-
struct mt76x2_sta *msta;
30+
struct mt76x02_sta *msta;
3131

32-
msta = (struct mt76x2_sta *)control->sta->drv_priv;
32+
msta = (struct mt76x02_sta *)control->sta->drv_priv;
3333
wcid = &msta->wcid;
3434
/* sw encrypted frames */
3535
if (!info->control.hw_key && wcid->hw_key_idx != 0xff)

drivers/net/wireless/mediatek/mt76/mt76x2u_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ mt76x2u_set_txinfo(struct sk_buff *skb,
6666
bool mt76x2u_tx_status_data(struct mt76_dev *mdev, u8 *update)
6767
{
6868
struct mt76x2_dev *dev = container_of(mdev, struct mt76x2_dev, mt76);
69-
struct mt76x2_tx_status stat;
69+
struct mt76x02_tx_status stat;
7070

7171
if (!mt76x2_mac_load_tx_status(dev, &stat))
7272
return false;

0 commit comments

Comments
 (0)