diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 604d6241476..00d72ec7259 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -62,12 +62,12 @@ config BLUETOOTH_HCI_CMD_COUNT help Number of buffers available for HCI commands. -config BLUETOOTH_HCI_CMD_SIZE - int "Size of HCI command buffers" - default 68 - range 68 260 +config BLUETOOTH_MAX_CMD_LEN + int "Maximum supported HCI command length" + default 64 + range 64 255 help - Maximum size of each HCI command buffer. + Maximum length of each HCI command. config BLUETOOTH_HCI_EVT_COUNT int "Number of HCI event buffers" @@ -79,12 +79,15 @@ config BLUETOOTH_HCI_EVT_COUNT 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 +config BLUETOOTH_MAX_EVT_LEN + int "Maximum supported HCI event length" + default 68 + range 68 255 help - Maximum size of each HCI event buffer. + Maximum size of each HCI event buffer. E.g. one big event + for LE is the Command Complete for Read Local Supported + Commands. It is a 3 byte Command Complete header + 65 byte + return parameters = 68 bytes in total. if BLUETOOTH_CONN config BLUETOOTH_ACL_IN_COUNT diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 085873a8024..e8f61eee41b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -75,15 +75,20 @@ struct acl_data { #define acl(buf) ((struct acl_data *)net_buf_user_data(buf)) /* HCI command buffers */ +#define CMD_BUF_SIZE (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ + sizeof(struct bt_hci_cmd_hdr) + \ + CONFIG_BLUETOOTH_MAX_CMD_LEN) 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 cmd_data)); +static NET_BUF_POOL(hci_cmd_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, + &avail_hci_cmd, NULL, sizeof(struct cmd_data)); /* HCI event buffers */ +#define EVT_BUF_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ + sizeof(struct bt_hci_evt_hdr) + \ + CONFIG_BLUETOOTH_MAX_EVT_LEN) 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); + CONFIG_BLUETOOTH_MAX_EVT_LEN, &avail_hci_evt, NULL, 0); #if defined(CONFIG_BLUETOOTH_CONN) static void report_completed_packet(struct net_buf *buf)