def poll_cq_ex_ts(cqex, ts_type=None):
        """
        Poll completion from the extended CQ.
        :param cqex: CQEX to poll from
        :param ts_type: If set, read the CQE timestamp in this format
        :return: The CQE timestamp if it requested.
        """
        polling_timeout = 10
        start = datetime.datetime.now()
        ts = 0

        poll_attr = PollCqAttr()
        ret = cqex.start_poll(poll_attr)
        while ret == 2 and (datetime.datetime.now() - start).seconds < polling_timeout:
            ret = cqex.start_poll(poll_attr)
        if ret == 2:
            raise PyverbsRDMAError('Failed to poll CQEX - Got timeout')
        if ret != 0:
            raise PyverbsRDMAError('Failed to poll CQEX')
        if cqex.status != e.IBV_WC_SUCCESS:
            raise PyverbsRDMAError('Completion status is {cqex.status}')
        if ts_type == FREE_RUNNING:
            ts = cqex.read_timestamp()
        if ts_type == REAL_TIME:
            ts = cqex.read_completion_wallclock_ns()
        cqex.end_poll()
        return ts
예제 #2
0
def poll_cq_ex(cqex, count=1):
    """
    Poll <count> completions from the extended CQ.
    :param cq: CQEX to poll from
    :param count: How many completions to poll
    :return: None
    """
    poll_attr = PollCqAttr()
    ret = cqex.start_poll(poll_attr)
    while ret == 2:  # ENOENT
        ret = cqex.start_poll(poll_attr)
    if ret != 0:
        raise PyverbsRDMAErrno('Failed to poll CQ')
    count -= 1
    if cqex.status != e.IBV_WC_SUCCESS:
        raise PyverbsRDMAErrno(
            'Completion status is {s}'.format(s=cqex.status))
    # Now poll the rest of the packets
    while count > 0:
        ret = cqex.poll_next()
        while ret == 2:
            ret = cqex.poll_next()
        if ret != 0:
            raise PyverbsRDMAErrno('Failed to poll CQ')
        if cqex.status != e.IBV_WC_SUCCESS:
            raise PyverbsRDMAErrno(
                'Completion status is {s}'.format(s=cqex.status))
        count -= 1
    cqex.end_poll()
예제 #3
0
파일: utils.py 프로젝트: Edan7/rdma-core
def poll_cq_ex(cqex, count=1, data=None):
    """
    Poll <count> completions from the extended CQ.
    :param cq: CQEX to poll from
    :param count: How many completions to poll
    :param data: In case of a work request with immediate, the immediate data
                 to be compared after poll
    :return: None
    """
    poll_attr = PollCqAttr()
    ret = cqex.start_poll(poll_attr)
    while ret == 2:  # ENOENT
        ret = cqex.start_poll(poll_attr)
    if ret != 0:
        raise PyverbsRDMAErrno('Failed to poll CQ')
    count -= 1
    if cqex.status != e.IBV_WC_SUCCESS:
        raise PyverbsRDMAErrno(
            'Completion status is {s}'.format(s=cqex.status))
    if data:
        assert data == socket.ntohl(cqex.read_imm_data())
    # Now poll the rest of the packets
    while count > 0:
        ret = cqex.poll_next()
        while ret == 2:
            ret = cqex.poll_next()
        if ret != 0:
            raise PyverbsRDMAErrno('Failed to poll CQ')
        if cqex.status != e.IBV_WC_SUCCESS:
            raise PyverbsRDMAErrno(
                'Completion status is {s}'.format(s=cqex.status))
        if data:
            assert data == socket.ntohl(cqex.read_imm_data())
        count -= 1
    cqex.end_poll()
예제 #4
0
    def poll_cq_ex(self, cqex, is_server=True, to_valid=True):
        start = time.perf_counter()
        poll_attr = PollCqAttr()
        ret = cqex.start_poll(poll_attr)
        while ret == 2 and (time.perf_counter() - start < u.POLL_CQ_TIMEOUT):
            ret = cqex.start_poll(poll_attr)
        if ret != 0:
            raise PyverbsRDMAErrno('Failed to poll CQ - got a timeout')
        if cqex.status != e.IBV_WC_SUCCESS:
            raise PyverbsError(f'Completion status is {cqex.status}')
        actual_cqe_dict = {}
        if to_valid:
            recv_flags = cqex.read_wc_flags()
            recv_opcode = cqex.read_opcode()
            actual_cqe_dict = {'wr_id': cqex.wr_id, 'opcode': cqex.read_opcode(),
                               'wc_flags': cqex.read_wc_flags()}
            if is_server:
                actual_cqe_dict['tag'] = cqex.read_tm_info().tag
            if recv_opcode == e.IBV_WC_TM_RECV and not \
                    (recv_flags & (e.IBV_WC_TM_MATCH | e.IBV_WC_TM_DATA_VALID)):
                # In case of receiving unexpected tag, HW doesn't return such wc_flags
                # updadte unexpected count and sync is required.
                self.server.unexp_cnt += 1
                cqex.end_poll()
                self.post_sync()
                return actual_cqe_dict
            if recv_opcode == e.IBV_WC_TM_ADD and (recv_flags & e.IBV_WC_TM_SYNC_REQ):
                # These completion is complemented by the IBV_WC_TM_SYNC_REQ flag,
                # which indicates whether further HW synchronization is needed.
                cqex.end_poll()
                self.post_sync()
                return actual_cqe_dict

        cqex.end_poll()
        return actual_cqe_dict