Bluetooth: Add BUILD_ASSERT to check Tx and Rx thread priorities

Added BUILD_ASSERT check for Tx and Rx thread priorities.

The Tx thread priority shall be higher than Rx thread
priority in order to correctly detect transaction violations
in ATT and SMP protocols. The Number of Completed Packets
for a connection shall be processed before any new data is
received and processed for that connection.

The Controller's priority receive thread priority shall be
higher than the Host's Tx and the Controller's Rx thread
priority.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2017-07-11 09:47:08 +02:00 committed by Johan Hedberg
commit 9a13a0c732
8 changed files with 59 additions and 15 deletions

View file

@ -17,3 +17,20 @@
* and that the system workqueue priority is negative (cooperative).
*/
BUILD_ASSERT(CONFIG_SYSTEM_WORKQUEUE_PRIORITY < 0);
/* The Bluetooth subsystem requires the Tx thread to execute at higher priority
* than the Rx thread as the Tx thread needs to process the acknowledgements
* before new Rx data is processed. This is a necessity to correctly detect
* transaction violations in ATT and SMP protocols.
*/
BUILD_ASSERT(CONFIG_BLUETOOTH_HCI_TX_PRIO < CONFIG_BLUETOOTH_RX_PRIO);
#if defined(CONFIG_BLUETOOTH_CONTROLLER)
/* The Bluetooth Controller's priority receive thread priority shall be higher
* than the Bluetooth Host's Tx and the Controller's receive thread priority.
* This is required in order to dispatch Number of Completed Packets event
* before any new data arrives on a connection to the Host threads.
*/
BUILD_ASSERT(CONFIG_BLUETOOTH_CONTROLLER_RX_PRIO <
CONFIG_BLUETOOTH_HCI_TX_PRIO);
#endif /* CONFIG_BLUETOOTH_CONTROLLER */