diff --git a/include/bluetooth/buf.h b/include/bluetooth/buf.h index c5430be5c37..c10c9049934 100644 --- a/include/bluetooth/buf.h +++ b/include/bluetooth/buf.h @@ -47,23 +47,10 @@ enum bt_buf_type { /** Minimum amount of user data size for buffers passed to the stack. */ #define BT_BUF_USER_DATA_MIN 4 -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) /** Data size neeed for HCI RX buffers */ #define BT_BUF_RX_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ sizeof(struct bt_hci_acl_hdr) + \ CONFIG_BLUETOOTH_RX_BUF_LEN) -#else -/** Data size neeed for HCI event buffers */ -#define BT_BUF_EVT_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ - sizeof(struct bt_hci_evt_hdr) + \ - CONFIG_BLUETOOTH_MAX_EVT_LEN) - -/** Data size needed for incoming ACL buffers */ -#define BT_BUF_ACL_IN_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ - sizeof(struct bt_hci_acl_hdr) + \ - 4 /* L2CAP header size */ + \ - CONFIG_BLUETOOTH_L2CAP_IN_MTU) -#endif /** Allocate a buffer for an HCI event * diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index b0593d96b77..b32789162a5 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -52,11 +52,6 @@ config BLUETOOTH_RECV_IS_RX_THREAD # thing to make a call to bt_rx_thread_ready(). bool -config BLUETOOTH_COMBINED_RX_BUF - # Virtual option usually set by the controller to request a - # combined pool for incoming buffers. - bool - config BLUETOOTH_HCI_CMD_COUNT int "Number of HCI command buffers" default 2 @@ -73,40 +68,10 @@ config BLUETOOTH_MAX_CMD_LEN help Maximum length of each HCI command. -if !BLUETOOTH_COMBINED_RX_BUF -config BLUETOOTH_HOST_FLOW_CONTROL - # Virtual option usually set by the HCI driver to state that ACL - # host flow control is needed. - bool - depends on BLUETOOTH_CONN - -config BLUETOOTH_HCI_EVT_COUNT - int "Number of HCI event buffers" - default 4 - default 8 if BLUETOOTH_CONN - range 2 64 - help - Number of buffers available for HCI events. This number should - ideally be at least as large as the available outgoing buffers - to make sure we've got enough buffers to handle bursts of - Number of Completed Packets HCI events. - -config BLUETOOTH_MAX_EVT_LEN - int "Maximum supported HCI event length" - default 68 - default 255 if BLUETOOTH_BREDR - range 68 255 - help - 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. -endif # !BLUETOOTH_COMBINED_RX_BUF - -if BLUETOOTH_COMBINED_RX_BUF config BLUETOOTH_RX_BUF_COUNT int "Number of HCI RX buffers" - default 1 + default 10 + default 1 if BLUETOOTH_RECV_IS_RX_THREAD range 1 255 help Number of buffers available for incoming ACL packets or HCI events @@ -119,7 +84,6 @@ config BLUETOOTH_RX_BUF_LEN range 70 2000 help Maximum data size for each HCI RX buffer. -endif # BLUETOOTH_COMBINED_RX_BUF config BLUETOOTH_UART_TO_HOST_DEV_NAME string "Device Name of UART Device to an external Bluetooth Host" @@ -130,26 +94,6 @@ config BLUETOOTH_UART_TO_HOST_DEV_NAME to connect to an external Bluetooth Host when Zephyr is acting as a Bluetooth Controller. -if !BLUETOOTH_COMBINED_RX_BUF && (BLUETOOTH_CONN || BLUETOOTH_HCI_RAW) -config BLUETOOTH_ACL_IN_COUNT - int "Number of incoming ACL data buffers" - default 6 - default BLUETOOTH_CONTROLLER_RX_BUFFERS if BLUETOOTH_CONTROLLER - range 2 64 - help - Number of buffers available for incoming ACL data. - -config BLUETOOTH_L2CAP_IN_MTU - int "Maximum supported L2CAP MTU for incoming data" - default 23 - default 65 if BLUETOOTH_SMP - default 200 if BLUETOOTH_BREDR - range 23 1300 - range 65 1300 if BLUETOOTH_SMP - help - Maximum size of each incoming L2CAP PDU. -endif # !BLUETOOTH_COMBINED_RX_BUF && (BLUETOOTH_CONN || BLUETOOTH_HCI_RAW) - if BLUETOOTH_HCI_HOST config BLUETOOTH_INTERNAL_STORAGE bool "Use an internal persistent storage handler" @@ -193,11 +137,10 @@ config BLUETOOTH_ATT_MTU default 23 default 50 if BLUETOOTH_SMP # BLUETOOTH_L2CAP_IN_MTU is big enough # for two complete ACL packets - range 23 BLUETOOTH_L2CAP_IN_MTU if !BLUETOOTH_COMBINED_RX_BUF - range 23 BLUETOOTH_RX_BUF_LEN if BLUETOOTH_COMBINED_RX_BUF + range 23 BLUETOOTH_RX_BUF_LEN help The MTU for the ATT channel. The minimum and default is 23, - whereas the maximum is limited by CONFIG_BLUETOOTH_L2CAP_IN_MTU. + whereas the maximum is limited by CONFIG_BLUETOOTH_RX_BUF_LEN. config BLUETOOTH_ATT_PREPARE_COUNT int "Number of ATT prepare write buffers" @@ -498,11 +441,9 @@ config BLUETOOTH_RFCOMM config BLUETOOTH_RFCOMM_L2CAP_MTU int "L2CAP MTU for RFCOMM frames" - default BLUETOOTH_L2CAP_IN_MTU if !BLUETOOTH_COMBINED_RX_BUF - default BLUETOOTH_RX_BUF_LEN if BLUETOOTH_COMBINED_RX_BUF + default BLUETOOTH_RX_BUF_LEN depends on BLUETOOTH_RFCOMM - range BLUETOOTH_L2CAP_IN_MTU 32767 if !BLUETOOTH_COMBINED_RX_BUF - range BLUETOOTH_RX_BUF_LEN 32767 if BLUETOOTH_COMBINED_RX_BUF + range BLUETOOTH_RX_BUF_LEN 32767 help Maximum size of L2CAP PDU for RFCOMM frames. diff --git a/subsys/bluetooth/host/avdtp_internal.h b/subsys/bluetooth/host/avdtp_internal.h index c967aff67be..cfccf3dc357 100644 --- a/subsys/bluetooth/host/avdtp_internal.h +++ b/subsys/bluetooth/host/avdtp_internal.h @@ -97,7 +97,7 @@ #define BT_AVDTP_ERR_BAD_STATE 0x31 #define BT_AVDTP_MIN_MTU 48 -#define BT_AVDTP_MAX_MTU CONFIG_BLUETOOTH_L2CAP_IN_MTU +#define BT_AVDTP_MAX_MTU CONFIG_BLUETOOTH_RX_BUF_LEN #define BT_AVDTP_MIN_SEID 0x01 #define BT_AVDTP_MAX_SEID 0x3E diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index c00743e51ed..22d8abd1f06 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -131,14 +131,8 @@ struct acl_data { NET_BUF_POOL_DEFINE(hci_cmd_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, sizeof(struct cmd_data), NULL); -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) NET_BUF_POOL_DEFINE(hci_rx_pool, CONFIG_BLUETOOTH_RX_BUF_COUNT, BT_BUF_RX_SIZE, BT_BUF_USER_DATA_MIN, NULL); -#else -/* HCI event buffers */ -NET_BUF_POOL_DEFINE(hci_evt_pool, CONFIG_BLUETOOTH_HCI_EVT_COUNT, - BT_BUF_EVT_SIZE, BT_BUF_USER_DATA_MIN, NULL); -#endif /* * This priority pool is to handle HCI events that must not be dropped @@ -164,50 +158,6 @@ NET_BUF_POOL_DEFINE(hci_evt_prio_pool, 1, PRIO_EVT_SIZE, static struct tc_hmac_prng_struct prng; -#if defined(CONFIG_BLUETOOTH_HOST_FLOW_CONTROL) -static void report_completed_packet(struct net_buf *buf) -{ - - struct bt_hci_cp_host_num_completed_packets *cp; - uint16_t handle = acl(buf)->handle; - struct bt_hci_handle_count *hc; - - net_buf_destroy(buf); - - /* Do nothing if controller to host flow control is not supported */ - if (!(bt_dev.supported_commands[10] & 0x20)) { - return; - } - - BT_DBG("Reporting completed packet for handle %u", handle); - - buf = bt_hci_cmd_create(BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS, - sizeof(*cp) + sizeof(*hc)); - if (!buf) { - BT_ERR("Unable to allocate new HCI command"); - return; - } - - cp = net_buf_add(buf, sizeof(*cp)); - cp->num_handles = sys_cpu_to_le16(1); - - hc = net_buf_add(buf, sizeof(*hc)); - hc->handle = sys_cpu_to_le16(handle); - hc->count = sys_cpu_to_le16(1); - - bt_hci_cmd_send(BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS, buf); -} - -NET_BUF_POOL_DEFINE(acl_in_pool, CONFIG_BLUETOOTH_ACL_IN_COUNT, - BT_BUF_ACL_IN_SIZE, sizeof(struct acl_data), - report_completed_packet); -#elif !defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) && \ - defined(CONFIG_BLUETOOTH_CONN) -NET_BUF_POOL_DEFINE(acl_in_pool, CONFIG_BLUETOOTH_ACL_IN_COUNT, - BT_BUF_ACL_IN_SIZE, sizeof(struct acl_data), - NULL); -#endif - #if defined(CONFIG_BLUETOOTH_DEBUG) const char *bt_addr_str(const bt_addr_t *addr) { @@ -1039,46 +989,6 @@ failed: } #endif /* CONFIG_BLUETOOTH_CONN */ -#if defined(CONFIG_BLUETOOTH_HOST_FLOW_CONTROL) -static int set_flow_control(void) -{ - struct bt_hci_cp_host_buffer_size *hbs; - struct net_buf *buf; - int err; - - /* Check if host flow control is actually supported */ - if (!(bt_dev.supported_commands[10] & 0x20)) { - BT_WARN("Controller to host flow control not supported"); - return 0; - } - - buf = bt_hci_cmd_create(BT_HCI_OP_HOST_BUFFER_SIZE, - sizeof(*hbs)); - if (!buf) { - return -ENOBUFS; - } - - hbs = net_buf_add(buf, sizeof(*hbs)); - memset(hbs, 0, sizeof(*hbs)); - hbs->acl_mtu = sys_cpu_to_le16(CONFIG_BLUETOOTH_L2CAP_IN_MTU + - sizeof(struct bt_l2cap_hdr)); - hbs->acl_pkts = sys_cpu_to_le16(CONFIG_BLUETOOTH_ACL_IN_COUNT); - - err = bt_hci_cmd_send_sync(BT_HCI_OP_HOST_BUFFER_SIZE, buf, NULL); - if (err) { - return err; - } - - buf = bt_hci_cmd_create(BT_HCI_OP_SET_CTL_TO_HOST_FLOW, 1); - if (!buf) { - return -ENOBUFS; - } - - net_buf_add_u8(buf, BT_HCI_CTL_TO_HOST_FLOW_ENABLE); - return bt_hci_cmd_send_sync(BT_HCI_OP_SET_CTL_TO_HOST_FLOW, buf, NULL); -} -#endif /* CONFIG_BLUETOOTH_HOST_FLOW_CONTROL */ - #if defined(CONFIG_BLUETOOTH_BREDR) static void reset_pairing(struct bt_conn *conn) { @@ -3021,13 +2931,6 @@ static int common_init(void) read_supported_commands_complete(rsp); net_buf_unref(rsp); -#if defined(CONFIG_BLUETOOTH_HOST_FLOW_CONTROL) - err = set_flow_control(); - if (err) { - return err; - } -#endif /* CONFIG_BLUETOOTH_CONN */ - return 0; } @@ -4083,11 +3986,7 @@ struct net_buf *bt_buf_get_evt(uint8_t opcode, int32_t timeout) buf = net_buf_alloc(&hci_evt_prio_pool, timeout); break; default: -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) buf = net_buf_alloc(&hci_rx_pool, K_NO_WAIT); -#else - buf = net_buf_alloc(&hci_evt_pool, K_NO_WAIT); -#endif if (!buf && opcode == 0x00) { buf = net_buf_alloc(&hci_evt_prio_pool, timeout); } @@ -4107,11 +4006,7 @@ struct net_buf *bt_buf_get_acl(int32_t timeout) #if defined(CONFIG_BLUETOOTH_CONN) struct net_buf *buf; -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) buf = net_buf_alloc(&hci_rx_pool, timeout); -#else - buf = net_buf_alloc(&acl_in_pool, timeout); -#endif if (buf) { net_buf_reserve(buf, CONFIG_BLUETOOTH_HCI_RECV_RESERVE); bt_buf_set_type(buf, BT_BUF_ACL_IN); diff --git a/subsys/bluetooth/host/hci_raw.c b/subsys/bluetooth/host/hci_raw.c index e1d3fccc280..3fce7d5756b 100644 --- a/subsys/bluetooth/host/hci_raw.c +++ b/subsys/bluetooth/host/hci_raw.c @@ -29,18 +29,8 @@ static struct k_fifo *raw_rx; -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) NET_BUF_POOL_DEFINE(hci_rx_pool, CONFIG_BLUETOOTH_RX_BUF_COUNT, BT_BUF_RX_SIZE, BT_BUF_USER_DATA_MIN, NULL); -#else -/* ACL incoming buffers */ -NET_BUF_POOL_DEFINE(acl_in_pool, CONFIG_BLUETOOTH_ACL_IN_COUNT, - BT_BUF_ACL_IN_SIZE, sizeof(uint8_t), NULL); - -/* HCI event buffers */ -NET_BUF_POOL_DEFINE(hci_evt_pool, CONFIG_BLUETOOTH_HCI_EVT_COUNT, - BT_BUF_EVT_SIZE, sizeof(uint8_t), NULL); -#endif struct bt_dev_raw bt_dev; @@ -73,11 +63,7 @@ struct net_buf *bt_buf_get_evt(uint8_t opcode, int timeout) { struct net_buf *buf; -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) buf = net_buf_alloc(&hci_rx_pool, timeout); -#else - buf = net_buf_alloc(&hci_evt_pool, timeout); -#endif if (buf) { bt_buf_set_type(buf, BT_BUF_EVT); } @@ -89,11 +75,7 @@ struct net_buf *bt_buf_get_acl(int32_t timeout) { struct net_buf *buf; -#if defined(CONFIG_BLUETOOTH_COMBINED_RX_BUF) buf = net_buf_alloc(&hci_rx_pool, timeout); -#else - buf = net_buf_alloc(&acl_in_pool, timeout); -#endif if (buf) { bt_buf_set_type(buf, BT_BUF_ACL_IN); } diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 5789a07bca1..7cf2074d631 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -41,7 +41,7 @@ #define LE_CHAN_RTX(_w) CONTAINER_OF(_w, struct bt_l2cap_le_chan, chan.rtx_work) #define L2CAP_LE_MIN_MTU 23 -#define L2CAP_LE_MAX_CREDITS (CONFIG_BLUETOOTH_ACL_IN_COUNT - 1) +#define L2CAP_LE_MAX_CREDITS (CONFIG_BLUETOOTH_RX_BUF_COUNT - 1) #define L2CAP_LE_CREDITS_THRESHOLD (L2CAP_LE_MAX_CREDITS / 2) #define L2CAP_LE_CID_DYN_START 0x0040 @@ -58,7 +58,7 @@ /* Size of MTU is based on the maximum amount of data the buffer can hold * excluding ACL and driver headers. */ -#define BT_L2CAP_MAX_LE_MPS CONFIG_BLUETOOTH_L2CAP_IN_MTU +#define BT_L2CAP_MAX_LE_MPS CONFIG_BLUETOOTH_RX_BUF_LEN /* For now use MPS - SDU length to disable segmentation */ #define BT_L2CAP_MAX_LE_MTU (BT_L2CAP_MAX_LE_MPS - 2) diff --git a/subsys/bluetooth/host/l2cap_br.c b/subsys/bluetooth/host/l2cap_br.c index ded62dd46f8..cb969629579 100644 --- a/subsys/bluetooth/host/l2cap_br.c +++ b/subsys/bluetooth/host/l2cap_br.c @@ -68,7 +68,7 @@ /* Size of MTU is based on the maximum amount of data the buffer can hold * excluding ACL and driver headers. */ -#define L2CAP_BR_MAX_MTU CONFIG_BLUETOOTH_L2CAP_IN_MTU +#define L2CAP_BR_MAX_MTU CONFIG_BLUETOOTH_RX_BUF_LEN /* * L2CAP extended feature mask: diff --git a/subsys/bluetooth/host/rfcomm.c b/subsys/bluetooth/host/rfcomm.c index 1d9c42c2a01..385df38847a 100644 --- a/subsys/bluetooth/host/rfcomm.c +++ b/subsys/bluetooth/host/rfcomm.c @@ -48,7 +48,7 @@ #define RFCOMM_MIN_MTU BT_RFCOMM_SIG_MIN_MTU #define RFCOMM_DEFAULT_MTU 127 -#define RFCOMM_MAX_CREDITS (CONFIG_BLUETOOTH_ACL_IN_COUNT - 1) +#define RFCOMM_MAX_CREDITS (CONFIG_BLUETOOTH_RX_BUF_COUNT - 1) #define RFCOMM_CREDITS_THRESHOLD (RFCOMM_MAX_CREDITS / 2) #define RFCOMM_DEFAULT_CREDIT RFCOMM_MAX_CREDITS