Beispiel #1
0
def summary(sched, sbn, node):
    if isinstance(node, rdma.subnet.CA):
        print '%-8s: %s ports %u "%s"' % ("Ca", node.ninf.nodeGUID,
                                          node.ninf.numPorts,
                                          IBA_describe.dstr(node.desc))
    elif isinstance(node, rdma.subnet.Switch):
        zport = node.ports[0]
        pinf = zport.pinf
        for port in node.ports:
            if port.pinf is not None:
                pinf = port.pinf
                break
        if pinf is None:
            path = sbn.get_path_smp(sched, zport)
            pinf = yield sched.SubnGet(IBA.SMPPortInfo, path)
            sbn.get_port_pinf(pinf, path=path, portIdx=0)
        print '%-8s: %s ports %u "%s" base port 0 lid %u lmc %u' % (
            "Switch", node.ninf.nodeGUID, node.ninf.numPorts,
            IBA_describe.dstr(node.desc), zport.LID, pinf.LMC)
    elif isinstance(node, rdma.subnet.Router):
        print '%-8s: %s ports %u "%s"' % ("Router", node.ninf.nodeGUID,
                                          node.ninf.numPorts,
                                          IBA_describe.dstr(node.desc))
    else:
        print '%-8s: %s ports %u "%s"' % (
            "??%u" % (node.ninf.nodeType), node.ninf.nodeGUID,
            node.ninf.numPorts, IBA_describe.dstr(node.desc))
Beispiel #2
0
def summary(sched,sbn,node):
    if isinstance(node,rdma.subnet.CA):
        print '%-8s: %s ports %u "%s"'%(
            "Ca",node.ninf.nodeGUID,node.ninf.numPorts,
            IBA_describe.dstr(node.desc));
    elif isinstance(node,rdma.subnet.Switch):
        zport = node.ports[0];
        pinf = zport.pinf;
        for port in node.ports:
            if port.pinf is not None:
                pinf = port.pinf;
                break;
        if pinf is None:
            path = sbn.get_path_smp(sched,zport);
            pinf = yield sched.SubnGet(IBA.SMPPortInfo,path);
            sbn.get_port_pinf(pinf,path=path,portIdx=0);
        print '%-8s: %s ports %u "%s" base port 0 lid %u lmc %u'%(
            "Switch",node.ninf.nodeGUID,node.ninf.numPorts,
            IBA_describe.dstr(node.desc),
            zport.LID,pinf.LMC);
    elif isinstance(node,rdma.subnet.Router):
        print '%-8s: %s ports %u "%s"'%(
            "Router",node.ninf.nodeGUID,node.ninf.numPorts,
            IBA_describe.dstr(node.desc));
    else:
        print '%-8s: %s ports %u "%s"'%(
            "??%u"%(node.ninf.nodeType),node.ninf.nodeGUID,node.ninf.numPorts,
            IBA_describe.dstr(node.desc));
Beispiel #3
0
def print_header(ninf,pinf,desc,portIdx,failed,kind):
    if lib.args.verbosity >= 1 or failed or warnings:
        if desc:
            desc = " (%s) "%(IBA_describe.dstr(desc));
        else:
            desc = ' ';
        if kind & KIND_PORT:
            print "Port check lid %u%sport %u:"%(pinf.LID,desc,portIdx),
        if kind & KIND_PERF:
            if portIdx == 0xFF:
                print "Error check lid %u%sall ports:"%(pinf.LID,desc),
            else:
                print "Error check lid %u%sport %u:"%(pinf.LID,desc,portIdx),
        if kind & KIND_CLEAR:
            if portIdx == 0xFF:
                print "Clear counters lid %u%sall ports:"%(pinf.LID,desc),
            else:
                print "Clear counters lid %u%sport %u:"%(pinf.LID,desc,portIdx),
        if kind & KIND_NODE:
            if ninf.nodeType == IBA.NODE_SWITCH:
                print "# Checking %s: nodeguid %s lid %s"%(
                    IBA_describe.node_type(ninf.nodeType),
                    ninf.nodeGUID,pinf.LID);
            else:
                print "# Checking %s: nodeguid %s lid %s port %u"%(
                    IBA_describe.node_type(ninf.nodeType),
                    ninf.nodeGUID,pinf.LID,portIdx);
            print "Node check lid %u:"%(pinf.LID),
        if failed is not None:
            print (red("FAILED") if failed else
                   blue("WARNING") if warnings else
                   green("OK"));
    for I in warnings:
        print blue("#warn: %s"%(I));
    return not (failed or warnings);
Beispiel #4
0
 def show_ca(dev):
     print "CA %r"%(dev.name);
     print "\tCA type: %s"%(dev.hca_type);
     print "\tNumber of ports: %s"%(len(dev.end_ports));
     print "\tFirmware version: %s"%(IBA_describe.dstr(dev.fw_ver));
     print "\tHardware version: %s"%(IBA_describe.dstr(dev.hw_ver));
     print "\tNode GUID: %s"%(dev.node_guid);
     print "\tSystem image GUID: %s"%(dev.sys_image_guid);
Beispiel #5
0
 def step(out_port, nport):
     nport_ep = nport.to_end_port()
     print "[%u] -> %s port %s[%u] lid %u/%u %s" % (
         out_port.port_id,
         IBA_describe.node_type(
             nport.parent.ninf.nodeType), nport_ep.portGUID,
         nport.port_id, nport_ep.LID, 16 - nport_ep.pinf.LMC,
         IBA_describe.dstr(nport.parent.desc, quotes=True))
Beispiel #6
0
 def show_ca(dev):
     print "CA %r" % (dev.name)
     print "\tCA type: %s" % (dev.hca_type)
     print "\tNumber of ports: %s" % (len(dev.end_ports))
     print "\tFirmware version: %s" % (IBA_describe.dstr(dev.fw_ver))
     print "\tHardware version: %s" % (IBA_describe.dstr(dev.hw_ver))
     print "\tNode GUID: %s" % (dev.node_guid)
     print "\tSystem image GUID: %s" % (dev.sys_image_guid)
Beispiel #7
0
 def print_rate(kv):
     portGUID, v = kv
     cur, ref = v
     link = cur[2]
     return "%s[%u] <=> %s[%u]: %s %sx  %s %sx" % (
         link[0][0], link[0][1], link[1][0], link[1][1],
         IBA_describe.link_speed(cur[0]), IBA_describe.link_width(cur[1]),
         IBA_describe.link_speed(ref[0]), IBA_describe.link_width(ref[1]))
Beispiel #8
0
 def show_port(port,offset="\t\t"):
     print "%sState: %s"%(offset,IBA_describe.link_state(port.state));
     print "%sPhysical state: %s"%(offset,IBA_describe.phys_link_state(port.phys_state));
     print "%sRate: %r"%(offset,port.rate);
     print "%sBase lid: %r"%(offset,port.lid);
     print "%sLMC: %r"%(offset,port.lmc);
     print "%sSM lid: %r"%(offset,port.sm_lid);
     print "%sCapability mask: 0x%08x"%(offset,port.cap_mask);
     print "%sPort GUID: %s"%(offset,port.port_guid);
Beispiel #9
0
 def show_port(port,offset="\t\t"):
     print "%sState: %s"%(offset,IBA_describe.link_state(port.state));
     print "%sPhysical state: %s"%(offset,IBA_describe.phys_link_state(port.phys_state));
     print "%sRate: %r"%(offset,port.rate);
     print "%sBase lid: %r"%(offset,port.lid);
     print "%sLMC: %r"%(offset,port.lmc);
     print "%sSM lid: %r"%(offset,port.sm_lid);
     print "%sCapability mask: 0x%08x"%(offset,port.cap_mask);
     print "%sPort GUID: %s"%(offset,port.port_guid);
Beispiel #10
0
 def step(out_port,nport):
     nport_ep = nport.to_end_port();
     print "[%u] -> %s port %s[%u] lid %u/%u %s"%(
         out_port.port_id,
         IBA_describe.node_type(nport.parent.ninf.nodeType),
         nport_ep.portGUID,
         nport.port_id,
         nport_ep.LID,16 - nport_ep.pinf.LMC,
         IBA_describe.dstr(nport.parent.desc,quotes=True));
 def print_rate(kv):
     portGUID,v = kv;
     cur,ref = v;
     link = cur[2];
     return "%s[%u] <=> %s[%u]: %s %sx  %s %sx"%(
         link[0][0],link[0][1],
         link[1][0],link[1][1],
         IBA_describe.link_speed(cur[0]),
         IBA_describe.link_width(cur[1]),
         IBA_describe.link_speed(ref[0]),
         IBA_describe.link_width(ref[1]));
