]>
Commit | Line | Data |
---|---|---|
24487981 JB |
1 | #ifndef __MAC80211_DRIVER_OPS |
2 | #define __MAC80211_DRIVER_OPS | |
3 | ||
4 | #include <net/mac80211.h> | |
5 | #include "ieee80211_i.h" | |
0a2b8bb2 | 6 | #include "driver-trace.h" |
24487981 JB |
7 | |
8 | static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb) | |
9 | { | |
10 | return local->ops->tx(&local->hw, skb); | |
11 | } | |
12 | ||
13 | static inline int drv_start(struct ieee80211_local *local) | |
14 | { | |
ea77f12f JB |
15 | int ret; |
16 | ||
e1781ed3 KV |
17 | might_sleep(); |
18 | ||
4efc76bd | 19 | trace_drv_start(local); |
ea77f12f JB |
20 | local->started = true; |
21 | smp_mb(); | |
22 | ret = local->ops->start(&local->hw); | |
4efc76bd | 23 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 24 | return ret; |
24487981 JB |
25 | } |
26 | ||
27 | static inline void drv_stop(struct ieee80211_local *local) | |
28 | { | |
e1781ed3 KV |
29 | might_sleep(); |
30 | ||
0a2b8bb2 | 31 | trace_drv_stop(local); |
4efc76bd JB |
32 | local->ops->stop(&local->hw); |
33 | trace_drv_return_void(local); | |
ea77f12f JB |
34 | |
35 | /* sync away all work on the tasklet before clearing started */ | |
36 | tasklet_disable(&local->tasklet); | |
37 | tasklet_enable(&local->tasklet); | |
38 | ||
39 | barrier(); | |
40 | ||
41 | local->started = false; | |
24487981 JB |
42 | } |
43 | ||
44 | static inline int drv_add_interface(struct ieee80211_local *local, | |
1ed32e4f | 45 | struct ieee80211_vif *vif) |
24487981 | 46 | { |
e1781ed3 KV |
47 | int ret; |
48 | ||
49 | might_sleep(); | |
50 | ||
4efc76bd | 51 | trace_drv_add_interface(local, vif_to_sdata(vif)); |
e1781ed3 | 52 | ret = local->ops->add_interface(&local->hw, vif); |
4efc76bd | 53 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 54 | return ret; |
24487981 JB |
55 | } |
56 | ||
57 | static inline void drv_remove_interface(struct ieee80211_local *local, | |
1ed32e4f | 58 | struct ieee80211_vif *vif) |
24487981 | 59 | { |
e1781ed3 KV |
60 | might_sleep(); |
61 | ||
1ed32e4f | 62 | trace_drv_remove_interface(local, vif_to_sdata(vif)); |
4efc76bd JB |
63 | local->ops->remove_interface(&local->hw, vif); |
64 | trace_drv_return_void(local); | |
24487981 JB |
65 | } |
66 | ||
67 | static inline int drv_config(struct ieee80211_local *local, u32 changed) | |
68 | { | |
e1781ed3 KV |
69 | int ret; |
70 | ||
71 | might_sleep(); | |
72 | ||
4efc76bd | 73 | trace_drv_config(local, changed); |
e1781ed3 | 74 | ret = local->ops->config(&local->hw, changed); |
4efc76bd | 75 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 76 | return ret; |
24487981 JB |
77 | } |
78 | ||
79 | static inline void drv_bss_info_changed(struct ieee80211_local *local, | |
12375ef9 | 80 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
81 | struct ieee80211_bss_conf *info, |
82 | u32 changed) | |
83 | { | |
e1781ed3 KV |
84 | might_sleep(); |
85 | ||
4efc76bd | 86 | trace_drv_bss_info_changed(local, sdata, info, changed); |
24487981 | 87 | if (local->ops->bss_info_changed) |
12375ef9 | 88 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
4efc76bd | 89 | trace_drv_return_void(local); |
24487981 JB |
90 | } |
91 | ||
3ac64bee | 92 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
22bedad3 | 93 | struct netdev_hw_addr_list *mc_list) |
3ac64bee JB |
94 | { |
95 | u64 ret = 0; | |
96 | ||
4efc76bd JB |
97 | trace_drv_prepare_multicast(local, mc_list->count); |
98 | ||
3ac64bee | 99 | if (local->ops->prepare_multicast) |
22bedad3 | 100 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
3ac64bee | 101 | |
4efc76bd | 102 | trace_drv_return_u64(local, ret); |
3ac64bee JB |
103 | |
104 | return ret; | |
105 | } | |
106 | ||
24487981 JB |
107 | static inline void drv_configure_filter(struct ieee80211_local *local, |
108 | unsigned int changed_flags, | |
109 | unsigned int *total_flags, | |
3ac64bee | 110 | u64 multicast) |
24487981 | 111 | { |
3ac64bee JB |
112 | might_sleep(); |
113 | ||
0a2b8bb2 | 114 | trace_drv_configure_filter(local, changed_flags, total_flags, |
3ac64bee | 115 | multicast); |
4efc76bd JB |
116 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
117 | multicast); | |
118 | trace_drv_return_void(local); | |
24487981 JB |
119 | } |
120 | ||
121 | static inline int drv_set_tim(struct ieee80211_local *local, | |
122 | struct ieee80211_sta *sta, bool set) | |
123 | { | |
0a2b8bb2 | 124 | int ret = 0; |
4efc76bd | 125 | trace_drv_set_tim(local, sta, set); |
24487981 | 126 | if (local->ops->set_tim) |
0a2b8bb2 | 127 | ret = local->ops->set_tim(&local->hw, sta, set); |
4efc76bd | 128 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 129 | return ret; |
24487981 JB |
130 | } |
131 | ||
132 | static inline int drv_set_key(struct ieee80211_local *local, | |
12375ef9 JB |
133 | enum set_key_cmd cmd, |
134 | struct ieee80211_sub_if_data *sdata, | |
24487981 JB |
135 | struct ieee80211_sta *sta, |
136 | struct ieee80211_key_conf *key) | |
137 | { | |
e1781ed3 KV |
138 | int ret; |
139 | ||
140 | might_sleep(); | |
141 | ||
4efc76bd | 142 | trace_drv_set_key(local, cmd, sdata, sta, key); |
e1781ed3 | 143 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
4efc76bd | 144 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 145 | return ret; |
24487981 JB |
146 | } |
147 | ||
148 | static inline void drv_update_tkip_key(struct ieee80211_local *local, | |
b3fbdcf4 | 149 | struct ieee80211_sub_if_data *sdata, |
24487981 | 150 | struct ieee80211_key_conf *conf, |
b3fbdcf4 | 151 | struct sta_info *sta, u32 iv32, |
24487981 JB |
152 | u16 *phase1key) |
153 | { | |
b3fbdcf4 JB |
154 | struct ieee80211_sta *ista = NULL; |
155 | ||
b3fbdcf4 JB |
156 | if (sta) |
157 | ista = &sta->sta; | |
158 | ||
4efc76bd | 159 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
24487981 | 160 | if (local->ops->update_tkip_key) |
b3fbdcf4 JB |
161 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
162 | ista, iv32, phase1key); | |
4efc76bd | 163 | trace_drv_return_void(local); |
24487981 JB |
164 | } |
165 | ||
166 | static inline int drv_hw_scan(struct ieee80211_local *local, | |
a060bbfe | 167 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
168 | struct cfg80211_scan_request *req) |
169 | { | |
e1781ed3 KV |
170 | int ret; |
171 | ||
172 | might_sleep(); | |
173 | ||
4efc76bd | 174 | trace_drv_hw_scan(local, sdata, req); |
a060bbfe | 175 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
4efc76bd | 176 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 177 | return ret; |
24487981 JB |
178 | } |
179 | ||
180 | static inline void drv_sw_scan_start(struct ieee80211_local *local) | |
181 | { | |
e1781ed3 KV |
182 | might_sleep(); |
183 | ||
4efc76bd | 184 | trace_drv_sw_scan_start(local); |
24487981 JB |
185 | if (local->ops->sw_scan_start) |
186 | local->ops->sw_scan_start(&local->hw); | |
4efc76bd | 187 | trace_drv_return_void(local); |
24487981 JB |
188 | } |
189 | ||
190 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) | |
191 | { | |
e1781ed3 KV |
192 | might_sleep(); |
193 | ||
4efc76bd | 194 | trace_drv_sw_scan_complete(local); |
24487981 JB |
195 | if (local->ops->sw_scan_complete) |
196 | local->ops->sw_scan_complete(&local->hw); | |
4efc76bd | 197 | trace_drv_return_void(local); |
24487981 JB |
198 | } |
199 | ||
200 | static inline int drv_get_stats(struct ieee80211_local *local, | |
201 | struct ieee80211_low_level_stats *stats) | |
202 | { | |
0a2b8bb2 JB |
203 | int ret = -EOPNOTSUPP; |
204 | ||
e1781ed3 KV |
205 | might_sleep(); |
206 | ||
0a2b8bb2 JB |
207 | if (local->ops->get_stats) |
208 | ret = local->ops->get_stats(&local->hw, stats); | |
209 | trace_drv_get_stats(local, stats, ret); | |
210 | ||
211 | return ret; | |
24487981 JB |
212 | } |
213 | ||
214 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, | |
215 | u8 hw_key_idx, u32 *iv32, u16 *iv16) | |
216 | { | |
217 | if (local->ops->get_tkip_seq) | |
218 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); | |
0a2b8bb2 | 219 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
24487981 JB |
220 | } |
221 | ||
222 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, | |
223 | u32 value) | |
224 | { | |
0a2b8bb2 | 225 | int ret = 0; |
e1781ed3 KV |
226 | |
227 | might_sleep(); | |
228 | ||
4efc76bd | 229 | trace_drv_set_rts_threshold(local, value); |
24487981 | 230 | if (local->ops->set_rts_threshold) |
0a2b8bb2 | 231 | ret = local->ops->set_rts_threshold(&local->hw, value); |
4efc76bd | 232 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 233 | return ret; |
24487981 JB |
234 | } |
235 | ||
310bc676 LT |
236 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
237 | u8 value) | |
238 | { | |
239 | int ret = 0; | |
240 | might_sleep(); | |
241 | ||
4efc76bd | 242 | trace_drv_set_coverage_class(local, value); |
310bc676 LT |
243 | if (local->ops->set_coverage_class) |
244 | local->ops->set_coverage_class(&local->hw, value); | |
245 | else | |
246 | ret = -EOPNOTSUPP; | |
247 | ||
4efc76bd | 248 | trace_drv_return_int(local, ret); |
310bc676 LT |
249 | return ret; |
250 | } | |
251 | ||
24487981 | 252 | static inline void drv_sta_notify(struct ieee80211_local *local, |
12375ef9 | 253 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
254 | enum sta_notify_cmd cmd, |
255 | struct ieee80211_sta *sta) | |
256 | { | |
4efc76bd | 257 | trace_drv_sta_notify(local, sdata, cmd, sta); |
24487981 | 258 | if (local->ops->sta_notify) |
12375ef9 | 259 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
4efc76bd | 260 | trace_drv_return_void(local); |
24487981 JB |
261 | } |
262 | ||
34e89507 JB |
263 | static inline int drv_sta_add(struct ieee80211_local *local, |
264 | struct ieee80211_sub_if_data *sdata, | |
265 | struct ieee80211_sta *sta) | |
266 | { | |
267 | int ret = 0; | |
268 | ||
269 | might_sleep(); | |
270 | ||
4efc76bd | 271 | trace_drv_sta_add(local, sdata, sta); |
34e89507 JB |
272 | if (local->ops->sta_add) |
273 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); | |
34e89507 | 274 | |
4efc76bd | 275 | trace_drv_return_int(local, ret); |
34e89507 JB |
276 | |
277 | return ret; | |
278 | } | |
279 | ||
280 | static inline void drv_sta_remove(struct ieee80211_local *local, | |
281 | struct ieee80211_sub_if_data *sdata, | |
282 | struct ieee80211_sta *sta) | |
283 | { | |
284 | might_sleep(); | |
285 | ||
4efc76bd | 286 | trace_drv_sta_remove(local, sdata, sta); |
34e89507 JB |
287 | if (local->ops->sta_remove) |
288 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); | |
34e89507 | 289 | |
4efc76bd | 290 | trace_drv_return_void(local); |
34e89507 JB |
291 | } |
292 | ||
24487981 JB |
293 | static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, |
294 | const struct ieee80211_tx_queue_params *params) | |
295 | { | |
0a2b8bb2 | 296 | int ret = -EOPNOTSUPP; |
e1781ed3 KV |
297 | |
298 | might_sleep(); | |
299 | ||
4efc76bd | 300 | trace_drv_conf_tx(local, queue, params); |
24487981 | 301 | if (local->ops->conf_tx) |
0a2b8bb2 | 302 | ret = local->ops->conf_tx(&local->hw, queue, params); |
4efc76bd | 303 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 304 | return ret; |
24487981 JB |
305 | } |
306 | ||
24487981 JB |
307 | static inline u64 drv_get_tsf(struct ieee80211_local *local) |
308 | { | |
0a2b8bb2 | 309 | u64 ret = -1ULL; |
e1781ed3 KV |
310 | |
311 | might_sleep(); | |
312 | ||
4efc76bd | 313 | trace_drv_get_tsf(local); |
24487981 | 314 | if (local->ops->get_tsf) |
0a2b8bb2 | 315 | ret = local->ops->get_tsf(&local->hw); |
4efc76bd | 316 | trace_drv_return_u64(local, ret); |
0a2b8bb2 | 317 | return ret; |
24487981 JB |
318 | } |
319 | ||
320 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) | |
321 | { | |
e1781ed3 KV |
322 | might_sleep(); |
323 | ||
4efc76bd | 324 | trace_drv_set_tsf(local, tsf); |
24487981 JB |
325 | if (local->ops->set_tsf) |
326 | local->ops->set_tsf(&local->hw, tsf); | |
4efc76bd | 327 | trace_drv_return_void(local); |
24487981 JB |
328 | } |
329 | ||
330 | static inline void drv_reset_tsf(struct ieee80211_local *local) | |
331 | { | |
e1781ed3 KV |
332 | might_sleep(); |
333 | ||
4efc76bd | 334 | trace_drv_reset_tsf(local); |
24487981 JB |
335 | if (local->ops->reset_tsf) |
336 | local->ops->reset_tsf(&local->hw); | |
4efc76bd | 337 | trace_drv_return_void(local); |
24487981 JB |
338 | } |
339 | ||
340 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) | |
341 | { | |
0a2b8bb2 | 342 | int ret = 1; |
e1781ed3 KV |
343 | |
344 | might_sleep(); | |
345 | ||
4efc76bd | 346 | trace_drv_tx_last_beacon(local); |
24487981 | 347 | if (local->ops->tx_last_beacon) |
0a2b8bb2 | 348 | ret = local->ops->tx_last_beacon(&local->hw); |
4efc76bd | 349 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 350 | return ret; |
24487981 JB |
351 | } |
352 | ||
353 | static inline int drv_ampdu_action(struct ieee80211_local *local, | |
12375ef9 | 354 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
355 | enum ieee80211_ampdu_mlme_action action, |
356 | struct ieee80211_sta *sta, u16 tid, | |
357 | u16 *ssn) | |
358 | { | |
0a2b8bb2 | 359 | int ret = -EOPNOTSUPP; |
cfcdbde3 JB |
360 | |
361 | might_sleep(); | |
362 | ||
4efc76bd JB |
363 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn); |
364 | ||
24487981 | 365 | if (local->ops->ampdu_action) |
12375ef9 | 366 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
0a2b8bb2 | 367 | sta, tid, ssn); |
85ad181e | 368 | |
4efc76bd JB |
369 | trace_drv_return_int(local, ret); |
370 | ||
0a2b8bb2 | 371 | return ret; |
24487981 | 372 | } |
1f87f7d3 | 373 | |
1289723e HS |
374 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
375 | struct survey_info *survey) | |
376 | { | |
377 | int ret = -EOPNOTSUPP; | |
c466d4ef JL |
378 | |
379 | trace_drv_get_survey(local, idx, survey); | |
380 | ||
35dd0509 | 381 | if (local->ops->get_survey) |
1289723e | 382 | ret = local->ops->get_survey(&local->hw, idx, survey); |
c466d4ef JL |
383 | |
384 | trace_drv_return_int(local, ret); | |
385 | ||
1289723e HS |
386 | return ret; |
387 | } | |
1f87f7d3 JB |
388 | |
389 | static inline void drv_rfkill_poll(struct ieee80211_local *local) | |
390 | { | |
e1781ed3 KV |
391 | might_sleep(); |
392 | ||
1f87f7d3 JB |
393 | if (local->ops->rfkill_poll) |
394 | local->ops->rfkill_poll(&local->hw); | |
395 | } | |
a80f7c0b JB |
396 | |
397 | static inline void drv_flush(struct ieee80211_local *local, bool drop) | |
398 | { | |
e1781ed3 KV |
399 | might_sleep(); |
400 | ||
a80f7c0b JB |
401 | trace_drv_flush(local, drop); |
402 | if (local->ops->flush) | |
403 | local->ops->flush(&local->hw, drop); | |
4efc76bd | 404 | trace_drv_return_void(local); |
a80f7c0b | 405 | } |
5ce6e438 JB |
406 | |
407 | static inline void drv_channel_switch(struct ieee80211_local *local, | |
408 | struct ieee80211_channel_switch *ch_switch) | |
409 | { | |
410 | might_sleep(); | |
411 | ||
5ce6e438 | 412 | trace_drv_channel_switch(local, ch_switch); |
4efc76bd JB |
413 | local->ops->channel_switch(&local->hw, ch_switch); |
414 | trace_drv_return_void(local); | |
5ce6e438 JB |
415 | } |
416 | ||
24487981 | 417 | #endif /* __MAC80211_DRIVER_OPS */ |