Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
state.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 __HICN_STATE__
17 #define __HICN_STATE__
18 
19 #include <netinet/in.h>
20 #include <vnet/buffer.h>
21 
22 #include "hicn.h"
23 #include "pcs.h"
24 #include "hashtb.h"
25 #include "strategy.h"
26 #include "strategy_dpo_ctx.h"
27 #include "strategy_dpo_manager.h"
28 
37 // TODO exploit this state to prefetch hash nodes and entries.
38 
53 always_inline void
55  hicn_hash_node_t **node,
56  const hicn_strategy_vft_t **strategy_vft,
57  const hicn_dpo_vft_t **dpo_vft, u8 *dpo_ctx_id,
58  hicn_hash_entry_t **hash_entry)
59 {
60  *node = pool_elt_at_index (pitcs->pcs_table->ht_nodes, hicnb->node_id);
61  *strategy_vft = hicn_dpo_get_strategy_vft (hicnb->vft_id);
62  *dpo_vft = hicn_dpo_get_vft (hicnb->vft_id);
63  *dpo_ctx_id = hicnb->dpo_ctx_id;
64 
65  hicn_hash_bucket_t *bucket;
66  if (hicnb->hash_bucket_flags & HICN_HASH_NODE_OVERFLOW_BUCKET)
67  bucket = pool_elt_at_index (pitcs->pcs_table->ht_overflow_buckets,
68  hicnb->bucket_id);
69  else
70  bucket =
71  (hicn_hash_bucket_t *) (pitcs->pcs_table->ht_buckets + hicnb->bucket_id);
72 
73  *hash_entry = &(bucket->hb_entries[hicnb->hash_entry_id]);
74 }
75 
76 /*
77  * This function set the PCS entry index, the dpo index and the vft index in
78  * the opaque2 buffer. In this way, the interest-hitpit and interest-hitcs
79  * nodes can prefetch the corresponding state (PIT entry, dpo_ctx and the
80  * strategy vft
81  */
96 always_inline void
97 hicn_store_internal_state (vlib_buffer_t *b, u64 name_hash, u32 node_id,
98  u8 dpo_ctx_id, u8 vft_id, u8 hash_entry_id,
99  u32 bucket_id, u8 bucket_is_overflow)
100 {
101  hicn_buffer_t *hicnb = hicn_get_buffer (b);
102  hicnb->name_hash = name_hash;
103  hicnb->node_id = node_id;
104  hicnb->dpo_ctx_id = dpo_ctx_id;
105  hicnb->vft_id = vft_id;
106  hicnb->hash_entry_id = hash_entry_id;
107  hicnb->bucket_id = bucket_id;
108  hicnb->hash_bucket_flags =
109  HICN_HASH_NODE_OVERFLOW_BUCKET * bucket_is_overflow;
110 }
111 
112 #endif /* // __HICN_STATE__ */
113 
114 /*
115  * fd.io coding-style-patch-verification: ON
116  *
117  * Local Variables: eval: (c-set-style "gnu") End:
118  */
strategy.h
strategy_dpo_manager.h
hicn.h
hicn_pit_cs_s
Definition: pcs.h:143
hicn_dpo_get_strategy_vft
const hicn_strategy_vft_t * hicn_dpo_get_strategy_vft(dpo_type_t vfts_id)
Get the vft with the hICN strategy functions.
hashtb.h
hicn_buffer_t
Definition: api.h:65
strategy_dpo_ctx.h
hicn_store_internal_state
always_inline void hicn_store_internal_state(vlib_buffer_t *b, u64 name_hash, u32 node_id, u8 dpo_ctx_id, u8 vft_id, u8 hash_entry_id, u32 bucket_id, u8 bucket_is_overflow)
Store the hicn state in the hicn buffer.
Definition: state.h:97
hicn_dpo_get_vft
const hicn_dpo_vft_t * hicn_dpo_get_vft(dpo_type_t vfts_id)
Get the vft to manage the dpo context.
hicn_dpo_vft_s
Definition of the virtual function table for a hICN DPO.
Definition: strategy_dpo_manager.h:45
hicn_get_internal_state
always_inline void hicn_get_internal_state(hicn_buffer_t *hicnb, hicn_pit_cs_t *pitcs, hicn_hash_node_t **node, const hicn_strategy_vft_t **strategy_vft, const hicn_dpo_vft_t **dpo_vft, u8 *dpo_ctx_id, hicn_hash_entry_t **hash_entry)
Retrieve the hicn state.
Definition: state.h:54
hicn_strategy_vft_s
Definition: strategy.h:50
pcs.h