aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/dvm
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-06-17 17:13:31 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-06-18 05:51:57 -0400
commit49464ae502680e362be519ac024a0f5998faaa7e (patch)
tree7ec2113cdc9d08153afb47a21e50327ef696f1ca /drivers/net/wireless/iwlwifi/dvm
parent44cc429cad4efd1f248b73bf6d692dfa5370dd58 (diff)
iwlwifi: remove testmode
The old nl80211 testmode is no longer useful in iwlwifi, we're moving towards a new model internally and there's no open tool to use it, so remove it. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/dvm')
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/Makefile1
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/agn.h37
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/dev.h13
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/lib.c6
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/main.c11
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/rs.c14
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/rx.c37
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/testmode.c471
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/tx.c12
10 files changed, 12 insertions, 592 deletions
diff --git a/drivers/net/wireless/iwlwifi/dvm/Makefile b/drivers/net/wireless/iwlwifi/dvm/Makefile
index 5ff76b204141..dce7ab2e0c4b 100644
--- a/drivers/net/wireless/iwlwifi/dvm/Makefile
+++ b/drivers/net/wireless/iwlwifi/dvm/Makefile
@@ -8,6 +8,5 @@ iwldvm-objs += scan.o led.o
8iwldvm-objs += rxon.o devices.o 8iwldvm-objs += rxon.o devices.o
9 9
10iwldvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o 10iwldvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o
11iwldvm-$(CONFIG_IWLWIFI_DEVICE_TESTMODE) += testmode.o
12 11
13ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/../ 12ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/../
diff --git a/drivers/net/wireless/iwlwifi/dvm/agn.h b/drivers/net/wireless/iwlwifi/dvm/agn.h
index de2c9514bef6..18355110deff 100644
--- a/drivers/net/wireless/iwlwifi/dvm/agn.h
+++ b/drivers/net/wireless/iwlwifi/dvm/agn.h
@@ -405,43 +405,6 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
405 405
406extern int iwl_alive_start(struct iwl_priv *priv); 406extern int iwl_alive_start(struct iwl_priv *priv);
407 407
408/* testmode support */
409#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
410
411extern int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data,
412 int len);
413extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw,
414 struct sk_buff *skb,
415 struct netlink_callback *cb,
416 void *data, int len);
417extern void iwl_testmode_init(struct iwl_priv *priv);
418extern void iwl_testmode_free(struct iwl_priv *priv);
419
420#else
421
422static inline
423int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
424{
425 return -ENOSYS;
426}
427
428static inline
429int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
430 struct netlink_callback *cb,
431 void *data, int len)
432{
433 return -ENOSYS;
434}
435
436static inline void iwl_testmode_init(struct iwl_priv *priv)
437{
438}
439
440static inline void iwl_testmode_free(struct iwl_priv *priv)
441{
442}
443#endif
444
445#ifdef CONFIG_IWLWIFI_DEBUG 408#ifdef CONFIG_IWLWIFI_DEBUG
446void iwl_print_rx_config_cmd(struct iwl_priv *priv, 409void iwl_print_rx_config_cmd(struct iwl_priv *priv,
447 enum iwl_rxon_context_id ctxid); 410 enum iwl_rxon_context_id ctxid);
diff --git a/drivers/net/wireless/iwlwifi/dvm/dev.h b/drivers/net/wireless/iwlwifi/dvm/dev.h
index f1b8df16dbba..310a6783051e 100644
--- a/drivers/net/wireless/iwlwifi/dvm/dev.h
+++ b/drivers/net/wireless/iwlwifi/dvm/dev.h
@@ -52,8 +52,6 @@
52#include "rs.h" 52#include "rs.h"
53#include "tt.h" 53#include "tt.h"
54 54
55#include "iwl-test.h"
56
57/* CT-KILL constants */ 55/* CT-KILL constants */
58#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ 56#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
59#define CT_KILL_THRESHOLD 114 /* in Celsius */ 57#define CT_KILL_THRESHOLD 114 /* in Celsius */
@@ -691,10 +689,6 @@ struct iwl_priv {
691 struct iwl_spectrum_notification measure_report; 689 struct iwl_spectrum_notification measure_report;
692 u8 measurement_status; 690 u8 measurement_status;
693 691
694#define IWL_OWNERSHIP_DRIVER 0
695#define IWL_OWNERSHIP_TM 1
696 u8 ucode_owner;
697
698 /* ucode beacon time */ 692 /* ucode beacon time */
699 u32 ucode_beacon_time; 693 u32 ucode_beacon_time;
700 int missed_beacon_threshold; 694 int missed_beacon_threshold;
@@ -889,7 +883,7 @@ struct iwl_priv {
889#endif /* CONFIG_IWLWIFI_DEBUGFS */ 883#endif /* CONFIG_IWLWIFI_DEBUGFS */
890 884
891 struct iwl_nvm_data *nvm_data; 885 struct iwl_nvm_data *nvm_data;
892 /* eeprom blob for debugfs/testmode */ 886 /* eeprom blob for debugfs */
893 u8 *eeprom_blob; 887 u8 *eeprom_blob;
894 size_t eeprom_blob_size; 888 size_t eeprom_blob_size;
895 889
@@ -905,11 +899,6 @@ struct iwl_priv {
905 unsigned long blink_on, blink_off; 899 unsigned long blink_on, blink_off;
906 bool led_registered; 900 bool led_registered;
907 901
908#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
909 struct iwl_test tst;
910 u32 tm_fixed_rate;
911#endif
912
913 /* WoWLAN GTK rekey data */ 902 /* WoWLAN GTK rekey data */
914 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN]; 903 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
915 __le64 replay_ctr; 904 __le64 replay_ctr;
diff --git a/drivers/net/wireless/iwlwifi/dvm/lib.c b/drivers/net/wireless/iwlwifi/dvm/lib.c
index 9879550a0fea..3d5bdc4217a8 100644
--- a/drivers/net/wireless/iwlwifi/dvm/lib.c
+++ b/drivers/net/wireless/iwlwifi/dvm/lib.c
@@ -1288,12 +1288,6 @@ int iwl_dvm_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1288 if (!(cmd->flags & CMD_ASYNC)) 1288 if (!(cmd->flags & CMD_ASYNC))
1289 lockdep_assert_held(&priv->mutex); 1289 lockdep_assert_held(&priv->mutex);
1290 1290
1291 if (priv->ucode_owner == IWL_OWNERSHIP_TM &&
1292 !(cmd->flags & CMD_ON_DEMAND)) {
1293 IWL_DEBUG_HC(priv, "tm own the uCode, no regular hcmd send\n");
1294 return -EIO;
1295 }
1296
1297 return iwl_trans_send_cmd(priv->trans, cmd); 1291 return iwl_trans_send_cmd(priv->trans, cmd);
1298} 1292}
1299 1293
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index c0039a992909..593aaf4d90f8 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -1765,8 +1765,6 @@ struct ieee80211_ops iwlagn_hw_ops = {
1765 .remain_on_channel = iwlagn_mac_remain_on_channel, 1765 .remain_on_channel = iwlagn_mac_remain_on_channel,
1766 .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, 1766 .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel,
1767 .rssi_callback = iwlagn_mac_rssi_callback, 1767 .rssi_callback = iwlagn_mac_rssi_callback,
1768 CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd)
1769 CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump)
1770 .set_tim = iwlagn_mac_set_tim, 1768 .set_tim = iwlagn_mac_set_tim,
1771}; 1769};
1772 1770
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
index 71db0895602d..3952ddf2ddb2 100644
--- a/drivers/net/wireless/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/iwlwifi/dvm/main.c
@@ -1105,8 +1105,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
1105 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 1105 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
1106 priv->agg_tids_count = 0; 1106 priv->agg_tids_count = 0;
1107 1107
1108 priv->ucode_owner = IWL_OWNERSHIP_DRIVER;
1109
1110 priv->rx_statistics_jiffies = jiffies; 1108 priv->rx_statistics_jiffies = jiffies;
1111 1109
1112 /* Choose which receivers/antennas to use */ 1110 /* Choose which receivers/antennas to use */
@@ -1172,12 +1170,6 @@ static void iwl_option_config(struct iwl_priv *priv)
1172 IWL_INFO(priv, "CONFIG_IWLWIFI_DEVICE_TRACING disabled\n"); 1170 IWL_INFO(priv, "CONFIG_IWLWIFI_DEVICE_TRACING disabled\n");
1173#endif 1171#endif
1174 1172
1175#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
1176 IWL_INFO(priv, "CONFIG_IWLWIFI_DEVICE_TESTMODE enabled\n");
1177#else
1178 IWL_INFO(priv, "CONFIG_IWLWIFI_DEVICE_TESTMODE disabled\n");
1179#endif
1180
1181#ifdef CONFIG_IWLWIFI_P2P 1173#ifdef CONFIG_IWLWIFI_P2P
1182 IWL_INFO(priv, "CONFIG_IWLWIFI_P2P enabled\n"); 1174 IWL_INFO(priv, "CONFIG_IWLWIFI_P2P enabled\n");
1183#else 1175#else
@@ -1451,7 +1443,6 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
1451 ********************/ 1443 ********************/
1452 iwl_setup_deferred_work(priv); 1444 iwl_setup_deferred_work(priv);
1453 iwl_setup_rx_handlers(priv); 1445 iwl_setup_rx_handlers(priv);
1454 iwl_testmode_init(priv);
1455 1446
1456 iwl_power_initialize(priv); 1447 iwl_power_initialize(priv);
1457 iwl_tt_initialize(priv); 1448 iwl_tt_initialize(priv);
@@ -1488,7 +1479,6 @@ out_mac80211_unregister:
1488 iwlagn_mac_unregister(priv); 1479 iwlagn_mac_unregister(priv);
1489out_destroy_workqueue: 1480out_destroy_workqueue:
1490 iwl_tt_exit(priv); 1481 iwl_tt_exit(priv);
1491 iwl_testmode_free(priv);
1492 iwl_cancel_deferred_work(priv); 1482 iwl_cancel_deferred_work(priv);
1493 destroy_workqueue(priv->workqueue); 1483 destroy_workqueue(priv->workqueue);
1494 priv->workqueue = NULL; 1484 priv->workqueue = NULL;
@@ -1510,7 +1500,6 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
1510 1500
1511 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); 1501 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
1512 1502
1513 iwl_testmode_free(priv);
1514 iwlagn_mac_unregister(priv); 1503 iwlagn_mac_unregister(priv);
1515 1504
1516 iwl_tt_exit(priv); 1505 iwl_tt_exit(priv);
diff --git a/drivers/net/wireless/iwlwifi/dvm/rs.c b/drivers/net/wireless/iwlwifi/dvm/rs.c
index 99d989a4510b..18e746b53b16 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rs.c
@@ -351,12 +351,6 @@ static void rs_program_fix_rate(struct iwl_priv *priv,
351 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 351 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
352 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 352 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
353 353
354#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
355 /* testmode has higher priority to overwirte the fixed rate */
356 if (priv->tm_fixed_rate)
357 lq_sta->dbg_fixed_rate = priv->tm_fixed_rate;
358#endif
359
360 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", 354 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n",
361 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); 355 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate);
362 356
@@ -1078,11 +1072,6 @@ done:
1078 if (sta && sta->supp_rates[sband->band]) 1072 if (sta && sta->supp_rates[sband->band])
1079 rs_rate_scale_perform(priv, skb, sta, lq_sta); 1073 rs_rate_scale_perform(priv, skb, sta, lq_sta);
1080 1074
1081#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_IWLWIFI_DEVICE_TESTMODE)
1082 if ((priv->tm_fixed_rate) &&
1083 (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate))
1084 rs_program_fix_rate(priv, lq_sta);
1085#endif
1086 if (priv->lib->bt_params && priv->lib->bt_params->advanced_bt_coexist) 1075 if (priv->lib->bt_params && priv->lib->bt_params->advanced_bt_coexist)
1087 rs_bt_update_lq(priv, ctx, lq_sta); 1076 rs_bt_update_lq(priv, ctx, lq_sta);
1088} 1077}
@@ -2908,9 +2897,6 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i
2908 if (sband->band == IEEE80211_BAND_5GHZ) 2897 if (sband->band == IEEE80211_BAND_5GHZ)
2909 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2898 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
2910 lq_sta->is_agg = 0; 2899 lq_sta->is_agg = 0;
2911#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
2912 priv->tm_fixed_rate = 0;
2913#endif
2914#ifdef CONFIG_MAC80211_DEBUGFS 2900#ifdef CONFIG_MAC80211_DEBUGFS
2915 lq_sta->dbg_fixed_rate = 0; 2901 lq_sta->dbg_fixed_rate = 0;
2916#endif 2902#endif
diff --git a/drivers/net/wireless/iwlwifi/dvm/rx.c b/drivers/net/wireless/iwlwifi/dvm/rx.c
index 5d31a1a15849..d71776dd1e6a 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rx.c
@@ -1119,32 +1119,17 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
1119 */ 1119 */
1120 iwl_notification_wait_notify(&priv->notif_wait, pkt); 1120 iwl_notification_wait_notify(&priv->notif_wait, pkt);
1121 1121
1122#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE 1122 /* Based on type of command response or notification,
1123 /* 1123 * handle those that need handling via function in
1124 * RX data may be forwarded to userspace in one 1124 * rx_handlers table. See iwl_setup_rx_handlers() */
1125 * of two cases: the user owns the fw through testmode or when 1125 if (priv->rx_handlers[pkt->hdr.cmd]) {
1126 * the user requested to monitor the rx w/o affecting the regular flow. 1126 priv->rx_handlers_stats[pkt->hdr.cmd]++;
1127 * In these cases the iwl_test object will handle forwarding the rx 1127 err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd);
1128 * data to user space. 1128 } else {
1129 * Note that if the ownership flag != IWL_OWNERSHIP_TM the flow 1129 /* No handling needed */
1130 * continues. 1130 IWL_DEBUG_RX(priv, "No handler needed for %s, 0x%02x\n",
1131 */ 1131 iwl_dvm_get_cmd_string(pkt->hdr.cmd),
1132 iwl_test_rx(&priv->tst, rxb); 1132 pkt->hdr.cmd);
1133#endif
1134
1135 if (priv->ucode_owner != IWL_OWNERSHIP_TM) {
1136 /* Based on type of command response or notification,
1137 * handle those that need handling via function in
1138 * rx_handlers table. See iwl_setup_rx_handlers() */
1139 if (priv->rx_handlers[pkt->hdr.cmd]) {
1140 priv->rx_handlers_stats[pkt->hdr.cmd]++;
1141 err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd);
1142 } else {
1143 /* No handling needed */
1144 IWL_DEBUG_RX(priv, "No handler needed for %s, 0x%02x\n",
1145 iwl_dvm_get_cmd_string(pkt->hdr.cmd),
1146 pkt->hdr.cmd);
1147 }
1148 } 1133 }
1149 return err; 1134 return err;
1150} 1135}
diff --git a/drivers/net/wireless/iwlwifi/dvm/testmode.c b/drivers/net/wireless/iwlwifi/dvm/testmode.c
deleted file mode 100644
index b89b9d9b9969..000000000000
--- a/drivers/net/wireless/iwlwifi/dvm/testmode.c
+++ /dev/null
@@ -1,471 +0,0 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2010 - 2013 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2010 - 2013 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63
64#include <linux/init.h>
65#include <linux/kernel.h>
66#include <linux/module.h>
67#include <linux/dma-mapping.h>
68#include <net/net_namespace.h>
69#include <linux/netdevice.h>
70#include <net/cfg80211.h>
71#include <net/mac80211.h>
72#include <net/netlink.h>
73
74#include "iwl-debug.h"
75#include "iwl-trans.h"
76#include "dev.h"
77#include "agn.h"
78#include "iwl-test.h"
79#include "iwl-testmode.h"
80
81static int iwl_testmode_send_cmd(struct iwl_op_mode *op_mode,
82 struct iwl_host_cmd *cmd)
83{
84 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
85 return iwl_dvm_send_cmd(priv, cmd);
86}
87
88static bool iwl_testmode_valid_hw_addr(u32 addr)
89{
90 if (iwlagn_hw_valid_rtc_data_addr(addr))
91 return true;
92
93 if (IWLAGN_RTC_INST_LOWER_BOUND <= addr &&
94 addr < IWLAGN_RTC_INST_UPPER_BOUND)
95 return true;
96
97 return false;
98}
99
100static u32 iwl_testmode_get_fw_ver(struct iwl_op_mode *op_mode)
101{
102 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
103 return priv->fw->ucode_ver;
104}
105
106static struct sk_buff*
107iwl_testmode_alloc_reply(struct iwl_op_mode *op_mode, int len)
108{
109 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
110 return cfg80211_testmode_alloc_reply_skb(priv->hw->wiphy, len);
111}
112
113static int iwl_testmode_reply(struct iwl_op_mode *op_mode, struct sk_buff *skb)
114{
115 return cfg80211_testmode_reply(skb);
116}
117
118static struct sk_buff *iwl_testmode_alloc_event(struct iwl_op_mode *op_mode,
119 int len)
120{
121 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
122 return cfg80211_testmode_alloc_event_skb(priv->hw->wiphy, len,
123 GFP_ATOMIC);
124}
125
126static void iwl_testmode_event(struct iwl_op_mode *op_mode, struct sk_buff *skb)
127{
128 return cfg80211_testmode_event(skb, GFP_ATOMIC);
129}
130
131static struct iwl_test_ops tst_ops = {
132 .send_cmd = iwl_testmode_send_cmd,
133 .valid_hw_addr = iwl_testmode_valid_hw_addr,
134 .get_fw_ver = iwl_testmode_get_fw_ver,
135 .alloc_reply = iwl_testmode_alloc_reply,
136 .reply = iwl_testmode_reply,
137 .alloc_event = iwl_testmode_alloc_event,
138 .event = iwl_testmode_event,
139};
140
141void iwl_testmode_init(struct iwl_priv *priv)
142{
143 iwl_test_init(&priv->tst, priv->trans, &tst_ops);
144}
145
146void iwl_testmode_free(struct iwl_priv *priv)
147{
148 iwl_test_free(&priv->tst);
149}
150
151static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv)
152{
153 struct iwl_notification_wait calib_wait;
154 static const u8 calib_complete[] = {
155 CALIBRATION_COMPLETE_NOTIFICATION
156 };
157 int ret;
158
159 iwl_init_notification_wait(&priv->notif_wait, &calib_wait,
160 calib_complete, ARRAY_SIZE(calib_complete),
161 NULL, NULL);
162 ret = iwl_init_alive_start(priv);
163 if (ret) {
164 IWL_ERR(priv, "Fail init calibration: %d\n", ret);
165 goto cfg_init_calib_error;
166 }
167
168 ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, 2 * HZ);
169 if (ret)
170 IWL_ERR(priv, "Error detecting"
171 " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret);
172 return ret;
173
174cfg_init_calib_error:
175 iwl_remove_notification(&priv->notif_wait, &calib_wait);
176 return ret;
177}
178
179/*
180 * This function handles the user application commands for driver.
181 *
182 * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
183 * handlers respectively.
184 *
185 * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned
186 * value of the actual command execution is replied to the user application.
187 *
188 * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP
189 * is used for carry the message while IWL_TM_ATTR_COMMAND must set to
190 * IWL_TM_CMD_DEV2APP_SYNC_RSP.
191 *
192 * @hw: ieee80211_hw object that represents the device
193 * @tb: gnl message fields from the user space
194 */
195static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
196{
197 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
198 struct iwl_trans *trans = priv->trans;
199 struct sk_buff *skb;
200 unsigned char *rsp_data_ptr = NULL;
201 int status = 0, rsp_data_len = 0;
202 u32 inst_size = 0, data_size = 0;
203 const struct fw_img *img;
204
205 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
206 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
207 rsp_data_ptr = (unsigned char *)priv->cfg->name;
208 rsp_data_len = strlen(priv->cfg->name);
209 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
210 rsp_data_len + 20);
211 if (!skb) {
212 IWL_ERR(priv, "Memory allocation fail\n");
213 return -ENOMEM;
214 }
215 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
216 IWL_TM_CMD_DEV2APP_SYNC_RSP) ||
217 nla_put(skb, IWL_TM_ATTR_SYNC_RSP,
218 rsp_data_len, rsp_data_ptr))
219 goto nla_put_failure;
220 status = cfg80211_testmode_reply(skb);
221 if (status < 0)
222 IWL_ERR(priv, "Error sending msg : %d\n", status);
223 break;
224
225 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
226 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);
227 if (status)
228 IWL_ERR(priv, "Error loading init ucode: %d\n", status);
229 break;
230
231 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
232 iwl_testmode_cfg_init_calib(priv);
233 priv->ucode_loaded = false;
234 iwl_trans_stop_device(trans);
235 break;
236
237 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
238 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
239 if (status) {
240 IWL_ERR(priv,
241 "Error loading runtime ucode: %d\n", status);
242 break;
243 }
244 status = iwl_alive_start(priv);
245 if (status)
246 IWL_ERR(priv,
247 "Error starting the device: %d\n", status);
248 break;
249
250 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
251 iwl_scan_cancel_timeout(priv, 200);
252 priv->ucode_loaded = false;
253 iwl_trans_stop_device(trans);
254 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN);
255 if (status) {
256 IWL_ERR(priv,
257 "Error loading WOWLAN ucode: %d\n", status);
258 break;
259 }
260 status = iwl_alive_start(priv);
261 if (status)
262 IWL_ERR(priv,
263 "Error starting the device: %d\n", status);
264 break;
265
266 case IWL_TM_CMD_APP2DEV_GET_EEPROM:
267 if (priv->eeprom_blob) {
268 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
269 priv->eeprom_blob_size + 20);
270 if (!skb) {
271 IWL_ERR(priv, "Memory allocation fail\n");
272 return -ENOMEM;
273 }
274 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
275 IWL_TM_CMD_DEV2APP_EEPROM_RSP) ||
276 nla_put(skb, IWL_TM_ATTR_EEPROM,
277 priv->eeprom_blob_size,
278 priv->eeprom_blob))
279 goto nla_put_failure;
280 status = cfg80211_testmode_reply(skb);
281 if (status < 0)
282 IWL_ERR(priv, "Error sending msg : %d\n",
283 status);
284 } else
285 return -ENODATA;
286 break;
287
288 case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
289 if (!tb[IWL_TM_ATTR_FIXRATE]) {
290 IWL_ERR(priv, "Missing fixrate setting\n");
291 return -ENOMSG;
292 }
293 priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]);
294 break;
295
296 case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
297 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8);
298 if (!skb) {
299 IWL_ERR(priv, "Memory allocation fail\n");
300 return -ENOMEM;
301 }
302 if (!priv->ucode_loaded) {
303 IWL_ERR(priv, "No uCode has not been loaded\n");
304 return -EINVAL;
305 } else {
306 img = &priv->fw->img[priv->cur_ucode];
307 inst_size = img->sec[IWL_UCODE_SECTION_INST].len;
308 data_size = img->sec[IWL_UCODE_SECTION_DATA].len;
309 }
310 if (nla_put_u32(skb, IWL_TM_ATTR_FW_TYPE, priv->cur_ucode) ||
311 nla_put_u32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size) ||
312 nla_put_u32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size))
313 goto nla_put_failure;
314 status = cfg80211_testmode_reply(skb);
315 if (status < 0)
316 IWL_ERR(priv, "Error sending msg : %d\n", status);
317 break;
318
319 default:
320 IWL_ERR(priv, "Unknown testmode driver command ID\n");
321 return -ENOSYS;
322 }
323 return status;
324
325nla_put_failure:
326 kfree_skb(skb);
327 return -EMSGSIZE;
328}
329
330/*
331 * This function handles the user application switch ucode ownership.
332 *
333 * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and
334 * decide who the current owner of the uCode
335 *
336 * If the current owner is OWNERSHIP_TM, then the only host command
337 * can deliver to uCode is from testmode, all the other host commands
338 * will dropped.
339 *
340 * default driver is the owner of uCode in normal operational mode
341 *
342 * @hw: ieee80211_hw object that represents the device
343 * @tb: gnl message fields from the user space
344 */
345static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
346{
347 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
348 u8 owner;
349
350 if (!tb[IWL_TM_ATTR_UCODE_OWNER]) {
351 IWL_ERR(priv, "Missing ucode owner\n");
352 return -ENOMSG;
353 }
354
355 owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
356 if (owner == IWL_OWNERSHIP_DRIVER) {
357 priv->ucode_owner = owner;
358 iwl_test_enable_notifications(&priv->tst, false);
359 } else if (owner == IWL_OWNERSHIP_TM) {
360 priv->ucode_owner = owner;
361 iwl_test_enable_notifications(&priv->tst, true);
362 } else {
363 IWL_ERR(priv, "Invalid owner\n");
364 return -EINVAL;
365 }
366 return 0;
367}
368
369/* The testmode gnl message handler that takes the gnl message from the
370 * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then
371 * invoke the corresponding handlers.
372 *
373 * This function is invoked when there is user space application sending
374 * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated
375 * by nl80211.
376 *
377 * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before
378 * dispatching it to the corresponding handler.
379 *
380 * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application;
381 * -ENOSYS is replied to the user application if the command is unknown;
382 * Otherwise, the command is dispatched to the respective handler.
383 *
384 * @hw: ieee80211_hw object that represents the device
385 * @data: pointer to user space message
386 * @len: length in byte of @data
387 */
388int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
389{
390 struct nlattr *tb[IWL_TM_ATTR_MAX];
391 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
392 int result;
393
394 result = iwl_test_parse(&priv->tst, tb, data, len);
395 if (result)
396 return result;
397
398 /* in case multiple accesses to the device happens */
399 mutex_lock(&priv->mutex);
400 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
401 case IWL_TM_CMD_APP2DEV_UCODE:
402 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
403 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
404 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
405 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
406 case IWL_TM_CMD_APP2DEV_END_TRACE:
407 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ:
408 case IWL_TM_CMD_APP2DEV_NOTIFICATIONS:
409 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
410 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
411 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE:
412 result = iwl_test_handle_cmd(&priv->tst, tb);
413 break;
414
415 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
416 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
417 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
418 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
419 case IWL_TM_CMD_APP2DEV_GET_EEPROM:
420 case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
421 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
422 case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
423 IWL_DEBUG_INFO(priv, "testmode cmd to driver\n");
424 result = iwl_testmode_driver(hw, tb);
425 break;
426
427 case IWL_TM_CMD_APP2DEV_OWNERSHIP:
428 IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n");
429 result = iwl_testmode_ownership(hw, tb);
430 break;
431
432 default:
433 IWL_ERR(priv, "Unknown testmode command\n");
434 result = -ENOSYS;
435 break;
436 }
437 mutex_unlock(&priv->mutex);
438
439 if (result)
440 IWL_ERR(priv, "Test cmd failed result=%d\n", result);
441 return result;
442}
443
444int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
445 struct netlink_callback *cb,
446 void *data, int len)
447{
448 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
449 int result;
450 u32 cmd;
451
452 if (cb->args[3]) {
453 /* offset by 1 since commands start at 0 */
454 cmd = cb->args[3] - 1;
455 } else {
456 struct nlattr *tb[IWL_TM_ATTR_MAX];
457
458 result = iwl_test_parse(&priv->tst, tb, data, len);
459 if (result)
460 return result;
461
462 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
463 cb->args[3] = cmd + 1;
464 }
465
466 /* in case multiple accesses to the device happens */
467 mutex_lock(&priv->mutex);
468 result = iwl_test_dump(&priv->tst, cmd, skb, cb);
469 mutex_unlock(&priv->mutex);
470 return result;
471}
diff --git a/drivers/net/wireless/iwlwifi/dvm/tx.c b/drivers/net/wireless/iwlwifi/dvm/tx.c
index 353a053b4eb1..5ee983faa679 100644
--- a/drivers/net/wireless/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/tx.c
@@ -162,18 +162,6 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
162 if (ieee80211_is_data(fc)) { 162 if (ieee80211_is_data(fc)) {
163 tx_cmd->initial_rate_index = 0; 163 tx_cmd->initial_rate_index = 0;
164 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; 164 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;
165#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
166 if (priv->tm_fixed_rate) {
167 /*
168 * rate overwrite by testmode
169 * we not only send lq command to change rate
170 * we also re-enforce per data pkt base.
171 */
172 tx_cmd->tx_flags &= ~TX_CMD_FLG_STA_RATE_MSK;
173 memcpy(&tx_cmd->rate_n_flags, &priv->tm_fixed_rate,
174 sizeof(tx_cmd->rate_n_flags));
175 }
176#endif
177 return; 165 return;
178 } else if (ieee80211_is_back_req(fc)) 166 } else if (ieee80211_is_back_req(fc))
179 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; 167 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;