diff options
author | adrian <adrian@FreeBSD.org> | 2014-09-09 03:10:21 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2014-09-09 03:10:21 +0000 |
commit | e5ddfb30abb527a21677ab200879826e3224fad1 (patch) | |
tree | ff96cd78e704c08d3c7b87a5179dc7648105fafb /sys/netinet/in_rss.h | |
parent | d8542f016cf5f6969dad82ccdd9ad11898f0c801 (diff) | |
download | FreeBSD-src-e5ddfb30abb527a21677ab200879826e3224fad1.zip FreeBSD-src-e5ddfb30abb527a21677ab200879826e3224fad1.tar.gz |
Implement IPv4 RSS software hash functions to use during packet ingress
and egress.
* rss_mbuf_software_hash_v4 - look at the IPv4 mbuf to fetch the IPv4 details
+ direction to calculate a hash.
* rss_proto_software_hash_v4 - hash the given source/destination IPv4 address,
port and direction.
* rss_soft_m2cpuid - map the given mbuf to an RSS CPU ("bucket" for now)
These functions are intended to be used by the stack to support
the following:
* Not all NICs do RSS hashing, so we should support some way of doing
a hash in software;
* The NIC / driver may not hash frames the way we want (eg UDP 4-tuple
hashing when the stack is only doing 2-tuple hashing for UDP); so we
may need to re-hash frames;
* .. same with IPv4 fragments - they will need to be re-hashed after
reassembly;
* .. and same with things like IP tunneling and such;
* The transmit path for things like UDP, RAW and ICMP don't currently
have any RSS information attached to them - so they'll need an
RSS calculation performed before transmit.
TODO:
* Counters! Everywhere!
* Add a debug mode that software hashes received frames and compares them
to the hardware hash provided by the hardware to ensure they match.
The IPv6 part of this is missing - I'm going to do some re-juggling of
where various parts of the RSS framework live before I add the IPv6
code (read: the IPv6 code is going to go into netinet6/in6_rss.[ch],
rather than living here.)
Note: This API is still fluid. Please keep that in mind.
Differential Revision: https://reviews.freebsd.org/D527
Reviewed by: grehan
Diffstat (limited to 'sys/netinet/in_rss.h')
-rw-r--r-- | sys/netinet/in_rss.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/netinet/in_rss.h b/sys/netinet/in_rss.h index a911e3c..66fb611 100644 --- a/sys/netinet/in_rss.h +++ b/sys/netinet/in_rss.h @@ -83,6 +83,16 @@ #define RSS_KEYSIZE 40 /* + * For RSS hash methods that do a software hash on an mbuf, the packet + * direction (ingress / egress) is required. + * + * The default direction (INGRESS) is the "receive into the NIC" - ie, + * what the hardware is hashing on. + */ +#define RSS_HASH_PKT_INGRESS 0 +#define RSS_HASH_PKT_EGRESS 1 + +/* * Device driver interfaces to query RSS properties that must be programmed * into hardware. */ @@ -116,4 +126,17 @@ int rss_hash2bucket(uint32_t hash_val, uint32_t hash_type, uint32_t *bucket_id); int rss_m2bucket(struct mbuf *m, uint32_t *bucket_id); +/* + * Functions to calculate a software RSS hash for a given mbuf or + * packet detail. + */ +int rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, + uint32_t *hashval, uint32_t *hashtype); +int rss_proto_software_hash_v4(struct in_addr src, + struct in_addr dst, u_short src_port, u_short dst_port, + int proto, uint32_t *hashval, + uint32_t *hashtype); +struct mbuf * rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, + u_int *cpuid); + #endif /* !_NETINET_IN_RSS_H_ */ |