static int ath12k_mac_op_config(struct ieee80211_hw *hw, u32 changed)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        int ret;
 
+       ar = ath12k_ah_to_ar(ah);
+
        ret = ath12k_mac_config(ar, changed);
        if (ret)
                ath12k_warn(ar->ab, "failed to update config pdev idx %d: %d\n",
                                           struct ieee80211_bss_conf *info,
                                           u64 changed)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
 
        ath12k_mac_bss_info_changed(ar, arvif, info, changed);
                                 struct ieee80211_vif *vif,
                                 struct ieee80211_scan_request *hw_req)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        struct cfg80211_scan_request *req = &hw_req->req;
        struct ath12k_wmi_scan_req_arg arg = {};
        int ret;
        int i;
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
 
        spin_lock_bh(&ar->data_lock);
                kfree(arg.extraie.ptr);
 
        mutex_unlock(&ar->conf_mutex);
+
        return ret;
 }
 
 static void ath12k_mac_op_cancel_hw_scan(struct ieee80211_hw *hw,
                                         struct ieee80211_vif *vif)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+
+       ar = ath12k_ah_to_ar(ah);
 
        mutex_lock(&ar->conf_mutex);
        ath12k_scan_abort(ar);
                                 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
                                 struct ieee80211_key_conf *key)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        struct ath12k_peer *peer;
        struct ath12k_sta *arsta;
            key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256)
                return 1;
 
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
+
        if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags))
                return 1;
 
                                   enum ieee80211_sta_state old_state,
                                   enum ieee80211_sta_state new_state)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
        struct ath12k_peer *peer;
             new_state == IEEE80211_STA_NOTEXIST))
                cancel_work_sync(&arsta->update_wk);
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
 
        if (old_state == IEEE80211_STA_NOTEXIST &&
        }
 
        mutex_unlock(&ar->conf_mutex);
+
        return ret;
 }
 
                                       struct ieee80211_vif *vif,
                                       struct ieee80211_sta *sta)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        int ret;
        s16 txpwr;
        if (txpwr > ATH12K_TX_POWER_MAX_VAL || txpwr < ATH12K_TX_POWER_MIN_VAL)
                return -EINVAL;
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
 
        ret = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id,
                                        struct ieee80211_sta *sta,
                                        u32 changed)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        struct ath12k_peer *peer;
        u32 bw, smps;
 
+       ar = ath12k_ah_to_ar(ah);
+
        spin_lock_bh(&ar->ab->base_lock);
 
        peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr);
                                 unsigned int link_id, u16 ac,
                                 const struct ieee80211_tx_queue_params *params)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        int ret;
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
        ret = ath12k_mac_conf_tx(arvif, link_id, ac, params);
        mutex_unlock(&ar->conf_mutex);
                             struct sk_buff *skb)
 {
        struct ath12k_skb_cb *skb_cb = ATH12K_SKB_CB(skb);
-       struct ath12k *ar = hw->priv;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_vif *vif = info->control.vif;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
+       struct ath12k *ar = arvif->ar;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
        struct ieee80211_key_conf *key = info->control.hw_key;
        u32 info_flags = info->flags;
 
 static int ath12k_mac_op_start(struct ieee80211_hw *hw)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
        struct ath12k_base *ab = ar->ab;
        int ret;
 
 
 static void ath12k_mac_op_stop(struct ieee80211_hw *hw)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
 
        ath12k_mac_drain_tx(ar);
 
 static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
                                       struct ieee80211_vif *vif)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        struct ath12k_wmi_vdev_create_arg vdev_arg = {0};
        struct ath12k_wmi_peer_create_arg peer_param;
 
        vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD;
 
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
+
        mutex_lock(&ar->conf_mutex);
 
        if (vif->type == NL80211_IFTYPE_AP &&
 static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
                                           struct ieee80211_vif *vif)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_base *ab;
        unsigned long time_left;
        int ret;
 
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
+
        mutex_lock(&ar->conf_mutex);
 
        ath12k_dbg(ab, ATH12K_DBG_MAC, "mac remove interface (vdev %d)\n",
                                           unsigned int *total_flags,
                                           u64 multicast)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+
+       ar = ath12k_ah_to_ar(ah);
 
        mutex_lock(&ar->conf_mutex);
 
 
 static int ath12k_mac_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+
