ath10k: testmode support
Subsystems (2)
v3 cover ath10k: testmode support
Hi,
new version of ath10k testmode support. Only functionality changes were in ath10k_tm_cmd_utf_start(). The user space interface didn't change from v2.
v3:
* remove false "fall through" comment in ath10k_start() (Michal)
* fix multiline comment style (Michal)
* put testmode interface definitions to testmode_uapi.h (or similar) (Johannes)
* document __set_bit(ar->fw_features) better (Michal)
* ath10k_tm_cmd_utf_start(): return ar->fw_feature value if there's an error
* free firmware in ath10k_tm_cmd_utf_start() when an error happens (Michal)
* ath10k_tm_cmd_utf_start(): move hif_power_down() to err_power_down label
v2:
* check error from ath10k_wmi_alloc_skb() (Michal)
* int err -> int ret (Michal)
* fix conflicts in core.c
* add ar->testmode.utf_monitor to check if ath10k_tm_event_wmi() should deliver WMI events or not
* print mode in ath10k_download_fw() log messages
* set ar->testmode.utf to NULL after it's released (Michal)
* release ar->testmode.utf also in ath10k_tm_cmd_utf_stop()
* rename ath10k_testmode_unregister() to ath10k_testmode_destroy()
* call ath10k_core_stop() in ath10k_testmode_destroy() (Michal)
* document wmi packet format in testmode commands (Michal)
* consume WMI packets so that mac80211 calls are not made in UTF mode (Michal)
* force to use 10x WMI interface with UTF firmware
* API change: remove ATH10K_TM_CMD_EVENT_WMI, use ATH10K_TM_CMD_WMI also for events
* API change: add major and minor version numbers to ATH10K_TM_CMD_GET_VERSION for the user space more easily to detect interface changes
* use conf_mutex in ath10k_tm_cmd_wmi()
* print "UTF firmware started" and "UTF firmware stopped"
* print "testmode %d" in ath10k_print_driver_info()
* don't call ath10k_wait_for_suspend() in UTF mode
---
Kalle Valo (2):
ath10k: make ath10k_wmi_cmd_send() public
ath10k: add testmode
drivers/net/wireless/ath/ath10k/Makefile | 1 drivers/net/wireless/ath/ath10k/core.c | 88 ++++-- drivers/net/wireless/ath/ath10k/core.h | 22 +- drivers/net/wireless/ath/ath10k/debug.c | 5 drivers/net/wireless/ath/ath10k/debug.h | 1 drivers/net/wireless/ath/ath10k/hw.h | 2 drivers/net/wireless/ath/ath10k/mac.c | 9 + drivers/net/wireless/ath/ath10k/testmode.c | 375 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/testmode.h | 46 +++ drivers/net/wireless/ath/ath10k/testmode_i.h | 70 +++++ drivers/net/wireless/ath/ath10k/wmi.c | 22 +- drivers/net/wireless/ath/ath10k/wmi.h | 4 12 files changed, 612 insertions(+), 33 deletions(-) create mode 100644 drivers/net/wireless/ath/ath10k/testmode.c create mode 100644 drivers/net/wireless/ath/ath10k/testmode.h create mode 100644 drivers/net/wireless/ath/ath10k/testmode_i.h
PATCH v3 1/2 ath10k: make ath10k_wmi_cmd_send() public
We need this function to send wmi packets from testmode.c.
--- drivers/net/wireless/ath/ath10k/wmi.c | 5 ++--- drivers/net/wireless/ath/ath10k/wmi.h | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/wmi.c +2 -3
@@ -624,7 +624,7 @@ int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)return ret; } -static struct sk_buff *ath10k_wmi_alloc_skb (struct ath10k *ar,u32 len) +struct sk_buff *ath10k_wmi_alloc_skb (struct ath10k *ar,u32 len) {struct sk_buff *skb;u32 round_len =roundup (len,4 );
@@ -725,8 +725,7 @@ static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)wake_up (&ar->wmi.tx_credits_wq); } -static int ath10k_wmi_cmd_send (struct ath10k *ar,struct sk_buff *skb, -u32 cmd_id) +int ath10k_wmi_cmd_send (struct ath10k *ar,struct sk_buff *skb,u32 cmd_id) {int ret = -EOPNOTSUPP ;
drivers/net/wireless/ath/ath10k/wmi.h +4 -0
@@ -4739,6 +4739,10 @@ int ath10k_wmi_wait_for_service_ready(struct ath10k *ar);int ath10k_wmi_wait_for_unified_ready (struct ath10k *ar);int ath10k_wmi_connect (struct ath10k *ar); + +struct sk_buff *ath10k_wmi_alloc_skb (struct ath10k *ar,u32 len); +int ath10k_wmi_cmd_send (struct ath10k *ar,struct sk_buff *skb,u32 cmd_id); +int ath10k_wmi_pdev_set_channel (struct ath10k *ar,const struct wmi_channel_arg *);int ath10k_wmi_pdev_suspend_target (struct ath10k *ar,u32 suspend_opt);
PATCH v3 2/2 ath10k: add testmode
In reply to Kalle ValoAdd testmode interface for starting and using UTF firmware which is used to run factory tests. This is implemented by adding new state ATH10K_STATE_UTF and user space can enable this state with ATH10K_TM_CMD_UTF_START command. To go back to normal mode user space can send ATH10K_TM_CMD_UTF_STOP.
--- drivers/net/wireless/ath/ath10k/Makefile | 1 drivers/net/wireless/ath/ath10k/core.c | 88 ++++-- drivers/net/wireless/ath/ath10k/core.h | 22 +- drivers/net/wireless/ath/ath10k/debug.c | 5 drivers/net/wireless/ath/ath10k/debug.h | 1 drivers/net/wireless/ath/ath10k/hw.h | 2 drivers/net/wireless/ath/ath10k/mac.c | 9 + drivers/net/wireless/ath/ath10k/testmode.c | 375 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/testmode.h | 46 +++ drivers/net/wireless/ath/ath10k/testmode_i.h | 70 +++++ drivers/net/wireless/ath/ath10k/wmi.c | 17 + 11 files changed, 606 insertions(+), 30 deletions(-) create mode 100644 drivers/net/wireless/ath/ath10k/testmode.c create mode 100644 drivers/net/wireless/ath/ath10k/testmode.h create mode 100644 drivers/net/wireless/ath/ath10k/testmode_i.h
drivers/net/wireless/ath/ath10k/Makefile +1 -0
@@ -11,6 +11,7 @@ ath10k_core-y += mac.o \ bmi.o ath10k_core-$(CONFIG_ATH10K_DEBUGFS) += spectral.o +ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o obj-$(CONFIG_ATH10K_PCI) += ath10k_pci.o
drivers/net/wireless/ath/ath10k/core.c +62 -26
173 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/core.h +21 -1
@@ -330,6 +330,17 @@ enum ath10k_state {* prevents completion timeouts and makes the driver more responsive to * userspace commands. This is also prevents recursive recovery. */ ATH10K_STATE_WEDGED , + +/* factory tests */ + ATH10K_STATE_UTF, +}; + +enum ath10k_firmware_mode { +/* the default mode, standard 802.11 functionality */ +ATH10K_FIRMWARE_MODE_NORMAL , + +/* factory tests etc */ +ATH10K_FIRMWARE_MODE_UTF , }; enum ath10k_fw_features {
@@ -543,6 +554,15 @@ struct ath10k {struct ath10k_spec_scan config; } spectral; +struct { +/* protected by conf_mutex */ +const struct firmware *utf; + DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT); + +/* protected by data_lock */ +bool utf_monitor; + } testmode; +/* must be last */ u8 drv_priv[0 ]__aligned(sizeof(void *)) ; };
@@ -551,7 +571,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, const struct ath10k_hif_ops *hif_ops);void ath10k_core_destroy (struct ath10k *ar); -int ath10k_core_start (struct ath10k *ar); +int ath10k_core_start (struct ath10k *ar,enum ath10k_firmware_mode mode);int ath10k_wait_for_suspend (struct ath10k *ar,u32 suspend_opt);void ath10k_core_stop (struct ath10k *ar);int ath10k_core_register (struct ath10k *ar,u32 chip_id);
drivers/net/wireless/ath/ath10k/debug.c +3 -2
@@ -134,11 +134,12 @@ void ath10k_print_driver_info(struct ath10k *ar) ar->fw_api, ar->htt.target_version_major, ar->htt.target_version_minor); -ath10k_info (ar,"debug %d debugfs %d tracing %d dfs %d\n" , +ath10k_info (ar,"debug %d debugfs %d tracing %d dfs %d testmode %d\n" ,config_enabled (CONFIG_ATH10K_DEBUG ),config_enabled (CONFIG_ATH10K_DEBUGFS ),config_enabled (CONFIG_ATH10K_TRACING ), -config_enabled (CONFIG_ATH10K_DFS_CERTIFIED )); +config_enabled (CONFIG_ATH10K_DFS_CERTIFIED ), +config_enabled (CONFIG_NL80211_TESTMODE )); }EXPORT_SYMBOL (ath10k_print_driver_info);
drivers/net/wireless/ath/ath10k/debug.h +1 -0
@@ -34,6 +34,7 @@ enum ath10k_debug_mask {ATH10K_DBG_DATA =0x00000200 ,ATH10K_DBG_BMI =0x00000400 ,ATH10K_DBG_REGULATORY =0x00000800 , +ATH10K_DBG_TESTMODE =0x00001000 , ATH10K_DBG_ANY = 0xffffffff, };
drivers/net/wireless/ath/ath10k/hw.h +2 -0
@@ -36,6 +36,8 @@#define ATH10K_FW_API2_FILE "firmware-2.bin"#define ATH10K_FW_API3_FILE "firmware-3.bin" +#define ATH10K_FW_UTF_FILE "utf.bin" +/* includes also the null byte */ #define ATH10K_FIRMWARE_MAGIC "QCA-ATH10K"
drivers/net/wireless/ath/ath10k/mac.c +8 -1
@@ -26,6 +26,7 @@#include "wmi.h" #include "htt.h" #include "txrx.h" +#include "testmode.h" /**********/ /* Crypto */
@@ -2480,6 +2481,9 @@ static int ath10k_start(struct ieee80211_hw *hw)WARN_ON (1 ); ret = -EINVAL ; goto err; +case ATH10K_STATE_UTF : + ret = -EBUSY ; + goto err; } ret =ath10k_hif_power_up (ar);
@@ -2488,7 +2492,7 @@ static int ath10k_start(struct ieee80211_hw *hw) goto err_off; } - ret =ath10k_core_start (ar); + ret =ath10k_core_start (ar,ATH10K_FIRMWARE_MODE_NORMAL );if (ret) {ath10k_err (ar,"Could not init core: %d\n" , ret); goto err_power_down;
@@ -4456,6 +4460,9 @@ static const struct ieee80211_ops ath10k_ops = { .sta_rc_update = ath10k_sta_rc_update, .get_tsf = ath10k_get_tsf, .ampdu_action = ath10k_ampdu_action, + + CFG80211_TESTMODE_CMD(ath10k_tm_cmd) +#ifdef CONFIG_PM .suspend = ath10k_suspend, .resume = ath10k_resume,
drivers/net/wireless/ath/ath10k/testmode.c new file +375 -0
375 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/testmode.h new file +46 -0
46 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/testmode_i.h new file +70 -0
70 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/wmi.c +17 -0
@@ -23,6 +23,7 @@#include "debug.h" #include "wmi.h" #include "mac.h" +#include "testmode.h" /* MAIN WMI cmd track */ static struct wmi_cmd_map wmi_cmd_map = {
@@ -2479,6 +2480,7 @@ static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) {struct wmi_cmd_hdr *cmd_hdr;enum wmi_10x_event_id id; +bool consumed; cmd_hdr = (struct wmi_cmd_hdr *)skb->data; id =MS (__le32_to_cpu (cmd_hdr->cmd_id),WMI_CMD_HDR_CMD_ID );
@@ -2488,6 +2490,17 @@ static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb)trace_ath10k_wmi_event (ar, id, skb->data, skb->len); + consumed =ath10k_tm_event_wmi (ar, id, skb); + +/* Ready event must be handled normally also in UTF mode so that we +* know the UTF firmware has booted, others we are just bypass WMI +* events to testmode. */ +if (consumed && id !=WMI_10X_READY_EVENTID ) { +ath10k_dbg (ar,ATH10K_DBG_WMI , +"wmi testmode consumed 0x%x\n" , id); + goto out; + } +switch (id) {case WMI_10X_MGMT_RX_EVENTID :ath10k_wmi_event_mgmt_rx (ar, skb);
@@ -2574,11 +2587,15 @@ static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb)case WMI_10X_READY_EVENTID :ath10k_wmi_ready_event_rx (ar, skb);break ; +case WMI_10X_PDEV_UTF_EVENTID : +/* ignore utf events */ +break ;default :ath10k_warn (ar,"Unknown eventid: %d\n" , id);break ; } +out:dev_kfree_skb (skb); }
Re: [PATCH v3 2/2] ath10k: add testmode
Quoted 7 lines · Kalle Valo
Add testmode interface for starting and using UTF firmware which is used to run factory tests. This is implemented by adding new state
ATH10K_STATE_UTFand user space can enable this state withATH10K_TM_CMD_UTF_STARTcommand. To go back to normal mode user space can sendATH10K_TM_CMD_UTF_STOP.Signed-off-by Kalle Valo <[email protected]>---
[...]
Quoted 12 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +12
-0+bool ath10k_tm_event_wmi (struct ath10k *ar,u32 cmd_id,struct sk_buff *skb) +{ +struct sk_buff *nl_skb; +bool consumed; +int ret; + +ath10k_dbg (ar,ATH10K_DBG_TESTMODE , +"testmode event wmi cmd_id %d skb %p skb->len %d\n" , + cmd_id, skb, skb->len); + +ath10k_dbg_dump (ar,ATH10K_DBG_TESTMODE ,NULL ,"" , skb->data, skb->len); +
drivers/net/wireless/ath/ath10k/testmode.c line 62
Quoted 10 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +10
-0+spin_lock_bh (&ar->data_lock); + +if (!ar->testmode.utf_monitor) { + consumed = false; + goto out; + } + +/* Only testmode.c should be handling events from utf firmware, +* otherwise all sort of problems will arise as mac80211 operations +* are not initialised. */
Comment style.
Quoted 13 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +13
-0+static int ath10k_tm_cmd_utf_start (struct ath10k *ar,struct nlattr *tb[]) +{ +char filename[100 ]; +int ret; + +ath10k_dbg (ar,ATH10K_DBG_TESTMODE ,"testmode cmd utf start\n" ); + +mutex_lock (&ar->conf_mutex); + +if (ar->state ==ATH10K_STATE_UTF ) { + ret = -EALREADY ; + goto err; + }
drivers/net/wireless/ath/ath10k/testmode.c line 163
Quoted 10 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +10
-0+ +/* start utf only when the driver is not in use */ +if (ar->state !=ATH10K_STATE_OFF ) { + ret = -EBUSY ; + goto err; + } + +if (ar->testmode.utf !=NULL ) +/* utf image is already downloaded */ + goto power_up;
I believe this shouldn't happen with the current code. We should probably treat it with a if (WARN_ON(utf != NULL)) goto err;
drivers/net/wireless/ath/ath10k/testmode.c line 371
Quoted 13 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +13
-0+void ath10k_testmode_destroy (struct ath10k *ar) +{ +mutex_lock (&ar->conf_mutex); + +release_firmware (ar->testmode.utf); + ar->testmode.utf =NULL ; + +if (ar->state !=ATH10K_STATE_UTF ) { +/* utf firmware is not running, nothing to do */ + goto out; + } + +ath10k_core_stop (ar);
Hmm, you don't call power_down here. This isn't a problem from a practical point of view after my recent changes but hey.
How about we split out guts from ath10k_tm_cmd_utf_stop() to __ath10k_tm_cmd_utf_stop() (which assumes conf_mutex is already held) and call it here like this:
mutex_lock(conf_mutex);
if (ar->state==UTF)
__ath10k_tm_cmd_utf_stop(ar);
mutex_unlock(conf_mutex);
drivers/net/wireless/ath/ath10k/wmi.c static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) · line 2497
Quoted 9 lines
drivers/net/wireless/ath/ath10k/wmi.c +5
-0@@ -2488,6 +2490,17 @@ static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb)trace_ath10k_wmi_event (ar, id, skb->data, skb->len); + consumed =ath10k_tm_event_wmi (ar, id, skb); + +/* Ready event must be handled normally also in UTF mode so that we +* know the UTF firmware has booted, others we are just bypass WMI +* events to testmode. */
Comment style.
Michał
Re: [PATCH v3 2/2] ath10k: add testmode
Quoted 25 lines · Michal Kazior
Quoted 7 lines · Kalle Valo
Add testmode interface for starting and using UTF firmware which is used to run factory tests. This is implemented by adding new state
ATH10K_STATE_UTFand user space can enable this state withATH10K_TM_CMD_UTF_STARTcommand. To go back to normal mode user space can sendATH10K_TM_CMD_UTF_STOP.Signed-off-by Kalle Valo <[email protected]>---
[...]
Quoted 16 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +16
-0+bool ath10k_tm_event_wmi (struct ath10k *ar,u32 cmd_id,struct sk_buff *skb) +{ +struct sk_buff *nl_skb; +bool consumed; +int ret; + +ath10k_dbg (ar,ATH10K_DBG_TESTMODE , +"testmode event wmi cmd_id %d skb %p skb->len %d\n" , + cmd_id, skb, skb->len); + +ath10k_dbg_dump (ar,ATH10K_DBG_TESTMODE ,NULL ,"" , skb->data, skb->len); + +spin_lock_bh (&ar->data_lock); + +if (!ar->testmode.utf_monitor) { + consumed = false;
Quoted 8 lines
drivers/net/wireless/ath/ath10k/testmode.c line 62
Quoted 6 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +6
-0+ goto out; + } + +/* Only testmode.c should be handling events from utf firmware, +* otherwise all sort of problems will arise as mac80211 operations +* are not initialised. */ Comment style.
Argh, will I ever learn :) Fixed now.
Quoted 18 lines
Quoted 18 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +18
-0+static int ath10k_tm_cmd_utf_start (struct ath10k *ar,struct nlattr *tb[]) +{ +char filename[100 ]; +int ret; + +ath10k_dbg (ar,ATH10K_DBG_TESTMODE ,"testmode cmd utf start\n" ); + +mutex_lock (&ar->conf_mutex); + +if (ar->state ==ATH10K_STATE_UTF ) { + ret = -EALREADY ; + goto err; + } + +/* start utf only when the driver is not in use */ +if (ar->state !=ATH10K_STATE_OFF ) { + ret = -EBUSY ; + goto err;
Quoted 8 lines
drivers/net/wireless/ath/ath10k/testmode.c line 163
Quoted 5 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +5
-0+ } + +if (ar->testmode.utf !=NULL ) +/* utf image is already downloaded */ + goto power_up;I believe this shouldn't happen with the current code. We should probably treat it with a if (
WARN_ON(utf != NULL)) goto err;
Yeah, I'll add that.
Quoted 17 lines
drivers/net/wireless/ath/ath10k/testmode.c line 371
Quoted 13 lines
drivers/net/wireless/ath/ath10k/testmode.c new file +13
-0+void ath10k_testmode_destroy (struct ath10k *ar) +{ +mutex_lock (&ar->conf_mutex); + +release_firmware (ar->testmode.utf); + ar->testmode.utf =NULL ; + +if (ar->state !=ATH10K_STATE_UTF ) { +/* utf firmware is not running, nothing to do */ + goto out; + } + +ath10k_core_stop (ar);Hmm, you don't call
power_downhere. This isn't a problem from a practical point of view after my recent changes but hey.
Quoted 8 lines
How about we split out guts from
ath10k_tm_cmd_utf_stop()to__ath10k_tm_cmd_utf_stop()(which assumesconf_mutexis already held) and call it here like this:
mutex_lock(conf_mutex);
if (ar->state==UTF)
__ath10k_tm_cmd_utf_stop(ar);
mutex_unlock(conf_mutex);
Good idea, I'll do that.
Quoted 11 lines
drivers/net/wireless/ath/ath10k/wmi.c static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb) · line 2497
Quoted 9 lines
drivers/net/wireless/ath/ath10k/wmi.c +5
-0@@ -2488,6 +2490,17 @@ static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb)trace_ath10k_wmi_event (ar, id, skb->data, skb->len); + consumed =ath10k_tm_event_wmi (ar, id, skb); + +/* Ready event must be handled normally also in UTF mode so that we +* know the UTF firmware has booted, others we are just bypass WMI +* events to testmode. */ Comment style.
Fixed.
Thanks for the review! I'll send v4 soon.
Signature · 1 line
Kalle Valo