ath10k: improve logging to include dev id
[cascardo/linux.git] / drivers / net / wireless / ath / ath10k / wmi.c
index fffb15b..e500a3c 100644 (file)
@@ -624,18 +624,18 @@ int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
        return ret;
 }
 
-static struct sk_buff *ath10k_wmi_alloc_skb(u32 len)
+static struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
 {
        struct sk_buff *skb;
        u32 round_len = roundup(len, 4);
 
-       skb = ath10k_htc_alloc_skb(WMI_SKB_HEADROOM + round_len);
+       skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len);
        if (!skb)
                return NULL;
 
        skb_reserve(skb, WMI_SKB_HEADROOM);
        if (!IS_ALIGNED((unsigned long)skb->data, 4))
-               ath10k_warn("Unaligned WMI skb\n");
+               ath10k_warn(ar, "Unaligned WMI skb\n");
 
        skb_put(skb, round_len);
        memset(skb->data, 0, round_len);
@@ -733,7 +733,7 @@ static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb,
        might_sleep();
 
        if (cmd_id == WMI_CMD_UNSUPPORTED) {
-               ath10k_warn("wmi command %d is not supported by firmware\n",
+               ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
                            cmd_id);
                return ret;
        }
@@ -781,7 +781,7 @@ int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb)
 
        len = round_up(len, 4);
 
-       wmi_skb = ath10k_wmi_alloc_skb(len);
+       wmi_skb = ath10k_wmi_alloc_skb(ar, len);
        if (!wmi_skb)
                return -ENOMEM;
 
@@ -795,7 +795,7 @@ int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb)
        memcpy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr), ETH_ALEN);
        memcpy(cmd->buf, skb->data, skb->len);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
                   wmi_skb, wmi_skb->len, fc & IEEE80211_FCTL_FTYPE,
                   fc & IEEE80211_FCTL_STYPE);
 
@@ -811,6 +811,130 @@ int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb)
        return ret;
 }
 
+static void ath10k_wmi_event_scan_started(struct ath10k *ar)
+{
+       lockdep_assert_held(&ar->data_lock);
+
+       switch (ar->scan.state) {
+       case ATH10K_SCAN_IDLE:
+       case ATH10K_SCAN_RUNNING:
+       case ATH10K_SCAN_ABORTING:
+               ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n",
+                           ath10k_scan_state_str(ar->scan.state),
+                           ar->scan.state);
+               break;
+       case ATH10K_SCAN_STARTING:
+               ar->scan.state = ATH10K_SCAN_RUNNING;
+
+               if (ar->scan.is_roc)
+                       ieee80211_ready_on_channel(ar->hw);
+
+               complete(&ar->scan.started);
+               break;
+       }
+}
+
+static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
+{
+       lockdep_assert_held(&ar->data_lock);
+
+       switch (ar->scan.state) {
+       case ATH10K_SCAN_IDLE:
+       case ATH10K_SCAN_STARTING:
+               /* One suspected reason scan can be completed while starting is
+                * if firmware fails to deliver all scan events to the host,
+                * e.g. when transport pipe is full. This has been observed
+                * with spectral scan phyerr events starving wmi transport
+                * pipe. In such case the "scan completed" event should be (and
+                * is) ignored by the host as it may be just firmware's scan
+                * state machine recovering.
+                */
+               ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
+                           ath10k_scan_state_str(ar->scan.state),
+                           ar->scan.state);
+               break;
+       case ATH10K_SCAN_RUNNING:
+       case ATH10K_SCAN_ABORTING:
+               __ath10k_scan_finish(ar);
+               break;
+       }
+}
+
+static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
+{
+       lockdep_assert_held(&ar->data_lock);
+
+       switch (ar->scan.state) {
+       case ATH10K_SCAN_IDLE:
+       case ATH10K_SCAN_STARTING:
+               ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
+                           ath10k_scan_state_str(ar->scan.state),
+                           ar->scan.state);
+               break;
+       case ATH10K_SCAN_RUNNING:
+       case ATH10K_SCAN_ABORTING:
+               ar->scan_channel = NULL;
+               break;
+       }
+}
+
+static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
+{
+       lockdep_assert_held(&ar->data_lock);
+
+       switch (ar->scan.state) {
+       case ATH10K_SCAN_IDLE:
+       case ATH10K_SCAN_STARTING:
+               ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
+                           ath10k_scan_state_str(ar->scan.state),
+                           ar->scan.state);
+               break;
+       case ATH10K_SCAN_RUNNING:
+       case ATH10K_SCAN_ABORTING:
+               ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
+
+               if (ar->scan.is_roc && ar->scan.roc_freq == freq)
+                       complete(&ar->scan.on_channel);
+               break;
+       }
+}
+
+static const char *
+ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
+                              enum wmi_scan_completion_reason reason)
+{
+       switch (type) {
+       case WMI_SCAN_EVENT_STARTED:
+               return "started";
+       case WMI_SCAN_EVENT_COMPLETED:
+               switch (reason) {
+               case WMI_SCAN_REASON_COMPLETED:
+                       return "completed";
+               case WMI_SCAN_REASON_CANCELLED:
+                       return "completed [cancelled]";
+               case WMI_SCAN_REASON_PREEMPTED:
+                       return "completed [preempted]";
+               case WMI_SCAN_REASON_TIMEDOUT:
+                       return "completed [timedout]";
+               case WMI_SCAN_REASON_MAX:
+                       break;
+               }
+               return "completed [unknown]";
+       case WMI_SCAN_EVENT_BSS_CHANNEL:
+               return "bss channel";
+       case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
+               return "foreign channel";
+       case WMI_SCAN_EVENT_DEQUEUED:
+               return "dequeued";
+       case WMI_SCAN_EVENT_PREEMPTED:
+               return "preempted";
+       case WMI_SCAN_EVENT_START_FAILED:
+               return "start failed";
+       default:
+               return "unknown";
+       }
+}
+
 static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
 {
        struct wmi_scan_event *event = (struct wmi_scan_event *)skb->data;
@@ -828,81 +952,32 @@ static int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
        scan_id    = __le32_to_cpu(event->scan_id);
        vdev_id    = __le32_to_cpu(event->vdev_id);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENTID\n");
-       ath10k_dbg(ATH10K_DBG_WMI,
-                  "scan event type %d reason %d freq %d req_id %d "
-                  "scan_id %d vdev_id %d\n",
-                  event_type, reason, freq, req_id, scan_id, vdev_id);
-
        spin_lock_bh(&ar->data_lock);
 
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
+                  "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
+                  ath10k_wmi_event_scan_type_str(event_type, reason),
+                  event_type, reason, freq, req_id, scan_id, vdev_id,
+                  ath10k_scan_state_str(ar->scan.state), ar->scan.state);
+
        switch (event_type) {
        case WMI_SCAN_EVENT_STARTED:
-               ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_STARTED\n");
-               if (ar->scan.in_progress && ar->scan.is_roc)
-                       ieee80211_ready_on_channel(ar->hw);
-
-               complete(&ar->scan.started);
+               ath10k_wmi_event_scan_started(ar);
                break;
        case WMI_SCAN_EVENT_COMPLETED:
-               ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_COMPLETED\n");
-               switch (reason) {
-               case WMI_SCAN_REASON_COMPLETED:
-                       ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_COMPLETED\n");
-                       break;
-               case WMI_SCAN_REASON_CANCELLED:
-                       ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_CANCELED\n");
-                       break;
-               case WMI_SCAN_REASON_PREEMPTED:
-                       ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_PREEMPTED\n");
-                       break;
-               case WMI_SCAN_REASON_TIMEDOUT:
-                       ath10k_dbg(ATH10K_DBG_WMI, "SCAN_REASON_TIMEDOUT\n");
-                       break;
-               default:
-                       break;
-               }
-
-               ar->scan_channel = NULL;
-               if (!ar->scan.in_progress) {
-                       ath10k_warn("no scan requested, ignoring\n");
-                       break;
-               }
-
-               if (ar->scan.is_roc) {
-                       ath10k_offchan_tx_purge(ar);
-
-                       if (!ar->scan.aborting)
-                               ieee80211_remain_on_channel_expired(ar->hw);
-               } else {
-                       ieee80211_scan_completed(ar->hw, ar->scan.aborting);
-               }
-
-               del_timer(&ar->scan.timeout);
-               complete_all(&ar->scan.completed);
-               ar->scan.in_progress = false;
+               ath10k_wmi_event_scan_completed(ar);
                break;
        case WMI_SCAN_EVENT_BSS_CHANNEL:
-               ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_BSS_CHANNEL\n");
-               ar->scan_channel = NULL;
+               ath10k_wmi_event_scan_bss_chan(ar);
                break;
        case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
-               ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_FOREIGN_CHANNEL\n");
-               ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
-               if (ar->scan.in_progress && ar->scan.is_roc &&
-                   ar->scan.roc_freq == freq) {
-                       complete(&ar->scan.on_channel);
-               }
-               break;
-       case WMI_SCAN_EVENT_DEQUEUED:
-               ath10k_dbg(ATH10K_DBG_WMI, "SCAN_EVENT_DEQUEUED\n");
-               break;
-       case WMI_SCAN_EVENT_PREEMPTED:
-               ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENT_PREEMPTED\n");
+               ath10k_wmi_event_scan_foreign_chan(ar, freq);
                break;
        case WMI_SCAN_EVENT_START_FAILED:
-               ath10k_dbg(ATH10K_DBG_WMI, "WMI_SCAN_EVENT_START_FAILED\n");
+               ath10k_warn(ar, "received scan start failure event\n");
                break;
+       case WMI_SCAN_EVENT_DEQUEUED:
+       case WMI_SCAN_EVENT_PREEMPTED:
        default:
                break;
        }
