xref: /illumos-gate/usr/src/uts/common/io/xge/hal/xgehal/xgehal-mgmtaux.c (revision 4e93fb0f6383eaac21897dcdae56b87118131e4d)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Copyright (c) 2002-2006 Neterion, Inc.
22  */
23 
24 #include "xgehal-mgmt.h"
25 #include "xgehal-driver.h"
26 #include "xgehal-device.h"
27 
28 #ifdef XGE_OS_HAS_SNPRINTF
29 #define __hal_aux_snprintf(retbuf, bufsize, fmt, key, value, retsize) \
30     if (bufsize <= 0) return XGE_HAL_ERR_OUT_OF_SPACE; \
31     retsize = xge_os_snprintf(retbuf, bufsize, fmt, key, \
32 			XGE_HAL_AUX_SEPA, value); \
33     if (retsize < 0 || retsize >= bufsize) return XGE_HAL_ERR_OUT_OF_SPACE;
34 #else
35 #define __hal_aux_snprintf(retbuf, bufsize, fmt, key, value, retsize) \
36 	if (bufsize <= 0) return XGE_HAL_ERR_OUT_OF_SPACE; \
37         retsize = xge_os_sprintf(retbuf, fmt, key, XGE_HAL_AUX_SEPA, value); \
38 	xge_assert(retsize < bufsize); \
39 	if (retsize < 0 || retsize >= bufsize) \
40 		return XGE_HAL_ERR_OUT_OF_SPACE;
41 #endif
42 
43 #define __HAL_AUX_ENTRY_DECLARE(size, buf) \
44 	int entrysize = 0, leftsize = size; \
45 	char *ptr = buf;
46 
47 #define __HAL_AUX_ENTRY(key, value, fmt) \
48 	ptr += entrysize; leftsize -= entrysize; \
49 	__hal_aux_snprintf(ptr, leftsize, "%s%c"fmt"\n", key, value, entrysize)
50 
51 #define __HAL_AUX_ENTRY_END(bufsize, retsize) \
52 	leftsize -= entrysize; \
53 	*retsize = bufsize - leftsize;
54 
55 /**
56  * xge_hal_aux_bar0_read - Read and format Xframe BAR0 register.
57  * @devh: HAL device handle.
58  * @offset: Register offset in the BAR0 space.
59  * @bufsize: Buffer size.
60  * @retbuf: Buffer pointer.
61  * @retsize: Size of the result. Cannot be greater than @bufsize.
62  *
63  * Read Xframe register from BAR0 space. The result is formatted as an ascii string.
64  *
65  * Returns: XGE_HAL_OK - success.
66  * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
67  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
68  * XGE_HAL_ERR_INVALID_OFFSET - Register offset in the BAR space is not
69  * valid.
70  * XGE_HAL_ERR_INVALID_BAR_ID - BAR id is not valid.
71  *
72  * See also: xge_hal_mgmt_reg_read().
73  */
74 xge_hal_status_e xge_hal_aux_bar0_read(xge_hal_device_h devh,
75 			unsigned int offset, int bufsize, char *retbuf,
76 			int *retsize)
77 {
78 	xge_hal_status_e status;
79 	u64 retval;
80 
81 	status = xge_hal_mgmt_reg_read(devh, 0, offset, &retval);
82 	if (status != XGE_HAL_OK) {
83 		return status;
84 	}
85 
86 	if (bufsize < XGE_OS_SPRINTF_STRLEN) {
87 		return XGE_HAL_ERR_OUT_OF_SPACE;
88 	}
89 
90 	*retsize = xge_os_sprintf(retbuf, "0x%04X%c0x%08X%08X\n", offset,
91 				XGE_HAL_AUX_SEPA, (u32)(retval>>32), (u32)retval);
92 
93 	return XGE_HAL_OK;
94 }
95 
96 /**
97  * xge_hal_aux_bar1_read - Read and format Xframe BAR1 register.
98  * @devh: HAL device handle.
99  * @offset: Register offset in the BAR1 space.
100  * @bufsize: Buffer size.
101  * @retbuf: Buffer pointer.
102  * @retsize: Size of the result. Cannot be greater than @bufsize.
103  *
104  * Read Xframe register from BAR1 space. The result is formatted as ascii string.
105  * Returns: XGE_HAL_OK - success.
106  * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
107  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
108  * XGE_HAL_ERR_INVALID_OFFSET - Register offset in the BAR space is not
109  * valid.
110  * XGE_HAL_ERR_INVALID_BAR_ID - BAR id is not valid.
111  *
112  * See also: xge_hal_mgmt_reg_read().
113  */
114 xge_hal_status_e xge_hal_aux_bar1_read(xge_hal_device_h devh,
115 			unsigned int offset, int bufsize, char *retbuf,
116 			int *retsize)
117 {
118 	xge_hal_status_e status;
119 	u64 retval;
120 
121 	status = xge_hal_mgmt_reg_read(devh, 1, offset, &retval);
122 	if (status != XGE_HAL_OK) {
123 		return status;
124 	}
125 
126 	if (bufsize < XGE_OS_SPRINTF_STRLEN) {
127 		return XGE_HAL_ERR_OUT_OF_SPACE;
128 	}
129 
130         *retsize = xge_os_sprintf(retbuf, "0x%04X%c0x%08X%08X\n",
131         offset,
132 				XGE_HAL_AUX_SEPA, (u32)(retval>>32), (u32)retval);
133 
134 	return XGE_HAL_OK;
135 }
136 
137 /**
138  * xge_hal_aux_bar0_write - Write BAR0 register.
139  * @devh: HAL device handle.
140  * @offset: Register offset in the BAR0 space.
141  * @value: Regsister value (to write).
142  *
143  * Write BAR0 register.
144  *
145  * Returns: XGE_HAL_OK - success.
146  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
147  * XGE_HAL_ERR_INVALID_OFFSET - Register offset in the BAR space is not
148  * valid.
149  * XGE_HAL_ERR_INVALID_BAR_ID - BAR id is not valid.
150  *
151  * See also: xge_hal_mgmt_reg_write().
152  */
153 xge_hal_status_e xge_hal_aux_bar0_write(xge_hal_device_h devh,
154 			unsigned int offset, u64 value)
155 {
156 	xge_hal_status_e status;
157 
158 	status = xge_hal_mgmt_reg_write(devh, 0, offset, value);
159 	if (status != XGE_HAL_OK) {
160 		return status;
161 	}
162 
163 	return XGE_HAL_OK;
164 }
165 
166 /**
167  * xge_hal_aux_about_read - Retrieve and format about info.
168  * @devh: HAL device handle.
169  * @bufsize: Buffer size.
170  * @retbuf: Buffer pointer.
171  * @retsize: Size of the result. Cannot be greater than @bufsize.
172  *
173  * Retrieve about info (using xge_hal_mgmt_about()) and sprintf it
174  * into the provided @retbuf.
175  *
176  * Returns: XGE_HAL_OK - success.
177  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
178  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
179  * XGE_HAL_FAIL - Failed to retrieve the information.
180  *
181  * See also: xge_hal_mgmt_about(), xge_hal_aux_device_dump().
182  */
183 xge_hal_status_e xge_hal_aux_about_read(xge_hal_device_h devh, int bufsize,
184 			char *retbuf, int *retsize)
185 {
186 	xge_hal_status_e status;
187 	xge_hal_mgmt_about_info_t about_info;
188 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
189 
190 	status = xge_hal_mgmt_about(devh, &about_info,
191 				  sizeof(xge_hal_mgmt_about_info_t));
192 	if (status != XGE_HAL_OK) {
193 		return status;
194 	}
195 
196 	__HAL_AUX_ENTRY("vendor", about_info.vendor, "0x%x");
197 	__HAL_AUX_ENTRY("device", about_info.device, "0x%x");
198 	__HAL_AUX_ENTRY("subsys_vendor", about_info.subsys_vendor, "0x%x");
199 	__HAL_AUX_ENTRY("subsys_device", about_info.subsys_device, "0x%x");
200 	__HAL_AUX_ENTRY("board_rev", about_info.board_rev, "0x%x");
201 	__HAL_AUX_ENTRY("vendor_name", about_info.vendor_name, "%s");
202 	__HAL_AUX_ENTRY("chip_name", about_info.chip_name, "%s");
203 	__HAL_AUX_ENTRY("media", about_info.media, "%s");
204 	__HAL_AUX_ENTRY("hal_major", about_info.hal_major, "%s");
205 	__HAL_AUX_ENTRY("hal_minor", about_info.hal_minor, "%s");
206 	__HAL_AUX_ENTRY("hal_fix", about_info.hal_fix, "%s");
207 	__HAL_AUX_ENTRY("hal_build", about_info.hal_build, "%s");
208 	__HAL_AUX_ENTRY("ll_major", about_info.ll_major, "%s");
209 	__HAL_AUX_ENTRY("ll_minor", about_info.ll_minor, "%s");
210 	__HAL_AUX_ENTRY("ll_fix", about_info.ll_fix, "%s");
211 	__HAL_AUX_ENTRY("ll_build", about_info.ll_build, "%s");
212 
213 	__HAL_AUX_ENTRY("transponder_temperature",
214 			about_info.transponder_temperature, "%d C");
215 
216 	__HAL_AUX_ENTRY_END(bufsize, retsize);
217 
218 	return XGE_HAL_OK;
219 }
220 
221 /**
222  * xge_hal_aux_stats_tmac_read - Read TMAC hardware statistics.
223  * @devh: HAL device handle.
224  * @bufsize: Buffer size.
225  * @retbuf: Buffer pointer.
226  * @retsize: Size of the result. Cannot be greater than @bufsize.
227  *
228  * Read TMAC hardware statistics. This is a subset of stats counters
229  * from xge_hal_stats_hw_info_t{}.
230  *
231  * Returns: XGE_HAL_OK - success.
232  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
233  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
234  *
235  * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
236  * xge_hal_aux_stats_pci_read(),
237  * xge_hal_aux_device_dump().
238  */
239 xge_hal_status_e xge_hal_aux_stats_tmac_read(xge_hal_device_h devh, int	bufsize,
240 				char *retbuf, int *retsize)
241 {
242 	xge_hal_status_e status;
243 	xge_hal_mgmt_hw_stats_t hw;
244 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
245 
246 	status = xge_hal_mgmt_hw_stats(devh, &hw,
247 				     sizeof(xge_hal_mgmt_hw_stats_t));
248 	if (status != XGE_HAL_OK) {
249 		return status;
250 	}
251 
252 	__HAL_AUX_ENTRY("tmac_data_octets", hw.tmac_data_octets, "%u");
253 	__HAL_AUX_ENTRY("tmac_frms", hw.tmac_frms, "%u");
254 	__HAL_AUX_ENTRY("tmac_drop_frms", (unsigned long long)
255 			hw.tmac_drop_frms, "%llu");
256 	__HAL_AUX_ENTRY("tmac_bcst_frms", hw.tmac_bcst_frms, "%u");
257 	__HAL_AUX_ENTRY("tmac_mcst_frms", hw.tmac_mcst_frms, "%u");
258 	__HAL_AUX_ENTRY("tmac_pause_ctrl_frms", (unsigned long long)
259 			hw.tmac_pause_ctrl_frms, "%llu");
260 	__HAL_AUX_ENTRY("tmac_ucst_frms", hw.tmac_ucst_frms, "%u");
261 	__HAL_AUX_ENTRY("tmac_ttl_octets", hw.tmac_ttl_octets, "%u");
262 	__HAL_AUX_ENTRY("tmac_any_err_frms", hw.tmac_any_err_frms, "%u");
263 	__HAL_AUX_ENTRY("tmac_nucst_frms", hw.tmac_nucst_frms, "%u");
264 	__HAL_AUX_ENTRY("tmac_ttl_less_fb_octets", (unsigned long long)
265 			hw.tmac_ttl_less_fb_octets, "%llu");
266 	__HAL_AUX_ENTRY("tmac_vld_ip_octets", (unsigned long long)
267 			hw.tmac_vld_ip_octets, "%llu");
268 	__HAL_AUX_ENTRY("tmac_drop_ip", hw.tmac_drop_ip, "%u");
269 	__HAL_AUX_ENTRY("tmac_vld_ip", hw.tmac_vld_ip, "%u");
270 	__HAL_AUX_ENTRY("tmac_rst_tcp", hw.tmac_rst_tcp, "%u");
271 	__HAL_AUX_ENTRY("tmac_icmp", hw.tmac_icmp, "%u");
272 	__HAL_AUX_ENTRY("tmac_tcp", (unsigned long long)
273 			hw.tmac_tcp, "%llu");
274 	__HAL_AUX_ENTRY("reserved_0", hw.reserved_0, "%u");
275 	__HAL_AUX_ENTRY("tmac_udp", hw.tmac_udp, "%u");
276 
277 	__HAL_AUX_ENTRY_END(bufsize, retsize);
278 
279 	return XGE_HAL_OK;
280 }
281 
282 /**
283  * xge_hal_aux_stats_rmac_read - Read RMAC hardware statistics.
284  * @devh: HAL device handle.
285  * @bufsize: Buffer size.
286  * @retbuf: Buffer pointer.
287  * @retsize: Size of the result. Cannot be greater than @bufsize.
288  *
289  * Read RMAC hardware statistics. This is a subset of stats counters
290  * from xge_hal_stats_hw_info_t{}.
291  *
292  * Returns: XGE_HAL_OK - success.
293  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
294  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
295  *
296  * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
297  * xge_hal_aux_stats_pci_read(), xge_hal_aux_stats_tmac_read(),
298  * xge_hal_aux_device_dump().
299  */
300 xge_hal_status_e xge_hal_aux_stats_rmac_read(xge_hal_device_h devh, int	bufsize,
301 				char *retbuf, int *retsize)
302 {
303 	xge_hal_status_e status;
304 	xge_hal_mgmt_hw_stats_t hw;
305 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
306 
307 	status = xge_hal_mgmt_hw_stats(devh, &hw,
308 				     sizeof(xge_hal_mgmt_hw_stats_t));
309 	if (status != XGE_HAL_OK) {
310 		return status;
311 	}
312 
313 	__HAL_AUX_ENTRY("rmac_data_octets", hw.rmac_data_octets, "%u");
314 	__HAL_AUX_ENTRY("rmac_vld_frms", hw.rmac_vld_frms, "%u");
315 	__HAL_AUX_ENTRY("rmac_fcs_err_frms", (unsigned long long)
316 			hw.rmac_fcs_err_frms, "%llu");
317 	__HAL_AUX_ENTRY("mac_drop_frms", (unsigned long long)
318 			hw.rmac_drop_frms, "%llu");
319 	__HAL_AUX_ENTRY("rmac_vld_bcst_frms", hw.rmac_vld_bcst_frms, "%u");
320 	__HAL_AUX_ENTRY("rmac_vld_mcst_frms", hw.rmac_vld_mcst_frms, "%u");
321 	__HAL_AUX_ENTRY("rmac_out_rng_len_err_frms",
322 			hw.rmac_out_rng_len_err_frms, "%u");
323 	__HAL_AUX_ENTRY("rmac_in_rng_len_err_frms",
324 			hw.rmac_in_rng_len_err_frms, "%u");
325 	__HAL_AUX_ENTRY("rmac_long_frms", (unsigned long long)
326 			hw.rmac_long_frms, "%llu");
327 	__HAL_AUX_ENTRY("rmac_pause_ctrl_frms", (unsigned long long)
328 			hw.rmac_pause_ctrl_frms, "%llu");
329 	__HAL_AUX_ENTRY("rmac_unsup_ctrl_frms", (unsigned long long)
330 			hw.rmac_unsup_ctrl_frms, "%llu");
331 	__HAL_AUX_ENTRY("rmac_accepted_ucst_frms",
332 			hw.rmac_accepted_ucst_frms, "%u");
333 	__HAL_AUX_ENTRY("rmac_ttl_octets", hw.rmac_ttl_octets, "%u");
334 	__HAL_AUX_ENTRY("rmac_discarded_frms", hw.rmac_discarded_frms, "%u");
335 	__HAL_AUX_ENTRY("rmac_accepted_nucst_frms",
336 			hw.rmac_accepted_nucst_frms, "%u");
337 	__HAL_AUX_ENTRY("reserved_1", hw.reserved_1, "%u");
338 	__HAL_AUX_ENTRY("rmac_drop_events", hw.rmac_drop_events, "%u");
339 	__HAL_AUX_ENTRY("rmac_ttl_less_fb_octets", (unsigned long long)
340 			hw.rmac_ttl_less_fb_octets, "%llu");
341 	__HAL_AUX_ENTRY("rmac_ttl_frms", (unsigned long long)
342 			hw.rmac_ttl_frms, "%llu");
343 	__HAL_AUX_ENTRY("reserved_2", (unsigned long long)
344 			hw.reserved_2, "%llu");
345 	__HAL_AUX_ENTRY("rmac_usized_frms", hw.rmac_usized_frms, "%u");
346 	__HAL_AUX_ENTRY("reserved_3", hw.reserved_3, "%u");
347 	__HAL_AUX_ENTRY("rmac_frag_frms", hw.rmac_frag_frms, "%u");
348 	__HAL_AUX_ENTRY("rmac_osized_frms", hw.rmac_osized_frms, "%u");
349 	__HAL_AUX_ENTRY("reserved_4", hw.reserved_4, "%u");
350 	__HAL_AUX_ENTRY("rmac_jabber_frms", hw.rmac_jabber_frms, "%u");
351 	__HAL_AUX_ENTRY("rmac_ttl_64_frms", (unsigned long long)
352 			hw.rmac_ttl_64_frms, "%llu");
353 	__HAL_AUX_ENTRY("rmac_ttl_65_127_frms", (unsigned long long)
354 			hw.rmac_ttl_65_127_frms, "%llu");
355 	__HAL_AUX_ENTRY("reserved_5", (unsigned long long)
356 			hw.reserved_5, "%llu");
357 	__HAL_AUX_ENTRY("rmac_ttl_128_255_frms", (unsigned long long)
358 			hw.rmac_ttl_128_255_frms, "%llu");
359 	__HAL_AUX_ENTRY("rmac_ttl_256_511_frms", (unsigned long long)
360 			hw.rmac_ttl_256_511_frms, "%llu");
361 	__HAL_AUX_ENTRY("reserved_6", (unsigned long long)
362 			hw.reserved_6, "%llu");
363 	__HAL_AUX_ENTRY("rmac_ttl_512_1023_frms", (unsigned long long)
364 			hw.rmac_ttl_512_1023_frms, "%llu");
365 	__HAL_AUX_ENTRY("rmac_ttl_1024_1518_frms", (unsigned long long)
366 			hw.rmac_ttl_1024_1518_frms, "%llu");
367 	__HAL_AUX_ENTRY("rmac_ip", hw.rmac_ip, "%u");
368 	__HAL_AUX_ENTRY("reserved_7", hw.reserved_7, "%u");
369 	__HAL_AUX_ENTRY("rmac_ip_octets", (unsigned long long)
370 			hw.rmac_ip_octets, "%llu");
371 	__HAL_AUX_ENTRY("rmac_drop_ip", hw.rmac_drop_ip, "%u");
372 	__HAL_AUX_ENTRY("rmac_hdr_err_ip", hw.rmac_hdr_err_ip, "%u");
373 	__HAL_AUX_ENTRY("reserved_8", hw.reserved_8, "%u");
374 	__HAL_AUX_ENTRY("rmac_icmp", hw.rmac_icmp, "%u");
375 	__HAL_AUX_ENTRY("rmac_tcp", (unsigned long long)
376 			hw.rmac_tcp, "%llu");
377 	__HAL_AUX_ENTRY("rmac_err_drp_udp", hw.rmac_err_drp_udp, "%u");
378 	__HAL_AUX_ENTRY("rmac_udp", hw.rmac_udp, "%u");
379 	__HAL_AUX_ENTRY("rmac_xgmii_err_sym", (unsigned long long)
380 			hw.rmac_xgmii_err_sym, "%llu");
381 	__HAL_AUX_ENTRY("rmac_frms_q0", (unsigned long long)
382 			hw.rmac_frms_q0, "%llu");
383 	__HAL_AUX_ENTRY("rmac_frms_q1", (unsigned long long)
384 			hw.rmac_frms_q1, "%llu");
385 	__HAL_AUX_ENTRY("rmac_frms_q2", (unsigned long long)
386 			hw.rmac_frms_q2, "%llu");
387 	__HAL_AUX_ENTRY("rmac_frms_q3", (unsigned long long)
388 			hw.rmac_frms_q3, "%llu");
389 	__HAL_AUX_ENTRY("rmac_frms_q4", (unsigned long long)
390 			hw.rmac_frms_q4, "%llu");
391 	__HAL_AUX_ENTRY("rmac_frms_q5", (unsigned long long)
392 			hw.rmac_frms_q5, "%llu");
393 	__HAL_AUX_ENTRY("rmac_frms_q6", (unsigned long long)
394 			hw.rmac_frms_q6, "%llu");
395 	__HAL_AUX_ENTRY("rmac_frms_q7", (unsigned long long)
396 			hw.rmac_frms_q7, "%llu");
397 	__HAL_AUX_ENTRY("rmac_full_q3", hw.rmac_full_q3, "%d");
398 	__HAL_AUX_ENTRY("rmac_full_q2", hw.rmac_full_q2, "%d");
399 	__HAL_AUX_ENTRY("rmac_full_q1", hw.rmac_full_q1, "%d");
400 	__HAL_AUX_ENTRY("rmac_full_q0", hw.rmac_full_q0, "%d");
401 	__HAL_AUX_ENTRY("rmac_full_q7", hw.rmac_full_q7, "%d");
402 	__HAL_AUX_ENTRY("rmac_full_q6", hw.rmac_full_q6, "%d");
403 	__HAL_AUX_ENTRY("rmac_full_q5", hw.rmac_full_q5, "%d");
404 	__HAL_AUX_ENTRY("rmac_full_q4", hw.rmac_full_q4, "%d");
405 	__HAL_AUX_ENTRY("reserved_9", hw.reserved_9, "%u");
406 	__HAL_AUX_ENTRY("rmac_pause_cnt", hw.rmac_pause_cnt, "%u");
407 	__HAL_AUX_ENTRY("rmac_xgmii_data_err_cnt", (unsigned long long)
408 			hw.rmac_xgmii_data_err_cnt, "%llu");
409 	__HAL_AUX_ENTRY("rmac_xgmii_ctrl_err_cnt", (unsigned long long)
410 			hw.rmac_xgmii_ctrl_err_cnt, "%llu");
411 	__HAL_AUX_ENTRY("rmac_err_tcp", hw.rmac_err_tcp, "%u");
412 	__HAL_AUX_ENTRY("rmac_accepted_ip", hw.rmac_accepted_ip, "%u");
413 
414 	__HAL_AUX_ENTRY_END(bufsize, retsize);
415 
416 	return XGE_HAL_OK;
417 }
418 
419 /**
420  * xge_hal_aux_stats_herc_enchanced - Get Hercules hardware statistics.
421  * @devh: HAL device handle.
422  * @bufsize: Buffer size.
423  * @retbuf: Buffer pointer.
424  * @retsize: Size of the result. Cannot be greater than @bufsize.
425  *
426  * Read Hercules device hardware statistics.
427  *
428  * Returns: XGE_HAL_OK - success.
429  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
430  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
431  *
432  * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
433  * xge_hal_aux_stats_tmac_read(), xge_hal_aux_stats_rmac_read(),
434  * xge_hal_aux_device_dump().
435 */
436 xge_hal_status_e xge_hal_aux_stats_herc_enchanced(xge_hal_device_h devh,
437 				  int bufsize, char *retbuf, int *retsize)
438 {
439 	xge_hal_status_e status;
440 	xge_hal_mgmt_hw_stats_t hw;
441 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
442 
443 	status = xge_hal_mgmt_hw_stats(devh, &hw,
444 				     sizeof(xge_hal_mgmt_hw_stats_t));
445 	if (status != XGE_HAL_OK) {
446 		return status;
447 	}
448 	__HAL_AUX_ENTRY("tmac_frms_oflow", hw.tmac_frms_oflow, "%u");
449 	__HAL_AUX_ENTRY("tmac_data_octets_oflow", hw.tmac_data_octets_oflow,
450 			"%u");
451 	__HAL_AUX_ENTRY("tmac_mcst_frms_oflow", hw.tmac_mcst_frms_oflow, "%u");
452 	__HAL_AUX_ENTRY("tmac_bcst_frms_oflow", hw.tmac_bcst_frms_oflow, "%u");
453 	__HAL_AUX_ENTRY("tmac_ttl_octets_oflow", hw.tmac_ttl_octets_oflow,
454 			"%u");
455 	__HAL_AUX_ENTRY("tmac_ucst_frms_oflow", hw.tmac_ucst_frms_oflow, "%u");
456 	__HAL_AUX_ENTRY("tmac_nucst_frms_oflow", hw.tmac_nucst_frms_oflow,
457 			"%u");
458 	__HAL_AUX_ENTRY("tmac_any_err_frms_oflow", hw.tmac_any_err_frms_oflow,
459 			"%u");
460 	__HAL_AUX_ENTRY("tmac_vlan_frms", (unsigned long long)hw.tmac_vlan_frms,
461 			"%llu");
462 	__HAL_AUX_ENTRY("tmac_vld_ip_oflow", hw.tmac_vld_ip_oflow, "%u");
463 	__HAL_AUX_ENTRY("tmac_drop_ip_oflow", hw.tmac_drop_ip_oflow, "%u");
464 	__HAL_AUX_ENTRY("tmac_icmp_oflow", hw.tmac_icmp_oflow, "%u");
465 	__HAL_AUX_ENTRY("tmac_rst_tcp_oflow", hw.tmac_rst_tcp_oflow, "%u");
466 	__HAL_AUX_ENTRY("tmac_udp_oflow", hw.tmac_udp_oflow, "%u");
467 	__HAL_AUX_ENTRY("tpa_unknown_protocol", hw.tpa_unknown_protocol, "%u");
468 	__HAL_AUX_ENTRY("tpa_parse_failure", hw.tpa_parse_failure, "%u");
469 	__HAL_AUX_ENTRY("rmac_vld_frms_oflow", hw.rmac_vld_frms_oflow, "%u");
470 	__HAL_AUX_ENTRY("rmac_data_octets_oflow", hw.rmac_data_octets_oflow,
471 			"%u");
472 	__HAL_AUX_ENTRY("rmac_vld_mcst_frms_oflow", hw.rmac_vld_mcst_frms_oflow,
473 			"%u");
474 	__HAL_AUX_ENTRY("rmac_vld_bcst_frms_oflow", hw.rmac_vld_bcst_frms_oflow,
475 			"%u");
476 	__HAL_AUX_ENTRY("rmac_ttl_octets_oflow", hw.rmac_ttl_octets_oflow,
477 			"%u");
478 	__HAL_AUX_ENTRY("rmac_accepted_ucst_frms_oflow",
479 			hw.rmac_accepted_ucst_frms_oflow, "%u");
480 	__HAL_AUX_ENTRY("rmac_accepted_nucst_frms_oflow",
481 			hw.rmac_accepted_nucst_frms_oflow, "%u");
482 	__HAL_AUX_ENTRY("rmac_discarded_frms_oflow",
483 			hw.rmac_discarded_frms_oflow, "%u");
484 	__HAL_AUX_ENTRY("rmac_drop_events_oflow", hw.rmac_drop_events_oflow,
485 			"%u");
486 	__HAL_AUX_ENTRY("rmac_usized_frms_oflow", hw.rmac_usized_frms_oflow,
487 			"%u");
488 	__HAL_AUX_ENTRY("rmac_osized_frms_oflow", hw.rmac_osized_frms_oflow,
489 			"%u");
490 	__HAL_AUX_ENTRY("rmac_frag_frms_oflow", hw.rmac_frag_frms_oflow, "%u");
491 	__HAL_AUX_ENTRY("rmac_jabber_frms_oflow", hw.rmac_jabber_frms_oflow,
492 			"%u");
493 	__HAL_AUX_ENTRY("rmac_ip_oflow", hw.rmac_ip_oflow, "%u");
494 	__HAL_AUX_ENTRY("rmac_drop_ip_oflow", hw.rmac_drop_ip_oflow, "%u");
495 	__HAL_AUX_ENTRY("rmac_icmp_oflow", hw.rmac_icmp_oflow, "%u");
496 	__HAL_AUX_ENTRY("rmac_udp_oflow", hw.rmac_udp_oflow, "%u");
497 	__HAL_AUX_ENTRY("rmac_err_drp_udp_oflow", hw.rmac_err_drp_udp_oflow,
498 			"%u");
499 	__HAL_AUX_ENTRY("rmac_pause_cnt_oflow", hw.rmac_pause_cnt_oflow, "%u");
500 	__HAL_AUX_ENTRY("rmac_ttl_1519_4095_frms",
501 			(unsigned long long)hw.rmac_ttl_1519_4095_frms, "%llu");
502 	__HAL_AUX_ENTRY("rmac_ttl_4096_8191_frms",
503 			(unsigned long long)hw.rmac_ttl_4096_8191_frms, "%llu");
504 	__HAL_AUX_ENTRY("rmac_ttl_8192_max_frms",
505 			(unsigned long long)hw.rmac_ttl_8192_max_frms, "%llu");
506 	__HAL_AUX_ENTRY("rmac_ttl_gt_max_frms",
507 			(unsigned long long)hw.rmac_ttl_gt_max_frms, "%llu");
508 	__HAL_AUX_ENTRY("rmac_osized_alt_frms",
509 			(unsigned long long)hw.rmac_osized_alt_frms, "%llu");
510 	__HAL_AUX_ENTRY("rmac_jabber_alt_frms",
511 			(unsigned long long)hw.rmac_jabber_alt_frms, "%llu");
512 	__HAL_AUX_ENTRY("rmac_gt_max_alt_frms",
513 			(unsigned long long)hw.rmac_gt_max_alt_frms, "%llu");
514 	__HAL_AUX_ENTRY("rmac_vlan_frms",
515 			(unsigned long long)hw.rmac_vlan_frms, "%llu");
516 	__HAL_AUX_ENTRY("rmac_fcs_discard", hw.rmac_fcs_discard, "%u");
517 	__HAL_AUX_ENTRY("rmac_len_discard", hw.rmac_len_discard, "%u");
518 	__HAL_AUX_ENTRY("rmac_da_discard", hw.rmac_da_discard, "%u");
519 	__HAL_AUX_ENTRY("rmac_pf_discard", hw.rmac_pf_discard, "%u");
520 	__HAL_AUX_ENTRY("rmac_rts_discard", hw.rmac_rts_discard, "%u");
521 	__HAL_AUX_ENTRY("rmac_red_discard", hw.rmac_red_discard, "%u");
522 	__HAL_AUX_ENTRY("rmac_ingm_full_discard", hw.rmac_ingm_full_discard,
523 			"%u");
524 	__HAL_AUX_ENTRY("rmac_accepted_ip_oflow", hw.rmac_accepted_ip_oflow,
525 			"%u");
526 	__HAL_AUX_ENTRY("link_fault_cnt", hw.link_fault_cnt, "%u");
527 
528 	__HAL_AUX_ENTRY_END(bufsize, retsize);
529 
530 	return XGE_HAL_OK;
531 }
532 
533 /**
534  * xge_hal_aux_stats_rmac_read - Read PCI hardware statistics.
535  * @devh: HAL device handle.
536  * @bufsize: Buffer size.
537  * @retbuf: Buffer pointer.
538  * @retsize: Size of the result. Cannot be greater than @bufsize.
539  *
540  * Read PCI statistics counters, including number of PCI read and
541  * write transactions, PCI retries, discards, etc.
542  * This is a subset of stats counters from xge_hal_stats_hw_info_t{}.
543  *
544  * Returns: XGE_HAL_OK - success.
545  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
546  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
547  *
548  * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
549  * xge_hal_aux_stats_tmac_read(), xge_hal_aux_stats_rmac_read(),
550  * xge_hal_aux_device_dump().
551  */
552 xge_hal_status_e xge_hal_aux_stats_pci_read(xge_hal_device_h devh, int bufsize,
553 				char *retbuf, int *retsize)
554 {
555 	xge_hal_status_e status;
556 	xge_hal_mgmt_hw_stats_t hw;
557 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
558 
559 	status = xge_hal_mgmt_hw_stats(devh, &hw,
560 				     sizeof(xge_hal_mgmt_hw_stats_t));
561 	if (status != XGE_HAL_OK) {
562 		return status;
563 	}
564 
565 	__HAL_AUX_ENTRY("new_rd_req_cnt", hw.new_rd_req_cnt, "%u");
566 	__HAL_AUX_ENTRY("rd_req_cnt", hw.rd_req_cnt, "%u");
567 	__HAL_AUX_ENTRY("rd_rtry_cnt", hw.rd_rtry_cnt, "%u");
568 	__HAL_AUX_ENTRY("new_rd_req_rtry_cnt", hw.new_rd_req_rtry_cnt, "%u");
569 	__HAL_AUX_ENTRY("wr_req_cnt", hw.wr_req_cnt, "%u");
570 	__HAL_AUX_ENTRY("wr_rtry_rd_ack_cnt", hw.wr_rtry_rd_ack_cnt, "%u");
571 	__HAL_AUX_ENTRY("new_wr_req_rtry_cnt", hw.new_wr_req_rtry_cnt, "%u");
572 	__HAL_AUX_ENTRY("new_wr_req_cnt", hw.new_wr_req_cnt, "%u");
573 	__HAL_AUX_ENTRY("wr_disc_cnt", hw.wr_disc_cnt, "%u");
574 	__HAL_AUX_ENTRY("wr_rtry_cnt", hw.wr_rtry_cnt, "%u");
575 	__HAL_AUX_ENTRY("txp_wr_cnt", hw.txp_wr_cnt, "%u");
576 	__HAL_AUX_ENTRY("rd_rtry_wr_ack_cnt", hw.rd_rtry_wr_ack_cnt, "%u");
577 	__HAL_AUX_ENTRY("txd_wr_cnt", hw.txd_wr_cnt, "%u");
578 	__HAL_AUX_ENTRY("txd_rd_cnt", hw.txd_rd_cnt, "%u");
579 	__HAL_AUX_ENTRY("rxd_wr_cnt", hw.rxd_wr_cnt, "%u");
580 	__HAL_AUX_ENTRY("rxd_rd_cnt", hw.rxd_rd_cnt, "%u");
581 	__HAL_AUX_ENTRY("rxf_wr_cnt", hw.rxf_wr_cnt, "%u");
582 	__HAL_AUX_ENTRY("txf_rd_cnt", hw.txf_rd_cnt, "%u");
583 
584 	__HAL_AUX_ENTRY_END(bufsize, retsize);
585 
586 	return XGE_HAL_OK;
587 }
588 
589 /**
590  * xge_hal_aux_stats_hal_read - Read HAL (layer) statistics.
591  * @devh: HAL device handle.
592  * @bufsize: Buffer size.
593  * @retbuf: Buffer pointer.
594  * @retsize: Size of the result. Cannot be greater than @bufsize.
595  *
596  * Read HAL statistics.
597  *
598  * Returns: XGE_HAL_OK - success.
599  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
600  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
601  * XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
602  * currently available.
603  *
604  * See also: xge_hal_aux_device_dump().
605  */
606 xge_hal_status_e xge_hal_aux_stats_hal_read(xge_hal_device_h devh,
607 			int bufsize, char *retbuf, int *retsize)
608 {
609 	xge_list_t *item;
610 	xge_hal_channel_t *channel;
611 	xge_hal_device_t *hldev = (xge_hal_device_t*)devh;
612 	xge_hal_status_e status;
613 	xge_hal_mgmt_device_stats_t devstat;
614 	xge_hal_mgmt_channel_stats_t chstat;
615 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
616 
617 	status = xge_hal_mgmt_device_stats(hldev, &devstat,
618 				     sizeof(xge_hal_mgmt_device_stats_t));
619 	if (status != XGE_HAL_OK) {
620 		return status;
621 	}
622 
623 	if (!hldev->config.bimodal_interrupts) {
624 		__HAL_AUX_ENTRY("rx_traffic_intr_cnt",
625 				devstat.rx_traffic_intr_cnt, "%u");
626 	}
627 	__HAL_AUX_ENTRY("tx_traffic_intr_cnt", devstat.tx_traffic_intr_cnt, "%u");
628 	__HAL_AUX_ENTRY("txpic_intr_cnt", devstat.txpic_intr_cnt, "%u");
629 	__HAL_AUX_ENTRY("txdma_intr_cnt", devstat.txdma_intr_cnt, "%u");
630 	__HAL_AUX_ENTRY("txmac_intr_cnt", devstat.txmac_intr_cnt, "%u");
631 	__HAL_AUX_ENTRY("txxgxs_intr_cnt", devstat.txxgxs_intr_cnt, "%u");
632 	__HAL_AUX_ENTRY("rxpic_intr_cnt", devstat.rxpic_intr_cnt, "%u");
633 	__HAL_AUX_ENTRY("rxdma_intr_cnt", devstat.rxdma_intr_cnt, "%u");
634 	__HAL_AUX_ENTRY("rxmac_intr_cnt", devstat.rxmac_intr_cnt, "%u");
635 	__HAL_AUX_ENTRY("rxxgxs_intr_cnt", devstat.rxxgxs_intr_cnt, "%u");
636 	__HAL_AUX_ENTRY("mc_intr_cnt", devstat.mc_intr_cnt, "%u");
637 	__HAL_AUX_ENTRY("not_traffic_intr_cnt",
638 			devstat.not_traffic_intr_cnt, "%u");
639 	__HAL_AUX_ENTRY("traffic_intr_cnt", devstat.traffic_intr_cnt, "%u");
640 	__HAL_AUX_ENTRY("total_intr_cnt", devstat.total_intr_cnt, "%u");
641 	__HAL_AUX_ENTRY("soft_reset_cnt", devstat.soft_reset_cnt, "%u");
642 
643 	if (hldev->config.rxufca_hi_lim != hldev->config.rxufca_lo_lim &&
644 	    hldev->config.rxufca_lo_lim != 0) {
645 		__HAL_AUX_ENTRY("rxufca_lo_adjust_cnt",
646 				devstat.rxufca_lo_adjust_cnt, "%u");
647 		__HAL_AUX_ENTRY("rxufca_hi_adjust_cnt",
648 				devstat.rxufca_hi_adjust_cnt, "%u");
649 	}
650 
651 	if (hldev->config.bimodal_interrupts) {
652 		__HAL_AUX_ENTRY("bimodal_lo_adjust_cnt",
653 				devstat.bimodal_lo_adjust_cnt, "%u");
654 		__HAL_AUX_ENTRY("bimodal_hi_adjust_cnt",
655 				devstat.bimodal_hi_adjust_cnt, "%u");
656 	}
657 
658 #if defined(XGE_HAL_CONFIG_LRO)
659 	__HAL_AUX_ENTRY("tot_frms_lroised",
660 			devstat.tot_frms_lroised, "%u");
661 	__HAL_AUX_ENTRY("tot_lro_sessions",
662 			devstat.tot_lro_sessions, "%u");
663 	__HAL_AUX_ENTRY("lro_frm_len_exceed_cnt",
664 			devstat.lro_frm_len_exceed_cnt, "%u");
665 	__HAL_AUX_ENTRY("lro_sg_exceed_cnt",
666 			devstat.lro_sg_exceed_cnt, "%u");
667 	__HAL_AUX_ENTRY("lro_out_of_seq_pkt_cnt",
668 			devstat.lro_out_of_seq_pkt_cnt, "%u");
669 	__HAL_AUX_ENTRY("lro_dup_pkt_cnt",
670 			devstat.lro_dup_pkt_cnt, "%u");
671 #endif
672 
673 	/* for each opened rx channel */
674 	xge_list_for_each(item, &hldev->ring_channels) {
675 		char key[XGE_OS_SPRINTF_STRLEN];
676 		channel = xge_container_of(item, xge_hal_channel_t, item);
677 
678 		status = xge_hal_mgmt_channel_stats(channel, &chstat,
679 				     sizeof(xge_hal_mgmt_channel_stats_t));
680 		if (status != XGE_HAL_OK) {
681 			return status;
682 		}
683 
684 		(void) xge_os_sprintf(key, "ring%d_", channel->post_qid);
685 
686 		xge_os_strcpy(key+6, "full_cnt");
687 		__HAL_AUX_ENTRY(key, chstat.full_cnt, "%u");
688 		xge_os_strcpy(key+6, "usage_max");
689 		__HAL_AUX_ENTRY(key, chstat.usage_max, "%u");
690 		xge_os_strcpy(key+6, "usage_cnt");
691 		__HAL_AUX_ENTRY(key, channel->usage_cnt, "%u");
692 		xge_os_strcpy(key+6, "reserve_free_swaps_cnt");
693 		__HAL_AUX_ENTRY(key, chstat.reserve_free_swaps_cnt, "%u");
694 		if (!hldev->config.bimodal_interrupts) {
695 			xge_os_strcpy(key+6, "avg_compl_per_intr_cnt");
696 			__HAL_AUX_ENTRY(key, chstat.avg_compl_per_intr_cnt, "%u");
697 		}
698 		xge_os_strcpy(key+6, "total_compl_cnt");
699 		__HAL_AUX_ENTRY(key, chstat.total_compl_cnt, "%u");
700 		xge_os_strcpy(key+6, "bump_cnt");
701 		__HAL_AUX_ENTRY(key, chstat.ring_bump_cnt, "%u");
702 	}
703 
704 	/* for each opened tx channel */
705 	xge_list_for_each(item, &hldev->fifo_channels) {
706 		char key[XGE_OS_SPRINTF_STRLEN];
707 		channel = xge_container_of(item, xge_hal_channel_t, item);
708 
709 		status = xge_hal_mgmt_channel_stats(channel, &chstat,
710 				     sizeof(xge_hal_mgmt_channel_stats_t));
711 		if (status != XGE_HAL_OK) {
712 			return status;
713 		}
714 
715 		(void) xge_os_sprintf(key, "fifo%d_", channel->post_qid);
716 
717 		xge_os_strcpy(key+6, "full_cnt");
718 		__HAL_AUX_ENTRY(key, chstat.full_cnt, "%u");
719 		xge_os_strcpy(key+6, "usage_max");
720 		__HAL_AUX_ENTRY(key, chstat.usage_max, "%u");
721 		xge_os_strcpy(key+6, "usage_cnt");
722 		__HAL_AUX_ENTRY(key, channel->usage_cnt, "%u");
723 		xge_os_strcpy(key+6, "reserve_free_swaps_cnt");
724 		__HAL_AUX_ENTRY(key, chstat.reserve_free_swaps_cnt, "%u");
725 		xge_os_strcpy(key+6, "avg_compl_per_intr_cnt");
726 		__HAL_AUX_ENTRY(key, chstat.avg_compl_per_intr_cnt, "%u");
727 		xge_os_strcpy(key+6, "total_compl_cnt");
728 		__HAL_AUX_ENTRY(key, chstat.total_compl_cnt, "%u");
729 		xge_os_strcpy(key+6, "total_posts");
730 		__HAL_AUX_ENTRY(key, chstat.total_posts, "%u");
731 		xge_os_strcpy(key+6, "total_posts_many");
732 		__HAL_AUX_ENTRY(key, chstat.total_posts_many, "%u");
733 		xge_os_strcpy(key+6, "copied_frags");
734 		__HAL_AUX_ENTRY(key, chstat.copied_frags, "%u");
735 		xge_os_strcpy(key+6, "copied_buffers");
736 		__HAL_AUX_ENTRY(key, chstat.copied_buffers, "%u");
737 		xge_os_strcpy(key+6, "total_buffers");
738 		__HAL_AUX_ENTRY(key, chstat.total_buffers, "%u");
739 		xge_os_strcpy(key+6, "avg_buffers_per_post");
740 		__HAL_AUX_ENTRY(key, chstat.avg_buffers_per_post, "%u");
741 		xge_os_strcpy(key+6, "avg_buffer_size");
742 		__HAL_AUX_ENTRY(key, chstat.avg_buffer_size, "%u");
743 		xge_os_strcpy(key+6, "avg_post_size");
744 		__HAL_AUX_ENTRY(key, chstat.avg_post_size, "%u");
745 		xge_os_strcpy(key+6, "total_posts_dtrs_many");
746 		__HAL_AUX_ENTRY(key, chstat.total_posts_dtrs_many, "%u");
747 		xge_os_strcpy(key+6, "total_posts_frags_many");
748 		__HAL_AUX_ENTRY(key, chstat.total_posts_frags_many, "%u");
749 		xge_os_strcpy(key+6, "total_posts_dang_dtrs");
750 		__HAL_AUX_ENTRY(key, chstat.total_posts_dang_dtrs, "%u");
751 		xge_os_strcpy(key+6, "total_posts_dang_frags");
752 		__HAL_AUX_ENTRY(key, chstat.total_posts_dang_frags, "%u");
753 	}
754 
755 	__HAL_AUX_ENTRY_END(bufsize, retsize);
756 
757 	return XGE_HAL_OK;
758 }
759 
760 
761 
762 /**
763  * xge_hal_aux_stats_sw_dev_read - Read software device statistics.
764  * @devh: HAL device handle.
765  * @bufsize: Buffer size.
766  * @retbuf: Buffer pointer.
767  * @retsize: Size of the result. Cannot be greater than @bufsize.
768  *
769  * Read software-maintained device statistics.
770  *
771  * Returns: XGE_HAL_OK - success.
772  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
773  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
774  * XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
775  * currently available.
776  *
777  * See also: xge_hal_aux_device_dump().
778  */
779 xge_hal_status_e xge_hal_aux_stats_sw_dev_read(xge_hal_device_h devh,
780 				int bufsize, char *retbuf, int *retsize)
781 {
782 	xge_hal_device_t *hldev = (xge_hal_device_t*)devh;
783 	xge_hal_status_e status;
784 	xge_hal_mgmt_sw_stats_t sw_dev_err_stats;
785 	int t_code;
786 	char buf[XGE_OS_SPRINTF_STRLEN];
787 
788 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
789 
790 	status = xge_hal_mgmt_sw_stats(hldev, &sw_dev_err_stats,
791 				     sizeof(xge_hal_mgmt_sw_stats_t));
792 	if (status != XGE_HAL_OK) {
793 		return status;
794 	}
795 
796 	__HAL_AUX_ENTRY("sm_err_cnt",sw_dev_err_stats.sm_err_cnt, "%u");
797 	__HAL_AUX_ENTRY("single_ecc_err_cnt",sw_dev_err_stats.single_ecc_err_cnt, "%u");
798 	__HAL_AUX_ENTRY("double_ecc_err_cnt",sw_dev_err_stats.double_ecc_err_cnt, "%u");
799 	__HAL_AUX_ENTRY("ecc_err_cnt", sw_dev_err_stats.ecc_err_cnt, "%u");
800 	__HAL_AUX_ENTRY("parity_err_cnt",sw_dev_err_stats.parity_err_cnt, "%u");
801 	__HAL_AUX_ENTRY("serr_cnt",sw_dev_err_stats.serr_cnt, "%u");
802 
803 	for (t_code = 1; t_code < 16; t_code++) {
804 	        int t_code_cnt = sw_dev_err_stats.rxd_t_code_err_cnt[t_code];
805 	        if (t_code_cnt)  {
806 			(void) xge_os_sprintf(buf, "rxd_t_code_%d", t_code);
807 			__HAL_AUX_ENTRY(buf, t_code_cnt, "%u");
808 	        }
809 	        t_code_cnt = sw_dev_err_stats.txd_t_code_err_cnt[t_code];
810 		if (t_code_cnt)	{
811 			(void) xge_os_sprintf(buf, "txd_t_code_%d", t_code);
812 			__HAL_AUX_ENTRY(buf, t_code_cnt, "%u");
813 		}
814 	}
815 	__HAL_AUX_ENTRY("alarm_transceiver_temp_high",sw_dev_err_stats.
816 			stats_xpak.alarm_transceiver_temp_high, "%u");
817 	__HAL_AUX_ENTRY("alarm_transceiver_temp_low",sw_dev_err_stats.
818 			stats_xpak.alarm_transceiver_temp_low, "%u");
819 	__HAL_AUX_ENTRY("alarm_laser_bias_current_high",sw_dev_err_stats.
820 			stats_xpak.alarm_laser_bias_current_high, "%u");
821 	__HAL_AUX_ENTRY("alarm_laser_bias_current_low",sw_dev_err_stats.
822 			stats_xpak.alarm_laser_bias_current_low, "%u");
823 	__HAL_AUX_ENTRY("alarm_laser_output_power_high",sw_dev_err_stats.
824 			stats_xpak.alarm_laser_output_power_high, "%u");
825 	__HAL_AUX_ENTRY("alarm_laser_output_power_low",sw_dev_err_stats.
826 			stats_xpak.alarm_laser_output_power_low, "%u");
827 	__HAL_AUX_ENTRY("warn_transceiver_temp_high",sw_dev_err_stats.
828 			stats_xpak.warn_transceiver_temp_high, "%u");
829 	__HAL_AUX_ENTRY("warn_transceiver_temp_low",sw_dev_err_stats.
830 			stats_xpak.warn_transceiver_temp_low, "%u");
831 	__HAL_AUX_ENTRY("warn_laser_bias_current_high",sw_dev_err_stats.
832 			stats_xpak.warn_laser_bias_current_high, "%u");
833 	__HAL_AUX_ENTRY("warn_laser_bias_current_low",sw_dev_err_stats.
834 			stats_xpak.warn_laser_bias_current_low, "%u");
835 	__HAL_AUX_ENTRY("warn_laser_output_power_high",sw_dev_err_stats.
836 			stats_xpak.warn_laser_output_power_high, "%u");
837 	__HAL_AUX_ENTRY("warn_laser_output_power_low",sw_dev_err_stats.
838 			stats_xpak.warn_laser_output_power_low, "%u");
839 
840 	__HAL_AUX_ENTRY_END(bufsize, retsize);
841 
842 	return XGE_HAL_OK;
843 }
844 
845 /**
846  * xge_hal_aux_pci_config_read - Retrieve and format PCI Configuration
847  * info.
848  * @devh: HAL device handle.
849  * @bufsize: Buffer size.
850  * @retbuf: Buffer pointer.
851  * @retsize: Size of the result. Cannot be greater than @bufsize.
852  *
853  * Retrieve about info (using xge_hal_mgmt_pci_config()) and sprintf it
854  * into the provided @retbuf.
855  *
856  * Returns: XGE_HAL_OK - success.
857  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
858  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
859  *
860  * See also: xge_hal_mgmt_pci_config(), xge_hal_aux_device_dump().
861  */
862 xge_hal_status_e xge_hal_aux_pci_config_read(xge_hal_device_h devh, int	bufsize,
863 				char *retbuf, int *retsize)
864 {
865 	xge_hal_status_e status;
866 	xge_hal_mgmt_pci_config_t pci_config;
867 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
868 
869 	status = xge_hal_mgmt_pci_config(devh, &pci_config,
870 				  sizeof(xge_hal_mgmt_pci_config_t));
871 	if (status != XGE_HAL_OK) {
872 		return status;
873 	}
874 
875 	__HAL_AUX_ENTRY("vendor_id", pci_config.vendor_id, "0x%04X");
876 	__HAL_AUX_ENTRY("device_id", pci_config.device_id, "0x%04X");
877 	__HAL_AUX_ENTRY("command", pci_config.command, "0x%04X");
878 	__HAL_AUX_ENTRY("status", pci_config.status, "0x%04X");
879 	__HAL_AUX_ENTRY("revision", pci_config.revision, "0x%02X");
880 	__HAL_AUX_ENTRY("pciClass1", pci_config.pciClass[0], "0x%02X");
881 	__HAL_AUX_ENTRY("pciClass2", pci_config.pciClass[1], "0x%02X");
882 	__HAL_AUX_ENTRY("pciClass3", pci_config.pciClass[2], "0x%02X");
883 	__HAL_AUX_ENTRY("cache_line_size",
884 			pci_config.cache_line_size, "0x%02X");
885 	__HAL_AUX_ENTRY("latency_timer", pci_config.latency_timer, "0x%02X");
886 	__HAL_AUX_ENTRY("header_type", pci_config.header_type, "0x%02X");
887 	__HAL_AUX_ENTRY("bist", pci_config.bist, "0x%02X");
888 	__HAL_AUX_ENTRY("base_addr0_lo", pci_config.base_addr0_lo, "0x%08X");
889 	__HAL_AUX_ENTRY("base_addr0_hi", pci_config.base_addr0_hi, "0x%08X");
890 	__HAL_AUX_ENTRY("base_addr1_lo", pci_config.base_addr1_lo, "0x%08X");
891 	__HAL_AUX_ENTRY("base_addr1_hi", pci_config.base_addr1_hi, "0x%08X");
892 	__HAL_AUX_ENTRY("not_Implemented1",
893 			pci_config.not_Implemented1, "0x%08X");
894 	__HAL_AUX_ENTRY("not_Implemented2", pci_config.not_Implemented2,
895 			"0x%08X");
896 	__HAL_AUX_ENTRY("cardbus_cis_pointer", pci_config.cardbus_cis_pointer,
897 			"0x%08X");
898 	__HAL_AUX_ENTRY("subsystem_vendor_id", pci_config.subsystem_vendor_id,
899 			"0x%04X");
900 	__HAL_AUX_ENTRY("subsystem_id", pci_config.subsystem_id, "0x%04X");
901 	__HAL_AUX_ENTRY("rom_base", pci_config.rom_base, "0x%08X");
902 	__HAL_AUX_ENTRY("capabilities_pointer",
903 			pci_config.capabilities_pointer, "0x%02X");
904 	__HAL_AUX_ENTRY("interrupt_line", pci_config.interrupt_line, "0x%02X");
905 	__HAL_AUX_ENTRY("interrupt_pin", pci_config.interrupt_pin, "0x%02X");
906 	__HAL_AUX_ENTRY("min_grant", pci_config.min_grant, "0x%02X");
907 	__HAL_AUX_ENTRY("max_latency", pci_config.max_latency, "0x%02X");
908 	__HAL_AUX_ENTRY("msi_cap_id", pci_config.msi_cap_id, "0x%02X");
909 	__HAL_AUX_ENTRY("msi_next_ptr", pci_config.msi_next_ptr, "0x%02X");
910 	__HAL_AUX_ENTRY("msi_control", pci_config.msi_control, "0x%04X");
911 	__HAL_AUX_ENTRY("msi_lower_address", pci_config.msi_lower_address,
912 			"0x%08X");
913 	__HAL_AUX_ENTRY("msi_higher_address", pci_config.msi_higher_address,
914 			"0x%08X");
915 	__HAL_AUX_ENTRY("msi_data", pci_config.msi_data, "0x%04X");
916 	__HAL_AUX_ENTRY("msi_unused", pci_config.msi_unused, "0x%04X");
917 	__HAL_AUX_ENTRY("vpd_cap_id", pci_config.vpd_cap_id, "0x%02X");
918 	__HAL_AUX_ENTRY("vpd_next_cap", pci_config.vpd_next_cap, "0x%02X");
919 	__HAL_AUX_ENTRY("vpd_addr", pci_config.vpd_addr, "0x%04X");
920 	__HAL_AUX_ENTRY("vpd_data", pci_config.vpd_data, "0x%08X");
921 	__HAL_AUX_ENTRY("pcix_cap", pci_config.pcix_cap, "0x%02X");
922 	__HAL_AUX_ENTRY("pcix_next_cap", pci_config.pcix_next_cap, "0x%02X");
923 	__HAL_AUX_ENTRY("pcix_command", pci_config.pcix_command, "0x%04X");
924 	__HAL_AUX_ENTRY("pcix_status", pci_config.pcix_status, "0x%08X");
925 
926 	if (xge_hal_device_check_id(devh) == XGE_HAL_CARD_HERC) {
927 		char key[XGE_OS_SPRINTF_STRLEN];
928 		int i;
929 
930 		for (i = 0;
931 		     i < (XGE_HAL_PCI_XFRAME_CONFIG_SPACE_SIZE - 0x68)/4;
932 		     i++) {
933 			(void) xge_os_sprintf(key, "%03x:", 4*i + 0x68);
934 			__HAL_AUX_ENTRY(key, *((int *)pci_config.rsvd_b1 + i),
935 					"0x%08X");
936 		}
937 	}
938 
939 	__HAL_AUX_ENTRY_END(bufsize, retsize);
940 
941 	return XGE_HAL_OK;
942 }
943 
944 
945 /**
946  * xge_hal_aux_channel_read - Read channels information.
947  * @devh: HAL device handle.
948  * @bufsize: Buffer size.
949  * @retbuf: Buffer pointer.
950  * @retsize: Size of the result. Cannot be greater than @bufsize.
951  *
952  * Read HAL statistics.
953  *
954  * Returns: XGE_HAL_OK - success.
955  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
956  * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
957  * See also: xge_hal_aux_device_dump().
958  */
959 xge_hal_status_e xge_hal_aux_channel_read(xge_hal_device_h devh,
960 				int bufsize, char *retbuf, int *retsize)
961 {
962 	xge_list_t *item;
963 	xge_hal_channel_t *channel;
964 	xge_hal_device_t *hldev = (xge_hal_device_t*)devh;
965 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
966 
967 	if (hldev->magic != XGE_HAL_MAGIC) {
968                 return XGE_HAL_ERR_INVALID_DEVICE;
969         }
970 
971 	/* for each opened rx channel */
972 	xge_list_for_each(item, &hldev->ring_channels) {
973 		char key[XGE_OS_SPRINTF_STRLEN];
974 		channel = xge_container_of(item, xge_hal_channel_t, item);
975 
976 		if (channel->is_open != 1)
977 			continue;
978 
979 		(void) xge_os_sprintf(key, "ring%d_", channel->post_qid);
980 		xge_os_strcpy(key+6, "type");
981 		__HAL_AUX_ENTRY(key, channel->type, "%u");
982 		xge_os_strcpy(key+6, "length");
983 		__HAL_AUX_ENTRY(key, channel->length, "%u");
984 		xge_os_strcpy(key+6, "is_open");
985 		__HAL_AUX_ENTRY(key, channel->is_open, "%u");
986 		xge_os_strcpy(key+6, "reserve_initial");
987 		__HAL_AUX_ENTRY(key, channel->reserve_initial, "%u");
988 		xge_os_strcpy(key+6, "reserve_max");
989 		__HAL_AUX_ENTRY(key, channel->reserve_max, "%u");
990 		xge_os_strcpy(key+6, "reserve_length");
991 		__HAL_AUX_ENTRY(key, channel->reserve_length, "%u");
992 		xge_os_strcpy(key+6, "reserve_top");
993 		__HAL_AUX_ENTRY(key, channel->reserve_top, "%u");
994 		xge_os_strcpy(key+6, "reserve_threshold");
995 		__HAL_AUX_ENTRY(key, channel->reserve_threshold, "%u");
996 		xge_os_strcpy(key+6, "free_length");
997 		__HAL_AUX_ENTRY(key, channel->free_length, "%u");
998 		xge_os_strcpy(key+6, "post_index");
999 		__HAL_AUX_ENTRY(key, channel->post_index, "%u");
1000 		xge_os_strcpy(key+6, "compl_index");
1001 		__HAL_AUX_ENTRY(key, channel->compl_index, "%u");
1002 		xge_os_strcpy(key+6, "per_dtr_space");
1003 		__HAL_AUX_ENTRY(key, channel->per_dtr_space, "%u");
1004 		xge_os_strcpy(key+6, "usage_cnt");
1005 		__HAL_AUX_ENTRY(key, channel->usage_cnt, "%u");
1006 	}
1007 
1008 	/* for each opened tx channel */
1009 	xge_list_for_each(item, &hldev->fifo_channels) {
1010 		char key[XGE_OS_SPRINTF_STRLEN];
1011 		channel = xge_container_of(item, xge_hal_channel_t, item);
1012 
1013 		if (channel->is_open != 1)
1014 			continue;
1015 
1016 		(void) xge_os_sprintf(key, "fifo%d_", channel->post_qid);
1017 		xge_os_strcpy(key+6, "type");
1018 		__HAL_AUX_ENTRY(key, channel->type, "%u");
1019 		xge_os_strcpy(key+6, "length");
1020 		__HAL_AUX_ENTRY(key, channel->length, "%u");
1021 		xge_os_strcpy(key+6, "is_open");
1022 		__HAL_AUX_ENTRY(key, channel->is_open, "%u");
1023 		xge_os_strcpy(key+6, "reserve_initial");
1024 		__HAL_AUX_ENTRY(key, channel->reserve_initial, "%u");
1025 		xge_os_strcpy(key+6, "reserve_max");
1026 		__HAL_AUX_ENTRY(key, channel->reserve_max, "%u");
1027 		xge_os_strcpy(key+6, "reserve_length");
1028 		__HAL_AUX_ENTRY(key, channel->reserve_length, "%u");
1029 		xge_os_strcpy(key+6, "reserve_top");
1030 		__HAL_AUX_ENTRY(key, channel->reserve_top, "%u");
1031 		xge_os_strcpy(key+6, "reserve_threshold");
1032 		__HAL_AUX_ENTRY(key, channel->reserve_threshold, "%u");
1033 		xge_os_strcpy(key+6, "free_length");
1034 		__HAL_AUX_ENTRY(key, channel->free_length, "%u");
1035 		xge_os_strcpy(key+6, "post_index");
1036 		__HAL_AUX_ENTRY(key, channel->post_index, "%u");
1037 		xge_os_strcpy(key+6, "compl_index");
1038 		__HAL_AUX_ENTRY(key, channel->compl_index, "%u");
1039 		xge_os_strcpy(key+6, "per_dtr_space");
1040 		__HAL_AUX_ENTRY(key, channel->per_dtr_space, "%u");
1041 		xge_os_strcpy(key+6, "usage_cnt");
1042 		__HAL_AUX_ENTRY(key, channel->usage_cnt, "%u");
1043 	}
1044 
1045 	__HAL_AUX_ENTRY_END(bufsize, retsize);
1046 
1047 	return XGE_HAL_OK;
1048 }
1049 
1050 /**
1051  * xge_hal_aux_device_dump - Dump driver "about" info and device state.
1052  * @devh: HAL device handle.
1053  *
1054  * Dump driver & device "about" info and device state,
1055  * including all BAR0 registers, hardware and software statistics, PCI
1056  * configuration space.
1057  * See also: xge_hal_aux_about_read(), xge_hal_mgmt_reg_read(),
1058  * xge_hal_aux_pci_config_read(), xge_hal_aux_stats_sw_dev_read(),
1059  * xge_hal_aux_stats_tmac_read(), xge_hal_aux_stats_rmac_read(),
1060  * xge_hal_aux_channel_read(), xge_hal_aux_stats_hal_read().
1061  * Returns:
1062  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1063  * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
1064  */
1065 xge_hal_status_e
1066 xge_hal_aux_device_dump(xge_hal_device_h devh)
1067 {
1068 	xge_hal_device_t *hldev = (xge_hal_device_t*)devh;
1069 	xge_hal_status_e status;
1070 	int retsize;
1071 	int offset;
1072 	u64 retval;
1073 
1074 	xge_assert(hldev->dump_buf != NULL);
1075 
1076 	xge_os_println("********* xge DEVICE DUMP BEGIN **********");
1077 
1078 	status = xge_hal_aux_about_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1079 	                                hldev->dump_buf,
1080 	                                &retsize);
1081 	if (status != XGE_HAL_OK) {
1082 		goto error;
1083 	}
1084 	xge_os_println(hldev->dump_buf);
1085 
1086 
1087 	for (offset = 0; offset < 1574; offset++) {
1088 
1089 		status = xge_hal_mgmt_reg_read(hldev, 0, offset*8, &retval);
1090 		if (status != XGE_HAL_OK) {
1091 			goto error;
1092 		}
1093 
1094 		if (!retval) continue;
1095 
1096 		xge_os_printf("0x%04x 0x%08x%08x", offset*8,
1097 					(u32)(retval>>32), (u32)retval);
1098 	}
1099 	xge_os_println("\n");
1100 
1101 	status = xge_hal_aux_pci_config_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1102 	                                     hldev->dump_buf,
1103 	                                     &retsize);
1104 	if (status != XGE_HAL_OK) {
1105 		goto error;
1106 	}
1107 	xge_os_println(hldev->dump_buf);
1108 
1109 	status = xge_hal_aux_stats_tmac_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1110 	                                     hldev->dump_buf,
1111 	                                     &retsize);
1112 	if (status != XGE_HAL_OK) {
1113 		goto error;
1114 	}
1115 	xge_os_println(hldev->dump_buf);
1116 
1117 	status = xge_hal_aux_stats_rmac_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1118 	                                     hldev->dump_buf,
1119 	                                     &retsize);
1120 	if (status != XGE_HAL_OK) {
1121 		goto error;
1122 	}
1123 	xge_os_println(hldev->dump_buf);
1124 
1125 	status = xge_hal_aux_stats_pci_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1126 	                                    hldev->dump_buf,
1127 	                                    &retsize);
1128 	if (status != XGE_HAL_OK) {
1129 		goto error;
1130 	}
1131 	xge_os_println(hldev->dump_buf);
1132 
1133 	if (xge_hal_device_check_id(hldev) == XGE_HAL_CARD_HERC) {
1134 		status = xge_hal_aux_stats_herc_enchanced(hldev,
1135 			     XGE_HAL_DUMP_BUF_SIZE, hldev->dump_buf, &retsize);
1136 		if (status != XGE_HAL_OK) {
1137 			goto error;
1138 		}
1139 		xge_os_println(hldev->dump_buf);
1140 	}
1141 
1142 	status = xge_hal_aux_stats_sw_dev_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1143 					     hldev->dump_buf, &retsize);
1144 	if (status != XGE_HAL_OK) {
1145 		goto error;
1146 	}
1147 	xge_os_println(hldev->dump_buf);
1148 
1149 	status = xge_hal_aux_channel_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1150 	                                  hldev->dump_buf,
1151 	                                  &retsize);
1152 	if (status != XGE_HAL_OK) {
1153 		goto error;
1154 	}
1155 	xge_os_println(hldev->dump_buf);
1156 
1157 	status = xge_hal_aux_stats_hal_read(hldev, XGE_HAL_DUMP_BUF_SIZE,
1158 	                                    hldev->dump_buf,
1159 	                                    &retsize);
1160 	if (status != XGE_HAL_OK) {
1161 		goto error;
1162 	}
1163 	xge_os_println(hldev->dump_buf);
1164 
1165 	xge_os_println("********* XFRAME DEVICE DUMP END **********");
1166 
1167 error:
1168 	return status;
1169 }
1170 
1171 
1172 /**
1173  * xge_hal_aux_driver_config_read - Read Driver configuration.
1174  * @bufsize: Buffer size.
1175  * @retbuf: Buffer pointer.
1176  * @retsize: Size of the result. Cannot be greater than @bufsize.
1177  *
1178  * Read driver configuration,
1179  *
1180  * Returns: XGE_HAL_OK - success.
1181  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
1182  *
1183  * See also: xge_hal_aux_device_config_read().
1184  */
1185 xge_hal_status_e
1186 xge_hal_aux_driver_config_read(int bufsize, char *retbuf, int *retsize)
1187 {
1188 	xge_hal_status_e status;
1189 	xge_hal_driver_config_t  drv_config;
1190 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
1191 
1192 	status = xge_hal_mgmt_driver_config(&drv_config,
1193 					  sizeof(xge_hal_driver_config_t));
1194 	if (status != XGE_HAL_OK) {
1195 		return status;
1196 	}
1197 
1198 	__HAL_AUX_ENTRY("queue size initial",
1199 			drv_config.queue_size_initial, "%u");
1200 	__HAL_AUX_ENTRY("queue size max", drv_config.queue_size_max, "%u");
1201 	__HAL_AUX_ENTRY_END(bufsize, retsize);
1202 
1203 	return XGE_HAL_OK;
1204 }
1205 
1206 
1207 /**
1208  * xge_hal_aux_device_config_read - Read device configuration.
1209  * @devh: HAL device handle.
1210  * @bufsize: Buffer size.
1211  * @retbuf: Buffer pointer.
1212  * @retsize: Size of the result. Cannot be greater than @bufsize.
1213  *
1214  * Read device configuration,
1215  *
1216  * Returns: XGE_HAL_OK - success.
1217  * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1218  * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
1219  *
1220  * See also: xge_hal_aux_driver_config_read().
1221  */
1222 xge_hal_status_e xge_hal_aux_device_config_read(xge_hal_device_h devh,
1223 				int bufsize, char *retbuf, int *retsize)
1224 {
1225 	int i;
1226 	xge_hal_status_e status;
1227 	xge_hal_device_config_t  dev_config;
1228 	char key[XGE_OS_SPRINTF_STRLEN];
1229 	__HAL_AUX_ENTRY_DECLARE(bufsize, retbuf);
1230 
1231 	status = xge_hal_mgmt_device_config(devh, &dev_config,
1232 					  sizeof(xge_hal_device_config_t));
1233 	if (status != XGE_HAL_OK) {
1234 		return status;
1235 	}
1236 
1237 	__HAL_AUX_ENTRY("mtu", dev_config.mtu, "%u");
1238 	__HAL_AUX_ENTRY("isr_polling_count", dev_config.isr_polling_cnt, "%u");
1239 	__HAL_AUX_ENTRY("latency_timer", dev_config.latency_timer, "%u");
1240 	__HAL_AUX_ENTRY("max_splits_trans",
1241 			dev_config.max_splits_trans, "%u");
1242 	__HAL_AUX_ENTRY("mmrb_count", dev_config.mmrb_count, "%d");
1243 	__HAL_AUX_ENTRY("shared_splits", dev_config.shared_splits, "%u");
1244 	__HAL_AUX_ENTRY("stats_refresh_time_sec",
1245 			dev_config.stats_refresh_time_sec, "%u");
1246 	__HAL_AUX_ENTRY("pci_freq_mherz", dev_config.pci_freq_mherz, "%u");
1247 	__HAL_AUX_ENTRY("intr_mode", dev_config.intr_mode, "%u");
1248 	__HAL_AUX_ENTRY("ring_memblock_size",
1249 			dev_config.ring.memblock_size,  "%u");
1250 
1251 	__HAL_AUX_ENTRY("sched_timer_us", dev_config.sched_timer_us, "%u");
1252 	__HAL_AUX_ENTRY("sched_timer_one_shot",
1253 			dev_config.sched_timer_one_shot,  "%u");
1254 	__HAL_AUX_ENTRY("rxufca_intr_thres", dev_config.rxufca_intr_thres,  "%u");
1255 	__HAL_AUX_ENTRY("rxufca_lo_lim", dev_config.rxufca_lo_lim,  "%u");
1256 	__HAL_AUX_ENTRY("rxufca_hi_lim", dev_config.rxufca_hi_lim,  "%u");
1257 	__HAL_AUX_ENTRY("rxufca_lbolt_period", dev_config.rxufca_lbolt_period,  "%u");
1258 
1259 	for(i = 0; i < XGE_HAL_MAX_RING_NUM;  i++)
1260 	{
1261 		xge_hal_ring_queue_t *ring = &dev_config.ring.queue[i];
1262 		xge_hal_rti_config_t *rti =  &ring->rti;
1263 
1264 		if (!ring->configured)
1265 			continue;
1266 
1267 		(void) xge_os_sprintf(key, "ring%d_", i);
1268 		xge_os_strcpy(key+6, "inital");
1269 		__HAL_AUX_ENTRY(key, ring->initial, "%u");
1270 		xge_os_strcpy(key+6, "max");
1271 		__HAL_AUX_ENTRY(key, ring->max, "%u");
1272 		xge_os_strcpy(key+6, "buffer_mode");
1273 		__HAL_AUX_ENTRY(key, ring->buffer_mode, "%u");
1274 		xge_os_strcpy(key+6, "dram_size_mb");
1275 		__HAL_AUX_ENTRY(key, ring->dram_size_mb, "%u");
1276 		xge_os_strcpy(key+6, "backoff_interval_us");
1277 		__HAL_AUX_ENTRY(key, ring->backoff_interval_us, "%u");
1278 		xge_os_strcpy(key+6, "max_frame_len");
1279 		__HAL_AUX_ENTRY(key, ring->max_frm_len, "%d");
1280 		xge_os_strcpy(key+6, "priority");
1281 		__HAL_AUX_ENTRY(key, ring->priority,  "%u");
1282 		xge_os_strcpy(key+6, "rth_en");
1283 		__HAL_AUX_ENTRY(key, ring->rth_en,  "%u");
1284 		xge_os_strcpy(key+6, "no_snoop_bits");
1285 		__HAL_AUX_ENTRY(key, ring->no_snoop_bits,  "%u");
1286 		xge_os_strcpy(key+6, "indicate_max_pkts");
1287 		__HAL_AUX_ENTRY(key, ring->indicate_max_pkts,  "%u");
1288 
1289 		xge_os_strcpy(key+6, "urange_a");
1290 		__HAL_AUX_ENTRY(key, rti->urange_a,  "%u");
1291 		xge_os_strcpy(key+6, "ufc_a");
1292 		__HAL_AUX_ENTRY(key, rti->ufc_a,  "%u");
1293 		xge_os_strcpy(key+6, "urange_b");
1294 		__HAL_AUX_ENTRY(key, rti->urange_b,  "%u");
1295 		xge_os_strcpy(key+6, "ufc_b");
1296 		__HAL_AUX_ENTRY(key, rti->ufc_b,  "%u");
1297 		xge_os_strcpy(key+6, "urange_c");
1298 		__HAL_AUX_ENTRY(key, rti->urange_c,  "%u");
1299 		xge_os_strcpy(key+6, "ufc_c");
1300 		__HAL_AUX_ENTRY(key, rti->ufc_c,  "%u");
1301 		xge_os_strcpy(key+6, "ufc_d");
1302 		__HAL_AUX_ENTRY(key, rti->ufc_d,  "%u");
1303 		xge_os_strcpy(key+6, "timer_val_us");
1304 		__HAL_AUX_ENTRY(key, rti->timer_val_us,  "%u");
1305 	}
1306 
1307 
1308 	{
1309 		xge_hal_mac_config_t *mac= &dev_config.mac;
1310 
1311 		__HAL_AUX_ENTRY("tmac_util_period",
1312 				mac->tmac_util_period, "%u");
1313 		__HAL_AUX_ENTRY("rmac_util_period",
1314 				mac->rmac_util_period, "%u");
1315 		__HAL_AUX_ENTRY("rmac_bcast_en",
1316 				mac->rmac_bcast_en, "%u");
1317 		__HAL_AUX_ENTRY("rmac_pause_gen_en",
1318 				mac->rmac_pause_gen_en, "%d");
1319 		__HAL_AUX_ENTRY("rmac_pause_rcv_en",
1320 				mac->rmac_pause_rcv_en, "%d");
1321 		__HAL_AUX_ENTRY("rmac_pause_time",
1322 				mac->rmac_pause_time, "%u");
1323 		__HAL_AUX_ENTRY("mc_pause_threshold_q0q3",
1324 				mac->mc_pause_threshold_q0q3, "%u");
1325 		__HAL_AUX_ENTRY("mc_pause_threshold_q4q7",
1326 				mac->mc_pause_threshold_q4q7, "%u");
1327 	}
1328 
1329 
1330 	__HAL_AUX_ENTRY("fifo_max_frags", dev_config.fifo.max_frags, "%u");
1331 	__HAL_AUX_ENTRY("fifo_reserve_threshold",
1332 			dev_config.fifo.reserve_threshold, "%u");
1333 	__HAL_AUX_ENTRY("fifo_memblock_size",
1334 			dev_config.fifo.memblock_size, "%u");
1335 #ifdef XGE_HAL_ALIGN_XMIT
1336 	__HAL_AUX_ENTRY("fifo_alignment_size",
1337 			dev_config.fifo.alignment_size, "%u");
1338 #endif
1339 
1340 	for (i = 0; i < XGE_HAL_MAX_FIFO_NUM;  i++) {
1341 		int j;
1342 		xge_hal_fifo_queue_t *fifo = &dev_config.fifo.queue[i];
1343 
1344 		if (!fifo->configured)
1345 			continue;
1346 
1347 		(void) xge_os_sprintf(key, "fifo%d_", i);
1348 		xge_os_strcpy(key+6, "initial");
1349 		__HAL_AUX_ENTRY(key, fifo->initial, "%u");
1350 		xge_os_strcpy(key+6, "max");
1351 		__HAL_AUX_ENTRY(key, fifo->max, "%u");
1352 		xge_os_strcpy(key+6, "intr");
1353 		__HAL_AUX_ENTRY(key, fifo->intr, "%u");
1354 		xge_os_strcpy(key+6, "no_snoop_bits");
1355 		__HAL_AUX_ENTRY(key, fifo->no_snoop_bits, "%u");
1356 
1357 		for (j = 0; j < XGE_HAL_MAX_FIFO_TTI_NUM; j++) {
1358 			xge_hal_tti_config_t *tti =
1359 				&dev_config.fifo.queue[i].tti[j];
1360 
1361 			if (!tti->enabled)
1362 				continue;
1363 
1364 			(void) xge_os_sprintf(key, "fifo%d_tti%02d_", i,
1365 				i * XGE_HAL_MAX_FIFO_TTI_NUM + j);
1366 			xge_os_strcpy(key+12, "urange_a");
1367 			__HAL_AUX_ENTRY(key, tti->urange_a, "%u");
1368 			xge_os_strcpy(key+12, "ufc_a");
1369 			__HAL_AUX_ENTRY(key, tti->ufc_a, "%u");
1370 			xge_os_strcpy(key+12, "urange_b");
1371 			__HAL_AUX_ENTRY(key, tti->urange_b, "%u");
1372 			xge_os_strcpy(key+12, "ufc_b");
1373 			__HAL_AUX_ENTRY(key, tti->ufc_b, "%u");
1374 			xge_os_strcpy(key+12, "urange_c");
1375 			__HAL_AUX_ENTRY(key, tti->urange_c, "%u");
1376 			xge_os_strcpy(key+12, "ufc_c");
1377 			__HAL_AUX_ENTRY(key, tti->ufc_c, "%u");
1378 			xge_os_strcpy(key+12, "ufc_d");
1379 			__HAL_AUX_ENTRY(key, tti->ufc_d, "%u");
1380 			xge_os_strcpy(key+12, "timer_val_us");
1381 			__HAL_AUX_ENTRY(key, tti->timer_val_us, "%u");
1382 			xge_os_strcpy(key+12, "timer_ci_en");
1383 			__HAL_AUX_ENTRY(key, tti->timer_ci_en, "%u");
1384 		}
1385 	}
1386 
1387 	/* and bimodal TTIs */
1388 	for (i=0; i<XGE_HAL_MAX_RING_NUM; i++) {
1389 		xge_hal_device_t *hldev = (xge_hal_device_t*)devh;
1390 		xge_hal_tti_config_t *tti = &hldev->bimodal_tti[i];
1391 
1392 		if (!tti->enabled)
1393 			continue;
1394 
1395 		(void) xge_os_sprintf(key, "tti%02d_",
1396 			      XGE_HAL_MAX_FIFO_TTI_RING_0 + i);
1397 
1398 		xge_os_strcpy(key+6, "urange_a");
1399 		__HAL_AUX_ENTRY(key, tti->urange_a, "%u");
1400 		xge_os_strcpy(key+6, "ufc_a");
1401 		__HAL_AUX_ENTRY(key, tti->ufc_a, "%u");
1402 		xge_os_strcpy(key+6, "urange_b");
1403 		__HAL_AUX_ENTRY(key, tti->urange_b, "%u");
1404 		xge_os_strcpy(key+6, "ufc_b");
1405 		__HAL_AUX_ENTRY(key, tti->ufc_b, "%u");
1406 		xge_os_strcpy(key+6, "urange_c");
1407 		__HAL_AUX_ENTRY(key, tti->urange_c, "%u");
1408 		xge_os_strcpy(key+6, "ufc_c");
1409 		__HAL_AUX_ENTRY(key, tti->ufc_c, "%u");
1410 		xge_os_strcpy(key+6, "ufc_d");
1411 		__HAL_AUX_ENTRY(key, tti->ufc_d, "%u");
1412 		xge_os_strcpy(key+6, "timer_val_us");
1413 		__HAL_AUX_ENTRY(key, tti->timer_val_us, "%u");
1414 		xge_os_strcpy(key+6, "timer_ac_en");
1415 		__HAL_AUX_ENTRY(key, tti->timer_ac_en, "%u");
1416 		xge_os_strcpy(key+6, "timer_ci_en");
1417 		__HAL_AUX_ENTRY(key, tti->timer_ci_en, "%u");
1418 	}
1419 	__HAL_AUX_ENTRY("dump_on_serr", dev_config.dump_on_serr, "%u");
1420 	__HAL_AUX_ENTRY("dump_on_eccerr",
1421 			dev_config.dump_on_eccerr, "%u");
1422 	__HAL_AUX_ENTRY("dump_on_parityerr",
1423 			dev_config.dump_on_parityerr, "%u");
1424 	__HAL_AUX_ENTRY("rth_en", dev_config.rth_en, "%u");
1425 	__HAL_AUX_ENTRY("rth_bucket_size", dev_config.rth_bucket_size, "%u");
1426 
1427 	__HAL_AUX_ENTRY_END(bufsize, retsize);
1428 
1429 	return XGE_HAL_OK;
1430 }
1431 
1432