net: macb: use NAPI for TX completion path
authorRobert Hancock <robert.hancock@calian.com>
Mon, 9 May 2022 19:46:35 +0000 (13:46 -0600)
committerJakub Kicinski <kuba@kernel.org>
Wed, 11 May 2022 23:14:13 +0000 (16:14 -0700)
commit138badbc21a0113ce783270c426210d6451da5d1
tree7949bca39c9a6892f92ca768986cf6756c5bcc21
parent1900e30d0ef74755213811cc23079b1be51298fe
net: macb: use NAPI for TX completion path

This driver was using the TX IRQ handler to perform all TX completion
tasks. Under heavy TX network load, this can cause significant irqs-off
latencies (found to be in the hundreds of microseconds using ftrace).
This can cause other issues, such as overrunning serial UART FIFOs when
using high baud rates with limited UART FIFO sizes.

Switch to using a NAPI poll handler to perform the TX completion work
to get this out of hard IRQ context and avoid the IRQ latency impact. A
separate NAPI instance is used for TX and RX to avoid checking the other
ring's state unnecessarily when doing the poll, and so that the NAPI
budget handling can work for both TX and RX packets.

A new per-queue tx_ptr_lock spinlock has been added to avoid using the
main device lock (with IRQs needing to be disabled) across the entire TX
mapping operation, and also to protect the TX queue pointers from
concurrent access between the TX start and TX poll operations.

The TX Used Bit Read interrupt (TXUBR) handling also needs to be moved into
the TX NAPI poll handler to maintain the proper order of operations. A flag
is used to notify the poll handler that a UBR condition needs to be
handled. The macb_tx_restart handler has had some locking added for global
register access, since this could now potentially happen concurrently on
different queues.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cadence/macb.h
drivers/net/ethernet/cadence/macb_main.c