aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlan Peer <ilan.peer@intel.com>2012-06-04 12:39:30 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-06-11 05:41:18 -0400
commitc76fe6d19b8beffe792c390c0bd215d193512f1e (patch)
tree97457f8ad76187a4422757194d0a34bb977b24f3
parent3a6490c0840c0ae67cc3a51e1b724bd7e460041e (diff)
iwlwifi: decouple testmode and iwl-test
The iwl-test flows were based on the cfg80211 testmode APIs. To remove this coupling, the op mode (during the initialization of the iwl_test object) is responsible to set the callbacks that should be used by iwl-test to allocate skbs for events and replies and to send events and replies. The current op modes implement these callbacks based on the cfg80211 testmode APIs. 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/dvm/rx.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/testmode.c31
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-test.c109
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-test.h44
4 files changed, 141 insertions, 45 deletions
diff --git a/drivers/net/wireless/iwlwifi/dvm/rx.c b/drivers/net/wireless/iwlwifi/dvm/rx.c
index afdacb25f344..c1f7a18e08dd 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rx.c
@@ -1143,7 +1143,7 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
1143 * Note that if the ownership flag != IWL_OWNERSHIP_TM the flow 1143 * Note that if the ownership flag != IWL_OWNERSHIP_TM the flow
1144 * continues. 1144 * continues.
1145 */ 1145 */
1146 iwl_test_rx(&priv->tst, priv->hw, rxb); 1146 iwl_test_rx(&priv->tst, rxb);
1147#endif 1147#endif
1148 1148
1149 if (priv->ucode_owner != IWL_OWNERSHIP_TM) { 1149 if (priv->ucode_owner != IWL_OWNERSHIP_TM) {
diff --git a/drivers/net/wireless/iwlwifi/dvm/testmode.c b/drivers/net/wireless/iwlwifi/dvm/testmode.c
index aa9518f13e89..57b918ce3b5f 100644
--- a/drivers/net/wireless/iwlwifi/dvm/testmode.c
+++ b/drivers/net/wireless/iwlwifi/dvm/testmode.c
@@ -103,10 +103,39 @@ static u32 iwl_testmode_get_fw_ver(struct iwl_op_mode *op_mode)
103 return priv->fw->ucode_ver; 103 return priv->fw->ucode_ver;
104} 104}
105 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
106static struct iwl_test_ops tst_ops = { 131static struct iwl_test_ops tst_ops = {
107 .send_cmd = iwl_testmode_send_cmd, 132 .send_cmd = iwl_testmode_send_cmd,
108 .valid_hw_addr = iwl_testmode_valid_hw_addr, 133 .valid_hw_addr = iwl_testmode_valid_hw_addr,
109 .get_fw_ver = iwl_testmode_get_fw_ver, 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,
110}; 139};
111 140
112void iwl_testmode_init(struct iwl_priv *priv) 141void iwl_testmode_init(struct iwl_priv *priv)
@@ -380,7 +409,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
380 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: 409 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
381 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: 410 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
382 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE: 411 case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE:
383 result = iwl_test_handle_cmd(&priv->tst, hw, tb); 412 result = iwl_test_handle_cmd(&priv->tst, tb);
384 break; 413 break;
385 414
386 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: 415 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
diff --git a/drivers/net/wireless/iwlwifi/iwl-test.c b/drivers/net/wireless/iwlwifi/iwl-test.c
index 76e18630f35d..7a264aee2534 100644
--- a/drivers/net/wireless/iwlwifi/iwl-test.c
+++ b/drivers/net/wireless/iwlwifi/iwl-test.c
@@ -61,7 +61,9 @@
61 * 61 *
62 *****************************************************************************/ 62 *****************************************************************************/
63 63
64#include <linux/export.h>
64#include <net/netlink.h> 65#include <net/netlink.h>
66
65#include "iwl-io.h" 67#include "iwl-io.h"
66#include "iwl-fh.h" 68#include "iwl-fh.h"
67#include "iwl-prph.h" 69#include "iwl-prph.h"
@@ -178,13 +180,51 @@ void iwl_test_free(struct iwl_test *tst)
178} 180}
179EXPORT_SYMBOL_GPL(iwl_test_free); 181EXPORT_SYMBOL_GPL(iwl_test_free);
180 182
183static inline int iwl_test_send_cmd(struct iwl_test *tst,
184 struct iwl_host_cmd *cmd)
185{
186 return tst->ops->send_cmd(tst->trans->op_mode, cmd);
187}
188
189static inline bool iwl_test_valid_hw_addr(struct iwl_test *tst, u32 addr)
190{
191 return tst->ops->valid_hw_addr(addr);
192}
193
194static inline u32 iwl_test_fw_ver(struct iwl_test *tst)
195{
196 return tst->ops->get_fw_ver(tst->trans->op_mode);
197}
198
199static inline struct sk_buff*
200iwl_test_alloc_reply(struct iwl_test *tst, int len)
201{
202 return tst->ops->alloc_reply(tst->trans->op_mode, len);
203}
204
205static inline int iwl_test_reply(struct iwl_test *tst, struct sk_buff *skb)
206{
207 return tst->ops->reply(tst->trans->op_mode, skb);
208}
209
210static inline struct sk_buff*
211iwl_test_alloc_event(struct iwl_test *tst, int len)
212{
213 return tst->ops->alloc_event(tst->trans->op_mode, len);
214}
215
216static inline void
217iwl_test_event(struct iwl_test *tst, struct sk_buff *skb)
218{
219 return tst->ops->event(tst->trans->op_mode, skb);
220}
221
181/* 222/*
182 * This function handles the user application commands to the fw. The fw 223 * 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 224 * commands are sent in a synchronuous manner. In case that the user requested
184 * to get commands response, it is send to the user. 225 * to get commands response, it is send to the user.
185 */ 226 */
186static int iwl_test_fw_cmd(struct iwl_test *tst, struct ieee80211_hw *hw, 227static int iwl_test_fw_cmd(struct iwl_test *tst, struct nlattr **tb)
187 struct nlattr **tb)
188{ 228{
189 struct iwl_host_cmd cmd; 229 struct iwl_host_cmd cmd;
190 struct iwl_rx_packet *pkt; 230 struct iwl_rx_packet *pkt;
@@ -214,7 +254,7 @@ static int iwl_test_fw_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
214 IWL_DEBUG_INFO(tst->trans, "test fw cmd=0x%x, flags 0x%x, len %d\n", 254 IWL_DEBUG_INFO(tst->trans, "test fw cmd=0x%x, flags 0x%x, len %d\n",
215 cmd.id, cmd.flags, cmd.len[0]); 255 cmd.id, cmd.flags, cmd.len[0]);
216 256
217 ret = tst->ops->send_cmd(tst->trans->op_mode, &cmd); 257 ret = iwl_test_send_cmd(tst, &cmd);
218 if (ret) { 258 if (ret) {
219 IWL_ERR(tst->trans, "Failed to send hcmd\n"); 259 IWL_ERR(tst->trans, "Failed to send hcmd\n");
220 return ret; 260 return ret;
@@ -230,7 +270,7 @@ static int iwl_test_fw_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
230 } 270 }
231 271
232 reply_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 272 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); 273 skb = iwl_test_alloc_reply(tst, reply_len + 20);
234 reply_buf = kmalloc(reply_len, GFP_KERNEL); 274 reply_buf = kmalloc(reply_len, GFP_KERNEL);
235 if (!skb || !reply_buf) { 275 if (!skb || !reply_buf) {
236 kfree_skb(skb); 276 kfree_skb(skb);
@@ -246,7 +286,7 @@ static int iwl_test_fw_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
246 IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) || 286 IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) ||
247 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf)) 287 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf))
248 goto nla_put_failure; 288 goto nla_put_failure;
249 return cfg80211_testmode_reply(skb); 289 return iwl_test_reply(tst, skb);
250 290
251nla_put_failure: 291nla_put_failure:
252 IWL_DEBUG_INFO(tst->trans, "Failed creating NL attributes\n"); 292 IWL_DEBUG_INFO(tst->trans, "Failed creating NL attributes\n");
@@ -258,8 +298,7 @@ nla_put_failure:
258/* 298/*
259 * Handles the user application commands for register access. 299 * Handles the user application commands for register access.
260 */ 300 */
261static int iwl_test_reg(struct iwl_test *tst, struct ieee80211_hw *hw, 301static int iwl_test_reg(struct iwl_test *tst, struct nlattr **tb)
262 struct nlattr **tb)
263{ 302{
264 u32 ofs, val32, cmd; 303 u32 ofs, val32, cmd;
265 u8 val8; 304 u8 val8;
@@ -293,14 +332,14 @@ static int iwl_test_reg(struct iwl_test *tst, struct ieee80211_hw *hw,
293 val32 = iwl_read_direct32(tst->trans, ofs); 332 val32 = iwl_read_direct32(tst->trans, ofs);
294 IWL_DEBUG_INFO(trans, "32 value to read 0x%x\n", val32); 333 IWL_DEBUG_INFO(trans, "32 value to read 0x%x\n", val32);
295 334
296 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); 335 skb = iwl_test_alloc_reply(tst, 20);
297 if (!skb) { 336 if (!skb) {
298 IWL_ERR(trans, "Memory allocation fail\n"); 337 IWL_ERR(trans, "Memory allocation fail\n");
299 return -ENOMEM; 338 return -ENOMEM;
300 } 339 }
301 if (nla_put_u32(skb, IWL_TM_ATTR_REG_VALUE32, val32)) 340 if (nla_put_u32(skb, IWL_TM_ATTR_REG_VALUE32, val32))
302 goto nla_put_failure; 341 goto nla_put_failure;
303 status = cfg80211_testmode_reply(skb); 342 status = iwl_test_reply(tst, skb);
304 if (status < 0) 343 if (status < 0)
305 IWL_ERR(trans, "Error sending msg : %d\n", status); 344 IWL_ERR(trans, "Error sending msg : %d\n", status);
306 break; 345 break;
@@ -343,8 +382,7 @@ nla_put_failure:
343 * Handles the request to start FW tracing. Allocates of the trace buffer 382 * 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. 383 * and sends a reply to user space with the address of the allocated buffer.
345 */ 384 */
346static int iwl_test_trace_begin(struct iwl_test *tst, struct ieee80211_hw *hw, 385static int iwl_test_trace_begin(struct iwl_test *tst, struct nlattr **tb)
347 struct nlattr **tb)
348{ 386{
349 struct sk_buff *skb; 387 struct sk_buff *skb;
350 int status = 0; 388 int status = 0;
@@ -378,9 +416,7 @@ static int iwl_test_trace_begin(struct iwl_test *tst, struct ieee80211_hw *hw,
378 416
379 memset(tst->trace.trace_addr, 0x03B, tst->trace.size); 417 memset(tst->trace.trace_addr, 0x03B, tst->trace.size);
380 418
381 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 419 skb = iwl_test_alloc_reply(tst, sizeof(tst->trace.dma_addr) + 20);
382 sizeof(tst->trace.dma_addr) + 20);
383
384 if (!skb) { 420 if (!skb) {
385 IWL_ERR(tst->trans, "Memory allocation fail\n"); 421 IWL_ERR(tst->trans, "Memory allocation fail\n");
386 iwl_test_trace_stop(tst); 422 iwl_test_trace_stop(tst);
@@ -392,7 +428,7 @@ static int iwl_test_trace_begin(struct iwl_test *tst, struct ieee80211_hw *hw,
392 (u64 *)&tst->trace.dma_addr)) 428 (u64 *)&tst->trace.dma_addr))
393 goto nla_put_failure; 429 goto nla_put_failure;
394 430
395 status = cfg80211_testmode_reply(skb); 431 status = iwl_test_reply(tst, skb);
396 if (status < 0) 432 if (status < 0)
397 IWL_ERR(tst->trans, "Error sending msg : %d\n", status); 433 IWL_ERR(tst->trans, "Error sending msg : %d\n", status);
398 434
@@ -485,7 +521,7 @@ static int iwl_test_indirect_write(struct iwl_test *tst, u32 addr,
485 iwl_write_prph(trans, addr+i, 521 iwl_write_prph(trans, addr+i,
486 *(u32 *)(buf+i)); 522 *(u32 *)(buf+i));
487 } 523 }
488 } else if (tst->ops->valid_hw_addr(addr)) { 524 } else if (iwl_test_valid_hw_addr(tst, addr)) {
489 _iwl_write_targ_mem_words(trans, addr, buf, size/4); 525 _iwl_write_targ_mem_words(trans, addr, buf, size/4);
490 } else { 526 } else {
491 return -EINVAL; 527 return -EINVAL;
@@ -541,8 +577,7 @@ static int iwl_test_notifications(struct iwl_test *tst,
541/* 577/*
542 * Handles the request to get the device id 578 * Handles the request to get the device id
543 */ 579 */
544static int iwl_test_get_dev_id(struct iwl_test *tst, struct ieee80211_hw *hw, 580static int iwl_test_get_dev_id(struct iwl_test *tst, struct nlattr **tb)
545 struct nlattr **tb)
546{ 581{
547 u32 devid = tst->trans->hw_id; 582 u32 devid = tst->trans->hw_id;
548 struct sk_buff *skb; 583 struct sk_buff *skb;
@@ -550,7 +585,7 @@ static int iwl_test_get_dev_id(struct iwl_test *tst, struct ieee80211_hw *hw,
550 585
551 IWL_DEBUG_INFO(tst->trans, "hw version: 0x%x\n", devid); 586 IWL_DEBUG_INFO(tst->trans, "hw version: 0x%x\n", devid);
552 587
553 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); 588 skb = iwl_test_alloc_reply(tst, 20);
554 if (!skb) { 589 if (!skb) {
555 IWL_ERR(tst->trans, "Memory allocation fail\n"); 590 IWL_ERR(tst->trans, "Memory allocation fail\n");
556 return -ENOMEM; 591 return -ENOMEM;
@@ -558,7 +593,7 @@ static int iwl_test_get_dev_id(struct iwl_test *tst, struct ieee80211_hw *hw,
558 593
559 if (nla_put_u32(skb, IWL_TM_ATTR_DEVICE_ID, devid)) 594 if (nla_put_u32(skb, IWL_TM_ATTR_DEVICE_ID, devid))
560 goto nla_put_failure; 595 goto nla_put_failure;
561 status = cfg80211_testmode_reply(skb); 596 status = iwl_test_reply(tst, skb);
562 if (status < 0) 597 if (status < 0)
563 IWL_ERR(tst->trans, "Error sending msg : %d\n", status); 598 IWL_ERR(tst->trans, "Error sending msg : %d\n", status);
564 599
@@ -572,16 +607,15 @@ nla_put_failure:
572/* 607/*
573 * Handles the request to get the FW version 608 * Handles the request to get the FW version
574 */ 609 */
575static int iwl_test_get_fw_ver(struct iwl_test *tst, struct ieee80211_hw *hw, 610static int iwl_test_get_fw_ver(struct iwl_test *tst, struct nlattr **tb)
576 struct nlattr **tb)
577{ 611{
578 struct sk_buff *skb; 612 struct sk_buff *skb;
579 int status; 613 int status;
580 u32 ver = tst->ops->get_fw_ver(tst->trans->op_mode); 614 u32 ver = iwl_test_fw_ver(tst);
581 615
582 IWL_DEBUG_INFO(tst->trans, "uCode version raw: 0x%x\n", ver); 616 IWL_DEBUG_INFO(tst->trans, "uCode version raw: 0x%x\n", ver);
583 617
584 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); 618 skb = iwl_test_alloc_reply(tst, 20);
585 if (!skb) { 619 if (!skb) {
586 IWL_ERR(tst->trans, "Memory allocation fail\n"); 620 IWL_ERR(tst->trans, "Memory allocation fail\n");
587 return -ENOMEM; 621 return -ENOMEM;
@@ -590,7 +624,7 @@ static int iwl_test_get_fw_ver(struct iwl_test *tst, struct ieee80211_hw *hw,
590 if (nla_put_u32(skb, IWL_TM_ATTR_FW_VERSION, ver)) 624 if (nla_put_u32(skb, IWL_TM_ATTR_FW_VERSION, ver))
591 goto nla_put_failure; 625 goto nla_put_failure;
592 626
593 status = cfg80211_testmode_reply(skb); 627 status = iwl_test_reply(tst, skb);
594 if (status < 0) 628 if (status < 0)
595 IWL_ERR(tst->trans, "Error sending msg : %d\n", status); 629 IWL_ERR(tst->trans, "Error sending msg : %d\n", status);
596 630
@@ -630,27 +664,26 @@ EXPORT_SYMBOL_GPL(iwl_test_parse);
630 * Returns 1 for unknown commands (not handled by the test object); negative 664 * Returns 1 for unknown commands (not handled by the test object); negative
631 * value in case of error. 665 * value in case of error.
632 */ 666 */
633int iwl_test_handle_cmd(struct iwl_test *tst, struct ieee80211_hw *hw, 667int iwl_test_handle_cmd(struct iwl_test *tst, struct nlattr **tb)
634 struct nlattr **tb)
635{ 668{
636 int result; 669 int result;
637 670
638 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 671 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
639 case IWL_TM_CMD_APP2DEV_UCODE: 672 case IWL_TM_CMD_APP2DEV_UCODE:
640 IWL_DEBUG_INFO(tst->trans, "test cmd to uCode\n"); 673 IWL_DEBUG_INFO(tst->trans, "test cmd to uCode\n");
641 result = iwl_test_fw_cmd(tst, hw, tb); 674 result = iwl_test_fw_cmd(tst, tb);
642 break; 675 break;
643 676
644 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: 677 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
645 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: 678 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
646 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: 679 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
647 IWL_DEBUG_INFO(tst->trans, "test cmd to register\n"); 680 IWL_DEBUG_INFO(tst->trans, "test cmd to register\n");
648 result = iwl_test_reg(tst, hw, tb); 681 result = iwl_test_reg(tst, tb);
649 break; 682 break;
650 683
651 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: 684 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
652 IWL_DEBUG_INFO(tst->trans, "test uCode trace cmd to driver\n"); 685 IWL_DEBUG_INFO(tst->trans, "test uCode trace cmd to driver\n");
653 result = iwl_test_trace_begin(tst, hw, tb); 686 result = iwl_test_trace_begin(tst, tb);
654 break; 687 break;
655 688
656 case IWL_TM_CMD_APP2DEV_END_TRACE: 689 case IWL_TM_CMD_APP2DEV_END_TRACE:
@@ -671,12 +704,12 @@ int iwl_test_handle_cmd(struct iwl_test *tst, struct ieee80211_hw *hw,
671 704
672 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: 705 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
673 IWL_DEBUG_INFO(tst->trans, "test get FW ver cmd\n"); 706 IWL_DEBUG_INFO(tst->trans, "test get FW ver cmd\n");
674 result = iwl_test_get_fw_ver(tst, hw, tb); 707 result = iwl_test_get_fw_ver(tst, tb);
675 break; 708 break;
676 709
677 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: 710 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
678 IWL_DEBUG_INFO(tst->trans, "test Get device ID cmd\n"); 711 IWL_DEBUG_INFO(tst->trans, "test Get device ID cmd\n");
679 result = iwl_test_get_dev_id(tst, hw, tb); 712 result = iwl_test_get_dev_id(tst, tb);
680 break; 713 break;
681 714
682 default: 715 default:
@@ -779,7 +812,7 @@ EXPORT_SYMBOL_GPL(iwl_test_dump);
779/* 812/*
780 * Multicast a spontaneous messages from the device to the user space. 813 * Multicast a spontaneous messages from the device to the user space.
781 */ 814 */
782static void iwl_test_send_rx(struct iwl_test *tst, struct ieee80211_hw *hw, 815static void iwl_test_send_rx(struct iwl_test *tst,
783 struct iwl_rx_cmd_buffer *rxb) 816 struct iwl_rx_cmd_buffer *rxb)
784{ 817{
785 struct sk_buff *skb; 818 struct sk_buff *skb;
@@ -792,8 +825,7 @@ static void iwl_test_send_rx(struct iwl_test *tst, struct ieee80211_hw *hw,
792 /* the length doesn't include len_n_flags field, so add it manually */ 825 /* the length doesn't include len_n_flags field, so add it manually */
793 length += sizeof(__le32); 826 length += sizeof(__le32);
794 827
795 skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, 828 skb = iwl_test_alloc_event(tst, length + 20);
796 GFP_ATOMIC);
797 if (skb == NULL) { 829 if (skb == NULL) {
798 IWL_ERR(tst->trans, "Out of memory for message to user\n"); 830 IWL_ERR(tst->trans, "Out of memory for message to user\n");
799 return; 831 return;
@@ -804,7 +836,7 @@ static void iwl_test_send_rx(struct iwl_test *tst, struct ieee80211_hw *hw,
804 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data)) 836 nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data))
805 goto nla_put_failure; 837 goto nla_put_failure;
806 838
807 cfg80211_testmode_event(skb, GFP_ATOMIC); 839 iwl_test_event(tst, skb);
808 return; 840 return;
809 841
810nla_put_failure: 842nla_put_failure:
@@ -816,10 +848,9 @@ nla_put_failure:
816 * Called whenever a Rx frames is recevied from the device. If notifications to 848 * 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. 849 * the user space are requested, sends the frames to the user.
818 */ 850 */
819void iwl_test_rx(struct iwl_test *tst, struct ieee80211_hw *hw, 851void iwl_test_rx(struct iwl_test *tst, struct iwl_rx_cmd_buffer *rxb)
820 struct iwl_rx_cmd_buffer *rxb)
821{ 852{
822 if (tst->notify) 853 if (tst->notify)
823 iwl_test_send_rx(tst, hw, rxb); 854 iwl_test_send_rx(tst, rxb);
824} 855}
825EXPORT_SYMBOL_GPL(iwl_test_rx); 856EXPORT_SYMBOL_GPL(iwl_test_rx);
diff --git a/drivers/net/wireless/iwlwifi/iwl-test.h b/drivers/net/wireless/iwlwifi/iwl-test.h
index 994615344955..e13ffa8acc02 100644
--- a/drivers/net/wireless/iwlwifi/iwl-test.h
+++ b/drivers/net/wireless/iwlwifi/iwl-test.h
@@ -84,11 +84,49 @@ struct iwl_test_mem {
84 bool in_read; 84 bool in_read;
85}; 85};
86 86
87/*
88 * struct iwl_test_ops: callback to the op mode
89 *
90 * The structure defines the callbacks that the op_mode should handle,
91 * inorder to handle logic that is out of the scope of iwl_test. The
92 * op_mode must set all the callbacks.
93
94 * @send_cmd: handler that is used by the test object to request the
95 * op_mode to send a command to the fw.
96 *
97 * @valid_hw_addr: handler that is used by the test object to request the
98 * op_mode to check if the given address is a valid address.
99 *
100 * @get_fw_ver: handler used to get the FW version.
101 *
102 * @alloc_reply: handler used by the test object to request the op_mode
103 * to allocate an skb for sending a reply to the user, and initialize
104 * the skb. It is assumed that the test object only fills the required
105 * attributes.
106 *
107 * @reply: handler used by the test object to request the op_mode to reply
108 * to a request. The skb is an skb previously allocated by the the
109 * alloc_reply callback.
110 I
111 * @alloc_event: handler used by the test object to request the op_mode
112 * to allocate an skb for sending an event, and initialize
113 * the skb. It is assumed that the test object only fills the required
114 * attributes.
115 *
116 * @reply: handler used by the test object to request the op_mode to send
117 * an event. The skb is an skb previously allocated by the the
118 * alloc_event callback.
119 */
87struct iwl_test_ops { 120struct iwl_test_ops {
88 int (*send_cmd)(struct iwl_op_mode *op_modes, 121 int (*send_cmd)(struct iwl_op_mode *op_modes,
89 struct iwl_host_cmd *cmd); 122 struct iwl_host_cmd *cmd);
90 bool (*valid_hw_addr)(u32 addr); 123 bool (*valid_hw_addr)(u32 addr);
91 u32 (*get_fw_ver)(struct iwl_op_mode *op_mode); 124 u32 (*get_fw_ver)(struct iwl_op_mode *op_mode);
125
126 struct sk_buff *(*alloc_reply)(struct iwl_op_mode *op_mode, int len);
127 int (*reply)(struct iwl_op_mode *op_mode, struct sk_buff *skb);
128 struct sk_buff* (*alloc_event)(struct iwl_op_mode *op_mode, int len);
129 void (*event)(struct iwl_op_mode *op_mode, struct sk_buff *skb);
92}; 130};
93 131
94struct iwl_test { 132struct iwl_test {
@@ -107,14 +145,12 @@ void iwl_test_free(struct iwl_test *tst);
107int iwl_test_parse(struct iwl_test *tst, struct nlattr **tb, 145int iwl_test_parse(struct iwl_test *tst, struct nlattr **tb,
108 void *data, int len); 146 void *data, int len);
109 147
110int iwl_test_handle_cmd(struct iwl_test *tst, struct ieee80211_hw *hw, 148int iwl_test_handle_cmd(struct iwl_test *tst, struct nlattr **tb);
111 struct nlattr **tb);
112 149
113int iwl_test_dump(struct iwl_test *tst, u32 cmd, struct sk_buff *skb, 150int iwl_test_dump(struct iwl_test *tst, u32 cmd, struct sk_buff *skb,
114 struct netlink_callback *cb); 151 struct netlink_callback *cb);
115 152
116void iwl_test_rx(struct iwl_test *tst, struct ieee80211_hw *hw, 153void iwl_test_rx(struct iwl_test *tst, struct iwl_rx_cmd_buffer *rxb);
117 struct iwl_rx_cmd_buffer *rxb);
118 154
119static inline void iwl_test_enable_notifications(struct iwl_test *tst, 155static inline void iwl_test_enable_notifications(struct iwl_test *tst,
120 bool enable) 156 bool enable)