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,45 +7607,25 @@ int ath12k_mac_register(struct ath12k_base *ab) ...@@ -7607,45 +7607,25 @@ 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 ieee80211_hw *hw; struct ath12k_base *ab = ar->ab;
struct ath12k *ar; struct ath12k_pdev *pdev = ar->pdev;
struct ath12k_pdev *pdev; u8 pdev_idx = ar->pdev_idx;
int ret;
int i;
if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags))
return 0;
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;
}
ar = hw->priv; ar->lmac_id = ath12k_hw_get_mac_from_pdev_id(ab->hw_params, pdev_idx);
ar->hw = hw;
ar->ab = ab;
ar->pdev = pdev;
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]; ar->wmi = &ab->wmi_ab.wmi[pdev_idx];
/* FIXME: wmi[0] is already initialized during attach, /* FIXME: wmi[0] is already initialized during attach,
* Should we do this again? * Should we do this again?
*/ */
ath12k_wmi_pdev_attach(ab, i); ath12k_wmi_pdev_attach(ab, pdev_idx);
ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask; ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask;
ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask; ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask;
ar->num_tx_chains = hweight32(pdev->cap.tx_chain_mask); ar->num_tx_chains = hweight32(pdev->cap.tx_chain_mask);
ar->num_rx_chains = hweight32(pdev->cap.rx_chain_mask); ar->num_rx_chains = hweight32(pdev->cap.rx_chain_mask);
pdev->ar = ar;
spin_lock_init(&ar->data_lock); spin_lock_init(&ar->data_lock);
INIT_LIST_HEAD(&ar->arvifs); INIT_LIST_HEAD(&ar->arvifs);
INIT_LIST_HEAD(&ar->ppdu_stats_info); INIT_LIST_HEAD(&ar->ppdu_stats_info);
...@@ -7665,19 +7645,9 @@ int ath12k_mac_allocate(struct ath12k_base *ab) ...@@ -7665,19 +7645,9 @@ int ath12k_mac_allocate(struct ath12k_base *ab)
INIT_WORK(&ar->wmi_mgmt_tx_work, ath12k_mgmt_over_wmi_tx_work); INIT_WORK(&ar->wmi_mgmt_tx_work, ath12k_mgmt_over_wmi_tx_work);
skb_queue_head_init(&ar->wmi_mgmt_tx_queue); skb_queue_head_init(&ar->wmi_mgmt_tx_queue);
clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags);
}
ath12k_dp_pdev_pre_alloc(ab);
return 0;
err_free_mac:
ath12k_mac_destroy(ab);
return ret;
} }
void ath12k_mac_destroy(struct ath12k_base *ab) static void ath12k_mac_hw_destroy(struct ath12k_base *ab)
{ {
struct ath12k *ar; struct ath12k *ar;
struct ath12k_pdev *pdev; struct ath12k_pdev *pdev;
...@@ -7693,3 +7663,59 @@ void ath12k_mac_destroy(struct ath12k_base *ab) ...@@ -7693,3 +7663,59 @@ void ath12k_mac_destroy(struct ath12k_base *ab)
pdev->ar = NULL; pdev->ar = NULL;
} }
} }
static int ath12k_mac_hw_allocate(struct ath12k_base *ab)
{
struct ieee80211_hw *hw;
struct ath12k *ar;
struct ath12k_pdev *pdev;
int ret;
int i;
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;
}
ar = hw->priv;
ar->hw = hw;
ar->ab = ab;
ar->pdev = pdev;
ar->pdev_idx = i;
pdev->ar = ar;
ath12k_mac_setup(ar);
}
return 0;
err_free_mac:
ath12k_mac_hw_destroy(ab);
return ret;
}
void ath12k_mac_destroy(struct ath12k_base *ab)
{
ath12k_mac_hw_destroy(ab);
}
int ath12k_mac_allocate(struct ath12k_base *ab)
{
int ret;
if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags))
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