Skip to contentSkip to conversation

6lowpan: Don't set IFF_NO_QUEUE

PATCH In review Luiz Augusto von Dentz 3 participants 13 messages Apr 11, 2017 – Apr 12, 2017

Subsystems (5)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/6 6lowpan: Don't set IFF_NO_QUEUE

From: Luiz Augusto von Dentz <[email protected]>

There is no point in setting IFF_NO_QUEUE should already have taken care of setting it if tx_queue_len is not set, in fact this may actually disable queue for interfaces that require it and do set tx_queue_len.

---
 net/6lowpan/core.c | 1 -
 1 file changed, 1 deletion(-)
net/6lowpan/core.c +0 -1
index 5f9909a..40d3d72 100644
@@ -35,7 +35,6 @@ int lowpan_register_netdevice(struct net_device *dev,
 
 	dev->type = ARPHRD_6LOWPAN;
 	dev->mtu = IPV6_MIN_MTU;
-	dev->priv_flags |= IFF_NO_QUEUE;
 
 	lowpan_dev(dev)->lltype = lltype;
 
Signature · 1 line
2.9.3
author maintainer
#1 lore raw

PATCH 2/6 Bluetooth: 6lowpan: Don't drop packets when run out of credits

From: Luiz Augusto von Dentz <[email protected]>

Since l2cap_chan_send will now queue the packets there is no point in checking the credits anymore.

---
 net/bluetooth/6lowpan.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
net/bluetooth/6lowpan.c +2 -9
index 5b91e85..22bd936 100644
@@ -478,15 +478,8 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
 		return 0;
 	}
 
-	if (!err)
-		err = (!chan->tx_credits ? -EAGAIN : 0);
-
-	if (err < 0) {
-		if (err == -EAGAIN)
-			netdev->stats.tx_dropped++;
-		else
-			netdev->stats.tx_errors++;
-	}
+	if (err < 0)
+		netdev->stats.tx_errors++;
 
 	return err;
 }
Signature · 1 line
2.9.3
Acked-by on v1 2/6
#2 lore raw

Re: [PATCH 2/6] Bluetooth: 6lowpan: Don't drop packets when run out of credits

Hi Luiz,

Quoted 30 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Since l2cap_chan_send will now queue the packets there is no point in checking the credits anymore.

---
 net/bluetooth/6lowpan.c | 11 ++---------

 1 file changed, 2 insertions(+), 9 deletions(-)
net/bluetooth/6lowpan.c +0 -0
index 5b91e85..22bd936 100644
@@ -478,15 +478,8 @@ static int send_pkt(struct l2cap_chan *chan,
 struct sk_buff *skb,
  		return 0;
  	}

net/bluetooth/6lowpan.c +2 -9
-	if (!err)
-		err = (!chan->tx_credits ? -EAGAIN : 0);
-
-	if (err < 0) {
-		if (err == -EAGAIN)
-			netdev->stats.tx_dropped++;
-		else
-			netdev->stats.tx_errors++;
-	}
+	if (err < 0)
+		netdev->stats.tx_errors++;
Quoted 3 lines


  return err;
 }

Cheers,
Jukka

author maintainer
#3 lore raw

PATCH 3/6 Bluetooth: 6lowpan: Use netif APIs to flow control

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Rely on netif_wake_queue and netif_stop_queue to flow control when transmit resources are unavailable.

---
 net/bluetooth/6lowpan.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
