]>
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" | |
011ad0e9 | 6 | #include "trace.h" |
24487981 | 7 | |
f6837ba8 | 8 | static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
7b7eab6f | 9 | { |
f6837ba8 JB |
10 | return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), |
11 | "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", | |
12 | sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); | |
7b7eab6f JB |
13 | } |
14 | ||
bc192f89 FF |
15 | static inline struct ieee80211_sub_if_data * |
16 | get_bss_sdata(struct ieee80211_sub_if_data *sdata) | |
17 | { | |
18 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | |
19 | sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, | |
20 | u.ap); | |
21 | ||
22 | return sdata; | |
23 | } | |
24 | ||
36323f81 TH |
25 | static inline void drv_tx(struct ieee80211_local *local, |
26 | struct ieee80211_tx_control *control, | |
27 | struct sk_buff *skb) | |
24487981 | 28 | { |
36323f81 | 29 | local->ops->tx(&local->hw, control, skb); |
24487981 JB |
30 | } |
31 | ||
e352114f BG |
32 | static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata, |
33 | u32 sset, u8 *data) | |
34 | { | |
35 | struct ieee80211_local *local = sdata->local; | |
36 | if (local->ops->get_et_strings) { | |
37 | trace_drv_get_et_strings(local, sset); | |
38 | local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data); | |
39 | trace_drv_return_void(local); | |
40 | } | |
41 | } | |
42 | ||
43 | static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata, | |
44 | struct ethtool_stats *stats, | |
45 | u64 *data) | |
46 | { | |
47 | struct ieee80211_local *local = sdata->local; | |
48 | if (local->ops->get_et_stats) { | |
49 | trace_drv_get_et_stats(local); | |
50 | local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data); | |
51 | trace_drv_return_void(local); | |
52 | } | |
53 | } | |
54 | ||
55 | static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata, | |
56 | int sset) | |
57 | { | |
58 | struct ieee80211_local *local = sdata->local; | |
59 | int rv = 0; | |
60 | if (local->ops->get_et_sset_count) { | |
61 | trace_drv_get_et_sset_count(local, sset); | |
62 | rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif, | |
63 | sset); | |
64 | trace_drv_return_int(local, rv); | |
65 | } | |
66 | return rv; | |
67 | } | |
68 | ||
24487981 JB |
69 | static inline int drv_start(struct ieee80211_local *local) |
70 | { | |
ea77f12f JB |
71 | int ret; |
72 | ||
e1781ed3 KV |
73 | might_sleep(); |
74 | ||
4efc76bd | 75 | trace_drv_start(local); |
ea77f12f JB |
76 | local->started = true; |
77 | smp_mb(); | |
78 | ret = local->ops->start(&local->hw); | |
4efc76bd | 79 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 80 | return ret; |
24487981 JB |
81 | } |
82 | ||
83 | static inline void drv_stop(struct ieee80211_local *local) | |
84 | { | |
e1781ed3 KV |
85 | might_sleep(); |
86 | ||
0a2b8bb2 | 87 | trace_drv_stop(local); |
4efc76bd JB |
88 | local->ops->stop(&local->hw); |
89 | trace_drv_return_void(local); | |
ea77f12f JB |
90 | |
91 | /* sync away all work on the tasklet before clearing started */ | |
92 | tasklet_disable(&local->tasklet); | |
93 | tasklet_enable(&local->tasklet); | |
94 | ||
95 | barrier(); | |
96 | ||
97 | local->started = false; | |
24487981 JB |
98 | } |
99 | ||
eecc4800 JB |
100 | #ifdef CONFIG_PM |
101 | static inline int drv_suspend(struct ieee80211_local *local, | |
102 | struct cfg80211_wowlan *wowlan) | |
103 | { | |
104 | int ret; | |
105 | ||
106 | might_sleep(); | |
107 | ||
108 | trace_drv_suspend(local); | |
109 | ret = local->ops->suspend(&local->hw, wowlan); | |
110 | trace_drv_return_int(local, ret); | |
111 | return ret; | |
112 | } | |
113 | ||
114 | static inline int drv_resume(struct ieee80211_local *local) | |
115 | { | |
116 | int ret; | |
117 | ||
118 | might_sleep(); | |
119 | ||
120 | trace_drv_resume(local); | |
121 | ret = local->ops->resume(&local->hw); | |
122 | trace_drv_return_int(local, ret); | |
123 | return ret; | |
124 | } | |
6d52563f JB |
125 | |
126 | static inline void drv_set_wakeup(struct ieee80211_local *local, | |
127 | bool enabled) | |
128 | { | |
129 | might_sleep(); | |
130 | ||
131 | if (!local->ops->set_wakeup) | |
132 | return; | |
133 | ||
134 | trace_drv_set_wakeup(local, enabled); | |
135 | local->ops->set_wakeup(&local->hw, enabled); | |
136 | trace_drv_return_void(local); | |
137 | } | |
eecc4800 JB |
138 | #endif |
139 | ||
24487981 | 140 | static inline int drv_add_interface(struct ieee80211_local *local, |
7b7eab6f | 141 | struct ieee80211_sub_if_data *sdata) |
24487981 | 142 | { |
e1781ed3 KV |
143 | int ret; |
144 | ||
145 | might_sleep(); | |
146 | ||
7b7eab6f | 147 | if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
4b6f1dd6 | 148 | (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
31eba5bc FF |
149 | !(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF) && |
150 | !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE)))) | |
7b7eab6f JB |
151 | return -EINVAL; |
152 | ||
153 | trace_drv_add_interface(local, sdata); | |
154 | ret = local->ops->add_interface(&local->hw, &sdata->vif); | |
4efc76bd | 155 | trace_drv_return_int(local, ret); |
7b7eab6f JB |
156 | |
157 | if (ret == 0) | |
158 | sdata->flags |= IEEE80211_SDATA_IN_DRIVER; | |
159 | ||
0a2b8bb2 | 160 | return ret; |
24487981 JB |
161 | } |
162 | ||
34d4bc4d JB |
163 | static inline int drv_change_interface(struct ieee80211_local *local, |
164 | struct ieee80211_sub_if_data *sdata, | |
2ca27bcf | 165 | enum nl80211_iftype type, bool p2p) |
34d4bc4d JB |
166 | { |
167 | int ret; | |
168 | ||
169 | might_sleep(); | |
170 | ||
f6837ba8 JB |
171 | if (!check_sdata_in_driver(sdata)) |
172 | return -EIO; | |
7b7eab6f | 173 | |
2ca27bcf JB |
174 | trace_drv_change_interface(local, sdata, type, p2p); |
175 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); | |
34d4bc4d JB |
176 | trace_drv_return_int(local, ret); |
177 | return ret; | |
178 | } | |
179 | ||
24487981 | 180 | static inline void drv_remove_interface(struct ieee80211_local *local, |
7b7eab6f | 181 | struct ieee80211_sub_if_data *sdata) |
24487981 | 182 | { |
e1781ed3 KV |
183 | might_sleep(); |
184 | ||
f6837ba8 JB |
185 | if (!check_sdata_in_driver(sdata)) |
186 | return; | |
7b7eab6f JB |
187 | |
188 | trace_drv_remove_interface(local, sdata); | |
189 | local->ops->remove_interface(&local->hw, &sdata->vif); | |
190 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; | |
4efc76bd | 191 | trace_drv_return_void(local); |
24487981 JB |
192 | } |
193 | ||
194 | static inline int drv_config(struct ieee80211_local *local, u32 changed) | |
195 | { | |
e1781ed3 KV |
196 | int ret; |
197 | ||
198 | might_sleep(); | |
199 | ||
4efc76bd | 200 | trace_drv_config(local, changed); |
e1781ed3 | 201 | ret = local->ops->config(&local->hw, changed); |
4efc76bd | 202 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 203 | return ret; |
24487981 JB |
204 | } |
205 | ||
206 | static inline void drv_bss_info_changed(struct ieee80211_local *local, | |
12375ef9 | 207 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
208 | struct ieee80211_bss_conf *info, |
209 | u32 changed) | |
210 | { | |
e1781ed3 KV |
211 | might_sleep(); |
212 | ||
5bbe754d JB |
213 | if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON | |
214 | BSS_CHANGED_BEACON_ENABLED) && | |
215 | sdata->vif.type != NL80211_IFTYPE_AP && | |
216 | sdata->vif.type != NL80211_IFTYPE_ADHOC && | |
239281f8 RL |
217 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && |
218 | sdata->vif.type != NL80211_IFTYPE_OCB)) | |
5bbe754d JB |
219 | return; |
220 | ||
221 | if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE || | |
222 | sdata->vif.type == NL80211_IFTYPE_MONITOR)) | |
223 | return; | |
b8dc1a35 | 224 | |
f6837ba8 JB |
225 | if (!check_sdata_in_driver(sdata)) |
226 | return; | |
7b7eab6f | 227 | |
4efc76bd | 228 | trace_drv_bss_info_changed(local, sdata, info, changed); |
24487981 | 229 | if (local->ops->bss_info_changed) |
12375ef9 | 230 | local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); |
4efc76bd | 231 | trace_drv_return_void(local); |
24487981 JB |
232 | } |
233 | ||
3ac64bee | 234 | static inline u64 drv_prepare_multicast(struct ieee80211_local *local, |
22bedad3 | 235 | struct netdev_hw_addr_list *mc_list) |
3ac64bee JB |
236 | { |
237 | u64 ret = 0; | |
238 | ||
4efc76bd JB |
239 | trace_drv_prepare_multicast(local, mc_list->count); |
240 | ||
3ac64bee | 241 | if (local->ops->prepare_multicast) |
22bedad3 | 242 | ret = local->ops->prepare_multicast(&local->hw, mc_list); |
3ac64bee | 243 | |
4efc76bd | 244 | trace_drv_return_u64(local, ret); |
3ac64bee JB |
245 | |
246 | return ret; | |
247 | } | |
248 | ||
24487981 JB |
249 | static inline void drv_configure_filter(struct ieee80211_local *local, |
250 | unsigned int changed_flags, | |
251 | unsigned int *total_flags, | |
3ac64bee | 252 | u64 multicast) |
24487981 | 253 | { |
3ac64bee JB |
254 | might_sleep(); |
255 | ||
0a2b8bb2 | 256 | trace_drv_configure_filter(local, changed_flags, total_flags, |
3ac64bee | 257 | multicast); |
4efc76bd JB |
258 | local->ops->configure_filter(&local->hw, changed_flags, total_flags, |
259 | multicast); | |
260 | trace_drv_return_void(local); | |
24487981 JB |
261 | } |
262 | ||
263 | static inline int drv_set_tim(struct ieee80211_local *local, | |
264 | struct ieee80211_sta *sta, bool set) | |
265 | { | |
0a2b8bb2 | 266 | int ret = 0; |
4efc76bd | 267 | trace_drv_set_tim(local, sta, set); |
24487981 | 268 | if (local->ops->set_tim) |
0a2b8bb2 | 269 | ret = local->ops->set_tim(&local->hw, sta, set); |
4efc76bd | 270 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 271 | return ret; |
24487981 JB |
272 | } |
273 | ||
274 | static inline int drv_set_key(struct ieee80211_local *local, | |
12375ef9 JB |
275 | enum set_key_cmd cmd, |
276 | struct ieee80211_sub_if_data *sdata, | |
24487981 JB |
277 | struct ieee80211_sta *sta, |
278 | struct ieee80211_key_conf *key) | |
279 | { | |
e1781ed3 KV |
280 | int ret; |
281 | ||
282 | might_sleep(); | |
283 | ||
077f4939 | 284 | sdata = get_bss_sdata(sdata); |
f6837ba8 JB |
285 | if (!check_sdata_in_driver(sdata)) |
286 | return -EIO; | |
7b7eab6f | 287 | |
4efc76bd | 288 | trace_drv_set_key(local, cmd, sdata, sta, key); |
e1781ed3 | 289 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
4efc76bd | 290 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 291 | return ret; |
24487981 JB |
292 | } |
293 | ||
294 | static inline void drv_update_tkip_key(struct ieee80211_local *local, | |
b3fbdcf4 | 295 | struct ieee80211_sub_if_data *sdata, |
24487981 | 296 | struct ieee80211_key_conf *conf, |
b3fbdcf4 | 297 | struct sta_info *sta, u32 iv32, |
24487981 JB |
298 | u16 *phase1key) |
299 | { | |
b3fbdcf4 JB |
300 | struct ieee80211_sta *ista = NULL; |
301 | ||
b3fbdcf4 JB |
302 | if (sta) |
303 | ista = &sta->sta; | |
304 | ||
077f4939 | 305 | sdata = get_bss_sdata(sdata); |
f6837ba8 JB |
306 | if (!check_sdata_in_driver(sdata)) |
307 | return; | |
7b7eab6f | 308 | |
4efc76bd | 309 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
24487981 | 310 | if (local->ops->update_tkip_key) |
b3fbdcf4 JB |
311 | local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, |
312 | ista, iv32, phase1key); | |
4efc76bd | 313 | trace_drv_return_void(local); |
24487981 JB |
314 | } |
315 | ||
316 | static inline int drv_hw_scan(struct ieee80211_local *local, | |
a060bbfe | 317 | struct ieee80211_sub_if_data *sdata, |
c56ef672 | 318 | struct ieee80211_scan_request *req) |
24487981 | 319 | { |
e1781ed3 KV |
320 | int ret; |
321 | ||
322 | might_sleep(); | |
323 | ||
f6837ba8 JB |
324 | if (!check_sdata_in_driver(sdata)) |
325 | return -EIO; | |
7b7eab6f | 326 | |
79f460ca | 327 | trace_drv_hw_scan(local, sdata); |
a060bbfe | 328 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
4efc76bd | 329 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 330 | return ret; |
24487981 JB |
331 | } |
332 | ||
b856439b EP |
333 | static inline void drv_cancel_hw_scan(struct ieee80211_local *local, |
334 | struct ieee80211_sub_if_data *sdata) | |
335 | { | |
336 | might_sleep(); | |
337 | ||
f6837ba8 JB |
338 | if (!check_sdata_in_driver(sdata)) |
339 | return; | |
7b7eab6f | 340 | |
b856439b EP |
341 | trace_drv_cancel_hw_scan(local, sdata); |
342 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); | |
343 | trace_drv_return_void(local); | |
344 | } | |
345 | ||
79f460ca LC |
346 | static inline int |
347 | drv_sched_scan_start(struct ieee80211_local *local, | |
348 | struct ieee80211_sub_if_data *sdata, | |
349 | struct cfg80211_sched_scan_request *req, | |
633e2713 | 350 | struct ieee80211_scan_ies *ies) |
79f460ca LC |
351 | { |
352 | int ret; | |
353 | ||
354 | might_sleep(); | |
355 | ||
f6837ba8 JB |
356 | if (!check_sdata_in_driver(sdata)) |
357 | return -EIO; | |
7b7eab6f | 358 | |
79f460ca LC |
359 | trace_drv_sched_scan_start(local, sdata); |
360 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, | |
361 | req, ies); | |
362 | trace_drv_return_int(local, ret); | |
363 | return ret; | |
364 | } | |
365 | ||
37e3308c JB |
366 | static inline int drv_sched_scan_stop(struct ieee80211_local *local, |
367 | struct ieee80211_sub_if_data *sdata) | |
79f460ca | 368 | { |
37e3308c JB |
369 | int ret; |
370 | ||
79f460ca LC |
371 | might_sleep(); |
372 | ||
f6837ba8 JB |
373 | if (!check_sdata_in_driver(sdata)) |
374 | return -EIO; | |
7b7eab6f | 375 | |
79f460ca | 376 | trace_drv_sched_scan_stop(local, sdata); |
37e3308c JB |
377 | ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
378 | trace_drv_return_int(local, ret); | |
379 | ||
380 | return ret; | |
79f460ca LC |
381 | } |
382 | ||
24487981 JB |
383 | static inline void drv_sw_scan_start(struct ieee80211_local *local) |
384 | { | |
e1781ed3 KV |
385 | might_sleep(); |
386 | ||
4efc76bd | 387 | trace_drv_sw_scan_start(local); |
24487981 JB |
388 | if (local->ops->sw_scan_start) |
389 | local->ops->sw_scan_start(&local->hw); | |
4efc76bd | 390 | trace_drv_return_void(local); |
24487981 JB |
391 | } |
392 | ||
393 | static inline void drv_sw_scan_complete(struct ieee80211_local *local) | |
394 | { | |
e1781ed3 KV |
395 | might_sleep(); |
396 | ||
4efc76bd | 397 | trace_drv_sw_scan_complete(local); |
24487981 JB |
398 | if (local->ops->sw_scan_complete) |
399 | local->ops->sw_scan_complete(&local->hw); | |
4efc76bd | 400 | trace_drv_return_void(local); |
24487981 JB |
401 | } |
402 | ||
403 | static inline int drv_get_stats(struct ieee80211_local *local, | |
404 | struct ieee80211_low_level_stats *stats) | |
405 | { | |
0a2b8bb2 JB |
406 | int ret = -EOPNOTSUPP; |
407 | ||
e1781ed3 KV |
408 | might_sleep(); |
409 | ||
0a2b8bb2 JB |
410 | if (local->ops->get_stats) |
411 | ret = local->ops->get_stats(&local->hw, stats); | |
412 | trace_drv_get_stats(local, stats, ret); | |
413 | ||
414 | return ret; | |
24487981 JB |
415 | } |
416 | ||
417 | static inline void drv_get_tkip_seq(struct ieee80211_local *local, | |
418 | u8 hw_key_idx, u32 *iv32, u16 *iv16) | |
419 | { | |
420 | if (local->ops->get_tkip_seq) | |
421 | local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16); | |
0a2b8bb2 | 422 | trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16); |
24487981 JB |
423 | } |
424 | ||
f23a4780 AN |
425 | static inline int drv_set_frag_threshold(struct ieee80211_local *local, |
426 | u32 value) | |
427 | { | |
428 | int ret = 0; | |
429 | ||
430 | might_sleep(); | |
431 | ||
432 | trace_drv_set_frag_threshold(local, value); | |
433 | if (local->ops->set_frag_threshold) | |
434 | ret = local->ops->set_frag_threshold(&local->hw, value); | |
435 | trace_drv_return_int(local, ret); | |
436 | return ret; | |
437 | } | |
438 | ||
24487981 JB |
439 | static inline int drv_set_rts_threshold(struct ieee80211_local *local, |
440 | u32 value) | |
441 | { | |
0a2b8bb2 | 442 | int ret = 0; |
e1781ed3 KV |
443 | |
444 | might_sleep(); | |
445 | ||
4efc76bd | 446 | trace_drv_set_rts_threshold(local, value); |
24487981 | 447 | if (local->ops->set_rts_threshold) |
0a2b8bb2 | 448 | ret = local->ops->set_rts_threshold(&local->hw, value); |
4efc76bd | 449 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 450 | return ret; |
24487981 JB |
451 | } |
452 | ||
310bc676 | 453 | static inline int drv_set_coverage_class(struct ieee80211_local *local, |
a4bcaf55 | 454 | s16 value) |
310bc676 LT |
455 | { |
456 | int ret = 0; | |
457 | might_sleep(); | |
458 | ||
4efc76bd | 459 | trace_drv_set_coverage_class(local, value); |
310bc676 LT |
460 | if (local->ops->set_coverage_class) |
461 | local->ops->set_coverage_class(&local->hw, value); | |
462 | else | |
463 | ret = -EOPNOTSUPP; | |
464 | ||
4efc76bd | 465 | trace_drv_return_int(local, ret); |
310bc676 LT |
466 | return ret; |
467 | } | |
468 | ||
24487981 | 469 | static inline void drv_sta_notify(struct ieee80211_local *local, |
12375ef9 | 470 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
471 | enum sta_notify_cmd cmd, |
472 | struct ieee80211_sta *sta) | |
473 | { | |
bc192f89 | 474 | sdata = get_bss_sdata(sdata); |
f6837ba8 JB |
475 | if (!check_sdata_in_driver(sdata)) |
476 | return; | |
7b7eab6f | 477 | |
4efc76bd | 478 | trace_drv_sta_notify(local, sdata, cmd, sta); |
24487981 | 479 | if (local->ops->sta_notify) |
12375ef9 | 480 | local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); |
4efc76bd | 481 | trace_drv_return_void(local); |
24487981 JB |
482 | } |
483 | ||
34e89507 JB |
484 | static inline int drv_sta_add(struct ieee80211_local *local, |
485 | struct ieee80211_sub_if_data *sdata, | |
486 | struct ieee80211_sta *sta) | |
487 | { | |
488 | int ret = 0; | |
489 | ||
490 | might_sleep(); | |
491 | ||
bc192f89 | 492 | sdata = get_bss_sdata(sdata); |
f6837ba8 JB |
493 | if (!check_sdata_in_driver(sdata)) |
494 | return -EIO; | |
7b7eab6f | 495 | |
4efc76bd | 496 | trace_drv_sta_add(local, sdata, sta); |
34e89507 JB |
497 | if (local->ops->sta_add) |
498 | ret = local->ops->sta_add(&local->hw, &sdata->vif, sta); | |
34e89507 | 499 | |
4efc76bd | 500 | trace_drv_return_int(local, ret); |
34e89507 JB |
501 | |
502 | return ret; | |
503 | } | |
504 | ||
505 | static inline void drv_sta_remove(struct ieee80211_local *local, | |
506 | struct ieee80211_sub_if_data *sdata, | |
507 | struct ieee80211_sta *sta) | |
508 | { | |
509 | might_sleep(); | |
510 | ||
bc192f89 | 511 | sdata = get_bss_sdata(sdata); |
f6837ba8 JB |
512 | if (!check_sdata_in_driver(sdata)) |
513 | return; | |
7b7eab6f | 514 | |
4efc76bd | 515 | trace_drv_sta_remove(local, sdata, sta); |
34e89507 JB |
516 | if (local->ops->sta_remove) |
517 | local->ops->sta_remove(&local->hw, &sdata->vif, sta); | |
34e89507 | 518 | |
4efc76bd | 519 | trace_drv_return_void(local); |
34e89507 JB |
520 | } |
521 | ||
77d2ece6 SM |
522 | #ifdef CONFIG_MAC80211_DEBUGFS |
523 | static inline void drv_sta_add_debugfs(struct ieee80211_local *local, | |
524 | struct ieee80211_sub_if_data *sdata, | |
525 | struct ieee80211_sta *sta, | |
526 | struct dentry *dir) | |
527 | { | |
528 | might_sleep(); | |
529 | ||
530 | sdata = get_bss_sdata(sdata); | |
f6837ba8 JB |
531 | if (!check_sdata_in_driver(sdata)) |
532 | return; | |
77d2ece6 SM |
533 | |
534 | if (local->ops->sta_add_debugfs) | |
535 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, | |
536 | sta, dir); | |
537 | } | |
538 | ||
539 | static inline void drv_sta_remove_debugfs(struct ieee80211_local *local, | |
540 | struct ieee80211_sub_if_data *sdata, | |
541 | struct ieee80211_sta *sta, | |
542 | struct dentry *dir) | |
543 | { | |
544 | might_sleep(); | |
545 | ||
546 | sdata = get_bss_sdata(sdata); | |
547 | check_sdata_in_driver(sdata); | |
548 | ||
549 | if (local->ops->sta_remove_debugfs) | |
550 | local->ops->sta_remove_debugfs(&local->hw, &sdata->vif, | |
551 | sta, dir); | |
552 | } | |
553 | #endif | |
554 | ||
6a9d1b91 JB |
555 | static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local, |
556 | struct ieee80211_sub_if_data *sdata, | |
557 | struct sta_info *sta) | |
558 | { | |
559 | might_sleep(); | |
560 | ||
561 | sdata = get_bss_sdata(sdata); | |
f6837ba8 JB |
562 | if (!check_sdata_in_driver(sdata)) |
563 | return; | |
6a9d1b91 JB |
564 | |
565 | trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta); | |
566 | if (local->ops->sta_pre_rcu_remove) | |
567 | local->ops->sta_pre_rcu_remove(&local->hw, &sdata->vif, | |
568 | &sta->sta); | |
569 | trace_drv_return_void(local); | |
570 | } | |
571 | ||
f09603a2 JB |
572 | static inline __must_check |
573 | int drv_sta_state(struct ieee80211_local *local, | |
574 | struct ieee80211_sub_if_data *sdata, | |
575 | struct sta_info *sta, | |
576 | enum ieee80211_sta_state old_state, | |
577 | enum ieee80211_sta_state new_state) | |
578 | { | |
579 | int ret = 0; | |
580 | ||
581 | might_sleep(); | |
582 | ||
583 | sdata = get_bss_sdata(sdata); | |
f6837ba8 JB |
584 | if (!check_sdata_in_driver(sdata)) |
585 | return -EIO; | |
f09603a2 JB |
586 | |
587 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); | |
a4ec45a4 | 588 | if (local->ops->sta_state) { |
f09603a2 JB |
589 | ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta, |
590 | old_state, new_state); | |
a4ec45a4 JB |
591 | } else if (old_state == IEEE80211_STA_AUTH && |
592 | new_state == IEEE80211_STA_ASSOC) { | |
593 | ret = drv_sta_add(local, sdata, &sta->sta); | |
594 | if (ret == 0) | |
595 | sta->uploaded = true; | |
596 | } else if (old_state == IEEE80211_STA_ASSOC && | |
597 | new_state == IEEE80211_STA_AUTH) { | |
598 | drv_sta_remove(local, sdata, &sta->sta); | |
599 | } | |
f09603a2 JB |
600 | trace_drv_return_int(local, ret); |
601 | return ret; | |
602 | } | |
603 | ||
8f727ef3 JB |
604 | static inline void drv_sta_rc_update(struct ieee80211_local *local, |
605 | struct ieee80211_sub_if_data *sdata, | |
606 | struct ieee80211_sta *sta, u32 changed) | |
607 | { | |
608 | sdata = get_bss_sdata(sdata); | |
f6837ba8 JB |
609 | if (!check_sdata_in_driver(sdata)) |
610 | return; | |
8f727ef3 | 611 | |
e687f61e | 612 | WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && |
f68d776a TP |
613 | (sdata->vif.type != NL80211_IFTYPE_ADHOC && |
614 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT)); | |
e687f61e | 615 | |
8f727ef3 JB |
616 | trace_drv_sta_rc_update(local, sdata, sta, changed); |
617 | if (local->ops->sta_rc_update) | |
618 | local->ops->sta_rc_update(&local->hw, &sdata->vif, | |
619 | sta, changed); | |
620 | ||
621 | trace_drv_return_void(local); | |
622 | } | |
623 | ||
f6f3def3 | 624 | static inline int drv_conf_tx(struct ieee80211_local *local, |
a3304b0a | 625 | struct ieee80211_sub_if_data *sdata, u16 ac, |
24487981 JB |
626 | const struct ieee80211_tx_queue_params *params) |
627 | { | |
0a2b8bb2 | 628 | int ret = -EOPNOTSUPP; |
e1781ed3 KV |
629 | |
630 | might_sleep(); | |
631 | ||
f6837ba8 JB |
632 | if (!check_sdata_in_driver(sdata)) |
633 | return -EIO; | |
7b7eab6f | 634 | |
f409079b JB |
635 | if (WARN_ONCE(params->cw_min == 0 || |
636 | params->cw_min > params->cw_max, | |
637 | "%s: invalid CW_min/CW_max: %d/%d\n", | |
638 | sdata->name, params->cw_min, params->cw_max)) | |
639 | return -EINVAL; | |
640 | ||
a3304b0a | 641 | trace_drv_conf_tx(local, sdata, ac, params); |
24487981 | 642 | if (local->ops->conf_tx) |
8a3a3c85 | 643 | ret = local->ops->conf_tx(&local->hw, &sdata->vif, |
a3304b0a | 644 | ac, params); |
4efc76bd | 645 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 646 | return ret; |
24487981 JB |
647 | } |
648 | ||
37a41b4a EP |
649 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
650 | struct ieee80211_sub_if_data *sdata) | |
24487981 | 651 | { |
0a2b8bb2 | 652 | u64 ret = -1ULL; |
e1781ed3 KV |
653 | |
654 | might_sleep(); | |
655 | ||
f6837ba8 JB |
656 | if (!check_sdata_in_driver(sdata)) |
657 | return ret; | |
7b7eab6f | 658 | |
37a41b4a | 659 | trace_drv_get_tsf(local, sdata); |
24487981 | 660 | if (local->ops->get_tsf) |
37a41b4a | 661 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
4efc76bd | 662 | trace_drv_return_u64(local, ret); |
0a2b8bb2 | 663 | return ret; |
24487981 JB |
664 | } |
665 | ||
37a41b4a EP |
666 | static inline void drv_set_tsf(struct ieee80211_local *local, |
667 | struct ieee80211_sub_if_data *sdata, | |
668 | u64 tsf) | |
24487981 | 669 | { |
e1781ed3 KV |
670 | might_sleep(); |
671 | ||
f6837ba8 JB |
672 | if (!check_sdata_in_driver(sdata)) |
673 | return; | |
7b7eab6f | 674 | |
37a41b4a | 675 | trace_drv_set_tsf(local, sdata, tsf); |
24487981 | 676 | if (local->ops->set_tsf) |
37a41b4a | 677 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
4efc76bd | 678 | trace_drv_return_void(local); |
24487981 JB |
679 | } |
680 | ||
37a41b4a EP |
681 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
682 | struct ieee80211_sub_if_data *sdata) | |
24487981 | 683 | { |
e1781ed3 KV |
684 | might_sleep(); |
685 | ||
f6837ba8 JB |
686 | if (!check_sdata_in_driver(sdata)) |
687 | return; | |
7b7eab6f | 688 | |
37a41b4a | 689 | trace_drv_reset_tsf(local, sdata); |
24487981 | 690 | if (local->ops->reset_tsf) |
37a41b4a | 691 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
4efc76bd | 692 | trace_drv_return_void(local); |
24487981 JB |
693 | } |
694 | ||
695 | static inline int drv_tx_last_beacon(struct ieee80211_local *local) | |
696 | { | |
02582e9b | 697 | int ret = 0; /* default unsupported op for less congestion */ |
e1781ed3 KV |
698 | |
699 | might_sleep(); | |
700 | ||
4efc76bd | 701 | trace_drv_tx_last_beacon(local); |
24487981 | 702 | if (local->ops->tx_last_beacon) |
0a2b8bb2 | 703 | ret = local->ops->tx_last_beacon(&local->hw); |
4efc76bd | 704 | trace_drv_return_int(local, ret); |
0a2b8bb2 | 705 | return ret; |
24487981 JB |
706 | } |
707 | ||
708 | static inline int drv_ampdu_action(struct ieee80211_local *local, | |
12375ef9 | 709 | struct ieee80211_sub_if_data *sdata, |
24487981 JB |
710 | enum ieee80211_ampdu_mlme_action action, |
711 | struct ieee80211_sta *sta, u16 tid, | |
0b01f030 | 712 | u16 *ssn, u8 buf_size) |
24487981 | 713 | { |
0a2b8bb2 | 714 | int ret = -EOPNOTSUPP; |
cfcdbde3 JB |
715 | |
716 | might_sleep(); | |
717 | ||
bc192f89 | 718 | sdata = get_bss_sdata(sdata); |
f6837ba8 JB |
719 | if (!check_sdata_in_driver(sdata)) |
720 | return -EIO; | |
7b7eab6f | 721 | |
0b01f030 | 722 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
4efc76bd | 723 | |
24487981 | 724 | if (local->ops->ampdu_action) |
12375ef9 | 725 | ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action, |
0b01f030 | 726 | sta, tid, ssn, buf_size); |
85ad181e | 727 | |
4efc76bd JB |
728 | trace_drv_return_int(local, ret); |
729 | ||
0a2b8bb2 | 730 | return ret; |
24487981 | 731 | } |
1f87f7d3 | 732 | |
1289723e HS |
733 | static inline int drv_get_survey(struct ieee80211_local *local, int idx, |
734 | struct survey_info *survey) | |
735 | { | |
736 | int ret = -EOPNOTSUPP; | |
c466d4ef JL |
737 | |
738 | trace_drv_get_survey(local, idx, survey); | |
739 | ||
35dd0509 | 740 | if (local->ops->get_survey) |
1289723e | 741 | ret = local->ops->get_survey(&local->hw, idx, survey); |
c466d4ef JL |
742 | |
743 | trace_drv_return_int(local, ret); | |
744 | ||
1289723e HS |
745 | return ret; |
746 | } | |
1f87f7d3 JB |
747 | |
748 | static inline void drv_rfkill_poll(struct ieee80211_local *local) | |
749 | { | |
e1781ed3 KV |
750 | might_sleep(); |
751 | ||
1f87f7d3 JB |
752 | if (local->ops->rfkill_poll) |
753 | local->ops->rfkill_poll(&local->hw); | |
754 | } | |
a80f7c0b | 755 | |
39ecc01d | 756 | static inline void drv_flush(struct ieee80211_local *local, |
77be2c54 | 757 | struct ieee80211_sub_if_data *sdata, |
39ecc01d | 758 | u32 queues, bool drop) |
a80f7c0b | 759 | { |
77be2c54 EG |
760 | struct ieee80211_vif *vif = sdata ? &sdata->vif : NULL; |
761 | ||
e1781ed3 KV |
762 | might_sleep(); |
763 | ||
f6837ba8 JB |
764 | if (sdata && !check_sdata_in_driver(sdata)) |
765 | return; | |
77be2c54 | 766 | |
39ecc01d | 767 | trace_drv_flush(local, queues, drop); |
a80f7c0b | 768 | if (local->ops->flush) |
77be2c54 | 769 | local->ops->flush(&local->hw, vif, queues, drop); |
4efc76bd | 770 | trace_drv_return_void(local); |
a80f7c0b | 771 | } |
5ce6e438 JB |
772 | |
773 | static inline void drv_channel_switch(struct ieee80211_local *local, | |
0f791eb4 LC |
774 | struct ieee80211_sub_if_data *sdata, |
775 | struct ieee80211_channel_switch *ch_switch) | |
5ce6e438 JB |
776 | { |
777 | might_sleep(); | |
778 | ||
0f791eb4 LC |
779 | trace_drv_channel_switch(local, sdata, ch_switch); |
780 | local->ops->channel_switch(&local->hw, &sdata->vif, ch_switch); | |
4efc76bd | 781 | trace_drv_return_void(local); |
5ce6e438 JB |
782 | } |
783 | ||
15d96753 BR |
784 | |
785 | static inline int drv_set_antenna(struct ieee80211_local *local, | |
786 | u32 tx_ant, u32 rx_ant) | |
787 | { | |
788 | int ret = -EOPNOTSUPP; | |
789 | might_sleep(); | |
790 | if (local->ops->set_antenna) | |
791 | ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant); | |
792 | trace_drv_set_antenna(local, tx_ant, rx_ant, ret); | |
793 | return ret; | |
794 | } | |
795 | ||
796 | static inline int drv_get_antenna(struct ieee80211_local *local, | |
797 | u32 *tx_ant, u32 *rx_ant) | |
798 | { | |
799 | int ret = -EOPNOTSUPP; | |
800 | might_sleep(); | |
801 | if (local->ops->get_antenna) | |
802 | ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant); | |
803 | trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret); | |
804 | return ret; | |
805 | } | |
806 | ||
21f83589 | 807 | static inline int drv_remain_on_channel(struct ieee80211_local *local, |
49884568 | 808 | struct ieee80211_sub_if_data *sdata, |
21f83589 | 809 | struct ieee80211_channel *chan, |
d339d5ca IP |
810 | unsigned int duration, |
811 | enum ieee80211_roc_type type) | |
21f83589 JB |
812 | { |
813 | int ret; | |
814 | ||
815 | might_sleep(); | |
816 | ||
d339d5ca | 817 | trace_drv_remain_on_channel(local, sdata, chan, duration, type); |
49884568 | 818 | ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, |
d339d5ca | 819 | chan, duration, type); |
21f83589 JB |
820 | trace_drv_return_int(local, ret); |
821 | ||
822 | return ret; | |
823 | } | |
824 | ||
825 | static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local) | |
826 | { | |
827 | int ret; | |
828 | ||
829 | might_sleep(); | |
830 | ||
831 | trace_drv_cancel_remain_on_channel(local); | |
832 | ret = local->ops->cancel_remain_on_channel(&local->hw); | |
833 | trace_drv_return_int(local, ret); | |
5f16a436 JB |
834 | |
835 | return ret; | |
836 | } | |
837 | ||
38c09159 JL |
838 | static inline int drv_set_ringparam(struct ieee80211_local *local, |
839 | u32 tx, u32 rx) | |
840 | { | |
841 | int ret = -ENOTSUPP; | |
842 | ||
843 | might_sleep(); | |
844 | ||
845 | trace_drv_set_ringparam(local, tx, rx); | |
846 | if (local->ops->set_ringparam) | |
847 | ret = local->ops->set_ringparam(&local->hw, tx, rx); | |
848 | trace_drv_return_int(local, ret); | |
849 | ||
850 | return ret; | |
851 | } | |
852 | ||
853 | static inline void drv_get_ringparam(struct ieee80211_local *local, | |
854 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) | |
855 | { | |
856 | might_sleep(); | |
857 | ||
858 | trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max); | |
859 | if (local->ops->get_ringparam) | |
860 | local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max); | |
861 | trace_drv_return_void(local); | |
862 | } | |
863 | ||
e8306f98 VN |
864 | static inline bool drv_tx_frames_pending(struct ieee80211_local *local) |
865 | { | |
866 | bool ret = false; | |
867 | ||
868 | might_sleep(); | |
869 | ||
870 | trace_drv_tx_frames_pending(local); | |
871 | if (local->ops->tx_frames_pending) | |
872 | ret = local->ops->tx_frames_pending(&local->hw); | |
873 | trace_drv_return_bool(local, ret); | |
874 | ||
875 | return ret; | |
876 | } | |
bdbfd6b5 SM |
877 | |
878 | static inline int drv_set_bitrate_mask(struct ieee80211_local *local, | |
879 | struct ieee80211_sub_if_data *sdata, | |
880 | const struct cfg80211_bitrate_mask *mask) | |
881 | { | |
882 | int ret = -EOPNOTSUPP; | |
883 | ||
884 | might_sleep(); | |
885 | ||
f6837ba8 JB |
886 | if (!check_sdata_in_driver(sdata)) |
887 | return -EIO; | |
7b7eab6f | 888 | |
bdbfd6b5 SM |
889 | trace_drv_set_bitrate_mask(local, sdata, mask); |
890 | if (local->ops->set_bitrate_mask) | |
891 | ret = local->ops->set_bitrate_mask(&local->hw, | |
892 | &sdata->vif, mask); | |
893 | trace_drv_return_int(local, ret); | |
894 | ||
895 | return ret; | |
896 | } | |
897 | ||
c68f4b89 JB |
898 | static inline void drv_set_rekey_data(struct ieee80211_local *local, |
899 | struct ieee80211_sub_if_data *sdata, | |
900 | struct cfg80211_gtk_rekey_data *data) | |
901 | { | |
f6837ba8 JB |
902 | if (!check_sdata_in_driver(sdata)) |
903 | return; | |
7b7eab6f | 904 | |
c68f4b89 JB |
905 | trace_drv_set_rekey_data(local, sdata, data); |
906 | if (local->ops->set_rekey_data) | |
907 | local->ops->set_rekey_data(&local->hw, &sdata->vif, data); | |
908 | trace_drv_return_void(local); | |
909 | } | |
910 | ||
615f7b9b | 911 | static inline void drv_rssi_callback(struct ieee80211_local *local, |
887da917 | 912 | struct ieee80211_sub_if_data *sdata, |
615f7b9b MV |
913 | const enum ieee80211_rssi_event event) |
914 | { | |
887da917 | 915 | trace_drv_rssi_callback(local, sdata, event); |
615f7b9b | 916 | if (local->ops->rssi_callback) |
887da917 | 917 | local->ops->rssi_callback(&local->hw, &sdata->vif, event); |
615f7b9b MV |
918 | trace_drv_return_void(local); |
919 | } | |
4049e09a JB |
920 | |
921 | static inline void | |
922 | drv_release_buffered_frames(struct ieee80211_local *local, | |
923 | struct sta_info *sta, u16 tids, int num_frames, | |
924 | enum ieee80211_frame_release_type reason, | |
925 | bool more_data) | |
926 | { | |
927 | trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames, | |
928 | reason, more_data); | |
929 | if (local->ops->release_buffered_frames) | |
930 | local->ops->release_buffered_frames(&local->hw, &sta->sta, tids, | |
931 | num_frames, reason, | |
932 | more_data); | |
933 | trace_drv_return_void(local); | |
934 | } | |
40b96408 JB |
935 | |
936 | static inline void | |
937 | drv_allow_buffered_frames(struct ieee80211_local *local, | |
938 | struct sta_info *sta, u16 tids, int num_frames, | |
939 | enum ieee80211_frame_release_type reason, | |
940 | bool more_data) | |
941 | { | |
942 | trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames, | |
943 | reason, more_data); | |
944 | if (local->ops->allow_buffered_frames) | |
945 | local->ops->allow_buffered_frames(&local->hw, &sta->sta, | |
946 | tids, num_frames, reason, | |
947 | more_data); | |
948 | trace_drv_return_void(local); | |
949 | } | |
66572cfc VG |
950 | |
951 | static inline int drv_get_rssi(struct ieee80211_local *local, | |
952 | struct ieee80211_sub_if_data *sdata, | |
953 | struct ieee80211_sta *sta, | |
954 | s8 *rssi_dbm) | |
955 | { | |
956 | int ret; | |
957 | ||
958 | might_sleep(); | |
959 | ||
960 | ret = local->ops->get_rssi(&local->hw, &sdata->vif, sta, rssi_dbm); | |
961 | trace_drv_get_rssi(local, sta, *rssi_dbm, ret); | |
962 | ||
963 | return ret; | |
964 | } | |
a1845fc7 JB |
965 | |
966 | static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, | |
967 | struct ieee80211_sub_if_data *sdata) | |
968 | { | |
969 | might_sleep(); | |
970 | ||
f6837ba8 JB |
971 | if (!check_sdata_in_driver(sdata)) |
972 | return; | |
a1845fc7 JB |
973 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
974 | ||
975 | trace_drv_mgd_prepare_tx(local, sdata); | |
976 | if (local->ops->mgd_prepare_tx) | |
977 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); | |
978 | trace_drv_return_void(local); | |
979 | } | |
c3645eac | 980 | |
ee10f2c7 AN |
981 | static inline void |
982 | drv_mgd_protect_tdls_discover(struct ieee80211_local *local, | |
983 | struct ieee80211_sub_if_data *sdata) | |
984 | { | |
985 | might_sleep(); | |
986 | ||
987 | if (!check_sdata_in_driver(sdata)) | |
988 | return; | |
989 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); | |
990 | ||
991 | trace_drv_mgd_protect_tdls_discover(local, sdata); | |
992 | if (local->ops->mgd_protect_tdls_discover) | |
993 | local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif); | |
994 | trace_drv_return_void(local); | |
995 | } | |
996 | ||
c3645eac MK |
997 | static inline int drv_add_chanctx(struct ieee80211_local *local, |
998 | struct ieee80211_chanctx *ctx) | |
999 | { | |
1000 | int ret = -EOPNOTSUPP; | |
1001 | ||
1002 | trace_drv_add_chanctx(local, ctx); | |
1003 | if (local->ops->add_chanctx) | |
1004 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); | |
1005 | trace_drv_return_int(local, ret); | |
8a61af65 JB |
1006 | if (!ret) |
1007 | ctx->driver_present = true; | |
c3645eac MK |
1008 | |
1009 | return ret; | |
1010 | } | |
1011 | ||
1012 | static inline void drv_remove_chanctx(struct ieee80211_local *local, | |
1013 | struct ieee80211_chanctx *ctx) | |
1014 | { | |
f6837ba8 JB |
1015 | if (WARN_ON(!ctx->driver_present)) |
1016 | return; | |
1017 | ||
c3645eac MK |
1018 | trace_drv_remove_chanctx(local, ctx); |
1019 | if (local->ops->remove_chanctx) | |
1020 | local->ops->remove_chanctx(&local->hw, &ctx->conf); | |
1021 | trace_drv_return_void(local); | |
8a61af65 | 1022 | ctx->driver_present = false; |
c3645eac MK |
1023 | } |
1024 | ||
1025 | static inline void drv_change_chanctx(struct ieee80211_local *local, | |
1026 | struct ieee80211_chanctx *ctx, | |
1027 | u32 changed) | |
1028 | { | |
1029 | trace_drv_change_chanctx(local, ctx, changed); | |
8a61af65 JB |
1030 | if (local->ops->change_chanctx) { |
1031 | WARN_ON_ONCE(!ctx->driver_present); | |
c3645eac | 1032 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); |
8a61af65 | 1033 | } |
c3645eac MK |
1034 | trace_drv_return_void(local); |
1035 | } | |
1036 | ||
1037 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, | |
1038 | struct ieee80211_sub_if_data *sdata, | |
1039 | struct ieee80211_chanctx *ctx) | |
1040 | { | |
1041 | int ret = 0; | |
1042 | ||
f6837ba8 JB |
1043 | if (!check_sdata_in_driver(sdata)) |
1044 | return -EIO; | |
c3645eac MK |
1045 | |
1046 | trace_drv_assign_vif_chanctx(local, sdata, ctx); | |
8a61af65 JB |
1047 | if (local->ops->assign_vif_chanctx) { |
1048 | WARN_ON_ONCE(!ctx->driver_present); | |
c3645eac MK |
1049 | ret = local->ops->assign_vif_chanctx(&local->hw, |
1050 | &sdata->vif, | |
1051 | &ctx->conf); | |
8a61af65 | 1052 | } |
c3645eac MK |
1053 | trace_drv_return_int(local, ret); |
1054 | ||
1055 | return ret; | |
1056 | } | |
1057 | ||
1058 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, | |
1059 | struct ieee80211_sub_if_data *sdata, | |
1060 | struct ieee80211_chanctx *ctx) | |
1061 | { | |
f6837ba8 JB |
1062 | if (!check_sdata_in_driver(sdata)) |
1063 | return; | |
c3645eac MK |
1064 | |
1065 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); | |
8a61af65 JB |
1066 | if (local->ops->unassign_vif_chanctx) { |
1067 | WARN_ON_ONCE(!ctx->driver_present); | |
c3645eac MK |
1068 | local->ops->unassign_vif_chanctx(&local->hw, |
1069 | &sdata->vif, | |
1070 | &ctx->conf); | |
8a61af65 | 1071 | } |
c3645eac MK |
1072 | trace_drv_return_void(local); |
1073 | } | |
1074 | ||
1a5f0c13 LC |
1075 | static inline int |
1076 | drv_switch_vif_chanctx(struct ieee80211_local *local, | |
1077 | struct ieee80211_vif_chanctx_switch *vifs, | |
1078 | int n_vifs, | |
1079 | enum ieee80211_chanctx_switch_mode mode) | |
1080 | { | |
1081 | int ret = 0; | |
1082 | int i; | |
1083 | ||
1084 | if (!local->ops->switch_vif_chanctx) | |
1085 | return -EOPNOTSUPP; | |
1086 | ||
1087 | for (i = 0; i < n_vifs; i++) { | |
1088 | struct ieee80211_chanctx *new_ctx = | |
1089 | container_of(vifs[i].new_ctx, | |
1090 | struct ieee80211_chanctx, | |
1091 | conf); | |
1092 | struct ieee80211_chanctx *old_ctx = | |
1093 | container_of(vifs[i].old_ctx, | |
1094 | struct ieee80211_chanctx, | |
1095 | conf); | |
1096 | ||
1097 | WARN_ON_ONCE(!old_ctx->driver_present); | |
1098 | WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS && | |
1099 | new_ctx->driver_present) || | |
1100 | (mode == CHANCTX_SWMODE_REASSIGN_VIF && | |
1101 | !new_ctx->driver_present)); | |
1102 | } | |
1103 | ||
1104 | trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode); | |
1105 | ret = local->ops->switch_vif_chanctx(&local->hw, | |
1106 | vifs, n_vifs, mode); | |
1107 | trace_drv_return_int(local, ret); | |
1108 | ||
1109 | if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) { | |
1110 | for (i = 0; i < n_vifs; i++) { | |
1111 | struct ieee80211_chanctx *new_ctx = | |
1112 | container_of(vifs[i].new_ctx, | |
1113 | struct ieee80211_chanctx, | |
1114 | conf); | |
1115 | struct ieee80211_chanctx *old_ctx = | |
1116 | container_of(vifs[i].old_ctx, | |
1117 | struct ieee80211_chanctx, | |
1118 | conf); | |
1119 | ||
1120 | new_ctx->driver_present = true; | |
1121 | old_ctx->driver_present = false; | |
1122 | } | |
1123 | } | |
1124 | ||
1125 | return ret; | |
1126 | } | |
1127 | ||
1041638f JB |
1128 | static inline int drv_start_ap(struct ieee80211_local *local, |
1129 | struct ieee80211_sub_if_data *sdata) | |
1130 | { | |
1131 | int ret = 0; | |
1132 | ||
f6837ba8 JB |
1133 | if (!check_sdata_in_driver(sdata)) |
1134 | return -EIO; | |
1041638f JB |
1135 | |
1136 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); | |
1137 | if (local->ops->start_ap) | |
1138 | ret = local->ops->start_ap(&local->hw, &sdata->vif); | |
1139 | trace_drv_return_int(local, ret); | |
1140 | return ret; | |
1141 | } | |
1142 | ||
1143 | static inline void drv_stop_ap(struct ieee80211_local *local, | |
1144 | struct ieee80211_sub_if_data *sdata) | |
1145 | { | |
f6837ba8 JB |
1146 | if (!check_sdata_in_driver(sdata)) |
1147 | return; | |
1041638f JB |
1148 | |
1149 | trace_drv_stop_ap(local, sdata); | |
1150 | if (local->ops->stop_ap) | |
1151 | local->ops->stop_ap(&local->hw, &sdata->vif); | |
1152 | trace_drv_return_void(local); | |
1153 | } | |
1154 | ||
cf2c92d8 EP |
1155 | static inline void |
1156 | drv_reconfig_complete(struct ieee80211_local *local, | |
1157 | enum ieee80211_reconfig_type reconfig_type) | |
9214ad7f JB |
1158 | { |
1159 | might_sleep(); | |
1160 | ||
cf2c92d8 EP |
1161 | trace_drv_reconfig_complete(local, reconfig_type); |
1162 | if (local->ops->reconfig_complete) | |
1163 | local->ops->reconfig_complete(&local->hw, reconfig_type); | |
9214ad7f JB |
1164 | trace_drv_return_void(local); |
1165 | } | |
1166 | ||
de5fad81 YD |
1167 | static inline void |
1168 | drv_set_default_unicast_key(struct ieee80211_local *local, | |
1169 | struct ieee80211_sub_if_data *sdata, | |
1170 | int key_idx) | |
1171 | { | |
f6837ba8 JB |
1172 | if (!check_sdata_in_driver(sdata)) |
1173 | return; | |
de5fad81 YD |
1174 | |
1175 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); | |
1176 | ||
1177 | trace_drv_set_default_unicast_key(local, sdata, key_idx); | |
1178 | if (local->ops->set_default_unicast_key) | |
1179 | local->ops->set_default_unicast_key(&local->hw, &sdata->vif, | |
1180 | key_idx); | |
1181 | trace_drv_return_void(local); | |
1182 | } | |
1183 | ||
a65240c1 JB |
1184 | #if IS_ENABLED(CONFIG_IPV6) |
1185 | static inline void drv_ipv6_addr_change(struct ieee80211_local *local, | |
1186 | struct ieee80211_sub_if_data *sdata, | |
1187 | struct inet6_dev *idev) | |
1188 | { | |
1189 | trace_drv_ipv6_addr_change(local, sdata); | |
1190 | if (local->ops->ipv6_addr_change) | |
1191 | local->ops->ipv6_addr_change(&local->hw, &sdata->vif, idev); | |
1192 | trace_drv_return_void(local); | |
1193 | } | |
1194 | #endif | |
1195 | ||
73da7d5b SW |
1196 | static inline void |
1197 | drv_channel_switch_beacon(struct ieee80211_sub_if_data *sdata, | |
1198 | struct cfg80211_chan_def *chandef) | |
1199 | { | |
1200 | struct ieee80211_local *local = sdata->local; | |
1201 | ||
1202 | if (local->ops->channel_switch_beacon) { | |
1203 | trace_drv_channel_switch_beacon(local, sdata, chandef); | |
1204 | local->ops->channel_switch_beacon(&local->hw, &sdata->vif, | |
1205 | chandef); | |
1206 | } | |
1207 | } | |
1208 | ||
6d027bcc LC |
1209 | static inline int |
1210 | drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata, | |
1211 | struct ieee80211_channel_switch *ch_switch) | |
1212 | { | |
1213 | struct ieee80211_local *local = sdata->local; | |
1214 | int ret = 0; | |
1215 | ||
1216 | if (!check_sdata_in_driver(sdata)) | |
1217 | return -EIO; | |
1218 | ||
1219 | trace_drv_pre_channel_switch(local, sdata, ch_switch); | |
1220 | if (local->ops->pre_channel_switch) | |
1221 | ret = local->ops->pre_channel_switch(&local->hw, &sdata->vif, | |
1222 | ch_switch); | |
1223 | trace_drv_return_int(local, ret); | |
1224 | return ret; | |
1225 | } | |
1226 | ||
f1d65583 LC |
1227 | static inline int |
1228 | drv_post_channel_switch(struct ieee80211_sub_if_data *sdata) | |
1229 | { | |
1230 | struct ieee80211_local *local = sdata->local; | |
1231 | int ret = 0; | |
1232 | ||
1233 | if (!check_sdata_in_driver(sdata)) | |
1234 | return -EIO; | |
1235 | ||
1236 | trace_drv_post_channel_switch(local, sdata); | |
1237 | if (local->ops->post_channel_switch) | |
1238 | ret = local->ops->post_channel_switch(&local->hw, &sdata->vif); | |
1239 | trace_drv_return_int(local, ret); | |
1240 | return ret; | |
1241 | } | |
1242 | ||
55fff501 JB |
1243 | static inline int drv_join_ibss(struct ieee80211_local *local, |
1244 | struct ieee80211_sub_if_data *sdata) | |
1245 | { | |
1246 | int ret = 0; | |
1247 | ||
1248 | might_sleep(); | |
f6837ba8 JB |
1249 | if (!check_sdata_in_driver(sdata)) |
1250 | return -EIO; | |
55fff501 JB |
1251 | |
1252 | trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); | |
1253 | if (local->ops->join_ibss) | |
1254 | ret = local->ops->join_ibss(&local->hw, &sdata->vif); | |
1255 | trace_drv_return_int(local, ret); | |
1256 | return ret; | |
1257 | } | |
1258 | ||
1259 | static inline void drv_leave_ibss(struct ieee80211_local *local, | |
1260 | struct ieee80211_sub_if_data *sdata) | |
1261 | { | |
1262 | might_sleep(); | |
f6837ba8 JB |
1263 | if (!check_sdata_in_driver(sdata)) |
1264 | return; | |
55fff501 JB |
1265 | |
1266 | trace_drv_leave_ibss(local, sdata); | |
1267 | if (local->ops->leave_ibss) | |
1268 | local->ops->leave_ibss(&local->hw, &sdata->vif); | |
1269 | trace_drv_return_void(local); | |
1270 | } | |
1271 | ||
cca674d4 AQ |
1272 | static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, |
1273 | struct ieee80211_sta *sta) | |
1274 | { | |
1275 | u32 ret = 0; | |
1276 | ||
1277 | trace_drv_get_expected_throughput(sta); | |
1278 | if (local->ops->get_expected_throughput) | |
1279 | ret = local->ops->get_expected_throughput(sta); | |
1280 | trace_drv_return_u32(local, ret); | |
1281 | ||
1282 | return ret; | |
1283 | } | |
1284 | ||
5b3dc42b FF |
1285 | static inline int drv_get_txpower(struct ieee80211_local *local, |
1286 | struct ieee80211_sub_if_data *sdata, int *dbm) | |
1287 | { | |
1288 | int ret; | |
1289 | ||
1290 | if (!local->ops->get_txpower) | |
1291 | return -EOPNOTSUPP; | |
1292 | ||
1293 | ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm); | |
1294 | trace_drv_get_txpower(local, sdata, *dbm, ret); | |
1295 | ||
1296 | return ret; | |
1297 | } | |
1298 | ||
24487981 | 1299 | #endif /* __MAC80211_DRIVER_OPS */ |