From: Shailend Chand <shailend@google.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org,
Shailend Chand <shailend@google.com>,
Willem de Bruijn <willemb@google.com>,
Jeroen de Borst <jeroendb@google.com>
Subject: [PATCH net-next 2/6] gve: Refactor napi add and remove functions
Date: Mon, 22 Jan 2024 18:26:28 +0000 [thread overview]
Message-ID: <20240122182632.1102721-3-shailend@google.com> (raw)
In-Reply-To: <20240122182632.1102721-1-shailend@google.com>
This change makes the napi poll functions non-static and moves the
gve_(add|remove)_napi functions to gve_utils.c, to make possible future
"start queue" hooks in the datapath files.
Signed-off-by: Shailend Chand <shailend@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jeroen de Borst <jeroendb@google.com>
---
drivers/net/ethernet/google/gve/gve.h | 3 +++
drivers/net/ethernet/google/gve/gve_dqo.h | 2 ++
drivers/net/ethernet/google/gve/gve_main.c | 20 +++-----------------
drivers/net/ethernet/google/gve/gve_utils.c | 15 +++++++++++++++
drivers/net/ethernet/google/gve/gve_utils.h | 3 +++
5 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index 00e7f8b06d89..ba6819ac600e 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -1085,6 +1085,9 @@ static inline u32 gve_xdp_tx_start_queue_id(struct gve_priv *priv)
return gve_xdp_tx_queue_id(priv, 0);
}
+/* gqi napi handler defined in gve_main.c */
+int gve_napi_poll(struct napi_struct *napi, int budget);
+
/* buffers */
int gve_alloc_page(struct gve_priv *priv, struct device *dev,
struct page **page, dma_addr_t *dma,
diff --git a/drivers/net/ethernet/google/gve/gve_dqo.h b/drivers/net/ethernet/google/gve/gve_dqo.h
index c36b93f0de15..8058b09f8e3e 100644
--- a/drivers/net/ethernet/google/gve/gve_dqo.h
+++ b/drivers/net/ethernet/google/gve/gve_dqo.h
@@ -93,4 +93,6 @@ gve_set_itr_coalesce_usecs_dqo(struct gve_priv *priv,
gve_write_irq_doorbell_dqo(priv, block,
gve_setup_itr_interval_dqo(usecs));
}
+
+int gve_napi_poll_dqo(struct napi_struct *napi, int budget);
#endif /* _GVE_DQO_H_ */
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 619bf63ec935..e07048cd249e 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -22,6 +22,7 @@
#include "gve_dqo.h"
#include "gve_adminq.h"
#include "gve_register.h"
+#include "gve_utils.h"
#define GVE_DEFAULT_RX_COPYBREAK (256)
@@ -252,7 +253,7 @@ static irqreturn_t gve_intr_dqo(int irq, void *arg)
return IRQ_HANDLED;
}
-static int gve_napi_poll(struct napi_struct *napi, int budget)
+int gve_napi_poll(struct napi_struct *napi, int budget)
{
struct gve_notify_block *block;
__be32 __iomem *irq_doorbell;
@@ -302,7 +303,7 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)
return work_done;
}
-static int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
+int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
{
struct gve_notify_block *block =
container_of(napi, struct gve_notify_block, napi);
@@ -581,21 +582,6 @@ static void gve_teardown_device_resources(struct gve_priv *priv)
gve_clear_device_resources_ok(priv);
}
-static void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
- int (*gve_poll)(struct napi_struct *, int))
-{
- struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
-
- netif_napi_add(priv->dev, &block->napi, gve_poll);
-}
-
-static void gve_remove_napi(struct gve_priv *priv, int ntfy_idx)
-{
- struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
-
- netif_napi_del(&block->napi);
-}
-
static int gve_register_xdp_qpls(struct gve_priv *priv)
{
int start_id;
diff --git a/drivers/net/ethernet/google/gve/gve_utils.c b/drivers/net/ethernet/google/gve/gve_utils.c
index 26e08d753270..974a75623789 100644
--- a/drivers/net/ethernet/google/gve/gve_utils.c
+++ b/drivers/net/ethernet/google/gve/gve_utils.c
@@ -81,3 +81,18 @@ void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info *page_info)
page_ref_add(page_info->page, INT_MAX - pagecount);
}
}
+
+void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
+ int (*gve_poll)(struct napi_struct *, int))
+{
+ struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
+
+ netif_napi_add(priv->dev, &block->napi, gve_poll);
+}
+
+void gve_remove_napi(struct gve_priv *priv, int ntfy_idx)
+{
+ struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
+
+ netif_napi_del(&block->napi);
+}
diff --git a/drivers/net/ethernet/google/gve/gve_utils.h b/drivers/net/ethernet/google/gve/gve_utils.h
index 324fd98a6112..924516e9eaae 100644
--- a/drivers/net/ethernet/google/gve/gve_utils.h
+++ b/drivers/net/ethernet/google/gve/gve_utils.h
@@ -23,5 +23,8 @@ struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *napi,
/* Decrement pagecnt_bias. Set it back to INT_MAX if it reached zero. */
void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info *page_info);
+void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
+ int (*gve_poll)(struct napi_struct *, int));
+void gve_remove_napi(struct gve_priv *priv, int ntfy_idx);
#endif /* _GVE_UTILS_H */
--
2.43.0.429.g432eaa2c6b-goog
next prev parent reply other threads:[~2024-01-22 18:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 18:26 [PATCH net-next 0/6] gve: Alloc before freeing when changing config Shailend Chand
2024-01-22 18:26 ` [PATCH net-next 1/6] gve: Define config structs for queue allocation Shailend Chand
2024-01-23 16:26 ` Simon Horman
2024-01-22 18:26 ` Shailend Chand [this message]
2024-01-23 16:26 ` [PATCH net-next 2/6] gve: Refactor napi add and remove functions Simon Horman
2024-01-22 18:26 ` [PATCH net-next 3/6] gve: Switch to config-aware queue allocation Shailend Chand
2024-01-23 16:27 ` Simon Horman
2024-01-22 18:26 ` [PATCH net-next 4/6] gve: Refactor gve_open and gve_close Shailend Chand
2024-01-22 18:26 ` [PATCH net-next 5/6] gve: Alloc before freeing when adjusting queues Shailend Chand
2024-01-22 18:26 ` [PATCH net-next 6/6] gve: Alloc before freeing when changing features Shailend Chand
2024-01-24 1:50 ` [PATCH net-next 0/6] gve: Alloc before freeing when changing config patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240122182632.1102721-3-shailend@google.com \
--to=shailend@google.com \
--cc=davem@davemloft.net \
--cc=jeroendb@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).