linux/drivers/staging/octeon
David Daney a620c16326 Staging: octeon-ethernet: Fix race freeing transmit buffers.
The existing code had the following race:

Thread-1                       Thread-2

inc/read in_use
                               inc/read in_use
inc tx_free_list[qos].len
                               inc tx_free_list[qos].len

The actual in_use value was incremented twice, but thread-1 is going
to free memory based on its stale value, and will free one too many
times.  The result is that memory is freed back to the kernel while
its packet is still in the transmit buffer.  If the memory is
overwritten before it is transmitted, the hardware will put a valid
checksum on it and send it out (just like it does with good packets).
If by chance the TCP flags are clobbered but not the addresses or
ports, the result can be a broken TCP stream.

The fix is to track the number of freed packets in a single location
(a Fetch-and-Add Unit register).  That way it can never get out of sync
with itself.

We try to free up to MAX_SKB_TO_FREE (currently 10) buffers at a time.
If fewer are available we adjust the free count with the difference.
The action of claiming buffers to free is atomic so two threads cannot
claim the same buffers.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2009-06-24 18:34:41 +01:00
..
cvmx-address.h
cvmx-asxx-defs.h
cvmx-cmd-queue.c
cvmx-cmd-queue.h
cvmx-config.h
cvmx-dbg-defs.h
cvmx-fau.h
cvmx-fpa-defs.h
cvmx-fpa.c
cvmx-fpa.h
cvmx-gmxx-defs.h
cvmx-helper-board.c
cvmx-helper-board.h
cvmx-helper-fpa.c
cvmx-helper-fpa.h
cvmx-helper-loop.c
cvmx-helper-loop.h
cvmx-helper-npi.c
cvmx-helper-npi.h
cvmx-helper-rgmii.c
cvmx-helper-rgmii.h
cvmx-helper-sgmii.c
cvmx-helper-sgmii.h
cvmx-helper-spi.c
cvmx-helper-spi.h
cvmx-helper-util.c
cvmx-helper-util.h
cvmx-helper-xaui.c
cvmx-helper-xaui.h
cvmx-helper.c
cvmx-helper.h
cvmx-interrupt-decodes.c
cvmx-interrupt-rsl.c
cvmx-ipd.h
cvmx-mdio.h
cvmx-packet.h
cvmx-pcsx-defs.h
cvmx-pcsxx-defs.h
cvmx-pip-defs.h
cvmx-pip.h
cvmx-pko-defs.h
cvmx-pko.c
cvmx-pko.h
cvmx-pow.h
cvmx-scratch.h
cvmx-smix-defs.h
cvmx-spi.c
cvmx-spi.h
cvmx-spxx-defs.h
cvmx-srxx-defs.h
cvmx-stxx-defs.h
cvmx-wqe.h
ethernet-defines.h Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
ethernet-mdio.c
ethernet-mdio.h
ethernet-mem.c
ethernet-mem.h
ethernet-proc.c
ethernet-proc.h
ethernet-rgmii.c
ethernet-rx.c
ethernet-rx.h
ethernet-sgmii.c
ethernet-spi.c
ethernet-tx.c Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
ethernet-tx.h Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
ethernet-util.h
ethernet-xaui.c
ethernet.c Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
Kconfig
Makefile
octeon-ethernet.h