Skip to content

Commit

Permalink
mt76: move tx_tasklet management in mt76x02-lib moudle
Browse files Browse the repository at this point in the history
Move tx_tasklet management in mt76x02_mmio.c in order to
be reused by mt76x0 driver and remove duplicated code

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Oct 5, 2018
1 parent 99e0486 commit 3d2cfe3
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 64 deletions.
2 changes: 1 addition & 1 deletion mt76x0/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static void mt76x0e_cleanup(struct mt76x02_dev *dev)
clear_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
mt76x0_chip_onoff(dev, false, false);
mt76x0e_stop_hw(dev);
mt76_dma_cleanup(&dev->mt76);
mt76x02_dma_cleanup(dev);
mt76x02_mcu_cleanup(&dev->mt76);
}

Expand Down
1 change: 1 addition & 0 deletions mt76x02_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ mt76x02_wait_for_wpdma(struct mt76_dev *dev, int timeout)

int mt76x02_dma_init(struct mt76x02_dev *dev);
void mt76x02_dma_disable(struct mt76x02_dev *dev);
void mt76x02_dma_cleanup(struct mt76x02_dev *dev);

#endif /* __MT76x02_DMA_H */
42 changes: 41 additions & 1 deletion mt76x02_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,49 @@ mt76x02_init_rx_queue(struct mt76x02_dev *dev, struct mt76_queue *q,
return 0;
}

static void mt76x02_process_tx_status_fifo(struct mt76x02_dev *dev)
{
struct mt76x02_tx_status stat;
u8 update = 1;

while (kfifo_get(&dev->txstatus_fifo, &stat))
mt76x02_send_tx_status(&dev->mt76, &stat, &update);
}

static void mt76x02_tx_tasklet(unsigned long data)
{
struct mt76x02_dev *dev = (struct mt76x02_dev *)data;
int i;

mt76x02_process_tx_status_fifo(dev);

for (i = MT_TXQ_MCU; i >= 0; i--)
mt76_queue_tx_cleanup(dev, i, false);

mt76x02_mac_poll_tx_status(dev, false);
mt76x02_irq_enable(dev, MT_INT_TX_DONE_ALL);
}

int mt76x02_dma_init(struct mt76x02_dev *dev)
{
struct mt76_txwi_cache __maybe_unused *t;
int i, ret, fifo_size;
struct mt76_queue *q;
int i, ret;
void *status_fifo;

BUILD_BUG_ON(sizeof(t->txwi) < sizeof(struct mt76x02_txwi));
BUILD_BUG_ON(sizeof(struct mt76x02_rxwi) > MT_RX_HEADROOM);

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

tasklet_init(&dev->tx_tasklet, mt76x02_tx_tasklet, (unsigned long) dev);
kfifo_init(&dev->txstatus_fifo, status_fifo, fifo_size);

mt76_dma_attach(&dev->mt76);

mt76_wr(dev, MT_WPDMA_RST_IDX, ~0);

for (i = 0; i < IEEE80211_NUM_ACS; i++) {
Expand Down Expand Up @@ -132,6 +165,13 @@ static void mt76x02_dma_enable(struct mt76x02_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76x02_dma_enable);

void mt76x02_dma_cleanup(struct mt76x02_dev *dev)
{
tasklet_kill(&dev->tx_tasklet);
mt76_dma_cleanup(&dev->mt76);
}
EXPORT_SYMBOL_GPL(mt76x02_dma_cleanup);

void mt76x02_dma_disable(struct mt76x02_dev *dev)
{
u32 val = mt76_rr(dev, MT_WPDMA_GLO_CFG);
Expand Down
2 changes: 1 addition & 1 deletion mt76x2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mt76x2-common-y := \
eeprom.o mac.o init.o phy.o debugfs.o mcu.o

mt76x2e-y := \
pci.o pci_dma.o pci_main.o pci_init.o pci_tx.o \
pci.o pci_main.o pci_init.o pci_tx.o \
pci_core.o pci_mac.o pci_mcu.o pci_phy.o \
pci_dfs.o pci_trace.o

Expand Down
2 changes: 0 additions & 2 deletions mt76x2/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ int mt76x2_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
struct sk_buff *skb);
void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx, bool val);

void mt76x2_mac_process_tx_status_fifo(struct mt76x02_dev *dev);

void mt76x2_mac_work(struct work_struct *work);

#endif
3 changes: 0 additions & 3 deletions mt76x2/mt76x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ int mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw,
int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level,
u8 channel);

void mt76x2_tx_tasklet(unsigned long data);
void mt76x2_dma_cleanup(struct mt76x02_dev *dev);

void mt76x2_cleanup(struct mt76x02_dev *dev);

void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val);
Expand Down
37 changes: 0 additions & 37 deletions mt76x2/pci_dma.c

This file was deleted.

11 changes: 1 addition & 10 deletions mt76x2/pci_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void mt76x2_cleanup(struct mt76x02_dev *dev)
tasklet_disable(&dev->dfs_pd.dfs_tasklet);
tasklet_disable(&dev->pre_tbtt_tasklet);
mt76x2_stop_hardware(dev);
mt76x2_dma_cleanup(dev);
mt76x02_dma_cleanup(dev);
mt76x02_mcu_cleanup(&dev->mt76);
}

Expand Down Expand Up @@ -464,17 +464,8 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
{
struct ieee80211_hw *hw = mt76_hw(dev);
struct wiphy *wiphy = hw->wiphy;
void *status_fifo;
int fifo_size;
int i, ret;

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

tasklet_init(&dev->tx_tasklet, mt76x2_tx_tasklet, (unsigned long)dev);
kfifo_init(&dev->txstatus_fifo, status_fifo, fifo_size);
INIT_DELAYED_WORK(&dev->cal_work, mt76x2_phy_calibrate);
INIT_DELAYED_WORK(&dev->mac_work, mt76x2_mac_work);

Expand Down
9 changes: 0 additions & 9 deletions mt76x2/pci_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ void mt76x2_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
get_unaligned_le16(addr + 4));
}

void mt76x2_mac_process_tx_status_fifo(struct mt76x02_dev *dev)
{
struct mt76x02_tx_status stat;
u8 update = 1;

while (kfifo_get(&dev->txstatus_fifo, &stat))
mt76x02_send_tx_status(&dev->mt76, &stat, &update);
}

static int
mt76_write_beacon(struct mt76x02_dev *dev, int offset, struct sk_buff *skb)
{
Expand Down

0 comments on commit 3d2cfe3

Please sign in to comment.