@@ -1032,7 +1107,7 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
 
        memset(status, 0, sizeof(*status));
 
-       ath10k_dbg(ATH10K_DBG_MGMT,
+       ath10k_dbg(ar, ATH10K_DBG_MGMT,
                   "event mgmt rx status %08x\n", rx_status);
 
        if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) {
@@ -1068,9 +1143,9 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
 
                if (phy_mode == MODE_11B &&
                    status->band == IEEE80211_BAND_5GHZ)
-                       ath10k_dbg(ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
+                       ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
        } else {
-               ath10k_warn("using (unreliable) phy_mode to extract band for mgmt rx\n");
+               ath10k_warn(ar, "using (unreliable) phy_mode to extract band for mgmt rx\n");
                status->band = phy_mode_to_band(phy_mode);
        }
 
@@ -1100,12 +1175,12 @@ static int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
                }
        }
 
-       ath10k_dbg(ATH10K_DBG_MGMT,
+       ath10k_dbg(ar, ATH10K_DBG_MGMT,
                   "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
                   skb, skb->len,
                   fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
 
-       ath10k_dbg(ATH10K_DBG_MGMT,
+       ath10k_dbg(ar, ATH10K_DBG_MGMT,
                   "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
                   status->freq, status->band, status->signal,
                   status->rate_idx);
@@ -1155,21 +1230,26 @@ static void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
        rx_clear_count = __le32_to_cpu(ev->rx_clear_count);
        cycle_count = __le32_to_cpu(ev->cycle_count);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
                   err_code, freq, cmd_flags, noise_floor, rx_clear_count,
                   cycle_count);
 
        spin_lock_bh(&ar->data_lock);
 
-       if (!ar->scan.in_progress) {
-               ath10k_warn("chan info event without a scan request?\n");
+       switch (ar->scan.state) {
+       case ATH10K_SCAN_IDLE:
+       case ATH10K_SCAN_STARTING:
+               ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
                goto exit;
+       case ATH10K_SCAN_RUNNING:
+       case ATH10K_SCAN_ABORTING:
+               break;
        }
 
        idx = freq_to_idx(ar, freq);
        if (idx >= ARRAY_SIZE(ar->survey)) {
-               ath10k_warn("chan info: invalid frequency %d (idx %d out of bounds)\n",
+               ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
                            freq, idx);
                goto exit;
        }
@@ -1200,12 +1280,12 @@ exit:
 
 static void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
 }
 
 static int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
                   skb->len);
 
        trace_ath10k_wmi_dbglog(skb->data, skb->len);
@@ -1218,7 +1298,7 @@ static void ath10k_wmi_event_update_stats(struct ath10k *ar,
 {
        struct wmi_stats_event *ev = (struct wmi_stats_event *)skb->data;
 
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
 
        ath10k_debug_read_target_stats(ar, ev);
 }
@@ -1228,7 +1308,7 @@ static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar,
 {
        struct wmi_vdev_start_response_event *ev;
 
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
 
        ev = (struct wmi_vdev_start_response_event *)skb->data;
 
@@ -1241,7 +1321,7 @@ static void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar,
 static void ath10k_wmi_event_vdev_stopped(struct ath10k *ar,
                                          struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
        complete(&ar->vdev_setup_done);
 }
 
@@ -1253,14 +1333,14 @@ static void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar,
 
        ev = (struct wmi_peer_sta_kickout_event *)skb->data;
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
                   ev->peer_macaddr.addr);
 
        rcu_read_lock();
 
        sta = ieee80211_find_sta_by_ifaddr(ar->hw, ev->peer_macaddr.addr, NULL);
        if (!sta) {
-               ath10k_warn("Spurious quick kickout for STA %pM\n",
+               ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
                            ev->peer_macaddr.addr);
                goto exit;
        }
@@ -1337,7 +1417,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar,
                                    (u8 *)skb_tail_pointer(bcn) - ies);
        if (!ie) {
                if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
-                       ath10k_warn("no tim ie found;\n");
+                       ath10k_warn(ar, "no tim ie found;\n");
                return;
        }
 
@@ -1357,12 +1437,12 @@ static void ath10k_wmi_update_tim(struct ath10k *ar,
                        ie_len += expand_size;
                        pvm_len += expand_size;
                } else {
-                       ath10k_warn("tim expansion failed\n");
+                       ath10k_warn(ar, "tim expansion failed\n");
                }
        }
 
        if (pvm_len > sizeof(arvif->u.ap.tim_bitmap)) {
-               ath10k_warn("tim pvm length is too great (%d)\n", pvm_len);
+               ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
                return;
        }
 
@@ -1376,7 +1456,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar,
                        ATH10K_SKB_CB(bcn)->bcn.deliver_cab = true;
        }
 
-       ath10k_dbg(ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
+       ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
                   tim->dtim_count, tim->dtim_period,
                   tim->bitmap_ctrl, pvm_len);
 }
@@ -1454,7 +1534,7 @@ static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
        if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
                return;
 
-       ath10k_dbg(ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
+       ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
        if (noa->changed & WMI_P2P_NOA_CHANGED_BIT) {
                new_len = ath10k_p2p_calc_noa_ie_len(noa);
                if (!new_len)
@@ -1502,7 +1582,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
        ev = (struct wmi_host_swba_event *)skb->data;
        map = __le32_to_cpu(ev->vdev_map);
 
-       ath10k_dbg(ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
+       ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
                   ev->vdev_map);
 
        for (; map; map >>= 1, vdev_id++) {
@@ -1512,13 +1592,13 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
                i++;
 
                if (i >= WMI_MAX_AP_VDEV) {
-                       ath10k_warn("swba has corrupted vdev map\n");
+                       ath10k_warn(ar, "swba has corrupted vdev map\n");
                        break;
                }
 
                bcn_info = &ev->bcn_info[i];
 
-               ath10k_dbg(ATH10K_DBG_MGMT,
+               ath10k_dbg(ar, ATH10K_DBG_MGMT,
                           "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n",
                           i,
                           __le32_to_cpu(bcn_info->tim_info.tim_len),
@@ -1532,7 +1612,8 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
 
                arvif = ath10k_get_arvif(ar, vdev_id);
                if (arvif == NULL) {
-                       ath10k_warn("no vif for vdev_id %d found\n", vdev_id);
+                       ath10k_warn(ar, "no vif for vdev_id %d found\n",
+                                   vdev_id);
                        continue;
                }
 
@@ -1549,7 +1630,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
 
                bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
                if (!bcn) {
-                       ath10k_warn("could not get mac80211 beacon\n");
+                       ath10k_warn(ar, "could not get mac80211 beacon\n");
                        continue;
                }
 
@@ -1561,7 +1642,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
 
                if (arvif->beacon) {
                        if (!arvif->beacon_sent)
-                               ath10k_warn("SWBA overrun on vdev %d\n",
+                               ath10k_warn(ar, "SWBA overrun on vdev %d\n",
                                            arvif->vdev_id);
 
                        dma_unmap_single(arvif->ar->dev,
@@ -1577,7 +1658,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
                ret = dma_mapping_error(arvif->ar->dev,
                                        ATH10K_SKB_CB(bcn)->paddr);
                if (ret) {
-                       ath10k_warn("failed to map beacon: %d\n", ret);
+                       ath10k_warn(ar, "failed to map beacon: %d\n", ret);
                        dev_kfree_skb_any(bcn);
                        goto skip;
                }
@@ -1594,7 +1675,7 @@ skip:
 static void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar,
                                               struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
 }
 
 static void ath10k_dfs_radar_report(struct ath10k *ar,
@@ -1610,20 +1691,20 @@ static void ath10k_dfs_radar_report(struct ath10k *ar,
        reg0 = __le32_to_cpu(rr->reg0);
        reg1 = __le32_to_cpu(rr->reg1);
 
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
                   MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
                   MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
                   MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
                   MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
                   MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
                   MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
                   MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
                   MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
                   MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
                   MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
                   MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
@@ -1650,25 +1731,25 @@ static void ath10k_dfs_radar_report(struct ath10k *ar,
        pe.width = width;
        pe.rssi = rssi;
 
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
                   pe.freq, pe.width, pe.rssi, pe.ts);
 
        ATH10K_DFS_STAT_INC(ar, pulses_detected);
 
        if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
-               ath10k_dbg(ATH10K_DBG_REGULATORY,
+               ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                           "dfs no pulse pattern detected, yet\n");
                return;
        }
 
-       ath10k_dbg(ATH10K_DBG_REGULATORY, "dfs radar detected\n");
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
        ATH10K_DFS_STAT_INC(ar, radar_detected);
 
        /* Control radar events reporting in debugfs file
           dfs_block_radar_events */
        if (ar->dfs_block_radar_events) {
-               ath10k_info("DFS Radar detected, but ignored as requested\n");
+               ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
                return;
        }
 
@@ -1687,13 +1768,13 @@ static int ath10k_dfs_fft_report(struct ath10k *ar,
        reg1 = __le32_to_cpu(fftr->reg1);
        rssi = event->hdr.rssi_combined;
 
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
                   MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
                   MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
                   MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
                   MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
                   MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
                   MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
@@ -1705,7 +1786,7 @@ static int ath10k_dfs_fft_report(struct ath10k *ar,
        /* false event detection */
        if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
            peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
-               ath10k_dbg(ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
+               ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
                ATH10K_DFS_STAT_INC(ar, pulses_discarded);
                return -EINVAL;
        }
@@ -1724,7 +1805,7 @@ static void ath10k_wmi_event_dfs(struct ath10k *ar,
        u8 *tlv_buf;
 
        buf_len = __le32_to_cpu(event->hdr.buf_len);
-       ath10k_dbg(ATH10K_DBG_REGULATORY,
+       ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                   "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
                   event->hdr.phy_err_code, event->hdr.rssi_combined,
                   __le32_to_cpu(event->hdr.tsf_timestamp), tsf, buf_len);
@@ -1737,21 +1818,22 @@ static void ath10k_wmi_event_dfs(struct ath10k *ar,
 
        while (i < buf_len) {
                if (i + sizeof(*tlv) > buf_len) {
-                       ath10k_warn("too short buf for tlv header (%d)\n", i);
+                       ath10k_warn(ar, "too short buf for tlv header (%d)\n",
+                                   i);
                        return;
                }
 
                tlv = (struct phyerr_tlv *)&event->bufp[i];
                tlv_len = __le16_to_cpu(tlv->len);
                tlv_buf = &event->bufp[i + sizeof(*tlv)];
-               ath10k_dbg(ATH10K_DBG_REGULATORY,
+               ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
                           "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
                           tlv_len, tlv->tag, tlv->sig);
 
                switch (tlv->tag) {
                case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
                        if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
-                               ath10k_warn("too short radar pulse summary (%d)\n",
+                               ath10k_warn(ar, "too short radar pulse summary (%d)\n",
                                            i);
                                return;
                        }
@@ -1761,7 +1843,8 @@ static void ath10k_wmi_event_dfs(struct ath10k *ar,
                        break;
                case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
                        if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
-                               ath10k_warn("too short fft report (%d)\n", i);
+                               ath10k_warn(ar, "too short fft report (%d)\n",
+                                           i);
                                return;
                        }
 
@@ -1790,7 +1873,7 @@ static void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
 
        while (i < buf_len) {
                if (i + sizeof(*tlv) > buf_len) {
-                       ath10k_warn("failed to parse phyerr tlv header at byte %d\n",
+                       ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
                                    i);
                        return;
                }
@@ -1800,7 +1883,7 @@ static void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
                tlv_buf = &event->bufp[i + sizeof(*tlv)];
 
                if (i + sizeof(*tlv) + tlv_len > buf_len) {
-                       ath10k_warn("failed to parse phyerr tlv payload at byte %d\n",
+                       ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
                                    i);
                        return;
                }
@@ -1808,7 +1891,7 @@ static void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
                switch (tlv->tag) {
                case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
                        if (sizeof(*fftr) > tlv_len) {
-                               ath10k_warn("failed to parse fft report at byte %d\n",
+                               ath10k_warn(ar, "failed to parse fft report at byte %d\n",
                                            i);
                                return;
                        }
@@ -1819,7 +1902,7 @@ static void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
                                                          fftr, fftr_len,
                                                          tsf);
                        if (res < 0) {
-                               ath10k_warn("failed to process fft report: %d\n",
+                               ath10k_warn(ar, "failed to process fft report: %d\n",
                                            res);
                                return;
                        }
@@ -1842,7 +1925,7 @@ static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
 
        /* Check if combined event available */
        if (left_len < sizeof(*comb_event)) {
-               ath10k_warn("wmi phyerr combined event wrong len\n");
+               ath10k_warn(ar, "wmi phyerr combined event wrong len\n");
                return;
        }
 
@@ -1856,7 +1939,7 @@ static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
        tsf <<= 32;
        tsf |= __le32_to_cpu(comb_event->hdr.tsf_l32);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi event phyerr count %d tsf64 0x%llX\n",
                   count, tsf);
 
@@ -1864,7 +1947,8 @@ static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
        for (i = 0; i < count; i++) {
                /* Check if we can read event header */
                if (left_len < sizeof(*event)) {
-                       ath10k_warn("single event (%d) wrong head len\n", i);
+                       ath10k_warn(ar, "single event (%d) wrong head len\n",
+                                   i);
                        return;
                }
 
@@ -1874,7 +1958,7 @@ static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
                phy_err_code = event->hdr.phy_err_code;
 
                if (left_len < buf_len) {
-                       ath10k_warn("single event (%d) wrong buf len\n", i);
+                       ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
                        return;
                }
 
@@ -1901,13 +1985,13 @@ static void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
 
 static void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_ROAM_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ROAM_EVENTID\n");
 }
 
 static void ath10k_wmi_event_profile_match(struct ath10k *ar,
                                    struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
 }
 
 static void ath10k_wmi_event_debug_print(struct ath10k *ar,
@@ -1932,7 +2016,7 @@ static void ath10k_wmi_event_debug_print(struct ath10k *ar,
        }
 
        if (i == sizeof(buf) - 1)
-               ath10k_warn("wmi debug print truncated: %d\n", skb->len);
+               ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
 
        /* for some reason the debug prints end with \n, remove that */
        if (skb->data[i - 1] == '\n')
@@ -1941,108 +2025,108 @@ static void ath10k_wmi_event_debug_print(struct ath10k *ar,
        /* the last byte is always reserved for the null character */
        buf[i] = '\0';
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi event debug print '%s'\n", buf);
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug print '%s'\n", buf);
 }
 
 static void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
 }
 
 static void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar,
                                               struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
 }
 
 static void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
                                             struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
 }
 
 static void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
                                             struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
 }
 
 static void ath10k_wmi_event_rtt_error_report(struct ath10k *ar,
                                              struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
 }
 
 static void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar,
                                             struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_WOW_WAKEUP_HOST_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WOW_WAKEUP_HOST_EVENTID\n");
 }
 
 static void ath10k_wmi_event_dcs_interference(struct ath10k *ar,
                                              struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
 }
 
 static void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar,
                                             struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_TPC_CONFIG_EVENTID\n");
 }
 
 static void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar,
                                           struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
 }
 
 static void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar,
                                         struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
 }
 
 static void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar,
                                            struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
 }
 
 static void ath10k_wmi_event_delba_complete(struct ath10k *ar,
                                            struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
 }
 
 static void ath10k_wmi_event_addba_complete(struct ath10k *ar,
                                            struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
 }
 
 static void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
                                                struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
 }
 
 static void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar,
                                             struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
 }
 
 static void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar,
                                              struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
 }
 
 static void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar,
                                             struct sk_buff *skb)
 {
-       ath10k_dbg(ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
 }
 
 static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
@@ -2062,7 +2146,7 @@ static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
                                                           &paddr,
                                                           GFP_ATOMIC);
        if (!ar->wmi.mem_chunks[idx].vaddr) {
-               ath10k_warn("failed to allocate memory chunk\n");
+               ath10k_warn(ar, "failed to allocate memory chunk\n");
                return -ENOMEM;
        }
 
@@ -2080,9 +2164,10 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar,
                                              struct sk_buff *skb)
 {
        struct wmi_service_ready_event *ev = (void *)skb->data;
+       DECLARE_BITMAP(svc_bmap, WMI_SERVICE_BM_SIZE) = {};
 
        if (skb->len < sizeof(*ev)) {
-               ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
+               ath10k_warn(ar, "Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
                            skb->len, sizeof(*ev));
                return;
        }
@@ -2105,7 +2190,7 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar,
                set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
 
        if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) {
-               ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
+               ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
                            ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM);
                ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM;
        }
@@ -2113,8 +2198,10 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar,
        ar->ath_common.regulatory.current_rd =
                __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd);
 
-       ath10k_debug_read_service_map(ar, ev->wmi_service_bitmap,
-                                     sizeof(ev->wmi_service_bitmap));
+       wmi_main_svc_map(ev->wmi_service_bitmap, svc_bmap);
+       ath10k_debug_read_service_map(ar, svc_bmap, sizeof(svc_bmap));
+       ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
+                       ev->wmi_service_bitmap, sizeof(ev->wmi_service_bitmap));
 
        if (strlen(ar->hw->wiphy->fw_version) == 0) {
                snprintf(ar->hw->wiphy->fw_version,
@@ -2128,11 +2215,11 @@ static void ath10k_wmi_service_ready_event_rx(struct ath10k *ar,
 
        /* FIXME: it probably should be better to support this */
        if (__le32_to_cpu(ev->num_mem_reqs) > 0) {
-               ath10k_warn("target requested %d memory chunks; ignoring\n",
+               ath10k_warn(ar, "target requested %d memory chunks; ignoring\n",
                            __le32_to_cpu(ev->num_mem_reqs));
        }
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n",
                   __le32_to_cpu(ev->sw_version),
                   __le32_to_cpu(ev->sw_version_1),
@@ -2154,9 +2241,10 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
        u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
        int ret;
        struct wmi_service_ready_event_10x *ev = (void *)skb->data;
+       DECLARE_BITMAP(svc_bmap, WMI_SERVICE_BM_SIZE) = {};
 
        if (skb->len < sizeof(*ev)) {
-               ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
+               ath10k_warn(ar, "Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
                            skb->len, sizeof(*ev));
                return;
        }
@@ -2172,7 +2260,7 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
        ar->num_rf_chains = __le32_to_cpu(ev->num_rf_chains);
 
        if (ar->num_rf_chains > WMI_MAX_SPATIAL_STREAM) {
-               ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
+               ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
                            ar->num_rf_chains, WMI_MAX_SPATIAL_STREAM);
                ar->num_rf_chains = WMI_MAX_SPATIAL_STREAM;
        }
@@ -2180,8 +2268,10 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
        ar->ath_common.regulatory.current_rd =
                __le32_to_cpu(ev->hal_reg_capabilities.eeprom_rd);
 
-       ath10k_debug_read_service_map(ar, ev->wmi_service_bitmap,
-                                     sizeof(ev->wmi_service_bitmap));
+       wmi_10x_svc_map(ev->wmi_service_bitmap, svc_bmap);
+       ath10k_debug_read_service_map(ar, svc_bmap, sizeof(svc_bmap));
+       ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
+                       ev->wmi_service_bitmap, sizeof(ev->wmi_service_bitmap));
 
        if (strlen(ar->hw->wiphy->fw_version) == 0) {
                snprintf(ar->hw->wiphy->fw_version,
@@ -2194,7 +2284,7 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
        num_mem_reqs = __le32_to_cpu(ev->num_mem_reqs);
 
        if (num_mem_reqs > ATH10K_MAX_MEM_REQS) {
-               ath10k_warn("requested memory chunks number (%d) exceeds the limit\n",
+               ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
                            num_mem_reqs);
                return;
        }
@@ -2202,7 +2292,7 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
        if (!num_mem_reqs)
                goto exit;
 
-       ath10k_dbg(ATH10K_DBG_WMI, "firmware has requested %d memory chunks\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "firmware has requested %d memory chunks\n",
                   num_mem_reqs);
 
        for (i = 0; i < num_mem_reqs; ++i) {
@@ -2220,7 +2310,7 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
                else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS)
                        num_units = TARGET_10X_NUM_VDEVS + 1;
 
-               ath10k_dbg(ATH10K_DBG_WMI,
+               ath10k_dbg(ar, ATH10K_DBG_WMI,
                           "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
                           req_id,
                           __le32_to_cpu(ev->mem_reqs[i].num_units),
@@ -2235,7 +2325,7 @@ static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k *ar,
        }
 
 exit:
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi event service ready sw_ver 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n",
                   __le32_to_cpu(ev->sw_version),
                   __le32_to_cpu(ev->abi_version),
@@ -2259,7 +2349,7 @@ static int ath10k_wmi_ready_event_rx(struct ath10k *ar, struct sk_buff *skb)
 
        memcpy(ar->mac_addr, ev->mac_addr.addr, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d skb->len %i ev-sz %zu\n",
                   __le32_to_cpu(ev->sw_version),
                   __le32_to_cpu(ev->abi_version),
@@ -2379,7 +2469,7 @@ static void ath10k_wmi_main_process_rx(struct ath10k *ar, struct sk_buff *skb)
                ath10k_wmi_ready_event_rx(ar, skb);
                break;
        default:
-               ath10k_warn("Unknown eventid: %d\n", id);
+               ath10k_warn(ar, "Unknown eventid: %d\n", id);
                break;
        }
 
@@ -2486,7 +2576,7 @@ static void ath10k_wmi_10x_process_rx(struct ath10k *ar, struct sk_buff *skb)
                ath10k_wmi_ready_event_rx(ar, skb);
                break;
        default:
-               ath10k_warn("Unknown eventid: %d\n", id);
+               ath10k_warn(ar, "Unknown eventid: %d\n", id);
                break;
        }
 
@@ -2599,11 +2689,11 @@ static void ath10k_wmi_10_2_process_rx(struct ath10k *ar, struct sk_buff *skb)
        case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
        case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
        case WMI_10_2_WDS_PEER_EVENTID:
-               ath10k_dbg(ATH10K_DBG_WMI,
+               ath10k_dbg(ar, ATH10K_DBG_WMI,
                           "received event id %d not implemented\n", id);
                break;
        default:
-               ath10k_warn("Unknown eventid: %d\n", id);
+               ath10k_warn(ar, "Unknown eventid: %d\n", id);
                break;
        }
 
@@ -2680,7 +2770,7 @@ int ath10k_wmi_connect(struct ath10k *ar)
 
        status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
        if (status) {
-               ath10k_warn("failed to connect to WMI CONTROL service status: %d\n",
+               ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
                            status);
                return status;
        }
@@ -2696,7 +2786,7 @@ static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd,
        struct wmi_pdev_set_regdomain_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -2707,7 +2797,7 @@ static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd,
        cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
        cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
                   rd, rd2g, rd5g, ctl2g, ctl5g);
 
@@ -2723,7 +2813,7 @@ static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd,
        struct wmi_pdev_set_regdomain_cmd_10x *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -2735,7 +2825,7 @@ static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd,
        cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
        cmd->dfs_domain = __cpu_to_le32(dfs_reg);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
                   rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
 
@@ -2765,7 +2855,7 @@ int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
        if (arg->passive)
                return -EINVAL;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -2783,7 +2873,7 @@ int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
        cmd->chan.reg_classid       = arg->reg_class_id;
        cmd->chan.antenna_max       = arg->max_antenna_gain;
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi set channel mode %d freq %d\n",
                   arg->mode, arg->freq);
 
@@ -2796,7 +2886,7 @@ int ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt)
        struct wmi_pdev_suspend_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -2810,7 +2900,7 @@ int ath10k_wmi_pdev_resume_target(struct ath10k *ar)
 {
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(0);
+       skb = ath10k_wmi_alloc_skb(ar, 0);
        if (skb == NULL)
                return -ENOMEM;
 
@@ -2823,11 +2913,12 @@ int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
        struct sk_buff *skb;
 
        if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
-               ath10k_warn("pdev param %d not supported by firmware\n", id);
+               ath10k_warn(ar, "pdev param %d not supported by firmware\n",
+                           id);
                return -EOPNOTSUPP;
        }
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -2835,7 +2926,7 @@ int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
        cmd->param_id    = __cpu_to_le32(id);
        cmd->param_value = __cpu_to_le32(value);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
                   id, value);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->pdev_set_param_cmdid);
 }
