Linux Audio

Check our new training course

Loading...
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Copyright 2015 Intel Deutschland GmbH
  4 * Copyright (C) 2022-2024 Intel Corporation
 
 
 
  5 */
  6#include <net/mac80211.h>
  7#include "ieee80211_i.h"
  8#include "trace.h"
  9#include "driver-ops.h"
 10#include "debugfs_sta.h"
 11#include "debugfs_netdev.h"
 12
 13int drv_start(struct ieee80211_local *local)
 14{
 15	int ret;
 16
 17	might_sleep();
 18	lockdep_assert_wiphy(local->hw.wiphy);
 19
 20	if (WARN_ON(local->started))
 21		return -EALREADY;
 22
 23	trace_drv_start(local);
 24	local->started = true;
 25	/* allow rx frames */
 26	smp_mb();
 27	ret = local->ops->start(&local->hw);
 28	trace_drv_return_int(local, ret);
 29
 30	if (ret)
 31		local->started = false;
 32
 33	return ret;
 34}
 35
 36void drv_stop(struct ieee80211_local *local, bool suspend)
 37{
 38	might_sleep();
 39	lockdep_assert_wiphy(local->hw.wiphy);
 40
 41	if (WARN_ON(!local->started))
 42		return;
 43
 44	trace_drv_stop(local, suspend);
 45	local->ops->stop(&local->hw, suspend);
 46	trace_drv_return_void(local);
 47
 48	/* sync away all work on the tasklet before clearing started */
 49	tasklet_disable(&local->tasklet);
 50	tasklet_enable(&local->tasklet);
 51
 52	barrier();
 53
 54	local->started = false;
 55}
 56
 57int drv_add_interface(struct ieee80211_local *local,
 58		      struct ieee80211_sub_if_data *sdata)
 59{
 60	int ret;
 61
 62	might_sleep();
 63	lockdep_assert_wiphy(local->hw.wiphy);
 64
 65	if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
 66		    (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
 67		     !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
 68		     !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR) &&
 69		     !(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))))
 70		return -EINVAL;
 71
 72	trace_drv_add_interface(local, sdata);
 73	ret = local->ops->add_interface(&local->hw, &sdata->vif);
 74	trace_drv_return_int(local, ret);
 75
 76	if (ret)
 77		return ret;
 78
 79	if (!(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) {
 80		sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
 81
 82		drv_vif_add_debugfs(local, sdata);
 83		/* initially vif is not MLD */
 84		ieee80211_link_debugfs_drv_add(&sdata->deflink);
 85	}
 86
 87	return 0;
 88}
 89
 90int drv_change_interface(struct ieee80211_local *local,
 91			 struct ieee80211_sub_if_data *sdata,
 92			 enum nl80211_iftype type, bool p2p)
 93{
 94	int ret;
 95
 96	might_sleep();
 97	lockdep_assert_wiphy(local->hw.wiphy);
 98
 99	if (!check_sdata_in_driver(sdata))
100		return -EIO;
101
102	trace_drv_change_interface(local, sdata, type, p2p);
103	ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
104	trace_drv_return_int(local, ret);
105	return ret;
106}
107
108void drv_remove_interface(struct ieee80211_local *local,
109			  struct ieee80211_sub_if_data *sdata)
110{
111	might_sleep();
112	lockdep_assert_wiphy(local->hw.wiphy);
113
114	if (!check_sdata_in_driver(sdata))
115		return;
116
117	sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
118
119	/* Remove driver debugfs entries */
120	ieee80211_debugfs_recreate_netdev(sdata, sdata->vif.valid_links);
121
122	trace_drv_remove_interface(local, sdata);
123	local->ops->remove_interface(&local->hw, &sdata->vif);
 
124	trace_drv_return_void(local);
125}
126
127__must_check
128int drv_sta_state(struct ieee80211_local *local,
129		  struct ieee80211_sub_if_data *sdata,
130		  struct sta_info *sta,
131		  enum ieee80211_sta_state old_state,
132		  enum ieee80211_sta_state new_state)
133{
134	int ret = 0;
135
136	might_sleep();
137	lockdep_assert_wiphy(local->hw.wiphy);
138
139	sdata = get_bss_sdata(sdata);
140	if (!check_sdata_in_driver(sdata))
141		return -EIO;
142
143	trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
144	if (local->ops->sta_state) {
145		ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
146					    old_state, new_state);
147	} else if (old_state == IEEE80211_STA_AUTH &&
148		   new_state == IEEE80211_STA_ASSOC) {
149		ret = drv_sta_add(local, sdata, &sta->sta);
150		if (ret == 0) {
151			sta->uploaded = true;
152			if (rcu_access_pointer(sta->sta.rates))
153				drv_sta_rate_tbl_update(local, sdata, &sta->sta);
154		}
155	} else if (old_state == IEEE80211_STA_ASSOC &&
156		   new_state == IEEE80211_STA_AUTH) {
157		drv_sta_remove(local, sdata, &sta->sta);
158	}
159	trace_drv_return_int(local, ret);
160	return ret;
161}
162
163__must_check
164int drv_sta_set_txpwr(struct ieee80211_local *local,
165		      struct ieee80211_sub_if_data *sdata,
166		      struct sta_info *sta)
167{
168	int ret = -EOPNOTSUPP;
169
170	might_sleep();
171	lockdep_assert_wiphy(local->hw.wiphy);
172
173	sdata = get_bss_sdata(sdata);
174	if (!check_sdata_in_driver(sdata))
175		return -EIO;
176
177	trace_drv_sta_set_txpwr(local, sdata, &sta->sta);
178	if (local->ops->sta_set_txpwr)
179		ret = local->ops->sta_set_txpwr(&local->hw, &sdata->vif,
180						&sta->sta);
181	trace_drv_return_int(local, ret);
182	return ret;
183}
184
185void drv_link_sta_rc_update(struct ieee80211_local *local,
186			    struct ieee80211_sub_if_data *sdata,
187			    struct ieee80211_link_sta *link_sta,
188			    u32 changed)
189{
190	sdata = get_bss_sdata(sdata);
191	if (!check_sdata_in_driver(sdata))
192		return;
193
194	WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
195		(sdata->vif.type != NL80211_IFTYPE_ADHOC &&
196		 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
197
198	trace_drv_link_sta_rc_update(local, sdata, link_sta, changed);
199	if (local->ops->link_sta_rc_update)
200		local->ops->link_sta_rc_update(&local->hw, &sdata->vif,
201					       link_sta, changed);
202
203	trace_drv_return_void(local);
204}
205
206int drv_conf_tx(struct ieee80211_local *local,
207		struct ieee80211_link_data *link, u16 ac,
208		const struct ieee80211_tx_queue_params *params)
209{
210	struct ieee80211_sub_if_data *sdata = link->sdata;
211	int ret = -EOPNOTSUPP;
212
213	might_sleep();
214	lockdep_assert_wiphy(local->hw.wiphy);
215
216	if (!check_sdata_in_driver(sdata))
217		return -EIO;
218
219	if (!ieee80211_vif_link_active(&sdata->vif, link->link_id))
220		return 0;
221
222	if (params->cw_min == 0 || params->cw_min > params->cw_max) {
223		/*
224		 * If we can't configure hardware anyway, don't warn. We may
225		 * never have initialized the CW parameters.
226		 */
227		WARN_ONCE(local->ops->conf_tx,
228			  "%s: invalid CW_min/CW_max: %d/%d\n",
229			  sdata->name, params->cw_min, params->cw_max);
230		return -EINVAL;
231	}
232
233	trace_drv_conf_tx(local, sdata, link->link_id, ac, params);
234	if (local->ops->conf_tx)
235		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
236					  link->link_id, ac, params);
237	trace_drv_return_int(local, ret);
238	return ret;
239}
240
241u64 drv_get_tsf(struct ieee80211_local *local,
242		struct ieee80211_sub_if_data *sdata)
243{
244	u64 ret = -1ULL;
245
246	might_sleep();
247	lockdep_assert_wiphy(local->hw.wiphy);
248
249	if (!check_sdata_in_driver(sdata))
250		return ret;
251
252	trace_drv_get_tsf(local, sdata);
253	if (local->ops->get_tsf)
254		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
255	trace_drv_return_u64(local, ret);
256	return ret;
257}
258
259void drv_set_tsf(struct ieee80211_local *local,
260		 struct ieee80211_sub_if_data *sdata,
261		 u64 tsf)
262{
263	might_sleep();
264	lockdep_assert_wiphy(local->hw.wiphy);
265
266	if (!check_sdata_in_driver(sdata))
267		return;
268
269	trace_drv_set_tsf(local, sdata, tsf);
270	if (local->ops->set_tsf)
271		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
272	trace_drv_return_void(local);
273}
274
275void drv_offset_tsf(struct ieee80211_local *local,
276		    struct ieee80211_sub_if_data *sdata,
277		    s64 offset)
278{
279	might_sleep();
280	lockdep_assert_wiphy(local->hw.wiphy);
281
282	if (!check_sdata_in_driver(sdata))
283		return;
284
285	trace_drv_offset_tsf(local, sdata, offset);
286	if (local->ops->offset_tsf)
287		local->ops->offset_tsf(&local->hw, &sdata->vif, offset);
288	trace_drv_return_void(local);
289}
290
291void drv_reset_tsf(struct ieee80211_local *local,
292		   struct ieee80211_sub_if_data *sdata)
293{
294	might_sleep();
295	lockdep_assert_wiphy(local->hw.wiphy);
296
297	if (!check_sdata_in_driver(sdata))
298		return;
299
300	trace_drv_reset_tsf(local, sdata);
301	if (local->ops->reset_tsf)
302		local->ops->reset_tsf(&local->hw, &sdata->vif);
303	trace_drv_return_void(local);
304}
305
306int drv_assign_vif_chanctx(struct ieee80211_local *local,
307			   struct ieee80211_sub_if_data *sdata,
308			   struct ieee80211_bss_conf *link_conf,
309			   struct ieee80211_chanctx *ctx)
310{
311	int ret = 0;
312
313	might_sleep();
314	lockdep_assert_wiphy(local->hw.wiphy);
315
316	/*
317	 * We should perhaps push emulate chanctx down and only
318	 * make it call ->config() when the chanctx is actually
319	 * assigned here (and unassigned below), but that's yet
320	 * another change to all drivers to add assign/unassign
321	 * emulation callbacks. Maybe later.
322	 */
323	if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
324	    local->emulate_chanctx &&
325	    !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF))
326		return 0;
327
328	if (!check_sdata_in_driver(sdata))
329		return -EIO;
330
331	if (!ieee80211_vif_link_active(&sdata->vif, link_conf->link_id))
332		return 0;
333
334	trace_drv_assign_vif_chanctx(local, sdata, link_conf, ctx);
335	if (local->ops->assign_vif_chanctx) {
336		WARN_ON_ONCE(!ctx->driver_present);
337		ret = local->ops->assign_vif_chanctx(&local->hw,
338						     &sdata->vif,
339						     link_conf,
340						     &ctx->conf);
341	}
342	trace_drv_return_int(local, ret);
343
344	return ret;
345}
346
347void drv_unassign_vif_chanctx(struct ieee80211_local *local,
348			      struct ieee80211_sub_if_data *sdata,
349			      struct ieee80211_bss_conf *link_conf,
350			      struct ieee80211_chanctx *ctx)
351{
352	might_sleep();
353	lockdep_assert_wiphy(local->hw.wiphy);
354
355	if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
356	    local->emulate_chanctx &&
357	    !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF))
358		return;
359
360	if (!check_sdata_in_driver(sdata))
361		return;
362
363	if (!ieee80211_vif_link_active(&sdata->vif, link_conf->link_id))
364		return;
365
366	trace_drv_unassign_vif_chanctx(local, sdata, link_conf, ctx);
367	if (local->ops->unassign_vif_chanctx) {
368		WARN_ON_ONCE(!ctx->driver_present);
369		local->ops->unassign_vif_chanctx(&local->hw,
370						 &sdata->vif,
371						 link_conf,
372						 &ctx->conf);
373	}
374	trace_drv_return_void(local);
375}
376
377int drv_switch_vif_chanctx(struct ieee80211_local *local,
378			   struct ieee80211_vif_chanctx_switch *vifs,
379			   int n_vifs, enum ieee80211_chanctx_switch_mode mode)
380{
381	int ret = 0;
382	int i;
383
384	might_sleep();
385	lockdep_assert_wiphy(local->hw.wiphy);
386
387	if (!local->ops->switch_vif_chanctx)
388		return -EOPNOTSUPP;
389
390	for (i = 0; i < n_vifs; i++) {
391		struct ieee80211_chanctx *new_ctx =
392			container_of(vifs[i].new_ctx,
393				     struct ieee80211_chanctx,
394				     conf);
395		struct ieee80211_chanctx *old_ctx =
396			container_of(vifs[i].old_ctx,
397				     struct ieee80211_chanctx,
398				     conf);
399
400		WARN_ON_ONCE(!old_ctx->driver_present);
401		WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
402			      new_ctx->driver_present) ||
403			     (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
404			      !new_ctx->driver_present));
405	}
406
407	trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
408	ret = local->ops->switch_vif_chanctx(&local->hw,
409					     vifs, n_vifs, mode);
410	trace_drv_return_int(local, ret);
411
412	if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
413		for (i = 0; i < n_vifs; i++) {
414			struct ieee80211_chanctx *new_ctx =
415				container_of(vifs[i].new_ctx,
416					     struct ieee80211_chanctx,
417					     conf);
418			struct ieee80211_chanctx *old_ctx =
419				container_of(vifs[i].old_ctx,
420					     struct ieee80211_chanctx,
421					     conf);
422
423			new_ctx->driver_present = true;
424			old_ctx->driver_present = false;
425		}
426	}
427
428	return ret;
429}
430
431int drv_ampdu_action(struct ieee80211_local *local,
432		     struct ieee80211_sub_if_data *sdata,
433		     struct ieee80211_ampdu_params *params)
434{
435	int ret = -EOPNOTSUPP;
436
437	might_sleep();
438	lockdep_assert_wiphy(local->hw.wiphy);
439
440	sdata = get_bss_sdata(sdata);
441	if (!check_sdata_in_driver(sdata))
442		return -EIO;
443
444	trace_drv_ampdu_action(local, sdata, params);
445
446	if (local->ops->ampdu_action)
447		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, params);
448
449	trace_drv_return_int(local, ret);
450
451	return ret;
452}
453
454void drv_link_info_changed(struct ieee80211_local *local,
455			   struct ieee80211_sub_if_data *sdata,
456			   struct ieee80211_bss_conf *info,
457			   int link_id, u64 changed)
458{
459	might_sleep();
460	lockdep_assert_wiphy(local->hw.wiphy);
461
462	if (WARN_ON_ONCE(changed & (BSS_CHANGED_BEACON |
463				    BSS_CHANGED_BEACON_ENABLED) &&
464			 sdata->vif.type != NL80211_IFTYPE_AP &&
465			 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
466			 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
467			 sdata->vif.type != NL80211_IFTYPE_OCB))
468		return;
469
470	if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||
471			 sdata->vif.type == NL80211_IFTYPE_NAN ||
472			 (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
473			  !sdata->vif.bss_conf.mu_mimo_owner &&
474			  !(changed & BSS_CHANGED_TXPOWER))))
475		return;
476
477	if (!check_sdata_in_driver(sdata))
478		return;
479
480	if (!ieee80211_vif_link_active(&sdata->vif, link_id))
481		return;
482
483	trace_drv_link_info_changed(local, sdata, info, changed);
484	if (local->ops->link_info_changed)
485		local->ops->link_info_changed(&local->hw, &sdata->vif,
486					      info, changed);
487	else if (local->ops->bss_info_changed)
488		local->ops->bss_info_changed(&local->hw, &sdata->vif,
489					     info, changed);
490	trace_drv_return_void(local);
491}
492
493int drv_set_key(struct ieee80211_local *local,
494		enum set_key_cmd cmd,
495		struct ieee80211_sub_if_data *sdata,
496		struct ieee80211_sta *sta,
497		struct ieee80211_key_conf *key)
498{
499	int ret;
500
501	might_sleep();
502	lockdep_assert_wiphy(local->hw.wiphy);
503
504	sdata = get_bss_sdata(sdata);
505	if (!check_sdata_in_driver(sdata))
506		return -EIO;
507
508	if (WARN_ON(key->link_id >= 0 && sdata->vif.active_links &&
509		    !(sdata->vif.active_links & BIT(key->link_id))))
510		return -ENOLINK;
511
512	trace_drv_set_key(local, cmd, sdata, sta, key);
513	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
514	trace_drv_return_int(local, ret);
515	return ret;
516}
517
518int drv_change_vif_links(struct ieee80211_local *local,
519			 struct ieee80211_sub_if_data *sdata,
520			 u16 old_links, u16 new_links,
521			 struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS])
522{
523	struct ieee80211_link_data *link;
524	unsigned long links_to_add;
525	unsigned long links_to_rem;
526	unsigned int link_id;
527	int ret = -EOPNOTSUPP;
528
529	might_sleep();
530	lockdep_assert_wiphy(local->hw.wiphy);
531
532	if (!check_sdata_in_driver(sdata))
533		return -EIO;
534
535	if (old_links == new_links)
536		return 0;
537
538	links_to_add = ~old_links & new_links;
539	links_to_rem = old_links & ~new_links;
540
541	for_each_set_bit(link_id, &links_to_rem, IEEE80211_MLD_MAX_NUM_LINKS) {
542		link = rcu_access_pointer(sdata->link[link_id]);
543
544		ieee80211_link_debugfs_drv_remove(link);
545	}
546
547	trace_drv_change_vif_links(local, sdata, old_links, new_links);
548	if (local->ops->change_vif_links)
549		ret = local->ops->change_vif_links(&local->hw, &sdata->vif,
550						   old_links, new_links, old);
551	trace_drv_return_int(local, ret);
552
553	if (ret)
554		return ret;
555
556	if (!local->in_reconfig && !local->resuming) {
557		for_each_set_bit(link_id, &links_to_add,
558				 IEEE80211_MLD_MAX_NUM_LINKS) {
559			link = rcu_access_pointer(sdata->link[link_id]);
560
561			ieee80211_link_debugfs_drv_add(link);
562		}
563	}
564
565	return 0;
566}
567
568int drv_change_sta_links(struct ieee80211_local *local,
569			 struct ieee80211_sub_if_data *sdata,
570			 struct ieee80211_sta *sta,
571			 u16 old_links, u16 new_links)
572{
573	struct sta_info *info = container_of(sta, struct sta_info, sta);
574	struct link_sta_info *link_sta;
575	unsigned long links_to_add;
576	unsigned long links_to_rem;
577	unsigned int link_id;
578	int ret = -EOPNOTSUPP;
579
580	might_sleep();
581	lockdep_assert_wiphy(local->hw.wiphy);
582
583	if (!check_sdata_in_driver(sdata))
584		return -EIO;
585
586	old_links &= sdata->vif.active_links;
587	new_links &= sdata->vif.active_links;
588
589	if (old_links == new_links)
590		return 0;
591
592	links_to_add = ~old_links & new_links;
593	links_to_rem = old_links & ~new_links;
594
595	for_each_set_bit(link_id, &links_to_rem, IEEE80211_MLD_MAX_NUM_LINKS) {
596		link_sta = rcu_dereference_protected(info->link[link_id],
597						     lockdep_is_held(&local->hw.wiphy->mtx));
598
599		ieee80211_link_sta_debugfs_drv_remove(link_sta);
600	}
601
602	trace_drv_change_sta_links(local, sdata, sta, old_links, new_links);
603	if (local->ops->change_sta_links)
604		ret = local->ops->change_sta_links(&local->hw, &sdata->vif, sta,
605						   old_links, new_links);
606	trace_drv_return_int(local, ret);
607
608	if (ret)
609		return ret;
610
611	/* during reconfig don't add it to debugfs again */
612	if (local->in_reconfig || local->resuming)
613		return 0;
614
615	for_each_set_bit(link_id, &links_to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
616		link_sta = rcu_dereference_protected(info->link[link_id],
617						     lockdep_is_held(&local->hw.wiphy->mtx));
618		ieee80211_link_sta_debugfs_drv_add(link_sta);
619	}
620
621	return 0;
622}
v4.6
 
  1/*
  2 * Copyright 2015 Intel Deutschland GmbH
  3 *
  4 * This program is free software; you can redistribute it and/or modify
  5 * it under the terms of the GNU General Public License version 2 as
  6 * published by the Free Software Foundation.
  7 */
  8#include <net/mac80211.h>
  9#include "ieee80211_i.h"
 10#include "trace.h"
 11#include "driver-ops.h"
 
 
 12
 13int drv_start(struct ieee80211_local *local)
 14{
 15	int ret;
 16
 17	might_sleep();
 
 18
 19	if (WARN_ON(local->started))
 20		return -EALREADY;
 21
 22	trace_drv_start(local);
 23	local->started = true;
 24	/* allow rx frames */
 25	smp_mb();
 26	ret = local->ops->start(&local->hw);
 27	trace_drv_return_int(local, ret);
 28
 29	if (ret)
 30		local->started = false;
 31
 32	return ret;
 33}
 34
 35void drv_stop(struct ieee80211_local *local)
 36{
 37	might_sleep();
 
 38
 39	if (WARN_ON(!local->started))
 40		return;
 41
 42	trace_drv_stop(local);
 43	local->ops->stop(&local->hw);
 44	trace_drv_return_void(local);
 45
 46	/* sync away all work on the tasklet before clearing started */
 47	tasklet_disable(&local->tasklet);
 48	tasklet_enable(&local->tasklet);
 49
 50	barrier();
 51
 52	local->started = false;
 53}
 54
 55int drv_add_interface(struct ieee80211_local *local,
 56		      struct ieee80211_sub_if_data *sdata)
 57{
 58	int ret;
 59
 60	might_sleep();
 
 61
 62	if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
 63		    (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
 64		     !ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
 65		     !(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
 
 66		return -EINVAL;
 67
 68	trace_drv_add_interface(local, sdata);
 69	ret = local->ops->add_interface(&local->hw, &sdata->vif);
 70	trace_drv_return_int(local, ret);
 71
 72	if (ret == 0)
 
 
 
 73		sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
 74
 75	return ret;
 
 
 
 
 
 76}
 77
 78int drv_change_interface(struct ieee80211_local *local,
 79			 struct ieee80211_sub_if_data *sdata,
 80			 enum nl80211_iftype type, bool p2p)
 81{
 82	int ret;
 83
 84	might_sleep();
 
 85
 86	if (!check_sdata_in_driver(sdata))
 87		return -EIO;
 88
 89	trace_drv_change_interface(local, sdata, type, p2p);
 90	ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
 91	trace_drv_return_int(local, ret);
 92	return ret;
 93}
 94
 95void drv_remove_interface(struct ieee80211_local *local,
 96			  struct ieee80211_sub_if_data *sdata)
 97{
 98	might_sleep();
 
 99
100	if (!check_sdata_in_driver(sdata))
101		return;
102
 
 
 
 
 
103	trace_drv_remove_interface(local, sdata);
104	local->ops->remove_interface(&local->hw, &sdata->vif);
105	sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
106	trace_drv_return_void(local);
107}
108
109__must_check
110int drv_sta_state(struct ieee80211_local *local,
111		  struct ieee80211_sub_if_data *sdata,
112		  struct sta_info *sta,
113		  enum ieee80211_sta_state old_state,
114		  enum ieee80211_sta_state new_state)
115{
116	int ret = 0;
117
118	might_sleep();
 
119
120	sdata = get_bss_sdata(sdata);
121	if (!check_sdata_in_driver(sdata))
122		return -EIO;
123
124	trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
125	if (local->ops->sta_state) {
126		ret = local->ops->sta_state(&local->hw, &sdata->vif, &sta->sta,
127					    old_state, new_state);
128	} else if (old_state == IEEE80211_STA_AUTH &&
129		   new_state == IEEE80211_STA_ASSOC) {
130		ret = drv_sta_add(local, sdata, &sta->sta);
131		if (ret == 0)
132			sta->uploaded = true;
 
 
 
133	} else if (old_state == IEEE80211_STA_ASSOC &&
134		   new_state == IEEE80211_STA_AUTH) {
135		drv_sta_remove(local, sdata, &sta->sta);
136	}
137	trace_drv_return_int(local, ret);
138	return ret;
139}
140
141void drv_sta_rc_update(struct ieee80211_local *local,
142		       struct ieee80211_sub_if_data *sdata,
143		       struct ieee80211_sta *sta, u32 changed)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144{
145	sdata = get_bss_sdata(sdata);
146	if (!check_sdata_in_driver(sdata))
147		return;
148
149	WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
150		(sdata->vif.type != NL80211_IFTYPE_ADHOC &&
151		 sdata->vif.type != NL80211_IFTYPE_MESH_POINT));
152
153	trace_drv_sta_rc_update(local, sdata, sta, changed);
154	if (local->ops->sta_rc_update)
155		local->ops->sta_rc_update(&local->hw, &sdata->vif,
156					  sta, changed);
157
158	trace_drv_return_void(local);
159}
160
161int drv_conf_tx(struct ieee80211_local *local,
162		struct ieee80211_sub_if_data *sdata, u16 ac,
163		const struct ieee80211_tx_queue_params *params)
164{
 
165	int ret = -EOPNOTSUPP;
166
167	might_sleep();
 
168
169	if (!check_sdata_in_driver(sdata))
170		return -EIO;
171
172	if (WARN_ONCE(params->cw_min == 0 ||
173		      params->cw_min > params->cw_max,
174		      "%s: invalid CW_min/CW_max: %d/%d\n",
175		      sdata->name, params->cw_min, params->cw_max))
 
 
 
 
 
 
 
176		return -EINVAL;
 
177
178	trace_drv_conf_tx(local, sdata, ac, params);
179	if (local->ops->conf_tx)
180		ret = local->ops->conf_tx(&local->hw, &sdata->vif,
181					  ac, params);
182	trace_drv_return_int(local, ret);
183	return ret;
184}
185
186u64 drv_get_tsf(struct ieee80211_local *local,
187		struct ieee80211_sub_if_data *sdata)
188{
189	u64 ret = -1ULL;
190
191	might_sleep();
 
192
193	if (!check_sdata_in_driver(sdata))
194		return ret;
195
196	trace_drv_get_tsf(local, sdata);
197	if (local->ops->get_tsf)
198		ret = local->ops->get_tsf(&local->hw, &sdata->vif);
199	trace_drv_return_u64(local, ret);
200	return ret;
201}
202
203void drv_set_tsf(struct ieee80211_local *local,
204		 struct ieee80211_sub_if_data *sdata,
205		 u64 tsf)
206{
207	might_sleep();
 
208
209	if (!check_sdata_in_driver(sdata))
210		return;
211
212	trace_drv_set_tsf(local, sdata, tsf);
213	if (local->ops->set_tsf)
214		local->ops->set_tsf(&local->hw, &sdata->vif, tsf);
215	trace_drv_return_void(local);
216}
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218void drv_reset_tsf(struct ieee80211_local *local,
219		   struct ieee80211_sub_if_data *sdata)
220{
221	might_sleep();
 
222
223	if (!check_sdata_in_driver(sdata))
224		return;
225
226	trace_drv_reset_tsf(local, sdata);
227	if (local->ops->reset_tsf)
228		local->ops->reset_tsf(&local->hw, &sdata->vif);
229	trace_drv_return_void(local);
230}
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232int drv_switch_vif_chanctx(struct ieee80211_local *local,
233			   struct ieee80211_vif_chanctx_switch *vifs,
234			   int n_vifs, enum ieee80211_chanctx_switch_mode mode)
235{
236	int ret = 0;
237	int i;
238
239	might_sleep();
 
240
241	if (!local->ops->switch_vif_chanctx)
242		return -EOPNOTSUPP;
243
244	for (i = 0; i < n_vifs; i++) {
245		struct ieee80211_chanctx *new_ctx =
246			container_of(vifs[i].new_ctx,
247				     struct ieee80211_chanctx,
248				     conf);
249		struct ieee80211_chanctx *old_ctx =
250			container_of(vifs[i].old_ctx,
251				     struct ieee80211_chanctx,
252				     conf);
253
254		WARN_ON_ONCE(!old_ctx->driver_present);
255		WARN_ON_ONCE((mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
256			      new_ctx->driver_present) ||
257			     (mode == CHANCTX_SWMODE_REASSIGN_VIF &&
258			      !new_ctx->driver_present));
259	}
260
261	trace_drv_switch_vif_chanctx(local, vifs, n_vifs, mode);
262	ret = local->ops->switch_vif_chanctx(&local->hw,
263					     vifs, n_vifs, mode);
264	trace_drv_return_int(local, ret);
265
266	if (!ret && mode == CHANCTX_SWMODE_SWAP_CONTEXTS) {
267		for (i = 0; i < n_vifs; i++) {
268			struct ieee80211_chanctx *new_ctx =
269				container_of(vifs[i].new_ctx,
270					     struct ieee80211_chanctx,
271					     conf);
272			struct ieee80211_chanctx *old_ctx =
273				container_of(vifs[i].old_ctx,
274					     struct ieee80211_chanctx,
275					     conf);
276
277			new_ctx->driver_present = true;
278			old_ctx->driver_present = false;
279		}
280	}
281
282	return ret;
283}
284
285int drv_ampdu_action(struct ieee80211_local *local,
286		     struct ieee80211_sub_if_data *sdata,
287		     struct ieee80211_ampdu_params *params)
288{
289	int ret = -EOPNOTSUPP;
290
291	might_sleep();
 
292
293	sdata = get_bss_sdata(sdata);
294	if (!check_sdata_in_driver(sdata))
295		return -EIO;
296
297	trace_drv_ampdu_action(local, sdata, params);
298
299	if (local->ops->ampdu_action)
300		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, params);
301
302	trace_drv_return_int(local, ret);
303
304	return ret;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305}