diff options
-rw-r--r-- | drivers/bluetooth/hci/Kconfig | 13 | ||||
-rw-r--r-- | drivers/bluetooth/hci/h5.c | 2 | ||||
-rw-r--r-- | include/bluetooth/buf.h | 2 | ||||
-rw-r--r-- | include/bluetooth/l2cap.h | 5 | ||||
-rw-r--r-- | samples/bluetooth/hci_uart/src/main.c | 10 | ||||
-rw-r--r-- | samples/bluetooth/hci_usb/src/main.c | 10 | ||||
-rw-r--r-- | subsys/bluetooth/host/avdtp_internal.h | 5 | ||||
-rw-r--r-- | subsys/bluetooth/host/conn.c | 2 | ||||
-rw-r--r-- | subsys/bluetooth/host/hci_core.c | 8 | ||||
-rw-r--r-- | subsys/bluetooth/host/rfcomm_internal.h | 5 |
10 files changed, 22 insertions, 40 deletions
diff --git a/drivers/bluetooth/hci/Kconfig b/drivers/bluetooth/hci/Kconfig index f3bbed4e5..3a52c5e0e 100644 --- a/drivers/bluetooth/hci/Kconfig +++ b/drivers/bluetooth/hci/Kconfig @@ -86,9 +86,7 @@ config BLUETOOTH_SPI_DEV_NAME # Headroom that the driver needs for sending and receiving buffers. # Add a new 'default' entry for each new driver. - -# Needed headroom for outgoing buffers (to controller) -config BLUETOOTH_HCI_SEND_RESERVE +config BLUETOOTH_HCI_RESERVE int # Even if no driver is selected the following default is still # needed e.g. for unit tests. @@ -97,15 +95,6 @@ config BLUETOOTH_HCI_SEND_RESERVE default 1 if BLUETOOTH_H5 default 1 if BLUETOOTH_SPI -# Needed headroom for incoming buffers (from controller) -config BLUETOOTH_HCI_RECV_RESERVE - int - # Even if no driver is selected the following default is still - # needed e.g. for unit tests. - default 0 - default 0 if BLUETOOTH_H4 - default 0 if BLUETOOTH_H5 - if BLUETOOTH_SPI config BLUETOOTH_SPI_BLUENRG diff --git a/drivers/bluetooth/hci/h5.c b/drivers/bluetooth/hci/h5.c index b234000dc..ce3720974 100644 --- a/drivers/bluetooth/hci/h5.c +++ b/drivers/bluetooth/hci/h5.c @@ -118,7 +118,7 @@ static const uint8_t conf_rsp[] = { 0x04, 0x7b }; /* H5 signal buffers pool */ #define CONFIG_BLUETOOTH_MAX_SIG_LEN 3 #define CONFIG_BLUETOOTH_SIGNAL_COUNT 2 -#define SIG_BUF_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ +#define SIG_BUF_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + \ CONFIG_BLUETOOTH_MAX_SIG_LEN) NET_BUF_POOL_DEFINE(h5_pool, CONFIG_BLUETOOTH_SIGNAL_COUNT, SIG_BUF_SIZE, 0, NULL); diff --git a/include/bluetooth/buf.h b/include/bluetooth/buf.h index a9ab7997f..ea1b32d03 100644 --- a/include/bluetooth/buf.h +++ b/include/bluetooth/buf.h @@ -38,7 +38,7 @@ enum bt_buf_type { #define BT_BUF_USER_DATA_MIN 4 /** Data size neeed for HCI RX buffers */ -#define BT_BUF_RX_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ +#define BT_BUF_RX_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + \ CONFIG_BLUETOOTH_RX_BUF_LEN) /** Allocate a buffer for incoming data diff --git a/include/bluetooth/l2cap.h b/include/bluetooth/l2cap.h index 422ba723d..23bfc284e 100644 --- a/include/bluetooth/l2cap.h +++ b/include/bluetooth/l2cap.h @@ -38,7 +38,7 @@ extern "C" { * * @return Needed buffer size to match the requested L2CAP MTU. */ -#define BT_L2CAP_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ +#define BT_L2CAP_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_RESERVE + \ BT_HCI_ACL_HDR_SIZE + BT_L2CAP_HDR_SIZE + \ (mtu)) @@ -206,8 +206,7 @@ struct bt_l2cap_chan_ops { /** @def BT_L2CAP_CHAN_SEND_RESERVE * @brief Headroom needed for outgoing buffers */ -#define BT_L2CAP_CHAN_SEND_RESERVE (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + 4 + 4 \ - + 2) +#define BT_L2CAP_CHAN_SEND_RESERVE (CONFIG_BLUETOOTH_HCI_RESERVE + 4 + 4 + 2) /** @brief L2CAP Server structure. */ struct bt_l2cap_server { diff --git a/samples/bluetooth/hci_uart/src/main.c b/samples/bluetooth/hci_uart/src/main.c index 39fdafd13..3924fd42d 100644 --- a/samples/bluetooth/hci_uart/src/main.c +++ b/samples/bluetooth/hci_uart/src/main.c @@ -22,6 +22,7 @@ #include <net/buf.h> #include <bluetooth/bluetooth.h> +#include <bluetooth/l2cap.h> #include <bluetooth/log.h> #include <bluetooth/hci.h> #include <bluetooth/buf.h> @@ -31,8 +32,7 @@ static struct device *hci_uart_dev; static BT_STACK_NOINIT(tx_thread_stack, CONFIG_BLUETOOTH_HCI_TX_STACK_SIZE); /* HCI command buffers */ -#define CMD_BUF_SIZE (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ - sizeof(struct bt_hci_cmd_hdr) + \ +#define CMD_BUF_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + BT_HCI_CMD_HDR_SIZE + \ CONFIG_BLUETOOTH_MAX_CMD_LEN) NET_BUF_POOL_DEFINE(cmd_tx_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, @@ -40,10 +40,8 @@ NET_BUF_POOL_DEFINE(cmd_tx_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, #define BT_L2CAP_MTU 65 /* 64-byte public key + opcode */ /** Data size needed for ACL buffers */ -#define BT_BUF_ACL_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ - sizeof(struct bt_hci_acl_hdr) + \ - 4 /* L2CAP header size */ + \ - BT_L2CAP_MTU) +#define BT_BUF_ACL_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + BT_HCI_ACL_HDR_SIZE + \ + BT_L2CAP_HDR_SIZE + BT_L2CAP_MTU) #if defined(CONFIG_BLUETOOTH_CONTROLLER_TX_BUFFERS) #define TX_BUF_COUNT CONFIG_BLUETOOTH_CONTROLLER_TX_BUFFERS diff --git a/samples/bluetooth/hci_usb/src/main.c b/samples/bluetooth/hci_usb/src/main.c index bea2cd2b0..1a4d51da7 100644 --- a/samples/bluetooth/hci_usb/src/main.c +++ b/samples/bluetooth/hci_usb/src/main.c @@ -15,6 +15,7 @@ #include <net/buf.h> #include <bluetooth/buf.h> #include <bluetooth/hci_raw.h> +#include <bluetooth/l2cap.h> #include "usb_device.h" #include "usb_common.h" @@ -74,8 +75,7 @@ static struct device *btusb_dev; static K_FIFO_DEFINE(rx_queue); /* HCI command buffers */ -#define CMD_BUF_SIZE (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ - sizeof(struct bt_hci_cmd_hdr) + \ +#define CMD_BUF_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + BT_HCI_CMD_HDR_SIZE + \ CONFIG_BLUETOOTH_MAX_CMD_LEN) NET_BUF_POOL_DEFINE(tx_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, @@ -83,10 +83,8 @@ NET_BUF_POOL_DEFINE(tx_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, #define BT_L2CAP_MTU 64 /** Data size needed for ACL buffers */ -#define BT_BUF_ACL_SIZE (CONFIG_BLUETOOTH_HCI_RECV_RESERVE + \ - sizeof(struct bt_hci_acl_hdr) + \ - 4 /* L2CAP header size */ + \ - BT_L2CAP_MTU) +#define BT_BUF_ACL_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + BT_HCI_ACL_HDR_SIZE + \ + BT_L2CAP_HDR_SIZE + BT_L2CAP_MTU) NET_BUF_POOL_DEFINE(acl_tx_pool, 2, BT_BUF_ACL_SIZE, sizeof(uint8_t), NULL); diff --git a/subsys/bluetooth/host/avdtp_internal.h b/subsys/bluetooth/host/avdtp_internal.h index 86ad87421..a3e40bc96 100644 --- a/subsys/bluetooth/host/avdtp_internal.h +++ b/subsys/bluetooth/host/avdtp_internal.h @@ -89,9 +89,8 @@ #define BT_AVDTP_MAX_SEID 0x3E /* Helper to calculate needed outgoing buffer size. */ -#define BT_AVDTP_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ - sizeof(struct bt_hci_acl_hdr) + \ - sizeof(struct bt_l2cap_hdr) + \ +#define BT_AVDTP_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_RESERVE + \ + BT_HCI_ACL_HDR_SIZE + BT_L2CAP_HDR_SIZE + \ BT_AVDTP_SIG_HDR_LEN + (mtu)) struct bt_avdtp_single_sig_hdr { diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 012955be6..d68e1e770 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -1587,7 +1587,7 @@ struct net_buf *bt_conn_create_pdu(struct net_buf_pool *pool, size_t reserve) buf = net_buf_alloc(pool, K_FOREVER); if (buf) { reserve += sizeof(struct bt_hci_acl_hdr) + - CONFIG_BLUETOOTH_HCI_SEND_RESERVE; + CONFIG_BLUETOOTH_HCI_RESERVE; net_buf_reserve(buf, reserve); } diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index c7381b3fd..3caa9124d 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -106,8 +106,8 @@ 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) + \ +#define CMD_BUF_SIZE (CONFIG_BLUETOOTH_HCI_RESERVE + \ + BT_HCI_CMD_HDR_SIZE + \ CONFIG_BLUETOOTH_MAX_CMD_LEN) NET_BUF_POOL_DEFINE(hci_cmd_pool, CONFIG_BLUETOOTH_HCI_CMD_COUNT, CMD_BUF_SIZE, sizeof(struct cmd_data), NULL); @@ -154,7 +154,7 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len) BT_DBG("buf %p", buf); - net_buf_reserve(buf, CONFIG_BLUETOOTH_HCI_SEND_RESERVE); + net_buf_reserve(buf, CONFIG_BLUETOOTH_HCI_RESERVE); cmd(buf)->type = BT_BUF_CMD; cmd(buf)->opcode = opcode; @@ -3975,7 +3975,7 @@ struct net_buf *bt_buf_get_rx(int32_t timeout) buf = net_buf_alloc(&hci_rx_pool, timeout); if (buf) { - net_buf_reserve(buf, CONFIG_BLUETOOTH_HCI_RECV_RESERVE); + net_buf_reserve(buf, CONFIG_BLUETOOTH_HCI_RESERVE); } return buf; diff --git a/subsys/bluetooth/host/rfcomm_internal.h b/subsys/bluetooth/host/rfcomm_internal.h index c5b9e6187..73c1dcc64 100644 --- a/subsys/bluetooth/host/rfcomm_internal.h +++ b/subsys/bluetooth/host/rfcomm_internal.h @@ -132,9 +132,8 @@ struct bt_rfcomm_rpn { * Length in rfcomm header can be two bytes depending on user data length. * One byte in the tail should be reserved for FCS. */ -#define BT_RFCOMM_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_SEND_RESERVE + \ - sizeof(struct bt_hci_acl_hdr) + \ - sizeof(struct bt_l2cap_hdr) + \ +#define BT_RFCOMM_BUF_SIZE(mtu) (CONFIG_BLUETOOTH_HCI_RESERVE + \ + BT_HCI_ACL_HDR_SIZE + BT_L2CAP_HDR_SIZE + \ sizeof(struct bt_rfcomm_hdr) + 1 + (mtu) + \ BT_RFCOMM_FCS_SIZE) |