0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "ieee802154_i.h"
0011 #include "driver-ops.h"
0012
0013
0014 const void *const mac802154_wpan_phy_privid = &mac802154_wpan_phy_privid;
0015
0016 void ieee802154_wake_queue(struct ieee802154_hw *hw)
0017 {
0018 struct ieee802154_local *local = hw_to_local(hw);
0019 struct ieee802154_sub_if_data *sdata;
0020
0021 rcu_read_lock();
0022 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
0023 if (!sdata->dev)
0024 continue;
0025
0026 netif_wake_queue(sdata->dev);
0027 }
0028 rcu_read_unlock();
0029 }
0030 EXPORT_SYMBOL(ieee802154_wake_queue);
0031
0032 void ieee802154_stop_queue(struct ieee802154_hw *hw)
0033 {
0034 struct ieee802154_local *local = hw_to_local(hw);
0035 struct ieee802154_sub_if_data *sdata;
0036
0037 rcu_read_lock();
0038 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
0039 if (!sdata->dev)
0040 continue;
0041
0042 netif_stop_queue(sdata->dev);
0043 }
0044 rcu_read_unlock();
0045 }
0046 EXPORT_SYMBOL(ieee802154_stop_queue);
0047
0048 enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer)
0049 {
0050 struct ieee802154_local *local =
0051 container_of(timer, struct ieee802154_local, ifs_timer);
0052
0053 ieee802154_wake_queue(&local->hw);
0054
0055 return HRTIMER_NORESTART;
0056 }
0057
0058 void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
0059 bool ifs_handling)
0060 {
0061 struct ieee802154_local *local = hw_to_local(hw);
0062
0063 local->tx_result = IEEE802154_SUCCESS;
0064
0065 if (ifs_handling) {
0066 u8 max_sifs_size;
0067
0068
0069
0070
0071
0072 if (hw->flags & IEEE802154_HW_TX_OMIT_CKSUM)
0073 max_sifs_size = IEEE802154_MAX_SIFS_FRAME_SIZE -
0074 IEEE802154_FCS_LEN;
0075 else
0076 max_sifs_size = IEEE802154_MAX_SIFS_FRAME_SIZE;
0077
0078 if (skb->len > max_sifs_size)
0079 hrtimer_start(&local->ifs_timer,
0080 hw->phy->lifs_period * NSEC_PER_USEC,
0081 HRTIMER_MODE_REL);
0082 else
0083 hrtimer_start(&local->ifs_timer,
0084 hw->phy->sifs_period * NSEC_PER_USEC,
0085 HRTIMER_MODE_REL);
0086 } else {
0087 ieee802154_wake_queue(hw);
0088 }
0089
0090 dev_consume_skb_any(skb);
0091 }
0092 EXPORT_SYMBOL(ieee802154_xmit_complete);
0093
0094 void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
0095 int reason)
0096 {
0097 struct ieee802154_local *local = hw_to_local(hw);
0098
0099 local->tx_result = reason;
0100 ieee802154_wake_queue(hw);
0101 dev_kfree_skb_any(skb);
0102 }
0103 EXPORT_SYMBOL(ieee802154_xmit_error);
0104
0105 void ieee802154_xmit_hw_error(struct ieee802154_hw *hw, struct sk_buff *skb)
0106 {
0107 ieee802154_xmit_error(hw, skb, IEEE802154_SYSTEM_ERROR);
0108 }
0109 EXPORT_SYMBOL(ieee802154_xmit_hw_error);
0110
0111 void ieee802154_stop_device(struct ieee802154_local *local)
0112 {
0113 flush_workqueue(local->workqueue);
0114 hrtimer_cancel(&local->ifs_timer);
0115 drv_stop(local);
0116 }