Commit graph

21541 commits

Author SHA1 Message Date
Stephanos Ioannidis
e0d582a6b6 cpp: Remove C++ exception handling arch restriction
The C++ exception handling feature is now supported on all
architectures.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-05-28 12:07:46 -05:00
Krzysztof Kopyściński
a527409011 Bluetooth: host:l2cap: fix sending error in le_ecred_reconf_req
Result to send was overwritten by BT_L2CAP_RECONF_SUCCESS just after
exiting while loop. This caused to send success response even if
reconfiguration failed. Now, result is initialized to success value,
and if reconfiguration fails, this value will be overwritten with
appropriate one. Added BT_L2CAP_RECONF_INVALID_CID (0x0003) for invalid
cid in request. Added BT_L2CAP_RECONF_OTHER_UNACCEPT (0x0004) to return
if MPS is to small. Reordered checks for mps/mtu as
BT_L2CAP_RECONF_OTHER_UNACCEPT is expected to be returned if both mps
and mtu are to small.

This was affecting L2CAP/ECFC/BI-05-C and L2CAP/ECFC/BI-05-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-05-28 10:50:42 -05:00
Joakim Andersson
faae326648 net: l2: bluetooth: Handle error if failed to register server
Return error code if init code failed to register the L2CAP server.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-28 10:44:47 -05:00
Ioannis Glaropoulos
dd574f6ec7 kernel: stack_sentinel: disable in single-threaded builds
Add a dependency on MULTITHREADING for the
STACK_SENTINEL feature, so it may not get
enabled in single-thread Zephyr builds.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-05-28 10:41:46 -05:00
Daniel Leung
dfa4b7e375 kernel: mmu: z_backing_store* to k_mem_paging_backing_store*
These functions are those that need be implemented by backing
store outside kernel. Promote them from z_* so these can be
included in documentation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Daniel Leung
31c362d966 kernel: mmu: rename z_eviction* to k_mem_paging_eviction*
These functions and data structures are those that need
to be implemented by eviction algorithm and application
outside kernel. Promote them from z_* so these can be
included in documentation.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-28 11:33:22 -04:00
Luiz Augusto von Dentz
066a7c2de5 Bluetooth: conn: Align cleanup for ISO connections
This makes connections of type BT_CONN_TYPE_ISO use BT_CONN_CLEANUP to
cleanup so the TX and RX queues are properly cleanup.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-05-28 15:34:20 +03:00
Luiz Augusto von Dentz
2a99d80403 Bluetooth: shell: Add connection type information to connections command
This prints information about the role and id along with connection
parameters in case the connection is of LE type.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-05-28 15:34:20 +03:00
Luiz Augusto von Dentz
fc9b7e62f0 Bluetooth: conn: Add support for ISO connections to bt_conn_get_info
This enables bt_conn_get_info to be used with connection of type
BT_CONN_TYPE_ISO.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-05-28 15:34:20 +03:00
Luiz Augusto von Dentz
8b6d3c6c4d Bluetooth: ISO: Fix call order of connected callback
The state shall be set before calling the callback as it could be check
code behind would expect the channel to be in connected state.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-05-28 15:34:20 +03:00
Luiz Augusto von Dentz
76ad664d4e Bluetooth: ISO: Fix not assigning CIG and CIS IDs
When handling CIS Requested event CIG and CIS IDs must be set in order
for the channel to be properly accepted.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-05-28 15:34:20 +03:00
Luiz Augusto von Dentz
21404c4bd0 Bluetooth: ISO: Simplify reference handling
This makes bt_conn_cleanup to be automatically called when the last
reference to a connection of BT_CONN_TYPE_ISO is dropped.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-05-28 15:34:20 +03:00
Pieter De Gendt
6d99e952cd net: mgmt: Initialize the event callbacks statically
This commit allows to add callbacks to NET_EVENT_IF_UP events before
the network initialization.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-05-28 07:00:23 -05:00
Martin Åberg
23bb8f421f cpp: Update list of archs supporting C++ exceptions
C++ exceptions are supported on SPARC.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-05-28 06:32:36 -05:00
Torbjörn Leksell
22071d613c Tracing: TRACING_NONE Compilation Fix
Fixed several compilation errors that resulted from selecting
TRACING without specifying a tracing system (Tracerecorder,
CTF, Systemview). In this case (TRACING_NONE), some default trace hooks
(in tracing.h) were incorrectly named resulting in compilation errors.
The legacy sys_trace_isr_enter, sys_trace_isr_exit, and sys_trace_idle
also caused problems since these were only given as defines, resulting
in undefined reference errors since they are required by the assembly
files calling these. To solve this issue I've added a stub file
"tracing_none.c" (only compiled if TRACING_NONE) and declared the
functions in tracing.h if no tracing system is selected.

