[PATCH] ath9k_htc: fix WMI command handling and improve message sending

Biancaa Ramesh posted 1 patch 3 months, 2 weeks ago
drivers/net/wireless/ath/ath9k/htc_drv_main.c | 139 +++++++-----------
1 file changed, 56 insertions(+), 83 deletions(-)
[PATCH] ath9k_htc: fix WMI command handling and improve message sending
Posted by Biancaa Ramesh 3 months, 2 weeks ago
Signed-off-by: Biancaa Ramesh <biancaa2210329@ssn.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/>
Re: [PATCH] ath9k_htc: fix WMI command handling and improve message sending
Posted by kernel test robot 3 months, 2 weeks ago
Hi Biancaa,

kernel test robot noticed the following build errors:

[auto build test ERROR on ath/ath-next]
[also build test ERROR on linus/master v6.18-rc2 next-20251021]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Biancaa-Ramesh/ath9k_htc-fix-WMI-command-handling-and-improve-message-sending/20251021-221643
base:   https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git ath-next
patch link:    https://lore.kernel.org/r/20251021141337.33268-1-biancaa2210329%40ssn.edu.in
patch subject: [PATCH] ath9k_htc: fix WMI command handling and improve message sending
config: i386-randconfig-141-20251022 (https://download.01.org/0day-ci/archive/20251022/202510221108.3obrzqLL-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251022/202510221108.3obrzqLL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510221108.3obrzqLL-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from drivers/net/wireless/ath/ath9k/htc.h:33,
                    from drivers/net/wireless/ath/ath9k/htc_drv_main.c:17:
   drivers/net/wireless/ath/ath9k/htc_drv_main.c: In function 'ath9k_htc_add_monitor_interface':
>> drivers/net/wireless/ath/ath9k/wmi.h:202:9: error: expected expression before 'do'
     202 |         do {                                                            \
         |         ^~
   drivers/net/wireless/ath/ath9k/htc_drv_main.c:371:11: note: in expansion of macro 'WMI_CMD_BUF'
     371 |     ret = WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
         |           ^~~~~~~~~~~
>> drivers/net/wireless/ath/ath9k/wmi.h:202:9: error: expected expression before 'do'
     202 |         do {                                                            \
         |         ^~
   drivers/net/wireless/ath/ath9k/htc_drv_main.c:389:11: note: in expansion of macro 'WMI_CMD_BUF'
     389 |     ret = WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
         |           ^~~~~~~~~~~
>> drivers/net/wireless/ath/ath9k/htc_drv_main.c:356:8: warning: unused variable 'cmd_rsp' [-Wunused-variable]
     356 |     u8 cmd_rsp;
         |        ^~~~~~~


vim +/cmd_rsp +356 drivers/net/wireless/ath/ath9k/htc_drv_main.c

cc72128750700d0 Sujith Manoharan   2011-01-03  349  
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  350  static int ath9k_htc_add_monitor_interface(struct ath9k_htc_priv *priv)
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  351  {
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  352      struct ath_common *common = ath9k_hw_common(priv->ah);
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  353      struct ath9k_htc_target_vif hvif;
cc72128750700d0 Sujith Manoharan   2011-01-03  354      struct ath9k_htc_target_sta tsta;
a97b478c92c1425 Sujith Manoharan   2011-02-21  355      int ret = 0, sta_idx;
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26 @356      u8 cmd_rsp;
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  357  
a97b478c92c1425 Sujith Manoharan   2011-02-21  358      if ((priv->nvifs >= ATH9K_HTC_MAX_VIF) ||
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  359          (priv->nstations >= ATH9K_HTC_MAX_STA))
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  360          return -ENOBUFS;
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  361  
a97b478c92c1425 Sujith Manoharan   2011-02-21  362      sta_idx = ffz(priv->sta_slot);
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  363      if (sta_idx < 0 || sta_idx >= ATH9K_HTC_MAX_STA)
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  364          return -ENOBUFS;
cc72128750700d0 Sujith Manoharan   2011-01-03  365  
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  366      memset(&hvif, 0, sizeof(hvif));
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  367      memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
e4c62506fcfa7c1 Sujith Manoharan   2011-04-13  368      hvif.opmode = HTC_M_MONITOR;
a97b478c92c1425 Sujith Manoharan   2011-02-21  369      hvif.index = ffz(priv->vif_slot);
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  370  
34af6f1f3df95cb Biancaa Ramesh     2025-10-21 @371      ret = WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  372      if (ret)
a97b478c92c1425 Sujith Manoharan   2011-02-21  373          goto err_vif;
a97b478c92c1425 Sujith Manoharan   2011-02-21  374  
a97b478c92c1425 Sujith Manoharan   2011-02-21  375      priv->mon_vif_idx = hvif.index;
a97b478c92c1425 Sujith Manoharan   2011-02-21  376      priv->vif_slot |= (1 << hvif.index);
a97b478c92c1425 Sujith Manoharan   2011-02-21  377  
a97b478c92c1425 Sujith Manoharan   2011-02-21  378      if (!priv->nvifs)
a97b478c92c1425 Sujith Manoharan   2011-02-21  379          priv->ah->opmode = NL80211_IFTYPE_MONITOR;
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  380      priv->nvifs++;
cc72128750700d0 Sujith Manoharan   2011-01-03  381  
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  382      memset(&tsta, 0, sizeof(tsta));
cc72128750700d0 Sujith Manoharan   2011-01-03  383      memcpy(&tsta.macaddr, common->macaddr, ETH_ALEN);
cc72128750700d0 Sujith Manoharan   2011-01-03  384      tsta.is_vif_sta = 1;
a97b478c92c1425 Sujith Manoharan   2011-02-21  385      tsta.sta_index = sta_idx;
cc72128750700d0 Sujith Manoharan   2011-01-03  386      tsta.vif_index = hvif.index;
b97c57ff3f568b3 Sujith Manoharan   2011-04-13  387      tsta.maxampdu = cpu_to_be16(0xffff);
cc72128750700d0 Sujith Manoharan   2011-01-03  388  
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  389      ret = WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
cc72128750700d0 Sujith Manoharan   2011-01-03  390      if (ret) {
cc72128750700d0 Sujith Manoharan   2011-01-03  391          ath_err(common, "Unable to add station entry for monitor mode\n");
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  392          __ath9k_htc_remove_monitor_interface(priv);
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  393          return ret;
cc72128750700d0 Sujith Manoharan   2011-01-03  394      }
cc72128750700d0 Sujith Manoharan   2011-01-03  395  
a97b478c92c1425 Sujith Manoharan   2011-02-21  396      priv->sta_slot |= (1 << sta_idx);
cc72128750700d0 Sujith Manoharan   2011-01-03  397      priv->nstations++;
a97b478c92c1425 Sujith Manoharan   2011-02-21  398      priv->vif_sta_pos[priv->mon_vif_idx] = sta_idx;
55de80d64545e5c Sujith Manoharan   2011-01-05  399      priv->ah->is_monitoring = true;
55de80d64545e5c Sujith Manoharan   2011-01-05  400  
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  401      ath_dbg(common, CONFIG, "Monitor interface added at idx %d, sta idx %d\n",
a97b478c92c1425 Sujith Manoharan   2011-02-21  402              priv->mon_vif_idx, sta_idx);
a97b478c92c1425 Sujith Manoharan   2011-02-21  403  
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  404      return 0;
cc72128750700d0 Sujith Manoharan   2011-01-03  405  
a97b478c92c1425 Sujith Manoharan   2011-02-21  406  err_vif:
34af6f1f3df95cb Biancaa Ramesh     2025-10-21  407      ath_dbg(common, FATAL, "Unable to attach monitor interface\n");
cc72128750700d0 Sujith Manoharan   2011-01-03  408      return ret;
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  409  }
81fc2a332045dc1 Rajkumar Manoharan 2010-11-26  410  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] ath9k_htc: fix WMI command handling and improve message sending
Posted by Markus Elfring 3 months, 2 weeks ago
…
> ---
>  drivers/net/wireless/ath/ath9k/htc_drv_main.c | 139 +++++++-----------
…

Thanks for your try to improve the implementation of the function “ath9k_htc_add_monitor_interface”.
https://elixir.bootlin.com/linux/v6.18-rc2/source/drivers/net/wireless/ath/ath9k/htc_drv_main.c#L350-L437

Please recheck the indentation approach accordingly.
Not all leading tab characters need to be replaced by space characters.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.18-rc2#n18


I miss some information so far.

1. Helpful change description
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc2#n45

2. More appropriate recipient selection
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc2#n231


…
> -- 
> ::DISCLAIMER::
…
> The 
> contents of this e-mail and any attachment(s) are confidential and
…

Please reconsider such hints once more for communication by the means of public mailing lists.
https://subspace.kernel.org/etiquette.html#do-not-include-confidentiality-disclaimers

Regards,
Markus