Skip to content

Commit 3cbbdfb

Browse files
Ritesh SinghKalle Valo
authored andcommitted
ath11k: vdev delete synchronization with firmware
When the interface is added immediately after removing the interface, vdev deletion in firmware might not have been completed. Hence, add vdev_delete_resp_event and wait_event_timeout to synchronize with firmware. Signed-off-by: Ritesh Singh <ritesi@codeaurora.org> Signed-off-by: Maharaja Kennadyrajan <mkenna@codeaurora.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/1605514143-17652-2-git-send-email-mkenna@codeaurora.org
1 parent 526740b commit 3cbbdfb

5 files changed

Lines changed: 90 additions & 8 deletions

File tree

‎drivers/net/wireless/ath/ath11k/core.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ static void ath11k_core_restart(struct work_struct *work)
810810
complete(&ar->peer_assoc_done);
811811
complete(&ar->install_key_done);
812812
complete(&ar->vdev_setup_done);
813+
complete(&ar->vdev_delete_done);
813814
complete(&ar->bss_survey_done);
814815
complete(&ar->thermal.wmi_sync);
815816

‎drivers/net/wireless/ath/ath11k/core.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ struct ath11k_per_peer_tx_stats {
430430
};
431431

432432
#define ATH11K_FLUSH_TIMEOUT (5 * HZ)
433+
#define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)
433434

434435
struct ath11k_vdev_stop_status {
435436
bool stop_in_progress;
@@ -512,6 +513,7 @@ struct ath11k {
512513
int last_wmi_vdev_start_status;
513514
struct ath11k_vdev_stop_status vdev_stop_status;
514515
struct completion vdev_setup_done;
516+
struct completion vdev_delete_done;
515517

516518
int num_peers;
517519
int max_num_peers;

‎drivers/net/wireless/ath/ath11k/mac.c‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4660,6 +4660,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,
46604660
struct ath11k *ar = hw->priv;
46614661
struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
46624662
struct ath11k_base *ab = ar->ab;
4663+
unsigned long time_left;
46634664
int ret;
46644665
int i;
46654666

@@ -4668,27 +4669,40 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,
46684669
ath11k_dbg(ab, ATH11K_DBG_MAC, "mac remove interface (vdev %d)\n",
46694670
arvif->vdev_id);
46704671

4671-
spin_lock_bh(&ar->data_lock);
4672-
list_del(&arvif->list);
4673-
spin_unlock_bh(&ar->data_lock);
4674-
46754672
if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
46764673
ret = ath11k_peer_delete(ar, arvif->vdev_id, vif->addr);
46774674
if (ret)
46784675
ath11k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n",
46794676
arvif->vdev_id, ret);
46804677
}
46814678

4679+
reinit_completion(&ar->vdev_delete_done);
4680+
46824681
ret = ath11k_wmi_vdev_delete(ar, arvif->vdev_id);
4683-
if (ret)
4682+
if (ret) {
46844683
ath11k_warn(ab, "failed to delete WMI vdev %d: %d\n",
46854684
arvif->vdev_id, ret);
4685+
goto err_vdev_del;
4686+
}
4687+
4688+
time_left = wait_for_completion_timeout(&ar->vdev_delete_done,
4689+
ATH11K_VDEV_DELETE_TIMEOUT_HZ);
4690+
if (time_left == 0) {
4691+
ath11k_warn(ab, "Timeout in receiving vdev delete response\n");
4692+
goto err_vdev_del;
4693+
}
46864694

4695+
ab->free_vdev_map |= 1LL << (arvif->vdev_id);
4696+
ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
46874697
ar->num_created_vdevs--;
4698+
46884699
ath11k_dbg(ab, ATH11K_DBG_MAC, "vdev %pM deleted, vdev_id %d\n",
46894700
vif->addr, arvif->vdev_id);
4690-
ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id);
4691-
ab->free_vdev_map |= 1LL << (arvif->vdev_id);
4701+
4702+
err_vdev_del:
4703+
spin_lock_bh(&ar->data_lock);
4704+
list_del(&arvif->list);
4705+
spin_unlock_bh(&ar->data_lock);
46924706

46934707
ath11k_peer_cleanup(ar, arvif->vdev_id);
46944708

@@ -6454,6 +6468,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab)
64546468
INIT_LIST_HEAD(&ar->ppdu_stats_info);
64556469
mutex_init(&ar->conf_mutex);
64566470
init_completion(&ar->vdev_setup_done);
6471+
init_completion(&ar->vdev_delete_done);
64576472
init_completion(&ar->peer_assoc_done);
64586473
init_completion(&ar->install_key_done);
64596474
init_completion(&ar->bss_survey_done);

