@@ -480,6 +480,20 @@ int ionic_xdp_xmit(struct net_device *netdev, int n,
480
480
return nxmit ;
481
481
}
482
482
483
+ static void ionic_xdp_rx_put_bufs (struct ionic_queue * q ,
484
+ struct ionic_buf_info * buf_info ,
485
+ int nbufs )
486
+ {
487
+ int i ;
488
+
489
+ for (i = 0 ; i < nbufs ; i ++ ) {
490
+ dma_unmap_page (q -> dev , buf_info -> dma_addr ,
491
+ IONIC_PAGE_SIZE , DMA_FROM_DEVICE );
492
+ buf_info -> page = NULL ;
493
+ buf_info ++ ;
494
+ }
495
+ }
496
+
483
497
static bool ionic_run_xdp (struct ionic_rx_stats * stats ,
484
498
struct net_device * netdev ,
485
499
struct bpf_prog * xdp_prog ,
@@ -493,6 +507,7 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
493
507
struct netdev_queue * nq ;
494
508
struct xdp_frame * xdpf ;
495
509
int remain_len ;
510
+ int nbufs = 1 ;
496
511
int frag_len ;
497
512
int err = 0 ;
498
513
@@ -542,6 +557,7 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
542
557
if (page_is_pfmemalloc (bi -> page ))
543
558
xdp_buff_set_frag_pfmemalloc (& xdp_buf );
544
559
} while (remain_len > 0 );
560
+ nbufs += sinfo -> nr_frags ;
545
561
}
546
562
547
563
xdp_action = bpf_prog_run_xdp (xdp_prog , & xdp_buf );
@@ -574,9 +590,6 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
574
590
goto out_xdp_abort ;
575
591
}
576
592
577
- dma_unmap_page (rxq -> dev , buf_info -> dma_addr ,
578
- IONIC_PAGE_SIZE , DMA_FROM_DEVICE );
579
-
580
593
err = ionic_xdp_post_frame (txq , xdpf , XDP_TX ,
581
594
buf_info -> page ,
582
595
buf_info -> page_offset ,
@@ -586,23 +599,19 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
586
599
netdev_dbg (netdev , "tx ionic_xdp_post_frame err %d\n" , err );
587
600
goto out_xdp_abort ;
588
601
}
589
- buf_info -> page = NULL ;
602
+ ionic_xdp_rx_put_bufs ( rxq , buf_info , nbufs ) ;
590
603
stats -> xdp_tx ++ ;
591
604
592
605
/* the Tx completion will free the buffers */
593
606
break ;
594
607
595
608
case XDP_REDIRECT :
596
- /* unmap the pages before handing them to a different device */
597
- dma_unmap_page (rxq -> dev , buf_info -> dma_addr ,
598
- IONIC_PAGE_SIZE , DMA_FROM_DEVICE );
599
-
600
609
err = xdp_do_redirect (netdev , & xdp_buf , xdp_prog );
601
610
if (err ) {
602
611
netdev_dbg (netdev , "xdp_do_redirect err %d\n" , err );
603
612
goto out_xdp_abort ;
604
613
}
605
- buf_info -> page = NULL ;
614
+ ionic_xdp_rx_put_bufs ( rxq , buf_info , nbufs ) ;
606
615
rxq -> xdp_flush = true;
607
616
stats -> xdp_redirect ++ ;
608
617
break ;
0 commit comments