diff options
Diffstat (limited to 'net/mac802154/driver-ops.h')
-rw-r--r-- | net/mac802154/driver-ops.h | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h new file mode 100644 index 000000000000..bf7980bbceff --- /dev/null +++ b/net/mac802154/driver-ops.h | |||
@@ -0,0 +1,202 @@ | |||
1 | #ifndef __MAC802154_DRVIER_OPS | ||
2 | #define __MAC802154_DRIVER_OPS | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/rtnetlink.h> | ||
6 | |||
7 | #include <net/mac802154.h> | ||
8 | |||
9 | #include "ieee802154_i.h" | ||
10 | |||
11 | static inline int | ||
12 | drv_xmit_async(struct ieee802154_local *local, struct sk_buff *skb) | ||
13 | { | ||
14 | return local->ops->xmit_async(&local->hw, skb); | ||
15 | } | ||
16 | |||
17 | static inline int | ||
18 | drv_xmit_sync(struct ieee802154_local *local, struct sk_buff *skb) | ||
19 | { | ||
20 | /* don't allow other operations while sync xmit */ | ||
21 | ASSERT_RTNL(); | ||
22 | |||
23 | might_sleep(); | ||
24 | |||
25 | return local->ops->xmit_sync(&local->hw, skb); | ||
26 | } | ||
27 | |||
28 | static inline int drv_start(struct ieee802154_local *local) | ||
29 | { | ||
30 | might_sleep(); | ||
31 | |||
32 | return local->ops->start(&local->hw); | ||
33 | } | ||
34 | |||
35 | static inline void drv_stop(struct ieee802154_local *local) | ||
36 | { | ||
37 | might_sleep(); | ||
38 | |||
39 | local->ops->stop(&local->hw); | ||
40 | } | ||
41 | |||
42 | static inline int drv_set_channel(struct ieee802154_local *local, | ||
43 | const u8 page, const u8 channel) | ||
44 | { | ||
45 | might_sleep(); | ||
46 | |||
47 | return local->ops->set_channel(&local->hw, page, channel); | ||
48 | } | ||
49 | |||
50 | static inline int drv_set_tx_power(struct ieee802154_local *local, | ||
51 | const s8 dbm) | ||
52 | { | ||
53 | might_sleep(); | ||
54 | |||
55 | if (!local->ops->set_txpower) { | ||
56 | WARN_ON(1); | ||
57 | return -EOPNOTSUPP; | ||
58 | } | ||
59 | |||
60 | return local->ops->set_txpower(&local->hw, dbm); | ||
61 | } | ||
62 | |||
63 | static inline int drv_set_cca_mode(struct ieee802154_local *local, | ||
64 | const u8 cca_mode) | ||
65 | { | ||
66 | might_sleep(); | ||
67 | |||
68 | if (!local->ops->set_cca_mode) { | ||
69 | WARN_ON(1); | ||
70 | return -EOPNOTSUPP; | ||
71 | } | ||
72 | |||
73 | return local->ops->set_cca_mode(&local->hw, cca_mode); | ||
74 | } | ||
75 | |||
76 | static inline int drv_set_lbt_mode(struct ieee802154_local *local, | ||
77 | const bool mode) | ||
78 | { | ||
79 | might_sleep(); | ||
80 | |||
81 | if (!local->ops->set_lbt) { | ||
82 | WARN_ON(1); | ||
83 | return -EOPNOTSUPP; | ||
84 | } | ||
85 | |||
86 | return local->ops->set_lbt(&local->hw, mode); | ||
87 | } | ||
88 | |||
89 | static inline int drv_set_cca_ed_level(struct ieee802154_local *local, | ||
90 | const s32 ed_level) | ||
91 | { | ||
92 | might_sleep(); | ||
93 | |||
94 | if (!local->ops->set_cca_ed_level) { | ||
95 | WARN_ON(1); | ||
96 | return -EOPNOTSUPP; | ||
97 | } | ||
98 | |||
99 | return local->ops->set_cca_ed_level(&local->hw, ed_level); | ||
100 | } | ||
101 | |||
102 | static inline int drv_set_pan_id(struct ieee802154_local *local, | ||
103 | const __le16 pan_id) | ||
104 | { | ||
105 | struct ieee802154_hw_addr_filt filt; | ||
106 | |||
107 | might_sleep(); | ||
108 | |||
109 | if (!local->ops->set_hw_addr_filt) { | ||
110 | WARN_ON(1); | ||
111 | return -EOPNOTSUPP; | ||
112 | } | ||
113 | |||
114 | filt.pan_id = pan_id; | ||
115 | |||
116 | return local->ops->set_hw_addr_filt(&local->hw, &filt, | ||
117 | IEEE802154_AFILT_PANID_CHANGED); | ||
118 | } | ||
119 | |||
120 | static inline int drv_set_extended_addr(struct ieee802154_local *local, | ||
121 | const __le64 extended_addr) | ||
122 | { | ||
123 | struct ieee802154_hw_addr_filt filt; | ||
124 | |||
125 | might_sleep(); | ||
126 | |||
127 | if (!local->ops->set_hw_addr_filt) { | ||
128 | WARN_ON(1); | ||
129 | return -EOPNOTSUPP; | ||
130 | } | ||
131 | |||
132 | filt.ieee_addr = extended_addr; | ||
133 | |||
134 | return local->ops->set_hw_addr_filt(&local->hw, &filt, | ||
135 | IEEE802154_AFILT_IEEEADDR_CHANGED); | ||
136 | } | ||
137 | |||
138 | static inline int drv_set_short_addr(struct ieee802154_local *local, | ||
139 | const __le16 short_addr) | ||
140 | { | ||
141 | struct ieee802154_hw_addr_filt filt; | ||
142 | |||
143 | might_sleep(); | ||
144 | |||
145 | if (!local->ops->set_hw_addr_filt) { | ||
146 | WARN_ON(1); | ||
147 | return -EOPNOTSUPP; | ||
148 | } | ||
149 | |||
150 | filt.short_addr = short_addr; | ||
151 | |||
152 | return local->ops->set_hw_addr_filt(&local->hw, &filt, | ||
153 | IEEE802154_AFILT_SADDR_CHANGED); | ||
154 | } | ||
155 | |||
156 | static inline int drv_set_pan_coord(struct ieee802154_local *local, | ||
157 | const bool is_coord) | ||
158 | { | ||
159 | struct ieee802154_hw_addr_filt filt; | ||
160 | |||
161 | might_sleep(); | ||
162 | |||
163 | if (!local->ops->set_hw_addr_filt) { | ||
164 | WARN_ON(1); | ||
165 | return -EOPNOTSUPP; | ||
166 | } | ||
167 | |||
168 | filt.pan_coord = is_coord; | ||
169 | |||
170 | return local->ops->set_hw_addr_filt(&local->hw, &filt, | ||
171 | IEEE802154_AFILT_PANC_CHANGED); | ||
172 | } | ||
173 | |||
174 | static inline int drv_set_csma_params(struct ieee802154_local *local, | ||
175 | u8 min_be, u8 max_be, | ||
176 | u8 max_csma_backoffs) | ||
177 | { | ||
178 | might_sleep(); | ||
179 | |||
180 | if (!local->ops->set_csma_params) { | ||
181 | WARN_ON(1); | ||
182 | return -EOPNOTSUPP; | ||
183 | } | ||
184 | |||
185 | return local->ops->set_csma_params(&local->hw, min_be, max_be, | ||
186 | max_csma_backoffs); | ||
187 | } | ||
188 | |||
189 | static inline int drv_set_max_frame_retries(struct ieee802154_local *local, | ||
190 | s8 max_frame_retries) | ||
191 | { | ||
192 | might_sleep(); | ||
193 | |||
194 | if (!local->ops->set_frame_retries) { | ||
195 | WARN_ON(1); | ||
196 | return -EOPNOTSUPP; | ||
197 | } | ||
198 | |||
199 | return local->ops->set_frame_retries(&local->hw, max_frame_retries); | ||
200 | } | ||
201 | |||
202 | #endif /* __MAC802154_DRVIER_OPS */ | ||