aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/octeon/ethernet-defines.h
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2009-06-23 16:20:56 -0700
committerRalf Baechle <ralf@linux-mips.org>2009-06-24 18:34:41 +0100
commita620c1632629b42369e78448acc7b384fe1faf48 (patch)
tree3318683c03abb4ca45307c7df0019f74bcba3b13 /drivers/staging/octeon/ethernet-defines.h
parentf696a10838ffab85e5bc07e7cff0d0e1870a30d7 (diff)
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>
Diffstat (limited to 'drivers/staging/octeon/ethernet-defines.h')
-rw-r--r--drivers/staging/octeon/ethernet-defines.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h
index 8f7374e7664..f13131b03c3 100644
--- a/drivers/staging/octeon/ethernet-defines.h
+++ b/drivers/staging/octeon/ethernet-defines.h
@@ -117,6 +117,8 @@
/* Maximum number of packets to process per interrupt. */
#define MAX_RX_PACKETS 120
+/* Maximum number of SKBs to try to free per xmit packet. */
+#define MAX_SKB_TO_FREE 10
#define MAX_OUT_QUEUE_DEPTH 1000
#ifndef CONFIG_SMP