summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/pcs.h
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-05-24 16:33:56 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-05-24 16:37:37 +0200
commit2e1756de877df622680b05be421cb27a884db167 (patch)
tree352a1091836dcc28713846b2be269b639cb9bdf5 /hicn-plugin/src/pcs.h
parentddde35131f8a4dbd13068b8233d417518ae75f8f (diff)
[HICN-197] Supporting multiple local faces for the same prefix. Fixed buffer deallocation when data are pushed from the application.
Change-Id: Ibc9625e420d0c8579be3d7f1310a08a5e37f765a Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src/pcs.h')
-rw-r--r--hicn-plugin/src/pcs.h66
1 files changed, 56 insertions, 10 deletions
diff --git a/hicn-plugin/src/pcs.h b/hicn-plugin/src/pcs.h
index b9b40a3fb..491476221 100644
--- a/hicn-plugin/src/pcs.h
+++ b/hicn-plugin/src/pcs.h
@@ -113,7 +113,7 @@ typedef struct __attribute__ ((packed)) hicn_cs_entry_s
u32 cs_lru_next;
/* Reserved for implementing cache policy different than LRU */
- /* 40B + 56B = 96B */
+ /* 40B + (64 - 40)B = 64B */
u8 opaque[HICN_CS_ENTRY_OPAQUE_SIZE];
@@ -174,7 +174,7 @@ hicn_pit_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
always_inline void
hicn_pcs_cs_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
- hicn_pcs_entry_t * entry, hicn_hash_node_t * node);
+ hicn_pcs_entry_t * old_entry, hicn_pcs_entry_t * entry, hicn_hash_node_t * node);
always_inline void
hicn_pcs_cs_delete (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
@@ -196,7 +196,7 @@ hicn_pcs_cs_insert_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
hicn_hash_entry_t ** hash_entry, u64 hashval,
u32 * node_id, u8 * dpo_ctx_id, u8 * vft_id,
u8 * is_cs, u8 * hash_entry_id, u32 * bucket_id,
- u8 * bucket_is_overflow);
+ u8 * bucket_is_overflow, dpo_id_t * inface);
always_inline int
hicn_pcs_pit_insert (hicn_pit_cs_t * pitcs, hicn_pcs_entry_t * entry,
@@ -356,7 +356,8 @@ hicn_pcs_delete_internal (hicn_pit_cs_t * pitcs,
if (hash_entry->he_flags & HICN_HASH_ENTRY_FLAG_CS_ENTRY)
{
pitcs->pcs_cs_dealloc++;
-
+ vlib_buffer_t *b0 = vlib_get_buffer (vm, pcs->u.cs.cs_pkt_buf);
+ ASSERT(b0->ref_count == 1);
/* Free any associated packet buffer */
vlib_buffer_free_one (vm, pcs->u.cs.cs_pkt_buf);
pcs->u.cs.cs_pkt_buf = ~0;
@@ -449,12 +450,12 @@ hicn_pit_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
always_inline void
hicn_pcs_cs_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
- hicn_pcs_entry_t * entry, hicn_hash_node_t * node)
+ hicn_pcs_entry_t * old_entry, hicn_pcs_entry_t * entry, hicn_hash_node_t * node)
{
hicn_cs_policy_t *policy_state;
hicn_cs_policy_vft_t *policy_vft;
- dpo_id_t *face_dpo = (dpo_id_t *) & (entry->u.cs.cs_rxface);
+ dpo_id_t *face_dpo = (dpo_id_t *) & (old_entry->u.cs.cs_rxface);
policy_state = &pitcs->policy_state;
policy_vft = &pitcs->policy_vft;
@@ -468,8 +469,45 @@ hicn_pcs_cs_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
policy_vft = &prod_face->policy_vft;
}
}
- /* Update the CS LRU, moving this item to the head */
- policy_vft->hicn_cs_update (pitcs, node, entry, policy_state);
+
+ if (dpo_cmp(&entry->u.cs.cs_rxface, &old_entry->u.cs.cs_rxface) !=0)
+ {
+ /* Dequeue content from the old queue */
+ policy_vft->hicn_cs_dequeue(pitcs, node, old_entry, policy_state);
+
+ dpo_copy(&old_entry->u.cs.cs_rxface, &entry->u.cs.cs_rxface);
+ face_dpo = (dpo_id_t *) & (old_entry->u.cs.cs_rxface);
+ policy_state = &pitcs->policy_state;
+ policy_vft = &pitcs->policy_vft;
+
+ if (face_dpo->dpoi_type == hicn_face_ip_type)
+ {
+ hicn_face_t *face = hicn_dpoi_get_from_idx (face_dpo->dpoi_index);
+ if (face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD)
+ {
+ hicn_face_prod_t *prod_face = (hicn_face_prod_t *) face->data;
+ policy_state = &prod_face->policy;
+ policy_vft = &prod_face->policy_vft;
+ }
+ }
+
+ policy_vft->hicn_cs_insert (pitcs, node, old_entry, policy_state);
+
+ if (policy_state->count > policy_state->max)
+ {
+ hicn_hash_node_t *node;
+ hicn_pcs_entry_t *pcs_entry;
+ hicn_hash_entry_t *hash_entry;
+ policy_vft->hicn_cs_delete_get (pitcs, policy_state,
+ &node, &pcs_entry, &hash_entry);
+
+ hicn_pcs_cs_delete (vm, pitcs, &pcs_entry, &node, hash_entry, NULL,
+ NULL);
+ }
+ }
+ else
+ /* Update the CS LRU, moving this item to the head */
+ policy_vft->hicn_cs_update (pitcs, node, old_entry, policy_state);
}
always_inline void
@@ -534,6 +572,11 @@ hicn_pcs_cs_insert (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
if (PREDICT_TRUE (ret == HICN_ERROR_NONE))
{
+ /* Mark the entry as a CS entry */
+ node->hn_flags |= HICN_HASH_NODE_CS_FLAGS;
+ entry->shared.entry_flags |= HICN_PCS_ENTRY_CS_FLAG;
+ (*hash_entry)->he_flags |= HICN_HASH_ENTRY_FLAG_CS_ENTRY;
+
hicn_cs_policy_t *policy_state;
hicn_cs_policy_vft_t *policy_vft;
@@ -579,12 +622,13 @@ hicn_pcs_cs_insert_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
hicn_hash_entry_t ** hash_entry, u64 hashval,
u32 * node_id, u8 * dpo_ctx_id, u8 * vft_id,
u8 * is_cs, u8 * hash_entry_id, u32 * bucket_id,
- u8 * bucket_is_overflow)
+ u8 * bucket_is_overflow, dpo_id_t * inface)
{
int ret;
ASSERT (entry == hicn_hashtb_node_data (node));
+ entry->u.cs.cs_rxface = *inface;
ret =
hicn_pcs_cs_insert (vm, pitcs, entry, node, hash_entry, hashval, node_id,
dpo_ctx_id, vft_id, is_cs, hash_entry_id, bucket_id,
@@ -605,8 +649,10 @@ hicn_pcs_cs_insert_update (vlib_main_t * vm, hicn_pit_cs_t * pitcs,
pitp->shared.create_time = entry->shared.create_time;
pitp->shared.expire_time = entry->shared.expire_time;
pitp->u.cs.cs_pkt_buf = entry->u.cs.cs_pkt_buf;
- hicn_pcs_cs_update (vm, pitcs, pitp, existing_node);
+
+ hicn_pcs_cs_update (vm, pitcs, pitp, entry, existing_node);
}
+
return (ret);
}