aboutsummaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-11-01 01:26:01 +0100
committerDamjan Marion <damarion@cisco.com>2016-11-01 01:28:00 +0100
commiteb90b7fbc1a64b7eeec0466f52a43dd8e6d8c8c5 (patch)
tree46a7e49769ca604f6a9cc3df86f619946968d313 /vlib
parentd5c9d6f30aa37ea8d7fdf8a79d3ab4c2e67d3249 (diff)
node: ensure that vlib_node_runtime_t is cacheline sized
Change-Id: Ib14ba63d09212a172fe52b01131404bf50cc494d Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/node.c5
-rw-r--r--vlib/vlib/node.h7
-rw-r--r--vlib/vlib/node_funcs.h4
3 files changed, 9 insertions, 7 deletions
diff --git a/vlib/vlib/node.c b/vlib/vlib/node.c
index 69bb07f6e41..fccc37ab7b9 100644
--- a/vlib/vlib/node.c
+++ b/vlib/vlib/node.c
@@ -433,7 +433,10 @@ register_node (vlib_main_t * vm, vlib_node_registration_t * r)
for (i = 0; i < vec_len (rt->errors); i++)
rt->errors[i] = vlib_error_set (n->index, i);
- ASSERT (vec_len (n->runtime_data) <= sizeof (rt->runtime_data));
+ ASSERT (sizeof (vlib_node_runtime_t) == 2 * CLIB_CACHE_LINE_BYTES);
+ ASSERT (vec_len (n->runtime_data) <= sizeof (vlib_node_runtime_t) -
+ STRUCT_OFFSET_OF (vlib_node_runtime_t, runtime_data));
+
if (vec_len (n->runtime_data) > 0)
clib_memcpy (rt->runtime_data, n->runtime_data,
vec_len (n->runtime_data));
diff --git a/vlib/vlib/node.h b/vlib/vlib/node.h
index 795856e6d7f..b624e9d636d 100644
--- a/vlib/vlib/node.h
+++ b/vlib/vlib/node.h
@@ -411,6 +411,7 @@ typedef struct
typedef struct vlib_node_runtime_t
{
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/* Node function to call. */
vlib_node_function_t *function;
@@ -465,11 +466,7 @@ typedef struct vlib_node_runtime_t
u16 cpu_index;
/* Function dependent node-runtime. */
- uword runtime_data[(128
- - 1 * sizeof (vlib_node_function_t *)
- - 1 * sizeof (vlib_error_t *)
- - 11 * sizeof (u32)
- - 5 * sizeof (u16)) / sizeof (uword)];
+ u8 runtime_data[0];
}
vlib_node_runtime_t;
diff --git a/vlib/vlib/node_funcs.h b/vlib/vlib/node_funcs.h
index bd199fa52f4..2116739602e 100644
--- a/vlib/vlib/node_funcs.h
+++ b/vlib/vlib/node_funcs.h
@@ -130,7 +130,9 @@ vlib_node_set_runtime_data (vlib_main_t * vm, u32 node_index,
vec_free (n->runtime_data);
vec_add (n->runtime_data, runtime_data, n_runtime_data_bytes);
- ASSERT (vec_len (n->runtime_data) <= sizeof (r->runtime_data));
+ ASSERT (vec_len (n->runtime_data) <= sizeof (vlib_node_runtime_t) -
+ STRUCT_OFFSET_OF (vlib_node_runtime_t, runtime_data));
+
if (vec_len (n->runtime_data) > 0)
clib_memcpy (r->runtime_data, n->runtime_data, vec_len (n->runtime_data));
}