#include "ovs-thread.h"
#include "ofproto-dpif-rid.h"
-struct rid_map {
- struct hmap map;
-};
-
struct rid_node {
struct hmap_node node;
uint32_t recirc_id;
};
struct rid_pool {
- struct rid_map ridmap;
+ struct hmap map;
uint32_t base; /* IDs in the range of [base, base + n_ids). */
uint32_t n_ids; /* Total number of ids in the pool. */
uint32_t next_free_id; /* Possible next free id. */
rids->base = base;
rids->n_ids = n_ids;
rids->next_free_id = base;
- hmap_init(&rids->ridmap.map);
+ hmap_init(&rids->map);
}
static void
{
struct rid_node *rid, *next;
- HMAP_FOR_EACH_SAFE(rid, next, node, &rids->ridmap.map) {
- hmap_remove(&rids->ridmap.map, &rid->node);
+ HMAP_FOR_EACH_SAFE(rid, next, node, &rids->map) {
+ hmap_remove(&rids->map, &rid->node);
free(rid);
}
- hmap_destroy(&rids->ridmap.map);
+ hmap_destroy(&rids->map);
}
static struct rid_node *
struct rid_node *rid;
hash = hash_int(id, 0);
- HMAP_FOR_EACH_WITH_HASH(rid, node, hash, &rids->ridmap.map) {
+ HMAP_FOR_EACH_WITH_HASH(rid, node, hash, &rids->map) {
if (id == rid->recirc_id) {
return rid;
}
rid->recirc_id = id;
hash = hash_int(id, 0);
- hmap_insert(&rids->ridmap.map, &rid->node, hash);
+ hmap_insert(&rids->map, &rid->node, hash);
return rid;
}
if (id > rids->base && (id <= rids->base + rids->n_ids)) {
rid = rid_pool_find(rids, id);
if (rid) {
- hmap_remove(&rids->ridmap.map, &rid->node);
+ hmap_remove(&rids->map, &rid->node);
}
}
}