We have introduced option HAS_HW_NRF_RADIO_BLE_CODED, which
reflects that an nRF SoC has a Radio with LE Coded PHY
capabilities. We now modify all #ifdef expressions for
Coded PHY in the nRF controller port, removing SOC_NRF52840
and adding this new option instead. This allows to build
an nRF controller with Coded PHY support for SOCs other
than nRF52840.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Relates to commit 76bfea7cf9 ("Bluetooth: controller: Ensure that a
`case` statement is present").
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When both central and peripheral are supported, one each Rx
node will be needed by connectable advertising and the
initiator to generate connection complete, hence
conditionally set the count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor to abstract the use of software interrupts in nRF5
Series.
Also, reduce the number of SWI used when interrupt priority
level configured is same for ULL High and ULL Low contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit completes the refactoring of radio.c, so it
calls abstract functions for PPI handling for LE Coded
PHY (e.g. enable, disable channels, or configure endpoints),
which, then, call the platform-specific functions for PPI
handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h, conditionally, if we
build the controller with support for LE Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Make the definitions of LE Coded PHY-specific macros
and inline functions conditional, i.e. only if we
actually build the controller with support for LE
Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit refactors radio.c, so it calls abstract functions
for PPI handling (e.g. enable, disable channels, or configure
endpoints), which, then, call the platform-specific functions
for PPI handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit defines generic macros for the software interrupt
(SWI) IRQ lines that are used for LLL and ULL LOW interrupts.
This is done for both the cases of the legacy and new (split)
controller architectures. In addition, it abstracts some of
the functionality around software-IRQ signals, to generic
functions, which have platform-specific implementations.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit adds an explicit inclusion of toolchain.h from pdu.h.
The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by pdu.h;
these being not defined can easily go unnoticed and cause unexpected
behaviours, as detailed in PR #18922.
toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Added ll_rx_link_inc_quota to allow vendor to manipulate
mem_link_rx.quota_pdu when cleaning up nodes via ull_vendor.h.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix a bug where in tx data PDU enqueued, while a ctrl PDU is
deferred due to Encryption setup being in progress, is
leaked causing HCI Tx Buffer Overflow crash.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix check in start encryption to disallow new encryption
setup while there is one already in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix MIC failure on re-encryption procedure when responding
at the same time to peer initiated feature request.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix control tx queue handling to correctly pause control PDU
responses during encryption setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to cache Data Length Procedure when
another control procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround, defer peer initiated encryption while local
initiated procedure with instant is not complete. Peer
master has sent CONN_UPDATE_IND in response to
CONN_PARAM_REQ, and also has initiated a Encryption Setup
thereafter. In this case, avoid corruption of the connection
update context by deferring the Encryption Setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to correctly cache the control procedures
initiatable by local and peer. And, fix feature exchange and
version information procedures from being disallowed by
having then as cached requests to the controller.
Relates to #15256.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
nrf_timer.h and nrf_ppi.h are included by including
radio_nrf5.h, so we do not need to include them in
radio.c.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Remove incorrect LL_ASSERT check in Lower Link Layer that
checked for invalid connection handle on reception of PDU.
The assert is not needed as PDUs can be received until the
Upper Link Layer is aware of the acknowledgement of the
terminate ind PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix handling of Rx-ed PDU on termination, do not process
Rx-ed control PDUs and release the PDU buffer back to the
free pool.
Without this fix, Rx-ed control PDU was responded with a
Tx PDU, which did not get acknowledged or released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Relates to #18578.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to handle data packet
enqueue being pause on Encryption Request be done early in
the ULL when enqueueing packets towards LLL.
Fixes#18645.
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.chettimada@gmail.com>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Post Tx pool corruption fix, clean up code and add comments
explaining the use of Tx node next field used to indicate
the Tx node's allocation from Control or Data pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the Tx FIFO, queue and pool corruption due to missing
release of link object to Tx link pool and hence missing
reset of the per connection initially allocated Tx link
free pointer.
The bug caused Tx PDUs and associated memory to be lost
leading to missing L2CAP segment transmissions. With lost
control PDU buffers, ULL would stall processing Done events
also leading to controller asserts.
Fixes#18546.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Due to conditional compile path ending in LL_ASSERT(0), the compiler
sees code following the assert as using uninitialized variables.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix the pipeline prepare-resume implementation to correctly
handle multiple continuous events that request resume on
being pre-empted.
Symptoms of the bug being, when having continuous scanning,
and an active peripheral if a directed advertising is
started the peripheral event are not scheduled causing link
supervision timeout.
This is fixed by not having an enqueued resume event
prepared if there is an enqueued new non-resume event in the
pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase pipeline size to accommodate probable multiple
prepare for directed advertising events, with reserved time
which are shorter than prepare duration, being enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the event start overhead time to accommodate for
processing time for dequeueing pipeline in Upper Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the maximum number of pending event done elements by
decoupling it from the maximum pipeline elements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix assert in the RPA timeout when no resolving entry exists in the
resolving list, and the advertiser was requested to use a local IRK
to generate it's own address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue with enhanced connection complete event raised by the
advertiser role. The advertiser reported that it has resolved the
the identity address of the peer, even when the peer is connecting
using it's identity address.
The host will not have the correct on-air address type i.e public.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Changes related to Bluetooth TSE 11068.
This is done because the current test suite does not issue
an LE Enable Address Resolution command anymore in RPA
generation tests. Makes sense now that the Bluetooth SIG has
agreed to completely decouple address resolution from
generation.
Fixes BT LL TS 5.1.0 test:
LL/SEC/ADV/BV-03-C [Privacy - Non-connectable Undirected
Advertising, Resolvable Private Address]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the pipeline prepare or resume dequeue loop from
overflow. Fixes premature exit of dequeue of done FIFO
which caused the pipeline to overflow due to previously
placed done is not dequeued correctly and next event not
being put back into the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable use of settings system in controller and introduce settings for
company_id and subversion_number.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Rename the controller Kconfig option BT_LL_SW to
BT_LL_SW_LEGACY in preparation towards switch to new Link
Layer implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditional compile the use of Rx Pool used to dispatch ULL
context generated messages towards LL thread context, which
is presently only used in connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the conditional compile of Data Length Update event
generation on PHY Update Procedure when Data Length
Extensions are not supported.
The regression was introduced in
commit 70a89876d0 ("Bluetooth: controller: Fix missing
data length update event")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a fix to handle L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Relates to #17046.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a bug related to missing reset of packet timing
restriction variable.
Fixes BT LL TS 5.1.0 test:
LL/CON/SLA/BV-55-C [Initiating PHY Update Procedure - Packet
Time Restrictions, LE Coded]
Related to #17097.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.
This fix with avoid states/roles from stepping on each
others event length. Connection would have supervision timed
out or have stalled data transmissions due to insufficient
reserved air time.
Relates to #15171.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.
Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the implementation of initiator to use correct anchor
tick and remainder microseconds when sending out CONNECT_REQ
PDU and then to scheduling the first connection event. This
is a fix when initiator is in continuous scan.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in the ported code of the connection update, when
the slave events are skipped due to other overlapping state
or role the connection update at the instant used wrong
latency calculations. This lead to connection disconnection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix assert in controller checking ticker_id_prepare = 0 when
a scanner and connection are active, and the connection is
skipping events in order to resize Rx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the reset of ticker_id_prepare variable to the early
return in event_connection_prepare function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Port the implementation that does radio event abort due to
ISR latencies. The implementation measures if the ISR could
not meet the hard real time deadline and closes the event
early.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added interface to get Advertiser and Scanner instance
handle for use in Lower Link Layer module.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/slist.h to sys/slist.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/mempool_base.h to sys/mempool_base.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/dlist.h to sys/dlist.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move entropy.h to drivers/entropy.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move clock_control.h to drivers/clock_control.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Added a fix handling L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Moved and renamed ull_entropy_get to lll_entropy_get, placed under
vendor specific ll_sw. This is needed for SW implemented entropy,
to allow vendor implementation of faster, less secure random number
generator for randomizing ADV timing.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Fix pending Tx control buffer leak on supervision timeout.
Queued tx buffers in LLL consists of both data and control
PDUs but only data buffers got correctly released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Port the implementation that performed random backoff of
forced slave event scheduling.
When peer master implementation skips events, multiple
local overlapping slaves will randomize their forced
scheduling to break out of a round robin pattern increasing
the chance of synchronizing with their masters again.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scan requests being processed during directed advertisiments.
Directed advertise packets are not scannable
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add some missing fatal asserts that need to be caught to
avoid unexpected failures in the implementation of the
architecture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the tx_ack mfifo count to accomodate both data and
control PDUs being acknowledged.
With out this fix, pending maximum number of data plus
control PDUs in LLL on supervision timeout asserted due to
tx_ack mfifo overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Explicitly track the connection update related ticker stop
and start to avoid asserting due to ticker update being done
at the same time for compensating the master clock drift.
Relates to #11764.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added an internal ull_update_mark function to detect race
conditions while stopping ticker instances during slave
drift, disconnection and connection update.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Port the fix for the controller implementation to make start
encryption queueable if there is any control procedure in
progress.
Refer to #15335.
Relates to #15335, #15186, #15958 and #14636.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implements hooks to implement user protocols in ull.c
A user defined init function can now be called, this code is gated by
the CONFIG_BT_CTLR_USER_EXT define.
A user defined PDU length can now also be defined using the Kconfig
CONFIG_BT_RX_USER_PDU_LEN
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Fix shell app regression due to stale tmp role implementation
not fully being removed in commit 4c77bf6194 ("Bluetooth:
controller: Remove redundant tmp role implementation").
The regression caused ticker indexes outside of allocations to
be accessed causing application faults and memory corruptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The the footer structure and extra bytes (rssi, resolving index etc.)
were overlapping in memory, rx_ftr was moved into the header, but the
extra and footer are still being read from the same place, extra was
written to the end. So this avoided memory corruption, but reading extra
reads wrong information.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compilation issues in central_hr or peripheral_hr sample when using
split LL and privacy is enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The node_rx buffer does not contain the data from the connect ind, so
copy it over.
Also back up the adv pdu chan_sel bit so that it can be used to properly
select the correct channel selection algorithm
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The node_rx buffer for the connect ind buffer is being reused to send
connection complete event, make sure all data is backed up before
reusing the buffer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The privacy state variables rl_idx and rpa_gen was not initialized
properly, which results in connection failing to be established.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Code refactored to allow calling of a proprietary rx demux function.
This will enable implementation of proprietary protocols and
functionality that is not yet public, while keeping a common zephyr
code base.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
A conditional block to save a directed advertising report flag was
present three times. Remove two of the blocks.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Port fix for #14044 from legacy LL to split LL.
The master is using unknown rsp to terminate slave side initiated
procedures that has collided with the encryption procedure initiated by
the master.
We need to handle an unknown response that is sent in unencrypted during
the encryption procedure, even though we have already set up to receive
encrypted packets.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove comment stating that UNKNOWN_RSP during encryption procedure
is a workaround.
The core spec mandates that connections should not be dropped if
receiving this control packet during encryption procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is a pure refactoring of the k32src_wait function. It used the
following rules when refactoring:
Don't use the preprocessor when unprocessed C language suffices.
Don't undefine macro's.
Avoid global variables when possible.
Use consistent names for similiar things (hf_clock, lf_clock).
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Fix broken master role RSSI measurement. Since the original
contribution clean up into Zephyr, the radio shorts that was
set for measuring the RSSI for master role has been broken,
as it was cleared by the radio switching code further in the
Tx ISR.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
The old footer was appended after PDU using pointer arithmetic. Now
the footer fields have been moved to the header struct, the
footer fields are now statically located in the data structure,
this is type safe and fields can be referred to by their actual
names rather than indirectly through reference to other members,
thus avoiding pointer arithmetic. Secondly, this change will pave
the way for adding other meta data in the future.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
This commit adds support for board: nrf52811_PCA10056.
The nRF52840 DK: PCA10056 is the recommend development kit, it emulates
the nRF52811, and can be used as a starting point for development
before moving over to a custom board.
Please note that this development kit does not support Bluetooth
Direction Finding. What is more it cannot be used with most of Arduino
shields because of PCA10056 PIN layout.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix an issue wherein local or remote initiated Connection
Parameter Request procedure would stall without generation
of LE Connection Update Complete HCI event because a local
or remote initiated PHY Update procedure has overwritten the
currently active Link Layer Control Procedure type.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.
Relates to #15366.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the encryption setup queueing implementation to avoid
overlapping with local initiated Length Update Procedure.
Fixes#15733.
Relates to #15335, and #15186.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a follow up to commit 0eaa5e53a3.
`HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE` is a base number for two PPI
channels, so two bits need to be marked in the used channel bit mask.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Due to a protracted merge of:
5e38ed9320
the naming for the HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI changed
semnatics, now requiring use of
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Mark the PPI channels and groups used by the Bluetooth controller
as occupied and thus unavailable for allocation through nrfx_ppi.
Add also a build time assertion that checks if these PPI channels
do not overlap with those assigned to the pwm_nrf5_sw driver
(to replace the comments in this driver that were supposed to warn
about this threat but had in fact little chance to be read by users).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Updated the controller implementation to not feature
exchange if already done once either by local or remote peer
device in an active connection session.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Fix incorrectly defined Rx and Tx buffer sizes. Wrong
calculation allocated more memory than necessary.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect data type used in calculation of slot_us
detected by compiler, and reported as possible integer
overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect conditional compilation that caused compile
error when lll_scan structure did not contain connection
context included which is needed only for central role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.
Relates to #15570, and #15727.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Increase the resolution of advertising random delay from
1 ms unit to 1 ticker unit.
Relates to #10289, #10391, and #10398.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix XTAL advanced feature by adding the missing
implementation to calculate and, retain or release the XTAL
clock source after a Bluetooth state or role is stopped.
Fixes#15817.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to toggle GPIO Debug pins on HFCLK
request and release by the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement a lower ISR latency ULL processing design. Instead
of looping use ISR/mayfly tail-chaining to process
successive ULL messages.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implemented ULL to yield from processing in an infinite loop
if current PDU being handled is deferred.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing BT_CTLR_FILTER conditional compilations that
cause compile errors when device whitelisting feature is
disabled in builds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
* Rename the stack local 'done' to 'evdone' so as to disambiguate from
MFIFO_DEQUEUE_PEEK(done) which is actually 'mfifo_done'.
* add comment on ull_slave_done
* add comments to addr_us_get
* add comments to HCI_CLASS
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.
Relates to #15570.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the nRF52840 Coded PHY radio timings based on testing
with conformance tester.
Fixes the following conformance tests:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI Change]
LL/CON/MAS/BV-54-C [Slave Receiving Data, LE Coded, CI Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the regression in Coded PHY CI change implementation
introduced by reverting the commit 9d1ca9c390 ("Bluetooth:
controller: remove redundant PPI channel and TIMER CC").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
In ull.c ll_rx_get, a configuration without CONFIG_BT_CONN would
sometimes return an uninitialized node_rx.
In ull_scan.c, the scanning channel was not initialized to 0 (37). This
would cause new scanning to start at random index (0,1,2).
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add defines to support updated slot reservation calculation in advertise
Note: Numbers used in added defines are subject to HW specific tuning
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Added a new define (EVENT_IFS_US) to pdu.h - this is now used instead of
previous TIFS_US from vendor specific header
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Correct slot reservation time calc for legacy advertise
Add dependency on data lengths for advertise and scan response
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix regression by the addition of CONFIG_BT_CONN conditional
compilation that disabled the advanced clock (crystal)
oscillator management when only observer and/or advertiser
states supported in the controller build.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to pause data PDU transmission during
PHY update procedure in order to comply to BT Spec. v5.1
Vol.6, Part B, Section 5.1.10.1 Packet transmit time
restrictions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactoring to move PKT_US into ULL internal header,
and rename ull_conn_allowed_check to ull_conn_llcp_req.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ported implementation of Data Length Update Procedure to
ULL/LLL architecture of the Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to make start encryption
queueable if there is any control procedure in progress.
The context related to encryption procedure is now shared so
that it will be used after the ongoing procedure completes.
The fix here maintains the old functionality of serializing
the queued data and LL Encryption Request PDU, so that data
queued before start encryption is acknowledged.
Fixes#15012.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Send unknown rsp instead of asserting when encryption related control
PDUs are received in the wrong state.
This would allow an attacker to intentionally crash the device.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop the Length request procedure from initiating during the encryption
procedue. This would cause the peer to disconnect the link with error
code LMP_TRANSACTION_COLLISION
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the encryption procedure pending and start it as soon as
there are no other procedures running.
This allows the Host to enqueue the encryption procedure, and not
get disallowed command because a different LL procedure is active.
Fixes#15012
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The fix done in #14938 introduced a later assert when raising an HCI
event for the procedure that was terminated during the procedure
collision handling. This assert happens because the unknown rsp
has information that is needed when raising the event.
Solve this by copying the scratch packet into the node buffer so that
we keep the data.
Fixes#15183
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The master is using unknown rsp to terminate slave side initiated
procedures that has collided with the encryption procedure initiated by
the master.
We need to handle an unknown response that is sent in unencrypted during
the encryption procedure, even though we have already set up to receive
encrypted packets.
Fixes#14044
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix a bug where the controller would use the length
field of the advertisement packet before checking
if the length field was valid.
It is possible that the controller has received a packet
that passes CRC check but has a length field that is invalid.
This would cause the scanner to overwrite the scan report
buffer
Fixes: #14741
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Peer side will disconnect if controller initiates
Encryption procedure before PHY update procedure
has finished.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug in LL encryption procedure, controller was
using the wrong pointer to connection state.
Function event_enc_prep is called from
slave_event_prepare, where _radio.curr_conn has not
been assigned yet.
The connection ended up sending LL_START_ENC_RSP
unencrypted, resulting in disconnect on the peer
side with reason MIC failure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix implementation to correctly return the configured
default Tx Power Level.
Also, fix the missing use of RADIO_TXP_DEFAULT in the new
ULL/LLL implementation of Advertiser and Observer states.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation in controller to use range delay
alongwith the active clock accuracy jitter.
Range has been hard coded to 1000 meters, suffices
modules out in the market.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround from asserting when Rx PDU buffers from pool
needing resize is acquired by another connection. By
skipping the connection events to give some headroom for
the host to process the Rx packets and eventually make the
pool available for resize.
Fixes#11841.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use reverse order for bitfields on big-endian architectures. Treat
all PDU data as little-endian and add conversions as needed. Treat
access address as 4-byte value instead of u32_t to avoid flipping
endianness.
Signed-off-by: Wolfgang Puffitsch <wopu@oticon.com>
Check the return value of mayfly_enqueue() and assert if not successful.
Coverity ID: CID 190991
Fixes#13833.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Inside ll_test_end(), result of lll_clk_off() is not checked
which might result in releasing resources acquired for radio.
Coverity-CID: 190954
Fixes: #13861
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
Some old peer central controllers respond with Unknown
Response PDU to our local Slave Initiated Feature Request
after the peer initiated the Encryption Setup Procedure.
The peer has voilated the Bluetooth Specification by sending
the Unknown Response during the Encryption Setup Procedure,
but as a workaround to IOP with such controller our local
implementation is updated to not disconnect the connection
but accept the voilating Unknown Response PDU.
Relates to #12362.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
mem_pdu_rx is not runtime resized meaning PDU_RX_SIZE_MIN is no longer
relevant.
Dynamic resizing was a left-over from the old bt controller.
Its size field was only ever set to PDU_RX_SIZE_MIN.
PDU_RX_SIZE_MIN only accounted for advertise PDUs.
So we remove size field from mem_pdu_rx.
However, the rest of the BT controller expects to be able to pull
RX_CNT-number of valid nodes from the pool at init/reset (rx_alloc)
time. This will fail unless we inflate the capacity by one.
To avoid inflation-by-one, mem_* would have to be rewritten to avoid
always-one-extra pattern.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Refactor PDU_RX_POOL_SIZE into its constituents and name each term.
No functional change expected.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Fix a bug in Encryption Procedure feature conditional
compile which prevent any data transfer when the feature was
disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
* Clarify certain functions and data structures in upper link layer.
* Disambiguate node rx event done, add commentary.
MFIFO_DEQUEUE macro does string concatenation.
Thus MFIFO_DEQUEUE(done) does not refer to done (the stack local), but
mfifo_done.
No functional change expected.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
ull_ref_inc already existed, but not ull_ref_dec.
No functional change expected.
Consistency is preferred due to code navigation.
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.
This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.
All files that use these macros have been updated.
Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
Rename ull_tx_ack_put to ll_tx_ack_put as ack is enqueued
into LL thread context from ULL ISR context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move PKT_US definition from LLL header file to ULL header so
as to share it across vendors.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile error due to missing conditional compile of
connection related code when selecting only observer state
support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Return meaninful HCI error when it's not possible to start advertising
because of maximum number of connections already in use.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
Remove the redundant proof of concept template temporary
role implementation from the repository.
Relates to #12860.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
During regression testing of PA/LNA feature it was noticed
that compilation failed due to missing port of the code
conditionally compiled for PA/LNA feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the control procedure context safety by adding checks in
thread mode control path to detect pre-emption by interrupt.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a squash merge of commits introducing the new split
Upper Link Layer and Lower Link Layer architecture of the
Bluetooth Low Energy controller.
This introduces a new, improved Link Layer based on the
concept of split responsibilities; The Upper Link Layer
(ULL) is in charge of control procedures, inter-event
scheduling and overall role management. The code for the
ULL is shared among all hardware implementations. The
Lower Link Layer (LLL) is responsible for the intra-event
scheduling and vendor specific radio hardware access.
The communication between ULL and LLL is achieved through
a set of FIFOs that contain both control and data packets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Signed-off-by: Wolfgang Puffitsch <wopu@oticon.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
Preliminary work done towards Mesh extensions on the old LL
architecture implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Missing updates to old architecture implementation towards
introduction of new ULL LLL architecture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactored the internal LL interfaces to have return value
to match the HCI error code u8_t data type.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit renames the nrf5_clock_control.h and
nrf5_clock_control.c files to nrf_clock_control.h and
nrf_clock_control.c, respectively, as they are used
in nRF9160 builds, as well.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit renames the CLOCK_CONTROL_NRF5 Kconfig symbol to
CLOCK_CONTROL_NRF. The change is required to aleviates confusion
when selecting the symbol in nRF9160 SOC definition.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Preparation to introduce the Upper Link Layer (ULL) and
Lower Link Layer (LLL) split architecture.
- Move SoC dependent HAL to vendor specific folder.
- Preparation to split data structures into ULL and LLL
types.
- Added more role and state conditional compilations.
- Added some work-in-progress implementation of advertising
extensions, will be used as inspiration in the new split
architecture work.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix an issue wherein local or remote initiated Connection
Parameter Request procedure would stall without generation
of LE Connection Update Complete HCI event because a local
or remote initiated PHY Update procedure has overwritten the
currently active Link Layer Control Procedure type.
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.kariappa@gmail.com>
Fix channel map update procedure implementation's handling
of different transaction collision by not asserting but
disconnecting the connection due to invalid behavior by
peer implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Explicitly track the connection update related ticker stop
and start to avoid asserting due to ticker update being done
at the same time for compensating the clock drift.
The compensation related ticker update failure in this case
can be safely ignored as new anchor point is used anyway
at the instant of the connection update.
Fixes#8796
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated controller implementation to disallow disabling
initiator state using scan disable. But allow disabling an
already disabled scan state. Also, disallow enabling scan
state while in initiator state.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the controller implementation to not feature
exchange if already done once either by local or remote peer
device in an active connection session.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for exchanging both minimum and maximum
connection interval values in Connection Parameter Request
Procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a pure refactoring of the k32src_wait function. It used the
following rules when refactoring:
Don't use the preprocessor when unprocessed C language suffices.
Don't undefine macro's.
Avoid global variables when possible.
Use consistent names for similiar things (hf_clock, lf_clock).
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Fix an integer overflow in the scheduling implementation
that calculates whether resources required for next radio
event be retained.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit optimizes access to RNG driver by taking advantage
of the data structures layout. As result, number of calls to RNG
driver is reduced.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
The entropy_nrf_get_entropy_isr(), which is specific to this driver,
is in fact equivalent of generic entropy_get_entropy_isr(..., 0).
This commit removes the entropy_nrf_get_entropy_isr() function
and replaces its usage by call to generic entropy API.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
Added implementation to avoid retransmitting NACK-ed Tx PDU,
to save on current consumption in retrying to transmit in
case peer device has no free buffer to receive the PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To allow the BLE stack to be used both in the real nRF platforms
and simulated ones, change the used macros in the code to the
COMPATIBLE ones.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Fix broken master role RSSI measurement. Since the original
contribution clean up into Zephyr, the radio shorts that was
set for measuring the RSSI for master role has been broken,
as it was cleared by the radio switching code further in the
Tx ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix connection failed to be established regression
introduced by the commit 350c569aba ("Bluetooth:
controller: Avoid offseting to lldata").
As the Rx-ed PDU buffer is re-used to construct the
connection complete message towards HCI, the fields in the
Rx-ed PDU need to be backup for future use in the control
path. Here the channel selection bit is backup now.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Connection Parameter Request Procedure implementation
to respond with sent interval_min and interval_max so that
certain peer devices dont reject the response as Invalid LL
Parameters.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>