Beispiel #12
0
def display_LFDB(switch,sbn,path,all):
    max_port = switch.ninf.numPorts;
    print "Unicast lids [%u-%u] of switch %s %r"%(0,len(switch.lfdb)-1,
                                                  path,switch.desc);
    print "  Lid  Out   Destination";
    print "       Port     Info";
    top_lid = len(sbn.lids);
    count = 0
    for lid,oport in enumerate(switch.lfdb):
        desc = '';
        if oport <= max_port:
            if lid < top_lid:
                port = sbn.lids[lid];
                if port is not None and port.parent is not None:
                    desc = "(%s portguid %s %r)"%(
                        IBA_describe.node_type(port.parent.ninf.nodeType),
                        port.portGUID,port.parent.desc);
        else:
            if not all:
                continue;
            if lid == IBA.LID_RESERVED:
                desc = "(reserved LID - illegal port)";
            else:
                desc = "(illegal port)";

        count = count+1;
        print "%6u %03u : %s"%(lid,oport,desc);
    if all:
        print "%u lids dumped"%(count);
    else:
        print "%u valid lids dumped"%(count);
Beispiel #13
0
def cmd_set_nodedesc(argv,o):
    """Set or display the node description for CAs.
       Usage: %prog [-v] [NAME]

       By default all CAs are altered, use -C or -P to select a single CA."""
    o.add_option("-v",dest="view_all",action="store_true",
                 help="Increase the verbosity level of diagnostic messages, each -v increases by 1.")
    o.add_option("-C","--Ca",dest="CA",
                 help="RDMA device to use. Specify a device name or node GUID");
    o.add_option("-P","--Port",dest="port",
                 help="RDMA end port to use. Specify a GID, port GUID, DEVICE/PORT or port number.");
    (args,values) = o.parse_args(argv);

    dev = None
    if args.CA is not None:
        dev = rdma.get_device(args.CA);
    if dev is None and args.port is not None:
        dev = rdma.get_end_port(args.port).parent;

    if args.view_all or len(values) <= 0:
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            print "%s: %s"%(I.name,IBA_describe.dstr(I.node_desc))
    else:
        name = values[0].decode();
        name = name.encode("utf-8");
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            with open(os.path.join(I._dir,"node_desc"),"w") as F:
                F.write(name);
    return True;
Beispiel #14
0
def display_LFDB(switch, sbn, path, all):
    max_port = switch.ninf.numPorts
    print "Unicast lids [%u-%u] of switch %s %r" % (0, len(switch.lfdb) - 1,
                                                    path, switch.desc)
    print "  Lid  Out   Destination"
    print "       Port     Info"
    top_lid = len(sbn.lids)
    count = 0
    for lid, oport in enumerate(switch.lfdb):
        desc = ''
        if oport <= max_port:
            if lid < top_lid:
                port = sbn.lids[lid]
                if port is not None and port.parent is not None:
                    desc = "(%s portguid %s %r)" % (IBA_describe.node_type(
                        port.parent.ninf.nodeType), port.portGUID,
                                                    port.parent.desc)
        else:
            if not all:
                continue
            if lid == IBA.LID_RESERVED:
                desc = "(reserved LID - illegal port)"
            else:
                desc = "(illegal port)"

        count = count + 1
        print "%6u %03u : %s" % (lid, oport, desc)
    if all:
        print "%u lids dumped" % (count)
    else:
        print "%u valid lids dumped" % (count)
Beispiel #15
0
def cmd_set_nodedesc(argv,o):
    """Set or display the node description for CAs.
       Usage: %prog [-v] [NAME]

       By default all CAs are altered, use -C or -P to select a single CA."""
    o.add_option("-v",dest="view_all",action="store_true",
                 help="Increase the verbosity level of diagnostic messages, each -v increases by 1.")
    o.add_option("-C","--Ca",dest="CA",
                 help="RDMA device to use. Specify a device name or node GUID");
    o.add_option("-P","--Port",dest="port",
                 help="RDMA end port to use. Specify a GID, port GUID, DEVICE/PORT or port number.");
    (args,values) = o.parse_args(argv);

    dev = None
    if args.CA is not None:
        dev = rdma.get_device(args.CA);
    if dev is None and args.port is not None:
        dev = rdma.get_end_port(args.port).parent;

    if args.view_all or len(values) <= 0:
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            print "%s: %s"%(I.name,IBA_describe.dstr(I.node_desc))
    else:
        name = values[0].decode();
        name = name.encode("utf-8");
        for I in rdma.get_devices():
            if dev is not None and I != dev:
                continue;
            with open(os.path.join(I._dir,"node_desc"),"w") as F:
                F.write(name);
    return True;
Beispiel #16
0
    def display_nodes(val):
        ports = set();
        for I in val:
            port = sbn.lids[I];
            if port is not None and (args.all_nodes == False or
                                     isinstance(port.parent,rdma.subnet.CA)):
                ports.add(port);

        ports = list(ports);
        ports.sort(key=lambda x:x.parent.desc);

        if o.verbosity >= 1:
            for I in ports:
                print ' %s lid %u "%s"'%(I.portGUID,I.LID,
                                         IBA_describe.dstr(I.parent.desc));
        else:
            for I in ports:
                print ' %s'%(IBA_describe.dstr(I.parent.desc));
Beispiel #17
0
    def display_nodes(val):
        ports = set()
        for I in val:
            port = sbn.lids[I]
            if port is not None and (args.all_nodes == False or isinstance(
                    port.parent, rdma.subnet.CA)):
                ports.add(port)

        ports = list(ports)
        ports.sort(key=lambda x: x.parent.desc)

        if o.verbosity >= 1:
            for I in ports:
                print ' %s lid %u "%s"' % (I.portGUID, I.LID,
                                           IBA_describe.dstr(I.parent.desc))
        else:
            for I in ports:
                print ' %s' % (IBA_describe.dstr(I.parent.desc))
Beispiel #18
0
def print_ibnetdiscover_single(sbn,node):
    ninf = node.ninf;
    print '''vendid=0x%x
devid=0x%x
sysimgguid=%s'''%(ninf.vendorID,ninf.deviceID,ninf.systemImageGUID)
    is_switch = False;
    if isinstance(node,rdma.subnet.CA):
        print '''caguid=%s
Ca\t%u %s\t# "%s"'''%(ninf.nodeGUID,ninf.numPorts,as_node_name(node),
                      IBA_describe.dstr(node.desc));
    elif isinstance(node,rdma.subnet.Switch):
        is_switch = True;
        port = node.ports[0];
        print '''switchguid=%s(%s)
Switch\t%u %s\t# "%s" base port 0 lid %u lmc %u'''%\
                (ninf.nodeGUID,port.portGUID,ninf.numPorts,as_node_name(node),
                 IBA_describe.dstr(node.desc),port.LID or 0,port.pinf.LMC);
    elif isinstance(node,rdma.subnet.Router):
        print '''rtguid=%s
Rt\t%u %s\t# "%s"'''%(ninf.nodeGUID,ninf.numPorts,as_node_name(node),
                      IBA_describe.dstr(node.desc));
    else:
        print '''nodeguid=%s
??%u\t%u %s\t# "%s"'''%(ninf.nodeGUID,ninf.nodeType,ninf.numPorts,as_node_name(node),
                      IBA_describe.dstr(node.desc));

    for port,idx in node.iterports():
        peer = sbn.topology.get(port);
        if peer is None:
            continue;

        if is_switch:
            print '[%s]\t%s\t# "%s" lid %u %ux%s'%(
                    idx,as_port_name(peer),IBA_describe.dstr(peer.parent.desc),
                    peer.to_end_port().LID or 0,
                    IBA_describe.link_width(port.pinf.linkWidthActive),
                    IBA_describe.link_speed(port.pinf.linkSpeedActive));
        else:
            print '[%s](%s)\t%s\t# lid %u lmc %u "%s" %ux%s'%(
                idx,port.portGUID,as_port_name(peer),
                port.LID or 0,port.pinf.LMC,
                IBA_describe.dstr(peer.parent.desc),
                IBA_describe.link_width(port.pinf.linkWidthActive),
                IBA_describe.link_speed(port.pinf.linkSpeedActive));
Beispiel #19
0
def print_ibnetdiscover_single(sbn,node):
    ninf = node.ninf;
    print '''vendid=0x%x
devid=0x%x
sysimgguid=%s'''%(ninf.vendorID,ninf.deviceID,ninf.systemImageGUID)
    is_switch = False;
    if isinstance(node,rdma.subnet.CA):
        print '''caguid=%s
Ca\t%u %s\t# "%s"'''%(ninf.nodeGUID,ninf.numPorts,as_node_name(node),
                      IBA_describe.dstr(node.desc));
    elif isinstance(node,rdma.subnet.Switch):
        is_switch = True;
        port = node.ports[0];
        print '''switchguid=%s(%s)
Switch\t%u %s\t# "%s" base port 0 lid %u lmc %u'''%\
                (ninf.nodeGUID,port.portGUID,ninf.numPorts,as_node_name(node),
                 IBA_describe.dstr(node.desc),port.LID or 0,port.pinf.LMC);
    elif isinstance(node,rdma.subnet.Router):
        print '''rtguid=%s
Rt\t%u %s\t# "%s"'''%(ninf.nodeGUID,ninf.numPorts,as_node_name(node),
                      IBA_describe.dstr(node.desc));
    else:
        print '''nodeguid=%s
??%u\t%u %s\t# "%s"'''%(ninf.nodeGUID,ninf.nodeType,ninf.numPorts,as_node_name(node),
                      IBA_describe.dstr(node.desc));

    for port,idx in node.iterports():
        peer = sbn.topology.get(port);
        if peer is None:
            continue;

        if is_switch:
            print '[%s]\t%s\t# "%s" lid %u %ux%s'%(
                    idx,as_port_name(peer),IBA_describe.dstr(peer.parent.desc),
                    peer.to_end_port().LID or 0,
                    IBA_describe.link_width(port.pinf.linkWidthActive),
                    IBA_describe.link_speed(port.pinf.linkSpeedActive));
        else:
            print '[%s](%s)\t%s\t# lid %u lmc %u "%s" %ux%s'%(
                idx,port.portGUID,as_port_name(peer),
                port.LID or 0,port.pinf.LMC,
                IBA_describe.dstr(peer.parent.desc),
                IBA_describe.link_width(port.pinf.linkWidthActive),
                IBA_describe.link_speed(port.pinf.linkSpeedActive));
Beispiel #20
0
def summary2(node):
    if isinstance(node, rdma.subnet.CA):
        kind = "Ca"
    elif isinstance(node, rdma.subnet.Switch):
        kind = "Switch"
    elif isinstance(node, rdma.subnet.Router):
        kind = "Router"
    else:
        kind = "??%u" % (node.ninf.nodeType)

    print '%-8s: %s ports %u devid 0x%x vendid 0x%x "%s"' % (
        kind, node.ninf.nodeGUID, node.ninf.numPorts, node.ninf.deviceID,
        node.ninf.vendorID, IBA_describe.dstr(node.desc))
Beispiel #21
0
def do_check_portwidth(sched,path,desc,pinf,port,sbn,**kwargs):
    """Coroutine to do the checkportwidth action"""
    # Figure out the max width of both sides of the link if we have topology.
    max_width = get_max(pinf.linkWidthSupported);
    if sbn is not None:
        peer_port = sbn.topology.get(port);
        if peer_port is not None and peer_port.pinf is not None:
            max_width = min(max_width,get_max(peer_port.pinf.linkWidthSupported));
    # FIXME: What about 12x ports vs three 4x ports? How is that reported?
    checkEQ(pinf,"linkWidthActive",
            max_width,
            desc=desc,
            fmt=lambda v:"%ux"%(IBA_describe.link_width(v)));
Beispiel #22
0
def cmd_ibstatus(argv,o):
    """Display the RDMA end ports in the system.
       Usage: %prog [DEVICE[/PORT]]"""
    (args,values) = o.parse_args(argv);

    if len(values) == 0:
        end_ports = (I for J in rdma.get_devices() for I in J.end_ports);
    elif len(values) == 1:
        end_ports = (rdma.get_end_port(values[0]),);
    else:
        raise CmdError("Too many arguments");

    for I in end_ports:
        print """Infiniband device %r port %u status:
\tdefault gid:\t %s
\tbase lid:\t %u
\tsm lid:\t\t %u
\tstate:\t\t %u: %s
\tphys state:\t %u: %s
\trate:\t\t %s\n"""%(I.parent.name,I.port_id,I.default_gid,I.lid,I.sm_lid,
             I.state,IBA_describe.link_state(I.state).upper(),
             I.phys_state,IBA_describe.phys_link_state(I.phys_state),I.rate);
    return True;
Beispiel #23
0
def summary2(node):
    if isinstance(node,rdma.subnet.CA):
        kind = "Ca";
    elif isinstance(node,rdma.subnet.Switch):
        kind = "Switch";
    elif isinstance(node,rdma.subnet.Router):
        kind = "Router";
    else:
        kind = "??%u"%(node.ninf.nodeType);

    print '%-8s: %s ports %u devid 0x%x vendid 0x%x "%s"'%(
        kind,node.ninf.nodeGUID,node.ninf.numPorts,
        node.ninf.deviceID,node.ninf.vendorID,
        IBA_describe.dstr(node.desc));
Beispiel #24
0
def cmd_ibstatus(argv,o):
    """Display the RDMA end ports in the system.
       Usage: %prog [DEVICE[/PORT]]"""
    (args,values) = o.parse_args(argv);

    if len(values) == 0:
        end_ports = (I for J in rdma.get_devices() for I in J.end_ports);
    elif len(values) == 1:
        end_ports = (rdma.get_end_port(values[0]),);
    else:
        raise CmdError("Too many arguments");

    for I in end_ports:
        print """Infiniband device %r port %u status:
\tdefault gid:\t %s
\tbase lid:\t %u
\tsm lid:\t\t %u
\tstate:\t\t %u: %s
\tphys state:\t %u: %s
\trate:\t\t %s\n"""%(I.parent.name,I.port_id,I.default_gid,I.lid,I.sm_lid,
             I.state,IBA_describe.link_state(I.state).upper(),
             I.phys_state,IBA_describe.phys_link_state(I.phys_state),I.rate);
    return True;
Beispiel #25
0
def print_header(ninf, pinf, desc, portIdx, failed, kind):
    if lib.args.verbosity >= 1 or failed or warnings:
        if desc:
            desc = " (%s) " % (IBA_describe.dstr(desc))
        else:
            desc = ' '
        if kind & KIND_PORT:
            print "Port check lid %u%sport %u:" % (pinf.LID, desc, portIdx),
        if kind & KIND_PERF:
            if portIdx == 0xFF:
                print "Error check lid %u%sall ports:" % (pinf.LID, desc),
            else:
                print "Error check lid %u%sport %u:" % (pinf.LID, desc,
                                                        portIdx),
        if kind & KIND_CLEAR:
            if portIdx == 0xFF:
                print "Clear counters lid %u%sall ports:" % (pinf.LID, desc),
            else:
                print "Clear counters lid %u%sport %u:" % (pinf.LID, desc,
                                                           portIdx),
        if kind & KIND_NODE:
            if ninf.nodeType == IBA.NODE_SWITCH:
                print "# Checking %s: nodeguid %s lid %s" % (
                    IBA_describe.node_type(
                        ninf.nodeType), ninf.nodeGUID, pinf.LID)
            else:
                print "# Checking %s: nodeguid %s lid %s port %u" % (
                    IBA_describe.node_type(
                        ninf.nodeType), ninf.nodeGUID, pinf.LID, portIdx)
            print "Node check lid %u:" % (pinf.LID),
        if failed is not None:
            print(
                red("FAILED")
                if failed else blue("WARNING") if warnings else green("OK"))
    for I in warnings:
        print blue("#warn: %s" % (I))
    return not (failed or warnings)
Beispiel #26
0
def do_check_portwidth(sched, path, desc, pinf, port, sbn, **kwargs):
    """Coroutine to do the checkportwidth action"""
    # Figure out the max width of both sides of the link if we have topology.
    max_width = get_max(pinf.linkWidthSupported)
    if not link_configured(pinf):
        return
    if sbn is not None:
        peer_port = sbn.topology.get(port)
        if peer_port is not None and peer_port.pinf is not None:
            if not link_configured(peer_port.pinf):
                return
            max_width = min(max_width,
                            get_max(peer_port.pinf.linkWidthSupported))
    # FIXME: What about 12x ports vs three 4x ports? How is that reported?
    checkEQ(pinf,
            "linkWidthActive",
            max_width,
            desc=desc,
            fmt=lambda v: "%ux" % (IBA_describe.link_width(v)))
