From 516c1d2faf4480c355ec5000d6d4ad4fc287d0e8 Mon Sep 17 00:00:00 2001
From: Aditya Kumar Singh <quic_adisi@quicinc.com>
Date: Thu, 30 Dec 2021 17:44:40 +0530
Subject: [PATCH] ath11k: fix support for ext vdev in NSS for AP_VLAN vif
 during recovery

When driver is recovering, it tears down nss connection and sets
ab->nss.enabled as false. However, this is not set back to its original
state post recovery and hence when ext vdev is added again, warning
trace appears since ath11k_mac_op_add_interface() does not handle
NL80211_IFTYPE_AP_VLAN vif with nss disabled and throws a WARN_ON(1).

[ 2777.201255] ------------[ cut here ]------------
[ 2777.209669] WARNING: CPU: 0 PID: 77 at drivers/net/wireless/ath/ath11k/mac.c:7298 ath11k_mac_op_add_interface+0x314/0xa98 [ath11k]
[----- Trimmed -----]
[ 2777.499054] CPU: 0 PID: 77 Comm: kworker/0:2 Tainted: G        W         5.4.89 #0
[ 2777.515132] Hardware name: Generic DT based system
[ 2777.522658] Workqueue: events_freezable ieee80211_restart_work [mac80211]
[ 2777.527305] [<8030f3a4>] (unwind_backtrace) from [<8030b700>] (show_stack+0x10/0x14)
[ 2777.534153] [<8030b700>] (show_stack) from [<808da410>] (dump_stack+0x88/0xa8)
[ 2777.541964] [<808da410>] (dump_stack) from [<8031bf20>] (__warn+0xa4/0xd0)
[ 2777.548994] [<8031bf20>] (__warn) from [<8031bfbc>] (warn_slowpath_fmt+0x70/0x9c)
[ 2777.555972] [<8031bfbc>] (warn_slowpath_fmt) from [<c02cb440>] (ath11k_mac_op_add_interface+0x314/0xa98 [ath11k])
[ 2777.563664] [<c02cb440>] (ath11k_mac_op_add_interface [ath11k]) from [<7fd34720>] (drv_add_interface+0x68/0x78 [mac80211])
[ 2777.573928] [<7fd34720>] (drv_add_interface [mac80211]) from [<7fd679bc>] (ieee80211_reconfig+0x240/0xce8 [mac80211])
[ 2777.584843] [<7fd679bc>] (ieee80211_reconfig [mac80211]) from [<7fd311ec>] (ieee80211_restart_work+0xd4/0xf4 [mac80211])
[ 2777.595401] [<7fd311ec>] (ieee80211_restart_work [mac80211]) from [<80331968>] (process_one_work+0x1dc/0x310)
[ 2777.606205] [<80331968>] (process_one_work) from [<80332cf8>] (worker_thread+0x2bc/0x40c)
[ 2777.616009] [<80332cf8>] (worker_thread) from [<803373ac>] (kthread+0x164/0x180)
[ 2777.624167] [<803373ac>] (kthread) from [<803010e0>] (ret_from_fork+0x14/0x34)

Added logic to enable nss as per MODULE_PARM_DESC parameter.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/core.c | 5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -2008,6 +2008,11 @@ static int ath11k_core_reconfigure_on_cr
 
 	clear_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
 
+	/* We have disabled NSS Offload support in the starting.
+	 * Re-enabling it if it was originally enabled in the MODULE_PARM_DESC.
+	 */
+	ab->nss.enabled = nss_offload;
+
 	ret = ath11k_core_qmi_firmware_ready(ab);
 	if (ret)
 		goto err_hal_srng_deinit;
