Skip to content
Permalink
Browse files

Bluetooth: controller: Enable use of user defined protocols

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>
  • Loading branch information...
asmk-ot authored and nashif committed May 24, 2019
1 parent c8ae05d commit 8844b7f5a5e22e7e55511f7a1b14cef09239231a
Showing with 29 additions and 4 deletions.
  1. +9 −0 subsys/bluetooth/controller/Kconfig
  2. +20 −4 subsys/bluetooth/controller/ll_sw/ull.c
@@ -736,4 +736,13 @@ config BT_CTLR_USER_EVT_RANGE
Number of event types reserved for proprietary use. The range
is typically used when BT_CTLR_USER_EXT is in use.

config BT_RX_USER_PDU_LEN
int "Maximum supported proprietary PDU buffer length"
default 2
range 2 255
help
Maximum data size for each proprietary PDU. This size includes link layer
header and payload. It does not account for HCI event headers as these
PDUs are assumed to not go across HCI.

endif # BT_CTLR
@@ -150,16 +150,23 @@ static struct {
static MFIFO_DEFINE(pdu_rx_free, sizeof(void *), PDU_RX_CNT);
static MFIFO_DEFINE(ll_pdu_rx_free, sizeof(void *), LL_PDU_RX_CNT);

#if defined(CONFIG_BT_RX_USER_PDU_LEN)
#define PDU_RX_USER_PDU_OCTETS_MAX (CONFIG_BT_RX_USER_PDU_LEN)
#else
#define PDU_RX_USER_PDU_OCTETS_MAX 0
#endif
#define NODE_RX_HEADER_SIZE (offsetof(struct node_rx_pdu, pdu))
#define NODE_RX_STRUCT_OVERHEAD (NODE_RX_HEADER_SIZE)

#define PDU_ADVERTIZE_SIZE (PDU_AC_SIZE_MAX + PDU_AC_SIZE_EXTRA)
#define PDU_DATA_SIZE (PDU_DC_LL_HEADER_SIZE + LL_LENGTH_OCTETS_RX_MAX)

#define PDU_RX_NODE_POOL_ELEMENT_SIZE \
MROUND( \
NODE_RX_STRUCT_OVERHEAD \
+ MAX(PDU_ADVERTIZE_SIZE, PDU_DATA_SIZE) \
#define PDU_RX_NODE_POOL_ELEMENT_SIZE \
MROUND( \
NODE_RX_STRUCT_OVERHEAD \
+ MAX(MAX(PDU_ADVERTIZE_SIZE, \
PDU_DATA_SIZE), \
PDU_RX_USER_PDU_OCTETS_MAX) \
)

#define PDU_RX_POOL_SIZE (PDU_RX_NODE_POOL_ELEMENT_SIZE * (RX_CNT + 1))
@@ -295,6 +302,13 @@ int ll_init(struct k_sem *sem_rx)
}
#endif /* CONFIG_BT_CONN */

#if defined(CONFIG_BT_CTLR_USER_EXT)
err = ull_user_init();
if (err) {
return err;
}
#endif /* CONFIG_BT_CTLR_USER_EXT */

/* reset whitelist, resolving list and initialise RPA timeout*/
if (IS_ENABLED(CONFIG_BT_CTLR_FILTER)) {
ull_filter_reset(true);
@@ -466,6 +480,7 @@ void ll_rx_dequeue(void)
defined(CONFIG_BT_CTLR_PROFILE_ISR) || \
defined(CONFIG_BT_CTLR_ADV_INDICATION) || \
defined(CONFIG_BT_CTLR_SCAN_INDICATION) || \
defined(CONFIG_BT_CTLR_USER_EXT) || \
defined(CONFIG_BT_CONN)

#if defined(CONFIG_BT_CONN)
@@ -550,6 +565,7 @@ void ll_rx_dequeue(void)
* CONFIG_BT_CTLR_PROFILE_ISR ||
* CONFIG_BT_CTLR_ADV_INDICATION ||
* CONFIG_BT_CTLR_SCAN_INDICATION ||
* CONFIG_BT_CTLR_USER_EXT ||
* CONFIG_BT_CONN
*/

0 comments on commit 8844b7f

Please sign in to comment.
You can’t perform that action at this time.