Example #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 PyverbsRDMAError as ex:
                 if ex.error_code == errno.EOPNOTSUPP:
                     raise unittest.SkipTest('Create extended CQ is not supported')
                 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 PyverbsRDMAError as ex:
                 if ex.error_code == errno.EOPNOTSUPP:
                     raise unittest.SkipTest('Create extended CQ is not supported')
                 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))
Example #2
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 = get_attrs_ex(attr, attr_ex)
             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 e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.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 e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.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))
Example #3
0
 def test_create_cq_ex_bad_flow():
     """
     Test ibv_create_cq_ex() with wrong comp_vector / number of cqes
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attrs_ex = get_attrs_ex(ctx)
             max_cqe = ctx.query_device().max_cqe
             attrs_ex.cqe = max_cqe + random.randint(1, 100)
             try:
                 CQEX(ctx, attrs_ex)
             except PyverbsError as e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with {c} CQEs while device\'s max CQE={dc}'
                     .format(c=attrs_ex.cqe, dc=max_cqe))
             comp_channel = random.randint(ctx.num_comp_vectors, 100)
             attrs_ex.comp_vector = comp_channel
             attrs_ex.cqe = get_num_cqes(ctx)
             try:
                 CQEX(ctx, attrs_ex)
             except PyverbsError as e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.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))
Example #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
Example #5
0
 def test_destroy_cq_ex(self):
     """
     Test ibv_destroy_cq() for extended CQs
     """
     for ctx, attr, attr_ex in self.devices:
         for i in range(10):
             with CQEX(ctx, get_attrs_ex(attr, attr_ex)) as cq:
                 cq.close()
Example #6
0
 def test_create_cq_ex(self):
     """
     Test ibv_create_cq_ex()
     """
     for ctx, attr, attr_ex in self.devices:
         for i in range(10):
             with CQEX(ctx, get_attrs_ex(attr, attr_ex)):
                 pass
Example #7
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
Example #8
0
 def test_create_cq_ex():
     """
     Test ibv_create_cq_ex()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CQEX(ctx, get_attrs_ex(ctx)):
                 pass
Example #9
0
 def test_destroy_cq_ex():
     """
     Test ibv_destroy_cq() for extended CQs
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CQEX(ctx, get_attrs_ex(ctx)) as cq:
                 cq.close()
Example #10
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)
Example #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)
    res.cq = CQEX(res.ctx, cia)
Example #12
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
Example #13
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
Example #14
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]
Example #15
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)
Example #16
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