Commit fbe50d9a authored by Felix Fietkau's avatar Felix Fietkau

mt76: allow drivers to drop rx packets early

This can be used to free received events without allocating an extra skb
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 5360522a
...@@ -572,9 +572,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) ...@@ -572,9 +572,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
if (data_len < len + q->buf_offset) { if (data_len < len + q->buf_offset) {
dev_kfree_skb(q->rx_head); dev_kfree_skb(q->rx_head);
q->rx_head = NULL; q->rx_head = NULL;
goto free_frag;
skb_free_frag(data);
continue;
} }
if (q->rx_head) { if (q->rx_head) {
...@@ -582,11 +580,14 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) ...@@ -582,11 +580,14 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
continue; continue;
} }
if (!more && dev->drv->rx_check &&
!(dev->drv->rx_check(dev, data, len)))
goto free_frag;
skb = build_skb(data, q->buf_size); skb = build_skb(data, q->buf_size);
if (!skb) { if (!skb)
skb_free_frag(data); goto free_frag;
continue;
}
skb_reserve(skb, q->buf_offset); skb_reserve(skb, q->buf_offset);
if (q == &dev->q_rx[MT_RXQ_MCU]) { if (q == &dev->q_rx[MT_RXQ_MCU]) {
...@@ -603,6 +604,10 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) ...@@ -603,6 +604,10 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
} }
dev->drv->rx_skb(dev, q - dev->q_rx, skb); dev->drv->rx_skb(dev, q - dev->q_rx, skb);
continue;
free_frag:
skb_free_frag(data);
} }
mt76_dma_rx_fill(dev, q); mt76_dma_rx_fill(dev, q);
......
...@@ -373,6 +373,8 @@ struct mt76_driver_ops { ...@@ -373,6 +373,8 @@ struct mt76_driver_ops {
bool (*tx_status_data)(struct mt76_dev *dev, u8 *update); bool (*tx_status_data)(struct mt76_dev *dev, u8 *update);
bool (*rx_check)(struct mt76_dev *dev, void *data, int len);
void (*rx_skb)(struct mt76_dev *dev, enum mt76_rxq_id q, void (*rx_skb)(struct mt76_dev *dev, enum mt76_rxq_id q,
struct sk_buff *skb); struct sk_buff *skb);
......
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