+       ar = ath12k_ah_to_ar(ah);
 
        mutex_lock(&ar->conf_mutex);
 
 
 static int ath12k_mac_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        int ret;
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
        ret = __ath12k_set_antenna(ar, tx_ant, rx_ant);
        mutex_unlock(&ar->conf_mutex);
                                      struct ieee80211_vif *vif,
                                      struct ieee80211_ampdu_params *params)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        int ret = -EINVAL;
 
+       ar = ath12k_ah_to_ar(ah);
+
        mutex_lock(&ar->conf_mutex);
        ret = ath12k_mac_ampdu_action(arvif, params);
        mutex_unlock(&ar->conf_mutex);
 static int ath12k_mac_op_add_chanctx(struct ieee80211_hw *hw,
                                     struct ieee80211_chanctx_conf *ctx)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
+
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
 
        ath12k_dbg(ab, ATH12K_DBG_MAC,
                   "mac chanctx add freq %u width %d ptr %pK\n",
 static void ath12k_mac_op_remove_chanctx(struct ieee80211_hw *hw,
                                         struct ieee80211_chanctx_conf *ctx)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
+
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
 
        ath12k_dbg(ab, ATH12K_DBG_MAC,
                   "mac chanctx remove freq %u width %d ptr %pK\n",
                                         struct ieee80211_chanctx_conf *ctx,
                                         u32 changed)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
+
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
 
        mutex_lock(&ar->conf_mutex);
 
                                 struct ieee80211_bss_conf *link_conf,
                                 struct ieee80211_chanctx_conf *ctx)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        int ret;
        struct ath12k_wmi_peer_create_arg param;
 
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
+
        mutex_lock(&ar->conf_mutex);
 
        ath12k_dbg(ab, ATH12K_DBG_MAC,
                                   struct ieee80211_bss_conf *link_conf,
                                   struct ieee80211_chanctx_conf *ctx)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
        struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
        int ret;
 
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
+
        mutex_lock(&ar->conf_mutex);
 
        ath12k_dbg(ab, ATH12K_DBG_MAC,
                                 int n_vifs,
                                 enum ieee80211_chanctx_switch_mode mode)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+
+       ar = ath12k_ah_to_ar(ah);
 
        mutex_lock(&ar->conf_mutex);
 
  */
 static int ath12k_mac_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
 {
-       struct ath12k *ar = hw->priv;
-       int param_id = WMI_VDEV_PARAM_RTS_THRESHOLD;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       int param_id = WMI_VDEV_PARAM_RTS_THRESHOLD, ret;
 
-       return ath12k_set_vdev_param_to_all_vifs(ar, param_id, value);
+       ar = ath12k_ah_to_ar(ah);
+
+       ret = ath12k_set_vdev_param_to_all_vifs(ar, param_id, value);
+
+       return ret;
 }
 
 static int ath12k_mac_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
 static void ath12k_mac_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                                u32 queues, bool drop)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
 
        if (drop)
                return;
        ldpc = !!(ar->ht_cap_info & WMI_HT_CAP_LDPC);
 
        sgi = mask->control[band].gi;
-       if (sgi == NL80211_TXRATE_FORCE_LGI)
-               return -EINVAL;
+       if (sgi == NL80211_TXRATE_FORCE_LGI) {
+               ret = -EINVAL;
+               goto out;
+       }
 
        /* mac80211 doesn't support sending a fixed HT/VHT MCS alone, rather it
         * requires passing at least one of used basic rates along with them.
                if (ret) {
                        ath12k_warn(ar->ab, "failed to get single legacy rate for vdev %i: %d\n",
                                    arvif->vdev_id, ret);
-                       return ret;
+                       goto out;
                }
                ieee80211_iterate_stations_atomic(hw,
                                                  ath12k_mac_disable_peer_fixed_rate,
                         */
                        ath12k_warn(ar->ab,
                                    "Setting more than one MCS Value in bitrate mask not supported\n");
