mm/vmalloc.c: report more vmalloc failures
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / mac80211 / driver-ops.h
blob5f165d7eb2db4c22c3411129c4f93b72216a2794
1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
6 #include "driver-trace.h"
8 static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
10 local->ops->tx(&local->hw, skb);
13 static inline int drv_start(struct ieee80211_local *local)
15 int ret;
17 might_sleep();
19 trace_drv_start(local);
20 local->started = true;
21 smp_mb();
22 ret = local->ops->start(&local->hw);
23 trace_drv_return_int(local, ret);
24 return ret;
27 static inline void drv_stop(struct ieee80211_local *local)
29 might_sleep();
31 trace_drv_stop(local);
32 local->ops->stop(&local->hw);
33 trace_drv_return_void(local);
35 /* sync away all work on the tasklet before clearing started */
36 tasklet_disable(&local->tasklet);
37 tasklet_enable(&local->tasklet);
39 barrier();
41 local->started = false;
44 #ifdef CONFIG_PM
45 static inline int drv_suspend(struct ieee80211_local *local,
46 struct cfg80211_wowlan *wowlan)
48 int ret;
50 might_sleep();
52 trace_drv_suspend(local);
53 ret = local->ops->suspend(&local->hw, wowlan);
54 trace_drv_return_int(local, ret);
55 return ret;
58 static inline int drv_resume(struct ieee80211_local *local)
60 int ret;
62 might_sleep();
64 trace_drv_resume(local);
65 ret = local->ops->resume(&local->hw);
66 trace_drv_return_int(local, ret);
67 return ret;
69 #endif
71 static inline int drv_add_interface(struct ieee80211_local *local,
72 struct ieee80211_vif *vif)
74 int ret;
76 might_sleep();
78 trace_drv_add_interface(local, vif_to_sdata(vif));
79 ret = local->ops->add_interface(&local->hw, vif);
80 trace_drv_return_int(local, ret);
81 return ret;
84 static inline int drv_change_interface(struct ieee80211_local *local,
85 struct ieee80211_sub_if_data *sdata,
86 enum nl80211_iftype type, bool p2p)
88 int ret;
90 might_sleep();
92 trace_drv_change_interface(local, sdata, type, p2p);
93 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
94 trace_drv_return_int(local, ret);
95 return ret;
98 static inline void drv_remove_interface(struct ieee80211_local *local,
99 struct ieee80211_vif *vif)
101 might_sleep();
103 trace_drv_remove_interface(local, vif_to_sdata(vif));
104 local->ops->remove_interface(&local->hw, vif);
105 trace_drv_return_void(local);
108 static inline int drv_config(struct ieee80211_local *local, u32 changed)
110 int ret;
112 might_sleep();
114 trace_drv_config(local, changed);
115 ret = local->ops->config(&local->hw, changed);
116 trace_drv_return_int(local, ret);
117 return ret;
120 static inline void drv_bss_info_changed(struct ieee80211_local *local,
121 struct ieee80211_sub_if_data *sdata,
122 struct ieee80211_bss_conf *info,
123 u32 changed)
125 might_sleep();
127 trace_drv_bss_info_changed(local, sdata, info, changed);
128 if (local->ops->bss_info_changed)
129 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
130 trace_drv_return_void(local);
133 static inline int drv_tx_sync(struct ieee80211_local *local,
134 struct ieee80211_sub_if_data *sdata,
135 const u8 *bssid,
136 enum ieee80211_tx_sync_type type)
138 int ret = 0;
140 might_sleep();
142 trace_drv_tx_sync(local, sdata, bssid, type);
143 if (local->ops->tx_sync)
144 ret = local->ops->tx_sync(&local->hw, &sdata->vif,
145 bssid, type);
146 trace_drv_return_int(local, ret);
147 return ret;
150 static inline void drv_finish_tx_sync(struct ieee80211_local *local,
151 struct ieee80211_sub_if_data *sdata,
152 const u8 *bssid,
153 enum ieee80211_tx_sync_type type)
155 might_sleep();
157 trace_drv_finish_tx_sync(local, sdata, bssid, type);
158 if (local->ops->finish_tx_sync)
159 local->ops->finish_tx_sync(&local->hw, &sdata->vif,
160 bssid, type);
161 trace_drv_return_void(local);
164 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
165 struct netdev_hw_addr_list *mc_list)
167 u64 ret = 0;
169 trace_drv_prepare_multicast(local, mc_list->count);
171 if (local->ops->prepare_multicast)
172 ret = local->ops->prepare_multicast(&local->hw, mc_list);
174 trace_drv_return_u64(local, ret);
176 return ret;
179 static inline void drv_configure_filter(struct ieee80211_local *local,
180 unsigned int changed_flags,
181 unsigned int *total_flags,
182 u64 multicast)
184 might_sleep();
186 trace_drv_configure_filter(local, changed_flags, total_flags,
187 multicast);
188 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
189 multicast);
190 trace_drv_return_void(local);
193 static inline int drv_set_tim(struct ieee80211_local *local,
194 struct ieee80211_sta *sta, bool set)
196 int ret = 0;
197 trace_drv_set_tim(local, sta, set);
198 if (local->ops->set_tim)
199 ret = local->ops->set_tim(&local->hw, sta, set);
200 trace_drv_return_int(local, ret);
201 return ret;
204 static inline int drv_set_key(struct ieee80211_local *local,
205 enum set_key_cmd cmd,
206 struct ieee80211_sub_if_data *sdata,
207 struct ieee80211_sta *sta,
208 struct ieee80211_key_conf *key)
210 int ret;
212 might_sleep();
214 trace_drv_set_key(local, cmd, sdata, sta, key);
215 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
216 trace_drv_return_int(local, ret);
217 return ret;
220 static inline void drv_update_tkip_key(struct ieee80211_local *local,
221 struct ieee80211_sub_if_data *sdata,
222 struct ieee80211_key_conf *conf,
223 struct sta_info *sta, u32 iv32,
224 u16 *phase1key)
226 struct ieee80211_sta *ista = NULL;
228 if (sta)
229 ista = &sta->sta;
231 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
232 if (local->ops->update_tkip_key)
233 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
234 ista, iv32, phase1key);
235 trace_drv_return_void(local);
238 static inline int drv_hw_scan(struct ieee80211_local *local,
239 struct ieee80211_sub_if_data *sdata,
240 struct cfg80211_scan_request *req)
242 int ret;
244 might_sleep();
246 trace_drv_hw_scan(local, sdata);
247 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
248 trace_drv_return_int(local, ret);
249 return ret;
252 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
253 struct ieee80211_sub_if_data *sdata)
255 might_sleep();
257 trace_drv_cancel_hw_scan(local, sdata);
258 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
259 trace_drv_return_void(local);
262 static inline int
263 drv_sched_scan_start(struct ieee80211_local *local,
264 struct ieee80211_sub_if_data *sdata,
265 struct cfg80211_sched_scan_request *req,
266 struct ieee80211_sched_scan_ies *ies)
268 int ret;
270 might_sleep();
272 trace_drv_sched_scan_start(local, sdata);
273 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
274 req, ies);
275 trace_drv_return_int(local, ret);
276 return ret;
279 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
280 struct ieee80211_sub_if_data *sdata)
282 might_sleep();
284 trace_drv_sched_scan_stop(local, sdata);
285 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
286 trace_drv_return_void(local);
289 static inline void drv_sw_scan_start(struct ieee80211_local *local)
291 might_sleep();
293 trace_drv_sw_scan_start(local);
294 if (local->ops->sw_scan_start)
295 local->ops->sw_scan_start(&local->hw);
296 trace_drv_return_void(local);
299 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
301 might_sleep();
303 trace_drv_sw_scan_complete(local);
304 if (local->ops->sw_scan_complete)
305 local->ops->sw_scan_complete(&local->hw);
306 trace_drv_return_void(local);
309 static inline int drv_get_stats(struct ieee80211_local *local,
310 struct ieee80211_low_level_stats *stats)
312 int ret = -EOPNOTSUPP;
314 might_sleep();
316 if (local->ops->get_stats)
317 ret = local->ops->get_stats(&local->hw, stats);
318 trace_drv_get_stats(local, stats, ret);
320 return ret;
323 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
324 u8 hw_key_idx, u32 *iv32, u16 *iv16)
326 if (local->ops->get_tkip_seq)
327 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
328 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
331 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
332 u32 value)
334 int ret = 0;
336 might_sleep();
338 trace_drv_set_frag_threshold(local, value);
339 if (local->ops->set_frag_threshold)
340 ret = local->ops->set_frag_threshold(&local->hw, value);
341 trace_drv_return_int(local, ret);
342 return ret;
345 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
346 u32 value)
348 int ret = 0;
350 might_sleep();
352 trace_drv_set_rts_threshold(local, value);
353 if (local->ops->set_rts_threshold)
354 ret = local->ops->set_rts_threshold(&local->hw, value);
355 trace_drv_return_int(local, ret);
356 return ret;
359 static inline int drv_set_coverage_class(struct ieee80211_local *local,
360 u8 value)
362 int ret = 0;
363 might_sleep();
365 trace_drv_set_coverage_class(local, value);
366 if (local->ops->set_coverage_class)
367 local->ops->set_coverage_class(&local->hw, value);
368 else
369 ret = -EOPNOTSUPP;
371 trace_drv_return_int(local, ret);
372 return ret;
375 static inline void drv_sta_notify(struct ieee80211_local *local,
376 struct ieee80211_sub_if_data *sdata,
377 enum sta_notify_cmd cmd,
378 struct ieee80211_sta *sta)
380 trace_drv_sta_notify(local, sdata, cmd, sta);
381 if (local->ops->sta_notify)
382 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
383 trace_drv_return_void(local);
386 static inline int drv_sta_add(struct ieee80211_local *local,
387 struct ieee80211_sub_if_data *sdata,
388 struct ieee80211_sta *sta)
390 int ret = 0;
392 might_sleep();
394 trace_drv_sta_add(local, sdata, sta);
395 if (local->ops->sta_add)
396 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
398 trace_drv_return_int(local, ret);
400 return ret;
403 static inline void drv_sta_remove(struct ieee80211_local *local,
404 struct ieee80211_sub_if_data *sdata,
405 struct ieee80211_sta *sta)
407 might_sleep();
409 trace_drv_sta_remove(local, sdata, sta);
410 if (local->ops->sta_remove)
411 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
413 trace_drv_return_void(local);
416 static inline int drv_conf_tx(struct ieee80211_local *local,
417 struct ieee80211_sub_if_data *sdata, u16 queue,
418 const struct ieee80211_tx_queue_params *params)
420 int ret = -EOPNOTSUPP;
422 might_sleep();
424 trace_drv_conf_tx(local, sdata, queue, params);
425 if (local->ops->conf_tx)
426 ret = local->ops->conf_tx(&local->hw, &sdata->vif,
427 queue, params);
428 trace_drv_return_int(local, ret);
429 return ret;
432 static inline u64 drv_get_tsf(struct ieee80211_local *local,
433 struct ieee80211_sub_if_data *sdata)
435 u64 ret = -1ULL;
437 might_sleep();
439 trace_drv_get_tsf(local, sdata);
440 if (local->ops->get_tsf)
441 ret = local->ops->get_tsf(&local->hw, &sdata->vif);
442 trace_drv_return_u64(local, ret);
443 return ret;
446 static inline void drv_set_tsf(struct ieee80211_local *local,
447 struct ieee80211_sub_if_data *sdata,
448 u64 tsf)
450 might_sleep();
452 trace_drv_set_tsf(local, sdata, tsf);
453 if (local->ops->set_tsf)
454 local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
455 trace_drv_return_void(local);
458 static inline void drv_reset_tsf(struct ieee80211_local *local,
459 struct ieee80211_sub_if_data *sdata)
461 might_sleep();
463 trace_drv_reset_tsf(local, sdata);
464 if (local->ops->reset_tsf)
465 local->ops->reset_tsf(&local->hw, &sdata->vif);
466 trace_drv_return_void(local);
469 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
471 int ret = 0; /* default unsuported op for less congestion */
473 might_sleep();
475 trace_drv_tx_last_beacon(local);
476 if (local->ops->tx_last_beacon)
477 ret = local->ops->tx_last_beacon(&local->hw);
478 trace_drv_return_int(local, ret);
479 return ret;
482 static inline int drv_ampdu_action(struct ieee80211_local *local,
483 struct ieee80211_sub_if_data *sdata,
484 enum ieee80211_ampdu_mlme_action action,
485 struct ieee80211_sta *sta, u16 tid,
486 u16 *ssn, u8 buf_size)
488 int ret = -EOPNOTSUPP;
490 might_sleep();
492 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
494 if (local->ops->ampdu_action)
495 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
496 sta, tid, ssn, buf_size);
498 trace_drv_return_int(local, ret);
500 return ret;
503 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
504 struct survey_info *survey)
506 int ret = -EOPNOTSUPP;
508 trace_drv_get_survey(local, idx, survey);
510 if (local->ops->get_survey)
511 ret = local->ops->get_survey(&local->hw, idx, survey);
513 trace_drv_return_int(local, ret);
515 return ret;
518 static inline void drv_rfkill_poll(struct ieee80211_local *local)
520 might_sleep();
522 if (local->ops->rfkill_poll)
523 local->ops->rfkill_poll(&local->hw);
526 static inline void drv_flush(struct ieee80211_local *local, bool drop)
528 might_sleep();
530 trace_drv_flush(local, drop);
531 if (local->ops->flush)
532 local->ops->flush(&local->hw, drop);
533 trace_drv_return_void(local);
536 static inline void drv_channel_switch(struct ieee80211_local *local,
537 struct ieee80211_channel_switch *ch_switch)
539 might_sleep();
541 trace_drv_channel_switch(local, ch_switch);
542 local->ops->channel_switch(&local->hw, ch_switch);
543 trace_drv_return_void(local);
547 static inline int drv_set_antenna(struct ieee80211_local *local,
548 u32 tx_ant, u32 rx_ant)
550 int ret = -EOPNOTSUPP;
551 might_sleep();
552 if (local->ops->set_antenna)
553 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
554 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
555 return ret;
558 static inline int drv_get_antenna(struct ieee80211_local *local,
559 u32 *tx_ant, u32 *rx_ant)
561 int ret = -EOPNOTSUPP;
562 might_sleep();
563 if (local->ops->get_antenna)
564 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
565 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
566 return ret;
569 static inline int drv_remain_on_channel(struct ieee80211_local *local,
570 struct ieee80211_channel *chan,
571 enum nl80211_channel_type chantype,
572 unsigned int duration)
574 int ret;
576 might_sleep();
578 trace_drv_remain_on_channel(local, chan, chantype, duration);
579 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
580 duration);
581 trace_drv_return_int(local, ret);
583 return ret;
586 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
588 int ret;
590 might_sleep();
592 trace_drv_cancel_remain_on_channel(local);
593 ret = local->ops->cancel_remain_on_channel(&local->hw);
594 trace_drv_return_int(local, ret);
596 return ret;
599 static inline int drv_set_ringparam(struct ieee80211_local *local,
600 u32 tx, u32 rx)
602 int ret = -ENOTSUPP;
604 might_sleep();
606 trace_drv_set_ringparam(local, tx, rx);
607 if (local->ops->set_ringparam)
608 ret = local->ops->set_ringparam(&local->hw, tx, rx);
609 trace_drv_return_int(local, ret);
611 return ret;
614 static inline void drv_get_ringparam(struct ieee80211_local *local,
615 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
617 might_sleep();
619 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
620 if (local->ops->get_ringparam)
621 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
622 trace_drv_return_void(local);
625 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
627 bool ret = false;
629 might_sleep();
631 trace_drv_tx_frames_pending(local);
632 if (local->ops->tx_frames_pending)
633 ret = local->ops->tx_frames_pending(&local->hw);
634 trace_drv_return_bool(local, ret);
636 return ret;
639 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
640 struct ieee80211_sub_if_data *sdata,
641 const struct cfg80211_bitrate_mask *mask)
643 int ret = -EOPNOTSUPP;
645 might_sleep();
647 trace_drv_set_bitrate_mask(local, sdata, mask);
648 if (local->ops->set_bitrate_mask)
649 ret = local->ops->set_bitrate_mask(&local->hw,
650 &sdata->vif, mask);
651 trace_drv_return_int(local, ret);
653 return ret;
656 static inline void drv_set_rekey_data(struct ieee80211_local *local,
657 struct ieee80211_sub_if_data *sdata,
658 struct cfg80211_gtk_rekey_data *data)
660 trace_drv_set_rekey_data(local, sdata, data);
661 if (local->ops->set_rekey_data)
662 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
663 trace_drv_return_void(local);
666 static inline void drv_rssi_callback(struct ieee80211_local *local,
667 const enum ieee80211_rssi_event event)
669 trace_drv_rssi_callback(local, event);
670 if (local->ops->rssi_callback)
671 local->ops->rssi_callback(&local->hw, event);
672 trace_drv_return_void(local);
675 static inline void
676 drv_release_buffered_frames(struct ieee80211_local *local,
677 struct sta_info *sta, u16 tids, int num_frames,
678 enum ieee80211_frame_release_type reason,
679 bool more_data)
681 trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
682 reason, more_data);
683 if (local->ops->release_buffered_frames)
684 local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
685 num_frames, reason,
686 more_data);
687 trace_drv_return_void(local);
690 static inline void
691 drv_allow_buffered_frames(struct ieee80211_local *local,
692 struct sta_info *sta, u16 tids, int num_frames,
693 enum ieee80211_frame_release_type reason,
694 bool more_data)
696 trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
697 reason, more_data);
698 if (local->ops->allow_buffered_frames)
699 local->ops->allow_buffered_frames(&local->hw, &sta->sta,
700 tids, num_frames, reason,
701 more_data);
702 trace_drv_return_void(local);
704 #endif /* __MAC80211_DRIVER_OPS */