driver-ops.h 10.2 KB
Newer Older
1 2 3 4 5
#ifndef __MAC80211_DRIVER_OPS
#define __MAC80211_DRIVER_OPS

#include <net/mac80211.h>
#include "ieee80211_i.h"
6
#include "driver-trace.h"
7 8 9 10 11 12 13 14

static inline int drv_tx(struct ieee80211_local *local, struct sk_buff *skb)
{
	return local->ops->tx(&local->hw, skb);
}

static inline int drv_start(struct ieee80211_local *local)
{
15 16
	int ret;

17 18
	might_sleep();

J
Johannes Berg 已提交
19
	trace_drv_start(local);
20 21 22
	local->started = true;
	smp_mb();
	ret = local->ops->start(&local->hw);
J
Johannes Berg 已提交
23
	trace_drv_return_int(local, ret);
24
	return ret;
25 26 27 28
}

static inline void drv_stop(struct ieee80211_local *local)
{
29 30
	might_sleep();

31
	trace_drv_stop(local);
J
Johannes Berg 已提交
32 33
	local->ops->stop(&local->hw);
	trace_drv_return_void(local);
34 35 36 37 38 39 40 41

	/* sync away all work on the tasklet before clearing started */
	tasklet_disable(&local->tasklet);
	tasklet_enable(&local->tasklet);

	barrier();

	local->started = false;
42 43 44
}

static inline int drv_add_interface(struct ieee80211_local *local,
45
				    struct ieee80211_vif *vif)
46
{
47 48 49 50
	int ret;

	might_sleep();

J
Johannes Berg 已提交
51
	trace_drv_add_interface(local, vif_to_sdata(vif));
52
	ret = local->ops->add_interface(&local->hw, vif);
J
Johannes Berg 已提交
53
	trace_drv_return_int(local, ret);
54
	return ret;
55 56
}

57 58
static inline int drv_change_interface(struct ieee80211_local *local,
				       struct ieee80211_sub_if_data *sdata,
59
				       enum nl80211_iftype type, bool p2p)
60 61 62 63 64
{
	int ret;

	might_sleep();

65 66
	trace_drv_change_interface(local, sdata, type, p2p);
	ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
67 68 69 70
	trace_drv_return_int(local, ret);
	return ret;
}

71
static inline void drv_remove_interface(struct ieee80211_local *local,
72
					struct ieee80211_vif *vif)
73
{
74 75
	might_sleep();

76
	trace_drv_remove_interface(local, vif_to_sdata(vif));
J
Johannes Berg 已提交
77 78
	local->ops->remove_interface(&local->hw, vif);
	trace_drv_return_void(local);
79 80 81 82
}

static inline int drv_config(struct ieee80211_local *local, u32 changed)
{
83 84 85 86
	int ret;

	might_sleep();

J
Johannes Berg 已提交
87
	trace_drv_config(local, changed);
88
	ret = local->ops->config(&local->hw, changed);
J
Johannes Berg 已提交
89
	trace_drv_return_int(local, ret);
90
	return ret;
91 92 93
}

static inline void drv_bss_info_changed(struct ieee80211_local *local,
J
Johannes Berg 已提交
94
					struct ieee80211_sub_if_data *sdata,
95 96 97
					struct ieee80211_bss_conf *info,
					u32 changed)
{
98 99
	might_sleep();

J
Johannes Berg 已提交
100
	trace_drv_bss_info_changed(local, sdata, info, changed);
101
	if (local->ops->bss_info_changed)
J
Johannes Berg 已提交
102
		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
J
Johannes Berg 已提交
103
	trace_drv_return_void(local);
104 105
}

106
static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
107
					struct netdev_hw_addr_list *mc_list)
108 109 110
{
	u64 ret = 0;

J
Johannes Berg 已提交
111 112
	trace_drv_prepare_multicast(local, mc_list->count);

113
	if (local->ops->prepare_multicast)
114
		ret = local->ops->prepare_multicast(&local->hw, mc_list);
115

J
Johannes Berg 已提交
116
	trace_drv_return_u64(local, ret);
117 118 119 120

	return ret;
}

