Bluetooth: ATT: Remove BT_ATT_TX_MAX

ATT channels do support queueing buffer so it no longer need to block
waiting the tx_sem besides the buffer allocation already serves the
same purpose as the application will not be able to have more requests
than there are buffers available.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2020-10-05 11:41:06 -07:00 committed by Anas Nashif
commit 8df6124deb
3 changed files with 3 additions and 45 deletions

View file

@ -24,16 +24,6 @@ config BT_ATT_PREPARE_COUNT
Number of buffers available for ATT prepare write, setting
this to 0 disables GATT long/reliable writes.
config BT_ATT_TX_MAX
int "Maximum number of queued outgoing ATT PDUs"
default BT_L2CAP_TX_BUF_COUNT
range 1 BT_L2CAP_TX_BUF_COUNT
help
Number of ATT PDUs that can be at a single moment queued for
transmission. If the application tries to send more than this
amount the calls will block until an existing queued PDU gets
sent.
config BT_EATT
bool "Enhanced ATT Bearers support [EXPERIMENTAL]"
depends on BT_L2CAP_ECRED

View file

@ -66,7 +66,7 @@ NET_BUF_POOL_DEFINE(prep_pool, CONFIG_BT_ATT_PREPARE_COUNT, BT_ATT_MTU,
#endif /* CONFIG_BT_ATT_PREPARE_COUNT */
K_MEM_SLAB_DEFINE(req_slab, sizeof(struct bt_att_req),
CONFIG_BT_ATT_TX_MAX, __alignof__(struct bt_att_req));
CONFIG_BT_L2CAP_TX_BUF_COUNT, __alignof__(struct bt_att_req));
enum {
ATT_PENDING_RSP,
@ -88,7 +88,6 @@ struct bt_att_chan {
struct bt_att_req *req;
struct k_fifo tx_queue;
struct k_delayed_work timeout_work;
struct k_sem tx_sem;
void (*sent)(struct bt_att_chan *chan);
sys_snode_t node;
};
@ -315,12 +314,7 @@ static void bt_att_sent(struct bt_l2cap_chan *ch)
}
/* Process global queue */
err = process_queue(chan, &att->tx_queue);
if (!err) {
return;
}
k_sem_give(&chan->tx_sem);
(void)process_queue(chan, &att->tx_queue);
}
static void chan_cfm_sent(struct bt_att_chan *chan)
@ -464,13 +458,6 @@ static int bt_att_chan_send(struct bt_att_chan *chan, struct net_buf *buf,
BT_DBG("chan %p flags %u code 0x%02x", chan, atomic_get(chan->flags),
hdr->code);
/* Don't use tx_sem if caller has set it own callback */
if (!cb) {
if (k_sem_take(&chan->tx_sem, K_NO_WAIT) < 0) {
return -EAGAIN;
}
}
return chan_send(chan, buf, cb);
}
@ -565,8 +552,6 @@ static uint8_t att_mtu_req(struct bt_att_chan *chan, struct net_buf *buf)
static int bt_att_chan_req_send(struct bt_att_chan *chan,
struct bt_att_req *req)
{
int err;
__ASSERT_NO_MSG(chan);
__ASSERT_NO_MSG(req);
__ASSERT_NO_MSG(req->func);
@ -574,16 +559,7 @@ static int bt_att_chan_req_send(struct bt_att_chan *chan,
BT_DBG("req %p", req);
if (k_sem_take(&chan->tx_sem, K_NO_WAIT) < 0) {
return -EAGAIN;
}
err = chan_req_send(chan, req);
if (err < 0) {
k_sem_give(&chan->tx_sem);
}
return err;
return chan_req_send(chan, req);
}
static void att_process(struct bt_att *att)
@ -2567,17 +2543,11 @@ static void att_reset(struct bt_att *att)
static void att_chan_detach(struct bt_att_chan *chan)
{
struct net_buf *buf;
int i;
BT_DBG("chan %p", chan);
sys_slist_find_and_remove(&chan->att->chans, &chan->node);
/* Ensure that any waiters are woken up */
for (i = 0; i < CONFIG_BT_ATT_TX_MAX; i++) {
k_sem_give(&chan->tx_sem);
}
/* Release pending buffers */
while ((buf = net_buf_get(&chan->tx_queue, K_NO_WAIT))) {
net_buf_unref(buf);
@ -2811,7 +2781,6 @@ static struct bt_att_chan *att_chan_new(struct bt_att *att, atomic_val_t flags)
(void)memset(chan, 0, sizeof(*chan));
chan->chan.chan.ops = &ops;
k_fifo_init(&chan->tx_queue);
k_sem_init(&chan->tx_sem, CONFIG_BT_ATT_TX_MAX, CONFIG_BT_ATT_TX_MAX);
atomic_set(chan->flags, flags);
chan->att = att;

View file

@ -7,7 +7,6 @@ CONFIG_BT_SIGNING=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_ATT_TX_MAX=3
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="Test Database"
CONFIG_BT_DEVICE_APPEARANCE=833