def GrpcRead(self, node): # read all via grpc msg = self.GetGrpcReadAllMessage(node) resp = api.client[node].Get(self.ObjType, [msg]) if not self.ValidateGrpcRead(node, resp): logger.critical("Object validation failed for %s" % (self.ObjType)) return False return True
def ReadObjects(self, node): logger.info(f"Reading {self.ObjType.name} Objects from {node}") msg = self.GetGrpcReadAllMessage(node) resp = api.client[node].Get(api.ObjectTypes.INTERFACE, [msg]) result = self.ValidateObjects(resp, node) if result is False: logger.critical("INTERFACE object validation failed!!!") return False return True
def GetAllConfigs(self, count, status): config_object = ConfigObject(self._cfg_meta, self) ret_status, _ = config_object.process(ConfigObjectMeta.GETALL) if ret_status != status: logger.critical("Status code does not match expected : %s," "actual : %s" % (status, ret_status)) if ConfigObjectMeta.GETALL not in self._ignore_ops: return False return True
def PdsctlRead(self, node): # read all via pdsctl # TODO: unify pdsctl code & get rid of this import if utils.IsDol(): import apollo.test.utils.pdsctl as pdsctl else: import iota.test.apulu.utils.pdsctl as pdsctl ret, op = pdsctl.GetObjects(node, self.GetPdsctlObjectName(), self.args) if not self.ValidatePdsctlRead(node, ret, op): logger.critical("Object validation failed for ", self.ObjType, ret, op) return False return True
def ReadObjects(self, node): if utils.IsPipelineApulu(): cfgObjects = self.__underlay_objs[node].values() else: cfgObjects = self.Objects(node) logger.info(f"Reading {len(cfgObjects)} NEXTHOP objects in {node}") result = list(map(lambda x: x.Read(), cfgObjects)) if not all(result): logger.critical( f"Reading {len(cfgObjects)} {self.ObjType.name} Objects FAILED in {node}" ) return False return True
def UpdateConfigs(self, count, status): print("Updating configuration for %s, count : %d" % (self, count)) for config_object in self._config_objects: ret_status, _ = config_object.process(ConfigObjectMeta.UPDATE, ext_refs={}) if ret_status != status: logger.critical("Status code does not match expected : %s," "actual : %s" % (status, ret_status)) if ConfigObjectMeta.UPDATE not in self._ignore_ops: return False config_object._status = ConfigObject._CREATED self.num_update_ops += 1 return True
def PrepareHALRequestSpec(self, req_spec): req_spec.lif_handle = 0 # HW LIF ID is not known in DOL. Assume it is filled in by hal::LifCreate. req_spec.type_num = self.queue_type.type req_spec.qid = 0 # HACK if self.queue_type.purpose == "LIF_QUEUE_PURPOSE_TX": req_spec.queue_state = bytes( EthTxQstate( host=1, total=3, enable=1, color=1, host_queue=1, p_index1=0xffff, c_index1=0xffff, lg2_desc_sz=log2(ctypes.sizeof(EthTxDescriptor)), lg2_cq_desc_sz=log2(ctypes.sizeof(EthTxCqDescriptor)), lg2_sg_desc_sz=log2(ctypes.sizeof(EthTxSgDescriptor)))) req_spec.label.handle = "p4plus" req_spec.label.prog_name = "txdma_stage0.bin" req_spec.label.label = "eth_tx_stage0" elif self.queue_type.purpose == "LIF_QUEUE_PURPOSE_RX": req_spec.queue_state = bytes( EthRxQstate( host=1, total=3, enable=1, color=1, host_queue=1, p_index1=0xffff, c_index1=0xffff, lg2_desc_sz=log2(ctypes.sizeof(EthRxDescriptor)), lg2_cq_desc_sz=log2(ctypes.sizeof(EthRxCqDescriptor)), lg2_sg_desc_sz=log2(ctypes.sizeof(EthRxSgDescriptor)), sg_max_elems=8)) req_spec.label.handle = "p4plus" req_spec.label.prog_name = "rxdma_stage0.bin" req_spec.label.label = "eth_rx_stage0" elif self.queue_type.purpose == "LIF_QUEUE_PURPOSE_ADMIN": req_spec.queue_state = bytes( AdminQstate(host=1, total=1, enable=1, color=1, host_queue=1)) req_spec.label.handle = "p4plus" req_spec.label.prog_name = "txdma_stage0.bin" req_spec.label.label = "adminq_stage0" elif self.queue_type.purpose == "LIF_QUEUE_PURPOSE_EQ": # not a real qstate, will do init in set_ring_size req_spec.queue_state = b'\0' * 8 else: logger.critical( "Unable to set program information for Queue Type %s" % self.queue_type.purpose) raise NotImplementedError
def DeleteConfigs(self, count, status): print("Deleting configuration for %s, count : %d" % (self, count)) for config_object in self._config_objects: if config_object.is_dol_config_modified: continue if config_object._status == ConfigObject._DELETED: continue ret_status, _ = config_object.process(ConfigObjectMeta.DELETE) if ret_status and ret_status != status: logger.critical("Status code does not match expected : %s," "actual : %s" % (status, ret_status)) if config_object.is_dol_created or ConfigObjectMeta.DELETE not in self._ignore_ops: return False config_object._status = ConfigObject._DELETED self.num_delete_ops += 1 return True
def VerifyConfigs(self, count, status): print("Verifying configuration for %s, count : %d" % (self, count)) for config_object in self._config_objects: if config_object.is_dol_config_modified: continue ret_status, _ = config_object.process(ConfigObjectMeta.GET) if ret_status != status: if ConfigObjectMeta.GET not in self._ignore_ops: return False else: return True logger.critical("Status code does not match expected : %s," "actual : %s" % (status, ret_status)) return self.num_read_ops += 1 return True
def qstate(self): if self._qstate is None: if self.queue_type.purpose == "LIF_QUEUE_PURPOSE_TX": self._qstate = EthTxQstateObject(addr=self.GetQstateAddr()) elif self.queue_type.purpose == "LIF_QUEUE_PURPOSE_RX": self._qstate = EthRxQstateObject(addr=self.GetQstateAddr()) elif self.queue_type.purpose == "LIF_QUEUE_PURPOSE_EQ": self._qstate = EthEqQstateObject(addr=self.GetQstateAddr()) elif self.queue_type.purpose == "LIF_QUEUE_PURPOSE_ADMIN": self._qstate = AdminQstateObject(addr=self.GetQstateAddr()) else: logger.critical( "Unable to initialize Qstate for Queue Type %s" % self.queue_type.purpose) raise NotImplementedError logger.info( "Loading Qstate: Lif=%s QType=%s QID=%s Addr=0x%x Size=%s" % (self.queue_type.lif.id, self.queue_type.type, self.id, self.GetQstateAddr(), self.queue_type.size)) return self._qstate
def CreateConfigObject(self, status, ext_refs={}, external_constraints=None): config_object = ConfigObject(self._cfg_meta, self) ret_status, _ = config_object.process( ConfigObjectMeta.CREATE, ext_refs=ext_refs, external_constraints=external_constraints) if ret_status != status: logger.critical("Status code does not match expected : %s," "actual : %s" % (status, ret_status)) config_object._status = ConfigObject._DELETED if ConfigObjectMeta.CREATE not in self._ignore_ops: assert False else: return config_object else: config_object._status = ConfigObject._CREATED return config_object