Commit graph

21541 commits

Author SHA1 Message Date
René Beckmann
41afd838aa Bluetooth: Crypto: Fix naming of params
The naming and documentation of the parameters was inconsistent with
their actual meaning and the implementation - enc_data and plaintext
were swapped.
Also, the parameter names in the file aes_ccm.c were completely
different from the ones in the header. Since all functions in the
header file are consistent in their parameter naming, I chose to make
the implementation follow the header and not the other way around.

Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
2021-05-12 12:37:27 +03:00
Flavio Ceolin
929c573d31 pm: policy: Fix residency policy math
The time necessary to resume from a power state has to be added to the
minimal residency time to check if there is enough time to go to a
particular state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-11 17:14:48 -05:00
Jukka Rissanen
f602801f91 net: igmp: Fix uninitialized variable
The return value might be uninitialized if there was no
suitable IPv4 address found for the network interface.

Coverity-CID: 224630
Fixes #35158

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-11 15:44:50 -05:00
Anas Nashif
7c582f4b7c tracing: systemview: rework IDs and make them match APIs
New version of Systemview has Zephyr API description that did not match
what we had, align with what the tools provides and expand hooks to
support additional APIs. We now cover most kernel APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-11 12:59:03 -05:00
Anas Nashif
72c830c3ee tracing: test format: print more details
Print timeouts and other details.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-11 12:59:03 -05:00
Anas Nashif
fe14c23852 tracing: move test format into its own directory
Minor cleanup keep format location uniform.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-11 12:59:03 -05:00
Fredrik Gihl
7e385d7d04 fs: logstr_dup causes error in LOG_ERROR messages
Using %s, without logstr_dup causes error when
CONFIG_LOG_DETECT_MISSED_STRDUP is enable.
Removing %s argument. LOG_FUNC_NAME_PREFIX_ERR can be used if prefix
is wanted.

Signed-off-by: Fredrik Gihl <fredrik.gihl@flir.se>
2021-05-11 07:14:24 -05:00
Lukasz Maciejonczyk
977aba6d02 net: openthread: Fix multiple Kconfig enablers for Link Metrics
Remove duplicated enabler for Link Metrics feature.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-05-11 09:53:29 +03:00
Robert Lubos
eaeac46720 net: openthread: Fix OT shell crash
After the recent OpenThread upmerge, OpenThread changed its behaviour in
terms of CLI handling during commissioning procedure. OpenThread will
now call the registered CLI callback when it recieves the Discovery
message.

This resulted in a crash if no CLI command was executed by the user
before, because the `shell_p` pointer was only set in the command
handler. As it was not set to the actual shell backend instance, it
caused a crash (or assert if enabled) in the `shell_vfprintf()`
function.

Fix this by verifying the `shell_p` pointer in the
`otConsoleOutputCallback()` function before use. Additionally, set the
pointer to the most common UART shell backed (if enabled) in the
initialization function so that the initial messages from OpenThread are
not dropped.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-05-11 09:53:12 +03:00
Jukka Rissanen
29e023d4e0 net: shell: Fix crash when invoking dns command in shell
This fixes a crash when typing "net dns" command in net-shell

Fixes #35041

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-11 09:52:10 +03:00
Jukka Rissanen
6485e7d07f net: if: Do not check IPv4 multicast addr when selecting src addr
When destination address is a multicast address, select the source
address from non link local address first.

This means that for example if we are responding to mDNS query,
and we have both normal IPv4 and LL (169.254.x.y) address set for
the interface, we are now able to select the normal address instead
of the LL one.

Fixes #34409

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-11 09:51:31 +03:00
Szymon Janc
aeb767ffc6 testsuite: ztest: Add missing syscalls/log_msg2.h stub
This stub is needed when unit testing code that includes log_msg.h or
log_msg2.h.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2021-05-10 13:17:44 -05:00
Vinayak Kariappa Chettimada
30f260dfaa Bluetooth: controller: Fix adv/scan context access post release
Fix advertiser and scanning context being accessed on done
event when connection complete node rx that is processed
earlier has release them.

Relates to #30735.
Fixes #35013.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-10 18:19:00 +02:00
Laczen JMS
5e9d6d638c nvs: fix possibility of losing data
Fix the possibility of losing data after startup as a result of a badly
erased sector.

Fixes #34722.

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
2021-05-10 05:31:36 -05:00
Aurelien Jarno
c387a0dd57 net: tcp: select MBEDTLS_MAC_MD5_ENABLED for ISN algorithm
The ISN algorithm from RFC 6528 doesn't need Mbed TLS, but rather the
MD5 algorithm from Mbed TLS. Therefore select MBEDTLS_MD and
MBEDTLS_MAC_MD5_ENABLED in addition to MBEDTLS.

