1 #ifndef __MAC802154_DRVIER_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"
12 drv_xmit_async(struct ieee802154_local
*local
, struct sk_buff
*skb
)
14 return local
->ops
->xmit_async(&local
->hw
, skb
);
18 drv_xmit_sync(struct ieee802154_local
*local
, struct sk_buff
*skb
)
20 /* don't allow other operations while sync xmit */
25 return local
->ops
->xmit_sync(&local
->hw
, skb
);
28 static inline int drv_start(struct ieee802154_local
*local
)
32 local
->started
= true;
35 return local
->ops
->start(&local
->hw
);
38 static inline void drv_stop(struct ieee802154_local
*local
)
42 local
->ops
->stop(&local
->hw
);
44 /* sync away all work on the tasklet before clearing started */
45 tasklet_disable(&local
->tasklet
);
46 tasklet_enable(&local
->tasklet
);
50 local
->started
= false;
53 static inline int drv_set_channel(struct ieee802154_local
*local
,
54 const u8 page
, const u8 channel
)
58 return local
->ops
->set_channel(&local
->hw
, page
, channel
);
61 static inline int drv_set_tx_power(struct ieee802154_local
*local
,
66 if (!local
->ops
->set_txpower
) {
71 return local
->ops
->set_txpower(&local
->hw
, dbm
);
74 static inline int drv_set_cca_mode(struct ieee802154_local
*local
,
79 if (!local
->ops
->set_cca_mode
) {
84 return local
->ops
->set_cca_mode(&local
->hw
, cca_mode
);
87 static inline int drv_set_lbt_mode(struct ieee802154_local
*local
,
92 if (!local
->ops
->set_lbt
) {
97 return local
->ops
->set_lbt(&local
->hw
, mode
);
100 static inline int drv_set_cca_ed_level(struct ieee802154_local
*local
,
105 if (!local
->ops
->set_cca_ed_level
) {
110 return local
->ops
->set_cca_ed_level(&local
->hw
, ed_level
);
113 static inline int drv_set_pan_id(struct ieee802154_local
*local
,
116 struct ieee802154_hw_addr_filt filt
;
120 if (!local
->ops
->set_hw_addr_filt
) {
125 filt
.pan_id
= pan_id
;
127 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
128 IEEE802154_AFILT_PANID_CHANGED
);
131 static inline int drv_set_extended_addr(struct ieee802154_local
*local
,
132 const __le64 extended_addr
)
134 struct ieee802154_hw_addr_filt filt
;
138 if (!local
->ops
->set_hw_addr_filt
) {
143 filt
.ieee_addr
= extended_addr
;
145 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
146 IEEE802154_AFILT_IEEEADDR_CHANGED
);
149 static inline int drv_set_short_addr(struct ieee802154_local
*local
,
150 const __le16 short_addr
)
152 struct ieee802154_hw_addr_filt filt
;
156 if (!local
->ops
->set_hw_addr_filt
) {
161 filt
.short_addr
= short_addr
;
163 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
164 IEEE802154_AFILT_SADDR_CHANGED
);
167 static inline int drv_set_pan_coord(struct ieee802154_local
*local
,
170 struct ieee802154_hw_addr_filt filt
;
174 if (!local
->ops
->set_hw_addr_filt
) {
179 filt
.pan_coord
= is_coord
;
181 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
182 IEEE802154_AFILT_PANC_CHANGED
);
185 static inline int drv_set_csma_params(struct ieee802154_local
*local
,
186 u8 min_be
, u8 max_be
,
187 u8 max_csma_backoffs
)
191 if (!local
->ops
->set_csma_params
) {
196 return local
->ops
->set_csma_params(&local
->hw
, min_be
, max_be
,
200 static inline int drv_set_max_frame_retries(struct ieee802154_local
*local
,
201 s8 max_frame_retries
)
205 if (!local
->ops
->set_frame_retries
) {
210 return local
->ops
->set_frame_retries(&local
->hw
, max_frame_retries
);
213 static inline int drv_set_promiscuous_mode(struct ieee802154_local
*local
,
218 if (!local
->ops
->set_promiscuous_mode
) {
223 return local
->ops
->set_promiscuous_mode(&local
->hw
, on
);
226 #endif /* __MAC802154_DRVIER_OPS */