From a15cfe7f21726d4a3c572af6e8122164e5cd9787 Mon Sep 17 00:00:00 2001 From: Alexandra Clifford Date: Tue, 15 Oct 2024 03:38:09 -0400 Subject: [PATCH] Make RX queue size configurable (#2324) --- esp-ieee802154/CHANGELOG.md | 9 +++++---- esp-ieee802154/Cargo.toml | 10 ++++++---- esp-ieee802154/build.rs | 13 +++++++++++++ esp-ieee802154/src/lib.rs | 9 +++++++++ esp-ieee802154/src/raw.rs | 3 ++- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/esp-ieee802154/CHANGELOG.md b/esp-ieee802154/CHANGELOG.md index 86fe332bf..c1b96f7a1 100644 --- a/esp-ieee802154/CHANGELOG.md +++ b/esp-ieee802154/CHANGELOG.md @@ -23,20 +23,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added board-specific consts for c6 and h2 when caluclating transmit power conversion +- Added board-specific consts for c6 and h2 when caluclating transmit power conversion (#2114) - Added `defmt` and `log` features (#2183) +- Make RX queue size configurable using esp-config (#2324) ### Changed -- Modified CCA threshold value to default of -60 +- Modified CCA threshold value to default of -60 (#2114) - The driver now take `RADIO_CLK` by value to avoid a collision with esp-wifi's usage (#2183) - `binary-logs` feature renamed to `sys-logs` (#2183) - Updated PHY driver to v5.3.1 (#2239) ### Fixed -- Fixed possible integer underflow in array access -- Fixed compile error when building sys-logs feature +- Fixed possible integer underflow in array access (#2114) +- Fixed compile error when building sys-logs feature (#2114) ## 0.2.0 - 2024-08-29 diff --git a/esp-ieee802154/Cargo.toml b/esp-ieee802154/Cargo.toml index d517ae991..67367b175 100644 --- a/esp-ieee802154/Cargo.toml +++ b/esp-ieee802154/Cargo.toml @@ -20,19 +20,21 @@ byte = "0.2.7" critical-section = "1.1.3" document-features = "0.2.10" esp-hal = { version = "0.21.0", path = "../esp-hal" } -esp-wifi-sys = { version = "0.6.0" } +esp-wifi-sys = { version = "0.6.0" } heapless = "0.8.0" ieee802154 = "0.6.1" cfg-if = "1.0.0" +esp-config = { version = "0.1.0", path = "../esp-config" } +defmt = { version = "0.3.8", optional = true } +log = { version = "0.4.22", optional = true } -defmt = { version = "0.3.8", optional = true } -log = { version = "0.4.22", optional = true } +[build-dependencies] +esp-config = { version = "0.1.0", path = "../esp-config" } [features] esp32c6 = ["esp-hal/esp32c6", "esp-wifi-sys/esp32c6"] esp32h2 = ["esp-hal/esp32h2", "esp-wifi-sys/esp32h2"] sys-logs = ["esp-wifi-sys/sys-logs"] - log = ["dep:log", "esp-wifi-sys/log"] defmt = ["dep:defmt", "esp-wifi-sys/defmt"] diff --git a/esp-ieee802154/build.rs b/esp-ieee802154/build.rs index c0971b476..f20eeeab3 100644 --- a/esp-ieee802154/build.rs +++ b/esp-ieee802154/build.rs @@ -1,6 +1,19 @@ use std::{env, path::PathBuf}; +use esp_config::{generate_config, Value}; + fn main() { let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); println!("cargo:rustc-link-search={}", out.display()); + + // emit config + generate_config( + "esp_ieee802154", + &[( + "rx_queue_size", + Value::UnsignedInteger(50), + "Size of the RX queue in frames", + )], + true, + ); } diff --git a/esp-ieee802154/src/lib.rs b/esp-ieee802154/src/lib.rs index dec954b65..810056b22 100644 --- a/esp-ieee802154/src/lib.rs +++ b/esp-ieee802154/src/lib.rs @@ -18,6 +18,7 @@ use core::{cell::RefCell, marker::PhantomData}; use byte::{BytesExt, TryRead}; use critical_section::Mutex; +use esp_config::*; use esp_hal::peripherals::{IEEE802154, RADIO_CLK}; use heapless::Vec; use ieee802154::mac::{self, FooterMode, FrameSerDesContext}; @@ -58,6 +59,14 @@ impl From for Error { } } +struct QueueConfig { + rx_queue_size: usize, +} + +pub(crate) const CONFIG: QueueConfig = QueueConfig { + rx_queue_size: esp_config_int!(usize, "ESP_IEEE802154_RX_QUEUE_SIZE"), +}; + /// IEEE 802.15.4 driver configuration #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Config { diff --git a/esp-ieee802154/src/raw.rs b/esp-ieee802154/src/raw.rs index 8ce91686d..73fb9b717 100644 --- a/esp-ieee802154/src/raw.rs +++ b/esp-ieee802154/src/raw.rs @@ -33,7 +33,8 @@ use crate::{ const PHY_ENABLE_VERSION_PRINT: u32 = 1; static mut RX_BUFFER: [u8; FRAME_SIZE] = [0u8; FRAME_SIZE]; -static RX_QUEUE: Mutex>> = Mutex::new(RefCell::new(Queue::new())); +static RX_QUEUE: Mutex>> = + Mutex::new(RefCell::new(Queue::new())); static STATE: Mutex> = Mutex::new(RefCell::new(Ieee802154State::Idle)); extern "C" {