summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/interest_hitpit_node.c
diff options
context:
space:
mode:
authorLuca Muscariello <lumuscar@cisco.com>2022-06-30 13:58:25 +0200
committerMauro Sardara <msardara@cisco.com>2022-07-01 12:11:33 +0200
commit012843b1c0bc0838e69085ed83a79ec8b6f97360 (patch)
tree4fa320673884488e4a1bf879ec144e99f134a3fb /hicn-plugin/src/interest_hitpit_node.c
parent6b94663b2455e212009a544ae23bb6a8c55407f8 (diff)
Revision and refactor of the VPP plugin with fixes for the
packet generator. Hash table for the packet cache has been changed with the bihash. Co-authored-by: Mauro Sardara <msardara@cisco.com> Signed-off-by: Luca Muscariello <muscariello@ieee.org> Change-Id: I0e0191a9f109d37081d32cc55d577ea43533f8c0 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'hicn-plugin/src/interest_hitpit_node.c')
-rw-r--r--hicn-plugin/src/interest_hitpit_node.c256
1 files changed, 115 insertions, 141 deletions
diff --git a/hicn-plugin/src/interest_hitpit_node.c b/hicn-plugin/src/interest_hitpit_node.c
index c98baf7e9..9715fc549 100644
--- a/hicn-plugin/src/interest_hitpit_node.c
+++ b/hicn-plugin/src/interest_hitpit_node.c
@@ -25,7 +25,6 @@
#include "strategy_dpo_manager.h"
#include "state.h"
#include "error.h"
-#include "face_db.h"
/* packet trace format function */
static u8 *hicn_interest_hitpit_format_trace (u8 *s, va_list *args);
@@ -48,11 +47,27 @@ static uword
hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
vlib_frame_t *frame)
{
+ int ret;
u32 n_left_from, *from, *to_next;
hicn_interest_hitpit_next_t next_index;
hicn_interest_hitpit_runtime_t *rt;
vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
f64 tnow;
+ u32 n_left_to_next;
+ vlib_buffer_t *b0;
+ u8 isv6;
+ u32 bi0;
+ u32 next0 = HICN_INTEREST_HITPIT_NEXT_ERROR_DROP;
+ const hicn_strategy_vft_t *strategy_vft0;
+ const hicn_dpo_vft_t *dpo_vft0;
+ u8 dpo_ctx_id0;
+ u8 found = 0;
+ hicn_face_id_t outfaces[MAX_OUT_FACES];
+ u32 clones[MAX_OUT_FACES];
+ u16 outfaces_len;
+ u32 pit_entry_index;
+ hicn_pcs_entry_t *pcs_entry = NULL;
+ hicn_buffer_t *hicnb0;
rt = vlib_node_get_runtime_data (vm, hicn_interest_hitpit_node.index);
@@ -69,35 +84,15 @@ hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
while (n_left_from > 0)
{
- u32 n_left_to_next;
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from > 0 && n_left_to_next > 0)
{
- vlib_buffer_t *b0;
- u8 isv6;
- u8 *nameptr;
- u16 namelen;
- u32 bi0;
- u32 next0 = HICN_INTEREST_HITPIT_NEXT_ERROR_DROP;
- hicn_hash_node_t *node0;
- const hicn_strategy_vft_t *strategy_vft0;
- const hicn_dpo_vft_t *dpo_vft0;
- hicn_pcs_entry_t *pitp;
- u8 dpo_ctx_id0;
- u8 found = 0;
- int nh_idx;
- hicn_face_id_t outfaces[MAX_OUT_FACES];
- u32 outfaces_len;
- hicn_hash_entry_t *hash_entry0;
- hicn_buffer_t *hicnb0;
-
/* Prefetch for next iteration. */
if (n_left_from > 1)
{
vlib_buffer_t *b1;
b1 = vlib_get_buffer (vm, from[1]);
CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, LOAD);
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES, STORE);
}
/* Dequeue a packet buffer */
@@ -112,163 +107,142 @@ hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
/* Get hicn buffer and state */
hicnb0 = hicn_get_buffer (b0);
- hicn_get_internal_state (hicnb0, rt->pitcs, &node0, &strategy_vft0,
- &dpo_vft0, &dpo_ctx_id0, &hash_entry0);
+ hicn_get_internal_state (hicnb0, &pit_entry_index, &strategy_vft0,
+ &dpo_vft0, &dpo_ctx_id0);
- hicn_buffer_get_name_and_namelen (b0, &nameptr, &namelen);
- isv6 = hicn_buffer_is_v6 (b0);
+ // Retrieve PIT entry
+ pcs_entry =
+ hicn_pcs_entry_get_entry_from_index (rt->pitcs, pit_entry_index);
- pitp = hicn_pit_get_data (node0);
- dpo_id_t hicn_dpo_id0 = { .dpoi_type =
- dpo_vft0->hicn_dpo_get_type (),
- .dpoi_proto = 0,
- .dpoi_next_node = 0,
- .dpoi_index = dpo_ctx_id0 };
+ isv6 = hicn_buffer_is_v6 (b0);
- /*
- * Check if the hit is instead a collision in the
- * hash table. Unlikely to happen.
- */
- if (PREDICT_FALSE (!hicn_node_compare (nameptr, namelen, node0)))
- {
- stats.interests_hash_collision++;
- /* Remove lock from the entry */
- hicn_pcs_remove_lock (rt->pitcs, &pitp, &node0, vm, hash_entry0,
- dpo_vft0, &hicn_dpo_id0);
- drop_packet (&next0);
+ // Increment packet counter
+ stats.pkts_processed += 1;
- goto end_processing;
- }
- /*
- * If the entry is expired, remove it no matter of
- * the possible cases.
- */
- if (tnow > pitp->shared.expire_time)
+ // If the entry is expired, remove it no matter of the possible
+ // cases.
+ if (tnow > hicn_pcs_entry_get_expire_time (pcs_entry))
{
+ // Notify strategy
strategy_vft0->hicn_on_interest_timeout (dpo_ctx_id0);
- hicn_pcs_delete (rt->pitcs, &pitp, &node0, vm, hash_entry0,
- dpo_vft0, &hicn_dpo_id0);
+
+ // Release lock on entry - this MUST delete the entry
+ hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry);
+
stats.pit_expired_count++;
+
+ // Forward to strategy node
+ // TODO this can be simplified by checking directly in the
+ // pcslookup node!
next0 = HICN_INTEREST_HITPIT_NEXT_STRATEGY;
}
else
{
- if ((hash_entry0->he_flags & HICN_HASH_ENTRY_FLAG_CS_ENTRY))
+ // A data packet may have arrived in the time between the pcs
+ // lookup and now. Check again to make sure the entry is CS or
+ // PIT
+ if (hicn_pcs_entry_is_cs (pcs_entry))
{
next0 = HICN_INTEREST_HITPIT_NEXT_INTEREST_HITCS;
}
else
{
- /*
- * Distinguish between aggregation or
- * retransmission
- */
-
+ // Distinguish between aggregation or retransmission
found =
- hicn_face_search (hicnb0->face_id, &(pitp->u.pit.faces));
+ hicn_pcs_entry_pit_search (pcs_entry, hicnb0->face_id);
if (found)
{
+ // Retransmission
strategy_vft0->hicn_select_next_hop (
- dpo_ctx_id0, &nh_idx, outfaces, &outfaces_len);
- /* Retransmission */
- /*
- * Prepare the packet for the
- * forwarding
- */
- if (outfaces_len == 1)
- {
- next0 = isv6 ?
- HICN_INTEREST_HITPIT_NEXT_FACE6_OUTPUT :
- HICN_INTEREST_HITPIT_NEXT_FACE4_OUTPUT;
- vnet_buffer (b0)->ip.adj_index[VLIB_TX] =
- outfaces[0];
+ dpo_ctx_id0, outfaces, &outfaces_len);
- /*
- * Update the egress face in
- * the PIT
- */
- pitp->u.pit.pe_txnh = nh_idx;
- stats.interests_retx++;
+ // Prepare the packet for the forwarding
+ next0 = isv6 ? HICN_INTEREST_HITPIT_NEXT_FACE6_OUTPUT :
+ HICN_INTEREST_HITPIT_NEXT_FACE4_OUTPUT;
+
+ // Update stats
+ stats.interests_retx += outfaces_len;
+
+ // Clone interest if needed
+ if (outfaces_len > 1)
+ {
+ ret = vlib_buffer_clone (vm, bi0, clones,
+ (u16) outfaces_len,
+ CLIB_CACHE_LINE_BYTES * 2);
+ ASSERT (ret == outfaces_len);
}
else
{
- // restore pointers
- to_next -= 1;
- n_left_to_next += 1;
- u32 clones[outfaces_len];
- int ret =
- vlib_buffer_clone (vm, bi0, clones, outfaces_len,
- CLIB_CACHE_LINE_BYTES * 2);
- ASSERT (ret == outfaces_len);
- for (u32 nh = 0; nh < outfaces_len; nh++)
+ clones[0] = bi0;
+ }
+
+ // We need to clone the packet over multiple output
+ // faces
+
+ // Restore pointers
+ to_next -= 1;
+ n_left_to_next += 1;
+
+ for (u32 nh = 0; nh < outfaces_len; nh++)
+ {
+ vlib_buffer_t *local_b0 =
+ vlib_get_buffer (vm, clones[nh]);
+ to_next[0] = clones[nh];
+ to_next += 1;
+ n_left_to_next -= 1;
+
+ vnet_buffer (local_b0)->ip.adj_index[VLIB_TX] =
+ outfaces[nh];
+
+ /* Maybe trace */
+ if (PREDICT_FALSE (
+ (node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (local_b0->flags & VLIB_BUFFER_IS_TRACED)))
{
- vlib_buffer_t *local_b0 =
- vlib_get_buffer (vm, clones[nh]);
- to_next[0] = clones[nh];
- to_next += 1;
- n_left_to_next -= 1;
-
- next0 =
- isv6 ? HICN_INTEREST_HITPIT_NEXT_FACE6_OUTPUT :
- HICN_INTEREST_HITPIT_NEXT_FACE4_OUTPUT;
- vnet_buffer (local_b0)->ip.adj_index[VLIB_TX] =
- outfaces[nh];
- stats.interests_retx++;
-
- /* Maybe trace */
- if (PREDICT_FALSE (
- (node->flags & VLIB_NODE_FLAG_TRACE) &&
- (local_b0->flags & VLIB_BUFFER_IS_TRACED)))
- {
- hicn_interest_hitpit_trace_t *t =
- vlib_add_trace (vm, node, local_b0,
- sizeof (*t));
- t->pkt_type = HICN_PACKET_TYPE_INTEREST;
- t->sw_if_index = vnet_buffer (local_b0)
- ->sw_if_index[VLIB_RX];
- t->next_index = next0;
- }
-
- /*
- * Verify speculative enqueue, maybe switch
- * current next frame
- */
- vlib_validate_buffer_enqueue_x1 (
- vm, node, next_index, to_next, n_left_to_next,
- clones[nh], next0);
+ hicn_interest_hitpit_trace_t *t =
+ vlib_add_trace (vm, node, local_b0,
+ sizeof (*t));
+ t->pkt_type = HICN_PACKET_TYPE_INTEREST;
+ t->sw_if_index =
+ vnet_buffer (local_b0)->sw_if_index[VLIB_RX];
+ t->next_index = next0;
}
- continue;
+
+ /*
+ * Verify speculative enqueue, maybe switch
+ * current next frame
+ */
+ vlib_validate_buffer_enqueue_x1 (
+ vm, node, next_index, to_next, n_left_to_next,
+ clones[nh], next0);
}
+ continue;
}
else
{
- hicn_face_db_add_face (hicnb0->face_id,
- &pitp->u.pit.faces);
+ // Aggregation
+ hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id);
/* Aggregation */
drop_packet (&next0);
stats.interests_aggregated++;
+
+ /* Maybe trace */
+ if (PREDICT_FALSE (
+ (node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ hicn_interest_hitpit_trace_t *t =
+ vlib_add_trace (vm, node, b0, sizeof (*t));
+ t->pkt_type = HICN_PACKET_TYPE_INTEREST;
+ t->sw_if_index =
+ vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ t->next_index = next0;
+ }
}
- /* Remove lock from the entry */
- hicn_pcs_remove_lock (rt->pitcs, &pitp, &node0, vm,
- hash_entry0, dpo_vft0, &hicn_dpo_id0);
}
}
- end_processing:
-
- /* Maybe trace */
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
- (b0->flags & VLIB_BUFFER_IS_TRACED)))
- {
- hicn_interest_hitpit_trace_t *t =
- vlib_add_trace (vm, node, b0, sizeof (*t));
- t->pkt_type = HICN_PACKET_TYPE_INTEREST;
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- t->next_index = next0;
- }
- /* Incr packet counter */
- stats.pkts_processed += 1;
/*
* Verify speculative enqueue, maybe switch current
@@ -279,7 +253,7 @@ hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- u32 pit_int_count = hicn_pit_get_int_count (rt->pitcs);
+ u32 pit_int_count = hicn_pcs_get_pit_count (rt->pitcs);
vlib_node_increment_counter (vm, hicn_interest_hitpit_node.index,
HICNFWD_ERROR_PROCESSED, stats.pkts_processed);