13
13
#include <linux/cpumask.h>
14
14
#include <linux/crash_dump.h>
15
15
#include <linux/vmalloc.h>
16
+ #include <net/page_pool/helpers.h>
16
17
17
18
#include "ionic.h"
18
19
#include "ionic_bus.h"
@@ -439,6 +440,9 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq)
439
440
qcq -> sg_base_pa = 0 ;
440
441
}
441
442
443
+ page_pool_destroy (qcq -> q .page_pool );
444
+ qcq -> q .page_pool = NULL ;
445
+
442
446
ionic_qcq_intr_free (lif , qcq );
443
447
vfree (qcq -> q .info );
444
448
qcq -> q .info = NULL ;
@@ -553,7 +557,8 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
553
557
unsigned int cq_desc_size ,
554
558
unsigned int sg_desc_size ,
555
559
unsigned int desc_info_size ,
556
- unsigned int pid , struct ionic_qcq * * qcq )
560
+ unsigned int pid , struct bpf_prog * xdp_prog ,
561
+ struct ionic_qcq * * qcq )
557
562
{
558
563
struct ionic_dev * idev = & lif -> ionic -> idev ;
559
564
struct device * dev = lif -> ionic -> dev ;
@@ -579,19 +584,44 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
579
584
goto err_out_free_qcq ;
580
585
}
581
586
587
+ if (type == IONIC_QTYPE_RXQ ) {
588
+ struct page_pool_params pp_params = {
589
+ .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV ,
590
+ .order = 0 ,
591
+ .pool_size = num_descs ,
592
+ .nid = NUMA_NO_NODE ,
593
+ .dev = lif -> ionic -> dev ,
594
+ .napi = & new -> napi ,
595
+ .dma_dir = DMA_FROM_DEVICE ,
596
+ .max_len = PAGE_SIZE ,
597
+ .netdev = lif -> netdev ,
598
+ };
599
+
600
+ if (xdp_prog )
601
+ pp_params .dma_dir = DMA_BIDIRECTIONAL ;
602
+
603
+ new -> q .page_pool = page_pool_create (& pp_params );
604
+ if (IS_ERR (new -> q .page_pool )) {
605
+ netdev_err (lif -> netdev , "Cannot create page_pool\n" );
606
+ err = PTR_ERR (new -> q .page_pool );
607
+ new -> q .page_pool = NULL ;
608
+ goto err_out_free_q_info ;
609
+ }
610
+ }
611
+
582
612
new -> q .type = type ;
583
613
new -> q .max_sg_elems = lif -> qtype_info [type ].max_sg_elems ;
584
614
585
615
err = ionic_q_init (lif , idev , & new -> q , index , name , num_descs ,
586
616
desc_size , sg_desc_size , pid );
587
617
if (err ) {
588
618
netdev_err (lif -> netdev , "Cannot initialize queue\n" );
589
- goto err_out_free_q_info ;
619
+ goto err_out_free_page_pool ;
590
620
}
591
621
592
622
err = ionic_alloc_qcq_interrupt (lif , new );
593
623
if (err )
594
- goto err_out_free_q_info ;
624
+ goto err_out_free_page_pool ;
595
625
596
626
err = ionic_cq_init (lif , & new -> cq , & new -> intr , num_descs , cq_desc_size );
597
627
if (err ) {
@@ -712,6 +742,8 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
712
742
devm_free_irq (dev , new -> intr .vector , & new -> napi );
713
743
ionic_intr_free (lif -> ionic , new -> intr .index );
714
744
}
745
+ err_out_free_page_pool :
746
+ page_pool_destroy (new -> q .page_pool );
715
747
err_out_free_q_info :
716
748
vfree (new -> q .info );
717
749
err_out_free_qcq :
@@ -734,7 +766,7 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif)
734
766
sizeof (struct ionic_admin_comp ),
735
767
0 ,
736
768
sizeof (struct ionic_admin_desc_info ),
737
- lif -> kern_pid , & lif -> adminqcq );
769
+ lif -> kern_pid , NULL , & lif -> adminqcq );
738
770
if (err )
739
771
return err ;
740
772
ionic_debugfs_add_qcq (lif , lif -> adminqcq );
@@ -747,7 +779,7 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif)
747
779
sizeof (union ionic_notifyq_comp ),
748
780
0 ,
749
781
sizeof (struct ionic_admin_desc_info ),
750
- lif -> kern_pid , & lif -> notifyqcq );
782
+ lif -> kern_pid , NULL , & lif -> notifyqcq );
751
783
if (err )
752
784
goto err_out ;
753
785
ionic_debugfs_add_qcq (lif , lif -> notifyqcq );
@@ -965,7 +997,7 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif)
965
997
err = ionic_qcq_alloc (lif , IONIC_QTYPE_TXQ , txq_i , "hwstamp_tx" , flags ,
966
998
num_desc , desc_sz , comp_sz , sg_desc_sz ,
967
999
sizeof (struct ionic_tx_desc_info ),
968
- lif -> kern_pid , & txq );
1000
+ lif -> kern_pid , NULL , & txq );
969
1001
if (err )
970
1002
goto err_qcq_alloc ;
971
1003
@@ -1025,7 +1057,7 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif)
1025
1057
err = ionic_qcq_alloc (lif , IONIC_QTYPE_RXQ , rxq_i , "hwstamp_rx" , flags ,
1026
1058
num_desc , desc_sz , comp_sz , sg_desc_sz ,
1027
1059
sizeof (struct ionic_rx_desc_info ),
1028
- lif -> kern_pid , & rxq );
1060
+ lif -> kern_pid , NULL , & rxq );
1029
1061
if (err )
1030
1062
goto err_qcq_alloc ;
1031
1063
@@ -2051,7 +2083,7 @@ static int ionic_txrx_alloc(struct ionic_lif *lif)
2051
2083
err = ionic_qcq_alloc (lif , IONIC_QTYPE_TXQ , i , "tx" , flags ,
2052
2084
num_desc , desc_sz , comp_sz , sg_desc_sz ,
2053
2085
sizeof (struct ionic_tx_desc_info ),
2054
- lif -> kern_pid , & lif -> txqcqs [i ]);
2086
+ lif -> kern_pid , NULL , & lif -> txqcqs [i ]);
2055
2087
if (err )
2056
2088
goto err_out ;
2057
2089
@@ -2083,7 +2115,8 @@ static int ionic_txrx_alloc(struct ionic_lif *lif)
2083
2115
err = ionic_qcq_alloc (lif , IONIC_QTYPE_RXQ , i , "rx" , flags ,
2084
2116
num_desc , desc_sz , comp_sz , sg_desc_sz ,
2085
2117
sizeof (struct ionic_rx_desc_info ),
2086
- lif -> kern_pid , & lif -> rxqcqs [i ]);
2118
+ lif -> kern_pid , lif -> xdp_prog ,
2119
+ & lif -> rxqcqs [i ]);
2087
2120
if (err )
2088
2121
goto err_out ;
2089
2122
@@ -2679,15 +2712,15 @@ static int ionic_register_rxq_info(struct ionic_queue *q, unsigned int napi_id)
2679
2712
2680
2713
err = xdp_rxq_info_reg (rxq_info , q -> lif -> netdev , q -> index , napi_id );
2681
2714
if (err ) {
2682
- dev_err (q -> dev , "Queue %d xdp_rxq_info_reg failed, err %d\n" ,
2683
- q -> index , err );
2715
+ netdev_err (q -> lif -> netdev , "q %d xdp_rxq_info_reg failed, err %d\n" ,
2716
+ q -> index , err );
2684
2717
goto err_out ;
2685
2718
}
2686
2719
2687
- err = xdp_rxq_info_reg_mem_model (rxq_info , MEM_TYPE_PAGE_ORDER0 , NULL );
2720
+ err = xdp_rxq_info_reg_mem_model (rxq_info , MEM_TYPE_PAGE_POOL , q -> page_pool );
2688
2721
if (err ) {
2689
- dev_err (q -> dev , "Queue %d xdp_rxq_info_reg_mem_model failed, err %d\n" ,
2690
- q -> index , err );
2722
+ netdev_err (q -> lif -> netdev , "q %d xdp_rxq_info_reg_mem_model failed, err %d\n" ,
2723
+ q -> index , err );
2691
2724
xdp_rxq_info_unreg (rxq_info );
2692
2725
goto err_out ;
2693
2726
}
@@ -2853,7 +2886,16 @@ static int ionic_cmb_reconfig(struct ionic_lif *lif,
2853
2886
2854
2887
static void ionic_swap_queues (struct ionic_qcq * a , struct ionic_qcq * b )
2855
2888
{
2856
- /* only swapping the queues, not the napi, flags, or other stuff */
2889
+ /* only swapping the queues and napi, not flags or other stuff */
2890
+ swap (a -> napi , b -> napi );
2891
+
2892
+ if (a -> q .type == IONIC_QTYPE_RXQ ) {
2893
+ swap (a -> q .page_pool , b -> q .page_pool );
2894
+ a -> q .page_pool -> p .napi = & a -> napi ;
2895
+ if (b -> q .page_pool ) /* is NULL when increasing queue count */
2896
+ b -> q .page_pool -> p .napi = & b -> napi ;
2897
+ }
2898
+
2857
2899
swap (a -> q .features , b -> q .features );
2858
2900
swap (a -> q .num_descs , b -> q .num_descs );
2859
2901
swap (a -> q .desc_size , b -> q .desc_size );
@@ -2943,7 +2985,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif,
2943
2985
err = ionic_qcq_alloc (lif , IONIC_QTYPE_TXQ , i , "tx" , flags ,
2944
2986
4 , desc_sz , comp_sz , sg_desc_sz ,
2945
2987
sizeof (struct ionic_tx_desc_info ),
2946
- lif -> kern_pid , & lif -> txqcqs [i ]);
2988
+ lif -> kern_pid , NULL , & lif -> txqcqs [i ]);
2947
2989
if (err )
2948
2990
goto err_out ;
2949
2991
}
@@ -2952,7 +2994,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif,
2952
2994
err = ionic_qcq_alloc (lif , IONIC_QTYPE_TXQ , i , "tx" , flags ,
2953
2995
num_desc , desc_sz , comp_sz , sg_desc_sz ,
2954
2996
sizeof (struct ionic_tx_desc_info ),
2955
- lif -> kern_pid , & tx_qcqs [i ]);
2997
+ lif -> kern_pid , NULL , & tx_qcqs [i ]);
2956
2998
if (err )
2957
2999
goto err_out ;
2958
3000
}
@@ -2974,7 +3016,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif,
2974
3016
err = ionic_qcq_alloc (lif , IONIC_QTYPE_RXQ , i , "rx" , flags ,
2975
3017
4 , desc_sz , comp_sz , sg_desc_sz ,
2976
3018
sizeof (struct ionic_rx_desc_info ),
2977
- lif -> kern_pid , & lif -> rxqcqs [i ]);
3019
+ lif -> kern_pid , NULL , & lif -> rxqcqs [i ]);
2978
3020
if (err )
2979
3021
goto err_out ;
2980
3022
}
@@ -2983,7 +3025,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif,
2983
3025
err = ionic_qcq_alloc (lif , IONIC_QTYPE_RXQ , i , "rx" , flags ,
2984
3026
num_desc , desc_sz , comp_sz , sg_desc_sz ,
2985
3027
sizeof (struct ionic_rx_desc_info ),
2986
- lif -> kern_pid , & rx_qcqs [i ]);
3028
+ lif -> kern_pid , qparam -> xdp_prog , & rx_qcqs [i ]);
2987
3029
if (err )
2988
3030
goto err_out ;
2989
3031
0 commit comments