Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
85790c95a9 Bluetooth: Controller: Introduce EVENT_MAFS_MIN_US value
Introduce Controller dependent EVENT_MAFS_MIN_US value to
use as the value when populating the aux offset between
Extended Advertising primary and auxiliary channel PDUs.

This can be used as workaround for peers having difficulty
receiving Extended Advertising PDUs with near 300 us MAFS
values used in aux offset calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:46:48 +01:00
Vinayak Kariappa Chettimada
4dbfb22a7e Bluetooth: Controller: Relax radio packet pointer assignment deadline
Relax the radio packet pointer assignment deadline assertion
until access address being transmitted. The PDU buffer is
probably only needed just after access address is being
transmitted or received by the radio. This will give some
more breathing room for slow CPUs like in nRF51x SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
642d4be940 Bluetooth: Controller: Fix regression using speed optimization
Fix regression using speed optimization introduced in
commit 1b7fe792e0 ("Bluetooth: Controller: Support Link
Time Optimizations (LTO)").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
b9a7a64563 Bluetooth: Controller: nRF51x: Fix regression in encrypted connection
Fix regression in encrypted connection introduced in
commit f3deccda91 ("Bluetooth: Controller: CCM read data
to early when DF enabled on PHY 1M").

Due to this nRF51x SoC hang waiting to encrypt and/or
check MIC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
40b71c9773 Bluetooth: Controller: Fix PDU length in case of ISR latency issue
In case of ISR latencies, if packet pointer has not been
set on time then we do not want to check uninitialized
length in rx buffer that did not get used by Radio DMA.
This would help us in detecting radio ready event being
set? We can not detect radio ready if it happens twice
before Radio ISR executes after latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
e36ddffa7a Bluetooth: Controller: Fix empty PDU buffer overrun under ISR latency
Only 3 bytes (PDU_EM_LL_SIZE_MAX) is required for empty PDU
transmission, but in case of Radio ISR latency if rx packet
pointer is not setup then Radio DMA will use previously
assigned buffer which can be this empty PDU buffer. Radio
DMA will overrun this buffer and cause memory corruption.
Any detection of ISR latency will not happen if the ISR
function pointer in RAM is corrupted by this overrun.
Increasing ISR latencies in OS and CPU usage in the
ULL_HIGH priority if it is same as LLL priority in
Controller implementation then it is making it tight to
execute Controller code in the tIFS between Tx-Rx PDU's
Radio ISRs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
8ef919a7a4 Bluetooth: Controller: Fix ISR profiling for single timer use
Fix ISR profiling when using single timer for tIFS radio
switching wherein in the timer is cleared on every radio
end. Hence, the captured timer value is the latency and
does not required the radio end timestamp to be subtracted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
53b6bc56fc Bluetooth: Controller: Verbose radio is ready assertion
Provide Radio ISR latency in microseconds when asserting due
to high ISR latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
409402f0cc Bluetooth: Controller: Add ISR profiling using ticker ticks
Add ISR profiling using ticker ticks, hence profile ISR
CPU use outside radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
56ca9b873d Bluetooth: Controller: Use uint16_t to store ISR profiling value
Use uint16_t to store ISR profiling value to avoid overflow
in case of higher latencies.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Vinayak Kariappa Chettimada
90bc2b2064 Bluetooth: Controller: Fix in-system ISR profiling for adv and conn
Fix in-system ISR profiling for advertiser and connection
role for the missing implementation when there is CRC error.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-08-14 10:45:59 +01:00
Emil Gydesen
ba62c8d876 Bluetooth: BAP: Support setting different values per dir in CIG
The interval and latency for a CIG are set for each direction now,
allowing applications to use e.g. 10ms for sink ASEs and 7.5ms for
source ASEs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-08-14 09:42:16 +02:00
Reto Schneider
b03fcfa0cf net: lib: lwm2m: Add name to choice symbol
Add name to choice symbol, so that default value can be changed
downstream.

Developed-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-08-14 09:40:34 +02:00
Pisit Sawangvonganan
d5a458df2e net: l2: ppp: ensure proper null-termination in ppp_fsm_close
- Remove the `strlen`, as it is unnecessary for safe copying.
- Limit the `strncpy` to `sizeof(fsm->terminate_reason) - 1`
  to ensure the last byte is reserved for null-termination.
- Add an explicit null terminator to guarantee correct string termination.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-14 09:40:23 +02:00
Tom Finet
5e834cc4b6 net: capture: Add packet capture stats for dropped packets
Cloning a packet for a capture may fail due to insufficient memory.
In such a case, the networking statistics should be updated
to reflect this processing error. This commit updates the processing
error count on the capture tunnel network interface because this is
the interface that the captured packet would have been assigned to.

Signed-off-by: Tom Finet <tomfinet@outlook.com>
2024-08-14 09:39:09 +02:00
Mikhail Kushnerov
e50d1190fa profiling: Add perf tool
Add profiling subsystem.

Add perf util based on periodic stack unwinding. Perf from Linux
was taken as a reference.

The operation of module is based on frame pointer usage and saving
registers during interruption handling.
The unwinding function stay in timer as expiry functioin so is called
during interruption handling. Thus the function have access to saved
registers (program counter and frame pointer in particular) of the current
thread and use it to unwind the thread stack.
Timer starting and results printing function are made as shell commands
for conveniency.

Originally-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
Signed-off-by: Mikhail Kushnerov <m.kushnerov@yadro.com>
2024-08-13 18:28:44 -04:00
Muhammad Haziq
9958a2e3c3 net: wifi: replace (1 << xyz) with BIT(xyz)
Refactor (1 << xyz) to use the BIT(xyz) macro.
The change aims to enhance code readability.

Signed-off-by: Muhammad Haziq <muhammad.haziq@zintechnologies.com>
2024-08-13 18:19:33 -04:00
Alberto Escolar Piedras
e3da5c3d39 Bluetooth: Mesh: Fix build warning with gcc 13
gcc 13 thinks  max_adv_duration may be used unitialized
and warns accordingly (see below)
It seems the reason is the goto, which confuses it.
In any case, pacifying this warning is trivial,
so let's just do so.

The warning:
```
In function ‘gatt_proxy_advertise’,
inlined from ‘bt_mesh_proxy_adv_start’ at
subsys/bluetooth/mesh/proxy_srv.c:1214:9:
subsys/bluetooth/mesh/proxy_srv.c:842:44: error: ‘max_adv_duration’ may
be used uninitialized [-Werror=maybe-uninitialized]
subsys/bluetooth/mesh/proxy_srv.c: In function ‘bt_mesh_proxy_adv_start’
zephyr/subsys/bluetooth/mesh/proxy_srv.c:786:17: note:
‘max_adv_duration’ was declared here
  786 |         int32_t max_adv_duration;
      |                 ^~~~~~~~~~~~~~~~
```

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-08-13 18:18:00 -04:00
Grygorii Strashko
965ca96c77 testsuite: coverage: fix arm64 build with gcov enabled
On ARM64 the build will fail with coverage and GCOV enabled:

  CONFIG_COVERAGE=y
  CONFIG_COVERAGE_GCOV=y
  CONFIG_FORCE_COVERAGE=y

west build -b rpi_5 -p always samples/hello_world -- \
 -DCONFIG_COVERAGE=y -DCONFIG_FORCE_COVERAGE=y

Failure:
 "linker_zephyr_pre0.cmd:181: undefined symbol `__gcov_bss_end' referenced
in expression"

Fix build of ARM64 platforms with coverage and GCOV enabled by adding for
ARM64 the same gcov linker sections as it is done for ARM.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
2024-08-13 14:57:50 +02:00
Piotr Kosycarz
2fd7ab7b97 testsuite: coverage: allow disabled multithreading
k_sched* are not avaliable when there is CONFIG_MULTITHREADING=n

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2024-08-13 14:57:18 +02:00
Krzysztof Chruściński
e18254901c logging: When strings are stripped keep source name pointers
90ab94f61d added a change that source name pointers were not stored
in the const data structure associated with a logging source. That was
done because those string pointers were invalid (on purpose pointing to
non-existing memory) and reading those strings could lead to a fault.
However, those pointers are used by scripts which are building the
dictionary database and after this change script was no longer
able to retrieve source names from elf file and database was incomplete.

This patch brings back storing of source name string pointers but in
API for reading those source names guards are added to not return
invalid addresses.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-08-13 14:56:14 +02:00
Dawid Niedzwiecki
c2151ad1e3 ztest: undefine _POSIX_C_SOURCE before defining it
Undefine _POSIX_C_SOURCE before defining it to avoid double
definition

The previous version, changed in this PR
https://github.com/zephyrproject-rtos/zephyr/pull/70363, did the undef.
Make sure to do the same for all files in the current dir.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-08-13 14:56:06 +02:00
Krzysztof Chruściński
530b8ccbed debug: coresight: Add coresight_trace_deformatter
Add module which decodes data encoded using Coresight Trace
Formatter.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-08-12 19:23:19 -04:00
Yago Fontoura do Rosario
42c8732dda Bluetooth: Gatt: Make CCC_STORE_MAX configurable
- Made CCC_STORE_MAX configurable under the BT_SETTINGS
- Added a buffer overflow check on ccc_save

Fixes: #76838

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2024-08-12 15:54:28 +02:00
Jan Peters
b8bef42add device_dt_metadata: handle dt_meta being NULL
Using  DEVICE_DEFINE, a device without a corresponding DT node can be
defined (for example CRYPTO_MTLS), Z_DEVICE_INIT() does not initialize
dt_meta for such devices, leaving the field as NULL.
device_get_dt_nodelabels() and functions calling it have to handle
dev->dt_meta == NULL to prevent fatal errors.

Signed-off-by: Jan Peters <peters@kt-elektronik.de>
2024-08-12 15:54:22 +02:00
Robert Lubos
086faa56aa net: lib: http_server: Clear http1_headers_sent flag on new request
http1_headers_sent flag has to be cleared when entering
HTTP_SERVER_REQUEST_STATE and not only on the client init. Otherwise,
serving multiple HTTP1 POST requests over the same connection does not
work as intended (headers were not sent for the second and further
requests).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-08-12 15:54:03 +02:00
Niklas Fabian
72f90ee063 logging: fs backend: optional append to latest file
Make appending to the newest log file in the fs logging backend optional.
By default, if there is still free space in the latest log file,
the fs logging backend appends to it on startup. This is useful for saving
space and avoiding the removal of older log files, if the maximum number
of log files has been reached. The drawback of this behavior is,
that log files that got appended can not be decoded, if the firmware
has changed between startups, for instance by an update,
since the log_dictionary.json used for decoding has also changed.
Therefore, it may be desirable to deactivate appending to log files.

Signed-off-by: Niklas Fabian <niklas.fabian@lemonbeat.com>
2024-08-12 12:44:11 +02:00
Jonathan Rico
8a2fe27c00 Bluetooth: Host: Free ACL RX fragments on disconnection
This function call frees the buffer kept by the host for reassembling L2CAP
PDUs into.

Without this call, the current buffer will eventually be
leaked, leading to a non-functional host due to lack of RX buffers.

The effect is worse when host flow control is not enabled, as the RX
buffer pool is shared with events, which means communication with the
controller is essentially dead.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-12 10:10:48 +02:00
Jonathan Rico
5a4fdfbf3e Bluetooth: hci_common: Add assert on buf allocation
`net_buf_alloc(K_FOREVER)` can now return NULL if running in the system
workqueue. `bt_hci_evt_create()` is called in that context in a few cases.

Since we can't really do anything about it, add a (default-on) assert.

This should ideally never fail. I saw it fail because of a leak in the ACL
buffer pool, which is also shared with events when host flow control is not
enabled.

In that particular case, the host is rendered non-functional, so trying to
recover using error handling is futile.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-12 10:10:48 +02:00
Benjamin Cabé
4458a05ec2 fs: fuse: ensure S_IFxxx macros are available
set _XOPEN_SOURCE appropriately to avoid compilation errors
due to missing S_IFxxx macros on some systems.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-08-11 10:32:20 +02:00
Keith Short
da4f4e8748 ztest: Replace PRINT with PRINT_DATA
The testsuite subsystem provides the macro PRINT_DATA() which can be
overridden using CONFIG_ZTEST_TC_UTIL_USER_OVERRIDE. Switch all calls of
PRINT() to PRINT_DATA withing the testsuite subsystem.

Signed-off-by: Keith Short <keithshort@google.com>
2024-08-09 08:39:18 -04:00
Keith Short
82a2a16649 ztest: Fix formatting
Run clang-format on some ztest files.

Signed-off-by: Keith Short <keithshort@google.com>
2024-08-09 08:39:18 -04:00
Keith Short
d8bc125469 ztest: fix compliance issue
Check compliance flagged an UNNESSARY_INT error.

Signed-off-by: Keith Short <keithshort@google.com>
2024-08-09 08:39:18 -04:00
Nick Ward
e738bca67f net: lwm2m: location object: make optional resources optional
Provides the user control over whether the altitude, radius,
or speed resources are in use.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2024-08-09 08:37:25 -04:00
Pisit Sawangvonganan
edbf8efeab net: wifi_utils: correct channel scan range in Wi-Fi 6GHz
Introduce `wifi_utils_get_next_chan_6g` to get the next
valid Wi-Fi 6GHz channel.

This commit addresses the proper handling of cases when
`chan_start` is not 1.

Fix #74063

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-09 08:36:22 -04:00
Victor Chavez
3ee6fa8c07 logging: Optimize ble notification size
Reduce the size of the ble notification if the length of
the line output is less than the current mtu size.

Signed-off-by: Victor Chavez <vchavezb@protonmail.com>
2024-08-09 09:54:14 +02:00
Pisit Sawangvonganan
721ee31c36 net: wifi: shell: enhance consistency in code style
Enhancing code consistency provides cognitive leverage with
the following changes:
- Unified the order of declaration for `opt`, `opt_index`,
  `state`, and `long_options`.
- Unified the wrapping of `getopt_long` calls, regardless of
  the length of the `options` string.
- Renamed `option_index` to `opt_index` for consistency.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-08 20:21:13 -04:00
Pisit Sawangvonganan
2ef08cee38 net: wifi: shell: use getopt_state for safer optarg access
Using `getopt_state` to access `optarg` and also `optopt` offers
a better alternative to direct global access.

See e145eb9201 for the previous change related to this.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-08 20:21:13 -04:00
Pisit Sawangvonganan
5af4e9df2f net: wifi: shell: apply struct option as static const
This change marks the remaining instance of the `struct option` as
`static const`.

The rationale is that `struct option` is a read-only variable.
By using `static const`, we ensure immutability, leading to usage of only
the `.rodata` section and a reduction in the `.data` area.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-08 20:21:13 -04:00
Pisit Sawangvonganan
e87d508ae5 net: wifi: shell: manual code formatting
Various manual code formatting adjustments, including:
- Wrapping lines in the `long_options` declaration to prevent them
  from extending too far to the right.
- Adding missing `{` and `}` in the `if` statement in
  `cmd_wifi_set_rts_threshold`.
- Aligning `SHELL_CMD_ARG` in `wifi_commands` with previous declarations.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-08 20:21:13 -04:00
Seppo Takalo
e3100c6f3a net: lwm2m: Allow SenML-CBOR floats decoded as int
SenML is technically a JSON based format which can
be encoded as a CBOR. SenML-CBOR specification in
RFC 8428 section 6 states that numbers can be decoded
as an integer.

Also RFC 7049 section 4.2 states that JSON numbers
without fractional part can be decoded as an integer.

I have seen with one commercial LwM2M platform that
the decoder  they use, sends floating point values as
integers, if there is no fractional part.

So LwM2M engine cannot assume from the path that
the incomming number is either float or int. Accept both.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-08-08 15:37:56 +02:00
Konrad Derda
5e4e63ba8f net: ipv6: route: get nexthop's LL address only if relevant
This commit moves reading nexthop's LL address only if it's supported
by a given neighbor and can be used for routing between interfaces.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-08-08 15:37:32 +02:00
Jonathan Rico
58ec51616d Bluetooth: host: fix incorrect ISO HCI fragmentation logic
Don't push the TS flag on `buf` itself.

This messes up the MTU calculations: a packet that would exactly fit the
MTU and has a timestamp would be unnecessarily fragmented.

The MTU check is done on `buf` as a whole. At the point where the
fragmentation length is decided, `buf` includes one extra byte to pass the
TS bit around. That byte shouldn't count towards the MTU.

Instead, infer the presence of the timestamp by inspecting the amount of
headroom that the buffer has. This works because we always reserve
enough memory to push the timestamp, but not always push a timestamp on
the buffer. #tightlycoupled

This method is slightly uglier IMO, but eases MTU confusion and doesn't
rely on user_data.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-08-08 06:07:08 -04:00
Krzysztof Chruściński
5bd6050241 testsuite: busy_sim: Add alarm cancelation to stop function
Without cancelation next start may return error.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-08-07 19:04:04 -04:00
Krzysztof Chruściński
42f003cebd testsuite: busy_sim: Allow running with timer random generator
Allow to run with timer random generator which does not need any
entropy device.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-08-07 19:04:04 -04:00
Kapil Bhatt
2f088fabc2 net: wifi: Add Current PHY rate
Current PHY rate
It represents the current PHY rate of transfer
of data in bits per second. It will a TX data rate.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-08-07 19:02:32 -04:00
Kapil Bhatt
459a63b137 net: wifi: Add over run count statistics
Over run count
It represents the number of packets dropped either at
received and sent due to lack of buffer memory to retain
all packets on the network interface.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-08-07 19:02:32 -04:00
Łukasz Duda
fb71ca2237 net: openthread: Handle deprecated IPv6 addresses correctly
This commit fixes an issue where deprecated IPv6 addresses were not
being correctly marked. In some cases, deprecated addresses might have
been used as source addresses.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-08-07 07:13:54 -04:00
Johann Fischer
5ddaa3b1a1 drivers: udc: add opaque pointer to store upper layer private data
Add an opaque pointer to store upper layer private data and initialize
it with the USB device context during controller initialization. Use the
pointer in event processing to get the correct context.

Fixes commit 48f2a4bc1a
("usb: device_next: remove initialized state checks in event processing")

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-08-06 17:17:41 -04:00
Seppo Takalo
b68477b372 net: lwm2m: Reset retry counter on update
On a successful update we should reset the retry counter, similarly
like we do on successful registration.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-08-06 17:16:46 -04:00