diff options
author | adrian <adrian@FreeBSD.org> | 2014-12-31 22:52:43 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2014-12-31 22:52:43 +0000 |
commit | 06c1511222c2634e60b2b997582869fd01901440 (patch) | |
tree | 2620d3031f532e46e873e3d0198bbfbf6440c05c /sys | |
parent | 0f65758efe597093a0c3052f75df5cf16fc305f8 (diff) | |
download | FreeBSD-src-06c1511222c2634e60b2b997582869fd01901440.zip FreeBSD-src-06c1511222c2634e60b2b997582869fd01901440.tar.gz |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in_rss.c | 26 | ||||
-rw-r--r-- | sys/netinet/in_rss.h | 8 | ||||
-rw-r--r-- | sys/netinet6/in6_pcbgroup.c | 4 | ||||
-rw-r--r-- | sys/netinet6/udp6_usrreq.c | 2 |
4 files changed, 20 insertions, 20 deletions
diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 5d4f3c0..336c64f 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -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)); diff --git a/sys/netinet/in_rss.h b/sys/netinet/in_rss.h index 66fb611..90d28ed 100644 --- a/sys/netinet/in_rss.h +++ b/sys/netinet/in_rss.h @@ -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. diff --git a/sys/netinet6/in6_pcbgroup.c b/sys/netinet6/in6_pcbgroup.c index 204370d..45773ed 100644 --- a/sys/netinet6/in6_pcbgroup.c +++ b/sys/netinet6/in6_pcbgroup.c @@ -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 diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 30089d2..fc6b6a0 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -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; |