Commit graph

21541 commits

Author SHA1 Message Date
Morten Priess
7dd5820920 Bluetooth: controller: Move common LLL from vendor file
Split lll_prepare and lll_resume from Nordic LLL to common file for
reuse by all vendors. The split also supports new JIT Scheduling by
defining a common place to calculate event prepare priority.

The module may also house other common parts of the LLL currently
re-implemented identically by vendors.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-04-13 12:15:12 +02:00
Morten Priess
385f232ae2 Bluetooth: controller: Propagate ticker force to ULL
The ticker 'force' flag is propagated via the ticker elapsed callback,
in order to provide necessary information for collision resolving in the
link layer.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-04-13 12:15:12 +02:00
Morten Priess
9f82034245 Bluetooth: controller: Introducing slot agnostic ticker
Added config BT_TICKER_SLOT_AGNOSTIC which configures the ticker in
a "slot agnostic" mode, in which no collision resolving or slot
reservation is possible or used. In this mode, the ticker acts as a
simple timer.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-04-13 12:15:12 +02:00
Morten Priess
4277af8f55 Bluetooth: controller: Rename BT_TICKER_COMPATIBILITY_MODE
Renamed to BT_TICKER_LOW_LAT in ticker, and changed selected
conditionally compiled code to use IS_DEFINED macro.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-04-13 12:15:12 +02:00
Robert Lubos
1a69317eea shell: telnet: Make sure the delayed work becomes idle after canceling
Replace k_work_cancel_delayable() with k_work_cancel_delayable_sync()
to make sure that the submitted work becomes idle before accessing
sensitive data.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-12 11:47:24 -04:00
Robert Lubos
501c7d17b0 shell: telnet: Update to the new k_work API
Update the shell telnet backend to use the new k_work_delayable API.

Fixes #34100

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-12 11:47:24 -04:00
Emil Gydesen
2016509756 Bluetooth: Audio: Audio Input Control Service and client
This commit implements the secondary service
Audio Input Control Service (AICS) server and client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-12 11:47:00 -04:00
Eduardo Montoya
1d668d4b7c net: openthread: add microseconds timer API
Add OpenThread API to handle microseconds timer, to be used initially
by CSL receiver.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-04-12 17:01:14 +03:00
Flavio Ceolin
d0dac69fa9 logging: Fix 10.4 violations
Both operands of an operator in which the usual arithmetic
conversions are performed shall have the same essential
type category.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-10 09:59:37 -04:00
Vinayak Kariappa Chettimada
661991405b Bluetooth: controller: Move LLL done handling from ULL to LLL
Move the LLL done event handling from ULL to LLL, this
reduces CPU utilization and reduces overhead between radio
events.

Fixes #21993.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-09 11:55:29 -04:00
Vinayak Kariappa Chettimada
5be2149c48 Bluetooth: controller: Defer event early abort
Defer the event early abort so that lll_done does not get
recursively invoked when called inside prepare callback.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-09 11:55:29 -04:00
Vinayak Kariappa Chettimada
27c26eb1e7 Bluetooth: controller: Fix LLL done and pipeline enqueue race
There is a race between the pipeline enqueue by the ULL
context when processing the LLL done event, and the
pipeline queue by the ticker timeout for a new radio
event. This caused an already enqueued event prepare to be
placed after the newly arrived request to enqueue a prepare
by ticker timeout.

Fix this race by placing the new prepare in the pipeline
instead of starting the event, when ULL is still processing
the LLL done event.

As ticker timeout and ULL processing of LLL done event are
in the same ULL_HIGH context, the pipeline handling is safe
with the order of prepares maintained correctly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-09 11:55:29 -04:00
Michał Narajowski
f62a40beb6 Bluetooth: Fix callback handling in ECC Public Key generation
Commit d6c34c4644 changed the behavior
slightly but didn't update the documentation. The callback will now be
reset to NULL once the key is generated. Calling bt_pub_key_gen()
multiple times before the key is finished would result in creation of an
infinite loop. This could happen when an application calls mesh_init()
and mesh_reset() in quick succession. Clarify the behavior of the API in
the documentation.

Also passing a NULL argument would result in an undefined behavior, so
add a check to match the behavior described in documentation.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-04-09 13:27:24 +02:00
Emil Gydesen
42da370df5 Bluetooth: Use ATT FIRST/LAST attribute handle defines where applicable
Change to use the BT_ATT_FIRST_ATTTRIBUTE_HANDLE and
BT_ATT_LAST_ATTTRIBUTE_HANDLE instead of the literal values where
applicable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-08 16:35:57 +02:00
Emil Gydesen
83396d91e2 Bluetooth: ISO: Fix segmentation fault for disconnecting BIS
The bt_iso_chan_disconnected assumes a CIS, but was
also used for BIS, so whenever it was called it attempted
to get a non-existing ACL connection.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-08 16:35:27 +02:00
Pavel Vasilyev
a94c7e3a23 Bluetooth: Mesh: Introduce acknowledged message API
The implementation of blocking calls is common for all the client
models.

