Skip to content

Commit ba0925c

Browse files
josh8551021davem330
authored andcommitted
gve: process XSK TX descriptors as part of RX NAPI
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]>
1 parent 40338d7 commit ba0925c

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
@@ -1140,6 +1140,7 @@ int gve_xdp_xmit_one(struct gve_priv *priv, struct gve_tx_ring *tx,
11401140
void gve_xdp_tx_flush(struct gve_priv *priv, u32 xdp_qid);
11411141
bool gve_tx_poll(struct gve_notify_block *block, int budget);
11421142
bool gve_xdp_poll(struct gve_notify_block *block, int budget);
1143+
int gve_xsk_tx_poll(struct gve_notify_block *block, int budget);
11431144
int gve_tx_alloc_rings_gqi(struct gve_priv *priv,
11441145
struct gve_tx_alloc_rings_cfg *cfg);
11451146
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
@@ -981,33 +981,41 @@ static int gve_xsk_tx(struct gve_priv *priv, struct gve_tx_ring *tx,
981981
return sent;
982982
}
983983

984+
int gve_xsk_tx_poll(struct gve_notify_block *rx_block, int budget)
985+
{
986+
struct gve_rx_ring *rx = rx_block->rx;
987+
struct gve_priv *priv = rx->gve;
988+
struct gve_tx_ring *tx;
989+
int sent = 0;
990+
991+
tx = &priv->tx[gve_xdp_tx_queue_id(priv, rx->q_num)];
992+
if (tx->xsk_pool) {
993+
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+
if (xsk_uses_need_wakeup(tx->xsk_pool))
999+
xsk_set_tx_need_wakeup(tx->xsk_pool);
1000+
}
1001+
1002+
return sent;
1003+
}
1004+
9841005
bool gve_xdp_poll(struct gve_notify_block *block, int budget)
9851006
{
9861007
struct gve_priv *priv = block->priv;
9871008
struct gve_tx_ring *tx = block->tx;
9881009
u32 nic_done;
989-
bool repoll;
9901010
u32 to_do;
9911011

9921012
/* Find out how much work there is to be done */
9931013
nic_done = gve_tx_load_event_counter(priv, tx);
9941014
to_do = min_t(u32, (nic_done - tx->done), budget);
9951015
gve_clean_xdp_done(priv, tx, to_do);
996-
repoll = nic_done != tx->done;
997-
998-
if (tx->xsk_pool) {
999-
int sent = gve_xsk_tx(priv, tx, budget);
1000-
1001-
u64_stats_update_begin(&tx->statss);
1002-
tx->xdp_xsk_sent += sent;
1003-
u64_stats_update_end(&tx->statss);
1004-
repoll |= (sent == budget);
1005-
if (xsk_uses_need_wakeup(tx->xsk_pool))
1006-
xsk_set_tx_need_wakeup(tx->xsk_pool);
1007-
}
10081016

10091017
/* If we still have work we want to repoll */
1010-
return repoll;
1018+
return nic_done != tx->done;
10111019
}
10121020

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

0 commit comments

Comments
 (0)