Esempio n. 1
0
 def test_open_dev():
     """
     Test ibv_open_device()
     """
     lst = d.get_device_list()
     for dev in lst:
         d.Context(name=dev.name.decode())
Esempio n. 2
0
 def test_create_cq_ex_bad_flow():
     """
     Test ibv_create_cq_ex() with wrong comp_vector / number of cqes
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attrs_ex = get_attrs_ex(ctx)
             max_cqe = ctx.query_device().max_cqe
             attrs_ex.cqe = max_cqe + random.randint(1, 100)
             try:
                 CQEX(ctx, attrs_ex)
             except PyverbsError as e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with {c} CQEs while device\'s max CQE={dc}'
                     .format(c=attrs_ex.cqe, dc=max_cqe))
             comp_channel = random.randint(ctx.num_comp_vectors, 100)
             attrs_ex.comp_vector = comp_channel
             attrs_ex.cqe = get_num_cqes(ctx)
             try:
                 CQEX(ctx, attrs_ex)
             except PyverbsError as e:
                 assert 'Failed to create extended CQ' in e.args[0]
                 assert ' Errno: 22' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a CQEX with comp_vector={c} while device\'s num_comp_vectors={dc}'
                     .format(c=comp_channel, dc=ctx.num_comp_vectors))
Esempio n. 3
0
 def get_port_space(self):
     ctx = d.Context(name=self.dev_name)
     dev_attrs = ctx.query_port(self.ib_port)
     port_space = ce.RDMA_PS_IPOIB \
         if dev_attrs.link_layer == e.IBV_LINK_LAYER_INFINIBAND \
             else ce.RDMA_PS_UDP
     return port_space
Esempio n. 4
0
 def test_create_dm_bad_flow(self):
     """
     test ibv_alloc_dm() with an illegal size and comp mask
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr = ctx.query_device_ex()
             if attr.max_dm_size == 0:
                 return
             dm_len = attr.max_dm_size + 1
             dm_attrs = u.get_dm_attrs(dm_len)
             try:
                 dm = d.DM(ctx, dm_attrs)
             except PyverbsRDMAError as e:
                 assert 'Failed to allocate device memory of size' in e.args[
                     0]
                 assert 'Max available size' in e.args[0]
             else:
                 raise PyverbsError(
                     'Created a DM with size larger than max reported')
             dm_attrs.comp_mask = random.randint(1, 100)
             try:
                 dm = d.DM(ctx, dm_attrs)
             except PyverbsRDMAError as e:
                 assert 'Failed to allocate device memory of size' in e.args[
                     0]
             else:
                 raise PyverbsError('Created a DM with illegal comp mask {c}'.\
                                    format(c=dm_attrs.comp_mask))
Esempio n. 5
0
 def test_dm_write_bad_flow(self):
     """
     Test writing to the device memory with bad offset and length
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr = ctx.query_device_ex()
             if attr.max_dm_size == 0:
                 return
             dm_len = random.randrange(u.MIN_DM_SIZE, attr.max_dm_size,
                                       u.DM_ALIGNMENT)
             dm_attrs = u.get_dm_attrs(dm_len)
             with d.DM(ctx, dm_attrs) as dm:
                 data_length = random.randrange(4, dm_len, u.DM_ALIGNMENT)
                 data_offset = random.randrange(0, dm_len - data_length,
                                                u.DM_ALIGNMENT)
                 data_offset += 1  # offset needs to be a multiple of 4
                 data = u.get_data(data_length)
                 try:
                     dm.copy_to_dm(data_offset, data.encode(), data_length)
                 except PyverbsRDMAError as e:
                     assert 'Failed to copy to dm' in e.args[0]
                 else:
                     raise PyverbsError(
                         'Wrote to device memory with a bad offset')
Esempio n. 6
0
 def test_query_gid(self):
     """
     Test ibv_query_gid()
     """
     for dev in self.get_device_list():
         with d.Context(name=dev.name.decode()) as ctx:
             ctx.query_gid(port_num=self.ib_port, index=0)
Esempio n. 7
0
 def test_query_port(self):
     """
     Test ibv_query_port
     """
     for dev in self.get_device_list():
         with d.Context(name=dev.name.decode()) as ctx:
             port_attr = ctx.query_port(self.ib_port)
             self.verify_port_attr(port_attr)
Esempio n. 8
0
 def test_query_gid():
     """
     Test ibv_query_gid()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             ctx.query_gid(port_num=1, index=0)
Esempio n. 9
0
 def test_query_device(self):
     """
     Test ibv_query_device()
     """
     for dev in self.get_device_list():
         with d.Context(name=dev.name.decode()) as ctx:
             attr = ctx.query_device()
             self.verify_device_attr(attr, dev)
Esempio n. 10
0
 def test_query_pkey(self):
     """
     Test ibv_query_pkey()
     """
     for dev in self.get_device_list():
         with d.Context(name=dev.name.decode()) as ctx:
             if dev.node_type == e.IBV_NODE_CA:
                 ctx.query_pkey(port_num=self.ib_port, index=0)
 def test_query_device(self):
     """
     Test ibv_query_device()
     """
     lst = d.get_device_list()
     for dev in lst:
         ctx = d.Context(name=dev.name.decode())
         ctx.query_device()
Esempio n. 12
0
 def test_dereg_mr(self):
     """ Test ibv_dereg_mr() """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 with MR(pd, u.get_mr_length(), u.get_access_flags()) as mr:
                     mr.close()
