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);
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 port.pinf.linkSpeedExtActive == 0: 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)); else: 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_ext(port.pinf.linkSpeedExtActive)); 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_ext(port.pinf.linkSpeedExtActive));
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]))
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 port.pinf.linkSpeedExtActive == 0: 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)) else: 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_ext(port.pinf.linkSpeedExtActive)) 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_ext(port.pinf.linkSpeedExtActive))
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]));
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)