1 #ifndef __MAC802154_DRIVER_OPS
2 #define __MAC802154_DRIVER_OPS
4 #include <linux/types.h>
5 #include <linux/rtnetlink.h>
7 #include <net/mac802154.h>
9 #include "ieee802154_i.h"
13 drv_xmit_async(struct ieee802154_local
*local
, struct sk_buff
*skb
)
15 return local
->ops
->xmit_async(&local
->hw
, skb
);
19 drv_xmit_sync(struct ieee802154_local
*local
, struct sk_buff
*skb
)
21 /* don't allow other operations while sync xmit */
26 return local
->ops
->xmit_sync(&local
->hw
, skb
);
29 static inline int drv_start(struct ieee802154_local
*local
)
35 trace_802154_drv_start(local
);
36 local
->started
= true;
38 ret
= local
->ops
->start(&local
->hw
);
39 trace_802154_drv_return_int(local
, ret
);
43 static inline void drv_stop(struct ieee802154_local
*local
)
47 trace_802154_drv_stop(local
);
48 local
->ops
->stop(&local
->hw
);
49 trace_802154_drv_return_void(local
);
51 /* sync away all work on the tasklet before clearing started */
52 tasklet_disable(&local
->tasklet
);
53 tasklet_enable(&local
->tasklet
);
57 local
->started
= false;
61 drv_set_channel(struct ieee802154_local
*local
, u8 page
, u8 channel
)
67 trace_802154_drv_set_channel(local
, page
, channel
);
68 ret
= local
->ops
->set_channel(&local
->hw
, page
, channel
);
69 trace_802154_drv_return_int(local
, ret
);
73 static inline int drv_set_tx_power(struct ieee802154_local
*local
, s32 mbm
)
79 if (!local
->ops
->set_txpower
) {
84 trace_802154_drv_set_tx_power(local
, mbm
);
85 ret
= local
->ops
->set_txpower(&local
->hw
, mbm
);
86 trace_802154_drv_return_int(local
, ret
);
90 static inline int drv_set_cca_mode(struct ieee802154_local
*local
,
91 const struct wpan_phy_cca
*cca
)
97 if (!local
->ops
->set_cca_mode
) {
102 trace_802154_drv_set_cca_mode(local
, cca
);
103 ret
= local
->ops
->set_cca_mode(&local
->hw
, cca
);
104 trace_802154_drv_return_int(local
, ret
);
108 static inline int drv_set_lbt_mode(struct ieee802154_local
*local
, bool mode
)
114 if (!local
->ops
->set_lbt
) {
119 trace_802154_drv_set_lbt_mode(local
, mode
);
120 ret
= local
->ops
->set_lbt(&local
->hw
, mode
);
121 trace_802154_drv_return_int(local
, ret
);
126 drv_set_cca_ed_level(struct ieee802154_local
*local
, s32 mbm
)
132 if (!local
->ops
->set_cca_ed_level
) {
137 trace_802154_drv_set_cca_ed_level(local
, mbm
);
138 ret
= local
->ops
->set_cca_ed_level(&local
->hw
, mbm
);
139 trace_802154_drv_return_int(local
, ret
);
143 static inline int drv_set_pan_id(struct ieee802154_local
*local
, __le16 pan_id
)
145 struct ieee802154_hw_addr_filt filt
;
150 if (!local
->ops
->set_hw_addr_filt
) {
155 filt
.pan_id
= pan_id
;
157 trace_802154_drv_set_pan_id(local
, pan_id
);
158 ret
= local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
159 IEEE802154_AFILT_PANID_CHANGED
);
160 trace_802154_drv_return_int(local
, ret
);
165 drv_set_extended_addr(struct ieee802154_local
*local
, __le64 extended_addr
)
167 struct ieee802154_hw_addr_filt filt
;
172 if (!local
->ops
->set_hw_addr_filt
) {
177 filt
.ieee_addr
= extended_addr
;
179 trace_802154_drv_set_extended_addr(local
, extended_addr
);
180 ret
= local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
181 IEEE802154_AFILT_IEEEADDR_CHANGED
);
182 trace_802154_drv_return_int(local
, ret
);
187 drv_set_short_addr(struct ieee802154_local
*local
, __le16 short_addr
)
189 struct ieee802154_hw_addr_filt filt
;
194 if (!local
->ops
->set_hw_addr_filt
) {
199 filt
.short_addr
= short_addr
;
201 trace_802154_drv_set_short_addr(local
, short_addr
);
202 ret
= local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
203 IEEE802154_AFILT_SADDR_CHANGED
);
204 trace_802154_drv_return_int(local
, ret
);
209 drv_set_pan_coord(struct ieee802154_local
*local
, bool is_coord
)
211 struct ieee802154_hw_addr_filt filt
;
216 if (!local
->ops
->set_hw_addr_filt
) {
221 filt
.pan_coord
= is_coord
;
223 trace_802154_drv_set_pan_coord(local
, is_coord
);
224 ret
= local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
225 IEEE802154_AFILT_PANC_CHANGED
);
226 trace_802154_drv_return_int(local
, ret
);
231 drv_set_csma_params(struct ieee802154_local
*local
, u8 min_be
, u8 max_be
,
232 u8 max_csma_backoffs
)
238 if (!local
->ops
->set_csma_params
) {
243 trace_802154_drv_set_csma_params(local
, min_be
, max_be
,
245 ret
= local
->ops
->set_csma_params(&local
->hw
, min_be
, max_be
,
247 trace_802154_drv_return_int(local
, ret
);
252 drv_set_max_frame_retries(struct ieee802154_local
*local
, s8 max_frame_retries
)
258 if (!local
->ops
->set_frame_retries
) {
263 trace_802154_drv_set_max_frame_retries(local
, max_frame_retries
);
264 ret
= local
->ops
->set_frame_retries(&local
->hw
, max_frame_retries
);
265 trace_802154_drv_return_int(local
, ret
);
270 drv_set_promiscuous_mode(struct ieee802154_local
*local
, bool on
)
276 if (!local
->ops
->set_promiscuous_mode
) {
281 trace_802154_drv_set_promiscuous_mode(local
, on
);
282 ret
= local
->ops
->set_promiscuous_mode(&local
->hw
, on
);
283 trace_802154_drv_return_int(local
, ret
);
287 #endif /* __MAC802154_DRIVER_OPS */