cfg80211: introduce nl80211 testmode command
Johannes Berg
maintainerPATCH 1/1 cfg80211: introduce nl80211 testmode command
This introduces a new NL80211_CMD_TESTMODE for testing and calibration use with nl80211. There's no multiplexing like like iwpriv had, and the command is not available by default, it needs to be explicitly enabled in Kconfig and shouldn't be enabled in most kernels.
The command requires a wiphy index or interface index to identify the device to operate on, and the new TESTDATA attribute. There also is API for sending replies to the command, and testmode multicast messages (on a testmode multicast group).
I've also updated mac80211 to be able to pass through the command to the driver, since it itself doesn't implement the testmode command.
Additionally, to give people an idea of how to use the command, I've added a little code to hwsim that makes use of the new command to set the powersave mode, this is currently done via debugfs and should remain there, and the testmode command only serves as an example of how to use this best -- with nested netlink attributes in the TESTDATA attribute. A hwsim testmode tool can be found at
http://git.sipsolutions.net/hwsim.git/. This tool is BSD licensed so people can easily use it as a basis for their own internal fabrication and validation tools.
---
I haven't implemented dumping because right now I'm not sure how to, nor whether people will use it when they can allocate larger skbs for more data which in test environments should be acceptable.
drivers/net/wireless/mac80211_hwsim.c | 68 +++++++++++++++++ include/linux/nl80211.h | 11 ++ include/net/cfg80211.h | 83 ++++++++++++++++++++ include/net/mac80211.h | 5 + net/mac80211/cfg.c | 13 +++ net/wireless/Kconfig | 15 +++ net/wireless/core.h | 4 + net/wireless/nl80211.c | 136 ++++++++++++++++++++++++++++++++++ 8 files changed, 335 insertions(+)
include/linux/nl80211.h +11 -0
@@ -242,6 +242,10 @@* @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is * determined by the network interface. * +* @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute +* to identify the device, and the TESTDATA blob attribute to pass through +* to the driver. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -310,6 +314,8 @@ enum nl80211_commands {NL80211_CMD_JOIN_IBSS ,NL80211_CMD_LEAVE_IBSS , + NL80211_CMD_TESTMODE, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -511,6 +517,9 @@ enum nl80211_commands {* authorized by user space. Otherwise, port is marked authorized by * default in station mode. * +* @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver. +* We recommend using nested, driver-specific attributes within this. +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */
@@ -619,6 +628,8 @@ enum nl80211_attrs {NL80211_ATTR_CONTROL_PORT , +NL80211_ATTR_TESTDATA , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +83 -0
99 lines not on this page · raw message
net/wireless/Kconfig +15 -0
@@ -2,6 +2,21 @@ config CFG80211 tristate "Improved wireless configuration API" depends on RFKILL || !RFKILL +config NL80211_TESTMODE + bool "nl80211 testmode command" + depends on CFG80211 + help + The nl80211 testmode command helps implementing things like + factory calibration or validation tools for wireless chips. + + Select this option ONLY for kernels that are specifically + built for such purposes. + + Debugging tools that are supposed to end up in the hands of + users should better be implemented with debugfs. + + Say N. + config CFG80211_REG_DEBUG bool "cfg80211 regulatory debugging" depends on CFG80211
net/wireless/core.h +4 -0
@@ -58,6 +58,10 @@ struct cfg80211_registered_device {struct cfg80211_scan_request *scan_req;/* protected by RTNL */ unsigned long suspend_at; +#ifdef CONFIG_NL80211_TESTMODE +struct genl_info *testmode_info; +#endif +#ifdef CONFIG_CFG80211_DEBUGFS /* Debugfs entries */ struct wiphy_debugfsdentries {
net/wireless/nl80211.c +136 -0
154 lines not on this page · raw message
include/net/mac80211.h +5 -0
@@ -1419,6 +1419,8 @@ enum ieee80211_ampdu_mlme_action {* @rfkill_poll: Poll rfkill hardware state. If you need this, you also * need to set wiphy->rfkill_poll to %true before registration, * and need to call wiphy_rfkill_set_hw_state() in the callback. +* +* @testmode_cmd: Implement a cfg80211 test mode command. */ struct ieee80211_ops {int (*tx)(struct ieee80211_hw *hw,struct sk_buff *skb);
@@ -1469,6 +1471,9 @@ struct ieee80211_ops { struct ieee80211_sta *sta, u16 tid, u16 *ssn);void (*rfkill_poll)(struct ieee80211_hw *hw); +#ifdef CONFIG_NL80211_TESTMODE +int (*testmode_cmd)(struct ieee80211_hw *hw,void *data,int len); +#endif };/**
net/mac80211/cfg.c +13 -0
@@ -1376,6 +1376,18 @@ static void ieee80211_rfkill_poll(structdrv_rfkill_poll (local); } +#ifdef CONFIG_NL80211_TESTMODE +int ieee80211_testmode_cmd (struct wiphy *wiphy,void *data,int len) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); + +if (!local->ops->testmode_cmd) +return -EOPNOTSUPP ; + +return local->ops->testmode_cmd (&local->hw, data, len); +} +#endif +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1418,4 +1430,5 @@ struct cfg80211_ops mac80211_config_ops .set_tx_power = ieee80211_set_tx_power, .get_tx_power = ieee80211_get_tx_power, .rfkill_poll = ieee80211_rfkill_poll, + CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) };
drivers/net/wireless/mac80211_hwsim.c +68 -0
80 lines not on this page · raw message