Commit b0e0e20d authored by Paul Barker's avatar Paul Barker Committed by Paolo Abeni

net: ravb: Align poll function with NAPI docs

Align ravb_poll() with the documentation in
`Documentation/networking/kapi.rst` and
`Documentation/networking/napi.rst`.

The documentation says that we should prefer napi_complete_done() over
napi_complete(), and using the former allows us to properly support busy
polling. We should ensure that napi_complete_done() is only called if
the work budget has not been exhausted, and we should only re-arm
interrupts if it returns true.
Signed-off-by: default avatarPaul Barker <paul.barker.ct@bp.renesas.com>
Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 118e640a
...@@ -1341,23 +1341,19 @@ static int ravb_poll(struct napi_struct *napi, int budget) ...@@ -1341,23 +1341,19 @@ static int ravb_poll(struct napi_struct *napi, int budget)
if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors) if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors)
ndev->stats.rx_fifo_errors = priv->rx_fifo_errors; ndev->stats.rx_fifo_errors = priv->rx_fifo_errors;
if (work_done == budget) if (work_done < budget && napi_complete_done(napi, work_done)) {
goto out; /* Re-enable RX/TX interrupts */
spin_lock_irqsave(&priv->lock, flags);
napi_complete(napi); if (!info->irq_en_dis) {
ravb_modify(ndev, RIC0, mask, mask);
/* Re-enable RX/TX interrupts */ ravb_modify(ndev, TIC, mask, mask);
spin_lock_irqsave(&priv->lock, flags); } else {
if (!info->irq_en_dis) { ravb_write(ndev, mask, RIE0);
ravb_modify(ndev, RIC0, mask, mask); ravb_write(ndev, mask, TIE);
ravb_modify(ndev, TIC, mask, mask); }
} else { spin_unlock_irqrestore(&priv->lock, flags);
ravb_write(ndev, mask, RIE0);
ravb_write(ndev, mask, TIE);
} }
spin_unlock_irqrestore(&priv->lock, flags);
out:
return work_done; return work_done;
} }
......
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