2 * Copyright(c) 2002-2011 Exar Corp.
5 * Redistribution and use in source and binary forms, with or without
6 * modification are permitted provided the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Exar Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
38 * vxge_print_registers
39 * Prints/logs Register values
40 * @registers Register values
43 vxge_print_registers(void *registers)
46 u64 noffset, nRegValue = 0;
49 fdAll = fopen("vxge_regs.log", "w+");
53 VXGE_PRINT_REG_NAME(fdAll, "Registers : COMMON");
54 VXGE_PRINT_HEADER_REGS(fdAll);
56 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_COMMON; i++) {
57 if (reginfo_registers[i].size == 1)
58 strlcpy(szName, reginfo_registers[i].name,
61 for (j = 0; j < reginfo_registers[i].size; j++) {
62 noffset = reginfo_registers[i].offset + (0x8 * j);
64 if (reginfo_registers[i].size > 1)
65 snprintf(szName, sizeof(szName),
66 reginfo_registers[i].name, j);
68 nRegValue = *((u64 *) ((unsigned char *) registers +
71 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
76 VXGE_PRINT_LINE(fdAll);
81 * vxge_print_registers_legacy
82 * Prints/logs legacy Register values
83 * @registers Register values
86 vxge_print_registers_legacy(void *registers)
89 u64 noffset, nRegValue = 0;
92 fdAll = fopen("vxge_regs.log", "a+");
96 VXGE_PRINT_REG_NAME(fdAll, "Registers : LEGACY");
97 VXGE_PRINT_HEADER_REGS(fdAll);
99 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_LEGACY; i++) {
100 if (reginfo_legacy[i].size == 1)
101 strlcpy(szName, reginfo_legacy[i].name, sizeof(szName));
103 for (j = 0; j < reginfo_legacy[i].size; j++) {
104 noffset = reginfo_legacy[i].offset + (0x8 * j);
106 if (reginfo_legacy[i].size > 1)
107 snprintf(szName, sizeof(szName),
108 reginfo_legacy[i].name, j);
110 nRegValue = *((u64 *) ((unsigned char *) registers +
113 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
118 VXGE_PRINT_LINE(fdAll);
123 * vxge_print_registers_toc
124 * Prints/logs toc Register values
125 * @registers Register values
128 vxge_print_registers_toc(void *registers)
131 u64 noffset, nRegValue = 0;
134 fdAll = fopen("vxge_regs.log", "a+");
138 VXGE_PRINT_REG_NAME(fdAll, "Registers : TOC");
139 VXGE_PRINT_HEADER_REGS(fdAll);
141 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_TOC; i++) {
142 if (reginfo_toc[i].size == 1)
143 strlcpy(szName, reginfo_toc[i].name, sizeof(szName));
145 for (j = 0; j < reginfo_toc[i].size; j++) {
146 noffset = reginfo_toc[i].offset + (0x8 * j);
148 if (reginfo_toc[i].size > 1)
149 snprintf(szName, sizeof(szName),
150 reginfo_toc[i].name, j);
152 nRegValue = *((u64 *) ((unsigned char *) registers +
155 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
160 VXGE_PRINT_LINE(fdAll);
165 * vxge_print_registers_pcicfgmgmt
166 * Prints/logs pcicfgmgmt Register values
167 * @registers Register values
170 vxge_print_registers_pcicfgmgmt(void *registers)
173 u64 noffset, nRegValue;
176 fdAll = fopen("vxge_regs.log", "a+");
180 VXGE_PRINT_REG_NAME(fdAll, "Registers : PCICFGMGMT");
181 VXGE_PRINT_HEADER_REGS(fdAll);
183 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_PCICFGMGMT; i++) {
184 if (reginfo_pcicfgmgmt[i].size == 1)
185 strlcpy(szName, reginfo_pcicfgmgmt[i].name,
188 for (j = 0; j < reginfo_pcicfgmgmt[i].size; j++) {
190 noffset = reginfo_pcicfgmgmt[i].offset + (0x8 * j);
192 if (reginfo_pcicfgmgmt[i].size > 1)
193 snprintf(szName, sizeof(szName),
194 reginfo_pcicfgmgmt[i].name, j);
196 nRegValue = *((u64 *) ((unsigned char *) registers +
199 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
204 VXGE_PRINT_LINE(fdAll);
209 * vxge_print_registers_vpath
210 * Prints/logs vpath Register values
211 * @registers Register values
214 vxge_print_registers_vpath(void *registers, int vpath_num)
217 u64 noffset, nRegValue = 0;
220 fdAll = fopen("vxge_regs.log", "a+");
224 VXGE_PRINT_REG_NAME(fdAll, "Registers : VPATH");
225 VXGE_PRINT_HEADER_REGS(fdAll);
227 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_VPATH; i++) {
228 if (reginfo_vpath[i].size == 1)
229 snprintf(szName, sizeof(szName),
230 reginfo_vpath[i].name, vpath_num);
232 for (j = 0; j < reginfo_vpath[i].size; j++) {
233 noffset = reginfo_vpath[i].offset + (0x8 * j);
235 if (reginfo_vpath[i].size > 1)
236 snprintf(szName, sizeof(szName), reginfo_vpath[i].name, j, vpath_num);
238 nRegValue = *((u64 *) ((unsigned char *) registers +
241 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
246 VXGE_PRINT_LINE(fdAll);
251 * vxge_print_registers_vpmgmt
252 * Prints/logs vpmgmt Register values
253 * @registers Register values
256 vxge_print_registers_vpmgmt(void *registers)
259 u64 noffset, nRegValue = 0;
262 fdAll = fopen("vxge_regs.log", "a+");
266 VXGE_PRINT_REG_NAME(fdAll, "Registers : VPMGMT");
267 VXGE_PRINT_HEADER_REGS(fdAll);
269 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_VPMGMT; i++) {
271 if (reginfo_vpmgmt[i].size == 1)
272 strlcpy(szName, reginfo_vpmgmt[i].name, sizeof(szName));
274 for (j = 0; j < reginfo_vpmgmt[i].size; j++) {
276 noffset = reginfo_vpmgmt[i].offset + (0x8 * j);
278 if (reginfo_vpmgmt[i].size > 1)
279 snprintf(szName, sizeof(szName),
280 reginfo_vpmgmt[i].name, j);
282 nRegValue = *((u64 *) ((unsigned char *) registers +
285 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
290 VXGE_PRINT_LINE(fdAll);
295 * vxge_print_registers_mrpcim
296 * Prints/logs mrpcim Register values
297 * @registers Register values
300 vxge_print_registers_mrpcim(void *registers)
303 u64 noffset, nRegValue = 0;
306 fdAll = fopen("vxge_regs.log", "a+");
310 VXGE_PRINT_REG_NAME(fdAll, "Registers : MRPCIM");
311 VXGE_PRINT_HEADER_REGS(fdAll);
313 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_MRPCIM; i++) {
315 if (reginfo_mrpcim[i].size == 1)
316 strlcpy(szName, reginfo_mrpcim[i].name, sizeof(szName));
318 for (j = 0; j < reginfo_mrpcim[i].size; j++) {
320 noffset = reginfo_mrpcim[i].offset + (0x8 * j);
322 if (reginfo_mrpcim[i].size > 1)
323 snprintf(szName, sizeof(szName),
324 reginfo_mrpcim[i].name, j);
326 nRegValue = *((u64 *) ((unsigned char *) registers +
329 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
334 VXGE_PRINT_LINE(fdAll);
339 * vxge_print_registers_srpcim
340 * Prints/logs srpcim Register values
341 * @registers Register values
344 vxge_print_registers_srpcim(void *registers)
347 u64 noffset, nRegValue = 0;
350 fdAll = fopen("vxge_regs.log", "a+");
354 VXGE_PRINT_REG_NAME(fdAll, "Registers : SRPCIM");
355 VXGE_PRINT_HEADER_REGS(fdAll);
357 for (i = 0; i < VXGE_HAL_MGMT_REG_COUNT_SRPCIM; i++) {
359 if (reginfo_srpcim[i].size == 1)
360 strlcpy(szName, reginfo_srpcim[i].name, sizeof(szName));
362 for (j = 0; j < reginfo_srpcim[i].size; j++) {
364 noffset = reginfo_srpcim[i].offset + (0x8 * j);
366 if (reginfo_srpcim[i].size > 1)
367 snprintf(szName, sizeof(szName),
368 reginfo_srpcim[i].name, j);
370 nRegValue = *((u64 *) ((unsigned char *) registers +
373 VXGE_PRINT_REGS(fdAll, (const char *) szName, noffset,
378 VXGE_PRINT_LINE(fdAll);
383 * vxge_print_stats_drv
384 * Prints/logs Driver Statistics
385 * @driver_stats Driver Statistics
388 vxge_print_stats_drv(void *driver_stats, int vpath_num)
393 no_of_vpath = vxge_get_num_vpath();
394 fdAll = fopen("vxge_drv_stats.log", "w+");
398 for (i = 0; i < no_of_vpath; i++) {
400 if (vpath_num != -1) {
401 if (vpath_num != i) {
402 driver_stats = driver_stats +
403 (VXGE_HAL_MGMT_STATS_COUNT_DRIVER * sizeof(u64));
408 VXGE_PRINT_LINE(fdAll);
409 VXGE_PRINT(fdAll, " VPath # %d ", i);
410 VXGE_PRINT_LINE(fdAll);
412 for (j = 0; j < VXGE_HAL_MGMT_STATS_COUNT_DRIVER; j++) {
414 driverInfo[j].value =
415 *((u64 *) ((unsigned char *) driver_stats +
416 (j * (sizeof(u64)))));
418 VXGE_PRINT_STATS(fdAll, (const char *)
419 driverInfo[j].name, driverInfo[j].value);
421 driver_stats = driver_stats + (j * sizeof(u64));
424 VXGE_PRINT_LINE(fdAll);
430 * Prints/logs Statistics
431 * @driver_stats Driver Statistics
434 vxge_print_stats(void *stats, vxge_query_device_info_e stat_type)
436 fdAll = fopen("vxge_stats.log", "a+");
441 case VXGE_GET_MRPCIM_STATS:
442 VXGE_PRINT_LINE(fdAll);
443 VXGE_PRINT_REG_NAME(fdAll, "Statistics : MRPCIM");
444 VXGE_PRINT_LINE(fdAll);
447 case VXGE_GET_DEVICE_STATS:
448 VXGE_PRINT_LINE(fdAll);
449 VXGE_PRINT_REG_NAME(fdAll, "Statistics: COMMON");
450 VXGE_PRINT_LINE(fdAll);
454 VXGE_PRINT(fdAll, "%s", stats);
459 vxge_print_pci_config(void *info)
461 fdAll = fopen("vxge_regs.log", "a+");
465 VXGE_PRINT_LINE(fdAll);
466 VXGE_PRINT_REG_NAME(fdAll, "PCI CONFIG SPACE");
467 VXGE_PRINT_LINE(fdAll);
468 VXGE_PRINT(fdAll, "%s", info);
473 vxge_print_hw_info(void *info)
476 vxge_device_hw_info_t *dev_hw_info;
477 vxge_hal_device_hw_info_t *hw_info;
478 vxge_hal_device_pmd_info_t *pmd_port;
480 fdAll = fopen("vxge_regs.log", "w+");
484 dev_hw_info = (vxge_device_hw_info_t *) info;
485 hw_info = &(dev_hw_info->hw_info);
486 pmd_port = &(hw_info->pmd_port0);
488 VXGE_PRINT_LINE(fdAll);
489 VXGE_PRINT_REG_NAME(fdAll, "HARDWARE INFO");
490 VXGE_PRINT_LINE(fdAll);
492 VXGE_PRINT(fdAll, "Description \t\t: %s",
493 hw_info->product_description);
495 VXGE_PRINT(fdAll, "Serial Number \t\t: %s", hw_info->serial_number);
496 VXGE_PRINT(fdAll, "Part Number \t\t: %s", hw_info->part_number);
498 VXGE_PRINT(fdAll, "Firmware Version \t: %s",
499 hw_info->fw_version.version);
501 VXGE_PRINT(fdAll, "Firmware Date \t\t: %s", hw_info->fw_date.date);
503 VXGE_PRINT(fdAll, "Function Mode \t\t: %s",
504 vxge_func_mode[hw_info->function_mode]);
506 for (i = 0; i < hw_info->ports; i++) {
508 vxge_null_terminate(pmd_port->vendor,
509 sizeof(pmd_port->vendor));
511 if (strlen(pmd_port->vendor) == 0) {
513 "PMD Port %d \t\t: vendor=??, sn=??, pn=??", i);
515 pmd_port = &(hw_info->pmd_port1);
519 vxge_null_terminate(pmd_port->ser_num,
520 sizeof(pmd_port->ser_num));
522 vxge_null_terminate(pmd_port->part_num,
523 sizeof(pmd_port->part_num));
526 "PMD Port %d \t\t: vendor=%s, sn=%s, pn=%s", i,
527 pmd_port->vendor, pmd_port->ser_num,
530 pmd_port = &(hw_info->pmd_port1);
533 if (hw_info->ports > 1) {
535 VXGE_PRINT(fdAll, "Port mode \t\t: %s",
536 vxge_port_mode[dev_hw_info->port_mode]);
538 if (dev_hw_info->port_mode != VXGE_HAL_DP_NP_MODE_SINGLE_PORT) {
539 VXGE_PRINT(fdAll, "Port failure \t\t: %s",
540 vxge_port_failure[dev_hw_info->port_failure]);
544 VXGE_PRINT_LINE(fdAll);
549 vxge_print_bw_priority(void *info)
553 vxge_bw_info_t *buffer;
555 fdAll = fopen("vxge_stats.log", "a+");
559 buffer = (vxge_bw_info_t *) info;
560 func_id = buffer->func_id;
562 VXGE_PRINT_LINE(fdAll);
565 "Function : %02lld Bandwidth : %05d\tPriority : %d",
566 func_id, (buffer->bandwidth ?
567 buffer->bandwidth : VXGE_MAX_BANDWIDTH),
570 VXGE_PRINT_LINE(fdAll);
575 vxge_print_port_mode(void *info)
577 vxge_port_info_t *buffer;
579 fdAll = fopen("vxge_stats.log", "a+");
583 buffer = (vxge_port_info_t *) info;
585 VXGE_PRINT_LINE(fdAll);
588 "Port Mode: %s\tPort Failure: %s",
589 vxge_port_mode[buffer->port_mode],
590 vxge_port_failure[buffer->port_failure]);
592 VXGE_PRINT_LINE(fdAll);