summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
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,