30#ifndef ZEPHYR_MODEM_CMUX_
31#define ZEPHYR_MODEM_CMUX_
58enum modem_cmux_state {
59 MODEM_CMUX_STATE_DISCONNECTED = 0,
60 MODEM_CMUX_STATE_CONNECTING,
61 MODEM_CMUX_STATE_CONNECTED,
62 MODEM_CMUX_STATE_DISCONNECTING,
65enum modem_cmux_receive_state {
66 MODEM_CMUX_RECEIVE_STATE_SOF = 0,
67 MODEM_CMUX_RECEIVE_STATE_RESYNC,
68 MODEM_CMUX_RECEIVE_STATE_ADDRESS,
69 MODEM_CMUX_RECEIVE_STATE_ADDRESS_CONT,
70 MODEM_CMUX_RECEIVE_STATE_CONTROL,
71 MODEM_CMUX_RECEIVE_STATE_LENGTH,
72 MODEM_CMUX_RECEIVE_STATE_LENGTH_CONT,
73 MODEM_CMUX_RECEIVE_STATE_DATA,
74 MODEM_CMUX_RECEIVE_STATE_FCS,
75 MODEM_CMUX_RECEIVE_STATE_DROP,
76 MODEM_CMUX_RECEIVE_STATE_EOF,
79enum modem_cmux_dlci_state {
80 MODEM_CMUX_DLCI_STATE_CLOSED,
81 MODEM_CMUX_DLCI_STATE_OPENING,
82 MODEM_CMUX_DLCI_STATE_OPEN,
83 MODEM_CMUX_DLCI_STATE_CLOSING,
86struct modem_cmux_dlci {
90 struct modem_pipe pipe;
94 struct modem_cmux *cmux;
105 enum modem_cmux_dlci_state
state;
108#if CONFIG_MODEM_STATS
109 struct modem_stats_buffer receive_buf_stats;
113struct modem_cmux_frame {
122struct modem_cmux_work {
124 struct modem_cmux *cmux;
129 struct modem_pipe *pipe;
139 enum modem_cmux_state
state;
140 bool flow_control_on;
147 enum modem_cmux_receive_state receive_state;
154 uint8_t work_buf[CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE];
158 struct k_mutex transmit_rb_lock;
161 struct modem_cmux_frame frame;
175#if CONFIG_MODEM_STATS
176 struct modem_stats_buffer receive_buf_stats;
177 struct modem_stats_buffer transmit_buf_stats;
int modem_cmux_connect(struct modem_cmux *cmux)
Connect CMUX instance.
int modem_cmux_disconnect(struct modem_cmux *cmux)
Close down and disconnect CMUX instance.
int modem_cmux_disconnect_async(struct modem_cmux *cmux)
Close down and disconnect CMUX instance asynchronously.
void(* modem_cmux_callback)(struct modem_cmux *cmux, enum modem_cmux_event event, void *user_data)
Definition cmux.h:51
int modem_cmux_connect_async(struct modem_cmux *cmux)
Connect CMUX instance asynchronously.
modem_cmux_event
Definition cmux.h:46
int modem_cmux_attach(struct modem_cmux *cmux, struct modem_pipe *pipe)
Attach CMUX instance to pipe.
struct modem_pipe * modem_cmux_dlci_init(struct modem_cmux *cmux, struct modem_cmux_dlci *dlci, const struct modem_cmux_dlci_config *config)
Initialize DLCI instance and register it with CMUX instance.
void modem_cmux_init(struct modem_cmux *cmux, const struct modem_cmux_config *config)
Initialize CMUX instance.
void modem_cmux_release(struct modem_cmux *cmux)
Release CMUX instance from pipe.
@ MODEM_CMUX_EVENT_DISCONNECTED
Definition cmux.h:48
@ MODEM_CMUX_EVENT_CONNECTED
Definition cmux.h:47
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
state
Definition parser_state.h:29
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Event Structure.
Definition kernel.h:2301
Mutex Structure.
Definition kernel.h:2994
Kernel Spin Lock.
Definition spinlock.h:45
A structure used to submit work after a delay.
Definition kernel.h:3985
Contains CMUX instance configuration data.
Definition cmux.h:188
uint8_t * receive_buf
Receive buffer.
Definition cmux.h:194
modem_cmux_callback callback
Invoked when event occurs.
Definition cmux.h:190
uint16_t receive_buf_size
Size of receive buffer in bytes [127, ...].
Definition cmux.h:196
void * user_data
Free to use pointer passed to event handler when invoked.
Definition cmux.h:192
uint8_t * transmit_buf
Transmit buffer.
Definition cmux.h:198
uint16_t transmit_buf_size
Size of transmit buffer in bytes [149, ...].
Definition cmux.h:200
CMUX DLCI configuration.
Definition cmux.h:213
uint8_t dlci_address
DLCI channel address.
Definition cmux.h:215
uint8_t * receive_buf
Receive buffer used by pipe.
Definition cmux.h:217
uint16_t receive_buf_size
Size of receive buffer used by pipe [127, ...].
Definition cmux.h:219
A structure to represent a ring buffer.
Definition ring_buffer.h:41