2 * Copyright (c) 2010-2011 Juniper Networks, Inc.
5 * This software was developed by Robert N. M. Watson under contract
6 * to Juniper Networks, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include "opt_inet6.h"
35 #include "opt_pcbgroup.h"
38 #error "options RSS depends on options PCBGROUP"
41 #include <sys/param.h>
43 #include <sys/socket.h>
45 #include <sys/kernel.h>
47 #include <sys/sysctl.h>
51 #include <net/if_var.h>
52 #include <net/netisr.h>
53 #include <net/rss_config.h>
55 #include <netinet/in.h>
56 #include <netinet/in_pcb.h>
57 #include <netinet6/in6_rss.h>
58 #include <netinet/in_var.h>
60 /* for software rss hash support */
61 #include <netinet/ip.h>
62 #include <netinet/tcp.h>
63 #include <netinet/udp.h>
66 * Hash an IPv6 2-tuple.
69 rss_hash_ip6_2tuple(const struct in6_addr *src, const struct in6_addr *dst)
71 uint8_t data[sizeof(*src) + sizeof(*dst)];
75 bcopy(src, &data[datalen], sizeof(*src));
76 datalen += sizeof(*src);
77 bcopy(dst, &data[datalen], sizeof(*dst));
78 datalen += sizeof(*dst);
79 return (rss_hash(datalen, data));
83 * Hash an IPv6 4-tuple.
86 rss_hash_ip6_4tuple(const struct in6_addr *src, u_short srcport,
87 const struct in6_addr *dst, u_short dstport)
89 uint8_t data[sizeof(*src) + sizeof(*dst) + sizeof(srcport) +
94 bcopy(src, &data[datalen], sizeof(*src));
95 datalen += sizeof(*src);
96 bcopy(dst, &data[datalen], sizeof(*dst));
97 datalen += sizeof(*dst);
98 bcopy(&srcport, &data[datalen], sizeof(srcport));
99 datalen += sizeof(srcport);
100 bcopy(&dstport, &data[datalen], sizeof(dstport));
101 datalen += sizeof(dstport);
102 return (rss_hash(datalen, data));