Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sqe.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2022 Intel Corporation
3 * SPDX-FileCopyrightText: Copyright (c) 2026 Infineon Technologies AG,
4 * SPDX-FileCopyrightText: or an affiliate of Infineon Technologies AG. All rights reserved.
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
14
15
16#ifndef ZEPHYR_INCLUDE_RTIO_SQE_H_
17#define ZEPHYR_INCLUDE_RTIO_SQE_H_
18
19#include <stdint.h>
20#include <string.h>
21#include <zephyr/kernel.h>
22#include <zephyr/sys/atomic.h>
24#include <zephyr/sys/util.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34
47
51#define RTIO_PRIO_LOW 0U
52
56#define RTIO_PRIO_NORM 127U
57
61#define RTIO_PRIO_HIGH 255U
62
66
67
74
82#define RTIO_SQE_CHAINED BIT(0)
83
100#define RTIO_SQE_TRANSACTION BIT(1)
101
102
112#define RTIO_SQE_MEMPOOL_BUFFER BIT(2)
113
123#define RTIO_SQE_CANCELED BIT(3) __DEPRECATED_MACRO
124
131#define RTIO_SQE_MULTISHOT BIT(4)
132
139#define RTIO_SQE_NO_RESPONSE BIT(5)
140
144
145
152
154#define RTIO_OP_NOP 0
155
157#define RTIO_OP_RX (RTIO_OP_NOP+1)
158
160#define RTIO_OP_TX (RTIO_OP_RX+1)
161
163#define RTIO_OP_TINY_TX (RTIO_OP_TX+1)
164
166#define RTIO_OP_CALLBACK (RTIO_OP_TINY_TX+1)
167
169#define RTIO_OP_TXRX (RTIO_OP_CALLBACK+1)
170
172#define RTIO_OP_DELAY (RTIO_OP_TXRX+1)
173
175#define RTIO_OP_I2C_RECOVER (RTIO_OP_DELAY+1)
176
178#define RTIO_OP_I2C_CONFIGURE (RTIO_OP_I2C_RECOVER+1)
179
181#define RTIO_OP_I3C_RECOVER (RTIO_OP_I2C_CONFIGURE+1)
182
184#define RTIO_OP_I3C_CONFIGURE (RTIO_OP_I3C_RECOVER+1)
185
187#define RTIO_OP_I3C_CCC (RTIO_OP_I3C_CONFIGURE+1)
188
190#define RTIO_OP_AWAIT (RTIO_OP_I3C_CCC+1)
191
195
196
203
207#define RTIO_IODEV_I2C_STOP BIT(1)
208
212#define RTIO_IODEV_I2C_RESTART BIT(2)
213
217#define RTIO_IODEV_I2C_10_BITS BIT(3)
218
222
229
233#define RTIO_IODEV_I3C_STOP BIT(1)
234
238#define RTIO_IODEV_I3C_RESTART BIT(2)
239
243#define RTIO_IODEV_I3C_HDR BIT(3)
244
248#define RTIO_IODEV_I3C_NBCH BIT(4)
249
253#define RTIO_IODEV_I3C_NOACK_EXPECTED BIT(5)
254
258#define RTIO_IODEV_I3C_HDR_MODE_MASK GENMASK(15, 8)
259
263#define RTIO_IODEV_I3C_HDR_MODE_SET(flags) \
264 FIELD_PREP(RTIO_IODEV_I3C_HDR_MODE_MASK, flags)
265
269#define RTIO_IODEV_I3C_HDR_MODE_GET(flags) \
270 FIELD_GET(RTIO_IODEV_I3C_HDR_MODE_MASK, flags)
271
275#define RTIO_IODEV_I3C_HDR_CMD_CODE_MASK GENMASK(22, 16)
276
280#define RTIO_IODEV_I3C_HDR_CMD_CODE_SET(flags) \
281 FIELD_PREP(RTIO_IODEV_I3C_HDR_CMD_CODE_MASK, flags)
282
286#define RTIO_IODEV_I3C_HDR_CMD_CODE_GET(flags) \
287 FIELD_GET(RTIO_IODEV_I3C_HDR_CMD_CODE_MASK, flags)
288
292
293
295struct rtio_sqe;
296struct rtio_iodev_sqe;
297struct rtio_iodev;
298struct rtio;
300
309typedef void (*rtio_callback_t)(struct rtio *r, const struct rtio_sqe *sqe, int res, void *arg0);
310
317typedef void (*rtio_signaled_t)(struct rtio_iodev_sqe *iodev_sqe, void *userdata);
318
332
341#define RTIO_SQE_HANDLE_INVALID ((rtio_sqe_handle_t)UINT32_MAX)
342
346struct rtio_sqe {
348
350
352
354
355 const struct rtio_iodev *iodev;
356
364 void *userdata;
365
367 union {
368
370 struct {
372 const uint8_t *buf;
373 } tx;
374
376 struct {
377 uint32_t buf_len;
379 } rx;
380
382 struct {
385 } tiny_tx;
386
388 struct {
390 void *arg0;
391 } callback;
392
394 struct {
395 uint32_t buf_len;
398 } txrx;
399
400#ifdef CONFIG_RTIO_OP_DELAY
402 struct {
403 k_timeout_t timeout;
404 } delay;
405#endif
406
409
411 struct {
412 /* enum i3c_config_type type; */
413 int type;
414 void *config;
415 } i3c_config;
416
418 /* struct i3c_ccc_payload *ccc_payload; */
420 };
421};
422
423
434#define RTIO_SQE_GEN_MASK GENMASK(15, 0)
436#define RTIO_SQE_ALLOCD BIT(16)
438#define RTIO_SQE_STATUS_CANCELED BIT(17)
440
448{
449 return (uint16_t)(handle >> 16);
450}
451
459{
460 return (uint16_t)(handle & RTIO_SQE_GEN_MASK);
461}
462
470 struct rtio_sqe sqe;
472 struct mpsc_node q;
476 struct rtio *r;
477
480
487 union {
489 struct {
492 } rx_bind;
493
495 struct {
498 void *userdata;
499 } await;
500
501#ifdef CONFIG_RTIO_OP_DELAY
503 k_timepoint_t delay_expiry;
504#endif
505 } rt;
506};
507
508
510/* Ensure the rtio_iodev_sqe never grows beyond a common cacheline size of 64 bytes */
511#if CONFIG_RTIO_SQE_CACHELINE_CHECK
512#ifdef CONFIG_DCACHE_LINE_SIZE
513#define RTIO_CACHE_LINE_SIZE CONFIG_DCACHE_LINE_SIZE
514#else
515#define RTIO_CACHE_LINE_SIZE 64
516#endif
517BUILD_ASSERT(sizeof(struct rtio_iodev_sqe) <= RTIO_CACHE_LINE_SIZE,
518 "RTIO performs best when the submissions queue entries are less than a cache line");
519#endif
521
525static inline void rtio_sqe_prep_nop(struct rtio_sqe *sqe,
526 const struct rtio_iodev *iodev,
527 void *userdata)
528{
529 memset(sqe, 0, sizeof(struct rtio_sqe));
530 sqe->op = RTIO_OP_NOP;
531 sqe->iodev = iodev;
532 sqe->userdata = userdata;
533}
534
535
540static inline void _rtio_sqe_prep_read(struct rtio_sqe *sqe,
541 const struct rtio_iodev *iodev,
542 int8_t prio,
543 uint8_t *buf,
544 uint32_t len,
545 void *userdata)
546{
547 memset(sqe, 0, sizeof(struct rtio_sqe));
548 sqe->op = RTIO_OP_RX;
549 sqe->prio = prio;
550 sqe->iodev = iodev;
551 sqe->rx.buf_len = len;
552 sqe->rx.buf = buf;
553 sqe->userdata = userdata;
554}
556
560static inline void rtio_sqe_prep_read(struct rtio_sqe *sqe,
561 const struct rtio_iodev *iodev,
562 int8_t prio,
563 uint8_t *buf,
564 uint32_t len,
565 void *userdata)
566{
567 __ASSERT_NO_MSG(len > 0 && buf != NULL);
568
569 _rtio_sqe_prep_read(sqe, iodev, prio, buf, len, userdata);
570}
571
577static inline void rtio_sqe_prep_read_with_pool(struct rtio_sqe *sqe,
578 const struct rtio_iodev *iodev, int8_t prio,
579 void *userdata)
580{
581 _rtio_sqe_prep_read(sqe, iodev, prio, NULL, 0, userdata);
583}
584
592static inline void rtio_sqe_prep_read_multishot(struct rtio_sqe *sqe,
593 const struct rtio_iodev *iodev, int8_t prio,
594 void *userdata)
595{
596 rtio_sqe_prep_read_with_pool(sqe, iodev, prio, userdata);
598}
599
603static inline void rtio_sqe_prep_write(struct rtio_sqe *sqe,
604 const struct rtio_iodev *iodev,
605 int8_t prio,
606 const uint8_t *buf,
607 uint32_t len,
608 void *userdata)
609{
610 __ASSERT_NO_MSG(len > 0 && buf != NULL);
611
612 memset(sqe, 0, sizeof(struct rtio_sqe));
613 sqe->op = RTIO_OP_TX;
614 sqe->prio = prio;
615 sqe->iodev = iodev;
616 sqe->tx.buf_len = len;
617 sqe->tx.buf = buf;
618 sqe->userdata = userdata;
619}
620
631static inline void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe,
632 const struct rtio_iodev *iodev,
633 int8_t prio,
634 const uint8_t *tiny_write_data,
635 uint8_t tiny_write_len,
636 void *userdata)
637{
638 __ASSERT_NO_MSG(tiny_write_len <= sizeof(sqe->tiny_tx.buf));
639 __ASSERT_NO_MSG(tiny_write_len > 0 && tiny_write_data != NULL);
640
641 memset(sqe, 0, sizeof(struct rtio_sqe));
642 sqe->op = RTIO_OP_TINY_TX;
643 sqe->prio = prio;
644 sqe->iodev = iodev;
645 sqe->tiny_tx.buf_len = tiny_write_len;
646 memcpy(sqe->tiny_tx.buf, tiny_write_data, tiny_write_len);
647 sqe->userdata = userdata;
648}
649
658static inline void rtio_sqe_prep_callback(struct rtio_sqe *sqe,
659 rtio_callback_t callback,
660 void *arg0,
661 void *userdata)
662{
663 memset(sqe, 0, sizeof(struct rtio_sqe));
664 sqe->op = RTIO_OP_CALLBACK;
665 sqe->prio = 0;
666 sqe->iodev = NULL;
667 sqe->callback.callback = callback;
668 sqe->callback.arg0 = arg0;
669 sqe->userdata = userdata;
670}
671
682static inline void rtio_sqe_prep_callback_no_cqe(struct rtio_sqe *sqe,
683 rtio_callback_t callback,
684 void *arg0,
685 void *userdata)
686{
687 rtio_sqe_prep_callback(sqe, callback, arg0, userdata);
689}
690
694static inline void rtio_sqe_prep_transceive(struct rtio_sqe *sqe,
695 const struct rtio_iodev *iodev,
696 int8_t prio,
697 const uint8_t *tx_buf,
698 uint8_t *rx_buf,
699 uint32_t buf_len,
700 void *userdata)
701{
702 __ASSERT_NO_MSG(buf_len > 0 && tx_buf != NULL && rx_buf != NULL);
703
704 memset(sqe, 0, sizeof(struct rtio_sqe));
705 sqe->op = RTIO_OP_TXRX;
706 sqe->prio = prio;
707 sqe->iodev = iodev;
708 sqe->txrx.buf_len = buf_len;
709 sqe->txrx.tx_buf = tx_buf;
710 sqe->txrx.rx_buf = rx_buf;
711 sqe->userdata = userdata;
712}
713
728static inline void rtio_sqe_prep_await(struct rtio_sqe *sqe,
729 const struct rtio_iodev *iodev,
730 int8_t prio,
731 void *userdata)
732{
733 memset(sqe, 0, sizeof(struct rtio_sqe));
734 sqe->op = RTIO_OP_AWAIT;
735 sqe->prio = prio;
736 sqe->iodev = iodev;
737 sqe->userdata = userdata;
738}
739
751static inline void rtio_sqe_prep_await_iodev(struct rtio_sqe *sqe, const struct rtio_iodev *iodev,
752 int8_t prio, void *userdata)
753{
754 __ASSERT_NO_MSG(iodev != NULL);
755 rtio_sqe_prep_await(sqe, iodev, prio, userdata);
756}
757
768static inline void rtio_sqe_prep_await_executor(struct rtio_sqe *sqe, int8_t prio, void *userdata)
769{
770 rtio_sqe_prep_await(sqe, NULL, prio, userdata);
771}
772
784#ifdef CONFIG_RTIO_OP_DELAY
791extern struct rtio_iodev rtio_timeout_iodev;
792
793static inline void rtio_sqe_prep_delay(struct rtio_sqe *sqe,
794 k_timeout_t timeout,
795 void *userdata)
796{
797 memset(sqe, 0, sizeof(struct rtio_sqe));
798 sqe->op = RTIO_OP_DELAY;
799 sqe->prio = 0;
800 sqe->iodev = &rtio_timeout_iodev;
801 sqe->delay.timeout = timeout;
802 sqe->userdata = userdata;
803}
804#else
805#define rtio_sqe_prep_delay(sqe, timeout, userdata) \
806 BUILD_ASSERT(false, "CONFIG_RTIO_OP_DELAY not enabled")
807#endif
808
810static inline void rtio_sqe_prep_i2c_configure(struct rtio_sqe *sqe,
811 const struct rtio_iodev *iodev,
812 int8_t prio,
813 uint32_t dev_config,
814 void *userdata)
815{
816 memset(sqe, 0, sizeof(struct rtio_sqe));
818 sqe->prio = prio;
819 sqe->iodev = iodev;
820 sqe->i2c_config = dev_config;
821 sqe->userdata = userdata;
822}
823
825static inline void rtio_sqe_prep_i2c_recover(struct rtio_sqe *sqe,
826 const struct rtio_iodev *iodev,
827 int8_t prio,
828 void *userdata)
829{
830 memset(sqe, 0, sizeof(struct rtio_sqe));
831 sqe->op = RTIO_OP_I2C_RECOVER;
832 sqe->prio = prio;
833 sqe->iodev = iodev;
834 sqe->userdata = userdata;
835}
836
845static inline struct rtio_iodev_sqe *rtio_txn_next(const struct rtio_iodev_sqe *iodev_sqe)
846{
847 struct rtio_iodev_sqe *next = NULL;
848
849 SYS_PORT_TRACING_FUNC_ENTER(rtio, txn_next, iodev_sqe->r, iodev_sqe);
850 if (iodev_sqe->sqe.flags & RTIO_SQE_TRANSACTION) {
851 next = iodev_sqe->next;
852 }
853 SYS_PORT_TRACING_FUNC_EXIT(rtio, txn_next, iodev_sqe->r, next);
854 return next;
855}
856
857
866static inline struct rtio_iodev_sqe *rtio_chain_next(const struct rtio_iodev_sqe *iodev_sqe)
867{
868 struct rtio_iodev_sqe *next = NULL;
869
870 SYS_PORT_TRACING_FUNC_ENTER(rtio, txn_next, iodev_sqe->r, iodev_sqe);
871 if (iodev_sqe->sqe.flags & RTIO_SQE_CHAINED) {
872 next = iodev_sqe->next;
873 }
874 SYS_PORT_TRACING_FUNC_EXIT(rtio, txn_next, iodev_sqe->r, next);
875 return next;
876}
877
886static inline struct rtio_iodev_sqe *rtio_iodev_sqe_next(const struct rtio_iodev_sqe *iodev_sqe)
887{
888 return iodev_sqe->next;
889}
890
904static inline bool rtio_iodev_sqe_is_canceled(const struct rtio_iodev_sqe *iodev_sqe)
905{
906 return (atomic_get(&iodev_sqe->status) & RTIO_SQE_STATUS_CANCELED) != 0;
907}
908
917static inline void rtio_iodev_sqe_set_canceled(struct rtio_iodev_sqe *iodev_sqe)
918{
920}
921
932static inline void rtio_iodev_sqe_await_signal(struct rtio_iodev_sqe *iodev_sqe,
934 void *userdata)
935{
936 iodev_sqe->rt.await.callback = callback;
937 iodev_sqe->rt.await.userdata = userdata;
938
939 if (!atomic_cas(&iodev_sqe->rt.await.ok, 0, 1)) {
940 callback(iodev_sqe, userdata);
941 }
942}
943
944/* Private structures and functions used for the pool of sqe structures */
946
947struct rtio_sqe_pool {
948 struct mpsc free_q;
949 const uint16_t pool_size;
950 uint16_t pool_free;
951 struct rtio_iodev_sqe *pool;
952};
953
954static inline struct rtio_iodev_sqe *rtio_sqe_pool_alloc(struct rtio_sqe_pool *pool)
955{
956 struct mpsc_node *node = mpsc_pop(&pool->free_q);
957
958 if (node == NULL) {
959 return NULL;
960 }
961
962 struct rtio_iodev_sqe *iodev_sqe = CONTAINER_OF(node, struct rtio_iodev_sqe, q);
963
964 /* Reset the runtime scratch so per-op state (await ok, mempool binding)
965 * starts clean for this allocation.
966 */
967 memset(&iodev_sqe->rt, 0, sizeof(iodev_sqe->rt));
968
969 /* The chain link is only valid once the executor links the entry at
970 * submit time; clear it so a cancel before then does not walk the
971 * previous occupant's chain.
972 */
973 iodev_sqe->next = NULL;
974
975 /* Mark the slot live. The generation persists from the previous free so a
976 * handle captured against the prior occupant no longer matches.
977 */
978 atomic_or(&iodev_sqe->status, RTIO_SQE_ALLOCD);
979
980 pool->pool_free--;
981
982 return iodev_sqe;
983}
984
985static inline void rtio_sqe_pool_free(struct rtio_sqe_pool *pool, struct rtio_iodev_sqe *iodev_sqe)
986{
987 /* Bump the generation and clear ALLOCD so any outstanding handle to this
988 * slot is rejected by rtio_iodev_sqe_from_handle() once it is recycled.
989 */
990 atomic_val_t gen = (atomic_get(&iodev_sqe->status) + 1) & RTIO_SQE_GEN_MASK;
991
992 atomic_set(&iodev_sqe->status, gen);
993
994 mpsc_push(&pool->free_q, &iodev_sqe->q);
995
996 pool->pool_free++;
997}
998
999#if CONFIG_RTIO_SQE_PLACEMENT_DTCM
1000#define RTIO_SQE_MEM Z_GENERIC_SECTION(".dtcm_bss") static
1001#elif defined(CONFIG_RTIO_SQE_PLACEMENT_NOCACHE)
1002#define RTIO_SQE_MEM __nocache static
1003#else
1004#define RTIO_SQE_MEM static
1005#endif
1006
1007/* Do not try and reformat the macros */
1008/* clang-format off */
1009
1010#define Z_RTIO_SQE_POOL_DEFINE(name, sz) \
1011 RTIO_SQE_MEM struct rtio_iodev_sqe CONCAT(_sqe_pool_, name)[sz]; \
1012 STRUCT_SECTION_ITERABLE(rtio_sqe_pool, name) = { \
1013 .free_q = MPSC_INIT((name.free_q)), \
1014 .pool_size = sz, \
1015 .pool_free = sz, \
1016 .pool = CONCAT(_sqe_pool_, name), \
1017 }
1018
1019/* clang-format on */
1021
1025
1026#ifdef __cplusplus
1027}
1028#endif
1029
1030#endif /* ZEPHYR_INCLUDE_RTIO_SQE_H_ */
Header file for the Atomic operations API.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
Atomic bitwise inclusive OR.
atomic_t atomic_val_t
Value type for atomic integer variables.
Definition atomic_types.h:41
atomic_val_t atomic_get(const atomic_t *target)
Atomic get.
atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
Atomic get-and-set.
_Bool atomic_cas(atomic_t *target, atomic_val_t old_value, atomic_val_t new_value)
Atomic compare-and-set.
static ALWAYS_INLINE void mpsc_push(struct mpsc *q, struct mpsc_node *n)
Push a node.
Definition mpsc_lockfree.h:126
static struct mpsc_node * mpsc_pop(struct mpsc *q)
Pop a node off of the list.
Definition mpsc_lockfree.h:145
#define RTIO_OP_CALLBACK
An operation that calls a given function (callback).
Definition sqe.h:166
#define RTIO_OP_I2C_RECOVER
An operation to recover I2C buses.
Definition sqe.h:175
#define RTIO_OP_TINY_TX
An operation that transmits tiny writes by copying the data to write.
Definition sqe.h:163
#define RTIO_OP_TX
An operation that transmits (writes).
Definition sqe.h:160
#define RTIO_OP_TXRX
An operation that transceives (reads and writes simultaneously).
Definition sqe.h:169
#define RTIO_OP_NOP
An operation that does nothing and will complete immediately.
Definition sqe.h:154
#define RTIO_OP_AWAIT
An operation to await a signal while blocking the iodev (if one is provided).
Definition sqe.h:190
#define RTIO_OP_I2C_CONFIGURE
An operation to configure I2C buses.
Definition sqe.h:178
#define RTIO_OP_DELAY
An operation that takes a specified amount of time (asynchronously) before completing.
Definition sqe.h:172
#define RTIO_OP_RX
An operation that receives (reads).
Definition sqe.h:157
#define RTIO_SQE_MULTISHOT
The SQE should continue producing CQEs until canceled.
Definition sqe.h:131
#define RTIO_SQE_TRANSACTION
The next request in the queue is part of a transaction.
Definition sqe.h:100
#define RTIO_SQE_MEMPOOL_BUFFER
The buffer should be allocated by the RTIO mempool.
Definition sqe.h:112
#define RTIO_SQE_NO_RESPONSE
The SQE does not produce a CQE.
Definition sqe.h:139
#define RTIO_SQE_CHAINED
The next request in the queue should wait on this one.
Definition sqe.h:82
static void rtio_sqe_prep_read_with_pool(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Prepare a read op submission with context's mempool.
Definition sqe.h:577
static void rtio_sqe_prep_i2c_recover(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Prepare an i2c recover op submission.
Definition sqe.h:825
static void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, const uint8_t *tiny_write_data, uint8_t tiny_write_len, void *userdata)
Prepare a tiny write op submission.
Definition sqe.h:631
#define RTIO_SQE_ALLOCD
Set while the entry is allocated from the pool (i.e.
Definition sqe.h:436
static void rtio_sqe_prep_nop(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, void *userdata)
Prepare a nop (no op) submission.
Definition sqe.h:525
void(* rtio_callback_t)(struct rtio *r, const struct rtio_sqe *sqe, int res, void *arg0)
Callback signature for RTIO_OP_CALLBACK.
Definition sqe.h:309
static void rtio_sqe_prep_await_iodev(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Prepare an await op submission which blocks an rtio_iodev until completion.
Definition sqe.h:751
#define RTIO_SQE_GEN_MASK
Generation counter; bumped on free, compared against a handle's generation.
Definition sqe.h:434
static void rtio_iodev_sqe_await_signal(struct rtio_iodev_sqe *iodev_sqe, rtio_signaled_t callback, void *userdata)
Await an AWAIT SQE signal from RTIO IODEV.
Definition sqe.h:932
static void rtio_sqe_prep_write(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, const uint8_t *buf, uint32_t len, void *userdata)
Prepare a write op submission.
Definition sqe.h:603
uint32_t rtio_sqe_handle_t
Opaque identity for a submission queue entry.
Definition sqe.h:331
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.
Definition sqe.h:560
static uint16_t rtio_sqe_handle_generation(rtio_sqe_handle_t handle)
Generation counter encoded in a handle.
Definition sqe.h:458
static bool rtio_iodev_sqe_is_canceled(const struct rtio_iodev_sqe *iodev_sqe)
Check whether cancellation of a submission has been requested.
Definition sqe.h:904
static void rtio_sqe_prep_read_multishot(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Prepare a multishot read op submission with context's mempool.
Definition sqe.h:592
static void rtio_sqe_prep_callback(struct rtio_sqe *sqe, rtio_callback_t callback, void *arg0, void *userdata)
Prepare a callback op submission.
Definition sqe.h:658
#define RTIO_SQE_STATUS_CANCELED
Set when cancellation of the submission has been requested.
Definition sqe.h:438
static void rtio_sqe_prep_await_executor(struct rtio_sqe *sqe, int8_t prio, void *userdata)
Prepare an await op submission which completes the sqe after being signaled.
Definition sqe.h:768
static uint16_t rtio_sqe_handle_index(rtio_sqe_handle_t handle)
Pool block index encoded in a handle.
Definition sqe.h:447
void(* rtio_signaled_t)(struct rtio_iodev_sqe *iodev_sqe, void *userdata)
Callback signature for RTIO_OP_AWAIT signaled.
Definition sqe.h:317
static void rtio_sqe_prep_transceive(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, const uint8_t *tx_buf, uint8_t *rx_buf, uint32_t buf_len, void *userdata)
Prepare a transceive op submission.
Definition sqe.h:694
static void rtio_sqe_prep_i2c_configure(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, uint32_t dev_config, void *userdata)
Prepare an i2c configure op submission.
Definition sqe.h:810
#define rtio_sqe_prep_delay(sqe, timeout, userdata)
Prepare a delay operation submission which completes after the given timeout.
Definition sqe.h:805
static struct rtio_iodev_sqe * rtio_chain_next(const struct rtio_iodev_sqe *iodev_sqe)
Get the next sqe in the chain.
Definition sqe.h:866
static void rtio_iodev_sqe_set_canceled(struct rtio_iodev_sqe *iodev_sqe)
Mark a submission canceled.
Definition sqe.h:917
static struct rtio_iodev_sqe * rtio_iodev_sqe_next(const struct rtio_iodev_sqe *iodev_sqe)
Get the next sqe in the chain or transaction.
Definition sqe.h:886
static void rtio_sqe_prep_callback_no_cqe(struct rtio_sqe *sqe, rtio_callback_t callback, void *arg0, void *userdata)
Prepare a callback op submission that does not create a CQE.
Definition sqe.h:682
static struct rtio_iodev_sqe * rtio_txn_next(const struct rtio_iodev_sqe *iodev_sqe)
Get the next sqe in the transaction.
Definition sqe.h:845
static void rtio_sqe_prep_await(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Prepare an await op submission.
Definition sqe.h:728
#define SYS_PORT_TRACING_FUNC_ENTER(type, func,...)
Tracing macro for the entry into a function that might or might not return a value.
Definition tracing_macros.h:246
#define SYS_PORT_TRACING_FUNC_EXIT(type, func,...)
Tracing macro for when a function ends its execution.
Definition tracing_macros.h:272
#define CONTAINER_OF(ptr, type, field)
Get a pointer to a structure containing the element.
Definition util.h:281
Public kernel APIs.
A wait-free intrusive multi producer single consumer (MPSC) queue using a singly linked list.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT8_TYPE__ int8_t
Definition stdint.h:72
void * memset(void *buf, int c, size_t n)
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
Kernel timeout type.
Definition clock.h:65
Kernel timepoint type.
Definition clock.h:289
Queue member.
Definition mpsc_lockfree.h:79
IO device submission queue entry.
Definition sqe.h:468
struct rtio_iodev_sqe * next
Next entry in a chained or transactional sequence, NULL if none.
Definition sqe.h:474
struct rtio_sqe sqe
The submission queue entry this wraps.
Definition sqe.h:470
uint8_t * buf
Buffer allocated for the read.
Definition sqe.h:490
struct rtio * r
RTIO context that owns this entry.
Definition sqe.h:476
atomic_t ok
Set once the awaited signal arrives.
Definition sqe.h:496
void * userdata
Opaque pointer passed to the callback.
Definition sqe.h:498
uint32_t buf_len
Length of the allocated buffer.
Definition sqe.h:491
atomic_t status
Identity + lifetime word (generation | ALLOCD), see RTIO_SQE_* bits above.
Definition sqe.h:479
struct rtio_iodev_sqe::@236333123355174166163204241333175337261032350217::@173144226234072317163120356060015135125010037312 await
OP_AWAIT signaling state.
struct mpsc_node q
Node used to link the entry into the pool free list and iodev queues.
Definition sqe.h:472
union rtio_iodev_sqe::@236333123355174166163204241333175337261032350217 rt
Runtime scratch state that the subsystem/driver mutates while it owns the submission.
rtio_signaled_t callback
Invoked when the entry is signaled.
Definition sqe.h:497
An IO device with a function table for submitting requests.
Definition iodev.h:83
A submission queue event.
Definition sqe.h:346
uint32_t i2c_config
OP_I2C_CONFIGURE.
Definition sqe.h:408
void * userdata
User provided data which is returned upon operation completion.
Definition sqe.h:364
const uint8_t * tx_buf
Buffer to write from.
Definition sqe.h:396
uint8_t op
Op code.
Definition sqe.h:347
struct rtio_sqe::@126267262255374054123217063150244034155174062054::@222067021034074304061254367152327164076222165070 rx
OP_RX.
struct rtio_sqe::@126267262255374054123217063150244034155174062054::@036347012270137154075057170156115300365157200061 tiny_tx
OP_TINY_TX.
void * arg0
Last argument given to callback.
Definition sqe.h:390
uint8_t * rx_buf
Buffer to read into.
Definition sqe.h:397
uint8_t prio
Op priority.
Definition sqe.h:349
uint32_t buf_len
Length of buffer.
Definition sqe.h:371
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:355
uint32_t iodev_flags
Op iodev flags.
Definition sqe.h:353
void * ccc_payload
OP_I3C_CCC.
Definition sqe.h:419
struct rtio_sqe::@126267262255374054123217063150244034155174062054::@366052340324346171254040100167341103343101366005 txrx
OP_TXRX.
int type
Configuration type, an enum i3c_config_type value.
Definition sqe.h:413
uint16_t flags
Op Flags.
Definition sqe.h:351
const uint8_t * buf
Buffer to write from.
Definition sqe.h:372
void * config
Configuration to apply.
Definition sqe.h:414
struct rtio_sqe::@126267262255374054123217063150244034155174062054::@344335000264002157174077227357232142206143107046 tx
OP_TX.
rtio_callback_t callback
Function to run.
Definition sqe.h:389
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:85
Misc utilities.