def build_traffic_elements_sig_pipelining(self): """ Build two WRs for data and response on client side and one WR for response on server side. Transaction consists of two operations: RDMA write of data and send/recv of response. Data size is 512 bytes, response size is 16 bytes. For simplicity the same memory is used for data and response. Data is transferred using the player signature mkey. Response is transferred using the plain MR. """ server_sge_resp = SGE(self.server.mr.buf, 16, self.server.mr.lkey) self.server_resp_wr = RecvWR(sg=[server_sge_resp], num_sge=1) client_sge_data = SGE(0, 512, self.client.mkey.lkey) self.client_data_wr = SendWR(wr_id=1, opcode=e.IBV_WR_RDMA_WRITE, num_sge=1, sg=[client_sge_data], send_flags=0) self.client_data_wr.set_wr_rdma(self.server.mkey.rkey, 0) client_sge_resp = SGE(self.client.mr.buf, 16, self.client.mr.lkey) client_send_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_FENCE self.client_resp_wr = SendWR(wr_id=1, opcode=e.IBV_WR_SEND, num_sge=1, sg=[client_sge_resp], send_flags=client_send_flags)
def invalidate_mkeys(self): """ Invalidate the players mkey. """ for player in [self.server, self.client]: inv_send_wr = SendWR(opcode=e.IBV_WR_LOCAL_INV) inv_send_wr.imm_data = player.mkey.lkey player.qp.post_send(inv_send_wr) u.poll_cq(player.cq)
def get_atomic_send_elements(agr_obj, opcode, cmp_add=0, swap=0): """ Creates a single SGE and a single Send WR for atomic operations. :param agr_obj: Aggregation object which contains all resources necessary :param opcode: The send opcode :param cmp_add: The compare or add value (depends on the opcode). :param swap: The swap value. :return: Send WR and its SGE """ sge = SGE(agr_obj.mr.buf, 8, agr_obj.mr_lkey) send_wr = SendWR(opcode=opcode, num_sge=1, sg=[sge]) send_wr.set_wr_atomic(rkey=int(agr_obj.rkey), addr=int(agr_obj.raddr), compare_add=int8b_from_int(cmp_add), swap=int8b_from_int(swap)) return send_wr, sge
def get_send_elements(self, tag=0, tm_opcode=e.IBV_TMH_EAGER, tm=True): """ Creates a single SGE and a single Send WR for client QP. The content of the message is 'c' for client side. The function also generates TMH and RVH to the msg :return: Send wr and expected msg that is read from mr """ sge = SGE(self.client.mr.buf, self.client.msg_size, self.client.mr_lkey) if tm_opcode == e.IBV_TMH_RNDV: max_rndv_hdr_size = self.server.ctx.query_device_ex().tm_caps.max_rndv_hdr_size sge.length = max_rndv_hdr_size if max_rndv_hdr_size <= self.server.mr.length else \ self.server.mr.length write_rndvu_header(player=self.client, mr=self.client.mr, tag=tag, tm_opcode=tm_opcode) c_recv_wr = RecvWR(wr_id=tag, sg=[sge], num_sge=1) # Need to post_recv client because the server sends rdma-read request to client u.post_recv(self.client, c_recv_wr) else: msg = self.client.msg_size * 'c' self.client.mr.write(msg, self.client.msg_size) if tm: write_tm_header(mr=self.client.mr, tag=tag, tm_opcode=tm_opcode) send_wr = SendWR(opcode=e.IBV_WR_SEND, num_sge=1, sg=[sge]) exp_msg = self.client.mr.read(self.client.msg_size, 0) return send_wr, exp_msg
def get_send_elements(agr_obj, is_server, opcode=e.IBV_WR_SEND): """ Creates a single SGE and a single Send WR for agr_obj's QP type. The content of the message is either 's' for server side or 'c' for client side. :param agr_obj: Aggregation object which contains all resources necessary :param is_server: Indicates whether this is server or client side :return: send wr and its SGE """ mr = agr_obj.mr qp_type = agr_obj.sqp_lst[0].qp_type if isinstance(agr_obj, XRCResources) \ else agr_obj.qp.qp_type offset = GRH_SIZE if qp_type == e.IBV_QPT_UD else 0 msg = (agr_obj.msg_size + offset) * ('s' if is_server else 'c') mr.write(msg, agr_obj.msg_size + offset) sge = SGE(mr.buf + offset, agr_obj.msg_size, mr.lkey) send_wr = SendWR(opcode=opcode, num_sge=1, sg=[sge]) if opcode in [e.IBV_WR_RDMA_WRITE, e.IBV_WR_RDMA_READ]: send_wr.set_wr_rdma(int(agr_obj.rkey), int(agr_obj.remote_addr)) return send_wr, sge
def build_traffic_elements(self, sge_size): """ Build the server and client send/recv work requests. :param sge_size: The sge send size using the mkey. """ opcode = e.IBV_WR_SEND server_sge = SGE(0, sge_size, self.server.mkey.lkey) self.server_recv_wr = RecvWR(sg=[server_sge], num_sge=1) client_sge = SGE(0, sge_size, self.client.mkey.lkey) self.client_send_wr = SendWR(opcode=opcode, num_sge=1, sg=[client_sge])
def bind_mw_type_2(self): client_send_wr = SendWR(opcode=e.IBV_WR_BIND_MW) client_send_wr.set_bind_wr(self.client.mw, self.client.mw_bind_info) server_send_wr = SendWR(opcode=e.IBV_WR_BIND_MW) server_send_wr.set_bind_wr(self.server.mw, self.server.mw_bind_info) self.server.qp.post_send(server_send_wr) self.client.qp.post_send(client_send_wr) # Poll the bind MW WR. u.poll_cq(self.server.cq) u.poll_cq(self.client.cq) self.server.rkey = client_send_wr.rkey self.server.remote_addr = self.client.mr.buf self.client.rkey = server_send_wr.rkey self.client.remote_addr = self.server.mr.buf
def test_odp_ud_traffic(self): client, server = self.create_players(OdpUD) # Implement the traffic here because OdpUD uses two different MRs for # send and recv. recv_sge = SGE(server.recv_mr.buf, server.msg_size + GRH_SIZE, server.recv_mr.lkey) server_recv_wr = RecvWR(sg=[recv_sge], num_sge=1) send_sge = SGE(client.send_mr.buf + GRH_SIZE, client.msg_size, client.send_mr.lkey) client_send_wr = SendWR(num_sge=1, sg=[send_sge]) for i in range(self.iters): server.qp.post_recv(server_recv_wr) post_send(client, client_send_wr, self.gid_index, self.ib_port) poll_cq(client.cq) poll_cq(server.cq)
def get_send_wr(agr_obj, is_server): """ Creates a single SGE Send WR for agr_obj's QP type. The content of the message is either 's' for server side or 'c' for client side. :param agr_obj: Aggregation object which contains all resources necessary :param is_server: Indicates whether this is server or client side :return: send wr """ qp_type = agr_obj.sqp_lst[0].qp_type if isinstance(agr_obj, XRCResources) \ else agr_obj.qp.qp_type mr = agr_obj.mr offset = GRH_SIZE if qp_type == e.IBV_QPT_UD else 0 send_sge = SGE(mr.buf + offset, agr_obj.msg_size, mr.lkey) msg = (agr_obj.msg_size + offset) * ('s' if is_server else 'c') mr.write(msg, agr_obj.msg_size + offset) return SendWR(num_sge=1, sg=[send_sge])
def get_send_elements_raw_qp(agr_obj, l3=PacketConsts.IP_V4, l4=PacketConsts.UDP_PROTO): """ Creates a single SGE and a single Send WR for agr_obj's RAW QP type. The content of the message is Eth | Ipv4 | UDP packet. :param agr_obj: Aggregation object which contains all resources necessary :param l3: Packet layer 3 type: 4 for IPv4 or 6 for IPv6 :param l4: Packet layer 4 type: 'tcp' or 'udp' :return: send wr, its SGE, and message """ mr = agr_obj.mr msg = gen_packet(agr_obj.msg_size, l3, l4) mr.write(msg, agr_obj.msg_size) sge = SGE(mr.buf, agr_obj.msg_size, mr.lkey) send_wr = SendWR(opcode=e.IBV_WR_SEND, num_sge=1, sg=[sge]) return send_wr, sge, msg
def invalidate_mw_type2_local(self): """ Invalidate the MWs by post invalidation send WR from the local QP. :return: None """ inv_send_wr = SendWR(opcode=e.IBV_WR_LOCAL_INV) inv_send_wr.imm_data = self.server.rkey self.client.qp.post_send(inv_send_wr) inv_send_wr = SendWR(opcode=e.IBV_WR_LOCAL_INV) inv_send_wr.imm_data = self.client.rkey self.server.qp.post_send(inv_send_wr) # Poll the invalidate MW WR. u.poll_cq(self.server.cq) u.poll_cq(self.client.cq)
def invalidate_mw_type2_remote(self): """ Invalidate the MWs by sending invalidation send WR from the remote QP. :return: None """ server_recv_wr = u.get_recv_wr(self.server) client_recv_wr = u.get_recv_wr(self.client) self.server.qp.post_recv(server_recv_wr) self.client.qp.post_recv(client_recv_wr) inv_send_wr = SendWR(opcode=e.IBV_WR_SEND_WITH_INV) inv_send_wr.imm_data = self.client.rkey self.client.qp.post_send(inv_send_wr) inv_send_wr = SendWR(opcode=e.IBV_WR_SEND_WITH_INV) inv_send_wr.imm_data = self.server.rkey self.server.qp.post_send(inv_send_wr) # Poll the invalidate MW send WR. u.poll_cq(self.server.cq) u.poll_cq(self.client.cq) # Poll the invalidate MW recv WR. u.poll_cq(self.server.cq) u.poll_cq(self.client.cq)
class Mlx5MkeyTest(RDMATestCase): """ Test various functionalities of the mlx5 mkeys. """ def setUp(self): super().setUp() self.iters = 10 self.server = None self.client = None def create_players(self, resource, **resource_arg): """ Init Mkey test resources. :param resource: The RDMA resources to use. :param resource_arg: Dict of args that specify the resource specific attributes. :return: None """ self.client = resource(**self.dev_info, **resource_arg) self.server = resource(**self.dev_info, **resource_arg) self.client.pre_run(self.server.psns, self.server.qps_num) self.server.pre_run(self.client.psns, self.client.qps_num) def reg_mr_list(self, configure_mkey=False): """ Register a list of SGEs using the player's mkeys. :param configure_mkey: If True, use the mkey configuration API. """ for player in [self.server, self.client]: player.qp.wr_start() player.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE sge_1 = SGE(player.mr.buf, 8, player.mr.lkey) sge_2 = SGE(player.mr.buf + 64, 8, player.mr.lkey) if configure_mkey: player.qp.wr_mkey_configure(player.mkey, 2, Mlx5MkeyConfAttr()) player.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE) player.qp.wr_set_mkey_layout_list([sge_1, sge_2]) else: player.qp.wr_mr_list(player.mkey, e.IBV_ACCESS_LOCAL_WRITE, sge_list=[sge_1, sge_2]) player.qp.wr_complete() u.poll_cq(player.cq) def reg_mr_interleaved(self, configure_mkey=False): """ Register an interleaved memory layout using the player's mkeys. :param configure_mkey: Use the mkey configuration API. """ for player in [self.server, self.client]: player.qp.wr_start() player.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE mr_interleaved_1 = Mlx5MrInterleaved(addr=player.mr.buf, bytes_count=8, bytes_skip=2, lkey=player.mr.lkey) mr_interleaved_2 = Mlx5MrInterleaved(addr=player.mr.buf + 64, bytes_count=8, bytes_skip=2, lkey=player.mr.lkey) mr_interleaved_lst = [mr_interleaved_1, mr_interleaved_2] mkey_access = e.IBV_ACCESS_LOCAL_WRITE if configure_mkey: player.qp.wr_mkey_configure(player.mkey, 2, Mlx5MkeyConfAttr()) player.qp.wr_set_mkey_access_flags(mkey_access) player.qp.wr_set_mkey_layout_interleaved(3, mr_interleaved_lst) else: player.qp.wr_mr_interleaved( player.mkey, e.IBV_ACCESS_LOCAL_WRITE, repeat_count=3, mr_interleaved_lst=mr_interleaved_lst) player.qp.wr_complete() u.poll_cq(player.cq) def reg_mr_sig_t10dif(self): """ Register the player's mkeys with T10DIF signature on the wire domain. """ for player in [self.server, self.client]: player.qp.wr_start() player.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE sge = SGE(player.mr.buf, 512, player.mr.lkey) player.qp.wr_mkey_configure(player.mkey, 3, Mlx5MkeyConfAttr()) player.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE) player.qp.wr_set_mkey_layout_list([sge]) t10dif_flags = (dve.MLX5DV_SIG_T10DIF_FLAG_REF_REMAP | dve.MLX5DV_SIG_T10DIF_FLAG_APP_ESCAPE | dve.MLX5DV_SIG_T10DIF_FLAG_APP_REF_ESCAPE) sig_t10dif = Mlx5SigT10Dif(bg_type=dve.MLX5DV_SIG_T10DIF_CRC, bg=0xFFFF, app_tag=0xABCD, ref_tag=0x01234567, flags=t10dif_flags) sig_type = dve.MLX5DV_SIG_TYPE_T10DIF block_size = dve.MLX5DV_BLOCK_SIZE_512 sig_block_domain = Mlx5SigBlockDomain(sig_type=sig_type, dif=sig_t10dif, block_size=block_size) check_mask = (dve.MLX5DV_SIG_MASK_T10DIF_GUARD | dve.MLX5DV_SIG_MASK_T10DIF_APPTAG | dve.MLX5DV_SIG_MASK_T10DIF_REFTAG) sig_attr = Mlx5SigBlockAttr(wire=sig_block_domain, check_mask=check_mask) player.qp.wr_set_mkey_sig_block(sig_attr) player.qp.wr_complete() u.poll_cq(player.cq) def reg_mr_sig_crc(self): """ Register the player's mkeys with CRC32 signature on the wire domain. """ for player in [self.server, self.client]: player.qp.wr_start() player.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE sge = SGE(player.mr.buf, 512, player.mr.lkey) player.qp.wr_mkey_configure(player.mkey, 3, Mlx5MkeyConfAttr()) player.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE) player.qp.wr_set_mkey_layout_list([sge]) sig_crc = Mlx5SigCrc(crc_type=dve.MLX5DV_SIG_CRC_TYPE_CRC32, seed=0xFFFFFFFF) sig_block_domain = Mlx5SigBlockDomain( sig_type=dve.MLX5DV_SIG_TYPE_CRC, crc=sig_crc, block_size=dve.MLX5DV_BLOCK_SIZE_512) sig_attr = Mlx5SigBlockAttr(wire=sig_block_domain, check_mask=dve.MLX5DV_SIG_MASK_CRC32) player.qp.wr_set_mkey_sig_block(sig_attr) player.qp.wr_complete() u.poll_cq(player.cq) def reg_mr_sig_err(self): """ Register the player's mkeys with an SGE and CRC32 signature on the memory domain. Data transport operation with these MKEYs will cause a signature error because the test does not fill out the signature in the memory buffer. """ sig_crc = Mlx5SigCrc(crc_type=dve.MLX5DV_SIG_CRC_TYPE_CRC32, seed=0xFFFFFFFF) block_size = dve.MLX5DV_BLOCK_SIZE_512 sig_block_domain = Mlx5SigBlockDomain(sig_type=dve.MLX5DV_SIG_TYPE_CRC, crc=sig_crc, block_size=block_size) sig_attr = Mlx5SigBlockAttr(mem=sig_block_domain, check_mask=dve.MLX5DV_SIG_MASK_CRC32) # Configure the mkey on the server side self.server.qp.wr_start() self.server.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE sge = SGE(self.server.mr.buf, 512, self.server.mr.lkey) self.server.qp.wr_mkey_configure(self.server.mkey, 2, Mlx5MkeyConfAttr()) self.server.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE) self.server.qp.wr_set_mkey_layout_list([sge]) self.server.qp.wr_complete() u.poll_cq(self.server.cq) # Configure the mkey on the client side self.client.qp.wr_start() self.client.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE sge = SGE(self.client.mr.buf, 512 + 4, self.client.mr.lkey) self.client.qp.wr_mkey_configure(self.client.mkey, 3, Mlx5MkeyConfAttr()) self.client.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE) self.client.qp.wr_set_mkey_layout_list([sge]) self.client.qp.wr_set_mkey_sig_block(sig_attr) self.client.qp.wr_complete() u.poll_cq(self.client.cq) def reg_mr_sig_pipelining_server(self): """ Register mkey without signature. """ self.server.qp.wr_start() self.server.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE sge = SGE(self.server.mr.buf, 512, self.server.mr.lkey) self.server.qp.wr_mkey_configure(self.server.mkey, 2, Mlx5MkeyConfAttr()) self.server.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE | e.IBV_ACCESS_REMOTE_WRITE) self.server.qp.wr_set_mkey_layout_list([sge]) self.server.qp.wr_complete() u.poll_cq(self.server.cq) def reg_mr_sig_pipelining_client(self, check_mask=0): """ Register mkey with CRC32 signature in memory domain and no signature in wire domain. :param check_mask: The mask for the signature checking. """ self.client.qp.wr_start() self.client.qp.wr_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_INLINE # Add 4 bytes for CRC32 signature sge = SGE(self.client.mr.buf, 512 + 4, self.client.mr.lkey) self.client.qp.wr_mkey_configure(self.client.mkey, 3, Mlx5MkeyConfAttr()) self.client.qp.wr_set_mkey_access_flags(e.IBV_ACCESS_LOCAL_WRITE) self.client.qp.wr_set_mkey_layout_list([sge]) sig = Mlx5SigCrc(crc_type=dve.MLX5DV_SIG_CRC_TYPE_CRC32) sig_domain = Mlx5SigBlockDomain(sig_type=dve.MLX5DV_SIG_TYPE_CRC, crc=sig, block_size=dve.MLX5DV_BLOCK_SIZE_512) sig_attr = Mlx5SigBlockAttr(mem=sig_domain, check_mask=check_mask) self.client.qp.wr_set_mkey_sig_block(sig_attr) self.client.qp.wr_complete() u.poll_cq(self.client.cq) def build_traffic_elements(self, sge_size): """ Build the server and client send/recv work requests. :param sge_size: The sge send size using the mkey. """ opcode = e.IBV_WR_SEND server_sge = SGE(0, sge_size, self.server.mkey.lkey) self.server_recv_wr = RecvWR(sg=[server_sge], num_sge=1) client_sge = SGE(0, sge_size, self.client.mkey.lkey) self.client_send_wr = SendWR(opcode=opcode, num_sge=1, sg=[client_sge]) def build_traffic_elements_sig_pipelining(self): """ Build two WRs for data and response on client side and one WR for response on server side. Transaction consists of two operations: RDMA write of data and send/recv of response. Data size is 512 bytes, response size is 16 bytes. For simplicity the same memory is used for data and response. Data is transferred using the player signature mkey. Response is transferred using the plain MR. """ server_sge_resp = SGE(self.server.mr.buf, 16, self.server.mr.lkey) self.server_resp_wr = RecvWR(sg=[server_sge_resp], num_sge=1) client_sge_data = SGE(0, 512, self.client.mkey.lkey) self.client_data_wr = SendWR(wr_id=1, opcode=e.IBV_WR_RDMA_WRITE, num_sge=1, sg=[client_sge_data], send_flags=0) self.client_data_wr.set_wr_rdma(self.server.mkey.rkey, 0) client_sge_resp = SGE(self.client.mr.buf, 16, self.client.mr.lkey) client_send_flags = e.IBV_SEND_SIGNALED | e.IBV_SEND_FENCE self.client_resp_wr = SendWR(wr_id=1, opcode=e.IBV_WR_SEND, num_sge=1, sg=[client_sge_resp], send_flags=client_send_flags) def traffic(self, sge_size, exp_buffer): """ Perform RC traffic using the mkey. :param sge_size: The sge size using the mkey. :param exp_buffer: The expected result of the receive buffer after the traffic operation. """ self.build_traffic_elements(sge_size) self.server.qp.post_recv(self.server_recv_wr) for _ in range(self.iters): self.server.mr.write('s' * self.server.msg_size, self.server.msg_size) self.client.mr.write('c' * self.client.msg_size, self.client.msg_size) self.client.qp.post_send(self.client_send_wr) u.poll_cq(self.client.cq) u.poll_cq(self.server.cq) self.server.qp.post_recv(self.server_recv_wr) act_buffer = self.server.mr.read(len(exp_buffer), 0).decode() if act_buffer != exp_buffer: raise PyverbsError('Data validation failed: expected ' f'{exp_buffer}, received {act_buffer}') def traffic_scattered_data(self, sge_size=16): exp_buffer = ((('c' * 8 + 's' * 56) * 2)[:100]) self.traffic(sge_size=sge_size, exp_buffer=exp_buffer) def traffic_sig(self): exp_buffer = ('c' * 512 + 's' * (self.server.msg_size - 512)) self.traffic(sge_size=512, exp_buffer=exp_buffer) def invalidate_mkeys(self): """ Invalidate the players mkey. """ for player in [self.server, self.client]: inv_send_wr = SendWR(opcode=e.IBV_WR_LOCAL_INV) inv_send_wr.imm_data = player.mkey.lkey player.qp.post_send(inv_send_wr) u.poll_cq(player.cq) def check_mkey(self, player, expected=dve.MLX5DV_MKEY_NO_ERR): """ Check the player's mkey for a signature error. param player: Player to check. param expected: The expected result of the checking. """ mkey_err = player.mkey.mkey_check() if mkey_err.err_type != expected: raise PyverbsRDMAError('MKEY check failed: ' f'expected err_type: {expected_type}, ' f'actual err_type: {mkey_err.err_type}') def test_mkey_interleaved(self): """ Create Mkeys, register an interleaved memory layout using this mkey and then perform traffic using it. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MR_INTERLEAVED) self.reg_mr_interleaved() self.traffic_scattered_data() self.invalidate_mkeys() def test_mkey_list(self): """ Create Mkeys, register a memory layout using this mkey and then perform traffic using this mkey. """ self.create_players(Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MR_LIST) self.reg_mr_list() self.traffic_scattered_data() self.invalidate_mkeys() def test_mkey_list_new_api(self): """ Create Mkeys, configure it with memory layout using the new API and traffic using this mkey. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE) self.reg_mr_list(configure_mkey=True) self.traffic_scattered_data() self.invalidate_mkeys() def test_mkey_interleaved_new_api(self): """ Create Mkeys, configure it with interleaved memory layout using the new API and then perform traffic using it. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE) self.reg_mr_interleaved(configure_mkey=True) self.traffic_scattered_data() self.invalidate_mkeys() def test_mkey_list_bad_flow(self): """ Create Mkeys, register a memory layout using this mkey and then try to access the memory out of the mkey defined region. Expect this case to fail. """ self.create_players(Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MR_LIST) self.reg_mr_list() with self.assertRaises(PyverbsRDMAError) as ex: self.traffic_scattered_data(sge_size=100) def test_mkey_sig_t10dif(self): """ Create Mkeys, configure it with T10DIF signature and traffic using this mkey. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE, mkey_create_flags=dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT | dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE) self.reg_mr_sig_t10dif() self.traffic_sig() self.check_mkey(self.server) self.check_mkey(self.client) self.invalidate_mkeys() def test_mkey_sig_crc(self): """ Create Mkeys, configure it with CRC32 signature and traffic using this mkey. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE, mkey_create_flags=dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT | dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE) self.reg_mr_sig_crc() self.traffic_sig() self.check_mkey(self.server) self.check_mkey(self.client) self.invalidate_mkeys() def test_mkey_sig_err(self): """ Test the signature error handling flow. Create Mkeys, configure it CRC32 signature on the memory domain but do not set a valid signature in the memory buffer. Run traffic using this mkey, ensure that the signature error is detected. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE, mkey_create_flags=dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT | dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE) self.reg_mr_sig_err() # The test supports only one iteration because mkey re-registration # is required after each signature error. self.iters = 1 self.traffic_sig() self.check_mkey(self.client, dve.MLX5DV_MKEY_SIG_BLOCK_BAD_GUARD) self.check_mkey(self.server) self.invalidate_mkeys() def test_mkey_sig_pipelining_good(self): """ Test the good signature pipelining scenario. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE, mkey_create_flags=dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT | dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE, dv_qp_create_flags=dve.MLX5DV_QP_CREATE_DISABLE_SCATTER_TO_CQE | dve.MLX5DV_QP_CREATE_SIG_PIPELINING) self.reg_mr_sig_pipelining_client() self.reg_mr_sig_pipelining_server() self.build_traffic_elements_sig_pipelining() self.server.qp.post_recv(self.server_resp_wr) self.client.qp.post_send(self.client_data_wr) self.client.qp.post_send(self.client_resp_wr) u.poll_cq(self.client.cq) u.poll_cq(self.server.cq) def test_mkey_sig_pipelining_bad(self): """ Test the bad signature pipelining scenario. """ self.create_players( Mlx5MkeyResources, dv_send_ops_flags=dve.MLX5DV_QP_EX_WITH_MKEY_CONFIGURE, mkey_create_flags=dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT | dve.MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE, dv_qp_create_flags=dve.MLX5DV_QP_CREATE_DISABLE_SCATTER_TO_CQE | dve.MLX5DV_QP_CREATE_SIG_PIPELINING) self.reg_mr_sig_pipelining_client(check_mask=dve.MLX5DV_SIG_MASK_CRC32) self.reg_mr_sig_pipelining_server() self.build_traffic_elements_sig_pipelining() self.server.qp.post_recv(self.server_resp_wr) self.client.qp.post_send(self.client_data_wr) self.client.qp.post_send(self.client_resp_wr) # Expect SQ_DRAINED event event = self.client.ctx.get_async_event() event.ack() self.assertEqual(event.event_type, e.IBV_EVENT_SQ_DRAINED) # No completion is expected on the client side nc, _ = self.client.cq.poll(1) self.assertEqual(nc, 0) # No completion is expected on the server side nc, _ = self.server.cq.poll(1) self.assertEqual(nc, 0) self.check_mkey(self.client, dve.MLX5DV_MKEY_SIG_BLOCK_BAD_GUARD) self.check_mkey(self.server) # Cancel and repost response WR canceled_count = self.client.qp.cancel_posted_send_wrs(1) self.assertEqual(canceled_count, 1) self.client.qp.post_send(self.client_resp_wr) # Move QP back to RTS and receive completions self.client.qp.modify( QPAttr(qp_state=e.IBV_QPS_RTS, cur_qp_state=e.IBV_QPS_SQD), e.IBV_QP_STATE | e.IBV_QP_CUR_STATE) u.poll_cq(self.client.cq) u.poll_cq(self.server.cq)
def get_send_wr(self, player, wire_encryption): mkey = player.wire_enc_mkey if wire_encryption else player.mem_enc_mkey sge = SGE(0, player.msg_size/2, mkey.lkey) return SendWR(opcode=e.IBV_WR_SEND, num_sge=1, sg=[sge])