コード例 #1
0
ファイル: discovery.py プロジェクト: tubbytani/python-rdma
def subnet_ninf_SMP(sched,sbn,path,get_desc=True,use_sa=None,done_desc=None):
    """Coroutine to send SMPs to get :class:`~rdma.IBA.SMPNodeInfo` and
    :class:`~rdma.IBA.SMPNodeDescription`. The result of the co-routine
    is the same as :meth:`rdma.subnet.Subnet.get_node_ninf`. If *sched*
    is a :class:`rdma.satransactor.SATransactor` then the query is optimized
    into a combined node info/node description SA query."""
    if use_sa is None:
        use_sa = isinstance(sched,rdma.satransactor.SATransactor);

    if use_sa:
        req = IBA.ComponentMask(IBA.SANodeRecord());
        req.LID = yield sched.prepare_path_lid(path);
        ret = yield sched.SubnAdmGet(req);
        sched.result = sbn.get_node_ninf(ret.nodeInfo,path);
        sched.result[0].set_desc(ret.nodeDescription.nodeString);
        path._cached_node_type = ret.nodeInfo.nodeType;
    else:
        ninf = yield sched.SubnGet(IBA.SMPNodeInfo,path);
        result = sbn.get_node_ninf(ninf,path);
        sched.result = result;
        node,port = result

        if node.desc is not None or get_desc is False:
            return;
        if done_desc is not None:
            if node in done_desc:
                return;
            done_desc.add(node);
        sched.queue(node.get_desc(sched,path));
        sched.result = result;
コード例 #2
0
ファイル: discovery.py プロジェクト: tubbytani/python-rdma
def subnet_ninf_SA(sched,sbn,node_type=None):
    """Coroutine to fetch all :class:`~rmda.IBA.SMPNodeInfo` records from the
    SA and store them in *sbn*."""
    req = IBA.ComponentMask(IBA.SANodeRecord());
    if node_type is not None:
        req.nodeInfo.nodeType = node_type;
    res = yield sched.SubnAdmGetTable(IBA.SANodeRecord());
    if res:
        sbn.set_max_lid(max(I.LID for I in res));
    for I in res:
        np = sbn.get_node_ninf(I.nodeInfo,LID=I.LID);
        np[0].set_desc(I.nodeDescription.nodeString);
    if node_type is None:
        sbn.loaded.add("all_NodeInfo");
        sbn.loaded.add("all_NodeDescription");
    else:
        sbn.loaded.add("all_NodeInfo %u"%(node_type));
        sbn.loaded.add("all_NodeDescription %u"%(node_type));
コード例 #3
0
 def ninf(self):
     try:
         return self.__dict__["ninf"];
     except KeyError:
         pass
     ninf = IBA.ComponentMask(IBA.SANodeRecord());
     ninf.LID = self.path.DLID;
     ninf = self.umad.SubnAdmGet(ninf);
     self.__dict__["ninf"] = ninf;
     if self.path.DGID is None:
         self.path.DGID = IBA.GID(prefix=IBA.GID_DEFAULT_PREFIX,
                                  guid=ninf.nodeInfo.portGUID);
     return ninf;
コード例 #4
0
ファイル: discovery.py プロジェクト: tubbytani/python-rdma
def subnet_ninf_GUID(sched,sbn,node_guid):
    """Coroutine to fetch a :class:`~rmda.IBA.SMPNodeInfo` record from the
    SA for a specific GUID and store it in *sbn*."""
    req = IBA.ComponentMask(IBA.SANodeRecord());
    req.nodeInfo.nodeGUID = node_guid;
    res = yield sched.SubnAdmGetTable(req);

    # The SM can return multiple records that match a nodeGUID, one for each port
    # on a CA. When it does this it must set the portGUID and localPortNum correctly
    # to match the LID in the RID.
    for I in res:
        np = sbn.get_node_ninf(I.nodeInfo,LID=I.LID);
        np[0].set_desc(I.nodeDescription.nodeString);
コード例 #5
0
def do_check_node(sched, path, portGUID, ninf, **kwargs):
    """Coroutine to do the checknode action"""
    req = IBA.ComponentMask(IBA.SANodeRecord())
    if isinstance(path, rdma.path.IBDRPath):
        req.nodeInfo.portGUID = portGUID
    else:
        req.LID = path.DLID
    ninfr = yield sched.SubnAdmGet(req)

    if portGUID != ninfr.nodeInfo.portGUID:
        raise CheckError("SA and SMP NodeInfo's differ %r != %r" %
                         (portGUID, ninfr.nodeInfo.portGUID))

    try:
        npath = yield rdma.path.get_mad_path(sched,
                                             portGUID,
                                             dqpn=1,
                                             qkey=IBA.IB_DEFAULT_QP1_QKEY)
        if lib.debug >= 1:
            print "D: SA path to end port is", repr(npath)
    except rdma.path.SAPathNotFoundError:
        raise CheckError("SA could not find a path for %r" % (ninf.portGUID))
    path._cached_gmp_path = npath
コード例 #6
0
    def SubnGet(self,payload,path,attributeModifier=0):
        ID = payload.MAD_ATTRIBUTE_ID;
        meth = payload.MAD_SUBNGET;
        if ID == IBA.SMPGUIDInfo.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SAGUIDInfoRecord());
            req.LID = self.get_path_lid(path);
            req.blockNum = attributeModifier;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     lambda x:x.GUIDInfo);
        if ID == IBA.SMPLinearForwardingTable.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SALinearForwardingTableRecord());
            req.LID = self.get_path_lid(path);
            req.blockNum = attributeModifier;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     (lambda x:x.linearForwardingTable,
                                      self._sa_error));
        if ID == IBA.SMPMulticastForwardingTable.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SAMulticastForwardingTableRecord());
            req.LID = self.get_path_lid(path);
            req.blockNum = attributeModifier & ((1<<9)-1);
            req.position = (attributeModifier >> 12) & 0xF;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     (lambda x:x.multicastForwardingTable,
                                      self._sa_error));
        if ID == IBA.SMPNodeDescription.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SANodeRecord());
            req.LID = self.get_path_lid(path);
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     self._finish_nodedesc);
        if ID == IBA.SMPNodeInfo.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SANodeRecord());
            req.LID = self.get_path_lid(path);
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     self._finish_nodeinfo);

        if ID == IBA.SMPPKeyTable.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SAPKeyTableRecord());
            req.LID = self.get_path_lid(path);
            nt = getattr(path,"_cached_node_type",None);
            if nt is None or nt == IBA.NODE_SWITCH:
                req.portNum = attributeModifier >> 16;
            req.blockNum = attributeModifier & 0xFFFF;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     (lambda x:x.PKeyTable,
                                      self._sa_error));

        if ID == IBA.SMPPortInfo.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SAPortInfoRecord());
            req.endportLID = self.get_path_lid(path);
            if (attributeModifier == 0 and
                getattr(path,"_cached_node_type",None) != IBA.NODE_SWITCH):
                # This can mean 'whatever port' or it can mean 'switch port 0'
                # If we don't know the node type then do a get table and
                # figure it out.
                return self._subn_adm_do(req,self.sa_path,0,
                                         req.MAD_SUBNADMGETTABLE,
                                         self._finish_port_info_attr0);

            req.portNum = attributeModifier;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     lambda x:x.portInfo);
        if ID == IBA.SMPSLToVLMappingTable.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SASLToVLMappingTableRecord());
            req.LID = self.get_path_lid(path);
            req.inputPortNum = (attributeModifier >> 8) & 0xFF;
            req.outputPortNum = attributeModifier & 0xFF;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     (lambda x:x.SLToVLMappingTable,
                                      self._sa_error));
        if ID == IBA.SMPSMInfo.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SASMInfoRecord());
            req.LID = self.get_path_lid(path);
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     lambda x:x.SMInfo);
        if ID == IBA.SMPSwitchInfo.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SASwitchInfoRecord());
            req.LID = self.get_path_lid(path);
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     lambda x:x.switchInfo);
        if ID == IBA.SMPVLArbitrationTable.MAD_ATTRIBUTE_ID:
            req = IBA.ComponentMask(IBA.SAVLArbitrationTableRecord());
            req.LID = self.get_path_lid(path);
            req.outputPortNum = attributeModifier & 0xFFFF;
            req.blockNum = (attributeModifier >> 16) & 0xFFFF;
            return self._subn_adm_do(req,self.sa_path,0,
                                     req.MAD_SUBNADMGET,
                                     (lambda x:x.VLArbitrationTable,
                                      self._sa_error));

        return self._parent.SubnGet(payload,path,attributeModifier);