summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-01-19 20:56:12 +0100
committerDave Barach <openvpp@barachs.net>2018-02-06 18:17:46 +0000
commitceab7882f8016c2407a4383f87277bad069885b1 (patch)
treee90e247184d9dc3086b6f11f25dff8bd6e7ce51e /src/vppinfra
parentdf5a99cef13ff6a22c195091be45152dc65f5d71 (diff)
vlib: epoll on worker threads
This patch teaches worer threads to sleep and to be waken up by kernel if there is activity on file desctiptors assigned to that thread. It also adds counters to epoll file descriptors and new debug cli 'show unix file'. Change-Id: Iaf67869f4aa88ff5b0a08982e1c08474013107c4 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/file.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/vppinfra/file.h b/src/vppinfra/file.h
index f9349721a7c..b5a0507c3b8 100644
--- a/src/vppinfra/file.h
+++ b/src/vppinfra/file.h
@@ -57,11 +57,22 @@ typedef struct clib_file
#define UNIX_FILE_DATA_AVAILABLE_TO_WRITE (1 << 0)
#define UNIX_FILE_EVENT_EDGE_TRIGGERED (1 << 1)
+ /* polling thread index */
+ u32 polling_thread_index;
+
/* Data available for function's use. */
uword private_data;
/* Functions to be called when read/write data becomes ready. */
clib_file_function_t *read_function, *write_function, *error_function;
+
+ /* Description */
+ u8 *description;
+
+ /* Stats */
+ u64 read_events;
+ u64 write_events;
+ u64 error_events;
} clib_file_t;
typedef enum
@@ -87,6 +98,9 @@ clib_file_add (clib_file_main_t * um, clib_file_t * template)
clib_file_t *f;
pool_get (um->file_pool, f);
f[0] = template[0];
+ f->read_events = 0;
+ f->write_events = 0;
+ f->error_events = 0;
um->file_update (f, UNIX_FILE_UPDATE_ADD);
return f - um->file_pool;
}
@@ -97,6 +111,7 @@ clib_file_del (clib_file_main_t * um, clib_file_t * f)
um->file_update (f, UNIX_FILE_UPDATE_DELETE);
close (f->file_descriptor);
f->file_descriptor = ~0;
+ vec_free (f->description);
pool_put (um->file_pool, f);
}
@@ -108,6 +123,16 @@ clib_file_del_by_index (clib_file_main_t * um, uword index)
clib_file_del (um, uf);
}
+always_inline void
+clib_file_set_polling_thread (clib_file_main_t * um, uword index,
+ u32 thread_index)
+{
+ clib_file_t *f = pool_elt_at_index (um->file_pool, index);
+ um->file_update (f, UNIX_FILE_UPDATE_DELETE);
+ f->polling_thread_index = thread_index;
+ um->file_update (f, UNIX_FILE_UPDATE_ADD);
+}
+
always_inline uword
clib_file_set_data_available_to_write (clib_file_main_t * um,
u32 clib_file_index,