Author: gnn
Date: Thu Apr 28 16:29:19 2011
New Revision: 221175
URL: http://svn.freebsd.org/changeset/base/221175

Log:
  A diagnostic tool to go along with the vxge(4) 10GbE driver.
  This tool can be used to print statistics, registers, and
  other device specific information once the driver is loaded
  into the kernel.
  
  Submitted by: Sriram Rapuru from Exar
  MFC after:    2 weeks

Added:
  head/tools/tools/vxge/
  head/tools/tools/vxge/Makefile   (contents, props changed)
  head/tools/tools/vxge/vxge_cmn.h   (contents, props changed)
  head/tools/tools/vxge/vxge_info.c   (contents, props changed)
  head/tools/tools/vxge/vxge_info.h   (contents, props changed)
  head/tools/tools/vxge/vxge_log.c   (contents, props changed)
  head/tools/tools/vxge/vxge_log.h   (contents, props changed)
Modified:
  head/tools/tools/README

Modified: head/tools/tools/README
==============================================================================
--- head/tools/tools/README     Thu Apr 28 16:18:30 2011        (r221174)
+++ head/tools/tools/README     Thu Apr 28 16:29:19 2011        (r221175)
@@ -66,4 +66,5 @@ vimage                An interim utility for managing 
                stack infrastructure.
 vop_table      Generates a HTML document that shows all the VOP's in
                the kernel.
+vxge           A diagnostic tool for the vxge(4) driver
 whereintheworld        Summarizes "make world" output.

Added: head/tools/tools/vxge/Makefile
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/vxge/Makefile      Thu Apr 28 16:29:19 2011        
(r221175)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= vxge-manage
+SRCS= vxge_info.c vxge_log.c
+NO_MAN=
+ 
+.include <bsd.prog.mk>

