예제 #1
0
파일: test_qp.py 프로젝트: rixon/rdma-core
 def test_create_qp_with_attr(self):
     """
     Test QP creation via ibv_create_qp 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):
                     qpts = [e.IBV_QPT_UD, e.IBV_QPT_RAW_PACKET] \
                         if u.is_eth(ctx, i) else [e.IBV_QPT_UD]
                     qia = get_qp_init_attr(cq, attr)
                     qia.qp_type = e.IBV_QPT_UD
                     with QP(pd, qia, QPAttr()) as qp:
                         assert qp.qp_state == e.IBV_QPS_RTS, 'UD QP should have been in RTS'
                     if u.is_eth(ctx, i) and u.is_root():
                         qia.qp_type = e.IBV_QPT_RAW_PACKET
                         try:
                             with QP(pd, 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 Raw Packet QP is not supported"
                                 )
                             raise ex
예제 #2
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}'
예제 #3
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)
예제 #4
0
파일: test_qp.py 프로젝트: tal-sh/rdma-core
    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}'
예제 #5
0
파일: test_qp.py 프로젝트: tal-sh/rdma-core
    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)
예제 #6
0
파일: test_qp.py 프로젝트: rixon/rdma-core
 def test_create_qp_ex_no_attr(self):
     """
     Test QP creation via ibv_create_qp_ex 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_ex(cq, pd, attr, attr_ex,
                                               e.IBV_QPT_UD)
                     try:
                         with QP(ctx, qia) as qp:
                             assert qp.qp_state == e.IBV_QPS_RESET, 'UD QP should have been in RESET'
                     except PyverbsRDMAError as ex:
                         if ex.error_code == errno.EOPNOTSUPP:
                             raise unittest.SkipTest(
                                 'Create QP with extended attrs is not supported'
                             )
                         raise ex
                     if u.is_eth(ctx, i) and u.is_root():
                         qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex,
                                                   e.IBV_QPT_RAW_PACKET)
                         try:
                             with QP(ctx, 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 QP with extended attrs is not supported'
                                 )
                             raise ex
예제 #7
0
파일: test_qp.py 프로젝트: rixon/rdma-core
def get_qp_types(ctx, port_num):
    """
    Returns a list of the commonly used QP types. Raw Packet QP will not be
    included if link layer is not Ethernet or it current user is not root.
    :param ctx: The device's Context, to query the port's link layer
    :param port_num: Port number to query
    :return: An array of QP types that can be created on this port
    """
    qpts = [e.IBV_QPT_RC, e.IBV_QPT_UC, e.IBV_QPT_UD]
    if u.is_eth(ctx, port_num) and u.is_root():
        qpts.append(e.IBV_QPT_RAW_PACKET)
    return qpts
예제 #8
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
                         with QP(pd, qia) as qp:
                             assert qp.qp_state == e.IBV_QPS_RESET, 'Raw Packet QP should have been in RESET'