summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-04-11 18:54:52 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-04-11 19:02:05 +0200
commitd75c88d2c066e7886cf0bc4ebeceee073588b750 (patch)
tree26e0722f0adad8ec0e33cc788f8b2106e8b342b4 /hicn-plugin/src
parente3533af73ab35a66530292f698b3e2a8fff2d80d (diff)
[HICN-176] Fixed bitmap size in pit entry and added static assert to avoid misconfiguration of parameters in param.h
Change-Id: Ia64eaebe267f87bd5f93abf3e5a9e80bab735765 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src')
-rw-r--r--hicn-plugin/src/data_fwd_node.c4
-rw-r--r--hicn-plugin/src/data_pcslookup_node.c2
-rw-r--r--hicn-plugin/src/data_push_node.c13
-rw-r--r--hicn-plugin/src/face_db.h16
-rw-r--r--hicn-plugin/src/faces/face.c2
-rw-r--r--hicn-plugin/src/params.h8
-rw-r--r--hicn-plugin/src/vface_db.h155
7 files changed, 34 insertions, 166 deletions
diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c
index f7c8ae70b..efb98164d 100644
--- a/hicn-plugin/src/data_fwd_node.c
+++ b/hicn-plugin/src/data_fwd_node.c
@@ -168,7 +168,8 @@ hicn_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
* not changed from the lookup.
*/
- if (tnow > pitp->shared.expire_time)
+ if (tnow > pitp->shared.expire_time
+ || (hash_entry0->he_flags & HICN_HASH_ENTRY_FLAG_DELETED))
{
dpo_id_t hicn_dpo_id0 =
{ dpo_vft0->hicn_dpo_get_type (), 0, 0, dpo_ctx_id0 };
@@ -503,6 +504,7 @@ hicn_satisfy_faces (vlib_main_t * vm, u32 bi0,
*n_left_to_next -= 1;
n_left_from -= 1;
clones += 1;
+
next0 = face0->dpoi_next_node;
vnet_buffer (h0)->ip.adj_index[VLIB_TX] = face0->dpoi_index;
diff --git a/hicn-plugin/src/data_pcslookup_node.c b/hicn-plugin/src/data_pcslookup_node.c
index 0a5793056..aeb8c2276 100644
--- a/hicn-plugin/src/data_pcslookup_node.c
+++ b/hicn-plugin/src/data_pcslookup_node.c
@@ -72,7 +72,7 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 next0 = HICN_DATA_PCSLOOKUP_NEXT_ERROR_DROP;
u64 name_hash = 0;
hicn_name_t name;
- hicn_header_t *hicn0;
+ hicn_header_t *hicn0 = NULL;
u32 node_id0 = 0;
u8 dpo_ctx_id0 = 0;
int ret0;
diff --git a/hicn-plugin/src/data_push_node.c b/hicn-plugin/src/data_push_node.c
index b955a765d..8f9e137f7 100644
--- a/hicn-plugin/src/data_push_node.c
+++ b/hicn-plugin/src/data_push_node.c
@@ -54,7 +54,6 @@ typedef struct
u32 next_index;
u32 sw_if_index;
u8 pkt_type;
- u8 packet_data[40];
} hicn_data_push_trace_t;
vlib_node_registration_t hicn_data_push_node;
@@ -250,6 +249,17 @@ hicn_data_push_fn (vlib_main_t * vm,
nameptr, namelen, isv6);
stats.pkts_data_count++;
}
+
+ /* Maybe trace */
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ hicn_data_push_trace_t *t =
+ vlib_add_trace (vm, node, b0, sizeof (*t));
+ t->pkt_type = HICN_PKT_TYPE_CONTENT;
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ t->next_index = HICN_DATA_PUSH_NEXT_ERROR_DROP;
+ }
}
to_forward -= n_to_forward;
@@ -266,6 +276,7 @@ hicn_data_push_fn (vlib_main_t * vm,
to_next++;
n_left_to_next--;
}
+
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
diff --git a/hicn-plugin/src/face_db.h b/hicn-plugin/src/face_db.h
index 5c95be334..c3308050a 100644
--- a/hicn-plugin/src/face_db.h
+++ b/hicn-plugin/src/face_db.h
@@ -30,18 +30,16 @@
/* Must be power of two */
#define HICN_FACE_DB_INLINE_FACES 4
-#define HICN_PIT_BITMAP_SIZE_BYTE (HICN_PARAM_FACES_MAX / 8)
+#define HICN_PIT_BITMAP_SIZE_BYTE HICN_PARAM_FACES_MAX/8
#define HICN_PIT_N_HOP_BITMAP_SIZE HICN_PARAM_FACES_MAX
#define HICN_PIT_N_HOP_BUCKET (HICN_PARAM_PIT_ENTRY_PHOPS_MAX - HICN_FACE_DB_INLINE_FACES)
-typedef struct __attribute__ ((packed)) hicn_face_bucket_s
+typedef struct hicn_face_bucket_s
{
/* Array of indexes of virtual faces */
dpo_id_t faces[HICN_PIT_N_HOP_BUCKET];
- CLIB_CACHE_LINE_ALIGN_MARK (cache_line1);
-
/* Used to check if interests are retransmission */
u8 bitmap[HICN_PIT_BITMAP_SIZE_BYTE];
@@ -116,7 +114,10 @@ hicn_face_db_add_face_dpo (dpo_id_t * dpo, hicn_face_db_t * face_db)
dpo_lock (dpo);
u32 bitmap_index = dpo->dpoi_index % HICN_PIT_N_HOP_BITMAP_SIZE;
- faces_bkt->bitmap[bitmap_index] |= 0x01;
+ u32 position_array = bitmap_index / 8;
+ u8 bit_index = (u8) (bitmap_index - position_array * 8);
+
+ faces_bkt->bitmap[position_array] |= (0x01 << bit_index);
face_db->n_faces++;
}
@@ -127,7 +128,10 @@ hicn_face_search (dpo_id_t * dpo, hicn_face_db_t * face_db)
pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket);
u32 bitmap_index = dpo->dpoi_index % HICN_PIT_N_HOP_BITMAP_SIZE;
- return faces_bkt->bitmap[bitmap_index] & 0x01;
+ u32 position_array = bitmap_index / 8;
+ u8 bit_index = bitmap_index - position_array * 8;
+
+ return (faces_bkt->bitmap[position_array] >> bit_index) & 0x01;
}
always_inline void
diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c
index 3be42a77f..68d2ba01c 100644
--- a/hicn-plugin/src/faces/face.c
+++ b/hicn-plugin/src/faces/face.c
@@ -85,7 +85,7 @@ hicn_face_module_init (vlib_main_t * vm)
hicn_iface_ip_init (vm);
hicn_face_udp_init (vm);
hicn_iface_udp_init (vm);
- vec_alloc (counters, 40);
+ counters = vec_new (vlib_combined_counter_main_t, HICN_PARAM_FACES_MAX);
}
u8 *
diff --git a/hicn-plugin/src/params.h b/hicn-plugin/src/params.h
index f3af714ec..1ca9ba08b 100644
--- a/hicn-plugin/src/params.h
+++ b/hicn-plugin/src/params.h
@@ -16,6 +16,8 @@
#ifndef __HICN_PARAM_H__
#define __HICN_PARAM_H__
+#include <math.h>
+
/*
* Features
*/
@@ -50,9 +52,13 @@ STATIC_ASSERT ((HICN_PARAM_FACES_MAX & (HICN_PARAM_FACES_MAX - 1)) == 0,
// aggregation limit(interest previous hops)
// Supported up to 516. For more than 4 faces this param must
-// satisfy the equation (HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4) % 2 = 0
+// HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4 must be a power of two
#define HICN_PARAM_PIT_ENTRY_PHOPS_MAX 20
+STATIC_ASSERT ((ceil (log2 ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4)))) ==
+ (floor (log2 ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4)))),
+ "HICN_PARAM_PIT_ENTRY_PHOPS_MAX - 4 must be a power of two");
+
STATIC_ASSERT ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX <= HICN_PARAM_FACES_MAX),
"HICN_PARAM_PIT_ENTRY_PHOP_MAX must be <= than HICN_PARAM_FACES_MAX");
diff --git a/hicn-plugin/src/vface_db.h b/hicn-plugin/src/vface_db.h
deleted file mode 100644
index b98a2f46d..000000000
--- a/hicn-plugin/src/vface_db.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HICN_FACE_DB_H__
-#define __HICN_FACE_DB_H__
-
-#include <vnet/dpo/dpo.h>
-#include "faces/face.h"
-
-/* Must be power of two*/
-#define HICN_FACE_DB_INLINE_FACES 4
-
-#define HICN_PIT_N_HOP_BITMAP_SIZE HICN_PARAM_PIT_ENTRY_PHOPS_MAX
-
-#define HICN_PIT_N_HOP_BUCKET (HICN_PARAM_PIT_ENTRY_PHOPS_MAX - HICN_FACE_DB_INLINE_FACES)
-
-STATIC_ASSERT ((HICN_PIT_N_HOP_BUCKET & (HICN_PIT_N_HOP_BUCKET - 1)) == 0,
- "HICN_PARAM_PIT_ENTRY_PHOP_MAX must be a power of 2 + 4");
-
-/* Takes 2 cache lines */
-typedef struct __attribute__ ((packed)) hicn_face_bucket_s
-{
- /* Array of indexes of virtual faces */
- dpo_id_t faces[HICN_PIT_N_HOP_BUCKET];
-
- CLIB_CACHE_LINE_ALIGN_MARK (cache_line1);
-
- /* Used to check if interests are retransmission */
- /* How much are we gaining (performance)/wasting (memory) wrt the linear */
- /* search on the array of faces? */
- u8 bitmap[HICN_PIT_N_HOP_BITMAP_SIZE];
-
-} hicn_face_bucket_t;
-
-extern hicn_face_bucket_t *hicn_face_bucket_pool;
-
-/*
- * Virtual faces will be stored in a pool and when a virtual face is created and
- * its index will be saved in the pit entry. In case of interest aggregation we
- * have to look on all the virtual faces to understand if there is a duplicated
- * interest
- */
-typedef struct __attribute__ ((packed)) hicn_face_db_s
-{
- /* 19B + 1B = 20B */
- /* Equal to one or zero */
- u8 is_overflow;
-
- /* Number of faces in the last bucket */
- /* Or next availabe entry for storing a dpo_id_t */
- /* 20B + 4B = 24B */
- u32 n_faces;
-
- /* 24B + 32B (8*4) = 56B */
- /* Array of indexes of virtual faces */
- dpo_id_t inline_faces[HICN_FACE_DB_INLINE_FACES];
-
- /* 56B + 4B = 60B */
- u32 next_bucket;
-
- /* 60B + 4B = 64B */
- u32 align; //align back to 64
-
-} hicn_face_db_t;
-
-//STATIC_ASSERT(HICN_PIT_N_HOP_BITMAP_SIZE <= (HICN_PARAM_PIT_ENTRY_PHOPS_MAX/8));
-
-always_inline dpo_id_t *
-hicn_face_db_get_dpo_face (u32 index, hicn_face_db_t * face_db)
-{
- ASSERT (index < face_db->n_faces);
-
- return index < HICN_FACE_DB_INLINE_FACES ? &(face_db->inline_faces[index]) :
- &(pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket)->faces
- [(index - HICN_FACE_DB_INLINE_FACES) & (HICN_PIT_N_HOP_BUCKET - 1)]);
-}
-
-always_inline void
-hicn_face_db_init (int max_element)
-{
- pool_init_fixed (hicn_face_bucket_pool, max_element);
-}
-
-always_inline hicn_face_bucket_t *
-hicn_face_db_get_bucket (u32 bucket_index)
-{
- return pool_elt_at_index (hicn_face_bucket_pool, bucket_index);
-}
-
-always_inline void
-hicn_face_db_add_face_dpo (dpo_id_t * dpo, hicn_face_db_t * face_db)
-{
- ASSERT (dpo->dpoi_index != ~0);
-
- hicn_face_bucket_t *faces_bkt =
- pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket);
- dpo_id_t *face =
- face_db->n_faces <
- HICN_FACE_DB_INLINE_FACES ? &(face_db->inline_faces[face_db->n_faces]) :
- &(faces_bkt->faces
- [(face_db->n_faces -
- HICN_FACE_DB_INLINE_FACES) & (HICN_PIT_N_HOP_BUCKET - 1)]);
-
- clib_memcpy (face, dpo, sizeof (dpo_id_t));
-
- /* This access the dpoi to increase the lock */
- dpo_lock (dpo);
-
- u32 bitmap_index = dpo->dpoi_index % HICN_PIT_N_HOP_BITMAP_SIZE;
- faces_bkt->bitmap[bitmap_index] |= 0x01;
- face_db->n_faces++;
-}
-
-always_inline u8
-hicn_face_search (dpo_id_t * dpo, hicn_face_db_t * face_db)
-{
- hicn_face_bucket_t *faces_bkt =
- pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket);
- u32 bitmap_index = dpo->dpoi_index % HICN_PIT_N_HOP_BITMAP_SIZE;
-
- return faces_bkt->bitmap[bitmap_index] & 0x01;
-}
-
-always_inline void
-hicn_faces_flush (hicn_face_db_t * face_db)
-{
- hicn_face_bucket_t *faces_bkt =
- pool_elt_at_index (hicn_face_bucket_pool, face_db->next_bucket);
- clib_memset_u64 (&(faces_bkt->bitmap), 0, HICN_PIT_N_HOP_BITMAP_SIZE / 8);
- face_db->n_faces = 0;
- pool_put_index (hicn_face_bucket_pool, face_db->next_bucket);
-}
-
-
-#endif // __HICN_FACE_DB_H__
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */