1 // SPDX-License-Identifier: GPL-2.0-only
7 * Based on: net/mac80211/util.c
10 #include "ieee802154_i.h"
11 #include "driver-ops.h"
13 /* privid for wpan_phys to determine whether they belong to us or not */
14 const void *const mac802154_wpan_phy_privid = &mac802154_wpan_phy_privid;
16 void ieee802154_wake_queue(struct ieee802154_hw *hw)
18 struct ieee802154_local *local = hw_to_local(hw);
19 struct ieee802154_sub_if_data *sdata;
22 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
26 netif_wake_queue(sdata->dev);
30 EXPORT_SYMBOL(ieee802154_wake_queue);
32 void ieee802154_stop_queue(struct ieee802154_hw *hw)
34 struct ieee802154_local *local = hw_to_local(hw);
35 struct ieee802154_sub_if_data *sdata;
38 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
42 netif_stop_queue(sdata->dev);
46 EXPORT_SYMBOL(ieee802154_stop_queue);
48 enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer)
50 struct ieee802154_local *local =
51 container_of(timer, struct ieee802154_local, ifs_timer);
53 ieee802154_wake_queue(&local->hw);
55 return HRTIMER_NORESTART;
58 void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
61 struct ieee802154_local *local = hw_to_local(hw);
63 local->tx_result = IEEE802154_SUCCESS;
68 /* If transceiver sets CRC on his own we need to use lifs
69 * threshold len above 16 otherwise 18, because it's not
72 if (hw->flags & IEEE802154_HW_TX_OMIT_CKSUM)
73 max_sifs_size = IEEE802154_MAX_SIFS_FRAME_SIZE -
76 max_sifs_size = IEEE802154_MAX_SIFS_FRAME_SIZE;
78 if (skb->len > max_sifs_size)
79 hrtimer_start(&local->ifs_timer,
80 hw->phy->lifs_period * NSEC_PER_USEC,
83 hrtimer_start(&local->ifs_timer,
84 hw->phy->sifs_period * NSEC_PER_USEC,
87 ieee802154_wake_queue(hw);
90 dev_consume_skb_any(skb);
92 EXPORT_SYMBOL(ieee802154_xmit_complete);
94 void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
97 struct ieee802154_local *local = hw_to_local(hw);
99 local->tx_result = reason;
100 ieee802154_wake_queue(hw);
101 dev_kfree_skb_any(skb);
103 EXPORT_SYMBOL(ieee802154_xmit_error);
105 void ieee802154_xmit_hw_error(struct ieee802154_hw *hw, struct sk_buff *skb)
107 ieee802154_xmit_error(hw, skb, IEEE802154_SYSTEM_ERROR);
109 EXPORT_SYMBOL(ieee802154_xmit_hw_error);
111 void ieee802154_stop_device(struct ieee802154_local *local)
113 flush_workqueue(local->workqueue);
114 hrtimer_cancel(&local->ifs_timer);