Skip to content

Commit cc72626

Browse files
LorenzoBianconinbd168
authored andcommitted
mt76: move mt76x02_bss_info_changed in mt76x02-lib module
Unify drv_bss_info_changed mac80211 callback and remove duplicated code in mt76x0 and mt76x2 drivers Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
1 parent 317ed42 commit cc72626

File tree

7 files changed

+48
-92
lines changed

7 files changed

+48
-92
lines changed

drivers/net/wireless/mediatek/mt76/mt76x0/main.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -71,52 +71,3 @@ int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
7171
return ret;
7272
}
7373
EXPORT_SYMBOL_GPL(mt76x0_config);
74-
75-
void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
76-
struct ieee80211_vif *vif,
77-
struct ieee80211_bss_conf *info, u32 changed)
78-
{
79-
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
80-
struct mt76x02_dev *dev = hw->priv;
81-
82-
mutex_lock(&dev->mt76.mutex);
83-
84-
if (changed & BSS_CHANGED_BSSID)
85-
mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
86-
87-
if (changed & BSS_CHANGED_BEACON_ENABLED) {
88-
tasklet_disable(&dev->pre_tbtt_tasklet);
89-
mt76x02_mac_set_beacon_enable(dev, mvif->idx,
90-
info->enable_beacon);
91-
tasklet_enable(&dev->pre_tbtt_tasklet);
92-
}
93-
94-
if (changed & BSS_CHANGED_BASIC_RATES) {
95-
mt76_wr(dev, MT_LEGACY_BASIC_RATE, info->basic_rates);
96-
mt76_wr(dev, MT_VHT_HT_FBK_CFG0, 0x65432100);
97-
mt76_wr(dev, MT_VHT_HT_FBK_CFG1, 0xedcba980);
98-
mt76_wr(dev, MT_LG_FBK_CFG0, 0xedcba988);
99-
mt76_wr(dev, MT_LG_FBK_CFG1, 0x00002100);
100-
}
101-
102-
if (changed & BSS_CHANGED_BEACON_INT) {
103-
mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
104-
MT_BEACON_TIME_CFG_INTVAL,
105-
info->beacon_int << 4);
106-
dev->beacon_int = info->beacon_int;
107-
dev->tbtt_count = 0;
108-
}
109-
110-
if (changed & BSS_CHANGED_ERP_PREAMBLE)
111-
mt76x02_mac_set_short_preamble(dev, info->use_short_preamble);
112-
113-
if (changed & BSS_CHANGED_ERP_SLOT) {
114-
int slottime = info->use_short_slot ? 9 : 20;
115-
116-
dev->slottime = slottime;
117-
mt76x02_set_tx_ackto(dev);
118-
}
119-
120-
mutex_unlock(&dev->mt76.mutex);
121-
}
122-
EXPORT_SYMBOL_GPL(mt76x0_bss_info_changed);

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ int mt76x0_mac_start(struct mt76x02_dev *dev);
6262
void mt76x0_mac_stop(struct mt76x02_dev *dev);
6363

6464
int mt76x0_config(struct ieee80211_hw *hw, u32 changed);
65-
void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
66-
struct ieee80211_vif *vif,
67-
struct ieee80211_bss_conf *info, u32 changed);
6865

6966
/* PHY */
7067
void mt76x0_phy_init(struct mt76x02_dev *dev);

drivers/net/wireless/mediatek/mt76/mt76x0/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
8989
.remove_interface = mt76x02_remove_interface,
9090
.config = mt76x0_config,
9191
.configure_filter = mt76x02_configure_filter,
92-
.bss_info_changed = mt76x0_bss_info_changed,
92+
.bss_info_changed = mt76x02_bss_info_changed,
9393
.sta_add = mt76x02_sta_add,
9494
.sta_remove = mt76x02_sta_remove,
9595
.set_key = mt76x02_set_key,

drivers/net/wireless/mediatek/mt76/mt76x0/usb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static const struct ieee80211_ops mt76x0u_ops = {
145145
.remove_interface = mt76x02_remove_interface,
146146
.config = mt76x0_config,
147147
.configure_filter = mt76x02_configure_filter,
148-
.bss_info_changed = mt76x0_bss_info_changed,
148+
.bss_info_changed = mt76x02_bss_info_changed,
149149
.sta_add = mt76x02_sta_add,
150150
.sta_remove = mt76x02_sta_remove,
151151
.set_key = mt76x02_set_key,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
158158
int mt76x02_get_txpower(struct ieee80211_hw *hw,
159159
struct ieee80211_vif *vif, int *dbm);
160160
void mt76x02_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);
161+
void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
162+
struct ieee80211_vif *vif,
163+
struct ieee80211_bss_conf *info, u32 changed);
161164