Beispiel #27
0
def do_print(out,s):
    """Special printing for some things to look like libib."""
    if isinstance(s,IBA.SANodeRecord):
        ninf = s.nodeInfo;
        desc = s.nodeDescription;
        s.nodeInfo = None;
        s.nodeDescription = None;
        if _format_args.get("name_map") is not None:
            args = copy.copy(_format_args);
            args["column"] = 24;
        else:
            args = _format_args;
        s.printer(out,**args);
        ninf.printer(out,**args);
        print >> out,"NodeDescription%s%s"%(
            "."*(args.get("column",33) - 15),
            IBA_describe.dstr(IBA_describe.description(desc.nodeString)));
    elif isinstance(s,IBA.SAPortInfoRecord):
        pinf = s.portInfo;
        s.portInfo = None;
        print "\tRID:"
        s.printer(out,**_format_args);
        print "\tPortInfo dump:"
        if _format_args.get("name_map") is not None:
            args = copy.copy(_format_args);
            args["name_map"] = libib_name_map_smpquery;
            args["colon"] = True;
            args["column"] = 33;
        else:
            args = _format_args;
        pinf.printer(out,**args);
    elif isinstance(s,IBA.SASwitchInfoRecord):
        sinf = s.switchInfo;
        s.switchInfo = None;
        print "\tRID:"
        s.printer(out,**_format_args);
        print "\tSwitchInfo dump:"
        if _format_args.get("name_map") is not None:
            args = copy.copy(_format_args);
            args["name_map"] = libib_name_map_smpquery;
            args["colon"] = True;
            args["column"] = 33;
        else:
            args = _format_args;
        sinf.printer(out,**args);
    elif isinstance(s,IBA.SAMulticastForwardingTableRecord):
        ft = s.multicastForwardingTable.portMaskBlock;
        s.multicastForwardingTable = None;
        s.printer(out,**_format_args);
        print >> out,"MFT:"
        print >> out,"MLID\tPort Mask"
        for I,v in enumerate(ft):
            print >> out,"0x%x\t0x%x"%(IBA.LID_MULTICAST + I + s.blockNum*32,v);
    elif isinstance(s,IBA.SALinearForwardingTableRecord):
        ft = s.linearForwardingTable.portBlock;
        s.linearForwardingTable = None;
        s.printer(out,**_format_args);
        print >> out,"LFT:"
        print >> out,"LID\tPort Number"
        for I,v in enumerate(ft):
            print >> out,"%u\t%u"%(I + s.blockNum*64,v);
    elif isinstance(s,IBA.SAPKeyTableRecord):
        pk = s.PKeyTable.PKeyBlock;
        s.PKeyTable = None;
        s.printer(out,**_format_args);
        print >> out,"PKey Table:"
        for num,I in enumerate(pk):
            if num % 8 == 0:
                if num != 0:
                    print >> out;
            print >> out,"0x%04x"%(I),
        print >> out;
    elif isinstance(s,IBA.SAVLArbitrationTableRecord):
        vl = s.VLArbitrationTable.VLWeightBlock;
        s.VLArbitrationTable = None;
        s.printer(out,**_format_args);
        print >> out, "VL    :" + "|".join(("%2u"%((I >> 8) & 0xF)) for I in vl[:16]) + "|";
        print >> out, "Weight:" + "|".join(("%2u"%(I & 0xFF)) for I in vl[:16]) + "|";
        print >> out, "VL    :" + "|".join(("%2u"%((I >> 8) & 0xF)) for I in vl[16:]) + "|";
        print >> out, "Weight:" + "|".join(("%2u"%(I & 0xFF)) for I in vl[16:]) + "|";
    else:
        s.printer(out,**_format_args);
Beispiel #28
0
def print_switch(sbn,args,switch):
    guid = (switch.ports[0].portGUID if args.port_guid else
            switch.ninf.nodeGUID);
    first = True;
    port0 = switch.get_port(0)
    for port,idx in switch.iterports():
        if idx == 0:
            continue;
        pinf = port.pinf;
        if args.only_down:
            if pinf.portPhysicalState == IBA.PHYS_PORT_STATE_LINK_UP:
                continue;
        if args.only_up:
            if pinf.portPhysicalState == IBA.PHYS_PORT_STATE_POLLING:
                continue
        if first and not args.line_mode:
            print "Switch %s %s:"%(guid,
                                   IBA_describe.dstr(switch.desc,True));
            first = False;
        if pinf.portPhysicalState != IBA.PHYS_PORT_STATE_LINK_UP:
            link = "%s/%s"%(
                IBA_describe.link_state(pinf.portState),
                IBA_describe.phys_link_state(pinf.portPhysicalState));
        else:
            if pinf.linkSpeedExtActive == 0:
                link = "%2ux %s %s/%s"%(
                    IBA_describe.link_width(pinf.linkWidthActive),
                    IBA_describe.link_speed(pinf.linkSpeedActive),
                    IBA_describe.link_state(pinf.portState),
                    IBA_describe.phys_link_state(pinf.portPhysicalState));
            else:
                link = "%2ux %s %s/%s"%(
                    IBA_describe.link_width(pinf.linkWidthActive),
                    IBA_describe.link_speed_ext(pinf.linkSpeedExtActive),
                    IBA_describe.link_state(pinf.portState),
                    IBA_describe.phys_link_state(pinf.portPhysicalState));
        if args.additional:
            additional = " (HOQ:%u VL_Stall:%u)"%(pinf.HOQLife,pinf.VLStallCount);
        else:
            additional = "";
        lhs = "%3d %4d[  ] ==(%s)%s"%(port0.LID,idx,link,additional);

        err = []
        peer_port = sbn.topology.get(port);
        if peer_port is None:
            rhs = '[  ] "" ( )';
        else:
            rhs = "%3d %4d[  ] %s"%(
                peer_port.to_end_port().LID,peer_port.port_id,
                IBA_describe.dstr(peer_port.parent.desc,True));
            if better_possible(pinf.linkWidthSupported,peer_port.pinf.linkWidthSupported,
                               pinf.linkWidthEnabled):
                err.append("Could be %sx"%(
                   IBA_describe.link_width(1<<int(math.floor(math.log(pinf.linkWidthSupported,2))))));
            if (pinf.linkSpeedExtSupported != 0 and peer_port.pinf.linkSpeedExtSupported):
                if better_possible(pinf.linkSpeedExtSupported,peer_port.pinf.linkSpeedExtSupported,
                                   pinf.linkSpeedExtEnabled):
                    err.append("Could be %s"%(
                        IBA_describe.link_speed_ext(1<<int(math.floor(math.log(pinf.linkSpeedExtSupported,2))))));
            else:
                if better_possible(pinf.linkSpeedSupported,peer_port.pinf.linkSpeedSupported,
                                   pinf.linkSpeedEnabled):
                    err.append("Could be %s"%(
                        IBA_describe.link_speed(1<<int(math.floor(math.log(pinf.linkSpeedSupported,2))))));

            err = ",".join(err);
        if err:
            err = " (%s)"%(err);

        if args.line_mode:
            print "%s %s %-40s==> %s%s"%(guid,
                                         IBA_describe.dstr(switch.desc,True),
                                         lhs,rhs,err);
        else:
            print "   %-40s==> %s%s"%(lhs,rhs,err);
Beispiel #29
0
def print_switch(sbn, args, switch):
    guid = (switch.ports[0].portGUID
            if args.port_guid else switch.ninf.nodeGUID)
    first = True
    port0 = switch.get_port(0)
    for port, idx in switch.iterports():
        if idx == 0:
            continue
        pinf = port.pinf
        if args.only_down:
            if pinf.portPhysicalState == IBA.PHYS_PORT_STATE_LINK_UP:
                continue
        if args.only_up:
            if pinf.portPhysicalState == IBA.PHYS_PORT_STATE_POLLING:
                continue
        if first and not args.line_mode:
            print "Switch %s %s:" % (guid, IBA_describe.dstr(
                switch.desc, True))
            first = False
        if pinf.portPhysicalState != IBA.PHYS_PORT_STATE_LINK_UP:
            link = "%s/%s" % (IBA_describe.link_state(pinf.portState),
                              IBA_describe.phys_link_state(
                                  pinf.portPhysicalState))
        else:
            if pinf.linkSpeedExtActive == 0:
                link = "%2ux %s %s/%s" % (
                    IBA_describe.link_width(pinf.linkWidthActive),
                    IBA_describe.link_speed(pinf.linkSpeedActive),
                    IBA_describe.link_state(pinf.portState),
                    IBA_describe.phys_link_state(pinf.portPhysicalState))
            else:
                link = "%2ux %s %s/%s" % (
                    IBA_describe.link_width(pinf.linkWidthActive),
                    IBA_describe.link_speed_ext(pinf.linkSpeedExtActive),
                    IBA_describe.link_state(pinf.portState),
                    IBA_describe.phys_link_state(pinf.portPhysicalState))
        if args.additional:
            additional = " (HOQ:%u VL_Stall:%u)" % (pinf.HOQLife,
                                                    pinf.VLStallCount)
        else:
            additional = ""
        lhs = "%3d %4d[  ] ==(%s)%s" % (port0.LID, idx, link, additional)

        err = []
        peer_port = sbn.topology.get(port)
        if peer_port is None:
            rhs = '[  ] "" ( )'
        else:
            rhs = "%3d %4d[  ] %s" % (
                peer_port.to_end_port().LID, peer_port.port_id,
                IBA_describe.dstr(peer_port.parent.desc, True))
            if better_possible(pinf.linkWidthSupported,
                               peer_port.pinf.linkWidthSupported,
                               pinf.linkWidthEnabled):
                err.append("Could be %sx" % (IBA_describe.link_width(1 << int(
                    math.floor(math.log(pinf.linkWidthSupported, 2))))))
            if (pinf.linkSpeedExtSupported != 0
                    and peer_port.pinf.linkSpeedExtSupported):
                if better_possible(pinf.linkSpeedExtSupported,
                                   peer_port.pinf.linkSpeedExtSupported,
                                   pinf.linkSpeedExtEnabled):
                    err.append(
                        "Could be %s" % (IBA_describe.link_speed_ext(1 << int(
                            math.floor(math.log(pinf.linkSpeedExtSupported,
                                                2))))))
            else:
                if better_possible(pinf.linkSpeedSupported,
                                   peer_port.pinf.linkSpeedSupported,
                                   pinf.linkSpeedEnabled):
                    err.append(
                        "Could be %s" % (IBA_describe.link_speed(1 << int(
                            math.floor(math.log(pinf.linkSpeedSupported, 2)))))
                    )

            err = ",".join(err)
        if err:
            err = " (%s)" % (err)

        if args.line_mode:
            print "%s %s %-40s==> %s%s" % (
                guid, IBA_describe.dstr(switch.desc, True), lhs, rhs, err)
        else:
            print "   %-40s==> %s%s" % (lhs, rhs, err)
Beispiel #30
0
def do_nd(umad, kind, path, attr):
    nd = umad.SubnGet(kind, path, attr)
    print "Node Description: %r" % (IBA_describe.description(nd.nodeString))
Beispiel #31
0
def perform_single_check(argv, o, funcs):
    o.add_option("-N",
                 "--nocolor",
                 action="store_false",
                 dest="colour",
                 default=True,
                 help="Do not colorize the output")
    if not isinstance(funcs, list):
        funcs = [funcs]
    funcs.sort(key=lambda x: x.kind)
    kinds = reduce(lambda x, y: x | y, (I.kind for I in funcs))
    if kinds & KIND_PERF:
        o.add_option("-s",
                     "--show_thresholds",
                     action="store_true",
                     dest="show_thresh",
                     default=False,
                     help="Only show the thresholds in use.")
        o.add_option("-T",
                     action="store",
                     dest="load_thresh",
                     metavar="FILE",
                     help="Load threshold values from this file.")
    LibIBOpts.setup(o)
    global lib
    if kinds & KIND_PERF:
        (args, values) = o.parse_args(argv)
        lib = LibIBOpts(o, args, values, 2, (tmpl_target, tmpl_int))
        global thresh
        thresh = load_thresholds(args.load_thresh)
        if args.show_thresh:
            for I in sorted(thresh.iteritems()):
                print "%s=%u" % I
            return True
        if len(values) < 1:
            raise CmdError("Got %u arguments but expected at least 1" %
                           (len(values)))
        if len(values) < 2:
            values.append(0xFF)
    elif kinds & KIND_PORT:
        (args, values) = o.parse_args(argv, expected_values=2)
        lib = LibIBOpts(o, args, values, 2, (tmpl_target, tmpl_int))
    else:
        (args, values) = o.parse_args(argv, expected_values=1)
        lib = LibIBOpts(o, args, values, 1, (tmpl_target, ))

    with lib.get_umad_for_target(values[0]) as umad:
        sched = lib.get_sched(umad)
        path = lib.path
        kwargs = {}
        kwargs["sbn"] = None
        kwargs["port"] = None
        kwargs["ninf"] = ninf = umad.SubnGet(IBA.SMPNodeInfo, path)
        if kinds & (KIND_PERF | KIND_PORT):
            kwargs["portIdx"] = portIdx = values[1]
        else:
            portIdx = ninf.localPortNum

        if kinds & KIND_PORT:
            kwargs["pinf"] = pinf = umad.SubnGet(IBA.SMPPortInfo, path,
                                                 values[1])
            if ninf.nodeType == IBA.NODE_SWITCH:
                ep_pinf = umad.SubnGet(IBA.SMPPortInfo, path, 0)
            else:
                ep_pinf = pinf
            kwargs["desc"] = "lid %u port %u" % (ep_pinf.LID, values[1])
        else:
            kwargs["pinf"] = ep_pinf = pinf = umad.SubnGet(
                IBA.SMPPortInfo, path)
        kwargs["portGUID"] = portGUID = kwargs["ninf"].portGUID
        nodeDesc = None
        if kinds & KIND_PERF:
            nodeDesc = IBA_describe.description(
                umad.SubnGet(IBA.SMPNodeDescription, path).nodeString)

        def done_checks(kind, failed=False):
            if kind & KIND_PERF and warnings:
                failed = True
            if lib.args.verbosity >= 1:
                print(
                    red("FAILED") if failed else
                    blue("WARNING") if warnings else green("OK"))
                for I in warnings:
                    print blue("#warn: %s" % (I))
            else:
                print_header(ninf, ep_pinf, nodeDesc, portIdx, failed, kind)

        try:
            printed = 0
            last_kind = 0
            for func in funcs:
                if lib.args.verbosity >= 1 and not (printed & func.kind):
                    print_header(ninf, ep_pinf, nodeDesc, portIdx, None,
                                 func.kind)

                if printed != 0 and last_kind != func.kind:
                    done_checks(last_kind)
                printed = printed | func.kind
                last_kind = func.kind

                if func.kind & (KIND_PERF
                                | KIND_CLEAR) and "gpath" not in kwargs:
                    kwargs["gpath"] = gpath = getattr(path, "_cached_gmp_path",
                                                      None)
                    if gpath is None:
                        gpath = rdma.path.get_mad_path(
                            umad,
                            portGUID,
                            dqpn=1,
                            qkey=IBA.IB_DEFAULT_QP1_QKEY)
                        path._cached_gmp_path = gpath
                        kwargs["gpath"] = gpath

                del warnings[:]
                sched.run(queue=func(sched, path, **kwargs))
        except (CmdError, rdma.RDMAError):
            done_checks(last_kind, True)
            raise
        done_checks(last_kind)
    return lib.done()
Beispiel #32
0
def do_print(out, s):
    """Special printing for some things to look like libib."""
    if isinstance(s, IBA.SANodeRecord):
        ninf = s.nodeInfo
        desc = s.nodeDescription
        s.nodeInfo = None
        s.nodeDescription = None
        if _format_args.get("name_map") is not None:
            args = copy.copy(_format_args)
            args["column"] = 24
        else:
            args = _format_args
        s.printer(out, **args)
        ninf.printer(out, **args)
        print >> out, "NodeDescription%s%s" % (
            "." * (args.get("column", 33) - 15),
            IBA_describe.dstr(IBA_describe.description(desc.nodeString)))
    elif isinstance(s, IBA.SAPortInfoRecord):
        pinf = s.portInfo
        s.portInfo = None
        print "\tRID:"
        s.printer(out, **_format_args)
        print "\tPortInfo dump:"
        if _format_args.get("name_map") is not None:
            args = copy.copy(_format_args)
            args["name_map"] = libib_name_map_smpquery
            args["colon"] = True
            args["column"] = 33
        else:
            args = _format_args
        pinf.printer(out, **args)
    elif isinstance(s, IBA.SASwitchInfoRecord):
        sinf = s.switchInfo
        s.switchInfo = None
        print "\tRID:"
        s.printer(out, **_format_args)
        print "\tSwitchInfo dump:"
        if _format_args.get("name_map") is not None:
            args = copy.copy(_format_args)
            args["name_map"] = libib_name_map_smpquery
            args["colon"] = True
            args["column"] = 33
        else:
            args = _format_args
        sinf.printer(out, **args)
    elif isinstance(s, IBA.SAMulticastForwardingTableRecord):
        ft = s.multicastForwardingTable.portMaskBlock
        s.multicastForwardingTable = None
        s.printer(out, **_format_args)
        print >> out, "MFT:"
        print >> out, "MLID\tPort Mask"
        for I, v in enumerate(ft):
            print >> out, "0x%x\t0x%x" % (IBA.LID_MULTICAST + I +
                                          s.blockNum * 32, v)
    elif isinstance(s, IBA.SALinearForwardingTableRecord):
        ft = s.linearForwardingTable.portBlock
        s.linearForwardingTable = None
        s.printer(out, **_format_args)
        print >> out, "LFT:"
        print >> out, "LID\tPort Number"
        for I, v in enumerate(ft):
            print >> out, "%u\t%u" % (I + s.blockNum * 64, v)
    elif isinstance(s, IBA.SAPKeyTableRecord):
        pk = s.PKeyTable.PKeyBlock
        s.PKeyTable = None
        s.printer(out, **_format_args)
        print >> out, "PKey Table:"
        for num, I in enumerate(pk):
            if num % 8 == 0:
                if num != 0:
                    print >> out
            print >> out, "0x%04x" % (I),
        print >> out
    elif isinstance(s, IBA.SAVLArbitrationTableRecord):
        vl = s.VLArbitrationTable.VLWeightBlock
        s.VLArbitrationTable = None
        s.printer(out, **_format_args)
        print >> out, "VL    :" + "|".join(
            ("%2u" % ((I >> 8) & 0xF)) for I in vl[:16]) + "|"
        print >> out, "Weight:" + "|".join(
            ("%2u" % (I & 0xFF)) for I in vl[:16]) + "|"
        print >> out, "VL    :" + "|".join(
            ("%2u" % ((I >> 8) & 0xF)) for I in vl[16:]) + "|"
        print >> out, "Weight:" + "|".join(
            ("%2u" % (I & 0xFF)) for I in vl[16:]) + "|"
    else:
        s.printer(out, **_format_args)
Beispiel #33
0
def cmd_ibtracert(argv,o):
    """Show the route a path will take in the network
       Usage: %prog {TARGET}|{SOURCE TARGET}

       If SOURCE is not specified then the local end port is used.

       When tracing a multicast path the entire multicast spanning tree
       for the MLID is loaded, and the route that goes between start/end
       is printed"""
    LibIBOpts.setup(o,address=True,discovery=True);
    o.add_option("-r","--reverse",action="store_true",dest="reverse",
                 help="Swap source and target");
    o.add_option("-m","--mlid",action="store",dest="mlid",
                 type=int,
                 help="Report on a multicast path");
    (args,values) = o.parse_args(argv);
    lib = LibIBOpts(o,args,values,2,(tmpl_target,tmpl_target));

    if len(values) <= 0:
        raise CmdError("Too few arguments");

    with lib.get_umad_for_target() as umad:
        sched = lib.get_sched(umad);
        sbn = lib.get_subnet(sched,["all_SwitchInfo"]);

        # Index 0 is the source, 1 is the target, 2 is the first source
        if len(values) == 1:
            paths = [rdma.path.IBPath(sched.end_port,
                                      SLID=sched.end_port.lid,
                                      DLID=sched.end_port.lid),
                     values[0]];
            spath,dpath = paths;

            # If the target has source information then copy it in to the
            # source path.
            if dpath.SLID != 0:
                spath.DLID = dpath.SLID;
            if dpath.SGID is not None:
                spath.DGID = dpath.SGID;
        else:
            paths = list(values);

        if args.reverse:
            paths.reverse();

        # Resolve the paths to something usable
        paths = [resolve_path(umad,sbn,I) for I in paths];
        sched.run(mqueue=(rdma.discovery.subnet_get_port(sched,sbn,I)
                          for I in paths));
        ports = [sbn.path_to_port(I) for I in paths];

        # If we are starting at something other than a switch port, or our
        # local port then we need to have the connected switch port because we
        # cannot DR from a CA port. Simplest way to get this is to
        # trace to the target from the local port.
        sport = ports[0];
        dport = ports[1];
        if (not isinstance(sport.parent,rdma.subnet.Switch) and
            sport not in sbn.topology and
            sport.LID != paths[0].end_port.lid and
            not isinstance(paths[0],rdma.path.IBDRPath) and
            not isinstance(sched,rdma.satransactor.SATransactor)):
            if sbn.lid_routed:
                lpath = rdma.path.IBPath(sched.end_port,SLID=sched.end_port.lid,
                                         DLID=sched.end_port.lid,
                                         dqpn=0,sqpn=0,qkey=IBA.IB_DEFAULT_QP0_QKEY);
            else:
                lpath = rdma.path.IBDRPath(sched.end_port);
            if lib.debug >= 1:
                print "D: Figuring out route from local port to source"
            paths.append(lpath);
            sched.run(queue=rdma.discovery.subnet_get_port(sched,sbn,lpath));
            lport = sbn.path_to_port(lpath);
            ports.append(lport);
            paths[0] = trace(umad,sched,sbn,lport,lpath,sport,paths[0],
                             lambda x,y: None)

        # The target must be LID routed.
        if dport.LID == 0:
            raise CmdError("Target port %s does not have a valid LID"%(
                ports[2].portGUID));
        if isinstance(paths[1],rdma.path.IBDRPath):
            paths[1] = rdma.path.IBPath(sched.end_port,
                                        DLID=ports[1].LID,
                                        dqpn=0,sqpn=0,
                                        qkey=IBA.IB_DEFAULT_QP0_QKEY);

        if lib.debug >= 1:
            for n,path,port in zip(("SRC","DST","START"),paths,ports):
                print "D: %s is %s (%s)"%(n,path,port.portGUID);


        print "From %s %s portnum %u LID %u/%u %s"%(
            IBA_describe.node_type(sport.parent.ninf.nodeType),
            sport.portGUID,sport.port_id,
            sport.LID,16-sport.pinf.LMC,
            IBA_describe.dstr(sport.parent.desc,quotes=True));
        def step(out_port,nport):
            nport_ep = nport.to_end_port();
            print "[%u] -> %s port %s[%u] lid %u/%u %s"%(
                out_port.port_id,
                IBA_describe.node_type(nport.parent.ninf.nodeType),
                nport_ep.portGUID,
                nport.port_id,
                nport_ep.LID,16 - nport_ep.pinf.LMC,
                IBA_describe.dstr(nport.parent.desc,quotes=True));

        if args.mlid is not None:
            if args.mlid < IBA.LID_MULTICAST:
                raise CmdError("Multicast LID %r is invalid"%(args.mlid));
            topo = fetch_mcast(sched,sbn,sport,paths[0],args.mlid);
            if lib.debug >= 1:
                print "D: Multicast spanning tree topology contains %u entries"%(len(topo))
            lst = trace_mcast(topo,ports[0],ports[1]);
            step(ports[0],topo[ports[0]]);
            for I in lst:
                step(I,topo[I]);
        else:
            trace(umad,sched,sbn,ports[0],paths[0],ports[1],paths[1],step);

        print "To %s %s portnum %u LID %u/%u %s"%(
            IBA_describe.node_type(dport.parent.ninf.nodeType),
            dport.portGUID,dport.port_id,
            paths[1].DLID,16-dport.pinf.LMC,
            IBA_describe.dstr(dport.parent.desc,quotes=True));

    return lib.done();
Beispiel #34
0
 def set_desc(self,nodeString):
     """Set the description from a *nodeString* type value."""
     self.desc = IBA_describe.description(nodeString);
Beispiel #35
0
 def set_desc(self, nodeString):
     """Set the description from a *nodeString* type value."""
     self.desc = IBA_describe.description(nodeString)
Beispiel #36
0
def do_nd(umad,kind,path,attr):
    nd = umad.SubnGet(kind,path,attr);
    print "Node Description: %r"%(IBA_describe.description(nd.nodeString));
