1 #ifndef __MAC80211_DRIVER_OPS
2 #define __MAC80211_DRIVER_OPS
3 
4 #include <net/mac80211.h>
5 #include "ieee80211_i.h"
6 #include "driver-trace.h"
7 
check_sdata_in_driver(struct ieee80211_sub_if_data * sdata)8 static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
9 {
10 	WARN_ON(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER));
11 }
12 
13 static inline struct ieee80211_sub_if_data *
get_bss_sdata(struct ieee80211_sub_if_data * sdata)14 get_bss_sdata(struct ieee80211_sub_if_data *sdata)
15 {
16 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
17 		sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
18 				     u.ap);
19 
20 	return sdata;
21 }
22 
drv_tx(struct ieee80211_local * local,struct sk_buff * skb)23 static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
24 {
25 	local->ops->tx(&local->hw, skb);
26 }
27 
drv_tx_frags(struct ieee80211_local * local,struct ieee80211_vif * vif,struct ieee80211_sta * sta,struct sk_buff_head * skbs)28 static inline void drv_tx_frags(struct ieee80211_local *local,
29 				struct ieee80211_vif *vif,
30 				struct ieee80211_sta *sta,
31 				struct sk_buff_head *skbs)
32 {
33 	local->ops->tx_frags(&local->hw, vif, sta, skbs);
34 }
35 
drv_start(struct ieee80211_local * local)36 static inline int drv_start(struct ieee80211_local *local)
37 {
38 	int ret;
39 
40 	might_sleep();
41 
42 	trace_drv_start(local);
43 	local->started = true;
44 	smp_mb();
45 	ret = local->ops->start(&local->hw);
46 	trace_drv_return_int(local, ret);
47 	return ret;
48 }
49 
drv_stop(struct ieee80211_local * local)50 static inline void drv_stop(struct ieee80211_local *local)
51 {
52 	might_sleep();
53 
54 	trace_drv_stop(local);
55 	local->ops->stop(&local->hw);
56 	trace_drv_return_void(local);
57 
58 	/* sync away all work on the tasklet before clearing started */
59 	tasklet_disable(&local->tasklet);
60 	tasklet_enable(&local->tasklet);
61 
62 	barrier();
63 
64 	local->started = false;
65 }
66 
67 #ifdef CONFIG_PM
drv_suspend(struct ieee80211_local * local,struct cfg80211_wowlan * wowlan)68 static inline int drv_suspend(struct ieee80211_local *local,
69 			      struct cfg80211_wowlan *wowlan)
70 {
71 	int ret;
72 
73 	might_sleep();
74 
75 	trace_drv_suspend(local);
76 	ret = local->ops->suspend(&local->hw, wowlan);
77 	trace_drv_return_int(local, ret);
78 	return ret;
79 }
80 
drv_resume(struct ieee80211_local * local)81 static inline int drv_resume(struct ieee80211_local *local)
82 {
83 	int ret;
84 
85 	might_sleep();
86 
87 	trace_drv_resume(local);
88 	ret = local->ops->resume(&local->hw);
89 	trace_drv_return_int(local, ret);
90 	return ret;
91 }
92 #endif
93 
drv_add_interface(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)94 static inline int drv_add_interface(struct ieee80211_local *local,
95 				    struct ieee80211_sub_if_data *sdata)
96 {
97 	int ret;
98 
99 	might_sleep();
100 
101 	if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
102 		    sdata->vif.type == NL80211_IFTYPE_MONITOR))
103 		return -EINVAL;
104 
105 	trace_drv_add_interface(local, sdata);
106 	ret = local->ops->add_interface(&local->hw, &sdata->vif);
107 	trace_drv_return_int(local, ret);
108 
109 	if (ret == 0)
110 		sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
111 
112 	return ret;
113 }
114 
drv_change_interface(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,enum nl80211_iftype type,bool p2p)115 static inline int drv_change_interface(struct ieee80211_local *local,
116 				       struct ieee80211_sub_if_data *sdata,
117 				       enum nl80211_iftype type, bool p2p)
118 {
119 	int ret;
120 
121 	might_sleep();
122 
123 	check_sdata_in_driver(sdata);
124 
125 	trace_drv_change_interface(local, sdata, type, p2p);
126 	ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
127 	trace_drv_return_int(local, ret);
128 	return ret;
129 }
130 
drv_remove_interface(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)131 static inline void drv_remove_interface(struct ieee80211_local *local,
132 					struct ieee80211_sub_if_data *sdata)
133 {
134 	might_sleep();
135 
136 	check_sdata_in_driver(sdata);
137 
138 	trace_drv_remove_interface(local, sdata);
139 	local->ops->remove_interface(&local->hw, &sdata->vif);
140 	sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
141 	trace_drv_return_void(local);
142 }
143 
drv_config(struct ieee80211_local * local,u32 changed)144 static inline int drv_config(struct ieee80211_local *local, u32 changed)
145 {
146 	int ret;
147 
148 	might_sleep();
149 
150 	trace_drv_config(local, changed);
151 	ret = local->ops->config(&local->hw, changed);
152 	trace_drv_return_int(local, ret);
153 	return ret;
154 }
155 
drv_bss_info_changed(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_bss_conf * info,u32 changed)156 static inline void drv_bss_info_changed(struct ieee80211_local *local,
157 					struct ieee80211_sub_if_data *sdata,
158 					struct ieee80211_bss_conf *info,
159 					u32 changed)
160 {
161 	might_sleep();
162 
163 	check_sdata_in_driver(sdata);
164 
165 	trace_drv_bss_info_changed(local, sdata, info, changed);
166 	if (local->ops->bss_info_changed)
167 		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
168 	trace_drv_return_void(local);
169 }
170 
drv_prepare_multicast(struct ieee80211_local * local,struct netdev_hw_addr_list * mc_list)171 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
172 					struct netdev_hw_addr_list *mc_list)
173 {
174 	u64 ret = 0;
175 
176 	trace_drv_prepare_multicast(local, mc_list->count);
177 
178 	if (local->ops->prepare_multicast)
179 		ret = local->ops->prepare_multicast(&local->hw, mc_list);
180 
181 	trace_drv_return_u64(local, ret);
182 
183 	return ret;
184 }
185 
drv_configure_filter(struct ieee80211_local * local,unsigned int changed_flags,unsigned int * total_flags,u64 multicast)186 static inline void drv_configure_filter(struct ieee80211_local *local,
187 					unsigned int changed_flags,
188 					unsigned int *total_flags,
189 					u64 multicast)
190 {
191 	might_sleep();
192 
193 	trace_drv_configure_filter(local, changed_flags, total_flags,
194 				   multicast);
195 	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
196 				     multicast);
197 	trace_drv_return_void(local);
198 }
199 
drv_set_tim(struct ieee80211_local * local,struct ieee80211_sta * sta,bool set)200 static inline int drv_set_tim(struct ieee80211_local *local,
201 			      struct ieee80211_sta *sta, bool set)
202 {
203 	int ret = 0;
204 	trace_drv_set_tim(local, sta, set);
205 	if (local->ops->set_tim)
206 		ret = local->ops->set_tim(&local->hw, sta, set);
207 	trace_drv_return_int(local, ret);
208 	return ret;
209 }
210 
drv_set_key(struct ieee80211_local * local,enum set_key_cmd cmd,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta,struct ieee80211_key_conf * key)211 static inline int drv_set_key(struct ieee80211_local *local,
212 			      enum set_key_cmd cmd,
213 			      struct ieee80211_sub_if_data *sdata,
214 			      struct ieee80211_sta *sta,
215 			      struct ieee80211_key_conf *key)
216 {
217 	int ret;
218 
219 	might_sleep();
220 
221 	sdata = get_bss_sdata(sdata);
222 	check_sdata_in_driver(sdata);
223 
224 	trace_drv_set_key(local, cmd, sdata, sta, key);
225 	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
226 	trace_drv_return_int(local, ret);
227 	return ret;
228 }
229 
drv_update_tkip_key(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_key_conf * conf,struct sta_info * sta,u32 iv32,u16 * phase1key)230 static inline void drv_update_tkip_key(struct ieee80211_local *local,
231 				       struct ieee80211_sub_if_data *sdata,
232 				       struct ieee80211_key_conf *conf,
233 				       struct sta_info *sta, u32 iv32,
234 				       u16 *phase1key)
235 {
236 	struct ieee80211_sta *ista = NULL;
237 
238 	if (sta)
239 		ista = &sta->sta;
240 
241 	sdata = get_bss_sdata(sdata);
242 	check_sdata_in_driver(sdata);
243 
244 	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
245 	if (local->ops->update_tkip_key)
246 		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
247 					    ista, iv32, phase1key);
248 	trace_drv_return_void(local);
249 }
250 
drv_hw_scan(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_scan_request * req)251 static inline int drv_hw_scan(struct ieee80211_local *local,
252 			      struct ieee80211_sub_if_data *sdata,
253 			      struct cfg80211_scan_request *req)
254 {
255 	int ret;
256 
257 	might_sleep();
258 
259 	check_sdata_in_driver(sdata);
260 
261 	trace_drv_hw_scan(local, sdata);
262 	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
263 	trace_drv_return_int(local, ret);
264 	return ret;
265 }
266 
drv_cancel_hw_scan(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)267 static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
268 				      struct ieee80211_sub_if_data *sdata)
269 {
270 	might_sleep();
271 
272 	check_sdata_in_driver(sdata);
273 
274 	trace_drv_cancel_hw_scan(local, sdata);
275 	local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
276 	trace_drv_return_void(local);
277 }
278 
279 static inline int
drv_sched_scan_start(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_sched_scan_request * req,struct ieee80211_sched_scan_ies * ies)280 drv_sched_scan_start(struct ieee80211_local *local,
281 		     struct ieee80211_sub_if_data *sdata,
282 		     struct cfg80211_sched_scan_request *req,
283 		     struct ieee80211_sched_scan_ies *ies)
284 {
285 	int ret;
286 
287 	might_sleep();
288 
289 	check_sdata_in_driver(sdata);
290 
291 	trace_drv_sched_scan_start(local, sdata);
292 	ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
293 					      req, ies);
294 	trace_drv_return_int(local, ret);
295 	return ret;
296 }
297 
drv_sched_scan_stop(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)298 static inline void drv_sched_scan_stop(struct ieee80211_local *local,
299 				       struct ieee80211_sub_if_data *sdata)
300 {
301 	might_sleep();
302 
303 	check_sdata_in_driver(sdata);
304 
305 	trace_drv_sched_scan_stop(local, sdata);
306 	local->ops->sched_scan_stop(&local->hw, &sdata->vif);
307 	trace_drv_return_void(local);
308 }
309 
drv_sw_scan_start(struct ieee80211_local * local)310 static inline void drv_sw_scan_start(struct ieee80211_local *local)
311 {
312 	might_sleep();
313 
314 	trace_drv_sw_scan_start(local);
315 	if (local->ops->sw_scan_start)
316 		local->ops->sw_scan_start(&local->hw);
317 	trace_drv_return_void(local);
318 }
319 
drv_sw_scan_complete(struct ieee80211_local * local)320 static inline void drv_sw_scan_complete(struct ieee80211_local *local)
321 {
322 	might_sleep();
323 
324 	trace_drv_sw_scan_complete(local);
325 	if (local->ops->sw_scan_complete)
326 		local->ops->sw_scan_complete(&local->hw);
327 	trace_drv_return_void(local);
328 }
329 
drv_get_stats(struct ieee80211_local * local,struct ieee80211_low_level_stats * stats)330 static inline int drv_get_stats(struct ieee80211_local *local,
331 				struct ieee80211_low_level_stats *stats)
332 {
333 	int ret = -EOPNOTSUPP;
334 
335 	might_sleep();
336 
337 	if (local->ops->get_stats)
338 		ret = local->ops->get_stats(&local->hw, stats);
339 	trace_drv_get_stats(local, stats, ret);
340 
341 	return ret;
342 }
343 
drv_get_tkip_seq(struct ieee80211_local * local,u8 hw_key_idx,u32 * iv32,u16 * iv16)344 static inline void drv_get_tkip_seq(struct ieee80211_local *local,
345 				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
346 {
347 	if (local->ops->get_tkip_seq)
348 		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
349 	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
350 }
351 
drv_set_frag_threshold(struct ieee80211_local * local,u32 value)352 static inline int drv_set_frag_threshold(struct ieee80211_local *local,
353 					u32 value)
354 {
355 	int ret = 0;
356 
357 	might_sleep();
358 
359 	trace_drv_set_frag_threshold(local, value);
360 	if (local->ops->set_frag_threshold)
361 		ret = local->ops->set_frag_threshold(&local->hw, value);
362 	trace_drv_return_int(local, ret);
363 	return ret;
364 }
365 
drv_set_rts_threshold(struct ieee80211_local * local,u32 value)366 static inline int drv_set_rts_threshold(struct ieee80211_local *local,
367 					u32 value)
368 {
369 	int ret = 0;
370 
371 	might_sleep();
372 
373 	trace_drv_set_rts_threshold(local, value);
374 	if (local->ops->set_rts_threshold)
375 		ret = local->ops->set_rts_threshold(&local->hw, value);
376 	trace_drv_return_int(local, ret);
377 	return ret;
378 }
379 
drv_set_coverage_class(struct ieee80211_local * local,u8 value)380 static inline int drv_set_coverage_class(struct ieee80211_local *local,
381 					 u8 value)
382 {
383 	int ret = 0;
384 	might_sleep();
385 
386 	trace_drv_set_coverage_class(local, value);
387 	if (local->ops->set_coverage_class)
388 		local->ops->set_coverage_class(&local->hw, value);
389 	else
390 		ret = -EOPNOTSUPP;
391 
392 	trace_drv_return_int(local, ret);
393 	return ret;
394 }
395 
drv_sta_notify(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,enum sta_notify_cmd cmd,struct ieee80211_sta * sta)396 static inline void drv_sta_notify(struct ieee80211_local *local,
397 				  struct ieee80211_sub_if_data *sdata,
398 				  enum sta_notify_cmd cmd,
399 				  struct ieee80211_sta *sta)
400 {
401 	sdata = get_bss_sdata(sdata);
402 	check_sdata_in_driver(sdata);
403 
404 	trace_drv_sta_notify(local, sdata, cmd, sta);
405 	if (local->ops->sta_notify)
406 		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
407 	trace_drv_return_void(local);
408 }
409 
drv_sta_add(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta)410 static inline int drv_sta_add(struct ieee80211_local *local,
411 			      struct ieee80211_sub_if_data *sdata,
412 			      struct ieee80211_sta *sta)
413 {
414 	int ret = 0;
415 
416 	might_sleep();
417 
418 	sdata = get_bss_sdata(sdata);
419 	check_sdata_in_driver(sdata);
420 
421 	trace_drv_sta_add(local, sdata, sta);
422 	if (local->ops->sta_add)
423 		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);
424 
425 	trace_drv_return_int(local, ret);
426 
427 	return ret;
428 }
429 
drv_sta_remove(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct ieee80211_sta * sta)430 static inline void drv_sta_remove(struct ieee80211_local *local,
431 				  struct ieee80211_sub_if_data *sdata,
432 				  struct ieee80211_sta *sta)
433 {
434 	might_sleep();
435 
436 	sdata = get_bss_sdata(sdata);
437 	check_sdata_in_driver(sdata);
438 
439 	trace_drv_sta_remove(local, sdata, sta);
440 	if (local->ops->sta_remove)
441 		local->ops->sta_remove(&local->hw, &sdata->vif, sta);
442 
443 	trace_drv_return_void(local);
444 }
445 
446 static inline __must_check
drv_sta_state(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct sta_info * sta,enum ieee80211_sta_state old_state,enum ieee80211_sta_state new_state)447 int drv_sta_state(struct ieee80211_local *local,
448 		  struct ieee80211_sub_if_data *sdata,
449 		  struct sta_info *sta,
450 		  enum ieee80211_sta_state old_state,
451 		  enum ieee80211_sta_state new_state)
452 {
453 	int ret = 0;
454 
455 	might_sleep();
456 
457 	sdata = get_bss_sdata(sdata);
458 	check_sdata_in_driver(sdata);
459 
460 	trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
461 	if (local->ops->sta_state) {
462 		ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
463 					    old_state, new_state);
464 	} else if (old_state == IEEE80211_STA_AUTH &&
465 		   new_state == IEEE80211_STA_ASSOC) {
466 		ret = drv_sta_add(local, sdata, &sta->sta);
467 		if (ret == 0)
468 			sta->uploaded = true;
469 	} else if (old_state == IEEE80211_STA_ASSOC &&
470 		   new_state == IEEE80211_STA_AUTH) {
471 		drv_sta_remove(local, sdata, &sta->sta);
472 	}
473 	trace_drv_return_int(local, ret);
474 	return ret;
475 }
476 
drv_conf_tx(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,u16 queue,const struct ieee80211_tx_queue_params * params)477 static inline int drv_conf_tx(struct ieee80211_local *local,
478 			      struct ieee80211_sub_if_data *sdata, u16 queue,
479 			      const struct ieee80211_tx_queue_params *params)
480 {
481 	int ret = -EOPNOTSUPP;
482 
483 	might_sleep();
484 
485 	check_sdata_in_driver(sdata);
486 
487 	trace_drv_conf_tx(local, sdata, queue, params);
488 	if (local->ops->conf_tx)
489 		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
490 					  queue, params);
491 	trace_drv_return_int(local, ret);
492 	return ret;
493 }
494 
drv_get_tsf(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)495 static inline u64 drv_get_tsf(struct ieee80211_local *local,
496 			      struct ieee80211_sub_if_data *sdata)
497 {
498 	u64 ret = -1ULL;
499 
500 	might_sleep();
501 
502 	check_sdata_in_driver(sdata);
503 
504 	trace_drv_get_tsf(local, sdata);
505 	if (local->ops->get_tsf)
506 		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
507 	trace_drv_return_u64(local, ret);
508 	return ret;
509 }
510 
drv_set_tsf(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,u64 tsf)511 static inline void drv_set_tsf(struct ieee80211_local *local,
512 			       struct ieee80211_sub_if_data *sdata,
513 			       u64 tsf)
514 {
515 	might_sleep();
516 
517 	check_sdata_in_driver(sdata);
518 
519 	trace_drv_set_tsf(local, sdata, tsf);
520 	if (local->ops->set_tsf)
521 		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
522 	trace_drv_return_void(local);
523 }
524 
drv_reset_tsf(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata)525 static inline void drv_reset_tsf(struct ieee80211_local *local,
526 				 struct ieee80211_sub_if_data *sdata)
527 {
528 	might_sleep();
529 
530 	check_sdata_in_driver(sdata);
531 
532 	trace_drv_reset_tsf(local, sdata);
533 	if (local->ops->reset_tsf)
534 		local->ops->reset_tsf(&local->hw, &sdata->vif);
535 	trace_drv_return_void(local);
536 }
537 
drv_tx_last_beacon(struct ieee80211_local * local)538 static inline int drv_tx_last_beacon(struct ieee80211_local *local)
539 {
540 	int ret = 0; /* default unsuported op for less congestion */
541 
542 	might_sleep();
543 
544 	trace_drv_tx_last_beacon(local);
545 	if (local->ops->tx_last_beacon)
546 		ret = local->ops->tx_last_beacon(&local->hw);
547 	trace_drv_return_int(local, ret);
548 	return ret;
549 }
550 
drv_ampdu_action(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,enum ieee80211_ampdu_mlme_action action,struct ieee80211_sta * sta,u16 tid,u16 * ssn,u8 buf_size)551 static inline int drv_ampdu_action(struct ieee80211_local *local,
552 				   struct ieee80211_sub_if_data *sdata,
553 				   enum ieee80211_ampdu_mlme_action action,
554 				   struct ieee80211_sta *sta, u16 tid,
555 				   u16 *ssn, u8 buf_size)
556 {
557 	int ret = -EOPNOTSUPP;
558 
559 	might_sleep();
560 
561 	sdata = get_bss_sdata(sdata);
562 	check_sdata_in_driver(sdata);
563 
564 	trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
565 
566 	if (local->ops->ampdu_action)
567 		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
568 					       sta, tid, ssn, buf_size);
569 
570 	trace_drv_return_int(local, ret);
571 
572 	return ret;
573 }
574 
drv_get_survey(struct ieee80211_local * local,int idx,struct survey_info * survey)575 static inline int drv_get_survey(struct ieee80211_local *local, int idx,
576 				struct survey_info *survey)
577 {
578 	int ret = -EOPNOTSUPP;
579 
580 	trace_drv_get_survey(local, idx, survey);
581 
582 	if (local->ops->get_survey)
583 		ret = local->ops->get_survey(&local->hw, idx, survey);
584 
585 	trace_drv_return_int(local, ret);
586 
587 	return ret;
588 }
589 
drv_rfkill_poll(struct ieee80211_local * local)590 static inline void drv_rfkill_poll(struct ieee80211_local *local)
591 {
592 	might_sleep();
593 
594 	if (local->ops->rfkill_poll)
595 		local->ops->rfkill_poll(&local->hw);
596 }
597 
drv_flush(struct ieee80211_local * local,bool drop)598 static inline void drv_flush(struct ieee80211_local *local, bool drop)
599 {
600 	might_sleep();
601 
602 	trace_drv_flush(local, drop);
603 	if (local->ops->flush)
604 		local->ops->flush(&local->hw, drop);
605 	trace_drv_return_void(local);
606 }
607 
drv_channel_switch(struct ieee80211_local * local,struct ieee80211_channel_switch * ch_switch)608 static inline void drv_channel_switch(struct ieee80211_local *local,
609 				     struct ieee80211_channel_switch *ch_switch)
610 {
611 	might_sleep();
612 
613 	trace_drv_channel_switch(local, ch_switch);
614 	local->ops->channel_switch(&local->hw, ch_switch);
615 	trace_drv_return_void(local);
616 }
617 
618 
drv_set_antenna(struct ieee80211_local * local,u32 tx_ant,u32 rx_ant)619 static inline int drv_set_antenna(struct ieee80211_local *local,
620 				  u32 tx_ant, u32 rx_ant)
621 {
622 	int ret = -EOPNOTSUPP;
623 	might_sleep();
624 	if (local->ops->set_antenna)
625 		ret = local->ops->set_antenna(&local->hw, tx_ant, rx_ant);
626 	trace_drv_set_antenna(local, tx_ant, rx_ant, ret);
627 	return ret;
628 }
629 
drv_get_antenna(struct ieee80211_local * local,u32 * tx_ant,u32 * rx_ant)630 static inline int drv_get_antenna(struct ieee80211_local *local,
631 				  u32 *tx_ant, u32 *rx_ant)
632 {
633 	int ret = -EOPNOTSUPP;
634 	might_sleep();
635 	if (local->ops->get_antenna)
636 		ret = local->ops->get_antenna(&local->hw, tx_ant, rx_ant);
637 	trace_drv_get_antenna(local, *tx_ant, *rx_ant, ret);
638 	return ret;
639 }
640 
drv_remain_on_channel(struct ieee80211_local * local,struct ieee80211_channel * chan,enum nl80211_channel_type chantype,unsigned int duration)641 static inline int drv_remain_on_channel(struct ieee80211_local *local,
642 					struct ieee80211_channel *chan,
643 					enum nl80211_channel_type chantype,
644 					unsigned int duration)
645 {
646 	int ret;
647 
648 	might_sleep();
649 
650 	trace_drv_remain_on_channel(local, chan, chantype, duration);
651 	ret = local->ops->remain_on_channel(&local->hw, chan, chantype,
652 					    duration);
653 	trace_drv_return_int(local, ret);
654 
655 	return ret;
656 }
657 
drv_cancel_remain_on_channel(struct ieee80211_local * local)658 static inline int drv_cancel_remain_on_channel(struct ieee80211_local *local)
659 {
660 	int ret;
661 
662 	might_sleep();
663 
664 	trace_drv_cancel_remain_on_channel(local);
665 	ret = local->ops->cancel_remain_on_channel(&local->hw);
666 	trace_drv_return_int(local, ret);
667 
668 	return ret;
669 }
670 
drv_set_ringparam(struct ieee80211_local * local,u32 tx,u32 rx)671 static inline int drv_set_ringparam(struct ieee80211_local *local,
672 				    u32 tx, u32 rx)
673 {
674 	int ret = -ENOTSUPP;
675 
676 	might_sleep();
677 
678 	trace_drv_set_ringparam(local, tx, rx);
679 	if (local->ops->set_ringparam)
680 		ret = local->ops->set_ringparam(&local->hw, tx, rx);
681 	trace_drv_return_int(local, ret);
682 
683 	return ret;
684 }
685 
drv_get_ringparam(struct ieee80211_local * local,u32 * tx,u32 * tx_max,u32 * rx,u32 * rx_max)686 static inline void drv_get_ringparam(struct ieee80211_local *local,
687 				     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
688 {
689 	might_sleep();
690 
691 	trace_drv_get_ringparam(local, tx, tx_max, rx, rx_max);
692 	if (local->ops->get_ringparam)
693 		local->ops->get_ringparam(&local->hw, tx, tx_max, rx, rx_max);
694 	trace_drv_return_void(local);
695 }
696 
drv_tx_frames_pending(struct ieee80211_local * local)697 static inline bool drv_tx_frames_pending(struct ieee80211_local *local)
698 {
699 	bool ret = false;
700 
701 	might_sleep();
702 
703 	trace_drv_tx_frames_pending(local);
704 	if (local->ops->tx_frames_pending)
705 		ret = local->ops->tx_frames_pending(&local->hw);
706 	trace_drv_return_bool(local, ret);
707 
708 	return ret;
709 }
710 
drv_set_bitrate_mask(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,const struct cfg80211_bitrate_mask * mask)711 static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
712 				       struct ieee80211_sub_if_data *sdata,
713 				       const struct cfg80211_bitrate_mask *mask)
714 {
715 	int ret = -EOPNOTSUPP;
716 
717 	might_sleep();
718 
719 	check_sdata_in_driver(sdata);
720 
721 	trace_drv_set_bitrate_mask(local, sdata, mask);
722 	if (local->ops->set_bitrate_mask)
723 		ret = local->ops->set_bitrate_mask(&local->hw,
724 						   &sdata->vif, mask);
725 	trace_drv_return_int(local, ret);
726 
727 	return ret;
728 }
729 
drv_set_rekey_data(struct ieee80211_local * local,struct ieee80211_sub_if_data * sdata,struct cfg80211_gtk_rekey_data * data)730 static inline void drv_set_rekey_data(struct ieee80211_local *local,
731 				      struct ieee80211_sub_if_data *sdata,
732 				      struct cfg80211_gtk_rekey_data *data)
733 {
734 	check_sdata_in_driver(sdata);
735 
736 	trace_drv_set_rekey_data(local, sdata, data);
737 	if (local->ops->set_rekey_data)
738 		local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
739 	trace_drv_return_void(local);
740 }
741 
drv_rssi_callback(struct ieee80211_local * local,const enum ieee80211_rssi_event event)742 static inline void drv_rssi_callback(struct ieee80211_local *local,
743 				     const enum ieee80211_rssi_event event)
744 {
745 	trace_drv_rssi_callback(local, event);
746 	if (local->ops->rssi_callback)
747 		local->ops->rssi_callback(&local->hw, event);
748 	trace_drv_return_void(local);
749 }
750 
751 static inline void
drv_release_buffered_frames(struct ieee80211_local * local,struct sta_info * sta,u16 tids,int num_frames,enum ieee80211_frame_release_type reason,bool more_data)752 drv_release_buffered_frames(struct ieee80211_local *local,
753 			    struct sta_info *sta, u16 tids, int num_frames,
754 			    enum ieee80211_frame_release_type reason,
755 			    bool more_data)
756 {
757 	trace_drv_release_buffered_frames(local, &sta->sta, tids, num_frames,
758 					  reason, more_data);
759 	if (local->ops->release_buffered_frames)
760 		local->ops->release_buffered_frames(&local->hw, &sta->sta, tids,
761 						    num_frames, reason,
762 						    more_data);
763 	trace_drv_return_void(local);
764 }
765 
766 static inline void
drv_allow_buffered_frames(struct ieee80211_local * local,struct sta_info * sta,u16 tids,int num_frames,enum ieee80211_frame_release_type reason,bool more_data)767 drv_allow_buffered_frames(struct ieee80211_local *local,
768 			  struct sta_info *sta, u16 tids, int num_frames,
769 			  enum ieee80211_frame_release_type reason,
770 			  bool more_data)
771 {
772 	trace_drv_allow_buffered_frames(local, &sta->sta, tids, num_frames,
773 					reason, more_data);
774 	if (local->ops->allow_buffered_frames)
775 		local->ops->allow_buffered_frames(&local->hw, &sta->sta,
776 						  tids, num_frames, reason,
777 						  more_data);
778 	trace_drv_return_void(local);
779 }
780 #endif /* __MAC80211_DRIVER_OPS */
781