From 3346aa4d39bd2b0ed11ecbad6556affb8cea1569 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Mon, 12 Oct 2020 10:12:42 +0200 Subject: [PATCH] Bluetooth: l2cap: Reduce size of disconnect pool Reduce the size of the disconnect pool required the full MTU for a disconnect request. Also completely remove the pool when not needed. Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/l2cap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index e4c3852a555..74c03ab98f5 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -54,13 +54,15 @@ #define L2CAP_DISC_TIMEOUT K_SECONDS(2) #define L2CAP_RTX_TIMEOUT K_SECONDS(2) +#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL) /* Dedicated pool for disconnect buffers so they are guaranteed to be send * even in case of data congestion due to flooding. */ NET_BUF_POOL_FIXED_DEFINE(disc_pool, 1, - BT_L2CAP_BUF_SIZE(CONFIG_BT_L2CAP_TX_MTU), NULL); + BT_L2CAP_BUF_SIZE( + sizeof(struct bt_l2cap_disconn_req)), + NULL); -#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL) #define L2CAP_MAX_LE_MPS CONFIG_BT_L2CAP_RX_MTU /* For now use MPS - SDU length to disable segmentation */ #define L2CAP_MAX_LE_MTU (L2CAP_MAX_LE_MPS - 2) @@ -401,10 +403,11 @@ static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf, struct bt_l2cap_sig_hdr *hdr; struct net_buf_pool *pool = NULL; +#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL) if (code == BT_L2CAP_DISCONN_REQ) { pool = &disc_pool; } - +#endif /* Don't wait more than the minimum RTX timeout of 2 seconds */ buf = bt_l2cap_create_pdu_timeout(pool, 0, L2CAP_RTX_TIMEOUT); if (!buf) {