Beispiel #37
0
def cmd_ibtracert(argv, o):
    """Show the route a path will take in the network
       Usage: %prog {TARGET}|{SOURCE TARGET}

       If SOURCE is not specified then the local end port is used.

       When tracing a multicast path the entire multicast spanning tree
       for the MLID is loaded, and the route that goes between start/end
       is printed"""
    LibIBOpts.setup(o, address=True, discovery=True)
    o.add_option("-r",
                 "--reverse",
                 action="store_true",
                 dest="reverse",
                 help="Swap source and target")
    o.add_option("-m",
                 "--mlid",
                 action="store",
                 dest="mlid",
                 type=int,
                 help="Report on a multicast path")
    (args, values) = o.parse_args(argv)
    lib = LibIBOpts(o, args, values, 2, (tmpl_target, tmpl_target))

    if len(values) <= 0:
        raise CmdError("Too few arguments")

    with lib.get_umad_for_target() as umad:
        sched = lib.get_sched(umad)
        sbn = lib.get_subnet(sched, ["all_SwitchInfo"])

        # Index 0 is the source, 1 is the target, 2 is the first source
        if len(values) == 1:
            paths = [
                rdma.path.IBPath(sched.end_port,
                                 SLID=sched.end_port.lid,
                                 DLID=sched.end_port.lid), values[0]
            ]
            spath, dpath = paths

            # If the target has source information then copy it in to the
            # source path.
            if dpath.SLID != 0:
                spath.DLID = dpath.SLID
            if dpath.SGID is not None:
                spath.DGID = dpath.SGID
        else:
            paths = list(values)

        if args.reverse:
            paths.reverse()

        # Resolve the paths to something usable
        paths = [resolve_path(umad, sbn, I) for I in paths]
        sched.run(mqueue=(rdma.discovery.subnet_get_port(sched, sbn, I)
                          for I in paths))
        ports = [sbn.path_to_port(I) for I in paths]

        # If we are starting at something other than a switch port, or our
        # local port then we need to have the connected switch port because we
        # cannot DR from a CA port. Simplest way to get this is to
        # trace to the target from the local port.
        sport = ports[0]
        dport = ports[1]
        if (not isinstance(sport.parent, rdma.subnet.Switch)
                and sport not in sbn.topology
                and sport.LID != paths[0].end_port.lid
                and not isinstance(paths[0], rdma.path.IBDRPath)
                and not isinstance(sched, rdma.satransactor.SATransactor)):
            if sbn.lid_routed:
                lpath = rdma.path.IBPath(sched.end_port,
                                         SLID=sched.end_port.lid,
                                         DLID=sched.end_port.lid,
                                         dqpn=0,
                                         sqpn=0,
                                         qkey=IBA.IB_DEFAULT_QP0_QKEY)
            else:
                lpath = rdma.path.IBDRPath(sched.end_port)
            if lib.debug >= 1:
                print "D: Figuring out route from local port to source"
            paths.append(lpath)
            sched.run(queue=rdma.discovery.subnet_get_port(sched, sbn, lpath))
            lport = sbn.path_to_port(lpath)
            ports.append(lport)
            paths[0] = trace(umad, sched, sbn, lport, lpath, sport, paths[0],
                             lambda x, y: None)

        # The target must be LID routed.
        if dport.LID == 0:
            raise CmdError("Target port %s does not have a valid LID" %
                           (ports[2].portGUID))
        if isinstance(paths[1], rdma.path.IBDRPath):
            paths[1] = rdma.path.IBPath(sched.end_port,
                                        DLID=ports[1].LID,
                                        dqpn=0,
                                        sqpn=0,
                                        qkey=IBA.IB_DEFAULT_QP0_QKEY)

        if lib.debug >= 1:
            for n, path, port in zip(("SRC", "DST", "START"), paths, ports):
                print "D: %s is %s (%s)" % (n, path, port.portGUID)

        print "From %s %s portnum %u LID %u/%u %s" % (
            IBA_describe.node_type(sport.parent.ninf.nodeType), sport.portGUID,
            sport.port_id, sport.LID, 16 - sport.pinf.LMC,
            IBA_describe.dstr(sport.parent.desc, quotes=True))

        def step(out_port, nport):
            nport_ep = nport.to_end_port()
            print "[%u] -> %s port %s[%u] lid %u/%u %s" % (
                out_port.port_id,
                IBA_describe.node_type(
                    nport.parent.ninf.nodeType), nport_ep.portGUID,
                nport.port_id, nport_ep.LID, 16 - nport_ep.pinf.LMC,
                IBA_describe.dstr(nport.parent.desc, quotes=True))

        if args.mlid is not None:
            if args.mlid < IBA.LID_MULTICAST:
                raise CmdError("Multicast LID %r is invalid" % (args.mlid))
            topo = fetch_mcast(sched, sbn, sport, paths[0], args.mlid)
            if lib.debug >= 1:
                print "D: Multicast spanning tree topology contains %u entries" % (
                    len(topo))
            lst = trace_mcast(topo, ports[0], ports[1])
            step(ports[0], topo[ports[0]])
            for I in lst:
                step(I, topo[I])
        else:
            trace(umad, sched, sbn, ports[0], paths[0], ports[1], paths[1],
                  step)

        print "To %s %s portnum %u LID %u/%u %s" % (
            IBA_describe.node_type(dport.parent.ninf.nodeType), dport.portGUID,
            dport.port_id, paths[1].DLID, 16 - dport.pinf.LMC,
            IBA_describe.dstr(dport.parent.desc, quotes=True))

    return lib.done()
Beispiel #38
0
def cmd_ibfindnodesusing(argv, o):
    """Display the LFT forwarding tables relative to a single link.
       Usage: %prog TARGET PORT

       Use -v to display GUID and LID information for the routed end ports."""
    LibIBOpts.setup(o, address=True, discovery=True)
    o.add_option("-a",
                 "--all",
                 action="store_true",
                 dest="all_nodes",
                 help="Display all routed end ports, not just CAs")
    (args, values) = o.parse_args(argv, expected_values=2)
    lib = LibIBOpts(o, args, values, 2, (tmpl_target, tmpl_int))

    args.do_mfdb = False
    args.do_lfdb = True

    args.port = values[1]

    def display_nodes(val):
        ports = set()
        for I in val:
            port = sbn.lids[I]
            if port is not None and (args.all_nodes == False or isinstance(
                    port.parent, rdma.subnet.CA)):
                ports.add(port)

        ports = list(ports)
        ports.sort(key=lambda x: x.parent.desc)

        if o.verbosity >= 1:
            for I in ports:
                print ' %s lid %u "%s"' % (I.portGUID, I.LID,
                                           IBA_describe.dstr(I.parent.desc))
        else:
            for I in ports:
                print ' %s' % (IBA_describe.dstr(I.parent.desc))

    with lib.get_umad_for_target(values[0]) as umad:
        path = lib.path
        sched = lib.get_sched(umad, path)
        sbn = lib.get_subnet(sched)
        if isinstance(path, rdma.path.IBDRPath):
            sbn.lid_routed = False
            sbn.paths = {}

        sched.run(queue=get_switch(sched, sbn, args, path))
        switch = sbn.path_to_port(path=path).parent
        if args.port <= 0 or args.port > switch.ninf.numPorts:
            raise CmdError("Port %u is invalid, switch has %u ports" %
                           (args.port, switch, ninf.numPorts))
        print switch.desc
        port = switch.get_port(args.port)
        eport = port.to_end_port()
        LIDs = set(LID for LID, port in enumerate(switch.lfdb)
                   if port == args.port)

        sched.run(queue=rdma.discovery.topo_peer_SMP(sched, sbn, port))
        pport = sbn.topology.get(port)
        if pport is None:
            raise CmdError("No link on port %u" % (args.port))
        peport = pport.to_end_port()
        pnode = pport.parent
        if isinstance(pnode, rdma.subnet.Switch):
            ppath = sbn.get_path_smp(sched, pport.to_end_port())
            sched.run(queue=pnode.get_switch_inf(sched, ppath))
            sched.run(queue=pnode.get_switch_fdb(sched, True, False, ppath))
            pportIdx = pnode.ports.index(pport)
            LIDs.update(LID for LID, port in enumerate(pnode.lfdb)
                        if port == pportIdx)

        sched.run(queue=rdma.discovery.subnet_ninf_LIDS_SMP(
            sched, sbn, list(LIDs), True))
        print '%s %u "%s" ==>> %s %u "%s"' % (
            eport.portGUID, switch.ports.index(port),
            IBA_describe.dstr(switch.desc), peport.portGUID,
            pnode.ports.index(pport), IBA_describe.dstr(pnode.desc))
        display_nodes(LID for LID, port in enumerate(switch.lfdb)
                      if port == args.port)

        print
        print '%s %u "%s" <<== %s %u "%s"' % (
            eport.portGUID, switch.ports.index(port),
            IBA_describe.dstr(switch.desc), peport.portGUID,
            pnode.ports.index(pport), IBA_describe.dstr(pnode.desc))
        if not isinstance(pnode, rdma.subnet.Switch):
            print " ** Not a switch **"
        else:
            display_nodes(LID for LID, port in enumerate(pnode.lfdb)
                          if port == pportIdx)

    return lib.done()
Beispiel #39
0
def cmd_ibfindnodesusing(argv,o):
    """Display the LFT forwarding tables relative to a single link.
       Usage: %prog TARGET PORT

       Use -v to display GUID and LID information for the routed end ports."""
    LibIBOpts.setup(o,address=True,discovery=True);
    o.add_option("-a","--all",action="store_true",dest="all_nodes",
                 help="Display all routed end ports, not just CAs");
    (args,values) = o.parse_args(argv,expected_values=2);
    lib = LibIBOpts(o,args,values,2,(tmpl_target,tmpl_int));

    args.do_mfdb = False;
    args.do_lfdb = True;

    args.port = values[1];

    def display_nodes(val):
        ports = set();
        for I in val:
            port = sbn.lids[I];
            if port is not None and (args.all_nodes == False or
                                     isinstance(port.parent,rdma.subnet.CA)):
                ports.add(port);

        ports = list(ports);
        ports.sort(key=lambda x:x.parent.desc);

        if o.verbosity >= 1:
            for I in ports:
                print ' %s lid %u "%s"'%(I.portGUID,I.LID,
                                         IBA_describe.dstr(I.parent.desc));
        else:
            for I in ports:
                print ' %s'%(IBA_describe.dstr(I.parent.desc));

    with lib.get_umad_for_target(values[0]) as umad:
        path = lib.path;
        sched = lib.get_sched(umad,path);
        sbn = lib.get_subnet(sched);
        if isinstance(path,rdma.path.IBDRPath):
            sbn.lid_routed = False;
            sbn.paths = {};

        sched.run(queue=get_switch(sched,sbn,args,path));
        switch = sbn.path_to_port(path=path).parent;
        if args.port <= 0 or args.port > switch.ninf.numPorts:
            raise CmdError("Port %u is invalid, switch has %u ports"%(
                args.port,switch,ninf.numPorts));
        print switch.desc
        port = switch.get_port(args.port);
        eport = port.to_end_port();
        LIDs = set(LID for LID,port in enumerate(switch.lfdb)
                   if port == args.port)

        sched.run(queue=rdma.discovery.topo_peer_SMP(sched,sbn,port));
        pport = sbn.topology.get(port);
        if pport is None:
            raise CmdError("No link on port %u"%(args.port));
        peport = pport.to_end_port();
        pnode = pport.parent;
        if isinstance(pnode,rdma.subnet.Switch):
            ppath = sbn.get_path_smp(sched,pport.to_end_port());
            sched.run(queue=pnode.get_switch_inf(sched,ppath));
            sched.run(queue=pnode.get_switch_fdb(sched,True,False,ppath));
            pportIdx = pnode.ports.index(pport);
            LIDs.update(LID for LID,port in enumerate(pnode.lfdb)
                        if port == pportIdx);

        sched.run(queue=rdma.discovery.subnet_ninf_LIDS_SMP(sched,sbn,list(LIDs),
                                                            True));
        print '%s %u "%s" ==>> %s %u "%s"'%(eport.portGUID,
                                            switch.ports.index(port),
                                            IBA_describe.dstr(switch.desc),
                                            peport.portGUID,
                                            pnode.ports.index(pport),
                                            IBA_describe.dstr(pnode.desc));
        display_nodes(LID for LID,port in enumerate(switch.lfdb) if port == args.port);

        print
        print '%s %u "%s" <<== %s %u "%s"'%(eport.portGUID,
                                            switch.ports.index(port),
                                            IBA_describe.dstr(switch.desc),
                                            peport.portGUID,
                                            pnode.ports.index(pport),
                                            IBA_describe.dstr(pnode.desc));
        if not isinstance(pnode,rdma.subnet.Switch):
            print " ** Not a switch **";
        else:
            display_nodes(LID for LID,port in enumerate(pnode.lfdb) if port == pportIdx);

    return lib.done();
Beispiel #40
0
def perform_single_check(argv,o,funcs):
    o.add_option("-N","--nocolor",action="store_false",dest="colour",
                 default=True,
                 help="Do not colorize the output");
    if not isinstance(funcs,list):
        funcs = [funcs];
    funcs.sort(key=lambda x:x.kind);
    kinds = reduce(lambda x,y:x | y,(I.kind for I in funcs));
    if kinds & KIND_PERF:
        o.add_option("-s","--show_thresholds",action="store_true",dest="show_thresh",
                     default=False,
                     help="Only show the thresholds in use.");
        o.add_option("-T",action="store",dest="load_thresh",metavar="FILE",
                     help="Load threshold values from this file.");
    LibIBOpts.setup(o);
    global lib
    if kinds & KIND_PERF:
        (args,values) = o.parse_args(argv);
        lib = LibIBOpts(o,args,values,2,(tmpl_target,tmpl_int));
        global thresh
        thresh = load_thresholds(args.load_thresh);
        if args.show_thresh:
            for I in sorted(thresh.iteritems()):
                print "%s=%u"%I
            return True;
        if len(values) < 1:
            raise CmdError("Got %u arguments but expected at least 1"%(len(values)));
        if len(values) < 2:
            values.append(0xFF);
    elif kinds & KIND_PORT:
        (args,values) = o.parse_args(argv,expected_values=2);
        lib = LibIBOpts(o,args,values,2,(tmpl_target,tmpl_int));
    else:
        (args,values) = o.parse_args(argv,expected_values=1);
        lib = LibIBOpts(o,args,values,1,(tmpl_target,));

    with lib.get_umad_for_target(values[0]) as umad:
        sched = lib.get_sched(umad);
        path = lib.path
        kwargs = {};
        kwargs["sbn"] = None;
        kwargs["port"] = None;
        kwargs["ninf"] = ninf = umad.SubnGet(IBA.SMPNodeInfo,path);
        if kinds & (KIND_PERF | KIND_PORT):
            kwargs["portIdx"] = portIdx = values[1];
        else:
            portIdx = ninf.localPortNum;

        if kinds & KIND_PORT:
            kwargs["pinf"] = pinf = umad.SubnGet(IBA.SMPPortInfo,path,values[1]);
            if ninf.nodeType == IBA.NODE_SWITCH:
                ep_pinf = umad.SubnGet(IBA.SMPPortInfo,path,0);
            else:
                ep_pinf = pinf;
            kwargs["desc"] = "lid %u port %u"%(ep_pinf.LID,values[1]);
        else:
            kwargs["pinf"] = ep_pinf = pinf = umad.SubnGet(IBA.SMPPortInfo,path);
        kwargs["portGUID"] = portGUID = kwargs["ninf"].portGUID;
        nodeDesc = None;
        if kinds & KIND_PERF:
            nodeDesc = IBA_describe.description(umad.SubnGet(IBA.SMPNodeDescription,path).nodeString);

        def done_checks(kind,failed=False):
            if kind & KIND_PERF and warnings:
                failed = True;
            if lib.args.verbosity >= 1:
                print (red("FAILED") if failed else
                       blue("WARNING") if warnings else
                       green("OK"));
                for I in warnings:
                    print blue("#warn: %s"%(I));
            else:
                print_header(ninf,ep_pinf,nodeDesc,portIdx,failed,
                             kind);

        try:
            printed = 0;
            last_kind = 0;
            for func in funcs:
                if lib.args.verbosity >= 1 and not (printed & func.kind):
                    print_header(ninf,ep_pinf,nodeDesc,portIdx,None,
                                 func.kind);

                if printed != 0 and last_kind != func.kind:
                    done_checks(last_kind);
                printed = printed | func.kind;
                last_kind = func.kind;

                if func.kind & (KIND_PERF|KIND_CLEAR) and "gpath" not in kwargs:
                    kwargs["gpath"] = gpath = getattr(path,"_cached_gmp_path",None);
                    if gpath is None:
                        gpath = rdma.path.get_mad_path(umad,portGUID,
                                                       dqpn=1,
                                                       qkey=IBA.IB_DEFAULT_QP1_QKEY);
                        path._cached_gmp_path = gpath;
                        kwargs["gpath"] = gpath;

                del warnings[:];
                sched.run(queue=func(sched,path,**kwargs));
        except (CmdError,rdma.RDMAError):
            done_checks(last_kind,True);
            raise
        done_checks(last_kind);
    return lib.done();