Skip to content

Commit

Permalink
mt76: move mt76x02_tx_complete in mt76x02-lib module
Browse files Browse the repository at this point in the history
Move mt76x02_tx_complete mt76x02-lib module in order to
be reused by mt76x0 drivers for irq unification.

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 3770c54 commit 9730290
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 70 deletions.
29 changes: 29 additions & 0 deletions mt76x02_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,32 @@ void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq)
}
}
EXPORT_SYMBOL_GPL(mt76x02_mac_poll_tx_status);

static void
mt76x02_mac_queue_txdone(struct mt76x02_dev *dev, struct sk_buff *skb,
void *txwi_ptr)
{
struct mt76x02_tx_info *txi = mt76x02_skb_tx_info(skb);
struct mt76x02_txwi *txwi = txwi_ptr;

mt76x02_mac_poll_tx_status(dev, false);

txi->tries = 0;
txi->jiffies = jiffies;
txi->wcid = txwi->wcid;
txi->pktid = txwi->pktid;
trace_mac_txdone_add(dev, txwi->wcid, txwi->pktid);
mt76x02_tx_complete(&dev->mt76, skb);
}

void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
struct mt76_queue_entry *e, bool flush)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);

if (e->txwi)
mt76x02_mac_queue_txdone(dev, e->skb, &e->txwi->txwi);
else
dev_kfree_skb_any(e->skb);
}
EXPORT_SYMBOL_GPL(mt76x02_tx_complete_skb);
19 changes: 19 additions & 0 deletions mt76x02_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ struct mt76x02_vif {
struct mt76_wcid group_wcid;
};

struct mt76x02_tx_info {
unsigned long jiffies;
u8 tries;

u8 wcid;
u8 pktid;
u8 retry;
};

DECLARE_EWMA(signal, 10, 8);

struct mt76x02_sta {
Expand Down Expand Up @@ -181,6 +190,14 @@ static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
return false;
}

static inline struct mt76x02_tx_info *
mt76x02_skb_tx_info(struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);

return (void *)info->status.status_driver_data;
}

void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq);
enum mt76x02_cipher_type
mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data);
Expand All @@ -206,4 +223,6 @@ void mt76x02_mac_write_txwi(struct mt76_dev *dev, struct mt76x02_txwi *txwi,
struct sk_buff *skb, struct mt76_wcid *wcid,
struct ieee80211_sta *sta, int len);
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);
#endif
22 changes: 22 additions & 0 deletions mt76x02_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ DECLARE_EVENT_CLASS(dev_evt,
TP_printk(DEV_PR_FMT, DEV_PR_ARG)
);

DECLARE_EVENT_CLASS(dev_txid_evt,
TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
TP_ARGS(dev, wcid, pktid),
TP_STRUCT__entry(
DEV_ENTRY
TXID_ENTRY
),
TP_fast_assign(
DEV_ASSIGN;
TXID_ASSIGN;
),
TP_printk(
DEV_PR_FMT TXID_PR_FMT,
DEV_PR_ARG, TXID_PR_ARG
)
);

DEFINE_EVENT(dev_txid_evt, mac_txdone_add,
TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
TP_ARGS(dev, wcid, pktid)
);

DEFINE_EVENT(dev_evt, mac_txstat_poll,
TP_PROTO(struct mt76x02_dev *dev),
TP_ARGS(dev)
Expand Down
17 changes: 0 additions & 17 deletions mt76x2/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ struct mt76x02_dev;
struct mt76x2_sta;
struct mt76x02_vif;

struct mt76x2_tx_info {
unsigned long jiffies;
u8 tries;

u8 wcid;
u8 pktid;
u8 retry;
};

static inline struct mt76x2_tx_info *
mt76x2_skb_tx_info(struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);

return (void *) info->status.status_driver_data;
}

int mt76x2_mac_start(struct mt76x02_dev *dev);
void mt76x2_mac_stop(struct mt76x02_dev *dev, bool force);
void mt76x2_mac_resume(struct mt76x02_dev *dev);
Expand Down
2 changes: 0 additions & 2 deletions mt76x2/mt76x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ void mt76x2_dma_cleanup(struct mt76x02_dev *dev);

void mt76x2_cleanup(struct mt76x02_dev *dev);

void mt76x2_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
struct mt76_queue_entry *e, bool flush);
void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val);

void mt76x2_pre_tbtt_tasklet(unsigned long arg);
Expand Down
2 changes: 1 addition & 1 deletion mt76x2/pci_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
.txwi_size = sizeof(struct mt76x02_txwi),
.update_survey = mt76x2_update_channel,
.tx_prepare_skb = mt76x02_tx_prepare_skb,
.tx_complete_skb = mt76x2_tx_complete_skb,
.tx_complete_skb = mt76x02_tx_complete_skb,
.rx_skb = mt76x02_queue_rx_skb,
.rx_poll_complete = mt76x2_rx_poll_complete,
.sta_ps = mt76x2_sta_ps,
Expand Down
28 changes: 0 additions & 28 deletions mt76x2/pci_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ void mt76x2_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr)
get_unaligned_le16(addr + 4));
}

static void
mt76x2_mac_queue_txdone(struct mt76x02_dev *dev, struct sk_buff *skb,
void *txwi_ptr)
{
struct mt76x2_tx_info *txi = mt76x2_skb_tx_info(skb);
struct mt76x02_txwi *txwi = txwi_ptr;

mt76x02_mac_poll_tx_status(dev, false);

txi->tries = 0;
txi->jiffies = jiffies;
txi->wcid = txwi->wcid;
txi->pktid = txwi->pktid;
trace_mac_txdone_add(dev, txwi->wcid, txwi->pktid);
mt76x02_tx_complete(&dev->mt76, skb);
}

void mt76x2_mac_process_tx_status_fifo(struct mt76x02_dev *dev)
{
struct mt76x02_tx_status stat;
Expand All @@ -54,17 +37,6 @@ void mt76x2_mac_process_tx_status_fifo(struct mt76x02_dev *dev)
mt76x02_send_tx_status(&dev->mt76, &stat, &update);
}

void mt76x2_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
struct mt76_queue_entry *e, bool flush)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);

if (e->txwi)
mt76x2_mac_queue_txdone(dev, e->skb, &e->txwi->txwi);
else
dev_kfree_skb_any(e->skb);
}

static int
mt76_write_beacon(struct mt76x02_dev *dev, int offset, struct sk_buff *skb)
{
Expand Down
22 changes: 0 additions & 22 deletions mt76x2/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,6 @@
#define TXID_PR_FMT " [%d:%d]"
#define TXID_PR_ARG __entry->wcid, __entry->pktid

DECLARE_EVENT_CLASS(dev_txid_evt,
TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
TP_ARGS(dev, wcid, pktid),
TP_STRUCT__entry(
DEV_ENTRY
TXID_ENTRY
),
TP_fast_assign(
DEV_ASSIGN;
TXID_ASSIGN;
),
TP_printk(
DEV_PR_FMT TXID_PR_FMT,
DEV_PR_ARG, TXID_PR_ARG
)
);

DEFINE_EVENT(dev_txid_evt, mac_txdone_add,
TP_PROTO(struct mt76x02_dev *dev, u8 wcid, u8 pktid),
TP_ARGS(dev, wcid, pktid)
);

TRACE_EVENT(dev_irq,
TP_PROTO(struct mt76x02_dev *dev, u32 val, u32 mask),

Expand Down

0 comments on commit 9730290

Please sign in to comment.