From 14365080d20742ee9bd822bf9e8364395e7b10cc Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Sun, 14 May 2017 06:21:09 +0200 Subject: [PATCH] Bluetooth: l2cap: Fix initial credit calculaton for MTU < MPS When required Rx MTU is less than configured Rx MPS, the resultant initial credits was 0 which prevented any L2CAP packet to be received. Fixed by ceiling the initial credits count in the credits calculation. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/host/l2cap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 7b5c74e0c0e..b97c7069a92 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -641,7 +641,8 @@ static void l2cap_chan_rx_init(struct bt_l2cap_le_chan *chan) if (!chan->rx.init_credits) { if (chan->chan.ops->alloc_buf) { /* Auto tune credits to receive a full packet */ - chan->rx.init_credits = chan->rx.mtu / + chan->rx.init_credits = (chan->rx.mtu + + (L2CAP_MAX_LE_MPS - 1)) / L2CAP_MAX_LE_MPS; } else { chan->rx.init_credits = L2CAP_LE_MAX_CREDITS;