ath10k: print more driver info when firmware crashes
[cascardo/linux.git] / drivers / net / wireless / ath / ath10k / debug.c
index 6debd28..442fe93 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <linux/module.h>
 #include <linux/debugfs.h>
+#include <linux/version.h>
+#include <linux/vermagic.h>
+#include <linux/vmalloc.h>
 
 #include "core.h"
 #include "debug.h"
 /* ms */
 #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000
 
+#define ATH10K_FW_CRASH_DUMP_VERSION 1
+
+/**
+ * enum ath10k_fw_crash_dump_type - types of data in the dump file
+ * @ATH10K_FW_CRASH_DUMP_REGDUMP: Register crash dump in binary format
+ */
+enum ath10k_fw_crash_dump_type {
+       ATH10K_FW_CRASH_DUMP_REGISTERS = 0,
+
+       ATH10K_FW_CRASH_DUMP_MAX,
+};
+
+struct ath10k_tlv_dump_data {
+       /* see ath10k_fw_crash_dump_type above */
+       __le32 type;
+
+       /* in bytes */
+       __le32 tlv_len;
+
+       /* pad to 32-bit boundaries as needed */
+       u8 tlv_data[];
+} __packed;
+
+struct ath10k_dump_file_data {
+       /* dump file information */
+
+       /* "ATH10K-FW-DUMP" */
+       char df_magic[16];
+
+       __le32 len;
+
+       /* file dump version */
+       __le32 version;
+
+       /* some info we can get from ath10k struct that might help */
+
+       u8 uuid[16];
+
+       __le32 chip_id;
+
+       /* 0 for now, in place for later hardware */
+       __le32 bus_type;
+
+       __le32 target_version;
+       __le32 fw_version_major;
+       __le32 fw_version_minor;
+       __le32 fw_version_release;
+       __le32 fw_version_build;
+       __le32 phy_capability;
+       __le32 hw_min_tx_power;
+       __le32 hw_max_tx_power;
+       __le32 ht_cap_info;
+       __le32 vht_cap_info;
+       __le32 num_rf_chains;
+
+       /* firmware version string */
+       char fw_ver[ETHTOOL_FWVERS_LEN];
+
+       /* Kernel related information */
+
+       /* time-of-day stamp */
+       __le64 tv_sec;
+
+       /* time-of-day stamp, nano-seconds */
+       __le64 tv_nsec;
+
+       /* LINUX_VERSION_CODE */
+       __le32 kernel_ver_code;
+
+       /* VERMAGIC_STRING */
+       char kernel_ver[64];
+
+       /* room for growth w/out changing binary format */
+       u8 unused[128];
+
+       /* struct ath10k_tlv_dump_data + more */
+       u8 data[0];
+} __packed;
+
 static int ath10k_printk(const char *level, const char *fmt, ...)
 {
        struct va_format vaf;
@@ -60,6 +142,24 @@ int ath10k_info(const char *fmt, ...)
 }
 EXPORT_SYMBOL(ath10k_info);
 