@@ -2902,7 +2993,7 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
        len = sizeof(*cmd) +
              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
 
-       buf = ath10k_wmi_alloc_skb(len);
+       buf = ath10k_wmi_alloc_skb(ar, len);
        if (!buf)
                return -ENOMEM;
 
@@ -2913,7 +3004,7 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
                goto out;
        }
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
                   ar->wmi.num_mem_chunks);
 
        cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
@@ -2926,7 +3017,7 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
                cmd->host_mem_chunks[i].req_id =
                        __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
 
-               ath10k_dbg(ATH10K_DBG_WMI,
+               ath10k_dbg(ar, ATH10K_DBG_WMI,
                           "wmi chunk %d len %d requested, addr 0x%llx\n",
                           i,
                           ar->wmi.mem_chunks[i].len,
@@ -2935,7 +3026,7 @@ static int ath10k_wmi_main_cmd_init(struct ath10k *ar)
 out:
        memcpy(&cmd->resource_config, &config, sizeof(config));
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi init\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
        return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid);
 }
 
@@ -2993,7 +3084,7 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
        len = sizeof(*cmd) +
              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
 
-       buf = ath10k_wmi_alloc_skb(len);
+       buf = ath10k_wmi_alloc_skb(ar, len);
        if (!buf)
                return -ENOMEM;
 
@@ -3004,7 +3095,7 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
                goto out;
        }
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
                   ar->wmi.num_mem_chunks);
 
        cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
@@ -3017,7 +3108,7 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
                cmd->host_mem_chunks[i].req_id =
                        __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
 
-               ath10k_dbg(ATH10K_DBG_WMI,
+               ath10k_dbg(ar, ATH10K_DBG_WMI,
                           "wmi chunk %d len %d requested, addr 0x%llx\n",
                           i,
                           ar->wmi.mem_chunks[i].len,
@@ -3026,7 +3117,7 @@ static int ath10k_wmi_10x_cmd_init(struct ath10k *ar)
 out:
        memcpy(&cmd->resource_config, &config, sizeof(config));
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi init 10x\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
        return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid);
 }
 
@@ -3084,7 +3175,7 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar)
        len = sizeof(*cmd) +
              (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
 
-       buf = ath10k_wmi_alloc_skb(len);
+       buf = ath10k_wmi_alloc_skb(ar, len);
        if (!buf)
                return -ENOMEM;
 
@@ -3095,7 +3186,7 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar)
                goto out;
        }
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi sending %d memory chunks info.\n",
                   ar->wmi.num_mem_chunks);
 
        cmd->num_host_mem_chunks = __cpu_to_le32(ar->wmi.num_mem_chunks);
