|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
47 #define HAVE_LINUX_EPOLL
49 #ifdef HAVE_LINUX_EPOLL
51 #include <sys/epoll.h>
72 f->polling_thread_index);
73 struct epoll_event e = { 0 };
81 e.data.u32 =
f -
fm->file_pool;
118 if (epoll_ctl (em->
epoll_fd, op,
f->file_descriptor, &e) < 0)
140 struct epoll_event *e;
146 u32 ticks_until_expiration;
149 int timeout_ms = 0, max_timeout_ms = 10;
161 struct timespec ts, tsrem;
164 node->input_main_loops_per_call = 0;
168 while (nanosleep (&ts, &tsrem) < 0)
174 else if (is_main && vector_rate < 2 && vm->api_queue_nonempty == 0
175 &&
nm->input_node_counts_by_state[VLIB_NODE_STATE_POLLING] == 0)
177 ticks_until_expiration =
TW (tw_timer_first_expires_in_ticks)
178 ((
TWT (tw_timer_wheel) *)
nm->timing_wheel);
184 timeout_ms = max_timeout_ms;
188 timeout = (
f64) ticks_until_expiration *1e-5;
193 timeout_ms = timeout * 1e3;
195 timeout_ms =
clib_max (1, timeout_ms);
196 timeout_ms =
clib_min (max_timeout_ms, timeout_ms);
199 node->input_main_loops_per_call = 0;
201 else if (is_main == 0 && vector_rate < 2 &&
203 nm->input_node_counts_by_state[VLIB_NODE_STATE_POLLING] == 0)
206 timeout_ms = max_timeout_ms;
207 node->input_main_loops_per_call = 0;
212 node->input_main_loops_per_call = 1024;
218 static sigset_t unblock_all_signals;
219 n_fds_ready = epoll_pwait (em->
epoll_fd,
222 timeout_ms, &unblock_all_signals);
225 if (n_fds_ready < 0 && errno == ENOSYS)
227 n_fds_ready = epoll_wait (em->
epoll_fd,
241 struct timespec ts, tsrem;
242 f64 limit =
now + (
f64) timeout_ms * 1e-3;
248 ts.tv_nsec = 1000 * 100;
250 while (nanosleep (&ts, &tsrem) < 0)
253 *
nm->pending_interrupts)
273 for (e = em->
epoll_events; e < em->epoll_events + n_fds_ready; e++)
285 f =
fm->file_pool +
i;
288 if (e->events & EPOLLIN)
292 "to free index %u",
i);
295 if (e->events & EPOLLOUT)
299 "to free index %u",
i);
302 if (e->events & EPOLLERR)
306 "to free index %u",
i);
312 if (e->events & EPOLLIN)
315 errors[n_errors] =
f->read_function (
f);
320 n_errors += errors[n_errors] != 0;
322 if (e->events & EPOLLOUT)
325 errors[n_errors] =
f->write_function (
f);
326 n_errors += errors[n_errors] != 0;
331 if (
f->error_function)
334 errors[n_errors] =
f->error_function (
f);
335 n_errors += errors[n_errors] != 0;
338 close (
f->file_descriptor);
342 for (
i = 0;
i < n_errors;
i++)
374 .name =
"unix-epoll-input",
422 .runs_before =
VLIB_INITS (
"linux_epoll_input_init"),
clib_file_main_t file_main
struct epoll_event * epoll_events
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
@ VLIB_NODE_TYPE_PRE_INPUT
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
static word unix_error_is_fatal(word error)
vlib_main_t vlib_node_runtime_t * node
#define clib_error_return(e, args...)
vlib_node_main_t node_main
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
__clib_export u32 clib_get_current_cpu_id()
vlib_worker_thread_t * vlib_worker_threads
static void unix_save_error(unix_main_t *um, clib_error_t *error)
#define clib_unix_warning(format, args...)
static void vlib_panic_with_error(vlib_main_t *vm, clib_error_t *error)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
volatile u32 * wait_at_barrier
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define UNIX_FILE_EVENT_EDGE_TRIGGERED
#define UNIX_FILE_DATA_AVAILABLE_TO_WRITE
static u32 vlib_last_vectors_per_main_loop(vlib_main_t *vm)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static_always_inline uword vlib_get_thread_index(void)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define static_always_inline
#define pool_is_free(P, E)
Use free bitmap to query whether given element is free.
#define TW_SLOTS_PER_RING
__clib_export u32 clib_get_current_numa_node()
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
@ UNIX_FILE_UPDATE_DELETE
#define VLIB_INIT_FUNCTION(x)
static vlib_main_t * vlib_get_first_main(void)
#define vec_foreach(var, vec)
Vector iterator.
@ UNIX_FILE_UPDATE_MODIFY
#define clib_error_return_unix(e, args...)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define clib_warning(format, args...)
static f64 vlib_time_now(vlib_main_t *vm)
static vlib_thread_main_t * vlib_get_thread_main()
#define VLIB_REGISTER_NODE(x,...)