Commit graph

21541 commits

Author SHA1 Message Date
Piotr Szkotak
c60d500bf9 net: openthread: Increase stack sizes with FP context
This PR increases the OpenThread stacks to compensate
for the runtime increase of the MPU stack guard
when the usage of the FP context is detected.

Signed-off-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
2021-04-29 09:50:44 -04:00
Krzysztof Chruscinski
a4af0ee2ec logging: Fix support for no multithreading
Fixed to ensure that semaphore is not used by the log core
when multithreading is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-29 14:50:35 +02:00
Krzysztof Chruscinski
d5664a4a2d debug: Allow spin lock validation only with multithreading
Spin lock validation is touching threads. Allow only when
multithreading is enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-29 14:50:35 +02:00
Krzysztof Chruscinski
5e06b4add0 testsuite: ztest: Add support for CONFIG_MULTITHREADING=n
Added support for no multithreading case where test cases are
called directly from main(). On failure in ztest assert macro,
macro returns from the function. It implies that ztest assert
macros can only be called in the test function.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-29 14:50:35 +02:00
Marcin Niestroj
d30b68a39a net: ppp: ipcp: use dns_resolve_reconfigure() API
Use recently introduced API, which takes care of gracefully closing any
pending DNS requests and replacing existing DNS server list with new
one.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Marcin Niestroj
de15a49640 net: dhcpv4: use dns_resolve_reconfigure() API
Use recently introduced API, which takes care of gracefully closing any
pending DNS requests and replacing existing DNS server list with new
one.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Marcin Niestroj
71c31c45c7 net: dns: add dns_resolve_reconfigure() API
So far there was no dedicated mechanism for replacing DNS servers with
new list. Add dns_resolve_reconfigure() API that allows to achieve that
in a thread-safe manner.

Introduce 3rd state in DNS context lifetime by converting from 'bool
is_used' to 'enum dns_resolve_context_state state'. This new
DEACTIVATING state allows to mark a DNS context as busy and safely close
context without holding lock. Closing DNS context with released lock
prevents deadlock in case net_context_close() has to synchronize with a
separate thread executing handler passed to net_context_recv() (which is
the case for example with ESP-AT WiFi driver).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Marcin Niestroj
83e5953783 net: dns: protect 'is_used' with mutex
ctx->is_used member seemed to be used sometimes within a mutex acquired
block, sometimes not. Make it consistent by always using it with
acquired mutex.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-29 08:00:09 -04:00
Jukka Rissanen
a1c4952dfd net: ipv4: Add IGMPv2 support
Add Internet Group Management Protocol v2 support, see RFC 2236
for details.

Fixes #2336

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-29 14:49:55 +03:00
Jukka Rissanen
d28e64c602 net: stats: Add IGMP statistics support
Collect IPv4 IGMP sent/received/dropped statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-29 14:49:55 +03:00
Jukka Rissanen
e5043f5a7f net: if: Add IPv4 multicast address join/leave functions
Allows caller to mark IPv4 multicast address to be used or not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-29 14:49:55 +03:00
Daniel Leung
8d0201f6eb logging: backend null check to use NULL...
...instead of numeric zero.

Using 0 instead of NULL is a violation of MISRA rule 11.9.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-29 07:16:37 -04:00
Gerard Marull-Paretas
f163bdb280 power: move reboot functionality to os lib
Reboot functionality has nothing to do with PM, so move it out to the
subsys/os folder.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 20:34:00 -04:00
Daniel Leung
9b4ae26e70 logging: add UART backend for dictionary based logging
This adds a new UART backend for dictionary based logging,
where this can output binary data in both binary and
hexidecimal strings.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-28 22:25:42 +02:00
Daniel Leung
a5ab1a7518 logging: add support for dictionary based logging
This adds dictionary based logging support. Dictionary based
logging is binary based where one big difference is that
static strings are stored as pointers instead of the whole
string. This results in reduced space requirements for
storing log messages in certain scenairos.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-28 22:25:42 +02:00
Daniel Leung
990919fb89 logging: simplify is_rodata() for NIOS2, RISC-V and SPARC
NIOS2, RISC-V and SPARC are using _image_rodata_start/_end in
their linker scripts to mark the boundaries of rodata. So
they no loner need special treatment.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-28 22:25:42 +02:00
Emil Gydesen
cc35750603 Bluetooth: ISO: Add missing handling of interval and latency of unidir
Adds missing handling of the m_interval and m_latency if tx QOS is
not set, and handling of the s_interval and s_latency if rx QOS is
not set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-28 14:34:48 -04:00
Robert Lubos
653c987762 net: lwm2m: Fix lwm2m_path_log_strdup buffer usage
Currently the lwm2m_path_log_strdup allocates a temporary buffer on a
stack, and then passes it to the log_strdup function to create a copy
of the string for the logger. log_strdup however will not copy the
string if for instance immediate logging is used, therefore the logging
function will still use the memory address of the already invalid buffer
allocated within lwm2m_path_log_strdup.