+void ath10k_print_driver_info(struct ath10k *ar)
+{
+       ath10k_info("%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d\n",
+                   ar->hw_params.name,
+                   ar->target_version,
+                   ar->chip_id,
+                   ar->hw->wiphy->fw_version,
+                   ar->fw_api,
+                   ar->htt.target_version_major,
+                   ar->htt.target_version_minor);
+       ath10k_info("debug %d debugfs %d tracing %d dfs %d\n",
+                   config_enabled(CONFIG_ATH10K_DEBUG),
+                   config_enabled(CONFIG_ATH10K_DEBUGFS),
+                   config_enabled(CONFIG_ATH10K_TRACING),
+                   config_enabled(CONFIG_ATH10K_DFS_CERTIFIED));
+}
+EXPORT_SYMBOL(ath10k_print_driver_info);
+
 int ath10k_err(const char *fmt, ...)
 {
        struct va_format vaf = {
@@ -115,9 +215,10 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
 {
        struct ath10k *ar = file->private_data;
        char *buf;
-       unsigned int len = 0, buf_len = 1500;
-       const char *status;
+       unsigned int len = 0, buf_len = 4096;
+       const char *name;
        ssize_t ret_cnt;
+       bool enabled;
        int i;
 
        buf = kzalloc(buf_len, GFP_KERNEL);
@@ -129,15 +230,22 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
        if (len > buf_len)
                len = buf_len;
 
-       for (i = 0; i < WMI_SERVICE_LAST; i++) {
-               if (WMI_SERVICE_IS_ENABLED(ar->debug.wmi_service_bitmap, i))
-                       status = "enabled";
-               else
-                       status = "disabled";
+       for (i = 0; i < WMI_MAX_SERVICE; i++) {
+               enabled = test_bit(i, ar->debug.wmi_service_bitmap);
+               name = wmi_service_name(i);
+
+               if (!name) {
+                       if (enabled)
+                               len += scnprintf(buf + len, buf_len - len,
+                                                "%-40s %s (bit %d)\n",
+                                                "unknown", "enabled", i);
+
+                       continue;
+               }
 
                len += scnprintf(buf + len, buf_len - len,
-                                "0x%02x - %20s - %s\n",
-                                i, wmi_service_name(i), status);
+                                "%-40s %s\n",
+                                name, enabled ? "enabled" : "-");
        }
 
        ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
@@ -161,7 +269,7 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
        u8 *tmp = ev->data;
        struct ath10k_target_stats *stats;
        int num_pdev_stats, num_vdev_stats, num_peer_stats;
-       struct wmi_pdev_stats *ps;
+       struct wmi_pdev_stats_10x *ps;
        int i;
 
        spin_lock_bh(&ar->data_lock);
@@ -173,7 +281,7 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
        num_peer_stats = __le32_to_cpu(ev->num_peer_stats); /* 0 or max peers */
 
        if (num_pdev_stats) {
-               ps = (struct wmi_pdev_stats *)tmp;
+               ps = (struct wmi_pdev_stats_10x *)tmp;
 
                stats->ch_noise_floor = __le32_to_cpu(ps->chan_nf);
                stats->tx_frame_count = __le32_to_cpu(ps->tx_frame_count);
@@ -228,7 +336,18 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
                stats->phy_err_drop = __le32_to_cpu(ps->wal.rx.phy_err_drop);
                stats->mpdu_errs = __le32_to_cpu(ps->wal.rx.mpdu_errs);
 
-               tmp += sizeof(struct wmi_pdev_stats);
+               if (test_bit(ATH10K_FW_FEATURE_WMI_10X,
+                            ar->fw_features)) {
+                       stats->ack_rx_bad = __le32_to_cpu(ps->ack_rx_bad);
+                       stats->rts_bad = __le32_to_cpu(ps->rts_bad);
+                       stats->rts_good = __le32_to_cpu(ps->rts_good);
+                       stats->fcs_bad = __le32_to_cpu(ps->fcs_bad);
+                       stats->no_beacons = __le32_to_cpu(ps->no_beacons);
+                       stats->mib_int_count = __le32_to_cpu(ps->mib_int_count);
+                       tmp += sizeof(struct wmi_pdev_stats_10x);
+               } else {
+                       tmp += sizeof(struct wmi_pdev_stats_old);
+               }
        }
 
        /* 0 or max vdevs */
@@ -243,22 +362,29 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
        }
 
        if (num_peer_stats) {
-               struct wmi_peer_stats *peer_stats;
+               struct wmi_peer_stats_10x *peer_stats;
                struct ath10k_peer_stat *s;
 
                stats->peers = num_peer_stats;
 
                for (i = 0; i < num_peer_stats; i++) {
-                       peer_stats = (struct wmi_peer_stats *)tmp;
+                       peer_stats = (struct wmi_peer_stats_10x *)tmp;
                        s = &stats->peer_stat[i];
 
-                       WMI_MAC_ADDR_TO_CHAR_ARRAY(&peer_stats->peer_macaddr,
-                                                  s->peer_macaddr);
+                       memcpy(s->peer_macaddr, &peer_stats->peer_macaddr.addr,
+                              ETH_ALEN);
                        s->peer_rssi = __le32_to_cpu(peer_stats->peer_rssi);
                        s->peer_tx_rate =
                                __le32_to_cpu(peer_stats->peer_tx_rate);
-
-                       tmp += sizeof(struct wmi_peer_stats);
+                       if (test_bit(ATH10K_FW_FEATURE_WMI_10X,
+                                    ar->fw_features)) {
+                               s->peer_rx_rate =
+                                       __le32_to_cpu(peer_stats->peer_rx_rate);
+                               tmp += sizeof(struct wmi_peer_stats_10x);
+
+                       } else {
+                               tmp += sizeof(struct wmi_peer_stats_old);
+                       }
                }
        }
 
@@ -272,7 +398,7 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
        struct ath10k *ar = file->private_data;
        struct ath10k_target_stats *fw_stats;
        char *buf = NULL;
-       unsigned int len = 0, buf_len = 2500;
+       unsigned int len = 0, buf_len = 8000;
        ssize_t ret_cnt = 0;
        long left;
        int i;
@@ -320,6 +446,16 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
                         "Cycle count", fw_stats->cycle_count);
        len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
                         "PHY error count", fw_stats->phy_err_count);
