Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
afff307645 Bluetooth: controller: Initial support for set periodic adv data
Add initial support for LE Set Periodic Advertising Data
command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-13 09:56:53 +01:00
Vinayak Kariappa Chettimada
92a942257d Bluetooth: controller: Fix Extended Advertising data population
Fix Extended Advertising Data population when there is no
Extended Header to be filled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-13 09:56:53 +01:00
Andrzej Kaczmarek
a17952237f Bluetooth: controller: Fix build error
.../ll_sw/nordic/lll/lll_scan.c: In function 'isr_tx':
.../ll_sw/nordic/lll/lll_scan.c:483:19: error: unused variable 'lll'
                                              [-Werror=unused-variable]
  483 |  struct lll_scan *lll = param;
      |                   ^~~
cc1: all warnings being treated as errors

This fixes https://github.com/zephyrproject-rtos/zephyr/issues/29968.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-13 00:02:12 +02:00
Jan Georgi
5da68ea186 net: shell: Added missing check for eth iface in "net iface" cmd
checking if iface is ethernet, before calling ethernet api func

Signed-off-by: Jan Georgi <jan.georgi@lemonbeat.com>
2020-11-12 14:16:40 +02:00
Daniel Leung
939d48cb02 shell: show thread execution cycles
This adds the bits to show the thread execution cycles
when doing "kernel threads" in shell.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-11-11 23:55:49 -05:00
Daniel Leung
11e6b43090 tracing: roll thread switch in/out into thread stats functions
Since the tracing of thread being switched in/out has the same
instrumentation points, we can roll the tracing function calls
into the one for thread stats gathering functions.
This avoids duplicating code to call another function.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-11-11 23:55:49 -05:00
Daniel Leung
9be37553ee timing: do not repeatedly do init()/start()/stop()
We should not be initializing/starting/stoping timing functions
multiple times. So this changes how the timing functions are
structured to allow only one initialization, only start when
stopped, and only stop when started.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-11-11 23:55:49 -05:00
Didrik Rokhaug
89f6e24590 rand: xoroshiro128: fix buffer overflow
If rand32_xoroshiro128::z_impl_sys_rand_get is called with outlen
not divisible by 4, it will overflow the dst buffer. This happens
because blocksize is not changed from 4 to the difference between
outlen and len. If outlen is < 4, z_impl_sys_rand_get will be stuck
in an infinite loop that keeps writing random bytes outside the buffer.
If outlen is > 4, z_impl_sys_rand_get returns after the correct number
of loops, but it writes every byte to the buffer, not just outlen number
of bytes. This causes the buffer to be overflowed with up to and
including 3 bytes.

Signed-off-by: Didrik Rokhaug <didrik.rokhaug@gmail.com>
2020-11-11 15:02:04 -06:00
Andrzej Kaczmarek
273cb94c0d Bluetooth: controller: Resolve AdvA in ADV_EXT_IND properly
Since ADV_EXT_IND is received on primary channel, the AR is configured
to resolve AdvA in legacy PDU (assuming on 1M) and it will not resolve
AdvA properly. In such case, we should resolve AdvA manually in LLL.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:27:25 +01:00
Andrzej Kaczmarek
0316329db1 Bluetooth: controller: Add radio API to resolve addr via AAR
This allows to synchronously resolve any address using AAR. The AAR
has to be configured prior to calling this function.

The intended use for this function is to resolve AdvA in a PDU on
primary channel when AR was configured for different PDU type. That
means AR was configured to resolve in legacy PDU, but extended PDU
was received and we need to resolve AdvA manually. In such case, AAR
is already configured so just need to trigger it again with proper
ADDRPTR.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:27:25 +01:00
Andrzej Kaczmarek
de027edfb8 Bluetooth: controller: Configure AR for resolving in ext adv
This patch allows to configure AR for resolving AdvA in extended adv
PDUs. The extra 'flags' field provides a hint from caller on how to
setup AR:
- if legacy PDU is expected, AdvA is set after PDU header,
- if extended PDU is expected, AdvA is set with +2B offset due to
  common extended advertising header,
- if Coded PHY is used, AdvA is set with extra +5b offset due to CI and
  TERM1 fields.

Note that AUX_SCAN_REQ and AUX_CONNECT_REQ are also considered legacy
PDUs here since they are exactly the same as SCAN_REQ and CONNECT_IND.

If neither legacy nor extended PDU is specified, it's derived from PHY,
i.e. 1M means legacy, non-1M means extended. Since it is still possible
to receive different type PDU in such case, it's up to LLL to detect
this and resolve AdvA when RX is done.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:27:25 +01:00
Andrzej Kaczmarek
fb0c3dbaa4 Bluetooth: controller: Disable AAR PPI on AR reset
This was never disabled so would be triggered even if not explicitly
enabled.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:27:25 +01:00
Emil Gydesen
d911f99bfc Bluetooth: controller: guard NODE_RX_TYPE_USER with range value
Instead of guarding the NODE_RX_TYPE_USER cases with
CONFIG_BT_CTLR_USER_EXT we guard them with
CONFIG_BT_CTLR_USER_EVT_RANGE > 0 as that is the actual value that
enables/disables the NODE_RX_TYPE_USER values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-11 13:25:20 +01:00
Emil Gydesen
58eb76e06d Bluetooth: Controller: Change node_rx_type to auto incrementing enum
Instead of having explicit values for each entry in the enum that
has to be updated for each new entry (thus requiring manual work
which can also be error-prone), the enum will now be
self-incrementing, to make it easier and safer to add new
entries.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-11 13:25:20 +01:00
Emil Gydesen
8af767e28c Bluetooth: controller: Remove #ifdef for node_rx_type enum
Removed the #ifdef's for the node_rx_type enum. Since the
savings, they just make the enum harder to read.

Furthermore it will also ensure that all the enum values
will have the same value once the enum entries are no
longer manually defined.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-11-11 13:25:20 +01:00
Erik Brockhoff
b67233c6a4 bluetooth: controller: don't assert on rl disabled
Simply return 0 to indicate the deferred resolve was not accepted when
address resolve is not enabled

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2020-11-11 13:24:14 +01:00
Thomas Ebert Hansen
28a8582a49 Bluetooth: host: Fix endianness in conn. handle
Fix the endianness of the connection handle in the handler for
BT_HCI_EVT_REMOTE_VERSION_INFO.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2020-11-11 13:23:49 +01:00
Andrzej Kaczmarek
04a48d9ec2 Bluetooth: controller: Fix build without BT_CENTRAL
lll->conn is only defined valid when BT_CENTRAL is enabled.
Also ull_sched_mfy_after_mstr_offset_get is only used when BT_CENTRAL
is enabled.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:23:33 +01:00
Lingao Meng
7e302979f3 Bluetooth: Mesh: Fix DST field check when send
Add check for dst field in transport layer tx function.

Fixes: #29868

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-11-11 13:23:14 +01:00
Trond Einar Snekvik
a2aad2b3f8 Bluetooth: Mesh: Check TTL max value on transport TX
Adds check for TTL max in the transport send functions, and moves
setting of default TTL to transport.

Fixes #29855.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-11 13:22:34 +01:00
Joakim Andersson
d81197ff77 Bluetooth: shell: Fix shell scan option duplicate filtering options
Fix the shell always setting the filter duplicates option for active
scan.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-11 13:22:02 +01:00
Joakim Andersson
bd7a2fc395 Bluetooth: host: Change directed advertising to privacy-enabled peer
Change the advertising option that controls if the directed advertiser
will use an RPA or the identity address of the peer for the initiator
address.
This option currently has two issues:
 - It behaves differently if the privacy feature has been enabled,
   which can be confusing for application to use.
 - It cannot start a directed advertiser towards a peer that is not
   privacy-enabled and has distributed an IRK.

This commit includes the following changes:
 - When privacy has been enabled in order to advertise towards a
   privacy-enabled peer the BT_LE_ADV_OPT_DIR_ADDR_RPA option must now
   be set (same as when privacy has been disabled).
 - It is now possible to start a directed advertiser using the identity
   address of the peer when privacy-enabled.
 - When privacy has been enabled the advertising option combination
   of using the local identity address and an RPA as the initiator
   address is now disallowed and will return an error code.
   This is done because this combination did not actually work and would
   have used the identity address of the peer instead.
 - If the controller does not support controller-based privacy then
   using the option BT_LE_ADV_OPT_DIR_ADDR_RPA will return ENOTSUP
   because this behavior cannot be done with host-based privacy.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-11 13:22:02 +01:00
Andrzej Kaczmarek
904a421915 Bluetooth: controller: Disallow starting scannable adv w/o scan rsp
Scannable advertising set cannot be started without scan response data.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:20:40 +01:00
Andrzej Kaczmarek
7195ce6970 Bluetooth: controller: Allow to discard scan response data
Host can discard scan response data by setting empty data. We simply
set PDU length to 0 to indicate this, it will make future check easier.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:20:40 +01:00
Andrzej Kaczmarek
b08a0bd8a7 Bluetooth: controller: Fix LE Set Ext Scan Rsp Data restrictions
This fixes restrictions for setting/discarding scan response data to
mach spec.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-11-11 13:20:40 +01:00
Vinayak Kariappa Chettimada
701d524143 Bluetooth: controller: Fix memory alignment of PDU buffer reference
Align the PDU buffer reference in struct node_rx_pdu so that
node rx type specific parameters, like, terminate and sync
lost reason can be accessed without any memory alignment
issues.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 13:20:33 +01:00
Vinayak Kariappa Chettimada
d7d8ae7894 Bluetooth: controller: Use connection complete variable naming
Use the connection complete varaible naming to access
connection complete parameters.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 13:20:33 +01:00
Vinayak Kariappa Chettimada
a5b489e2fa Bluetooth: controller: Make conn cancel and sync cancel impl. consistent
Make the connection cancel and periodic advertising sync
create cancel implementation consistent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 13:20:33 +01:00
Vinayak Kariappa Chettimada
92b2591558 Bluetooth: controller: Fix missing storage for sync cancel reason
Fix missing storage allocation in ll_sync_set structure for
storing the sync cancel reason.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 13:20:33 +01:00
Brian Bradley
313f1713ac mgmt: mcumgr: add configuration option to enable shell management
This configuration is be required to enable the shell management
command handler supported by the core mcumgr library

Signed-off-by: Brian Bradley <brian.bradley.p@gmail.com>
2020-11-11 13:17:02 +01:00
Vinayak Kariappa Chettimada
be090f7b33 Bluetooth: controller: Fix maximum AC PDU payload size calcuation
Fix maximum Advertising Channel PDU payload size calculation
by including the Common Extended Advertising Payload Format
overload alongwith the AD data maximum size supported.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
f677144f30 Bluetooth: controller: Remove unused defined in pdu.h file
Remove used constant macro defined in pdu.h file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
09c5035359 Bluetooth: controller: Added comments related to AD data double buffering
Added inline comments explaining the implementation of AD
data PDU double buffering.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
22ec1acacc Bluetooth: controller: Minor move code closer to locality of reference
Minor change to move code closer to locality of reference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
c842eef3ae Bluetooth: controller: Add semaphore to indicate free AD data buffers
Add semaphore implementation to indicate and wait for free
AD data buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
dc02ebf5ed Bluetooth: controller: Release AD data on advertising set remove
Add implementation to release AD data PDU buffers on
advertising set remove.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
5b396aaafb Bluetooth: controller: Use mfifo to return stale AD data PDU
Added implementation using mfifo to return stale AD data PDU
from LLL to Thread context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
2be0d07543 Bluetooth: controller: Add Max. AD data buffers Kconfig option
Add Kconfig option to configure maximum number of buffered
AD data PDUs across enabled advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Vinayak Kariappa Chettimada
c2fc629dd2 Bluetooth: controller: 255 byte AD payload support
Add 255 byte AD payload support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-11-11 12:28:05 +01:00
Kumar Gala
d439478805 device: treat a NULL device_pm_control as device_pm_control_nop
This is a step towards phasing out DEVICE_INIT and just having
DEVICE_DEFINE.  To make it a little easier on users or DEVICE_DEFINE
if they don't care about PM, they can just pass NULL for the
pm_control_fn paramater.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-10 08:38:09 -06:00
Wolfgang Puffitsch
f68d7863e5 Bluetooth: controller: Create HCI stubs for CIG/CIS creation and removal
Put infrastructure for the following HCI commands/events in place:
* LE Set CIG Parameters command
* LE Remove CIG command
* LE Create CIS command
* LE Accept CIS Request command
* LE Reject CIS Request command
* LE CIS Established event
* LE CIS Request event

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-11-10 13:19:08 +01:00
Wolfgang Puffitsch
e5356595ca Bluetooth: controller: Introduce Kconfig options for CIS central/peripheral
Add Kconfig options to enable Connected Isochronous Stream central and
peripheral roles.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2020-11-10 13:19:08 +01:00
Jordan Yates
ffab099eb9 Bluetooth: add destroy callback to indication
Adds a `destroy` callback to the `struct bt_gatt_indicate_params` which
is used to signify to the application that the indication operation has
completed and the struct instance can be freed/destroyed.

This is required as the number of indication value callbacks that will
be triggered is not known by the caller when the `conn` parameter is
`NULL`.

Tracking when this callback should be run is mananged by a private
reference counter inside the struct.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-11-10 11:21:46 +01:00
Jordan Yates
170f17e0e7 Bluetooth: indication callback signature update
Update the signature of the `bt_gatt_indicate_func_t` callback type by
replacing the attr pointer with a pointer to the
`bt_gatt_indicate_params` struct that was used to start the indication.

This allows the callback to free the `bt_gatt_indicate_params` instance
if it was allocated from storage, while still allowing the
`bt_gatt_attr` value to be accessed through `params->attr`.

Allocating the `bt_gatt_indicate_params` instance from storage is
desirable as multiple indications can be queued, however each instance
must be valid until the callback is run.

Implements API update from #29357

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-11-10 11:21:46 +01:00
Christopher Friedt
0fc80cf79f net: dns: enable dns service discovery for mdns responder
This change enables support for DNS service discovery
(RFC 6763) in the mdns_responder service and sample app.

Fixes #29429

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-09 16:15:02 -08:00
Christopher Friedt
e7e58439e7 net: dns: dns-sd: support dns service discovery
This change adds support for DNS Service Discovery (DNS-SD)
as described in RFC 6763.

Fixes #29099

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-09 16:15:02 -08:00
Christopher Friedt
5c691491a7 net: context: add net_context api to check if a port is bound
This change adds net_context_port_in_use(), which is a simple
wrapper around net_context_check_port() and is used to check
if a particular socket is bound to a given IP address.

Fixes #29649

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2020-11-09 16:15:02 -08:00
Joakim Andersson
f8956cfbc7 Bluetooth: L2CAP: Enable L2CAP dynamic channels without Enhanced CBFC
Allow application to enable L2CAP dynamic channels without support
for Enhanced Credit Based Flow Control (CBFC).

Since these are separate features in the qualification it should
be possible to qualify L2CAP connection oriented channels without
also having to qualify L2CAP enhanced credit based flow control.

The L2CAP/LE/REJ/BI-02-C conformance test will fail when enhanced CBFC
has not been selected in the ICS.

The lower tester expects that since the Enhanced CBFC is not supported,
the command L2CAP_CREDIT_BASED_CONNECTION_REQ should be met with an
L2CAP_COMMAND_REJECT_RSP and not an L2CAP_CREDIT_BASED_CONNECTION_RSP.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-11-09 11:25:10 +01:00
Trond Einar Snekvik
ad2fd44d7a Bluetooth: Mesh: Encapsulate feature config
Moves mesh feature configuration to a separate module, deprecating the
bt_mesh_cfg_srv structure. The initial values for the features should
now be enabled through KConfig, where new config entries have been added
for each feature.

This removes the upward dependency on the config server from the core
stack, and makes the config server a pure frontend for the configuration
states, as all spec mandated behavior around the feature states is now
encapsulated.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-09 11:23:34 +02:00
Trond Einar Snekvik
0dc9e5cd96 Bluetooth: Mesh: Move heartbeat to separate module
Encapsulates the Heartbeat state and functionality in a separate
heartbeat module, removing all manipulation of the heartbeat state from
the transport and config server modules.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-09 11:23:34 +02:00