Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 1 | #ifndef __CFG802154_RDEV_OPS |
| 2 | #define __CFG802154_RDEV_OPS |
| 3 | |
| 4 | #include <net/cfg802154.h> |
| 5 | |
| 6 | #include "core.h" |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 7 | #include "trace.h" |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 8 | |
| 9 | static inline struct net_device * |
| 10 | rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, |
| 11 | const char *name, int type) |
| 12 | { |
| 13 | return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, |
| 14 | type); |
| 15 | } |
| 16 | |
| 17 | static inline void |
| 18 | rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, |
| 19 | struct net_device *dev) |
| 20 | { |
| 21 | rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev); |
| 22 | } |
| 23 | |
Alexander Aring | ab0bd56 | 2014-11-12 03:36:55 +0100 | [diff] [blame] | 24 | static inline int |
Alexander Aring | f3ea5e4 | 2014-11-17 08:20:51 +0100 | [diff] [blame] | 25 | rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, |
Alexander Aring | 0e57547 | 2014-11-17 08:20:52 +0100 | [diff] [blame] | 26 | enum nl802154_iftype type, __le64 extended_addr) |
Alexander Aring | f3ea5e4 | 2014-11-17 08:20:51 +0100 | [diff] [blame] | 27 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 28 | int ret; |
| 29 | |
| 30 | trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type, |
Alexander Aring | 0e57547 | 2014-11-17 08:20:52 +0100 | [diff] [blame] | 31 | extended_addr); |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 32 | ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type, |
| 33 | extended_addr); |
| 34 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 35 | return ret; |
Alexander Aring | f3ea5e4 | 2014-11-17 08:20:51 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static inline int |
Alexander Aring | b821ecd | 2014-11-17 08:20:53 +0100 | [diff] [blame] | 39 | rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, |
| 40 | struct wpan_dev *wpan_dev) |
| 41 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 42 | int ret; |
| 43 | |
| 44 | trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev); |
| 45 | ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); |
| 46 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 47 | return ret; |
Alexander Aring | b821ecd | 2014-11-17 08:20:53 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static inline int |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 51 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) |
Alexander Aring | ab0bd56 | 2014-11-12 03:36:55 +0100 | [diff] [blame] | 52 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 53 | int ret; |
| 54 | |
| 55 | trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel); |
| 56 | ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel); |
| 57 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 58 | return ret; |
Alexander Aring | ab0bd56 | 2014-11-12 03:36:55 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 61 | static inline int |
Alexander Aring | ba2a950 | 2014-12-10 15:33:13 +0100 | [diff] [blame] | 62 | rdev_set_cca_mode(struct cfg802154_registered_device *rdev, |
| 63 | const struct wpan_phy_cca *cca) |
| 64 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 65 | int ret; |
| 66 | |
| 67 | trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca); |
| 68 | ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca); |
| 69 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 70 | return ret; |
Alexander Aring | ba2a950 | 2014-12-10 15:33:13 +0100 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static inline int |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 74 | rdev_set_pan_id(struct cfg802154_registered_device *rdev, |
Alexander Aring | ee7b905 | 2014-11-17 08:20:55 +0100 | [diff] [blame] | 75 | struct wpan_dev *wpan_dev, __le16 pan_id) |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 76 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 77 | int ret; |
| 78 | |
| 79 | trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); |
| 80 | ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); |
| 81 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 82 | return ret; |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Alexander Aring | 9830c62 | 2014-11-12 03:36:58 +0100 | [diff] [blame] | 85 | static inline int |
| 86 | rdev_set_short_addr(struct cfg802154_registered_device *rdev, |
Alexander Aring | ee7b905 | 2014-11-17 08:20:55 +0100 | [diff] [blame] | 87 | struct wpan_dev *wpan_dev, __le16 short_addr) |
Alexander Aring | 9830c62 | 2014-11-12 03:36:58 +0100 | [diff] [blame] | 88 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 89 | int ret; |
| 90 | |
| 91 | trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); |
| 92 | ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); |
| 93 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 94 | return ret; |
Alexander Aring | 9830c62 | 2014-11-12 03:36:58 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 97 | static inline int |
| 98 | rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 99 | struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 100 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 101 | int ret; |
| 102 | |
| 103 | trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev, |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 104 | min_be, max_be); |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 105 | ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev, |
| 106 | min_be, max_be); |
| 107 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 108 | return ret; |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 109 | } |
| 110 | |
Alexander Aring | a01ba76 | 2014-11-12 03:37:01 +0100 | [diff] [blame] | 111 | static inline int |
| 112 | rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 113 | struct wpan_dev *wpan_dev, u8 max_csma_backoffs) |
Alexander Aring | a01ba76 | 2014-11-12 03:37:01 +0100 | [diff] [blame] | 114 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 115 | int ret; |
| 116 | |
| 117 | trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev, |
| 118 | max_csma_backoffs); |
| 119 | ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev, |
| 120 | max_csma_backoffs); |
| 121 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 122 | return ret; |
Alexander Aring | a01ba76 | 2014-11-12 03:37:01 +0100 | [diff] [blame] | 123 | } |
| 124 | |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 125 | static inline int |
| 126 | rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 127 | struct wpan_dev *wpan_dev, s8 max_frame_retries) |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 128 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 129 | int ret; |
| 130 | |
| 131 | trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev, |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 132 | max_frame_retries); |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 133 | ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev, |
| 134 | max_frame_retries); |
| 135 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 136 | return ret; |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 137 | } |
| 138 | |
Alexander Aring | c8937a1d | 2014-11-12 03:37:05 +0100 | [diff] [blame] | 139 | static inline int |
| 140 | rdev_set_lbt_mode(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 141 | struct wpan_dev *wpan_dev, bool mode) |
Alexander Aring | c8937a1d | 2014-11-12 03:37:05 +0100 | [diff] [blame] | 142 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame^] | 143 | int ret; |
| 144 | |
| 145 | trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); |
| 146 | ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); |
| 147 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 148 | return ret; |
Alexander Aring | c8937a1d | 2014-11-12 03:37:05 +0100 | [diff] [blame] | 149 | } |
| 150 | |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 151 | #endif /* __CFG802154_RDEV_OPS */ |