예제 #1
0
static __inline int
INP_MPORT_HASH_TCP(in_addr_t faddr, in_addr_t laddr,
		   in_port_t fport, in_port_t lport)
{
	return toeplitz_hash(
	       toeplitz_rawhash_addrport(faddr, laddr, fport, lport));
}
예제 #2
0
uint32_t
sfxge_toeplitz_hash(sfxge_t *sp, unsigned int addr_size,
    uint8_t *src_addr, uint16_t src_port, uint8_t *dst_addr, uint16_t dst_port)
{
	uint32_t hash = 0;
	unsigned pos = 0;

	hash ^= toeplitz_hash(sp->s_toeplitz_cache, src_addr, pos, addr_size);
	pos += addr_size;
	hash ^= toeplitz_hash(sp->s_toeplitz_cache, dst_addr, pos, addr_size);
	pos += addr_size;
	if (src_port != 0 || dst_port != 0) {
		hash ^= toeplitz_hash(sp->s_toeplitz_cache,
		    (const uint8_t *)&src_port, pos, sizeof (src_port));
		pos += sizeof (src_port);
		hash ^= toeplitz_hash(sp->s_toeplitz_cache,
		    (const uint8_t *)&dst_port, pos, sizeof (dst_port));
	}
	return (hash);
}
예제 #3
0
/*
 * Toeplitz hash functions - the idea is to match the hardware.
 */
static __inline int
INP_MPORT_HASH_UDP(in_addr_t faddr, in_addr_t laddr,
		   in_port_t fport, in_port_t lport)
{
	/*
	 * NOTE: laddr could be multicast, since UDP socket could be
	 * bound to multicast address.
	 */
	if (IN_MULTICAST(ntohl(faddr)) || IN_MULTICAST(ntohl(laddr))) {
		/* XXX handle multicast on CPU0 for now */
		return 0;
	}
	return toeplitz_hash(toeplitz_rawhash_addr(faddr, laddr));
}
예제 #4
0
uint32_t
rss_hash(u_int datalen, const uint8_t *data)
{
 
	switch (rss_hashalgo) {
	case RSS_HASH_TOEPLITZ:
		return (toeplitz_hash(sizeof(rss_key), rss_key, datalen,
		    data));

	case RSS_HASH_NAIVE:
		return (rss_naive_hash(sizeof(rss_key), rss_key, datalen,
		    data));

	default:
		panic("%s: unsupported/unknown hashalgo %d", __func__,
		    rss_hashalgo);
	}
}