xref: /openbmc/linux/net/ieee802154/rdev-ops.h (revision e2f1cf25)
1 #ifndef __CFG802154_RDEV_OPS
2 #define __CFG802154_RDEV_OPS
3 
4 #include <net/cfg802154.h>
5 
6 #include "core.h"
7 #include "trace.h"
8 
9 static inline struct net_device *
10 rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
11 				 const char *name,
12 				 unsigned char name_assign_type,
13 				 int type)
14 {
15 	return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
16 						      name_assign_type, type);
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 
26 static inline int
27 rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
28 		      unsigned char name_assign_type,
29 		      enum nl802154_iftype type, __le64 extended_addr)
30 {
31 	int ret;
32 
33 	trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
34 					   extended_addr);
35 	ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
36 					  name_assign_type, type,
37 					  extended_addr);
38 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
39 	return ret;
40 }
41 
42 static inline int
43 rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
44 		      struct wpan_dev *wpan_dev)
45 {
46 	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;
52 }
53 
54 static inline int
55 rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
56 {
57 	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;
63 }
64 
65 static inline int
66 rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
67 		  const struct wpan_phy_cca *cca)
68 {
69 	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;
75 }
76 
77 static inline int
78 rdev_set_cca_ed_level(struct cfg802154_registered_device *rdev, s32 ed_level)
79 {
80 	int ret;
81 
82 	trace_802154_rdev_set_cca_ed_level(&rdev->wpan_phy, ed_level);
83 	ret = rdev->ops->set_cca_ed_level(&rdev->wpan_phy, ed_level);
84 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
85 	return ret;
86 }
87 
88 static inline int
89 rdev_set_tx_power(struct cfg802154_registered_device *rdev,
90 		  s32 power)
91 {
92 	int ret;
93 
94 	trace_802154_rdev_set_tx_power(&rdev->wpan_phy, power);
95 	ret = rdev->ops->set_tx_power(&rdev->wpan_phy, power);
96 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
97 	return ret;
98 }
99 
100 static inline int
101 rdev_set_pan_id(struct cfg802154_registered_device *rdev,
102 		struct wpan_dev *wpan_dev, __le16 pan_id)
103 {
104 	int ret;
105 
106 	trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
107 	ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
108 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
109 	return ret;
110 }
111 
112 static inline int
113 rdev_set_short_addr(struct cfg802154_registered_device *rdev,
114 		    struct wpan_dev *wpan_dev, __le16 short_addr)
115 {
116 	int ret;
117 
118 	trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
119 	ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
120 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
121 	return ret;
122 }
123 
124 static inline int
125 rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
126 			  struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
127 {
128 	int ret;
129 
130 	trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
131 					       min_be, max_be);
132 	ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
133 					      min_be, max_be);
134 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
135 	return ret;
136 }
137 
138 static inline int
139 rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
140 			   struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
141 {
142 	int ret;
143 
144 	trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
145 					    max_csma_backoffs);
146 	ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
147 					       max_csma_backoffs);
148 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
149 	return ret;
150 }
151 
152 static inline int
153 rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
154 			   struct wpan_dev *wpan_dev, s8 max_frame_retries)
155 {
156 	int ret;
157 
158 	trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
159 						max_frame_retries);
160 	ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
161 					       max_frame_retries);
162 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
163 	return ret;
164 }
165 
166 static inline int
167 rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
168 		  struct wpan_dev *wpan_dev, bool mode)
169 {
170 	int ret;
171 
172 	trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
173 	ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
174 	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
175 	return ret;
176 }
177 
178 #endif /* __CFG802154_RDEV_OPS */
179