-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix NCM state on restart #3438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix NCM state on restart #3438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes NCM device notification state handling during interface restart and refactors buffer management for improved performance. When an NCM interface is deactivated and reactivated, the link state notification is now correctly sent. Additionally, the buffer management has been optimized by replacing linear search operations with circular buffer implementations.
- Fixes notification state handling to ensure link state updates are sent when interface is reactivated
- Refactors recv_ready_ntb and xmit_ready_ntb from linear arrays with memmove operations to circular buffers for O(1) operations
- Adds LED blinking functionality to the example application with USB device state indicators
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/class/net/ncm_device.c | Implements circular buffer management for recv/xmit ready buffers with head/tail/count tracking; fixes notification state reset when interface is deactivated to ensure proper link state updates on reactivation; corrects log message in xmit_get_next_ready_ntb |
| examples/device/net_lwip_webserver/src/main.c | Adds LED blinking task with different patterns for device states (not mounted, mounted, suspended) and implements USB device callbacks (mount, unmount, suspend, resume) to control blink intervals |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Size Difference ReportBecause TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds. Note: If there is no change, only one value is shown. Changes >1% in sizeNo entries. Changes <1% in size
No changes
|
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
Signed-off-by: HiFiPhile <[email protected]>
2a19aec to
bb94472
Compare
Fixed notification state handling so that when the interface is deactivated and reactivated, the link state update notification is correctly sent. Fix NCM interface stop transmitting packets after ifconfig down+up on Linux side (STM32H7 DWC2) #3436
Refactored both
recv_ready_ntbandxmit_ready_ntbbuffers inncm_interface_tto use circular buffers, adding head, tail, and count fields for each, replacing the previous linear search and memmove approach.