netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances
@ 2024-09-30 21:07 Joe Damato
  2024-09-30 21:07 ` [net-next v2 1/2] gve: Map IRQs to " Joe Damato
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joe Damato @ 2024-09-30 21:07 UTC (permalink / raw)
  To: netdev
  Cc: pkaligineedi, horms, Joe Damato, David S. Miller, Eric Dumazet,
	Harshitha Ramamurthy, Jakub Kicinski, Jeroen de Borst,
	Paolo Abeni, Shailend Chand, Willem de Bruijn, Ziwei Xiao,
	open list

Greetings:

Welcome to v2. The previous revision was an RFC [1].

This series uses the netdev-genl API to link IRQs and queues to NAPI IDs
so that this information is queryable by user apps. This is particularly
useful for epoll-based busy polling apps which rely on having access to
the NAPI ID.

I've tested these commits on a GCP instance with a GVE NIC configured
and have included test output in the commit messages for each patch
showing how to query the information.

Thanks,
Joe

[1]: https://lore.kernel.org/netdev/20240926030025.226221-1-jdamato@fastly.com/

v2:
  - Fixed spelling error in commit message of patch 1 suggested by Simon
    Horman
  - Fixed patch 2 to skip XDP TX queues, as suggested by Praveen
    Kaligineedi

Joe Damato (2):
  gve: Map IRQs to NAPI instances
  gve: Map NAPI instances to queues

 drivers/net/ethernet/google/gve/gve_main.c  | 17 +++++++++++++++++
 drivers/net/ethernet/google/gve/gve_utils.c |  1 +
 2 files changed, 18 insertions(+)

-- 
2.43.0


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

* [net-next v2 1/2] gve: Map IRQs to NAPI instances
  2024-09-30 21:07 [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances Joe Damato
@ 2024-09-30 21:07 ` Joe Damato
  2024-10-01 15:38   ` Praveen Kaligineedi
  2024-09-30 21:07 ` [net-next v2 2/2] gve: Map NAPI instances to queues Joe Damato
  2024-10-04  0:10 ` [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Joe Damato @ 2024-09-30 21:07 UTC (permalink / raw)
  To: netdev
  Cc: pkaligineedi, horms, Joe Damato, Jeroen de Borst, Shailend Chand,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, open list

Use netdev-genl interface to map IRQs to NAPI instances so that this
information is accessible by user apps via netlink.

$ cat /proc/interrupts | grep gve | grep -v mgmnt | cut -f1 --delimiter=':'
 34
 35
 36
 37
 38
 39
 40
[...]
 65

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
                         --dump napi-get --json='{"ifindex": 2}'
[{'id': 8288, 'ifindex': 2, 'irq': 65},
  [...]
 {'id': 8263, 'ifindex': 2, 'irq': 40},
 {'id': 8262, 'ifindex': 2, 'irq': 39},
 {'id': 8261, 'ifindex': 2, 'irq': 38},
 {'id': 8260, 'ifindex': 2, 'irq': 37},
 {'id': 8259, 'ifindex': 2, 'irq': 36},
 {'id': 8258, 'ifindex': 2, 'irq': 35},
 {'id': 8257, 'ifindex': 2, 'irq': 34}]

Signed-off-by: Joe Damato <jdamato@fastly.com>
---
 v2:
   - Fix a spelling error in the commit message, pointed out by Simon
     Horman

 drivers/net/ethernet/google/gve/gve_utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/google/gve/gve_utils.c b/drivers/net/ethernet/google/gve/gve_utils.c
index 2349750075a5..30fef100257e 100644
--- a/drivers/net/ethernet/google/gve/gve_utils.c
+++ b/drivers/net/ethernet/google/gve/gve_utils.c
@@ -111,6 +111,7 @@ void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
 	struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
 
 	netif_napi_add(priv->dev, &block->napi, gve_poll);
+	netif_napi_set_irq(&block->napi, block->irq);
 }
 
 void gve_remove_napi(struct gve_priv *priv, int ntfy_idx)
-- 
2.43.0


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

* [net-next v2 2/2] gve: Map NAPI instances to queues
  2024-09-30 21:07 [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances Joe Damato
  2024-09-30 21:07 ` [net-next v2 1/2] gve: Map IRQs to " Joe Damato
@ 2024-09-30 21:07 ` Joe Damato
  2024-10-01 15:37   ` Praveen Kaligineedi
  2024-10-04  0:10 ` [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Joe Damato @ 2024-09-30 21:07 UTC (permalink / raw)
  To: netdev
  Cc: pkaligineedi, horms, Joe Damato, Jeroen de Borst, Shailend Chand,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Harshitha Ramamurthy, Ziwei Xiao, open list

Use the netdev-genl interface to map NAPI instances to queues so that
this information is accessible to user programs via netlink.

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
			 --dump queue-get --json='{"ifindex": 2}'

[{'id': 0, 'ifindex': 2, 'napi-id': 8313, 'type': 'rx'},
 {'id': 1, 'ifindex': 2, 'napi-id': 8314, 'type': 'rx'},
 {'id': 2, 'ifindex': 2, 'napi-id': 8315, 'type': 'rx'},
 {'id': 3, 'ifindex': 2, 'napi-id': 8316, 'type': 'rx'},
 {'id': 4, 'ifindex': 2, 'napi-id': 8317, 'type': 'rx'},
[...]
 {'id': 0, 'ifindex': 2, 'napi-id': 8297, 'type': 'tx'},
 {'id': 1, 'ifindex': 2, 'napi-id': 8298, 'type': 'tx'},
 {'id': 2, 'ifindex': 2, 'napi-id': 8299, 'type': 'tx'},
 {'id': 3, 'ifindex': 2, 'napi-id': 8300, 'type': 'tx'},
 {'id': 4, 'ifindex': 2, 'napi-id': 8301, 'type': 'tx'},
[...]

Signed-off-by: Joe Damato <jdamato@fastly.com>
---
 v2:
   - Check that idx < priv->tx_cfg.num_queues in both gve_turnup and
     gve_turndown as suggested by Praveen Kaligineedi

 drivers/net/ethernet/google/gve/gve_main.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 661566db68c8..294ddcd0bf6c 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -1875,6 +1875,11 @@ static void gve_turndown(struct gve_priv *priv)
 
 		if (!gve_tx_was_added_to_block(priv, idx))
 			continue;
+
+		if (idx < priv->tx_cfg.num_queues)
+			netif_queue_set_napi(priv->dev, idx,
+					     NETDEV_QUEUE_TYPE_TX, NULL);
+
 		napi_disable(&block->napi);
 	}
 	for (idx = 0; idx < priv->rx_cfg.num_queues; idx++) {
@@ -1883,6 +1888,9 @@ static void gve_turndown(struct gve_priv *priv)
 
 		if (!gve_rx_was_added_to_block(priv, idx))
 			continue;
+
+		netif_queue_set_napi(priv->dev, idx, NETDEV_QUEUE_TYPE_RX,
+				     NULL);
 		napi_disable(&block->napi);
 	}
 
@@ -1909,6 +1917,12 @@ static void gve_turnup(struct gve_priv *priv)
 			continue;
 
 		napi_enable(&block->napi);
+
+		if (idx < priv->tx_cfg.num_queues)
+			netif_queue_set_napi(priv->dev, idx,
+					     NETDEV_QUEUE_TYPE_TX,
+					     &block->napi);
+
 		if (gve_is_gqi(priv)) {
 			iowrite32be(0, gve_irq_doorbell(priv, block));
 		} else {
@@ -1931,6 +1945,9 @@ static void gve_turnup(struct gve_priv *priv)
 			continue;
 
 		napi_enable(&block->napi);
+		netif_queue_set_napi(priv->dev, idx, NETDEV_QUEUE_TYPE_RX,
+				     &block->napi);
+
 		if (gve_is_gqi(priv)) {
 			iowrite32be(0, gve_irq_doorbell(priv, block));
 		} else {
-- 
2.43.0


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

* Re: [net-next v2 2/2] gve: Map NAPI instances to queues
  2024-09-30 21:07 ` [net-next v2 2/2] gve: Map NAPI instances to queues Joe Damato
