From: Damjan Marion Date: Sat, 19 Apr 2025 16:51:06 +0000 (+0200) Subject: vppinfra: unify thread_index handling X-Git-Tag: v25.10-rc0~70 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=fc7b794758fbdd9bcae337e90255c1fc1e548808;p=vpp.git vppinfra: unify thread_index handling use typedef for thread_index instead if u16, u32, uword.... Type: improvement Change-Id: Ib31a0f918035e07d8f53c46a3d80b9ad8b3df129 Signed-off-by: Damjan Marion --- diff --git a/src/examples/srv6-sample-localsid/node.c b/src/examples/srv6-sample-localsid/node.c index e3a3259e877..4d727498c03 100644 --- a/src/examples/srv6-sample-localsid/node.c +++ b/src/examples/srv6-sample-localsid/node.c @@ -173,7 +173,7 @@ srv6_localsid_sample_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_fram from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); while (n_left_from > 0) { diff --git a/src/plugins/acl/elog_acl_trace.h b/src/plugins/acl/elog_acl_trace.h index 0c4f68f7b0f..ae2ef8588ea 100644 --- a/src/plugins/acl/elog_acl_trace.h +++ b/src/plugins/acl/elog_acl_trace.h @@ -19,119 +19,143 @@ /* use like: elog_acl_cond_trace_X1(am, (x < 0), "foobar: %d", "i4", int32_value); */ -#define elog_acl_cond_trace_X1(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1) \ -do { \ - if (trace_cond) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - } \ -} while (0) - +#define elog_acl_cond_trace_X1(am, trace_cond, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1) \ + do \ + { \ + if (trace_cond) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + } \ + } \ + while (0) /* use like: elog_acl_cond_trace_X2(am, (x<0), "foobar: %d some u64: %lu", "i4i8", int32_value, int64_value); */ -#define elog_acl_cond_trace_X2(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, \ - acl_elog_val1, acl_elog_val2) \ -do { \ - if (trace_cond) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - typeof(acl_elog_val2) val2; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - ed->val2 = acl_elog_val2; \ - } \ -} while (0) - +#define elog_acl_cond_trace_X2(am, trace_cond, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1, \ + acl_elog_val2) \ + do \ + { \ + if (trace_cond) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1) - \ + sizeof (acl_elog_val2)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + typeof (acl_elog_val2) val2; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + ed->val2 = acl_elog_val2; \ + } \ + } \ + while (0) /* use like: elog_acl_cond_trace_X3(am, (x<0), "foobar: %d some u64 %lu baz: %d", "i4i8i4", int32_value, u64_value, int_value); */ -#define elog_acl_cond_trace_X3(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \ - acl_elog_val2, acl_elog_val3) \ -do { \ - if (trace_cond) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \ - - sizeof(acl_elog_val3)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - typeof(acl_elog_val2) val2; \ - typeof(acl_elog_val3) val3; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - ed->val2 = acl_elog_val2; \ - ed->val3 = acl_elog_val3; \ - } \ -} while (0) - +#define elog_acl_cond_trace_X3(am, trace_cond, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1, \ + acl_elog_val2, acl_elog_val3) \ + do \ + { \ + if (trace_cond) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1) - \ + sizeof (acl_elog_val2) - \ + sizeof (acl_elog_val3)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + typeof (acl_elog_val2) val2; \ + typeof (acl_elog_val3) val3; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + ed->val2 = acl_elog_val2; \ + ed->val3 = acl_elog_val3; \ + } \ + } \ + while (0) /* use like: elog_acl_cond_trace_X4(am, (x<0), "foobar: %d some int %d baz: %d bar: %d", "i4i4i4i4", int32_value, int32_value2, int_value, int_value); */ -#define elog_acl_cond_trace_X4(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \ - acl_elog_val2, acl_elog_val3, acl_elog_val4) \ -do { \ - if (trace_cond) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \ - - sizeof(acl_elog_val3) -sizeof(acl_elog_val4)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - typeof(acl_elog_val2) val2; \ - typeof(acl_elog_val3) val3; \ - typeof(acl_elog_val4) val4; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - ed->val2 = acl_elog_val2; \ - ed->val3 = acl_elog_val3; \ - ed->val4 = acl_elog_val4; \ - } \ -} while (0) - +#define elog_acl_cond_trace_X4(am, trace_cond, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1, \ + acl_elog_val2, acl_elog_val3, acl_elog_val4) \ + do \ + { \ + if (trace_cond) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1) - \ + sizeof (acl_elog_val2) - \ + sizeof (acl_elog_val3) - \ + sizeof (acl_elog_val4)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + typeof (acl_elog_val2) val2; \ + typeof (acl_elog_val3) val3; \ + typeof (acl_elog_val4) val4; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + ed->val2 = acl_elog_val2; \ + ed->val3 = acl_elog_val3; \ + ed->val4 = acl_elog_val4; \ + } \ + } \ + while (0) #endif diff --git a/src/plugins/acl/fa_node.h b/src/plugins/acl/fa_node.h index c4a971aada3..f1ea8dfaf0a 100644 --- a/src/plugins/acl/fa_node.h +++ b/src/plugins/acl/fa_node.h @@ -110,7 +110,7 @@ typedef struct { u8 as_u8[2]; u16 as_u16; } tcp_flags_seen; ; /* +2 bytes = 62 */ - u16 thread_index; /* +2 bytes = 64 */ + clib_thread_index_t thread_index; /* +2 bytes = 64 */ u64 link_enqueue_time; /* 8 byte = 8 */ u32 link_prev_idx; /* +4 bytes = 12 */ u32 link_next_idx; /* +4 bytes = 16 */ @@ -133,7 +133,7 @@ typedef struct { u64 as_u64; struct { u32 session_index; - u16 thread_index; + clib_thread_index_t thread_index; u16 intf_policy_epoch; }; }; @@ -255,119 +255,143 @@ u8 *format_acl_plugin_5tuple (u8 * s, va_list * args); /* use like: elog_acl_maybe_trace_X1(am, "foobar: %d", "i4", int32_value); */ -#define elog_acl_maybe_trace_X1(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1) \ -do { \ - if (am->trace_sessions) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - } \ -} while (0) - +#define elog_acl_maybe_trace_X1(am, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1) \ + do \ + { \ + if (am->trace_sessions) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + } \ + } \ + while (0) /* use like: elog_acl_maybe_trace_X2(am, "foobar: %d some u64: %lu", "i4i8", int32_value, int64_value); */ -#define elog_acl_maybe_trace_X2(am, acl_elog_trace_format_label, acl_elog_trace_format_args, \ - acl_elog_val1, acl_elog_val2) \ -do { \ - if (am->trace_sessions) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - typeof(acl_elog_val2) val2; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - ed->val2 = acl_elog_val2; \ - } \ -} while (0) - +#define elog_acl_maybe_trace_X2(am, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1, \ + acl_elog_val2) \ + do \ + { \ + if (am->trace_sessions) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1) - \ + sizeof (acl_elog_val2)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + typeof (acl_elog_val2) val2; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + ed->val2 = acl_elog_val2; \ + } \ + } \ + while (0) /* use like: elog_acl_maybe_trace_X3(am, "foobar: %d some u64 %lu baz: %d", "i4i8i4", int32_value, u64_value, int_value); */ -#define elog_acl_maybe_trace_X3(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \ - acl_elog_val2, acl_elog_val3) \ -do { \ - if (am->trace_sessions) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \ - - sizeof(acl_elog_val3)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - typeof(acl_elog_val2) val2; \ - typeof(acl_elog_val3) val3; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - ed->val2 = acl_elog_val2; \ - ed->val3 = acl_elog_val3; \ - } \ -} while (0) - +#define elog_acl_maybe_trace_X3(am, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1, \ + acl_elog_val2, acl_elog_val3) \ + do \ + { \ + if (am->trace_sessions) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1) - \ + sizeof (acl_elog_val2) - \ + sizeof (acl_elog_val3)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + typeof (acl_elog_val2) val2; \ + typeof (acl_elog_val3) val3; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + ed->val2 = acl_elog_val2; \ + ed->val3 = acl_elog_val3; \ + } \ + } \ + while (0) /* use like: elog_acl_maybe_trace_X4(am, "foobar: %d some int %d baz: %d bar: %d", "i4i4i4i4", int32_value, int32_value2, int_value, int_value); */ -#define elog_acl_maybe_trace_X4(am, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \ - acl_elog_val2, acl_elog_val3, acl_elog_val4) \ -do { \ - if (am->trace_sessions) { \ - CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \ - - sizeof(acl_elog_val3) -sizeof(acl_elog_val4)]; } *static_check); \ - u16 thread_index = os_get_thread_index (); \ - vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \ - ELOG_TYPE_DECLARE (e) = \ - { \ - .format = "(%02d) " acl_elog_trace_format_label, \ - .format_args = "i2" acl_elog_trace_format_args, \ - }; \ - CLIB_PACKED(struct \ - { \ - u16 thread; \ - typeof(acl_elog_val1) val1; \ - typeof(acl_elog_val2) val2; \ - typeof(acl_elog_val3) val3; \ - typeof(acl_elog_val4) val4; \ - }) *ed; \ - ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ - ed->thread = thread_index; \ - ed->val1 = acl_elog_val1; \ - ed->val2 = acl_elog_val2; \ - ed->val3 = acl_elog_val3; \ - ed->val4 = acl_elog_val4; \ - } \ -} while (0) - +#define elog_acl_maybe_trace_X4(am, acl_elog_trace_format_label, \ + acl_elog_trace_format_args, acl_elog_val1, \ + acl_elog_val2, acl_elog_val3, acl_elog_val4) \ + do \ + { \ + if (am->trace_sessions) \ + { \ + CLIB_UNUSED (struct { \ + u8 available_space[18 - sizeof (acl_elog_val1) - \ + sizeof (acl_elog_val2) - \ + sizeof (acl_elog_val3) - \ + sizeof (acl_elog_val4)]; \ + } * static_check); \ + clib_thread_index_t thread_index = os_get_thread_index (); \ + vlib_worker_thread_t *w = vlib_worker_threads + thread_index; \ + ELOG_TYPE_DECLARE (e) = { \ + .format = "(%02d) " acl_elog_trace_format_label, \ + .format_args = "i2" acl_elog_trace_format_args, \ + }; \ + CLIB_PACKED (struct { \ + u16 thread; \ + typeof (acl_elog_val1) val1; \ + typeof (acl_elog_val2) val2; \ + typeof (acl_elog_val3) val3; \ + typeof (acl_elog_val4) val4; \ + }) * \ + ed; \ + ed = \ + ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \ + ed->thread = thread_index; \ + ed->val1 = acl_elog_val1; \ + ed->val2 = acl_elog_val2; \ + ed->val3 = acl_elog_val3; \ + ed->val4 = acl_elog_val4; \ + } \ + } \ + while (0) #endif diff --git a/src/plugins/acl/public_inlines.h b/src/plugins/acl/public_inlines.h index 80edfd674d3..f39285344b0 100644 --- a/src/plugins/acl/public_inlines.h +++ b/src/plugins/acl/public_inlines.h @@ -715,8 +715,10 @@ acl_plugin_match_5tuple_inline_and_count (void *p_acl_main, u32 lc_index, r_acl_pos_p, r_acl_match_p, r_rule_match_p, trace_bitmap); } if (PREDICT_TRUE(ret)) { - u16 thread_index = os_get_thread_index (); - vlib_increment_combined_counter(am->combined_acl_counters + *r_acl_match_p, thread_index, *r_rule_match_p, 1, packet_size); + clib_thread_index_t thread_index = os_get_thread_index (); + vlib_increment_combined_counter ( + am->combined_acl_counters + *r_acl_match_p, thread_index, + *r_rule_match_p, 1, packet_size); } return ret; } diff --git a/src/plugins/acl/sess_mgmt_node.c b/src/plugins/acl/sess_mgmt_node.c index 418baef9b6b..10f0e92c808 100644 --- a/src/plugins/acl/sess_mgmt_node.c +++ b/src/plugins/acl/sess_mgmt_node.c @@ -136,16 +136,17 @@ fa_session_get_list_timeout (acl_main_t * am, fa_session_t * sess) } static u64 -acl_fa_get_list_head_expiry_time (acl_main_t * am, - acl_fa_per_worker_data_t * pw, u64 now, - u16 thread_index, int timeout_type) +acl_fa_get_list_head_expiry_time (acl_main_t *am, acl_fa_per_worker_data_t *pw, + u64 now, clib_thread_index_t thread_index, + int timeout_type) { return pw->fa_conn_list_head_expiry_time[timeout_type]; } static int -acl_fa_conn_time_to_check (acl_main_t * am, acl_fa_per_worker_data_t * pw, - u64 now, u16 thread_index, u32 session_index) +acl_fa_conn_time_to_check (acl_main_t *am, acl_fa_per_worker_data_t *pw, + u64 now, clib_thread_index_t thread_index, + u32 session_index) { if (session_index == FA_SESSION_BOGUS_INDEX) return 0; @@ -162,7 +163,8 @@ acl_fa_conn_time_to_check (acl_main_t * am, acl_fa_per_worker_data_t * pw, * return the total number of sessions reclaimed. */ static int -acl_fa_check_idle_sessions (acl_main_t * am, u16 thread_index, u64 now) +acl_fa_check_idle_sessions (acl_main_t *am, clib_thread_index_t thread_index, + u64 now) { acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index]; fa_full_session_id_t fsid; @@ -429,7 +431,7 @@ acl_fa_worker_conn_cleaner_process (vlib_main_t * vm, { acl_main_t *am = &acl_main; u64 now = clib_cpu_time_now (); - u16 thread_index = os_get_thread_index (); + clib_thread_index_t thread_index = os_get_thread_index (); acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index]; int num_expired; elog_acl_maybe_trace_X1 (am, diff --git a/src/plugins/acl/session_inlines.h b/src/plugins/acl/session_inlines.h index edc8a7057ee..c98194005a4 100644 --- a/src/plugins/acl/session_inlines.h +++ b/src/plugins/acl/session_inlines.h @@ -115,16 +115,16 @@ fa_session_get_timeout (acl_main_t * am, fa_session_t * sess) } always_inline fa_session_t * -get_session_ptr_no_check (acl_main_t * am, u16 thread_index, +get_session_ptr_no_check (acl_main_t *am, clib_thread_index_t thread_index, u32 session_index) { acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index]; return pool_elt_at_index (pw->fa_sessions_pool, session_index); } - always_inline fa_session_t * -get_session_ptr (acl_main_t * am, u16 thread_index, u32 session_index) +get_session_ptr (acl_main_t *am, clib_thread_index_t thread_index, + u32 session_index) { acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index]; @@ -135,7 +135,8 @@ get_session_ptr (acl_main_t * am, u16 thread_index, u32 session_index) } always_inline int -is_valid_session_ptr (acl_main_t * am, u16 thread_index, fa_session_t * sess) +is_valid_session_ptr (acl_main_t *am, clib_thread_index_t thread_index, + fa_session_t *sess) { acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index]; return ((sess != 0) @@ -470,10 +471,10 @@ acl_fa_can_add_session (acl_main_t * am, int is_input, u32 sw_if_index) am->fa_conn_table_max_entries); } - always_inline void -acl_fa_try_recycle_session (acl_main_t * am, int is_input, u16 thread_index, - u32 sw_if_index, u64 now) +acl_fa_try_recycle_session (acl_main_t *am, int is_input, + clib_thread_index_t thread_index, u32 sw_if_index, + u64 now) { /* try to recycle a TCP transient session */ acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index]; diff --git a/src/plugins/adl/ip4_allowlist.c b/src/plugins/adl/ip4_allowlist.c index 4c755725ea7..a44cb51762f 100644 --- a/src/plugins/adl/ip4_allowlist.c +++ b/src/plugins/adl/ip4_allowlist.c @@ -58,7 +58,7 @@ VLIB_NODE_FN (ip4_adl_allowlist_node) (vlib_main_t * vm, adl_feature_type_t next_index; adl_main_t *cm = &adl_main; vlib_combined_counter_main_t * vcm = &load_balance_main.lbm_via_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 allowed_packets; from = vlib_frame_vector_args (frame); diff --git a/src/plugins/adl/ip6_allowlist.c b/src/plugins/adl/ip6_allowlist.c index 5f38484666b..f9d964645c4 100644 --- a/src/plugins/adl/ip6_allowlist.c +++ b/src/plugins/adl/ip6_allowlist.c @@ -58,7 +58,7 @@ VLIB_NODE_FN (ip6_adl_allowlist_node) (vlib_main_t * vm, adl_feature_type_t next_index; adl_main_t *cm = &adl_main; vlib_combined_counter_main_t * vcm = &load_balance_main.lbm_via_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 allowed_packets; from = vlib_frame_vector_args (frame); diff --git a/src/plugins/af_packet/node.c b/src/plugins/af_packet/node.c index 279f11c0183..e60a037b093 100644 --- a/src/plugins/af_packet/node.c +++ b/src/plugins/af_packet/node.c @@ -269,7 +269,7 @@ af_packet_v3_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u32 block_nr = rx_queue->rx_req->req3.tp_block_nr; u8 *block_start = 0; uword n_trace = vlib_get_trace_count (vm, node); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_buffer_bytes = vlib_buffer_get_default_data_size (vm); u32 min_bufs = rx_queue->rx_req->req3.tp_frame_size / n_buffer_bytes; u32 num_pkts = 0; @@ -571,7 +571,7 @@ af_packet_v2_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u32 frame_num = rx_queue->rx_req->req.tp_frame_nr; u8 *block_start = rx_queue->rx_ring[block]; uword n_trace = vlib_get_trace_count (vm, node); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_buffer_bytes = vlib_buffer_get_default_data_size (vm); u32 min_bufs = rx_queue->rx_req->req.tp_frame_size / n_buffer_bytes; u32 sw_if_index = apif->sw_if_index; diff --git a/src/plugins/cnat/cnat_types.h b/src/plugins/cnat/cnat_types.h index d229d21adae..37eb62ec981 100644 --- a/src/plugins/cnat/cnat_types.h +++ b/src/plugins/cnat/cnat_types.h @@ -192,7 +192,7 @@ typedef struct cnat_timestamp_mpool_t_ typedef struct cnat_node_ctx_ { f64 now; - u32 thread_index; + clib_thread_index_t thread_index; ip_address_family_t af; u8 do_trace; } cnat_node_ctx_t; diff --git a/src/plugins/crypto_sw_scheduler/main.c b/src/plugins/crypto_sw_scheduler/main.c index dc97ce937d9..bb1505a38cf 100644 --- a/src/plugins/crypto_sw_scheduler/main.c +++ b/src/plugins/crypto_sw_scheduler/main.c @@ -446,7 +446,7 @@ convert_async_crypto_id (vnet_crypto_op_id_t async_op_id, u32 *crypto_op, static_always_inline vnet_crypto_async_frame_t * crypto_sw_scheduler_dequeue (vlib_main_t *vm, u32 *nb_elts_processed, - u32 *enqueue_thread_idx) + clib_thread_index_t *enqueue_thread_idx) { crypto_sw_scheduler_main_t *cm = &crypto_sw_scheduler_main; crypto_sw_scheduler_per_thread_data_t *ptd = diff --git a/src/plugins/ct6/ct6.h b/src/plugins/ct6/ct6.h index 0b7deb07839..a6919174d86 100644 --- a/src/plugins/ct6/ct6.h +++ b/src/plugins/ct6/ct6.h @@ -46,7 +46,7 @@ typedef CLIB_PACKED (struct typedef struct { ct6_session_key_t key; - u32 thread_index; + clib_thread_index_t thread_index; u32 next_index; u32 prev_index; u32 hits; @@ -95,7 +95,7 @@ static inline void ct6_lru_remove (ct6_main_t * cmp, ct6_session_t * s0) { ct6_session_t *next_sess, *prev_sess; - u32 thread_index; + clib_thread_index_t thread_index; u32 s0_index; thread_index = s0->thread_index; @@ -128,7 +128,7 @@ static inline void ct6_lru_add (ct6_main_t * cmp, ct6_session_t * s0, f64 now) { ct6_session_t *next_sess; - u32 thread_index; + clib_thread_index_t thread_index; u32 s0_index; s0->hits++; diff --git a/src/plugins/dev_armada/pp2/rx.c b/src/plugins/dev_armada/pp2/rx.c index 4e73882e3d8..8eff72d6157 100644 --- a/src/plugins/dev_armada/pp2/rx.c +++ b/src/plugins/dev_armada/pp2/rx.c @@ -208,7 +208,7 @@ mrvl_pp2_rx_refill (vlib_main_t *vm, vlib_node_runtime_t *node, vnet_dev_port_t *port = rxq->port; vnet_dev_t *dev = port->dev; mvpp2_device_t *md = vnet_dev_get_data (dev); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; struct pp2_hif *hif = md->hif[thread_index]; struct pp2_bpool *bpool = md->thread[thread_index].bpool; struct buff_release_entry *bre = md->thread[thread_index].bre; diff --git a/src/plugins/dev_octeon/crypto.c b/src/plugins/dev_octeon/crypto.c index 52c796089d5..49b6f61375c 100644 --- a/src/plugins/dev_octeon/crypto.c +++ b/src/plugins/dev_octeon/crypto.c @@ -1827,7 +1827,7 @@ oct_crypto_enqueue_aead_aad_0_dec (vlib_main_t *vm, vnet_crypto_async_frame_t * oct_crypto_frame_dequeue (vlib_main_t *vm, u32 *nb_elts_processed, - u32 *enqueue_thread_idx) + clib_thread_index_t *enqueue_thread_idx) { oct_crypto_main_t *ocm = &oct_crypto_main; u32 deq_head, status = VNET_CRYPTO_OP_STATUS_COMPLETED; diff --git a/src/plugins/dev_octeon/crypto.h b/src/plugins/dev_octeon/crypto.h index 4d8c56a314c..a99ee12ddb2 100644 --- a/src/plugins/dev_octeon/crypto.h +++ b/src/plugins/dev_octeon/crypto.h @@ -211,9 +211,9 @@ int oct_crypto_enqueue_aead_aad_12_dec (vlib_main_t *vm, vnet_crypto_async_frame_t *frame); int oct_crypto_enqueue_aead_aad_0_dec (vlib_main_t *vm, vnet_crypto_async_frame_t *frame); -vnet_crypto_async_frame_t *oct_crypto_frame_dequeue (vlib_main_t *vm, - u32 *nb_elts_processed, - u32 *enqueue_thread_idx); +vnet_crypto_async_frame_t * +oct_crypto_frame_dequeue (vlib_main_t *vm, u32 *nb_elts_processed, + clib_thread_index_t *enqueue_thread_idx); int oct_init_crypto_engine_handlers (vlib_main_t *vm, vnet_dev_t *dev); int oct_conf_sw_queue (vlib_main_t *vm, vnet_dev_t *dev, oct_crypto_dev_t *ocd); diff --git a/src/plugins/dpdk/cryptodev/cryptodev.c b/src/plugins/dpdk/cryptodev/cryptodev.c index a8817a1ec08..af695580363 100644 --- a/src/plugins/dpdk/cryptodev/cryptodev.c +++ b/src/plugins/dpdk/cryptodev/cryptodev.c @@ -608,7 +608,7 @@ format_cryptodev_inst (u8 * s, va_list * args) cryptodev_main_t *cmt = &cryptodev_main; u32 inst = va_arg (*args, u32); cryptodev_inst_t *cit = cmt->cryptodev_inst + inst; - u32 thread_index = 0; + clib_thread_index_t thread_index = 0; struct rte_cryptodev_info info; rte_cryptodev_info_get (cit->dev_id, &info); @@ -670,7 +670,7 @@ cryptodev_show_cache_rings_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) { cryptodev_main_t *cmt = &cryptodev_main; - u32 thread_index = 0; + clib_thread_index_t thread_index = 0; u16 i; vec_foreach_index (thread_index, cmt->per_thread_data) { @@ -756,7 +756,7 @@ cryptodev_set_assignment_fn (vlib_main_t * vm, unformat_input_t * input, cryptodev_main_t *cmt = &cryptodev_main; cryptodev_engine_thread_t *cet; unformat_input_t _line_input, *line_input = &_line_input; - u32 thread_index, inst_index; + clib_thread_index_t thread_index, inst_index; u32 thread_present = 0, inst_present = 0; clib_error_t *error = 0; int ret; diff --git a/src/plugins/dpdk/cryptodev/cryptodev_op_data_path.c b/src/plugins/dpdk/cryptodev/cryptodev_op_data_path.c index 8d55e4fbf0f..2282ffac10c 100644 --- a/src/plugins/dpdk/cryptodev/cryptodev_op_data_path.c +++ b/src/plugins/dpdk/cryptodev/cryptodev_op_data_path.c @@ -461,7 +461,8 @@ error_exit: } static_always_inline u8 -cryptodev_frame_dequeue_internal (vlib_main_t *vm, u32 *enqueue_thread_idx) +cryptodev_frame_dequeue_internal (vlib_main_t *vm, + clib_thread_index_t *enqueue_thread_idx) { cryptodev_main_t *cmt = &cryptodev_main; cryptodev_engine_thread_t *cet = cmt->per_thread_data + vm->thread_index; @@ -563,7 +564,7 @@ cryptodev_enqueue_frame (vlib_main_t *vm, cryptodev_cache_ring_elt_t *ring_elt) static_always_inline vnet_crypto_async_frame_t * cryptodev_frame_dequeue (vlib_main_t *vm, u32 *nb_elts_processed, - u32 *enqueue_thread_idx) + clib_thread_index_t *enqueue_thread_idx) { cryptodev_main_t *cmt = &cryptodev_main; vnet_crypto_main_t *cm = &crypto_main; @@ -670,7 +671,7 @@ cryptodev_register_cop_hdl (vlib_main_t *vm, u32 eidx) vec_foreach (cet, cmt->per_thread_data) { - u32 thread_index = cet - cmt->per_thread_data; + clib_thread_index_t thread_index = cet - cmt->per_thread_data; u32 numa = vlib_get_main_by_index (thread_index)->numa_node; name = format (0, "vpp_cop_pool_%u_%u", numa, thread_index); cet->cop_pool = rte_mempool_create ( diff --git a/src/plugins/dpdk/cryptodev/cryptodev_raw_data_path.c b/src/plugins/dpdk/cryptodev/cryptodev_raw_data_path.c index 67ab9c89e67..40d0a4299da 100644 --- a/src/plugins/dpdk/cryptodev/cryptodev_raw_data_path.c +++ b/src/plugins/dpdk/cryptodev/cryptodev_raw_data_path.c @@ -463,7 +463,8 @@ cryptodev_post_dequeue (void *frame, u32 index, u8 is_op_success) } static_always_inline u8 -cryptodev_raw_dequeue_internal (vlib_main_t *vm, u32 *enqueue_thread_idx) +cryptodev_raw_dequeue_internal (vlib_main_t *vm, + clib_thread_index_t *enqueue_thread_idx) { cryptodev_main_t *cmt = &cryptodev_main; cryptodev_engine_thread_t *cet = cmt->per_thread_data + vm->thread_index; @@ -537,7 +538,7 @@ cryptodev_enqueue_frame_to_qat (vlib_main_t *vm, static_always_inline vnet_crypto_async_frame_t * cryptodev_raw_dequeue (vlib_main_t *vm, u32 *nb_elts_processed, - u32 *enqueue_thread_idx) + clib_thread_index_t *enqueue_thread_idx) { cryptodev_main_t *cmt = &cryptodev_main; vnet_crypto_main_t *cm = &crypto_main; diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c index 842c83813af..5fd936d1743 100644 --- a/src/plugins/dpdk/device/device.c +++ b/src/plugins/dpdk/device/device.c @@ -280,7 +280,7 @@ VNET_DEVICE_CLASS_TX_FN (dpdk_device_class) (vlib_main_t * vm, u32 n_packets = f->n_vectors; u32 n_left; u32 n_prep; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; int queue_id = tf->queue_id; u8 is_shared = tf->shared_queue; u8 offload_enabled = 0; diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h index 794953da55e..2067b118532 100644 --- a/src/plugins/dpdk/device/dpdk_priv.h +++ b/src/plugins/dpdk/device/dpdk_priv.h @@ -50,7 +50,7 @@ dpdk_device_flag_set (dpdk_device_t *xd, __typeof__ (xd->flags) flag, int val) void dpdk_counters_xstats_init (dpdk_device_t *xd); static inline void -dpdk_get_xstats (dpdk_device_t *xd, u32 thread_index) +dpdk_get_xstats (dpdk_device_t *xd, clib_thread_index_t thread_index) { int ret; int i; @@ -101,7 +101,7 @@ static inline void dpdk_update_counters (dpdk_device_t * xd, f64 now) { vnet_main_t *vnm = vnet_get_main (); - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); xd->time_last_stats_update = now ? now : xd->time_last_stats_update; clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats)); diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c index ca1690b708f..2f4c10ebf46 100644 --- a/src/plugins/dpdk/device/node.c +++ b/src/plugins/dpdk/device/node.c @@ -340,8 +340,9 @@ dpdk_process_lro_offload (dpdk_device_t *xd, dpdk_per_thread_data_t *ptd, } static_always_inline u32 -dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd, - vlib_node_runtime_t * node, u32 thread_index, u16 queue_id) +dpdk_device_input (vlib_main_t *vm, dpdk_main_t *dm, dpdk_device_t *xd, + vlib_node_runtime_t *node, clib_thread_index_t thread_index, + u16 queue_id) { uword n_rx_packets = 0, n_rx_bytes; dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, queue_id); @@ -543,7 +544,7 @@ VLIB_NODE_FN (dpdk_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, dpdk_device_t *xd; uword n_rx_packets = 0; vnet_hw_if_rxq_poll_vector_t *pv; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; /* * Poll all devices on this cpu for input/interrupts. diff --git a/src/plugins/geneve/decap.c b/src/plugins/geneve/decap.c index c64121e2829..3a1de2af217 100644 --- a/src/plugins/geneve/decap.c +++ b/src/plugins/geneve/decap.c @@ -79,7 +79,7 @@ geneve_input (vlib_main_t * vm, geneve4_tunnel_key_t last_key4; geneve6_tunnel_key_t last_key6; u32 pkts_decapsulated = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; diff --git a/src/plugins/geneve/encap.c b/src/plugins/geneve/encap.c index 609da2218cf..581c47983df 100644 --- a/src/plugins/geneve/encap.c +++ b/src/plugins/geneve/encap.c @@ -60,7 +60,7 @@ geneve_encap_inline (vlib_main_t * vm, vnet_interface_main_t *im = &vnm->interface_main; u32 pkts_encapsulated = 0; u16 old_l0 = 0, old_l1 = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; u32 sw_if_index0 = ~0, sw_if_index1 = ~0; u32 next0 = 0, next1 = 0; diff --git a/src/plugins/gtpu/gtpu_decap.c b/src/plugins/gtpu/gtpu_decap.c index 093d85ef13c..4e0f8bf8e16 100644 --- a/src/plugins/gtpu/gtpu_decap.c +++ b/src/plugins/gtpu/gtpu_decap.c @@ -85,7 +85,7 @@ gtpu_input (vlib_main_t * vm, gtpu4_tunnel_key_t last_key4; gtpu6_tunnel_key_t last_key6; u32 pkts_decapsulated = 0; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; if (is_ip4) @@ -1838,7 +1838,7 @@ gtpu_flow_input (vlib_main_t * vm, vnet_main_t * vnm = gtm->vnet_main; vnet_interface_main_t * im = &vnm->interface_main; u32 pkts_decapsulated = 0; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; u8 ip_err0, ip_err1, udp_err0, udp_err1, csum_err0, csum_err1; diff --git a/src/plugins/gtpu/gtpu_encap.c b/src/plugins/gtpu/gtpu_encap.c index 2c3c46a4be2..1caca1da915 100644 --- a/src/plugins/gtpu/gtpu_encap.c +++ b/src/plugins/gtpu/gtpu_encap.c @@ -67,7 +67,7 @@ gtpu_encap_inline (vlib_main_t * vm, vnet_interface_main_t * im = &vnm->interface_main; u32 pkts_encapsulated = 0; u16 old_l0 = 0, old_l1 = 0, old_l2 = 0, old_l3 = 0; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; u32 sw_if_index0 = 0, sw_if_index1 = 0, sw_if_index2 = 0, sw_if_index3 = 0; u32 next0 = 0, next1 = 0, next2 = 0, next3 = 0; diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c index f57fd748dba..173124401b8 100644 --- a/src/plugins/hs_apps/echo_client.c +++ b/src/plugins/hs_apps/echo_client.c @@ -53,7 +53,7 @@ signal_evt_to_cli (int code) } static inline ec_worker_t * -ec_worker_get (u32 thread_index) +ec_worker_get (clib_thread_index_t thread_index) { return vec_elt_at_index (ec_main.wrk, thread_index); } @@ -575,7 +575,7 @@ quic_ec_session_connected_callback (u32 app_index, u32 api_context, ec_main_t *ecm = &ec_main; ec_session_t *es; ec_worker_t *wrk; - u32 thread_index; + clib_thread_index_t thread_index; if (PREDICT_FALSE (api_context == HS_CTRL_HANDLE)) return ec_ctrl_session_connected_callback (s); @@ -632,7 +632,7 @@ ec_session_connected_callback (u32 app_index, u32 api_context, session_t *s, { ec_main_t *ecm = &ec_main; ec_session_t *es; - u32 thread_index; + clib_thread_index_t thread_index; ec_worker_t *wrk; if (PREDICT_FALSE (ecm->run_test != EC_STARTING)) diff --git a/src/plugins/hs_apps/echo_client.h b/src/plugins/hs_apps/echo_client.h index d06f237c757..b8744feccfc 100644 --- a/src/plugins/hs_apps/echo_client.h +++ b/src/plugins/hs_apps/echo_client.h @@ -29,7 +29,7 @@ typedef struct ec_session_ foreach_app_session_field #undef _ u32 vpp_session_index; - u32 thread_index; + clib_thread_index_t thread_index; u64 bytes_to_send; u64 bytes_sent; u64 bytes_to_receive; @@ -45,7 +45,7 @@ typedef struct ec_worker_ u32 *conn_indices; /**< sessions handled by worker */ u32 *conns_this_batch; /**< sessions handled in batch */ svm_msg_q_t *vpp_event_queue; /**< session layer worker mq */ - u32 thread_index; /**< thread index for worker */ + clib_thread_index_t thread_index; /**< thread index for worker */ } ec_worker_t; typedef struct diff --git a/src/plugins/hs_apps/echo_server.c b/src/plugins/hs_apps/echo_server.c index dc303e2f83a..61b86769768 100644 --- a/src/plugins/hs_apps/echo_server.c +++ b/src/plugins/hs_apps/echo_server.c @@ -40,7 +40,7 @@ typedef struct es_session_t *sessions; u8 *rx_buf; /**< Per-thread RX buffer */ svm_msg_q_t *vpp_event_queue; - u32 thread_index; + clib_thread_index_t thread_index; } es_worker_t; typedef struct @@ -87,7 +87,7 @@ echo_server_main_t echo_server_main; #define es_cli(_fmt, _args...) vlib_cli_output (vm, _fmt, ##_args) static inline es_worker_t * -es_worker_get (u32 thread_index) +es_worker_get (clib_thread_index_t thread_index) { return vec_elt_at_index (echo_server_main.wrk, thread_index); } @@ -277,7 +277,7 @@ es_wrk_cleanup_sessions (void *args) { echo_server_main_t *esm = &echo_server_main; vnet_disconnect_args_t _a = {}, *a = &_a; - u32 thread_index = pointer_to_uword (args); + clib_thread_index_t thread_index = pointer_to_uword (args); es_session_t *es; es_worker_t *wrk; @@ -373,7 +373,7 @@ echo_server_rx_callback (session_t * s) int actual_transfer; svm_fifo_t *tx_fifo, *rx_fifo; echo_server_main_t *esm = &echo_server_main; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); es_worker_t *wrk; es_session_t *es; diff --git a/src/plugins/hs_apps/http_cli.c b/src/plugins/hs_apps/http_cli.c index 531e2750c1e..40acf6a1635 100644 --- a/src/plugins/hs_apps/http_cli.c +++ b/src/plugins/hs_apps/http_cli.c @@ -37,7 +37,7 @@ typedef struct typedef struct { u32 hs_index; - u32 thread_index; + clib_thread_index_t thread_index; u64 node_index; u8 plain_text; u8 *buf; @@ -47,7 +47,7 @@ typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; u8 *tx_buf; u32 tx_offset; u32 vpp_session_index; @@ -85,7 +85,7 @@ typedef struct static hcs_main_t hcs_main; static hcs_session_t * -hcs_session_alloc (u32 thread_index) +hcs_session_alloc (clib_thread_index_t thread_index) { hcs_main_t *hcm = &hcs_main; hcs_session_t *hs; @@ -98,7 +98,7 @@ hcs_session_alloc (u32 thread_index) } static hcs_session_t * -hcs_session_get (u32 thread_index, u32 hs_index) +hcs_session_get (clib_thread_index_t thread_index, u32 hs_index) { hcs_main_t *hcm = &hcs_main; if (pool_is_free_index (hcm->sessions[thread_index], hs_index)) diff --git a/src/plugins/hs_apps/http_client.c b/src/plugins/hs_apps/http_client.c index 1cf96cfa651..578d21140f1 100644 --- a/src/plugins/hs_apps/http_client.c +++ b/src/plugins/hs_apps/http_client.c @@ -22,7 +22,7 @@ typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; u64 to_recv; u8 is_closed; hc_stats_t stats; @@ -35,7 +35,7 @@ typedef struct typedef struct { hc_session_t *sessions; - u32 thread_index; + clib_thread_index_t thread_index; vlib_main_t *vlib_main; u8 *headers_buf; http_headers_ctx_t req_headers; @@ -98,13 +98,13 @@ static hc_main_t hc_main; static hc_stats_t hc_stats; static inline hc_worker_t * -hc_worker_get (u32 thread_index) +hc_worker_get (clib_thread_index_t thread_index) { return &hc_main.wrk[thread_index]; } static inline hc_session_t * -hc_session_get (u32 session_index, u32 thread_index) +hc_session_get (u32 session_index, clib_thread_index_t thread_index) { hc_worker_t *wrk = hc_worker_get (thread_index); wrk->vlib_main = vlib_get_main_by_index (thread_index); diff --git a/src/plugins/hs_apps/http_client_cli.c b/src/plugins/hs_apps/http_client_cli.c index 8df5bfd10b8..b72d4dfae54 100644 --- a/src/plugins/hs_apps/http_client_cli.c +++ b/src/plugins/hs_apps/http_client_cli.c @@ -31,7 +31,7 @@ typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; u32 rx_offset; u32 vpp_session_index; u64 to_recv; @@ -41,7 +41,7 @@ typedef struct typedef struct { hcc_session_t *sessions; - u32 thread_index; + clib_thread_index_t thread_index; } hcc_worker_t; typedef struct @@ -76,7 +76,7 @@ typedef enum static hcc_main_t hcc_main; static hcc_worker_t * -hcc_worker_get (u32 thread_index) +hcc_worker_get (clib_thread_index_t thread_index) { return vec_elt_at_index (hcc_main.wrk, thread_index); } @@ -92,7 +92,7 @@ hcc_session_alloc (hcc_worker_t *wrk) } static hcc_session_t * -hcc_session_get (u32 hs_index, u32 thread_index) +hcc_session_get (u32 hs_index, clib_thread_index_t thread_index) { hcc_worker_t *wrk = hcc_worker_get (thread_index); return pool_elt_at_index (wrk->sessions, hs_index); diff --git a/src/plugins/hs_apps/http_tps.c b/src/plugins/hs_apps/http_tps.c index 59a0309e363..ac6b6c79a70 100644 --- a/src/plugins/hs_apps/http_tps.c +++ b/src/plugins/hs_apps/http_tps.c @@ -25,7 +25,7 @@ typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; u64 data_len; u64 data_offset; u32 vpp_session_index; @@ -78,7 +78,7 @@ typedef struct hs_main_ static hts_main_t hts_main; static hts_session_t * -hts_session_alloc (u32 thread_index) +hts_session_alloc (clib_thread_index_t thread_index) { hts_main_t *htm = &hts_main; hts_session_t *hs; @@ -92,7 +92,7 @@ hts_session_alloc (u32 thread_index) } static hts_session_t * -hts_session_get (u32 thread_index, u32 hts_index) +hts_session_get (clib_thread_index_t thread_index, u32 hts_index) { hts_main_t *htm = &hts_main; @@ -620,7 +620,7 @@ hts_start_listen (hts_main_t *htm, session_endpoint_cfg_t *sep, u8 *uri, u8 need_crypto; hts_session_t *hls; session_t *ls; - u32 thread_index = 0; + clib_thread_index_t thread_index = 0; int rv; clib_memset (a, 0, sizeof (*a)); diff --git a/src/plugins/hs_apps/proxy.c b/src/plugins/hs_apps/proxy.c index ca088f4bc8a..140183d5f59 100644 --- a/src/plugins/hs_apps/proxy.c +++ b/src/plugins/hs_apps/proxy.c @@ -112,7 +112,8 @@ proxy_do_connect (vnet_connect_args_t *a) static void proxy_handle_connects_rpc (void *args) { - u32 thread_index = pointer_to_uword (args), n_connects = 0, n_pending; + clib_thread_index_t thread_index = pointer_to_uword (args), n_connects = 0, + n_pending; proxy_worker_t *wrk; u32 max_connects; diff --git a/src/plugins/hs_apps/proxy.h b/src/plugins/hs_apps/proxy.h index f26f4bf0ea2..88b7cdf41ee 100644 --- a/src/plugins/hs_apps/proxy.h +++ b/src/plugins/hs_apps/proxy.h @@ -117,7 +117,7 @@ typedef struct extern proxy_main_t proxy_main; static inline proxy_worker_t * -proxy_worker_get (u32 thread_index) +proxy_worker_get (clib_thread_index_t thread_index) { proxy_main_t *pm = &proxy_main; return vec_elt_at_index (pm->workers, thread_index); diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c index ff32a1f2f8f..c7eefcdae48 100644 --- a/src/plugins/http/http.c +++ b/src/plugins/http/http.c @@ -113,13 +113,13 @@ format_http_time_now (u8 *s, va_list *args) } static inline http_worker_t * -http_worker_get (u32 thread_index) +http_worker_get (clib_thread_index_t thread_index) { return &http_main.wrk[thread_index]; } static inline u32 -http_conn_alloc_w_thread (u32 thread_index) +http_conn_alloc_w_thread (clib_thread_index_t thread_index) { http_worker_t *wrk = http_worker_get (thread_index); http_conn_t *hc; @@ -129,14 +129,15 @@ http_conn_alloc_w_thread (u32 thread_index) } static inline http_conn_t * -http_conn_get_w_thread (u32 hc_index, u32 thread_index) +http_conn_get_w_thread (u32 hc_index, clib_thread_index_t thread_index) { http_worker_t *wrk = http_worker_get (thread_index); return pool_elt_at_index (wrk->conn_pool, hc_index); } static inline http_conn_t * -http_conn_get_w_thread_if_valid (u32 hc_index, u32 thread_index) +http_conn_get_w_thread_if_valid (u32 hc_index, + clib_thread_index_t thread_index) { http_worker_t *wrk = http_worker_get (thread_index); if (pool_is_free_index (wrk->conn_pool, hc_index)) @@ -983,7 +984,7 @@ http_stop_listen (u32 listener_index) } static void -http_transport_close (u32 rh, u32 thread_index) +http_transport_close (u32 rh, clib_thread_index_t thread_index) { http_conn_t *hc; u32 hc_index; @@ -1014,7 +1015,7 @@ http_transport_close (u32 rh, u32 thread_index) } static void -http_transport_reset (u32 rh, u32 thread_index) +http_transport_reset (u32 rh, clib_thread_index_t thread_index) { http_conn_t *hc; u32 hc_index; @@ -1037,7 +1038,7 @@ http_transport_reset (u32 rh, u32 thread_index) } static transport_connection_t * -http_transport_get_connection (u32 rh, u32 thread_index) +http_transport_get_connection (u32 rh, clib_thread_index_t thread_index) { http_req_handle_t hr_handle; @@ -1107,7 +1108,7 @@ http_app_rx_evt_cb (transport_connection_t *tc) } static void -http_transport_get_endpoint (u32 rh, u32 thread_index, +http_transport_get_endpoint (u32 rh, clib_thread_index_t thread_index, transport_endpoint_t *tep, u8 is_lcl) { http_conn_t *hc; @@ -1144,7 +1145,7 @@ static u8 * format_http_transport_connection (u8 *s, va_list *args) { http_req_handle_t rh = va_arg (*args, http_req_handle_t); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); u32 hc_index; http_conn_t *hc; diff --git a/src/plugins/http/http1.c b/src/plugins/http/http1.c index fbd0d32784c..5ecc1f52300 100644 --- a/src/plugins/http/http1.c +++ b/src/plugins/http/http1.c @@ -80,7 +80,7 @@ http1_conn_alloc_req (http_conn_t *hc) } always_inline http_req_t * -http1_req_get (u32 req_index, u32 thread_index) +http1_req_get (u32 req_index, clib_thread_index_t thread_index) { http1_main_t *h1m = &http1_main; @@ -88,7 +88,7 @@ http1_req_get (u32 req_index, u32 thread_index) } always_inline http_req_t * -http1_req_get_if_valid (u32 req_index, u32 thread_index) +http1_req_get_if_valid (u32 req_index, clib_thread_index_t thread_index) { http1_main_t *h1m = &http1_main; @@ -1669,7 +1669,8 @@ http1_req_run_state_machine (http_conn_t *hc, http_req_t *req, /*****************/ static u32 -http1_hc_index_get_by_req_index (u32 req_index, u32 thread_index) +http1_hc_index_get_by_req_index (u32 req_index, + clib_thread_index_t thread_index) { http_req_t *req; @@ -1678,7 +1679,7 @@ http1_hc_index_get_by_req_index (u32 req_index, u32 thread_index) } static transport_connection_t * -http1_req_get_connection (u32 req_index, u32 thread_index) +http1_req_get_connection (u32 req_index, clib_thread_index_t thread_index) { http_req_t *req; req = http1_req_get (req_index, thread_index); @@ -1704,7 +1705,7 @@ static u8 * http1_format_req (u8 *s, va_list *args) { u32 req_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); http_conn_t *hc = va_arg (*args, http_conn_t *); u32 verbose = va_arg (*args, u32); http_req_t *req; @@ -1758,7 +1759,8 @@ http1_app_tx_callback (http_conn_t *hc, u32 req_index, } static void -http1_app_rx_evt_callback (http_conn_t *hc, u32 req_index, u32 thread_index) +http1_app_rx_evt_callback (http_conn_t *hc, u32 req_index, + clib_thread_index_t thread_index) { http_req_t *req; @@ -1769,7 +1771,8 @@ http1_app_rx_evt_callback (http_conn_t *hc, u32 req_index, u32 thread_index) } static void -http1_app_close_callback (http_conn_t *hc, u32 req_index, u32 thread_index) +http1_app_close_callback (http_conn_t *hc, u32 req_index, + clib_thread_index_t thread_index) { http_req_t *req; @@ -1794,7 +1797,8 @@ http1_app_close_callback (http_conn_t *hc, u32 req_index, u32 thread_index) } static void -http1_app_reset_callback (http_conn_t *hc, u32 req_index, u32 thread_index) +http1_app_reset_callback (http_conn_t *hc, u32 req_index, + clib_thread_index_t thread_index) { http_req_t *req; req = http1_req_get (req_index, thread_index); diff --git a/src/plugins/http/http2/http2.c b/src/plugins/http/http2/http2.c index a447dc40038..67db185823c 100644 --- a/src/plugins/http/http2/http2.c +++ b/src/plugins/http/http2/http2.c @@ -163,7 +163,8 @@ http2_conn_alloc_req (http_conn_t *hc, u32 stream_id) } static inline void -http2_conn_free_req (http2_conn_ctx_t *h2c, http2_req_t *req, u32 thread_index) +http2_conn_free_req (http2_conn_ctx_t *h2c, http2_req_t *req, + clib_thread_index_t thread_index) { http2_main_t *h2m = &http2_main; @@ -202,7 +203,7 @@ http2_conn_get_req (http_conn_t *hc, u32 stream_id) } always_inline http2_req_t * -http2_req_get (u32 req_index, u32 thread_index) +http2_req_get (u32 req_index, clib_thread_index_t thread_index) { http2_main_t *h2m = &http2_main; @@ -990,7 +991,8 @@ http2_expect_preface (http_conn_t *hc, http2_conn_ctx_t *h2c) /*****************/ static u32 -http2_hc_index_get_by_req_index (u32 req_index, u32 thread_index) +http2_hc_index_get_by_req_index (u32 req_index, + clib_thread_index_t thread_index) { http2_req_t *req; @@ -999,7 +1001,7 @@ http2_hc_index_get_by_req_index (u32 req_index, u32 thread_index) } static transport_connection_t * -http2_req_get_connection (u32 req_index, u32 thread_index) +http2_req_get_connection (u32 req_index, clib_thread_index_t thread_index) { http2_req_t *req; req = http2_req_get (req_index, thread_index); @@ -1026,7 +1028,7 @@ static u8 * http2_format_req (u8 *s, va_list *args) { u32 req_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); http_conn_t *hc = va_arg (*args, http_conn_t *); u32 verbose = va_arg (*args, u32); http2_req_t *req; @@ -1097,13 +1099,15 @@ http2_app_tx_callback (http_conn_t *hc, u32 req_index, } static void -http2_app_rx_evt_callback (http_conn_t *hc, u32 req_index, u32 thread_index) +http2_app_rx_evt_callback (http_conn_t *hc, u32 req_index, + clib_thread_index_t thread_index) { /* TODO: continue tunnel RX */ } static void -http2_app_close_callback (http_conn_t *hc, u32 req_index, u32 thread_index) +http2_app_close_callback (http_conn_t *hc, u32 req_index, + clib_thread_index_t thread_index) { http2_req_t *req; @@ -1130,7 +1134,8 @@ http2_app_close_callback (http_conn_t *hc, u32 req_index, u32 thread_index) } static void -http2_app_reset_callback (http_conn_t *hc, u32 req_index, u32 thread_index) +http2_app_reset_callback (http_conn_t *hc, u32 req_index, + clib_thread_index_t thread_index) { http2_req_t *req; diff --git a/src/plugins/http/http_private.h b/src/plugins/http/http_private.h index 45faeceeab2..1f9812de7fa 100644 --- a/src/plugins/http/http_private.h +++ b/src/plugins/http/http_private.h @@ -264,18 +264,19 @@ typedef struct http_main_ typedef struct http_engine_vft_ { const char *name; - u32 (*hc_index_get_by_req_index) (u32 req_index, u32 thread_index); - transport_connection_t *(*req_get_connection) (u32 req_index, - u32 thread_index); + u32 (*hc_index_get_by_req_index) (u32 req_index, + clib_thread_index_t thread_index); + transport_connection_t *(*req_get_connection) ( + u32 req_index, clib_thread_index_t thread_index); u8 *(*format_req) (u8 *s, va_list *args); void (*app_tx_callback) (http_conn_t *hc, u32 req_index, transport_send_params_t *sp); void (*app_rx_evt_callback) (http_conn_t *hc, u32 req_index, - u32 thread_index); + clib_thread_index_t thread_index); void (*app_close_callback) (http_conn_t *hc, u32 req_index, - u32 thread_index); + clib_thread_index_t thread_index); void (*app_reset_callback) (http_conn_t *hc, u32 req_index, - u32 thread_index); + clib_thread_index_t thread_index); int (*transport_connected_callback) (http_conn_t *hc); void (*transport_rx_callback) (http_conn_t *hc); void (*transport_close_callback) (http_conn_t *hc); diff --git a/src/plugins/http_static/http_static.h b/src/plugins/http_static/http_static.h index 678fb6347d8..2b5c065e287 100644 --- a/src/plugins/http_static/http_static.h +++ b/src/plugins/http_static/http_static.h @@ -39,7 +39,7 @@ typedef struct hss_session_ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); u32 session_index; /** rx thread index */ - u32 thread_index; + clib_thread_index_t thread_index; /** vpp session index, handle */ u32 vpp_session_index; session_handle_t vpp_session_handle; @@ -82,7 +82,7 @@ typedef struct hss_session_handle_ struct { u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; }; u64 as_u64; }; @@ -226,7 +226,8 @@ void hss_register_url_handler (hss_url_handler_fn fp, const char *url, http_req_method_t type); void hss_session_send_data (hss_url_handler_args_t *args); void hss_builtinurl_json_handlers_init (void); -hss_session_t *hss_session_get (u32 thread_index, u32 hs_index); +hss_session_t *hss_session_get (clib_thread_index_t thread_index, + u32 hs_index); #endif /* __included_http_static_h__ */ diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index 9c5dfbab5c0..c62fe462b68 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -81,7 +81,7 @@ hss_confirm_data_read (hss_session_t *hs, u32 n_last_deq) } static hss_session_t * -hss_session_alloc (u32 thread_index) +hss_session_alloc (clib_thread_index_t thread_index) { hss_main_t *hsm = &hss_main; hss_session_t *hs; @@ -96,7 +96,7 @@ hss_session_alloc (u32 thread_index) } __clib_export hss_session_t * -hss_session_get (u32 thread_index, u32 hs_index) +hss_session_get (clib_thread_index_t thread_index, u32 hs_index) { hss_main_t *hsm = &hss_main; if (pool_is_free_index (hsm->sessions[thread_index], hs_index)) diff --git a/src/plugins/ikev2/ikev2.c b/src/plugins/ikev2/ikev2.c index 94de4f81b0e..c8183feddfd 100644 --- a/src/plugins/ikev2/ikev2.c +++ b/src/plugins/ikev2/ikev2.c @@ -2223,7 +2223,7 @@ ikev2_create_tunnel_interface (vlib_main_t *vm, ikev2_sa_t *sa, ikev2_child_sa_t *child, u32 sa_index, u32 child_index, u8 is_rekey, u8 kex) { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); ikev2_main_t *km = &ikev2_main; ipsec_crypto_alg_t encr_type; ipsec_integ_alg_t integ_type; @@ -3190,7 +3190,7 @@ ikev2_node_internal (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b; u16 nexts[VLIB_FRAME_SIZE], *next = nexts; ikev2_main_per_thread_data_t *ptd = ikev2_get_per_thread_data (); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; ikev2_stats_t _stats, *stats = &_stats; int res; diff --git a/src/plugins/ikev2/ikev2_priv.h b/src/plugins/ikev2/ikev2_priv.h index 2751657bff9..58da36d9d59 100644 --- a/src/plugins/ikev2/ikev2_priv.h +++ b/src/plugins/ikev2/ikev2_priv.h @@ -661,7 +661,7 @@ clib_error_t *ikev2_profile_natt_disable (u8 * name); static_always_inline ikev2_main_per_thread_data_t * ikev2_get_per_thread_data () { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); return vec_elt_at_index (ikev2_main.per_thread_data, thread_index); } #endif /* __included_ikev2_priv_h__ */ diff --git a/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c b/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c index 61476ebd85c..a4deae2ca60 100644 --- a/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c +++ b/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c @@ -646,7 +646,7 @@ vlib_node_registration_t ioam_cache_ts_timer_tick_node; typedef struct { - u32 thread_index; + clib_thread_index_t thread_index; } ioam_cache_ts_timer_tick_trace_t; /* packet trace format function */ @@ -696,7 +696,7 @@ expired_cache_ts_timer_callback (u32 * expired_timers) ioam_cache_main_t *cm = &ioam_cache_main; int i; u32 pool_index; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 count = 0; for (i = 0; i < vec_len (expired_timers); i++) diff --git a/src/plugins/l2tp/l2tp.c b/src/plugins/l2tp/l2tp.c index 907468b5900..cada9dc2656 100644 --- a/src/plugins/l2tp/l2tp.c +++ b/src/plugins/l2tp/l2tp.c @@ -151,7 +151,7 @@ test_counters_command_fn (vlib_main_t * vm, u32 session_index; u32 counter_index; u32 nincr = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; pool_foreach (session, lm->sessions) { diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c index 7ae1884ff31..0c4f21a4a78 100644 --- a/src/plugins/lb/lb.c +++ b/src/plugins/lb/lb.c @@ -108,7 +108,7 @@ u8 *format_lb_main (u8 * s, va_list * args) s = format(s, " #vips: %u\n", pool_elts(lbm->vips)); s = format(s, " #ass: %u\n", pool_elts(lbm->ass) - 1); - u32 thread_index; + clib_thread_index_t thread_index; for(thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++ ) { lb_hash_t *h = lbm->per_cpu[thread_index].sticky_ht; if (h) { @@ -764,7 +764,7 @@ next: int lb_flush_vip_as (u32 vip_index, u32 as_index) { - u32 thread_index; + clib_thread_index_t thread_index; vlib_thread_main_t *tm = vlib_get_thread_main(); lb_main_t *lbm = &lb_main; diff --git a/src/plugins/lb/node.c b/src/plugins/lb/node.c index a37fe11a9b4..1ddc556a8bf 100644 --- a/src/plugins/lb/node.c +++ b/src/plugins/lb/node.c @@ -124,7 +124,7 @@ format_lb_nat_trace (u8 * s, va_list * args) } lb_hash_t * -lb_get_sticky_table (u32 thread_index) +lb_get_sticky_table (clib_thread_index_t thread_index) { lb_main_t *lbm = &lb_main; lb_hash_t *sticky_ht = lbm->per_cpu[thread_index].sticky_ht; @@ -282,7 +282,7 @@ lb_node_fn (vlib_main_t * vm, { lb_main_t *lbm = &lb_main; u32 n_left_from, *from, next_index, *to_next, n_left_to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 lb_time = lb_hash_time_now (vm); lb_hash_t *sticky_ht = lb_get_sticky_table (thread_index); diff --git a/src/plugins/lisp/lisp-gpe/decap.c b/src/plugins/lisp/lisp-gpe/decap.c index 18e32675a32..b568fef24fa 100644 --- a/src/plugins/lisp/lisp-gpe/decap.c +++ b/src/plugins/lisp/lisp-gpe/decap.c @@ -102,9 +102,9 @@ next_index_to_iface (lisp_gpe_main_t * lgm, u32 next_index) } static_always_inline void -incr_decap_stats (vnet_main_t * vnm, u32 thread_index, u32 length, - u32 sw_if_index, u32 * last_sw_if_index, u32 * n_packets, - u32 * n_bytes) +incr_decap_stats (vnet_main_t *vnm, clib_thread_index_t thread_index, + u32 length, u32 sw_if_index, u32 *last_sw_if_index, + u32 *n_packets, u32 *n_bytes) { vnet_interface_main_t *im; diff --git a/src/plugins/lisp/lisp-gpe/interface.c b/src/plugins/lisp/lisp-gpe/interface.c index ed2b08f9aaf..5d3ad9463ea 100644 --- a/src/plugins/lisp/lisp-gpe/interface.c +++ b/src/plugins/lisp/lisp-gpe/interface.c @@ -233,7 +233,7 @@ l2_lisp_gpe_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node, { u32 n_left_from, next_index, *from, *to_next; lisp_gpe_main_t *lgm = &lisp_gpe_main; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; from = vlib_frame_vector_args (from_frame); diff --git a/src/plugins/mactime/node.c b/src/plugins/mactime/node.c index fad487e666e..dfe7a26c2af 100644 --- a/src/plugins/mactime/node.c +++ b/src/plugins/mactime/node.c @@ -87,7 +87,7 @@ mactime_node_inline (vlib_main_t * vm, clib_bihash_8_8_t *lut = &mm->lookup_table; u32 packets_ok = 0; f64 now; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vnet_main_t *vnm = vnet_get_main (); vnet_interface_main_t *im = &vnm->interface_main; u8 arc = im->output_feature_arc_index; diff --git a/src/plugins/map/ip4_map.c b/src/plugins/map/ip4_map.c index 652808e6d37..1ff585ceb3a 100644 --- a/src/plugins/map/ip4_map.c +++ b/src/plugins/map/ip4_map.c @@ -154,7 +154,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) next_index = node->cached_next_index; map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 *buffer0 = 0; while (n_left_from > 0) diff --git a/src/plugins/map/ip4_map_t.c b/src/plugins/map/ip4_map_t.c index fe29af458a2..ec89056e0cc 100644 --- a/src/plugins/map/ip4_map_t.c +++ b/src/plugins/map/ip4_map_t.c @@ -117,7 +117,7 @@ ip4_map_t_icmp (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { @@ -549,7 +549,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) n_left_from = frame->n_vectors; next_index = node->cached_next_index; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { diff --git a/src/plugins/map/ip6_map.c b/src/plugins/map/ip6_map.c index 3d9b21dfcd9..33d5a0ebbd3 100644 --- a/src/plugins/map/ip6_map.c +++ b/src/plugins/map/ip6_map.c @@ -166,7 +166,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vlib_node_get_runtime (vm, ip6_map_node.index); map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -559,7 +559,7 @@ ip6_map_post_ip4_reass (vlib_main_t * vm, vlib_node_get_runtime (vm, ip6_map_post_ip4_reass_node.index); map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = mm->domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -651,7 +651,7 @@ ip6_map_icmp_relay (vlib_main_t * vm, vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip6_map_icmp_relay_node.index); map_main_t *mm = &map_main; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u16 *fragment_ids, *fid; from = vlib_frame_vector_args (frame); diff --git a/src/plugins/map/ip6_map_t.c b/src/plugins/map/ip6_map_t.c index f8d894a013a..854410eb462 100644 --- a/src/plugins/map/ip6_map_t.c +++ b/src/plugins/map/ip6_map_t.c @@ -118,7 +118,7 @@ ip6_map_t_icmp (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { @@ -494,7 +494,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vlib_node_get_runtime (vm, ip6_map_t_node.index); map_main_t *mm = &map_main; vlib_combined_counter_main_t *cm = map_main.domain_counters; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c index d483f92b2fe..08b248df534 100644 --- a/src/plugins/memif/node.c +++ b/src/plugins/memif/node.c @@ -504,7 +504,7 @@ memif_device_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node, u32 n_left_to_next; u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT; vlib_buffer_t *buffer_ptrs[MEMIF_RX_VECTOR_SZ]; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; memif_per_thread_data_t *ptd = vec_elt_at_index (mm->per_thread_data, thread_index); u16 cur_slot, ring_size, n_slots, mask; @@ -763,7 +763,7 @@ memif_device_input_zc_inline (vlib_main_t *vm, vlib_node_runtime_t *node, u16 slot, s0; memif_desc_t *d0; vlib_buffer_t *b0, *b1, *b2, *b3; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; memif_per_thread_data_t *ptd = vec_elt_at_index (mm->per_thread_data, thread_index); u16 cur_slot, last_slot, ring_size, n_slots, mask, head; @@ -1061,7 +1061,7 @@ CLIB_MARCH_FN (memif_dma_completion_cb, void, vlib_main_t *vm, { memif_main_t *mm = &memif_main; memif_if_t *mif = vec_elt_at_index (mm->interfaces, b->cookie >> 16); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_left_to_next = 0; u16 nexts[MEMIF_RX_VECTOR_SZ], *next; u32 _to_next_bufs[MEMIF_RX_VECTOR_SZ], *to_next_bufs = _to_next_bufs, *bi; diff --git a/src/plugins/netmap/node.c b/src/plugins/netmap/node.c index 6169847fa79..85e7db5808b 100644 --- a/src/plugins/netmap/node.c +++ b/src/plugins/netmap/node.c @@ -98,7 +98,7 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, u32 n_free_bufs; struct netmap_ring *ring; int cur_ring; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_buffer_bytes = vlib_buffer_get_default_data_size (vm); if (nif->per_interface_next_index != ~0) @@ -255,7 +255,7 @@ VLIB_NODE_FN (netmap_input_node) (vlib_main_t * vm, { int i; u32 n_rx_packets = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; netmap_main_t *nm = &netmap_main; netmap_if_t *nmi; diff --git a/src/plugins/pppoe/pppoe_cp_node.c b/src/plugins/pppoe/pppoe_cp_node.c index c96559679f0..efafc448f98 100644 --- a/src/plugins/pppoe/pppoe_cp_node.c +++ b/src/plugins/pppoe/pppoe_cp_node.c @@ -73,7 +73,7 @@ VLIB_NODE_FN (pppoe_cp_dispatch_node) (vlib_main_t * vm, vnet_main_t * vnm = pem->vnet_main; vnet_interface_main_t * im = &vnm->interface_main; u32 pkts_decapsulated = 0; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; pppoe_entry_key_t cached_key; pppoe_entry_result_t cached_result; diff --git a/src/plugins/pppoe/pppoe_decap.c b/src/plugins/pppoe/pppoe_decap.c index 854364b1aca..17fbeaabb43 100644 --- a/src/plugins/pppoe/pppoe_decap.c +++ b/src/plugins/pppoe/pppoe_decap.c @@ -54,7 +54,7 @@ VLIB_NODE_FN (pppoe_input_node) (vlib_main_t * vm, vnet_main_t * vnm = pem->vnet_main; vnet_interface_main_t * im = &vnm->interface_main; u32 pkts_decapsulated = 0; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; pppoe_entry_key_t cached_key; pppoe_entry_result_t cached_result; diff --git a/src/plugins/pvti/input.c b/src/plugins/pvti/input.c index 6a8806e2795..d7727153aa7 100644 --- a/src/plugins/pvti/input.c +++ b/src/plugins/pvti/input.c @@ -124,7 +124,7 @@ pvti_input_node_common (vlib_main_t *vm, vlib_node_runtime_t *node, pvti_main_t *pvm = &pvti_main; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); pvti_per_thread_data_t *ptd = vec_elt_at_index (pvm->per_thread_data[is_ip6], thread_index); diff --git a/src/plugins/pvti/output.c b/src/plugins/pvti/output.c index 1939c6f585a..5fb6263795e 100644 --- a/src/plugins/pvti/output.c +++ b/src/plugins/pvti/output.c @@ -340,7 +340,7 @@ pvti_output_node_common (vlib_main_t *vm, vlib_node_runtime_t *node, u8 stream_index = pvti_get_stream_index (is_ip6); - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); pvti_per_thread_data_t *ptd = vec_elt_at_index (pvm->per_thread_data[is_ip6], thread_index); diff --git a/src/plugins/pvti/pvti.h b/src/plugins/pvti/pvti.h index ac097c5ecca..608610362d7 100644 --- a/src/plugins/pvti/pvti.h +++ b/src/plugins/pvti/pvti.h @@ -223,7 +223,7 @@ extern vlib_node_registration_t pvti_periodic_node; always_inline u8 pvti_get_stream_index (int is_ip6) { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); ASSERT ((thread_index & 0xffffff80) == 0); diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c index 10651f10e7e..77d35634fa9 100644 --- a/src/plugins/quic/quic.c +++ b/src/plugins/quic/quic.c @@ -51,7 +51,8 @@ static void quic_update_timer (quic_ctx_t * ctx); static void quic_check_quic_session_connected (quic_ctx_t * ctx); static int quic_reset_connection (u64 udp_session_handle, quic_rx_packet_ctx_t * pctx); -static void quic_proto_on_close (u32 ctx_index, u32 thread_index); +static void quic_proto_on_close (u32 ctx_index, + clib_thread_index_t thread_index); static quicly_stream_open_t on_stream_open; static quicly_closed_by_remote_t on_closed_by_remote; @@ -133,7 +134,7 @@ quic_crypto_context_alloc (u8 thread_index) } static crypto_context_t * -quic_crypto_context_get (u32 cr_index, u32 thread_index) +quic_crypto_context_get (u32 cr_index, clib_thread_index_t thread_index) { quic_main_t *qm = &quic_main; ASSERT (cr_index >> 24 == thread_index); @@ -381,7 +382,7 @@ error: /* Helper functions */ static u32 -quic_ctx_alloc (u32 thread_index) +quic_ctx_alloc (clib_thread_index_t thread_index) { quic_main_t *qm = &quic_main; quic_ctx_t *ctx; @@ -401,7 +402,7 @@ static void quic_ctx_free (quic_ctx_t * ctx) { QUIC_DBG (2, "Free ctx %u %x", ctx->c_thread_index, ctx->c_c_index); - u32 thread_index = ctx->c_thread_index; + clib_thread_index_t thread_index = ctx->c_thread_index; QUIC_ASSERT (ctx->timer_handle == QUIC_TIMER_HANDLE_INVALID); if (CLIB_DEBUG) clib_memset (ctx, 0xfb, sizeof (*ctx)); @@ -409,13 +410,13 @@ quic_ctx_free (quic_ctx_t * ctx) } static quic_ctx_t * -quic_ctx_get (u32 ctx_index, u32 thread_index) +quic_ctx_get (u32 ctx_index, clib_thread_index_t thread_index) { return pool_elt_at_index (quic_main.ctx_pool[thread_index], ctx_index); } static quic_ctx_t * -quic_ctx_get_if_valid (u32 ctx_index, u32 thread_index) +quic_ctx_get_if_valid (u32 ctx_index, clib_thread_index_t thread_index) { if (pool_is_free_index (quic_main.ctx_pool[thread_index], ctx_index)) return 0; @@ -1100,7 +1101,7 @@ quic_get_time (quicly_now_t * self) } static u32 -quic_set_time_now (u32 thread_index) +quic_set_time_now (clib_thread_index_t thread_index) { vlib_main_t *vlib_main = vlib_get_main (); f64 time = vlib_time_now (vlib_main); @@ -1396,7 +1397,7 @@ quic_connect (transport_endpoint_cfg_t * tep) } static void -quic_proto_on_close (u32 ctx_index, u32 thread_index) +quic_proto_on_close (u32 ctx_index, clib_thread_index_t thread_index) { int err; quic_ctx_t *ctx = quic_ctx_get_if_valid (ctx_index, thread_index); @@ -1548,7 +1549,7 @@ quic_stop_listen (u32 lctx_index) } static transport_connection_t * -quic_connection_get (u32 ctx_index, u32 thread_index) +quic_connection_get (u32 ctx_index, clib_thread_index_t thread_index) { quic_ctx_t *ctx; ctx = quic_ctx_get (ctx_index, thread_index); @@ -1600,7 +1601,7 @@ static u8 * format_quic_connection (u8 * s, va_list * args) { u32 qc_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); quic_ctx_t *ctx = quic_ctx_get (qc_index, thread_index); s = format (s, "%U", format_quic_ctx, ctx, verbose); @@ -1611,7 +1612,7 @@ static u8 * format_quic_half_open (u8 * s, va_list * args) { u32 qc_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); quic_ctx_t *ctx = quic_ctx_get (qc_index, thread_index); s = format (s, "[#%d][Q] half-open app %u", thread_index, ctx->parent_app_id); @@ -1623,7 +1624,7 @@ static u8 * format_quic_listener (u8 * s, va_list * args) { u32 tci = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); quic_ctx_t *ctx = quic_ctx_get (tci, thread_index); s = format (s, "%U", format_quic_ctx, ctx, verbose); @@ -1660,7 +1661,7 @@ quic_on_quic_session_connected (quic_ctx_t * ctx) session_t *quic_session; app_worker_t *app_wrk; u32 ctx_id = ctx->c_c_index; - u32 thread_index = ctx->c_thread_index; + clib_thread_index_t thread_index = ctx->c_thread_index; int rv; quic_session = session_alloc (thread_index); @@ -1775,7 +1776,7 @@ static void quic_transfer_connection (u32 ctx_index, u32 dest_thread) { quic_ctx_t *ctx, *temp_ctx; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); QUIC_DBG (2, "Transferring conn %u to thread %u", ctx_index, dest_thread); @@ -1811,7 +1812,7 @@ quic_udp_session_connected_callback (u32 quic_app_index, u32 ctx_index, app_worker_t *app_wrk; quicly_conn_t *conn; quic_ctx_t *ctx; - u32 thread_index; + clib_thread_index_t thread_index; int ret; quicly_context_t *quicly_ctx; @@ -1918,7 +1919,7 @@ quic_udp_session_accepted_callback (session_t * udp_session) u32 ctx_index; quic_ctx_t *ctx, *lctx; session_t *udp_listen_session; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); udp_listen_session = listen_session_get_from_handle (udp_session->listener_handle); @@ -2199,7 +2200,7 @@ quic_process_one_rx_packet (u64 udp_session_handle, svm_fifo_t * f, { size_t plen; u32 full_len, ret; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 cur_deq = svm_fifo_max_dequeue (f) - fifo_offset; quicly_context_t *quicly_ctx; session_t *udp_session; @@ -2281,7 +2282,7 @@ quic_udp_session_rx_callback (session_t * udp_session) u32 max_deq; u64 udp_session_handle = session_handle (udp_session); int rv = 0; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 cur_deq, fifo_offset, max_packets, i; quic_rx_packet_ctx_t packets_ctx[QUIC_RCV_MAX_PACKETS]; @@ -2306,7 +2307,7 @@ rx_start: #endif for (i = 0; i < max_packets; i++) { - packets_ctx[i].thread_index = UINT32_MAX; + packets_ctx[i].thread_index = CLIB_INVALID_THREAD_INDEX; packets_ctx[i].ctx_index = UINT32_MAX; packets_ctx[i].ptype = QUIC_PACKET_TYPE_DROP; @@ -2421,8 +2422,8 @@ quic_get_transport_listener_endpoint (u32 listener_index, } static void -quic_get_transport_endpoint (u32 ctx_index, u32 thread_index, - transport_endpoint_t * tep, u8 is_lcl) +quic_get_transport_endpoint (u32 ctx_index, clib_thread_index_t thread_index, + transport_endpoint_t *tep, u8 is_lcl) { quic_ctx_t *ctx; ctx = quic_ctx_get (ctx_index, thread_index); diff --git a/src/plugins/quic/quic.h b/src/plugins/quic/quic.h index 081bcb120e9..4474aa15e75 100644 --- a/src/plugins/quic/quic.h +++ b/src/plugins/quic/quic.h @@ -205,7 +205,7 @@ typedef struct quic_session_cache_ typedef struct quic_stream_data_ { u32 ctx_id; - u32 thread_index; + clib_thread_index_t thread_index; u32 app_rx_data_len; /**< bytes received, to be read by external app */ u32 app_tx_data_len; /**< bytes sent */ } quic_stream_data_t; @@ -232,7 +232,7 @@ typedef struct quic_rx_packet_ctx_ quicly_decoded_packet_t packet; u8 data[QUIC_MAX_PACKET_SIZE]; u32 ctx_index; - u32 thread_index; + clib_thread_index_t thread_index; union { struct sockaddr sa; diff --git a/src/plugins/sflow/sflow.c b/src/plugins/sflow/sflow.c index 02a74d2c7f5..14d07d69233 100644 --- a/src/plugins/sflow/sflow.c +++ b/src/plugins/sflow/sflow.c @@ -246,7 +246,8 @@ total_drops (sflow_main_t *smp) { // sum sendmsg and worker-fifo drops u32 all_drops = smp->psample_send_drops; - for (u32 thread_index = 0; thread_index < smp->total_threads; thread_index++) + for (clib_thread_index_t thread_index = 0; thread_index < smp->total_threads; + thread_index++) { sflow_per_thread_data_t *sfwk = vec_elt_at_index (smp->per_thread_data, thread_index); @@ -321,8 +322,8 @@ read_worker_fifos (sflow_main_t *smp) for (; batch < SFLOW_READ_BATCH; batch++) { u32 psample_send = 0, psample_send_fail = 0; - for (u32 thread_index = 0; thread_index < smp->total_threads; - thread_index++) + for (clib_thread_index_t thread_index = 0; + thread_index < smp->total_threads; thread_index++) { sflow_per_thread_data_t *sfwk = vec_elt_at_index (smp->per_thread_data, thread_index); @@ -388,7 +389,8 @@ read_node_counters (sflow_main_t *smp, sflow_err_ctrs_t *ctrs) { for (u32 ec = 0; ec < SFLOW_N_ERROR; ec++) ctrs->counters[ec] = 0; - for (u32 thread_index = 0; thread_index < smp->total_threads; thread_index++) + for (clib_thread_index_t thread_index = 0; thread_index < smp->total_threads; + thread_index++) { sflow_per_thread_data_t *sfwk = vec_elt_at_index (smp->per_thread_data, thread_index); @@ -487,7 +489,8 @@ sflow_set_worker_sampling_state (sflow_main_t *smp) vlib_thread_main_t *tm = &vlib_thread_main; smp->total_threads = 1 + tm->n_threads; vec_validate (smp->per_thread_data, smp->total_threads); - for (u32 thread_index = 0; thread_index < smp->total_threads; thread_index++) + for (clib_thread_index_t thread_index = 0; thread_index < smp->total_threads; + thread_index++) { sflow_per_thread_data_t *sfwk = vec_elt_at_index (smp->per_thread_data, thread_index); diff --git a/src/plugins/snort/enqueue.c b/src/plugins/snort/enqueue.c index 84efb4d432f..ae04c58bba0 100644 --- a/src/plugins/snort/enqueue.c +++ b/src/plugins/snort/enqueue.c @@ -93,7 +93,7 @@ snort_enq_node_inline (vlib_main_t *vm, vlib_node_runtime_t *node, snort_main_t *sm = &snort_main; snort_instance_t *si = 0; snort_qpair_t *qp = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_left = frame->n_vectors; u32 n_trace = 0; u32 total_enq = 0, n_unprocessed = 0; diff --git a/src/plugins/srtp/srtp.c b/src/plugins/srtp/srtp.c index 5426b7aa03f..f86b7be980e 100644 --- a/src/plugins/srtp/srtp.c +++ b/src/plugins/srtp/srtp.c @@ -19,11 +19,11 @@ static srtp_main_t srtp_main; -static void srtp_disconnect (u32 ctx_handle, u32 thread_index); +static void srtp_disconnect (u32 ctx_handle, clib_thread_index_t thread_index); static void srtp_disconnect_transport (srtp_tc_t *ctx); static inline u32 -srtp_ctx_alloc_w_thread (u32 thread_index) +srtp_ctx_alloc_w_thread (clib_thread_index_t thread_index) { srtp_tc_t *ctx; pool_get_aligned_safe (srtp_main.ctx_pool[thread_index], ctx, @@ -36,7 +36,7 @@ srtp_ctx_alloc_w_thread (u32 thread_index) } static inline srtp_tc_t * -srtp_ctx_get_w_thread (u32 ctx_index, u32 thread_index) +srtp_ctx_get_w_thread (u32 ctx_index, clib_thread_index_t thread_index) { return pool_elt_at_index (srtp_main.ctx_pool[thread_index], ctx_index); } @@ -82,7 +82,7 @@ srtp_ctx_free (srtp_tc_t *ctx) } static inline u32 -srtp_ctx_attach (u32 thread_index, void *ctx_ptr) +srtp_ctx_attach (clib_thread_index_t thread_index, void *ctx_ptr) { srtp_tc_t *ctx; @@ -688,7 +688,7 @@ srtp_disconnect_transport (srtp_tc_t *ctx) } static void -srtp_disconnect (u32 ctx_handle, u32 thread_index) +srtp_disconnect (u32 ctx_handle, clib_thread_index_t thread_index) { session_t *app_session; srtp_tc_t *ctx; @@ -801,7 +801,7 @@ srtp_stop_listen (u32 lctx_index) } transport_connection_t * -srtp_connection_get (u32 ctx_index, u32 thread_index) +srtp_connection_get (u32 ctx_index, clib_thread_index_t thread_index) { srtp_tc_t *ctx; ctx = srtp_ctx_get_w_thread (ctx_index, thread_index); @@ -895,7 +895,7 @@ u8 * format_srtp_connection (u8 *s, va_list *args) { u32 ctx_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); srtp_tc_t *ctx; @@ -935,7 +935,7 @@ format_srtp_half_open (u8 *s, va_list *args) } static void -srtp_transport_endpoint_get (u32 ctx_handle, u32 thread_index, +srtp_transport_endpoint_get (u32 ctx_handle, clib_thread_index_t thread_index, transport_endpoint_t *tep, u8 is_lcl) { srtp_tc_t *ctx = srtp_ctx_get_w_thread (ctx_handle, thread_index); diff --git a/src/plugins/srv6-ad-flow/node.c b/src/plugins/srv6-ad-flow/node.c index 66be2dc7972..28fbc105d84 100644 --- a/src/plugins/srv6-ad-flow/node.c +++ b/src/plugins/srv6-ad-flow/node.c @@ -583,7 +583,7 @@ srv6_ad_flow_localsid_fn (vlib_main_t *vm, vlib_node_runtime_t *node, ip6_sr_main_t *srm = &sr_main; f64 now = vlib_time_now (vm); u32 n_left_from, next_index, *from, *to_next, n_left_to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/plugins/srv6-am/node.c b/src/plugins/srv6-am/node.c index beef6a30910..012afda581b 100644 --- a/src/plugins/srv6-am/node.c +++ b/src/plugins/srv6-am/node.c @@ -147,7 +147,7 @@ srv6_am_localsid_fn (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { diff --git a/src/plugins/srv6-mobile/node.c b/src/plugins/srv6-mobile/node.c index ed0697a8009..c8f619cf044 100644 --- a/src/plugins/srv6-mobile/node.c +++ b/src/plugins/srv6-mobile/node.c @@ -325,7 +325,7 @@ VLIB_NODE_FN (srv6_end_m_gtp4_e) srv6_end_main_v4_t *sm = &srv6_end_main_v4; ip6_sr_main_t *sm2 = &sr_main; u32 n_left_from, next_index, *from, *to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 good_n = 0, bad_n = 0; @@ -1327,7 +1327,7 @@ VLIB_NODE_FN (srv6_end_m_gtp6_e) srv6_end_main_v6_t *sm = &srv6_end_main_v6; ip6_sr_main_t *sm2 = &sr_main; u32 n_left_from, next_index, *from, *to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 good_n = 0, bad_n = 0; @@ -2088,7 +2088,7 @@ VLIB_NODE_FN (srv6_end_m_gtp6_d) srv6_end_main_v6_decap_t *sm = &srv6_end_main_v6_decap; ip6_sr_main_t *sm2 = &sr_main; u32 n_left_from, next_index, *from, *to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; ip6_sr_localsid_t *ls0; srv6_end_gtp6_d_param_t *ls_param; @@ -2238,7 +2238,7 @@ VLIB_NODE_FN (srv6_end_m_gtp6_d_di) srv6_end_main_v6_decap_di_t *sm = &srv6_end_main_v6_decap_di; ip6_sr_main_t *sm2 = &sr_main; u32 n_left_from, next_index, *from, *to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; srv6_end_gtp6_d_param_t *ls_param; u32 good_n = 0, bad_n = 0; @@ -2686,7 +2686,7 @@ VLIB_NODE_FN (srv6_end_m_gtp6_dt) srv6_end_main_v6_dt_t *sm = &srv6_end_main_v6_dt; ip6_sr_main_t *sm2 = &sr_main; u32 n_left_from, next_index, *from, *to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 good_n = 0, bad_n = 0; diff --git a/src/plugins/tlsmbedtls/tls_mbedtls.c b/src/plugins/tlsmbedtls/tls_mbedtls.c index 2f4757e28a1..44d48b1edb4 100644 --- a/src/plugins/tlsmbedtls/tls_mbedtls.c +++ b/src/plugins/tlsmbedtls/tls_mbedtls.c @@ -127,7 +127,7 @@ mbedtls_ctx_get_w_thread (u32 ctx_index, u8 thread_index) static int tls_init_ctr_seed_drbgs (void) { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); mbedtls_main_t *tm = &mbedtls_main; u8 *pers; int rv; diff --git a/src/plugins/tlsopenssl/tls_async.c b/src/plugins/tlsopenssl/tls_async.c index cd08da5d9ea..e28d730e307 100644 --- a/src/plugins/tlsopenssl/tls_async.c +++ b/src/plugins/tlsopenssl/tls_async.c @@ -114,8 +114,8 @@ openssl_async_t openssl_async_main; static vlib_node_registration_t tls_async_process_node; /* to avoid build warning */ -void session_send_rpc_evt_to_thread (u32 thread_index, void *fp, - void *rpc_args); +void session_send_rpc_evt_to_thread (clib_thread_index_t thread_index, + void *fp, void *rpc_args); void evt_pool_init (vlib_main_t * vm) @@ -528,7 +528,7 @@ openssl_async_node_enable_disable (u8 is_en) } int -tls_async_do_job (int eidx, u32 thread_index) +tls_async_do_job (int eidx, clib_thread_index_t thread_index) { tls_ctx_t *ctx; openssl_evt_t *event; diff --git a/src/plugins/tlsopenssl/tls_openssl.c b/src/plugins/tlsopenssl/tls_openssl.c index f0be025a207..5b57e706586 100644 --- a/src/plugins/tlsopenssl/tls_openssl.c +++ b/src/plugins/tlsopenssl/tls_openssl.c @@ -35,7 +35,7 @@ openssl_main_t openssl_main; static u32 -openssl_ctx_alloc_w_thread (u32 thread_index) +openssl_ctx_alloc_w_thread (clib_thread_index_t thread_index) { openssl_main_t *om = &openssl_main; openssl_ctx_t **ctx; @@ -102,7 +102,7 @@ openssl_ctx_detach (tls_ctx_t *ctx) } static u32 -openssl_ctx_attach (u32 thread_index, void *ctx_ptr) +openssl_ctx_attach (clib_thread_index_t thread_index, void *ctx_ptr) { openssl_main_t *om = &openssl_main; session_handle_t sh; diff --git a/src/plugins/unittest/tcp_test.c b/src/plugins/unittest/tcp_test.c index 33c5387b98f..6236ccdfe08 100644 --- a/src/plugins/unittest/tcp_test.c +++ b/src/plugins/unittest/tcp_test.c @@ -1002,7 +1002,7 @@ tbt_seq_lt (u32 a, u32 b) } static void -tcp_test_set_time (u32 thread_index, u32 val) +tcp_test_set_time (clib_thread_index_t thread_index, u32 val) { session_main.wrk[thread_index].last_vlib_time = val; tcp_set_time_now (&tcp_main.wrk[thread_index], val); @@ -1011,7 +1011,7 @@ tcp_test_set_time (u32 thread_index, u32 val) static int tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input) { - u32 thread_index = 0, snd_una, *min_seqs = 0; + clib_thread_index_t thread_index = 0, snd_una, *min_seqs = 0; tcp_rate_sample_t _rs = { 0 }, *rs = &_rs; tcp_connection_t _tc, *tc = &_tc; sack_scoreboard_t *sb = &tc->sack_sb; @@ -1337,7 +1337,7 @@ tcp_test_delivery (vlib_main_t * vm, unformat_input_t * input) static int tcp_test_bt (vlib_main_t * vm, unformat_input_t * input) { - u32 thread_index = 0; + clib_thread_index_t thread_index = 0; tcp_rate_sample_t _rs = { 0 }, *rs = &_rs; tcp_connection_t _tc, *tc = &_tc; int __clib_unused verbose = 0, i; diff --git a/src/plugins/vhost/vhost_user.c b/src/plugins/vhost/vhost_user.c index 35aca37926c..592a126c683 100644 --- a/src/plugins/vhost/vhost_user.c +++ b/src/plugins/vhost/vhost_user.c @@ -347,7 +347,7 @@ vhost_user_vring_close (vhost_user_intf_t * vui, u32 qid) u16 q = vui->vrings[qid].qid; u32 queue_index = vui->vrings[qid].queue_index; u32 mode = vui->vrings[qid].mode; - u32 thread_index = vui->vrings[qid].thread_index; + clib_thread_index_t thread_index = vui->vrings[qid].thread_index; vhost_user_vring_init (vui, qid); vui->vrings[qid].qid = q; vui->vrings[qid].queue_index = queue_index; @@ -1441,7 +1441,7 @@ vhost_user_delete_if (vnet_main_t * vnm, vlib_main_t * vm, u32 sw_if_index) vhost_user_vring_t *txvq = &vui->vrings[qid]; if ((txvq->mode == VNET_HW_IF_RX_MODE_POLLING) && - (txvq->thread_index != ~0)) + (txvq->thread_index != CLIB_INVALID_THREAD_INDEX)) { vhost_cpu_t *cpu = vec_elt_at_index (vum->cpus, txvq->thread_index); ASSERT (cpu->polling_q_count != 0); diff --git a/src/plugins/vhost/vhost_user.h b/src/plugins/vhost/vhost_user.h index fe2ee21a0c4..9e461979007 100644 --- a/src/plugins/vhost/vhost_user.h +++ b/src/plugins/vhost/vhost_user.h @@ -231,7 +231,7 @@ typedef struct u16 last_kick; u8 first_kick; u32 queue_index; - u32 thread_index; + clib_thread_index_t thread_index; } vhost_user_vring_t; #define VHOST_USER_EVENT_START_TIMER 1 diff --git a/src/plugins/vhost/vhost_user_output.c b/src/plugins/vhost/vhost_user_output.c index 2ae5c56d4c6..3052ae39ec1 100644 --- a/src/plugins/vhost/vhost_user_output.c +++ b/src/plugins/vhost/vhost_user_output.c @@ -382,7 +382,7 @@ vhost_user_device_class_packed (vlib_main_t *vm, vlib_node_runtime_t *node, vhost_user_main_t *vum = &vhost_user_main; u32 qid = rxvq->qid; u8 error; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vhost_cpu_t *cpu = &vum->cpus[thread_index]; u32 map_hint = 0; u8 retry = 8; @@ -698,7 +698,7 @@ VNET_DEVICE_CLASS_TX_FN (vhost_user_device_class) (vlib_main_t * vm, u32 qid; vhost_user_vring_t *rxvq; u8 error; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vhost_cpu_t *cpu = &vum->cpus[thread_index]; u32 map_hint = 0; u8 retry = 8; @@ -1051,7 +1051,7 @@ vhost_user_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index, return clib_error_return (0, "unsupported"); } - if (txvq->thread_index == ~0) + if (txvq->thread_index == CLIB_INVALID_THREAD_INDEX) return clib_error_return (0, "Queue initialization is not finished yet"); cpu = vec_elt_at_index (vum->cpus, txvq->thread_index); diff --git a/src/plugins/vmxnet3/input.c b/src/plugins/vmxnet3/input.c index 25632546b6d..55fb418e501 100644 --- a/src/plugins/vmxnet3/input.c +++ b/src/plugins/vmxnet3/input.c @@ -203,7 +203,7 @@ vmxnet3_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vmxnet3_rx_comp *rx_comp; u32 desc_idx; vmxnet3_rxq_t *rxq; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 buffer_indices[VLIB_FRAME_SIZE], *bi; u16 nexts[VLIB_FRAME_SIZE], *next; vmxnet3_rx_ring *ring; diff --git a/src/plugins/vmxnet3/vmxnet3.h b/src/plugins/vmxnet3/vmxnet3.h index 89602f8ee9e..8de992eaffe 100644 --- a/src/plugins/vmxnet3/vmxnet3.h +++ b/src/plugins/vmxnet3/vmxnet3.h @@ -523,7 +523,7 @@ typedef struct u32 mode; u8 buffer_pool_index; u32 queue_index; - u32 thread_index; + clib_thread_index_t thread_index; vmxnet3_rx_ring rx_ring[VMXNET3_RX_RING_SIZE]; vmxnet3_rx_desc *rx_desc[VMXNET3_RX_RING_SIZE]; vmxnet3_rx_comp *rx_comp; diff --git a/src/plugins/vxlan-gpe/decap.c b/src/plugins/vxlan-gpe/decap.c index 29f03e3b380..80f2facef29 100644 --- a/src/plugins/vxlan-gpe/decap.c +++ b/src/plugins/vxlan-gpe/decap.c @@ -210,7 +210,7 @@ vxlan_gpe_input (vlib_main_t * vm, vxlan4_gpe_tunnel_cache_t last4; vxlan6_gpe_tunnel_cache_t last6; u32 pkts_decapsulated = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; if (is_ip4) diff --git a/src/plugins/vxlan-gpe/encap.c b/src/plugins/vxlan-gpe/encap.c index d8bab921493..701c3af55b5 100644 --- a/src/plugins/vxlan-gpe/encap.c +++ b/src/plugins/vxlan-gpe/encap.c @@ -156,7 +156,7 @@ vxlan_gpe_encap (vlib_main_t * vm, vnet_main_t *vnm = ngm->vnet_main; vnet_interface_main_t *im = &vnm->interface_main; u32 pkts_encapsulated = 0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; diff --git a/src/plugins/vxlan/decap.c b/src/plugins/vxlan/decap.c index 5f28c5e97bb..4ad35bc2d5d 100644 --- a/src/plugins/vxlan/decap.c +++ b/src/plugins/vxlan/decap.c @@ -193,7 +193,7 @@ vxlan_input (vlib_main_t * vm, last_tunnel_cache4 last4; last_tunnel_cache6 last6; u32 pkts_dropped = 0; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); if (is_ip4) clib_memset (&last4, 0xff, sizeof last4); @@ -1039,7 +1039,7 @@ VLIB_NODE_FN (vxlan4_flow_input_node) (vlib_main_t * vm, [VXLAN_FLOW_NEXT_L2_INPUT] = im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, }; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 *from = vlib_frame_vector_args (f); u32 n_left_from = f->n_vectors; diff --git a/src/plugins/vxlan/encap.c b/src/plugins/vxlan/encap.c index 98464d809ba..60181bff451 100644 --- a/src/plugins/vxlan/encap.c +++ b/src/plugins/vxlan/encap.c @@ -78,7 +78,7 @@ vxlan_encap_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_combined_counter_main_t *tx_counter = im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX; u32 pkts_encapsulated = 0; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 sw_if_index0 = 0, sw_if_index1 = 0; u32 next0 = 0, next1 = 0; vxlan_tunnel_t *t0 = NULL, *t1 = NULL; diff --git a/src/plugins/wireguard/wireguard_input.c b/src/plugins/wireguard/wireguard_input.c index 1eb7fbfed0b..0ae0480fc2c 100644 --- a/src/plugins/wireguard/wireguard_input.c +++ b/src/plugins/wireguard/wireguard_input.c @@ -698,7 +698,7 @@ wg_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; vlib_buffer_t *lb; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vnet_crypto_op_t **crypto_ops; const u16 drop_next = WG_INPUT_NEXT_PUNT; message_type_t header_type; diff --git a/src/plugins/wireguard/wireguard_output_tun.c b/src/plugins/wireguard/wireguard_output_tun.c index c9411f6ff20..7bbec11fdcb 100644 --- a/src/plugins/wireguard/wireguard_output_tun.c +++ b/src/plugins/wireguard/wireguard_output_tun.c @@ -436,7 +436,7 @@ wg_output_tun_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vnet_crypto_op_t **crypto_ops; u16 nexts[VLIB_FRAME_SIZE], *next = nexts; vlib_buffer_t *sync_bufs[VLIB_FRAME_SIZE]; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u16 n_sync = 0; const u16 drop_next = WG_OUTPUT_NEXT_ERROR; const u8 is_async = wg_op_mode_is_set_ASYNC (); diff --git a/src/vlib/buffer_funcs.c b/src/vlib/buffer_funcs.c index d910b25afac..ce09a51c600 100644 --- a/src/vlib/buffer_funcs.c +++ b/src/vlib/buffer_funcs.c @@ -297,7 +297,7 @@ vlib_buffer_enqueue_to_thread_inline (vlib_main_t *vm, u32 drop_list[VLIB_FRAME_SIZE], n_drop = 0; vlib_frame_bitmap_t mask, used_elts = {}; vlib_frame_queue_elt_t *hf = 0; - u16 thread_index; + clib_thread_index_t thread_index; u32 n_comp, off = 0, n_left = n_packets; thread_index = thread_indices[0]; diff --git a/src/vlib/counter.h b/src/vlib/counter.h index f9da576a5f2..a9c261770d4 100644 --- a/src/vlib/counter.h +++ b/src/vlib/counter.h @@ -68,7 +68,7 @@ u32 vlib_simple_counter_n_counters (const vlib_simple_counter_main_t * cm); /** Pre-fetch a per-thread simple counter for the given object index */ always_inline void vlib_prefetch_simple_counter (const vlib_simple_counter_main_t *cm, - u32 thread_index, u32 index) + clib_thread_index_t thread_index, u32 index) { counter_t *my_counters; @@ -86,8 +86,9 @@ vlib_prefetch_simple_counter (const vlib_simple_counter_main_t *cm, @param increment - (u64) quantitiy to add to the counter */ always_inline void -vlib_increment_simple_counter (vlib_simple_counter_main_t * cm, - u32 thread_index, u32 index, u64 increment) +vlib_increment_simple_counter (vlib_simple_counter_main_t *cm, + clib_thread_index_t thread_index, u32 index, + u64 increment) { counter_t *my_counters; @@ -102,8 +103,9 @@ vlib_increment_simple_counter (vlib_simple_counter_main_t * cm, @param increment - (u64) quantitiy remove from the counter value */ always_inline void -vlib_decrement_simple_counter (vlib_simple_counter_main_t * cm, - u32 thread_index, u32 index, u64 decrement) +vlib_decrement_simple_counter (vlib_simple_counter_main_t *cm, + clib_thread_index_t thread_index, u32 index, + u64 decrement) { counter_t *my_counters; @@ -121,8 +123,9 @@ vlib_decrement_simple_counter (vlib_simple_counter_main_t * cm, @param value - (u64) quantitiy to set to the counter */ always_inline void -vlib_set_simple_counter (vlib_simple_counter_main_t * cm, - u32 thread_index, u32 index, u64 value) +vlib_set_simple_counter (vlib_simple_counter_main_t *cm, + clib_thread_index_t thread_index, u32 index, + u64 value) { counter_t *my_counters; @@ -246,9 +249,9 @@ void vlib_clear_combined_counters (vlib_combined_counter_main_t * cm); */ always_inline void -vlib_increment_combined_counter (vlib_combined_counter_main_t * cm, - u32 thread_index, - u32 index, u64 n_packets, u64 n_bytes) +vlib_increment_combined_counter (vlib_combined_counter_main_t *cm, + clib_thread_index_t thread_index, u32 index, + u64 n_packets, u64 n_bytes) { vlib_counter_t *my_counters; @@ -261,8 +264,8 @@ vlib_increment_combined_counter (vlib_combined_counter_main_t * cm, /** Pre-fetch a per-thread combined counter for the given object index */ always_inline void -vlib_prefetch_combined_counter (const vlib_combined_counter_main_t * cm, - u32 thread_index, u32 index) +vlib_prefetch_combined_counter (const vlib_combined_counter_main_t *cm, + clib_thread_index_t thread_index, u32 index) { vlib_counter_t *cpu_counters; diff --git a/src/vlib/format.c b/src/vlib/format.c index 98010620a5d..8ed2535fe8a 100644 --- a/src/vlib/format.c +++ b/src/vlib/format.c @@ -213,7 +213,7 @@ unformat_vlib_tmpfile (unformat_input_t * input, va_list * args) u8 * format_vlib_thread_name (u8 * s, va_list * args) { - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); if (thread_index == 0) return format (s, "main"); @@ -226,7 +226,7 @@ format_vlib_thread_name (u8 * s, va_list * args) u8 * format_vlib_thread_name_and_index (u8 * s, va_list * args) { - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); return format (s, "%U (%u)", format_vlib_thread_name, thread_index, thread_index); diff --git a/src/vlib/global_funcs.h b/src/vlib/global_funcs.h index 3c0fdb78364..2558e611750 100644 --- a/src/vlib/global_funcs.h +++ b/src/vlib/global_funcs.h @@ -26,7 +26,7 @@ vlib_get_n_threads () } always_inline vlib_main_t * -vlib_get_main_by_index (u32 thread_index) +vlib_get_main_by_index (clib_thread_index_t thread_index) { vlib_main_t *vm; vm = vlib_global_main.vlib_mains[thread_index]; diff --git a/src/vlib/log.h b/src/vlib/log.h index a4f5a4b0bc2..5bacd7f45cb 100644 --- a/src/vlib/log.h +++ b/src/vlib/log.h @@ -41,7 +41,7 @@ typedef enum typedef struct { - u16 thread_index; + clib_thread_index_t thread_index; u8 level; /* vlib_log_level_t */ vlib_log_class_t class; f64 timestamp; diff --git a/src/vlib/main.h b/src/vlib/main.h index aa7e1dbaf84..270b203bd68 100644 --- a/src/vlib/main.h +++ b/src/vlib/main.h @@ -204,7 +204,7 @@ typedef struct vlib_main_t clib_random_buffer_t random_buffer; /* thread, cpu and numa_node indices */ - u32 thread_index; + clib_thread_index_t thread_index; u32 numa_node; /* control-plane API queue signal pending, length indication */ @@ -325,13 +325,10 @@ extern vlib_global_main_t vlib_global_main; always_inline f64 vlib_time_now (vlib_main_t * vm) { -#if CLIB_DEBUG > 0 - extern __thread uword __os_thread_index; -#endif /* * Make sure folks don't pass &vlib_global_main from a worker thread. */ - ASSERT (vm->thread_index == __os_thread_index); + ASSERT (vm->thread_index == os_get_thread_index ()); return clib_time_now (&vm->clib_time) + vm->time_offset; } diff --git a/src/vlib/punt_node.c b/src/vlib/punt_node.c index 4b81a61715a..800d520733d 100644 --- a/src/vlib/punt_node.c +++ b/src/vlib/punt_node.c @@ -68,14 +68,10 @@ format_punt_trace (u8 * s, va_list * args) } always_inline u32 -punt_replicate (vlib_main_t * vm, - vlib_node_runtime_t * node, - u32 thread_index, - vlib_buffer_t * b0, - u32 bi0, - vlib_punt_reason_t pr0, - u32 * next_index, - u32 * n_left_to_next, u32 ** to_next, u32 * n_dispatched) +punt_replicate (vlib_main_t *vm, vlib_node_runtime_t *node, + clib_thread_index_t thread_index, vlib_buffer_t *b0, u32 bi0, + vlib_punt_reason_t pr0, u32 *next_index, u32 *n_left_to_next, + u32 **to_next, u32 *n_dispatched) { /* multiple clients => replicate a copy to each */ u16 n_clones0, n_cloned0, clone0; @@ -134,13 +130,10 @@ punt_replicate (vlib_main_t * vm, } always_inline u32 -punt_dispatch_one (vlib_main_t * vm, - vlib_node_runtime_t * node, - vlib_combined_counter_main_t * cm, - u32 thread_index, - u32 bi0, - u32 * next_index, - u32 * n_left_to_next, u32 ** to_next, u32 * n_dispatched) +punt_dispatch_one (vlib_main_t *vm, vlib_node_runtime_t *node, + vlib_combined_counter_main_t *cm, + clib_thread_index_t thread_index, u32 bi0, u32 *next_index, + u32 *n_left_to_next, u32 **to_next, u32 *n_dispatched) { vlib_punt_reason_t pr0; vlib_buffer_t *b0; diff --git a/src/vlib/threads.c b/src/vlib/threads.c index bf5031b7ee4..949ec9c3c0e 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -1549,7 +1549,7 @@ vlib_workers_sync (void) if (!(*vlib_worker_threads->wait_at_barrier) && !clib_atomic_swap_rel_n (&vlib_worker_threads->wait_before_barrier, 1)) { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); vlib_rpc_call_main_thread (vlib_worker_sync_rpc, (u8 *) &thread_index, sizeof (thread_index)); vlib_worker_flush_pending_rpc_requests (vlib_get_main ()); diff --git a/src/vlib/threads.h b/src/vlib/threads.h index 8c5d56058eb..94bb335fb3b 100644 --- a/src/vlib/threads.h +++ b/src/vlib/threads.h @@ -186,7 +186,7 @@ void vlib_worker_wait_one_loop (void); */ void vlib_worker_flush_pending_rpc_requests (vlib_main_t *vm); -static_always_inline uword +static_always_inline clib_thread_index_t vlib_get_thread_index (void) { return __os_thread_index; @@ -343,7 +343,7 @@ vlib_get_worker_thread_index (u32 worker_index) } always_inline u32 -vlib_get_worker_index (u32 thread_index) +vlib_get_worker_index (clib_thread_index_t thread_index) { return thread_index - 1; } @@ -361,7 +361,7 @@ vlib_worker_thread_barrier_check (void) { vlib_global_main_t *vgm = vlib_get_global_main (); vlib_main_t *vm = vlib_get_main (); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; f64 t = vlib_time_now (vm); if (PREDICT_FALSE (vec_len (vm->barrier_perf_callbacks) != 0)) @@ -378,7 +378,7 @@ vlib_worker_thread_barrier_check (void) struct { - u32 thread_index; + clib_thread_index_t thread_index; } __clib_packed *ed; ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); @@ -425,7 +425,7 @@ vlib_worker_thread_barrier_check (void) struct { - u32 thread_index; + clib_thread_index_t thread_index; } __clib_packed *ed; ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, @@ -450,7 +450,7 @@ vlib_worker_thread_barrier_check (void) struct { - u32 thread_index; + clib_thread_index_t thread_index; u32 duration; } __clib_packed *ed; diff --git a/src/vlib/unix/input.c b/src/vlib/unix/input.c index 33c778e4124..dcc76fc4234 100644 --- a/src/vlib/unix/input.c +++ b/src/vlib/unix/input.c @@ -142,8 +142,9 @@ is_int_pending (vlib_node_main_t *nm) } static_always_inline uword -linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, - vlib_frame_t * frame, u32 thread_index) +linux_epoll_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node, + vlib_frame_t *frame, + clib_thread_index_t thread_index) { unix_main_t *um = &unix_main; clib_file_main_t *fm = &file_main; @@ -363,7 +364,7 @@ static uword linux_epoll_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); if (thread_index == 0) return linux_epoll_input_inline (vm, node, frame, 0); diff --git a/src/vnet/adj/adj_l2.c b/src/vnet/adj/adj_l2.c index 5413eca6212..8bf9b8225ad 100644 --- a/src/vnet/adj/adj_l2.c +++ b/src/vnet/adj/adj_l2.c @@ -53,7 +53,7 @@ adj_l2_rewrite_inline (vlib_main_t * vm, { u32 * from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, * to_next, next_index; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index(); ethernet_main_t * em = ðernet_main; n_left_from = frame->n_vectors; diff --git a/src/vnet/adj/adj_nsh.c b/src/vnet/adj/adj_nsh.c index 1b4fa6c15b9..9c59d70bf17 100644 --- a/src/vnet/adj/adj_nsh.c +++ b/src/vnet/adj/adj_nsh.c @@ -55,7 +55,7 @@ adj_nsh_rewrite_inline (vlib_main_t * vm, { u32 * from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, * to_next, next_index; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index(); n_left_from = frame->n_vectors; next_index = node->cached_next_index; diff --git a/src/vnet/bier/bier_lookup.c b/src/vnet/bier/bier_lookup.c index f7a21a1c744..50e07d1a2fc 100644 --- a/src/vnet/bier/bier_lookup.c +++ b/src/vnet/bier/bier_lookup.c @@ -83,7 +83,7 @@ bier_lookup (vlib_main_t * vm, { u32 n_left_from, next_index, * from, * to_next; bier_lookup_main_t *blm = &bier_lookup_main; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); bier_bit_mask_bucket_t buckets_copy[BIER_HDR_BUCKETS_4096]; from = vlib_frame_vector_args (from_frame); @@ -347,7 +347,7 @@ clib_error_t * bier_lookup_module_init (vlib_main_t * vm) { bier_lookup_main_t *blm = &bier_lookup_main; - u32 thread_index; + clib_thread_index_t thread_index; vec_validate (blm->blm_clones, vlib_num_workers()); vec_validate (blm->blm_fmasks, vlib_num_workers()); diff --git a/src/vnet/bier/bier_output.c b/src/vnet/bier/bier_output.c index 5c19103d6a3..99fccf09f27 100644 --- a/src/vnet/bier/bier_output.c +++ b/src/vnet/bier/bier_output.c @@ -68,7 +68,7 @@ bier_output (vlib_main_t * vm, { vlib_combined_counter_main_t *cm = &bier_fmask_counters; u32 n_left_from, next_index, * from, * to_next; - u32 thread_index; + clib_thread_index_t thread_index; thread_index = vm->thread_index; from = vlib_frame_vector_args (from_frame); diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c index cdc935ff10f..33a313b8052 100644 --- a/src/vnet/bonding/cli.c +++ b/src/vnet/bonding/cli.c @@ -609,7 +609,7 @@ bond_add_member (vlib_main_t * vm, bond_add_member_args_t * args) vnet_interface_main_t *im = &vnm->interface_main; vnet_hw_interface_t *bif_hw, *mif_hw; vnet_sw_interface_t *sw; - u32 thread_index; + clib_thread_index_t thread_index; u32 mif_if_index; bif = bond_get_bond_if_by_sw_if_index (args->group); diff --git a/src/vnet/bonding/device.c b/src/vnet/bonding/device.c index 81661c15eec..5081ddfed57 100644 --- a/src/vnet/bonding/device.c +++ b/src/vnet/bonding/device.c @@ -186,7 +186,7 @@ bond_lb_broadcast (vlib_main_t *vm, bond_if_t *bif, vlib_buffer_t *b0, vlib_buffer_t *c0; int port; u32 sw_if_index; - u16 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; bond_per_thread_data_t *ptd = vec_elt_at_index (bm->per_thread_data, thread_index); @@ -461,7 +461,7 @@ VNET_DEVICE_CLASS_TX_FN (bond_dev_class) (vlib_main_t * vm, { vnet_interface_output_runtime_t *rund = (void *) node->runtime_data; bond_main_t *bm = &bond_main; - u16 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; bond_if_t *bif = pool_elt_at_index (bm->interfaces, rund->dev_instance); uword n_members; vlib_buffer_t *bufs[VLIB_FRAME_SIZE]; diff --git a/src/vnet/bonding/node.c b/src/vnet/bonding/node.c index 66de1e4dd80..347aa56dbc0 100644 --- a/src/vnet/bonding/node.c +++ b/src/vnet/bonding/node.c @@ -197,7 +197,7 @@ VLIB_NODE_FN (bond_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { - u16 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 *from, n_left; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b; u32 sw_if_indices[VLIB_FRAME_SIZE], *sw_if_index; diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h index 247af56f403..276cb1115f1 100644 --- a/src/vnet/buffer.h +++ b/src/vnet/buffer.h @@ -340,7 +340,7 @@ typedef struct u32 __pad[3]; u32 sad_index; u32 protect_index; - u16 thread_index; + clib_thread_index_t thread_index; } ipsec; /* MAP */ @@ -502,7 +502,7 @@ typedef struct */ struct { - u32 thread_index; + clib_thread_index_t thread_index; u32 pool_index; u32 id; } reass; diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c index 77c1c81f9c4..998615e5d33 100644 --- a/src/vnet/classify/vnet_classify.c +++ b/src/vnet/classify/vnet_classify.c @@ -232,7 +232,7 @@ static inline void make_working_copy vnet_classify_bucket_t working_bucket __attribute__ ((aligned (8))); void *oldheap; vnet_classify_entry_t *working_copy; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); int working_copy_length, required_length; if (thread_index >= vec_len (t->working_copies)) @@ -427,7 +427,7 @@ vnet_classify_add_del (vnet_classify_table_t *t, vnet_classify_entry_t *add_v, u32 hash, new_hash; u32 limit; u32 old_log2_pages, new_log2_pages; - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); u8 *key_minus_skip; int resplit_once = 0; int mark_bucket_linear; diff --git a/src/vnet/crypto/crypto.h b/src/vnet/crypto/crypto.h index c80987ecff7..a56f4c42c0b 100644 --- a/src/vnet/crypto/crypto.h +++ b/src/vnet/crypto/crypto.h @@ -326,7 +326,7 @@ typedef struct vnet_crypto_async_frame_elt_t elts[VNET_CRYPTO_FRAME_SIZE]; u32 buffer_indices[VNET_CRYPTO_FRAME_SIZE]; u16 next_node_index[VNET_CRYPTO_FRAME_SIZE]; - u32 enqueue_thread_index; + clib_thread_index_t enqueue_thread_index; } vnet_crypto_async_frame_t; typedef struct @@ -353,9 +353,9 @@ typedef void (vnet_crypto_key_fn_t) (vnet_crypto_key_op_t kop, /** async crypto function handlers **/ typedef int (vnet_crypto_frame_enq_fn_t) (vlib_main_t *vm, vnet_crypto_async_frame_t *frame); -typedef vnet_crypto_async_frame_t * - (vnet_crypto_frame_dequeue_t) (vlib_main_t * vm, u32 * nb_elts_processed, - u32 * enqueue_thread_idx); +typedef vnet_crypto_async_frame_t *( + vnet_crypto_frame_dequeue_t) (vlib_main_t *vm, u32 *nb_elts_processed, + clib_thread_index_t *enqueue_thread_idx); u32 vnet_crypto_register_engine (vlib_main_t * vm, char *name, int prio, diff --git a/src/vnet/crypto/node.c b/src/vnet/crypto/node.c index 7d023f3ff9d..c0d258ae963 100644 --- a/src/vnet/crypto/node.c +++ b/src/vnet/crypto/node.c @@ -78,7 +78,7 @@ crypto_dequeue_frame (vlib_main_t * vm, vlib_node_runtime_t * node, { vnet_crypto_main_t *cm = &crypto_main; u32 n_elts = 0; - u32 enqueue_thread_idx = ~0; + clib_thread_index_t enqueue_thread_idx = CLIB_INVALID_THREAD_INDEX; vnet_crypto_async_frame_t *cf = (hdl) (vm, &n_elts, &enqueue_thread_idx); *n_total += n_elts; diff --git a/src/vnet/dev/bus/pci.c b/src/vnet/dev/bus/pci.c index a5713349b6f..a8d374f9510 100644 --- a/src/vnet/dev/bus/pci.c +++ b/src/vnet/dev/bus/pci.c @@ -318,7 +318,8 @@ vnet_dev_pci_msix_add_handler (vlib_main_t *vm, vnet_dev_t *dev, void vnet_dev_pci_msix_set_polling_thread (vlib_main_t *vm, vnet_dev_t *dev, - u16 line, u16 thread_index) + u16 line, + clib_thread_index_t thread_index) { vlib_pci_dev_handle_t h = vnet_dev_get_pci_handle (dev); u32 index; diff --git a/src/vnet/dev/dev.h b/src/vnet/dev/dev.h index f3f7563317e..ad2e793907f 100644 --- a/src/vnet/dev/dev.h +++ b/src/vnet/dev/dev.h @@ -711,7 +711,7 @@ void vnet_dev_poll_port_remove (vlib_main_t *, vnet_dev_port_t *, typedef struct { - u16 thread_index; + clib_thread_index_t thread_index; u8 completed; u8 in_order; vnet_dev_port_t *port; diff --git a/src/vnet/dev/runtime.c b/src/vnet/dev/runtime.c index 944c3ef32fa..7a6f39a6be6 100644 --- a/src/vnet/dev/runtime.c +++ b/src/vnet/dev/runtime.c @@ -55,7 +55,7 @@ static uword vnet_dev_rt_mgmt_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) { - u16 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vnet_dev_rt_op_t *op, *ops = __atomic_load_n (&rt_ops, __ATOMIC_ACQUIRE); u32 n_pending = 0; uword rv = 0; diff --git a/src/vnet/devices/devices.h b/src/vnet/devices/devices.h index cadf1f857a6..5c904dffc13 100644 --- a/src/vnet/devices/devices.h +++ b/src/vnet/devices/devices.h @@ -81,7 +81,7 @@ vnet_get_aggregate_rx_packets (void) } static inline void -vnet_device_increment_rx_packets (u32 thread_index, u64 count) +vnet_device_increment_rx_packets (clib_thread_index_t thread_index, u64 count) { vnet_device_main_t *vdm = &vnet_device_main; vnet_device_per_worker_data_t *pwd; diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c index 027e1ed4e74..730c1ff17d8 100644 --- a/src/vnet/devices/virtio/node.c +++ b/src/vnet/devices/virtio/node.c @@ -262,7 +262,7 @@ virtio_device_input_gso_inline (vlib_main_t *vm, vlib_node_runtime_t *node, int checksum_offload_enabled, int packed) { vnet_main_t *vnm = vnet_get_main (); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; uword n_trace = vlib_get_trace_count (vm, node); u32 next_index; const int hdr_sz = vif->virtio_net_hdr_sz; diff --git a/src/vnet/dpo/interface_rx_dpo.c b/src/vnet/dpo/interface_rx_dpo.c index 5a519d344c1..9f5cb6be059 100644 --- a/src/vnet/dpo/interface_rx_dpo.c +++ b/src/vnet/dpo/interface_rx_dpo.c @@ -242,7 +242,7 @@ interface_rx_dpo_inline (vlib_main_t * vm, u8 is_l2) { u32 n_left_from, next_index, * from, * to_next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vnet_interface_main_t *im; im = &vnet_get_main ()->interface_main; diff --git a/src/vnet/dpo/lookup_dpo.c b/src/vnet/dpo/lookup_dpo.c index 9ce94eebe5c..265f3d93023 100644 --- a/src/vnet/dpo/lookup_dpo.c +++ b/src/vnet/dpo/lookup_dpo.c @@ -290,7 +290,7 @@ lookup_dpo_ip4_inline (vlib_main_t * vm, int table_from_interface) { u32 n_left_from, next_index, * from, * to_next; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; from = vlib_frame_vector_args (from_frame); @@ -647,7 +647,7 @@ lookup_dpo_ip6_inline (vlib_main_t * vm, { vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; u32 n_left_from, next_index, * from, * to_next; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -989,7 +989,7 @@ lookup_dpo_mpls_inline (vlib_main_t * vm, int table_from_interface) { u32 n_left_from, next_index, * from, * to_next; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; from = vlib_frame_vector_args (from_frame); diff --git a/src/vnet/dpo/replicate_dpo.c b/src/vnet/dpo/replicate_dpo.c index 0474fd82984..07254f5cf6a 100644 --- a/src/vnet/dpo/replicate_dpo.c +++ b/src/vnet/dpo/replicate_dpo.c @@ -742,7 +742,7 @@ replicate_inline (vlib_main_t * vm, vlib_combined_counter_main_t * cm = &replicate_main.repm_counters; replicate_main_t * rm = &replicate_main; u32 n_left_from, * from, * to_next, next_index; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index f1bb6b81070..39073d761ea 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -507,7 +507,7 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, u32 n_left_from, *from; u32 next_index = 0; u32 n_bytes; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vnet_main_t *vnm = vnet_get_main (); vnet_interface_main_t *im = &vnm->interface_main; l2_input_config_t *config; diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c index 03cbdde1c2b..2d7f0913994 100644 --- a/src/vnet/ethernet/node.c +++ b/src/vnet/ethernet/node.c @@ -1218,7 +1218,7 @@ ethernet_input_inline (vlib_main_t * vm, vlib_node_runtime_t *error_node; u32 n_left_from, next_index, *to_next; u32 stats_sw_if_index, stats_n_packets, stats_n_bytes; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 cached_sw_if_index = ~0; u32 cached_is_l2 = 0; /* shut up gcc */ vnet_hw_interface_t *hi = NULL; /* used for main interface only */ diff --git a/src/vnet/ethernet/p2p_ethernet_input.c b/src/vnet/ethernet/p2p_ethernet_input.c index 3d81e99cff2..140a3fd95d3 100644 --- a/src/vnet/ethernet/p2p_ethernet_input.c +++ b/src/vnet/ethernet/p2p_ethernet_input.c @@ -63,7 +63,7 @@ VLIB_NODE_FN (p2p_ethernet_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_trace = vlib_get_trace_count (vm, node); u32 n_left_from, *from, *to_next; u32 next_index; diff --git a/src/vnet/gso/node.c b/src/vnet/gso/node.c index c1d4459476e..c4f4b74cd92 100644 --- a/src/vnet/gso/node.c +++ b/src/vnet/gso/node.c @@ -471,7 +471,7 @@ drop_one_buffer_and_count (vlib_main_t * vm, vnet_main_t * vnm, vlib_node_runtime_t * node, u32 * pbi0, u32 sw_if_index, u32 drop_error_code) { - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vlib_simple_counter_main_t *cm; cm = @@ -498,7 +498,7 @@ vnet_gso_node_inline (vlib_main_t * vm, u32 *from = vlib_frame_vector_args (frame); u32 n_left_from = frame->n_vectors; u32 *from_end = from + n_left_from; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vnet_interface_main_t *im = &vnm->interface_main; vnet_interface_per_thread_data_t *ptd = vec_elt_at_index (im->per_thread_data, thread_index); diff --git a/src/vnet/interface.h b/src/vnet/interface.h index eb557fdef8b..81d7729700b 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -615,7 +615,7 @@ typedef struct u32 dev_instance; /* index of thread pollling this queue */ - u32 thread_index; + clib_thread_index_t thread_index; /* file index of queue interrupt line */ u32 file_index; diff --git a/src/vnet/interface/rx_queue.c b/src/vnet/interface/rx_queue.c index 00201302a07..84068a05ea5 100644 --- a/src/vnet/interface/rx_queue.c +++ b/src/vnet/interface/rx_queue.c @@ -27,7 +27,7 @@ VLIB_REGISTER_LOG_CLASS (if_rxq_log, static) = { #define log_err(fmt, ...) vlib_log_err (if_rxq_log.class, fmt, __VA_ARGS__) static u32 -next_thread_index (vnet_main_t *vnm, u32 thread_index) +next_thread_index (vnet_main_t *vnm, clib_thread_index_t thread_index) { vnet_device_main_t *vdm = &vnet_device_main; if (vdm->first_worker_thread_index == 0) @@ -62,7 +62,7 @@ vnet_hw_if_get_rx_queue_index_by_id (vnet_main_t *vnm, u32 hw_if_index, u32 vnet_hw_if_register_rx_queue (vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, - u32 thread_index) + clib_thread_index_t thread_index) { vnet_interface_main_t *im = &vnm->interface_main; vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index); @@ -225,7 +225,7 @@ vnet_hw_if_get_rx_queue_mode (vnet_main_t *vnm, u32 queue_index) void vnet_hw_if_set_rx_queue_thread_index (vnet_main_t *vnm, u32 queue_index, - u32 thread_index) + clib_thread_index_t thread_index) { vnet_hw_if_rx_queue_t *rxq = vnet_hw_if_get_rx_queue (vnm, queue_index); vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, rxq->hw_if_index); diff --git a/src/vnet/interface/rx_queue_funcs.h b/src/vnet/interface/rx_queue_funcs.h index 906d7118296..4295463f4b9 100644 --- a/src/vnet/interface/rx_queue_funcs.h +++ b/src/vnet/interface/rx_queue_funcs.h @@ -20,7 +20,8 @@ u32 vnet_hw_if_get_rx_queue_index_by_id (vnet_main_t *vnm, u32 hw_if_index, u32 queue_id); u32 vnet_hw_if_register_rx_queue (vnet_main_t *vnm, u32 hw_if_index, - u32 queue_id, u32 thread_idnex); + u32 queue_id, + clib_thread_index_t thread_index); void vnet_hw_if_unregister_rx_queue (vnet_main_t *vnm, u32 queue_index); void vnet_hw_if_unregister_all_rx_queues (vnet_main_t *vnm, u32 hw_if_index); void vnet_hw_if_set_rx_queue_file_index (vnet_main_t *vnm, u32 queue_index, @@ -32,7 +33,7 @@ int vnet_hw_if_set_rx_queue_mode (vnet_main_t *vnm, u32 queue_index, vnet_hw_if_rx_mode vnet_hw_if_get_rx_queue_mode (vnet_main_t *vnm, u32 queue_index); void vnet_hw_if_set_rx_queue_thread_index (vnet_main_t *vnm, u32 queue_index, - u32 thread_index); + clib_thread_index_t thread_index); vnet_hw_if_rxq_poll_vector_t * vnet_hw_if_generate_rxq_int_poll_vector (vlib_main_t *vm, vlib_node_runtime_t *node); diff --git a/src/vnet/interface/tx_queue.c b/src/vnet/interface/tx_queue.c index 8a6cd9da304..6c7c938c576 100644 --- a/src/vnet/interface/tx_queue.c +++ b/src/vnet/interface/tx_queue.c @@ -107,7 +107,7 @@ vnet_hw_if_unregister_all_tx_queues (vnet_main_t *vnm, u32 hw_if_index) void vnet_hw_if_tx_queue_assign_thread (vnet_main_t *vnm, u32 queue_index, - u32 thread_index) + clib_thread_index_t thread_index) { vnet_hw_if_tx_queue_t *txq = vnet_hw_if_get_tx_queue (vnm, queue_index); vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, txq->hw_if_index); @@ -122,7 +122,7 @@ vnet_hw_if_tx_queue_assign_thread (vnet_main_t *vnm, u32 queue_index, void vnet_hw_if_tx_queue_unassign_thread (vnet_main_t *vnm, u32 queue_index, - u32 thread_index) + clib_thread_index_t thread_index) { vnet_hw_if_tx_queue_t *txq = vnet_hw_if_get_tx_queue (vnm, queue_index); vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, txq->hw_if_index); diff --git a/src/vnet/interface/tx_queue_funcs.h b/src/vnet/interface/tx_queue_funcs.h index 8fcf7c336a8..14792e0f023 100644 --- a/src/vnet/interface/tx_queue_funcs.h +++ b/src/vnet/interface/tx_queue_funcs.h @@ -13,9 +13,9 @@ u32 vnet_hw_if_register_tx_queue (vnet_main_t *vnm, u32 hw_if_index, void vnet_hw_if_unregister_tx_queue (vnet_main_t *vnm, u32 queue_index); void vnet_hw_if_unregister_all_tx_queues (vnet_main_t *vnm, u32 hw_if_index); void vnet_hw_if_tx_queue_assign_thread (vnet_main_t *vnm, u32 queue_index, - u32 thread_index); + clib_thread_index_t thread_index); void vnet_hw_if_tx_queue_unassign_thread (vnet_main_t *vnm, u32 queue_index, - u32 thread_index); + clib_thread_index_t thread_index); /* inline functions */ diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index 65f3a02c86b..d835a36f46d 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -1330,7 +1330,7 @@ vl_api_sw_interface_set_tx_placement_t_handler ( size = mp->array_size; for (u32 i = 0; i < size; i++) { - u32 thread_index = mp->threads[i]; + clib_thread_index_t thread_index = mp->threads[i]; bitmap = clib_bitmap_set (bitmap, thread_index, 1); } diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c index cc214c10f6b..4d3c98f6aa5 100644 --- a/src/vnet/interface_cli.c +++ b/src/vnet/interface_cli.c @@ -1694,7 +1694,7 @@ VLIB_CLI_COMMAND (show_interface_rx_placement, static) = { }; clib_error_t * set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id, - u32 thread_index, u8 is_main) + clib_thread_index_t thread_index, u8 is_main) { vnet_main_t *vnm = vnet_get_main (); vnet_device_main_t *vdm = &vnet_device_main; @@ -1731,7 +1731,7 @@ set_interface_rx_placement (vlib_main_t *vm, unformat_input_t *input, vnet_main_t *vnm = vnet_get_main (); u32 hw_if_index = (u32) ~ 0; u32 queue_id = (u32) 0; - u32 thread_index = (u32) ~ 0; + clib_thread_index_t thread_index = CLIB_INVALID_THREAD_INDEX; u8 is_main = 0; if (!unformat_user (input, unformat_line_input, line_input)) @@ -1831,11 +1831,12 @@ set_hw_interface_tx_queue (u32 hw_if_index, u32 queue_id, uword *bitmap) vlib_thread_main_t *vtm = vlib_get_thread_main (); vnet_hw_if_tx_queue_t *txq; u32 queue_index; - u32 thread_index; + clib_thread_index_t thread_index; /* highest set bit in bitmap should not exceed last worker thread index */ thread_index = clib_bitmap_last_set (bitmap); - if ((thread_index != ~0) && (thread_index >= vtm->n_vlib_mains)) + if ((thread_index != CLIB_INVALID_THREAD_INDEX) && + (thread_index >= vtm->n_vlib_mains)) return VNET_API_ERROR_INVALID_VALUE; queue_index = diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h index 511df4920e4..54e789679b0 100644 --- a/src/vnet/interface_funcs.h +++ b/src/vnet/interface_funcs.h @@ -426,7 +426,8 @@ clib_error_t *set_hw_interface_change_rx_mode (vnet_main_t * vnm, /* Set rx-placement on the interface */ clib_error_t *set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id, - u32 thread_index, u8 is_main); + clib_thread_index_t thread_index, + u8 is_main); /* Set tx-queue placement on the interface */ int set_hw_interface_tx_queue (u32 hw_if_index, u32 queue_id, uword *bitmap); diff --git a/src/vnet/interface_test.c b/src/vnet/interface_test.c index 2d0c0ee81d1..f2889fd45fc 100644 --- a/src/vnet/interface_test.c +++ b/src/vnet/interface_test.c @@ -911,7 +911,7 @@ vl_api_sw_interface_tx_placement_details_t_handler ( for (u32 i = 0; i < size; i++) { - u32 thread_index = ntohl (mp->threads[i]); + clib_thread_index_t thread_index = ntohl (mp->threads[i]); bitmap = clib_bitmap_set (bitmap, thread_index, 1); } diff --git a/src/vnet/ip-neighbor/ip4_neighbor.c b/src/vnet/ip-neighbor/ip4_neighbor.c index 61b9e768fe5..1d8d39ddcb8 100644 --- a/src/vnet/ip-neighbor/ip4_neighbor.c +++ b/src/vnet/ip-neighbor/ip4_neighbor.c @@ -56,7 +56,7 @@ VLIB_REGISTER_LOG_CLASS (ip4_neighbor_log, static) = { vlib_log_debug (ip4_neighbor_log.class, fmt, __VA_ARGS__) void -ip4_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, +ip4_neighbor_probe_dst (u32 sw_if_index, clib_thread_index_t thread_index, const ip4_address_t *dst) { ip4_address_t src; @@ -74,7 +74,8 @@ ip4_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, void ip4_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, - u32 thread_index, const ip4_address_t *addr) + clib_thread_index_t thread_index, + const ip4_address_t *addr) { vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); ip4_main_t *i4m = &ip4_main; @@ -142,7 +143,7 @@ ip4_arp_inline (vlib_main_t * vm, vnet_main_t *vnm = vnet_get_main (); u32 *from, *to_next_drop; uword n_left_from, n_left_to_next_drop, next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u64 seed; if (node->flags & VLIB_NODE_FLAG_TRACE) diff --git a/src/vnet/ip-neighbor/ip4_neighbor.h b/src/vnet/ip-neighbor/ip4_neighbor.h index 7941ebdbced..3327c525d68 100644 --- a/src/vnet/ip-neighbor/ip4_neighbor.h +++ b/src/vnet/ip-neighbor/ip4_neighbor.h @@ -20,10 +20,12 @@ #include #include -extern void ip4_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, +extern void ip4_neighbor_probe_dst (u32 sw_if_index, + clib_thread_index_t thread_index, const ip4_address_t *dst); extern void ip4_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, - u32 sw_if_index, u32 thread_index, + u32 sw_if_index, + clib_thread_index_t thread_index, const ip4_address_t *addr); always_inline vlib_buffer_t * diff --git a/src/vnet/ip-neighbor/ip6_neighbor.c b/src/vnet/ip-neighbor/ip6_neighbor.c index ca8aed3d4ca..79a4a30ff53 100644 --- a/src/vnet/ip-neighbor/ip6_neighbor.c +++ b/src/vnet/ip-neighbor/ip6_neighbor.c @@ -32,7 +32,7 @@ VLIB_REGISTER_LOG_CLASS (ip6_neighbor_log, static) = { #define log_debug(fmt, ...) \ vlib_log_debug (ip6_neighbor_log.class, fmt, __VA_ARGS__) void -ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, +ip6_neighbor_probe_dst (u32 sw_if_index, clib_thread_index_t thread_index, const ip6_address_t *dst) { ip6_address_t src; @@ -45,7 +45,8 @@ ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, void ip6_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, - u32 thread_index, const ip6_address_t *addr) + clib_thread_index_t thread_index, + const ip6_address_t *addr) { vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); ip6_main_t *i6m = &ip6_main; @@ -129,7 +130,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, u32 *from, *to_next_drop; uword n_left_from, n_left_to_next_drop; u64 seed; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; if (node->flags & VLIB_NODE_FLAG_TRACE) ip6_forward_next_trace (vm, node, frame, VLIB_TX); diff --git a/src/vnet/ip-neighbor/ip6_neighbor.h b/src/vnet/ip-neighbor/ip6_neighbor.h index c6e718dc2ff..31dc1eab033 100644 --- a/src/vnet/ip-neighbor/ip6_neighbor.h +++ b/src/vnet/ip-neighbor/ip6_neighbor.h @@ -31,15 +31,17 @@ extern vlib_packet_template_t ip6_neighbor_packet_template; extern void ip6_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, - u32 sw_if_index, u32 thread_index, + u32 sw_if_index, + clib_thread_index_t thread_index, const ip6_address_t *addr); -extern void ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, +extern void ip6_neighbor_probe_dst (u32 sw_if_index, + clib_thread_index_t thread_index, const ip6_address_t *dst); always_inline vlib_buffer_t * ip6_neighbor_probe (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, - u32 thread_index, const ip6_address_t *src, + clib_thread_index_t thread_index, const ip6_address_t *src, const ip6_address_t *dst) { icmp6_neighbor_solicitation_header_t *h0; diff --git a/src/vnet/ip-neighbor/ip_neighbor.c b/src/vnet/ip-neighbor/ip_neighbor.c index 614b78489cd..73fa0b30317 100644 --- a/src/vnet/ip-neighbor/ip_neighbor.c +++ b/src/vnet/ip-neighbor/ip_neighbor.c @@ -1092,7 +1092,7 @@ ip_neighbor_register (ip_address_family_t af, const ip_neighbor_vft_t * vft) } void -ip_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, +ip_neighbor_probe_dst (u32 sw_if_index, clib_thread_index_t thread_index, ip_address_family_t af, const ip46_address_t *dst) { if (!vnet_sw_interface_is_admin_up (vnet_get_main (), sw_if_index)) diff --git a/src/vnet/ip-neighbor/ip_neighbor.h b/src/vnet/ip-neighbor/ip_neighbor.h index cc888ba2054..813c2bb1e2d 100644 --- a/src/vnet/ip-neighbor/ip_neighbor.h +++ b/src/vnet/ip-neighbor/ip_neighbor.h @@ -56,7 +56,8 @@ extern void ip_neighbor_learn (const ip_neighbor_learn_t * l); extern void ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai); extern void ip_neighbor_probe (const ip_adjacency_t * adj); -extern void ip_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, +extern void ip_neighbor_probe_dst (u32 sw_if_index, + clib_thread_index_t thread_index, ip_address_family_t af, const ip46_address_t *ip); diff --git a/src/vnet/ip/icmp4.c b/src/vnet/ip/icmp4.c index fa4a0e12276..acbe06bfc1d 100644 --- a/src/vnet/ip/icmp4.c +++ b/src/vnet/ip/icmp4.c @@ -251,7 +251,7 @@ ip4_icmp_error (vlib_main_t * vm, u32 *from, *to_next; uword n_left_from, n_left_to_next; ip4_icmp_error_next_t next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/vnet/ip/icmp6.c b/src/vnet/ip/icmp6.c index f93ebce4bf1..b37554c3d78 100644 --- a/src/vnet/ip/icmp6.c +++ b/src/vnet/ip/icmp6.c @@ -292,7 +292,7 @@ ip6_icmp_error (vlib_main_t * vm, u32 *from, *to_next; uword n_left_from, n_left_to_next; ip6_icmp_error_next_t next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 81d6cd1a0bd..cabefd81230 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -117,7 +117,7 @@ VLIB_NODE_FN (ip4_load_balance_node) (vlib_main_t * vm, { vlib_combined_counter_main_t *cm = &load_balance_main.lbm_via_counters; u32 n_left, *from; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; u16 nexts[VLIB_FRAME_SIZE], *next; @@ -2113,7 +2113,7 @@ ip4_rewrite_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_node_get_runtime (vm, ip4_input_node.index); n_left_from = frame->n_vectors; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vlib_get_buffers (vm, from, bufs, n_left_from); clib_memset_u16 (nexts, IP4_REWRITE_NEXT_DROP, n_left_from); diff --git a/src/vnet/ip/ip4_forward.h b/src/vnet/ip/ip4_forward.h index 54150d4dab4..8122d57e653 100644 --- a/src/vnet/ip/ip4_forward.h +++ b/src/vnet/ip/ip4_forward.h @@ -59,7 +59,7 @@ ip4_lookup_inline (vlib_main_t * vm, ip4_main_t *im = &ip4_main; vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; u32 n_left, *from; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vlib_buffer_t *bufs[VLIB_FRAME_SIZE]; vlib_buffer_t **b = bufs; u16 nexts[VLIB_FRAME_SIZE], *next; diff --git a/src/vnet/ip/ip4_input.c b/src/vnet/ip/ip4_input.c index af2b89ab2ec..28b9fb8b279 100644 --- a/src/vnet/ip/ip4_input.c +++ b/src/vnet/ip/ip4_input.c @@ -96,7 +96,7 @@ ip4_input_check_sw_if_index (vlib_main_t * vm, { ip4_main_t *im = &ip4_main; ip_lookup_main_t *lm = &im->lookup_main; - u32 thread_index; + clib_thread_index_t thread_index; if (*last_sw_if_index == sw_if_index) { (*cnt)++; @@ -125,7 +125,7 @@ ip4_input_inline (vlib_main_t * vm, { vnet_main_t *vnm = vnet_get_main (); u32 n_left_from, *from; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip4_input_node.index); vlib_simple_counter_main_t *cm; diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index 31adc90ecab..3c1f40beff5 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -750,7 +750,7 @@ VLIB_NODE_FN (ip6_load_balance_node) (vlib_main_t * vm, { vlib_combined_counter_main_t *cm = &load_balance_main.lbm_via_counters; u32 n_left, *from; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; ip6_main_t *im = &ip6_main; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; u16 nexts[VLIB_FRAME_SIZE], *next; @@ -1781,7 +1781,7 @@ ip6_rewrite_inline_with_gso (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { diff --git a/src/vnet/ip/ip6_forward.h b/src/vnet/ip/ip6_forward.h index 8e5dd256ceb..71b6cc9ae04 100644 --- a/src/vnet/ip/ip6_forward.h +++ b/src/vnet/ip/ip6_forward.h @@ -60,7 +60,7 @@ ip6_lookup_inline (vlib_main_t * vm, vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; u32 n_left_from, n_left_to_next, *from, *to_next; ip_lookup_next_t next; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/vnet/ip/ip6_input.c b/src/vnet/ip/ip6_input.c index ae59b765d2e..a79a17ca64a 100644 --- a/src/vnet/ip/ip6_input.c +++ b/src/vnet/ip/ip6_input.c @@ -73,7 +73,7 @@ VLIB_NODE_FN (ip6_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_node_runtime_t *error_node = vlib_node_get_runtime (vm, ip6_input_node.index); vlib_simple_counter_main_t *cm; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/vnet/ip/punt_node.c b/src/vnet/ip/punt_node.c index 6400e49c626..9898a663154 100644 --- a/src/vnet/ip/punt_node.c +++ b/src/vnet/ip/punt_node.c @@ -247,7 +247,7 @@ punt_socket_inline2 (vlib_main_t *vm, vlib_node_runtime_t *node, ip_address_family_t af, ip_protocol_t protocol) { u32 *buffers = vlib_frame_vector_args (frame); - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; uword n_packets = frame->n_vectors; punt_main_t *pm = &punt_main; int i; diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c index bab7d479dcf..808acb03ab8 100644 --- a/src/vnet/ip/reass/ip4_full_reass.c +++ b/src/vnet/ip/reass/ip4_full_reass.c @@ -91,7 +91,7 @@ typedef union struct { u32 reass_index; - u32 memory_owner_thread_index; + clib_thread_index_t memory_owner_thread_index; }; u64 as_u64; } ip4_full_reass_val_t; @@ -147,10 +147,10 @@ typedef struct // number of fragments in this reassembly u32 fragments_n; // thread owning memory for this context (whose pool contains this ctx) - u32 memory_owner_thread_index; + clib_thread_index_t memory_owner_thread_index; // thread which received fragment with offset 0 and which sends out the // completed reassembly - u32 sendout_thread_index; + clib_thread_index_t sendout_thread_index; } ip4_full_reass_t; typedef struct @@ -246,8 +246,8 @@ typedef struct ip4_full_reass_range_trace_t trace_range; u32 size_diff; u32 op_id; - u32 thread_id; - u32 thread_id_to; + clib_thread_index_t thread_id; + clib_thread_index_t thread_id_to; u32 fragment_first; u32 fragment_last; u32 total_data_len; @@ -345,10 +345,10 @@ format_ip4_full_reass_trace (u8 * s, va_list * args) } static void -ip4_full_reass_add_trace (vlib_main_t * vm, vlib_node_runtime_t * node, - ip4_full_reass_t * reass, u32 bi, +ip4_full_reass_add_trace (vlib_main_t *vm, vlib_node_runtime_t *node, + ip4_full_reass_t *reass, u32 bi, ip4_full_reass_trace_operation_e action, - u32 size_diff, u32 thread_id_to) + u32 size_diff, clib_thread_index_t thread_id_to) { vlib_buffer_t *b = vlib_get_buffer (vm, bi); vnet_buffer_opaque_t *vnb = vnet_buffer (b); @@ -917,11 +917,12 @@ ip4_full_reass_remove_range_from_chain (vlib_main_t * vm, } always_inline ip4_full_reass_rc_t -ip4_full_reass_update (vlib_main_t * vm, vlib_node_runtime_t * node, - ip4_full_reass_main_t * rm, - ip4_full_reass_per_thread_t * rt, - ip4_full_reass_t * reass, u32 * bi0, u32 * next0, - u32 * error0, bool is_custom, u32 * handoff_thread_idx) +ip4_full_reass_update (vlib_main_t *vm, vlib_node_runtime_t *node, + ip4_full_reass_main_t *rm, + ip4_full_reass_per_thread_t *rt, + ip4_full_reass_t *reass, u32 *bi0, u32 *next0, + u32 *error0, bool is_custom, + clib_thread_index_t *handoff_thread_idx) { vlib_buffer_t *fb = vlib_get_buffer (vm, *bi0); vnet_buffer_opaque_t *fvnb = vnet_buffer (fb); @@ -1256,7 +1257,7 @@ ip4_full_reass_inline (vlib_main_t *vm, vlib_node_runtime_t *node, } else if (reass) { - u32 handoff_thread_idx; + clib_thread_index_t handoff_thread_idx; u32 counter = ~0; switch (ip4_full_reass_update (vm, node, rm, rt, reass, &bi0, &next0, &error0, CUSTOM == type, diff --git a/src/vnet/ip/reass/ip4_sv_reass.c b/src/vnet/ip/reass/ip4_sv_reass.c index 50b4b22eb60..6d14526e6a7 100644 --- a/src/vnet/ip/reass/ip4_sv_reass.c +++ b/src/vnet/ip/reass/ip4_sv_reass.c @@ -65,7 +65,7 @@ typedef union struct { u32 reass_index; - u32 thread_index; + clib_thread_index_t thread_index; }; u64 as_u64; } ip4_sv_reass_val_t; @@ -1684,7 +1684,7 @@ static char *ip4_sv_reass_handoff_error_strings[] = { typedef struct { - u32 thread_index; + clib_thread_index_t thread_index; } ip4_sv_reass_handoff_trace_t; static u8 * diff --git a/src/vnet/ip/reass/ip6_sv_reass.c b/src/vnet/ip/reass/ip6_sv_reass.c index 69b27c5aa8e..b2934d99721 100644 --- a/src/vnet/ip/reass/ip6_sv_reass.c +++ b/src/vnet/ip/reass/ip6_sv_reass.c @@ -67,7 +67,7 @@ typedef union struct { u32 reass_index; - u32 thread_index; + clib_thread_index_t thread_index; }; u64 as_u64; } ip6_sv_reass_val_t; @@ -1399,7 +1399,7 @@ static char *ip6_sv_reassembly_handoff_error_strings[] = { typedef struct { - u32 thread_index; + clib_thread_index_t thread_index; } ip6_sv_reassembly_handoff_trace_t; static u8 * diff --git a/src/vnet/ipfix-export/flow_report.c b/src/vnet/ipfix-export/flow_report.c index 4eb93520ed8..7d94b4aa6e2 100644 --- a/src/vnet/ipfix-export/flow_report.c +++ b/src/vnet/ipfix-export/flow_report.c @@ -312,7 +312,7 @@ vnet_flow_rewrite_generic_callback (ipfix_exporter_t *exp, flow_report_t *fr, vlib_buffer_t * vnet_ipfix_exp_get_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, - flow_report_t *fr, u32 thread_index) + flow_report_t *fr, clib_thread_index_t thread_index) { u32 bi0; vlib_buffer_t *b0; @@ -343,7 +343,8 @@ vnet_ipfix_exp_get_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, void vnet_ipfix_exp_send_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, flow_report_t *fr, flow_report_stream_t *stream, - u32 thread_index, vlib_buffer_t *b0) + clib_thread_index_t thread_index, + vlib_buffer_t *b0) { flow_report_main_t *frm = &flow_report_main; vlib_frame_t *f; diff --git a/src/vnet/ipfix-export/flow_report.h b/src/vnet/ipfix-export/flow_report.h index cd0cafb6158..1a94ce9b9a6 100644 --- a/src/vnet/ipfix-export/flow_report.h +++ b/src/vnet/ipfix-export/flow_report.h @@ -255,7 +255,8 @@ vnet_ipfix_exporter_lookup (const ip_address_t *ipfix_collector); */ vlib_buffer_t *vnet_ipfix_exp_get_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, - flow_report_t *fr, u32 thread_index); + flow_report_t *fr, + clib_thread_index_t thread_index); /* * Send the provided buffer. At this stage the buffer should be populated @@ -265,7 +266,8 @@ vlib_buffer_t *vnet_ipfix_exp_get_buffer (vlib_main_t *vm, void vnet_ipfix_exp_send_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, flow_report_t *fr, flow_report_stream_t *stream, - u32 thread_index, vlib_buffer_t *b0); + clib_thread_index_t thread_index, + vlib_buffer_t *b0); #endif /* __included_vnet_flow_report_h__ */ diff --git a/src/vnet/ipip/node.c b/src/vnet/ipip/node.c index a289cc885df..ae9317f446f 100644 --- a/src/vnet/ipip/node.c +++ b/src/vnet/ipip/node.c @@ -66,7 +66,7 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node, ipip_main_t *gm = &ipip_main; u32 n_left_from, next_index, *from, *to_next, n_left_to_next; u32 tunnel_sw_if_index = ~0; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 len; vnet_interface_main_t *im = &gm->vnet_main->interface_main; diff --git a/src/vnet/ipsec/ah.h b/src/vnet/ipsec/ah.h index 450c9cfd6dc..08842702e76 100644 --- a/src/vnet/ipsec/ah.h +++ b/src/vnet/ipsec/ah.h @@ -74,8 +74,8 @@ ah_decrypt_err_to_sa_err (u32 err) always_inline void ah_encrypt_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, - u32 thread_index, u32 err, u16 index, u16 *nexts, - u16 drop_next, u32 sa_index) + clib_thread_index_t thread_index, u32 err, + u16 index, u16 *nexts, u16 drop_next, u32 sa_index) { ipsec_set_next_index (b, node, thread_index, err, ah_encrypt_err_to_sa_err (err), index, nexts, @@ -84,8 +84,8 @@ ah_encrypt_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, always_inline void ah_decrypt_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, - u32 thread_index, u32 err, u16 index, u16 *nexts, - u16 drop_next, u32 sa_index) + clib_thread_index_t thread_index, u32 err, + u16 index, u16 *nexts, u16 drop_next, u32 sa_index) { ipsec_set_next_index (b, node, thread_index, err, ah_decrypt_err_to_sa_err (err), index, nexts, diff --git a/src/vnet/ipsec/ah_decrypt.c b/src/vnet/ipsec/ah_decrypt.c index 30ea4429a75..e95cc9e851e 100644 --- a/src/vnet/ipsec/ah_decrypt.c +++ b/src/vnet/ipsec/ah_decrypt.c @@ -118,7 +118,7 @@ ah_decrypt_inline (vlib_main_t * vm, int is_ip6) { u32 n_left, *from; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u16 buffer_data_size = vlib_buffer_get_default_data_size (vm); ah_decrypt_packet_data_t pkt_data[VLIB_FRAME_SIZE], *pd = pkt_data; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; diff --git a/src/vnet/ipsec/esp.h b/src/vnet/ipsec/esp.h index a31e3145429..c855843f35d 100644 --- a/src/vnet/ipsec/esp.h +++ b/src/vnet/ipsec/esp.h @@ -169,8 +169,8 @@ esp_decrypt_err_to_sa_err (u32 err) always_inline void esp_encrypt_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, - u32 thread_index, u32 err, u16 index, u16 *nexts, - u16 drop_next, u32 sa_index) + clib_thread_index_t thread_index, u32 err, + u16 index, u16 *nexts, u16 drop_next, u32 sa_index) { ipsec_set_next_index (b, node, thread_index, err, esp_encrypt_err_to_sa_err (err), index, nexts, @@ -179,8 +179,8 @@ esp_encrypt_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, always_inline void esp_decrypt_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, - u32 thread_index, u32 err, u16 index, u16 *nexts, - u16 drop_next, u32 sa_index) + clib_thread_index_t thread_index, u32 err, + u16 index, u16 *nexts, u16 drop_next, u32 sa_index) { ipsec_set_next_index (b, node, thread_index, err, esp_decrypt_err_to_sa_err (err), index, nexts, diff --git a/src/vnet/ipsec/esp_decrypt.c b/src/vnet/ipsec/esp_decrypt.c index 928f1b06f9b..7f7cd57488d 100644 --- a/src/vnet/ipsec/esp_decrypt.c +++ b/src/vnet/ipsec/esp_decrypt.c @@ -1068,7 +1068,7 @@ esp_decrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node, { ipsec_main_t *im = &ipsec_main; const u16 *next_by_next_header = im->next_header_registrations; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u16 len; ipsec_per_thread_data_t *ptd = vec_elt_at_index (im->ptd, thread_index); u32 *from = vlib_frame_vector_args (from_frame); diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c index 8916eb135f8..1f2cc243074 100644 --- a/src/vnet/ipsec/esp_encrypt.c +++ b/src/vnet/ipsec/esp_encrypt.c @@ -607,7 +607,7 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node, u32 *from = vlib_frame_vector_args (frame); u32 n_left = frame->n_vectors; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u16 buffer_data_size = vlib_buffer_get_default_data_size (vm); u32 current_sa_index = ~0, current_sa_packets = 0; u32 current_sa_bytes = 0, spi = 0; diff --git a/src/vnet/ipsec/ipsec.h b/src/vnet/ipsec/ipsec.h index c4977ddb6b9..bdc4ee4d455 100644 --- a/src/vnet/ipsec/ipsec.h +++ b/src/vnet/ipsec/ipsec.h @@ -361,8 +361,9 @@ ipsec_spinlock_unlock (i32 *lock) */ always_inline void ipsec_set_next_index (vlib_buffer_t *b, vlib_node_runtime_t *node, - u32 thread_index, u32 err, u32 ipsec_sa_err, u16 index, - u16 *nexts, u16 drop_next, u32 sa_index) + clib_thread_index_t thread_index, u32 err, + u32 ipsec_sa_err, u16 index, u16 *nexts, u16 drop_next, + u32 sa_index) { nexts[index] = drop_next; b->error = node->errors[err]; diff --git a/src/vnet/ipsec/ipsec_api.c b/src/vnet/ipsec/ipsec_api.c index d27e9827074..e5b38992de2 100644 --- a/src/vnet/ipsec/ipsec_api.c +++ b/src/vnet/ipsec/ipsec_api.c @@ -1222,7 +1222,7 @@ send_ipsec_sa_v4_details (ipsec_sa_t *sa, void *arg) ipsec_sa_outb_rt_t *ort = ipsec_sa_get_outb_rt (sa); ipsec_dump_walk_ctx_t *ctx = arg; vl_api_ipsec_sa_v4_details_t *mp; - u32 thread_index = 0; + clib_thread_index_t thread_index = 0; mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); @@ -1309,7 +1309,7 @@ send_ipsec_sa_v5_details (ipsec_sa_t *sa, void *arg) ipsec_sa_outb_rt_t *ort = ipsec_sa_get_outb_rt (sa); ipsec_dump_walk_ctx_t *ctx = arg; vl_api_ipsec_sa_v5_details_t *mp; - u32 thread_index = 0; + clib_thread_index_t thread_index = 0; mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); diff --git a/src/vnet/ipsec/ipsec_input.c b/src/vnet/ipsec/ipsec_input.c index a7c7482a125..d649c705bb0 100644 --- a/src/vnet/ipsec/ipsec_input.c +++ b/src/vnet/ipsec/ipsec_input.c @@ -318,10 +318,11 @@ ipsec_collect_ah_trace (vlib_buffer_t **b, vlib_node_runtime_t *node, always_inline void ipsec_ah_packet_process (vlib_main_t *vm, ipsec_main_t *im, ip4_header_t *ip0, - ah_header_t *ah0, u32 thread_index, ipsec_spd_t *spd0, - vlib_buffer_t **b, vlib_node_runtime_t *node, - u64 *ipsec_bypassed, u64 *ipsec_dropped, - u64 *ipsec_matched, u64 *ipsec_unprocessed, u16 *next) + ah_header_t *ah0, clib_thread_index_t thread_index, + ipsec_spd_t *spd0, vlib_buffer_t **b, + vlib_node_runtime_t *node, u64 *ipsec_bypassed, + u64 *ipsec_dropped, u64 *ipsec_matched, + u64 *ipsec_unprocessed, u16 *next) { ipsec_policy_t *p0 = NULL; @@ -452,7 +453,7 @@ ipsec_ah_packet_process (vlib_main_t *vm, ipsec_main_t *im, ip4_header_t *ip0, always_inline void ipsec_esp_packet_process (vlib_main_t *vm, ipsec_main_t *im, ip4_header_t *ip0, udp_header_t *udp0, esp_header_t *esp0, - u32 thread_index, ipsec_spd_t *spd0, + clib_thread_index_t thread_index, ipsec_spd_t *spd0, vlib_buffer_t **b, vlib_node_runtime_t *node, u64 *ipsec_bypassed, u64 *ipsec_dropped, u64 *ipsec_matched, u64 *ipsec_unprocessed, @@ -834,7 +835,7 @@ extern vlib_node_registration_t ipsec6_input_node; always_inline void ipsec6_esp_packet_process (vlib_main_t *vm, ipsec_main_t *im, ip6_header_t *ip0, esp_header_t *esp0, - u32 thread_index, ipsec_spd_t *spd0, + clib_thread_index_t thread_index, ipsec_spd_t *spd0, vlib_buffer_t **b, vlib_node_runtime_t *node, u64 *ipsec_bypassed, u64 *ipsec_dropped, u64 *ipsec_matched, u64 *ipsec_unprocessed, diff --git a/src/vnet/ipsec/ipsec_sa.c b/src/vnet/ipsec/ipsec_sa.c index ec281cd9a11..2347a00f052 100644 --- a/src/vnet/ipsec/ipsec_sa.c +++ b/src/vnet/ipsec/ipsec_sa.c @@ -426,7 +426,7 @@ ipsec_sa_add_and_lock (u32 id, u32 spi, ipsec_protocol_t proto, clib_error_t *err; ipsec_sa_t *sa; u32 sa_index, irt_sz; - u16 thread_index = (vlib_num_workers ()) ? ~0 : 0; + clib_thread_index_t thread_index = (vlib_num_workers ()) ? ~0 : 0; u64 rand[2]; uword *p; int rv; @@ -670,7 +670,7 @@ ipsec_sa_bind (u32 id, u32 worker, bool bind) ipsec_sa_t *sa; ipsec_sa_inb_rt_t *irt; ipsec_sa_outb_rt_t *ort; - u16 thread_index; + clib_thread_index_t thread_index; p = hash_get (im->sa_index_by_sa_id, id); if (!p) diff --git a/src/vnet/ipsec/ipsec_sa.h b/src/vnet/ipsec/ipsec_sa.h index 9d8c90bab41..330043809ae 100644 --- a/src/vnet/ipsec/ipsec_sa.h +++ b/src/vnet/ipsec/ipsec_sa.h @@ -157,7 +157,7 @@ typedef struct u8 cipher_iv_size; u8 integ_icv_size; u8 udp_sz; - u16 thread_index; + clib_thread_index_t thread_index; u32 salt; u64 seq64; u16 async_op_id; @@ -187,7 +187,7 @@ typedef struct u8 integ_icv_size; ip_dscp_t t_dscp; tunnel_encap_decap_flags_t tunnel_flags; - u16 thread_index; + clib_thread_index_t thread_index; u16 async_op_id; u32 salt; u32 spi_be; @@ -687,8 +687,9 @@ ipsec_sa_anti_replay_window_shift (ipsec_sa_inb_rt_t *irt, u32 window_size, * the branch cost. */ always_inline u64 -ipsec_sa_anti_replay_advance (ipsec_sa_inb_rt_t *irt, u32 thread_index, - u32 seq, u32 hi_seq) +ipsec_sa_anti_replay_advance (ipsec_sa_inb_rt_t *irt, + clib_thread_index_t thread_index, u32 seq, + u32 hi_seq) { u64 n_lost = 0; u32 window_size = irt->anti_replay_window_size; diff --git a/src/vnet/ipsec/ipsec_tun_in.c b/src/vnet/ipsec/ipsec_tun_in.c index 3dde084cb24..38f6baf3d2e 100644 --- a/src/vnet/ipsec/ipsec_tun_in.c +++ b/src/vnet/ipsec/ipsec_tun_in.c @@ -114,7 +114,7 @@ ipsec_tun_protect_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vnet_interface_main_t *vim = &vnm->interface_main; int is_trace = node->flags & VLIB_NODE_FLAG_TRACE; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 n_left_from, *from; u16 nexts[VLIB_FRAME_SIZE], *next; diff --git a/src/vnet/l2/l2_flood.c b/src/vnet/l2/l2_flood.c index f8cb3cb5687..c06bf5c636b 100644 --- a/src/vnet/l2/l2_flood.c +++ b/src/vnet/l2/l2_flood.c @@ -141,7 +141,7 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm, u32 n_left_from, *from, *to_next; l2flood_next_t next_index; l2flood_main_t *msm = &l2flood_main; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/src/vnet/mpls/mpls_input.c b/src/vnet/mpls/mpls_input.c index 0505d9a1829..79da5e53cba 100644 --- a/src/vnet/mpls/mpls_input.c +++ b/src/vnet/mpls/mpls_input.c @@ -75,7 +75,7 @@ mpls_input_inline (vlib_main_t * vm, { u32 n_left_from, next_index, * from, * to_next; mpls_main_t * mm = &mpls_main; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); vlib_simple_counter_main_t * cm; vnet_main_t * vnm = vnet_get_main(); diff --git a/src/vnet/mpls/mpls_lookup.c b/src/vnet/mpls/mpls_lookup.c index a5ac56534a5..5b0e9413ea3 100644 --- a/src/vnet/mpls/mpls_lookup.c +++ b/src/vnet/mpls/mpls_lookup.c @@ -61,7 +61,7 @@ VLIB_NODE_FN (mpls_lookup_node) (vlib_main_t * vm, vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters; u32 n_left_from, next_index, * from, * to_next; mpls_main_t * mm = &mpls_main; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; @@ -493,7 +493,7 @@ VLIB_NODE_FN (mpls_load_balance_node) (vlib_main_t * vm, { vlib_combined_counter_main_t * cm = &load_balance_main.lbm_via_counters; u32 n_left_from, n_left_to_next, * from, * to_next; - u32 thread_index = vlib_get_thread_index(); + clib_thread_index_t thread_index = vlib_get_thread_index (); u32 next; from = vlib_frame_vector_args (frame); diff --git a/src/vnet/policer/police.h b/src/vnet/policer/police.h index 8f126e22175..c1b8096ed41 100644 --- a/src/vnet/policer/police.h +++ b/src/vnet/policer/police.h @@ -91,7 +91,8 @@ typedef struct u32 current_bucket; // MOD u32 extended_limit; u32 extended_bucket; // MOD - u32 thread_index; // Tie policer to a thread, rather than lock + clib_thread_index_t + thread_index; // Tie policer to a thread, rather than lock u64 last_update_time; // MOD u8 *name; } policer_t; diff --git a/src/vnet/policer/police_inlines.h b/src/vnet/policer/police_inlines.h index 08000b9a303..7b7e19171d6 100644 --- a/src/vnet/policer/police_inlines.h +++ b/src/vnet/policer/police_inlines.h @@ -74,7 +74,7 @@ vnet_policer_police (vlib_main_t *vm, vlib_buffer_t *b, u32 policer_index, if (handoff) { - if (PREDICT_FALSE (pol->thread_index == ~0)) + if (PREDICT_FALSE (pol->thread_index == CLIB_INVALID_THREAD_INDEX)) /* * This is the first packet to use this policer. Set the * thread index in the policer to this thread and any diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c index eacc1adf941..1a2509e6356 100644 --- a/src/vnet/session/application.c +++ b/src/vnet/session/application.c @@ -490,7 +490,7 @@ vlib_node_registration_t appsl_rx_mqs_input_node; VLIB_NODE_FN (appsl_rx_mqs_input_node) (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) { - u32 thread_index = vm->thread_index, n_msgs = 0; + clib_thread_index_t thread_index = vm->thread_index, n_msgs = 0; app_rx_mq_elt_t *elt, *next; app_main_t *am = &app_main; session_worker_t *wrk; @@ -581,7 +581,7 @@ app_rx_mqs_epoll_add (application_t *app, app_rx_mq_elt_t *mqe) { clib_file_t template = { 0 }; app_rx_mq_handle_t handle; - u32 thread_index; + clib_thread_index_t thread_index; int fd; thread_index = mqe - app->rx_mqs; @@ -603,7 +603,7 @@ app_rx_mqs_epoll_add (application_t *app, app_rx_mq_elt_t *mqe) static void app_rx_mqs_epoll_del (application_t *app, app_rx_mq_elt_t *mqe) { - u32 thread_index = mqe - app->rx_mqs; + clib_thread_index_t thread_index = mqe - app->rx_mqs; app_main_t *am = &app_main; appsl_wrk_t *aw; diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h index c68a911230f..d748eae9cd5 100644 --- a/src/vnet/session/application.h +++ b/src/vnet/session/application.h @@ -175,7 +175,7 @@ typedef struct app_rx_mq_handle_ struct { u32 app_index; - u32 thread_index; + clib_thread_index_t thread_index; }; u64 as_u64; }; @@ -368,9 +368,11 @@ int app_worker_session_fifo_tuning (app_worker_t * app_wrk, session_t * s, session_ft_action_t act, u32 len); void app_worker_add_event (app_worker_t *app_wrk, session_t *s, session_evt_type_t evt_type); -void app_worker_add_event_custom (app_worker_t *app_wrk, u32 thread_index, +void app_worker_add_event_custom (app_worker_t *app_wrk, + clib_thread_index_t thread_index, session_event_t *evt); -int app_wrk_flush_wrk_events (app_worker_t *app_wrk, u32 thread_index); +int app_wrk_flush_wrk_events (app_worker_t *app_wrk, + clib_thread_index_t thread_index); void app_worker_del_all_events (app_worker_t *app_wrk); segment_manager_t *app_worker_get_listen_segment_manager (app_worker_t *, session_t *); @@ -386,10 +388,12 @@ void app_wrk_send_ctrl_evt_fd (app_worker_t *app_wrk, u8 evt_type, void *msg, u32 msg_len, int fd); void app_wrk_send_ctrl_evt (app_worker_t *app_wrk, u8 evt_type, void *msg, u32 msg_len); -u8 app_worker_mq_wrk_is_congested (app_worker_t *app_wrk, u32 thread_index); -void app_worker_set_mq_wrk_congested (app_worker_t *app_wrk, u32 thread_index); +u8 app_worker_mq_wrk_is_congested (app_worker_t *app_wrk, + clib_thread_index_t thread_index); +void app_worker_set_mq_wrk_congested (app_worker_t *app_wrk, + clib_thread_index_t thread_index); void app_worker_unset_wrk_mq_congested (app_worker_t *app_wrk, - u32 thread_index); + clib_thread_index_t thread_index); session_t *app_worker_proxy_listener (app_worker_t * app, u8 fib_proto, u8 transport_proto); void app_worker_del_detached_sm (app_worker_t * app_wrk, u32 sm_index); diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index 18ea77dc8a8..f22e3647b7f 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -76,13 +76,13 @@ typedef struct ct_main_ static ct_main_t ct_main; static inline ct_worker_t * -ct_worker_get (u32 thread_index) +ct_worker_get (clib_thread_index_t thread_index) { return &ct_main.wrk[thread_index]; } static ct_connection_t * -ct_connection_alloc (u32 thread_index) +ct_connection_alloc (clib_thread_index_t thread_index) { ct_worker_t *wrk = ct_worker_get (thread_index); ct_connection_t *ct; @@ -99,7 +99,7 @@ ct_connection_alloc (u32 thread_index) } static ct_connection_t * -ct_connection_get (u32 ct_index, u32 thread_index) +ct_connection_get (u32 ct_index, clib_thread_index_t thread_index) { ct_worker_t *wrk = ct_worker_get (thread_index); @@ -659,7 +659,7 @@ ct_init_accepted_session (app_worker_t *server_wrk, ct_connection_t *ct, } static void -ct_accept_one (u32 thread_index, u32 ho_index) +ct_accept_one (clib_thread_index_t thread_index, u32 ho_index) { ct_connection_t *sct, *cct, *ho; transport_connection_t *ll_ct; @@ -768,7 +768,7 @@ ct_accept_one (u32 thread_index, u32 ho_index) static void ct_accept_rpc_wrk_handler (void *rpc_args) { - u32 thread_index, n_connects, i, n_pending; + clib_thread_index_t thread_index, n_connects, i, n_pending; const u32 max_connects = 32; ct_worker_t *wrk; u8 need_rpc = 0; @@ -805,7 +805,7 @@ ct_accept_rpc_wrk_handler (void *rpc_args) static void ct_fwrk_flush_connects (void *rpc_args) { - u32 thread_index, fwrk_index, n_workers; + clib_thread_index_t thread_index, fwrk_index, n_workers; ct_main_t *cm = &ct_main; ct_worker_t *wrk; u8 need_rpc; @@ -851,7 +851,7 @@ static void ct_program_connect_to_wrk (u32 ho_index) { ct_main_t *cm = &ct_main; - u32 thread_index; + clib_thread_index_t thread_index; /* Simple round-robin policy for spreading sessions over workers. We skip * thread index 0, i.e., offset the index by 1, when we have workers as it @@ -946,7 +946,7 @@ ct_session_half_open_get (u32 ct_index) } static void -ct_session_cleanup (u32 conn_index, u32 thread_index) +ct_session_cleanup (u32 conn_index, clib_thread_index_t thread_index) { ct_connection_t *ct, *peer_ct; @@ -1173,7 +1173,7 @@ ct_program_cleanup (ct_connection_t *ct) } static void -ct_session_close (u32 ct_index, u32 thread_index) +ct_session_close (u32 ct_index, clib_thread_index_t thread_index) { ct_connection_t *ct, *peer_ct; session_t *s; @@ -1204,7 +1204,7 @@ ct_session_close (u32 ct_index, u32 thread_index) } static void -ct_session_reset (u32 ct_index, u32 thread_index) +ct_session_reset (u32 ct_index, clib_thread_index_t thread_index) { ct_connection_t *ct; ct = ct_connection_get (ct_index, thread_index); @@ -1213,7 +1213,7 @@ ct_session_reset (u32 ct_index, u32 thread_index) } static transport_connection_t * -ct_session_get (u32 ct_index, u32 thread_index) +ct_session_get (u32 ct_index, clib_thread_index_t thread_index) { return (transport_connection_t *) ct_connection_get (ct_index, thread_index); @@ -1331,7 +1331,7 @@ static u8 * format_ct_session (u8 * s, va_list * args) { u32 ct_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); ct_connection_t *ct; diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c index ad0b18e8d75..a5b1e1f4ea4 100644 --- a/src/vnet/session/application_worker.c +++ b/src/vnet/session/application_worker.c @@ -471,7 +471,8 @@ app_worker_connect_notify (app_worker_t * app_wrk, session_t * s, session_event_t evt = { .event_type = SESSION_CTRL_EVT_CONNECTED, .as_u64[0] = s ? s->session_index : ~0, .as_u64[1] = (u64) opaque << 32 | (u32) err }; - u32 thread_index = s ? s->thread_index : vlib_get_thread_index (); + clib_thread_index_t thread_index = + s ? s->thread_index : vlib_get_thread_index (); app_worker_add_event_custom (app_wrk, thread_index, &evt); return 0; @@ -782,7 +783,8 @@ app_worker_add_event (app_worker_t *app_wrk, session_t *s, } void -app_worker_add_event_custom (app_worker_t *app_wrk, u32 thread_index, +app_worker_add_event_custom (app_worker_t *app_wrk, + clib_thread_index_t thread_index, session_event_t *evt) { clib_fifo_add1 (app_wrk->wrk_evts[thread_index], *evt); @@ -832,13 +834,15 @@ app_wrk_send_ctrl_evt (app_worker_t *app_wrk, u8 evt_type, void *msg, } u8 -app_worker_mq_wrk_is_congested (app_worker_t *app_wrk, u32 thread_index) +app_worker_mq_wrk_is_congested (app_worker_t *app_wrk, + clib_thread_index_t thread_index) { return app_wrk->wrk_mq_congested[thread_index] > 0; } void -app_worker_set_mq_wrk_congested (app_worker_t *app_wrk, u32 thread_index) +app_worker_set_mq_wrk_congested (app_worker_t *app_wrk, + clib_thread_index_t thread_index) { ASSERT (thread_index == vlib_get_thread_index ()); if (!app_wrk->wrk_mq_congested[thread_index]) @@ -849,7 +853,8 @@ app_worker_set_mq_wrk_congested (app_worker_t *app_wrk, u32 thread_index) } void -app_worker_unset_wrk_mq_congested (app_worker_t *app_wrk, u32 thread_index) +app_worker_unset_wrk_mq_congested (app_worker_t *app_wrk, + clib_thread_index_t thread_index) { clib_atomic_fetch_sub_relax (&app_wrk->mq_congested, 1); ASSERT (thread_index == vlib_get_thread_index ()); diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index 8c8b904c33d..341b70086d1 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -702,7 +702,8 @@ segment_manager_del_sessions_filter (segment_manager_t *sm, } int -segment_manager_try_alloc_fifos (fifo_segment_t *fs, u32 thread_index, +segment_manager_try_alloc_fifos (fifo_segment_t *fs, + clib_thread_index_t thread_index, u32 rx_fifo_size, u32 tx_fifo_size, svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo) { @@ -740,8 +741,8 @@ segment_manager_try_alloc_fifos (fifo_segment_t *fs, u32 thread_index, static inline int sm_lookup_segment_and_alloc_fifos (segment_manager_t *sm, segment_manager_props_t *props, - u32 thread_index, svm_fifo_t **rx_fifo, - svm_fifo_t **tx_fifo) + clib_thread_index_t thread_index, + svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo) { uword free_bytes, max_free_bytes; fifo_segment_t *cur, *fs = 0; @@ -771,7 +772,8 @@ sm_lookup_segment_and_alloc_fifos (segment_manager_t *sm, static int sm_lock_and_alloc_segment_and_fifos (segment_manager_t *sm, segment_manager_props_t *props, - u32 thread_index, svm_fifo_t **rx_fifo, + clib_thread_index_t thread_index, + svm_fifo_t **rx_fifo, svm_fifo_t **tx_fifo) { int new_fs_index, rv; @@ -814,10 +816,10 @@ done: } int -segment_manager_alloc_session_fifos (segment_manager_t * sm, - u32 thread_index, - svm_fifo_t ** rx_fifo, - svm_fifo_t ** tx_fifo) +segment_manager_alloc_session_fifos (segment_manager_t *sm, + clib_thread_index_t thread_index, + svm_fifo_t **rx_fifo, + svm_fifo_t **tx_fifo) { segment_manager_props_t *props; int rv; diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h index 86ca23bc9c7..0fb957a0912 100644 --- a/src/vnet/session/segment_manager.h +++ b/src/vnet/session/segment_manager.h @@ -146,15 +146,15 @@ u64 segment_manager_segment_handle (segment_manager_t * sm, fifo_segment_t * segment); void segment_manager_segment_reader_unlock (segment_manager_t * sm); -int segment_manager_alloc_session_fifos (segment_manager_t * sm, - u32 thread_index, - svm_fifo_t ** rx_fifo, - svm_fifo_t ** tx_fifo); -int segment_manager_try_alloc_fifos (fifo_segment_t * fs, - u32 thread_index, +int segment_manager_alloc_session_fifos (segment_manager_t *sm, + clib_thread_index_t thread_index, + svm_fifo_t **rx_fifo, + svm_fifo_t **tx_fifo); +int segment_manager_try_alloc_fifos (fifo_segment_t *fs, + clib_thread_index_t thread_index, u32 rx_fifo_size, u32 tx_fifo_size, - svm_fifo_t ** rx_fifo, - svm_fifo_t ** tx_fifo); + svm_fifo_t **rx_fifo, + svm_fifo_t **tx_fifo); void segment_manager_dealloc_fifos (svm_fifo_t * rx_fifo, svm_fifo_t * tx_fifo); void segment_manager_detach_fifo (segment_manager_t *sm, svm_fifo_t **f); diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index d65371e81e5..7eb6181adb9 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -36,7 +36,8 @@ typedef enum } session_evt_family_t; static inline int -session_send_evt_to_thread (void *data, void *args, u32 thread_index, +session_send_evt_to_thread (void *data, void *args, + clib_thread_index_t thread_index, session_evt_type_t evt_type, session_evt_family_t family) { @@ -105,7 +106,8 @@ session_send_io_evt_to_thread (svm_fifo_t * f, session_evt_type_t evt_type) /* Deprecated, use session_program_* functions */ int -session_send_io_evt_to_thread_custom (void *data, u32 thread_index, +session_send_io_evt_to_thread_custom (void *data, + clib_thread_index_t thread_index, session_evt_type_t evt_type) { return session_send_evt_to_thread (data, 0, thread_index, evt_type, @@ -154,15 +156,16 @@ session_send_ctrl_evt_to_thread (session_t * s, session_evt_type_t evt_type) } void -session_send_rpc_evt_to_thread_force (u32 thread_index, void *fp, - void *rpc_args) +session_send_rpc_evt_to_thread_force (clib_thread_index_t thread_index, + void *fp, void *rpc_args) { session_send_evt_to_thread (fp, rpc_args, thread_index, SESSION_CTRL_EVT_RPC, SESSION_EVT_RPC); } void -session_send_rpc_evt_to_thread (u32 thread_index, void *fp, void *rpc_args) +session_send_rpc_evt_to_thread (clib_thread_index_t thread_index, void *fp, + void *rpc_args) { if (thread_index != vlib_get_thread_index ()) session_send_rpc_evt_to_thread_force (thread_index, fp, rpc_args); @@ -225,7 +228,7 @@ sesssion_reschedule_tx (transport_connection_t * tc) static void session_program_transport_ctrl_evt (session_t * s, session_evt_type_t evt) { - u32 thread_index = vlib_get_thread_index (); + clib_thread_index_t thread_index = vlib_get_thread_index (); session_evt_elt_t *elt; session_worker_t *wrk; @@ -247,7 +250,7 @@ session_program_transport_ctrl_evt (session_t * s, session_evt_type_t evt) } session_t * -session_alloc (u32 thread_index) +session_alloc (clib_thread_index_t thread_index) { session_worker_t *wrk = &session_main.wrk[thread_index]; session_t *s; @@ -466,7 +469,7 @@ session_t * session_alloc_for_connection (transport_connection_t * tc) { session_t *s; - u32 thread_index = tc->thread_index; + clib_thread_index_t thread_index = tc->thread_index; ASSERT (thread_index == vlib_get_thread_index () || transport_protocol_is_cl (tc->proto)); @@ -638,7 +641,7 @@ session_dequeue_notify (session_t *s) */ void session_main_flush_enqueue_events (transport_proto_t transport_proto, - u32 thread_index) + clib_thread_index_t thread_index) { session_worker_t *wrk = session_main_get_worker (thread_index); session_handle_t *handles; @@ -772,7 +775,7 @@ session_switch_pool_closed_rpc (void *arg) typedef struct _session_switch_pool_args { u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; u32 new_thread_index; u32 new_session_index; } session_switch_pool_args_t; @@ -1064,8 +1067,8 @@ session_stream_accept_notify (transport_connection_t * tc) * Accept a stream session. Optionally ping the server by callback. */ int -session_stream_accept (transport_connection_t * tc, u32 listener_index, - u32 thread_index, u8 notify) +session_stream_accept (transport_connection_t *tc, u32 listener_index, + clib_thread_index_t thread_index, u8 notify) { session_t *s; int rv; @@ -1099,8 +1102,8 @@ session_stream_accept (transport_connection_t * tc, u32 listener_index, } int -session_dgram_accept (transport_connection_t * tc, u32 listener_index, - u32 thread_index) +session_dgram_accept (transport_connection_t *tc, u32 listener_index, + clib_thread_index_t thread_index) { app_worker_t *app_wrk; session_t *s; diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h index d6c5cbc6085..d5402b3571e 100644 --- a/src/vnet/session/session.h +++ b/src/vnet/session/session.h @@ -336,13 +336,13 @@ vnet_get_session_main () } always_inline session_worker_t * -session_main_get_worker (u32 thread_index) +session_main_get_worker (clib_thread_index_t thread_index) { return vec_elt_at_index (session_main.wrk, thread_index); } static inline session_worker_t * -session_main_get_worker_if_valid (u32 thread_index) +session_main_get_worker_if_valid (clib_thread_index_t thread_index) { if (thread_index > vec_len (session_main.wrk)) return 0; @@ -350,7 +350,7 @@ session_main_get_worker_if_valid (u32 thread_index) } always_inline svm_msg_q_t * -session_main_get_vpp_event_queue (u32 thread_index) +session_main_get_vpp_event_queue (clib_thread_index_t thread_index) { return session_main_get_worker (thread_index)->vpp_event_queue; } @@ -455,7 +455,7 @@ session_evt_alloc_old (session_worker_t * wrk) int session_wrk_handle_mq (session_worker_t *wrk, svm_msg_q_t *mq); -session_t *session_alloc (u32 thread_index); +session_t *session_alloc (clib_thread_index_t thread_index); void session_free (session_t * s); void session_cleanup (session_t *s); void session_program_cleanup (session_t *s); @@ -463,14 +463,14 @@ void session_cleanup_half_open (session_handle_t ho_handle); u8 session_is_valid (u32 si, u8 thread_index); always_inline session_t * -session_get (u32 si, u32 thread_index) +session_get (u32 si, clib_thread_index_t thread_index) { ASSERT (session_is_valid (si, thread_index)); return pool_elt_at_index (session_main.wrk[thread_index].sessions, si); } always_inline session_t * -session_get_if_valid (u64 si, u32 thread_index) +session_get_if_valid (u64 si, clib_thread_index_t thread_index) { if (thread_index >= vec_len (session_main.wrk)) return 0; @@ -518,7 +518,7 @@ session_get_from_handle_safe (session_handle_tu_t handle) } always_inline session_t * -session_clone_safe (u32 session_index, u32 thread_index) +session_clone_safe (u32 session_index, clib_thread_index_t thread_index) { u32 current_thread_index = vlib_get_thread_index (), new_index; session_t *old_s, *new_s; @@ -550,17 +550,18 @@ int session_enqueue_notify_cl (session_t *s); /* Deprecated, use session_program_* functions */ int session_send_io_evt_to_thread (svm_fifo_t *f, session_evt_type_t evt_type); /* Deprecated, use session_program_* functions */ -int session_send_io_evt_to_thread_custom (void *data, u32 thread_index, +int session_send_io_evt_to_thread_custom (void *data, + clib_thread_index_t thread_index, session_evt_type_t evt_type); int session_program_tx_io_evt (session_handle_tu_t sh, session_evt_type_t evt_type); int session_program_rx_io_evt (session_handle_tu_t sh); int session_program_transport_io_evt (session_handle_tu_t sh, session_evt_type_t evt_type); -void session_send_rpc_evt_to_thread (u32 thread_index, void *fp, - void *rpc_args); -void session_send_rpc_evt_to_thread_force (u32 thread_index, void *fp, - void *rpc_args); +void session_send_rpc_evt_to_thread (clib_thread_index_t thread_index, + void *fp, void *rpc_args); +void session_send_rpc_evt_to_thread_force (clib_thread_index_t thread_index, + void *fp, void *rpc_args); void session_add_self_custom_tx_evt (transport_connection_t * tc, u8 has_prio); void sesssion_reschedule_tx (transport_connection_t * tc); @@ -593,10 +594,10 @@ void session_half_open_migrate_notify (transport_connection_t *tc); int session_half_open_migrated_notify (transport_connection_t *tc); void session_transport_closed_notify (transport_connection_t * tc); void session_transport_reset_notify (transport_connection_t * tc); -int session_stream_accept (transport_connection_t * tc, u32 listener_index, - u32 thread_index, u8 notify); -int session_dgram_accept (transport_connection_t * tc, u32 listener_index, - u32 thread_index); +int session_stream_accept (transport_connection_t *tc, u32 listener_index, + clib_thread_index_t thread_index, u8 notify); +int session_dgram_accept (transport_connection_t *tc, u32 listener_index, + clib_thread_index_t thread_index); /** * Initialize session layer for given transport proto and ip version @@ -616,7 +617,7 @@ void session_register_transport (transport_proto_t transport_proto, transport_proto_t session_add_transport_proto (void); void session_register_update_time_fn (session_update_time_fn fn, u8 is_add); void session_main_flush_enqueue_events (transport_proto_t transport_proto, - u32 thread_index); + clib_thread_index_t thread_index); void session_queue_run_on_main_thread (vlib_main_t *vm); int session_tx_fifo_peek_bytes (transport_connection_t * tc, u8 * buffer, u32 offset, u32 max_bytes); @@ -860,7 +861,7 @@ session_enqueue_dgram_connection_inline (session_t *s, * flushed by calling @ref session_main_flush_enqueue_events () */ if (!(s->flags & SESSION_F_RX_EVT)) { - u32 thread_index = + clib_thread_index_t thread_index = is_cl ? vlib_get_thread_index () : s->thread_index; session_worker_t *wrk = session_main_get_worker (thread_index); ASSERT (s->thread_index == vlib_get_thread_index () || is_cl); @@ -959,19 +960,19 @@ transport_rx_fifo_req_deq_ntf (transport_connection_t *tc) } always_inline clib_time_type_t -transport_time_now (u32 thread_index) +transport_time_now (clib_thread_index_t thread_index) { return session_main.wrk[thread_index].last_vlib_time; } always_inline clib_us_time_t -transport_us_time_now (u32 thread_index) +transport_us_time_now (clib_thread_index_t thread_index) { return session_main.wrk[thread_index].last_vlib_us_time; } always_inline clib_time_type_t -transport_seconds_per_loop (u32 thread_index) +transport_seconds_per_loop (clib_thread_index_t thread_index) { return session_main.wrk[thread_index].vm->seconds_per_loop; } @@ -1081,7 +1082,8 @@ transport_connection_t *listen_session_get_transport (session_t * s); * must exist */ always_inline void -session_add_pending_tx_buffer (u32 thread_index, u32 bi, u32 next_node) +session_add_pending_tx_buffer (clib_thread_index_t thread_index, u32 bi, + u32 next_node) { session_worker_t *wrk = session_main_get_worker (thread_index); vec_add1 (wrk->pending_tx_buffers, bi); diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index 5ac21c4eb85..8192194ff34 100644 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -517,7 +517,7 @@ mq_send_session_migrate_cb (session_t * s, session_handle_t new_sh) fifo_segment_t *eq_seg; app_worker_t *app_wrk; application_t *app; - u32 thread_index; + clib_thread_index_t thread_index; thread_index = session_thread_from_handle (new_sh); app_wrk = app_worker_get (s->app_wrk_index); diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c index aff102a6989..b223eff41b0 100644 --- a/src/vnet/session/session_cli.c +++ b/src/vnet/session/session_cli.c @@ -404,7 +404,7 @@ typedef struct session_cli_filter_ session_cli_endpt_flags_t endpt_flags; session_state_t *states; transport_proto_t transport_proto; - u32 thread_index; + clib_thread_index_t thread_index; u32 verbose; } session_cli_filter_t; @@ -521,7 +521,8 @@ session_cli_show_session_filter (vlib_main_t *vm, session_cli_filter_t *sf) } void -session_cli_show_events_thread (vlib_main_t * vm, u32 thread_index) +session_cli_show_events_thread (vlib_main_t *vm, + clib_thread_index_t thread_index) { session_worker_t *wrk; @@ -540,7 +541,7 @@ session_cli_show_events_thread (vlib_main_t * vm, u32 thread_index) } static void -session_cli_show_events (vlib_main_t * vm, u32 thread_index) +session_cli_show_events (vlib_main_t *vm, clib_thread_index_t thread_index) { session_main_t *smm = &session_main; if (!thread_index) @@ -824,7 +825,7 @@ clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { session_main_t *smm = &session_main; - u32 thread_index = 0, clear_all = 0; + clib_thread_index_t thread_index = 0, clear_all = 0; session_worker_t *wrk; u32 session_index = ~0; session_t *session; diff --git a/src/vnet/session/session_input.c b/src/vnet/session/session_input.c index 23a51823ef6..dd3bde77058 100644 --- a/src/vnet/session/session_input.c +++ b/src/vnet/session/session_input.c @@ -35,7 +35,7 @@ app_worker_del_all_events (app_worker_t *app_wrk) { session_worker_t *wrk; session_event_t *evt; - u32 thread_index; + clib_thread_index_t thread_index; session_t *s; for (thread_index = 0; thread_index < vec_len (app_wrk->wrk_evts); @@ -73,7 +73,8 @@ app_worker_del_all_events (app_worker_t *app_wrk) } always_inline int -app_worker_flush_events_inline (app_worker_t *app_wrk, u32 thread_index, +app_worker_flush_events_inline (app_worker_t *app_wrk, + clib_thread_index_t thread_index, u8 is_builtin) { application_t *app = application_get (app_wrk->app_index); @@ -285,7 +286,8 @@ app_worker_flush_events_inline (app_worker_t *app_wrk, u32 thread_index, } int -app_wrk_flush_wrk_events (app_worker_t *app_wrk, u32 thread_index) +app_wrk_flush_wrk_events (app_worker_t *app_wrk, + clib_thread_index_t thread_index) { if (app_worker_application_is_builtin (app_wrk)) return app_worker_flush_events_inline (app_wrk, thread_index, @@ -300,7 +302,7 @@ session_wrk_flush_events (session_worker_t *wrk) { app_worker_t *app_wrk; uword app_wrk_index; - u32 thread_index; + clib_thread_index_t thread_index; thread_index = wrk->vm->thread_index; app_wrk_index = clib_bitmap_first_set (wrk->app_wrks_pending_ntf); @@ -328,7 +330,7 @@ session_wrk_flush_events (session_worker_t *wrk) VLIB_NODE_FN (session_input_node) (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) { - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; session_worker_t *wrk; wrk = session_main_get_worker (thread_index); diff --git a/src/vnet/session/session_lookup.c b/src/vnet/session/session_lookup.c index 7678b0e0761..42b48a00d02 100644 --- a/src/vnet/session/session_lookup.c +++ b/src/vnet/session/session_lookup.c @@ -954,10 +954,10 @@ session_lookup_half_open_connection (u64 handle, u8 proto, u8 is_ip4) * @return pointer to transport connection, if one is found, 0 otherwise */ transport_connection_t * -session_lookup_connection_wt4 (u32 fib_index, ip4_address_t * lcl, - ip4_address_t * rmt, u16 lcl_port, - u16 rmt_port, u8 proto, u32 thread_index, - u8 * result) +session_lookup_connection_wt4 (u32 fib_index, ip4_address_t *lcl, + ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, + u8 proto, clib_thread_index_t thread_index, + u8 *result) { session_table_t *st; session_kv4_t kv4; @@ -1185,10 +1185,10 @@ session_lookup_safe4 (u32 fib_index, ip4_address_t * lcl, ip4_address_t * rmt, * @return pointer to transport connection, if one is found, 0 otherwise */ transport_connection_t * -session_lookup_connection_wt6 (u32 fib_index, ip6_address_t * lcl, - ip6_address_t * rmt, u16 lcl_port, - u16 rmt_port, u8 proto, u32 thread_index, - u8 * result) +session_lookup_connection_wt6 (u32 fib_index, ip6_address_t *lcl, + ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, + u8 proto, clib_thread_index_t thread_index, + u8 *result) { session_table_t *st; session_t *s; diff --git a/src/vnet/session/session_lookup.h b/src/vnet/session/session_lookup.h index 8f9ff7ee9bc..64016639190 100644 --- a/src/vnet/session/session_lookup.h +++ b/src/vnet/session/session_lookup.h @@ -43,25 +43,17 @@ session_t *session_lookup_safe4 (u32 fib_index, ip4_address_t * lcl, session_t *session_lookup_safe6 (u32 fib_index, ip6_address_t * lcl, ip6_address_t * rmt, u16 lcl_port, u16 rmt_port, u8 proto); -transport_connection_t *session_lookup_connection_wt4 (u32 fib_index, - ip4_address_t * lcl, - ip4_address_t * rmt, - u16 lcl_port, - u16 rmt_port, u8 proto, - u32 thread_index, - u8 * is_filtered); +transport_connection_t *session_lookup_connection_wt4 ( + u32 fib_index, ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, + u16 rmt_port, u8 proto, clib_thread_index_t thread_index, u8 *is_filtered); transport_connection_t *session_lookup_connection4 (u32 fib_index, ip4_address_t * lcl, ip4_address_t * rmt, u16 lcl_port, u16 rmt_port, u8 proto); -transport_connection_t *session_lookup_connection_wt6 (u32 fib_index, - ip6_address_t * lcl, - ip6_address_t * rmt, - u16 lcl_port, - u16 rmt_port, u8 proto, - u32 thread_index, - u8 * is_filtered); +transport_connection_t *session_lookup_connection_wt6 ( + u32 fib_index, ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, + u16 rmt_port, u8 proto, clib_thread_index_t thread_index, u8 *is_filtered); transport_connection_t *session_lookup_connection6 (u32 fib_index, ip6_address_t * lcl, ip6_address_t * rmt, diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 655f7ada09e..fb4c6252bb6 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -64,7 +64,8 @@ session_wrk_timerfd_update (session_worker_t *wrk, u64 time_ns) } always_inline u64 -session_wrk_tfd_timeout (session_wrk_state_t state, u32 thread_index) +session_wrk_tfd_timeout (session_wrk_state_t state, + clib_thread_index_t thread_index) { if (state == SESSION_WRK_INTERRUPT) return thread_index ? 1e6 : vlib_num_workers () ? 5e8 : 1e6; @@ -282,7 +283,7 @@ session_mq_handle_connects_rpc (void *arg) static void session_mq_connect_handler (session_worker_t *wrk, session_evt_elt_t *elt) { - u32 thread_index = wrk - session_main.wrk; + clib_thread_index_t thread_index = wrk - session_main.wrk; session_evt_elt_t *he; if (PREDICT_FALSE (thread_index > transport_cl_thread ())) @@ -778,7 +779,7 @@ session_wrk_handle_evts_main_rpc (void *args) clib_llist_index_t ei, next_ei; session_evt_elt_t *he, *elt; session_worker_t *fwrk; - u32 thread_index; + clib_thread_index_t thread_index; vlib_worker_thread_barrier_sync (vm); @@ -836,7 +837,7 @@ vlib_node_registration_t session_queue_node; typedef struct { - u32 thread_index; + clib_thread_index_t thread_index; } session_queue_trace_t; /* packet trace format function */ @@ -1845,7 +1846,7 @@ static const u32 session_evt_msg_sizes[] = { always_inline void session_update_time_subscribers (session_main_t *smm, clib_time_type_t now, - u32 thread_index) + clib_thread_index_t thread_index) { session_update_time_fn *fn; @@ -1953,7 +1954,7 @@ static uword session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { - u32 thread_index = vm->thread_index, __clib_unused n_evts; + clib_thread_index_t thread_index = vm->thread_index, __clib_unused n_evts; session_evt_elt_t *elt, *ctrl_he, *new_he, *old_he; session_main_t *smm = vnet_get_session_main (); session_worker_t *wrk = &smm->wrk[thread_index]; @@ -2119,7 +2120,7 @@ session_wrk_tfd_write_ready (clib_file_t *cf) void session_wrk_enable_adaptive_mode (session_worker_t *wrk) { - u32 thread_index = wrk->vm->thread_index; + clib_thread_index_t thread_index = wrk->vm->thread_index; clib_file_t template = { 0 }; if ((wrk->timerfd = timerfd_create (CLOCK_MONOTONIC, TFD_NONBLOCK)) < 0) diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h index 0c5afd40183..47a77449ba7 100644 --- a/src/vnet/session/session_types.h +++ b/src/vnet/session/session_types.h @@ -34,7 +34,7 @@ typedef union session_handle_tu_ struct { u32 session_index; - u32 thread_index; + clib_thread_index_t thread_index; }; } __attribute__ ((__transparent_union__)) session_handle_tu_t; @@ -220,7 +220,7 @@ typedef struct session_ u32 session_index; /** Index of the thread that allocated the session */ - u32 thread_index; + clib_thread_index_t thread_index; }; }; diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c index 3bd12d82fd8..edec182541e 100644 --- a/src/vnet/session/transport.c +++ b/src/vnet/session/transport.c @@ -106,7 +106,7 @@ format_transport_connection (u8 * s, va_list * args) { u32 transport_proto = va_arg (*args, u32); u32 conn_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); transport_proto_vft_t *tp_vft; transport_connection_t *tc; @@ -431,8 +431,8 @@ default_get_transport_endpoint (transport_connection_t * tc, void transport_get_endpoint (transport_proto_t tp, u32 conn_index, - u32 thread_index, transport_endpoint_t * tep, - u8 is_lcl) + clib_thread_index_t thread_index, + transport_endpoint_t *tep, u8 is_lcl) { if (tp_vfts[tp].get_transport_endpoint) tp_vfts[tp].get_transport_endpoint (conn_index, thread_index, tep, @@ -830,7 +830,7 @@ u8 * format_transport_pacer (u8 * s, va_list * args) { spacer_t *pacer = va_arg (*args, spacer_t *); - u32 thread_index = va_arg (*args, int); + clib_thread_index_t thread_index = va_arg (*args, int); clib_us_time_t now, diff; now = transport_us_time_now (thread_index); @@ -966,7 +966,8 @@ transport_connection_tx_pacer_update_bytes (transport_connection_t * tc, } void -transport_update_pacer_time (u32 thread_index, clib_time_type_t now) +transport_update_pacer_time (clib_thread_index_t thread_index, + clib_time_type_t now) { session_wrk_update_time (session_main_get_worker (thread_index), now); } diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h index de2a6becaae..31ad36bdc67 100644 --- a/src/vnet/session/transport.h +++ b/src/vnet/session/transport.h @@ -74,10 +74,10 @@ typedef struct _transport_proto_vft u32 (*start_listen) (u32 session_index, transport_endpoint_cfg_t *lcl); u32 (*stop_listen) (u32 conn_index); int (*connect) (transport_endpoint_cfg_t * rmt); - void (*half_close) (u32 conn_index, u32 thread_index); - void (*close) (u32 conn_index, u32 thread_index); - void (*reset) (u32 conn_index, u32 thread_index); - void (*cleanup) (u32 conn_index, u32 thread_index); + void (*half_close) (u32 conn_index, clib_thread_index_t thread_index); + void (*close) (u32 conn_index, clib_thread_index_t thread_index); + void (*reset) (u32 conn_index, clib_thread_index_t thread_index); + void (*cleanup) (u32 conn_index, clib_thread_index_t thread_index); void (*cleanup_ho) (u32 conn_index); clib_error_t *(*enable) (vlib_main_t * vm, u8 is_en); @@ -97,7 +97,8 @@ typedef struct _transport_proto_vft /* * Connection retrieval */ - transport_connection_t *(*get_connection) (u32 conn_idx, u32 thread_idx); + transport_connection_t *(*get_connection) (u32 conn_idx, + clib_thread_index_t thread_idx); transport_connection_t *(*get_listener) (u32 conn_index); transport_connection_t *(*get_half_open) (u32 conn_index); @@ -111,13 +112,14 @@ typedef struct _transport_proto_vft /* * Properties retrieval/setting */ - void (*get_transport_endpoint) (u32 conn_index, u32 thread_index, + void (*get_transport_endpoint) (u32 conn_index, + clib_thread_index_t thread_index, transport_endpoint_t *tep, u8 is_lcl); void (*get_transport_listener_endpoint) (u32 conn_index, transport_endpoint_t *tep, u8 is_lcl); - int (*attribute) (u32 conn_index, u32 thread_index, u8 is_get, - transport_endpt_attr_t *attr); + int (*attribute) (u32 conn_index, clib_thread_index_t thread_index, + u8 is_get, transport_endpt_attr_t *attr); /* * Properties @@ -144,8 +146,8 @@ void transport_cleanup (transport_proto_t tp, u32 conn_index, u8 thread_index); void transport_cleanup_half_open (transport_proto_t tp, u32 conn_index); void transport_get_endpoint (transport_proto_t tp, u32 conn_index, - u32 thread_index, transport_endpoint_t * tep, - u8 is_lcl); + clib_thread_index_t thread_index, + transport_endpoint_t *tep, u8 is_lcl); void transport_get_listener_endpoint (transport_proto_t tp, u32 conn_index, transport_endpoint_t * tep, u8 is_lcl); int transport_connection_attribute (transport_proto_t tp, u32 conn_index, @@ -179,7 +181,8 @@ transport_custom_tx (transport_proto_t tp, void *s, } static inline int -transport_app_rx_evt (transport_proto_t tp, u32 conn_index, u32 thread_index) +transport_app_rx_evt (transport_proto_t tp, u32 conn_index, + clib_thread_index_t thread_index) { transport_connection_t *tc; if (!tp_vfts[tp].app_rx_evt) @@ -368,7 +371,8 @@ transport_connection_tx_pacer_update_bytes (transport_connection_t * tc, * @param thread_index thread for which time is updated * @param now time now */ -void transport_update_pacer_time (u32 thread_index, clib_time_type_t now); +void transport_update_pacer_time (clib_thread_index_t thread_index, + clib_time_type_t now); #endif /* SRC_VNET_SESSION_TRANSPORT_H_ */ diff --git a/src/vnet/session/transport_types.h b/src/vnet/session/transport_types.h index 4a2f861814f..55cb1206e6b 100644 --- a/src/vnet/session/transport_types.h +++ b/src/vnet/session/transport_types.h @@ -113,7 +113,7 @@ typedef struct _transport_connection u32 s_index; /**< Parent session index */ u32 c_index; /**< Connection index in transport pool */ - u32 thread_index; /**< Worker-thread index */ + clib_thread_index_t thread_index; /**< Worker-thread index */ u8 flags; /**< Transport specific flags */ u8 dscp; /**< Differentiated Services Code Point */ diff --git a/src/vnet/srv6/sr_localsid.c b/src/vnet/srv6/sr_localsid.c index 47082e9c96a..8bf0996bbe1 100644 --- a/src/vnet/srv6/sr_localsid.c +++ b/src/vnet/srv6/sr_localsid.c @@ -1196,7 +1196,7 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node, from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { @@ -1500,7 +1500,7 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node, from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { @@ -1809,7 +1809,7 @@ sr_localsid_un_fn (vlib_main_t * vm, vlib_node_runtime_t * node, from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { @@ -2116,7 +2116,7 @@ sr_localsid_un_perf_fn (vlib_main_t * vm, vlib_node_runtime_t * node, from = vlib_frame_vector_args (from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; while (n_left_from > 0) { diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index 02239d991bd..ed8c514ae8e 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -432,7 +432,7 @@ tcp_connection_close (tcp_connection_t * tc) } static void -tcp_session_half_close (u32 conn_index, u32 thread_index) +tcp_session_half_close (u32 conn_index, clib_thread_index_t thread_index) { tcp_worker_ctx_t *wrk; tcp_connection_t *tc; @@ -456,7 +456,7 @@ tcp_session_half_close (u32 conn_index, u32 thread_index) } static void -tcp_session_close (u32 conn_index, u32 thread_index) +tcp_session_close (u32 conn_index, clib_thread_index_t thread_index) { tcp_connection_t *tc; tc = tcp_connection_get (conn_index, thread_index); @@ -464,7 +464,7 @@ tcp_session_close (u32 conn_index, u32 thread_index) } static void -tcp_session_cleanup (u32 conn_index, u32 thread_index) +tcp_session_cleanup (u32 conn_index, clib_thread_index_t thread_index) { tcp_connection_t *tc; tc = tcp_connection_get (conn_index, thread_index); @@ -487,7 +487,7 @@ tcp_session_cleanup_ho (u32 conn_index) } static void -tcp_session_reset (u32 conn_index, u32 thread_index) +tcp_session_reset (u32 conn_index, clib_thread_index_t thread_index) { tcp_connection_t *tc; tc = tcp_connection_get (conn_index, thread_index); @@ -856,7 +856,7 @@ static u8 * format_tcp_session (u8 * s, va_list * args) { u32 tci = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); tcp_connection_t *tc; @@ -906,7 +906,7 @@ format_tcp_half_open_session (u8 * s, va_list * args) } static transport_connection_t * -tcp_session_get_transport (u32 conn_index, u32 thread_index) +tcp_session_get_transport (u32 conn_index, clib_thread_index_t thread_index) { tcp_connection_t *tc = tcp_connection_get (conn_index, thread_index); if (PREDICT_FALSE (!tc)) @@ -1016,8 +1016,8 @@ tcp_get_attribute (tcp_connection_t *tc, transport_endpt_attr_t *attr) } static int -tcp_session_attribute (u32 conn_index, u32 thread_index, u8 is_get, - transport_endpt_attr_t *attr) +tcp_session_attribute (u32 conn_index, clib_thread_index_t thread_index, + u8 is_get, transport_endpt_attr_t *attr) { tcp_connection_t *tc = tcp_connection_get (conn_index, thread_index); @@ -1279,7 +1279,7 @@ tcp_dispatch_pending_timers (tcp_worker_ctx_t * wrk) static void tcp_handle_cleanups (tcp_worker_ctx_t * wrk, clib_time_type_t now) { - u32 thread_index = wrk->vm->thread_index; + clib_thread_index_t thread_index = wrk->vm->thread_index; tcp_cleanup_req_t *req; tcp_connection_t *tc; @@ -1404,7 +1404,8 @@ tcp_reschedule (tcp_connection_t * tc) static void tcp_expired_timers_dispatch (u32 * expired_timers) { - u32 thread_index = vlib_get_thread_index (), n_left, max_per_loop; + clib_thread_index_t thread_index = vlib_get_thread_index (), n_left, + max_per_loop; u32 connection_index, timer_id, n_expired, max_loops; tcp_worker_ctx_t *wrk; tcp_connection_t *tc; diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h index 830b81df9ee..67dc7407e91 100644 --- a/src/vnet/tcp/tcp.h +++ b/src/vnet/tcp/tcp.h @@ -299,7 +299,7 @@ vnet_get_tcp_main () } always_inline tcp_worker_ctx_t * -tcp_get_worker (u32 thread_index) +tcp_get_worker (clib_thread_index_t thread_index) { ASSERT (thread_index < vec_len (tcp_main.wrk)); return &tcp_main.wrk[thread_index]; @@ -314,8 +314,8 @@ void tcp_connection_cleanup (tcp_connection_t * tc); void tcp_connection_del (tcp_connection_t * tc); int tcp_half_open_connection_cleanup (tcp_connection_t * tc); -void tcp_send_reset_w_pkt (tcp_connection_t * tc, vlib_buffer_t * pkt, - u32 thread_index, u8 is_ip4); +void tcp_send_reset_w_pkt (tcp_connection_t *tc, vlib_buffer_t *pkt, + clib_thread_index_t thread_index, u8 is_ip4); void tcp_send_reset (tcp_connection_t * tc); void tcp_send_syn (tcp_connection_t * tc); void tcp_send_synack (tcp_connection_t * tc); diff --git a/src/vnet/tcp/tcp_cubic.c b/src/vnet/tcp/tcp_cubic.c index cf2b9a17d18..63abcd1312d 100644 --- a/src/vnet/tcp/tcp_cubic.c +++ b/src/vnet/tcp/tcp_cubic.c @@ -49,7 +49,7 @@ typedef struct cubic_data_ STATIC_ASSERT (sizeof (cubic_data_t) <= TCP_CC_DATA_SZ, "cubic data len"); static inline f64 -cubic_time (u32 thread_index) +cubic_time (clib_thread_index_t thread_index) { return tcp_time_now_us (thread_index); } diff --git a/src/vnet/tcp/tcp_inlines.h b/src/vnet/tcp/tcp_inlines.h index 4c48f9ecfc5..6ab467d759b 100644 --- a/src/vnet/tcp/tcp_inlines.h +++ b/src/vnet/tcp/tcp_inlines.h @@ -56,7 +56,7 @@ tcp_buffer_hdr (vlib_buffer_t * b) } always_inline tcp_connection_t * -tcp_connection_get (u32 conn_index, u32 thread_index) +tcp_connection_get (u32 conn_index, clib_thread_index_t thread_index) { tcp_worker_ctx_t *wrk = tcp_get_worker (thread_index); if (PREDICT_FALSE (pool_is_free_index (wrk->connections, conn_index))) @@ -65,7 +65,7 @@ tcp_connection_get (u32 conn_index, u32 thread_index) } always_inline tcp_connection_t * -tcp_connection_get_if_valid (u32 conn_index, u32 thread_index) +tcp_connection_get_if_valid (u32 conn_index, clib_thread_index_t thread_index) { tcp_worker_ctx_t *wrk; if (thread_index >= vec_len (tcp_main.wrk)) @@ -215,7 +215,7 @@ tcp_is_lost_fin (tcp_connection_t * tc) * Time used to generate timestamps, not the timestamp */ always_inline u32 -tcp_time_tstamp (u32 thread_index) +tcp_time_tstamp (clib_thread_index_t thread_index) { return tcp_main.wrk[thread_index].time_tstamp; } @@ -230,7 +230,7 @@ tcp_tstamp (tcp_connection_t * tc) } always_inline f64 -tcp_time_now_us (u32 thread_index) +tcp_time_now_us (clib_thread_index_t thread_index) { return tcp_main.wrk[thread_index].time_us; } diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index 7977a6c0a6e..47ae8513f62 100644 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -498,7 +498,7 @@ tcp_estimate_initial_rtt (tcp_connection_t * tc) static void tcp_handle_postponed_dequeues (tcp_worker_ctx_t * wrk) { - u32 thread_index = wrk->vm->thread_index; + clib_thread_index_t thread_index = wrk->vm->thread_index; u32 *pending_deq_acked; tcp_connection_t *tc; int i; @@ -1011,7 +1011,8 @@ tcp_program_disconnect (tcp_worker_ctx_t * wrk, tcp_connection_t * tc) static void tcp_handle_disconnects (tcp_worker_ctx_t * wrk) { - u32 thread_index, *pending_disconnects, *pending_resets; + clib_thread_index_t thread_index; + u32 *pending_disconnects, *pending_resets; tcp_connection_t *tc; int i; @@ -1397,7 +1398,8 @@ always_inline uword tcp46_established_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, int is_ip4) { - u32 thread_index = vm->thread_index, n_left_from, *from; + clib_thread_index_t thread_index = vm->thread_index; + u32 n_left_from, *from; tcp_worker_ctx_t *wrk = tcp_get_worker (thread_index); vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b; u16 err_counters[TCP_N_ERROR] = { 0 }; @@ -2025,7 +2027,7 @@ static void tcp46_rcv_process_trace_frame (vlib_main_t *vm, vlib_node_runtime_t *node, u32 *from, u32 n_bufs) { - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; tcp_connection_t *tc = 0; tcp_rx_trace_t *t; vlib_buffer_t *b; @@ -2051,7 +2053,8 @@ always_inline uword tcp46_rcv_process_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ip4) { - u32 thread_index = vm->thread_index, n_left_from, *from, max_deq; + clib_thread_index_t thread_index = vm->thread_index; + u32 n_left_from, *from, max_deq; tcp_worker_ctx_t *wrk = tcp_get_worker (thread_index); vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b; @@ -2544,7 +2547,7 @@ tcp46_listen_inline (vlib_main_t *vm, vlib_node_runtime_t *node, { u32 n_left_from, *from, n_syns = 0; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; u32 tw_iss = 0; from = vlib_frame_vector_args (frame); diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index 2e8a10896eb..120ad6c533e 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -646,8 +646,8 @@ tcp_buffer_make_reset (vlib_main_t *vm, vlib_buffer_t *b, u8 is_ip4) * It extracts connection info out of original packet */ void -tcp_send_reset_w_pkt (tcp_connection_t * tc, vlib_buffer_t * pkt, - u32 thread_index, u8 is_ip4) +tcp_send_reset_w_pkt (tcp_connection_t *tc, vlib_buffer_t *pkt, + clib_thread_index_t thread_index, u8 is_ip4) { tcp_worker_ctx_t *wrk = tcp_get_worker (thread_index); vlib_main_t *vm = wrk->vm; diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c index 08809f70070..d409ee5f126 100644 --- a/src/vnet/tls/tls.c +++ b/src/vnet/tls/tls.c @@ -21,7 +21,7 @@ static tls_main_t tls_main; tls_engine_vft_t *tls_vfts; -void tls_disconnect (u32 ctx_handle, u32 thread_index); +void tls_disconnect (u32 ctx_handle, clib_thread_index_t thread_index); void tls_disconnect_transport (tls_ctx_t * ctx) @@ -684,7 +684,7 @@ tls_connect (transport_endpoint_cfg_t * tep) } void -tls_disconnect (u32 ctx_handle, u32 thread_index) +tls_disconnect (u32 ctx_handle, clib_thread_index_t thread_index) { tls_ctx_t *ctx; @@ -820,7 +820,7 @@ tls_stop_listen (u32 lctx_index) } transport_connection_t * -tls_connection_get (u32 ctx_index, u32 thread_index) +tls_connection_get (u32 ctx_index, clib_thread_index_t thread_index) { tls_ctx_t *ctx; ctx = tls_ctx_get_w_thread (ctx_index, thread_index); @@ -959,7 +959,7 @@ u8 * format_tls_connection (u8 * s, va_list * args) { u32 ctx_index = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); tls_ctx_t *ctx; @@ -1013,8 +1013,8 @@ format_tls_half_open (u8 * s, va_list * args) } static void -tls_transport_endpoint_get (u32 ctx_handle, u32 thread_index, - transport_endpoint_t * tep, u8 is_lcl) +tls_transport_endpoint_get (u32 ctx_handle, clib_thread_index_t thread_index, + transport_endpoint_t *tep, u8 is_lcl) { tls_ctx_t *ctx = tls_ctx_get_w_thread (ctx_handle, thread_index); session_t *ts; @@ -1179,7 +1179,7 @@ dtls_half_open_get (u32 ho_index) } static void -dtls_cleanup_callback (u32 ctx_index, u32 thread_index) +dtls_cleanup_callback (u32 ctx_index, clib_thread_index_t thread_index) { /* No op */ } diff --git a/src/vnet/tls/tls.h b/src/vnet/tls/tls.h index 244e2042f11..7e69432512e 100644 --- a/src/vnet/tls/tls.h +++ b/src/vnet/tls/tls.h @@ -146,10 +146,10 @@ typedef struct tls_main_ typedef struct tls_engine_vft_ { u32 (*ctx_alloc) (void); - u32 (*ctx_alloc_w_thread) (u32 thread_index); + u32 (*ctx_alloc_w_thread) (clib_thread_index_t thread_index); void (*ctx_free) (tls_ctx_t * ctx); void *(*ctx_detach) (tls_ctx_t *ctx); - u32 (*ctx_attach) (u32 thread_index, void *ctx); + u32 (*ctx_attach) (clib_thread_index_t thread_index, void *ctx); tls_ctx_t *(*ctx_get) (u32 ctx_index); tls_ctx_t *(*ctx_get_w_thread) (u32 ctx_index, u8 thread_index); int (*ctx_init_client) (tls_ctx_t * ctx); diff --git a/src/vnet/tls/tls_inlines.h b/src/vnet/tls/tls_inlines.h index 3e3f59fcf51..2f12a779102 100644 --- a/src/vnet/tls/tls_inlines.h +++ b/src/vnet/tls/tls_inlines.h @@ -23,7 +23,8 @@ tls_ctx_alloc (crypto_engine_type_t engine_type) } static inline u32 -tls_ctx_alloc_w_thread (crypto_engine_type_t engine_type, u32 thread_index) +tls_ctx_alloc_w_thread (crypto_engine_type_t engine_type, + clib_thread_index_t thread_index) { u32 ctx_index; ctx_index = tls_vfts[engine_type].ctx_alloc_w_thread (thread_index); @@ -65,7 +66,8 @@ tls_ctx_init_client (tls_ctx_t *ctx) } static inline u32 -tls_ctx_attach (crypto_engine_type_t engine_type, u32 thread_index, void *ctx) +tls_ctx_attach (crypto_engine_type_t engine_type, + clib_thread_index_t thread_index, void *ctx) { u32 ctx_index; ctx_index = tls_vfts[engine_type].ctx_attach (thread_index, ctx); diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c index d997da21edf..2c2b744a49f 100644 --- a/src/vnet/udp/udp.c +++ b/src/vnet/udp/udp.c @@ -71,7 +71,7 @@ udp_connection_unregister_port (u16 lcl_port, u8 is_ip4) } udp_connection_t * -udp_connection_alloc (u32 thread_index) +udp_connection_alloc (clib_thread_index_t thread_index) { udp_worker_t *wrk = udp_worker_get (thread_index); udp_connection_t *uc; @@ -115,7 +115,7 @@ udp_connection_delete (udp_connection_t * uc) static void udp_handle_cleanups (void *args) { - u32 thread_index = (u32) pointer_to_uword (args); + clib_thread_index_t thread_index = (u32) pointer_to_uword (args); udp_connection_t *uc; udp_worker_t *wrk; u32 *uc_index; @@ -361,7 +361,7 @@ udp_push_header (transport_connection_t *tc, vlib_buffer_t **bs, u32 n_bufs) } static transport_connection_t * -udp_session_get (u32 connection_index, u32 thread_index) +udp_session_get (u32 connection_index, clib_thread_index_t thread_index) { udp_connection_t *uc; uc = udp_connection_get (connection_index, thread_index); @@ -371,7 +371,7 @@ udp_session_get (u32 connection_index, u32 thread_index) } static void -udp_session_close (u32 connection_index, u32 thread_index) +udp_session_close (u32 connection_index, clib_thread_index_t thread_index) { udp_connection_t *uc; @@ -386,7 +386,7 @@ udp_session_close (u32 connection_index, u32 thread_index) } static void -udp_session_cleanup (u32 connection_index, u32 thread_index) +udp_session_cleanup (u32 connection_index, clib_thread_index_t thread_index) { udp_connection_t *uc; uc = udp_connection_get (connection_index, thread_index); @@ -421,7 +421,7 @@ udp_open_connection (transport_endpoint_cfg_t * rmt) udp_main_t *um = &udp_main; ip46_address_t lcl_addr; udp_connection_t *uc; - u32 thread_index; + clib_thread_index_t thread_index; u16 lcl_port; int rv; @@ -484,7 +484,7 @@ static transport_connection_t * udp_session_get_half_open (u32 conn_index) { udp_connection_t *uc; - u32 thread_index; + clib_thread_index_t thread_index; /* We don't poll main thread if we have workers */ thread_index = transport_cl_thread (); @@ -498,7 +498,7 @@ static u8 * format_udp_session (u8 * s, va_list * args) { u32 uci = va_arg (*args, u32); - u32 thread_index = va_arg (*args, u32); + clib_thread_index_t thread_index = va_arg (*args, u32); u32 verbose = va_arg (*args, u32); udp_connection_t *uc; diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h index 2e280f7c2a8..57a0fe94d8c 100644 --- a/src/vnet/udp/udp.h +++ b/src/vnet/udp/udp.h @@ -176,13 +176,13 @@ void udp_add_dst_port (udp_main_t * um, udp_dst_port_t dst_port, char *dst_port_name, u8 is_ip4); always_inline udp_worker_t * -udp_worker_get (u32 thread_index) +udp_worker_get (clib_thread_index_t thread_index) { return vec_elt_at_index (udp_main.wrk, thread_index); } always_inline udp_connection_t * -udp_connection_get (u32 conn_index, u32 thread_index) +udp_connection_get (u32 conn_index, clib_thread_index_t thread_index) { udp_worker_t *wrk = udp_worker_get (thread_index); @@ -210,11 +210,12 @@ udp_connection_from_transport (transport_connection_t * tc) } void udp_connection_free (udp_connection_t * uc); -udp_connection_t *udp_connection_alloc (u32 thread_index); +udp_connection_t *udp_connection_alloc (clib_thread_index_t thread_index); void udp_connection_share_port (u16 lcl_port, u8 is_ip4); always_inline udp_connection_t * -udp_connection_clone_safe (u32 connection_index, u32 thread_index) +udp_connection_clone_safe (u32 connection_index, + clib_thread_index_t thread_index) { u32 current_thread_index = vlib_get_thread_index (), new_index; udp_connection_t *old_c, *new_c; diff --git a/src/vnet/udp/udp_encap_node.c b/src/vnet/udp/udp_encap_node.c index a86614f5475..99658ef6d03 100644 --- a/src/vnet/udp/udp_encap_node.c +++ b/src/vnet/udp/udp_encap_node.c @@ -78,7 +78,7 @@ udp_encap_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_combined_counter_main_t *cm = &udp_encap_counters; u32 *from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, *to_next, next_index; - u32 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; n_left_from = frame->n_vectors; next_index = node->cached_next_index; diff --git a/src/vnet/udp/udp_input.c b/src/vnet/udp/udp_input.c index 19cc04c2881..e4aaa0c7218 100644 --- a/src/vnet/udp/udp_input.c +++ b/src/vnet/udp/udp_input.c @@ -36,7 +36,7 @@ typedef struct { u32 connection; u32 disposition; - u32 thread_index; + clib_thread_index_t thread_index; } udp_input_trace_t; /* packet trace format function */ @@ -101,8 +101,8 @@ udp_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node, } static udp_connection_t * -udp_connection_accept (udp_connection_t * listener, session_dgram_hdr_t * hdr, - u32 thread_index) +udp_connection_accept (udp_connection_t *listener, session_dgram_hdr_t *hdr, + clib_thread_index_t thread_index) { udp_connection_t *uc; @@ -129,9 +129,10 @@ udp_connection_accept (udp_connection_t * listener, session_dgram_hdr_t * hdr, } static void -udp_connection_enqueue (udp_connection_t * uc0, session_t * s0, - session_dgram_hdr_t * hdr0, u32 thread_index, - vlib_buffer_t * b, u8 queue_event, u32 * error0) +udp_connection_enqueue (udp_connection_t *uc0, session_t *s0, + session_dgram_hdr_t *hdr0, + clib_thread_index_t thread_index, vlib_buffer_t *b, + u8 queue_event, u32 *error0) { int wrote0; @@ -258,7 +259,8 @@ always_inline uword udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, u8 is_ip4) { - u32 thread_index = vm->thread_index, n_left_from, *from, *first_buffer; + clib_thread_index_t thread_index = vm->thread_index; + u32 n_left_from, *from, *first_buffer; vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b; u16 err_counters[UDP_N_ERROR] = { 0 }; diff --git a/src/vnet/udp/udp_output.c b/src/vnet/udp/udp_output.c index 22b94141365..87bb150e403 100644 --- a/src/vnet/udp/udp_output.c +++ b/src/vnet/udp/udp_output.c @@ -52,7 +52,7 @@ format_udp_tx_trace (u8 *s, va_list *args) } always_inline udp_connection_t * -udp_output_get_connection (vlib_buffer_t *b, u32 thread_index) +udp_output_get_connection (vlib_buffer_t *b, clib_thread_index_t thread_index) { if (PREDICT_FALSE (vnet_buffer (b)->tcp.flags & UDP_CONN_F_LISTEN)) return udp_listener_get (vnet_buffer (b)->tcp.connection_index); diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c index eca846d3a1a..9013f4bf878 100644 --- a/src/vnet/unix/tuntap.c +++ b/src/vnet/unix/tuntap.c @@ -153,7 +153,7 @@ tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vnet_interface_main_t *im = &vnm->interface_main; u32 n_bytes = 0; int i; - u16 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; for (i = 0; i < n_packets; i++) { @@ -242,7 +242,7 @@ tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) vlib_buffer_t *b; u32 bi; const uword buffer_size = vlib_buffer_get_default_data_size (vm); - u16 thread_index = vm->thread_index; + clib_thread_index_t thread_index = vm->thread_index; /** Make sure we have some RX buffers. */ { diff --git a/src/vnet/util/refcount.c b/src/vnet/util/refcount.c index a7b525d67be..dcb29841262 100644 --- a/src/vnet/util/refcount.c +++ b/src/vnet/util/refcount.c @@ -32,7 +32,7 @@ u64 vlib_refcount_get(vlib_refcount_t *r, u32 index) { u64 count = 0; vlib_thread_main_t *tm = vlib_get_thread_main (); - u32 thread_index; + clib_thread_index_t thread_index; for (thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++) { vlib_refcount_lock(r->per_cpu[thread_index].counter_lock); if (index < vec_len(r->per_cpu[thread_index].counters)) diff --git a/src/vnet/util/refcount.h b/src/vnet/util/refcount.h index 4c7d7bdbdd5..63bc80d72be 100644 --- a/src/vnet/util/refcount.h +++ b/src/vnet/util/refcount.h @@ -64,8 +64,9 @@ void vlib_refcount_unlock (clib_spinlock_t counter_lock) void __vlib_refcount_resize(vlib_refcount_per_cpu_t *per_cpu, u32 size); -static_always_inline -void vlib_refcount_add(vlib_refcount_t *r, u32 thread_index, u32 counter_index, i32 v) +static_always_inline void +vlib_refcount_add (vlib_refcount_t *r, clib_thread_index_t thread_index, + u32 counter_index, i32 v) { vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[thread_index]; if (PREDICT_FALSE(counter_index >= vec_len(per_cpu->counters))) @@ -80,7 +81,7 @@ static_always_inline void vlib_refcount_init(vlib_refcount_t *r) { vlib_thread_main_t *tm = vlib_get_thread_main (); - u32 thread_index; + clib_thread_index_t thread_index; r->per_cpu = 0; vec_validate (r->per_cpu, tm->n_vlib_mains - 1); diff --git a/src/vnet/util/throttle.h b/src/vnet/util/throttle.h index 53435c4a359..4fd1619935e 100644 --- a/src/vnet/util/throttle.h +++ b/src/vnet/util/throttle.h @@ -40,7 +40,7 @@ extern void throttle_init (throttle_t *t, u32 n_threads, u32 buckets, f64 time); always_inline u64 -throttle_seed (throttle_t * t, u32 thread_index, f64 time_now) +throttle_seed (throttle_t *t, clib_thread_index_t thread_index, f64 time_now) { if (time_now - t->last_seed_change_time[thread_index] > t->time) { @@ -53,7 +53,8 @@ throttle_seed (throttle_t * t, u32 thread_index, f64 time_now) } always_inline int -throttle_check (throttle_t * t, u32 thread_index, u64 hash, u64 seed) +throttle_check (throttle_t *t, clib_thread_index_t thread_index, u64 hash, + u64 seed) { ASSERT (is_pow2 (t->buckets)); diff --git a/src/vppinfra/CMakeLists.txt b/src/vppinfra/CMakeLists.txt index 83a8b2a7e57..08a5fa213ab 100644 --- a/src/vppinfra/CMakeLists.txt +++ b/src/vppinfra/CMakeLists.txt @@ -194,7 +194,6 @@ set(VPPINFRA_HEADERS random_isaac.h rbtree.h serialize.h - smp.h socket.h sparse_vec.h stack.h diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index d488b1a659c..975607d904e 100644 --- a/src/vppinfra/bihash_template.c +++ b/src/vppinfra/bihash_template.c @@ -544,7 +544,7 @@ BV (make_working_copy) (BVT (clib_bihash) * h, BVT (clib_bihash_bucket) * b) BVT (clib_bihash_value) * v; BVT (clib_bihash_bucket) working_bucket __attribute__ ((aligned (8))); BVT (clib_bihash_value) * working_copy; - u32 thread_index = os_get_thread_index (); + clib_thread_index_t thread_index = os_get_thread_index (); int log2_working_copy_length; ASSERT (h->alloc_lock[0]); @@ -696,7 +696,7 @@ static_always_inline int BV (clib_bihash_add_del_inline_with_hash) ( int i, limit; u64 new_hash; u32 new_log2_pages, old_log2_pages; - u32 thread_index = os_get_thread_index (); + clib_thread_index_t thread_index = os_get_thread_index (); int mark_bucket_linear; int resplit_once; diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h index 4ab7bcf7a7c..e4badb7f27d 100644 --- a/src/vppinfra/bitmap.h +++ b/src/vppinfra/bitmap.h @@ -381,11 +381,12 @@ clib_bitmap_set_region (uword * bitmap, uword i, uword value, uword n_bits) @param ai - the bitmap @param body - the expression to evaluate for each set bit */ -#define clib_bitmap_foreach(i,ai) \ - if (ai) \ - for (i = clib_bitmap_first_set (ai); \ - i != ~0; \ - i = clib_bitmap_next_set (ai, i + 1)) +#define clib_bitmap_foreach(i, ai) \ + if (ai) \ + for (uword __index = clib_bitmap_first_set (ai), \ + __clib_unused __dummy = (i) = __index; \ + __index != ~0; \ + __index = clib_bitmap_next_set (ai, __index + 1), (i) = __index) /** Return the lowest numbered set bit in a bitmap @param ai - pointer to the bitmap diff --git a/src/vppinfra/file.h b/src/vppinfra/file.h index 22d6feee274..99a1e97e1aa 100644 --- a/src/vppinfra/file.h +++ b/src/vppinfra/file.h @@ -155,7 +155,7 @@ clib_file_del_by_index (clib_file_main_t *fm, uword index) } always_inline void -clib_file_free_deleted (clib_file_main_t *fm, u32 thread_index) +clib_file_free_deleted (clib_file_main_t *fm, clib_thread_index_t thread_index) { u32 n_keep = 0; @@ -179,7 +179,7 @@ clib_file_free_deleted (clib_file_main_t *fm, u32 thread_index) always_inline void clib_file_set_polling_thread (clib_file_main_t *fm, uword index, - u32 thread_index) + clib_thread_index_t thread_index) { clib_file_t *f = clib_file_get (fm, index); fm->file_update (f, UNIX_FILE_UPDATE_DELETE); diff --git a/src/vppinfra/os.h b/src/vppinfra/os.h index cd3b4289da6..229ed375e74 100644 --- a/src/vppinfra/os.h +++ b/src/vppinfra/os.h @@ -56,29 +56,29 @@ void os_out_of_memory (void); /* Estimate, measure or divine CPU timestamp clock frequency. */ f64 os_cpu_clock_frequency (void); -extern __thread uword __os_thread_index; -extern __thread uword __os_numa_index; +extern __thread clib_thread_index_t __os_thread_index; +extern __thread clib_numa_node_index_t __os_numa_index; -static_always_inline uword +static_always_inline clib_thread_index_t os_get_thread_index (void) { return __os_thread_index; } static_always_inline void -os_set_thread_index (uword thread_index) +os_set_thread_index (clib_thread_index_t thread_index) { __os_thread_index = thread_index; } -static_always_inline uword +static_always_inline clib_numa_node_index_t os_get_numa_index (void) { return __os_numa_index; } static_always_inline void -os_set_numa_index (uword numa_index) +os_set_numa_index (clib_numa_node_index_t numa_index) { __os_numa_index = numa_index; } @@ -94,14 +94,6 @@ os_get_cpu_number (void) uword os_get_nthreads (void); -#include +#include #endif /* included_os_h */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/src/vppinfra/smp.h b/src/vppinfra/smp.h deleted file mode 100644 index 2b3ed548dfa..00000000000 --- a/src/vppinfra/smp.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ -/* - Copyright (c) 2001-2005 Eliot Dresselhaus - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef included_clib_smp_h -#define included_clib_smp_h - -#include -#include /* for os_panic */ - -#if defined (i386) || defined (__x86_64__) -#define clib_smp_pause() do { asm volatile ("pause"); } while (0) -#elif defined (__aarch64__) || defined (__arm__) -#define clib_smp_pause() do { asm volatile ("isb" ::: "memory"); } while (0) -#endif - -#ifndef clib_smp_pause -#define clib_smp_pause() do { } while (0) -#endif - -#ifdef CLIB_UNIX -#include - -always_inline void -os_sched_yield (void) -{ - sched_yield (); -} -#else -always_inline void -os_sched_yield (void) -{ - clib_smp_pause (); -} -#endif - - -#endif /* included_clib_smp_h */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c index 2abf2b244cd..f4dad844d33 100644 --- a/src/vppinfra/socket.c +++ b/src/vppinfra/socket.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include diff --git a/src/vppinfra/types.h b/src/vppinfra/types.h index ad85af35ac9..9ed1754fbff 100644 --- a/src/vppinfra/types.h +++ b/src/vppinfra/types.h @@ -211,6 +211,10 @@ typedef uword uwordu __attribute__ ((aligned (1), __may_alias__)); __ptr_ptr - (ARRAY_LEN (__ptr_array) - 1) < __ptr_array; \ __var = *++__ptr_ptr) +typedef u16 clib_thread_index_t; +typedef u8 clib_numa_node_index_t; +#define CLIB_INVALID_THREAD_INDEX CLIB_U16_MAX + #endif /* included_clib_types_h */ /* diff --git a/src/vppinfra/unix-misc.c b/src/vppinfra/unix-misc.c index c0cf507aa5c..2255cc7cc3a 100644 --- a/src/vppinfra/unix-misc.c +++ b/src/vppinfra/unix-misc.c @@ -64,8 +64,8 @@ #include /* for sprintf */ #include -__clib_export __thread uword __os_thread_index = 0; -__clib_export __thread uword __os_numa_index = 0; +__clib_export __thread clib_thread_index_t __os_thread_index = 0; +__clib_export __thread clib_numa_node_index_t __os_numa_index = 0; __clib_export cpu_set_t __os_affinity_cpu_set; __clib_export clib_bitmap_t *os_get_cpu_affinity_bitmap ();