Skip to content

Commit 077ef69

Browse files
josh8551021gregkh
authored andcommitted
gve: process XSK TX descriptors as part of RX NAPI
commit ba0925c upstream. When busy polling is enabled, xsk_sendmsg for AF_XDP zero copy marks the NAPI ID corresponding to the memory pool allocated for the socket. In GVE, this NAPI ID will never correspond to a NAPI ID of one of the dedicated XDP TX queues registered with the umem because XDP TX is not set up to share a NAPI with a corresponding RX queue. This patch moves XSK TX descriptor processing from the TX NAPI to the RX NAPI, and the gve_xsk_wakeup callback is updated to use the RX NAPI instead of the TX NAPI, accordingly. The branch on if the wakeup is for TX is removed, as the NAPI poll should be invoked whether the wakeup is for TX or for RX. Fixes: fd8e403 ("gve: Add AF_XDP zero-copy support for GQI-QPL format") Cc: [email protected] Signed-off-by: Praveen Kaligineedi <[email protected]> Signed-off-by: Joshua Washington <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d066ab5 commit 077ef69

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ int gve_xdp_xmit_one(struct gve_priv *priv, struct gve_tx_ring *tx,
11341134
void gve_xdp_tx_flush(struct gve_priv *priv, u32 xdp_qid);
11351135
bool gve_tx_poll(struct gve_notify_block *block, int budget);
11361136
bool gve_xdp_poll(struct gve_notify_block *block, int budget);
1137+
int gve_xsk_tx_poll(struct gve_notify_block *block, int budget);
11371138
int gve_tx_alloc_rings_gqi(struct gve_priv *priv,
11381139
struct gve_tx_alloc_rings_cfg *cfg);
11391140
void gve_tx_free_rings_gqi(struct gve_priv *priv,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ int gve_napi_poll(struct napi_struct *napi, int budget)
333333

334334
if (block->rx) {
335335
work_done = gve_rx_poll(block, budget);
336+
337+
/* Poll XSK TX as part of RX NAPI. Setup re-poll based on max of
338+
* TX and RX work done.
339+
*/
340+
if (priv->xdp_prog)
341+
work_done = max_t(int, work_done,
342+
gve_xsk_tx_poll(block, budget));
343+
336344
reschedule |= work_done == budget;
337345
}
338346

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -975,33 +975,41 @@ static int gve_xsk_tx(struct gve_priv *priv, struct gve_tx_ring *tx,
975975
return sent;
976976
}
977977

978+
int gve_xsk_tx_poll(struct gve_notify_block *rx_block, int budget)
979+
{
980+
struct gve_rx_ring *rx = rx_block->rx;
981+
struct gve_priv *priv = rx->gve;
982+
struct gve_tx_ring *tx;
983+
int sent = 0;
984+
985+
tx = &priv->tx[gve_xdp_tx_queue_id(priv, rx->q_num)];
986+
if (tx->xsk_pool) {
987+
sent = gve_xsk_tx(priv, tx, budget);
988+
989+
u64_stats_update_begin(&tx->statss);
990+
tx->xdp_xsk_sent += sent;
991+
u64_stats_update_end(&tx->statss);
992+
if (xsk_uses_need_wakeup(tx->xsk_pool))
993+
xsk_set_tx_need_wakeup(tx->xsk_pool);
994+
}
995+
996+
return sent;
997+
}
998+
978999
bool gve_xdp_poll(struct gve_notify_block *block, int budget)
9791000
{
9801001
struct gve_priv *priv = block->priv;
9811002
struct gve_tx_ring *tx = block->tx;
9821003
u32 nic_done;
983-
bool repoll;
9841004
u32 to_do;
9851005

9861006
/* Find out how much work there is to be done */
9871007
nic_done = gve_tx_load_event_counter(priv, tx);
9881008
to_do = min_t(u32, (nic_done - tx->done), budget);
9891009
gve_clean_xdp_done(priv, tx, to_do);
990-
repoll = nic_done != tx->done;
991-
992-
if (tx->xsk_pool) {
993-
int sent = gve_xsk_tx(priv, tx, budget);
994-
995-
u64_stats_update_begin(&tx->statss);
996-
tx->xdp_xsk_sent += sent;
997-
u64_stats_update_end(&tx->statss);
998-
repoll |= (sent == budget);
999-
if (xsk_uses_need_wakeup(tx->xsk_pool))
1000-
xsk_set_tx_need_wakeup(tx->xsk_pool);
1001-
}
10021010

10031011
/* If we still have work we want to repoll */
1004-
return repoll;
1012+
return nic_done != tx->done;
10051013
}
10061014

10071015
bool gve_tx_poll(struct gve_notify_block *block, int budget)

0 commit comments

Comments
 (0)