38#include <sys/socket.h>
40#include <sys/kernel.h>
42#include <sys/sysctl.h>
46#include <net/if_var.h>
47#include <net/netisr.h>
48#include <net/rss_config.h>
66 uint8_t data[
sizeof(src) +
sizeof(dst)];
70 bcopy(&src, &data[datalen],
sizeof(src));
71 datalen +=
sizeof(src);
72 bcopy(&dst, &data[datalen],
sizeof(dst));
73 datalen +=
sizeof(dst);
74 return (rss_hash(datalen, data));
84 uint8_t data[
sizeof(src) +
sizeof(dst) +
sizeof(srcport) +
89 bcopy(&src, &data[datalen],
sizeof(src));
90 datalen +=
sizeof(src);
91 bcopy(&dst, &data[datalen],
sizeof(dst));
92 datalen +=
sizeof(dst);
93 bcopy(&srcport, &data[datalen],
sizeof(srcport));
94 datalen +=
sizeof(srcport);
95 bcopy(&dstport, &data[datalen],
sizeof(dstport));
96 datalen +=
sizeof(dstport);
97 return (rss_hash(datalen, data));
115 u_short sp, u_short dp,
int proto,
125 (rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4)) {
128 *hashtype = M_HASHTYPE_RSS_TCP_IPV4;
131 (rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4)) {
134 *hashtype = M_HASHTYPE_RSS_UDP_IPV4;
136 }
else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) {
140 *hashtype = M_HASHTYPE_RSS_IPV4;
145 RSS_DEBUG(
"no available hashtypes!\n");
162 u_short sp, u_short dp,
int proto,
uint32_t *hashtype)
171 (rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4)) {
173 *hashtype = M_HASHTYPE_RSS_TCP_IPV4;
176 (rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4)) {
178 *hashtype = M_HASHTYPE_RSS_UDP_IPV4;
180 }
else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) {
183 *hashtype = M_HASHTYPE_RSS_IPV4;
187 *hashtype = M_HASHTYPE_NONE;
211 const struct tcphdr *th;
222 if (dir != RSS_HASH_PKT_INGRESS) {
223 RSS_DEBUG(
"called on EGRESS packet!\n");
231 if (m->m_pkthdr.len < (
sizeof(
struct ip))) {
232 RSS_DEBUG(
"short mbuf pkthdr\n");
235 if (m->m_len < (
sizeof(
struct ip))) {
236 RSS_DEBUG(
"short mbuf len\n");
241 ip = mtod(m,
struct ip *);
264 flowid = m->m_pkthdr.flowid;
265 flowtype = M_HASHTYPE_GET(m);
267 if (flowtype != M_HASHTYPE_NONE) {
270 if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4) &&
271 (flowtype == M_HASHTYPE_RSS_UDP_IPV4) &&
279 if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) &&
280 ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4) == 0) &&
281 flowtype == M_HASHTYPE_RSS_IPV4) {
286 if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4) &&
287 (flowtype == M_HASHTYPE_RSS_TCP_IPV4) &&
295 if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) &&
296 ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4) == 0) &&
297 flowtype == M_HASHTYPE_RSS_IPV4) {
302 if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) &&
303 flowtype == M_HASHTYPE_RSS_IPV4) {
316 if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4) &&
319 if (m->m_len < iphlen +
sizeof(
struct tcphdr)) {
320 RSS_DEBUG(
"short TCP frame?\n");
323 th = (
const struct tcphdr *)((c_caddr_t)
ip + iphlen);
330 }
else if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4) &&
333 uh = (
const struct udphdr *)((c_caddr_t)
ip + iphlen);
334 if (m->m_len < iphlen +
sizeof(
struct udphdr)) {
335 RSS_DEBUG(
"short UDP frame?\n");
344 }
else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) {
353 RSS_DEBUG(
"no available hashtypes!\n");
380 &hash_val, &hash_type);
383 *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m));
384 }
else if (ret == 0) {
386 m->m_pkthdr.flowid = hash_val;
387 M_HASHTYPE_SET(m, hash_type);
388 *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m));
391 *cpuid = NETISR_CPUID_NONE;
struct in_addr ip_src ip_dst