Exemple #1
0
 def test_create_cq_bad_flow(self):
     """
     Test ibv_create_cq() with a wrong comp_vector / cqe number
     """
     for ctx, attr, attr_ex in self.devices:
         for i in range(10):
             cc = CompChannel(ctx)
             cqes = 100
             comp_vector = ctx.num_comp_vectors + int(100 * random.random())
             has_cc = random.choice([True, False])
             if not has_cc:
                 cc = None
             try:
                 with CQ(ctx, cqes, None, cc, comp_vector):
                     pass
             except PyverbsError as e:
                 assert 'Failed to create a CQ' in e.args[0]
                 assert 'Invalid argument' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQ with comp_vector={n} while device\'s num_comp_vectors={nc}'
                     .format(n=comp_vector, nc=ctx.num_comp_vectors))
             max_cqe = ctx.query_device().max_cqe
             cqes = random.randint(max_cqe + 1, max_cqe + 100)
             try:
                 with CQ(ctx, cqes, None, cc, 0):
                     pass
             except PyverbsError as err:
                 assert 'Failed to create a CQ' in err.args[0]
                 assert 'Invalid argument' in err.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQ with cqe={n} while device\'s max_cqe={nc}'
                     .format(n=cqes, nc=max_cqe))
Exemple #2
0
    def test_create_cq_bad_flow(self):
        """
        Test ibv_create_cq() with wrong comp_vector / number of cqes
        """
        with self.assertRaises(PyverbsRDMAError) as ex:
            CQ(self.ctx, self.max_cqe + 1, None, None, 0)
        self.assertEqual(ex.exception.error_code, errno.EINVAL)

        with self.assertRaises(PyverbsRDMAError) as ex:
            CQ(self.ctx, 100, None, None, self.ctx.num_comp_vectors + 1)
        self.assertEqual(ex.exception.error_code, errno.EINVAL)
Exemple #3
0
 def test_create_cq(self):
     """
     Test ibv_create_cq()
     """
     for ctx, attr, attr_ex in self.devices:
         for i in range(10):
             cqes = get_num_cqes(attr)
             comp_vector = int(ctx.num_comp_vectors * random.random())
             if random.choice([True, False]):
                 with CompChannel(ctx) as cc:
                     with CQ(ctx, cqes, None, cc, comp_vector):
                         pass
             else:
                 with CQ(ctx, cqes, None, None, comp_vector):
                     pass
Exemple #4
0
 def test_modify_qp(self):
     """
     Queries a QP after calling modify(). Verifies that its properties are
     as expected.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 is_ex = random.choice([True, False])
                 if is_ex:
                     qia = get_qp_init_attr_ex(cq, pd, [e.IBV_QPT_UD], attr,
                                               attr_ex)
                 else:
                     qia = get_qp_init_attr(cq, [e.IBV_QPT_UD], attr)
                 qp = QP(ctx, qia) if is_ex \
                     else QP(pd, qia)
                 qa = QPAttr()
                 qa.qkey = 0x123
                 qp.to_init(qa)
                 attr, iattr = qp.query(e.IBV_QP_QKEY)
                 assert attr.qkey == qa.qkey
                 qp.to_rtr(qa)
                 qa.sq_psn = 0x45
                 qp.to_rts(qa)
                 attr, iattr = qp.query(e.IBV_QP_SQ_PSN)
                 assert attr.sq_psn == qa.sq_psn
                 qa.qp_state = e.IBV_QPS_RESET
                 qp.modify(qa, e.IBV_QP_STATE)
                 assert qp.qp_state == e.IBV_QPS_RESET
Exemple #5
0
 def test_create_qp_no_attr(self):
     """
     Test QP creation via ibv_create_qp without a QPAttr object proivded.
     Checked QP types are Raw Packet and UD. Raw Packet is skipped for
     non-root users / Infiniband link layer.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 for i in range(1, attr.phys_port_cnt + 1):
                     qia = get_qp_init_attr(cq, attr)
                     qia.qp_type = e.IBV_QPT_UD
                     with QP(pd, qia) as qp:
                         assert qp.qp_state == e.IBV_QPS_RESET, 'UD QP should have been in RESET'
                     if u.is_eth(ctx, i) and u.is_root():
                         qia.qp_type = e.IBV_QPT_RAW_PACKET
                         try:
                             with QP(pd, qia) as qp:
                                 assert qp.qp_state == e.IBV_QPS_RESET, 'Raw Packet QP should have been in RESET'
                         except PyverbsRDMAError as ex:
                             if ex.error_code == errno.EOPNOTSUPP:
                                 raise unittest.SkipTest(
                                     "Create Raw Packet QP is not supported"
                                 )
                             raise ex
Exemple #6
0
 def test_create_qp_no_attr_connected(self):
     """
     Test QP creation via ibv_create_qp without a QPAttr object proivded.
     Checked QP types are RC and UC.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 qia = get_qp_init_attr(cq, attr)
                 qia.qp_type = e.IBV_QPT_RC
                 try:
                     with QP(pd, qia) as qp:
                         assert qp.qp_state == e.IBV_QPS_RESET, 'RC QP should have been in RESET'
                 except PyverbsRDMAError as ex:
                     if ex.error_code == errno.EOPNOTSUPP:
                         raise unittest.SkipTest(
                             'Create QP with RC attrs is not supported')
                     raise ex
                 qia.qp_type = e.IBV_QPT_UC
                 try:
                     with QP(pd, qia) as qp:
                         assert qp.qp_state == e.IBV_QPS_RESET, 'UC QP should have been in RESET'
                 except PyverbsRDMAError as ex:
                     if ex.error_code == errno.EOPNOTSUPP:
                         raise unittest.SkipTest(
                             'Create QP with UC attrs is not supported')
                     raise ex
Exemple #7
0
 def test_query_qp(self):
     """
     Queries a QP after creation. Verifies that its properties are as
     expected.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 for i in range(1, attr.phys_port_cnt + 1):
                     qpts = get_qp_types(ctx, i)
                     for qpt in qpts:
                         # Extended QP
                         qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                                   qpt)
                         caps = qia.cap  # Save them to verify values later
                         qp = QP(ctx, qia)
                         qp_attr, qp_init_attr = qp.query(e.IBV_QP_CUR_STATE
                                                          | e.IBV_QP_CAP)
                         verify_qp_attrs(caps, e.IBV_QPS_RESET,
                                         qp_init_attr, qp_attr)
                         # Legacy QP
                         qia = get_qp_init_attr(cq, attr)
                         qia.qp_type = qpt
                         caps = qia.cap  # Save them to verify values later
                         qp = QP(pd, qia)
                         qp_attr, qp_init_attr = qp.query(e.IBV_QP_CUR_STATE
                                                          | e.IBV_QP_CAP)
                         verify_qp_attrs(caps, e.IBV_QPS_RESET,
                                         qp_init_attr, qp_attr)
Exemple #8
0
 def create_cq(self):
     """
     Initializes self.cq with a CQ of depth <num_msgs> - defined by each
     test.
     :return: None
     """
     self.cq = CQ(self.ctx, self.num_msgs, None, None, 0)
Exemple #9
0
 def test_create_qp_ex_with_attr_connected(self):
     """
     Test QP creation via ibv_create_qp_ex with a QPAttr object proivded.
     Checked QP type are RC and UC.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                           e.IBV_QPT_RC)
                 try:
                     with QP(ctx, qia, QPAttr()) as qp:
                         assert qp.qp_state == e.IBV_QPS_INIT, 'RC QP should have been in INIT'
                 except PyverbsRDMAError as ex:
                     if ex.error_code == errno.EOPNOTSUPP:
                         raise unittest.SkipTest('Create QP with extended attrs is not supported')
                     raise ex
                 qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                           e.IBV_QPT_UC)
                 try:
                     with QP(ctx, qia, QPAttr()) as qp:
                         assert qp.qp_state == e.IBV_QPS_INIT, 'UC QP should have been in INIT'
                 except PyverbsRDMAError as ex:
                     if ex.error_code == errno.EOPNOTSUPP:
                         raise unittest.SkipTest('Create QP with extended attrs is not supported')
                     raise ex
Exemple #10
0
    def create_qp_common_test(self, qp_type, qp_state, is_ex, with_attr):
        """
        Common function used by create QP tests.
        """
        for ctx, attr, attr_ex in self.devices:
            with PD(ctx) as pd:
                with CQ(ctx, 100, None, None, 0) as cq:
                    port_num = 1
                    if qp_type == e.IBV_QPT_RAW_PACKET:
                        eth_port = 0
                        for i in range(1, attr.phys_port_cnt + 1):
                            if u.is_eth(ctx, i) and u.is_root():
                                eth_port = i
                                port_num = eth_port
                                break
                        if eth_port == 0:
                            raise unittest.SkipTest(
                                'To Create RAW QP must be done by root on Ethernet link layer'
                            )

                    if is_ex:
                        qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                                  qp_type)
                        creator = ctx
                    else:
                        qia = u.get_qp_init_attr(cq, attr)
                        qia.qp_type = qp_type
                        creator = pd

                    qp = self.create_qp(creator, qia, is_ex, with_attr,
                                        port_num)
                    qp_type_str = pu.qp_type_to_str(qp_type)
                    qp_state_str = pu.qp_state_to_str(qp_state)
                    assert qp.qp_state == qp_state, f'{qp_type_str} QP should have been in {qp_state_str}'
Exemple #11
0
 def test_create_qp_ex_with_attr(self):
     """
     Test QP creation via ibv_create_qp_ex with a QPAttr object proivded.
     Checked QP types are Raw Packet and UD. Raw Packet is skipped for
     non-root users / Infiniband link layer.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 for i in range(1, attr.phys_port_cnt + 1):
                     qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                               e.IBV_QPT_UD)
                     try:
                         with QP(ctx, qia, QPAttr()) as qp:
                             assert qp.qp_state == e.IBV_QPS_RTS, 'UD QP should have been in RTS'
                     except PyverbsRDMAError as ex:
                         if ex.error_code == errno.EOPNOTSUPP:
                             raise unittest.SkipTest('Create QP with extended attrs is not supported')
                         raise ex
                     if is_eth(ctx, i) and is_root():
                         qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                                   e.IBV_QPT_RAW_PACKET)
                         try:
                             with QP(ctx, qia, QPAttr()) as qp:
                                 assert qp.qp_state == e.IBV_QPS_RTS, 'Raw Packet QP should have been in RTS'
                         except PyverbsRDMAError as ex:
                             if ex.error_code == errno.EOPNOTSUPP:
                                 raise unittest.SkipTest('Create QP with extended attrs is not supported')
                             raise ex
Exemple #12
0
    def query_qp_common_test(self, qp_type):
        for ctx, attr, attr_ex in self.devices:
            with PD(ctx) as pd:
                with CQ(ctx, 100, None, None, 0) as cq:
                    port_num = 1
                    if qp_type == e.IBV_QPT_RAW_PACKET:
                        eth_port = 0
                        for i in range(1, attr.phys_port_cnt + 1):
                            if u.is_eth(ctx, i) and u.is_root():
                                eth_port = i
                                port_num = eth_port
                                break
                        if eth_port == 0:
                            raise unittest.SkipTest(
                                'To Create RAW QP must be done by root on Ethernet link layer'
                            )

                    # Legacy QP
                    qia = u.get_qp_init_attr(cq, attr)
                    qia.qp_type = qp_type
                    caps = qia.cap
                    qp = self.create_qp(pd, qia, False, False, port_num)
                    qp_attr, qp_init_attr = qp.query(e.IBV_QP_STATE
                                                     | e.IBV_QP_CAP)
                    self.verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
                                         qp_attr)

                    # Extended QP
                    qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex, qp_type)
                    caps = qia.cap  # Save them to verify values later
                    qp = self.create_qp(ctx, qia, True, False, port_num)
                    qp_attr, qp_init_attr = qp.query(e.IBV_QP_STATE
                                                     | e.IBV_QP_CAP)
                    self.verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
                                         qp_attr)