This change reduces the code duplication by introducing new API that
helps to manage acknowledged messages.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-04-08 13:44:24 +02:00
Jukka Rissanen
b59f0e5057 log: Align the log_strdup_buf properly
The k_mem_slab_init() calls create_free_list() which checks
the slab block alignment. Noticed with Intel ehl_crb board,
which is 64-bit architecture, that the k_mem_slab_init() fails
because the log_strdup_buf items were not aligned properly.
This commit adds the alignment requirement to log_strdup_buf so
that the elements are alignment properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-08 09:57:42 +02:00
Emil Gydesen
477dab13b3 Bluetooth: ISO: Update check for invalid num_bis for BIS events
Updates the check to only log the error if the issue was with
the num_bis and not the status.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 23:23:34 +02:00
Emil Gydesen
c479aa8211 Bluetooth: ISO: Add missinng disconnect reason to big_disconnect
A few calls to big_disconnect was missing the disconnect reason
due to a bad rebase.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 23:23:34 +02:00
Emil Gydesen
55771d36a7 Bluetooth: shell: Add index check for per_adv_sync commands
Adds a check for valid index before accessing the per_adv_syncs
array.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:17:34 +02:00
Emil Gydesen
49bf124bf6 Bluetooth: shell: Fix null check in cmd_per_adv_sync_delete
The check for NULL was on the pointer to the pointer,
rather than the pointer. The pointer of the pointer would
always be non-null, but the pointer might not be.

Moved from using a pointer of a pointer to just a
pointer to make it easier to read and understand.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:17:34 +02:00
Emil Gydesen
026da2df03 Bluetooth: host: Add ISO disconnect reason
Adds a disconnect reason in the ISO disconnect callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:16:54 +02:00
Emil Gydesen
62ba4f325c Bluetooth: host: Fixed bt_le_per_adv_sync interval unit decription
Changed from 1.25MS to 1.25 ms to be consistent with other
unit decriptions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:16:46 +02:00
Emil Gydesen
5a1afaa47a Bluetooth: host: Add functions for periodic adv sync objects
Adds two functions:
1) Lookup periodic adv sync object by address
2) Get information about a periodic adv sync object.

These can be useful for the application verify if there is already an
existing sync to an periodic advertiser.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-07 14:16:46 +02:00
Martin Jäger
962e361e54 canbus: isotp: prevent race-condition during debugging
During debugging I got "Got unexpected PDU" errors because a new CF was
received before the state was set to ISOTP_TX_WAIT_FC in the send state
machine. Setting the state before printing the debug information fixes
the issue.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-04-06 16:44:34 -04:00
Martin Jäger
0c8cb0586a canbus: isotp: add fixed addressing feature
Fixed addressing as specified in ISO 15765-2 encodes the source and
target address of a device or function inside the CAN ID according to
SAE J1939.

In order to allow to receive incoming requests from different nodes,
the CAN filter mask has to be set such that the source address is
ignored in the receive context. In addition to that, flow control
frames have to be sent back to the actual source of the request, which
requires adjustments to the TX CAN ID.

This commit implements above features and thus allows ISO-TP to be
used in a network based on SAE J1939 or NMEA-2000.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-04-06 16:44:34 -04:00
Martin Jäger
f5496147b5 canbus: isotp: allow frames with padding
ISO 15765-2 specifies that the CAN frame length for single frames and
the last consecutive frame may or may not be optimized to the actual
length of the PDU payload. The ISO-TP implementation should only
consider the information from the N_PCI section.

The previous implementation did not allow padding. With this commit,
padding is allowed by default and can even be required to be more
compliant to AUTOSAR standards.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-04-06 16:44:34 -04:00
Martin Jäger
ade6cc4a71 canbus: isotp: fix asserts to check rx and tx addr
Previous implementation contained a typo so that only the rx address
was checked.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-04-06 16:44:34 -04:00
Daniel Leung
1559712b22 timing: add kconfig CONFIG_TIMING_FUNCTIONS_NEED_AT_BOOT
This adds a new kconfig CONFIG_TIMING_FUNCTIONS_NEED_AT_BOOT so
that the timing subsystem can be initialized at boot, instead of
being #ifdef under thread runtime statistics. This will allow
other part of kernel and other subsystems to utilize the timing
functions.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-04-06 16:43:55 -04:00
Joakim Andersson
9f7061a83d Bluetooth: host: Add discovery of standard descriptor values
Add discovery of standard descriptor values. This provides a shorthand
instead of doing a read by UUID, allowing the application discovery
procedure to re-use the discover parameters for simple descriptors.

