Lines Matching +full:per +full:- +full:channel

1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
6 * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
32 * Per-cpu relay channel buffer
36 void *start; /* start of channel buffer */
37 void *data; /* start of current sub-buffer */
38 size_t offset; /* current offset into sub-buffer */
39 size_t subbufs_produced; /* count of sub-buffers produced */
40 size_t subbufs_consumed; /* count of sub-buffers consumed */
41 struct rchan *chan; /* associated channel */
44 struct dentry *dentry; /* channel file dentry */
45 struct kref kref; /* channel buffer refcount */
49 size_t *padding; /* padding counts per sub-buffer */
57 * Relay channel data structure
62 size_t subbuf_size; /* sub-buffer size */
63 size_t n_subbufs; /* number of sub-buffers per buffer */
66 struct kref kref; /* channel refcount */
67 void *private_data; /* for user-defined data */
69 struct rchan_buf * __percpu *buf; /* per-cpu channel buffers */
71 struct list_head list; /* for channel list */
78 * Relay channel client callbacks
83 * subbuf_start - called on buffer-switch to a new sub-buffer
84 * @buf: the channel buffer containing the new sub-buffer
85 * @subbuf: the start of the new sub-buffer
86 * @prev_subbuf: the start of the previous sub-buffer
87 * @prev_padding: unused space at the end of previous sub-buffer
95 * created, so that the first sub-buffer can be initialized
99 * sub-buffer by calling subbuf_start_reserve() in this callback.
107 * create_buf_file - create file to represent a relay channel buffer
111 * @buf: the channel buffer
112 * @is_global: outparam - set non-zero if the buffer should be global
114 * Called during relay_open(), once for each per-cpu buffer,
116 * represent the corresponding channel buffer. If the file is
123 * Setting the is_global outparam to a non-zero value will
125 * than the default set of per-cpu buffers.
138 * remove_buf_file - remove file representing a relay channel buffer
141 * Called during relay_close(), once for each per-cpu buffer,
143 * channel buffer.
177 * relay_write - write data into the channel
178 * @chan: relay channel
182 * Writes data into the current cpu's channel buffer.
197 buf = *this_cpu_ptr(chan->buf); in relay_write()
198 if (unlikely(buf->offset + length > chan->subbuf_size)) in relay_write()
200 memcpy(buf->data + buf->offset, data, length); in relay_write()
201 buf->offset += length; in relay_write()
206 * __relay_write - write data into the channel
207 * @chan: relay channel
211 * Writes data into the current cpu's channel buffer.
223 buf = *get_cpu_ptr(chan->buf); in __relay_write()
224 if (unlikely(buf->offset + length > buf->chan->subbuf_size)) in __relay_write()
226 memcpy(buf->data + buf->offset, data, length); in __relay_write()
227 buf->offset += length; in __relay_write()
228 put_cpu_ptr(chan->buf); in __relay_write()
232 * relay_reserve - reserve slot in channel buffer
233 * @chan: relay channel
238 * Reserves a slot in the current cpu's channel buffer.
239 * Does not protect the buffer at all - caller must provide
245 struct rchan_buf *buf = *get_cpu_ptr(chan->buf); in relay_reserve()
247 if (unlikely(buf->offset + length > buf->chan->subbuf_size)) { in relay_reserve()
252 reserved = buf->data + buf->offset; in relay_reserve()
253 buf->offset += length; in relay_reserve()
256 put_cpu_ptr(chan->buf); in relay_reserve()
261 * subbuf_start_reserve - reserve bytes at the start of a sub-buffer
262 * @buf: relay channel buffer
266 * a sub-buffer in the subbuf_start() callback.
271 BUG_ON(length >= buf->chan->subbuf_size - 1); in subbuf_start_reserve()
272 buf->offset = length; in subbuf_start_reserve()