Ejemplo n.º 1
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}'
Ejemplo n.º 2
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}'
Ejemplo n.º 3
0
 def create_qp(self, creator, qp_init_attr, is_ex, with_attr, port_num):
     """
     Auxiliary function to create QP object.
     """
     try:
         qp_attr = (None, QPAttr(port_num=port_num))[with_attr]
         return QP(creator, qp_init_attr, qp_attr)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             with_str = ('without', 'with')[with_attr] + ('', ' extended')[is_ex]
             qp_type_str = pu.qp_type_to_str(qp_init_attr.qp_type)
             raise unittest.SkipTest(f'Create {qp_type_str} QP {with_str} attrs is not supported')
         raise ex