Skip to content

Commit e680dc8

Browse files
Vudentzjoerchan
authored andcommitted
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 <[email protected]>
1 parent 2797902 commit e680dc8

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

subsys/bluetooth/host/Kconfig.gatt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ config BT_ATT_PREPARE_COUNT
2424
Number of buffers available for ATT prepare write, setting
2525
this to 0 disables GATT long/reliable writes.
2626

27-
config BT_ATT_TX_MAX
28-
int "Maximum number of queued outgoing ATT PDUs"
29-
default BT_L2CAP_TX_BUF_COUNT
30-
range 1 BT_L2CAP_TX_BUF_COUNT
31-
help
32-
Number of ATT PDUs that can be at a single moment queued for
33-
transmission. If the application tries to send more than this
34-
amount the calls will block until an existing queued PDU gets
35-
sent.
36-
3727
config BT_EATT
3828
bool "Enhanced ATT Bearers support [EXPERIMENTAL]"
3929
depends on BT_L2CAP_ECRED

subsys/bluetooth/host/att.c

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ NET_BUF_POOL_DEFINE(prep_pool, CONFIG_BT_ATT_PREPARE_COUNT, BT_ATT_MTU,
6666
#endif /* CONFIG_BT_ATT_PREPARE_COUNT */
6767

6868
K_MEM_SLAB_DEFINE(req_slab, sizeof(struct bt_att_req),
69-
CONFIG_BT_ATT_TX_MAX, __alignof__(struct bt_att_req));
69+
CONFIG_BT_L2CAP_TX_BUF_COUNT, __alignof__(struct bt_att_req));
7070

7171
enum {
7272
ATT_PENDING_RSP,
@@ -88,7 +88,6 @@ struct bt_att_chan {
8888
struct bt_att_req *req;
8989
struct k_fifo tx_queue;
9090
struct k_delayed_work timeout_work;
91-
struct k_sem tx_sem;
9291
void (*sent)(struct bt_att_chan *chan);
9392
sys_snode_t node;
9493
};
@@ -315,12 +314,7 @@ static void bt_att_sent(struct bt_l2cap_chan *ch)
315314
}
316315

317316
/* Process global queue */
318-
err = process_queue(chan, &att->tx_queue);
319-
if (!err) {
320-
return;
321-
}
322-
323-
k_sem_give(&chan->tx_sem);
317+
(void)process_queue(chan, &att->tx_queue);
324318
}
325319

326320
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,
464458
BT_DBG("chan %p flags %u code 0x%02x", chan, atomic_get(chan->flags),
465459
hdr->code);
466460

467-
/* Don't use tx_sem if caller has set it own callback */
468-
if (!cb) {
469-
if (k_sem_take(&chan->tx_sem, K_NO_WAIT) < 0) {
470-
return -EAGAIN;
471-
}
472-
}
473-
474461
return chan_send(chan, buf, cb);
475462
}
476463

@@ -565,25 +552,14 @@ static uint8_t att_mtu_req(struct bt_att_chan *chan, struct net_buf *buf)
565552
static int bt_att_chan_req_send(struct bt_att_chan *chan,
566553
struct bt_att_req *req)
567554
{
568-
int err;
569-
570555
__ASSERT_NO_MSG(chan);
571556
__ASSERT_NO_MSG(req);
572557
__ASSERT_NO_MSG(req->func);
573558
__ASSERT_NO_MSG(!chan->req);
574559

575560
BT_DBG("req %p", req);
576561

577-
if (k_sem_take(&chan->tx_sem, K_NO_WAIT) < 0) {
578-
return -EAGAIN;
579-
}
580-
581-
err = chan_req_send(chan, req);
582-
if (err < 0) {
583-
k_sem_give(&chan->tx_sem);
584-
}
585-
586-
return err;
562+
return chan_req_send(chan, req);
587563
}
588564

589565
static void att_process(struct bt_att *att)
@@ -2567,17 +2543,11 @@ static void att_reset(struct bt_att *att)
25672543
static void att_chan_detach(struct bt_att_chan *chan)
25682544
{
25692545
struct net_buf *buf;
2570-
int i;
25712546

25722547
BT_DBG("chan %p", chan);
25732548

25742549
sys_slist_find_and_remove(&chan->att->chans, &chan->node);
25752550

2576-
/* Ensure that any waiters are woken up */
2577-
for (i = 0; i < CONFIG_BT_ATT_TX_MAX; i++) {
2578-
k_sem_give(&chan->tx_sem);
2579-
}
2580-
25812551
/* Release pending buffers */
25822552
while ((buf = net_buf_get(&chan->tx_queue, K_NO_WAIT))) {
25832553
net_buf_unref(buf);
@@ -2811,7 +2781,6 @@ static struct bt_att_chan *att_chan_new(struct bt_att *att, atomic_val_t flags)
28112781
(void)memset(chan, 0, sizeof(*chan));
28122782
chan->chan.chan.ops = &ops;
28132783
k_fifo_init(&chan->tx_queue);
2814-
k_sem_init(&chan->tx_sem, CONFIG_BT_ATT_TX_MAX, CONFIG_BT_ATT_TX_MAX);
28152784
atomic_set(chan->flags, flags);
28162785
chan->att = att;
28172786

tests/bluetooth/bsim_bt/edtt_ble_test_app/gatt_test_app/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ CONFIG_BT_SIGNING=y
77
CONFIG_BT_TINYCRYPT_ECC=y
88
CONFIG_BT_PERIPHERAL=y
99
CONFIG_BT_ATT_PREPARE_COUNT=2
10-
CONFIG_BT_ATT_TX_MAX=3
1110
CONFIG_BT_PRIVACY=y
1211
CONFIG_BT_DEVICE_NAME="Test Database"
1312
CONFIG_BT_DEVICE_APPEARANCE=833

0 commit comments

Comments
 (0)