1 /* bnx2x_stats.h: Broadcom Everest network driver.
2  *
3  * Copyright (c) 2007-2010 Broadcom Corporation
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation.
8  *
9  * Maintained by: Eilon Greenstein <eilong@broadcom.com>
10  * Written by: Eliezer Tamir
11  * Based on code from Michael Chan's bnx2 driver
12  * UDP CSUM errata workaround by Arik Gendelman
13  * Slowpath and fastpath rework by Vladislav Zolotarov
14  * Statistics and Link management by Yitchak Gertner
15  *
16  */
17 
18 #ifndef BNX2X_STATS_H
19 #define BNX2X_STATS_H
20 
21 #include <linux/types.h>
22 
23 struct bnx2x_eth_q_stats {
24 	u32 total_bytes_received_hi;
25 	u32 total_bytes_received_lo;
26 	u32 total_bytes_transmitted_hi;
27 	u32 total_bytes_transmitted_lo;
28 	u32 total_unicast_packets_received_hi;
29 	u32 total_unicast_packets_received_lo;
30 	u32 total_multicast_packets_received_hi;
31 	u32 total_multicast_packets_received_lo;
32 	u32 total_broadcast_packets_received_hi;
33 	u32 total_broadcast_packets_received_lo;
34 	u32 total_unicast_packets_transmitted_hi;
35 	u32 total_unicast_packets_transmitted_lo;
36 	u32 total_multicast_packets_transmitted_hi;
37 	u32 total_multicast_packets_transmitted_lo;
38 	u32 total_broadcast_packets_transmitted_hi;
39 	u32 total_broadcast_packets_transmitted_lo;
40 	u32 valid_bytes_received_hi;
41 	u32 valid_bytes_received_lo;
42 
43 	u32 error_bytes_received_hi;
44 	u32 error_bytes_received_lo;
45 	u32 etherstatsoverrsizepkts_hi;
46 	u32 etherstatsoverrsizepkts_lo;
47 	u32 no_buff_discard_hi;
48 	u32 no_buff_discard_lo;
49 
50 	u32 driver_xoff;
51 	u32 rx_err_discard_pkt;
52 	u32 rx_skb_alloc_failed;
53 	u32 hw_csum_err;
54 };
55 
56 #define Q_STATS_OFFSET32(stat_name) \
57 			(offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
58 
59 struct nig_stats {
60 	u32 brb_discard;
61 	u32 brb_packet;
62 	u32 brb_truncate;
63 	u32 flow_ctrl_discard;
64 	u32 flow_ctrl_octets;
65 	u32 flow_ctrl_packet;
66 	u32 mng_discard;
67 	u32 mng_octet_inp;
68 	u32 mng_octet_out;
69 	u32 mng_packet_inp;
70 	u32 mng_packet_out;
71 	u32 pbf_octets;
72 	u32 pbf_packet;
73 	u32 safc_inp;
74 	u32 egress_mac_pkt0_lo;
75 	u32 egress_mac_pkt0_hi;
76 	u32 egress_mac_pkt1_lo;
77 	u32 egress_mac_pkt1_hi;
78 };
79 
80 
81 enum bnx2x_stats_event {
82 	STATS_EVENT_PMF = 0,
83 	STATS_EVENT_LINK_UP,
84 	STATS_EVENT_UPDATE,
85 	STATS_EVENT_STOP,
86 	STATS_EVENT_MAX
87 };
88 
89 enum bnx2x_stats_state {
90 	STATS_STATE_DISABLED = 0,
91 	STATS_STATE_ENABLED,
92 	STATS_STATE_MAX
93 };
94 
95 struct bnx2x_eth_stats {
96 	u32 total_bytes_received_hi;
97 	u32 total_bytes_received_lo;
98 	u32 total_bytes_transmitted_hi;
99 	u32 total_bytes_transmitted_lo;
100 	u32 total_unicast_packets_received_hi;
101 	u32 total_unicast_packets_received_lo;
102 	u32 total_multicast_packets_received_hi;
103 	u32 total_multicast_packets_received_lo;
104 	u32 total_broadcast_packets_received_hi;
105 	u32 total_broadcast_packets_received_lo;
106 	u32 total_unicast_packets_transmitted_hi;
107 	u32 total_unicast_packets_transmitted_lo;
108 	u32 total_multicast_packets_transmitted_hi;
109 	u32 total_multicast_packets_transmitted_lo;
110 	u32 total_broadcast_packets_transmitted_hi;
111 	u32 total_broadcast_packets_transmitted_lo;
112 	u32 valid_bytes_received_hi;
113 	u32 valid_bytes_received_lo;
114 
115 	u32 error_bytes_received_hi;
116 	u32 error_bytes_received_lo;
117 	u32 etherstatsoverrsizepkts_hi;
118 	u32 etherstatsoverrsizepkts_lo;
119 	u32 no_buff_discard_hi;
120 	u32 no_buff_discard_lo;
121 
122 	u32 rx_stat_ifhcinbadoctets_hi;
123 	u32 rx_stat_ifhcinbadoctets_lo;
124 	u32 tx_stat_ifhcoutbadoctets_hi;
125 	u32 tx_stat_ifhcoutbadoctets_lo;
126 	u32 rx_stat_dot3statsfcserrors_hi;
127 	u32 rx_stat_dot3statsfcserrors_lo;
128 	u32 rx_stat_dot3statsalignmenterrors_hi;
129 	u32 rx_stat_dot3statsalignmenterrors_lo;
130 	u32 rx_stat_dot3statscarriersenseerrors_hi;
131 	u32 rx_stat_dot3statscarriersenseerrors_lo;
132 	u32 rx_stat_falsecarriererrors_hi;
133 	u32 rx_stat_falsecarriererrors_lo;
134 	u32 rx_stat_etherstatsundersizepkts_hi;
135 	u32 rx_stat_etherstatsundersizepkts_lo;
136 	u32 rx_stat_dot3statsframestoolong_hi;
137 	u32 rx_stat_dot3statsframestoolong_lo;
138 	u32 rx_stat_etherstatsfragments_hi;
139 	u32 rx_stat_etherstatsfragments_lo;
140 	u32 rx_stat_etherstatsjabbers_hi;
141 	u32 rx_stat_etherstatsjabbers_lo;
142 	u32 rx_stat_maccontrolframesreceived_hi;
143 	u32 rx_stat_maccontrolframesreceived_lo;
144 	u32 rx_stat_bmac_xpf_hi;
145 	u32 rx_stat_bmac_xpf_lo;
146 	u32 rx_stat_bmac_xcf_hi;
147 	u32 rx_stat_bmac_xcf_lo;
148 	u32 rx_stat_xoffstateentered_hi;
149 	u32 rx_stat_xoffstateentered_lo;
150 	u32 rx_stat_xonpauseframesreceived_hi;
151 	u32 rx_stat_xonpauseframesreceived_lo;
152 	u32 rx_stat_xoffpauseframesreceived_hi;
153 	u32 rx_stat_xoffpauseframesreceived_lo;
154 	u32 tx_stat_outxonsent_hi;
155 	u32 tx_stat_outxonsent_lo;
156 	u32 tx_stat_outxoffsent_hi;
157 	u32 tx_stat_outxoffsent_lo;
158 	u32 tx_stat_flowcontroldone_hi;
159 	u32 tx_stat_flowcontroldone_lo;
160 	u32 tx_stat_etherstatscollisions_hi;
161 	u32 tx_stat_etherstatscollisions_lo;
162 	u32 tx_stat_dot3statssinglecollisionframes_hi;
163 	u32 tx_stat_dot3statssinglecollisionframes_lo;
164 	u32 tx_stat_dot3statsmultiplecollisionframes_hi;
165 	u32 tx_stat_dot3statsmultiplecollisionframes_lo;
166 	u32 tx_stat_dot3statsdeferredtransmissions_hi;
167 	u32 tx_stat_dot3statsdeferredtransmissions_lo;
168 	u32 tx_stat_dot3statsexcessivecollisions_hi;
169 	u32 tx_stat_dot3statsexcessivecollisions_lo;
170 	u32 tx_stat_dot3statslatecollisions_hi;
171 	u32 tx_stat_dot3statslatecollisions_lo;
172 	u32 tx_stat_etherstatspkts64octets_hi;
173 	u32 tx_stat_etherstatspkts64octets_lo;
174 	u32 tx_stat_etherstatspkts65octetsto127octets_hi;
175 	u32 tx_stat_etherstatspkts65octetsto127octets_lo;
176 	u32 tx_stat_etherstatspkts128octetsto255octets_hi;
177 	u32 tx_stat_etherstatspkts128octetsto255octets_lo;
178 	u32 tx_stat_etherstatspkts256octetsto511octets_hi;
179 	u32 tx_stat_etherstatspkts256octetsto511octets_lo;
180 	u32 tx_stat_etherstatspkts512octetsto1023octets_hi;
181 	u32 tx_stat_etherstatspkts512octetsto1023octets_lo;
182 	u32 tx_stat_etherstatspkts1024octetsto1522octets_hi;
183 	u32 tx_stat_etherstatspkts1024octetsto1522octets_lo;
184 	u32 tx_stat_etherstatspktsover1522octets_hi;
185 	u32 tx_stat_etherstatspktsover1522octets_lo;
186 	u32 tx_stat_bmac_2047_hi;
187 	u32 tx_stat_bmac_2047_lo;
188 	u32 tx_stat_bmac_4095_hi;
189 	u32 tx_stat_bmac_4095_lo;
190 	u32 tx_stat_bmac_9216_hi;
191 	u32 tx_stat_bmac_9216_lo;
192 	u32 tx_stat_bmac_16383_hi;
193 	u32 tx_stat_bmac_16383_lo;
194 	u32 tx_stat_dot3statsinternalmactransmiterrors_hi;
195 	u32 tx_stat_dot3statsinternalmactransmiterrors_lo;
196 	u32 tx_stat_bmac_ufl_hi;
197 	u32 tx_stat_bmac_ufl_lo;
198 
199 	u32 pause_frames_received_hi;
200 	u32 pause_frames_received_lo;
201 	u32 pause_frames_sent_hi;
202 	u32 pause_frames_sent_lo;
203 
204 	u32 etherstatspkts1024octetsto1522octets_hi;
205 	u32 etherstatspkts1024octetsto1522octets_lo;
206 	u32 etherstatspktsover1522octets_hi;
207 	u32 etherstatspktsover1522octets_lo;
208 
209 	u32 brb_drop_hi;
210 	u32 brb_drop_lo;
211 	u32 brb_truncate_hi;
212 	u32 brb_truncate_lo;
213 
214 	u32 mac_filter_discard;
215 	u32 xxoverflow_discard;
216 	u32 brb_truncate_discard;
217 	u32 mac_discard;
218 
219 	u32 driver_xoff;
220 	u32 rx_err_discard_pkt;
221 	u32 rx_skb_alloc_failed;
222 	u32 hw_csum_err;
223 
224 	u32 nig_timer_max;
225 };
226 
227 #define STATS_OFFSET32(stat_name) \
228 			(offsetof(struct bnx2x_eth_stats, stat_name) / 4)
229 
230 /* Forward declaration */
231 struct bnx2x;
232 
233 void bnx2x_stats_init(struct bnx2x *bp);
234 
235 extern const u32 dmae_reg_go_c[];
236 
237 #endif /* BNX2X_STATS_H */
238