@@ -87,7 +87,8 @@ struct virtnet_sq_stats {
87
87
u64 kicks ;
88
88
};
89
89
90
- struct virtnet_rq_stat_items {
90
+ struct virtnet_rq_stats {
91
+ struct u64_stats_sync syncp ;
91
92
u64 packets ;
92
93
u64 bytes ;
93
94
u64 drops ;
@@ -98,17 +99,8 @@ struct virtnet_rq_stat_items {
98
99
u64 kicks ;
99
100
};
100
101
101
- struct virtnet_rq_stats {
102
- struct u64_stats_sync syncp ;
103
- struct virtnet_rq_stat_items items ;
104
- };
105
-
106
- struct virtnet_rx_stats {
107
- struct virtnet_rq_stat_items rx ;
108
- };
109
-
110
102
#define VIRTNET_SQ_STAT (m ) offsetof(struct virtnet_sq_stats, m)
111
- #define VIRTNET_RQ_STAT (m ) offsetof(struct virtnet_rq_stat_items , m)
103
+ #define VIRTNET_RQ_STAT (m ) offsetof(struct virtnet_rq_stats , m)
112
104
113
105
static const struct virtnet_stat_desc virtnet_sq_stats_desc [] = {
114
106
{ "packets" , VIRTNET_SQ_STAT (packets ) },
@@ -617,7 +609,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
617
609
void * buf , void * ctx ,
618
610
unsigned int len ,
619
611
unsigned int * xdp_xmit ,
620
- struct virtnet_rx_stats * stats )
612
+ struct virtnet_rq_stats * stats )
621
613
{
622
614
struct sk_buff * skb ;
623
615
struct bpf_prog * xdp_prog ;
@@ -632,7 +624,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
632
624
int err ;
633
625
634
626
len -= vi -> hdr_len ;
635
- stats -> rx . bytes += len ;
627
+ stats -> bytes += len ;
636
628
637
629
rcu_read_lock ();
638
630
xdp_prog = rcu_dereference (rq -> xdp_prog );
@@ -674,7 +666,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
674
666
xdp .rxq = & rq -> xdp_rxq ;
675
667
orig_data = xdp .data ;
676
668
act = bpf_prog_run_xdp (xdp_prog , & xdp );
677
- stats -> rx . xdp_packets ++ ;
669
+ stats -> xdp_packets ++ ;
678
670
679
671
switch (act ) {
680
672
case XDP_PASS :
@@ -683,7 +675,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
683
675
len = xdp .data_end - xdp .data ;
684
676
break ;
685
677
case XDP_TX :
686
- stats -> rx . xdp_tx ++ ;
678
+ stats -> xdp_tx ++ ;
687
679
xdpf = convert_to_xdp_frame (& xdp );
688
680
if (unlikely (!xdpf ))
689
681
goto err_xdp ;
@@ -696,7 +688,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
696
688
rcu_read_unlock ();
697
689
goto xdp_xmit ;
698
690
case XDP_REDIRECT :
699
- stats -> rx . xdp_redirects ++ ;
691
+ stats -> xdp_redirects ++ ;
700
692
err = xdp_do_redirect (dev , & xdp , xdp_prog );
701
693
if (err )
702
694
goto err_xdp ;
@@ -730,8 +722,8 @@ static struct sk_buff *receive_small(struct net_device *dev,
730
722
731
723
err_xdp :
732
724
rcu_read_unlock ();
733
- stats -> rx . xdp_drops ++ ;
734
- stats -> rx . drops ++ ;
725
+ stats -> xdp_drops ++ ;
726
+ stats -> drops ++ ;
735
727
put_page (page );
736
728
xdp_xmit :
737
729
return NULL ;
@@ -742,19 +734,19 @@ static struct sk_buff *receive_big(struct net_device *dev,
742
734
struct receive_queue * rq ,
743
735
void * buf ,
744
736
unsigned int len ,
745
- struct virtnet_rx_stats * stats )
737
+ struct virtnet_rq_stats * stats )
746
738
{
747
739
struct page * page = buf ;
748
740
struct sk_buff * skb = page_to_skb (vi , rq , page , 0 , len , PAGE_SIZE );
749
741
750
- stats -> rx . bytes += len - vi -> hdr_len ;
742
+ stats -> bytes += len - vi -> hdr_len ;
751
743
if (unlikely (!skb ))
752
744
goto err ;
753
745
754
746
return skb ;
755
747
756
748
err :
757
- stats -> rx . drops ++ ;
749
+ stats -> drops ++ ;
758
750
give_pages (rq , page );
759
751
return NULL ;
760
752
}
@@ -766,7 +758,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
766
758
void * ctx ,
767
759
unsigned int len ,
768
760
unsigned int * xdp_xmit ,
769
- struct virtnet_rx_stats * stats )
761
+ struct virtnet_rq_stats * stats )
770
762
{
771
763
struct virtio_net_hdr_mrg_rxbuf * hdr = buf ;
772
764
u16 num_buf = virtio16_to_cpu (vi -> vdev , hdr -> num_buffers );
@@ -779,7 +771,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
779
771
int err ;
780
772
781
773
head_skb = NULL ;
782
- stats -> rx . bytes += len - vi -> hdr_len ;
774
+ stats -> bytes += len - vi -> hdr_len ;
783
775
784
776
rcu_read_lock ();
785
777
xdp_prog = rcu_dereference (rq -> xdp_prog );
@@ -828,7 +820,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
828
820
xdp .rxq = & rq -> xdp_rxq ;
829
821
830
822
act = bpf_prog_run_xdp (xdp_prog , & xdp );
831
- stats -> rx . xdp_packets ++ ;
823
+ stats -> xdp_packets ++ ;
832
824
833
825
switch (act ) {
834
826
case XDP_PASS :
@@ -853,7 +845,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
853
845
}
854
846
break ;
855
847
case XDP_TX :
856
- stats -> rx . xdp_tx ++ ;
848
+ stats -> xdp_tx ++ ;
857
849
xdpf = convert_to_xdp_frame (& xdp );
858
850
if (unlikely (!xdpf ))
859
851
goto err_xdp ;
@@ -870,7 +862,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
870
862
rcu_read_unlock ();
871
863
goto xdp_xmit ;
872
864
case XDP_REDIRECT :
873
- stats -> rx . xdp_redirects ++ ;
865
+ stats -> xdp_redirects ++ ;
874
866
err = xdp_do_redirect (dev , & xdp , xdp_prog );
875
867
if (err ) {
876
868
if (unlikely (xdp_page != page ))
@@ -920,7 +912,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
920
912
goto err_buf ;
921
913
}
922
914
923
- stats -> rx . bytes += len ;
915
+ stats -> bytes += len ;
924
916
page = virt_to_head_page (buf );
925
917
926
918
truesize = mergeable_ctx_to_truesize (ctx );
@@ -966,7 +958,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
966
958
967
959
err_xdp :
968
960
rcu_read_unlock ();
969
- stats -> rx . xdp_drops ++ ;
961
+ stats -> xdp_drops ++ ;
970
962
err_skb :
971
963
put_page (page );
972
964
while (num_buf -- > 1 ) {
@@ -977,12 +969,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
977
969
dev -> stats .rx_length_errors ++ ;
978
970
break ;
979
971
}
980
- stats -> rx . bytes += len ;
972
+ stats -> bytes += len ;
981
973
page = virt_to_head_page (buf );
982
974
put_page (page );
983
975
}
984
976
err_buf :
985
- stats -> rx . drops ++ ;
977
+ stats -> drops ++ ;
986
978
dev_kfree_skb (head_skb );
987
979
xdp_xmit :
988
980
return NULL ;
@@ -991,7 +983,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
991
983
static void receive_buf (struct virtnet_info * vi , struct receive_queue * rq ,
992
984
void * buf , unsigned int len , void * * ctx ,
993
985
unsigned int * xdp_xmit ,
994
- struct virtnet_rx_stats * stats )
986
+ struct virtnet_rq_stats * stats )
995
987
{
996
988
struct net_device * dev = vi -> dev ;
997
989
struct sk_buff * skb ;
@@ -1212,7 +1204,7 @@ static bool try_fill_recv(struct virtnet_info *vi, struct receive_queue *rq,
1212
1204
} while (rq -> vq -> num_free );
1213
1205
if (virtqueue_kick_prepare (rq -> vq ) && virtqueue_notify (rq -> vq )) {
1214
1206
u64_stats_update_begin (& rq -> stats .syncp );
1215
- rq -> stats .items . kicks ++ ;
1207
+ rq -> stats .kicks ++ ;
1216
1208
u64_stats_update_end (& rq -> stats .syncp );
1217
1209
}
1218
1210
@@ -1290,24 +1282,24 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
1290
1282
unsigned int * xdp_xmit )
1291
1283
{
1292
1284
struct virtnet_info * vi = rq -> vq -> vdev -> priv ;
1293
- struct virtnet_rx_stats stats = {};
1285
+ struct virtnet_rq_stats stats = {};
1294
1286
unsigned int len ;
1295
1287
void * buf ;
1296
1288
int i ;
1297
1289
1298
1290
if (!vi -> big_packets || vi -> mergeable_rx_bufs ) {
1299
1291
void * ctx ;
1300
1292
1301
- while (stats .rx . packets < budget &&
1293
+ while (stats .packets < budget &&
1302
1294
(buf = virtqueue_get_buf_ctx (rq -> vq , & len , & ctx ))) {
1303
1295
receive_buf (vi , rq , buf , len , ctx , xdp_xmit , & stats );
1304
- stats .rx . packets ++ ;
1296
+ stats .packets ++ ;
1305
1297
}
1306
1298
} else {
1307
- while (stats .rx . packets < budget &&
1299
+ while (stats .packets < budget &&
1308
1300
(buf = virtqueue_get_buf (rq -> vq , & len )) != NULL ) {
1309
1301
receive_buf (vi , rq , buf , len , NULL , xdp_xmit , & stats );
1310
- stats .rx . packets ++ ;
1302
+ stats .packets ++ ;
1311
1303
}
1312
1304
}
1313
1305
@@ -1321,12 +1313,12 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
1321
1313
size_t offset = virtnet_rq_stats_desc [i ].offset ;
1322
1314
u64 * item ;
1323
1315
1324
- item = (u64 * )((u8 * )& rq -> stats . items + offset );
1325
- * item += * (u64 * )((u8 * )& stats . rx + offset );
1316
+ item = (u64 * )((u8 * )& rq -> stats + offset );
1317
+ * item += * (u64 * )((u8 * )& stats + offset );
1326
1318
}
1327
1319
u64_stats_update_end (& rq -> stats .syncp );
1328
1320
1329
- return stats .rx . packets ;
1321
+ return stats .packets ;
1330
1322
}
1331
1323
1332
1324
static void free_old_xmit_skbs (struct send_queue * sq )
@@ -1686,9 +1678,9 @@ static void virtnet_stats(struct net_device *dev,
1686
1678
1687
1679
do {
1688
1680
start = u64_stats_fetch_begin_irq (& rq -> stats .syncp );
1689
- rpackets = rq -> stats .items . packets ;
1690
- rbytes = rq -> stats .items . bytes ;
1691
- rdrops = rq -> stats .items . drops ;
1681
+ rpackets = rq -> stats .packets ;
1682
+ rbytes = rq -> stats .bytes ;
1683
+ rdrops = rq -> stats .drops ;
1692
1684
} while (u64_stats_fetch_retry_irq (& rq -> stats .syncp , start ));
1693
1685
1694
1686
tot -> rx_packets += rpackets ;
@@ -2078,7 +2070,7 @@ static void virtnet_get_ethtool_stats(struct net_device *dev,
2078
2070
for (i = 0 ; i < vi -> curr_queue_pairs ; i ++ ) {
2079
2071
struct receive_queue * rq = & vi -> rq [i ];
2080
2072
2081
- stats_base = (u8 * )& rq -> stats . items ;
2073
+ stats_base = (u8 * )& rq -> stats ;
2082
2074
do {
2083
2075
start = u64_stats_fetch_begin_irq (& rq -> stats .syncp );
2084
2076
for (j = 0 ; j < VIRTNET_RQ_STATS_LEN ; j ++ ) {
0 commit comments