@@ -3108,7 +3199,7 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar)
                cmd->host_mem_chunks[i].req_id =
                        __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
 
-               ath10k_dbg(ATH10K_DBG_WMI,
+               ath10k_dbg(ar, ATH10K_DBG_WMI,
                           "wmi chunk %d len %d requested, addr 0x%llx\n",
                           i,
                           ar->wmi.mem_chunks[i].len,
@@ -3117,7 +3208,7 @@ static int ath10k_wmi_10_2_cmd_init(struct ath10k *ar)
 out:
        memcpy(&cmd->resource_config.common, &config, sizeof(config));
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi init 10.2\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
        return ath10k_wmi_cmd_send(ar, buf, ar->wmi.cmd->init_cmdid);
 }
 
@@ -3209,7 +3300,7 @@ int ath10k_wmi_start_scan(struct ath10k *ar,
        if (len < 0)
                return len; /* len contains error code here */
 
-       skb = ath10k_wmi_alloc_skb(len);
+       skb = ath10k_wmi_alloc_skb(ar, len);
        if (!skb)
                return -ENOMEM;
 
@@ -3305,7 +3396,7 @@ int ath10k_wmi_start_scan(struct ath10k *ar,
                return -EINVAL;
        }
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi start scan\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->start_scan_cmdid);
 }
 