Added: head/tools/tools/vxge/vxge_cmn.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/vxge/vxge_cmn.h    Thu Apr 28 16:29:19 2011        
(r221175)
@@ -0,0 +1,260 @@
+/*-
+ * Copyright(c) 2002-2011 Exar Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification are permitted provided the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice,
+ *       this list of conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *
+ *    3. Neither the name of the Exar Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived from
+ *       this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*$FreeBSD$*/
+
+#ifndef        _VXGE_CMN_H_
+#define        _VXGE_CMN_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define        VXGE_OS_HOST_BIG_ENDIAN
+#else
+#define        VXGE_OS_HOST_LITTLE_ENDIAN
+#endif
+
+#if defined(VXGE_OS_HOST_BIG_ENDIAN)
+
+#define        GET_OFFSET_STATS(index)         statsInfo[(index)].be_offset
+#define        GET_OFFSET_PCICONF(index)       pciconfInfo[(index)].be_offset
+
+#else
+
+#define        GET_OFFSET_STATS(index)         statsInfo[(index)].le_offset
+#define        GET_OFFSET_PCICONF(index)       pciconfInfo[(index)].le_offset
+
+#endif
+
+#define        vxge_mem_free(x)        \
+       if (NULL != x) { free(x); x = NULL; }
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef unsigned long long u64;
+typedef u_long ulong_t;
+
+typedef enum _vxge_query_device_info_e {
+
+       VXGE_GET_PCI_CONF = 100,
+       VXGE_GET_MRPCIM_STATS = 101,
+       VXGE_GET_DEVICE_STATS = 102,
+       VXGE_GET_DEVICE_HWINFO = 103,
+       VXGE_GET_DRIVER_STATS = 104,
+       VXGE_GET_INTR_STATS = 105,
+       VXGE_GET_VERSION = 106,
+       VXGE_GET_TCODE = 107,
+       VXGE_GET_VPATH_COUNT = 108,
+       VXGE_GET_BANDWIDTH = 109,
+       VXGE_SET_BANDWIDTH = 110,
+       VXGE_GET_PORT_MODE = 111,
+       VXGE_SET_PORT_MODE = 112
+
+} vxge_query_device_info_e;
+
+/* Register type enumaration */
+typedef enum vxge_hal_mgmt_reg_type_e {
+
+       vxge_hal_mgmt_reg_type_legacy = 0,
+       vxge_hal_mgmt_reg_type_toc = 1,
+       vxge_hal_mgmt_reg_type_common = 2,
+       vxge_hal_mgmt_reg_type_memrepair = 3,
+       vxge_hal_mgmt_reg_type_pcicfgmgmt = 4,
+       vxge_hal_mgmt_reg_type_mrpcim = 5,
+       vxge_hal_mgmt_reg_type_srpcim = 6,
+       vxge_hal_mgmt_reg_type_vpmgmt = 7,
+       vxge_hal_mgmt_reg_type_vpath = 8
+
+} vxge_hal_mgmt_reg_type_e;
+
+typedef enum vxge_hal_xmac_nwif_dp_mode {
+
+       VXGE_HAL_DP_NP_MODE_DEFAULT,
+       VXGE_HAL_DP_NP_MODE_LINK_AGGR,
+       VXGE_HAL_DP_NP_MODE_ACTIVE_PASSIVE,
+       VXGE_HAL_DP_NP_MODE_SINGLE_PORT,
+       VXGE_HAL_DP_NP_MODE_DUAL_PORT,
+       VXGE_HAL_DP_NP_MODE_DISABLE_PORT_MGMT
+
+} vxge_hal_xmac_nwif_dp_mode;
+
+typedef enum vxge_hal_xmac_nwif_behavior_on_failure {
+
+       VXGE_HAL_XMAC_NWIF_OnFailure_NoMove,
+       VXGE_HAL_XMAC_NWIF_OnFailure_OtherPort,
+       VXGE_HAL_XMAC_NWIF_OnFailure_OtherPortBackOnRestore
+
+} vxge_hal_xmac_nwif_behavior_on_failure;
+
+#define        VXGE_HAL_MGMT_REG_COUNT_LEGACY          7
+#define        VXGE_HAL_MGMT_REG_COUNT_TOC             11
+#define        VXGE_HAL_MGMT_REG_COUNT_COMMON          65
+#define        VXGE_HAL_MGMT_REG_COUNT_PCICFGMGMT      3
+#define        VXGE_HAL_MGMT_REG_COUNT_MRPCIM          1370
+#define        VXGE_HAL_MGMT_REG_COUNT_SRPCIM          48
+#define        VXGE_HAL_MGMT_REG_COUNT_VPMGMT          29
+#define        VXGE_HAL_MGMT_REG_COUNT_VPATH           139
+#define        VXGE_HAL_MGMT_STATS_COUNT_DRIVER        17
+#define        VXGE_HAL_MGMT_STATS_COUNT               160
+#define        VXGE_HAL_MGMT_STATS_COUNT_SW            54
+#define        VXGE_HAL_MGMT_STATS_COUNT_EXTENDED      56
+#define        VXGE_MAX_BANDWIDTH                      10000
+
+#define        VXGE_HAL_MAX_VIRTUAL_PATHS              17
+#define        ETH_LENGTH_OF_ADDRESS                   6
+
+typedef char macaddr[ETH_LENGTH_OF_ADDRESS];
+
+#define        VXGE_PRINT(fd, fmt...) {        \
+       fprintf(fd, fmt);               \
+       fprintf(fd, "\n");              \
+       printf(fmt);                    \
+       printf("\n");                   \
+}
+
+/* Read        & Write Register */
+typedef struct _vxge_register_info_t {
+
+       u64     value;
+       u64     offset;
+       char    option[2];
+
+} vxge_register_info_t;
+
+/* Register Dump */
+typedef struct _vxge_pci_bar0_t {
+       char    name[64];
+       u64     offset;
+       u32     size;
+
+} vxge_pci_bar0_t;
+
+typedef struct _vxge_stats_driver_info_t {
+
+       char    name[32];
+       u64     value;
+
+} vxge_stats_driver_info_t;
+
+typedef struct _vxge_hal_device_pmd_info_t {
+
+       u32     type;
+       u32     unused;
+       char    vendor[24];
+       char    part_num[24];
+       char    ser_num[24];
+
+} vxge_hal_device_pmd_info_t;
+
+typedef struct _vxge_hal_device_version_t {
+
+       u32     major;
+       u32     minor;
+       u32     build;
+       char    version[32];
+
+} vxge_hal_device_version_t;
+
+typedef struct _vxge_hal_device_date_t {
+
+       u32     day;
+       u32     month;
+       u32     year;
+       char    date[16];
+
+} vxge_hal_device_date_t;
+
+typedef struct _vxge_hal_device_hw_info_t {
+
+       u32     host_type;
+       u64     function_mode;
+       u32     func_id;
+       u64     vpath_mask;
+
+       vxge_hal_device_version_t fw_version;
+       vxge_hal_device_date_t fw_date;
+       vxge_hal_device_version_t flash_version;
+       vxge_hal_device_date_t flash_date;
+
+       char    serial_number[24];
+       char    part_number[24];
+       char    product_description[72];
+       u32     unused;
+       u32     ports;
+
+       vxge_hal_device_pmd_info_t pmd_port0;
+       vxge_hal_device_pmd_info_t pmd_port1;
+
+       macaddr mac_addrs[VXGE_HAL_MAX_VIRTUAL_PATHS];
+       macaddr mac_addr_masks[VXGE_HAL_MAX_VIRTUAL_PATHS];
+
+} vxge_hal_device_hw_info_t;
+
+typedef struct _vxge_device_hw_info_t {
+
+       vxge_hal_device_hw_info_t hw_info;
+       u32     port_mode;
+       u32     port_failure;
+
+} vxge_device_hw_info_t;
+
+typedef struct _vxge_bw_info_t {
+
+       char    query;
+       u64     func_id;
+       int     priority;
+       int     bandwidth;
+
+} vxge_bw_info_t;
+
+typedef struct _vxge_port_info_t {
+
+       char    query;
+       int     port_mode;
+       int     port_failure;
+
+} vxge_port_info_t;
+
+u32    vxge_get_num_vpath(void);
+void   vxge_null_terminate(char *, size_t);
+
+#endif /* _VXGE_CMN_H_ */

