Add hash_uint64() and apply it when appropriate.
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
static uint32_t
hash_mpid(uint64_t mpid)
{
- return hash_bytes(&mpid, sizeof mpid, 0);
+ return hash_uint64(mpid);
}
static bool
hash_metadata(ovs_be64 metadata_)
{
uint64_t metadata = (OVS_FORCE uint64_t) metadata_;
- return hash_2words(metadata, metadata >> 32);
+ return hash_uint64(metadata);
}
static struct cls_partition *
static inline uint32_t hash_int(uint32_t x, uint32_t basis);
static inline uint32_t hash_2words(uint32_t, uint32_t);
+static inline uint32_t hash_uint64(uint64_t);
uint32_t hash_3words(uint32_t, uint32_t, uint32_t);
static inline uint32_t hash_boolean(bool x, uint32_t basis);
return mhash_finish(mhash_add(mhash_add(x, 0), y), 8);
}
+static inline uint32_t hash_uint64(const uint64_t x)
+{
+ return hash_2words((uint32_t)(x >> 32), (uint32_t)x);
+}
+
#ifdef __cplusplus
}
#endif
if (ovsthread_once_start(&once)) {
hmap_init(&addrs);
for (node = nodes; node < &nodes[ARRAY_SIZE(nodes)]; node++) {
- hmap_insert(&addrs, &node->hmap_node,
- hash_2words(node->ea64, node->ea64 >> 32));
+ hmap_insert(&addrs, &node->hmap_node, hash_uint64(node->ea64));
}
ovsthread_once_done(&once);
}
ea64 = eth_addr_to_uint64(ea);
- HMAP_FOR_EACH_IN_BUCKET (node, hmap_node, hash_2words(ea64, ea64 >> 32),
- &addrs) {
+ HMAP_FOR_EACH_IN_BUCKET (node, hmap_node, hash_uint64(ea64), &addrs) {
if (node->ea64 == ea64) {
return true;
}
static uint32_t
hash_cookie(ovs_be64 cookie)
{
- return hash_2words((OVS_FORCE uint64_t)cookie >> 32,
- (OVS_FORCE uint64_t)cookie);
+ return hash_uint64((OVS_FORCE uint64_t)cookie);
}
static void