From 28f46131b30cab7a8770733af717439cf4487496 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Fri, 13 Sep 2019 17:06:11 +0530 Subject: [PATCH] Bluetooth: controller: split: Fix Rx reserved for conn cmplt When both central and peripheral are supported, one each Rx node will be needed by connectable advertising and the initiator to generate connection complete, hence conditionally set the count. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/ull.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index faa272ae5d6..e013563fd18 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -166,19 +166,30 @@ static MFIFO_DEFINE(pdu_rx_free, sizeof(void *), PDU_RX_CNT); PDU_RX_USER_PDU_OCTETS_MAX) \ ) -#define PDU_RX_POOL_SIZE (PDU_RX_NODE_POOL_ELEMENT_SIZE * (RX_CNT + 1)) +/* When both central and peripheral are supported, one each Rx node will be + * needed by connectable advertising and the initiator to generate connection + * complete event, hence conditionally set the count. + */ +#if defined(CONFIG_BT_MAX_CONN) +#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PERIPHERAL) +#define BT_CTLR_MAX_CONNECTABLE 2 +#else +#define BT_CTLR_MAX_CONNECTABLE 1 +#endif +#define BT_CTLR_MAX_CONN CONFIG_BT_MAX_CONN +#else +#define BT_CTLR_MAX_CONNECTABLE 0 +#define BT_CTLR_MAX_CONN 0 +#endif + +#define PDU_RX_POOL_SIZE (PDU_RX_NODE_POOL_ELEMENT_SIZE * \ + (RX_CNT + BT_CTLR_MAX_CONNECTABLE)) static struct { void *free; u8_t pool[PDU_RX_POOL_SIZE]; } mem_pdu_rx; -#if defined(CONFIG_BT_MAX_CONN) -#define BT_CTLR_MAX_CONN CONFIG_BT_MAX_CONN -#else -#define BT_CTLR_MAX_CONN 0 -#endif - #define LINK_RX_POOL_SIZE (sizeof(memq_link_t) * (RX_CNT + 2 + \ BT_CTLR_MAX_CONN)) static struct {