diff mbox series

[v2,36/50] wilc1000: introduce transmit path chip queue

Message ID 20211223011358.4031459-37-davidm@egauge.net (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wilc1000: rework tx path to use sk_buffs throughout | expand

Commit Message

David Mosberger-Tang Dec. 23, 2021, 1:14 a.m. UTC
This introduces a chip queue that will hold packets ready to be
transferred to the chip.  A later patch will start using it.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
---
 .../net/wireless/microchip/wilc1000/cfg80211.c |  3 +++
 .../net/wireless/microchip/wilc1000/netdev.h   | 18 ++++++++++++++++++
 drivers/net/wireless/microchip/wilc1000/wlan.c |  5 +++++
 3 files changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
index 6f19dee813f2a..6d3635864569f 100644
--- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -1716,6 +1716,9 @@  int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
 	for (i = 0; i < NQUEUES; i++)
 		skb_queue_head_init(&wl->txq[i]);
 
+	skb_queue_head_init(&wl->chipq);
+	wl->chipq_bytes = 0;
+
 	INIT_LIST_HEAD(&wl->rxq_head.list);
 	INIT_LIST_HEAD(&wl->vif_list);
 
diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h
index 82f38a0e20214..e168f8644c678 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.h
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -261,6 +261,24 @@  struct wilc {
 	struct wilc_tx_queue_status tx_q_limit;
 	struct rxq_entry_t rxq_head;
 
+	/* The chip queue contains sk_buffs that are ready to be
+	 * transferred to the wilc1000 chip.  In particular, they
+	 * already have the VMM and Ethernet headers (for net packets)
+	 * and they are padded to a size that is an integer-multiple
+	 * of 4 bytes.
+	 *
+	 * This queue is usually empty on return from
+	 * wilc_wlan_handle_txq().  However, when the chip does fill
+	 * up, the packets that didn't fit will be held until there is
+	 * space again.
+	 *
+	 * This queue is only accessed by the txq handler thread, so
+	 * no locking is required.
+	 */
+	struct sk_buff_head chipq;
+	/* Total number of bytes queued on the chipq: */
+	int chipq_bytes;
+
 	const struct firmware *firmware;
 
 	struct device *dev;
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 18b1e7fad4d71..c3802a34defed 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -1263,6 +1263,11 @@  void wilc_wlan_cleanup(struct net_device *dev)
 	struct wilc *wilc = vif->wilc;
 
 	wilc->quit = 1;
+
+	while ((tqe = __skb_dequeue(&wilc->chipq)))
+		wilc_wlan_tx_packet_done(tqe, 0);
+	wilc->chipq_bytes = 0;
+
 	for (ac = 0; ac < NQUEUES; ac++) {
 		while ((tqe = skb_dequeue(&wilc->txq[ac])))
 			wilc_wlan_tx_packet_done(tqe, 0);