spdk 25.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. spdk/__init__.py +9 -0
  2. spdk/rpc/__init__.py +240 -0
  3. spdk/rpc/accel.py +132 -0
  4. spdk/rpc/app.py +142 -0
  5. spdk/rpc/bdev.py +1725 -0
  6. spdk/rpc/blobfs.py +62 -0
  7. spdk/rpc/client.py +281 -0
  8. spdk/rpc/cmd_parser.py +35 -0
  9. spdk/rpc/compressdev.py +15 -0
  10. spdk/rpc/dpdk_cryptodev.py +26 -0
  11. spdk/rpc/dsa.py +19 -0
  12. spdk/rpc/env_dpdk.py +13 -0
  13. spdk/rpc/fsdev.py +71 -0
  14. spdk/rpc/helpers.py +20 -0
  15. spdk/rpc/iaa.py +12 -0
  16. spdk/rpc/ioat.py +12 -0
  17. spdk/rpc/iobuf.py +35 -0
  18. spdk/rpc/iscsi.py +647 -0
  19. spdk/rpc/keyring.py +22 -0
  20. spdk/rpc/log.py +70 -0
  21. spdk/rpc/lvol.py +343 -0
  22. spdk/rpc/mlx5.py +40 -0
  23. spdk/rpc/nbd.py +24 -0
  24. spdk/rpc/notify.py +30 -0
  25. spdk/rpc/nvme.py +140 -0
  26. spdk/rpc/nvmf.py +799 -0
  27. spdk/rpc/sock.py +89 -0
  28. spdk/rpc/subsystem.py +16 -0
  29. spdk/rpc/trace.py +65 -0
  30. spdk/rpc/ublk.py +48 -0
  31. spdk/rpc/vfio_user.py +141 -0
  32. spdk/rpc/vhost.py +198 -0
  33. spdk/rpc/vmd.py +21 -0
  34. spdk/sma/__init__.py +21 -0
  35. spdk/sma/common.py +25 -0
  36. spdk/sma/device/__init__.py +9 -0
  37. spdk/sma/device/device.py +44 -0
  38. spdk/sma/device/nvmf_tcp.py +250 -0
  39. spdk/sma/device/nvmf_vfiouser.py +329 -0
  40. spdk/sma/device/vhost_blk.py +228 -0
  41. spdk/sma/proto/.gitignore +2 -0
  42. spdk/sma/proto/__init__.py +3 -0
  43. spdk/sma/qmp.py +290 -0
  44. spdk/sma/qos.py +63 -0
  45. spdk/sma/sma.py +199 -0
  46. spdk/sma/volume/__init__.py +11 -0
  47. spdk/sma/volume/crypto.py +91 -0
  48. spdk/sma/volume/crypto_bdev.py +136 -0
  49. spdk/sma/volume/volume.py +330 -0
  50. spdk/spdk_cli.py +93 -0
  51. spdk/spdk_rpc.py +4088 -0
  52. spdk/spdk_sma.py +158 -0
  53. spdk/spdkcli/__init__.py +5 -0
  54. spdk/spdkcli/ui_node.py +916 -0
  55. spdk/spdkcli/ui_node_iscsi.py +643 -0
  56. spdk/spdkcli/ui_node_nvmf.py +432 -0
  57. spdk/spdkcli/ui_root.py +592 -0
  58. spdk/version.py +1 -0
  59. spdk-25.5.dist-info/METADATA +84 -0
  60. spdk-25.5.dist-info/RECORD +62 -0
  61. spdk-25.5.dist-info/WHEEL +4 -0
  62. spdk-25.5.dist-info/entry_points.txt +4 -0
