Skip to content

Commit f5a7f12

Browse files
Stanislaw GruszkaKalle Valo
authored andcommitted
mt76: unify sta structure part 1
First 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 98ff26e commit f5a7f12

File tree

5 files changed

+49
-27
lines changed

5 files changed

+49
-27
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "mt76.h"
1919
#include "mt76x02_regs.h"
20+
#include "mt76x02_mac.h"
2021

2122
enum mt76x02_cipher_type
2223
mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
@@ -130,3 +131,27 @@ void mt76x02_mac_wcid_set_drop(struct mt76_dev *dev, u8 idx, bool drop)
130131
__mt76_wr(dev, MT_WCID_DROP(idx), (val & ~bit) | (bit * drop));
131132
}
132133
EXPORT_SYMBOL_GPL(mt76x02_mac_wcid_set_drop);
134+
135+
void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq)
136+
{
137+
struct mt76_txq *mtxq;
138+
139+
if (!txq)
140+
return;
141+
142+
mtxq = (struct mt76_txq *) txq->drv_priv;
143+
if (txq->sta) {
144+
struct mt76x02_sta *sta;
145+
146+
sta = (struct mt76x02_sta *) txq->sta->drv_priv;
147+
mtxq->wcid = &sta->wcid;
148+
} else {
149+
struct mt76x02_vif *mvif;
150+
151+
mvif = (struct mt76x02_vif *) txq->vif->drv_priv;
152+
mtxq->wcid = &mvif->group_wcid;
153+
}
154+
155+
mt76_txq_init(dev, txq);
156+
}
157+
EXPORT_SYMBOL_GPL(mt76x02_txq_init);

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

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

21+
struct mt76x02_tx_status {
22+
u8 valid:1;
23+
u8 success:1;
24+
u8 aggr:1;
25+
u8 ack_req:1;
26+
u8 wcid;
27+
u8 pktid;
28+
u8 retry;
29+
u16 rate;
30+
} __packed __aligned(2);
31+
2132
struct mt76x02_vif {
2233
u8 idx;
2334

2435
struct mt76_wcid group_wcid;
2536
};
2637

38+
struct mt76x02_sta {
39+
struct mt76_wcid wcid; /* must be first */
40+
41+
struct mt76x02_vif *vif;
42+
struct mt76x02_tx_status status;
43+
int n_frames;
44+
};
45+
2746
static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
2847
{
2948
const u32 MAC_CSR0 = 0x1000;
@@ -45,6 +64,8 @@ static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
4564
return false;
4665
}
4766

67+
void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq);
68+
4869
enum mt76x02_cipher_type
4970
mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data);
5071

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,6 @@
1818
#include "mt76x2.h"
1919
#include "mt76x02_mac.h"
2020

21-
void mt76x2_txq_init(struct mt76x2_dev *dev, struct ieee80211_txq *txq)
22-
{
23-
struct mt76_txq *mtxq;
24-
25-
if (!txq)
26-
return;
27-
28-
mtxq = (struct mt76_txq *) txq->drv_priv;
29-
if (txq->sta) {
30-
struct mt76x2_sta *sta;
31-
32-
sta = (struct mt76x2_sta *) txq->sta->drv_priv;
33-
mtxq->wcid = &sta->wcid;
34-
} else {
35-
struct mt76x02_vif *mvif;
36-
37-
mvif = (struct mt76x02_vif *) txq->vif->drv_priv;
38-
mtxq->wcid = &mvif->group_wcid;
39-
}
40-
41-
mt76_txq_init(&dev->mt76, txq);
42-
}
43-
EXPORT_SYMBOL_GPL(mt76x2_txq_init);
44-
4521
int mt76x2_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4622
struct ieee80211_ampdu_params *params)
4723
{
@@ -118,7 +94,7 @@ int mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
11894
mt76x02_mac_wcid_setup(&dev->mt76, idx, mvif->idx, sta->addr);
11995
mt76x02_mac_wcid_set_drop(&dev->mt76, idx, false);
12096
for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
121-
mt76x2_txq_init(dev, sta->txq[i]);
97+
mt76x02_txq_init(&dev->mt76, sta->txq[i]);
12298

12399
if (vif->type == NL80211_IFTYPE_AP)
124100
set_bit(MT_WCID_FLAG_CHECK_PS, &msta->wcid.flags);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ mt76x2_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
8383
mvif->idx = idx;
8484
mvif->group_wcid.idx = MT_VIF_WCID(idx);
8585
mvif->group_wcid.hw_key_idx = -1;
86-
mt76x2_txq_init(dev, vif->txq);
86+
mt76x02_txq_init(&dev->mt76, vif->txq);
8787

8888
return 0;
8989
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
5858
mvif->idx = idx;
5959
mvif->group_wcid.idx = MT_VIF_WCID(idx);
6060
mvif->group_wcid.hw_key_idx = -1;
61-
mt76x2_txq_init(dev, vif->txq);
61+
mt76x02_txq_init(&dev->mt76, vif->txq);
6262

6363
return 0;
6464
}

0 commit comments

Comments
 (0)