Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
cs_lru.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __LRU_H__
17 #define __LRU_H__
18 
19 #include "../pcs.h"
20 #include "../hashtb.h"
21 #include "cs_policy.h"
22 
29 extern hicn_cs_policy_vft_t hicn_cs_lru;
30 
31 /*
32  * Insert a new CS element at the head of the CS LRU
33  */
34 void hicn_cs_lru_insert (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode,
35  hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru);
36 
37 /*
38  * Dequeue an LRU element, for example when it has expired.
39  */
40 void hicn_cs_lru_dequeue (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode,
41  hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru);
42 
43 /*
44  * Move a CS LRU element to the head, probably after it's been used.
45  */
46 void hicn_cs_lru_update_head (hicn_pit_cs_t *pcs, hicn_hash_node_t *pnode,
47  hicn_pcs_entry_t *entry, hicn_cs_policy_t *lru);
48 
49 void hicn_cs_lru_delete_get (hicn_pit_cs_t *p, hicn_cs_policy_t *policy,
50  hicn_hash_node_t **node, hicn_pcs_entry_t **pcs,
51  hicn_hash_entry_t **hash_entry);
52 
53 /*
54  * Remove a batch of nodes from the CS LRU, copying their node indexes into
55  * the caller's array. We expect this is done when the LRU size exceeds the
56  * CS's limit. Return the number of removed nodes.
57  */
58 int hicn_cs_lru_trim (hicn_pit_cs_t *pcs, u32 *node_list, int sz,
59  hicn_cs_policy_t *lru);
60 
61 int hicn_cs_lru_flush (vlib_main_t *vm, struct hicn_pit_cs_s *pitcs,
62  hicn_cs_policy_t *state);
63 #endif /* // __LRU_H__ */
64 
65 /*
66  * fd.io coding-style-patch-verification: ON
67  *
68  * Local Variables: eval: (c-set-style "gnu") End:
69  */
hicn_pcs_entry_s
Definition: pcs.h:128
hicn_pit_cs_s
Definition: pcs.h:143
hicn_cs_policy_s
Definition: cs_policy.h:30
cs_policy.h
hicn_cs_policy_vft_s
Definition of the virtual functin table for a cache policy.
Definition: cs_policy.h:57