Fixes: #21489

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-04-06 10:50:18 -04:00
Flavio Ceolin
8153666a27 logging: Fix 14.4 guideline violation
The controlling expression of an if statement has to be an
essentially boolean type.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-06 10:25:24 -04:00
Trond Einar Snekvik
b84fee5190 Bluetooth: Mesh: Composition data page 0 traversal
Adds a parsing mechanism for Composition data page 0 in the Config
Client API, and uses it in the shell module to parse the incoming
composition data.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-06 16:19:13 +03:00
Trond Einar Snekvik
9259b199bb Bluetooth: Mesh: Rename bt_mesh_cfg_comp_data_get's status param to rsp
The first byte of the composition data status message is the returned
page index, not the status of the request. This is now reflected in the
API.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-06 16:19:13 +03:00
Vinayak Kariappa Chettimada
470e9fdd5c Bluetooth: controller: Fix minor typo in Periodic Sync PHY
Fix minor typo in Periodic Advertising Sync implementation
when PA/LNA is enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-06 13:52:14 +02:00
Vinayak Kariappa Chettimada
6ae93e62f0 Bluetooth: controller: Trivial peripheral ISO code cleanup
Trivial peripheral ISO code cleanup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-06 13:51:56 +02:00
Morten Priess
07d4ba5917 Bluetooth: controller: Fix ISO CI tests
Make bluetooth.init tests for nRF platform pass again by adding ULL/LLL
stub functions, and fixing minor compile issues.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-04-06 13:51:56 +02:00
Vinayak Kariappa Chettimada
a0c255f23e Bluetooth: controller: openisa: Fix missing conditional compile
Fix missing conditional compile regression introduced by
the commit 34451a9970 ("Bluetooth: controller: Conditional
compile adv addr used by initiator").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-06 13:51:45 +02:00
Alexey Markevich
5ee6793e57 jwt: use pre-computed JWT header
JWT header is unmodifable and can be used as constant.

Signed-off-by: Alexey Markevich <buhhunyx@gmail.com>
2021-04-03 06:52:40 -04:00
Emil Gydesen
b86f7addae Bluetooth: SMP: Adds Kconfig for minimum encryption key size
Adds a Kconfig option to set the minimum key size accepted
by this device. This can be used to e.g. enforce 128-bit keys.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-02 16:46:18 +03:00
Jukka Rissanen
ce2abc26b5 net: capture: Catch sent and received packets
Create net_l2_send() function which will be called by each L2
sending function so that we can catch all the network packets
that are being sent. Some L2 layers send things a bit differently,
so in those cases call the net_capture_send() directly by the L2
layer.
Add network packet capture call in receive side after the pkt has
been received by the RX queue handler. This avoids calling the
net_capture_send() from ISR context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
af2711db23 net: shell: Print external net_pkt slab information
The "net mem" command did not print external net_pkt slabs
properly (the number of free net_pkt's was not printed).

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
313d973be0 net: shell: Show detailed interface information
Show detailed information about network interface that is down,
only when user asks such information about one specific network
interface. This means that for "net iface" command only
"Interface is down." is printed but the command "net iface 1"
will print detailed information even if interface is down.
This helps to view the information and user does not need
to bring interface up to see the details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
c5d062a400 net: shell: Add network packet capture support
Add commands in shell to setup and enable/disable network
packet capture.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
e917d80473 net: capture: Add support for network packet capturing
Add infrastructure to allow user to configure the system so that
all the network packets, that are sent to or received from a specific
network interface, are sent to remote system for analysis.
The captured network packets are placed as a payload in UDP packet,
which is then sent inside a tunnel to a remote host. The host can
then receive the packets and for example show them in wireshark.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
0501957f26 net: pkt: Add helper to store capture bit
Add get/set helpers to store information whether the net_pkt
is captured already or not. This bit is used to detect capture
loop and avoid recursion.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
c6fac25e87 net: pkt: Make net_pkt_clone() to use the original slab
Instead of forcing net_pkt_clone() use the tx_pkts slab, use
the same slab that was used when allocating the original net_pkt.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
934caba82b net: l2: ipip: Support more than one IPIP tunnel
Alloc code to create more than one IPIP tunnel interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Jukka Rissanen
574b8725e0 net: l2: ipip: Add capability bit for IPIP tunnel
The IPIP tunnel capability bit helps to detect which network
interface supports IPIP tunneling.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-02 07:24:06 -04:00
Robert Lubos
814fb71bf3 net: socket: Implement SO_BINDTODEVICE socket option
Implement SO_BINDTODEVICE socket option which allows to bind an open
socket to a particular network interface. Once bound, the socket will
only send and receive packets through that interface.

For the TX path, simply avoid overwriting the interface pointer by
net_context_bind() in case it's already bound to an interface with an
option. For the RX path, drop the packet in case the connection handler
detects that the net_context associated with that connection is bound to
a different interface that the packet origin interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-02 07:23:17 -04:00
Emil Lindqvist
3115610558 net: socket: dtls: add sockopt to set & get dtls handshake timeout
An option has been added which can be passed to setsockopt
which allows the user to set & get the dtls handshake timeout,
either before first handshake or online.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2021-04-01 20:02:59 +03:00