net/bluetooth/6lowpan.c +16 -0
index 22bd936..dc7fda3 100644
@@ -867,12 +867,28 @@ static struct sk_buff *chan_alloc_skb_cb(struct l2cap_chan *chan,
 
 static void chan_suspend_cb(struct l2cap_chan *chan)
 {
+	struct lowpan_btle_dev *dev;
+
 	BT_DBG("chan %p suspend", chan);
+
+	dev = lookup_dev(chan->conn);
+	if (!dev || !dev->netdev)
+		return;
+
+	netif_stop_queue(dev->netdev);
 }
 
 static void chan_resume_cb(struct l2cap_chan *chan)
 {
+	struct lowpan_btle_dev *dev;
+
 	BT_DBG("chan %p resume", chan);
+
+	dev = lookup_dev(chan->conn);
+	if (!dev || !dev->netdev)
+		return;
+
+	netif_wake_queue(dev->netdev);
 }
 
 static long chan_get_sndtimeo_cb(struct l2cap_chan *chan)
Signature · 1 line
2.9.3
Acked-by on v1 3/6
#4 lore raw

Re: [PATCH 3/6] Bluetooth: 6lowpan: Use netif APIs to flow control

Hi Luiz,

Quoted 41 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Rely on netif_wake_queue and netif_stop_queue to flow control when transmit resources are unavailable.

---
 net/bluetooth/6lowpan.c | 16 ++++++++++++++++

 1 file changed, 16 insertions(+)
net/bluetooth/6lowpan.c +0 -0
index 22bd936..dc7fda3 100644
@@ -867,12 +867,28 @@ static struct sk_buff *chan_alloc_skb_cb(struct
 l2cap_chan *chan,


 static void chan_suspend_cb(struct l2cap_chan *chan) {

net/bluetooth/6lowpan.c +2 -0
+	struct lowpan_btle_dev *dev;
+

  BT_DBG("chan %p suspend", chan);

net/bluetooth/6lowpan.c +6 -0
+
+	dev = lookup_dev(chan->conn);
+	if (!dev || !dev->netdev)
+		return;
+
+	netif_stop_queue(dev->netdev);

 }

 static void chan_resume_cb(struct l2cap_chan *chan) {

net/bluetooth/6lowpan.c +2 -0
+	struct lowpan_btle_dev *dev;
+

  BT_DBG("chan %p resume", chan);

net/bluetooth/6lowpan.c +6 -0
+
+	dev = lookup_dev(chan->conn);
+	if (!dev || !dev->netdev)
+		return;
+
+	netif_wake_queue(dev->netdev);
Quoted 3 lines

 }

 static long chan_get_sndtimeo_cb(struct l2cap_chan *chan)

Cheers,
Jukka

author maintainer
#5 lore raw

PATCH 4/6 Bluetooth: L2CAP: Add l2cap_le_flowctl_send

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

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

---
 net/bluetooth/l2cap_core.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)
net/bluetooth/l2cap_core.c +19 -8
index 3a202b0..f88ac995 100644
@@ -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);
Signature · 1 line
2.9.3
Acked-by on v1 4/6
#6 lore raw

Re: [PATCH 4/6] Bluetooth: L2CAP: Add l2cap_le_flowctl_send

Hi Luiz,

Quoted 68 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

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

---
 net/bluetooth/l2cap_core.c | 27 +++++++++++++++++++--------

 1 file changed, 19 insertions(+), 8 deletions(-)
net/bluetooth/l2cap_core.c +0 -0
index 3a202b0..f88ac995 100644
@@ -2425,6 +2425,22 @@ static int l2cap_segment_le_sdu(struct
 l2cap_chan *chan,
  	return 0;
  }

net/bluetooth/l2cap_core.c +13 -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-
Quoted 1 line

tx_credits,

net/bluetooth/l2cap_core.c +3 -0
+	       skb_queue_len(&chan->tx_q));
+}
+

 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
 {
  struct sk_buff *skb;

net/bluetooth/l2cap_core.c +0 -0
@@ -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);

net/bluetooth/l2cap_core.c +0 -1
-		while (chan->tx_credits && !skb_queue_empty(&chan-
Quoted 1 line

tx_q)) {

net/bluetooth/l2cap_core.c +0 -1
-			l2cap_do_send(chan, skb_dequeue(&chan-
Quoted 1 line

tx_q));

net/bluetooth/l2cap_core.c +1 -2
-			chan->tx_credits--;
-		}
+		l2cap_le_flowctl_send(chan);


  if (!chan->tx_credits)
  chan->ops->suspend(chan);

net/bluetooth/l2cap_core.c +0 -0
@@ -5567,10 +5580,8 @@ static inline int l2cap_le_credits(struct
 l2cap_conn *conn,


  chan->tx_credits += credits;

net/bluetooth/l2cap_core.c +2 -4
-	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);
Quoted 3 lines


  if (chan->tx_credits)
  chan->ops->resume(chan);

Cheers,
Jukka

author maintainer
#7 lore raw

PATCH 5/6 Bluetooth: 6lowpan: Set tx_queue_len to DEFAULT_TX_QUEUE_LEN

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Make netdev queue packets if we run out of credits.

---
 net/bluetooth/6lowpan.c | 2 ++
 1 file changed, 2 insertions(+)
net/bluetooth/6lowpan.c +2 -0
index dc7fda3..a4deba6 100644
@@ -20,6 +20,7 @@
 #include <net/ipv6.h>
 #include <net/ip6_route.h>
 #include <net/addrconf.h>
+#include <net/pkt_sched.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -594,6 +595,7 @@ static void netdev_setup(struct net_device *dev)
 	dev->flags		= IFF_RUNNING | IFF_POINTOPOINT |
 				  IFF_MULTICAST;
 	dev->watchdog_timeo	= 0;
+	dev->tx_queue_len	= DEFAULT_TX_QUEUE_LEN;
 
 	dev->netdev_ops		= &netdev_ops;
 	dev->header_ops		= &header_ops;
