Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 May 2014 22:32:04 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266419 - head/sys/netinet
Message-ID:  <201405182232.s4IMW468057333@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun May 18 22:32:04 2014
New Revision: 266419
URL: http://svnweb.freebsd.org/changeset/base/266419

Log:
  Add a new function to do a CPU ID lookup based on RSS hash information.
  
  This is intended to be used by various places that wish to hash some
  information about a TCP/UDP/IP flow but don't necessarily have a
  live mbuf to do it with.
  
  Refactor rss_m2cpuid() to use the refactored function.

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 May 18 22:30:12 2014	(r266418)
+++ head/sys/netinet/in_rss.c	Sun May 18 22:32:04 2014	(r266419)
@@ -407,27 +407,34 @@ rss_getcpu(u_int bucket)
 }
 
 /*
- * netisr CPU affinity lookup routine for use by protocols.
+ * netisr CPU affinity lookup given just the hash and hashtype.
  */
-struct mbuf *
-rss_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid)
+u_int
+rss_hash2cpuid(uint32_t hash_val, uint32_t hash_type)
 {
 
-	M_ASSERTPKTHDR(m);
-
-	switch (M_HASHTYPE_GET(m)) {
+	switch (hash_type) {
 	case M_HASHTYPE_RSS_IPV4:
 	case M_HASHTYPE_RSS_TCP_IPV4:
-		*cpuid = rss_getcpu(rss_getbucket(m->m_pkthdr.flowid));
-		return (m);
-
+		return (rss_getcpu(rss_getbucket(hash_val)));
 	default:
-		*cpuid = NETISR_CPUID_NONE;
-		return (m);
+		return (NETISR_CPUID_NONE);
 	}
 }
 
 /*
+ * netisr CPU affinity lookup routine for use by protocols.
+ */
+struct mbuf *
+rss_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid)
+{
+
+	M_ASSERTPKTHDR(m);
+	*cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m));
+	return (m);
+}
+
+/*
  * Query the RSS hash algorithm.
  */
 u_int

Modified: head/sys/netinet/in_rss.h
==============================================================================
--- head/sys/netinet/in_rss.h	Sun May 18 22:30:12 2014	(r266418)
+++ head/sys/netinet/in_rss.h	Sun May 18 22:32:04 2014	(r266419)
@@ -90,5 +90,6 @@ uint32_t	rss_hash_ip6_2tuple(struct in6_
  * Network stack interface to query desired CPU affinity of a packet.
  */
 struct mbuf	*rss_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid);
+u_int		rss_hash2cpuid(uint32_t hash_val, uint32_t hash_type);
 
 #endif /* !_NETINET_IN_RSS_H_ */



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