mt76: mt76u: use mt76_queue as mt76u_complete_rx context

In order to reuse mt76u_complete_rx for both data and mcu rx queue, rely
on mt76_queue as urb context in mt76u_complete_rx. Moreover set usb rx
endoint according to rx queue in mt76u_submit_rx_buf. This is a
preliminary patch to add mt7663u support

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Lorenzo Bianconi 2020-01-15 11:58:45 +01:00 committed by Felix Fietkau
parent ab221b207b
commit 2fe6a5564d

View File

@ -506,8 +506,8 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb,
static void mt76u_complete_rx(struct urb *urb)
{
struct mt76_dev *dev = urb->context;
struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
struct mt76_dev *dev = dev_get_drvdata(&urb->dev->dev);
struct mt76_queue *q = urb->context;
unsigned long flags;
trace_rx_urb(dev, urb);
@ -537,10 +537,13 @@ static void mt76u_complete_rx(struct urb *urb)
}
static int
mt76u_submit_rx_buf(struct mt76_dev *dev, struct urb *urb)
mt76u_submit_rx_buf(struct mt76_dev *dev, enum mt76_rxq_id qid,
struct urb *urb)
{
mt76u_fill_bulk_urb(dev, USB_DIR_IN, MT_EP_IN_PKT_RX, urb,
mt76u_complete_rx, dev);
int ep = qid == MT_RXQ_MAIN ? MT_EP_IN_PKT_RX : MT_EP_IN_CMD_RESP;
mt76u_fill_bulk_urb(dev, USB_DIR_IN, ep, urb,
mt76u_complete_rx, &dev->q_rx[qid]);
trace_submit_urb(dev, urb);
return usb_submit_urb(urb, GFP_ATOMIC);
@ -564,7 +567,7 @@ mt76u_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q)
if (err < 0)
break;
}
mt76u_submit_rx_buf(dev, urb);
mt76u_submit_rx_buf(dev, qid, urb);
}
if (qid == MT_RXQ_MAIN)
mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL);
@ -588,7 +591,7 @@ static int mt76u_submit_rx_buffers(struct mt76_dev *dev)
spin_lock_irqsave(&q->lock, flags);
for (i = 0; i < q->ndesc; i++) {
err = mt76u_submit_rx_buf(dev, q->entry[i].urb);
err = mt76u_submit_rx_buf(dev, MT_RXQ_MAIN, q->entry[i].urb);
if (err < 0)
break;
}