@@ -3347,7 +3438,7 @@ int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg)
        if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
                return -EINVAL;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3363,7 +3454,7 @@ int ath10k_wmi_stop_scan(struct ath10k *ar, const struct wmi_stop_scan_arg *arg)
        cmd->scan_id     = __cpu_to_le32(scan_id);
        cmd->scan_req_id = __cpu_to_le32(req_id);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
                   arg->req_id, arg->req_type, arg->u.scan_id);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->stop_scan_cmdid);
@@ -3377,7 +3468,7 @@ int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id,
        struct wmi_vdev_create_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3387,7 +3478,7 @@ int ath10k_wmi_vdev_create(struct ath10k *ar, u32 vdev_id,
        cmd->vdev_subtype = __cpu_to_le32(subtype);
        memcpy(cmd->vdev_macaddr.addr, macaddr, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
                   vdev_id, type, subtype, macaddr);
 
@@ -3399,14 +3490,14 @@ int ath10k_wmi_vdev_delete(struct ath10k *ar, u32 vdev_id)
        struct wmi_vdev_delete_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
        cmd = (struct wmi_vdev_delete_cmd *)skb->data;
        cmd->vdev_id = __cpu_to_le32(vdev_id);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "WMI vdev delete id %d\n", vdev_id);
 
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_delete_cmdid);
@@ -3439,7 +3530,7 @@ static int ath10k_wmi_vdev_start_restart(struct ath10k *ar,
        else
                return -EINVAL; /* should not happen, we already check cmd_id */
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3477,7 +3568,7 @@ static int ath10k_wmi_vdev_start_restart(struct ath10k *ar,
        cmd->chan.reg_classid = arg->channel.reg_class_id;
        cmd->chan.antenna_max = arg->channel.max_antenna_gain;
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, "
                   "ch_flags: 0x%0X, max_power: %d\n", cmdname, arg->vdev_id,
                   flags, arg->channel.freq, arg->channel.mode,
@@ -3507,14 +3598,14 @@ int ath10k_wmi_vdev_stop(struct ath10k *ar, u32 vdev_id)
        struct wmi_vdev_stop_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
        cmd = (struct wmi_vdev_stop_cmd *)skb->data;
        cmd->vdev_id = __cpu_to_le32(vdev_id);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
 
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_stop_cmdid);
 }
@@ -3524,7 +3615,7 @@ int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid)
        struct wmi_vdev_up_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3533,7 +3624,7 @@ int ath10k_wmi_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid, const u8 *bssid)
        cmd->vdev_assoc_id = __cpu_to_le32(aid);
        memcpy(&cmd->vdev_bssid.addr, bssid, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
                   vdev_id, aid, bssid);
 
@@ -3545,14 +3636,14 @@ int ath10k_wmi_vdev_down(struct ath10k *ar, u32 vdev_id)
        struct wmi_vdev_down_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
        cmd = (struct wmi_vdev_down_cmd *)skb->data;
        cmd->vdev_id = __cpu_to_le32(vdev_id);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi mgmt vdev down id 0x%x\n", vdev_id);
 
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->vdev_down_cmdid);
@@ -3565,13 +3656,13 @@ int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
        struct sk_buff *skb;
 
        if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
-               ath10k_dbg(ATH10K_DBG_WMI,
+               ath10k_dbg(ar, ATH10K_DBG_WMI,
                           "vdev param %d not supported by firmware\n",
                            param_id);
                return -EOPNOTSUPP;
        }
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3580,7 +3671,7 @@ int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
        cmd->param_id    = __cpu_to_le32(param_id);
        cmd->param_value = __cpu_to_le32(param_value);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi vdev id 0x%x set param %d value %d\n",
                   vdev_id, param_id, param_value);
 
@@ -3598,7 +3689,7 @@ int ath10k_wmi_vdev_install_key(struct ath10k *ar,
        if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
                return -EINVAL;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd) + arg->key_len);
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
        if (!skb)
                return -ENOMEM;
 
