Bluetooth: host: Use CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU

Remove dependency on CONFIG_BT_ACL_FLOW_CONTROL and use
CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU.
The ATT MTU is set from two different KConfig options depending
on if CONFIG_BT_ACL_FLOW_CONTROL is enabled, which makes it
a confusing option and hard to provide a conf file that
supports multiple board configurations.

This changes the behavior when CONFIG_BT_ACL_FLOW_CONTROL and
CONFIG_BT_BUF_RX_LEN was used to set the L2CAP RX MTU, and by
extension the ATT MTU.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-07-20 11:56:26 +02:00 committed by Carles Cufí
commit 1d66c1e491
7 changed files with 11 additions and 24 deletions

View file

@ -11,3 +11,4 @@ CONFIG_NET_CONFIG_BT_NODE=y
# raise bluetooth RX buffer settings for 6lowpan traffic
CONFIG_BT_RX_BUF_COUNT=20
CONFIG_BT_RX_BUF_LEN=128
CONFIG_BT_L2CAP_RX_MTU=120

View file

@ -14,7 +14,6 @@ config BT_L2CAP_RX_MTU
range 70 1300 if BT_EATT
range 65 1300 if BT_SMP
range 23 1300
depends on BT_HCI_ACL_FLOW_CONTROL
help
Maximum size of each incoming L2CAP PDU.

View file

@ -10,8 +10,9 @@
#define BT_ATT_DEFAULT_LE_MTU 23
#define BT_ATT_TIMEOUT K_SECONDS(30)
#if BT_L2CAP_RX_MTU < CONFIG_BT_L2CAP_TX_MTU
#define BT_ATT_MTU BT_L2CAP_RX_MTU
/* ATT MTU must be equal for RX and TX, so select the smallest value */
#if CONFIG_BT_L2CAP_RX_MTU < CONFIG_BT_L2CAP_TX_MTU
#define BT_ATT_MTU CONFIG_BT_L2CAP_RX_MTU
#else
#define BT_ATT_MTU CONFIG_BT_L2CAP_TX_MTU
#endif

View file

@ -82,7 +82,7 @@
#define BT_AVDTP_ERR_UNSUPPORTED_CONFIGURAION 0x29
#define BT_AVDTP_ERR_BAD_STATE 0x31
#define BT_AVDTP_MAX_MTU BT_L2CAP_RX_MTU
#define BT_AVDTP_MAX_MTU CONFIG_BT_L2CAP_RX_MTU
#define BT_AVDTP_MIN_SEID 0x01
#define BT_AVDTP_MAX_SEID 0x3E

View file

@ -61,10 +61,7 @@ NET_BUF_POOL_FIXED_DEFINE(disc_pool, 1,
BT_L2CAP_BUF_SIZE(CONFIG_BT_L2CAP_TX_MTU), NULL);
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
/* Size of MTU is based on the maximum amount of data the buffer can hold
* excluding ACL and driver headers.
*/
#define L2CAP_MAX_LE_MPS BT_L2CAP_RX_MTU
#define L2CAP_MAX_LE_MPS CONFIG_BT_L2CAP_RX_MTU
/* For now use MPS - SDU length to disable segmentation */
#define L2CAP_MAX_LE_MTU (L2CAP_MAX_LE_MPS - 2)
@ -777,9 +774,9 @@ static void l2cap_chan_rx_init(struct bt_l2cap_le_chan *chan)
if (!chan->rx.init_credits) {
if (chan->chan.ops->alloc_buf) {
/* Auto tune credits to receive a full packet */
chan->rx.init_credits = (chan->rx.mtu +
(L2CAP_MAX_LE_MPS - 1)) /
L2CAP_MAX_LE_MPS;
chan->rx.init_credits =
ceiling_fraction(chan->rx.mtu,
L2CAP_MAX_LE_MPS);
} else {
chan->rx.init_credits = L2CAP_LE_MAX_CREDITS;
}

View file

@ -51,11 +51,6 @@
#define L2CAP_BR_DISCONN_TIMEOUT K_SECONDS(1)
#define L2CAP_BR_CONN_TIMEOUT K_SECONDS(40)
/* 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 BT_L2CAP_RX_MTU
/*
* L2CAP extended feature mask:
* BR/EDR fixed channel support enabled
@ -733,7 +728,8 @@ static void l2cap_br_conn_req(struct bt_l2cap_br *l2cap, uint8_t ident,
atomic_set_bit(BR_CHAN(chan)->flags, L2CAP_FLAG_CONN_ACCEPTOR);
/* Disable fragmentation of l2cap rx pdu */
BR_CHAN(chan)->rx.mtu = MIN(BR_CHAN(chan)->rx.mtu, L2CAP_BR_MAX_MTU);
BR_CHAN(chan)->rx.mtu = MIN(BR_CHAN(chan)->rx.mtu,
CONFIG_BT_L2CAP_RX_MTU);
switch (l2cap_br_conn_security(chan, psm)) {
case L2CAP_CONN_SECURITY_PENDING:

View file

@ -227,13 +227,6 @@ struct bt_l2cap_ecred_reconf_rsp {
#define BT_L2CAP_SDU_HDR_LEN 2
#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
#define BT_L2CAP_RX_MTU CONFIG_BT_L2CAP_RX_MTU
#else
#define BT_L2CAP_RX_MTU (CONFIG_BT_RX_BUF_LEN - \
BT_HCI_ACL_HDR_SIZE - BT_L2CAP_HDR_SIZE)
#endif
struct bt_l2cap_fixed_chan {
uint16_t cid;
int (*accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan);