netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: airoha: Implement BQL support
@ 2024-09-30 12:58 Lorenzo Bianconi
  2024-10-04  0:24 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2024-09-30 12:58 UTC (permalink / raw)
  To: Lorenzo Bianconi, Felix Fietkau, Sean Wang, Mark Lee,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Matthias Brugger, AngeloGioacchino Del Regno
  Cc: linux-arm-kernel, linux-mediatek, netdev, upstream

Introduce BQL support in the airoha_eth driver to avoid queuing to much
packets into the device hw queues and keep the latency small.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/mediatek/airoha_eth.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
index 930f180688e5..6dfde2828d93 100644
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
@@ -786,6 +786,7 @@ struct airoha_hw_stats {
 };
 
 struct airoha_qdma {
+	struct airoha_gdm_port *port;
 	struct airoha_eth *eth;
 	void __iomem *regs;
 
@@ -1658,6 +1659,7 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget)
 
 	while (irq_q->queued > 0 && done < budget) {
 		u32 qid, last, val = irq_q->q[irq_q->head];
+		u32 bytes = 0, count = 0;
 		struct airoha_queue *q;
 
 		if (val == 0xff)
@@ -1684,7 +1686,6 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget)
 			struct airoha_qdma_desc *desc = &q->desc[q->tail];
 			struct airoha_queue_entry *e = &q->entry[q->tail];
 			u32 desc_ctrl = le32_to_cpu(desc->ctrl);
-			struct sk_buff *skb = e->skb;
 			u16 index = q->tail;
 
 			if (!(desc_ctrl & QDMA_DESC_DONE_MASK) &&
@@ -1700,15 +1701,11 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget)
 			WRITE_ONCE(desc->msg0, 0);
 			WRITE_ONCE(desc->msg1, 0);
 
-			if (skb) {
-				struct netdev_queue *txq;
-
-				txq = netdev_get_tx_queue(skb->dev, qid);
-				if (netif_tx_queue_stopped(txq) &&
-				    q->ndesc - q->queued >= q->free_thr)
-					netif_tx_wake_queue(txq);
+			if (e->skb) {
+				bytes += e->skb->len;
+				count++;
 
-				dev_kfree_skb_any(skb);
+				dev_kfree_skb_any(e->skb);
 				e->skb = NULL;
 			}
 
@@ -1716,6 +1713,16 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget)
 				break;
 		}
 
+		if (qdma->port) {
+			struct netdev_queue *txq;
+
+			txq = netdev_get_tx_queue(qdma->port->dev, qid);
+			netdev_tx_completed_queue(txq, count, bytes);
+			if (netif_tx_queue_stopped(txq) &&
+			    q->ndesc - q->queued >= q->free_thr)
+				netif_tx_wake_queue(txq);
+		}
+
 		spin_unlock_bh(&q->lock);
 	}
 
@@ -2482,6 +2489,7 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
 	q->head = index;
 	q->queued += i;
 
+	netdev_tx_sent_queue(txq, skb->len);
 	skb_tx_timestamp(skb);
 	if (q->ndesc - q->queued < q->free_thr)
 		netif_tx_stop_queue(txq);
@@ -2650,6 +2658,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
 	port->dev = dev;
 	port->id = id;
 	eth->ports[index] = port;
+	qdma->port = port;
 
 	return register_netdev(dev);
 }

---
base-commit: c824deb1a89755f70156b5cdaf569fca80698719
change-id: 20240930-en7581-bql-552566f2078e

Best regards,
-- 
Lorenzo Bianconi <lorenzo@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: airoha: Implement BQL support
  2024-09-30 12:58 [PATCH net-next] net: airoha: Implement BQL support Lorenzo Bianconi
@ 2024-10-04  0:24 ` Jakub Kicinski
  2024-10-04  8:30   ` Lorenzo Bianconi
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2024-10-04  0:24 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Felix Fietkau, Sean Wang, Mark Lee, David S. Miller, Eric Dumazet,
	Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-arm-kernel, linux-mediatek, netdev, upstream

On Mon, 30 Sep 2024 14:58:35 +0200 Lorenzo Bianconi wrote:
> Introduce BQL support in the airoha_eth driver to avoid queuing to much
> packets into the device hw queues and keep the latency small.

This patch got set to Superseded in patchwork, somehow, but I don't see
a newer version. I think you're missing resetting the BQL state in
airoha_qdma_cleanup_tx_queue() ?
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: airoha: Implement BQL support
  2024-10-04  0:24 ` Jakub Kicinski
@ 2024-10-04  8:30   ` Lorenzo Bianconi
  0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2024-10-04  8:30 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Felix Fietkau, Sean Wang, Mark Lee, David S. Miller, Eric Dumazet,
	Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-arm-kernel, linux-mediatek, netdev, upstream

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

> On Mon, 30 Sep 2024 14:58:35 +0200 Lorenzo Bianconi wrote:
> > Introduce BQL support in the airoha_eth driver to avoid queuing to much
> > packets into the device hw queues and keep the latency small.
> 
> This patch got set to Superseded in patchwork, somehow, but I don't see
> a newer version. I think you're missing resetting the BQL state in
> airoha_qdma_cleanup_tx_queue() ?
> -- 
> pw-bot: cr

Hi Jakub,

for an unknown reason my email about dropping this patch has not gone through.
Sorry for that. I need to rework this patch in preparation of qdisc offloading.

Regards,
Lorenzo

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-04  8:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 12:58 [PATCH net-next] net: airoha: Implement BQL support Lorenzo Bianconi
2024-10-04  0:24 ` Jakub Kicinski
2024-10-04  8:30   ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).