def _create_mr_devx(self, rdma_device, buf_size):
            """This method create mkey and memory buffer using devx (part of ofed driver).
            """
            mlx5dv_attr = Mlx5DVContextAttr()
            self.ctx = Mlx5Context(mlx5dv_attr, name=rdma_device)
            self.my_pd = PD(self.ctx)
            self.dv_pd = Mlx5DvObj(dve.MLX5DV_OBJ_PD, pd=self.my_pd).dvpd
            self.umem = self._create_umem(self.ctx, buf_size)
            self.mkey_ctx = SwMkc(umr_en=0,
                                  lr=1,
                                  lw=1,
                                  access_mode_1_0=0x1,
                                  pd=self.dv_pd.pdn,
                                  start_addr=self.umem.umem_addr,
                                  len=buf_size)
            mkey_in = CreateMkeyIn(sw_mkc=self.mkey_ctx,
                                   mkey_umem_id=self.umem.umem_id,
                                   mkey_umem_valid=1)
            self.mkey_obj = Mlx5DevxObj(self.ctx, mkey_in,
                                        len(CreateMkeyOut()))
            mkey_out = CreateMkeyOut(self.mkey_obj.out_view)
            if mkey_out.status:
                raise PyverbsRDMAError(
                    "Failed to create mkey with syndrome {0}".format(
                        mkey_out.syndrome))

            mkey_index = mkey_out.mkey_index
            self.lkey = mkey_index << 8
 def func_wrapper(instance):
     try:
         ctx = Mlx5Context(Mlx5DVContextAttr(), instance.dev_name)
     except PyverbsUserError as ex:
         raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
     except PyverbsRDMAError:
         raise unittest.SkipTest('Opening mlx5 context is not supported')
     # Query NIC Flow Table capabilities
     cmd_in = struct.pack('!HIH8s', MLX5_CMD_OP_QUERY_HCA_CAP, 0,
                          MLX5_CMD_MOD_NIC_FLOW_TABLE_CAP << 1 | 0x1,
                          bytes(8))
     try:
         cmd_out = Mlx5Context.devx_general_cmd(
             ctx, cmd_in, MLX5_CMD_OP_QUERY_HCA_CAP_OUT_LEN)
     except PyverbsRDMAError as ex:
         if ex.error_code in [errno.EOPNOTSUPP, errno.EPROTONOSUPPORT]:
             raise unittest.SkipTest(
                 'DevX general command is not supported')
         raise ex
     cmd_view = memoryview(cmd_out)
     status = cmd_view[0]
     if status:
         raise PyverbsRDMAError(
             'Query NIC Flow Table CAPs failed with status'
             f' ({status})')
     # Verify that both NIC RX and TX support reformat actions by checking
     # the following PRM fields: encap_general_header,
     # log_max_packet_reformat, and reformat (for both RX and TX).
     if not (cmd_view[20] & 0x80 and cmd_view[21] & 0x1f
             and cmd_view[80] & 0x1 and cmd_view[272] & 0x1):
         raise unittest.SkipTest('NIC flow table does not support reformat')
     return func(instance)
Exemple #3
0
 def create_context(self):
     mlx5dv_attr = Mlx5DVContextAttr()
     try:
         self.ctx = Mlx5Context(mlx5dv_attr, name=self.dev_name)
     except PyverbsUserError as ex:
         raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
     except PyverbsRDMAError:
         raise unittest.SkipTest('Opening mlx5 context is not supported')
 def create_context(self):
     try:
         attr = Mlx5DVContextAttr(dve.MLX5DV_CONTEXT_FLAGS_DEVX)
         self.ctx = Mlx5Context(attr, self.dev_name)
     except PyverbsUserError as ex:
         raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
     except PyverbsRDMAError:
         raise unittest.SkipTest('Opening mlx5 DevX context is not supported')
Exemple #5
0
 def __init__(self, dev_name):
     try:
         mlx5dv_attr = Mlx5DVContextAttr(e.MLX5DV_CONTEXT_FLAGS_DEVX)
         self.ctx = Mlx5Context(mlx5dv_attr, dev_name)
     except PyverbsUserError as ex:
         raise unittest.SkipTest('Could not open mlx5 context ({})'.format(
             str(ex)))
     except PyverbsRDMAError:
         raise unittest.SkipTest(
             'Opening mlx5 DevX context is not supported')
     self.pps = []
Exemple #6
0
 def create_context(self):
     mlx5dv_attr = Mlx5DVContextAttr()
     try:
         self.ctx = Mlx5Context(mlx5dv_attr, name=self.dev_name)
     except PyverbsUserError as ex:
         raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
     except PyverbsRDMAError:
         raise unittest.SkipTest('Opening mlx5 context is not supported')
     if self.requested_dev_cap:
         if not self.ctx.query_mlx5_device().flags & self.requested_dev_cap:
             miss_caps = context_flags_to_str(self.requested_dev_cap)
             raise unittest.SkipTest(f'Device caps doesn\'t support {miss_caps}')
Exemple #7
0
def check_crypto_caps(dev_name):
    """
    Check that this device support crypto actions.
    :param dev_name: The device name.
    """
    mlx5dv_attr = Mlx5DVContextAttr()
    ctx = Mlx5Context(mlx5dv_attr, name=dev_name)
    crypto_caps = ctx.query_mlx5_device().crypto_caps
    failed_selftests = crypto_caps['failed_selftests']
    if failed_selftests:
        raise unittest.SkipTest(f'The device crypto selftest failed ({failed_selftests})')
    if not dve.MLX5DV_CRYPTO_ENGINES_CAP_AES_XTS & crypto_caps['crypto_engines']:
        raise unittest.SkipTest('The device crypto engines does not support AES')
Exemple #8
0
    def test_dma_memcpy_large_data_bad_flow(self):
        """
        Bad flow test, testing DMA memcpy with data larger than the maximum
        allowed size, according to the HCA capabilities.
        :return: None
        """
        try:
            ctx = Mlx5Context(Mlx5DVContextAttr(), name=self.dev_name)
        except PyverbsUserError as ex:
            raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
        except PyverbsRDMAError:
            raise unittest.SkipTest('Opening mlx5 context is not supported')
        max_size = ctx.query_mlx5_device(
            dve.MLX5DV_CONTEXT_MASK_WR_MEMCPY_LENGTH).max_wr_memcpy_length
        max_size = max_size if max_size else 1024

        with self.assertRaises(PyverbsRDMAError):
            self.dma_memcpy(max_size + 1)
 def func_wrapper(instance):
     try:
         ctx = Mlx5Context(Mlx5DVContextAttr(), instance.dev_name)
     except PyverbsUserError as ex:
         raise unittest.SkipTest(f'Could not open mlx5 context ({ex})')
     except PyverbsRDMAError:
         raise unittest.SkipTest('Opening mlx5 context is not supported')
     # Query NIC Flow Table capabilities
     cmd_in = struct.pack('!HIH8s', MLX5_CMD_OP_QUERY_HCA_CAP, 0,
                          MLX5_CMD_MOD_NIC_FLOW_TABLE_CAP << 1 | 0x1,
                          bytes(8))
     cmd_out = Mlx5Context.devx_general_cmd(
         ctx, cmd_in, MLX5_CMD_OP_QUERY_HCA_CAP_OUT_LEN)
     cmd_view = memoryview(cmd_out)
     status = cmd_view[0]
     if status:
         raise PyverbsRDMAError(
             'Query NIC Flow Table CAPs failed with status'
             f' ({status})')
     # Verify that both NIC RX and TX support reformat actions
     if not (cmd_view[80] & 0x1 and cmd_view[272] & 0x1):
         raise unittest.SkipTest('NIC flow table does not support reformat')
     return func(instance)