Blackfin: bf51x/bf52x: fix typo in hysteresis MMR names
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / mac80211 / driver-ops.h
blobeebf7a67daf73122ea7cf455e48abb8d8196c3be
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 u64 drv_prepare_multicast(struct ieee80211_local *local,
134 struct netdev_hw_addr_list *mc_list)
136 u64 ret = 0;
138 trace_drv_prepare_multicast(local, mc_list->count);
140 if (local->ops->prepare_multicast)
141 ret = local->ops->prepare_multicast(&local->hw, mc_list);
143 trace_drv_return_u64(local, ret);
145 return ret;
148 static inline void drv_configure_filter(struct ieee80211_local *local,
149 unsigned int changed_flags,
150 unsigned int *total_flags,
151 u64 multicast)
153 might_sleep();
155 trace_drv_configure_filter(local, changed_flags, total_flags,
156 multicast);
157 local->ops->configure_filter(&local->hw, changed_flags, total_flags,
158 multicast);
159 trace_drv_return_void(local);
162 static inline int drv_set_tim(struct ieee80211_local *local,
163 struct ieee80211_sta *sta, bool set)
165 int ret = 0;
166 trace_drv_set_tim(local, sta, set);
167 if (local->ops->set_tim)
168 ret = local->ops->set_tim(&local->hw, sta, set);
169 trace_drv_return_int(local, ret);
170 return ret;
173 static inline int drv_set_key(struct ieee80211_local *local,
174 enum set_key_cmd cmd,
175 struct ieee80211_sub_if_data *sdata,
176 struct ieee80211_sta *sta,
177 struct ieee80211_key_conf *key)
179 int ret;
181 might_sleep();
183 trace_drv_set_key(local, cmd, sdata, sta, key);
184 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
185 trace_drv_return_int(local, ret);
186 return ret;
189 static inline void drv_update_tkip_key(struct ieee80211_local *local,
190 struct ieee80211_sub_if_data *sdata,
191 struct ieee80211_key_conf *conf,
192 struct sta_info *sta, u32 iv32,
193 u16 *phase1key)
195 struct ieee80211_sta *ista = NULL;
197 if (sta)
198 ista = &sta->sta;
200 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
201 if (local->ops->update_tkip_key)
202 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
203 ista, iv32, phase1key);
204 trace_drv_return_void(local);
207 static inline int drv_hw_scan(struct ieee80211_local *local,
208 struct ieee80211_sub_if_data *sdata,
209 struct cfg80211_scan_request *req)
211 int ret;
213 might_sleep();
215 trace_drv_hw_scan(local, sdata);
216 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
217 trace_drv_return_int(local, ret);
218 return ret;
221 static inline int
222 drv_sched_scan_start(struct ieee80211_local *local,
223 struct ieee80211_sub_if_data *sdata,
224 struct cfg80211_sched_scan_request *req,
225 struct ieee80211_sched_scan_ies *ies)
227 int ret;
229 might_sleep();
231 trace_drv_sched_scan_start(local, sdata);
232 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
233 req, ies);
234 trace_drv_return_int(local, ret);
235 return ret;
238 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
239 struct ieee80211_sub_if_data *sdata)
241 might_sleep();
243 trace_drv_sched_scan_stop(local, sdata);
244 local->ops->sched_scan_stop(&local->hw, &sdata->vif);
245 trace_drv_return_void(local);
248 static inline void drv_sw_scan_start(struct ieee80211_local *local)
250 might_sleep();
252 trace_drv_sw_scan_start(local);
253 if (local->ops->sw_scan_start)
254 local->ops->sw_scan_start(&local->hw);
255 trace_drv_return_void(local);
258 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
260 might_sleep();
262 trace_drv_sw_scan_complete(local);
263 if (local->ops->sw_scan_complete)
264 local->ops->sw_scan_complete(&local->hw);
265 trace_drv_return_void(local);
268 static inline int drv_get_stats(struct ieee80211_local *local,
269 struct ieee80211_low_level_stats *stats)
271 int ret = -EOPNOTSUPP;
273 might_sleep();
275 if (local->ops->get_stats)
276 ret = local->ops->get_stats(&local->hw, stats);
277 trace_drv_get_stats(local, stats, ret);
279 return ret;
282 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
283 u8 hw_key_idx, u32 *iv32, u16 *iv16)
285 if (local->ops->get_tkip_seq)
286 local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
287 trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
290 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
291 u32 value)
293 int ret = 0;
295 might_sleep();
297 trace_drv_set_frag_threshold(local, value);
298 if (local->ops->set_frag_threshold)
299 ret = local->ops->set_frag_threshold(&local->hw, value);
300 trace_drv_return_int(local, ret);
301 return ret;
304 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
305 u32 value)
307 int ret = 0;
309 might_sleep();
311 trace_drv_set_rts_threshold(local, value);
312 if (local->ops->set_rts_threshold)
313 ret = local->ops->set_rts_threshold(&local->hw, value);
314 trace_drv_return_int(local, ret);
315 return ret;
318 static inline int drv_set_coverage_class(struct ieee80211_local *local,
319 u8 value)
321 int ret = 0;
322 might_sleep();
324 trace_drv_set_coverage_class(local, value);
325 if (local->ops->set_coverage_class)
326 local->ops->set_coverage_class(&local->hw, value);
327 else
328 ret = -EOPNOTSUPP;
330 trace_drv_return_int(local, ret);
331 return ret;
334 static inline void drv_sta_notify(struct ieee80211_local *local,
335 struct ieee80211_sub_if_data *sdata,
336 enum sta_notify_cmd cmd,
337 struct ieee80211_sta *sta)
339 trace_drv_sta_notify(local, sdata, cmd, sta);
340 if (local->ops->sta_notify)
341 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
342 trace_drv_return_void(local);
345 static inline int drv_sta_add(struct ieee80211_local *local,
346 struct ieee80211_sub_if_data *sdata,
347 struct ieee80211_sta *sta)
349 int ret = 0;
351 might_sleep();
353 trace_drv_sta_add(local, sdata, sta);
354 if (local->ops->sta_add)
355 ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
357 trace_drv_return_int(local, ret);
359 return ret;
362 static inline void drv_sta_remove(struct ieee80211_local *local,
363 struct ieee80211_sub_if_data *sdata,
364 struct ieee80211_sta *sta)
366 might_sleep();
368 trace_drv_sta_remove(local, sdata, sta);
369 if (local->ops->sta_remove)
370 local->ops->sta_remove(&local->hw, &sdata->vif, sta);
372 trace_drv_return_void(local);
375 static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
376 const struct ieee80211_tx_queue_params *params)
378 int ret = -EOPNOTSUPP;
380 might_sleep();
382 trace_drv_conf_tx(local, queue, params);
383 if (local->ops->conf_tx)
384 ret = local->ops->conf_tx(&local->hw, queue, params);
385 trace_drv_return_int(local, ret);
386 return ret;
389 static inline u64 drv_get_tsf(struct ieee80211_local *local)
391 u64 ret = -1ULL;
393 might_sleep();
395 trace_drv_get_tsf(local);
396 if (local->ops->get_tsf)
397 ret = local->ops->get_tsf(&local->hw);
398 trace_drv_return_u64(local, ret);
399 return ret;
402 static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
404 might_sleep();
406 trace_drv_set_tsf(local, tsf);
407 if (local->ops->set_tsf)
408 local->ops->set_tsf(&local->hw, tsf);
409 trace_drv_return_void(local);
412 static inline void drv_reset_tsf(struct ieee80211_local *local)
414 might_sleep();
416 trace_drv_reset_tsf(local);
417 if (local->ops->reset_tsf)
418 local->ops->reset_tsf(&local->hw);
419 trace_drv_return_void(local);
422 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
424 int ret = 0; /* default unsuported op for less congestion */
426 might_sleep();
428 trace_drv_tx_last_beacon(local);
429 if (local->ops->tx_last_beacon)
430 ret = local->ops->tx_last_beacon(&local->hw);
431 trace_drv_return_int(local, ret);
432 return ret;
435 static inline int drv_ampdu_action(struct ieee80211_local *local,
436 struct ieee80211_sub_if_data *sdata,
437 enum ieee80211_ampdu_mlme_action action,
438 struct ieee80211_sta *sta, u16 tid,
439 u16 *ssn, u8 buf_size)
441 int ret = -EOPNOTSUPP;
443 might_sleep();
445 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
447 if (local->ops->ampdu_action)
448 ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
449 sta, tid, ssn, buf_size);
451 trace_drv_return_int(local, ret);
453 return ret;
456 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
457 struct survey_info *survey)
459 int ret = -EOPNOTSUPP;
461 trace_drv_get_survey(local, idx, survey);
463 if (local->ops->get_survey)
464 ret = local->ops->get_survey(&local->hw, idx, survey);
466 trace_drv_return_int(local, ret);
468 return ret;
471 static inline void drv_rfkill_poll(struct ieee80211_local *local)
473 might_sleep();
475 if (local->ops->rfkill_poll)
476 local->ops->rfkill_poll(&local->hw);
479 static inline void drv_flush(struct ieee80211_local *local, bool drop)
481 might_sleep();
483 trace_drv_flush(local, drop);
484 if (local->ops->flush)
485 local->ops->flush(&local->hw, drop);
486 trace_drv_return_void(local);
489 static inline void drv_channel_switch(struct ieee80211_local *local,
490 struct ieee80211_channel_switch *ch_switch)
492 might_sleep();
494 trace_drv_channel_switch(local, ch_switch);
495 local->ops->channel_switch(&local->hw, ch_switch);
496 trace_drv_return_void(local);
500 static inline int drv_set_antenna(struct ieee80211_local *local,
501 u32 tx_ant, u32 rx_ant)
503 int ret = -EOPNOTSUPP;
504 might_sleep();
505 if (local->ops->set_antenna)
506 ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
507 trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
508 return ret;
511 static inline int drv_get_antenna(struct ieee80211_local *local,
512 u32 *tx_ant, u32 *rx_ant)
514 int ret = -EOPNOTSUPP;
515 might_sleep();
516 if (local->ops->get_antenna)
517 ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
518 trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
519 return ret;
522 static inline int drv_remain_on_channel(struct ieee80211_local *local,
523 struct ieee80211_channel *chan,
524 enum nl80211_channel_type chantype,
525 unsigned int duration)
527 int ret;
529 might_sleep();
531 trace_drv_remain_on_channel(local, chan, chantype, duration);
532 ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
533 duration);
534 trace_drv_return_int(local, ret);
536 return ret;
539 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
541 int ret;
543 might_sleep();
545 trace_drv_cancel_remain_on_channel(local);
546 ret = local->ops->cancel_remain_on_channel(&local->hw);
547 trace_drv_return_int(local, ret);
549 return ret;
552 static inline int drv_offchannel_tx(struct ieee80211_local *local,
553 struct sk_buff *skb,
554 struct ieee80211_channel *chan,
555 enum nl80211_channel_type channel_type,
556 unsigned int wait)
558 int ret;
560 might_sleep();
562 trace_drv_offchannel_tx(local, skb, chan, channel_type, wait);
563 ret = local->ops->offchannel_tx(&local->hw, skb, chan,
564 channel_type, wait);
565 trace_drv_return_int(local, ret);
567 return ret;
570 static inline int drv_offchannel_tx_cancel_wait(struct ieee80211_local *local)
572 int ret;
574 might_sleep();
576 trace_drv_offchannel_tx_cancel_wait(local);
577 ret = local->ops->offchannel_tx_cancel_wait(&local->hw);
578 trace_drv_return_int(local, ret);
580 return ret;
583 static inline int drv_set_ringparam(struct ieee80211_local *local,
584 u32 tx, u32 rx)
586 int ret = -ENOTSUPP;
588 might_sleep();
590 trace_drv_set_ringparam(local, tx, rx);
591 if (local->ops->set_ringparam)
592 ret = local->ops->set_ringparam(&local->hw, tx, rx);
593 trace_drv_return_int(local, ret);
595 return ret;
598 static inline void drv_get_ringparam(struct ieee80211_local *local,
599 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
601 might_sleep();
603 trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
604 if (local->ops->get_ringparam)
605 local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
606 trace_drv_return_void(local);
609 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
611 bool ret = false;
613 might_sleep();
615 trace_drv_tx_frames_pending(local);
616 if (local->ops->tx_frames_pending)
617 ret = local->ops->tx_frames_pending(&local->hw);
618 trace_drv_return_bool(local, ret);
620 return ret;
623 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
624 struct ieee80211_sub_if_data *sdata,
625 const struct cfg80211_bitrate_mask *mask)
627 int ret = -EOPNOTSUPP;
629 might_sleep();
631 trace_drv_set_bitrate_mask(local, sdata, mask);
632 if (local->ops->set_bitrate_mask)
633 ret = local->ops->set_bitrate_mask(&local->hw,
634 &sdata->vif, mask);
635 trace_drv_return_int(local, ret);
637 return ret;
640 #endif /* __MAC80211_DRIVER_OPS */