From owner-svn-src-head@FreeBSD.ORG Tue Sep 9 04:19:37 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0AF261A7; Tue, 9 Sep 2014 04:19:37 +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 D0613A08; Tue, 9 Sep 2014 04:19:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s894JaOO007434; Tue, 9 Sep 2014 04:19:36 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s894JalU007433; Tue, 9 Sep 2014 04:19:36 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201409090419.s894JalU007433@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 9 Sep 2014 04:19:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271301 - 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-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Sep 2014 04:19:37 -0000 Author: adrian Date: Tue Sep 9 04:19:36 2014 New Revision: 271301 URL: http://svnweb.freebsd.org/changeset/base/271301 Log: Calculate the RSS hash for outbound UDPv4 frames. Differential Revision: https://reviews.freebsd.org/D527 Reviewed by: grehan Modified: head/sys/netinet/udp_usrreq.c Modified: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Tue Sep 9 04:18:20 2014 (r271300) +++ head/sys/netinet/udp_usrreq.c Tue Sep 9 04:19:36 2014 (r271301) @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef IPSEC #include @@ -207,6 +208,13 @@ void udp_init(void) { + /* + * For now default to 2-tuple UDP hashing - until the fragment + * reassembly code can also update the flowid. + * + * Once we can calculate the flowid that way and re-establish + * a 4-tuple, flip this to 4-tuple. + */ in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE, "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE, IPI_HASHFIELDS_2TUPLE); @@ -1435,9 +1443,46 @@ udp_output(struct inpcb *inp, struct mbu m->m_flags |= M_FLOWID; m->m_pkthdr.flowid = flowid; M_HASHTYPE_SET(m, flowid_type); +#ifdef RSS + } else { + uint32_t hash_val, hash_type; + /* + * Calculate an appropriate RSS hash for UDP and + * UDP Lite. + * + * The called function will take care of figuring out + * whether a 2-tuple or 4-tuple hash is required based + * on the currently configured scheme. + * + * Later later on connected socket values should be + * cached in the inpcb and reused, rather than constantly + * re-calculating it. + * + * UDP Lite is a different protocol number and will + * likely end up being hashed as a 2-tuple until + * RSS / NICs grow UDP Lite protocol awareness. + */ + if (rss_proto_software_hash_v4(faddr, laddr, fport, lport, + pr, &hash_val, &hash_type) == 0) { + m->m_pkthdr.flowid = hash_val; + m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, hash_type); + } +#endif } #ifdef RSS + /* + * Don't override with the inp cached flowid value. + * + * Depending upon the kind of send being done, the inp + * flowid/flowtype values may actually not be appropriate + * for this particular socket send. + * + * We should either leave the flowid at zero (which is what is + * currently done) or set it to some software generated + * hash value based on the packet contents. + */ ipflags |= IP_NODEFAULTFLOWID; #endif /* RSS */