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.
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.
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]
21 * Copyright (c) 2002-2006 Neterion, Inc.
24 #include "xgehal-mgmt.h"
25 #include "xgehal-driver.h"
26 #include "xgehal-device.h"
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;
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;
43 #define __HAL_AUX_ENTRY_DECLARE(size, buf) \
44 int entrysize = 0, leftsize = size; \
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)
51 #define __HAL_AUX_ENTRY_END(bufsize, retsize) \
52 leftsize -= entrysize; \
53 *retsize = bufsize - leftsize;
55 #define __hal_aux_pci_link_info(name, index, var) { \
56 __HAL_AUX_ENTRY(name, \
57 (unsigned long long)pcim.link_info[index].var, "%llu") \
60 #define __hal_aux_pci_aggr_info(name, index, var) { \
61 __HAL_AUX_ENTRY(name, \
62 (unsigned long long)pcim.aggr_info[index].var, "%llu") \
66 * xge_hal_aux_bar0_read - Read and format Xframe BAR0 register.
67 * @devh: HAL device handle.
68 * @offset: Register offset in the BAR0 space.
69 * @bufsize: Buffer size.
70 * @retbuf: Buffer pointer.
71 * @retsize: Size of the result. Cannot be greater than @bufsize.
73 * Read Xframe register from BAR0 space. The result is formatted as an ascii string.
75 * Returns: XGE_HAL_OK - success.
76 * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
77 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
78 * XGE_HAL_ERR_INVALID_OFFSET - Register offset in the BAR space is not
80 * XGE_HAL_ERR_INVALID_BAR_ID - BAR id is not valid.
82 * See also: xge_hal_mgmt_reg_read().
84 xge_hal_status_e
xge_hal_aux_bar0_read(xge_hal_device_h devh
,
85 unsigned int offset
, int bufsize
, char *retbuf
,
88 xge_hal_status_e status
;
91 status
= xge_hal_mgmt_reg_read(devh
, 0, offset
, &retval
);
92 if (status
!= XGE_HAL_OK
) {
96 if (bufsize
< XGE_OS_SPRINTF_STRLEN
) {
97 return XGE_HAL_ERR_OUT_OF_SPACE
;
100 *retsize
= xge_os_snprintf(retbuf
, bufsize
, "0x%04X%c0x%08X%08X\n",
101 offset
, XGE_HAL_AUX_SEPA
, (u32
)(retval
>>32), (u32
)retval
);
107 * xge_hal_aux_bar1_read - Read and format Xframe BAR1 register.
108 * @devh: HAL device handle.
109 * @offset: Register offset in the BAR1 space.
110 * @bufsize: Buffer size.
111 * @retbuf: Buffer pointer.
112 * @retsize: Size of the result. Cannot be greater than @bufsize.
114 * Read Xframe register from BAR1 space. The result is formatted as ascii string.
115 * Returns: XGE_HAL_OK - success.
116 * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
117 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
118 * XGE_HAL_ERR_INVALID_OFFSET - Register offset in the BAR space is not
120 * XGE_HAL_ERR_INVALID_BAR_ID - BAR id is not valid.
122 * See also: xge_hal_mgmt_reg_read().
124 xge_hal_status_e
xge_hal_aux_bar1_read(xge_hal_device_h devh
,
125 unsigned int offset
, int bufsize
, char *retbuf
,
128 xge_hal_status_e status
;
131 status
= xge_hal_mgmt_reg_read(devh
, 1, offset
, &retval
);
132 if (status
!= XGE_HAL_OK
)
135 if (bufsize
< XGE_OS_SPRINTF_STRLEN
)
136 return XGE_HAL_ERR_OUT_OF_SPACE
;
138 *retsize
= xge_os_snprintf(retbuf
, bufsize
, "0x%04X%c0x%08X%08X\n",
139 offset
, XGE_HAL_AUX_SEPA
, (u32
)(retval
>>32), (u32
)retval
);
145 * xge_hal_aux_bar0_write - Write BAR0 register.
146 * @devh: HAL device handle.
147 * @offset: Register offset in the BAR0 space.
148 * @value: Regsister value (to write).
150 * Write BAR0 register.
152 * Returns: XGE_HAL_OK - success.
153 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
154 * XGE_HAL_ERR_INVALID_OFFSET - Register offset in the BAR space is not
156 * XGE_HAL_ERR_INVALID_BAR_ID - BAR id is not valid.
158 * See also: xge_hal_mgmt_reg_write().
160 xge_hal_status_e
xge_hal_aux_bar0_write(xge_hal_device_h devh
,
161 unsigned int offset
, u64 value
)
163 xge_hal_status_e status
;
165 status
= xge_hal_mgmt_reg_write(devh
, 0, offset
, value
);
166 if (status
!= XGE_HAL_OK
) {
174 * xge_hal_aux_about_read - Retrieve and format about info.
175 * @devh: HAL device handle.
176 * @bufsize: Buffer size.
177 * @retbuf: Buffer pointer.
178 * @retsize: Size of the result. Cannot be greater than @bufsize.
180 * Retrieve about info (using xge_hal_mgmt_about()) and sprintf it
181 * into the provided @retbuf.
183 * Returns: XGE_HAL_OK - success.
184 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
185 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
186 * XGE_HAL_FAIL - Failed to retrieve the information.
188 * See also: xge_hal_mgmt_about(), xge_hal_aux_device_dump().
190 xge_hal_status_e
xge_hal_aux_about_read(xge_hal_device_h devh
, int bufsize
,
191 char *retbuf
, int *retsize
)
193 xge_hal_status_e status
;
194 xge_hal_mgmt_about_info_t about_info
;
195 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
197 status
= xge_hal_mgmt_about(devh
, &about_info
,
198 sizeof(xge_hal_mgmt_about_info_t
));
199 if (status
!= XGE_HAL_OK
) {
203 __HAL_AUX_ENTRY("vendor", about_info
.vendor
, "0x%x");
204 __HAL_AUX_ENTRY("device", about_info
.device
, "0x%x");
205 __HAL_AUX_ENTRY("subsys_vendor", about_info
.subsys_vendor
, "0x%x");
206 __HAL_AUX_ENTRY("subsys_device", about_info
.subsys_device
, "0x%x");
207 __HAL_AUX_ENTRY("board_rev", about_info
.board_rev
, "0x%x");
208 __HAL_AUX_ENTRY("vendor_name", about_info
.vendor_name
, "%s");
209 __HAL_AUX_ENTRY("chip_name", about_info
.chip_name
, "%s");
210 __HAL_AUX_ENTRY("media", about_info
.media
, "%s");
211 __HAL_AUX_ENTRY("hal_major", about_info
.hal_major
, "%s");
212 __HAL_AUX_ENTRY("hal_minor", about_info
.hal_minor
, "%s");
213 __HAL_AUX_ENTRY("hal_fix", about_info
.hal_fix
, "%s");
214 __HAL_AUX_ENTRY("hal_build", about_info
.hal_build
, "%s");
215 __HAL_AUX_ENTRY("ll_major", about_info
.ll_major
, "%s");
216 __HAL_AUX_ENTRY("ll_minor", about_info
.ll_minor
, "%s");
217 __HAL_AUX_ENTRY("ll_fix", about_info
.ll_fix
, "%s");
218 __HAL_AUX_ENTRY("ll_build", about_info
.ll_build
, "%s");
220 __HAL_AUX_ENTRY("transponder_temperature",
221 about_info
.transponder_temperature
, "%d C");
223 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
229 * xge_hal_aux_stats_tmac_read - Read TMAC hardware statistics.
230 * @devh: HAL device handle.
231 * @bufsize: Buffer size.
232 * @retbuf: Buffer pointer.
233 * @retsize: Size of the result. Cannot be greater than @bufsize.
235 * Read TMAC hardware statistics. This is a subset of stats counters
236 * from xge_hal_stats_hw_info_t{}.
238 * Returns: XGE_HAL_OK - success.
239 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
240 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
242 * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
243 * xge_hal_aux_stats_pci_read(),
244 * xge_hal_aux_device_dump().
246 xge_hal_status_e
xge_hal_aux_stats_tmac_read(xge_hal_device_h devh
, int bufsize
,
247 char *retbuf
, int *retsize
)
249 xge_hal_status_e status
;
250 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
252 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
254 if (xge_hal_device_check_id(hldev
) != XGE_HAL_CARD_TITAN
) {
255 xge_hal_mgmt_hw_stats_t hw
;
257 status
= xge_hal_mgmt_hw_stats(devh
, &hw
,
258 sizeof(xge_hal_mgmt_hw_stats_t
));
259 if (status
!= XGE_HAL_OK
) {
263 __HAL_AUX_ENTRY("tmac_data_octets", hw
.tmac_data_octets
, "%u");
264 __HAL_AUX_ENTRY("tmac_frms", hw
.tmac_frms
, "%u");
265 __HAL_AUX_ENTRY("tmac_drop_frms", (unsigned long long)
266 hw
.tmac_drop_frms
, "%llu");
267 __HAL_AUX_ENTRY("tmac_bcst_frms", hw
.tmac_bcst_frms
, "%u");
268 __HAL_AUX_ENTRY("tmac_mcst_frms", hw
.tmac_mcst_frms
, "%u");
269 __HAL_AUX_ENTRY("tmac_pause_ctrl_frms", (unsigned long long)
270 hw
.tmac_pause_ctrl_frms
, "%llu");
271 __HAL_AUX_ENTRY("tmac_ucst_frms", hw
.tmac_ucst_frms
, "%u");
272 __HAL_AUX_ENTRY("tmac_ttl_octets", hw
.tmac_ttl_octets
, "%u");
273 __HAL_AUX_ENTRY("tmac_any_err_frms", hw
.tmac_any_err_frms
, "%u");
274 __HAL_AUX_ENTRY("tmac_nucst_frms", hw
.tmac_nucst_frms
, "%u");
275 __HAL_AUX_ENTRY("tmac_ttl_less_fb_octets", (unsigned long long)
276 hw
.tmac_ttl_less_fb_octets
, "%llu");
277 __HAL_AUX_ENTRY("tmac_vld_ip_octets", (unsigned long long)
278 hw
.tmac_vld_ip_octets
, "%llu");
279 __HAL_AUX_ENTRY("tmac_drop_ip", hw
.tmac_drop_ip
, "%u");
280 __HAL_AUX_ENTRY("tmac_vld_ip", hw
.tmac_vld_ip
, "%u");
281 __HAL_AUX_ENTRY("tmac_rst_tcp", hw
.tmac_rst_tcp
, "%u");
282 __HAL_AUX_ENTRY("tmac_icmp", hw
.tmac_icmp
, "%u");
283 __HAL_AUX_ENTRY("tmac_tcp", (unsigned long long)
284 hw
.tmac_tcp
, "%llu");
285 __HAL_AUX_ENTRY("reserved_0", hw
.reserved_0
, "%u");
286 __HAL_AUX_ENTRY("tmac_udp", hw
.tmac_udp
, "%u");
289 xge_hal_mgmt_pcim_stats_t pcim
;
290 status
= xge_hal_mgmt_pcim_stats(devh
, &pcim
,
291 sizeof(xge_hal_mgmt_pcim_stats_t
));
292 if (status
!= XGE_HAL_OK
) {
296 for (i
= 0; i
< XGE_HAL_MAC_LINKS
; i
++) {
297 __hal_aux_pci_link_info("tx_frms", i
,
299 __hal_aux_pci_link_info("tx_ttl_eth_octets",
300 i
, tx_ttl_eth_octets
);
301 __hal_aux_pci_link_info("tx_data_octets", i
,
303 __hal_aux_pci_link_info("tx_mcst_frms", i
,
305 __hal_aux_pci_link_info("tx_bcst_frms", i
,
307 __hal_aux_pci_link_info("tx_ucst_frms", i
,
309 __hal_aux_pci_link_info("tx_tagged_frms", i
,
311 __hal_aux_pci_link_info("tx_vld_ip", i
,
313 __hal_aux_pci_link_info("tx_vld_ip_octets", i
,
315 __hal_aux_pci_link_info("tx_icmp", i
,
317 __hal_aux_pci_link_info("tx_tcp", i
,
319 __hal_aux_pci_link_info("tx_rst_tcp", i
,
321 __hal_aux_pci_link_info("tx_udp", i
,
323 __hal_aux_pci_link_info("tx_unknown_protocol", i
,
324 tx_unknown_protocol
);
325 __hal_aux_pci_link_info("tx_parse_error", i
,
327 __hal_aux_pci_link_info("tx_pause_ctrl_frms", i
,
329 __hal_aux_pci_link_info("tx_lacpdu_frms", i
,
331 __hal_aux_pci_link_info("tx_marker_pdu_frms", i
,
333 __hal_aux_pci_link_info("tx_marker_resp_pdu_frms", i
,
334 tx_marker_resp_pdu_frms
);
335 __hal_aux_pci_link_info("tx_drop_ip", i
,
337 __hal_aux_pci_link_info("tx_xgmii_char1_match", i
,
338 tx_xgmii_char1_match
);
339 __hal_aux_pci_link_info("tx_xgmii_char2_match", i
,
340 tx_xgmii_char2_match
);
341 __hal_aux_pci_link_info("tx_xgmii_column1_match", i
,
342 tx_xgmii_column1_match
);
343 __hal_aux_pci_link_info("tx_xgmii_column2_match", i
,
344 tx_xgmii_column2_match
);
345 __hal_aux_pci_link_info("tx_drop_frms", i
,
347 __hal_aux_pci_link_info("tx_any_err_frms", i
,
351 for (i
= 0; i
< XGE_HAL_MAC_AGGREGATORS
; i
++) {
352 __hal_aux_pci_aggr_info("tx_frms", i
, tx_frms
);
353 __hal_aux_pci_aggr_info("tx_mcst_frms", i
,
355 __hal_aux_pci_aggr_info("tx_bcst_frms", i
,
357 __hal_aux_pci_aggr_info("tx_discarded_frms", i
,
359 __hal_aux_pci_aggr_info("tx_errored_frms", i
,
364 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
370 * xge_hal_aux_stats_rmac_read - Read RMAC hardware statistics.
371 * @devh: HAL device handle.
372 * @bufsize: Buffer size.
373 * @retbuf: Buffer pointer.
374 * @retsize: Size of the result. Cannot be greater than @bufsize.
376 * Read RMAC hardware statistics. This is a subset of stats counters
377 * from xge_hal_stats_hw_info_t{}.
379 * Returns: XGE_HAL_OK - success.
380 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
381 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
383 * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
384 * xge_hal_aux_stats_pci_read(), xge_hal_aux_stats_tmac_read(),
385 * xge_hal_aux_device_dump().
387 xge_hal_status_e
xge_hal_aux_stats_rmac_read(xge_hal_device_h devh
, int bufsize
,
388 char *retbuf
, int *retsize
)
390 xge_hal_status_e status
;
391 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
393 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
395 if (xge_hal_device_check_id(hldev
) != XGE_HAL_CARD_TITAN
) {
396 xge_hal_mgmt_hw_stats_t hw
;
398 status
= xge_hal_mgmt_hw_stats(devh
, &hw
,
399 sizeof(xge_hal_mgmt_hw_stats_t
));
400 if (status
!= XGE_HAL_OK
) {
404 __HAL_AUX_ENTRY("rmac_data_octets", hw
.rmac_data_octets
, "%u");
405 __HAL_AUX_ENTRY("rmac_vld_frms", hw
.rmac_vld_frms
, "%u");
406 __HAL_AUX_ENTRY("rmac_fcs_err_frms", (unsigned long long)
407 hw
.rmac_fcs_err_frms
, "%llu");
408 __HAL_AUX_ENTRY("mac_drop_frms", (unsigned long long)
409 hw
.rmac_drop_frms
, "%llu");
410 __HAL_AUX_ENTRY("rmac_vld_bcst_frms", hw
.rmac_vld_bcst_frms
,
412 __HAL_AUX_ENTRY("rmac_vld_mcst_frms", hw
.rmac_vld_mcst_frms
,
414 __HAL_AUX_ENTRY("rmac_out_rng_len_err_frms",
415 hw
.rmac_out_rng_len_err_frms
, "%u");
416 __HAL_AUX_ENTRY("rmac_in_rng_len_err_frms",
417 hw
.rmac_in_rng_len_err_frms
, "%u");
418 __HAL_AUX_ENTRY("rmac_long_frms", (unsigned long long)
419 hw
.rmac_long_frms
, "%llu");
420 __HAL_AUX_ENTRY("rmac_pause_ctrl_frms", (unsigned long long)
421 hw
.rmac_pause_ctrl_frms
, "%llu");
422 __HAL_AUX_ENTRY("rmac_unsup_ctrl_frms", (unsigned long long)
423 hw
.rmac_unsup_ctrl_frms
, "%llu");
424 __HAL_AUX_ENTRY("rmac_accepted_ucst_frms",
425 hw
.rmac_accepted_ucst_frms
, "%u");
426 __HAL_AUX_ENTRY("rmac_ttl_octets", hw
.rmac_ttl_octets
, "%u");
427 __HAL_AUX_ENTRY("rmac_discarded_frms", hw
.rmac_discarded_frms
,
429 __HAL_AUX_ENTRY("rmac_accepted_nucst_frms",
430 hw
.rmac_accepted_nucst_frms
, "%u");
431 __HAL_AUX_ENTRY("reserved_1", hw
.reserved_1
, "%u");
432 __HAL_AUX_ENTRY("rmac_drop_events", hw
.rmac_drop_events
, "%u");
433 __HAL_AUX_ENTRY("rmac_ttl_less_fb_octets", (unsigned long long)
434 hw
.rmac_ttl_less_fb_octets
, "%llu");
435 __HAL_AUX_ENTRY("rmac_ttl_frms", (unsigned long long)
436 hw
.rmac_ttl_frms
, "%llu");
437 __HAL_AUX_ENTRY("reserved_2", (unsigned long long)
438 hw
.reserved_2
, "%llu");
439 __HAL_AUX_ENTRY("rmac_usized_frms", hw
.rmac_usized_frms
, "%u");
440 __HAL_AUX_ENTRY("reserved_3", hw
.reserved_3
, "%u");
441 __HAL_AUX_ENTRY("rmac_frag_frms", hw
.rmac_frag_frms
, "%u");
442 __HAL_AUX_ENTRY("rmac_osized_frms", hw
.rmac_osized_frms
, "%u");
443 __HAL_AUX_ENTRY("reserved_4", hw
.reserved_4
, "%u");
444 __HAL_AUX_ENTRY("rmac_jabber_frms", hw
.rmac_jabber_frms
, "%u");
445 __HAL_AUX_ENTRY("rmac_ttl_64_frms", (unsigned long long)
446 hw
.rmac_ttl_64_frms
, "%llu");
447 __HAL_AUX_ENTRY("rmac_ttl_65_127_frms", (unsigned long long)
448 hw
.rmac_ttl_65_127_frms
, "%llu");
449 __HAL_AUX_ENTRY("reserved_5", (unsigned long long)
450 hw
.reserved_5
, "%llu");
451 __HAL_AUX_ENTRY("rmac_ttl_128_255_frms", (unsigned long long)
452 hw
.rmac_ttl_128_255_frms
, "%llu");
453 __HAL_AUX_ENTRY("rmac_ttl_256_511_frms", (unsigned long long)
454 hw
.rmac_ttl_256_511_frms
, "%llu");
455 __HAL_AUX_ENTRY("reserved_6", (unsigned long long)
456 hw
.reserved_6
, "%llu");
457 __HAL_AUX_ENTRY("rmac_ttl_512_1023_frms", (unsigned long long)
458 hw
.rmac_ttl_512_1023_frms
, "%llu");
459 __HAL_AUX_ENTRY("rmac_ttl_1024_1518_frms", (unsigned long long)
460 hw
.rmac_ttl_1024_1518_frms
, "%llu");
461 __HAL_AUX_ENTRY("rmac_ip", hw
.rmac_ip
, "%u");
462 __HAL_AUX_ENTRY("reserved_7", hw
.reserved_7
, "%u");
463 __HAL_AUX_ENTRY("rmac_ip_octets", (unsigned long long)
464 hw
.rmac_ip_octets
, "%llu");
465 __HAL_AUX_ENTRY("rmac_drop_ip", hw
.rmac_drop_ip
, "%u");
466 __HAL_AUX_ENTRY("rmac_hdr_err_ip", hw
.rmac_hdr_err_ip
, "%u");
467 __HAL_AUX_ENTRY("reserved_8", hw
.reserved_8
, "%u");
468 __HAL_AUX_ENTRY("rmac_icmp", hw
.rmac_icmp
, "%u");
469 __HAL_AUX_ENTRY("rmac_tcp", (unsigned long long)
470 hw
.rmac_tcp
, "%llu");
471 __HAL_AUX_ENTRY("rmac_err_drp_udp", hw
.rmac_err_drp_udp
, "%u");
472 __HAL_AUX_ENTRY("rmac_udp", hw
.rmac_udp
, "%u");
473 __HAL_AUX_ENTRY("rmac_xgmii_err_sym", (unsigned long long)
474 hw
.rmac_xgmii_err_sym
, "%llu");
475 __HAL_AUX_ENTRY("rmac_frms_q0", (unsigned long long)
476 hw
.rmac_frms_q0
, "%llu");
477 __HAL_AUX_ENTRY("rmac_frms_q1", (unsigned long long)
478 hw
.rmac_frms_q1
, "%llu");
479 __HAL_AUX_ENTRY("rmac_frms_q2", (unsigned long long)
480 hw
.rmac_frms_q2
, "%llu");
481 __HAL_AUX_ENTRY("rmac_frms_q3", (unsigned long long)
482 hw
.rmac_frms_q3
, "%llu");
483 __HAL_AUX_ENTRY("rmac_frms_q4", (unsigned long long)
484 hw
.rmac_frms_q4
, "%llu");
485 __HAL_AUX_ENTRY("rmac_frms_q5", (unsigned long long)
486 hw
.rmac_frms_q5
, "%llu");
487 __HAL_AUX_ENTRY("rmac_frms_q6", (unsigned long long)
488 hw
.rmac_frms_q6
, "%llu");
489 __HAL_AUX_ENTRY("rmac_frms_q7", (unsigned long long)
490 hw
.rmac_frms_q7
, "%llu");
491 __HAL_AUX_ENTRY("rmac_full_q3", hw
.rmac_full_q3
, "%d");
492 __HAL_AUX_ENTRY("rmac_full_q2", hw
.rmac_full_q2
, "%d");
493 __HAL_AUX_ENTRY("rmac_full_q1", hw
.rmac_full_q1
, "%d");
494 __HAL_AUX_ENTRY("rmac_full_q0", hw
.rmac_full_q0
, "%d");
495 __HAL_AUX_ENTRY("rmac_full_q7", hw
.rmac_full_q7
, "%d");
496 __HAL_AUX_ENTRY("rmac_full_q6", hw
.rmac_full_q6
, "%d");
497 __HAL_AUX_ENTRY("rmac_full_q5", hw
.rmac_full_q5
, "%d");
498 __HAL_AUX_ENTRY("rmac_full_q4", hw
.rmac_full_q4
, "%d");
499 __HAL_AUX_ENTRY("reserved_9", hw
.reserved_9
, "%u");
500 __HAL_AUX_ENTRY("rmac_pause_cnt", hw
.rmac_pause_cnt
, "%u");
501 __HAL_AUX_ENTRY("rmac_xgmii_data_err_cnt", (unsigned long long)
502 hw
.rmac_xgmii_data_err_cnt
, "%llu");
503 __HAL_AUX_ENTRY("rmac_xgmii_ctrl_err_cnt", (unsigned long long)
504 hw
.rmac_xgmii_ctrl_err_cnt
, "%llu");
505 __HAL_AUX_ENTRY("rmac_err_tcp", hw
.rmac_err_tcp
, "%u");
506 __HAL_AUX_ENTRY("rmac_accepted_ip", hw
.rmac_accepted_ip
, "%u");
509 xge_hal_mgmt_pcim_stats_t pcim
;
510 status
= xge_hal_mgmt_pcim_stats(devh
, &pcim
,
511 sizeof(xge_hal_mgmt_pcim_stats_t
));
512 if (status
!= XGE_HAL_OK
) {
515 for (i
= 0; i
< XGE_HAL_MAC_LINKS
; i
++) {
516 __hal_aux_pci_link_info("rx_ttl_frms", i
,
518 __hal_aux_pci_link_info("rx_vld_frms", i
,
520 __hal_aux_pci_link_info("rx_offld_frms", i
,
522 __hal_aux_pci_link_info("rx_ttl_eth_octets", i
,
524 __hal_aux_pci_link_info("rx_data_octets", i
,
526 __hal_aux_pci_link_info("rx_offld_octets", i
,
528 __hal_aux_pci_link_info("rx_vld_mcst_frms", i
,
530 __hal_aux_pci_link_info("rx_vld_bcst_frms", i
,
532 __hal_aux_pci_link_info("rx_accepted_ucst_frms", i
,
533 rx_accepted_ucst_frms
);
534 __hal_aux_pci_link_info("rx_accepted_nucst_frms", i
,
535 rx_accepted_nucst_frms
);
536 __hal_aux_pci_link_info("rx_tagged_frms", i
,
538 __hal_aux_pci_link_info("rx_long_frms", i
,
540 __hal_aux_pci_link_info("rx_usized_frms", i
,
542 __hal_aux_pci_link_info("rx_osized_frms", i
,
544 __hal_aux_pci_link_info("rx_frag_frms", i
,
546 __hal_aux_pci_link_info("rx_jabber_frms", i
,
548 __hal_aux_pci_link_info("rx_ttl_64_frms", i
,
550 __hal_aux_pci_link_info("rx_ttl_65_127_frms", i
,
552 __hal_aux_pci_link_info("rx_ttl_128_255_frms", i
,
553 rx_ttl_128_255_frms
);
554 __hal_aux_pci_link_info("rx_ttl_256_511_frms", i
,
555 rx_ttl_256_511_frms
);
556 __hal_aux_pci_link_info("rx_ttl_512_1023_frms", i
,
557 rx_ttl_512_1023_frms
);
558 __hal_aux_pci_link_info("rx_ttl_1024_1518_frms", i
,
559 rx_ttl_1024_1518_frms
);
560 __hal_aux_pci_link_info("rx_ttl_1519_4095_frms", i
,
561 rx_ttl_1519_4095_frms
);
562 __hal_aux_pci_link_info("rx_ttl_40956_8191_frms", i
,
563 rx_ttl_40956_8191_frms
);
564 __hal_aux_pci_link_info("rx_ttl_8192_max_frms", i
,
565 rx_ttl_8192_max_frms
);
566 __hal_aux_pci_link_info("rx_ttl_gt_max_frms", i
,
568 __hal_aux_pci_link_info("rx_ip", i
,
570 __hal_aux_pci_link_info("rx_ip_octets", i
,
573 __hal_aux_pci_link_info("rx_hdr_err_ip", i
,
576 __hal_aux_pci_link_info("rx_icmp", i
,
578 __hal_aux_pci_link_info("rx_tcp", i
,
580 __hal_aux_pci_link_info("rx_udp", i
,
582 __hal_aux_pci_link_info("rx_err_tcp", i
,
584 __hal_aux_pci_link_info("rx_pause_cnt", i
,
586 __hal_aux_pci_link_info("rx_pause_ctrl_frms", i
,
588 __hal_aux_pci_link_info("rx_unsup_ctrl_frms", i
,
590 __hal_aux_pci_link_info("rx_in_rng_len_err_frms", i
,
591 rx_in_rng_len_err_frms
);
592 __hal_aux_pci_link_info("rx_out_rng_len_err_frms", i
,
593 rx_out_rng_len_err_frms
);
594 __hal_aux_pci_link_info("rx_drop_frms", i
,
596 __hal_aux_pci_link_info("rx_discarded_frms", i
,
598 __hal_aux_pci_link_info("rx_drop_ip", i
,
600 __hal_aux_pci_link_info("rx_err_drp_udp", i
,
602 __hal_aux_pci_link_info("rx_lacpdu_frms", i
,
604 __hal_aux_pci_link_info("rx_marker_pdu_frms", i
,
606 __hal_aux_pci_link_info("rx_marker_resp_pdu_frms", i
,
607 rx_marker_resp_pdu_frms
);
608 __hal_aux_pci_link_info("rx_unknown_pdu_frms", i
,
609 rx_unknown_pdu_frms
);
610 __hal_aux_pci_link_info("rx_illegal_pdu_frms", i
,
611 rx_illegal_pdu_frms
);
612 __hal_aux_pci_link_info("rx_fcs_discard", i
,
614 __hal_aux_pci_link_info("rx_len_discard", i
,
616 __hal_aux_pci_link_info("rx_pf_discard", i
,
618 __hal_aux_pci_link_info("rx_trash_discard", i
,
620 __hal_aux_pci_link_info("rx_rts_discard", i
,
622 __hal_aux_pci_link_info("rx_wol_discard", i
,
624 __hal_aux_pci_link_info("rx_red_discard", i
,
626 __hal_aux_pci_link_info("rx_ingm_full_discard", i
,
627 rx_ingm_full_discard
);
628 __hal_aux_pci_link_info("rx_xgmii_data_err_cnt", i
,
629 rx_xgmii_data_err_cnt
);
630 __hal_aux_pci_link_info("rx_xgmii_ctrl_err_cnt", i
,
631 rx_xgmii_ctrl_err_cnt
);
632 __hal_aux_pci_link_info("rx_xgmii_err_sym", i
,
634 __hal_aux_pci_link_info("rx_xgmii_char1_match", i
,
635 rx_xgmii_char1_match
);
636 __hal_aux_pci_link_info("rx_xgmii_char2_match", i
,
637 rx_xgmii_char2_match
);
638 __hal_aux_pci_link_info("rx_xgmii_column1_match", i
,
639 rx_xgmii_column1_match
);
640 __hal_aux_pci_link_info("rx_xgmii_column2_match", i
,
641 rx_xgmii_column2_match
);
642 __hal_aux_pci_link_info("rx_local_fault", i
,
644 __hal_aux_pci_link_info("rx_remote_fault", i
,
646 __hal_aux_pci_link_info("rx_queue_full", i
,
649 for (i
= 0; i
< XGE_HAL_MAC_AGGREGATORS
; i
++) {
650 __hal_aux_pci_aggr_info("rx_frms", i
, rx_frms
);
651 __hal_aux_pci_link_info("rx_data_octets", i
,
653 __hal_aux_pci_aggr_info("rx_mcst_frms", i
,
655 __hal_aux_pci_aggr_info("rx_bcst_frms", i
,
657 __hal_aux_pci_aggr_info("rx_discarded_frms", i
,
659 __hal_aux_pci_aggr_info("rx_errored_frms", i
,
661 __hal_aux_pci_aggr_info("rx_unknown_protocol_frms", i
,
662 rx_unknown_protocol_frms
);
666 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
672 * xge_hal_aux_stats_herc_enchanced - Get Hercules hardware statistics.
673 * @devh: HAL device handle.
674 * @bufsize: Buffer size.
675 * @retbuf: Buffer pointer.
676 * @retsize: Size of the result. Cannot be greater than @bufsize.
678 * Read Hercules device hardware statistics.
680 * Returns: XGE_HAL_OK - success.
681 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
682 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
684 * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
685 * xge_hal_aux_stats_tmac_read(), xge_hal_aux_stats_rmac_read(),
686 * xge_hal_aux_device_dump().
688 xge_hal_status_e
xge_hal_aux_stats_herc_enchanced(xge_hal_device_h devh
,
689 int bufsize
, char *retbuf
, int *retsize
)
691 xge_hal_status_e status
;
692 xge_hal_mgmt_hw_stats_t hw
;
693 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
695 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
697 if (xge_hal_device_check_id(hldev
) == XGE_HAL_CARD_TITAN
) {
699 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
705 status
= xge_hal_mgmt_hw_stats(devh
, &hw
,
706 sizeof(xge_hal_mgmt_hw_stats_t
));
707 if (status
!= XGE_HAL_OK
) {
710 __HAL_AUX_ENTRY("tmac_frms_oflow", hw
.tmac_frms_oflow
, "%u");
711 __HAL_AUX_ENTRY("tmac_data_octets_oflow", hw
.tmac_data_octets_oflow
,
713 __HAL_AUX_ENTRY("tmac_mcst_frms_oflow", hw
.tmac_mcst_frms_oflow
, "%u");
714 __HAL_AUX_ENTRY("tmac_bcst_frms_oflow", hw
.tmac_bcst_frms_oflow
, "%u");
715 __HAL_AUX_ENTRY("tmac_ttl_octets_oflow", hw
.tmac_ttl_octets_oflow
,
717 __HAL_AUX_ENTRY("tmac_ucst_frms_oflow", hw
.tmac_ucst_frms_oflow
, "%u");
718 __HAL_AUX_ENTRY("tmac_nucst_frms_oflow", hw
.tmac_nucst_frms_oflow
,
720 __HAL_AUX_ENTRY("tmac_any_err_frms_oflow", hw
.tmac_any_err_frms_oflow
,
722 __HAL_AUX_ENTRY("tmac_vlan_frms", (unsigned long long)hw
.tmac_vlan_frms
,
724 __HAL_AUX_ENTRY("tmac_vld_ip_oflow", hw
.tmac_vld_ip_oflow
, "%u");
725 __HAL_AUX_ENTRY("tmac_drop_ip_oflow", hw
.tmac_drop_ip_oflow
, "%u");
726 __HAL_AUX_ENTRY("tmac_icmp_oflow", hw
.tmac_icmp_oflow
, "%u");
727 __HAL_AUX_ENTRY("tmac_rst_tcp_oflow", hw
.tmac_rst_tcp_oflow
, "%u");
728 __HAL_AUX_ENTRY("tmac_udp_oflow", hw
.tmac_udp_oflow
, "%u");
729 __HAL_AUX_ENTRY("tpa_unknown_protocol", hw
.tpa_unknown_protocol
, "%u");
730 __HAL_AUX_ENTRY("tpa_parse_failure", hw
.tpa_parse_failure
, "%u");
731 __HAL_AUX_ENTRY("rmac_vld_frms_oflow", hw
.rmac_vld_frms_oflow
, "%u");
732 __HAL_AUX_ENTRY("rmac_data_octets_oflow", hw
.rmac_data_octets_oflow
,
734 __HAL_AUX_ENTRY("rmac_vld_mcst_frms_oflow", hw
.rmac_vld_mcst_frms_oflow
,
736 __HAL_AUX_ENTRY("rmac_vld_bcst_frms_oflow", hw
.rmac_vld_bcst_frms_oflow
,
738 __HAL_AUX_ENTRY("rmac_ttl_octets_oflow", hw
.rmac_ttl_octets_oflow
,
740 __HAL_AUX_ENTRY("rmac_accepted_ucst_frms_oflow",
741 hw
.rmac_accepted_ucst_frms_oflow
, "%u");
742 __HAL_AUX_ENTRY("rmac_accepted_nucst_frms_oflow",
743 hw
.rmac_accepted_nucst_frms_oflow
, "%u");
744 __HAL_AUX_ENTRY("rmac_discarded_frms_oflow",
745 hw
.rmac_discarded_frms_oflow
, "%u");
746 __HAL_AUX_ENTRY("rmac_drop_events_oflow", hw
.rmac_drop_events_oflow
,
748 __HAL_AUX_ENTRY("rmac_usized_frms_oflow", hw
.rmac_usized_frms_oflow
,
750 __HAL_AUX_ENTRY("rmac_osized_frms_oflow", hw
.rmac_osized_frms_oflow
,
752 __HAL_AUX_ENTRY("rmac_frag_frms_oflow", hw
.rmac_frag_frms_oflow
, "%u");
753 __HAL_AUX_ENTRY("rmac_jabber_frms_oflow", hw
.rmac_jabber_frms_oflow
,
755 __HAL_AUX_ENTRY("rmac_ip_oflow", hw
.rmac_ip_oflow
, "%u");
756 __HAL_AUX_ENTRY("rmac_drop_ip_oflow", hw
.rmac_drop_ip_oflow
, "%u");
757 __HAL_AUX_ENTRY("rmac_icmp_oflow", hw
.rmac_icmp_oflow
, "%u");
758 __HAL_AUX_ENTRY("rmac_udp_oflow", hw
.rmac_udp_oflow
, "%u");
759 __HAL_AUX_ENTRY("rmac_err_drp_udp_oflow", hw
.rmac_err_drp_udp_oflow
,
761 __HAL_AUX_ENTRY("rmac_pause_cnt_oflow", hw
.rmac_pause_cnt_oflow
, "%u");
762 __HAL_AUX_ENTRY("rmac_ttl_1519_4095_frms",
763 (unsigned long long)hw
.rmac_ttl_1519_4095_frms
, "%llu");
764 __HAL_AUX_ENTRY("rmac_ttl_4096_8191_frms",
765 (unsigned long long)hw
.rmac_ttl_4096_8191_frms
, "%llu");
766 __HAL_AUX_ENTRY("rmac_ttl_8192_max_frms",
767 (unsigned long long)hw
.rmac_ttl_8192_max_frms
, "%llu");
768 __HAL_AUX_ENTRY("rmac_ttl_gt_max_frms",
769 (unsigned long long)hw
.rmac_ttl_gt_max_frms
, "%llu");
770 __HAL_AUX_ENTRY("rmac_osized_alt_frms",
771 (unsigned long long)hw
.rmac_osized_alt_frms
, "%llu");
772 __HAL_AUX_ENTRY("rmac_jabber_alt_frms",
773 (unsigned long long)hw
.rmac_jabber_alt_frms
, "%llu");
774 __HAL_AUX_ENTRY("rmac_gt_max_alt_frms",
775 (unsigned long long)hw
.rmac_gt_max_alt_frms
, "%llu");
776 __HAL_AUX_ENTRY("rmac_vlan_frms",
777 (unsigned long long)hw
.rmac_vlan_frms
, "%llu");
778 __HAL_AUX_ENTRY("rmac_fcs_discard", hw
.rmac_fcs_discard
, "%u");
779 __HAL_AUX_ENTRY("rmac_len_discard", hw
.rmac_len_discard
, "%u");
780 __HAL_AUX_ENTRY("rmac_da_discard", hw
.rmac_da_discard
, "%u");
781 __HAL_AUX_ENTRY("rmac_pf_discard", hw
.rmac_pf_discard
, "%u");
782 __HAL_AUX_ENTRY("rmac_rts_discard", hw
.rmac_rts_discard
, "%u");
783 __HAL_AUX_ENTRY("rmac_red_discard", hw
.rmac_red_discard
, "%u");
784 __HAL_AUX_ENTRY("rmac_ingm_full_discard", hw
.rmac_ingm_full_discard
,
786 __HAL_AUX_ENTRY("rmac_accepted_ip_oflow", hw
.rmac_accepted_ip_oflow
,
788 __HAL_AUX_ENTRY("link_fault_cnt", hw
.link_fault_cnt
, "%u");
790 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
796 * xge_hal_aux_stats_rmac_read - Read PCI hardware statistics.
797 * @devh: HAL device handle.
798 * @bufsize: Buffer size.
799 * @retbuf: Buffer pointer.
800 * @retsize: Size of the result. Cannot be greater than @bufsize.
802 * Read PCI statistics counters, including number of PCI read and
803 * write transactions, PCI retries, discards, etc.
804 * This is a subset of stats counters from xge_hal_stats_hw_info_t{}.
806 * Returns: XGE_HAL_OK - success.
807 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
808 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
810 * See also: xge_hal_mgmt_hw_stats{}, xge_hal_stats_hw_info_t{},
811 * xge_hal_aux_stats_tmac_read(), xge_hal_aux_stats_rmac_read(),
812 * xge_hal_aux_device_dump().
814 xge_hal_status_e
xge_hal_aux_stats_pci_read(xge_hal_device_h devh
, int bufsize
,
815 char *retbuf
, int *retsize
)
817 xge_hal_status_e status
;
818 xge_hal_mgmt_hw_stats_t hw
;
819 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
821 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
823 if (xge_hal_device_check_id(hldev
) == XGE_HAL_CARD_TITAN
) {
825 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
831 status
= xge_hal_mgmt_hw_stats(devh
, &hw
,
832 sizeof(xge_hal_mgmt_hw_stats_t
));
833 if (status
!= XGE_HAL_OK
) {
837 __HAL_AUX_ENTRY("new_rd_req_cnt", hw
.new_rd_req_cnt
, "%u");
838 __HAL_AUX_ENTRY("rd_req_cnt", hw
.rd_req_cnt
, "%u");
839 __HAL_AUX_ENTRY("rd_rtry_cnt", hw
.rd_rtry_cnt
, "%u");
840 __HAL_AUX_ENTRY("new_rd_req_rtry_cnt", hw
.new_rd_req_rtry_cnt
, "%u");
841 __HAL_AUX_ENTRY("wr_req_cnt", hw
.wr_req_cnt
, "%u");
842 __HAL_AUX_ENTRY("wr_rtry_rd_ack_cnt", hw
.wr_rtry_rd_ack_cnt
, "%u");
843 __HAL_AUX_ENTRY("new_wr_req_rtry_cnt", hw
.new_wr_req_rtry_cnt
, "%u");
844 __HAL_AUX_ENTRY("new_wr_req_cnt", hw
.new_wr_req_cnt
, "%u");
845 __HAL_AUX_ENTRY("wr_disc_cnt", hw
.wr_disc_cnt
, "%u");
846 __HAL_AUX_ENTRY("wr_rtry_cnt", hw
.wr_rtry_cnt
, "%u");
847 __HAL_AUX_ENTRY("txp_wr_cnt", hw
.txp_wr_cnt
, "%u");
848 __HAL_AUX_ENTRY("rd_rtry_wr_ack_cnt", hw
.rd_rtry_wr_ack_cnt
, "%u");
849 __HAL_AUX_ENTRY("txd_wr_cnt", hw
.txd_wr_cnt
, "%u");
850 __HAL_AUX_ENTRY("txd_rd_cnt", hw
.txd_rd_cnt
, "%u");
851 __HAL_AUX_ENTRY("rxd_wr_cnt", hw
.rxd_wr_cnt
, "%u");
852 __HAL_AUX_ENTRY("rxd_rd_cnt", hw
.rxd_rd_cnt
, "%u");
853 __HAL_AUX_ENTRY("rxf_wr_cnt", hw
.rxf_wr_cnt
, "%u");
854 __HAL_AUX_ENTRY("txf_rd_cnt", hw
.txf_rd_cnt
, "%u");
856 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
862 * xge_hal_aux_stats_hal_read - Read HAL (layer) statistics.
863 * @devh: HAL device handle.
864 * @bufsize: Buffer size.
865 * @retbuf: Buffer pointer.
866 * @retsize: Size of the result. Cannot be greater than @bufsize.
868 * Read HAL statistics.
870 * Returns: XGE_HAL_OK - success.
871 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
872 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
873 * XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
874 * currently available.
876 * See also: xge_hal_aux_device_dump().
878 xge_hal_status_e
xge_hal_aux_stats_hal_read(xge_hal_device_h devh
,
879 int bufsize
, char *retbuf
, int *retsize
)
882 xge_hal_channel_t
*channel
;
883 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
884 xge_hal_status_e status
;
885 xge_hal_mgmt_device_stats_t devstat
;
886 xge_hal_mgmt_channel_stats_t chstat
;
887 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
891 char key
[XGE_OS_SPRINTF_STRLEN
];
893 status
= xge_hal_mgmt_device_stats(hldev
, &devstat
,
894 sizeof(xge_hal_mgmt_device_stats_t
));
895 if (status
!= XGE_HAL_OK
) {
899 if (!hldev
->config
.bimodal_interrupts
) {
900 __HAL_AUX_ENTRY("rx_traffic_intr_cnt",
901 devstat
.rx_traffic_intr_cnt
, "%u");
903 __HAL_AUX_ENTRY("tx_traffic_intr_cnt", devstat
.tx_traffic_intr_cnt
, "%u");
904 __HAL_AUX_ENTRY("txpic_intr_cnt", devstat
.txpic_intr_cnt
, "%u");
905 __HAL_AUX_ENTRY("txdma_intr_cnt", devstat
.txdma_intr_cnt
, "%u");
906 __HAL_AUX_ENTRY("txmac_intr_cnt", devstat
.txmac_intr_cnt
, "%u");
907 __HAL_AUX_ENTRY("txxgxs_intr_cnt", devstat
.txxgxs_intr_cnt
, "%u");
908 __HAL_AUX_ENTRY("rxpic_intr_cnt", devstat
.rxpic_intr_cnt
, "%u");
909 __HAL_AUX_ENTRY("rxdma_intr_cnt", devstat
.rxdma_intr_cnt
, "%u");
910 __HAL_AUX_ENTRY("rxmac_intr_cnt", devstat
.rxmac_intr_cnt
, "%u");
911 __HAL_AUX_ENTRY("rxxgxs_intr_cnt", devstat
.rxxgxs_intr_cnt
, "%u");
912 __HAL_AUX_ENTRY("mc_intr_cnt", devstat
.mc_intr_cnt
, "%u");
913 __HAL_AUX_ENTRY("not_xge_intr_cnt", devstat
.not_xge_intr_cnt
, "%u");
914 __HAL_AUX_ENTRY("not_traffic_intr_cnt",
915 devstat
.not_traffic_intr_cnt
, "%u");
916 __HAL_AUX_ENTRY("traffic_intr_cnt", devstat
.traffic_intr_cnt
, "%u");
917 __HAL_AUX_ENTRY("total_intr_cnt", devstat
.total_intr_cnt
, "%u");
918 __HAL_AUX_ENTRY("soft_reset_cnt", devstat
.soft_reset_cnt
, "%u");
920 if (hldev
->config
.rxufca_hi_lim
!= hldev
->config
.rxufca_lo_lim
&&
921 hldev
->config
.rxufca_lo_lim
!= 0) {
922 __HAL_AUX_ENTRY("rxufca_lo_adjust_cnt",
923 devstat
.rxufca_lo_adjust_cnt
, "%u");
924 __HAL_AUX_ENTRY("rxufca_hi_adjust_cnt",
925 devstat
.rxufca_hi_adjust_cnt
, "%u");
928 if (hldev
->config
.bimodal_interrupts
) {
929 __HAL_AUX_ENTRY("bimodal_lo_adjust_cnt",
930 devstat
.bimodal_lo_adjust_cnt
, "%u");
931 __HAL_AUX_ENTRY("bimodal_hi_adjust_cnt",
932 devstat
.bimodal_hi_adjust_cnt
, "%u");
935 #if defined(XGE_HAL_CONFIG_LRO)
936 __HAL_AUX_ENTRY("tot_frms_lroised",
937 devstat
.tot_frms_lroised
, "%u");
938 __HAL_AUX_ENTRY("tot_lro_sessions",
939 devstat
.tot_lro_sessions
, "%u");
940 __HAL_AUX_ENTRY("lro_frm_len_exceed_cnt",
941 devstat
.lro_frm_len_exceed_cnt
, "%u");
942 __HAL_AUX_ENTRY("lro_sg_exceed_cnt",
943 devstat
.lro_sg_exceed_cnt
, "%u");
944 __HAL_AUX_ENTRY("lro_out_of_seq_pkt_cnt",
945 devstat
.lro_out_of_seq_pkt_cnt
, "%u");
946 __HAL_AUX_ENTRY("lro_dup_pkt_cnt",
947 devstat
.lro_dup_pkt_cnt
, "%u");
950 /* for each opened rx channel */
951 xge_list_for_each(item
, &hldev
->ring_channels
) {
952 channel
= xge_container_of(item
, xge_hal_channel_t
, item
);
953 status
= xge_hal_mgmt_channel_stats(channel
, &chstat
,
954 sizeof(xge_hal_mgmt_channel_stats_t
));
955 if (status
!= XGE_HAL_OK
) {
959 (void) xge_os_snprintf(key
, sizeof(key
), "ring%d_", channel
->post_qid
);
961 dest_addr
= key
+ strlen(key
);
962 dest_size
= sizeof(key
) - strlen(key
);
964 xge_os_strlcpy(dest_addr
, "full_cnt", dest_size
);
965 __HAL_AUX_ENTRY(key
, chstat
.full_cnt
, "%u");
967 xge_os_strlcpy(dest_addr
, "usage_max", dest_size
);
968 __HAL_AUX_ENTRY(key
, chstat
.usage_max
, "%u");
970 xge_os_strlcpy(dest_addr
, "usage_cnt", dest_size
);
971 __HAL_AUX_ENTRY(key
, channel
->usage_cnt
, "%u");
973 xge_os_strlcpy(dest_addr
, "reserve_free_swaps_cnt", dest_size
);
974 __HAL_AUX_ENTRY(key
, chstat
.reserve_free_swaps_cnt
, "%u");
976 if (!hldev
->config
.bimodal_interrupts
) {
977 xge_os_strlcpy(dest_addr
, "avg_compl_per_intr_cnt", dest_size
);
978 __HAL_AUX_ENTRY(key
, chstat
.avg_compl_per_intr_cnt
, "%u");
981 xge_os_strlcpy(dest_addr
, "total_compl_cnt", dest_size
);
982 __HAL_AUX_ENTRY(key
, chstat
.total_compl_cnt
, "%u");
984 xge_os_strlcpy(dest_addr
, "bump_cnt", dest_size
);
985 __HAL_AUX_ENTRY(key
, chstat
.ring_bump_cnt
, "%u");
988 /* for each opened tx channel */
989 xge_list_for_each(item
, &hldev
->fifo_channels
) {
990 channel
= xge_container_of(item
, xge_hal_channel_t
, item
);
992 status
= xge_hal_mgmt_channel_stats(channel
, &chstat
,
993 sizeof(xge_hal_mgmt_channel_stats_t
));
994 if (status
!= XGE_HAL_OK
) {
998 (void) xge_os_snprintf(key
, sizeof(key
), "fifo%d_", channel
->post_qid
);
1000 dest_addr
= key
+ strlen(key
);
1001 dest_size
= sizeof(key
) - strlen(key
);
1003 xge_os_strlcpy(dest_addr
, "full_cnt", dest_size
);
1004 __HAL_AUX_ENTRY(key
, chstat
.full_cnt
, "%u");
1006 xge_os_strlcpy(dest_addr
, "usage_max", dest_size
);
1007 __HAL_AUX_ENTRY(key
, chstat
.usage_max
, "%u");
1009 xge_os_strlcpy(dest_addr
, "usage_cnt", dest_size
);
1010 __HAL_AUX_ENTRY(key
, channel
->usage_cnt
, "%u");
1012 xge_os_strlcpy(dest_addr
, "reserve_free_swaps_cnt", dest_size
);
1013 __HAL_AUX_ENTRY(key
, chstat
.reserve_free_swaps_cnt
, "%u");
1015 xge_os_strlcpy(dest_addr
, "avg_compl_per_intr_cnt", dest_size
);
1016 __HAL_AUX_ENTRY(key
, chstat
.avg_compl_per_intr_cnt
, "%u");
1018 xge_os_strlcpy(dest_addr
, "total_compl_cnt", dest_size
);
1019 __HAL_AUX_ENTRY(key
, chstat
.total_compl_cnt
, "%u");
1021 xge_os_strlcpy(dest_addr
, "total_posts", dest_size
);
1022 __HAL_AUX_ENTRY(key
, chstat
.total_posts
, "%u");
1024 xge_os_strlcpy(dest_addr
, "total_posts_many", dest_size
);
1025 __HAL_AUX_ENTRY(key
, chstat
.total_posts_many
, "%u");
1027 xge_os_strlcpy(dest_addr
, "copied_frags", dest_size
);
1028 __HAL_AUX_ENTRY(key
, chstat
.copied_frags
, "%u");
1030 xge_os_strlcpy(dest_addr
, "copied_buffers", dest_size
);
1031 __HAL_AUX_ENTRY(key
, chstat
.copied_buffers
, "%u");
1033 xge_os_strlcpy(dest_addr
, "total_buffers", dest_size
);
1034 __HAL_AUX_ENTRY(key
, chstat
.total_buffers
, "%u");
1036 xge_os_strlcpy(dest_addr
, "avg_buffers_per_post", dest_size
);
1037 __HAL_AUX_ENTRY(key
, chstat
.avg_buffers_per_post
, "%u");
1039 xge_os_strlcpy(dest_addr
, "avg_buffer_size", dest_size
);
1040 __HAL_AUX_ENTRY(key
, chstat
.avg_buffer_size
, "%u");
1042 xge_os_strlcpy(dest_addr
, "avg_post_size", dest_size
);
1043 __HAL_AUX_ENTRY(key
, chstat
.avg_post_size
, "%u");
1045 xge_os_strlcpy(dest_addr
, "total_posts_dtrs_many", dest_size
);
1046 __HAL_AUX_ENTRY(key
, chstat
.total_posts_dtrs_many
, "%u");
1048 xge_os_strlcpy(dest_addr
, "total_posts_frags_many", dest_size
);
1049 __HAL_AUX_ENTRY(key
, chstat
.total_posts_frags_many
, "%u");
1051 xge_os_strlcpy(dest_addr
, "total_posts_dang_dtrs", dest_size
);
1052 __HAL_AUX_ENTRY(key
, chstat
.total_posts_dang_dtrs
, "%u");
1054 xge_os_strlcpy(dest_addr
, "total_posts_dang_frags", dest_size
);
1055 __HAL_AUX_ENTRY(key
, chstat
.total_posts_dang_frags
, "%u");
1058 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
1066 * xge_hal_aux_stats_sw_dev_read - Read software device statistics.
1067 * @devh: HAL device handle.
1068 * @bufsize: Buffer size.
1069 * @retbuf: Buffer pointer.
1070 * @retsize: Size of the result. Cannot be greater than @bufsize.
1072 * Read software-maintained device statistics.
1074 * Returns: XGE_HAL_OK - success.
1075 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1076 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
1077 * XGE_HAL_INF_STATS_IS_NOT_READY - Statistics information is not
1078 * currently available.
1080 * See also: xge_hal_aux_device_dump().
1082 xge_hal_status_e
xge_hal_aux_stats_sw_dev_read(xge_hal_device_h devh
,
1083 int bufsize
, char *retbuf
, int *retsize
)
1085 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
1086 xge_hal_status_e status
;
1087 xge_hal_mgmt_sw_stats_t sw_dev_err_stats
;
1088 int t_code
, t_code_cnt
;
1089 char buf
[XGE_OS_SPRINTF_STRLEN
];
1091 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
1093 status
= xge_hal_mgmt_sw_stats(hldev
, &sw_dev_err_stats
,
1094 sizeof(xge_hal_mgmt_sw_stats_t
));
1095 if (status
!= XGE_HAL_OK
) {
1099 __HAL_AUX_ENTRY("sm_err_cnt",sw_dev_err_stats
.sm_err_cnt
, "%u");
1100 __HAL_AUX_ENTRY("single_ecc_err_cnt",sw_dev_err_stats
.single_ecc_err_cnt
, "%u");
1101 __HAL_AUX_ENTRY("double_ecc_err_cnt",sw_dev_err_stats
.double_ecc_err_cnt
, "%u");
1102 __HAL_AUX_ENTRY("ecc_err_cnt", sw_dev_err_stats
.ecc_err_cnt
, "%u");
1103 __HAL_AUX_ENTRY("parity_err_cnt",sw_dev_err_stats
.parity_err_cnt
, "%u");
1104 __HAL_AUX_ENTRY("serr_cnt",sw_dev_err_stats
.serr_cnt
, "%u");
1106 for (t_code
= 1; t_code
< 16; t_code
++) {
1107 t_code_cnt
= sw_dev_err_stats
.rxd_t_code_err_cnt
[t_code
];
1109 (void) xge_os_snprintf(buf
, sizeof(buf
), "rxd_t_code_%d", t_code
);
1110 __HAL_AUX_ENTRY(buf
, t_code_cnt
, "%u");
1112 t_code_cnt
= sw_dev_err_stats
.txd_t_code_err_cnt
[t_code
];
1114 (void) xge_os_snprintf(buf
, sizeof(buf
), "txd_t_code_%d", t_code
);
1115 __HAL_AUX_ENTRY(buf
, t_code_cnt
, "%u");
1118 __HAL_AUX_ENTRY("alarm_transceiver_temp_high",sw_dev_err_stats
.
1119 stats_xpak
.alarm_transceiver_temp_high
, "%u");
1120 __HAL_AUX_ENTRY("alarm_transceiver_temp_low",sw_dev_err_stats
.
1121 stats_xpak
.alarm_transceiver_temp_low
, "%u");
1122 __HAL_AUX_ENTRY("alarm_laser_bias_current_high",sw_dev_err_stats
.
1123 stats_xpak
.alarm_laser_bias_current_high
, "%u");
1124 __HAL_AUX_ENTRY("alarm_laser_bias_current_low",sw_dev_err_stats
.
1125 stats_xpak
.alarm_laser_bias_current_low
, "%u");
1126 __HAL_AUX_ENTRY("alarm_laser_output_power_high",sw_dev_err_stats
.
1127 stats_xpak
.alarm_laser_output_power_high
, "%u");
1128 __HAL_AUX_ENTRY("alarm_laser_output_power_low",sw_dev_err_stats
.
1129 stats_xpak
.alarm_laser_output_power_low
, "%u");
1130 __HAL_AUX_ENTRY("warn_transceiver_temp_high",sw_dev_err_stats
.
1131 stats_xpak
.warn_transceiver_temp_high
, "%u");
1132 __HAL_AUX_ENTRY("warn_transceiver_temp_low",sw_dev_err_stats
.
1133 stats_xpak
.warn_transceiver_temp_low
, "%u");
1134 __HAL_AUX_ENTRY("warn_laser_bias_current_high",sw_dev_err_stats
.
1135 stats_xpak
.warn_laser_bias_current_high
, "%u");
1136 __HAL_AUX_ENTRY("warn_laser_bias_current_low",sw_dev_err_stats
.
1137 stats_xpak
.warn_laser_bias_current_low
, "%u");
1138 __HAL_AUX_ENTRY("warn_laser_output_power_high",sw_dev_err_stats
.
1139 stats_xpak
.warn_laser_output_power_high
, "%u");
1140 __HAL_AUX_ENTRY("warn_laser_output_power_low",sw_dev_err_stats
.
1141 stats_xpak
.warn_laser_output_power_low
, "%u");
1143 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
1149 * xge_hal_aux_pci_config_read - Retrieve and format PCI Configuration
1151 * @devh: HAL device handle.
1152 * @bufsize: Buffer size.
1153 * @retbuf: Buffer pointer.
1154 * @retsize: Size of the result. Cannot be greater than @bufsize.
1156 * Retrieve about info (using xge_hal_mgmt_pci_config()) and sprintf it
1157 * into the provided @retbuf.
1159 * Returns: XGE_HAL_OK - success.
1160 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1161 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
1163 * See also: xge_hal_mgmt_pci_config(), xge_hal_aux_device_dump().
1165 xge_hal_status_e
xge_hal_aux_pci_config_read(xge_hal_device_h devh
, int bufsize
,
1166 char *retbuf
, int *retsize
)
1169 xge_hal_status_e status
;
1170 xge_hal_mgmt_pci_config_t pci_config
;
1171 char key
[XGE_OS_SPRINTF_STRLEN
];
1173 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
1175 status
= xge_hal_mgmt_pci_config(devh
, &pci_config
,
1176 sizeof(xge_hal_mgmt_pci_config_t
));
1177 if (status
!= XGE_HAL_OK
) {
1181 __HAL_AUX_ENTRY("vendor_id", pci_config
.vendor_id
, "0x%04X");
1182 __HAL_AUX_ENTRY("device_id", pci_config
.device_id
, "0x%04X");
1183 __HAL_AUX_ENTRY("command", pci_config
.command
, "0x%04X");
1184 __HAL_AUX_ENTRY("status", pci_config
.status
, "0x%04X");
1185 __HAL_AUX_ENTRY("revision", pci_config
.revision
, "0x%02X");
1186 __HAL_AUX_ENTRY("pciClass1", pci_config
.pciClass
[0], "0x%02X");
1187 __HAL_AUX_ENTRY("pciClass2", pci_config
.pciClass
[1], "0x%02X");
1188 __HAL_AUX_ENTRY("pciClass3", pci_config
.pciClass
[2], "0x%02X");
1189 __HAL_AUX_ENTRY("cache_line_size",
1190 pci_config
.cache_line_size
, "0x%02X");
1191 __HAL_AUX_ENTRY("latency_timer", pci_config
.latency_timer
, "0x%02X");
1192 __HAL_AUX_ENTRY("header_type", pci_config
.header_type
, "0x%02X");
1193 __HAL_AUX_ENTRY("bist", pci_config
.bist
, "0x%02X");
1194 __HAL_AUX_ENTRY("base_addr0_lo", pci_config
.base_addr0_lo
, "0x%08X");
1195 __HAL_AUX_ENTRY("base_addr0_hi", pci_config
.base_addr0_hi
, "0x%08X");
1196 __HAL_AUX_ENTRY("base_addr1_lo", pci_config
.base_addr1_lo
, "0x%08X");
1197 __HAL_AUX_ENTRY("base_addr1_hi", pci_config
.base_addr1_hi
, "0x%08X");
1198 __HAL_AUX_ENTRY("not_Implemented1",
1199 pci_config
.not_Implemented1
, "0x%08X");
1200 __HAL_AUX_ENTRY("not_Implemented2", pci_config
.not_Implemented2
,
1202 __HAL_AUX_ENTRY("cardbus_cis_pointer", pci_config
.cardbus_cis_pointer
,
1204 __HAL_AUX_ENTRY("subsystem_vendor_id", pci_config
.subsystem_vendor_id
,
1206 __HAL_AUX_ENTRY("subsystem_id", pci_config
.subsystem_id
, "0x%04X");
1207 __HAL_AUX_ENTRY("rom_base", pci_config
.rom_base
, "0x%08X");
1208 __HAL_AUX_ENTRY("capabilities_pointer",
1209 pci_config
.capabilities_pointer
, "0x%02X");
1210 __HAL_AUX_ENTRY("interrupt_line", pci_config
.interrupt_line
, "0x%02X");
1211 __HAL_AUX_ENTRY("interrupt_pin", pci_config
.interrupt_pin
, "0x%02X");
1212 __HAL_AUX_ENTRY("min_grant", pci_config
.min_grant
, "0x%02X");
1213 __HAL_AUX_ENTRY("max_latency", pci_config
.max_latency
, "0x%02X");
1214 __HAL_AUX_ENTRY("msi_cap_id", pci_config
.msi_cap_id
, "0x%02X");
1215 __HAL_AUX_ENTRY("msi_next_ptr", pci_config
.msi_next_ptr
, "0x%02X");
1216 __HAL_AUX_ENTRY("msi_control", pci_config
.msi_control
, "0x%04X");
1217 __HAL_AUX_ENTRY("msi_lower_address", pci_config
.msi_lower_address
,
1219 __HAL_AUX_ENTRY("msi_higher_address", pci_config
.msi_higher_address
,
1221 __HAL_AUX_ENTRY("msi_data", pci_config
.msi_data
, "0x%04X");
1222 __HAL_AUX_ENTRY("msi_unused", pci_config
.msi_unused
, "0x%04X");
1223 __HAL_AUX_ENTRY("vpd_cap_id", pci_config
.vpd_cap_id
, "0x%02X");
1224 __HAL_AUX_ENTRY("vpd_next_cap", pci_config
.vpd_next_cap
, "0x%02X");
1225 __HAL_AUX_ENTRY("vpd_addr", pci_config
.vpd_addr
, "0x%04X");
1226 __HAL_AUX_ENTRY("vpd_data", pci_config
.vpd_data
, "0x%08X");
1227 __HAL_AUX_ENTRY("pcix_cap", pci_config
.pcix_cap
, "0x%02X");
1228 __HAL_AUX_ENTRY("pcix_next_cap", pci_config
.pcix_next_cap
, "0x%02X");
1229 __HAL_AUX_ENTRY("pcix_command", pci_config
.pcix_command
, "0x%04X");
1230 __HAL_AUX_ENTRY("pcix_status", pci_config
.pcix_status
, "0x%08X");
1232 if (xge_hal_device_check_id(devh
) == XGE_HAL_CARD_HERC
) {
1233 for (i
= 0; i
< (XGE_HAL_PCI_XFRAME_CONFIG_SPACE_SIZE
- 0x68)/4; i
++) {
1234 (void) xge_os_snprintf(key
, sizeof(key
), "%03x:", 4*i
+ 0x68);
1235 __HAL_AUX_ENTRY(key
, *((int *)pci_config
.rsvd_b1
+ i
), "0x%08X");
1239 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
1246 * xge_hal_aux_channel_read - Read channels information.
1247 * @devh: HAL device handle.
1248 * @bufsize: Buffer size.
1249 * @retbuf: Buffer pointer.
1250 * @retsize: Size of the result. Cannot be greater than @bufsize.
1252 * Read HAL statistics.
1254 * Returns: XGE_HAL_OK - success.
1255 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1256 * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
1257 * See also: xge_hal_aux_device_dump().
1259 xge_hal_status_e
xge_hal_aux_channel_read(xge_hal_device_h devh
,
1260 int bufsize
, char *retbuf
, int *retsize
)
1263 xge_hal_channel_t
*channel
;
1264 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
1265 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
1269 char key
[XGE_OS_SPRINTF_STRLEN
];
1271 if (hldev
->magic
!= XGE_HAL_MAGIC
) {
1272 return XGE_HAL_ERR_INVALID_DEVICE
;
1275 /* for each opened rx channel */
1276 xge_list_for_each(item
, &hldev
->ring_channels
) {
1277 channel
= xge_container_of(item
, xge_hal_channel_t
, item
);
1279 if (channel
->is_open
!= 1)
1282 (void) xge_os_snprintf(key
, sizeof(key
), "ring%d_", channel
->post_qid
);
1284 dest_addr
= key
+ strlen(key
);
1285 dest_size
= sizeof(key
) - strlen(key
);
1287 xge_os_strlcpy(dest_addr
, "type", dest_size
);
1288 __HAL_AUX_ENTRY(key
, channel
->type
, "%u");
1290 xge_os_strlcpy(dest_addr
, "length", dest_size
);
1291 __HAL_AUX_ENTRY(key
, channel
->length
, "%u");
1293 xge_os_strlcpy(dest_addr
, "is_open", dest_size
);
1294 __HAL_AUX_ENTRY(key
, channel
->is_open
, "%u");
1296 xge_os_strlcpy(dest_addr
, "reserve_initial", dest_size
);
1297 __HAL_AUX_ENTRY(key
, channel
->reserve_initial
, "%u");
1299 xge_os_strlcpy(dest_addr
, "reserve_max", dest_size
);
1300 __HAL_AUX_ENTRY(key
, channel
->reserve_max
, "%u");
1302 xge_os_strlcpy(dest_addr
, "reserve_length", dest_size
);
1303 __HAL_AUX_ENTRY(key
, channel
->reserve_length
, "%u");
1305 xge_os_strlcpy(dest_addr
, "reserve_top", dest_size
);
1306 __HAL_AUX_ENTRY(key
, channel
->reserve_top
, "%u");
1308 xge_os_strlcpy(dest_addr
, "reserve_threshold", dest_size
);
1309 __HAL_AUX_ENTRY(key
, channel
->reserve_threshold
, "%u");
1311 xge_os_strlcpy(dest_addr
, "free_length", dest_size
);
1312 __HAL_AUX_ENTRY(key
, channel
->free_length
, "%u");
1314 xge_os_strlcpy(dest_addr
, "post_index", dest_size
);
1315 __HAL_AUX_ENTRY(key
, channel
->post_index
, "%u");
1317 xge_os_strlcpy(dest_addr
, "compl_index", dest_size
);
1318 __HAL_AUX_ENTRY(key
, channel
->compl_index
, "%u");
1320 xge_os_strlcpy(dest_addr
, "per_dtr_space", dest_size
);
1321 __HAL_AUX_ENTRY(key
, channel
->per_dtr_space
, "%u");
1323 xge_os_strlcpy(dest_addr
, "usage_cnt", dest_size
);
1324 __HAL_AUX_ENTRY(key
, channel
->usage_cnt
, "%u");
1327 /* for each opened tx channel */
1328 xge_list_for_each(item
, &hldev
->fifo_channels
) {
1329 channel
= xge_container_of(item
, xge_hal_channel_t
, item
);
1330 if (channel
->is_open
!= 1)
1333 (void) xge_os_snprintf(key
, sizeof(key
), "fifo%d_", channel
->post_qid
);
1335 dest_addr
= key
+ strlen(key
);
1336 dest_size
= sizeof(key
) - strlen(key
);
1338 xge_os_strlcpy(dest_addr
, "type", dest_size
);
1339 __HAL_AUX_ENTRY(key
, channel
->type
, "%u");
1341 xge_os_strlcpy(dest_addr
, "length", dest_size
);
1342 __HAL_AUX_ENTRY(key
, channel
->length
, "%u");
1344 xge_os_strlcpy(dest_addr
, "is_open", dest_size
);
1345 __HAL_AUX_ENTRY(key
, channel
->is_open
, "%u");
1347 xge_os_strlcpy(dest_addr
, "reserve_initial", dest_size
);
1348 __HAL_AUX_ENTRY(key
, channel
->reserve_initial
, "%u");
1350 xge_os_strlcpy(dest_addr
, "reserve_max", dest_size
);
1351 __HAL_AUX_ENTRY(key
, channel
->reserve_max
, "%u");
1353 xge_os_strlcpy(dest_addr
, "reserve_length", dest_size
);
1354 __HAL_AUX_ENTRY(key
, channel
->reserve_length
, "%u");
1356 xge_os_strlcpy(dest_addr
, "reserve_top", dest_size
);
1357 __HAL_AUX_ENTRY(key
, channel
->reserve_top
, "%u");
1359 xge_os_strlcpy(dest_addr
, "reserve_threshold", dest_size
);
1360 __HAL_AUX_ENTRY(key
, channel
->reserve_threshold
, "%u");
1362 xge_os_strlcpy(dest_addr
, "free_length", dest_size
);
1363 __HAL_AUX_ENTRY(key
, channel
->free_length
, "%u");
1365 xge_os_strlcpy(dest_addr
, "post_index", dest_size
);
1366 __HAL_AUX_ENTRY(key
, channel
->post_index
, "%u");
1368 xge_os_strlcpy(dest_addr
, "compl_index", dest_size
);
1369 __HAL_AUX_ENTRY(key
, channel
->compl_index
, "%u");
1371 xge_os_strlcpy(dest_addr
, "per_dtr_space", dest_size
);
1372 __HAL_AUX_ENTRY(key
, channel
->per_dtr_space
, "%u");
1374 xge_os_strlcpy(dest_addr
, "usage_cnt", dest_size
);
1375 __HAL_AUX_ENTRY(key
, channel
->usage_cnt
, "%u");
1378 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
1384 * xge_hal_aux_device_dump - Dump driver "about" info and device state.
1385 * @devh: HAL device handle.
1387 * Dump driver & device "about" info and device state,
1388 * including all BAR0 registers, hardware and software statistics, PCI
1389 * configuration space.
1390 * See also: xge_hal_aux_about_read(), xge_hal_mgmt_reg_read(),
1391 * xge_hal_aux_pci_config_read(), xge_hal_aux_stats_sw_dev_read(),
1392 * xge_hal_aux_stats_tmac_read(), xge_hal_aux_stats_rmac_read(),
1393 * xge_hal_aux_channel_read(), xge_hal_aux_stats_hal_read().
1395 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1396 * XGE_HAL_ERR_OUT_OF_SPACE - Buffer size is very small.
1399 xge_hal_aux_device_dump(xge_hal_device_h devh
)
1401 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
1402 xge_hal_status_e status
;
1407 xge_assert(hldev
->dump_buf
!= NULL
);
1409 xge_os_println("********* xge DEVICE DUMP BEGIN **********");
1411 status
= xge_hal_aux_about_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1414 if (status
!= XGE_HAL_OK
) {
1417 xge_os_println(hldev
->dump_buf
);
1420 for (offset
= 0; offset
< 1574; offset
++) {
1422 status
= xge_hal_mgmt_reg_read(hldev
, 0, offset
*8, &retval
);
1423 if (status
!= XGE_HAL_OK
) {
1427 if (!retval
) continue;
1429 xge_os_printf("0x%04x 0x%08x%08x", offset
*8,
1430 (u32
)(retval
>>32), (u32
)retval
);
1432 xge_os_println("\n");
1434 status
= xge_hal_aux_pci_config_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1437 if (status
!= XGE_HAL_OK
) {
1440 xge_os_println(hldev
->dump_buf
);
1442 status
= xge_hal_aux_stats_tmac_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1445 if (status
!= XGE_HAL_OK
) {
1448 xge_os_println(hldev
->dump_buf
);
1450 status
= xge_hal_aux_stats_rmac_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1453 if (status
!= XGE_HAL_OK
) {
1456 xge_os_println(hldev
->dump_buf
);
1458 status
= xge_hal_aux_stats_pci_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1461 if (status
!= XGE_HAL_OK
) {
1464 xge_os_println(hldev
->dump_buf
);
1466 if (xge_hal_device_check_id(hldev
) == XGE_HAL_CARD_HERC
) {
1467 status
= xge_hal_aux_stats_herc_enchanced(hldev
,
1468 XGE_HAL_DUMP_BUF_SIZE
, hldev
->dump_buf
, &retsize
);
1469 if (status
!= XGE_HAL_OK
) {
1472 xge_os_println(hldev
->dump_buf
);
1475 status
= xge_hal_aux_stats_sw_dev_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1476 hldev
->dump_buf
, &retsize
);
1477 if (status
!= XGE_HAL_OK
) {
1480 xge_os_println(hldev
->dump_buf
);
1482 status
= xge_hal_aux_channel_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1485 if (status
!= XGE_HAL_OK
) {
1488 xge_os_println(hldev
->dump_buf
);
1490 status
= xge_hal_aux_stats_hal_read(hldev
, XGE_HAL_DUMP_BUF_SIZE
,
1493 if (status
!= XGE_HAL_OK
) {
1496 xge_os_println(hldev
->dump_buf
);
1498 xge_os_println("********* XFRAME DEVICE DUMP END **********");
1506 * xge_hal_aux_driver_config_read - Read Driver configuration.
1507 * @bufsize: Buffer size.
1508 * @retbuf: Buffer pointer.
1509 * @retsize: Size of the result. Cannot be greater than @bufsize.
1511 * Read driver configuration,
1513 * Returns: XGE_HAL_OK - success.
1514 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
1516 * See also: xge_hal_aux_device_config_read().
1519 xge_hal_aux_driver_config_read(int bufsize
, char *retbuf
, int *retsize
)
1521 xge_hal_status_e status
;
1522 xge_hal_driver_config_t drv_config
;
1523 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
1525 status
= xge_hal_mgmt_driver_config(&drv_config
,
1526 sizeof(xge_hal_driver_config_t
));
1527 if (status
!= XGE_HAL_OK
) {
1531 __HAL_AUX_ENTRY("queue size initial",
1532 drv_config
.queue_size_initial
, "%u");
1533 __HAL_AUX_ENTRY("queue size max", drv_config
.queue_size_max
, "%u");
1534 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
1541 * xge_hal_aux_device_config_read - Read device configuration.
1542 * @devh: HAL device handle.
1543 * @bufsize: Buffer size.
1544 * @retbuf: Buffer pointer.
1545 * @retsize: Size of the result. Cannot be greater than @bufsize.
1547 * Read device configuration,
1549 * Returns: XGE_HAL_OK - success.
1550 * XGE_HAL_ERR_INVALID_DEVICE - Device is not valid.
1551 * XGE_HAL_ERR_VERSION_CONFLICT - Version it not maching.
1553 * See also: xge_hal_aux_driver_config_read().
1555 xge_hal_status_e
xge_hal_aux_device_config_read(xge_hal_device_h devh
,
1556 int bufsize
, char *retbuf
, int *retsize
)
1559 xge_hal_status_e status
;
1560 xge_hal_device_config_t
*dev_config
;
1561 xge_hal_ring_queue_t
*ring
;
1562 xge_hal_fifo_queue_t
*fifo
;
1563 xge_hal_rti_config_t
*rti
;
1564 xge_hal_tti_config_t
*tti
;
1565 xge_hal_mac_config_t
*mac
;
1569 char key
[XGE_OS_SPRINTF_STRLEN
];
1571 xge_hal_device_t
*hldev
= (xge_hal_device_t
*)devh
;
1572 __HAL_AUX_ENTRY_DECLARE(bufsize
, retbuf
);
1574 dev_config
= (xge_hal_device_config_t
*) xge_os_malloc(hldev
->pdev
,
1575 sizeof(xge_hal_device_config_t
));
1576 if (dev_config
== NULL
) {
1577 return XGE_HAL_FAIL
;
1580 status
= xge_hal_mgmt_device_config(devh
, dev_config
,
1581 sizeof(xge_hal_device_config_t
));
1582 if (status
!= XGE_HAL_OK
) {
1583 xge_os_free(hldev
->pdev
, dev_config
,
1584 sizeof(xge_hal_device_config_t
));
1588 __HAL_AUX_ENTRY("mtu", dev_config
->mtu
, "%u");
1589 __HAL_AUX_ENTRY("isr_polling_count", dev_config
->isr_polling_cnt
, "%u");
1590 __HAL_AUX_ENTRY("latency_timer", dev_config
->latency_timer
, "%u");
1591 __HAL_AUX_ENTRY("max_splits_trans",
1592 dev_config
->max_splits_trans
, "%u");
1593 __HAL_AUX_ENTRY("mmrb_count", dev_config
->mmrb_count
, "%d");
1594 __HAL_AUX_ENTRY("shared_splits", dev_config
->shared_splits
, "%u");
1595 __HAL_AUX_ENTRY("stats_refresh_time_sec",
1596 dev_config
->stats_refresh_time_sec
, "%u");
1597 __HAL_AUX_ENTRY("pci_freq_mherz", dev_config
->pci_freq_mherz
, "%u");
1598 __HAL_AUX_ENTRY("intr_mode", dev_config
->intr_mode
, "%u");
1599 __HAL_AUX_ENTRY("ring_memblock_size",
1600 dev_config
->ring
.memblock_size
, "%u");
1602 __HAL_AUX_ENTRY("sched_timer_us", dev_config
->sched_timer_us
, "%u");
1603 __HAL_AUX_ENTRY("sched_timer_one_shot",
1604 dev_config
->sched_timer_one_shot
, "%u");
1605 __HAL_AUX_ENTRY("rxufca_intr_thres", dev_config
->rxufca_intr_thres
, "%u");
1606 __HAL_AUX_ENTRY("rxufca_lo_lim", dev_config
->rxufca_lo_lim
, "%u");
1607 __HAL_AUX_ENTRY("rxufca_hi_lim", dev_config
->rxufca_hi_lim
, "%u");
1608 __HAL_AUX_ENTRY("rxufca_lbolt_period", dev_config
->rxufca_lbolt_period
, "%u");
1610 for(i
= 0; i
< XGE_HAL_MAX_RING_NUM
; i
++)
1612 ring
= &dev_config
->ring
.queue
[i
];
1615 if (!ring
->configured
)
1618 (void) xge_os_snprintf(key
, sizeof(key
), "ring%d_", i
);
1620 dest_addr
= key
+ strlen(key
);
1621 dest_size
= sizeof(key
) - strlen(key
);
1623 xge_os_strlcpy(dest_addr
, "inital", dest_size
);
1624 __HAL_AUX_ENTRY(key
, ring
->initial
, "%u");
1626 xge_os_strlcpy(dest_addr
, "max", dest_size
);
1627 __HAL_AUX_ENTRY(key
, ring
->max
, "%u");
1629 xge_os_strlcpy(dest_addr
, "buffer_mode", dest_size
);
1630 __HAL_AUX_ENTRY(key
, ring
->buffer_mode
, "%u");
1632 xge_os_strlcpy(dest_addr
, "dram_size_mb", dest_size
);
1633 __HAL_AUX_ENTRY(key
, ring
->dram_size_mb
, "%u");
1635 xge_os_strlcpy(dest_addr
, "backoff_interval_us", dest_size
);
1636 __HAL_AUX_ENTRY(key
, ring
->backoff_interval_us
, "%u");
1638 xge_os_strlcpy(dest_addr
, "max_frame_len", dest_size
);
1639 __HAL_AUX_ENTRY(key
, ring
->max_frm_len
, "%d");
1641 xge_os_strlcpy(dest_addr
, "priority", dest_size
);
1642 __HAL_AUX_ENTRY(key
, ring
->priority
, "%u");
1644 xge_os_strlcpy(dest_addr
, "rth_en", dest_size
);
1645 __HAL_AUX_ENTRY(key
, ring
->rth_en
, "%u");
1647 xge_os_strlcpy(dest_addr
, "no_snoop_bits", dest_size
);
1648 __HAL_AUX_ENTRY(key
, ring
->no_snoop_bits
, "%u");
1650 xge_os_strlcpy(dest_addr
, "indicate_max_pkts", dest_size
);
1651 __HAL_AUX_ENTRY(key
, ring
->indicate_max_pkts
, "%u");
1653 xge_os_strlcpy(dest_addr
, "urange_a", dest_size
);
1654 __HAL_AUX_ENTRY(key
, rti
->urange_a
, "%u");
1656 xge_os_strlcpy(dest_addr
, "ufc_a", dest_size
);
1657 __HAL_AUX_ENTRY(key
, rti
->ufc_a
, "%u");
1659 xge_os_strlcpy(dest_addr
, "urange_b", dest_size
);
1660 __HAL_AUX_ENTRY(key
, rti
->urange_b
, "%u");
1662 xge_os_strlcpy(dest_addr
, "ufc_b", dest_size
);
1663 __HAL_AUX_ENTRY(key
, rti
->ufc_b
, "%u");
1665 xge_os_strlcpy(dest_addr
, "urange_c", dest_size
);
1666 __HAL_AUX_ENTRY(key
, rti
->urange_c
, "%u");
1668 xge_os_strlcpy(dest_addr
, "ufc_c", dest_size
);
1669 __HAL_AUX_ENTRY(key
, rti
->ufc_c
, "%u");
1671 xge_os_strlcpy(dest_addr
, "ufc_d", dest_size
);
1672 __HAL_AUX_ENTRY(key
, rti
->ufc_d
, "%u");
1674 xge_os_strlcpy(dest_addr
, "timer_val_us", dest_size
);
1675 __HAL_AUX_ENTRY(key
, rti
->timer_val_us
, "%u");
1680 mac
= &dev_config
->mac
;
1682 __HAL_AUX_ENTRY("tmac_util_period",
1683 mac
->tmac_util_period
, "%u");
1684 __HAL_AUX_ENTRY("rmac_util_period",
1685 mac
->rmac_util_period
, "%u");
1686 __HAL_AUX_ENTRY("rmac_bcast_en",
1687 mac
->rmac_bcast_en
, "%u");
1688 __HAL_AUX_ENTRY("rmac_pause_gen_en",
1689 mac
->rmac_pause_gen_en
, "%d");
1690 __HAL_AUX_ENTRY("rmac_pause_rcv_en",
1691 mac
->rmac_pause_rcv_en
, "%d");
1692 __HAL_AUX_ENTRY("rmac_pause_time",
1693 mac
->rmac_pause_time
, "%u");
1694 __HAL_AUX_ENTRY("mc_pause_threshold_q0q3",
1695 mac
->mc_pause_threshold_q0q3
, "%u");
1696 __HAL_AUX_ENTRY("mc_pause_threshold_q4q7",
1697 mac
->mc_pause_threshold_q4q7
, "%u");
1701 __HAL_AUX_ENTRY("fifo_max_frags",
1702 dev_config
->fifo
.max_frags
, "%u");
1703 __HAL_AUX_ENTRY("fifo_reserve_threshold",
1704 dev_config
->fifo
.reserve_threshold
, "%u");
1705 __HAL_AUX_ENTRY("fifo_memblock_size",
1706 dev_config
->fifo
.memblock_size
, "%u");
1707 #ifdef XGE_HAL_ALIGN_XMIT
1708 __HAL_AUX_ENTRY("fifo_alignment_size",
1709 dev_config
->fifo
.alignment_size
, "%u");
1712 for (i
= 0; i
< XGE_HAL_MAX_FIFO_NUM
; i
++) {
1713 fifo
= &dev_config
->fifo
.queue
[i
];
1715 if (!fifo
->configured
)
1718 (void) xge_os_snprintf(key
, sizeof(key
), "fifo%d_", i
);
1720 dest_addr
= key
+ strlen(key
);
1721 dest_size
= sizeof(key
) - strlen(key
);
1723 xge_os_strlcpy(dest_addr
, "initial", dest_size
);
1724 __HAL_AUX_ENTRY(key
, fifo
->initial
, "%u");
1726 xge_os_strlcpy(dest_addr
, "max", dest_size
);
1727 __HAL_AUX_ENTRY(key
, fifo
->max
, "%u");
1729 xge_os_strlcpy(dest_addr
, "intr", dest_size
);
1730 __HAL_AUX_ENTRY(key
, fifo
->intr
, "%u");
1732 xge_os_strlcpy(dest_addr
, "no_snoop_bits", dest_size
);
1733 __HAL_AUX_ENTRY(key
, fifo
->no_snoop_bits
, "%u");
1735 for (j
= 0; j
< XGE_HAL_MAX_FIFO_TTI_NUM
; j
++) {
1736 tti
= &dev_config
->fifo
.queue
[i
].tti
[j
];
1740 (void) xge_os_snprintf(key
, sizeof(key
), "fifo%d_tti%02d_", i
,
1741 i
* XGE_HAL_MAX_FIFO_TTI_NUM
+ j
);
1743 dest_addr
= key
+ strlen(key
);
1744 dest_size
= sizeof(key
) - strlen(key
);
1746 xge_os_strlcpy(dest_addr
, "urange_a", dest_size
);
1747 __HAL_AUX_ENTRY(key
, tti
->urange_a
, "%u");
1749 xge_os_strlcpy(dest_addr
, "ufc_a", dest_size
);
1750 __HAL_AUX_ENTRY(key
, tti
->ufc_a
, "%u");
1752 xge_os_strlcpy(dest_addr
, "urange_b", dest_size
);
1753 __HAL_AUX_ENTRY(key
, tti
->urange_b
, "%u");
1755 xge_os_strlcpy(dest_addr
, "ufc_b", dest_size
);
1756 __HAL_AUX_ENTRY(key
, tti
->ufc_b
, "%u");
1758 xge_os_strlcpy(dest_addr
, "urange_c", dest_size
);
1759 __HAL_AUX_ENTRY(key
, tti
->urange_c
, "%u");
1761 xge_os_strlcpy(dest_addr
, "ufc_c", dest_size
);
1762 __HAL_AUX_ENTRY(key
, tti
->ufc_c
, "%u");
1764 xge_os_strlcpy(dest_addr
, "ufc_d", dest_size
);
1765 __HAL_AUX_ENTRY(key
, tti
->ufc_d
, "%u");
1767 xge_os_strlcpy(dest_addr
, "timer_val_us", dest_size
);
1768 __HAL_AUX_ENTRY(key
, tti
->timer_val_us
, "%u");
1770 xge_os_strlcpy(dest_addr
, "timer_ci_en", dest_size
);
1771 __HAL_AUX_ENTRY(key
, tti
->timer_ci_en
, "%u");
1775 /* and bimodal TTIs */
1776 for (i
=0; i
<XGE_HAL_MAX_RING_NUM
; i
++) {
1777 tti
= &hldev
->bimodal_tti
[i
];
1781 (void) xge_os_snprintf(key
, sizeof(key
), "tti%02d_",
1782 XGE_HAL_MAX_FIFO_TTI_RING_0
+ i
);
1784 dest_addr
= key
+ strlen(key
);
1785 dest_size
= sizeof(key
) - strlen(key
);
1787 xge_os_strlcpy(dest_addr
, "urange_a", dest_size
);
1788 __HAL_AUX_ENTRY(key
, tti
->urange_a
, "%u");
1790 xge_os_strlcpy(dest_addr
, "ufc_a", dest_size
);
1791 __HAL_AUX_ENTRY(key
, tti
->ufc_a
, "%u");
1793 xge_os_strlcpy(dest_addr
, "urange_b", dest_size
);
1794 __HAL_AUX_ENTRY(key
, tti
->urange_b
, "%u");
1796 xge_os_strlcpy(dest_addr
, "ufc_b", dest_size
);
1797 __HAL_AUX_ENTRY(key
, tti
->ufc_b
, "%u");
1799 xge_os_strlcpy(dest_addr
, "urange_c", dest_size
);
1800 __HAL_AUX_ENTRY(key
, tti
->urange_c
, "%u");
1802 xge_os_strlcpy(dest_addr
, "ufc_c", dest_size
);
1803 __HAL_AUX_ENTRY(key
, tti
->ufc_c
, "%u");
1805 xge_os_strlcpy(dest_addr
, "ufc_d", dest_size
);
1806 __HAL_AUX_ENTRY(key
, tti
->ufc_d
, "%u");
1808 xge_os_strlcpy(dest_addr
, "timer_val_us", dest_size
);
1809 __HAL_AUX_ENTRY(key
, tti
->timer_val_us
, "%u");
1811 xge_os_strlcpy(dest_addr
, "timer_ac_en", dest_size
);
1812 __HAL_AUX_ENTRY(key
, tti
->timer_ac_en
, "%u");
1814 xge_os_strlcpy(dest_addr
, "timer_ci_en", dest_size
);
1815 __HAL_AUX_ENTRY(key
, tti
->timer_ci_en
, "%u");
1817 __HAL_AUX_ENTRY("dump_on_serr", dev_config
->dump_on_serr
, "%u");
1818 __HAL_AUX_ENTRY("dump_on_eccerr",
1819 dev_config
->dump_on_eccerr
, "%u");
1820 __HAL_AUX_ENTRY("dump_on_parityerr",
1821 dev_config
->dump_on_parityerr
, "%u");
1822 __HAL_AUX_ENTRY("rth_en", dev_config
->rth_en
, "%u");
1823 __HAL_AUX_ENTRY("rth_bucket_size", dev_config
->rth_bucket_size
, "%u");
1825 __HAL_AUX_ENTRY_END(bufsize
, retsize
);
1827 xge_os_free(hldev
->pdev
, dev_config
,
1828 sizeof(xge_hal_device_config_t
));