]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mac802154: Use netif flow control
authorAlan Ott <alan@signal11.us>
Wed, 3 Apr 2013 04:00:56 +0000 (04:00 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 7 Apr 2013 21:06:43 +0000 (17:06 -0400)
Use netif_stop_queue() and netif_wake_queue() to control the flow of
packets to mac802154 devices.  Since many IEEE 802.15.4 devices have no
output buffer, and since the mac802154 xmit() function is designed to
block, netif_stop_queue() is called after each packet.

Signed-off-by: Alan Ott <alan@signal11.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mac802154/tx.c

index 726487493e5ca13cd97f01fae50267980f2ce12a..3fd3e07ec599becf7c29d537724abcb421fff4c8 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/if_arp.h>
 #include <linux/crc-ccitt.h>
 
+#include <net/ieee802154_netdev.h>
 #include <net/mac802154.h>
 #include <net/wpan-phy.h>
 
@@ -44,6 +45,7 @@ struct xmit_work {
 static void mac802154_xmit_worker(struct work_struct *work)
 {
        struct xmit_work *xw = container_of(work, struct xmit_work, work);
+       struct mac802154_sub_if_data *sdata;
        int res;
 
        mutex_lock(&xw->priv->phy->pib_lock);
@@ -65,6 +67,11 @@ static void mac802154_xmit_worker(struct work_struct *work)
 out:
        mutex_unlock(&xw->priv->phy->pib_lock);
 
+       /* Restart the netif queue on each sub_if_data object. */
+       rcu_read_lock();
+       list_for_each_entry_rcu(sdata, &xw->priv->slaves, list)
+               netif_wake_queue(sdata->dev);
+       rcu_read_unlock();
 
        dev_kfree_skb(xw->skb);
 
@@ -75,6 +82,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
                         u8 page, u8 chan)
 {
        struct xmit_work *work;
+       struct mac802154_sub_if_data *sdata;
 
        if (!(priv->phy->channels_supported[page] & (1 << chan))) {
                WARN_ON(1);
@@ -102,6 +110,12 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
                return NETDEV_TX_BUSY;
        }
 
+       /* Stop the netif queue on each sub_if_data object. */
+       rcu_read_lock();
+       list_for_each_entry_rcu(sdata, &priv->slaves, list)
+               netif_stop_queue(sdata->dev);
+       rcu_read_unlock();
+
        INIT_WORK(&work->work, mac802154_xmit_worker);
        work->skb = skb;
        work->priv = priv;