+       len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
+                        "RTS bad count", fw_stats->rts_bad);
+       len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
+                        "RTS good count", fw_stats->rts_good);
+       len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
+                        "FCS bad count", fw_stats->fcs_bad);
+       len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
+                        "No beacon count", fw_stats->no_beacons);
+       len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
+                        "MIB int count", fw_stats->mib_int_count);
 
        len += scnprintf(buf + len, buf_len - len, "\n");
        len += scnprintf(buf + len, buf_len - len, "%30s\n",
@@ -411,8 +547,8 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
                         "MPDU errors (FCS, MIC, ENC)", fw_stats->mpdu_errs);
 
        len += scnprintf(buf + len, buf_len - len, "\n");
-       len += scnprintf(buf + len, buf_len - len, "%30s\n",
-                        "ath10k PEER stats");
+       len += scnprintf(buf + len, buf_len - len, "%30s (%d)\n",
+                        "ath10k PEER stats", fw_stats->peers);
        len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
                                 "=================");
 
@@ -425,6 +561,9 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
                len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
                                 "Peer TX rate",
                                 fw_stats->peer_stat[i].peer_tx_rate);
+               len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
+                                "Peer RX rate",
+                                fw_stats->peer_stat[i].peer_rx_rate);
                len += scnprintf(buf + len, buf_len - len, "\n");
        }
        spin_unlock_bh(&ar->data_lock);
@@ -451,27 +590,37 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
                                             char __user *user_buf,
                                             size_t count, loff_t *ppos)
 {
-       const char buf[] = "To simulate firmware crash write the keyword"
-                          " `crash` to this file.\nThis will force firmware"
-                          " to report a crash to the host system.\n";
+       const char buf[] = "To simulate firmware crash write one of the"
+                          " keywords to this file:\n `soft` - this will send"
+                          " WMI_FORCE_FW_HANG_ASSERT to firmware if FW"
+                          " supports that command.\n `hard` - this will send"
+                          " to firmware command with illegal parameters"
+                          " causing firmware crash.\n";
+
        return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
 }
 
+/* Simulate firmware crash:
+ * 'soft': Call wmi command causing firmware hang. This firmware hang is
+ * recoverable by warm firmware reset.
+ * 'hard': Force firmware crash by setting any vdev parameter for not allowed
+ * vdev id. This is hard firmware crash because it is recoverable only by cold
+ * firmware reset.
+ */
 static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
                                              const char __user *user_buf,
                                              size_t count, loff_t *ppos)
 {
        struct ath10k *ar = file->private_data;
-       char buf[32] = {};
+       char buf[32];
        int ret;
 
        mutex_lock(&ar->conf_mutex);
 
        simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
-       if (strcmp(buf, "crash") && strcmp(buf, "crash\n")) {
-               ret = -EINVAL;
-               goto exit;
-       }
+
+       /* make sure that buf is null terminated */
+       buf[sizeof(buf) - 1] = 0;
 
        if (ar->state != ATH10K_STATE_ON &&
            ar->state != ATH10K_STATE_RESTARTED) {
@@ -479,14 +628,33 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
                goto exit;
        }
 
-       ath10k_info("simulating firmware crash\n");
+       /* drop the possible '\n' from the end */
+       if (buf[count - 1] == '\n') {
+               buf[count - 1] = 0;
+               count--;
+       }
 
-       ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);
-       if (ret)
-               ath10k_warn("failed to force fw hang (%d)\n", ret);
+       if (!strcmp(buf, "soft")) {
+               ath10k_info("simulating soft firmware crash\n");
+               ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);
+       } else if (!strcmp(buf, "hard")) {
+               ath10k_info("simulating hard firmware crash\n");
+               /* 0x7fff is vdev id, and it is always out of range for all
+                * firmware variants in order to force a firmware crash.
+                */
+               ret = ath10k_wmi_vdev_set_param(ar, 0x7fff,
+                                       ar->wmi.vdev_param->rts_threshold, 0);
+       } else {
+               ret = -EINVAL;
+               goto exit;
+       }
+
+       if (ret) {
+               ath10k_warn("failed to simulate firmware crash: %d\n", ret);
+               goto exit;
+       }
 
-       if (ret == 0)
-               ret = count;
+       ret = count;
 
 exit:
        mutex_unlock(&ar->conf_mutex);
@@ -520,6 +688,138 @@ static const struct file_operations fops_chip_id = {
        .llseek = default_llseek,
 };
 
