Add a new function to do a CPU ID lookup based on RSS hash information.

This is intended to be used by various places that wish to hash some
information about a TCP/UDP/IP flow but don't necessarily have a
live mbuf to do it with.

Refactor rss_m2cpuid() to use the refactored function.
This commit is contained in:
Adrian Chadd 2014-05-18 22:32:04 +00:00
parent 34e3dcedec
commit cc6c187794
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=266419
2 changed files with 19 additions and 11 deletions

View file

@ -406,6 +406,22 @@ rss_getcpu(u_int bucket)
return (rss_table[bucket].rte_cpu);
}
/*
* netisr CPU affinity lookup given just the hash and hashtype.
*/
u_int
rss_hash2cpuid(uint32_t hash_val, uint32_t hash_type)
{
switch (hash_type) {
case M_HASHTYPE_RSS_IPV4:
case M_HASHTYPE_RSS_TCP_IPV4:
return (rss_getcpu(rss_getbucket(hash_val)));
default:
return (NETISR_CPUID_NONE);
}
}
/*
* netisr CPU affinity lookup routine for use by protocols.
*/
@ -414,17 +430,8 @@ rss_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid)
{
M_ASSERTPKTHDR(m);
switch (M_HASHTYPE_GET(m)) {
case M_HASHTYPE_RSS_IPV4:
case M_HASHTYPE_RSS_TCP_IPV4:
*cpuid = rss_getcpu(rss_getbucket(m->m_pkthdr.flowid));
return (m);
default:
*cpuid = NETISR_CPUID_NONE;
return (m);
}
*cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m));
return (m);
}
/*

View file

@ -90,5 +90,6 @@ uint32_t rss_hash_ip6_2tuple(struct in6_addr src,
* Network stack interface to query desired CPU affinity of a packet.
*/
struct mbuf *rss_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid);
u_int rss_hash2cpuid(uint32_t hash_val, uint32_t hash_type);
#endif /* !_NETINET_IN_RSS_H_ */