wifi: ath12k: relocate a few functions in mac.c

An upcoming change will invoke ath12k_mac_init_arvif(),
ath12k_mac_assign_link_vif(), ath12k_mac_unassign_link_vif(), and
ath12k_mac_remove_link_interface() from a line located above their current
definition. Hence, relocate these functions to above so that these can be
invoked later on.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00130-QCAHKSWPL_SILICONZ-1.97421.5 # Nicolas Escande

Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Tested-by: Nicolas Escande <nico.escande@gmail.com>
Link: https://patch.msgid.link/20250204-unlink_link_arvif_from_chanctx-v2-6-764fb5973c1a@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
This commit is contained in:
Aditya Kumar Singh 2025-02-04 22:35:12 +05:30 committed by Jeff Johnson
parent 00e4dc1169
commit b81c39d67f

View File

@ -3470,6 +3470,131 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,
ath12k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret);
}
static void ath12k_mac_init_arvif(struct ath12k_vif *ahvif,
struct ath12k_link_vif *arvif, int link_id)
{
struct ath12k_hw *ah = ahvif->ah;
u8 _link_id;
int i;
lockdep_assert_wiphy(ah->hw->wiphy);
if (WARN_ON(!arvif))
return;
if (WARN_ON(link_id >= ATH12K_NUM_MAX_LINKS))
return;
if (link_id < 0)
_link_id = 0;
else
_link_id = link_id;
arvif->ahvif = ahvif;
arvif->link_id = _link_id;
INIT_LIST_HEAD(&arvif->list);
INIT_DELAYED_WORK(&arvif->connection_loss_work,
ath12k_mac_vif_sta_connection_loss_work);
for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
arvif->bitrate_mask.control[i].legacy = 0xffffffff;
memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
sizeof(arvif->bitrate_mask.control[i].ht_mcs));
memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
sizeof(arvif->bitrate_mask.control[i].vht_mcs));
}
/* Handle MLO related assignments */
if (link_id >= 0) {
rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
ahvif->links_map |= BIT(_link_id);
}
ath12k_generic_dbg(ATH12K_DBG_MAC,
"mac init link arvif (link_id %d%s) for vif %pM. links_map 0x%x",
_link_id, (link_id < 0) ? " deflink" : "", ahvif->vif->addr,
ahvif->links_map);
}
static void ath12k_mac_remove_link_interface(struct ieee80211_hw *hw,
struct ath12k_link_vif *arvif)
{
struct ath12k_vif *ahvif = arvif->ahvif;
struct ath12k_hw *ah = hw->priv;
struct ath12k *ar = arvif->ar;
int ret;
lockdep_assert_wiphy(ah->hw->wiphy);
cancel_delayed_work_sync(&arvif->connection_loss_work);
ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac remove link interface (vdev %d link id %d)",
arvif->vdev_id, arvif->link_id);
if (ahvif->vdev_type == WMI_VDEV_TYPE_AP) {
ret = ath12k_peer_delete(ar, arvif->vdev_id, arvif->bssid);
if (ret)
ath12k_warn(ar->ab, "failed to submit AP self-peer removal on vdev %d link id %d: %d",
arvif->vdev_id, arvif->link_id, ret);
}
ath12k_mac_vdev_delete(ar, arvif);
}
static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
struct ieee80211_vif *vif,
u8 link_id)
{
struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
struct ath12k_link_vif *arvif;
lockdep_assert_wiphy(ah->hw->wiphy);
arvif = wiphy_dereference(ah->hw->wiphy, ahvif->link[link_id]);
if (arvif)
return arvif;
if (!vif->valid_links) {
/* Use deflink for Non-ML VIFs and mark the link id as 0
*/
link_id = 0;
arvif = &ahvif->deflink;
} else {
/* If this is the first link arvif being created for an ML VIF
* use the preallocated deflink memory except for scan arvifs
*/
if (!ahvif->links_map && link_id != ATH12K_DEFAULT_SCAN_LINK) {
arvif = &ahvif->deflink;
} else {
arvif = (struct ath12k_link_vif *)
kzalloc(sizeof(struct ath12k_link_vif), GFP_KERNEL);
if (!arvif)
return NULL;
}
}
ath12k_mac_init_arvif(ahvif, arvif, link_id);
return arvif;
}
static void ath12k_mac_unassign_link_vif(struct ath12k_link_vif *arvif)
{
struct ath12k_vif *ahvif = arvif->ahvif;
struct ath12k_hw *ah = ahvif->ah;
lockdep_assert_wiphy(ah->hw->wiphy);
rcu_assign_pointer(ahvif->link[arvif->link_id], NULL);
synchronize_rcu();
ahvif->links_map &= ~BIT(arvif->link_id);
if (arvif != &ahvif->deflink)
kfree(arvif);
else
memset(arvif, 0, sizeof(*arvif));
}
static int
ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
@ -3974,131 +4099,6 @@ static void ath12k_mac_op_link_info_changed(struct ieee80211_hw *hw,
ath12k_mac_bss_info_changed(ar, arvif, info, changed);
}
static void ath12k_mac_init_arvif(struct ath12k_vif *ahvif,
struct ath12k_link_vif *arvif, int link_id)
{
struct ath12k_hw *ah = ahvif->ah;
u8 _link_id;
int i;
lockdep_assert_wiphy(ah->hw->wiphy);
if (WARN_ON(!arvif))
return;
if (WARN_ON(link_id >= ATH12K_NUM_MAX_LINKS))
return;
if (link_id < 0)
_link_id = 0;
else
_link_id = link_id;
arvif->ahvif = ahvif;
arvif->link_id = _link_id;
INIT_LIST_HEAD(&arvif->list);
INIT_DELAYED_WORK(&arvif->connection_loss_work,
ath12k_mac_vif_sta_connection_loss_work);
for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
arvif->bitrate_mask.control[i].legacy = 0xffffffff;
memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
sizeof(arvif->bitrate_mask.control[i].ht_mcs));
memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
sizeof(arvif->bitrate_mask.control[i].vht_mcs));
}
/* Handle MLO related assignments */
if (link_id >= 0) {
rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
ahvif->links_map |= BIT(_link_id);
}
ath12k_generic_dbg(ATH12K_DBG_MAC,
"mac init link arvif (link_id %d%s) for vif %pM. links_map 0x%x",
_link_id, (link_id < 0) ? " deflink" : "", ahvif->vif->addr,
ahvif->links_map);
}
static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
struct ieee80211_vif *vif,
u8 link_id)
{
struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
struct ath12k_link_vif *arvif;
lockdep_assert_wiphy(ah->hw->wiphy);
arvif = wiphy_dereference(ah->hw->wiphy, ahvif->link[link_id]);
if (arvif)
return arvif;
if (!vif->valid_links) {
/* Use deflink for Non-ML VIFs and mark the link id as 0
*/
link_id = 0;
arvif = &ahvif->deflink;
} else {
/* If this is the first link arvif being created for an ML VIF
* use the preallocated deflink memory except for scan arvifs
*/
if (!ahvif->links_map && link_id != ATH12K_DEFAULT_SCAN_LINK) {
arvif = &ahvif->deflink;
} else {
arvif = (struct ath12k_link_vif *)
kzalloc(sizeof(struct ath12k_link_vif), GFP_KERNEL);
if (!arvif)
return NULL;
}
}
ath12k_mac_init_arvif(ahvif, arvif, link_id);
return arvif;
}
static void ath12k_mac_unassign_link_vif(struct ath12k_link_vif *arvif)
{
struct ath12k_vif *ahvif = arvif->ahvif;
struct ath12k_hw *ah = ahvif->ah;
lockdep_assert_wiphy(ah->hw->wiphy);
rcu_assign_pointer(ahvif->link[arvif->link_id], NULL);
synchronize_rcu();
ahvif->links_map &= ~BIT(arvif->link_id);
if (arvif != &ahvif->deflink)
kfree(arvif);
else
memset(arvif, 0, sizeof(*arvif));
}
static void ath12k_mac_remove_link_interface(struct ieee80211_hw *hw,
struct ath12k_link_vif *arvif)
{
struct ath12k_vif *ahvif = arvif->ahvif;
struct ath12k_hw *ah = hw->priv;
struct ath12k *ar = arvif->ar;
int ret;
lockdep_assert_wiphy(ah->hw->wiphy);
cancel_delayed_work_sync(&arvif->connection_loss_work);
ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac remove link interface (vdev %d link id %d)",
arvif->vdev_id, arvif->link_id);
if (ahvif->vdev_type == WMI_VDEV_TYPE_AP) {
ret = ath12k_peer_delete(ar, arvif->vdev_id, arvif->bssid);
if (ret)
ath12k_warn(ar->ab, "failed to submit AP self-peer removal on vdev %d link id %d: %d",
arvif->vdev_id, arvif->link_id, ret);
}
ath12k_mac_vdev_delete(ar, arvif);
}
static struct ath12k*
ath12k_mac_select_scan_device(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,