Zephyr Project API 4.5.0-rc2
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
94#define RTIO_SQE_TRANSACTION BIT(1)
95
96
106#define RTIO_SQE_MEMPOOL_BUFFER BIT(2)
107
117#define RTIO_SQE_CANCELED BIT(3) __DEPRECATED_MACRO
118
125#define RTIO_SQE_MULTISHOT BIT(4)
126
130#define RTIO_SQE_NO_RESPONSE BIT(5)
131
135
136
143
145#define RTIO_OP_NOP 0
146
148#define RTIO_OP_RX (RTIO_OP_NOP+1)
149
151#define RTIO_OP_TX (RTIO_OP_RX+1)
152
154#define RTIO_OP_TINY_TX (RTIO_OP_TX+1)
155
157#define RTIO_OP_CALLBACK (RTIO_OP_TINY_TX+1)
158
160#define RTIO_OP_TXRX (RTIO_OP_CALLBACK+1)
161
163#define RTIO_OP_DELAY (RTIO_OP_TXRX+1)
164
166#define RTIO_OP_I2C_RECOVER (RTIO_OP_DELAY+1)
167
169#define RTIO_OP_I2C_CONFIGURE (RTIO_OP_I2C_RECOVER+1)
170
172#define RTIO_OP_I3C_RECOVER (RTIO_OP_I2C_CONFIGURE+1)
173
175#define RTIO_OP_I3C_CONFIGURE (RTIO_OP_I3C_RECOVER+1)
176
178#define RTIO_OP_I3C_CCC (RTIO_OP_I3C_CONFIGURE+1)
179
181#define RTIO_OP_AWAIT (RTIO_OP_I3C_CCC+1)
182
186
187
194
198#define RTIO_IODEV_I2C_STOP BIT(1)
199
203#define RTIO_IODEV_I2C_RESTART BIT(2)
204
208#define RTIO_IODEV_I2C_10_BITS BIT(3)
209
213
220
224#define RTIO_IODEV_I3C_STOP BIT(1)
225
229#define RTIO_IODEV_I3C_RESTART BIT(2)
230
234#define RTIO_IODEV_I3C_HDR BIT(3)
235
239#define RTIO_IODEV_I3C_NBCH BIT(4)
240
244#define RTIO_IODEV_I3C_NOACK_EXPECTED BIT(5)
245
249#define RTIO_IODEV_I3C_HDR_MODE_MASK GENMASK(15, 8)
250
254#define RTIO_IODEV_I3C_HDR_MODE_SET(flags) \
255 FIELD_PREP(RTIO_IODEV_I3C_HDR_MODE_MASK, flags)
256
260#define RTIO_IODEV_I3C_HDR_MODE_GET(flags) \
261 FIELD_GET(RTIO_IODEV_I3C_HDR_MODE_MASK, flags)
262
266#define RTIO_IODEV_I3C_HDR_CMD_CODE_MASK GENMASK(22, 16)
267
271#define RTIO_IODEV_I3C_HDR_CMD_CODE_SET(flags) \
272 FIELD_PREP(RTIO_IODEV_I3C_HDR_CMD_CODE_MASK, flags)
273
277#define RTIO_IODEV_I3C_HDR_CMD_CODE_GET(flags) \
278 FIELD_GET(RTIO_IODEV_I3C_HDR_CMD_CODE_MASK, flags)
279
283
284
286struct rtio_sqe;
287struct rtio_iodev_sqe;
288struct rtio_iodev;
289struct rtio;
291
300typedef void (*rtio_callback_t)(struct rtio *r, const struct rtio_sqe *sqe, int res, void *arg0);
301
308typedef void (*rtio_signaled_t)(struct rtio_iodev_sqe *iodev_sqe, void *userdata);
309
323
332#define RTIO_SQE_HANDLE_INVALID ((rtio_sqe_handle_t)UINT32_MAX)
333
337struct rtio_sqe {
339
341
343
345
346 const struct rtio_iodev *iodev;
347
355 void *userdata;
356
358 union {
359
361 struct {
363 const uint8_t *buf;
364 } tx;
365
367 struct {
368 uint32_t buf_len;
370 } rx;
371
373 struct {
376 } tiny_tx;
377
379 struct {
381 void *arg0;
382 } callback;
383
385 struct {
386 uint32_t buf_len;
389 } txrx;
390
391#ifdef CONFIG_RTIO_OP_DELAY
393 struct {
394 k_timeout_t timeout;
395 } delay;
396#endif
397
400
402 struct {
403 /* enum i3c_config_type type; */
404 int type;
405 void *config;
406 } i3c_config;
407
409 /* struct i3c_ccc_payload *ccc_payload; */
411 };
412};
413
414
425#define RTIO_SQE_GEN_MASK GENMASK(15, 0)
427#define RTIO_SQE_ALLOCD BIT(16)
429#define RTIO_SQE_STATUS_CANCELED BIT(17)
431
439{
440 return (uint16_t)(handle >> 16);
441}
442
450{
451 return (uint16_t)(handle & RTIO_SQE_GEN_MASK);
452}
453
461 struct rtio_sqe sqe;
463 struct mpsc_node q;
467 struct rtio *r;
468
471
478 union {
480 struct {
483 } rx_bind;
484
486 struct {
489 void *userdata;
490 } await;
491
492#ifdef CONFIG_RTIO_OP_DELAY
494 k_timepoint_t delay_expiry;
495#endif
496 } rt;
497};
498
499
501/* Ensure the rtio_iodev_sqe never grows beyond a common cacheline size of 64 bytes */
502#if CONFIG_RTIO_SQE_CACHELINE_CHECK
503#ifdef CONFIG_DCACHE_LINE_SIZE
504#define RTIO_CACHE_LINE_SIZE CONFIG_DCACHE_LINE_SIZE
505#else
506#define RTIO_CACHE_LINE_SIZE 64
507#endif
508BUILD_ASSERT(sizeof(struct rtio_iodev_sqe) <= RTIO_CACHE_LINE_SIZE,
509 "RTIO performs best when the submissions queue entries are less than a cache line");
510#endif
512
516static inline void rtio_sqe_prep_nop(struct rtio_sqe *sqe,
517 const struct rtio_iodev *iodev,
518 void *userdata)
519{
520 memset(sqe, 0, sizeof(struct rtio_sqe));
521 sqe->op = RTIO_OP_NOP;
522 sqe->iodev = iodev;
523 sqe->userdata = userdata;
524}
525
526
531static inline void _rtio_sqe_prep_read(struct rtio_sqe *sqe,
532 const struct rtio_iodev *iodev,
533 int8_t prio,
534 uint8_t *buf,
535 uint32_t len,
536 void *userdata)
537{
538 memset(sqe, 0, sizeof(struct rtio_sqe));
539 sqe->op = RTIO_OP_RX;
540 sqe->prio = prio;
541 sqe->iodev = iodev;
542 sqe->rx.buf_len = len;
543 sqe->rx.buf = buf;
544 sqe->userdata = userdata;
545}
547
551static inline void rtio_sqe_prep_read(struct rtio_sqe *sqe,
552 const struct rtio_iodev *iodev,
553 int8_t prio,
554 uint8_t *buf,
555 uint32_t len,
556 void *userdata)
557{
558 __ASSERT_NO_MSG(len > 0 && buf != NULL);
559
560 _rtio_sqe_prep_read(sqe, iodev, prio, buf, len, userdata);
561}
562
568static inline void rtio_sqe_prep_read_with_pool(struct rtio_sqe *sqe,
569 const struct rtio_iodev *iodev, int8_t prio,
570 void *userdata)
571{
572 _rtio_sqe_prep_read(sqe, iodev, prio, NULL, 0, userdata);
574}
575
583static inline void rtio_sqe_prep_read_multishot(struct rtio_sqe *sqe,
584 const struct rtio_iodev *iodev, int8_t prio,
585 void *userdata)
586{
587 rtio_sqe_prep_read_with_pool(sqe, iodev, prio, userdata);
589}
590
594static inline void rtio_sqe_prep_write(struct rtio_sqe *sqe,
595 const struct rtio_iodev *iodev,
596 int8_t prio,
597 const uint8_t *buf,
598 uint32_t len,
599 void *userdata)
600{
601 __ASSERT_NO_MSG(len > 0 && buf != NULL);
602
603 memset(sqe, 0, sizeof(struct rtio_sqe));
604 sqe->op = RTIO_OP_TX;
605 sqe->prio = prio;
606 sqe->iodev = iodev;
607 sqe->tx.buf_len = len;
608 sqe->tx.buf = buf;
609 sqe->userdata = userdata;
610}
611
622static inline void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe,
623 const struct rtio_iodev *iodev,
624 int8_t prio,
625 const uint8_t *tiny_write_data,
626 uint8_t tiny_write_len,
627 void *userdata)
628{
629 __ASSERT_NO_MSG(tiny_write_len <= sizeof(sqe->tiny_tx.buf));
630 __ASSERT_NO_MSG(tiny_write_len > 0 && tiny_write_data != NULL);
631
632 memset(sqe, 0, sizeof(struct rtio_sqe));
633 sqe->op = RTIO_OP_TINY_TX;
634 sqe->prio = prio;
635 sqe->iodev = iodev;
636 sqe->tiny_tx.buf_len = tiny_write_len;
637 memcpy(sqe->tiny_tx.buf, tiny_write_data, tiny_write_len);
638 sqe->userdata = userdata;
639}
640
649static inline void rtio_sqe_prep_callback(struct rtio_sqe *sqe,
650 rtio_callback_t callback,
651 void *arg0,
652 void *userdata)
653{
654 memset(sqe, 0, sizeof(struct rtio_sqe));
655 sqe->op = RTIO_OP_CALLBACK;
656 sqe->prio = 0;
657 sqe->iodev = NULL;
658 sqe->callback.callback = callback;
659 sqe->callback.arg0 = arg0;
660 sqe->userdata = userdata;
661}
662
673static inline void rtio_sqe_prep_callback_no_cqe(struct rtio_sqe *sqe,
674 rtio_callback_t callback,
675 void *arg0,
676 void *userdata)
677{
678 rtio_sqe_prep_callback(sqe, callback, arg0, userdata);
680}
681
685static inline void rtio_sqe_prep_transceive(struct rtio_sqe *sqe,
686 const struct rtio_iodev *iodev,
687 int8_t prio,
688 const uint8_t *tx_buf,
689 uint8_t *rx_buf,
690 uint32_t buf_len,
691 void *userdata)
692{
693 __ASSERT_NO_MSG(buf_len > 0 && tx_buf != NULL && rx_buf != NULL);
694
695 memset(sqe, 0, sizeof(struct rtio_sqe));
696 sqe->op = RTIO_OP_TXRX;
697 sqe->prio = prio;
698 sqe->iodev = iodev;
699 sqe->txrx.buf_len = buf_len;
700 sqe->txrx.tx_buf = tx_buf;
701 sqe->txrx.rx_buf = rx_buf;
702 sqe->userdata = userdata;
703}
704
719static inline void rtio_sqe_prep_await(struct rtio_sqe *sqe,
720 const struct rtio_iodev *iodev,
721 int8_t prio,
722 void *userdata)
723{
724 memset(sqe, 0, sizeof(struct rtio_sqe));
725 sqe->op = RTIO_OP_AWAIT;
726 sqe->prio = prio;
727 sqe->iodev = iodev;
728 sqe->userdata = userdata;
729}
730
742static inline void rtio_sqe_prep_await_iodev(struct rtio_sqe *sqe, const struct rtio_iodev *iodev,
743 int8_t prio, void *userdata)
744{
745 __ASSERT_NO_MSG(iodev != NULL);
746 rtio_sqe_prep_await(sqe, iodev, prio, userdata);
747}
748
759static inline void rtio_sqe_prep_await_executor(struct rtio_sqe *sqe, int8_t prio, void *userdata)
760{
761 rtio_sqe_prep_await(sqe, NULL, prio, userdata);
762}
763
775#ifdef CONFIG_RTIO_OP_DELAY
782extern struct rtio_iodev rtio_timeout_iodev;
783
784static inline void rtio_sqe_prep_delay(struct rtio_sqe *sqe,
785 k_timeout_t timeout,
786 void *userdata)
787{
788 memset(sqe, 0, sizeof(struct rtio_sqe));
789 sqe->op = RTIO_OP_DELAY;
790 sqe->prio = 0;
791 sqe->iodev = &rtio_timeout_iodev;
792 sqe->delay.timeout = timeout;
793 sqe->userdata = userdata;
794}
795#else
796#define rtio_sqe_prep_delay(sqe, timeout, userdata) \
797 BUILD_ASSERT(false, "CONFIG_RTIO_OP_DELAY not enabled")
798#endif
799
801static inline void rtio_sqe_prep_i2c_configure(struct rtio_sqe *sqe,
802 const struct rtio_iodev *iodev,
803 int8_t prio,
804 uint32_t dev_config,
805 void *userdata)
806{
807 memset(sqe, 0, sizeof(struct rtio_sqe));
809 sqe->prio = prio;
810 sqe->iodev = iodev;
811 sqe->i2c_config = dev_config;
812 sqe->userdata = userdata;
813}
814
816static inline void rtio_sqe_prep_i2c_recover(struct rtio_sqe *sqe,
817 const struct rtio_iodev *iodev,
818 int8_t prio,
819 void *userdata)
820{
821 memset(sqe, 0, sizeof(struct rtio_sqe));
822 sqe->op = RTIO_OP_I2C_RECOVER;
823 sqe->prio = prio;
824 sqe->iodev = iodev;
825 sqe->userdata = userdata;
826}
827
836static inline struct rtio_iodev_sqe *rtio_txn_next(const struct rtio_iodev_sqe *iodev_sqe)
837{
838 struct rtio_iodev_sqe *next = NULL;
839
840 SYS_PORT_TRACING_FUNC_ENTER(rtio, txn_next, iodev_sqe->r, iodev_sqe);
841 if (iodev_sqe->sqe.flags & RTIO_SQE_TRANSACTION) {
842 next = iodev_sqe->next;
843 }
844 SYS_PORT_TRACING_FUNC_EXIT(rtio, txn_next, iodev_sqe->r, next);
845 return next;
846}
847
848
857static inline struct rtio_iodev_sqe *rtio_chain_next(const struct rtio_iodev_sqe *iodev_sqe)
858{
859 struct rtio_iodev_sqe *next = NULL;
860
861 SYS_PORT_TRACING_FUNC_ENTER(rtio, txn_next, iodev_sqe->r, iodev_sqe);
862 if (iodev_sqe->sqe.flags & RTIO_SQE_CHAINED) {
863 next = iodev_sqe->next;
864 }
865 SYS_PORT_TRACING_FUNC_EXIT(rtio, txn_next, iodev_sqe->r, next);
866 return next;
867}
868
877static inline struct rtio_iodev_sqe *rtio_iodev_sqe_next(const struct rtio_iodev_sqe *iodev_sqe)
878{
879 return iodev_sqe->next;
880}
881
895static inline bool rtio_iodev_sqe_is_canceled(const struct rtio_iodev_sqe *iodev_sqe)
896{
897 return (atomic_get(&iodev_sqe->status) & RTIO_SQE_STATUS_CANCELED) != 0;
898}
899
908static inline void rtio_iodev_sqe_set_canceled(struct rtio_iodev_sqe *iodev_sqe)
909{
911}
912
923static inline void rtio_iodev_sqe_await_signal(struct rtio_iodev_sqe *iodev_sqe,
925 void *userdata)
926{
927 iodev_sqe->rt.await.callback = callback;
928 iodev_sqe->rt.await.userdata = userdata;
929
930 if (!atomic_cas(&iodev_sqe->rt.await.ok, 0, 1)) {
931 callback(iodev_sqe, userdata);
932 }
933}
934
935/* Private structures and functions used for the pool of sqe structures */
937
938struct rtio_sqe_pool {
939 struct mpsc free_q;
940 const uint16_t pool_size;
941 uint16_t pool_free;
942 struct rtio_iodev_sqe *pool;
943};
944
945static inline struct rtio_iodev_sqe *rtio_sqe_pool_alloc(struct rtio_sqe_pool *pool)
946{
947 struct mpsc_node *node = mpsc_pop(&pool->free_q);
948
949 if (node == NULL) {
950 return NULL;
951 }
952
953 struct rtio_iodev_sqe *iodev_sqe = CONTAINER_OF(node, struct rtio_iodev_sqe, q);
954
955 /* Reset the runtime scratch so per-op state (await ok, mempool binding)
956 * starts clean for this allocation.
957 */
958 memset(&iodev_sqe->rt, 0, sizeof(iodev_sqe->rt));
959
960 /* The chain link is only valid once the executor links the entry at
961 * submit time; clear it so a cancel before then does not walk the
962 * previous occupant's chain.
963 */
964 iodev_sqe->next = NULL;
965
966 /* Mark the slot live. The generation persists from the previous free so a
967 * handle captured against the prior occupant no longer matches.
968 */
969 atomic_or(&iodev_sqe->status, RTIO_SQE_ALLOCD);
970
971 pool->pool_free--;
972
973 return iodev_sqe;
974}
975
976static inline void rtio_sqe_pool_free(struct rtio_sqe_pool *pool, struct rtio_iodev_sqe *iodev_sqe)
977{
978 /* Bump the generation and clear ALLOCD so any outstanding handle to this
979 * slot is rejected by rtio_iodev_sqe_from_handle() once it is recycled.
980 */
981 atomic_val_t gen = (atomic_get(&iodev_sqe->status) + 1) & RTIO_SQE_GEN_MASK;
982
983 atomic_set(&iodev_sqe->status, gen);
984
985 mpsc_push(&pool->free_q, &iodev_sqe->q);
986
987 pool->pool_free++;
988}
989
990#if CONFIG_RTIO_SQE_PLACEMENT_DTCM
991#define RTIO_SQE_MEM Z_GENERIC_SECTION(".dtcm_bss") static
992#elif defined(CONFIG_RTIO_SQE_PLACEMENT_NOCACHE)
993#define RTIO_SQE_MEM __nocache static
994#else
995#define RTIO_SQE_MEM static
996#endif
997
998/* Do not try and reformat the macros */
999/* clang-format off */
1000
1001#define Z_RTIO_SQE_POOL_DEFINE(name, sz) \
1002 RTIO_SQE_MEM struct rtio_iodev_sqe CONCAT(_sqe_pool_, name)[sz]; \
1003 STRUCT_SECTION_ITERABLE(rtio_sqe_pool, name) = { \
1004 .free_q = MPSC_INIT((name.free_q)), \
1005 .pool_size = sz, \
1006 .pool_free = sz, \
1007 .pool = CONCAT(_sqe_pool_, name), \
1008 }
1009
1010/* clang-format on */
1012
1016
1017#ifdef __cplusplus
1018}
1019#endif
1020
1021#endif /* ZEPHYR_INCLUDE_RTIO_SQE_H_ */
workaround assembler barfing for ST r
Definition asm-macro-32-bit-gnu.h:27
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:157
#define RTIO_OP_I2C_RECOVER
An operation to recover I2C buses.
Definition sqe.h:166
#define RTIO_OP_TINY_TX
An operation that transmits tiny writes by copying the data to write.
Definition sqe.h:154
#define RTIO_OP_TX
An operation that transmits (writes).
Definition sqe.h:151
#define RTIO_OP_TXRX
An operation that transceives (reads and writes simultaneously).
Definition sqe.h:160
#define RTIO_OP_NOP
An operation that does nothing and will complete immediately.
Definition sqe.h:145
#define RTIO_OP_AWAIT
An operation to await a signal while blocking the iodev (if one is provided).
Definition sqe.h:181
#define RTIO_OP_I2C_CONFIGURE
An operation to configure I2C buses.
Definition sqe.h:169
#define RTIO_OP_DELAY
An operation that takes a specified amount of time (asynchronously) before completing.
Definition sqe.h:163
#define RTIO_OP_RX
An operation that receives (reads).
Definition sqe.h:148
#define RTIO_SQE_MULTISHOT
The SQE should continue producing CQEs until canceled.
Definition sqe.h:125
#define RTIO_SQE_TRANSACTION
The next request in the queue is part of a transaction.
Definition sqe.h:94
#define RTIO_SQE_MEMPOOL_BUFFER
The buffer should be allocated by the RTIO mempool.
Definition sqe.h:106
#define RTIO_SQE_NO_RESPONSE
The SQE does not produce a CQE.
Definition sqe.h:130
#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:568
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:816
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:622
#define RTIO_SQE_ALLOCD
Set while the entry is allocated from the pool (i.e.
Definition sqe.h:427
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:516
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:300
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:742
#define RTIO_SQE_GEN_MASK
Generation counter; bumped on free, compared against a handle's generation.
Definition sqe.h:425
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:923
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:594
uint32_t rtio_sqe_handle_t
Opaque identity for a submission queue entry.
Definition sqe.h:322
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:551
static uint16_t rtio_sqe_handle_generation(rtio_sqe_handle_t handle)
Generation counter encoded in a handle.
Definition sqe.h:449
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:895
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:583
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:649
#define RTIO_SQE_STATUS_CANCELED
Set when cancellation of the submission has been requested.
Definition sqe.h:429
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:759
static uint16_t rtio_sqe_handle_index(rtio_sqe_handle_t handle)
Pool block index encoded in a handle.
Definition sqe.h:438
void(* rtio_signaled_t)(struct rtio_iodev_sqe *iodev_sqe, void *userdata)
Callback signature for RTIO_OP_AWAIT signaled.
Definition sqe.h:308
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:685
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:801
#define rtio_sqe_prep_delay(sqe, timeout, userdata)
Prepare a delay operation submission which completes after the given timeout.
Definition sqe.h:796
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:857
static void rtio_iodev_sqe_set_canceled(struct rtio_iodev_sqe *iodev_sqe)
Mark a submission canceled.
Definition sqe.h:908
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:877
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:673
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:836
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:719
#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
#define NULL
Definition iar_missing_defs.h:20
#define BUILD_ASSERT(EXPR, MSG...)
Definition llvm.h:51
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:459
struct rtio_iodev_sqe::@330064006263143366064036221227125351044336131221::@020376107202163366036113216314102104241220072312 await
OP_AWAIT signaling state.
struct rtio_iodev_sqe * next
Next entry in a chained or transactional sequence, NULL if none.
Definition sqe.h:465
struct rtio_sqe sqe
The submission queue entry this wraps.
Definition sqe.h:461
uint8_t * buf
Buffer allocated for the read.
Definition sqe.h:481
struct rtio * r
RTIO context that owns this entry.
Definition sqe.h:467
atomic_t ok
Set once the awaited signal arrives.
Definition sqe.h:487
void * userdata
Opaque pointer passed to the callback.
Definition sqe.h:489
uint32_t buf_len
Length of the allocated buffer.
Definition sqe.h:482
atomic_t status
Identity + lifetime word (generation | ALLOCD), see RTIO_SQE_* bits above.
Definition sqe.h:470
struct mpsc_node q
Node used to link the entry into the pool free list and iodev queues.
Definition sqe.h:463
union rtio_iodev_sqe::@330064006263143366064036221227125351044336131221 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:488
An IO device with a function table for submitting requests.
Definition iodev.h:83
A submission queue event.
Definition sqe.h:337
uint32_t i2c_config
OP_I2C_CONFIGURE.
Definition sqe.h:399
void * userdata
User provided data which is returned upon operation completion.
Definition sqe.h:355
const uint8_t * tx_buf
Buffer to write from.
Definition sqe.h:387
uint8_t op
Op code.
Definition sqe.h:338
void * arg0
Last argument given to callback.
Definition sqe.h:381
uint8_t * rx_buf
Buffer to read into.
Definition sqe.h:388
struct rtio_sqe::@342363352172076106335370162240320153276337137375::@017245174153135075241134370152236032302025336125 tiny_tx
OP_TINY_TX.
uint8_t prio
Op priority.
Definition sqe.h:340
uint32_t buf_len
Length of buffer.
Definition sqe.h:362
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:346
struct rtio_sqe::@342363352172076106335370162240320153276337137375::@331301263323312231326352370225016114352302103127 txrx
OP_TXRX.
uint32_t iodev_flags
Op iodev flags.
Definition sqe.h:344
void * ccc_payload
OP_I3C_CCC.
Definition sqe.h:410
struct rtio_sqe::@342363352172076106335370162240320153276337137375::@325336075103140057167073177100146101272354232055 tx
OP_TX.
struct rtio_sqe::@342363352172076106335370162240320153276337137375::@110162343014114265152332336213215220201374200140 rx
OP_RX.
int type
Configuration type, an enum i3c_config_type value.
Definition sqe.h:404
uint16_t flags
Op Flags.
Definition sqe.h:342
const uint8_t * buf
Buffer to write from.
Definition sqe.h:363
void * config
Configuration to apply.
Definition sqe.h:405
rtio_callback_t callback
Function to run.
Definition sqe.h:380
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:83
Header file for the Atomic operations API.
Misc utilities.