def __init__(self, lif, eq_id, num_eqes): super().__init__() self.Clone(Store.templates.Get('QSTATE_RDMA_EQ')) self.lif = lif self.id = eq_id self.int_num = resmgr.InterruptAllocator.get() self.GID("EQ%04d" % self.id) self.num_eq_wqes = self.__roundup_to_pow_2(num_eqes) self.eqwqe_size = self.__get_eqwqe_size() self.eq_size = self.num_eq_wqes * self.eqwqe_size self.intr_tbl_addr = 0 self.eqe_base_addr = None self.eqe_base_addr_phy = None self.eq = lif.GetQ('RDMA_EQ', self.id) if (self.eq is None): assert (0) # create eq slab self.eq_slab = slab.SlabObject(self.lif, self.eq_size, True) self.lif.AddSlab(self.eq_slab) self.Show() return
def __init__(self, ep, cq_id, num_wqes, pg_sz, privileged=False, lif=None): super().__init__() self.Clone(Store.templates.Get('QSTATE_RDMA_CQ')) self.privileged = privileged self.num_cq_wqes = self.__roundup_to_pow_2(num_wqes) self.cqwqe_size = self.__get_cqwqe_size() self.cq_size = self.num_cq_wqes * self.cqwqe_size if privileged is True: self.lif = lif self.ep = None self.remote = False self.hostmem_pg_size = self.cq_size else: self.lif = ep.intf.lif self.ep = ep self.remote = ep.remote self.hostmem_pg_size = pg_sz self.id = cq_id self.GID("CQ%04d" % self.id) # Every 8 CQs share a EQ self.eq_id = int((self.id + 7) / 8) if not self.remote: self.cq = self.lif.GetQ('RDMA_CQ', self.id) self.eq = self.lif.GetQ('RDMA_EQ', self.eq_id) if (self.cq is None or self.eq is None): assert (0) # create cq slab if self.privileged is True: self.cq_slab = slab.SlabObject(self.lif, self.cq_size, True) self.lif.AddSlab(self.cq_slab) else: self.cq_slab = slab.SlabObject(self.ep.intf.lif, self.cq_size) self.ep.AddSlab(self.cq_slab) self.Show() return
def __init__(self, lif, aq_id, num_aqe, hostmem_pg_size): super().__init__() self.Clone(Store.templates.Get('ADMIN_RDMA')) self.lif = lif self.id = aq_id self.GID("AQ%04d" % self.id) self.hostmem_pg_size = hostmem_pg_size self.num_aq_wqes = self.__roundup_to_pow_2(num_aqe) self.aqwqe_size = self.__get_aqwqe_size() self.aq_size = self.num_aq_wqes * self.aqwqe_size self.aq_base_addr = None self.aq_base_addr_phy = None # AdminQ IDs start from 1 for RDMA self.aq = lif.GetQ('RDMA_AQ', self.id) if (self.aq is None): assert (0) self.cq = lif.GetQ('RDMA_CQ', lif.rdma_admin_cq_id) if (self.cq is None): assert (0) self.eq = lif.GetQ('RDMA_EQ', lif.rdma_async_eq_id) # Sharing Async EQ with AQ if (self.eq is None): assert (0) self.aq_slab = slab.SlabObject(self.lif, self.aq_size, True) self.lif.AddSlab(self.aq_slab) self.Show() return
def __init__(self, pd, qp_id, spec, sges): super().__init__() self.Clone(Store.templates.Get('QPAIR_RDMA')) self.pd = pd self.remote = pd.remote self.id = qp_id self.GID("QP%04d" % self.id) self.spec = spec self.lif = pd.ep.intf.lif if self.remote is False else None self.pd = pd self.svc = spec.service self.pmtu = spec.pmtu self.hostmem_pg_size = spec.hostmem_pg_size self.atomic_enabled = spec.atomic_enabled self.sq_in_nic = spec.sq_in_nic self.rq_in_nic = spec.rq_in_nic self.congestion_mgmt_type = spec.congestion_mgmt_type self.modify_qp_oper = 0 self.qstate = 0 self.q_key = 0 self.dst_qp = 0 self.sq_tbl_pos = -1 self.rq_tbl_pos = -1 self.rsq_tbl_pos = -1 self.rrq_tbl_pos = -1 self.HdrTemplate = None # we can use the following attributes to filter testcases self.tiny = False self.max_sge_8 = False self.max_sge_16 = False self.spec_en = True if sges <= 2: self.tiny = True elif sges > 2 and sges <= 4: self.tiny = False elif sges > 4 and sges <= 8: self.max_sge_8 = True elif sges > 8 and sges <= 16: self.max_sge_8 = True self.max_sge_16 = True elif sges > 16: self.spec_en = False self.max_sge_8 = True self.max_sge_16 = True # Pass the same spec_en value to both SQ and RQ self.flags = (self.spec_en << 8) | (self.spec_en << 9) | ( spec.sq_in_nic << 13) | (spec.rq_in_nic << 14) self.num_sq_sges = sges self.num_sq_wqes = self.__roundup_to_pow_2(spec.num_sq_wqes) self.num_rrq_wqes = self.__roundup_to_pow_2(spec.num_rrq_wqes) self.log_sq_size = self.__get_log_size(self.num_sq_wqes) self.num_rq_sges = sges self.num_rq_wqes = self.__roundup_to_pow_2(spec.num_rq_wqes) self.num_rsq_wqes = self.__roundup_to_pow_2(spec.num_rsq_wqes) self.log_rq_size = self.__get_log_size(self.num_rq_wqes) self.sqwqe_size = self.__get_sqwqe_size() self.rqwqe_size = self.__get_rqwqe_size() self.rrqwqe_size = self.__get_rrqwqe_size() self.rsqwqe_size = self.__get_rsqwqe_size() self.sq_size = self.num_sq_wqes * self.sqwqe_size self.rq_size = self.num_rq_wqes * self.rqwqe_size self.rrq_size = self.num_rrq_wqes * self.rrqwqe_size self.rsq_size = self.num_rsq_wqes * self.rsqwqe_size if not self.remote: self.sq = pd.ep.intf.lif.GetQ('RDMA_SQ', self.id) self.rq = pd.ep.intf.lif.GetQ('RDMA_RQ', self.id) if (self.sq is None or self.rq is None): assert (0) self.cq_id = pd.ep.cqs.Get("CQ%04d" % self.id).id self.eq_id = pd.ep.cqs.Get("CQ%04d" % self.id).eq_id #logger.info('QP: %s PD: %s Remote: %s intf: %s lif: %s' %(self.GID(), self.pd.GID(), self.remote, pd.ep.intf.GID(), pd.ep.intf.lif.GID())) self.tx = pd.ep.intf.lif.GetQt('TX') self.rx = pd.ep.intf.lif.GetQt('RX') if (self.tx is None or self.rx is None): assert (0) # for now map both sq/rq cq to be same self.sq_cq = pd.ep.intf.lif.GetQ('RDMA_CQ', self.cq_id) self.rq_cq = pd.ep.intf.lif.GetQ('RDMA_CQ', self.cq_id) if (self.sq_cq is None or self.rq_cq is None): assert (0) # allocating one EQ for one PD self.eq = pd.ep.intf.lif.GetQ('RDMA_EQ', self.eq_id) if (self.eq is None): assert (0) # create sq/rq slabs self.sq_slab = slab.SlabObject(self.pd.ep.intf.lif, self.sq_size) self.rq_slab = slab.SlabObject(self.pd.ep.intf.lif, self.rq_size) self.hdr_slab = slab.SlabObject(self.pd.ep.intf.lif, 0) self.pd.ep.AddSlab(self.sq_slab) self.pd.ep.AddSlab(self.rq_slab) self.pd.ep.AddSlab(self.hdr_slab) # create sq/rq mrs #self.sq_mr = mr.MrObject(self.pd, self.sq_slab) #self.rq_mr = mr.MrObject(self.pd, self.rq_slab) #self.pd.AddMr(self.sq_mr) #self.pd.AddMr(self.rq_mr) if (GlobalOptions.dryrun): dcqcn_data = bytes(DCQCN_CB_T_SIZE_BYTES) self.dcqcn_data = RdmaDCQCNstate(dcqcn_data) self.Show() return
def Init(self, tenant, spec, namespace=None): if namespace: self.id = namespace.get() else: self.id = resmgr.LifIdAllocator.get() self.GID("Lif%d" % self.id) self.status = haldefs.interface.IF_STATUS_UP self.hw_lif_id = -1 self.qstate_base = {} self.promiscuous = False self.allmulticast = False self.pds = [] self.c_lib_name = getattr(spec, 'c_lib', None) if self.c_lib_name: self.c_lib = clibs.LoadCLib(self.c_lib_name) if self.c_lib: self.c_lib_config = self.c_lib[self.c_lib_name + '_config'] self.c_lib_config.argtypes = [ctypes.POINTER(QInfoStruct)] self.c_lib_config.restype = None else: self.c_lib = None if hasattr(spec, 'rdma') and spec.rdma.enable: self.enable_rdma = spec.rdma.enable self.rdma_max_pt_entries = spec.rdma.max_pt_entries self.rdma_max_keys = spec.rdma.max_keys self.rdma_max_ahs = spec.rdma.max_ahs self.hostmem_pg_size = spec.rdma.hostmem_pg_size self.hbm_barmap_entries = (int(spec.rdma.hbm_barmap_size / spec.rdma.hostmem_pg_size)) self.rdma_tbl_pos = BitArray(length=self.rdma_max_pt_entries) self.hbm_tbl_pos = BitArray(length=self.hbm_barmap_entries) self.rdma_async_eq_id = 0 self.rdma_admin_aq_id = 1 self.rdma_admin_cq_id = 0 else: self.enable_rdma = False self.rdma_max_pt_entries = 0 self.rdma_max_keys = 0 self.rdma_max_ahs = 0 self.hbm_barmap_entries = 0 self.hostmem_pg_size = 0 self.rdma_pt_base_addr = 0 self.rdma_kt_base_addr = 0 self.rdma_dcqcn_profile_base_addr = 0 self.rdma_at_base_addr = 0 if hasattr(spec, 'nvme') and spec.nvme.enable: self.enable_nvme = spec.nvme.enable self.nvme_lif = nvme_lif.NvmeLifObject(self, spec.nvme) else: self.enable_nvme = False self.vlan_strip_en = False self.vlan_insert_en = False self.queue_types = objects.ObjectDatabase() self.obj_helper_q = queue_type.QueueTypeObjectHelper() self.obj_helper_q.Generate(self, spec) self.queue_types.SetAll(self.obj_helper_q.queue_types) self.queue_types_list = self.obj_helper_q.queue_types self.queue_list = [] for q_type in self.queue_types_list: for queue in q_type.queues.GetAll(): self.queue_list.append(queue) # RDMA per LIF allocators if self.enable_rdma: # QP 0, 1 are special QPs self.qpid_allocator = objects.TemplateFieldObject( "range/2/" + str(spec.rdma.max_qp)) # AQ ID 0 is owned by ETH self.aqid_allocator = objects.TemplateFieldObject( "range/1/" + str(spec.rdma.max_aq)) # Reserve CQ 0, 1 for special QPs, AQ self.cqid_allocator = objects.TemplateFieldObject( "range/2/" + str(spec.rdma.max_cq)) self.eqid_allocator = objects.TemplateFieldObject( "range/0/" + str(spec.rdma.max_eq)) self.pd_allocator = objects.TemplateFieldObject( "range/0/" + str(spec.rdma.max_pd)) self.mr_key_allocator = objects.TemplateFieldObject( "range/1/" + str(spec.rdma.max_mr)) self.slab_allocator = objects.TemplateFieldObject("range/0/2048") self.kslab_allocator = objects.TemplateFieldObject("range/0/2048") # Generate RDMA LIF owned resources self.slabs = objects.ObjectDatabase() # Generate KernelSlab of 4KB and 10 MB for FRPMR self.kslab_4KB = slab.SlabObject(self, 4096, True) self.obj_helper_slab = slab.SlabObjectHelper() #slab_spec = spec.rdma.slab.Get(Store) #self.obj_helper_slab.Generate(self, slab_spec) #self.slabs.SetAll(self.obj_helper_slab.slabs) # Create EQs for RDMA LIF self.eqs = objects.ObjectDatabase() self.obj_helper_eq = eq.EqObjectHelper() self.obj_helper_eq.Generate(self, spec.rdma.max_eq, spec.rdma.max_eqe) if len(self.obj_helper_eq.eqs): self.eqs.SetAll(self.obj_helper_eq.eqs) # Create CQ 0 for adminQ logger.info("Creating 1 Cqs. for LIF:%s" % (self.GID())) # Hardcode CQ 0 for AQ # Page size is calculated as max_cqe * cqe_size by the CQ for privileged resources cq_id = 0 self.cq = cqs.CqObject(None, cq_id, spec.rdma.max_cqe, 0, True, self) # Create AdminQ logger.info("Creating 1 Aqs. for LIF:%s" % (self.GID())) aq_id = self.GetAqid() self.aq = aqs.AqObject(self, aq_id, spec.rdma.max_aqe, spec.rdma.hostmem_pg_size) self.dcqcn_config_spec = spec.rdma.dcqcn_config.Get(Store) if hasattr(spec, 'rss'): self.rss_type = ( haldefs.interface.LifRssType.Value("RSS_TYPE_IPV4") | haldefs.interface.LifRssType.Value("RSS_TYPE_IPV4_TCP") | haldefs.interface.LifRssType.Value("RSS_TYPE_IPV4_UDP") | haldefs.interface.LifRssType.Value("RSS_TYPE_IPV6") | haldefs.interface.LifRssType.Value("RSS_TYPE_IPV6_TCP") | haldefs.interface.LifRssType.Value("RSS_TYPE_IPV6_UDP")) self.rss_key = array.array('B', toeplitz.toeplitz_msft_key) self.rss_indir = array.array('B', [0] * 128) else: self.rss_type = haldefs.interface.LifRssType.Value("RSS_TYPE_NONE") self.rss_key = array.array('B', toeplitz.toeplitz_msft_key) self.rss_indir = array.array('B', [0] * 128) self.tenant = tenant self.spec = spec self.tx_qos_class = None self.rx_qos_class = None if self.tenant.IsQosEnabled(): self.tx_qos_class = getattr(spec, 'tx_qos_class', None) self.rx_qos_class = getattr(spec, 'rx_qos_class', None) if self.tx_qos_class: self.tx_qos_class = Store.objects.Get(self.tx_qos_class) if self.rx_qos_class: self.rx_qos_class = Store.objects.Get(self.rx_qos_class) self.Show()