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"
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
,
74 const struct wpan_phy_cca
*cca
)
78 if (!local
->ops
->set_cca_mode
) {
83 return local
->ops
->set_cca_mode(&local
->hw
, cca
);
86 static inline int drv_set_lbt_mode(struct ieee802154_local
*local
, bool mode
)
90 if (!local
->ops
->set_lbt
) {
95 return local
->ops
->set_lbt(&local
->hw
, mode
);
99 drv_set_cca_ed_level(struct ieee802154_local
*local
, s32 ed_level
)
103 if (!local
->ops
->set_cca_ed_level
) {
108 return local
->ops
->set_cca_ed_level(&local
->hw
, ed_level
);
111 static inline int drv_set_pan_id(struct ieee802154_local
*local
, __le16 pan_id
)
113 struct ieee802154_hw_addr_filt filt
;
117 if (!local
->ops
->set_hw_addr_filt
) {
122 filt
.pan_id
= pan_id
;
124 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
125 IEEE802154_AFILT_PANID_CHANGED
);
129 drv_set_extended_addr(struct ieee802154_local
*local
, __le64 extended_addr
)
131 struct ieee802154_hw_addr_filt filt
;
135 if (!local
->ops
->set_hw_addr_filt
) {
140 filt
.ieee_addr
= extended_addr
;
142 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
143 IEEE802154_AFILT_IEEEADDR_CHANGED
);
147 drv_set_short_addr(struct ieee802154_local
*local
, __le16 short_addr
)
149 struct ieee802154_hw_addr_filt filt
;
153 if (!local
->ops
->set_hw_addr_filt
) {
158 filt
.short_addr
= short_addr
;
160 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
161 IEEE802154_AFILT_SADDR_CHANGED
);
165 drv_set_pan_coord(struct ieee802154_local
*local
, bool is_coord
)
167 struct ieee802154_hw_addr_filt filt
;
171 if (!local
->ops
->set_hw_addr_filt
) {
176 filt
.pan_coord
= is_coord
;
178 return local
->ops
->set_hw_addr_filt(&local
->hw
, &filt
,
179 IEEE802154_AFILT_PANC_CHANGED
);
183 drv_set_csma_params(struct ieee802154_local
*local
, u8 min_be
, u8 max_be
,
184 u8 max_csma_backoffs
)
188 if (!local
->ops
->set_csma_params
) {
193 return local
->ops
->set_csma_params(&local
->hw
, min_be
, max_be
,
198 drv_set_max_frame_retries(struct ieee802154_local
*local
, s8 max_frame_retries
)
202 if (!local
->ops
->set_frame_retries
) {
207 return local
->ops
->set_frame_retries(&local
->hw
, max_frame_retries
);
211 drv_set_promiscuous_mode(struct ieee802154_local
*local
, bool on
)
215 if (!local
->ops
->set_promiscuous_mode
) {
220 return local
->ops
->set_promiscuous_mode(&local
->hw
, on
);
223 #endif /* __MAC802154_DRIVER_OPS */