コード例 #1
0
 def test_dmabuf_reg_mr_bad_flags(self):
     """
     Verify that illegal flags combination fails as expected
     """
     check_dmabuf_support(self.gpu)
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             check_dmabuf_mr_support(pd, self.gpu)
             for i in range(5):
                 flags = random.sample([
                     e.IBV_ACCESS_REMOTE_WRITE, e.IBV_ACCESS_REMOTE_ATOMIC
                 ], random.randint(1, 2))
                 mr_flags = 0
                 for i in flags:
                     mr_flags += i.value
                 try:
                     DmaBufMR(pd,
                              u.get_mr_length(),
                              mr_flags,
                              gpu=self.gpu,
                              gtt=self.gtt)
                 except PyverbsRDMAError as err:
                     assert 'Failed to register a dma-buf MR' in err.args[0]
                 else:
                     raise PyverbsRDMAError(
                         'Registered a dma-buf MR with illegal falgs')
コード例 #2
0
 def test_dmabuf_read(self):
     """
     Test reading from DmaBufMR's buffer
     """
     check_dmabuf_support(self.gpu)
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             check_dmabuf_mr_support(pd, self.gpu)
             for i in range(10):
                 mr_len = u.get_mr_length()
                 flags = u.get_dmabuf_access_flags(ctx)
                 for f in flags:
                     for mr_off in [0, mr_len // 2]:
                         with DmaBufMR(pd,
                                       mr_len,
                                       f,
                                       offset=mr_off,
                                       gpu=self.gpu,
                                       gtt=self.gtt) as mr:
                             write_len = min(random.randint(1, MAX_IO_LEN),
                                             mr_len)
                             write_str = 'a' * write_len
                             mr.write(write_str, write_len)
                             read_len = random.randint(1, write_len)
                             offset = random.randint(
                                 0, write_len - read_len)
                             read_str = mr.read(read_len, offset).decode()
                             assert read_str in write_str
コード例 #3
0
 def create_mr(self):
     check_dmabuf_support(self.gpu)
     check_dmabuf_mr_support(self.pd, self.gpu)
     access = e.IBV_ACCESS_LOCAL_WRITE | e.IBV_ACCESS_REMOTE_WRITE
     mr = DmaBufMR(self.pd, self.msg_size, access, gpu=self.gpu,
                   gtt=self.gtt)
     self.mr = mr
コード例 #4
0
def check_dmabuf_mr_support(pd, gpu=0):
    """
    Check if dma-buf MR registration is supported by the driver.
    Skip the test on failure
    """
    try:
        DmaBufMR(pd, 1, 0, gpu=gpu)
    except PyverbsRDMAError as ex:
        if ex.error_code == errno.EOPNOTSUPP:
            raise unittest.SkipTest('Reg dma-buf MR is not supported by the RDMA driver')
コード例 #5
0
 def test_dmabuf_rkey(self):
     """
     Test reading rkey property
     """
     check_dmabuf_support(self.gpu)
     with PD(self.ctx) as pd:
         check_dmabuf_mr_support(pd, self.gpu)
         length = u.get_mr_length()
         flags = u.get_dmabuf_access_flags(self.ctx)
         for f in flags:
             with DmaBufMR(pd, length, f, unit=self.gpu,
                           gtt=self.gtt) as mr:
                 mr.rkey
コード例 #6
0
 def test_dmabuf_lkey(self):
     """
     Test reading lkey property
     """
     check_dmabuf_support(self.gpu)
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             check_dmabuf_mr_support(pd, self.gpu)
             length = u.get_mr_length()
             flags = u.get_dmabuf_access_flags(ctx)
             for f in flags:
                 with DmaBufMR(pd, length, f, gpu=self.gpu,
                               gtt=self.gtt) as mr:
                     mr.lkey
コード例 #7
0
 def test_dmabuf_dereg_mr(self):
     """
     Test ibv_dereg_mr() with DmaBufMR
     """
     check_dmabuf_support(self.gpu)
     with PD(self.ctx) as pd:
         check_dmabuf_mr_support(pd, self.gpu)
         flags = u.get_dmabuf_access_flags(self.ctx)
         for f in flags:
             len = u.get_mr_length()
             for off in [0, len//2]:
                 with DmaBufMR(pd, len, f, offset=off, unit=self.gpu,
                               gtt=self.gtt) as mr:
                     mr.close()
コード例 #8
0
ファイル: test_mr.py プロジェクト: fuchunliuliu/rdma-core
 def test_dmabuf_reg_mr(self):
     """
     Test ibv_reg_dmabuf_mr()
     """
     check_dmabuf_support(self.gpu)
     for ctx, attr, attr_ex in self.devices:
         with PD(ctx) as pd:
             check_dmabuf_mr_support(pd, self.gpu)
             flags = u.get_dmabuf_access_flags(ctx)
             for f in flags:
                 len = u.get_mr_length()
                 for off in [0, len//2]:
                     with DmaBufMR(pd, len, f, offset=off, gpu=self.gpu,
                                   gtt=self.gtt) as mr:
                         pass
コード例 #9
0
 def test_dmabuf_write(self):
     """
     Test writing to DmaBufMR's buffer
     """
     check_dmabuf_support(self.gpu)
     with PD(self.ctx) as pd:
         check_dmabuf_mr_support(pd, self.gpu)
         for i in range(10):
             mr_len = u.get_mr_length()
             flags = u.get_dmabuf_access_flags(self.ctx)
             for f in flags:
                 for mr_off in [0, mr_len//2]:
                     with DmaBufMR(pd, mr_len, f, offset=mr_off,
                                   unit=self.gpu, gtt=self.gtt) as mr:
                         write_len = min(random.randint(1, MAX_IO_LEN),
                                         mr_len)
                         mr.write('a' * write_len, write_len)
コード例 #10
0
 def test_dmabuf_dereg_mr_twice(self):
     """
     Verify that explicit call to DmaBufMR's close() doesn't fail
     """
     check_dmabuf_support(self.gpu)
     with PD(self.ctx) as pd:
         check_dmabuf_mr_support(pd, self.gpu)
         flags = u.get_dmabuf_access_flags(self.ctx)
         for f in flags:
             len = u.get_mr_length()
             for off in [0, len//2]:
                 with DmaBufMR(pd, len, f, offset=off, unit=self.gpu,
                               gtt=self.gtt) as mr:
                     # Pyverbs supports multiple destruction of objects,
                     # we are not expecting an exception here.
                     mr.close()
                     mr.close()