diff options
author | Eliad Peller <eliad@wizery.com> | 2011-09-21 07:06:11 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-09-27 14:27:48 -0400 |
commit | 37a41b4affa33bb237d3692bf51f1b5ebcaf29d8 (patch) | |
tree | 0201e166912d12bd8270b2117b11717756cfd5db /net/mac80211 | |
parent | 129321804e36721e71fadcab5b475bd37bf53044 (diff) |
mac80211: add ieee80211_vif param to tsf functions
TSF can be kept per vif.
Add ieee80211_vif param to set/get/reset_tsf, and move
the debugfs entries to the per-vif directory.
Update all the drivers that implement these callbacks.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/debugfs.c | 52 | ||||
-rw-r--r-- | net/mac80211/debugfs_netdev.c | 48 | ||||
-rw-r--r-- | net/mac80211/driver-ops.h | 22 | ||||
-rw-r--r-- | net/mac80211/driver-trace.h | 26 | ||||
-rw-r--r-- | net/mac80211/ibss.c | 4 |
5 files changed, 78 insertions, 74 deletions
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index c9141168fd43..883996b2f99f 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -78,57 +78,6 @@ DEBUGFS_READONLY_FILE(wep_iv, "%#08x", | |||
78 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s", | 78 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s", |
79 | local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver"); | 79 | local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver"); |
80 | 80 | ||
81 | static ssize_t tsf_read(struct file *file, char __user *user_buf, | ||
82 | size_t count, loff_t *ppos) | ||
83 | { | ||
84 | struct ieee80211_local *local = file->private_data; | ||
85 | u64 tsf; | ||
86 | |||
87 | tsf = drv_get_tsf(local); | ||
88 | |||
89 | return mac80211_format_buffer(user_buf, count, ppos, "0x%016llx\n", | ||
90 | (unsigned long long) tsf); | ||
91 | } | ||
92 | |||
93 | static ssize_t tsf_write(struct file *file, | ||
94 | const char __user *user_buf, | ||
95 | size_t count, loff_t *ppos) | ||
96 | { | ||
97 | struct ieee80211_local *local = file->private_data; | ||
98 | unsigned long long tsf; | ||
99 | char buf[100]; | ||
100 | size_t len; | ||
101 | |||
102 | len = min(count, sizeof(buf) - 1); | ||
103 | if (copy_from_user(buf, user_buf, len)) | ||
104 | return -EFAULT; | ||
105 | buf[len] = '\0'; | ||
106 | |||
107 | if (strncmp(buf, "reset", 5) == 0) { | ||
108 | if (local->ops->reset_tsf) { | ||
109 | drv_reset_tsf(local); | ||
110 | wiphy_info(local->hw.wiphy, "debugfs reset TSF\n"); | ||
111 | } | ||
112 | } else { | ||
113 | tsf = simple_strtoul(buf, NULL, 0); | ||
114 | if (local->ops->set_tsf) { | ||
115 | drv_set_tsf(local, tsf); | ||
116 | wiphy_info(local->hw.wiphy, | ||
117 | "debugfs set TSF to %#018llx\n", tsf); | ||
118 | |||
119 | } | ||
120 | } | ||
121 | |||
122 | return count; | ||
123 | } | ||
124 | |||
125 | static const struct file_operations tsf_ops = { | ||
126 | .read = tsf_read, | ||
127 | .write = tsf_write, | ||
128 | .open = mac80211_open_file_generic, | ||
129 | .llseek = default_llseek, | ||
130 | }; | ||
131 | |||
132 | static ssize_t reset_write(struct file *file, const char __user *user_buf, | 81 | static ssize_t reset_write(struct file *file, const char __user *user_buf, |
133 | size_t count, loff_t *ppos) | 82 | size_t count, loff_t *ppos) |
134 | { | 83 | { |
@@ -447,7 +396,6 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
447 | DEBUGFS_ADD(frequency); | 396 | DEBUGFS_ADD(frequency); |
448 | DEBUGFS_ADD(total_ps_buffered); | 397 | DEBUGFS_ADD(total_ps_buffered); |
449 | DEBUGFS_ADD(wep_iv); | 398 | DEBUGFS_ADD(wep_iv); |
450 | DEBUGFS_ADD(tsf); | ||
451 | DEBUGFS_ADD(queues); | 399 | DEBUGFS_ADD(queues); |
452 | DEBUGFS_ADD_MODE(reset, 0200); | 400 | DEBUGFS_ADD_MODE(reset, 0200); |
453 | DEBUGFS_ADD(noack); | 401 | DEBUGFS_ADD(noack); |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index dd0462917518..9352819a986b 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "rate.h" | 21 | #include "rate.h" |
22 | #include "debugfs.h" | 22 | #include "debugfs.h" |
23 | #include "debugfs_netdev.h" | 23 | #include "debugfs_netdev.h" |
24 | #include "driver-ops.h" | ||
24 | 25 | ||
25 | static ssize_t ieee80211_if_read( | 26 | static ssize_t ieee80211_if_read( |
26 | struct ieee80211_sub_if_data *sdata, | 27 | struct ieee80211_sub_if_data *sdata, |
@@ -331,6 +332,46 @@ static ssize_t ieee80211_if_fmt_num_buffered_multicast( | |||
331 | } | 332 | } |
332 | __IEEE80211_IF_FILE(num_buffered_multicast, NULL); | 333 | __IEEE80211_IF_FILE(num_buffered_multicast, NULL); |
333 | 334 | ||
335 | /* IBSS attributes */ | ||
336 | static ssize_t ieee80211_if_fmt_tsf( | ||
337 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) | ||
338 | { | ||
339 | struct ieee80211_local *local = sdata->local; | ||
340 | u64 tsf; | ||
341 | |||
342 | tsf = drv_get_tsf(local, (struct ieee80211_sub_if_data *)sdata); | ||
343 | |||
344 | return scnprintf(buf, buflen, "0x%016llx\n", (unsigned long long) tsf); | ||
345 | } | ||
346 | |||
347 | static ssize_t ieee80211_if_parse_tsf( | ||
348 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) | ||
349 | { | ||
350 | struct ieee80211_local *local = sdata->local; | ||
351 | unsigned long long tsf; | ||
352 | int ret; | ||
353 | |||
354 | if (strncmp(buf, "reset", 5) == 0) { | ||
355 | if (local->ops->reset_tsf) { | ||
356 | drv_reset_tsf(local, sdata); | ||
357 | wiphy_info(local->hw.wiphy, "debugfs reset TSF\n"); | ||
358 | } | ||
359 | } else { | ||
360 | ret = kstrtoull(buf, 10, &tsf); | ||
361 | if (ret < 0) | ||
362 | return -EINVAL; | ||
363 | if (local->ops->set_tsf) { | ||
364 | drv_set_tsf(local, sdata, tsf); | ||
365 | wiphy_info(local->hw.wiphy, | ||
366 | "debugfs set TSF to %#018llx\n", tsf); | ||
367 | } | ||
368 | } | ||
369 | |||
370 | return buflen; | ||
371 | } | ||
372 | __IEEE80211_IF_FILE_W(tsf); | ||
373 | |||
374 | |||
334 | /* WDS attributes */ | 375 | /* WDS attributes */ |
335 | IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC); | 376 | IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC); |
336 | 377 | ||
@@ -421,6 +462,11 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata) | |||
421 | DEBUGFS_ADD_MODE(tkip_mic_test, 0200); | 462 | DEBUGFS_ADD_MODE(tkip_mic_test, 0200); |
422 | } | 463 | } |
423 | 464 | ||
465 | static void add_ibss_files(struct ieee80211_sub_if_data *sdata) | ||
466 | { | ||
467 | DEBUGFS_ADD_MODE(tsf, 0600); | ||
468 | } | ||
469 | |||
424 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) | 470 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) |
425 | { | 471 | { |
426 | DEBUGFS_ADD(drop_unencrypted); | 472 | DEBUGFS_ADD(drop_unencrypted); |
@@ -515,7 +561,7 @@ static void add_files(struct ieee80211_sub_if_data *sdata) | |||
515 | add_sta_files(sdata); | 561 | add_sta_files(sdata); |
516 | break; | 562 | break; |
517 | case NL80211_IFTYPE_ADHOC: | 563 | case NL80211_IFTYPE_ADHOC: |
518 | /* XXX */ | 564 | add_ibss_files(sdata); |
519 | break; | 565 | break; |
520 | case NL80211_IFTYPE_AP: | 566 | case NL80211_IFTYPE_AP: |
521 | add_ap_files(sdata); | 567 | add_ap_files(sdata); |
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 9001ff331f0a..5e5d97389bc9 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h | |||
@@ -427,36 +427,40 @@ static inline int drv_conf_tx(struct ieee80211_local *local, u16 queue, | |||
427 | return ret; | 427 | return ret; |
428 | } | 428 | } |
429 | 429 | ||
430 | static inline u64 drv_get_tsf(struct ieee80211_local *local) | 430 | static inline u64 drv_get_tsf(struct ieee80211_local *local, |
431 | struct ieee80211_sub_if_data *sdata) | ||
431 | { | 432 | { |
432 | u64 ret = -1ULL; | 433 | u64 ret = -1ULL; |
433 | 434 | ||
434 | might_sleep(); | 435 | might_sleep(); |
435 | 436 | ||
436 | trace_drv_get_tsf(local); | 437 | trace_drv_get_tsf(local, sdata); |
437 | if (local->ops->get_tsf) | 438 | if (local->ops->get_tsf) |
438 | ret = local->ops->get_tsf(&local->hw); | 439 | ret = local->ops->get_tsf(&local->hw, &sdata->vif); |
439 | trace_drv_return_u64(local, ret); | 440 | trace_drv_return_u64(local, ret); |
440 | return ret; | 441 | return ret; |
441 | } | 442 | } |
442 | 443 | ||
443 | static inline void drv_set_tsf(struct ieee80211_local *local, u64 tsf) | 444 | static inline void drv_set_tsf(struct ieee80211_local *local, |
445 | struct ieee80211_sub_if_data *sdata, | ||
446 | u64 tsf) | ||
444 | { | 447 | { |
445 | might_sleep(); | 448 | might_sleep(); |
446 | 449 | ||
447 | trace_drv_set_tsf(local, tsf); | 450 | trace_drv_set_tsf(local, sdata, tsf); |
448 | if (local->ops->set_tsf) | 451 | if (local->ops->set_tsf) |
449 | local->ops->set_tsf(&local->hw, tsf); | 452 | local->ops->set_tsf(&local->hw, &sdata->vif, tsf); |
450 | trace_drv_return_void(local); | 453 | trace_drv_return_void(local); |
451 | } | 454 | } |
452 | 455 | ||
453 | static inline void drv_reset_tsf(struct ieee80211_local *local) | 456 | static inline void drv_reset_tsf(struct ieee80211_local *local, |
457 | struct ieee80211_sub_if_data *sdata) | ||
454 | { | 458 | { |
455 | might_sleep(); | 459 | might_sleep(); |
456 | 460 | ||
457 | trace_drv_reset_tsf(local); | 461 | trace_drv_reset_tsf(local, sdata); |
458 | if (local->ops->reset_tsf) | 462 | if (local->ops->reset_tsf) |
459 | local->ops->reset_tsf(&local->hw); | 463 | local->ops->reset_tsf(&local->hw, &sdata->vif); |
460 | trace_drv_return_void(local); | 464 | trace_drv_return_void(local); |
461 | } | 465 | } |
462 | 466 | ||
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h index f47b00dc7afd..07d94ff55798 100644 --- a/net/mac80211/driver-trace.h +++ b/net/mac80211/driver-trace.h | |||
@@ -726,35 +726,41 @@ TRACE_EVENT(drv_conf_tx, | |||
726 | ) | 726 | ) |
727 | ); | 727 | ); |
728 | 728 | ||
729 | DEFINE_EVENT(local_only_evt, drv_get_tsf, | 729 | DEFINE_EVENT(local_sdata_evt, drv_get_tsf, |
730 | TP_PROTO(struct ieee80211_local *local), | 730 | TP_PROTO(struct ieee80211_local *local, |
731 | TP_ARGS(local) | 731 | struct ieee80211_sub_if_data *sdata), |
732 | TP_ARGS(local, sdata) | ||
732 | ); | 733 | ); |
733 | 734 | ||
734 | TRACE_EVENT(drv_set_tsf, | 735 | TRACE_EVENT(drv_set_tsf, |
735 | TP_PROTO(struct ieee80211_local *local, u64 tsf), | 736 | TP_PROTO(struct ieee80211_local *local, |
737 | struct ieee80211_sub_if_data *sdata, | ||
738 | u64 tsf), | ||
736 | 739 | ||
737 | TP_ARGS(local, tsf), | 740 | TP_ARGS(local, sdata, tsf), |
738 | 741 | ||
739 | TP_STRUCT__entry( | 742 | TP_STRUCT__entry( |
740 | LOCAL_ENTRY | 743 | LOCAL_ENTRY |
744 | VIF_ENTRY | ||
741 | __field(u64, tsf) | 745 | __field(u64, tsf) |
742 | ), | 746 | ), |
743 | 747 | ||
744 | TP_fast_assign( | 748 | TP_fast_assign( |
745 | LOCAL_ASSIGN; | 749 | LOCAL_ASSIGN; |
750 | VIF_ASSIGN; | ||
746 | __entry->tsf = tsf; | 751 | __entry->tsf = tsf; |
747 | ), | 752 | ), |
748 | 753 | ||
749 | TP_printk( | 754 | TP_printk( |
750 | LOCAL_PR_FMT " tsf:%llu", | 755 | LOCAL_PR_FMT VIF_PR_FMT " tsf:%llu", |
751 | LOCAL_PR_ARG, (unsigned long long)__entry->tsf | 756 | LOCAL_PR_ARG, VIF_PR_ARG, (unsigned long long)__entry->tsf |
752 | ) | 757 | ) |
753 | ); | 758 | ); |
754 | 759 | ||
755 | DEFINE_EVENT(local_only_evt, drv_reset_tsf, | 760 | DEFINE_EVENT(local_sdata_evt, drv_reset_tsf, |
756 | TP_PROTO(struct ieee80211_local *local), | 761 | TP_PROTO(struct ieee80211_local *local, |
757 | TP_ARGS(local) | 762 | struct ieee80211_sub_if_data *sdata), |
763 | TP_ARGS(local, sdata) | ||
758 | ); | 764 | ); |
759 | 765 | ||
760 | DEFINE_EVENT(local_only_evt, drv_tx_last_beacon, | 766 | DEFINE_EVENT(local_only_evt, drv_tx_last_beacon, |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 836b2752ecd6..7809895df8b0 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -81,7 +81,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
81 | lockdep_assert_held(&ifibss->mtx); | 81 | lockdep_assert_held(&ifibss->mtx); |
82 | 82 | ||
83 | /* Reset own TSF to allow time synchronization work. */ | 83 | /* Reset own TSF to allow time synchronization work. */ |
84 | drv_reset_tsf(local); | 84 | drv_reset_tsf(local, sdata); |
85 | 85 | ||
86 | skb = ifibss->skb; | 86 | skb = ifibss->skb; |
87 | rcu_assign_pointer(ifibss->presp, NULL); | 87 | rcu_assign_pointer(ifibss->presp, NULL); |
@@ -382,7 +382,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
382 | * second best option: get current TSF | 382 | * second best option: get current TSF |
383 | * (will return -1 if not supported) | 383 | * (will return -1 if not supported) |
384 | */ | 384 | */ |
385 | rx_timestamp = drv_get_tsf(local); | 385 | rx_timestamp = drv_get_tsf(local, sdata); |
386 | } | 386 | } |
387 | 387 | ||
388 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 388 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |