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