Skip to content

Commit 169270e

Browse files
jori-nordiccarlescufi
authored andcommitted
Bluetooth: host: downgrade select log messages
In the case of a constrained system that uses dynamic channels (ie, not much initial credits), the user's log would be flooded with those three messages. This is not really an error per se as the stack will handle it properly and reschedule the sending of the buffers as soon as more credits arrive. Thus downgrading the severity of - the l2cap messages, as they are only compiled when dynamic channels are enabled - the conn message. Reporting the error belongs in the upper layers. Signed-off-by: Jonathan Rico <[email protected]>
1 parent 6748d58 commit 169270e

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

subsys/bluetooth/host/att.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf)
281281
err = bt_l2cap_send_cb(chan->att->conn, BT_L2CAP_CID_ATT,
282282
buf, att_cb(buf), data);
283283
if (err) {
284+
if (err == -ENOBUFS) {
285+
LOG_ERR("Ran out of TX buffers or contexts.");
286+
}
284287
/* In case of an error has occurred restore the buffer state */
285288
net_buf_simple_restore(&buf->b, &state);
286289
}

subsys/bluetooth/host/conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ int bt_conn_send_cb(struct bt_conn *conn, struct net_buf *buf,
429429
if (cb) {
430430
tx = conn_tx_alloc();
431431
if (!tx) {
432-
LOG_ERR("Unable to allocate TX context");
432+
LOG_DBG("Unable to allocate TX context");
433433
return -ENOBUFS;
434434
}
435435

subsys/bluetooth/host/l2cap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch,
19731973
int len, err;
19741974

19751975
if (!test_and_dec(&ch->tx.credits)) {
1976-
LOG_WRN("No credits to transmit packet");
1976+
LOG_DBG("No credits to transmit packet");
19771977
return -EAGAIN;
19781978
}
19791979

@@ -2003,7 +2003,7 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch,
20032003
}
20042004

20052005
if (err) {
2006-
LOG_WRN("Unable to send seg %d", err);
2006+
LOG_DBG("Unable to send seg %d", err);
20072007
atomic_inc(&ch->tx.credits);
20082008

20092009
/* The host takes ownership of the reference in seg when

subsys/bluetooth/host/smp.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,13 @@ static void smp_br_timeout(struct k_work *work)
798798
static void smp_br_send(struct bt_smp_br *smp, struct net_buf *buf,
799799
bt_conn_tx_cb_t cb)
800800
{
801-
if (bt_l2cap_send_cb(smp->chan.chan.conn, BT_L2CAP_CID_BR_SMP, buf, cb, NULL)) {
801+
int err = bt_l2cap_send_cb(smp->chan.chan.conn, BT_L2CAP_CID_BR_SMP, buf, cb, NULL);
802+
803+
if (err) {
804+
if (err == -ENOBUFS) {
805+
LOG_ERR("Ran out of TX buffers or contexts.");
806+
}
807+
802808
net_buf_unref(buf);
803809
return;
804810
}
@@ -1716,7 +1722,13 @@ static void smp_timeout(struct k_work *work)
17161722
static void smp_send(struct bt_smp *smp, struct net_buf *buf,
17171723
bt_conn_tx_cb_t cb, void *user_data)
17181724
{
1719-
if (bt_l2cap_send_cb(smp->chan.chan.conn, BT_L2CAP_CID_SMP, buf, cb, NULL)) {
1725+
int err = bt_l2cap_send_cb(smp->chan.chan.conn, BT_L2CAP_CID_SMP, buf, cb, NULL);
1726+
1727+
if (err) {
1728+
if (err == -ENOBUFS) {
1729+
LOG_ERR("Ran out of TX buffers or contexts.");
1730+
}
1731+
17201732
net_buf_unref(buf);
17211733
return;
17221734
}

0 commit comments

Comments
 (0)