121 122 123
static inline void drv_configure_filter(struct ieee80211_local *local,
					unsigned int changed_flags,
					unsigned int *total_flags,
124
					u64 multicast)
125
{
126 127
	might_sleep();

128
	trace_drv_configure_filter(local, changed_flags, total_flags,
129
				   multicast);
J
Johannes Berg 已提交
130 131 132
	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
				     multicast);
	trace_drv_return_void(local);
133 134 135 136 137
}

static inline int drv_set_tim(struct ieee80211_local *local,
			      struct ieee80211_sta *sta, bool set)
{
138
	int ret = 0;
J
Johannes Berg 已提交
139
	trace_drv_set_tim(local, sta, set);
140
	if (local->ops->set_tim)
141
		ret = local->ops->set_tim(&local->hw, sta, set);
J
Johannes Berg 已提交
142
	trace_drv_return_int(local, ret);
143
	return ret;
144 145 146
}

static inline int drv_set_key(struct ieee80211_local *local,
J
Johannes Berg 已提交
147 148
			      enum set_key_cmd cmd,
			      struct ieee80211_sub_if_data *sdata,
149 150 151
			      struct ieee80211_sta *sta,
			      struct ieee80211_key_conf *key)
{
152 153 154 155
	int ret;

	might_sleep();

J
Johannes Berg 已提交
156
	trace_drv_set_key(local, cmd, sdata, sta, key);
157
	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
J
Johannes Berg 已提交
158
	trace_drv_return_int(local, ret);
159
	return ret;
160 161 162
}

static inline void drv_update_tkip_key(struct ieee80211_local *local,
163
				       struct ieee80211_sub_if_data *sdata,
164
				       struct ieee80211_key_conf *conf,
165
				       struct sta_info *sta, u32 iv32,
166 167
				       u16 *phase1key)
{
168 169 170 171 172
	struct ieee80211_sta *ista = NULL;

	if (sta)
		ista = &sta->sta;

J
Johannes Berg 已提交
173
	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
174
	if (local->ops->update_tkip_key)
175 176
		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
					    ista, iv32, phase1key);
J
Johannes Berg 已提交
177
	trace_drv_return_void(local);
178 179 180
}

static inline int drv_hw_scan(struct ieee80211_local *local,
181
			      struct ieee80211_sub_if_data *sdata,
182 183
			      struct cfg80211_scan_request *req)
{
184 185 186 187
	int ret;

	might_sleep();

J
Johannes Berg 已提交
188
	trace_drv_hw_scan(local, sdata, req);
189
	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
J
Johannes Berg 已提交
190
	trace_drv_return_int(local, ret);
191
	return ret;
192 193 194 195
}

static inline void drv_sw_scan_start(struct ieee80211_local *local)
{
196 197
	might_sleep();

J
Johannes Berg 已提交
198
	trace_drv_sw_scan_start(local);
199 200
	if (local->ops->sw_scan_start)
		local->ops->sw_scan_start(&local->hw);
J
Johannes Berg 已提交
201
	trace_drv_return_void(local);
202 203 204 205
}

static inline void drv_sw_scan_complete(struct ieee80211_local *local)
{
206 207
	might_sleep();

J
Johannes Berg 已提交
208
	trace_drv_sw_scan_complete(local);
209 210
	if (local->ops->sw_scan_complete)
		local->ops->sw_scan_complete(&local->hw);
J
Johannes Berg 已提交
211
	trace_drv_return_void(local);
212 213 214 215 216
}

static inline int drv_get_stats(struct ieee80211_local *local,
				struct ieee80211_low_level_stats *stats)
{
217 218
	int ret = -EOPNOTSUPP;

219 220
	might_sleep();

221 222 223 224 225
	if (local->ops->get_stats)
		ret = local->ops->get_stats(&local->hw, stats);
	trace_drv_get_stats(local, stats, ret);

