diff options
author | David Spinadel <david.spinadel@intel.com> | 2013-07-31 11:04:15 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-08-12 08:11:37 -0400 |
commit | fc73f11f5fa230f8c687d51b0fddb00433092ce0 (patch) | |
tree | f1c2e5c855a97dd4039b3df2a0b8cde96744898f | |
parent | af61a165187bb94b1dc7628ef815c23d0eacf40b (diff) |
cfg80211: add wdev to testmode cmd
To allow drivers to implement per-interface testmode operations
more easily, pass a wdev pointer if any identification for one
was given from userspace. Clean up the code a bit while at it.
Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | drivers/net/wireless/ath/ath6kl/testmode.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath6kl/testmode.h | 7 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 4 | ||||
-rw-r--r-- | include/net/cfg80211.h | 5 | ||||
-rw-r--r-- | net/mac80211/cfg.c | 4 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 23 | ||||
-rw-r--r-- | net/wireless/rdev-ops.h | 5 | ||||
-rw-r--r-- | net/wireless/trace.h | 8 |
8 files changed, 41 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/testmode.c b/drivers/net/wireless/ath/ath6kl/testmode.c index acc9aa832f76..d67170ea1038 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.c +++ b/drivers/net/wireless/ath/ath6kl/testmode.c | |||
@@ -66,7 +66,8 @@ nla_put_failure: | |||
66 | ath6kl_warn("nla_put failed on testmode rx skb!\n"); | 66 | ath6kl_warn("nla_put failed on testmode rx skb!\n"); |
67 | } | 67 | } |
68 | 68 | ||
69 | int ath6kl_tm_cmd(struct wiphy *wiphy, void *data, int len) | 69 | int ath6kl_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev, |
70 | void *data, int len) | ||
70 | { | 71 | { |
71 | struct ath6kl *ar = wiphy_priv(wiphy); | 72 | struct ath6kl *ar = wiphy_priv(wiphy); |
72 | struct nlattr *tb[ATH6KL_TM_ATTR_MAX + 1]; | 73 | struct nlattr *tb[ATH6KL_TM_ATTR_MAX + 1]; |
diff --git a/drivers/net/wireless/ath/ath6kl/testmode.h b/drivers/net/wireless/ath/ath6kl/testmode.h index fe651d6707df..9fbcdec3e208 100644 --- a/drivers/net/wireless/ath/ath6kl/testmode.h +++ b/drivers/net/wireless/ath/ath6kl/testmode.h | |||
@@ -20,7 +20,8 @@ | |||
20 | #ifdef CONFIG_NL80211_TESTMODE | 20 | #ifdef CONFIG_NL80211_TESTMODE |
21 | 21 | ||
22 | void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, size_t buf_len); | 22 | void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, size_t buf_len); |
23 | int ath6kl_tm_cmd(struct wiphy *wiphy, void *data, int len); | 23 | int ath6kl_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev, |
24 | void *data, int len); | ||
24 | 25 | ||
25 | #else | 26 | #else |
26 | 27 | ||
@@ -29,7 +30,9 @@ static inline void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, | |||
29 | { | 30 | { |
30 | } | 31 | } |
31 | 32 | ||
32 | static inline int ath6kl_tm_cmd(struct wiphy *wiphy, void *data, int len) | 33 | static inline int ath6kl_tm_cmd(struct wiphy *wiphy, |
34 | struct wireless_dev *wdev, | ||
35 | void *data, int len) | ||
33 | { | 36 | { |
34 | return 0; | 37 | return 0; |
35 | } | 38 | } |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index 277b37ae7126..b7d885020dd7 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | |||
@@ -3152,7 +3152,9 @@ static int brcmf_cfg80211_sched_scan_stop(struct wiphy *wiphy, | |||
3152 | } | 3152 | } |
3153 | 3153 | ||
3154 | #ifdef CONFIG_NL80211_TESTMODE | 3154 | #ifdef CONFIG_NL80211_TESTMODE |
3155 | static int brcmf_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) | 3155 | static int brcmf_cfg80211_testmode(struct wiphy *wiphy, |
3156 | struct wireless_dev *wdev, | ||
3157 | void *data, int len) | ||
3156 | { | 3158 | { |
3157 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); | 3159 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
3158 | struct net_device *ndev = cfg_to_ndev(cfg); | 3160 | struct net_device *ndev = cfg_to_ndev(cfg); |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b7495c72061c..9ab7a0690d93 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -2081,7 +2081,7 @@ struct cfg80211_update_ft_ies_params { | |||
2081 | * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management | 2081 | * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management |
2082 | * frame on another channel | 2082 | * frame on another channel |
2083 | * | 2083 | * |
2084 | * @testmode_cmd: run a test mode command | 2084 | * @testmode_cmd: run a test mode command; @wdev may be %NULL |
2085 | * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be | 2085 | * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be |
2086 | * used by the function, but 0 and 1 must not be touched. Additionally, | 2086 | * used by the function, but 0 and 1 must not be touched. Additionally, |
2087 | * return error codes other than -ENOBUFS and -ENOENT will terminate the | 2087 | * return error codes other than -ENOBUFS and -ENOENT will terminate the |
@@ -2290,7 +2290,8 @@ struct cfg80211_ops { | |||
2290 | void (*rfkill_poll)(struct wiphy *wiphy); | 2290 | void (*rfkill_poll)(struct wiphy *wiphy); |
2291 | 2291 | ||
2292 | #ifdef CONFIG_NL80211_TESTMODE | 2292 | #ifdef CONFIG_NL80211_TESTMODE |
2293 | int (*testmode_cmd)(struct wiphy *wiphy, void *data, int len); | 2293 | int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev, |
2294 | void *data, int len); | ||
2294 | int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb, | 2295 | int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb, |
2295 | struct netlink_callback *cb, | 2296 | struct netlink_callback *cb, |
2296 | void *data, int len); | 2297 | void *data, int len); |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 44449ceb7966..c77916ffe74c 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -2300,7 +2300,9 @@ static void ieee80211_rfkill_poll(struct wiphy *wiphy) | |||
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | #ifdef CONFIG_NL80211_TESTMODE | 2302 | #ifdef CONFIG_NL80211_TESTMODE |
2303 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len) | 2303 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, |
2304 | struct wireless_dev *wdev, | ||
2305 | void *data, int len) | ||
2304 | { | 2306 | { |
2305 | struct ieee80211_local *local = wiphy_priv(wiphy); | 2307 | struct ieee80211_local *local = wiphy_priv(wiphy); |
2306 | 2308 | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index c2a40a2e56bd..334697de5cc0 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -6591,19 +6591,30 @@ static struct genl_multicast_group nl80211_testmode_mcgrp = { | |||
6591 | static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) | 6591 | static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) |
6592 | { | 6592 | { |
6593 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 6593 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6594 | struct wireless_dev *wdev = | ||
6595 | __cfg80211_wdev_from_attrs(genl_info_net(info), info->attrs); | ||
6594 | int err; | 6596 | int err; |
6595 | 6597 | ||
6598 | if (!rdev->ops->testmode_cmd) | ||
6599 | return -EOPNOTSUPP; | ||
6600 | |||
6601 | if (IS_ERR(wdev)) { | ||
6602 | err = PTR_ERR(wdev); | ||
6603 | if (err != -EINVAL) | ||
6604 | return err; | ||
6605 | wdev = NULL; | ||
6606 | } else if (wdev->wiphy != &rdev->wiphy) { | ||
6607 | return -EINVAL; | ||
6608 | } | ||
6609 | |||
6596 | if (!info->attrs[NL80211_ATTR_TESTDATA]) | 6610 | if (!info->attrs[NL80211_ATTR_TESTDATA]) |
6597 | return -EINVAL; | 6611 | return -EINVAL; |
6598 | 6612 | ||
6599 | err = -EOPNOTSUPP; | 6613 | rdev->testmode_info = info; |
6600 | if (rdev->ops->testmode_cmd) { | 6614 | err = rdev_testmode_cmd(rdev, wdev, |
6601 | rdev->testmode_info = info; | ||
6602 | err = rdev_testmode_cmd(rdev, | ||
6603 | nla_data(info->attrs[NL80211_ATTR_TESTDATA]), | 6615 | nla_data(info->attrs[NL80211_ATTR_TESTDATA]), |
6604 | nla_len(info->attrs[NL80211_ATTR_TESTDATA])); | 6616 | nla_len(info->attrs[NL80211_ATTR_TESTDATA])); |
6605 | rdev->testmode_info = NULL; | 6617 | rdev->testmode_info = NULL; |
6606 | } | ||
6607 | 6618 | ||
6608 | return err; | 6619 | return err; |
6609 | } | 6620 | } |
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index de870d4d0bcc..37ce9fdfe934 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h | |||
@@ -516,11 +516,12 @@ static inline void rdev_rfkill_poll(struct cfg80211_registered_device *rdev) | |||
516 | 516 | ||
517 | #ifdef CONFIG_NL80211_TESTMODE | 517 | #ifdef CONFIG_NL80211_TESTMODE |
518 | static inline int rdev_testmode_cmd(struct cfg80211_registered_device *rdev, | 518 | static inline int rdev_testmode_cmd(struct cfg80211_registered_device *rdev, |
519 | struct wireless_dev *wdev, | ||
519 | void *data, int len) | 520 | void *data, int len) |
520 | { | 521 | { |
521 | int ret; | 522 | int ret; |
522 | trace_rdev_testmode_cmd(&rdev->wiphy); | 523 | trace_rdev_testmode_cmd(&rdev->wiphy, wdev); |
523 | ret = rdev->ops->testmode_cmd(&rdev->wiphy, data, len); | 524 | ret = rdev->ops->testmode_cmd(&rdev->wiphy, wdev, data, len); |
524 | trace_rdev_return_int(&rdev->wiphy, ret); | 525 | trace_rdev_return_int(&rdev->wiphy, ret); |
525 | return ret; | 526 | return ret; |
526 | } | 527 | } |
diff --git a/net/wireless/trace.h b/net/wireless/trace.h index f0ebdcd394ef..ba5f0d6614d5 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h | |||
@@ -1293,15 +1293,17 @@ TRACE_EVENT(rdev_return_int_int, | |||
1293 | 1293 | ||
1294 | #ifdef CONFIG_NL80211_TESTMODE | 1294 | #ifdef CONFIG_NL80211_TESTMODE |
1295 | TRACE_EVENT(rdev_testmode_cmd, | 1295 | TRACE_EVENT(rdev_testmode_cmd, |
1296 | TP_PROTO(struct wiphy *wiphy), | 1296 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), |
1297 | TP_ARGS(wiphy), | 1297 | TP_ARGS(wiphy, wdev), |
1298 | TP_STRUCT__entry( | 1298 | TP_STRUCT__entry( |
1299 | WIPHY_ENTRY | 1299 | WIPHY_ENTRY |
1300 | WDEV_ENTRY | ||
1300 | ), | 1301 | ), |
1301 | TP_fast_assign( | 1302 | TP_fast_assign( |
1302 | WIPHY_ASSIGN; | 1303 | WIPHY_ASSIGN; |
1304 | WDEV_ASSIGN; | ||
1303 | ), | 1305 | ), |
1304 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | 1306 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG) |
1305 | ); | 1307 | ); |
1306 | 1308 | ||
1307 | TRACE_EVENT(rdev_testmode_dump, | 1309 | TRACE_EVENT(rdev_testmode_dump, |