blob: 7b5a9dd94fe5a2b55d01103aa529261141ece521 [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
Alexander Aringf3ea5e42014-11-17 08:20:51 +010027rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
Varka Bhadram5b4a10392015-04-30 17:44:57 +020028 unsigned char name_assign_type,
Alexander Aring0e575472014-11-17 08:20:52 +010029 enum nl802154_iftype type, __le64 extended_addr)
Alexander Aringf3ea5e42014-11-17 08:20:51 +010030{
Guido Günther1cc800e2015-04-30 17:44:55 +020031 int ret;
32
33 trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
Alexander Aring0e575472014-11-17 08:20:52 +010034 extended_addr);
Varka Bhadram5b4a10392015-04-30 17:44:57 +020035 ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
36 name_assign_type, type,
Guido Günther1cc800e2015-04-30 17:44:55 +020037 extended_addr);
38 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
39 return ret;
Alexander Aringf3ea5e42014-11-17 08:20:51 +010040}
41
42static inline int
Alexander Aringb821ecd2014-11-17 08:20:53 +010043rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
44 struct wpan_dev *wpan_dev)
45{
Guido Günther1cc800e2015-04-30 17:44:55 +020046 int ret;
47
48 trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev);
49 ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev);
50 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
51 return ret;
Alexander Aringb821ecd2014-11-17 08:20:53 +010052}
53
54static inline int
Alexander Aring628b1e12014-11-17 08:20:47 +010055rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
Alexander Aringab0bd562014-11-12 03:36:55 +010056{
Guido Günther1cc800e2015-04-30 17:44:55 +020057 int ret;
58
59 trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel);
60 ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
61 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
62 return ret;
Alexander Aringab0bd562014-11-12 03:36:55 +010063}
64
Alexander Aring702bf372014-11-12 03:36:57 +010065static inline int
Alexander Aringba2a9502014-12-10 15:33:13 +010066rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
67 const struct wpan_phy_cca *cca)
68{
Guido Günther1cc800e2015-04-30 17:44:55 +020069 int ret;
70
71 trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca);
72 ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca);
73 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
74 return ret;
Alexander Aringba2a9502014-12-10 15:33:13 +010075}
76
77static inline int
Alexander Aring702bf372014-11-12 03:36:57 +010078rdev_set_pan_id(struct cfg802154_registered_device *rdev,
Alexander Aringee7b9052014-11-17 08:20:55 +010079 struct wpan_dev *wpan_dev, __le16 pan_id)
Alexander Aring702bf372014-11-12 03:36:57 +010080{
Guido Günther1cc800e2015-04-30 17:44:55 +020081 int ret;
82
83 trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
84 ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
85 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
86 return ret;
Alexander Aring702bf372014-11-12 03:36:57 +010087}
88
Alexander Aring9830c622014-11-12 03:36:58 +010089static inline int
90rdev_set_short_addr(struct cfg802154_registered_device *rdev,
Alexander Aringee7b9052014-11-17 08:20:55 +010091 struct wpan_dev *wpan_dev, __le16 short_addr)
Alexander Aring9830c622014-11-12 03:36:58 +010092{
Guido Günther1cc800e2015-04-30 17:44:55 +020093 int ret;
94
95 trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
96 ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
97 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
98 return ret;
Alexander Aring9830c622014-11-12 03:36:58 +010099}
100
Alexander Aring656a9992014-11-12 03:36:59 +0100101static inline int
102rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100103 struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
Alexander Aring656a9992014-11-12 03:36:59 +0100104{
Guido Günther1cc800e2015-04-30 17:44:55 +0200105 int ret;
106
107 trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
Alexander Aring656a9992014-11-12 03:36:59 +0100108 min_be, max_be);
Guido Günther1cc800e2015-04-30 17:44:55 +0200109 ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
110 min_be, max_be);
111 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
112 return ret;
Alexander Aring656a9992014-11-12 03:36:59 +0100113}
114
Alexander Aringa01ba762014-11-12 03:37:01 +0100115static inline int
116rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100117 struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
Alexander Aringa01ba762014-11-12 03:37:01 +0100118{
Guido Günther1cc800e2015-04-30 17:44:55 +0200119 int ret;
120
121 trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
122 max_csma_backoffs);
123 ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
124 max_csma_backoffs);
125 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
126 return ret;
Alexander Aringa01ba762014-11-12 03:37:01 +0100127}
128
Alexander Aring17a3a462014-11-12 03:37:03 +0100129static inline int
130rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100131 struct wpan_dev *wpan_dev, s8 max_frame_retries)
Alexander Aring17a3a462014-11-12 03:37:03 +0100132{
Guido Günther1cc800e2015-04-30 17:44:55 +0200133 int ret;
134
135 trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
Alexander Aring17a3a462014-11-12 03:37:03 +0100136 max_frame_retries);
Guido Günther1cc800e2015-04-30 17:44:55 +0200137 ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
138 max_frame_retries);
139 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
140 return ret;
Alexander Aring17a3a462014-11-12 03:37:03 +0100141}
142
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100143static inline int
144rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
Alexander Aring628b1e12014-11-17 08:20:47 +0100145 struct wpan_dev *wpan_dev, bool mode)
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100146{
Guido Günther1cc800e2015-04-30 17:44:55 +0200147 int ret;
148
149 trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
150 ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
151 trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
152 return ret;
Alexander Aringc8937a1d2014-11-12 03:37:05 +0100153}
154
Alexander Aring4a9a8162014-11-02 04:18:38 +0100155#endif /* __CFG802154_RDEV_OPS */