From 69790e5c739b14d2be5ea1f439f1f7d99b9c7835 Mon Sep 17 00:00:00 2001 From: Asger Munk Nielsen Date: Thu, 9 May 2019 15:41:39 +0200 Subject: [PATCH] Bluetooth: controller: Enable use of proprietary rx demuxing functions 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 --- subsys/bluetooth/controller/Kconfig | 15 +++++++++++++++ subsys/bluetooth/controller/ll_sw/lll.h | 16 +++++++++++++++- subsys/bluetooth/controller/ll_sw/ull.c | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index 44cff829609ebb..0d4a96bc65fdfd 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -750,4 +750,19 @@ config BT_MAYFLY_YIELD_AFTER_CALL If set to 'n', all pending mayflies for callee are executed before yielding +config BT_CTLR_USER_EXT + prompt "Enable proprietary extensions in Controller" + bool + help + Catch-all for enabling proprietary event types in Controller behavior. + +config BT_CTLR_USER_EVT_RANGE + int "Range of event contants reserved for proprietary event types" + depends on BT_CTLR_USER_EXT + default 5 + range 0 10 + help + Number of event types reserved for proprietary use. The range + is typically used when BT_CTLR_USER_EXT is in use. + endif # BT_CTLR diff --git a/subsys/bluetooth/controller/ll_sw/lll.h b/subsys/bluetooth/controller/ll_sw/lll.h index 603d5c7ee895db..6fa7ff037189b0 100644 --- a/subsys/bluetooth/controller/ll_sw/lll.h +++ b/subsys/bluetooth/controller/ll_sw/lll.h @@ -173,8 +173,15 @@ enum node_rx_type { NODE_RX_TYPE_MESH_ADV_CPLT = 0x13, NODE_RX_TYPE_MESH_REPORT = 0x14, #endif /* CONFIG_BT_HCI_MESH_EXT */ -}; +/* Following proprietary defines must be at end of enum range */ +#if defined(CONFIG_BT_CTLR_USER_EXT) + NODE_RX_TYPE_USER_START = 0x15, + NODE_RX_TYPE_USER_END = NODE_RX_TYPE_USER_START + + CONFIG_BT_CTLR_USER_EVT_RANGE, +#endif /* CONFIG_BT_CTLR_USER_EXT */ + +}; /* Footer of node_rx_hdr */ struct node_rx_ftr { @@ -208,6 +215,13 @@ struct node_rx_pdu { enum { EVENT_DONE_EXTRA_TYPE_NONE, EVENT_DONE_EXTRA_TYPE_CONN, +/* Following proprietary defines must be at end of enum range */ +#if defined(CONFIG_BT_CTLR_USER_EXT) + EVENT_DONE_EXTRA_TYPE_USER_START, + EVENT_DONE_EXTRA_TYPE_USER_END = EVENT_DONE_EXTRA_TYPE_USER_START + + CONFIG_BT_CTLR_USER_EVT_RANGE, +#endif /* CONFIG_BT_CTLR_USER_EXT */ + }; struct event_done_extra_slave { diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index 17bc7551e0b6d5..65dde17aeedb77 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -45,6 +45,10 @@ #include "ull_scan_internal.h" #include "ull_conn_internal.h" +#if defined(CONFIG_BT_CTLR_USER_EXT) +#include "ull_vendor.h" +#endif /* CONFIG_BT_CTLR_USER_EXT */ + #define LOG_MODULE_NAME bt_ctlr_llsw_ull #include "common/log.h" #include "hal/debug.h" @@ -516,6 +520,9 @@ void ll_rx_dequeue(void) case NODE_RX_TYPE_MESH_REPORT: #endif /* CONFIG_BT_HCI_MESH_EXT */ +#if defined(CONFIG_BT_CTLR_USER_EXT) + case NODE_RX_TYPE_USER_START ... NODE_RX_TYPE_USER_END: +#endif /* CONFIG_BT_CTLR_USER_EXT */ /* * We have just dequeued from memq_ll_rx; that frees up some * quota for Link Layer. Note that we threw away the rx node @@ -741,6 +748,10 @@ void ll_rx_mem_release(void **node_rx) case NODE_RX_TYPE_MESH_REPORT: #endif /* CONFIG_BT_HCI_MESH_EXT */ +#if defined(CONFIG_BT_CTLR_USER_EXT) + case NODE_RX_TYPE_USER_START ... NODE_RX_TYPE_USER_END: +#endif /* CONFIG_BT_CTLR_USER_EXT */ + mem_release(rx_free, &mem_pdu_rx.free); break; @@ -1473,7 +1484,13 @@ static inline int rx_demux_rx(memq_link_t *link, struct node_rx_hdr *rx) default: { +#if defined(CONFIG_BT_CTLR_USER_EXT) + /* Try proprietary demuxing */ + rx_demux_rx_proprietary(link, rx, memq_ull_rx.tail, + &memq_ull_rx.head); +#else LL_ASSERT(0); +#endif /* CONFIG_BT_CTLR_USER_EXT */ } break; } @@ -1498,6 +1515,14 @@ static inline void rx_demux_event_done(memq_link_t *link, ull_conn_done(done); break; #endif /* CONFIG_BT_CONN */ + +#if defined(CONFIG_BT_CTLR_USER_EXT) + case EVENT_DONE_EXTRA_TYPE_USER_START + ... EVENT_DONE_EXTRA_TYPE_USER_END: + ull_proprietary_done(done); + break; +#endif /* CONFIG_BT_CTLR_USER_EXT */ + case EVENT_DONE_EXTRA_TYPE_NONE: /* ignore */ break;