xref: /linux/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h (revision 3fd6c59042dbba50391e30862beac979491145fe)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) Meta Platforms, Inc. and affiliates. */
3 
4 #ifndef _FBNIC_HW_STATS_H_
5 #define _FBNIC_HW_STATS_H_
6 
7 #include <linux/ethtool.h>
8 
9 #include "fbnic_csr.h"
10 
11 struct fbnic_stat_counter {
12 	u64 value;
13 	union {
14 		u32 old_reg_value_32;
15 		u64 old_reg_value_64;
16 	} u;
17 	bool reported;
18 };
19 
20 struct fbnic_eth_mac_stats {
21 	struct fbnic_stat_counter FramesTransmittedOK;
22 	struct fbnic_stat_counter FramesReceivedOK;
23 	struct fbnic_stat_counter FrameCheckSequenceErrors;
24 	struct fbnic_stat_counter AlignmentErrors;
25 	struct fbnic_stat_counter OctetsTransmittedOK;
26 	struct fbnic_stat_counter FramesLostDueToIntMACXmitError;
27 	struct fbnic_stat_counter OctetsReceivedOK;
28 	struct fbnic_stat_counter FramesLostDueToIntMACRcvError;
29 	struct fbnic_stat_counter MulticastFramesXmittedOK;
30 	struct fbnic_stat_counter BroadcastFramesXmittedOK;
31 	struct fbnic_stat_counter MulticastFramesReceivedOK;
32 	struct fbnic_stat_counter BroadcastFramesReceivedOK;
33 	struct fbnic_stat_counter FrameTooLongErrors;
34 };
35 
36 struct fbnic_mac_stats {
37 	struct fbnic_eth_mac_stats eth_mac;
38 };
39 
40 struct fbnic_rpc_stats {
41 	struct fbnic_stat_counter unkn_etype, unkn_ext_hdr;
42 	struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp;
43 	struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err;
44 };
45 
46 struct fbnic_pcie_stats {
47 	struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword;
48 	struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword;
49 	struct fbnic_stat_counter ob_cpl_tlp, ob_cpl_dword;
50 
51 	struct fbnic_stat_counter ob_rd_no_tag;
52 	struct fbnic_stat_counter ob_rd_no_cpl_cred;
53 	struct fbnic_stat_counter ob_rd_no_np_cred;
54 };
55 
56 struct fbnic_hw_stats {
57 	struct fbnic_mac_stats mac;
58 	struct fbnic_rpc_stats rpc;
59 	struct fbnic_pcie_stats pcie;
60 };
61 
62 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
63 
64 void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
65 void fbnic_get_hw_stats32(struct fbnic_dev *fbd);
66 void fbnic_get_hw_stats(struct fbnic_dev *fbd);
67 
68 #endif /* _FBNIC_HW_STATS_H_ */
69