@@ -3616,7 +3707,7 @@ int ath10k_wmi_vdev_install_key(struct ath10k *ar,
        if (arg->key_data)
                memcpy(cmd->key_data, arg->key_data, arg->key_len);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi vdev install key idx %d cipher %d len %d\n",
                   arg->key_idx, arg->key_cipher, arg->key_len);
        return ath10k_wmi_cmd_send(ar, skb,
@@ -3630,7 +3721,7 @@ int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
        struct sk_buff *skb;
        u32 cmdid;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3666,7 +3757,7 @@ int ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger,
        struct sk_buff *skb;
        u32 cmdid;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3685,7 +3776,7 @@ int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id,
        struct wmi_peer_create_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3693,7 +3784,7 @@ int ath10k_wmi_peer_create(struct ath10k *ar, u32 vdev_id,
        cmd->vdev_id = __cpu_to_le32(vdev_id);
        memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi peer create vdev_id %d peer_addr %pM\n",
                   vdev_id, peer_addr);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_create_cmdid);
@@ -3705,7 +3796,7 @@ int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id,
        struct wmi_peer_delete_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3713,7 +3804,7 @@ int ath10k_wmi_peer_delete(struct ath10k *ar, u32 vdev_id,
        cmd->vdev_id = __cpu_to_le32(vdev_id);
        memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi peer delete vdev_id %d peer_addr %pM\n",
                   vdev_id, peer_addr);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_delete_cmdid);
@@ -3725,7 +3816,7 @@ int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id,
        struct wmi_peer_flush_tids_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3734,7 +3825,7 @@ int ath10k_wmi_peer_flush(struct ath10k *ar, u32 vdev_id,
        cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
        memcpy(cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
                   vdev_id, peer_addr, tid_bitmap);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_flush_tids_cmdid);
@@ -3747,7 +3838,7 @@ int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id,
        struct wmi_peer_set_param_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3757,7 +3848,7 @@ int ath10k_wmi_peer_set_param(struct ath10k *ar, u32 vdev_id,
        cmd->param_value = __cpu_to_le32(param_value);
        memcpy(&cmd->peer_macaddr.addr, peer_addr, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi vdev %d peer 0x%pM set param %d value %d\n",
                   vdev_id, peer_addr, param_id, param_value);
 
@@ -3770,7 +3861,7 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
        struct wmi_sta_powersave_mode_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3778,7 +3869,7 @@ int ath10k_wmi_set_psmode(struct ath10k *ar, u32 vdev_id,
        cmd->vdev_id     = __cpu_to_le32(vdev_id);
        cmd->sta_ps_mode = __cpu_to_le32(psmode);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi set powersave id 0x%x mode %d\n",
                   vdev_id, psmode);
 
@@ -3793,7 +3884,7 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
        struct wmi_sta_powersave_param_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3802,7 +3893,7 @@ int ath10k_wmi_set_sta_ps_param(struct ath10k *ar, u32 vdev_id,
        cmd->param_id    = __cpu_to_le32(param_id);
        cmd->param_value = __cpu_to_le32(value);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi sta ps param vdev_id 0x%x param %d value %d\n",
                   vdev_id, param_id, value);
        return ath10k_wmi_cmd_send(ar, skb,
@@ -3818,7 +3909,7 @@ int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
        if (!mac)
                return -EINVAL;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -3828,7 +3919,7 @@ int ath10k_wmi_set_ap_ps_param(struct ath10k *ar, u32 vdev_id, const u8 *mac,
        cmd->param_value = __cpu_to_le32(value);
        memcpy(&cmd->peer_macaddr, mac, ETH_ALEN);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
                   vdev_id, param_id, value, mac);
 
@@ -3848,7 +3939,7 @@ int ath10k_wmi_scan_chan_list(struct ath10k *ar,
 
        len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
 
-       skb = ath10k_wmi_alloc_skb(len);
+       skb = ath10k_wmi_alloc_skb(ar, len);
        if (!skb)
                return -EINVAL;
 
@@ -3990,7 +4081,7 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar,
                len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
        }
 
-       skb = ath10k_wmi_alloc_skb(len);
+       skb = ath10k_wmi_alloc_skb(ar, len);
        if (!skb)
                return -ENOMEM;
 
@@ -4003,7 +4094,7 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar,
                ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
        }
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi peer assoc vdev %d addr %pM (%s)\n",
                   arg->vdev_id, arg->addr,
                   arg->peer_reassoc ? "reassociate" : "new");
@@ -4021,7 +4112,7 @@ int ath10k_wmi_beacon_send_ref_nowait(struct ath10k_vif *arvif)
        int ret;
        u16 fc;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -4069,7 +4160,7 @@ int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
        struct wmi_pdev_set_wmm_params *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -4079,7 +4170,7 @@ int ath10k_wmi_pdev_set_wmm_params(struct ath10k *ar,
        ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
        ath10k_wmi_pdev_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
        return ath10k_wmi_cmd_send(ar, skb,
                                   ar->wmi.cmd->pdev_set_wmm_params_cmdid);
 }
@@ -4089,14 +4180,14 @@ int ath10k_wmi_request_stats(struct ath10k *ar, enum wmi_stats_id stats_id)
        struct wmi_request_stats_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
        cmd = (struct wmi_request_stats_cmd *)skb->data;
        cmd->stats_id = __cpu_to_le32(stats_id);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id);
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats %d\n", (int)stats_id);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->request_stats_cmdid);
 }
 
@@ -4106,7 +4197,7 @@ int ath10k_wmi_force_fw_hang(struct ath10k *ar,
        struct wmi_force_fw_hang_cmd *cmd;
        struct sk_buff *skb;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -4114,7 +4205,7 @@ int ath10k_wmi_force_fw_hang(struct ath10k *ar,
        cmd->type = __cpu_to_le32(type);
        cmd->delay_ms = __cpu_to_le32(delay_ms);
 
-       ath10k_dbg(ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
+       ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
                   type, delay_ms);
        return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
 }
@@ -4125,7 +4216,7 @@ int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable)
        struct sk_buff *skb;
        u32 cfg;
 
-       skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+       skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
        if (!skb)
                return -ENOMEM;
 
@@ -4146,7 +4237,7 @@ int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable)
        cmd->config_enable = __cpu_to_le32(cfg);
        cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
 
-       ath10k_dbg(ATH10K_DBG_WMI,
+       ath10k_dbg(ar, ATH10K_DBG_WMI,
                   "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
                   __le32_to_cpu(cmd->module_enable),
                   __le32_to_cpu(cmd->module_valid),