|
ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
|
#include "tx_queue.h"#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "hardware/pio.h"#include "drivers/pio_tx_rx_driver.h"#include "drivers/w5500_driver.h"#include "protocol/hdlc_encoder.h"#include "system/common.h"#include "system/error.h"#include "system/ringbuffer.h"#include "pico/time.h"
Go to the source code of this file.
Macros | |
| #define | TX_QUEUE_TX_INPROG_MS 1000U |
| #define | QUEUE_FILLING_UP_THRESHOLD 5U |
Functions | |
| e2s_error_t | tx_queue_init (TX_QUEUE_T *queue, uint8_t *buffer_data) |
| Initialize TX queue and ring buffer storage. | |
| e2s_error_t | poll_queue_stats (TX_QUEUE_T *queue) |
| Emit queue usage statistics when needed. | |
| static e2s_error_t | tx_queue_drain_bytes (TX_QUEUE_T *queue, TX_QUEUE_ENTRY_T *entry, size_t bytes_to_drain, size_t *bytes_drained) |
| size_t | tx_queue_get_count (const TX_QUEUE_T *queue) |
| Get current number of queued entries. | |
| bool | tx_queue_is_empty (TX_QUEUE_T *queue) |
| Check whether queue and active entry are fully drained. | |
| e2s_error_t | tx_queue_drain (TX_QUEUE_T *queue, size_t bytes_to_drain, size_t *bytes_drained) |
Drain up to bytes_to_drain bytes from queue into TX FIFO. | |
| e2s_error_t | tx_queue_enqueue_udp_frame (TX_QUEUE_T *queue, const UDP_FRAME_T *frame) |
| Encode UDP frame to HDLC and append it to TX queue. | |
| #define QUEUE_FILLING_UP_THRESHOLD 5U |
| #define TX_QUEUE_TX_INPROG_MS 1000U |
Definition at line 36 of file tx_queue.c.
| e2s_error_t poll_queue_stats | ( | TX_QUEUE_T * | queue | ) |
Emit queue usage statistics when needed.
| queue | TX queue instance. |
Definition at line 49 of file tx_queue.c.
References Ringbuffer::capacity, Ringbuffer::count, E2S_ERR_TX_QUEUE_NOT_INITIALIZED, E2S_OK, LOG_INFO, LOG_TRACE, TX_QUEUE_T::queue_buffer, QUEUE_FILLING_UP_THRESHOLD, and TX_QUEUE_T::queue_touched.
Referenced by poll_tx_pipeline().

| e2s_error_t tx_queue_drain | ( | TX_QUEUE_T * | queue, |
| size_t | bytes_to_drain, | ||
| size_t * | bytes_drained | ||
| ) |
Drain up to bytes_to_drain bytes from queue into TX FIFO.
| queue | TX queue instance. |
| bytes_to_drain | Maximum bytes to attempt. |
| bytes_drained | Pointer to where the number of actually drained bytes is written. |
Restart only when CTS changed during this frame's transmission window. Stale edges from idle periods must not retrigger unrelated future frames.
Definition at line 129 of file tx_queue.c.
References HDLC_FRAME_T::capacity, TX_QUEUE_T::current_entry, TX_QUEUE_T::current_frame_cts_seq_start, TX_QUEUE_T::current_frame_cts_seq_valid, E2S_ERR_TX_QUEUE_NOT_INITIALIZED, E2S_OK, TX_QUEUE_ENTRY_T::frame, HDLC_FRAME_T::length, LOG_DEBUG, LOG_TRACE, TX_QUEUE_ENTRY_T::offset, TX_QUEUE_ENTRY_T::payload, HDLC_FRAME_T::payload, TX_QUEUE_T::queue_buffer, RbPopFront(), tx_clock_get_cts_toggle_seq(), tx_clock_hard_reset(), tx_queue_drain_bytes(), and TX_QUEUE_TX_INPROG_MS.
Referenced by poll_tx_pipeline().


|
static |
Definition at line 75 of file tx_queue.c.
References E2S_ERR_TX_QUEUE_NOT_INITIALIZED, E2S_OK, TX_QUEUE_ENTRY_T::frame, HDLC_FRAME_T::length, TX_QUEUE_ENTRY_T::offset, HDLC_FRAME_T::payload, tx_put(), and TX_QUEUE_T::tx_wire_bytes.
Referenced by tx_queue_drain().


| e2s_error_t tx_queue_enqueue_udp_frame | ( | TX_QUEUE_T * | queue, |
| const UDP_FRAME_T * | frame | ||
| ) |
Encode UDP frame to HDLC and append it to TX queue.
| queue | TX queue instance. |
| frame | UDP frame payload source. |
Definition at line 201 of file tx_queue.c.
References HDLC_FRAME_T::capacity, Ringbuffer::capacity, Ringbuffer::count, E2S_ERR_HDLC_ENCODE_FAILED, E2S_ERR_TX_QUEUE_FULL, E2S_ERR_TX_QUEUE_NOT_INITIALIZED, E2S_OK, TX_QUEUE_ENTRY_T::frame, hdlc_encode(), UDP_FRAME_T::length, HDLC_FRAME_T::length, LOG_DEBUG, TX_QUEUE_ENTRY_T::payload, UDP_FRAME_T::payload, HDLC_FRAME_T::payload, TX_QUEUE_T::queue_buffer, TX_QUEUE_T::queue_touched, and RbPushBack().
Referenced by event_dispatch(), and poll_and_enqueue_udp_rx().


| size_t tx_queue_get_count | ( | const TX_QUEUE_T * | queue | ) |
Get current number of queued entries.
| queue | TX queue instance. |
Definition at line 113 of file tx_queue.c.
References Ringbuffer::count, and TX_QUEUE_T::queue_buffer.
Referenced by update_statistics(), and update_udp_rx_throttle_state().

| e2s_error_t tx_queue_init | ( | TX_QUEUE_T * | queue, |
| uint8_t * | buffer_data | ||
| ) |
Initialize TX queue and ring buffer storage.
| queue | TX queue instance. |
| buffer_data | Backing storage for ring buffer entries. |
Definition at line 38 of file tx_queue.c.
References TX_QUEUE_T::current_frame_cts_seq_start, TX_QUEUE_T::current_frame_cts_seq_valid, E2S_OK, TX_QUEUE_T::queue_buffer, TX_QUEUE_T::queue_touched, RbInit(), TX_FRAME_QUEUE_SIZE, and TX_QUEUE_T::tx_wire_bytes.
Referenced by main().


| bool tx_queue_is_empty | ( | TX_QUEUE_T * | queue | ) |
Check whether queue and active entry are fully drained.
| queue | TX queue instance. |
Definition at line 122 of file tx_queue.c.
References Ringbuffer::count, TX_QUEUE_T::current_entry, TX_QUEUE_ENTRY_T::frame, HDLC_FRAME_T::length, TX_QUEUE_ENTRY_T::offset, and TX_QUEUE_T::queue_buffer.
Referenced by ev_set_v24_settings(), poll_and_dispatch_events(), and poll_tx_pipeline().