-                       return -EINVAL;
+                       ret = -EINVAL;
+                       goto out;
                }
 
                ieee80211_iterate_stations_atomic(hw,
 
        mutex_unlock(&ar->conf_mutex);
 
+out:
        return ret;
 }
 
 ath12k_mac_op_reconfig_complete(struct ieee80211_hw *hw,
                                enum ieee80211_reconfig_type reconfig_type)
 {
-       struct ath12k *ar = hw->priv;
-       struct ath12k_base *ab = ar->ab;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
+       struct ath12k_base *ab;
        struct ath12k_vif *arvif;
        int recovery_count;
 
        if (reconfig_type != IEEE80211_RECONFIG_TYPE_RESTART)
                return;
 
+       ar = ath12k_ah_to_ar(ah);
+       ab = ar->ab;
+
        mutex_lock(&ar->conf_mutex);
 
        if (ar->state == ATH12K_STATE_RESTARTED) {
 static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,
                                    struct survey_info *survey)
 {
-       struct ath12k *ar = hw->priv;
+       struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+       struct ath12k *ar;
        struct ieee80211_supported_band *sband;
        struct survey_info *ar_survey;
        int ret = 0;
        if (idx >= ATH12K_NUM_CHANS)
                return -ENOENT;
 
+       ar = ath12k_ah_to_ar(ah);
+
        ar_survey = &ar->survey[idx];
 
        mutex_lock(&ar->conf_mutex);
 
 exit:
        mutex_unlock(&ar->conf_mutex);
+
        return ret;
 }
 
        return 0;
 }
 
-static int ath12k_mac_setup_iface_combinations(struct ath12k *ar)
+static u16 ath12k_mac_get_ifmodes(struct ath12k_hw *ah)
 {
-       struct ath12k_base *ab = ar->ab;
-       struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
-       struct wiphy *wiphy = hw->wiphy;
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
+       u16 interface_modes = U16_MAX;
+
+       interface_modes &= ar->ab->hw_params->interface_modes;
+
+       return interface_modes == U16_MAX ? 0 : interface_modes;
+}
+
+static bool ath12k_mac_is_iface_mode_enable(struct ath12k_hw *ah,
+                                           enum nl80211_iftype type)
+{
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
+       u16 interface_modes, mode;
+       bool is_enable = true;
+
+       mode = BIT(type);
+
+       interface_modes = ar->ab->hw_params->interface_modes;
+       if (!(interface_modes & mode))
+               is_enable = false;
+
+       return is_enable;
+}
+
+static int ath12k_mac_setup_iface_combinations(struct ath12k_hw *ah)
+{
+       struct wiphy *wiphy = ah->hw->wiphy;
        struct ieee80211_iface_combination *combinations;
        struct ieee80211_iface_limit *limits;
        int n_limits, max_interfaces;
        bool ap, mesh;
 
-       ap = ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_AP);
+       ap = ath12k_mac_is_iface_mode_enable(ah, NL80211_IFTYPE_AP);
 
        mesh = IS_ENABLED(CONFIG_MAC80211_MESH) &&
-               ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_MESH_POINT);
+               ath12k_mac_is_iface_mode_enable(ah, NL80211_IFTYPE_MESH_POINT);
 
        combinations = kzalloc(sizeof(*combinations), GFP_KERNEL);
        if (!combinations)
        kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels);
 }
 
-static void ath12k_mac_hw_unregister(struct ath12k *ar)
+static void ath12k_mac_hw_unregister(struct ath12k_hw *ah)
 {
-       struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
+       struct ieee80211_hw *hw = ah->hw;
        struct wiphy *wiphy = hw->wiphy;
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
 
        cancel_work_sync(&ar->regd_update_work);
 
        return 0;
 }
 
