diff options
| author | Johan Hedberg <johan.hedberg@intel.com> | 2013-12-05 02:43:34 -0500 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2013-12-05 10:05:34 -0500 |
| commit | b1c325c23d75c5e27607fdcc89bc9bf80af0ba9b (patch) | |
| tree | 22a372709ad13b3d059ed3770df375b56bd5f86f /net/bluetooth | |
| parent | 1f435424ce2c93c31c3887ec67e3afb6056f18f6 (diff) | |
Bluetooth: Implement returning of LE L2CAP credits
We should return credits to the remote side whenever they fall below a
certain level (in our case under half of the initially given amount).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
| -rw-r--r-- | net/bluetooth/l2cap_core.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index fe55162947f8..4e0e2bedd457 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
| @@ -6610,6 +6610,32 @@ drop: | |||
| 6610 | return 0; | 6610 | return 0; |
| 6611 | } | 6611 | } |
| 6612 | 6612 | ||
| 6613 | static void l2cap_chan_le_send_credits(struct l2cap_chan *chan) | ||
| 6614 | { | ||
| 6615 | struct l2cap_conn *conn = chan->conn; | ||
| 6616 | struct l2cap_le_credits pkt; | ||
| 6617 | u16 return_credits; | ||
| 6618 | |||
| 6619 | /* We return more credits to the sender only after the amount of | ||
| 6620 | * credits falls below half of the initial amount. | ||
| 6621 | */ | ||
| 6622 | if (chan->rx_credits >= (L2CAP_LE_MAX_CREDITS + 1) / 2) | ||
| 6623 | return; | ||
| 6624 | |||
| 6625 | return_credits = L2CAP_LE_MAX_CREDITS - chan->rx_credits; | ||
| 6626 | |||
| 6627 | BT_DBG("chan %p returning %u credits to sender", chan, return_credits); | ||
| 6628 | |||
| 6629 | chan->rx_credits += return_credits; | ||
| 6630 | |||
| 6631 | pkt.cid = cpu_to_le16(chan->scid); | ||
| 6632 | pkt.credits = cpu_to_le16(return_credits); | ||
| 6633 | |||
| 6634 | chan->ident = l2cap_get_ident(conn); | ||
| 6635 | |||
| 6636 | l2cap_send_cmd(conn, chan->ident, L2CAP_LE_CREDITS, sizeof(pkt), &pkt); | ||
| 6637 | } | ||
| 6638 | |||
| 6613 | static void l2cap_data_channel(struct l2cap_conn *conn, u16 cid, | 6639 | static void l2cap_data_channel(struct l2cap_conn *conn, u16 cid, |
| 6614 | struct sk_buff *skb) | 6640 | struct sk_buff *skb) |
| 6615 | { | 6641 | { |
