diff options
author | 2019-11-21 11:59:54 +0000 | |
---|---|---|
committer | 2019-11-22 12:47:14 +0000 | |
commit | 62f7b46d4c49d6e5bfb5b3b537bfcaf6503e7bac (patch) | |
tree | 35e206900cf6a1535df2b3439a55e0fdd9091a7f /hicn-plugin/src/cache_policies | |
parent | ae6f3b8e1f55fc4bb7807c293850d3cb46cab1fd (diff) |
[HICN-405] Added application face delete
Added two new messages in the binary api:
- hicn_api_face_cons_del to delete a consumer face
- hicn_api_face_prod_del to delete a producer face
Added the corresponding commands in the vpp_api_test for debugging and testing
Reworked the cache policy structure to add a new function that flash the content store
from the content coming from the destroyed producer face. This is required since the CS
while each producer face has its own lru list. Removing only the producer face without
flushing the CS from the content coming from the producer face will lead to a segfault
in case there is a hit in the CS as the lru no longer exists and it won't be possible
to update the head of the lru.
Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Change-Id: I8776c86952d50900aa504dd22aec521ed25c1dae
Diffstat (limited to 'hicn-plugin/src/cache_policies')
-rw-r--r-- | hicn-plugin/src/cache_policies/cs_lru.c | 59 | ||||
-rw-r--r-- | hicn-plugin/src/cache_policies/cs_lru.h | 2 | ||||
-rw-r--r-- | hicn-plugin/src/cache_policies/cs_policy.h | 3 |
3 files changed, 60 insertions, 4 deletions
diff --git a/hicn-plugin/src/cache_policies/cs_lru.c b/hicn-plugin/src/cache_policies/cs_lru.c index 1f1d14667..45c4b5b79 100644 --- a/hicn-plugin/src/cache_policies/cs_lru.c +++ b/hicn-plugin/src/cache_policies/cs_lru.c @@ -25,6 +25,7 @@ hicn_cs_policy_vft_t hicn_cs_lru = { .hicn_cs_dequeue = &hicn_cs_lru_dequeue, .hicn_cs_delete_get = &hicn_cs_lru_delete_get, .hicn_cs_trim = &hicn_cs_lru_trim, + .hicn_cs_flush = &hicn_cs_lru_flush, }; /* @@ -151,10 +152,10 @@ hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode, { /* The element is already dequeue */ if (pcs->u.cs.cs_lru_next == 0) - { - /* Now detached from the list; attach at head */ - hicn_cs_lru_insert (pit, pnode, pcs, lru); - } + { + /* Now detached from the list; attach at head */ + hicn_cs_lru_insert (pit, pnode, pcs, lru); + } ASSERT (lru->head == hicn_hashtb_node_idx_from_node (pit->pcs_table, pnode)); } @@ -212,6 +213,56 @@ hicn_cs_lru_trim (hicn_pit_cs_t * pit, u32 * node_list, int sz, return (i); } +int +hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs, + hicn_cs_policy_t * state) +{ + if (state->head == 0 && state->tail == 0) + return 0; + + hicn_hash_node_t *lrunode; + hicn_pcs_entry_t *lrupcs; + u32 idx; + int i = 0; + + idx = state->tail; + + while (idx != 0) + { + lrunode = hicn_hashtb_node_from_idx (pitcs->pcs_table, idx); + lrupcs = hicn_pit_get_data (lrunode); + + u64 hashval = 0; + hicn_hashtb_fullhash ((u8 *) & (lrunode->hn_key.ks.key), + lrunode->hn_keysize, &hashval); + hicn_hash_bucket_t *bucket = NULL; + if ((hashval & (pitcs->pcs_table->ht_bucket_count - 1)) == + lrunode->bucket_id) + { + //The bucket is in the non overflown + bucket = + pool_elt_at_index (pitcs->pcs_table->ht_buckets, + lrunode->bucket_id); + } + else + { + bucket = + pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets, + lrunode->bucket_id); + } + hicn_hash_entry_t *hash_entry = + &(bucket->hb_entries[lrunode->entry_idx]); + hash_entry->locks++; + hicn_pcs_cs_delete (vm, pitcs, &lrupcs, &lrunode, hash_entry, NULL, + NULL); + idx = state->tail; + i++; + } + + return (i); + +} + /* * fd.io coding-style-patch-verification: ON * diff --git a/hicn-plugin/src/cache_policies/cs_lru.h b/hicn-plugin/src/cache_policies/cs_lru.h index 94320f7f9..0a58912d6 100644 --- a/hicn-plugin/src/cache_policies/cs_lru.h +++ b/hicn-plugin/src/cache_policies/cs_lru.h @@ -58,6 +58,8 @@ int hicn_cs_lru_trim (hicn_pit_cs_t * pcs, u32 * node_list, int sz, hicn_cs_policy_t * lru); +int hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs, + hicn_cs_policy_t * state); #endif /* // __LRU_H__ */ /* diff --git a/hicn-plugin/src/cache_policies/cs_policy.h b/hicn-plugin/src/cache_policies/cs_policy.h index 08817de18..c1a9a44c9 100644 --- a/hicn-plugin/src/cache_policies/cs_policy.h +++ b/hicn-plugin/src/cache_policies/cs_policy.h @@ -68,6 +68,9 @@ typedef struct hicn_cs_policy_vft_s int (*hicn_cs_trim) (struct hicn_pit_cs_s * p, u32 * node_list, int sz, hicn_cs_policy_t * policy); + + int (*hicn_cs_flush) (vlib_main_t * vm, struct hicn_pit_cs_s * p, + hicn_cs_policy_t * policy_state); } hicn_cs_policy_vft_t; |