Allow configuring MTU for CMUX.
Some AT manual and specification define this as a
frame size. Linux ldattach default to 127 bytes,
3GPP TS 27.010 defaults to 31.
We should limit our CMUX frames to a size that
remote end is capable of handling.
Linux silently drops oversized frames.
Also, remove MODEM_CELLULAR_CMUX_MAX_FRAME_SIZE as
this was only limiting a buffer sizes, and resulted
CMUX frames to be capped to same value.
Use MODEM_CMUX_WORK_BUFFER_SIZE and MODEM_CMUX_MTU instead.
Also rename CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZES to
CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZE as it is now
only used as a Chat module. DLCI pipes use
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Use `UINT_TO_POINTER` to convert a number to pointer.
Use `POINTER_TO_UINT` to get a number from a pointer.
Fixes#87527.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
When the GATT server is enabled the proxy advertiser
server need to be stopped. This solved a bug where the
Mesh Proxy Service is not restared.
This fix is done to fix several failing PTS test that
was failing when CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE
was enabled. Calling the stop_proxy_adv was left out
in a prevouis commit when doing code cleanup.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
The Generic Provisioning protocol requires that a transaction must be
acknowledged before the next Generic Provisioning PDU is processed
(section 5.3.3, MshPRT_v1.1).
In the current PB-ADV implementation, if there is an ongoing transaction
(link.tx.adv points to a valid advertisement), any received Generic
Provisioning Start and Continuation PDUs are ignored.
This creates a scenario where a remote device misses the Transaction
Acknowledgment PDU and retransmits the last PDUs, but they are ignored
by the local device because the local device has already started sending
the next Provisioning PDU.
In particular, in the observed failure, the Provisioner missed the
Generic Transaction Acknowledgment PDU during the transmission of the
Provisioning Data PDU.
This commit modifies the processing logic for Generic Provisioning Start
and Continuation PDUs by checking if the received PDU has already been
received. If so, it attempts to re-send the Generic Transaction
Acknowledgment PDU.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Add support for the IP_MULTICAST_LOOP socket option to control
multicast packet loopback.
Signed-off-by: AbdElRahman Khalifa <abdelrahman.5alifa@gmail.com>
The options for BT_CTLR_CENTRAL_ISO and
BT_CTLR_PERIPHERAL_ISO did not have the proper defaults not
dependencies when BT_LL_SW_SPLIT=y
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement Set/Clear Feature endpoint halt request and
fix the corresponding commands in the shell.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The device command is broken due to the overhaul of how USB devices are
handled in the host stack. Add a device address argument to all device
commands and obtain a pointer to the USB device during command
execution.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Make reading and writing string values more flexible:
1. Eliminate the intermediate buffer when saving a string
setting. This needlessly limited the maximum string
length that could be saved using the shell command.
2. Do not add nor assume that a string saved in the settings
includes the null-terminator. The settings subsystem uses
metadata for encoding the value length, so there it is
redundant to also store the null-terminator in flash.
By the way, also make sure the command handlers only return
-EINVAL and -ENOEXEC error codes as documented in the
handler type description.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
When loading an extension, read-only sections that do not have
relocations and whose data is accessible from the ELF buffer can be
directly mapped as-is in the extension memory. This avoids the need to
allocate and copy unmodified data from the ELF buffer to the LLEXT heap.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This patch moves the alignment checks for MPU and MMU regions to the
beginning of the llext_copy_region() function. This is done to ensure
that the correct region alignment and size are used even in the case
where the region is reused from the ELF file buffer, avoiding MMU/MPU
configuration issues.
This also relaxes the same checks for regions that are accessed by the
kernel only (e.g. symbol and string tables), which do not need special
MMU/MPU treatment. This exposed an inconsistency in the MMU code, which
was setting the permission on the correct regions, but later restoring
the default permissions on every region, including the now-unaligned
ones.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This patch introduces an 'enum llext_storage_type' that defines the
storage type of the ELF data that will be loaded:
- LLEXT_STORAGE_TEMPORARY: ELF data is only available during
llext_load(); even when the loader supports directly accessing the
memory via llext_peek(), the buffer contents will be discarded
afterwards.
LLEXT will allocate copies of all required data into its heap.
- LLEXT_STORAGE_PERSISTENT: ELF data is stored in a *read-only* buffer
that is guaranteed to be always accessible for as long as the
extension is loaded.
LLEXT may directly reuse constant data from the buffer, but may still
allocate copies if relocations need to be applied.
- LLEXT_STORAGE_WRITABLE: ELF data is stored in a *writable* memory
buffer that is guaranteed to be always accessible for as long as the
extension is loaded.
LLEXT may freely modify and reuse data in the buffer; so, after the
extension is unloaded, the contents should be re-initialized before a
subsequent llext_load() call.
To keep full compatibility with existing code, the storage type of
LLEXT_BUF_LOADER is determined by the CONFIG_LLEXT_STORAGE_WRITABLE Kconfig
option between LLEXT_STORAGE_PERSISTENT and LLEXT_STORAGE_WRITABLE.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Adding this information allows easy cross-reference of the effects of
memory optimization changes between subsequent commits.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Following warning is printed if using strncpy(), so use memcpy()
instead. Note that this is false positive as there is no error here but
in order to avoid the warning, change the copy function.
subsys/net/lib/dns/mdns_responder.c:1371:25: warning:
'strncpy' output may be truncated copying 7 bytes from a string
of length 8 [-Wstringop-truncation]
1468 | strncpy(if_req.ifr_name, name, sizeof(if_req.ifr_name) - 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subsys/net/lib/dns/mdns_responder.c:1468:25: warning:
'strncpy' output may be truncated copying 7 bytes from a string
of length 8 [-Wstringop-truncation]
1468 | strncpy(if_req.ifr_name, name, sizeof(if_req.ifr_name) - 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add support for the IPV6_MULTICAST_LOOP socket option.
This option allows enabling or disabling the consumption of multicast
packets by the sender. By default, the socket option will be enabled.
Co-authored-by: Pieter De Gendt <pieter.degendt@gmail.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
TLS_CREDENTIAL_SERVER_CERTIFICATE credential type is misleading, as in
fact it just represents a public certificate, it does not matter if the
certificate belongs to a server or a client. And actually, it was
already used in-tree for clients as well, for example in LwM2M.
Therefore rename the credential type to a more generic
TLS_CREDENTIAL_PUBLIC_CERTIFICATE and deprecate the old one.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If there are no virtual interfaces attached to this virtual
interface, check if there is a RX handler for this virtual
interface and pass data to it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Clear all previous events when register is called a second time. This is
the same behavior as before, if the call happens with `len` equal or
greater then the previous call but in the case if `len` is less then the
first call, now, all events are cleared. This is more predictable behavior.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
Keep the err in code as it is convention in Bluetooth code, remove ret,
change error_code as avdtp_err_code for avdtp protocol error.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
We drop the packet if TTL or hop limit is 0, but we should
also unref the packet in this case because we return 0 to
the caller which is not then able to free the packet because
it thinks that the packet was sent properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The check_ip() in net_core.c did not check that the packet
Ethernet type is either IPv4 or IPv6. This meant that we for
example checked TTL also for ARP packets which is pointless as
those are not IPv4 packets.
Fix this by checking the link layer protocol type of the packet
to be either IPv4 or IPv6 before doing L3 checks.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Adding a helper to parse one or more IPv4/6 strings with optional
netmask or prefix length.
Example of the string:
2001:db8::1/64,192.0.2.1,2001:db8::2,192.0.2.2/24
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
All connection information was printed only if connection debugging
was enabled which then did not print information about Wireguard or
DHCP handlers. Limiting the printouts like this is not really needed
so print all connection information with "net conn" command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
It is useful in testing to allow user to change the default
network interface by "net iface default <index>".
Also print out the default interface for "net iface" and
"net iface default" commands.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Sometimes it is useful to view low level network interface information
in the network shell. Enable such prints if network interface debugging
is enabled.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add sys_trace_idle_exit to RISCV cpu_idle functions and allow
enabling CPU_LOAD module for RISCV and disable it for SMP.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
The set size can now be dynamically set and notified.
The rank is added as a argument in the case that changing
the set size, also affects the device's rank, as ranks
in a coordinated set needs to be continuous.
The set coordinator implementation has been updated
to support receiving the new set size, and providing
this information to the upper layers.
This commit adds a babblesim test for the new API,
as well as a shell command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current overhead check needlessly flushes some events for
CONFIG_BT_TICKER_SLOT_AGNOSTIC resulting in some lost or incomplete
advertising events; Use a lower overhead value for this configuration
to avoid that
Signed-off-by: Troels Nilsson <trnn@demant.com>
For a CIG with a CIG Sync Delay larger than a SDU interval, we cannot
be sure that we can target the very next ISO event when the CIG event
is ongoing; Only reduce event_offset if CIG Sync Delay is smaller
than an SDU interval
Signed-off-by: Troels Nilsson <trnn@demant.com>
Add more parameters to command `connect` and `register`, including mode,
mode_optional, extended_control, and hold_credit.
Add command `credits` to give the rx credit.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a sub-command set `l2cap` for command set `br`.
Move command `l2cap-register` to sub-command set. And rename it to
`register`.
Add command `connect`, `disconnect`, and `send` for command set
`l2cap`.
Remove original net buffer pool from `data_pool` to `data_rx_pool`.
Add a net buffer pool `data_tx_pool` for command `send`.
Do not wait anymore if no net buffer can be allocated from
`data_rx_pool`.
Dump all received data in L2CAP data received callback.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Improve the retransmission and flow control to support sending
multiple SDU at the same time if the TX windows is not full.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add mode optional support for BR l2cap connect initiator role.
If `chan->rx.optional` is true, set the mode to basic mode instead of
return error code `-ENOTSUP`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Enable signaling channel configuration for retransmission and Flow
control feature.
Send I-frame and S-frame. Support retransmission and Flow control for
sending.
Receive and handle I-frame and S-frame.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The original flow of socket_service thread handling the Zperf UDP RX
packets is: zsock_poll() polls all sockets for events, if ctx->recv_q
of Zperf is not empty, it will call trigger_work() -> udp_recv_data()
-> zsock_recvfrom() to read only one UDP packet from ctx->recv_q, then
go back to zsock_poll() and run the same process again, which is
inefficient.
The alternative solution is, in udp_recv_data(), it should exhaust all
the packets in the current ctx->recv_q, and then go back to
zsock_poll() to run the same process again.
In our Wi-Fi test case, for WPA3 security mode of 5GHz, the STA UDP RX
throughput can be improved from 91.48 Mbps to 99.87 Mbps, the SAP UDP
RX throughput can be improved from 85.97 Mbps to 96.00 Mbps.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
ENTROPY_NRF_CRACEN_CTR_DRBG symbol is based on devicetree
node with compatible nordic,nrf-cracen-ctrdrbg. It does not
have to be selected explicitly.
Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
The stack will no longer implicitly set the data path
for ISO channel, and the responsibility for doing that is
now for the upper layers/applications.
This provides additional flexibility for the higher layers
as they can better control the values and timing of the data
path, as well as support removing and even reconfiguring the
data path at will.
This also removes some complexity from the stack.
This commit also fixed a inconsistency in the disconnected
handler. CIS for centrals as well as BIS were still valid
bt_iso_chan channels in the disconnected callback,
but CIS for peripherals were completely cleaned up at this
point. This issue is fixed by moving the disconnected callback
handling to before the code to cleanup the channel for
peripherals.
Since there is a difference in how you remove data paths
depending on the GAP role (central/peripheral), the
iso_info struct type has been expanded to be more
concise of which type of CIS it is.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This was inspired by the detection of 2 instances of the warning:
warning: 'strncpy' specified bound 16 equals destination size
[-Wstringop-truncation]
The current code is already safe with regards to overflows, because
fixed-length string functions are used in the call tree. However, when
given a name 16 chars or larger, the current compare in llext_by_name()
will not work as expected because the stored extension name is truncated
to a max of 15.
Define a global LLEXT_MAX_NAME_LEN constant to simplify all this logic
and also implement name checks in the shell before calling llext_load().
Finally, using strlen() instead of strnlen() gets the real length of the
hex string passed as a parameter, which is important for the next safety
check.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Currently, the L2 PPP won't work with AF_PACKET socket family as it only
supports packets from AF_INET/AF_INET6 families. Because of this, it's
not possible to use AF_PACKET RAW or DGRAm sockets with PPP interfaces,
as the packets they generate have family field set to AF_PACKET.
Fix this, by verifying the LL protocol field in the PPP L2 before
passing the packet the respective PPP driver. If the AF_PACKET packet is
received, and the protocol field is set to IP/IPv6, update the packet
family to AF_INET/AF_INET6 accordingly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>