aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/cache_policies
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src/cache_policies')
-rw-r--r--hicn-plugin/src/cache_policies/cs_lru.c55
-rw-r--r--hicn-plugin/src/cache_policies/cs_lru.h33
-rw-r--r--hicn-plugin/src/cache_policies/cs_policy.h55
3 files changed, 64 insertions, 79 deletions
diff --git a/hicn-plugin/src/cache_policies/cs_lru.c b/hicn-plugin/src/cache_policies/cs_lru.c
index 079af58ab..408a6cb49 100644
--- a/hicn-plugin/src/cache_policies/cs_lru.c
+++ b/hicn-plugin/src/cache_policies/cs_lru.c
@@ -32,8 +32,8 @@ hicn_cs_policy_vft_t hicn_cs_lru = {
* Insert a new CS element at the head of the CS LRU
*/
void
-hicn_cs_lru_insert (hicn_pit_cs_t * p, hicn_hash_node_t * node,
- hicn_pcs_entry_t * pcs, hicn_cs_policy_t * policy_state)
+hicn_cs_lru_insert (hicn_pit_cs_t *p, hicn_hash_node_t *node,
+ hicn_pcs_entry_t *pcs, hicn_cs_policy_t *policy_state)
{
hicn_hash_node_t *lrunode;
hicn_pcs_entry_t *lrupcs;
@@ -56,7 +56,7 @@ hicn_cs_lru_insert (hicn_pit_cs_t * p, hicn_hash_node_t * node,
}
else
{
- ASSERT (policy_state->tail == 0); /* We think the list is
+ ASSERT (policy_state->tail == 0); /* We think the list is
* empty */
policy_state->head = policy_state->tail = idx;
@@ -68,26 +68,24 @@ hicn_cs_lru_insert (hicn_pit_cs_t * p, hicn_hash_node_t * node,
}
void
-hicn_cs_lru_delete_get (hicn_pit_cs_t * p, hicn_cs_policy_t * policy_state,
- hicn_hash_node_t ** nodep,
- hicn_pcs_entry_t ** pcs_entry,
- hicn_hash_entry_t ** hash_entry)
+hicn_cs_lru_delete_get (hicn_pit_cs_t *p, hicn_cs_policy_t *policy_state,
+ hicn_hash_node_t **nodep, hicn_pcs_entry_t **pcs_entry,
+ hicn_hash_entry_t **hash_entry)
{
*nodep = hicn_hashtb_node_from_idx (p->pcs_table, policy_state->tail);
*pcs_entry = hicn_pit_get_data (*nodep);
- *hash_entry = hicn_hashtb_get_entry (p->pcs_table, (*nodep)->entry_idx,
- (*nodep)->bucket_id,
- (*nodep)->hn_flags &
- HICN_HASH_NODE_OVERFLOW_BUCKET);
+ *hash_entry = hicn_hashtb_get_entry (
+ p->pcs_table, (*nodep)->entry_idx, (*nodep)->bucket_id,
+ (*nodep)->hn_flags & HICN_HASH_NODE_OVERFLOW_BUCKET);
}
/*
* Dequeue an LRU element, for example when it has expired.
*/
void
-hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
- hicn_pcs_entry_t * pcs, hicn_cs_policy_t * lru)
+hicn_cs_lru_dequeue (hicn_pit_cs_t *pit, hicn_hash_node_t *pnode,
+ hicn_pcs_entry_t *pcs, hicn_cs_policy_t *lru)
{
hicn_hash_node_t *lrunode;
hicn_pcs_entry_t *lrupcs;
@@ -95,8 +93,8 @@ hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
if (pcs->u.cs.cs_lru_prev != 0)
{
/* Not already on the head of the LRU */
- lrunode = hicn_hashtb_node_from_idx (pit->pcs_table,
- pcs->u.cs.cs_lru_prev);
+ lrunode =
+ hicn_hashtb_node_from_idx (pit->pcs_table, pcs->u.cs.cs_lru_prev);
lrupcs = hicn_pit_get_data (lrunode);
lrupcs->u.cs.cs_lru_next = pcs->u.cs.cs_lru_next;
@@ -111,8 +109,8 @@ hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
if (pcs->u.cs.cs_lru_next != 0)
{
/* Not already the end of the LRU */
- lrunode = hicn_hashtb_node_from_idx (pit->pcs_table,
- pcs->u.cs.cs_lru_next);
+ lrunode =
+ hicn_hashtb_node_from_idx (pit->pcs_table, pcs->u.cs.cs_lru_next);
lrupcs = hicn_pit_get_data (lrunode);
lrupcs->u.cs.cs_lru_prev = pcs->u.cs.cs_lru_prev;
@@ -133,8 +131,8 @@ hicn_cs_lru_dequeue (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
* Move a CS LRU element to the head, probably after it's been used.
*/
void
-hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
- hicn_pcs_entry_t * pcs, hicn_cs_policy_t * lru)
+hicn_cs_lru_update_head (hicn_pit_cs_t *pit, hicn_hash_node_t *pnode,
+ hicn_pcs_entry_t *pcs, hicn_cs_policy_t *lru)
{
if (pcs->u.cs.cs_lru_prev != 0)
{
@@ -146,7 +144,6 @@ hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
/* Now detached from the list; attach at head */
hicn_cs_lru_insert (pit, pnode, pcs, lru);
-
}
else
{
@@ -167,8 +164,8 @@ hicn_cs_lru_update_head (hicn_pit_cs_t * pit, hicn_hash_node_t * pnode,
* CS's limit. Return the number of removed nodes.
*/
int
-hicn_cs_lru_trim (hicn_pit_cs_t * pit, u32 * node_list, int sz,
- hicn_cs_policy_t * lru)
+hicn_cs_lru_trim (hicn_pit_cs_t *pit, u32 *node_list, int sz,
+ hicn_cs_policy_t *lru)
{
hicn_hash_node_t *lrunode;
hicn_pcs_entry_t *lrupcs;
@@ -214,8 +211,8 @@ hicn_cs_lru_trim (hicn_pit_cs_t * pit, u32 * node_list, int sz,
}
int
-hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs,
- hicn_cs_policy_t * state)
+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;
@@ -233,20 +230,19 @@ hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs,
lrupcs = hicn_pit_get_data (lrunode);
u64 hashval = 0;
- hicn_hashtb_fullhash ((u8 *) & (lrunode->hn_key.ks.key),
+ 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
+ // The bucket is in the non overflown
bucket = pitcs->pcs_table->ht_buckets + lrunode->bucket_id;
}
else
{
- bucket =
- pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets,
- lrunode->bucket_id);
+ 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]);
@@ -258,7 +254,6 @@ hicn_cs_lru_flush (vlib_main_t * vm, struct hicn_pit_cs_s *pitcs,
}
return (i);
-
}
/*
diff --git a/hicn-plugin/src/cache_policies/cs_lru.h b/hicn-plugin/src/cache_policies/cs_lru.h
index 3bd18060d..c939b45df 100644
--- a/hicn-plugin/src/cache_policies/cs_lru.h
+++ b/hicn-plugin/src/cache_policies/cs_lru.h
@@ -26,47 +26,40 @@
* This file implements the LRU policy for the CS
*/
-
extern hicn_cs_policy_vft_t hicn_cs_lru;
/*
* Insert a new CS element at the head of the CS LRU
*/
-void
-hicn_cs_lru_insert (hicn_pit_cs_t * pcs, hicn_hash_node_t * pnode,
- hicn_pcs_entry_t * entry, hicn_cs_policy_t * lru);
-
+void hicn_cs_lru_insert (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode,
+ hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru);
/*
* Dequeue an LRU element, for example when it has expired.
*/
-void
-hicn_cs_lru_dequeue (hicn_pit_cs_t * pcs, hicn_hash_node_t * pnode,
- hicn_pcs_entry_t * entry, hicn_cs_policy_t * lru);
+void hicn_cs_lru_dequeue (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode,
+ hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru);
/*
* Move a CS LRU element to the head, probably after it's been used.
*/
-void
-hicn_cs_lru_update_head (hicn_pit_cs_t * pcs, hicn_hash_node_t * pnode,
- hicn_pcs_entry_t * entry, hicn_cs_policy_t * lru);
+void hicn_cs_lru_update_head (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode,
+ hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru);
-void
-hicn_cs_lru_delete_get (hicn_pit_cs_t * p, hicn_cs_policy_t * policy,
- hicn_hash_node_t ** node, hicn_pcs_entry_t ** pcs,
- hicn_hash_entry_t ** hash_entry);
+void hicn_cs_lru_delete_get (hicn_pit_cs_t *p, hicn_cs_policy_t *policy,
+ hicn_hash_node_t **node, hicn_pcs_entry_t **pcs,
+ hicn_hash_entry_t **hash_entry);
/*
* Remove a batch of nodes from the CS LRU, copying their node indexes into
* the caller's array. We expect this is done when the LRU size exceeds the
* CS's limit. Return the number of removed nodes.
*/
-int hicn_cs_lru_trim (hicn_pit_cs_t * pcs, u32 * node_list, int sz,
- hicn_cs_policy_t * lru);
-
+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);
+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 0bf745915..505138943 100644
--- a/hicn-plugin/src/cache_policies/cs_policy.h
+++ b/hicn-plugin/src/cache_policies/cs_policy.h
@@ -24,7 +24,6 @@
* This file provides the needed structures to implement a CS policy
*/
-
/*
* Structure
*/
@@ -57,36 +56,34 @@ struct hicn_cs_policy_s;
*/
typedef struct hicn_cs_policy_vft_s
{
- void (*hicn_cs_insert) (struct hicn_pit_cs_s * p,
- struct hicn_hash_node_s * node,
- struct hicn_pcs_entry_s * pcs,
- hicn_cs_policy_t * policy);
-
- void (*hicn_cs_update) (struct hicn_pit_cs_s * p,
- struct hicn_hash_node_s * node,
- struct hicn_pcs_entry_s * pcs,
- hicn_cs_policy_t * policy);
-
- void (*hicn_cs_dequeue) (struct hicn_pit_cs_s * p,
- struct hicn_hash_node_s * node,
- struct hicn_pcs_entry_s * pcs,
- hicn_cs_policy_t * policy);
-
- void (*hicn_cs_delete_get) (struct hicn_pit_cs_s * p,
- hicn_cs_policy_t * policy,
- struct hicn_hash_node_s ** node,
- struct hicn_pcs_entry_s ** pcs,
- struct hicn_hash_entry_s ** hash_entry);
-
- 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);
+ void (*hicn_cs_insert) (struct hicn_pit_cs_s *p,
+ struct hicn_hash_node_s *node,
+ struct hicn_pcs_entry_s *pcs,
+ hicn_cs_policy_t *policy);
+
+ void (*hicn_cs_update) (struct hicn_pit_cs_s *p,
+ struct hicn_hash_node_s *node,
+ struct hicn_pcs_entry_s *pcs,
+ hicn_cs_policy_t *policy);
+
+ void (*hicn_cs_dequeue) (struct hicn_pit_cs_s *p,
+ struct hicn_hash_node_s *node,
+ struct hicn_pcs_entry_s *pcs,
+ hicn_cs_policy_t *policy);
+
+ void (*hicn_cs_delete_get) (struct hicn_pit_cs_s *p,
+ hicn_cs_policy_t *policy,
+ struct hicn_hash_node_s **node,
+ struct hicn_pcs_entry_s **pcs,
+ struct hicn_hash_entry_s **hash_entry);
+
+ 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;
-
-
#endif /* // __HICN_POLICY_H__ */
/*