Ejemplo n.º 1
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)
 def ts_traffic(self):
     """
     Run RDMA traffic and read the completions timestamps.
     """
     s_recv_wr = u.get_recv_wr(self.server)
     u.post_recv(self.server, s_recv_wr)
     if self.qp_type == e.IBV_QPT_RAW_PACKET:
         c_send_wr, _, _ = u.get_send_elements_raw_qp(self.client)
     else:
         c_send_wr, _ = u.get_send_elements(self.client, False)
     u.send(self.client, c_send_wr, e.IBV_WR_SEND, False, 0)
     self.client.timestamp = self.poll_cq_ex_ts(self.client.scq, ts_type=self.send_ts)
     self.server.timestamp = self.poll_cq_ex_ts(self.server.rcq, ts_type=self.recv_ts)
Ejemplo n.º 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, [])
Ejemplo n.º 4
0
 def full_sq_bad_flow(self):
     """
     Check post_send while qp's sq is full.
     - Find qp's sq length
     - Fill the qp with work requests until overflow
     """
     qp_idx = 0
     send_op = e.IBV_QP_EX_WITH_SEND
     ah = u.get_global_ah(self.client, self.gid_index, self.ib_port)
     qp_attr, _ = self.client.qps[qp_idx].query(e.IBV_QP_CAP)
     max_send_wr = qp_attr.cap.max_send_wr
     with self.assertRaises(PyverbsRDMAError) as ex:
         for _ in range(max_send_wr + 1):
             _, c_sg = u.get_send_elements(self.client, False)
             u.send(self.client,
                    c_sg,
                    send_op,
                    new_send=True,
                    qp_idx=qp_idx,
                    ah=ah)
     self.assertEqual(ex.exception.error_code, errno.ENOMEM)
Ejemplo n.º 5
0
    def test_resize_cq(self):
        """
        Test resize CQ, start with specific value and then increase and decrease
        the CQ size. The test also check bad flow of decrease the CQ size when
        there are more completions on it than the new value.
        """
        self.create_players(CQUDResources, cq_depth=3)
        # Decrease the CQ size.
        new_cq_size = 1
        try:
            self.client.cq.resize(new_cq_size)
        except PyverbsRDMAError as ex:
            if ex.error_code == errno.EOPNOTSUPP:
                raise unittest.SkipTest('Resize CQ is not supported')
            raise ex
        self.assertTrue(
            self.client.cq.cqe >= new_cq_size,
            f'The actual CQ size ({self.client.cq.cqe}) is less '
            'than guaranteed ({new_cq_size})')

        # Increase the CQ size.
        new_cq_size = 7
        self.client.cq.resize(new_cq_size)
        self.assertTrue(
            self.client.cq.cqe >= new_cq_size,
            f'The actual CQ size ({self.client.cq.cqe}) is less '
            'than guaranteed ({new_cq_size})')

        # Fill the CQ entries except one for avoid cq_overrun warnings.
        send_wr, _ = u.get_send_elements(self.client, False)
        ah_client = u.get_global_ah(self.client, self.gid_index, self.ib_port)
        for i in range(self.client.cq.cqe - 1):
            u.send(self.client, send_wr, ah=ah_client)

        # Decrease the CQ size to less than the CQ unpolled entries.
        new_cq_size = 1
        with self.assertRaises(PyverbsRDMAError) as ex:
            self.client.cq.resize(new_cq_size)
        self.assertEqual(ex.exception.error_code, errno.EINVAL)
