Browse Source

Bluetooth: Split HCI command & event buffers to two pools

The HCI commands and events have slightly different requirements
(e.g. max sizes, or the fact that events don't need any user data) so
it makes sense to keep them separate. The total count is kept at 8 (2
+ 6) but the ACL_OUT count is modified to not exceed the event count
(to avoid inability of handling bursts of Number of Completed Packets
events). The ACL_IN count is also modified to keep these symmetric for
now.

Change-Id: Ia1915a596424425525b6df67e0ddce47a7f618f3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
pull/255/head
Johan Hedberg 10 years ago committed by Anas Nashif
parent
commit
297f4f481f
  1. 35
      net/bluetooth/Kconfig
  2. 22
      net/bluetooth/hci_core.c

35
net/bluetooth/Kconfig

@ -55,24 +55,41 @@ config BLUETOOTH_DEBUG_HCI_CORE @@ -55,24 +55,41 @@ 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
config BLUETOOTH_HCI_CMD_COUNT
int "Number of HCI command buffers"
default 2
range 2 64
help
Number of buffers available for HCI commands and events.
Number of buffers available for HCI commands.
config BLUETOOTH_HCI_SIZE
int "Size of HCI buffers"
config BLUETOOTH_HCI_CMD_SIZE
int "Size of HCI command buffers"
default 72
range 72 260
help
Maximum size of each HCI buffer.
Maximum size of each HCI command buffer.
config BLUETOOTH_HCI_EVT_COUNT
int "Number of HCI event buffers"
default 6
range 2 64
help
Number of buffers available for HCI events. This number should
ideally be at least as large as BLUETOOTH_ACL_OUT_COUNT to make
sure we've got enough buffers to handle bursts of Number of
Completed Packets HCI events.
config BLUETOOTH_HCI_EVT_SIZE
int "Size of HCI event buffers"
default 72
range 72 260
help
Maximum size of each HCI event buffer.
if BLUETOOTH_CONN
config BLUETOOTH_ACL_IN_COUNT
int "Number of incoming ACL data buffers"
default 7
default 5
range 1 16
help
Number of buffers available for incoming ACL data.
@ -88,7 +105,7 @@ config BLUETOOTH_ACL_IN_SIZE @@ -88,7 +105,7 @@ config BLUETOOTH_ACL_IN_SIZE
config BLUETOOTH_ACL_OUT_COUNT
int "Number of incoming ACL data buffers"
default 7
default 5
range 1 16
help
Number of buffers available for incoming ACL data.

22
net/bluetooth/hci_core.c

@ -74,12 +74,17 @@ struct bt_acl_data { @@ -74,12 +74,17 @@ struct bt_acl_data {
#define bt_hci(buf) ((struct bt_hci_data *)net_buf_user_data(buf))
#define bt_acl(buf) ((struct bt_acl_data *)net_buf_user_data(buf))
/* Available (free) buffers queues */
static struct nano_fifo avail_hci;
static NET_BUF_POOL(hci_pool, CONFIG_BLUETOOTH_HCI_COUNT,
CONFIG_BLUETOOTH_HCI_SIZE, &avail_hci, NULL,
/* HCI command buffers */
static struct nano_fifo avail_hci_cmd;
static NET_BUF_POOL(hci_cmd_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT,
CONFIG_BLUETOOTH_HCI_CMD_SIZE, &avail_hci_cmd, NULL,
sizeof(struct bt_hci_data));
/* HCI event buffers */
static struct nano_fifo avail_hci_evt;
static NET_BUF_POOL(hci_evt_pool, CONFIG_BLUETOOTH_HCI_EVT_COUNT,
CONFIG_BLUETOOTH_HCI_EVT_SIZE, &avail_hci_evt, NULL, 0);
#if defined(CONFIG_BLUETOOTH_CONN)
static void report_completed_packet(struct net_buf *buf)
{
@ -116,7 +121,7 @@ static NET_BUF_POOL(acl_in_pool, CONFIG_BLUETOOTH_ACL_IN_COUNT, @@ -116,7 +121,7 @@ static NET_BUF_POOL(acl_in_pool, CONFIG_BLUETOOTH_ACL_IN_COUNT,
/* Incoming buffer type lookup helper */
static enum bt_buf_type bt_type(struct net_buf *buf)
{
if (buf->free == &avail_hci) {
if (buf->free == &avail_hci_evt) {
return BT_EVT;
} else {
return BT_ACL_IN;
@ -158,7 +163,7 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len) @@ -158,7 +163,7 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len)
BT_DBG("opcode %x param_len %u\n", opcode, param_len);
buf = net_buf_get(&avail_hci, bt_dev.drv->send_reserve);
buf = net_buf_get(&avail_hci_cmd, bt_dev.drv->send_reserve);
if (!buf) {
BT_ERR("Cannot get free buffer\n");
return NULL;
@ -1595,7 +1600,8 @@ int bt_enable(bt_ready_cb_t cb) @@ -1595,7 +1600,8 @@ int bt_enable(bt_ready_cb_t cb)
}
/* Initialize the buffer pools */
net_buf_pool_init(hci_pool);
net_buf_pool_init(hci_cmd_pool);
net_buf_pool_init(hci_evt_pool);
#if defined(CONFIG_BLUETOOTH_CONN)
net_buf_pool_init(acl_in_pool);
#endif /* CONFIG_BLUETOOTH_CONN */
@ -1782,7 +1788,7 @@ int bt_stop_scanning(void) @@ -1782,7 +1788,7 @@ int bt_stop_scanning(void)
struct net_buf *bt_buf_get_evt(void)
{
return net_buf_get(&avail_hci, bt_dev.drv->recv_reserve);
return net_buf_get(&avail_hci_evt, bt_dev.drv->recv_reserve);
}
struct net_buf *bt_buf_get_acl(void)

Loading…
Cancel
Save