Exemple #1
0
 def test_create_cq_ex_bad_flow(self):
     """
     Test ibv_create_cq_ex() with wrong comp_vector / number of cqes
     """
     for ctx, attr, attr_ex in self.devices:
         for i in range(10):
             cq_attrs_ex = CqInitAttrEx(cqe=0, wc_flags=0, comp_mask=0, flags=0)
             max_cqe = attr.max_cqe
             cq_attrs_ex.cqe = max_cqe + 1 + int(100 * random.random())
             try:
                 CQEX(ctx, cq_attrs_ex)
             except PyverbsError as ex:
                 assert 'Failed to create extended CQ' in ex.args[0]
                 assert ' Errno: 22' in ex.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with {c} CQEs while device\'s max CQE={dc}'.
                     format(c=cq_attrs_ex.cqe, dc=max_cqe))
             comp_channel = random.randint(ctx.num_comp_vectors, 100)
             cq_attrs_ex.comp_vector = comp_channel
             cq_attrs_ex.cqe = get_num_cqes(attr)
             try:
                 CQEX(ctx, cq_attrs_ex)
             except PyverbsError as ex:
                 assert 'Failed to create extended CQ' in ex.args[0]
                 assert ' Errno: 22' in ex.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with comp_vector={c} while device\'s num_comp_vectors={dc}'.
                     format(c=comp_channel, dc=ctx.num_comp_vectors))
def create_dv_cq(res):
    """
    Create Mlx5 DV CQ.
    :param res: An instance of BaseResources.
    :return: None
    """
    dvcq_init_attr = Mlx5DVCQInitAttr()
    if res.cqe_comp_res_format:
        dvcq_init_attr.cqe_comp_res_format = res.cqe_comp_res_format
        dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE
        # Check CQE compression capability
        cqe_comp_caps = res.ctx.query_mlx5_device().cqe_comp_caps
        if not (cqe_comp_caps['supported_format'] & res.cqe_comp_res_format) or \
                not cqe_comp_caps['max_num']:
            cqe_comp_str = cqe_comp_to_str(res.cqe_comp_res_format)
            raise unittest.SkipTest(
                f'CQE compression {cqe_comp_str} is not supported')
    if res.flags:
        dvcq_init_attr.flags = res.flags
        dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_FLAGS
    if res.cqe_size:
        dvcq_init_attr.cqe_size = res.cqe_size
        dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_CQE_SIZE
    try:
        res.cq = Mlx5CQ(res.ctx, CqInitAttrEx(), dvcq_init_attr)
    except PyverbsRDMAError as ex:
        if ex.error_code == errno.EOPNOTSUPP:
            raise unittest.SkipTest('Create Mlx5DV CQ is not supported')
        raise ex
Exemple #3
0
 def create_cq(self):
     cq_init_attr = CqInitAttrEx(wc_flags=e.IBV_WC_EX_WITH_TM_INFO | e.IBV_WC_STANDARD_FLAGS)
     try:
         self.cq = CQEX(self.ctx, cq_init_attr)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             raise unittest.SkipTest('Extended CQ is not supported')
         raise ex
Exemple #4
0
    def test_create_cq_ex(self):
        """
        Test ibv_create_cq_ex()
        """
        cq_init_attrs_ex = CqInitAttrEx(cqe=10,
                                        wc_flags=0,
                                        comp_mask=0,
                                        flags=0)
        if self.attr_ex.raw_packet_caps & e.IBV_RAW_PACKET_CAP_CVLAN_STRIPPING:
            cq_init_attrs_ex.wc_flags = e.IBV_WC_EX_WITH_CVLAN
            CQEX(self.ctx, cq_init_attrs_ex)

        for flag in list(e.ibv_create_cq_wc_flags):
            cq_init_attrs_ex.wc_flags = flag
            try:
                cq_ex = CQEX(self.ctx, cq_init_attrs_ex)
                cq_ex.close()
            except PyverbsRDMAError as ex:
                if ex.error_code != errno.EOPNOTSUPP:
                    raise ex

        cq_init_attrs_ex.wc_flags = 0
        cq_init_attrs_ex.comp_mask = e.IBV_CQ_INIT_ATTR_MASK_FLAGS
        attr_flags = list(e.ibv_create_cq_attr_flags)
        for flag in attr_flags:
            cq_init_attrs_ex.flags = flag
            try:
                cq_ex = CQEX(self.ctx, cq_init_attrs_ex)
                cq_ex.close()
            except PyverbsRDMAError as ex:
                if ex.error_code != errno.EOPNOTSUPP:
                    raise ex