‎drivers/net/wireless/ath/ath11k/wmi.c‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ static const struct wmi_tlv_policy wmi_tlv_policies[] = {
126126
.min_len = sizeof(struct wmi_fils_discovery_event) },
127127
[WMI_TAG_OFFLOAD_PRB_RSP_TX_STATUS_EVENT] = {
128128
.min_len = sizeof(struct wmi_probe_resp_tx_status_event) },
129+
[WMI_TAG_VDEV_DELETE_RESP_EVENT] = {
130+
.min_len = sizeof(struct wmi_vdev_delete_resp_event) },
129131
};
130132

131133
#define PRIMAP(_hw_mode_) \
@@ -4379,6 +4381,34 @@ static int ath11k_pull_peer_del_resp_ev(struct ath11k_base *ab, struct sk_buff *
43794381
return 0;
43804382
}
43814383

4384+
static int ath11k_pull_vdev_del_resp_ev(struct ath11k_base *ab,
4385+
struct sk_buff *skb,
4386+
u32 *vdev_id)
4387+
{
4388+
const void **tb;
4389+
const struct wmi_vdev_delete_resp_event *ev;
4390+
int ret;
4391+
4392+
tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
4393+
if (IS_ERR(tb)) {
4394+
ret = PTR_ERR(tb);
4395+
ath11k_warn(ab, "failed to parse tlv: %d\n", ret);
4396+
return ret;
4397+
}
4398+
4399+
ev = tb[WMI_TAG_VDEV_DELETE_RESP_EVENT];
4400+
if (!ev) {
4401+
ath11k_warn(ab, "failed to fetch vdev delete resp ev");
4402+
kfree(tb);
4403+
return -EPROTO;
4404+
}
4405+
4406+
*vdev_id = ev->vdev_id;
4407+
4408+
kfree(tb);
4409+
return 0;
4410+
}
4411+
43824412
static int ath11k_pull_bcn_tx_status_ev(struct ath11k_base *ab, void *evt_buf,
43834413
u32 len, u32 *vdev_id,
43844414
u32 *tx_status)
@@ -5711,6 +5741,34 @@ static void ath11k_peer_delete_resp_event(struct ath11k_base *ab, struct sk_buff
57115741
*/
57125742
}
57135743

5744+
static void ath11k_vdev_delete_resp_event(struct ath11k_base *ab,
5745+
struct sk_buff *skb)
5746+
{
5747+
struct ath11k *ar;
5748+
u32 vdev_id = 0;
5749+
5750+
if (ath11k_pull_vdev_del_resp_ev(ab, skb, &vdev_id) != 0) {
5751+
ath11k_warn(ab, "failed to extract vdev delete resp");
5752+
return;
5753+
}
5754+
5755+
rcu_read_lock();
5756+
ar = ath11k_mac_get_ar_by_vdev_id(ab, vdev_id);
5757+
if (!ar) {
5758+
ath11k_warn(ab, "invalid vdev id in vdev delete resp ev %d",
5759+
vdev_id);
5760+
rcu_read_unlock();
5761+
return;
5762+
}
5763+
5764+
complete(&ar->vdev_delete_done);
5765+
5766+
rcu_read_unlock();
5767+
5768+
ath11k_dbg(ab, ATH11K_DBG_WMI, "vdev delete resp for vdev id %d\n",
5769+
vdev_id);
5770+
}
5771+
57145772
static inline const char *ath11k_wmi_vdev_resp_print(u32 vdev_resp_status)
57155773
{
57165774
switch (vdev_resp_status) {
@@ -6722,7 +6780,6 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)
67226780
break;
67236781
/* add Unsupported events here */
67246782
case WMI_TBTTOFFSET_EXT_UPDATE_EVENTID:
6725-
case WMI_VDEV_DELETE_RESP_EVENTID:
67266783
case WMI_PEER_OPER_MODE_CHANGE_EVENTID:
67276784
case WMI_TWT_ENABLE_EVENTID:
67286785
case WMI_TWT_DISABLE_EVENTID:
@@ -6733,6 +6790,9 @@ static void ath11k_wmi_tlv_op_rx(struct ath11k_base *ab, struct sk_buff *skb)
67336790
case WMI_PDEV_DFS_RADAR_DETECTION_EVENTID:
67346791
ath11k_wmi_pdev_dfs_radar_detected_event(ab, skb);
67356792
break;
6793+
case WMI_VDEV_DELETE_RESP_EVENTID:
6794+
ath11k_vdev_delete_resp_event(ab, skb);
6795+
break;
67366796
/* TODO: Add remaining events */
67376797
default:
67386798
ath11k_dbg(ab, ATH11K_DBG_WMI, "Unknown eventid: 0x%x\n", id);

‎drivers/net/wireless/ath/ath11k/wmi.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,6 +4018,10 @@ struct wmi_regulatory_rule_struct {
40184018
u32 flag_info;
40194019
};
40204020

4021+
struct wmi_vdev_delete_resp_event {
4022+
u32 vdev_id;
4023+
} __packed;
4024+
40214025
struct wmi_peer_delete_resp_event {
40224026
u32 vdev_id;
40234027
struct wmi_mac_addr peer_macaddr;

0 commit comments

Comments
 (0)