@@ -59,6 +59,41 @@ static const struct hns3_stats hns3_rxq_stats[] = {
59
59
60
60
#define HNS3_TQP_STATS_COUNT (HNS3_TXQ_STATS_COUNT + HNS3_RXQ_STATS_COUNT)
61
61
62
+ /* netdev stats */
63
+ #define HNS3_NETDEV_STAT (_string , _member ) { \
64
+ .stats_string = _string, \
65
+ .stats_offset = offsetof(struct rtnl_link_stats64, _member) \
66
+ }
67
+
68
+ static const struct hns3_stats hns3_netdev_stats [] = {
69
+ /* Rx per-queue statistics */
70
+ HNS3_NETDEV_STAT ("rx_packets" , rx_packets ),
71
+ HNS3_NETDEV_STAT ("tx_packets" , tx_packets ),
72
+ HNS3_NETDEV_STAT ("rx_bytes" , rx_bytes ),
73
+ HNS3_NETDEV_STAT ("tx_bytes" , tx_bytes ),
74
+ HNS3_NETDEV_STAT ("rx_errors" , rx_errors ),
75
+ HNS3_NETDEV_STAT ("tx_errors" , tx_errors ),
76
+ HNS3_NETDEV_STAT ("rx_dropped" , rx_dropped ),
77
+ HNS3_NETDEV_STAT ("tx_dropped" , tx_dropped ),
78
+ HNS3_NETDEV_STAT ("multicast" , multicast ),
79
+ HNS3_NETDEV_STAT ("collisions" , collisions ),
80
+ HNS3_NETDEV_STAT ("rx_length_errors" , rx_length_errors ),
81
+ HNS3_NETDEV_STAT ("rx_over_errors" , rx_over_errors ),
82
+ HNS3_NETDEV_STAT ("rx_crc_errors" , rx_crc_errors ),
83
+ HNS3_NETDEV_STAT ("rx_frame_errors" , rx_frame_errors ),
84
+ HNS3_NETDEV_STAT ("rx_fifo_errors" , rx_fifo_errors ),
85
+ HNS3_NETDEV_STAT ("rx_missed_errors" , rx_missed_errors ),
86
+ HNS3_NETDEV_STAT ("tx_aborted_errors" , tx_aborted_errors ),
87
+ HNS3_NETDEV_STAT ("tx_carrier_errors" , tx_carrier_errors ),
88
+ HNS3_NETDEV_STAT ("tx_fifo_errors" , tx_fifo_errors ),
89
+ HNS3_NETDEV_STAT ("tx_heartbeat_errors" , tx_heartbeat_errors ),
90
+ HNS3_NETDEV_STAT ("tx_window_errors" , tx_window_errors ),
91
+ HNS3_NETDEV_STAT ("rx_compressed" , rx_compressed ),
92
+ HNS3_NETDEV_STAT ("tx_compressed" , tx_compressed ),
93
+ };
94
+
95
+ #define HNS3_NETDEV_STATS_COUNT ARRAY_SIZE(hns3_netdev_stats)
96
+
62
97
#define HNS3_SELF_TEST_TPYE_NUM 1
63
98
#define HNS3_NIC_LB_TEST_PKT_NUM 1
64
99
#define HNS3_NIC_LB_TEST_RING_ID 0
@@ -431,6 +466,27 @@ static u8 *hns3_get_strings_tqps(struct hnae3_handle *handle, u8 *data)
431
466
return data ;
432
467
}
433
468
469
+ static u8 * hns3_netdev_stats_get_strings (u8 * data )
470
+ {
471
+ int i ;
472
+
473
+ /* get strings for netdev */
474
+ for (i = 0 ; i < HNS3_NETDEV_STATS_COUNT ; i ++ ) {
475
+ snprintf (data , ETH_GSTRING_LEN ,
476
+ hns3_netdev_stats [i ].stats_string );
477
+ data += ETH_GSTRING_LEN ;
478
+ }
479
+
480
+ snprintf (data , ETH_GSTRING_LEN , "netdev_rx_dropped" );
481
+ data += ETH_GSTRING_LEN ;
482
+ snprintf (data , ETH_GSTRING_LEN , "netdev_tx_dropped" );
483
+ data += ETH_GSTRING_LEN ;
484
+ snprintf (data , ETH_GSTRING_LEN , "netdev_tx_timeout" );
485
+ data += ETH_GSTRING_LEN ;
486
+
487
+ return data ;
488
+ }
489
+
434
490
static void hns3_get_strings (struct net_device * netdev , u32 stringset , u8 * data )
435
491
{
436
492
struct hnae3_handle * h = hns3_get_handle (netdev );
@@ -442,6 +498,7 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
442
498
443
499
switch (stringset ) {
444
500
case ETH_SS_STATS :
501
+ buff = hns3_netdev_stats_get_strings (buff );
445
502
buff = hns3_get_strings_tqps (h , buff );
446
503
h -> ae_algo -> ops -> get_strings (h , stringset , (u8 * )buff );
447
504
break ;
@@ -480,6 +537,27 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
480
537
return data ;
481
538
}
482
539
540
+ static u64 * hns3_get_netdev_stats (struct net_device * netdev , u64 * data )
541
+ {
542
+ struct hns3_nic_priv * priv = netdev_priv (netdev );
543
+ const struct rtnl_link_stats64 * net_stats ;
544
+ struct rtnl_link_stats64 temp ;
545
+ u8 * stat ;
546
+ int i ;
547
+
548
+ net_stats = dev_get_stats (netdev , & temp );
549
+ for (i = 0 ; i < HNS3_NETDEV_STATS_COUNT ; i ++ ) {
550
+ stat = (u8 * )net_stats + hns3_netdev_stats [i ].stats_offset ;
551
+ * data ++ = * (u64 * )stat ;
552
+ }
553
+
554
+ * data ++ = netdev -> rx_dropped .counter ;
555
+ * data ++ = netdev -> tx_dropped .counter ;
556
+ * data ++ = priv -> tx_timeout_count ;
557
+
558
+ return data ;
559
+ }
560
+
483
561
/* hns3_get_stats - get detail statistics.
484
562
* @netdev: net device
485
563
* @stats: statistics info.
@@ -496,7 +574,7 @@ static void hns3_get_stats(struct net_device *netdev,
496
574
return ;
497
575
}
498
576
499
- h -> ae_algo -> ops -> update_stats ( h , & netdev -> stats );
577
+ p = hns3_get_netdev_stats ( netdev , p );
500
578
501
579
/* get per-queue stats */
502
580
p = hns3_get_stats_tqps (h , p );
0 commit comments