diff mbox series

[v4] wifi: mac80211: add exported tpt_led_trig function for softmac driver

Message ID ce30818cd336b64ded17f410b594e9c9c1f5f4ee.1696376062.git.yi-chia.hsieh@mediatek.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series [v4] wifi: mac80211: add exported tpt_led_trig function for softmac driver | expand

Commit Message

Yi-Chia Hsieh Oct. 4, 2023, 8:47 p.m. UTC
Add a new function __ieee80211_tpt_led_trig_trx. It is exported and
takes ieee80211_hw as argument so that softmac driver can use. This
can be helpful when traffic runs in HW path and mac80211 is not
aware of the traffic.

Signed-off-by: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
Signed-off-by: Money Wang <Money.Wang@mediatek.com>
Signed-off-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
---
v2: split series
---
v3: retitle, keep the original API and combine double-underscore functions
---
v4: export ieee80211_tpt_led_trig_trx and make double-underscore function inline

---
 include/net/mac80211.h | 10 ++++++++++
 net/mac80211/led.c     |  7 +++++++
 net/mac80211/led.h     | 29 +++++++++++------------------
 net/mac80211/rx.c      |  2 +-
 net/mac80211/tx.c      |  4 ++--
 5 files changed, 31 insertions(+), 21 deletions(-)

Comments

kernel test robot Oct. 5, 2023, 5:25 p.m. UTC | #1
Hi Yi-Chia,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v6.6-rc4 next-20231005]
[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/Yi-Chia-Hsieh/wifi-mac80211-add-exported-tpt_led_trig-function-for-softmac-driver/20231005-045011
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/ce30818cd336b64ded17f410b594e9c9c1f5f4ee.1696376062.git.yi-chia.hsieh%40mediatek.com
patch subject: [PATCH v4] wifi: mac80211: add exported tpt_led_trig function for softmac driver
config: x86_64-randconfig-005-20231005 (https://download.01.org/0day-ci/archive/20231006/202310060127.50JAGHMk-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231006/202310060127.50JAGHMk-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/202310060127.50JAGHMk-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: net/mac80211/rx.o: in function `ieee80211_rx_list':
>> net/mac80211/rx.c:5386: undefined reference to `ieee80211_tpt_led_trig_trx'
   ld: net/mac80211/tx.o: in function `__ieee80211_subif_start_xmit':
>> net/mac80211/tx.c:4337: undefined reference to `ieee80211_tpt_led_trig_trx'
   ld: net/mac80211/tx.o: in function `ieee80211_8023_xmit':
   net/mac80211/tx.c:4668: undefined reference to `ieee80211_tpt_led_trig_trx'


vim +5386 net/mac80211/rx.c

  5263	
  5264	/*
  5265	 * This is the receive path handler. It is called by a low level driver when an
  5266	 * 802.11 MPDU is received from the hardware.
  5267	 */
  5268	void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta,
  5269			       struct sk_buff *skb, struct list_head *list)
  5270	{
  5271		struct ieee80211_local *local = hw_to_local(hw);
  5272		struct ieee80211_rate *rate = NULL;
  5273		struct ieee80211_supported_band *sband;
  5274		struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
  5275		struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  5276	
  5277		WARN_ON_ONCE(softirq_count() == 0);
  5278	
  5279		if (WARN_ON(status->band >= NUM_NL80211_BANDS))
  5280			goto drop;
  5281	
  5282		sband = local->hw.wiphy->bands[status->band];
  5283		if (WARN_ON(!sband))
  5284			goto drop;
  5285	
  5286		/*
  5287		 * If we're suspending, it is possible although not too likely
  5288		 * that we'd be receiving frames after having already partially
  5289		 * quiesced the stack. We can't process such frames then since
  5290		 * that might, for example, cause stations to be added or other
  5291		 * driver callbacks be invoked.
  5292		 */
  5293		if (unlikely(local->quiescing || local->suspended))
  5294			goto drop;
  5295	
  5296		/* We might be during a HW reconfig, prevent Rx for the same reason */
  5297		if (unlikely(local->in_reconfig))
  5298			goto drop;
  5299	
  5300		/*
  5301		 * The same happens when we're not even started,
  5302		 * but that's worth a warning.
  5303		 */
  5304		if (WARN_ON(!local->started))
  5305			goto drop;
  5306	
  5307		if (likely(!(status->flag & RX_FLAG_FAILED_PLCP_CRC))) {
  5308			/*
  5309			 * Validate the rate, unless a PLCP error means that
  5310			 * we probably can't have a valid rate here anyway.
  5311			 */
  5312	
  5313			switch (status->encoding) {
  5314			case RX_ENC_HT:
  5315				/*
  5316				 * rate_idx is MCS index, which can be [0-76]
  5317				 * as documented on:
  5318				 *
  5319				 * https://wireless.wiki.kernel.org/en/developers/Documentation/ieee80211/802.11n
  5320				 *
  5321				 * Anything else would be some sort of driver or
  5322				 * hardware error. The driver should catch hardware
  5323				 * errors.
  5324				 */
  5325				if (WARN(status->rate_idx > 76,
  5326					 "Rate marked as an HT rate but passed "
  5327					 "status->rate_idx is not "
  5328					 "an MCS index [0-76]: %d (0x%02x)\n",
  5329					 status->rate_idx,
  5330					 status->rate_idx))
  5331					goto drop;
  5332				break;
  5333			case RX_ENC_VHT:
  5334				if (WARN_ONCE(status->rate_idx > 11 ||
  5335					      !status->nss ||
  5336					      status->nss > 8,
  5337					      "Rate marked as a VHT rate but data is invalid: MCS: %d, NSS: %d\n",
  5338					      status->rate_idx, status->nss))
  5339					goto drop;
  5340				break;
  5341			case RX_ENC_HE:
  5342				if (WARN_ONCE(status->rate_idx > 11 ||
  5343					      !status->nss ||
  5344					      status->nss > 8,
  5345					      "Rate marked as an HE rate but data is invalid: MCS: %d, NSS: %d\n",
  5346					      status->rate_idx, status->nss))
  5347					goto drop;
  5348				break;
  5349			case RX_ENC_EHT:
  5350				if (WARN_ONCE(status->rate_idx > 15 ||
  5351					      !status->nss ||
  5352					      status->nss > 8 ||
  5353					      status->eht.gi > NL80211_RATE_INFO_EHT_GI_3_2,
  5354					      "Rate marked as an EHT rate but data is invalid: MCS:%d, NSS:%d, GI:%d\n",
  5355					      status->rate_idx, status->nss, status->eht.gi))
  5356					goto drop;
  5357				break;
  5358			default:
  5359				WARN_ON_ONCE(1);
  5360				fallthrough;
  5361			case RX_ENC_LEGACY:
  5362				if (WARN_ON(status->rate_idx >= sband->n_bitrates))
  5363					goto drop;
  5364				rate = &sband->bitrates[status->rate_idx];
  5365			}
  5366		}
  5367	
  5368		if (WARN_ON_ONCE(status->link_id >= IEEE80211_LINK_UNSPECIFIED))
  5369			goto drop;
  5370	
  5371		status->rx_flags = 0;
  5372	
  5373		kcov_remote_start_common(skb_get_kcov_handle(skb));
  5374	
  5375		/*
  5376		 * Frames with failed FCS/PLCP checksum are not returned,
  5377		 * all other frames are returned without radiotap header
  5378		 * if it was previously present.
  5379		 * Also, frames with less than 16 bytes are dropped.
  5380		 */
  5381		if (!(status->flag & RX_FLAG_8023))
  5382			skb = ieee80211_rx_monitor(local, skb, rate);
  5383		if (skb) {
  5384			if ((status->flag & RX_FLAG_8023) ||
  5385				ieee80211_is_data_present(hdr->frame_control))
> 5386				ieee80211_tpt_led_trig_trx(&local->hw, 0, skb->len);
  5387	
  5388			if (status->flag & RX_FLAG_8023)
  5389				__ieee80211_rx_handle_8023(hw, pubsta, skb, list);
  5390			else
  5391				__ieee80211_rx_handle_packet(hw, pubsta, skb, list);
  5392		}
  5393	
  5394		kcov_remote_stop();
  5395		return;
  5396	 drop:
  5397		kfree_skb(skb);
  5398	}
  5399	EXPORT_SYMBOL(ieee80211_rx_list);
  5400
diff mbox series

Patch

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 72375eceb786..de37020ee845 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4853,6 +4853,16 @@  ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags,
 #endif
 }
 
+/**
+ * ieee80211_tpt_led_trig_trx - report traffic to throughput LED
+ *
+ * @hw: the hardware to count bytes for tpt_led
+ * @tx_bytes: bytes to add to tx
+ * @rx_bytes: bytes to add to rx
+ */
+void ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw,
+				int tx_bytes, int rx_bytes);
+
 /**
  * ieee80211_unregister_hw - Unregister a hardware device
  *
diff --git a/net/mac80211/led.c b/net/mac80211/led.c
index 2dc732147e85..89fd5da21423 100644
--- a/net/mac80211/led.c
+++ b/net/mac80211/led.c
@@ -319,6 +319,13 @@  __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
 }
 EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger);
 
+void ieee80211_tpt_led_trig_trx(struct ieee80211_hw *hw,
+				int tx_bytes, int rx_bytes)
+{
+	__ieee80211_tpt_led_trig_trx(hw_to_local(hw), tx_bytes, rx_bytes);
+}
+EXPORT_SYMBOL(ieee80211_tpt_led_trig_trx);
+
 static void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
 {
 	struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
diff --git a/net/mac80211/led.h b/net/mac80211/led.h
index d25f13346b82..8368564d205f 100644
--- a/net/mac80211/led.h
+++ b/net/mac80211/led.h
@@ -28,6 +28,17 @@  static inline void ieee80211_led_tx(struct ieee80211_local *local)
 #endif
 }
 
+static inline void __ieee80211_tpt_led_trig_trx(struct ieee80211_local *local,
+						int tx_bytes, int rx_bytes)
+{
+#ifdef CONFIG_MAC80211_LEDS
+	if (atomic_read(&local->tpt_led_active)) {
+		local->tpt_led_trigger->tx_bytes += tx_bytes;
+		local->tpt_led_trigger->rx_bytes += rx_bytes;
+	}
+#endif
+}
+
 #ifdef CONFIG_MAC80211_LEDS
 void ieee80211_led_assoc(struct ieee80211_local *local,
 			 bool associated);
@@ -66,21 +77,3 @@  static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
 {
 }
 #endif
-
-static inline void
-ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
-{
-#ifdef CONFIG_MAC80211_LEDS
-	if (atomic_read(&local->tpt_led_active))
-		local->tpt_led_trigger->tx_bytes += bytes;
-#endif
-}
-
-static inline void
-ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes)
-{
-#ifdef CONFIG_MAC80211_LEDS
-	if (atomic_read(&local->tpt_led_active))
-		local->tpt_led_trigger->rx_bytes += bytes;
-#endif
-}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 051db97a92b4..c6d67e62d866 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -5383,7 +5383,7 @@  void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta,
 	if (skb) {
 		if ((status->flag & RX_FLAG_8023) ||
 			ieee80211_is_data_present(hdr->frame_control))
-			ieee80211_tpt_led_trig_rx(local, skb->len);
+			ieee80211_tpt_led_trig_trx(&local->hw, 0, skb->len);
 
 		if (status->flag & RX_FLAG_8023)
 			__ieee80211_rx_handle_8023(hw, pubsta, skb, list);
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index a984fc54644e..0cffd3a94830 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -4334,7 +4334,7 @@  void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 	len = 0;
  out:
 	if (len)
-		ieee80211_tpt_led_trig_tx(local, len);
+		ieee80211_tpt_led_trig_trx(&local->hw, len, 0);
 	rcu_read_unlock();
 }
 
@@ -4665,7 +4665,7 @@  static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 	sta->deflink.tx_stats.packets[queue] += skbs;
 	sta->deflink.tx_stats.bytes[queue] += len;
 
-	ieee80211_tpt_led_trig_tx(local, len);
+	ieee80211_tpt_led_trig_trx(&local->hw, len, 0);
 
 	ieee80211_tx_8023(sdata, skb, sta, false);