driver-ops.h 9.5 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
}

static inline void drv_remove_interface(struct ieee80211_local *local,
58
					struct ieee80211_vif *vif)
59
{
60 61
	might_sleep();

62
	trace_drv_remove_interface(local, vif_to_sdata(vif));
J
Johannes Berg 已提交
63 64
	local->ops->remove_interface(&local->hw, vif);
	trace_drv_return_void(local);
65 66 67 68
}

static inline int drv_config(struct ieee80211_local *local, u32 changed)
{
69 70 71 72
	int ret;

	might_sleep();

J
Johannes Berg 已提交
73
	trace_drv_config(local, changed);
74
	ret = local->ops->config(&local->hw, changed);
J
Johannes Berg 已提交
75
	trace_drv_return_int(local, ret);
76
	return ret;
77 78 79
}

static inline void drv_bss_info_changed(struct ieee80211_local *local,
J
Johannes Berg 已提交
80
					struct ieee80211_sub_if_data *sdata,
81 82 83
					struct ieee80211_bss_conf *info,
					u32 changed)
{
84 85
	might_sleep();

J
Johannes Berg 已提交
86
	trace_drv_bss_info_changed(local, sdata, info, changed);
87
	if (local->ops->bss_info_changed)
J
Johannes Berg 已提交
88
		local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed);
J
Johannes Berg 已提交
89
	trace_drv_return_void(local);
90 91
}

92
static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
93
					struct netdev_hw_addr_list *mc_list)
94 95 96
{
	u64 ret = 0;

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

99
	if (local->ops->prepare_multicast)
100
		ret = local->ops->prepare_multicast(&local->hw, mc_list);
101

J
Johannes Berg 已提交
102
	trace_drv_return_u64(local, ret);
103 104 105 106

	return ret;
}

107 108 109
static inline void drv_configure_filter(struct ieee80211_local *local,
					unsigned int changed_flags,
					unsigned int *total_flags,
110
					u64 multicast)
111
{
112 113
	might_sleep();

114
	trace_drv_configure_filter(local, changed_flags, total_flags,
115
				   multicast);
J
Johannes Berg 已提交
116 117 118
	local->ops->configure_filter(&local->hw, changed_flags, total_flags,
				     multicast);
	trace_drv_return_void(local);
119 120 121 122 123
}

static inline int drv_set_tim(struct ieee80211_local *local,
			      struct ieee80211_sta *sta, bool set)
{
124
	int ret = 0;
J
Johannes Berg 已提交
125
	trace_drv_set_tim(local, sta, set);
126
	if (local->ops->set_tim)
127
		ret = local->ops->set_tim(&local->hw, sta, set);
J
Johannes Berg 已提交
128
	trace_drv_return_int(local, ret);
129
	return ret;
130 131 132
}

static inline int drv_set_key(struct ieee80211_local *local,
J
Johannes Berg 已提交
133 134
			      enum set_key_cmd cmd,
			      struct ieee80211_sub_if_data *sdata,
135 136 137
			      struct ieee80211_sta *sta,
			      struct ieee80211_key_conf *key)
{
138 139 140 141
	int ret;

	might_sleep();

J
Johannes Berg 已提交
142
	trace_drv_set_key(local, cmd, sdata, sta, key);
143
	ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
J
Johannes Berg 已提交
144
	trace_drv_return_int(local, ret);
145
	return ret;
146 147 148
}

static inline void drv_update_tkip_key(struct ieee80211_local *local,
149
				       struct ieee80211_sub_if_data *sdata,
150
				       struct ieee80211_key_conf *conf,
151
				       struct sta_info *sta, u32 iv32,
152 153
				       u16 *phase1key)
{
154 155 156 157 158
	struct ieee80211_sta *ista = NULL;

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

J
Johannes Berg 已提交
159
	trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
160
	if (local->ops->update_tkip_key)
161 162
		local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
					    ista, iv32, phase1key);
J
Johannes Berg 已提交
163
	trace_drv_return_void(local);
164 165 166
}

static inline int drv_hw_scan(struct ieee80211_local *local,
167
			      struct ieee80211_sub_if_data *sdata,
168 169
			      struct cfg80211_scan_request *req)
{
170 171 172 173
	int ret;

	might_sleep();

J
Johannes Berg 已提交
174
	trace_drv_hw_scan(local, sdata, req);
175
	ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
J
Johannes Berg 已提交
176
	trace_drv_return_int(local, ret);
177
	return ret;
178 179 180 181
}

static inline void drv_sw_scan_start(struct ieee80211_local *local)
{
182 183
	might_sleep();

J
Johannes Berg 已提交
184
	trace_drv_sw_scan_start(local);
185 186
	if (local->ops->sw_scan_start)
		local->ops->sw_scan_start(&local->hw);
J
Johannes Berg 已提交
187
	trace_drv_return_void(local);
188 189 190 191
}

static inline void drv_sw_scan_complete(struct ieee80211_local *local)
{
192 193
	might_sleep();

J
Johannes Berg 已提交
194
	trace_drv_sw_scan_complete(local);
195 196
	if (local->ops->sw_scan_complete)
		local->ops->sw_scan_complete(&local->hw);
J
Johannes Berg 已提交
197
	trace_drv_return_void(local);
198 199 200 201 202
}

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

205 206
	might_sleep();

207 208 209 210 211
	if (local->ops->get_stats)
		ret = local->ops->get_stats(&local->hw, stats);
	trace_drv_get_stats(local, stats, ret);

	return ret;
212 213 214 215 216 217 218
}

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);
219
	trace_drv_get_tkip_seq(local, hw_key_idx, iv32, iv16);
220 221 222 223 224
}

static inline int drv_set_rts_threshold(struct ieee80211_local *local,
					u32 value)
{
225
	int ret = 0;
226 227 228

	might_sleep();

J
Johannes Berg 已提交
229
	trace_drv_set_rts_threshold(local, value);
230
	if (local->ops->set_rts_threshold)
231
		ret = local->ops->set_rts_threshold(&local->hw, value);
J
Johannes Berg 已提交
232
	trace_drv_return_int(local, ret);
233
	return ret;
234 235
}

236 237 238 239 240 241
static inline int drv_set_coverage_class(struct ieee80211_local *local,
					 u8 value)
{
	int ret = 0;
	might_sleep();

J
Johannes Berg 已提交
242
	trace_drv_set_coverage_class(local, value);
243 244 245 246 247
	if (local->ops->set_coverage_class)
		local->ops->set_coverage_class(&local->hw, value);
	else
		ret = -EOPNOTSUPP;

J
Johannes Berg 已提交
248
	trace_drv_return_int(local, ret);
249 250 251
	return ret;
}

252
static inline void drv_sta_notify(struct ieee80211_local *local,
J
Johannes Berg 已提交
253
				  struct ieee80211_sub_if_data *sdata,
254 255 256
				  enum sta_notify_cmd cmd,
				  struct ieee80211_sta *sta)
{
J
Johannes Berg 已提交
257
	trace_drv_sta_notify(local, sdata, cmd, sta);
258
	if (local->ops->sta_notify)
J
Johannes Berg 已提交
259
		local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta);
J
Johannes Berg 已提交
260
	trace_drv_return_void(local);
261 262
}

263 264 265 266 267 268 269 270
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 已提交
271
	trace_drv_sta_add(local, sdata, sta);
272 273 274
	if (local->ops->sta_add)
		ret = local->ops->sta_add(&local->hw, &sdata->vif, sta);

J
Johannes Berg 已提交
275
	trace_drv_return_int(local, ret);
276 277 278 279 280 281 282 283 284 285

	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 已提交
286
	trace_drv_sta_remove(local, sdata, sta);
287 288 289
	if (local->ops->sta_remove)
		local->ops->sta_remove(&local->hw, &sdata->vif, sta);

J
Johannes Berg 已提交
290
	trace_drv_return_void(local);
291 292
}

