mac802154: add netdev qeue helpers
[linux-2.6-block.git] / net / mac802154 / util.c
1 /* This program is free software; you can redistribute it and/or modify
2  * it under the terms of the GNU General Public License version 2
3  * as published by the Free Software Foundation.
4  *
5  * This program is distributed in the hope that it will be useful,
6  * but WITHOUT ANY WARRANTY; without even the implied warranty of
7  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8  * GNU General Public License for more details.
9  *
10  * Authors:
11  * Alexander Aring <aar@pengutronix.de>
12  *
13  * Based on: net/mac80211/util.c
14  */
15
16 #include "ieee802154_i.h"
17
18 void ieee802154_wake_queue(struct ieee802154_hw *hw)
19 {
20         struct ieee802154_local *local = hw_to_local(hw);
21         struct ieee802154_sub_if_data *sdata;
22
23         rcu_read_lock();
24         list_for_each_entry_rcu(sdata, &local->interfaces, list) {
25                 if (!sdata->dev)
26                         continue;
27
28                 netif_wake_queue(sdata->dev);
29         }
30         rcu_read_unlock();
31 }
32 EXPORT_SYMBOL(ieee802154_wake_queue);
33
34 void ieee802154_stop_queue(struct ieee802154_hw *hw)
35 {
36         struct ieee802154_local *local = hw_to_local(hw);
37         struct ieee802154_sub_if_data *sdata;
38
39         rcu_read_lock();
40         list_for_each_entry_rcu(sdata, &local->interfaces, list) {
41                 if (!sdata->dev)
42                         continue;
43
44                 netif_stop_queue(sdata->dev);
45         }
46         rcu_read_unlock();
47 }
48 EXPORT_SYMBOL(ieee802154_stop_queue);
49
50 void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb)
51 {
52         ieee802154_wake_queue(hw);
53         consume_skb(skb);
54 }
55 EXPORT_SYMBOL(ieee802154_xmit_complete);