Zephyr Project API
3.3.0
A Scalable Open Source RTOS
|
RTIO API. More...
Modules | |
RTIO Priorities | |
RTIO Predefined Priorties. | |
RTIO SQE Flags | |
RTIO SQE Flags. | |
Data Structures | |
struct | rtio_sqe |
A submission queue event. More... | |
struct | rtio_sq |
Submission queue. More... | |
struct | rtio_cqe |
A completion queue event. More... | |
struct | rtio_cq |
Completion queue. More... | |
struct | rtio_executor_api |
struct | rtio_executor |
An executor does the work of executing the submissions. More... | |
struct | rtio |
An RTIO queue pair that both the kernel and application work with. More... | |
struct | rtio_iodev_api |
API that an RTIO IO device should implement. More... | |
struct | rtio_iodev_sqe |
struct | rtio_iodev_sq |
IO device submission queue. More... | |
struct | rtio_iodev |
An IO device with a function table for submitting requests. More... | |
Macros | |
#define | RTIO_OP_NOP 0 |
#define | RTIO_OP_RX 1 |
#define | RTIO_OP_TX 2 |
#define | RTIO_SQ_DEFINE(name, len) RTIO_SPSC_DEFINE(name, struct rtio_sqe, len) |
Statically define and initialize a fixed length submission queue. More... | |
#define | RTIO_CQ_DEFINE(name, len) RTIO_SPSC_DEFINE(name, struct rtio_cqe, len) |
Statically define and initialize a fixed length completion queue. More... | |
#define | RTIO_IODEV_SQ_DEFINE(name, len) RTIO_SPSC_DEFINE(name, struct rtio_iodev_sqe, len) |
Statically define and initialize a fixed length iodev submission queue. More... | |
#define | RTIO_IODEV_DEFINE(name, iodev_api, qsize, iodev_data) |
Statically define and initialize an RTIO IODev. More... | |
#define | RTIO_DEFINE(name, exec, sq_sz, cq_sz) |
Statically define and initialize an RTIO context. More... | |
Functions | |
static void | rtio_sqe_prep_nop (struct rtio_sqe *sqe, const struct rtio_iodev *iodev, void *userdata) |
Prepare a nop (no op) submission. More... | |
static void | rtio_sqe_prep_read (struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, uint8_t *buf, uint32_t len, void *userdata) |
Prepare a read op submission. More... | |
static void | rtio_sqe_prep_write (struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, uint8_t *buf, uint32_t len, void *userdata) |
Prepare a write op submission. More... | |
static void | rtio_set_executor (struct rtio *r, struct rtio_executor *exc) |
Set the executor of the rtio context. More... | |
static void | rtio_iodev_submit (const struct rtio_sqe *sqe, struct rtio *r) |
Perform a submitted operation with an iodev. More... | |
static uint32_t | rtio_sqe_acquirable (struct rtio *r) |
Count of acquirable submission queue events. More... | |
static struct rtio_sqe * | rtio_sqe_acquire (struct rtio *r) |
Acquire a single submission queue event if available. More... | |
static void | rtio_sqe_produce_all (struct rtio *r) |
Produce all previously acquired sqe. More... | |
static void | rtio_sqe_drop_all (struct rtio *r) |
Drop all previously acquired sqe. More... | |
static struct rtio_cqe * | rtio_cqe_consume (struct rtio *r) |
Consume a single completion queue event if available. More... | |
static struct rtio_cqe * | rtio_cqe_consume_block (struct rtio *r) |
Wait for and consume a single completion queue event. More... | |
static void | rtio_cqe_release_all (struct rtio *r) |
Release all consumed completion queue events. More... | |
static void | rtio_sqe_ok (struct rtio *r, const struct rtio_sqe *sqe, int result) |
Inform the executor of a submission completion with success. More... | |
static void | rtio_sqe_err (struct rtio *r, const struct rtio_sqe *sqe, int result) |
Inform the executor of a submissions completion with error. More... | |
static void | rtio_cqe_submit (struct rtio *r, int result, void *userdata) |
static void | rtio_access_grant (struct rtio *r, struct k_thread *t) |
int | rtio_sqe_copy_in (struct rtio *r, const struct rtio_sqe *sqes, size_t sqe_count) |
Copy an array of SQEs into the queue. More... | |
int | rtio_cqe_copy_out (struct rtio *r, struct rtio_cqe *cqes, size_t cqe_count, k_timeout_t timeout) |
Copy an array of CQEs from the queue. More... | |
int | rtio_submit (struct rtio *r, uint32_t wait_count) |
Submit I/O requests to the underlying executor. More... | |
RTIO API.
#define RTIO_CQ_DEFINE | ( | name, | |
len | |||
) | RTIO_SPSC_DEFINE(name, struct rtio_cqe, len) |
#include <include/zephyr/rtio/rtio.h>
Statically define and initialize a fixed length completion queue.
name | Name of the completion queue. |
len | Queue length, power of 2 required (2, 4, 8). |
#define RTIO_DEFINE | ( | name, | |
exec, | |||
sq_sz, | |||
cq_sz | |||
) |
#include <include/zephyr/rtio/rtio.h>
Statically define and initialize an RTIO context.
name | Name of the RTIO |
exec | Symbol for rtio_executor (pointer) |
sq_sz | Size of the submission queue, must be power of 2 |
cq_sz | Size of the completion queue, must be power of 2 |
#define RTIO_IODEV_DEFINE | ( | name, | |
iodev_api, | |||
qsize, | |||
iodev_data | |||
) |
#include <include/zephyr/rtio/rtio.h>
Statically define and initialize an RTIO IODev.
name | Name of the iodev |
iodev_api | Pointer to struct rtio_iodev_api |
qsize | Size of the submission queue, must be power of 2 |
iodev_data | Data pointer |
#define RTIO_IODEV_SQ_DEFINE | ( | name, | |
len | |||
) | RTIO_SPSC_DEFINE(name, struct rtio_iodev_sqe, len) |
#include <include/zephyr/rtio/rtio.h>
Statically define and initialize a fixed length iodev submission queue.
name | Name of the queue. |
len | Queue length, power of 2 required |
#define RTIO_OP_NOP 0 |
#include <include/zephyr/rtio/rtio.h>
An operation that does nothing and will complete immediately
#define RTIO_OP_RX 1 |
#include <include/zephyr/rtio/rtio.h>
An operation that receives (reads)
#define RTIO_OP_TX 2 |
#include <include/zephyr/rtio/rtio.h>
An operation that transmits (writes)
#define RTIO_SQ_DEFINE | ( | name, | |
len | |||
) | RTIO_SPSC_DEFINE(name, struct rtio_sqe, len) |
#include <include/zephyr/rtio/rtio.h>
Statically define and initialize a fixed length submission queue.
name | Name of the submission queue. |
len | Queue length, power of 2 required (2, 4, 8). |
#include <include/zephyr/rtio/rtio.h>
Grant access to an RTIO context to a user thread
#include <include/zephyr/rtio/rtio.h>
Consume a single completion queue event if available.
If a completion queue event is returned rtio_cq_release(r) must be called at some point to release the cqe spot for the cqe producer.
r | RTIO context |
cqe | A valid completion queue event consumed from the completion queue |
NULL | No completion queue event available |
#include <include/zephyr/rtio/rtio.h>
Wait for and consume a single completion queue event.
If a completion queue event is returned rtio_cq_release(r) must be called at some point to release the cqe spot for the cqe producer.
r | RTIO context |
cqe | A valid completion queue event consumed from the completion queue |
int rtio_cqe_copy_out | ( | struct rtio * | r, |
struct rtio_cqe * | cqes, | ||
size_t | cqe_count, | ||
k_timeout_t | timeout | ||
) |
#include <include/zephyr/rtio/rtio.h>
Copy an array of CQEs from the queue.
Copies from the RTIO context and its queue completion queue events, waiting for the given time period to gather the number of completions requested.
r | RTIO context |
cqes | Pointer to an array of SQEs |
cqe_count | Count of sqes in array |
timeout | Timeout to wait for each completion event. Total wait time is potentially timeout*cqe_count at maximum. |
copy_count | Count of copied CQEs (0 to cqe_count) |
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Release all consumed completion queue events.
r | RTIO context |
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Submit a completion queue event with a given result and userdata
Called by the executor to produce a completion queue event, no inherent locking is performed and this is not safe to do from multiple callers.
r | RTIO context |
result | Integer result code (could be -errno) |
userdata | Userdata to pass along to completion |
#include <include/zephyr/rtio/rtio.h>
Perform a submitted operation with an iodev.
sqe | Submission to work on |
r | RTIO context |
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Set the executor of the rtio context.
#include <include/zephyr/rtio/rtio.h>
Count of acquirable submission queue events.
r | RTIO context |
#include <include/zephyr/rtio/rtio.h>
Acquire a single submission queue event if available.
r | RTIO context |
sqe | A valid submission queue event acquired from the submission queue |
NULL | No subsmission queue event available |
#include <include/zephyr/rtio/rtio.h>
Copy an array of SQEs into the queue.
Useful if a batch of submissions is stored in ROM or RTIO is used from user mode where a copy must be made.
Partial copying is not done as chained SQEs need to be submitted as a whole set.
r | RTIO context |
sqes | Pointer to an array of SQEs |
sqe_count | Count of sqes in array |
0 | success |
-ENOMEM | not enough room in the queue |
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Inform the executor of a submissions completion with error.
This SHALL fail the remaining submissions in the chain.
r | RTIO context |
sqe | Submission that has failed |
result | Result of the request |
#include <include/zephyr/rtio/rtio.h>
Inform the executor of a submission completion with success.
This may start the next asynchronous request if one is available.
r | RTIO context |
sqe | Submission that has succeeded |
result | Result of the request |
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Prepare a nop (no op) submission.
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Prepare a read op submission.
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Prepare a write op submission.
|
inlinestatic |
#include <include/zephyr/rtio/rtio.h>
Submit I/O requests to the underlying executor.
Submits the queue of submission queue events to the executor. The executor will do the work of managing tasks representing each submission chain, freeing submission queue events when done, and producing completion queue events as submissions are completed.
r | RTIO context |
wait_count | Number of submissions to wait for completion of. |
0 | On success |