def event_handler(self, expected_event=None): """ Handle and execute corresponding API for RDMACM events of asynchronous communication. :param expected_event: The user expected event. :return: None """ cm_event = CMEvent(self.cm_res.cmid.event_channel) if cm_event.event_type == ce.RDMA_CM_EVENT_CONNECT_REQUEST: self.cm_res.create_child_id(cm_event) if expected_event and expected_event != cm_event.event_type: raise PyverbsError( 'Expected this event: {}, got this event: {}'.format( expected_event, cm_event.event_str())) cm_event.ack_cm_event()
def event_handler(agr_obj): """ Handle and execute corresponding API for RDMACM events of asynchronous communication :param agr_obj: Aggregation object which contains all necessary resources :return: None """ cm_event = CMEvent(agr_obj.cmid.event_channel) if cm_event.event_type == ce.RDMA_CM_EVENT_ADDR_RESOLVED: agr_obj.cmid.resolve_route() elif cm_event.event_type == ce.RDMA_CM_EVENT_ROUTE_RESOLVED: agr_obj.create_qp() param = agr_obj.create_conn_param() if agr_obj.with_ext_qp: param.qpn = agr_obj.qp.qp_num agr_obj.cmid.connect(param) elif cm_event.event_type == ce.RDMA_CM_EVENT_CONNECT_REQUEST: agr_obj.create_child_id(cm_event) param = agr_obj.create_conn_param() agr_obj.create_qp() if agr_obj.with_ext_qp: agr_obj.modify_ext_qp_to_rts() param.qpn = agr_obj.qp.qp_num agr_obj.child_id.accept(param) elif cm_event.event_type == ce.RDMA_CM_EVENT_ESTABLISHED: agr_obj.connected = True elif cm_event.event_type == ce.RDMA_CM_EVENT_CONNECT_RESPONSE: agr_obj.connected = True if agr_obj.with_ext_qp: agr_obj.modify_ext_qp_to_rts() agr_obj.cmid.establish() elif cm_event.event_type == ce.RDMA_CM_EVENT_DISCONNECTED: if agr_obj.is_server: agr_obj.child_id.disconnect() agr_obj.connected = False else: agr_obj.cmid.disconnect() agr_obj.connected = False else: if cm_event.event_type in events_dict: raise PyverbsError('Unexpected event - {}'.format( events_dict[cm_event.event_type])) else: raise PyverbsError('The event {} is not supported'.format( cm_event.event_type)) cm_event.ack_cm_event()
def event_handler(self, expected_event=None): """ Handle and execute corresponding API for RDMACM events of asynchronous communication. :param expected_event: The user expected event. :return: None """ cm_event = CMEvent(self.cm_res.cmid.event_channel) if cm_event.event_type == ce.RDMA_CM_EVENT_CONNECT_REQUEST: self.cm_res.create_child_id(cm_event) elif cm_event.event_type in [ce.RDMA_CM_EVENT_ESTABLISHED, ce.RDMA_CM_EVENT_MULTICAST_JOIN]: self.cm_res.set_ud_params(cm_event) if expected_event and expected_event != cm_event.event_type: raise PyverbsError('Expected this event: {}, got this event: {}'. format(expected_event, cm_event.event_str())) if expected_event == ce.RDMA_CM_EVENT_REJECTED: assert cm_event.private_data == REJECT_MSG, \ f'CM event data ({cm_event.private_data}) is different than the expected ({REJECT_MSG})' cm_event.ack_cm_event()