Skip to content

Commit

Permalink
mt76x0: pci: add get_survey support
Browse files Browse the repository at this point in the history
Move mt76x02_update_channel routine in mt76x02-lib module in
order to be reused by mt76x0 driver adding get_survey support

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
Lorenzo Bianconi authored and Felix Fietkau committed Nov 30, 2018
1 parent b8defea commit 6250318
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
2 changes: 2 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x0/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ void mt76x0_mac_work(struct work_struct *work)
u32 sum, n;
int i, j, k;

mt76x02_update_channel(&dev->mt76);

/* Note: using MCU_RANDOM_READ is actually slower then reading all the
* registers by hand. MCU takes ca. 20ms to complete read of 24
* registers while reading them one by one will takes roughly
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x0/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)

mt76_set_channel(&dev->mt76);
ret = mt76x0_phy_set_channel(dev, chandef);

/* channel cycle counters read-and-clear */
mt76_rr(dev, MT_CH_IDLE);
mt76_rr(dev, MT_CH_BUSY);

mt76_txq_schedule_all(&dev->mt76);

return ret;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
.ampdu_action = mt76x02_ampdu_action,
.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
.wake_tx_queue = mt76_wake_tx_queue,
.get_survey = mt76_get_survey,
};

static int mt76x0e_register_device(struct mt76x02_dev *dev)
Expand Down Expand Up @@ -135,6 +136,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
static const struct mt76_driver_ops drv_ops = {
.txwi_size = sizeof(struct mt76x02_txwi),
.update_survey = mt76x02_update_channel,
.tx_prepare_skb = mt76x02_tx_prepare_skb,
.tx_complete_skb = mt76x02_tx_complete_skb,
.rx_skb = mt76x02_queue_rx_skb,
Expand Down
18 changes: 18 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,3 +735,21 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
dev_kfree_skb_any(e->skb);
}
EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb);

void mt76x02_update_channel(struct mt76_dev *mdev)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
struct mt76_channel_state *state;
u32 active, busy;

state = mt76_channel_state(&dev->mt76, dev->mt76.chandef.chan);

busy = mt76_rr(dev, MT_CH_BUSY);
active = busy + mt76_rr(dev, MT_CH_IDLE);

spin_lock_bh(&dev->mt76.cc_lock);
state->cc_busy += busy;
state->cc_active += active;
spin_unlock_bh(&dev->mt76.cc_lock);
}
EXPORT_SYMBOL_GPL(mt76x02_update_channel);
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,5 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq);
void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
struct mt76_queue_entry *e, bool flush);
void mt76x02_update_channel(struct mt76_dev *mdev);
#endif
2 changes: 0 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ void mt76x2_pre_tbtt_tasklet(unsigned long arg);

void mt76x2_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);

void mt76x2_update_channel(struct mt76_dev *mdev);

void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable);
void mt76x2_init_txpower(struct mt76x02_dev *dev,
struct ieee80211_supported_band *sband);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
{
static const struct mt76_driver_ops drv_ops = {
.txwi_size = sizeof(struct mt76x02_txwi),
.update_survey = mt76x2_update_channel,
.update_survey = mt76x02_update_channel,
.tx_prepare_skb = mt76x02_tx_prepare_skb,
.tx_complete_skb = mt76x02_tx_complete_skb,
.rx_skb = mt76x02_queue_rx_skb,
Expand Down
19 changes: 1 addition & 18 deletions drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,13 @@ void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev,
mt76x02_irq_disable(dev, MT_INT_PRE_TBTT | MT_INT_TBTT);
}

void mt76x2_update_channel(struct mt76_dev *mdev)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
struct mt76_channel_state *state;
u32 active, busy;

state = mt76_channel_state(&dev->mt76, dev->mt76.chandef.chan);

busy = mt76_rr(dev, MT_CH_BUSY);
active = busy + mt76_rr(dev, MT_CH_IDLE);

spin_lock_bh(&dev->mt76.cc_lock);
state->cc_busy += busy;
state->cc_active += active;
spin_unlock_bh(&dev->mt76.cc_lock);
}

void mt76x2_mac_work(struct work_struct *work)
{
struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
mac_work.work);
int i, idx;

mt76x2_update_channel(&dev->mt76);
mt76x02_update_channel(&dev->mt76);
for (i = 0, idx = 0; i < 16; i++) {
u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));

Expand Down

0 comments on commit 6250318

Please sign in to comment.