	return ret;
226 227 228 229 230 231 232
}

static inline void drv_get_tkip_seq(struct ieee80211_local *local,
				    u8 hw_key_idx, u32 *iv32, u16 *iv16)
{
	if (local->ops->get_tkip_seq)
		local->ops->get_tkip_seq(&local->hw, hw_key_idx, iv32, iv16);
233
	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
234 235
}

236 237 238 239 240 241 242 243 244 245 246 247 248 249
static inline int drv_set_frag_threshold(struct ieee80211_local *local,
					u32 value)
{
	int ret = 0;

	might_sleep();

	trace_drv_set_frag_threshold(local, value);
	if (local->ops->set_frag_threshold)
		ret = local->ops->set_frag_threshold(&local->hw, value);
	trace_drv_return_int(local, ret);
	return ret;
}

250 251 252
static inline int drv_set_rts_threshold(struct ieee80211_local *local,
					u32 value)
{
253
	int ret = 0;
254 255 256

	might_sleep();

J
Johannes Berg 已提交
257
	trace_drv_set_rts_threshold(local, value);
258
	if (local->ops->set_rts_threshold)
259
		ret = local->ops->set_rts_threshold(&local->hw, value);
J
Johannes Berg 已提交
260
	trace_drv_return_int(local, ret);
261
	return ret;
262 263
}

264 265 266 267 268 269
static inline int drv_set_coverage_class(struct ieee80211_local *local,
					 u8 value)
{
	int ret = 0;
	might_sleep();

J
Johannes Berg 已提交
270
	trace_drv_set_coverage_class(local, value);
271 272 273 274 275
	if (local->ops->set_coverage_class)
		local->ops->set_coverage_class(&local->hw, value);
	else
		ret = -EOPNOTSUPP;

J
Johannes Berg 已提交
276
	trace_drv_return_int(local, ret);
277 278 279
	return ret;
}

280
static inline void drv_sta_notify(struct ieee80211_local *local,
J
Johannes Berg 已提交
281
				  struct ieee80211_sub_if_data *sdata,
282 283 284
				  enum sta_notify_cmd cmd,
				  struct ieee80211_sta *sta)
{
J
Johannes Berg 已提交
285
	trace_drv_sta_notify(local, sdata, cmd, sta);
286
	if (local->ops->sta_notify)
J
Johannes Berg 已提交
287
		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
J
Johannes Berg 已提交
288
	trace_drv_return_void(local);
289 290
}

291 292 293 294 295 296 297 298
static inline int drv_sta_add(struct ieee80211_local *local,
			      struct ieee80211_sub_if_data *sdata,
			      struct ieee80211_sta *sta)
{
	int ret = 0;

	might_sleep();

J
Johannes Berg 已提交
299
	trace_drv_sta_add(local, sdata, sta);
300 301 302
	if (local->ops->sta_add)
		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);

J
Johannes Berg 已提交
303
	trace_drv_return_int(local, ret);
304 305 306 307 308 309 310 311 312 313

	return ret;
}

static inline void drv_sta_remove(struct ieee80211_local *local,
				  struct ieee80211_sub_if_data *sdata,
				  struct ieee80211_sta *sta)
{
	might_sleep();

J
Johannes Berg 已提交
314
	trace_drv_sta_remove(local, sdata, sta);
315 316 317
	if (local->ops->sta_remove)
		local->ops->sta_remove(&local->hw, &sdata->vif, sta);

J
Johannes Berg 已提交
318
	trace_drv_return_void(local);
319 320
}

321 322 323
static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
			      const struct ieee80211_tx_queue_params *params)
{
324
	int ret = -EOPNOTSUPP;
325 326 327

	might_sleep();

J
Johannes Berg 已提交
328
	trace_drv_conf_tx(local, queue, params);
329
	if (local->ops->conf_tx)
330
		ret = local->ops->conf_tx(&local->hw, queue, params);
J
Johannes Berg 已提交
331
	trace_drv_return_int(local, ret);
332
	return ret;
333 334 335 336
}

