Skip to content

Commit

Permalink
net: hibmcge: Add support for dump statistics
Browse files Browse the repository at this point in the history
The driver supports many hw statistics. This patch supports
dump statistics through ethtool_ops and ndo.get_stats64().

The type of hw statistics register is u32,
To prevent the statistics register from overflowing,
the driver dump the statistics every 30 seconds.
in a scheduled task.

Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Jijie Shao authored and Paolo Abeni committed Mar 4, 2025
1 parent d1352f7 commit c0bf9bf
Show file tree
Hide file tree
Showing 6 changed files with 741 additions and 2 deletions.
111 changes: 111 additions & 0 deletions drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,115 @@ struct hbg_user_def {
struct ethtool_pauseparam pause_param;
};

struct hbg_stats {
u64 rx_desc_drop;
u64 rx_desc_l2_err_cnt;
u64 rx_desc_pkt_len_err_cnt;
u64 rx_desc_l3l4_err_cnt;
u64 rx_desc_l3_wrong_head_cnt;
u64 rx_desc_l3_csum_err_cnt;
u64 rx_desc_l3_len_err_cnt;
u64 rx_desc_l3_zero_ttl_cnt;
u64 rx_desc_l3_other_cnt;
u64 rx_desc_l4_err_cnt;
u64 rx_desc_l4_wrong_head_cnt;
u64 rx_desc_l4_len_err_cnt;
u64 rx_desc_l4_csum_err_cnt;
u64 rx_desc_l4_zero_port_num_cnt;
u64 rx_desc_l4_other_cnt;
u64 rx_desc_frag_cnt;
u64 rx_desc_ip_ver_err_cnt;
u64 rx_desc_ipv4_pkt_cnt;
u64 rx_desc_ipv6_pkt_cnt;
u64 rx_desc_no_ip_pkt_cnt;
u64 rx_desc_ip_pkt_cnt;
u64 rx_desc_tcp_pkt_cnt;
u64 rx_desc_udp_pkt_cnt;
u64 rx_desc_vlan_pkt_cnt;
u64 rx_desc_icmp_pkt_cnt;
u64 rx_desc_arp_pkt_cnt;
u64 rx_desc_rarp_pkt_cnt;
u64 rx_desc_multicast_pkt_cnt;
u64 rx_desc_broadcast_pkt_cnt;
u64 rx_desc_ipsec_pkt_cnt;
u64 rx_desc_ip_opt_pkt_cnt;
u64 rx_desc_key_not_match_cnt;

u64 rx_octets_total_ok_cnt;
u64 rx_uc_pkt_cnt;
u64 rx_mc_pkt_cnt;
u64 rx_bc_pkt_cnt;
u64 rx_vlan_pkt_cnt;
u64 rx_octets_bad_cnt;
u64 rx_octets_total_filt_cnt;
u64 rx_filt_pkt_cnt;
u64 rx_trans_pkt_cnt;
u64 rx_framesize_64;
u64 rx_framesize_65_127;
u64 rx_framesize_128_255;
u64 rx_framesize_256_511;
u64 rx_framesize_512_1023;
u64 rx_framesize_1024_1518;
u64 rx_framesize_bt_1518;
u64 rx_fcs_error_cnt;
u64 rx_data_error_cnt;
u64 rx_align_error_cnt;
u64 rx_pause_macctl_frame_cnt;
u64 rx_unknown_macctl_frame_cnt;
/* crc ok, > max_frm_size, < 2max_frm_size */
u64 rx_frame_long_err_cnt;
/* crc fail, > max_frm_size, < 2max_frm_size */
u64 rx_jabber_err_cnt;
/* > 2max_frm_size */
u64 rx_frame_very_long_err_cnt;
/* < 64byte, >= short_runts_thr */
u64 rx_frame_runt_err_cnt;
/* < short_runts_thr */
u64 rx_frame_short_err_cnt;
/* PCU: dropped when the RX FIFO is full.*/
u64 rx_overflow_cnt;
/* GMAC: the count of overflows of the RX FIFO */
u64 rx_overrun_cnt;
/* PCU: the count of buffer alloc errors in RX */
u64 rx_bufrq_err_cnt;
/* PCU: the count of write descriptor errors in RX */
u64 rx_we_err_cnt;
/* GMAC: the count of pkts that contain PAD but length is not 64 */
u64 rx_lengthfield_err_cnt;
u64 rx_fail_comma_cnt;

u64 rx_dma_err_cnt;

u64 tx_octets_total_ok_cnt;
u64 tx_uc_pkt_cnt;
u64 tx_mc_pkt_cnt;
u64 tx_bc_pkt_cnt;
u64 tx_vlan_pkt_cnt;
u64 tx_octets_bad_cnt;
u64 tx_trans_pkt_cnt;
u64 tx_pause_frame_cnt;
u64 tx_framesize_64;
u64 tx_framesize_65_127;
u64 tx_framesize_128_255;
u64 tx_framesize_256_511;
u64 tx_framesize_512_1023;
u64 tx_framesize_1024_1518;
u64 tx_framesize_bt_1518;
/* GMAC: the count of times that frames fail to be transmitted
* due to internal errors.
*/
u64 tx_underrun_err_cnt;
u64 tx_add_cs_fail_cnt;
/* PCU: the count of buffer free errors in TX */
u64 tx_bufrl_err_cnt;
u64 tx_crc_err_cnt;
u64 tx_drop_cnt;
u64 tx_excessive_length_drop_cnt;

u64 tx_timeout_cnt;
u64 tx_dma_err_cnt;
};

struct hbg_priv {
struct net_device *netdev;
struct pci_dev *pdev;
Expand All @@ -155,6 +264,8 @@ struct hbg_priv {
struct hbg_mac_filter filter;
enum hbg_reset_type reset_type;
struct hbg_user_def user_def;
struct hbg_stats stats;
struct delayed_work service_task;
};

#endif
Loading

0 comments on commit c0bf9bf

Please sign in to comment.