aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlan Peer <ilan.peer@intel.com>2012-06-03 06:36:51 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-06-11 05:37:21 -0400
commit3a6490c0840c0ae67cc3a51e1b724bd7e460041e (patch)
treea4ca0fb263015d883fdc6f681442df5a9c4d60d8
parentb1abedada3fd0aa100723aa9b60b7e31c17945cb (diff)
iwlwifi: refactor testmode
Create an object that will enacpsulate the testmode functionality that is common to all op modes. * Copy definitions from dvm/dev.h * Copy the testmode logic from dvm/testmode.c * Link iwl-test object into the iwlwifi module * Modify DVM to use iwl-test object Reviewed-by: Amit Beka <amit.beka@intel.com> Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile1
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/agn.h17
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/dev.h26
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/main.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/rx.c24
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/testmode.c769
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-test.c825
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-test.h125
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-testmode.h (renamed from drivers/net/wireless/iwlwifi/dvm/testmode.h)0
9 files changed, 1027 insertions, 762 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 98c8f6449649..afa9758364ea 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -13,5 +13,6 @@ iwlwifi-objs += pcie/drv.o pcie/rx.o pcie/tx.o pcie/trans.o
13iwlwifi-objs += pcie/1000.o pcie/2000.o pcie/5000.o pcie/6000.o 13iwlwifi-objs += pcie/1000.o pcie/2000.o pcie/5000.o pcie/6000.o
14 14
15iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o 15iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o
16iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TESTMODE) += iwl-test.o
16 17
17ccflags-y += -D__CHECK_ENDIAN__ -I$(src) 18ccflags-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 2ae3608472a6..6d102413dd94 100644
--- a/drivers/net/wireless/iwlwifi/dvm/agn.h
+++ b/drivers/net/wireless/iwlwifi/dvm/agn.h
@@ -395,8 +395,10 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
395} 395}
396 396
397extern int iwl_alive_start(struct iwl_priv *priv); 397extern int iwl_alive_start(struct iwl_priv *priv);
398/* svtool */ 398
399/* testmode support */
399#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE 400#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
401
400extern int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, 402extern int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data,
401 int len); 403 int len);
402extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, 404extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw,
@@ -404,13 +406,16 @@ extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw,
404 struct netlink_callback *cb, 406 struct netlink_callback *cb,
405 void *data, int len); 407 void *data, int len);
406extern void iwl_testmode_init(struct iwl_priv *priv); 408extern void iwl_testmode_init(struct iwl_priv *priv);
407extern void iwl_testmode_cleanup(struct iwl_priv *priv); 409extern void iwl_testmode_free(struct iwl_priv *priv);
410
408#else 411#else
412
409static inline 413static inline
410int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) 414int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
411{ 415{
412 return -ENOSYS; 416 return -ENOSYS;
413} 417}
418
414static inline 419static inline
415int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, 420int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
416 struct netlink_callback *cb, 421 struct netlink_callback *cb,
@@ -418,12 +423,12 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
418{ 423{
419 return -ENOSYS; 424 return -ENOSYS;
420} 425}
421static inline 426
422void iwl_testmode_init(struct iwl_priv *priv) 427static inline void iwl_testmode_init(struct iwl_priv *priv)
423{ 428{
424} 429}
425static inline 430
426void iwl_testmode_cleanup(struct iwl_priv *priv) 431static inline void iwl_testmode_free(struct iwl_priv *priv)
427{ 432{
428} 433}
429#endif 434#endif
diff --git a/drivers/net/wireless/iwlwifi/dvm/dev.h b/drivers/net/wireless/iwlwifi/dvm/dev.h
index 89f2e1040e7f..4620b657948a 100644
--- a/drivers/net/wireless/iwlwifi/dvm/dev.h
+++ b/drivers/net/wireless/iwlwifi/dvm/dev.h
@@ -52,6 +52,8 @@
52#include "rs.h" 52#include "rs.h"
53#include "tt.h" 53#include "tt.h"
54 54
55#include "iwl-test.h"
56
55/* CT-KILL constants */ 57/* CT-KILL constants */
56#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ 58#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
57#define CT_KILL_THRESHOLD 114 /* in Celsius */ 59#define CT_KILL_THRESHOLD 114 /* in Celsius */
@@ -596,24 +598,6 @@ struct iwl_lib_ops {
596 void (*temperature)(struct iwl_priv *priv); 598 void (*temperature)(struct iwl_priv *priv);
597}; 599};
598 600
599#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
600struct iwl_testmode_trace {
601 u32 buff_size;
602 u32 total_size;
603 u32 num_chunks;
604 u8 *cpu_addr;
605 u8 *trace_addr;
606 dma_addr_t dma_addr;
607 bool trace_enabled;
608};
609struct iwl_testmode_mem {
610 u32 buff_size;
611 u32 num_chunks;
612 u8 *buff_addr;
613 bool read_in_progress;
614};
615#endif
616
617struct iwl_wipan_noa_data { 601struct iwl_wipan_noa_data {
618 struct rcu_head rcu_head; 602 struct rcu_head rcu_head;
619 u32 length; 603 u32 length;
@@ -670,8 +654,6 @@ struct iwl_priv {
670 enum ieee80211_band band; 654 enum ieee80211_band band;
671 u8 valid_contexts; 655 u8 valid_contexts;
672 656
673 void (*pre_rx_handler)(struct iwl_priv *priv,
674 struct iwl_rx_cmd_buffer *rxb);
675 int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv, 657 int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
676 struct iwl_rx_cmd_buffer *rxb, 658 struct iwl_rx_cmd_buffer *rxb,
677 struct iwl_device_cmd *cmd); 659 struct iwl_device_cmd *cmd);
@@ -895,9 +877,9 @@ struct iwl_priv {
895 struct led_classdev led; 877 struct led_classdev led;
896 unsigned long blink_on, blink_off; 878 unsigned long blink_on, blink_off;
897 bool led_registered; 879 bool led_registered;
880
898#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE 881#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
899 struct iwl_testmode_trace testmode_trace; 882 struct iwl_test tst;
900 struct iwl_testmode_mem testmode_mem;
901 u32 tm_fixed_rate; 883 u32 tm_fixed_rate;
902#endif 884#endif
903 885
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
index 1c2d0233a405..656ed317c6d3 100644
--- a/drivers/net/wireless/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/iwlwifi/dvm/main.c
@@ -1548,7 +1548,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
1548 1548
1549 iwl_dbgfs_unregister(priv); 1549 iwl_dbgfs_unregister(priv);
1550 1550
1551 iwl_testmode_cleanup(priv); 1551 iwl_testmode_free(priv);
1552 iwlagn_mac_unregister(priv); 1552 iwlagn_mac_unregister(priv);
1553 1553
1554 iwl_tt_exit(priv); 1554 iwl_tt_exit(priv);
diff --git a/drivers/net/wireless/iwlwifi/dvm/rx.c b/drivers/net/wireless/iwlwifi/dvm/rx.c
index 0ed90bb8b56a..afdacb25f344 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rx.c
@@ -1124,8 +1124,6 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
1124{ 1124{
1125 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1125 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1126 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); 1126 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
1127 void (*pre_rx_handler)(struct iwl_priv *,
1128 struct iwl_rx_cmd_buffer *);
1129 int err = 0; 1127 int err = 0;
1130 1128
1131 /* 1129 /*
@@ -1135,19 +1133,19 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
1135 */ 1133 */
1136 iwl_notification_wait_notify(&priv->notif_wait, pkt); 1134 iwl_notification_wait_notify(&priv->notif_wait, pkt);
1137 1135
1138 /* RX data may be forwarded to userspace (using pre_rx_handler) in one 1136#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
1139 * of two cases: the first, that the user owns the uCode through 1137 /*
1140 * testmode - in such case the pre_rx_handler is set and no further 1138 * RX data may be forwarded to userspace in one
1141 * processing takes place. The other case is when the user want to 1139 * of two cases: the user owns the fw through testmode or when
1142 * monitor the rx w/o affecting the regular flow - the pre_rx_handler 1140 * the user requested to monitor the rx w/o affecting the regular flow.
1143 * will be set but the ownership flag != IWL_OWNERSHIP_TM and the flow 1141 * In these cases the iwl_test object will handle forwarding the rx
1142 * data to user space.
1143 * Note that if the ownership flag != IWL_OWNERSHIP_TM the flow
1144 * continues. 1144 * continues.
1145 * We need to use ACCESS_ONCE to prevent a case where the handler
1146 * changes between the check and the call.
1147 */ 1145 */
1148 pre_rx_handler = ACCESS_ONCE(priv->pre_rx_handler); 1146 iwl_test_rx(&priv->tst, priv->hw, rxb);
1149 if (pre_rx_handler) 1147#endif
1150 pre_rx_handler(priv, rxb); 1148
1151 if (priv->ucode_owner != IWL_OWNERSHIP_TM) { 1149 if (priv->ucode_owner != IWL_OWNERSHIP_TM) {
1152 /* Based on type of command response or notification, 1150 /* Based on type of command response or notification,
1153 * handle those that need handling via function in 1151 * handle those that need handling via function in
diff --git a/drivers/net/wireless/iwlwifi/dvm/testmode.c b/drivers/net/wireless/iwlwifi/dvm/testmode.c
index a7b59590bb53..aa9518f13e89 100644
--- a/drivers/net/wireless/iwlwifi/dvm/testmode.c
+++ b/drivers/net/wireless/iwlwifi/dvm/testmode.c
@@ -60,6 +60,7 @@
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 * 61 *
62 *****************************************************************************/ 62 *****************************************************************************/
63
63#include <linux/init.h> 64#include <linux/init.h>
64#include <linux/kernel.h> 65#include <linux/kernel.h>
65#include <linux/module.h> 66#include <linux/module.h>
@@ -69,355 +70,55 @@
69#include <net/cfg80211.h> 70#include <net/cfg80211.h>
70#include <net/mac80211.h> 71#include <net/mac80211.h>
71#include <net/netlink.h> 72#include <net/netlink.h>
73
72#include "iwl-debug.h" 74#include "iwl-debug.h"
73#include "iwl-io.h"
74#include "iwl-trans.h" 75#include "iwl-trans.h"
75#include "iwl-fh.h"
76#include "iwl-prph.h"
77#include "dev.h" 76#include "dev.h"
78#include "agn.h" 77#include "agn.h"
79#include "testmode.h" 78#include "iwl-test.h"
80 79#include "iwl-testmode.h"
81
82/* Periphery registers absolute lower bound. This is used in order to
83 * differentiate registery access through HBUS_TARG_PRPH_* and
84 * HBUS_TARG_MEM_* accesses.
85 */
86#define IWL_TM_ABS_PRPH_START (0xA00000)
87
88/* The TLVs used in the gnl message policy between the kernel module and
89 * user space application. iwl_testmode_gnl_msg_policy is to be carried
90 * through the NL80211_CMD_TESTMODE channel regulated by nl80211.
91 * See testmode.h
92 */
93static
94struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = {
95 [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, },
96
97 [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, },
98 [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, },
99
100 [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, },
101 [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, },
102 [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, },
103
104 [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, },
105 [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, },
106 80
107 [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, 81static int iwl_testmode_send_cmd(struct iwl_op_mode *op_mode,
108 82 struct iwl_host_cmd *cmd)
109 [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, },
110 [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, },
111 [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, },
112
113 [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, },
114
115 [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, },
116
117 [IWL_TM_ATTR_MEM_ADDR] = { .type = NLA_U32, },
118 [IWL_TM_ATTR_BUFFER_SIZE] = { .type = NLA_U32, },
119 [IWL_TM_ATTR_BUFFER_DUMP] = { .type = NLA_UNSPEC, },
120
121 [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, },
122 [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, },
123 [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, },
124 [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, },
125 [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, },
126
127 [IWL_TM_ATTR_ENABLE_NOTIFICATION] = {.type = NLA_FLAG, },
128};
129
130/*
131 * See the struct iwl_rx_packet in commands.h for the format of the
132 * received events from the device
133 */
134static inline int get_event_length(struct iwl_rx_cmd_buffer *rxb)
135{ 83{
136 struct iwl_rx_packet *pkt = rxb_addr(rxb); 84 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
137 if (pkt) 85 return iwl_dvm_send_cmd(priv, cmd);
138 return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
139 else
140 return 0;
141} 86}
142 87
143 88static bool iwl_testmode_valid_hw_addr(u32 addr)
144/*
145 * This function multicasts the spontaneous messages from the device to the
146 * user space. It is invoked whenever there is a received messages
147 * from the device. This function is called within the ISR of the rx handlers
148 * in iwlagn driver.
149 *
150 * The parsing of the message content is left to the user space application,
151 * The message content is treated as unattacked raw data and is encapsulated
152 * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space.
153 *
154 * @priv: the instance of iwlwifi device
155 * @rxb: pointer to rx data content received by the ISR
156 *
157 * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[].
158 * For the messages multicasting to the user application, the mandatory
159 * TLV fields are :
160 * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT
161 * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content
162 */
163
164static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv,
165 struct iwl_rx_cmd_buffer *rxb)
166{ 89{
167 struct ieee80211_hw *hw = priv->hw; 90 if (iwlagn_hw_valid_rtc_data_addr(addr))
168 struct sk_buff *skb; 91 return true;
169 void *data;
170 int length;
171
172 data = (void *)rxb_addr(rxb);
173 length = get_event_length(rxb);
174 92
175 if (!data || length == 0) 93 if (IWLAGN_RTC_INST_LOWER_BOUND <= addr &&
176 return; 94 addr < IWLAGN_RTC_INST_UPPER_BOUND)
95 return true;
177 96
178 skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, 97 return false;
179 GFP_ATOMIC);
180 if (skb == NULL) {
181 IWL_ERR(priv,
182 "Run out of memory for messages to user space ?\n");
183 return;
184 }
185 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) ||
186 /* the length doesn't include len_n_flags field, so add it manually */
187 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, length + sizeof(__le32), data))
188 goto nla_put_failure;
189 cfg80211_testmode_event(skb, GFP_ATOMIC);
190 return;
191
192nla_put_failure:
193 kfree_skb(skb);
194 IWL_ERR(priv, "Ouch, overran buffer, check allocation!\n");
195} 98}
196 99
197void iwl_testmode_init(struct iwl_priv *priv) 100static u32 iwl_testmode_get_fw_ver(struct iwl_op_mode *op_mode)
198{ 101{
199 priv->pre_rx_handler = NULL; 102 struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
200 priv->testmode_trace.trace_enabled = false; 103 return priv->fw->ucode_ver;
201 priv->testmode_mem.read_in_progress = false;
202}
203
204static void iwl_mem_cleanup(struct iwl_priv *priv)
205{
206 if (priv->testmode_mem.read_in_progress) {
207 kfree(priv->testmode_mem.buff_addr);
208 priv->testmode_mem.buff_addr = NULL;
209 priv->testmode_mem.buff_size = 0;
210 priv->testmode_mem.num_chunks = 0;
211 priv->testmode_mem.read_in_progress = false;
212 }
213}
214
215static void iwl_trace_cleanup(struct iwl_priv *priv)
216{
217 if (priv->testmode_trace.trace_enabled) {
218 if (priv->testmode_trace.cpu_addr &&
219 priv->testmode_trace.dma_addr)
220 dma_free_coherent(priv->trans->dev,
221 priv->testmode_trace.total_size,
222 priv->testmode_trace.cpu_addr,
223 priv->testmode_trace.dma_addr);
224 priv->testmode_trace.trace_enabled = false;
225 priv->testmode_trace.cpu_addr = NULL;
226 priv->testmode_trace.trace_addr = NULL;
227 priv->testmode_trace.dma_addr = 0;
228 priv->testmode_trace.buff_size = 0;
229 priv->testmode_trace.total_size = 0;
230 }
231}
232
233
234void iwl_testmode_cleanup(struct iwl_priv *priv)
235{
236 iwl_trace_cleanup(priv);
237 iwl_mem_cleanup(priv);
238} 104}
239 105
106static struct iwl_test_ops tst_ops = {
107 .send_cmd = iwl_testmode_send_cmd,
108 .valid_hw_addr = iwl_testmode_valid_hw_addr,
109 .get_fw_ver = iwl_testmode_get_fw_ver,
110};
240 111
241/* 112void iwl_testmode_init(struct iwl_priv *priv)
242 * This function handles the user application commands to the ucode.
243 *
244 * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and
245 * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the
246 * host command to the ucode.
247 *
248 * If any mandatory field is missing, -ENOMSG is replied to the user space
249 * application; otherwise, waits for the host command to be sent and checks
250 * the return code. In case or error, it is returned, otherwise a reply is
251 * allocated and the reply RX packet
252 * is returned.
253 *
254 * @hw: ieee80211_hw object that represents the device
255 * @tb: gnl message fields from the user space
256 */
257static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
258{ 113{
259 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 114 iwl_test_init(&priv->tst, priv->trans, &tst_ops);
260 struct iwl_host_cmd cmd;
261 struct iwl_rx_packet *pkt;
262 struct sk_buff *skb;
263 void *reply_buf;
264 u32 reply_len;
265 int ret;
266 bool cmd_want_skb;
267
268 memset(&cmd, 0, sizeof(struct iwl_host_cmd));
269
270 if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] ||
271 !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) {
272 IWL_ERR(priv, "Missing ucode command mandatory fields\n");
273 return -ENOMSG;
274 }
275
276 cmd.flags = CMD_ON_DEMAND | CMD_SYNC;
277 cmd_want_skb = nla_get_flag(tb[IWL_TM_ATTR_UCODE_CMD_SKB]);
278 if (cmd_want_skb)
279 cmd.flags |= CMD_WANT_SKB;
280
281 cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]);
282 cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
283 cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
284 cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
285 IWL_DEBUG_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x,"
286 " len %d\n", cmd.id, cmd.flags, cmd.len[0]);
287
288 ret = iwl_dvm_send_cmd(priv, &cmd);
289 if (ret) {
290 IWL_ERR(priv, "Failed to send hcmd\n");
291 return ret;
292 }
293 if (!cmd_want_skb)
294 return ret;
295
296 /* Handling return of SKB to the user */
297 pkt = cmd.resp_pkt;
298 if (!pkt) {
299 IWL_ERR(priv, "HCMD received a null response packet\n");
300 return ret;
301 }
302
303 reply_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
304 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, reply_len + 20);
305 reply_buf = kmalloc(reply_len, GFP_KERNEL);
306 if (!skb || !reply_buf) {
307 kfree_skb(skb);
308 kfree(reply_buf);
309 return -ENOMEM;
310 }
311
312 /* The reply is in a page, that we cannot send to user space. */
313 memcpy(reply_buf, &(pkt->hdr), reply_len);
314 iwl_free_resp(&cmd);
315
316 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) ||
317 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf))
318 goto nla_put_failure;
319 return cfg80211_testmode_reply(skb);
320
321nla_put_failure:
322 IWL_DEBUG_INFO(priv, "Failed creating NL attributes\n");
323 return -ENOMSG;
324} 115}
325 116
326 117void iwl_testmode_free(struct iwl_priv *priv)
327/*
328 * This function handles the user application commands for register access.
329 *
330 * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
331 * handlers respectively.
332 *
333 * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the
334 * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32,
335 * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating
336 * the success of the command execution.
337 *
338 * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read
339 * value is returned with IWL_TM_ATTR_REG_VALUE32.
340 *
341 * @hw: ieee80211_hw object that represents the device
342 * @tb: gnl message fields from the user space
343 */
344static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
345{ 118{
346 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 119 iwl_test_free(&priv->tst);
347 u32 ofs, val32, cmd;
348 u8 val8;
349 struct sk_buff *skb;
350 int status = 0;
351
352 if (!tb[IWL_TM_ATTR_REG_OFFSET]) {
353 IWL_ERR(priv, "Missing register offset\n");
354 return -ENOMSG;
355 }
356 ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]);
357 IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs);
358
359 /* Allow access only to FH/CSR/HBUS in direct mode.
360 Since we don't have the upper bounds for the CSR and HBUS segments,
361 we will use only the upper bound of FH for sanity check. */
362 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
363 if ((cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 ||
364 cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 ||
365 cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8) &&
366 (ofs >= FH_MEM_UPPER_BOUND)) {
367 IWL_ERR(priv, "offset out of segment (0x0 - 0x%x)\n",
368 FH_MEM_UPPER_BOUND);
369 return -EINVAL;
370 }
371
372 switch (cmd) {
373 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
374 val32 = iwl_read_direct32(priv->trans, ofs);
375 IWL_INFO(priv, "32bit value to read 0x%x\n", val32);
376
377 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
378 if (!skb) {
379 IWL_ERR(priv, "Memory allocation fail\n");
380 return -ENOMEM;
381 }
382 if (nla_put_u32(skb, IWL_TM_ATTR_REG_VALUE32, val32))
383 goto nla_put_failure;
384 status = cfg80211_testmode_reply(skb);
385 if (status < 0)
386 IWL_ERR(priv, "Error sending msg : %d\n", status);
387 break;
388 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
389 if (!tb[IWL_TM_ATTR_REG_VALUE32]) {
390 IWL_ERR(priv, "Missing value to write\n");
391 return -ENOMSG;
392 } else {
393 val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]);
394 IWL_INFO(priv, "32bit value to write 0x%x\n", val32);
395 iwl_write_direct32(priv->trans, ofs, val32);
396 }
397 break;
398 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
399 if (!tb[IWL_TM_ATTR_REG_VALUE8]) {
400 IWL_ERR(priv, "Missing value to write\n");
401 return -ENOMSG;
402 } else {
403 val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]);
404 IWL_INFO(priv, "8bit value to write 0x%x\n", val8);
405 iwl_write8(priv->trans, ofs, val8);
406 }
407 break;
408 default:
409 IWL_ERR(priv, "Unknown testmode register command ID\n");
410 return -ENOSYS;
411 }
412
413 return status;
414
415nla_put_failure:
416 kfree_skb(skb);
417 return -EMSGSIZE;
418} 120}
419 121
420
421static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) 122static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv)
422{ 123{
423 struct iwl_notification_wait calib_wait; 124 struct iwl_notification_wait calib_wait;
@@ -469,7 +170,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
469 struct sk_buff *skb; 170 struct sk_buff *skb;
470 unsigned char *rsp_data_ptr = NULL; 171 unsigned char *rsp_data_ptr = NULL;
471 int status = 0, rsp_data_len = 0; 172 int status = 0, rsp_data_len = 0;
472 u32 devid, inst_size = 0, data_size = 0; 173 u32 inst_size = 0, data_size = 0;
473 const struct fw_img *img; 174 const struct fw_img *img;
474 175
475 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 176 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
@@ -563,39 +264,6 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
563 priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); 264 priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]);
564 break; 265 break;
565 266
566 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
567 IWL_INFO(priv, "uCode version raw: 0x%x\n",
568 priv->fw->ucode_ver);
569
570 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
571 if (!skb) {
572 IWL_ERR(priv, "Memory allocation fail\n");
573 return -ENOMEM;
574 }
575 if (nla_put_u32(skb, IWL_TM_ATTR_FW_VERSION,
576 priv->fw->ucode_ver))
577 goto nla_put_failure;
578 status = cfg80211_testmode_reply(skb);
579 if (status < 0)
580 IWL_ERR(priv, "Error sending msg : %d\n", status);
581 break;
582
583 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
584 devid = priv->trans->hw_id;
585 IWL_INFO(priv, "hw version: 0x%x\n", devid);
586
587 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
588 if (!skb) {
589 IWL_ERR(priv, "Memory allocation fail\n");
590 return -ENOMEM;
591 }
592 if (nla_put_u32(skb, IWL_TM_ATTR_DEVICE_ID, devid))
593 goto nla_put_failure;
594 status = cfg80211_testmode_reply(skb);
595 if (status < 0)
596 IWL_ERR(priv, "Error sending msg : %d\n", status);
597 break;
598
599 case IWL_TM_CMD_APP2DEV_GET_FW_INFO: 267 case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
600 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8); 268 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8);
601 if (!skb) { 269 if (!skb) {
@@ -630,125 +298,6 @@ nla_put_failure:
630 return -EMSGSIZE; 298 return -EMSGSIZE;
631} 299}
632 300
633
634/*
635 * This function handles the user application commands for uCode trace
636 *
637 * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
638 * handlers respectively.
639 *
640 * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned
641 * value of the actual command execution is replied to the user application.
642 *
643 * @hw: ieee80211_hw object that represents the device
644 * @tb: gnl message fields from the user space
645 */
646static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb)
647{
648 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
649 struct sk_buff *skb;
650 int status = 0;
651 struct device *dev = priv->trans->dev;
652
653 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
654 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
655 if (priv->testmode_trace.trace_enabled)
656 return -EBUSY;
657
658 if (!tb[IWL_TM_ATTR_TRACE_SIZE])
659 priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF;
660 else
661 priv->testmode_trace.buff_size =
662 nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]);
663 if (!priv->testmode_trace.buff_size)
664 return -EINVAL;
665 if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN ||
666 priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX)
667 return -EINVAL;
668
669 priv->testmode_trace.total_size =
670 priv->testmode_trace.buff_size + TRACE_BUFF_PADD;
671 priv->testmode_trace.cpu_addr =
672 dma_alloc_coherent(dev,
673 priv->testmode_trace.total_size,
674 &priv->testmode_trace.dma_addr,
675 GFP_KERNEL);
676 if (!priv->testmode_trace.cpu_addr)
677 return -ENOMEM;
678 priv->testmode_trace.trace_enabled = true;
679 priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN(
680 priv->testmode_trace.cpu_addr, 0x100);
681 memset(priv->testmode_trace.trace_addr, 0x03B,
682 priv->testmode_trace.buff_size);
683 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
684 sizeof(priv->testmode_trace.dma_addr) + 20);
685 if (!skb) {
686 IWL_ERR(priv, "Memory allocation fail\n");
687 iwl_trace_cleanup(priv);
688 return -ENOMEM;
689 }
690 if (nla_put(skb, IWL_TM_ATTR_TRACE_ADDR,
691 sizeof(priv->testmode_trace.dma_addr),
692 (u64 *)&priv->testmode_trace.dma_addr))
693 goto nla_put_failure;
694 status = cfg80211_testmode_reply(skb);
695 if (status < 0) {
696 IWL_ERR(priv, "Error sending msg : %d\n", status);
697 }
698 priv->testmode_trace.num_chunks =
699 DIV_ROUND_UP(priv->testmode_trace.buff_size,
700 DUMP_CHUNK_SIZE);
701 break;
702
703 case IWL_TM_CMD_APP2DEV_END_TRACE:
704 iwl_trace_cleanup(priv);
705 break;
706 default:
707 IWL_ERR(priv, "Unknown testmode mem command ID\n");
708 return -ENOSYS;
709 }
710 return status;
711
712nla_put_failure:
713 kfree_skb(skb);
714 if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) ==
715 IWL_TM_CMD_APP2DEV_BEGIN_TRACE)
716 iwl_trace_cleanup(priv);
717 return -EMSGSIZE;
718}
719
720static int iwl_testmode_trace_dump(struct ieee80211_hw *hw,
721 struct sk_buff *skb,
722 struct netlink_callback *cb)
723{
724 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
725 int idx, length;
726
727 if (priv->testmode_trace.trace_enabled &&
728 priv->testmode_trace.trace_addr) {
729 idx = cb->args[4];
730 if (idx >= priv->testmode_trace.num_chunks)
731 return -ENOENT;
732 length = DUMP_CHUNK_SIZE;
733 if (((idx + 1) == priv->testmode_trace.num_chunks) &&
734 (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE))
735 length = priv->testmode_trace.buff_size %
736 DUMP_CHUNK_SIZE;
737
738 if (nla_put(skb, IWL_TM_ATTR_TRACE_DUMP, length,
739 priv->testmode_trace.trace_addr +
740 (DUMP_CHUNK_SIZE * idx)))
741 goto nla_put_failure;
742 idx++;
743 cb->args[4] = idx;
744 return 0;
745 } else
746 return -EFAULT;
747
748 nla_put_failure:
749 return -ENOBUFS;
750}
751
752/* 301/*
753 * This function handles the user application switch ucode ownership. 302 * This function handles the user application switch ucode ownership.
754 * 303 *
@@ -777,10 +326,10 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
777 owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); 326 owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
778 if (owner == IWL_OWNERSHIP_DRIVER) { 327 if (owner == IWL_OWNERSHIP_DRIVER) {
779 priv->ucode_owner = owner; 328 priv->ucode_owner = owner;
780 priv->pre_rx_handler = NULL; 329 iwl_test_enable_notifications(&priv->tst, false);
781 } else if (owner == IWL_OWNERSHIP_TM) { 330 } else if (owner == IWL_OWNERSHIP_TM) {
782 priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt;
783 priv->ucode_owner = owner; 331 priv->ucode_owner = owner;
332 iwl_test_enable_notifications(&priv->tst, true);
784 } else { 333 } else {
785 IWL_ERR(priv, "Invalid owner\n"); 334 IWL_ERR(priv, "Invalid owner\n");
786 return -EINVAL; 335 return -EINVAL;
@@ -788,180 +337,6 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
788 return 0; 337 return 0;
789} 338}
790 339
791static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size)
792{
793 struct iwl_trans *trans = priv->trans;
794 unsigned long flags;
795 int i;
796
797 if (size & 0x3)
798 return -EINVAL;
799 priv->testmode_mem.buff_size = size;
800 priv->testmode_mem.buff_addr =
801 kmalloc(priv->testmode_mem.buff_size, GFP_KERNEL);
802 if (priv->testmode_mem.buff_addr == NULL)
803 return -ENOMEM;
804
805 /* Hard-coded periphery absolute address */
806 if (IWL_TM_ABS_PRPH_START <= addr &&
807 addr < IWL_TM_ABS_PRPH_START + PRPH_END) {
808 spin_lock_irqsave(&trans->reg_lock, flags);
809 iwl_grab_nic_access(trans);
810 iwl_write32(trans, HBUS_TARG_PRPH_RADDR,
811 addr | (3 << 24));
812 for (i = 0; i < size; i += 4)
813 *(u32 *)(priv->testmode_mem.buff_addr + i) =
814 iwl_read32(trans, HBUS_TARG_PRPH_RDAT);
815 iwl_release_nic_access(trans);
816 spin_unlock_irqrestore(&trans->reg_lock, flags);
817 } else { /* target memory (SRAM) */
818 _iwl_read_targ_mem_words(trans, addr,
819 priv->testmode_mem.buff_addr,
820 priv->testmode_mem.buff_size / 4);
821 }
822
823 priv->testmode_mem.num_chunks =
824 DIV_ROUND_UP(priv->testmode_mem.buff_size, DUMP_CHUNK_SIZE);
825 priv->testmode_mem.read_in_progress = true;
826 return 0;
827
828}
829
830static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr,
831 u32 size, unsigned char *buf)
832{
833 struct iwl_trans *trans = priv->trans;
834 u32 val, i;
835 unsigned long flags;
836
837 if (IWL_TM_ABS_PRPH_START <= addr &&
838 addr < IWL_TM_ABS_PRPH_START + PRPH_END) {
839 /* Periphery writes can be 1-3 bytes long, or DWORDs */
840 if (size < 4) {
841 memcpy(&val, buf, size);
842 spin_lock_irqsave(&trans->reg_lock, flags);
843 iwl_grab_nic_access(trans);
844 iwl_write32(trans, HBUS_TARG_PRPH_WADDR,
845 (addr & 0x0000FFFF) |
846 ((size - 1) << 24));
847 iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val);
848 iwl_release_nic_access(trans);
849 /* needed after consecutive writes w/o read */
850 mmiowb();
851 spin_unlock_irqrestore(&trans->reg_lock, flags);
852 } else {
853 if (size % 4)
854 return -EINVAL;
855 for (i = 0; i < size; i += 4)
856 iwl_write_prph(trans, addr+i,
857 *(u32 *)(buf+i));
858 }
859 } else if (iwlagn_hw_valid_rtc_data_addr(addr) ||
860 (IWLAGN_RTC_INST_LOWER_BOUND <= addr &&
861 addr < IWLAGN_RTC_INST_UPPER_BOUND)) {
862 _iwl_write_targ_mem_words(trans, addr, buf, size/4);
863 } else
864 return -EINVAL;
865 return 0;
866}
867
868/*
869 * This function handles the user application commands for SRAM data dump
870 *
871 * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and
872 * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading
873 *
874 * Several error will be retured, -EBUSY if the SRAM data retrieved by
875 * previous command has not been delivered to userspace, or -ENOMSG if
876 * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE)
877 * are missing, or -ENOMEM if the buffer allocation fails.
878 *
879 * Otherwise 0 is replied indicating the success of the SRAM reading.
880 *
881 * @hw: ieee80211_hw object that represents the device
882 * @tb: gnl message fields from the user space
883 */
884static int iwl_testmode_indirect_mem(struct ieee80211_hw *hw,
885 struct nlattr **tb)
886{
887 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
888 u32 addr, size, cmd;
889 unsigned char *buf;
890
891 /* Both read and write should be blocked, for atomicity */
892 if (priv->testmode_mem.read_in_progress)
893 return -EBUSY;
894
895 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
896 if (!tb[IWL_TM_ATTR_MEM_ADDR]) {
897 IWL_ERR(priv, "Error finding memory offset address\n");
898 return -ENOMSG;
899 }
900 addr = nla_get_u32(tb[IWL_TM_ATTR_MEM_ADDR]);
901 if (!tb[IWL_TM_ATTR_BUFFER_SIZE]) {
902 IWL_ERR(priv, "Error finding size for memory reading\n");
903 return -ENOMSG;
904 }
905 size = nla_get_u32(tb[IWL_TM_ATTR_BUFFER_SIZE]);
906
907 if (cmd == IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ)
908 return iwl_testmode_indirect_read(priv, addr, size);
909 else {
910 if (!tb[IWL_TM_ATTR_BUFFER_DUMP])
911 return -EINVAL;
912 buf = (unsigned char *) nla_data(tb[IWL_TM_ATTR_BUFFER_DUMP]);
913 return iwl_testmode_indirect_write(priv, addr, size, buf);
914 }
915}
916
917static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw,
918 struct sk_buff *skb,
919 struct netlink_callback *cb)
920{
921 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
922 int idx, length;
923
924 if (priv->testmode_mem.read_in_progress) {
925 idx = cb->args[4];
926 if (idx >= priv->testmode_mem.num_chunks) {
927 iwl_mem_cleanup(priv);
928 return -ENOENT;
929 }
930 length = DUMP_CHUNK_SIZE;
931 if (((idx + 1) == priv->testmode_mem.num_chunks) &&
932 (priv->testmode_mem.buff_size % DUMP_CHUNK_SIZE))
933 length = priv->testmode_mem.buff_size %
934 DUMP_CHUNK_SIZE;
935
936 if (nla_put(skb, IWL_TM_ATTR_BUFFER_DUMP, length,
937 priv->testmode_mem.buff_addr +
938 (DUMP_CHUNK_SIZE * idx)))
939 goto nla_put_failure;
940 idx++;
941 cb->args[4] = idx;
942 return 0;
943 } else
944 return -EFAULT;
945
946 nla_put_failure:
947 return -ENOBUFS;
948}
949
950static int iwl_testmode_notifications(struct ieee80211_hw *hw,
951 struct nlattr **tb)
952{
953 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
954 bool enable;
955
956 enable = nla_get_flag(tb[IWL_TM_ATTR_ENABLE_NOTIFICATION]);
957 if (enable)
958 priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt;
959 else
960 priv->pre_rx_handler = NULL;
961 return 0;
962}
963
964
965/* The testmode gnl message handler that takes the gnl message from the 340/* The testmode gnl message handler that takes the gnl message from the
966 * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then 341 * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then
967 * invoke the corresponding handlers. 342 * invoke the corresponding handlers.
@@ -987,32 +362,27 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
987 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 362 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
988 int result; 363 int result;
989 364
990 result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, 365 result = iwl_test_parse(&priv->tst, tb, data, len);
991 iwl_testmode_gnl_msg_policy); 366 if (result)
992 if (result != 0) {
993 IWL_ERR(priv, "Error parsing the gnl message : %d\n", result);
994 return result; 367 return result;
995 }
996 368
997 /* IWL_TM_ATTR_COMMAND is absolutely mandatory */
998 if (!tb[IWL_TM_ATTR_COMMAND]) {
999 IWL_ERR(priv, "Missing testmode command type\n");
1000 return -ENOMSG;
1001 }
1002 /* in case multiple accesses to the device happens */ 369 /* in case multiple accesses to the device happens */
1003 mutex_lock(&priv->mutex); 370 mutex_lock(&priv->mutex);
1004
1005 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 371 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
1006 case IWL_TM_CMD_APP2DEV_UCODE: 372 case IWL_TM_CMD_APP2DEV_UCODE:
1007 IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n");
1008 result = iwl_testmode_ucode(hw, tb);
1009 break;
1010 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: 373 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
1011 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: 374 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
1012 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: 375 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
1013 IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); 376 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
1014 result = iwl_testmode_reg(hw, tb); 377 case IWL_TM_CMD_APP2DEV_END_TRACE:
378 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ:
379 case IWL_TM_CMD_APP2DEV_NOTIFICATIONS:
380 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
381 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
382 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE:
383 result = iwl_test_handle_cmd(&priv->tst, hw, tb);
1015 break; 384 break;
385
1016 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: 386 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
1017 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: 387 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
1018 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: 388 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
@@ -1020,45 +390,25 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
1020 case IWL_TM_CMD_APP2DEV_GET_EEPROM: 390 case IWL_TM_CMD_APP2DEV_GET_EEPROM:
1021 case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: 391 case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
1022 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: 392 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
1023 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
1024 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
1025 case IWL_TM_CMD_APP2DEV_GET_FW_INFO: 393 case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
1026 IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); 394 IWL_DEBUG_INFO(priv, "testmode cmd to driver\n");
1027 result = iwl_testmode_driver(hw, tb); 395 result = iwl_testmode_driver(hw, tb);
1028 break; 396 break;
1029 397
1030 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
1031 case IWL_TM_CMD_APP2DEV_END_TRACE:
1032 case IWL_TM_CMD_APP2DEV_READ_TRACE:
1033 IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n");
1034 result = iwl_testmode_trace(hw, tb);
1035 break;
1036
1037 case IWL_TM_CMD_APP2DEV_OWNERSHIP: 398 case IWL_TM_CMD_APP2DEV_OWNERSHIP:
1038 IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); 399 IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n");
1039 result = iwl_testmode_ownership(hw, tb); 400 result = iwl_testmode_ownership(hw, tb);
1040 break; 401 break;
1041 402
1042 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ:
1043 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE:
1044 IWL_DEBUG_INFO(priv, "testmode indirect memory cmd "
1045 "to driver\n");
1046 result = iwl_testmode_indirect_mem(hw, tb);
1047 break;
1048
1049 case IWL_TM_CMD_APP2DEV_NOTIFICATIONS:
1050 IWL_DEBUG_INFO(priv, "testmode notifications cmd "
1051 "to driver\n");
1052 result = iwl_testmode_notifications(hw, tb);
1053 break;
1054
1055 default: 403 default:
1056 IWL_ERR(priv, "Unknown testmode command\n"); 404 IWL_ERR(priv, "Unknown testmode command\n");
1057 result = -ENOSYS; 405 result = -ENOSYS;
1058 break; 406 break;
1059 } 407 }
1060
1061 mutex_unlock(&priv->mutex); 408 mutex_unlock(&priv->mutex);
409
410 if (result)
411 IWL_ERR(priv, "Test cmd failed result=%d\n", result);
1062 return result; 412 return result;
1063} 413}
1064 414
@@ -1066,7 +416,6 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
1066 struct netlink_callback *cb, 416 struct netlink_callback *cb,
1067 void *data, int len) 417 void *data, int len)
1068{ 418{
1069 struct nlattr *tb[IWL_TM_ATTR_MAX];
1070 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 419 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
1071 int result; 420 int result;
1072 u32 cmd; 421 u32 cmd;
@@ -1075,39 +424,19 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
1075 /* offset by 1 since commands start at 0 */ 424 /* offset by 1 since commands start at 0 */
1076 cmd = cb->args[3] - 1; 425 cmd = cb->args[3] - 1;
1077 } else { 426 } else {
1078 result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, 427 struct nlattr *tb[IWL_TM_ATTR_MAX];
1079 iwl_testmode_gnl_msg_policy); 428
1080 if (result) { 429 result = iwl_test_parse(&priv->tst, tb, data, len);
1081 IWL_ERR(priv, 430 if (result)
1082 "Error parsing the gnl message : %d\n", result);
1083 return result; 431 return result;
1084 }
1085 432
1086 /* IWL_TM_ATTR_COMMAND is absolutely mandatory */
1087 if (!tb[IWL_TM_ATTR_COMMAND]) {
1088 IWL_ERR(priv, "Missing testmode command type\n");
1089 return -ENOMSG;
1090 }
1091 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); 433 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
1092 cb->args[3] = cmd + 1; 434 cb->args[3] = cmd + 1;
1093 } 435 }
1094 436
1095 /* in case multiple accesses to the device happens */ 437 /* in case multiple accesses to the device happens */
1096 mutex_lock(&priv->mutex); 438 mutex_lock(&priv->mutex);
1097 switch (cmd) { 439 result = iwl_test_dump(&priv->tst, cmd, skb, cb);
1098 case IWL_TM_CMD_APP2DEV_READ_TRACE:
1099 IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n");
1100 result = iwl_testmode_trace_dump(hw, skb, cb);
1101 break;
1102 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP:
1103 IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n");
1104 result = iwl_testmode_buffer_dump(hw, skb, cb);
1105 break;
1106 default:
1107 result = -EINVAL;
1108 break;
1109 }
1110
1111 mutex_unlock(&priv->mutex); 440 mutex_unlock(&priv->mutex);
1112 return result; 441 return result;
1113} 442}
diff --git a/drivers/net/wireless/iwlwifi/iwl-test.c b/drivers/net/wireless/iwlwifi/iwl-test.c
new file mode 100644
index 000000000000..76e18630f35d
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-test.c
@@ -0,0 +1,825 @@
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 - 2012 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 LICENSE.GPL.
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 - 2012 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 <net/netlink.h>
65#include "iwl-io.h"
66#include "iwl-fh.h"
67#include "iwl-prph.h"
68#include "iwl-trans.h"
69#include "iwl-test.h"
70#include "iwl-csr.h"
71#include "iwl-testmode.h"
72
73/*
74 * Periphery registers absolute lower bound. This is used in order to
75 * differentiate registery access through HBUS_TARG_PRPH_* and
76 * HBUS_TARG_MEM_* accesses.
77 */
78#define IWL_ABS_PRPH_START (0xA00000)
79
80/*
81 * The TLVs used in the gnl message policy between the kernel module and
82 * user space application. iwl_testmode_gnl_msg_policy is to be carried
83 * through the NL80211_CMD_TESTMODE channel regulated by nl80211.
84 * See iwl-testmode.h
85 */
86static
87struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = {
88 [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, },
89
90 [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, },
91 [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, },
92
93 [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, },
94 [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, },
95 [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, },
96
97 [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, },
98 [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, },
99
100 [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, },
101
102 [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, },
103 [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, },
104 [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, },
105
106 [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, },
107
108 [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, },
109
110 [IWL_TM_ATTR_MEM_ADDR] = { .type = NLA_U32, },
111 [IWL_TM_ATTR_BUFFER_SIZE] = { .type = NLA_U32, },
112 [IWL_TM_ATTR_BUFFER_DUMP] = { .type = NLA_UNSPEC, },
113
114 [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, },
115 [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, },
116 [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, },
117 [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, },
118 [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, },
119
120 [IWL_TM_ATTR_ENABLE_NOTIFICATION] = {.type = NLA_FLAG, },
121};
122
123static inline void iwl_test_trace_clear(struct iwl_test *tst)
124{
125 memset(&tst->trace, 0, sizeof(struct iwl_test_trace));
126}
127
128static void iwl_test_trace_stop(struct iwl_test *tst)
129{
130 if (!tst->trace.enabled)
131 return;
132
133 if (tst->trace.cpu_addr && tst->trace.dma_addr)
134 dma_free_coherent(tst->trans->dev,
135 tst->trace.tsize,
136 tst->trace.cpu_addr,
137 tst->trace.dma_addr);
138
139 iwl_test_trace_clear(tst);
140}
141
142static inline void iwl_test_mem_clear(struct iwl_test *tst)
143{
144 memset(&tst->mem, 0, sizeof(struct iwl_test_mem));
145}
146
147static inline void iwl_test_mem_stop(struct iwl_test *tst)
148{
149 if (!tst->mem.in_read)
150 return;
151
152 iwl_test_mem_clear(tst);
153}
154
155/*
156 * Initializes the test object
157 * During the lifetime of the test object it is assumed that the transport is
158 * started. The test object should be stopped before the transport is stopped.
159 */
160void iwl_test_init(struct iwl_test *tst, struct iwl_trans *trans,
161 struct iwl_test_ops *ops)
162{
163 tst->trans = trans;
164 tst->ops = ops;
165
166 iwl_test_trace_clear(tst);
167 iwl_test_mem_clear(tst);
168}
169EXPORT_SYMBOL_GPL(iwl_test_init);
170
171/*
172 * Stop the test object
173 */
174void iwl_test_free(struct iwl_test *tst)
175{
176 iwl_test_mem_stop(tst);
177 iwl_test_trace_stop(tst);
178}
179EXPORT_SYMBOL_GPL(iwl_test_free);
180
181/*
182 * This function handles the user application commands to the fw. The fw
183 * commands are sent in a synchronuous manner. In case that the user requested
184 * to get commands response, it is send to the user.
185 */
186static int iwl_test_fw_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
187 struct nlattr **tb)
188{
189 struct iwl_host_cmd cmd;
190 struct iwl_rx_packet *pkt;
191 struct sk_buff *skb;
192 void *reply_buf;
193 u32 reply_len;
194 int ret;
195 bool cmd_want_skb;
196
197 memset(&cmd, 0, sizeof(struct iwl_host_cmd));
198
199 if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] ||
200 !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) {
201 IWL_ERR(tst->trans, "Missing fw command mandatory fields\n");
202 return -ENOMSG;
203 }
204
205 cmd.flags = CMD_ON_DEMAND | CMD_SYNC;
206 cmd_want_skb = nla_get_flag(tb[IWL_TM_ATTR_UCODE_CMD_SKB]);
207 if (cmd_want_skb)
208 cmd.flags |= CMD_WANT_SKB;
209
210 cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]);
211 cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
212 cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
213 cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
214 IWL_DEBUG_INFO(tst->trans, "test fw cmd=0x%x, flags 0x%x, len %d\n",
215 cmd.id, cmd.flags, cmd.len[0]);
216
217 ret = tst->ops->send_cmd(tst->trans->op_mode, &cmd);
218 if (ret) {
219 IWL_ERR(tst->trans, "Failed to send hcmd\n");
220 return ret;
221 }
222 if (!cmd_want_skb)
223 return ret;
224
225 /* Handling return of SKB to the user */
226 pkt = cmd.resp_pkt;
227 if (!pkt) {
228 IWL_ERR(tst->trans, "HCMD received a null response packet\n");
229 return ret;
230 }
231
232 reply_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
233 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, reply_len + 20);
234 reply_buf = kmalloc(reply_len, GFP_KERNEL);
235 if (!skb || !reply_buf) {
236 kfree_skb(skb);
237 kfree(reply_buf);
238 return -ENOMEM;
239 }
240
241 /* The reply is in a page, that we cannot send to user space. */
242 memcpy(reply_buf, &(pkt->hdr), reply_len);
243 iwl_free_resp(&cmd);
244
245 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
246 IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) ||
247 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf))
248 goto nla_put_failure;
249 return cfg80211_testmode_reply(skb);
250
251nla_put_failure:
252 IWL_DEBUG_INFO(tst->trans, "Failed creating NL attributes\n");
253 kfree(reply_buf);
254 kfree_skb(skb);
255 return -ENOMSG;
256}
257
258/*
259 * Handles the user application commands for register access.
260 */
261static int iwl_test_reg(struct iwl_test *tst, struct ieee80211_hw *hw,
262 struct nlattr **tb)
263{
264 u32 ofs, val32, cmd;
265 u8 val8;
266 struct sk_buff *skb;
267 int status = 0;
268 struct iwl_trans *trans = tst->trans;
269
270 if (!tb[IWL_TM_ATTR_REG_OFFSET]) {
271 IWL_ERR(trans, "Missing reg offset\n");
272 return -ENOMSG;
273 }
274
275 ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]);
276 IWL_DEBUG_INFO(trans, "test reg access cmd offset=0x%x\n", ofs);
277
278 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
279
280 /*
281 * Allow access only to FH/CSR/HBUS in direct mode.
282 * Since we don't have the upper bounds for the CSR and HBUS segments,
283 * we will use only the upper bound of FH for sanity check.
284 */
285 if (ofs >= FH_MEM_UPPER_BOUND) {
286 IWL_ERR(trans, "offset out of segment (0x0 - 0x%x)\n",
287 FH_MEM_UPPER_BOUND);
288 return -EINVAL;
289 }
290
291 switch (cmd) {
292 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
293 val32 = iwl_read_direct32(tst->trans, ofs);
294 IWL_DEBUG_INFO(trans, "32 value to read 0x%x\n", val32);
295
296 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
297 if (!skb) {
298 IWL_ERR(trans, "Memory allocation fail\n");
299 return -ENOMEM;
300 }
301 if (nla_put_u32(skb, IWL_TM_ATTR_REG_VALUE32, val32))
302 goto nla_put_failure;
303 status = cfg80211_testmode_reply(skb);
304 if (status < 0)
305 IWL_ERR(trans, "Error sending msg : %d\n", status);
306 break;
307
308 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
309 if (!tb[IWL_TM_ATTR_REG_VALUE32]) {
310 IWL_ERR(trans, "Missing value to write\n");
311 return -ENOMSG;
312 } else {
313 val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]);
314 IWL_DEBUG_INFO(trans, "32b write val=0x%x\n", val32);
315 iwl_write_direct32(tst->trans, ofs, val32);
316 }
317 break;
318
319 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
320 if (!tb[IWL_TM_ATTR_REG_VALUE8]) {
321 IWL_ERR(trans, "Missing value to write\n");
322 return -ENOMSG;
323 } else {
324 val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]);
325 IWL_DEBUG_INFO(trans, "8b write val=0x%x\n", val8);
326 iwl_write8(tst->trans, ofs, val8);
327 }
328 break;
329
330 default:
331 IWL_ERR(trans, "Unknown test register cmd ID\n");
332 return -ENOMSG;
333 }
334
335 return status;
336
337nla_put_failure:
338 kfree_skb(skb);
339 return -EMSGSIZE;
340}
341
342/*
343 * Handles the request to start FW tracing. Allocates of the trace buffer
344 * and sends a reply to user space with the address of the allocated buffer.
345 */
346static int iwl_test_trace_begin(struct iwl_test *tst, struct ieee80211_hw *hw,
347 struct nlattr **tb)
348{
349 struct sk_buff *skb;
350 int status = 0;
351
352 if (tst->trace.enabled)
353 return -EBUSY;
354
355 if (!tb[IWL_TM_ATTR_TRACE_SIZE])
356 tst->trace.size = TRACE_BUFF_SIZE_DEF;
357 else
358 tst->trace.size =
359 nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]);
360
361 if (!tst->trace.size)
362 return -EINVAL;
363
364 if (tst->trace.size < TRACE_BUFF_SIZE_MIN ||
365 tst->trace.size > TRACE_BUFF_SIZE_MAX)
366 return -EINVAL;
367
368 tst->trace.tsize = tst->trace.size + TRACE_BUFF_PADD;
369 tst->trace.cpu_addr = dma_alloc_coherent(tst->trans->dev,
370 tst->trace.tsize,
371 &tst->trace.dma_addr,
372 GFP_KERNEL);
373 if (!tst->trace.cpu_addr)
374 return -ENOMEM;
375
376 tst->trace.enabled = true;
377 tst->trace.trace_addr = (u8 *)PTR_ALIGN(tst->trace.cpu_addr, 0x100);
378
379 memset(tst->trace.trace_addr, 0x03B, tst->trace.size);
380
381 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
382 sizeof(tst->trace.dma_addr) + 20);
383
384 if (!skb) {
385 IWL_ERR(tst->trans, "Memory allocation fail\n");
386 iwl_test_trace_stop(tst);
387 return -ENOMEM;
388 }
389
390 if (nla_put(skb, IWL_TM_ATTR_TRACE_ADDR,
391 sizeof(tst->trace.dma_addr),
392 (u64 *)&tst->trace.dma_addr))
393 goto nla_put_failure;
394
395 status = cfg80211_testmode_reply(skb);
396 if (status < 0)
397 IWL_ERR(tst->trans, "Error sending msg : %d\n", status);
398
399 tst->trace.nchunks = DIV_ROUND_UP(tst->trace.size,
400 DUMP_CHUNK_SIZE);
401
402 return status;
403
404nla_put_failure:
405 kfree_skb(skb);
406 if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) ==
407 IWL_TM_CMD_APP2DEV_BEGIN_TRACE)
408 iwl_test_trace_stop(tst);
409 return -EMSGSIZE;
410}
411
412/*
413 * Handles indirect read from the periphery or the SRAM. The read is performed
414 * to a temporary buffer. The user space application should later issue a dump
415 */
416static int iwl_test_indirect_read(struct iwl_test *tst, u32 addr, u32 size)
417{
418 struct iwl_trans *trans = tst->trans;
419 unsigned long flags;
420 int i;
421
422 if (size & 0x3)
423 return -EINVAL;
424
425 tst->mem.size = size;
426 tst->mem.addr = kmalloc(tst->mem.size, GFP_KERNEL);
427 if (tst->mem.addr == NULL)
428 return -ENOMEM;
429
430 /* Hard-coded periphery absolute address */
431 if (IWL_ABS_PRPH_START <= addr &&
432 addr < IWL_ABS_PRPH_START + PRPH_END) {
433 spin_lock_irqsave(&trans->reg_lock, flags);
434 iwl_grab_nic_access(trans);
435 iwl_write32(trans, HBUS_TARG_PRPH_RADDR,
436 addr | (3 << 24));
437 for (i = 0; i < size; i += 4)
438 *(u32 *)(tst->mem.addr + i) =
439 iwl_read32(trans, HBUS_TARG_PRPH_RDAT);
440 iwl_release_nic_access(trans);
441 spin_unlock_irqrestore(&trans->reg_lock, flags);
442 } else { /* target memory (SRAM) */
443 _iwl_read_targ_mem_words(trans, addr,
444 tst->mem.addr,
445 tst->mem.size / 4);
446 }
447
448 tst->mem.nchunks =
449 DIV_ROUND_UP(tst->mem.size, DUMP_CHUNK_SIZE);
450 tst->mem.in_read = true;
451 return 0;
452
453}
454
455/*
456 * Handles indirect write to the periphery or SRAM. The is performed to a
457 * temporary buffer.
458 */
459static int iwl_test_indirect_write(struct iwl_test *tst, u32 addr,
460 u32 size, unsigned char *buf)
461{
462 struct iwl_trans *trans = tst->trans;
463 u32 val, i;
464 unsigned long flags;
465
466 if (IWL_ABS_PRPH_START <= addr &&
467 addr < IWL_ABS_PRPH_START + PRPH_END) {
468 /* Periphery writes can be 1-3 bytes long, or DWORDs */
469 if (size < 4) {
470 memcpy(&val, buf, size);
471 spin_lock_irqsave(&trans->reg_lock, flags);
472 iwl_grab_nic_access(trans);
473 iwl_write32(trans, HBUS_TARG_PRPH_WADDR,
474 (addr & 0x0000FFFF) |
475 ((size - 1) << 24));
476 iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val);
477 iwl_release_nic_access(trans);
478 /* needed after consecutive writes w/o read */
479 mmiowb();
480 spin_unlock_irqrestore(&trans->reg_lock, flags);
481 } else {
482 if (size % 4)
483 return -EINVAL;
484 for (i = 0; i < size; i += 4)
485 iwl_write_prph(trans, addr+i,
486 *(u32 *)(buf+i));
487 }
488 } else if (tst->ops->valid_hw_addr(addr)) {
489 _iwl_write_targ_mem_words(trans, addr, buf, size/4);
490 } else {
491 return -EINVAL;
492 }
493 return 0;
494}
495
496/*
497 * Handles the user application commands for indirect read/write
498 * to/from the periphery or the SRAM.
499 */
500static int iwl_test_indirect_mem(struct iwl_test *tst, struct nlattr **tb)
501{
502 u32 addr, size, cmd;
503 unsigned char *buf;
504
505 /* Both read and write should be blocked, for atomicity */
506 if (tst->mem.in_read)
507 return -EBUSY;
508
509 cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
510 if (!tb[IWL_TM_ATTR_MEM_ADDR]) {
511 IWL_ERR(tst->trans, "Error finding memory offset address\n");
512 return -ENOMSG;
513 }
514 addr = nla_get_u32(tb[IWL_TM_ATTR_MEM_ADDR]);
515 if (!tb[IWL_TM_ATTR_BUFFER_SIZE]) {
516 IWL_ERR(tst->trans, "Error finding size for memory reading\n");
517 return -ENOMSG;
518 }
519 size = nla_get_u32(tb[IWL_TM_ATTR_BUFFER_SIZE]);
520
521 if (cmd == IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ) {
522 return iwl_test_indirect_read(tst, addr, size);
523 } else {
524 if (!tb[IWL_TM_ATTR_BUFFER_DUMP])
525 return -EINVAL;
526 buf = (unsigned char *)nla_data(tb[IWL_TM_ATTR_BUFFER_DUMP]);
527 return iwl_test_indirect_write(tst, addr, size, buf);
528 }
529}
530
531/*
532 * Enable notifications to user space
533 */
534static int iwl_test_notifications(struct iwl_test *tst,
535 struct nlattr **tb)
536{
537 tst->notify = nla_get_flag(tb[IWL_TM_ATTR_ENABLE_NOTIFICATION]);
538 return 0;
539}
540
541/*
542 * Handles the request to get the device id
543 */
544static int iwl_test_get_dev_id(struct iwl_test *tst, struct ieee80211_hw *hw,
545 struct nlattr **tb)
546{
547 u32 devid = tst->trans->hw_id;
548 struct sk_buff *skb;
549 int status;
550
551 IWL_DEBUG_INFO(tst->trans, "hw version: 0x%x\n", devid);
552
553 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
554 if (!skb) {
555 IWL_ERR(tst->trans, "Memory allocation fail\n");
556 return -ENOMEM;
557 }
558
559 if (nla_put_u32(skb, IWL_TM_ATTR_DEVICE_ID, devid))
560 goto nla_put_failure;
561 status = cfg80211_testmode_reply(skb);
562 if (status < 0)
563 IWL_ERR(tst->trans, "Error sending msg : %d\n", status);
564
565 return 0;
566
567nla_put_failure:
568 kfree_skb(skb);
569 return -EMSGSIZE;
570}
571
572/*
573 * Handles the request to get the FW version
574 */
575static int iwl_test_get_fw_ver(struct iwl_test *tst, struct ieee80211_hw *hw,
576 struct nlattr **tb)
577{
578 struct sk_buff *skb;
579 int status;
580 u32 ver = tst->ops->get_fw_ver(tst->trans->op_mode);
581
582 IWL_DEBUG_INFO(tst->trans, "uCode version raw: 0x%x\n", ver);
583
584 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
585 if (!skb) {
586 IWL_ERR(tst->trans, "Memory allocation fail\n");
587 return -ENOMEM;
588 }
589
590 if (nla_put_u32(skb, IWL_TM_ATTR_FW_VERSION, ver))
591 goto nla_put_failure;
592
593 status = cfg80211_testmode_reply(skb);
594 if (status < 0)
595 IWL_ERR(tst->trans, "Error sending msg : %d\n", status);
596
597 return 0;
598
599nla_put_failure:
600 kfree_skb(skb);
601 return -EMSGSIZE;
602}
603
604/*
605 * Parse the netlink message and validate that the IWL_TM_ATTR_CMD exists
606 */
607int iwl_test_parse(struct iwl_test *tst, struct nlattr **tb,
608 void *data, int len)
609{
610 int result;
611
612 result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len,
613 iwl_testmode_gnl_msg_policy);
614 if (result) {
615 IWL_ERR(tst->trans, "Fail parse gnl msg: %d\n", result);
616 return result;
617 }
618
619 /* IWL_TM_ATTR_COMMAND is absolutely mandatory */
620 if (!tb[IWL_TM_ATTR_COMMAND]) {
621 IWL_ERR(tst->trans, "Missing testmode command type\n");
622 return -ENOMSG;
623 }
624 return 0;
625}
626EXPORT_SYMBOL_GPL(iwl_test_parse);
627
628/*
629 * Handle test commands.
630 * Returns 1 for unknown commands (not handled by the test object); negative
631 * value in case of error.
632 */
633int iwl_test_handle_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
634 struct nlattr **tb)
635{
636 int result;
637
638 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
639 case IWL_TM_CMD_APP2DEV_UCODE:
640 IWL_DEBUG_INFO(tst->trans, "test cmd to uCode\n");
641 result = iwl_test_fw_cmd(tst, hw, tb);
642 break;
643
644 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
645 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
646 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
647 IWL_DEBUG_INFO(tst->trans, "test cmd to register\n");
648 result = iwl_test_reg(tst, hw, tb);
649 break;
650
651 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
652 IWL_DEBUG_INFO(tst->trans, "test uCode trace cmd to driver\n");
653 result = iwl_test_trace_begin(tst, hw, tb);
654 break;
655
656 case IWL_TM_CMD_APP2DEV_END_TRACE:
657 iwl_test_trace_stop(tst);
658 result = 0;
659 break;
660
661 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ:
662 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE:
663 IWL_DEBUG_INFO(tst->trans, "test indirect memory cmd\n");
664 result = iwl_test_indirect_mem(tst, tb);
665 break;
666
667 case IWL_TM_CMD_APP2DEV_NOTIFICATIONS:
668 IWL_DEBUG_INFO(tst->trans, "test notifications cmd\n");
669 result = iwl_test_notifications(tst, tb);
670 break;
671
672 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
673 IWL_DEBUG_INFO(tst->trans, "test get FW ver cmd\n");
674 result = iwl_test_get_fw_ver(tst, hw, tb);
675 break;
676
677 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
678 IWL_DEBUG_INFO(tst->trans, "test Get device ID cmd\n");
679 result = iwl_test_get_dev_id(tst, hw, tb);
680 break;
681
682 default:
683 IWL_DEBUG_INFO(tst->trans, "Unknown test command\n");
684 result = 1;
685 break;
686 }
687 return result;
688}
689EXPORT_SYMBOL_GPL(iwl_test_handle_cmd);
690
691static int iwl_test_trace_dump(struct iwl_test *tst, struct sk_buff *skb,
692 struct netlink_callback *cb)
693{
694 int idx, length;
695
696 if (!tst->trace.enabled || !tst->trace.trace_addr)
697 return -EFAULT;
698
699 idx = cb->args[4];
700 if (idx >= tst->trace.nchunks)
701 return -ENOENT;
702
703 length = DUMP_CHUNK_SIZE;
704 if (((idx + 1) == tst->trace.nchunks) &&
705 (tst->trace.size % DUMP_CHUNK_SIZE))
706 length = tst->trace.size %
707 DUMP_CHUNK_SIZE;
708
709 if (nla_put(skb, IWL_TM_ATTR_TRACE_DUMP, length,
710 tst->trace.trace_addr + (DUMP_CHUNK_SIZE * idx)))
711 goto nla_put_failure;
712
713 cb->args[4] = ++idx;
714 return 0;
715
716 nla_put_failure:
717 return -ENOBUFS;
718}
719
720static int iwl_test_buffer_dump(struct iwl_test *tst, struct sk_buff *skb,
721 struct netlink_callback *cb)
722{
723 int idx, length;
724
725 if (!tst->mem.in_read)
726 return -EFAULT;
727
728 idx = cb->args[4];
729 if (idx >= tst->mem.nchunks) {
730 iwl_test_mem_stop(tst);
731 return -ENOENT;
732 }
733
734 length = DUMP_CHUNK_SIZE;
735 if (((idx + 1) == tst->mem.nchunks) &&
736 (tst->mem.size % DUMP_CHUNK_SIZE))
737 length = tst->mem.size % DUMP_CHUNK_SIZE;
738
739 if (nla_put(skb, IWL_TM_ATTR_BUFFER_DUMP, length,
740 tst->mem.addr + (DUMP_CHUNK_SIZE * idx)))
741 goto nla_put_failure;
742
743 cb->args[4] = ++idx;
744 return 0;
745
746 nla_put_failure:
747 return -ENOBUFS;
748}
749
750/*
751 * Handle dump commands.
752 * Returns 1 for unknown commands (not handled by the test object); negative
753 * value in case of error.
754 */
755int iwl_test_dump(struct iwl_test *tst, u32 cmd, struct sk_buff *skb,
756 struct netlink_callback *cb)
757{
758 int result;
759
760 switch (cmd) {
761 case IWL_TM_CMD_APP2DEV_READ_TRACE:
762 IWL_DEBUG_INFO(tst->trans, "uCode trace cmd\n");
763 result = iwl_test_trace_dump(tst, skb, cb);
764 break;
765
766 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP:
767 IWL_DEBUG_INFO(tst->trans, "testmode sram dump cmd\n");
768 result = iwl_test_buffer_dump(tst, skb, cb);
769 break;
770
771 default:
772 result = 1;
773 break;
774 }
775 return result;
776}
777EXPORT_SYMBOL_GPL(iwl_test_dump);
778
779/*
780 * Multicast a spontaneous messages from the device to the user space.
781 */
782static void iwl_test_send_rx(struct iwl_test *tst, struct ieee80211_hw *hw,
783 struct iwl_rx_cmd_buffer *rxb)
784{
785 struct sk_buff *skb;
786 struct iwl_rx_packet *data;
787 int length;
788
789 data = rxb_addr(rxb);
790 length = le32_to_cpu(data->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
791
792 /* the length doesn't include len_n_flags field, so add it manually */
793 length += sizeof(__le32);
794
795 skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length,
796 GFP_ATOMIC);
797 if (skb == NULL) {
798 IWL_ERR(tst->trans, "Out of memory for message to user\n");
799 return;
800 }
801
802 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
803 IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) ||
804 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data))
805 goto nla_put_failure;
806
807 cfg80211_testmode_event(skb, GFP_ATOMIC);
808 return;
809
810nla_put_failure:
811 kfree_skb(skb);
812 IWL_ERR(tst->trans, "Ouch, overran buffer, check allocation!\n");
813}
814
815/*
816 * Called whenever a Rx frames is recevied from the device. If notifications to
817 * the user space are requested, sends the frames to the user.
818 */
819void iwl_test_rx(struct iwl_test *tst, struct ieee80211_hw *hw,
820 struct iwl_rx_cmd_buffer *rxb)
821{
822 if (tst->notify)
823 iwl_test_send_rx(tst, hw, rxb);
824}
825EXPORT_SYMBOL_GPL(iwl_test_rx);
diff --git a/drivers/net/wireless/iwlwifi/iwl-test.h b/drivers/net/wireless/iwlwifi/iwl-test.h
new file mode 100644
index 000000000000..994615344955
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-test.h
@@ -0,0 +1,125 @@
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 - 2012 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 LICENSE.GPL.
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 - 2012 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#ifndef __IWL_TEST_H__
65#define __IWL_TEST_H__
66
67#include <linux/types.h>
68#include "iwl-trans.h"
69
70struct iwl_test_trace {
71 u32 size;
72 u32 tsize;
73 u32 nchunks;
74 u8 *cpu_addr;
75 u8 *trace_addr;
76 dma_addr_t dma_addr;
77 bool enabled;
78};
79
80struct iwl_test_mem {
81 u32 size;
82 u32 nchunks;
83 u8 *addr;
84 bool in_read;
85};
86
87struct iwl_test_ops {
88 int (*send_cmd)(struct iwl_op_mode *op_modes,
89 struct iwl_host_cmd *cmd);
90 bool (*valid_hw_addr)(u32 addr);
91 u32 (*get_fw_ver)(struct iwl_op_mode *op_mode);
92};
93
94struct iwl_test {
95 struct iwl_trans *trans;
96 struct iwl_test_ops *ops;
97 struct iwl_test_trace trace;
98 struct iwl_test_mem mem;
99 bool notify;
100};
101
102void iwl_test_init(struct iwl_test *tst, struct iwl_trans *trans,
103 struct iwl_test_ops *ops);
104
105void iwl_test_free(struct iwl_test *tst);
106
107int iwl_test_parse(struct iwl_test *tst, struct nlattr **tb,
108 void *data, int len);
109
110int iwl_test_handle_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
111 struct nlattr **tb);
112
113int iwl_test_dump(struct iwl_test *tst, u32 cmd, struct sk_buff *skb,
114 struct netlink_callback *cb);
115
116void iwl_test_rx(struct iwl_test *tst, struct ieee80211_hw *hw,
117 struct iwl_rx_cmd_buffer *rxb);
118
119static inline void iwl_test_enable_notifications(struct iwl_test *tst,
120 bool enable)
121{
122 tst->notify = enable;
123}
124
125#endif
diff --git a/drivers/net/wireless/iwlwifi/dvm/testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h
index 6ba211b09426..6ba211b09426 100644
--- a/drivers/net/wireless/iwlwifi/dvm/testmode.h
+++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h