From owner-svn-src-all@FreeBSD.ORG Sun Jun 5 08:20:11 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69DA21065673; Sun, 5 Jun 2011 08:20:11 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 46BB98FC13; Sun, 5 Jun 2011 08:20:10 +0000 (UTC) Received: from julian-mac.elischer.org (home-nat.elischer.org [67.100.89.137]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p558K7jN008461 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 5 Jun 2011 01:20:08 -0700 (PDT) (envelope-from julian@freebsd.org) Message-ID: <4DEB3C32.9070709@freebsd.org> Date: Sun, 05 Jun 2011 01:20:02 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Robert Watson References: <201106042331.p54NVfC0030751@svn.freebsd.org> In-Reply-To: <201106042331.p54NVfC0030751@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r222702 - head/sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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, 05 Jun 2011 08:20:11 -0000 On 6/4/11 4:31 PM, Robert Watson wrote: > Author: rwatson > Date: Sat Jun 4 23:31:41 2011 > New Revision: 222702 > URL: http://svn.freebsd.org/changeset/base/222702 > > Log: > Allocate four bits from the mbuf flags field to represent the hash > type of a software- or hardware-generated hash held in the > mbuf.m_pkthdr.flowid field, and provide accessor macros to easily > clear, set, receive, and test for hash values. Some of these > constants correspond to RSS hash types, but we don't want to limit > ourselves to that, as a number of other hashing techniques are in > use on hardware supported by FreeBSD. > > Mark the M_FLOWID flag as deprecated; I hope to remove this before > 9.0, changing drivers and the stack over to using the new > M_HASHTYPEBITS, most likely to use M_HASHTYPE_OPAQUE as we don't yet > want to nail down the KPI for RSS key/bucket management for device > drivers. > > MFC after: 3 days > Reviewed by: bz > Sponsored by: Juniper Networks, Inc. > > Modified: > head/sys/sys/mbuf.h > > Modified: head/sys/sys/mbuf.h > ============================================================================== > --- head/sys/sys/mbuf.h Sat Jun 4 23:31:33 2011 (r222701) > +++ head/sys/sys/mbuf.h Sat Jun 4 23:31:41 2011 (r222702) > @@ -199,7 +199,9 @@ struct mbuf { > #define M_PROTO6 0x00080000 /* protocol-specific */ > #define M_PROTO7 0x00100000 /* protocol-specific */ > #define M_PROTO8 0x00200000 /* protocol-specific */ > -#define M_FLOWID 0x00400000 /* flowid is valid */ > +#define M_FLOWID 0x00400000 /* deprecated: flowid is valid */ > +#define M_HASHTYPEBITS 0x0F000000 /* mask of bits holding flowid hash type */ > + > /* > * For RELENG_{6,7} steal these flags for limited multiple routing table > * support. In RELENG_8 and beyond, use just one flag and a tag. > @@ -215,11 +217,45 @@ struct mbuf { > (M_PROTO1|M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5|M_PROTO6|M_PROTO7|M_PROTO8) > > /* > + * Network interface cards are able to hash protocol fields (such as IPv4 > + * addresses and TCP port numbers) classify packets into flows. These flows > + * can then be used to maintain ordering while delivering packets to the OS > + * via parallel input queues, as well as to provide a stateless affinity > + * model. NIC drivers can pass up the hash via m->m_pkthdr.flowid, and set > + * m_flag fields to indicate how the hash should be interpreted by the > + * network stack. > + * > + * Most NICs support RSS, which provides ordering and explicit affinity, and > + * use the hash m_flag bits to indicate what header fields were covered by > + * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations > + * that provide an opaque flow identifier, allowing for ordering and > + * distribution without explicit affinity. > + */ > +#define M_HASHTYPE_SHIFT 24 > +#define M_HASHTYPE_NONE 0x0 > +#define M_HASHTYPE_RSS_IPV4 0x1 /* IPv4 2-tuple */ > +#define M_HASHTYPE_RSS_TCP_IPV4 0x2 /* TCPv4 4-tuple */ > +#define M_HASHTYPE_RSS_IPV6 0x3 /* IPv6 2-tuple */ > +#define M_HASHTYPE_RSS_TCP_IPV6 0x4 /* TCPv6 4-tuple */ > +#define M_HASHTYPE_RSS_IPV6_EX 0x5 /* IPv6 2-tuple + ext hdrs */ > +#define M_HASHTYPE_RSS_TCP_IPV6_EX 0x6 /* TCPv6 4-tiple + ext hdrs */ > +#define M_HASHTYPE_OPAQUE 0xf /* ordering, not affinity */ > + > +#define M_HASHTYPE_CLEAR(m) (m)->m_flags&= ~(M_HASHTYPEBITS) > +#define M_HASHTYPE_GET(m) (((m)->m_flags& M_HASHTYPEBITS)>> \ > + M_HASHTYPE_SHIFT) > +#define M_HASHTYPE_SET(m, v) do { \ > + (m)->m_flags&= ~M_HASHTYPEBITS; \ > + (m)->m_flags |= ((v)<< M_HASHTYPE_SHIFT); \ > +while (0) > +#define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) > + > +/* > * Flags preserved when copying m_pkthdr. > */ > #define M_COPYFLAGS \ > (M_PKTHDR|M_EOR|M_RDONLY|M_PROTOFLAGS|M_SKIP_FIREWALL|M_BCAST|M_MCAST|\ > - M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB) > + M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB|M_HASHTYPEBITS) > > /* > * External buffer types: identify ext_buf type. > > hmm note that my stealing of 4 bits for FIB was supposed to go away for 8 and beyond. We need to do an mbuf redesign.. at this stage, I guess it's a project for 10.