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

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
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -210,6 +210,8 @@ struct mt76_queue {
	u16 first;
	u16 head;
	u16 tail;
	u8 hw_idx;
	u8 ep;
	int ndesc;
	int queued;
	int buf_size;
@@ -217,7 +219,6 @@ struct mt76_queue {
	bool blocked;

	u8 buf_offset;
	u8 hw_idx;
	u16 flags;

	struct mtk_wed_device *wed;
@@ -1470,13 +1471,6 @@ static inline bool mt76u_urb_error(struct urb *urb)
	       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
mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
	       int timeout, int ep)
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
			    struct mt76_tx_info *tx_info)
{
	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;
	bool ampdu = IEEE80211_SKB_CB(tx_info->skb)->flags & IEEE80211_TX_CTL_AMPDU;
	enum mt76_qsel qsel;
+22 −13
Original line number Diff line number Diff line
@@ -872,9 +872,8 @@ mt76u_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q,
	if (err < 0)
		return err;

	mt76u_fill_bulk_urb(dev, USB_DIR_OUT, q2ep(q->hw_idx),
			    q->entry[idx].urb, mt76u_complete_tx,
			    &q->entry[idx]);
	mt76u_fill_bulk_urb(dev, USB_DIR_OUT, q->ep, q->entry[idx].urb,
			    mt76u_complete_tx, &q->entry[idx]);

	q->head = (q->head + 1) % q->ndesc;
	q->entry[idx].skb = tx_info.skb;
@@ -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[] = {
			/* ac to lmac mapping */
			[IEEE80211_AC_BK] = 0,
@@ -917,13 +920,20 @@ static u8 mt76u_ac_to_hwq(struct mt76_dev *dev, u8 ac)
			[IEEE80211_AC_VO] = 4,
		};

		if (WARN_ON(ac >= ARRAY_SIZE(lmac_queue_map)))
			return 1; /* BE */

		return lmac_queue_map[ac];
		q->hw_idx = lmac_queue_map[ac];
		q->ep = q->hw_idx + 1;
		break;
	}
	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)
@@ -939,8 +949,7 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
			return -ENOMEM;

		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;

		q->entry = devm_kcalloc(dev->dev,