-static int ath12k_mac_hw_register(struct ath12k *ar)
+static int ath12k_mac_hw_register(struct ath12k_hw *ah)
 {
-       struct ath12k_base *ab = ar->ab;
-       struct ieee80211_hw *hw = ath12k_ar_to_hw(ar);
+       struct ieee80211_hw *hw = ah->hw;
        struct wiphy *wiphy = hw->wiphy;
-       struct ath12k_pdev *pdev = ar->pdev;
-       struct ath12k_pdev_cap *cap = &pdev->cap;
+       struct ath12k *ar = ath12k_ah_to_ar(ah);
+       struct ath12k_base *ab = ar->ab;
+       struct ath12k_pdev *pdev;
+       struct ath12k_pdev_cap *cap;
        static const u32 cipher_suites[] = {
                WLAN_CIPHER_SUITE_TKIP,
                WLAN_CIPHER_SUITE_CCMP,
        int ret;
        u32 ht_cap = 0;
 
-       if (ab->pdevs_macaddr_valid) {
+       pdev = ar->pdev;
+
+       if (ab->pdevs_macaddr_valid)
                ether_addr_copy(ar->mac_addr, pdev->mac_addr);
-       } else {
+       else
                ether_addr_copy(ar->mac_addr, ab->mac_addr);
-               ar->mac_addr[4] += ar->pdev_idx;
-       }
 
        ret = ath12k_mac_setup_register(ar, &ht_cap, hw->wiphy->bands);
        if (ret)
                goto out;
 
+       wiphy->max_ap_assoc_sta = ar->max_num_stations;
+
+       cap = &pdev->cap;
+
+       wiphy->available_antennas_rx = cap->rx_chain_mask;
+       wiphy->available_antennas_tx = cap->tx_chain_mask;
+
        SET_IEEE80211_PERM_ADDR(hw, ar->mac_addr);
        SET_IEEE80211_DEV(hw, ab->dev);
 
-       ret = ath12k_mac_setup_iface_combinations(ar);
+       ret = ath12k_mac_setup_iface_combinations(ah);
        if (ret) {
-               ath12k_err(ar->ab, "failed to setup interface combinations: %d\n", ret);
-               goto err_setup_unregister;
+               ath12k_err(ab, "failed to setup interface combinations: %d\n", ret);
+               goto err_cleanup_unregister;
        }
 
-       wiphy->available_antennas_rx = cap->rx_chain_mask;
-       wiphy->available_antennas_tx = cap->tx_chain_mask;
-
-       wiphy->interface_modes = ab->hw_params->interface_modes;
+       wiphy->interface_modes = ath12k_mac_get_ifmodes(ah);
 
        if (wiphy->bands[NL80211_BAND_2GHZ] &&
            wiphy->bands[NL80211_BAND_5GHZ] &&
        wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |
                                   NL80211_FEATURE_AP_SCAN;
 
-       wiphy->max_ap_assoc_sta = ar->max_num_stations;
-
        hw->queues = ATH12K_HW_MAX_QUEUES;
        wiphy->tx_queue_len = ATH12K_QUEUE_LEN;
        hw->offchannel_tx_hw_queue = ATH12K_HW_MAX_QUEUES - 1;
 
        ret = ieee80211_register_hw(hw);
        if (ret) {
-               ath12k_err(ar->ab, "ieee80211 registration failed: %d\n", ret);
+               ath12k_err(ab, "ieee80211 registration failed: %d\n", ret);
                goto err_free_if_combs;
        }
 
        kfree(wiphy->iface_combinations[0].limits);
        kfree(wiphy->iface_combinations);
 
-err_setup_unregister:
-       kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels);
-       kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels);
-       kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels);
+err_cleanup_unregister:
+       ath12k_mac_cleanup_unregister(ar);
 
+out:
        SET_IEEE80211_DEV(hw, NULL);
 
