Bluetooth: L2CAP: clarify BT_L2CAP_STATUS_OUT
Makes it clearer what that bit means: If set, the channel has capacity to send at least one PDU. If unset, the channel ran out of credits and won't be able to send anything until the peer sends credits back. Also add debug logs. Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This commit is contained in:
parent
61f834ee67
commit
79e86472c3
|
@ -120,7 +120,7 @@ typedef enum bt_l2cap_chan_state {
|
|||
|
||||
/** @brief Status of L2CAP channel. */
|
||||
typedef enum bt_l2cap_chan_status {
|
||||
/** Channel output status */
|
||||
/** Channel can send at least one PDU */
|
||||
BT_L2CAP_STATUS_OUT,
|
||||
|
||||
/** @brief Channel shutdown status
|
||||
|
|
|
@ -973,9 +973,11 @@ static void l2cap_chan_tx_give_credits(struct bt_l2cap_le_chan *chan,
|
|||
|
||||
atomic_add(&chan->tx.credits, credits);
|
||||
|
||||
if (!atomic_test_and_set_bit(chan->chan.status, BT_L2CAP_STATUS_OUT) &&
|
||||
chan->chan.ops->status) {
|
||||
chan->chan.ops->status(&chan->chan, chan->chan.status);
|
||||
if (!atomic_test_and_set_bit(chan->chan.status, BT_L2CAP_STATUS_OUT)) {
|
||||
LOG_DBG("chan %p unpaused", chan);
|
||||
if (chan->chan.ops->status) {
|
||||
chan->chan.ops->status(&chan->chan, chan->chan.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2045,11 +2047,11 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch,
|
|||
return err;
|
||||
}
|
||||
|
||||
/* Check if there is no credits left clear output status and notify its
|
||||
* change.
|
||||
*/
|
||||
/* Notify channel user that it can't send anymore on this channel. */
|
||||
if (!atomic_get(&ch->tx.credits)) {
|
||||
LOG_DBG("chan %p paused", ch);
|
||||
atomic_clear_bit(ch->chan.status, BT_L2CAP_STATUS_OUT);
|
||||
|
||||
if (ch->chan.ops->status) {
|
||||
ch->chan.ops->status(&ch->chan, ch->chan.status);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue