[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251021141337.33268-1-biancaa2210329@ssn.edu.in>
Date: Tue, 21 Oct 2025 19:43:37 +0530
From: Biancaa Ramesh <biancaa2210329@....edu.in>
To: linux-kernel@...r.kernel.org
Cc: Biancaa Ramesh <biancaa2210329@....edu.in>
Subject: [PATCH] ath9k_htc: fix WMI command handling and improve message sending
Signed-off-by: Biancaa Ramesh <biancaa2210329@....edu.in>
---
drivers/net/wireless/ath/ath9k/htc_drv_main.c | 139 +++++++-----------
1 file changed, 56 insertions(+), 83 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 0d6272ac0dac..1333b90ae425 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -349,93 +349,66 @@ static void __ath9k_htc_remove_monitor_interface(struct ath9k_htc_priv *priv)
static int ath9k_htc_add_monitor_interface(struct ath9k_htc_priv *priv)
{
- struct ath_common *common = ath9k_hw_common(priv->ah);
- struct ath9k_htc_target_vif hvif;
- struct ath9k_htc_target_sta tsta;
- int ret = 0, sta_idx;
- u8 cmd_rsp;
-
- if ((priv->nvifs >= ATH9K_HTC_MAX_VIF) ||
- (priv->nstations >= ATH9K_HTC_MAX_STA)) {
- ret = -ENOBUFS;
- goto err_vif;
- }
-
- sta_idx = ffz(priv->sta_slot);
- if ((sta_idx < 0) || (sta_idx > ATH9K_HTC_MAX_STA)) {
- ret = -ENOBUFS;
- goto err_vif;
- }
-
- /*
- * Add an interface.
- */
- memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
- memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
-
- hvif.opmode = HTC_M_MONITOR;
- hvif.index = ffz(priv->vif_slot);
-
- WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
- if (ret)
- goto err_vif;
-
- /*
- * Assign the monitor interface index as a special case here.
- * This is needed when the interface is brought down.
- */
- priv->mon_vif_idx = hvif.index;
- priv->vif_slot |= (1 << hvif.index);
-
- /*
- * Set the hardware mode to monitor only if there are no
- * other interfaces.
- */
- if (!priv->nvifs)
- priv->ah->opmode = NL80211_IFTYPE_MONITOR;
-
- priv->nvifs++;
+ struct ath_common *common = ath9k_hw_common(priv->ah);
+ struct ath9k_htc_target_vif hvif;
+ struct ath9k_htc_target_sta tsta;
+ int ret = 0, sta_idx;
+ u8 cmd_rsp;
+
+ if ((priv->nvifs >= ATH9K_HTC_MAX_VIF) ||
+ (priv->nstations >= ATH9K_HTC_MAX_STA))
+ return -ENOBUFS;
+
+ sta_idx = ffz(priv->sta_slot);
+ if (sta_idx < 0 || sta_idx >= ATH9K_HTC_MAX_STA)
+ return -ENOBUFS;
+
+ memset(&hvif, 0, sizeof(hvif));
+ memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
+ hvif.opmode = HTC_M_MONITOR;
+ hvif.index = ffz(priv->vif_slot);
+
+ ret = WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
+ if (ret)
+ goto err_vif;
+
+ priv->mon_vif_idx = hvif.index;
+ priv->vif_slot |= (1 << hvif.index);
+
+ if (!priv->nvifs)
+ priv->ah->opmode = NL80211_IFTYPE_MONITOR;
+ priv->nvifs++;
+
+ memset(&tsta, 0, sizeof(tsta));
+ memcpy(&tsta.macaddr, common->macaddr, ETH_ALEN);
+ tsta.is_vif_sta = 1;
+ tsta.sta_index = sta_idx;
+ tsta.vif_index = hvif.index;
+ tsta.maxampdu = cpu_to_be16(0xffff);
+
+ ret = WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
+ if (ret) {
+ ath_err(common, "Unable to add station entry for monitor mode\n");
+ __ath9k_htc_remove_monitor_interface(priv);
+ return ret;
+ }
+
+ priv->sta_slot |= (1 << sta_idx);
+ priv->nstations++;
+ priv->vif_sta_pos[priv->mon_vif_idx] = sta_idx;
+ priv->ah->is_monitoring = true;
+
+ ath_dbg(common, CONFIG, "Monitor interface added at idx %d, sta idx %d\n",
+ priv->mon_vif_idx, sta_idx);
+
+ return 0;
- /*
- * Associate a station with the interface for packet injection.
- */
- memset(&tsta, 0, sizeof(struct ath9k_htc_target_sta));
-
- memcpy(&tsta.macaddr, common->macaddr, ETH_ALEN);
-
- tsta.is_vif_sta = 1;
- tsta.sta_index = sta_idx;
- tsta.vif_index = hvif.index;
- tsta.maxampdu = cpu_to_be16(0xffff);
-
- WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
- if (ret) {
- ath_err(common, "Unable to add station entry for monitor mode\n");
- goto err_sta;
- }
-
- priv->sta_slot |= (1 << sta_idx);
- priv->nstations++;
- priv->vif_sta_pos[priv->mon_vif_idx] = sta_idx;
- priv->ah->is_monitoring = true;
-
- ath_dbg(common, CONFIG,
- "Attached a monitor interface at idx: %d, sta idx: %d\n",
- priv->mon_vif_idx, sta_idx);
-
- return 0;
-
-err_sta:
- /*
- * Remove the interface from the target.
- */
- __ath9k_htc_remove_monitor_interface(priv);
err_vif:
- ath_dbg(common, FATAL, "Unable to attach a monitor interface\n");
-
- return ret;
+ ath_dbg(common, FATAL, "Unable to attach monitor interface\n");
+ return ret;
}
+
static int ath9k_htc_remove_monitor_interface(struct ath9k_htc_priv *priv)
{
struct ath_common *common = ath9k_hw_common(priv->ah);
--
2.43.0
--
::DISCLAIMER::
---------------------------------------------------------------------
The
contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only. Views or opinions, if any,
presented in
this email are solely those of the author and may not
necessarily reflect
the views or opinions of SSN Institutions (SSN) or its
affiliates. Any form
of reproduction, dissemination, copying, disclosure,
modification,
distribution and / or publication of this message without the
prior written
consent of authorized representative of SSN is strictly
prohibited. If you
have received this email in error please delete it and
notify the sender
immediately.
---------------------------------------------------------------------
Header of this mail should have a valid DKIM signature for the domain
ssn.edu.in <http://www.ssn.edu.in/>
Powered by blists - more mailing lists