コード例 #1
0
 def test_dm_bad_access(self):
     """
     Test multiple types of bad access to the Device Memory. Device memory
     access requests a 4B alignment. The test tries to access the DM
     with bad alignment or outside of the allocated memory.
     """
     ctx, _, _ = self.devices[0]
     dm_size = 100
     with d.DM(ctx, d.AllocDmAttr(length=dm_size)) as dm:
         dm_access = e.IBV_ACCESS_ZERO_BASED | e.IBV_ACCESS_LOCAL_WRITE
         dmmr = DMMR(PD(ctx), dm_size, dm_access, dm, 0)
         access_cases = [
             (DM_INVALID_ALIGNMENT,
              4),  # Valid length with unaligned offset
             (4,
              DM_INVALID_ALIGNMENT),  # Valid offset with unaligned length
             (dm_size + 4, 4),  # Offset out of allocated memory
             (0, dm_size + 4)
         ]  # Length out of allocated memory
         for case in access_cases:
             offset, length = case
             with self.assertRaisesRegex(PyverbsRDMAError,
                                         'Failed to copy from dm'):
                 dmmr.read(offset=offset, length=length)
             with self.assertRaisesRegex(PyverbsRDMAError,
                                         'Failed to copy to dm'):
                 dmmr.write(data='s' * length, offset=offset, length=length)
コード例 #2
0
 def test_dm_bad_registration(self):
     """
     Test bad Device Memory registration when trying to register bigger DMMR
     than the allocated DM.
     """
     dm_size = 100
     with d.DM(self.ctx, d.AllocDmAttr(length=dm_size)) as dm:
         dm_access = e.IBV_ACCESS_ZERO_BASED | e.IBV_ACCESS_LOCAL_WRITE
         with self.assertRaisesRegex(PyverbsRDMAError, 'Failed to register a device MR'):
             DMMR(PD(self.ctx), dm_size + 4, dm_access, dm, 0)
コード例 #3
0
 def test_create_dm_mr(self):
     max_dm_size = self.attr_ex.max_dm_size
     dm_access = e.IBV_ACCESS_ZERO_BASED | e.IBV_ACCESS_LOCAL_WRITE
     for dm_size in [4, max_dm_size/4, max_dm_size/2]:
         dm_size = dm_size - (dm_size % u.DM_ALIGNMENT)
         for dmmr_factor_size in [0.1, 0.5, 1]:
             dmmr_size = dm_size * dmmr_factor_size
             dmmr_size = dmmr_size - (dmmr_size % u.DM_ALIGNMENT)
             with d.DM(self.ctx, d.AllocDmAttr(length=dm_size)) as dm:
                 DMMR(PD(self.ctx), dmmr_size, dm_access, dm, 0)
コード例 #4
0
 def create_mr(self):
     try:
         self.dm = d.DM(self.ctx, d.AllocDmAttr(length=self.msg_size))
         access = e.IBV_ACCESS_ZERO_BASED | e.IBV_ACCESS_LOCAL_WRITE
         if self.remote_access:
             access |= e.IBV_ACCESS_REMOTE_WRITE
         self.mr = DMMR(self.pd, self.msg_size, access, self.dm, 0)
     except PyverbsRDMAError as ex:
         if ex.error_code == errno.EOPNOTSUPP:
             raise unittest.SkipTest(f'Reg DMMR with access={access} is not supported')
         raise ex
コード例 #5
0
ファイル: mr.py プロジェクト: jggtest/rdma-plumbing
 def test_create_dm_mr(self):
     """
     Test ibv_reg_dm_mr
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             return
         with PD(ctx) as pd:
             for i in range(10):
                 dm_len = random.randrange(u.MIN_DM_SIZE, attr_ex.max_dm_size,
                                           u.DM_ALIGNMENT)
                 dm_attrs = u.get_dm_attrs(dm_len)
                 with d.DM(ctx, dm_attrs) as dm:
                     dm_mr_len = random.randint(1, dm_len)
                     dm_mr_offset = random.randint(0, (dm_len - dm_mr_len))
                     DMMR(pd, dm_mr_len, e.IBV_ACCESS_ZERO_BASED, dm=dm,
                          offset=dm_mr_offset)
コード例 #6
0
ファイル: mr.py プロジェクト: rhiswell/rdma-core
 def test_create_dm_mr(self):
     """
     Test ibv_reg_dm_mr
     """
     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
             with PD(ctx) as pd:
                 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:
                     dm_mr_len = random.randint(1, dm_len)
                     dm_mr_offset = random.randint(0, (dm_len - dm_mr_len))
                     dm_mr = DMMR(pd,
                                  dm_mr_len,
                                  e.IBV_ACCESS_ZERO_BASED,
                                  dm=dm,
                                  offset=dm_mr_offset)
コード例 #7
0
 def test_destroy_dm_mr(self):
     """
     Test freeing of dm_mr
     """
     for ctx, attr, attr_ex in self.devices:
         if attr_ex.max_dm_size == 0:
             raise unittest.SkipTest('Device memory is not supported')
         with PD(ctx) as pd:
             for i in range(10):
                 dm_len = random.randrange(u.MIN_DM_SIZE,
                                           attr_ex.max_dm_size / 2,
                                           u.DM_ALIGNMENT)
                 dm_attrs = u.get_dm_attrs(dm_len)
                 with d.DM(ctx, dm_attrs) as dm:
                     dm_mr_len = random.randint(1, dm_len)
                     dm_mr_offset = random.randint(0, (dm_len - dm_mr_len))
                     dm_mr = DMMR(pd,
                                  dm_mr_len,
                                  e.IBV_ACCESS_ZERO_BASED,
                                  dm=dm,
                                  offset=dm_mr_offset)
                     dm_mr.close()