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