Signature · 1 line
2.9.3
Acked-by on v1 5/6
#8 lore raw

Re: [PATCH 5/6] Bluetooth: 6lowpan: Set tx_queue_len to DEFAULT_TX_QUEUE_LEN

Hi Luiz,

Quoted 26 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Make netdev queue packets if we run out of credits.

---
 net/bluetooth/6lowpan.c | 2 ++

 1 file changed, 2 insertions(+)
net/bluetooth/6lowpan.c +1 -0
index dc7fda3..a4deba6 100644
@@ -20,6 +20,7 @@
  #include <net/ipv6.h>
  #include <net/ip6_route.h>
  #include <net/addrconf.h>
+#include <net/pkt_sched.h>


 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>

net/bluetooth/6lowpan.c +0 -0
@@ -594,6 +595,7 @@ static void netdev_setup(struct net_device *dev)

  dev->flags = IFF_RUNNING | IFF_POINTOPOINT |
    IFF_MULTICAST;
  dev->watchdog_timeo = 0;

net/bluetooth/6lowpan.c +1 -0
+	dev->tx_queue_len	= DEFAULT_TX_QUEUE_LEN;
Quoted 3 lines


  dev->netdev_ops = &netdev_ops;
  dev->header_ops = &header_ops;

Cheers,
Jukka

author maintainer
#9 lore raw

PATCH 6/6 bluetooth: Do not set IFF_POINTOPOINT

In reply to Luiz Augusto von Dentz

From: Patrik Flykt <[email protected]>

The IPv6 stack needs to send and receive Neighbor Discovery messages. Remove the IFF_POINTOPOINT flag.

---
 net/bluetooth/6lowpan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/bluetooth/6lowpan.c +1 -2
index a4deba6..6089599 100644
@@ -592,8 +592,7 @@ static void netdev_setup(struct net_device *dev)
 {
 	dev->hard_header_len	= 0;
 	dev->needed_tailroom	= 0;
-	dev->flags		= IFF_RUNNING | IFF_POINTOPOINT |
-				  IFF_MULTICAST;
+	dev->flags		= IFF_RUNNING | IFF_MULTICAST;
 	dev->watchdog_timeo	= 0;
 	dev->tx_queue_len	= DEFAULT_TX_QUEUE_LEN;
 
Signature · 1 line
2.9.3
Acked-by on v1 6/6
#10 lore raw

Re: [PATCH 6/6] bluetooth: Do not set IFF_POINTOPOINT

Quoted 24 lines · Luiz Augusto von Dentz

From: Patrik Flykt <[email protected]>

The IPv6 stack needs to send and receive Neighbor Discovery messages. Remove the IFF_POINTOPOINT flag.

---
 net/bluetooth/6lowpan.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
net/bluetooth/6lowpan.c +1 -2
index a4deba6..6089599 100644
@@ -592,8 +592,7 @@ static void netdev_setup(struct net_device *dev)
  {
  	dev->hard_header_len	= 0;
  	dev->needed_tailroom	= 0;
-	dev->flags		= IFF_RUNNING | IFF_POINTOPOINT |
-				  IFF_MULTICAST;
+	dev->flags		= IFF_RUNNING | IFF_MULTICAST;
  	dev->watchdog_timeo	= 0;
  	dev->tx_queue_len	= DEFAULT_TX_QUEUE_LEN;
Quoted 1 line

Cheers,
Jukka

Acked-by on v1 1/6
#11 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 22 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

There is no point in setting IFF_NO_QUEUE should already have taken care of setting it if tx_queue_len is not set, in fact this may actually disable queue for interfaces that require it and do set tx_queue_len.

---
 net/6lowpan/core.c | 1 -

 1 file changed, 1 deletion(-)
net/6lowpan/core.c +0 -0
index 5f9909a..40d3d72 100644
@@ -35,7 +35,6 @@ int lowpan_register_netdevice(struct net_device
 *dev,


  dev->type = ARPHRD_6LOWPAN;
  dev->mtu = IPV6_MIN_MTU;

net/6lowpan/core.c +0 -1
-	dev->priv_flags |= IFF_NO_QUEUE;
Quoted 3 lines


  lowpan_dev(dev)->lltype = lltype;

Cheers,
Jukka

maintainer
#12 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 9 lines

There is no point in setting IFF_NO_QUEUE should already have taken care of setting it if tx_queue_len is not set, in fact this may actually disable queue for interfaces that require it and do set tx_queue_len.

---
net/6lowpan/core.c | 1 -

1 file changed, 1 deletion(-)

all 6 patches have been applied to bluetooth-next tree.

Regards

Marcel