Commit 84072889 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt76u: add mt76u_process_rx_queue utility routine

Introduce mt76u_process_rx_queue routine to process rx hw queue.
This is a preliminary patch to support new devices (e.g. mt7663u) that
rely on a hw queue for mcu messages
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent f4021e1f
......@@ -468,9 +468,9 @@ mt76u_build_rx_skb(void *data, int len, int buf_size)
}
static int
mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb)
mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb,
int buf_size)
{
struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
u8 *data = urb->num_sgs ? sg_virt(&urb->sg[0]) : urb->transfer_buffer;
int data_len = urb->num_sgs ? urb->sg[0].length : urb->actual_length;
int len, nsgs = 1;
......@@ -484,7 +484,7 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb)
return 0;
data_len = min_t(int, len, data_len - MT_DMA_HDR_LEN);
skb = mt76u_build_rx_skb(data, data_len, q->buf_size);
skb = mt76u_build_rx_skb(data, data_len, buf_size);
if (!skb)
return 0;
......@@ -493,8 +493,8 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb)
data_len = min_t(int, len, urb->sg[nsgs].length);
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
sg_page(&urb->sg[nsgs]),
urb->sg[nsgs].offset,
data_len, q->buf_size);
urb->sg[nsgs].offset, data_len,
buf_size);
len -= data_len;
nsgs++;
}
......@@ -545,20 +545,19 @@ mt76u_submit_rx_buf(struct mt76_dev *dev, struct urb *urb)
return usb_submit_urb(urb, GFP_ATOMIC);
}
static void mt76u_rx_tasklet(unsigned long data)
static void
mt76u_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q)
{
struct mt76_dev *dev = (struct mt76_dev *)data;
int qid = q - &dev->q_rx[MT_RXQ_MAIN];
struct urb *urb;
int err, count;
rcu_read_lock();
while (true) {
urb = mt76u_get_next_rx_entry(dev);
if (!urb)
break;
count = mt76u_process_rx_entry(dev, urb);
count = mt76u_process_rx_entry(dev, urb, q->buf_size);
if (count > 0) {
err = mt76u_refill_rx(dev, urb, count, GFP_ATOMIC);
if (err < 0)
......@@ -566,8 +565,17 @@ static void mt76u_rx_tasklet(unsigned long data)
}
mt76u_submit_rx_buf(dev, urb);
}
mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL);
if (qid == MT_RXQ_MAIN)
mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL);
}
static void mt76u_rx_tasklet(unsigned long data)
{
struct mt76_dev *dev = (struct mt76_dev *)data;
struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
rcu_read_lock();
mt76u_process_rx_queue(dev, q);
rcu_read_unlock();
}
......
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