spdk/__init__.py ADDED
@@ -0,0 +1,9 @@
1
+ # SPDX-License-Identifier: BSD-3-Clause
2
+ # Copyright (C) 2021 Intel Corporation.
3
+ # All rights reserved.
4
+
5
+ try:
6
+ # version.py is generated during the build, so ignore it if it doesn't exist
7
+ from .version import __version__
8
+ except ModuleNotFoundError:
9
+ __version__ = '0.0'
spdk/rpc/__init__.py ADDED
@@ -0,0 +1,240 @@
1
+ # SPDX-License-Identifier: BSD-3-Clause
2
+ # Copyright (C) 2017 Intel Corporation.
3
+ # All rights reserved.
4
+
5
+ import json
6
+ import os
7
+ import sys
8
+
9
+ from io import IOBase as io
10
+
11
+ from . import accel
12
+ from . import app
13
+ from . import bdev
14
+ from . import blobfs
15
+ from . import compressdev
16
+ from . import fsdev
17
+ from . import env_dpdk
18
+ from . import dsa
19
+ from . import iaa
20
+ from . import ioat
21
+ from . import iscsi
22
+ from . import keyring
23
+ from . import log
24
+ from . import lvol
25
+ from . import nbd
26
+ from . import ublk
27
+ from . import notify
28
+ from . import nvme
29
+ from . import nvmf
30
+ from . import subsystem
31
+ from . import trace
32
+ from . import vhost
33
+ from . import vmd
34
+ from . import sock
35
+ from . import vfio_user
36
+ from . import iobuf
37
+ from . import dpdk_cryptodev
38
+ from . import mlx5
39
+ from . import client as rpc_client
40
+
41
+
42
+ def framework_start_init(client):
43
+ """Start initialization of subsystems"""
44
+ return client.call('framework_start_init')
45
+
46
+
47
+ def framework_wait_init(client):
48
+ """Block until subsystems have been initialized"""
49
+ return client.call('framework_wait_init')
50
+
51
+
52
+ def framework_disable_cpumask_locks(client):
53
+ """ Disable CPU core lock files."""
54
+ return client.call('framework_disable_cpumask_locks')
55
+
56
+
57
+ def framework_enable_cpumask_locks(client):
58
+ """ Enable CPU core lock files."""
59
+ return client.call('framework_enable_cpumask_locks')
60
+
61
+
62
+ def rpc_get_methods(client, current=None, include_aliases=None):
63
+ """Get list of supported RPC methods.
64
+ Args:
65
+ current: Get list of RPC methods only callable in the current state.
66
+ include_aliases: Include aliases in the list with RPC methods.
67
+ """
68
+ params = {}
69
+
70
+ if current:
71
+ params['current'] = current
72
+ if include_aliases:
73
+ params['include_aliases'] = include_aliases
74
+
75
+ return client.call('rpc_get_methods', params)
76
+
77
+
78
+ def spdk_get_version(client):
79
+ """Get SPDK version"""
80
+ return client.call('spdk_get_version')
81
+
82
+
83
+ def _json_dump(config, fd, indent):
84
+ if indent is None:
85
+ indent = 2
86
+ elif indent < 0:
87
+ indent = None
88
+ json.dump(config, fd, indent=indent)
89
+ fd.write('\n')
90
+
91
+
92
+ def _json_load(j):
93
+ if j == sys.stdin or isinstance(j, io):
94
+ json_conf = json.load(j)
95
+ elif os.path.exists(j):
96
+ with open(j, "r") as j:
97
+ json_conf = json.load(j)
98
+ else:
99
+ json_conf = json.loads(j)
100
+ return json_conf
101
+
102
+
103
+ def save_config(client, fd, indent=2, subsystems=None):
104
+ """Write current (live) configuration of SPDK subsystems and targets to stdout.
105
+ Args:
106
+ fd: opened file descriptor where data will be saved
107
+ indent: Indent level. Value less than 0 mean compact mode.
108
+ Default indent level is 2.
109
+ subsystems: subsystems (and their dependencies) to save
110
+ """
111
+ config = {
112
+ 'subsystems': []
113
+ }
114
+
115
+ subsystems_json = client.call('framework_get_subsystems')
116
+
117
+ # Build a dictionary of all subsystems to their fully expanded set of
118
+ # dependencies.
119
+ dependencies = dict()
120
+ for elem in subsystems_json:
121
+ subsystem = elem['subsystem']
122
+ dependencies[subsystem] = {subsystem}
123
+ for d in elem['depends_on']:
124
+ dependencies[subsystem].update(dependencies[d])
125
+
126
+ # Build a set of all of the subsystems to print based on the
127
+ # subsystems parameter.
128
+ to_print = set()
129
+ if subsystems is None:
130
+ to_print = dependencies.keys()
131
+ else:
132
+ for s in subsystems.split(','):
133
+ to_print.update(dependencies[s])
134
+
135
+ def _print(x): return x['subsystem'] in to_print
136
+ for elem in filter(_print, subsystems_json):
137
+ cfg = {
138
+ 'subsystem': elem['subsystem'],
139
+ 'config': client.call('framework_get_config', {"name": elem['subsystem']})
140
+ }
141
+ config['subsystems'].append(cfg)
142
+
143
+ _json_dump(config, fd, indent)
144
+
145
+
146
+ def load_config(client, fd, include_aliases=False):
147
+ """Configure SPDK subsystems and targets using JSON RPC read from stdin.
148
+ Args:
149
+ fd: opened file descriptor where data will be taken from
150
+ """
151
+ json_config = _json_load(fd)
152
+
153
+ # remove subsystems with no config
154
+ subsystems = json_config['subsystems']
155
+ for subsystem in list(subsystems):
156
+ if not subsystem['config']:
157
+ subsystems.remove(subsystem)
158
+
159
+ # check if methods in the config file are known
160
+ allowed_methods = client.call('rpc_get_methods', {'include_aliases': include_aliases})
161
+ if not subsystems and 'framework_start_init' in allowed_methods:
162
+ framework_start_init(client)
163
+ return
164
+
165
+ for subsystem in list(subsystems):
166
+ config = subsystem['config']
167
+ for elem in list(config):
168
+ if 'method' not in elem or elem['method'] not in allowed_methods:
169
+ raise rpc_client.JSONRPCException("Unknown method was included in the config file")
170
+
171
+ while subsystems:
172
+ allowed_methods = client.call('rpc_get_methods', {'current': True,
173
+ 'include_aliases': include_aliases})
174
+ allowed_found = False
175
+
176
+ for subsystem in list(subsystems):
177
+ config = subsystem['config']
178
+ for elem in list(config):
179
+ if 'method' not in elem or elem['method'] not in allowed_methods:
180
+ continue
181
+
182
+ client.call(**elem)
183
+ config.remove(elem)
184
+ allowed_found = True
185
+
186
+ if not config:
187
+ subsystems.remove(subsystem)
188
+
189
+ if 'framework_start_init' in allowed_methods:
190
+ framework_start_init(client)
191
+ allowed_found = True
192
+
193
+ if not allowed_found:
194
+ break
195
+
196
+ if subsystems:
197
+ print("Some configs were skipped because the RPC state that can call them passed over.")
198
+
199
+
200
+ def save_subsystem_config(client, fd, indent=2, name=None):
201
+ """Write current (live) configuration of SPDK subsystem to stdout.
202
+ Args:
203
+ fd: opened file descriptor where data will be saved
204
+ indent: Indent level. Value less than 0 mean compact mode.
205
+ Default is indent level 2.
206
+ """
207
+ cfg = {
208
+ 'subsystem': name,
209
+ 'config': client.call('framework_get_config', {"name": name})
210
+ }
211
+
212
+ _json_dump(cfg, fd, indent)
213
+
214
+
215
+ def load_subsystem_config(client, fd):
216
+ """Configure SPDK subsystem using JSON RPC read from stdin.
217
+ Args:
218
+ fd: opened file descriptor where data will be taken from
219
+ """
220
+ subsystem = _json_load(fd)
221
+
222
+ if not subsystem['config']:
223
+ return
224
+
225
+ allowed_methods = client.call('rpc_get_methods')
226
+ config = subsystem['config']
227
+ for elem in list(config):
228
+ if 'method' not in elem or elem['method'] not in allowed_methods:
229
+ raise rpc_client.JSONRPCException("Unknown method was included in the config file")
230
+
231
+ allowed_methods = client.call('rpc_get_methods', {'current': True})
232
+ for elem in list(config):
233
+ if 'method' not in elem or elem['method'] not in allowed_methods:
234
+ continue
235
+
236
+ client.call(**elem)
237
+ config.remove(elem)
238
+
239
+ if config:
240
+ print("Some configs were skipped because they cannot be called in the current RPC state.")
spdk/rpc/accel.py ADDED
@@ -0,0 +1,132 @@
1
+ # SPDX-License-Identifier: BSD-3-Clause
2
+ # Copyright (C) 2022 Intel Corporation.
3
+ # All rights reserved.
4
+ #
5
+
6
+ from spdk.rpc.helpers import deprecated_alias
7
+
8
+
9
+ def 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')
16
+ def 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
+
22
+ def 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
+
37
+ def 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
+
60
+ def 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
+
73
+ def 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
+
87
+ def 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
+
96
+ def 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
+
115
+ def accel_get_stats(client):
116
+ """Get accel framework's statistics"""
117
+
118
+ return client.call('accel_get_stats')
119
+
120
+
121
+ def 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})
spdk/rpc/app.py ADDED
@@ -0,0 +1,142 @@
1
+ # SPDX-License-Identifier: BSD-3-Clause
2
+ # Copyright (C) 2017 Intel Corporation.
3
+ # All rights reserved.
4
+
5
+
6
+ def spdk_kill_instance(client, sig_name):
7
+ """Send a signal to the SPDK process.
8
+
9
+ Args:
10
+ sig_name: signal to send ("SIGINT", "SIGTERM", "SIGQUIT", "SIGHUP", or "SIGKILL")
11
+ """
12
+ params = {'sig_name': sig_name}
13
+ return client.call('spdk_kill_instance', params)
14
+
15
+
16
+ def framework_monitor_context_switch(client, enabled=None):
17
+ """Query or set state of context switch monitoring.
18
+
19
+ Args:
20
+ enabled: True to enable monitoring; False to disable monitoring; None to query (optional)
21
+
22
+ Returns:
23
+ Current context switch monitoring state (after applying enabled flag).
24
+ """
25
+ params = {}
26
+ if enabled is not None:
27
+ params['enabled'] = enabled
28
+ return client.call('framework_monitor_context_switch', params)
29
+
30
+
31
+ def framework_get_reactors(client):
32
+ """Query list of all reactors.
33
+
34
+ Returns:
35
+ List of all reactors.
36
+ """
37
+ return client.call('framework_get_reactors')
38
+
39
+
40
+ def framework_set_scheduler(client, name, period=None, load_limit=None, core_limit=None,
41
+ core_busy=None, mappings=None):
42
+ """Select threads scheduler that will be activated and its period.
43
+
44
+ Args:
45
+ name: Name of a scheduler
46
+ period: Scheduler period in microseconds
47
+ Returns:
48
+ True or False
49
+ """
50
+ params = {'name': name}
51
+ if period is not None:
52
+ params['period'] = period
53
+ if load_limit is not None:
54
+ params['load_limit'] = load_limit
55
+ if core_limit is not None:
56
+ params['core_limit'] = core_limit
57
+ if core_busy is not None:
58
+ params['core_busy'] = core_busy
59
+ if mappings is not None:
60
+ params['mappings'] = mappings
61
+ return client.call('framework_set_scheduler', params)
62
+
63
+
64
+ def framework_get_scheduler(client):
65
+ """Query currently set scheduler.
66
+
67
+ Returns:
68
+ Name, period (in microseconds) of currently set scheduler and name of currently set governor.
69
+ """
70
+ return client.call('framework_get_scheduler')
71
+
72
+
73
+ def framework_get_governor(client):
74
+ """Query current governor data.
75
+
76
+ Returns:
77
+ Name of currently set governor, available frequencies and currently set frequency of the CPU cores.
78
+ """
79
+ return client.call('framework_get_governor')
80
+
81
+
82
+ def scheduler_set_options(client, scheduling_core=None, isolated_core_mask=None):
83
+ params = {}
84
+ if isolated_core_mask is not None:
85
+ params['isolated_core_mask'] = isolated_core_mask
86
+ if scheduling_core is not None:
87
+ params['scheduling_core'] = scheduling_core
88
+ return client.call('scheduler_set_options', params)
89
+
90
+
91
+ def thread_get_stats(client):
92
+ """Query threads statistics.
93
+
94
+ Returns:
95
+ Current threads statistics.
96
+ """
97
+ return client.call('thread_get_stats')
98
+
99
+
100
+ def thread_set_cpumask(client, id, cpumask):
101
+ """Set the cpumask of the thread whose ID matches to the specified value.
102
+
103
+ Args:
104
+ id: thread ID
105
+ cpumask: cpumask for this thread
106
+
107
+ Returns:
108
+ True or False
109
+ """
110
+ params = {'id': id, 'cpumask': cpumask}
111
+ return client.call('thread_set_cpumask', params)
112
+
113
+
114
+ def log_enable_timestamps(client, enabled):
115
+ """Enable or disable timestamps.
116
+
117
+ Args:
118
+ value: on or off
119
+
120
+ Returns:
121
+ None
122
+ """
123
+ params = {'enabled': enabled}
124
+ return client.call('log_enable_timestamps', params)
125
+
126
+
127
+ def thread_get_pollers(client):
128
+ """Query current pollers.
129
+
130
+ Returns:
131
+ Current pollers.
132
+ """
133
+ return client.call('thread_get_pollers')
134
+
135
+
136
+ def thread_get_io_channels(client):
137
+ """Query current IO channels.
138
+
139
+ Returns:
140
+ Current IO channels.
141
+ """
142
+ return client.call('thread_get_io_channels')