From: Michael Brown Date: Tue, 22 Apr 2014 12:12:54 +0000 (+0100) Subject: [intel] Avoid completely filling the TX descriptor ring X-Git-Tag: v1.20.1~1229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27884298a39553aa0b9b336493c988cf54d73f77;p=thirdparty%2Fipxe.git [intel] Avoid completely filling the TX descriptor ring It is unclear from the datasheets whether or not the TX ring can be completely filled (i.e. whether writing the tail value as equal to the current head value will cause the ring to be treated as completely full or completely empty). It is very plausible that this edge case could differ in behaviour between real hardware and the many implementations of an emulated Intel NIC found in various virtual machines. Err on the side of caution and always leave at least one ring entry empty. Signed-off-by: Michael Brown --- diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index 04e86dd40..f56012634 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -593,7 +593,7 @@ int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) { physaddr_t address; /* Get next transmit descriptor */ - if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_NUM_TX_DESC ) { + if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_TX_FILL ) { DBGC ( intel, "INTEL %p out of transmit descriptors\n", intel ); return -ENOBUFS; } diff --git a/src/drivers/net/intel.h b/src/drivers/net/intel.h index 20b4255e1..8ce9ea973 100644 --- a/src/drivers/net/intel.h +++ b/src/drivers/net/intel.h @@ -156,6 +156,9 @@ enum intel_descriptor_status { */ #define INTEL_NUM_TX_DESC 16 +/** Transmit descriptor ring maximum fill level */ +#define INTEL_TX_FILL ( INTEL_NUM_TX_DESC - 1 ) + /** Receive/Transmit Descriptor Base Address Low (offset) */ #define INTEL_xDBAL 0x00