xref: /spdk/python/spdk/rpc/accel.py (revision 760cb0232b8a15d4632a102b81a4473adff9d3d2)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (C) 2022 Intel Corporation.
3#  All rights reserved.
4#
5
6from spdk.rpc.helpers import deprecated_alias
7
8
9def accel_get_opc_assignments(client):
10    """Get list of opcode name to module assignments.
11    """
12    return client.call('accel_get_opc_assignments')
13
14
15@deprecated_alias('accel_get_engine_info')
16def accel_get_module_info(client):
17    """Get list of valid module names and their operations.
18    """
19    return client.call('accel_get_module_info')
20
21
22def accel_assign_opc(client, opname, module):
23    """Manually assign an operation to a module.
24
25    Args:
26        opname: name of operation
27        module: name of module
28    """
29    params = {
30        'opname': opname,
31        'module': module,
32    }
33
34    return client.call('accel_assign_opc', params)
35
36
37def accel_crypto_key_create(client, cipher, key, key2, tweak_mode, name):
38    """Create Data Encryption Key Identifier.
39
40    Args:
41        cipher: cipher
42        key: key
43        key2: key2
44        tweak_mode: tweak mode
45        name: key name
46    """
47    params = {
48        'cipher': cipher,
49        'key': key,
50        'name': name,
51    }
52    if key2 is not None:
53        params['key2'] = key2
54    if tweak_mode is not None:
55        params['tweak_mode'] = tweak_mode
56
57    return client.call('accel_crypto_key_create', params)
58
59
60def accel_crypto_key_destroy(client, key_name):
61    """Destroy Data Encryption Key.
62
63    Args:
64        key_name: key name
65    """
66    params = {
67        'key_name': key_name
68    }
69
70    return client.call('accel_crypto_key_destroy', params)
71
72
73def accel_crypto_keys_get(client, key_name):
74    """Get a list of the crypto keys.
75
76    Args:
77        key_name: Get information about a specific key
78    """
79    params = {}
80
81    if key_name is not None:
82        params['key_name'] = key_name
83
84    return client.call('accel_crypto_keys_get', params)
85
86
87def accel_set_driver(client, name):
88    """Select accel platform driver to execute operation chains.
89
90    Args:
91        name: name of the driver
92    """
93    return client.call('accel_set_driver', {'name': name})
94
95
96def accel_set_options(client, small_cache_size, large_cache_size,
97                      task_count, sequence_count, buf_count):
98    """Set accel framework's options."""
99    params = {}
100
101    if small_cache_size is not None:
102        params['small_cache_size'] = small_cache_size
103    if large_cache_size is not None:
104        params['large_cache_size'] = large_cache_size
105    if task_count is not None:
106        params['task_count'] = task_count
107    if sequence_count is not None:
108        params['sequence_count'] = sequence_count
109    if buf_count is not None:
110        params['buf_count'] = buf_count
111
112    return client.call('accel_set_options', params)
113
114
115def accel_get_stats(client):
116    """Get accel framework's statistics"""
117
118    return client.call('accel_get_stats')
119
120
121def accel_error_inject_error(client, opcode, type, count=None, interval=None, errcode=None):
122    """Inject an error to processing accel operation"""
123    params = {}
124    if count is not None:
125        params['count'] = count
126    if interval is not None:
127        params['interval'] = interval
128    if errcode is not None:
129        params['errcode'] = errcode
130
131    return client.call('accel_error_inject_error',
132                       {'opcode': opcode, 'type': type, **params})
133