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, |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 11 | const char *name, |
| 12 | unsigned char name_assign_type, |
| 13 | int type) |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 14 | { |
| 15 | return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 16 | name_assign_type, type); |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | static inline void |
| 20 | rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, |
| 21 | struct net_device *dev) |
| 22 | { |
| 23 | rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev); |
| 24 | } |
| 25 | |
Alexander Aring | ab0bd56 | 2014-11-12 03:36:55 +0100 | [diff] [blame] | 26 | static inline int |
Varka Bhadram | a6cb869 | 2015-06-24 11:36:35 +0200 | [diff] [blame] | 27 | rdev_suspend(struct cfg802154_registered_device *rdev) |
| 28 | { |
| 29 | int ret; |
| 30 | trace_802154_rdev_suspend(&rdev->wpan_phy); |
| 31 | ret = rdev->ops->suspend(&rdev->wpan_phy); |
| 32 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 33 | return ret; |
| 34 | } |
| 35 | |
| 36 | static inline int |
| 37 | rdev_resume(struct cfg802154_registered_device *rdev) |
| 38 | { |
| 39 | int ret; |
| 40 | trace_802154_rdev_resume(&rdev->wpan_phy); |
| 41 | ret = rdev->ops->resume(&rdev->wpan_phy); |
| 42 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 43 | return ret; |
| 44 | } |
| 45 | |
| 46 | static inline int |
Alexander Aring | f3ea5e4 | 2014-11-17 08:20:51 +0100 | [diff] [blame] | 47 | rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 48 | unsigned char name_assign_type, |
Alexander Aring | 0e57547 | 2014-11-17 08:20:52 +0100 | [diff] [blame] | 49 | enum nl802154_iftype type, __le64 extended_addr) |
Alexander Aring | f3ea5e4 | 2014-11-17 08:20:51 +0100 | [diff] [blame] | 50 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 51 | int ret; |
| 52 | |
| 53 | trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type, |
Alexander Aring | 0e57547 | 2014-11-17 08:20:52 +0100 | [diff] [blame] | 54 | extended_addr); |
Varka Bhadram | 5b4a1039 | 2015-04-30 17:44:57 +0200 | [diff] [blame] | 55 | ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, |
| 56 | name_assign_type, type, |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 57 | extended_addr); |
| 58 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 59 | return ret; |
Alexander Aring | f3ea5e4 | 2014-11-17 08:20:51 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static inline int |
Alexander Aring | b821ecd | 2014-11-17 08:20:53 +0100 | [diff] [blame] | 63 | rdev_del_virtual_intf(struct cfg802154_registered_device *rdev, |
| 64 | struct wpan_dev *wpan_dev) |
| 65 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 66 | int ret; |
| 67 | |
| 68 | trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev); |
| 69 | ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev); |
| 70 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 71 | return ret; |
Alexander Aring | b821ecd | 2014-11-17 08:20:53 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static inline int |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 75 | rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) |
Alexander Aring | ab0bd56 | 2014-11-12 03:36:55 +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_channel(&rdev->wpan_phy, page, channel); |
| 80 | ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel); |
| 81 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 82 | return ret; |
Alexander Aring | ab0bd56 | 2014-11-12 03:36:55 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 85 | static inline int |
Alexander Aring | ba2a950 | 2014-12-10 15:33:13 +0100 | [diff] [blame] | 86 | rdev_set_cca_mode(struct cfg802154_registered_device *rdev, |
| 87 | const struct wpan_phy_cca *cca) |
| 88 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 89 | int ret; |
| 90 | |
| 91 | trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca); |
| 92 | ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca); |
| 93 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 94 | return ret; |
Alexander Aring | ba2a950 | 2014-12-10 15:33:13 +0100 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static inline int |
Alexander Aring | b69644c | 2015-05-27 13:42:10 +0200 | [diff] [blame] | 98 | rdev_set_cca_ed_level(struct cfg802154_registered_device *rdev, s32 ed_level) |
| 99 | { |
| 100 | int ret; |
| 101 | |
| 102 | trace_802154_rdev_set_cca_ed_level(&rdev->wpan_phy, ed_level); |
| 103 | ret = rdev->ops->set_cca_ed_level(&rdev->wpan_phy, ed_level); |
| 104 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 105 | return ret; |
| 106 | } |
| 107 | |
| 108 | static inline int |
Varka Bhadram | 0f999b0 | 2015-05-27 09:10:54 +0530 | [diff] [blame] | 109 | rdev_set_tx_power(struct cfg802154_registered_device *rdev, |
| 110 | s32 power) |
| 111 | { |
| 112 | int ret; |
| 113 | |
| 114 | trace_802154_rdev_set_tx_power(&rdev->wpan_phy, power); |
| 115 | ret = rdev->ops->set_tx_power(&rdev->wpan_phy, power); |
| 116 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | static inline int |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 121 | rdev_set_pan_id(struct cfg802154_registered_device *rdev, |
Alexander Aring | ee7b905 | 2014-11-17 08:20:55 +0100 | [diff] [blame] | 122 | struct wpan_dev *wpan_dev, __le16 pan_id) |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 123 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 124 | int ret; |
| 125 | |
| 126 | trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); |
| 127 | ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id); |
| 128 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 129 | return ret; |
Alexander Aring | 702bf37 | 2014-11-12 03:36:57 +0100 | [diff] [blame] | 130 | } |
| 131 | |
Alexander Aring | 9830c62 | 2014-11-12 03:36:58 +0100 | [diff] [blame] | 132 | static inline int |
| 133 | rdev_set_short_addr(struct cfg802154_registered_device *rdev, |
Alexander Aring | ee7b905 | 2014-11-17 08:20:55 +0100 | [diff] [blame] | 134 | struct wpan_dev *wpan_dev, __le16 short_addr) |
Alexander Aring | 9830c62 | 2014-11-12 03:36:58 +0100 | [diff] [blame] | 135 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 136 | int ret; |
| 137 | |
| 138 | trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); |
| 139 | ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); |
| 140 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 141 | return ret; |
Alexander Aring | 9830c62 | 2014-11-12 03:36:58 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 144 | static inline int |
| 145 | rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 146 | struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 147 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 148 | int ret; |
| 149 | |
| 150 | trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev, |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 151 | min_be, max_be); |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 152 | ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev, |
| 153 | min_be, max_be); |
| 154 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 155 | return ret; |
Alexander Aring | 656a999 | 2014-11-12 03:36:59 +0100 | [diff] [blame] | 156 | } |
| 157 | |
Alexander Aring | a01ba76 | 2014-11-12 03:37:01 +0100 | [diff] [blame] | 158 | static inline int |
| 159 | rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 160 | struct wpan_dev *wpan_dev, u8 max_csma_backoffs) |
Alexander Aring | a01ba76 | 2014-11-12 03:37:01 +0100 | [diff] [blame] | 161 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 162 | int ret; |
| 163 | |
| 164 | trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev, |
| 165 | max_csma_backoffs); |
| 166 | ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev, |
| 167 | max_csma_backoffs); |
| 168 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 169 | return ret; |
Alexander Aring | a01ba76 | 2014-11-12 03:37:01 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 172 | static inline int |
| 173 | rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 174 | struct wpan_dev *wpan_dev, s8 max_frame_retries) |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 175 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 176 | int ret; |
| 177 | |
| 178 | trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev, |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 179 | max_frame_retries); |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 180 | ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev, |
| 181 | max_frame_retries); |
| 182 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 183 | return ret; |
Alexander Aring | 17a3a46 | 2014-11-12 03:37:03 +0100 | [diff] [blame] | 184 | } |
| 185 | |
Alexander Aring | c8937a1d | 2014-11-12 03:37:05 +0100 | [diff] [blame] | 186 | static inline int |
| 187 | rdev_set_lbt_mode(struct cfg802154_registered_device *rdev, |
Alexander Aring | 628b1e1 | 2014-11-17 08:20:47 +0100 | [diff] [blame] | 188 | struct wpan_dev *wpan_dev, bool mode) |
Alexander Aring | c8937a1d | 2014-11-12 03:37:05 +0100 | [diff] [blame] | 189 | { |
Guido Günther | 1cc800e | 2015-04-30 17:44:55 +0200 | [diff] [blame] | 190 | int ret; |
| 191 | |
| 192 | trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); |
| 193 | ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode); |
| 194 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 195 | return ret; |
Alexander Aring | c8937a1d | 2014-11-12 03:37:05 +0100 | [diff] [blame] | 196 | } |
| 197 | |
Alexander Aring | c91208d | 2015-08-10 21:15:58 +0200 | [diff] [blame] | 198 | static inline int |
| 199 | rdev_set_ackreq_default(struct cfg802154_registered_device *rdev, |
| 200 | struct wpan_dev *wpan_dev, bool ackreq) |
| 201 | { |
| 202 | int ret; |
| 203 | |
| 204 | trace_802154_rdev_set_ackreq_default(&rdev->wpan_phy, wpan_dev, |
| 205 | ackreq); |
| 206 | ret = rdev->ops->set_ackreq_default(&rdev->wpan_phy, wpan_dev, ackreq); |
| 207 | trace_802154_rdev_return_int(&rdev->wpan_phy, ret); |
| 208 | return ret; |
| 209 | } |
| 210 | |
Alexander Aring | a26c5fd | 2015-09-28 09:00:25 +0200 | [diff] [blame] | 211 | #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL |
| 212 | /* TODO this is already a nl802154, so move into ieee802154 */ |
| 213 | static inline void |
| 214 | rdev_get_llsec_table(struct cfg802154_registered_device *rdev, |
| 215 | struct wpan_dev *wpan_dev, |
| 216 | struct ieee802154_llsec_table **table) |
| 217 | { |
| 218 | rdev->ops->get_llsec_table(&rdev->wpan_phy, wpan_dev, table); |
| 219 | } |
| 220 | |
| 221 | static inline void |
| 222 | rdev_lock_llsec_table(struct cfg802154_registered_device *rdev, |
| 223 | struct wpan_dev *wpan_dev) |
| 224 | { |
| 225 | rdev->ops->lock_llsec_table(&rdev->wpan_phy, wpan_dev); |
| 226 | } |
| 227 | |
| 228 | static inline void |
| 229 | rdev_unlock_llsec_table(struct cfg802154_registered_device *rdev, |
| 230 | struct wpan_dev *wpan_dev) |
| 231 | { |
| 232 | rdev->ops->unlock_llsec_table(&rdev->wpan_phy, wpan_dev); |
| 233 | } |
| 234 | |
| 235 | static inline int |
| 236 | rdev_get_llsec_params(struct cfg802154_registered_device *rdev, |
| 237 | struct wpan_dev *wpan_dev, |
| 238 | struct ieee802154_llsec_params *params) |
| 239 | { |
| 240 | return rdev->ops->get_llsec_params(&rdev->wpan_phy, wpan_dev, params); |
| 241 | } |
| 242 | |
| 243 | static inline int |
| 244 | rdev_set_llsec_params(struct cfg802154_registered_device *rdev, |
| 245 | struct wpan_dev *wpan_dev, |
| 246 | const struct ieee802154_llsec_params *params, |
| 247 | u32 changed) |
| 248 | { |
| 249 | return rdev->ops->set_llsec_params(&rdev->wpan_phy, wpan_dev, params, |
| 250 | changed); |
| 251 | } |
| 252 | |
| 253 | static inline int |
| 254 | rdev_add_llsec_key(struct cfg802154_registered_device *rdev, |
| 255 | struct wpan_dev *wpan_dev, |
| 256 | const struct ieee802154_llsec_key_id *id, |
| 257 | const struct ieee802154_llsec_key *key) |
| 258 | { |
| 259 | return rdev->ops->add_llsec_key(&rdev->wpan_phy, wpan_dev, id, key); |
| 260 | } |
| 261 | |
| 262 | static inline int |
| 263 | rdev_del_llsec_key(struct cfg802154_registered_device *rdev, |
| 264 | struct wpan_dev *wpan_dev, |
| 265 | const struct ieee802154_llsec_key_id *id) |
| 266 | { |
| 267 | return rdev->ops->del_llsec_key(&rdev->wpan_phy, wpan_dev, id); |
| 268 | } |
| 269 | |
| 270 | static inline int |
| 271 | rdev_add_seclevel(struct cfg802154_registered_device *rdev, |
| 272 | struct wpan_dev *wpan_dev, |
| 273 | const struct ieee802154_llsec_seclevel *sl) |
| 274 | { |
| 275 | return rdev->ops->add_seclevel(&rdev->wpan_phy, wpan_dev, sl); |
| 276 | } |
| 277 | |
| 278 | static inline int |
| 279 | rdev_del_seclevel(struct cfg802154_registered_device *rdev, |
| 280 | struct wpan_dev *wpan_dev, |
| 281 | const struct ieee802154_llsec_seclevel *sl) |
| 282 | { |
| 283 | return rdev->ops->del_seclevel(&rdev->wpan_phy, wpan_dev, sl); |
| 284 | } |
| 285 | |
| 286 | static inline int |
| 287 | rdev_add_device(struct cfg802154_registered_device *rdev, |
| 288 | struct wpan_dev *wpan_dev, |
| 289 | const struct ieee802154_llsec_device *dev_desc) |
| 290 | { |
| 291 | return rdev->ops->add_device(&rdev->wpan_phy, wpan_dev, dev_desc); |
| 292 | } |
| 293 | |
| 294 | static inline int |
| 295 | rdev_del_device(struct cfg802154_registered_device *rdev, |
| 296 | struct wpan_dev *wpan_dev, __le64 extended_addr) |
| 297 | { |
| 298 | return rdev->ops->del_device(&rdev->wpan_phy, wpan_dev, extended_addr); |
| 299 | } |
| 300 | |
| 301 | static inline int |
| 302 | rdev_add_devkey(struct cfg802154_registered_device *rdev, |
| 303 | struct wpan_dev *wpan_dev, __le64 extended_addr, |
| 304 | const struct ieee802154_llsec_device_key *devkey) |
| 305 | { |
| 306 | return rdev->ops->add_devkey(&rdev->wpan_phy, wpan_dev, extended_addr, |
| 307 | devkey); |
| 308 | } |
| 309 | |
| 310 | static inline int |
| 311 | rdev_del_devkey(struct cfg802154_registered_device *rdev, |
| 312 | struct wpan_dev *wpan_dev, __le64 extended_addr, |
| 313 | const struct ieee802154_llsec_device_key *devkey) |
| 314 | { |
| 315 | return rdev->ops->del_devkey(&rdev->wpan_phy, wpan_dev, extended_addr, |
| 316 | devkey); |
| 317 | } |
| 318 | #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */ |
| 319 | |
Alexander Aring | 4a9a816 | 2014-11-02 04:18:38 +0100 | [diff] [blame] | 320 | #endif /* __CFG802154_RDEV_OPS */ |