dpdk_config (vlib_main_t * vm, unformat_input_t * input)
{
clib_error_t * error = 0;
+ dpdk_main_t * dm = &dpdk_main;
dpdk_config_main_t * conf = &dpdk_config_main;
vlib_thread_main_t * tm = vlib_get_thread_main();
vlib_node_runtime_t * rt = vlib_node_get_runtime (vm, dpdk_input_node.index);
conf->use_virtio_vhost = 0;
else if (unformat (input, "rss %d", &conf->use_rss))
;
-
+ else if (unformat (input, "poll-sleep %d", &dm->poll_sleep))
+ ;
#define _(a) \
else if (unformat(input, #a)) \
{ \
return mb_index;
}
-#if VIRL > 0
-#define VIRL_SPEED_LIMIT() \
- /* Limit the input rate to 1000 vectors / sec */ \
- { \
- struct timespec ts, tsrem; \
- \
- ts.tv_sec = 0; \
- ts.tv_nsec = 1000*1000; /* 1ms */ \
- \
- while (nanosleep(&ts, &tsrem) < 0) \
- { \
- ts = tsrem; \
- } \
- }
-#else
-#define VIRL_SPEED_LIMIT()
-#endif
+static inline void poll_rate_limit(dpdk_main_t * dm)
+{
+ /* Limit the poll rate by sleeping for N msec between polls */
+ if (PREDICT_FALSE (dm->poll_sleep != 0))
+ {
+ struct timespec ts, tsrem;
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1000*1000*dm->poll_sleep; /* 1ms */
+ while (nanosleep(&ts, &tsrem) < 0)
+ {
+ ts = tsrem;
+ }
+ }
+}
static uword
dpdk_input (vlib_main_t * vm,
n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, 0, 0);
}
- VIRL_SPEED_LIMIT()
+ poll_rate_limit(dm);
return n_rx_packets;
}
n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, 0);
}
- VIRL_SPEED_LIMIT()
+ poll_rate_limit(dm);
return n_rx_packets;
}
n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, 1);
}
- VIRL_SPEED_LIMIT()
+ poll_rate_limit(dm);
return n_rx_packets;
}