Signed-off-by: Torbjörn Leksell <torbjorn.leksell@percepio.com>
2021-05-27 14:39:40 -05:00
Stephanos Ioannidis
d05977b8e1 cpp: Restrict C++ exceptions usage to supported archs
This commit makes CONFIG_EXCEPTIONS un-selectable for the architectures
that are known to have broken C++ exception handling support
(see #32448).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-05-27 14:36:13 -05:00
Flavio Ceolin
40780fdbeb pm: device: Get rid of device_idx_t
It was just making the code hard to read. Also it was not following
the code guideline because the type was not telling us the sign
and size.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-27 14:35:27 -04:00
Flavio Ceolin
3dad4a068a pm: device: Get rid of z_pm_core_devices
z_pm_core_devices was hack to set some priority between devices. It
was doing it hardcoding some devices that were the first to bring up
and the last to power down. Remove it and use the same list used to
initialize devices.

Fixes #34214

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-27 14:35:27 -04:00
Eduardo Montoya
9c6895105d drivers: ieee802154: fix ACK length handling
OpenThread expects the FCS field at the end of the ACK frame to be
passed with `otPlatRadioTxDone`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-27 12:59:06 -05:00
Emil Lindqvist
91177eebc1 net: sockets: tls: check return code from fcntl
Not checking return code in fcntl can result in interpreting -1 as
flags, and cause unexpected behaviour.

Fixes #35541

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2021-05-27 15:44:03 +02:00
Krzysztof Chruscinski
f98bc0c0bc logging: backend_rtt: Align to changes in RTT_LOCK/UNLOCK
RTT_LOCK/UNLOCK in certain configuration creates code block (curly
braces). In that case variables declared inside are local to that
block. Moved declaration of ret variable before the block. Updated
code to ensure that RTT_LOCK/UNLOCK are in the same code block.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-27 13:33:02 +02:00
Casper Bonde
3af1f4bac5 Bluetooth: ISO: Make it possible to setup unidirectional CIS
The current iso commands in the shell only supports setting up
a bidirectional stream or unidirectional for central role.
Adding rx/tx/rxtx option to iso listen command to allow for
peripheral side configuration of an iso connection.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2021-05-27 13:16:40 +02:00
Casper Bonde
04dfcba792 Bluetooth: ISO: Add sequence number to ISO data packets
The sequence number is needed in the appliaction layer to detect lost
packets in the ISO stream in cases where the timestamp is not included.
(Sequence number is mandatory to include where timestamp is optional).
The API for the public metadata have been moved to a public header file.

As the size of the ISO meta data exceeds the default 4 octets net_buf
user_data the public ISO metadata have been moved into a seperate array.
The internal metadata is still stored in net_buf user_data.

This also fixed the user_data overflow on 32 bit systems, caused by
writing the ts into user_data on index 4 to 7, which is outside the 4
allocated bytes.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2021-05-27 13:16:40 +02:00
Flavio Ceolin
3056c5ec30 pm: device_runtime: Remove not necessary check
pm_device_runtime_state_set takes care of the check the reference count
and take the right action. It is not necessary check it in
pm_device_request.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
5c03d9643f pm: device_runtime: Simplify mutex usage
Assuming that pm_device_state_set is synchronous it is possible to
simplify the mutex usage. Now there are two places where the lock is
held, one in the worqueue handler and other in pm_device_request to
cover the synchronous path. It is no longer needed held the lock in the
pm_device_state_set callback and not needed to wait on the conditional
variable after set the state in the synchronous path.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
d67a5786bc pm: device_runtime: Change API behavior s/_sync/_async
Most APIs have the default synchronous and an asynchronous version
with the sufix _async because that is the most common use.

All devices in tree right now are using the synchronous version, so
just change it to be consistent with the rest of the system.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
29d3246ba5 pm: device_runtime: Don't use k_work on synchronous calls
Do not use worqueue on put/get synchronous calls.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
d325642892 pm: device_runtime: Get rid of atomic for state
Since we are using mutex to protect critical sections and mutexes are
reentrant, it is possible to get rid of atomic for the state because
we can lock the mutex in device_pm_callback.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
97281b3862 pm: device_runtime: get rid of the spinlock
Protect critical sections using the mutex.
The mutex is required to use the conditional variable and since we
need to atomically check the pm state and the workqueue before wait
the condition, it is necessary to protect them using the same mutex.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
366c6ad47b pm: device_runtime: Fix sync path
Properly wait on conditional variable using the new API.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
ce989e33e6 pm: device_runtime: Fix atomic usage
Protect critical sessions using the spinlock available. The atomic
usage was not properly protecting the critical section and was
possible to have a race condition between the usage check and state
set.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
98fd9c3e65 pm: device_runtime: Fix enable / disable runtime pm
Device pm runtime should only be enabled if device supports pm.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Flavio Ceolin
378a19d2a8 pm: device_runtime: Add helper to wait on async ops
Add a function that properly uses a mutex to check a condition before
wait on the conditional variable.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-26 10:56:55 -04:00
Joakim Andersson
b6c95edc63 Bluetooth: host: Fix extended advertising feature bit check
Fix CONFIG_BT_EXT_ADV_LEGACY_SUPPORT option which optimizes the host
to skip checking the feature bit of the controller to check for
extended advertising commands.
This was broken because of how this was implented using an undef of the
feature bit, which was not replicated in scan.c, adv.c and id.c once
this was split out from hci_core.

Instead of doing this wierd way of redefining the feature check macro
do it in a proper way by defining a new macro.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-26 16:35:15 +02:00
Dominik Ermel
f451cd3663 mgmt/mcumgr: Info on SHELL_BACKEND_DUMMY_BUF_SIZE impact on mcumgr
The commit adds information to Kconfig options:
 MCUMGR_CMD_SHELL_MGMT and MCUMGR_BUF_SIZE
on how the SHELL_BACKEND_DUMMY_BUF_SIZE value impacts them.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-05-26 00:05:56 -04:00
Dominik Ermel
3b49ed46df shell: Parametrize dummy shell buffer size
The commit adds Kconfig option to configure dummy shell buffer size.
Size of this buffer determines how mutch of command output will be
stored in buffer.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-05-26 00:05:56 -04:00
Dominik Ermel
f20cc4b7a4 storage/flash_map: Fix flash area bounds checking
The commit adds check if offset is positive; previously negative
offset would be allowed, which means that writing flash before flash
area start was possible.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-05-25 16:59:01 -05:00
Joakim Andersson
8a32c2d967 Bluetooth: host: Fix disconnect priority event handling
Fix issue is host handling of connected and disconnected event.
Since the host wants the disconnected event to be processed as a
priority event as well as in reguler event context while the connected
event is always in reguler event context we can end up in a situation
where the disconnected priority event is processed before the connected
event.

Since the disconnected priority event is there to release unack'ed TX
pending on the connection in case the RX thread is blocked waiting
for TX resources, we need to keep this behavior. Otherwise this would
be a potential deadlock of the RX thread waiting for resources that can
only be released by the RX thread.
When this situation happens we know that there cannot be any pending TX
on this connection so we can safely skip releasing of unack'ed TX.

The second thing the disconnected priority event does is marking the TX
path on the connection as disconnected. We need to do the same in this
situation, so we make sure that the TX path is already marked
disconnected when providing the connected callback to the application.

This fixes a regression from 4be66bd33d.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-25 20:30:48 +03:00
Joakim Andersson
c99b7ba71c Bluetooth: host: Fix L2CAP sent callback on disconnected channel
When receiving the L2CAP sent callbacks the dynamic L2CAP channel may
have been disconnected already. The user of the dynamic channel should
have received the disconnected and released callbacks for this channel
to release any resources for the data being sent, so simply ignoring
this sent callback is enough.

Fix sent callbacks by providing the CID to the callback instead of a
pointer to potentially released memory, and lookup the CID to check that
it is still valid.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-25 19:26:32 +02:00
Joakim Andersson
c429ffb0ed Bluetooth: host: Add check for already enabled in advertising set start
Add check for the advertising already being enabled when attempting to
start the advertising set.
Document that the advertising set cannot be started from the connection
connected callback, and instead has to be started from the advertising
set connected callback.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-25 19:26:23 +02:00
Joakim Andersson
3318bd3491 Bluetooth: host: Fix multiple advertisers with different ID support
Fix multiple advertisers with different ID support, this was added
in 98321c61fb but the guard was never
removed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-25 19:25:05 +02:00
Vinayak Kariappa Chettimada
79f6a63840 Bluetooth: controller: Fix initial empty flag for peripheral
Fix to avoid an assertion when processing an acknowledgment
in the first connection event in peripheral role.

Ensure that empty flag reflects the state of the Tx queue,
as a peripheral the first connection event has no prior PDU
transmitted, an incorrect acknowledgment by peer should
not dequeue a PDU that has not been transmitted on air.

Relates to assert added in commit 2bfaadffb8 ("Bluetooth:
controller: Add Tx fragmentation assertion").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-25 19:24:55 +02:00
Krzysztof Chruscinski
8c4bffa66c ipc: rpmsg_service: Add missing log_strdup
Add missing log_strdup to %s parameters.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-25 16:38:28 +02:00
Anas Nashif
108129cf7d tracing: fix conflict with RTT locking
Make custom RTT locking configurable and select it where it is needed.
When using RTT for tracing we want to use the default locking.

Update both segger and tracerecorder modules to support that.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-25 07:36:38 -05:00
Anas Nashif
acee43a176 tracing: fix indentation of config entries
Fix indentation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-25 07:36:38 -05:00
Jukka Rissanen
0f69123897 net: tcp2: Ack any data received in FIN_WAIT_1 state
If we receive any data in FIN_WAIT_1, then ack it even if we
are discarding it.

Fixes #33986

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Jim Paris <jim@jim.sh>
2021-05-24 23:30:36 -04:00
Jukka Rissanen
c53d483b6d net: sockets: Do not hijack k_fifo API name
The k_fifo_ prefix is meant for kernel API functions, and
not to our socket helper. So remove the k_ prefix in order
to avoid confusion.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-24 23:30:18 -04:00
Jukka Rissanen
20a51b49a0 net: sockets: Release the socket lock if needed
If we are waiting all the data i.e., the MSG_WAITALL flag is set,
then if we have not yet received all the data at the end of the
receive loop. We must use the condition variable to get the signal
when the data is ready to be received. Otherwise the receive loop
will not release the socket lock and receive_cb will not be able
to indicate that data is received.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-24 23:30:18 -04:00
Jukka Rissanen
1184089d54 net: sockets: Add locking to receive callback
Fix a regression when application is waiting data but does
not notice that because socket layer is not woken up.

This could happen because application was waiting condition
variable but the signal to wake the condvar came before the
wait started. Normally if there is constant flow of incoming
data to the socket, the signal would be given later. But if
the peer is waiting that Zephyr replies, there might be a
timeout at peer.

The solution is to add locking in socket receive callback so
that we only signal the condition variable after we have made
sure that the condition variable is actually waiting the data.

Fixes #34964

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-24 23:30:18 -04:00
Joakim Andersson
7986cae05c Bluetooth: host: Remove cancel sync from database hash commit
Fix deadlock when db_hash_commit has to wait for the delayed work to
finish. This creates a deadlock if the delayed work for database hash
calculation needs to store the hash since the settings API is locked
when calling the commit callback.
Remove call to k_work_cancel_delayable_sync from db_hash_commit in order
to avoid the deadlock. Instead move comparing of the stored hash to the
delayed work and reschedule the work with no wait.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-24 23:29:52 -04:00