Exemple #5
0
    def test_create_cq_ex_bad_flow(self):
        """
        Test ibv_create_cq_ex() with wrong comp_vector / number of cqes
        """
        cq_attrs_ex = CqInitAttrEx(cqe=self.max_cqe + 1,
                                   wc_flags=0,
                                   comp_mask=0,
                                   flags=0)
        with self.assertRaises(PyverbsRDMAError) as ex:
            CQEX(self.ctx, cq_attrs_ex)
        if ex.exception.error_code == errno.EOPNOTSUPP:
            raise unittest.SkipTest('Create Extended CQ is not supported')
        self.assertEqual(ex.exception.error_code, errno.EINVAL)

        cq_attrs_ex = CqInitAttrEx(10, wc_flags=0, comp_mask=0, flags=0)
        cq_attrs_ex.comp_vector = self.ctx.num_comp_vectors + 1
        with self.assertRaises(PyverbsRDMAError) as ex:
            CQEX(self.ctx, cq_attrs_ex)
        self.assertEqual(ex.exception.error_code, errno.EINVAL)
Exemple #6
0
def create_ex_cq(res):
    """
    Create an Extended CQ using res's context and assign it to res's cq member.
    IBV_WC_STANDARD_FLAGS is used for WC flags to avoid support differences
    between devices.
    :param res: An instance of TrafficResources
    """
    wc_flags = e.IBV_WC_STANDARD_FLAGS
    cia = CqInitAttrEx(cqe=2000, wc_flags=wc_flags)
    res.cq = CQEX(res.ctx, cia)
Exemple #7
0
 def create_cq(self):
     wc_flags = e.IBV_WC_STANDARD_FLAGS
     cia = CqInitAttrEx(cqe=2000, wc_flags=wc_flags, parent_domain=self.pd,
                        comp_mask=e.IBV_CQ_INIT_ATTR_MASK_FLAGS |
                                  e.IBV_CQ_INIT_ATTR_MASK_PD)
     try:
         self.cq = CQEX(self.ctx, cia)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             raise unittest.SkipTest('Extended CQ with Parent Domain is not supported')
         raise ex
 def create_cq(self):
     """
     Initializes self.cq with a dv_cq
     :return: None
     """
     dvcq_init_attr = Mlx5DVCQInitAttr()
     try:
         self.cq = Mlx5CQ(self.ctx, CqInitAttrEx(), dvcq_init_attr)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             raise unittest.SkipTest('Create Mlx5DV CQ is not supported')
         raise ex
Exemple #9
0
 def create_cq(self):
     """
     Create an Extended CQ.
     """
     wc_flags = e.IBV_WC_STANDARD_FLAGS | self.wc_flags
     cia = CqInitAttrEx(cqe=self.num_msgs, wc_flags=wc_flags)
     try:
         self.cq = CQEX(self.ctx, cia)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             raise unittest.SkipTest('Create Extended CQ is not supported')
         raise ex
Exemple #10
0
 def _create_rdma_objects(self):
     cq = CQ(self.pd_res.ctx, 100, None, None, 0)
     dev_attr = self.pd_res.ctx.query_device()
     qp_cap = u.random_qp_cap(dev_attr)
     qia = QPInitAttr(scq=cq, rcq=cq, cap=qp_cap)
     qia.qp_type = e.IBV_QPT_RC
     QP(self.pd_res.parent_domain, qia)
     srq_init_attr = SrqInitAttr(SrqAttr())
     SRQ(self.pd_res.parent_domain, srq_init_attr)
     cq_init_attrs_ex = CqInitAttrEx(
         comp_mask=e.IBV_CQ_INIT_ATTR_MASK_PD,
         parent_domain=self.pd_res.parent_domain)
     CQEX(self.pd_res.ctx, cq_init_attrs_ex)
Exemple #11
0
def create_ex_cq(res):
    """
    Create an Extended CQ using res's context and assign it to res's cq member.
    IBV_WC_STANDARD_FLAGS is used for WC flags to avoid support differences
    between devices.
    :param res: An instance of TrafficResources
    """
    wc_flags = e.IBV_WC_STANDARD_FLAGS
    cia = CqInitAttrEx(cqe=2000, wc_flags=wc_flags)
    try:
        res.cq = CQEX(res.ctx, cia)
    except PyverbsRDMAError as ex:
        if ex.error_code == errno.EOPNOTSUPP:
            raise unittest.SkipTest('Create Extended CQ is not supported')
        raise ex
 def _create_ex_cq(self, timestamp=None):
     """
     Create an Extended CQ.
     :param timestamp: If set, the timestamp type to use.
     """
     wc_flags = e.IBV_WC_STANDARD_FLAGS
     if timestamp:
         wc_flags |= timestamp
     cia = CqInitAttrEx(cqe=self.num_msgs, wc_flags=wc_flags)
     try:
         cq = CQEX(self.ctx, cia)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             raise unittest.SkipTest('Create Extended CQ is not supported')
         raise ex
     return cq
