blob: 624413ee095f3fe87799ffa71c21a17ce0532e84 [file] [log] [blame]
Alexander Aring4a9a8162014-11-02 04:18:38 +01001#ifndef __CFG802154_RDEV_OPS
2#define __CFG802154_RDEV_OPS
3
4#include <net/cfg802154.h>
5
6#include "core.h"
Guido Günther1cc800e2015-04-30 17:44:55 +02007#include "trace.h"
Alexander Aring4a9a8162014-11-02 04:18:38 +01008
9static inline struct net_device *
10rdev_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
17static inline void
18rdev_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 Aringab0bd562014-11-12 03:36:55 +010024static inline int
Alexander Aringf3ea5e42014-11-17 08:20:51 +010025rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
Alexander Aring0e575472014-11-17 08:20:52 +010026 enum nl802154_iftype type, __le64 extended_addr)
Alexander Aringf3ea5e42014-11-17 08:20:51 +010027{
Guido Günther1cc800e2015-04-30 17:44:55 +020028 int ret;
29
30 trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
Alexander Aring0e575472014-11-17 08:20:52 +010031 extended_addr);
Guido Günther1cc800e2015-04-30 17:44:55 +020032 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 Aringf3ea5e42014-11-17 08:20:51 +010036}
37
38static inline int
Alexander Aringb821ecd2014-11-17 08:20:53 +010039rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
40 struct wpan_dev *wpan_dev)
41{
Guido Günther1cc800e2015-04-30 17:44:55 +020042 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 Aringb821ecd2014-11-17 08:20:53 +010048}
49
50static inline int
Alexander Aring628b1e12014-11-17 08:20:47 +010051rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
Alexander Aringab0bd562014-11-12 03:36:55 +010052{
Guido Günther1cc800e2015-04-30 17:44:55 +020053 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 Aringab0bd562014-11-12 03:36:55 +010059}
60
Alexander Aring702bf372014-11-12 03:36:57 +010061static inline int
Alexander Aringba2a9502014-12-10 15:33:13 +010062rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
63 const struct wpan_phy_cca *cca)
64{
Guido Günther1cc800e2015-04-30 17:44:55 +020065 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 Aringba2a9502014-12-10 15:33:13 +010071}
72
73static inline int
Alexander Aring702bf372014-11-12 03:36:57 +010074rdev_set_pan_id(struct cfg802154_registered_device *rdev,
Alexander Aringee7b9052014-11-17 08:20:55 +010075 struct wpan_dev *wpan_dev, __le16 pan_id)
Alexander Aring702bf372014-11-12 03:36:57 +010076{
Guido Günther1cc800e2015-04-30 17:44:55 +020077 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 Aring702bf372014-11-12 03:36:57 +010083}
84
Alexander Aring9830c622014-11-12 03:36:58 +010085static inline int
86rdev_set_short_addr(struct cfg802154_registered_device *rdev,
Alexander Aringee7b9052014-11-17 08:20:55 +010087 struct wpan_dev *wpan_dev, __le16 short_addr)
Alexander Aring9830c622014-11-12 03:36:58 +010088{
Guido Günther1cc800e2015-04-30 17:44:55 +020089 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 Aring9830c622014-11-12 03:36:58 +010095}
96
Alexander Aring656a9992014-11-12 03:36:59 +010097static inline int
98rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +010099 struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
Alexander Aring656a9992014-11-12 03:36:59 +0100100{
Guido Günther1cc800e2015-04-30 17:44:55 +0200101 int ret;
102
103 trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
Alexander Aring656a9992014-11-12 03:36:59 +0100104 min_be, max_be);
Guido Günther1cc800e2015-04-30 17:44:55 +0200105 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 Aring656a9992014-11-12 03:36:59 +0100109}
110
Alexander Aringa01ba762014-11-12 03:37:01 +0100111static inline int
112rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100113 struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
Alexander Aringa01ba762014-11-12 03:37:01 +0100114{
Guido Günther1cc800e2015-04-30 17:44:55 +0200115 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 Aringa01ba762014-11-12 03:37:01 +0100123}
124
Alexander Aring17a3a462014-11-12 03:37:03 +0100125static inline int
126rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100127 struct wpan_dev *wpan_dev, s8 max_frame_retries)
Alexander Aring17a3a462014-11-12 03:37:03 +0100128{
Guido Günther1cc800e2015-04-30 17:44:55 +0200129 int ret;
130
131 trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
Alexander Aring17a3a462014-11-12 03:37:03 +0100132 max_frame_retries);
Guido Günther1cc800e2015-04-30 17:44:55 +0200133 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 Aring17a3a462014-11-12 03:37:03 +0100137}
138
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100139static inline int
140rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100141 struct wpan_dev *wpan_dev, bool mode)
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100142{
Guido Günther1cc800e2015-04-30 17:44:55 +0200143 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 Aringc8937a1d2014-11-12 03:37:05 +0100149}
150
Alexander Aring4a9a8162014-11-02 04:18:38 +0100151#endif /* __CFG802154_RDEV_OPS */