xref: /linux/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h (revision df9c299371054cb725eef730fd0f1d0fe2ed6bb0)
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_hw_stat {
21 	struct fbnic_stat_counter frames;
22 	struct fbnic_stat_counter bytes;
23 };
24 
25 struct fbnic_eth_mac_stats {
26 	struct fbnic_stat_counter FramesTransmittedOK;
27 	struct fbnic_stat_counter FramesReceivedOK;
28 	struct fbnic_stat_counter FrameCheckSequenceErrors;
29 	struct fbnic_stat_counter AlignmentErrors;
30 	struct fbnic_stat_counter OctetsTransmittedOK;
31 	struct fbnic_stat_counter FramesLostDueToIntMACXmitError;
32 	struct fbnic_stat_counter OctetsReceivedOK;
33 	struct fbnic_stat_counter FramesLostDueToIntMACRcvError;
34 	struct fbnic_stat_counter MulticastFramesXmittedOK;
35 	struct fbnic_stat_counter BroadcastFramesXmittedOK;
36 	struct fbnic_stat_counter MulticastFramesReceivedOK;
37 	struct fbnic_stat_counter BroadcastFramesReceivedOK;
38 	struct fbnic_stat_counter FrameTooLongErrors;
39 };
40 
41 struct fbnic_mac_stats {
42 	struct fbnic_eth_mac_stats eth_mac;
43 };
44 
45 struct fbnic_tmi_stats {
46 	struct fbnic_hw_stat drop;
47 	struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts;
48 };
49 
50 struct fbnic_tti_stats {
51 	struct fbnic_hw_stat cm_drop, frame_drop, tbi_drop;
52 };
53 
54 struct fbnic_rpc_stats {
55 	struct fbnic_stat_counter unkn_etype, unkn_ext_hdr;
56 	struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp;
57 	struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err;
58 };
59 
60 struct fbnic_rxb_enqueue_stats {
61 	struct fbnic_hw_stat drbo;
62 	struct fbnic_stat_counter integrity_err, mac_err;
63 	struct fbnic_stat_counter parser_err, frm_err;
64 };
65 
66 struct fbnic_rxb_fifo_stats {
67 	struct fbnic_hw_stat drop, trunc;
68 	struct fbnic_stat_counter trans_drop, trans_ecn;
69 	struct fbnic_stat_counter level;
70 };
71 
72 struct fbnic_rxb_dequeue_stats {
73 	struct fbnic_hw_stat intf, pbuf;
74 };
75 
76 struct fbnic_rxb_stats {
77 	struct fbnic_rxb_enqueue_stats enq[FBNIC_RXB_ENQUEUE_INDICES];
78 	struct fbnic_rxb_fifo_stats fifo[FBNIC_RXB_FIFO_INDICES];
79 	struct fbnic_rxb_dequeue_stats deq[FBNIC_RXB_DEQUEUE_INDICES];
80 };
81 
82 struct fbnic_hw_q_stats {
83 	struct fbnic_stat_counter rde_pkt_err;
84 	struct fbnic_stat_counter rde_pkt_cq_drop;
85 	struct fbnic_stat_counter rde_pkt_bdq_drop;
86 };
87 
88 struct fbnic_pcie_stats {
89 	struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword;
90 	struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword;
91 	struct fbnic_stat_counter ob_cpl_tlp, ob_cpl_dword;
92 
93 	struct fbnic_stat_counter ob_rd_no_tag;
94 	struct fbnic_stat_counter ob_rd_no_cpl_cred;
95 	struct fbnic_stat_counter ob_rd_no_np_cred;
96 };
97 
98 struct fbnic_hw_stats {
99 	struct fbnic_mac_stats mac;
100 	struct fbnic_tmi_stats tmi;
101 	struct fbnic_tti_stats tti;
102 	struct fbnic_rpc_stats rpc;
103 	struct fbnic_rxb_stats rxb;
104 	struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];
105 	struct fbnic_pcie_stats pcie;
106 };
107 
108 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
109 
110 void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
111 void fbnic_get_hw_q_stats(struct fbnic_dev *fbd,
112 			  struct fbnic_hw_q_stats *hw_q);
113 void fbnic_get_hw_stats32(struct fbnic_dev *fbd);
114 void fbnic_get_hw_stats(struct fbnic_dev *fbd);
115 
116 #endif /* _FBNIC_HW_STATS_H_ */
117