Skip to content

Commit

Permalink
fix(esp_tinyusb): Add possibility to configure NCM NTB buffers via me…
Browse files Browse the repository at this point in the history
…nuconfig
  • Loading branch information
peter-marcisovsky committed Jan 15, 2025
1 parent d8041fd commit 80ecd79
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
4 changes: 4 additions & 0 deletions device/esp_tinyusb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [Unreleased]

- esp_tinyusb: Added possibility to configure NCM Transfer Blocks (NTB) via menuconfig

## 1.6.0

- CDC-ACM: Fixed memory leak on deinit
Expand Down
45 changes: 45 additions & 0 deletions device/esp_tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,51 @@ menu "TinyUSB Stack"
config TINYUSB_NET_MODE_NONE
bool "None"
endchoice

config TINYUSB_NCM_OUT_NTB_BUFFS_COUNT
int "Number of NCM NTB buffers for reception side"
depends on TINYUSB_NET_MODE_NCM
default 3
range 1 6
help
Number of NTB buffers for reception side.
Can be increased to improve performance and stability with the cost of additional RAM requirements.
Helps to mitigate "tud_network_can_xmit: request blocked" warning message when running NCM device.

config TINYUSB_NCM_IN_NTB_BUFFS_COUNT
int "Number of NCM NTB buffers for transmission side"
depends on TINYUSB_NET_MODE_NCM
default 3
range 1 6
help
Number of NTB buffers for transmission side.
Can be increased to improve performance and stability with the cost of additional RAM requirements.
Helps to mitigate "tud_network_can_xmit: request blocked" warning message when running NCM device.

config TINYUSB_NCM_OUT_NTB_BUFF_MAX_SIZE
int "NCM NTB Buffer size for reception size"
depends on TINYUSB_NET_MODE_NCM
default 8192
range 1600 10240
help
Size of NTB buffers on the reception side. The minimum size used by Linux is 2048 bytes.
NTB buffer size must be significantly larger than the MTU (Maximum Transmission Unit).
The typical default MTU size for Ethernet is 1500 bytes, plus an additional packet overhead.
To improve performance, the NTB buffer size should be large enough to fit multiple MTU-sized
frames in a single NTB buffer and it's length should be multiple of 4.

config TINYUSB_NCM_IN_NTB_BUFF_MAX_SIZE
int "NCM NTB Buffer size for transmission size"
depends on TINYUSB_NET_MODE_NCM
default 8192
range 1600 10240
help
Size of NTB buffers on the transmission side. The minimum size used by Linux is 2048 bytes.
NTB buffer size must be significantly larger than the MTU (Maximum Transmission Unit).
The typical default MTU size for Ethernet is 1500 bytes, plus an additional packet overhead.
To improve performance, the NTB buffer size should be large enough to fit multiple MTU-sized
frames in a single NTB buffer and it's length should be multiple of 4.

endmenu # "Network driver (ECM/NCM/RNDIS)"

menu "Vendor Specific Interface"
Expand Down
8 changes: 7 additions & 1 deletion device/esp_tinyusb/include/tusb_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2019 Ha Thach (tinyusb.org),
* SPDX-FileContributor: 2020-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2020-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2019 Ha Thach (tinyusb.org),
Expand Down Expand Up @@ -173,6 +173,12 @@ extern "C" {
#define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME
#define CFG_TUD_BTH CONFIG_TINYUSB_BTH_ENABLED

// NCM NET Mode NTB buffers configuration
#define CFG_TUD_NCM_OUT_NTB_N CONFIG_TINYUSB_NCM_OUT_NTB_BUFFS_COUNT
#define CFG_TUD_NCM_IN_NTB_N CONFIG_TINYUSB_NCM_IN_NTB_BUFFS_COUNT
#define CFG_TUD_NCM_OUT_NTB_MAX_SIZE CONFIG_TINYUSB_NCM_OUT_NTB_BUFF_MAX_SIZE
#define CFG_TUD_NCM_IN_NTB_MAX_SIZE CONFIG_TINYUSB_NCM_IN_NTB_BUFF_MAX_SIZE

#ifdef __cplusplus
}
#endif

0 comments on commit 80ecd79

Please sign in to comment.