When creating a BAP broadcast source with bt_bap_broadcast_source_create
only the subgroup information is stored in the streams and the remaining
BIS specific information is not stored in the stream->codec_cfg,
which it should.
Fix is to store bis specific information also in stream codec config.
Updated broadcast source BSIM test to verify above usecase.
Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
The polling properties are a period in us but are named as "-rate" right
now, which would imply that that's a frequency. Rename them to
"period-us" to make that unambiguous.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Returning a status code will allow the application developer
to detect logic issues.
We consider this as not breaking the API.
If `-Werror -Wunused-result` is enabled, the application developer needs
to validate the return code.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Callbacks can only be registered once. Otherwise the slist
will become circular.
In this commit we have choosen to ignore the second registration
call if the callback has already been registed. The alternative
is to trigger an assertion. That doesn't work if the assertions
are turned off.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This allows us to use functionality provided by slist.
First use case: Avoid adding an element twice.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Allow to protect the data part of each NVS item with a 32-bit CRC.
This uses 4 more bytes per NVS item.
Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
While forwarding a multicast packet decrement hop limit in a common net
buffer. Also, packets with hop limit equal to 0 should not be forwarded.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cfg_meta_get_pref_context
as absence of pref context in BAP implicitly means a unspecified
for LC3.
In the case that it is absent BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED
is the returned value.
While the metadata for codec cfg and codec cap are similar,
this only applies for codec cfg as per BAP.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cap_get_max_codec_frames_per_sdu
as absence of max codec frames per SDU in BAP implicitly
means a single frame for LC3.
In the case that it is absent 1 is the returned value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cap_get_supported_audio_chan_counts
as absence of channel count in BAP implicitly means a single channel
for Lc3.
In the case that it is absent 1 is the returned value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cfg_get_chan_allocation as absence of
channel allocation in BAP implicitly means Mono.
In the case that it is absent,
BT_AUDIO_LOCATION_MONO_AUDIO is the returned value.
This commit also fixes the implementation of
bt_audio_codec_cfg_get_frame_blocks_per_sdu as it only applies to
LC3 (as per the BAP spec). It also adds additional testing of it
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding network interface status monitor function. Depending
on the interface operation state and change of the state
events are generated and handled by the function.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds implementation of the PTP thread that will
poll sockets descriptors and PTP Port's timeres for timeouts,
generate events and handle them and trigger STATE_DECISION_EVENT
handling when needed.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The STATE_DECISION_EVENT in PTP is a pivotal mechanism that
facilitates dynamic state management within the protocol,
allowing devices to adapt their operational states based on the BTCA's
recommendations and the health of the network.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduction of PTP stack's core functions responsible for
event generation and handling of these events. Events are generated
base on timeouts and/or PTP messages received via BSD sockets
assigned to a specific PTP Port. These function will be used
in PTP thread.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The commit adds functions that enable and disable PTP Port.
This is going to be used by event handling routine.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Timers are used to trigger message transmission and detect
inactivity of other PTP Clocks what should result in an action
of the PTP Port.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces routines for PTP message transmission.
It includes transmission of three types of messages (Announce,
Sync, Delay_Req) that should be send periodically depending
on the PTP Port's state.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduction of routines processing received PTP Management messages.
The processing is split into clock-oriented and port-oriented parts.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add handler for STATE_DECISION_EVENT it consists of following routines:
- state decision algorithm
- best timeTransmitter clock algorithm
- data sets comparison algorithm
Based on IEEE 1588-2019 section 9.3.3
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds routines for handling incoming messages
needed for correct operation of the PTP stack in end to end
mode with multicast operation mode.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Initial implementation of the clock adjustment and delay calculation.
Timestamp values used for calculations will be obtained from
proper PTP messages (Sync, Follow_Up, Delay_Req, and Delay_Resp)
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Foreign timeTransmitters are other PTP Clocks in a domain. They announce
their parameters via announce messages. PTP Ports should record
these foreign timeTransmitters.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces module responsible for sending and receiving
messages. It is based on BSD Sockets API.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add allocation of container used for TLVs and dummy functions for
preparing correct byte order of data. TLV stands for Type, Length,
Value, and it is extension of PTP messages that's used to transmit
extra information. This data is attached at the end of PTP message.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add functions preparing messages to network byte order before sending
and changing to host byte order after reception and before processing
by PTP stack.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add dynamic memory allocation for PTP messages. Memory allocation
is done with Zephyr's memory slab. It's size can be configured
with `PTP_MSG_POLL_SIZE` Kconfig symbol.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduces definition of structures for all types of PTP messages
defined in the IEEE 1588-2019 standard.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Based on IEEE 1588-2019 some of PTP Port states might not be used
if the option of 17.7 is implemented. This patch prepares state
machine implementation for such scenario.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Implement possibility to configure PTP stack in TIME_RECEIVER_ONLY mode.
This restrics stack behaviour and doesn't allow for any PTP Port
of the PTP Clock become a TimeTransmitter Clock.
The change includes:
- Kconfig option
- Additional field in `struct ptp_port` structure
- New state machine function for a timeReceiver-only PTP Port.
- Extra steps in PTP Clock and PTP Port initialization.
New finite state machine is based on the figure 31
in section 9.2.5 of the IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces PTP Clock and PTP Port structures
and API for initializing PTP Clock and PTP Ports. Configuration
options has been added as Kconfig symbols to configure parameters
of the Clock and Ports at compile time.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Datasets defined in the header file are going to be used
in PTP Clock's structure and PTP Port's structure. They
gather data into structures defined in IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The patch brings implementationof a state machine for full
PTP implementation. It returns new PTP Port's state based
on event that occured and previous state.
Based on the figure 30 in section 9.2.5 of the IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The header's file content is based on 5.3 section of
the IEEE 1588-2019 standard describing Precise Time Protocol (PTP)
used to synchronize devices in the network.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is an initial commit that introduces PTP library in the Zephyr.
It adds basic Kconfig symbols for enabling library, CMakeLists.txt
for compiling it, public header file, and initial PTP thread definition
and library initialization. Implementation of the functional PTP stack
will be introduced in following commits.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add returning timestamp of received packet in ancillary data buffer
in `msghdr` structure. This commit enables getting timestamp of
the received packet by calling `recvmsg()` function. The function
returns in the `msg_control` field timestamp if following criteria
are met:
- `CONFIG_NET_CONTEXT_TIMESTAMPING` is set
- `SO_TIMESTAMPING` socket option has `SOF_TIMESTAMPING_RX_HARDWARE`
option enabled for that socket
- driver used by sockets supports packet timestamping
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is the last commit of the set of patches that introduces
`SO_TIMESTAMPING` socket level optino in Zephyr. The patch
adds `SOF_TIMESTAMPING_RX_HARDWARE` and `SOF_TIMESTAMPING_TX_HARDWARE`
bitmasks. It can be extedned in the future to cover more timestamping
features. Currently the feature can be used with ptp_clock driver.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is next commit from the set of patches that brings to the
Zephyr, SO_TIMESTAMPING socket level option. It stores timestamping
option bitmask that can be transfered to the net_pkt.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is the first commit from the set of patches that brings to the
Zephyr, SO_TIMESTAMPING socket level option. This enables to pass to
the network driver information whether given network packet should
be timestamped or not.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Added incrementation of the packet reference count when puting
the packet on the queue used in tx timestamping thread. This fixes
an issue when user wants to access the packet data in the timestamp
callback context. Before the fix was introduced if sockets were used
packet has been unreferenced before execution reached timestamp callback
context.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The same way as `bt_hci_get_adv_handle` and `bt_hci_get_conn_handle` add
a function to get the handle of a periodic advertising sync.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
In the parse_recv_state we did not verify that we can handle all
the subgroups before we started parsing them.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add proper PSA_WANT kconfigs for TLS sockets and RSA key exchanges
when CONFIG_PSA_CRYPTO_CLIENT is set.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit add the proper PSA_WANT kconfigs which are required
to perform an RSA signature when a PSA crypto provider is
available in the system (i.e. CONFIG_PSA_CRYPTO_CLIENT is set).
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
When testing https://github.com/zephyrproject-rtos/zephyr/pull/72090/,
there is an issue found.
The change in the previous commit is to put all data sending
operations into the work queue context, and lock the current
AG before sending data.
And in change of #72090, the HCI TX thread is removed. All
sending sequence are happened in work queue context.
There is a possible problem when AG creates a SCO connection
by calling the function bt_conn_create_sco. Before the
function bt_conn_create_sco is called, AG will be locked to
avoid creating repeated SCO connection.
And the execution of the function bt_conn_create_sco
depends on the work queue. Because the HCI command of
function bt_conn_create_sco is sent in work queue context.
In the normal case, there is not any issue.
But there is a case that when the function
bt_conn_create_sco is being executed, there is a pending AG
TX waiting to be executed.
Once the work queue starts executing the handler, the AG TX
handler is executed first. Since the lock has been acquired
by other threads, the AG TX handler cannot acquire the lock.
As a result, the SCO connection creation fails.
Remove the AG lock from SCO creating. Instead, use a flag
to mark whether a SCO connection is be created.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Due to the sent callback of RFCOMM is changed, the
sending buf need to be primed waiting for the
previous one to be completed. Add a worker for
this purpose.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Due to the parameter `buf` has been removed by rfcomm,
update the prototype of channel sent callback hfp_hf_sent.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Due to the sending buf cannot be referred
by sending layer.
It is unsafe to use `buf` identification
for a transmission, because the buf may
have been newly transmitted when the
sent callback is triggered.
Now instead, when the send completion
callback is received, the upper layer
is notified that a transfer is completed.
If multiple bufs are sent at the same
time, there is no guarantee which buf
is completed when the sent callback
triggered. Therefore, it is recommended
that the caller transfers the next data
block after the previous transfer is
completed.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
There is a change (commit no.: 93d0eac834) that if
the `ref` of sending buf is not 1, the error code
`-EINVAL` will be returned from bt_conn_send_cb.
It causes the RFCOMM functionality cannot work
properly.
Remove the ref operation from the buf to be sent
to fix the issue.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Also any demand paging and page frame related bits are
renamed.
This is part of a series to move memory management related
stuff out of the Z_ namespace into its own namespace.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This is part of a series to move memory management related
stuff from Z_ namespace into its own namespace.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Adds calls to the set_src_ctrl of TCPC driver to enable and disable
the VBUS sourcing. If the TCPC doesn't support these functions,
no errors should be printed.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
When validating the parameters for broadcast reception start some
return statements were missing, they have been added, as well as
proper initialisation of a variable
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
If we are merging subgroup and BIS codec configuration data
for a codec other than LC3, then we just append them, but
did not properly update the length.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The 3-byte value suits the assigned number much better,
and also allows for less memory copies when getting and
setting the values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the "stream" part of the value and functions to
better fit with the name in the assigned numbers document.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
View buffers are now also a limited resource. Acquire them before
attempting to pull data. `CONFIG_BT_CONN_FRAG_COUNT` should be tuned on
a per-application basis to avoid this.
A possible optimization, that was present before, is to not create a
frag when the original buffer fits the controller's HCI size.
I prefer deferring this optimization to a future patchset.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
We can get rid of the view pool for SDU segments :)
We have to make the code slightly more complex :'(
The basic idea is always giving the original SDU buffer to `conn.c` for it
to pull ACL fragments from.
In order to do this, we need to add the PDU headers just-in-time.
`bt_l2cap_send_pdu()` does not add them before putting the PDU on the queue
anymore. They are added by `l2cap_data_pull()` right before the data leaves
`l2cap.c` for `conn.c`.
We also have to inform `conn.c` "out of band" of the real L2CAP PDU size so
it doesn't fragment across segment boundaries. This oob is the new `length`
parameter to the `.pull()` method.
This is the added complexity mentioned above.
Since SDU segmentation concerns only LE-L2CAP, ISO and Classic L2CAP don't
need this extra logic.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
We don't need the TX thread anymore.
Generalizing the pull-based architecture (ie. `tx_processor`) to HCI
commands makes it possible to run the whole TX path from the the system
workqueue, or any workqueue really.
There is an edge-case, where we call `bt_hci_cmd_send_sync()` from the
syswq, stalling the system. The proposed mitigation is to attempt to drain
the command queue from within `bt_hci_cmd_send_sync()`.
My spidey sense tingles however, and it would be better to just remove the
capability of calling this fn from the syswq. But doing this requires
refactoring a bunch of synchronous procedures in the stack (e.g. stack
init, connection establishment, address setting etc), dragging in more
work. I will do it, but in a later patch.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This API replaces `bt_l2cap_send()` and `bt_l2cap_send_cb()`.
The difference is that it takes the `struct bt_l2cap_le_chan` object
directly instead of a connection + CID.
We need the channel object in order to put the PDU on the TX queue. It
is inefficient to do a search for every PDU when the caller knows the
channel object's address and can just pass it down.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The current TX pattern in the host is to try to push a buffer through all
the layers up until it is ingested by the controller.
Since sending can fail at any layer, we need error-handling and separate
retry logic on pretty much all layers. That logic obscures the "happy path"
for people trying ot understand the code.
This commit inverts the control, in a way that doesn't require changing the
host or HCI driver API (yet):
Layers don't send buffers synchronously, they instead put their buffer in a
private queue of their own and raise a TX flag on the lower layer. Think of
it as a `READY` interrupt line that has to be serviced by the lower layer.
Sending is now non-blocking, rate depends on the size of buffer pools.
There is a single TX processing function. This can be thought as the
Interrupt Service Routine that will handle the `READY` interrupt from the
layers above.
That `tx_processor()` will then attempt to allocate enough resources in
order to send the buffer through to the controller. This allocation logic
does not block.
After acquiring all the resources, the TX processor will attempt to pull
data from the upper layer. The upper layer has to figure out which buffer
to pass to the controller. This is a good spot to put scheduling or QoS
logic in the upper layer.
Notes:
- user-facing API for tuning QoS will be implemented in a future patch
- this scheme could (and probably will) be extended to upper layers (e.g.
ATT, L2CAP CoC segmentation).
- this patch removes the `pending_no_cb()` memory optimization for
clarity/correctness. It might get re-implemented after a stabilization
period. Hopefully with more documentation.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Instead of allocating segments/fragments and copying data into them, we
allocate segments as "views" (or slices) into the original buffer.
The view also gives access to the headroom of the original buffer, allowing
lower layers to push their headers.
We choose not to allow multiple views into the same buffer as the headroom
of a view would overlap with the data of the previous view.
We mark a buffer as locked (or "in-view") by temporarily setting its
headroom to zero. This effectively stops create_view because the requested
headroom is not available.
Each layer that does some kind of fragmentation and wants to use views for
that needs to maintain a buffer pool (bufsize 0, count = max views) and a
metadata array (size = max views) for the view mechanism to work.
Maximum number of views: number of parallel buffers from the upper layer,
e.g. number of L2CAP channels for L2CAP segmentation or number of ACL
connections for HCI fragmentation.
Reason for the change:
1. prevent deadlocks or (ATT/SMP) requests timing out
2. save time (zero-copy)
3. save memory (gets rid of frag pools)
L2CAP CoC: would either allocate from the `alloc_seg` application callback,
or worse _steal_ from the same pool, or allocate from the global ACL pool.
Conn/HCI: would either allocate from `frag_pool` or the global ACL pool.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
`bt_conn_send_cb` used to allocate a TX context (K_FOREVER).
Instead, we now put the context in the userdata of the buffer.
This means that now this fn will never block and always succeed since the
tx_queue is a FIFO (infinite size). It just puts the buf on the queue.
The metadata is stored safely in there until we have acquired all the
necessary resources to send it to the controller without failing: TX
context and controller buffer.
I.e. when `bt_conn_process_tx` is called, that's when a TX context is
try-allocated and the contents of `buf->userdata` is moved into it.
The buffer is now ready to be sent to the lower layer.
`bt_conn_process_tx` will return -EWOULDBLOCK if it's not able to acquire a
TX context, this PR modifies `bt_conn_prepare_events` to respond to this by
also waiting on the TX context pool.
Unfortunately, this increases the required userdata size for any buffers
handed to `bt_conn_send_cb`. This will be fixed in a later commit.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
In case we want to immediately send empty Ack to server,
we should bypass all send queues.
This is required when we try to send Ack from callbacks
that happen from socket-loop context. On those cases
the Ack would have not been send because the callback
might be blocking the socket-loop while processing
a request (like write callbacks).
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The `LOG_BACKEND_FORMAT_TIMESTAMP` Kconfig currently depends on
a list of hardcoded backends.
Let's modify it to depend on an intermediary Kconfig
`LOG_BACKEND_SUPPORTS_FORMAT_TIMESTAMP` instead, which can be
selected by a OOT log backend.
Updated all exisitng supported backends to select this new
Kconfig.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Add an option to reset gcov counters before running tests.
This ensures that only code lines triggered by test itself are counted in
the coverage report and all the board initialization code and pre-test
bootstrap is not counted. This is useful when, for example, you are
testing code that is also executed during bootup
Test Plan:
west build -p always -b qemu_x86_64 tests/ztest/base/ -- \
-DCONFIG_COVERAGE=y -DCONFIG_COVERAGE_GCOV=y -DCONFIG_COVERAGE_DUMP=y \
-DCONFIG_ZTEST_COVERAGE_RESET_BEFORE_TESTS=y
ninja -Cbuild run | tee log.log
Signed-off-by: Roman Studenikin <srv@meta.com>
Ability to reset gcov counters allows better isolation of tests
coverage. Specifically it allows to:
1. Not include counters for any code that was executed prior running the
test, which includes all the code executed during the board boot.
2. Run multiple tests without firmware reload by resetting counters
between each.
Signed-off-by: Roman Studenikin <srv@meta.com>
If the length of the string literal reserved for the serial number
descriptor is odd, the string is not used because its length is always
even and therefore one character longer. Fix this by using the shortest
length for the copy.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
If the new encryption state is the same as the old one, there's no point in
doing additional processing or callbacks. Simply log a warning and ignore
the HCI event in such a case.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The drivers should be independent after the move to the new HCI driver
API. Having them as a choice also has unexpected consequences with some
drivers being unexpectedly enabled.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Update the native controller to the new HCI driver API. The devicetree
node is placed under existing `radio` nodes, which seemed like the most
intuitive option.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Add support for HCI drivers which use the newly defined HCI driver API.
Since Zephyr (currently) only supports a single HCI driver instance,
boards are expected to indicate the instance using a new devicetree
chosen property `zephyr,bt_hci`.
In order to maintain compatibility with not-yet-converted drivers the
code has been placed behind `#if DT_HAS_CHOSEN(zephyr_bt_hci)`
conditionals.
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
https://github.com/zephyrproject-rtos/zephyr/pull/72674 fixed
a bug where this configuration did not work.
Now that this configuration is tested, we should mark it
as supported.
The timeout check that was present in the code before
was useless and was not working because the check was
run before a default timeout of 0 was converted to a timeout.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
ull_adv_sync_pdu_set_clear does pretty much everything, causing
it to be very complex and awkward to use. In addition, it only handles
a single PDU, meaning callers have to handle the chain.
It has been replaced with simpler, more complete functions for handling
the relevant operations
Fixed issues include:
- Fragmentation of adv data over HCI is now decoupled from PDU
fragmentation, fixing HCI/DDI/BI-13-C, LL/DDI/ADV/BV-26-C and
LL/DDI/ADV/BV-55-C
- Adding BigInfo now preserves the PDU chain
- Enabling periodic advertising with ADI on would sometimes fail
due to insufficient space in a single PDU to add ADI
Signed-off-by: Troels Nilsson <trnn@demant.com>
These macros tend to be defined by too many headers.
Let's guard these definition with ifdefs to avoid
redefining them to practically the same.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
that utilizes the fact that the ldpc recovery matrix is triangular and only
stores the half with non-zero values.
This implementation is hopefully going to make forward error correction
usable on lower memory devices.
Signed-off-by: Lucas Romero <luqasn@gmail.com>
to no longer be a long-lived status variable because we already map it into
is_active and this reduces the number of states the transport can be in.
It also helps us prepare for being able to plug in more decoders by
removing implementation specific bits from the general transport interface.
Signed-off-by: Lucas Romero <luqasn@gmail.com>
Add modem pipelink module which exposes modem pipes globally.
The pipelink module implements a callback to inform when a
pipe becomes available to use by whichever modem is attached
to it. This could be a shell, or a network interface.
The module aims to allow modem drivers to be split into modules,
and allowing applications to implement their own custom logic
without altering the modem drivers.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
If network socket tracing is enabled, then the system will track
various socket API calls for usage.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Replaced tcp_out() with tcp_out_ext() when sending
SYN during tcp connect, so we can intercept error value,
beacuse in such case the packet would not be sent at all
and the stack would not trigger any mechanism to flush
this context so it ends up leaking. These scenarios can
arise when the underlaying interface is not properly
configured or is disconnected. The conn is marked to be
closed and is closed before exiting tcp_in().
Since we can now identify this case we can also exit
early in the net_tcp_connect() function and not wait
for any timeout.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
This commit fixes the issue where a serialization
error was reported after properly sending a data with 'icbmsg' backend.
The icbmsg send function's return code is set to
the sent data's len as in other backends.
The related docs were fixed and updated.
Signed-off-by: Piotr Koziar <piotr.koziar@nordicsemi.no>
Add descriptions for recently introduced IPv4 and IPv6
connectivity events to the net event monitor.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
conn_mgr now fires:
- NET_EVENT_L4_IPV4_CONNECTED
- NET_EVENT_L4_IPV4_DISCONNECTED
- NET_EVENT_L4_IPV6_CONNECTED
- NET_EVENT_L4_IPV6_DISCONNECTED
These events track whether there are any ready ifaces offering
specifically IPv4 or specifically IPv6 connectivity.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Don't track up/down blame separately.
Instead, track a single last-blame iface.
Don't track blame iface inside set_ready.
Instead, track directly inside handle_update.
These two changes will simplify the addition
of blame for IPv4- and IPv6-specific events.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Instead of incrementing and decrementing global counter,
just recompute the ready-count from scratch every time
conn_mgr_mon_handle_update is called.
This will simplify the introduction of additional ready count types.
This should have no externally observable impact on the behavior of
conn_mgr.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
In case of ACD Probe/Announcement, all we need is to generate ARP
packet, we don't really want any cache entries to be created or searched
for. There was a bug, that a cache entry was created for the
Announcement sent, resulting in skipped ARP packet generation and
malformed packet being sent by the ACD module.
Therefore, simplify all this, by simply returning early in case of
conflict detection packets.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The autoconf module can now reuse generic address conflict detection,
which was added for all address types.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a conflict was detected on a DHCP-assigned address, send a
Decline message to the server and start over.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case IPv4 conflict detection is enabled, monitor network events to
determine whether IPv4 address is ready to use or not, so that the
library returns only after the network setup is fully complete.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Connection manager needs to monitor ACD events as well to determine
whether a preferred IPv4 address is available.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add support for IPv4 conflict detection, as specified in RFC 5227.
The new feature is optional and disabled by default.
Address conflict detection was implemented as a part of the IPv4
autoconf feature can be generalized to be available for all address
types.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The VDED was adding the channel information per clone. But it could be
done in the original buffer. This commit fixes that by adding the
channel information to the original buffer and not for each clone. As a
result, we have a more straightforward VDED execution with fewer copies.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
Add a symbol to enable device power state constraints this
saves resources when this feature is not needed.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Declare power state constraints for a device in devicetree.
It allows a map between device instances and power states that disable
their power. This information is used by a new API
(pm_policy_device_power_lock_put/get) that automically set/release
pm state constraints.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Make call to de-initialize disk in fatfs_unmount(). This will permit the
disk to be reinitialized when it is mounted with fatfs_mount().
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Add DISK_IOCTL_CTRL_DEINIT ioctl command to disk subsystem. When
disk_access_ioctl() is called with this command, the disk will be
de-initialized. After this IOCTL completes, the disk can safely be
reinitialized.
Fixes#60628
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Add DISK_IOCTL_CTRL_INIT IOCTL to initialize a disk. This IOCTL is
intended to replace disk_access_init() for new applications, but
disk_access_init() is kept for legacy compatibility. The INIT IOCTL is
added to better match the path that will be used for disk
de-initialization. Like the disk_access_init() calls,
DISK_IOCTL_CTRL_INIT calls are reference counted
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Reference count initialization calls for disks. This changes the
behavior of the disk_access_init() function, such that disks will no
longer be initialized again if the first disk access init call
succeeds.
Disk access is reference counted in preparation for supporting disk
de-initialization, where a balanced number of disk de-initialization
calls with disk initialization calls will de-initialize the disk.
Also, remove code in disk drivers that was already checking against
duplicate disk_access_init() calls.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit moves ELF loading and linking code to separate files. This
is done to make the code more manageable and to make it easier to add
new features in the future.
No functional changes are introduced by this commit, except for a few
static functions now made public to allow this file split to occur.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Move all memory management code to a separate file, llext_mem.c, to
allow for better separation of concerns and to make the code more
readable.
No functional changes are introduced by this commit.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This patch moves the initial checks performed on the ELF file, that were
split between llext_load() and do_llext_load(), to the newly defined
llext_load_elf_data() function.
This way:
- only one function deals with ELF internal data checks;
- do_llext_load() is reduced to a list of tasks;
- llext_load() only focuses on the extension management.
One totally misplaced line initializing the number of symbols has been
moved to llext_count_export_syms().
No functional change except that the `struct llext` allocation may be
performed unnecessarily if the ELF file is not valid.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Add llext_alloc(), llext_aligned_alloc() and llext_free() wrapper
functions to manage memory allocation and deallocation from the llext
heap. Also add a helper to free all memory regions allocated by an
extension.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Use the compatible kconfig option so that for the simulated
nRF54L15 we build the same code as for the real platform.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
For the Nordic HW, the BT_CTLR_DATA_LEN_UPDATE_SUPPORT
does not require CCM HW enabled, hence support Data Length
Update if Encryption Support is disabled.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In some nRF54 devices, DATAWHITEIV was renamed to
DATAWHITE,
and the CRCCNF SKIADDR field was renamed OFFSET.
The nrf HAL hid this change internally,
so let's use it so we don't need to ifdef these
in the Bluetooth Controller HAL code.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add preliminary support for nRF54L15 SoC. This commit does
not support Controller Random Number Generation and
Controller Cryptography (AES-128 encryption) commands, nor
does it support encrypted connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use NRF_RTC and NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk instead
to prepare towards using configurable use of RTC and Radio
hardware defines.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add unit tests to cover explicit LLCP error code check and
cover the same in the Controller implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A Host shall consider any error code that it does not
explicitly understand equivalent to the error code
Unspecified Error (0x1F).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce BT_CTLR_CRYPTO_SUPPORT so that preliminary port to
support nRF54L15 SoC can be upstreamed without encryption
support.
ENTROPY_GENERATOR now selected when BT_CTLR_CRYPTO enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When CP has a secure channel active, it should never receive a
REPLY_CCRYPT or REPLY_RMAC_I. Since these responses change the SC state,
let's also make sure that they are accepted only when they are
expected: in response to commands CMD_CHLNG and CMD_SCRYPT respectively.
Reported-by: Eran Jacob <eran.jacob@otorio.com>
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
This commit adds host support for the Path Loss Monitoring
feature see Bluetooth Core specification, Version 5.4,
Vol 6, Part B, Section 4.6.32.
Limited logic is required, just adding a wrapper around the
HCI command and callback for HCI event.
Add new zone - BT_CONN_LE_PATH_LOSS_ZONE_UNAVAILABLE, to
convert 0xFF path loss to a useful zone.
Add new Kconfigs and functionality to the bt shell.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
The existing code in the cap_stream.c that handled the
check before calling CAP initiator unicast functions
seemingly did not work for x86 targets such as native_sim
or native_posix.
Modified the check so that IS_ENABLED is used directly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Introduced temporary variables `buf0_xor` and `buf1_xor` to store
XOR results and added an explicit cast to `uint16_t` for
the `*len` variable.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Correct the boundary condition in `fcb_put_len` function to
properly include `FCB_MAX_LEN` and change the #define to address
the potential flaw where `CHAR_MAX` might be treated as unsigned by
the compiler flag `-funsigned-char`, which would yield `FCB_MAX_LEN`
to 0x7fff instead of 0x3fff.
Fixes#73868
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
The assert was verifying that the current sensor address was greater
or equal than the start of the iterable section - 1 which isn't quite
right as the start is inclusive.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Moves the rtio_ prefixed lockfree queues to sys alongside existing
mpsc/spsc pbuf, ringbuf, and similar queue-like data structures.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Previously the schedule_next_timeout() function was feeding the hardware
watchdog irrespective of whether or not it was started. This is now
fixed.
Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
The simulated targets support the same power levels as the
real targets. Let's correct the kconfig dependencies
accordingly.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
When we receive CoAP packets, it is in input buffer
that is size of NET_IPV6_MTU.
So in reality, we can handle bigger Block-Wise writes
than CONFIG_LWM2M_COAP_BLOCK_SIZE.
So if parsing of CoAP packet has passed, continue
with the same block-size instead of going to default.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
PM_DEVICE is not attached to system managed device power management.
It is a very common use case targets with device runtime power
management that don't want system device power management enabled.
We introduce a new symbol (PM_DEVICE_SYSTEM_MANAGED) to explicit
control whether or not system device power management should be
globally enabled.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Remove device pm path when there is no is no power state in DT with
device pm enabled. This basically does the same thing that was done
by PM_DEVICE_RUNTIME_EXCLUSIVE.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Make it possible to disble device power management individually per
power state. This allows targets tuning which states should
(and which should not) trigger device power management.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>