Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a6490c0 authored by Ilan Peer's avatar Ilan Peer Committed by Johannes Berg
Browse files

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: default avatarAmit Beka <amit.beka@intel.com>
Reviewed-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarIlan Peer <ilan.peer@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent b1abedad
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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)
+11 −6
Original line number Diff line number Diff line
@@ -395,8 +395,10 @@ 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,
@@ -404,13 +406,16 @@ extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw,
				    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,
@@ -418,12 +423,12 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
{
	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
+4 −22
Original line number Diff line number Diff line
@@ -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 */
@@ -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;
@@ -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);
@@ -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

+1 −1
Original line number Diff line number Diff line
@@ -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);
+11 −13
Original line number Diff line number Diff line
@@ -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;

	/*
@@ -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
Loading