mt76: move tx_tasklet management in mt76x02-lib moudle
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 <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
a23fde09c2
commit
53d20fdb46
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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++) {
|
||||
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mt76x2.h"
|
||||
|
||||
void mt76x2_tx_tasklet(unsigned long data)
|
||||
{
|
||||
struct mt76x02_dev *dev = (struct mt76x02_dev *) data;
|
||||
int i;
|
||||
|
||||
mt76x2_mac_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);
|
||||
}
|
||||
|
||||
void mt76x2_dma_cleanup(struct mt76x02_dev *dev)
|
||||
{
|
||||
tasklet_kill(&dev->tx_tasklet);
|
||||
mt76_dma_cleanup(&dev->mt76);
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user