Esempio n. 13
0
 def test_query_device_ex(self):
     """
     Test ibv_query_device_ex()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr_ex = ctx.query_device_ex()
             self.verify_device_attr(attr_ex.orig_attr)
Esempio n. 14
0
 def setUp(self):
     super().setUp()
     self.iters = 10
     self.server = None
     self.client = None
     self.traffic_args = None
     ctx = d.Context(name=self.dev_name)
     if ctx.query_device().atomic_caps == e.IBV_ATOMIC_NONE:
         raise unittest.SkipTest('Atomic operations are not supported')
Esempio n. 15
0
 def test_open_dev():
     """
     Test ibv_open_device()
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         d.Context(name=dev.name.decode())
Esempio n. 16
0
 def test_alloc_pd(self):
     """
     Test ibv_alloc_pd()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx):
                 pass
Esempio n. 17
0
 def test_create_cq_ex():
     """
     Test ibv_create_cq_ex()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CQEX(ctx, get_attrs_ex(ctx)):
                 pass
Esempio n. 18
0
 def test_dealloc_pd():
     """
     Test ibv_dealloc_pd()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 pd.close()
Esempio n. 19
0
 def test_destroy_cq_ex():
     """
     Test ibv_destroy_cq() for extended CQs
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CQEX(ctx, get_attrs_ex(ctx)) as cq:
                 cq.close()
Esempio n. 20
0
 def test_destroy_comp_channel():
     """
     Test ibv_destroy_comp_channel()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             cc = CompChannel(ctx)
             cc.close()
Esempio n. 21
0
 def test_create_comp_channel():
     """
     Test ibv_create_comp_channel()
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with CompChannel(ctx):
                 pass
Esempio n. 22
0
 def test_multiple_pd_creation():
     """
     Test multiple creations and destructions of a PD object
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             for i in range(random.randint(1, 200)):
                 with PD(ctx) as pd:
                     pd.close()
Esempio n. 23
0
 def test_query_gid():
     """
     Test ibv_query_gid()
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             ctx.query_gid(port_num=1, index=0)
Esempio n. 24
0
 def test_dereg_mw(self):
     """ Test ibv_dealloc_mw() """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 with MW(pd,
                         random.choice([e.IBV_MW_TYPE_1,
                                        e.IBV_MW_TYPE_2])) as mw:
                     mw.close()
Esempio n. 25
0
 def test_query_port(self):
     """
     Test ibv_query_port
     """
     for dev in self.get_device_list():
         with d.Context(name=dev.name.decode()) as ctx:
             num_ports = ctx.query_device().phys_port_cnt
             for p in range(num_ports):
                 port_attr = ctx.query_port(p + 1)
                 self.verify_port_attr(port_attr)
Esempio n. 26
0
    def setUp(self):
        """
        Verify that the test case has dev_name, ib_port, gid_index and pkey index.
        If not provided by the user, the first valid combination will be used.
        """
        if self.pkey_index is None:
            # To avoid iterating the entire pkeys table, if a pkey index wasn't
            # provided, use index 0 which is always valid
            self.pkey_index = 0

        self.args = []
        if self.dev_name is not None:
            ctx = d.Context(name=self.dev_name)
            if self.ib_port is not None:
                if self.gid_index is not None:
                    # We have all we need, return
                    return
                else:
                    # Add avaiable GIDs of the given dev_name + port
                    self._add_gids_per_port(ctx, self.dev_name, self.ib_port)
            else:
                # Add available GIDs for each port of the given dev_name
                self._add_gids_per_device(ctx, self.dev_name)
        else:
            # Iterate available devices, add available GIDs for each of
            # their ports
            lst = d.get_device_list()
            for dev in lst:
                dev_name = dev.name.decode()
                ctx = d.Context(name=dev_name)
                self._add_gids_per_device(ctx, dev_name)

        if not self.args:
            raise unittest.SkipTest(
                'No supported port is up, can\'t run traffic')
        # Choose one combination and use it
        self._select_config()
        self.dev_info = {
            'dev_name': self.dev_name,
            'ib_port': self.ib_port,
            'gid_index': self.gid_index
        }
Esempio n. 27
0
 def test_query_device_ex(self):
     """
     Test ibv_query_device_ex()
     """
     lst = d.get_device_list()
     if len(lst) == 0:
         raise unittest.SkipTest('No IB devices found')
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             attr_ex = ctx.query_device_ex()
             self.verify_device_attr(attr_ex.orig_attr)
Esempio n. 28
0
 def setUp(self):
     """
     Opens the devices and queries them
     """
     lst = d.get_device_list()
     self.devices = []
     for dev in lst:
         c = d.Context(name=dev.name.decode())
         attr = c.query_device()
         attr_ex = c.query_device_ex()
         self.devices.append((c, attr, attr_ex))
Esempio n. 29
0
 def test_buffer(self):
     """
     Test reading buf property
     """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 length = u.get_mr_length()
                 with MR(pd, length, u.get_access_flags()) as mr:
                     buf = mr.buf
Esempio n. 30
0
 def test_dereg_mr_twice(self):
     """ Verify that explicit call to MR's close() doesn't fails """
     lst = d.get_device_list()
     for dev in lst:
         with d.Context(name=dev.name.decode()) as ctx:
             with PD(ctx) as pd:
                 with MR(pd, u.get_mr_length(), u.get_access_flags()) as mr:
                     # Pyverbs supports multiple destruction of objects, we are
                     # not expecting an exception here.
                     mr.close()
                     mr.close()