Exemple #13
0
 def test_query_qp(self):
     """
     Queries a QP after creation. Verifies that its properties are as
     expected.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 for i in range(1, attr.phys_port_cnt + 1):
                     qpts = get_qp_types(ctx, i)
                     for qpt in qpts:
                         # Extended QP
                         qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                                   qpt)
                         caps = qia.cap  # Save them to verify values later
                         try:
                             qp = QP(ctx, qia)
                         except PyverbsRDMAError as ex:
                             if ex.error_code == errno.EOPNOTSUPP:
                                 raise unittest.SkipTest('Create QP with extended attrs is not supported')
                             raise ex
                         qp_attr, qp_init_attr = qp.query(e.IBV_QP_CUR_STATE |
                                                          e.IBV_QP_CAP)
                         verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
                                         qp_attr)
                         # Legacy QP
                         qia = get_qp_init_attr(cq, attr)
                         qia.qp_type = qpt
                         caps = qia.cap  # Save them to verify values later
                         qp = QP(pd, qia)
                         qp_attr, qp_init_attr = qp.query(e.IBV_QP_CUR_STATE |
                                                          e.IBV_QP_CAP)
                         verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
                                         qp_attr)
Exemple #14
0
 def test_create_cq():
     """
     Test ibv_create_cq()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             cqes = get_num_cqes(ctx)
             comp_vector = random.randint(0, ctx.num_comp_vectors - 1)
             if random.choice([True, False]):
                 with CompChannel(ctx) as cc:
                     with CQ(ctx, cqes, None, cc, comp_vector):
                         pass
             else:
                 with CQ(ctx, cqes, None, None, comp_vector):
                     pass
Exemple #15
0
    def create_qp_common_test(self, qp_type, qp_state, is_ex, with_attr):
        """
        Common function used by create QP tests.
        """
        with PD(self.ctx) as pd:
            with CQ(self.ctx, 100, None, None, 0) as cq:
                if qp_type == e.IBV_QPT_RAW_PACKET:
                    if not (u.is_eth(self.ctx, self.ib_port) and u.is_root()):
                        raise unittest.SkipTest(
                            'To Create RAW QP must be done by root on Ethernet link layer'
                        )

                if is_ex:
                    qia = get_qp_init_attr_ex(cq, pd, self.attr, self.attr_ex,
                                              qp_type)
                    creator = self.ctx
                else:
                    qia = u.get_qp_init_attr(cq, self.attr)
                    qia.qp_type = qp_type
                    creator = pd

                qp = self.create_qp(creator, qia, is_ex, with_attr,
                                    self.ib_port)
                qp_type_str = pu.qp_type_to_str(qp_type)
                qp_state_str = pu.qp_state_to_str(qp_state)
                assert qp.qp_state == qp_state, f'{qp_type_str} QP should have been in {qp_state_str}'
Exemple #16
0
    def query_qp_common_test(self, qp_type):
        with PD(self.ctx) as pd:
            with CQ(self.ctx, 100, None, None, 0) as cq:
                if qp_type == e.IBV_QPT_RAW_PACKET:
                    if not (u.is_eth(self.ctx, self.ib_port) and u.is_root()):
                        raise unittest.SkipTest(
                            'To Create RAW QP must be done by root on Ethernet link layer'
                        )

                # Legacy QP
                qia = u.get_qp_init_attr(cq, self.attr)
                qia.qp_type = qp_type
                caps = qia.cap
                qp = self.create_qp(pd, qia, False, False, self.ib_port)
                qp_attr, qp_init_attr = qp.query(e.IBV_QP_STATE | e.IBV_QP_CAP)
                self.verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
                                     qp_attr)

                # Extended QP
                qia = get_qp_init_attr_ex(cq, pd, self.attr, self.attr_ex,
                                          qp_type)
                caps = qia.cap  # Save them to verify values later
                qp = self.create_qp(self.ctx, qia, True, False, self.ib_port)
                qp_attr, qp_init_attr = qp.query(e.IBV_QP_STATE | e.IBV_QP_CAP)
                self.verify_qp_attrs(caps, e.IBV_QPS_RESET, qp_init_attr,
                                     qp_attr)
Exemple #17
0
 def create_cq(self):
     """
     Initializes self.cq with a CQ of depth <num_msgs> - defined by each
     test.
     :return: None
     """
     cq_depth = self.cq_depth if self.cq_depth is not None else self.num_msgs
     self.cq = CQ(self.ctx, cq_depth, None, None, 0)
Exemple #18
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)
Exemple #19
0
 def test_create_cq_with_comp_channel(self):
     for cq_size in [1, self.attr.max_cqe / 2, self.attr.max_cqe]:
         try:
             cc = CompChannel(self.ctx)
             CQ(self.ctx, cq_size, None, cc, 0)
             cc.close()
         except PyverbsRDMAError as ex:
             if ex.error_code == errno.EOPNOTSUPP:
                 raise unittest.SkipTest(
                     f'CQ with completion channel is not supported')
