* Calculate an appropriate ipv4 2-tuple or 4-tuple given the given * IPv4 source/destination address, UDP or TCP source/destination ports * and the protocol type. * * The protocol code may wish to do a software hash of the given * tuple. This depends upon the currently configured RSS hash types. * * It assumes the packet source/destination address * are in "outgoing" packet order (ie, des
| 163 | * are in "outgoing" packet order (ie, destination is "far" address.) |
| 164 | */ |
| 165 | uint32_t |
| 166 | xps_proto_software_hash_v4(struct in_addr s, struct in_addr d, |
| 167 | u_short sp, u_short dp, int proto, uint32_t *hashtype) |
| 168 | { |
| 169 | uint32_t hash; |
| 170 | |
| 171 | /* |
| 172 | * Next, choose the hash type depending upon the protocol |
| 173 | * identifier. |
| 174 | */ |
| 175 | if ((proto == IPPROTO_TCP) && |
| 176 | (rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4)) { |
| 177 | hash = rss_hash_ip4_4tuple(d, dp, s, sp); |
| 178 | *hashtype = M_HASHTYPE_RSS_TCP_IPV4; |
| 179 | return (hash); |
| 180 | } else if ((proto == IPPROTO_UDP) && |
| 181 | (rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4)) { |
| 182 | hash = rss_hash_ip4_4tuple(d, dp, s, sp); |
| 183 | *hashtype = M_HASHTYPE_RSS_UDP_IPV4; |
| 184 | return (hash); |
| 185 | } else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) { |
| 186 | /* RSS doesn't hash on other protocols like SCTP; so 2-tuple */ |
| 187 | hash = rss_hash_ip4_2tuple(d, s); |
| 188 | *hashtype = M_HASHTYPE_RSS_IPV4; |
| 189 | return (hash); |
| 190 | } |
| 191 | |
| 192 | *hashtype = M_HASHTYPE_NONE; |
| 193 | return (0); |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * Do a software calculation of the RSS for the given mbuf. |
nothing calls this directly
no test coverage detected