blob: 8d5960a37195136380032644b65a8b741a03ab00 [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,
Varka Bhadram5b4a10392015-04-30 17:44:57 +020011 const char *name,
12 unsigned char name_assign_type,
13 int type)
Alexander Aring4a9a8162014-11-02 04:18:38 +010014{
15 return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
Varka Bhadram5b4a10392015-04-30 17:44:57 +020016 name_assign_type, type);
Alexander Aring4a9a8162014-11-02 04:18:38 +010017}
18
19static inline void
20rdev_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 Aringab0bd562014-11-12 03:36:55 +010026static inline int
Varka Bhadrama6cb8692015-06-24 11:36:35 +020027rdev_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
36static inline int
37rdev_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
46static inline int
Alexander Aringf3ea5e42014-11-17 08:20:51 +010047rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
Varka Bhadram5b4a10392015-04-30 17:44:57 +020048 unsigned char name_assign_type,
Alexander Aring0e575472014-11-17 08:20:52 +010049 enum nl802154_iftype type, __le64 extended_addr)
Alexander Aringf3ea5e42014-11-17 08:20:51 +010050{
Guido Günther1cc800e2015-04-30 17:44:55 +020051 int ret;
52
53 trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
Alexander Aring0e575472014-11-17 08:20:52 +010054 extended_addr);
Varka Bhadram5b4a10392015-04-30 17:44:57 +020055 ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
56 name_assign_type, type,
Guido Günther1cc800e2015-04-30 17:44:55 +020057 extended_addr);
58 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
59 return ret;
Alexander Aringf3ea5e42014-11-17 08:20:51 +010060}
61
62static inline int
Alexander Aringb821ecd2014-11-17 08:20:53 +010063rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
64 struct wpan_dev *wpan_dev)
65{
Guido Günther1cc800e2015-04-30 17:44:55 +020066 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 Aringb821ecd2014-11-17 08:20:53 +010072}
73
74static inline int
Alexander Aring628b1e12014-11-17 08:20:47 +010075rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
Alexander Aringab0bd562014-11-12 03:36:55 +010076{
Guido Günther1cc800e2015-04-30 17:44:55 +020077 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 Aringab0bd562014-11-12 03:36:55 +010083}
84
Alexander Aring702bf372014-11-12 03:36:57 +010085static inline int
Alexander Aringba2a9502014-12-10 15:33:13 +010086rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
87 const struct wpan_phy_cca *cca)
88{
Guido Günther1cc800e2015-04-30 17:44:55 +020089 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 Aringba2a9502014-12-10 15:33:13 +010095}
96
97static inline int
Alexander Aringb69644c2015-05-27 13:42:10 +020098rdev_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
108static inline int
Varka Bhadram0f999b02015-05-27 09:10:54 +0530109rdev_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
120static inline int
Alexander Aring702bf372014-11-12 03:36:57 +0100121rdev_set_pan_id(struct cfg802154_registered_device *rdev,
Alexander Aringee7b9052014-11-17 08:20:55 +0100122 struct wpan_dev *wpan_dev, __le16 pan_id)
Alexander Aring702bf372014-11-12 03:36:57 +0100123{
Guido Günther1cc800e2015-04-30 17:44:55 +0200124 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 Aring702bf372014-11-12 03:36:57 +0100130}
131
Alexander Aring9830c622014-11-12 03:36:58 +0100132static inline int
133rdev_set_short_addr(struct cfg802154_registered_device *rdev,
Alexander Aringee7b9052014-11-17 08:20:55 +0100134 struct wpan_dev *wpan_dev, __le16 short_addr)
Alexander Aring9830c622014-11-12 03:36:58 +0100135{
Guido Günther1cc800e2015-04-30 17:44:55 +0200136 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 Aring9830c622014-11-12 03:36:58 +0100142}
143
Alexander Aring656a9992014-11-12 03:36:59 +0100144static inline int
145rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100146 struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
Alexander Aring656a9992014-11-12 03:36:59 +0100147{
Guido Günther1cc800e2015-04-30 17:44:55 +0200148 int ret;
149
150 trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
Alexander Aring656a9992014-11-12 03:36:59 +0100151 min_be, max_be);
Guido Günther1cc800e2015-04-30 17:44:55 +0200152 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 Aring656a9992014-11-12 03:36:59 +0100156}
157
Alexander Aringa01ba762014-11-12 03:37:01 +0100158static inline int
159rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100160 struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
Alexander Aringa01ba762014-11-12 03:37:01 +0100161{
Guido Günther1cc800e2015-04-30 17:44:55 +0200162 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 Aringa01ba762014-11-12 03:37:01 +0100170}
171
Alexander Aring17a3a462014-11-12 03:37:03 +0100172static inline int
173rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100174 struct wpan_dev *wpan_dev, s8 max_frame_retries)
Alexander Aring17a3a462014-11-12 03:37:03 +0100175{
Guido Günther1cc800e2015-04-30 17:44:55 +0200176 int ret;
177
178 trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
Alexander Aring17a3a462014-11-12 03:37:03 +0100179 max_frame_retries);
Guido Günther1cc800e2015-04-30 17:44:55 +0200180 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 Aring17a3a462014-11-12 03:37:03 +0100184}
185
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100186static inline int
187rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100188 struct wpan_dev *wpan_dev, bool mode)
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100189{
Guido Günther1cc800e2015-04-30 17:44:55 +0200190 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 Aringc8937a1d2014-11-12 03:37:05 +0100196}
197
Alexander Aring4a9a8162014-11-02 04:18:38 +0100198#endif /* __CFG802154_RDEV_OPS */