Commit 5304bf3b authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

wifi: mt76: usb: store usb endpoint in mt76_queue

Store usb endpoint in mt76_queue structure and rework q2ep routine.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarDeren Wu <deren.wu@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 375c5eeb
...@@ -210,6 +210,8 @@ struct mt76_queue { ...@@ -210,6 +210,8 @@ struct mt76_queue {
u16 first; u16 first;
u16 head; u16 head;
u16 tail; u16 tail;
u8 hw_idx;
u8 ep;
int ndesc; int ndesc;
int queued; int queued;
int buf_size; int buf_size;
...@@ -217,7 +219,6 @@ struct mt76_queue { ...@@ -217,7 +219,6 @@ struct mt76_queue {
bool blocked; bool blocked;
u8 buf_offset; u8 buf_offset;
u8 hw_idx;
u16 flags; u16 flags;
struct mtk_wed_device *wed; struct mtk_wed_device *wed;
...@@ -1470,13 +1471,6 @@ static inline bool mt76u_urb_error(struct urb *urb) ...@@ -1470,13 +1471,6 @@ static inline bool mt76u_urb_error(struct urb *urb)
urb->status != -ENOENT; urb->status != -ENOENT;
} }
/* Map hardware queues to usb endpoints */
static inline u8 q2ep(u8 qid)
{
/* TODO: take management packets to queue 5 */
return qid + 1;
}
static inline int static inline int
mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len, mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
int timeout, int ep) int timeout, int ep)
......
...@@ -67,7 +67,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data, ...@@ -67,7 +67,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
struct mt76_tx_info *tx_info) struct mt76_tx_info *tx_info)
{ {
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
int pid, len = tx_info->skb->len, ep = q2ep(dev->mphy.q_tx[qid]->hw_idx); int pid, len = tx_info->skb->len, ep = dev->mphy.q_tx[qid]->ep;
struct mt76x02_txwi *txwi; struct mt76x02_txwi *txwi;
bool ampdu = IEEE80211_SKB_CB(tx_info->skb)->flags & IEEE80211_TX_CTL_AMPDU; bool ampdu = IEEE80211_SKB_CB(tx_info->skb)->flags & IEEE80211_TX_CTL_AMPDU;
enum mt76_qsel qsel; enum mt76_qsel qsel;
......
...@@ -872,9 +872,8 @@ mt76u_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, ...@@ -872,9 +872,8 @@ mt76u_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
if (err < 0) if (err < 0)
return err; return err;
mt76u_fill_bulk_urb(dev, USB_DIR_OUT, q2ep(q->hw_idx), mt76u_fill_bulk_urb(dev, USB_DIR_OUT, q->ep, q->entry[idx].urb,
q->entry[idx].urb, mt76u_complete_tx, mt76u_complete_tx, &q->entry[idx]);
&q->entry[idx]);
q->head = (q->head + 1) % q->ndesc; q->head = (q->head + 1) % q->ndesc;
q->entry[idx].skb = tx_info.skb; q->entry[idx].skb = tx_info.skb;
...@@ -906,9 +905,13 @@ static void mt76u_tx_kick(struct mt76_dev *dev, struct mt76_queue *q) ...@@ -906,9 +905,13 @@ static void mt76u_tx_kick(struct mt76_dev *dev, struct mt76_queue *q)
} }
} }
static u8 mt76u_ac_to_hwq(struct mt76_dev *dev, u8 ac) static void
mt76u_ac_to_hwq(struct mt76_dev *dev, struct mt76_queue *q, u8 qid)
{ {
if (mt76_chip(dev) == 0x7663) { u8 ac = qid < IEEE80211_NUM_ACS ? qid : IEEE80211_AC_BE;
switch (mt76_chip(dev)) {
case 0x7663: {
static const u8 lmac_queue_map[] = { static const u8 lmac_queue_map[] = {
/* ac to lmac mapping */ /* ac to lmac mapping */
[IEEE80211_AC_BK] = 0, [IEEE80211_AC_BK] = 0,
...@@ -917,13 +920,20 @@ static u8 mt76u_ac_to_hwq(struct mt76_dev *dev, u8 ac) ...@@ -917,13 +920,20 @@ static u8 mt76u_ac_to_hwq(struct mt76_dev *dev, u8 ac)
[IEEE80211_AC_VO] = 4, [IEEE80211_AC_VO] = 4,
}; };
if (WARN_ON(ac >= ARRAY_SIZE(lmac_queue_map))) q->hw_idx = lmac_queue_map[ac];
return 1; /* BE */ q->ep = q->hw_idx + 1;
break;
return lmac_queue_map[ac]; }
case 0x7961:
case 0x7925:
q->hw_idx = mt76_ac_to_hwq(ac);
q->ep = qid == MT_TXQ_PSD ? MT_EP_OUT_HCCA : q->hw_idx + 1;
break;
default:
q->hw_idx = mt76_ac_to_hwq(ac);
q->ep = q->hw_idx + 1;
break;
} }
return mt76_ac_to_hwq(ac);
} }
static int mt76u_alloc_tx(struct mt76_dev *dev) static int mt76u_alloc_tx(struct mt76_dev *dev)
...@@ -939,8 +949,7 @@ static int mt76u_alloc_tx(struct mt76_dev *dev) ...@@ -939,8 +949,7 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&q->lock); spin_lock_init(&q->lock);
q->hw_idx = mt76u_ac_to_hwq(dev, i); mt76u_ac_to_hwq(dev, q, i);
dev->phy.q_tx[i] = q; dev->phy.q_tx[i] = q;
q->entry = devm_kcalloc(dev->dev, q->entry = devm_kcalloc(dev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment