Commit graph

1155 commits

Author SHA1 Message Date
Vinayak Chettimada 2de3cc95be Bluetooth: controller: Move nRF5 specific debug pins to hal/nrf5
Move the nRF5 specific GPIO debug pin macro definitions to
hal/nrf5/debug.h.

The Controller's hal folder contains prototypes and
hal/<soc> shall contain SoC specific implementation to
realize a software-based Link Layer.

Change-id: Ic7bf283f926bbc3069e7d15c047fe93a6daa894f
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada 698de88916 Bluetooth: controller: Cleanup redundant ticker busy loop
Cleanup redundant ticker busy loop that could hang if the
worker and job IRQ priority levels are misconfigured, and
job gets disabled before all users/mayfly functions using
job complete.

Change-id: I053ad75a4328c51cfe651b820a2fa961e42ae48f
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada ddba873aae Bluetooth: Kconfig: Move BLUETOOTH_CONTROLLER to Controller file
Move the Kconfig BLUETOOTH_CONTROLLER switch from top-level
Bluetooth Kconfig to Bluetooth Controller Kconfig.

Change-id: Iead760c22a0fbbda11e4558c4943b3366ecc8769
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Johan Hedberg dd1ba28726 Bluetooth: Controller: Introduce rate-limiting on stack analysis
In case the controller is receiving PDUs very rapidly, prevent it from
spamming the logs by limiting its stack analysis to at most once every
5 seconds.

Change-Id: I31c70d28e8af62b27172a4a77bf6e614ea3e20eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada b593e44da6 Bluetooth: controller: Move comp id and subver to configuration
Move company id and subversion number Kconfig to the
Controller configuration section from the features section.

Change-id: Ic4deb8b24d84d9b1817ba542705eebd612f0e020
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada 16bd3d48db Bluetooth: controller: Hide advance features in Kconfig
Added a explicit Kconfig option to show the Controller's
advanced feature configurations. These feature
configurations need specific in-depth Controller
implementation knowledge and should not overwhelm normal
users of the Controller.

Change-id: Iae764f2b266b199cf180936c51c7a4ea089ee510
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada f38d57cba3 Bluetooth: controller: Kconfig option for advanced scheduling
Add Kconfig option to enable advanced scheduling in the
controller.

Enable non-overlapping placement of observer, initiator and
master roles in timespace. Uses window offset in connection
updates and uses connection parameter request in slave role
to negotiate non-overlapping placement with active master
roles to avoid slave roles drifting into active master
roles in the local controller.

This feature maximizes the average data transmission amongst
active concurrent master and slave connections while other
observer, initiator, master or slave roles are active in the
local controller.

Disabling this feature will lead to overlapping role in
timespace leading to skipped events amongst active roles.

Change-id: I16e4e6c3ca99f93987ab86924af0cb9d76bdbc7e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada 646726518f Bluetooth: controller: Kconfig for advanced event preparation
Added Kconfig option to enable advanced event preparation
feature.

Enables advanced event preparation offset ahead of radio
tx/rx, taking into account predictive processing time
requirements in preparation to the event, like control
procedure handling and CPU execution speeds. Crystal
oscillator is retained between closely spaced consecutive
radio events to reduce the overall number of crystal
settling current consumptions.

This feature maximizes radio utilization in an average role
event timeslice when they are closely spaced by using a
reduced offset between preparation and radio event.

By disabling this feature, the controller will use a
constant offset between the preparation and radio event. The
controller will toggle crystal oscillator between two
closely spaced radio events leading to higher average
current due to increased number of crystal settling current
consumptions.

Change-id: I19e640f7395ac7938873ef4bfac38acf8d6f7e0e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-04-08 20:11:54 +03:00
Vinayak Chettimada 611460b913 Bluetooth: controller: Fix race waiting for ticker job to complt
Same volatile status variable as return and being updated
in ISR would modify the variable in two context which
caused the variable to be set to a stale value.

This commit uses two different variables, one for return
value and the other to be updated by ISR.

Jira: ZEP-1941

Change-id: I19e3bdc85e15bda7891395f3f1f64c2ddbeee0c6
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-24 17:06:59 +00:00
Vinayak Chettimada 2d644f2f42 Bluetooth: controller: Fix mayfly caller id for thread call path
role_disable initiated through HCI commands are initiated
in thread context and controller code was using the job
mayfly caller id instead of using the correct app caller
id.

Also the XTAL retain calls being called from two different
call context used the same worker caller id and same mayfly
instead of using the correct caller ids and independent
mayfly for each caller.

This potentially could cause mayfly enqueued list to be
corrupted and enqueued mayfly could be lost.

Change-id: Ia356419462d1fb4e38f4a20c720974143f12fdb6
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-24 17:06:43 +00:00
Vinayak Chettimada 0efd38885a Bluetooth: controller: Cleanup makefiles
Cleanup controller's root makefile and add folder level
makefile to have better control over dependencies.

Also explicitly include folder paths in c files to clearly
depict the dependencies.

Change-id: Iac7b3a86eff11082111049ba48559c74f6c4d3fb
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:43 -07:00
Vinayak Chettimada 9522b9a37f Bluetooth: controller: Move PDU macros from radio.h to pdu.h
Move the PDU related size definitions out of radio.h and
place it in pdu.h. This will remove hci's dependency on
radio.h.

Change-id: Idf9d7cdf7c60d74816ef2b093c4ae457df16e9a9
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:43 -07:00
Johan Hedberg 24c7397160 Bluetooth: Controller: Increase default TX buffer count
Only 1 TX buffer is sub-optimal for performance since the controller
would always have to wait for the host TX thread to give it another
buffer. Increase the value to 2 so the controller can keep
transmitting data without waiting for the host.

Change-Id: I4841a6c5010f294996d6fe0fe63260b848a6a437
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada f1aabd8ba2 Bluetooth: controller: Replace 0 for pointers with NULL keyword
Updated controller code to use NULL keyword instead of
using 0 for pointers.

Change-id: I5ebff53dfeeba670fb7afe4740596b2662eb0334
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Johan Hedberg 94831a7589 Bluetooth: Introduce public big-endian AES API
There may be use cases where input and output is in big-endian rather
than little-endian. Introduce a native big-endian API to avoid
excessive byte order reversals in these cases.

Change-Id: Ia7b3e01bb0a07c4560b23f60c2f615ec614eb431
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Johan Hedberg 6cb853fc04 Bluetooth: Controller: Introduce big-endian variant for ECB
There are some use cases where all parameters are in big-endian. To
avoid excessive byte order reversals introduce a native big-endian
API.

Change-Id: I58fe9156c8819a3a43d715e70b6ba358bd2f844b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Johan Hedberg 579551ed06 Bluetooth: Controller: Factor out ECB core code from ecb_encrypt()
Do this in preparation of a purely big-endian API (all three
parameters as big-endian).

Change-Id: I815f74549caffd5ac387b5bb84e5851aa96639b9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada a91dd34830 Bluetooth: Make LE Encrypt helpers public
Expose LE Encrypt helpers to applications. If software-
based controller is compiled-in, then controller's AES
hardware will be used by the exposed helper interface.

Change-id: I2bac9dfa5ccb3dd50447079affb52d920ae5bd81
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>.
2017-03-21 17:05:42 -07:00
Vinayak Chettimada 32f03a42c7 Bluetooth: controller: Move bt_rand into separate file
Move crypto related interface provided by the
software-based Controller bt_rand into separate file,
crypto.c.

Change-id: I9998a43fe45799b479969ca195f324199418b8c2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada 5bf86ea209 Bluetooth: controller: Use explicit paths to internal headers
Use explicit path while including internal header files.

Change-id: Ide80eb23007574a7362850173ac227943bda21d5
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Carles Cufi 4b10d75fbe Bluetooth: controller: Move LL code from driver to ll_sw
The current hci_driver.c contained all the software Link Layer
initialization code. To decouple HCI from the actual LL, most of the
functionality that is actually part of the LL has been moved to the
ll_sw folder, opening the possibility for future hardware-based LL
implementations.

Change-Id: I1b54d655568a4ec02409da2f1a0addb4d64beed0
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Carles Cufi 8dd0374214 Bluetooth: controller: Remove public address config option
Since this presents a risk of public Bluetooth address duplication in
the wild by compiling once with a particular address and then flashing
the same image to multiple devices, a decision has been taken to remove
that config option and replace it later with another mechanism.

Change-Id: I068db25b2996c2409630554b1819b6adc48226cd
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Carles Cufi a7f6656998 Bluetooth: controller: Move ll.h to an include folder
To present a common interface to both software and hardware Link Layers
the API in ll.h now lives in its own separate include/ folder.

Change-Id: I2b0ab0d11b47b9c35a5759bcc30f347e6c616648
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Johan Hedberg 5517893543 Bluetooth: Make bt_hci_driver instances link-time constants
Declaring these as const lets the linker generate more optimal code.
Some extra care is needed with hci_ecc.c since it was overwriting the
send callback. Now the choice of send() call is done directly in the
bt_send() function

Change-Id: Iac74f5ee9bee097bbb34c11bd13d1d886700f5cc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Carles Cufi 841c5432cc Bluetooth: controller: Introduce BLUETOOTH_LL_SW
In preparation for future hardware implementations of the BLE
Link Layer, this patch introduces the BLUETOOTH_LL_SW
configuration option to specify that the default software
LL is to be built.

Change-Id: I8b9d5b5e0d2926d18f9e8c8f042a74326895bf95
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Carles Cufi be060208e9 Bluetooth: controller: Rename downstream API calls
Rename all LL downstream API calls from radio_ to ll_ so that they
reflect the layer they are actually targeting. Additionally they have
been moved to ll.h so as to expose a proper interface.

Change-Id: I4fb3946597920c9fafaacb6d87d34d83d75e8f27
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Carles Cufi 7e0a900e05 Bluetooth: controller: Remove unused H:4 tag macros
Remove the H:4 packet type macros that were unused in this file.

Change-Id: If161ddbf2d3adb2871cadd76de0e6c3bb50a16db
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada e3d00bf338 Bluetooth: Controller: Version 5.0 and PDU type rename
Report as Bluetooth 5.0 compliant controller as there are
no mandatory features.

Rename PDU types as per the changes in Bluetooth 5.0
Specification.

Change-id: I1363e054eafd37c2bdca0f69b2638c7edb785787
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada 00d8a902b7 Bluetooth: Controller: Add Kconfig range check for public address
Bluetooth device address is 48-bit, added Kconfig range
field to restrict input to 48-bit hexadecimal value.

Change-id: I650343eab5809535137e164e783c9dd4f3e2a6f2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Matthias Ringwald 34b6c53c46 Bluetooth: Controller: Kconfig company id and subversion number
Add Kconfig option to set the Controller's company id and
subversion number.

Change-id: I3508aba18bf0b79fd423c7b4142b6fc57eaf55d7
Signed-off-by: Matthias Ringwald <matthias@bluekitchen-gmbh.com>
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada 0d75faf02d Bluetooth: Controller: Add advertisement event indication feature
Add a Controller event that indicates everytime
advertisement event has been transmitted on air.

Change-id: I4722488bbfeca987e66983faf5b26467407a89c9
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada d8f28bc96a Bluetooth: Controller: Fix RSSI feature conditional compilation
Add ARG_UNUSED on rssi_ready local variable when the RSSI
feature is compiled out.

Change-id: I04f8f11cbc3530f7b85ffa72f27373e213b6e35e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-21 17:05:42 -07:00
Vinayak Chettimada 16608e9a51 Bluetooth: Controller: mayfly enable to supercede over disable
If mayfly enable is called before mayfly could be disabled,
then enable shall supercede disabling, the mayfly will
remain enabled. Any new mayfly enqueued by the caller that
tried to disable mayfly will be chain for deferred
executon under this condition.

The BLE Controller's connection update procedure broke when
mayfly implementation was updated to defer disabling until
all queued mayfly where completed. Mayfly is disabled
between ticker_stop and ticker_start calls to chain them
so that ticker does not power off counter h/w if the ticker
being stopped is last one.

This commit fixes the connection update procedure which
used the mayfly enable before mayfly disable could
complete.

Jira: ZEP-1839

Change-id: I07d34c90d193b5eca9762acd8b7272e8d7a78474
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-08 15:14:32 +00:00
Vinayak Chettimada ecc0f83d92 Bluetooth: Controller: Fix assert on role stop/abort
Call to ticker_stop/update can fail under the condition
where in a role is being stopped but at the same time it is
preempted by the role event that also uses ticker_stop/
update.

Also if a role closes graceful while it is being stopped,
the radio ISR will process the stop state with no active
role at that instance in time. In this case just reset the
state to none, the role has already been gracefully closed
before this ISR execution. The above applies to aborting a
role event too.

This commit adds code to detect these conditions and
deterministically recover from it.

This commit fixes the assert observed while stopping
advertiser in the Bluetooth sample scan_adv.

Jira: ZEP-1852

Change-id: I51c8d6e212ef43e3526a199cf7b666a79729c732
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-08 15:14:22 +00:00
Vinayak Chettimada 8747090426 Bluetooth: Controller: Kconfig option to set public address
Added Kconfig option to be able set public address. Seems
conformance testers look for valid public address.

Change-Id: I2c4f702117f99a42c9eef0133b46556a1c6d1496
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-07 14:51:54 +01:00
Vinayak Chettimada 966fbbcd04 Bluetooth: Controller: Run all enqueued mayfly before disable
Controller asserted in preparation of a role event due to
the previous (same or another) role event preparation being
not complete.

Mayfly callee was disabled in the previous event due to the
preparation time being short and previous start running
(higher natural priority) before all previous preparation
mayfly completed. The previous start disabled mayfly to
avoid Radio ISR latencies.

The current role event that asserted, preempted the
previous role (observer role with continuous scanning
window) which runs until preemption to maximise the Radio
h/w use (observer scanning until next interval). The
previous preparation mayfly is still disabled when the
current role preparation tries to use same mayfly instance
which should be free for a new enqueue.

This commit updates mayfly implementation so that mayfly
callee is disabled only after all enqueued mayfly instances
are run to completion.

Jira: ZEP-1839

Change-id: I3e0d31422db8e47b819189110b11ebd07dd09a7c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Carles Cufi ff3e6e333f Bluetooth: controller: Report 5.0 compliant controller
Since there are no mandatory features in 5.0 when compared to a 4.2
compliant controller, report 5.0 as the current specification
implemented by the controller, to allow for features such as short
advertising intervals (< 100ms) which are already supported.

Change-Id: I1b138a86290a0422760a5e265cdd7b72d68f0048
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Carles Cufi 3141dcf3b4 Bluetooth: controller: Introduce debug pins Kconfig option
A new Kconfig debug option now controls the usage of pin toggling to
debug the BLE controller.

Change-Id: I24c5c13ca71e3395e10f14e27ad4bca9f2e94687
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Carles Cufi 34e0c4b253 Bluetooth: controller: Set debug pins with macros
Use macros to identify the different debug pins used to monitor the
runtime behavior of the controller, for easier identification of the
lines.

Change-Id: Ia76d6298985b1d367b7ad193d8261f5403446371
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Vinayak Chettimada c78601481d Bluetooth: Controller: Fix LE Ping PDU dispatch
It was observed that due to possible CRC errors, one
connection interval was not sufficient by the peer to
respond to LE Ping PDU which caused the Controller to
generate the Authenticated Payload Timeout event to host.

This fix advanced the dispatch of LE Ping PDU by 6
connection intervals that the peer would listen to before
the 30s timeout.

Change-id: I6c292c623047a05b4e771e70093d87228db62cce
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Vinayak Chettimada 16ef73423e Bluetooth: Controller: Use direct ISR for Radio IRQ only
The new hard real-time (direct) interrupt support is used
only for Radio IRQ. Only Radio ISR has hard real-time
requirement of completing its execution inside the tIFS of
150us.

This commit reverts back RTC0 and SWI4 ISR to using the
normal IRQ_CONNECT.

Observed on nRF51, Radio ISR (open text, notifications):
Latencies: min. of 5us and max. of 10us.
CPU utilized: min. of 44us and max. of 77us.

Observed on nRF51, Radio ISR (LESC, fast encrypted,
notifications):
Latencies: min. of 5us and max. of 10us.
CPU utilized: min. of 39us and max. of 112us.

Jira: ZEP-1038

Change-id: Id3d09df7bdbdfea090f21f6f58aaded8c5f1e10d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Carles Cufi 727987276e Bluetooth: controller: Use direct ISRs
The new hard real-time (direct) interrupt support in the kernel allows
ISRs to be run directly with no significant latency overhead.

Use this new mechanism to improve the latency of the 3 critical
interrupts in the controller: radio, RTC0 and SWI4.

Jira: ZEP-1038

Change-Id: Ief9dacbea4c4c2e8a1c77893a0d6175a91819ffb
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-03-07 12:21:29 +01:00
Johan Hedberg 5b80603dbd Bluetooth: Controller: Use LL_ASSERT instead of BT_ASSERT
The controller code should not use BT_ASSERT directly.

Change-Id: If0b7d8e21d2ab4569a564bd03e36e4eb9204c595
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-07 12:29:58 +00:00
Johan Hedberg 50678b03cb Bluetooth: Reuse HCI command buffers for the command response
Reduce the pressure on the common RX buffer pool by reusing HCI
command buffers also for the Command Status or Command Complete
response to them. This also implies removing the existing Kconfig
variable for the command buffer sizes since the size is also dependent
on maximum Command Complete event sizes. Instead, reuse the RX buffer
size also for HCI Command buffers.

Change-Id: I006b287d64a0c9ca40de741aa9a424a49a927385
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-05 22:39:25 +02:00
Johan Hedberg 6c0e9720e2 Bluetooth: Controller: Redesign response buffer allocation for commands
With an upcoming patch the HCI command buffers will be reused for the
Command Complete/Status HCI events. The controller HCI code needs some
refactoring to postpone the event buffer allocation so that the
parsing state of the HCI command buffer isn't touched.

Change-Id: I1f614fb9f02ed1886ca84198fbc8c64abc29e44f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-05 22:39:25 +02:00
Kumar Gala 8d4c1787bf Bluetooth: Controller: Use CMSIS NVIC APIs directly
Convert driver to use the CMSIS NVIC APIs rather than the internal
ones so we can remove them in the future.

Change-Id: Ib9fe696e8d5e55f60865d3fd958a035135ce517a
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-23 15:15:55 -06:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Johan Hedberg 645f867444 Bluetooth: Take advantage of IS_ENABLED macro for BT_DBG
The new IS_ENABLED macro allows exposing conditionally enabled code
always to the compiler, even though it may not ultimately end up being
built. This is in particular useful for letting the compiler catch any
logging format string errors. Introduce a new BT_DBG_ENABLED macro
that c-files need to define before including <bluetooth/log.h> in
order to choose whether BT_DBG() logs are enabled or not.

When no Bluetooth logs are enabled the patch also modifies the log
macros to have the format strings checked with the help of the
__printf_like annotation and empty static inline functions.

Change-Id: Ie6bc8e10727b5b306f3ed0f94089a07a22583d9b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-18 08:28:06 +02:00
Johan Hedberg 815e15e3b2 Bluetooth: Controller: Rename hci_le_rand to bt_rand
Rename hci_le_rand to bt_rand and make its parameter types compatible.
This also includes updating rand_get() to use size_t instead of
uint32_t & uint8_t.

Change-Id: I4d434dfbbaf339b1bc7b451d358d07a291dd0375
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-17 08:44:21 +02:00
Johan Hedberg 4cd92c90c9 Bluetooth: Use the controller bt_rand() whenever possible
The controller bt_rand() ties into the hardware which uses less memory
and is more power-efficient than using the TinyCrypt PRNG.

Change-Id: I7570d18f3e84dae3d5c2d3322b5d37cd3e8f3b6b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-17 08:44:21 +02:00
Vinayak Chettimada 2d064eef89 Bluetooth: Controller: revert to event callback inside radio ISR
In order that host can continue a connection event by
enqueuing packets, the number of completed packets event
needs to be generated as soon it arrives on air. Hence, the
Controller now calls the radio_event_callback on every radio
Rx complete ISR.

The callback executes at the Radio ISR priority, take care
to only do as little as necessary in the callback, say, just
a semaphore give to wake up the hci_driver's thread.

Change-id: If48afd0f1390d450bc1e7ec66f1c9fd45208d9a4
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:17 +02:00
Carles Cufi e979d656cc bluetooth: controller: Split events into normal and priority
For the host to be able to block on the recv_thread while waiting for a
number of completed packets HCI event, those are pulled from the radio
in a new, higher priority thread that also schedules the execution of
the lower priority event/ACL data recv_thread.

Change-id: I9d356bd297d0504cb16a032fb5fe5530693546e2
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:17 +02:00
Johan Hedberg d64f47d956 Bluetooth: Create separate bt_recv_prio() API
Since callers of bt_recv() have so far anyway been required to know in
which context to call it (based on e.g. bt_hci_evt_is_prio) it's
cleaner to have two separate APIs: bt_recv and bt_recv_prio.

Change-Id: Icd0d9aed9c51ffd2def31432c4ffcc16a9f13ccd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-05 08:49:17 +02:00
Johan Hedberg 2f191012c2 Bluetooth: Controller: Deprioritize adv report buffer allocation
Advertising reports are the only HCI events which we can drop if we
are low on buffers. Allocate them therefore with K_NO_WAIT rather than
K_FOREVER.

Change-Id: I0b7c92647f9be54b8746da837037725f8161a452
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-05 08:49:17 +02:00
Johan Hedberg 88b620550c Bluetooth: Controller: Switch to controller-side RX thread
Since the controller already uses a thread for receiving data it makes
sense to enable the BLUETOOTH_RECV_IS_RX_THREAD option.

Change-Id: I927b20c1a0afaea8d000df28cc220a69ae817d59
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-05 08:49:17 +02:00
Johan Hedberg d79bdd74e9 Bluetooth: Controller: Use bt_buf_get_rx for buffer allocation
The controller uses K_FOREVER for the allocations so there's no
benefit in trying to use specialized pools (which exist to try to
guarantee availability of buffers for critical data).

Change-Id: I130f2c44a2f28af1284290e6a0b17dcba438862f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-05 08:49:17 +02:00
Vinayak Chettimada a69cdca529 Bluetooth: Controller: Remove advertiser struct use in observer
Change-id: I2c332047d80167cb5823f5af605cb5edbcb5e9fe
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 0565945a5c Bluetooth: Controller: fix DLE conditional compilations
Fix missing conditional compilation of Data Length Update
feature.

Change-id: I93aa1da2145a33095c220c863ed1457bb27a7aec
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada d5d473b0f8 Bluetooth: Controller: replace work with mayfly
This commit introduces a very light-weight and lock-less
scheduling of the Controller's deferred function calls
called the Mayfly.

Earlier work implementation used in the Controller had an
O(n) to schedule a function in a linked list that used IRQ
lock during modification of the linked list in the
Controller's ISR executions.

Mayfly is a compile time configurable matrix of queues
where an execution context-safe queue exists between two
execution context, one being the caller and the second
being the callee. Callee(s) are run in a software interrupt
but can also be run in an OS thread.

There are minor clean ups too in this commit related to
folder structure.

Change-id: I5ff44dcee6679d2f5ce9e8437d98d6c868782f3d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 8bd73aeba7 Bluetooth: Controller: add memq_peek interface
Change-id: I276eddd5e347a5930cff3158ee9aaec0cc7a1585
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 85cfff0d92 Bluetooth: Controller: Kconfig fast encryption setup feature
Enable connection encryption setup in 3 connection
intervals. Peripheral will respond to Encryption Request
with Encryption Response in the same connection interval,
and also, will respond with Start Encryption Response PDU in
the 3rd connection interval, hence completing encryption
setup in 3 connection intervals. Encrypted data would be
transmitted as fast as in 3rd connection interval from the
connection establishment. Maximum CPU time in Radio ISR will
increase if this feature is selected.

Change-id: I16f2863fc2aaed624826505739519d4de1ac44c5
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 404e7662e0 Bluetooth: Controller: Kconfig Tx buffer size
Add Kconfig configuration to select Tx buffer size, this
value will be returned in the HCI LE Read Buffer Size
command response.
This configuration will allow lower Tx RAM usage when
larger PDU sizes are desired in Rx direction only.

Change-Id: I5106a448d78a0754c4b0f6fa61fd5dcacd87a67c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 27353bb655 Bluetooth: Controller: Kconfig connection RSSI measurement
Add Kconfig configuration and conditional compilation of
RSSI measurement during a connection.

Change-id: I5a2f23f76a7cbbd9569d53d31899a472bf39d3ee
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 08fcc44b8a Bluetooth: Controller: Kconfig Data Length Update feature
Add Kconfig configuration to conditionally enable Data
Length Update procedure support in the Controller.
This will save CPU time, flash and RAM, if this feature is
not desired.

Change-id: I4515c0c7cf9aeb333a289397ae3c9bac04a08e4e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 4fb2947b61 Bluetooth: Controller: fix LE Ping conditional compilations
Add additional conditional compilation of code not needed
when LE Ping is disabled in Kconfig.

Change-id: Idab40b1371488e06a6f2009fb553f7655b7b86f3
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Carles Cufi 4b7cdd499f bluetooth: Tune stack sizes after measuring with hci_uart
The following readings were obtained after running the peripheral and
central_hr apps in qemu combined with the controller (hci_uart) on nRF51
and nRF52:

Main Stack 380
Idle Stack: 68
ISR stack: 532
Controller RX Stack: 388
HCI TX Stack: 516

The numbers set in this change provide a safety margin from the ones
measured empirically.

Change-id: Ice7ad7f081502e0ea1accf856a7937c0bf0783b2
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada b37e285c03 Bluetooth: Controller: Kconfig LE Ping feature
Add Kconfig configuration to conditionally enable LE Ping
feature in the Controller.
This will save CPU time, flash and RAM, if this feature is
not desired.

Change-id: I5fbbdbe8f45ac01c9b0d7b11e002a0d1db4d272e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 1921b53484 Bluetooth: Controller: refactor ISR to reduce critical path code
Move code that can be executed after radio tx/rx packet ptr
has been assigned in the radio h/w.

Change-id: I9c5a34ee6bb74c1265d7871bcdf93894e3e7b190
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada a591205045 Bluetooth: Controller: Kconfig radio ISR profiling
Add Kconfig configuration and conditional compilation of
radio ISR profiling.

Change-id: Ia80d6bc54810156be99b2e6a25327c30d0714697
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 73236dbaa5 Bluetooth: Controller: BT_INFO the ISR profiling event
Change-id: Ic2e01f698c13d76fc462349fe67f1694639888cb
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada ecb649c2a1 Bluetooth: Controller: add radio ISR profiling event
Added code to profile radio ISR execution time and generate
an event, which can be used to populate a vendor HCI event.

This event and associated code is disabled, subsequent
patch will add kconfig to enable it.

Change-id: Ic3fa3e0f4e36829a22a25ffee039949eaae561a7
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada 6996619399 Bluetooth: Controller: use BT_WARN to display unknown rsp
Use BT_WARN instead of BT_ASSERT to display unknown rsp in
HCI layer.

Change-id: I63c792468d9c4768f69df73395ee026a03521704
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Vinayak Chettimada ced33653fa Bluetooth: Controller: internally handle unknown rsp for LE Ping
Peer controllers not supporting LE Ping feature will
respond with unknown response PDU, handle it internally in
the controller rather than exposing it to HCI layer.

Discovered that controller was passing the unknown rsp PDU
to HCI layer when LE Ping was send to Nexus 5.

Unknown response for slave feature request was forwarded to
HCI layer, during that implementation unknown rsp for LE
ping too was getting forwarded to HCI layer.

Change-id: I4396c482e5546d78239cf41d88728de996e48d7d
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Johan Hedberg f3c632bf44 Bluetooth: Add timeout to event & ACL buffer allocation functions
Not all users are in an ISR context where we can't block, so give the
callers the freedom to choose if they want to block or not.

Jira: ZEP-1481

Change-Id: I19bd7e2df94c4eeb60886a17a78f872bd7bea887
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-24 08:42:15 +02:00
Carles Cufi 167eac7df3 Bluetooth: controller: Move call to k_sem_give() out of the ISR
The execution time of k_sem_give() increased slightly recently, and
since it was being called from the radio ISR this had an impact in the
deadlines not being met.
This change moves the actual call to k_sem_give() to a lower-priority
job and thus out of the ISR to avoid its execution time affecting the
ISR's timing.

Change-id: I76c82df895c6daaffef52786b0c900ee15acb0aa
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-24 08:42:15 +02:00
Carles Cufi fc479e03e0 Bluetooth: controller: Use SERIES config instead of NRF52
In preparation for the new Nordic MDK and nRF52840 IC support we switch
to using the SERIES config instead of the old "NRF52" macro that will be
deprecated in the new MDK.

JIRA: ZEP-1418

Change-Id: I563f025c9db9b7497116c5af23814d95c720f836
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-20 09:14:47 -06:00
Johan Hedberg 1c9da665c3 Bluetooth: Remove unnecessary runtime kernel object initialization
There are static initializer macros available for most kernel objects
which we should use whenever possible.

Change-Id: I496f4d05d26801eddd21fae53bdd4fcdc3246fe3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-16 10:27:48 +02:00
Vinayak Chettimada f0bd2805bc Bluetooth: Controller: tune the xtal and hard realtime radio start offsets
Reduce the time limit for active clock startup and increase
the CPU usage time limit before hard real-time radio
transmit/receive.

Due to isr_wrapper overhead in ARM architectures, more time
was used before hard real-time radio transmission or
reception which was detected by controller implementation
and the controller aborted the radio transactions.

This commit permits more CPU utilization by the controller
before hard real-time radio transactions start.

Change-Id: Id976add80c70cabc753c43dfac6f6603588458d9
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-12-16 10:27:48 +02:00
Vinayak Chettimada 6de7a808af Bluetooth: Controller: ctrl pdu processing based on available CPU time
On CPUs like nRF51 which run at 16MHz, certain BLE control
procedure PDU processing take more CPU time than permitted
inside tIFS (150us). Current implementation of Data Length
Update procedure does not span over multiple connection
interval (unlike Encryption Setup, which is another control
procedure processing that would consume more CPU time)
hence taking more CPU time inside tIFS on nRF51.

During the radio ISR, the active clock and packet timer are
active and it is used to profile the CPU time taken which
is used to decide on whether there is sufficient time in
the current radio event to process the control packet.

This commit also fixes a potential bug that would cause
disconnection due to MIC failure on encrypted connections
that performed Data Length Update. Controller used to NACK
the request/response PDU if it was not in a state to resize
the receive buffers but did not reset the CCM counter. This
is now fixed by the change done to NACK control PDU based
on available CPU time in radio ISR.

Change-id: Id58322ad76a0dbc284738cdd9a7c0437c9e8c423
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-12-16 10:27:48 +02:00
Johan Hedberg 299216b2f0 Bluetooth: Controller: Make use of min() convenience macro
Instead of having custom logic for determining the minimum of two
values, use the existing min() helper from misc/util.h.

Change-Id: I9809883d4a31126329373f293897dd49eb91e9ad
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-03 17:09:38 +00:00
Vinayak Chettimada f0186d716d Bluetooth: Controller: Fix DLE to check supported rx length
When the Controller is configured to support less than 251
as the supported maximum data length, missing check caused
the Controller to incorrectly re-initialize its rx buffers
causing assert during the DLE procedure. This commit fixes
the procedure to correctly use the supported maximum length
if the peer requests a transmit length that exceeds the
supported receive length.

Change-id: I6ad7196e3db44b303ddf2ec06e0ae579bf2eb774
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-03 17:09:38 +00:00
Carles Cufi d42987acf4 Bluetooth: Controller: Fix local LE supported features bitmap
Correct the local LE supported features bitmap to actually "or"
together all the bits that correspond to the set of features that
are implemented at this time.

Change-Id: I0c62ec566c775514250fcf062aeef6c9656719e3
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-03 17:09:38 +00:00
Carles Cufi 3b1baa88ef Bluetooth: Controller: Implement ECC commands
Implement the 2 HCI commands that provide ECC public key
and shared secret generation:

- LE Read Local P-256 Public Key
- LE Generate DHKey

Jira: ZEP-1246

Change-Id: I79388bfdb9f2e28b9377b4bb6ee2caca25f33f3e
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-03 17:09:38 +00:00
Carles Cufi c969e757bc Bluetooth: Controller: Implement missing DLE commands
Implement the 3 missing HCI commands required to support
Data Length Extensions:

- LE Read Suggested Default Data Length
- LE Write Suggested Default Data Length
- LE Read Maximum Data Length

Note: Only octets are actually used at this time, not time.

Jira: ZEP-1246

Change-Id: Id76d8fedb5ecaf0001c8429cf22f9a3e2c910a44
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada e9b818e763 Bluetooth: Controller: Fix suspicious use of sizeof
Fix Coverity, sizeof not portable, defect; by explicitly
using sizeof(void *).

suspicious_sizeof:
Passing argument mem_head of type void ** and argument 4U
/* sizeof (mem_head) */ to function memcpy is suspicious.
In this case, sizeof (void **) is equal to sizeof
(void *), but this is not a portable assumption.

Change-id: I4b4776466e16020876500feba0141985b8581017
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada 26f6b71a8e Bluetooth: Controller: Fix incorrect irq priority check
External interrupts are indexed from value 16, wherein
0 to 15 are ARM cortex M exceptions. Fixed code in
_irq_is_priority_equal to fetch correct external
interrupt line ISR priority.

Change-id: I9cfd411480e78dfc9635e72d14df9d667a9d8400
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada 27b1a24993 Bluetooth: Controller: Remove unused util functions
Change-id: I7b691d082d080239c35b63221e3c6c7aa93ed58e
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada 94a425429c Bluetooth: Controller: Fix incorrect auto variable init
Coverity analysis discovered NULL pointer being
dereferenced when passing a auto variable. The variable is
now correctly assigned with address of a valid default
value variable. As per design, the dereferencing will not
happen as the master role does not use the passed parameter
only slave role uses it to prepare the connection parameter
request PDU.

Change-id: I3f8519b23a83cb8c50c7fba81810eff7737ff74a
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada 7b1c042b02 Bluetooth: Controller: Fix observer filter_policy field size
Coverity analysis discovered that observer filter policy
field was 1 bit, whereas valid range for extended scanner
filter policy feature implemented in controller is 0 to 3.
Increase the bit field size from 1 to 2.

Change-Id: Id4b2e354961dfb3b45f72fa4e0ab18de7425bbb5
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada 11770b8bf4 Bluetooth: Controller: Fix HCI Reset Command implementation
Added implementation for HCI Reset Command. Implementation
gracefully disables any running advertiser, observer, and/
or connection roles, and it resets controller context members.
The HCI Reset Command is implemented in such a way that
driver instances shared with other sub-systems and
application is not disturbed and instance/references used
by Bluetooth Controller are gracefully returned back.

Jira: ZEP-1282

Change-id: Ifb9ae6807736b5ec2d9f346cf2a590322056bcee
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-11-18 07:47:50 +02:00
Vinayak Chettimada 4812b2d40e Bluetooth: Controller: Fix device whitelist feature
During the initial integration of controller to Zephyr OS,
radio hardware access was abstracted out into hal/radio.c
file. Bug introduced in hal/radio.c has been fixed so that
whitelist feature works again.

Change-id: Ie5faf80b1a008ef326613548a5a28a4ba52e7ef7
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-11 16:40:59 +00:00
Johan Hedberg c245b96249 Bluetooth: Kconfig: Fix order of default entries
The conditional defaults must come last in order to be properly
processed.

Change-Id: Id7a152ca1a1584935029e212d0dd8f37494d1cf4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 12:09:46 +00:00
Vinayak Chettimada 5629197b17 Bluetooth: Controller: Add HCI_LE_Remove_Device_From_White_List
Add implementation in HCI and Controller to support
HCI_LE_Remove_Device_From_White_List, as it is listed as
mandatory under BT Spec. v4.2, Part E, Section 3.19 LE
Controller Requirements.

Change-id: Icef88dffc85746f3cc7adb7fb692ae5578274ed2
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-11 11:56:47 +00:00
Johan Hedberg 916ed6cdd2 Bluetooth: Controller: Stop using deprecated APIs
Switch from fiber_start() to k_thread_spawn() and from NANOKERNEL to
POST_KERNEL init level.

Change-Id: I34fb11cbe20216c8646ebacb07be304a67e3cd0a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 10:04:02 +02:00
Johan Hedberg b0f0742b6e Bluetooth: Use k_yield() instead of deprecated fiber_yield()
Use the unified kernel API k_yield() instead of fiber_yield().

Change-Id: I8f52031f52f7ac8783033a51751dc22decdfa59a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 09:38:40 +02:00
Johan Hedberg 3062516a1a Bluetooth: Controller: Improve default RX/TX buffer counts
Currently the ideal buffer counts for a controller-only build are 6 RX
buffers and 7 TX buffers: ATT_MTU of 158 bytes can be sent in one
connection interval of 6 tx/rx -es wherein connection interval is
7.5ms

Change-Id: I64b4620c5e8e7db8d7ed72fa1db82e266e121f27
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 07:59:15 +02:00
Johan Hedberg c583a9f43b Bluetooth: Kconfig: Restructure for a more logical hierarchy
Restructure the Bluetooth options more logically.

- Both host and controller are now behind the same high level
  CONFIG_BLUETOOTH.

- Selecting controller support disables other HCI driver selection, so
  the controller isn't in the same list as HCI drivers any more.

- Under the top-level there's a "Custom stack" option, which when
  enabled opens up the option of choosing CONFIG_NBLE.

There are various other cleanups and simplifications in this patch as
well, since splitting these up would have been fairly tricky while
making sure all test cases still build.

Change-Id: I5bb715cb9d20201cb8b72fbd149c8a09a4b2d7d2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 07:59:15 +02:00
Carles Cufi f7d313b154 Bluetooth: Controller: Add ASSERT info dump on HCI builds
When building Zephyr in the controller-only configuration,
assertions that happen in the Link Layer code are not visible
to the Host which is running on another HCI and connected via
UART or USB to it. This patch allows the Controller code
to output the assertion line number when in such a configuration,
allowing the Host to view the event to help debugging.

The event format used is temporary and will be replaced by a
standardized Vendor Specific specification to come at a later
time.

Change-Id: I013ca6783a3fdedc47b171132919dd4798c66285
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-11-11 07:59:15 +02:00
Johan Hedberg 50f03a8de5 Bluetooth: Controller: Kconfig: Clean up style issues
The right convention for help text is tab + 2 spaces.

Change-Id: I2722a8b33f5f74be110dc43fbcecc12841f0db84
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 07:59:15 +02:00
Carles Cufi 6ccfa64b5c Bluetooth: Controller: Handle LL_UNKNOWN_RSP PDU for remote features
When a peer controller does not recognize one of the LL control
PDUs received, it will issue an LL_UNKNOWN_RSP PDU to let the
peer know that it does not recognize the request.
The controller now handles this incoming PDU and completes the
procedure by issuing the appropriate HCI event in the case of
an LL_FEATURE_REQ and _RSP pair.

Jira: ZEP-1220

Change-Id: I7c04a346441f04deee41198daa6309c11ae1b571
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-11-09 08:57:52 +02:00
Szymon Janc e18e3ed60a Bluetooth: Controller: Use unified k_sem API for semaphore
Change-Id: I02b4e5f4d0a2995cfae1b9a2edcbdf01d6ec631a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-09 08:57:52 +02:00
Szymon Janc 8944c25c90 Bluetooth: Controller: Include zephyr.h instead of nanokernel.h
zephyr.h includes required kernel header depending on selected
configuration.

Change-Id: Ib72c4038637c303ee32e433706355299ae1b9a13
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-09 08:57:52 +02:00
Vinayak Chettimada fb032efa90 Bluetooth: Controller: Use configured clock source
Remove hardcoded use of crystal as 32KHz clock source and
20 ppm accuracy; and use the values from config for sleep
clock source and sleep clock accuracy value in Bluetooth
Controller.

Change-id: I1c0d53ecf8ad158153d5186a6680b5eb03d1641b
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-07 12:04:03 +00:00
Vinayak Chettimada d62426030c Bluetooth: Controller: Fix re-encryption procedure
During implementation of alternate encryption procedure
usable in nRF51, commited in
c41d3edda8, re-encryption
procedure was broken. This commit fixes the issue, and
now re-encryption should work on both nRF51 and nRF52.

Change-id: Ia41200f42b1d46e1f3f35ff44b582d4ffcc5f4fa
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-11-04 22:06:31 +02:00
Johan Hedberg 26d39cd107 Bluetooth: Move controller code to subsys/bluetooth
Move controller code from drivers/controller to
subsys/bluetooth/controller.

Change-Id: I73f675188485aa3267507bad7647796e593a3da0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-04 22:05:05 +02:00