예제 #1
0
    def mixed_traffic(self):
        s_recv_wr = u.get_recv_wr(self.server)
        u.post_recv(self.server, s_recv_wr)
        self.prepare_send_elements()

        for i in range(self.iters):
            self.client.qp.wr_start()
            if i % 2:
                self.client.mr.write('c' * self.client.mr.length,
                                     self.client.mr.length)
                self.client.qp.wr_flags = e.IBV_SEND_SIGNALED
                self.client.qp.wr_send()
                self.client.qp.wr_set_sge(self.regular_send_sge)
            else:
                self.client.mr.write('s' * self.client.mr.length,
                                     self.client.mr.length)
                self.client.qp.wr_raw_wqe(self.raw_send_wqe)
            self.client.qp.wr_complete()
            u.poll_cq_ex(self.client.cq)
            u.poll_cq_ex(self.server.cq)
            u.post_recv(self.server, s_recv_wr)

            if not i % 2 and self.client.cq.read_opcode() != e.IBV_WC_DRIVER2:
                raise PyverbsError(
                    'Opcode validation failed: expected '
                    f'{e.IBV_WC_DRIVER2}, received {self.client.cq.read_opcode()}'
                )

            act_buffer = self.server.mr.read(self.server.mr.length, 0)
            u.validate(act_buffer, i % 2, self.server.mr.length)
예제 #2
0
 def send_client_raw_packets(self, iters, src_mac=None):
     """
     Send raw packets.
     :param iters: Number of packets to send.
     :param src_mac: If set, src mac to set in the packets.
     """
     c_send_wr, _, _ = u.get_send_elements_raw_qp(self.client, src_mac=src_mac)
     for _ in range(iters):
         u.send(self.client, c_send_wr, e.IBV_WR_SEND)
         u.poll_cq_ex(self.client.cq)
예제 #3
0
 def send_server_fdb_to_nic_packets(self, iters):
     """
     Server sends and receives raw packets.
     :param iters: Number of packets to send.
     """
     s_recv_wr = u.get_recv_wr(self.server)
     u.post_recv(self.server, s_recv_wr, qp_idx=0)
     c_send_wr, _, msg = u.get_send_elements_raw_qp(self.server)
     for _ in range(iters):
         u.send(self.server, c_send_wr, e.IBV_WR_SEND)
         u.poll_cq_ex(self.server.cq)
         u.post_recv(self.server, s_recv_wr, qp_idx=0)
         msg_received = self.server.mr.read(self.server.msg_size, 0)
         u.validate_raw(msg_received, msg, [])
예제 #4
0
 def dma_memcpy_bad_protection_flow(self, bad_flow_type):
     """
     Creates resources with bad protection and posts a memcpy WR.
     The bad protection is either a destination MR created on a different PD
     or a destination MR created with insufficient access permissions.
     :param bad_flow_type: An enum of BadFlowType that indicates the bad flow type
     :return: None
     """
     self.create_resources(bad_flow_type)
     self.server.qp.wr_start()
     self.server.qp.wr_flags = e.IBV_SEND_SIGNALED
     self.server.qp.wr_memcpy(self.dest_mr.lkey, self.dest_mr.buf,
                              self.server.mr.lkey, self.server.mr.buf,
                              self.server.msg_size)
     self.server.qp.wr_complete()
     with self.assertRaises(PyverbsRDMAError):
         u.poll_cq_ex(self.server.cq)
     self.assertEqual(self.server.cq.status, e.IBV_WC_LOC_PROT_ERR,
                      'Expected CQE with Local Protection Error')
예제 #5
0
 def dma_memcpy(self, msg_size=1024):
     """
     Creates resources and posts a memcpy WR.
     After posting the WR, the WC opcode and the data are verified.
     :param msg_size: Size of the data to be copied (in Bytes)
     :return: None
     """
     self.create_resources(msg_size=msg_size)
     self.dest_mr.write('0' * msg_size, msg_size)
     self.server.mr.write('s' * msg_size, msg_size)
     self.server.qp.wr_start()
     self.server.qp.wr_flags = e.IBV_SEND_SIGNALED
     self.server.qp.wr_memcpy(self.dest_mr.lkey, self.dest_mr.buf,
                              self.server.mr.lkey, self.server.mr.buf,
                              msg_size)
     self.server.qp.wr_complete()
     u.poll_cq_ex(self.server.cq)
     wc_opcode = self.server.cq.read_opcode()
     self.assertEqual(wc_opcode, dve.MLX5DV_WC_MEMCPY,
                      'WC opcode validation failed')
     self.assertEqual(self.dest_mr.read(msg_size, 0),
                      self.server.mr.read(msg_size, 0))