Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Feb 2015 06:24:49 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279094 - head/sys/dev/sfxge
Message-ID:  <201502210624.t1L6OneO052511@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Sat Feb 21 06:24:48 2015
New Revision: 279094
URL: https://svnweb.freebsd.org/changeset/base/279094

Log:
  sfxge: more accurate calculation of maximum number of TSO segments
  
  Sponsored by:   Solarflare Communications, Inc.
  Approved by:    gnn (mentor)

Modified:
  head/sys/dev/sfxge/sfxge_tx.c
  head/sys/dev/sfxge/sfxge_tx.h

Modified: head/sys/dev/sfxge/sfxge_tx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.c	Sat Feb 21 06:05:51 2015	(r279093)
+++ head/sys/dev/sfxge/sfxge_tx.c	Sat Feb 21 06:24:48 2015	(r279094)
@@ -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

Modified: head/sys/dev/sfxge/sfxge_tx.h
==============================================================================
--- head/sys/dev/sfxge/sfxge_tx.h	Sat Feb 21 06:05:51 2015	(r279093)
+++ head/sys/dev/sfxge/sfxge_tx.h	Sat Feb 21 06:24:48 2015	(r279094)
@@ -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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502210624.t1L6OneO052511>