From owner-svn-src-all@FreeBSD.ORG Sun May 18 22:32:05 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 17CB1CC; Sun, 18 May 2014 22:32:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF8CD2215; Sun, 18 May 2014 22:32:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4IMW4rT057335; Sun, 18 May 2014 22:32:04 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4IMW468057333; Sun, 18 May 2014 22:32:04 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201405182232.s4IMW468057333@svn.freebsd.org> From: Adrian Chadd Date: Sun, 18 May 2014 22:32:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266419 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2014 22:32:05 -0000 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_ */