@@ -392,13 +392,6 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
392
392
goto failure ;
393
393
}
394
394
395
- if (!is_power_of_2 (vsi -> rx_rings [qid ]-> count ) ||
396
- !is_power_of_2 (vsi -> tx_rings [qid ]-> count )) {
397
- netdev_err (vsi -> netdev , "Please align ring sizes to power of 2\n" );
398
- pool_failure = - EINVAL ;
399
- goto failure ;
400
- }
401
-
402
395
if_running = netif_running (vsi -> netdev ) && ice_is_xdp_ena_vsi (vsi );
403
396
404
397
if (if_running ) {
@@ -534,11 +527,10 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
534
527
bool ice_alloc_rx_bufs_zc (struct ice_rx_ring * rx_ring , u16 count )
535
528
{
536
529
u16 rx_thresh = ICE_RING_QUARTER (rx_ring );
537
- u16 batched , leftover , i , tail_bumps ;
530
+ u16 leftover , i , tail_bumps ;
538
531
539
- batched = ALIGN_DOWN (count , rx_thresh );
540
- tail_bumps = batched / rx_thresh ;
541
- leftover = count & (rx_thresh - 1 );
532
+ tail_bumps = count / rx_thresh ;
533
+ leftover = count - (tail_bumps * rx_thresh );
542
534
543
535
for (i = 0 ; i < tail_bumps ; i ++ )
544
536
if (!__ice_alloc_rx_bufs_zc (rx_ring , rx_thresh ))
@@ -788,69 +780,57 @@ ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, struct ice_tx_buf *tx_buf)
788
780
}
789
781
790
782
/**
791
- * ice_clean_xdp_irq_zc - Reclaim resources after transmit completes on XDP ring
792
- * @xdp_ring: XDP ring to clean
793
- * @napi_budget: amount of descriptors that NAPI allows us to clean
794
- *
795
- * Returns count of cleaned descriptors
783
+ * ice_clean_xdp_irq_zc - produce AF_XDP descriptors to CQ
784
+ * @xdp_ring: XDP Tx ring
796
785
*/
797
- static u16 ice_clean_xdp_irq_zc (struct ice_tx_ring * xdp_ring , int napi_budget )
786
+ static void ice_clean_xdp_irq_zc (struct ice_tx_ring * xdp_ring )
798
787
{
799
- u16 tx_thresh = ICE_RING_QUARTER (xdp_ring );
800
- int budget = napi_budget / tx_thresh ;
801
- u16 next_dd = xdp_ring -> next_dd ;
802
- u16 ntc , cleared_dds = 0 ;
803
-
804
- do {
805
- struct ice_tx_desc * next_dd_desc ;
806
- u16 desc_cnt = xdp_ring -> count ;
807
- struct ice_tx_buf * tx_buf ;
808
- u32 xsk_frames ;
809
- u16 i ;
810
-
811
- next_dd_desc = ICE_TX_DESC (xdp_ring , next_dd );
812
- if (!(next_dd_desc -> cmd_type_offset_bsz &
813
- cpu_to_le64 (ICE_TX_DESC_DTYPE_DESC_DONE )))
814
- break ;
788
+ u16 ntc = xdp_ring -> next_to_clean ;
789
+ struct ice_tx_desc * tx_desc ;
790
+ u16 cnt = xdp_ring -> count ;
791
+ struct ice_tx_buf * tx_buf ;
792
+ u16 xsk_frames = 0 ;
793
+ u16 last_rs ;
794
+ int i ;
815
795
816
- cleared_dds ++ ;
817
- xsk_frames = 0 ;
818
- if (likely (!xdp_ring -> xdp_tx_active )) {
819
- xsk_frames = tx_thresh ;
820
- goto skip ;
821
- }
796
+ last_rs = xdp_ring -> next_to_use ? xdp_ring -> next_to_use - 1 : cnt - 1 ;
797
+ tx_desc = ICE_TX_DESC (xdp_ring , last_rs );
798
+ if ((tx_desc -> cmd_type_offset_bsz &
799
+ cpu_to_le64 (ICE_TX_DESC_DTYPE_DESC_DONE ))) {
800
+ if (last_rs >= ntc )
801
+ xsk_frames = last_rs - ntc + 1 ;
802
+ else
803
+ xsk_frames = last_rs + cnt - ntc + 1 ;
804
+ }
822
805
823
- ntc = xdp_ring -> next_to_clean ;
806
+ if (!xsk_frames )
807
+ return ;
824
808
825
- for ( i = 0 ; i < tx_thresh ; i ++ ) {
826
- tx_buf = & xdp_ring -> tx_buf [ ntc ] ;
809
+ if ( likely (! xdp_ring -> xdp_tx_active ))
810
+ goto skip ;
827
811
828
- if (tx_buf -> raw_buf ) {
829
- ice_clean_xdp_tx_buf (xdp_ring , tx_buf );
830
- tx_buf -> raw_buf = NULL ;
831
- } else {
832
- xsk_frames ++ ;
833
- }
812
+ ntc = xdp_ring -> next_to_clean ;
813
+ for (i = 0 ; i < xsk_frames ; i ++ ) {
814
+ tx_buf = & xdp_ring -> tx_buf [ntc ];
834
815
835
- ntc ++ ;
836
- if (ntc >= xdp_ring -> count )
837
- ntc = 0 ;
816
+ if (tx_buf -> raw_buf ) {
817
+ ice_clean_xdp_tx_buf (xdp_ring , tx_buf );
818
+ tx_buf -> raw_buf = NULL ;
819
+ } else {
820
+ xsk_frames ++ ;
838
821
}
822
+
823
+ ntc ++ ;
824
+ if (ntc >= xdp_ring -> count )
825
+ ntc = 0 ;
826
+ }
839
827
skip :
840
- xdp_ring -> next_to_clean += tx_thresh ;
841
- if (xdp_ring -> next_to_clean >= desc_cnt )
842
- xdp_ring -> next_to_clean -= desc_cnt ;
843
- if (xsk_frames )
844
- xsk_tx_completed (xdp_ring -> xsk_pool , xsk_frames );
845
- next_dd_desc -> cmd_type_offset_bsz = 0 ;
846
- next_dd = next_dd + tx_thresh ;
847
- if (next_dd >= desc_cnt )
848
- next_dd = tx_thresh - 1 ;
849
- } while (-- budget );
850
-
851
- xdp_ring -> next_dd = next_dd ;
852
-
853
- return cleared_dds * tx_thresh ;
828
+ tx_desc -> cmd_type_offset_bsz = 0 ;
829
+ xdp_ring -> next_to_clean += xsk_frames ;
830
+ if (xdp_ring -> next_to_clean >= cnt )
831
+ xdp_ring -> next_to_clean -= cnt ;
832
+ if (xsk_frames )
833
+ xsk_tx_completed (xdp_ring -> xsk_pool , xsk_frames );
854
834
}
855
835
856
836
/**
@@ -885,7 +865,6 @@ static void ice_xmit_pkt(struct ice_tx_ring *xdp_ring, struct xdp_desc *desc,
885
865
static void ice_xmit_pkt_batch (struct ice_tx_ring * xdp_ring , struct xdp_desc * descs ,
886
866
unsigned int * total_bytes )
887
867
{
888
- u16 tx_thresh = ICE_RING_QUARTER (xdp_ring );
889
868
u16 ntu = xdp_ring -> next_to_use ;
890
869
struct ice_tx_desc * tx_desc ;
891
870
u32 i ;
@@ -905,13 +884,6 @@ static void ice_xmit_pkt_batch(struct ice_tx_ring *xdp_ring, struct xdp_desc *de
905
884
}
906
885
907
886
xdp_ring -> next_to_use = ntu ;
908
-
909
- if (xdp_ring -> next_to_use > xdp_ring -> next_rs ) {
910
- tx_desc = ICE_TX_DESC (xdp_ring , xdp_ring -> next_rs );
911
- tx_desc -> cmd_type_offset_bsz |=
912
- cpu_to_le64 (ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S );
913
- xdp_ring -> next_rs += tx_thresh ;
914
- }
915
887
}
916
888
917
889
/**
@@ -924,7 +896,6 @@ static void ice_xmit_pkt_batch(struct ice_tx_ring *xdp_ring, struct xdp_desc *de
924
896
static void ice_fill_tx_hw_ring (struct ice_tx_ring * xdp_ring , struct xdp_desc * descs ,
925
897
u32 nb_pkts , unsigned int * total_bytes )
926
898
{
927
- u16 tx_thresh = ICE_RING_QUARTER (xdp_ring );
928
899
u32 batched , leftover , i ;
929
900
930
901
batched = ALIGN_DOWN (nb_pkts , PKTS_PER_BATCH );
@@ -933,54 +904,54 @@ static void ice_fill_tx_hw_ring(struct ice_tx_ring *xdp_ring, struct xdp_desc *d
933
904
ice_xmit_pkt_batch (xdp_ring , & descs [i ], total_bytes );
934
905
for (; i < batched + leftover ; i ++ )
935
906
ice_xmit_pkt (xdp_ring , & descs [i ], total_bytes );
907
+ }
936
908
937
- if (xdp_ring -> next_to_use > xdp_ring -> next_rs ) {
938
- struct ice_tx_desc * tx_desc ;
909
+ /**
910
+ * ice_set_rs_bit - set RS bit on last produced descriptor (one behind current NTU)
911
+ * @xdp_ring: XDP ring to produce the HW Tx descriptors on
912
+ */
913
+ static void ice_set_rs_bit (struct ice_tx_ring * xdp_ring )
914
+ {
915
+ u16 ntu = xdp_ring -> next_to_use ? xdp_ring -> next_to_use - 1 : xdp_ring -> count - 1 ;
916
+ struct ice_tx_desc * tx_desc ;
939
917
940
- tx_desc = ICE_TX_DESC (xdp_ring , xdp_ring -> next_rs );
941
- tx_desc -> cmd_type_offset_bsz |=
942
- cpu_to_le64 (ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S );
943
- xdp_ring -> next_rs += tx_thresh ;
944
- }
918
+ tx_desc = ICE_TX_DESC (xdp_ring , ntu );
919
+ tx_desc -> cmd_type_offset_bsz |=
920
+ cpu_to_le64 (ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S );
945
921
}
946
922
947
923
/**
948
924
* ice_xmit_zc - take entries from XSK Tx ring and place them onto HW Tx ring
949
925
* @xdp_ring: XDP ring to produce the HW Tx descriptors on
950
- * @budget: number of free descriptors on HW Tx ring that can be used
951
- * @napi_budget: amount of descriptors that NAPI allows us to clean
952
926
*
953
927
* Returns true if there is no more work that needs to be done, false otherwise
954
928
*/
955
- bool ice_xmit_zc (struct ice_tx_ring * xdp_ring , u32 budget , int napi_budget )
929
+ bool ice_xmit_zc (struct ice_tx_ring * xdp_ring )
956
930
{
957
931
struct xdp_desc * descs = xdp_ring -> xsk_pool -> tx_descs ;
958
- u16 tx_thresh = ICE_RING_QUARTER (xdp_ring );
959
932
u32 nb_pkts , nb_processed = 0 ;
960
933
unsigned int total_bytes = 0 ;
934
+ int budget ;
935
+
936
+ ice_clean_xdp_irq_zc (xdp_ring );
961
937
962
- if ( budget < tx_thresh )
963
- budget += ice_clean_xdp_irq_zc ( xdp_ring , napi_budget );
938
+ budget = ICE_DESC_UNUSED ( xdp_ring );
939
+ budget = min_t ( u16 , budget , ICE_RING_QUARTER ( xdp_ring ) );
964
940
965
941
nb_pkts = xsk_tx_peek_release_desc_batch (xdp_ring -> xsk_pool , budget );
966
942
if (!nb_pkts )
967
943
return true;
968
944
969
945
if (xdp_ring -> next_to_use + nb_pkts >= xdp_ring -> count ) {
970
- struct ice_tx_desc * tx_desc ;
971
-
972
946
nb_processed = xdp_ring -> count - xdp_ring -> next_to_use ;
973
947
ice_fill_tx_hw_ring (xdp_ring , descs , nb_processed , & total_bytes );
974
- tx_desc = ICE_TX_DESC (xdp_ring , xdp_ring -> next_rs );
975
- tx_desc -> cmd_type_offset_bsz |=
976
- cpu_to_le64 (ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S );
977
- xdp_ring -> next_rs = tx_thresh - 1 ;
978
948
xdp_ring -> next_to_use = 0 ;
979
949
}
980
950
981
951
ice_fill_tx_hw_ring (xdp_ring , & descs [nb_processed ], nb_pkts - nb_processed ,
982
952
& total_bytes );
983
953
954
+ ice_set_rs_bit (xdp_ring );
984
955
ice_xdp_ring_update_tail (xdp_ring );
985
956
ice_update_tx_ring_stats (xdp_ring , nb_pkts , total_bytes );
986
957
@@ -1058,14 +1029,16 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi)
1058
1029
*/
1059
1030
void ice_xsk_clean_rx_ring (struct ice_rx_ring * rx_ring )
1060
1031
{
1061
- u16 count_mask = rx_ring -> count - 1 ;
1062
1032
u16 ntc = rx_ring -> next_to_clean ;
1063
1033
u16 ntu = rx_ring -> next_to_use ;
1064
1034
1065
- for ( ; ntc != ntu ; ntc = ( ntc + 1 ) & count_mask ) {
1035
+ while ( ntc != ntu ) {
1066
1036
struct xdp_buff * xdp = * ice_xdp_buf (rx_ring , ntc );
1067
1037
1068
1038
xsk_buff_free (xdp );
1039
+ ntc ++ ;
1040
+ if (ntc >= rx_ring -> count )
1041
+ ntc = 0 ;
1069
1042
}
1070
1043
}
1071
1044
0 commit comments