int main(int argc, char **argv) { int mgmt_classes[3] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS }; int sysstat_class = IB_VENDOR_OPENIB_SYSSTAT_CLASS; ib_portid_t portid = { 0 }; int attr = IB_PING_ATTR; char *err; const struct ibdiag_opt opts[] = { {"oui", 'o', 1, NULL, "use specified OUI number"}, {"Server", 'S', 0, NULL, "start in server mode"}, {0} }; char usage_args[] = "<dest lid|guid> [<op>]"; ibdiag_process_opts(argc, argv, NULL, "DKy", opts, process_opt, usage_args, NULL); argc -= optind; argv += optind; if (!argc && !server) ibdiag_show_usage(); if (argc > 1 && (attr = match_attr(argv[1])) < 0) ibdiag_show_usage(); srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3); if (!srcport) IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port); if (server) { if (mad_register_server_via(sysstat_class, 1, 0, oui, srcport) < 0) IBEXIT("can't serve class %d", sysstat_class); host_ncpu = build_cpuinfo(); if ((err = ibsystat_serv())) IBEXIT("ibssystat to %s: %s", portid2str(&portid), err); exit(0); } if (mad_register_client_via(sysstat_class, 1, srcport) < 0) IBEXIT("can't register to sysstat class %d", sysstat_class); if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0], ibd_dest_type, ibd_sm_id, srcport) < 0) IBEXIT("can't resolve destination port %s", argv[0]); if ((err = ibsystat(&portid, attr))) IBEXIT("ibsystat to %s: %s", portid2str(&portid), err); mad_rpc_close_port(srcport); exit(0); }
int main(int argc, char **argv) { char usage_args[1024]; int mgmt_classes[3] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS }; ib_portid_t portid = { 0 }; char *err; op_fn_t *fn; const match_rec_t *r; int n; const struct ibdiag_opt opts[] = { {"combined", 'c', 0, NULL, "use Combined route address argument"}, {"node-name-map", 1, 1, "<file>", "node name map file"}, {"extended", 'x', 0, NULL, "use extended speeds"}, {0} }; const char *usage_examples[] = { "portinfo 3 1\t\t\t\t# portinfo by lid, with port modifier", "-G switchinfo 0x2C9000100D051 1\t# switchinfo by guid", "-D nodeinfo 0\t\t\t\t# nodeinfo by direct route", "-c nodeinfo 6 0,12\t\t\t# nodeinfo by combined route", NULL }; n = sprintf(usage_args, "<op> <dest dr_path|lid|guid> [op params]\n" "\nSupported ops (and aliases, case insensitive):\n"); for (r = match_tbl; r->name; r++) { n += snprintf(usage_args + n, sizeof(usage_args) - n, " %s (%s) <addr>%s\n", r->name, r->alias ? r->alias : "", r->opt_portnum ? " [<portnum>]" : ""); if (n >= sizeof(usage_args)) exit(-1); } ibdiag_process_opts(argc, argv, NULL, NULL, opts, process_opt, usage_args, usage_examples); argc -= optind; argv += optind; if (argc < 2) ibdiag_show_usage(); if (!(fn = match_op(match_tbl, argv[0]))) IBEXIT("operation '%s' not supported", argv[0]); srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3); if (!srcport) IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port); smp_mkey_set(srcport, ibd_mkey); node_name_map = open_node_name_map(node_name_map_file); if (ibd_dest_type != IB_DEST_DRSLID) { if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1], ibd_dest_type, ibd_sm_id, srcport) < 0) IBEXIT("can't resolve destination port %s", argv[1]); if ((err = fn(&portid, argv + 2, argc - 2))) IBEXIT("operation %s: %s", argv[0], err); } else { char concat[64]; memset(concat, 0, 64); snprintf(concat, sizeof(concat), "%s %s", argv[1], argv[2]); if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, concat, ibd_dest_type, ibd_sm_id, srcport) < 0) IBEXIT("can't resolve destination port %s", concat); if ((err = fn(&portid, argv + 3, argc - 3))) IBEXIT("operation %s: %s", argv[0], err); } close_node_name_map(node_name_map); mad_rpc_close_port(srcport); exit(0); }
int main(int argc, char **argv) { char usage_args[1024]; int mgmt_classes[3] = { IB_SMI_CLASS, IB_SA_CLASS, IB_CC_CLASS }; ib_portid_t portid = { 0 }; char *err; op_fn_t *fn; const match_rec_t *r; int n; const struct ibdiag_opt opts[] = { {"cckey", 'c', 1, "<key>", "CC key"}, {0} }; const char *usage_examples[] = { "SwitchCongestionSetting 2 0x1F 0x1FFFFFFFFF 0x0 0xF 8 0 0:0 1\t# Configure Switch Congestion Settings", "CACongestionSetting 1 0 0x3 150 1 0 0\t\t# Configure CA Congestion Settings to SL 0 and SL 1", "CACongestionSetting 1 0 0x4 200 1 0 0\t\t# Configure CA Congestion Settings to SL 2", "CongestionControlTable 1 63 0 0:0 0:1 ...\t# Configure first block of Congestion Control Table", "CongestionControlTable 1 127 0 0:64 0:65 ...\t# Configure second block of Congestion Control Table", NULL }; n = sprintf(usage_args, "[-c key] <op> <lid|guid>\n" "\nWARNING -- You should understand what you are " "doing before using this tool. Misuse of this " "tool could result in a broken fabric.\n" "\nSupported ops (and aliases, case insensitive):\n"); for (r = match_tbl; r->name; r++) { n += snprintf(usage_args + n, sizeof(usage_args) - n, " %s (%s) <lid|guid>%s%s%s\n", r->name, r->alias ? r->alias : "", r->opt_portnum ? " <portnum>" : "", r->ops_extra ? " " : "", r->ops_extra ? r->ops_extra : ""); if (n >= sizeof(usage_args)) exit(-1); } ibdiag_process_opts(argc, argv, NULL, "DK", opts, process_opt, usage_args, usage_examples); argc -= optind; argv += optind; if (argc < 2) ibdiag_show_usage(); if (!(fn = match_op(match_tbl, argv[0]))) IBEXIT("operation '%s' not supported", argv[0]); srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3); if (!srcport) IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port); smp_mkey_set(srcport, ibd_mkey); if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1], ibd_dest_type, ibd_sm_id, srcport) < 0) IBEXIT("can't resolve destination %s", argv[1]); if ((err = fn(&portid, argv + 2, argc - 2))) IBEXIT("operation %s: %s", argv[0], err); mad_rpc_close_port(srcport); exit(0); }
int main(int argc, char **argv) { int mgmt_classes[3] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS }; ib_portid_t portid = { 0 }; int port_op = -1; int is_switch, is_peer_switch, espeed_cap, peer_espeed_cap; int state, physstate, lwe, lws, lwa, lse, lss, lsa, lsee, lses, lsea, fdr10s, fdr10e, fdr10a; int peerlocalportnum, peerlwe, peerlws, peerlwa, peerlse, peerlss, peerlsa, peerlsee, peerlses, peerlsea, peerfdr10s, peerfdr10e, peerfdr10a; int peerwidth, peerspeed, peerespeed; uint8_t data[IB_SMP_DATA_SIZE] = { 0 }; uint8_t data2[IB_SMP_DATA_SIZE] = { 0 }; ib_portid_t peerportid = { 0 }; int portnum = 0; ib_portid_t selfportid = { 0 }; int selfport = 0; int changed = 0; int i; uint32_t vendorid, rem_vendorid; uint16_t devid, rem_devid; uint64_t val; char *endp; char usage_args[] = "<dest dr_path|lid|guid> <portnum> [<op>]\n" "\nSupported ops: enable, disable, on, off, reset, speed, espeed, fdr10,\n" "\twidth, query, down, arm, active, vls, mtu, lid, smlid, lmc,\n" "\tmkey, mkeylease, mkeyprot\n"; const char *usage_examples[] = { "3 1 disable\t\t\t# by lid", "-G 0x2C9000100D051 1 enable\t# by guid", "-D 0 1\t\t\t# (query) by direct route", "3 1 reset\t\t\t# by lid", "3 1 speed 1\t\t\t# by lid", "3 1 width 1\t\t\t# by lid", "-D 0 1 lid 0x1234 arm\t\t# by direct route", NULL }; ibdiag_process_opts(argc, argv, NULL, NULL, NULL, NULL, usage_args, usage_examples); argc -= optind; argv += optind; if (argc < 2) ibdiag_show_usage(); srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3); if (!srcport) IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port); smp_mkey_set(srcport, ibd_mkey); if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0], ibd_dest_type, ibd_sm_id, srcport) < 0) IBEXIT("can't resolve destination port %s", argv[0]); if (argc > 1) portnum = strtol(argv[1], 0, 0); for (i = 2; i < argc; i++) { int j; for (j = 0; j < NPORT_ARGS; j++) { if (strcmp(argv[i], port_args[j].name)) continue; port_args[j].set = 1; if (!port_args[j].val) { if (port_op >= 0) IBEXIT("%s only one of: ", "query, enable, disable, " "reset, down, arm, active, " "can be specified", port_args[j].name); port_op = j; break; } if (++i >= argc) IBEXIT("%s requires an additional parameter", port_args[j].name); val = strtoull(argv[i], 0, 0); switch (j) { case SPEED: if (val > 15) IBEXIT("invalid speed value %ld", val); break; case ESPEED: if (val > 31) IBEXIT("invalid extended speed value %ld", val); break; case FDR10SPEED: if (val > 1) IBEXIT("invalid fdr10 speed value %ld", val); break; case WIDTH: if ((val > 31 && val != 255)) IBEXIT("invalid width value %ld", val); break; case VLS: if (val == 0 || val > 5) IBEXIT("invalid vls value %ld", val); break; case MTU: if (val == 0 || val > 5) IBEXIT("invalid mtu value %ld", val); break; case LID: if (val == 0 || val >= 0xC000) IBEXIT("invalid lid value 0x%lx", val); break; case SMLID: if (val == 0 || val >= 0xC000) IBEXIT("invalid smlid value 0x%lx", val); break; case LMC: if (val > 7) IBEXIT("invalid lmc value %ld", val); break; case MKEY: errno = 0; val = strtoull(argv[i], &endp, 0); if (errno || *endp != '\0') { errno = 0; val = strtoull(getpass("New M_Key: "), &endp, 0); if (errno || *endp != '\0') { IBEXIT("Bad new M_Key\n"); } } /* All 64-bit values are legal */ break; case MKEYLEASE: if (val > 0xFFFF) IBEXIT("invalid mkey lease time %ld", val); break; case MKEYPROT: if (val > 3) IBEXIT("invalid mkey protection bit setting %ld", val); } *port_args[j].val = val; changed = 1; break; } if (j == NPORT_ARGS) IBEXIT("invalid operation: %s", argv[i]); } if (port_op < 0) port_op = QUERY; is_switch = get_node_info(&portid, data); vendorid = (uint32_t) mad_get_field(data, 0, IB_NODE_VENDORID_F); devid = (uint16_t) mad_get_field(data, 0, IB_NODE_DEVID_F); if ((port_args[MKEY].set || port_args[MKEYLEASE].set || port_args[MKEYPROT].set) && is_switch && portnum != 0) IBEXIT("Can't set M_Key fields on switch port != 0"); if (port_op != QUERY || changed) printf("Initial %s PortInfo:\n", is_switch ? "Switch" : "CA/RT"); else printf("%s PortInfo:\n", is_switch ? "Switch" : "CA/RT"); espeed_cap = get_port_info(&portid, data, portnum, is_switch); show_port_info(&portid, data, portnum, espeed_cap, is_switch); if (is_mlnx_ext_port_info_supported(vendorid, devid)) { get_mlnx_ext_port_info(&portid, data2, portnum); show_mlnx_ext_port_info(&portid, data2, portnum); } if (port_op != QUERY || changed) { /* * If we aren't setting the LID and the LID is the default, * the SMA command will fail due to an invalid LID. * Set it to something unlikely but valid. */ physstate = mad_get_field(data, 0, IB_PORT_PHYS_STATE_F); val = mad_get_field(data, 0, IB_PORT_LID_F); if (!port_args[LID].set && (!val || val == 0xFFFF)) mad_set_field(data, 0, IB_PORT_LID_F, 0x1234); val = mad_get_field(data, 0, IB_PORT_SMLID_F); if (!port_args[SMLID].set && (!val || val == 0xFFFF)) mad_set_field(data, 0, IB_PORT_SMLID_F, 0x1234); mad_set_field(data, 0, IB_PORT_STATE_F, 0); /* NOP */ mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 0); /* NOP */ switch (port_op) { case ON: /* Enable only if state is Disable */ if(physstate != 3) { printf("Port is already in enable state\n"); goto close_port; } case ENABLE: case RESET: /* Polling */ mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2); break; case OFF: case DISABLE: printf("Disable may be irreversible\n"); mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 3); break; case DOWN: mad_set_field(data, 0, IB_PORT_STATE_F, 1); break; case ARM: mad_set_field(data, 0, IB_PORT_STATE_F, 3); break; case ACTIVE: mad_set_field(data, 0, IB_PORT_STATE_F, 4); break; } /* always set enabled speeds/width - defaults to NOP */ mad_set_field(data, 0, IB_PORT_LINK_SPEED_ENABLED_F, speed); mad_set_field(data, 0, IB_PORT_LINK_SPEED_EXT_ENABLED_F, espeed); mad_set_field(data, 0, IB_PORT_LINK_WIDTH_ENABLED_F, width); if (port_args[VLS].set) mad_set_field(data, 0, IB_PORT_OPER_VLS_F, vls); if (port_args[MTU].set) mad_set_field(data, 0, IB_PORT_NEIGHBOR_MTU_F, mtu); if (port_args[LID].set) mad_set_field(data, 0, IB_PORT_LID_F, lid); if (port_args[SMLID].set) mad_set_field(data, 0, IB_PORT_SMLID_F, smlid); if (port_args[LMC].set) mad_set_field(data, 0, IB_PORT_LMC_F, lmc); if (port_args[FDR10SPEED].set) { mad_set_field(data2, 0, IB_MLNX_EXT_PORT_STATE_CHG_ENABLE_F, FDR10); mad_set_field(data2, 0, IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F, fdr10); set_mlnx_ext_port_info(&portid, data2, portnum); } if (port_args[MKEY].set) mad_set_field64(data, 0, IB_PORT_MKEY_F, mkey); if (port_args[MKEYLEASE].set) mad_set_field(data, 0, IB_PORT_MKEY_LEASE_F, mkeylease); if (port_args[MKEYPROT].set) mad_set_field(data, 0, IB_PORT_MKEY_PROT_BITS_F, mkeyprot); set_port_info(&portid, data, portnum, espeed_cap, is_switch); } else if (is_switch && portnum) { /* Now, make sure PortState is Active */ /* Or is PortPhysicalState LinkUp sufficient ? */ mad_decode_field(data, IB_PORT_STATE_F, &state); mad_decode_field(data, IB_PORT_PHYS_STATE_F, &physstate); if (state == 4) { /* Active */ mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F, &lwe); mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F, &lws); mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F, &lwa); mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F, &lss); mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F, &lsa); mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, &lse); mad_decode_field(data2, IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F, &fdr10s); mad_decode_field(data2, IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F, &fdr10e); mad_decode_field(data2, IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F, &fdr10a); if (espeed_cap) { mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_SUPPORTED_F, &lses); mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ACTIVE_F, &lsea); mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ENABLED_F, &lsee); } /* Setup portid for peer port */ memcpy(&peerportid, &portid, sizeof(peerportid)); if (portid.lid == 0) { peerportid.drpath.cnt++; if (peerportid.drpath.cnt == IB_SUBNET_PATH_HOPS_MAX) { IBEXIT("Too many hops"); } } else { peerportid.drpath.cnt = 1; /* Set DrSLID to local lid */ if (resolve_self(ibd_ca, ibd_ca_port, &selfportid, &selfport, 0) < 0) IBEXIT("could not resolve self"); peerportid.drpath.drslid = (uint16_t) selfportid.lid; peerportid.drpath.drdlid = 0xffff; } peerportid.drpath.p[peerportid.drpath.cnt] = (uint8_t) portnum; /* Get peer port NodeInfo to obtain peer port number */ is_peer_switch = get_node_info(&peerportid, data); rem_vendorid = (uint32_t) mad_get_field(data, 0, IB_NODE_VENDORID_F); rem_devid = (uint16_t) mad_get_field(data, 0, IB_NODE_DEVID_F); mad_decode_field(data, IB_NODE_LOCAL_PORT_F, &peerlocalportnum); printf("Peer PortInfo:\n"); /* Get peer port characteristics */ peer_espeed_cap = get_port_info(&peerportid, data, peerlocalportnum, is_peer_switch); if (is_mlnx_ext_port_info_supported(rem_vendorid, rem_devid)) get_mlnx_ext_port_info(&peerportid, data2, peerlocalportnum); show_port_info(&peerportid, data, peerlocalportnum, peer_espeed_cap, is_peer_switch); if (is_mlnx_ext_port_info_supported(rem_vendorid, rem_devid)) show_mlnx_ext_port_info(&peerportid, data2, peerlocalportnum); mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F, &peerlwe); mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F, &peerlws); mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F, &peerlwa); mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F, &peerlss); mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F, &peerlsa); mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, &peerlse); mad_decode_field(data2, IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F, &peerfdr10s); mad_decode_field(data2, IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F, &peerfdr10e); mad_decode_field(data2, IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F, &peerfdr10a); if (peer_espeed_cap) { mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_SUPPORTED_F, &peerlses); mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ACTIVE_F, &peerlsea); mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ENABLED_F, &peerlsee); } /* Now validate peer port characteristics */ /* Examine Link Width */ width = get_link_width(lwe, lws); peerwidth = get_link_width(peerlwe, peerlws); validate_width(width, peerwidth, lwa); /* Examine Link Speeds */ speed = get_link_speed(lse, lss); peerspeed = get_link_speed(peerlse, peerlss); validate_speed(speed, peerspeed, lsa); if (espeed_cap && peer_espeed_cap) { espeed = get_link_speed_ext(lsee, lses); peerespeed = get_link_speed_ext(peerlsee, peerlses); validate_extended_speed(espeed, peerespeed, lsea); } else { if (fdr10e & FDR10 && peerfdr10e & FDR10) { if (!(fdr10a & FDR10)) IBWARN("Peer ports operating at active speed %d rather than FDR10", lsa); } } } } close_port: mad_rpc_close_port(srcport); exit(0); }
int main(int argc, char **argv) { int mgmt_classes[1] = { IB_SA_CLASS }; int ping_class = IB_VENDOR_OPENIB_PING_CLASS; uint64_t rtt; char *err; const struct ibdiag_opt opts[] = { {"count", 'c', 1, "<num>", "stop after count packets"}, {"flood", 'f', 0, NULL, "flood destination"}, {"oui", 'o', 1, NULL, "use specified OUI number"}, {"Server", 'S', 0, NULL, "start in server mode"}, {0} }; char usage_args[] = "<dest lid|guid>"; ibdiag_process_opts(argc, argv, NULL, "DKy", opts, process_opt, usage_args, NULL); argc -= optind; argv += optind; if (!argc && !server) ibdiag_show_usage(); srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 1); if (!srcport) IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port); if (server) { if (mad_register_server_via(ping_class, 0, 0, oui, srcport) < 0) IBEXIT("can't serve class %d on this port", ping_class); get_host_and_domain(host_and_domain, sizeof host_and_domain); if ((err = ibping_serv())) IBEXIT("ibping to %s: %s", portid2str(&portid), err); exit(0); } if (mad_register_client_via(ping_class, 0, srcport) < 0) IBEXIT("can't register ping class %d on this port", ping_class); if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0], ibd_dest_type, ibd_sm_id, srcport) < 0) IBEXIT("can't resolve destination port %s", argv[0]); signal(SIGINT, report); signal(SIGTERM, report); start = cl_get_time_stamp(); while (count-- > 0) { ntrans++; if ((rtt = ibping(&portid, flood)) == ~0ull) { DEBUG("ibping to %s failed", portid2str(&portid)); lost++; } else { if (rtt < minrtt) minrtt = rtt; if (rtt > maxrtt) maxrtt = rtt; total_rtt += rtt; replied++; } if (!flood) sleep(1); } report(0); mad_rpc_close_port(srcport); exit(-1); }
int main(int argc, char **argv) { struct ibnd_config config = { 0 }; int resolved = -1; ib_portid_t portid = { 0 }; ib_portid_t self_portid = { 0 }; int rc = 0; ibnd_fabric_t *fabric = NULL; ib_gid_t self_gid; int port = 0; int mgmt_classes[4] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS, IB_PERFORMANCE_CLASS }; const struct ibdiag_opt opts[] = { {"suppress", 's', 1, "<err1,err2,...>", "suppress errors listed"}, {"suppress-common", 'c', 0, NULL, "suppress some of the common counters"}, {"node-name-map", 1, 1, "<file>", "node name map file"}, {"port-guid", 'G', 1, "<port_guid>", "report the node containing the port specified by <port_guid>"}, {"", 'S', 1, "<port_guid>", "Same as \"-G\" for backward compatibility"}, {"Direct", 'D', 1, "<dr_path>", "report the node containing the port specified by <dr_path>"}, {"skip-sl", 10, 0, NULL,"don't obtain SL to all destinations"}, {"report-port", 'r', 0, NULL, "report port link information"}, {"threshold-file", 8, 1, NULL, "specify an alternate threshold file, default: " DEF_THRES_FILE}, {"GNDN", 'R', 0, NULL, "(This option is obsolete and does nothing)"}, {"data", 2, 0, NULL, "include data counters for ports with errors"}, {"switch", 3, 0, NULL, "print data for switches only"}, {"ca", 4, 0, NULL, "print data for CA's only"}, {"router", 5, 0, NULL, "print data for routers only"}, {"details", 6, 0, NULL, "include transmit discard details"}, {"counters", 9, 0, NULL, "print data counters only"}, {"clear-errors", 'k', 0, NULL, "Clear error counters after read"}, {"clear-counts", 'K', 0, NULL, "Clear data counters after read"}, {"load-cache", 7, 1, "<file>", "filename of ibnetdiscover cache to load"}, {"outstanding_smps", 'o', 1, NULL, "specify the number of outstanding SMP's which should be " "issued during the scan"}, {0} }; char usage_args[] = ""; memset(suppressed_fields, 0, sizeof suppressed_fields); ibdiag_process_opts(argc, argv, &config, "cDGKLnRrSs", opts, process_opt, usage_args, NULL); argc -= optind; argv += optind; if (!node_type_to_print) node_type_to_print = PRINT_ALL; ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 4); if (!ibmad_port) IBEXIT("Failed to open port; %s:%d\n", ibd_ca, ibd_ca_port); smp_mkey_set(ibmad_port, ibd_mkey); if (ibd_timeout) { mad_rpc_set_timeout(ibmad_port, ibd_timeout); config.timeout_ms = ibd_timeout; } config.flags = ibd_ibnetdisc_flags; config.mkey = ibd_mkey; node_name_map = open_node_name_map(node_name_map_file); if (dr_path && load_cache_file) { fprintf(stderr, "Cannot specify cache and direct route path\n"); exit(-1); } if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, &self_gid.raw) < 0) { IBEXIT("can't resolve self port %s", argv[0]); goto close_port; } /* limit the scan the fabric around the target */ if (dr_path) { if ((resolved = resolve_portid_str(ibd_ca, ibd_ca_port, &portid, dr_path, IB_DEST_DRPATH, NULL, ibmad_port)) < 0) IBWARN("Failed to resolve %s; attempting full scan", dr_path); } else if (port_guid_str) { if ((resolved = resolve_portid_str(ibd_ca, ibd_ca_port, &portid, port_guid_str, IB_DEST_GUID, ibd_sm_id, ibmad_port)) < 0) IBWARN("Failed to resolve %s; attempting full scan", port_guid_str); if(obtain_sl) lid2sl_table[portid.lid] = portid.sl; } if (load_cache_file) { if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) { fprintf(stderr, "loading cached fabric failed\n"); exit(-1); } } else { if (resolved >= 0) { if (!config.max_hops) config.max_hops = 1; if (!(fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port, &portid, &config))) IBWARN("Single node discover failed;" " attempting full scan"); } if (!fabric && !(fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port, NULL, &config))) { fprintf(stderr, "discover failed\n"); rc = -1; goto close_port; } } set_thresholds(threshold_file); if (port_guid_str) { ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid); if (port) print_node(port->node, NULL); else fprintf(stderr, "Failed to find node: %s\n", port_guid_str); } else if (dr_path) { ibnd_port_t *port = ibnd_find_port_dr(fabric, dr_path); uint8_t ni[IB_SMP_DATA_SIZE] = { 0 }; if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0, ibd_timeout, ibmad_port)) { rc = -1; goto destroy_fabric; } mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid)); port = ibnd_find_port_guid(fabric, port_guid); if (port) { if(obtain_sl) if(path_record_query(self_gid,port->guid)) goto destroy_fabric; print_node(port->node, NULL); } else fprintf(stderr, "Failed to find node: %s\n", dr_path); } else { if(obtain_sl) if(path_record_query(self_gid,0)) goto destroy_fabric; ibnd_iter_nodes(fabric, print_node, NULL); } rc = print_summary(); if (rc) rc = 1; destroy_fabric: ibnd_destroy_fabric(fabric); close_port: mad_rpc_close_port(ibmad_port); close_node_name_map(node_name_map); exit(rc); }
static int process_opt(int ch, char *optarg) { char *endp; long val; switch (ch) { case 'z': read_ibdiag_config(optarg); break; case 'h': ibdiag_show_usage(); break; case 'V': fprintf(stderr, "%s %s\n", prog_name, get_build_version()); exit(0); case 'e': madrpc_show_errors(1); break; case 'v': ibverbose++; break; case 'd': ibdebug++; madrpc_show_errors(1); umad_debug(ibdebug - 1); break; case 'C': ibd_ca = optarg; break; case 'P': ibd_ca_port = strtoul(optarg, 0, 0); break; case 'D': ibd_dest_type = IB_DEST_DRPATH; break; case 'L': ibd_dest_type = IB_DEST_LID; break; case 'G': ibd_dest_type = IB_DEST_GUID; break; case 't': errno = 0; val = strtol(optarg, &endp, 0); if (errno || (endp && *endp != '\0') || val <= 0 || val > INT_MAX) IBERROR("Invalid timeout \"%s\". Timeout requires a " "positive integer value < %d.", optarg, INT_MAX); else { madrpc_set_timeout((int)val); ibd_timeout = (int)val; } break; case 's': /* srcport is not required when resolving via IB_DEST_LID */ if (resolve_portid_str(ibd_ca, ibd_ca_port, &sm_portid, optarg, IB_DEST_LID, 0, NULL) < 0) IBERROR("cannot resolve SM destination port %s", optarg); ibd_sm_id = &sm_portid; break; case 'K': show_keys = 1; break; case 'y': errno = 0; ibd_mkey = strtoull(optarg, &endp, 0); if (errno || *endp != '\0') { errno = 0; ibd_mkey = strtoull(getpass("M_Key: "), &endp, 0); if (errno || *endp != '\0') { IBERROR("Bad M_Key"); } } break; default: return -1; } return 0; }