summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarybchik <arybchik@FreeBSD.org>2015-03-25 10:59:24 +0000
committerarybchik <arybchik@FreeBSD.org>2015-03-25 10:59:24 +0000
commitdb246d0ceeaaebb15869a8e06f8b2f4b2d7306f6 (patch)
tree9eba9d99135baa4462163778652bac35cc28bc0a
parent4f836db713790f3820d88bca7dbf84eeb70d17fc (diff)
downloadFreeBSD-src-db246d0ceeaaebb15869a8e06f8b2f4b2d7306f6.zip
FreeBSD-src-db246d0ceeaaebb15869a8e06f8b2f4b2d7306f6.tar.gz
MFC: 279094
sfxge: more accurate calculation of maximum number of TSO segments Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor)
-rw-r--r--sys/dev/sfxge/sfxge_tx.c6
-rw-r--r--sys/dev/sfxge/sfxge_tx.h12
2 files changed, 14 insertions, 4 deletions
diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c
index c1e09a4..63dd8d7 100644
--- a/sys/dev/sfxge/sfxge_tx.c
+++ b/sys/dev/sfxge/sfxge_tx.c
@@ -72,10 +72,10 @@ __FBSDID("$FreeBSD$");
* maximum mbuf length we might need more than a ring-ful of
* descriptors, but this should not happen in practice except
* due to deliberate attack. In that case we will truncate
- * the output at a packet boundary. Allow for a reasonable
- * minimum MSS of 512.
+ * the output at a packet boundary.
*/
-#define SFXGE_TSO_MAX_DESC ((65535 / 512) * 2 + SFXGE_TX_MAPPING_MAX_SEG - 1)
+#define SFXGE_TSO_MAX_DESC \
+ (SFXGE_TSO_MAX_SEGS * 2 + SFXGE_TX_MAPPING_MAX_SEG - 1)
#define SFXGE_TXQ_BLOCK_LEVEL(_entries) ((_entries) - SFXGE_TSO_MAX_DESC)
#ifdef SFXGE_HAVE_MQ
diff --git a/sys/dev/sfxge/sfxge_tx.h b/sys/dev/sfxge/sfxge_tx.h
index b430288..3965ffd 100644
--- a/sys/dev/sfxge/sfxge_tx.h
+++ b/sys/dev/sfxge/sfxge_tx.h
@@ -36,12 +36,22 @@
#include <netinet/ip.h>
#include <netinet/tcp.h>
+/* Maximum size of TSO packet */
+#define SFXGE_TSO_MAX_SIZE (65535)
+
+/*
+ * Maximum number of segments to be created for a TSO packet.
+ * Allow for a reasonable minimum MSS of 512.
+ */
+#define SFXGE_TSO_MAX_SEGS howmany(SFXGE_TSO_MAX_SIZE, 512)
+
/* Maximum number of DMA segments needed to map an mbuf chain. With
* TSO, the mbuf length may be just over 64K, divided into 2K mbuf
* clusters. (The chain could be longer than this initially, but can
* be shortened with m_collapse().)
*/
-#define SFXGE_TX_MAPPING_MAX_SEG (64 / 2 + 1)
+#define SFXGE_TX_MAPPING_MAX_SEG \
+ (1 + howmany(SFXGE_TSO_MAX_SIZE, MCLBYTES))
/*
* Buffer mapping flags.
OpenPOWER on IntegriCloud