Skip to content

Commit

Permalink
Bluetooth: controller: Enable use of proprietary rx demuxing functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
asmk-ot authored and carlescufi committed May 22, 2019
1 parent 03ef375 commit 69790e5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
15 changes: 15 additions & 0 deletions subsys/bluetooth/controller/Kconfig
Expand Up @@ -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
16 changes: 15 additions & 1 deletion subsys/bluetooth/controller/ll_sw/lll.h
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions subsys/bluetooth/controller/ll_sw/ull.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 69790e5

Please sign in to comment.