xref: /spdk/python/spdk/rpc/bdev.py (revision cec5ba284b55d19c90359936d77b707e398829f7)
1588dfe31SMichal Berger#  SPDX-License-Identifier: BSD-3-Clause
2588dfe31SMichal Berger#  Copyright (C) 2017 Intel Corporation.
3588dfe31SMichal Berger#  All rights reserved.
42796687dSParameswaran Krishnamurthy#  Copyright (c) 2022 Dell Inc, or its subsidiaries.
50568555aSEvgeniy Kochetov#  Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
6588dfe31SMichal Berger
7555ca7adSMike Gerdts
892595a58SKonrad Sztyberdef bdev_set_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None,
99b21ca0cSKonrad Sztyber                     bdev_auto_examine=None, iobuf_small_cache_size=None,
109b21ca0cSKonrad Sztyber                     iobuf_large_cache_size=None):
117610bc38SKonrad Sztyber    """Set parameters for the bdev subsystem.
127610bc38SKonrad Sztyber    Args:
137610bc38SKonrad Sztyber        bdev_io_pool_size: number of bdev_io structures in shared buffer pool (optional)
147610bc38SKonrad Sztyber        bdev_io_cache_size: maximum number of bdev_io structures cached per thread (optional)
157610bc38SKonrad Sztyber        bdev_auto_examine: if set to false, the bdev layer will not examine every disks automatically (optional)
169b21ca0cSKonrad Sztyber        iobuf_small_cache_size: size of the small iobuf per thread cache
179b21ca0cSKonrad Sztyber        iobuf_large_cache_size: size of the large iobuf per thread cache
187610bc38SKonrad Sztyber    """
198feddadaSEugene Kobyak    params = dict()
208feddadaSEugene Kobyak    if bdev_io_pool_size is not None:
217610bc38SKonrad Sztyber        params['bdev_io_pool_size'] = bdev_io_pool_size
228feddadaSEugene Kobyak    if bdev_io_cache_size is not None:
237610bc38SKonrad Sztyber        params['bdev_io_cache_size'] = bdev_io_cache_size
247610bc38SKonrad Sztyber    if bdev_auto_examine is not None:
258feddadaSEugene Kobyak        params['bdev_auto_examine'] = bdev_auto_examine
269b21ca0cSKonrad Sztyber    if iobuf_small_cache_size is not None:
278feddadaSEugene Kobyak        params['iobuf_small_cache_size'] = iobuf_small_cache_size
289b21ca0cSKonrad Sztyber    if iobuf_large_cache_size is not None:
298feddadaSEugene Kobyak        params['iobuf_large_cache_size'] = iobuf_large_cache_size
307610bc38SKonrad Sztyber    return client.call('bdev_set_options', params)
317610bc38SKonrad Sztyber
327610bc38SKonrad Sztyber
337610bc38SKonrad Sztyberdef bdev_examine(client, name):
347610bc38SKonrad Sztyber    """Examine a bdev manually. If the bdev does not exist yet when this RPC is called,
357610bc38SKonrad Sztyber    it will be examined when it is created
367610bc38SKonrad Sztyber    Args:
377610bc38SKonrad Sztyber        name: name of the bdev
387610bc38SKonrad Sztyber    """
398feddadaSEugene Kobyak    params = dict()
408feddadaSEugene Kobyak    params['name'] = name
417610bc38SKonrad Sztyber    return client.call('bdev_examine', params)
427610bc38SKonrad Sztyber
437610bc38SKonrad Sztyber
447610bc38SKonrad Sztyberdef bdev_wait_for_examine(client):
457610bc38SKonrad Sztyber    """Report when all bdevs have been examined
467610bc38SKonrad Sztyber    """
477610bc38SKonrad Sztyber    return client.call('bdev_wait_for_examine')
487610bc38SKonrad Sztyber
497610bc38SKonrad Sztyber
50ddd4603cSYankun Lidef bdev_compress_create(client, base_bdev_name, pm_path, lb_size=None, comp_algo=None, comp_level=None):
517610bc38SKonrad Sztyber    """Construct a compress virtual block device.
527610bc38SKonrad Sztyber    Args:
537610bc38SKonrad Sztyber        base_bdev_name: name of the underlying base bdev
547610bc38SKonrad Sztyber        pm_path: path to persistent memory
557610bc38SKonrad Sztyber        lb_size: logical block size for the compressed vol in bytes.  Must be 4K or 512.
56ddd4603cSYankun Li        comp_algo: compression algorithm for the compressed vol. Default is deflate.
57ddd4603cSYankun Li        comp_level: compression algorithm level for the compressed vol. Default is 1.
587610bc38SKonrad Sztyber    Returns:
597610bc38SKonrad Sztyber        Name of created virtual block device.
607610bc38SKonrad Sztyber    """
618feddadaSEugene Kobyak    params = dict()
628feddadaSEugene Kobyak    params['base_bdev_name'] = base_bdev_name
638feddadaSEugene Kobyak    params['pm_path'] = pm_path
648feddadaSEugene Kobyak    if lb_size is not None:
65642f8b3dSJaroslaw Chachulski        params['lb_size'] = lb_size
66ddd4603cSYankun Li    if comp_algo is not None:
67ddd4603cSYankun Li        params['comp_algo'] = comp_algo
68ddd4603cSYankun Li    if comp_level is not None:
69ddd4603cSYankun Li        params['comp_level'] = comp_level
707610bc38SKonrad Sztyber    return client.call('bdev_compress_create', params)
717610bc38SKonrad Sztyber
727610bc38SKonrad Sztyber
737610bc38SKonrad Sztyberdef bdev_compress_delete(client, name):
747610bc38SKonrad Sztyber    """Delete compress virtual block device.
757610bc38SKonrad Sztyber    Args:
767610bc38SKonrad Sztyber        name: name of compress vbdev to delete
777610bc38SKonrad Sztyber    """
788feddadaSEugene Kobyak    params = dict()
798feddadaSEugene Kobyak    params['name'] = name
807610bc38SKonrad Sztyber    return client.call('bdev_compress_delete', params)
817610bc38SKonrad Sztyber
827610bc38SKonrad Sztyber
837610bc38SKonrad Sztyberdef bdev_compress_get_orphans(client, name=None):
847610bc38SKonrad Sztyber    """Get a list of comp bdevs that do not have a pmem file (aka orphaned).
857610bc38SKonrad Sztyber    Args:
867610bc38SKonrad Sztyber        name: comp bdev name to query (optional; if omitted, query all comp bdevs)
877610bc38SKonrad Sztyber    Returns:
887610bc38SKonrad Sztyber        List of comp bdev names.
897610bc38SKonrad Sztyber    """
908feddadaSEugene Kobyak    params = dict()
918feddadaSEugene Kobyak    if name is not None:
927610bc38SKonrad Sztyber        params['name'] = name
937610bc38SKonrad Sztyber    return client.call('bdev_compress_get_orphans', params)
947610bc38SKonrad Sztyber
957610bc38SKonrad Sztyber
9613f97e67SAlexey Marchukdef bdev_crypto_create(client, base_bdev_name, name, crypto_pmd=None, key=None, cipher=None, key2=None, key_name=None):
977610bc38SKonrad Sztyber    """Construct a crypto virtual block device.
987610bc38SKonrad Sztyber    Args:
997610bc38SKonrad Sztyber        base_bdev_name: name of the underlying base bdev
1007610bc38SKonrad Sztyber        name: name for the crypto vbdev
10113f97e67SAlexey Marchuk        crypto_pmd: name of the DPDK crypto driver to use
1027610bc38SKonrad Sztyber        key: key
10313f97e67SAlexey Marchuk        cipher: crypto algorithm to use
10413f97e67SAlexey Marchuk        key2: Optional second part of the key
10513f97e67SAlexey Marchuk        key_name: The key name to use in crypto operations
1067610bc38SKonrad Sztyber    Returns:
1077610bc38SKonrad Sztyber        Name of created virtual block device.
1087610bc38SKonrad Sztyber    """
1098feddadaSEugene Kobyak    params = dict()
1108feddadaSEugene Kobyak    params['base_bdev_name'] = base_bdev_name
1118feddadaSEugene Kobyak    params['name'] = name
11213f97e67SAlexey Marchuk    if crypto_pmd is not None:
11313f97e67SAlexey Marchuk        params['crypto_pmd'] = crypto_pmd
11413f97e67SAlexey Marchuk    if key is not None:
11513f97e67SAlexey Marchuk        params['key'] = key
11613f97e67SAlexey Marchuk    if cipher is not None:
11713f97e67SAlexey Marchuk        params['cipher'] = cipher
11860a8d0ceSEugene Kobyak    if key2 is not None:
11960a8d0ceSEugene Kobyak        params['key2'] = key2
12013f97e67SAlexey Marchuk    if key_name is not None:
12113f97e67SAlexey Marchuk        params['key_name'] = key_name
1227610bc38SKonrad Sztyber    return client.call('bdev_crypto_create', params)
1237610bc38SKonrad Sztyber
1247610bc38SKonrad Sztyber
1257610bc38SKonrad Sztyberdef bdev_crypto_delete(client, name):
1267610bc38SKonrad Sztyber    """Delete crypto virtual block device.
1277610bc38SKonrad Sztyber    Args:
1287610bc38SKonrad Sztyber        name: name of crypto vbdev to delete
1297610bc38SKonrad Sztyber    """
1308feddadaSEugene Kobyak    params = dict()
1318feddadaSEugene Kobyak    params['name'] = name
1327610bc38SKonrad Sztyber    return client.call('bdev_crypto_delete', params)
1337610bc38SKonrad Sztyber
1347610bc38SKonrad Sztyber
1357b2e6213SEugene Kobyakdef bdev_ocf_create(client, name, mode, cache_bdev_name, core_bdev_name, cache_line_size=None):
1367610bc38SKonrad Sztyber    """Add an OCF block device
1377610bc38SKonrad Sztyber    Args:
1387610bc38SKonrad Sztyber        name: name of constructed OCF bdev
1397610bc38SKonrad Sztyber        mode: OCF cache mode: {'wb', 'wt', 'pt', 'wa', 'wi', 'wo'}
1407610bc38SKonrad Sztyber        cache_bdev_name: name of underlying cache bdev
1417610bc38SKonrad Sztyber        core_bdev_name: name of underlying core bdev
14260a8d0ceSEugene Kobyak        cache_line_size: OCF cache line size. The unit is KiB: {4, 8, 16, 32, 64}
1437610bc38SKonrad Sztyber    Returns:
1447610bc38SKonrad Sztyber        Name of created block device
1457610bc38SKonrad Sztyber    """
1468feddadaSEugene Kobyak    params = dict()
1478feddadaSEugene Kobyak    params['name'] = name
1488feddadaSEugene Kobyak    params['mode'] = mode
1498feddadaSEugene Kobyak    params['cache_bdev_name'] = cache_bdev_name
1508feddadaSEugene Kobyak    params['core_bdev_name'] = core_bdev_name
1518feddadaSEugene Kobyak    if cache_line_size is not None:
152cd79f1a2SJaroslaw Chachulski        params['cache_line_size'] = cache_line_size
1537610bc38SKonrad Sztyber    return client.call('bdev_ocf_create', params)
1547610bc38SKonrad Sztyber
1557610bc38SKonrad Sztyber
1567610bc38SKonrad Sztyberdef bdev_ocf_delete(client, name):
1577610bc38SKonrad Sztyber    """Delete an OCF device
1587610bc38SKonrad Sztyber    Args:
1597610bc38SKonrad Sztyber        name: name of OCF bdev
1607610bc38SKonrad Sztyber    """
1618feddadaSEugene Kobyak    params = dict()
1628feddadaSEugene Kobyak    params['name'] = name
1637610bc38SKonrad Sztyber    return client.call('bdev_ocf_delete', params)
1647610bc38SKonrad Sztyber
1657610bc38SKonrad Sztyber
1667610bc38SKonrad Sztyberdef bdev_ocf_get_stats(client, name):
1677610bc38SKonrad Sztyber    """Get statistics of chosen OCF block device
1687610bc38SKonrad Sztyber    Args:
1697610bc38SKonrad Sztyber        name: name of OCF bdev
1707610bc38SKonrad Sztyber    Returns:
1717610bc38SKonrad Sztyber        Statistics as json object
1727610bc38SKonrad Sztyber    """
1738feddadaSEugene Kobyak    params = dict()
1748feddadaSEugene Kobyak    params['name'] = name
1757610bc38SKonrad Sztyber    return client.call('bdev_ocf_get_stats', params)
1767610bc38SKonrad Sztyber
1777610bc38SKonrad Sztyber
1786b79f767SAmir Haroushdef bdev_ocf_reset_stats(client, name):
1796b79f767SAmir Haroush    """Reset statistics of chosen OCF block device
1806b79f767SAmir Haroush    Args:
1816b79f767SAmir Haroush        name: name of OCF bdev
1826b79f767SAmir Haroush    Returns:
1836b79f767SAmir Haroush        None
1846b79f767SAmir Haroush    """
1858feddadaSEugene Kobyak    params = dict()
1868feddadaSEugene Kobyak    params['name'] = name
1876b79f767SAmir Haroush    return client.call('bdev_ocf_reset_stats', params)
1886b79f767SAmir Haroush
1896b79f767SAmir Haroush
1907610bc38SKonrad Sztyberdef bdev_ocf_get_bdevs(client, name=None):
1917610bc38SKonrad Sztyber    """Get list of OCF devices including unregistered ones
1927610bc38SKonrad Sztyber    Args:
1937610bc38SKonrad Sztyber        name: name of OCF vbdev or name of cache device or name of core device (optional)
1947610bc38SKonrad Sztyber    Returns:
1957610bc38SKonrad Sztyber        Array of OCF devices with their current status
1967610bc38SKonrad Sztyber    """
1978feddadaSEugene Kobyak    params = dict()
1988feddadaSEugene Kobyak    if name is not None:
1998feddadaSEugene Kobyak        params['name'] = name
2007610bc38SKonrad Sztyber    return client.call('bdev_ocf_get_bdevs', params)
2017610bc38SKonrad Sztyber
2027610bc38SKonrad Sztyber
2037610bc38SKonrad Sztyberdef bdev_ocf_set_cache_mode(client, name, mode):
2047610bc38SKonrad Sztyber    """Set cache mode of OCF block device
2057610bc38SKonrad Sztyber    Args:
2067610bc38SKonrad Sztyber        name: name of OCF bdev
2077610bc38SKonrad Sztyber        mode: OCF cache mode: {'wb', 'wt', 'pt', 'wa', 'wi', 'wo'}
2087610bc38SKonrad Sztyber    Returns:
2097610bc38SKonrad Sztyber        New cache mode name
2107610bc38SKonrad Sztyber    """
2118feddadaSEugene Kobyak    params = dict()
2128feddadaSEugene Kobyak    params['name'] = name
2138feddadaSEugene Kobyak    params['mode'] = mode
2147610bc38SKonrad Sztyber    return client.call('bdev_ocf_set_cache_mode', params)
2157610bc38SKonrad Sztyber
2167610bc38SKonrad Sztyber
2177b2e6213SEugene Kobyakdef bdev_ocf_set_seqcutoff(client, name, policy, threshold=None, promotion_count=None):
2187610bc38SKonrad Sztyber    """Set sequential cutoff parameters on all cores for the given OCF cache device
2197610bc38SKonrad Sztyber    Args:
2207610bc38SKonrad Sztyber        name: Name of OCF cache bdev
2217610bc38SKonrad Sztyber        policy: Sequential cutoff policy
2227610bc38SKonrad Sztyber        threshold: Activation threshold [KiB] (optional)
2237610bc38SKonrad Sztyber        promotion_count: Promotion request count (optional)
2247610bc38SKonrad Sztyber    """
2258feddadaSEugene Kobyak    params = dict()
2268feddadaSEugene Kobyak    params['name'] = name
2278feddadaSEugene Kobyak    params['policy'] = policy
2288feddadaSEugene Kobyak    if threshold is not None:
2297610bc38SKonrad Sztyber        params['threshold'] = threshold
2308feddadaSEugene Kobyak    if promotion_count is not None:
2317610bc38SKonrad Sztyber        params['promotion_count'] = promotion_count
2327610bc38SKonrad Sztyber    return client.call('bdev_ocf_set_seqcutoff', params)
2337610bc38SKonrad Sztyber
2347610bc38SKonrad Sztyber
2358000cedbSRafal Stefanowskidef bdev_ocf_flush_start(client, name):
2368000cedbSRafal Stefanowski    """Start flushing OCF cache device
2378000cedbSRafal Stefanowski    Args:
2388000cedbSRafal Stefanowski        name: name of OCF bdev
2398000cedbSRafal Stefanowski    """
2408feddadaSEugene Kobyak    params = dict()
2418feddadaSEugene Kobyak    params['name'] = name
2428000cedbSRafal Stefanowski    return client.call('bdev_ocf_flush_start', params)
2438000cedbSRafal Stefanowski
2448000cedbSRafal Stefanowski
2458000cedbSRafal Stefanowskidef bdev_ocf_flush_status(client, name):
2468000cedbSRafal Stefanowski    """Get flush status of OCF cache device
2478000cedbSRafal Stefanowski    Args:
2488000cedbSRafal Stefanowski        name: name of OCF bdev
2498000cedbSRafal Stefanowski    Returns:
2508000cedbSRafal Stefanowski        Flush status
2518000cedbSRafal Stefanowski    """
2528feddadaSEugene Kobyak    params = dict()
2538feddadaSEugene Kobyak    params['name'] = name
2548000cedbSRafal Stefanowski    return client.call('bdev_ocf_flush_status', params)
2558000cedbSRafal Stefanowski
2568000cedbSRafal Stefanowski
2571eb06bd6SPanfil, Wojciechdef bdev_malloc_create(client, num_blocks, block_size, physical_block_size=None, name=None, uuid=None, optimal_io_boundary=None,
258c016e6ffSShuhei Matsumoto                       md_size=None, md_interleave=None, dif_type=None, dif_is_head_of_md=None, dif_pi_format=None):
2597610bc38SKonrad Sztyber    """Construct a malloc block device.
2607610bc38SKonrad Sztyber    Args:
2617610bc38SKonrad Sztyber        num_blocks: size of block device in blocks
262aef00d44SShuhei Matsumoto        block_size: Data block size of device; must be a power of 2 and at least 512
2631eb06bd6SPanfil, Wojciech        physical_block_size: Physical block size of device; must be a power of 2 and at least 512 (optional)
2647610bc38SKonrad Sztyber        name: name of block device (optional)
2657610bc38SKonrad Sztyber        uuid: UUID of block device (optional)
2667610bc38SKonrad Sztyber        optimal_io_boundary: Split on optimal IO boundary, in number of blocks, default 0 (disabled, optional)
267aef00d44SShuhei Matsumoto        md_size: metadata size of device (0, 8, 16, 32, 64, or 128), default 0 (optional)
268aef00d44SShuhei Matsumoto        md_interleave: metadata location, interleaved if set, and separated if omitted (optional)
26900bff560SShuhei Matsumoto        dif_type: protection information type (optional)
27000bff560SShuhei Matsumoto        dif_is_head_of_md: protection information is in the first 8 bytes of metadata (optional)
271c016e6ffSShuhei Matsumoto        dif_pi_format: protection information format (optional)
2727610bc38SKonrad Sztyber    Returns:
2737610bc38SKonrad Sztyber        Name of created block device.
2747610bc38SKonrad Sztyber    """
2758feddadaSEugene Kobyak    params = dict()
2768feddadaSEugene Kobyak    params['num_blocks'] = num_blocks
2778feddadaSEugene Kobyak    params['block_size'] = block_size
2788feddadaSEugene Kobyak    if physical_block_size is not None:
2791eb06bd6SPanfil, Wojciech        params['physical_block_size'] = physical_block_size
2808feddadaSEugene Kobyak    if name is not None:
2817610bc38SKonrad Sztyber        params['name'] = name
2828feddadaSEugene Kobyak    if uuid is not None:
2837610bc38SKonrad Sztyber        params['uuid'] = uuid
2848feddadaSEugene Kobyak    if optimal_io_boundary is not None:
2857610bc38SKonrad Sztyber        params['optimal_io_boundary'] = optimal_io_boundary
2868feddadaSEugene Kobyak    if md_size is not None:
287aef00d44SShuhei Matsumoto        params['md_size'] = md_size
2888feddadaSEugene Kobyak    if md_interleave is not None:
289aef00d44SShuhei Matsumoto        params['md_interleave'] = md_interleave
2908feddadaSEugene Kobyak    if dif_type is not None:
29100bff560SShuhei Matsumoto        params['dif_type'] = dif_type
2928feddadaSEugene Kobyak    if dif_is_head_of_md is not None:
29300bff560SShuhei Matsumoto        params['dif_is_head_of_md'] = dif_is_head_of_md
294c016e6ffSShuhei Matsumoto    if dif_pi_format is not None:
295c016e6ffSShuhei Matsumoto        params['dif_pi_format'] = dif_pi_format
2967610bc38SKonrad Sztyber    return client.call('bdev_malloc_create', params)
2977610bc38SKonrad Sztyber
2987610bc38SKonrad Sztyber
2997610bc38SKonrad Sztyberdef bdev_malloc_delete(client, name):
3007610bc38SKonrad Sztyber    """Delete malloc block device.
3017610bc38SKonrad Sztyber    Args:
3027610bc38SKonrad Sztyber        bdev_name: name of malloc bdev to delete
3037610bc38SKonrad Sztyber    """
3048feddadaSEugene Kobyak    params = dict()
3058feddadaSEugene Kobyak    params['name'] = name
3067610bc38SKonrad Sztyber    return client.call('bdev_malloc_delete', params)
3077610bc38SKonrad Sztyber
3087610bc38SKonrad Sztyber
3097f50da15SPanfil, Wojciechdef bdev_null_create(client, num_blocks, block_size, name, physical_block_size=None, uuid=None, md_size=None,
3101521bf3bSShuhei Matsumoto                     dif_type=None, dif_is_head_of_md=None, dif_pi_format=None):
3117610bc38SKonrad Sztyber    """Construct a null block device.
3127610bc38SKonrad Sztyber    Args:
3137610bc38SKonrad Sztyber        num_blocks: size of block device in blocks
3147610bc38SKonrad Sztyber        block_size: block size of device; data part size must be a power of 2 and at least 512
3157610bc38SKonrad Sztyber        name: name of block device
3167f50da15SPanfil, Wojciech        physical_block_size: physical block size of the device; data part size must be a power of 2 and at least 512 (optional)
3177610bc38SKonrad Sztyber        uuid: UUID of block device (optional)
3187610bc38SKonrad Sztyber        md_size: metadata size of device (optional)
3197610bc38SKonrad Sztyber        dif_type: protection information type (optional)
3207610bc38SKonrad Sztyber        dif_is_head_of_md: protection information is in the first 8 bytes of metadata (optional)
3211521bf3bSShuhei Matsumoto        dif_pi_format: protection information format (optional)
3227610bc38SKonrad Sztyber    Returns:
3237610bc38SKonrad Sztyber        Name of created block device.
3247610bc38SKonrad Sztyber    """
3258feddadaSEugene Kobyak    params = dict()
3268feddadaSEugene Kobyak    params['num_blocks'] = num_blocks
3278feddadaSEugene Kobyak    params['block_size'] = block_size
32860a8d0ceSEugene Kobyak    params['name'] = name
3298feddadaSEugene Kobyak    if physical_block_size is not None:
3307f50da15SPanfil, Wojciech        params['physical_block_size'] = physical_block_size
3318feddadaSEugene Kobyak    if uuid is not None:
3327610bc38SKonrad Sztyber        params['uuid'] = uuid
3338feddadaSEugene Kobyak    if md_size is not None:
3347610bc38SKonrad Sztyber        params['md_size'] = md_size
3358feddadaSEugene Kobyak    if dif_type is not None:
3367610bc38SKonrad Sztyber        params['dif_type'] = dif_type
3378feddadaSEugene Kobyak    if dif_is_head_of_md is not None:
3387610bc38SKonrad Sztyber        params['dif_is_head_of_md'] = dif_is_head_of_md
3391521bf3bSShuhei Matsumoto    if dif_pi_format is not None:
3401521bf3bSShuhei Matsumoto        params['dif_pi_format'] = dif_pi_format
3417610bc38SKonrad Sztyber    return client.call('bdev_null_create', params)
3427610bc38SKonrad Sztyber
3437610bc38SKonrad Sztyber
3447610bc38SKonrad Sztyberdef bdev_null_delete(client, name):
3457610bc38SKonrad Sztyber    """Remove null bdev from the system.
3467610bc38SKonrad Sztyber    Args:
3477610bc38SKonrad Sztyber        name: name of null bdev to delete
3487610bc38SKonrad Sztyber    """
3498feddadaSEugene Kobyak    params = dict()
3508feddadaSEugene Kobyak    params['name'] = name
3517610bc38SKonrad Sztyber    return client.call('bdev_null_delete', params)
3527610bc38SKonrad Sztyber
3537610bc38SKonrad Sztyber
3547610bc38SKonrad Sztyberdef bdev_null_resize(client, name, new_size):
3557610bc38SKonrad Sztyber    """Resize null bdev in the system.
3567610bc38SKonrad Sztyber    Args:
3577610bc38SKonrad Sztyber        name: name of null bdev to resize
3587610bc38SKonrad Sztyber        new_size: new bdev size of resize operation. The unit is MiB
3597610bc38SKonrad Sztyber    """
3608feddadaSEugene Kobyak    params = dict()
3618feddadaSEugene Kobyak    params['name'] = name
3628feddadaSEugene Kobyak    params['new_size'] = new_size
3637610bc38SKonrad Sztyber    return client.call('bdev_null_resize', params)
3647610bc38SKonrad Sztyber
3657610bc38SKonrad Sztyber
36689fd1730Sxupeng9def bdev_raid_set_options(client, process_window_size_kb=None, process_max_bandwidth_mb_sec=None):
367f39350beSArtur Paszkiewicz    """Set options for bdev raid.
368f39350beSArtur Paszkiewicz    Args:
369f39350beSArtur Paszkiewicz        process_window_size_kb: Background process (e.g. rebuild) window size in KiB
37089fd1730Sxupeng9        process_max_bandwidth_mb_sec: Background process (e.g. rebuild) maximum bandwidth in MiB/Sec
371f39350beSArtur Paszkiewicz    """
3728feddadaSEugene Kobyak    params = dict()
373f39350beSArtur Paszkiewicz    if process_window_size_kb is not None:
374f39350beSArtur Paszkiewicz        params['process_window_size_kb'] = process_window_size_kb
37589fd1730Sxupeng9
37689fd1730Sxupeng9    if process_max_bandwidth_mb_sec is not None:
37789fd1730Sxupeng9        params['process_max_bandwidth_mb_sec'] = process_max_bandwidth_mb_sec
37889fd1730Sxupeng9
379f39350beSArtur Paszkiewicz    return client.call('bdev_raid_set_options', params)
380f39350beSArtur Paszkiewicz
381f39350beSArtur Paszkiewicz
3827610bc38SKonrad Sztyberdef bdev_raid_get_bdevs(client, category):
3837610bc38SKonrad Sztyber    """Get list of raid bdevs based on category
3847610bc38SKonrad Sztyber    Args:
3857610bc38SKonrad Sztyber        category: any one of all or online or configuring or offline
3867610bc38SKonrad Sztyber    Returns:
387ec6d94b6SArtur Paszkiewicz        List of raid bdev details
3887610bc38SKonrad Sztyber    """
3898feddadaSEugene Kobyak    params = dict()
3908feddadaSEugene Kobyak    params['category'] = category
3917610bc38SKonrad Sztyber    return client.call('bdev_raid_get_bdevs', params)
3927610bc38SKonrad Sztyber
3937610bc38SKonrad Sztyber
3948feddadaSEugene Kobyakdef bdev_raid_create(client, name, raid_level, base_bdevs, strip_size_kb=None, uuid=None, superblock=None):
3957610bc38SKonrad Sztyber    """Create raid bdev. Either strip size arg will work but one is required.
3967610bc38SKonrad Sztyber    Args:
3977610bc38SKonrad Sztyber        name: user defined raid bdev name
3987610bc38SKonrad Sztyber        raid_level: raid level of raid bdev, supported values 0
3997610bc38SKonrad Sztyber        base_bdevs: Space separated names of Nvme bdevs in double quotes, like "Nvme0n1 Nvme1n1 Nvme2n1"
40060a8d0ceSEugene Kobyak        strip_size_kb: strip size of raid bdev in KB, supported values like 8, 16, 32, 64, 128, 256, etc
4011db41324SKrzysztof Karas        uuid: UUID for this raid bdev (optional)
402e39760fdSKrzysztof Smolinski        superblock: information about raid bdev will be stored in superblock on each base bdev,
403e39760fdSKrzysztof Smolinski                    disabled by default due to backward compatibility
4047610bc38SKonrad Sztyber    Returns:
4057610bc38SKonrad Sztyber        None
4067610bc38SKonrad Sztyber    """
4078feddadaSEugene Kobyak    params = dict()
4088feddadaSEugene Kobyak    params['name'] = name
4098feddadaSEugene Kobyak    params['raid_level'] = raid_level
4108feddadaSEugene Kobyak    params['base_bdevs'] = base_bdevs
4118feddadaSEugene Kobyak    if strip_size_kb is not None:
4127610bc38SKonrad Sztyber        params['strip_size_kb'] = strip_size_kb
4138feddadaSEugene Kobyak    if uuid is not None:
4141db41324SKrzysztof Karas        params['uuid'] = uuid
4158feddadaSEugene Kobyak    if superblock is not None:
4168feddadaSEugene Kobyak        params['superblock'] = superblock
4177610bc38SKonrad Sztyber    return client.call('bdev_raid_create', params)
4187610bc38SKonrad Sztyber
4197610bc38SKonrad Sztyber
4207610bc38SKonrad Sztyberdef bdev_raid_delete(client, name):
4217610bc38SKonrad Sztyber    """Delete raid bdev
4227610bc38SKonrad Sztyber    Args:
4237610bc38SKonrad Sztyber        name: raid bdev name
4247610bc38SKonrad Sztyber    Returns:
4257610bc38SKonrad Sztyber        None
4267610bc38SKonrad Sztyber    """
4278feddadaSEugene Kobyak    params = dict()
4288feddadaSEugene Kobyak    params['name'] = name
4297610bc38SKonrad Sztyber    return client.call('bdev_raid_delete', params)
4307610bc38SKonrad Sztyber
4317610bc38SKonrad Sztyber
432524129a9SKrzysztof Smolinskidef bdev_raid_add_base_bdev(client, base_bdev, raid_bdev):
433524129a9SKrzysztof Smolinski    """Add base bdev to existing raid bdev
434524129a9SKrzysztof Smolinski    Args:
435524129a9SKrzysztof Smolinski        base_bdev: base bdev name
43660a8d0ceSEugene Kobyak        raid_bdev: raid bdev name
437524129a9SKrzysztof Smolinski    Returns:
438524129a9SKrzysztof Smolinski        None
439524129a9SKrzysztof Smolinski    """
4408feddadaSEugene Kobyak    params = dict()
4418feddadaSEugene Kobyak    params['base_bdev'] = base_bdev
4428feddadaSEugene Kobyak    params['raid_bdev'] = raid_bdev
443524129a9SKrzysztof Smolinski    return client.call('bdev_raid_add_base_bdev', params)
444524129a9SKrzysztof Smolinski
445524129a9SKrzysztof Smolinski
44623850b03SKrzysztof Smolinskidef bdev_raid_remove_base_bdev(client, name):
44723850b03SKrzysztof Smolinski    """Remove base bdev from existing raid bdev
44823850b03SKrzysztof Smolinski    Args:
44923850b03SKrzysztof Smolinski        name: base bdev name
45023850b03SKrzysztof Smolinski    Returns:
45123850b03SKrzysztof Smolinski        None
45223850b03SKrzysztof Smolinski    """
4538feddadaSEugene Kobyak    params = dict()
4548feddadaSEugene Kobyak    params['name'] = name
45523850b03SKrzysztof Smolinski    return client.call('bdev_raid_remove_base_bdev', params)
45623850b03SKrzysztof Smolinski
45723850b03SKrzysztof Smolinski
458e5693d68SMateusz Kozlowskidef bdev_aio_create(client, filename, name, block_size=None, readonly=None, fallocate=None, uuid=None):
4597610bc38SKonrad Sztyber    """Construct a Linux AIO block device.
4607610bc38SKonrad Sztyber    Args:
4617610bc38SKonrad Sztyber        filename: path to device or file (ex: /dev/sda)
4627610bc38SKonrad Sztyber        name: name of block device
4637610bc38SKonrad Sztyber        block_size: block size of device (optional; autodetected if omitted)
4644c6a2e3dSYuhua        readonly: set aio bdev as read-only
46571eba7ffSzhenwei pi        fallocate: enable fallocate for UNMAP/WRITEZEROS support (note that fallocate syscall would block reactor)
466e5693d68SMateusz Kozlowski        uuid: UUID of the bdev (optional)
4677610bc38SKonrad Sztyber    Returns:
4687610bc38SKonrad Sztyber        Name of created block device.
4697610bc38SKonrad Sztyber    """
4708feddadaSEugene Kobyak    params = dict()
4718feddadaSEugene Kobyak    params['filename'] = filename
47260a8d0ceSEugene Kobyak    params['name'] = name
4738feddadaSEugene Kobyak    if block_size is not None:
4747610bc38SKonrad Sztyber        params['block_size'] = block_size
4758feddadaSEugene Kobyak    if readonly is not None:
4764c6a2e3dSYuhua        params['readonly'] = readonly
4778feddadaSEugene Kobyak    if fallocate is not None:
478648a5414Szhenwei pi        params['fallocate'] = fallocate
479e5693d68SMateusz Kozlowski    if uuid is not None:
480e5693d68SMateusz Kozlowski        params['uuid'] = uuid
4817610bc38SKonrad Sztyber    return client.call('bdev_aio_create', params)
4827610bc38SKonrad Sztyber
4837610bc38SKonrad Sztyber
4847610bc38SKonrad Sztyberdef bdev_aio_rescan(client, name):
4857610bc38SKonrad Sztyber    """Rescan a Linux AIO block device.
4867610bc38SKonrad Sztyber    Args:
487d62e9b74Sliucheng        name: name of aio bdev to rescan
4887610bc38SKonrad Sztyber    """
4898feddadaSEugene Kobyak    params = dict()
4908feddadaSEugene Kobyak    params['name'] = name
4917610bc38SKonrad Sztyber    return client.call('bdev_aio_rescan', params)
4927610bc38SKonrad Sztyber
4937610bc38SKonrad Sztyber
4947610bc38SKonrad Sztyberdef bdev_aio_delete(client, name):
4957610bc38SKonrad Sztyber    """Remove aio bdev from the system.
4967610bc38SKonrad Sztyber    Args:
497d62e9b74Sliucheng        name: name of aio bdev to delete
4987610bc38SKonrad Sztyber    """
4998feddadaSEugene Kobyak    params = dict()
5008feddadaSEugene Kobyak    params['name'] = name
5017610bc38SKonrad Sztyber    return client.call('bdev_aio_delete', params)
5027610bc38SKonrad Sztyber
5037610bc38SKonrad Sztyber
504a420536aSYoav Cohendef bdev_uring_create(client, filename, name, block_size=None, uuid=None):
5057610bc38SKonrad Sztyber    """Create a bdev with Linux io_uring backend.
5067610bc38SKonrad Sztyber    Args:
5077610bc38SKonrad Sztyber        filename: path to device or file (ex: /dev/nvme0n1)
5087610bc38SKonrad Sztyber        name: name of bdev
5097610bc38SKonrad Sztyber        block_size: block size of device (optional; autodetected if omitted)
510a420536aSYoav Cohen        uuid: UUID of block device (optional)
5117610bc38SKonrad Sztyber    Returns:
5127610bc38SKonrad Sztyber        Name of created bdev.
5137610bc38SKonrad Sztyber    """
5148feddadaSEugene Kobyak    params = dict()
5158feddadaSEugene Kobyak    params['filename'] = filename
51660a8d0ceSEugene Kobyak    params['name'] = name
5178feddadaSEugene Kobyak    if block_size is not None:
5187610bc38SKonrad Sztyber        params['block_size'] = block_size
5198feddadaSEugene Kobyak    if uuid is not None:
520a420536aSYoav Cohen        params['uuid'] = uuid
5217610bc38SKonrad Sztyber    return client.call('bdev_uring_create', params)
5227610bc38SKonrad Sztyber
5237610bc38SKonrad Sztyber
524d62e9b74Sliuchengdef bdev_uring_rescan(client, name):
525d62e9b74Sliucheng    """Rescan a Linux URING block device.
526d62e9b74Sliucheng    Args:
527d62e9b74Sliucheng        name: name of uring bdev to rescan
528d62e9b74Sliucheng    """
5298feddadaSEugene Kobyak    params = dict()
5308feddadaSEugene Kobyak    params['name'] = name
531d62e9b74Sliucheng    return client.call('bdev_uring_rescan', params)
532d62e9b74Sliucheng
533d62e9b74Sliucheng
5347610bc38SKonrad Sztyberdef bdev_uring_delete(client, name):
5357610bc38SKonrad Sztyber    """Delete a uring bdev.
5367610bc38SKonrad Sztyber    Args:
5377610bc38SKonrad Sztyber        name: name of uring bdev to delete
5387610bc38SKonrad Sztyber    """
5398feddadaSEugene Kobyak    params = dict()
5408feddadaSEugene Kobyak    params['name'] = name
5417610bc38SKonrad Sztyber    return client.call('bdev_uring_delete', params)
5427610bc38SKonrad Sztyber
5437610bc38SKonrad Sztyber
544637d0d0bSMichal Bergerdef bdev_xnvme_create(client, filename, name, io_mechanism, conserve_cpu):
5456f338d4bSKrishna Kanth Reddy    """Create a bdev with xNVMe backend.
5466f338d4bSKrishna Kanth Reddy    Args:
5476f338d4bSKrishna Kanth Reddy        filename: path to device or file (ex: /dev/nvme0n1)
5486f338d4bSKrishna Kanth Reddy        name: name of xNVMe bdev to create
5496f338d4bSKrishna Kanth Reddy        io_mechanism: I/O mechanism to use (ex: io_uring, io_uring_cmd, etc.)
550b99b00e5SSimon A. F. Lund        conserve_cpu: Whether or not to conserve CPU when polling (default: False)
5516f338d4bSKrishna Kanth Reddy    Returns:
5526f338d4bSKrishna Kanth Reddy        Name of created bdev.
5536f338d4bSKrishna Kanth Reddy    """
5548feddadaSEugene Kobyak    params = dict()
5558feddadaSEugene Kobyak    params['filename'] = filename
55660a8d0ceSEugene Kobyak    params['name'] = name
5578feddadaSEugene Kobyak    params['io_mechanism'] = io_mechanism
558b99b00e5SSimon A. F. Lund    params['conserve_cpu'] = conserve_cpu
5596f338d4bSKrishna Kanth Reddy    return client.call('bdev_xnvme_create', params)
5606f338d4bSKrishna Kanth Reddy
5616f338d4bSKrishna Kanth Reddy
5626f338d4bSKrishna Kanth Reddydef bdev_xnvme_delete(client, name):
5636f338d4bSKrishna Kanth Reddy    """Delete a xNVMe bdev.
5646f338d4bSKrishna Kanth Reddy    Args:
5656f338d4bSKrishna Kanth Reddy        name: name of xNVMe bdev to delete
5666f338d4bSKrishna Kanth Reddy    """
5678feddadaSEugene Kobyak    params = dict()
5688feddadaSEugene Kobyak    params['name'] = name
5696f338d4bSKrishna Kanth Reddy    return client.call('bdev_xnvme_delete', params)
5706f338d4bSKrishna Kanth Reddy
5716f338d4bSKrishna Kanth Reddy
5727610bc38SKonrad Sztyberdef bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, timeout_admin_us=None,
573f9eb3739SEugene Kobyak                          keep_alive_timeout_ms=None, arbitration_burst=None,
5747610bc38SKonrad Sztyber                          low_priority_weight=None, medium_priority_weight=None, high_priority_weight=None,
5757610bc38SKonrad Sztyber                          nvme_adminq_poll_period_us=None, nvme_ioq_poll_period_us=None, io_queue_requests=None,
5767610bc38SKonrad Sztyber                          delay_cmd_submit=None, transport_retry_count=None, bdev_retry_count=None,
5777610bc38SKonrad Sztyber                          transport_ack_timeout=None, ctrlr_loss_timeout_sec=None, reconnect_delay_sec=None,
578990cd38aSMichael Haeuptle                          fast_io_fail_timeout_sec=None, disable_auto_failback=None, generate_uuids=None,
5796ecf0442SKonrad Sztyber                          transport_tos=None, nvme_error_stat=None, rdma_srq_size=None, io_path_stat=None,
58075883719SKonrad Sztyber                          allow_accel_sequence=None, rdma_max_cq_size=None, rdma_cm_event_timeout_ms=None,
581*cec5ba28SAlexey Marchuk                          dhchap_digests=None, dhchap_dhgroups=None, rdma_umr_per_io=None):
5827610bc38SKonrad Sztyber    """Set options for the bdev nvme. This is startup command.
5837610bc38SKonrad Sztyber    Args:
5847610bc38SKonrad Sztyber        action_on_timeout:  action to take on command time out. Valid values are: none, reset, abort (optional)
5857610bc38SKonrad Sztyber        timeout_us: Timeout for each command, in microseconds. If 0, don't track timeouts (optional)
5867610bc38SKonrad Sztyber        timeout_admin_us: Timeout for each admin command, in microseconds. If 0, treat same as io timeouts (optional)
5877610bc38SKonrad Sztyber        keep_alive_timeout_ms: Keep alive timeout period in millisecond, default is 10s (optional)
5887610bc38SKonrad Sztyber        arbitration_burst: The value is expressed as a power of two (optional)
5897610bc38SKonrad Sztyber        low_priority_weight: The number of commands that may be executed from the low priority queue at one time (optional)
5907610bc38SKonrad Sztyber        medium_priority_weight: The number of commands that may be executed from the medium priority queue at one time (optional)
5917610bc38SKonrad Sztyber        high_priority_weight: The number of commands that may be executed from the high priority queue at one time (optional)
5927610bc38SKonrad Sztyber        nvme_adminq_poll_period_us: How often the admin queue is polled for asynchronous events in microseconds (optional)
5937610bc38SKonrad Sztyber        nvme_ioq_poll_period_us: How often to poll I/O queues for completions in microseconds (optional)
5947610bc38SKonrad Sztyber        io_queue_requests: The number of requests allocated for each NVMe I/O queue. Default: 512 (optional)
5957610bc38SKonrad Sztyber        delay_cmd_submit: Enable delayed NVMe command submission to allow batching of multiple commands (optional)
5967610bc38SKonrad Sztyber        transport_retry_count: The number of attempts per I/O in the transport layer when an I/O fails (optional)
5977610bc38SKonrad Sztyber        bdev_retry_count: The number of attempts per I/O in the bdev layer when an I/O fails. -1 means infinite retries. (optional)
59831db7b13Szhangduan        transport_ack_timeout: Time to wait ack until packet retransmission for RDMA or until closes connection for TCP.
5997610bc38SKonrad Sztyber        Range 0-31 where 0 is driver-specific default value (optional)
6007610bc38SKonrad Sztyber        ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr.
6017610bc38SKonrad Sztyber        -1 means infinite reconnect retries. 0 means no reconnect retry.
6027610bc38SKonrad Sztyber        If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero.
6037610bc38SKonrad Sztyber        If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec.
6047610bc38SKonrad Sztyber        This can be overridden by bdev_nvme_attach_controller. (optional)
6057610bc38SKonrad Sztyber        reconnect_delay_sec: Time to delay a reconnect retry.
6067610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero.
6077610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero.
6087610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec.
6097610bc38SKonrad Sztyber        This can be overridden by bdev_nvme_attach_controller. (optional)
61060a8d0ceSEugene Kobyak        fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr.
6117610bc38SKonrad Sztyber        0 means no such timeout.
6127610bc38SKonrad Sztyber        If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than
6137610bc38SKonrad Sztyber        ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1.
6147610bc38SKonrad Sztyber        This can be overridden by bdev_nvme_attach_controller. (optional)
61500d46b80SShuhei Matsumoto        disable_auto_failback: Disable automatic failback. bdev_nvme_set_preferred_path can be used to do manual failback.
61600d46b80SShuhei Matsumoto        By default, immediately failback to the preferred I/O path if it is restored. (optional)
617b5bdbbb9SKrzysztof Karas        generate_uuids: Enable generation of unique identifiers for NVMe bdevs only if they do not provide UUID themselves.
618b5bdbbb9SKrzysztof Karas        These strings are based on device serial number and namespace ID and will always be the same for that device.
619990cd38aSMichael Haeuptle        transport_tos: IPv4 Type of Service value. Only applicable for RDMA transports.
620990cd38aSMichael Haeuptle        The default is 0 which means no TOS is applied. (optional)
621e33ae4a6SShuhei Matsumoto        nvme_error_stat: Enable collecting NVMe error counts. (optional)
622a3ae6eaaSShuhei Matsumoto        rdma_srq_size: Set the size of a shared rdma receive queue. Default: 0 (disabled) (optional)
623f61b0041SRichael Zhuang        io_path_stat: Enable collection I/O path stat of each io path. (optional)
6246ecf0442SKonrad Sztyber        allow_accel_sequence: Allow NVMe bdevs to advertise support for accel sequences if the
6256ecf0442SKonrad Sztyber        controller also supports them. (optional)
6264790c4efSShuhei Matsumoto        rdma_max_cq_size: The maximum size of a rdma completion queue. Default: 0 (unlimited) (optional)
6270568555aSEvgeniy Kochetov        rdma_cm_event_timeout_ms: Time to wait for RDMA CM event. Only applicable for RDMA transports.
62875883719SKonrad Sztyber        dhchap_digests: List of allowed DH-HMAC-CHAP digests. (optional)
62975883719SKonrad Sztyber        dhchap_dhgroups: List of allowed DH-HMAC-CHAP DH groups. (optional)
630*cec5ba28SAlexey Marchuk        rdma_umr_per_io: Enable/disable scatter-gather UMR per IO in RDMA transport if supported by system (optional).
6317610bc38SKonrad Sztyber    """
6328feddadaSEugene Kobyak    params = dict()
6338feddadaSEugene Kobyak    if action_on_timeout is not None:
6347610bc38SKonrad Sztyber        params['action_on_timeout'] = action_on_timeout
6357610bc38SKonrad Sztyber    if timeout_us is not None:
6367610bc38SKonrad Sztyber        params['timeout_us'] = timeout_us
6377610bc38SKonrad Sztyber    if timeout_admin_us is not None:
6387610bc38SKonrad Sztyber        params['timeout_admin_us'] = timeout_admin_us
6397610bc38SKonrad Sztyber    if keep_alive_timeout_ms is not None:
6407610bc38SKonrad Sztyber        params['keep_alive_timeout_ms'] = keep_alive_timeout_ms
6417610bc38SKonrad Sztyber    if arbitration_burst is not None:
6427610bc38SKonrad Sztyber        params['arbitration_burst'] = arbitration_burst
6437610bc38SKonrad Sztyber    if low_priority_weight is not None:
6447610bc38SKonrad Sztyber        params['low_priority_weight'] = low_priority_weight
6457610bc38SKonrad Sztyber    if medium_priority_weight is not None:
6467610bc38SKonrad Sztyber        params['medium_priority_weight'] = medium_priority_weight
6477610bc38SKonrad Sztyber    if high_priority_weight is not None:
6487610bc38SKonrad Sztyber        params['high_priority_weight'] = high_priority_weight
6498feddadaSEugene Kobyak    if nvme_adminq_poll_period_us is not None:
6507610bc38SKonrad Sztyber        params['nvme_adminq_poll_period_us'] = nvme_adminq_poll_period_us
6517610bc38SKonrad Sztyber    if nvme_ioq_poll_period_us is not None:
6527610bc38SKonrad Sztyber        params['nvme_ioq_poll_period_us'] = nvme_ioq_poll_period_us
6537610bc38SKonrad Sztyber    if io_queue_requests is not None:
6547610bc38SKonrad Sztyber        params['io_queue_requests'] = io_queue_requests
6557610bc38SKonrad Sztyber    if delay_cmd_submit is not None:
6567610bc38SKonrad Sztyber        params['delay_cmd_submit'] = delay_cmd_submit
6577610bc38SKonrad Sztyber    if transport_retry_count is not None:
6587610bc38SKonrad Sztyber        params['transport_retry_count'] = transport_retry_count
6597610bc38SKonrad Sztyber    if bdev_retry_count is not None:
6607610bc38SKonrad Sztyber        params['bdev_retry_count'] = bdev_retry_count
6617610bc38SKonrad Sztyber    if transport_ack_timeout is not None:
6627610bc38SKonrad Sztyber        params['transport_ack_timeout'] = transport_ack_timeout
6637610bc38SKonrad Sztyber    if ctrlr_loss_timeout_sec is not None:
6647610bc38SKonrad Sztyber        params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec
6657610bc38SKonrad Sztyber    if reconnect_delay_sec is not None:
6667610bc38SKonrad Sztyber        params['reconnect_delay_sec'] = reconnect_delay_sec
6677610bc38SKonrad Sztyber    if fast_io_fail_timeout_sec is not None:
6687610bc38SKonrad Sztyber        params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec
66900d46b80SShuhei Matsumoto    if disable_auto_failback is not None:
67000d46b80SShuhei Matsumoto        params['disable_auto_failback'] = disable_auto_failback
671b5bdbbb9SKrzysztof Karas    if generate_uuids is not None:
672b5bdbbb9SKrzysztof Karas        params['generate_uuids'] = generate_uuids
673990cd38aSMichael Haeuptle    if transport_tos is not None:
674990cd38aSMichael Haeuptle        params['transport_tos'] = transport_tos
675e33ae4a6SShuhei Matsumoto    if nvme_error_stat is not None:
676e33ae4a6SShuhei Matsumoto        params['nvme_error_stat'] = nvme_error_stat
677a3ae6eaaSShuhei Matsumoto    if rdma_srq_size is not None:
678a3ae6eaaSShuhei Matsumoto        params['rdma_srq_size'] = rdma_srq_size
679f61b0041SRichael Zhuang    if io_path_stat is not None:
680f61b0041SRichael Zhuang        params['io_path_stat'] = io_path_stat
6816ecf0442SKonrad Sztyber    if allow_accel_sequence is not None:
6826ecf0442SKonrad Sztyber        params['allow_accel_sequence'] = allow_accel_sequence
6834790c4efSShuhei Matsumoto    if rdma_max_cq_size is not None:
6844790c4efSShuhei Matsumoto        params['rdma_max_cq_size'] = rdma_max_cq_size
6850568555aSEvgeniy Kochetov    if rdma_cm_event_timeout_ms is not None:
6860568555aSEvgeniy Kochetov        params['rdma_cm_event_timeout_ms'] = rdma_cm_event_timeout_ms
68775883719SKonrad Sztyber    if dhchap_digests is not None:
68875883719SKonrad Sztyber        params['dhchap_digests'] = dhchap_digests
68975883719SKonrad Sztyber    if dhchap_dhgroups is not None:
69075883719SKonrad Sztyber        params['dhchap_dhgroups'] = dhchap_dhgroups
691*cec5ba28SAlexey Marchuk    if rdma_umr_per_io is not None:
692*cec5ba28SAlexey Marchuk        params['rdma_umr_per_io'] = rdma_umr_per_io
6937610bc38SKonrad Sztyber    return client.call('bdev_nvme_set_options', params)
6947610bc38SKonrad Sztyber
6957610bc38SKonrad Sztyber
6967610bc38SKonrad Sztyberdef bdev_nvme_set_hotplug(client, enable, period_us=None):
6977610bc38SKonrad Sztyber    """Set options for the bdev nvme. This is startup command.
6987610bc38SKonrad Sztyber    Args:
6997610bc38SKonrad Sztyber       enable: True to enable hotplug, False to disable.
7007610bc38SKonrad Sztyber       period_us: how often the hotplug is processed for insert and remove events. Set 0 to reset to default. (optional)
7017610bc38SKonrad Sztyber    """
7028feddadaSEugene Kobyak    params = dict()
7038feddadaSEugene Kobyak    params['enable'] = enable
7048feddadaSEugene Kobyak    if period_us is not None:
7057610bc38SKonrad Sztyber        params['period_us'] = period_us
7067610bc38SKonrad Sztyber    return client.call('bdev_nvme_set_hotplug', params)
7077610bc38SKonrad Sztyber
7087610bc38SKonrad Sztyber
7097610bc38SKonrad Sztyberdef bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvcid=None,
7107610bc38SKonrad Sztyber                                priority=None, subnqn=None, hostnqn=None, hostaddr=None,
7117610bc38SKonrad Sztyber                                hostsvcid=None, prchk_reftag=None, prchk_guard=None,
712ecb6d9ffSEugene Kobyak                                hdgst=None, ddgst=None, fabrics_connect_timeout_us=None,
713ecb6d9ffSEugene Kobyak                                multipath=None, num_io_queues=None, ctrlr_loss_timeout_sec=None,
714ecb6d9ffSEugene Kobyak                                reconnect_delay_sec=None, fast_io_fail_timeout_sec=None,
71578467a35SKarl Bonde Torp                                psk=None, max_bdevs=None, dhchap_key=None, dhchap_ctrlr_key=None,
71678467a35SKarl Bonde Torp                                allow_unrecognized_csi=None):
7177610bc38SKonrad Sztyber    """Construct block device for each NVMe namespace in the attached controller.
7187610bc38SKonrad Sztyber    Args:
7197610bc38SKonrad Sztyber        name: bdev name prefix; "n" + namespace ID will be appended to create unique names
7207610bc38SKonrad Sztyber        trtype: transport type ("PCIe", "RDMA", "FC", "TCP")
7217610bc38SKonrad Sztyber        traddr: transport address (PCI BDF or IP address)
7227610bc38SKonrad Sztyber        adrfam: address family ("IPv4", "IPv6", "IB", or "FC")
7237610bc38SKonrad Sztyber        trsvcid: transport service ID (port number for IP-based addresses)
7247610bc38SKonrad Sztyber        priority: transport connection priority (Sock priority for TCP-based transports; optional)
7257610bc38SKonrad Sztyber        subnqn: subsystem NQN to connect to (optional)
7267610bc38SKonrad Sztyber        hostnqn: NQN to connect from (optional)
7277610bc38SKonrad Sztyber        hostaddr: host transport address (IP address for IP-based transports, NULL for PCIe or FC; optional)
7287610bc38SKonrad Sztyber        hostsvcid: host transport service ID (port number for IP-based transports, NULL for PCIe or FC; optional)
7297610bc38SKonrad Sztyber        prchk_reftag: Enable checking of PI reference tag for I/O processing (optional)
7307610bc38SKonrad Sztyber        prchk_guard: Enable checking of PI guard for I/O processing (optional)
7317610bc38SKonrad Sztyber        hdgst: Enable TCP header digest (optional)
7327610bc38SKonrad Sztyber        ddgst: Enable TCP data digest (optional)
733ecb6d9ffSEugene Kobyak        fabrics_connect_timeout_us: Fabrics connect timeout in us (optional)
7347610bc38SKonrad Sztyber        multipath: The behavior when multiple paths are created ("disable", "failover", or "multipath"; failover if not specified)
7357610bc38SKonrad Sztyber        num_io_queues: The number of IO queues to request during initialization. (optional)
7367610bc38SKonrad Sztyber        ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr.
7377610bc38SKonrad Sztyber        -1 means infinite reconnect retries. 0 means no reconnect retry.
7387610bc38SKonrad Sztyber        If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero.
7397610bc38SKonrad Sztyber        If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec.
7407610bc38SKonrad Sztyber        (optional)
7417610bc38SKonrad Sztyber        reconnect_delay_sec: Time to delay a reconnect retry.
7427610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero.
7437610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero.
7447610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec.
7457610bc38SKonrad Sztyber        (optional)
74660a8d0ceSEugene Kobyak        fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr.
7477610bc38SKonrad Sztyber        0 means no such timeout.
7487610bc38SKonrad Sztyber        If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than
7497610bc38SKonrad Sztyber        ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1. (optional)
75003b6183aSKrzysztof Karas        psk: Set PSK file path and enable TCP SSL socket implementation (optional)
75126b9be75SShuhei Matsumoto        max_bdevs: Size of the name array for newly created bdevs. Default is 128. (optional)
75258a28432SKonrad Sztyber        dhchap_key: DH-HMAC-CHAP key name.
7533e4c5347SKonrad Sztyber        dhchap_ctrlr_key: DH-HMAC-CHAP controller key name.
75478467a35SKarl Bonde Torp        allow_unrecognized_csi: Allow attaching namespaces with unrecognized command set identifiers. These will only support NVMe
75578467a35SKarl Bonde Torp        passthrough.
7567610bc38SKonrad Sztyber    Returns:
7577610bc38SKonrad Sztyber        Names of created block devices.
7587610bc38SKonrad Sztyber    """
7598feddadaSEugene Kobyak    params = dict()
7608feddadaSEugene Kobyak    params['name'] = name
7618feddadaSEugene Kobyak    params['trtype'] = trtype
7628feddadaSEugene Kobyak    params['traddr'] = traddr
7638feddadaSEugene Kobyak    if adrfam is not None:
7647610bc38SKonrad Sztyber        params['adrfam'] = adrfam
7658feddadaSEugene Kobyak    if trsvcid is not None:
7667610bc38SKonrad Sztyber        params['trsvcid'] = trsvcid
7678feddadaSEugene Kobyak    if priority is not None:
7687610bc38SKonrad Sztyber        params['priority'] = priority
7698feddadaSEugene Kobyak    if subnqn is not None:
7707610bc38SKonrad Sztyber        params['subnqn'] = subnqn
77160a8d0ceSEugene Kobyak    if hostnqn is not None:
77260a8d0ceSEugene Kobyak        params['hostnqn'] = hostnqn
77360a8d0ceSEugene Kobyak    if hostaddr is not None:
77460a8d0ceSEugene Kobyak        params['hostaddr'] = hostaddr
77560a8d0ceSEugene Kobyak    if hostsvcid is not None:
77660a8d0ceSEugene Kobyak        params['hostsvcid'] = hostsvcid
7778feddadaSEugene Kobyak    if prchk_reftag is not None:
7787610bc38SKonrad Sztyber        params['prchk_reftag'] = prchk_reftag
7798feddadaSEugene Kobyak    if prchk_guard is not None:
7807610bc38SKonrad Sztyber        params['prchk_guard'] = prchk_guard
7818feddadaSEugene Kobyak    if hdgst is not None:
7827610bc38SKonrad Sztyber        params['hdgst'] = hdgst
7838feddadaSEugene Kobyak    if ddgst is not None:
7847610bc38SKonrad Sztyber        params['ddgst'] = ddgst
7858feddadaSEugene Kobyak    if fabrics_connect_timeout_us is not None:
786ecb6d9ffSEugene Kobyak        params['fabrics_connect_timeout_us'] = fabrics_connect_timeout_us
7878feddadaSEugene Kobyak    if multipath is not None:
7887610bc38SKonrad Sztyber        params['multipath'] = multipath
7898feddadaSEugene Kobyak    if num_io_queues is not None:
7907610bc38SKonrad Sztyber        params['num_io_queues'] = num_io_queues
7917610bc38SKonrad Sztyber    if ctrlr_loss_timeout_sec is not None:
7927610bc38SKonrad Sztyber        params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec
7937610bc38SKonrad Sztyber    if reconnect_delay_sec is not None:
7947610bc38SKonrad Sztyber        params['reconnect_delay_sec'] = reconnect_delay_sec
7957610bc38SKonrad Sztyber    if fast_io_fail_timeout_sec is not None:
7967610bc38SKonrad Sztyber        params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec
7978feddadaSEugene Kobyak    if psk is not None:
79835f7f0ceSBoris Glimcher        params['psk'] = psk
79926b9be75SShuhei Matsumoto    if max_bdevs is not None:
80026b9be75SShuhei Matsumoto        params['max_bdevs'] = max_bdevs
80158a28432SKonrad Sztyber    if dhchap_key is not None:
80258a28432SKonrad Sztyber        params['dhchap_key'] = dhchap_key
8033e4c5347SKonrad Sztyber    if dhchap_ctrlr_key is not None:
8043e4c5347SKonrad Sztyber        params['dhchap_ctrlr_key'] = dhchap_ctrlr_key
80578467a35SKarl Bonde Torp    if allow_unrecognized_csi is not None:
80678467a35SKarl Bonde Torp        params['allow_unrecognized_csi'] = allow_unrecognized_csi
8077610bc38SKonrad Sztyber    return client.call('bdev_nvme_attach_controller', params)
8087610bc38SKonrad Sztyber
8097610bc38SKonrad Sztyber
8107610bc38SKonrad Sztyberdef bdev_nvme_detach_controller(client, name, trtype=None, traddr=None,
8117610bc38SKonrad Sztyber                                adrfam=None, trsvcid=None, subnqn=None,
8127610bc38SKonrad Sztyber                                hostaddr=None, hostsvcid=None):
8137610bc38SKonrad Sztyber    """Detach NVMe controller and delete any associated bdevs. Optionally,
8147610bc38SKonrad Sztyber       If all of the transport ID options are specified, only remove that
8157610bc38SKonrad Sztyber       transport path from the specified controller. If that is the only
8167610bc38SKonrad Sztyber       available path for the controller, this will also result in the
8177610bc38SKonrad Sztyber       controller being detached and the associated bdevs being deleted.
8187610bc38SKonrad Sztyber    Args:
8197610bc38SKonrad Sztyber        name: controller name
8207610bc38SKonrad Sztyber        trtype: transport type ("PCIe", "RDMA")
8217610bc38SKonrad Sztyber        traddr: transport address (PCI BDF or IP address)
8227610bc38SKonrad Sztyber        adrfam: address family ("IPv4", "IPv6", "IB", or "FC")
8237610bc38SKonrad Sztyber        trsvcid: transport service ID (port number for IP-based addresses)
8247610bc38SKonrad Sztyber        subnqn: subsystem NQN to connect to (optional)
8257610bc38SKonrad Sztyber        hostaddr: Host address (IP address)
8267610bc38SKonrad Sztyber        hostsvcid: transport service ID on host side (port number)
8277610bc38SKonrad Sztyber    """
8288feddadaSEugene Kobyak    params = dict()
8298feddadaSEugene Kobyak    params['name'] = name
8308feddadaSEugene Kobyak    if trtype is not None:
8317610bc38SKonrad Sztyber        params['trtype'] = trtype
8328feddadaSEugene Kobyak    if traddr is not None:
8337610bc38SKonrad Sztyber        params['traddr'] = traddr
8348feddadaSEugene Kobyak    if adrfam is not None:
8357610bc38SKonrad Sztyber        params['adrfam'] = adrfam
8368feddadaSEugene Kobyak    if trsvcid is not None:
8377610bc38SKonrad Sztyber        params['trsvcid'] = trsvcid
8388feddadaSEugene Kobyak    if subnqn is not None:
8397610bc38SKonrad Sztyber        params['subnqn'] = subnqn
8408feddadaSEugene Kobyak    if hostaddr is not None:
8417610bc38SKonrad Sztyber        params['hostaddr'] = hostaddr
8428feddadaSEugene Kobyak    if hostsvcid is not None:
8437610bc38SKonrad Sztyber        params['hostsvcid'] = hostsvcid
8447610bc38SKonrad Sztyber    return client.call('bdev_nvme_detach_controller', params)
8457610bc38SKonrad Sztyber
8467610bc38SKonrad Sztyber
8477b2e6213SEugene Kobyakdef bdev_nvme_reset_controller(client, name, cntlid=None):
8486f2e8fa5SShuhei Matsumoto    """Reset an NVMe controller or all NVMe controllers in an NVMe bdev controller.
8497610bc38SKonrad Sztyber    Args:
8507610bc38SKonrad Sztyber        name: controller name
8516f2e8fa5SShuhei Matsumoto        cntlid: NVMe controller ID (optional)
8527610bc38SKonrad Sztyber    """
8538feddadaSEugene Kobyak    params = dict()
8548feddadaSEugene Kobyak    params['name'] = name
8556f2e8fa5SShuhei Matsumoto    if cntlid is not None:
8566f2e8fa5SShuhei Matsumoto        params['cntlid'] = cntlid
8577610bc38SKonrad Sztyber    return client.call('bdev_nvme_reset_controller', params)
8587610bc38SKonrad Sztyber
8597610bc38SKonrad Sztyber
8607b2e6213SEugene Kobyakdef bdev_nvme_enable_controller(client, name, cntlid=None):
861bef7abeeSShuhei Matsumoto    """Enable an NVMe controller or all NVMe controllers in an NVMe bdev controller.
862bef7abeeSShuhei Matsumoto    Args:
863bef7abeeSShuhei Matsumoto        name: controller name
864bef7abeeSShuhei Matsumoto        cntlid: NVMe controller ID (optional)
865bef7abeeSShuhei Matsumoto    """
8668feddadaSEugene Kobyak    params = dict()
8678feddadaSEugene Kobyak    params['name'] = name
868bef7abeeSShuhei Matsumoto    if cntlid is not None:
869bef7abeeSShuhei Matsumoto        params['cntlid'] = cntlid
870bef7abeeSShuhei Matsumoto    return client.call('bdev_nvme_enable_controller', params)
871bef7abeeSShuhei Matsumoto
872bef7abeeSShuhei Matsumoto
8737b2e6213SEugene Kobyakdef bdev_nvme_disable_controller(client, name, cntlid=None):
874bef7abeeSShuhei Matsumoto    """Disable an NVMe controller or all NVMe controllers in an NVMe bdev controller.
875bef7abeeSShuhei Matsumoto    Args:
876bef7abeeSShuhei Matsumoto        name: controller name
877bef7abeeSShuhei Matsumoto        cntlid: NVMe controller ID (optional)
878bef7abeeSShuhei Matsumoto    """
8798feddadaSEugene Kobyak    params = dict()
8808feddadaSEugene Kobyak    params['name'] = name
881bef7abeeSShuhei Matsumoto    if cntlid is not None:
882bef7abeeSShuhei Matsumoto        params['cntlid'] = cntlid
883bef7abeeSShuhei Matsumoto    return client.call('bdev_nvme_disable_controller', params)
884bef7abeeSShuhei Matsumoto
885bef7abeeSShuhei Matsumoto
8867610bc38SKonrad Sztyberdef bdev_nvme_start_discovery(client, name, trtype, traddr, adrfam=None, trsvcid=None,
8877610bc38SKonrad Sztyber                              hostnqn=None, wait_for_attach=None, ctrlr_loss_timeout_sec=None,
888e5f9e822SKonrad Sztyber                              reconnect_delay_sec=None, fast_io_fail_timeout_sec=None,
889e5f9e822SKonrad Sztyber                              attach_timeout_ms=None):
8907610bc38SKonrad Sztyber    """Start discovery with the specified discovery subsystem
8917610bc38SKonrad Sztyber    Args:
8927610bc38SKonrad Sztyber        name: bdev name prefix; "n" + namespace ID will be appended to create unique names
8937610bc38SKonrad Sztyber        trtype: transport type ("PCIe", "RDMA", "FC", "TCP")
8947610bc38SKonrad Sztyber        traddr: transport address (PCI BDF or IP address)
8957610bc38SKonrad Sztyber        adrfam: address family ("IPv4", "IPv6", "IB", or "FC")
8967610bc38SKonrad Sztyber        trsvcid: transport service ID (port number for IP-based addresses)
8977610bc38SKonrad Sztyber        hostnqn: NQN to connect from (optional)
8987610bc38SKonrad Sztyber        wait_for_attach: Wait to complete RPC until all discovered NVM subsystems have attached (optional)
8997610bc38SKonrad Sztyber        ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr.
9007610bc38SKonrad Sztyber        -1 means infinite reconnect retries. 0 means no reconnect retry.
9017610bc38SKonrad Sztyber        If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero.
9027610bc38SKonrad Sztyber        If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec.
9037610bc38SKonrad Sztyber        (optional)
9047610bc38SKonrad Sztyber        reconnect_delay_sec: Time to delay a reconnect retry.
9057610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero.
9067610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero.
9077610bc38SKonrad Sztyber        If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec.
9087610bc38SKonrad Sztyber        (optional)
90960a8d0ceSEugene Kobyak        fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr.
9107610bc38SKonrad Sztyber        0 means no such timeout.
9117610bc38SKonrad Sztyber        If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than
9127610bc38SKonrad Sztyber        ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1. (optional)
913e5f9e822SKonrad Sztyber        attach_timeout_ms: Time to wait until the discovery and all discovered NVM subsystems are attached (optional)
9147610bc38SKonrad Sztyber    """
9158feddadaSEugene Kobyak    params = dict()
9168feddadaSEugene Kobyak    params['name'] = name
9178feddadaSEugene Kobyak    params['trtype'] = trtype
9188feddadaSEugene Kobyak    params['traddr'] = traddr
9198feddadaSEugene Kobyak    if adrfam is not None:
9207610bc38SKonrad Sztyber        params['adrfam'] = adrfam
9218feddadaSEugene Kobyak    if trsvcid is not None:
9227610bc38SKonrad Sztyber        params['trsvcid'] = trsvcid
92360a8d0ceSEugene Kobyak    if hostnqn is not None:
92460a8d0ceSEugene Kobyak        params['hostnqn'] = hostnqn
9258feddadaSEugene Kobyak    if wait_for_attach is not None:
9268feddadaSEugene Kobyak        params['wait_for_attach'] = wait_for_attach
9277610bc38SKonrad Sztyber    if ctrlr_loss_timeout_sec is not None:
9287610bc38SKonrad Sztyber        params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec
9297610bc38SKonrad Sztyber    if reconnect_delay_sec is not None:
9307610bc38SKonrad Sztyber        params['reconnect_delay_sec'] = reconnect_delay_sec
9317610bc38SKonrad Sztyber    if fast_io_fail_timeout_sec is not None:
9327610bc38SKonrad Sztyber        params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec
93360a8d0ceSEugene Kobyak    if attach_timeout_ms is not None:
93460a8d0ceSEugene Kobyak        params['attach_timeout_ms'] = attach_timeout_ms
9357610bc38SKonrad Sztyber    return client.call('bdev_nvme_start_discovery', params)
9367610bc38SKonrad Sztyber
9377610bc38SKonrad Sztyber
9387610bc38SKonrad Sztyberdef bdev_nvme_stop_discovery(client, name):
9397610bc38SKonrad Sztyber    """Stop a previously started discovery service
9407610bc38SKonrad Sztyber    Args:
9417610bc38SKonrad Sztyber        name: name of discovery service to start
9427610bc38SKonrad Sztyber    """
9438feddadaSEugene Kobyak    params = dict()
9448feddadaSEugene Kobyak    params['name'] = name
9457610bc38SKonrad Sztyber    return client.call('bdev_nvme_stop_discovery', params)
9467610bc38SKonrad Sztyber
9477610bc38SKonrad Sztyber
948f331ae16SKonrad Sztyberdef bdev_nvme_get_discovery_info(client):
949f331ae16SKonrad Sztyber    """Get information about the automatic discovery
950f331ae16SKonrad Sztyber    """
951f331ae16SKonrad Sztyber    return client.call('bdev_nvme_get_discovery_info')
952f331ae16SKonrad Sztyber
953f331ae16SKonrad Sztyber
9547b2e6213SEugene Kobyakdef bdev_nvme_get_io_paths(client, name=None):
9552a6a6448SShuhei Matsumoto    """Display all or the specified NVMe bdev's active I/O paths
9562a6a6448SShuhei Matsumoto    Args:
9572a6a6448SShuhei Matsumoto        name: Name of the NVMe bdev (optional)
9582a6a6448SShuhei Matsumoto    Returns:
9592a6a6448SShuhei Matsumoto        List of active I/O paths
9602a6a6448SShuhei Matsumoto    """
9618feddadaSEugene Kobyak    params = dict()
9628feddadaSEugene Kobyak    if name is not None:
9632a6a6448SShuhei Matsumoto        params['name'] = name
9642a6a6448SShuhei Matsumoto    return client.call('bdev_nvme_get_io_paths', params)
9652a6a6448SShuhei Matsumoto
9662a6a6448SShuhei Matsumoto
96722b77a3cSShuhei Matsumotodef bdev_nvme_set_preferred_path(client, name, cntlid):
96822b77a3cSShuhei Matsumoto    """Set the preferred I/O path for an NVMe bdev when in multipath mode
96922b77a3cSShuhei Matsumoto    Args:
97022b77a3cSShuhei Matsumoto        name: NVMe bdev name
97122b77a3cSShuhei Matsumoto        cntlid: NVMe-oF controller ID
97222b77a3cSShuhei Matsumoto    """
9738feddadaSEugene Kobyak    params = dict()
9748feddadaSEugene Kobyak    params['name'] = name
9758feddadaSEugene Kobyak    params['cntlid'] = cntlid
97622b77a3cSShuhei Matsumoto    return client.call('bdev_nvme_set_preferred_path', params)
97722b77a3cSShuhei Matsumoto
97822b77a3cSShuhei Matsumoto
9797b2e6213SEugene Kobyakdef bdev_nvme_set_multipath_policy(client, name, policy, selector=None, rr_min_io=None):
9808f9b9775SShuhei Matsumoto    """Set multipath policy of the NVMe bdev
9818f9b9775SShuhei Matsumoto    Args:
9828f9b9775SShuhei Matsumoto        name: NVMe bdev name
9838f9b9775SShuhei Matsumoto        policy: Multipath policy (active_passive or active_active)
9846aa4edc2SRichael Zhuang        selector: Multipath selector (round_robin, queue_depth)
9852f500a23SRichael Zhuang        rr_min_io: Number of IO to route to a path before switching to another one (optional)
9868f9b9775SShuhei Matsumoto    """
9878feddadaSEugene Kobyak    params = dict()
9888feddadaSEugene Kobyak    params['name'] = name
9898feddadaSEugene Kobyak    params['policy'] = policy
9908feddadaSEugene Kobyak    if selector is not None:
9916aa4edc2SRichael Zhuang        params['selector'] = selector
9928feddadaSEugene Kobyak    if rr_min_io is not None:
9932f500a23SRichael Zhuang        params['rr_min_io'] = rr_min_io
9948f9b9775SShuhei Matsumoto    return client.call('bdev_nvme_set_multipath_policy', params)
9958f9b9775SShuhei Matsumoto
9968f9b9775SShuhei Matsumoto
997b317d8f3SRichael Zhuangdef bdev_nvme_get_path_iostat(client, name):
998b317d8f3SRichael Zhuang    """Get I/O statistics for IO paths of the block device.
999b317d8f3SRichael Zhuang    Args:
1000b317d8f3SRichael Zhuang        name: bdev name to query
1001b317d8f3SRichael Zhuang    Returns:
1002b317d8f3SRichael Zhuang        I/O statistics for IO paths of the requested block device.
1003b317d8f3SRichael Zhuang    """
10048feddadaSEugene Kobyak    params = dict()
10058feddadaSEugene Kobyak    params['name'] = name
1006b317d8f3SRichael Zhuang    return client.call('bdev_nvme_get_path_iostat', params)
1007b317d8f3SRichael Zhuang
1008b317d8f3SRichael Zhuang
10097610bc38SKonrad Sztyberdef bdev_nvme_cuse_register(client, name):
10107610bc38SKonrad Sztyber    """Register CUSE devices on NVMe controller.
10117610bc38SKonrad Sztyber    Args:
10127610bc38SKonrad Sztyber        name: Name of the operating NVMe controller
10137610bc38SKonrad Sztyber    """
10148feddadaSEugene Kobyak    params = dict()
10158feddadaSEugene Kobyak    params['name'] = name
10167610bc38SKonrad Sztyber    return client.call('bdev_nvme_cuse_register', params)
10177610bc38SKonrad Sztyber
10187610bc38SKonrad Sztyber
10197610bc38SKonrad Sztyberdef bdev_nvme_cuse_unregister(client, name):
10207610bc38SKonrad Sztyber    """Unregister CUSE devices on NVMe controller.
10217610bc38SKonrad Sztyber    Args:
10227610bc38SKonrad Sztyber        name: Name of the operating NVMe controller
10237610bc38SKonrad Sztyber    """
10248feddadaSEugene Kobyak    params = dict()
10258feddadaSEugene Kobyak    params['name'] = name
10267610bc38SKonrad Sztyber    return client.call('bdev_nvme_cuse_unregister', params)
10277610bc38SKonrad Sztyber
10287610bc38SKonrad Sztyber
10298d3f8fb8SKonrad Sztyberdef bdev_nvme_set_keys(client, name, dhchap_key=None, dhchap_ctrlr_key=None):
10308d3f8fb8SKonrad Sztyber    """Set DH-HMAC-CHAP keys and force (re)authentication on all connected qpairs.
10318d3f8fb8SKonrad Sztyber    Args:
10328d3f8fb8SKonrad Sztyber        name: name of the NVMe controller
10338d3f8fb8SKonrad Sztyber        dhchap_key: DH-HMAC-CHAP key name
10348d3f8fb8SKonrad Sztyber        dhchap_ctrlr_key: DH-HMAC-CHAP controller key name
10358d3f8fb8SKonrad Sztyber    """
10368d3f8fb8SKonrad Sztyber    params = {'name': name}
10378d3f8fb8SKonrad Sztyber    if dhchap_key is not None:
10388d3f8fb8SKonrad Sztyber        params['dhchap_key'] = dhchap_key
10398d3f8fb8SKonrad Sztyber    if dhchap_ctrlr_key is not None:
10408d3f8fb8SKonrad Sztyber        params['dhchap_ctrlr_key'] = dhchap_ctrlr_key
10418d3f8fb8SKonrad Sztyber    return client.call('bdev_nvme_set_keys', params)
10428d3f8fb8SKonrad Sztyber
10438d3f8fb8SKonrad Sztyber
10447610bc38SKonrad Sztyberdef bdev_zone_block_create(client, name, base_bdev, zone_capacity, optimal_open_zones):
10457610bc38SKonrad Sztyber    """Creates a virtual zone device on top of existing non-zoned bdev.
10467610bc38SKonrad Sztyber    Args:
10477610bc38SKonrad Sztyber        name: Zone device name
10487610bc38SKonrad Sztyber        base_bdev: Base Nvme bdev name
10497610bc38SKonrad Sztyber        zone_capacity: Surfaced zone capacity in blocks
10507610bc38SKonrad Sztyber        optimal_open_zones: Number of zones required to reach optimal write speed (optional, default: 1)
10517610bc38SKonrad Sztyber    Returns:
10527610bc38SKonrad Sztyber        Name of created block device.
10537610bc38SKonrad Sztyber    """
10548feddadaSEugene Kobyak    params = dict()
10558feddadaSEugene Kobyak    params['name'] = name
10568feddadaSEugene Kobyak    params['base_bdev'] = base_bdev
10578feddadaSEugene Kobyak    params['zone_capacity'] = zone_capacity
10588feddadaSEugene Kobyak    params['optimal_open_zones'] = optimal_open_zones
10597610bc38SKonrad Sztyber    return client.call('bdev_zone_block_create', params)
10607610bc38SKonrad Sztyber
10617610bc38SKonrad Sztyber
10627610bc38SKonrad Sztyberdef bdev_zone_block_delete(client, name):
10637610bc38SKonrad Sztyber    """Remove block zone bdev from the system.
10647610bc38SKonrad Sztyber    Args:
10657610bc38SKonrad Sztyber        name: name of block zone bdev to delete
10667610bc38SKonrad Sztyber    """
10678feddadaSEugene Kobyak    params = dict()
10688feddadaSEugene Kobyak    params['name'] = name
10697610bc38SKonrad Sztyber    return client.call('bdev_zone_block_delete', params)
10707610bc38SKonrad Sztyber
10717610bc38SKonrad Sztyber
10727b2e6213SEugene Kobyakdef bdev_rbd_register_cluster(client, name=None, user_id=None, config_param=None, config_file=None, key_file=None, core_mask=None):
10737610bc38SKonrad Sztyber    """Create a Rados Cluster object of the Ceph RBD backend.
10747610bc38SKonrad Sztyber    Args:
10757610bc38SKonrad Sztyber        name: name of Rados Cluster
1076dd04b4deSEugene Kobyak        user_id: Ceph user name (optional)
10777610bc38SKonrad Sztyber        config_param: map of config keys to values (optional)
10787610bc38SKonrad Sztyber        config_file: file path of Ceph configuration file (optional)
10797610bc38SKonrad Sztyber        key_file: file path of Ceph key file (optional)
1080b618f056SYue-Zhu        core_mask: core mask for librbd IO context threads (optional)
10817610bc38SKonrad Sztyber    Returns:
10827610bc38SKonrad Sztyber        Name of registered Rados Cluster object.
10837610bc38SKonrad Sztyber    """
10848feddadaSEugene Kobyak    params = dict()
10857b2e6213SEugene Kobyak    if name is not None:
10867b2e6213SEugene Kobyak        params['name'] = name
1087dd04b4deSEugene Kobyak    if user_id is not None:
1088dd04b4deSEugene Kobyak        params['user_id'] = user_id
10897610bc38SKonrad Sztyber    if config_param is not None:
10907610bc38SKonrad Sztyber        params['config_param'] = config_param
10917610bc38SKonrad Sztyber    if config_file is not None:
10927610bc38SKonrad Sztyber        params['config_file'] = config_file
10937610bc38SKonrad Sztyber    if key_file is not None:
10947610bc38SKonrad Sztyber        params['key_file'] = key_file
1095b618f056SYue-Zhu    if core_mask is not None:
1096b618f056SYue-Zhu        params['core_mask'] = core_mask
10977610bc38SKonrad Sztyber    return client.call('bdev_rbd_register_cluster', params)
10987610bc38SKonrad Sztyber
10997610bc38SKonrad Sztyber
11007610bc38SKonrad Sztyberdef bdev_rbd_unregister_cluster(client, name):
11017610bc38SKonrad Sztyber    """Remove Rados cluster object from the system.
11027610bc38SKonrad Sztyber    Args:
11037610bc38SKonrad Sztyber        name: name of Rados cluster object to unregister
11047610bc38SKonrad Sztyber    """
11058feddadaSEugene Kobyak    params = dict()
11068feddadaSEugene Kobyak    params['name'] = name
11077610bc38SKonrad Sztyber    return client.call('bdev_rbd_unregister_cluster', params)
11087610bc38SKonrad Sztyber
11097610bc38SKonrad Sztyber
11107b2e6213SEugene Kobyakdef bdev_rbd_get_clusters_info(client, name=None):
11117610bc38SKonrad Sztyber    """Get the cluster(s) info
11127610bc38SKonrad Sztyber    Args:
11137610bc38SKonrad Sztyber        name: name of Rados cluster object to query (optional; if omitted, query all clusters)
11147610bc38SKonrad Sztyber    Returns:
11157610bc38SKonrad Sztyber        List of registered Rados cluster information objects.
11167610bc38SKonrad Sztyber    """
11178feddadaSEugene Kobyak    params = dict()
11188feddadaSEugene Kobyak    if name is not None:
11197610bc38SKonrad Sztyber        params['name'] = name
11207610bc38SKonrad Sztyber    return client.call('bdev_rbd_get_clusters_info', params)
11217610bc38SKonrad Sztyber
11227610bc38SKonrad Sztyber
1123dd04b4deSEugene Kobyakdef bdev_rbd_create(client, pool_name, rbd_name, block_size, name=None, user_id=None, config=None, cluster_name=None, uuid=None):
11247610bc38SKonrad Sztyber    """Create a Ceph RBD block device.
11257610bc38SKonrad Sztyber    Args:
11267610bc38SKonrad Sztyber        pool_name: Ceph RBD pool name
11277610bc38SKonrad Sztyber        rbd_name: Ceph RBD image name
11287610bc38SKonrad Sztyber        block_size: block size of RBD volume
11297610bc38SKonrad Sztyber        name: name of block device (optional)
1130dd04b4deSEugene Kobyak        user_id: Ceph user name (optional)
11317610bc38SKonrad Sztyber        config: map of config keys to values (optional)
11327610bc38SKonrad Sztyber        cluster_name: Name to identify Rados cluster (optional)
11337610bc38SKonrad Sztyber        uuid: UUID of block device (optional)
11347610bc38SKonrad Sztyber    Returns:
11357610bc38SKonrad Sztyber        Name of created block device.
11367610bc38SKonrad Sztyber    """
11378feddadaSEugene Kobyak    params = dict()
11388feddadaSEugene Kobyak    params['pool_name'] = pool_name
11398feddadaSEugene Kobyak    params['rbd_name'] = rbd_name
11408feddadaSEugene Kobyak    params['block_size'] = block_size
11418feddadaSEugene Kobyak    if name is not None:
11427610bc38SKonrad Sztyber        params['name'] = name
1143dd04b4deSEugene Kobyak    if user_id is not None:
1144dd04b4deSEugene Kobyak        params['user_id'] = user_id
11457610bc38SKonrad Sztyber    if config is not None:
11467610bc38SKonrad Sztyber        params['config'] = config
11477610bc38SKonrad Sztyber    if cluster_name is not None:
11487610bc38SKonrad Sztyber        params['cluster_name'] = cluster_name
1149f656eed6SYifan Bian    else:
1150f656eed6SYifan Bian        print("WARNING:bdev_rbd_create should be used with specifying -c to have a cluster name after bdev_rbd_register_cluster.")
11517610bc38SKonrad Sztyber    if uuid is not None:
11527610bc38SKonrad Sztyber        params['uuid'] = uuid
11537610bc38SKonrad Sztyber    return client.call('bdev_rbd_create', params)
11547610bc38SKonrad Sztyber
11557610bc38SKonrad Sztyber
11567610bc38SKonrad Sztyberdef bdev_rbd_delete(client, name):
11577610bc38SKonrad Sztyber    """Remove rbd bdev from the system.
11587610bc38SKonrad Sztyber    Args:
11597610bc38SKonrad Sztyber        name: name of rbd bdev to delete
11607610bc38SKonrad Sztyber    """
11618feddadaSEugene Kobyak    params = dict()
11628feddadaSEugene Kobyak    params['name'] = name
11637610bc38SKonrad Sztyber    return client.call('bdev_rbd_delete', params)
11647610bc38SKonrad Sztyber
11657610bc38SKonrad Sztyber
11667610bc38SKonrad Sztyberdef bdev_rbd_resize(client, name, new_size):
11677610bc38SKonrad Sztyber    """Resize rbd bdev in the system.
11687610bc38SKonrad Sztyber    Args:
11697610bc38SKonrad Sztyber        name: name of rbd bdev to resize
11707610bc38SKonrad Sztyber        new_size: new bdev size of resize operation. The unit is MiB
11717610bc38SKonrad Sztyber    """
11728feddadaSEugene Kobyak    params = dict()
11738feddadaSEugene Kobyak    params['name'] = name
11748feddadaSEugene Kobyak    params['new_size'] = new_size
11757610bc38SKonrad Sztyber    return client.call('bdev_rbd_resize', params)
11767610bc38SKonrad Sztyber
11777610bc38SKonrad Sztyber
117891ea8102SKrzysztof Karasdef bdev_error_create(client, base_name, uuid=None):
11797610bc38SKonrad Sztyber    """Construct an error injection block device.
11807610bc38SKonrad Sztyber    Args:
11817610bc38SKonrad Sztyber        base_name: base bdev name
118291ea8102SKrzysztof Karas        uuid: UUID for this bdev (optional)
11837610bc38SKonrad Sztyber    """
11848feddadaSEugene Kobyak    params = dict()
11858feddadaSEugene Kobyak    params['base_name'] = base_name
118691ea8102SKrzysztof Karas    if uuid is not None:
118791ea8102SKrzysztof Karas        params['uuid'] = uuid
11887610bc38SKonrad Sztyber    return client.call('bdev_error_create', params)
11897610bc38SKonrad Sztyber
11907610bc38SKonrad Sztyber
11912f08dc7fSTomasz Zawadzkidef bdev_delay_create(client, base_bdev_name, name, avg_read_latency, p99_read_latency, avg_write_latency, p99_write_latency, uuid=None):
11927610bc38SKonrad Sztyber    """Construct a delay block device.
11937610bc38SKonrad Sztyber    Args:
11947610bc38SKonrad Sztyber        base_bdev_name: name of the existing bdev
11957610bc38SKonrad Sztyber        name: name of block device
11967610bc38SKonrad Sztyber        avg_read_latency: complete 99% of read ops with this delay
11977610bc38SKonrad Sztyber        p99_read_latency: complete 1% of read ops with this delay
11987610bc38SKonrad Sztyber        avg_write_latency: complete 99% of write ops with this delay
11997610bc38SKonrad Sztyber        p99_write_latency: complete 1% of write ops with this delay
12002f08dc7fSTomasz Zawadzki        uuid: UUID of block device (optional)
12017610bc38SKonrad Sztyber    Returns:
12027610bc38SKonrad Sztyber        Name of created block device.
12037610bc38SKonrad Sztyber    """
12048feddadaSEugene Kobyak    params = dict()
12058feddadaSEugene Kobyak    params['base_bdev_name'] = base_bdev_name
12068feddadaSEugene Kobyak    params['name'] = name
12078feddadaSEugene Kobyak    params['avg_read_latency'] = avg_read_latency
12088feddadaSEugene Kobyak    params['p99_read_latency'] = p99_read_latency
12098feddadaSEugene Kobyak    params['avg_write_latency'] = avg_write_latency
12108feddadaSEugene Kobyak    params['p99_write_latency'] = p99_write_latency
12118feddadaSEugene Kobyak    if uuid is not None:
12122f08dc7fSTomasz Zawadzki        params['uuid'] = uuid
12137610bc38SKonrad Sztyber    return client.call('bdev_delay_create', params)
12147610bc38SKonrad Sztyber
12157610bc38SKonrad Sztyber
12167610bc38SKonrad Sztyberdef bdev_delay_delete(client, name):
12177610bc38SKonrad Sztyber    """Remove delay bdev from the system.
12187610bc38SKonrad Sztyber    Args:
12197610bc38SKonrad Sztyber        name: name of delay bdev to delete
12207610bc38SKonrad Sztyber    """
12218feddadaSEugene Kobyak    params = dict()
12228feddadaSEugene Kobyak    params['name'] = name
12237610bc38SKonrad Sztyber    return client.call('bdev_delay_delete', params)
12247610bc38SKonrad Sztyber
12257610bc38SKonrad Sztyber
12267610bc38SKonrad Sztyberdef bdev_delay_update_latency(client, delay_bdev_name, latency_type, latency_us):
12277610bc38SKonrad Sztyber    """Update the latency value for a delay block device
12287610bc38SKonrad Sztyber    Args:
12297610bc38SKonrad Sztyber        delay_bdev_name: name of the delay bdev
12307610bc38SKonrad Sztyber        latency_type: 'one of: avg_read, avg_write, p99_read, p99_write. No other values accepted.'
12317610bc38SKonrad Sztyber        latency_us: 'new latency value.'
12327610bc38SKonrad Sztyber    Returns:
12337610bc38SKonrad Sztyber        True if successful, or a specific error otherwise.
12347610bc38SKonrad Sztyber    """
12358feddadaSEugene Kobyak    params = dict()
12368feddadaSEugene Kobyak    params['delay_bdev_name'] = delay_bdev_name
12378feddadaSEugene Kobyak    params['latency_type'] = latency_type
12388feddadaSEugene Kobyak    params['latency_us'] = latency_us
12397610bc38SKonrad Sztyber    return client.call('bdev_delay_update_latency', params)
12407610bc38SKonrad Sztyber
12417610bc38SKonrad Sztyber
12427610bc38SKonrad Sztyberdef bdev_error_delete(client, name):
12437610bc38SKonrad Sztyber    """Remove error bdev from the system.
12447610bc38SKonrad Sztyber    Args:
12457610bc38SKonrad Sztyber        bdev_name: name of error bdev to delete
12467610bc38SKonrad Sztyber    """
12478feddadaSEugene Kobyak    params = dict()
12488feddadaSEugene Kobyak    params['name'] = name
12497610bc38SKonrad Sztyber    return client.call('bdev_error_delete', params)
12507610bc38SKonrad Sztyber
12517610bc38SKonrad Sztyber
12527b2e6213SEugene Kobyakdef bdev_iscsi_set_options(client, timeout_sec=None):
12531519aa47Sgongwei    """Set options for the bdev iscsi.
12541519aa47Sgongwei    Args:
1255c8e594c2Sgongwei        timeout_sec: Timeout for command, in seconds, if 0, don't track timeout
12561519aa47Sgongwei    """
12578feddadaSEugene Kobyak    params = dict()
1258c8e594c2Sgongwei    if timeout_sec is not None:
1259c8e594c2Sgongwei        params['timeout_sec'] = timeout_sec
12601519aa47Sgongwei    return client.call('bdev_iscsi_set_options', params)
12611519aa47Sgongwei
12621519aa47Sgongwei
12637610bc38SKonrad Sztyberdef bdev_iscsi_create(client, name, url, initiator_iqn):
12647610bc38SKonrad Sztyber    """Construct an iSCSI block device.
12657610bc38SKonrad Sztyber    Args:
12667610bc38SKonrad Sztyber        name: name of block device
12677610bc38SKonrad Sztyber        url: iSCSI URL
12687610bc38SKonrad Sztyber        initiator_iqn: IQN name to be used by initiator
12697610bc38SKonrad Sztyber    Returns:
12707610bc38SKonrad Sztyber        Name of created block device.
12717610bc38SKonrad Sztyber    """
12728feddadaSEugene Kobyak    params = dict()
12738feddadaSEugene Kobyak    params['name'] = name
12748feddadaSEugene Kobyak    params['url'] = url
12758feddadaSEugene Kobyak    params['initiator_iqn'] = initiator_iqn
12767610bc38SKonrad Sztyber    return client.call('bdev_iscsi_create', params)
12777610bc38SKonrad Sztyber
12787610bc38SKonrad Sztyber
12797610bc38SKonrad Sztyberdef bdev_iscsi_delete(client, name):
12807610bc38SKonrad Sztyber    """Remove iSCSI bdev from the system.
12817610bc38SKonrad Sztyber    Args:
12827610bc38SKonrad Sztyber        bdev_name: name of iSCSI bdev to delete
12837610bc38SKonrad Sztyber    """
12848feddadaSEugene Kobyak    params = dict()
12858feddadaSEugene Kobyak    params['name'] = name
12867610bc38SKonrad Sztyber    return client.call('bdev_iscsi_delete', params)
12877610bc38SKonrad Sztyber
12887610bc38SKonrad Sztyber
12897809cb41SArtur Paszkiewiczdef bdev_passthru_create(client, base_bdev_name, name, uuid=None):
12907610bc38SKonrad Sztyber    """Construct a pass-through block device.
12917610bc38SKonrad Sztyber    Args:
12927610bc38SKonrad Sztyber        base_bdev_name: name of the existing bdev
12937610bc38SKonrad Sztyber        name: name of block device
12947809cb41SArtur Paszkiewicz        uuid: UUID of block device (optional)
12957610bc38SKonrad Sztyber    Returns:
12967610bc38SKonrad Sztyber        Name of created block device.
12977610bc38SKonrad Sztyber    """
12988feddadaSEugene Kobyak    params = dict()
12998feddadaSEugene Kobyak    params['base_bdev_name'] = base_bdev_name
13008feddadaSEugene Kobyak    params['name'] = name
13018feddadaSEugene Kobyak    if uuid is not None:
13027809cb41SArtur Paszkiewicz        params['uuid'] = uuid
13037610bc38SKonrad Sztyber    return client.call('bdev_passthru_create', params)
13047610bc38SKonrad Sztyber
13057610bc38SKonrad Sztyber
13067610bc38SKonrad Sztyberdef bdev_passthru_delete(client, name):
13077610bc38SKonrad Sztyber    """Remove pass through bdev from the system.
13087610bc38SKonrad Sztyber    Args:
13097610bc38SKonrad Sztyber        name: name of pass through bdev to delete
13107610bc38SKonrad Sztyber    """
13118feddadaSEugene Kobyak    params = dict()
13128feddadaSEugene Kobyak    params['name'] = name
13137610bc38SKonrad Sztyber    return client.call('bdev_passthru_delete', params)
13147610bc38SKonrad Sztyber
13157610bc38SKonrad Sztyber
13167610bc38SKonrad Sztyberdef bdev_opal_create(client, nvme_ctrlr_name, nsid, locking_range_id, range_start, range_length, password):
13177610bc38SKonrad Sztyber    """Create opal virtual block devices from a base nvme bdev.
13187610bc38SKonrad Sztyber    Args:
13197610bc38SKonrad Sztyber        nvme_ctrlr_name: name of the nvme ctrlr
13207610bc38SKonrad Sztyber        nsid: namespace ID of nvme ctrlr
13217610bc38SKonrad Sztyber        locking_range_id: locking range ID corresponding to this virtual bdev
13227610bc38SKonrad Sztyber        range_start: start address of this locking range
13237610bc38SKonrad Sztyber        range_length: length of this locking range
13247610bc38SKonrad Sztyber        password: admin password of base nvme bdev
13257610bc38SKonrad Sztyber    Returns:
13267610bc38SKonrad Sztyber        Name of the new created block devices.
13277610bc38SKonrad Sztyber    """
13288feddadaSEugene Kobyak    params = dict()
13298feddadaSEugene Kobyak    params['nvme_ctrlr_name'] = nvme_ctrlr_name
13308feddadaSEugene Kobyak    params['nsid'] = nsid
13318feddadaSEugene Kobyak    params['locking_range_id'] = locking_range_id
13328feddadaSEugene Kobyak    params['range_start'] = range_start
13338feddadaSEugene Kobyak    params['range_length'] = range_length
13348feddadaSEugene Kobyak    params['password'] = password
13357610bc38SKonrad Sztyber    return client.call('bdev_opal_create', params)
13367610bc38SKonrad Sztyber
13377610bc38SKonrad Sztyber
13387610bc38SKonrad Sztyberdef bdev_opal_get_info(client, bdev_name, password):
13397610bc38SKonrad Sztyber    """Get opal locking range info.
13407610bc38SKonrad Sztyber    Args:
13417610bc38SKonrad Sztyber        bdev_name: name of opal vbdev to get info
13427610bc38SKonrad Sztyber        password: admin password
13437610bc38SKonrad Sztyber    Returns:
13447610bc38SKonrad Sztyber        Locking range info.
13457610bc38SKonrad Sztyber    """
13468feddadaSEugene Kobyak    params = dict()
13478feddadaSEugene Kobyak    params['bdev_name'] = bdev_name
13488feddadaSEugene Kobyak    params['password'] = password
13497610bc38SKonrad Sztyber    return client.call('bdev_opal_get_info', params)
13507610bc38SKonrad Sztyber
13517610bc38SKonrad Sztyber
13527610bc38SKonrad Sztyberdef bdev_opal_delete(client, bdev_name, password):
13537610bc38SKonrad Sztyber    """Delete opal virtual bdev from the system.
13547610bc38SKonrad Sztyber    Args:
13557610bc38SKonrad Sztyber        bdev_name: name of opal vbdev to delete
13567610bc38SKonrad Sztyber        password: admin password of base nvme bdev
13577610bc38SKonrad Sztyber    """
13588feddadaSEugene Kobyak    params = dict()
13598feddadaSEugene Kobyak    params['bdev_name'] = bdev_name
13608feddadaSEugene Kobyak    params['password'] = password
13617610bc38SKonrad Sztyber    return client.call('bdev_opal_delete', params)
13627610bc38SKonrad Sztyber
13637610bc38SKonrad Sztyber
13647610bc38SKonrad Sztyberdef bdev_opal_new_user(client, bdev_name, admin_password, user_id, user_password):
13657610bc38SKonrad Sztyber    """Add a user to opal bdev who can set lock state for this bdev.
13667610bc38SKonrad Sztyber    Args:
13677610bc38SKonrad Sztyber        bdev_name: name of opal vbdev
13687610bc38SKonrad Sztyber        admin_password: admin password
13697610bc38SKonrad Sztyber        user_id: ID of the user who will be added to this opal bdev
13707610bc38SKonrad Sztyber        user_password: password set for this user
13717610bc38SKonrad Sztyber    """
13728feddadaSEugene Kobyak    params = dict()
13738feddadaSEugene Kobyak    params['bdev_name'] = bdev_name
13748feddadaSEugene Kobyak    params['admin_password'] = admin_password
13758feddadaSEugene Kobyak    params['user_id'] = user_id
13768feddadaSEugene Kobyak    params['user_password'] = user_password
13777610bc38SKonrad Sztyber    return client.call('bdev_opal_new_user', params)
13787610bc38SKonrad Sztyber
13797610bc38SKonrad Sztyber
13807610bc38SKonrad Sztyberdef bdev_opal_set_lock_state(client, bdev_name, user_id, password, lock_state):
13817610bc38SKonrad Sztyber    """set lock state for an opal bdev.
13827610bc38SKonrad Sztyber    Args:
13837610bc38SKonrad Sztyber        bdev_name: name of opal vbdev
13847610bc38SKonrad Sztyber        user_id: ID of the user who will set lock state
13857610bc38SKonrad Sztyber        password: password of the user
13867610bc38SKonrad Sztyber        lock_state: lock state to set
13877610bc38SKonrad Sztyber    """
13888feddadaSEugene Kobyak    params = dict()
13898feddadaSEugene Kobyak    params['bdev_name'] = bdev_name
13908feddadaSEugene Kobyak    params['user_id'] = user_id
13918feddadaSEugene Kobyak    params['password'] = password
13928feddadaSEugene Kobyak    params['lock_state'] = lock_state
13937610bc38SKonrad Sztyber    return client.call('bdev_opal_set_lock_state', params)
13947610bc38SKonrad Sztyber
13957610bc38SKonrad Sztyber
13967610bc38SKonrad Sztyberdef bdev_split_create(client, base_bdev, split_count, split_size_mb=None):
13977610bc38SKonrad Sztyber    """Create split block devices from a base bdev.
13987610bc38SKonrad Sztyber    Args:
13997610bc38SKonrad Sztyber        base_bdev: name of bdev to split
14007610bc38SKonrad Sztyber        split_count: number of split bdevs to create
14017610bc38SKonrad Sztyber        split_size_mb: size of each split volume in MiB (optional)
14027610bc38SKonrad Sztyber    Returns:
14037610bc38SKonrad Sztyber        List of created block devices.
14047610bc38SKonrad Sztyber    """
14058feddadaSEugene Kobyak    params = dict()
14068feddadaSEugene Kobyak    params['base_bdev'] = base_bdev
14078feddadaSEugene Kobyak    params['split_count'] = split_count
14088feddadaSEugene Kobyak    if split_size_mb is not None:
14097610bc38SKonrad Sztyber        params['split_size_mb'] = split_size_mb
14107610bc38SKonrad Sztyber    return client.call('bdev_split_create', params)
14117610bc38SKonrad Sztyber
14127610bc38SKonrad Sztyber
14137610bc38SKonrad Sztyberdef bdev_split_delete(client, base_bdev):
14147610bc38SKonrad Sztyber    """Delete split block devices.
14157610bc38SKonrad Sztyber    Args:
14167610bc38SKonrad Sztyber        base_bdev: name of previously split bdev
14177610bc38SKonrad Sztyber    """
14188feddadaSEugene Kobyak    params = dict()
14198feddadaSEugene Kobyak    params['base_bdev'] = base_bdev
14207610bc38SKonrad Sztyber    return client.call('bdev_split_delete', params)
14217610bc38SKonrad Sztyber
14227610bc38SKonrad Sztyber
14237b2e6213SEugene Kobyakdef bdev_ftl_create(client, name, base_bdev, cache, **kwargs):
14247610bc38SKonrad Sztyber    """Construct FTL bdev
14257610bc38SKonrad Sztyber    Args:
14267610bc38SKonrad Sztyber        name: name of the bdev
14277610bc38SKonrad Sztyber        base_bdev: name of the base bdev
14287b2e6213SEugene Kobyak        cache: name of the cache device
14297610bc38SKonrad Sztyber        kwargs: optional parameters
14307610bc38SKonrad Sztyber    """
14318feddadaSEugene Kobyak    params = dict()
14328feddadaSEugene Kobyak    params['name'] = name
14338feddadaSEugene Kobyak    params['base_bdev'] = base_bdev
14348feddadaSEugene Kobyak    params['cache'] = cache
14357610bc38SKonrad Sztyber    for key, value in kwargs.items():
14367610bc38SKonrad Sztyber        if value is not None:
14377610bc38SKonrad Sztyber            params[key] = value
14387610bc38SKonrad Sztyber    return client.call('bdev_ftl_create', params)
14397610bc38SKonrad Sztyber
14407610bc38SKonrad Sztyber
14417b2e6213SEugene Kobyakdef bdev_ftl_load(client, name, base_bdev, cache, **kwargs):
1442be90ea6eSArtur Paszkiewicz    """Load FTL bdev
1443be90ea6eSArtur Paszkiewicz    Args:
1444be90ea6eSArtur Paszkiewicz        name: name of the bdev
1445be90ea6eSArtur Paszkiewicz        base_bdev: name of the base bdev
14467b2e6213SEugene Kobyak        cache: Name of the cache device
1447be90ea6eSArtur Paszkiewicz        kwargs: optional parameters
1448be90ea6eSArtur Paszkiewicz    """
14498feddadaSEugene Kobyak    params = dict()
14508feddadaSEugene Kobyak    params['name'] = name
14518feddadaSEugene Kobyak    params['base_bdev'] = base_bdev
14528feddadaSEugene Kobyak    params['cache'] = cache
1453be90ea6eSArtur Paszkiewicz    for key, value in kwargs.items():
1454be90ea6eSArtur Paszkiewicz        if value is not None:
1455be90ea6eSArtur Paszkiewicz            params[key] = value
1456be90ea6eSArtur Paszkiewicz    return client.call('bdev_ftl_load', params)
1457be90ea6eSArtur Paszkiewicz
1458be90ea6eSArtur Paszkiewicz
14597b2e6213SEugene Kobyakdef bdev_ftl_unload(client, name, fast_shutdown=None):
1460be90ea6eSArtur Paszkiewicz    """Unload FTL bdev
1461be90ea6eSArtur Paszkiewicz    Args:
1462be90ea6eSArtur Paszkiewicz        name: name of the bdev
14637b2e6213SEugene Kobyak        fast_shutdown: When set FTL will minimize persisted data during deletion and rely on shared memory during next load
1464be90ea6eSArtur Paszkiewicz    """
14658feddadaSEugene Kobyak    params = dict()
14668feddadaSEugene Kobyak    params['name'] = name
14677b2e6213SEugene Kobyak    if fast_shutdown is not None:
14687b2e6213SEugene Kobyak        params['fast_shutdown'] = fast_shutdown
1469be90ea6eSArtur Paszkiewicz    return client.call('bdev_ftl_unload', params)
1470be90ea6eSArtur Paszkiewicz
1471be90ea6eSArtur Paszkiewicz
14727b2e6213SEugene Kobyakdef bdev_ftl_delete(client, name, fast_shutdown=None):
14737610bc38SKonrad Sztyber    """Delete FTL bdev
14747610bc38SKonrad Sztyber    Args:
14757610bc38SKonrad Sztyber        name: name of the bdev
14767b2e6213SEugene Kobyak        fast_shutdown: When set FTL will minimize persisted data during deletion and rely on shared memory during next load
14777610bc38SKonrad Sztyber    """
14788feddadaSEugene Kobyak    params = dict()
14798feddadaSEugene Kobyak    params['name'] = name
14807b2e6213SEugene Kobyak    if fast_shutdown is not None:
14817b2e6213SEugene Kobyak        params['fast_shutdown'] = fast_shutdown
14827610bc38SKonrad Sztyber    return client.call('bdev_ftl_delete', params)
14837610bc38SKonrad Sztyber
14847610bc38SKonrad Sztyber
14852c7c8b6cSKozlowski Mateuszdef bdev_ftl_unmap(client, name, lba, num_blocks):
14862c7c8b6cSKozlowski Mateusz    """FTL unmap
14872c7c8b6cSKozlowski Mateusz    Args:
14882c7c8b6cSKozlowski Mateusz        name: name of the bdev
14892c7c8b6cSKozlowski Mateusz        lba: starting lba to be unmapped
14902c7c8b6cSKozlowski Mateusz        num_blocks: number of blocks to unmap
14912c7c8b6cSKozlowski Mateusz    """
14928feddadaSEugene Kobyak    params = dict()
14938feddadaSEugene Kobyak    params['name'] = name
14948feddadaSEugene Kobyak    params['lba'] = lba
14958feddadaSEugene Kobyak    params['num_blocks'] = num_blocks
14962c7c8b6cSKozlowski Mateusz    return client.call('bdev_ftl_unmap', params)
14972c7c8b6cSKozlowski Mateusz
14982c7c8b6cSKozlowski Mateusz
14991790ee8aSArtur Paszkiewiczdef bdev_ftl_get_stats(client, name):
15001790ee8aSArtur Paszkiewicz    """get FTL stats
15011790ee8aSArtur Paszkiewicz    Args:
15021790ee8aSArtur Paszkiewicz        name: name of the bdev
15031790ee8aSArtur Paszkiewicz    """
15048feddadaSEugene Kobyak    params = dict()
15058feddadaSEugene Kobyak    params['name'] = name
15061790ee8aSArtur Paszkiewicz    return client.call('bdev_ftl_get_stats', params)
15071790ee8aSArtur Paszkiewicz
15081790ee8aSArtur Paszkiewicz
1509309682caSMateusz Kozlowskidef bdev_ftl_get_properties(client, name):
1510309682caSMateusz Kozlowski    """Get FTL properties
1511309682caSMateusz Kozlowski    Args:
1512309682caSMateusz Kozlowski        name: name of the bdev
1513309682caSMateusz Kozlowski    """
15148feddadaSEugene Kobyak    params = dict()
15158feddadaSEugene Kobyak    params['name'] = name
1516309682caSMateusz Kozlowski    return client.call('bdev_ftl_get_properties', params)
1517309682caSMateusz Kozlowski
1518309682caSMateusz Kozlowski
1519c959f72eSMateusz Kozlowskidef bdev_ftl_set_property(client, name, ftl_property, value):
1520c959f72eSMateusz Kozlowski    """Set FTL property
1521c959f72eSMateusz Kozlowski    Args:
1522c959f72eSMateusz Kozlowski        name: name of the bdev
152360a8d0ceSEugene Kobyak        ftl_property: name of the property to be set
1524c959f72eSMateusz Kozlowski        value: The new value of the updated property
1525c959f72eSMateusz Kozlowski    """
15268feddadaSEugene Kobyak    params = dict()
15278feddadaSEugene Kobyak    params['name'] = name
15288feddadaSEugene Kobyak    params['ftl_property'] = ftl_property
15298feddadaSEugene Kobyak    params['value'] = value
1530c959f72eSMateusz Kozlowski    return client.call('bdev_ftl_set_property', params)
1531c959f72eSMateusz Kozlowski
1532c959f72eSMateusz Kozlowski
15337610bc38SKonrad Sztyberdef bdev_get_bdevs(client, name=None, timeout=None):
15347610bc38SKonrad Sztyber    """Get information about block devices.
15357610bc38SKonrad Sztyber    Args:
15367610bc38SKonrad Sztyber        name: bdev name to query (optional; if omitted, query all bdevs)
15377610bc38SKonrad Sztyber        timeout: time in ms to wait for the bdev with specified name to appear
15387610bc38SKonrad Sztyber    Returns:
15397610bc38SKonrad Sztyber        List of bdev information objects.
15407610bc38SKonrad Sztyber    """
15418feddadaSEugene Kobyak    params = dict()
15428feddadaSEugene Kobyak    if name is not None:
15437610bc38SKonrad Sztyber        params['name'] = name
15448feddadaSEugene Kobyak    if timeout is not None:
15457610bc38SKonrad Sztyber        params['timeout'] = timeout
15467610bc38SKonrad Sztyber    return client.call('bdev_get_bdevs', params)
15477610bc38SKonrad Sztyber
15487610bc38SKonrad Sztyber
154963e0c25dSVasilii Ivanovdef bdev_get_iostat(client, name=None, per_channel=None, reset_mode=None):
15507610bc38SKonrad Sztyber    """Get I/O statistics for block devices.
15517610bc38SKonrad Sztyber    Args:
15527610bc38SKonrad Sztyber        name: bdev name to query (optional; if omitted, query all bdevs)
1553e28e2479SGangCao        per_channel: display per channel IO stats for specified bdev
155463e0c25dSVasilii Ivanov        reset_mode: mode to reset stats after getting: all, maxmin, none (optional: if omitted, no reset will happen)
15557610bc38SKonrad Sztyber    Returns:
15567610bc38SKonrad Sztyber        I/O statistics for the requested block devices.
15577610bc38SKonrad Sztyber    """
15588feddadaSEugene Kobyak    params = dict()
15598feddadaSEugene Kobyak    if name is not None:
15607610bc38SKonrad Sztyber        params['name'] = name
15618feddadaSEugene Kobyak    if per_channel is not None:
1562e28e2479SGangCao        params['per_channel'] = per_channel
156363e0c25dSVasilii Ivanov    if reset_mode is not None:
156463e0c25dSVasilii Ivanov        params['reset_mode'] = reset_mode
15657610bc38SKonrad Sztyber    return client.call('bdev_get_iostat', params)
15667610bc38SKonrad Sztyber
15677610bc38SKonrad Sztyber
1568d7ad7bcaSShuhei Matsumotodef bdev_reset_iostat(client, name=None, mode=None):
1569cf4e8664SShuhei Matsumoto    """Reset I/O statistics for block devices.
1570cf4e8664SShuhei Matsumoto    Args:
1571cf4e8664SShuhei Matsumoto        name: bdev name to reset (optional; if omitted, reset all bdevs)
1572d7ad7bcaSShuhei Matsumoto        mode: mode to reset: all, maxmin (optional: if omitted, reset all fields)
1573cf4e8664SShuhei Matsumoto    """
15748feddadaSEugene Kobyak    params = dict()
15758feddadaSEugene Kobyak    if name is not None:
1576cf4e8664SShuhei Matsumoto        params['name'] = name
15778feddadaSEugene Kobyak    if mode is not None:
1578d7ad7bcaSShuhei Matsumoto        params['mode'] = mode
1579cf4e8664SShuhei Matsumoto    return client.call('bdev_reset_iostat', params)
1580cf4e8664SShuhei Matsumoto
1581cf4e8664SShuhei Matsumoto
1582f3cef5e1SAtul Malakardef bdev_enable_histogram(client, name, enable, opc):
15837610bc38SKonrad Sztyber    """Control whether histogram is enabled for specified bdev.
15847610bc38SKonrad Sztyber    Args:
158560a8d0ceSEugene Kobyak        name: name of bdev
15867b2e6213SEugene Kobyak        enable: Enable or disable histogram on specified device
1587f3cef5e1SAtul Malakar        opc: name of io_type (optional)
15887610bc38SKonrad Sztyber    """
15898feddadaSEugene Kobyak    params = dict()
15908feddadaSEugene Kobyak    params['name'] = name
15918feddadaSEugene Kobyak    params['enable'] = enable
1592f3cef5e1SAtul Malakar    if opc:
1593f3cef5e1SAtul Malakar        params['opc'] = opc
15947610bc38SKonrad Sztyber    return client.call('bdev_enable_histogram', params)
15957610bc38SKonrad Sztyber
15967610bc38SKonrad Sztyber
15977610bc38SKonrad Sztyberdef bdev_get_histogram(client, name):
15987610bc38SKonrad Sztyber    """Get histogram for specified bdev.
15997610bc38SKonrad Sztyber    Args:
160060a8d0ceSEugene Kobyak        name: name of bdev
16017610bc38SKonrad Sztyber    """
16028feddadaSEugene Kobyak    params = dict()
16038feddadaSEugene Kobyak    params['name'] = name
16047610bc38SKonrad Sztyber    return client.call('bdev_get_histogram', params)
16057610bc38SKonrad Sztyber
16067610bc38SKonrad Sztyber
16078feddadaSEugene Kobyakdef bdev_error_inject_error(client, name, io_type, error_type, num=None,
16088feddadaSEugene Kobyak                            queue_depth=None, corrupt_offset=None, corrupt_value=None):
16097610bc38SKonrad Sztyber    """Inject an error via an error bdev.
16107610bc38SKonrad Sztyber    Args:
16117610bc38SKonrad Sztyber        name: name of error bdev
16127610bc38SKonrad Sztyber        io_type: one of "clear", "read", "write", "unmap", "flush", or "all"
1613408a2155SArtur Paszkiewicz        error_type: one of "failure", "pending", "corrupt_data" or "nomem"
16147610bc38SKonrad Sztyber        num: number of commands to fail
16154dacace1SArtur Paszkiewicz        queue_depth: the queue depth at which to trigger the error
16163d2a3ee4SShuhei Matsumoto        corrupt_offset: offset in bytes to xor with corrupt_value
16173d2a3ee4SShuhei Matsumoto        corrupt_value: value for xor (1-255, 0 is invalid)
16187610bc38SKonrad Sztyber    """
16198feddadaSEugene Kobyak    params = dict()
16208feddadaSEugene Kobyak    params['name'] = name
16218feddadaSEugene Kobyak    params['io_type'] = io_type
16228feddadaSEugene Kobyak    params['error_type'] = error_type
16238feddadaSEugene Kobyak    if num is not None:
1624642f8b3dSJaroslaw Chachulski        params['num'] = num
16258feddadaSEugene Kobyak    if queue_depth is not None:
16264dacace1SArtur Paszkiewicz        params['queue_depth'] = queue_depth
16278feddadaSEugene Kobyak    if corrupt_offset is not None:
16283d2a3ee4SShuhei Matsumoto        params['corrupt_offset'] = corrupt_offset
16298feddadaSEugene Kobyak    if corrupt_value is not None:
16303d2a3ee4SShuhei Matsumoto        params['corrupt_value'] = corrupt_value
16317610bc38SKonrad Sztyber    return client.call('bdev_error_inject_error', params)
16327610bc38SKonrad Sztyber
16337610bc38SKonrad Sztyber
16347610bc38SKonrad Sztyberdef bdev_set_qd_sampling_period(client, name, period):
16357610bc38SKonrad Sztyber    """Enable queue depth tracking on a specified bdev.
16367610bc38SKonrad Sztyber    Args:
16377610bc38SKonrad Sztyber        name: name of a bdev on which to track queue depth.
16387610bc38SKonrad Sztyber        period: period (in microseconds) at which to update the queue depth reading. If set to 0, polling will be disabled.
16397610bc38SKonrad Sztyber    """
16408feddadaSEugene Kobyak    params = dict()
16417610bc38SKonrad Sztyber    params['name'] = name
16427610bc38SKonrad Sztyber    params['period'] = period
16437610bc38SKonrad Sztyber    return client.call('bdev_set_qd_sampling_period', params)
16447610bc38SKonrad Sztyber
16457610bc38SKonrad Sztyber
16467610bc38SKonrad Sztyberdef bdev_set_qos_limit(
16477610bc38SKonrad Sztyber        client,
16487610bc38SKonrad Sztyber        name,
16497610bc38SKonrad Sztyber        rw_ios_per_sec=None,
16507610bc38SKonrad Sztyber        rw_mbytes_per_sec=None,
16517610bc38SKonrad Sztyber        r_mbytes_per_sec=None,
16527610bc38SKonrad Sztyber        w_mbytes_per_sec=None):
16537610bc38SKonrad Sztyber    """Set QoS rate limit on a block device.
16547610bc38SKonrad Sztyber    Args:
16557610bc38SKonrad Sztyber        name: name of block device
16567610bc38SKonrad Sztyber        rw_ios_per_sec: R/W IOs per second limit (>=1000, example: 20000). 0 means unlimited.
16577610bc38SKonrad Sztyber        rw_mbytes_per_sec: R/W megabytes per second limit (>=10, example: 100). 0 means unlimited.
16587610bc38SKonrad Sztyber        r_mbytes_per_sec: Read megabytes per second limit (>=10, example: 100). 0 means unlimited.
16597610bc38SKonrad Sztyber        w_mbytes_per_sec: Write megabytes per second limit (>=10, example: 100). 0 means unlimited.
16607610bc38SKonrad Sztyber    """
16618feddadaSEugene Kobyak    params = dict()
16627610bc38SKonrad Sztyber    params['name'] = name
16637610bc38SKonrad Sztyber    if rw_ios_per_sec is not None:
16647610bc38SKonrad Sztyber        params['rw_ios_per_sec'] = rw_ios_per_sec
16657610bc38SKonrad Sztyber    if rw_mbytes_per_sec is not None:
16667610bc38SKonrad Sztyber        params['rw_mbytes_per_sec'] = rw_mbytes_per_sec
16677610bc38SKonrad Sztyber    if r_mbytes_per_sec is not None:
16687610bc38SKonrad Sztyber        params['r_mbytes_per_sec'] = r_mbytes_per_sec
16697610bc38SKonrad Sztyber    if w_mbytes_per_sec is not None:
16707610bc38SKonrad Sztyber        params['w_mbytes_per_sec'] = w_mbytes_per_sec
16717610bc38SKonrad Sztyber    return client.call('bdev_set_qos_limit', params)
16727610bc38SKonrad Sztyber
16737610bc38SKonrad Sztyber
16747610bc38SKonrad Sztyberdef bdev_nvme_apply_firmware(client, bdev_name, filename):
16757610bc38SKonrad Sztyber    """Download and commit firmware to NVMe device.
16767610bc38SKonrad Sztyber    Args:
16777610bc38SKonrad Sztyber        bdev_name: name of NVMe block device
16787610bc38SKonrad Sztyber        filename: filename of the firmware to download
16797610bc38SKonrad Sztyber    """
16808feddadaSEugene Kobyak    params = dict()
16818feddadaSEugene Kobyak    params['bdev_name'] = bdev_name
168260a8d0ceSEugene Kobyak    params['filename'] = filename
16837610bc38SKonrad Sztyber    return client.call('bdev_nvme_apply_firmware', params)
16847610bc38SKonrad Sztyber
16857610bc38SKonrad Sztyber
16867610bc38SKonrad Sztyberdef bdev_nvme_get_transport_statistics(client):
16877610bc38SKonrad Sztyber    """Get bdev_nvme poll group transport statistics"""
16887610bc38SKonrad Sztyber    return client.call('bdev_nvme_get_transport_statistics')
16897610bc38SKonrad Sztyber
16907610bc38SKonrad Sztyber
16917610bc38SKonrad Sztyberdef bdev_nvme_get_controller_health_info(client, name):
16927610bc38SKonrad Sztyber    """Display health log of the required NVMe bdev controller.
16937610bc38SKonrad Sztyber    Args:
16947610bc38SKonrad Sztyber        name: name of the required NVMe bdev controller
16957610bc38SKonrad Sztyber    Returns:
16967610bc38SKonrad Sztyber        Health log for the requested NVMe bdev controller.
16977610bc38SKonrad Sztyber    """
16988feddadaSEugene Kobyak    params = dict()
16997610bc38SKonrad Sztyber    params['name'] = name
17007610bc38SKonrad Sztyber    return client.call('bdev_nvme_get_controller_health_info', params)
17012e283fcbS0xe0f
17022e283fcbS0xe0f
17033d7851e0SDenis Barakhtanovdef bdev_daos_create(client, num_blocks, block_size, pool, cont, name, oclass=None, uuid=None):
17042e283fcbS0xe0f    """Construct DAOS block device.
17052e283fcbS0xe0f    Args:
17062e283fcbS0xe0f        num_blocks: size of block device in blocks
17072e283fcbS0xe0f        block_size: block size of device; must be a power of 2 and at least 512
17082e283fcbS0xe0f        pool: UUID of DAOS pool
17092e283fcbS0xe0f        cont: UUID of DAOS container
171060a8d0ceSEugene Kobyak        name: name of block device (also the name of the backend file on DAOS DFS)
17113d7851e0SDenis Barakhtanov        oclass: DAOS object class (optional)
171260a8d0ceSEugene Kobyak        uuid: UUID of block device (optional)
17132e283fcbS0xe0f    Returns:
17142e283fcbS0xe0f        Name of created block device.
17152e283fcbS0xe0f    """
17168feddadaSEugene Kobyak    params = dict()
17178feddadaSEugene Kobyak    params['num_blocks'] = num_blocks
17188feddadaSEugene Kobyak    params['block_size'] = block_size
17198feddadaSEugene Kobyak    params['pool'] = pool
17208feddadaSEugene Kobyak    params['cont'] = cont
17218feddadaSEugene Kobyak    params['name'] = name
17228feddadaSEugene Kobyak    if oclass is not None:
17233d7851e0SDenis Barakhtanov        params['oclass'] = oclass
172460a8d0ceSEugene Kobyak    if uuid is not None:
172560a8d0ceSEugene Kobyak        params['uuid'] = uuid
17262e283fcbS0xe0f    return client.call('bdev_daos_create', params)
17272e283fcbS0xe0f
17282e283fcbS0xe0f
17292e283fcbS0xe0fdef bdev_daos_delete(client, name):
17302e283fcbS0xe0f    """Delete DAOS block device.
17312e283fcbS0xe0f    Args:
17322e283fcbS0xe0f        bdev_name: name of DAOS bdev to delete
17332e283fcbS0xe0f    """
17348feddadaSEugene Kobyak    params = dict()
17358feddadaSEugene Kobyak    params['name'] = name
17362e283fcbS0xe0f    return client.call('bdev_daos_delete', params)
1737bdc683aaSDenis Barakhtanov
1738bdc683aaSDenis Barakhtanov
1739bdc683aaSDenis Barakhtanovdef bdev_daos_resize(client, name, new_size):
1740bdc683aaSDenis Barakhtanov    """Resize DAOS bdev in the system.
1741bdc683aaSDenis Barakhtanov    Args:
1742bdc683aaSDenis Barakhtanov        name: name of DAOS bdev to resize
1743bdc683aaSDenis Barakhtanov        new_size: new bdev size of resize operation. The unit is MiB
1744bdc683aaSDenis Barakhtanov    """
17458feddadaSEugene Kobyak    params = dict()
17468feddadaSEugene Kobyak    params['name'] = name
17478feddadaSEugene Kobyak    params['new_size'] = new_size
1748bdc683aaSDenis Barakhtanov    return client.call('bdev_daos_resize', params)
17492796687dSParameswaran Krishnamurthy
17502796687dSParameswaran Krishnamurthy
17512796687dSParameswaran Krishnamurthydef bdev_nvme_start_mdns_discovery(client, name, svcname, hostnqn=None):
17522796687dSParameswaran Krishnamurthy    """Start discovery with mDNS
17532796687dSParameswaran Krishnamurthy    Args:
17542796687dSParameswaran Krishnamurthy        name: bdev name prefix; "n" + unique seqno + namespace ID will be appended to create unique names
17552796687dSParameswaran Krishnamurthy        svcname: service to discover ("_nvme-disc._tcp")
17562796687dSParameswaran Krishnamurthy        hostnqn: NQN to connect from (optional)
17572796687dSParameswaran Krishnamurthy    """
17588feddadaSEugene Kobyak    params = dict()
17598feddadaSEugene Kobyak    params['name'] = name
17608feddadaSEugene Kobyak    params['svcname'] = svcname
17618feddadaSEugene Kobyak    if hostnqn is not None:
17622796687dSParameswaran Krishnamurthy        params['hostnqn'] = hostnqn
17632796687dSParameswaran Krishnamurthy    return client.call('bdev_nvme_start_mdns_discovery', params)
17642796687dSParameswaran Krishnamurthy
17652796687dSParameswaran Krishnamurthy
17662796687dSParameswaran Krishnamurthydef bdev_nvme_stop_mdns_discovery(client, name):
17672796687dSParameswaran Krishnamurthy    """Stop a previously started mdns discovery service
17682796687dSParameswaran Krishnamurthy    Args:
17692796687dSParameswaran Krishnamurthy        name: name of the discovery service to stop
17702796687dSParameswaran Krishnamurthy    """
17718feddadaSEugene Kobyak    params = dict()
17728feddadaSEugene Kobyak    params['name'] = name
17732796687dSParameswaran Krishnamurthy    return client.call('bdev_nvme_stop_mdns_discovery', params)
17742796687dSParameswaran Krishnamurthy
17752796687dSParameswaran Krishnamurthy
17762796687dSParameswaran Krishnamurthydef bdev_nvme_get_mdns_discovery_info(client):
17772796687dSParameswaran Krishnamurthy    """Get information about the automatic mdns discovery
17782796687dSParameswaran Krishnamurthy    """
17792796687dSParameswaran Krishnamurthy    return client.call('bdev_nvme_get_mdns_discovery_info')
1780