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 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:
            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));
        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,idx,
                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 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);
Exemple #2
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);
Exemple #3
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);
Exemple #4
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;
Exemple #5
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;
Exemple #6
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)