Exemple #20
0
 def test_create_cq_bad_flow():
     """
     Test ibv_create_cq() with a wrong comp_vector / cqe number
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             cqes = get_num_cqes(ctx)
             comp_vector = random.randint(ctx.num_comp_vectors, 100)
             try:
                 if random.choice([True, False]):
                     with CompChannel(ctx) as cc:
                         with CQ(ctx, cqes, None, cc, comp_vector):
                             pass
                 else:
                     with CQ(ctx, cqes, None, None, comp_vector):
                         pass
             except PyverbsError as e:
                 assert 'Failed to create a CQ' in e.args[0]
                 assert 'Invalid argument' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQ with comp_vector={n} while device\'s num_comp_vectors={nc}'
                     .format(n=comp_vector, nc=ctx.num_comp_vectors))
             max_cqe = ctx.query_device().max_cqe
             cqes = random.randint(max_cqe + 1, max_cqe + 100)
             try:
                 if random.choice([True, False]):
                     with CompChannel(ctx) as cc:
                         with CQ(ctx, cqes, None, cc, 0):
                             pass
                 else:
                     with CQ(ctx, cqes, None, None, 0):
                         pass
             except PyverbsError as err:
                 assert 'Failed to create a CQ' in err.args[0]
                 assert 'Invalid argument' in err.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQ with cqe={n} while device\'s max_cqe={nc}'
                     .format(n=cqes, nc=max_cqe))
Exemple #21
0
 def test_create_qp_with_attr_connected(self):
     """
     Test QP creation via ibv_create_qp without a QPAttr object proivded.
     QP type can be either RC or UC.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 qia = get_qp_init_attr(cq, [e.IBV_QPT_RC, e.IBV_QPT_UC],
                                        attr)
                 with QP(pd, qia, QPAttr()) as qp:
                     assert qp.qp_state == e.IBV_QPS_INIT
Exemple #22
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 #23
0
 def create_qp(self):
     """
     Create an rdmacm QP. If self.with_ext_qp is set, then an external CQ and
     RC QP will be created and set in self.cq and self.qp
     respectively.
     """
     cmid = self.child_id if self.passive else self.cmid
     if not self.with_ext_qp:
         cmid.create_qp(self.create_qp_init_attr())
     else:
         self.cq = CQ(cmid.context, self.num_msgs, None, None, 0)
         init_attr = self.create_qp_init_attr(rcq=self.cq, scq=self.cq)
         self.qp = QP(cmid.pd, init_attr, QPAttr())
Exemple #24
0
 def test_query_data_in_order(self):
     """
     Queries an UD QP data in order after moving it to RTS state.
     Verifies that the result from the query is valid.
     """
     with PD(self.ctx) as pd:
         with CQ(self.ctx, 100, None, None, 0) as cq:
             qia = u.get_qp_init_attr(cq, self.attr)
             qia.qp_type = e.IBV_QPT_UD
             qp = self.create_qp(pd, qia, False, True, self.ib_port)
             is_data_in_order = qp.query_data_in_order(e.IBV_WR_SEND)
             self.assertIn(is_data_in_order, [0, 1],
                           'Data in order result is not valid')
Exemple #25
0
 def test_efadv_create_driver_qp(self):
     """
     Test efadv_create_driver_qp()
     """
     with PD(self.ctx) as pd:
         with CQ(self.ctx, 100) as cq:
             qia = u.get_qp_init_attr(cq, self.attr)
             qia.qp_type = e.IBV_QPT_DRIVER
             try:
                 qp = efa.SRDQP(pd, qia)
             except PyverbsRDMAError as ex:
                 if ex.error_code == errno.EOPNOTSUPP:
                     raise unittest.SkipTest("Create SRD QP is not supported")
                 raise ex
Exemple #26
0
 def test_create_qp_ex_no_attr(self):
     """
     Test QP creation via ibv_create_qp_ex without a QPAttr object proivded.
     QP type can be either Raw Packet or UD.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 for i in range(1, attr.phys_port_cnt + 1):
                     qpts = [e.IBV_QPT_UD, e.IBV_QPT_RAW_PACKET] \
                         if is_eth(ctx, i) else [e.IBV_QPT_UD]
                     qia = get_qp_init_attr_ex(cq, pd, qpts, attr, attr_ex)
                     with QP(ctx, qia) as qp:
                         assert qp.qp_state == e.IBV_QPS_RESET
Exemple #27
0
 def test_create_qp_with_attr_connected(self):
     """
     Test QP creation via ibv_create_qp without a QPAttr object proivded.
     Checked QP types are RC and UC.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 qia = get_qp_init_attr(cq, attr)
                 qia.qp_type = e.IBV_QPT_RC
                 with QP(pd, qia, QPAttr()) as qp:
                     assert qp.qp_state == e.IBV_QPS_INIT, 'RC QP should have been in INIT'
                 qia.qp_type = e.IBV_QPT_UC
                 with QP(pd, qia, QPAttr()) as qp:
                     assert qp.qp_state == e.IBV_QPS_INIT, 'UC QP should have been in INIT'
