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'
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
def test_modify_ud_qp(self): """ Queries a UD 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: # Legacy QP qia = u.get_qp_init_attr(cq, attr) qia.qp_type = e.IBV_QPT_UD qp = self.create_qp(pd, qia, False, False, self.ib_port) qa = QPAttr() qa.qkey = 0x123 qp.to_init(qa) qp_attr, _ = 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.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' # Extended QP qia = get_qp_init_attr_ex(cq, pd, attr, attr_ex, e.IBV_QPT_UD) qp = self.create_qp(ctx, qia, True, False, self.ib_port) qa = QPAttr() qa.qkey = 0x123 qp.to_init(qa) qp_attr, _ = 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.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'