Migrate the RSS IPv6 hash code to use pointers to the v6 addresses

rather than passing them in by value.

The eventual aim is to do incremental hash construction rather than
all of the memcpy()'ing into a contiguous buffer for the hash
function, which does show up as taking quite a bit of CPU during
profiling.

Tested:

* a variety of laptops/desktop setups I have, with v6 connectivity

Differential Revision:	D1404
Reviewed by:	bz, rpaulo
This commit is contained in:
Adrian Chadd 2014-12-31 22:52:43 +00:00
parent 42e7be2030
commit 492ccbe14d
4 changed files with 20 additions and 20 deletions

View File

@ -346,16 +346,16 @@ rss_hash_ip4_4tuple(struct in_addr src, u_short srcport, struct in_addr dst,
* Hash an IPv6 2-tuple.
*/
uint32_t
rss_hash_ip6_2tuple(struct in6_addr src, struct in6_addr dst)
rss_hash_ip6_2tuple(const struct in6_addr *src, const struct in6_addr *dst)
{
uint8_t data[sizeof(src) + sizeof(dst)];
uint8_t data[sizeof(*src) + sizeof(*dst)];
u_int datalen;
datalen = 0;
bcopy(&src, &data[datalen], sizeof(src));
datalen += sizeof(src);
bcopy(&dst, &data[datalen], sizeof(dst));
datalen += sizeof(dst);
bcopy(src, &data[datalen], sizeof(*src));
datalen += sizeof(*src);
bcopy(dst, &data[datalen], sizeof(*dst));
datalen += sizeof(*dst);
return (rss_hash(datalen, data));
}
@ -363,18 +363,18 @@ rss_hash_ip6_2tuple(struct in6_addr src, struct in6_addr dst)
* Hash an IPv6 4-tuple.
*/
uint32_t
rss_hash_ip6_4tuple(struct in6_addr src, u_short srcport,
struct in6_addr dst, u_short dstport)
rss_hash_ip6_4tuple(const struct in6_addr *src, u_short srcport,
const struct in6_addr *dst, u_short dstport)
{
uint8_t data[sizeof(src) + sizeof(dst) + sizeof(srcport) +
uint8_t data[sizeof(*src) + sizeof(*dst) + sizeof(srcport) +
sizeof(dstport)];
u_int datalen;
datalen = 0;
bcopy(&src, &data[datalen], sizeof(src));
datalen += sizeof(src);
bcopy(&dst, &data[datalen], sizeof(dst));
datalen += sizeof(dst);
bcopy(src, &data[datalen], sizeof(*src));
datalen += sizeof(*src);
bcopy(dst, &data[datalen], sizeof(*dst));
datalen += sizeof(*dst);
bcopy(&srcport, &data[datalen], sizeof(srcport));
datalen += sizeof(srcport);
bcopy(&dstport, &data[datalen], sizeof(dstport));

View File

@ -112,10 +112,10 @@ u_int rss_gethashconfig(void);
uint32_t rss_hash_ip4_4tuple(struct in_addr src, u_short srcport,
struct in_addr dst, u_short dstport);
uint32_t rss_hash_ip4_2tuple(struct in_addr src, struct in_addr dst);
uint32_t rss_hash_ip6_4tuple(struct in6_addr src, u_short srcport,
struct in6_addr dst, u_short dstport);
uint32_t rss_hash_ip6_2tuple(struct in6_addr src,
struct in6_addr dst);
uint32_t rss_hash_ip6_4tuple(const struct in6_addr *src, u_short srcport,
const struct in6_addr *dst, u_short dstport);
uint32_t rss_hash_ip6_2tuple(const struct in6_addr *src,
const struct in6_addr *dst);
/*
* Network stack interface to query desired CPU affinity of a packet.

View File

@ -105,7 +105,7 @@ in6_pcbgroup_bytuple(struct inpcbinfo *pcbinfo, const struct in6_addr *laddrp,
switch (pcbinfo->ipi_hashfields) {
case IPI_HASHFIELDS_4TUPLE:
#ifdef RSS
hash = rss_hash_ip6_4tuple(*faddrp, fport, *laddrp, lport);
hash = rss_hash_ip6_4tuple(faddrp, fport, laddrp, lport);
#else
hash = faddrp->s6_addr32[3] ^ fport;
#endif
@ -113,7 +113,7 @@ in6_pcbgroup_bytuple(struct inpcbinfo *pcbinfo, const struct in6_addr *laddrp,
case IPI_HASHFIELDS_2TUPLE:
#ifdef RSS
hash = rss_hash_ip6_2tuple(*faddrp, *laddrp);
hash = rss_hash_ip6_2tuple(faddrp, laddrp);
#else
hash = faddrp->s6_addr32[3] ^ laddrp->s6_addr32[3];
#endif

View File

@ -841,7 +841,7 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6,
* XXX .. and we should likely cache this in the inpcb.
*/
#ifdef RSS
m->m_pkthdr.flowid = rss_hash_ip6_2tuple(*faddr, *laddr);
m->m_pkthdr.flowid = rss_hash_ip6_2tuple(faddr, laddr);
M_HASHTYPE_SET(m, M_HASHTYPE_RSS_IPV6);
#endif
flags = 0;