293 294 295
static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue,
			      const struct ieee80211_tx_queue_params *params)
{
296
	int ret = -EOPNOTSUPP;
297 298 299

	might_sleep();

J
Johannes Berg 已提交
300
	trace_drv_conf_tx(local, queue, params);
301
	if (local->ops->conf_tx)
302
		ret = local->ops->conf_tx(&local->hw, queue, params);
J
Johannes Berg 已提交
303
	trace_drv_return_int(local, ret);
304
	return ret;
305 306 307 308
}

static inline u64 drv_get_tsf(struct ieee80211_local *local)
{
309
	u64 ret = -1ULL;
310 311 312

	might_sleep();

J
Johannes Berg 已提交
313
	trace_drv_get_tsf(local);
314
	if (local->ops->get_tsf)
315
		ret = local->ops->get_tsf(&local->hw);
J
Johannes Berg 已提交
316
	trace_drv_return_u64(local, ret);
317
	return ret;
318 319 320 321
}

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

J
Johannes Berg 已提交
324
	trace_drv_set_tsf(local, tsf);
325 326
	if (local->ops->set_tsf)
		local->ops->set_tsf(&local->hw, tsf);
J
Johannes Berg 已提交
327
	trace_drv_return_void(local);
328 329 330 331
}

static inline void drv_reset_tsf(struct ieee80211_local *local)
{
332 333
	might_sleep();

J
Johannes Berg 已提交
334
	trace_drv_reset_tsf(local);
335 336
	if (local->ops->reset_tsf)
		local->ops->reset_tsf(&local->hw);
J
Johannes Berg 已提交
337
	trace_drv_return_void(local);
338 339 340 341
}

static inline int drv_tx_last_beacon(struct ieee80211_local *local)
{
342
	int ret = 1;
343 344 345

	might_sleep();

J
Johannes Berg 已提交
346
	trace_drv_tx_last_beacon(local);
347
	if (local->ops->tx_last_beacon)
348
		ret = local->ops->tx_last_beacon(&local->hw);
J
Johannes Berg 已提交
349
	trace_drv_return_int(local, ret);
350
	return ret;
351 352 353
}

static inline int drv_ampdu_action(struct ieee80211_local *local,
J
Johannes Berg 已提交
354
				   struct ieee80211_sub_if_data *sdata,
355 356 357 358
				   enum ieee80211_ampdu_mlme_action action,
				   struct ieee80211_sta *sta, u16 tid,
				   u16 *ssn)
{
359
	int ret = -EOPNOTSUPP;
360 361 362

	might_sleep();

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

365
	if (local->ops->ampdu_action)
J
Johannes Berg 已提交
366
		ret = local->ops->ampdu_action(&local->hw, &sdata->vif, action,
367
					       sta, tid, ssn);
368

J
Johannes Berg 已提交
369 370
	trace_drv_return_int(local, ret);

371
	return ret;
372
}
J
Johannes Berg 已提交
373

374 375 376 377
static inline int drv_get_survey(struct ieee80211_local *local, int idx,
				struct survey_info *survey)
{
	int ret = -EOPNOTSUPP;
378
	if (local->ops->get_survey)
379 380 381 382
		ret = local->ops->get_survey(&local->hw, idx, survey);
	/* trace_drv_get_survey(local, idx, survey, ret); */
	return ret;
}
J
Johannes Berg 已提交
383 384 385

static inline void drv_rfkill_poll(struct ieee80211_local *local)
{
386 387
	might_sleep();

J
Johannes Berg 已提交
388 389 390
	if (local->ops->rfkill_poll)
		local->ops->rfkill_poll(&local->hw);
}
391 392 393

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

396 397 398
	trace_drv_flush(local, drop);
	if (local->ops->flush)
		local->ops->flush(&local->hw, drop);
J
Johannes Berg 已提交
399
	trace_drv_return_void(local);
400
}
401 402 403 404 405 406 407

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 已提交
408 409
	local->ops->channel_switch(&local->hw, ch_switch);
	trace_drv_return_void(local);
410 411
}

412
#endif /* __MAC80211_DRIVER_OPS */