diff options
author | Michael Brown | 2015-02-06 02:29:11 +0100 |
---|---|---|
committer | Michael Brown | 2015-02-06 10:54:04 +0100 |
commit | 2d3f2b24465cfd270066e60e2daa36aa879ca89b (patch) | |
tree | dbfdead6233aaf5f42427bc8b476a31d45793f64 /src/drivers/net/ncm.h | |
parent | [usb] Report xHCI host controller events (diff) | |
download | ipxe-2d3f2b24465cfd270066e60e2daa36aa879ca89b.tar.gz ipxe-2d3f2b24465cfd270066e60e2daa36aa879ca89b.tar.xz ipxe-2d3f2b24465cfd270066e60e2daa36aa879ca89b.zip |
[ncm] Use large multi-packet buffers by default
Some devices have a very small number of internal buffers, and rely on
being able to pack multiple packets into each buffer. Using 2048-byte
buffers on such devices produces throughput of around 100Mbps. Using
a small number of much larger buffers (e.g. 32kB) increases the
throughput to around 780Mbps. (The full 1Gbps is not reached because
the high RTT induced by the use of multi-packet buffers causes us to
saturate our 256kB TCP window.)
Since allocation of large buffers is very likely to fail, allocate the
buffer set only once when the device is opened and recycle buffers
immediately after use. Received data is now always copied to
per-packet buffers.
If allocation of large buffers fails, fall back to allocating a larger
number of smaller buffers. This will give reduced performance, but
the device will at least still be functional.
Share code between the interrupt and bulk IN endpoint handlers, since
the buffer handling is now very similar.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/ncm.h')
-rw-r--r-- | src/drivers/net/ncm.h | 75 |
1 files changed, 50 insertions, 25 deletions
diff --git a/src/drivers/net/ncm.h b/src/drivers/net/ncm.h index 5f02b49e..b76902b9 100644 --- a/src/drivers/net/ncm.h +++ b/src/drivers/net/ncm.h @@ -74,12 +74,11 @@ struct ncm_set_ntb_input_size { uint32_t mtu; } __attribute__ (( packed )); -/** NTB input size - * - * This is a policy decision. 2048 is the minimum size which must be - * supported according to the specification. - */ -#define NCM_NTB_INPUT_SIZE 2048 +/** Minimum allowed NTB input size */ +#define NCM_MIN_NTB_INPUT_SIZE 2048 + +/** Maximum allowed NTB input size (16-bit) */ +#define NCM_MAX_NTB_INPUT_SIZE 65536 /** CDC-NCM transfer header (16-bit) */ struct ncm_transfer_header { @@ -140,6 +139,26 @@ struct ncm_ntb_header { struct ncm_datagram_descriptor desc[2]; } __attribute__ (( packed )); +/** A CDC-NCM receive ring */ +struct ncm_rx_ring { + /** USB endpoint */ + struct usb_endpoint ep; + /** I/O buffer size */ + size_t mtu; + /** Recycled buffer list */ + struct list_head list; +}; + +/** A CDC-NCM transmit ring */ +struct ncm_tx_ring { + /** USB endpoint */ + struct usb_endpoint ep; + /** Transmitted packet sequence number */ + uint16_t sequence; + /** Alignment padding required on transmitted packets */ + size_t padding; +}; + /** A CDC-NCM network device */ struct ncm_device { /** USB device */ @@ -154,33 +173,39 @@ struct ncm_device { /** Data interface */ unsigned int data; - /** Interrupt endpoint */ - struct usb_endpoint intr; - /** Bulk IN endpoint */ - struct usb_endpoint in; - /** Bulk OUT endpoint */ - struct usb_endpoint out; - - /** Recycled interrupt I/O buffers */ - struct list_head intrs; - /** Current bulk IN ring fill level */ - unsigned int fill; - /** Transmitted packet sequence number */ - uint16_t sequence; - /** Alignment padding required on transmitted packets */ - size_t padding; + /** Maximum supported NTB input size */ + size_t mtu; + + /** Interrupt ring */ + struct ncm_rx_ring intr; + /** Bulk IN ring */ + struct ncm_rx_ring in; + /** Bulk OUT ring */ + struct ncm_tx_ring out; }; -/** Bulk IN ring fill level +/** Bulk IN ring minimum buffer count + * + * This is a policy decision. + */ +#define NCM_IN_MIN_COUNT 3 + +/** Bulk IN ring minimum total buffer size + * + * This is a policy decision. + */ +#define NCM_IN_MIN_SIZE 16384 + +/** Bulk IN ring maximum total buffer size * * This is a policy decision. */ -#define NCM_IN_FILL 16 +#define NCM_IN_MAX_SIZE 131072 -/** Interrupt ring fill level +/** Interrupt ring buffer count * * This is a policy decision. */ -#define NCM_INTR_FILL 2 +#define NCM_INTR_COUNT 2 #endif /* _NCM_H */ |