Ejemplo n.º 6
0
 def tm_traffic(self, tm_opcode=e.IBV_TMH_EAGER, fixed_send_tag=None):
     """
     Runs Tag matching traffic between two sides (server and client)
     :param tm_opcode: The TM opcode in the send WR
     :param fixed_send_tag: If not None complitions are expected to be with no tag
     """
     tags_list = list(range(1, self.iters))
     for recv_tag in tags_list:
         self.post_recv_tm(tag=recv_tag, wrid=recv_tag)
         actual_cqe = self.poll_cq_ex(cqex=self.server.cq)
         self.verify_cqe(actual_cqe=actual_cqe, wr_id=recv_tag, opcode=e.IBV_WC_TM_ADD)
     tags_list.reverse()
     for send_tag in tags_list:
         send_tag, tag_exp, wrid_exp, wc_flags = self.get_exp_params(
             fixed_send_tag=fixed_send_tag, send_tag=send_tag, tm_opcode=tm_opcode)
         send_wr, exp_msg = self.get_send_elements(tag=send_tag, tm_opcode=tm_opcode)
         u.send(self.client, send_wr)
         self.poll_cq_ex(cqex=self.client.cq, to_valid=False)
         actual_cqe = self.poll_cq_ex(cqex=self.server.cq)
         exp_recv_tm_opcode = e.IBV_WC_TM_NO_TAG if tm_opcode == e.IBV_TMH_NO_TAG else \
             e.IBV_WC_TM_RECV
         self.verify_cqe(actual_cqe=actual_cqe, wr_id=wrid_exp, opcode=exp_recv_tm_opcode,
                         wc_flags=wc_flags, tag=tag_exp)
         if tm_opcode == e.IBV_TMH_RNDV:
             actual_cqe = self.poll_cq_ex(cqex=self.client.cq)
             self.verify_cqe(actual_cqe=actual_cqe, opcode=e.IBV_WC_RECV, is_server=False)
             actual_cqe = self.poll_cq_ex(cqex=self.server.cq)
             self.verify_cqe(actual_cqe=actual_cqe, wr_id=wrid_exp, opcode=e.IBV_WC_TM_RECV,
                             wc_flags=e.IBV_WC_TM_DATA_VALID)
         actual_msg, exp_msg, msg_size = self.build_expected_and_recv_msgs \
             (exp_msg=exp_msg, tm_opcode=tm_opcode, fixed_send_tag=fixed_send_tag)
         self.validate_msg(actual_msg, exp_msg, msg_size)
         if fixed_send_tag and tm_opcode != e.IBV_TMH_NO_TAG:
             self.validate_exp_recv_params(exp_parm=self.curr_unexpected_cnt,
                                           recv_parm=self.server.unexp_cnt,
                                           descriptor='unexpected_count')
             self.curr_unexpected_cnt += 1
         u.post_recv(self.server, u.get_recv_wr(self.server))
Ejemplo n.º 7
0
 def traffic_with_bad_flow(client, server, iters, gid_idx, port):
     """
     Runs basic traffic with bad flow between two sides
     :param client: client side, clients base class is BaseTraffic
     :param server: server side, servers base class is BaseTraffic
     :param iters: number of traffic iterations
     :param gid_idx: local gid index
     :param port: IB port
     :return: None
     """
     import tests.utils as u
     send_op = e.IBV_QP_EX_WITH_SEND
     ah_client = u.get_global_ah(client, gid_idx, port)
     s_recv_wr = u.get_recv_wr(server)
     c_recv_wr = u.get_recv_wr(client)
     for qp_idx in range(server.qp_count):
         # Prepare the receive queue with RecvWR
         u.post_recv(client, c_recv_wr, qp_idx=qp_idx)
         u.post_recv(server, s_recv_wr, qp_idx=qp_idx)
     read_offset = 0
     for _ in range(iters):
         for qp_idx in range(server.qp_count):
             _, c_send_object = u.get_send_elements(client, False)
             u.send(client, c_send_object, send_op, True, qp_idx, ah_client,
                    False)
             try:
                 u.poll_cq(client.cq)
             except PyverbsError as ex:
                 if client.bad_flow_handling(qp_idx, ex, True):
                     continue
                 raise ex
             u.poll_cq(server.cq)
             u.post_recv(server, s_recv_wr, qp_idx=qp_idx)
             msg_received = server.mr.read(server.msg_size, read_offset)
             u.validate(msg_received, True, server.msg_size)
     client.check_after_traffic()