Exemple #28
0
 def test_efadv_create_qp_ex(self):
     """
     Test efadv_create_qp_ex()
     """
     with PD(self.ctx) as pd:
         with CQ(self.ctx, 100) as cq:
             qiaEx = get_qp_init_attr_ex(cq, pd, self.attr)
             efaqia = efa.EfaQPInitAttr()
             efaqia.driver_qp_type = efa_e.EFADV_QP_DRIVER_TYPE_SRD
             try:
                 qp = efa.SRDQPEx(self.ctx, qiaEx, efaqia)
             except PyverbsRDMAError as ex:
                 if ex.error_code == errno.EOPNOTSUPP:
                     raise unittest.SkipTest("Create SRD QPEx is not supported")
                 raise ex
Exemple #29
0
 def test_modify_qp(self):
     """
     Queries a QP after calling modify(). Verifies that its properties are
     as expected.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 # Extended QP
                 qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                           e.IBV_QPT_UD)
                 try:
                     qp = QP(ctx, qia)
                 except PyverbsRDMAError as ex:
                     if ex.error_code == errno.EOPNOTSUPP:
                         raise unittest.SkipTest(
                             'Create QP with extended attrs is not supported'
                         )
                     raise ex
                 qa = QPAttr()
                 qa.qkey = 0x123
                 qp.to_init(qa)
                 qp_attr, qp_iattr = qp.query(e.IBV_QP_QKEY)
                 assert qp_attr.qkey == qa.qkey, 'Extended QP, QKey is not as expected'
                 qp.to_rtr(qa)
                 qa.sq_psn = 0x45
                 qp.to_rts(qa)
                 qp_attr, qp_iattr = qp.query(e.IBV_QP_SQ_PSN)
                 assert qp_attr.sq_psn == qa.sq_psn, 'Extended QP, SQ PSN is not as expected'
                 qa.qp_state = e.IBV_QPS_RESET
                 qp.modify(qa, e.IBV_QP_STATE)
                 assert qp.qp_state == e.IBV_QPS_RESET, 'Extended QP, QP state is not as expected'
                 # Legacy QP
                 qia = get_qp_init_attr(cq, attr)
                 qp = QP(pd, qia)
                 qa = QPAttr()
                 qa.qkey = 0x123
                 qp.to_init(qa)
                 qp_attr, qp_iattr = qp.query(e.IBV_QP_QKEY)
                 assert qp_attr.qkey == qa.qkey, 'Legacy QP, QKey is not as expected'
                 qp.to_rtr(qa)
                 qa.sq_psn = 0x45
                 qp.to_rts(qa)
                 qp_attr, qp_iattr = qp.query(e.IBV_QP_SQ_PSN)
                 assert qp_attr.sq_psn == qa.sq_psn, 'Legacy QP, SQ PSN is not as expected'
                 qa.qp_state = e.IBV_QPS_RESET
                 qp.modify(qa, e.IBV_QP_STATE)
                 assert qp.qp_state == e.IBV_QPS_RESET, 'Legacy QP, QP state is not as expected'
Exemple #30
0
 def test_create_qp_ex_no_attr_connected(self):
     """
     Test QP creation via ibv_create_qp_ex without a QPAttr object proivded.
     Checked QP types are RC and UC.
     """
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             with CQ(ctx, 100, None, None, 0) as cq:
                 qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                           e.IBV_QPT_RC)
                 with QP(ctx, qia) as qp:
                     assert qp.qp_state == e.IBV_QPS_RESET, 'RC QP should have been in RESET'
                 qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                           e.IBV_QPT_UC)
                 with QP(ctx, qia) as qp:
                     assert qp.qp_state == e.IBV_QPS_RESET, 'UC QP should have been in RESET'