Since we may receive a BASE often, some of the log statements
could end up flooding the log. Add RATELIMIT to those that either
directly discards the BASE or logs as WRN.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds checks for the number of subgroups as well as the size
of the metadata when we parse the BASE, in the case that the
bt_bap_scan_delegator_mod_src_param does not support the number
of subgroups or the metadata.
If the number of subgroups is the issue, then we discard the BASE
as we would otherwise write incorrect data to the receive state.
If the size of the metadata is the issue, then we just don't write
it to the receive state, as that is not mandatory as per BASS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the special handling of metadata_len == 0 to keep existing
metadata, as this prevents applications from actually setting the
metadata_len to 0.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use #include <> instead of #include "" to include a header file which path
is not relative to the directory path of the file emitting the #include
directive.
This change was made running scripts/check_quoted_includes.py script
proposed in https://github.com/zephyrproject-rtos/zephyr/pull/112135
with the Linux shell command below and manually selecting the applicable
changes:
$ ./scripts/check_quoted_includes.py -w subsys/bluetooth/host/classic/
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
The interval validation in valid_adv_ext_param() capped the maximum
interval at 0x4000 (the legacy advertising limit). Extended advertising
uses a 24-bit interval field with a permitted range of 0x000020–0xFFFFFF
per Core Spec Vol 4, Part E, 7.8.53. Use BT_HCI_LE_PRIM_ADV_INTERVAL_MAX
when BT_LE_ADV_OPT_EXT_ADV is set, and remove the now-unused
adv_interval_max_get() helper.
Assisted-by: Augment:claude-sonnet-4.6
Signed-off-by: Sharon Lin <slin@atmosic.com>
Change the registration of the PA sync callbacks to be
more lazy (only do it when we are trying to do any PA
related activities).
This not only defers such operations until they are useful,
but also helps reduce noise when using the LE Audio shell.
This also reduces the scope of per_adv_sync_cb as well
as moving the related functions to a single guard.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added help text for the BT_CONN, BT_AUDIO_RX, and BT_AUDIO_TX options.
While these are promptless, they are worth explaining and should show up
in Kconfig reference doc page.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add additional check to avoid printing the same error
for each SDU. If the SDU length changes, then it is still
printed every time to notify the user about
such behavior from the remote (useful for debugging), so it
is only if the SDU size is wrong and does not change that
we rate limit it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The member_params variable can be quite large, and scales with
CONFIG_BT_MAX_CONN. Make it static to avoid requiring a large
stack size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
acquire_mutex() took a module-global semaphore on every lock, but that
lock is only needed to serialize the lazy auto-init of a statically
initialized mutex. Push it into to_posix_mutex() with a double-checked
re-test so an already-initialized handle is acquired with no global
serialization, reading owner/type/lock_count locklessly as
pthread_mutex_unlock() already does. This removes an SMP scalability
bottleneck and a single-core priority-inversion window.
On qemu_cortex_a53 (deterministic icount), 1M uncontended lock/unlock
pairs drop from 817 to 508 cycles/pair (~38%).
Add a regression test for locking a PTHREAD_MUTEX_INITIALIZER mutex.
Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Major rework of the ICBMSG ipc service backend:
1. User callback is called from the mbox interrupt context.
Since RX holding functionality is supported it is possible to
postpone data processing to the thread context and limit the
time spent in the interrupt context to a minimum.
2.Extracted buffer allocation into separate file (heap)
Buffer can now be allocated from interrupt context as well.
3.Changed control path.
Instead of sending messages using icmsg, lightweight queue is used.
Each direction has producer and consumer queue. Each queue has n
(typically 16) byte slots. Producer is writing an index of the buffer
where new message can be found into the next free slot. Receiver is
reading from the producer queue and when buffer is processed then its
index is written to the next free slot in the consumer queue.
TX side, after each sending, is performing a garbage collection by
reading slots from the consumer queue and freeing the buffer. With this
approach producer queue is written only by the TX side and read by RX
side and consumer queue is written by the RX side and read by the
TX side. Additionally, queue supports 2 priority levels. Consumer is
first reading high priority messages.
Rework significantly reduces code size (2,5-4kB) and increases
performance. It also allows to send messages from any context and
reduced round trip time since receiver can respond directly from the
receive callback.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Assisted-by: Cursor:auto
Since we are reusing the cpuhold thread objects, we must join
those threads to make sure the spawned threads have actually
stopped. The situation is further compliacted due to those
cpuhold threads are running with interrupt disabled inside
cpu_hold(). This means the IPI sent by k_thread_abort() is not
being processed to abort the thread. And there is no thread
swapping where the scheduler checks if a thread is going away.
Since k_thread_abort() is rather meaningless here and we must
do k_thread_join(), simply replace abort with join.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit resolves -Wpointer-sign warnings in the Bluetooth Mesh
subsystem by updating comp_data_pages[] to store a const char *path and
updating bt_mesh_k5 to natively accept const char *p, avoiding the need
for pointer casts.
This is part of a larger effort to fix pointer-sign warnings across the
codebase in preparation for dropping -Wno-pointer-sign globally.
Related to #8921
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
remove lookup from rejoin, as no longer needed
as we only use it then using addresses that are
already on the iface.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
When I set the socket option
ZSOCK_IPV6_ADD_MEMBERSHIP or ZSOCK_IP_ADD_MEMBERSHIP
I expect that that setting is valid for at least the time
that the socket is open. As a udp does not close
when the iface that it is attached to, goes down,
it should not be removed from the iface on down.
Just with the socket api I have no way to detect that
the multicast membership no longer exists and then
also no way to recover.
Therefore we preserve the multicast membership on iface down
and then just send a leave without removing the membership from the
iface. This way the membership is still valid and will rejoin when the
iface comes back up.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
leave mcast groups in mdns_test_reinit_with_stale_slot,
no longer assume the mdns groups are left on
net_if_down.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The last callers of bt_testing_tx_tid_get() were removed by
commit 28be8909a6 ("Bluetooth: host: remove TX thread"), which also
changed the function to return the system workqueue thread. That return
value has in turn been stale since
commit f101976e31 ("Bluetooth: Host: Run tx processor on its own thread")
moved TX processing to a dedicated thread whenever
CONFIG_BT_TX_PROCESSOR_THREAD is enabled (the default).
Instead of fixing the return value of a function nobody calls, remove
it, together with the leftover extern declarations in the bsim tests.
The att/pipeline test enabled CONFIG_BT_TESTING solely for this
function, so drop it there. The att/sequential test claimed the same in
a comment, but actually also depends on CONFIG_BT_TESTING for
bt_conn_suspend_tx(), so only the stale comment is corrected there.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-fable-5
PSA_WANT_ALG_SHA_256 is defined inside an "if PSA_CRYPTO" block, so
selecting it without enabling PSA_CRYPTO aborts Kconfig on TF-M targets,
where SECURE_STORAGE (and thus its implicit PSA_CRYPTO select) is
unavailable.
Assisted-by: Cursor:claude-opus-5
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If we are pending PAST, we do not have a pa_sync object to delete, but
we should not rejec the request to stop the sync, as that indicates
that we should just stop waiting.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Normalize the signed terminal sequence ID before comparing it with
unsigned session counters.
Encode its magnitude as the iPerf ACK datagram total and derive the
public received-packet result from total and loss.
Track recent missing sequence IDs so late packets only reconcile
genuine gaps. Duplicates can no longer mask real packet loss.
Add loopback regressions for trailing loss, reordered gap recovery,
and duplicate packets.
Assisted-by: Codex:GPT-5
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
A multicast packet the sending socket should also receive is cloned in
net_try_send_data() and passed to net_recv_data(). The clone is taken
before the L2 header is written, yet is queued without
net_pkt_set_l2_processed(), so the receive path still offers it to the
L2. An L2 that has a header of its own then reads the network header as
a link layer one and drops the packet:
process_data: Packet 0x446de8 discarded by L2
IP_MULTICAST_LOOP, and CONFIG_NET_INITIAL_IPV4_MCAST_LOOP which defaults
to y, therefore have no effect on an Ethernet interface: a sender never
receives its own multicast.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add a readiness check before using the STMESP logging frontend.
If the STM device is not ready, skip frontend usage to avoid invalid access
and improve robustness during early boot or misconfiguration.
Signed-off-by: Alejandro Lara Raigada <Alejandro.Lararaigada@analog.com>
Two CCC callbacks used K_FOREVER instead of MUTEX_TIMEOUT
as the mutex timeout. Change to be consistent and to avoid
blocking everything in case that it could not lock the mutex.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
RFC 6762 Section 8.3 requires the startup announcement to contain all
of a responder's newly registered resource records, not just address
records -- but send_announce() only ever sent A/AAAA records, never a
registered DNS-SD service's PTR/SRV/TXT records.
Add send_dns_sd_announce(), called from send_announce()'s per-family
loop when CONFIG_MDNS_RESPONDER_ANNOUNCE_DNS_SD is enabled: sends one
extra packet per DNS-SD service (registered via
DNS_SD_REGISTER_SERVICE() or mdns_responder_set_ext_records())
alongside the existing address-only announce, reusing
dns_sd_handle_ptr_query() (already used for direct query responses).
Disabled by default to keep startup announcements smaller/less
frequent for devices that don't need it -- clients that actively
query for services (e.g. avahi-browse) are unaffected either way,
since normal query/response handling already answers DNS-SD queries
regardless of this option.
Test: tests/net/lib/mdns_responder_probe/ registers one external
DNS-SD record, drives the responder through a normal (non-racing)
bring-up, and confirms at least one of the resulting announce packets
is a PTR answer for that service. Verified as a genuine regression
test: reverting the two send_dns_sd_announce() call sites reproduces
the exact "no announce packet included a PTR answer" failure.
Depends on the v4_svc/v6_svc probe-sizing fix in this branch's parent
commit: without it, CONFIG_MDNS_RESPONDER_PROBE fails independently of
this feature (probing itself can't complete), which would make this
test fail for an unrelated reason.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Robert Rozelle <rwrozelle@gmail.com>
Remove the pa_sync_state parsing from
cmd_bap_scan_delegator_bis_synced as it was not used by the command,
and caused the parsing of the bis_synced value to fail.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the sync_state_get_or_new we should compare with the src_id instead
of the pointer. If the receive state was added locally via
cmd_bap_scan_delegator_add_src then the src_id is assigned, but not
the pointer. This caused any locally added receive states to be
unavailable, and thus causing error prints when using the
shell module.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Mark static variables bip_app, rfcomm_server, and l2cap_server with
ZTESTABLE_STATIC to allow them to be accessed from unit tests while
maintaining static linkage in production builds.
Signed-off-by: Cheng Chang <cheng.chang@nxp.com>
Fix typo in `BT_AVDTP_UNSUPPORTED_CONFIGURATION` constant name.
The constant was misspelled as `BT_AVDTP_UNSUPPORTED_CONFIGURAION`.
Update the enum definition in `avdtp.h` and all references in `a2dp.c`
to use the correct spelling.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Rather than having the timeout struct embedded in the submission, which
takes up significant space, use a common Kernel timeout entry that is
shared and managed through a custom RTIO timeout queue.
Adds additional testing around the management of this queue to ensure
that timeouts are ordered properly and that cancellations are best
effort handled by the timeout queue.
The timeout queue itself is now a singleton iodev that takes
submissions rather than baked into the framework.
Assisted-by: claude:opus-4.8
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>