-out:
        return ret;
 }
 
 
 int ath12k_mac_register(struct ath12k_base *ab)
 {
-       struct ath12k *ar;
-       struct ath12k_pdev *pdev;
+       struct ath12k_hw *ah;
        int i;
        int ret;
 
        ab->cc_freq_hz = 320000;
        ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1;
 
-       for (i = 0; i < ab->num_radios; i++) {
-               pdev = &ab->pdevs[i];
-               ar = pdev->ar;
+       for (i = 0; i < ab->num_hw; i++) {
+               ah = ab->ah[i];
 
-               ret = ath12k_mac_hw_register(ar);
+               ret = ath12k_mac_hw_register(ah);
                if (ret)
-                       goto err_cleanup;
+                       goto err;
        }
 
        return 0;
 
-err_cleanup:
+err:
        for (i = i - 1; i >= 0; i--) {
-               pdev = &ab->pdevs[i];
-               ar = pdev->ar;
-               ath12k_mac_hw_unregister(ar);
+               ah = ab->ah[i];
+               if (!ah)
+                       continue;
+
+               ath12k_mac_hw_unregister(ah);
        }
 
        return ret;
 
 void ath12k_mac_unregister(struct ath12k_base *ab)
 {
-       struct ath12k *ar;
-       struct ath12k_pdev *pdev;
+       struct ath12k_hw *ah;
        int i;
 
-       for (i = 0; i < ab->num_radios; i++) {
-               pdev = &ab->pdevs[i];
-               ar = pdev->ar;
-               if (!ar)
+       for (i = ab->num_hw - 1; i >= 0; i--) {
+               ah = ab->ah[i];
+               if (!ah)
                        continue;
 
-               ath12k_mac_hw_unregister(ar);
+               ath12k_mac_hw_unregister(ah);
        }
 }
 
-static void ath12k_mac_hw_destroy(struct ath12k_base *ab)
+static void ath12k_mac_hw_destroy(struct ath12k_hw *ah)
 {
-       struct ath12k *ar;
-       struct ath12k_pdev *pdev;
-       int i;
-
-       for (i = 0; i < ab->num_radios; i++) {
-               pdev = &ab->pdevs[i];
-               ar = pdev->ar;
-               if (!ar)
-                       continue;
-
-               ieee80211_free_hw(ath12k_ar_to_hw(ar));
-               pdev->ar = NULL;
-       }
+       ieee80211_free_hw(ah->hw);
 }
 
-static int ath12k_mac_hw_allocate(struct ath12k_base *ab)
+static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab,
+                                               struct ath12k_pdev_map *pdev_map,
+                                               u8 num_pdev_map)
 {
        struct ieee80211_hw *hw;
        struct ath12k *ar;
        struct ath12k_pdev *pdev;
-       int ret;
+       struct ath12k_hw *ah;
        int i;
+       u8 pdev_idx;
 
-       for (i = 0; i < ab->num_radios; i++) {
-               pdev = &ab->pdevs[i];
-               hw = ieee80211_alloc_hw(sizeof(struct ath12k), &ath12k_ops);
-               if (!hw) {
-                       ath12k_warn(ab, "failed to allocate mac80211 hw device\n");
-                       ret = -ENOMEM;
-                       goto err_free_mac;
-               }
+       hw = ieee80211_alloc_hw(struct_size(ah, radio, num_pdev_map),
+                               &ath12k_ops);
+       if (!hw)
+               return NULL;
+
+       ah = ath12k_hw_to_ah(hw);
+       ah->hw = hw;
+       ah->num_radio = num_pdev_map;
+
+       for (i = 0; i < num_pdev_map; i++) {
+               ab = pdev_map[i].ab;
+               pdev_idx = pdev_map[i].pdev_idx;
+               pdev = &ab->pdevs[pdev_idx];
 
-               ar = hw->priv;
-               ar->hw = hw;
+               ar = ath12k_ah_to_ar(ah);
+               ar->ah = ah;
                ar->ab = ab;
+               ar->hw_link_id = i;
                ar->pdev = pdev;
-               ar->pdev_idx = i;
+               ar->pdev_idx = pdev_idx;
                pdev->ar = ar;
 
                ath12k_mac_setup(ar);
        }
 
-       return 0;
-
-err_free_mac:
-       ath12k_mac_hw_destroy(ab);
-
-       return ret;
+       return ah;
 }
 
 void ath12k_mac_destroy(struct ath12k_base *ab)
 {
-       ath12k_mac_hw_destroy(ab);
+       struct ath12k_pdev *pdev;
+       int i;
+
+       for (i = 0; i < ab->num_radios; i++) {
+               pdev = &ab->pdevs[i];
+               if (!pdev->ar)
+                       continue;
+
+               pdev->ar = NULL;
+       }
+
+       for (i = 0; i < ab->num_hw; i++) {
+               if (!ab->ah[i])
+                       continue;
+
+               ath12k_mac_hw_destroy(ab->ah[i]);
+               ab->ah[i] = NULL;
+       }
 }
 
 int ath12k_mac_allocate(struct ath12k_base *ab)
 {
-       int ret;
+       struct ath12k_hw *ah;
+       struct ath12k_pdev_map pdev_map[MAX_RADIOS];
+       int ret, i, j;
+       u8 radio_per_hw;
 
        if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags))
                return 0;
 
-       ret = ath12k_mac_hw_allocate(ab);
-       if (ret)
-               return ret;
+       ab->num_hw = ab->num_radios;
+       radio_per_hw = 1;
+
+       for (i = 0; i < ab->num_hw; i++) {
+               for (j = 0; j < radio_per_hw; j++) {
+                       pdev_map[j].ab = ab;
+                       pdev_map[j].pdev_idx = (i * radio_per_hw) + j;
+               }
+
+               ah = ath12k_mac_hw_allocate(ab, pdev_map, radio_per_hw);
+               if (!ah) {
+                       ath12k_warn(ab, "failed to allocate mac80211 hw device for hw_idx %d\n",
+                                   i);
+                       goto err;
+               }
+
+               ab->ah[i] = ah;
+       }
 
        ath12k_dp_pdev_pre_alloc(ab);
 
        return 0;
+
+err:
+       for (i = i - 1; i >= 0; i--) {
+               if (!ab->ah[i])
+                       continue;
+
+               ath12k_mac_hw_destroy(ab->ah[i]);
+               ab->ah[i] = NULL;
+       }
+
+       return ret;
 }