Commit 59ae83dc authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'tg3-link-irqs-napis-and-queues'

Joe Damato says:

====================
tg3: Link IRQs, NAPIs, and queues

This follows from a previous RFC (wherein I botched the subject lines of
all the messages) [1].

I've taken Michael Chan's suggestion on modifying patch 2 and I've
updated the commit messages of both patches to test and show the output
for the default 1 TX 4 RX queues and the 4 TX and 4 RX queues cases.

Reviewers: please check the commit messages carefully to ensure the
output is correct (or on your own systems to verify, if you like). I am
not a tg3 expert and it's possible that I got something wrong.

[1]: https://lore.kernel.org/all/20241005145717.302575-3-jdamato@fastly.com/T/
====================

Link: https://patch.msgid.link/20241009175509.31753-1-jdamato@fastly.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 854d71c5 aec5514d
Loading
Loading
Loading
Loading
+40 −7
Original line number Diff line number Diff line
@@ -7395,27 +7395,60 @@ static int tg3_poll(struct napi_struct *napi, int budget)

static void tg3_napi_disable(struct tg3 *tp)
{
	int txq_idx = tp->txq_cnt - 1;
	int rxq_idx = tp->rxq_cnt - 1;
	struct tg3_napi *tnapi;
	int i;

	for (i = tp->irq_cnt - 1; i >= 0; i--)
		napi_disable(&tp->napi[i].napi);
	for (i = tp->irq_cnt - 1; i >= 0; i--) {
		tnapi = &tp->napi[i];
		if (tnapi->tx_buffers) {
			netif_queue_set_napi(tp->dev, txq_idx,
					     NETDEV_QUEUE_TYPE_TX, NULL);
			txq_idx--;
		}
		if (tnapi->rx_rcb) {
			netif_queue_set_napi(tp->dev, rxq_idx,
					     NETDEV_QUEUE_TYPE_RX, NULL);
			rxq_idx--;
		}
		napi_disable(&tnapi->napi);
	}
}

static void tg3_napi_enable(struct tg3 *tp)
{
	int txq_idx = 0, rxq_idx = 0;
	struct tg3_napi *tnapi;
	int i;

	for (i = 0; i < tp->irq_cnt; i++)
		napi_enable(&tp->napi[i].napi);
	for (i = 0; i < tp->irq_cnt; i++) {
		tnapi = &tp->napi[i];
		napi_enable(&tnapi->napi);
		if (tnapi->tx_buffers) {
			netif_queue_set_napi(tp->dev, txq_idx,
					     NETDEV_QUEUE_TYPE_TX,
					     &tnapi->napi);
			txq_idx++;
		}
		if (tnapi->rx_rcb) {
			netif_queue_set_napi(tp->dev, rxq_idx,
					     NETDEV_QUEUE_TYPE_RX,
					     &tnapi->napi);
			rxq_idx++;
		}
	}
}

static void tg3_napi_init(struct tg3 *tp)
{
	int i;

	netif_napi_add(tp->dev, &tp->napi[0].napi, tg3_poll);
	for (i = 1; i < tp->irq_cnt; i++)
		netif_napi_add(tp->dev, &tp->napi[i].napi, tg3_poll_msix);
	for (i = 0; i < tp->irq_cnt; i++) {
		netif_napi_add(tp->dev, &tp->napi[i].napi,
			       i ? tg3_poll_msix : tg3_poll);
		netif_napi_set_irq(&tp->napi[i].napi, tp->napi[i].irq_vec);
	}
}

static void tg3_napi_fini(struct tg3 *tp)