aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2014-07-20 07:36:59 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2014-07-20 07:36:59 +0000
commit40c753e3da0f3f36db2082bf873a59b798997247 (patch)
tree1b2b1cb817f70ee926257014b69e305ff55d238f
parent85415b47c8fcea6d3202fc7caabd68027e0aab21 (diff)
downloadsrc-40c753e3da0f3f36db2082bf873a59b798997247.tar.gz
src-40c753e3da0f3f36db2082bf873a59b798997247.zip
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.
Notes
Notes: svn path=/head/; revision=268911
-rw-r--r--sys/netinet/in_rss.c34
-rw-r--r--sys/netinet/in_rss.h20
2 files changed, 54 insertions, 0 deletions
diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c
index 1e122f140143..edba1100097a 100644
--- a/sys/netinet/in_rss.c
+++ b/sys/netinet/in_rss.c
@@ -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.
*/
diff --git a/sys/netinet/in_rss.h b/sys/netinet/in_rss.h
index 8d390f1e17fb..a911e3c0f926 100644
--- a/sys/netinet/in_rss.h
+++ b/sys/netinet/in_rss.h
@@ -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.