Skip to content

Commit 1dfc2e4

Browse files
shailend-gkuba-moo
authored andcommitted
gve: Refactor napi add and remove functions
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 <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Reviewed-by: Jeroen de Borst <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7cea48b commit 1dfc2e4

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

drivers/net/ethernet/google/gve/gve.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ static inline u32 gve_xdp_tx_start_queue_id(struct gve_priv *priv)
10851085
return gve_xdp_tx_queue_id(priv, 0);
10861086
}
10871087

1088+
/* gqi napi handler defined in gve_main.c */
1089+
int gve_napi_poll(struct napi_struct *napi, int budget);
1090+
10881091
/* buffers */
10891092
int gve_alloc_page(struct gve_priv *priv, struct device *dev,
10901093
struct page **page, dma_addr_t *dma,

drivers/net/ethernet/google/gve/gve_dqo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,6 @@ gve_set_itr_coalesce_usecs_dqo(struct gve_priv *priv,
9393
gve_write_irq_doorbell_dqo(priv, block,
9494
gve_setup_itr_interval_dqo(usecs));
9595
}
96+
97+
int gve_napi_poll_dqo(struct napi_struct *napi, int budget);
9698
#endif /* _GVE_DQO_H_ */

drivers/net/ethernet/google/gve/gve_main.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "gve_dqo.h"
2323
#include "gve_adminq.h"
2424
#include "gve_register.h"
25+
#include "gve_utils.h"
2526

2627
#define GVE_DEFAULT_RX_COPYBREAK (256)
2728

@@ -252,7 +253,7 @@ static irqreturn_t gve_intr_dqo(int irq, void *arg)
252253
return IRQ_HANDLED;
253254
}
254255

255-
static int gve_napi_poll(struct napi_struct *napi, int budget)
256+
int gve_napi_poll(struct napi_struct *napi, int budget)
256257
{
257258
struct gve_notify_block *block;
258259
__be32 __iomem *irq_doorbell;
@@ -302,7 +303,7 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)
302303
return work_done;
303304
}
304305

305-
static int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
306+
int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
306307
{
307308
struct gve_notify_block *block =
308309
container_of(napi, struct gve_notify_block, napi);
@@ -581,21 +582,6 @@ static void gve_teardown_device_resources(struct gve_priv *priv)
581582
gve_clear_device_resources_ok(priv);
582583
}
583584

584-
static void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
585-
int (*gve_poll)(struct napi_struct *, int))
586-
{
587-
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
588-
589-
netif_napi_add(priv->dev, &block->napi, gve_poll);
590-
}
591-
592-
static void gve_remove_napi(struct gve_priv *priv, int ntfy_idx)
593-
{
594-
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
595-
596-
netif_napi_del(&block->napi);
597-
}
598-
599585
static int gve_register_xdp_qpls(struct gve_priv *priv)
600586
{
601587
int start_id;

drivers/net/ethernet/google/gve/gve_utils.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,18 @@ void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info *page_info)
8181
page_ref_add(page_info->page, INT_MAX - pagecount);
8282
}
8383
}
84+
85+
void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
86+
int (*gve_poll)(struct napi_struct *, int))
87+
{
88+
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
89+
90+
netif_napi_add(priv->dev, &block->napi, gve_poll);
91+
}
92+
93+
void gve_remove_napi(struct gve_priv *priv, int ntfy_idx)
94+
{
95+
struct gve_notify_block *block = &priv->ntfy_blocks[ntfy_idx];
96+
97+
netif_napi_del(&block->napi);
98+
}

drivers/net/ethernet/google/gve/gve_utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *napi,
2323
/* Decrement pagecnt_bias. Set it back to INT_MAX if it reached zero. */
2424
void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info *page_info);
2525

26+
void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
27+
int (*gve_poll)(struct napi_struct *, int));
28+
void gve_remove_napi(struct gve_priv *priv, int ntfy_idx);
2629
#endif /* _GVE_UTILS_H */
2730

0 commit comments

Comments
 (0)