Skip to content

feat(server): make server alloc-free on bare_metal, and surface inbound non-SD unicast#131

Closed
JustinKovacich wants to merge 3 commits into
feature/phase21_api_symmetryfrom
feat/no-alloc-bare-metal
Closed

feat(server): make server alloc-free on bare_metal, and surface inbound non-SD unicast#131
JustinKovacich wants to merge 3 commits into
feature/phase21_api_symmetryfrom
feat/no-alloc-bare-metal

Conversation

@JustinKovacich

Copy link
Copy Markdown
Contributor

Note: Supersedes #124. #124 was accidentally merged into phase21 with a merge commit during a stacking operation; the merge was reverted (phase21 force-reset, no merge commit on the branch) and this PR re-opens the same feat/no-alloc-bare-metal branch as a review unit in the linear stack. Full review history + approval live on #124.

Makes the server feature alloc-free by default and adds a callback for non-SD SOME/IP unicast datagrams.

No-alloc support and feature gating

  • server is alloc-free by default; allocator-backed conveniences gated behind _alloc. Default handle types switch between Arc<T> and &'static T by allocator availability.
  • StartedLatch is Arc<AtomicBool> on alloc builds, &'static AtomicBool on no-alloc.

Non-SD SOME/IP datagram callback

  • Optional non_sd_observer (NonSdRequestCallback) invoked for every non-SD unicast datagram.

Subscription handling for bare-metal/no-alloc

  • SubscriptionHandle returns core::future::Ready instead of boxed futures on no_std.

API

  • Exports NonSdRequestCallback under the server feature.

Stack: this ← #127 (PR 0) ← #129 (PR 1).

Feliciano Angulo and others added 3 commits June 8, 2026 10:51
…estCallback

Two related changes to land the no-alloc bare-metal server path:
1.  drop _alloc from the server feature and gate every alloc usage (use alloc::sync::Arc, Wrappable handles, SocketOptions, sd-protocol import, run_inner's 64 KiB vec! and new_with_deps/new_passive_with_deps' Arc-wrap constructors) so client+server+bare_metal builds with zero __rust_alloc/__rg_alloc symbol references. The Server struct's started latch is now a feature-gated StartedLatch type alias (Arc<AtomicBool> under _alloc, &'static AtomicBool on bare metal) passed through ServerStorage; the H/Hsd/Hep default generics use cfg'd DefaultSocketHandle/DefaultSdStateHandle/DefaultEventPublisherHandle aliases so Arc names don't need to resolve under no-alloc. StaticSubscriptionHandle returns core::future::Ready instead of alloc::boxed::Box::pin (the lock closures are synchronous).
2. Add NonSdRequestCallback fn-pointer on ServerStorage/Server, threaded through run_with_buffers/run_combined/recv_loop, invoked in place of the historical 'non-SD ignored' branch — surfaces method requests / fire-and-forget calls (e.g. halo's HWP1* requests) to the consumer FFI without requiring a ChannelFactory-backed ServerUpdates channel.
add non-SD observer support and no-alloc witness tests
Co-authored-by: Justin Kovacich <32140377+JustinKovacich@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the server feature to be allocator-free by default for bare_metal/no_std usage, and adds an optional callback to surface inbound non-Service Discovery (non-SD) unicast SOME/IP datagrams to consumers.

Changes:

  • Make bare-metal SubscriptionHandle operations allocation-free by returning core::future::Ready instead of boxed futures.
  • Add NonSdRequestCallback / non_sd_observer plumbing from ServerDeps through the server runtime receive loop, plus tests that witness the callback behavior.
  • Add a new no_alloc_server_witness integration test and register it in Cargo.toml as a no-alloc CI gate.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/no_alloc_server_witness.rs New no-alloc runtime witness for StaticSubscriptionHandle hot paths.
tests/bare_metal_server.rs Adds non_sd_observer initialization and callback behavior tests.
tests/bare_metal_e2e.rs Updates ServerDeps construction to include non_sd_observer: None.
src/server/subscription_manager.rs Removes heap allocation from bare-metal subscribe/unsubscribe by returning Ready.
src/server/runtime.rs Threads non_sd_observer into recv_loop and invokes it for non-SD unicast datagrams.
src/server/mod.rs Introduces NonSdRequestCallback, StartedLatch abstraction, and carries observer/latch through storage and run futures.
src/lib.rs Re-exports NonSdRequestCallback under the server feature.
examples/embassy_net_client/src/main.rs Updates example deps struct to set non_sd_observer: None.
examples/bare_metal_server/src/main.rs Updates example deps struct to set non_sd_observer: None.
Cargo.toml Removes _alloc implication from server feature; registers no_alloc_server_witness test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server/mod.rs
Comment on lines +649 to +652
#[cfg(feature = "_alloc")]
type StartedLatch = Arc<AtomicBool>;
#[cfg(not(feature = "_alloc"))]
type StartedLatch = &'static AtomicBool;
Comment thread src/server/mod.rs
Comment on lines +642 to +643
/// payload is the full raw datagram bytes; the caller is responsible
/// for re-parsing the SOME/IP header (and applying any E2E check) on
Comment on lines +468 to +474
drive_until(|| {
OBSERVED_SOME
.get()
.and_then(|m| m.lock().unwrap().clone())
.is_some()
})
.await;
Comment on lines +559 to +566
let observed = OBSERVED_NONE
.get()
.and_then(|m| m.lock().unwrap().clone());
assert!(
observed.is_none(),
"callback must NOT fire when non_sd_observer is None; got {:?}",
observed
);
@JustinKovacich

Copy link
Copy Markdown
Contributor Author

Folded into main via the 0.8.0 consolidation (#138). Content verified present in main; closing and deleting the branch as part of post-0.8.0 cleanup.

@JustinKovacich
JustinKovacich deleted the feat/no-alloc-bare-metal branch June 29, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants