Skip to content

Commit

Permalink
mt76: mt76x02: move mac_reset_counter in mt76x02_lib module
Browse files Browse the repository at this point in the history
Unify mac_reset_counter routine and move it in mt76x02_lib module
since it is shared by all mt76x02 drivers (pci/usb)

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Sep 26, 2019
1 parent 63e8152 commit f3792b5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
12 changes: 1 addition & 11 deletions mt76x0/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,6 @@ static void mt76x0_init_mac_registers(struct mt76x02_dev *dev)
mt76_rmw(dev, MT_WMM_CTRL, 0x3ff, 0x201);
}

static void mt76x0_reset_counters(struct mt76x02_dev *dev)
{
mt76_rr(dev, MT_RX_STAT_0);
mt76_rr(dev, MT_RX_STAT_1);
mt76_rr(dev, MT_RX_STAT_2);
mt76_rr(dev, MT_TX_STA_0);
mt76_rr(dev, MT_TX_STA_1);
mt76_rr(dev, MT_TX_STA_2);
}

int mt76x0_mac_start(struct mt76x02_dev *dev)
{
mt76_wr(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX);
Expand Down Expand Up @@ -252,7 +242,7 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev)
for (i = 0; i < 256; i++)
mt76x02_mac_wcid_setup(dev, i, 0, NULL);

mt76x0_reset_counters(dev);
mt76x02_mac_reset_counters(dev);

ret = mt76x0_eeprom_init(dev);
if (ret)
Expand Down
21 changes: 21 additions & 0 deletions mt76x02_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@
#include "mt76x02.h"
#include "mt76x02_trace.h"

void mt76x02_mac_reset_counters(struct mt76x02_dev *dev)
{
int i;

mt76_rr(dev, MT_RX_STAT_0);
mt76_rr(dev, MT_RX_STAT_1);
mt76_rr(dev, MT_RX_STAT_2);
mt76_rr(dev, MT_TX_STA_0);
mt76_rr(dev, MT_TX_STA_1);
mt76_rr(dev, MT_TX_STA_2);

for (i = 0; i < 16; i++)
mt76_rr(dev, MT_TX_AGG_CNT(i));

for (i = 0; i < 16; i++)
mt76_rr(dev, MT_TX_STAT_FIFO);

memset(dev->aggr_stats, 0, sizeof(dev->aggr_stats));
}
EXPORT_SYMBOL_GPL(mt76x02_mac_reset_counters);

static enum mt76x02_cipher_type
mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
{
Expand Down
1 change: 1 addition & 0 deletions mt76x02_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
return false;
}

void mt76x02_mac_reset_counters(struct mt76x02_dev *dev);
void mt76x02_mac_set_short_preamble(struct mt76x02_dev *dev, bool enable);
int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx,
u8 key_idx, struct ieee80211_key_conf *key);
Expand Down
10 changes: 1 addition & 9 deletions mt76x2/pci_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,7 @@ int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)

int mt76x2_mac_start(struct mt76x02_dev *dev)
{
int i;

for (i = 0; i < 16; i++)
mt76_rr(dev, MT_TX_AGG_CNT(i));

for (i = 0; i < 16; i++)
mt76_rr(dev, MT_TX_STAT_FIFO);

memset(dev->aggr_stats, 0, sizeof(dev->aggr_stats));
mt76x02_mac_reset_counters(dev);
mt76x02_mac_start(dev);

return 0;
Expand Down
12 changes: 1 addition & 11 deletions mt76x2/usb_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
#include "mt76x2u.h"
#include "eeprom.h"

static void mt76x2u_mac_reset_counters(struct mt76x02_dev *dev)
{
mt76_rr(dev, MT_RX_STAT_0);
mt76_rr(dev, MT_RX_STAT_1);
mt76_rr(dev, MT_RX_STAT_2);
mt76_rr(dev, MT_TX_STA_0);
mt76_rr(dev, MT_TX_STA_1);
mt76_rr(dev, MT_TX_STA_2);
}

static void mt76x2u_mac_fixup_xtal(struct mt76x02_dev *dev)
{
s8 offset = 0;
Expand Down Expand Up @@ -104,7 +94,7 @@ int mt76x2u_mac_reset(struct mt76x02_dev *dev)

int mt76x2u_mac_start(struct mt76x02_dev *dev)
{
mt76x2u_mac_reset_counters(dev);
mt76x02_mac_reset_counters(dev);

mt76_wr(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_ENABLE_TX);
mt76x02_wait_for_wpdma(&dev->mt76, 1000);
Expand Down

0 comments on commit f3792b5

Please sign in to comment.