Bluetooth: Introduce config options for buffer counts/sizes

Introduce dedicate Kconfig options for ACL & HCI buffer counts and
sizes.

Change-Id: I96796058f70998e1e721849422c4bc4e950b6d93
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-10-29 14:45:02 +02:00 committed by Anas Nashif
commit e9ceedcff7
5 changed files with 57 additions and 20 deletions

View file

@ -55,6 +55,54 @@ config BLUETOOTH_DEBUG_HCI_CORE
This option enables debug support for Bluetooth HCI
core.
config BLUETOOTH_HCI_COUNT
int "Number of HCI buffers"
default 8
range 2 64
help
Number of buffers available for HCI commands and events.
config BLUETOOTH_HCI_SIZE
int "Size of HCI buffers"
default 72
range 72 260
help
Maximum size of each HCI buffer.
if BLUETOOTH_CONN
config BLUETOOTH_ACL_IN_COUNT
int "Number of incoming ACL data buffers"
default 7
range 1 16
help
Number of buffers available for incoming ACL data.
config BLUETOOTH_ACL_IN_SIZE
int "Size of incoming ACL data buffers"
default 74 if BLUETOOTH_SMP
default 32 if !BLUETOOTH_SMP
range 74 1300 if BLUETOOTH_SMP
range 32 1300 if !BLUETOOTH_SMP
help
Maximum size of each incoming ACL data buffer.
config BLUETOOTH_ACL_OUT_COUNT
int "Number of incoming ACL data buffers"
default 7
range 1 16
help
Number of buffers available for incoming ACL data.
config BLUETOOTH_ACL_OUT_SIZE
int "Size of incoming ACL data buffers"
default 74 if BLUETOOTH_SMP
default 32 if !BLUETOOTH_SMP
range 74 1300 if BLUETOOTH_SMP
range 32 1300 if !BLUETOOTH_SMP
help
Maximum size of each outgoing ACL data buffer.
endif # BLUETOOTH_CONN
if BLUETOOTH_PERIPHERAL || BLUETOOTH_CENTRAL
config BLUETOOTH_SMP
bool "Security Manager Protocol support"

View file

@ -21,7 +21,7 @@
/* Size of MTU is based on the maximum amount of data the buffer can hold
* excluding L2CAP, ACL and driver headers.
*/
#define BT_ATT_MAX_LE_MTU (BT_BUF_MAX_DATA - \
#define BT_ATT_MAX_LE_MTU (CONFIG_BLUETOOTH_ACL_IN_SIZE - \
sizeof(struct bt_l2cap_hdr) - \
sizeof(struct bt_hci_acl_hdr) - \
bt_dev.drv->recv_reserve)

View file

@ -76,7 +76,8 @@ struct bt_acl_data {
/* Available (free) buffers queues */
static struct nano_fifo avail_hci;
static NET_BUF_POOL(hci_pool, 8, BT_BUF_MAX_DATA, &avail_hci, NULL,
static NET_BUF_POOL(hci_pool, CONFIG_BLUETOOTH_HCI_COUNT,
CONFIG_BLUETOOTH_HCI_SIZE, &avail_hci, NULL,
sizeof(struct bt_hci_data));
#if defined(CONFIG_BLUETOOTH_CONN)
@ -108,9 +109,9 @@ static void report_completed_packet(struct net_buf *buf)
#define BT_BUF_ACL_IN_MAX 7
static struct nano_fifo avail_acl_in;
static NET_BUF_POOL(acl_in_pool, BT_BUF_ACL_IN_MAX, BT_BUF_MAX_DATA,
&avail_acl_in, report_completed_packet,
sizeof(struct bt_acl_data));
static NET_BUF_POOL(acl_in_pool, CONFIG_BLUETOOTH_ACL_IN_COUNT,
CONFIG_BLUETOOTH_ACL_IN_SIZE, &avail_acl_in,
report_completed_packet, sizeof(struct bt_acl_data));
#endif /* CONFIG_BLUETOOTH_CONN */
/* Incoming buffer type lookup helper */
@ -731,7 +732,7 @@ static int set_flow_control(void)
hbs = net_buf_add(buf, sizeof(*hbs));
memset(hbs, 0, sizeof(*hbs));
hbs->acl_mtu = sys_cpu_to_le16(BT_BUF_MAX_DATA -
hbs->acl_mtu = sys_cpu_to_le16(CONFIG_BLUETOOTH_ACL_IN_SIZE -
sizeof(struct bt_hci_acl_hdr) -
bt_dev.drv->recv_reserve);
hbs->acl_pkts = sys_cpu_to_le16(BT_BUF_ACL_IN_MAX);

View file

@ -175,14 +175,3 @@ const char *bt_addr_le_str(const bt_addr_le_t *addr);
#endif
int bt_le_scan_update(void);
/** @def BT_BUF_MAX_DATA
* @brief Maximum amount of data that can fit in a buffer.
*
* The biggest foreseeable buffer size requirement right now comes from
* the Bluetooth 4.2 SMP MTU which is 65. This then become 65 + 4 (L2CAP
* header) + 4 (ACL header) + 1 (H4 header) = 74. This also covers the
* biggest HCI commands and events which are a bit under the 70 byte
* mark.
*/
#define BT_BUF_MAX_DATA 74

View file

@ -62,10 +62,9 @@ struct bt_l2cap {
static struct bt_l2cap bt_l2cap_pool[CONFIG_BLUETOOTH_MAX_CONN];
#define BT_BUF_ACL_OUT_MAX 7
static struct nano_fifo avail_acl_out;
static NET_BUF_POOL(acl_out_pool, BT_BUF_ACL_OUT_MAX, BT_BUF_MAX_DATA,
&avail_acl_out, NULL, 0);
static NET_BUF_POOL(acl_out_pool, CONFIG_BLUETOOTH_ACL_OUT_COUNT,
CONFIG_BLUETOOTH_ACL_OUT_SIZE, &avail_acl_out, NULL, 0);
static struct bt_l2cap *l2cap_chan_get(struct bt_conn *conn)
{