svn commit: r268911 - head/sys/netinet

Adrian Chadd adrian at FreeBSD.org
Sun Jul 20 07:37:00 UTC 2014


Author: adrian
Date: Sun Jul 20 07:36:59 2014
New Revision: 268911
URL: http://svnweb.freebsd.org/changeset/base/268911

Log:
  Implement rss_gethashconfig() - return the currently supported hash methods
  by the stack.
  
  Right now the stack isn't really setup for RSS with 4-tuple UDP hashing
  for either IPv4 and IPv6.
  
  The specifics:
  
  * The UDP init path udp_init() and udplite_init() specify the hash as
    2-tuple, so the PCBGROUPS code only tries a 2-tuple check;
  * The PCBGROUPS and RSS code doesn't know about the UDP hash types
    just yet, so they're never treated as valid hashes.
  * For correctness, 4-tuple can't be enabled in the general case because
    UDP datagrams can be more fragmented than IP datagrams may be.
  
  Strictly speaking, TCP datagrams may also be fragmented and this could
  cause issues with PCBGROUPS/RSS until the IP defragment path grows some
  code to re-calculate the RSS hash.
  
  I'll follow this commit up with awareness of the UDP 4-tuple for those
  who wish to configure it, but for now it'll stay disabled.
  
  No drivers (yet) know to use this function when RSS is enabled.

Modified:
  head/sys/netinet/in_rss.c
  head/sys/netinet/in_rss.h

Modified: head/sys/netinet/in_rss.c
==============================================================================
--- head/sys/netinet/in_rss.c	Sun Jul 20 07:35:00 2014	(r268910)
+++ head/sys/netinet/in_rss.c	Sun Jul 20 07:36:59 2014	(r268911)
@@ -535,6 +535,40 @@ rss_getnumcpus(void)
 }
 
 /*
+ * Return the supported RSS hash configuration.
+ *
+ * NICs should query this to determine what to configure in their redirection
+ * matching table.
+ */
+u_int
+rss_gethashconfig(void)
+{
+	/* Return 4-tuple for TCP; 2-tuple for others */
+	/*
+	 * UDP may fragment more often than TCP and thus we'll end up with
+	 * NICs returning 2-tuple fragments.
+	 * udp_init() and udplite_init() both currently initialise things
+	 * as 2-tuple.
+	 * So for now disable UDP 4-tuple hashing until all of the other
+	 * pieces are in place.
+	 */
+	return (
+	    RSS_HASHTYPE_RSS_IPV4
+	|    RSS_HASHTYPE_RSS_TCP_IPV4
+	|    RSS_HASHTYPE_RSS_IPV6
+	|    RSS_HASHTYPE_RSS_TCP_IPV6
+	|    RSS_HASHTYPE_RSS_IPV6_EX
+	|    RSS_HASHTYPE_RSS_TCP_IPV6_EX
+#if 0
+	|    RSS_HASHTYPE_RSS_UDP_IPV4
+	|    RSS_HASHTYPE_RSS_UDP_IPV4_EX
+	|    RSS_HASHTYPE_RSS_UDP_IPV6
+	|    RSS_HASHTYPE_RSS_UDP_IPV6_EX
+#endif
+	);
+}
+
+/*
  * XXXRW: Confirm that sysctl -a won't dump this keying material, don't want
  * it appearing in debugging output unnecessarily.
  */

Modified: head/sys/netinet/in_rss.h
==============================================================================
--- head/sys/netinet/in_rss.h	Sun Jul 20 07:35:00 2014	(r268910)
+++ head/sys/netinet/in_rss.h	Sun Jul 20 07:36:59 2014	(r268911)
@@ -52,6 +52,25 @@
 #define	RSS_HASHFIELDS_2TUPLE		2
 
 /*
+ * Define RSS representations of the M_HASHTYPE_* values, representing
+ * which particular bits are supported.  The NICs can then use this to
+ * calculate which hash types to enable and which not to enable.
+ *
+ * The fact that these line up with M_HASHTYPE_* is not to be relied
+ * upon.
+ */
+#define	RSS_HASHTYPE_RSS_IPV4		(1 << 1)	/* IPv4 2-tuple */
+#define	RSS_HASHTYPE_RSS_TCP_IPV4	(1 << 2)	/* TCPv4 4-tuple */
+#define	RSS_HASHTYPE_RSS_IPV6		(1 << 3)	/* IPv6 2-tuple */
+#define	RSS_HASHTYPE_RSS_TCP_IPV6	(1 << 4)	/* TCPv6 4-tuple */
+#define	RSS_HASHTYPE_RSS_IPV6_EX	(1 << 5)	/* IPv6 2-tuple + ext hdrs */
+#define	RSS_HASHTYPE_RSS_TCP_IPV6_EX	(1 << 6)	/* TCPv6 4-tiple + ext hdrs */
+#define	RSS_HASHTYPE_RSS_UDP_IPV4	(1 << 7)	/* IPv4 UDP 4-tuple */
+#define	RSS_HASHTYPE_RSS_UDP_IPV4_EX	(1 << 8)	/* IPv4 UDP 4-tuple + ext hdrs */
+#define	RSS_HASHTYPE_RSS_UDP_IPV6	(1 << 9)	/* IPv6 UDP 4-tuple */
+#define	RSS_HASHTYPE_RSS_UDP_IPV6_EX	(1 << 10)	/* IPv6 UDP 4-tuple + ext hdrs */
+
+/*
  * Compile-time limits on the size of the indirection table.
  */
 #define	RSS_MAXBITS	7
@@ -75,6 +94,7 @@ void	rss_getkey(uint8_t *key);
 u_int	rss_gethashalgo(void);
 u_int	rss_getnumbuckets(void);
 u_int	rss_getnumcpus(void);
+u_int	rss_gethashconfig(void);
 
 /*
  * Network stack interface to generate a hash for a protocol tuple.


More information about the svn-src-head mailing list