Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/in_rss.c
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | if ((proto == IPPROTO_TCP) && | ||||
/* RSS doesn't hash on other protocols like SCTP; so 2-tuple */ | /* RSS doesn't hash on other protocols like SCTP; so 2-tuple */ | ||||
hash = rss_hash_ip4_2tuple(s, d); | hash = rss_hash_ip4_2tuple(s, d); | ||||
*hashval = hash; | *hashval = hash; | ||||
*hashtype = M_HASHTYPE_RSS_IPV4; | *hashtype = M_HASHTYPE_RSS_IPV4; | ||||
return (0); | return (0); | ||||
} | } | ||||
/* No configured available hashtypes! */ | /* No configured available hashtypes! */ | ||||
printf("%s: no available hashtypes!\n", __func__); | RSS_DEBUG("no available hashtypes!\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* | /* | ||||
* Do a software calculation of the RSS for the given mbuf. | * Do a software calculation of the RSS for the given mbuf. | ||||
* | * | ||||
* This is typically used by the input path to recalculate the RSS after | * This is typically used by the input path to recalculate the RSS after | ||||
* some form of packet processing (eg de-capsulation, IP fragment reassembly.) | * some form of packet processing (eg de-capsulation, IP fragment reassembly.) | ||||
Show All 19 Lines | rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, | ||||
uint8_t proto; | uint8_t proto; | ||||
int iphlen; | int iphlen; | ||||
int is_frag = 0; | int is_frag = 0; | ||||
/* | /* | ||||
* XXX For now this only handles hashing on incoming mbufs. | * XXX For now this only handles hashing on incoming mbufs. | ||||
*/ | */ | ||||
if (dir != RSS_HASH_PKT_INGRESS) { | if (dir != RSS_HASH_PKT_INGRESS) { | ||||
printf("%s: called on EGRESS packet!\n", __func__); | RSS_DEBUG("called on EGRESS packet!\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* | /* | ||||
* First, validate that the mbuf we have is long enough | * First, validate that the mbuf we have is long enough | ||||
* to have an IPv4 header in it. | * to have an IPv4 header in it. | ||||
*/ | */ | ||||
if (m->m_pkthdr.len < (sizeof(struct ip))) { | if (m->m_pkthdr.len < (sizeof(struct ip))) { | ||||
printf("%s: short mbuf pkthdr\n", __func__); | RSS_DEBUG("short mbuf pkthdr\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (m->m_len < (sizeof(struct ip))) { | if (m->m_len < (sizeof(struct ip))) { | ||||
printf("%s: short mbuf len\n", __func__); | RSS_DEBUG("short mbuf len\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* Ok, let's dereference that */ | /* Ok, let's dereference that */ | ||||
ip = mtod(m, struct ip *); | ip = mtod(m, struct ip *); | ||||
proto = ip->ip_p; | proto = ip->ip_p; | ||||
iphlen = ip->ip_hl << 2; | iphlen = ip->ip_hl << 2; | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, | ||||
* | * | ||||
* XXX TODO: does the hardware hash on 4-tuple if IP | * XXX TODO: does the hardware hash on 4-tuple if IP | ||||
* options are present? | * options are present? | ||||
*/ | */ | ||||
if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4) && | if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4) && | ||||
(proto == IPPROTO_TCP) && | (proto == IPPROTO_TCP) && | ||||
(is_frag == 0)) { | (is_frag == 0)) { | ||||
if (m->m_len < iphlen + sizeof(struct tcphdr)) { | if (m->m_len < iphlen + sizeof(struct tcphdr)) { | ||||
printf("%s: short TCP frame?\n", __func__); | RSS_DEBUG("short TCP frame?\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
th = (const struct tcphdr *)((c_caddr_t)ip + iphlen); | th = (const struct tcphdr *)((c_caddr_t)ip + iphlen); | ||||
return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, | return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, | ||||
th->th_sport, | th->th_sport, | ||||
th->th_dport, | th->th_dport, | ||||
proto, | proto, | ||||
hashval, | hashval, | ||||
hashtype); | hashtype); | ||||
} else if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4) && | } else if ((rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4) && | ||||
(proto == IPPROTO_UDP) && | (proto == IPPROTO_UDP) && | ||||
(is_frag == 0)) { | (is_frag == 0)) { | ||||
uh = (const struct udphdr *)((c_caddr_t)ip + iphlen); | uh = (const struct udphdr *)((c_caddr_t)ip + iphlen); | ||||
if (m->m_len < iphlen + sizeof(struct udphdr)) { | if (m->m_len < iphlen + sizeof(struct udphdr)) { | ||||
printf("%s: short UDP frame?\n", __func__); | RSS_DEBUG("short UDP frame?\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, | return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, | ||||
uh->uh_sport, | uh->uh_sport, | ||||
uh->uh_dport, | uh->uh_dport, | ||||
proto, | proto, | ||||
hashval, | hashval, | ||||
hashtype); | hashtype); | ||||
} else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) { | } else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) { | ||||
/* Default to 2-tuple hash */ | /* Default to 2-tuple hash */ | ||||
return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, | return rss_proto_software_hash_v4(ip->ip_src, ip->ip_dst, | ||||
0, /* source port */ | 0, /* source port */ | ||||
0, /* destination port */ | 0, /* destination port */ | ||||
0, /* IPPROTO_IP */ | 0, /* IPPROTO_IP */ | ||||
hashval, | hashval, | ||||
hashtype); | hashtype); | ||||
} else { | } else { | ||||
printf("%s: no available hashtypes!\n", __func__); | RSS_DEBUG("no available hashtypes!\n"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Similar to rss_m2cpuid, but designed to be used by the IP NETISR | * Similar to rss_m2cpuid, but designed to be used by the IP NETISR | ||||
* on incoming frames. | * on incoming frames. | ||||
* | * | ||||
Show All 33 Lines |