コード例 #1
0
ファイル: ip_demux.c プロジェクト: AhmadTux/DragonFlyBSD
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
ファイル: sfxge_hash.c プロジェクト: bahamas10/openzfs
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
ファイル: rss_config.c プロジェクト: hmatyschok/MeshBSD
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);
	}
}