diff options
author | Simon Horman <simon.horman@netronome.com> | 2014-09-25 11:57:52 +0000 |
---|---|---|
committer | Andy Zhou <azhou@nicira.com> | 2014-09-25 13:46:48 -0700 |
commit | 4673ac185d2c44b6f01517415bd254e3c79d8f6d (patch) | |
tree | c198f89b73bd07a011b53a64121e3685d7fbf20e | |
parent | 0b5d64f6f7fa75c6c5d4e9fba82ac2d16784c9b6 (diff) | |
download | openvswitch-4673ac185d2c44b6f01517415bd254e3c79d8f6d.tar.gz |
ofproto-dpif-rid: remove struct rid_map
struct rid_map only has one member which is a struct hmap.
This allows for a slight simplification of the code by removing
struct rid_map and using a struct hmap directly instead.
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
-rw-r--r-- | ofproto/ofproto-dpif-rid.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/ofproto/ofproto-dpif-rid.c b/ofproto/ofproto-dpif-rid.c index e75dfc857..1326eae33 100644 --- a/ofproto/ofproto-dpif-rid.c +++ b/ofproto/ofproto-dpif-rid.c @@ -21,17 +21,13 @@ #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. */ @@ -99,7 +95,7 @@ rid_pool_init(struct rid_pool *rids, uint32_t base, uint32_t n_ids) rids->base = base; rids->n_ids = n_ids; rids->next_free_id = base; - hmap_init(&rids->ridmap.map); + hmap_init(&rids->map); } static void @@ -107,12 +103,12 @@ rid_pool_uninit(struct rid_pool *rids) { 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 * @@ -122,7 +118,7 @@ rid_pool_find(struct rid_pool *rids, uint32_t id) 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; } @@ -138,7 +134,7 @@ rid_pool_add(struct rid_pool *rids, uint32_t id) 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; } @@ -184,7 +180,7 @@ rid_pool_free_id(struct rid_pool *rids, uint32_t id) 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); } } } |