static inline u64 drv_get_tsf(struct ieee80211_local *local)
{
337
	u64 ret = -1ULL;
338 339 340

	might_sleep();

J
Johannes Berg 已提交
341
	trace_drv_get_tsf(local);
342
	if (local->ops->get_tsf)
343
		ret = local->ops->get_tsf(&local->hw);
J
Johannes Berg 已提交
344
	trace_drv_return_u64(local, ret);
345
	return ret;
346 347 348 349
}

static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf)
{
350 351
	might_sleep();

J
Johannes Berg 已提交
352
	trace_drv_set_tsf(local, tsf);
353 354
	if (local->ops->set_tsf)
		local->ops->set_tsf(&local->hw, tsf);
J
Johannes Berg 已提交
355
	trace_drv_return_void(local);
356 357 358 359
}

static inline void drv_reset_tsf(struct ieee80211_local *local)
{
360 361
	might_sleep();

J
Johannes Berg 已提交
362
	trace_drv_reset_tsf(local);
363 364
	if (local->ops->reset_tsf)
		local->ops->reset_tsf(&local->hw);
J
Johannes Berg 已提交
365
	trace_drv_return_void(local);
366 367 368 369
}

static inline int drv_tx_last_beacon(struct ieee80211_local *local)
{
370
	int ret = 1;
371 372 373

	might_sleep();

J
Johannes Berg 已提交
374
	trace_drv_tx_last_beacon(local);
375
	if (local->ops->tx_last_beacon)
376
		ret = local->ops->tx_last_beacon(&local->hw);
J
Johannes Berg 已提交
377
	trace_drv_return_int(local, ret);
378
	return ret;
379 380 381
}

static inline int drv_ampdu_action(struct ieee80211_local *local,
J
Johannes Berg 已提交
382
				   struct ieee80211_sub_if_data *sdata,
383 384 385 386
				   enum ieee80211_ampdu_mlme_action action,
				   struct ieee80211_sta *sta, u16 tid,
				   u16 *ssn)
{
387
	int ret = -EOPNOTSUPP;
388 389 390

	might_sleep();

J
Johannes Berg 已提交
391 392
	trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn);

393
	if (local->ops->ampdu_action)
J
Johannes Berg 已提交
394
		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
395
					       sta, tid, ssn);
396

J
Johannes Berg 已提交
397 398
	trace_drv_return_int(local, ret);

399
	return ret;
400
}
J
Johannes Berg 已提交
401

402 403 404 405
static inline int drv_get_survey(struct ieee80211_local *local, int idx,
				struct survey_info *survey)
{
	int ret = -EOPNOTSUPP;
406 407 408

	trace_drv_get_survey(local, idx, survey);

409
	if (local->ops->get_survey)
410
		ret = local->ops->get_survey(&local->hw, idx, survey);
411 412 413

	trace_drv_return_int(local, ret);

414 415
	return ret;
}
J
Johannes Berg 已提交
416 417 418

static inline void drv_rfkill_poll(struct ieee80211_local *local)
{
419 420
	might_sleep();

J
Johannes Berg 已提交
421 422 423
	if (local->ops->rfkill_poll)
		local->ops->rfkill_poll(&local->hw);
}
424 425 426

static inline void drv_flush(struct ieee80211_local *local, bool drop)
{
427 428
	might_sleep();

429 430 431
	trace_drv_flush(local, drop);
	if (local->ops->flush)
		local->ops->flush(&local->hw, drop);
J
Johannes Berg 已提交
432
	trace_drv_return_void(local);
433
}
434 435 436 437 438 439 440

static inline void drv_channel_switch(struct ieee80211_local *local,
				     struct ieee80211_channel_switch *ch_switch)
{
	might_sleep();

	trace_drv_channel_switch(local, ch_switch);
J
Johannes Berg 已提交
441 442
	local->ops->channel_switch(&local->hw, ch_switch);
	trace_drv_return_void(local);
443 444
}

445
#endif /* __MAC80211_DRIVER_OPS */