From 27bad8743f22178207d07ef664ffef4ba69d7ccc Mon Sep 17 00:00:00 2001 From: Vinayak Chettimada Date: Tue, 25 Apr 2017 14:37:15 +0200 Subject: [PATCH] Bluetooth: l2cap: Decouple segmentation size L2CAP Tx segmentation used BT_L2CAP_RX_MTU value which is the value used by fixed channel protocols. Decoupling the buffer size provides the opportunity to reduce RAM used per connection. Change-id: Id064f9b2e3f02073402815d09c3ea13a35df2a6c Signed-off-by: Vinayak Chettimada --- subsys/bluetooth/host/Kconfig | 9 +++++++++ subsys/bluetooth/host/l2cap.c | 15 ++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index 2a821876db8..d853a7ae670 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -267,6 +267,15 @@ config BLUETOOTH_L2CAP_DYNAMIC_CHANNEL This option enables support for LE Connection oriented Channels, allowing the creation of dynamic L2CAP Channels. +config BLUETOOTH_L2CAP_DYN_CHAN_BUF_SIZE + int "L2CAP Dynamic channel segment buffer size" + depends on BLUETOOTH_L2CAP_DYNAMIC_CHANNEL + range 23 BLUETOOTH_L2CAP_TX_MTU + default 23 + help + Size of the buffer used for segmentation of SDU when application + supplied buffer does not have sufficient headroom. + config BLUETOOTH_GATT_DYNAMIC_DB bool "GATT dynamic database support" help diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index db284fc47e6..2d7a33be10b 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -41,6 +41,9 @@ #define L2CAP_CONN_TIMEOUT K_SECONDS(40) #define L2CAP_DISC_TIMEOUT K_SECONDS(1) +static sys_slist_t le_channels; + +#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) /* Size of MTU is based on the maximum amount of data the buffer can hold * excluding ACL and driver headers. */ @@ -48,20 +51,14 @@ /* For now use MPS - SDU length to disable segmentation */ #define L2CAP_MAX_LE_MTU (L2CAP_MAX_LE_MPS - 2) -#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) #define l2cap_lookup_ident(conn, ident) __l2cap_lookup_ident(conn, ident, false) #define l2cap_remove_ident(conn, ident) __l2cap_lookup_ident(conn, ident, true) -#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ -static sys_slist_t le_channels; -#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) static sys_slist_t servers; -#endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ -#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) /* Pool for outgoing LE data packets, MTU is 23 */ -NET_BUF_POOL_DEFINE(le_data_pool, CONFIG_BLUETOOTH_MAX_CONN, - BT_L2CAP_BUF_SIZE(L2CAP_MAX_LE_MPS), +NET_BUF_POOL_DEFINE(le_l2cap_dyn_chan_pool, CONFIG_BLUETOOTH_MAX_CONN, + BT_L2CAP_BUF_SIZE(CONFIG_BLUETOOTH_L2CAP_DYN_CHAN_BUF_SIZE), BT_BUF_USER_DATA_MIN, NULL); #endif /* CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL */ @@ -1016,7 +1013,7 @@ static inline struct net_buf *l2cap_alloc_seg(struct net_buf *buf) } } - return bt_l2cap_create_pdu(&le_data_pool, 0); + return bt_l2cap_create_pdu(&le_l2cap_dyn_chan_pool, 0); } static struct net_buf *l2cap_chan_create_seg(struct bt_l2cap_le_chan *ch,