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

Commit 4613e72d authored by Cindy H. Kao's avatar Cindy H. Kao Committed by Wey-Yi Guy
Browse files

iwlwifi: support the svtool messages interactions through nl80211 test mode



This patch adds the feature to support the test mode operation through
the generic netlink channel NL80211_CMD_TESTMODE between intel
wireless device iwlwifi and the user space application svtool.

The main purpose is to create a transportation layer between the iwlwifi
device and the user space application so that the interaction between the
user space application svtool and the iwlwifi device in the kernel space is
in a way of generic netlink messaging.

The detail specific functions are:

1. The function iwl_testmode_cmd() is added to digest the svtool test command
   from the user space application. The svtool test commands are categorized  to
   three types : commands to be processed by the device ucode, commands to access
   the registers, and commands to be processed at the driver level(such as reload
   the ucode). iwl_testmode_cmd() dispatches the commands the corresponding handlers
   and reply to user space regarding the command execution status. Extra data is
   returned to the user space application if there's any.

2. The function iwl_testmode_ucode_rx_pkt() is added to multicast all the spontaneous
   messages from the iwlwifi device to the user space. Regardless the message types,
   whenever there is a valid spontaneous message received by the iwlwifi ISR,
   iwl_testmode_ucode_rx_pkt() is invoked to multicast the message content to user
   space. The message content is not attacked and the message parsing is left to
   the user space application.

Implementation guidelines:

1. The generic netlink messaging for iwliwif test mode is through  NL80211_CMD_TESTMODE
   channel, therefore, the codes need to follow the regulations set by cfg80211.ko
   to get the actual device instance ieee80211_ops via cfg80211.ko, so that the iwlwifi
   device is indicated with ieee80211_ops and can be actually accessed.

   Therefore, a callback iwl_testmode_cmd() is added to the structure
   iwlagn_hw_ops in iwl-agn.c.

2. It intends to utilize those low level device access APIs from iwlwifi device driver
   (ie. iwlagn.ko) rather than creating it's own set of device access functions.
   For example, iwl_send_cmd(), iwl_read32(), iwl_write8(), and iwl_write32() are reused.

3. The main functions are maintained in new files instead of spreading all over the
   existing iwlwifi driver files.

   The new files added are :

   drivers/net/wireless/iwlwifi/iwl-sv-open.c
        - to handle the user space test mode application command
          and reply the respective command status to the user space application.
        - to multicast the spontaneous messages from device to user space.

   drivers/net/wireless/iwlwifi/iwl-testmode.h
        - the commonly referenced definitions for the TLVs used in
          the generic netlink messages

Signed-off-by: default avatarCindy H. Kao <cindy.h.kao@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
parent d6d023a1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -102,6 +102,16 @@ config IWLWIFI_DEVICE_TRACING
	  occur.
endmenu

config IWLWIFI_DEVICE_SVTOOL
	bool "iwlwifi device svtool support"
	depends on IWLAGN
	select NL80211_TESTMODE
	help
	  This option enables the svtool support for iwlwifi device through
	  NL80211_TESTMODE. svtool is a software validation tool that runs in
	  the user space and interacts with the device in the kernel space
	  through the generic netlink message via NL80211_TESTMODE channel.

config IWL_P2P
	bool "iwlwifi experimental P2P support"
	depends on IWLAGN
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ iwlagn-objs += iwl-2000.o

iwlagn-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o
iwlagn-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o
iwlagn-$(CONFIG_IWLWIFI_DEVICE_SVTOOL) += iwl-sv-open.o

CFLAGS_iwl-devtrace.o := -I$(src)

+1 −1
Original line number Diff line number Diff line
@@ -269,7 +269,7 @@ void iwlagn_rx_calib_result(struct iwl_priv *priv,
	iwl_calib_set(&priv->calib_results[index], pkt->u.raw, len);
}

static int iwlagn_init_alive_start(struct iwl_priv *priv)
int iwlagn_init_alive_start(struct iwl_priv *priv)
{
	int ret;

+5 −1
Original line number Diff line number Diff line
@@ -776,6 +776,8 @@ static void iwl_rx_handle(struct iwl_priv *priv)

			wake_up_all(&priv->_agn.notif_waitq);
		}
		if (priv->pre_rx_handler)
			priv->pre_rx_handler(priv, rxb);

		/* Based on type of command response or notification,
		 *   handle those that need handling via function in
@@ -2211,7 +2213,7 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg)
 *                   from protocol/runtime uCode (initialization uCode's
 *                   Alive gets handled by iwl_init_alive_start()).
 */
static int iwl_alive_start(struct iwl_priv *priv)
int iwl_alive_start(struct iwl_priv *priv)
{
	int ret = 0;
	struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
@@ -3507,6 +3509,7 @@ struct ieee80211_ops iwlagn_hw_ops = {
	.cancel_remain_on_channel = iwl_mac_cancel_remain_on_channel,
	.offchannel_tx = iwl_mac_offchannel_tx,
	.offchannel_tx_cancel_wait = iwl_mac_offchannel_tx_cancel_wait,
	CFG80211_TESTMODE_CMD(iwl_testmode_cmd)
};

static u32 iwl_hw_detect(struct iwl_priv *priv)
@@ -3816,6 +3819,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

	iwl_setup_deferred_work(priv);
	iwl_setup_rx_handlers(priv);
	iwl_testmode_init(priv);

	/*********************************************
	 * 8. Enable interrupts and read RFKILL state
+17 −0
Original line number Diff line number Diff line
@@ -344,5 +344,22 @@ iwlagn_wait_notification(struct iwl_priv *priv,
void __releases(wait_entry)
iwlagn_remove_notification(struct iwl_priv *priv,
			   struct iwl_notification_wait *wait_entry);
extern int iwlagn_init_alive_start(struct iwl_priv *priv);
extern int iwl_alive_start(struct iwl_priv *priv);
/* svtool */
#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
extern int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len);
extern void iwl_testmode_init(struct iwl_priv *priv);
#else
static inline
int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
{
	return -ENOSYS;
}
static inline
void iwl_testmode_init(struct iwl_priv *priv)
{
}
#endif

#endif /* __iwl_agn_h__ */
Loading