Fix this by passing an addittional `buf` parameter to the
lwm2m_path_log_strdup function, therefore allowing the user to provide
the buffer within a valid scope.

CID: 220536
Fixes #34005

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-28 19:30:09 +02:00
Chih Hung Yu
5cebdf5fd3 net: lib: sockets: Fix zsock_select
zsock_select() cannot poll file descriptors with number >= 32.

When a whole word in FD_SET was skipped due to being empty,
corresponding fd number was not updated, leading to wrong
fd's being passed to poll().

Fixes #34563

Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
2021-04-28 20:01:31 +03:00
Paul Sokolovsky
92ba428626 testsuite: Factor out suite header/footer to tc_util.h
We have a few remaining tests where ztest module is not used directly,
and instead lower-level tc_util.h is used (where ztest also uses that
header). Supposedly, there're good reasons for that. However, tc_util.h
tests have output which is somewhat inconsistent with ztest output,
which may be a problem with automated parsing of test results, e.g. in
CI systems.

So, factor out code to mark testsuite start/end from ztest.c to
tc_util.h as TC_SUITE_START() and TC_SUITE_END() macros, to allow
tc_util.h based tests to produce output fully consistent with
ztest, while avoiding duplicate of code. TC_SUITE_END() accepts
result code (TC_PASS/TC_FAIL), similar to existing TC_END_REPORT().

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2021-04-28 12:54:13 -04:00
Peter Bigot
4e6cb116f8 Bluetooth: Mesh: transport: update delayable work
Switch to the new API. Adds early exits for the ack and retransmit
timers, and replaces a remaining_time() + submit() call with schedule().

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Peter Bigot
1577fec851 Bluetooth: Mesh: proxy: update delayable work
Switch to the new API. Adds check for a pending buffer in the SAR
timeout handler.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Peter Bigot
3cba9613a4 Bluetooth: Mesh: pb_gatt: update delayable work
Switch to the new API. Adds a link check to the protocol timeout to
ensure the link is still active.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Peter Bigot
45e5914ce9 Bluetooth: Mesh: pb_adv: update delayable work
Switch to the new API. Consolidates reliable sending logic for the first
transmission and the retransmit into one. Adds check for link active in
protocol timeout.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Peter Bigot
f415ae7859 Bluetooth: Mesh: adv_ext: update delayable work
Switch to the new API in Mesh's extended advertising handler.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Peter Bigot
38609d34e0 Bluetooth: Mesh: Core delayable work updates
Switch to the new API in friend, net and main.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Trond Einar Snekvik
0f5b5f74ac Bluetooth: Mesh: Add friend_is_allocated utility
Friend structure allocaction logic is implemented over and over
throughout the friend module. Move it into a static utility function for
readability.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-28 11:48:59 +03:00
Jennifer Williams
a3c7e45a73 usb: usb_device: fix missing final else
set_endpoint() and reset_endpoint() were missing final
else statement in the if else if construct. This commit
adds a final else {} with assert to comply with coding
guideline 15.7.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-04-27 17:31:59 -04:00
Jennifer Williams
b65abf1d4b testsuite: ztest: src: fix missing final else
cleanup_test() was missing final else statement in
the if else if construct. This commit adds else {}
to comply with coding guideline 15.7.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-04-27 17:31:59 -04:00
Gerard Marull-Paretas
d7da2a31f0 usb: remove usage of device_pm_control_nop
If device PM is not implemented just use NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-27 16:28:49 -04:00
Gerard Marull-Paretas
3daf9f2d97 net: remove usage of device_pm_control_nop
If device PM is not implemented just use NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-27 16:28:49 -04:00
Gerard Marull-Paretas
bfce935caf power: remove device_pm_control_nop function
Devices that do not require PM should just use NULL.
`device_pm_control_nop` is still kept as an alias to NULL untill all
in-tree usage is replaced with NULL.

Code relying on device_pm_control function now returns -ENOTSUP
(equivalent to calling device_pm_control_nop).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-27 16:28:49 -04:00
Peter Bigot
5dced184b8 mgmt: updatehub: Conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Fixes: #34101

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2021-04-27 16:13:24 -04:00
Emil Gydesen
676a91636b Bluetooth: Audio: VOCS add error checks on read
The error check was removed earlier as it was assumed that
we would either get an error, or the data would be valid.
However, without an error check, we are not guarded
against bad reads.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-27 13:31:06 -04:00
Emil Gydesen
449ceca2fe Bluetooth: Audio: Remove VOCS desc data check as it can be empty
If the output description of the server is empty (legal by the
spec), then we should not return an error to the application
when read. Also added some debug statements when the value is
truncated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-27 13:31:06 -04:00
Emil Gydesen
d005a62451 Bluetooth: Audio: Fix issues with setting VOCS offset state
Fixes 2 issues:
1) The write callback always returned an error
2) The auto-read of the offset state did not, unlike what the
comment suggested, retry only once and fail on the second attempt,
but rather keep retrying.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-27 13:31:06 -04:00
Emil Gydesen
abb97f57dd Bluetooth: GATT: Extend GATT notify/indicate security check with auth
Add authentication check to the security checks for
GATT notify and indicate.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-27 13:30:44 -04:00
Emil Gydesen
2f4ee7dcb6 Bluetooth: GATT: Verify security when notifiying or indicating
Adds a security checks when notifying or indicating, such
that we don't send notifications for characteristics that
require encryption on an unencrypted link.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-27 13:30:44 -04:00
Navin Sankar Velliangiri
62149516c4 mgmt: hawkbit: Conversion of k_work API
Implement new workqueue API changes.

Signed-off-by: Navin Sankar Velliangiri <navin@linumiz.com>
2021-04-27 13:29:39 -04:00
Robert Lubos
afaf52af66 net: trickle: Do not initialize a work item from its handler
Initializing a work item from its handler will destroy the content of
the kernel structures used to process the work item. This can lead to a
system crash for example when the delayed work is being rescheduled when
the previous run is already queued for processing but not yet executed.

Fix this by initializing the work item once during trickle timer
creation and moving the logic, previously achieved by switching the work
handler, into the new work handler.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-27 19:48:16 +03:00
Jukka Rissanen
bd03493fdc net: pkt: Have separate create time for net_pkt
This value is used to measure the RX/TX statistics. The previous
use of the timestamp field did not work in RX path as the timestamp
value could be overwritten by the driver if gPTP timestamping
is enabled. So to fix the RX statistics, use a separate field
for the create time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen
3b08e87680 net: If userspace support is enabled, then we need TX/RX threads
If user enables CONFIG_USERSPACE, then at least one TX or RX thread
is needed to isolate the application from the kernel space components.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen
f5fb80750e net: Enable running without TX or RX threads
Set the default behaviour of the networking subsystem so that
no TX or RX threads are created. This will save RAM as there
is no need to allocate stack space for the RX/TX threads.
Also this will give small improvement to network packet latency
shown here:
* with 1 traffic class (1 TX and RX thread)

Avg TX net_pkt (42707) time 60 us	[0->22->15->22=59 us]
Avg RX net_pkt (42697) time 36 us	[0->10->3->12->7=32 us]

* with 0 traffic classes (no TX and RX threads)

Avg TX net_pkt (41608) time 42 us	[0->21->20=41 us]
Avg RX net_pkt (41593) time 31 us	[0->9->12->8=29 us]

In this qemu_x86 test run, 40k UDP packets was transferred between
echo-server and echo-client. In TX the speed increase was 30% and
in RX it was 14%.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen
d533f95e18 net: pkt: Set the pkt creation time more accurately
Set the net_pkt creation time just before the actual net_pkt
is allocated in order to get more accurate information for
statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen
c59372b6e6 net: Push highest priority net_pkt directly to driver
If user has set the priority of the sent net_pkt to highest
priority (NET_PRIORITY_CA) and enabled CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO
option, then push that packet directly to driver instead of TX queue.
This will make the TX sending latency smaller for the high priority
packet. This is not enabled by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Krzysztof Chruscinski
292a15be78 logging: Increase thread stack size when net backend in use
It has been seen that when net backend is enabled stack usage
is around 1080. Setting 1152 as the default.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-26 14:14:34 -04:00
Flavio Ceolin
11ac18abc2 power: Add an assert for an unexpected condition
Exit latency time should never be greater than the residency time.
Just add an assert in case the policy does not properly handle it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-26 08:21:30 -04:00
Flavio Ceolin
fba5779a8d power: policy: Account exit latency
Account exit latency time in the residency policy.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-26 08:21:30 -04:00
Flavio Ceolin
cdcd2dff85 power: Consider the exit latency required by an idle state
Set the timeout to expire "exit_latency_us" earlier to the CPU be
capable of honor the next scheduled event.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-26 08:21:30 -04:00
Emil Gydesen
910e0c63f4 Bluetooth: Audio: VOCS: Move callback structure to register function
Moves the callback structure for VOCS to the register function
which is renamed from init, as there's no reason to register
the callbacks separately.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-26 13:42:50 +02:00