/* * 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); }
/* * vxge_print_stats_drv * Prints/logs Driver Statistics * @driver_stats Driver Statistics */ void vxge_print_stats_drv(void *driver_stats, int vpath_num) { int i, j; u32 no_of_vpath; no_of_vpath = vxge_get_num_vpath(); fdAll = fopen("vxge_drv_stats.log", "w+"); if (!fdAll) return; for (i = 0; i < no_of_vpath; i++) { if (vpath_num != -1) { if (vpath_num != i) { driver_stats = driver_stats + (VXGE_HAL_MGMT_STATS_COUNT_DRIVER * sizeof(u64)); continue; } } VXGE_PRINT_LINE(fdAll); VXGE_PRINT(fdAll, " VPath # %d ", i); VXGE_PRINT_LINE(fdAll); for (j = 0; j < VXGE_HAL_MGMT_STATS_COUNT_DRIVER; j++) { driverInfo[j].value = *((u64 *) ((unsigned char *) driver_stats + (j * (sizeof(u64))))); VXGE_PRINT_STATS(fdAll, (const char *) driverInfo[j].name, driverInfo[j].value); } driver_stats = driver_stats + (j * sizeof(u64)); } VXGE_PRINT_LINE(fdAll); fclose(fdAll); }
int main(int argc, char *argv[]) { uid_t uid; uid = getuid(); if (uid) { printf("vxge-manage: Operation not permitted.\nExiting...\n"); goto _exit0; } 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); }