aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-07-01 15:26:51 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-10 15:01:50 -0400
commitaff89a9b9084931e51b89d8f3ee3c547bea6c422 (patch)
tree592c1dfa2ef994a1b3e117b3d7bc1cc7b7bde637 /include
parent5121ea0481f9cea1dfd958f18d7b4ac78778cd40 (diff)
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. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/nl80211.h11
-rw-r--r--include/net/cfg80211.h83
-rw-r--r--include/net/mac80211.h5
3 files changed, 99 insertions, 0 deletions
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index dbea93b694e5..651b18839088 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -242,6 +242,10 @@
242 * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is 242 * @NL80211_CMD_LEAVE_IBSS: Leave the IBSS -- no special arguments, the IBSS is
243 * determined by the network interface. 243 * determined by the network interface.
244 * 244 *
245 * @NL80211_CMD_TESTMODE: testmode command, takes a wiphy (or ifindex) attribute
246 * to identify the device, and the TESTDATA blob attribute to pass through
247 * to the driver.
248 *
245 * @NL80211_CMD_MAX: highest used command number 249 * @NL80211_CMD_MAX: highest used command number
246 * @__NL80211_CMD_AFTER_LAST: internal use 250 * @__NL80211_CMD_AFTER_LAST: internal use
247 */ 251 */
@@ -310,6 +314,8 @@ enum nl80211_commands {
310 NL80211_CMD_JOIN_IBSS, 314 NL80211_CMD_JOIN_IBSS,
311 NL80211_CMD_LEAVE_IBSS, 315 NL80211_CMD_LEAVE_IBSS,
312 316
317 NL80211_CMD_TESTMODE,
318
313 /* add new commands above here */ 319 /* add new commands above here */
314 320
315 /* used to define NL80211_CMD_MAX below */ 321 /* used to define NL80211_CMD_MAX below */
@@ -511,6 +517,9 @@ enum nl80211_commands {
511 * authorized by user space. Otherwise, port is marked authorized by 517 * authorized by user space. Otherwise, port is marked authorized by
512 * default in station mode. 518 * default in station mode.
513 * 519 *
520 * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
521 * We recommend using nested, driver-specific attributes within this.
522 *
514 * @NL80211_ATTR_MAX: highest attribute number currently defined 523 * @NL80211_ATTR_MAX: highest attribute number currently defined
515 * @__NL80211_ATTR_AFTER_LAST: internal use 524 * @__NL80211_ATTR_AFTER_LAST: internal use
516 */ 525 */
@@ -619,6 +628,8 @@ enum nl80211_attrs {
619 628
620 NL80211_ATTR_CONTROL_PORT, 629 NL80211_ATTR_CONTROL_PORT,
621 630
631 NL80211_ATTR_TESTDATA,
632
622 /* add attributes here, update the policy in nl80211.c */ 633 /* add attributes here, update the policy in nl80211.c */
623 634
624 __NL80211_ATTR_AFTER_LAST, 635 __NL80211_ATTR_AFTER_LAST,
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 10eb53e2bc9f..885d4e5bc4b5 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -857,6 +857,8 @@ enum tx_power_setting {
857 * 857 *
858 * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting 858 * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
859 * functions to adjust rfkill hw state 859 * functions to adjust rfkill hw state
860 *
861 * @testmode_cmd: run a test mode command
860 */ 862 */
861struct cfg80211_ops { 863struct cfg80211_ops {
862 int (*suspend)(struct wiphy *wiphy); 864 int (*suspend)(struct wiphy *wiphy);
@@ -955,6 +957,10 @@ struct cfg80211_ops {
955 int (*get_tx_power)(struct wiphy *wiphy, int *dbm); 957 int (*get_tx_power)(struct wiphy *wiphy, int *dbm);
956 958
957 void (*rfkill_poll)(struct wiphy *wiphy); 959 void (*rfkill_poll)(struct wiphy *wiphy);
960
961#ifdef CONFIG_NL80211_TESTMODE
962 int (*testmode_cmd)(struct wiphy *wiphy, void *data, int len);
963#endif
958}; 964};
959 965
960/* 966/*
@@ -1705,4 +1711,81 @@ void wiphy_rfkill_start_polling(struct wiphy *wiphy);
1705 */ 1711 */
1706void wiphy_rfkill_stop_polling(struct wiphy *wiphy); 1712void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
1707 1713
1714#ifdef CONFIG_NL80211_TESTMODE
1715/**
1716 * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
1717 * @wiphy: the wiphy
1718 * @approxlen: an upper bound of the length of the data that will
1719 * be put into the skb
1720 *
1721 * This function allocates and pre-fills an skb for a reply to
1722 * the testmode command. Since it is intended for a reply, calling
1723 * it outside of the @testmode_cmd operation is invalid.
1724 *
1725 * The returned skb (or %NULL if any errors happen) is pre-filled
1726 * with the wiphy index and set up in a way that any data that is
1727 * put into the skb (with skb_put(), nla_put() or similar) will end
1728 * up being within the %NL80211_ATTR_TESTDATA attribute, so all that
1729 * needs to be done with the skb is adding data for the corresponding
1730 * userspace tool which can then read that data out of the testdata
1731 * attribute. You must not modify the skb in any other way.
1732 *
1733 * When done, call cfg80211_testmode_reply() with the skb and return
1734 * its error code as the result of the @testmode_cmd operation.
1735 */
1736struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy,
1737 int approxlen);
1738
1739/**
1740 * cfg80211_testmode_reply - send the reply skb
1741 * @skb: The skb, must have been allocated with
1742 * cfg80211_testmode_alloc_reply_skb()
1743 *
1744 * Returns an error code or 0 on success, since calling this
1745 * function will usually be the last thing before returning
1746 * from the @testmode_cmd you should return the error code.
1747 * Note that this function consumes the skb regardless of the
1748 * return value.
1749 */
1750int cfg80211_testmode_reply(struct sk_buff *skb);
1751
1752/**
1753 * cfg80211_testmode_alloc_event_skb - allocate testmode event
1754 * @wiphy: the wiphy
1755 * @approxlen: an upper bound of the length of the data that will
1756 * be put into the skb
1757 * @gfp: allocation flags
1758 *
1759 * This function allocates and pre-fills an skb for an event on the
1760 * testmode multicast group.
1761 *
1762 * The returned skb (or %NULL if any errors happen) is set up in the
1763 * same way as with cfg80211_testmode_alloc_reply_skb() but prepared
1764 * for an event. As there, you should simply add data to it that will
1765 * then end up in the %NL80211_ATTR_TESTDATA attribute. Again, you must
1766 * not modify the skb in any other way.
1767 *
1768 * When done filling the skb, call cfg80211_testmode_event() with the
1769 * skb to send the event.
1770 */
1771struct sk_buff *cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy,
1772 int approxlen, gfp_t gfp);
1773
1774/**
1775 * cfg80211_testmode_event - send the event
1776 * @skb: The skb, must have been allocated with
1777 * cfg80211_testmode_alloc_event_skb()
1778 * @gfp: allocation flags
1779 *
1780 * This function sends the given @skb, which must have been allocated
1781 * by cfg80211_testmode_alloc_event_skb(), as an event. It always
1782 * consumes it.
1783 */
1784void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp);
1785
1786#define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
1787#else
1788#define CFG80211_TESTMODE_CMD(cmd)
1789#endif
1790
1708#endif /* __NET_CFG80211_H */ 1791#endif /* __NET_CFG80211_H */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index fe80771d95f1..ce7cb1b5d453 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1416,6 +1416,8 @@ enum ieee80211_ampdu_mlme_action {
1416 * @rfkill_poll: Poll rfkill hardware state. If you need this, you also 1416 * @rfkill_poll: Poll rfkill hardware state. If you need this, you also
1417 * need to set wiphy->rfkill_poll to %true before registration, 1417 * need to set wiphy->rfkill_poll to %true before registration,
1418 * and need to call wiphy_rfkill_set_hw_state() in the callback. 1418 * and need to call wiphy_rfkill_set_hw_state() in the callback.
1419 *
1420 * @testmode_cmd: Implement a cfg80211 test mode command.
1419 */ 1421 */
1420struct ieee80211_ops { 1422struct ieee80211_ops {
1421 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); 1423 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
@@ -1466,6 +1468,9 @@ struct ieee80211_ops {
1466 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 1468 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
1467 1469
1468 void (*rfkill_poll)(struct ieee80211_hw *hw); 1470 void (*rfkill_poll)(struct ieee80211_hw *hw);
1471#ifdef CONFIG_NL80211_TESTMODE
1472 int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len);
1473#endif
1469}; 1474};
1470 1475
1471/** 1476/**