Skip to content

Commit c0c4eec

Browse files
committed
nsim: enable output scheduling on main thread
Type: fix Change-Id: I5d47cb9bc7eb7f3c8485e3b42f0701e81d87ba2a Signed-off-by: Dave Wallace <[email protected]>
1 parent 54eda4b commit c0c4eec

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/plugins/nsim/nsim.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ nsim_configure (nsim_main_t * nsm, f64 bandwidth, f64 delay, f64 packet_size,
182182
vec_validate (nsm->wheel_by_thread, num_workers);
183183

184184
/* Initialize the output scheduler wheels */
185-
for (i = num_workers ? 1 : 0; i < num_workers + 1; i++)
185+
i = (!nsm->poll_main_thread && num_workers) ? 1 : 0;
186+
for (; i < num_workers + 1; i++)
186187
{
187188
nsim_wheel_t *wp;
188189

@@ -205,7 +206,8 @@ nsim_configure (nsim_main_t * nsm, f64 bandwidth, f64 delay, f64 packet_size,
205206
vlib_worker_thread_barrier_sync (vm);
206207

207208
/* turn on the ring scrapers */
208-
for (i = num_workers ? 1 : 0; i < num_workers + 1; i++)
209+
i = (!nsm->poll_main_thread && num_workers) ? 1 : 0;
210+
for (; i < num_workers + 1; i++)
209211
{
210212
vlib_main_t *this_vm = vlib_mains[i];
211213

@@ -287,6 +289,28 @@ nsim_cross_connect_enable_disable_command_fn (vlib_main_t * vm,
287289
return 0;
288290
}
289291

292+
static clib_error_t *
293+
nsim_config (vlib_main_t * vm, unformat_input_t * input)
294+
{
295+
nsim_main_t *nsm = &nsim_main;
296+
297+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
298+
{
299+
if (unformat (input, "poll-main-thread"))
300+
{
301+
nsm->poll_main_thread = 1;
302+
}
303+
else
304+
{
305+
return clib_error_return (0, "unknown input '%U'",
306+
format_unformat_error, input);
307+
}
308+
}
309+
return 0;
310+
}
311+
312+
VLIB_CONFIG_FUNCTION (nsim_config, "nsim");
313+
290314
/*?
291315
* Enable or disable network simulation cross-connect on two interfaces
292316
* The network simulator must have already been configured, see
@@ -584,6 +608,8 @@ set_nsim_command_fn (vlib_main_t * vm,
584608
return clib_error_return
585609
(0, "drop fraction must be between zero and 1");
586610
}
611+
else if (unformat (input, "poll-main-thread"))
612+
nsm->poll_main_thread = 1;
587613
else
588614
break;
589615
}

src/plugins/nsim/nsim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef struct
6868
f64 bandwidth;
6969
f64 packet_size;
7070
f64 drop_fraction;
71+
u32 poll_main_thread;
7172

7273
u64 mmap_size;
7374

0 commit comments

Comments
 (0)