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;
54 drv_set_channel(struct ieee802154_local
*local
, u8 page
, u8 channel
)
58 return local
->ops
->set_channel(&local
->hw
, page
, channel
);
61 static inline int drv_set_tx_power(struct ieee802154_local
*local
, s8 dbm
)
65 if (!local
->ops
->set_txpower
) {
70 return local
->ops
->set_txpower(&local
->hw
, dbm
);
73 static inline int drv_set_cca_mode(struct ieee802154_local
*local
, u8 cca_mode
)
77 if (!local
->ops
->set_cca_mode
) {
82 return local
->ops
->set_cca_mode(&local
->hw
, cca_mode
);
85 static inline int drv_set_lbt_mode(struct ieee802154_local
*local
, bool mode
)
89 if (!local
->ops
->set_lbt
) {
94 return local
->ops
->set_lbt(&local
->hw
, mode
);
98 drv_set_cca_ed_level(struct ieee802154_local
*local
, s32 ed_level
)
102 if (!local
->ops
->set_cca_ed_level
) {
107 return local
->ops
->set_cca_ed_level(&local
->hw
, ed_level
);
110 static inline int drv_set_pan_id(struct ieee802154_local
*local
, __le16 pan_id
)
112 struct ieee802154_hw_addr_filt filt
;
116 if (!local
->ops
->set_hw_addr_filt
) {
121 filt
.pan_id
= pan_id
;
123 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
124 IEEE802154_AFILT_PANID_CHANGED
);
128 drv_set_extended_addr(struct ieee802154_local
*local
, __le64 extended_addr
)
130 struct ieee802154_hw_addr_filt filt
;
134 if (!local
->ops
->set_hw_addr_filt
) {
139 filt
.ieee_addr
= extended_addr
;
141 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
142 IEEE802154_AFILT_IEEEADDR_CHANGED
);
146 drv_set_short_addr(struct ieee802154_local
*local
, __le16 short_addr
)
148 struct ieee802154_hw_addr_filt filt
;
152 if (!local
->ops
->set_hw_addr_filt
) {
157 filt
.short_addr
= short_addr
;
159 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
160 IEEE802154_AFILT_SADDR_CHANGED
);
164 drv_set_pan_coord(struct ieee802154_local
*local
, bool is_coord
)
166 struct ieee802154_hw_addr_filt filt
;
170 if (!local
->ops
->set_hw_addr_filt
) {
175 filt
.pan_coord
= is_coord
;
177 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
178 IEEE802154_AFILT_PANC_CHANGED
);
182 drv_set_csma_params(struct ieee802154_local
*local
, u8 min_be
, u8 max_be
,
183 u8 max_csma_backoffs
)
187 if (!local
->ops
->set_csma_params
) {
192 return local
->ops
->set_csma_params(&local
->hw
, min_be
, max_be
,
197 drv_set_max_frame_retries(struct ieee802154_local
*local
, s8 max_frame_retries
)
201 if (!local
->ops
->set_frame_retries
) {
206 return local
->ops
->set_frame_retries(&local
->hw
, max_frame_retries
);
210 drv_set_promiscuous_mode(struct ieee802154_local
*local
, bool on
)
214 if (!local
->ops
->set_promiscuous_mode
) {
219 return local
->ops
->set_promiscuous_mode(&local
->hw
, on
);
222 #endif /* __MAC802154_DRVIER_OPS */