1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved. 3219820Sjeff * 4219820Sjeff * This software is available to you under a choice of one of two 5219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 6219820Sjeff * General Public License (GPL) Version 2, available from the file 7219820Sjeff * COPYING in the main directory of this source tree, or the 8219820Sjeff * OpenIB.org BSD license below: 9219820Sjeff * 10219820Sjeff * Redistribution and use in source and binary forms, with or 11219820Sjeff * without modification, are permitted provided that the following 12219820Sjeff * conditions are met: 13219820Sjeff * 14219820Sjeff * - Redistributions of source code must retain the above 15219820Sjeff * copyright notice, this list of conditions and the following 16219820Sjeff * disclaimer. 17219820Sjeff * 18219820Sjeff * - Redistributions in binary form must reproduce the above 19219820Sjeff * copyright notice, this list of conditions and the following 20219820Sjeff * disclaimer in the documentation and/or other materials 21219820Sjeff * provided with the distribution. 22219820Sjeff * 23219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30219820Sjeff * SOFTWARE. 31219820Sjeff * 32219820Sjeff */ 33219820Sjeff 34219820Sjeff#if HAVE_CONFIG_H 35219820Sjeff# include <config.h> 36219820Sjeff#endif /* HAVE_CONFIG_H */ 37219820Sjeff 38219820Sjeff#include <stdio.h> 39219820Sjeff#include <stdlib.h> 40219820Sjeff#include <unistd.h> 41219820Sjeff#include <stdarg.h> 42219820Sjeff#include <time.h> 43219820Sjeff#include <string.h> 44219820Sjeff#include <inttypes.h> 45219820Sjeff#include <getopt.h> 46219820Sjeff#include <netinet/in.h> 47219820Sjeff#include <ctype.h> 48219820Sjeff 49219820Sjeff#include <infiniband/common.h> 50219820Sjeff#include <infiniband/umad.h> 51219820Sjeff#include <infiniband/mad.h> 52219820Sjeff#include <infiniband/complib/cl_nodenamemap.h> 53219820Sjeff 54219820Sjeff#include "ibdiag_common.h" 55219820Sjeff 56219820Sjeffstatic int dest_type = IB_DEST_LID; 57219820Sjeffstatic int brief; 58219820Sjeffstatic int verbose; 59219820Sjeffstatic int dump_all; 60219820Sjeff 61219820Sjeffchar *argv0 = "ibroute"; 62219820Sjeff 63219820Sjeff/*******************************************/ 64219820Sjeff 65219820Sjeffchar * 66219820Sjeffcheck_switch(ib_portid_t *portid, int *nports, uint64_t *guid, 67219820Sjeff uint8_t *sw, char *nd) 68219820Sjeff{ 69219820Sjeff uint8_t ni[IB_SMP_DATA_SIZE] = {0}; 70219820Sjeff int type; 71219820Sjeff 72219820Sjeff DEBUG("checking node type"); 73219820Sjeff if (!smp_query(ni, portid, IB_ATTR_NODE_INFO, 0, 0)) { 74219820Sjeff xdump(stderr, "nodeinfo\n", ni, sizeof ni); 75219820Sjeff return "node info failed: valid addr?"; 76219820Sjeff } 77219820Sjeff 78219820Sjeff if (!smp_query(nd, portid, IB_ATTR_NODE_DESC, 0, 0)) 79219820Sjeff return "node desc failed"; 80219820Sjeff 81219820Sjeff mad_decode_field(ni, IB_NODE_TYPE_F, &type); 82219820Sjeff if (type != IB_NODE_SWITCH) 83219820Sjeff return "not a switch"; 84219820Sjeff 85219820Sjeff DEBUG("Gathering information about switch"); 86219820Sjeff mad_decode_field(ni, IB_NODE_NPORTS_F, nports); 87219820Sjeff mad_decode_field(ni, IB_NODE_GUID_F, guid); 88219820Sjeff 89219820Sjeff if (!smp_query(sw, portid, IB_ATTR_SWITCH_INFO, 0, 0)) 90219820Sjeff return "switch info failed: is a switch node?"; 91219820Sjeff 92219820Sjeff return 0; 93219820Sjeff} 94219820Sjeff 95219820Sjeff#define IB_MLIDS_IN_BLOCK (IB_SMP_DATA_SIZE/2) 96219820Sjeff 97219820Sjeffint 98219820Sjeffdump_mlid(char *str, int strlen, int mlid, int nports, 99219820Sjeff uint16_t mft[16][IB_MLIDS_IN_BLOCK]) 100219820Sjeff{ 101219820Sjeff uint16_t mask; 102219820Sjeff int i, chunk, bit; 103219820Sjeff int nonzero = 0; 104219820Sjeff 105219820Sjeff if (brief) { 106219820Sjeff int n = 0, chunks = ALIGN(nports + 1, 16) / 16; 107219820Sjeff for (i = 0; i < chunks; i++) { 108219820Sjeff mask = ntohs(mft[i][mlid%IB_MLIDS_IN_BLOCK]); 109219820Sjeff if (mask) 110219820Sjeff nonzero++; 111219820Sjeff n += snprintf(str + n, strlen - n, "%04hx", mask); 112219820Sjeff if (n >= strlen) { 113219820Sjeff n = strlen; 114219820Sjeff break; 115219820Sjeff } 116219820Sjeff } 117219820Sjeff if (!nonzero && !dump_all) { 118219820Sjeff str[0] = 0; 119219820Sjeff return 0; 120219820Sjeff } 121219820Sjeff return n; 122219820Sjeff } 123219820Sjeff for (i = 0; i <= nports; i++) { 124219820Sjeff chunk = i / 16; 125219820Sjeff bit = i % 16; 126219820Sjeff 127219820Sjeff mask = ntohs(mft[chunk][mlid%IB_MLIDS_IN_BLOCK]); 128219820Sjeff if (mask) 129219820Sjeff nonzero++; 130219820Sjeff str[i*2] = (mask & (1 << bit)) ? 'x' : ' '; 131219820Sjeff str[i*2+1] = ' '; 132219820Sjeff } 133219820Sjeff if (!nonzero && !dump_all) { 134219820Sjeff str[0] = 0; 135219820Sjeff return 0; 136219820Sjeff } 137219820Sjeff str[i*2] = 0; 138219820Sjeff return i * 2; 139219820Sjeff} 140219820Sjeff 141219820Sjeffuint16_t mft[16][IB_MLIDS_IN_BLOCK]; 142219820Sjeff 143219820Sjeffchar * 144219820Sjeffdump_multicast_tables(ib_portid_t *portid, int startlid, int endlid) 145219820Sjeff{ 146219820Sjeff char nd[IB_SMP_DATA_SIZE] = {0}; 147219820Sjeff uint8_t sw[IB_SMP_DATA_SIZE] = {0}; 148219820Sjeff char str[512]; 149219820Sjeff char *s; 150219820Sjeff uint64_t nodeguid; 151219820Sjeff uint32_t mod; 152219820Sjeff int block, i, j, e, nports, cap, chunks; 153219820Sjeff int n = 0, startblock, lastblock; 154219820Sjeff 155219820Sjeff if ((s = check_switch(portid, &nports, &nodeguid, sw, nd))) 156219820Sjeff return s; 157219820Sjeff 158219820Sjeff mad_decode_field(sw, IB_SW_MCAST_FDB_CAP_F, &cap); 159219820Sjeff 160219820Sjeff if (!endlid || endlid > IB_MIN_MCAST_LID + cap - 1) 161219820Sjeff endlid = IB_MIN_MCAST_LID + cap - 1; 162219820Sjeff 163219820Sjeff if (!startlid) 164219820Sjeff startlid = IB_MIN_MCAST_LID; 165219820Sjeff 166219820Sjeff if (startlid < IB_MIN_MCAST_LID) { 167219820Sjeff IBWARN("illegal start mlid %x, set to %x", startlid, IB_MIN_MCAST_LID); 168219820Sjeff startlid = IB_MIN_MCAST_LID; 169219820Sjeff } 170219820Sjeff 171219820Sjeff if (endlid > IB_MAX_MCAST_LID) { 172219820Sjeff IBWARN("illegal end mlid %x, truncate to %x", endlid, IB_MAX_MCAST_LID); 173219820Sjeff endlid = IB_MAX_MCAST_LID; 174219820Sjeff } 175219820Sjeff 176219820Sjeff printf("Multicast mlids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64 " (%s):\n", 177219820Sjeff startlid, endlid, portid2str(portid), nodeguid, clean_nodedesc(nd)); 178219820Sjeff 179219820Sjeff if (brief) 180219820Sjeff printf(" MLid Port Mask\n"); 181219820Sjeff else { 182219820Sjeff if (nports > 9) { 183219820Sjeff for (i = 0, s = str; i <= nports; i++) { 184219820Sjeff *s++ = (i%10) ? ' ' : '0' + i/10; 185219820Sjeff *s++ = ' '; 186219820Sjeff } 187219820Sjeff *s = 0; 188219820Sjeff printf(" %s\n", str); 189219820Sjeff } 190219820Sjeff for (i = 0, s = str; i <= nports; i++) 191219820Sjeff s += sprintf(s, "%d ", i%10); 192219820Sjeff printf(" Ports: %s\n", str); 193219820Sjeff printf(" MLid\n"); 194219820Sjeff } 195219820Sjeff if (verbose) 196219820Sjeff printf("Switch muticast mlids capability is 0x%d\n", cap); 197219820Sjeff 198219820Sjeff chunks = ALIGN(nports + 1, 16) / 16; 199219820Sjeff 200219820Sjeff startblock = startlid / IB_MLIDS_IN_BLOCK; 201219820Sjeff lastblock = endlid / IB_MLIDS_IN_BLOCK; 202219820Sjeff for (block = startblock; block <= lastblock; block++) { 203219820Sjeff for (j = 0; j < chunks; j++) { 204219820Sjeff mod = (block - IB_MIN_MCAST_LID/IB_MLIDS_IN_BLOCK) | (j << 28); 205219820Sjeff 206219820Sjeff DEBUG("reading block %x chunk %d mod %x", block, j, mod); 207219820Sjeff if (!smp_query(mft + j, portid, IB_ATTR_MULTICASTFORWTBL, mod, 0)) 208219820Sjeff return "multicast forwarding table get failed"; 209219820Sjeff } 210219820Sjeff 211219820Sjeff i = block * IB_MLIDS_IN_BLOCK; 212219820Sjeff e = i + IB_MLIDS_IN_BLOCK; 213219820Sjeff if (i < startlid) 214219820Sjeff i = startlid; 215219820Sjeff if (e > endlid + 1) 216219820Sjeff e = endlid + 1; 217219820Sjeff 218219820Sjeff for (; i < e; i++) { 219219820Sjeff if (dump_mlid(str, sizeof str, i, nports, mft) == 0) 220219820Sjeff continue; 221219820Sjeff printf("0x%04x %s\n", i, str); 222219820Sjeff n++; 223219820Sjeff } 224219820Sjeff } 225219820Sjeff 226219820Sjeff printf("%d %smlids dumped \n", n, dump_all ? "" : "valid "); 227219820Sjeff return 0; 228219820Sjeff} 229219820Sjeff 230219820Sjeffint 231219820Sjeffdump_lid(char *str, int strlen, int lid, int valid) 232219820Sjeff{ 233219820Sjeff char nd[IB_SMP_DATA_SIZE] = {0}; 234219820Sjeff uint8_t ni[IB_SMP_DATA_SIZE] = {0}; 235219820Sjeff uint8_t pi[IB_SMP_DATA_SIZE] = {0}; 236219820Sjeff ib_portid_t lidport = {0}; 237219820Sjeff static int last_port_lid, base_port_lid; 238219820Sjeff char ntype[50], sguid[30], desc[64]; 239219820Sjeff static uint64_t portguid; 240219820Sjeff int baselid, lmc, type; 241219820Sjeff 242219820Sjeff if (brief) { 243219820Sjeff str[0] = 0; 244219820Sjeff return 0; 245219820Sjeff } 246219820Sjeff 247219820Sjeff if (lid <= last_port_lid) { 248219820Sjeff if (!valid) 249219820Sjeff return snprintf(str, strlen, ": (path #%d - illegal port)", 250219820Sjeff lid - base_port_lid); 251219820Sjeff else if (!portguid) 252219820Sjeff return snprintf(str, strlen, 253219820Sjeff ": (path #%d out of %d)", 254219820Sjeff lid - base_port_lid + 1, 255219820Sjeff last_port_lid - base_port_lid + 1); 256219820Sjeff else { 257219820Sjeff return snprintf(str, strlen, 258219820Sjeff ": (path #%d out of %d: portguid %s)", 259219820Sjeff lid - base_port_lid + 1, 260219820Sjeff last_port_lid - base_port_lid + 1, 261219820Sjeff mad_dump_val(IB_NODE_PORT_GUID_F, sguid, sizeof sguid, &portguid)); 262219820Sjeff } 263219820Sjeff } 264219820Sjeff 265219820Sjeff if (!valid) 266219820Sjeff return snprintf(str, strlen, ": (illegal port)"); 267219820Sjeff 268219820Sjeff portguid = 0; 269219820Sjeff lidport.lid = lid; 270219820Sjeff 271219820Sjeff if (!smp_query(nd, &lidport, IB_ATTR_NODE_DESC, 0, 100) || 272219820Sjeff !smp_query(pi, &lidport, IB_ATTR_PORT_INFO, 0, 100) || 273219820Sjeff !smp_query(ni, &lidport, IB_ATTR_NODE_INFO, 0, 100)) 274219820Sjeff return snprintf(str, strlen, ": (unknown node and type)"); 275219820Sjeff 276219820Sjeff mad_decode_field(ni, IB_NODE_PORT_GUID_F, &portguid); 277219820Sjeff mad_decode_field(ni, IB_NODE_TYPE_F, &type); 278219820Sjeff 279219820Sjeff mad_decode_field(pi, IB_PORT_LID_F, &baselid); 280219820Sjeff mad_decode_field(pi, IB_PORT_LMC_F, &lmc); 281219820Sjeff 282219820Sjeff if (lmc > 0) { 283219820Sjeff base_port_lid = baselid; 284219820Sjeff last_port_lid = baselid + (1 << lmc) - 1; 285219820Sjeff } 286219820Sjeff 287219820Sjeff return snprintf(str, strlen, ": (%s portguid %s: %s)", 288219820Sjeff mad_dump_val(IB_NODE_TYPE_F, ntype, sizeof ntype, &type), 289219820Sjeff mad_dump_val(IB_NODE_PORT_GUID_F, sguid, sizeof sguid, &portguid), 290219820Sjeff mad_dump_val(IB_NODE_DESC_F, desc, sizeof desc, clean_nodedesc(nd))); 291219820Sjeff} 292219820Sjeff 293219820Sjeffchar * 294219820Sjeffdump_unicast_tables(ib_portid_t *portid, int startlid, int endlid) 295219820Sjeff{ 296219820Sjeff char lft[IB_SMP_DATA_SIZE]; 297219820Sjeff char nd[IB_SMP_DATA_SIZE]; 298219820Sjeff uint8_t sw[IB_SMP_DATA_SIZE]; 299219820Sjeff char str[200], *s; 300219820Sjeff uint64_t nodeguid; 301219820Sjeff int block, i, e, nports, top; 302219820Sjeff int n = 0, startblock, endblock; 303219820Sjeff 304219820Sjeff if ((s = check_switch(portid, &nports, &nodeguid, sw, nd))) 305219820Sjeff return s; 306219820Sjeff 307219820Sjeff mad_decode_field(sw, IB_SW_LINEAR_FDB_TOP_F, &top); 308219820Sjeff 309219820Sjeff if (!endlid || endlid > top) 310219820Sjeff endlid = top; 311219820Sjeff 312219820Sjeff if (endlid > IB_MAX_UCAST_LID) { 313219820Sjeff IBWARN("ilegal lft top %d, truncate to %d", endlid, IB_MAX_UCAST_LID); 314219820Sjeff endlid = IB_MAX_UCAST_LID; 315219820Sjeff } 316219820Sjeff 317219820Sjeff printf("Unicast lids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64 " (%s):\n", 318219820Sjeff startlid, endlid, portid2str(portid), nodeguid, clean_nodedesc(nd)); 319219820Sjeff 320219820Sjeff DEBUG("Switch top is 0x%x\n", top); 321219820Sjeff 322219820Sjeff printf(" Lid Out Destination\n"); 323219820Sjeff printf(" Port Info \n"); 324219820Sjeff startblock = startlid / IB_SMP_DATA_SIZE; 325219820Sjeff endblock = ALIGN(endlid, IB_SMP_DATA_SIZE) / IB_SMP_DATA_SIZE; 326219820Sjeff for (block = startblock; block <= endblock; block++) { 327219820Sjeff DEBUG("reading block %d", block); 328219820Sjeff if (!smp_query(lft, portid, IB_ATTR_LINEARFORWTBL, block, 0)) 329219820Sjeff return "linear forwarding table get failed"; 330219820Sjeff i = block * IB_SMP_DATA_SIZE; 331219820Sjeff e = i + IB_SMP_DATA_SIZE; 332219820Sjeff if (i < startlid) 333219820Sjeff i = startlid; 334219820Sjeff if (e > endlid + 1) 335219820Sjeff e = endlid + 1; 336219820Sjeff 337219820Sjeff for (;i < e; i++) { 338219820Sjeff unsigned outport = lft[i % IB_SMP_DATA_SIZE]; 339219820Sjeff unsigned valid = (outport <= nports); 340219820Sjeff 341219820Sjeff if (!valid && !dump_all) 342219820Sjeff continue; 343219820Sjeff dump_lid(str, sizeof str, i, valid); 344219820Sjeff printf("0x%04x %03u %s\n", i, outport & 0xff, str); 345219820Sjeff n++; 346219820Sjeff } 347219820Sjeff } 348219820Sjeff 349219820Sjeff printf("%d %slids dumped \n", n, dump_all ? "" : "valid "); 350219820Sjeff return 0; 351219820Sjeff} 352219820Sjeff 353219820Sjeffvoid 354219820Sjeffusage(void) 355219820Sjeff{ 356219820Sjeff char *basename; 357219820Sjeff 358219820Sjeff if (!(basename = strrchr(argv0, '/'))) 359219820Sjeff basename = argv0; 360219820Sjeff else 361219820Sjeff basename++; 362219820Sjeff 363219820Sjeff fprintf(stderr, "Usage: %s [-d(ebug)] -a(ll) -n(o_dests) -v(erbose) -D(irect) -G(uid) -M(ulticast) -s smlid -V(ersion) -C ca_name -P ca_port " 364219820Sjeff "-t(imeout) timeout_ms] [<dest dr_path|lid|guid> [<startlid> [<endlid>]]]\n", 365219820Sjeff basename); 366219820Sjeff fprintf(stderr, "\n\tUnicast examples:\n"); 367219820Sjeff fprintf(stderr, "\t\t%s 4\t# dump all lids with valid out ports of switch with lid 4\n", basename); 368219820Sjeff fprintf(stderr, "\t\t%s -a 4\t# same, but dump all lids, even with invalid out ports\n", basename); 369219820Sjeff fprintf(stderr, "\t\t%s -n 4\t# simple dump format - no destination resolving\n", basename); 370219820Sjeff fprintf(stderr, "\t\t%s 4 10\t# dump lids starting from 10\n", basename); 371219820Sjeff fprintf(stderr, "\t\t%s 4 0x10 0x20\t# dump lid range\n", basename); 372219820Sjeff fprintf(stderr, "\t\t%s -G 0x08f1040023\t# resolve switch by GUID\n", basename); 373219820Sjeff fprintf(stderr, "\t\t%s -D 0,1\t# resolve switch by direct path\n", basename); 374219820Sjeff 375219820Sjeff fprintf(stderr, "\n\tMulticast examples:\n"); 376219820Sjeff fprintf(stderr, "\t\t%s -M 4\t# dump all non empty mlids of switch with lid 4\n", basename); 377219820Sjeff fprintf(stderr, "\t\t%s -M 4 0xc010 0xc020\t# same, but with range\n", basename); 378219820Sjeff fprintf(stderr, "\t\t%s -M -n 4\t# simple dump format\n", basename); 379219820Sjeff exit(-1); 380219820Sjeff} 381219820Sjeff 382219820Sjeffint 383219820Sjeffmain(int argc, char **argv) 384219820Sjeff{ 385219820Sjeff int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS}; 386219820Sjeff ib_portid_t portid = {0}; 387219820Sjeff ib_portid_t *sm_id = 0, sm_portid = {0}; 388219820Sjeff int timeout; 389219820Sjeff int multicast = 0, startlid = 0, endlid = 0; 390219820Sjeff char *err; 391219820Sjeff char *ca = 0; 392219820Sjeff int ca_port = 0; 393219820Sjeff 394219820Sjeff static char const str_opts[] = "C:P:t:s:danvDGMVhu"; 395219820Sjeff static const struct option long_opts[] = { 396219820Sjeff { "C", 1, 0, 'C'}, 397219820Sjeff { "P", 1, 0, 'P'}, 398219820Sjeff { "debug", 0, 0, 'd'}, 399219820Sjeff { "all", 0, 0, 'a'}, 400219820Sjeff { "no_dests", 0, 0, 'n'}, 401219820Sjeff { "verbose", 0, 0, 'v'}, 402219820Sjeff { "Direct", 0, 0, 'D'}, 403219820Sjeff { "Guid", 0, 0, 'G'}, 404219820Sjeff { "Multicast", 0, 0, 'M'}, 405219820Sjeff { "timeout", 1, 0, 't'}, 406219820Sjeff { "s", 1, 0, 's'}, 407219820Sjeff { "Version", 0, 0, 'V'}, 408219820Sjeff { "help", 0, 0, 'h'}, 409219820Sjeff { "usage", 0, 0, 'u'}, 410219820Sjeff { } 411219820Sjeff }; 412219820Sjeff 413219820Sjeff argv0 = argv[0]; 414219820Sjeff 415219820Sjeff while (1) { 416219820Sjeff int ch = getopt_long(argc, argv, str_opts, long_opts, NULL); 417219820Sjeff if ( ch == -1 ) 418219820Sjeff break; 419219820Sjeff switch(ch) { 420219820Sjeff case 'C': 421219820Sjeff ca = optarg; 422219820Sjeff break; 423219820Sjeff case 'P': 424219820Sjeff ca_port = strtoul(optarg, 0, 0); 425219820Sjeff break; 426219820Sjeff case 'a': 427219820Sjeff dump_all++; 428219820Sjeff break; 429219820Sjeff case 'd': 430219820Sjeff ibdebug++; 431219820Sjeff break; 432219820Sjeff case 'D': 433219820Sjeff dest_type = IB_DEST_DRPATH; 434219820Sjeff break; 435219820Sjeff case 'G': 436219820Sjeff dest_type = IB_DEST_GUID; 437219820Sjeff break; 438219820Sjeff case 'M': 439219820Sjeff multicast++; 440219820Sjeff break; 441219820Sjeff case 'n': 442219820Sjeff brief++; 443219820Sjeff break; 444219820Sjeff case 's': 445219820Sjeff if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0) 446219820Sjeff IBERROR("can't resolve SM destination port %s", optarg); 447219820Sjeff sm_id = &sm_portid; 448219820Sjeff break; 449219820Sjeff case 't': 450219820Sjeff timeout = strtoul(optarg, 0, 0); 451219820Sjeff madrpc_set_timeout(timeout); 452219820Sjeff break; 453219820Sjeff case 'v': 454219820Sjeff madrpc_show_errors(1); 455219820Sjeff verbose++; 456219820Sjeff break; 457219820Sjeff case 'V': 458219820Sjeff fprintf(stderr, "%s %s\n", argv0, get_build_version() ); 459219820Sjeff exit(-1); 460219820Sjeff default: 461219820Sjeff usage(); 462219820Sjeff break; 463219820Sjeff } 464219820Sjeff } 465219820Sjeff argc -= optind; 466219820Sjeff argv += optind; 467219820Sjeff 468219820Sjeff if (!argc) 469219820Sjeff usage(); 470219820Sjeff 471219820Sjeff if (argc > 1) 472219820Sjeff startlid = strtoul(argv[1], 0, 0); 473219820Sjeff if (argc > 2) 474219820Sjeff endlid = strtoul(argv[2], 0, 0); 475219820Sjeff 476219820Sjeff madrpc_init(ca, ca_port, mgmt_classes, 3); 477219820Sjeff 478219820Sjeff if (!argc) { 479219820Sjeff if (ib_resolve_self(&portid, 0, 0) < 0) 480219820Sjeff IBERROR("can't resolve self addr"); 481219820Sjeff } else { 482219820Sjeff if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0) 483219820Sjeff IBERROR("can't resolve destination port %s", argv[1]); 484219820Sjeff } 485219820Sjeff 486219820Sjeff if (multicast) 487219820Sjeff err = dump_multicast_tables(&portid, startlid, endlid); 488219820Sjeff else 489219820Sjeff err = dump_unicast_tables(&portid, startlid, endlid); 490219820Sjeff 491219820Sjeff if (err) 492219820Sjeff IBERROR("dump tables: %s", err); 493219820Sjeff 494219820Sjeff exit(0); 495219820Sjeff} 496