162165
extern const u16 mt76x02_beacon_offsets[16];
163166
void mt76x02_init_beacon_config(struct mt76x02_dev *dev);

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,4 +647,46 @@ void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
647647
}
648648
EXPORT_SYMBOL_GPL(mt76x02_init_beacon_config);
649649

650+
void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
651+
struct ieee80211_vif *vif,
652+
struct ieee80211_bss_conf *info,
653+
u32 changed)
654+
{
655+
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
656+
struct mt76x02_dev *dev = hw->priv;
657+
658+
mutex_lock(&dev->mt76.mutex);
659+
660+
if (changed & BSS_CHANGED_BSSID)
661+
mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
662+
663+
if (changed & BSS_CHANGED_BEACON_ENABLED) {
664+
tasklet_disable(&dev->pre_tbtt_tasklet);
665+
mt76x02_mac_set_beacon_enable(dev, mvif->idx,
666+
info->enable_beacon);
667+
tasklet_enable(&dev->pre_tbtt_tasklet);
668+
}
669+
670+
if (changed & BSS_CHANGED_BEACON_INT) {
671+
mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
672+
MT_BEACON_TIME_CFG_INTVAL,
673+
info->beacon_int << 4);
674+
dev->beacon_int = info->beacon_int;
675+
dev->tbtt_count = 0;
676+
}
677+
678+
if (changed & BSS_CHANGED_ERP_PREAMBLE)
679+
mt76x02_mac_set_short_preamble(dev, info->use_short_preamble);
680+
681+
if (changed & BSS_CHANGED_ERP_SLOT) {
682+
int slottime = info->use_short_slot ? 9 : 20;
683+
684+
dev->slottime = slottime;
685+
mt76x02_set_tx_ackto(dev);
686+
}
687+
688+
mutex_unlock(&dev->mt76.mutex);
689+
}
690+
EXPORT_SYMBOL_GPL(mt76x02_bss_info_changed);
691+
650692
MODULE_LICENSE("Dual BSD/GPL");

drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -127,43 +127,6 @@ mt76x2_config(struct ieee80211_hw *hw, u32 changed)
127127
return ret;
128128
}
129129

130-
static void
131-
mt76x2_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
132-
struct ieee80211_bss_conf *info, u32 changed)
133-
{
134-
struct mt76x02_dev *dev = hw->priv;
135-
struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
136-
137-
mutex_lock(&dev->mt76.mutex);
138-
139-
if (changed & BSS_CHANGED_BSSID)
140-
mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
141-
142-
if (changed & BSS_CHANGED_BEACON_INT) {
143-
mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
144-
MT_BEACON_TIME_CFG_INTVAL,
145-
info->beacon_int << 4);
146-
dev->beacon_int = info->beacon_int;
147-
dev->tbtt_count = 0;
148-
}
149-
150-
if (changed & BSS_CHANGED_BEACON_ENABLED) {
151-
tasklet_disable(&dev->pre_tbtt_tasklet);
152-
mt76x02_mac_set_beacon_enable(dev, mvif->idx,
153-
info->enable_beacon);
154-
tasklet_enable(&dev->pre_tbtt_tasklet);
155-
}
156-
157-
if (changed & BSS_CHANGED_ERP_SLOT) {
158-
int slottime = info->use_short_slot ? 9 : 20;
159-
160-
dev->slottime = slottime;
161-
mt76x02_set_tx_ackto(dev);
162-
}
163-
164-
mutex_unlock(&dev->mt76.mutex);
165-
}
166-
167130
static void
168131
mt76x2_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
169132
u32 queues, bool drop)
@@ -218,7 +181,7 @@ const struct ieee80211_ops mt76x2_ops = {
218181
.remove_interface = mt76x02_remove_interface,
219182
.config = mt76x2_config,
220183
.configure_filter = mt76x02_configure_filter,
221-
.bss_info_changed = mt76x2_bss_info_changed,
184+
.bss_info_changed = mt76x02_bss_info_changed,
222185
.sta_add = mt76x02_sta_add,
223186
.sta_remove = mt76x02_sta_remove,
224187
.set_key = mt76x02_set_key,

0 commit comments

Comments
 (0)