diff options
author | Johannes Berg <johannes.berg@intel.com> | 2014-06-04 11:31:56 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-06-23 05:05:33 -0400 |
commit | b7ffbd7ef6751f6cde73082346e365738daf00d2 (patch) | |
tree | 849c2b771a45b68a6733698c5de030ae100de952 /net/wireless | |
parent | ba9030c20a2def223d9b993cb3dfdd3aab3d2b31 (diff) |
cfg80211: make ethtool the driver's responsibility
Currently, cfg80211 tries to implement ethtool, but that doesn't
really scale well, with all the different operations. Make the
lower-level driver responsible for it, which currently only has
an effect on mac80211. It will similarly not scale well at that
level though, since mac80211 also has many drivers.
To cleanly implement this in mac80211, introduce a new file and
move some code to appropriate places.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/core.c | 3 | ||||
-rw-r--r-- | net/wireless/ethtool.c | 86 | ||||
-rw-r--r-- | net/wireless/ethtool.h | 6 | ||||
-rw-r--r-- | net/wireless/rdev-ops.h | 48 | ||||
-rw-r--r-- | net/wireless/trace.h | 49 |
5 files changed, 2 insertions, 190 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c index a1c40654dd9b..afee5e0455ea 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "sysfs.h" | 25 | #include "sysfs.h" |
26 | #include "debugfs.h" | 26 | #include "debugfs.h" |
27 | #include "wext-compat.h" | 27 | #include "wext-compat.h" |
28 | #include "ethtool.h" | ||
29 | #include "rdev-ops.h" | 28 | #include "rdev-ops.h" |
30 | 29 | ||
31 | /* name for sysfs, %d is appended */ | 30 | /* name for sysfs, %d is appended */ |
@@ -927,8 +926,6 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
927 | /* allow mac80211 to determine the timeout */ | 926 | /* allow mac80211 to determine the timeout */ |
928 | wdev->ps_timeout = -1; | 927 | wdev->ps_timeout = -1; |
929 | 928 | ||
930 | netdev_set_default_ethtool_ops(dev, &cfg80211_ethtool_ops); | ||
931 | |||
932 | if ((wdev->iftype == NL80211_IFTYPE_STATION || | 929 | if ((wdev->iftype == NL80211_IFTYPE_STATION || |
933 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT || | 930 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT || |
934 | wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr) | 931 | wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr) |
diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c index d4860bfc020e..e9e91298c70d 100644 --- a/net/wireless/ethtool.c +++ b/net/wireless/ethtool.c | |||
@@ -1,11 +1,9 @@ | |||
1 | #include <linux/utsname.h> | 1 | #include <linux/utsname.h> |
2 | #include <net/cfg80211.h> | 2 | #include <net/cfg80211.h> |
3 | #include "core.h" | 3 | #include "core.h" |
4 | #include "ethtool.h" | ||
5 | #include "rdev-ops.h" | 4 | #include "rdev-ops.h" |
6 | 5 | ||
7 | static void cfg80211_get_drvinfo(struct net_device *dev, | 6 | void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
8 | struct ethtool_drvinfo *info) | ||
9 | { | 7 | { |
10 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 8 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
11 | 9 | ||
@@ -23,84 +21,4 @@ static void cfg80211_get_drvinfo(struct net_device *dev, | |||
23 | strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)), | 21 | strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)), |
24 | sizeof(info->bus_info)); | 22 | sizeof(info->bus_info)); |
25 | } | 23 | } |
26 | 24 | EXPORT_SYMBOL(cfg80211_get_drvinfo); | |
27 | static int cfg80211_get_regs_len(struct net_device *dev) | ||
28 | { | ||
29 | /* For now, return 0... */ | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs, | ||
34 | void *data) | ||
35 | { | ||
36 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
37 | |||
38 | regs->version = wdev->wiphy->hw_version; | ||
39 | regs->len = 0; | ||
40 | } | ||
41 | |||
42 | static void cfg80211_get_ringparam(struct net_device *dev, | ||
43 | struct ethtool_ringparam *rp) | ||
44 | { | ||
45 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
46 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); | ||
47 | |||
48 | memset(rp, 0, sizeof(*rp)); | ||
49 | |||
50 | if (rdev->ops->get_ringparam) | ||
51 | rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending, | ||
52 | &rp->rx_pending, &rp->rx_max_pending); | ||
53 | } | ||
54 | |||
55 | static int cfg80211_set_ringparam(struct net_device *dev, | ||
56 | struct ethtool_ringparam *rp) | ||
57 | { | ||
58 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
59 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); | ||
60 | |||
61 | if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0) | ||
62 | return -EINVAL; | ||
63 | |||
64 | if (rdev->ops->set_ringparam) | ||
65 | return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending); | ||
66 | |||
67 | return -ENOTSUPP; | ||
68 | } | ||
69 | |||
70 | static int cfg80211_get_sset_count(struct net_device *dev, int sset) | ||
71 | { | ||
72 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
73 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); | ||
74 | if (rdev->ops->get_et_sset_count) | ||
75 | return rdev_get_et_sset_count(rdev, dev, sset); | ||
76 | return -EOPNOTSUPP; | ||
77 | } | ||
78 | |||
79 | static void cfg80211_get_stats(struct net_device *dev, | ||
80 | struct ethtool_stats *stats, u64 *data) | ||
81 | { | ||
82 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
83 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); | ||
84 | if (rdev->ops->get_et_stats) | ||
85 | rdev_get_et_stats(rdev, dev, stats, data); | ||
86 | } | ||
87 | |||
88 | static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data) | ||
89 | { | ||
90 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
91 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); | ||
92 | if (rdev->ops->get_et_strings) | ||
93 | rdev_get_et_strings(rdev, dev, sset, data); | ||
94 | } | ||
95 | |||
96 | const struct ethtool_ops cfg80211_ethtool_ops = { | ||
97 | .get_drvinfo = cfg80211_get_drvinfo, | ||
98 | .get_regs_len = cfg80211_get_regs_len, | ||
99 | .get_regs = cfg80211_get_regs, | ||
100 | .get_link = ethtool_op_get_link, | ||
101 | .get_ringparam = cfg80211_get_ringparam, | ||
102 | .set_ringparam = cfg80211_set_ringparam, | ||
103 | .get_strings = cfg80211_get_strings, | ||
104 | .get_ethtool_stats = cfg80211_get_stats, | ||
105 | .get_sset_count = cfg80211_get_sset_count, | ||
106 | }; | ||
diff --git a/net/wireless/ethtool.h b/net/wireless/ethtool.h deleted file mode 100644 index 695ecad20bd6..000000000000 --- a/net/wireless/ethtool.h +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef __CFG80211_ETHTOOL__ | ||
2 | #define __CFG80211_ETHTOOL__ | ||
3 | |||
4 | extern const struct ethtool_ops cfg80211_ethtool_ops; | ||
5 | |||
6 | #endif /* __CFG80211_ETHTOOL__ */ | ||
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index d95bbe348138..f552b0abbd70 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h | |||
@@ -714,25 +714,6 @@ static inline int rdev_get_antenna(struct cfg80211_registered_device *rdev, | |||
714 | return ret; | 714 | return ret; |
715 | } | 715 | } |
716 | 716 | ||
717 | static inline int rdev_set_ringparam(struct cfg80211_registered_device *rdev, | ||
718 | u32 tx, u32 rx) | ||
719 | { | ||
720 | int ret; | ||
721 | trace_rdev_set_ringparam(&rdev->wiphy, tx, rx); | ||
722 | ret = rdev->ops->set_ringparam(&rdev->wiphy, tx, rx); | ||
723 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
724 | return ret; | ||
725 | } | ||
726 | |||
727 | static inline void rdev_get_ringparam(struct cfg80211_registered_device *rdev, | ||
728 | u32 *tx, u32 *tx_max, u32 *rx, | ||
729 | u32 *rx_max) | ||
730 | { | ||
731 | trace_rdev_get_ringparam(&rdev->wiphy); | ||
732 | rdev->ops->get_ringparam(&rdev->wiphy, tx, tx_max, rx, rx_max); | ||
733 | trace_rdev_return_void_tx_rx(&rdev->wiphy, *tx, *tx_max, *rx, *rx_max); | ||
734 | } | ||
735 | |||
736 | static inline int | 717 | static inline int |
737 | rdev_sched_scan_start(struct cfg80211_registered_device *rdev, | 718 | rdev_sched_scan_start(struct cfg80211_registered_device *rdev, |
738 | struct net_device *dev, | 719 | struct net_device *dev, |
@@ -816,35 +797,6 @@ static inline int rdev_set_noack_map(struct cfg80211_registered_device *rdev, | |||
816 | } | 797 | } |
817 | 798 | ||
818 | static inline int | 799 | static inline int |
819 | rdev_get_et_sset_count(struct cfg80211_registered_device *rdev, | ||
820 | struct net_device *dev, int sset) | ||
821 | { | ||
822 | int ret; | ||
823 | trace_rdev_get_et_sset_count(&rdev->wiphy, dev, sset); | ||
824 | ret = rdev->ops->get_et_sset_count(&rdev->wiphy, dev, sset); | ||
825 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
826 | return ret; | ||
827 | } | ||
828 | |||
829 | static inline void rdev_get_et_stats(struct cfg80211_registered_device *rdev, | ||
830 | struct net_device *dev, | ||
831 | struct ethtool_stats *stats, u64 *data) | ||
832 | { | ||
833 | trace_rdev_get_et_stats(&rdev->wiphy, dev); | ||
834 | rdev->ops->get_et_stats(&rdev->wiphy, dev, stats, data); | ||
835 | trace_rdev_return_void(&rdev->wiphy); | ||
836 | } | ||
837 | |||
838 | static inline void rdev_get_et_strings(struct cfg80211_registered_device *rdev, | ||
839 | struct net_device *dev, u32 sset, | ||
840 | u8 *data) | ||
841 | { | ||
842 | trace_rdev_get_et_strings(&rdev->wiphy, dev, sset); | ||
843 | rdev->ops->get_et_strings(&rdev->wiphy, dev, sset, data); | ||
844 | trace_rdev_return_void(&rdev->wiphy); | ||
845 | } | ||
846 | |||
847 | static inline int | ||
848 | rdev_get_channel(struct cfg80211_registered_device *rdev, | 800 | rdev_get_channel(struct cfg80211_registered_device *rdev, |
849 | struct wireless_dev *wdev, | 801 | struct wireless_dev *wdev, |
850 | struct cfg80211_chan_def *chandef) | 802 | struct cfg80211_chan_def *chandef) |
diff --git a/net/wireless/trace.h b/net/wireless/trace.h index 560ed77084e9..174559aade57 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h | |||
@@ -298,11 +298,6 @@ DEFINE_EVENT(wiphy_only_evt, rdev_return_void, | |||
298 | TP_ARGS(wiphy) | 298 | TP_ARGS(wiphy) |
299 | ); | 299 | ); |
300 | 300 | ||
301 | DEFINE_EVENT(wiphy_only_evt, rdev_get_ringparam, | ||
302 | TP_PROTO(struct wiphy *wiphy), | ||
303 | TP_ARGS(wiphy) | ||
304 | ); | ||
305 | |||
306 | DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna, | 301 | DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna, |
307 | TP_PROTO(struct wiphy *wiphy), | 302 | TP_PROTO(struct wiphy *wiphy), |
308 | TP_ARGS(wiphy) | 303 | TP_ARGS(wiphy) |
@@ -580,11 +575,6 @@ DEFINE_EVENT(wiphy_netdev_evt, rdev_stop_ap, | |||
580 | TP_ARGS(wiphy, netdev) | 575 | TP_ARGS(wiphy, netdev) |
581 | ); | 576 | ); |
582 | 577 | ||
583 | DEFINE_EVENT(wiphy_netdev_evt, rdev_get_et_stats, | ||
584 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
585 | TP_ARGS(wiphy, netdev) | ||
586 | ); | ||
587 | |||
588 | DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop, | 578 | DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop, |
589 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | 579 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), |
590 | TP_ARGS(wiphy, netdev) | 580 | TP_ARGS(wiphy, netdev) |
@@ -1439,11 +1429,6 @@ DECLARE_EVENT_CLASS(tx_rx_evt, | |||
1439 | WIPHY_PR_ARG, __entry->tx, __entry->rx) | 1429 | WIPHY_PR_ARG, __entry->tx, __entry->rx) |
1440 | ); | 1430 | ); |
1441 | 1431 | ||
1442 | DEFINE_EVENT(tx_rx_evt, rdev_set_ringparam, | ||
1443 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1444 | TP_ARGS(wiphy, rx, tx) | ||
1445 | ); | ||
1446 | |||
1447 | DEFINE_EVENT(tx_rx_evt, rdev_set_antenna, | 1432 | DEFINE_EVENT(tx_rx_evt, rdev_set_antenna, |
1448 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | 1433 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), |
1449 | TP_ARGS(wiphy, rx, tx) | 1434 | TP_ARGS(wiphy, rx, tx) |
@@ -1725,40 +1710,6 @@ TRACE_EVENT(rdev_set_noack_map, | |||
1725 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map) | 1710 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map) |
1726 | ); | 1711 | ); |
1727 | 1712 | ||
1728 | TRACE_EVENT(rdev_get_et_sset_count, | ||
1729 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int sset), | ||
1730 | TP_ARGS(wiphy, netdev, sset), | ||
1731 | TP_STRUCT__entry( | ||
1732 | WIPHY_ENTRY | ||
1733 | NETDEV_ENTRY | ||
1734 | __field(int, sset) | ||
1735 | ), | ||
1736 | TP_fast_assign( | ||
1737 | WIPHY_ASSIGN; | ||
1738 | NETDEV_ASSIGN; | ||
1739 | __entry->sset = sset; | ||
1740 | ), | ||
1741 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %d", | ||
1742 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset) | ||
1743 | ); | ||
1744 | |||
1745 | TRACE_EVENT(rdev_get_et_strings, | ||
1746 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 sset), | ||
1747 | TP_ARGS(wiphy, netdev, sset), | ||
1748 | TP_STRUCT__entry( | ||
1749 | WIPHY_ENTRY | ||
1750 | NETDEV_ENTRY | ||
1751 | __field(u32, sset) | ||
1752 | ), | ||
1753 | TP_fast_assign( | ||
1754 | WIPHY_ASSIGN; | ||
1755 | NETDEV_ASSIGN; | ||
1756 | __entry->sset = sset; | ||
1757 | ), | ||
1758 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %u", | ||
1759 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset) | ||
1760 | ); | ||
1761 | |||
1762 | DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel, | 1713 | DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel, |
1763 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | 1714 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), |
1764 | TP_ARGS(wiphy, wdev) | 1715 | TP_ARGS(wiphy, wdev) |