+struct ath10k_fw_crash_data *
+ath10k_debug_get_new_fw_crash_data(struct ath10k *ar)
+{
+       struct ath10k_fw_crash_data *crash_data = ar->debug.fw_crash_data;
+
+       lockdep_assert_held(&ar->data_lock);
+
+       crash_data->crashed_since_read = true;
+       uuid_le_gen(&crash_data->uuid);
+       getnstimeofday(&crash_data->timestamp);
+
+       return crash_data;
+}
+EXPORT_SYMBOL(ath10k_debug_get_new_fw_crash_data);
+
+static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar)
+{
+       struct ath10k_fw_crash_data *crash_data = ar->debug.fw_crash_data;
+       struct ath10k_dump_file_data *dump_data;
+       struct ath10k_tlv_dump_data *dump_tlv;
+       int hdr_len = sizeof(*dump_data);
+       unsigned int len, sofar = 0;
+       unsigned char *buf;
+
+       len = hdr_len;
+       len += sizeof(*dump_tlv) + sizeof(crash_data->registers);
+
+       sofar += hdr_len;
+
+       /* This is going to get big when we start dumping FW RAM and such,
+        * so go ahead and use vmalloc.
+        */
+       buf = vzalloc(len);
+       if (!buf)
+               return NULL;
+
+       spin_lock_bh(&ar->data_lock);
+
+       if (!crash_data->crashed_since_read) {
+               spin_unlock_bh(&ar->data_lock);
+               vfree(buf);
+               return NULL;
+       }
+
+       dump_data = (struct ath10k_dump_file_data *)(buf);
+       strlcpy(dump_data->df_magic, "ATH10K-FW-DUMP",
+               sizeof(dump_data->df_magic));
+       dump_data->len = cpu_to_le32(len);
+
+       dump_data->version = cpu_to_le32(ATH10K_FW_CRASH_DUMP_VERSION);
+
+       memcpy(dump_data->uuid, &crash_data->uuid, sizeof(dump_data->uuid));
+       dump_data->chip_id = cpu_to_le32(ar->chip_id);
+       dump_data->bus_type = cpu_to_le32(0);
+       dump_data->target_version = cpu_to_le32(ar->target_version);
+       dump_data->fw_version_major = cpu_to_le32(ar->fw_version_major);
+       dump_data->fw_version_minor = cpu_to_le32(ar->fw_version_minor);
+       dump_data->fw_version_release = cpu_to_le32(ar->fw_version_release);
+       dump_data->fw_version_build = cpu_to_le32(ar->fw_version_build);
+       dump_data->phy_capability = cpu_to_le32(ar->phy_capability);
+       dump_data->hw_min_tx_power = cpu_to_le32(ar->hw_min_tx_power);
+       dump_data->hw_max_tx_power = cpu_to_le32(ar->hw_max_tx_power);
+       dump_data->ht_cap_info = cpu_to_le32(ar->ht_cap_info);
+       dump_data->vht_cap_info = cpu_to_le32(ar->vht_cap_info);
+       dump_data->num_rf_chains = cpu_to_le32(ar->num_rf_chains);
+
+       strlcpy(dump_data->fw_ver, ar->hw->wiphy->fw_version,
+               sizeof(dump_data->fw_ver));
+
+       dump_data->kernel_ver_code = cpu_to_le32(LINUX_VERSION_CODE);
+       strlcpy(dump_data->kernel_ver, VERMAGIC_STRING,
+               sizeof(dump_data->kernel_ver));
+
+       dump_data->tv_sec = cpu_to_le64(crash_data->timestamp.tv_sec);
+       dump_data->tv_nsec = cpu_to_le64(crash_data->timestamp.tv_nsec);
+
+       /* Gather crash-dump */
+       dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar);
+       dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_REGISTERS);
+       dump_tlv->tlv_len = cpu_to_le32(sizeof(crash_data->registers));
+       memcpy(dump_tlv->tlv_data, &crash_data->registers,
+              sizeof(crash_data->registers));
+       sofar += sizeof(*dump_tlv) + sizeof(crash_data->registers);
+
+       ar->debug.fw_crash_data->crashed_since_read = false;
+
+       spin_unlock_bh(&ar->data_lock);
+
+       return dump_data;
+}
+
+static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
+{
+       struct ath10k *ar = inode->i_private;
+       struct ath10k_dump_file_data *dump;
+
+       dump = ath10k_build_dump_file(ar);
+       if (!dump)
+               return -ENODATA;
+
+       file->private_data = dump;
+
+       return 0;
+}
+
+static ssize_t ath10k_fw_crash_dump_read(struct file *file,
+                                        char __user *user_buf,
+                                        size_t count, loff_t *ppos)
+{
+       struct ath10k_dump_file_data *dump_file = file->private_data;
+
+       return simple_read_from_buffer(user_buf, count, ppos,
+                                      dump_file,
+                                      le32_to_cpu(dump_file->len));
+}
+
+static int ath10k_fw_crash_dump_release(struct inode *inode,
+                                       struct file *file)
+{
+       vfree(file->private_data);
+
+       return 0;
+}
+
+static const struct file_operations fops_fw_crash_dump = {
+       .open = ath10k_fw_crash_dump_open,
+       .read = ath10k_fw_crash_dump_read,
+       .release = ath10k_fw_crash_dump_release,
+       .owner = THIS_MODULE,
+       .llseek = default_llseek,
+};
+
 static int ath10k_debug_htt_stats_req(struct ath10k *ar)
 {
        u64 cookie;
@@ -614,6 +914,72 @@ static const struct file_operations fops_htt_stats_mask = {
        .llseek = default_llseek,
 };
 
+static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file,
+                                              char __user *user_buf,
+                                              size_t count, loff_t *ppos)
+{
+       struct ath10k *ar = file->private_data;
+       char buf[64];
+       u8 amsdu = 3, ampdu = 64;
+       unsigned int len;
+
+       mutex_lock(&ar->conf_mutex);
+
+       if (ar->debug.htt_max_amsdu)
+               amsdu = ar->debug.htt_max_amsdu;
+
+       if (ar->debug.htt_max_ampdu)
+               ampdu = ar->debug.htt_max_ampdu;
+
+       mutex_unlock(&ar->conf_mutex);
+
+       len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu);
+
+       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
+                                               const char __user *user_buf,
+                                               size_t count, loff_t *ppos)
+{
+       struct ath10k *ar = file->private_data;
+       int res;
+       char buf[64];
+       unsigned int amsdu, ampdu;
+
+       simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+
+       /* make sure that buf is null terminated */
+       buf[sizeof(buf) - 1] = 0;
+
+       res = sscanf(buf, "%u %u", &amsdu, &ampdu);
+
+       if (res != 2)
+               return -EINVAL;
+
+       mutex_lock(&ar->conf_mutex);
+
+       res = ath10k_htt_h2t_aggr_cfg_msg(&ar->htt, ampdu, amsdu);
+       if (res)
+               goto out;
+
+       res = count;
+       ar->debug.htt_max_amsdu = amsdu;
+       ar->debug.htt_max_ampdu = ampdu;
+
+out:
+       mutex_unlock(&ar->conf_mutex);
+       return res;
+}
+
+static const struct file_operations fops_htt_max_amsdu_ampdu = {
+       .read = ath10k_read_htt_max_amsdu_ampdu,
+       .write = ath10k_write_htt_max_amsdu_ampdu,
+       .open = simple_open,
+       .owner = THIS_MODULE,
+       .llseek = default_llseek,
+};
+
 static ssize_t ath10k_read_fw_dbglog(struct file *file,
                                            char __user *user_buf,
                                            size_t count, loff_t *ppos)
@@ -700,6 +1066,9 @@ void ath10k_debug_stop(struct ath10k *ar)
         * warning from del_timer(). */
        if (ar->debug.htt_stats_mask != 0)
                cancel_delayed_work(&ar->debug.htt_stats_dwork);
+
+       ar->debug.htt_max_amsdu = 0;
+       ar->debug.htt_max_ampdu = 0;
 }
 
 static ssize_t ath10k_write_simulate_radar(struct file *file,
@@ -784,11 +1153,20 @@ static const struct file_operations fops_dfs_stats = {
 
 int ath10k_debug_create(struct ath10k *ar)
 {
+       int ret;
+
+       ar->debug.fw_crash_data = vzalloc(sizeof(*ar->debug.fw_crash_data));
+       if (!ar->debug.fw_crash_data) {
+               ret = -ENOMEM;
+               goto err;
+       }
+
        ar->debug.debugfs_phy = debugfs_create_dir("ath10k",
                                                   ar->hw->wiphy->debugfsdir);
-
-       if (!ar->debug.debugfs_phy)
-               return -ENOMEM;
+       if (!ar->debug.debugfs_phy) {
+               ret = -ENOMEM;
+               goto err_free_fw_crash_data;
+       }
 
        INIT_DELAYED_WORK(&ar->debug.htt_stats_dwork,
                          ath10k_debug_htt_stats_dwork);
@@ -804,12 +1182,19 @@ int ath10k_debug_create(struct ath10k *ar)
        debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy,
                            ar, &fops_simulate_fw_crash);
 
+       debugfs_create_file("fw_crash_dump", S_IRUSR, ar->debug.debugfs_phy,
+                           ar, &fops_fw_crash_dump);
+
        debugfs_create_file("chip_id", S_IRUSR, ar->debug.debugfs_phy,
                            ar, &fops_chip_id);
 
        debugfs_create_file("htt_stats_mask", S_IRUSR, ar->debug.debugfs_phy,
                            ar, &fops_htt_stats_mask);
 
+       debugfs_create_file("htt_max_amsdu_ampdu", S_IRUSR | S_IWUSR,
+                           ar->debug.debugfs_phy, ar,
+                           &fops_htt_max_amsdu_ampdu);
+
        debugfs_create_file("fw_dbglog", S_IRUSR, ar->debug.debugfs_phy,
                            ar, &fops_fw_dbglog);
 
@@ -828,10 +1213,17 @@ int ath10k_debug_create(struct ath10k *ar)
        }
 
        return 0;
+
+err_free_fw_crash_data:
+       vfree(ar->debug.fw_crash_data);
+
+err:
+       return ret;
 }
 
 void ath10k_debug_destroy(struct ath10k *ar)
 {
+       vfree(ar->debug.fw_crash_data);
        cancel_delayed_work_sync(&ar->debug.htt_stats_dwork);
 }