Added: head/tools/tools/vxge/vxge_info.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/vxge/vxge_info.c   Thu Apr 28 16:29:19 2011        
(r221175)
@@ -0,0 +1,857 @@
+/*-
+ * Copyright(c) 2002-2011 Exar Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification are permitted provided the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice,
+ *       this list of conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *
+ *    3. Neither the name of the Exar Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived from
+ *       this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*$FreeBSD$*/
+
+#include "vxge_info.h"
+
+static int sockfd;
+static struct ifreq ifr;
+
+int
+main(int argc, char *argv[])
+{
+       if (argc >= 4) {
+               if (!((strcasecmp(argv[2], "regs") == 0) ||
+                   (strcasecmp(argv[2], "stats") == 0) ||
+                   (strcasecmp(argv[2], "bw_pri_set") == 0) ||
+                   (strcasecmp(argv[2], "port_mode_set") == 0) ||
+                   (strcasecmp(argv[2], "bw_pri_get") == 0)))
+                       goto out;
+               else {
+                       if (strcasecmp(argv[2], "regs") == 0) {
+                               if (!((strcasecmp(argv[3], "common") == 0) ||
+                                   (strcasecmp(argv[3], "legacy") == 0) ||
+                                   (strcasecmp(argv[3], "pcicfgmgmt") == 0) ||
+                                   (strcasecmp(argv[3], "toc") == 0) ||
+                                   (strcasecmp(argv[3], "vpath") == 0) ||
+                                   (strcasecmp(argv[3], "vpmgmt") == 0) ||
+                                   (strcasecmp(argv[3], "mrpcim") == 0) ||
+                                   (strcasecmp(argv[3], "srpcim") == 0) ||
+                                   (strcasecmp(argv[3], "all") == 0))) {
+                                       goto regs;
+                               }
+                       } else if (strcasecmp(argv[2], "stats") == 0) {
+
+                               if (!((strcasecmp(argv[3], "common") == 0) ||
+                                   (strcasecmp(argv[3], "mrpcim") == 0) ||
+                                   (strcasecmp(argv[3], "all") == 0) ||
+                                   (strcasecmp(argv[3], "driver") == 0))) {
+                                       goto stats;
+                               }
+                       }
+               }
+       } else {
+               if (argc != 3)
+                       goto out;
+               else {
+                       if (!((strcasecmp(argv[2], "hwinfo") == 0) ||
+                           (strcasecmp(argv[2], "pciconfig") == 0) ||
+                           (strcasecmp(argv[2], "port_mode_get") == 0) ||
+                           (strcasecmp(argv[2], "bw_pri_get") == 0))) {
+                               if (strcasecmp(argv[2], "regs") == 0)
+                                       goto regs;
+
+                               if (strcasecmp(argv[2], "stats") == 0)
+                                       goto stats;
+
+                               if (strcasecmp(argv[2], "bw_pri_set") == 0)
+                                       goto bw_pri_set;
+
+                               if (strcasecmp(argv[2], "port_mode_set") == 0)
+                                       goto port_mode_set;
+
+                               goto out;
+                       }
+               }
+       }
+
+       sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+       if (sockfd < 0) {
+               printf("Creating socket failed\n");
+               goto _exit0;
+       }
+
+       ifr.ifr_addr.sa_family = AF_INET;
+       strlcpy(ifr.ifr_name, argv[1], sizeof(ifr.ifr_name));
+
+       if (strcasecmp(argv[2], "pciconfig") == 0)
+               vxge_get_pci_config();
+
+       else if (strcasecmp(argv[2], "hwinfo") == 0)
+               vxge_get_hw_info();
+
+       else if (strcasecmp(argv[2], "vpathinfo") == 0)
+               vxge_get_num_vpath();
+
+       else if (strcasecmp(argv[2], "port_mode_get") == 0)
+               vxge_get_port_mode();
+
+       else if (strcasecmp(argv[2], "regs") == 0) {
+
+               if (strcasecmp(argv[3], "common") == 0)
+                       vxge_get_registers_common();
+
+               else if (strcasecmp(argv[3], "toc") == 0)
+                       vxge_get_registers_toc();
+
+               else if (strcasecmp(argv[3], "pcicfgmgmt") == 0)
+                       vxge_get_registers_pcicfgmgmt();
+
+               else if (strcasecmp(argv[3], "vpath") == 0)
+                       vxge_get_registers_vpath();
+
+               else if (strcasecmp(argv[3], "vpmgmt") == 0)
+                       vxge_get_registers_vpmgmt();
+
+               else if (strcasecmp(argv[3], "srpcim") == 0)
+                       vxge_get_registers_srpcim();
+
+               else if (strcasecmp(argv[3], "legacy") == 0)
+                       vxge_get_registers_legacy();
+
+               if (strcasecmp(argv[3], "mrpcim") == 0)
+                       vxge_get_registers_mrpcim();
+
+               else if (strcasecmp(argv[3], "all") == 0)
+                       vxge_get_registers_all();
+
+       } else if (strcasecmp(argv[2], "stats") == 0) {
+
+               if (strcasecmp(argv[3], "mrpcim") == 0)
+                       vxge_get_stats_mrpcim();
+
+               else if (strcasecmp(argv[3], "common") == 0)
+                       vxge_get_stats_common();
+
+               else if (strcasecmp(argv[3], "all") == 0)
+                       vxge_get_stats_all();
+
+               else if (strcasecmp(argv[3], "driver") == 0) {
+                       if (argc == 4) {
+                               vxge_get_stats_driver(-1);
+                       } else if (argc == 6) {
+                               if ((strcasecmp(argv[4], "vpath") == 0) &&
+                                   (atoi(argv[5]) >= 0) &&
+                                   (atoi(argv[5]) < 17)) {
+                                       vxge_get_stats_driver(atoi(argv[5]));
+                               } else {
+                                       goto stats;
+                               }
+                       }
+               } else {
+                       goto stats;
+               }
+       } else if (strcasecmp(argv[2], "port_mode_set") == 0) {
+               if ((atoi(argv[3]) >= 2) && (atoi(argv[3]) <= 4))
+                       vxge_set_port_mode(atoi(argv[3]));
+               else
+                       goto port_mode_set;
+       } else if (argc == 5) {
+               if (strcasecmp(argv[2], "bw_pri_set") == 0) {
+                       if (((atoi(argv[3]) >= 0) && (atoi(argv[3]) < 8) &&
+                           (atoi(argv[4]) <= 10000)))
+                               vxge_set_bw_priority(atoi(argv[3]),
+                                   atoi(argv[4]), -1, VXGE_SET_BANDWIDTH);
+                       else
+                               goto bw_pri_set;
+               }
+       } else if (argc == 6) {
+               if (strcasecmp(argv[2], "bw_pri_set") == 0) {
+                       if (((atoi(argv[3]) >= 0) && (atoi(argv[3]) < 8) &&
+                           (atoi(argv[4]) <= 10000)) && (atoi(argv[5]) <= 3))
+                               vxge_set_bw_priority(atoi(argv[3]),
+                                   atoi(argv[4]), atoi(argv[5]),
+                                   VXGE_SET_BANDWIDTH);
+                       else
+                               goto bw_pri_set;
+               }
+       } else if (argc == 4) {
+               if (strcasecmp(argv[2], "bw_pri_get") == 0) {
+                       if ((atoi(argv[3]) >= 0) && (atoi(argv[3]) < 8))
+                               vxge_get_bw_priority(atoi(argv[3]), 
VXGE_GET_BANDWIDTH);
+                       else
+                               goto bw_pri_get;
+               }
+       } else if (argc == 3) {
+               if (strcasecmp(argv[2], "bw_pri_get") == 0)
+                       vxge_get_bw_priority(-1, VXGE_GET_BANDWIDTH);
+               else
+                       goto bw_pri_get;
+       }
+
+       goto _exit0;
+
+out:
+       printf("Usage: ");
+       printf("vxge-manage <INTERFACE> ");
+       printf("[regs] [stats] [hwinfo] [bw_pri_get] [bw_pri_set] 
[port_mode_get] [port_mode_set] [pciconfig]\n");
+       printf("\tINTERFACE      : Interface (vxge0, vxge1, vxge2, ..)\n");
+       printf("\tregs           : Prints register values\n");
+       printf("\tstats          : Prints statistics\n");
+       printf("\tpciconfig      : Prints pci configuration space\n");
+       printf("\thwinfo         : Displays hardware information\n");
+       printf("\tbw_pri_get     : Displays bandwidth and priority 
information\n");
+       printf("\tbw_pri_set     : Set bandwidth and priority of a function\n");
+       printf("\tport_mode_get  : Displays dual port adapter's port mode\n");
+       printf("\tport_mode_set  : Set dual port adapter's port mode\n\n");
+       goto _exit0;
+
+regs:
+       printf("Regs\n");
+       printf("[common] [legacy] [pcicfgmgmt] [toc] [vpath] [vpmgmt] [mrpcim] 
[srpcim] [All]\n");
+       printf("\tcommon         : print common registers\n");
+       printf("\tlegacy         : print legacy registers\n");
+       printf("\tpcicfgmgmt     : print pcicfgmgmt registers\n");
+       printf("\ttoc            : print toc registers\n");
+       printf("\tvpath          : print vpath registers\n");
+       printf("\tvpmgmt         : print vpmgmt registers\n");
+       printf("\tmrpcim         : print mrpcim registers\n");
+       printf("\tsrpcim         : print srpcim registers\n\n");
+       goto _exit0;
+
+stats:
+       printf("Stats\n");
+       printf("[common] [mrpcim] [driver [vpath (< 17) ]] [All]\n");
+       printf("\tcommon         : print common statistics\n");
+       printf("\tmrpcim         : print mrpcim statistics\n");
+       printf("\tdriver         : print driver statistics\n");
+       printf("\tAll            : print all statistics\n\n");
+       goto _exit0;
+
+bw_pri_set:
+       printf("Bandwidth & Priority\n");
+       printf("[vf-id (0-7)] [bandwidth (100-10000)] [priority (0-3)]\n\n");
+       goto _exit0;
+
+bw_pri_get:
+       printf("Bandwidth & Priority\n");
+       printf("[vf-id (0-7)]\n\n");
+       goto _exit0;
+
+port_mode_set:
+       printf("Port mode Setting\n");
+       printf("[port mode value (2-4)]\n\n");
+       goto _exit0;
+
+_exit0:
+       return (0);
+}
+
+/*
+ * vxge_get_registers_all
+ */
+void
+vxge_get_registers_all(void)
+{
+       vxge_get_registers_legacy();
+       vxge_get_registers_toc();
+       vxge_get_registers_common();
+       vxge_get_registers_pcicfgmgmt();
+       vxge_get_registers_srpcim();
+       vxge_get_registers_mrpcim();
+       vxge_get_registers_vpmgmt();
+       vxge_get_registers_vpath();
+}
+
+int
+vxge_get_registers_common(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize =
+           reginfo_registers[VXGE_HAL_MGMT_REG_COUNT_COMMON - 1].offset + 8;
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = vxge_hal_mgmt_reg_type_common;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting register values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_registers(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_registers_legacy
+ */
+int
+vxge_get_registers_legacy(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = reginfo_legacy[VXGE_HAL_MGMT_REG_COUNT_LEGACY - 1].offset + 8;
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = vxge_hal_mgmt_reg_type_legacy;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting register values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_registers_legacy(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_registers_toc
+ */
+int
+vxge_get_registers_toc(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = reginfo_toc[VXGE_HAL_MGMT_REG_COUNT_TOC - 1].offset + 8;
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = vxge_hal_mgmt_reg_type_toc;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting register values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_registers_toc(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_registers_pcicfgmgmt
+ */
+int
+vxge_get_registers_pcicfgmgmt(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = reginfo_pcicfgmgmt[VXGE_HAL_MGMT_REG_COUNT_PCICFGMGMT - 
1].offset + 8;
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = vxge_hal_mgmt_reg_type_pcicfgmgmt;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting register values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_registers_pcicfgmgmt(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_registers_vpath
+ */
+int
+vxge_get_registers_vpath(void)
+{
+       int bufsize, err = 0;
+       u32 i, no_of_vpath;
+       char *buffer = NULL;
+
+       no_of_vpath = vxge_get_num_vpath();
+       bufsize = reginfo_vpath[VXGE_HAL_MGMT_REG_COUNT_VPATH - 1].offset + 8;
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       for (i = 0; i < no_of_vpath; i++) {
+
+               bzero(buffer, bufsize);
+               *buffer = vxge_hal_mgmt_reg_type_vpath;
+               *((u32 *) (buffer + sizeof(u32))) = i;
+
+               ifr.ifr_data = (caddr_t) buffer;
+               err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+               if ((err < 0) || (err == EINVAL)) {
+                       printf("Getting register values failed\n");
+                       goto _exit0;
+               }
+
+               vxge_print_registers_vpath(buffer, i);
+       }
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_registers_vpmgmt
+ */
+int
+vxge_get_registers_vpmgmt(void)
+{
+       int bufsize, err = 0;
+       u32 i, no_of_vpath;
+       char *buffer = NULL;
+
+       no_of_vpath = vxge_get_num_vpath();
+       bufsize = reginfo_vpmgmt[VXGE_HAL_MGMT_REG_COUNT_VPMGMT - 1].offset + 8;
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       for (i = 0; i < no_of_vpath; i++) {
+
+               bzero(buffer, bufsize);
+               *buffer = vxge_hal_mgmt_reg_type_vpmgmt;
+               *((u32 *) (buffer + sizeof(u32))) = i;
+
+               ifr.ifr_data = (caddr_t) buffer;
+               err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+               if ((err < 0) || (err == EINVAL)) {
+                       printf("Getting register values failed\n");
+                       goto _exit0;
+               }
+
+               vxge_print_registers_vpmgmt(buffer);
+       }
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+u32
+vxge_get_num_vpath(void)
+{
+       int err = 0;
+       u32 buffer, no_of_vpath = 0;
+
+       buffer = VXGE_GET_VPATH_COUNT;
+
+       ifr.ifr_data = (caddr_t) &buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if (err == 0)
+               no_of_vpath = buffer;
+       else
+               printf("Getting number of vpath failed\n");
+
+       return (no_of_vpath);
+}
+
+/*
+ * vxge_get_registers_mrpcim
+ */
+int
+vxge_get_registers_mrpcim(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = reginfo_mrpcim[VXGE_HAL_MGMT_REG_COUNT_MRPCIM - 1].offset + 8;
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = vxge_hal_mgmt_reg_type_mrpcim;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting register values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_registers_mrpcim(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_registers_srpcim
+ * Gets srpcim register values
+ * Returns EXIT_SUCCESS or EXIT_FAILURE
+ */
+int
+vxge_get_registers_srpcim(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = reginfo_srpcim[VXGE_HAL_MGMT_REG_COUNT_SRPCIM - 1].offset + 8;
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for register dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = vxge_hal_mgmt_reg_type_srpcim;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_1, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting register values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_registers_srpcim(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_stats_driver
+ */
+int
+vxge_get_stats_driver(int vpath_num)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = VXGE_HAL_MGMT_STATS_COUNT_DRIVER * sizeof(u64) *
+           VXGE_HAL_MAX_VIRTUAL_PATHS;
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for driver statistics failed\n");
+               goto _exit0;
+       }
+
+       *buffer = VXGE_GET_DRIVER_STATS;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_0, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting Driver Statistics failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_stats_drv(buffer, vpath_num);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_stats_common
+ */
+int
+vxge_get_stats_common(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = 1024 * 64 * sizeof(char);
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for statistics dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = VXGE_GET_DEVICE_STATS;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_0, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting statistics values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_stats(buffer, VXGE_GET_DEVICE_STATS);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+
+}
+
+/*
+ * vxge_get_stats_mrpcim
+ */
+int
+vxge_get_stats_mrpcim(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = 1024 * 64 * sizeof(char);
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for statistics dump failed\n");
+               goto _exit0;
+       }
+
+       *buffer = VXGE_GET_MRPCIM_STATS;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_0, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting statistics values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_stats(buffer, VXGE_GET_MRPCIM_STATS);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+int
+vxge_get_pci_config(void)
+{
+       int bufsize, err = 0;
+       char *buffer = NULL;
+
+       bufsize = 64 * 1024 * sizeof(char);
+
+       buffer = (char *) vxge_mem_alloc(bufsize);
+       if (!buffer) {
+               printf("Allocating memory for pci config failed\n");
+               goto _exit0;
+       }
+
+       *buffer = VXGE_GET_PCI_CONF;
+
+       ifr.ifr_data = (caddr_t) buffer;
+       err = ioctl(sockfd, SIOCGPRIVATE_0, &ifr);
+       if ((err < 0) || (err == EINVAL)) {
+               printf("Getting pci config values failed\n");
+               goto _exit0;
+       }
+
+       vxge_print_pci_config(buffer);
+
+_exit0:
+       vxge_mem_free(buffer);
+       return (err);
+}
+
+/*
+ * vxge_get_hw_info
+ */
+int
+vxge_get_hw_info(void)
+{
+       int err = 0;
+       char *buffer = NULL;
+
+       buffer = (char *) vxge_mem_alloc(sizeof(vxge_device_hw_info_t));

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to