Exemple #13
0
def get_attrs_ex(ctx):
    cqe = get_num_cqes(ctx)
    sample = random.sample(list(e.ibv_create_cq_wc_flags),
                           random.randint(0, 11))
    wc_flags = 0
    for flag in sample:
        wc_flags |= flag
    comp_mask = random.choice([0, e.IBV_CQ_INIT_ATTR_MASK_FLAGS])
    flags = 0
    if comp_mask is not 0:
        sample = random.sample(list(e.ibv_create_cq_attr_flags),
                               random.randint(0, 2))
        for flag in sample:
            flags |= flag
    return CqInitAttrEx(cqe=cqe,
                        wc_flags=wc_flags,
                        comp_mask=comp_mask,
                        flags=flags)
Exemple #14
0
def create_dv_cq(res):
    """
    Create Mlx5 DV CQ.
    :param res: An instance of BaseResources.
    :return: None
    """
    dvcq_init_attr = Mlx5DVCQInitAttr()
    if res.cqe_comp_res_format:
        dvcq_init_attr.cqe_comp_res_format = res.cqe_comp_res_format
        dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE
    if res.flags:
        dvcq_init_attr.flags = res.flags
        dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_FLAGS
    if res.cqe_size:
        dvcq_init_attr.cqe_size = res.cqe_size
        dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_CQE_SIZE
    try:
        res.cq = Mlx5CQ(res.ctx, CqInitAttrEx(), dvcq_init_attr)
    except PyverbsRDMAError as ex:
        if ex.error_code == errno.EOPNOTSUPP:
            raise unittest.SkipTest('Create Mlx5DV CQ is not supported')
        raise ex
Exemple #15
0
 def test_destroy_cq_ex(self):
     """
     Test ibv_destroy_cq() for extended CQs
     """
     for ctx, attr, attr_ex in self.devices:
         cqe = get_num_cqes(attr)
         cq_init_attrs_ex = CqInitAttrEx(cqe=cqe,
                                         wc_flags=0,
                                         comp_mask=0,
                                         flags=0)
         wc_flags = get_cq_flags_with_caps()
         if attr_ex.raw_packet_caps & e.IBV_RAW_PACKET_CAP_CVLAN_STRIPPING == 0:
             wc_flags.remove(e.IBV_WC_EX_WITH_CVLAN)
         for f in wc_flags:
             cq_init_attrs_ex.wc_flags = f
             with CQEX(ctx, cq_init_attrs_ex) as cq:
                 cq.close()
         # For the wc_flags that have no capability bit, we're not raising
         # an exception for EOPNOTSUPPORT
         wc_flags = get_cq_flags_with_no_caps()
         for f in wc_flags:
             cq_init_attrs_ex.wc_flags = f
             try:
                 with CQEX(ctx, cq_init_attrs_ex) as cq:
                     cq.close()
             except PyverbsError as ex:
                 assert 'Failed to create extended CQ' in ex.args[0]
                 assert ' Errno: 95' in ex.args[0]
         cq_init_attrs_ex.wc_flags = 0
         cq_init_attrs_ex.comp_mask = e.IBV_CQ_INIT_ATTR_MASK_FLAGS
         attr_flags = list(e.ibv_create_cq_attr_flags)
         for f in attr_flags:
             cq_init_attrs_ex.flags = f
             try:
                 with CQEX(ctx, cq_init_attrs_ex) as cq:
                     cq.close()
             except PyverbsError as ex:
                 assert 'Failed to create extended CQ' in ex.args[0]
                 assert ' Errno: 95' in ex.args[0]
Exemple #16
0
def get_attrs_ex(attr, attr_ex):
    cqe = get_num_cqes(attr)
    wc_flags = list(e.ibv_create_cq_wc_flags)
    # Flow tag is not always supported, doesn't have a capability bit to check
    wc_flags.remove(e.IBV_WC_EX_WITH_FLOW_TAG)
    if attr_ex.tm_caps.max_ops == 0:
        wc_flags.remove(e.IBV_WC_EX_WITH_TM_INFO)
    if attr_ex.raw_packet_caps & e.IBV_RAW_PACKET_CAP_CVLAN_STRIPPING == 0:
        wc_flags.remove(e.IBV_WC_EX_WITH_CVLAN)
    sample = u.sample(wc_flags)
    wc_flags = 0
    for flag in sample:
        wc_flags |= flag
    comp_mask = random.choice([0, e.IBV_CQ_INIT_ATTR_MASK_FLAGS])
    flags = 0
    if comp_mask is not 0:
        attr_flags = list(e.ibv_create_cq_attr_flags)
        sample = u.sample(attr_flags)
        for flag in sample:
            flags |= flag
    return CqInitAttrEx(cqe=cqe,
                        wc_flags=wc_flags,
                        comp_mask=comp_mask,
                        flags=flags)