@@ -2430,6 +2430,46 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
2430
2430
}
2431
2431
}
2432
2432
2433
+ static void stmmac_xsk_request_timestamp (void * _priv )
2434
+ {
2435
+ struct stmmac_metadata_request * meta_req = _priv ;
2436
+
2437
+ stmmac_enable_tx_timestamp (meta_req -> priv , meta_req -> tx_desc );
2438
+ * meta_req -> set_ic = true;
2439
+ }
2440
+
2441
+ static u64 stmmac_xsk_fill_timestamp (void * _priv )
2442
+ {
2443
+ struct stmmac_xsk_tx_complete * tx_compl = _priv ;
2444
+ struct stmmac_priv * priv = tx_compl -> priv ;
2445
+ struct dma_desc * desc = tx_compl -> desc ;
2446
+ bool found = false;
2447
+ u64 ns = 0 ;
2448
+
2449
+ if (!priv -> hwts_tx_en )
2450
+ return 0 ;
2451
+
2452
+ /* check tx tstamp status */
2453
+ if (stmmac_get_tx_timestamp_status (priv , desc )) {
2454
+ stmmac_get_timestamp (priv , desc , priv -> adv_ts , & ns );
2455
+ found = true;
2456
+ } else if (!stmmac_get_mac_tx_timestamp (priv , priv -> hw , & ns )) {
2457
+ found = true;
2458
+ }
2459
+
2460
+ if (found ) {
2461
+ ns -= priv -> plat -> cdc_error_adj ;
2462
+ return ns_to_ktime (ns );
2463
+ }
2464
+
2465
+ return 0 ;
2466
+ }
2467
+
2468
+ static const struct xsk_tx_metadata_ops stmmac_xsk_tx_metadata_ops = {
2469
+ .tmo_request_timestamp = stmmac_xsk_request_timestamp ,
2470
+ .tmo_fill_timestamp = stmmac_xsk_fill_timestamp ,
2471
+ };
2472
+
2433
2473
static bool stmmac_xdp_xmit_zc (struct stmmac_priv * priv , u32 queue , u32 budget )
2434
2474
{
2435
2475
struct netdev_queue * nq = netdev_get_tx_queue (priv -> dev , queue );
@@ -2449,6 +2489,8 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
2449
2489
budget = min (budget , stmmac_tx_avail (priv , queue ));
2450
2490
2451
2491
while (budget -- > 0 ) {
2492
+ struct stmmac_metadata_request meta_req ;
2493
+ struct xsk_tx_metadata * meta = NULL ;
2452
2494
dma_addr_t dma_addr ;
2453
2495
bool set_ic ;
2454
2496
@@ -2472,6 +2514,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
2472
2514
tx_desc = tx_q -> dma_tx + entry ;
2473
2515
2474
2516
dma_addr = xsk_buff_raw_get_dma (pool , xdp_desc .addr );
2517
+ meta = xsk_buff_get_metadata (pool , xdp_desc .addr );
2475
2518
xsk_buff_raw_dma_sync_for_device (pool , dma_addr , xdp_desc .len );
2476
2519
2477
2520
tx_q -> tx_skbuff_dma [entry ].buf_type = STMMAC_TXBUF_T_XSK_TX ;
@@ -2499,6 +2542,11 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
2499
2542
else
2500
2543
set_ic = false;
2501
2544
2545
+ meta_req .priv = priv ;
2546
+ meta_req .tx_desc = tx_desc ;
2547
+ meta_req .set_ic = & set_ic ;
2548
+ xsk_tx_metadata_request (meta , & stmmac_xsk_tx_metadata_ops ,
2549
+ & meta_req );
2502
2550
if (set_ic ) {
2503
2551
tx_q -> tx_count_frames = 0 ;
2504
2552
stmmac_set_tx_ic (priv , tx_desc );
@@ -2511,6 +2559,9 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
2511
2559
2512
2560
stmmac_enable_dma_transmission (priv , priv -> ioaddr );
2513
2561
2562
+ xsk_tx_metadata_to_compl (meta ,
2563
+ & tx_q -> tx_skbuff_dma [entry ].xsk_meta );
2564
+
2514
2565
tx_q -> cur_tx = STMMAC_GET_ENTRY (tx_q -> cur_tx , priv -> dma_conf .dma_tx_size );
2515
2566
entry = tx_q -> cur_tx ;
2516
2567
}
@@ -2620,8 +2671,18 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
2620
2671
} else {
2621
2672
tx_packets ++ ;
2622
2673
}
2623
- if (skb )
2674
+ if (skb ) {
2624
2675
stmmac_get_tx_hwtstamp (priv , p , skb );
2676
+ } else {
2677
+ struct stmmac_xsk_tx_complete tx_compl = {
2678
+ .priv = priv ,
2679
+ .desc = p ,
2680
+ };
2681
+
2682
+ xsk_tx_metadata_complete (& tx_q -> tx_skbuff_dma [entry ].xsk_meta ,
2683
+ & stmmac_xsk_tx_metadata_ops ,
2684
+ & tx_compl );
2685
+ }
2625
2686
}
2626
2687
2627
2688
if (likely (tx_q -> tx_skbuff_dma [entry ].buf &&
@@ -7464,6 +7525,7 @@ int stmmac_dvr_probe(struct device *device,
7464
7525
ndev -> netdev_ops = & stmmac_netdev_ops ;
7465
7526
7466
7527
ndev -> xdp_metadata_ops = & stmmac_xdp_metadata_ops ;
7528
+ ndev -> xsk_tx_metadata_ops = & stmmac_xsk_tx_metadata_ops ;
7467
7529
7468
7530
ndev -> hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
7469
7531
NETIF_F_RXCSUM ;
0 commit comments