Commit 8a742a79 authored by Karthikeyan Periyasamy's avatar Karthikeyan Periyasamy Committed by Kalle Valo

wifi: ath12k: refactor ath12k_mac_allocate() and ath12k_mac_destroy()

Currently, the MAC allocation and destroy helper functions are tightly
coupled with the link/radio (ar) structure. In the future, to support
single/Multi link operations, need to refactor these helper functions
across the core and mac sub modules, so that it can be easy to scale
these functions to support single/Multi link operations.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Signed-off-by: default avatarKarthikeyan Periyasamy <quic_periyasa@quicinc.com>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20231206034920.1037449-3-quic_periyasa@quicinc.com
parent eaf9f17b
...@@ -7607,7 +7607,64 @@ int ath12k_mac_register(struct ath12k_base *ab) ...@@ -7607,7 +7607,64 @@ int ath12k_mac_register(struct ath12k_base *ab)
return ret; return ret;
} }
int ath12k_mac_allocate(struct ath12k_base *ab) static void ath12k_mac_setup(struct ath12k *ar)
{
struct ath12k_base *ab = ar->ab;
struct ath12k_pdev *pdev = ar->pdev;
u8 pdev_idx = ar->pdev_idx;
ar->lmac_id = ath12k_hw_get_mac_from_pdev_id(ab->hw_params, pdev_idx);
ar->wmi = &ab->wmi_ab.wmi[pdev_idx];
/* FIXME: wmi[0] is already initialized during attach,
* Should we do this again?
*/
ath12k_wmi_pdev_attach(ab, pdev_idx);
ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask;
ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask;
ar->num_tx_chains = hweight32(pdev->cap.tx_chain_mask);
ar->num_rx_chains = hweight32(pdev->cap.rx_chain_mask);
spin_lock_init(&ar->data_lock);
INIT_LIST_HEAD(&ar->arvifs);
INIT_LIST_HEAD(&ar->ppdu_stats_info);
mutex_init(&ar->conf_mutex);
init_completion(&ar->vdev_setup_done);
init_completion(&ar->vdev_delete_done);
init_completion(&ar->peer_assoc_done);
init_completion(&ar->peer_delete_done);
init_completion(&ar->install_key_done);
init_completion(&ar->bss_survey_done);
init_completion(&ar->scan.started);
init_completion(&ar->scan.completed);
INIT_DELAYED_WORK(&ar->scan.timeout, ath12k_scan_timeout_work);
INIT_WORK(&ar->regd_update_work, ath12k_regd_update_work);
INIT_WORK(&ar->wmi_mgmt_tx_work, ath12k_mgmt_over_wmi_tx_work);
skb_queue_head_init(&ar->wmi_mgmt_tx_queue);
clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags);
}
static void ath12k_mac_hw_destroy(struct ath12k_base *ab)
{
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(ar->hw);
pdev->ar = NULL;
}
}
static int ath12k_mac_hw_allocate(struct ath12k_base *ab)
{ {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct ath12k *ar; struct ath12k *ar;
...@@ -7615,9 +7672,6 @@ int ath12k_mac_allocate(struct ath12k_base *ab) ...@@ -7615,9 +7672,6 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
int ret; int ret;
int i; int i;
if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags))
return 0;
for (i = 0; i < ab->num_radios; i++) { for (i = 0; i < ab->num_radios; i++) {
pdev = &ab->pdevs[i]; pdev = &ab->pdevs[i];
hw = ieee80211_alloc_hw(sizeof(struct ath12k), &ath12k_ops); hw = ieee80211_alloc_hw(sizeof(struct ath12k), &ath12k_ops);
...@@ -7632,64 +7686,36 @@ int ath12k_mac_allocate(struct ath12k_base *ab) ...@@ -7632,64 +7686,36 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
ar->ab = ab; ar->ab = ab;
ar->pdev = pdev; ar->pdev = pdev;
ar->pdev_idx = i; ar->pdev_idx = i;
ar->lmac_id = ath12k_hw_get_mac_from_pdev_id(ab->hw_params, i);
ar->wmi = &ab->wmi_ab.wmi[i];
/* FIXME: wmi[0] is already initialized during attach,
* Should we do this again?
*/
ath12k_wmi_pdev_attach(ab, i);
ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask;
ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask;
ar->num_tx_chains = hweight32(pdev->cap.tx_chain_mask);
ar->num_rx_chains = hweight32(pdev->cap.rx_chain_mask);
pdev->ar = ar; pdev->ar = ar;
spin_lock_init(&ar->data_lock);
INIT_LIST_HEAD(&ar->arvifs);
INIT_LIST_HEAD(&ar->ppdu_stats_info);
mutex_init(&ar->conf_mutex);
init_completion(&ar->vdev_setup_done);
init_completion(&ar->vdev_delete_done);
init_completion(&ar->peer_assoc_done);
init_completion(&ar->peer_delete_done);
init_completion(&ar->install_key_done);
init_completion(&ar->bss_survey_done);
init_completion(&ar->scan.started);
init_completion(&ar->scan.completed);
INIT_DELAYED_WORK(&ar->scan.timeout, ath12k_scan_timeout_work);
INIT_WORK(&ar->regd_update_work, ath12k_regd_update_work);
INIT_WORK(&ar->wmi_mgmt_tx_work, ath12k_mgmt_over_wmi_tx_work);
skb_queue_head_init(&ar->wmi_mgmt_tx_queue);
clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags);
}
ath12k_dp_pdev_pre_alloc(ab); ath12k_mac_setup(ar);
}
return 0; return 0;
err_free_mac: err_free_mac:
ath12k_mac_destroy(ab); ath12k_mac_hw_destroy(ab);
return ret; return ret;
} }
void ath12k_mac_destroy(struct ath12k_base *ab) void ath12k_mac_destroy(struct ath12k_base *ab)
{ {
struct ath12k *ar; ath12k_mac_hw_destroy(ab);
struct ath12k_pdev *pdev; }
int i;
for (i = 0; i < ab->num_radios; i++) { int ath12k_mac_allocate(struct ath12k_base *ab)
pdev = &ab->pdevs[i]; {
ar = pdev->ar; int ret;
if (!ar)
continue;
ieee80211_free_hw(ar->hw); if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags))
pdev->ar = NULL; return 0;
}
ret = ath12k_mac_hw_allocate(ab);
if (ret)
return ret;
ath12k_dp_pdev_pre_alloc(ab);
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment