2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright(c) 2002-2011 Exar Corp.
7 * Redistribution and use in source and binary forms, with or without
8 * modification are permitted provided the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Exar Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
40 * vxge_print_registers
41 * Prints/logs Register values
42 * @registers Register values
45 vxge_print_registers(void *registers)
48 u64 noffset, nRegValue = 0;
51 fdAll = fopen("vxge_regs.log", "w+");
55 VXGE_PRINT_REG_NAME(fdAll, "Registers : COMMON");
56 VXGE_PRINT_HEADER_REGS(fdAll);
58 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_COMMON; i++) {
59 if (reginfo_registers[i].size == 1)
60 strlcpy(szName, reginfo_registers[i].name,
63 for (j = 0; j < reginfo_registers[i].size; j++) {
64 noffset = reginfo_registers[i].offset + (0x8 * j);
66 if (reginfo_registers[i].size > 1)
67 snprintf(szName, sizeof(szName),
68 reginfo_registers[i].name, j);
70 nRegValue = *((u64 *) ((unsigned char *) registers +
73 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
78 VXGE_PRINT_LINE(fdAll);
83 * vxge_print_registers_legacy
84 * Prints/logs legacy Register values
85 * @registers Register values
88 vxge_print_registers_legacy(void *registers)
91 u64 noffset, nRegValue = 0;
94 fdAll = fopen("vxge_regs.log", "a+");
98 VXGE_PRINT_REG_NAME(fdAll, "Registers : LEGACY");
99 VXGE_PRINT_HEADER_REGS(fdAll);
101 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_LEGACY; i++) {
102 if (reginfo_legacy[i].size == 1)
103 strlcpy(szName, reginfo_legacy[i].name, sizeof(szName));
105 for (j = 0; j < reginfo_legacy[i].size; j++) {
106 noffset = reginfo_legacy[i].offset + (0x8 * j);
108 if (reginfo_legacy[i].size > 1)
109 snprintf(szName, sizeof(szName),
110 reginfo_legacy[i].name, j);
112 nRegValue = *((u64 *) ((unsigned char *) registers +
115 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
120 VXGE_PRINT_LINE(fdAll);
125 * vxge_print_registers_toc
126 * Prints/logs toc Register values
127 * @registers Register values
130 vxge_print_registers_toc(void *registers)
133 u64 noffset, nRegValue = 0;
136 fdAll = fopen("vxge_regs.log", "a+");
140 VXGE_PRINT_REG_NAME(fdAll, "Registers : TOC");
141 VXGE_PRINT_HEADER_REGS(fdAll);
143 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_TOC; i++) {
144 if (reginfo_toc[i].size == 1)
145 strlcpy(szName, reginfo_toc[i].name, sizeof(szName));
147 for (j = 0; j < reginfo_toc[i].size; j++) {
148 noffset = reginfo_toc[i].offset + (0x8 * j);
150 if (reginfo_toc[i].size > 1)
151 snprintf(szName, sizeof(szName),
152 reginfo_toc[i].name, j);
154 nRegValue = *((u64 *) ((unsigned char *) registers +
157 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
162 VXGE_PRINT_LINE(fdAll);
167 * vxge_print_registers_pcicfgmgmt
168 * Prints/logs pcicfgmgmt Register values
169 * @registers Register values
172 vxge_print_registers_pcicfgmgmt(void *registers)
175 u64 noffset, nRegValue;
178 fdAll = fopen("vxge_regs.log", "a+");
182 VXGE_PRINT_REG_NAME(fdAll, "Registers : PCICFGMGMT");
183 VXGE_PRINT_HEADER_REGS(fdAll);
185 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_PCICFGMGMT; i++) {
186 if (reginfo_pcicfgmgmt[i].size == 1)
187 strlcpy(szName, reginfo_pcicfgmgmt[i].name,
190 for (j = 0; j < reginfo_pcicfgmgmt[i].size; j++) {
192 noffset = reginfo_pcicfgmgmt[i].offset + (0x8 * j);
194 if (reginfo_pcicfgmgmt[i].size > 1)
195 snprintf(szName, sizeof(szName),
196 reginfo_pcicfgmgmt[i].name, j);
198 nRegValue = *((u64 *) ((unsigned char *) registers +
201 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
206 VXGE_PRINT_LINE(fdAll);
211 * vxge_print_registers_vpath
212 * Prints/logs vpath Register values
213 * @registers Register values
216 vxge_print_registers_vpath(void *registers, int vpath_num)
219 u64 noffset, nRegValue = 0;
222 fdAll = fopen("vxge_regs.log", "a+");
226 VXGE_PRINT_REG_NAME(fdAll, "Registers : VPATH");
227 VXGE_PRINT_HEADER_REGS(fdAll);
229 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_VPATH; i++) {
230 if (reginfo_vpath[i].size == 1)
231 snprintf(szName, sizeof(szName),
232 reginfo_vpath[i].name, vpath_num);
234 for (j = 0; j < reginfo_vpath[i].size; j++) {
235 noffset = reginfo_vpath[i].offset + (0x8 * j);
237 if (reginfo_vpath[i].size > 1)
238 snprintf(szName, sizeof(szName), reginfo_vpath[i].name, j, vpath_num);
240 nRegValue = *((u64 *) ((unsigned char *) registers +
243 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
248 VXGE_PRINT_LINE(fdAll);
253 * vxge_print_registers_vpmgmt
254 * Prints/logs vpmgmt Register values
255 * @registers Register values
258 vxge_print_registers_vpmgmt(void *registers)
261 u64 noffset, nRegValue = 0;
264 fdAll = fopen("vxge_regs.log", "a+");
268 VXGE_PRINT_REG_NAME(fdAll, "Registers : VPMGMT");
269 VXGE_PRINT_HEADER_REGS(fdAll);
271 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_VPMGMT; i++) {
273 if (reginfo_vpmgmt[i].size == 1)
274 strlcpy(szName, reginfo_vpmgmt[i].name, sizeof(szName));
276 for (j = 0; j < reginfo_vpmgmt[i].size; j++) {
278 noffset = reginfo_vpmgmt[i].offset + (0x8 * j);
280 if (reginfo_vpmgmt[i].size > 1)
281 snprintf(szName, sizeof(szName),
282 reginfo_vpmgmt[i].name, j);
284 nRegValue = *((u64 *) ((unsigned char *) registers +
287 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
292 VXGE_PRINT_LINE(fdAll);
297 * vxge_print_registers_mrpcim
298 * Prints/logs mrpcim Register values
299 * @registers Register values
302 vxge_print_registers_mrpcim(void *registers)
305 u64 noffset, nRegValue = 0;
308 fdAll = fopen("vxge_regs.log", "a+");
312 VXGE_PRINT_REG_NAME(fdAll, "Registers : MRPCIM");
313 VXGE_PRINT_HEADER_REGS(fdAll);
315 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_MRPCIM; i++) {
317 if (reginfo_mrpcim[i].size == 1)
318 strlcpy(szName, reginfo_mrpcim[i].name, sizeof(szName));
320 for (j = 0; j < reginfo_mrpcim[i].size; j++) {
322 noffset = reginfo_mrpcim[i].offset + (0x8 * j);
324 if (reginfo_mrpcim[i].size > 1)
325 snprintf(szName, sizeof(szName),
326 reginfo_mrpcim[i].name, j);
328 nRegValue = *((u64 *) ((unsigned char *) registers +
331 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
336 VXGE_PRINT_LINE(fdAll);
341 * vxge_print_registers_srpcim
342 * Prints/logs srpcim Register values
343 * @registers Register values
346 vxge_print_registers_srpcim(void *registers)
349 u64 noffset, nRegValue = 0;
352 fdAll = fopen("vxge_regs.log", "a+");
356 VXGE_PRINT_REG_NAME(fdAll, "Registers : SRPCIM");
357 VXGE_PRINT_HEADER_REGS(fdAll);
359 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_SRPCIM; i++) {
361 if (reginfo_srpcim[i].size == 1)
362 strlcpy(szName, reginfo_srpcim[i].name, sizeof(szName));
364 for (j = 0; j < reginfo_srpcim[i].size; j++) {
366 noffset = reginfo_srpcim[i].offset + (0x8 * j);
368 if (reginfo_srpcim[i].size > 1)
369 snprintf(szName, sizeof(szName),
370 reginfo_srpcim[i].name, j);
372 nRegValue = *((u64 *) ((unsigned char *) registers +
375 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
380 VXGE_PRINT_LINE(fdAll);
385 * vxge_print_stats_drv
386 * Prints/logs Driver Statistics
387 * @driver_stats Driver Statistics
390 vxge_print_stats_drv(void *driver_stats, int vpath_num)
395 no_of_vpath = vxge_get_num_vpath();
396 fdAll = fopen("vxge_drv_stats.log", "w+");
400 for (i = 0; i < no_of_vpath; i++) {
402 if (vpath_num != -1) {
403 if (vpath_num != i) {
404 driver_stats = driver_stats +
405 (VXGE_HAL_MGMT_STATS_COUNT_DRIVER * sizeof(u64));
410 VXGE_PRINT_LINE(fdAll);
411 VXGE_PRINT(fdAll, " VPath # %d ", i);
412 VXGE_PRINT_LINE(fdAll);
414 for (j = 0; j < VXGE_HAL_MGMT_STATS_COUNT_DRIVER; j++) {
416 driverInfo[j].value =
417 *((u64 *) ((unsigned char *) driver_stats +
418 (j * (sizeof(u64)))));
420 VXGE_PRINT_STATS(fdAll, (const char *)
421 driverInfo[j].name, driverInfo[j].value);
423 driver_stats = driver_stats + (j * sizeof(u64));
426 VXGE_PRINT_LINE(fdAll);
432 * Prints/logs Statistics
433 * @driver_stats Driver Statistics
436 vxge_print_stats(void *stats, vxge_query_device_info_e stat_type)
438 fdAll = fopen("vxge_stats.log", "a+");
443 case VXGE_GET_MRPCIM_STATS:
444 VXGE_PRINT_LINE(fdAll);
445 VXGE_PRINT_REG_NAME(fdAll, "Statistics : MRPCIM");
446 VXGE_PRINT_LINE(fdAll);
449 case VXGE_GET_DEVICE_STATS:
450 VXGE_PRINT_LINE(fdAll);
451 VXGE_PRINT_REG_NAME(fdAll, "Statistics: COMMON");
452 VXGE_PRINT_LINE(fdAll);
456 VXGE_PRINT(fdAll, "%s", stats);
461 vxge_print_pci_config(void *info)
463 fdAll = fopen("vxge_regs.log", "a+");
467 VXGE_PRINT_LINE(fdAll);
468 VXGE_PRINT_REG_NAME(fdAll, "PCI CONFIG SPACE");
469 VXGE_PRINT_LINE(fdAll);
470 VXGE_PRINT(fdAll, "%s", info);
475 vxge_print_hw_info(void *info)
478 vxge_device_hw_info_t *dev_hw_info;
479 vxge_hal_device_hw_info_t *hw_info;
480 vxge_hal_device_pmd_info_t *pmd_port;
482 fdAll = fopen("vxge_regs.log", "w+");
486 dev_hw_info = (vxge_device_hw_info_t *) info;
487 hw_info = &(dev_hw_info->hw_info);
488 pmd_port = &(hw_info->pmd_port0);
490 VXGE_PRINT_LINE(fdAll);
491 VXGE_PRINT_REG_NAME(fdAll, "HARDWARE INFO");
492 VXGE_PRINT_LINE(fdAll);
494 VXGE_PRINT(fdAll, "Description \t\t: %s",
495 hw_info->product_description);
497 VXGE_PRINT(fdAll, "Serial Number \t\t: %s", hw_info->serial_number);
498 VXGE_PRINT(fdAll, "Part Number \t\t: %s", hw_info->part_number);
500 VXGE_PRINT(fdAll, "Firmware Version \t: %s",
501 hw_info->fw_version.version);
503 VXGE_PRINT(fdAll, "Firmware Date \t\t: %s", hw_info->fw_date.date);
505 VXGE_PRINT(fdAll, "Function Mode \t\t: %s",
506 vxge_func_mode[hw_info->function_mode]);
508 for (i = 0; i < hw_info->ports; i++) {
510 vxge_null_terminate(pmd_port->vendor,
511 sizeof(pmd_port->vendor));
513 if (strlen(pmd_port->vendor) == 0) {
515 "PMD Port %d \t\t: vendor=??, sn=??, pn=??", i);
517 pmd_port = &(hw_info->pmd_port1);
521 vxge_null_terminate(pmd_port->ser_num,
522 sizeof(pmd_port->ser_num));
524 vxge_null_terminate(pmd_port->part_num,
525 sizeof(pmd_port->part_num));
528 "PMD Port %d \t\t: vendor=%s, sn=%s, pn=%s", i,
529 pmd_port->vendor, pmd_port->ser_num,
532 pmd_port = &(hw_info->pmd_port1);
535 if (hw_info->ports > 1) {
537 VXGE_PRINT(fdAll, "Port mode \t\t: %s",
538 vxge_port_mode[dev_hw_info->port_mode]);
540 if (dev_hw_info->port_mode != VXGE_HAL_DP_NP_MODE_SINGLE_PORT) {
541 VXGE_PRINT(fdAll, "Port failure \t\t: %s",
542 vxge_port_failure[dev_hw_info->port_failure]);
546 VXGE_PRINT_LINE(fdAll);
551 vxge_print_bw_priority(void *info)
555 vxge_bw_info_t *buffer;
557 fdAll = fopen("vxge_stats.log", "a+");
561 buffer = (vxge_bw_info_t *) info;
562 func_id = buffer->func_id;
564 VXGE_PRINT_LINE(fdAll);
567 "Function : %02lld Bandwidth : %05d\tPriority : %d",
568 func_id, (buffer->bandwidth ?
569 buffer->bandwidth : VXGE_MAX_BANDWIDTH),
572 VXGE_PRINT_LINE(fdAll);
577 vxge_print_port_mode(void *info)
579 vxge_port_info_t *buffer;
581 fdAll = fopen("vxge_stats.log", "a+");
585 buffer = (vxge_port_info_t *) info;
587 VXGE_PRINT_LINE(fdAll);
590 "Port Mode: %s\tPort Failure: %s",
591 vxge_port_mode[buffer->port_mode],
592 vxge_port_failure[buffer->port_failure]);
594 VXGE_PRINT_LINE(fdAll);