-struct lockless_rchan
-{
- u8 bufno_bits; /* # bits used for sub-buffer id */
- u8 offset_bits; /* # bits used for offset within sub-buffer */
- u32 index; /* current index = sub-buffer id and offset */
- u32 offset_mask; /* used to obtain offset portion of index */
- u32 index_mask; /* used to mask off unused bits index */
- atomic_t fill_count[RELAY_MAX_BUFS]; /* fill count per sub-buffer */
-};
-
-/*
- * Locking scheme-specific data
- */
-struct locking_rchan
-{
- char *write_buf; /* start of write sub-buffer */
- char *write_buf_end; /* end of write sub-buffer */
- char *current_write_pos; /* current write pointer */
- char *write_limit; /* takes reserves into account */
- char *in_progress_event_pos; /* used for interrupted writes */
- u16 in_progress_event_size; /* used for interrupted writes */
- char *interrupted_pos; /* used for interrupted writes */
- u16 interrupting_size; /* used for interrupted writes */
- spinlock_t lock; /* channel lock for locking scheme */
-};
-
-struct relay_ops;
-
-/*
- * Offset resizing data structure
- */
-struct resize_offset
-{
- u32 ge;
- u32 le;
- int delta;
-};
-
-/*
- * Relay channel data structure
- */
-struct rchan
-{
- u32 version; /* the version of this struct */
- char *buf; /* the channel buffer */
- union
- {
- struct lockless_rchan lockless;
- struct locking_rchan locking;
- } scheme; /* scheme-specific channel data */
-
- int id; /* the channel id */
- struct rchan_callbacks *callbacks; /* client callbacks */
- u32 flags; /* relay channel attributes */
- u32 buf_id; /* current sub-buffer id */
- u32 buf_idx; /* current sub-buffer index */
-
- atomic_t mapped; /* map count */
-
- atomic_t suspended; /* channel suspended i.e full? */
- int half_switch; /* used internally for suspend */
-
- struct timeval buf_start_time; /* current sub-buffer start time */
- u32 buf_start_tsc; /* current sub-buffer start TSC */
-
- u32 buf_size; /* sub-buffer size */
- u32 alloc_size; /* total buffer size allocated */
- u32 n_bufs; /* number of sub-buffers */
-
- u32 bufs_produced; /* count of sub-buffers produced */
- u32 bufs_consumed; /* count of sub-buffers consumed */
- u32 bytes_consumed; /* bytes consumed in cur sub-buffer */
-
- int initialized; /* first buffer initialized? */
- int finalized; /* channel finalized? */
-
- u32 start_reserve; /* reserve at start of sub-buffers */
- u32 end_reserve; /* reserve at end of sub-buffers */
- u32 rchan_start_reserve; /* additional reserve sub-buffer 0 */
-
- struct dentry *dentry; /* channel file dentry */
-
- wait_queue_head_t read_wait; /* VFS read wait queue */
- wait_queue_head_t write_wait; /* VFS write wait queue */
- struct work_struct wake_readers; /* reader wake-up work struct */
- struct work_struct wake_writers; /* reader wake-up work struct */
- atomic_t refcount; /* channel refcount */
-
- struct relay_ops *relay_ops; /* scheme-specific channel ops */
-
- int unused_bytes[RELAY_MAX_BUFS]; /* unused count per sub-buffer */
-
- struct semaphore resize_sem; /* serializes alloc/repace */
- struct work_struct work; /* resize allocation work struct */
-
- struct list_head open_readers; /* open readers for this channel */
- rwlock_t open_readers_lock; /* protection for open_readers list */
-
- char *init_buf; /* init channel buffer, if non-NULL */
-
- u32 resize_min; /* minimum resized total buffer size */
- u32 resize_max; /* maximum resized total buffer size */
- char *resize_buf; /* for autosize alloc/free */
- u32 resize_buf_size; /* resized sub-buffer size */
- u32 resize_n_bufs; /* resized number of sub-buffers */
- u32 resize_alloc_size; /* resized actual total size */
- int resizing; /* is resizing in progress? */
- int resize_err; /* resizing err code */
- int resize_failures; /* number of resize failures */
- int replace_buffer; /* is the alloced buffer ready? */
- struct resize_offset resize_offset; /* offset change */
- struct timer_list shrink_timer; /* timer used for shrinking */
- int resize_order; /* size of last resize */
- u32 expand_buf_id; /* subbuf id expand will occur at */
-
- struct page **buf_page_array; /* array of current buffer pages */
- int buf_page_count; /* number of current buffer pages */
- struct page **expand_page_array;/* new pages to be inserted */
- int expand_page_count; /* number of new pages */
- struct page **shrink_page_array;/* old pages to be freed */
- int shrink_page_count; /* number of old pages */
- struct page **resize_page_array;/* will become current pages */
- int resize_page_count; /* number of resize pages */
- struct page **old_buf_page_array; /* hold for freeing */
-} ____cacheline_aligned;
-
-/*
- * Relay channel reader struct
- */
-struct rchan_reader
-{
- struct list_head list; /* for list inclusion */
- struct rchan *rchan; /* the channel we're reading from */
- int auto_consume; /* does this reader auto-consume? */
- u32 bufs_consumed; /* buffers this reader has consumed */
- u32 bytes_consumed; /* bytes consumed in cur sub-buffer */
- int offset_changed; /* have channel offsets changed? */
- int vfs_reader; /* are we a VFS reader? */
- int map_reader; /* are we an mmap reader? */
-
- union
- {
- struct file *file;
- u32 f_pos;
- } pos; /* current read offset */
-};
-
-/*
- * These help make union member access less tedious
- */
-#define channel_buffer(rchan) ((rchan)->buf)
-#define idx(rchan) ((rchan)->scheme.lockless.index)
-#define bufno_bits(rchan) ((rchan)->scheme.lockless.bufno_bits)
-#define offset_bits(rchan) ((rchan)->scheme.lockless.offset_bits)
-#define offset_mask(rchan) ((rchan)->scheme.lockless.offset_mask)
-#define idx_mask(rchan) ((rchan)->scheme.lockless.index_mask)
-#define bulk_delivery(rchan) (((rchan)->flags & RELAY_DELIVERY_BULK) ? 1 : 0)
-#define packet_delivery(rchan) (((rchan)->flags & RELAY_DELIVERY_PACKET) ? 1 : 0)
-#define using_lockless(rchan) (((rchan)->flags & RELAY_SCHEME_LOCKLESS) ? 1 : 0)
-#define using_locking(rchan) (((rchan)->flags & RELAY_SCHEME_LOCKING) ? 1 : 0)
-#define using_tsc(rchan) (((rchan)->flags & RELAY_TIMESTAMP_TSC) ? 1 : 0)
-#define using_gettimeofday(rchan) (((rchan)->flags & RELAY_TIMESTAMP_GETTIMEOFDAY) ? 1 : 0)
-#define usage_smp(rchan) (((rchan)->flags & RELAY_USAGE_SMP) ? 1 : 0)
-#define usage_global(rchan) (((rchan)->flags & RELAY_USAGE_GLOBAL) ? 1 : 0)
-#define mode_continuous(rchan) (((rchan)->flags & RELAY_MODE_CONTINUOUS) ? 1 : 0)
-#define fill_count(rchan, i) ((rchan)->scheme.lockless.fill_count[(i)])
-#define write_buf(rchan) ((rchan)->scheme.locking.write_buf)
-#define read_buf(rchan) ((rchan)->scheme.locking.read_buf)
-#define write_buf_end(rchan) ((rchan)->scheme.locking.write_buf_end)
-#define read_buf_end(rchan) ((rchan)->scheme.locking.read_buf_end)
-#define cur_write_pos(rchan) ((rchan)->scheme.locking.current_write_pos)
-#define read_limit(rchan) ((rchan)->scheme.locking.read_limit)
-#define write_limit(rchan) ((rchan)->scheme.locking.write_limit)
-#define in_progress_event_pos(rchan) ((rchan)->scheme.locking.in_progress_event_pos)
-#define in_progress_event_size(rchan) ((rchan)->scheme.locking.in_progress_event_size)
-#define interrupted_pos(rchan) ((rchan)->scheme.locking.interrupted_pos)
-#define interrupting_size(rchan) ((rchan)->scheme.locking.interrupting_size)
-#define channel_lock(rchan) ((rchan)->scheme.locking.lock)