Skip to content

Commit

Permalink
iwlwifi: refactor testmode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ilan Peer authored and Johannes Berg committed Jun 11, 2012
1 parent b1abeda commit 3a6490c
Show file tree
Hide file tree
Showing 9 changed files with 1,027 additions and 762 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/iwlwifi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ iwlwifi-objs += pcie/drv.o pcie/rx.o pcie/tx.o pcie/trans.o
iwlwifi-objs += pcie/1000.o pcie/2000.o pcie/5000.o pcie/6000.o

iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o
iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TESTMODE) += iwl-test.o

ccflags-y += -D__CHECK_ENDIAN__ -I$(src)
17 changes: 11 additions & 6 deletions drivers/net/wireless/iwlwifi/dvm/agn.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,35 +395,40 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
}

extern int iwl_alive_start(struct iwl_priv *priv);
/* svtool */

/* testmode support */
#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE

extern int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data,
int len);
extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw,
struct sk_buff *skb,
struct netlink_callback *cb,
void *data, int len);
extern void iwl_testmode_init(struct iwl_priv *priv);
extern void iwl_testmode_cleanup(struct iwl_priv *priv);
extern void iwl_testmode_free(struct iwl_priv *priv);

#else

static inline
int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
{
return -ENOSYS;
}

static inline
int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
struct netlink_callback *cb,
void *data, int len)
{
return -ENOSYS;
}
static inline
void iwl_testmode_init(struct iwl_priv *priv)

static inline void iwl_testmode_init(struct iwl_priv *priv)
{
}
static inline
void iwl_testmode_cleanup(struct iwl_priv *priv)

static inline void iwl_testmode_free(struct iwl_priv *priv)
{
}
#endif
Expand Down
26 changes: 4 additions & 22 deletions drivers/net/wireless/iwlwifi/dvm/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include "rs.h"
#include "tt.h"

#include "iwl-test.h"

/* CT-KILL constants */
#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
#define CT_KILL_THRESHOLD 114 /* in Celsius */
Expand Down Expand Up @@ -596,24 +598,6 @@ struct iwl_lib_ops {
void (*temperature)(struct iwl_priv *priv);
};

#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
struct iwl_testmode_trace {
u32 buff_size;
u32 total_size;
u32 num_chunks;
u8 *cpu_addr;
u8 *trace_addr;
dma_addr_t dma_addr;
bool trace_enabled;
};
struct iwl_testmode_mem {
u32 buff_size;
u32 num_chunks;
u8 *buff_addr;
bool read_in_progress;
};
#endif

struct iwl_wipan_noa_data {
struct rcu_head rcu_head;
u32 length;
Expand Down Expand Up @@ -670,8 +654,6 @@ struct iwl_priv {
enum ieee80211_band band;
u8 valid_contexts;

void (*pre_rx_handler)(struct iwl_priv *priv,
struct iwl_rx_cmd_buffer *rxb);
int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
struct iwl_rx_cmd_buffer *rxb,
struct iwl_device_cmd *cmd);
Expand Down Expand Up @@ -895,9 +877,9 @@ struct iwl_priv {
struct led_classdev led;
unsigned long blink_on, blink_off;
bool led_registered;

#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
struct iwl_testmode_trace testmode_trace;
struct iwl_testmode_mem testmode_mem;
struct iwl_test tst;
u32 tm_fixed_rate;
#endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/iwlwifi/dvm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)

iwl_dbgfs_unregister(priv);

iwl_testmode_cleanup(priv);
iwl_testmode_free(priv);
iwlagn_mac_unregister(priv);

iwl_tt_exit(priv);
Expand Down
24 changes: 11 additions & 13 deletions drivers/net/wireless/iwlwifi/dvm/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,6 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
{
struct iwl_rx_packet *pkt = rxb_addr(rxb);
struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
void (*pre_rx_handler)(struct iwl_priv *,
struct iwl_rx_cmd_buffer *);
int err = 0;

/*
Expand All @@ -1135,19 +1133,19 @@ int iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct iwl_rx_cmd_buffer *rxb,
*/
iwl_notification_wait_notify(&priv->notif_wait, pkt);

/* RX data may be forwarded to userspace (using pre_rx_handler) in one
* of two cases: the first, that the user owns the uCode through
* testmode - in such case the pre_rx_handler is set and no further
* processing takes place. The other case is when the user want to
* monitor the rx w/o affecting the regular flow - the pre_rx_handler
* will be set but the ownership flag != IWL_OWNERSHIP_TM and the flow
#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
/*
* RX data may be forwarded to userspace in one
* of two cases: the user owns the fw through testmode or when
* the user requested to monitor the rx w/o affecting the regular flow.
* In these cases the iwl_test object will handle forwarding the rx
* data to user space.
* Note that if the ownership flag != IWL_OWNERSHIP_TM the flow
* continues.
* We need to use ACCESS_ONCE to prevent a case where the handler
* changes between the check and the call.
*/
pre_rx_handler = ACCESS_ONCE(priv->pre_rx_handler);
if (pre_rx_handler)
pre_rx_handler(priv, rxb);
iwl_test_rx(&priv->tst, priv->hw, rxb);
#endif

if (priv->ucode_owner != IWL_OWNERSHIP_TM) {
/* Based on type of command response or notification,
* handle those that need handling via function in
Expand Down
Loading

0 comments on commit 3a6490c

Please sign in to comment.