Bluetooth: Kconfig: Merge headroom reserve variables into a single one

A subsequent patch will start reusing HCI command buffers for
receiving the response, so the distinction of received vs sent data
headroom would just make the code unnecessarily complex. Instead, just
merge these two variable into a single one.

Change-Id: I31d846331939f1a2270df7ed0c75112825e16493
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-02-01 12:59:11 +02:00
commit 743379c21f
10 changed files with 22 additions and 40 deletions

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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 {

View file

@ -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

View file

@ -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);

View file

@ -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 {

View file

@ -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);
}

View file

@ -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;

View file

@ -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)