@ 2024-10-01 15:37   ` Praveen Kaligineedi
  0 siblings, 0 replies; 6+ messages in thread
From: Praveen Kaligineedi @ 2024-10-01 15:37 UTC (permalink / raw)
  To: Joe Damato
  Cc: netdev, horms, Jeroen de Borst, Shailend Chand, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	Harshitha Ramamurthy, Ziwei Xiao, open list

On Mon, Sep 30, 2024 at 2:08 PM Joe Damato <jdamato@fastly.com> wrote:
>
> Use the netdev-genl interface to map NAPI instances to queues so that
> this information is accessible to user programs via netlink.
>
> $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
>                          --dump queue-get --json='{"ifindex": 2}'
>
> [{'id': 0, 'ifindex': 2, 'napi-id': 8313, 'type': 'rx'},
>  {'id': 1, 'ifindex': 2, 'napi-id': 8314, 'type': 'rx'},
>  {'id': 2, 'ifindex': 2, 'napi-id': 8315, 'type': 'rx'},
>  {'id': 3, 'ifindex': 2, 'napi-id': 8316, 'type': 'rx'},
>  {'id': 4, 'ifindex': 2, 'napi-id': 8317, 'type': 'rx'},
> [...]
>  {'id': 0, 'ifindex': 2, 'napi-id': 8297, 'type': 'tx'},
>  {'id': 1, 'ifindex': 2, 'napi-id': 8298, 'type': 'tx'},
>  {'id': 2, 'ifindex': 2, 'napi-id': 8299, 'type': 'tx'},
>  {'id': 3, 'ifindex': 2, 'napi-id': 8300, 'type': 'tx'},
>  {'id': 4, 'ifindex': 2, 'napi-id': 8301, 'type': 'tx'},
> [...]
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>

Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com>

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

* Re: [net-next v2 1/2] gve: Map IRQs to NAPI instances
  2024-09-30 21:07 ` [net-next v2 1/2] gve: Map IRQs to " Joe Damato
@ 2024-10-01 15:38   ` Praveen Kaligineedi
  0 siblings, 0 replies; 6+ messages in thread
From: Praveen Kaligineedi @ 2024-10-01 15:38 UTC (permalink / raw)
  To: Joe Damato
  Cc: netdev, horms, Jeroen de Borst, Shailend Chand, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	open list

On Mon, Sep 30, 2024 at 2:07 PM Joe Damato <jdamato@fastly.com> wrote:
>
> Use netdev-genl interface to map IRQs to NAPI instances so that this
> information is accessible by user apps via netlink.
>
> $ cat /proc/interrupts | grep gve | grep -v mgmnt | cut -f1 --delimiter=':'
>  34
>  35
>  36
>  37
>  38
>  39
>  40
> [...]
>  65
>
> $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
>                          --dump napi-get --json='{"ifindex": 2}'
> [{'id': 8288, 'ifindex': 2, 'irq': 65},
>   [...]
>  {'id': 8263, 'ifindex': 2, 'irq': 40},
>  {'id': 8262, 'ifindex': 2, 'irq': 39},
>  {'id': 8261, 'ifindex': 2, 'irq': 38},
>  {'id': 8260, 'ifindex': 2, 'irq': 37},
>  {'id': 8259, 'ifindex': 2, 'irq': 36},
>  {'id': 8258, 'ifindex': 2, 'irq': 35},
>  {'id': 8257, 'ifindex': 2, 'irq': 34}]
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>

Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com>

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

* Re: [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances
  2024-09-30 21:07 [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances Joe Damato
  2024-09-30 21:07 ` [net-next v2 1/2] gve: Map IRQs to " Joe Damato
  2024-09-30 21:07 ` [net-next v2 2/2] gve: Map NAPI instances to queues Joe Damato
@ 2024-10-04  0:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-04  0:10 UTC (permalink / raw)
  To: Joe Damato
  Cc: netdev, pkaligineedi, horms, davem, edumazet, hramamurthy, kuba,
	jeroendb, pabeni, shailend, willemb, ziweixiao, linux-kernel

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 30 Sep 2024 21:07:06 +0000 you wrote:
> Greetings:
> 
> Welcome to v2. The previous revision was an RFC [1].
> 
> This series uses the netdev-genl API to link IRQs and queues to NAPI IDs
> so that this information is queryable by user apps. This is particularly
> useful for epoll-based busy polling apps which rely on having access to
> the NAPI ID.
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/2] gve: Map IRQs to NAPI instances
    https://git.kernel.org/netdev/net-next/c/3017238b60d3
  - [net-next,v2,2/2] gve: Map NAPI instances to queues
    https://git.kernel.org/netdev/net-next/c/021f9e671e4a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 21:07 [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances Joe Damato
2024-09-30 21:07 ` [net-next v2 1/2] gve: Map IRQs to " Joe Damato
2024-10-01 15:38   ` Praveen Kaligineedi
2024-09-30 21:07 ` [net-next v2 2/2] gve: Map NAPI instances to queues Joe Damato
2024-10-01 15:37   ` Praveen Kaligineedi
2024-10-04  0:10 ` [net-next v2 0/2] gve: Link IRQs, queues, and NAPI instances patchwork-bot+netdevbpf

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).