Debian Codegraph @

drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h

raw
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 #include <linux/spinlock.h>
9
10 #include "fbnic_csr.h"
11
12 struct fbnic_stat_counter {
13 u64 value;
14 union {
15 u32 old_reg_value_32;
16 u64 old_reg_value_64;
17 } u;
18 bool reported;
19 };
20
21 struct fbnic_hw_stat {
22 struct fbnic_stat_counter frames;
23 struct fbnic_stat_counter bytes;
24 };
25
26 struct fbnic_fec_stats {
27 struct fbnic_stat_counter corrected_blocks, uncorrectable_blocks;
28 };
29
30 struct fbnic_pcs_stats {
31 struct {
32 struct fbnic_stat_counter lanes[FBNIC_PCS_MAX_LANES];
33 } SymbolErrorDuringCarrier;
34 };
35
36 /* Note: not updated by fbnic_get_hw_stats() */
37 struct fbnic_eth_ctrl_stats {
38 struct fbnic_stat_counter MACControlFramesTransmitted;
39 struct fbnic_stat_counter MACControlFramesReceived;
40 };
41
42 /* Note: not updated by fbnic_get_hw_stats() */
43 struct fbnic_rmon_stats {
44 struct fbnic_stat_counter undersize_pkts;
45 struct fbnic_stat_counter oversize_pkts;
46 struct fbnic_stat_counter fragments;
47 struct fbnic_stat_counter jabbers;
48
49 struct fbnic_stat_counter hist[ETHTOOL_RMON_HIST_MAX];
50 struct fbnic_stat_counter hist_tx[ETHTOOL_RMON_HIST_MAX];
51 };
52
53 /* Note: not updated by fbnic_get_hw_stats() */
54 struct fbnic_pause_stats {
55 struct fbnic_stat_counter tx_pause_frames;
56 struct fbnic_stat_counter rx_pause_frames;
57 };
58
59 struct fbnic_eth_mac_stats {
60 struct fbnic_stat_counter FramesTransmittedOK;
61 struct fbnic_stat_counter FramesReceivedOK;
62 struct fbnic_stat_counter FrameCheckSequenceErrors;
63 struct fbnic_stat_counter AlignmentErrors;
64 struct fbnic_stat_counter OctetsTransmittedOK;
65 struct fbnic_stat_counter FramesLostDueToIntMACXmitError;
66 struct fbnic_stat_counter OctetsReceivedOK;
67 struct fbnic_stat_counter FramesLostDueToIntMACRcvError;
68 struct fbnic_stat_counter MulticastFramesXmittedOK;
69 struct fbnic_stat_counter BroadcastFramesXmittedOK;
70 struct fbnic_stat_counter MulticastFramesReceivedOK;
71 struct fbnic_stat_counter BroadcastFramesReceivedOK;
72 struct fbnic_stat_counter FrameTooLongErrors;
73 };
74
75 struct fbnic_phy_stats {
76 struct fbnic_fec_stats fec;
77 struct fbnic_pcs_stats pcs;
78 };
79
80 struct fbnic_mac_stats {
81 struct fbnic_eth_mac_stats eth_mac;
82 struct fbnic_pause_stats pause;
83 struct fbnic_eth_ctrl_stats eth_ctrl;
84 struct fbnic_rmon_stats rmon;
85 };
86
87 struct fbnic_tmi_stats {
88 struct fbnic_hw_stat drop;
89 struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts;
90 };
91
92 struct fbnic_tti_stats {
93 struct fbnic_hw_stat cm_drop, frame_drop, tbi_drop;
94 };
95
96 struct fbnic_rpc_stats {
97 struct fbnic_stat_counter unkn_etype, unkn_ext_hdr;
98 struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp;
99 struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err;
100 };
101
102 struct fbnic_rxb_enqueue_stats {
103 struct fbnic_hw_stat drbo;
104 struct fbnic_stat_counter integrity_err, mac_err;
105 struct fbnic_stat_counter parser_err, frm_err;
106 };
107
108 struct fbnic_rxb_fifo_stats {
109 struct fbnic_hw_stat drop, trunc;
110 struct fbnic_stat_counter trans_drop, trans_ecn;
111 struct fbnic_stat_counter level;
112 };
113
114 struct fbnic_rxb_dequeue_stats {
115 struct fbnic_hw_stat intf, pbuf;
116 };
117
118 struct fbnic_rxb_stats {
119 struct fbnic_rxb_enqueue_stats enq[FBNIC_RXB_ENQUEUE_INDICES];
120 struct fbnic_rxb_fifo_stats fifo[FBNIC_RXB_FIFO_INDICES];
121 struct fbnic_rxb_dequeue_stats deq[FBNIC_RXB_DEQUEUE_INDICES];
122 };
123
124 struct fbnic_hw_q_stats {
125 struct fbnic_stat_counter rde_pkt_err;
126 struct fbnic_stat_counter rde_pkt_cq_drop;
127 struct fbnic_stat_counter rde_pkt_bdq_drop;
128 };
129
130 struct fbnic_pcie_stats {
131 struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword;
132 struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword;
133 struct fbnic_stat_counter ob_cpl_tlp, ob_cpl_dword;
134
135 struct fbnic_stat_counter ob_rd_no_tag;
136 struct fbnic_stat_counter ob_rd_no_cpl_cred;
137 struct fbnic_stat_counter ob_rd_no_np_cred;
138 };
139
140 struct fbnic_hw_stats {
141 struct fbnic_phy_stats phy;
142 struct fbnic_mac_stats mac;
143 struct fbnic_tmi_stats tmi;
144 struct fbnic_tti_stats tti;
145 struct fbnic_rpc_stats rpc;
146 struct fbnic_rxb_stats rxb;
147 struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];
148 struct fbnic_pcie_stats pcie;
149
150 /* Lock protecting the access to hw stats */
151 spinlock_t lock;
152 };
153
154 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
155
156 void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
157 void fbnic_init_hw_stats(struct fbnic_dev *fbd);
158 void fbnic_get_hw_q_stats(struct fbnic_dev *fbd,
159 struct fbnic_hw_q_stats *hw_q);
160 void fbnic_get_hw_stats32(struct fbnic_dev *fbd);
161 void fbnic_get_hw_stats(struct fbnic_dev *fbd);
162
163 #endif /* _FBNIC_HW_STATS_H_ */