This fixes the following build failure when using TLS version 1.2 is
selected:
  zephyr/subsys/net/ip/tcp2.c:1329: undefined reference to
  `mbedtls_md5_ret'

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-05-10 05:30:03 -05:00
Aurelien Jarno
c30339aa16 net: openthread: Select ECDSA when SRP is enabled
SRP client and server require ECDSA to be enabled otherwise the build
fails. Select OPENTHREAD_ECDSA for both OPENTHREAD_SRP_CLIENT and
OPENTHREAD_SRP_SERVER options.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-05-10 05:29:19 -05:00
Aurelien Jarno
bc9e759ca4 net: openthread: Move SRP Kconfig options to Kconfig.features
OPENTHREAD_SRP_CLIENT and OPENTHREAD_SRP_SERVER are Thread features and
not Thread configuration, so move them to Kconfig.features.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-05-10 05:29:19 -05:00
Aurelien Jarno
a80e28a26c net: openthread: Make child related options only visible on FTD
The OPENTHREAD_MAX_CHILDREN and OPENTHREAD_MAX_IP_ADDR_PER_CHILD options
make not sense for a MTD device. Make them depend on OPENTHREAD_FTD.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-05-10 05:29:19 -05:00
Torsten Rasmussen
3a0951fcd0 openthread: kconfig: rework OpenThread security configurations
With the updates to mbedTLS Kconfig it is now possible to update the
OpenThread security configurations by disabling the mbedTLS prompt and
avoid stuck symbol selection.

As part of this, the OpenThread security selection has been reworked
into a choice which ensures only a single security selection can be
chosen.

And the OPENTHREAD_MBEDTLS itself has been made promptless to ensure
other parts of the build system can select a specific OpenThread
security implementation and disable user selection, if the module or
sample require such behavior.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-05-09 15:24:23 -05:00
David Brown
aa5187ecde tls: Change some external symbols from Mbed TLS
In Mbed TLS:
    commit eccd88871767e2fba5f3a079cfdfcb77c376cf20
    Author: Gilles Peskine <Gilles.Peskine@arm.com>
    Date:   Tue Mar 10 12:19:08 2020 +0100

        Rename identifiers containing double-underscore

changes the name of a symbol we use.  As part of upgrading to newer
versions of Mbed TLS, change the name of the symbol we use.

A better fix would be to not use this symbol at all, and perhaps define
our own symbol the same way this internal symbol is defined within the
library.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-05-09 09:59:22 -05:00
Ioannis Glaropoulos
61df25d867 Revert "openthread: kconfig: rework OpenThread security configurations"
This reverts commit 88f3a9899a.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-05-09 09:59:22 -05:00
Anas Nashif
6a8148f384 tracing: systemview: cleanup headers
Cleanup systemview headers and move sysview hooks into sysview_config.c

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-08 17:06:24 -04:00
Torsten Rasmussen
88f3a9899a openthread: kconfig: rework OpenThread security configurations
With the updates to mbedTLS Kconfig it is now possible to update the
OpenThread security configurations by disabling the mbedTLS prompt and
avoid stuck symbol selection.

As part of this, the OpenThread security selection has been reworked
into a choice which ensures only a single security selection can be
chosen.

And the OPENTHREAD_MBEDTLS itself has been made promptless to ensure
other parts of the build system can select a specific OpenThread
security implementation and disable user selection, if the module or
sample require such behavior.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-05-08 07:11:00 +02:00
Jonathan Nilsen
e1891b3e9a storage/stream: Move fill value handling to flash_sync
Move the code responsible for aligning the flash write by writing fill
values - from stream_flash_buffered_write to flash_sync. This avoids
having to correct buf_bytes/buf_written after the write and thus
simplifies error handling.

This commit also fixes an issue where the write length passed to the
callback in flash_sync includes the fill length.

Signed-off-by: Jonathan Nilsen <Jonathan.Nilsen@nordicsemi.no>
2021-05-08 07:10:31 +02:00
Anas Nashif
4d994af032 kernel: remove object tracing
Remove this intrusive tracing feature in favor of the new object tracing
using the main tracing feature in zephyr. See #33603 for the new tracing
coverage for all objects.

This will allow for support in more tools and less reliance on GDB for
tracing objects.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif
1af037f477 modules: enable percepio tracerecorder for tracing
Add support for percepio tracealyzer.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif
f477bac818 tracing: support new macros with systemview
Use new macros with systemview and rework hooks adding support for new
trace points.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif
a35bb82539 tracing: Use new macros with CTF based tracing
Use new tracing macros to generate tracing output in CTF format.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Anas Nashif
270be80caa tracing: add empty test macros
Add support for new tracing macros in test backend. Move header from
sample into the subsystem and make it available for general testing with
any application.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Torbjörn Leksell
16bbb8ef34 Tracing: Trace hook support macros
Adds generic trace hook macros for inserting trace hook for
function entry, exit, blocking, and object initialization
with a variable number of arguments (objects, return values,
etc.). Utilizing macro concatenation these macros produce
trace hooks of a similar format to the old trace system
with SYS_TRACING_OBJ_FUNC(k_thread, switched_in) being
turned into sys_trace_k_thread_switched_in() by the
preprocessor. Although these macros still rely on the manual
definition of each unique trace hook in tracing.h, the benefit
of not directly calling those is that we can enable/disable
trace hooks based on object type (k_thread, k_sem, etc.)
through the preprocessor while providing the ability of adding
type specific runtime trace processing similar to
SYS_TRACING_OBJ_INIT.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-07 22:10:21 -04:00
Shlomi Vaknin
8d48b919c6 fs: shell: add cat file command
Add cat command to fs shell module.
This command prints to the standard output
the given files.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-05-07 20:52:36 -04:00
Flavio Ceolin
0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin
86a8ab5c2c pm: device_runtime: Just fix a comment
Fixing the comment about powering a device on in pre-kernel.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin
1bd781e7b5 power: device_pm: Remove device idle pm states
Avoid confusion with device runtime idle pm states and just use device
pm states.

This simplify the code a little bit and prepare the ground for having
a better definition of device pm states. Right now this code needed to
hijack two transitional states to not break the current code logic but
the goal is avoid it and have everything in one single place.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin
e89d9d65cc pm: device_runtime: Power device on/off in pre-kernel
Devices may be initialized but started powered down for this reason
is necessary to power a device on if requested even if in pre-kernel
state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
c7f5270a01 pm: device: fsm_state -> state
Rename state variable.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
4ce32edb76 power: device: Do not suspend a busy device
Check if a device is busy before suspend it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
54324fd08e power: device_pm: Use spin lock instead of semaphore
Device pm runtime was using semaphore to protect critical section but
enable / disable functions were waiting on the semaphore. So, just
replace it with a spin lock.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
39ec8c1cb9 power: device_pm: Add missing fallthrough
Add an explicit fallthrough in a case label.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
8705c688e2 power: device_pm: Fix concurrence issues
The sync API was using k_poll_signal and in certain conditions is
possible multiple threads waiting on a signal leading to an undefined
behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
66b0483cce power: device_pm: Use BIT macro for code compliance
BIT macro properly handle bit shift operations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
6d67bb1b7d power: device_pm: Check if is running in pre-kernel
Don't use kernel services before in pre-kernel state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Flavio Ceolin
9ac646f277 power: device: Don't wake up devices unnecessarily
Currently when the system goes to sleep it asks *all* devices that
support PM to suspend or go to a low power state, and the system wakes
up it put *all* suspended devices in active state, even if a device
was already suspended and not being used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Jukka Rissanen
bcdc762609 net: Use k_fifo instead of k_work in RX and TX processing
The k_work handler cannot manipulate the used k_work. This means
that it is not easy to cleanup the net_pkt because it contains
k_work in it. Because of this, use k_fifo instead between
RX thread and network driver, and between application and TX
thread.

A echo-server/client run with IPv4 and UDP gave following
results:

Using k_work
------------
TX traffic class statistics:
TC  Priority	Sent pkts	bytes	time
[0] BK (1)	21922		5543071	103 us	[0->41->26->34=101 us]
[1] BE (0)	0		0	-
RX traffic class statistics:
TC  Priority	Recv pkts	bytes	time
[0] BK (0)	0		0	-
[1] BE (0)	21925		6039151	97 us	[0->21->16->37->20=94 us]

Using k_fifo
------------
TX traffic class statistics:
TC  Priority	Sent pkts	bytes	time
[0] BK (1)	15079		3811118	94 us	[0->36->23->32=91 us]
[1] BE (0)	0		0	-
RX traffic class statistics:
TC  Priority	Recv pkts	bytes	time
[0] BK (1)	0		0	-
[1] BE (0)	15073		4150947	79 us	[0->17->12->32->14=75 us]

So using k_fifo gives about 10% better performance with same workload.

Fixes #34690

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-07 09:46:44 -05:00
Jukka Rissanen
2697275d23 net: ppp: Convert to use k_fifo instead of k_work
Following commits will remove k_work from net_pkt, so convert
PPP L2 to use k_fifo when sending PPP data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-07 09:46:44 -05:00
Jukka Rissanen
0808ead6ff net: 6locan: Convert to use k_fifo instead of k_work
Following commits will remove k_work from net_pkt, so convert
6locan L2 to use k_fifo between application and TX thread, and
driver and RX error handler.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-07 09:46:44 -05:00
Vinayak Kariappa Chettimada
32d9b68944 Bluetooth: controller: Implement LE Set Host Feature Command
Added implementation of HCI LE Set Host Feature command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-07 15:25:18 +02:00
Vinayak Kariappa Chettimada
ed59ceba62 Bluetooth: controller: Replace use if LL_FEAT with ll_feat_get()
Replace the use of LL_FEAT define with ll_feat_get() so that
feature set value can be updated at runtime with host
feature bit values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-07 15:25:18 +02:00
Emil Gydesen
82a32f5ca5 Bluetooth: Audio: Volume Control Service and client
This commit implements the volume control service (VCS) and
client, The implementation supports and uses the
Audio Input Control Service (AICS) and
Volume Offset Control Service (VOCS) secondary services.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-07 15:02:41 +02:00