@@ -333,6 +333,14 @@ int gve_napi_poll(struct napi_struct *napi, int budget)
333
333
334
334
if (block -> rx ) {
335
335
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
+
336
344
reschedule |= work_done == budget ;
337
345
}
338
346
@@ -922,11 +930,13 @@ static void gve_init_sync_stats(struct gve_priv *priv)
922
930
static void gve_tx_get_curr_alloc_cfg (struct gve_priv * priv ,
923
931
struct gve_tx_alloc_rings_cfg * cfg )
924
932
{
933
+ int num_xdp_queues = priv -> xdp_prog ? priv -> rx_cfg .num_queues : 0 ;
934
+
925
935
cfg -> qcfg = & priv -> tx_cfg ;
926
936
cfg -> raw_addressing = !gve_is_qpl (priv );
927
937
cfg -> ring_size = priv -> tx_desc_cnt ;
928
938
cfg -> start_idx = 0 ;
929
- cfg -> num_rings = gve_num_tx_queues ( priv ) ;
939
+ cfg -> num_rings = priv -> tx_cfg . num_queues + num_xdp_queues ;
930
940
cfg -> tx = priv -> tx ;
931
941
}
932
942
@@ -1623,8 +1633,8 @@ static int gve_xsk_pool_enable(struct net_device *dev,
1623
1633
if (err )
1624
1634
return err ;
1625
1635
1626
- /* If XDP prog is not installed, return */
1627
- if (!priv -> xdp_prog )
1636
+ /* If XDP prog is not installed or interface is down , return. */
1637
+ if (!priv -> xdp_prog || ! netif_running ( dev ) )
1628
1638
return 0 ;
1629
1639
1630
1640
rx = & priv -> rx [qid ];
@@ -1669,21 +1679,16 @@ static int gve_xsk_pool_disable(struct net_device *dev,
1669
1679
if (qid >= priv -> rx_cfg .num_queues )
1670
1680
return - EINVAL ;
1671
1681
1672
- /* If XDP prog is not installed, unmap DMA and return */
1673
- if (!priv -> xdp_prog )
1674
- goto done ;
1675
-
1676
- tx_qid = gve_xdp_tx_queue_id (priv , qid );
1677
- if (!netif_running (dev )) {
1678
- priv -> rx [qid ].xsk_pool = NULL ;
1679
- xdp_rxq_info_unreg (& priv -> rx [qid ].xsk_rxq );
1680
- priv -> tx [tx_qid ].xsk_pool = NULL ;
1682
+ /* If XDP prog is not installed or interface is down, unmap DMA and
1683
+ * return.
1684
+ */
1685
+ if (!priv -> xdp_prog || !netif_running (dev ))
1681
1686
goto done ;
1682
- }
1683
1687
1684
1688
napi_rx = & priv -> ntfy_blocks [priv -> rx [qid ].ntfy_id ].napi ;
1685
1689
napi_disable (napi_rx ); /* make sure current rx poll is done */
1686
1690
1691
+ tx_qid = gve_xdp_tx_queue_id (priv , qid );
1687
1692
napi_tx = & priv -> ntfy_blocks [priv -> tx [tx_qid ].ntfy_id ].napi ;
1688
1693
napi_disable (napi_tx ); /* make sure current tx poll is done */
1689
1694
@@ -1711,6 +1716,9 @@ static int gve_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
1711
1716
struct gve_priv * priv = netdev_priv (dev );
1712
1717
int tx_queue_id = gve_xdp_tx_queue_id (priv , queue_id );
1713
1718
1719
+ if (!gve_get_napi_enabled (priv ))
1720
+ return - ENETDOWN ;
1721
+
1714
1722
if (queue_id >= priv -> rx_cfg .num_queues || !priv -> xdp_prog )
1715
1723
return - EINVAL ;
1716
1724
@@ -1837,6 +1845,7 @@ int gve_adjust_queues(struct gve_priv *priv,
1837
1845
{
1838
1846
struct gve_tx_alloc_rings_cfg tx_alloc_cfg = {0 };
1839
1847
struct gve_rx_alloc_rings_cfg rx_alloc_cfg = {0 };
1848
+ int num_xdp_queues ;
1840
1849
int err ;
1841
1850
1842
1851
gve_get_curr_alloc_cfgs (priv , & tx_alloc_cfg , & rx_alloc_cfg );
@@ -1847,6 +1856,10 @@ int gve_adjust_queues(struct gve_priv *priv,
1847
1856
rx_alloc_cfg .qcfg = & new_rx_config ;
1848
1857
tx_alloc_cfg .num_rings = new_tx_config .num_queues ;
1849
1858
1859
+ /* Add dedicated XDP TX queues if enabled. */
1860
+ num_xdp_queues = priv -> xdp_prog ? new_rx_config .num_queues : 0 ;
1861
+ tx_alloc_cfg .num_rings += num_xdp_queues ;
1862
+
1850
1863
if (netif_running (priv -> dev )) {
1851
1864
err = gve_adjust_config (priv , & tx_alloc_cfg , & rx_alloc_cfg );
1852
1865
return err ;
@@ -1899,6 +1912,9 @@ static void gve_turndown(struct gve_priv *priv)
1899
1912
1900
1913
gve_clear_napi_enabled (priv );
1901
1914
gve_clear_report_stats (priv );
1915
+
1916
+ /* Make sure that all traffic is finished processing. */
1917
+ synchronize_net ();
1902
1918
}
1903
1919
1904
1920
static void gve_turnup (struct gve_priv * priv )
0 commit comments