* 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. * * This assumes that the packet in question isn't a fragment. * * It also assumes the packet
| 116 | * are in "incoming" packet order (ie, source is "far" address.) |
| 117 | */ |
| 118 | int |
| 119 | rss_proto_software_hash_v4(struct in_addr s, struct in_addr d, |
| 120 | u_short sp, u_short dp, int proto, |
| 121 | uint32_t *hashval, uint32_t *hashtype) |
| 122 | { |
| 123 | uint32_t hash; |
| 124 | |
| 125 | /* |
| 126 | * Next, choose the hash type depending upon the protocol |
| 127 | * identifier. |
| 128 | */ |
| 129 | if ((proto == IPPROTO_TCP) && |
| 130 | (rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV4)) { |
| 131 | hash = rss_hash_ip4_4tuple(s, sp, d, dp); |
| 132 | *hashval = hash; |
| 133 | *hashtype = M_HASHTYPE_RSS_TCP_IPV4; |
| 134 | return (0); |
| 135 | } else if ((proto == IPPROTO_UDP) && |
| 136 | (rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV4)) { |
| 137 | hash = rss_hash_ip4_4tuple(s, sp, d, dp); |
| 138 | *hashval = hash; |
| 139 | *hashtype = M_HASHTYPE_RSS_UDP_IPV4; |
| 140 | return (0); |
| 141 | } else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV4) { |
| 142 | /* RSS doesn't hash on other protocols like SCTP; so 2-tuple */ |
| 143 | hash = rss_hash_ip4_2tuple(s, d); |
| 144 | *hashval = hash; |
| 145 | *hashtype = M_HASHTYPE_RSS_IPV4; |
| 146 | return (0); |
| 147 | } |
| 148 | |
| 149 | /* No configured available hashtypes! */ |
| 150 | RSS_DEBUG("no available hashtypes!\n"); |
| 151 | return (-1); |
| 152 | } |
| 153 | |
| 154 | /* |
| 155 | * Calculate an appropriate ipv4 2-tuple or 4-tuple given the given |
no test coverage detected