linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: patrik.flykt@linux.intel.com, aar@pengutronix.de,
	jukka.rissanen@linux.intel.com, linux-wpan@vger.kernel.org
Subject: [PATCH 4/6] Bluetooth: L2CAP: Add l2cap_le_flowctl_send
Date: Tue, 11 Apr 2017 22:21:01 +0300	[thread overview]
Message-ID: <20170411192103.3209-4-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20170411192103.3209-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Consolidate code sending data to LE CoC channels and adds proper
accounting of packets sent, the remaining credits and how many packets
are queued.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/l2cap_core.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 3a202b0..f88ac995 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2425,6 +2425,22 @@ static int l2cap_segment_le_sdu(struct l2cap_chan *chan,
 	return 0;
 }
 
+static void l2cap_le_flowctl_send(struct l2cap_chan *chan)
+{
+	int sent = 0;
+
+	BT_DBG("chan %p", chan);
+
+	while (chan->tx_credits && !skb_queue_empty(&chan->tx_q)) {
+		l2cap_do_send(chan, skb_dequeue(&chan->tx_q));
+		chan->tx_credits--;
+		sent++;
+	}
+
+	BT_DBG("Sent %d credits %u queued %u", sent, chan->tx_credits,
+	       skb_queue_len(&chan->tx_q));
+}
+
 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
 {
 	struct sk_buff *skb;
@@ -2472,10 +2488,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
 
 		skb_queue_splice_tail_init(&seg_queue, &chan->tx_q);
 
-		while (chan->tx_credits && !skb_queue_empty(&chan->tx_q)) {
-			l2cap_do_send(chan, skb_dequeue(&chan->tx_q));
-			chan->tx_credits--;
-		}
+		l2cap_le_flowctl_send(chan);
 
 		if (!chan->tx_credits)
 			chan->ops->suspend(chan);
@@ -5567,10 +5580,8 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,
 
 	chan->tx_credits += credits;
 
-	while (chan->tx_credits && !skb_queue_empty(&chan->tx_q)) {
-		l2cap_do_send(chan, skb_dequeue(&chan->tx_q));
-		chan->tx_credits--;
-	}
+	/* Resume sending */
+	l2cap_le_flowctl_send(chan);
 
 	if (chan->tx_credits)
 		chan->ops->resume(chan);
-- 
2.9.3


  parent reply	other threads:[~2017-04-11 19:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11 19:20 [PATCH 1/6] 6lowpan: Don't set IFF_NO_QUEUE Luiz Augusto von Dentz
2017-04-11 19:20 ` [PATCH 2/6] Bluetooth: 6lowpan: Don't drop packets when run out of credits Luiz Augusto von Dentz
2017-04-12 13:56   ` Jukka Rissanen
2017-04-11 19:21 ` [PATCH 3/6] Bluetooth: 6lowpan: Use netif APIs to flow control Luiz Augusto von Dentz
2017-04-12 13:57   ` Jukka Rissanen
2017-04-11 19:21 ` Luiz Augusto von Dentz [this message]
2017-04-12 13:57   ` [PATCH 4/6] Bluetooth: L2CAP: Add l2cap_le_flowctl_send Jukka Rissanen
2017-04-11 19:21 ` [PATCH 5/6] Bluetooth: 6lowpan: Set tx_queue_len to DEFAULT_TX_QUEUE_LEN Luiz Augusto von Dentz
2017-04-12 13:58   ` Jukka Rissanen
2017-04-11 19:21 ` [PATCH 6/6] bluetooth: Do not set IFF_POINTOPOINT Luiz Augusto von Dentz
2017-04-12 13:58   ` Jukka Rissanen
2017-04-12 13:55 ` [PATCH 1/6] 6lowpan: Don't set IFF_NO_QUEUE Jukka Rissanen
2017-04-12 19:58 ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170411192103.3209-4-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=aar@pengutronix.de \
    --cc=jukka.rissanen@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=patrik.flykt@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).